mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Moving dirty editor handling out of uploadMgr
issue #1327 - just moved to be in editor obj, everything else is the same
This commit is contained in:
parent
340206fa4b
commit
3fd3102486
1 changed files with 11 additions and 16 deletions
|
@ -448,8 +448,16 @@
|
|||
return this.uploadMgr.getEditorValue();
|
||||
},
|
||||
|
||||
unloadDirtyMessage: function () {
|
||||
return "==============================\n\n" +
|
||||
"Hey there! It looks like you're in the middle of writing" +
|
||||
" something and you haven't saved all of your content." +
|
||||
"\n\nSave before you go!\n\n" +
|
||||
"==============================";
|
||||
},
|
||||
|
||||
setEditorDirty: function (dirty) {
|
||||
return this.uploadMgr.setEditorDirty(dirty);
|
||||
window.onbeforeunload = dirty ? this.unloadDirtyMessage : null;
|
||||
},
|
||||
|
||||
initUploads: function () {
|
||||
|
@ -465,6 +473,7 @@
|
|||
var self = this;
|
||||
this.editor.setOption("readOnly", false);
|
||||
this.editor.on('change', function () {
|
||||
self.setEditorDirty(true);
|
||||
self.renderPreview();
|
||||
});
|
||||
},
|
||||
|
@ -662,30 +671,16 @@
|
|||
return value;
|
||||
}
|
||||
|
||||
function unloadDirtyMessage() {
|
||||
return "==============================\n\n" +
|
||||
"Hey there! It looks like you're in the middle of writing" +
|
||||
" something and you haven't saved all of your content." +
|
||||
"\n\nSave before you go!\n\n" +
|
||||
"==============================";
|
||||
}
|
||||
|
||||
function setEditorDirty(dirty) {
|
||||
window.onbeforeunload = dirty ? unloadDirtyMessage : null;
|
||||
}
|
||||
|
||||
// Public API
|
||||
_.extend(this, {
|
||||
getEditorValue: getEditorValue,
|
||||
handleUpload: handleUpload,
|
||||
setEditorDirty: setEditorDirty
|
||||
handleUpload: handleUpload
|
||||
});
|
||||
|
||||
// initialise
|
||||
editor.on('change', function (cm, changeObj) {
|
||||
/*jslint unparam:true*/
|
||||
setEditorDirty(true);
|
||||
|
||||
var linesChanged = _.range(changeObj.from.line, changeObj.from.line + changeObj.text.length);
|
||||
|
||||
_.each(linesChanged, function (ln) {
|
||||
|
|
Loading…
Reference in a new issue