Mercurial Hosting > sceditor
diff src/plugins/autosave.js @ 29:ea32a44b5a6e
remove more oo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 11 Aug 2022 19:54:03 -0600 |
parents | b7725dab7482 |
children |
line wrap: on
line diff
--- a/src/plugins/autosave.js Thu Aug 11 00:04:48 2022 -0600 +++ b/src/plugins/autosave.js Thu Aug 11 19:54:03 2022 -0600 @@ -19,7 +19,7 @@ } sceditor.plugins.autosave = function () { - var base = this; + var base = {}; var editor; var isLoading = false; var storageKey = defaultKey; @@ -45,8 +45,8 @@ } } - base.init = function () { - editor = this; + base.init = function (ed) { + editor = ed; var opts = editor.opts && editor.opts.autosave || {}; saveHandler = opts.save || saveHandler; @@ -57,13 +57,13 @@ gc(); }; - base.signalReady = function () { + base.signalReady = function (editor) { // Add submit event listener to clear autosave var parent = editor.getContentAreaContainer(); while (parent) { if (/form/i.test(parent.nodeName)) { parent.addEventListener( - 'submit', clear.bind(null, storageKey), true + 'submit', function(){clear(storageKey)}, true ); break; } @@ -86,24 +86,26 @@ isLoading = false; } else { saveHandler({ - caret: this.sourceEditorCaret(), - sourceMode: this.sourceMode(), + caret: editor.sourceEditorCaret(), + sourceMode: editor.sourceMode(), value: editor.val(null, false), time: Date.now() }); } }; - base.signalValuechangedEvent = function (e) { + base.signalValuechangedEvent = function (editor, e) { if (!isLoading) { saveHandler({ - caret: this.sourceEditorCaret(), - sourceMode: this.sourceMode(), + caret: editor.sourceEditorCaret(), + sourceMode: editor.sourceMode(), value: e.detail.rawValue, time: Date.now() }); } }; + + return base; }; sceditor.plugins.autosave.clear = clear;