From: Alexander Ebert Date: Tue, 6 Jan 2015 00:33:57 +0000 (+0100) Subject: Show 'Draft saved' message only once every 2 minutes if content has been modified X-Git-Tag: 2.1.0_Beta_3~27 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=92cf7b67651d6a5f90267e35b38c0b632a2666a9;p=GitHub%2FWoltLab%2FWCF.git Show 'Draft saved' message only once every 2 minutes if content has been modified --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index ae9d010baf..329003eb2c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -12,6 +12,8 @@ RedactorPlugins.wutil = function() { var $autosaveLastMessage = ''; var $autosaveNotice = null; + var $autosaveDidSave = false; + var $autosaveSaveNoticePE = null; return { /** @@ -276,7 +278,9 @@ RedactorPlugins.wutil = function() { if (this.wutil._autosaveWorker === null) { this.wutil.autosavePurgeOutdated(); - this.wutil._autosaveWorker = new WCF.PeriodicalExecuter($.proxy(this.wutil.saveTextToStorage, this), 15 * 1000); + this.wutil._autosaveWorker = new WCF.PeriodicalExecuter((function(pe) { + this.wutil.saveTextToStorage(false); + }).bind(this), 15 * 1000); } return true; @@ -299,8 +303,21 @@ RedactorPlugins.wutil = function() { timestamp: Date.now() })); $autosaveLastMessage = $content; + $autosaveDidSave = true; - this.wutil.autosaveShowNotice('saved'); + if ($autosaveSaveNoticePE === null) { + $autosaveSaveNoticePE = new WCF.PeriodicalExecuter((function(pe) { + if ($autosaveDidSave === false) { + pe.stop(); + $autosaveSaveNoticePE = null; + + return; + } + + this.wutil.autosaveShowNotice('saved'); + $autosaveDidSave = false; + }).bind(this), 120 * 1000); + } } catch (e) { console.debug("[wutil.saveTextToStorage] Unable to access local storage: " + e.message);