mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Add files via upload
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
@@ -19,279 +19,304 @@
|
||||
* - No editor.onEvent
|
||||
* - Can't cancel execCommands with beforeExecCommand
|
||||
*/
|
||||
(function(tinymce) {
|
||||
var reported;
|
||||
(function (tinymce) {
|
||||
var reported;
|
||||
|
||||
function noop() {
|
||||
}
|
||||
function noop() {
|
||||
}
|
||||
|
||||
function log(apiCall) {
|
||||
if (!reported && window && window.console) {
|
||||
reported = true;
|
||||
console.log("Deprecated TinyMCE API call: " + apiCall);
|
||||
}
|
||||
}
|
||||
function log(apiCall) {
|
||||
if (!reported && window && window.console) {
|
||||
reported = true;
|
||||
console.log("Deprecated TinyMCE API call: " + apiCall);
|
||||
}
|
||||
}
|
||||
|
||||
function Dispatcher(target, newEventName, argsMap, defaultScope) {
|
||||
target = target || this;
|
||||
function Dispatcher(target, newEventName, argsMap, defaultScope) {
|
||||
target = target || this;
|
||||
var cbs = [];
|
||||
|
||||
if (!newEventName) {
|
||||
this.add = this.addToTop = this.remove = this.dispatch = noop;
|
||||
return;
|
||||
}
|
||||
if (!newEventName) {
|
||||
this.add = this.addToTop = this.remove = this.dispatch = noop;
|
||||
return;
|
||||
}
|
||||
|
||||
this.add = function(callback, scope, prepend) {
|
||||
log('<target>.on' + newEventName + ".add(..)");
|
||||
this.add = function (callback, scope, prepend) {
|
||||
log('<target>.on' + newEventName + ".add(..)");
|
||||
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2)
|
||||
function patchedEventCallback(e) {
|
||||
var callbackArgs = [];
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2)
|
||||
function patchedEventCallback(e) {
|
||||
var callbackArgs = [];
|
||||
|
||||
if (typeof argsMap == "string") {
|
||||
argsMap = argsMap.split(" ");
|
||||
}
|
||||
if (typeof argsMap == "string") {
|
||||
argsMap = argsMap.split(" ");
|
||||
}
|
||||
|
||||
if (argsMap && typeof argsMap != "function") {
|
||||
for (var i = 0; i < argsMap.length; i++) {
|
||||
callbackArgs.push(e[argsMap[i]]);
|
||||
}
|
||||
}
|
||||
if (argsMap && typeof argsMap !== "function") {
|
||||
for (var i = 0; i < argsMap.length; i++) {
|
||||
callbackArgs.push(e[argsMap[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof argsMap == "function") {
|
||||
callbackArgs = argsMap(newEventName, e, target);
|
||||
if (!callbackArgs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (typeof argsMap == "function") {
|
||||
callbackArgs = argsMap(newEventName, e, target);
|
||||
if (!callbackArgs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!argsMap) {
|
||||
callbackArgs = [e];
|
||||
}
|
||||
if (!argsMap) {
|
||||
callbackArgs = [e];
|
||||
}
|
||||
|
||||
callbackArgs.unshift(defaultScope || target);
|
||||
callbackArgs.unshift(defaultScope || target);
|
||||
|
||||
if (callback.apply(scope || defaultScope || target, callbackArgs) === false) {
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
if (callback.apply(scope || defaultScope || target, callbackArgs) === false) {
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
target.on(newEventName, patchedEventCallback, prepend);
|
||||
target.on(newEventName, patchedEventCallback, prepend);
|
||||
|
||||
return patchedEventCallback;
|
||||
};
|
||||
var handlers = {
|
||||
original: callback,
|
||||
patched: patchedEventCallback
|
||||
};
|
||||
|
||||
this.addToTop = function(callback, scope) {
|
||||
this.add(callback, scope, true);
|
||||
};
|
||||
cbs.push(handlers);
|
||||
return patchedEventCallback;
|
||||
};
|
||||
|
||||
this.remove = function(callback) {
|
||||
return target.off(newEventName, callback);
|
||||
};
|
||||
this.addToTop = function (callback, scope) {
|
||||
this.add(callback, scope, true);
|
||||
};
|
||||
|
||||
this.dispatch = function() {
|
||||
target.fire(newEventName);
|
||||
this.remove = function (callback) {
|
||||
cbs.forEach(function (item, i) {
|
||||
if (item.original === callback) {
|
||||
cbs.splice(i, 1);
|
||||
return target.off(newEventName, item.patched);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return target.off(newEventName, callback);
|
||||
};
|
||||
|
||||
tinymce.util.Dispatcher = Dispatcher;
|
||||
tinymce.onBeforeUnload = new Dispatcher(tinymce, "BeforeUnload");
|
||||
tinymce.onAddEditor = new Dispatcher(tinymce, "AddEditor", "editor");
|
||||
tinymce.onRemoveEditor = new Dispatcher(tinymce, "RemoveEditor", "editor");
|
||||
this.dispatch = function () {
|
||||
target.fire(newEventName);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
tinymce.util.Cookie = {
|
||||
get: noop, getHash: noop, remove: noop, set: noop, setHash: noop
|
||||
};
|
||||
tinymce.util.Dispatcher = Dispatcher;
|
||||
tinymce.onBeforeUnload = new Dispatcher(tinymce, "BeforeUnload");
|
||||
tinymce.onAddEditor = new Dispatcher(tinymce, "AddEditor", "editor");
|
||||
tinymce.onRemoveEditor = new Dispatcher(tinymce, "RemoveEditor", "editor");
|
||||
|
||||
function patchEditor(editor) {
|
||||
function patchEditorEvents(oldEventNames, argsMap) {
|
||||
tinymce.each(oldEventNames.split(" "), function(oldName) {
|
||||
editor["on" + oldName] = new Dispatcher(editor, oldName, argsMap);
|
||||
});
|
||||
}
|
||||
tinymce.util.Cookie = {
|
||||
get: noop, getHash: noop, remove: noop, set: noop, setHash: noop
|
||||
};
|
||||
|
||||
function convertUndoEventArgs(type, event, target) {
|
||||
return [
|
||||
event.level,
|
||||
target
|
||||
];
|
||||
}
|
||||
function patchEditor(editor) {
|
||||
|
||||
function filterSelectionEvents(needsSelection) {
|
||||
return function(type, e) {
|
||||
if ((!e.selection && !needsSelection) || e.selection == needsSelection) {
|
||||
return [e];
|
||||
}
|
||||
};
|
||||
}
|
||||
function translate(str) {
|
||||
var prefix = editor.settings.language || "en";
|
||||
var prefixedStr = [prefix, str].join('.');
|
||||
var translatedStr = tinymce.i18n.translate(prefixedStr);
|
||||
|
||||
if (editor.controlManager) {
|
||||
return;
|
||||
}
|
||||
return prefixedStr !== translatedStr ? translatedStr : tinymce.i18n.translate(str);
|
||||
}
|
||||
|
||||
function cmNoop() {
|
||||
var obj = {}, methods = 'add addMenu addSeparator collapse createMenu destroy displayColor expand focus ' +
|
||||
'getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark ' +
|
||||
'postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex ' +
|
||||
'setActive setAriaProperty setColor setDisabled setSelected setState showMenu update';
|
||||
function patchEditorEvents(oldEventNames, argsMap) {
|
||||
tinymce.each(oldEventNames.split(" "), function (oldName) {
|
||||
editor["on" + oldName] = new Dispatcher(editor, oldName, argsMap);
|
||||
});
|
||||
}
|
||||
|
||||
log('editor.controlManager.*');
|
||||
function convertUndoEventArgs(type, event, target) {
|
||||
return [
|
||||
event.level,
|
||||
target
|
||||
];
|
||||
}
|
||||
|
||||
function _noop() {
|
||||
return cmNoop();
|
||||
}
|
||||
function filterSelectionEvents(needsSelection) {
|
||||
return function (type, e) {
|
||||
if ((!e.selection && !needsSelection) || e.selection == needsSelection) {
|
||||
return [e];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
tinymce.each(methods.split(' '), function(method) {
|
||||
obj[method] = _noop;
|
||||
});
|
||||
if (editor.controlManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
function cmNoop() {
|
||||
var obj = {}, methods = 'add addMenu addSeparator collapse createMenu destroy displayColor expand focus ' +
|
||||
'getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark ' +
|
||||
'postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex ' +
|
||||
'setActive setAriaProperty setColor setDisabled setSelected setState showMenu update';
|
||||
|
||||
editor.controlManager = {
|
||||
buttons: {},
|
||||
log('editor.controlManager.*');
|
||||
|
||||
setDisabled: function(name, state) {
|
||||
log("controlManager.setDisabled(..)");
|
||||
function _noop() {
|
||||
return cmNoop();
|
||||
}
|
||||
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].disabled(state);
|
||||
}
|
||||
},
|
||||
tinymce.each(methods.split(' '), function (method) {
|
||||
obj[method] = _noop;
|
||||
});
|
||||
|
||||
setActive: function(name, state) {
|
||||
log("controlManager.setActive(..)");
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].active(state);
|
||||
}
|
||||
},
|
||||
editor.controlManager = {
|
||||
buttons: {},
|
||||
|
||||
onAdd: new Dispatcher(),
|
||||
onPostRender: new Dispatcher(),
|
||||
setDisabled: function (name, state) {
|
||||
log("controlManager.setDisabled(..)");
|
||||
|
||||
add: function(obj) {
|
||||
return obj;
|
||||
},
|
||||
createButton: cmNoop,
|
||||
createColorSplitButton: cmNoop,
|
||||
createControl: cmNoop,
|
||||
createDropMenu: cmNoop,
|
||||
createListBox: cmNoop,
|
||||
createMenuButton: cmNoop,
|
||||
createSeparator: cmNoop,
|
||||
createSplitButton: cmNoop,
|
||||
createToolbar: cmNoop,
|
||||
createToolbarGroup: cmNoop,
|
||||
destroy: noop,
|
||||
get: noop,
|
||||
setControlType: cmNoop
|
||||
};
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].disabled(state);
|
||||
}
|
||||
},
|
||||
|
||||
patchEditorEvents("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate", "editor");
|
||||
patchEditorEvents("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset");
|
||||
patchEditorEvents("BeforeExecCommand ExecCommand", "command ui value args"); // args.terminate not supported
|
||||
patchEditorEvents("PreProcess PostProcess LoadContent SaveContent Change");
|
||||
patchEditorEvents("BeforeSetContent BeforeGetContent SetContent GetContent", filterSelectionEvents(false));
|
||||
patchEditorEvents("SetProgressState", "state time");
|
||||
patchEditorEvents("VisualAid", "element hasVisual");
|
||||
patchEditorEvents("Undo Redo", convertUndoEventArgs);
|
||||
setActive: function (name, state) {
|
||||
log("controlManager.setActive(..)");
|
||||
|
||||
patchEditorEvents("NodeChange", function(type, e) {
|
||||
return [
|
||||
editor.controlManager,
|
||||
e.element,
|
||||
editor.selection.isCollapsed(),
|
||||
e
|
||||
];
|
||||
});
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].active(state);
|
||||
}
|
||||
},
|
||||
|
||||
var originalAddButton = editor.addButton;
|
||||
editor.addButton = function(name, settings) {
|
||||
var originalOnPostRender;
|
||||
onAdd: new Dispatcher(),
|
||||
onPostRender: new Dispatcher(),
|
||||
|
||||
function patchedPostRender() {
|
||||
editor.controlManager.buttons[name] = this;
|
||||
add: function (obj) {
|
||||
return obj;
|
||||
},
|
||||
createButton: cmNoop,
|
||||
createColorSplitButton: cmNoop,
|
||||
createControl: cmNoop,
|
||||
createDropMenu: cmNoop,
|
||||
createListBox: cmNoop,
|
||||
createMenuButton: cmNoop,
|
||||
createSeparator: cmNoop,
|
||||
createSplitButton: cmNoop,
|
||||
createToolbar: cmNoop,
|
||||
createToolbarGroup: cmNoop,
|
||||
destroy: noop,
|
||||
get: noop,
|
||||
setControlType: cmNoop
|
||||
};
|
||||
|
||||
if (originalOnPostRender) {
|
||||
return originalOnPostRender.call(this);
|
||||
}
|
||||
}
|
||||
patchEditorEvents("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate", "editor");
|
||||
patchEditorEvents("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset");
|
||||
patchEditorEvents("BeforeExecCommand ExecCommand", "command ui value args"); // args.terminate not supported
|
||||
patchEditorEvents("PreProcess PostProcess LoadContent SaveContent Change");
|
||||
patchEditorEvents("BeforeSetContent BeforeGetContent SetContent GetContent", filterSelectionEvents(false));
|
||||
patchEditorEvents("SetProgressState", "state time");
|
||||
patchEditorEvents("VisualAid", "element hasVisual");
|
||||
patchEditorEvents("Undo Redo", convertUndoEventArgs);
|
||||
|
||||
for (var key in settings) {
|
||||
if (key.toLowerCase() === "onpostrender") {
|
||||
originalOnPostRender = settings[key];
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
}
|
||||
patchEditorEvents("NodeChange", function (type, e) {
|
||||
return [
|
||||
editor.controlManager,
|
||||
e.element,
|
||||
editor.selection.isCollapsed(),
|
||||
e
|
||||
];
|
||||
});
|
||||
|
||||
if (!originalOnPostRender) {
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
var originalAddButton = editor.addButton;
|
||||
editor.addButton = function (name, settings) {
|
||||
var originalOnPostRender;
|
||||
|
||||
if (settings.title) {
|
||||
settings.title = tinymce.i18n.translate((editor.settings.language || "en") + "." + settings.title);
|
||||
}
|
||||
function patchedPostRender() {
|
||||
editor.controlManager.buttons[name] = this;
|
||||
|
||||
return originalAddButton.call(this, name, settings);
|
||||
};
|
||||
if (originalOnPostRender) {
|
||||
return originalOnPostRender.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
editor.on('init', function() {
|
||||
var undoManager = editor.undoManager, selection = editor.selection;
|
||||
for (var key in settings) {
|
||||
if (key.toLowerCase() === "onpostrender") {
|
||||
originalOnPostRender = settings[key];
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
}
|
||||
|
||||
undoManager.onUndo = new Dispatcher(editor, "Undo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onRedo = new Dispatcher(editor, "Redo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onBeforeAdd = new Dispatcher(editor, "BeforeAddUndo", null, undoManager);
|
||||
undoManager.onAdd = new Dispatcher(editor, "AddUndo", null, undoManager);
|
||||
if (!originalOnPostRender) {
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
|
||||
selection.onBeforeGetContent = new Dispatcher(editor, "BeforeGetContent", filterSelectionEvents(true), selection);
|
||||
selection.onGetContent = new Dispatcher(editor, "GetContent", filterSelectionEvents(true), selection);
|
||||
selection.onBeforeSetContent = new Dispatcher(editor, "BeforeSetContent", filterSelectionEvents(true), selection);
|
||||
selection.onSetContent = new Dispatcher(editor, "SetContent", filterSelectionEvents(true), selection);
|
||||
});
|
||||
if (settings.title) {
|
||||
settings.title = translate(settings.title);
|
||||
}
|
||||
|
||||
editor.on('BeforeRenderUI', function() {
|
||||
var windowManager = editor.windowManager;
|
||||
return originalAddButton.call(this, name, settings);
|
||||
};
|
||||
|
||||
windowManager.onOpen = new Dispatcher();
|
||||
windowManager.onClose = new Dispatcher();
|
||||
windowManager.createInstance = function(className, a, b, c, d, e) {
|
||||
log("windowManager.createInstance(..)");
|
||||
editor.on('init', function () {
|
||||
var undoManager = editor.undoManager, selection = editor.selection;
|
||||
|
||||
var constr = tinymce.resolve(className);
|
||||
return new constr(a, b, c, d, e);
|
||||
};
|
||||
});
|
||||
}
|
||||
undoManager.onUndo = new Dispatcher(editor, "Undo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onRedo = new Dispatcher(editor, "Redo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onBeforeAdd = new Dispatcher(editor, "BeforeAddUndo", null, undoManager);
|
||||
undoManager.onAdd = new Dispatcher(editor, "AddUndo", null, undoManager);
|
||||
|
||||
tinymce.on('SetupEditor', patchEditor);
|
||||
tinymce.PluginManager.add("compat3x", patchEditor);
|
||||
selection.onBeforeGetContent = new Dispatcher(editor, "BeforeGetContent", filterSelectionEvents(true), selection);
|
||||
selection.onGetContent = new Dispatcher(editor, "GetContent", filterSelectionEvents(true), selection);
|
||||
selection.onBeforeSetContent = new Dispatcher(editor, "BeforeSetContent", filterSelectionEvents(true), selection);
|
||||
selection.onSetContent = new Dispatcher(editor, "SetContent", filterSelectionEvents(true), selection);
|
||||
});
|
||||
|
||||
tinymce.addI18n = function(prefix, o) {
|
||||
var I18n = tinymce.util.I18n, each = tinymce.each;
|
||||
editor.on('BeforeRenderUI', function () {
|
||||
var windowManager = editor.windowManager;
|
||||
|
||||
if (typeof prefix == "string" && prefix.indexOf('.') === -1) {
|
||||
I18n.add(prefix, o);
|
||||
return;
|
||||
}
|
||||
windowManager.onOpen = new Dispatcher();
|
||||
windowManager.onClose = new Dispatcher();
|
||||
windowManager.createInstance = function (className, a, b, c, d, e) {
|
||||
log("windowManager.createInstance(..)");
|
||||
|
||||
if (!tinymce.is(prefix, 'string')) {
|
||||
each(prefix, function(o, lc) {
|
||||
each(o, function(o, g) {
|
||||
each(o, function(o, k) {
|
||||
if (g === 'common') {
|
||||
I18n.data[lc + '.' + k] = o;
|
||||
} else {
|
||||
I18n.data[lc + '.' + g + '.' + k] = o;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
each(o, function(o, k) {
|
||||
I18n.data[prefix + '.' + k] = o;
|
||||
});
|
||||
}
|
||||
};
|
||||
var constr = tinymce.resolve(className);
|
||||
return new constr(a, b, c, d, e);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
tinymce.on('SetupEditor', function (e) {
|
||||
patchEditor(e.editor);
|
||||
});
|
||||
|
||||
tinymce.PluginManager.add("compat3x", patchEditor);
|
||||
|
||||
tinymce.addI18n = function (prefix, o) {
|
||||
var I18n = tinymce.util.I18n, each = tinymce.each;
|
||||
|
||||
if (typeof prefix == "string" && prefix.indexOf('.') === -1) {
|
||||
I18n.add(prefix, o);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tinymce.is(prefix, 'string')) {
|
||||
each(prefix, function (o, lc) {
|
||||
each(o, function (o, g) {
|
||||
each(o, function (o, k) {
|
||||
if (g === 'common') {
|
||||
I18n.data[lc + '.' + k] = o;
|
||||
} else {
|
||||
I18n.data[lc + '.' + g + '.' + k] = o;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
each(o, function (o, k) {
|
||||
I18n.data[prefix + '.' + k] = o;
|
||||
});
|
||||
}
|
||||
};
|
||||
})(tinymce);
|
||||
|
@@ -1 +1 @@
|
||||
!function(a){function b(){}function c(a){!f&&window&&window.console&&(f=!0,console.log("Deprecated TinyMCE API call: "+a))}function d(a,d,e,f){return a=a||this,d?(this.add=function(b,g,h){function i(c){var h=[];if("string"==typeof e&&(e=e.split(" ")),e&&"function"!=typeof e)for(var i=0;i<e.length;i++)h.push(c[e[i]]);("function"!=typeof e||(h=e(d,c,a)))&&(e||(h=[c]),h.unshift(f||a),b.apply(g||f||a,h)===!1&&c.stopImmediatePropagation())}return c("<target>.on"+d+".add(..)"),a.on(d,i,h),i},this.addToTop=function(a,b){this.add(a,b,!0)},this.remove=function(b){return a.off(d,b)},void(this.dispatch=function(){return a.fire(d),!0})):void(this.add=this.addToTop=this.remove=this.dispatch=b)}function e(e){function f(b,c){a.each(b.split(" "),function(a){e["on"+a]=new d(e,a,c)})}function g(a,b,c){return[b.level,c]}function h(a){return function(b,c){return!c.selection&&!a||c.selection==a?[c]:void 0}}function i(){function b(){return i()}var d={},e="add addMenu addSeparator collapse createMenu destroy displayColor expand focus getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex setActive setAriaProperty setColor setDisabled setSelected setState showMenu update";return c("editor.controlManager.*"),a.each(e.split(" "),function(a){d[a]=b}),d}if(!e.controlManager){e.controlManager={buttons:{},setDisabled:function(a,b){c("controlManager.setDisabled(..)"),this.buttons[a]&&this.buttons[a].disabled(b)},setActive:function(a,b){c("controlManager.setActive(..)"),this.buttons[a]&&this.buttons[a].active(b)},onAdd:new d,onPostRender:new d,add:function(a){return a},createButton:i,createColorSplitButton:i,createControl:i,createDropMenu:i,createListBox:i,createMenuButton:i,createSeparator:i,createSplitButton:i,createToolbar:i,createToolbarGroup:i,destroy:b,get:b,setControlType:i},f("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),f("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),f("BeforeExecCommand ExecCommand","command ui value args"),f("PreProcess PostProcess LoadContent SaveContent Change"),f("BeforeSetContent BeforeGetContent SetContent GetContent",h(!1)),f("SetProgressState","state time"),f("VisualAid","element hasVisual"),f("Undo Redo",g),f("NodeChange",function(a,b){return[e.controlManager,b.element,e.selection.isCollapsed(),b]});var j=e.addButton;e.addButton=function(b,c){function d(){return e.controlManager.buttons[b]=this,f?f.call(this):void 0}var f;for(var g in c)"onpostrender"===g.toLowerCase()&&(f=c[g],c.onPostRender=d);return f||(c.onPostRender=d),c.title&&(c.title=a.i18n.translate((e.settings.language||"en")+"."+c.title)),j.call(this,b,c)},e.on("init",function(){var a=e.undoManager,b=e.selection;a.onUndo=new d(e,"Undo",g,null,a),a.onRedo=new d(e,"Redo",g,null,a),a.onBeforeAdd=new d(e,"BeforeAddUndo",null,a),a.onAdd=new d(e,"AddUndo",null,a),b.onBeforeGetContent=new d(e,"BeforeGetContent",h(!0),b),b.onGetContent=new d(e,"GetContent",h(!0),b),b.onBeforeSetContent=new d(e,"BeforeSetContent",h(!0),b),b.onSetContent=new d(e,"SetContent",h(!0),b)}),e.on("BeforeRenderUI",function(){var b=e.windowManager;b.onOpen=new d,b.onClose=new d,b.createInstance=function(b,d,e,f,g,h){c("windowManager.createInstance(..)");var i=a.resolve(b);return new i(d,e,f,g,h)}})}}var f;a.util.Dispatcher=d,a.onBeforeUnload=new d(a,"BeforeUnload"),a.onAddEditor=new d(a,"AddEditor","editor"),a.onRemoveEditor=new d(a,"RemoveEditor","editor"),a.util.Cookie={get:b,getHash:b,remove:b,set:b,setHash:b},a.on("SetupEditor",e),a.PluginManager.add("compat3x",e),a.addI18n=function(b,c){var d=a.util.I18n,e=a.each;return"string"==typeof b&&-1===b.indexOf(".")?void d.add(b,c):void(a.is(b,"string")?e(c,function(a,c){d.data[b+"."+c]=a}):e(b,function(a,b){e(a,function(a,c){e(a,function(a,e){"common"===c?d.data[b+"."+e]=a:d.data[b+"."+c+"."+e]=a})})}))}}(tinymce);
|
||||
!function(u){var t;function l(){}function f(e){!t&&window&&window.console&&(t=!0,console.log("Deprecated TinyMCE API call: "+e))}function i(i,a,d,s){i=i||this;var c=[];a?(this.add=function(o,r,e){function t(e){var t=[];if("string"==typeof d&&(d=d.split(" ")),d&&"function"!=typeof d)for(var n=0;n<d.length;n++)t.push(e[d[n]]);("function"!=typeof d||(t=d(a,e,i)))&&(d||(t=[e]),t.unshift(s||i),!1===o.apply(r||s||i,t)&&e.stopImmediatePropagation())}f("<target>.on"+a+".add(..)"),i.on(a,t,e);var n={original:o,patched:t};return c.push(n),t},this.addToTop=function(e,t){this.add(e,t,!0)},this.remove=function(n){return c.forEach(function(e,t){if(e.original===n)return c.splice(t,1),i.off(a,e.patched)}),i.off(a,n)},this.dispatch=function(){return i.fire(a),!0}):this.add=this.addToTop=this.remove=this.dispatch=l}function n(s){function e(e,t){u.each(e.split(" "),function(e){s["on"+e]=new i(s,e,t)})}function n(e,t,n){return[t.level,n]}function o(n){return function(e,t){if(!t.selection&&!n||t.selection==n)return[t]}}if(!s.controlManager){s.controlManager={buttons:{},setDisabled:function(e,t){f("controlManager.setDisabled(..)"),this.buttons[e]&&this.buttons[e].disabled(t)},setActive:function(e,t){f("controlManager.setActive(..)"),this.buttons[e]&&this.buttons[e].active(t)},onAdd:new i,onPostRender:new i,add:function(e){return e},createButton:r,createColorSplitButton:r,createControl:r,createDropMenu:r,createListBox:r,createMenuButton:r,createSeparator:r,createSplitButton:r,createToolbar:r,createToolbarGroup:r,destroy:l,get:l,setControlType:r},e("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),e("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),e("BeforeExecCommand ExecCommand","command ui value args"),e("PreProcess PostProcess LoadContent SaveContent Change"),e("BeforeSetContent BeforeGetContent SetContent GetContent",o(!1)),e("SetProgressState","state time"),e("VisualAid","element hasVisual"),e("Undo Redo",n),e("NodeChange",function(e,t){return[s.controlManager,t.element,s.selection.isCollapsed(),t]});var c=s.addButton;s.addButton=function(e,t){var n,o,r,i;function a(){if(s.controlManager.buttons[e]=this,n)return n.apply(this,arguments)}for(var d in t)"onpostrender"===d.toLowerCase()&&(n=t[d],t.onPostRender=a);return n||(t.onPostRender=a),t.title&&(t.title=(o=t.title,r=[s.settings.language||"en",o].join("."),i=u.i18n.translate(r),r!==i?i:u.i18n.translate(o))),c.call(this,e,t)},s.on("init",function(){var e=s.undoManager,t=s.selection;e.onUndo=new i(s,"Undo",n,null,e),e.onRedo=new i(s,"Redo",n,null,e),e.onBeforeAdd=new i(s,"BeforeAddUndo",null,e),e.onAdd=new i(s,"AddUndo",null,e),t.onBeforeGetContent=new i(s,"BeforeGetContent",o(!0),t),t.onGetContent=new i(s,"GetContent",o(!0),t),t.onBeforeSetContent=new i(s,"BeforeSetContent",o(!0),t),t.onSetContent=new i(s,"SetContent",o(!0),t)}),s.on("BeforeRenderUI",function(){var e=s.windowManager;e.onOpen=new i,e.onClose=new i,e.createInstance=function(e,t,n,o,r,i){return f("windowManager.createInstance(..)"),new(u.resolve(e))(t,n,o,r,i)}})}function r(){var t={};function n(){return r()}return f("editor.controlManager.*"),u.each("add addMenu addSeparator collapse createMenu destroy displayColor expand focus getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex setActive setAriaProperty setColor setDisabled setSelected setState showMenu update".split(" "),function(e){t[e]=n}),t}}u.util.Dispatcher=i,u.onBeforeUnload=new i(u,"BeforeUnload"),u.onAddEditor=new i(u,"AddEditor","editor"),u.onRemoveEditor=new i(u,"RemoveEditor","editor"),u.util.Cookie={get:l,getHash:l,remove:l,set:l,setHash:l},u.on("SetupEditor",function(e){n(e.editor)}),u.PluginManager.add("compat3x",n),u.addI18n=function(n,e){var r=u.util.I18n,t=u.each;"string"!=typeof n||-1!==n.indexOf(".")?u.is(n,"string")?t(e,function(e,t){r.data[n+"."+t]=e}):t(n,function(e,o){t(e,function(e,n){t(e,function(e,t){"common"===n?r.data[o+"."+t]=e:r.data[o+"."+n+"."+t]=e})})}):r.add(n,e)}}(tinymce);
|
1008
e107_plugins/tinymce4/plugins/compat3x/tiny_mce_popup.js
vendored
1008
e107_plugins/tinymce4/plugins/compat3x/tiny_mce_popup.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,70 +1,72 @@
|
||||
/**
|
||||
* editable_selects.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
var TinyMCE_EditableSelects = {
|
||||
editSelectElm : null,
|
||||
editSelectElm : null,
|
||||
|
||||
init : function() {
|
||||
var nl = document.getElementsByTagName("select"), i, d = document, o;
|
||||
init : function () {
|
||||
var nl = document.getElementsByTagName("select"), i, d = document, o;
|
||||
|
||||
for (i=0; i<nl.length; i++) {
|
||||
if (nl[i].className.indexOf('mceEditableSelect') != -1) {
|
||||
o = new Option(tinyMCEPopup.editor.translate('value'), '__mce_add_custom__');
|
||||
for (i = 0; i < nl.length; i++) {
|
||||
if (nl[i].className.indexOf('mceEditableSelect') != -1) {
|
||||
o = new Option(tinyMCEPopup.editor.translate('value'), '__mce_add_custom__');
|
||||
|
||||
o.className = 'mceAddSelectValue';
|
||||
o.className = 'mceAddSelectValue';
|
||||
|
||||
nl[i].options[nl[i].options.length] = o;
|
||||
nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
|
||||
}
|
||||
}
|
||||
},
|
||||
nl[i].options[nl[i].options.length] = o;
|
||||
nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onChangeEditableSelect : function(e) {
|
||||
var d = document, ne, se = window.event ? window.event.srcElement : e.target;
|
||||
onChangeEditableSelect : function (e) {
|
||||
var d = document, ne, se = window.event ? window.event.srcElement : e.target;
|
||||
|
||||
if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
|
||||
ne = d.createElement("input");
|
||||
ne.id = se.id + "_custom";
|
||||
ne.name = se.name + "_custom";
|
||||
ne.type = "text";
|
||||
if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
|
||||
ne = d.createElement("input");
|
||||
ne.id = se.id + "_custom";
|
||||
ne.name = se.name + "_custom";
|
||||
ne.type = "text";
|
||||
|
||||
ne.style.width = se.offsetWidth + 'px';
|
||||
se.parentNode.insertBefore(ne, se);
|
||||
se.style.display = 'none';
|
||||
ne.focus();
|
||||
ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
|
||||
ne.onkeydown = TinyMCE_EditableSelects.onKeyDown;
|
||||
TinyMCE_EditableSelects.editSelectElm = se;
|
||||
}
|
||||
},
|
||||
ne.style.width = se.offsetWidth + 'px';
|
||||
se.parentNode.insertBefore(ne, se);
|
||||
se.style.display = 'none';
|
||||
ne.focus();
|
||||
ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
|
||||
ne.onkeydown = TinyMCE_EditableSelects.onKeyDown;
|
||||
TinyMCE_EditableSelects.editSelectElm = se;
|
||||
}
|
||||
},
|
||||
|
||||
onBlurEditableSelectInput : function() {
|
||||
var se = TinyMCE_EditableSelects.editSelectElm;
|
||||
onBlurEditableSelectInput : function () {
|
||||
var se = TinyMCE_EditableSelects.editSelectElm;
|
||||
|
||||
if (se) {
|
||||
if (se.previousSibling.value != '') {
|
||||
addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
|
||||
selectByValue(document.forms[0], se.id, se.previousSibling.value);
|
||||
} else
|
||||
selectByValue(document.forms[0], se.id, '');
|
||||
if (se) {
|
||||
if (se.previousSibling.value != '') {
|
||||
addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
|
||||
selectByValue(document.forms[0], se.id, se.previousSibling.value);
|
||||
} else {
|
||||
selectByValue(document.forms[0], se.id, '');
|
||||
}
|
||||
|
||||
se.style.display = 'inline';
|
||||
se.parentNode.removeChild(se.previousSibling);
|
||||
TinyMCE_EditableSelects.editSelectElm = null;
|
||||
}
|
||||
},
|
||||
se.style.display = 'inline';
|
||||
se.parentNode.removeChild(se.previousSibling);
|
||||
TinyMCE_EditableSelects.editSelectElm = null;
|
||||
}
|
||||
},
|
||||
|
||||
onKeyDown : function(e) {
|
||||
e = e || window.event;
|
||||
onKeyDown : function (e) {
|
||||
e = e || window.event;
|
||||
|
||||
if (e.keyCode == 13)
|
||||
TinyMCE_EditableSelects.onBlurEditableSelectInput();
|
||||
}
|
||||
if (e.keyCode == 13) {
|
||||
TinyMCE_EditableSelects.onBlurEditableSelectInput();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* form_utils.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
@@ -11,200 +11,212 @@
|
||||
var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
|
||||
|
||||
function getColorPickerHTML(id, target_form_element) {
|
||||
var h = "", dom = tinyMCEPopup.dom;
|
||||
var h = "", dom = tinyMCEPopup.dom;
|
||||
|
||||
if (label = dom.select('label[for=' + target_form_element + ']')[0]) {
|
||||
label.id = label.id || dom.uniqueId();
|
||||
}
|
||||
if (label = dom.select('label[for=' + target_form_element + ']')[0]) {
|
||||
label.id = label.id || dom.uniqueId();
|
||||
}
|
||||
|
||||
h += '<a role="button" aria-labelledby="' + id + '_label" id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
|
||||
h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"> <span id="' + id + '_label" class="mceVoiceLabel mceIconOnly" style="display:none;">' + tinyMCEPopup.getLang('browse') + '</span></span></a>';
|
||||
h += '<a role="button" aria-labelledby="' + id + '_label" id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element + '\');" onmousedown="return false;" class="pickcolor">';
|
||||
h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"> <span id="' + id + '_label" class="mceVoiceLabel mceIconOnly" style="display:none;">' + tinyMCEPopup.getLang('browse') + '</span></span></a>';
|
||||
|
||||
return h;
|
||||
return h;
|
||||
}
|
||||
|
||||
function updateColor(img_id, form_element_id) {
|
||||
document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
|
||||
document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
|
||||
}
|
||||
|
||||
function setBrowserDisabled(id, state) {
|
||||
var img = document.getElementById(id);
|
||||
var lnk = document.getElementById(id + "_link");
|
||||
var img = document.getElementById(id);
|
||||
var lnk = document.getElementById(id + "_link");
|
||||
|
||||
if (lnk) {
|
||||
if (state) {
|
||||
lnk.setAttribute("realhref", lnk.getAttribute("href"));
|
||||
lnk.removeAttribute("href");
|
||||
tinyMCEPopup.dom.addClass(img, 'disabled');
|
||||
} else {
|
||||
if (lnk.getAttribute("realhref"))
|
||||
lnk.setAttribute("href", lnk.getAttribute("realhref"));
|
||||
if (lnk) {
|
||||
if (state) {
|
||||
lnk.setAttribute("realhref", lnk.getAttribute("href"));
|
||||
lnk.removeAttribute("href");
|
||||
tinyMCEPopup.dom.addClass(img, 'disabled');
|
||||
} else {
|
||||
if (lnk.getAttribute("realhref")) {
|
||||
lnk.setAttribute("href", lnk.getAttribute("realhref"));
|
||||
}
|
||||
|
||||
tinyMCEPopup.dom.removeClass(img, 'disabled');
|
||||
}
|
||||
}
|
||||
tinyMCEPopup.dom.removeClass(img, 'disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getBrowserHTML(id, target_form_element, type, prefix) {
|
||||
var option = prefix + "_" + type + "_browser_callback", cb, html;
|
||||
var option = prefix + "_" + type + "_browser_callback", cb, html;
|
||||
|
||||
cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
|
||||
cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
|
||||
|
||||
if (!cb)
|
||||
return "";
|
||||
if (!cb) {
|
||||
return "";
|
||||
}
|
||||
|
||||
html = "";
|
||||
html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
|
||||
html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"> </span></a>';
|
||||
html = "";
|
||||
html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
|
||||
html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"> </span></a>';
|
||||
|
||||
return html;
|
||||
return html;
|
||||
}
|
||||
|
||||
function openBrowser(img_id, target_form_element, type, option) {
|
||||
var img = document.getElementById(img_id);
|
||||
var img = document.getElementById(img_id);
|
||||
|
||||
if (img.className != "mceButtonDisabled")
|
||||
tinyMCEPopup.openBrowser(target_form_element, type, option);
|
||||
if (img.className != "mceButtonDisabled") {
|
||||
tinyMCEPopup.openBrowser(target_form_element, type, option);
|
||||
}
|
||||
}
|
||||
|
||||
function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
|
||||
if (!form_obj || !form_obj.elements[field_name])
|
||||
return;
|
||||
if (!form_obj || !form_obj.elements[field_name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!value)
|
||||
value = "";
|
||||
if (!value) {
|
||||
value = "";
|
||||
}
|
||||
|
||||
var sel = form_obj.elements[field_name];
|
||||
var sel = form_obj.elements[field_name];
|
||||
|
||||
var found = false;
|
||||
for (var i=0; i<sel.options.length; i++) {
|
||||
var option = sel.options[i];
|
||||
var found = false;
|
||||
for (var i = 0; i < sel.options.length; i++) {
|
||||
var option = sel.options[i];
|
||||
|
||||
if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
|
||||
option.selected = true;
|
||||
found = true;
|
||||
} else
|
||||
option.selected = false;
|
||||
}
|
||||
if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
|
||||
option.selected = true;
|
||||
found = true;
|
||||
} else {
|
||||
option.selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && add_custom && value != '') {
|
||||
var option = new Option(value, value);
|
||||
option.selected = true;
|
||||
sel.options[sel.options.length] = option;
|
||||
sel.selectedIndex = sel.options.length - 1;
|
||||
}
|
||||
if (!found && add_custom && value != '') {
|
||||
var option = new Option(value, value);
|
||||
option.selected = true;
|
||||
sel.options[sel.options.length] = option;
|
||||
sel.selectedIndex = sel.options.length - 1;
|
||||
}
|
||||
|
||||
return found;
|
||||
return found;
|
||||
}
|
||||
|
||||
function getSelectValue(form_obj, field_name) {
|
||||
var elm = form_obj.elements[field_name];
|
||||
var elm = form_obj.elements[field_name];
|
||||
|
||||
if (elm == null || elm.options == null || elm.selectedIndex === -1)
|
||||
return "";
|
||||
if (elm == null || elm.options == null || elm.selectedIndex === -1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return elm.options[elm.selectedIndex].value;
|
||||
return elm.options[elm.selectedIndex].value;
|
||||
}
|
||||
|
||||
function addSelectValue(form_obj, field_name, name, value) {
|
||||
var s = form_obj.elements[field_name];
|
||||
var o = new Option(name, value);
|
||||
s.options[s.options.length] = o;
|
||||
var s = form_obj.elements[field_name];
|
||||
var o = new Option(name, value);
|
||||
s.options[s.options.length] = o;
|
||||
}
|
||||
|
||||
function addClassesToList(list_id, specific_option) {
|
||||
// Setup class droplist
|
||||
var styleSelectElm = document.getElementById(list_id);
|
||||
var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
|
||||
styles = tinyMCEPopup.getParam(specific_option, styles);
|
||||
// Setup class droplist
|
||||
var styleSelectElm = document.getElementById(list_id);
|
||||
var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
|
||||
styles = tinyMCEPopup.getParam(specific_option, styles);
|
||||
|
||||
if (styles) {
|
||||
var stylesAr = styles.split(';');
|
||||
if (styles) {
|
||||
var stylesAr = styles.split(';');
|
||||
|
||||
for (var i=0; i<stylesAr.length; i++) {
|
||||
if (stylesAr != "") {
|
||||
var key, value;
|
||||
for (var i = 0; i < stylesAr.length; i++) {
|
||||
if (stylesAr != "") {
|
||||
var key, value;
|
||||
|
||||
key = stylesAr[i].split('=')[0];
|
||||
value = stylesAr[i].split('=')[1];
|
||||
key = stylesAr[i].split('=')[0];
|
||||
value = stylesAr[i].split('=')[1];
|
||||
|
||||
styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
|
||||
styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
|
||||
});*/
|
||||
}
|
||||
styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
|
||||
styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
function isVisible(element_id) {
|
||||
var elm = document.getElementById(element_id);
|
||||
var elm = document.getElementById(element_id);
|
||||
|
||||
return elm && elm.style.display != "none";
|
||||
return elm && elm.style.display != "none";
|
||||
}
|
||||
|
||||
function convertRGBToHex(col) {
|
||||
var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
|
||||
var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
|
||||
|
||||
var rgb = col.replace(re, "$1,$2,$3").split(',');
|
||||
if (rgb.length == 3) {
|
||||
r = parseInt(rgb[0]).toString(16);
|
||||
g = parseInt(rgb[1]).toString(16);
|
||||
b = parseInt(rgb[2]).toString(16);
|
||||
var rgb = col.replace(re, "$1,$2,$3").split(',');
|
||||
if (rgb.length == 3) {
|
||||
r = parseInt(rgb[0]).toString(16);
|
||||
g = parseInt(rgb[1]).toString(16);
|
||||
b = parseInt(rgb[2]).toString(16);
|
||||
|
||||
r = r.length == 1 ? '0' + r : r;
|
||||
g = g.length == 1 ? '0' + g : g;
|
||||
b = b.length == 1 ? '0' + b : b;
|
||||
r = r.length == 1 ? '0' + r : r;
|
||||
g = g.length == 1 ? '0' + g : g;
|
||||
b = b.length == 1 ? '0' + b : b;
|
||||
|
||||
return "#" + r + g + b;
|
||||
}
|
||||
return "#" + r + g + b;
|
||||
}
|
||||
|
||||
return col;
|
||||
return col;
|
||||
}
|
||||
|
||||
function convertHexToRGB(col) {
|
||||
if (col.indexOf('#') != -1) {
|
||||
col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
|
||||
if (col.indexOf('#') != -1) {
|
||||
col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
|
||||
|
||||
r = parseInt(col.substring(0, 2), 16);
|
||||
g = parseInt(col.substring(2, 4), 16);
|
||||
b = parseInt(col.substring(4, 6), 16);
|
||||
r = parseInt(col.substring(0, 2), 16);
|
||||
g = parseInt(col.substring(2, 4), 16);
|
||||
b = parseInt(col.substring(4, 6), 16);
|
||||
|
||||
return "rgb(" + r + "," + g + "," + b + ")";
|
||||
}
|
||||
return "rgb(" + r + "," + g + "," + b + ")";
|
||||
}
|
||||
|
||||
return col;
|
||||
return col;
|
||||
}
|
||||
|
||||
function trimSize(size) {
|
||||
return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2');
|
||||
return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2');
|
||||
}
|
||||
|
||||
function getCSSSize(size) {
|
||||
size = trimSize(size);
|
||||
size = trimSize(size);
|
||||
|
||||
if (size == "")
|
||||
return "";
|
||||
if (size == "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Add px
|
||||
if (/^[0-9]+$/.test(size))
|
||||
size += 'px';
|
||||
// Sanity check, IE doesn't like broken values
|
||||
else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size)))
|
||||
return "";
|
||||
// Add px
|
||||
if (/^[0-9]+$/.test(size)) {
|
||||
size += 'px';
|
||||
}
|
||||
// Sanity check, IE doesn't like broken values
|
||||
else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size))) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return size;
|
||||
return size;
|
||||
}
|
||||
|
||||
function getStyle(elm, attrib, style) {
|
||||
var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
|
||||
var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
|
||||
|
||||
if (val != '')
|
||||
return '' + val;
|
||||
if (val != '') {
|
||||
return '' + val;
|
||||
}
|
||||
|
||||
if (typeof(style) == 'undefined')
|
||||
style = attrib;
|
||||
if (typeof (style) == 'undefined') {
|
||||
style = attrib;
|
||||
}
|
||||
|
||||
return tinyMCEPopup.dom.getStyle(elm, style);
|
||||
return tinyMCEPopup.dom.getStyle(elm, style);
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* mctabs.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
@@ -11,154 +11,158 @@
|
||||
/*jshint globals: tinyMCEPopup */
|
||||
|
||||
function MCTabs() {
|
||||
this.settings = [];
|
||||
this.onChange = tinyMCEPopup.editor.windowManager.createInstance('tinymce.util.Dispatcher');
|
||||
this.settings = [];
|
||||
this.onChange = tinyMCEPopup.editor.windowManager.createInstance('tinymce.util.Dispatcher');
|
||||
}
|
||||
|
||||
MCTabs.prototype.init = function (settings) {
|
||||
this.settings = settings;
|
||||
};
|
||||
|
||||
MCTabs.prototype.init = function(settings) {
|
||||
this.settings = settings;
|
||||
MCTabs.prototype.getParam = function (name, default_value) {
|
||||
var value = null;
|
||||
|
||||
value = (typeof (this.settings[name]) == "undefined") ? default_value : this.settings[name];
|
||||
|
||||
// Fix bool values
|
||||
if (value == "true" || value == "false") {
|
||||
return (value == "true");
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
MCTabs.prototype.getParam = function(name, default_value) {
|
||||
var value = null;
|
||||
|
||||
value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
|
||||
|
||||
// Fix bool values
|
||||
if (value == "true" || value == "false")
|
||||
return (value == "true");
|
||||
|
||||
return value;
|
||||
MCTabs.prototype.showTab = function (tab) {
|
||||
tab.className = 'current';
|
||||
tab.setAttribute("aria-selected", true);
|
||||
tab.setAttribute("aria-expanded", true);
|
||||
tab.tabIndex = 0;
|
||||
};
|
||||
|
||||
MCTabs.prototype.showTab =function(tab){
|
||||
tab.className = 'current';
|
||||
tab.setAttribute("aria-selected", true);
|
||||
tab.setAttribute("aria-expanded", true);
|
||||
tab.tabIndex = 0;
|
||||
MCTabs.prototype.hideTab = function (tab) {
|
||||
var t = this;
|
||||
|
||||
tab.className = '';
|
||||
tab.setAttribute("aria-selected", false);
|
||||
tab.setAttribute("aria-expanded", false);
|
||||
tab.tabIndex = -1;
|
||||
};
|
||||
|
||||
MCTabs.prototype.hideTab =function(tab){
|
||||
var t=this;
|
||||
|
||||
tab.className = '';
|
||||
tab.setAttribute("aria-selected", false);
|
||||
tab.setAttribute("aria-expanded", false);
|
||||
tab.tabIndex = -1;
|
||||
MCTabs.prototype.showPanel = function (panel) {
|
||||
panel.className = 'current';
|
||||
panel.setAttribute("aria-hidden", false);
|
||||
};
|
||||
|
||||
MCTabs.prototype.showPanel = function(panel) {
|
||||
panel.className = 'current';
|
||||
panel.setAttribute("aria-hidden", false);
|
||||
MCTabs.prototype.hidePanel = function (panel) {
|
||||
panel.className = 'panel';
|
||||
panel.setAttribute("aria-hidden", true);
|
||||
};
|
||||
|
||||
MCTabs.prototype.hidePanel = function(panel) {
|
||||
panel.className = 'panel';
|
||||
panel.setAttribute("aria-hidden", true);
|
||||
MCTabs.prototype.getPanelForTab = function (tabElm) {
|
||||
return tinyMCEPopup.dom.getAttrib(tabElm, "aria-controls");
|
||||
};
|
||||
|
||||
MCTabs.prototype.getPanelForTab = function(tabElm) {
|
||||
return tinyMCEPopup.dom.getAttrib(tabElm, "aria-controls");
|
||||
MCTabs.prototype.displayTab = function (tab_id, panel_id, avoid_focus) {
|
||||
var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i, t = this;
|
||||
|
||||
tabElm = document.getElementById(tab_id);
|
||||
|
||||
if (panel_id === undefined) {
|
||||
panel_id = t.getPanelForTab(tabElm);
|
||||
}
|
||||
|
||||
panelElm = document.getElementById(panel_id);
|
||||
panelContainerElm = panelElm ? panelElm.parentNode : null;
|
||||
tabContainerElm = tabElm ? tabElm.parentNode : null;
|
||||
selectionClass = t.getParam('selection_class', 'current');
|
||||
|
||||
if (tabElm && tabContainerElm) {
|
||||
nodes = tabContainerElm.childNodes;
|
||||
|
||||
// Hide all other tabs
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeName == "LI") {
|
||||
t.hideTab(nodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Show selected tab
|
||||
t.showTab(tabElm);
|
||||
}
|
||||
|
||||
if (panelElm && panelContainerElm) {
|
||||
nodes = panelContainerElm.childNodes;
|
||||
|
||||
// Hide all other panels
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeName == "DIV") {
|
||||
t.hidePanel(nodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!avoid_focus) {
|
||||
tabElm.focus();
|
||||
}
|
||||
|
||||
// Show selected panel
|
||||
t.showPanel(panelElm);
|
||||
}
|
||||
};
|
||||
|
||||
MCTabs.prototype.displayTab = function(tab_id, panel_id, avoid_focus) {
|
||||
var panelElm, panelContainerElm, tabElm, tabContainerElm, selectionClass, nodes, i, t = this;
|
||||
MCTabs.prototype.getAnchor = function () {
|
||||
var pos, url = document.location.href;
|
||||
|
||||
tabElm = document.getElementById(tab_id);
|
||||
if ((pos = url.lastIndexOf('#')) != -1) {
|
||||
return url.substring(pos + 1);
|
||||
}
|
||||
|
||||
if (panel_id === undefined) {
|
||||
panel_id = t.getPanelForTab(tabElm);
|
||||
}
|
||||
|
||||
panelElm= document.getElementById(panel_id);
|
||||
panelContainerElm = panelElm ? panelElm.parentNode : null;
|
||||
tabContainerElm = tabElm ? tabElm.parentNode : null;
|
||||
selectionClass = t.getParam('selection_class', 'current');
|
||||
|
||||
if (tabElm && tabContainerElm) {
|
||||
nodes = tabContainerElm.childNodes;
|
||||
|
||||
// Hide all other tabs
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeName == "LI") {
|
||||
t.hideTab(nodes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Show selected tab
|
||||
t.showTab(tabElm);
|
||||
}
|
||||
|
||||
if (panelElm && panelContainerElm) {
|
||||
nodes = panelContainerElm.childNodes;
|
||||
|
||||
// Hide all other panels
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeName == "DIV")
|
||||
t.hidePanel(nodes[i]);
|
||||
}
|
||||
|
||||
if (!avoid_focus) {
|
||||
tabElm.focus();
|
||||
}
|
||||
|
||||
// Show selected panel
|
||||
t.showPanel(panelElm);
|
||||
}
|
||||
};
|
||||
|
||||
MCTabs.prototype.getAnchor = function() {
|
||||
var pos, url = document.location.href;
|
||||
|
||||
if ((pos = url.lastIndexOf('#')) != -1)
|
||||
return url.substring(pos + 1);
|
||||
|
||||
return "";
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
//Global instance
|
||||
var mcTabs = new MCTabs();
|
||||
|
||||
tinyMCEPopup.onInit.add(function() {
|
||||
var tinymce = tinyMCEPopup.getWin().tinymce, dom = tinyMCEPopup.dom, each = tinymce.each;
|
||||
tinyMCEPopup.onInit.add(function () {
|
||||
var tinymce = tinyMCEPopup.getWin().tinymce, dom = tinyMCEPopup.dom, each = tinymce.each;
|
||||
|
||||
each(dom.select('div.tabs'), function(tabContainerElm) {
|
||||
//var keyNav;
|
||||
each(dom.select('div.tabs'), function (tabContainerElm) {
|
||||
//var keyNav;
|
||||
|
||||
dom.setAttrib(tabContainerElm, "role", "tablist");
|
||||
dom.setAttrib(tabContainerElm, "role", "tablist");
|
||||
|
||||
var items = tinyMCEPopup.dom.select('li', tabContainerElm);
|
||||
var action = function(id) {
|
||||
mcTabs.displayTab(id, mcTabs.getPanelForTab(id));
|
||||
mcTabs.onChange.dispatch(id);
|
||||
};
|
||||
var items = tinyMCEPopup.dom.select('li', tabContainerElm);
|
||||
var action = function (id) {
|
||||
mcTabs.displayTab(id, mcTabs.getPanelForTab(id));
|
||||
mcTabs.onChange.dispatch(id);
|
||||
};
|
||||
|
||||
each(items, function(item) {
|
||||
dom.setAttrib(item, 'role', 'tab');
|
||||
dom.bind(item, 'click', function(evt) {
|
||||
action(item.id);
|
||||
});
|
||||
});
|
||||
each(items, function (item) {
|
||||
dom.setAttrib(item, 'role', 'tab');
|
||||
dom.bind(item, 'click', function (evt) {
|
||||
action(item.id);
|
||||
});
|
||||
});
|
||||
|
||||
dom.bind(dom.getRoot(), 'keydown', function(evt) {
|
||||
if (evt.keyCode === 9 && evt.ctrlKey && !evt.altKey) { // Tab
|
||||
//keyNav.moveFocus(evt.shiftKey ? -1 : 1);
|
||||
tinymce.dom.Event.cancel(evt);
|
||||
}
|
||||
});
|
||||
dom.bind(dom.getRoot(), 'keydown', function (evt) {
|
||||
if (evt.keyCode === 9 && evt.ctrlKey && !evt.altKey) { // Tab
|
||||
//keyNav.moveFocus(evt.shiftKey ? -1 : 1);
|
||||
tinymce.dom.Event.cancel(evt);
|
||||
}
|
||||
});
|
||||
|
||||
each(dom.select('a', tabContainerElm), function(a) {
|
||||
dom.setAttrib(a, 'tabindex', '-1');
|
||||
});
|
||||
each(dom.select('a', tabContainerElm), function (a) {
|
||||
dom.setAttrib(a, 'tabindex', '-1');
|
||||
});
|
||||
|
||||
/*keyNav = tinyMCEPopup.editor.windowManager.createInstance('tinymce.ui.KeyboardNavigation', {
|
||||
root: tabContainerElm,
|
||||
items: items,
|
||||
onAction: action,
|
||||
actOnFocus: true,
|
||||
enableLeftRight: true,
|
||||
enableUpDown: true
|
||||
}, tinyMCEPopup.dom);*/
|
||||
});
|
||||
/*keyNav = tinyMCEPopup.editor.windowManager.createInstance('tinymce.ui.KeyboardNavigation', {
|
||||
root: tabContainerElm,
|
||||
items: items,
|
||||
onAction: action,
|
||||
actOnFocus: true,
|
||||
enableLeftRight: true,
|
||||
enableUpDown: true
|
||||
}, tinyMCEPopup.dom);*/
|
||||
}
|
||||
);
|
||||
});
|
@@ -1,252 +1,267 @@
|
||||
/**
|
||||
* validate.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
// String validation:
|
||||
// String validation:
|
||||
|
||||
if (!Validator.isEmail('myemail'))
|
||||
alert('Invalid email.');
|
||||
if (!Validator.isEmail('myemail'))
|
||||
alert('Invalid email.');
|
||||
|
||||
// Form validation:
|
||||
// Form validation:
|
||||
|
||||
var f = document.forms['myform'];
|
||||
var f = document.forms['myform'];
|
||||
|
||||
if (!Validator.isEmail(f.myemail))
|
||||
alert('Invalid email.');
|
||||
if (!Validator.isEmail(f.myemail))
|
||||
alert('Invalid email.');
|
||||
*/
|
||||
|
||||
var Validator = {
|
||||
isEmail : function(s) {
|
||||
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
|
||||
},
|
||||
isEmail : function (s) {
|
||||
return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
|
||||
},
|
||||
|
||||
isAbsUrl : function(s) {
|
||||
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
|
||||
},
|
||||
isAbsUrl : function (s) {
|
||||
return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
|
||||
},
|
||||
|
||||
isSize : function(s) {
|
||||
return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
|
||||
},
|
||||
isSize : function (s) {
|
||||
return this.test(s, '^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)?$');
|
||||
},
|
||||
|
||||
isId : function(s) {
|
||||
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
|
||||
},
|
||||
isId : function (s) {
|
||||
return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
|
||||
},
|
||||
|
||||
isEmpty : function(s) {
|
||||
var nl, i;
|
||||
isEmpty : function (s) {
|
||||
var nl, i;
|
||||
|
||||
if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
|
||||
return true;
|
||||
if (s.nodeName == 'SELECT' && s.selectedIndex < 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s.type == 'checkbox' && !s.checked)
|
||||
return true;
|
||||
if (s.type == 'checkbox' && !s.checked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s.type == 'radio') {
|
||||
for (i=0, nl = s.form.elements; i<nl.length; i++) {
|
||||
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
|
||||
return false;
|
||||
}
|
||||
if (s.type == 'radio') {
|
||||
for (i = 0, nl = s.form.elements; i < nl.length; i++) {
|
||||
if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
|
||||
},
|
||||
return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
|
||||
},
|
||||
|
||||
isNumber : function(s, d) {
|
||||
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
|
||||
},
|
||||
isNumber : function (s, d) {
|
||||
return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
|
||||
},
|
||||
|
||||
test : function(s, p) {
|
||||
s = s.nodeType == 1 ? s.value : s;
|
||||
test : function (s, p) {
|
||||
s = s.nodeType == 1 ? s.value : s;
|
||||
|
||||
return s == '' || new RegExp(p).test(s);
|
||||
}
|
||||
return s == '' || new RegExp(p).test(s);
|
||||
}
|
||||
};
|
||||
|
||||
var AutoValidator = {
|
||||
settings : {
|
||||
id_cls : 'id',
|
||||
int_cls : 'int',
|
||||
url_cls : 'url',
|
||||
number_cls : 'number',
|
||||
email_cls : 'email',
|
||||
size_cls : 'size',
|
||||
required_cls : 'required',
|
||||
invalid_cls : 'invalid',
|
||||
min_cls : 'min',
|
||||
max_cls : 'max'
|
||||
},
|
||||
settings : {
|
||||
id_cls : 'id',
|
||||
int_cls : 'int',
|
||||
url_cls : 'url',
|
||||
number_cls : 'number',
|
||||
email_cls : 'email',
|
||||
size_cls : 'size',
|
||||
required_cls : 'required',
|
||||
invalid_cls : 'invalid',
|
||||
min_cls : 'min',
|
||||
max_cls : 'max'
|
||||
},
|
||||
|
||||
init : function(s) {
|
||||
var n;
|
||||
init : function (s) {
|
||||
var n;
|
||||
|
||||
for (n in s)
|
||||
this.settings[n] = s[n];
|
||||
},
|
||||
for (n in s) {
|
||||
this.settings[n] = s[n];
|
||||
}
|
||||
},
|
||||
|
||||
validate : function(f) {
|
||||
var i, nl, s = this.settings, c = 0;
|
||||
validate : function (f) {
|
||||
var i, nl, s = this.settings, c = 0;
|
||||
|
||||
nl = this.tags(f, 'label');
|
||||
for (i=0; i<nl.length; i++) {
|
||||
this.removeClass(nl[i], s.invalid_cls);
|
||||
nl[i].setAttribute('aria-invalid', false);
|
||||
}
|
||||
nl = this.tags(f, 'label');
|
||||
for (i = 0; i < nl.length; i++) {
|
||||
this.removeClass(nl[i], s.invalid_cls);
|
||||
nl[i].setAttribute('aria-invalid', false);
|
||||
}
|
||||
|
||||
c += this.validateElms(f, 'input');
|
||||
c += this.validateElms(f, 'select');
|
||||
c += this.validateElms(f, 'textarea');
|
||||
c += this.validateElms(f, 'input');
|
||||
c += this.validateElms(f, 'select');
|
||||
c += this.validateElms(f, 'textarea');
|
||||
|
||||
return c == 3;
|
||||
},
|
||||
return c == 3;
|
||||
},
|
||||
|
||||
invalidate : function(n) {
|
||||
this.mark(n.form, n);
|
||||
},
|
||||
invalidate : function (n) {
|
||||
this.mark(n.form, n);
|
||||
},
|
||||
|
||||
getErrorMessages : function(f) {
|
||||
var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
|
||||
nl = this.tags(f, "label");
|
||||
for (i=0; i<nl.length; i++) {
|
||||
if (this.hasClass(nl[i], s.invalid_cls)) {
|
||||
field = document.getElementById(nl[i].getAttribute("for"));
|
||||
values = { field: nl[i].textContent };
|
||||
if (this.hasClass(field, s.min_cls, true)) {
|
||||
message = ed.getLang('invalid_data_min');
|
||||
values.min = this.getNum(field, s.min_cls);
|
||||
} else if (this.hasClass(field, s.number_cls)) {
|
||||
message = ed.getLang('invalid_data_number');
|
||||
} else if (this.hasClass(field, s.size_cls)) {
|
||||
message = ed.getLang('invalid_data_size');
|
||||
} else {
|
||||
message = ed.getLang('invalid_data');
|
||||
}
|
||||
getErrorMessages : function (f) {
|
||||
var nl, i, s = this.settings, field, msg, values, messages = [], ed = tinyMCEPopup.editor;
|
||||
nl = this.tags(f, "label");
|
||||
for (i = 0; i < nl.length; i++) {
|
||||
if (this.hasClass(nl[i], s.invalid_cls)) {
|
||||
field = document.getElementById(nl[i].getAttribute("for"));
|
||||
values = { field: nl[i].textContent };
|
||||
if (this.hasClass(field, s.min_cls, true)) {
|
||||
message = ed.getLang('invalid_data_min');
|
||||
values.min = this.getNum(field, s.min_cls);
|
||||
} else if (this.hasClass(field, s.number_cls)) {
|
||||
message = ed.getLang('invalid_data_number');
|
||||
} else if (this.hasClass(field, s.size_cls)) {
|
||||
message = ed.getLang('invalid_data_size');
|
||||
} else {
|
||||
message = ed.getLang('invalid_data');
|
||||
}
|
||||
|
||||
message = message.replace(/{\#([^}]+)\}/g, function(a, b) {
|
||||
return values[b] || '{#' + b + '}';
|
||||
});
|
||||
messages.push(message);
|
||||
}
|
||||
}
|
||||
return messages;
|
||||
},
|
||||
message = message.replace(/{\#([^}]+)\}/g, function (a, b) {
|
||||
return values[b] || '{#' + b + '}';
|
||||
});
|
||||
messages.push(message);
|
||||
}
|
||||
}
|
||||
return messages;
|
||||
},
|
||||
|
||||
reset : function(e) {
|
||||
var t = ['label', 'input', 'select', 'textarea'];
|
||||
var i, j, nl, s = this.settings;
|
||||
reset : function (e) {
|
||||
var t = ['label', 'input', 'select', 'textarea'];
|
||||
var i, j, nl, s = this.settings;
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<t.length; i++) {
|
||||
nl = this.tags(e.form ? e.form : e, t[i]);
|
||||
for (j=0; j<nl.length; j++) {
|
||||
this.removeClass(nl[j], s.invalid_cls);
|
||||
nl[j].setAttribute('aria-invalid', false);
|
||||
}
|
||||
}
|
||||
},
|
||||
for (i = 0; i < t.length; i++) {
|
||||
nl = this.tags(e.form ? e.form : e, t[i]);
|
||||
for (j = 0; j < nl.length; j++) {
|
||||
this.removeClass(nl[j], s.invalid_cls);
|
||||
nl[j].setAttribute('aria-invalid', false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
validateElms : function(f, e) {
|
||||
var nl, i, n, s = this.settings, st = true, va = Validator, v;
|
||||
validateElms : function (f, e) {
|
||||
var nl, i, n, s = this.settings, st = true, va = Validator, v;
|
||||
|
||||
nl = this.tags(f, e);
|
||||
for (i=0; i<nl.length; i++) {
|
||||
n = nl[i];
|
||||
nl = this.tags(f, e);
|
||||
for (i = 0; i < nl.length; i++) {
|
||||
n = nl[i];
|
||||
|
||||
this.removeClass(n, s.invalid_cls);
|
||||
this.removeClass(n, s.invalid_cls);
|
||||
|
||||
if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.required_cls) && va.isEmpty(n)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.number_cls) && !va.isNumber(n)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.email_cls) && !va.isEmail(n)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.size_cls) && !va.isSize(n))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.size_cls) && !va.isSize(n)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.id_cls) && !va.isId(n))
|
||||
st = this.mark(f, n);
|
||||
if (this.hasClass(n, s.id_cls) && !va.isId(n)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.min_cls, true)) {
|
||||
v = this.getNum(n, s.min_cls);
|
||||
if (this.hasClass(n, s.min_cls, true)) {
|
||||
v = this.getNum(n, s.min_cls);
|
||||
|
||||
if (isNaN(v) || parseInt(n.value) < parseInt(v))
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
if (isNaN(v) || parseInt(n.value) < parseInt(v)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.hasClass(n, s.max_cls, true)) {
|
||||
v = this.getNum(n, s.max_cls);
|
||||
if (this.hasClass(n, s.max_cls, true)) {
|
||||
v = this.getNum(n, s.max_cls);
|
||||
|
||||
if (isNaN(v) || parseInt(n.value) > parseInt(v))
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
}
|
||||
if (isNaN(v) || parseInt(n.value) > parseInt(v)) {
|
||||
st = this.mark(f, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return st;
|
||||
},
|
||||
return st;
|
||||
},
|
||||
|
||||
hasClass : function(n, c, d) {
|
||||
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
|
||||
},
|
||||
hasClass : function (n, c, d) {
|
||||
return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
|
||||
},
|
||||
|
||||
getNum : function(n, c) {
|
||||
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
|
||||
c = c.replace(/[^0-9]/g, '');
|
||||
getNum : function (n, c) {
|
||||
c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
|
||||
c = c.replace(/[^0-9]/g, '');
|
||||
|
||||
return c;
|
||||
},
|
||||
return c;
|
||||
},
|
||||
|
||||
addClass : function(n, c, b) {
|
||||
var o = this.removeClass(n, c);
|
||||
n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
|
||||
},
|
||||
addClass : function (n, c, b) {
|
||||
var o = this.removeClass(n, c);
|
||||
n.className = b ? c + (o !== '' ? (' ' + o) : '') : (o !== '' ? (o + ' ') : '') + c;
|
||||
},
|
||||
|
||||
removeClass : function(n, c) {
|
||||
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
|
||||
return n.className = c != ' ' ? c : '';
|
||||
},
|
||||
removeClass : function (n, c) {
|
||||
c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
|
||||
return n.className = c !== ' ' ? c : '';
|
||||
},
|
||||
|
||||
tags : function(f, s) {
|
||||
return f.getElementsByTagName(s);
|
||||
},
|
||||
tags : function (f, s) {
|
||||
return f.getElementsByTagName(s);
|
||||
},
|
||||
|
||||
mark : function(f, n) {
|
||||
var s = this.settings;
|
||||
mark : function (f, n) {
|
||||
var s = this.settings;
|
||||
|
||||
this.addClass(n, s.invalid_cls);
|
||||
n.setAttribute('aria-invalid', 'true');
|
||||
this.markLabels(f, n, s.invalid_cls);
|
||||
this.addClass(n, s.invalid_cls);
|
||||
n.setAttribute('aria-invalid', 'true');
|
||||
this.markLabels(f, n, s.invalid_cls);
|
||||
|
||||
return false;
|
||||
},
|
||||
return false;
|
||||
},
|
||||
|
||||
markLabels : function(f, n, ic) {
|
||||
var nl, i;
|
||||
markLabels : function (f, n, ic) {
|
||||
var nl, i;
|
||||
|
||||
nl = this.tags(f, "label");
|
||||
for (i=0; i<nl.length; i++) {
|
||||
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
|
||||
this.addClass(nl[i], ic);
|
||||
}
|
||||
nl = this.tags(f, "label");
|
||||
for (i = 0; i < nl.length; i++) {
|
||||
if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id) {
|
||||
this.addClass(nl[i], ic);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user