diff --git a/Resources/Plugins/edit-design/browser.js b/Resources/Plugins/edit-design/browser.js index f8b73ef3..2ffdc881 100644 --- a/Resources/Plugins/edit-design/browser.js +++ b/Resources/Plugins/edit-design/browser.js @@ -238,7 +238,7 @@ enabled(){ _render: () => $(this.htmlModal), destroy: function(){ if (this.reloadPage){ - location.reload(); + window.TDPF_requestReload(); return; } @@ -257,7 +257,7 @@ enabled(){ }; TD.decider.updateForGuestId(); - this.$pluginSettings.requiresPageReload = enable; + this.$requiresReload = enable; }; // animation optimization diff --git a/Resources/Scripts/plugins.browser.js b/Resources/Scripts/plugins.browser.js index 36c27ee7..78c89b0c 100644 --- a/Resources/Scripts/plugins.browser.js +++ b/Resources/Scripts/plugins.browser.js @@ -1,12 +1,14 @@ (function(){ + var isReloading = false; + // // Class: Abstract plugin base class. // window.PluginBase = class{ constructor(pluginSettings){ - this.$pluginSettings = pluginSettings || {}; + this.$requiresReload = !!(pluginSettings && pluginSettings.requiresPageReload); } - + enabled(){} ready(){} disabled(){} @@ -49,11 +51,11 @@ } setState(plugin, enable){ - let reloading = plugin.obj.$pluginSettings.requiresPageReload; + let reloading = plugin.obj.$requiresReload; if (enable && this.isDisabled(plugin)){ if (reloading){ - location.reload(); + window.TDPF_requestReload(); } else{ this.disabled.splice(this.disabled.indexOf(plugin.id), 1); @@ -63,7 +65,7 @@ } else if (!enable && !this.isDisabled(plugin)){ if (reloading){ - location.reload(); + window.TDPF_requestReload(); } else{ this.disabled.push(plugin.id); @@ -84,4 +86,14 @@ window.TDPF_setPluginState = function(identifier, enable){ window.TD_PLUGINS.setState(window.TD_PLUGINS.findObject(identifier), enable); }; -})(); \ No newline at end of file + + // + // Block: Setup global function to reload the page. + // + window.TDPF_requestReload = function(){ + if (!isReloading){ + window.setTimeout(() => location.reload(), 1); + isReloading = true; + } + }; +})(); diff --git a/Resources/Scripts/plugins.js b/Resources/Scripts/plugins.js index 38103d61..9bde979a 100644 --- a/Resources/Scripts/plugins.js +++ b/Resources/Scripts/plugins.js @@ -51,4 +51,4 @@ obj.element = element; return obj; }; -})($TDP); \ No newline at end of file +})($TDP); diff --git a/Resources/Scripts/plugins.notification.js b/Resources/Scripts/plugins.notification.js index cc801c7a..2474b485 100644 --- a/Resources/Scripts/plugins.notification.js +++ b/Resources/Scripts/plugins.notification.js @@ -1,21 +1,16 @@ -(function(){ - // - // Class: Abstract plugin base class. - // - window.PluginBase = class{ - constructor(pluginSettings){ - this.$pluginSettings = pluginSettings || {}; - } +// +// Class: Abstract plugin base class. +// +window.PluginBase = class{ + constructor(){} + run(){} +}; - run(){} - }; - - // - // Variable: Main object for containing and managing plugins. - // - window.TD_PLUGINS = { - install: function(plugin){ - plugin.obj.run(); - } - }; -})(); \ No newline at end of file +// +// Variable: Main object for containing and managing plugins. +// +window.TD_PLUGINS = { + install: function(plugin){ + plugin.obj.run(); + } +};