Refactoring
This commit is contained in:
7
web/bower_components/tinymce/plugins/save/index.js
vendored
Normal file
7
web/bower_components/tinymce/plugins/save/index.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Exports the "save" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/save')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/save'
|
||||
require('./plugin.js');
|
||||
98
web/bower_components/tinymce/plugins/save/plugin.js
vendored
Normal file
98
web/bower_components/tinymce/plugins/save/plugin.js
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2015 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true */
|
||||
|
||||
tinymce.PluginManager.add('save', function(editor) {
|
||||
function save() {
|
||||
var formObj;
|
||||
|
||||
formObj = tinymce.DOM.getParent(editor.id, 'form');
|
||||
|
||||
if (editor.getParam("save_enablewhendirty", true) && !editor.isDirty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
tinymce.triggerSave();
|
||||
|
||||
// Use callback instead
|
||||
if (editor.getParam("save_onsavecallback")) {
|
||||
editor.execCallback('save_onsavecallback', editor);
|
||||
editor.nodeChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
if (formObj) {
|
||||
editor.setDirty(false);
|
||||
|
||||
if (!formObj.onsubmit || formObj.onsubmit()) {
|
||||
if (typeof formObj.submit == "function") {
|
||||
formObj.submit();
|
||||
} else {
|
||||
displayErrorMessage(editor.translate("Error: Form submit field collision."));
|
||||
}
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
} else {
|
||||
displayErrorMessage(editor.translate("Error: No form element found."));
|
||||
}
|
||||
}
|
||||
|
||||
function displayErrorMessage(message) {
|
||||
editor.notificationManager.open({
|
||||
text: message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
var h = tinymce.trim(editor.startContent);
|
||||
|
||||
// Use callback instead
|
||||
if (editor.getParam("save_oncancelcallback")) {
|
||||
editor.execCallback('save_oncancelcallback', editor);
|
||||
return;
|
||||
}
|
||||
|
||||
editor.setContent(h);
|
||||
editor.undoManager.clear();
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
function stateToggle() {
|
||||
var self = this;
|
||||
|
||||
editor.on('nodeChange dirty', function() {
|
||||
self.disabled(editor.getParam("save_enablewhendirty", true) && !editor.isDirty());
|
||||
});
|
||||
}
|
||||
|
||||
editor.addCommand('mceSave', save);
|
||||
editor.addCommand('mceCancel', cancel);
|
||||
|
||||
editor.addButton('save', {
|
||||
icon: 'save',
|
||||
text: 'Save',
|
||||
cmd: 'mceSave',
|
||||
disabled: true,
|
||||
onPostRender: stateToggle
|
||||
});
|
||||
|
||||
editor.addButton('cancel', {
|
||||
text: 'Cancel',
|
||||
icon: false,
|
||||
cmd: 'mceCancel',
|
||||
disabled: true,
|
||||
onPostRender: stateToggle
|
||||
});
|
||||
|
||||
editor.addShortcut('Meta+S', '', 'mceSave');
|
||||
});
|
||||
1
web/bower_components/tinymce/plugins/save/plugin.min.js
vendored
Normal file
1
web/bower_components/tinymce/plugins/save/plugin.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("save",function(e){function t(){var t;if(t=tinymce.DOM.getParent(e.id,"form"),!e.getParam("save_enablewhendirty",!0)||e.isDirty())return tinymce.triggerSave(),e.getParam("save_onsavecallback")?(e.execCallback("save_onsavecallback",e),void e.nodeChanged()):void(t?(e.setDirty(!1),t.onsubmit&&!t.onsubmit()||("function"==typeof t.submit?t.submit():n(e.translate("Error: Form submit field collision."))),e.nodeChanged()):n(e.translate("Error: No form element found.")))}function n(t){e.notificationManager.open({text:t,type:"error"})}function r(){var t=tinymce.trim(e.startContent);return e.getParam("save_oncancelcallback")?void e.execCallback("save_oncancelcallback",e):(e.setContent(t),e.undoManager.clear(),void e.nodeChanged())}function i(){var t=this;e.on("nodeChange dirty",function(){t.disabled(e.getParam("save_enablewhendirty",!0)&&!e.isDirty())})}e.addCommand("mceSave",t),e.addCommand("mceCancel",r),e.addButton("save",{icon:"save",text:"Save",cmd:"mceSave",disabled:!0,onPostRender:i}),e.addButton("cancel",{text:"Cancel",icon:!1,cmd:"mceCancel",disabled:!0,onPostRender:i}),e.addShortcut("Meta+S","","mceSave")});
|
||||
Reference in New Issue
Block a user