MDL-52954 atto: Stop autosave timer, when editor no-longer exists.
This commit is contained in:
+15
-1
@@ -820,6 +820,14 @@ EditorAutosave.prototype = {
|
||||
*/
|
||||
autosaveInstance: null,
|
||||
|
||||
/**
|
||||
* Autosave Timer.
|
||||
*
|
||||
* @property autosaveTimer
|
||||
* @type object
|
||||
*/
|
||||
autosaveTimer: null,
|
||||
|
||||
/**
|
||||
* Initialize the autosave process
|
||||
*
|
||||
@@ -904,7 +912,7 @@ EditorAutosave.prototype = {
|
||||
// Now setup the timer for periodic saves.
|
||||
|
||||
var delay = parseInt(this.get('autosaveFrequency'), 10) * 1000;
|
||||
Y.later(delay, this, this.saveDraft, false, true);
|
||||
this.autosaveTimer = Y.later(delay, this, this.saveDraft, false, true);
|
||||
|
||||
// Now setup the listener for form submission.
|
||||
form = this.textarea.ancestor('form');
|
||||
@@ -968,6 +976,12 @@ EditorAutosave.prototype = {
|
||||
*/
|
||||
saveDraft: function() {
|
||||
var url, params;
|
||||
|
||||
if (!this.editor.getDOMNode()) {
|
||||
// Stop autosaving if the editor was removed from the page.
|
||||
this.autosaveTimer.cancel();
|
||||
return;
|
||||
}
|
||||
// Only copy the text from the div to the textarea if the textarea is not currently visible.
|
||||
if (!this.editor.get('hidden')) {
|
||||
this.updateOriginal();
|
||||
|
||||
+3
-3
File diff suppressed because one or more lines are too long
+15
-1
@@ -815,6 +815,14 @@ EditorAutosave.prototype = {
|
||||
*/
|
||||
autosaveInstance: null,
|
||||
|
||||
/**
|
||||
* Autosave Timer.
|
||||
*
|
||||
* @property autosaveTimer
|
||||
* @type object
|
||||
*/
|
||||
autosaveTimer: null,
|
||||
|
||||
/**
|
||||
* Initialize the autosave process
|
||||
*
|
||||
@@ -897,7 +905,7 @@ EditorAutosave.prototype = {
|
||||
// Now setup the timer for periodic saves.
|
||||
|
||||
var delay = parseInt(this.get('autosaveFrequency'), 10) * 1000;
|
||||
Y.later(delay, this, this.saveDraft, false, true);
|
||||
this.autosaveTimer = Y.later(delay, this, this.saveDraft, false, true);
|
||||
|
||||
// Now setup the listener for form submission.
|
||||
form = this.textarea.ancestor('form');
|
||||
@@ -961,6 +969,12 @@ EditorAutosave.prototype = {
|
||||
*/
|
||||
saveDraft: function() {
|
||||
var url, params;
|
||||
|
||||
if (!this.editor.getDOMNode()) {
|
||||
// Stop autosaving if the editor was removed from the page.
|
||||
this.autosaveTimer.cancel();
|
||||
return;
|
||||
}
|
||||
// Only copy the text from the div to the textarea if the textarea is not currently visible.
|
||||
if (!this.editor.get('hidden')) {
|
||||
this.updateOriginal();
|
||||
|
||||
+15
-1
@@ -99,6 +99,14 @@ EditorAutosave.prototype = {
|
||||
*/
|
||||
autosaveInstance: null,
|
||||
|
||||
/**
|
||||
* Autosave Timer.
|
||||
*
|
||||
* @property autosaveTimer
|
||||
* @type object
|
||||
*/
|
||||
autosaveTimer: null,
|
||||
|
||||
/**
|
||||
* Initialize the autosave process
|
||||
*
|
||||
@@ -183,7 +191,7 @@ EditorAutosave.prototype = {
|
||||
// Now setup the timer for periodic saves.
|
||||
|
||||
var delay = parseInt(this.get('autosaveFrequency'), 10) * 1000;
|
||||
Y.later(delay, this, this.saveDraft, false, true);
|
||||
this.autosaveTimer = Y.later(delay, this, this.saveDraft, false, true);
|
||||
|
||||
// Now setup the listener for form submission.
|
||||
form = this.textarea.ancestor('form');
|
||||
@@ -247,6 +255,12 @@ EditorAutosave.prototype = {
|
||||
*/
|
||||
saveDraft: function() {
|
||||
var url, params;
|
||||
|
||||
if (!this.editor.getDOMNode()) {
|
||||
// Stop autosaving if the editor was removed from the page.
|
||||
this.autosaveTimer.cancel();
|
||||
return;
|
||||
}
|
||||
// Only copy the text from the div to the textarea if the textarea is not currently visible.
|
||||
if (!this.editor.get('hidden')) {
|
||||
this.updateOriginal();
|
||||
|
||||
Reference in New Issue
Block a user