wp-tinymce.php 0000644 00000002022 14740051667 0007357 0 ustar 00 0;
});
};
var itemsToArray = function (value, defaultValue) {
var stringToItemsArray = function (value) {
return typeof value === 'string' ? splitNoEmpty(value, /[ ,]/) : value;
};
var boolToItemsArray = function (value, defaultValue) {
return value === false ? [] : defaultValue;
};
if (Type.isArray(value)) {
return value;
} else if (Type.isString(value)) {
return stringToItemsArray(value);
} else if (Type.isBoolean(value)) {
return boolToItemsArray(value, defaultValue);
}
return defaultValue;
};
var getToolbarItemsOr = function (predicate) {
return function (editor, name, defaultValue) {
var value = name in editor.settings ? editor.settings[name] : defaultValue;
validDefaultOrDie(defaultValue, predicate);
return itemsToArray(value, defaultValue);
};
};
var EditorSettings = {
getStringOr: getByTypeOr(Type.isString),
getBoolOr: getByTypeOr(Type.isBoolean),
getNumberOr: getByTypeOr(Type.isNumber),
getHandlerOr: getByTypeOr(Type.isFunction),
getToolbarItemsOr: getToolbarItemsOr(Type.isArray)
};
var global$6 = tinymce.util.Tools.resolve('tinymce.geom.Rect');
var result$1 = function (rect, position) {
return {
rect: rect,
position: position
};
};
var moveTo = function (rect, toRect) {
return {
x: toRect.x,
y: toRect.y,
w: rect.w,
h: rect.h
};
};
var calcByPositions = function (testPositions1, testPositions2, targetRect, contentAreaRect, panelRect) {
var relPos, relRect, outputPanelRect;
var paddedContentRect = {
x: contentAreaRect.x,
y: contentAreaRect.y,
w: contentAreaRect.w + (contentAreaRect.w < panelRect.w + targetRect.w ? panelRect.w : 0),
h: contentAreaRect.h + (contentAreaRect.h < panelRect.h + targetRect.h ? panelRect.h : 0)
};
relPos = global$6.findBestRelativePosition(panelRect, targetRect, paddedContentRect, testPositions1);
targetRect = global$6.clamp(targetRect, paddedContentRect);
if (relPos) {
relRect = global$6.relativePosition(panelRect, targetRect, relPos);
outputPanelRect = moveTo(panelRect, relRect);
return result$1(outputPanelRect, relPos);
}
targetRect = global$6.intersect(paddedContentRect, targetRect);
if (targetRect) {
relPos = global$6.findBestRelativePosition(panelRect, targetRect, paddedContentRect, testPositions2);
if (relPos) {
relRect = global$6.relativePosition(panelRect, targetRect, relPos);
outputPanelRect = moveTo(panelRect, relRect);
return result$1(outputPanelRect, relPos);
}
outputPanelRect = moveTo(panelRect, targetRect);
return result$1(outputPanelRect, relPos);
}
return null;
};
var calcInsert = function (targetRect, contentAreaRect, panelRect) {
return calcByPositions([
'cr-cl',
'cl-cr'
], [
'bc-tc',
'bl-tl',
'br-tr'
], targetRect, contentAreaRect, panelRect);
};
var calc = function (targetRect, contentAreaRect, panelRect) {
return calcByPositions([
'tc-bc',
'bc-tc',
'tl-bl',
'bl-tl',
'tr-br',
'br-tr',
'cr-cl',
'cl-cr'
], [
'bc-tc',
'bl-tl',
'br-tr',
'cr-cl'
], targetRect, contentAreaRect, panelRect);
};
var userConstrain = function (handler, targetRect, contentAreaRect, panelRect) {
var userConstrainedPanelRect;
if (typeof handler === 'function') {
userConstrainedPanelRect = handler({
elementRect: Convert.toClientRect(targetRect),
contentAreaRect: Convert.toClientRect(contentAreaRect),
panelRect: Convert.toClientRect(panelRect)
});
return Convert.fromClientRect(userConstrainedPanelRect);
}
return panelRect;
};
var defaultHandler = function (rects) {
return rects.panelRect;
};
var Layout = {
calcInsert: calcInsert,
calc: calc,
userConstrain: userConstrain,
defaultHandler: defaultHandler
};
var toAbsoluteUrl = function (editor, url) {
return editor.documentBaseURI.toAbsolute(url);
};
var urlFromName = function (name) {
var prefix = global$5.baseURL + '/skins/';
return name ? prefix + name : prefix + 'lightgray';
};
var getTextSelectionToolbarItems = function (editor) {
return EditorSettings.getToolbarItemsOr(editor, 'selection_toolbar', [
'bold',
'italic',
'|',
'quicklink',
'h2',
'h3',
'blockquote'
]);
};
var getInsertToolbarItems = function (editor) {
return EditorSettings.getToolbarItemsOr(editor, 'insert_toolbar', [
'quickimage',
'quicktable'
]);
};
var getPositionHandler = function (editor) {
return EditorSettings.getHandlerOr(editor, 'inline_toolbar_position_handler', Layout.defaultHandler);
};
var getSkinUrl = function (editor) {
var settings = editor.settings;
return settings.skin_url ? toAbsoluteUrl(editor, settings.skin_url) : urlFromName(settings.skin);
};
var isSkinDisabled = function (editor) {
return editor.settings.skin === false;
};
var Settings = {
getTextSelectionToolbarItems: getTextSelectionToolbarItems,
getInsertToolbarItems: getInsertToolbarItems,
getPositionHandler: getPositionHandler,
getSkinUrl: getSkinUrl,
isSkinDisabled: isSkinDisabled
};
var fireSkinLoaded$1 = function (editor, callback) {
var done = function () {
editor._skinLoaded = true;
Events.fireSkinLoaded(editor);
callback();
};
if (editor.initialized) {
done();
} else {
editor.on('init', done);
}
};
var load = function (editor, callback) {
var skinUrl = Settings.getSkinUrl(editor);
var done = function () {
fireSkinLoaded$1(editor, callback);
};
if (Settings.isSkinDisabled(editor)) {
done();
} else {
global$2.DOM.styleSheetLoader.load(skinUrl + '/skin.min.css', done);
editor.contentCSS.push(skinUrl + '/content.inline.min.css');
}
};
var SkinLoader = { load: load };
var getSelectionElements = function (editor) {
var node = editor.selection.getNode();
var elms = editor.dom.getParents(node, '*');
return elms;
};
var createToolbar = function (editor, selector, id, items) {
var selectorPredicate = function (elm) {
return editor.dom.is(elm, selector);
};
return {
predicate: selectorPredicate,
id: id,
items: items
};
};
var getToolbars = function (editor) {
var contextToolbars = editor.contextToolbars;
return DeepFlatten.flatten([
contextToolbars ? contextToolbars : [],
createToolbar(editor, 'img', 'image', 'alignleft aligncenter alignright')
]);
};
var findMatchResult = function (editor, toolbars) {
var result, elements, contextToolbarsPredicateIds;
elements = getSelectionElements(editor);
contextToolbarsPredicateIds = PredicateId.fromContextToolbars(toolbars);
result = Matcher.match(editor, [
ElementMatcher.element(elements[0], contextToolbarsPredicateIds),
SelectionMatcher.textSelection('text'),
SelectionMatcher.emptyTextBlock(elements, 'insert'),
ElementMatcher.parent(elements, contextToolbarsPredicateIds)
]);
return result && result.rect ? result : null;
};
var editorHasFocus = function (editor) {
return domGlobals.document.activeElement === editor.getBody();
};
var togglePanel = function (editor, panel) {
var toggle = function () {
var toolbars = getToolbars(editor);
var result = findMatchResult(editor, toolbars);
if (result) {
panel.show(editor, result.id, result.rect, toolbars);
} else {
panel.hide();
}
};
return function () {
if (!editor.removed && editorHasFocus(editor)) {
toggle();
}
};
};
var repositionPanel = function (editor, panel) {
return function () {
var toolbars = getToolbars(editor);
var result = findMatchResult(editor, toolbars);
if (result) {
panel.reposition(editor, result.id, result.rect);
}
};
};
var ignoreWhenFormIsVisible = function (editor, panel, f) {
return function () {
if (!editor.removed && !panel.inForm()) {
f();
}
};
};
var bindContextualToolbarsEvents = function (editor, panel) {
var throttledTogglePanel = global$3.throttle(togglePanel(editor, panel), 0);
var throttledTogglePanelWhenNotInForm = global$3.throttle(ignoreWhenFormIsVisible(editor, panel, togglePanel(editor, panel)), 0);
var reposition = repositionPanel(editor, panel);
editor.on('blur hide ObjectResizeStart', panel.hide);
editor.on('click', throttledTogglePanel);
editor.on('nodeChange mouseup', throttledTogglePanelWhenNotInForm);
editor.on('ResizeEditor keyup', throttledTogglePanel);
editor.on('ResizeWindow', reposition);
global$2.DOM.bind(global$1.container, 'scroll', reposition);
editor.on('remove', function () {
global$2.DOM.unbind(global$1.container, 'scroll', reposition);
panel.remove();
});
editor.shortcuts.add('Alt+F10,F10', '', panel.focus);
};
var overrideLinkShortcut = function (editor, panel) {
editor.shortcuts.remove('meta+k');
editor.shortcuts.add('meta+k', '', function () {
var toolbars = getToolbars(editor);
var result = Matcher.match(editor, [SelectionMatcher.textSelection('quicklink')]);
if (result) {
panel.show(editor, result.id, result.rect, toolbars);
}
});
};
var renderInlineUI = function (editor, panel) {
SkinLoader.load(editor, function () {
bindContextualToolbarsEvents(editor, panel);
overrideLinkShortcut(editor, panel);
});
return {};
};
var fail = function (message) {
throw new Error(message);
};
var renderUI = function (editor, panel) {
return editor.inline ? renderInlineUI(editor, panel) : fail('inlite theme only supports inline mode.');
};
var Render = { renderUI: renderUI };
var noop = function () {
};
var constant = function (value) {
return function () {
return value;
};
};
var never = constant(false);
var always = constant(true);
var none = function () {
return NONE;
};
var NONE = function () {
var eq = function (o) {
return o.isNone();
};
var call = function (thunk) {
return thunk();
};
var id = function (n) {
return n;
};
var me = {
fold: function (n, s) {
return n();
},
is: never,
isSome: never,
isNone: always,
getOr: id,
getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: constant(null),
getOrUndefined: constant(undefined),
or: id,
orThunk: call,
map: none,
each: noop,
bind: none,
exists: never,
forall: always,
filter: none,
equals: eq,
equals_: eq,
toArray: function () {
return [];
},
toString: constant('none()')
};
if (Object.freeze) {
Object.freeze(me);
}
return me;
}();
var some = function (a) {
var constant_a = constant(a);
var self = function () {
return me;
};
var bind = function (f) {
return f(a);
};
var me = {
fold: function (n, s) {
return s(a);
},
is: function (v) {
return a === v;
},
isSome: always,
isNone: never,
getOr: constant_a,
getOrThunk: constant_a,
getOrDie: constant_a,
getOrNull: constant_a,
getOrUndefined: constant_a,
or: self,
orThunk: self,
map: function (f) {
return some(f(a));
},
each: function (f) {
f(a);
},
bind: bind,
exists: bind,
forall: bind,
filter: function (f) {
return f(a) ? me : NONE;
},
toArray: function () {
return [a];
},
toString: function () {
return 'some(' + a + ')';
},
equals: function (o) {
return o.is(a);
},
equals_: function (o, elementEq) {
return o.fold(never, function (b) {
return elementEq(a, b);
});
}
};
return me;
};
var from = function (value) {
return value === null || value === undefined ? NONE : some(value);
};
var Option = {
some: some,
none: none,
from: from
};
var typeOf = function (x) {
if (x === null) {
return 'null';
}
var t = typeof x;
if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
return 'array';
}
if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
return 'string';
}
return t;
};
var isType$1 = function (type) {
return function (value) {
return typeOf(value) === type;
};
};
var isArray$1 = isType$1('array');
var isFunction$1 = isType$1('function');
var isNumber$1 = isType$1('number');
var nativeSlice = Array.prototype.slice;
var nativeIndexOf = Array.prototype.indexOf;
var nativePush = Array.prototype.push;
var rawIndexOf = function (ts, t) {
return nativeIndexOf.call(ts, t);
};
var indexOf = function (xs, x) {
var r = rawIndexOf(xs, x);
return r === -1 ? Option.none() : Option.some(r);
};
var exists = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
var map = function (xs, f) {
var len = xs.length;
var r = new Array(len);
for (var i = 0; i < len; i++) {
var x = xs[i];
r[i] = f(x, i);
}
return r;
};
var each = function (xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i);
}
};
var filter = function (xs, pred) {
var r = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
var foldl = function (xs, f, acc) {
each(xs, function (x) {
acc = f(acc, x);
});
return acc;
};
var find = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(x);
}
}
return Option.none();
};
var flatten$1 = function (xs) {
var r = [];
for (var i = 0, len = xs.length; i < len; ++i) {
if (!isArray$1(xs[i])) {
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
}
nativePush.apply(r, xs[i]);
}
return r;
};
var from$1 = isFunction$1(Array.from) ? Array.from : function (x) {
return nativeSlice.call(x);
};
var count = 0;
var funcs = {
id: function () {
return 'mceu_' + count++;
},
create: function (name, attrs, children) {
var elm = domGlobals.document.createElement(name);
global$2.DOM.setAttribs(elm, attrs);
if (typeof children === 'string') {
elm.innerHTML = children;
} else {
global$4.each(children, function (child) {
if (child.nodeType) {
elm.appendChild(child);
}
});
}
return elm;
},
createFragment: function (html) {
return global$2.DOM.createFragment(html);
},
getWindowSize: function () {
return global$2.DOM.getViewPort();
},
getSize: function (elm) {
var width, height;
if (elm.getBoundingClientRect) {
var rect = elm.getBoundingClientRect();
width = Math.max(rect.width || rect.right - rect.left, elm.offsetWidth);
height = Math.max(rect.height || rect.bottom - rect.bottom, elm.offsetHeight);
} else {
width = elm.offsetWidth;
height = elm.offsetHeight;
}
return {
width: width,
height: height
};
},
getPos: function (elm, root) {
return global$2.DOM.getPos(elm, root || funcs.getContainer());
},
getContainer: function () {
return global$1.container ? global$1.container : domGlobals.document.body;
},
getViewPort: function (win) {
return global$2.DOM.getViewPort(win);
},
get: function (id) {
return domGlobals.document.getElementById(id);
},
addClass: function (elm, cls) {
return global$2.DOM.addClass(elm, cls);
},
removeClass: function (elm, cls) {
return global$2.DOM.removeClass(elm, cls);
},
hasClass: function (elm, cls) {
return global$2.DOM.hasClass(elm, cls);
},
toggleClass: function (elm, cls, state) {
return global$2.DOM.toggleClass(elm, cls, state);
},
css: function (elm, name, value) {
return global$2.DOM.setStyle(elm, name, value);
},
getRuntimeStyle: function (elm, name) {
return global$2.DOM.getStyle(elm, name, true);
},
on: function (target, name, callback, scope) {
return global$2.DOM.bind(target, name, callback, scope);
},
off: function (target, name, callback) {
return global$2.DOM.unbind(target, name, callback);
},
fire: function (target, name, args) {
return global$2.DOM.fire(target, name, args);
},
innerHtml: function (elm, html) {
global$2.DOM.setHTML(elm, html);
}
};
var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
var global$8 = tinymce.util.Tools.resolve('tinymce.util.Class');
var global$9 = tinymce.util.Tools.resolve('tinymce.util.EventDispatcher');
var BoxUtils = {
parseBox: function (value) {
var len;
var radix = 10;
if (!value) {
return;
}
if (typeof value === 'number') {
value = value || 0;
return {
top: value,
left: value,
bottom: value,
right: value
};
}
value = value.split(' ');
len = value.length;
if (len === 1) {
value[1] = value[2] = value[3] = value[0];
} else if (len === 2) {
value[2] = value[0];
value[3] = value[1];
} else if (len === 3) {
value[3] = value[1];
}
return {
top: parseInt(value[0], radix) || 0,
right: parseInt(value[1], radix) || 0,
bottom: parseInt(value[2], radix) || 0,
left: parseInt(value[3], radix) || 0
};
},
measureBox: function (elm, prefix) {
function getStyle(name) {
var defaultView = elm.ownerDocument.defaultView;
if (defaultView) {
var computedStyle = defaultView.getComputedStyle(elm, null);
if (computedStyle) {
name = name.replace(/[A-Z]/g, function (a) {
return '-' + a;
});
return computedStyle.getPropertyValue(name);
} else {
return null;
}
}
return elm.currentStyle[name];
}
function getSide(name) {
var val = parseFloat(getStyle(name));
return isNaN(val) ? 0 : val;
}
return {
top: getSide(prefix + 'TopWidth'),
right: getSide(prefix + 'RightWidth'),
bottom: getSide(prefix + 'BottomWidth'),
left: getSide(prefix + 'LeftWidth')
};
}
};
function noop$1() {
}
function ClassList(onchange) {
this.cls = [];
this.cls._map = {};
this.onchange = onchange || noop$1;
this.prefix = '';
}
global$4.extend(ClassList.prototype, {
add: function (cls) {
if (cls && !this.contains(cls)) {
this.cls._map[cls] = true;
this.cls.push(cls);
this._change();
}
return this;
},
remove: function (cls) {
if (this.contains(cls)) {
var i = void 0;
for (i = 0; i < this.cls.length; i++) {
if (this.cls[i] === cls) {
break;
}
}
this.cls.splice(i, 1);
delete this.cls._map[cls];
this._change();
}
return this;
},
toggle: function (cls, state) {
var curState = this.contains(cls);
if (curState !== state) {
if (curState) {
this.remove(cls);
} else {
this.add(cls);
}
this._change();
}
return this;
},
contains: function (cls) {
return !!this.cls._map[cls];
},
_change: function () {
delete this.clsValue;
this.onchange.call(this);
}
});
ClassList.prototype.toString = function () {
var value;
if (this.clsValue) {
return this.clsValue;
}
value = '';
for (var i = 0; i < this.cls.length; i++) {
if (i > 0) {
value += ' ';
}
value += this.prefix + this.cls[i];
}
return value;
};
function unique(array) {
var uniqueItems = [];
var i = array.length, item;
while (i--) {
item = array[i];
if (!item.__checked) {
uniqueItems.push(item);
item.__checked = 1;
}
}
i = uniqueItems.length;
while (i--) {
delete uniqueItems[i].__checked;
}
return uniqueItems;
}
var expression = /^([\w\\*]+)?(?:#([\w\-\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i;
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g;
var whiteSpace = /^\s*|\s*$/g;
var Collection;
var Selector = global$8.extend({
init: function (selector) {
var match = this.match;
function compileNameFilter(name) {
if (name) {
name = name.toLowerCase();
return function (item) {
return name === '*' || item.type === name;
};
}
}
function compileIdFilter(id) {
if (id) {
return function (item) {
return item._name === id;
};
}
}
function compileClassesFilter(classes) {
if (classes) {
classes = classes.split('.');
return function (item) {
var i = classes.length;
while (i--) {
if (!item.classes.contains(classes[i])) {
return false;
}
}
return true;
};
}
}
function compileAttrFilter(name, cmp, check) {
if (name) {
return function (item) {
var value = item[name] ? item[name]() : '';
return !cmp ? !!check : cmp === '=' ? value === check : cmp === '*=' ? value.indexOf(check) >= 0 : cmp === '~=' ? (' ' + value + ' ').indexOf(' ' + check + ' ') >= 0 : cmp === '!=' ? value !== check : cmp === '^=' ? value.indexOf(check) === 0 : cmp === '$=' ? value.substr(value.length - check.length) === check : false;
};
}
}
function compilePsuedoFilter(name) {
var notSelectors;
if (name) {
name = /(?:not\((.+)\))|(.+)/i.exec(name);
if (!name[1]) {
name = name[2];
return function (item, index, length) {
return name === 'first' ? index === 0 : name === 'last' ? index === length - 1 : name === 'even' ? index % 2 === 0 : name === 'odd' ? index % 2 === 1 : item[name] ? item[name]() : false;
};
}
notSelectors = parseChunks(name[1], []);
return function (item) {
return !match(item, notSelectors);
};
}
}
function compile(selector, filters, direct) {
var parts;
function add(filter) {
if (filter) {
filters.push(filter);
}
}
parts = expression.exec(selector.replace(whiteSpace, ''));
add(compileNameFilter(parts[1]));
add(compileIdFilter(parts[2]));
add(compileClassesFilter(parts[3]));
add(compileAttrFilter(parts[4], parts[5], parts[6]));
add(compilePsuedoFilter(parts[7]));
filters.pseudo = !!parts[7];
filters.direct = direct;
return filters;
}
function parseChunks(selector, selectors) {
var parts = [];
var extra, matches, i;
do {
chunker.exec('');
matches = chunker.exec(selector);
if (matches) {
selector = matches[3];
parts.push(matches[1]);
if (matches[2]) {
extra = matches[3];
break;
}
}
} while (matches);
if (extra) {
parseChunks(extra, selectors);
}
selector = [];
for (i = 0; i < parts.length; i++) {
if (parts[i] !== '>') {
selector.push(compile(parts[i], [], parts[i - 1] === '>'));
}
}
selectors.push(selector);
return selectors;
}
this._selectors = parseChunks(selector, []);
},
match: function (control, selectors) {
var i, l, si, sl, selector, fi, fl, filters, index, length, siblings, count, item;
selectors = selectors || this._selectors;
for (i = 0, l = selectors.length; i < l; i++) {
selector = selectors[i];
sl = selector.length;
item = control;
count = 0;
for (si = sl - 1; si >= 0; si--) {
filters = selector[si];
while (item) {
if (filters.pseudo) {
siblings = item.parent().items();
index = length = siblings.length;
while (index--) {
if (siblings[index] === item) {
break;
}
}
}
for (fi = 0, fl = filters.length; fi < fl; fi++) {
if (!filters[fi](item, index, length)) {
fi = fl + 1;
break;
}
}
if (fi === fl) {
count++;
break;
} else {
if (si === sl - 1) {
break;
}
}
item = item.parent();
}
}
if (count === sl) {
return true;
}
}
return false;
},
find: function (container) {
var matches = [], i, l;
var selectors = this._selectors;
function collect(items, selector, index) {
var i, l, fi, fl, item;
var filters = selector[index];
for (i = 0, l = items.length; i < l; i++) {
item = items[i];
for (fi = 0, fl = filters.length; fi < fl; fi++) {
if (!filters[fi](item, i, l)) {
fi = fl + 1;
break;
}
}
if (fi === fl) {
if (index === selector.length - 1) {
matches.push(item);
} else {
if (item.items) {
collect(item.items(), selector, index + 1);
}
}
} else if (filters.direct) {
return;
}
if (item.items) {
collect(item.items(), selector, index);
}
}
}
if (container.items) {
for (i = 0, l = selectors.length; i < l; i++) {
collect(container.items(), selectors[i], 0);
}
if (l > 1) {
matches = unique(matches);
}
}
if (!Collection) {
Collection = Selector.Collection;
}
return new Collection(matches);
}
});
var Collection$1, proto;
var push = Array.prototype.push, slice = Array.prototype.slice;
proto = {
length: 0,
init: function (items) {
if (items) {
this.add(items);
}
},
add: function (items) {
var self = this;
if (!global$4.isArray(items)) {
if (items instanceof Collection$1) {
self.add(items.toArray());
} else {
push.call(self, items);
}
} else {
push.apply(self, items);
}
return self;
},
set: function (items) {
var self = this;
var len = self.length;
var i;
self.length = 0;
self.add(items);
for (i = self.length; i < len; i++) {
delete self[i];
}
return self;
},
filter: function (selector) {
var self = this;
var i, l;
var matches = [];
var item, match;
if (typeof selector === 'string') {
selector = new Selector(selector);
match = function (item) {
return selector.match(item);
};
} else {
match = selector;
}
for (i = 0, l = self.length; i < l; i++) {
item = self[i];
if (match(item)) {
matches.push(item);
}
}
return new Collection$1(matches);
},
slice: function () {
return new Collection$1(slice.apply(this, arguments));
},
eq: function (index) {
return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
},
each: function (callback) {
global$4.each(this, callback);
return this;
},
toArray: function () {
return global$4.toArray(this);
},
indexOf: function (ctrl) {
var self = this;
var i = self.length;
while (i--) {
if (self[i] === ctrl) {
break;
}
}
return i;
},
reverse: function () {
return new Collection$1(global$4.toArray(this).reverse());
},
hasClass: function (cls) {
return this[0] ? this[0].classes.contains(cls) : false;
},
prop: function (name, value) {
var self = this;
var item;
if (value !== undefined) {
self.each(function (item) {
if (item[name]) {
item[name](value);
}
});
return self;
}
item = self[0];
if (item && item[name]) {
return item[name]();
}
},
exec: function (name) {
var self = this, args = global$4.toArray(arguments).slice(1);
self.each(function (item) {
if (item[name]) {
item[name].apply(item, args);
}
});
return self;
},
remove: function () {
var i = this.length;
while (i--) {
this[i].remove();
}
return this;
},
addClass: function (cls) {
return this.each(function (item) {
item.classes.add(cls);
});
},
removeClass: function (cls) {
return this.each(function (item) {
item.classes.remove(cls);
});
}
};
global$4.each('fire on off show hide append prepend before after reflow'.split(' '), function (name) {
proto[name] = function () {
var args = global$4.toArray(arguments);
this.each(function (ctrl) {
if (name in ctrl) {
ctrl[name].apply(ctrl, args);
}
});
return this;
};
});
global$4.each('text name disabled active selected checked visible parent value data'.split(' '), function (name) {
proto[name] = function (value) {
return this.prop(name, value);
};
});
Collection$1 = global$8.extend(proto);
Selector.Collection = Collection$1;
var Collection$2 = Collection$1;
var Binding = function (settings) {
this.create = settings.create;
};
Binding.create = function (model, name) {
return new Binding({
create: function (otherModel, otherName) {
var bindings;
var fromSelfToOther = function (e) {
otherModel.set(otherName, e.value);
};
var fromOtherToSelf = function (e) {
model.set(name, e.value);
};
otherModel.on('change:' + otherName, fromOtherToSelf);
model.on('change:' + name, fromSelfToOther);
bindings = otherModel._bindings;
if (!bindings) {
bindings = otherModel._bindings = [];
otherModel.on('destroy', function () {
var i = bindings.length;
while (i--) {
bindings[i]();
}
});
}
bindings.push(function () {
model.off('change:' + name, fromSelfToOther);
});
return model.get(name);
}
});
};
var global$a = tinymce.util.Tools.resolve('tinymce.util.Observable');
function isNode(node) {
return node.nodeType > 0;
}
function isEqual(a, b) {
var k, checked;
if (a === b) {
return true;
}
if (a === null || b === null) {
return a === b;
}
if (typeof a !== 'object' || typeof b !== 'object') {
return a === b;
}
if (global$4.isArray(b)) {
if (a.length !== b.length) {
return false;
}
k = a.length;
while (k--) {
if (!isEqual(a[k], b[k])) {
return false;
}
}
}
if (isNode(a) || isNode(b)) {
return a === b;
}
checked = {};
for (k in b) {
if (!isEqual(a[k], b[k])) {
return false;
}
checked[k] = true;
}
for (k in a) {
if (!checked[k] && !isEqual(a[k], b[k])) {
return false;
}
}
return true;
}
var ObservableObject = global$8.extend({
Mixins: [global$a],
init: function (data) {
var name, value;
data = data || {};
for (name in data) {
value = data[name];
if (value instanceof Binding) {
data[name] = value.create(this, name);
}
}
this.data = data;
},
set: function (name, value) {
var key, args;
var oldValue = this.data[name];
if (value instanceof Binding) {
value = value.create(this, name);
}
if (typeof name === 'object') {
for (key in name) {
this.set(key, name[key]);
}
return this;
}
if (!isEqual(oldValue, value)) {
this.data[name] = value;
args = {
target: this,
name: name,
value: value,
oldValue: oldValue
};
this.fire('change:' + name, args);
this.fire('change', args);
}
return this;
},
get: function (name) {
return this.data[name];
},
has: function (name) {
return name in this.data;
},
bind: function (name) {
return Binding.create(this, name);
},
destroy: function () {
this.fire('destroy');
}
});
var dirtyCtrls = {}, animationFrameRequested;
var ReflowQueue = {
add: function (ctrl) {
var parent = ctrl.parent();
if (parent) {
if (!parent._layout || parent._layout.isNative()) {
return;
}
if (!dirtyCtrls[parent._id]) {
dirtyCtrls[parent._id] = parent;
}
if (!animationFrameRequested) {
animationFrameRequested = true;
global$3.requestAnimationFrame(function () {
var id, ctrl;
animationFrameRequested = false;
for (id in dirtyCtrls) {
ctrl = dirtyCtrls[id];
if (ctrl.state.get('rendered')) {
ctrl.reflow();
}
}
dirtyCtrls = {};
}, domGlobals.document.body);
}
}
},
remove: function (ctrl) {
if (dirtyCtrls[ctrl._id]) {
delete dirtyCtrls[ctrl._id];
}
}
};
var getUiContainerDelta = function (ctrl) {
var uiContainer = getUiContainer(ctrl);
if (uiContainer && global$2.DOM.getStyle(uiContainer, 'position', true) !== 'static') {
var containerPos = global$2.DOM.getPos(uiContainer);
var dx = uiContainer.scrollLeft - containerPos.x;
var dy = uiContainer.scrollTop - containerPos.y;
return Option.some({
x: dx,
y: dy
});
} else {
return Option.none();
}
};
var setUiContainer = function (editor, ctrl) {
var uiContainer = global$2.DOM.select(editor.settings.ui_container)[0];
ctrl.getRoot().uiContainer = uiContainer;
};
var getUiContainer = function (ctrl) {
return ctrl ? ctrl.getRoot().uiContainer : null;
};
var inheritUiContainer = function (fromCtrl, toCtrl) {
return toCtrl.uiContainer = getUiContainer(fromCtrl);
};
var UiContainer = {
getUiContainerDelta: getUiContainerDelta,
setUiContainer: setUiContainer,
getUiContainer: getUiContainer,
inheritUiContainer: inheritUiContainer
};
var hasMouseWheelEventSupport = 'onmousewheel' in domGlobals.document;
var hasWheelEventSupport = false;
var classPrefix = 'mce-';
var Control, idCounter = 0;
var proto$1 = {
Statics: { classPrefix: classPrefix },
isRtl: function () {
return Control.rtl;
},
classPrefix: classPrefix,
init: function (settings) {
var self = this;
var classes, defaultClasses;
function applyClasses(classes) {
var i;
classes = classes.split(' ');
for (i = 0; i < classes.length; i++) {
self.classes.add(classes[i]);
}
}
self.settings = settings = global$4.extend({}, self.Defaults, settings);
self._id = settings.id || 'mceu_' + idCounter++;
self._aria = { role: settings.role };
self._elmCache = {};
self.$ = global$7;
self.state = new ObservableObject({
visible: true,
active: false,
disabled: false,
value: ''
});
self.data = new ObservableObject(settings.data);
self.classes = new ClassList(function () {
if (self.state.get('rendered')) {
self.getEl().className = this.toString();
}
});
self.classes.prefix = self.classPrefix;
classes = settings.classes;
if (classes) {
if (self.Defaults) {
defaultClasses = self.Defaults.classes;
if (defaultClasses && classes !== defaultClasses) {
applyClasses(defaultClasses);
}
}
applyClasses(classes);
}
global$4.each('title text name visible disabled active value'.split(' '), function (name) {
if (name in settings) {
self[name](settings[name]);
}
});
self.on('click', function () {
if (self.disabled()) {
return false;
}
});
self.settings = settings;
self.borderBox = BoxUtils.parseBox(settings.border);
self.paddingBox = BoxUtils.parseBox(settings.padding);
self.marginBox = BoxUtils.parseBox(settings.margin);
if (settings.hidden) {
self.hide();
}
},
Properties: 'parent,name',
getContainerElm: function () {
var uiContainer = UiContainer.getUiContainer(this);
return uiContainer ? uiContainer : funcs.getContainer();
},
getParentCtrl: function (elm) {
var ctrl;
var lookup = this.getRoot().controlIdLookup;
while (elm && lookup) {
ctrl = lookup[elm.id];
if (ctrl) {
break;
}
elm = elm.parentNode;
}
return ctrl;
},
initLayoutRect: function () {
var self = this;
var settings = self.settings;
var borderBox, layoutRect;
var elm = self.getEl();
var width, height, minWidth, minHeight, autoResize;
var startMinWidth, startMinHeight, initialSize;
borderBox = self.borderBox = self.borderBox || BoxUtils.measureBox(elm, 'border');
self.paddingBox = self.paddingBox || BoxUtils.measureBox(elm, 'padding');
self.marginBox = self.marginBox || BoxUtils.measureBox(elm, 'margin');
initialSize = funcs.getSize(elm);
startMinWidth = settings.minWidth;
startMinHeight = settings.minHeight;
minWidth = startMinWidth || initialSize.width;
minHeight = startMinHeight || initialSize.height;
width = settings.width;
height = settings.height;
autoResize = settings.autoResize;
autoResize = typeof autoResize !== 'undefined' ? autoResize : !width && !height;
width = width || minWidth;
height = height || minHeight;
var deltaW = borderBox.left + borderBox.right;
var deltaH = borderBox.top + borderBox.bottom;
var maxW = settings.maxWidth || 65535;
var maxH = settings.maxHeight || 65535;
self._layoutRect = layoutRect = {
x: settings.x || 0,
y: settings.y || 0,
w: width,
h: height,
deltaW: deltaW,
deltaH: deltaH,
contentW: width - deltaW,
contentH: height - deltaH,
innerW: width - deltaW,
innerH: height - deltaH,
startMinWidth: startMinWidth || 0,
startMinHeight: startMinHeight || 0,
minW: Math.min(minWidth, maxW),
minH: Math.min(minHeight, maxH),
maxW: maxW,
maxH: maxH,
autoResize: autoResize,
scrollW: 0
};
self._lastLayoutRect = {};
return layoutRect;
},
layoutRect: function (newRect) {
var self = this;
var curRect = self._layoutRect, lastLayoutRect, size, deltaWidth, deltaHeight, repaintControls;
if (!curRect) {
curRect = self.initLayoutRect();
}
if (newRect) {
deltaWidth = curRect.deltaW;
deltaHeight = curRect.deltaH;
if (newRect.x !== undefined) {
curRect.x = newRect.x;
}
if (newRect.y !== undefined) {
curRect.y = newRect.y;
}
if (newRect.minW !== undefined) {
curRect.minW = newRect.minW;
}
if (newRect.minH !== undefined) {
curRect.minH = newRect.minH;
}
size = newRect.w;
if (size !== undefined) {
size = size < curRect.minW ? curRect.minW : size;
size = size > curRect.maxW ? curRect.maxW : size;
curRect.w = size;
curRect.innerW = size - deltaWidth;
}
size = newRect.h;
if (size !== undefined) {
size = size < curRect.minH ? curRect.minH : size;
size = size > curRect.maxH ? curRect.maxH : size;
curRect.h = size;
curRect.innerH = size - deltaHeight;
}
size = newRect.innerW;
if (size !== undefined) {
size = size < curRect.minW - deltaWidth ? curRect.minW - deltaWidth : size;
size = size > curRect.maxW - deltaWidth ? curRect.maxW - deltaWidth : size;
curRect.innerW = size;
curRect.w = size + deltaWidth;
}
size = newRect.innerH;
if (size !== undefined) {
size = size < curRect.minH - deltaHeight ? curRect.minH - deltaHeight : size;
size = size > curRect.maxH - deltaHeight ? curRect.maxH - deltaHeight : size;
curRect.innerH = size;
curRect.h = size + deltaHeight;
}
if (newRect.contentW !== undefined) {
curRect.contentW = newRect.contentW;
}
if (newRect.contentH !== undefined) {
curRect.contentH = newRect.contentH;
}
lastLayoutRect = self._lastLayoutRect;
if (lastLayoutRect.x !== curRect.x || lastLayoutRect.y !== curRect.y || lastLayoutRect.w !== curRect.w || lastLayoutRect.h !== curRect.h) {
repaintControls = Control.repaintControls;
if (repaintControls) {
if (repaintControls.map && !repaintControls.map[self._id]) {
repaintControls.push(self);
repaintControls.map[self._id] = true;
}
}
lastLayoutRect.x = curRect.x;
lastLayoutRect.y = curRect.y;
lastLayoutRect.w = curRect.w;
lastLayoutRect.h = curRect.h;
}
return self;
}
return curRect;
},
repaint: function () {
var self = this;
var style, bodyStyle, bodyElm, rect, borderBox;
var borderW, borderH, lastRepaintRect, round, value;
round = !domGlobals.document.createRange ? Math.round : function (value) {
return value;
};
style = self.getEl().style;
rect = self._layoutRect;
lastRepaintRect = self._lastRepaintRect || {};
borderBox = self.borderBox;
borderW = borderBox.left + borderBox.right;
borderH = borderBox.top + borderBox.bottom;
if (rect.x !== lastRepaintRect.x) {
style.left = round(rect.x) + 'px';
lastRepaintRect.x = rect.x;
}
if (rect.y !== lastRepaintRect.y) {
style.top = round(rect.y) + 'px';
lastRepaintRect.y = rect.y;
}
if (rect.w !== lastRepaintRect.w) {
value = round(rect.w - borderW);
style.width = (value >= 0 ? value : 0) + 'px';
lastRepaintRect.w = rect.w;
}
if (rect.h !== lastRepaintRect.h) {
value = round(rect.h - borderH);
style.height = (value >= 0 ? value : 0) + 'px';
lastRepaintRect.h = rect.h;
}
if (self._hasBody && rect.innerW !== lastRepaintRect.innerW) {
value = round(rect.innerW);
bodyElm = self.getEl('body');
if (bodyElm) {
bodyStyle = bodyElm.style;
bodyStyle.width = (value >= 0 ? value : 0) + 'px';
}
lastRepaintRect.innerW = rect.innerW;
}
if (self._hasBody && rect.innerH !== lastRepaintRect.innerH) {
value = round(rect.innerH);
bodyElm = bodyElm || self.getEl('body');
if (bodyElm) {
bodyStyle = bodyStyle || bodyElm.style;
bodyStyle.height = (value >= 0 ? value : 0) + 'px';
}
lastRepaintRect.innerH = rect.innerH;
}
self._lastRepaintRect = lastRepaintRect;
self.fire('repaint', {}, false);
},
updateLayoutRect: function () {
var self = this;
self.parent()._lastRect = null;
funcs.css(self.getEl(), {
width: '',
height: ''
});
self._layoutRect = self._lastRepaintRect = self._lastLayoutRect = null;
self.initLayoutRect();
},
on: function (name, callback) {
var self = this;
function resolveCallbackName(name) {
var callback, scope;
if (typeof name !== 'string') {
return name;
}
return function (e) {
if (!callback) {
self.parentsAndSelf().each(function (ctrl) {
var callbacks = ctrl.settings.callbacks;
if (callbacks && (callback = callbacks[name])) {
scope = ctrl;
return false;
}
});
}
if (!callback) {
e.action = name;
this.fire('execute', e);
return;
}
return callback.call(scope, e);
};
}
getEventDispatcher(self).on(name, resolveCallbackName(callback));
return self;
},
off: function (name, callback) {
getEventDispatcher(this).off(name, callback);
return this;
},
fire: function (name, args, bubble) {
var self = this;
args = args || {};
if (!args.control) {
args.control = self;
}
args = getEventDispatcher(self).fire(name, args);
if (bubble !== false && self.parent) {
var parent = self.parent();
while (parent && !args.isPropagationStopped()) {
parent.fire(name, args, false);
parent = parent.parent();
}
}
return args;
},
hasEventListeners: function (name) {
return getEventDispatcher(this).has(name);
},
parents: function (selector) {
var self = this;
var ctrl, parents = new Collection$2();
for (ctrl = self.parent(); ctrl; ctrl = ctrl.parent()) {
parents.add(ctrl);
}
if (selector) {
parents = parents.filter(selector);
}
return parents;
},
parentsAndSelf: function (selector) {
return new Collection$2(this).add(this.parents(selector));
},
next: function () {
var parentControls = this.parent().items();
return parentControls[parentControls.indexOf(this) + 1];
},
prev: function () {
var parentControls = this.parent().items();
return parentControls[parentControls.indexOf(this) - 1];
},
innerHtml: function (html) {
this.$el.html(html);
return this;
},
getEl: function (suffix) {
var id = suffix ? this._id + '-' + suffix : this._id;
if (!this._elmCache[id]) {
this._elmCache[id] = global$7('#' + id)[0];
}
return this._elmCache[id];
},
show: function () {
return this.visible(true);
},
hide: function () {
return this.visible(false);
},
focus: function () {
try {
this.getEl().focus();
} catch (ex) {
}
return this;
},
blur: function () {
this.getEl().blur();
return this;
},
aria: function (name, value) {
var self = this, elm = self.getEl(self.ariaTarget);
if (typeof value === 'undefined') {
return self._aria[name];
}
self._aria[name] = value;
if (self.state.get('rendered')) {
elm.setAttribute(name === 'role' ? name : 'aria-' + name, value);
}
return self;
},
encode: function (text, translate) {
if (translate !== false) {
text = this.translate(text);
}
return (text || '').replace(/[&<>"]/g, function (match) {
return '' + match.charCodeAt(0) + ';';
});
},
translate: function (text) {
return Control.translate ? Control.translate(text) : text;
},
before: function (items) {
var self = this, parent = self.parent();
if (parent) {
parent.insert(items, parent.items().indexOf(self), true);
}
return self;
},
after: function (items) {
var self = this, parent = self.parent();
if (parent) {
parent.insert(items, parent.items().indexOf(self));
}
return self;
},
remove: function () {
var self = this;
var elm = self.getEl();
var parent = self.parent();
var newItems, i;
if (self.items) {
var controls = self.items().toArray();
i = controls.length;
while (i--) {
controls[i].remove();
}
}
if (parent && parent.items) {
newItems = [];
parent.items().each(function (item) {
if (item !== self) {
newItems.push(item);
}
});
parent.items().set(newItems);
parent._lastRect = null;
}
if (self._eventsRoot && self._eventsRoot === self) {
global$7(elm).off();
}
var lookup = self.getRoot().controlIdLookup;
if (lookup) {
delete lookup[self._id];
}
if (elm && elm.parentNode) {
elm.parentNode.removeChild(elm);
}
self.state.set('rendered', false);
self.state.destroy();
self.fire('remove');
return self;
},
renderBefore: function (elm) {
global$7(elm).before(this.renderHtml());
this.postRender();
return this;
},
renderTo: function (elm) {
global$7(elm || this.getContainerElm()).append(this.renderHtml());
this.postRender();
return this;
},
preRender: function () {
},
render: function () {
},
renderHtml: function () {
return '
';
},
postRender: function () {
var self = this;
var settings = self.settings;
var elm, box, parent, name, parentEventsRoot;
self.$el = global$7(self.getEl());
self.state.set('rendered', true);
for (name in settings) {
if (name.indexOf('on') === 0) {
self.on(name.substr(2), settings[name]);
}
}
if (self._eventsRoot) {
for (parent = self.parent(); !parentEventsRoot && parent; parent = parent.parent()) {
parentEventsRoot = parent._eventsRoot;
}
if (parentEventsRoot) {
for (name in parentEventsRoot._nativeEvents) {
self._nativeEvents[name] = true;
}
}
}
bindPendingEvents(self);
if (settings.style) {
elm = self.getEl();
if (elm) {
elm.setAttribute('style', settings.style);
elm.style.cssText = settings.style;
}
}
if (self.settings.border) {
box = self.borderBox;
self.$el.css({
'border-top-width': box.top,
'border-right-width': box.right,
'border-bottom-width': box.bottom,
'border-left-width': box.left
});
}
var root = self.getRoot();
if (!root.controlIdLookup) {
root.controlIdLookup = {};
}
root.controlIdLookup[self._id] = self;
for (var key in self._aria) {
self.aria(key, self._aria[key]);
}
if (self.state.get('visible') === false) {
self.getEl().style.display = 'none';
}
self.bindStates();
self.state.on('change:visible', function (e) {
var state = e.value;
var parentCtrl;
if (self.state.get('rendered')) {
self.getEl().style.display = state === false ? 'none' : '';
self.getEl().getBoundingClientRect();
}
parentCtrl = self.parent();
if (parentCtrl) {
parentCtrl._lastRect = null;
}
self.fire(state ? 'show' : 'hide');
ReflowQueue.add(self);
});
self.fire('postrender', {}, false);
},
bindStates: function () {
},
scrollIntoView: function (align) {
function getOffset(elm, rootElm) {
var x, y, parent = elm;
x = y = 0;
while (parent && parent !== rootElm && parent.nodeType) {
x += parent.offsetLeft || 0;
y += parent.offsetTop || 0;
parent = parent.offsetParent;
}
return {
x: x,
y: y
};
}
var elm = this.getEl(), parentElm = elm.parentNode;
var x, y, width, height, parentWidth, parentHeight;
var pos = getOffset(elm, parentElm);
x = pos.x;
y = pos.y;
width = elm.offsetWidth;
height = elm.offsetHeight;
parentWidth = parentElm.clientWidth;
parentHeight = parentElm.clientHeight;
if (align === 'end') {
x -= parentWidth - width;
y -= parentHeight - height;
} else if (align === 'center') {
x -= parentWidth / 2 - width / 2;
y -= parentHeight / 2 - height / 2;
}
parentElm.scrollLeft = x;
parentElm.scrollTop = y;
return this;
},
getRoot: function () {
var ctrl = this, rootControl;
var parents = [];
while (ctrl) {
if (ctrl.rootControl) {
rootControl = ctrl.rootControl;
break;
}
parents.push(ctrl);
rootControl = ctrl;
ctrl = ctrl.parent();
}
if (!rootControl) {
rootControl = this;
}
var i = parents.length;
while (i--) {
parents[i].rootControl = rootControl;
}
return rootControl;
},
reflow: function () {
ReflowQueue.remove(this);
var parent = this.parent();
if (parent && parent._layout && !parent._layout.isNative()) {
parent.reflow();
}
return this;
}
};
global$4.each('text title visible disabled active value'.split(' '), function (name) {
proto$1[name] = function (value) {
if (arguments.length === 0) {
return this.state.get(name);
}
if (typeof value !== 'undefined') {
this.state.set(name, value);
}
return this;
};
});
Control = global$8.extend(proto$1);
function getEventDispatcher(obj) {
if (!obj._eventDispatcher) {
obj._eventDispatcher = new global$9({
scope: obj,
toggleEvent: function (name, state) {
if (state && global$9.isNative(name)) {
if (!obj._nativeEvents) {
obj._nativeEvents = {};
}
obj._nativeEvents[name] = true;
if (obj.state.get('rendered')) {
bindPendingEvents(obj);
}
}
}
});
}
return obj._eventDispatcher;
}
function bindPendingEvents(eventCtrl) {
var i, l, parents, eventRootCtrl, nativeEvents, name;
function delegate(e) {
var control = eventCtrl.getParentCtrl(e.target);
if (control) {
control.fire(e.type, e);
}
}
function mouseLeaveHandler() {
var ctrl = eventRootCtrl._lastHoverCtrl;
if (ctrl) {
ctrl.fire('mouseleave', { target: ctrl.getEl() });
ctrl.parents().each(function (ctrl) {
ctrl.fire('mouseleave', { target: ctrl.getEl() });
});
eventRootCtrl._lastHoverCtrl = null;
}
}
function mouseEnterHandler(e) {
var ctrl = eventCtrl.getParentCtrl(e.target), lastCtrl = eventRootCtrl._lastHoverCtrl, idx = 0, i, parents, lastParents;
if (ctrl !== lastCtrl) {
eventRootCtrl._lastHoverCtrl = ctrl;
parents = ctrl.parents().toArray().reverse();
parents.push(ctrl);
if (lastCtrl) {
lastParents = lastCtrl.parents().toArray().reverse();
lastParents.push(lastCtrl);
for (idx = 0; idx < lastParents.length; idx++) {
if (parents[idx] !== lastParents[idx]) {
break;
}
}
for (i = lastParents.length - 1; i >= idx; i--) {
lastCtrl = lastParents[i];
lastCtrl.fire('mouseleave', { target: lastCtrl.getEl() });
}
}
for (i = idx; i < parents.length; i++) {
ctrl = parents[i];
ctrl.fire('mouseenter', { target: ctrl.getEl() });
}
}
}
function fixWheelEvent(e) {
e.preventDefault();
if (e.type === 'mousewheel') {
e.deltaY = -1 / 40 * e.wheelDelta;
if (e.wheelDeltaX) {
e.deltaX = -1 / 40 * e.wheelDeltaX;
}
} else {
e.deltaX = 0;
e.deltaY = e.detail;
}
e = eventCtrl.fire('wheel', e);
}
nativeEvents = eventCtrl._nativeEvents;
if (nativeEvents) {
parents = eventCtrl.parents().toArray();
parents.unshift(eventCtrl);
for (i = 0, l = parents.length; !eventRootCtrl && i < l; i++) {
eventRootCtrl = parents[i]._eventsRoot;
}
if (!eventRootCtrl) {
eventRootCtrl = parents[parents.length - 1] || eventCtrl;
}
eventCtrl._eventsRoot = eventRootCtrl;
for (l = i, i = 0; i < l; i++) {
parents[i]._eventsRoot = eventRootCtrl;
}
var eventRootDelegates = eventRootCtrl._delegates;
if (!eventRootDelegates) {
eventRootDelegates = eventRootCtrl._delegates = {};
}
for (name in nativeEvents) {
if (!nativeEvents) {
return false;
}
if (name === 'wheel' && !hasWheelEventSupport) {
if (hasMouseWheelEventSupport) {
global$7(eventCtrl.getEl()).on('mousewheel', fixWheelEvent);
} else {
global$7(eventCtrl.getEl()).on('DOMMouseScroll', fixWheelEvent);
}
continue;
}
if (name === 'mouseenter' || name === 'mouseleave') {
if (!eventRootCtrl._hasMouseEnter) {
global$7(eventRootCtrl.getEl()).on('mouseleave', mouseLeaveHandler).on('mouseover', mouseEnterHandler);
eventRootCtrl._hasMouseEnter = 1;
}
} else if (!eventRootDelegates[name]) {
global$7(eventRootCtrl.getEl()).on(name, delegate);
eventRootDelegates[name] = true;
}
nativeEvents[name] = false;
}
}
}
var Control$1 = Control;
var isStatic = function (elm) {
return funcs.getRuntimeStyle(elm, 'position') === 'static';
};
var isFixed = function (ctrl) {
return ctrl.state.get('fixed');
};
function calculateRelativePosition(ctrl, targetElm, rel) {
var ctrlElm, pos, x, y, selfW, selfH, targetW, targetH, viewport, size;
viewport = getWindowViewPort();
pos = funcs.getPos(targetElm, UiContainer.getUiContainer(ctrl));
x = pos.x;
y = pos.y;
if (isFixed(ctrl) && isStatic(domGlobals.document.body)) {
x -= viewport.x;
y -= viewport.y;
}
ctrlElm = ctrl.getEl();
size = funcs.getSize(ctrlElm);
selfW = size.width;
selfH = size.height;
size = funcs.getSize(targetElm);
targetW = size.width;
targetH = size.height;
rel = (rel || '').split('');
if (rel[0] === 'b') {
y += targetH;
}
if (rel[1] === 'r') {
x += targetW;
}
if (rel[0] === 'c') {
y += Math.round(targetH / 2);
}
if (rel[1] === 'c') {
x += Math.round(targetW / 2);
}
if (rel[3] === 'b') {
y -= selfH;
}
if (rel[4] === 'r') {
x -= selfW;
}
if (rel[3] === 'c') {
y -= Math.round(selfH / 2);
}
if (rel[4] === 'c') {
x -= Math.round(selfW / 2);
}
return {
x: x,
y: y,
w: selfW,
h: selfH
};
}
var getUiContainerViewPort = function (customUiContainer) {
return {
x: 0,
y: 0,
w: customUiContainer.scrollWidth - 1,
h: customUiContainer.scrollHeight - 1
};
};
var getWindowViewPort = function () {
var win = domGlobals.window;
var x = Math.max(win.pageXOffset, domGlobals.document.body.scrollLeft, domGlobals.document.documentElement.scrollLeft);
var y = Math.max(win.pageYOffset, domGlobals.document.body.scrollTop, domGlobals.document.documentElement.scrollTop);
var w = win.innerWidth || domGlobals.document.documentElement.clientWidth;
var h = win.innerHeight || domGlobals.document.documentElement.clientHeight;
return {
x: x,
y: y,
w: w,
h: h
};
};
var getViewPortRect = function (ctrl) {
var customUiContainer = UiContainer.getUiContainer(ctrl);
return customUiContainer && !isFixed(ctrl) ? getUiContainerViewPort(customUiContainer) : getWindowViewPort();
};
var Movable = {
testMoveRel: function (elm, rels) {
var viewPortRect = getViewPortRect(this);
for (var i = 0; i < rels.length; i++) {
var pos = calculateRelativePosition(this, elm, rels[i]);
if (isFixed(this)) {
if (pos.x > 0 && pos.x + pos.w < viewPortRect.w && pos.y > 0 && pos.y + pos.h < viewPortRect.h) {
return rels[i];
}
} else {
if (pos.x > viewPortRect.x && pos.x + pos.w < viewPortRect.w + viewPortRect.x && pos.y > viewPortRect.y && pos.y + pos.h < viewPortRect.h + viewPortRect.y) {
return rels[i];
}
}
}
return rels[0];
},
moveRel: function (elm, rel) {
if (typeof rel !== 'string') {
rel = this.testMoveRel(elm, rel);
}
var pos = calculateRelativePosition(this, elm, rel);
return this.moveTo(pos.x, pos.y);
},
moveBy: function (dx, dy) {
var self = this, rect = self.layoutRect();
self.moveTo(rect.x + dx, rect.y + dy);
return self;
},
moveTo: function (x, y) {
var self = this;
function constrain(value, max, size) {
if (value < 0) {
return 0;
}
if (value + size > max) {
value = max - size;
return value < 0 ? 0 : value;
}
return value;
}
if (self.settings.constrainToViewport) {
var viewPortRect = getViewPortRect(this);
var layoutRect = self.layoutRect();
x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w);
y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h);
}
var uiContainer = UiContainer.getUiContainer(self);
if (uiContainer && isStatic(uiContainer) && !isFixed(self)) {
x -= uiContainer.scrollLeft;
y -= uiContainer.scrollTop;
}
if (uiContainer) {
x += 1;
y += 1;
}
if (self.state.get('rendered')) {
self.layoutRect({
x: x,
y: y
}).repaint();
} else {
self.settings.x = x;
self.settings.y = y;
}
self.fire('move', {
x: x,
y: y
});
return self;
}
};
var Tooltip = Control$1.extend({
Mixins: [Movable],
Defaults: { classes: 'widget tooltip tooltip-n' },
renderHtml: function () {
var self = this, prefix = self.classPrefix;
return '' + '
' + '
' + self.encode(self.state.get('text')) + '
' + '
';
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.getEl().lastChild.innerHTML = self.encode(e.value);
});
return self._super();
},
repaint: function () {
var self = this;
var style, rect;
style = self.getEl().style;
rect = self._layoutRect;
style.left = rect.x + 'px';
style.top = rect.y + 'px';
style.zIndex = 65535 + 65535;
}
});
var Widget = Control$1.extend({
init: function (settings) {
var self = this;
self._super(settings);
settings = self.settings;
self.canFocus = true;
if (settings.tooltip && Widget.tooltips !== false) {
self.on('mouseenter', function (e) {
var tooltip = self.tooltip().moveTo(-65535);
if (e.control === self) {
var rel = tooltip.text(settings.tooltip).show().testMoveRel(self.getEl(), [
'bc-tc',
'bc-tl',
'bc-tr'
]);
tooltip.classes.toggle('tooltip-n', rel === 'bc-tc');
tooltip.classes.toggle('tooltip-nw', rel === 'bc-tl');
tooltip.classes.toggle('tooltip-ne', rel === 'bc-tr');
tooltip.moveRel(self.getEl(), rel);
} else {
tooltip.hide();
}
});
self.on('mouseleave mousedown click', function () {
self.tooltip().remove();
self._tooltip = null;
});
}
self.aria('label', settings.ariaLabel || settings.tooltip);
},
tooltip: function () {
if (!this._tooltip) {
this._tooltip = new Tooltip({ type: 'tooltip' });
UiContainer.inheritUiContainer(this, this._tooltip);
this._tooltip.renderTo();
}
return this._tooltip;
},
postRender: function () {
var self = this, settings = self.settings;
self._super();
if (!self.parent() && (settings.width || settings.height)) {
self.initLayoutRect();
self.repaint();
}
if (settings.autofocus) {
self.focus();
}
},
bindStates: function () {
var self = this;
function disable(state) {
self.aria('disabled', state);
self.classes.toggle('disabled', state);
}
function active(state) {
self.aria('pressed', state);
self.classes.toggle('active', state);
}
self.state.on('change:disabled', function (e) {
disable(e.value);
});
self.state.on('change:active', function (e) {
active(e.value);
});
if (self.state.get('disabled')) {
disable(true);
}
if (self.state.get('active')) {
active(true);
}
return self._super();
},
remove: function () {
this._super();
if (this._tooltip) {
this._tooltip.remove();
this._tooltip = null;
}
}
});
var Progress = Widget.extend({
Defaults: { value: 0 },
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('progress');
if (!self.settings.filter) {
self.settings.filter = function (value) {
return Math.round(value);
};
}
},
renderHtml: function () {
var self = this, id = self._id, prefix = this.classPrefix;
return '';
},
postRender: function () {
var self = this;
self._super();
self.value(self.settings.value);
return self;
},
bindStates: function () {
var self = this;
function setValue(value) {
value = self.settings.filter(value);
self.getEl().lastChild.innerHTML = value + '%';
self.getEl().firstChild.firstChild.style.width = value + '%';
}
self.state.on('change:value', function (e) {
setValue(e.value);
});
setValue(self.state.get('value'));
return self._super();
}
});
var updateLiveRegion = function (ctx, text) {
ctx.getEl().lastChild.textContent = text + (ctx.progressBar ? ' ' + ctx.progressBar.value() + '%' : '');
};
var Notification = Control$1.extend({
Mixins: [Movable],
Defaults: { classes: 'widget notification' },
init: function (settings) {
var self = this;
self._super(settings);
self.maxWidth = settings.maxWidth;
if (settings.text) {
self.text(settings.text);
}
if (settings.icon) {
self.icon = settings.icon;
}
if (settings.color) {
self.color = settings.color;
}
if (settings.type) {
self.classes.add('notification-' + settings.type);
}
if (settings.timeout && (settings.timeout < 0 || settings.timeout > 0) && !settings.closeButton) {
self.closeButton = false;
} else {
self.classes.add('has-close');
self.closeButton = true;
}
if (settings.progressBar) {
self.progressBar = new Progress();
}
self.on('click', function (e) {
if (e.target.className.indexOf(self.classPrefix + 'close') !== -1) {
self.close();
}
});
},
renderHtml: function () {
var self = this;
var prefix = self.classPrefix;
var icon = '', closeButton = '', progressBar = '', notificationStyle = '';
if (self.icon) {
icon = ' ';
}
notificationStyle = ' style="max-width: ' + self.maxWidth + 'px;' + (self.color ? 'background-color: ' + self.color + ';"' : '"');
if (self.closeButton) {
closeButton = '\xD7 ';
}
if (self.progressBar) {
progressBar = self.progressBar.renderHtml();
}
return '' + icon + '
' + self.state.get('text') + '
' + progressBar + closeButton + '
' + '
';
},
postRender: function () {
var self = this;
global$3.setTimeout(function () {
self.$el.addClass(self.classPrefix + 'in');
updateLiveRegion(self, self.state.get('text'));
}, 100);
return self._super();
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.getEl().firstChild.innerHTML = e.value;
updateLiveRegion(self, e.value);
});
if (self.progressBar) {
self.progressBar.bindStates();
self.progressBar.state.on('change:value', function (e) {
updateLiveRegion(self, self.state.get('text'));
});
}
return self._super();
},
close: function () {
var self = this;
if (!self.fire('close').isDefaultPrevented()) {
self.remove();
}
return self;
},
repaint: function () {
var self = this;
var style, rect;
style = self.getEl().style;
rect = self._layoutRect;
style.left = rect.x + 'px';
style.top = rect.y + 'px';
style.zIndex = 65535 - 1;
}
});
function NotificationManagerImpl (editor) {
var getEditorContainer = function (editor) {
return editor.inline ? editor.getElement() : editor.getContentAreaContainer();
};
var getContainerWidth = function () {
var container = getEditorContainer(editor);
return funcs.getSize(container).width;
};
var prePositionNotifications = function (notifications) {
each(notifications, function (notification) {
notification.moveTo(0, 0);
});
};
var positionNotifications = function (notifications) {
if (notifications.length > 0) {
var firstItem = notifications.slice(0, 1)[0];
var container = getEditorContainer(editor);
firstItem.moveRel(container, 'tc-tc');
each(notifications, function (notification, index) {
if (index > 0) {
notification.moveRel(notifications[index - 1].getEl(), 'bc-tc');
}
});
}
};
var reposition = function (notifications) {
prePositionNotifications(notifications);
positionNotifications(notifications);
};
var open = function (args, closeCallback) {
var extendedArgs = global$4.extend(args, { maxWidth: getContainerWidth() });
var notif = new Notification(extendedArgs);
notif.args = extendedArgs;
if (extendedArgs.timeout > 0) {
notif.timer = setTimeout(function () {
notif.close();
closeCallback();
}, extendedArgs.timeout);
}
notif.on('close', function () {
closeCallback();
});
notif.renderTo();
return notif;
};
var close = function (notification) {
notification.close();
};
var getArgs = function (notification) {
return notification.args;
};
return {
open: open,
close: close,
reposition: reposition,
getArgs: getArgs
};
}
function getDocumentSize(doc) {
var documentElement, body, scrollWidth, clientWidth;
var offsetWidth, scrollHeight, clientHeight, offsetHeight;
var max = Math.max;
documentElement = doc.documentElement;
body = doc.body;
scrollWidth = max(documentElement.scrollWidth, body.scrollWidth);
clientWidth = max(documentElement.clientWidth, body.clientWidth);
offsetWidth = max(documentElement.offsetWidth, body.offsetWidth);
scrollHeight = max(documentElement.scrollHeight, body.scrollHeight);
clientHeight = max(documentElement.clientHeight, body.clientHeight);
offsetHeight = max(documentElement.offsetHeight, body.offsetHeight);
return {
width: scrollWidth < offsetWidth ? clientWidth : scrollWidth,
height: scrollHeight < offsetHeight ? clientHeight : scrollHeight
};
}
function updateWithTouchData(e) {
var keys, i;
if (e.changedTouches) {
keys = 'screenX screenY pageX pageY clientX clientY'.split(' ');
for (i = 0; i < keys.length; i++) {
e[keys[i]] = e.changedTouches[0][keys[i]];
}
}
}
function DragHelper (id, settings) {
var $eventOverlay;
var doc = settings.document || domGlobals.document;
var downButton;
var start, stop, drag, startX, startY;
settings = settings || {};
var handleElement = doc.getElementById(settings.handle || id);
start = function (e) {
var docSize = getDocumentSize(doc);
var handleElm, cursor;
updateWithTouchData(e);
e.preventDefault();
downButton = e.button;
handleElm = handleElement;
startX = e.screenX;
startY = e.screenY;
if (domGlobals.window.getComputedStyle) {
cursor = domGlobals.window.getComputedStyle(handleElm, null).getPropertyValue('cursor');
} else {
cursor = handleElm.runtimeStyle.cursor;
}
$eventOverlay = global$7('
').css({
position: 'absolute',
top: 0,
left: 0,
width: docSize.width,
height: docSize.height,
zIndex: 2147483647,
opacity: 0.0001,
cursor: cursor
}).appendTo(doc.body);
global$7(doc).on('mousemove touchmove', drag).on('mouseup touchend', stop);
settings.start(e);
};
drag = function (e) {
updateWithTouchData(e);
if (e.button !== downButton) {
return stop(e);
}
e.deltaX = e.screenX - startX;
e.deltaY = e.screenY - startY;
e.preventDefault();
settings.drag(e);
};
stop = function (e) {
updateWithTouchData(e);
global$7(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop);
$eventOverlay.remove();
if (settings.stop) {
settings.stop(e);
}
};
this.destroy = function () {
global$7(handleElement).off();
};
global$7(handleElement).on('mousedown touchstart', start);
}
var global$b = tinymce.util.Tools.resolve('tinymce.ui.Factory');
var hasTabstopData = function (elm) {
return elm.getAttribute('data-mce-tabstop') ? true : false;
};
function KeyboardNavigation (settings) {
var root = settings.root;
var focusedElement, focusedControl;
function isElement(node) {
return node && node.nodeType === 1;
}
try {
focusedElement = domGlobals.document.activeElement;
} catch (ex) {
focusedElement = domGlobals.document.body;
}
focusedControl = root.getParentCtrl(focusedElement);
function getRole(elm) {
elm = elm || focusedElement;
if (isElement(elm)) {
return elm.getAttribute('role');
}
return null;
}
function getParentRole(elm) {
var role, parent = elm || focusedElement;
while (parent = parent.parentNode) {
if (role = getRole(parent)) {
return role;
}
}
}
function getAriaProp(name) {
var elm = focusedElement;
if (isElement(elm)) {
return elm.getAttribute('aria-' + name);
}
}
function isTextInputElement(elm) {
var tagName = elm.tagName.toUpperCase();
return tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT';
}
function canFocus(elm) {
if (isTextInputElement(elm) && !elm.hidden) {
return true;
}
if (hasTabstopData(elm)) {
return true;
}
if (/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(getRole(elm))) {
return true;
}
return false;
}
function getFocusElements(elm) {
var elements = [];
function collect(elm) {
if (elm.nodeType !== 1 || elm.style.display === 'none' || elm.disabled) {
return;
}
if (canFocus(elm)) {
elements.push(elm);
}
for (var i = 0; i < elm.childNodes.length; i++) {
collect(elm.childNodes[i]);
}
}
collect(elm || root.getEl());
return elements;
}
function getNavigationRoot(targetControl) {
var navigationRoot, controls;
targetControl = targetControl || focusedControl;
controls = targetControl.parents().toArray();
controls.unshift(targetControl);
for (var i = 0; i < controls.length; i++) {
navigationRoot = controls[i];
if (navigationRoot.settings.ariaRoot) {
break;
}
}
return navigationRoot;
}
function focusFirst(targetControl) {
var navigationRoot = getNavigationRoot(targetControl);
var focusElements = getFocusElements(navigationRoot.getEl());
if (navigationRoot.settings.ariaRemember && 'lastAriaIndex' in navigationRoot) {
moveFocusToIndex(navigationRoot.lastAriaIndex, focusElements);
} else {
moveFocusToIndex(0, focusElements);
}
}
function moveFocusToIndex(idx, elements) {
if (idx < 0) {
idx = elements.length - 1;
} else if (idx >= elements.length) {
idx = 0;
}
if (elements[idx]) {
elements[idx].focus();
}
return idx;
}
function moveFocus(dir, elements) {
var idx = -1;
var navigationRoot = getNavigationRoot();
elements = elements || getFocusElements(navigationRoot.getEl());
for (var i = 0; i < elements.length; i++) {
if (elements[i] === focusedElement) {
idx = i;
}
}
idx += dir;
navigationRoot.lastAriaIndex = moveFocusToIndex(idx, elements);
}
function left() {
var parentRole = getParentRole();
if (parentRole === 'tablist') {
moveFocus(-1, getFocusElements(focusedElement.parentNode));
} else if (focusedControl.parent().submenu) {
cancel();
} else {
moveFocus(-1);
}
}
function right() {
var role = getRole(), parentRole = getParentRole();
if (parentRole === 'tablist') {
moveFocus(1, getFocusElements(focusedElement.parentNode));
} else if (role === 'menuitem' && parentRole === 'menu' && getAriaProp('haspopup')) {
enter();
} else {
moveFocus(1);
}
}
function up() {
moveFocus(-1);
}
function down() {
var role = getRole(), parentRole = getParentRole();
if (role === 'menuitem' && parentRole === 'menubar') {
enter();
} else if (role === 'button' && getAriaProp('haspopup')) {
enter({ key: 'down' });
} else {
moveFocus(1);
}
}
function tab(e) {
var parentRole = getParentRole();
if (parentRole === 'tablist') {
var elm = getFocusElements(focusedControl.getEl('body'))[0];
if (elm) {
elm.focus();
}
} else {
moveFocus(e.shiftKey ? -1 : 1);
}
}
function cancel() {
focusedControl.fire('cancel');
}
function enter(aria) {
aria = aria || {};
focusedControl.fire('click', {
target: focusedElement,
aria: aria
});
}
root.on('keydown', function (e) {
function handleNonTabOrEscEvent(e, handler) {
if (isTextInputElement(focusedElement) || hasTabstopData(focusedElement)) {
return;
}
if (getRole(focusedElement) === 'slider') {
return;
}
if (handler(e) !== false) {
e.preventDefault();
}
}
if (e.isDefaultPrevented()) {
return;
}
switch (e.keyCode) {
case 37:
handleNonTabOrEscEvent(e, left);
break;
case 39:
handleNonTabOrEscEvent(e, right);
break;
case 38:
handleNonTabOrEscEvent(e, up);
break;
case 40:
handleNonTabOrEscEvent(e, down);
break;
case 27:
cancel();
break;
case 14:
case 13:
case 32:
handleNonTabOrEscEvent(e, enter);
break;
case 9:
tab(e);
e.preventDefault();
break;
}
});
root.on('focusin', function (e) {
focusedElement = e.target;
focusedControl = e.control;
});
return { focusFirst: focusFirst };
}
var selectorCache = {};
var Container = Control$1.extend({
init: function (settings) {
var self = this;
self._super(settings);
settings = self.settings;
if (settings.fixed) {
self.state.set('fixed', true);
}
self._items = new Collection$2();
if (self.isRtl()) {
self.classes.add('rtl');
}
self.bodyClasses = new ClassList(function () {
if (self.state.get('rendered')) {
self.getEl('body').className = this.toString();
}
});
self.bodyClasses.prefix = self.classPrefix;
self.classes.add('container');
self.bodyClasses.add('container-body');
if (settings.containerCls) {
self.classes.add(settings.containerCls);
}
self._layout = global$b.create((settings.layout || '') + 'layout');
if (self.settings.items) {
self.add(self.settings.items);
} else {
self.add(self.render());
}
self._hasBody = true;
},
items: function () {
return this._items;
},
find: function (selector) {
selector = selectorCache[selector] = selectorCache[selector] || new Selector(selector);
return selector.find(this);
},
add: function (items) {
var self = this;
self.items().add(self.create(items)).parent(self);
return self;
},
focus: function (keyboard) {
var self = this;
var focusCtrl, keyboardNav, items;
if (keyboard) {
keyboardNav = self.keyboardNav || self.parents().eq(-1)[0].keyboardNav;
if (keyboardNav) {
keyboardNav.focusFirst(self);
return;
}
}
items = self.find('*');
if (self.statusbar) {
items.add(self.statusbar.items());
}
items.each(function (ctrl) {
if (ctrl.settings.autofocus) {
focusCtrl = null;
return false;
}
if (ctrl.canFocus) {
focusCtrl = focusCtrl || ctrl;
}
});
if (focusCtrl) {
focusCtrl.focus();
}
return self;
},
replace: function (oldItem, newItem) {
var ctrlElm;
var items = this.items();
var i = items.length;
while (i--) {
if (items[i] === oldItem) {
items[i] = newItem;
break;
}
}
if (i >= 0) {
ctrlElm = newItem.getEl();
if (ctrlElm) {
ctrlElm.parentNode.removeChild(ctrlElm);
}
ctrlElm = oldItem.getEl();
if (ctrlElm) {
ctrlElm.parentNode.removeChild(ctrlElm);
}
}
newItem.parent(this);
},
create: function (items) {
var self = this;
var settings;
var ctrlItems = [];
if (!global$4.isArray(items)) {
items = [items];
}
global$4.each(items, function (item) {
if (item) {
if (!(item instanceof Control$1)) {
if (typeof item === 'string') {
item = { type: item };
}
settings = global$4.extend({}, self.settings.defaults, item);
item.type = settings.type = settings.type || item.type || self.settings.defaultType || (settings.defaults ? settings.defaults.type : null);
item = global$b.create(settings);
}
ctrlItems.push(item);
}
});
return ctrlItems;
},
renderNew: function () {
var self = this;
self.items().each(function (ctrl, index) {
var containerElm;
ctrl.parent(self);
if (!ctrl.state.get('rendered')) {
containerElm = self.getEl('body');
if (containerElm.hasChildNodes() && index <= containerElm.childNodes.length - 1) {
global$7(containerElm.childNodes[index]).before(ctrl.renderHtml());
} else {
global$7(containerElm).append(ctrl.renderHtml());
}
ctrl.postRender();
ReflowQueue.add(ctrl);
}
});
self._layout.applyClasses(self.items().filter(':visible'));
self._lastRect = null;
return self;
},
append: function (items) {
return this.add(items).renderNew();
},
prepend: function (items) {
var self = this;
self.items().set(self.create(items).concat(self.items().toArray()));
return self.renderNew();
},
insert: function (items, index, before) {
var self = this;
var curItems, beforeItems, afterItems;
items = self.create(items);
curItems = self.items();
if (!before && index < curItems.length - 1) {
index += 1;
}
if (index >= 0 && index < curItems.length) {
beforeItems = curItems.slice(0, index).toArray();
afterItems = curItems.slice(index).toArray();
curItems.set(beforeItems.concat(items, afterItems));
}
return self.renderNew();
},
fromJSON: function (data) {
var self = this;
for (var name in data) {
self.find('#' + name).value(data[name]);
}
return self;
},
toJSON: function () {
var self = this, data = {};
self.find('*').each(function (ctrl) {
var name = ctrl.name(), value = ctrl.value();
if (name && typeof value !== 'undefined') {
data[name] = value;
}
});
return data;
},
renderHtml: function () {
var self = this, layout = self._layout, role = this.settings.role;
self.preRender();
layout.preRender(self);
return '' + '
' + (self.settings.html || '') + layout.renderHtml(self) + '
' + '
';
},
postRender: function () {
var self = this;
var box;
self.items().exec('postRender');
self._super();
self._layout.postRender(self);
self.state.set('rendered', true);
if (self.settings.style) {
self.$el.css(self.settings.style);
}
if (self.settings.border) {
box = self.borderBox;
self.$el.css({
'border-top-width': box.top,
'border-right-width': box.right,
'border-bottom-width': box.bottom,
'border-left-width': box.left
});
}
if (!self.parent()) {
self.keyboardNav = KeyboardNavigation({ root: self });
}
return self;
},
initLayoutRect: function () {
var self = this, layoutRect = self._super();
self._layout.recalc(self);
return layoutRect;
},
recalc: function () {
var self = this;
var rect = self._layoutRect;
var lastRect = self._lastRect;
if (!lastRect || lastRect.w !== rect.w || lastRect.h !== rect.h) {
self._layout.recalc(self);
rect = self.layoutRect();
self._lastRect = {
x: rect.x,
y: rect.y,
w: rect.w,
h: rect.h
};
return true;
}
},
reflow: function () {
var i;
ReflowQueue.remove(this);
if (this.visible()) {
Control$1.repaintControls = [];
Control$1.repaintControls.map = {};
this.recalc();
i = Control$1.repaintControls.length;
while (i--) {
Control$1.repaintControls[i].repaint();
}
if (this.settings.layout !== 'flow' && this.settings.layout !== 'stack') {
this.repaint();
}
Control$1.repaintControls = [];
}
return this;
}
});
var Scrollable = {
init: function () {
var self = this;
self.on('repaint', self.renderScroll);
},
renderScroll: function () {
var self = this, margin = 2;
function repaintScroll() {
var hasScrollH, hasScrollV, bodyElm;
function repaintAxis(axisName, posName, sizeName, contentSizeName, hasScroll, ax) {
var containerElm, scrollBarElm, scrollThumbElm;
var containerSize, scrollSize, ratio, rect;
var posNameLower, sizeNameLower;
scrollBarElm = self.getEl('scroll' + axisName);
if (scrollBarElm) {
posNameLower = posName.toLowerCase();
sizeNameLower = sizeName.toLowerCase();
global$7(self.getEl('absend')).css(posNameLower, self.layoutRect()[contentSizeName] - 1);
if (!hasScroll) {
global$7(scrollBarElm).css('display', 'none');
return;
}
global$7(scrollBarElm).css('display', 'block');
containerElm = self.getEl('body');
scrollThumbElm = self.getEl('scroll' + axisName + 't');
containerSize = containerElm['client' + sizeName] - margin * 2;
containerSize -= hasScrollH && hasScrollV ? scrollBarElm['client' + ax] : 0;
scrollSize = containerElm['scroll' + sizeName];
ratio = containerSize / scrollSize;
rect = {};
rect[posNameLower] = containerElm['offset' + posName] + margin;
rect[sizeNameLower] = containerSize;
global$7(scrollBarElm).css(rect);
rect = {};
rect[posNameLower] = containerElm['scroll' + posName] * ratio;
rect[sizeNameLower] = containerSize * ratio;
global$7(scrollThumbElm).css(rect);
}
}
bodyElm = self.getEl('body');
hasScrollH = bodyElm.scrollWidth > bodyElm.clientWidth;
hasScrollV = bodyElm.scrollHeight > bodyElm.clientHeight;
repaintAxis('h', 'Left', 'Width', 'contentW', hasScrollH, 'Height');
repaintAxis('v', 'Top', 'Height', 'contentH', hasScrollV, 'Width');
}
function addScroll() {
function addScrollAxis(axisName, posName, sizeName, deltaPosName, ax) {
var scrollStart;
var axisId = self._id + '-scroll' + axisName, prefix = self.classPrefix;
global$7(self.getEl()).append('');
self.draghelper = new DragHelper(axisId + 't', {
start: function () {
scrollStart = self.getEl('body')['scroll' + posName];
global$7('#' + axisId).addClass(prefix + 'active');
},
drag: function (e) {
var ratio, hasScrollH, hasScrollV, containerSize;
var layoutRect = self.layoutRect();
hasScrollH = layoutRect.contentW > layoutRect.innerW;
hasScrollV = layoutRect.contentH > layoutRect.innerH;
containerSize = self.getEl('body')['client' + sizeName] - margin * 2;
containerSize -= hasScrollH && hasScrollV ? self.getEl('scroll' + axisName)['client' + ax] : 0;
ratio = containerSize / self.getEl('body')['scroll' + sizeName];
self.getEl('body')['scroll' + posName] = scrollStart + e['delta' + deltaPosName] / ratio;
},
stop: function () {
global$7('#' + axisId).removeClass(prefix + 'active');
}
});
}
self.classes.add('scroll');
addScrollAxis('v', 'Top', 'Height', 'Y', 'Width');
addScrollAxis('h', 'Left', 'Width', 'X', 'Height');
}
if (self.settings.autoScroll) {
if (!self._hasScroll) {
self._hasScroll = true;
addScroll();
self.on('wheel', function (e) {
var bodyEl = self.getEl('body');
bodyEl.scrollLeft += (e.deltaX || 0) * 10;
bodyEl.scrollTop += e.deltaY * 10;
repaintScroll();
});
global$7(self.getEl('body')).on('scroll', repaintScroll);
}
repaintScroll();
}
}
};
var Panel = Container.extend({
Defaults: {
layout: 'fit',
containerCls: 'panel'
},
Mixins: [Scrollable],
renderHtml: function () {
var self = this;
var layout = self._layout;
var innerHtml = self.settings.html;
self.preRender();
layout.preRender(self);
if (typeof innerHtml === 'undefined') {
innerHtml = '' + layout.renderHtml(self) + '
';
} else {
if (typeof innerHtml === 'function') {
innerHtml = innerHtml.call(self);
}
self._hasBody = false;
}
return '' + (self._preBodyHtml || '') + innerHtml + '
';
}
});
var Resizable = {
resizeToContent: function () {
this._layoutRect.autoResize = true;
this._lastRect = null;
this.reflow();
},
resizeTo: function (w, h) {
if (w <= 1 || h <= 1) {
var rect = funcs.getWindowSize();
w = w <= 1 ? w * rect.w : w;
h = h <= 1 ? h * rect.h : h;
}
this._layoutRect.autoResize = false;
return this.layoutRect({
minW: w,
minH: h,
w: w,
h: h
}).reflow();
},
resizeBy: function (dw, dh) {
var self = this, rect = self.layoutRect();
return self.resizeTo(rect.w + dw, rect.h + dh);
}
};
var documentClickHandler, documentScrollHandler, windowResizeHandler;
var visiblePanels = [];
var zOrder = [];
var hasModal;
function isChildOf(ctrl, parent) {
while (ctrl) {
if (ctrl === parent) {
return true;
}
ctrl = ctrl.parent();
}
}
function skipOrHidePanels(e) {
var i = visiblePanels.length;
while (i--) {
var panel = visiblePanels[i], clickCtrl = panel.getParentCtrl(e.target);
if (panel.settings.autohide) {
if (clickCtrl) {
if (isChildOf(clickCtrl, panel) || panel.parent() === clickCtrl) {
continue;
}
}
e = panel.fire('autohide', { target: e.target });
if (!e.isDefaultPrevented()) {
panel.hide();
}
}
}
}
function bindDocumentClickHandler() {
if (!documentClickHandler) {
documentClickHandler = function (e) {
if (e.button === 2) {
return;
}
skipOrHidePanels(e);
};
global$7(domGlobals.document).on('click touchstart', documentClickHandler);
}
}
function bindDocumentScrollHandler() {
if (!documentScrollHandler) {
documentScrollHandler = function () {
var i;
i = visiblePanels.length;
while (i--) {
repositionPanel$1(visiblePanels[i]);
}
};
global$7(domGlobals.window).on('scroll', documentScrollHandler);
}
}
function bindWindowResizeHandler() {
if (!windowResizeHandler) {
var docElm_1 = domGlobals.document.documentElement;
var clientWidth_1 = docElm_1.clientWidth, clientHeight_1 = docElm_1.clientHeight;
windowResizeHandler = function () {
if (!domGlobals.document.all || clientWidth_1 !== docElm_1.clientWidth || clientHeight_1 !== docElm_1.clientHeight) {
clientWidth_1 = docElm_1.clientWidth;
clientHeight_1 = docElm_1.clientHeight;
FloatPanel.hideAll();
}
};
global$7(domGlobals.window).on('resize', windowResizeHandler);
}
}
function repositionPanel$1(panel) {
var scrollY = funcs.getViewPort().y;
function toggleFixedChildPanels(fixed, deltaY) {
var parent;
for (var i = 0; i < visiblePanels.length; i++) {
if (visiblePanels[i] !== panel) {
parent = visiblePanels[i].parent();
while (parent && (parent = parent.parent())) {
if (parent === panel) {
visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint();
}
}
}
}
}
if (panel.settings.autofix) {
if (!panel.state.get('fixed')) {
panel._autoFixY = panel.layoutRect().y;
if (panel._autoFixY < scrollY) {
panel.fixed(true).layoutRect({ y: 0 }).repaint();
toggleFixedChildPanels(true, scrollY - panel._autoFixY);
}
} else {
if (panel._autoFixY > scrollY) {
panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint();
toggleFixedChildPanels(false, panel._autoFixY - scrollY);
}
}
}
}
function addRemove(add, ctrl) {
var i, zIndex = FloatPanel.zIndex || 65535, topModal;
if (add) {
zOrder.push(ctrl);
} else {
i = zOrder.length;
while (i--) {
if (zOrder[i] === ctrl) {
zOrder.splice(i, 1);
}
}
}
if (zOrder.length) {
for (i = 0; i < zOrder.length; i++) {
if (zOrder[i].modal) {
zIndex++;
topModal = zOrder[i];
}
zOrder[i].getEl().style.zIndex = zIndex;
zOrder[i].zIndex = zIndex;
zIndex++;
}
}
var modalBlockEl = global$7('#' + ctrl.classPrefix + 'modal-block', ctrl.getContainerElm())[0];
if (topModal) {
global$7(modalBlockEl).css('z-index', topModal.zIndex - 1);
} else if (modalBlockEl) {
modalBlockEl.parentNode.removeChild(modalBlockEl);
hasModal = false;
}
FloatPanel.currentZIndex = zIndex;
}
var FloatPanel = Panel.extend({
Mixins: [
Movable,
Resizable
],
init: function (settings) {
var self = this;
self._super(settings);
self._eventsRoot = self;
self.classes.add('floatpanel');
if (settings.autohide) {
bindDocumentClickHandler();
bindWindowResizeHandler();
visiblePanels.push(self);
}
if (settings.autofix) {
bindDocumentScrollHandler();
self.on('move', function () {
repositionPanel$1(this);
});
}
self.on('postrender show', function (e) {
if (e.control === self) {
var $modalBlockEl_1;
var prefix_1 = self.classPrefix;
if (self.modal && !hasModal) {
$modalBlockEl_1 = global$7('#' + prefix_1 + 'modal-block', self.getContainerElm());
if (!$modalBlockEl_1[0]) {
$modalBlockEl_1 = global$7('
').appendTo(self.getContainerElm());
}
global$3.setTimeout(function () {
$modalBlockEl_1.addClass(prefix_1 + 'in');
global$7(self.getEl()).addClass(prefix_1 + 'in');
});
hasModal = true;
}
addRemove(true, self);
}
});
self.on('show', function () {
self.parents().each(function (ctrl) {
if (ctrl.state.get('fixed')) {
self.fixed(true);
return false;
}
});
});
if (settings.popover) {
self._preBodyHtml = '
';
self.classes.add('popover').add('bottom').add(self.isRtl() ? 'end' : 'start');
}
self.aria('label', settings.ariaLabel);
self.aria('labelledby', self._id);
self.aria('describedby', self.describedBy || self._id + '-none');
},
fixed: function (state) {
var self = this;
if (self.state.get('fixed') !== state) {
if (self.state.get('rendered')) {
var viewport = funcs.getViewPort();
if (state) {
self.layoutRect().y -= viewport.y;
} else {
self.layoutRect().y += viewport.y;
}
}
self.classes.toggle('fixed', state);
self.state.set('fixed', state);
}
return self;
},
show: function () {
var self = this;
var i;
var state = self._super();
i = visiblePanels.length;
while (i--) {
if (visiblePanels[i] === self) {
break;
}
}
if (i === -1) {
visiblePanels.push(self);
}
return state;
},
hide: function () {
removeVisiblePanel(this);
addRemove(false, this);
return this._super();
},
hideAll: function () {
FloatPanel.hideAll();
},
close: function () {
var self = this;
if (!self.fire('close').isDefaultPrevented()) {
self.remove();
addRemove(false, self);
}
return self;
},
remove: function () {
removeVisiblePanel(this);
this._super();
},
postRender: function () {
var self = this;
if (self.settings.bodyRole) {
this.getEl('body').setAttribute('role', self.settings.bodyRole);
}
return self._super();
}
});
FloatPanel.hideAll = function () {
var i = visiblePanels.length;
while (i--) {
var panel = visiblePanels[i];
if (panel && panel.settings.autohide) {
panel.hide();
visiblePanels.splice(i, 1);
}
}
};
function removeVisiblePanel(panel) {
var i;
i = visiblePanels.length;
while (i--) {
if (visiblePanels[i] === panel) {
visiblePanels.splice(i, 1);
}
}
i = zOrder.length;
while (i--) {
if (zOrder[i] === panel) {
zOrder.splice(i, 1);
}
}
}
var windows = [];
var oldMetaValue = '';
function toggleFullScreenState(state) {
var noScaleMetaValue = 'width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0';
var viewport = global$7('meta[name=viewport]')[0], contentValue;
if (global$1.overrideViewPort === false) {
return;
}
if (!viewport) {
viewport = domGlobals.document.createElement('meta');
viewport.setAttribute('name', 'viewport');
domGlobals.document.getElementsByTagName('head')[0].appendChild(viewport);
}
contentValue = viewport.getAttribute('content');
if (contentValue && typeof oldMetaValue !== 'undefined') {
oldMetaValue = contentValue;
}
viewport.setAttribute('content', state ? noScaleMetaValue : oldMetaValue);
}
function toggleBodyFullScreenClasses(classPrefix, state) {
if (checkFullscreenWindows() && state === false) {
global$7([
domGlobals.document.documentElement,
domGlobals.document.body
]).removeClass(classPrefix + 'fullscreen');
}
}
function checkFullscreenWindows() {
for (var i = 0; i < windows.length; i++) {
if (windows[i]._fullscreen) {
return true;
}
}
return false;
}
function handleWindowResize() {
if (!global$1.desktop) {
var lastSize_1 = {
w: domGlobals.window.innerWidth,
h: domGlobals.window.innerHeight
};
global$3.setInterval(function () {
var w = domGlobals.window.innerWidth, h = domGlobals.window.innerHeight;
if (lastSize_1.w !== w || lastSize_1.h !== h) {
lastSize_1 = {
w: w,
h: h
};
global$7(domGlobals.window).trigger('resize');
}
}, 100);
}
function reposition() {
var i;
var rect = funcs.getWindowSize();
var layoutRect;
for (i = 0; i < windows.length; i++) {
layoutRect = windows[i].layoutRect();
windows[i].moveTo(windows[i].settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2), windows[i].settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2));
}
}
global$7(domGlobals.window).on('resize', reposition);
}
var Window = FloatPanel.extend({
modal: true,
Defaults: {
border: 1,
layout: 'flex',
containerCls: 'panel',
role: 'dialog',
callbacks: {
submit: function () {
this.fire('submit', { data: this.toJSON() });
},
close: function () {
this.close();
}
}
},
init: function (settings) {
var self = this;
self._super(settings);
if (self.isRtl()) {
self.classes.add('rtl');
}
self.classes.add('window');
self.bodyClasses.add('window-body');
self.state.set('fixed', true);
if (settings.buttons) {
self.statusbar = new Panel({
layout: 'flex',
border: '1 0 0 0',
spacing: 3,
padding: 10,
align: 'center',
pack: self.isRtl() ? 'start' : 'end',
defaults: { type: 'button' },
items: settings.buttons
});
self.statusbar.classes.add('foot');
self.statusbar.parent(self);
}
self.on('click', function (e) {
var closeClass = self.classPrefix + 'close';
if (funcs.hasClass(e.target, closeClass) || funcs.hasClass(e.target.parentNode, closeClass)) {
self.close();
}
});
self.on('cancel', function () {
self.close();
});
self.on('move', function (e) {
if (e.control === self) {
FloatPanel.hideAll();
}
});
self.aria('describedby', self.describedBy || self._id + '-none');
self.aria('label', settings.title);
self._fullscreen = false;
},
recalc: function () {
var self = this;
var statusbar = self.statusbar;
var layoutRect, width, x, needsRecalc;
if (self._fullscreen) {
self.layoutRect(funcs.getWindowSize());
self.layoutRect().contentH = self.layoutRect().innerH;
}
self._super();
layoutRect = self.layoutRect();
if (self.settings.title && !self._fullscreen) {
width = layoutRect.headerW;
if (width > layoutRect.w) {
x = layoutRect.x - Math.max(0, width / 2);
self.layoutRect({
w: width,
x: x
});
needsRecalc = true;
}
}
if (statusbar) {
statusbar.layoutRect({ w: self.layoutRect().innerW }).recalc();
width = statusbar.layoutRect().minW + layoutRect.deltaW;
if (width > layoutRect.w) {
x = layoutRect.x - Math.max(0, width - layoutRect.w);
self.layoutRect({
w: width,
x: x
});
needsRecalc = true;
}
}
if (needsRecalc) {
self.recalc();
}
},
initLayoutRect: function () {
var self = this;
var layoutRect = self._super();
var deltaH = 0, headEl;
if (self.settings.title && !self._fullscreen) {
headEl = self.getEl('head');
var size = funcs.getSize(headEl);
layoutRect.headerW = size.width;
layoutRect.headerH = size.height;
deltaH += layoutRect.headerH;
}
if (self.statusbar) {
deltaH += self.statusbar.layoutRect().h;
}
layoutRect.deltaH += deltaH;
layoutRect.minH += deltaH;
layoutRect.h += deltaH;
var rect = funcs.getWindowSize();
layoutRect.x = self.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2);
layoutRect.y = self.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2);
return layoutRect;
},
renderHtml: function () {
var self = this, layout = self._layout, id = self._id, prefix = self.classPrefix;
var settings = self.settings;
var headerHtml = '', footerHtml = '', html = settings.html;
self.preRender();
layout.preRender(self);
if (settings.title) {
headerHtml = '' + '
' + self.encode(settings.title) + '
' + '
' + '
' + ' ' + ' ' + '
';
}
if (settings.url) {
html = '';
}
if (typeof html === 'undefined') {
html = layout.renderHtml(self);
}
if (self.statusbar) {
footerHtml = self.statusbar.renderHtml();
}
return '' + '
' + headerHtml + '
' + html + '
' + footerHtml + '
' + '
';
},
fullscreen: function (state) {
var self = this;
var documentElement = domGlobals.document.documentElement;
var slowRendering;
var prefix = self.classPrefix;
var layoutRect;
if (state !== self._fullscreen) {
global$7(domGlobals.window).on('resize', function () {
var time;
if (self._fullscreen) {
if (!slowRendering) {
time = new Date().getTime();
var rect = funcs.getWindowSize();
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
if (new Date().getTime() - time > 50) {
slowRendering = true;
}
} else {
if (!self._timer) {
self._timer = global$3.setTimeout(function () {
var rect = funcs.getWindowSize();
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
self._timer = 0;
}, 50);
}
}
}
});
layoutRect = self.layoutRect();
self._fullscreen = state;
if (!state) {
self.borderBox = BoxUtils.parseBox(self.settings.border);
self.getEl('head').style.display = '';
layoutRect.deltaH += layoutRect.headerH;
global$7([
documentElement,
domGlobals.document.body
]).removeClass(prefix + 'fullscreen');
self.classes.remove('fullscreen');
self.moveTo(self._initial.x, self._initial.y).resizeTo(self._initial.w, self._initial.h);
} else {
self._initial = {
x: layoutRect.x,
y: layoutRect.y,
w: layoutRect.w,
h: layoutRect.h
};
self.borderBox = BoxUtils.parseBox('0');
self.getEl('head').style.display = 'none';
layoutRect.deltaH -= layoutRect.headerH + 2;
global$7([
documentElement,
domGlobals.document.body
]).addClass(prefix + 'fullscreen');
self.classes.add('fullscreen');
var rect = funcs.getWindowSize();
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
}
}
return self.reflow();
},
postRender: function () {
var self = this;
var startPos;
setTimeout(function () {
self.classes.add('in');
self.fire('open');
}, 0);
self._super();
if (self.statusbar) {
self.statusbar.postRender();
}
self.focus();
this.dragHelper = new DragHelper(self._id + '-dragh', {
start: function () {
startPos = {
x: self.layoutRect().x,
y: self.layoutRect().y
};
},
drag: function (e) {
self.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY);
}
});
self.on('submit', function (e) {
if (!e.isDefaultPrevented()) {
self.close();
}
});
windows.push(self);
toggleFullScreenState(true);
},
submit: function () {
return this.fire('submit', { data: this.toJSON() });
},
remove: function () {
var self = this;
var i;
self.dragHelper.destroy();
self._super();
if (self.statusbar) {
this.statusbar.remove();
}
toggleBodyFullScreenClasses(self.classPrefix, false);
i = windows.length;
while (i--) {
if (windows[i] === self) {
windows.splice(i, 1);
}
}
toggleFullScreenState(windows.length > 0);
},
getContentWindow: function () {
var ifr = this.getEl().getElementsByTagName('iframe')[0];
return ifr ? ifr.contentWindow : null;
}
});
handleWindowResize();
var MessageBox = Window.extend({
init: function (settings) {
settings = {
border: 1,
padding: 20,
layout: 'flex',
pack: 'center',
align: 'center',
containerCls: 'panel',
autoScroll: true,
buttons: {
type: 'button',
text: 'Ok',
action: 'ok'
},
items: {
type: 'label',
multiline: true,
maxWidth: 500,
maxHeight: 200
}
};
this._super(settings);
},
Statics: {
OK: 1,
OK_CANCEL: 2,
YES_NO: 3,
YES_NO_CANCEL: 4,
msgBox: function (settings) {
var buttons;
var callback = settings.callback || function () {
};
function createButton(text, status, primary) {
return {
type: 'button',
text: text,
subtype: primary ? 'primary' : '',
onClick: function (e) {
e.control.parents()[1].close();
callback(status);
}
};
}
switch (settings.buttons) {
case MessageBox.OK_CANCEL:
buttons = [
createButton('Ok', true, true),
createButton('Cancel', false)
];
break;
case MessageBox.YES_NO:
case MessageBox.YES_NO_CANCEL:
buttons = [
createButton('Yes', 1, true),
createButton('No', 0)
];
if (settings.buttons === MessageBox.YES_NO_CANCEL) {
buttons.push(createButton('Cancel', -1));
}
break;
default:
buttons = [createButton('Ok', true, true)];
break;
}
return new Window({
padding: 20,
x: settings.x,
y: settings.y,
minWidth: 300,
minHeight: 100,
layout: 'flex',
pack: 'center',
align: 'center',
buttons: buttons,
title: settings.title,
role: 'alertdialog',
items: {
type: 'label',
multiline: true,
maxWidth: 500,
maxHeight: 200,
text: settings.text
},
onPostRender: function () {
this.aria('describedby', this.items()[0]._id);
},
onClose: settings.onClose,
onCancel: function () {
callback(false);
}
}).renderTo(domGlobals.document.body).reflow();
},
alert: function (settings, callback) {
if (typeof settings === 'string') {
settings = { text: settings };
}
settings.callback = callback;
return MessageBox.msgBox(settings);
},
confirm: function (settings, callback) {
if (typeof settings === 'string') {
settings = { text: settings };
}
settings.callback = callback;
settings.buttons = MessageBox.OK_CANCEL;
return MessageBox.msgBox(settings);
}
}
});
function WindowManagerImpl (editor) {
var open = function (args, params, closeCallback) {
var win;
args.title = args.title || ' ';
args.url = args.url || args.file;
if (args.url) {
args.width = parseInt(args.width || 320, 10);
args.height = parseInt(args.height || 240, 10);
}
if (args.body) {
args.items = {
defaults: args.defaults,
type: args.bodyType || 'form',
items: args.body,
data: args.data,
callbacks: args.commands
};
}
if (!args.url && !args.buttons) {
args.buttons = [
{
text: 'Ok',
subtype: 'primary',
onclick: function () {
win.find('form')[0].submit();
}
},
{
text: 'Cancel',
onclick: function () {
win.close();
}
}
];
}
win = new Window(args);
win.on('close', function () {
closeCallback(win);
});
if (args.data) {
win.on('postRender', function () {
this.find('*').each(function (ctrl) {
var name = ctrl.name();
if (name in args.data) {
ctrl.value(args.data[name]);
}
});
});
}
win.features = args || {};
win.params = params || {};
win = win.renderTo(domGlobals.document.body).reflow();
return win;
};
var alert = function (message, choiceCallback, closeCallback) {
var win;
win = MessageBox.alert(message, function () {
choiceCallback();
});
win.on('close', function () {
closeCallback(win);
});
return win;
};
var confirm = function (message, choiceCallback, closeCallback) {
var win;
win = MessageBox.confirm(message, function (state) {
choiceCallback(state);
});
win.on('close', function () {
closeCallback(win);
});
return win;
};
var close = function (window) {
window.close();
};
var getParams = function (window) {
return window.params;
};
var setParams = function (window, params) {
window.params = params;
};
return {
open: open,
alert: alert,
confirm: confirm,
close: close,
getParams: getParams,
setParams: setParams
};
}
var get = function (editor, panel) {
var renderUI = function () {
return Render.renderUI(editor, panel);
};
return {
renderUI: renderUI,
getNotificationManagerImpl: function () {
return NotificationManagerImpl(editor);
},
getWindowManagerImpl: function () {
return WindowManagerImpl();
}
};
};
var ThemeApi = { get: get };
var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
var path = function (parts, scope) {
var o = scope !== undefined && scope !== null ? scope : Global;
for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
o = o[parts[i]];
}
return o;
};
var resolve = function (p, scope) {
var parts = p.split('.');
return path(parts, scope);
};
var unsafe = function (name, scope) {
return resolve(name, scope);
};
var getOrDie = function (name, scope) {
var actual = unsafe(name, scope);
if (actual === undefined || actual === null) {
throw new Error(name + ' not available on this browser');
}
return actual;
};
var Global$1 = { getOrDie: getOrDie };
function FileReader () {
var f = Global$1.getOrDie('FileReader');
return new f();
}
var global$c = tinymce.util.Tools.resolve('tinymce.util.Promise');
var blobToBase64 = function (blob) {
return new global$c(function (resolve) {
var reader = FileReader();
reader.onloadend = function () {
resolve(reader.result.split(',')[1]);
};
reader.readAsDataURL(blob);
});
};
var Conversions = { blobToBase64: blobToBase64 };
var pickFile = function () {
return new global$c(function (resolve) {
var fileInput;
fileInput = domGlobals.document.createElement('input');
fileInput.type = 'file';
fileInput.style.position = 'fixed';
fileInput.style.left = 0;
fileInput.style.top = 0;
fileInput.style.opacity = 0.001;
domGlobals.document.body.appendChild(fileInput);
fileInput.onchange = function (e) {
resolve(Array.prototype.slice.call(e.target.files));
};
fileInput.click();
fileInput.parentNode.removeChild(fileInput);
});
};
var Picker = { pickFile: pickFile };
var count$1 = 0;
var seed = function () {
var rnd = function () {
return Math.round(Math.random() * 4294967295).toString(36);
};
return 's' + Date.now().toString(36) + rnd() + rnd() + rnd();
};
var uuid = function (prefix) {
return prefix + count$1++ + seed();
};
var Uuid = { uuid: uuid };
var create$1 = function (dom, rng) {
var bookmark = {};
function setupEndPoint(start) {
var offsetNode, container, offset;
container = rng[start ? 'startContainer' : 'endContainer'];
offset = rng[start ? 'startOffset' : 'endOffset'];
if (container.nodeType === 1) {
offsetNode = dom.create('span', { 'data-mce-type': 'bookmark' });
if (container.hasChildNodes()) {
offset = Math.min(offset, container.childNodes.length - 1);
if (start) {
container.insertBefore(offsetNode, container.childNodes[offset]);
} else {
dom.insertAfter(offsetNode, container.childNodes[offset]);
}
} else {
container.appendChild(offsetNode);
}
container = offsetNode;
offset = 0;
}
bookmark[start ? 'startContainer' : 'endContainer'] = container;
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
}
setupEndPoint(true);
if (!rng.collapsed) {
setupEndPoint();
}
return bookmark;
};
var resolve$1 = function (dom, bookmark) {
function restoreEndPoint(start) {
var container, offset, node;
function nodeIndex(container) {
var node = container.parentNode.firstChild, idx = 0;
while (node) {
if (node === container) {
return idx;
}
if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
idx++;
}
node = node.nextSibling;
}
return -1;
}
container = node = bookmark[start ? 'startContainer' : 'endContainer'];
offset = bookmark[start ? 'startOffset' : 'endOffset'];
if (!container) {
return;
}
if (container.nodeType === 1) {
offset = nodeIndex(container);
container = container.parentNode;
dom.remove(node);
}
bookmark[start ? 'startContainer' : 'endContainer'] = container;
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
}
restoreEndPoint(true);
restoreEndPoint();
var rng = dom.createRng();
rng.setStart(bookmark.startContainer, bookmark.startOffset);
if (bookmark.endContainer) {
rng.setEnd(bookmark.endContainer, bookmark.endOffset);
}
return rng;
};
var Bookmark = {
create: create$1,
resolve: resolve$1
};
var global$d = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
var global$e = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
var getSelectedElements = function (rootElm, startNode, endNode) {
var walker, node;
var elms = [];
walker = new global$d(startNode, rootElm);
for (node = startNode; node; node = walker.next()) {
if (node.nodeType === 1) {
elms.push(node);
}
if (node === endNode) {
break;
}
}
return elms;
};
var unwrapElements = function (editor, elms) {
var bookmark, dom, selection;
dom = editor.dom;
selection = editor.selection;
bookmark = Bookmark.create(dom, selection.getRng());
global$4.each(elms, function (elm) {
editor.dom.remove(elm, true);
});
selection.setRng(Bookmark.resolve(dom, bookmark));
};
var isLink = function (elm) {
return elm.nodeName === 'A' && elm.hasAttribute('href');
};
var getParentAnchorOrSelf = function (dom, elm) {
var anchorElm = dom.getParent(elm, isLink);
return anchorElm ? anchorElm : elm;
};
var getSelectedAnchors = function (editor) {
var startElm, endElm, rootElm, anchorElms, selection, dom, rng;
selection = editor.selection;
dom = editor.dom;
rng = selection.getRng();
startElm = getParentAnchorOrSelf(dom, global$e.getNode(rng.startContainer, rng.startOffset));
endElm = global$e.getNode(rng.endContainer, rng.endOffset);
rootElm = editor.getBody();
anchorElms = global$4.grep(getSelectedElements(rootElm, startElm, endElm), isLink);
return anchorElms;
};
var unlinkSelection = function (editor) {
unwrapElements(editor, getSelectedAnchors(editor));
};
var Unlink = { unlinkSelection: unlinkSelection };
var createTableHtml = function (cols, rows) {
var x, y, html;
html = '';
html += '';
for (y = 0; y < rows; y++) {
html += '';
for (x = 0; x < cols; x++) {
html += ' ';
}
html += ' ';
}
html += ' ';
html += '
';
return html;
};
var getInsertedElement = function (editor) {
var elms = editor.dom.select('*[data-mce-id]');
return elms[0];
};
var insertTableHtml = function (editor, cols, rows) {
editor.undoManager.transact(function () {
var tableElm, cellElm;
editor.insertContent(createTableHtml(cols, rows));
tableElm = getInsertedElement(editor);
tableElm.removeAttribute('data-mce-id');
cellElm = editor.dom.select('td,th', tableElm);
editor.selection.setCursorLocation(cellElm[0], 0);
});
};
var insertTable = function (editor, cols, rows) {
editor.plugins.table ? editor.plugins.table.insertTable(cols, rows) : insertTableHtml(editor, cols, rows);
};
var formatBlock = function (editor, formatName) {
editor.execCommand('FormatBlock', false, formatName);
};
var insertBlob = function (editor, base64, blob) {
var blobCache, blobInfo;
blobCache = editor.editorUpload.blobCache;
blobInfo = blobCache.create(Uuid.uuid('mceu'), blob, base64);
blobCache.add(blobInfo);
editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() }));
};
var collapseSelectionToEnd = function (editor) {
editor.selection.collapse(false);
};
var unlink = function (editor) {
editor.focus();
Unlink.unlinkSelection(editor);
collapseSelectionToEnd(editor);
};
var changeHref = function (editor, elm, url) {
editor.focus();
editor.dom.setAttrib(elm, 'href', url);
collapseSelectionToEnd(editor);
};
var insertLink = function (editor, url) {
editor.execCommand('mceInsertLink', false, { href: url });
collapseSelectionToEnd(editor);
};
var updateOrInsertLink = function (editor, url) {
var elm = editor.dom.getParent(editor.selection.getStart(), 'a[href]');
elm ? changeHref(editor, elm, url) : insertLink(editor, url);
};
var createLink = function (editor, url) {
url.trim().length === 0 ? unlink(editor) : updateOrInsertLink(editor, url);
};
var Actions = {
insertTable: insertTable,
formatBlock: formatBlock,
insertBlob: insertBlob,
createLink: createLink,
unlink: unlink
};
var addHeaderButtons = function (editor) {
var formatBlock = function (name) {
return function () {
Actions.formatBlock(editor, name);
};
};
for (var i = 1; i < 6; i++) {
var name = 'h' + i;
editor.addButton(name, {
text: name.toUpperCase(),
tooltip: 'Heading ' + i,
stateSelector: name,
onclick: formatBlock(name),
onPostRender: function () {
var span = this.getEl().firstChild.firstChild;
span.style.fontWeight = 'bold';
}
});
}
};
var addToEditor = function (editor, panel) {
editor.addButton('quicklink', {
icon: 'link',
tooltip: 'Insert/Edit link',
stateSelector: 'a[href]',
onclick: function () {
panel.showForm(editor, 'quicklink');
}
});
editor.addButton('quickimage', {
icon: 'image',
tooltip: 'Insert image',
onclick: function () {
Picker.pickFile().then(function (files) {
var blob = files[0];
Conversions.blobToBase64(blob).then(function (base64) {
Actions.insertBlob(editor, base64, blob);
});
});
}
});
editor.addButton('quicktable', {
icon: 'table',
tooltip: 'Insert table',
onclick: function () {
panel.hide();
Actions.insertTable(editor, 2, 2);
}
});
addHeaderButtons(editor);
};
var Buttons = { addToEditor: addToEditor };
var getUiContainerDelta$1 = function () {
var uiContainer = global$1.container;
if (uiContainer && global$2.DOM.getStyle(uiContainer, 'position', true) !== 'static') {
var containerPos = global$2.DOM.getPos(uiContainer);
var dx = containerPos.x - uiContainer.scrollLeft;
var dy = containerPos.y - uiContainer.scrollTop;
return Option.some({
x: dx,
y: dy
});
} else {
return Option.none();
}
};
var UiContainer$1 = { getUiContainerDelta: getUiContainerDelta$1 };
var isDomainLike = function (href) {
return /^www\.|\.(com|org|edu|gov|uk|net|ca|de|jp|fr|au|us|ru|ch|it|nl|se|no|es|mil)$/i.test(href.trim());
};
var isAbsolute = function (href) {
return /^https?:\/\//.test(href.trim());
};
var UrlType = {
isDomainLike: isDomainLike,
isAbsolute: isAbsolute
};
var focusFirstTextBox = function (form) {
form.find('textbox').eq(0).each(function (ctrl) {
ctrl.focus();
});
};
var createForm = function (name, spec) {
var form = global$b.create(global$4.extend({
type: 'form',
layout: 'flex',
direction: 'row',
padding: 5,
name: name,
spacing: 3
}, spec));
form.on('show', function () {
focusFirstTextBox(form);
});
return form;
};
var toggleVisibility = function (ctrl, state) {
return state ? ctrl.show() : ctrl.hide();
};
var askAboutPrefix = function (editor, href) {
return new global$c(function (resolve) {
editor.windowManager.confirm('The URL you entered seems to be an external link. Do you want to add the required http:// prefix?', function (result) {
var output = result === true ? 'http://' + href : href;
resolve(output);
});
});
};
var convertLinkToAbsolute = function (editor, href) {
return !UrlType.isAbsolute(href) && UrlType.isDomainLike(href) ? askAboutPrefix(editor, href) : global$c.resolve(href);
};
var createQuickLinkForm = function (editor, hide) {
var attachState = {};
var unlink = function () {
editor.focus();
Actions.unlink(editor);
hide();
};
var onChangeHandler = function (e) {
var meta = e.meta;
if (meta && meta.attach) {
attachState = {
href: this.value(),
attach: meta.attach
};
}
};
var onShowHandler = function (e) {
if (e.control === this) {
var elm = void 0, linkurl = '';
elm = editor.dom.getParent(editor.selection.getStart(), 'a[href]');
if (elm) {
linkurl = editor.dom.getAttrib(elm, 'href');
}
this.fromJSON({ linkurl: linkurl });
toggleVisibility(this.find('#unlink'), elm);
this.find('#linkurl')[0].focus();
}
};
return createForm('quicklink', {
items: [
{
type: 'button',
name: 'unlink',
icon: 'unlink',
onclick: unlink,
tooltip: 'Remove link'
},
{
type: 'filepicker',
name: 'linkurl',
placeholder: 'Paste or type a link',
filetype: 'file',
onchange: onChangeHandler
},
{
type: 'button',
icon: 'checkmark',
subtype: 'primary',
tooltip: 'Ok',
onclick: 'submit'
}
],
onshow: onShowHandler,
onsubmit: function (e) {
convertLinkToAbsolute(editor, e.data.linkurl).then(function (url) {
editor.undoManager.transact(function () {
if (url === attachState.href) {
attachState.attach();
attachState = {};
}
Actions.createLink(editor, url);
});
hide();
});
}
});
};
var Forms = { createQuickLinkForm: createQuickLinkForm };
var getSelectorStateResult = function (itemName, item) {
var result = function (selector, handler) {
return {
selector: selector,
handler: handler
};
};
var activeHandler = function (state) {
item.active(state);
};
var disabledHandler = function (state) {
item.disabled(state);
};
if (item.settings.stateSelector) {
return result(item.settings.stateSelector, activeHandler);
}
if (item.settings.disabledStateSelector) {
return result(item.settings.disabledStateSelector, disabledHandler);
}
return null;
};
var bindSelectorChanged = function (editor, itemName, item) {
return function () {
var result = getSelectorStateResult(itemName, item);
if (result !== null) {
editor.selection.selectorChanged(result.selector, result.handler);
}
};
};
var itemsToArray$1 = function (items) {
if (Type.isArray(items)) {
return items;
} else if (Type.isString(items)) {
return items.split(/[ ,]/);
}
return [];
};
var create$2 = function (editor, name, items) {
var toolbarItems = [];
var buttonGroup;
if (!items) {
return;
}
global$4.each(itemsToArray$1(items), function (item) {
if (item === '|') {
buttonGroup = null;
} else {
if (editor.buttons[item]) {
if (!buttonGroup) {
buttonGroup = {
type: 'buttongroup',
items: []
};
toolbarItems.push(buttonGroup);
}
var button = editor.buttons[item];
if (Type.isFunction(button)) {
button = button();
}
button.type = button.type || 'button';
button = global$b.create(button);
button.on('postRender', bindSelectorChanged(editor, item, button));
buttonGroup.items.push(button);
}
}
});
return global$b.create({
type: 'toolbar',
layout: 'flow',
name: name,
items: toolbarItems
});
};
var Toolbar = { create: create$2 };
var create$3 = function () {
var panel, currentRect;
var createToolbars = function (editor, toolbars) {
return global$4.map(toolbars, function (toolbar) {
return Toolbar.create(editor, toolbar.id, toolbar.items);
});
};
var hasToolbarItems = function (toolbar) {
return toolbar.items().length > 0;
};
var create = function (editor, toolbars) {
var items = createToolbars(editor, toolbars).concat([
Toolbar.create(editor, 'text', Settings.getTextSelectionToolbarItems(editor)),
Toolbar.create(editor, 'insert', Settings.getInsertToolbarItems(editor)),
Forms.createQuickLinkForm(editor, hide)
]);
return global$b.create({
type: 'floatpanel',
role: 'dialog',
classes: 'tinymce tinymce-inline arrow',
ariaLabel: 'Inline toolbar',
layout: 'flex',
direction: 'column',
align: 'stretch',
autohide: false,
autofix: true,
fixed: true,
border: 1,
items: global$4.grep(items, hasToolbarItems),
oncancel: function () {
editor.focus();
}
});
};
var showPanel = function (panel) {
if (panel) {
panel.show();
}
};
var movePanelTo = function (panel, pos) {
panel.moveTo(pos.x, pos.y);
};
var togglePositionClass = function (panel, relPos) {
relPos = relPos ? relPos.substr(0, 2) : '';
global$4.each({
t: 'down',
b: 'up',
c: 'center'
}, function (cls, pos) {
panel.classes.toggle('arrow-' + cls, pos === relPos.substr(0, 1));
});
if (relPos === 'cr') {
panel.classes.toggle('arrow-left', true);
panel.classes.toggle('arrow-right', false);
} else if (relPos === 'cl') {
panel.classes.toggle('arrow-left', false);
panel.classes.toggle('arrow-right', true);
} else {
global$4.each({
l: 'left',
r: 'right'
}, function (cls, pos) {
panel.classes.toggle('arrow-' + cls, pos === relPos.substr(1, 1));
});
}
};
var showToolbar = function (panel, id) {
var toolbars = panel.items().filter('#' + id);
if (toolbars.length > 0) {
toolbars[0].show();
panel.reflow();
return true;
}
return false;
};
var repositionPanelAt = function (panel, id, editor, targetRect) {
var contentAreaRect, panelRect, result, userConstainHandler;
userConstainHandler = Settings.getPositionHandler(editor);
contentAreaRect = Measure.getContentAreaRect(editor);
panelRect = global$2.DOM.getRect(panel.getEl());
if (id === 'insert') {
result = Layout.calcInsert(targetRect, contentAreaRect, panelRect);
} else {
result = Layout.calc(targetRect, contentAreaRect, panelRect);
}
if (result) {
var delta = UiContainer$1.getUiContainerDelta().getOr({
x: 0,
y: 0
});
var transposedPanelRect = {
x: result.rect.x - delta.x,
y: result.rect.y - delta.y,
w: result.rect.w,
h: result.rect.h
};
currentRect = targetRect;
movePanelTo(panel, Layout.userConstrain(userConstainHandler, targetRect, contentAreaRect, transposedPanelRect));
togglePositionClass(panel, result.position);
return true;
} else {
return false;
}
};
var showPanelAt = function (panel, id, editor, targetRect) {
showPanel(panel);
panel.items().hide();
if (!showToolbar(panel, id)) {
hide();
return;
}
if (repositionPanelAt(panel, id, editor, targetRect) === false) {
hide();
}
};
var hasFormVisible = function () {
return panel.items().filter('form:visible').length > 0;
};
var showForm = function (editor, id) {
if (panel) {
panel.items().hide();
if (!showToolbar(panel, id)) {
hide();
return;
}
var contentAreaRect = void 0, panelRect = void 0, result = void 0, userConstainHandler = void 0;
showPanel(panel);
panel.items().hide();
showToolbar(panel, id);
userConstainHandler = Settings.getPositionHandler(editor);
contentAreaRect = Measure.getContentAreaRect(editor);
panelRect = global$2.DOM.getRect(panel.getEl());
result = Layout.calc(currentRect, contentAreaRect, panelRect);
if (result) {
panelRect = result.rect;
movePanelTo(panel, Layout.userConstrain(userConstainHandler, currentRect, contentAreaRect, panelRect));
togglePositionClass(panel, result.position);
}
}
};
var show = function (editor, id, targetRect, toolbars) {
if (!panel) {
Events.fireBeforeRenderUI(editor);
panel = create(editor, toolbars);
panel.renderTo().reflow().moveTo(targetRect.x, targetRect.y);
editor.nodeChanged();
}
showPanelAt(panel, id, editor, targetRect);
};
var reposition = function (editor, id, targetRect) {
if (panel) {
repositionPanelAt(panel, id, editor, targetRect);
}
};
var hide = function () {
if (panel) {
panel.hide();
}
};
var focus = function () {
if (panel) {
panel.find('toolbar:visible').eq(0).each(function (item) {
item.focus(true);
});
}
};
var remove = function () {
if (panel) {
panel.remove();
panel = null;
}
};
var inForm = function () {
return panel && panel.visible() && hasFormVisible();
};
return {
show: show,
showForm: showForm,
reposition: reposition,
inForm: inForm,
hide: hide,
focus: focus,
remove: remove
};
};
var Layout$1 = global$8.extend({
Defaults: {
firstControlClass: 'first',
lastControlClass: 'last'
},
init: function (settings) {
this.settings = global$4.extend({}, this.Defaults, settings);
},
preRender: function (container) {
container.bodyClasses.add(this.settings.containerClass);
},
applyClasses: function (items) {
var self = this;
var settings = self.settings;
var firstClass, lastClass, firstItem, lastItem;
firstClass = settings.firstControlClass;
lastClass = settings.lastControlClass;
items.each(function (item) {
item.classes.remove(firstClass).remove(lastClass).add(settings.controlClass);
if (item.visible()) {
if (!firstItem) {
firstItem = item;
}
lastItem = item;
}
});
if (firstItem) {
firstItem.classes.add(firstClass);
}
if (lastItem) {
lastItem.classes.add(lastClass);
}
},
renderHtml: function (container) {
var self = this;
var html = '';
self.applyClasses(container.items());
container.items().each(function (item) {
html += item.renderHtml();
});
return html;
},
recalc: function () {
},
postRender: function () {
},
isNative: function () {
return false;
}
});
var AbsoluteLayout = Layout$1.extend({
Defaults: {
containerClass: 'abs-layout',
controlClass: 'abs-layout-item'
},
recalc: function (container) {
container.items().filter(':visible').each(function (ctrl) {
var settings = ctrl.settings;
ctrl.layoutRect({
x: settings.x,
y: settings.y,
w: settings.w,
h: settings.h
});
if (ctrl.recalc) {
ctrl.recalc();
}
});
},
renderHtml: function (container) {
return '
' + this._super(container);
}
});
var Button = Widget.extend({
Defaults: {
classes: 'widget btn',
role: 'button'
},
init: function (settings) {
var self = this;
var size;
self._super(settings);
settings = self.settings;
size = self.settings.size;
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('touchstart', function (e) {
self.fire('click', e);
e.preventDefault();
});
if (settings.subtype) {
self.classes.add(settings.subtype);
}
if (size) {
self.classes.add('btn-' + size);
}
if (settings.icon) {
self.icon(settings.icon);
}
},
icon: function (icon) {
if (!arguments.length) {
return this.state.get('icon');
}
this.state.set('icon', icon);
return this;
},
repaint: function () {
var btnElm = this.getEl().firstChild;
var btnStyle;
if (btnElm) {
btnStyle = btnElm.style;
btnStyle.width = btnStyle.height = '100%';
}
this._super();
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
var icon = self.state.get('icon'), image;
var text = self.state.get('text');
var textHtml = '';
var ariaPressed;
var settings = self.settings;
image = settings.image;
if (image) {
icon = 'none';
if (typeof image !== 'string') {
image = domGlobals.window.getSelection ? image[0] : image[1];
}
image = ' style="background-image: url(\'' + image + '\')"';
} else {
image = '';
}
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
icon = icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : '';
return '' + '' + (icon ? ' ' : '') + textHtml + ' ' + '
';
},
bindStates: function () {
var self = this, $ = self.$, textCls = self.classPrefix + 'txt';
function setButtonText(text) {
var $span = $('span.' + textCls, self.getEl());
if (text) {
if (!$span[0]) {
$('button:first', self.getEl()).append(' ');
$span = $('span.' + textCls, self.getEl());
}
$span.html(self.encode(text));
} else {
$span.remove();
}
self.classes.toggle('btn-has-text', !!text);
}
self.state.on('change:text', function (e) {
setButtonText(e.value);
});
self.state.on('change:icon', function (e) {
var icon = e.value;
var prefix = self.classPrefix;
self.settings.icon = icon;
icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
var btnElm = self.getEl().firstChild;
var iconElm = btnElm.getElementsByTagName('i')[0];
if (icon) {
if (!iconElm || iconElm !== btnElm.firstChild) {
iconElm = domGlobals.document.createElement('i');
btnElm.insertBefore(iconElm, btnElm.firstChild);
}
iconElm.className = icon;
} else if (iconElm) {
btnElm.removeChild(iconElm);
}
setButtonText(self.state.get('text'));
});
return self._super();
}
});
var BrowseButton = Button.extend({
init: function (settings) {
var self = this;
settings = global$4.extend({
text: 'Browse...',
multiple: false,
accept: null
}, settings);
self._super(settings);
self.classes.add('browsebutton');
if (settings.multiple) {
self.classes.add('multiple');
}
},
postRender: function () {
var self = this;
var input = funcs.create('input', {
type: 'file',
id: self._id + '-browse',
accept: self.settings.accept
});
self._super();
global$7(input).on('change', function (e) {
var files = e.target.files;
self.value = function () {
if (!files.length) {
return null;
} else if (self.settings.multiple) {
return files;
} else {
return files[0];
}
};
e.preventDefault();
if (files.length) {
self.fire('change', e);
}
});
global$7(input).on('click', function (e) {
e.stopPropagation();
});
global$7(self.getEl('button')).on('click touchstart', function (e) {
e.stopPropagation();
input.click();
e.preventDefault();
});
self.getEl().appendChild(input);
},
remove: function () {
global$7(this.getEl('button')).off();
global$7(this.getEl('input')).off();
this._super();
}
});
var ButtonGroup = Container.extend({
Defaults: {
defaultType: 'button',
role: 'group'
},
renderHtml: function () {
var self = this, layout = self._layout;
self.classes.add('btn-group');
self.preRender();
layout.preRender(self);
return '' + '
' + (self.settings.html || '') + layout.renderHtml(self) + '
' + '
';
}
});
var Checkbox = Widget.extend({
Defaults: {
classes: 'checkbox',
role: 'checkbox',
checked: false
},
init: function (settings) {
var self = this;
self._super(settings);
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('click', function (e) {
e.preventDefault();
if (!self.disabled()) {
self.checked(!self.checked());
}
});
self.checked(self.settings.checked);
},
checked: function (state) {
if (!arguments.length) {
return this.state.get('checked');
}
this.state.set('checked', state);
return this;
},
value: function (state) {
if (!arguments.length) {
return this.checked();
}
return this.checked(state);
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
return '' + ' ' + '' + self.encode(self.state.get('text')) + ' ' + '
';
},
bindStates: function () {
var self = this;
function checked(state) {
self.classes.toggle('checked', state);
self.aria('checked', state);
}
self.state.on('change:text', function (e) {
self.getEl('al').firstChild.data = self.translate(e.value);
});
self.state.on('change:checked change:value', function (e) {
self.fire('change');
checked(e.value);
});
self.state.on('change:icon', function (e) {
var icon = e.value;
var prefix = self.classPrefix;
if (typeof icon === 'undefined') {
return self.settings.icon;
}
self.settings.icon = icon;
icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
var btnElm = self.getEl().firstChild;
var iconElm = btnElm.getElementsByTagName('i')[0];
if (icon) {
if (!iconElm || iconElm !== btnElm.firstChild) {
iconElm = domGlobals.document.createElement('i');
btnElm.insertBefore(iconElm, btnElm.firstChild);
}
iconElm.className = icon;
} else if (iconElm) {
btnElm.removeChild(iconElm);
}
});
if (self.state.get('checked')) {
checked(true);
}
return self._super();
}
});
var global$f = tinymce.util.Tools.resolve('tinymce.util.VK');
var ComboBox = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
settings = self.settings;
self.classes.add('combobox');
self.subinput = true;
self.ariaTarget = 'inp';
settings.menu = settings.menu || settings.values;
if (settings.menu) {
settings.icon = 'caret';
}
self.on('click', function (e) {
var elm = e.target;
var root = self.getEl();
if (!global$7.contains(root, elm) && elm !== root) {
return;
}
while (elm && elm !== root) {
if (elm.id && elm.id.indexOf('-open') !== -1) {
self.fire('action');
if (settings.menu) {
self.showMenu();
if (e.aria) {
self.menu.items()[0].focus();
}
}
}
elm = elm.parentNode;
}
});
self.on('keydown', function (e) {
var rootControl;
if (e.keyCode === 13 && e.target.nodeName === 'INPUT') {
e.preventDefault();
self.parents().reverse().each(function (ctrl) {
if (ctrl.toJSON) {
rootControl = ctrl;
return false;
}
});
self.fire('submit', { data: rootControl.toJSON() });
}
});
self.on('keyup', function (e) {
if (e.target.nodeName === 'INPUT') {
var oldValue = self.state.get('value');
var newValue = e.target.value;
if (newValue !== oldValue) {
self.state.set('value', newValue);
self.fire('autocomplete', e);
}
}
});
self.on('mouseover', function (e) {
var tooltip = self.tooltip().moveTo(-65535);
if (self.statusLevel() && e.target.className.indexOf(self.classPrefix + 'status') !== -1) {
var statusMessage = self.statusMessage() || 'Ok';
var rel = tooltip.text(statusMessage).show().testMoveRel(e.target, [
'bc-tc',
'bc-tl',
'bc-tr'
]);
tooltip.classes.toggle('tooltip-n', rel === 'bc-tc');
tooltip.classes.toggle('tooltip-nw', rel === 'bc-tl');
tooltip.classes.toggle('tooltip-ne', rel === 'bc-tr');
tooltip.moveRel(e.target, rel);
}
});
},
statusLevel: function (value) {
if (arguments.length > 0) {
this.state.set('statusLevel', value);
}
return this.state.get('statusLevel');
},
statusMessage: function (value) {
if (arguments.length > 0) {
this.state.set('statusMessage', value);
}
return this.state.get('statusMessage');
},
showMenu: function () {
var self = this;
var settings = self.settings;
var menu;
if (!self.menu) {
menu = settings.menu || [];
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
self.menu = global$b.create(menu).parent(self).renderTo(self.getContainerElm());
self.fire('createmenu');
self.menu.reflow();
self.menu.on('cancel', function (e) {
if (e.control === self.menu) {
self.focus();
}
});
self.menu.on('show hide', function (e) {
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.value() === self.value());
});
}).fire('show');
self.menu.on('select', function (e) {
self.value(e.control.value());
});
self.on('focusin', function (e) {
if (e.target.tagName.toUpperCase() === 'INPUT') {
self.menu.hide();
}
});
self.aria('expanded', true);
}
self.menu.show();
self.menu.layoutRect({ w: self.layoutRect().w });
self.menu.moveRel(self.getEl(), self.isRtl() ? [
'br-tr',
'tr-br'
] : [
'bl-tl',
'tl-bl'
]);
},
focus: function () {
this.getEl('inp').focus();
},
repaint: function () {
var self = this, elm = self.getEl(), openElm = self.getEl('open'), rect = self.layoutRect();
var width, lineHeight, innerPadding = 0;
var inputElm = elm.firstChild;
if (self.statusLevel() && self.statusLevel() !== 'none') {
innerPadding = parseInt(funcs.getRuntimeStyle(inputElm, 'padding-right'), 10) - parseInt(funcs.getRuntimeStyle(inputElm, 'padding-left'), 10);
}
if (openElm) {
width = rect.w - funcs.getSize(openElm).width - 10;
} else {
width = rect.w - 10;
}
var doc = domGlobals.document;
if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) {
lineHeight = self.layoutRect().h - 2 + 'px';
}
global$7(inputElm).css({
width: width - innerPadding,
lineHeight: lineHeight
});
self._super();
return self;
},
postRender: function () {
var self = this;
global$7(this.getEl('inp')).on('change', function (e) {
self.state.set('value', e.target.value);
self.fire('change', e);
});
return self._super();
},
renderHtml: function () {
var self = this, id = self._id, settings = self.settings, prefix = self.classPrefix;
var value = self.state.get('value') || '';
var icon, text, openBtnHtml = '', extraAttrs = '', statusHtml = '';
if ('spellcheck' in settings) {
extraAttrs += ' spellcheck="' + settings.spellcheck + '"';
}
if (settings.maxLength) {
extraAttrs += ' maxlength="' + settings.maxLength + '"';
}
if (settings.size) {
extraAttrs += ' size="' + settings.size + '"';
}
if (settings.subtype) {
extraAttrs += ' type="' + settings.subtype + '"';
}
statusHtml = ' ';
if (self.disabled()) {
extraAttrs += ' disabled="disabled"';
}
icon = settings.icon;
if (icon && icon !== 'caret') {
icon = prefix + 'ico ' + prefix + 'i-' + settings.icon;
}
text = self.state.get('text');
if (icon || text) {
openBtnHtml = '' + '' + (icon !== 'caret' ? ' ' : ' ') + (text ? (icon ? ' ' : '') + text : '') + ' ' + '
';
self.classes.add('has-open');
}
return '' + ' ' + statusHtml + openBtnHtml + '
';
},
value: function (value) {
if (arguments.length) {
this.state.set('value', value);
return this;
}
if (this.state.get('rendered')) {
this.state.set('value', this.getEl('inp').value);
}
return this.state.get('value');
},
showAutoComplete: function (items, term) {
var self = this;
if (items.length === 0) {
self.hideMenu();
return;
}
var insert = function (value, title) {
return function () {
self.fire('selectitem', {
title: title,
value: value
});
};
};
if (self.menu) {
self.menu.items().remove();
} else {
self.menu = global$b.create({
type: 'menu',
classes: 'combobox-menu',
layout: 'flow'
}).parent(self).renderTo();
}
global$4.each(items, function (item) {
self.menu.add({
text: item.title,
url: item.previewUrl,
match: term,
classes: 'menu-item-ellipsis',
onclick: insert(item.value, item.title)
});
});
self.menu.renderNew();
self.hideMenu();
self.menu.on('cancel', function (e) {
if (e.control.parent() === self.menu) {
e.stopPropagation();
self.focus();
self.hideMenu();
}
});
self.menu.on('select', function () {
self.focus();
});
var maxW = self.layoutRect().w;
self.menu.layoutRect({
w: maxW,
minW: 0,
maxW: maxW
});
self.menu.repaint();
self.menu.reflow();
self.menu.show();
self.menu.moveRel(self.getEl(), self.isRtl() ? [
'br-tr',
'tr-br'
] : [
'bl-tl',
'tl-bl'
]);
},
hideMenu: function () {
if (this.menu) {
this.menu.hide();
}
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
if (self.getEl('inp').value !== e.value) {
self.getEl('inp').value = e.value;
}
});
self.state.on('change:disabled', function (e) {
self.getEl('inp').disabled = e.value;
});
self.state.on('change:statusLevel', function (e) {
var statusIconElm = self.getEl('status');
var prefix = self.classPrefix, value = e.value;
funcs.css(statusIconElm, 'display', value === 'none' ? 'none' : '');
funcs.toggleClass(statusIconElm, prefix + 'i-checkmark', value === 'ok');
funcs.toggleClass(statusIconElm, prefix + 'i-warning', value === 'warn');
funcs.toggleClass(statusIconElm, prefix + 'i-error', value === 'error');
self.classes.toggle('has-status', value !== 'none');
self.repaint();
});
funcs.on(self.getEl('status'), 'mouseleave', function () {
self.tooltip().hide();
});
self.on('cancel', function (e) {
if (self.menu && self.menu.visible()) {
e.stopPropagation();
self.hideMenu();
}
});
var focusIdx = function (idx, menu) {
if (menu && menu.items().length > 0) {
menu.items().eq(idx)[0].focus();
}
};
self.on('keydown', function (e) {
var keyCode = e.keyCode;
if (e.target.nodeName === 'INPUT') {
if (keyCode === global$f.DOWN) {
e.preventDefault();
self.fire('autocomplete');
focusIdx(0, self.menu);
} else if (keyCode === global$f.UP) {
e.preventDefault();
focusIdx(-1, self.menu);
}
}
});
return self._super();
},
remove: function () {
global$7(this.getEl('inp')).off();
if (this.menu) {
this.menu.remove();
}
this._super();
}
});
var ColorBox = ComboBox.extend({
init: function (settings) {
var self = this;
settings.spellcheck = false;
if (settings.onaction) {
settings.icon = 'none';
}
self._super(settings);
self.classes.add('colorbox');
self.on('change keyup postrender', function () {
self.repaintColor(self.value());
});
},
repaintColor: function (value) {
var openElm = this.getEl('open');
var elm = openElm ? openElm.getElementsByTagName('i')[0] : null;
if (elm) {
try {
elm.style.background = value;
} catch (ex) {
}
}
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
if (self.state.get('rendered')) {
self.repaintColor(e.value);
}
});
return self._super();
}
});
var PanelButton = Button.extend({
showPanel: function () {
var self = this, settings = self.settings;
self.classes.add('opened');
if (!self.panel) {
var panelSettings = settings.panel;
if (panelSettings.type) {
panelSettings = {
layout: 'grid',
items: panelSettings
};
}
panelSettings.role = panelSettings.role || 'dialog';
panelSettings.popover = true;
panelSettings.autohide = true;
panelSettings.ariaRoot = true;
self.panel = new FloatPanel(panelSettings).on('hide', function () {
self.classes.remove('opened');
}).on('cancel', function (e) {
e.stopPropagation();
self.focus();
self.hidePanel();
}).parent(self).renderTo(self.getContainerElm());
self.panel.fire('show');
self.panel.reflow();
} else {
self.panel.show();
}
var rtlRels = [
'bc-tc',
'bc-tl',
'bc-tr'
];
var ltrRels = [
'bc-tc',
'bc-tr',
'bc-tl',
'tc-bc',
'tc-br',
'tc-bl'
];
var rel = self.panel.testMoveRel(self.getEl(), settings.popoverAlign || (self.isRtl() ? rtlRels : ltrRels));
self.panel.classes.toggle('start', rel.substr(-1) === 'l');
self.panel.classes.toggle('end', rel.substr(-1) === 'r');
var isTop = rel.substr(0, 1) === 't';
self.panel.classes.toggle('bottom', !isTop);
self.panel.classes.toggle('top', isTop);
self.panel.moveRel(self.getEl(), rel);
},
hidePanel: function () {
var self = this;
if (self.panel) {
self.panel.hide();
}
},
postRender: function () {
var self = this;
self.aria('haspopup', true);
self.on('click', function (e) {
if (e.control === self) {
if (self.panel && self.panel.visible()) {
self.hidePanel();
} else {
self.showPanel();
self.panel.focus(!!e.aria);
}
}
});
return self._super();
},
remove: function () {
if (this.panel) {
this.panel.remove();
this.panel = null;
}
return this._super();
}
});
var DOM = global$2.DOM;
var ColorButton = PanelButton.extend({
init: function (settings) {
this._super(settings);
this.classes.add('splitbtn');
this.classes.add('colorbutton');
},
color: function (color) {
if (color) {
this._color = color;
this.getEl('preview').style.backgroundColor = color;
return this;
}
return this._color;
},
resetColor: function () {
this._color = null;
this.getEl('preview').style.backgroundColor = null;
return this;
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix, text = self.state.get('text');
var icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
var image = self.settings.image ? ' style="background-image: url(\'' + self.settings.image + '\')"' : '';
var textHtml = '';
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
return '' + '' + (icon ? ' ' : '') + ' ' + textHtml + ' ' + '' + ' ' + ' ' + '
';
},
postRender: function () {
var self = this, onClickHandler = self.settings.onclick;
self.on('click', function (e) {
if (e.aria && e.aria.key === 'down') {
return;
}
if (e.control === self && !DOM.getParent(e.target, '.' + self.classPrefix + 'open')) {
e.stopImmediatePropagation();
onClickHandler.call(self, e);
}
});
delete self.settings.onclick;
return self._super();
}
});
var global$g = tinymce.util.Tools.resolve('tinymce.util.Color');
var ColorPicker = Widget.extend({
Defaults: { classes: 'widget colorpicker' },
init: function (settings) {
this._super(settings);
},
postRender: function () {
var self = this;
var color = self.color();
var hsv, hueRootElm, huePointElm, svRootElm, svPointElm;
hueRootElm = self.getEl('h');
huePointElm = self.getEl('hp');
svRootElm = self.getEl('sv');
svPointElm = self.getEl('svp');
function getPos(elm, event) {
var pos = funcs.getPos(elm);
var x, y;
x = event.pageX - pos.x;
y = event.pageY - pos.y;
x = Math.max(0, Math.min(x / elm.clientWidth, 1));
y = Math.max(0, Math.min(y / elm.clientHeight, 1));
return {
x: x,
y: y
};
}
function updateColor(hsv, hueUpdate) {
var hue = (360 - hsv.h) / 360;
funcs.css(huePointElm, { top: hue * 100 + '%' });
if (!hueUpdate) {
funcs.css(svPointElm, {
left: hsv.s + '%',
top: 100 - hsv.v + '%'
});
}
svRootElm.style.background = global$g({
s: 100,
v: 100,
h: hsv.h
}).toHex();
self.color().parse({
s: hsv.s,
v: hsv.v,
h: hsv.h
});
}
function updateSaturationAndValue(e) {
var pos;
pos = getPos(svRootElm, e);
hsv.s = pos.x * 100;
hsv.v = (1 - pos.y) * 100;
updateColor(hsv);
self.fire('change');
}
function updateHue(e) {
var pos;
pos = getPos(hueRootElm, e);
hsv = color.toHsv();
hsv.h = (1 - pos.y) * 360;
updateColor(hsv, true);
self.fire('change');
}
self._repaint = function () {
hsv = color.toHsv();
updateColor(hsv);
};
self._super();
self._svdraghelper = new DragHelper(self._id + '-sv', {
start: updateSaturationAndValue,
drag: updateSaturationAndValue
});
self._hdraghelper = new DragHelper(self._id + '-h', {
start: updateHue,
drag: updateHue
});
self._repaint();
},
rgb: function () {
return this.color().toRgb();
},
value: function (value) {
var self = this;
if (arguments.length) {
self.color().parse(value);
if (self._rendered) {
self._repaint();
}
} else {
return self.color().toHex();
}
},
color: function () {
if (!this._color) {
this._color = global$g();
}
return this._color;
},
renderHtml: function () {
var self = this;
var id = self._id;
var prefix = self.classPrefix;
var hueHtml;
var stops = '#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000';
function getOldIeFallbackHtml() {
var i, l, html = '', gradientPrefix, stopsList;
gradientPrefix = 'filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=';
stopsList = stops.split(',');
for (i = 0, l = stopsList.length - 1; i < l; i++) {
html += '
';
}
return html;
}
var gradientCssText = 'background: -ms-linear-gradient(top,' + stops + ');' + 'background: linear-gradient(to bottom,' + stops + ');';
hueHtml = '' + getOldIeFallbackHtml() + '
' + '
';
return '';
}
});
var DropZone = Widget.extend({
init: function (settings) {
var self = this;
settings = global$4.extend({
height: 100,
text: 'Drop an image here',
multiple: false,
accept: null
}, settings);
self._super(settings);
self.classes.add('dropzone');
if (settings.multiple) {
self.classes.add('multiple');
}
},
renderHtml: function () {
var self = this;
var attrs, elm;
var cfg = self.settings;
attrs = {
id: self._id,
hidefocus: '1'
};
elm = funcs.create('div', attrs, '' + this.translate(cfg.text) + ' ');
if (cfg.height) {
funcs.css(elm, 'height', cfg.height + 'px');
}
if (cfg.width) {
funcs.css(elm, 'width', cfg.width + 'px');
}
elm.className = self.classes;
return elm.outerHTML;
},
postRender: function () {
var self = this;
var toggleDragClass = function (e) {
e.preventDefault();
self.classes.toggle('dragenter');
self.getEl().className = self.classes;
};
var filter = function (files) {
var accept = self.settings.accept;
if (typeof accept !== 'string') {
return files;
}
var re = new RegExp('(' + accept.split(/\s*,\s*/).join('|') + ')$', 'i');
return global$4.grep(files, function (file) {
return re.test(file.name);
});
};
self._super();
self.$el.on('dragover', function (e) {
e.preventDefault();
});
self.$el.on('dragenter', toggleDragClass);
self.$el.on('dragleave', toggleDragClass);
self.$el.on('drop', function (e) {
e.preventDefault();
if (self.state.get('disabled')) {
return;
}
var files = filter(e.dataTransfer.files);
self.value = function () {
if (!files.length) {
return null;
} else if (self.settings.multiple) {
return files;
} else {
return files[0];
}
};
if (files.length) {
self.fire('change', e);
}
});
},
remove: function () {
this.$el.off();
this._super();
}
});
var Path = Widget.extend({
init: function (settings) {
var self = this;
if (!settings.delimiter) {
settings.delimiter = '\xBB';
}
self._super(settings);
self.classes.add('path');
self.canFocus = true;
self.on('click', function (e) {
var index;
var target = e.target;
if (index = target.getAttribute('data-index')) {
self.fire('select', {
value: self.row()[index],
index: index
});
}
});
self.row(self.settings.row);
},
focus: function () {
var self = this;
self.getEl().firstChild.focus();
return self;
},
row: function (row) {
if (!arguments.length) {
return this.state.get('row');
}
this.state.set('row', row);
return this;
},
renderHtml: function () {
var self = this;
return '' + self._getDataPathHtml(self.state.get('row')) + '
';
},
bindStates: function () {
var self = this;
self.state.on('change:row', function (e) {
self.innerHtml(self._getDataPathHtml(e.value));
});
return self._super();
},
_getDataPathHtml: function (data) {
var self = this;
var parts = data || [];
var i, l, html = '';
var prefix = self.classPrefix;
for (i = 0, l = parts.length; i < l; i++) {
html += (i > 0 ? ' ' + self.settings.delimiter + '
' : '') + '' + parts[i].name + '
';
}
if (!html) {
html = '\xA0
';
}
return html;
}
});
var ElementPath = Path.extend({
postRender: function () {
var self = this, editor = self.settings.editor;
function isHidden(elm) {
if (elm.nodeType === 1) {
if (elm.nodeName === 'BR' || !!elm.getAttribute('data-mce-bogus')) {
return true;
}
if (elm.getAttribute('data-mce-type') === 'bookmark') {
return true;
}
}
return false;
}
if (editor.settings.elementpath !== false) {
self.on('select', function (e) {
editor.focus();
editor.selection.select(this.row()[e.index].element);
editor.nodeChanged();
});
editor.on('nodeChange', function (e) {
var outParents = [];
var parents = e.parents;
var i = parents.length;
while (i--) {
if (parents[i].nodeType === 1 && !isHidden(parents[i])) {
var args = editor.fire('ResolveName', {
name: parents[i].nodeName.toLowerCase(),
target: parents[i]
});
if (!args.isDefaultPrevented()) {
outParents.push({
name: args.name,
element: parents[i]
});
}
if (args.isPropagationStopped()) {
break;
}
}
}
self.row(outParents);
});
}
return self._super();
}
});
var FormItem = Container.extend({
Defaults: {
layout: 'flex',
align: 'center',
defaults: { flex: 1 }
},
renderHtml: function () {
var self = this, layout = self._layout, prefix = self.classPrefix;
self.classes.add('formitem');
layout.preRender(self);
return '' + (self.settings.title ? '
' + self.settings.title + '
' : '') + '
' + (self.settings.html || '') + layout.renderHtml(self) + '
' + '
';
}
});
var Form = Container.extend({
Defaults: {
containerCls: 'form',
layout: 'flex',
direction: 'column',
align: 'stretch',
flex: 1,
padding: 15,
labelGap: 30,
spacing: 10,
callbacks: {
submit: function () {
this.submit();
}
}
},
preRender: function () {
var self = this, items = self.items();
if (!self.settings.formItemDefaults) {
self.settings.formItemDefaults = {
layout: 'flex',
autoResize: 'overflow',
defaults: { flex: 1 }
};
}
items.each(function (ctrl) {
var formItem;
var label = ctrl.settings.label;
if (label) {
formItem = new FormItem(global$4.extend({
items: {
type: 'label',
id: ctrl._id + '-l',
text: label,
flex: 0,
forId: ctrl._id,
disabled: ctrl.disabled()
}
}, self.settings.formItemDefaults));
formItem.type = 'formitem';
ctrl.aria('labelledby', ctrl._id + '-l');
if (typeof ctrl.settings.flex === 'undefined') {
ctrl.settings.flex = 1;
}
self.replace(ctrl, formItem);
formItem.add(ctrl);
}
});
},
submit: function () {
return this.fire('submit', { data: this.toJSON() });
},
postRender: function () {
var self = this;
self._super();
self.fromJSON(self.settings.data);
},
bindStates: function () {
var self = this;
self._super();
function recalcLabels() {
var maxLabelWidth = 0;
var labels = [];
var i, labelGap, items;
if (self.settings.labelGapCalc === false) {
return;
}
if (self.settings.labelGapCalc === 'children') {
items = self.find('formitem');
} else {
items = self.items();
}
items.filter('formitem').each(function (item) {
var labelCtrl = item.items()[0], labelWidth = labelCtrl.getEl().clientWidth;
maxLabelWidth = labelWidth > maxLabelWidth ? labelWidth : maxLabelWidth;
labels.push(labelCtrl);
});
labelGap = self.settings.labelGap || 0;
i = labels.length;
while (i--) {
labels[i].settings.minWidth = maxLabelWidth + labelGap;
}
}
self.on('show', recalcLabels);
recalcLabels();
}
});
var FieldSet = Form.extend({
Defaults: {
containerCls: 'fieldset',
layout: 'flex',
direction: 'column',
align: 'stretch',
flex: 1,
padding: '25 15 5 15',
labelGap: 30,
spacing: 10,
border: 1
},
renderHtml: function () {
var self = this, layout = self._layout, prefix = self.classPrefix;
self.preRender();
layout.preRender(self);
return '' + (self.settings.title ? '' + self.settings.title + ' ' : '') + '' + (self.settings.html || '') + layout.renderHtml(self) + '
' + ' ';
}
});
var unique$1 = 0;
var generate = function (prefix) {
var date = new Date();
var time = date.getTime();
var random = Math.floor(Math.random() * 1000000000);
unique$1++;
return prefix + '_' + random + unique$1 + String(time);
};
var fromHtml = function (html, scope) {
var doc = scope || domGlobals.document;
var div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
domGlobals.console.error('HTML does not have a single root node', html);
throw new Error('HTML must have a single root node');
}
return fromDom(div.childNodes[0]);
};
var fromTag = function (tag, scope) {
var doc = scope || domGlobals.document;
var node = doc.createElement(tag);
return fromDom(node);
};
var fromText = function (text, scope) {
var doc = scope || domGlobals.document;
var node = doc.createTextNode(text);
return fromDom(node);
};
var fromDom = function (node) {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: constant(node) };
};
var fromPoint = function (docElm, x, y) {
var doc = docElm.dom();
return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
};
var Element = {
fromHtml: fromHtml,
fromTag: fromTag,
fromText: fromText,
fromDom: fromDom,
fromPoint: fromPoint
};
var cached = function (f) {
var called = false;
var r;
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!called) {
called = true;
r = f.apply(null, args);
}
return r;
};
};
var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE;
var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE;
var COMMENT = domGlobals.Node.COMMENT_NODE;
var DOCUMENT = domGlobals.Node.DOCUMENT_NODE;
var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE;
var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE;
var ELEMENT = domGlobals.Node.ELEMENT_NODE;
var TEXT = domGlobals.Node.TEXT_NODE;
var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE;
var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE;
var ENTITY = domGlobals.Node.ENTITY_NODE;
var NOTATION = domGlobals.Node.NOTATION_NODE;
var Immutable = function () {
var fields = [];
for (var _i = 0; _i < arguments.length; _i++) {
fields[_i] = arguments[_i];
}
return function () {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
if (fields.length !== values.length) {
throw new Error('Wrong number of arguments to struct. Expected "[' + fields.length + ']", got ' + values.length + ' arguments');
}
var struct = {};
each(fields, function (name, i) {
struct[name] = constant(values[i]);
});
return struct;
};
};
var node = function () {
var f = Global$1.getOrDie('Node');
return f;
};
var compareDocumentPosition = function (a, b, match) {
return (a.compareDocumentPosition(b) & match) !== 0;
};
var documentPositionPreceding = function (a, b) {
return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_PRECEDING);
};
var documentPositionContainedBy = function (a, b) {
return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY);
};
var Node = {
documentPositionPreceding: documentPositionPreceding,
documentPositionContainedBy: documentPositionContainedBy
};
var firstMatch = function (regexes, s) {
for (var i = 0; i < regexes.length; i++) {
var x = regexes[i];
if (x.test(s)) {
return x;
}
}
return undefined;
};
var find$1 = function (regexes, agent) {
var r = firstMatch(regexes, agent);
if (!r) {
return {
major: 0,
minor: 0
};
}
var group = function (i) {
return Number(agent.replace(r, '$' + i));
};
return nu(group(1), group(2));
};
var detect = function (versionRegexes, agent) {
var cleanedAgent = String(agent).toLowerCase();
if (versionRegexes.length === 0) {
return unknown();
}
return find$1(versionRegexes, cleanedAgent);
};
var unknown = function () {
return nu(0, 0);
};
var nu = function (major, minor) {
return {
major: major,
minor: minor
};
};
var Version = {
nu: nu,
detect: detect,
unknown: unknown
};
var edge = 'Edge';
var chrome = 'Chrome';
var ie = 'IE';
var opera = 'Opera';
var firefox = 'Firefox';
var safari = 'Safari';
var isBrowser = function (name, current) {
return function () {
return current === name;
};
};
var unknown$1 = function () {
return nu$1({
current: undefined,
version: Version.unknown()
});
};
var nu$1 = function (info) {
var current = info.current;
var version = info.version;
return {
current: current,
version: version,
isEdge: isBrowser(edge, current),
isChrome: isBrowser(chrome, current),
isIE: isBrowser(ie, current),
isOpera: isBrowser(opera, current),
isFirefox: isBrowser(firefox, current),
isSafari: isBrowser(safari, current)
};
};
var Browser = {
unknown: unknown$1,
nu: nu$1,
edge: constant(edge),
chrome: constant(chrome),
ie: constant(ie),
opera: constant(opera),
firefox: constant(firefox),
safari: constant(safari)
};
var windows$1 = 'Windows';
var ios = 'iOS';
var android = 'Android';
var linux = 'Linux';
var osx = 'OSX';
var solaris = 'Solaris';
var freebsd = 'FreeBSD';
var isOS = function (name, current) {
return function () {
return current === name;
};
};
var unknown$2 = function () {
return nu$2({
current: undefined,
version: Version.unknown()
});
};
var nu$2 = function (info) {
var current = info.current;
var version = info.version;
return {
current: current,
version: version,
isWindows: isOS(windows$1, current),
isiOS: isOS(ios, current),
isAndroid: isOS(android, current),
isOSX: isOS(osx, current),
isLinux: isOS(linux, current),
isSolaris: isOS(solaris, current),
isFreeBSD: isOS(freebsd, current)
};
};
var OperatingSystem = {
unknown: unknown$2,
nu: nu$2,
windows: constant(windows$1),
ios: constant(ios),
android: constant(android),
linux: constant(linux),
osx: constant(osx),
solaris: constant(solaris),
freebsd: constant(freebsd)
};
var DeviceType = function (os, browser, userAgent) {
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
var isiPhone = os.isiOS() && !isiPad;
var isAndroid3 = os.isAndroid() && os.version.major === 3;
var isAndroid4 = os.isAndroid() && os.version.major === 4;
var isTablet = isiPad || isAndroid3 || isAndroid4 && /mobile/i.test(userAgent) === true;
var isTouch = os.isiOS() || os.isAndroid();
var isPhone = isTouch && !isTablet;
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
return {
isiPad: constant(isiPad),
isiPhone: constant(isiPhone),
isTablet: constant(isTablet),
isPhone: constant(isPhone),
isTouch: constant(isTouch),
isAndroid: os.isAndroid,
isiOS: os.isiOS,
isWebView: constant(iOSwebview)
};
};
var detect$1 = function (candidates, userAgent) {
var agent = String(userAgent).toLowerCase();
return find(candidates, function (candidate) {
return candidate.search(agent);
});
};
var detectBrowser = function (browsers, userAgent) {
return detect$1(browsers, userAgent).map(function (browser) {
var version = Version.detect(browser.versionRegexes, userAgent);
return {
current: browser.name,
version: version
};
});
};
var detectOs = function (oses, userAgent) {
return detect$1(oses, userAgent).map(function (os) {
var version = Version.detect(os.versionRegexes, userAgent);
return {
current: os.name,
version: version
};
});
};
var UaString = {
detectBrowser: detectBrowser,
detectOs: detectOs
};
var contains = function (str, substr) {
return str.indexOf(substr) !== -1;
};
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
var checkContains = function (target) {
return function (uastring) {
return contains(uastring, target);
};
};
var browsers = [
{
name: 'Edge',
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
search: function (uastring) {
return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
}
},
{
name: 'Chrome',
versionRegexes: [
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
normalVersionRegex
],
search: function (uastring) {
return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
}
},
{
name: 'IE',
versionRegexes: [
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
/.*?rv:([0-9]+)\.([0-9]+).*/
],
search: function (uastring) {
return contains(uastring, 'msie') || contains(uastring, 'trident');
}
},
{
name: 'Opera',
versionRegexes: [
normalVersionRegex,
/.*?opera\/([0-9]+)\.([0-9]+).*/
],
search: checkContains('opera')
},
{
name: 'Firefox',
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
search: checkContains('firefox')
},
{
name: 'Safari',
versionRegexes: [
normalVersionRegex,
/.*?cpu os ([0-9]+)_([0-9]+).*/
],
search: function (uastring) {
return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
}
}
];
var oses = [
{
name: 'Windows',
search: checkContains('win'),
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'iOS',
search: function (uastring) {
return contains(uastring, 'iphone') || contains(uastring, 'ipad');
},
versionRegexes: [
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
/.*cpu os ([0-9]+)_([0-9]+).*/,
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
]
},
{
name: 'Android',
search: checkContains('android'),
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'OSX',
search: checkContains('os x'),
versionRegexes: [/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]
},
{
name: 'Linux',
search: checkContains('linux'),
versionRegexes: []
},
{
name: 'Solaris',
search: checkContains('sunos'),
versionRegexes: []
},
{
name: 'FreeBSD',
search: checkContains('freebsd'),
versionRegexes: []
}
];
var PlatformInfo = {
browsers: constant(browsers),
oses: constant(oses)
};
var detect$2 = function (userAgent) {
var browsers = PlatformInfo.browsers();
var oses = PlatformInfo.oses();
var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu);
var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
var deviceType = DeviceType(os, browser, userAgent);
return {
browser: browser,
os: os,
deviceType: deviceType
};
};
var PlatformDetection = { detect: detect$2 };
var detect$3 = cached(function () {
var userAgent = domGlobals.navigator.userAgent;
return PlatformDetection.detect(userAgent);
});
var PlatformDetection$1 = { detect: detect$3 };
var ELEMENT$1 = ELEMENT;
var DOCUMENT$1 = DOCUMENT;
var bypassSelector = function (dom) {
return dom.nodeType !== ELEMENT$1 && dom.nodeType !== DOCUMENT$1 || dom.childElementCount === 0;
};
var all = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element.fromDom);
};
var one = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element.fromDom);
};
var regularContains = function (e1, e2) {
var d1 = e1.dom();
var d2 = e2.dom();
return d1 === d2 ? false : d1.contains(d2);
};
var ieContains = function (e1, e2) {
return Node.documentPositionContainedBy(e1.dom(), e2.dom());
};
var browser = PlatformDetection$1.detect().browser;
var contains$1 = browser.isIE() ? ieContains : regularContains;
var spot = Immutable('element', 'offset');
var descendants = function (scope, selector) {
return all(selector, scope);
};
var trim = global$4.trim;
var hasContentEditableState = function (value) {
return function (node) {
if (node && node.nodeType === 1) {
if (node.contentEditable === value) {
return true;
}
if (node.getAttribute('data-mce-contenteditable') === value) {
return true;
}
}
return false;
};
};
var isContentEditableTrue = hasContentEditableState('true');
var isContentEditableFalse = hasContentEditableState('false');
var create$4 = function (type, title, url, level, attach) {
return {
type: type,
title: title,
url: url,
level: level,
attach: attach
};
};
var isChildOfContentEditableTrue = function (node) {
while (node = node.parentNode) {
var value = node.contentEditable;
if (value && value !== 'inherit') {
return isContentEditableTrue(node);
}
}
return false;
};
var select = function (selector, root) {
return map(descendants(Element.fromDom(root), selector), function (element) {
return element.dom();
});
};
var getElementText = function (elm) {
return elm.innerText || elm.textContent;
};
var getOrGenerateId = function (elm) {
return elm.id ? elm.id : generate('h');
};
var isAnchor = function (elm) {
return elm && elm.nodeName === 'A' && (elm.id || elm.name);
};
var isValidAnchor = function (elm) {
return isAnchor(elm) && isEditable(elm);
};
var isHeader = function (elm) {
return elm && /^(H[1-6])$/.test(elm.nodeName);
};
var isEditable = function (elm) {
return isChildOfContentEditableTrue(elm) && !isContentEditableFalse(elm);
};
var isValidHeader = function (elm) {
return isHeader(elm) && isEditable(elm);
};
var getLevel = function (elm) {
return isHeader(elm) ? parseInt(elm.nodeName.substr(1), 10) : 0;
};
var headerTarget = function (elm) {
var headerId = getOrGenerateId(elm);
var attach = function () {
elm.id = headerId;
};
return create$4('header', getElementText(elm), '#' + headerId, getLevel(elm), attach);
};
var anchorTarget = function (elm) {
var anchorId = elm.id || elm.name;
var anchorText = getElementText(elm);
return create$4('anchor', anchorText ? anchorText : '#' + anchorId, '#' + anchorId, 0, noop);
};
var getHeaderTargets = function (elms) {
return map(filter(elms, isValidHeader), headerTarget);
};
var getAnchorTargets = function (elms) {
return map(filter(elms, isValidAnchor), anchorTarget);
};
var getTargetElements = function (elm) {
var elms = select('h1,h2,h3,h4,h5,h6,a:not([href])', elm);
return elms;
};
var hasTitle = function (target) {
return trim(target.title).length > 0;
};
var find$2 = function (elm) {
var elms = getTargetElements(elm);
return filter(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle);
};
var LinkTargets = { find: find$2 };
var getActiveEditor = function () {
return window.tinymce ? window.tinymce.activeEditor : global$5.activeEditor;
};
var history = {};
var HISTORY_LENGTH = 5;
var clearHistory = function () {
history = {};
};
var toMenuItem = function (target) {
return {
title: target.title,
value: {
title: { raw: target.title },
url: target.url,
attach: target.attach
}
};
};
var toMenuItems = function (targets) {
return global$4.map(targets, toMenuItem);
};
var staticMenuItem = function (title, url) {
return {
title: title,
value: {
title: title,
url: url,
attach: noop
}
};
};
var isUniqueUrl = function (url, targets) {
var foundTarget = exists(targets, function (target) {
return target.url === url;
});
return !foundTarget;
};
var getSetting = function (editorSettings, name, defaultValue) {
var value = name in editorSettings ? editorSettings[name] : defaultValue;
return value === false ? null : value;
};
var createMenuItems = function (term, targets, fileType, editorSettings) {
var separator = { title: '-' };
var fromHistoryMenuItems = function (history) {
var historyItems = history.hasOwnProperty(fileType) ? history[fileType] : [];
var uniqueHistory = filter(historyItems, function (url) {
return isUniqueUrl(url, targets);
});
return global$4.map(uniqueHistory, function (url) {
return {
title: url,
value: {
title: url,
url: url,
attach: noop
}
};
});
};
var fromMenuItems = function (type) {
var filteredTargets = filter(targets, function (target) {
return target.type === type;
});
return toMenuItems(filteredTargets);
};
var anchorMenuItems = function () {
var anchorMenuItems = fromMenuItems('anchor');
var topAnchor = getSetting(editorSettings, 'anchor_top', '#top');
var bottomAchor = getSetting(editorSettings, 'anchor_bottom', '#bottom');
if (topAnchor !== null) {
anchorMenuItems.unshift(staticMenuItem('', topAnchor));
}
if (bottomAchor !== null) {
anchorMenuItems.push(staticMenuItem('', bottomAchor));
}
return anchorMenuItems;
};
var join = function (items) {
return foldl(items, function (a, b) {
var bothEmpty = a.length === 0 || b.length === 0;
return bothEmpty ? a.concat(b) : a.concat(separator, b);
}, []);
};
if (editorSettings.typeahead_urls === false) {
return [];
}
return fileType === 'file' ? join([
filterByQuery(term, fromHistoryMenuItems(history)),
filterByQuery(term, fromMenuItems('header')),
filterByQuery(term, anchorMenuItems())
]) : filterByQuery(term, fromHistoryMenuItems(history));
};
var addToHistory = function (url, fileType) {
var items = history[fileType];
if (!/^https?/.test(url)) {
return;
}
if (items) {
if (indexOf(items, url).isNone()) {
history[fileType] = items.slice(0, HISTORY_LENGTH).concat(url);
}
} else {
history[fileType] = [url];
}
};
var filterByQuery = function (term, menuItems) {
var lowerCaseTerm = term.toLowerCase();
var result = global$4.grep(menuItems, function (item) {
return item.title.toLowerCase().indexOf(lowerCaseTerm) !== -1;
});
return result.length === 1 && result[0].title === term ? [] : result;
};
var getTitle = function (linkDetails) {
var title = linkDetails.title;
return title.raw ? title.raw : title;
};
var setupAutoCompleteHandler = function (ctrl, editorSettings, bodyElm, fileType) {
var autocomplete = function (term) {
var linkTargets = LinkTargets.find(bodyElm);
var menuItems = createMenuItems(term, linkTargets, fileType, editorSettings);
ctrl.showAutoComplete(menuItems, term);
};
ctrl.on('autocomplete', function () {
autocomplete(ctrl.value());
});
ctrl.on('selectitem', function (e) {
var linkDetails = e.value;
ctrl.value(linkDetails.url);
var title = getTitle(linkDetails);
if (fileType === 'image') {
ctrl.fire('change', {
meta: {
alt: title,
attach: linkDetails.attach
}
});
} else {
ctrl.fire('change', {
meta: {
text: title,
attach: linkDetails.attach
}
});
}
ctrl.focus();
});
ctrl.on('click', function (e) {
if (ctrl.value().length === 0 && e.target.nodeName === 'INPUT') {
autocomplete('');
}
});
ctrl.on('PostRender', function () {
ctrl.getRoot().on('submit', function (e) {
if (!e.isDefaultPrevented()) {
addToHistory(ctrl.value(), fileType);
}
});
});
};
var statusToUiState = function (result) {
var status = result.status, message = result.message;
if (status === 'valid') {
return {
status: 'ok',
message: message
};
} else if (status === 'unknown') {
return {
status: 'warn',
message: message
};
} else if (status === 'invalid') {
return {
status: 'warn',
message: message
};
} else {
return {
status: 'none',
message: ''
};
}
};
var setupLinkValidatorHandler = function (ctrl, editorSettings, fileType) {
var validatorHandler = editorSettings.filepicker_validator_handler;
if (validatorHandler) {
var validateUrl_1 = function (url) {
if (url.length === 0) {
ctrl.statusLevel('none');
return;
}
validatorHandler({
url: url,
type: fileType
}, function (result) {
var uiState = statusToUiState(result);
ctrl.statusMessage(uiState.message);
ctrl.statusLevel(uiState.status);
});
};
ctrl.state.on('change:value', function (e) {
validateUrl_1(e.value);
});
}
};
var FilePicker = ComboBox.extend({
Statics: { clearHistory: clearHistory },
init: function (settings) {
var self = this, editor = getActiveEditor(), editorSettings = editor.settings;
var actionCallback, fileBrowserCallback, fileBrowserCallbackTypes;
var fileType = settings.filetype;
settings.spellcheck = false;
fileBrowserCallbackTypes = editorSettings.file_picker_types || editorSettings.file_browser_callback_types;
if (fileBrowserCallbackTypes) {
fileBrowserCallbackTypes = global$4.makeMap(fileBrowserCallbackTypes, /[, ]/);
}
if (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[fileType]) {
fileBrowserCallback = editorSettings.file_picker_callback;
if (fileBrowserCallback && (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[fileType])) {
actionCallback = function () {
var meta = self.fire('beforecall').meta;
meta = global$4.extend({ filetype: fileType }, meta);
fileBrowserCallback.call(editor, function (value, meta) {
self.value(value).fire('change', { meta: meta });
}, self.value(), meta);
};
} else {
fileBrowserCallback = editorSettings.file_browser_callback;
if (fileBrowserCallback && (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[fileType])) {
actionCallback = function () {
fileBrowserCallback(self.getEl('inp').id, self.value(), fileType, window);
};
}
}
}
if (actionCallback) {
settings.icon = 'browse';
settings.onaction = actionCallback;
}
self._super(settings);
self.classes.add('filepicker');
setupAutoCompleteHandler(self, editorSettings, editor.getBody(), fileType);
setupLinkValidatorHandler(self, editorSettings, fileType);
}
});
var FitLayout = AbsoluteLayout.extend({
recalc: function (container) {
var contLayoutRect = container.layoutRect(), paddingBox = container.paddingBox;
container.items().filter(':visible').each(function (ctrl) {
ctrl.layoutRect({
x: paddingBox.left,
y: paddingBox.top,
w: contLayoutRect.innerW - paddingBox.right - paddingBox.left,
h: contLayoutRect.innerH - paddingBox.top - paddingBox.bottom
});
if (ctrl.recalc) {
ctrl.recalc();
}
});
}
});
var FlexLayout = AbsoluteLayout.extend({
recalc: function (container) {
var i, l, items, contLayoutRect, contPaddingBox, contSettings, align, pack, spacing, totalFlex, availableSpace, direction;
var ctrl, ctrlLayoutRect, ctrlSettings, flex;
var maxSizeItems = [];
var size, maxSize, ratio, rect, pos, maxAlignEndPos;
var sizeName, minSizeName, posName, maxSizeName, beforeName, innerSizeName, deltaSizeName, contentSizeName;
var alignAxisName, alignInnerSizeName, alignSizeName, alignMinSizeName, alignBeforeName, alignAfterName;
var alignDeltaSizeName, alignContentSizeName;
var max = Math.max, min = Math.min;
items = container.items().filter(':visible');
contLayoutRect = container.layoutRect();
contPaddingBox = container.paddingBox;
contSettings = container.settings;
direction = container.isRtl() ? contSettings.direction || 'row-reversed' : contSettings.direction;
align = contSettings.align;
pack = container.isRtl() ? contSettings.pack || 'end' : contSettings.pack;
spacing = contSettings.spacing || 0;
if (direction === 'row-reversed' || direction === 'column-reverse') {
items = items.set(items.toArray().reverse());
direction = direction.split('-')[0];
}
if (direction === 'column') {
posName = 'y';
sizeName = 'h';
minSizeName = 'minH';
maxSizeName = 'maxH';
innerSizeName = 'innerH';
beforeName = 'top';
deltaSizeName = 'deltaH';
contentSizeName = 'contentH';
alignBeforeName = 'left';
alignSizeName = 'w';
alignAxisName = 'x';
alignInnerSizeName = 'innerW';
alignMinSizeName = 'minW';
alignAfterName = 'right';
alignDeltaSizeName = 'deltaW';
alignContentSizeName = 'contentW';
} else {
posName = 'x';
sizeName = 'w';
minSizeName = 'minW';
maxSizeName = 'maxW';
innerSizeName = 'innerW';
beforeName = 'left';
deltaSizeName = 'deltaW';
contentSizeName = 'contentW';
alignBeforeName = 'top';
alignSizeName = 'h';
alignAxisName = 'y';
alignInnerSizeName = 'innerH';
alignMinSizeName = 'minH';
alignAfterName = 'bottom';
alignDeltaSizeName = 'deltaH';
alignContentSizeName = 'contentH';
}
availableSpace = contLayoutRect[innerSizeName] - contPaddingBox[beforeName] - contPaddingBox[beforeName];
maxAlignEndPos = totalFlex = 0;
for (i = 0, l = items.length; i < l; i++) {
ctrl = items[i];
ctrlLayoutRect = ctrl.layoutRect();
ctrlSettings = ctrl.settings;
flex = ctrlSettings.flex;
availableSpace -= i < l - 1 ? spacing : 0;
if (flex > 0) {
totalFlex += flex;
if (ctrlLayoutRect[maxSizeName]) {
maxSizeItems.push(ctrl);
}
ctrlLayoutRect.flex = flex;
}
availableSpace -= ctrlLayoutRect[minSizeName];
size = contPaddingBox[alignBeforeName] + ctrlLayoutRect[alignMinSizeName] + contPaddingBox[alignAfterName];
if (size > maxAlignEndPos) {
maxAlignEndPos = size;
}
}
rect = {};
if (availableSpace < 0) {
rect[minSizeName] = contLayoutRect[minSizeName] - availableSpace + contLayoutRect[deltaSizeName];
} else {
rect[minSizeName] = contLayoutRect[innerSizeName] - availableSpace + contLayoutRect[deltaSizeName];
}
rect[alignMinSizeName] = maxAlignEndPos + contLayoutRect[alignDeltaSizeName];
rect[contentSizeName] = contLayoutRect[innerSizeName] - availableSpace;
rect[alignContentSizeName] = maxAlignEndPos;
rect.minW = min(rect.minW, contLayoutRect.maxW);
rect.minH = min(rect.minH, contLayoutRect.maxH);
rect.minW = max(rect.minW, contLayoutRect.startMinWidth);
rect.minH = max(rect.minH, contLayoutRect.startMinHeight);
if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) {
rect.w = rect.minW;
rect.h = rect.minH;
container.layoutRect(rect);
this.recalc(container);
if (container._lastRect === null) {
var parentCtrl = container.parent();
if (parentCtrl) {
parentCtrl._lastRect = null;
parentCtrl.recalc();
}
}
return;
}
ratio = availableSpace / totalFlex;
for (i = 0, l = maxSizeItems.length; i < l; i++) {
ctrl = maxSizeItems[i];
ctrlLayoutRect = ctrl.layoutRect();
maxSize = ctrlLayoutRect[maxSizeName];
size = ctrlLayoutRect[minSizeName] + ctrlLayoutRect.flex * ratio;
if (size > maxSize) {
availableSpace -= ctrlLayoutRect[maxSizeName] - ctrlLayoutRect[minSizeName];
totalFlex -= ctrlLayoutRect.flex;
ctrlLayoutRect.flex = 0;
ctrlLayoutRect.maxFlexSize = maxSize;
} else {
ctrlLayoutRect.maxFlexSize = 0;
}
}
ratio = availableSpace / totalFlex;
pos = contPaddingBox[beforeName];
rect = {};
if (totalFlex === 0) {
if (pack === 'end') {
pos = availableSpace + contPaddingBox[beforeName];
} else if (pack === 'center') {
pos = Math.round(contLayoutRect[innerSizeName] / 2 - (contLayoutRect[innerSizeName] - availableSpace) / 2) + contPaddingBox[beforeName];
if (pos < 0) {
pos = contPaddingBox[beforeName];
}
} else if (pack === 'justify') {
pos = contPaddingBox[beforeName];
spacing = Math.floor(availableSpace / (items.length - 1));
}
}
rect[alignAxisName] = contPaddingBox[alignBeforeName];
for (i = 0, l = items.length; i < l; i++) {
ctrl = items[i];
ctrlLayoutRect = ctrl.layoutRect();
size = ctrlLayoutRect.maxFlexSize || ctrlLayoutRect[minSizeName];
if (align === 'center') {
rect[alignAxisName] = Math.round(contLayoutRect[alignInnerSizeName] / 2 - ctrlLayoutRect[alignSizeName] / 2);
} else if (align === 'stretch') {
rect[alignSizeName] = max(ctrlLayoutRect[alignMinSizeName] || 0, contLayoutRect[alignInnerSizeName] - contPaddingBox[alignBeforeName] - contPaddingBox[alignAfterName]);
rect[alignAxisName] = contPaddingBox[alignBeforeName];
} else if (align === 'end') {
rect[alignAxisName] = contLayoutRect[alignInnerSizeName] - ctrlLayoutRect[alignSizeName] - contPaddingBox.top;
}
if (ctrlLayoutRect.flex > 0) {
size += ctrlLayoutRect.flex * ratio;
}
rect[sizeName] = size;
rect[posName] = pos;
ctrl.layoutRect(rect);
if (ctrl.recalc) {
ctrl.recalc();
}
pos += size + spacing;
}
}
});
var FlowLayout = Layout$1.extend({
Defaults: {
containerClass: 'flow-layout',
controlClass: 'flow-layout-item',
endClass: 'break'
},
recalc: function (container) {
container.items().filter(':visible').each(function (ctrl) {
if (ctrl.recalc) {
ctrl.recalc();
}
});
},
isNative: function () {
return true;
}
});
var descendant = function (scope, selector) {
return one(selector, scope);
};
var toggleFormat = function (editor, fmt) {
return function () {
editor.execCommand('mceToggleFormat', false, fmt);
};
};
var addFormatChangedListener = function (editor, name, changed) {
var handler = function (state) {
changed(state, name);
};
if (editor.formatter) {
editor.formatter.formatChanged(name, handler);
} else {
editor.on('init', function () {
editor.formatter.formatChanged(name, handler);
});
}
};
var postRenderFormatToggle = function (editor, name) {
return function (e) {
addFormatChangedListener(editor, name, function (state) {
e.control.active(state);
});
};
};
var register = function (editor) {
var alignFormats = [
'alignleft',
'aligncenter',
'alignright',
'alignjustify'
];
var defaultAlign = 'alignleft';
var alignMenuItems = [
{
text: 'Left',
icon: 'alignleft',
onclick: toggleFormat(editor, 'alignleft')
},
{
text: 'Center',
icon: 'aligncenter',
onclick: toggleFormat(editor, 'aligncenter')
},
{
text: 'Right',
icon: 'alignright',
onclick: toggleFormat(editor, 'alignright')
},
{
text: 'Justify',
icon: 'alignjustify',
onclick: toggleFormat(editor, 'alignjustify')
}
];
editor.addMenuItem('align', {
text: 'Align',
menu: alignMenuItems
});
editor.addButton('align', {
type: 'menubutton',
icon: defaultAlign,
menu: alignMenuItems,
onShowMenu: function (e) {
var menu = e.control.menu;
global$4.each(alignFormats, function (formatName, idx) {
menu.items().eq(idx).each(function (item) {
return item.active(editor.formatter.match(formatName));
});
});
},
onPostRender: function (e) {
var ctrl = e.control;
global$4.each(alignFormats, function (formatName, idx) {
addFormatChangedListener(editor, formatName, function (state) {
ctrl.icon(defaultAlign);
if (state) {
ctrl.icon(formatName);
}
});
});
}
});
global$4.each({
alignleft: [
'Align left',
'JustifyLeft'
],
aligncenter: [
'Align center',
'JustifyCenter'
],
alignright: [
'Align right',
'JustifyRight'
],
alignjustify: [
'Justify',
'JustifyFull'
],
alignnone: [
'No alignment',
'JustifyNone'
]
}, function (item, name) {
editor.addButton(name, {
active: false,
tooltip: item[0],
cmd: item[1],
onPostRender: postRenderFormatToggle(editor, name)
});
});
};
var Align = { register: register };
var getFirstFont = function (fontFamily) {
return fontFamily ? fontFamily.split(',')[0] : '';
};
var findMatchingValue = function (items, fontFamily) {
var font = fontFamily ? fontFamily.toLowerCase() : '';
var value;
global$4.each(items, function (item) {
if (item.value.toLowerCase() === font) {
value = item.value;
}
});
global$4.each(items, function (item) {
if (!value && getFirstFont(item.value).toLowerCase() === getFirstFont(font).toLowerCase()) {
value = item.value;
}
});
return value;
};
var createFontNameListBoxChangeHandler = function (editor, items) {
return function () {
var self = this;
self.state.set('value', null);
editor.on('init nodeChange', function (e) {
var fontFamily = editor.queryCommandValue('FontName');
var match = findMatchingValue(items, fontFamily);
self.value(match ? match : null);
if (!match && fontFamily) {
self.text(getFirstFont(fontFamily));
}
});
};
};
var createFormats = function (formats) {
formats = formats.replace(/;$/, '').split(';');
var i = formats.length;
while (i--) {
formats[i] = formats[i].split('=');
}
return formats;
};
var getFontItems = function (editor) {
var defaultFontsFormats = 'Andale Mono=andale mono,monospace;' + 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,sans-serif;' + 'Book Antiqua=book antiqua,palatino,serif;' + 'Comic Sans MS=comic sans ms,sans-serif;' + 'Courier New=courier new,courier,monospace;' + 'Georgia=georgia,palatino,serif;' + 'Helvetica=helvetica,arial,sans-serif;' + 'Impact=impact,sans-serif;' + 'Symbol=symbol;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Terminal=terminal,monaco,monospace;' + 'Times New Roman=times new roman,times,serif;' + 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' + 'Verdana=verdana,geneva,sans-serif;' + 'Webdings=webdings;' + 'Wingdings=wingdings,zapf dingbats';
var fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
return global$4.map(fonts, function (font) {
return {
text: { raw: font[0] },
value: font[1],
textStyle: font[1].indexOf('dings') === -1 ? 'font-family:' + font[1] : ''
};
});
};
var registerButtons = function (editor) {
editor.addButton('fontselect', function () {
var items = getFontItems(editor);
return {
type: 'listbox',
text: 'Font Family',
tooltip: 'Font Family',
values: items,
fixedWidth: true,
onPostRender: createFontNameListBoxChangeHandler(editor, items),
onselect: function (e) {
if (e.control.settings.value) {
editor.execCommand('FontName', false, e.control.settings.value);
}
}
};
});
};
var register$1 = function (editor) {
registerButtons(editor);
};
var FontSelect = { register: register$1 };
var round = function (number, precision) {
var factor = Math.pow(10, precision);
return Math.round(number * factor) / factor;
};
var toPt = function (fontSize, precision) {
if (/[0-9.]+px$/.test(fontSize)) {
return round(parseInt(fontSize, 10) * 72 / 96, precision || 0) + 'pt';
}
return fontSize;
};
var findMatchingValue$1 = function (items, pt, px) {
var value;
global$4.each(items, function (item) {
if (item.value === px) {
value = px;
} else if (item.value === pt) {
value = pt;
}
});
return value;
};
var createFontSizeListBoxChangeHandler = function (editor, items) {
return function () {
var self = this;
editor.on('init nodeChange', function (e) {
var px, pt, precision, match;
px = editor.queryCommandValue('FontSize');
if (px) {
for (precision = 3; !match && precision >= 0; precision--) {
pt = toPt(px, precision);
match = findMatchingValue$1(items, pt, px);
}
}
self.value(match ? match : null);
if (!match) {
self.text(pt);
}
});
};
};
var getFontSizeItems = function (editor) {
var defaultFontsizeFormats = '8pt 10pt 12pt 14pt 18pt 24pt 36pt';
var fontsizeFormats = editor.settings.fontsize_formats || defaultFontsizeFormats;
return global$4.map(fontsizeFormats.split(' '), function (item) {
var text = item, value = item;
var values = item.split('=');
if (values.length > 1) {
text = values[0];
value = values[1];
}
return {
text: text,
value: value
};
});
};
var registerButtons$1 = function (editor) {
editor.addButton('fontsizeselect', function () {
var items = getFontSizeItems(editor);
return {
type: 'listbox',
text: 'Font Sizes',
tooltip: 'Font Sizes',
values: items,
fixedWidth: true,
onPostRender: createFontSizeListBoxChangeHandler(editor, items),
onclick: function (e) {
if (e.control.settings.value) {
editor.execCommand('FontSize', false, e.control.settings.value);
}
}
};
});
};
var register$2 = function (editor) {
registerButtons$1(editor);
};
var FontSizeSelect = { register: register$2 };
var hideMenuObjects = function (editor, menu) {
var count = menu.length;
global$4.each(menu, function (item) {
if (item.menu) {
item.hidden = hideMenuObjects(editor, item.menu) === 0;
}
var formatName = item.format;
if (formatName) {
item.hidden = !editor.formatter.canApply(formatName);
}
if (item.hidden) {
count--;
}
});
return count;
};
var hideFormatMenuItems = function (editor, menu) {
var count = menu.items().length;
menu.items().each(function (item) {
if (item.menu) {
item.visible(hideFormatMenuItems(editor, item.menu) > 0);
}
if (!item.menu && item.settings.menu) {
item.visible(hideMenuObjects(editor, item.settings.menu) > 0);
}
var formatName = item.settings.format;
if (formatName) {
item.visible(editor.formatter.canApply(formatName));
}
if (!item.visible()) {
count--;
}
});
return count;
};
var createFormatMenu = function (editor) {
var count = 0;
var newFormats = [];
var defaultStyleFormats = [
{
title: 'Headings',
items: [
{
title: 'Heading 1',
format: 'h1'
},
{
title: 'Heading 2',
format: 'h2'
},
{
title: 'Heading 3',
format: 'h3'
},
{
title: 'Heading 4',
format: 'h4'
},
{
title: 'Heading 5',
format: 'h5'
},
{
title: 'Heading 6',
format: 'h6'
}
]
},
{
title: 'Inline',
items: [
{
title: 'Bold',
icon: 'bold',
format: 'bold'
},
{
title: 'Italic',
icon: 'italic',
format: 'italic'
},
{
title: 'Underline',
icon: 'underline',
format: 'underline'
},
{
title: 'Strikethrough',
icon: 'strikethrough',
format: 'strikethrough'
},
{
title: 'Superscript',
icon: 'superscript',
format: 'superscript'
},
{
title: 'Subscript',
icon: 'subscript',
format: 'subscript'
},
{
title: 'Code',
icon: 'code',
format: 'code'
}
]
},
{
title: 'Blocks',
items: [
{
title: 'Paragraph',
format: 'p'
},
{
title: 'Blockquote',
format: 'blockquote'
},
{
title: 'Div',
format: 'div'
},
{
title: 'Pre',
format: 'pre'
}
]
},
{
title: 'Alignment',
items: [
{
title: 'Left',
icon: 'alignleft',
format: 'alignleft'
},
{
title: 'Center',
icon: 'aligncenter',
format: 'aligncenter'
},
{
title: 'Right',
icon: 'alignright',
format: 'alignright'
},
{
title: 'Justify',
icon: 'alignjustify',
format: 'alignjustify'
}
]
}
];
var createMenu = function (formats) {
var menu = [];
if (!formats) {
return;
}
global$4.each(formats, function (format) {
var menuItem = {
text: format.title,
icon: format.icon
};
if (format.items) {
menuItem.menu = createMenu(format.items);
} else {
var formatName = format.format || 'custom' + count++;
if (!format.format) {
format.name = formatName;
newFormats.push(format);
}
menuItem.format = formatName;
menuItem.cmd = format.cmd;
}
menu.push(menuItem);
});
return menu;
};
var createStylesMenu = function () {
var menu;
if (editor.settings.style_formats_merge) {
if (editor.settings.style_formats) {
menu = createMenu(defaultStyleFormats.concat(editor.settings.style_formats));
} else {
menu = createMenu(defaultStyleFormats);
}
} else {
menu = createMenu(editor.settings.style_formats || defaultStyleFormats);
}
return menu;
};
editor.on('init', function () {
global$4.each(newFormats, function (format) {
editor.formatter.register(format.name, format);
});
});
return {
type: 'menu',
items: createStylesMenu(),
onPostRender: function (e) {
editor.fire('renderFormatsMenu', { control: e.control });
},
itemDefaults: {
preview: true,
textStyle: function () {
if (this.settings.format) {
return editor.formatter.getCssText(this.settings.format);
}
},
onPostRender: function () {
var self = this;
self.parent().on('show', function () {
var formatName, command;
formatName = self.settings.format;
if (formatName) {
self.disabled(!editor.formatter.canApply(formatName));
self.active(editor.formatter.match(formatName));
}
command = self.settings.cmd;
if (command) {
self.active(editor.queryCommandState(command));
}
});
},
onclick: function () {
if (this.settings.format) {
toggleFormat(editor, this.settings.format)();
}
if (this.settings.cmd) {
editor.execCommand(this.settings.cmd);
}
}
}
};
};
var registerMenuItems = function (editor, formatMenu) {
editor.addMenuItem('formats', {
text: 'Formats',
menu: formatMenu
});
};
var registerButtons$2 = function (editor, formatMenu) {
editor.addButton('styleselect', {
type: 'menubutton',
text: 'Formats',
menu: formatMenu,
onShowMenu: function () {
if (editor.settings.style_formats_autohide) {
hideFormatMenuItems(editor, this.menu);
}
}
});
};
var register$3 = function (editor) {
var formatMenu = createFormatMenu(editor);
registerMenuItems(editor, formatMenu);
registerButtons$2(editor, formatMenu);
};
var Formats = { register: register$3 };
var defaultBlocks = 'Paragraph=p;' + 'Heading 1=h1;' + 'Heading 2=h2;' + 'Heading 3=h3;' + 'Heading 4=h4;' + 'Heading 5=h5;' + 'Heading 6=h6;' + 'Preformatted=pre';
var createFormats$1 = function (formats) {
formats = formats.replace(/;$/, '').split(';');
var i = formats.length;
while (i--) {
formats[i] = formats[i].split('=');
}
return formats;
};
var createListBoxChangeHandler = function (editor, items, formatName) {
return function () {
var self = this;
editor.on('nodeChange', function (e) {
var formatter = editor.formatter;
var value = null;
global$4.each(e.parents, function (node) {
global$4.each(items, function (item) {
if (formatName) {
if (formatter.matchNode(node, formatName, { value: item.value })) {
value = item.value;
}
} else {
if (formatter.matchNode(node, item.value)) {
value = item.value;
}
}
if (value) {
return false;
}
});
if (value) {
return false;
}
});
self.value(value);
});
};
};
var lazyFormatSelectBoxItems = function (editor, blocks) {
return function () {
var items = [];
global$4.each(blocks, function (block) {
items.push({
text: block[0],
value: block[1],
textStyle: function () {
return editor.formatter.getCssText(block[1]);
}
});
});
return {
type: 'listbox',
text: blocks[0][0],
values: items,
fixedWidth: true,
onselect: function (e) {
if (e.control) {
var fmt = e.control.value();
toggleFormat(editor, fmt)();
}
},
onPostRender: createListBoxChangeHandler(editor, items)
};
};
};
var buildMenuItems = function (editor, blocks) {
return global$4.map(blocks, function (block) {
return {
text: block[0],
onclick: toggleFormat(editor, block[1]),
textStyle: function () {
return editor.formatter.getCssText(block[1]);
}
};
});
};
var register$4 = function (editor) {
var blocks = createFormats$1(editor.settings.block_formats || defaultBlocks);
editor.addMenuItem('blockformats', {
text: 'Blocks',
menu: buildMenuItems(editor, blocks)
});
editor.addButton('formatselect', lazyFormatSelectBoxItems(editor, blocks));
};
var FormatSelect = { register: register$4 };
var createCustomMenuItems = function (editor, names) {
var items, nameList;
if (typeof names === 'string') {
nameList = names.split(' ');
} else if (global$4.isArray(names)) {
return flatten$1(global$4.map(names, function (names) {
return createCustomMenuItems(editor, names);
}));
}
items = global$4.grep(nameList, function (name) {
return name === '|' || name in editor.menuItems;
});
return global$4.map(items, function (name) {
return name === '|' ? { text: '-' } : editor.menuItems[name];
});
};
var isSeparator = function (menuItem) {
return menuItem && menuItem.text === '-';
};
var trimMenuItems = function (menuItems) {
var menuItems2 = filter(menuItems, function (menuItem, i) {
return !isSeparator(menuItem) || !isSeparator(menuItems[i - 1]);
});
return filter(menuItems2, function (menuItem, i) {
return !isSeparator(menuItem) || i > 0 && i < menuItems2.length - 1;
});
};
var createContextMenuItems = function (editor, context) {
var outputMenuItems = [{ text: '-' }];
var menuItems = global$4.grep(editor.menuItems, function (menuItem) {
return menuItem.context === context;
});
global$4.each(menuItems, function (menuItem) {
if (menuItem.separator === 'before') {
outputMenuItems.push({ text: '|' });
}
if (menuItem.prependToContext) {
outputMenuItems.unshift(menuItem);
} else {
outputMenuItems.push(menuItem);
}
if (menuItem.separator === 'after') {
outputMenuItems.push({ text: '|' });
}
});
return outputMenuItems;
};
var createInsertMenu = function (editor) {
var insertButtonItems = editor.settings.insert_button_items;
if (insertButtonItems) {
return trimMenuItems(createCustomMenuItems(editor, insertButtonItems));
} else {
return trimMenuItems(createContextMenuItems(editor, 'insert'));
}
};
var registerButtons$3 = function (editor) {
editor.addButton('insert', {
type: 'menubutton',
icon: 'insert',
menu: [],
oncreatemenu: function () {
this.menu.add(createInsertMenu(editor));
this.menu.renderNew();
}
});
};
var register$5 = function (editor) {
registerButtons$3(editor);
};
var InsertButton = { register: register$5 };
var registerFormatButtons = function (editor) {
global$4.each({
bold: 'Bold',
italic: 'Italic',
underline: 'Underline',
strikethrough: 'Strikethrough',
subscript: 'Subscript',
superscript: 'Superscript'
}, function (text, name) {
editor.addButton(name, {
active: false,
tooltip: text,
onPostRender: postRenderFormatToggle(editor, name),
onclick: toggleFormat(editor, name)
});
});
};
var registerCommandButtons = function (editor) {
global$4.each({
outdent: [
'Decrease indent',
'Outdent'
],
indent: [
'Increase indent',
'Indent'
],
cut: [
'Cut',
'Cut'
],
copy: [
'Copy',
'Copy'
],
paste: [
'Paste',
'Paste'
],
help: [
'Help',
'mceHelp'
],
selectall: [
'Select all',
'SelectAll'
],
visualaid: [
'Visual aids',
'mceToggleVisualAid'
],
newdocument: [
'New document',
'mceNewDocument'
],
removeformat: [
'Clear formatting',
'RemoveFormat'
],
remove: [
'Remove',
'Delete'
]
}, function (item, name) {
editor.addButton(name, {
tooltip: item[0],
cmd: item[1]
});
});
};
var registerCommandToggleButtons = function (editor) {
global$4.each({
blockquote: [
'Blockquote',
'mceBlockQuote'
],
subscript: [
'Subscript',
'Subscript'
],
superscript: [
'Superscript',
'Superscript'
]
}, function (item, name) {
editor.addButton(name, {
active: false,
tooltip: item[0],
cmd: item[1],
onPostRender: postRenderFormatToggle(editor, name)
});
});
};
var registerButtons$4 = function (editor) {
registerFormatButtons(editor);
registerCommandButtons(editor);
registerCommandToggleButtons(editor);
};
var registerMenuItems$1 = function (editor) {
global$4.each({
bold: [
'Bold',
'Bold',
'Meta+B'
],
italic: [
'Italic',
'Italic',
'Meta+I'
],
underline: [
'Underline',
'Underline',
'Meta+U'
],
strikethrough: [
'Strikethrough',
'Strikethrough'
],
subscript: [
'Subscript',
'Subscript'
],
superscript: [
'Superscript',
'Superscript'
],
removeformat: [
'Clear formatting',
'RemoveFormat'
],
newdocument: [
'New document',
'mceNewDocument'
],
cut: [
'Cut',
'Cut',
'Meta+X'
],
copy: [
'Copy',
'Copy',
'Meta+C'
],
paste: [
'Paste',
'Paste',
'Meta+V'
],
selectall: [
'Select all',
'SelectAll',
'Meta+A'
]
}, function (item, name) {
editor.addMenuItem(name, {
text: item[0],
icon: name,
shortcut: item[2],
cmd: item[1]
});
});
editor.addMenuItem('codeformat', {
text: 'Code',
icon: 'code',
onclick: toggleFormat(editor, 'code')
});
};
var register$6 = function (editor) {
registerButtons$4(editor);
registerMenuItems$1(editor);
};
var SimpleControls = { register: register$6 };
var toggleUndoRedoState = function (editor, type) {
return function () {
var self = this;
var checkState = function () {
var typeFn = type === 'redo' ? 'hasRedo' : 'hasUndo';
return editor.undoManager ? editor.undoManager[typeFn]() : false;
};
self.disabled(!checkState());
editor.on('Undo Redo AddUndo TypingUndo ClearUndos SwitchMode', function () {
self.disabled(editor.readonly || !checkState());
});
};
};
var registerMenuItems$2 = function (editor) {
editor.addMenuItem('undo', {
text: 'Undo',
icon: 'undo',
shortcut: 'Meta+Z',
onPostRender: toggleUndoRedoState(editor, 'undo'),
cmd: 'undo'
});
editor.addMenuItem('redo', {
text: 'Redo',
icon: 'redo',
shortcut: 'Meta+Y',
onPostRender: toggleUndoRedoState(editor, 'redo'),
cmd: 'redo'
});
};
var registerButtons$5 = function (editor) {
editor.addButton('undo', {
tooltip: 'Undo',
onPostRender: toggleUndoRedoState(editor, 'undo'),
cmd: 'undo'
});
editor.addButton('redo', {
tooltip: 'Redo',
onPostRender: toggleUndoRedoState(editor, 'redo'),
cmd: 'redo'
});
};
var register$7 = function (editor) {
registerMenuItems$2(editor);
registerButtons$5(editor);
};
var UndoRedo = { register: register$7 };
var toggleVisualAidState = function (editor) {
return function () {
var self = this;
editor.on('VisualAid', function (e) {
self.active(e.hasVisual);
});
self.active(editor.hasVisual);
};
};
var registerMenuItems$3 = function (editor) {
editor.addMenuItem('visualaid', {
text: 'Visual aids',
selectable: true,
onPostRender: toggleVisualAidState(editor),
cmd: 'mceToggleVisualAid'
});
};
var register$8 = function (editor) {
registerMenuItems$3(editor);
};
var VisualAid = { register: register$8 };
var setupEnvironment = function () {
Widget.tooltips = !global$1.iOS;
Control$1.translate = function (text) {
return global$5.translate(text);
};
};
var setupUiContainer = function (editor) {
if (editor.settings.ui_container) {
global$1.container = descendant(Element.fromDom(domGlobals.document.body), editor.settings.ui_container).fold(constant(null), function (elm) {
return elm.dom();
});
}
};
var setupRtlMode = function (editor) {
if (editor.rtl) {
Control$1.rtl = true;
}
};
var setupHideFloatPanels = function (editor) {
editor.on('mousedown progressstate', function () {
FloatPanel.hideAll();
});
};
var setup = function (editor) {
setupRtlMode(editor);
setupHideFloatPanels(editor);
setupUiContainer(editor);
setupEnvironment();
FormatSelect.register(editor);
Align.register(editor);
SimpleControls.register(editor);
UndoRedo.register(editor);
FontSizeSelect.register(editor);
FontSelect.register(editor);
Formats.register(editor);
VisualAid.register(editor);
InsertButton.register(editor);
};
var FormatControls = { setup: setup };
var GridLayout = AbsoluteLayout.extend({
recalc: function (container) {
var settings, rows, cols, items, contLayoutRect, width, height, rect, ctrlLayoutRect, ctrl, x, y, posX, posY, ctrlSettings, contPaddingBox, align, spacingH, spacingV, alignH, alignV, maxX, maxY;
var colWidths = [];
var rowHeights = [];
var ctrlMinWidth, ctrlMinHeight, availableWidth, availableHeight, reverseRows, idx;
settings = container.settings;
items = container.items().filter(':visible');
contLayoutRect = container.layoutRect();
cols = settings.columns || Math.ceil(Math.sqrt(items.length));
rows = Math.ceil(items.length / cols);
spacingH = settings.spacingH || settings.spacing || 0;
spacingV = settings.spacingV || settings.spacing || 0;
alignH = settings.alignH || settings.align;
alignV = settings.alignV || settings.align;
contPaddingBox = container.paddingBox;
reverseRows = 'reverseRows' in settings ? settings.reverseRows : container.isRtl();
if (alignH && typeof alignH === 'string') {
alignH = [alignH];
}
if (alignV && typeof alignV === 'string') {
alignV = [alignV];
}
for (x = 0; x < cols; x++) {
colWidths.push(0);
}
for (y = 0; y < rows; y++) {
rowHeights.push(0);
}
for (y = 0; y < rows; y++) {
for (x = 0; x < cols; x++) {
ctrl = items[y * cols + x];
if (!ctrl) {
break;
}
ctrlLayoutRect = ctrl.layoutRect();
ctrlMinWidth = ctrlLayoutRect.minW;
ctrlMinHeight = ctrlLayoutRect.minH;
colWidths[x] = ctrlMinWidth > colWidths[x] ? ctrlMinWidth : colWidths[x];
rowHeights[y] = ctrlMinHeight > rowHeights[y] ? ctrlMinHeight : rowHeights[y];
}
}
availableWidth = contLayoutRect.innerW - contPaddingBox.left - contPaddingBox.right;
for (maxX = 0, x = 0; x < cols; x++) {
maxX += colWidths[x] + (x > 0 ? spacingH : 0);
availableWidth -= (x > 0 ? spacingH : 0) + colWidths[x];
}
availableHeight = contLayoutRect.innerH - contPaddingBox.top - contPaddingBox.bottom;
for (maxY = 0, y = 0; y < rows; y++) {
maxY += rowHeights[y] + (y > 0 ? spacingV : 0);
availableHeight -= (y > 0 ? spacingV : 0) + rowHeights[y];
}
maxX += contPaddingBox.left + contPaddingBox.right;
maxY += contPaddingBox.top + contPaddingBox.bottom;
rect = {};
rect.minW = maxX + (contLayoutRect.w - contLayoutRect.innerW);
rect.minH = maxY + (contLayoutRect.h - contLayoutRect.innerH);
rect.contentW = rect.minW - contLayoutRect.deltaW;
rect.contentH = rect.minH - contLayoutRect.deltaH;
rect.minW = Math.min(rect.minW, contLayoutRect.maxW);
rect.minH = Math.min(rect.minH, contLayoutRect.maxH);
rect.minW = Math.max(rect.minW, contLayoutRect.startMinWidth);
rect.minH = Math.max(rect.minH, contLayoutRect.startMinHeight);
if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) {
rect.w = rect.minW;
rect.h = rect.minH;
container.layoutRect(rect);
this.recalc(container);
if (container._lastRect === null) {
var parentCtrl = container.parent();
if (parentCtrl) {
parentCtrl._lastRect = null;
parentCtrl.recalc();
}
}
return;
}
if (contLayoutRect.autoResize) {
rect = container.layoutRect(rect);
rect.contentW = rect.minW - contLayoutRect.deltaW;
rect.contentH = rect.minH - contLayoutRect.deltaH;
}
var flexV;
if (settings.packV === 'start') {
flexV = 0;
} else {
flexV = availableHeight > 0 ? Math.floor(availableHeight / rows) : 0;
}
var totalFlex = 0;
var flexWidths = settings.flexWidths;
if (flexWidths) {
for (x = 0; x < flexWidths.length; x++) {
totalFlex += flexWidths[x];
}
} else {
totalFlex = cols;
}
var ratio = availableWidth / totalFlex;
for (x = 0; x < cols; x++) {
colWidths[x] += flexWidths ? flexWidths[x] * ratio : ratio;
}
posY = contPaddingBox.top;
for (y = 0; y < rows; y++) {
posX = contPaddingBox.left;
height = rowHeights[y] + flexV;
for (x = 0; x < cols; x++) {
if (reverseRows) {
idx = y * cols + cols - 1 - x;
} else {
idx = y * cols + x;
}
ctrl = items[idx];
if (!ctrl) {
break;
}
ctrlSettings = ctrl.settings;
ctrlLayoutRect = ctrl.layoutRect();
width = Math.max(colWidths[x], ctrlLayoutRect.startMinWidth);
ctrlLayoutRect.x = posX;
ctrlLayoutRect.y = posY;
align = ctrlSettings.alignH || (alignH ? alignH[x] || alignH[0] : null);
if (align === 'center') {
ctrlLayoutRect.x = posX + width / 2 - ctrlLayoutRect.w / 2;
} else if (align === 'right') {
ctrlLayoutRect.x = posX + width - ctrlLayoutRect.w;
} else if (align === 'stretch') {
ctrlLayoutRect.w = width;
}
align = ctrlSettings.alignV || (alignV ? alignV[x] || alignV[0] : null);
if (align === 'center') {
ctrlLayoutRect.y = posY + height / 2 - ctrlLayoutRect.h / 2;
} else if (align === 'bottom') {
ctrlLayoutRect.y = posY + height - ctrlLayoutRect.h;
} else if (align === 'stretch') {
ctrlLayoutRect.h = height;
}
ctrl.layoutRect(ctrlLayoutRect);
posX += width + spacingH;
if (ctrl.recalc) {
ctrl.recalc();
}
}
posY += height + spacingV;
}
}
});
var Iframe = Widget.extend({
renderHtml: function () {
var self = this;
self.classes.add('iframe');
self.canFocus = false;
return '';
},
src: function (src) {
this.getEl().src = src;
},
html: function (html, callback) {
var self = this, body = this.getEl().contentWindow.document.body;
if (!body) {
global$3.setTimeout(function () {
self.html(html);
});
} else {
body.innerHTML = html;
if (callback) {
callback();
}
}
return this;
}
});
var InfoBox = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('widget').add('infobox');
self.canFocus = false;
},
severity: function (level) {
this.classes.remove('error');
this.classes.remove('warning');
this.classes.remove('success');
this.classes.add(level);
},
help: function (state) {
this.state.set('help', state);
},
renderHtml: function () {
var self = this, prefix = self.classPrefix;
return '' + '
' + self.encode(self.state.get('text')) + '' + ' ' + ' ' + '
' + '
';
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.getEl('body').firstChild.data = self.encode(e.value);
if (self.state.get('rendered')) {
self.updateLayoutRect();
}
});
self.state.on('change:help', function (e) {
self.classes.toggle('has-help', e.value);
if (self.state.get('rendered')) {
self.updateLayoutRect();
}
});
return self._super();
}
});
var Label = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('widget').add('label');
self.canFocus = false;
if (settings.multiline) {
self.classes.add('autoscroll');
}
if (settings.strong) {
self.classes.add('strong');
}
},
initLayoutRect: function () {
var self = this, layoutRect = self._super();
if (self.settings.multiline) {
var size = funcs.getSize(self.getEl());
if (size.width > layoutRect.maxW) {
layoutRect.minW = layoutRect.maxW;
self.classes.add('multiline');
}
self.getEl().style.width = layoutRect.minW + 'px';
layoutRect.startMinH = layoutRect.h = layoutRect.minH = Math.min(layoutRect.maxH, funcs.getSize(self.getEl()).height);
}
return layoutRect;
},
repaint: function () {
var self = this;
if (!self.settings.multiline) {
self.getEl().style.lineHeight = self.layoutRect().h + 'px';
}
return self._super();
},
severity: function (level) {
this.classes.remove('error');
this.classes.remove('warning');
this.classes.remove('success');
this.classes.add(level);
},
renderHtml: function () {
var self = this;
var targetCtrl, forName, forId = self.settings.forId;
var text = self.settings.html ? self.settings.html : self.encode(self.state.get('text'));
if (!forId && (forName = self.settings.forName)) {
targetCtrl = self.getRoot().find('#' + forName)[0];
if (targetCtrl) {
forId = targetCtrl._id;
}
}
if (forId) {
return '' + text + ' ';
}
return '' + text + ' ';
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.innerHtml(self.encode(e.value));
if (self.state.get('rendered')) {
self.updateLayoutRect();
}
});
return self._super();
}
});
var Toolbar$1 = Container.extend({
Defaults: {
role: 'toolbar',
layout: 'flow'
},
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('toolbar');
},
postRender: function () {
var self = this;
self.items().each(function (ctrl) {
ctrl.classes.add('toolbar-item');
});
return self._super();
}
});
var MenuBar = Toolbar$1.extend({
Defaults: {
role: 'menubar',
containerCls: 'menubar',
ariaRoot: true,
defaults: { type: 'menubutton' }
}
});
function isChildOf$1(node, parent) {
while (node) {
if (parent === node) {
return true;
}
node = node.parentNode;
}
return false;
}
var MenuButton = Button.extend({
init: function (settings) {
var self = this;
self._renderOpen = true;
self._super(settings);
settings = self.settings;
self.classes.add('menubtn');
if (settings.fixedWidth) {
self.classes.add('fixed-width');
}
self.aria('haspopup', true);
self.state.set('menu', settings.menu || self.render());
},
showMenu: function (toggle) {
var self = this;
var menu;
if (self.menu && self.menu.visible() && toggle !== false) {
return self.hideMenu();
}
if (!self.menu) {
menu = self.state.get('menu') || [];
self.classes.add('opened');
if (menu.length) {
menu = {
type: 'menu',
animate: true,
items: menu
};
} else {
menu.type = menu.type || 'menu';
menu.animate = true;
}
if (!menu.renderTo) {
self.menu = global$b.create(menu).parent(self).renderTo();
} else {
self.menu = menu.parent(self).show().renderTo();
}
self.fire('createmenu');
self.menu.reflow();
self.menu.on('cancel', function (e) {
if (e.control.parent() === self.menu) {
e.stopPropagation();
self.focus();
self.hideMenu();
}
});
self.menu.on('select', function () {
self.focus();
});
self.menu.on('show hide', function (e) {
if (e.type === 'hide' && e.control.parent() === self) {
self.classes.remove('opened-under');
}
if (e.control === self.menu) {
self.activeMenu(e.type === 'show');
self.classes.toggle('opened', e.type === 'show');
}
self.aria('expanded', e.type === 'show');
}).fire('show');
}
self.menu.show();
self.menu.layoutRect({ w: self.layoutRect().w });
self.menu.repaint();
self.menu.moveRel(self.getEl(), self.isRtl() ? [
'br-tr',
'tr-br'
] : [
'bl-tl',
'tl-bl'
]);
var menuLayoutRect = self.menu.layoutRect();
var selfBottom = self.$el.offset().top + self.layoutRect().h;
if (selfBottom > menuLayoutRect.y && selfBottom < menuLayoutRect.y + menuLayoutRect.h) {
self.classes.add('opened-under');
}
self.fire('showmenu');
},
hideMenu: function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
}
},
activeMenu: function (state) {
this.classes.toggle('active', state);
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
var icon = self.settings.icon, image;
var text = self.state.get('text');
var textHtml = '';
image = self.settings.image;
if (image) {
icon = 'none';
if (typeof image !== 'string') {
image = domGlobals.window.getSelection ? image[0] : image[1];
}
image = ' style="background-image: url(\'' + image + '\')"';
} else {
image = '';
}
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
self.aria('role', self.parent() instanceof MenuBar ? 'menuitem' : 'button');
return '' + '' + (icon ? ' ' : '') + textHtml + ' ' + ' ' + '
';
},
postRender: function () {
var self = this;
self.on('click', function (e) {
if (e.control === self && isChildOf$1(e.target, self.getEl())) {
self.focus();
self.showMenu(!e.aria);
if (e.aria) {
self.menu.items().filter(':visible')[0].focus();
}
}
});
self.on('mouseenter', function (e) {
var overCtrl = e.control;
var parent = self.parent();
var hasVisibleSiblingMenu;
if (overCtrl && parent && overCtrl instanceof MenuButton && overCtrl.parent() === parent) {
parent.items().filter('MenuButton').each(function (ctrl) {
if (ctrl.hideMenu && ctrl !== overCtrl) {
if (ctrl.menu && ctrl.menu.visible()) {
hasVisibleSiblingMenu = true;
}
ctrl.hideMenu();
}
});
if (hasVisibleSiblingMenu) {
overCtrl.focus();
overCtrl.showMenu();
}
}
});
return self._super();
},
bindStates: function () {
var self = this;
self.state.on('change:menu', function () {
if (self.menu) {
self.menu.remove();
}
self.menu = null;
});
return self._super();
},
remove: function () {
this._super();
if (this.menu) {
this.menu.remove();
}
}
});
function Throbber (elm, inline) {
var self = this;
var state;
var classPrefix = Control$1.classPrefix;
var timer;
self.show = function (time, callback) {
function render() {
if (state) {
global$7(elm).append('
');
if (callback) {
callback();
}
}
}
self.hide();
state = true;
if (time) {
timer = global$3.setTimeout(render, time);
} else {
render();
}
return self;
};
self.hide = function () {
var child = elm.lastChild;
global$3.clearTimeout(timer);
if (child && child.className.indexOf('throbber') !== -1) {
child.parentNode.removeChild(child);
}
state = false;
return self;
};
}
var Menu = FloatPanel.extend({
Defaults: {
defaultType: 'menuitem',
border: 1,
layout: 'stack',
role: 'application',
bodyRole: 'menu',
ariaRoot: true
},
init: function (settings) {
var self = this;
settings.autohide = true;
settings.constrainToViewport = true;
if (typeof settings.items === 'function') {
settings.itemsFactory = settings.items;
settings.items = [];
}
if (settings.itemDefaults) {
var items = settings.items;
var i = items.length;
while (i--) {
items[i] = global$4.extend({}, settings.itemDefaults, items[i]);
}
}
self._super(settings);
self.classes.add('menu');
if (settings.animate && global$1.ie !== 11) {
self.classes.add('animate');
}
},
repaint: function () {
this.classes.toggle('menu-align', true);
this._super();
this.getEl().style.height = '';
this.getEl('body').style.height = '';
return this;
},
cancel: function () {
var self = this;
self.hideAll();
self.fire('select');
},
load: function () {
var self = this;
var time, factory;
function hideThrobber() {
if (self.throbber) {
self.throbber.hide();
self.throbber = null;
}
}
factory = self.settings.itemsFactory;
if (!factory) {
return;
}
if (!self.throbber) {
self.throbber = new Throbber(self.getEl('body'), true);
if (self.items().length === 0) {
self.throbber.show();
self.fire('loading');
} else {
self.throbber.show(100, function () {
self.items().remove();
self.fire('loading');
});
}
self.on('hide close', hideThrobber);
}
self.requestTime = time = new Date().getTime();
self.settings.itemsFactory(function (items) {
if (items.length === 0) {
self.hide();
return;
}
if (self.requestTime !== time) {
return;
}
self.getEl().style.width = '';
self.getEl('body').style.width = '';
hideThrobber();
self.items().remove();
self.getEl('body').innerHTML = '';
self.add(items);
self.renderNew();
self.fire('loaded');
});
},
hideAll: function () {
var self = this;
this.find('menuitem').exec('hideMenu');
return self._super();
},
preRender: function () {
var self = this;
self.items().each(function (ctrl) {
var settings = ctrl.settings;
if (settings.icon || settings.image || settings.selectable) {
self._hasIcons = true;
return false;
}
});
if (self.settings.itemsFactory) {
self.on('postrender', function () {
if (self.settings.itemsFactory) {
self.load();
}
});
}
self.on('show hide', function (e) {
if (e.control === self) {
if (e.type === 'show') {
global$3.setTimeout(function () {
self.classes.add('in');
}, 0);
} else {
self.classes.remove('in');
}
}
});
return self._super();
}
});
var ListBox = MenuButton.extend({
init: function (settings) {
var self = this;
var values, selected, selectedText, lastItemCtrl;
function setSelected(menuValues) {
for (var i = 0; i < menuValues.length; i++) {
selected = menuValues[i].selected || settings.value === menuValues[i].value;
if (selected) {
selectedText = selectedText || menuValues[i].text;
self.state.set('value', menuValues[i].value);
return true;
}
if (menuValues[i].menu) {
if (setSelected(menuValues[i].menu)) {
return true;
}
}
}
}
self._super(settings);
settings = self.settings;
self._values = values = settings.values;
if (values) {
if (typeof settings.value !== 'undefined') {
setSelected(values);
}
if (!selected && values.length > 0) {
selectedText = values[0].text;
self.state.set('value', values[0].value);
}
self.state.set('menu', values);
}
self.state.set('text', settings.text || selectedText);
self.classes.add('listbox');
self.on('select', function (e) {
var ctrl = e.control;
if (lastItemCtrl) {
e.lastControl = lastItemCtrl;
}
if (settings.multiple) {
ctrl.active(!ctrl.active());
} else {
self.value(e.control.value());
}
lastItemCtrl = ctrl;
});
},
value: function (value) {
if (arguments.length === 0) {
return this.state.get('value');
}
if (typeof value === 'undefined') {
return this;
}
function valueExists(values) {
return exists(values, function (a) {
return a.menu ? valueExists(a.menu) : a.value === value;
});
}
if (this.settings.values) {
if (valueExists(this.settings.values)) {
this.state.set('value', value);
} else if (value === null) {
this.state.set('value', null);
}
} else {
this.state.set('value', value);
}
return this;
},
bindStates: function () {
var self = this;
function activateMenuItemsByValue(menu, value) {
if (menu instanceof Menu) {
menu.items().each(function (ctrl) {
if (!ctrl.hasMenus()) {
ctrl.active(ctrl.value() === value);
}
});
}
}
function getSelectedItem(menuValues, value) {
var selectedItem;
if (!menuValues) {
return;
}
for (var i = 0; i < menuValues.length; i++) {
if (menuValues[i].value === value) {
return menuValues[i];
}
if (menuValues[i].menu) {
selectedItem = getSelectedItem(menuValues[i].menu, value);
if (selectedItem) {
return selectedItem;
}
}
}
}
self.on('show', function (e) {
activateMenuItemsByValue(e.control, self.value());
});
self.state.on('change:value', function (e) {
var selectedItem = getSelectedItem(self.state.get('menu'), e.value);
if (selectedItem) {
self.text(selectedItem.text);
} else {
self.text(self.settings.text);
}
});
return self._super();
}
});
var toggleTextStyle = function (ctrl, state) {
var textStyle = ctrl._textStyle;
if (textStyle) {
var textElm = ctrl.getEl('text');
textElm.setAttribute('style', textStyle);
if (state) {
textElm.style.color = '';
textElm.style.backgroundColor = '';
}
}
};
var MenuItem = Widget.extend({
Defaults: {
border: 0,
role: 'menuitem'
},
init: function (settings) {
var self = this;
var text;
self._super(settings);
settings = self.settings;
self.classes.add('menu-item');
if (settings.menu) {
self.classes.add('menu-item-expand');
}
if (settings.preview) {
self.classes.add('menu-item-preview');
}
text = self.state.get('text');
if (text === '-' || text === '|') {
self.classes.add('menu-item-sep');
self.aria('role', 'separator');
self.state.set('text', '-');
}
if (settings.selectable) {
self.aria('role', 'menuitemcheckbox');
self.classes.add('menu-item-checkbox');
settings.icon = 'selected';
}
if (!settings.preview && !settings.selectable) {
self.classes.add('menu-item-normal');
}
self.on('mousedown', function (e) {
e.preventDefault();
});
if (settings.menu && !settings.ariaHideMenu) {
self.aria('haspopup', true);
}
},
hasMenus: function () {
return !!this.settings.menu;
},
showMenu: function () {
var self = this;
var settings = self.settings;
var menu;
var parent = self.parent();
parent.items().each(function (ctrl) {
if (ctrl !== self) {
ctrl.hideMenu();
}
});
if (settings.menu) {
menu = self.menu;
if (!menu) {
menu = settings.menu;
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
if (parent.settings.itemDefaults) {
menu.itemDefaults = parent.settings.itemDefaults;
}
menu = self.menu = global$b.create(menu).parent(self).renderTo();
menu.reflow();
menu.on('cancel', function (e) {
e.stopPropagation();
self.focus();
menu.hide();
});
menu.on('show hide', function (e) {
if (e.control.items) {
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.settings.selected);
});
}
}).fire('show');
menu.on('hide', function (e) {
if (e.control === menu) {
self.classes.remove('selected');
}
});
menu.submenu = true;
} else {
menu.show();
}
menu._parentMenu = parent;
menu.classes.add('menu-sub');
var rel = menu.testMoveRel(self.getEl(), self.isRtl() ? [
'tl-tr',
'bl-br',
'tr-tl',
'br-bl'
] : [
'tr-tl',
'br-bl',
'tl-tr',
'bl-br'
]);
menu.moveRel(self.getEl(), rel);
menu.rel = rel;
rel = 'menu-sub-' + rel;
menu.classes.remove(menu._lastRel).add(rel);
menu._lastRel = rel;
self.classes.add('selected');
self.aria('expanded', true);
}
},
hideMenu: function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
self.aria('expanded', false);
}
return self;
},
renderHtml: function () {
var self = this;
var id = self._id;
var settings = self.settings;
var prefix = self.classPrefix;
var text = self.state.get('text');
var icon = self.settings.icon, image = '', shortcut = settings.shortcut;
var url = self.encode(settings.url), iconHtml = '';
function convertShortcut(shortcut) {
var i, value, replace = {};
if (global$1.mac) {
replace = {
alt: '⌥',
ctrl: '⌘',
shift: '⇧',
meta: '⌘'
};
} else {
replace = { meta: 'Ctrl' };
}
shortcut = shortcut.split('+');
for (i = 0; i < shortcut.length; i++) {
value = replace[shortcut[i].toLowerCase()];
if (value) {
shortcut[i] = value;
}
}
return shortcut.join('+');
}
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function markMatches(text) {
var match = settings.match || '';
return match ? text.replace(new RegExp(escapeRegExp(match), 'gi'), function (match) {
return '!mce~match[' + match + ']mce~match!';
}) : text;
}
function boldMatches(text) {
return text.replace(new RegExp(escapeRegExp('!mce~match['), 'g'), '').replace(new RegExp(escapeRegExp(']mce~match!'), 'g'), ' ');
}
if (icon) {
self.parent().classes.add('menu-has-icons');
}
if (settings.image) {
image = ' style="background-image: url(\'' + settings.image + '\')"';
}
if (shortcut) {
shortcut = convertShortcut(shortcut);
}
icon = prefix + 'ico ' + prefix + 'i-' + (self.settings.icon || 'none');
iconHtml = text !== '-' ? ' \xA0' : '';
text = boldMatches(self.encode(markMatches(text)));
url = boldMatches(self.encode(markMatches(url)));
return '' + iconHtml + (text !== '-' ? '
' + text + ' ' : '') + (shortcut ? '' : '') + (settings.menu ? '
' : '') + (url ? '' : '') + '
';
},
postRender: function () {
var self = this, settings = self.settings;
var textStyle = settings.textStyle;
if (typeof textStyle === 'function') {
textStyle = textStyle.call(this);
}
if (textStyle) {
var textElm = self.getEl('text');
if (textElm) {
textElm.setAttribute('style', textStyle);
self._textStyle = textStyle;
}
}
self.on('mouseenter click', function (e) {
if (e.control === self) {
if (!settings.menu && e.type === 'click') {
self.fire('select');
global$3.requestAnimationFrame(function () {
self.parent().hideAll();
});
} else {
self.showMenu();
if (e.aria) {
self.menu.focus(true);
}
}
}
});
self._super();
return self;
},
hover: function () {
var self = this;
self.parent().items().each(function (ctrl) {
ctrl.classes.remove('selected');
});
self.classes.toggle('selected', true);
return self;
},
active: function (state) {
toggleTextStyle(this, state);
if (typeof state !== 'undefined') {
this.aria('checked', state);
}
return this._super(state);
},
remove: function () {
this._super();
if (this.menu) {
this.menu.remove();
}
}
});
var Radio = Checkbox.extend({
Defaults: {
classes: 'radio',
role: 'radio'
}
});
var ResizeHandle = Widget.extend({
renderHtml: function () {
var self = this, prefix = self.classPrefix;
self.classes.add('resizehandle');
if (self.settings.direction === 'both') {
self.classes.add('resizehandle-both');
}
self.canFocus = false;
return '' + ' ' + '
';
},
postRender: function () {
var self = this;
self._super();
self.resizeDragHelper = new DragHelper(this._id, {
start: function () {
self.fire('ResizeStart');
},
drag: function (e) {
if (self.settings.direction !== 'both') {
e.deltaX = 0;
}
self.fire('Resize', e);
},
stop: function () {
self.fire('ResizeEnd');
}
});
},
remove: function () {
if (this.resizeDragHelper) {
this.resizeDragHelper.destroy();
}
return this._super();
}
});
function createOptions(options) {
var strOptions = '';
if (options) {
for (var i = 0; i < options.length; i++) {
strOptions += '' + options[i] + ' ';
}
}
return strOptions;
}
var SelectBox = Widget.extend({
Defaults: {
classes: 'selectbox',
role: 'selectbox',
options: []
},
init: function (settings) {
var self = this;
self._super(settings);
if (self.settings.size) {
self.size = self.settings.size;
}
if (self.settings.options) {
self._options = self.settings.options;
}
self.on('keydown', function (e) {
var rootControl;
if (e.keyCode === 13) {
e.preventDefault();
self.parents().reverse().each(function (ctrl) {
if (ctrl.toJSON) {
rootControl = ctrl;
return false;
}
});
self.fire('submit', { data: rootControl.toJSON() });
}
});
},
options: function (state) {
if (!arguments.length) {
return this.state.get('options');
}
this.state.set('options', state);
return this;
},
renderHtml: function () {
var self = this;
var options, size = '';
options = createOptions(self._options);
if (self.size) {
size = ' size = "' + self.size + '"';
}
return '' + options + ' ';
},
bindStates: function () {
var self = this;
self.state.on('change:options', function (e) {
self.getEl().innerHTML = createOptions(e.value);
});
return self._super();
}
});
function constrain(value, minVal, maxVal) {
if (value < minVal) {
value = minVal;
}
if (value > maxVal) {
value = maxVal;
}
return value;
}
function setAriaProp(el, name, value) {
el.setAttribute('aria-' + name, value);
}
function updateSliderHandle(ctrl, value) {
var maxHandlePos, shortSizeName, sizeName, stylePosName, styleValue, handleEl;
if (ctrl.settings.orientation === 'v') {
stylePosName = 'top';
sizeName = 'height';
shortSizeName = 'h';
} else {
stylePosName = 'left';
sizeName = 'width';
shortSizeName = 'w';
}
handleEl = ctrl.getEl('handle');
maxHandlePos = (ctrl.layoutRect()[shortSizeName] || 100) - funcs.getSize(handleEl)[sizeName];
styleValue = maxHandlePos * ((value - ctrl._minValue) / (ctrl._maxValue - ctrl._minValue)) + 'px';
handleEl.style[stylePosName] = styleValue;
handleEl.style.height = ctrl.layoutRect().h + 'px';
setAriaProp(handleEl, 'valuenow', value);
setAriaProp(handleEl, 'valuetext', '' + ctrl.settings.previewFilter(value));
setAriaProp(handleEl, 'valuemin', ctrl._minValue);
setAriaProp(handleEl, 'valuemax', ctrl._maxValue);
}
var Slider = Widget.extend({
init: function (settings) {
var self = this;
if (!settings.previewFilter) {
settings.previewFilter = function (value) {
return Math.round(value * 100) / 100;
};
}
self._super(settings);
self.classes.add('slider');
if (settings.orientation === 'v') {
self.classes.add('vertical');
}
self._minValue = isNumber$1(settings.minValue) ? settings.minValue : 0;
self._maxValue = isNumber$1(settings.maxValue) ? settings.maxValue : 100;
self._initValue = self.state.get('value');
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
return '';
},
reset: function () {
this.value(this._initValue).repaint();
},
postRender: function () {
var self = this;
var minValue, maxValue, screenCordName, stylePosName, sizeName, shortSizeName;
function toFraction(min, max, val) {
return (val + min) / (max - min);
}
function fromFraction(min, max, val) {
return val * (max - min) - min;
}
function handleKeyboard(minValue, maxValue) {
function alter(delta) {
var value;
value = self.value();
value = fromFraction(minValue, maxValue, toFraction(minValue, maxValue, value) + delta * 0.05);
value = constrain(value, minValue, maxValue);
self.value(value);
self.fire('dragstart', { value: value });
self.fire('drag', { value: value });
self.fire('dragend', { value: value });
}
self.on('keydown', function (e) {
switch (e.keyCode) {
case 37:
case 38:
alter(-1);
break;
case 39:
case 40:
alter(1);
break;
}
});
}
function handleDrag(minValue, maxValue, handleEl) {
var startPos, startHandlePos, maxHandlePos, handlePos, value;
self._dragHelper = new DragHelper(self._id, {
handle: self._id + '-handle',
start: function (e) {
startPos = e[screenCordName];
startHandlePos = parseInt(self.getEl('handle').style[stylePosName], 10);
maxHandlePos = (self.layoutRect()[shortSizeName] || 100) - funcs.getSize(handleEl)[sizeName];
self.fire('dragstart', { value: value });
},
drag: function (e) {
var delta = e[screenCordName] - startPos;
handlePos = constrain(startHandlePos + delta, 0, maxHandlePos);
handleEl.style[stylePosName] = handlePos + 'px';
value = minValue + handlePos / maxHandlePos * (maxValue - minValue);
self.value(value);
self.tooltip().text('' + self.settings.previewFilter(value)).show().moveRel(handleEl, 'bc tc');
self.fire('drag', { value: value });
},
stop: function () {
self.tooltip().hide();
self.fire('dragend', { value: value });
}
});
}
minValue = self._minValue;
maxValue = self._maxValue;
if (self.settings.orientation === 'v') {
screenCordName = 'screenY';
stylePosName = 'top';
sizeName = 'height';
shortSizeName = 'h';
} else {
screenCordName = 'screenX';
stylePosName = 'left';
sizeName = 'width';
shortSizeName = 'w';
}
self._super();
handleKeyboard(minValue, maxValue);
handleDrag(minValue, maxValue, self.getEl('handle'));
},
repaint: function () {
this._super();
updateSliderHandle(this, this.value());
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
updateSliderHandle(self, e.value);
});
return self._super();
}
});
var Spacer = Widget.extend({
renderHtml: function () {
var self = this;
self.classes.add('spacer');
self.canFocus = false;
return '
';
}
});
var SplitButton = MenuButton.extend({
Defaults: {
classes: 'widget btn splitbtn',
role: 'button'
},
repaint: function () {
var self = this;
var elm = self.getEl();
var rect = self.layoutRect();
var mainButtonElm, menuButtonElm;
self._super();
mainButtonElm = elm.firstChild;
menuButtonElm = elm.lastChild;
global$7(mainButtonElm).css({
width: rect.w - funcs.getSize(menuButtonElm).width,
height: rect.h - 2
});
global$7(menuButtonElm).css({ height: rect.h - 2 });
return self;
},
activeMenu: function (state) {
var self = this;
global$7(self.getEl().lastChild).toggleClass(self.classPrefix + 'active', state);
},
renderHtml: function () {
var self = this;
var id = self._id;
var prefix = self.classPrefix;
var image;
var icon = self.state.get('icon');
var text = self.state.get('text');
var settings = self.settings;
var textHtml = '', ariaPressed;
image = settings.image;
if (image) {
icon = 'none';
if (typeof image !== 'string') {
image = domGlobals.window.getSelection ? image[0] : image[1];
}
image = ' style="background-image: url(\'' + image + '\')"';
} else {
image = '';
}
icon = settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : '';
return '' + '' + (icon ? ' ' : '') + textHtml + ' ' + '' + (self._menuBtnText ? (icon ? '\xA0' : '') + self._menuBtnText : '') + ' ' + ' ' + '
';
},
postRender: function () {
var self = this, onClickHandler = self.settings.onclick;
self.on('click', function (e) {
var node = e.target;
if (e.control === this) {
while (node) {
if (e.aria && e.aria.key !== 'down' || node.nodeName === 'BUTTON' && node.className.indexOf('open') === -1) {
e.stopImmediatePropagation();
if (onClickHandler) {
onClickHandler.call(this, e);
}
return;
}
node = node.parentNode;
}
}
});
delete self.settings.onclick;
return self._super();
}
});
var StackLayout = FlowLayout.extend({
Defaults: {
containerClass: 'stack-layout',
controlClass: 'stack-layout-item',
endClass: 'break'
},
isNative: function () {
return true;
}
});
var TabPanel = Panel.extend({
Defaults: {
layout: 'absolute',
defaults: { type: 'panel' }
},
activateTab: function (idx) {
var activeTabElm;
if (this.activeTabId) {
activeTabElm = this.getEl(this.activeTabId);
global$7(activeTabElm).removeClass(this.classPrefix + 'active');
activeTabElm.setAttribute('aria-selected', 'false');
}
this.activeTabId = 't' + idx;
activeTabElm = this.getEl('t' + idx);
activeTabElm.setAttribute('aria-selected', 'true');
global$7(activeTabElm).addClass(this.classPrefix + 'active');
this.items()[idx].show().fire('showtab');
this.reflow();
this.items().each(function (item, i) {
if (idx !== i) {
item.hide();
}
});
},
renderHtml: function () {
var self = this;
var layout = self._layout;
var tabsHtml = '';
var prefix = self.classPrefix;
self.preRender();
layout.preRender(self);
self.items().each(function (ctrl, i) {
var id = self._id + '-t' + i;
ctrl.aria('role', 'tabpanel');
ctrl.aria('labelledby', id);
tabsHtml += '' + self.encode(ctrl.settings.title) + '
';
});
return '' + '
' + tabsHtml + '
' + '
' + layout.renderHtml(self) + '
' + '
';
},
postRender: function () {
var self = this;
self._super();
self.settings.activeTab = self.settings.activeTab || 0;
self.activateTab(self.settings.activeTab);
this.on('click', function (e) {
var targetParent = e.target.parentNode;
if (targetParent && targetParent.id === self._id + '-head') {
var i = targetParent.childNodes.length;
while (i--) {
if (targetParent.childNodes[i] === e.target) {
self.activateTab(i);
}
}
}
});
},
initLayoutRect: function () {
var self = this;
var rect, minW, minH;
minW = funcs.getSize(self.getEl('head')).width;
minW = minW < 0 ? 0 : minW;
minH = 0;
self.items().each(function (item) {
minW = Math.max(minW, item.layoutRect().minW);
minH = Math.max(minH, item.layoutRect().minH);
});
self.items().each(function (ctrl) {
ctrl.settings.x = 0;
ctrl.settings.y = 0;
ctrl.settings.w = minW;
ctrl.settings.h = minH;
ctrl.layoutRect({
x: 0,
y: 0,
w: minW,
h: minH
});
});
var headH = funcs.getSize(self.getEl('head')).height;
self.settings.minWidth = minW;
self.settings.minHeight = minH + headH;
rect = self._super();
rect.deltaH += headH;
rect.innerH = rect.h - rect.deltaH;
return rect;
}
});
var TextBox = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('textbox');
if (settings.multiline) {
self.classes.add('multiline');
} else {
self.on('keydown', function (e) {
var rootControl;
if (e.keyCode === 13) {
e.preventDefault();
self.parents().reverse().each(function (ctrl) {
if (ctrl.toJSON) {
rootControl = ctrl;
return false;
}
});
self.fire('submit', { data: rootControl.toJSON() });
}
});
self.on('keyup', function (e) {
self.state.set('value', e.target.value);
});
}
},
repaint: function () {
var self = this;
var style, rect, borderBox, borderW, borderH = 0, lastRepaintRect;
style = self.getEl().style;
rect = self._layoutRect;
lastRepaintRect = self._lastRepaintRect || {};
var doc = domGlobals.document;
if (!self.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) {
style.lineHeight = rect.h - borderH + 'px';
}
borderBox = self.borderBox;
borderW = borderBox.left + borderBox.right + 8;
borderH = borderBox.top + borderBox.bottom + (self.settings.multiline ? 8 : 0);
if (rect.x !== lastRepaintRect.x) {
style.left = rect.x + 'px';
lastRepaintRect.x = rect.x;
}
if (rect.y !== lastRepaintRect.y) {
style.top = rect.y + 'px';
lastRepaintRect.y = rect.y;
}
if (rect.w !== lastRepaintRect.w) {
style.width = rect.w - borderW + 'px';
lastRepaintRect.w = rect.w;
}
if (rect.h !== lastRepaintRect.h) {
style.height = rect.h - borderH + 'px';
lastRepaintRect.h = rect.h;
}
self._lastRepaintRect = lastRepaintRect;
self.fire('repaint', {}, false);
return self;
},
renderHtml: function () {
var self = this;
var settings = self.settings;
var attrs, elm;
attrs = {
id: self._id,
hidefocus: '1'
};
global$4.each([
'rows',
'spellcheck',
'maxLength',
'size',
'readonly',
'min',
'max',
'step',
'list',
'pattern',
'placeholder',
'required',
'multiple'
], function (name) {
attrs[name] = settings[name];
});
if (self.disabled()) {
attrs.disabled = 'disabled';
}
if (settings.subtype) {
attrs.type = settings.subtype;
}
elm = funcs.create(settings.multiline ? 'textarea' : 'input', attrs);
elm.value = self.state.get('value');
elm.className = self.classes.toString();
return elm.outerHTML;
},
value: function (value) {
if (arguments.length) {
this.state.set('value', value);
return this;
}
if (this.state.get('rendered')) {
this.state.set('value', this.getEl().value);
}
return this.state.get('value');
},
postRender: function () {
var self = this;
self.getEl().value = self.state.get('value');
self._super();
self.$el.on('change', function (e) {
self.state.set('value', e.target.value);
self.fire('change', e);
});
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
if (self.getEl().value !== e.value) {
self.getEl().value = e.value;
}
});
self.state.on('change:disabled', function (e) {
self.getEl().disabled = e.value;
});
return self._super();
},
remove: function () {
this.$el.off();
this._super();
}
});
var getApi = function () {
return {
Selector: Selector,
Collection: Collection$2,
ReflowQueue: ReflowQueue,
Control: Control$1,
Factory: global$b,
KeyboardNavigation: KeyboardNavigation,
Container: Container,
DragHelper: DragHelper,
Scrollable: Scrollable,
Panel: Panel,
Movable: Movable,
Resizable: Resizable,
FloatPanel: FloatPanel,
Window: Window,
MessageBox: MessageBox,
Tooltip: Tooltip,
Widget: Widget,
Progress: Progress,
Notification: Notification,
Layout: Layout$1,
AbsoluteLayout: AbsoluteLayout,
Button: Button,
ButtonGroup: ButtonGroup,
Checkbox: Checkbox,
ComboBox: ComboBox,
ColorBox: ColorBox,
PanelButton: PanelButton,
ColorButton: ColorButton,
ColorPicker: ColorPicker,
Path: Path,
ElementPath: ElementPath,
FormItem: FormItem,
Form: Form,
FieldSet: FieldSet,
FilePicker: FilePicker,
FitLayout: FitLayout,
FlexLayout: FlexLayout,
FlowLayout: FlowLayout,
FormatControls: FormatControls,
GridLayout: GridLayout,
Iframe: Iframe,
InfoBox: InfoBox,
Label: Label,
Toolbar: Toolbar$1,
MenuBar: MenuBar,
MenuButton: MenuButton,
MenuItem: MenuItem,
Throbber: Throbber,
Menu: Menu,
ListBox: ListBox,
Radio: Radio,
ResizeHandle: ResizeHandle,
SelectBox: SelectBox,
Slider: Slider,
Spacer: Spacer,
SplitButton: SplitButton,
StackLayout: StackLayout,
TabPanel: TabPanel,
TextBox: TextBox,
DropZone: DropZone,
BrowseButton: BrowseButton
};
};
var appendTo = function (target) {
if (target.ui) {
global$4.each(getApi(), function (ref, key) {
target.ui[key] = ref;
});
} else {
target.ui = getApi();
}
};
var registerToFactory = function () {
global$4.each(getApi(), function (ref, key) {
global$b.add(key, ref);
});
};
var Api = {
appendTo: appendTo,
registerToFactory: registerToFactory
};
Api.registerToFactory();
Api.appendTo(window.tinymce ? window.tinymce : {});
global.add('inlite', function (editor) {
var panel = create$3();
FormatControls.setup(editor);
Buttons.addToEditor(editor, panel);
return ThemeApi.get(editor, panel);
});
function Theme () {
}
return Theme;
}(window));
})();
themes/inlite/theme.min.js 0000644 00000401443 14740051667 0011557 0 ustar 00 !function(_){"use strict";var u,t,e,n,i,r=tinymce.util.Tools.resolve("tinymce.ThemeManager"),h=tinymce.util.Tools.resolve("tinymce.Env"),v=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),c=tinymce.util.Tools.resolve("tinymce.util.Delay"),o=function(t){return t.reduce(function(t,e){return Array.isArray(e)?t.concat(o(e)):t.concat(e)},[])},s={flatten:o},a=function(t,e){for(var n=0;n+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,zt=/^\s*|\s*$/g,Ft=St.extend({init:function(t){var o=this.match;function s(t,e,n){var i;function r(t){t&&e.push(t)}return r(function(e){if(e)return e=e.toLowerCase(),function(t){return"*"===e||t.type===e}}((i=Lt.exec(t.replace(zt,"")))[1])),r(function(e){if(e)return function(t){return t._name===e}}(i[2])),r(function(n){if(n)return n=n.split("."),function(t){for(var e=n.length;e--;)if(!t.classes.contains(n[e]))return!1;return!0}}(i[3])),r(function(n,i,r){if(n)return function(t){var e=t[n]?t[n]():"";return i?"="===i?e===r:"*="===i?0<=e.indexOf(r):"~="===i?0<=(" "+e+" ").indexOf(" "+r+" "):"!="===i?e!==r:"^="===i?0===e.indexOf(r):"$="===i&&e.substr(e.length-r.length)===r:!!r}}(i[4],i[5],i[6])),r(function(i){var e;if(i)return(i=/(?:not\((.+)\))|(.+)/i.exec(i))[1]?(e=a(i[1],[]),function(t){return!o(t,e)}):(i=i[2],function(t,e,n){return"first"===i?0===e:"last"===i?e===n-1:"even"===i?e%2==0:"odd"===i?e%2==1:!!t[i]&&t[i]()})}(i[7])),e.pseudo=!!i[7],e.direct=n,e}function a(t,e){var n,i,r,o=[];do{if(It.exec(""),(i=It.exec(t))&&(t=i[3],o.push(i[1]),i[2])){n=i[3];break}}while(i);for(n&&a(n,e),t=[],r=0;r"!==o[r]&&t.push(s(o[r],[],">"===o[r-1]));return e.push(t),e}this._selectors=a(t,[])},match:function(t,e){var n,i,r,o,s,a,l,u,c,d,f,h,m;for(n=0,i=(e=e||this._selectors).length;na.maxW?a.maxW:n,a.w=n,a.innerW=n-i),(n=t.h)!==undefined&&(n=(n=na.maxH?a.maxH:n,a.h=n,a.innerH=n-r),(n=t.innerW)!==undefined&&(n=(n=na.maxW-i?a.maxW-i:n,a.innerW=n,a.w=n+i),(n=t.innerH)!==undefined&&(n=(n=na.maxH-r?a.maxH-r:n,a.innerH=n,a.h=n+r),t.contentW!==undefined&&(a.contentW=t.contentW),t.contentH!==undefined&&(a.contentH=t.contentH),(e=s._lastLayoutRect).x===a.x&&e.y===a.y&&e.w===a.w&&e.h===a.h||((o=Jt.repaintControls)&&o.map&&!o.map[s._id]&&(o.push(s),o.map[s._id]=!0),e.x=a.x,e.y=a.y,e.w=a.w,e.h=a.h),s):a},repaint:function(){var t,e,n,i,r,o,s,a,l,u,c=this;l=_.document.createRange?function(t){return t}:Math.round,t=c.getEl().style,i=c._layoutRect,a=c._lastRepaintRect||{},o=(r=c.borderBox).left+r.right,s=r.top+r.bottom,i.x!==a.x&&(t.left=l(i.x)+"px",a.x=i.x),i.y!==a.y&&(t.top=l(i.y)+"px",a.y=i.y),i.w!==a.w&&(u=l(i.w-o),t.width=(0<=u?u:0)+"px",a.w=i.w),i.h!==a.h&&(u=l(i.h-s),t.height=(0<=u?u:0)+"px",a.h=i.h),c._hasBody&&i.innerW!==a.innerW&&(u=l(i.innerW),(n=c.getEl("body"))&&((e=n.style).width=(0<=u?u:0)+"px"),a.innerW=i.innerW),c._hasBody&&i.innerH!==a.innerH&&(u=l(i.innerH),(n=n||c.getEl("body"))&&((e=e||n.style).height=(0<=u?u:0)+"px"),a.innerH=i.innerH),c._lastRepaintRect=a,c.fire("repaint",{},!1)},updateLayoutRect:function(){var t=this;t.parent()._lastRect=null,Ht.css(t.getEl(),{width:"",height:""}),t._layoutRect=t._lastRepaintRect=t._lastLayoutRect=null,t.initLayoutRect()},on:function(t,e){var n,i,r,o=this;return oe(o).on(t,"string"!=typeof(n=e)?n:function(t){return i||o.parentsAndSelf().each(function(t){var e=t.settings.callbacks;if(e&&(i=e[n]))return r=t,!1}),i?i.call(r,t):(t.action=n,void this.fire("execute",t))}),o},off:function(t,e){return oe(this).off(t,e),this},fire:function(t,e,n){if((e=e||{}).control||(e.control=this),e=oe(this).fire(t,e),!1!==n&&this.parent)for(var i=this.parent();i&&!e.isPropagationStopped();)i.fire(t,e,!1),i=i.parent();return e},hasEventListeners:function(t){return oe(this).has(t)},parents:function(t){var e,n=new qt;for(e=this.parent();e;e=e.parent())n.add(e);return t&&(n=n.filter(t)),n},parentsAndSelf:function(t){return new qt(this).add(this.parents(t))},next:function(){var t=this.parent().items();return t[t.indexOf(this)+1]},prev:function(){var t=this.parent().items();return t[t.indexOf(this)-1]},innerHtml:function(t){return this.$el.html(t),this},getEl:function(t){var e=t?this._id+"-"+t:this._id;return this._elmCache[e]||(this._elmCache[e]=Tt("#"+e)[0]),this._elmCache[e]},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(t){}return this},blur:function(){return this.getEl().blur(),this},aria:function(t,e){var n=this,i=n.getEl(n.ariaTarget);return void 0===e?n._aria[t]:(n._aria[t]=e,n.state.get("rendered")&&i.setAttribute("role"===t?t:"aria-"+t,e),n)},encode:function(t,e){return!1!==e&&(t=this.translate(t)),(t||"").replace(/[&<>"]/g,function(t){return""+t.charCodeAt(0)+";"})},translate:function(t){return Jt.translate?Jt.translate(t):t},before:function(t){var e=this.parent();return e&&e.insert(t,e.items().indexOf(this),!0),this},after:function(t){var e=this.parent();return e&&e.insert(t,e.items().indexOf(this)),this},remove:function(){var e,t,n=this,i=n.getEl(),r=n.parent();if(n.items){var o=n.items().toArray();for(t=o.length;t--;)o[t].remove()}r&&r.items&&(e=[],r.items().each(function(t){t!==n&&e.push(t)}),r.items().set(e),r._lastRect=null),n._eventsRoot&&n._eventsRoot===n&&Tt(i).off();var s=n.getRoot().controlIdLookup;return s&&delete s[n._id],i&&i.parentNode&&i.parentNode.removeChild(i),n.state.set("rendered",!1),n.state.destroy(),n.fire("remove"),n},renderBefore:function(t){return Tt(t).before(this.renderHtml()),this.postRender(),this},renderTo:function(t){return Tt(t||this.getContainerElm()).append(this.renderHtml()),this.postRender(),this},preRender:function(){},render:function(){},renderHtml:function(){return'
'},postRender:function(){var t,e,n,i,r,o=this,s=o.settings;for(i in o.$el=Tt(o.getEl()),o.state.set("rendered",!0),s)0===i.indexOf("on")&&o.on(i.substr(2),s[i]);if(o._eventsRoot){for(n=o.parent();!r&&n;n=n.parent())r=n._eventsRoot;if(r)for(i in r._nativeEvents)o._nativeEvents[i]=!0}se(o),s.style&&(t=o.getEl())&&(t.setAttribute("style",s.style),t.style.cssText=s.style),o.settings.border&&(e=o.borderBox,o.$el.css({"border-top-width":e.top,"border-right-width":e.right,"border-bottom-width":e.bottom,"border-left-width":e.left}));var a=o.getRoot();for(var l in a.controlIdLookup||(a.controlIdLookup={}),(a.controlIdLookup[o._id]=o)._aria)o.aria(l,o._aria[l]);!1===o.state.get("visible")&&(o.getEl().style.display="none"),o.bindStates(),o.state.on("change:visible",function(t){var e,n=t.value;o.state.get("rendered")&&(o.getEl().style.display=!1===n?"none":"",o.getEl().getBoundingClientRect()),(e=o.parent())&&(e._lastRect=null),o.fire(n?"show":"hide"),Zt.add(o)}),o.fire("postrender",{},!1)},bindStates:function(){},scrollIntoView:function(t){var e,n,i,r,o,s,a=this.getEl(),l=a.parentNode,u=function(t,e){var n,i,r=t;for(n=i=0;r&&r!==e&&r.nodeType;)n+=r.offsetLeft||0,i+=r.offsetTop||0,r=r.offsetParent;return{x:n,y:i}}(a,l);return e=u.x,n=u.y,i=a.offsetWidth,r=a.offsetHeight,o=l.clientWidth,s=l.clientHeight,"end"===t?(e-=o-i,n-=s-r):"center"===t&&(e-=o/2-i/2,n-=s/2-r/2),l.scrollLeft=e,l.scrollTop=n,this},getRoot:function(){for(var t,e=this,n=[];e;){if(e.rootControl){t=e.rootControl;break}n.push(e),e=(t=e).parent()}t||(t=this);for(var i=n.length;i--;)n[i].rootControl=t;return t},reflow:function(){Zt.remove(this);var t=this.parent();return t&&t._layout&&!t._layout.isNative()&&t.reflow(),this}};function oe(n){return n._eventDispatcher||(n._eventDispatcher=new Mt({scope:n,toggleEvent:function(t,e){e&&Mt.isNative(t)&&(n._nativeEvents||(n._nativeEvents={}),n._nativeEvents[t]=!0,n.state.get("rendered")&&se(n))}})),n._eventDispatcher}function se(a){var t,e,n,l,i,r;function o(t){var e=a.getParentCtrl(t.target);e&&e.fire(t.type,t)}function s(){var t=l._lastHoverCtrl;t&&(t.fire("mouseleave",{target:t.getEl()}),t.parents().each(function(t){t.fire("mouseleave",{target:t.getEl()})}),l._lastHoverCtrl=null)}function u(t){var e,n,i,r=a.getParentCtrl(t.target),o=l._lastHoverCtrl,s=0;if(r!==o){if((n=(l._lastHoverCtrl=r).parents().toArray().reverse()).push(r),o){for((i=o.parents().toArray().reverse()).push(o),s=0;sn.x&&r.x+r.wn.y&&r.y+r.h
'+t.encode(t.state.get("text"))+"
"},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.getEl().lastChild.innerHTML=e.encode(t.value)}),e._super()},repaint:function(){var t,e;t=this.getEl().style,e=this._layoutRect,t.left=e.x+"px",t.top=e.y+"px",t.zIndex=131070}}),ge=ae.extend({init:function(i){var r=this;r._super(i),i=r.settings,r.canFocus=!0,i.tooltip&&!1!==ge.tooltips&&(r.on("mouseenter",function(t){var e=r.tooltip().moveTo(-65535);if(t.control===r){var n=e.text(i.tooltip).show().testMoveRel(r.getEl(),["bc-tc","bc-tl","bc-tr"]);e.classes.toggle("tooltip-n","bc-tc"===n),e.classes.toggle("tooltip-nw","bc-tl"===n),e.classes.toggle("tooltip-ne","bc-tr"===n),e.moveRel(r.getEl(),n)}else e.hide()}),r.on("mouseleave mousedown click",function(){r.tooltip().remove(),r._tooltip=null})),r.aria("label",i.ariaLabel||i.tooltip)},tooltip:function(){return this._tooltip||(this._tooltip=new me({type:"tooltip"}),te.inheritUiContainer(this,this._tooltip),this._tooltip.renderTo()),this._tooltip},postRender:function(){var t=this,e=t.settings;t._super(),t.parent()||!e.width&&!e.height||(t.initLayoutRect(),t.repaint()),e.autofocus&&t.focus()},bindStates:function(){var e=this;function n(t){e.aria("disabled",t),e.classes.toggle("disabled",t)}function i(t){e.aria("pressed",t),e.classes.toggle("active",t)}return e.state.on("change:disabled",function(t){n(t.value)}),e.state.on("change:active",function(t){i(t.value)}),e.state.get("disabled")&&n(!0),e.state.get("active")&&i(!0),e._super()},remove:function(){this._super(),this._tooltip&&(this._tooltip.remove(),this._tooltip=null)}}),pe=ge.extend({Defaults:{value:0},init:function(t){this._super(t),this.classes.add("progress"),this.settings.filter||(this.settings.filter=function(t){return Math.round(t)})},renderHtml:function(){var t=this._id,e=this.classPrefix;return''},postRender:function(){return this._super(),this.value(this.settings.value),this},bindStates:function(){var e=this;function n(t){t=e.settings.filter(t),e.getEl().lastChild.innerHTML=t+"%",e.getEl().firstChild.firstChild.style.width=t+"%"}return e.state.on("change:value",function(t){n(t.value)}),n(e.state.get("value")),e._super()}}),ve=function(t,e){t.getEl().lastChild.textContent=e+(t.progressBar?" "+t.progressBar.value()+"%":"")},be=ae.extend({Mixins:[he],Defaults:{classes:"widget notification"},init:function(t){var e=this;e._super(t),e.maxWidth=t.maxWidth,t.text&&e.text(t.text),t.icon&&(e.icon=t.icon),t.color&&(e.color=t.color),t.type&&e.classes.add("notification-"+t.type),t.timeout&&(t.timeout<0||0 '),t=' style="max-width: '+e.maxWidth+"px;"+(e.color?"background-color: "+e.color+';"':'"'),e.closeButton&&(r='\xd7 '),e.progressBar&&(o=e.progressBar.renderHtml()),''+i+'
'+e.state.get("text")+"
"+o+r+'
'},postRender:function(){var t=this;return c.setTimeout(function(){t.$el.addClass(t.classPrefix+"in"),ve(t,t.state.get("text"))},100),t._super()},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.getEl().firstChild.innerHTML=t.value,ve(e,t.value)}),e.progressBar&&(e.progressBar.bindStates(),e.progressBar.state.on("change:value",function(t){ve(e,e.state.get("text"))})),e._super()},close:function(){return this.fire("close").isDefaultPrevented()||this.remove(),this},repaint:function(){var t,e;t=this.getEl().style,e=this._layoutRect,t.left=e.x+"px",t.top=e.y+"px",t.zIndex=65534}});function ye(o){var s=function(t){return t.inline?t.getElement():t.getContentAreaContainer()};return{open:function(t,e){var n,i=R.extend(t,{maxWidth:(n=s(o),Ht.getSize(n).width)}),r=new be(i);return 0<(r.args=i).timeout&&(r.timer=setTimeout(function(){r.close(),e()},i.timeout)),r.on("close",function(){e()}),r.renderTo(),r},close:function(t){t.close()},reposition:function(t){Ct(t,function(t){t.moveTo(0,0)}),function(n){if(0").css({position:"absolute",top:0,left:0,width:f.width,height:f.height,zIndex:2147483647,opacity:1e-4,cursor:d}).appendTo(x.body),Tt(x).on("mousemove touchmove",v).on("mouseup touchend",p),h.start(t)},v=function(t){if(xe(t),t.button!==g)return p(t);t.deltaX=t.screenX-b,t.deltaY=t.screenY-y,t.preventDefault(),h.drag(t)},p=function(t){xe(t),Tt(x).off("mousemove touchmove",v).off("mouseup touchend",p),m.remove(),h.stop&&h.stop(t)},this.destroy=function(){Tt(w).off()},Tt(w).on("mousedown touchstart",e)}var _e=tinymce.util.Tools.resolve("tinymce.ui.Factory"),Re=function(t){return!!t.getAttribute("data-mce-tabstop")};function Ce(t){var o,r,n=t.root;function i(t){return t&&1===t.nodeType}try{o=_.document.activeElement}catch(e){o=_.document.body}function s(t){return i(t=t||o)?t.getAttribute("role"):null}function a(t){for(var e,n=t||o;n=n.parentNode;)if(e=s(n))return e}function l(t){var e=o;if(i(e))return e.getAttribute("aria-"+t)}function u(t){var e=t.tagName.toUpperCase();return"INPUT"===e||"TEXTAREA"===e||"SELECT"===e}function c(e){var r=[];return function t(e){if(1===e.nodeType&&"none"!==e.style.display&&!e.disabled){var n;(u(n=e)&&!n.hidden||Re(n)||/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(s(n)))&&r.push(e);for(var i=0;i=e.length&&(t=0),e[t]&&e[t].focus(),t}function h(t,e){var n=-1,i=d();e=e||c(i.getEl());for(var r=0;r'+(t.settings.html||"")+e.renderHtml(t)+"
"},postRender:function(){var t,e=this;return e.items().exec("postRender"),e._super(),e._layout.postRender(e),e.state.set("rendered",!0),e.settings.style&&e.$el.css(e.settings.style),e.settings.border&&(t=e.borderBox,e.$el.css({"border-top-width":t.top,"border-right-width":t.right,"border-bottom-width":t.bottom,"border-left-width":t.left})),e.parent()||(e.keyboardNav=Ce({root:e})),e},initLayoutRect:function(){var t=this._super();return this._layout.recalc(this),t},recalc:function(){var t=this,e=t._layoutRect,n=t._lastRect;if(!n||n.w!==e.w||n.h!==e.h)return t._layout.recalc(t),e=t.layoutRect(),t._lastRect={x:e.x,y:e.y,w:e.w,h:e.h},!0},reflow:function(){var t;if(Zt.remove(this),this.visible()){for(ae.repaintControls=[],ae.repaintControls.map={},this.recalc(),t=ae.repaintControls.length;t--;)ae.repaintControls[t].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),ae.repaintControls=[]}return this}}),Ne={init:function(){this.on("repaint",this.renderScroll)},renderScroll:function(){var p=this,v=2;function n(){var m,g,t;function e(t,e,n,i,r,o){var s,a,l,u,c,d,f,h;if(a=p.getEl("scroll"+t)){if(f=e.toLowerCase(),h=n.toLowerCase(),Tt(p.getEl("absend")).css(f,p.layoutRect()[i]-1),!r)return void Tt(a).css("display","none");Tt(a).css("display","block"),s=p.getEl("body"),l=p.getEl("scroll"+t+"t"),u=s["client"+n]-2*v,c=(u-=m&&g?a["client"+o]:0)/s["scroll"+n],(d={})[f]=s["offset"+e]+v,d[h]=u,Tt(a).css(d),(d={})[f]=s["scroll"+e]*c,d[h]=u*c,Tt(l).css(d)}}t=p.getEl("body"),m=t.scrollWidth>t.clientWidth,g=t.scrollHeight>t.clientHeight,e("h","Left","Width","contentW",m,"Height"),e("v","Top","Height","contentH",g,"Width")}p.settings.autoScroll&&(p._hasScroll||(p._hasScroll=!0,function(){function t(s,a,l,u,c){var d,t=p._id+"-scroll"+s,e=p.classPrefix;Tt(p.getEl()).append(''),p.draghelper=new we(t+"t",{start:function(){d=p.getEl("body")["scroll"+a],Tt("#"+t).addClass(e+"active")},drag:function(t){var e,n,i,r,o=p.layoutRect();n=o.contentW>o.innerW,i=o.contentH>o.innerH,r=p.getEl("body")["client"+l]-2*v,e=(r-=n&&i?p.getEl("scroll"+s)["client"+c]:0)/p.getEl("body")["scroll"+l],p.getEl("body")["scroll"+a]=d+t["delta"+u]/e},stop:function(){Tt("#"+t).removeClass(e+"active")}})}p.classes.add("scroll"),t("v","Top","Height","Y","Width"),t("h","Left","Width","X","Height")}(),p.on("wheel",function(t){var e=p.getEl("body");e.scrollLeft+=10*(t.deltaX||0),e.scrollTop+=10*t.deltaY,n()}),Tt(p.getEl("body")).on("scroll",n)),n())}},Oe=Me.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[Ne],renderHtml:function(){var t=this,e=t._layout,n=t.settings.html;return t.preRender(),e.preRender(t),void 0===n?n=''+e.renderHtml(t)+"
":("function"==typeof n&&(n=n.call(t)),t._hasBody=!1),''+(t._preBodyHtml||"")+n+"
"}}),We={resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(t,e){if(t<=1||e<=1){var n=Ht.getWindowSize();t=t<=1?t*n.w:t,e=e<=1?e*n.h:e}return this._layoutRect.autoResize=!1,this.layoutRect({minW:t,minH:e,w:t,h:e}).reflow()},resizeBy:function(t,e){var n=this.layoutRect();return this.resizeTo(n.w+t,n.h+e)}},Pe=[],De=[];function Ae(t,e){for(;t;){if(t===e)return!0;t=t.parent()}}function Be(){ke||(ke=function(t){2!==t.button&&function(t){for(var e=Pe.length;e--;){var n=Pe[e],i=n.getParentCtrl(t.target);if(n.settings.autohide){if(i&&(Ae(i,n)||n.parent()===i))continue;(t=n.fire("autohide",{target:t.target})).isDefaultPrevented()||n.hide()}}}(t)},Tt(_.document).on("click touchstart",ke))}function Le(r){var t=Ht.getViewPort().y;function e(t,e){for(var n,i=0;it&&(r.fixed(!1).layoutRect({y:r._autoFixY}).repaint(),e(!1,r._autoFixY-t)):(r._autoFixY=r.layoutRect().y,r._autoFixY').appendTo(i.getContainerElm())),c.setTimeout(function(){e.addClass(n+"in"),Tt(i.getEl()).addClass(n+"in")}),Te=!0),Ie(!0,i)}}),i.on("show",function(){i.parents().each(function(t){if(t.state.get("fixed"))return i.fixed(!0),!1})}),t.popover&&(i._preBodyHtml='
',i.classes.add("popover").add("bottom").add(i.isRtl()?"end":"start")),i.aria("label",t.ariaLabel),i.aria("labelledby",i._id),i.aria("describedby",i.describedBy||i._id+"-none")},fixed:function(t){var e=this;if(e.state.get("fixed")!==t){if(e.state.get("rendered")){var n=Ht.getViewPort();t?e.layoutRect().y-=n.y:e.layoutRect().y+=n.y}e.classes.toggle("fixed",t),e.state.set("fixed",t)}return e},show:function(){var t,e=this._super();for(t=Pe.length;t--&&Pe[t]!==this;);return-1===t&&Pe.push(this),e},hide:function(){return Fe(this),Ie(!1,this),this._super()},hideAll:function(){ze.hideAll()},close:function(){return this.fire("close").isDefaultPrevented()||(this.remove(),Ie(!1,this)),this},remove:function(){Fe(this),this._super()},postRender:function(){return this.settings.bodyRole&&this.getEl("body").setAttribute("role",this.settings.bodyRole),this._super()}});function Fe(t){var e;for(e=Pe.length;e--;)Pe[e]===t&&Pe.splice(e,1);for(e=De.length;e--;)De[e]===t&&De.splice(e,1)}ze.hideAll=function(){for(var t=Pe.length;t--;){var e=Pe[t];e&&e.settings.autohide&&(e.hide(),Pe.splice(t,1))}};var Ue=[],Ve="";function qe(t){var e,n=Tt("meta[name=viewport]")[0];!1!==h.overrideViewPort&&(n||((n=_.document.createElement("meta")).setAttribute("name","viewport"),_.document.getElementsByTagName("head")[0].appendChild(n)),(e=n.getAttribute("content"))&&void 0!==Ve&&(Ve=e),n.setAttribute("content",t?"width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0":Ve))}function Ye(t,e){(function(){for(var t=0;tt.w&&(n=t.x-Math.max(0,e/2),r.layoutRect({w:e,x:n}),i=!0),o&&(o.layoutRect({w:r.layoutRect().innerW}).recalc(),(e=o.layoutRect().minW+t.deltaW)>t.w&&(n=t.x-Math.max(0,e-t.w),r.layoutRect({w:e,x:n}),i=!0)),i&&r.recalc()},initLayoutRect:function(){var t,e=this,n=e._super(),i=0;if(e.settings.title&&!e._fullscreen){t=e.getEl("head");var r=Ht.getSize(t);n.headerW=r.width,n.headerH=r.height,i+=n.headerH}e.statusbar&&(i+=e.statusbar.layoutRect().h),n.deltaH+=i,n.minH+=i,n.h+=i;var o=Ht.getWindowSize();return n.x=e.settings.x||Math.max(0,o.w/2-n.w/2),n.y=e.settings.y||Math.max(0,o.h/2-n.h/2),n},renderHtml:function(){var t=this,e=t._layout,n=t._id,i=t.classPrefix,r=t.settings,o="",s="",a=r.html;return t.preRender(),e.preRender(t),r.title&&(o=''),r.url&&(a=''),void 0===a&&(a=e.renderHtml(t)),t.statusbar&&(s=t.statusbar.renderHtml()),'"},fullscreen:function(t){var n,e,i=this,r=_.document.documentElement,o=i.classPrefix;if(t!==i._fullscreen)if(Tt(_.window).on("resize",function(){var t;if(i._fullscreen)if(n)i._timer||(i._timer=c.setTimeout(function(){var t=Ht.getWindowSize();i.moveTo(0,0).resizeTo(t.w,t.h),i._timer=0},50));else{t=(new Date).getTime();var e=Ht.getWindowSize();i.moveTo(0,0).resizeTo(e.w,e.h),50<(new Date).getTime()-t&&(n=!0)}}),e=i.layoutRect(),i._fullscreen=t){i._initial={x:e.x,y:e.y,w:e.w,h:e.h},i.borderBox=Nt("0"),i.getEl("head").style.display="none",e.deltaH-=e.headerH+2,Tt([r,_.document.body]).addClass(o+"fullscreen"),i.classes.add("fullscreen");var s=Ht.getWindowSize();i.moveTo(0,0).resizeTo(s.w,s.h)}else i.borderBox=Nt(i.settings.border),i.getEl("head").style.display="",e.deltaH+=e.headerH,Tt([r,_.document.body]).removeClass(o+"fullscreen"),i.classes.remove("fullscreen"),i.moveTo(i._initial.x,i._initial.y).resizeTo(i._initial.w,i._initial.h);return i.reflow()},postRender:function(){var e,n=this;setTimeout(function(){n.classes.add("in"),n.fire("open")},0),n._super(),n.statusbar&&n.statusbar.postRender(),n.focus(),this.dragHelper=new we(n._id+"-dragh",{start:function(){e={x:n.layoutRect().x,y:n.layoutRect().y}},drag:function(t){n.moveTo(e.x+t.deltaX,e.y+t.deltaY)}}),n.on("submit",function(t){t.isDefaultPrevented()||n.close()}),Ue.push(n),qe(!0)},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var t,e=this;for(e.dragHelper.destroy(),e._super(),e.statusbar&&this.statusbar.remove(),Ye(e.classPrefix,!1),t=Ue.length;t--;)Ue[t]===e&&Ue.splice(t,1);qe(0',r+="",i=0;i",n=0;n ";r+=""}return r+=" ",r+=""}(r,o)),(t=i.dom.select("*[data-mce-id]")[0]).removeAttribute("data-mce-id"),e=i.dom.select("td,th",t),i.selection.setCursorLocation(e[0],0)}))},bn=function(t,e){t.execCommand("FormatBlock",!1,e)},yn=function(t,e,n){var i,r;r=(i=t.editorUpload.blobCache).create(sn("mceu"),n,e),i.add(r),t.insertContent(t.dom.createHTML("img",{src:r.blobUri()}))},xn=function(t,e){0===e.trim().length?gn(t):pn(t,e)},wn=gn,_n=function(n,t){n.addButton("quicklink",{icon:"link",tooltip:"Insert/Edit link",stateSelector:"a[href]",onclick:function(){t.showForm(n,"quicklink")}}),n.addButton("quickimage",{icon:"image",tooltip:"Insert image",onclick:function(){rn().then(function(t){var e=t[0];nn(e).then(function(t){yn(n,t,e)})})}}),n.addButton("quicktable",{icon:"table",tooltip:"Insert table",onclick:function(){t.hide(),vn(n,2,2)}}),function(e){for(var t=function(t){return function(){bn(e,t)}},n=1;n<6;n++){var i="h"+n;e.addButton(i,{text:i.toUpperCase(),tooltip:"Heading "+n,stateSelector:i,onclick:t(i),onPostRender:function(){this.getEl().firstChild.firstChild.style.fontWeight="bold"}})}}(n)},Rn=function(){var t=h.container;if(t&&"static"!==v.DOM.getStyle(t,"position",!0)){var e=v.DOM.getPos(t),n=e.x-t.scrollLeft,i=e.y-t.scrollTop;return mt.some({x:n,y:i})}return mt.none()},Cn=function(t){return/^www\.|\.(com|org|edu|gov|uk|net|ca|de|jp|fr|au|us|ru|ch|it|nl|se|no|es|mil)$/i.test(t.trim())},kn=function(t){return/^https?:\/\//.test(t.trim())},En=function(t,e){return!kn(e)&&Cn(e)?(n=t,i=e,new en(function(e){n.windowManager.confirm("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){e(!0===t?"http://"+i:i)})})):en.resolve(e);var n,i},Hn=function(r,e){var t,n,i,o={};return t="quicklink",n={items:[{type:"button",name:"unlink",icon:"unlink",onclick:function(){r.focus(),wn(r),e()},tooltip:"Remove link"},{type:"filepicker",name:"linkurl",placeholder:"Paste or type a link",filetype:"file",onchange:function(t){var e=t.meta;e&&e.attach&&(o={href:this.value(),attach:e.attach})}},{type:"button",icon:"checkmark",subtype:"primary",tooltip:"Ok",onclick:"submit"}],onshow:function(t){if(t.control===this){var e,n="";(e=r.dom.getParent(r.selection.getStart(),"a[href]"))&&(n=r.dom.getAttrib(e,"href")),this.fromJSON({linkurl:n}),i=this.find("#unlink"),e?i.show():i.hide(),this.find("#linkurl")[0].focus()}var i},onsubmit:function(t){En(r,t.data.linkurl).then(function(t){r.undoManager.transact(function(){t===o.href&&(o.attach(),o={}),xn(r,t)}),e()})}},(i=_e.create(R.extend({type:"form",layout:"flex",direction:"row",padding:5,name:t,spacing:3},n))).on("show",function(){i.find("textbox").eq(0).each(function(t){t.focus()})}),i},Tn=function(n,t,e){var o,i,s=[];if(e)return R.each(B(i=e)?i:W(i)?i.split(/[ ,]/):[],function(t){if("|"===t)o=null;else if(n.buttons[t]){o||(o={type:"buttongroup",items:[]},s.push(o));var e=n.buttons[t];A(e)&&(e=e()),e.type=e.type||"button",(e=_e.create(e)).on("postRender",(i=n,r=e,function(){var e,t,n=(t=function(t,e){return{selector:t,handler:e}},(e=r).settings.stateSelector?t(e.settings.stateSelector,function(t){e.active(t)}):e.settings.disabledStateSelector?t(e.settings.disabledStateSelector,function(t){e.disabled(t)}):null);null!==n&&i.selection.selectorChanged(n.selector,n.handler)})),o.items.push(e)}var i,r}),_e.create({type:"toolbar",layout:"flow",name:t,items:s})},Sn=function(){var l,c,o=function(t){return 0'+this._super(t)}}),On=ge.extend({Defaults:{classes:"widget btn",role:"button"},init:function(t){var e,n=this;n._super(t),t=n.settings,e=n.settings.size,n.on("click mousedown",function(t){t.preventDefault()}),n.on("touchstart",function(t){n.fire("click",t),t.preventDefault()}),t.subtype&&n.classes.add(t.subtype),e&&n.classes.add("btn-"+e),t.icon&&n.icon(t.icon)},icon:function(t){return arguments.length?(this.state.set("icon",t),this):this.state.get("icon")},repaint:function(){var t,e=this.getEl().firstChild;e&&((t=e.style).width=t.height="100%"),this._super()},renderHtml:function(){var t,e,n=this,i=n._id,r=n.classPrefix,o=n.state.get("icon"),s=n.state.get("text"),a="",l=n.settings;return(t=l.image)?(o="none","string"!=typeof t&&(t=_.window.getSelection?t[0]:t[1]),t=" style=\"background-image: url('"+t+"')\""):t="",s&&(n.classes.add("btn-has-text"),a=''+n.encode(s)+" "),o=o?r+"ico "+r+"i-"+o:"",e="boolean"==typeof l.active?' aria-pressed="'+l.active+'"':"",''+(o?' ":"")+a+"
"},bindStates:function(){var o=this,n=o.$,i=o.classPrefix+"txt";function s(t){var e=n("span."+i,o.getEl());t?(e[0]||(n("button:first",o.getEl()).append(' '),e=n("span."+i,o.getEl())),e.html(o.encode(t))):e.remove(),o.classes.toggle("btn-has-text",!!t)}return o.state.on("change:text",function(t){s(t.value)}),o.state.on("change:icon",function(t){var e=t.value,n=o.classPrefix;e=(o.settings.icon=e)?n+"ico "+n+"i-"+o.settings.icon:"";var i=o.getEl().firstChild,r=i.getElementsByTagName("i")[0];e?(r&&r===i.firstChild||(r=_.document.createElement("i"),i.insertBefore(r,i.firstChild)),r.className=e):r&&i.removeChild(r),s(o.state.get("text"))}),o._super()}}),Wn=On.extend({init:function(t){t=R.extend({text:"Browse...",multiple:!1,accept:null},t),this._super(t),this.classes.add("browsebutton"),t.multiple&&this.classes.add("multiple")},postRender:function(){var n=this,e=Ht.create("input",{type:"file",id:n._id+"-browse",accept:n.settings.accept});n._super(),Tt(e).on("change",function(t){var e=t.target.files;n.value=function(){return e.length?n.settings.multiple?e:e[0]:null},t.preventDefault(),e.length&&n.fire("change",t)}),Tt(e).on("click",function(t){t.stopPropagation()}),Tt(n.getEl("button")).on("click touchstart",function(t){t.stopPropagation(),e.click(),t.preventDefault()}),n.getEl().appendChild(e)},remove:function(){Tt(this.getEl("button")).off(),Tt(this.getEl("input")).off(),this._super()}}),Pn=Me.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var t=this,e=t._layout;return t.classes.add("btn-group"),t.preRender(),e.preRender(t),''+(t.settings.html||"")+e.renderHtml(t)+"
"}}),Dn=ge.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(t){var e=this;e._super(t),e.on("click mousedown",function(t){t.preventDefault()}),e.on("click",function(t){t.preventDefault(),e.disabled()||e.checked(!e.checked())}),e.checked(e.settings.checked)},checked:function(t){return arguments.length?(this.state.set("checked",t),this):this.state.get("checked")},value:function(t){return arguments.length?this.checked(t):this.checked()},renderHtml:function(){var t=this,e=t._id,n=t.classPrefix;return''+t.encode(t.state.get("text"))+"
"},bindStates:function(){var o=this;function e(t){o.classes.toggle("checked",t),o.aria("checked",t)}return o.state.on("change:text",function(t){o.getEl("al").firstChild.data=o.translate(t.value)}),o.state.on("change:checked change:value",function(t){o.fire("change"),e(t.value)}),o.state.on("change:icon",function(t){var e=t.value,n=o.classPrefix;if(void 0===e)return o.settings.icon;e=(o.settings.icon=e)?n+"ico "+n+"i-"+o.settings.icon:"";var i=o.getEl().firstChild,r=i.getElementsByTagName("i")[0];e?(r&&r===i.firstChild||(r=_.document.createElement("i"),i.insertBefore(r,i.firstChild)),r.className=e):r&&i.removeChild(r)}),o.state.get("checked")&&e(!0),o._super()}}),An=tinymce.util.Tools.resolve("tinymce.util.VK"),Bn=ge.extend({init:function(i){var r=this;r._super(i),i=r.settings,r.classes.add("combobox"),r.subinput=!0,r.ariaTarget="inp",i.menu=i.menu||i.values,i.menu&&(i.icon="caret"),r.on("click",function(t){var e=t.target,n=r.getEl();if(Tt.contains(n,e)||e===n)for(;e&&e!==n;)e.id&&-1!==e.id.indexOf("-open")&&(r.fire("action"),i.menu&&(r.showMenu(),t.aria&&r.menu.items()[0].focus())),e=e.parentNode}),r.on("keydown",function(t){var e;13===t.keyCode&&"INPUT"===t.target.nodeName&&(t.preventDefault(),r.parents().reverse().each(function(t){if(t.toJSON)return e=t,!1}),r.fire("submit",{data:e.toJSON()}))}),r.on("keyup",function(t){if("INPUT"===t.target.nodeName){var e=r.state.get("value"),n=t.target.value;n!==e&&(r.state.set("value",n),r.fire("autocomplete",t))}}),r.on("mouseover",function(t){var e=r.tooltip().moveTo(-65535);if(r.statusLevel()&&-1!==t.target.className.indexOf(r.classPrefix+"status")){var n=r.statusMessage()||"Ok",i=e.text(n).show().testMoveRel(t.target,["bc-tc","bc-tl","bc-tr"]);e.classes.toggle("tooltip-n","bc-tc"===i),e.classes.toggle("tooltip-nw","bc-tl"===i),e.classes.toggle("tooltip-ne","bc-tr"===i),e.moveRel(t.target,i)}})},statusLevel:function(t){return 0',i.disabled()&&(u+=' disabled="disabled"'),(t=o.icon)&&"caret"!==t&&(t=s+"ico "+s+"i-"+o.icon),e=i.state.get("text"),(t||e)&&(l=''+("caret"!==t?' ':' ')+(e?(t?" ":"")+e:"")+"
",i.classes.add("has-open")),' '+n+l+"
"},value:function(t){return arguments.length?(this.state.set("value",t),this):(this.state.get("rendered")&&this.state.set("value",this.getEl("inp").value),this.state.get("value"))},showAutoComplete:function(t,i){var r=this;if(0!==t.length){r.menu?r.menu.items().remove():r.menu=_e.create({type:"menu",classes:"combobox-menu",layout:"flow"}).parent(r).renderTo(),R.each(t,function(t){var e,n;r.menu.add({text:t.title,url:t.previewUrl,match:i,classes:"menu-item-ellipsis",onclick:(e=t.value,n=t.title,function(){r.fire("selectitem",{title:n,value:e})})})}),r.menu.renderNew(),r.hideMenu(),r.menu.on("cancel",function(t){t.control.parent()===r.menu&&(t.stopPropagation(),r.focus(),r.hideMenu())}),r.menu.on("select",function(){r.focus()});var e=r.layoutRect().w;r.menu.layoutRect({w:e,minW:0,maxW:e}),r.menu.repaint(),r.menu.reflow(),r.menu.show(),r.menu.moveRel(r.getEl(),r.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])}else r.hideMenu()},hideMenu:function(){this.menu&&this.menu.hide()},bindStates:function(){var r=this;r.state.on("change:value",function(t){r.getEl("inp").value!==t.value&&(r.getEl("inp").value=t.value)}),r.state.on("change:disabled",function(t){r.getEl("inp").disabled=t.value}),r.state.on("change:statusLevel",function(t){var e=r.getEl("status"),n=r.classPrefix,i=t.value;Ht.css(e,"display","none"===i?"none":""),Ht.toggleClass(e,n+"i-checkmark","ok"===i),Ht.toggleClass(e,n+"i-warning","warn"===i),Ht.toggleClass(e,n+"i-error","error"===i),r.classes.toggle("has-status","none"!==i),r.repaint()}),Ht.on(r.getEl("status"),"mouseleave",function(){r.tooltip().hide()}),r.on("cancel",function(t){r.menu&&r.menu.visible()&&(t.stopPropagation(),r.hideMenu())});var n=function(t,e){e&&0'+t.encode(i)+""),''+(r?' ":"")+' '+s+'
'},postRender:function(){var e=this,n=e.settings.onclick;return e.on("click",function(t){t.aria&&"down"===t.aria.key||t.control!==e||zn.getParent(t.target,"."+e.classPrefix+"open")||(t.stopImmediatePropagation(),n.call(e,t))}),delete e.settings.onclick,e._super()}}),Un=tinymce.util.Tools.resolve("tinymce.util.Color"),Vn=ge.extend({Defaults:{classes:"widget colorpicker"},init:function(t){this._super(t)},postRender:function(){var n,i,r,o,s,a=this,l=a.color();function u(t,e){var n,i,r=Ht.getPos(t);return n=e.pageX-r.x,i=e.pageY-r.y,{x:n=Math.max(0,Math.min(n/t.clientWidth,1)),y:i=Math.max(0,Math.min(i/t.clientHeight,1))}}function c(t,e){var n=(360-t.h)/360;Ht.css(r,{top:100*n+"%"}),e||Ht.css(s,{left:t.s+"%",top:100-t.v+"%"}),o.style.background=Un({s:100,v:100,h:t.h}).toHex(),a.color().parse({s:t.s,v:t.v,h:t.h})}function t(t){var e;e=u(o,t),n.s=100*e.x,n.v=100*(1-e.y),c(n),a.fire("change")}function e(t){var e;e=u(i,t),(n=l.toHsv()).h=360*(1-e.y),c(n,!0),a.fire("change")}i=a.getEl("h"),r=a.getEl("hp"),o=a.getEl("sv"),s=a.getEl("svp"),a._repaint=function(){c(n=l.toHsv())},a._super(),a._svdraghelper=new we(a._id+"-sv",{start:t,drag:t}),a._hdraghelper=new we(a._id+"-h",{start:e,drag:e}),a._repaint()},rgb:function(){return this.color().toRgb()},value:function(t){if(!arguments.length)return this.color().toHex();this.color().parse(t),this._rendered&&this._repaint()},color:function(){return this._color||(this._color=Un()),this._color},renderHtml:function(){var t,e=this._id,o=this.classPrefix,s="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000";return t=''+function(){var t,e,n,i,r="";for(n="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",t=0,e=(i=s.split(",")).length-1;t
';return r}()+'
','"}}),qn=ge.extend({init:function(t){t=R.extend({height:100,text:"Drop an image here",multiple:!1,accept:null},t),this._super(t),this.classes.add("dropzone"),t.multiple&&this.classes.add("multiple")},renderHtml:function(){var t,e,n=this.settings;return t={id:this._id,hidefocus:"1"},e=Ht.create("div",t,""+this.translate(n.text)+" "),n.height&&Ht.css(e,"height",n.height+"px"),n.width&&Ht.css(e,"width",n.width+"px"),e.className=this.classes,e.outerHTML},postRender:function(){var i=this,t=function(t){t.preventDefault(),i.classes.toggle("dragenter"),i.getEl().className=i.classes};i._super(),i.$el.on("dragover",function(t){t.preventDefault()}),i.$el.on("dragenter",t),i.$el.on("dragleave",t),i.$el.on("drop",function(t){if(t.preventDefault(),!i.state.get("disabled")){var e=function(t){var e=i.settings.accept;if("string"!=typeof e)return t;var n=new RegExp("("+e.split(/\s*,\s*/).join("|")+")$","i");return R.grep(t,function(t){return n.test(t.name)})}(t.dataTransfer.files);i.value=function(){return e.length?i.settings.multiple?e:e[0]:null},e.length&&i.fire("change",t)}})},remove:function(){this.$el.off(),this._super()}}),Yn=ge.extend({init:function(t){var n=this;t.delimiter||(t.delimiter="\xbb"),n._super(t),n.classes.add("path"),n.canFocus=!0,n.on("click",function(t){var e;(e=t.target.getAttribute("data-index"))&&n.fire("select",{value:n.row()[e],index:e})}),n.row(n.settings.row)},focus:function(){return this.getEl().firstChild.focus(),this},row:function(t){return arguments.length?(this.state.set("row",t),this):this.state.get("row")},renderHtml:function(){return''+this._getDataPathHtml(this.state.get("row"))+"
"},bindStates:function(){var e=this;return e.state.on("change:row",function(t){e.innerHtml(e._getDataPathHtml(t.value))}),e._super()},_getDataPathHtml:function(t){var e,n,i=t||[],r="",o=this.classPrefix;for(e=0,n=i.length;e '+this.settings.delimiter+" ":"")+''+i[e].name+"
";return r||(r='\xa0
'),r}}),$n=Yn.extend({postRender:function(){var o=this,s=o.settings.editor;function a(t){if(1===t.nodeType){if("BR"===t.nodeName||t.getAttribute("data-mce-bogus"))return!0;if("bookmark"===t.getAttribute("data-mce-type"))return!0}return!1}return!1!==s.settings.elementpath&&(o.on("select",function(t){s.focus(),s.selection.select(this.row()[t.index].element),s.nodeChanged()}),s.on("nodeChange",function(t){for(var e=[],n=t.parents,i=n.length;i--;)if(1===n[i].nodeType&&!a(n[i])){var r=s.fire("ResolveName",{name:n[i].nodeName.toLowerCase(),target:n[i]});if(r.isDefaultPrevented()||e.push({name:r.name,element:n[i]}),r.isPropagationStopped())break}o.row(e)})),o._super()}}),Xn=Me.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var t=this,e=t._layout,n=t.classPrefix;return t.classes.add("formitem"),e.preRender(t),''+(t.settings.title?'
'+t.settings.title+"
":"")+'
'+(t.settings.html||"")+e.renderHtml(t)+"
"}}),jn=Me.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:15,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var i=this,t=i.items();i.settings.formItemDefaults||(i.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),t.each(function(t){var e,n=t.settings.label;n&&((e=new Xn(R.extend({items:{type:"label",id:t._id+"-l",text:n,flex:0,forId:t._id,disabled:t.disabled()}},i.settings.formItemDefaults))).type="formitem",t.aria("labelledby",t._id+"-l"),"undefined"==typeof t.settings.flex&&(t.settings.flex=1),i.replace(t,e),e.add(t))})},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){this._super(),this.fromJSON(this.settings.data)},bindStates:function(){var n=this;function t(){var t,e,i=0,r=[];if(!1!==n.settings.labelGapCalc)for(("children"===n.settings.labelGapCalc?n.find("formitem"):n.items()).filter("formitem").each(function(t){var e=t.items()[0],n=e.getEl().clientWidth;i=i'+(t.settings.title?''+t.settings.title+" ":"")+''+(t.settings.html||"")+e.renderHtml(t)+"
"}}),Gn=0,Kn=function(t){if(null===t||t===undefined)throw new Error("Node cannot be null or undefined");return{dom:lt(t)}},Zn={fromHtml:function(t,e){var n=(e||_.document).createElement("div");if(n.innerHTML=t,!n.hasChildNodes()||1",l)),null!==u&&a.push(ji("",u)),a))],o=function(t,e){return 0===t.length||0===e.length?t.concat(e):t.concat(c,e)},s=[],Ct(n,function(t){s=o(s,t)}),s):Ki(t,d($i))},Ki=function(t,e){var n=t.toLowerCase(),i=R.grep(e,function(t){return-1!==t.title.toLowerCase().indexOf(n)});return 1===i.length&&i[0].title===t?[]:i},Zi=function(r,i,o,s){var e=function(t){var e=Yi(o),n=Gi(t,e,s,i);r.showAutoComplete(n,t)};r.on("autocomplete",function(){e(r.value())}),r.on("selectitem",function(t){var e=t.value;r.value(e.url);var n,i=(n=e.title).raw?n.raw:n;"image"===s?r.fire("change",{meta:{alt:i,attach:e.attach}}):r.fire("change",{meta:{text:i,attach:e.attach}}),r.focus()}),r.on("click",function(t){0===r.value().length&&"INPUT"===t.target.nodeName&&e("")}),r.on("PostRender",function(){r.getRoot().on("submit",function(t){var e,n,i;t.isDefaultPrevented()||(e=r.value(),i=$i[n=s],/^https?/.test(e)&&(i?wt(i,e).isNone()&&($i[n]=i.slice(0,5).concat(e)):$i[n]=[e]))})})},Qi=function(o,t,n){var i=t.filepicker_validator_handler;i&&o.state.on("change:value",function(t){var e;0!==(e=t.value).length?i({url:e,type:n},function(t){var e,n,i,r=(n=(e=t).status,i=e.message,"valid"===n?{status:"ok",message:i}:"unknown"===n?{status:"warn",message:i}:"invalid"===n?{status:"warn",message:i}:{status:"none",message:""});o.statusMessage(r.message),o.statusLevel(r.status)}):o.statusLevel("none")})},tr=Bn.extend({Statics:{clearHistory:function(){$i={}}},init:function(t){var e,n,i,r=this,o=window.tinymce?window.tinymce.activeEditor:M.activeEditor,s=o.settings,a=t.filetype;t.spellcheck=!1,(i=s.file_picker_types||s.file_browser_callback_types)&&(i=R.makeMap(i,/[, ]/)),i&&!i[a]||(!(n=s.file_picker_callback)||i&&!i[a]?!(n=s.file_browser_callback)||i&&!i[a]||(e=function(){n(r.getEl("inp").id,r.value(),a,window)}):e=function(){var t=r.fire("beforecall").meta;t=R.extend({filetype:a},t),n.call(o,function(t,e){r.value(t).fire("change",{meta:e})},r.value(),t)}),e&&(t.icon="browse",t.onaction=e),r._super(t),r.classes.add("filepicker"),Zi(r,s,o.getBody(),a),Qi(r,s,a)}}),er=Nn.extend({recalc:function(t){var e=t.layoutRect(),n=t.paddingBox;t.items().filter(":visible").each(function(t){t.layoutRect({x:n.left,y:n.top,w:e.innerW-n.right-n.left,h:e.innerH-n.top-n.bottom}),t.recalc&&t.recalc()})}}),nr=Nn.extend({recalc:function(t){var e,n,i,r,o,s,a,l,u,c,d,f,h,m,g,p,v,b,y,x,w,_,R,C,k,E,H,T,S,M,N,O,W,P,D,A,B,L=[],I=Math.max,z=Math.min;for(i=t.items().filter(":visible"),r=t.layoutRect(),o=t.paddingBox,s=t.settings,f=t.isRtl()?s.direction||"row-reversed":s.direction,a=s.align,l=t.isRtl()?s.pack||"end":s.pack,u=s.spacing||0,"row-reversed"!==f&&"column-reverse"!==f||(i=i.set(i.toArray().reverse()),f=f.split("-")[0]),"column"===f?(C="y",_="h",R="minH",k="maxH",H="innerH",E="top",T="deltaH",S="contentH",P="left",O="w",M="x",N="innerW",W="minW",D="right",A="deltaW",B="contentW"):(C="x",_="w",R="minW",k="maxW",H="innerW",E="left",T="deltaW",S="contentW",P="top",O="h",M="y",N="innerH",W="minH",D="bottom",A="deltaH",B="contentH"),d=r[H]-o[E]-o[E],w=c=0,e=0,n=i.length;eS[d]?C:S[d],M[f]=k>M[f]?k:M[f];for(E=o.innerW-p.left-p.right,d=_=0;d'},src:function(t){this.getEl().src=t},html:function(t,e){var n=this,i=this.getEl().contentWindow.document.body;return i?(i.innerHTML=t,e&&e()):c.setTimeout(function(){n.html(t)}),this}}),Dr=ge.extend({init:function(t){this._super(t),this.classes.add("widget").add("infobox"),this.canFocus=!1},severity:function(t){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(t)},help:function(t){this.state.set("help",t)},renderHtml:function(){var t=this,e=t.classPrefix;return''+t.encode(t.state.get("text"))+'
'},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.getEl("body").firstChild.data=e.encode(t.value),e.state.get("rendered")&&e.updateLayoutRect()}),e.state.on("change:help",function(t){e.classes.toggle("has-help",t.value),e.state.get("rendered")&&e.updateLayoutRect()}),e._super()}}),Ar=ge.extend({init:function(t){var e=this;e._super(t),e.classes.add("widget").add("label"),e.canFocus=!1,t.multiline&&e.classes.add("autoscroll"),t.strong&&e.classes.add("strong")},initLayoutRect:function(){var t=this,e=t._super();return t.settings.multiline&&(Ht.getSize(t.getEl()).width>e.maxW&&(e.minW=e.maxW,t.classes.add("multiline")),t.getEl().style.width=e.minW+"px",e.startMinH=e.h=e.minH=Math.min(e.maxH,Ht.getSize(t.getEl()).height)),e},repaint:function(){return this.settings.multiline||(this.getEl().style.lineHeight=this.layoutRect().h+"px"),this._super()},severity:function(t){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(t)},renderHtml:function(){var t,e,n=this,i=n.settings.forId,r=n.settings.html?n.settings.html:n.encode(n.state.get("text"));return!i&&(e=n.settings.forName)&&(t=n.getRoot().find("#"+e)[0])&&(i=t._id),i?'"+r+" ":''+r+" "},bindStates:function(){var e=this;return e.state.on("change:text",function(t){e.innerHtml(e.encode(t.value)),e.state.get("rendered")&&e.updateLayoutRect()}),e._super()}}),Br=Me.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(t){this._super(t),this.classes.add("toolbar")},postRender:function(){return this.items().each(function(t){t.classes.add("toolbar-item")}),this._super()}}),Lr=Br.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}}),Ir=On.extend({init:function(t){var e=this;e._renderOpen=!0,e._super(t),t=e.settings,e.classes.add("menubtn"),t.fixedWidth&&e.classes.add("fixed-width"),e.aria("haspopup",!0),e.state.set("menu",t.menu||e.render())},showMenu:function(t){var e,n=this;if(n.menu&&n.menu.visible()&&!1!==t)return n.hideMenu();n.menu||(e=n.state.get("menu")||[],n.classes.add("opened"),e.length?e={type:"menu",animate:!0,items:e}:(e.type=e.type||"menu",e.animate=!0),e.renderTo?n.menu=e.parent(n).show().renderTo():n.menu=_e.create(e).parent(n).renderTo(),n.fire("createmenu"),n.menu.reflow(),n.menu.on("cancel",function(t){t.control.parent()===n.menu&&(t.stopPropagation(),n.focus(),n.hideMenu())}),n.menu.on("select",function(){n.focus()}),n.menu.on("show hide",function(t){"hide"===t.type&&t.control.parent()===n&&n.classes.remove("opened-under"),t.control===n.menu&&(n.activeMenu("show"===t.type),n.classes.toggle("opened","show"===t.type)),n.aria("expanded","show"===t.type)}).fire("show")),n.menu.show(),n.menu.layoutRect({w:n.layoutRect().w}),n.menu.repaint(),n.menu.moveRel(n.getEl(),n.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]);var i=n.menu.layoutRect(),r=n.$el.offset().top+n.layoutRect().h;r>i.y&&r'+e.encode(o)+""),r=e.settings.icon?i+"ico "+i+"i-"+r:"",e.aria("role",e.parent()instanceof Lr?"menuitem":"button"),''+(r?' ":"")+s+'
'},postRender:function(){var r=this;return r.on("click",function(t){t.control===r&&function(t,e){for(;t;){if(e===t)return!0;t=t.parentNode}return!1}(t.target,r.getEl())&&(r.focus(),r.showMenu(!t.aria),t.aria&&r.menu.items().filter(":visible")[0].focus())}),r.on("mouseenter",function(t){var e,n=t.control,i=r.parent();n&&i&&n instanceof Ir&&n.parent()===i&&(i.items().filter("MenuButton").each(function(t){t.hideMenu&&t!==n&&(t.menu&&t.menu.visible()&&(e=!0),t.hideMenu())}),e&&(n.focus(),n.showMenu()))}),r._super()},bindStates:function(){var t=this;return t.state.on("change:menu",function(){t.menu&&t.menu.remove(),t.menu=null}),t._super()},remove:function(){this._super(),this.menu&&this.menu.remove()}});function zr(i,r){var o,s,a=this,l=ae.classPrefix;a.show=function(t,e){function n(){o&&(Tt(i).append('
'),e&&e())}return a.hide(),o=!0,t?s=c.setTimeout(n,t):n(),a},a.hide=function(){var t=i.lastChild;return c.clearTimeout(s),t&&-1!==t.className.indexOf("throbber")&&t.parentNode.removeChild(t),o=!1,a}}var Fr=ze.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(t){if(t.autohide=!0,t.constrainToViewport=!0,"function"==typeof t.items&&(t.itemsFactory=t.items,t.items=[]),t.itemDefaults)for(var e=t.items,n=e.length;n--;)e[n]=R.extend({},t.itemDefaults,e[n]);this._super(t),this.classes.add("menu"),t.animate&&11!==h.ie&&this.classes.add("animate")},repaint:function(){return this.classes.toggle("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){this.hideAll(),this.fire("select")},load:function(){var e,n=this;function i(){n.throbber&&(n.throbber.hide(),n.throbber=null)}n.settings.itemsFactory&&(n.throbber||(n.throbber=new zr(n.getEl("body"),!0),0===n.items().length?(n.throbber.show(),n.fire("loading")):n.throbber.show(100,function(){n.items().remove(),n.fire("loading")}),n.on("hide close",i)),n.requestTime=e=(new Date).getTime(),n.settings.itemsFactory(function(t){0!==t.length?n.requestTime===e&&(n.getEl().style.width="",n.getEl("body").style.width="",i(),n.items().remove(),n.getEl("body").innerHTML="",n.add(t),n.renderNew(),n.fire("loaded")):n.hide()}))},hideAll:function(){return this.find("menuitem").exec("hideMenu"),this._super()},preRender:function(){var n=this;return n.items().each(function(t){var e=t.settings;if(e.icon||e.image||e.selectable)return!(n._hasIcons=!0)}),n.settings.itemsFactory&&n.on("postrender",function(){n.settings.itemsFactory&&n.load()}),n.on("show hide",function(t){t.control===n&&("show"===t.type?c.setTimeout(function(){n.classes.add("in")},0):n.classes.remove("in"))}),n._super()}}),Ur=Ir.extend({init:function(i){var e,r,o,n,s=this;s._super(i),i=s.settings,s._values=e=i.values,e&&("undefined"!=typeof i.value&&function t(e){for(var n=0;n").replace(new RegExp(c("]mce~match!"),"g"),"")}return s&&e.parent().classes.add("menu-has-icons"),i.image&&(a=" style=\"background-image: url('"+i.image+"')\""),l&&(l=function(t){var e,n,i={};for(i=h.mac?{alt:"⌥",ctrl:"⌘",shift:"⇧",meta:"⌘"}:{meta:"Ctrl"},t=t.split("+"),e=0;e \xa0":"",o=f(e.encode(d(o))),u=f(e.encode(d(u))),''+t+("-"!==o?'
'+o+" ":"")+(l?'":"")+(i.menu?'
':"")+(u?'":"")+"
"},postRender:function(){var e=this,n=e.settings,t=n.textStyle;if("function"==typeof t&&(t=t.call(this)),t){var i=e.getEl("text");i&&(i.setAttribute("style",t),e._textStyle=t)}return e.on("mouseenter click",function(t){t.control===e&&(n.menu||"click"!==t.type?(e.showMenu(),t.aria&&e.menu.focus(!0)):(e.fire("select"),c.requestAnimationFrame(function(){e.parent().hideAll()})))}),e._super(),e},hover:function(){return this.parent().items().each(function(t){t.classes.remove("selected")}),this.classes.toggle("selected",!0),this},active:function(t){return function(t,e){var n=t._textStyle;if(n){var i=t.getEl("text");i.setAttribute("style",n),e&&(i.style.color="",i.style.backgroundColor="")}}(this,t),void 0!==t&&this.aria("checked",t),this._super(t)},remove:function(){this._super(),this.menu&&this.menu.remove()}}),qr=Dn.extend({Defaults:{classes:"radio",role:"radio"}}),Yr=ge.extend({renderHtml:function(){var t=this,e=t.classPrefix;return t.classes.add("resizehandle"),"both"===t.settings.direction&&t.classes.add("resizehandle-both"),t.canFocus=!1,'
'},postRender:function(){var e=this;e._super(),e.resizeDragHelper=new we(this._id,{start:function(){e.fire("ResizeStart")},drag:function(t){"both"!==e.settings.direction&&(t.deltaX=0),e.fire("Resize",t)},stop:function(){e.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}});function $r(t){var e="";if(t)for(var n=0;n'+t[n]+"";return e}var Xr=ge.extend({Defaults:{classes:"selectbox",role:"selectbox",options:[]},init:function(t){var n=this;n._super(t),n.settings.size&&(n.size=n.settings.size),n.settings.options&&(n._options=n.settings.options),n.on("keydown",function(t){var e;13===t.keyCode&&(t.preventDefault(),n.parents().reverse().each(function(t){if(t.toJSON)return e=t,!1}),n.fire("submit",{data:e.toJSON()}))})},options:function(t){return arguments.length?(this.state.set("options",t),this):this.state.get("options")},renderHtml:function(){var t,e=this,n="";return t=$r(e._options),e.size&&(n=' size = "'+e.size+'"'),'"+t+" "},bindStates:function(){var e=this;return e.state.on("change:options",function(t){e.getEl().innerHTML=$r(t.value)}),e._super()}});function jr(t,e,n){return t
'},reset:function(){this.value(this._initValue).repaint()},postRender:function(){var t,e,n,i,r,o,s,a,l,u,c,d,f,h,m=this;t=m._minValue,e=m._maxValue,"v"===m.settings.orientation?(n="screenY",i="top",r="height",o="h"):(n="screenX",i="left",r="width",o="w"),m._super(),function(o,s){function e(t){var e,n,i,r;e=jr(e=(((e=m.value())+(r=n=o))/((i=s)-r)+.05*t)*(i-n)-n,o,s),m.value(e),m.fire("dragstart",{value:e}),m.fire("drag",{value:e}),m.fire("dragend",{value:e})}m.on("keydown",function(t){switch(t.keyCode){case 37:case 38:e(-1);break;case 39:case 40:e(1)}})}(t,e),s=t,a=e,l=m.getEl("handle"),m._dragHelper=new we(m._id,{handle:m._id+"-handle",start:function(t){u=t[n],c=parseInt(m.getEl("handle").style[i],10),d=(m.layoutRect()[o]||100)-Ht.getSize(l)[r],m.fire("dragstart",{value:h})},drag:function(t){var e=t[n]-u;f=jr(c+e,0,d),l.style[i]=f+"px",h=s+f/d*(a-s),m.value(h),m.tooltip().text(""+m.settings.previewFilter(h)).show().moveRel(l,"bc tc"),m.fire("drag",{value:h})},stop:function(){m.tooltip().hide(),m.fire("dragend",{value:h})}})},repaint:function(){this._super(),Gr(this,this.value())},bindStates:function(){var e=this;return e.state.on("change:value",function(t){Gr(e,t.value)}),e._super()}}),Zr=ge.extend({renderHtml:function(){return this.classes.add("spacer"),this.canFocus=!1,'
'}}),Qr=Ir.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var t,e,n=this.getEl(),i=this.layoutRect();return this._super(),t=n.firstChild,e=n.lastChild,Tt(t).css({width:i.w-Ht.getSize(e).width,height:i.h-2}),Tt(e).css({height:i.h-2}),this},activeMenu:function(t){Tt(this.getEl().lastChild).toggleClass(this.classPrefix+"active",t)},renderHtml:function(){var t,e,n=this,i=n._id,r=n.classPrefix,o=n.state.get("icon"),s=n.state.get("text"),a=n.settings,l="";return(t=a.image)?(o="none","string"!=typeof t&&(t=_.window.getSelection?t[0]:t[1]),t=" style=\"background-image: url('"+t+"')\""):t="",o=a.icon?r+"ico "+r+"i-"+o:"",s&&(n.classes.add("btn-has-text"),l=''+n.encode(s)+" "),e="boolean"==typeof a.active?' aria-pressed="'+a.active+'"':"",''+(o?' ":"")+l+' '+(n._menuBtnText?(o?"\xa0":"")+n._menuBtnText:"")+'
'},postRender:function(){var n=this.settings.onclick;return this.on("click",function(t){var e=t.target;if(t.control===this)for(;e;){if(t.aria&&"down"!==t.aria.key||"BUTTON"===e.nodeName&&-1===e.className.indexOf("open"))return t.stopImmediatePropagation(),void(n&&n.call(this,t));e=e.parentNode}}),delete this.settings.onclick,this._super()}}),to=ir.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}}),eo=Oe.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(n){var t;this.activeTabId&&(t=this.getEl(this.activeTabId),Tt(t).removeClass(this.classPrefix+"active"),t.setAttribute("aria-selected","false")),this.activeTabId="t"+n,(t=this.getEl("t"+n)).setAttribute("aria-selected","true"),Tt(t).addClass(this.classPrefix+"active"),this.items()[n].show().fire("showtab"),this.reflow(),this.items().each(function(t,e){n!==e&&t.hide()})},renderHtml:function(){var i=this,t=i._layout,r="",o=i.classPrefix;return i.preRender(),t.preRender(i),i.items().each(function(t,e){var n=i._id+"-t"+e;t.aria("role","tabpanel"),t.aria("labelledby",n),r+=''+i.encode(t.settings.title)+"
"}),'"},postRender:function(){var i=this;i._super(),i.settings.activeTab=i.settings.activeTab||0,i.activateTab(i.settings.activeTab),this.on("click",function(t){var e=t.target.parentNode;if(e&&e.id===i._id+"-head")for(var n=e.childNodes.length;n--;)e.childNodes[n]===t.target&&i.activateTab(n)})},initLayoutRect:function(){var t,e,n,i=this;e=(e=Ht.getSize(i.getEl("head")).width)<0?0:e,n=0,i.items().each(function(t){e=Math.max(e,t.layoutRect().minW),n=Math.max(n,t.layoutRect().minH)}),i.items().each(function(t){t.settings.x=0,t.settings.y=0,t.settings.w=e,t.settings.h=n,t.layoutRect({x:0,y:0,w:e,h:n})});var r=Ht.getSize(i.getEl("head")).height;return i.settings.minWidth=e,i.settings.minHeight=n+r,(t=i._super()).deltaH+=r,t.innerH=t.h-t.deltaH,t}}),no=ge.extend({init:function(t){var n=this;n._super(t),n.classes.add("textbox"),t.multiline?n.classes.add("multiline"):(n.on("keydown",function(t){var e;13===t.keyCode&&(t.preventDefault(),n.parents().reverse().each(function(t){if(t.toJSON)return e=t,!1}),n.fire("submit",{data:e.toJSON()}))}),n.on("keyup",function(t){n.state.set("value",t.target.value)}))},repaint:function(){var t,e,n,i,r,o=this,s=0;t=o.getEl().style,e=o._layoutRect,r=o._lastRepaintRect||{};var a=_.document;return!o.settings.multiline&&a.all&&(!a.documentMode||a.documentMode<=8)&&(t.lineHeight=e.h-s+"px"),i=(n=o.borderBox).left+n.right+8,s=n.top+n.bottom+(o.settings.multiline?8:0),e.x!==r.x&&(t.left=e.x+"px",r.x=e.x),e.y!==r.y&&(t.top=e.y+"px",r.y=e.y),e.w!==r.w&&(t.width=e.w-i+"px",r.w=e.w),e.h!==r.h&&(t.height=e.h-s+"px",r.h=e.h),o._lastRepaintRect=r,o.fire("repaint",{},!1),o},renderHtml:function(){var e,t,n=this,i=n.settings;return e={id:n._id,hidefocus:"1"},R.each(["rows","spellcheck","maxLength","size","readonly","min","max","step","list","pattern","placeholder","required","multiple"],function(t){e[t]=i[t]}),n.disabled()&&(e.disabled="disabled"),i.subtype&&(e.type=i.subtype),(t=Ht.create(i.multiline?"textarea":"input",e)).value=n.state.get("value"),t.className=n.classes.toString(),t.outerHTML},value:function(t){return arguments.length?(this.state.set("value",t),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var e=this;e.getEl().value=e.state.get("value"),e._super(),e.$el.on("change",function(t){e.state.set("value",t.target.value),e.fire("change",t)})},bindStates:function(){var e=this;return e.state.on("change:value",function(t){e.getEl().value!==t.value&&(e.getEl().value=t.value)}),e.state.on("change:disabled",function(t){e.getEl().disabled=t.value}),e._super()},remove:function(){this.$el.off(),this._super()}}),io=function(){return{Selector:Ft,Collection:qt,ReflowQueue:Zt,Control:ae,Factory:_e,KeyboardNavigation:Ce,Container:Me,DragHelper:we,Scrollable:Ne,Panel:Oe,Movable:he,Resizable:We,FloatPanel:ze,Window:$e,MessageBox:Ge,Tooltip:me,Widget:ge,Progress:pe,Notification:be,Layout:Mn,AbsoluteLayout:Nn,Button:On,ButtonGroup:Pn,Checkbox:Dn,ComboBox:Bn,ColorBox:Ln,PanelButton:In,ColorButton:Fn,ColorPicker:Vn,Path:Yn,ElementPath:$n,FormItem:Xn,Form:jn,FieldSet:Jn,FilePicker:tr,FitLayout:er,FlexLayout:nr,FlowLayout:ir,FormatControls:Or,GridLayout:Wr,Iframe:Pr,InfoBox:Dr,Label:Ar,Toolbar:Br,MenuBar:Lr,MenuButton:Ir,MenuItem:Vr,Throbber:zr,Menu:Fr,ListBox:Ur,Radio:qr,ResizeHandle:Yr,SelectBox:Xr,Slider:Kr,Spacer:Zr,SplitButton:Qr,StackLayout:to,TabPanel:eo,TextBox:no,DropZone:qn,BrowseButton:Wn}},ro=function(n){n.ui?R.each(io(),function(t,e){n.ui[e]=t}):n.ui=io()};R.each(io(),function(t,e){_e.add(e,t)}),ro(window.tinymce?window.tinymce:{}),r.add("inlite",function(t){var e=Sn();return Or.setup(t),_n(t,e),Ke(t,e)})}(window); themes/modern/theme.js 0000644 00001150123 14740051667 0010772 0 ustar 00 (function () {
var modern = (function (domGlobals) {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.ThemeManager');
var global$1 = tinymce.util.Tools.resolve('tinymce.EditorManager');
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
var isBrandingEnabled = function (editor) {
return editor.getParam('branding', true, 'boolean');
};
var hasMenubar = function (editor) {
return getMenubar(editor) !== false;
};
var getMenubar = function (editor) {
return editor.getParam('menubar');
};
var hasStatusbar = function (editor) {
return editor.getParam('statusbar', true, 'boolean');
};
var getToolbarSize = function (editor) {
return editor.getParam('toolbar_items_size');
};
var isReadOnly = function (editor) {
return editor.getParam('readonly', false, 'boolean');
};
var getFixedToolbarContainer = function (editor) {
return editor.getParam('fixed_toolbar_container');
};
var getInlineToolbarPositionHandler = function (editor) {
return editor.getParam('inline_toolbar_position_handler');
};
var getMenu = function (editor) {
return editor.getParam('menu');
};
var getRemovedMenuItems = function (editor) {
return editor.getParam('removed_menuitems', '');
};
var getMinWidth = function (editor) {
return editor.getParam('min_width', 100, 'number');
};
var getMinHeight = function (editor) {
return editor.getParam('min_height', 100, 'number');
};
var getMaxWidth = function (editor) {
return editor.getParam('max_width', 65535, 'number');
};
var getMaxHeight = function (editor) {
return editor.getParam('max_height', 65535, 'number');
};
var isSkinDisabled = function (editor) {
return editor.settings.skin === false;
};
var isInline = function (editor) {
return editor.getParam('inline', false, 'boolean');
};
var getResize = function (editor) {
var resize = editor.getParam('resize', 'vertical');
if (resize === false) {
return 'none';
} else if (resize === 'both') {
return 'both';
} else {
return 'vertical';
}
};
var getSkinUrl = function (editor) {
var settings = editor.settings;
var skin = settings.skin;
var skinUrl = settings.skin_url;
if (skin !== false) {
var skinName = skin ? skin : 'lightgray';
if (skinUrl) {
skinUrl = editor.documentBaseURI.toAbsolute(skinUrl);
} else {
skinUrl = global$1.baseURL + '/skins/' + skinName;
}
}
return skinUrl;
};
var getIndexedToolbars = function (settings, defaultToolbar) {
var toolbars = [];
for (var i = 1; i < 10; i++) {
var toolbar = settings['toolbar' + i];
if (!toolbar) {
break;
}
toolbars.push(toolbar);
}
var mainToolbar = settings.toolbar ? [settings.toolbar] : [defaultToolbar];
return toolbars.length > 0 ? toolbars : mainToolbar;
};
var getToolbars = function (editor) {
var toolbar = editor.getParam('toolbar');
var defaultToolbar = 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image';
if (toolbar === false) {
return [];
} else if (global$2.isArray(toolbar)) {
return global$2.grep(toolbar, function (toolbar) {
return toolbar.length > 0;
});
} else {
return getIndexedToolbars(editor.settings, defaultToolbar);
}
};
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
var global$4 = tinymce.util.Tools.resolve('tinymce.ui.Factory');
var global$5 = tinymce.util.Tools.resolve('tinymce.util.I18n');
var fireSkinLoaded = function (editor) {
return editor.fire('SkinLoaded');
};
var fireResizeEditor = function (editor) {
return editor.fire('ResizeEditor');
};
var fireBeforeRenderUI = function (editor) {
return editor.fire('BeforeRenderUI');
};
var Events = {
fireSkinLoaded: fireSkinLoaded,
fireResizeEditor: fireResizeEditor,
fireBeforeRenderUI: fireBeforeRenderUI
};
var focus = function (panel, type) {
return function () {
var item = panel.find(type)[0];
if (item) {
item.focus(true);
}
};
};
var addKeys = function (editor, panel) {
editor.shortcuts.add('Alt+F9', '', focus(panel, 'menubar'));
editor.shortcuts.add('Alt+F10,F10', '', focus(panel, 'toolbar'));
editor.shortcuts.add('Alt+F11', '', focus(panel, 'elementpath'));
panel.on('cancel', function () {
editor.focus();
});
};
var A11y = { addKeys: addKeys };
var global$6 = tinymce.util.Tools.resolve('tinymce.geom.Rect');
var global$7 = tinymce.util.Tools.resolve('tinymce.util.Delay');
var noop = function () {
};
var constant = function (value) {
return function () {
return value;
};
};
var never = constant(false);
var always = constant(true);
var none = function () {
return NONE;
};
var NONE = function () {
var eq = function (o) {
return o.isNone();
};
var call = function (thunk) {
return thunk();
};
var id = function (n) {
return n;
};
var me = {
fold: function (n, s) {
return n();
},
is: never,
isSome: never,
isNone: always,
getOr: id,
getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: constant(null),
getOrUndefined: constant(undefined),
or: id,
orThunk: call,
map: none,
each: noop,
bind: none,
exists: never,
forall: always,
filter: none,
equals: eq,
equals_: eq,
toArray: function () {
return [];
},
toString: constant('none()')
};
if (Object.freeze) {
Object.freeze(me);
}
return me;
}();
var some = function (a) {
var constant_a = constant(a);
var self = function () {
return me;
};
var bind = function (f) {
return f(a);
};
var me = {
fold: function (n, s) {
return s(a);
},
is: function (v) {
return a === v;
},
isSome: always,
isNone: never,
getOr: constant_a,
getOrThunk: constant_a,
getOrDie: constant_a,
getOrNull: constant_a,
getOrUndefined: constant_a,
or: self,
orThunk: self,
map: function (f) {
return some(f(a));
},
each: function (f) {
f(a);
},
bind: bind,
exists: bind,
forall: bind,
filter: function (f) {
return f(a) ? me : NONE;
},
toArray: function () {
return [a];
},
toString: function () {
return 'some(' + a + ')';
},
equals: function (o) {
return o.is(a);
},
equals_: function (o, elementEq) {
return o.fold(never, function (b) {
return elementEq(a, b);
});
}
};
return me;
};
var from = function (value) {
return value === null || value === undefined ? NONE : some(value);
};
var Option = {
some: some,
none: none,
from: from
};
var getUiContainerDelta = function (ctrl) {
var uiContainer = getUiContainer(ctrl);
if (uiContainer && global$3.DOM.getStyle(uiContainer, 'position', true) !== 'static') {
var containerPos = global$3.DOM.getPos(uiContainer);
var dx = uiContainer.scrollLeft - containerPos.x;
var dy = uiContainer.scrollTop - containerPos.y;
return Option.some({
x: dx,
y: dy
});
} else {
return Option.none();
}
};
var setUiContainer = function (editor, ctrl) {
var uiContainer = global$3.DOM.select(editor.settings.ui_container)[0];
ctrl.getRoot().uiContainer = uiContainer;
};
var getUiContainer = function (ctrl) {
return ctrl ? ctrl.getRoot().uiContainer : null;
};
var inheritUiContainer = function (fromCtrl, toCtrl) {
return toCtrl.uiContainer = getUiContainer(fromCtrl);
};
var UiContainer = {
getUiContainerDelta: getUiContainerDelta,
setUiContainer: setUiContainer,
getUiContainer: getUiContainer,
inheritUiContainer: inheritUiContainer
};
var createToolbar = function (editor, items, size) {
var toolbarItems = [];
var buttonGroup;
if (!items) {
return;
}
global$2.each(items.split(/[ ,]/), function (item) {
var itemName;
var bindSelectorChanged = function () {
var selection = editor.selection;
if (item.settings.stateSelector) {
selection.selectorChanged(item.settings.stateSelector, function (state) {
item.active(state);
}, true);
}
if (item.settings.disabledStateSelector) {
selection.selectorChanged(item.settings.disabledStateSelector, function (state) {
item.disabled(state);
});
}
};
if (item === '|') {
buttonGroup = null;
} else {
if (!buttonGroup) {
buttonGroup = {
type: 'buttongroup',
items: []
};
toolbarItems.push(buttonGroup);
}
if (editor.buttons[item]) {
itemName = item;
item = editor.buttons[itemName];
if (typeof item === 'function') {
item = item();
}
item.type = item.type || 'button';
item.size = size;
item = global$4.create(item);
buttonGroup.items.push(item);
if (editor.initialized) {
bindSelectorChanged();
} else {
editor.on('init', bindSelectorChanged);
}
}
}
});
return {
type: 'toolbar',
layout: 'flow',
items: toolbarItems
};
};
var createToolbars = function (editor, size) {
var toolbars = [];
var addToolbar = function (items) {
if (items) {
toolbars.push(createToolbar(editor, items, size));
}
};
global$2.each(getToolbars(editor), function (toolbar) {
addToolbar(toolbar);
});
if (toolbars.length) {
return {
type: 'panel',
layout: 'stack',
classes: 'toolbar-grp',
ariaRoot: true,
ariaRemember: true,
items: toolbars
};
}
};
var Toolbar = {
createToolbar: createToolbar,
createToolbars: createToolbars
};
var DOM = global$3.DOM;
var toClientRect = function (geomRect) {
return {
left: geomRect.x,
top: geomRect.y,
width: geomRect.w,
height: geomRect.h,
right: geomRect.x + geomRect.w,
bottom: geomRect.y + geomRect.h
};
};
var hideAllFloatingPanels = function (editor) {
global$2.each(editor.contextToolbars, function (toolbar) {
if (toolbar.panel) {
toolbar.panel.hide();
}
});
};
var movePanelTo = function (panel, pos) {
panel.moveTo(pos.left, pos.top);
};
var togglePositionClass = function (panel, relPos, predicate) {
relPos = relPos ? relPos.substr(0, 2) : '';
global$2.each({
t: 'down',
b: 'up'
}, function (cls, pos) {
panel.classes.toggle('arrow-' + cls, predicate(pos, relPos.substr(0, 1)));
});
global$2.each({
l: 'left',
r: 'right'
}, function (cls, pos) {
panel.classes.toggle('arrow-' + cls, predicate(pos, relPos.substr(1, 1)));
});
};
var userConstrain = function (handler, x, y, elementRect, contentAreaRect, panelRect) {
panelRect = toClientRect({
x: x,
y: y,
w: panelRect.w,
h: panelRect.h
});
if (handler) {
panelRect = handler({
elementRect: toClientRect(elementRect),
contentAreaRect: toClientRect(contentAreaRect),
panelRect: panelRect
});
}
return panelRect;
};
var addContextualToolbars = function (editor) {
var scrollContainer;
var getContextToolbars = function () {
return editor.contextToolbars || [];
};
var getElementRect = function (elm) {
var pos, targetRect, root;
pos = DOM.getPos(editor.getContentAreaContainer());
targetRect = editor.dom.getRect(elm);
root = editor.dom.getRoot();
if (root.nodeName === 'BODY') {
targetRect.x -= root.ownerDocument.documentElement.scrollLeft || root.scrollLeft;
targetRect.y -= root.ownerDocument.documentElement.scrollTop || root.scrollTop;
}
targetRect.x += pos.x;
targetRect.y += pos.y;
return targetRect;
};
var reposition = function (match, shouldShow) {
var relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions, smallElementWidthThreshold;
var handler = getInlineToolbarPositionHandler(editor);
if (editor.removed) {
return;
}
if (!match || !match.toolbar.panel) {
hideAllFloatingPanels(editor);
return;
}
testPositions = [
'bc-tc',
'tc-bc',
'tl-bl',
'bl-tl',
'tr-br',
'br-tr'
];
panel = match.toolbar.panel;
if (shouldShow) {
panel.show();
}
elementRect = getElementRect(match.element);
panelRect = DOM.getRect(panel.getEl());
contentAreaRect = DOM.getRect(editor.getContentAreaContainer() || editor.getBody());
var delta = UiContainer.getUiContainerDelta(panel).getOr({
x: 0,
y: 0
});
elementRect.x += delta.x;
elementRect.y += delta.y;
panelRect.x += delta.x;
panelRect.y += delta.y;
contentAreaRect.x += delta.x;
contentAreaRect.y += delta.y;
smallElementWidthThreshold = 25;
if (DOM.getStyle(match.element, 'display', true) !== 'inline') {
var clientRect = match.element.getBoundingClientRect();
elementRect.w = clientRect.width;
elementRect.h = clientRect.height;
}
if (!editor.inline) {
contentAreaRect.w = editor.getDoc().documentElement.offsetWidth;
}
if (editor.selection.controlSelection.isResizable(match.element) && elementRect.w < smallElementWidthThreshold) {
elementRect = global$6.inflate(elementRect, 0, 8);
}
relPos = global$6.findBestRelativePosition(panelRect, elementRect, contentAreaRect, testPositions);
elementRect = global$6.clamp(elementRect, contentAreaRect);
if (relPos) {
relRect = global$6.relativePosition(panelRect, elementRect, relPos);
movePanelTo(panel, userConstrain(handler, relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
} else {
contentAreaRect.h += panelRect.h;
elementRect = global$6.intersect(contentAreaRect, elementRect);
if (elementRect) {
relPos = global$6.findBestRelativePosition(panelRect, elementRect, contentAreaRect, [
'bc-tc',
'bl-tl',
'br-tr'
]);
if (relPos) {
relRect = global$6.relativePosition(panelRect, elementRect, relPos);
movePanelTo(panel, userConstrain(handler, relRect.x, relRect.y, elementRect, contentAreaRect, panelRect));
} else {
movePanelTo(panel, userConstrain(handler, elementRect.x, elementRect.y, elementRect, contentAreaRect, panelRect));
}
} else {
panel.hide();
}
}
togglePositionClass(panel, relPos, function (pos1, pos2) {
return pos1 === pos2;
});
};
var repositionHandler = function (show) {
return function () {
var execute = function () {
if (editor.selection) {
reposition(findFrontMostMatch(editor.selection.getNode()), show);
}
};
global$7.requestAnimationFrame(execute);
};
};
var bindScrollEvent = function (panel) {
if (!scrollContainer) {
var reposition_1 = repositionHandler(true);
var uiContainer_1 = UiContainer.getUiContainer(panel);
scrollContainer = editor.selection.getScrollContainer() || editor.getWin();
DOM.bind(scrollContainer, 'scroll', reposition_1);
DOM.bind(uiContainer_1, 'scroll', reposition_1);
editor.on('remove', function () {
DOM.unbind(scrollContainer, 'scroll', reposition_1);
DOM.unbind(uiContainer_1, 'scroll', reposition_1);
});
}
};
var showContextToolbar = function (match) {
var panel;
if (match.toolbar.panel) {
match.toolbar.panel.show();
reposition(match);
return;
}
panel = global$4.create({
type: 'floatpanel',
role: 'dialog',
classes: 'tinymce tinymce-inline arrow',
ariaLabel: 'Inline toolbar',
layout: 'flex',
direction: 'column',
align: 'stretch',
autohide: false,
autofix: true,
fixed: true,
border: 1,
items: Toolbar.createToolbar(editor, match.toolbar.items),
oncancel: function () {
editor.focus();
}
});
UiContainer.setUiContainer(editor, panel);
bindScrollEvent(panel);
match.toolbar.panel = panel;
panel.renderTo().reflow();
reposition(match);
};
var hideAllContextToolbars = function () {
global$2.each(getContextToolbars(), function (toolbar) {
if (toolbar.panel) {
toolbar.panel.hide();
}
});
};
var findFrontMostMatch = function (targetElm) {
var i, y, parentsAndSelf;
var toolbars = getContextToolbars();
parentsAndSelf = editor.$(targetElm).parents().add(targetElm);
for (i = parentsAndSelf.length - 1; i >= 0; i--) {
for (y = toolbars.length - 1; y >= 0; y--) {
if (toolbars[y].predicate(parentsAndSelf[i])) {
return {
toolbar: toolbars[y],
element: parentsAndSelf[i]
};
}
}
}
return null;
};
editor.on('click keyup setContent ObjectResized', function (e) {
if (e.type === 'setcontent' && !e.selection) {
return;
}
global$7.setEditorTimeout(editor, function () {
var match;
match = findFrontMostMatch(editor.selection.getNode());
if (match) {
hideAllContextToolbars();
showContextToolbar(match);
} else {
hideAllContextToolbars();
}
});
});
editor.on('blur hide contextmenu', hideAllContextToolbars);
editor.on('ObjectResizeStart', function () {
var match = findFrontMostMatch(editor.selection.getNode());
if (match && match.toolbar.panel) {
match.toolbar.panel.hide();
}
});
editor.on('ResizeEditor ResizeWindow', repositionHandler(true));
editor.on('nodeChange', repositionHandler(false));
editor.on('remove', function () {
global$2.each(getContextToolbars(), function (toolbar) {
if (toolbar.panel) {
toolbar.panel.remove();
}
});
editor.contextToolbars = {};
});
editor.shortcuts.add('ctrl+F9', '', function () {
var match = findFrontMostMatch(editor.selection.getNode());
if (match && match.toolbar.panel) {
match.toolbar.panel.items()[0].focus();
}
});
};
var ContextToolbars = { addContextualToolbars: addContextualToolbars };
var typeOf = function (x) {
if (x === null) {
return 'null';
}
var t = typeof x;
if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
return 'array';
}
if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
return 'string';
}
return t;
};
var isType = function (type) {
return function (value) {
return typeOf(value) === type;
};
};
var isArray = isType('array');
var isFunction = isType('function');
var isNumber = isType('number');
var nativeSlice = Array.prototype.slice;
var nativeIndexOf = Array.prototype.indexOf;
var nativePush = Array.prototype.push;
var rawIndexOf = function (ts, t) {
return nativeIndexOf.call(ts, t);
};
var indexOf = function (xs, x) {
var r = rawIndexOf(xs, x);
return r === -1 ? Option.none() : Option.some(r);
};
var exists = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
var map = function (xs, f) {
var len = xs.length;
var r = new Array(len);
for (var i = 0; i < len; i++) {
var x = xs[i];
r[i] = f(x, i);
}
return r;
};
var each = function (xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i);
}
};
var filter = function (xs, pred) {
var r = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
var foldl = function (xs, f, acc) {
each(xs, function (x) {
acc = f(acc, x);
});
return acc;
};
var find = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(x);
}
}
return Option.none();
};
var findIndex = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(i);
}
}
return Option.none();
};
var flatten = function (xs) {
var r = [];
for (var i = 0, len = xs.length; i < len; ++i) {
if (!isArray(xs[i])) {
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
}
nativePush.apply(r, xs[i]);
}
return r;
};
var from$1 = isFunction(Array.from) ? Array.from : function (x) {
return nativeSlice.call(x);
};
var defaultMenus = {
file: {
title: 'File',
items: 'newdocument restoredraft | preview | print'
},
edit: {
title: 'Edit',
items: 'undo redo | cut copy paste pastetext | selectall'
},
view: {
title: 'View',
items: 'code | visualaid visualchars visualblocks | spellchecker | preview fullscreen'
},
insert: {
title: 'Insert',
items: 'image link media template codesample inserttable | charmap hr | pagebreak nonbreaking anchor toc | insertdatetime'
},
format: {
title: 'Format',
items: 'bold italic underline strikethrough superscript subscript codeformat | blockformats align | removeformat'
},
tools: {
title: 'Tools',
items: 'spellchecker spellcheckerlanguage | a11ycheck code'
},
table: { title: 'Table' },
help: { title: 'Help' }
};
var delimiterMenuNamePair = function () {
return {
name: '|',
item: { text: '|' }
};
};
var createMenuNameItemPair = function (name, item) {
var menuItem = item ? {
name: name,
item: item
} : null;
return name === '|' ? delimiterMenuNamePair() : menuItem;
};
var hasItemName = function (namedMenuItems, name) {
return findIndex(namedMenuItems, function (namedMenuItem) {
return namedMenuItem.name === name;
}).isSome();
};
var isSeparator = function (namedMenuItem) {
return namedMenuItem && namedMenuItem.item.text === '|';
};
var cleanupMenu = function (namedMenuItems, removedMenuItems) {
var menuItemsPass1 = filter(namedMenuItems, function (namedMenuItem) {
return removedMenuItems.hasOwnProperty(namedMenuItem.name) === false;
});
var menuItemsPass2 = filter(menuItemsPass1, function (namedMenuItem, i) {
return !isSeparator(namedMenuItem) || !isSeparator(menuItemsPass1[i - 1]);
});
return filter(menuItemsPass2, function (namedMenuItem, i) {
return !isSeparator(namedMenuItem) || i > 0 && i < menuItemsPass2.length - 1;
});
};
var createMenu = function (editorMenuItems, menus, removedMenuItems, context) {
var menuButton, menu, namedMenuItems, isUserDefined;
if (menus) {
menu = menus[context];
isUserDefined = true;
} else {
menu = defaultMenus[context];
}
if (menu) {
menuButton = { text: menu.title };
namedMenuItems = [];
global$2.each((menu.items || '').split(/[ ,]/), function (name) {
var namedMenuItem = createMenuNameItemPair(name, editorMenuItems[name]);
if (namedMenuItem) {
namedMenuItems.push(namedMenuItem);
}
});
if (!isUserDefined) {
global$2.each(editorMenuItems, function (item, name) {
if (item.context === context && !hasItemName(namedMenuItems, name)) {
if (item.separator === 'before') {
namedMenuItems.push(delimiterMenuNamePair());
}
if (item.prependToContext) {
namedMenuItems.unshift(createMenuNameItemPair(name, item));
} else {
namedMenuItems.push(createMenuNameItemPair(name, item));
}
if (item.separator === 'after') {
namedMenuItems.push(delimiterMenuNamePair());
}
}
});
}
menuButton.menu = map(cleanupMenu(namedMenuItems, removedMenuItems), function (menuItem) {
return menuItem.item;
});
if (!menuButton.menu.length) {
return null;
}
}
return menuButton;
};
var getDefaultMenubar = function (editor) {
var name;
var defaultMenuBar = [];
var menu = getMenu(editor);
if (menu) {
for (name in menu) {
defaultMenuBar.push(name);
}
} else {
for (name in defaultMenus) {
defaultMenuBar.push(name);
}
}
return defaultMenuBar;
};
var createMenuButtons = function (editor) {
var menuButtons = [];
var defaultMenuBar = getDefaultMenubar(editor);
var removedMenuItems = global$2.makeMap(getRemovedMenuItems(editor).split(/[ ,]/));
var menubar = getMenubar(editor);
var enabledMenuNames = typeof menubar === 'string' ? menubar.split(/[ ,]/) : defaultMenuBar;
for (var i = 0; i < enabledMenuNames.length; i++) {
var menuItems = enabledMenuNames[i];
var menu = createMenu(editor.menuItems, getMenu(editor), removedMenuItems, menuItems);
if (menu) {
menuButtons.push(menu);
}
}
return menuButtons;
};
var Menubar = { createMenuButtons: createMenuButtons };
var DOM$1 = global$3.DOM;
var getSize = function (elm) {
return {
width: elm.clientWidth,
height: elm.clientHeight
};
};
var resizeTo = function (editor, width, height) {
var containerElm, iframeElm, containerSize, iframeSize;
containerElm = editor.getContainer();
iframeElm = editor.getContentAreaContainer().firstChild;
containerSize = getSize(containerElm);
iframeSize = getSize(iframeElm);
if (width !== null) {
width = Math.max(getMinWidth(editor), width);
width = Math.min(getMaxWidth(editor), width);
DOM$1.setStyle(containerElm, 'width', width + (containerSize.width - iframeSize.width));
DOM$1.setStyle(iframeElm, 'width', width);
}
height = Math.max(getMinHeight(editor), height);
height = Math.min(getMaxHeight(editor), height);
DOM$1.setStyle(iframeElm, 'height', height);
Events.fireResizeEditor(editor);
};
var resizeBy = function (editor, dw, dh) {
var elm = editor.getContentAreaContainer();
resizeTo(editor, elm.clientWidth + dw, elm.clientHeight + dh);
};
var Resize = {
resizeTo: resizeTo,
resizeBy: resizeBy
};
var global$8 = tinymce.util.Tools.resolve('tinymce.Env');
var api = function (elm) {
return {
element: function () {
return elm;
}
};
};
var trigger = function (sidebar, panel, callbackName) {
var callback = sidebar.settings[callbackName];
if (callback) {
callback(api(panel.getEl('body')));
}
};
var hidePanels = function (name, container, sidebars) {
global$2.each(sidebars, function (sidebar) {
var panel = container.items().filter('#' + sidebar.name)[0];
if (panel && panel.visible() && sidebar.name !== name) {
trigger(sidebar, panel, 'onhide');
panel.visible(false);
}
});
};
var deactivateButtons = function (toolbar) {
toolbar.items().each(function (ctrl) {
ctrl.active(false);
});
};
var findSidebar = function (sidebars, name) {
return global$2.grep(sidebars, function (sidebar) {
return sidebar.name === name;
})[0];
};
var showPanel = function (editor, name, sidebars) {
return function (e) {
var btnCtrl = e.control;
var container = btnCtrl.parents().filter('panel')[0];
var panel = container.find('#' + name)[0];
var sidebar = findSidebar(sidebars, name);
hidePanels(name, container, sidebars);
deactivateButtons(btnCtrl.parent());
if (panel && panel.visible()) {
trigger(sidebar, panel, 'onhide');
panel.hide();
btnCtrl.active(false);
} else {
if (panel) {
panel.show();
trigger(sidebar, panel, 'onshow');
} else {
panel = global$4.create({
type: 'container',
name: name,
layout: 'stack',
classes: 'sidebar-panel',
html: ''
});
container.prepend(panel);
trigger(sidebar, panel, 'onrender');
trigger(sidebar, panel, 'onshow');
}
btnCtrl.active(true);
}
Events.fireResizeEditor(editor);
};
};
var isModernBrowser = function () {
return !global$8.ie || global$8.ie >= 11;
};
var hasSidebar = function (editor) {
return isModernBrowser() && editor.sidebars ? editor.sidebars.length > 0 : false;
};
var createSidebar = function (editor) {
var buttons = global$2.map(editor.sidebars, function (sidebar) {
var settings = sidebar.settings;
return {
type: 'button',
icon: settings.icon,
image: settings.image,
tooltip: settings.tooltip,
onclick: showPanel(editor, sidebar.name, editor.sidebars)
};
});
return {
type: 'panel',
name: 'sidebar',
layout: 'stack',
classes: 'sidebar',
items: [{
type: 'toolbar',
layout: 'stack',
classes: 'sidebar-toolbar',
items: buttons
}]
};
};
var Sidebar = {
hasSidebar: hasSidebar,
createSidebar: createSidebar
};
var fireSkinLoaded$1 = function (editor) {
var done = function () {
editor._skinLoaded = true;
Events.fireSkinLoaded(editor);
};
return function () {
if (editor.initialized) {
done();
} else {
editor.on('init', done);
}
};
};
var SkinLoaded = { fireSkinLoaded: fireSkinLoaded$1 };
var DOM$2 = global$3.DOM;
var switchMode = function (panel) {
return function (e) {
panel.find('*').disabled(e.mode === 'readonly');
};
};
var editArea = function (border) {
return {
type: 'panel',
name: 'iframe',
layout: 'stack',
classes: 'edit-area',
border: border,
html: ''
};
};
var editAreaContainer = function (editor) {
return {
type: 'panel',
layout: 'stack',
classes: 'edit-aria-container',
border: '1 0 0 0',
items: [
editArea('0'),
Sidebar.createSidebar(editor)
]
};
};
var render = function (editor, theme, args) {
var panel, resizeHandleCtrl, startSize;
if (isSkinDisabled(editor) === false && args.skinUiCss) {
DOM$2.styleSheetLoader.load(args.skinUiCss, SkinLoaded.fireSkinLoaded(editor));
} else {
SkinLoaded.fireSkinLoaded(editor)();
}
panel = theme.panel = global$4.create({
type: 'panel',
role: 'application',
classes: 'tinymce',
style: 'visibility: hidden',
layout: 'stack',
border: 1,
items: [
{
type: 'container',
classes: 'top-part',
items: [
hasMenubar(editor) === false ? null : {
type: 'menubar',
border: '0 0 1 0',
items: Menubar.createMenuButtons(editor)
},
Toolbar.createToolbars(editor, getToolbarSize(editor))
]
},
Sidebar.hasSidebar(editor) ? editAreaContainer(editor) : editArea('1 0 0 0')
]
});
UiContainer.setUiContainer(editor, panel);
if (getResize(editor) !== 'none') {
resizeHandleCtrl = {
type: 'resizehandle',
direction: getResize(editor),
onResizeStart: function () {
var elm = editor.getContentAreaContainer().firstChild;
startSize = {
width: elm.clientWidth,
height: elm.clientHeight
};
},
onResize: function (e) {
if (getResize(editor) === 'both') {
Resize.resizeTo(editor, startSize.width + e.deltaX, startSize.height + e.deltaY);
} else {
Resize.resizeTo(editor, null, startSize.height + e.deltaY);
}
}
};
}
if (hasStatusbar(editor)) {
var linkHtml = 'Tiny ';
var html = global$5.translate([
'Powered by {0}',
linkHtml
]);
var brandingLabel = isBrandingEnabled(editor) ? {
type: 'label',
classes: 'branding',
html: ' ' + html
} : null;
panel.add({
type: 'panel',
name: 'statusbar',
classes: 'statusbar',
layout: 'flow',
border: '1 0 0 0',
ariaRoot: true,
items: [
{
type: 'elementpath',
editor: editor
},
resizeHandleCtrl,
brandingLabel
]
});
}
Events.fireBeforeRenderUI(editor);
editor.on('SwitchMode', switchMode(panel));
panel.renderBefore(args.targetNode).reflow();
if (isReadOnly(editor)) {
editor.setMode('readonly');
}
if (args.width) {
DOM$2.setStyle(panel.getEl(), 'width', args.width);
}
editor.on('remove', function () {
panel.remove();
panel = null;
});
A11y.addKeys(editor, panel);
ContextToolbars.addContextualToolbars(editor);
return {
iframeContainer: panel.find('#iframe')[0].getEl(),
editorContainer: panel.getEl()
};
};
var Iframe = { render: render };
var global$9 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
var count = 0;
var funcs = {
id: function () {
return 'mceu_' + count++;
},
create: function (name, attrs, children) {
var elm = domGlobals.document.createElement(name);
global$3.DOM.setAttribs(elm, attrs);
if (typeof children === 'string') {
elm.innerHTML = children;
} else {
global$2.each(children, function (child) {
if (child.nodeType) {
elm.appendChild(child);
}
});
}
return elm;
},
createFragment: function (html) {
return global$3.DOM.createFragment(html);
},
getWindowSize: function () {
return global$3.DOM.getViewPort();
},
getSize: function (elm) {
var width, height;
if (elm.getBoundingClientRect) {
var rect = elm.getBoundingClientRect();
width = Math.max(rect.width || rect.right - rect.left, elm.offsetWidth);
height = Math.max(rect.height || rect.bottom - rect.bottom, elm.offsetHeight);
} else {
width = elm.offsetWidth;
height = elm.offsetHeight;
}
return {
width: width,
height: height
};
},
getPos: function (elm, root) {
return global$3.DOM.getPos(elm, root || funcs.getContainer());
},
getContainer: function () {
return global$8.container ? global$8.container : domGlobals.document.body;
},
getViewPort: function (win) {
return global$3.DOM.getViewPort(win);
},
get: function (id) {
return domGlobals.document.getElementById(id);
},
addClass: function (elm, cls) {
return global$3.DOM.addClass(elm, cls);
},
removeClass: function (elm, cls) {
return global$3.DOM.removeClass(elm, cls);
},
hasClass: function (elm, cls) {
return global$3.DOM.hasClass(elm, cls);
},
toggleClass: function (elm, cls, state) {
return global$3.DOM.toggleClass(elm, cls, state);
},
css: function (elm, name, value) {
return global$3.DOM.setStyle(elm, name, value);
},
getRuntimeStyle: function (elm, name) {
return global$3.DOM.getStyle(elm, name, true);
},
on: function (target, name, callback, scope) {
return global$3.DOM.bind(target, name, callback, scope);
},
off: function (target, name, callback) {
return global$3.DOM.unbind(target, name, callback);
},
fire: function (target, name, args) {
return global$3.DOM.fire(target, name, args);
},
innerHtml: function (elm, html) {
global$3.DOM.setHTML(elm, html);
}
};
var isStatic = function (elm) {
return funcs.getRuntimeStyle(elm, 'position') === 'static';
};
var isFixed = function (ctrl) {
return ctrl.state.get('fixed');
};
function calculateRelativePosition(ctrl, targetElm, rel) {
var ctrlElm, pos, x, y, selfW, selfH, targetW, targetH, viewport, size;
viewport = getWindowViewPort();
pos = funcs.getPos(targetElm, UiContainer.getUiContainer(ctrl));
x = pos.x;
y = pos.y;
if (isFixed(ctrl) && isStatic(domGlobals.document.body)) {
x -= viewport.x;
y -= viewport.y;
}
ctrlElm = ctrl.getEl();
size = funcs.getSize(ctrlElm);
selfW = size.width;
selfH = size.height;
size = funcs.getSize(targetElm);
targetW = size.width;
targetH = size.height;
rel = (rel || '').split('');
if (rel[0] === 'b') {
y += targetH;
}
if (rel[1] === 'r') {
x += targetW;
}
if (rel[0] === 'c') {
y += Math.round(targetH / 2);
}
if (rel[1] === 'c') {
x += Math.round(targetW / 2);
}
if (rel[3] === 'b') {
y -= selfH;
}
if (rel[4] === 'r') {
x -= selfW;
}
if (rel[3] === 'c') {
y -= Math.round(selfH / 2);
}
if (rel[4] === 'c') {
x -= Math.round(selfW / 2);
}
return {
x: x,
y: y,
w: selfW,
h: selfH
};
}
var getUiContainerViewPort = function (customUiContainer) {
return {
x: 0,
y: 0,
w: customUiContainer.scrollWidth - 1,
h: customUiContainer.scrollHeight - 1
};
};
var getWindowViewPort = function () {
var win = domGlobals.window;
var x = Math.max(win.pageXOffset, domGlobals.document.body.scrollLeft, domGlobals.document.documentElement.scrollLeft);
var y = Math.max(win.pageYOffset, domGlobals.document.body.scrollTop, domGlobals.document.documentElement.scrollTop);
var w = win.innerWidth || domGlobals.document.documentElement.clientWidth;
var h = win.innerHeight || domGlobals.document.documentElement.clientHeight;
return {
x: x,
y: y,
w: w,
h: h
};
};
var getViewPortRect = function (ctrl) {
var customUiContainer = UiContainer.getUiContainer(ctrl);
return customUiContainer && !isFixed(ctrl) ? getUiContainerViewPort(customUiContainer) : getWindowViewPort();
};
var Movable = {
testMoveRel: function (elm, rels) {
var viewPortRect = getViewPortRect(this);
for (var i = 0; i < rels.length; i++) {
var pos = calculateRelativePosition(this, elm, rels[i]);
if (isFixed(this)) {
if (pos.x > 0 && pos.x + pos.w < viewPortRect.w && pos.y > 0 && pos.y + pos.h < viewPortRect.h) {
return rels[i];
}
} else {
if (pos.x > viewPortRect.x && pos.x + pos.w < viewPortRect.w + viewPortRect.x && pos.y > viewPortRect.y && pos.y + pos.h < viewPortRect.h + viewPortRect.y) {
return rels[i];
}
}
}
return rels[0];
},
moveRel: function (elm, rel) {
if (typeof rel !== 'string') {
rel = this.testMoveRel(elm, rel);
}
var pos = calculateRelativePosition(this, elm, rel);
return this.moveTo(pos.x, pos.y);
},
moveBy: function (dx, dy) {
var self = this, rect = self.layoutRect();
self.moveTo(rect.x + dx, rect.y + dy);
return self;
},
moveTo: function (x, y) {
var self = this;
function constrain(value, max, size) {
if (value < 0) {
return 0;
}
if (value + size > max) {
value = max - size;
return value < 0 ? 0 : value;
}
return value;
}
if (self.settings.constrainToViewport) {
var viewPortRect = getViewPortRect(this);
var layoutRect = self.layoutRect();
x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w);
y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h);
}
var uiContainer = UiContainer.getUiContainer(self);
if (uiContainer && isStatic(uiContainer) && !isFixed(self)) {
x -= uiContainer.scrollLeft;
y -= uiContainer.scrollTop;
}
if (uiContainer) {
x += 1;
y += 1;
}
if (self.state.get('rendered')) {
self.layoutRect({
x: x,
y: y
}).repaint();
} else {
self.settings.x = x;
self.settings.y = y;
}
self.fire('move', {
x: x,
y: y
});
return self;
}
};
var global$a = tinymce.util.Tools.resolve('tinymce.util.Class');
var global$b = tinymce.util.Tools.resolve('tinymce.util.EventDispatcher');
var BoxUtils = {
parseBox: function (value) {
var len;
var radix = 10;
if (!value) {
return;
}
if (typeof value === 'number') {
value = value || 0;
return {
top: value,
left: value,
bottom: value,
right: value
};
}
value = value.split(' ');
len = value.length;
if (len === 1) {
value[1] = value[2] = value[3] = value[0];
} else if (len === 2) {
value[2] = value[0];
value[3] = value[1];
} else if (len === 3) {
value[3] = value[1];
}
return {
top: parseInt(value[0], radix) || 0,
right: parseInt(value[1], radix) || 0,
bottom: parseInt(value[2], radix) || 0,
left: parseInt(value[3], radix) || 0
};
},
measureBox: function (elm, prefix) {
function getStyle(name) {
var defaultView = elm.ownerDocument.defaultView;
if (defaultView) {
var computedStyle = defaultView.getComputedStyle(elm, null);
if (computedStyle) {
name = name.replace(/[A-Z]/g, function (a) {
return '-' + a;
});
return computedStyle.getPropertyValue(name);
} else {
return null;
}
}
return elm.currentStyle[name];
}
function getSide(name) {
var val = parseFloat(getStyle(name));
return isNaN(val) ? 0 : val;
}
return {
top: getSide(prefix + 'TopWidth'),
right: getSide(prefix + 'RightWidth'),
bottom: getSide(prefix + 'BottomWidth'),
left: getSide(prefix + 'LeftWidth')
};
}
};
function noop$1() {
}
function ClassList(onchange) {
this.cls = [];
this.cls._map = {};
this.onchange = onchange || noop$1;
this.prefix = '';
}
global$2.extend(ClassList.prototype, {
add: function (cls) {
if (cls && !this.contains(cls)) {
this.cls._map[cls] = true;
this.cls.push(cls);
this._change();
}
return this;
},
remove: function (cls) {
if (this.contains(cls)) {
var i = void 0;
for (i = 0; i < this.cls.length; i++) {
if (this.cls[i] === cls) {
break;
}
}
this.cls.splice(i, 1);
delete this.cls._map[cls];
this._change();
}
return this;
},
toggle: function (cls, state) {
var curState = this.contains(cls);
if (curState !== state) {
if (curState) {
this.remove(cls);
} else {
this.add(cls);
}
this._change();
}
return this;
},
contains: function (cls) {
return !!this.cls._map[cls];
},
_change: function () {
delete this.clsValue;
this.onchange.call(this);
}
});
ClassList.prototype.toString = function () {
var value;
if (this.clsValue) {
return this.clsValue;
}
value = '';
for (var i = 0; i < this.cls.length; i++) {
if (i > 0) {
value += ' ';
}
value += this.prefix + this.cls[i];
}
return value;
};
function unique(array) {
var uniqueItems = [];
var i = array.length, item;
while (i--) {
item = array[i];
if (!item.__checked) {
uniqueItems.push(item);
item.__checked = 1;
}
}
i = uniqueItems.length;
while (i--) {
delete uniqueItems[i].__checked;
}
return uniqueItems;
}
var expression = /^([\w\\*]+)?(?:#([\w\-\\]+))?(?:\.([\w\\\.]+))?(?:\[\@?([\w\\]+)([\^\$\*!~]?=)([\w\\]+)\])?(?:\:(.+))?/i;
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g;
var whiteSpace = /^\s*|\s*$/g;
var Collection;
var Selector = global$a.extend({
init: function (selector) {
var match = this.match;
function compileNameFilter(name) {
if (name) {
name = name.toLowerCase();
return function (item) {
return name === '*' || item.type === name;
};
}
}
function compileIdFilter(id) {
if (id) {
return function (item) {
return item._name === id;
};
}
}
function compileClassesFilter(classes) {
if (classes) {
classes = classes.split('.');
return function (item) {
var i = classes.length;
while (i--) {
if (!item.classes.contains(classes[i])) {
return false;
}
}
return true;
};
}
}
function compileAttrFilter(name, cmp, check) {
if (name) {
return function (item) {
var value = item[name] ? item[name]() : '';
return !cmp ? !!check : cmp === '=' ? value === check : cmp === '*=' ? value.indexOf(check) >= 0 : cmp === '~=' ? (' ' + value + ' ').indexOf(' ' + check + ' ') >= 0 : cmp === '!=' ? value !== check : cmp === '^=' ? value.indexOf(check) === 0 : cmp === '$=' ? value.substr(value.length - check.length) === check : false;
};
}
}
function compilePsuedoFilter(name) {
var notSelectors;
if (name) {
name = /(?:not\((.+)\))|(.+)/i.exec(name);
if (!name[1]) {
name = name[2];
return function (item, index, length) {
return name === 'first' ? index === 0 : name === 'last' ? index === length - 1 : name === 'even' ? index % 2 === 0 : name === 'odd' ? index % 2 === 1 : item[name] ? item[name]() : false;
};
}
notSelectors = parseChunks(name[1], []);
return function (item) {
return !match(item, notSelectors);
};
}
}
function compile(selector, filters, direct) {
var parts;
function add(filter) {
if (filter) {
filters.push(filter);
}
}
parts = expression.exec(selector.replace(whiteSpace, ''));
add(compileNameFilter(parts[1]));
add(compileIdFilter(parts[2]));
add(compileClassesFilter(parts[3]));
add(compileAttrFilter(parts[4], parts[5], parts[6]));
add(compilePsuedoFilter(parts[7]));
filters.pseudo = !!parts[7];
filters.direct = direct;
return filters;
}
function parseChunks(selector, selectors) {
var parts = [];
var extra, matches, i;
do {
chunker.exec('');
matches = chunker.exec(selector);
if (matches) {
selector = matches[3];
parts.push(matches[1]);
if (matches[2]) {
extra = matches[3];
break;
}
}
} while (matches);
if (extra) {
parseChunks(extra, selectors);
}
selector = [];
for (i = 0; i < parts.length; i++) {
if (parts[i] !== '>') {
selector.push(compile(parts[i], [], parts[i - 1] === '>'));
}
}
selectors.push(selector);
return selectors;
}
this._selectors = parseChunks(selector, []);
},
match: function (control, selectors) {
var i, l, si, sl, selector, fi, fl, filters, index, length, siblings, count, item;
selectors = selectors || this._selectors;
for (i = 0, l = selectors.length; i < l; i++) {
selector = selectors[i];
sl = selector.length;
item = control;
count = 0;
for (si = sl - 1; si >= 0; si--) {
filters = selector[si];
while (item) {
if (filters.pseudo) {
siblings = item.parent().items();
index = length = siblings.length;
while (index--) {
if (siblings[index] === item) {
break;
}
}
}
for (fi = 0, fl = filters.length; fi < fl; fi++) {
if (!filters[fi](item, index, length)) {
fi = fl + 1;
break;
}
}
if (fi === fl) {
count++;
break;
} else {
if (si === sl - 1) {
break;
}
}
item = item.parent();
}
}
if (count === sl) {
return true;
}
}
return false;
},
find: function (container) {
var matches = [], i, l;
var selectors = this._selectors;
function collect(items, selector, index) {
var i, l, fi, fl, item;
var filters = selector[index];
for (i = 0, l = items.length; i < l; i++) {
item = items[i];
for (fi = 0, fl = filters.length; fi < fl; fi++) {
if (!filters[fi](item, i, l)) {
fi = fl + 1;
break;
}
}
if (fi === fl) {
if (index === selector.length - 1) {
matches.push(item);
} else {
if (item.items) {
collect(item.items(), selector, index + 1);
}
}
} else if (filters.direct) {
return;
}
if (item.items) {
collect(item.items(), selector, index);
}
}
}
if (container.items) {
for (i = 0, l = selectors.length; i < l; i++) {
collect(container.items(), selectors[i], 0);
}
if (l > 1) {
matches = unique(matches);
}
}
if (!Collection) {
Collection = Selector.Collection;
}
return new Collection(matches);
}
});
var Collection$1, proto;
var push = Array.prototype.push, slice = Array.prototype.slice;
proto = {
length: 0,
init: function (items) {
if (items) {
this.add(items);
}
},
add: function (items) {
var self = this;
if (!global$2.isArray(items)) {
if (items instanceof Collection$1) {
self.add(items.toArray());
} else {
push.call(self, items);
}
} else {
push.apply(self, items);
}
return self;
},
set: function (items) {
var self = this;
var len = self.length;
var i;
self.length = 0;
self.add(items);
for (i = self.length; i < len; i++) {
delete self[i];
}
return self;
},
filter: function (selector) {
var self = this;
var i, l;
var matches = [];
var item, match;
if (typeof selector === 'string') {
selector = new Selector(selector);
match = function (item) {
return selector.match(item);
};
} else {
match = selector;
}
for (i = 0, l = self.length; i < l; i++) {
item = self[i];
if (match(item)) {
matches.push(item);
}
}
return new Collection$1(matches);
},
slice: function () {
return new Collection$1(slice.apply(this, arguments));
},
eq: function (index) {
return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
},
each: function (callback) {
global$2.each(this, callback);
return this;
},
toArray: function () {
return global$2.toArray(this);
},
indexOf: function (ctrl) {
var self = this;
var i = self.length;
while (i--) {
if (self[i] === ctrl) {
break;
}
}
return i;
},
reverse: function () {
return new Collection$1(global$2.toArray(this).reverse());
},
hasClass: function (cls) {
return this[0] ? this[0].classes.contains(cls) : false;
},
prop: function (name, value) {
var self = this;
var item;
if (value !== undefined) {
self.each(function (item) {
if (item[name]) {
item[name](value);
}
});
return self;
}
item = self[0];
if (item && item[name]) {
return item[name]();
}
},
exec: function (name) {
var self = this, args = global$2.toArray(arguments).slice(1);
self.each(function (item) {
if (item[name]) {
item[name].apply(item, args);
}
});
return self;
},
remove: function () {
var i = this.length;
while (i--) {
this[i].remove();
}
return this;
},
addClass: function (cls) {
return this.each(function (item) {
item.classes.add(cls);
});
},
removeClass: function (cls) {
return this.each(function (item) {
item.classes.remove(cls);
});
}
};
global$2.each('fire on off show hide append prepend before after reflow'.split(' '), function (name) {
proto[name] = function () {
var args = global$2.toArray(arguments);
this.each(function (ctrl) {
if (name in ctrl) {
ctrl[name].apply(ctrl, args);
}
});
return this;
};
});
global$2.each('text name disabled active selected checked visible parent value data'.split(' '), function (name) {
proto[name] = function (value) {
return this.prop(name, value);
};
});
Collection$1 = global$a.extend(proto);
Selector.Collection = Collection$1;
var Collection$2 = Collection$1;
var Binding = function (settings) {
this.create = settings.create;
};
Binding.create = function (model, name) {
return new Binding({
create: function (otherModel, otherName) {
var bindings;
var fromSelfToOther = function (e) {
otherModel.set(otherName, e.value);
};
var fromOtherToSelf = function (e) {
model.set(name, e.value);
};
otherModel.on('change:' + otherName, fromOtherToSelf);
model.on('change:' + name, fromSelfToOther);
bindings = otherModel._bindings;
if (!bindings) {
bindings = otherModel._bindings = [];
otherModel.on('destroy', function () {
var i = bindings.length;
while (i--) {
bindings[i]();
}
});
}
bindings.push(function () {
model.off('change:' + name, fromSelfToOther);
});
return model.get(name);
}
});
};
var global$c = tinymce.util.Tools.resolve('tinymce.util.Observable');
function isNode(node) {
return node.nodeType > 0;
}
function isEqual(a, b) {
var k, checked;
if (a === b) {
return true;
}
if (a === null || b === null) {
return a === b;
}
if (typeof a !== 'object' || typeof b !== 'object') {
return a === b;
}
if (global$2.isArray(b)) {
if (a.length !== b.length) {
return false;
}
k = a.length;
while (k--) {
if (!isEqual(a[k], b[k])) {
return false;
}
}
}
if (isNode(a) || isNode(b)) {
return a === b;
}
checked = {};
for (k in b) {
if (!isEqual(a[k], b[k])) {
return false;
}
checked[k] = true;
}
for (k in a) {
if (!checked[k] && !isEqual(a[k], b[k])) {
return false;
}
}
return true;
}
var ObservableObject = global$a.extend({
Mixins: [global$c],
init: function (data) {
var name, value;
data = data || {};
for (name in data) {
value = data[name];
if (value instanceof Binding) {
data[name] = value.create(this, name);
}
}
this.data = data;
},
set: function (name, value) {
var key, args;
var oldValue = this.data[name];
if (value instanceof Binding) {
value = value.create(this, name);
}
if (typeof name === 'object') {
for (key in name) {
this.set(key, name[key]);
}
return this;
}
if (!isEqual(oldValue, value)) {
this.data[name] = value;
args = {
target: this,
name: name,
value: value,
oldValue: oldValue
};
this.fire('change:' + name, args);
this.fire('change', args);
}
return this;
},
get: function (name) {
return this.data[name];
},
has: function (name) {
return name in this.data;
},
bind: function (name) {
return Binding.create(this, name);
},
destroy: function () {
this.fire('destroy');
}
});
var dirtyCtrls = {}, animationFrameRequested;
var ReflowQueue = {
add: function (ctrl) {
var parent = ctrl.parent();
if (parent) {
if (!parent._layout || parent._layout.isNative()) {
return;
}
if (!dirtyCtrls[parent._id]) {
dirtyCtrls[parent._id] = parent;
}
if (!animationFrameRequested) {
animationFrameRequested = true;
global$7.requestAnimationFrame(function () {
var id, ctrl;
animationFrameRequested = false;
for (id in dirtyCtrls) {
ctrl = dirtyCtrls[id];
if (ctrl.state.get('rendered')) {
ctrl.reflow();
}
}
dirtyCtrls = {};
}, domGlobals.document.body);
}
}
},
remove: function (ctrl) {
if (dirtyCtrls[ctrl._id]) {
delete dirtyCtrls[ctrl._id];
}
}
};
var hasMouseWheelEventSupport = 'onmousewheel' in domGlobals.document;
var hasWheelEventSupport = false;
var classPrefix = 'mce-';
var Control, idCounter = 0;
var proto$1 = {
Statics: { classPrefix: classPrefix },
isRtl: function () {
return Control.rtl;
},
classPrefix: classPrefix,
init: function (settings) {
var self = this;
var classes, defaultClasses;
function applyClasses(classes) {
var i;
classes = classes.split(' ');
for (i = 0; i < classes.length; i++) {
self.classes.add(classes[i]);
}
}
self.settings = settings = global$2.extend({}, self.Defaults, settings);
self._id = settings.id || 'mceu_' + idCounter++;
self._aria = { role: settings.role };
self._elmCache = {};
self.$ = global$9;
self.state = new ObservableObject({
visible: true,
active: false,
disabled: false,
value: ''
});
self.data = new ObservableObject(settings.data);
self.classes = new ClassList(function () {
if (self.state.get('rendered')) {
self.getEl().className = this.toString();
}
});
self.classes.prefix = self.classPrefix;
classes = settings.classes;
if (classes) {
if (self.Defaults) {
defaultClasses = self.Defaults.classes;
if (defaultClasses && classes !== defaultClasses) {
applyClasses(defaultClasses);
}
}
applyClasses(classes);
}
global$2.each('title text name visible disabled active value'.split(' '), function (name) {
if (name in settings) {
self[name](settings[name]);
}
});
self.on('click', function () {
if (self.disabled()) {
return false;
}
});
self.settings = settings;
self.borderBox = BoxUtils.parseBox(settings.border);
self.paddingBox = BoxUtils.parseBox(settings.padding);
self.marginBox = BoxUtils.parseBox(settings.margin);
if (settings.hidden) {
self.hide();
}
},
Properties: 'parent,name',
getContainerElm: function () {
var uiContainer = UiContainer.getUiContainer(this);
return uiContainer ? uiContainer : funcs.getContainer();
},
getParentCtrl: function (elm) {
var ctrl;
var lookup = this.getRoot().controlIdLookup;
while (elm && lookup) {
ctrl = lookup[elm.id];
if (ctrl) {
break;
}
elm = elm.parentNode;
}
return ctrl;
},
initLayoutRect: function () {
var self = this;
var settings = self.settings;
var borderBox, layoutRect;
var elm = self.getEl();
var width, height, minWidth, minHeight, autoResize;
var startMinWidth, startMinHeight, initialSize;
borderBox = self.borderBox = self.borderBox || BoxUtils.measureBox(elm, 'border');
self.paddingBox = self.paddingBox || BoxUtils.measureBox(elm, 'padding');
self.marginBox = self.marginBox || BoxUtils.measureBox(elm, 'margin');
initialSize = funcs.getSize(elm);
startMinWidth = settings.minWidth;
startMinHeight = settings.minHeight;
minWidth = startMinWidth || initialSize.width;
minHeight = startMinHeight || initialSize.height;
width = settings.width;
height = settings.height;
autoResize = settings.autoResize;
autoResize = typeof autoResize !== 'undefined' ? autoResize : !width && !height;
width = width || minWidth;
height = height || minHeight;
var deltaW = borderBox.left + borderBox.right;
var deltaH = borderBox.top + borderBox.bottom;
var maxW = settings.maxWidth || 65535;
var maxH = settings.maxHeight || 65535;
self._layoutRect = layoutRect = {
x: settings.x || 0,
y: settings.y || 0,
w: width,
h: height,
deltaW: deltaW,
deltaH: deltaH,
contentW: width - deltaW,
contentH: height - deltaH,
innerW: width - deltaW,
innerH: height - deltaH,
startMinWidth: startMinWidth || 0,
startMinHeight: startMinHeight || 0,
minW: Math.min(minWidth, maxW),
minH: Math.min(minHeight, maxH),
maxW: maxW,
maxH: maxH,
autoResize: autoResize,
scrollW: 0
};
self._lastLayoutRect = {};
return layoutRect;
},
layoutRect: function (newRect) {
var self = this;
var curRect = self._layoutRect, lastLayoutRect, size, deltaWidth, deltaHeight, repaintControls;
if (!curRect) {
curRect = self.initLayoutRect();
}
if (newRect) {
deltaWidth = curRect.deltaW;
deltaHeight = curRect.deltaH;
if (newRect.x !== undefined) {
curRect.x = newRect.x;
}
if (newRect.y !== undefined) {
curRect.y = newRect.y;
}
if (newRect.minW !== undefined) {
curRect.minW = newRect.minW;
}
if (newRect.minH !== undefined) {
curRect.minH = newRect.minH;
}
size = newRect.w;
if (size !== undefined) {
size = size < curRect.minW ? curRect.minW : size;
size = size > curRect.maxW ? curRect.maxW : size;
curRect.w = size;
curRect.innerW = size - deltaWidth;
}
size = newRect.h;
if (size !== undefined) {
size = size < curRect.minH ? curRect.minH : size;
size = size > curRect.maxH ? curRect.maxH : size;
curRect.h = size;
curRect.innerH = size - deltaHeight;
}
size = newRect.innerW;
if (size !== undefined) {
size = size < curRect.minW - deltaWidth ? curRect.minW - deltaWidth : size;
size = size > curRect.maxW - deltaWidth ? curRect.maxW - deltaWidth : size;
curRect.innerW = size;
curRect.w = size + deltaWidth;
}
size = newRect.innerH;
if (size !== undefined) {
size = size < curRect.minH - deltaHeight ? curRect.minH - deltaHeight : size;
size = size > curRect.maxH - deltaHeight ? curRect.maxH - deltaHeight : size;
curRect.innerH = size;
curRect.h = size + deltaHeight;
}
if (newRect.contentW !== undefined) {
curRect.contentW = newRect.contentW;
}
if (newRect.contentH !== undefined) {
curRect.contentH = newRect.contentH;
}
lastLayoutRect = self._lastLayoutRect;
if (lastLayoutRect.x !== curRect.x || lastLayoutRect.y !== curRect.y || lastLayoutRect.w !== curRect.w || lastLayoutRect.h !== curRect.h) {
repaintControls = Control.repaintControls;
if (repaintControls) {
if (repaintControls.map && !repaintControls.map[self._id]) {
repaintControls.push(self);
repaintControls.map[self._id] = true;
}
}
lastLayoutRect.x = curRect.x;
lastLayoutRect.y = curRect.y;
lastLayoutRect.w = curRect.w;
lastLayoutRect.h = curRect.h;
}
return self;
}
return curRect;
},
repaint: function () {
var self = this;
var style, bodyStyle, bodyElm, rect, borderBox;
var borderW, borderH, lastRepaintRect, round, value;
round = !domGlobals.document.createRange ? Math.round : function (value) {
return value;
};
style = self.getEl().style;
rect = self._layoutRect;
lastRepaintRect = self._lastRepaintRect || {};
borderBox = self.borderBox;
borderW = borderBox.left + borderBox.right;
borderH = borderBox.top + borderBox.bottom;
if (rect.x !== lastRepaintRect.x) {
style.left = round(rect.x) + 'px';
lastRepaintRect.x = rect.x;
}
if (rect.y !== lastRepaintRect.y) {
style.top = round(rect.y) + 'px';
lastRepaintRect.y = rect.y;
}
if (rect.w !== lastRepaintRect.w) {
value = round(rect.w - borderW);
style.width = (value >= 0 ? value : 0) + 'px';
lastRepaintRect.w = rect.w;
}
if (rect.h !== lastRepaintRect.h) {
value = round(rect.h - borderH);
style.height = (value >= 0 ? value : 0) + 'px';
lastRepaintRect.h = rect.h;
}
if (self._hasBody && rect.innerW !== lastRepaintRect.innerW) {
value = round(rect.innerW);
bodyElm = self.getEl('body');
if (bodyElm) {
bodyStyle = bodyElm.style;
bodyStyle.width = (value >= 0 ? value : 0) + 'px';
}
lastRepaintRect.innerW = rect.innerW;
}
if (self._hasBody && rect.innerH !== lastRepaintRect.innerH) {
value = round(rect.innerH);
bodyElm = bodyElm || self.getEl('body');
if (bodyElm) {
bodyStyle = bodyStyle || bodyElm.style;
bodyStyle.height = (value >= 0 ? value : 0) + 'px';
}
lastRepaintRect.innerH = rect.innerH;
}
self._lastRepaintRect = lastRepaintRect;
self.fire('repaint', {}, false);
},
updateLayoutRect: function () {
var self = this;
self.parent()._lastRect = null;
funcs.css(self.getEl(), {
width: '',
height: ''
});
self._layoutRect = self._lastRepaintRect = self._lastLayoutRect = null;
self.initLayoutRect();
},
on: function (name, callback) {
var self = this;
function resolveCallbackName(name) {
var callback, scope;
if (typeof name !== 'string') {
return name;
}
return function (e) {
if (!callback) {
self.parentsAndSelf().each(function (ctrl) {
var callbacks = ctrl.settings.callbacks;
if (callbacks && (callback = callbacks[name])) {
scope = ctrl;
return false;
}
});
}
if (!callback) {
e.action = name;
this.fire('execute', e);
return;
}
return callback.call(scope, e);
};
}
getEventDispatcher(self).on(name, resolveCallbackName(callback));
return self;
},
off: function (name, callback) {
getEventDispatcher(this).off(name, callback);
return this;
},
fire: function (name, args, bubble) {
var self = this;
args = args || {};
if (!args.control) {
args.control = self;
}
args = getEventDispatcher(self).fire(name, args);
if (bubble !== false && self.parent) {
var parent = self.parent();
while (parent && !args.isPropagationStopped()) {
parent.fire(name, args, false);
parent = parent.parent();
}
}
return args;
},
hasEventListeners: function (name) {
return getEventDispatcher(this).has(name);
},
parents: function (selector) {
var self = this;
var ctrl, parents = new Collection$2();
for (ctrl = self.parent(); ctrl; ctrl = ctrl.parent()) {
parents.add(ctrl);
}
if (selector) {
parents = parents.filter(selector);
}
return parents;
},
parentsAndSelf: function (selector) {
return new Collection$2(this).add(this.parents(selector));
},
next: function () {
var parentControls = this.parent().items();
return parentControls[parentControls.indexOf(this) + 1];
},
prev: function () {
var parentControls = this.parent().items();
return parentControls[parentControls.indexOf(this) - 1];
},
innerHtml: function (html) {
this.$el.html(html);
return this;
},
getEl: function (suffix) {
var id = suffix ? this._id + '-' + suffix : this._id;
if (!this._elmCache[id]) {
this._elmCache[id] = global$9('#' + id)[0];
}
return this._elmCache[id];
},
show: function () {
return this.visible(true);
},
hide: function () {
return this.visible(false);
},
focus: function () {
try {
this.getEl().focus();
} catch (ex) {
}
return this;
},
blur: function () {
this.getEl().blur();
return this;
},
aria: function (name, value) {
var self = this, elm = self.getEl(self.ariaTarget);
if (typeof value === 'undefined') {
return self._aria[name];
}
self._aria[name] = value;
if (self.state.get('rendered')) {
elm.setAttribute(name === 'role' ? name : 'aria-' + name, value);
}
return self;
},
encode: function (text, translate) {
if (translate !== false) {
text = this.translate(text);
}
return (text || '').replace(/[&<>"]/g, function (match) {
return '' + match.charCodeAt(0) + ';';
});
},
translate: function (text) {
return Control.translate ? Control.translate(text) : text;
},
before: function (items) {
var self = this, parent = self.parent();
if (parent) {
parent.insert(items, parent.items().indexOf(self), true);
}
return self;
},
after: function (items) {
var self = this, parent = self.parent();
if (parent) {
parent.insert(items, parent.items().indexOf(self));
}
return self;
},
remove: function () {
var self = this;
var elm = self.getEl();
var parent = self.parent();
var newItems, i;
if (self.items) {
var controls = self.items().toArray();
i = controls.length;
while (i--) {
controls[i].remove();
}
}
if (parent && parent.items) {
newItems = [];
parent.items().each(function (item) {
if (item !== self) {
newItems.push(item);
}
});
parent.items().set(newItems);
parent._lastRect = null;
}
if (self._eventsRoot && self._eventsRoot === self) {
global$9(elm).off();
}
var lookup = self.getRoot().controlIdLookup;
if (lookup) {
delete lookup[self._id];
}
if (elm && elm.parentNode) {
elm.parentNode.removeChild(elm);
}
self.state.set('rendered', false);
self.state.destroy();
self.fire('remove');
return self;
},
renderBefore: function (elm) {
global$9(elm).before(this.renderHtml());
this.postRender();
return this;
},
renderTo: function (elm) {
global$9(elm || this.getContainerElm()).append(this.renderHtml());
this.postRender();
return this;
},
preRender: function () {
},
render: function () {
},
renderHtml: function () {
return '
';
},
postRender: function () {
var self = this;
var settings = self.settings;
var elm, box, parent, name, parentEventsRoot;
self.$el = global$9(self.getEl());
self.state.set('rendered', true);
for (name in settings) {
if (name.indexOf('on') === 0) {
self.on(name.substr(2), settings[name]);
}
}
if (self._eventsRoot) {
for (parent = self.parent(); !parentEventsRoot && parent; parent = parent.parent()) {
parentEventsRoot = parent._eventsRoot;
}
if (parentEventsRoot) {
for (name in parentEventsRoot._nativeEvents) {
self._nativeEvents[name] = true;
}
}
}
bindPendingEvents(self);
if (settings.style) {
elm = self.getEl();
if (elm) {
elm.setAttribute('style', settings.style);
elm.style.cssText = settings.style;
}
}
if (self.settings.border) {
box = self.borderBox;
self.$el.css({
'border-top-width': box.top,
'border-right-width': box.right,
'border-bottom-width': box.bottom,
'border-left-width': box.left
});
}
var root = self.getRoot();
if (!root.controlIdLookup) {
root.controlIdLookup = {};
}
root.controlIdLookup[self._id] = self;
for (var key in self._aria) {
self.aria(key, self._aria[key]);
}
if (self.state.get('visible') === false) {
self.getEl().style.display = 'none';
}
self.bindStates();
self.state.on('change:visible', function (e) {
var state = e.value;
var parentCtrl;
if (self.state.get('rendered')) {
self.getEl().style.display = state === false ? 'none' : '';
self.getEl().getBoundingClientRect();
}
parentCtrl = self.parent();
if (parentCtrl) {
parentCtrl._lastRect = null;
}
self.fire(state ? 'show' : 'hide');
ReflowQueue.add(self);
});
self.fire('postrender', {}, false);
},
bindStates: function () {
},
scrollIntoView: function (align) {
function getOffset(elm, rootElm) {
var x, y, parent = elm;
x = y = 0;
while (parent && parent !== rootElm && parent.nodeType) {
x += parent.offsetLeft || 0;
y += parent.offsetTop || 0;
parent = parent.offsetParent;
}
return {
x: x,
y: y
};
}
var elm = this.getEl(), parentElm = elm.parentNode;
var x, y, width, height, parentWidth, parentHeight;
var pos = getOffset(elm, parentElm);
x = pos.x;
y = pos.y;
width = elm.offsetWidth;
height = elm.offsetHeight;
parentWidth = parentElm.clientWidth;
parentHeight = parentElm.clientHeight;
if (align === 'end') {
x -= parentWidth - width;
y -= parentHeight - height;
} else if (align === 'center') {
x -= parentWidth / 2 - width / 2;
y -= parentHeight / 2 - height / 2;
}
parentElm.scrollLeft = x;
parentElm.scrollTop = y;
return this;
},
getRoot: function () {
var ctrl = this, rootControl;
var parents = [];
while (ctrl) {
if (ctrl.rootControl) {
rootControl = ctrl.rootControl;
break;
}
parents.push(ctrl);
rootControl = ctrl;
ctrl = ctrl.parent();
}
if (!rootControl) {
rootControl = this;
}
var i = parents.length;
while (i--) {
parents[i].rootControl = rootControl;
}
return rootControl;
},
reflow: function () {
ReflowQueue.remove(this);
var parent = this.parent();
if (parent && parent._layout && !parent._layout.isNative()) {
parent.reflow();
}
return this;
}
};
global$2.each('text title visible disabled active value'.split(' '), function (name) {
proto$1[name] = function (value) {
if (arguments.length === 0) {
return this.state.get(name);
}
if (typeof value !== 'undefined') {
this.state.set(name, value);
}
return this;
};
});
Control = global$a.extend(proto$1);
function getEventDispatcher(obj) {
if (!obj._eventDispatcher) {
obj._eventDispatcher = new global$b({
scope: obj,
toggleEvent: function (name, state) {
if (state && global$b.isNative(name)) {
if (!obj._nativeEvents) {
obj._nativeEvents = {};
}
obj._nativeEvents[name] = true;
if (obj.state.get('rendered')) {
bindPendingEvents(obj);
}
}
}
});
}
return obj._eventDispatcher;
}
function bindPendingEvents(eventCtrl) {
var i, l, parents, eventRootCtrl, nativeEvents, name;
function delegate(e) {
var control = eventCtrl.getParentCtrl(e.target);
if (control) {
control.fire(e.type, e);
}
}
function mouseLeaveHandler() {
var ctrl = eventRootCtrl._lastHoverCtrl;
if (ctrl) {
ctrl.fire('mouseleave', { target: ctrl.getEl() });
ctrl.parents().each(function (ctrl) {
ctrl.fire('mouseleave', { target: ctrl.getEl() });
});
eventRootCtrl._lastHoverCtrl = null;
}
}
function mouseEnterHandler(e) {
var ctrl = eventCtrl.getParentCtrl(e.target), lastCtrl = eventRootCtrl._lastHoverCtrl, idx = 0, i, parents, lastParents;
if (ctrl !== lastCtrl) {
eventRootCtrl._lastHoverCtrl = ctrl;
parents = ctrl.parents().toArray().reverse();
parents.push(ctrl);
if (lastCtrl) {
lastParents = lastCtrl.parents().toArray().reverse();
lastParents.push(lastCtrl);
for (idx = 0; idx < lastParents.length; idx++) {
if (parents[idx] !== lastParents[idx]) {
break;
}
}
for (i = lastParents.length - 1; i >= idx; i--) {
lastCtrl = lastParents[i];
lastCtrl.fire('mouseleave', { target: lastCtrl.getEl() });
}
}
for (i = idx; i < parents.length; i++) {
ctrl = parents[i];
ctrl.fire('mouseenter', { target: ctrl.getEl() });
}
}
}
function fixWheelEvent(e) {
e.preventDefault();
if (e.type === 'mousewheel') {
e.deltaY = -1 / 40 * e.wheelDelta;
if (e.wheelDeltaX) {
e.deltaX = -1 / 40 * e.wheelDeltaX;
}
} else {
e.deltaX = 0;
e.deltaY = e.detail;
}
e = eventCtrl.fire('wheel', e);
}
nativeEvents = eventCtrl._nativeEvents;
if (nativeEvents) {
parents = eventCtrl.parents().toArray();
parents.unshift(eventCtrl);
for (i = 0, l = parents.length; !eventRootCtrl && i < l; i++) {
eventRootCtrl = parents[i]._eventsRoot;
}
if (!eventRootCtrl) {
eventRootCtrl = parents[parents.length - 1] || eventCtrl;
}
eventCtrl._eventsRoot = eventRootCtrl;
for (l = i, i = 0; i < l; i++) {
parents[i]._eventsRoot = eventRootCtrl;
}
var eventRootDelegates = eventRootCtrl._delegates;
if (!eventRootDelegates) {
eventRootDelegates = eventRootCtrl._delegates = {};
}
for (name in nativeEvents) {
if (!nativeEvents) {
return false;
}
if (name === 'wheel' && !hasWheelEventSupport) {
if (hasMouseWheelEventSupport) {
global$9(eventCtrl.getEl()).on('mousewheel', fixWheelEvent);
} else {
global$9(eventCtrl.getEl()).on('DOMMouseScroll', fixWheelEvent);
}
continue;
}
if (name === 'mouseenter' || name === 'mouseleave') {
if (!eventRootCtrl._hasMouseEnter) {
global$9(eventRootCtrl.getEl()).on('mouseleave', mouseLeaveHandler).on('mouseover', mouseEnterHandler);
eventRootCtrl._hasMouseEnter = 1;
}
} else if (!eventRootDelegates[name]) {
global$9(eventRootCtrl.getEl()).on(name, delegate);
eventRootDelegates[name] = true;
}
nativeEvents[name] = false;
}
}
}
var Control$1 = Control;
var hasTabstopData = function (elm) {
return elm.getAttribute('data-mce-tabstop') ? true : false;
};
function KeyboardNavigation (settings) {
var root = settings.root;
var focusedElement, focusedControl;
function isElement(node) {
return node && node.nodeType === 1;
}
try {
focusedElement = domGlobals.document.activeElement;
} catch (ex) {
focusedElement = domGlobals.document.body;
}
focusedControl = root.getParentCtrl(focusedElement);
function getRole(elm) {
elm = elm || focusedElement;
if (isElement(elm)) {
return elm.getAttribute('role');
}
return null;
}
function getParentRole(elm) {
var role, parent = elm || focusedElement;
while (parent = parent.parentNode) {
if (role = getRole(parent)) {
return role;
}
}
}
function getAriaProp(name) {
var elm = focusedElement;
if (isElement(elm)) {
return elm.getAttribute('aria-' + name);
}
}
function isTextInputElement(elm) {
var tagName = elm.tagName.toUpperCase();
return tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT';
}
function canFocus(elm) {
if (isTextInputElement(elm) && !elm.hidden) {
return true;
}
if (hasTabstopData(elm)) {
return true;
}
if (/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(getRole(elm))) {
return true;
}
return false;
}
function getFocusElements(elm) {
var elements = [];
function collect(elm) {
if (elm.nodeType !== 1 || elm.style.display === 'none' || elm.disabled) {
return;
}
if (canFocus(elm)) {
elements.push(elm);
}
for (var i = 0; i < elm.childNodes.length; i++) {
collect(elm.childNodes[i]);
}
}
collect(elm || root.getEl());
return elements;
}
function getNavigationRoot(targetControl) {
var navigationRoot, controls;
targetControl = targetControl || focusedControl;
controls = targetControl.parents().toArray();
controls.unshift(targetControl);
for (var i = 0; i < controls.length; i++) {
navigationRoot = controls[i];
if (navigationRoot.settings.ariaRoot) {
break;
}
}
return navigationRoot;
}
function focusFirst(targetControl) {
var navigationRoot = getNavigationRoot(targetControl);
var focusElements = getFocusElements(navigationRoot.getEl());
if (navigationRoot.settings.ariaRemember && 'lastAriaIndex' in navigationRoot) {
moveFocusToIndex(navigationRoot.lastAriaIndex, focusElements);
} else {
moveFocusToIndex(0, focusElements);
}
}
function moveFocusToIndex(idx, elements) {
if (idx < 0) {
idx = elements.length - 1;
} else if (idx >= elements.length) {
idx = 0;
}
if (elements[idx]) {
elements[idx].focus();
}
return idx;
}
function moveFocus(dir, elements) {
var idx = -1;
var navigationRoot = getNavigationRoot();
elements = elements || getFocusElements(navigationRoot.getEl());
for (var i = 0; i < elements.length; i++) {
if (elements[i] === focusedElement) {
idx = i;
}
}
idx += dir;
navigationRoot.lastAriaIndex = moveFocusToIndex(idx, elements);
}
function left() {
var parentRole = getParentRole();
if (parentRole === 'tablist') {
moveFocus(-1, getFocusElements(focusedElement.parentNode));
} else if (focusedControl.parent().submenu) {
cancel();
} else {
moveFocus(-1);
}
}
function right() {
var role = getRole(), parentRole = getParentRole();
if (parentRole === 'tablist') {
moveFocus(1, getFocusElements(focusedElement.parentNode));
} else if (role === 'menuitem' && parentRole === 'menu' && getAriaProp('haspopup')) {
enter();
} else {
moveFocus(1);
}
}
function up() {
moveFocus(-1);
}
function down() {
var role = getRole(), parentRole = getParentRole();
if (role === 'menuitem' && parentRole === 'menubar') {
enter();
} else if (role === 'button' && getAriaProp('haspopup')) {
enter({ key: 'down' });
} else {
moveFocus(1);
}
}
function tab(e) {
var parentRole = getParentRole();
if (parentRole === 'tablist') {
var elm = getFocusElements(focusedControl.getEl('body'))[0];
if (elm) {
elm.focus();
}
} else {
moveFocus(e.shiftKey ? -1 : 1);
}
}
function cancel() {
focusedControl.fire('cancel');
}
function enter(aria) {
aria = aria || {};
focusedControl.fire('click', {
target: focusedElement,
aria: aria
});
}
root.on('keydown', function (e) {
function handleNonTabOrEscEvent(e, handler) {
if (isTextInputElement(focusedElement) || hasTabstopData(focusedElement)) {
return;
}
if (getRole(focusedElement) === 'slider') {
return;
}
if (handler(e) !== false) {
e.preventDefault();
}
}
if (e.isDefaultPrevented()) {
return;
}
switch (e.keyCode) {
case 37:
handleNonTabOrEscEvent(e, left);
break;
case 39:
handleNonTabOrEscEvent(e, right);
break;
case 38:
handleNonTabOrEscEvent(e, up);
break;
case 40:
handleNonTabOrEscEvent(e, down);
break;
case 27:
cancel();
break;
case 14:
case 13:
case 32:
handleNonTabOrEscEvent(e, enter);
break;
case 9:
tab(e);
e.preventDefault();
break;
}
});
root.on('focusin', function (e) {
focusedElement = e.target;
focusedControl = e.control;
});
return { focusFirst: focusFirst };
}
var selectorCache = {};
var Container = Control$1.extend({
init: function (settings) {
var self = this;
self._super(settings);
settings = self.settings;
if (settings.fixed) {
self.state.set('fixed', true);
}
self._items = new Collection$2();
if (self.isRtl()) {
self.classes.add('rtl');
}
self.bodyClasses = new ClassList(function () {
if (self.state.get('rendered')) {
self.getEl('body').className = this.toString();
}
});
self.bodyClasses.prefix = self.classPrefix;
self.classes.add('container');
self.bodyClasses.add('container-body');
if (settings.containerCls) {
self.classes.add(settings.containerCls);
}
self._layout = global$4.create((settings.layout || '') + 'layout');
if (self.settings.items) {
self.add(self.settings.items);
} else {
self.add(self.render());
}
self._hasBody = true;
},
items: function () {
return this._items;
},
find: function (selector) {
selector = selectorCache[selector] = selectorCache[selector] || new Selector(selector);
return selector.find(this);
},
add: function (items) {
var self = this;
self.items().add(self.create(items)).parent(self);
return self;
},
focus: function (keyboard) {
var self = this;
var focusCtrl, keyboardNav, items;
if (keyboard) {
keyboardNav = self.keyboardNav || self.parents().eq(-1)[0].keyboardNav;
if (keyboardNav) {
keyboardNav.focusFirst(self);
return;
}
}
items = self.find('*');
if (self.statusbar) {
items.add(self.statusbar.items());
}
items.each(function (ctrl) {
if (ctrl.settings.autofocus) {
focusCtrl = null;
return false;
}
if (ctrl.canFocus) {
focusCtrl = focusCtrl || ctrl;
}
});
if (focusCtrl) {
focusCtrl.focus();
}
return self;
},
replace: function (oldItem, newItem) {
var ctrlElm;
var items = this.items();
var i = items.length;
while (i--) {
if (items[i] === oldItem) {
items[i] = newItem;
break;
}
}
if (i >= 0) {
ctrlElm = newItem.getEl();
if (ctrlElm) {
ctrlElm.parentNode.removeChild(ctrlElm);
}
ctrlElm = oldItem.getEl();
if (ctrlElm) {
ctrlElm.parentNode.removeChild(ctrlElm);
}
}
newItem.parent(this);
},
create: function (items) {
var self = this;
var settings;
var ctrlItems = [];
if (!global$2.isArray(items)) {
items = [items];
}
global$2.each(items, function (item) {
if (item) {
if (!(item instanceof Control$1)) {
if (typeof item === 'string') {
item = { type: item };
}
settings = global$2.extend({}, self.settings.defaults, item);
item.type = settings.type = settings.type || item.type || self.settings.defaultType || (settings.defaults ? settings.defaults.type : null);
item = global$4.create(settings);
}
ctrlItems.push(item);
}
});
return ctrlItems;
},
renderNew: function () {
var self = this;
self.items().each(function (ctrl, index) {
var containerElm;
ctrl.parent(self);
if (!ctrl.state.get('rendered')) {
containerElm = self.getEl('body');
if (containerElm.hasChildNodes() && index <= containerElm.childNodes.length - 1) {
global$9(containerElm.childNodes[index]).before(ctrl.renderHtml());
} else {
global$9(containerElm).append(ctrl.renderHtml());
}
ctrl.postRender();
ReflowQueue.add(ctrl);
}
});
self._layout.applyClasses(self.items().filter(':visible'));
self._lastRect = null;
return self;
},
append: function (items) {
return this.add(items).renderNew();
},
prepend: function (items) {
var self = this;
self.items().set(self.create(items).concat(self.items().toArray()));
return self.renderNew();
},
insert: function (items, index, before) {
var self = this;
var curItems, beforeItems, afterItems;
items = self.create(items);
curItems = self.items();
if (!before && index < curItems.length - 1) {
index += 1;
}
if (index >= 0 && index < curItems.length) {
beforeItems = curItems.slice(0, index).toArray();
afterItems = curItems.slice(index).toArray();
curItems.set(beforeItems.concat(items, afterItems));
}
return self.renderNew();
},
fromJSON: function (data) {
var self = this;
for (var name in data) {
self.find('#' + name).value(data[name]);
}
return self;
},
toJSON: function () {
var self = this, data = {};
self.find('*').each(function (ctrl) {
var name = ctrl.name(), value = ctrl.value();
if (name && typeof value !== 'undefined') {
data[name] = value;
}
});
return data;
},
renderHtml: function () {
var self = this, layout = self._layout, role = this.settings.role;
self.preRender();
layout.preRender(self);
return '' + '
' + (self.settings.html || '') + layout.renderHtml(self) + '
' + '
';
},
postRender: function () {
var self = this;
var box;
self.items().exec('postRender');
self._super();
self._layout.postRender(self);
self.state.set('rendered', true);
if (self.settings.style) {
self.$el.css(self.settings.style);
}
if (self.settings.border) {
box = self.borderBox;
self.$el.css({
'border-top-width': box.top,
'border-right-width': box.right,
'border-bottom-width': box.bottom,
'border-left-width': box.left
});
}
if (!self.parent()) {
self.keyboardNav = KeyboardNavigation({ root: self });
}
return self;
},
initLayoutRect: function () {
var self = this, layoutRect = self._super();
self._layout.recalc(self);
return layoutRect;
},
recalc: function () {
var self = this;
var rect = self._layoutRect;
var lastRect = self._lastRect;
if (!lastRect || lastRect.w !== rect.w || lastRect.h !== rect.h) {
self._layout.recalc(self);
rect = self.layoutRect();
self._lastRect = {
x: rect.x,
y: rect.y,
w: rect.w,
h: rect.h
};
return true;
}
},
reflow: function () {
var i;
ReflowQueue.remove(this);
if (this.visible()) {
Control$1.repaintControls = [];
Control$1.repaintControls.map = {};
this.recalc();
i = Control$1.repaintControls.length;
while (i--) {
Control$1.repaintControls[i].repaint();
}
if (this.settings.layout !== 'flow' && this.settings.layout !== 'stack') {
this.repaint();
}
Control$1.repaintControls = [];
}
return this;
}
});
function getDocumentSize(doc) {
var documentElement, body, scrollWidth, clientWidth;
var offsetWidth, scrollHeight, clientHeight, offsetHeight;
var max = Math.max;
documentElement = doc.documentElement;
body = doc.body;
scrollWidth = max(documentElement.scrollWidth, body.scrollWidth);
clientWidth = max(documentElement.clientWidth, body.clientWidth);
offsetWidth = max(documentElement.offsetWidth, body.offsetWidth);
scrollHeight = max(documentElement.scrollHeight, body.scrollHeight);
clientHeight = max(documentElement.clientHeight, body.clientHeight);
offsetHeight = max(documentElement.offsetHeight, body.offsetHeight);
return {
width: scrollWidth < offsetWidth ? clientWidth : scrollWidth,
height: scrollHeight < offsetHeight ? clientHeight : scrollHeight
};
}
function updateWithTouchData(e) {
var keys, i;
if (e.changedTouches) {
keys = 'screenX screenY pageX pageY clientX clientY'.split(' ');
for (i = 0; i < keys.length; i++) {
e[keys[i]] = e.changedTouches[0][keys[i]];
}
}
}
function DragHelper (id, settings) {
var $eventOverlay;
var doc = settings.document || domGlobals.document;
var downButton;
var start, stop, drag, startX, startY;
settings = settings || {};
var handleElement = doc.getElementById(settings.handle || id);
start = function (e) {
var docSize = getDocumentSize(doc);
var handleElm, cursor;
updateWithTouchData(e);
e.preventDefault();
downButton = e.button;
handleElm = handleElement;
startX = e.screenX;
startY = e.screenY;
if (domGlobals.window.getComputedStyle) {
cursor = domGlobals.window.getComputedStyle(handleElm, null).getPropertyValue('cursor');
} else {
cursor = handleElm.runtimeStyle.cursor;
}
$eventOverlay = global$9('
').css({
position: 'absolute',
top: 0,
left: 0,
width: docSize.width,
height: docSize.height,
zIndex: 2147483647,
opacity: 0.0001,
cursor: cursor
}).appendTo(doc.body);
global$9(doc).on('mousemove touchmove', drag).on('mouseup touchend', stop);
settings.start(e);
};
drag = function (e) {
updateWithTouchData(e);
if (e.button !== downButton) {
return stop(e);
}
e.deltaX = e.screenX - startX;
e.deltaY = e.screenY - startY;
e.preventDefault();
settings.drag(e);
};
stop = function (e) {
updateWithTouchData(e);
global$9(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop);
$eventOverlay.remove();
if (settings.stop) {
settings.stop(e);
}
};
this.destroy = function () {
global$9(handleElement).off();
};
global$9(handleElement).on('mousedown touchstart', start);
}
var Scrollable = {
init: function () {
var self = this;
self.on('repaint', self.renderScroll);
},
renderScroll: function () {
var self = this, margin = 2;
function repaintScroll() {
var hasScrollH, hasScrollV, bodyElm;
function repaintAxis(axisName, posName, sizeName, contentSizeName, hasScroll, ax) {
var containerElm, scrollBarElm, scrollThumbElm;
var containerSize, scrollSize, ratio, rect;
var posNameLower, sizeNameLower;
scrollBarElm = self.getEl('scroll' + axisName);
if (scrollBarElm) {
posNameLower = posName.toLowerCase();
sizeNameLower = sizeName.toLowerCase();
global$9(self.getEl('absend')).css(posNameLower, self.layoutRect()[contentSizeName] - 1);
if (!hasScroll) {
global$9(scrollBarElm).css('display', 'none');
return;
}
global$9(scrollBarElm).css('display', 'block');
containerElm = self.getEl('body');
scrollThumbElm = self.getEl('scroll' + axisName + 't');
containerSize = containerElm['client' + sizeName] - margin * 2;
containerSize -= hasScrollH && hasScrollV ? scrollBarElm['client' + ax] : 0;
scrollSize = containerElm['scroll' + sizeName];
ratio = containerSize / scrollSize;
rect = {};
rect[posNameLower] = containerElm['offset' + posName] + margin;
rect[sizeNameLower] = containerSize;
global$9(scrollBarElm).css(rect);
rect = {};
rect[posNameLower] = containerElm['scroll' + posName] * ratio;
rect[sizeNameLower] = containerSize * ratio;
global$9(scrollThumbElm).css(rect);
}
}
bodyElm = self.getEl('body');
hasScrollH = bodyElm.scrollWidth > bodyElm.clientWidth;
hasScrollV = bodyElm.scrollHeight > bodyElm.clientHeight;
repaintAxis('h', 'Left', 'Width', 'contentW', hasScrollH, 'Height');
repaintAxis('v', 'Top', 'Height', 'contentH', hasScrollV, 'Width');
}
function addScroll() {
function addScrollAxis(axisName, posName, sizeName, deltaPosName, ax) {
var scrollStart;
var axisId = self._id + '-scroll' + axisName, prefix = self.classPrefix;
global$9(self.getEl()).append('');
self.draghelper = new DragHelper(axisId + 't', {
start: function () {
scrollStart = self.getEl('body')['scroll' + posName];
global$9('#' + axisId).addClass(prefix + 'active');
},
drag: function (e) {
var ratio, hasScrollH, hasScrollV, containerSize;
var layoutRect = self.layoutRect();
hasScrollH = layoutRect.contentW > layoutRect.innerW;
hasScrollV = layoutRect.contentH > layoutRect.innerH;
containerSize = self.getEl('body')['client' + sizeName] - margin * 2;
containerSize -= hasScrollH && hasScrollV ? self.getEl('scroll' + axisName)['client' + ax] : 0;
ratio = containerSize / self.getEl('body')['scroll' + sizeName];
self.getEl('body')['scroll' + posName] = scrollStart + e['delta' + deltaPosName] / ratio;
},
stop: function () {
global$9('#' + axisId).removeClass(prefix + 'active');
}
});
}
self.classes.add('scroll');
addScrollAxis('v', 'Top', 'Height', 'Y', 'Width');
addScrollAxis('h', 'Left', 'Width', 'X', 'Height');
}
if (self.settings.autoScroll) {
if (!self._hasScroll) {
self._hasScroll = true;
addScroll();
self.on('wheel', function (e) {
var bodyEl = self.getEl('body');
bodyEl.scrollLeft += (e.deltaX || 0) * 10;
bodyEl.scrollTop += e.deltaY * 10;
repaintScroll();
});
global$9(self.getEl('body')).on('scroll', repaintScroll);
}
repaintScroll();
}
}
};
var Panel = Container.extend({
Defaults: {
layout: 'fit',
containerCls: 'panel'
},
Mixins: [Scrollable],
renderHtml: function () {
var self = this;
var layout = self._layout;
var innerHtml = self.settings.html;
self.preRender();
layout.preRender(self);
if (typeof innerHtml === 'undefined') {
innerHtml = '' + layout.renderHtml(self) + '
';
} else {
if (typeof innerHtml === 'function') {
innerHtml = innerHtml.call(self);
}
self._hasBody = false;
}
return '' + (self._preBodyHtml || '') + innerHtml + '
';
}
});
var Resizable = {
resizeToContent: function () {
this._layoutRect.autoResize = true;
this._lastRect = null;
this.reflow();
},
resizeTo: function (w, h) {
if (w <= 1 || h <= 1) {
var rect = funcs.getWindowSize();
w = w <= 1 ? w * rect.w : w;
h = h <= 1 ? h * rect.h : h;
}
this._layoutRect.autoResize = false;
return this.layoutRect({
minW: w,
minH: h,
w: w,
h: h
}).reflow();
},
resizeBy: function (dw, dh) {
var self = this, rect = self.layoutRect();
return self.resizeTo(rect.w + dw, rect.h + dh);
}
};
var documentClickHandler, documentScrollHandler, windowResizeHandler;
var visiblePanels = [];
var zOrder = [];
var hasModal;
function isChildOf(ctrl, parent) {
while (ctrl) {
if (ctrl === parent) {
return true;
}
ctrl = ctrl.parent();
}
}
function skipOrHidePanels(e) {
var i = visiblePanels.length;
while (i--) {
var panel = visiblePanels[i], clickCtrl = panel.getParentCtrl(e.target);
if (panel.settings.autohide) {
if (clickCtrl) {
if (isChildOf(clickCtrl, panel) || panel.parent() === clickCtrl) {
continue;
}
}
e = panel.fire('autohide', { target: e.target });
if (!e.isDefaultPrevented()) {
panel.hide();
}
}
}
}
function bindDocumentClickHandler() {
if (!documentClickHandler) {
documentClickHandler = function (e) {
if (e.button === 2) {
return;
}
skipOrHidePanels(e);
};
global$9(domGlobals.document).on('click touchstart', documentClickHandler);
}
}
function bindDocumentScrollHandler() {
if (!documentScrollHandler) {
documentScrollHandler = function () {
var i;
i = visiblePanels.length;
while (i--) {
repositionPanel(visiblePanels[i]);
}
};
global$9(domGlobals.window).on('scroll', documentScrollHandler);
}
}
function bindWindowResizeHandler() {
if (!windowResizeHandler) {
var docElm_1 = domGlobals.document.documentElement;
var clientWidth_1 = docElm_1.clientWidth, clientHeight_1 = docElm_1.clientHeight;
windowResizeHandler = function () {
if (!domGlobals.document.all || clientWidth_1 !== docElm_1.clientWidth || clientHeight_1 !== docElm_1.clientHeight) {
clientWidth_1 = docElm_1.clientWidth;
clientHeight_1 = docElm_1.clientHeight;
FloatPanel.hideAll();
}
};
global$9(domGlobals.window).on('resize', windowResizeHandler);
}
}
function repositionPanel(panel) {
var scrollY = funcs.getViewPort().y;
function toggleFixedChildPanels(fixed, deltaY) {
var parent;
for (var i = 0; i < visiblePanels.length; i++) {
if (visiblePanels[i] !== panel) {
parent = visiblePanels[i].parent();
while (parent && (parent = parent.parent())) {
if (parent === panel) {
visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint();
}
}
}
}
}
if (panel.settings.autofix) {
if (!panel.state.get('fixed')) {
panel._autoFixY = panel.layoutRect().y;
if (panel._autoFixY < scrollY) {
panel.fixed(true).layoutRect({ y: 0 }).repaint();
toggleFixedChildPanels(true, scrollY - panel._autoFixY);
}
} else {
if (panel._autoFixY > scrollY) {
panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint();
toggleFixedChildPanels(false, panel._autoFixY - scrollY);
}
}
}
}
function addRemove(add, ctrl) {
var i, zIndex = FloatPanel.zIndex || 65535, topModal;
if (add) {
zOrder.push(ctrl);
} else {
i = zOrder.length;
while (i--) {
if (zOrder[i] === ctrl) {
zOrder.splice(i, 1);
}
}
}
if (zOrder.length) {
for (i = 0; i < zOrder.length; i++) {
if (zOrder[i].modal) {
zIndex++;
topModal = zOrder[i];
}
zOrder[i].getEl().style.zIndex = zIndex;
zOrder[i].zIndex = zIndex;
zIndex++;
}
}
var modalBlockEl = global$9('#' + ctrl.classPrefix + 'modal-block', ctrl.getContainerElm())[0];
if (topModal) {
global$9(modalBlockEl).css('z-index', topModal.zIndex - 1);
} else if (modalBlockEl) {
modalBlockEl.parentNode.removeChild(modalBlockEl);
hasModal = false;
}
FloatPanel.currentZIndex = zIndex;
}
var FloatPanel = Panel.extend({
Mixins: [
Movable,
Resizable
],
init: function (settings) {
var self = this;
self._super(settings);
self._eventsRoot = self;
self.classes.add('floatpanel');
if (settings.autohide) {
bindDocumentClickHandler();
bindWindowResizeHandler();
visiblePanels.push(self);
}
if (settings.autofix) {
bindDocumentScrollHandler();
self.on('move', function () {
repositionPanel(this);
});
}
self.on('postrender show', function (e) {
if (e.control === self) {
var $modalBlockEl_1;
var prefix_1 = self.classPrefix;
if (self.modal && !hasModal) {
$modalBlockEl_1 = global$9('#' + prefix_1 + 'modal-block', self.getContainerElm());
if (!$modalBlockEl_1[0]) {
$modalBlockEl_1 = global$9('
').appendTo(self.getContainerElm());
}
global$7.setTimeout(function () {
$modalBlockEl_1.addClass(prefix_1 + 'in');
global$9(self.getEl()).addClass(prefix_1 + 'in');
});
hasModal = true;
}
addRemove(true, self);
}
});
self.on('show', function () {
self.parents().each(function (ctrl) {
if (ctrl.state.get('fixed')) {
self.fixed(true);
return false;
}
});
});
if (settings.popover) {
self._preBodyHtml = '
';
self.classes.add('popover').add('bottom').add(self.isRtl() ? 'end' : 'start');
}
self.aria('label', settings.ariaLabel);
self.aria('labelledby', self._id);
self.aria('describedby', self.describedBy || self._id + '-none');
},
fixed: function (state) {
var self = this;
if (self.state.get('fixed') !== state) {
if (self.state.get('rendered')) {
var viewport = funcs.getViewPort();
if (state) {
self.layoutRect().y -= viewport.y;
} else {
self.layoutRect().y += viewport.y;
}
}
self.classes.toggle('fixed', state);
self.state.set('fixed', state);
}
return self;
},
show: function () {
var self = this;
var i;
var state = self._super();
i = visiblePanels.length;
while (i--) {
if (visiblePanels[i] === self) {
break;
}
}
if (i === -1) {
visiblePanels.push(self);
}
return state;
},
hide: function () {
removeVisiblePanel(this);
addRemove(false, this);
return this._super();
},
hideAll: function () {
FloatPanel.hideAll();
},
close: function () {
var self = this;
if (!self.fire('close').isDefaultPrevented()) {
self.remove();
addRemove(false, self);
}
return self;
},
remove: function () {
removeVisiblePanel(this);
this._super();
},
postRender: function () {
var self = this;
if (self.settings.bodyRole) {
this.getEl('body').setAttribute('role', self.settings.bodyRole);
}
return self._super();
}
});
FloatPanel.hideAll = function () {
var i = visiblePanels.length;
while (i--) {
var panel = visiblePanels[i];
if (panel && panel.settings.autohide) {
panel.hide();
visiblePanels.splice(i, 1);
}
}
};
function removeVisiblePanel(panel) {
var i;
i = visiblePanels.length;
while (i--) {
if (visiblePanels[i] === panel) {
visiblePanels.splice(i, 1);
}
}
i = zOrder.length;
while (i--) {
if (zOrder[i] === panel) {
zOrder.splice(i, 1);
}
}
}
var isFixed$1 = function (inlineToolbarContainer, editor) {
return !!(inlineToolbarContainer && !editor.settings.ui_container);
};
var render$1 = function (editor, theme, args) {
var panel, inlineToolbarContainer;
var DOM = global$3.DOM;
var fixedToolbarContainer = getFixedToolbarContainer(editor);
if (fixedToolbarContainer) {
inlineToolbarContainer = DOM.select(fixedToolbarContainer)[0];
}
var reposition = function () {
if (panel && panel.moveRel && panel.visible() && !panel._fixed) {
var scrollContainer = editor.selection.getScrollContainer(), body = editor.getBody();
var deltaX = 0, deltaY = 0;
if (scrollContainer) {
var bodyPos = DOM.getPos(body), scrollContainerPos = DOM.getPos(scrollContainer);
deltaX = Math.max(0, scrollContainerPos.x - bodyPos.x);
deltaY = Math.max(0, scrollContainerPos.y - bodyPos.y);
}
panel.fixed(false).moveRel(body, editor.rtl ? [
'tr-br',
'br-tr'
] : [
'tl-bl',
'bl-tl',
'tr-br'
]).moveBy(deltaX, deltaY);
}
};
var show = function () {
if (panel) {
panel.show();
reposition();
DOM.addClass(editor.getBody(), 'mce-edit-focus');
}
};
var hide = function () {
if (panel) {
panel.hide();
FloatPanel.hideAll();
DOM.removeClass(editor.getBody(), 'mce-edit-focus');
}
};
var render = function () {
if (panel) {
if (!panel.visible()) {
show();
}
return;
}
panel = theme.panel = global$4.create({
type: inlineToolbarContainer ? 'panel' : 'floatpanel',
role: 'application',
classes: 'tinymce tinymce-inline',
layout: 'flex',
direction: 'column',
align: 'stretch',
autohide: false,
autofix: true,
fixed: isFixed$1(inlineToolbarContainer, editor),
border: 1,
items: [
hasMenubar(editor) === false ? null : {
type: 'menubar',
border: '0 0 1 0',
items: Menubar.createMenuButtons(editor)
},
Toolbar.createToolbars(editor, getToolbarSize(editor))
]
});
UiContainer.setUiContainer(editor, panel);
Events.fireBeforeRenderUI(editor);
if (inlineToolbarContainer) {
panel.renderTo(inlineToolbarContainer).reflow();
} else {
panel.renderTo().reflow();
}
A11y.addKeys(editor, panel);
show();
ContextToolbars.addContextualToolbars(editor);
editor.on('nodeChange', reposition);
editor.on('ResizeWindow', reposition);
editor.on('activate', show);
editor.on('deactivate', hide);
editor.nodeChanged();
};
editor.settings.content_editable = true;
editor.on('focus', function () {
if (isSkinDisabled(editor) === false && args.skinUiCss) {
DOM.styleSheetLoader.load(args.skinUiCss, render, render);
} else {
render();
}
});
editor.on('blur hide', hide);
editor.on('remove', function () {
if (panel) {
panel.remove();
panel = null;
}
});
if (isSkinDisabled(editor) === false && args.skinUiCss) {
DOM.styleSheetLoader.load(args.skinUiCss, SkinLoaded.fireSkinLoaded(editor));
} else {
SkinLoaded.fireSkinLoaded(editor)();
}
return {};
};
var Inline = { render: render$1 };
function Throbber (elm, inline) {
var self = this;
var state;
var classPrefix = Control$1.classPrefix;
var timer;
self.show = function (time, callback) {
function render() {
if (state) {
global$9(elm).append('
');
if (callback) {
callback();
}
}
}
self.hide();
state = true;
if (time) {
timer = global$7.setTimeout(render, time);
} else {
render();
}
return self;
};
self.hide = function () {
var child = elm.lastChild;
global$7.clearTimeout(timer);
if (child && child.className.indexOf('throbber') !== -1) {
child.parentNode.removeChild(child);
}
state = false;
return self;
};
}
var setup = function (editor, theme) {
var throbber;
editor.on('ProgressState', function (e) {
throbber = throbber || new Throbber(theme.panel.getEl('body'));
if (e.state) {
throbber.show(e.time);
} else {
throbber.hide();
}
});
};
var ProgressState = { setup: setup };
var renderUI = function (editor, theme, args) {
var skinUrl = getSkinUrl(editor);
if (skinUrl) {
args.skinUiCss = skinUrl + '/skin.min.css';
editor.contentCSS.push(skinUrl + '/content' + (editor.inline ? '.inline' : '') + '.min.css');
}
ProgressState.setup(editor, theme);
return isInline(editor) ? Inline.render(editor, theme, args) : Iframe.render(editor, theme, args);
};
var Render = { renderUI: renderUI };
var Tooltip = Control$1.extend({
Mixins: [Movable],
Defaults: { classes: 'widget tooltip tooltip-n' },
renderHtml: function () {
var self = this, prefix = self.classPrefix;
return '' + '
' + '
' + self.encode(self.state.get('text')) + '
' + '
';
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.getEl().lastChild.innerHTML = self.encode(e.value);
});
return self._super();
},
repaint: function () {
var self = this;
var style, rect;
style = self.getEl().style;
rect = self._layoutRect;
style.left = rect.x + 'px';
style.top = rect.y + 'px';
style.zIndex = 65535 + 65535;
}
});
var Widget = Control$1.extend({
init: function (settings) {
var self = this;
self._super(settings);
settings = self.settings;
self.canFocus = true;
if (settings.tooltip && Widget.tooltips !== false) {
self.on('mouseenter', function (e) {
var tooltip = self.tooltip().moveTo(-65535);
if (e.control === self) {
var rel = tooltip.text(settings.tooltip).show().testMoveRel(self.getEl(), [
'bc-tc',
'bc-tl',
'bc-tr'
]);
tooltip.classes.toggle('tooltip-n', rel === 'bc-tc');
tooltip.classes.toggle('tooltip-nw', rel === 'bc-tl');
tooltip.classes.toggle('tooltip-ne', rel === 'bc-tr');
tooltip.moveRel(self.getEl(), rel);
} else {
tooltip.hide();
}
});
self.on('mouseleave mousedown click', function () {
self.tooltip().remove();
self._tooltip = null;
});
}
self.aria('label', settings.ariaLabel || settings.tooltip);
},
tooltip: function () {
if (!this._tooltip) {
this._tooltip = new Tooltip({ type: 'tooltip' });
UiContainer.inheritUiContainer(this, this._tooltip);
this._tooltip.renderTo();
}
return this._tooltip;
},
postRender: function () {
var self = this, settings = self.settings;
self._super();
if (!self.parent() && (settings.width || settings.height)) {
self.initLayoutRect();
self.repaint();
}
if (settings.autofocus) {
self.focus();
}
},
bindStates: function () {
var self = this;
function disable(state) {
self.aria('disabled', state);
self.classes.toggle('disabled', state);
}
function active(state) {
self.aria('pressed', state);
self.classes.toggle('active', state);
}
self.state.on('change:disabled', function (e) {
disable(e.value);
});
self.state.on('change:active', function (e) {
active(e.value);
});
if (self.state.get('disabled')) {
disable(true);
}
if (self.state.get('active')) {
active(true);
}
return self._super();
},
remove: function () {
this._super();
if (this._tooltip) {
this._tooltip.remove();
this._tooltip = null;
}
}
});
var Progress = Widget.extend({
Defaults: { value: 0 },
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('progress');
if (!self.settings.filter) {
self.settings.filter = function (value) {
return Math.round(value);
};
}
},
renderHtml: function () {
var self = this, id = self._id, prefix = this.classPrefix;
return '';
},
postRender: function () {
var self = this;
self._super();
self.value(self.settings.value);
return self;
},
bindStates: function () {
var self = this;
function setValue(value) {
value = self.settings.filter(value);
self.getEl().lastChild.innerHTML = value + '%';
self.getEl().firstChild.firstChild.style.width = value + '%';
}
self.state.on('change:value', function (e) {
setValue(e.value);
});
setValue(self.state.get('value'));
return self._super();
}
});
var updateLiveRegion = function (ctx, text) {
ctx.getEl().lastChild.textContent = text + (ctx.progressBar ? ' ' + ctx.progressBar.value() + '%' : '');
};
var Notification = Control$1.extend({
Mixins: [Movable],
Defaults: { classes: 'widget notification' },
init: function (settings) {
var self = this;
self._super(settings);
self.maxWidth = settings.maxWidth;
if (settings.text) {
self.text(settings.text);
}
if (settings.icon) {
self.icon = settings.icon;
}
if (settings.color) {
self.color = settings.color;
}
if (settings.type) {
self.classes.add('notification-' + settings.type);
}
if (settings.timeout && (settings.timeout < 0 || settings.timeout > 0) && !settings.closeButton) {
self.closeButton = false;
} else {
self.classes.add('has-close');
self.closeButton = true;
}
if (settings.progressBar) {
self.progressBar = new Progress();
}
self.on('click', function (e) {
if (e.target.className.indexOf(self.classPrefix + 'close') !== -1) {
self.close();
}
});
},
renderHtml: function () {
var self = this;
var prefix = self.classPrefix;
var icon = '', closeButton = '', progressBar = '', notificationStyle = '';
if (self.icon) {
icon = ' ';
}
notificationStyle = ' style="max-width: ' + self.maxWidth + 'px;' + (self.color ? 'background-color: ' + self.color + ';"' : '"');
if (self.closeButton) {
closeButton = '\xD7 ';
}
if (self.progressBar) {
progressBar = self.progressBar.renderHtml();
}
return '' + icon + '
' + self.state.get('text') + '
' + progressBar + closeButton + '
' + '
';
},
postRender: function () {
var self = this;
global$7.setTimeout(function () {
self.$el.addClass(self.classPrefix + 'in');
updateLiveRegion(self, self.state.get('text'));
}, 100);
return self._super();
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.getEl().firstChild.innerHTML = e.value;
updateLiveRegion(self, e.value);
});
if (self.progressBar) {
self.progressBar.bindStates();
self.progressBar.state.on('change:value', function (e) {
updateLiveRegion(self, self.state.get('text'));
});
}
return self._super();
},
close: function () {
var self = this;
if (!self.fire('close').isDefaultPrevented()) {
self.remove();
}
return self;
},
repaint: function () {
var self = this;
var style, rect;
style = self.getEl().style;
rect = self._layoutRect;
style.left = rect.x + 'px';
style.top = rect.y + 'px';
style.zIndex = 65535 - 1;
}
});
function NotificationManagerImpl (editor) {
var getEditorContainer = function (editor) {
return editor.inline ? editor.getElement() : editor.getContentAreaContainer();
};
var getContainerWidth = function () {
var container = getEditorContainer(editor);
return funcs.getSize(container).width;
};
var prePositionNotifications = function (notifications) {
each(notifications, function (notification) {
notification.moveTo(0, 0);
});
};
var positionNotifications = function (notifications) {
if (notifications.length > 0) {
var firstItem = notifications.slice(0, 1)[0];
var container = getEditorContainer(editor);
firstItem.moveRel(container, 'tc-tc');
each(notifications, function (notification, index) {
if (index > 0) {
notification.moveRel(notifications[index - 1].getEl(), 'bc-tc');
}
});
}
};
var reposition = function (notifications) {
prePositionNotifications(notifications);
positionNotifications(notifications);
};
var open = function (args, closeCallback) {
var extendedArgs = global$2.extend(args, { maxWidth: getContainerWidth() });
var notif = new Notification(extendedArgs);
notif.args = extendedArgs;
if (extendedArgs.timeout > 0) {
notif.timer = setTimeout(function () {
notif.close();
closeCallback();
}, extendedArgs.timeout);
}
notif.on('close', function () {
closeCallback();
});
notif.renderTo();
return notif;
};
var close = function (notification) {
notification.close();
};
var getArgs = function (notification) {
return notification.args;
};
return {
open: open,
close: close,
reposition: reposition,
getArgs: getArgs
};
}
var windows = [];
var oldMetaValue = '';
function toggleFullScreenState(state) {
var noScaleMetaValue = 'width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0';
var viewport = global$9('meta[name=viewport]')[0], contentValue;
if (global$8.overrideViewPort === false) {
return;
}
if (!viewport) {
viewport = domGlobals.document.createElement('meta');
viewport.setAttribute('name', 'viewport');
domGlobals.document.getElementsByTagName('head')[0].appendChild(viewport);
}
contentValue = viewport.getAttribute('content');
if (contentValue && typeof oldMetaValue !== 'undefined') {
oldMetaValue = contentValue;
}
viewport.setAttribute('content', state ? noScaleMetaValue : oldMetaValue);
}
function toggleBodyFullScreenClasses(classPrefix, state) {
if (checkFullscreenWindows() && state === false) {
global$9([
domGlobals.document.documentElement,
domGlobals.document.body
]).removeClass(classPrefix + 'fullscreen');
}
}
function checkFullscreenWindows() {
for (var i = 0; i < windows.length; i++) {
if (windows[i]._fullscreen) {
return true;
}
}
return false;
}
function handleWindowResize() {
if (!global$8.desktop) {
var lastSize_1 = {
w: domGlobals.window.innerWidth,
h: domGlobals.window.innerHeight
};
global$7.setInterval(function () {
var w = domGlobals.window.innerWidth, h = domGlobals.window.innerHeight;
if (lastSize_1.w !== w || lastSize_1.h !== h) {
lastSize_1 = {
w: w,
h: h
};
global$9(domGlobals.window).trigger('resize');
}
}, 100);
}
function reposition() {
var i;
var rect = funcs.getWindowSize();
var layoutRect;
for (i = 0; i < windows.length; i++) {
layoutRect = windows[i].layoutRect();
windows[i].moveTo(windows[i].settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2), windows[i].settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2));
}
}
global$9(domGlobals.window).on('resize', reposition);
}
var Window = FloatPanel.extend({
modal: true,
Defaults: {
border: 1,
layout: 'flex',
containerCls: 'panel',
role: 'dialog',
callbacks: {
submit: function () {
this.fire('submit', { data: this.toJSON() });
},
close: function () {
this.close();
}
}
},
init: function (settings) {
var self = this;
self._super(settings);
if (self.isRtl()) {
self.classes.add('rtl');
}
self.classes.add('window');
self.bodyClasses.add('window-body');
self.state.set('fixed', true);
if (settings.buttons) {
self.statusbar = new Panel({
layout: 'flex',
border: '1 0 0 0',
spacing: 3,
padding: 10,
align: 'center',
pack: self.isRtl() ? 'start' : 'end',
defaults: { type: 'button' },
items: settings.buttons
});
self.statusbar.classes.add('foot');
self.statusbar.parent(self);
}
self.on('click', function (e) {
var closeClass = self.classPrefix + 'close';
if (funcs.hasClass(e.target, closeClass) || funcs.hasClass(e.target.parentNode, closeClass)) {
self.close();
}
});
self.on('cancel', function () {
self.close();
});
self.on('move', function (e) {
if (e.control === self) {
FloatPanel.hideAll();
}
});
self.aria('describedby', self.describedBy || self._id + '-none');
self.aria('label', settings.title);
self._fullscreen = false;
},
recalc: function () {
var self = this;
var statusbar = self.statusbar;
var layoutRect, width, x, needsRecalc;
if (self._fullscreen) {
self.layoutRect(funcs.getWindowSize());
self.layoutRect().contentH = self.layoutRect().innerH;
}
self._super();
layoutRect = self.layoutRect();
if (self.settings.title && !self._fullscreen) {
width = layoutRect.headerW;
if (width > layoutRect.w) {
x = layoutRect.x - Math.max(0, width / 2);
self.layoutRect({
w: width,
x: x
});
needsRecalc = true;
}
}
if (statusbar) {
statusbar.layoutRect({ w: self.layoutRect().innerW }).recalc();
width = statusbar.layoutRect().minW + layoutRect.deltaW;
if (width > layoutRect.w) {
x = layoutRect.x - Math.max(0, width - layoutRect.w);
self.layoutRect({
w: width,
x: x
});
needsRecalc = true;
}
}
if (needsRecalc) {
self.recalc();
}
},
initLayoutRect: function () {
var self = this;
var layoutRect = self._super();
var deltaH = 0, headEl;
if (self.settings.title && !self._fullscreen) {
headEl = self.getEl('head');
var size = funcs.getSize(headEl);
layoutRect.headerW = size.width;
layoutRect.headerH = size.height;
deltaH += layoutRect.headerH;
}
if (self.statusbar) {
deltaH += self.statusbar.layoutRect().h;
}
layoutRect.deltaH += deltaH;
layoutRect.minH += deltaH;
layoutRect.h += deltaH;
var rect = funcs.getWindowSize();
layoutRect.x = self.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2);
layoutRect.y = self.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2);
return layoutRect;
},
renderHtml: function () {
var self = this, layout = self._layout, id = self._id, prefix = self.classPrefix;
var settings = self.settings;
var headerHtml = '', footerHtml = '', html = settings.html;
self.preRender();
layout.preRender(self);
if (settings.title) {
headerHtml = '' + '
' + self.encode(settings.title) + '
' + '
' + '
' + ' ' + ' ' + '
';
}
if (settings.url) {
html = '';
}
if (typeof html === 'undefined') {
html = layout.renderHtml(self);
}
if (self.statusbar) {
footerHtml = self.statusbar.renderHtml();
}
return '' + '
' + headerHtml + '
' + html + '
' + footerHtml + '
' + '
';
},
fullscreen: function (state) {
var self = this;
var documentElement = domGlobals.document.documentElement;
var slowRendering;
var prefix = self.classPrefix;
var layoutRect;
if (state !== self._fullscreen) {
global$9(domGlobals.window).on('resize', function () {
var time;
if (self._fullscreen) {
if (!slowRendering) {
time = new Date().getTime();
var rect = funcs.getWindowSize();
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
if (new Date().getTime() - time > 50) {
slowRendering = true;
}
} else {
if (!self._timer) {
self._timer = global$7.setTimeout(function () {
var rect = funcs.getWindowSize();
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
self._timer = 0;
}, 50);
}
}
}
});
layoutRect = self.layoutRect();
self._fullscreen = state;
if (!state) {
self.borderBox = BoxUtils.parseBox(self.settings.border);
self.getEl('head').style.display = '';
layoutRect.deltaH += layoutRect.headerH;
global$9([
documentElement,
domGlobals.document.body
]).removeClass(prefix + 'fullscreen');
self.classes.remove('fullscreen');
self.moveTo(self._initial.x, self._initial.y).resizeTo(self._initial.w, self._initial.h);
} else {
self._initial = {
x: layoutRect.x,
y: layoutRect.y,
w: layoutRect.w,
h: layoutRect.h
};
self.borderBox = BoxUtils.parseBox('0');
self.getEl('head').style.display = 'none';
layoutRect.deltaH -= layoutRect.headerH + 2;
global$9([
documentElement,
domGlobals.document.body
]).addClass(prefix + 'fullscreen');
self.classes.add('fullscreen');
var rect = funcs.getWindowSize();
self.moveTo(0, 0).resizeTo(rect.w, rect.h);
}
}
return self.reflow();
},
postRender: function () {
var self = this;
var startPos;
setTimeout(function () {
self.classes.add('in');
self.fire('open');
}, 0);
self._super();
if (self.statusbar) {
self.statusbar.postRender();
}
self.focus();
this.dragHelper = new DragHelper(self._id + '-dragh', {
start: function () {
startPos = {
x: self.layoutRect().x,
y: self.layoutRect().y
};
},
drag: function (e) {
self.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY);
}
});
self.on('submit', function (e) {
if (!e.isDefaultPrevented()) {
self.close();
}
});
windows.push(self);
toggleFullScreenState(true);
},
submit: function () {
return this.fire('submit', { data: this.toJSON() });
},
remove: function () {
var self = this;
var i;
self.dragHelper.destroy();
self._super();
if (self.statusbar) {
this.statusbar.remove();
}
toggleBodyFullScreenClasses(self.classPrefix, false);
i = windows.length;
while (i--) {
if (windows[i] === self) {
windows.splice(i, 1);
}
}
toggleFullScreenState(windows.length > 0);
},
getContentWindow: function () {
var ifr = this.getEl().getElementsByTagName('iframe')[0];
return ifr ? ifr.contentWindow : null;
}
});
handleWindowResize();
var MessageBox = Window.extend({
init: function (settings) {
settings = {
border: 1,
padding: 20,
layout: 'flex',
pack: 'center',
align: 'center',
containerCls: 'panel',
autoScroll: true,
buttons: {
type: 'button',
text: 'Ok',
action: 'ok'
},
items: {
type: 'label',
multiline: true,
maxWidth: 500,
maxHeight: 200
}
};
this._super(settings);
},
Statics: {
OK: 1,
OK_CANCEL: 2,
YES_NO: 3,
YES_NO_CANCEL: 4,
msgBox: function (settings) {
var buttons;
var callback = settings.callback || function () {
};
function createButton(text, status, primary) {
return {
type: 'button',
text: text,
subtype: primary ? 'primary' : '',
onClick: function (e) {
e.control.parents()[1].close();
callback(status);
}
};
}
switch (settings.buttons) {
case MessageBox.OK_CANCEL:
buttons = [
createButton('Ok', true, true),
createButton('Cancel', false)
];
break;
case MessageBox.YES_NO:
case MessageBox.YES_NO_CANCEL:
buttons = [
createButton('Yes', 1, true),
createButton('No', 0)
];
if (settings.buttons === MessageBox.YES_NO_CANCEL) {
buttons.push(createButton('Cancel', -1));
}
break;
default:
buttons = [createButton('Ok', true, true)];
break;
}
return new Window({
padding: 20,
x: settings.x,
y: settings.y,
minWidth: 300,
minHeight: 100,
layout: 'flex',
pack: 'center',
align: 'center',
buttons: buttons,
title: settings.title,
role: 'alertdialog',
items: {
type: 'label',
multiline: true,
maxWidth: 500,
maxHeight: 200,
text: settings.text
},
onPostRender: function () {
this.aria('describedby', this.items()[0]._id);
},
onClose: settings.onClose,
onCancel: function () {
callback(false);
}
}).renderTo(domGlobals.document.body).reflow();
},
alert: function (settings, callback) {
if (typeof settings === 'string') {
settings = { text: settings };
}
settings.callback = callback;
return MessageBox.msgBox(settings);
},
confirm: function (settings, callback) {
if (typeof settings === 'string') {
settings = { text: settings };
}
settings.callback = callback;
settings.buttons = MessageBox.OK_CANCEL;
return MessageBox.msgBox(settings);
}
}
});
function WindowManagerImpl (editor) {
var open = function (args, params, closeCallback) {
var win;
args.title = args.title || ' ';
args.url = args.url || args.file;
if (args.url) {
args.width = parseInt(args.width || 320, 10);
args.height = parseInt(args.height || 240, 10);
}
if (args.body) {
args.items = {
defaults: args.defaults,
type: args.bodyType || 'form',
items: args.body,
data: args.data,
callbacks: args.commands
};
}
if (!args.url && !args.buttons) {
args.buttons = [
{
text: 'Ok',
subtype: 'primary',
onclick: function () {
win.find('form')[0].submit();
}
},
{
text: 'Cancel',
onclick: function () {
win.close();
}
}
];
}
win = new Window(args);
win.on('close', function () {
closeCallback(win);
});
if (args.data) {
win.on('postRender', function () {
this.find('*').each(function (ctrl) {
var name = ctrl.name();
if (name in args.data) {
ctrl.value(args.data[name]);
}
});
});
}
win.features = args || {};
win.params = params || {};
win = win.renderTo(domGlobals.document.body).reflow();
return win;
};
var alert = function (message, choiceCallback, closeCallback) {
var win;
win = MessageBox.alert(message, function () {
choiceCallback();
});
win.on('close', function () {
closeCallback(win);
});
return win;
};
var confirm = function (message, choiceCallback, closeCallback) {
var win;
win = MessageBox.confirm(message, function (state) {
choiceCallback(state);
});
win.on('close', function () {
closeCallback(win);
});
return win;
};
var close = function (window) {
window.close();
};
var getParams = function (window) {
return window.params;
};
var setParams = function (window, params) {
window.params = params;
};
return {
open: open,
alert: alert,
confirm: confirm,
close: close,
getParams: getParams,
setParams: setParams
};
}
var get = function (editor) {
var renderUI = function (args) {
return Render.renderUI(editor, this, args);
};
var resizeTo = function (w, h) {
return Resize.resizeTo(editor, w, h);
};
var resizeBy = function (dw, dh) {
return Resize.resizeBy(editor, dw, dh);
};
var getNotificationManagerImpl = function () {
return NotificationManagerImpl(editor);
};
var getWindowManagerImpl = function () {
return WindowManagerImpl();
};
return {
renderUI: renderUI,
resizeTo: resizeTo,
resizeBy: resizeBy,
getNotificationManagerImpl: getNotificationManagerImpl,
getWindowManagerImpl: getWindowManagerImpl
};
};
var ThemeApi = { get: get };
var Layout = global$a.extend({
Defaults: {
firstControlClass: 'first',
lastControlClass: 'last'
},
init: function (settings) {
this.settings = global$2.extend({}, this.Defaults, settings);
},
preRender: function (container) {
container.bodyClasses.add(this.settings.containerClass);
},
applyClasses: function (items) {
var self = this;
var settings = self.settings;
var firstClass, lastClass, firstItem, lastItem;
firstClass = settings.firstControlClass;
lastClass = settings.lastControlClass;
items.each(function (item) {
item.classes.remove(firstClass).remove(lastClass).add(settings.controlClass);
if (item.visible()) {
if (!firstItem) {
firstItem = item;
}
lastItem = item;
}
});
if (firstItem) {
firstItem.classes.add(firstClass);
}
if (lastItem) {
lastItem.classes.add(lastClass);
}
},
renderHtml: function (container) {
var self = this;
var html = '';
self.applyClasses(container.items());
container.items().each(function (item) {
html += item.renderHtml();
});
return html;
},
recalc: function () {
},
postRender: function () {
},
isNative: function () {
return false;
}
});
var AbsoluteLayout = Layout.extend({
Defaults: {
containerClass: 'abs-layout',
controlClass: 'abs-layout-item'
},
recalc: function (container) {
container.items().filter(':visible').each(function (ctrl) {
var settings = ctrl.settings;
ctrl.layoutRect({
x: settings.x,
y: settings.y,
w: settings.w,
h: settings.h
});
if (ctrl.recalc) {
ctrl.recalc();
}
});
},
renderHtml: function (container) {
return '
' + this._super(container);
}
});
var Button = Widget.extend({
Defaults: {
classes: 'widget btn',
role: 'button'
},
init: function (settings) {
var self = this;
var size;
self._super(settings);
settings = self.settings;
size = self.settings.size;
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('touchstart', function (e) {
self.fire('click', e);
e.preventDefault();
});
if (settings.subtype) {
self.classes.add(settings.subtype);
}
if (size) {
self.classes.add('btn-' + size);
}
if (settings.icon) {
self.icon(settings.icon);
}
},
icon: function (icon) {
if (!arguments.length) {
return this.state.get('icon');
}
this.state.set('icon', icon);
return this;
},
repaint: function () {
var btnElm = this.getEl().firstChild;
var btnStyle;
if (btnElm) {
btnStyle = btnElm.style;
btnStyle.width = btnStyle.height = '100%';
}
this._super();
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
var icon = self.state.get('icon'), image;
var text = self.state.get('text');
var textHtml = '';
var ariaPressed;
var settings = self.settings;
image = settings.image;
if (image) {
icon = 'none';
if (typeof image !== 'string') {
image = domGlobals.window.getSelection ? image[0] : image[1];
}
image = ' style="background-image: url(\'' + image + '\')"';
} else {
image = '';
}
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
icon = icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : '';
return '' + '' + (icon ? ' ' : '') + textHtml + ' ' + '
';
},
bindStates: function () {
var self = this, $ = self.$, textCls = self.classPrefix + 'txt';
function setButtonText(text) {
var $span = $('span.' + textCls, self.getEl());
if (text) {
if (!$span[0]) {
$('button:first', self.getEl()).append(' ');
$span = $('span.' + textCls, self.getEl());
}
$span.html(self.encode(text));
} else {
$span.remove();
}
self.classes.toggle('btn-has-text', !!text);
}
self.state.on('change:text', function (e) {
setButtonText(e.value);
});
self.state.on('change:icon', function (e) {
var icon = e.value;
var prefix = self.classPrefix;
self.settings.icon = icon;
icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
var btnElm = self.getEl().firstChild;
var iconElm = btnElm.getElementsByTagName('i')[0];
if (icon) {
if (!iconElm || iconElm !== btnElm.firstChild) {
iconElm = domGlobals.document.createElement('i');
btnElm.insertBefore(iconElm, btnElm.firstChild);
}
iconElm.className = icon;
} else if (iconElm) {
btnElm.removeChild(iconElm);
}
setButtonText(self.state.get('text'));
});
return self._super();
}
});
var BrowseButton = Button.extend({
init: function (settings) {
var self = this;
settings = global$2.extend({
text: 'Browse...',
multiple: false,
accept: null
}, settings);
self._super(settings);
self.classes.add('browsebutton');
if (settings.multiple) {
self.classes.add('multiple');
}
},
postRender: function () {
var self = this;
var input = funcs.create('input', {
type: 'file',
id: self._id + '-browse',
accept: self.settings.accept
});
self._super();
global$9(input).on('change', function (e) {
var files = e.target.files;
self.value = function () {
if (!files.length) {
return null;
} else if (self.settings.multiple) {
return files;
} else {
return files[0];
}
};
e.preventDefault();
if (files.length) {
self.fire('change', e);
}
});
global$9(input).on('click', function (e) {
e.stopPropagation();
});
global$9(self.getEl('button')).on('click touchstart', function (e) {
e.stopPropagation();
input.click();
e.preventDefault();
});
self.getEl().appendChild(input);
},
remove: function () {
global$9(this.getEl('button')).off();
global$9(this.getEl('input')).off();
this._super();
}
});
var ButtonGroup = Container.extend({
Defaults: {
defaultType: 'button',
role: 'group'
},
renderHtml: function () {
var self = this, layout = self._layout;
self.classes.add('btn-group');
self.preRender();
layout.preRender(self);
return '' + '
' + (self.settings.html || '') + layout.renderHtml(self) + '
' + '
';
}
});
var Checkbox = Widget.extend({
Defaults: {
classes: 'checkbox',
role: 'checkbox',
checked: false
},
init: function (settings) {
var self = this;
self._super(settings);
self.on('click mousedown', function (e) {
e.preventDefault();
});
self.on('click', function (e) {
e.preventDefault();
if (!self.disabled()) {
self.checked(!self.checked());
}
});
self.checked(self.settings.checked);
},
checked: function (state) {
if (!arguments.length) {
return this.state.get('checked');
}
this.state.set('checked', state);
return this;
},
value: function (state) {
if (!arguments.length) {
return this.checked();
}
return this.checked(state);
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
return '' + ' ' + '' + self.encode(self.state.get('text')) + ' ' + '
';
},
bindStates: function () {
var self = this;
function checked(state) {
self.classes.toggle('checked', state);
self.aria('checked', state);
}
self.state.on('change:text', function (e) {
self.getEl('al').firstChild.data = self.translate(e.value);
});
self.state.on('change:checked change:value', function (e) {
self.fire('change');
checked(e.value);
});
self.state.on('change:icon', function (e) {
var icon = e.value;
var prefix = self.classPrefix;
if (typeof icon === 'undefined') {
return self.settings.icon;
}
self.settings.icon = icon;
icon = icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
var btnElm = self.getEl().firstChild;
var iconElm = btnElm.getElementsByTagName('i')[0];
if (icon) {
if (!iconElm || iconElm !== btnElm.firstChild) {
iconElm = domGlobals.document.createElement('i');
btnElm.insertBefore(iconElm, btnElm.firstChild);
}
iconElm.className = icon;
} else if (iconElm) {
btnElm.removeChild(iconElm);
}
});
if (self.state.get('checked')) {
checked(true);
}
return self._super();
}
});
var global$d = tinymce.util.Tools.resolve('tinymce.util.VK');
var ComboBox = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
settings = self.settings;
self.classes.add('combobox');
self.subinput = true;
self.ariaTarget = 'inp';
settings.menu = settings.menu || settings.values;
if (settings.menu) {
settings.icon = 'caret';
}
self.on('click', function (e) {
var elm = e.target;
var root = self.getEl();
if (!global$9.contains(root, elm) && elm !== root) {
return;
}
while (elm && elm !== root) {
if (elm.id && elm.id.indexOf('-open') !== -1) {
self.fire('action');
if (settings.menu) {
self.showMenu();
if (e.aria) {
self.menu.items()[0].focus();
}
}
}
elm = elm.parentNode;
}
});
self.on('keydown', function (e) {
var rootControl;
if (e.keyCode === 13 && e.target.nodeName === 'INPUT') {
e.preventDefault();
self.parents().reverse().each(function (ctrl) {
if (ctrl.toJSON) {
rootControl = ctrl;
return false;
}
});
self.fire('submit', { data: rootControl.toJSON() });
}
});
self.on('keyup', function (e) {
if (e.target.nodeName === 'INPUT') {
var oldValue = self.state.get('value');
var newValue = e.target.value;
if (newValue !== oldValue) {
self.state.set('value', newValue);
self.fire('autocomplete', e);
}
}
});
self.on('mouseover', function (e) {
var tooltip = self.tooltip().moveTo(-65535);
if (self.statusLevel() && e.target.className.indexOf(self.classPrefix + 'status') !== -1) {
var statusMessage = self.statusMessage() || 'Ok';
var rel = tooltip.text(statusMessage).show().testMoveRel(e.target, [
'bc-tc',
'bc-tl',
'bc-tr'
]);
tooltip.classes.toggle('tooltip-n', rel === 'bc-tc');
tooltip.classes.toggle('tooltip-nw', rel === 'bc-tl');
tooltip.classes.toggle('tooltip-ne', rel === 'bc-tr');
tooltip.moveRel(e.target, rel);
}
});
},
statusLevel: function (value) {
if (arguments.length > 0) {
this.state.set('statusLevel', value);
}
return this.state.get('statusLevel');
},
statusMessage: function (value) {
if (arguments.length > 0) {
this.state.set('statusMessage', value);
}
return this.state.get('statusMessage');
},
showMenu: function () {
var self = this;
var settings = self.settings;
var menu;
if (!self.menu) {
menu = settings.menu || [];
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
self.menu = global$4.create(menu).parent(self).renderTo(self.getContainerElm());
self.fire('createmenu');
self.menu.reflow();
self.menu.on('cancel', function (e) {
if (e.control === self.menu) {
self.focus();
}
});
self.menu.on('show hide', function (e) {
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.value() === self.value());
});
}).fire('show');
self.menu.on('select', function (e) {
self.value(e.control.value());
});
self.on('focusin', function (e) {
if (e.target.tagName.toUpperCase() === 'INPUT') {
self.menu.hide();
}
});
self.aria('expanded', true);
}
self.menu.show();
self.menu.layoutRect({ w: self.layoutRect().w });
self.menu.moveRel(self.getEl(), self.isRtl() ? [
'br-tr',
'tr-br'
] : [
'bl-tl',
'tl-bl'
]);
},
focus: function () {
this.getEl('inp').focus();
},
repaint: function () {
var self = this, elm = self.getEl(), openElm = self.getEl('open'), rect = self.layoutRect();
var width, lineHeight, innerPadding = 0;
var inputElm = elm.firstChild;
if (self.statusLevel() && self.statusLevel() !== 'none') {
innerPadding = parseInt(funcs.getRuntimeStyle(inputElm, 'padding-right'), 10) - parseInt(funcs.getRuntimeStyle(inputElm, 'padding-left'), 10);
}
if (openElm) {
width = rect.w - funcs.getSize(openElm).width - 10;
} else {
width = rect.w - 10;
}
var doc = domGlobals.document;
if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) {
lineHeight = self.layoutRect().h - 2 + 'px';
}
global$9(inputElm).css({
width: width - innerPadding,
lineHeight: lineHeight
});
self._super();
return self;
},
postRender: function () {
var self = this;
global$9(this.getEl('inp')).on('change', function (e) {
self.state.set('value', e.target.value);
self.fire('change', e);
});
return self._super();
},
renderHtml: function () {
var self = this, id = self._id, settings = self.settings, prefix = self.classPrefix;
var value = self.state.get('value') || '';
var icon, text, openBtnHtml = '', extraAttrs = '', statusHtml = '';
if ('spellcheck' in settings) {
extraAttrs += ' spellcheck="' + settings.spellcheck + '"';
}
if (settings.maxLength) {
extraAttrs += ' maxlength="' + settings.maxLength + '"';
}
if (settings.size) {
extraAttrs += ' size="' + settings.size + '"';
}
if (settings.subtype) {
extraAttrs += ' type="' + settings.subtype + '"';
}
statusHtml = ' ';
if (self.disabled()) {
extraAttrs += ' disabled="disabled"';
}
icon = settings.icon;
if (icon && icon !== 'caret') {
icon = prefix + 'ico ' + prefix + 'i-' + settings.icon;
}
text = self.state.get('text');
if (icon || text) {
openBtnHtml = '' + '' + (icon !== 'caret' ? ' ' : ' ') + (text ? (icon ? ' ' : '') + text : '') + ' ' + '
';
self.classes.add('has-open');
}
return '' + ' ' + statusHtml + openBtnHtml + '
';
},
value: function (value) {
if (arguments.length) {
this.state.set('value', value);
return this;
}
if (this.state.get('rendered')) {
this.state.set('value', this.getEl('inp').value);
}
return this.state.get('value');
},
showAutoComplete: function (items, term) {
var self = this;
if (items.length === 0) {
self.hideMenu();
return;
}
var insert = function (value, title) {
return function () {
self.fire('selectitem', {
title: title,
value: value
});
};
};
if (self.menu) {
self.menu.items().remove();
} else {
self.menu = global$4.create({
type: 'menu',
classes: 'combobox-menu',
layout: 'flow'
}).parent(self).renderTo();
}
global$2.each(items, function (item) {
self.menu.add({
text: item.title,
url: item.previewUrl,
match: term,
classes: 'menu-item-ellipsis',
onclick: insert(item.value, item.title)
});
});
self.menu.renderNew();
self.hideMenu();
self.menu.on('cancel', function (e) {
if (e.control.parent() === self.menu) {
e.stopPropagation();
self.focus();
self.hideMenu();
}
});
self.menu.on('select', function () {
self.focus();
});
var maxW = self.layoutRect().w;
self.menu.layoutRect({
w: maxW,
minW: 0,
maxW: maxW
});
self.menu.repaint();
self.menu.reflow();
self.menu.show();
self.menu.moveRel(self.getEl(), self.isRtl() ? [
'br-tr',
'tr-br'
] : [
'bl-tl',
'tl-bl'
]);
},
hideMenu: function () {
if (this.menu) {
this.menu.hide();
}
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
if (self.getEl('inp').value !== e.value) {
self.getEl('inp').value = e.value;
}
});
self.state.on('change:disabled', function (e) {
self.getEl('inp').disabled = e.value;
});
self.state.on('change:statusLevel', function (e) {
var statusIconElm = self.getEl('status');
var prefix = self.classPrefix, value = e.value;
funcs.css(statusIconElm, 'display', value === 'none' ? 'none' : '');
funcs.toggleClass(statusIconElm, prefix + 'i-checkmark', value === 'ok');
funcs.toggleClass(statusIconElm, prefix + 'i-warning', value === 'warn');
funcs.toggleClass(statusIconElm, prefix + 'i-error', value === 'error');
self.classes.toggle('has-status', value !== 'none');
self.repaint();
});
funcs.on(self.getEl('status'), 'mouseleave', function () {
self.tooltip().hide();
});
self.on('cancel', function (e) {
if (self.menu && self.menu.visible()) {
e.stopPropagation();
self.hideMenu();
}
});
var focusIdx = function (idx, menu) {
if (menu && menu.items().length > 0) {
menu.items().eq(idx)[0].focus();
}
};
self.on('keydown', function (e) {
var keyCode = e.keyCode;
if (e.target.nodeName === 'INPUT') {
if (keyCode === global$d.DOWN) {
e.preventDefault();
self.fire('autocomplete');
focusIdx(0, self.menu);
} else if (keyCode === global$d.UP) {
e.preventDefault();
focusIdx(-1, self.menu);
}
}
});
return self._super();
},
remove: function () {
global$9(this.getEl('inp')).off();
if (this.menu) {
this.menu.remove();
}
this._super();
}
});
var ColorBox = ComboBox.extend({
init: function (settings) {
var self = this;
settings.spellcheck = false;
if (settings.onaction) {
settings.icon = 'none';
}
self._super(settings);
self.classes.add('colorbox');
self.on('change keyup postrender', function () {
self.repaintColor(self.value());
});
},
repaintColor: function (value) {
var openElm = this.getEl('open');
var elm = openElm ? openElm.getElementsByTagName('i')[0] : null;
if (elm) {
try {
elm.style.background = value;
} catch (ex) {
}
}
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
if (self.state.get('rendered')) {
self.repaintColor(e.value);
}
});
return self._super();
}
});
var PanelButton = Button.extend({
showPanel: function () {
var self = this, settings = self.settings;
self.classes.add('opened');
if (!self.panel) {
var panelSettings = settings.panel;
if (panelSettings.type) {
panelSettings = {
layout: 'grid',
items: panelSettings
};
}
panelSettings.role = panelSettings.role || 'dialog';
panelSettings.popover = true;
panelSettings.autohide = true;
panelSettings.ariaRoot = true;
self.panel = new FloatPanel(panelSettings).on('hide', function () {
self.classes.remove('opened');
}).on('cancel', function (e) {
e.stopPropagation();
self.focus();
self.hidePanel();
}).parent(self).renderTo(self.getContainerElm());
self.panel.fire('show');
self.panel.reflow();
} else {
self.panel.show();
}
var rtlRels = [
'bc-tc',
'bc-tl',
'bc-tr'
];
var ltrRels = [
'bc-tc',
'bc-tr',
'bc-tl',
'tc-bc',
'tc-br',
'tc-bl'
];
var rel = self.panel.testMoveRel(self.getEl(), settings.popoverAlign || (self.isRtl() ? rtlRels : ltrRels));
self.panel.classes.toggle('start', rel.substr(-1) === 'l');
self.panel.classes.toggle('end', rel.substr(-1) === 'r');
var isTop = rel.substr(0, 1) === 't';
self.panel.classes.toggle('bottom', !isTop);
self.panel.classes.toggle('top', isTop);
self.panel.moveRel(self.getEl(), rel);
},
hidePanel: function () {
var self = this;
if (self.panel) {
self.panel.hide();
}
},
postRender: function () {
var self = this;
self.aria('haspopup', true);
self.on('click', function (e) {
if (e.control === self) {
if (self.panel && self.panel.visible()) {
self.hidePanel();
} else {
self.showPanel();
self.panel.focus(!!e.aria);
}
}
});
return self._super();
},
remove: function () {
if (this.panel) {
this.panel.remove();
this.panel = null;
}
return this._super();
}
});
var DOM$3 = global$3.DOM;
var ColorButton = PanelButton.extend({
init: function (settings) {
this._super(settings);
this.classes.add('splitbtn');
this.classes.add('colorbutton');
},
color: function (color) {
if (color) {
this._color = color;
this.getEl('preview').style.backgroundColor = color;
return this;
}
return this._color;
},
resetColor: function () {
this._color = null;
this.getEl('preview').style.backgroundColor = null;
return this;
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix, text = self.state.get('text');
var icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
var image = self.settings.image ? ' style="background-image: url(\'' + self.settings.image + '\')"' : '';
var textHtml = '';
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
return '' + '' + (icon ? ' ' : '') + ' ' + textHtml + ' ' + '' + ' ' + ' ' + '
';
},
postRender: function () {
var self = this, onClickHandler = self.settings.onclick;
self.on('click', function (e) {
if (e.aria && e.aria.key === 'down') {
return;
}
if (e.control === self && !DOM$3.getParent(e.target, '.' + self.classPrefix + 'open')) {
e.stopImmediatePropagation();
onClickHandler.call(self, e);
}
});
delete self.settings.onclick;
return self._super();
}
});
var global$e = tinymce.util.Tools.resolve('tinymce.util.Color');
var ColorPicker = Widget.extend({
Defaults: { classes: 'widget colorpicker' },
init: function (settings) {
this._super(settings);
},
postRender: function () {
var self = this;
var color = self.color();
var hsv, hueRootElm, huePointElm, svRootElm, svPointElm;
hueRootElm = self.getEl('h');
huePointElm = self.getEl('hp');
svRootElm = self.getEl('sv');
svPointElm = self.getEl('svp');
function getPos(elm, event) {
var pos = funcs.getPos(elm);
var x, y;
x = event.pageX - pos.x;
y = event.pageY - pos.y;
x = Math.max(0, Math.min(x / elm.clientWidth, 1));
y = Math.max(0, Math.min(y / elm.clientHeight, 1));
return {
x: x,
y: y
};
}
function updateColor(hsv, hueUpdate) {
var hue = (360 - hsv.h) / 360;
funcs.css(huePointElm, { top: hue * 100 + '%' });
if (!hueUpdate) {
funcs.css(svPointElm, {
left: hsv.s + '%',
top: 100 - hsv.v + '%'
});
}
svRootElm.style.background = global$e({
s: 100,
v: 100,
h: hsv.h
}).toHex();
self.color().parse({
s: hsv.s,
v: hsv.v,
h: hsv.h
});
}
function updateSaturationAndValue(e) {
var pos;
pos = getPos(svRootElm, e);
hsv.s = pos.x * 100;
hsv.v = (1 - pos.y) * 100;
updateColor(hsv);
self.fire('change');
}
function updateHue(e) {
var pos;
pos = getPos(hueRootElm, e);
hsv = color.toHsv();
hsv.h = (1 - pos.y) * 360;
updateColor(hsv, true);
self.fire('change');
}
self._repaint = function () {
hsv = color.toHsv();
updateColor(hsv);
};
self._super();
self._svdraghelper = new DragHelper(self._id + '-sv', {
start: updateSaturationAndValue,
drag: updateSaturationAndValue
});
self._hdraghelper = new DragHelper(self._id + '-h', {
start: updateHue,
drag: updateHue
});
self._repaint();
},
rgb: function () {
return this.color().toRgb();
},
value: function (value) {
var self = this;
if (arguments.length) {
self.color().parse(value);
if (self._rendered) {
self._repaint();
}
} else {
return self.color().toHex();
}
},
color: function () {
if (!this._color) {
this._color = global$e();
}
return this._color;
},
renderHtml: function () {
var self = this;
var id = self._id;
var prefix = self.classPrefix;
var hueHtml;
var stops = '#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000';
function getOldIeFallbackHtml() {
var i, l, html = '', gradientPrefix, stopsList;
gradientPrefix = 'filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=';
stopsList = stops.split(',');
for (i = 0, l = stopsList.length - 1; i < l; i++) {
html += '
';
}
return html;
}
var gradientCssText = 'background: -ms-linear-gradient(top,' + stops + ');' + 'background: linear-gradient(to bottom,' + stops + ');';
hueHtml = '' + getOldIeFallbackHtml() + '
' + '
';
return '';
}
});
var DropZone = Widget.extend({
init: function (settings) {
var self = this;
settings = global$2.extend({
height: 100,
text: 'Drop an image here',
multiple: false,
accept: null
}, settings);
self._super(settings);
self.classes.add('dropzone');
if (settings.multiple) {
self.classes.add('multiple');
}
},
renderHtml: function () {
var self = this;
var attrs, elm;
var cfg = self.settings;
attrs = {
id: self._id,
hidefocus: '1'
};
elm = funcs.create('div', attrs, '' + this.translate(cfg.text) + ' ');
if (cfg.height) {
funcs.css(elm, 'height', cfg.height + 'px');
}
if (cfg.width) {
funcs.css(elm, 'width', cfg.width + 'px');
}
elm.className = self.classes;
return elm.outerHTML;
},
postRender: function () {
var self = this;
var toggleDragClass = function (e) {
e.preventDefault();
self.classes.toggle('dragenter');
self.getEl().className = self.classes;
};
var filter = function (files) {
var accept = self.settings.accept;
if (typeof accept !== 'string') {
return files;
}
var re = new RegExp('(' + accept.split(/\s*,\s*/).join('|') + ')$', 'i');
return global$2.grep(files, function (file) {
return re.test(file.name);
});
};
self._super();
self.$el.on('dragover', function (e) {
e.preventDefault();
});
self.$el.on('dragenter', toggleDragClass);
self.$el.on('dragleave', toggleDragClass);
self.$el.on('drop', function (e) {
e.preventDefault();
if (self.state.get('disabled')) {
return;
}
var files = filter(e.dataTransfer.files);
self.value = function () {
if (!files.length) {
return null;
} else if (self.settings.multiple) {
return files;
} else {
return files[0];
}
};
if (files.length) {
self.fire('change', e);
}
});
},
remove: function () {
this.$el.off();
this._super();
}
});
var Path = Widget.extend({
init: function (settings) {
var self = this;
if (!settings.delimiter) {
settings.delimiter = '\xBB';
}
self._super(settings);
self.classes.add('path');
self.canFocus = true;
self.on('click', function (e) {
var index;
var target = e.target;
if (index = target.getAttribute('data-index')) {
self.fire('select', {
value: self.row()[index],
index: index
});
}
});
self.row(self.settings.row);
},
focus: function () {
var self = this;
self.getEl().firstChild.focus();
return self;
},
row: function (row) {
if (!arguments.length) {
return this.state.get('row');
}
this.state.set('row', row);
return this;
},
renderHtml: function () {
var self = this;
return '' + self._getDataPathHtml(self.state.get('row')) + '
';
},
bindStates: function () {
var self = this;
self.state.on('change:row', function (e) {
self.innerHtml(self._getDataPathHtml(e.value));
});
return self._super();
},
_getDataPathHtml: function (data) {
var self = this;
var parts = data || [];
var i, l, html = '';
var prefix = self.classPrefix;
for (i = 0, l = parts.length; i < l; i++) {
html += (i > 0 ? ' ' + self.settings.delimiter + '
' : '') + '' + parts[i].name + '
';
}
if (!html) {
html = '\xA0
';
}
return html;
}
});
var ElementPath = Path.extend({
postRender: function () {
var self = this, editor = self.settings.editor;
function isHidden(elm) {
if (elm.nodeType === 1) {
if (elm.nodeName === 'BR' || !!elm.getAttribute('data-mce-bogus')) {
return true;
}
if (elm.getAttribute('data-mce-type') === 'bookmark') {
return true;
}
}
return false;
}
if (editor.settings.elementpath !== false) {
self.on('select', function (e) {
editor.focus();
editor.selection.select(this.row()[e.index].element);
editor.nodeChanged();
});
editor.on('nodeChange', function (e) {
var outParents = [];
var parents = e.parents;
var i = parents.length;
while (i--) {
if (parents[i].nodeType === 1 && !isHidden(parents[i])) {
var args = editor.fire('ResolveName', {
name: parents[i].nodeName.toLowerCase(),
target: parents[i]
});
if (!args.isDefaultPrevented()) {
outParents.push({
name: args.name,
element: parents[i]
});
}
if (args.isPropagationStopped()) {
break;
}
}
}
self.row(outParents);
});
}
return self._super();
}
});
var FormItem = Container.extend({
Defaults: {
layout: 'flex',
align: 'center',
defaults: { flex: 1 }
},
renderHtml: function () {
var self = this, layout = self._layout, prefix = self.classPrefix;
self.classes.add('formitem');
layout.preRender(self);
return '' + (self.settings.title ? '
' + self.settings.title + '
' : '') + '
' + (self.settings.html || '') + layout.renderHtml(self) + '
' + '
';
}
});
var Form = Container.extend({
Defaults: {
containerCls: 'form',
layout: 'flex',
direction: 'column',
align: 'stretch',
flex: 1,
padding: 15,
labelGap: 30,
spacing: 10,
callbacks: {
submit: function () {
this.submit();
}
}
},
preRender: function () {
var self = this, items = self.items();
if (!self.settings.formItemDefaults) {
self.settings.formItemDefaults = {
layout: 'flex',
autoResize: 'overflow',
defaults: { flex: 1 }
};
}
items.each(function (ctrl) {
var formItem;
var label = ctrl.settings.label;
if (label) {
formItem = new FormItem(global$2.extend({
items: {
type: 'label',
id: ctrl._id + '-l',
text: label,
flex: 0,
forId: ctrl._id,
disabled: ctrl.disabled()
}
}, self.settings.formItemDefaults));
formItem.type = 'formitem';
ctrl.aria('labelledby', ctrl._id + '-l');
if (typeof ctrl.settings.flex === 'undefined') {
ctrl.settings.flex = 1;
}
self.replace(ctrl, formItem);
formItem.add(ctrl);
}
});
},
submit: function () {
return this.fire('submit', { data: this.toJSON() });
},
postRender: function () {
var self = this;
self._super();
self.fromJSON(self.settings.data);
},
bindStates: function () {
var self = this;
self._super();
function recalcLabels() {
var maxLabelWidth = 0;
var labels = [];
var i, labelGap, items;
if (self.settings.labelGapCalc === false) {
return;
}
if (self.settings.labelGapCalc === 'children') {
items = self.find('formitem');
} else {
items = self.items();
}
items.filter('formitem').each(function (item) {
var labelCtrl = item.items()[0], labelWidth = labelCtrl.getEl().clientWidth;
maxLabelWidth = labelWidth > maxLabelWidth ? labelWidth : maxLabelWidth;
labels.push(labelCtrl);
});
labelGap = self.settings.labelGap || 0;
i = labels.length;
while (i--) {
labels[i].settings.minWidth = maxLabelWidth + labelGap;
}
}
self.on('show', recalcLabels);
recalcLabels();
}
});
var FieldSet = Form.extend({
Defaults: {
containerCls: 'fieldset',
layout: 'flex',
direction: 'column',
align: 'stretch',
flex: 1,
padding: '25 15 5 15',
labelGap: 30,
spacing: 10,
border: 1
},
renderHtml: function () {
var self = this, layout = self._layout, prefix = self.classPrefix;
self.preRender();
layout.preRender(self);
return '' + (self.settings.title ? '' + self.settings.title + ' ' : '') + '' + (self.settings.html || '') + layout.renderHtml(self) + '
' + ' ';
}
});
var unique$1 = 0;
var generate = function (prefix) {
var date = new Date();
var time = date.getTime();
var random = Math.floor(Math.random() * 1000000000);
unique$1++;
return prefix + '_' + random + unique$1 + String(time);
};
var fromHtml = function (html, scope) {
var doc = scope || domGlobals.document;
var div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
domGlobals.console.error('HTML does not have a single root node', html);
throw new Error('HTML must have a single root node');
}
return fromDom(div.childNodes[0]);
};
var fromTag = function (tag, scope) {
var doc = scope || domGlobals.document;
var node = doc.createElement(tag);
return fromDom(node);
};
var fromText = function (text, scope) {
var doc = scope || domGlobals.document;
var node = doc.createTextNode(text);
return fromDom(node);
};
var fromDom = function (node) {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: constant(node) };
};
var fromPoint = function (docElm, x, y) {
var doc = docElm.dom();
return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
};
var Element = {
fromHtml: fromHtml,
fromTag: fromTag,
fromText: fromText,
fromDom: fromDom,
fromPoint: fromPoint
};
var cached = function (f) {
var called = false;
var r;
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!called) {
called = true;
r = f.apply(null, args);
}
return r;
};
};
var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE;
var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE;
var COMMENT = domGlobals.Node.COMMENT_NODE;
var DOCUMENT = domGlobals.Node.DOCUMENT_NODE;
var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE;
var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE;
var ELEMENT = domGlobals.Node.ELEMENT_NODE;
var TEXT = domGlobals.Node.TEXT_NODE;
var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE;
var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE;
var ENTITY = domGlobals.Node.ENTITY_NODE;
var NOTATION = domGlobals.Node.NOTATION_NODE;
var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
var path = function (parts, scope) {
var o = scope !== undefined && scope !== null ? scope : Global;
for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
o = o[parts[i]];
}
return o;
};
var resolve = function (p, scope) {
var parts = p.split('.');
return path(parts, scope);
};
var unsafe = function (name, scope) {
return resolve(name, scope);
};
var getOrDie = function (name, scope) {
var actual = unsafe(name, scope);
if (actual === undefined || actual === null) {
throw new Error(name + ' not available on this browser');
}
return actual;
};
var Global$1 = { getOrDie: getOrDie };
var Immutable = function () {
var fields = [];
for (var _i = 0; _i < arguments.length; _i++) {
fields[_i] = arguments[_i];
}
return function () {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
if (fields.length !== values.length) {
throw new Error('Wrong number of arguments to struct. Expected "[' + fields.length + ']", got ' + values.length + ' arguments');
}
var struct = {};
each(fields, function (name, i) {
struct[name] = constant(values[i]);
});
return struct;
};
};
var node = function () {
var f = Global$1.getOrDie('Node');
return f;
};
var compareDocumentPosition = function (a, b, match) {
return (a.compareDocumentPosition(b) & match) !== 0;
};
var documentPositionPreceding = function (a, b) {
return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_PRECEDING);
};
var documentPositionContainedBy = function (a, b) {
return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY);
};
var Node = {
documentPositionPreceding: documentPositionPreceding,
documentPositionContainedBy: documentPositionContainedBy
};
var firstMatch = function (regexes, s) {
for (var i = 0; i < regexes.length; i++) {
var x = regexes[i];
if (x.test(s)) {
return x;
}
}
return undefined;
};
var find$1 = function (regexes, agent) {
var r = firstMatch(regexes, agent);
if (!r) {
return {
major: 0,
minor: 0
};
}
var group = function (i) {
return Number(agent.replace(r, '$' + i));
};
return nu(group(1), group(2));
};
var detect = function (versionRegexes, agent) {
var cleanedAgent = String(agent).toLowerCase();
if (versionRegexes.length === 0) {
return unknown();
}
return find$1(versionRegexes, cleanedAgent);
};
var unknown = function () {
return nu(0, 0);
};
var nu = function (major, minor) {
return {
major: major,
minor: minor
};
};
var Version = {
nu: nu,
detect: detect,
unknown: unknown
};
var edge = 'Edge';
var chrome = 'Chrome';
var ie = 'IE';
var opera = 'Opera';
var firefox = 'Firefox';
var safari = 'Safari';
var isBrowser = function (name, current) {
return function () {
return current === name;
};
};
var unknown$1 = function () {
return nu$1({
current: undefined,
version: Version.unknown()
});
};
var nu$1 = function (info) {
var current = info.current;
var version = info.version;
return {
current: current,
version: version,
isEdge: isBrowser(edge, current),
isChrome: isBrowser(chrome, current),
isIE: isBrowser(ie, current),
isOpera: isBrowser(opera, current),
isFirefox: isBrowser(firefox, current),
isSafari: isBrowser(safari, current)
};
};
var Browser = {
unknown: unknown$1,
nu: nu$1,
edge: constant(edge),
chrome: constant(chrome),
ie: constant(ie),
opera: constant(opera),
firefox: constant(firefox),
safari: constant(safari)
};
var windows$1 = 'Windows';
var ios = 'iOS';
var android = 'Android';
var linux = 'Linux';
var osx = 'OSX';
var solaris = 'Solaris';
var freebsd = 'FreeBSD';
var isOS = function (name, current) {
return function () {
return current === name;
};
};
var unknown$2 = function () {
return nu$2({
current: undefined,
version: Version.unknown()
});
};
var nu$2 = function (info) {
var current = info.current;
var version = info.version;
return {
current: current,
version: version,
isWindows: isOS(windows$1, current),
isiOS: isOS(ios, current),
isAndroid: isOS(android, current),
isOSX: isOS(osx, current),
isLinux: isOS(linux, current),
isSolaris: isOS(solaris, current),
isFreeBSD: isOS(freebsd, current)
};
};
var OperatingSystem = {
unknown: unknown$2,
nu: nu$2,
windows: constant(windows$1),
ios: constant(ios),
android: constant(android),
linux: constant(linux),
osx: constant(osx),
solaris: constant(solaris),
freebsd: constant(freebsd)
};
var DeviceType = function (os, browser, userAgent) {
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
var isiPhone = os.isiOS() && !isiPad;
var isAndroid3 = os.isAndroid() && os.version.major === 3;
var isAndroid4 = os.isAndroid() && os.version.major === 4;
var isTablet = isiPad || isAndroid3 || isAndroid4 && /mobile/i.test(userAgent) === true;
var isTouch = os.isiOS() || os.isAndroid();
var isPhone = isTouch && !isTablet;
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
return {
isiPad: constant(isiPad),
isiPhone: constant(isiPhone),
isTablet: constant(isTablet),
isPhone: constant(isPhone),
isTouch: constant(isTouch),
isAndroid: os.isAndroid,
isiOS: os.isiOS,
isWebView: constant(iOSwebview)
};
};
var detect$1 = function (candidates, userAgent) {
var agent = String(userAgent).toLowerCase();
return find(candidates, function (candidate) {
return candidate.search(agent);
});
};
var detectBrowser = function (browsers, userAgent) {
return detect$1(browsers, userAgent).map(function (browser) {
var version = Version.detect(browser.versionRegexes, userAgent);
return {
current: browser.name,
version: version
};
});
};
var detectOs = function (oses, userAgent) {
return detect$1(oses, userAgent).map(function (os) {
var version = Version.detect(os.versionRegexes, userAgent);
return {
current: os.name,
version: version
};
});
};
var UaString = {
detectBrowser: detectBrowser,
detectOs: detectOs
};
var contains = function (str, substr) {
return str.indexOf(substr) !== -1;
};
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
var checkContains = function (target) {
return function (uastring) {
return contains(uastring, target);
};
};
var browsers = [
{
name: 'Edge',
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
search: function (uastring) {
return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
}
},
{
name: 'Chrome',
versionRegexes: [
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
normalVersionRegex
],
search: function (uastring) {
return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
}
},
{
name: 'IE',
versionRegexes: [
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
/.*?rv:([0-9]+)\.([0-9]+).*/
],
search: function (uastring) {
return contains(uastring, 'msie') || contains(uastring, 'trident');
}
},
{
name: 'Opera',
versionRegexes: [
normalVersionRegex,
/.*?opera\/([0-9]+)\.([0-9]+).*/
],
search: checkContains('opera')
},
{
name: 'Firefox',
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
search: checkContains('firefox')
},
{
name: 'Safari',
versionRegexes: [
normalVersionRegex,
/.*?cpu os ([0-9]+)_([0-9]+).*/
],
search: function (uastring) {
return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
}
}
];
var oses = [
{
name: 'Windows',
search: checkContains('win'),
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'iOS',
search: function (uastring) {
return contains(uastring, 'iphone') || contains(uastring, 'ipad');
},
versionRegexes: [
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
/.*cpu os ([0-9]+)_([0-9]+).*/,
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
]
},
{
name: 'Android',
search: checkContains('android'),
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'OSX',
search: checkContains('os x'),
versionRegexes: [/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]
},
{
name: 'Linux',
search: checkContains('linux'),
versionRegexes: []
},
{
name: 'Solaris',
search: checkContains('sunos'),
versionRegexes: []
},
{
name: 'FreeBSD',
search: checkContains('freebsd'),
versionRegexes: []
}
];
var PlatformInfo = {
browsers: constant(browsers),
oses: constant(oses)
};
var detect$2 = function (userAgent) {
var browsers = PlatformInfo.browsers();
var oses = PlatformInfo.oses();
var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu);
var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
var deviceType = DeviceType(os, browser, userAgent);
return {
browser: browser,
os: os,
deviceType: deviceType
};
};
var PlatformDetection = { detect: detect$2 };
var detect$3 = cached(function () {
var userAgent = domGlobals.navigator.userAgent;
return PlatformDetection.detect(userAgent);
});
var PlatformDetection$1 = { detect: detect$3 };
var ELEMENT$1 = ELEMENT;
var DOCUMENT$1 = DOCUMENT;
var bypassSelector = function (dom) {
return dom.nodeType !== ELEMENT$1 && dom.nodeType !== DOCUMENT$1 || dom.childElementCount === 0;
};
var all = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element.fromDom);
};
var one = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element.fromDom);
};
var regularContains = function (e1, e2) {
var d1 = e1.dom();
var d2 = e2.dom();
return d1 === d2 ? false : d1.contains(d2);
};
var ieContains = function (e1, e2) {
return Node.documentPositionContainedBy(e1.dom(), e2.dom());
};
var browser = PlatformDetection$1.detect().browser;
var contains$1 = browser.isIE() ? ieContains : regularContains;
var spot = Immutable('element', 'offset');
var descendants = function (scope, selector) {
return all(selector, scope);
};
var trim = global$2.trim;
var hasContentEditableState = function (value) {
return function (node) {
if (node && node.nodeType === 1) {
if (node.contentEditable === value) {
return true;
}
if (node.getAttribute('data-mce-contenteditable') === value) {
return true;
}
}
return false;
};
};
var isContentEditableTrue = hasContentEditableState('true');
var isContentEditableFalse = hasContentEditableState('false');
var create = function (type, title, url, level, attach) {
return {
type: type,
title: title,
url: url,
level: level,
attach: attach
};
};
var isChildOfContentEditableTrue = function (node) {
while (node = node.parentNode) {
var value = node.contentEditable;
if (value && value !== 'inherit') {
return isContentEditableTrue(node);
}
}
return false;
};
var select = function (selector, root) {
return map(descendants(Element.fromDom(root), selector), function (element) {
return element.dom();
});
};
var getElementText = function (elm) {
return elm.innerText || elm.textContent;
};
var getOrGenerateId = function (elm) {
return elm.id ? elm.id : generate('h');
};
var isAnchor = function (elm) {
return elm && elm.nodeName === 'A' && (elm.id || elm.name);
};
var isValidAnchor = function (elm) {
return isAnchor(elm) && isEditable(elm);
};
var isHeader = function (elm) {
return elm && /^(H[1-6])$/.test(elm.nodeName);
};
var isEditable = function (elm) {
return isChildOfContentEditableTrue(elm) && !isContentEditableFalse(elm);
};
var isValidHeader = function (elm) {
return isHeader(elm) && isEditable(elm);
};
var getLevel = function (elm) {
return isHeader(elm) ? parseInt(elm.nodeName.substr(1), 10) : 0;
};
var headerTarget = function (elm) {
var headerId = getOrGenerateId(elm);
var attach = function () {
elm.id = headerId;
};
return create('header', getElementText(elm), '#' + headerId, getLevel(elm), attach);
};
var anchorTarget = function (elm) {
var anchorId = elm.id || elm.name;
var anchorText = getElementText(elm);
return create('anchor', anchorText ? anchorText : '#' + anchorId, '#' + anchorId, 0, noop);
};
var getHeaderTargets = function (elms) {
return map(filter(elms, isValidHeader), headerTarget);
};
var getAnchorTargets = function (elms) {
return map(filter(elms, isValidAnchor), anchorTarget);
};
var getTargetElements = function (elm) {
var elms = select('h1,h2,h3,h4,h5,h6,a:not([href])', elm);
return elms;
};
var hasTitle = function (target) {
return trim(target.title).length > 0;
};
var find$2 = function (elm) {
var elms = getTargetElements(elm);
return filter(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle);
};
var LinkTargets = { find: find$2 };
var getActiveEditor = function () {
return window.tinymce ? window.tinymce.activeEditor : global$1.activeEditor;
};
var history = {};
var HISTORY_LENGTH = 5;
var clearHistory = function () {
history = {};
};
var toMenuItem = function (target) {
return {
title: target.title,
value: {
title: { raw: target.title },
url: target.url,
attach: target.attach
}
};
};
var toMenuItems = function (targets) {
return global$2.map(targets, toMenuItem);
};
var staticMenuItem = function (title, url) {
return {
title: title,
value: {
title: title,
url: url,
attach: noop
}
};
};
var isUniqueUrl = function (url, targets) {
var foundTarget = exists(targets, function (target) {
return target.url === url;
});
return !foundTarget;
};
var getSetting = function (editorSettings, name, defaultValue) {
var value = name in editorSettings ? editorSettings[name] : defaultValue;
return value === false ? null : value;
};
var createMenuItems = function (term, targets, fileType, editorSettings) {
var separator = { title: '-' };
var fromHistoryMenuItems = function (history) {
var historyItems = history.hasOwnProperty(fileType) ? history[fileType] : [];
var uniqueHistory = filter(historyItems, function (url) {
return isUniqueUrl(url, targets);
});
return global$2.map(uniqueHistory, function (url) {
return {
title: url,
value: {
title: url,
url: url,
attach: noop
}
};
});
};
var fromMenuItems = function (type) {
var filteredTargets = filter(targets, function (target) {
return target.type === type;
});
return toMenuItems(filteredTargets);
};
var anchorMenuItems = function () {
var anchorMenuItems = fromMenuItems('anchor');
var topAnchor = getSetting(editorSettings, 'anchor_top', '#top');
var bottomAchor = getSetting(editorSettings, 'anchor_bottom', '#bottom');
if (topAnchor !== null) {
anchorMenuItems.unshift(staticMenuItem('', topAnchor));
}
if (bottomAchor !== null) {
anchorMenuItems.push(staticMenuItem('', bottomAchor));
}
return anchorMenuItems;
};
var join = function (items) {
return foldl(items, function (a, b) {
var bothEmpty = a.length === 0 || b.length === 0;
return bothEmpty ? a.concat(b) : a.concat(separator, b);
}, []);
};
if (editorSettings.typeahead_urls === false) {
return [];
}
return fileType === 'file' ? join([
filterByQuery(term, fromHistoryMenuItems(history)),
filterByQuery(term, fromMenuItems('header')),
filterByQuery(term, anchorMenuItems())
]) : filterByQuery(term, fromHistoryMenuItems(history));
};
var addToHistory = function (url, fileType) {
var items = history[fileType];
if (!/^https?/.test(url)) {
return;
}
if (items) {
if (indexOf(items, url).isNone()) {
history[fileType] = items.slice(0, HISTORY_LENGTH).concat(url);
}
} else {
history[fileType] = [url];
}
};
var filterByQuery = function (term, menuItems) {
var lowerCaseTerm = term.toLowerCase();
var result = global$2.grep(menuItems, function (item) {
return item.title.toLowerCase().indexOf(lowerCaseTerm) !== -1;
});
return result.length === 1 && result[0].title === term ? [] : result;
};
var getTitle = function (linkDetails) {
var title = linkDetails.title;
return title.raw ? title.raw : title;
};
var setupAutoCompleteHandler = function (ctrl, editorSettings, bodyElm, fileType) {
var autocomplete = function (term) {
var linkTargets = LinkTargets.find(bodyElm);
var menuItems = createMenuItems(term, linkTargets, fileType, editorSettings);
ctrl.showAutoComplete(menuItems, term);
};
ctrl.on('autocomplete', function () {
autocomplete(ctrl.value());
});
ctrl.on('selectitem', function (e) {
var linkDetails = e.value;
ctrl.value(linkDetails.url);
var title = getTitle(linkDetails);
if (fileType === 'image') {
ctrl.fire('change', {
meta: {
alt: title,
attach: linkDetails.attach
}
});
} else {
ctrl.fire('change', {
meta: {
text: title,
attach: linkDetails.attach
}
});
}
ctrl.focus();
});
ctrl.on('click', function (e) {
if (ctrl.value().length === 0 && e.target.nodeName === 'INPUT') {
autocomplete('');
}
});
ctrl.on('PostRender', function () {
ctrl.getRoot().on('submit', function (e) {
if (!e.isDefaultPrevented()) {
addToHistory(ctrl.value(), fileType);
}
});
});
};
var statusToUiState = function (result) {
var status = result.status, message = result.message;
if (status === 'valid') {
return {
status: 'ok',
message: message
};
} else if (status === 'unknown') {
return {
status: 'warn',
message: message
};
} else if (status === 'invalid') {
return {
status: 'warn',
message: message
};
} else {
return {
status: 'none',
message: ''
};
}
};
var setupLinkValidatorHandler = function (ctrl, editorSettings, fileType) {
var validatorHandler = editorSettings.filepicker_validator_handler;
if (validatorHandler) {
var validateUrl_1 = function (url) {
if (url.length === 0) {
ctrl.statusLevel('none');
return;
}
validatorHandler({
url: url,
type: fileType
}, function (result) {
var uiState = statusToUiState(result);
ctrl.statusMessage(uiState.message);
ctrl.statusLevel(uiState.status);
});
};
ctrl.state.on('change:value', function (e) {
validateUrl_1(e.value);
});
}
};
var FilePicker = ComboBox.extend({
Statics: { clearHistory: clearHistory },
init: function (settings) {
var self = this, editor = getActiveEditor(), editorSettings = editor.settings;
var actionCallback, fileBrowserCallback, fileBrowserCallbackTypes;
var fileType = settings.filetype;
settings.spellcheck = false;
fileBrowserCallbackTypes = editorSettings.file_picker_types || editorSettings.file_browser_callback_types;
if (fileBrowserCallbackTypes) {
fileBrowserCallbackTypes = global$2.makeMap(fileBrowserCallbackTypes, /[, ]/);
}
if (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[fileType]) {
fileBrowserCallback = editorSettings.file_picker_callback;
if (fileBrowserCallback && (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[fileType])) {
actionCallback = function () {
var meta = self.fire('beforecall').meta;
meta = global$2.extend({ filetype: fileType }, meta);
fileBrowserCallback.call(editor, function (value, meta) {
self.value(value).fire('change', { meta: meta });
}, self.value(), meta);
};
} else {
fileBrowserCallback = editorSettings.file_browser_callback;
if (fileBrowserCallback && (!fileBrowserCallbackTypes || fileBrowserCallbackTypes[fileType])) {
actionCallback = function () {
fileBrowserCallback(self.getEl('inp').id, self.value(), fileType, window);
};
}
}
}
if (actionCallback) {
settings.icon = 'browse';
settings.onaction = actionCallback;
}
self._super(settings);
self.classes.add('filepicker');
setupAutoCompleteHandler(self, editorSettings, editor.getBody(), fileType);
setupLinkValidatorHandler(self, editorSettings, fileType);
}
});
var FitLayout = AbsoluteLayout.extend({
recalc: function (container) {
var contLayoutRect = container.layoutRect(), paddingBox = container.paddingBox;
container.items().filter(':visible').each(function (ctrl) {
ctrl.layoutRect({
x: paddingBox.left,
y: paddingBox.top,
w: contLayoutRect.innerW - paddingBox.right - paddingBox.left,
h: contLayoutRect.innerH - paddingBox.top - paddingBox.bottom
});
if (ctrl.recalc) {
ctrl.recalc();
}
});
}
});
var FlexLayout = AbsoluteLayout.extend({
recalc: function (container) {
var i, l, items, contLayoutRect, contPaddingBox, contSettings, align, pack, spacing, totalFlex, availableSpace, direction;
var ctrl, ctrlLayoutRect, ctrlSettings, flex;
var maxSizeItems = [];
var size, maxSize, ratio, rect, pos, maxAlignEndPos;
var sizeName, minSizeName, posName, maxSizeName, beforeName, innerSizeName, deltaSizeName, contentSizeName;
var alignAxisName, alignInnerSizeName, alignSizeName, alignMinSizeName, alignBeforeName, alignAfterName;
var alignDeltaSizeName, alignContentSizeName;
var max = Math.max, min = Math.min;
items = container.items().filter(':visible');
contLayoutRect = container.layoutRect();
contPaddingBox = container.paddingBox;
contSettings = container.settings;
direction = container.isRtl() ? contSettings.direction || 'row-reversed' : contSettings.direction;
align = contSettings.align;
pack = container.isRtl() ? contSettings.pack || 'end' : contSettings.pack;
spacing = contSettings.spacing || 0;
if (direction === 'row-reversed' || direction === 'column-reverse') {
items = items.set(items.toArray().reverse());
direction = direction.split('-')[0];
}
if (direction === 'column') {
posName = 'y';
sizeName = 'h';
minSizeName = 'minH';
maxSizeName = 'maxH';
innerSizeName = 'innerH';
beforeName = 'top';
deltaSizeName = 'deltaH';
contentSizeName = 'contentH';
alignBeforeName = 'left';
alignSizeName = 'w';
alignAxisName = 'x';
alignInnerSizeName = 'innerW';
alignMinSizeName = 'minW';
alignAfterName = 'right';
alignDeltaSizeName = 'deltaW';
alignContentSizeName = 'contentW';
} else {
posName = 'x';
sizeName = 'w';
minSizeName = 'minW';
maxSizeName = 'maxW';
innerSizeName = 'innerW';
beforeName = 'left';
deltaSizeName = 'deltaW';
contentSizeName = 'contentW';
alignBeforeName = 'top';
alignSizeName = 'h';
alignAxisName = 'y';
alignInnerSizeName = 'innerH';
alignMinSizeName = 'minH';
alignAfterName = 'bottom';
alignDeltaSizeName = 'deltaH';
alignContentSizeName = 'contentH';
}
availableSpace = contLayoutRect[innerSizeName] - contPaddingBox[beforeName] - contPaddingBox[beforeName];
maxAlignEndPos = totalFlex = 0;
for (i = 0, l = items.length; i < l; i++) {
ctrl = items[i];
ctrlLayoutRect = ctrl.layoutRect();
ctrlSettings = ctrl.settings;
flex = ctrlSettings.flex;
availableSpace -= i < l - 1 ? spacing : 0;
if (flex > 0) {
totalFlex += flex;
if (ctrlLayoutRect[maxSizeName]) {
maxSizeItems.push(ctrl);
}
ctrlLayoutRect.flex = flex;
}
availableSpace -= ctrlLayoutRect[minSizeName];
size = contPaddingBox[alignBeforeName] + ctrlLayoutRect[alignMinSizeName] + contPaddingBox[alignAfterName];
if (size > maxAlignEndPos) {
maxAlignEndPos = size;
}
}
rect = {};
if (availableSpace < 0) {
rect[minSizeName] = contLayoutRect[minSizeName] - availableSpace + contLayoutRect[deltaSizeName];
} else {
rect[minSizeName] = contLayoutRect[innerSizeName] - availableSpace + contLayoutRect[deltaSizeName];
}
rect[alignMinSizeName] = maxAlignEndPos + contLayoutRect[alignDeltaSizeName];
rect[contentSizeName] = contLayoutRect[innerSizeName] - availableSpace;
rect[alignContentSizeName] = maxAlignEndPos;
rect.minW = min(rect.minW, contLayoutRect.maxW);
rect.minH = min(rect.minH, contLayoutRect.maxH);
rect.minW = max(rect.minW, contLayoutRect.startMinWidth);
rect.minH = max(rect.minH, contLayoutRect.startMinHeight);
if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) {
rect.w = rect.minW;
rect.h = rect.minH;
container.layoutRect(rect);
this.recalc(container);
if (container._lastRect === null) {
var parentCtrl = container.parent();
if (parentCtrl) {
parentCtrl._lastRect = null;
parentCtrl.recalc();
}
}
return;
}
ratio = availableSpace / totalFlex;
for (i = 0, l = maxSizeItems.length; i < l; i++) {
ctrl = maxSizeItems[i];
ctrlLayoutRect = ctrl.layoutRect();
maxSize = ctrlLayoutRect[maxSizeName];
size = ctrlLayoutRect[minSizeName] + ctrlLayoutRect.flex * ratio;
if (size > maxSize) {
availableSpace -= ctrlLayoutRect[maxSizeName] - ctrlLayoutRect[minSizeName];
totalFlex -= ctrlLayoutRect.flex;
ctrlLayoutRect.flex = 0;
ctrlLayoutRect.maxFlexSize = maxSize;
} else {
ctrlLayoutRect.maxFlexSize = 0;
}
}
ratio = availableSpace / totalFlex;
pos = contPaddingBox[beforeName];
rect = {};
if (totalFlex === 0) {
if (pack === 'end') {
pos = availableSpace + contPaddingBox[beforeName];
} else if (pack === 'center') {
pos = Math.round(contLayoutRect[innerSizeName] / 2 - (contLayoutRect[innerSizeName] - availableSpace) / 2) + contPaddingBox[beforeName];
if (pos < 0) {
pos = contPaddingBox[beforeName];
}
} else if (pack === 'justify') {
pos = contPaddingBox[beforeName];
spacing = Math.floor(availableSpace / (items.length - 1));
}
}
rect[alignAxisName] = contPaddingBox[alignBeforeName];
for (i = 0, l = items.length; i < l; i++) {
ctrl = items[i];
ctrlLayoutRect = ctrl.layoutRect();
size = ctrlLayoutRect.maxFlexSize || ctrlLayoutRect[minSizeName];
if (align === 'center') {
rect[alignAxisName] = Math.round(contLayoutRect[alignInnerSizeName] / 2 - ctrlLayoutRect[alignSizeName] / 2);
} else if (align === 'stretch') {
rect[alignSizeName] = max(ctrlLayoutRect[alignMinSizeName] || 0, contLayoutRect[alignInnerSizeName] - contPaddingBox[alignBeforeName] - contPaddingBox[alignAfterName]);
rect[alignAxisName] = contPaddingBox[alignBeforeName];
} else if (align === 'end') {
rect[alignAxisName] = contLayoutRect[alignInnerSizeName] - ctrlLayoutRect[alignSizeName] - contPaddingBox.top;
}
if (ctrlLayoutRect.flex > 0) {
size += ctrlLayoutRect.flex * ratio;
}
rect[sizeName] = size;
rect[posName] = pos;
ctrl.layoutRect(rect);
if (ctrl.recalc) {
ctrl.recalc();
}
pos += size + spacing;
}
}
});
var FlowLayout = Layout.extend({
Defaults: {
containerClass: 'flow-layout',
controlClass: 'flow-layout-item',
endClass: 'break'
},
recalc: function (container) {
container.items().filter(':visible').each(function (ctrl) {
if (ctrl.recalc) {
ctrl.recalc();
}
});
},
isNative: function () {
return true;
}
});
var descendant = function (scope, selector) {
return one(selector, scope);
};
var toggleFormat = function (editor, fmt) {
return function () {
editor.execCommand('mceToggleFormat', false, fmt);
};
};
var addFormatChangedListener = function (editor, name, changed) {
var handler = function (state) {
changed(state, name);
};
if (editor.formatter) {
editor.formatter.formatChanged(name, handler);
} else {
editor.on('init', function () {
editor.formatter.formatChanged(name, handler);
});
}
};
var postRenderFormatToggle = function (editor, name) {
return function (e) {
addFormatChangedListener(editor, name, function (state) {
e.control.active(state);
});
};
};
var register = function (editor) {
var alignFormats = [
'alignleft',
'aligncenter',
'alignright',
'alignjustify'
];
var defaultAlign = 'alignleft';
var alignMenuItems = [
{
text: 'Left',
icon: 'alignleft',
onclick: toggleFormat(editor, 'alignleft')
},
{
text: 'Center',
icon: 'aligncenter',
onclick: toggleFormat(editor, 'aligncenter')
},
{
text: 'Right',
icon: 'alignright',
onclick: toggleFormat(editor, 'alignright')
},
{
text: 'Justify',
icon: 'alignjustify',
onclick: toggleFormat(editor, 'alignjustify')
}
];
editor.addMenuItem('align', {
text: 'Align',
menu: alignMenuItems
});
editor.addButton('align', {
type: 'menubutton',
icon: defaultAlign,
menu: alignMenuItems,
onShowMenu: function (e) {
var menu = e.control.menu;
global$2.each(alignFormats, function (formatName, idx) {
menu.items().eq(idx).each(function (item) {
return item.active(editor.formatter.match(formatName));
});
});
},
onPostRender: function (e) {
var ctrl = e.control;
global$2.each(alignFormats, function (formatName, idx) {
addFormatChangedListener(editor, formatName, function (state) {
ctrl.icon(defaultAlign);
if (state) {
ctrl.icon(formatName);
}
});
});
}
});
global$2.each({
alignleft: [
'Align left',
'JustifyLeft'
],
aligncenter: [
'Align center',
'JustifyCenter'
],
alignright: [
'Align right',
'JustifyRight'
],
alignjustify: [
'Justify',
'JustifyFull'
],
alignnone: [
'No alignment',
'JustifyNone'
]
}, function (item, name) {
editor.addButton(name, {
active: false,
tooltip: item[0],
cmd: item[1],
onPostRender: postRenderFormatToggle(editor, name)
});
});
};
var Align = { register: register };
var getFirstFont = function (fontFamily) {
return fontFamily ? fontFamily.split(',')[0] : '';
};
var findMatchingValue = function (items, fontFamily) {
var font = fontFamily ? fontFamily.toLowerCase() : '';
var value;
global$2.each(items, function (item) {
if (item.value.toLowerCase() === font) {
value = item.value;
}
});
global$2.each(items, function (item) {
if (!value && getFirstFont(item.value).toLowerCase() === getFirstFont(font).toLowerCase()) {
value = item.value;
}
});
return value;
};
var createFontNameListBoxChangeHandler = function (editor, items) {
return function () {
var self = this;
self.state.set('value', null);
editor.on('init nodeChange', function (e) {
var fontFamily = editor.queryCommandValue('FontName');
var match = findMatchingValue(items, fontFamily);
self.value(match ? match : null);
if (!match && fontFamily) {
self.text(getFirstFont(fontFamily));
}
});
};
};
var createFormats = function (formats) {
formats = formats.replace(/;$/, '').split(';');
var i = formats.length;
while (i--) {
formats[i] = formats[i].split('=');
}
return formats;
};
var getFontItems = function (editor) {
var defaultFontsFormats = 'Andale Mono=andale mono,monospace;' + 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,sans-serif;' + 'Book Antiqua=book antiqua,palatino,serif;' + 'Comic Sans MS=comic sans ms,sans-serif;' + 'Courier New=courier new,courier,monospace;' + 'Georgia=georgia,palatino,serif;' + 'Helvetica=helvetica,arial,sans-serif;' + 'Impact=impact,sans-serif;' + 'Symbol=symbol;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Terminal=terminal,monaco,monospace;' + 'Times New Roman=times new roman,times,serif;' + 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' + 'Verdana=verdana,geneva,sans-serif;' + 'Webdings=webdings;' + 'Wingdings=wingdings,zapf dingbats';
var fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
return global$2.map(fonts, function (font) {
return {
text: { raw: font[0] },
value: font[1],
textStyle: font[1].indexOf('dings') === -1 ? 'font-family:' + font[1] : ''
};
});
};
var registerButtons = function (editor) {
editor.addButton('fontselect', function () {
var items = getFontItems(editor);
return {
type: 'listbox',
text: 'Font Family',
tooltip: 'Font Family',
values: items,
fixedWidth: true,
onPostRender: createFontNameListBoxChangeHandler(editor, items),
onselect: function (e) {
if (e.control.settings.value) {
editor.execCommand('FontName', false, e.control.settings.value);
}
}
};
});
};
var register$1 = function (editor) {
registerButtons(editor);
};
var FontSelect = { register: register$1 };
var round = function (number, precision) {
var factor = Math.pow(10, precision);
return Math.round(number * factor) / factor;
};
var toPt = function (fontSize, precision) {
if (/[0-9.]+px$/.test(fontSize)) {
return round(parseInt(fontSize, 10) * 72 / 96, precision || 0) + 'pt';
}
return fontSize;
};
var findMatchingValue$1 = function (items, pt, px) {
var value;
global$2.each(items, function (item) {
if (item.value === px) {
value = px;
} else if (item.value === pt) {
value = pt;
}
});
return value;
};
var createFontSizeListBoxChangeHandler = function (editor, items) {
return function () {
var self = this;
editor.on('init nodeChange', function (e) {
var px, pt, precision, match;
px = editor.queryCommandValue('FontSize');
if (px) {
for (precision = 3; !match && precision >= 0; precision--) {
pt = toPt(px, precision);
match = findMatchingValue$1(items, pt, px);
}
}
self.value(match ? match : null);
if (!match) {
self.text(pt);
}
});
};
};
var getFontSizeItems = function (editor) {
var defaultFontsizeFormats = '8pt 10pt 12pt 14pt 18pt 24pt 36pt';
var fontsizeFormats = editor.settings.fontsize_formats || defaultFontsizeFormats;
return global$2.map(fontsizeFormats.split(' '), function (item) {
var text = item, value = item;
var values = item.split('=');
if (values.length > 1) {
text = values[0];
value = values[1];
}
return {
text: text,
value: value
};
});
};
var registerButtons$1 = function (editor) {
editor.addButton('fontsizeselect', function () {
var items = getFontSizeItems(editor);
return {
type: 'listbox',
text: 'Font Sizes',
tooltip: 'Font Sizes',
values: items,
fixedWidth: true,
onPostRender: createFontSizeListBoxChangeHandler(editor, items),
onclick: function (e) {
if (e.control.settings.value) {
editor.execCommand('FontSize', false, e.control.settings.value);
}
}
};
});
};
var register$2 = function (editor) {
registerButtons$1(editor);
};
var FontSizeSelect = { register: register$2 };
var hideMenuObjects = function (editor, menu) {
var count = menu.length;
global$2.each(menu, function (item) {
if (item.menu) {
item.hidden = hideMenuObjects(editor, item.menu) === 0;
}
var formatName = item.format;
if (formatName) {
item.hidden = !editor.formatter.canApply(formatName);
}
if (item.hidden) {
count--;
}
});
return count;
};
var hideFormatMenuItems = function (editor, menu) {
var count = menu.items().length;
menu.items().each(function (item) {
if (item.menu) {
item.visible(hideFormatMenuItems(editor, item.menu) > 0);
}
if (!item.menu && item.settings.menu) {
item.visible(hideMenuObjects(editor, item.settings.menu) > 0);
}
var formatName = item.settings.format;
if (formatName) {
item.visible(editor.formatter.canApply(formatName));
}
if (!item.visible()) {
count--;
}
});
return count;
};
var createFormatMenu = function (editor) {
var count = 0;
var newFormats = [];
var defaultStyleFormats = [
{
title: 'Headings',
items: [
{
title: 'Heading 1',
format: 'h1'
},
{
title: 'Heading 2',
format: 'h2'
},
{
title: 'Heading 3',
format: 'h3'
},
{
title: 'Heading 4',
format: 'h4'
},
{
title: 'Heading 5',
format: 'h5'
},
{
title: 'Heading 6',
format: 'h6'
}
]
},
{
title: 'Inline',
items: [
{
title: 'Bold',
icon: 'bold',
format: 'bold'
},
{
title: 'Italic',
icon: 'italic',
format: 'italic'
},
{
title: 'Underline',
icon: 'underline',
format: 'underline'
},
{
title: 'Strikethrough',
icon: 'strikethrough',
format: 'strikethrough'
},
{
title: 'Superscript',
icon: 'superscript',
format: 'superscript'
},
{
title: 'Subscript',
icon: 'subscript',
format: 'subscript'
},
{
title: 'Code',
icon: 'code',
format: 'code'
}
]
},
{
title: 'Blocks',
items: [
{
title: 'Paragraph',
format: 'p'
},
{
title: 'Blockquote',
format: 'blockquote'
},
{
title: 'Div',
format: 'div'
},
{
title: 'Pre',
format: 'pre'
}
]
},
{
title: 'Alignment',
items: [
{
title: 'Left',
icon: 'alignleft',
format: 'alignleft'
},
{
title: 'Center',
icon: 'aligncenter',
format: 'aligncenter'
},
{
title: 'Right',
icon: 'alignright',
format: 'alignright'
},
{
title: 'Justify',
icon: 'alignjustify',
format: 'alignjustify'
}
]
}
];
var createMenu = function (formats) {
var menu = [];
if (!formats) {
return;
}
global$2.each(formats, function (format) {
var menuItem = {
text: format.title,
icon: format.icon
};
if (format.items) {
menuItem.menu = createMenu(format.items);
} else {
var formatName = format.format || 'custom' + count++;
if (!format.format) {
format.name = formatName;
newFormats.push(format);
}
menuItem.format = formatName;
menuItem.cmd = format.cmd;
}
menu.push(menuItem);
});
return menu;
};
var createStylesMenu = function () {
var menu;
if (editor.settings.style_formats_merge) {
if (editor.settings.style_formats) {
menu = createMenu(defaultStyleFormats.concat(editor.settings.style_formats));
} else {
menu = createMenu(defaultStyleFormats);
}
} else {
menu = createMenu(editor.settings.style_formats || defaultStyleFormats);
}
return menu;
};
editor.on('init', function () {
global$2.each(newFormats, function (format) {
editor.formatter.register(format.name, format);
});
});
return {
type: 'menu',
items: createStylesMenu(),
onPostRender: function (e) {
editor.fire('renderFormatsMenu', { control: e.control });
},
itemDefaults: {
preview: true,
textStyle: function () {
if (this.settings.format) {
return editor.formatter.getCssText(this.settings.format);
}
},
onPostRender: function () {
var self = this;
self.parent().on('show', function () {
var formatName, command;
formatName = self.settings.format;
if (formatName) {
self.disabled(!editor.formatter.canApply(formatName));
self.active(editor.formatter.match(formatName));
}
command = self.settings.cmd;
if (command) {
self.active(editor.queryCommandState(command));
}
});
},
onclick: function () {
if (this.settings.format) {
toggleFormat(editor, this.settings.format)();
}
if (this.settings.cmd) {
editor.execCommand(this.settings.cmd);
}
}
}
};
};
var registerMenuItems = function (editor, formatMenu) {
editor.addMenuItem('formats', {
text: 'Formats',
menu: formatMenu
});
};
var registerButtons$2 = function (editor, formatMenu) {
editor.addButton('styleselect', {
type: 'menubutton',
text: 'Formats',
menu: formatMenu,
onShowMenu: function () {
if (editor.settings.style_formats_autohide) {
hideFormatMenuItems(editor, this.menu);
}
}
});
};
var register$3 = function (editor) {
var formatMenu = createFormatMenu(editor);
registerMenuItems(editor, formatMenu);
registerButtons$2(editor, formatMenu);
};
var Formats = { register: register$3 };
var defaultBlocks = 'Paragraph=p;' + 'Heading 1=h1;' + 'Heading 2=h2;' + 'Heading 3=h3;' + 'Heading 4=h4;' + 'Heading 5=h5;' + 'Heading 6=h6;' + 'Preformatted=pre';
var createFormats$1 = function (formats) {
formats = formats.replace(/;$/, '').split(';');
var i = formats.length;
while (i--) {
formats[i] = formats[i].split('=');
}
return formats;
};
var createListBoxChangeHandler = function (editor, items, formatName) {
return function () {
var self = this;
editor.on('nodeChange', function (e) {
var formatter = editor.formatter;
var value = null;
global$2.each(e.parents, function (node) {
global$2.each(items, function (item) {
if (formatName) {
if (formatter.matchNode(node, formatName, { value: item.value })) {
value = item.value;
}
} else {
if (formatter.matchNode(node, item.value)) {
value = item.value;
}
}
if (value) {
return false;
}
});
if (value) {
return false;
}
});
self.value(value);
});
};
};
var lazyFormatSelectBoxItems = function (editor, blocks) {
return function () {
var items = [];
global$2.each(blocks, function (block) {
items.push({
text: block[0],
value: block[1],
textStyle: function () {
return editor.formatter.getCssText(block[1]);
}
});
});
return {
type: 'listbox',
text: blocks[0][0],
values: items,
fixedWidth: true,
onselect: function (e) {
if (e.control) {
var fmt = e.control.value();
toggleFormat(editor, fmt)();
}
},
onPostRender: createListBoxChangeHandler(editor, items)
};
};
};
var buildMenuItems = function (editor, blocks) {
return global$2.map(blocks, function (block) {
return {
text: block[0],
onclick: toggleFormat(editor, block[1]),
textStyle: function () {
return editor.formatter.getCssText(block[1]);
}
};
});
};
var register$4 = function (editor) {
var blocks = createFormats$1(editor.settings.block_formats || defaultBlocks);
editor.addMenuItem('blockformats', {
text: 'Blocks',
menu: buildMenuItems(editor, blocks)
});
editor.addButton('formatselect', lazyFormatSelectBoxItems(editor, blocks));
};
var FormatSelect = { register: register$4 };
var createCustomMenuItems = function (editor, names) {
var items, nameList;
if (typeof names === 'string') {
nameList = names.split(' ');
} else if (global$2.isArray(names)) {
return flatten(global$2.map(names, function (names) {
return createCustomMenuItems(editor, names);
}));
}
items = global$2.grep(nameList, function (name) {
return name === '|' || name in editor.menuItems;
});
return global$2.map(items, function (name) {
return name === '|' ? { text: '-' } : editor.menuItems[name];
});
};
var isSeparator$1 = function (menuItem) {
return menuItem && menuItem.text === '-';
};
var trimMenuItems = function (menuItems) {
var menuItems2 = filter(menuItems, function (menuItem, i) {
return !isSeparator$1(menuItem) || !isSeparator$1(menuItems[i - 1]);
});
return filter(menuItems2, function (menuItem, i) {
return !isSeparator$1(menuItem) || i > 0 && i < menuItems2.length - 1;
});
};
var createContextMenuItems = function (editor, context) {
var outputMenuItems = [{ text: '-' }];
var menuItems = global$2.grep(editor.menuItems, function (menuItem) {
return menuItem.context === context;
});
global$2.each(menuItems, function (menuItem) {
if (menuItem.separator === 'before') {
outputMenuItems.push({ text: '|' });
}
if (menuItem.prependToContext) {
outputMenuItems.unshift(menuItem);
} else {
outputMenuItems.push(menuItem);
}
if (menuItem.separator === 'after') {
outputMenuItems.push({ text: '|' });
}
});
return outputMenuItems;
};
var createInsertMenu = function (editor) {
var insertButtonItems = editor.settings.insert_button_items;
if (insertButtonItems) {
return trimMenuItems(createCustomMenuItems(editor, insertButtonItems));
} else {
return trimMenuItems(createContextMenuItems(editor, 'insert'));
}
};
var registerButtons$3 = function (editor) {
editor.addButton('insert', {
type: 'menubutton',
icon: 'insert',
menu: [],
oncreatemenu: function () {
this.menu.add(createInsertMenu(editor));
this.menu.renderNew();
}
});
};
var register$5 = function (editor) {
registerButtons$3(editor);
};
var InsertButton = { register: register$5 };
var registerFormatButtons = function (editor) {
global$2.each({
bold: 'Bold',
italic: 'Italic',
underline: 'Underline',
strikethrough: 'Strikethrough',
subscript: 'Subscript',
superscript: 'Superscript'
}, function (text, name) {
editor.addButton(name, {
active: false,
tooltip: text,
onPostRender: postRenderFormatToggle(editor, name),
onclick: toggleFormat(editor, name)
});
});
};
var registerCommandButtons = function (editor) {
global$2.each({
outdent: [
'Decrease indent',
'Outdent'
],
indent: [
'Increase indent',
'Indent'
],
cut: [
'Cut',
'Cut'
],
copy: [
'Copy',
'Copy'
],
paste: [
'Paste',
'Paste'
],
help: [
'Help',
'mceHelp'
],
selectall: [
'Select all',
'SelectAll'
],
visualaid: [
'Visual aids',
'mceToggleVisualAid'
],
newdocument: [
'New document',
'mceNewDocument'
],
removeformat: [
'Clear formatting',
'RemoveFormat'
],
remove: [
'Remove',
'Delete'
]
}, function (item, name) {
editor.addButton(name, {
tooltip: item[0],
cmd: item[1]
});
});
};
var registerCommandToggleButtons = function (editor) {
global$2.each({
blockquote: [
'Blockquote',
'mceBlockQuote'
],
subscript: [
'Subscript',
'Subscript'
],
superscript: [
'Superscript',
'Superscript'
]
}, function (item, name) {
editor.addButton(name, {
active: false,
tooltip: item[0],
cmd: item[1],
onPostRender: postRenderFormatToggle(editor, name)
});
});
};
var registerButtons$4 = function (editor) {
registerFormatButtons(editor);
registerCommandButtons(editor);
registerCommandToggleButtons(editor);
};
var registerMenuItems$1 = function (editor) {
global$2.each({
bold: [
'Bold',
'Bold',
'Meta+B'
],
italic: [
'Italic',
'Italic',
'Meta+I'
],
underline: [
'Underline',
'Underline',
'Meta+U'
],
strikethrough: [
'Strikethrough',
'Strikethrough'
],
subscript: [
'Subscript',
'Subscript'
],
superscript: [
'Superscript',
'Superscript'
],
removeformat: [
'Clear formatting',
'RemoveFormat'
],
newdocument: [
'New document',
'mceNewDocument'
],
cut: [
'Cut',
'Cut',
'Meta+X'
],
copy: [
'Copy',
'Copy',
'Meta+C'
],
paste: [
'Paste',
'Paste',
'Meta+V'
],
selectall: [
'Select all',
'SelectAll',
'Meta+A'
]
}, function (item, name) {
editor.addMenuItem(name, {
text: item[0],
icon: name,
shortcut: item[2],
cmd: item[1]
});
});
editor.addMenuItem('codeformat', {
text: 'Code',
icon: 'code',
onclick: toggleFormat(editor, 'code')
});
};
var register$6 = function (editor) {
registerButtons$4(editor);
registerMenuItems$1(editor);
};
var SimpleControls = { register: register$6 };
var toggleUndoRedoState = function (editor, type) {
return function () {
var self = this;
var checkState = function () {
var typeFn = type === 'redo' ? 'hasRedo' : 'hasUndo';
return editor.undoManager ? editor.undoManager[typeFn]() : false;
};
self.disabled(!checkState());
editor.on('Undo Redo AddUndo TypingUndo ClearUndos SwitchMode', function () {
self.disabled(editor.readonly || !checkState());
});
};
};
var registerMenuItems$2 = function (editor) {
editor.addMenuItem('undo', {
text: 'Undo',
icon: 'undo',
shortcut: 'Meta+Z',
onPostRender: toggleUndoRedoState(editor, 'undo'),
cmd: 'undo'
});
editor.addMenuItem('redo', {
text: 'Redo',
icon: 'redo',
shortcut: 'Meta+Y',
onPostRender: toggleUndoRedoState(editor, 'redo'),
cmd: 'redo'
});
};
var registerButtons$5 = function (editor) {
editor.addButton('undo', {
tooltip: 'Undo',
onPostRender: toggleUndoRedoState(editor, 'undo'),
cmd: 'undo'
});
editor.addButton('redo', {
tooltip: 'Redo',
onPostRender: toggleUndoRedoState(editor, 'redo'),
cmd: 'redo'
});
};
var register$7 = function (editor) {
registerMenuItems$2(editor);
registerButtons$5(editor);
};
var UndoRedo = { register: register$7 };
var toggleVisualAidState = function (editor) {
return function () {
var self = this;
editor.on('VisualAid', function (e) {
self.active(e.hasVisual);
});
self.active(editor.hasVisual);
};
};
var registerMenuItems$3 = function (editor) {
editor.addMenuItem('visualaid', {
text: 'Visual aids',
selectable: true,
onPostRender: toggleVisualAidState(editor),
cmd: 'mceToggleVisualAid'
});
};
var register$8 = function (editor) {
registerMenuItems$3(editor);
};
var VisualAid = { register: register$8 };
var setupEnvironment = function () {
Widget.tooltips = !global$8.iOS;
Control$1.translate = function (text) {
return global$1.translate(text);
};
};
var setupUiContainer = function (editor) {
if (editor.settings.ui_container) {
global$8.container = descendant(Element.fromDom(domGlobals.document.body), editor.settings.ui_container).fold(constant(null), function (elm) {
return elm.dom();
});
}
};
var setupRtlMode = function (editor) {
if (editor.rtl) {
Control$1.rtl = true;
}
};
var setupHideFloatPanels = function (editor) {
editor.on('mousedown progressstate', function () {
FloatPanel.hideAll();
});
};
var setup$1 = function (editor) {
setupRtlMode(editor);
setupHideFloatPanels(editor);
setupUiContainer(editor);
setupEnvironment();
FormatSelect.register(editor);
Align.register(editor);
SimpleControls.register(editor);
UndoRedo.register(editor);
FontSizeSelect.register(editor);
FontSelect.register(editor);
Formats.register(editor);
VisualAid.register(editor);
InsertButton.register(editor);
};
var FormatControls = { setup: setup$1 };
var GridLayout = AbsoluteLayout.extend({
recalc: function (container) {
var settings, rows, cols, items, contLayoutRect, width, height, rect, ctrlLayoutRect, ctrl, x, y, posX, posY, ctrlSettings, contPaddingBox, align, spacingH, spacingV, alignH, alignV, maxX, maxY;
var colWidths = [];
var rowHeights = [];
var ctrlMinWidth, ctrlMinHeight, availableWidth, availableHeight, reverseRows, idx;
settings = container.settings;
items = container.items().filter(':visible');
contLayoutRect = container.layoutRect();
cols = settings.columns || Math.ceil(Math.sqrt(items.length));
rows = Math.ceil(items.length / cols);
spacingH = settings.spacingH || settings.spacing || 0;
spacingV = settings.spacingV || settings.spacing || 0;
alignH = settings.alignH || settings.align;
alignV = settings.alignV || settings.align;
contPaddingBox = container.paddingBox;
reverseRows = 'reverseRows' in settings ? settings.reverseRows : container.isRtl();
if (alignH && typeof alignH === 'string') {
alignH = [alignH];
}
if (alignV && typeof alignV === 'string') {
alignV = [alignV];
}
for (x = 0; x < cols; x++) {
colWidths.push(0);
}
for (y = 0; y < rows; y++) {
rowHeights.push(0);
}
for (y = 0; y < rows; y++) {
for (x = 0; x < cols; x++) {
ctrl = items[y * cols + x];
if (!ctrl) {
break;
}
ctrlLayoutRect = ctrl.layoutRect();
ctrlMinWidth = ctrlLayoutRect.minW;
ctrlMinHeight = ctrlLayoutRect.minH;
colWidths[x] = ctrlMinWidth > colWidths[x] ? ctrlMinWidth : colWidths[x];
rowHeights[y] = ctrlMinHeight > rowHeights[y] ? ctrlMinHeight : rowHeights[y];
}
}
availableWidth = contLayoutRect.innerW - contPaddingBox.left - contPaddingBox.right;
for (maxX = 0, x = 0; x < cols; x++) {
maxX += colWidths[x] + (x > 0 ? spacingH : 0);
availableWidth -= (x > 0 ? spacingH : 0) + colWidths[x];
}
availableHeight = contLayoutRect.innerH - contPaddingBox.top - contPaddingBox.bottom;
for (maxY = 0, y = 0; y < rows; y++) {
maxY += rowHeights[y] + (y > 0 ? spacingV : 0);
availableHeight -= (y > 0 ? spacingV : 0) + rowHeights[y];
}
maxX += contPaddingBox.left + contPaddingBox.right;
maxY += contPaddingBox.top + contPaddingBox.bottom;
rect = {};
rect.minW = maxX + (contLayoutRect.w - contLayoutRect.innerW);
rect.minH = maxY + (contLayoutRect.h - contLayoutRect.innerH);
rect.contentW = rect.minW - contLayoutRect.deltaW;
rect.contentH = rect.minH - contLayoutRect.deltaH;
rect.minW = Math.min(rect.minW, contLayoutRect.maxW);
rect.minH = Math.min(rect.minH, contLayoutRect.maxH);
rect.minW = Math.max(rect.minW, contLayoutRect.startMinWidth);
rect.minH = Math.max(rect.minH, contLayoutRect.startMinHeight);
if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) {
rect.w = rect.minW;
rect.h = rect.minH;
container.layoutRect(rect);
this.recalc(container);
if (container._lastRect === null) {
var parentCtrl = container.parent();
if (parentCtrl) {
parentCtrl._lastRect = null;
parentCtrl.recalc();
}
}
return;
}
if (contLayoutRect.autoResize) {
rect = container.layoutRect(rect);
rect.contentW = rect.minW - contLayoutRect.deltaW;
rect.contentH = rect.minH - contLayoutRect.deltaH;
}
var flexV;
if (settings.packV === 'start') {
flexV = 0;
} else {
flexV = availableHeight > 0 ? Math.floor(availableHeight / rows) : 0;
}
var totalFlex = 0;
var flexWidths = settings.flexWidths;
if (flexWidths) {
for (x = 0; x < flexWidths.length; x++) {
totalFlex += flexWidths[x];
}
} else {
totalFlex = cols;
}
var ratio = availableWidth / totalFlex;
for (x = 0; x < cols; x++) {
colWidths[x] += flexWidths ? flexWidths[x] * ratio : ratio;
}
posY = contPaddingBox.top;
for (y = 0; y < rows; y++) {
posX = contPaddingBox.left;
height = rowHeights[y] + flexV;
for (x = 0; x < cols; x++) {
if (reverseRows) {
idx = y * cols + cols - 1 - x;
} else {
idx = y * cols + x;
}
ctrl = items[idx];
if (!ctrl) {
break;
}
ctrlSettings = ctrl.settings;
ctrlLayoutRect = ctrl.layoutRect();
width = Math.max(colWidths[x], ctrlLayoutRect.startMinWidth);
ctrlLayoutRect.x = posX;
ctrlLayoutRect.y = posY;
align = ctrlSettings.alignH || (alignH ? alignH[x] || alignH[0] : null);
if (align === 'center') {
ctrlLayoutRect.x = posX + width / 2 - ctrlLayoutRect.w / 2;
} else if (align === 'right') {
ctrlLayoutRect.x = posX + width - ctrlLayoutRect.w;
} else if (align === 'stretch') {
ctrlLayoutRect.w = width;
}
align = ctrlSettings.alignV || (alignV ? alignV[x] || alignV[0] : null);
if (align === 'center') {
ctrlLayoutRect.y = posY + height / 2 - ctrlLayoutRect.h / 2;
} else if (align === 'bottom') {
ctrlLayoutRect.y = posY + height - ctrlLayoutRect.h;
} else if (align === 'stretch') {
ctrlLayoutRect.h = height;
}
ctrl.layoutRect(ctrlLayoutRect);
posX += width + spacingH;
if (ctrl.recalc) {
ctrl.recalc();
}
}
posY += height + spacingV;
}
}
});
var Iframe$1 = Widget.extend({
renderHtml: function () {
var self = this;
self.classes.add('iframe');
self.canFocus = false;
return '';
},
src: function (src) {
this.getEl().src = src;
},
html: function (html, callback) {
var self = this, body = this.getEl().contentWindow.document.body;
if (!body) {
global$7.setTimeout(function () {
self.html(html);
});
} else {
body.innerHTML = html;
if (callback) {
callback();
}
}
return this;
}
});
var InfoBox = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('widget').add('infobox');
self.canFocus = false;
},
severity: function (level) {
this.classes.remove('error');
this.classes.remove('warning');
this.classes.remove('success');
this.classes.add(level);
},
help: function (state) {
this.state.set('help', state);
},
renderHtml: function () {
var self = this, prefix = self.classPrefix;
return '' + '
' + self.encode(self.state.get('text')) + '' + ' ' + ' ' + '
' + '
';
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.getEl('body').firstChild.data = self.encode(e.value);
if (self.state.get('rendered')) {
self.updateLayoutRect();
}
});
self.state.on('change:help', function (e) {
self.classes.toggle('has-help', e.value);
if (self.state.get('rendered')) {
self.updateLayoutRect();
}
});
return self._super();
}
});
var Label = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('widget').add('label');
self.canFocus = false;
if (settings.multiline) {
self.classes.add('autoscroll');
}
if (settings.strong) {
self.classes.add('strong');
}
},
initLayoutRect: function () {
var self = this, layoutRect = self._super();
if (self.settings.multiline) {
var size = funcs.getSize(self.getEl());
if (size.width > layoutRect.maxW) {
layoutRect.minW = layoutRect.maxW;
self.classes.add('multiline');
}
self.getEl().style.width = layoutRect.minW + 'px';
layoutRect.startMinH = layoutRect.h = layoutRect.minH = Math.min(layoutRect.maxH, funcs.getSize(self.getEl()).height);
}
return layoutRect;
},
repaint: function () {
var self = this;
if (!self.settings.multiline) {
self.getEl().style.lineHeight = self.layoutRect().h + 'px';
}
return self._super();
},
severity: function (level) {
this.classes.remove('error');
this.classes.remove('warning');
this.classes.remove('success');
this.classes.add(level);
},
renderHtml: function () {
var self = this;
var targetCtrl, forName, forId = self.settings.forId;
var text = self.settings.html ? self.settings.html : self.encode(self.state.get('text'));
if (!forId && (forName = self.settings.forName)) {
targetCtrl = self.getRoot().find('#' + forName)[0];
if (targetCtrl) {
forId = targetCtrl._id;
}
}
if (forId) {
return '' + text + ' ';
}
return '' + text + ' ';
},
bindStates: function () {
var self = this;
self.state.on('change:text', function (e) {
self.innerHtml(self.encode(e.value));
if (self.state.get('rendered')) {
self.updateLayoutRect();
}
});
return self._super();
}
});
var Toolbar$1 = Container.extend({
Defaults: {
role: 'toolbar',
layout: 'flow'
},
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('toolbar');
},
postRender: function () {
var self = this;
self.items().each(function (ctrl) {
ctrl.classes.add('toolbar-item');
});
return self._super();
}
});
var MenuBar = Toolbar$1.extend({
Defaults: {
role: 'menubar',
containerCls: 'menubar',
ariaRoot: true,
defaults: { type: 'menubutton' }
}
});
function isChildOf$1(node, parent) {
while (node) {
if (parent === node) {
return true;
}
node = node.parentNode;
}
return false;
}
var MenuButton = Button.extend({
init: function (settings) {
var self = this;
self._renderOpen = true;
self._super(settings);
settings = self.settings;
self.classes.add('menubtn');
if (settings.fixedWidth) {
self.classes.add('fixed-width');
}
self.aria('haspopup', true);
self.state.set('menu', settings.menu || self.render());
},
showMenu: function (toggle) {
var self = this;
var menu;
if (self.menu && self.menu.visible() && toggle !== false) {
return self.hideMenu();
}
if (!self.menu) {
menu = self.state.get('menu') || [];
self.classes.add('opened');
if (menu.length) {
menu = {
type: 'menu',
animate: true,
items: menu
};
} else {
menu.type = menu.type || 'menu';
menu.animate = true;
}
if (!menu.renderTo) {
self.menu = global$4.create(menu).parent(self).renderTo();
} else {
self.menu = menu.parent(self).show().renderTo();
}
self.fire('createmenu');
self.menu.reflow();
self.menu.on('cancel', function (e) {
if (e.control.parent() === self.menu) {
e.stopPropagation();
self.focus();
self.hideMenu();
}
});
self.menu.on('select', function () {
self.focus();
});
self.menu.on('show hide', function (e) {
if (e.type === 'hide' && e.control.parent() === self) {
self.classes.remove('opened-under');
}
if (e.control === self.menu) {
self.activeMenu(e.type === 'show');
self.classes.toggle('opened', e.type === 'show');
}
self.aria('expanded', e.type === 'show');
}).fire('show');
}
self.menu.show();
self.menu.layoutRect({ w: self.layoutRect().w });
self.menu.repaint();
self.menu.moveRel(self.getEl(), self.isRtl() ? [
'br-tr',
'tr-br'
] : [
'bl-tl',
'tl-bl'
]);
var menuLayoutRect = self.menu.layoutRect();
var selfBottom = self.$el.offset().top + self.layoutRect().h;
if (selfBottom > menuLayoutRect.y && selfBottom < menuLayoutRect.y + menuLayoutRect.h) {
self.classes.add('opened-under');
}
self.fire('showmenu');
},
hideMenu: function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
}
},
activeMenu: function (state) {
this.classes.toggle('active', state);
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
var icon = self.settings.icon, image;
var text = self.state.get('text');
var textHtml = '';
image = self.settings.image;
if (image) {
icon = 'none';
if (typeof image !== 'string') {
image = domGlobals.window.getSelection ? image[0] : image[1];
}
image = ' style="background-image: url(\'' + image + '\')"';
} else {
image = '';
}
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
self.aria('role', self.parent() instanceof MenuBar ? 'menuitem' : 'button');
return '' + '' + (icon ? ' ' : '') + textHtml + ' ' + ' ' + '
';
},
postRender: function () {
var self = this;
self.on('click', function (e) {
if (e.control === self && isChildOf$1(e.target, self.getEl())) {
self.focus();
self.showMenu(!e.aria);
if (e.aria) {
self.menu.items().filter(':visible')[0].focus();
}
}
});
self.on('mouseenter', function (e) {
var overCtrl = e.control;
var parent = self.parent();
var hasVisibleSiblingMenu;
if (overCtrl && parent && overCtrl instanceof MenuButton && overCtrl.parent() === parent) {
parent.items().filter('MenuButton').each(function (ctrl) {
if (ctrl.hideMenu && ctrl !== overCtrl) {
if (ctrl.menu && ctrl.menu.visible()) {
hasVisibleSiblingMenu = true;
}
ctrl.hideMenu();
}
});
if (hasVisibleSiblingMenu) {
overCtrl.focus();
overCtrl.showMenu();
}
}
});
return self._super();
},
bindStates: function () {
var self = this;
self.state.on('change:menu', function () {
if (self.menu) {
self.menu.remove();
}
self.menu = null;
});
return self._super();
},
remove: function () {
this._super();
if (this.menu) {
this.menu.remove();
}
}
});
var Menu = FloatPanel.extend({
Defaults: {
defaultType: 'menuitem',
border: 1,
layout: 'stack',
role: 'application',
bodyRole: 'menu',
ariaRoot: true
},
init: function (settings) {
var self = this;
settings.autohide = true;
settings.constrainToViewport = true;
if (typeof settings.items === 'function') {
settings.itemsFactory = settings.items;
settings.items = [];
}
if (settings.itemDefaults) {
var items = settings.items;
var i = items.length;
while (i--) {
items[i] = global$2.extend({}, settings.itemDefaults, items[i]);
}
}
self._super(settings);
self.classes.add('menu');
if (settings.animate && global$8.ie !== 11) {
self.classes.add('animate');
}
},
repaint: function () {
this.classes.toggle('menu-align', true);
this._super();
this.getEl().style.height = '';
this.getEl('body').style.height = '';
return this;
},
cancel: function () {
var self = this;
self.hideAll();
self.fire('select');
},
load: function () {
var self = this;
var time, factory;
function hideThrobber() {
if (self.throbber) {
self.throbber.hide();
self.throbber = null;
}
}
factory = self.settings.itemsFactory;
if (!factory) {
return;
}
if (!self.throbber) {
self.throbber = new Throbber(self.getEl('body'), true);
if (self.items().length === 0) {
self.throbber.show();
self.fire('loading');
} else {
self.throbber.show(100, function () {
self.items().remove();
self.fire('loading');
});
}
self.on('hide close', hideThrobber);
}
self.requestTime = time = new Date().getTime();
self.settings.itemsFactory(function (items) {
if (items.length === 0) {
self.hide();
return;
}
if (self.requestTime !== time) {
return;
}
self.getEl().style.width = '';
self.getEl('body').style.width = '';
hideThrobber();
self.items().remove();
self.getEl('body').innerHTML = '';
self.add(items);
self.renderNew();
self.fire('loaded');
});
},
hideAll: function () {
var self = this;
this.find('menuitem').exec('hideMenu');
return self._super();
},
preRender: function () {
var self = this;
self.items().each(function (ctrl) {
var settings = ctrl.settings;
if (settings.icon || settings.image || settings.selectable) {
self._hasIcons = true;
return false;
}
});
if (self.settings.itemsFactory) {
self.on('postrender', function () {
if (self.settings.itemsFactory) {
self.load();
}
});
}
self.on('show hide', function (e) {
if (e.control === self) {
if (e.type === 'show') {
global$7.setTimeout(function () {
self.classes.add('in');
}, 0);
} else {
self.classes.remove('in');
}
}
});
return self._super();
}
});
var ListBox = MenuButton.extend({
init: function (settings) {
var self = this;
var values, selected, selectedText, lastItemCtrl;
function setSelected(menuValues) {
for (var i = 0; i < menuValues.length; i++) {
selected = menuValues[i].selected || settings.value === menuValues[i].value;
if (selected) {
selectedText = selectedText || menuValues[i].text;
self.state.set('value', menuValues[i].value);
return true;
}
if (menuValues[i].menu) {
if (setSelected(menuValues[i].menu)) {
return true;
}
}
}
}
self._super(settings);
settings = self.settings;
self._values = values = settings.values;
if (values) {
if (typeof settings.value !== 'undefined') {
setSelected(values);
}
if (!selected && values.length > 0) {
selectedText = values[0].text;
self.state.set('value', values[0].value);
}
self.state.set('menu', values);
}
self.state.set('text', settings.text || selectedText);
self.classes.add('listbox');
self.on('select', function (e) {
var ctrl = e.control;
if (lastItemCtrl) {
e.lastControl = lastItemCtrl;
}
if (settings.multiple) {
ctrl.active(!ctrl.active());
} else {
self.value(e.control.value());
}
lastItemCtrl = ctrl;
});
},
value: function (value) {
if (arguments.length === 0) {
return this.state.get('value');
}
if (typeof value === 'undefined') {
return this;
}
function valueExists(values) {
return exists(values, function (a) {
return a.menu ? valueExists(a.menu) : a.value === value;
});
}
if (this.settings.values) {
if (valueExists(this.settings.values)) {
this.state.set('value', value);
} else if (value === null) {
this.state.set('value', null);
}
} else {
this.state.set('value', value);
}
return this;
},
bindStates: function () {
var self = this;
function activateMenuItemsByValue(menu, value) {
if (menu instanceof Menu) {
menu.items().each(function (ctrl) {
if (!ctrl.hasMenus()) {
ctrl.active(ctrl.value() === value);
}
});
}
}
function getSelectedItem(menuValues, value) {
var selectedItem;
if (!menuValues) {
return;
}
for (var i = 0; i < menuValues.length; i++) {
if (menuValues[i].value === value) {
return menuValues[i];
}
if (menuValues[i].menu) {
selectedItem = getSelectedItem(menuValues[i].menu, value);
if (selectedItem) {
return selectedItem;
}
}
}
}
self.on('show', function (e) {
activateMenuItemsByValue(e.control, self.value());
});
self.state.on('change:value', function (e) {
var selectedItem = getSelectedItem(self.state.get('menu'), e.value);
if (selectedItem) {
self.text(selectedItem.text);
} else {
self.text(self.settings.text);
}
});
return self._super();
}
});
var toggleTextStyle = function (ctrl, state) {
var textStyle = ctrl._textStyle;
if (textStyle) {
var textElm = ctrl.getEl('text');
textElm.setAttribute('style', textStyle);
if (state) {
textElm.style.color = '';
textElm.style.backgroundColor = '';
}
}
};
var MenuItem = Widget.extend({
Defaults: {
border: 0,
role: 'menuitem'
},
init: function (settings) {
var self = this;
var text;
self._super(settings);
settings = self.settings;
self.classes.add('menu-item');
if (settings.menu) {
self.classes.add('menu-item-expand');
}
if (settings.preview) {
self.classes.add('menu-item-preview');
}
text = self.state.get('text');
if (text === '-' || text === '|') {
self.classes.add('menu-item-sep');
self.aria('role', 'separator');
self.state.set('text', '-');
}
if (settings.selectable) {
self.aria('role', 'menuitemcheckbox');
self.classes.add('menu-item-checkbox');
settings.icon = 'selected';
}
if (!settings.preview && !settings.selectable) {
self.classes.add('menu-item-normal');
}
self.on('mousedown', function (e) {
e.preventDefault();
});
if (settings.menu && !settings.ariaHideMenu) {
self.aria('haspopup', true);
}
},
hasMenus: function () {
return !!this.settings.menu;
},
showMenu: function () {
var self = this;
var settings = self.settings;
var menu;
var parent = self.parent();
parent.items().each(function (ctrl) {
if (ctrl !== self) {
ctrl.hideMenu();
}
});
if (settings.menu) {
menu = self.menu;
if (!menu) {
menu = settings.menu;
if (menu.length) {
menu = {
type: 'menu',
items: menu
};
} else {
menu.type = menu.type || 'menu';
}
if (parent.settings.itemDefaults) {
menu.itemDefaults = parent.settings.itemDefaults;
}
menu = self.menu = global$4.create(menu).parent(self).renderTo();
menu.reflow();
menu.on('cancel', function (e) {
e.stopPropagation();
self.focus();
menu.hide();
});
menu.on('show hide', function (e) {
if (e.control.items) {
e.control.items().each(function (ctrl) {
ctrl.active(ctrl.settings.selected);
});
}
}).fire('show');
menu.on('hide', function (e) {
if (e.control === menu) {
self.classes.remove('selected');
}
});
menu.submenu = true;
} else {
menu.show();
}
menu._parentMenu = parent;
menu.classes.add('menu-sub');
var rel = menu.testMoveRel(self.getEl(), self.isRtl() ? [
'tl-tr',
'bl-br',
'tr-tl',
'br-bl'
] : [
'tr-tl',
'br-bl',
'tl-tr',
'bl-br'
]);
menu.moveRel(self.getEl(), rel);
menu.rel = rel;
rel = 'menu-sub-' + rel;
menu.classes.remove(menu._lastRel).add(rel);
menu._lastRel = rel;
self.classes.add('selected');
self.aria('expanded', true);
}
},
hideMenu: function () {
var self = this;
if (self.menu) {
self.menu.items().each(function (item) {
if (item.hideMenu) {
item.hideMenu();
}
});
self.menu.hide();
self.aria('expanded', false);
}
return self;
},
renderHtml: function () {
var self = this;
var id = self._id;
var settings = self.settings;
var prefix = self.classPrefix;
var text = self.state.get('text');
var icon = self.settings.icon, image = '', shortcut = settings.shortcut;
var url = self.encode(settings.url), iconHtml = '';
function convertShortcut(shortcut) {
var i, value, replace = {};
if (global$8.mac) {
replace = {
alt: '⌥',
ctrl: '⌘',
shift: '⇧',
meta: '⌘'
};
} else {
replace = { meta: 'Ctrl' };
}
shortcut = shortcut.split('+');
for (i = 0; i < shortcut.length; i++) {
value = replace[shortcut[i].toLowerCase()];
if (value) {
shortcut[i] = value;
}
}
return shortcut.join('+');
}
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
function markMatches(text) {
var match = settings.match || '';
return match ? text.replace(new RegExp(escapeRegExp(match), 'gi'), function (match) {
return '!mce~match[' + match + ']mce~match!';
}) : text;
}
function boldMatches(text) {
return text.replace(new RegExp(escapeRegExp('!mce~match['), 'g'), '').replace(new RegExp(escapeRegExp(']mce~match!'), 'g'), ' ');
}
if (icon) {
self.parent().classes.add('menu-has-icons');
}
if (settings.image) {
image = ' style="background-image: url(\'' + settings.image + '\')"';
}
if (shortcut) {
shortcut = convertShortcut(shortcut);
}
icon = prefix + 'ico ' + prefix + 'i-' + (self.settings.icon || 'none');
iconHtml = text !== '-' ? ' \xA0' : '';
text = boldMatches(self.encode(markMatches(text)));
url = boldMatches(self.encode(markMatches(url)));
return '' + iconHtml + (text !== '-' ? '
' + text + ' ' : '') + (shortcut ? '' : '') + (settings.menu ? '
' : '') + (url ? '' : '') + '
';
},
postRender: function () {
var self = this, settings = self.settings;
var textStyle = settings.textStyle;
if (typeof textStyle === 'function') {
textStyle = textStyle.call(this);
}
if (textStyle) {
var textElm = self.getEl('text');
if (textElm) {
textElm.setAttribute('style', textStyle);
self._textStyle = textStyle;
}
}
self.on('mouseenter click', function (e) {
if (e.control === self) {
if (!settings.menu && e.type === 'click') {
self.fire('select');
global$7.requestAnimationFrame(function () {
self.parent().hideAll();
});
} else {
self.showMenu();
if (e.aria) {
self.menu.focus(true);
}
}
}
});
self._super();
return self;
},
hover: function () {
var self = this;
self.parent().items().each(function (ctrl) {
ctrl.classes.remove('selected');
});
self.classes.toggle('selected', true);
return self;
},
active: function (state) {
toggleTextStyle(this, state);
if (typeof state !== 'undefined') {
this.aria('checked', state);
}
return this._super(state);
},
remove: function () {
this._super();
if (this.menu) {
this.menu.remove();
}
}
});
var Radio = Checkbox.extend({
Defaults: {
classes: 'radio',
role: 'radio'
}
});
var ResizeHandle = Widget.extend({
renderHtml: function () {
var self = this, prefix = self.classPrefix;
self.classes.add('resizehandle');
if (self.settings.direction === 'both') {
self.classes.add('resizehandle-both');
}
self.canFocus = false;
return '' + ' ' + '
';
},
postRender: function () {
var self = this;
self._super();
self.resizeDragHelper = new DragHelper(this._id, {
start: function () {
self.fire('ResizeStart');
},
drag: function (e) {
if (self.settings.direction !== 'both') {
e.deltaX = 0;
}
self.fire('Resize', e);
},
stop: function () {
self.fire('ResizeEnd');
}
});
},
remove: function () {
if (this.resizeDragHelper) {
this.resizeDragHelper.destroy();
}
return this._super();
}
});
function createOptions(options) {
var strOptions = '';
if (options) {
for (var i = 0; i < options.length; i++) {
strOptions += '' + options[i] + ' ';
}
}
return strOptions;
}
var SelectBox = Widget.extend({
Defaults: {
classes: 'selectbox',
role: 'selectbox',
options: []
},
init: function (settings) {
var self = this;
self._super(settings);
if (self.settings.size) {
self.size = self.settings.size;
}
if (self.settings.options) {
self._options = self.settings.options;
}
self.on('keydown', function (e) {
var rootControl;
if (e.keyCode === 13) {
e.preventDefault();
self.parents().reverse().each(function (ctrl) {
if (ctrl.toJSON) {
rootControl = ctrl;
return false;
}
});
self.fire('submit', { data: rootControl.toJSON() });
}
});
},
options: function (state) {
if (!arguments.length) {
return this.state.get('options');
}
this.state.set('options', state);
return this;
},
renderHtml: function () {
var self = this;
var options, size = '';
options = createOptions(self._options);
if (self.size) {
size = ' size = "' + self.size + '"';
}
return '' + options + ' ';
},
bindStates: function () {
var self = this;
self.state.on('change:options', function (e) {
self.getEl().innerHTML = createOptions(e.value);
});
return self._super();
}
});
function constrain(value, minVal, maxVal) {
if (value < minVal) {
value = minVal;
}
if (value > maxVal) {
value = maxVal;
}
return value;
}
function setAriaProp(el, name, value) {
el.setAttribute('aria-' + name, value);
}
function updateSliderHandle(ctrl, value) {
var maxHandlePos, shortSizeName, sizeName, stylePosName, styleValue, handleEl;
if (ctrl.settings.orientation === 'v') {
stylePosName = 'top';
sizeName = 'height';
shortSizeName = 'h';
} else {
stylePosName = 'left';
sizeName = 'width';
shortSizeName = 'w';
}
handleEl = ctrl.getEl('handle');
maxHandlePos = (ctrl.layoutRect()[shortSizeName] || 100) - funcs.getSize(handleEl)[sizeName];
styleValue = maxHandlePos * ((value - ctrl._minValue) / (ctrl._maxValue - ctrl._minValue)) + 'px';
handleEl.style[stylePosName] = styleValue;
handleEl.style.height = ctrl.layoutRect().h + 'px';
setAriaProp(handleEl, 'valuenow', value);
setAriaProp(handleEl, 'valuetext', '' + ctrl.settings.previewFilter(value));
setAriaProp(handleEl, 'valuemin', ctrl._minValue);
setAriaProp(handleEl, 'valuemax', ctrl._maxValue);
}
var Slider = Widget.extend({
init: function (settings) {
var self = this;
if (!settings.previewFilter) {
settings.previewFilter = function (value) {
return Math.round(value * 100) / 100;
};
}
self._super(settings);
self.classes.add('slider');
if (settings.orientation === 'v') {
self.classes.add('vertical');
}
self._minValue = isNumber(settings.minValue) ? settings.minValue : 0;
self._maxValue = isNumber(settings.maxValue) ? settings.maxValue : 100;
self._initValue = self.state.get('value');
},
renderHtml: function () {
var self = this, id = self._id, prefix = self.classPrefix;
return '';
},
reset: function () {
this.value(this._initValue).repaint();
},
postRender: function () {
var self = this;
var minValue, maxValue, screenCordName, stylePosName, sizeName, shortSizeName;
function toFraction(min, max, val) {
return (val + min) / (max - min);
}
function fromFraction(min, max, val) {
return val * (max - min) - min;
}
function handleKeyboard(minValue, maxValue) {
function alter(delta) {
var value;
value = self.value();
value = fromFraction(minValue, maxValue, toFraction(minValue, maxValue, value) + delta * 0.05);
value = constrain(value, minValue, maxValue);
self.value(value);
self.fire('dragstart', { value: value });
self.fire('drag', { value: value });
self.fire('dragend', { value: value });
}
self.on('keydown', function (e) {
switch (e.keyCode) {
case 37:
case 38:
alter(-1);
break;
case 39:
case 40:
alter(1);
break;
}
});
}
function handleDrag(minValue, maxValue, handleEl) {
var startPos, startHandlePos, maxHandlePos, handlePos, value;
self._dragHelper = new DragHelper(self._id, {
handle: self._id + '-handle',
start: function (e) {
startPos = e[screenCordName];
startHandlePos = parseInt(self.getEl('handle').style[stylePosName], 10);
maxHandlePos = (self.layoutRect()[shortSizeName] || 100) - funcs.getSize(handleEl)[sizeName];
self.fire('dragstart', { value: value });
},
drag: function (e) {
var delta = e[screenCordName] - startPos;
handlePos = constrain(startHandlePos + delta, 0, maxHandlePos);
handleEl.style[stylePosName] = handlePos + 'px';
value = minValue + handlePos / maxHandlePos * (maxValue - minValue);
self.value(value);
self.tooltip().text('' + self.settings.previewFilter(value)).show().moveRel(handleEl, 'bc tc');
self.fire('drag', { value: value });
},
stop: function () {
self.tooltip().hide();
self.fire('dragend', { value: value });
}
});
}
minValue = self._minValue;
maxValue = self._maxValue;
if (self.settings.orientation === 'v') {
screenCordName = 'screenY';
stylePosName = 'top';
sizeName = 'height';
shortSizeName = 'h';
} else {
screenCordName = 'screenX';
stylePosName = 'left';
sizeName = 'width';
shortSizeName = 'w';
}
self._super();
handleKeyboard(minValue, maxValue);
handleDrag(minValue, maxValue, self.getEl('handle'));
},
repaint: function () {
this._super();
updateSliderHandle(this, this.value());
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
updateSliderHandle(self, e.value);
});
return self._super();
}
});
var Spacer = Widget.extend({
renderHtml: function () {
var self = this;
self.classes.add('spacer');
self.canFocus = false;
return '
';
}
});
var SplitButton = MenuButton.extend({
Defaults: {
classes: 'widget btn splitbtn',
role: 'button'
},
repaint: function () {
var self = this;
var elm = self.getEl();
var rect = self.layoutRect();
var mainButtonElm, menuButtonElm;
self._super();
mainButtonElm = elm.firstChild;
menuButtonElm = elm.lastChild;
global$9(mainButtonElm).css({
width: rect.w - funcs.getSize(menuButtonElm).width,
height: rect.h - 2
});
global$9(menuButtonElm).css({ height: rect.h - 2 });
return self;
},
activeMenu: function (state) {
var self = this;
global$9(self.getEl().lastChild).toggleClass(self.classPrefix + 'active', state);
},
renderHtml: function () {
var self = this;
var id = self._id;
var prefix = self.classPrefix;
var image;
var icon = self.state.get('icon');
var text = self.state.get('text');
var settings = self.settings;
var textHtml = '', ariaPressed;
image = settings.image;
if (image) {
icon = 'none';
if (typeof image !== 'string') {
image = domGlobals.window.getSelection ? image[0] : image[1];
}
image = ' style="background-image: url(\'' + image + '\')"';
} else {
image = '';
}
icon = settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : '';
if (text) {
self.classes.add('btn-has-text');
textHtml = '' + self.encode(text) + ' ';
}
ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : '';
return '' + '' + (icon ? ' ' : '') + textHtml + ' ' + '' + (self._menuBtnText ? (icon ? '\xA0' : '') + self._menuBtnText : '') + ' ' + ' ' + '
';
},
postRender: function () {
var self = this, onClickHandler = self.settings.onclick;
self.on('click', function (e) {
var node = e.target;
if (e.control === this) {
while (node) {
if (e.aria && e.aria.key !== 'down' || node.nodeName === 'BUTTON' && node.className.indexOf('open') === -1) {
e.stopImmediatePropagation();
if (onClickHandler) {
onClickHandler.call(this, e);
}
return;
}
node = node.parentNode;
}
}
});
delete self.settings.onclick;
return self._super();
}
});
var StackLayout = FlowLayout.extend({
Defaults: {
containerClass: 'stack-layout',
controlClass: 'stack-layout-item',
endClass: 'break'
},
isNative: function () {
return true;
}
});
var TabPanel = Panel.extend({
Defaults: {
layout: 'absolute',
defaults: { type: 'panel' }
},
activateTab: function (idx) {
var activeTabElm;
if (this.activeTabId) {
activeTabElm = this.getEl(this.activeTabId);
global$9(activeTabElm).removeClass(this.classPrefix + 'active');
activeTabElm.setAttribute('aria-selected', 'false');
}
this.activeTabId = 't' + idx;
activeTabElm = this.getEl('t' + idx);
activeTabElm.setAttribute('aria-selected', 'true');
global$9(activeTabElm).addClass(this.classPrefix + 'active');
this.items()[idx].show().fire('showtab');
this.reflow();
this.items().each(function (item, i) {
if (idx !== i) {
item.hide();
}
});
},
renderHtml: function () {
var self = this;
var layout = self._layout;
var tabsHtml = '';
var prefix = self.classPrefix;
self.preRender();
layout.preRender(self);
self.items().each(function (ctrl, i) {
var id = self._id + '-t' + i;
ctrl.aria('role', 'tabpanel');
ctrl.aria('labelledby', id);
tabsHtml += '' + self.encode(ctrl.settings.title) + '
';
});
return '' + '
' + tabsHtml + '
' + '
' + layout.renderHtml(self) + '
' + '
';
},
postRender: function () {
var self = this;
self._super();
self.settings.activeTab = self.settings.activeTab || 0;
self.activateTab(self.settings.activeTab);
this.on('click', function (e) {
var targetParent = e.target.parentNode;
if (targetParent && targetParent.id === self._id + '-head') {
var i = targetParent.childNodes.length;
while (i--) {
if (targetParent.childNodes[i] === e.target) {
self.activateTab(i);
}
}
}
});
},
initLayoutRect: function () {
var self = this;
var rect, minW, minH;
minW = funcs.getSize(self.getEl('head')).width;
minW = minW < 0 ? 0 : minW;
minH = 0;
self.items().each(function (item) {
minW = Math.max(minW, item.layoutRect().minW);
minH = Math.max(minH, item.layoutRect().minH);
});
self.items().each(function (ctrl) {
ctrl.settings.x = 0;
ctrl.settings.y = 0;
ctrl.settings.w = minW;
ctrl.settings.h = minH;
ctrl.layoutRect({
x: 0,
y: 0,
w: minW,
h: minH
});
});
var headH = funcs.getSize(self.getEl('head')).height;
self.settings.minWidth = minW;
self.settings.minHeight = minH + headH;
rect = self._super();
rect.deltaH += headH;
rect.innerH = rect.h - rect.deltaH;
return rect;
}
});
var TextBox = Widget.extend({
init: function (settings) {
var self = this;
self._super(settings);
self.classes.add('textbox');
if (settings.multiline) {
self.classes.add('multiline');
} else {
self.on('keydown', function (e) {
var rootControl;
if (e.keyCode === 13) {
e.preventDefault();
self.parents().reverse().each(function (ctrl) {
if (ctrl.toJSON) {
rootControl = ctrl;
return false;
}
});
self.fire('submit', { data: rootControl.toJSON() });
}
});
self.on('keyup', function (e) {
self.state.set('value', e.target.value);
});
}
},
repaint: function () {
var self = this;
var style, rect, borderBox, borderW, borderH = 0, lastRepaintRect;
style = self.getEl().style;
rect = self._layoutRect;
lastRepaintRect = self._lastRepaintRect || {};
var doc = domGlobals.document;
if (!self.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) {
style.lineHeight = rect.h - borderH + 'px';
}
borderBox = self.borderBox;
borderW = borderBox.left + borderBox.right + 8;
borderH = borderBox.top + borderBox.bottom + (self.settings.multiline ? 8 : 0);
if (rect.x !== lastRepaintRect.x) {
style.left = rect.x + 'px';
lastRepaintRect.x = rect.x;
}
if (rect.y !== lastRepaintRect.y) {
style.top = rect.y + 'px';
lastRepaintRect.y = rect.y;
}
if (rect.w !== lastRepaintRect.w) {
style.width = rect.w - borderW + 'px';
lastRepaintRect.w = rect.w;
}
if (rect.h !== lastRepaintRect.h) {
style.height = rect.h - borderH + 'px';
lastRepaintRect.h = rect.h;
}
self._lastRepaintRect = lastRepaintRect;
self.fire('repaint', {}, false);
return self;
},
renderHtml: function () {
var self = this;
var settings = self.settings;
var attrs, elm;
attrs = {
id: self._id,
hidefocus: '1'
};
global$2.each([
'rows',
'spellcheck',
'maxLength',
'size',
'readonly',
'min',
'max',
'step',
'list',
'pattern',
'placeholder',
'required',
'multiple'
], function (name) {
attrs[name] = settings[name];
});
if (self.disabled()) {
attrs.disabled = 'disabled';
}
if (settings.subtype) {
attrs.type = settings.subtype;
}
elm = funcs.create(settings.multiline ? 'textarea' : 'input', attrs);
elm.value = self.state.get('value');
elm.className = self.classes.toString();
return elm.outerHTML;
},
value: function (value) {
if (arguments.length) {
this.state.set('value', value);
return this;
}
if (this.state.get('rendered')) {
this.state.set('value', this.getEl().value);
}
return this.state.get('value');
},
postRender: function () {
var self = this;
self.getEl().value = self.state.get('value');
self._super();
self.$el.on('change', function (e) {
self.state.set('value', e.target.value);
self.fire('change', e);
});
},
bindStates: function () {
var self = this;
self.state.on('change:value', function (e) {
if (self.getEl().value !== e.value) {
self.getEl().value = e.value;
}
});
self.state.on('change:disabled', function (e) {
self.getEl().disabled = e.value;
});
return self._super();
},
remove: function () {
this.$el.off();
this._super();
}
});
var getApi = function () {
return {
Selector: Selector,
Collection: Collection$2,
ReflowQueue: ReflowQueue,
Control: Control$1,
Factory: global$4,
KeyboardNavigation: KeyboardNavigation,
Container: Container,
DragHelper: DragHelper,
Scrollable: Scrollable,
Panel: Panel,
Movable: Movable,
Resizable: Resizable,
FloatPanel: FloatPanel,
Window: Window,
MessageBox: MessageBox,
Tooltip: Tooltip,
Widget: Widget,
Progress: Progress,
Notification: Notification,
Layout: Layout,
AbsoluteLayout: AbsoluteLayout,
Button: Button,
ButtonGroup: ButtonGroup,
Checkbox: Checkbox,
ComboBox: ComboBox,
ColorBox: ColorBox,
PanelButton: PanelButton,
ColorButton: ColorButton,
ColorPicker: ColorPicker,
Path: Path,
ElementPath: ElementPath,
FormItem: FormItem,
Form: Form,
FieldSet: FieldSet,
FilePicker: FilePicker,
FitLayout: FitLayout,
FlexLayout: FlexLayout,
FlowLayout: FlowLayout,
FormatControls: FormatControls,
GridLayout: GridLayout,
Iframe: Iframe$1,
InfoBox: InfoBox,
Label: Label,
Toolbar: Toolbar$1,
MenuBar: MenuBar,
MenuButton: MenuButton,
MenuItem: MenuItem,
Throbber: Throbber,
Menu: Menu,
ListBox: ListBox,
Radio: Radio,
ResizeHandle: ResizeHandle,
SelectBox: SelectBox,
Slider: Slider,
Spacer: Spacer,
SplitButton: SplitButton,
StackLayout: StackLayout,
TabPanel: TabPanel,
TextBox: TextBox,
DropZone: DropZone,
BrowseButton: BrowseButton
};
};
var appendTo = function (target) {
if (target.ui) {
global$2.each(getApi(), function (ref, key) {
target.ui[key] = ref;
});
} else {
target.ui = getApi();
}
};
var registerToFactory = function () {
global$2.each(getApi(), function (ref, key) {
global$4.add(key, ref);
});
};
var Api = {
appendTo: appendTo,
registerToFactory: registerToFactory
};
Api.registerToFactory();
Api.appendTo(window.tinymce ? window.tinymce : {});
global.add('modern', function (editor) {
FormatControls.setup(editor);
return ThemeApi.get(editor);
});
function Theme () {
}
return Theme;
}(window));
})();
themes/modern/theme.min.js 0000644 00000377272 14740051667 0011573 0 ustar 00 !function(_){"use strict";var e,t,n,i,r=tinymce.util.Tools.resolve("tinymce.ThemeManager"),l=tinymce.util.Tools.resolve("tinymce.EditorManager"),w=tinymce.util.Tools.resolve("tinymce.util.Tools"),d=function(e){return!1!==c(e)},c=function(e){return e.getParam("menubar")},f=function(e){return e.getParam("toolbar_items_size")},h=function(e){return e.getParam("menu")},m=function(e){return!1===e.settings.skin},g=function(e){var t=e.getParam("resize","vertical");return!1===t?"none":"both"===t?"both":"vertical"},p=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),v=tinymce.util.Tools.resolve("tinymce.ui.Factory"),b=tinymce.util.Tools.resolve("tinymce.util.I18n"),o=function(e){return e.fire("SkinLoaded")},y=function(e){return e.fire("ResizeEditor")},x=function(e){return e.fire("BeforeRenderUI")},s=function(t,n){return function(){var e=t.find(n)[0];e&&e.focus(!0)}},R=function(e,t){e.shortcuts.add("Alt+F9","",s(t,"menubar")),e.shortcuts.add("Alt+F10,F10","",s(t,"toolbar")),e.shortcuts.add("Alt+F11","",s(t,"elementpath")),t.on("cancel",function(){e.focus()})},C=tinymce.util.Tools.resolve("tinymce.geom.Rect"),u=tinymce.util.Tools.resolve("tinymce.util.Delay"),E=function(){},k=function(e){return function(){return e}},a=k(!1),H=k(!0),S=function(){return T},T=(e=function(e){return e.isNone()},i={fold:function(e,t){return e()},is:a,isSome:a,isNone:H,getOr:n=function(e){return e},getOrThunk:t=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:k(null),getOrUndefined:k(undefined),or:n,orThunk:t,map:S,each:E,bind:S,exists:a,forall:H,filter:S,equals:e,equals_:e,toArray:function(){return[]},toString:k("none()")},Object.freeze&&Object.freeze(i),i),M=function(n){var e=k(n),t=function(){return r},i=function(e){return e(n)},r={fold:function(e,t){return t(n)},is:function(e){return n===e},isSome:H,isNone:a,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return M(e(n))},each:function(e){e(n)},bind:i,exists:i,forall:i,filter:function(e){return e(n)?r:T},toArray:function(){return[n]},toString:function(){return"some("+n+")"},equals:function(e){return e.is(n)},equals_:function(e,t){return e.fold(a,function(e){return t(n,e)})}};return r},N={some:M,none:S,from:function(e){return null===e||e===undefined?T:M(e)}},P=function(e){return e?e.getRoot().uiContainer:null},W={getUiContainerDelta:function(e){var t=P(e);if(t&&"static"!==p.DOM.getStyle(t,"position",!0)){var n=p.DOM.getPos(t),i=t.scrollLeft-n.x,r=t.scrollTop-n.y;return N.some({x:i,y:r})}return N.none()},setUiContainer:function(e,t){var n=p.DOM.select(e.settings.ui_container)[0];t.getRoot().uiContainer=n},getUiContainer:P,inheritUiContainer:function(e,t){return t.uiContainer=P(e)}},D=function(i,e,r){var o,s=[];if(e)return w.each(e.split(/[ ,]/),function(t){var e,n=function(){var e=i.selection;t.settings.stateSelector&&e.selectorChanged(t.settings.stateSelector,function(e){t.active(e)},!0),t.settings.disabledStateSelector&&e.selectorChanged(t.settings.disabledStateSelector,function(e){t.disabled(e)})};"|"===t?o=null:(o||(o={type:"buttongroup",items:[]},s.push(o)),i.buttons[t]&&(e=t,"function"==typeof(t=i.buttons[e])&&(t=t()),t.type=t.type||"button",t.size=r,t=v.create(t),o.items.push(t),i.initialized?n():i.on("init",n)))}),{type:"toolbar",layout:"flow",items:s}},O=D,A=function(n,i){var e,t,r=[];if(w.each(!1===(t=(e=n).getParam("toolbar"))?[]:w.isArray(t)?w.grep(t,function(e){return 0Tiny']),u=t.getParam("branding",!0,"boolean")?{type:"label",classes:"branding",html:" "+l}:null;i.add({type:"panel",name:"statusbar",classes:"statusbar",layout:"flow",border:"1 0 0 0",ariaRoot:!0,items:[{type:"elementpath",editor:t},r,u]})}return x(t),t.on("SwitchMode",(a=i,function(e){a.find("*").disabled("readonly"===e.mode)})),i.renderBefore(n.targetNode).reflow(),t.getParam("readonly",!1,"boolean")&&t.setMode("readonly"),n.width&&pe.setStyle(i.getEl(),"width",n.width),t.on("remove",function(){i.remove(),i=null}),R(t,i),F(t),{iframeContainer:i.find("#iframe")[0].getEl(),editorContainer:i.getEl()}},ye=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),xe=0,we={id:function(){return"mceu_"+xe++},create:function(e,t,n){var i=_.document.createElement(e);return p.DOM.setAttribs(i,t),"string"==typeof n?i.innerHTML=n:w.each(n,function(e){e.nodeType&&i.appendChild(e)}),i},createFragment:function(e){return p.DOM.createFragment(e)},getWindowSize:function(){return p.DOM.getViewPort()},getSize:function(e){var t,n;if(e.getBoundingClientRect){var i=e.getBoundingClientRect();t=Math.max(i.width||i.right-i.left,e.offsetWidth),n=Math.max(i.height||i.bottom-i.bottom,e.offsetHeight)}else t=e.offsetWidth,n=e.offsetHeight;return{width:t,height:n}},getPos:function(e,t){return p.DOM.getPos(e,t||we.getContainer())},getContainer:function(){return ce.container?ce.container:_.document.body},getViewPort:function(e){return p.DOM.getViewPort(e)},get:function(e){return _.document.getElementById(e)},addClass:function(e,t){return p.DOM.addClass(e,t)},removeClass:function(e,t){return p.DOM.removeClass(e,t)},hasClass:function(e,t){return p.DOM.hasClass(e,t)},toggleClass:function(e,t,n){return p.DOM.toggleClass(e,t,n)},css:function(e,t,n){return p.DOM.setStyle(e,t,n)},getRuntimeStyle:function(e,t){return p.DOM.getStyle(e,t,!0)},on:function(e,t,n,i){return p.DOM.bind(e,t,n,i)},off:function(e,t,n){return p.DOM.unbind(e,t,n)},fire:function(e,t,n){return p.DOM.fire(e,t,n)},innerHtml:function(e,t){p.DOM.setHTML(e,t)}},_e=function(e){return"static"===we.getRuntimeStyle(e,"position")},Re=function(e){return e.state.get("fixed")};function Ce(e,t,n){var i,r,o,s,a,l,u,c,d,f;return d=Ee(),o=(r=we.getPos(t,W.getUiContainer(e))).x,s=r.y,Re(e)&&_e(_.document.body)&&(o-=d.x,s-=d.y),i=e.getEl(),a=(f=we.getSize(i)).width,l=f.height,u=(f=we.getSize(t)).width,c=f.height,"b"===(n=(n||"").split(""))[0]&&(s+=c),"r"===n[1]&&(o+=u),"c"===n[0]&&(s+=Math.round(c/2)),"c"===n[1]&&(o+=Math.round(u/2)),"b"===n[3]&&(s-=l),"r"===n[4]&&(o-=a),"c"===n[3]&&(s-=Math.round(l/2)),"c"===n[4]&&(o-=Math.round(a/2)),{x:o,y:s,w:a,h:l}}var Ee=function(){var e=_.window;return{x:Math.max(e.pageXOffset,_.document.body.scrollLeft,_.document.documentElement.scrollLeft),y:Math.max(e.pageYOffset,_.document.body.scrollTop,_.document.documentElement.scrollTop),w:e.innerWidth||_.document.documentElement.clientWidth,h:e.innerHeight||_.document.documentElement.clientHeight}},ke=function(e){var t,n=W.getUiContainer(e);return n&&!Re(e)?{x:0,y:0,w:(t=n).scrollWidth-1,h:t.scrollHeight-1}:Ee()},He={testMoveRel:function(e,t){for(var n=ke(this),i=0;in.x&&r.x+r.wn.y&&r.y+r.h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,ze=/^\s*|\s*$/g,Ie=Se.extend({init:function(e){var o=this.match;function s(e,t,n){var i;function r(e){e&&t.push(e)}return r(function(t){if(t)return t=t.toLowerCase(),function(e){return"*"===t||e.type===t}}((i=Be.exec(e.replace(ze,"")))[1])),r(function(t){if(t)return function(e){return e._name===t}}(i[2])),r(function(n){if(n)return n=n.split("."),function(e){for(var t=n.length;t--;)if(!e.classes.contains(n[t]))return!1;return!0}}(i[3])),r(function(n,i,r){if(n)return function(e){var t=e[n]?e[n]():"";return i?"="===i?t===r:"*="===i?0<=t.indexOf(r):"~="===i?0<=(" "+t+" ").indexOf(" "+r+" "):"!="===i?t!==r:"^="===i?0===t.indexOf(r):"$="===i&&t.substr(t.length-r.length)===r:!!r}}(i[4],i[5],i[6])),r(function(i){var t;if(i)return(i=/(?:not\((.+)\))|(.+)/i.exec(i))[1]?(t=a(i[1],[]),function(e){return!o(e,t)}):(i=i[2],function(e,t,n){return"first"===i?0===t:"last"===i?t===n-1:"even"===i?t%2==0:"odd"===i?t%2==1:!!e[i]&&e[i]()})}(i[7])),t.pseudo=!!i[7],t.direct=n,t}function a(e,t){var n,i,r,o=[];do{if(Le.exec(""),(i=Le.exec(e))&&(e=i[3],o.push(i[1]),i[2])){n=i[3];break}}while(i);for(n&&a(n,t),e=[],r=0;r"!==o[r]&&e.push(s(o[r],[],">"===o[r-1]));return t.push(e),t}this._selectors=a(e,[])},match:function(e,t){var n,i,r,o,s,a,l,u,c,d,f,h,m;for(n=0,i=(t=t||this._selectors).length;na.maxW?a.maxW:n,a.w=n,a.innerW=n-i),(n=e.h)!==undefined&&(n=(n=na.maxH?a.maxH:n,a.h=n,a.innerH=n-r),(n=e.innerW)!==undefined&&(n=(n=na.maxW-i?a.maxW-i:n,a.innerW=n,a.w=n+i),(n=e.innerH)!==undefined&&(n=(n=na.maxH-r?a.maxH-r:n,a.innerH=n,a.h=n+r),e.contentW!==undefined&&(a.contentW=e.contentW),e.contentH!==undefined&&(a.contentH=e.contentH),(t=s._lastLayoutRect).x===a.x&&t.y===a.y&&t.w===a.w&&t.h===a.h||((o=je.repaintControls)&&o.map&&!o.map[s._id]&&(o.push(s),o.map[s._id]=!0),t.x=a.x,t.y=a.y,t.w=a.w,t.h=a.h),s):a},repaint:function(){var e,t,n,i,r,o,s,a,l,u,c=this;l=_.document.createRange?function(e){return e}:Math.round,e=c.getEl().style,i=c._layoutRect,a=c._lastRepaintRect||{},o=(r=c.borderBox).left+r.right,s=r.top+r.bottom,i.x!==a.x&&(e.left=l(i.x)+"px",a.x=i.x),i.y!==a.y&&(e.top=l(i.y)+"px",a.y=i.y),i.w!==a.w&&(u=l(i.w-o),e.width=(0<=u?u:0)+"px",a.w=i.w),i.h!==a.h&&(u=l(i.h-s),e.height=(0<=u?u:0)+"px",a.h=i.h),c._hasBody&&i.innerW!==a.innerW&&(u=l(i.innerW),(n=c.getEl("body"))&&((t=n.style).width=(0<=u?u:0)+"px"),a.innerW=i.innerW),c._hasBody&&i.innerH!==a.innerH&&(u=l(i.innerH),(n=n||c.getEl("body"))&&((t=t||n.style).height=(0<=u?u:0)+"px"),a.innerH=i.innerH),c._lastRepaintRect=a,c.fire("repaint",{},!1)},updateLayoutRect:function(){var e=this;e.parent()._lastRect=null,we.css(e.getEl(),{width:"",height:""}),e._layoutRect=e._lastRepaintRect=e._lastLayoutRect=null,e.initLayoutRect()},on:function(e,t){var n,i,r,o=this;return nt(o).on(e,"string"!=typeof(n=t)?n:function(e){return i||o.parentsAndSelf().each(function(e){var t=e.settings.callbacks;if(t&&(i=t[n]))return r=e,!1}),i?i.call(r,e):(e.action=n,void this.fire("execute",e))}),o},off:function(e,t){return nt(this).off(e,t),this},fire:function(e,t,n){if((t=t||{}).control||(t.control=this),t=nt(this).fire(e,t),!1!==n&&this.parent)for(var i=this.parent();i&&!t.isPropagationStopped();)i.fire(e,t,!1),i=i.parent();return t},hasEventListeners:function(e){return nt(this).has(e)},parents:function(e){var t,n=new Ve;for(t=this.parent();t;t=t.parent())n.add(t);return e&&(n=n.filter(e)),n},parentsAndSelf:function(e){return new Ve(this).add(this.parents(e))},next:function(){var e=this.parent().items();return e[e.indexOf(this)+1]},prev:function(){var e=this.parent().items();return e[e.indexOf(this)-1]},innerHtml:function(e){return this.$el.html(e),this},getEl:function(e){var t=e?this._id+"-"+e:this._id;return this._elmCache[t]||(this._elmCache[t]=ye("#"+t)[0]),this._elmCache[t]},show:function(){return this.visible(!0)},hide:function(){return this.visible(!1)},focus:function(){try{this.getEl().focus()}catch(e){}return this},blur:function(){return this.getEl().blur(),this},aria:function(e,t){var n=this,i=n.getEl(n.ariaTarget);return void 0===t?n._aria[e]:(n._aria[e]=t,n.state.get("rendered")&&i.setAttribute("role"===e?e:"aria-"+e,t),n)},encode:function(e,t){return!1!==t&&(e=this.translate(e)),(e||"").replace(/[&<>"]/g,function(e){return""+e.charCodeAt(0)+";"})},translate:function(e){return je.translate?je.translate(e):e},before:function(e){var t=this.parent();return t&&t.insert(e,t.items().indexOf(this),!0),this},after:function(e){var t=this.parent();return t&&t.insert(e,t.items().indexOf(this)),this},remove:function(){var t,e,n=this,i=n.getEl(),r=n.parent();if(n.items){var o=n.items().toArray();for(e=o.length;e--;)o[e].remove()}r&&r.items&&(t=[],r.items().each(function(e){e!==n&&t.push(e)}),r.items().set(t),r._lastRect=null),n._eventsRoot&&n._eventsRoot===n&&ye(i).off();var s=n.getRoot().controlIdLookup;return s&&delete s[n._id],i&&i.parentNode&&i.parentNode.removeChild(i),n.state.set("rendered",!1),n.state.destroy(),n.fire("remove"),n},renderBefore:function(e){return ye(e).before(this.renderHtml()),this.postRender(),this},renderTo:function(e){return ye(e||this.getContainerElm()).append(this.renderHtml()),this.postRender(),this},preRender:function(){},render:function(){},renderHtml:function(){return'
'},postRender:function(){var e,t,n,i,r,o=this,s=o.settings;for(i in o.$el=ye(o.getEl()),o.state.set("rendered",!0),s)0===i.indexOf("on")&&o.on(i.substr(2),s[i]);if(o._eventsRoot){for(n=o.parent();!r&&n;n=n.parent())r=n._eventsRoot;if(r)for(i in r._nativeEvents)o._nativeEvents[i]=!0}it(o),s.style&&(e=o.getEl())&&(e.setAttribute("style",s.style),e.style.cssText=s.style),o.settings.border&&(t=o.borderBox,o.$el.css({"border-top-width":t.top,"border-right-width":t.right,"border-bottom-width":t.bottom,"border-left-width":t.left}));var a=o.getRoot();for(var l in a.controlIdLookup||(a.controlIdLookup={}),(a.controlIdLookup[o._id]=o)._aria)o.aria(l,o._aria[l]);!1===o.state.get("visible")&&(o.getEl().style.display="none"),o.bindStates(),o.state.on("change:visible",function(e){var t,n=e.value;o.state.get("rendered")&&(o.getEl().style.display=!1===n?"none":"",o.getEl().getBoundingClientRect()),(t=o.parent())&&(t._lastRect=null),o.fire(n?"show":"hide"),Ke.add(o)}),o.fire("postrender",{},!1)},bindStates:function(){},scrollIntoView:function(e){var t,n,i,r,o,s,a=this.getEl(),l=a.parentNode,u=function(e,t){var n,i,r=e;for(n=i=0;r&&r!==t&&r.nodeType;)n+=r.offsetLeft||0,i+=r.offsetTop||0,r=r.offsetParent;return{x:n,y:i}}(a,l);return t=u.x,n=u.y,i=a.offsetWidth,r=a.offsetHeight,o=l.clientWidth,s=l.clientHeight,"end"===e?(t-=o-i,n-=s-r):"center"===e&&(t-=o/2-i/2,n-=s/2-r/2),l.scrollLeft=t,l.scrollTop=n,this},getRoot:function(){for(var e,t=this,n=[];t;){if(t.rootControl){e=t.rootControl;break}n.push(t),t=(e=t).parent()}e||(e=this);for(var i=n.length;i--;)n[i].rootControl=e;return e},reflow:function(){Ke.remove(this);var e=this.parent();return e&&e._layout&&!e._layout.isNative()&&e.reflow(),this}};function nt(n){return n._eventDispatcher||(n._eventDispatcher=new Te({scope:n,toggleEvent:function(e,t){t&&Te.isNative(e)&&(n._nativeEvents||(n._nativeEvents={}),n._nativeEvents[e]=!0,n.state.get("rendered")&&it(n))}})),n._eventDispatcher}function it(a){var e,t,n,l,i,r;function o(e){var t=a.getParentCtrl(e.target);t&&t.fire(e.type,e)}function s(){var e=l._lastHoverCtrl;e&&(e.fire("mouseleave",{target:e.getEl()}),e.parents().each(function(e){e.fire("mouseleave",{target:e.getEl()})}),l._lastHoverCtrl=null)}function u(e){var t,n,i,r=a.getParentCtrl(e.target),o=l._lastHoverCtrl,s=0;if(r!==o){if((n=(l._lastHoverCtrl=r).parents().toArray().reverse()).push(r),o){for((i=o.parents().toArray().reverse()).push(o),s=0;s=t.length&&(e=0),t[e]&&t[e].focus(),e}function h(e,t){var n=-1,i=d();t=t||c(i.getEl());for(var r=0;r'+(e.settings.html||"")+t.renderHtml(e)+"
"},postRender:function(){var e,t=this;return t.items().exec("postRender"),t._super(),t._layout.postRender(t),t.state.set("rendered",!0),t.settings.style&&t.$el.css(t.settings.style),t.settings.border&&(e=t.borderBox,t.$el.css({"border-top-width":e.top,"border-right-width":e.right,"border-bottom-width":e.bottom,"border-left-width":e.left})),t.parent()||(t.keyboardNav=st({root:t})),t},initLayoutRect:function(){var e=this._super();return this._layout.recalc(this),e},recalc:function(){var e=this,t=e._layoutRect,n=e._lastRect;if(!n||n.w!==t.w||n.h!==t.h)return e._layout.recalc(e),t=e.layoutRect(),e._lastRect={x:t.x,y:t.y,w:t.w,h:t.h},!0},reflow:function(){var e;if(Ke.remove(this),this.visible()){for(rt.repaintControls=[],rt.repaintControls.map={},this.recalc(),e=rt.repaintControls.length;e--;)rt.repaintControls[e].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),rt.repaintControls=[]}return this}});function ut(e){var t,n;if(e.changedTouches)for(t="screenX screenY pageX pageY clientX clientY".split(" "),n=0;n").css({position:"absolute",top:0,left:0,width:f.width,height:f.height,zIndex:2147483647,opacity:1e-4,cursor:d}).appendTo(x.body),ye(x).on("mousemove touchmove",v).on("mouseup touchend",p),h.start(e)},v=function(e){if(ut(e),e.button!==g)return p(e);e.deltaX=e.screenX-b,e.deltaY=e.screenY-y,e.preventDefault(),h.drag(e)},p=function(e){ut(e),ye(x).off("mousemove touchmove",v).off("mouseup touchend",p),m.remove(),h.stop&&h.stop(e)},this.destroy=function(){ye(w).off()},ye(w).on("mousedown touchstart",t)}var dt,ft,ht,mt,gt={init:function(){this.on("repaint",this.renderScroll)},renderScroll:function(){var p=this,v=2;function n(){var m,g,e;function t(e,t,n,i,r,o){var s,a,l,u,c,d,f,h;if(a=p.getEl("scroll"+e)){if(f=t.toLowerCase(),h=n.toLowerCase(),ye(p.getEl("absend")).css(f,p.layoutRect()[i]-1),!r)return void ye(a).css("display","none");ye(a).css("display","block"),s=p.getEl("body"),l=p.getEl("scroll"+e+"t"),u=s["client"+n]-2*v,c=(u-=m&&g?a["client"+o]:0)/s["scroll"+n],(d={})[f]=s["offset"+t]+v,d[h]=u,ye(a).css(d),(d={})[f]=s["scroll"+t]*c,d[h]=u*c,ye(l).css(d)}}e=p.getEl("body"),m=e.scrollWidth>e.clientWidth,g=e.scrollHeight>e.clientHeight,t("h","Left","Width","contentW",m,"Height"),t("v","Top","Height","contentH",g,"Width")}p.settings.autoScroll&&(p._hasScroll||(p._hasScroll=!0,function(){function e(s,a,l,u,c){var d,e=p._id+"-scroll"+s,t=p.classPrefix;ye(p.getEl()).append(''),p.draghelper=new ct(e+"t",{start:function(){d=p.getEl("body")["scroll"+a],ye("#"+e).addClass(t+"active")},drag:function(e){var t,n,i,r,o=p.layoutRect();n=o.contentW>o.innerW,i=o.contentH>o.innerH,r=p.getEl("body")["client"+l]-2*v,t=(r-=n&&i?p.getEl("scroll"+s)["client"+c]:0)/p.getEl("body")["scroll"+l],p.getEl("body")["scroll"+a]=d+e["delta"+u]/t},stop:function(){ye("#"+e).removeClass(t+"active")}})}p.classes.add("scroll"),e("v","Top","Height","Y","Width"),e("h","Left","Width","X","Height")}(),p.on("wheel",function(e){var t=p.getEl("body");t.scrollLeft+=10*(e.deltaX||0),t.scrollTop+=10*e.deltaY,n()}),ye(p.getEl("body")).on("scroll",n)),n())}},pt=lt.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[gt],renderHtml:function(){var e=this,t=e._layout,n=e.settings.html;return e.preRender(),t.preRender(e),void 0===n?n=''+t.renderHtml(e)+"
":("function"==typeof n&&(n=n.call(e)),e._hasBody=!1),''+(e._preBodyHtml||"")+n+"
"}}),vt={resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(e,t){if(e<=1||t<=1){var n=we.getWindowSize();e=e<=1?e*n.w:e,t=t<=1?t*n.h:t}return this._layoutRect.autoResize=!1,this.layoutRect({minW:e,minH:t,w:e,h:t}).reflow()},resizeBy:function(e,t){var n=this.layoutRect();return this.resizeTo(n.w+e,n.h+t)}},bt=[],yt=[];function xt(e,t){for(;e;){if(e===t)return!0;e=e.parent()}}function wt(){dt||(dt=function(e){2!==e.button&&function(e){for(var t=bt.length;t--;){var n=bt[t],i=n.getParentCtrl(e.target);if(n.settings.autohide){if(i&&(xt(i,n)||n.parent()===i))continue;(e=n.fire("autohide",{target:e.target})).isDefaultPrevented()||n.hide()}}}(e)},ye(_.document).on("click touchstart",dt))}function _t(r){var e=we.getViewPort().y;function t(e,t){for(var n,i=0;ie&&(r.fixed(!1).layoutRect({y:r._autoFixY}).repaint(),t(!1,r._autoFixY-e)):(r._autoFixY=r.layoutRect().y,r._autoFixY').appendTo(i.getContainerElm())),u.setTimeout(function(){t.addClass(n+"in"),ye(i.getEl()).addClass(n+"in")}),mt=!0),Rt(!0,i)}}),i.on("show",function(){i.parents().each(function(e){if(e.state.get("fixed"))return i.fixed(!0),!1})}),e.popover&&(i._preBodyHtml='
',i.classes.add("popover").add("bottom").add(i.isRtl()?"end":"start")),i.aria("label",e.ariaLabel),i.aria("labelledby",i._id),i.aria("describedby",i.describedBy||i._id+"-none")},fixed:function(e){var t=this;if(t.state.get("fixed")!==e){if(t.state.get("rendered")){var n=we.getViewPort();e?t.layoutRect().y-=n.y:t.layoutRect().y+=n.y}t.classes.toggle("fixed",e),t.state.set("fixed",e)}return t},show:function(){var e,t=this._super();for(e=bt.length;e--&&bt[e]!==this;);return-1===e&&bt.push(this),t},hide:function(){return Et(this),Rt(!1,this),this._super()},hideAll:function(){Ct.hideAll()},close:function(){return this.fire("close").isDefaultPrevented()||(this.remove(),Rt(!1,this)),this},remove:function(){Et(this),this._super()},postRender:function(){return this.settings.bodyRole&&this.getEl("body").setAttribute("role",this.settings.bodyRole),this._super()}});function Et(e){var t;for(t=bt.length;t--;)bt[t]===e&&bt.splice(t,1);for(t=yt.length;t--;)yt[t]===e&&yt.splice(t,1)}Ct.hideAll=function(){for(var e=bt.length;e--;){var t=bt[e];t&&t.settings.autohide&&(t.hide(),bt.splice(e,1))}};var kt=function(s,n,e){var a,i,l=p.DOM,t=s.getParam("fixed_toolbar_container");t&&(i=l.select(t)[0]);var r=function(){if(a&&a.moveRel&&a.visible()&&!a._fixed){var e=s.selection.getScrollContainer(),t=s.getBody(),n=0,i=0;if(e){var r=l.getPos(t),o=l.getPos(e);n=Math.max(0,o.x-r.x),i=Math.max(0,o.y-r.y)}a.fixed(!1).moveRel(t,s.rtl?["tr-br","br-tr"]:["tl-bl","bl-tl","tr-br"]).moveBy(n,i)}},o=function(){a&&(a.show(),r(),l.addClass(s.getBody(),"mce-edit-focus"))},u=function(){a&&(a.hide(),Ct.hideAll(),l.removeClass(s.getBody(),"mce-edit-focus"))},c=function(){var e,t;a?a.visible()||o():(a=n.panel=v.create({type:i?"panel":"floatpanel",role:"application",classes:"tinymce tinymce-inline",layout:"flex",direction:"column",align:"stretch",autohide:!1,autofix:!0,fixed:(e=i,t=s,!(!e||t.settings.ui_container)),border:1,items:[!1===d(s)?null:{type:"menubar",border:"0 0 1 0",items:re(s)},A(s,f(s))]}),W.setUiContainer(s,a),x(s),i?a.renderTo(i).reflow():a.renderTo().reflow(),R(s,a),o(),F(s),s.on("nodeChange",r),s.on("ResizeWindow",r),s.on("activate",o),s.on("deactivate",u),s.nodeChanged())};return s.settings.content_editable=!0,s.on("focus",function(){!1===m(s)&&e.skinUiCss?l.styleSheetLoader.load(e.skinUiCss,c,c):c()}),s.on("blur hide",u),s.on("remove",function(){a&&(a.remove(),a=null)}),!1===m(s)&&e.skinUiCss?l.styleSheetLoader.load(e.skinUiCss,ge(s)):ge(s)(),{}};function Ht(i,r){var o,s,a=this,l=rt.classPrefix;a.show=function(e,t){function n(){o&&(ye(i).append('
'),t&&t())}return a.hide(),o=!0,e?s=u.setTimeout(n,e):n(),a},a.hide=function(){var e=i.lastChild;return u.clearTimeout(s),e&&-1!==e.className.indexOf("throbber")&&e.parentNode.removeChild(e),o=!1,a}}var St=function(e,t){var n;e.on("ProgressState",function(e){n=n||new Ht(t.panel.getEl("body")),e.state?n.show(e.time):n.hide()})},Tt=function(e,t,n){var i=function(e){var t=e.settings,n=t.skin,i=t.skin_url;if(!1!==n){var r=n||"lightgray";i=i?e.documentBaseURI.toAbsolute(i):l.baseURL+"/skins/"+r}return i}(e);return i&&(n.skinUiCss=i+"/skin.min.css",e.contentCSS.push(i+"/content"+(e.inline?".inline":"")+".min.css")),St(e,t),e.getParam("inline",!1,"boolean")?kt(e,t,n):be(e,t,n)},Mt=rt.extend({Mixins:[He],Defaults:{classes:"widget tooltip tooltip-n"},renderHtml:function(){var e=this,t=e.classPrefix;return'
'+e.encode(e.state.get("text"))+"
"},bindStates:function(){var t=this;return t.state.on("change:text",function(e){t.getEl().lastChild.innerHTML=t.encode(e.value)}),t._super()},repaint:function(){var e,t;e=this.getEl().style,t=this._layoutRect,e.left=t.x+"px",e.top=t.y+"px",e.zIndex=131070}}),Nt=rt.extend({init:function(i){var r=this;r._super(i),i=r.settings,r.canFocus=!0,i.tooltip&&!1!==Nt.tooltips&&(r.on("mouseenter",function(e){var t=r.tooltip().moveTo(-65535);if(e.control===r){var n=t.text(i.tooltip).show().testMoveRel(r.getEl(),["bc-tc","bc-tl","bc-tr"]);t.classes.toggle("tooltip-n","bc-tc"===n),t.classes.toggle("tooltip-nw","bc-tl"===n),t.classes.toggle("tooltip-ne","bc-tr"===n),t.moveRel(r.getEl(),n)}else t.hide()}),r.on("mouseleave mousedown click",function(){r.tooltip().remove(),r._tooltip=null})),r.aria("label",i.ariaLabel||i.tooltip)},tooltip:function(){return this._tooltip||(this._tooltip=new Mt({type:"tooltip"}),W.inheritUiContainer(this,this._tooltip),this._tooltip.renderTo()),this._tooltip},postRender:function(){var e=this,t=e.settings;e._super(),e.parent()||!t.width&&!t.height||(e.initLayoutRect(),e.repaint()),t.autofocus&&e.focus()},bindStates:function(){var t=this;function n(e){t.aria("disabled",e),t.classes.toggle("disabled",e)}function i(e){t.aria("pressed",e),t.classes.toggle("active",e)}return t.state.on("change:disabled",function(e){n(e.value)}),t.state.on("change:active",function(e){i(e.value)}),t.state.get("disabled")&&n(!0),t.state.get("active")&&i(!0),t._super()},remove:function(){this._super(),this._tooltip&&(this._tooltip.remove(),this._tooltip=null)}}),Pt=Nt.extend({Defaults:{value:0},init:function(e){this._super(e),this.classes.add("progress"),this.settings.filter||(this.settings.filter=function(e){return Math.round(e)})},renderHtml:function(){var e=this._id,t=this.classPrefix;return''},postRender:function(){return this._super(),this.value(this.settings.value),this},bindStates:function(){var t=this;function n(e){e=t.settings.filter(e),t.getEl().lastChild.innerHTML=e+"%",t.getEl().firstChild.firstChild.style.width=e+"%"}return t.state.on("change:value",function(e){n(e.value)}),n(t.state.get("value")),t._super()}}),Wt=function(e,t){e.getEl().lastChild.textContent=t+(e.progressBar?" "+e.progressBar.value()+"%":"")},Dt=rt.extend({Mixins:[He],Defaults:{classes:"widget notification"},init:function(e){var t=this;t._super(e),t.maxWidth=e.maxWidth,e.text&&t.text(e.text),e.icon&&(t.icon=e.icon),e.color&&(t.color=e.color),e.type&&t.classes.add("notification-"+e.type),e.timeout&&(e.timeout<0||0 '),e=' style="max-width: '+t.maxWidth+"px;"+(t.color?"background-color: "+t.color+';"':'"'),t.closeButton&&(r='\xd7 '),t.progressBar&&(o=t.progressBar.renderHtml()),''+i+'
'+t.state.get("text")+"
"+o+r+'
'},postRender:function(){var e=this;return u.setTimeout(function(){e.$el.addClass(e.classPrefix+"in"),Wt(e,e.state.get("text"))},100),e._super()},bindStates:function(){var t=this;return t.state.on("change:text",function(e){t.getEl().firstChild.innerHTML=e.value,Wt(t,e.value)}),t.progressBar&&(t.progressBar.bindStates(),t.progressBar.state.on("change:value",function(e){Wt(t,t.state.get("text"))})),t._super()},close:function(){return this.fire("close").isDefaultPrevented()||this.remove(),this},repaint:function(){var e,t;e=this.getEl().style,t=this._layoutRect,e.left=t.x+"px",e.top=t.y+"px",e.zIndex=65534}});function Ot(o){var s=function(e){return e.inline?e.getElement():e.getContentAreaContainer()};return{open:function(e,t){var n,i=w.extend(e,{maxWidth:(n=s(o),we.getSize(n).width)}),r=new Dt(i);return 0<(r.args=i).timeout&&(r.timer=setTimeout(function(){r.close(),t()},i.timeout)),r.on("close",function(){t()}),r.renderTo(),r},close:function(e){e.close()},reposition:function(e){K(e,function(e){e.moveTo(0,0)}),function(n){if(0e.w&&(n=e.x-Math.max(0,t/2),r.layoutRect({w:t,x:n}),i=!0),o&&(o.layoutRect({w:r.layoutRect().innerW}).recalc(),(t=o.layoutRect().minW+e.deltaW)>e.w&&(n=e.x-Math.max(0,t-e.w),r.layoutRect({w:t,x:n}),i=!0)),i&&r.recalc()},initLayoutRect:function(){var e,t=this,n=t._super(),i=0;if(t.settings.title&&!t._fullscreen){e=t.getEl("head");var r=we.getSize(e);n.headerW=r.width,n.headerH=r.height,i+=n.headerH}t.statusbar&&(i+=t.statusbar.layoutRect().h),n.deltaH+=i,n.minH+=i,n.h+=i;var o=we.getWindowSize();return n.x=t.settings.x||Math.max(0,o.w/2-n.w/2),n.y=t.settings.y||Math.max(0,o.h/2-n.h/2),n},renderHtml:function(){var e=this,t=e._layout,n=e._id,i=e.classPrefix,r=e.settings,o="",s="",a=r.html;return e.preRender(),t.preRender(e),r.title&&(o=''),r.url&&(a=''),void 0===a&&(a=t.renderHtml(e)),e.statusbar&&(s=e.statusbar.renderHtml()),'"},fullscreen:function(e){var n,t,i=this,r=_.document.documentElement,o=i.classPrefix;if(e!==i._fullscreen)if(ye(_.window).on("resize",function(){var e;if(i._fullscreen)if(n)i._timer||(i._timer=u.setTimeout(function(){var e=we.getWindowSize();i.moveTo(0,0).resizeTo(e.w,e.h),i._timer=0},50));else{e=(new Date).getTime();var t=we.getWindowSize();i.moveTo(0,0).resizeTo(t.w,t.h),50<(new Date).getTime()-e&&(n=!0)}}),t=i.layoutRect(),i._fullscreen=e){i._initial={x:t.x,y:t.y,w:t.w,h:t.h},i.borderBox=Me("0"),i.getEl("head").style.display="none",t.deltaH-=t.headerH+2,ye([r,_.document.body]).addClass(o+"fullscreen"),i.classes.add("fullscreen");var s=we.getWindowSize();i.moveTo(0,0).resizeTo(s.w,s.h)}else i.borderBox=Me(i.settings.border),i.getEl("head").style.display="",t.deltaH+=t.headerH,ye([r,_.document.body]).removeClass(o+"fullscreen"),i.classes.remove("fullscreen"),i.moveTo(i._initial.x,i._initial.y).resizeTo(i._initial.w,i._initial.h);return i.reflow()},postRender:function(){var t,n=this;setTimeout(function(){n.classes.add("in"),n.fire("open")},0),n._super(),n.statusbar&&n.statusbar.postRender(),n.focus(),this.dragHelper=new ct(n._id+"-dragh",{start:function(){t={x:n.layoutRect().x,y:n.layoutRect().y}},drag:function(e){n.moveTo(t.x+e.deltaX,t.y+e.deltaY)}}),n.on("submit",function(e){e.isDefaultPrevented()||n.close()}),At.push(n),Lt(!0)},submit:function(){return this.fire("submit",{data:this.toJSON()})},remove:function(){var e,t=this;for(t.dragHelper.destroy(),t._super(),t.statusbar&&this.statusbar.remove(),zt(t.classPrefix,!1),e=At.length;e--;)At[e]===t&&At.splice(e,1);Lt(0'+this._super(e)}}),jt=Nt.extend({Defaults:{classes:"widget btn",role:"button"},init:function(e){var t,n=this;n._super(e),e=n.settings,t=n.settings.size,n.on("click mousedown",function(e){e.preventDefault()}),n.on("touchstart",function(e){n.fire("click",e),e.preventDefault()}),e.subtype&&n.classes.add(e.subtype),t&&n.classes.add("btn-"+t),e.icon&&n.icon(e.icon)},icon:function(e){return arguments.length?(this.state.set("icon",e),this):this.state.get("icon")},repaint:function(){var e,t=this.getEl().firstChild;t&&((e=t.style).width=e.height="100%"),this._super()},renderHtml:function(){var e,t,n=this,i=n._id,r=n.classPrefix,o=n.state.get("icon"),s=n.state.get("text"),a="",l=n.settings;return(e=l.image)?(o="none","string"!=typeof e&&(e=_.window.getSelection?e[0]:e[1]),e=" style=\"background-image: url('"+e+"')\""):e="",s&&(n.classes.add("btn-has-text"),a=''+n.encode(s)+" "),o=o?r+"ico "+r+"i-"+o:"",t="boolean"==typeof l.active?' aria-pressed="'+l.active+'"':"",''+(o?' ":"")+a+"
"},bindStates:function(){var o=this,n=o.$,i=o.classPrefix+"txt";function s(e){var t=n("span."+i,o.getEl());e?(t[0]||(n("button:first",o.getEl()).append(' '),t=n("span."+i,o.getEl())),t.html(o.encode(e))):t.remove(),o.classes.toggle("btn-has-text",!!e)}return o.state.on("change:text",function(e){s(e.value)}),o.state.on("change:icon",function(e){var t=e.value,n=o.classPrefix;t=(o.settings.icon=t)?n+"ico "+n+"i-"+o.settings.icon:"";var i=o.getEl().firstChild,r=i.getElementsByTagName("i")[0];t?(r&&r===i.firstChild||(r=_.document.createElement("i"),i.insertBefore(r,i.firstChild)),r.className=t):r&&i.removeChild(r),s(o.state.get("text"))}),o._super()}}),Jt=jt.extend({init:function(e){e=w.extend({text:"Browse...",multiple:!1,accept:null},e),this._super(e),this.classes.add("browsebutton"),e.multiple&&this.classes.add("multiple")},postRender:function(){var n=this,t=we.create("input",{type:"file",id:n._id+"-browse",accept:n.settings.accept});n._super(),ye(t).on("change",function(e){var t=e.target.files;n.value=function(){return t.length?n.settings.multiple?t:t[0]:null},e.preventDefault(),t.length&&n.fire("change",e)}),ye(t).on("click",function(e){e.stopPropagation()}),ye(n.getEl("button")).on("click touchstart",function(e){e.stopPropagation(),t.click(),e.preventDefault()}),n.getEl().appendChild(t)},remove:function(){ye(this.getEl("button")).off(),ye(this.getEl("input")).off(),this._super()}}),Gt=lt.extend({Defaults:{defaultType:"button",role:"group"},renderHtml:function(){var e=this,t=e._layout;return e.classes.add("btn-group"),e.preRender(),t.preRender(e),''+(e.settings.html||"")+t.renderHtml(e)+"
"}}),Kt=Nt.extend({Defaults:{classes:"checkbox",role:"checkbox",checked:!1},init:function(e){var t=this;t._super(e),t.on("click mousedown",function(e){e.preventDefault()}),t.on("click",function(e){e.preventDefault(),t.disabled()||t.checked(!t.checked())}),t.checked(t.settings.checked)},checked:function(e){return arguments.length?(this.state.set("checked",e),this):this.state.get("checked")},value:function(e){return arguments.length?this.checked(e):this.checked()},renderHtml:function(){var e=this,t=e._id,n=e.classPrefix;return''+e.encode(e.state.get("text"))+"
"},bindStates:function(){var o=this;function t(e){o.classes.toggle("checked",e),o.aria("checked",e)}return o.state.on("change:text",function(e){o.getEl("al").firstChild.data=o.translate(e.value)}),o.state.on("change:checked change:value",function(e){o.fire("change"),t(e.value)}),o.state.on("change:icon",function(e){var t=e.value,n=o.classPrefix;if(void 0===t)return o.settings.icon;t=(o.settings.icon=t)?n+"ico "+n+"i-"+o.settings.icon:"";var i=o.getEl().firstChild,r=i.getElementsByTagName("i")[0];t?(r&&r===i.firstChild||(r=_.document.createElement("i"),i.insertBefore(r,i.firstChild)),r.className=t):r&&i.removeChild(r)}),o.state.get("checked")&&t(!0),o._super()}}),Zt=tinymce.util.Tools.resolve("tinymce.util.VK"),Qt=Nt.extend({init:function(i){var r=this;r._super(i),i=r.settings,r.classes.add("combobox"),r.subinput=!0,r.ariaTarget="inp",i.menu=i.menu||i.values,i.menu&&(i.icon="caret"),r.on("click",function(e){var t=e.target,n=r.getEl();if(ye.contains(n,t)||t===n)for(;t&&t!==n;)t.id&&-1!==t.id.indexOf("-open")&&(r.fire("action"),i.menu&&(r.showMenu(),e.aria&&r.menu.items()[0].focus())),t=t.parentNode}),r.on("keydown",function(e){var t;13===e.keyCode&&"INPUT"===e.target.nodeName&&(e.preventDefault(),r.parents().reverse().each(function(e){if(e.toJSON)return t=e,!1}),r.fire("submit",{data:t.toJSON()}))}),r.on("keyup",function(e){if("INPUT"===e.target.nodeName){var t=r.state.get("value"),n=e.target.value;n!==t&&(r.state.set("value",n),r.fire("autocomplete",e))}}),r.on("mouseover",function(e){var t=r.tooltip().moveTo(-65535);if(r.statusLevel()&&-1!==e.target.className.indexOf(r.classPrefix+"status")){var n=r.statusMessage()||"Ok",i=t.text(n).show().testMoveRel(e.target,["bc-tc","bc-tl","bc-tr"]);t.classes.toggle("tooltip-n","bc-tc"===i),t.classes.toggle("tooltip-nw","bc-tl"===i),t.classes.toggle("tooltip-ne","bc-tr"===i),t.moveRel(e.target,i)}})},statusLevel:function(e){return 0',i.disabled()&&(u+=' disabled="disabled"'),(e=o.icon)&&"caret"!==e&&(e=s+"ico "+s+"i-"+o.icon),t=i.state.get("text"),(e||t)&&(l=''+("caret"!==e?' ':' ')+(t?(e?" ":"")+t:"")+"
",i.classes.add("has-open")),' '+n+l+"
"},value:function(e){return arguments.length?(this.state.set("value",e),this):(this.state.get("rendered")&&this.state.set("value",this.getEl("inp").value),this.state.get("value"))},showAutoComplete:function(e,i){var r=this;if(0!==e.length){r.menu?r.menu.items().remove():r.menu=v.create({type:"menu",classes:"combobox-menu",layout:"flow"}).parent(r).renderTo(),w.each(e,function(e){var t,n;r.menu.add({text:e.title,url:e.previewUrl,match:i,classes:"menu-item-ellipsis",onclick:(t=e.value,n=e.title,function(){r.fire("selectitem",{title:n,value:t})})})}),r.menu.renderNew(),r.hideMenu(),r.menu.on("cancel",function(e){e.control.parent()===r.menu&&(e.stopPropagation(),r.focus(),r.hideMenu())}),r.menu.on("select",function(){r.focus()});var t=r.layoutRect().w;r.menu.layoutRect({w:t,minW:0,maxW:t}),r.menu.repaint(),r.menu.reflow(),r.menu.show(),r.menu.moveRel(r.getEl(),r.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"])}else r.hideMenu()},hideMenu:function(){this.menu&&this.menu.hide()},bindStates:function(){var r=this;r.state.on("change:value",function(e){r.getEl("inp").value!==e.value&&(r.getEl("inp").value=e.value)}),r.state.on("change:disabled",function(e){r.getEl("inp").disabled=e.value}),r.state.on("change:statusLevel",function(e){var t=r.getEl("status"),n=r.classPrefix,i=e.value;we.css(t,"display","none"===i?"none":""),we.toggleClass(t,n+"i-checkmark","ok"===i),we.toggleClass(t,n+"i-warning","warn"===i),we.toggleClass(t,n+"i-error","error"===i),r.classes.toggle("has-status","none"!==i),r.repaint()}),we.on(r.getEl("status"),"mouseleave",function(){r.tooltip().hide()}),r.on("cancel",function(e){r.menu&&r.menu.visible()&&(e.stopPropagation(),r.hideMenu())});var n=function(e,t){t&&0'+e.encode(i)+""),''+(r?' ":"")+' '+s+'
'},postRender:function(){var t=this,n=t.settings.onclick;return t.on("click",function(e){e.aria&&"down"===e.aria.key||e.control!==t||nn.getParent(e.target,"."+t.classPrefix+"open")||(e.stopImmediatePropagation(),n.call(t,e))}),delete t.settings.onclick,t._super()}}),on=tinymce.util.Tools.resolve("tinymce.util.Color"),sn=Nt.extend({Defaults:{classes:"widget colorpicker"},init:function(e){this._super(e)},postRender:function(){var n,i,r,o,s,a=this,l=a.color();function u(e,t){var n,i,r=we.getPos(e);return n=t.pageX-r.x,i=t.pageY-r.y,{x:n=Math.max(0,Math.min(n/e.clientWidth,1)),y:i=Math.max(0,Math.min(i/e.clientHeight,1))}}function c(e,t){var n=(360-e.h)/360;we.css(r,{top:100*n+"%"}),t||we.css(s,{left:e.s+"%",top:100-e.v+"%"}),o.style.background=on({s:100,v:100,h:e.h}).toHex(),a.color().parse({s:e.s,v:e.v,h:e.h})}function e(e){var t;t=u(o,e),n.s=100*t.x,n.v=100*(1-t.y),c(n),a.fire("change")}function t(e){var t;t=u(i,e),(n=l.toHsv()).h=360*(1-t.y),c(n,!0),a.fire("change")}i=a.getEl("h"),r=a.getEl("hp"),o=a.getEl("sv"),s=a.getEl("svp"),a._repaint=function(){c(n=l.toHsv())},a._super(),a._svdraghelper=new ct(a._id+"-sv",{start:e,drag:e}),a._hdraghelper=new ct(a._id+"-h",{start:t,drag:t}),a._repaint()},rgb:function(){return this.color().toRgb()},value:function(e){if(!arguments.length)return this.color().toHex();this.color().parse(e),this._rendered&&this._repaint()},color:function(){return this._color||(this._color=on()),this._color},renderHtml:function(){var e,t=this._id,o=this.classPrefix,s="#ff0000,#ff0080,#ff00ff,#8000ff,#0000ff,#0080ff,#00ffff,#00ff80,#00ff00,#80ff00,#ffff00,#ff8000,#ff0000";return e=''+function(){var e,t,n,i,r="";for(n="filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=",e=0,t=(i=s.split(",")).length-1;e
';return r}()+'
','"}}),an=Nt.extend({init:function(e){e=w.extend({height:100,text:"Drop an image here",multiple:!1,accept:null},e),this._super(e),this.classes.add("dropzone"),e.multiple&&this.classes.add("multiple")},renderHtml:function(){var e,t,n=this.settings;return e={id:this._id,hidefocus:"1"},t=we.create("div",e,""+this.translate(n.text)+" "),n.height&&we.css(t,"height",n.height+"px"),n.width&&we.css(t,"width",n.width+"px"),t.className=this.classes,t.outerHTML},postRender:function(){var i=this,e=function(e){e.preventDefault(),i.classes.toggle("dragenter"),i.getEl().className=i.classes};i._super(),i.$el.on("dragover",function(e){e.preventDefault()}),i.$el.on("dragenter",e),i.$el.on("dragleave",e),i.$el.on("drop",function(e){if(e.preventDefault(),!i.state.get("disabled")){var t=function(e){var t=i.settings.accept;if("string"!=typeof t)return e;var n=new RegExp("("+t.split(/\s*,\s*/).join("|")+")$","i");return w.grep(e,function(e){return n.test(e.name)})}(e.dataTransfer.files);i.value=function(){return t.length?i.settings.multiple?t:t[0]:null},t.length&&i.fire("change",e)}})},remove:function(){this.$el.off(),this._super()}}),ln=Nt.extend({init:function(e){var n=this;e.delimiter||(e.delimiter="\xbb"),n._super(e),n.classes.add("path"),n.canFocus=!0,n.on("click",function(e){var t;(t=e.target.getAttribute("data-index"))&&n.fire("select",{value:n.row()[t],index:t})}),n.row(n.settings.row)},focus:function(){return this.getEl().firstChild.focus(),this},row:function(e){return arguments.length?(this.state.set("row",e),this):this.state.get("row")},renderHtml:function(){return''+this._getDataPathHtml(this.state.get("row"))+"
"},bindStates:function(){var t=this;return t.state.on("change:row",function(e){t.innerHtml(t._getDataPathHtml(e.value))}),t._super()},_getDataPathHtml:function(e){var t,n,i=e||[],r="",o=this.classPrefix;for(t=0,n=i.length;t '+this.settings.delimiter+" ":"")+''+i[t].name+"
";return r||(r='\xa0
'),r}}),un=ln.extend({postRender:function(){var o=this,s=o.settings.editor;function a(e){if(1===e.nodeType){if("BR"===e.nodeName||e.getAttribute("data-mce-bogus"))return!0;if("bookmark"===e.getAttribute("data-mce-type"))return!0}return!1}return!1!==s.settings.elementpath&&(o.on("select",function(e){s.focus(),s.selection.select(this.row()[e.index].element),s.nodeChanged()}),s.on("nodeChange",function(e){for(var t=[],n=e.parents,i=n.length;i--;)if(1===n[i].nodeType&&!a(n[i])){var r=s.fire("ResolveName",{name:n[i].nodeName.toLowerCase(),target:n[i]});if(r.isDefaultPrevented()||t.push({name:r.name,element:n[i]}),r.isPropagationStopped())break}o.row(t)})),o._super()}}),cn=lt.extend({Defaults:{layout:"flex",align:"center",defaults:{flex:1}},renderHtml:function(){var e=this,t=e._layout,n=e.classPrefix;return e.classes.add("formitem"),t.preRender(e),''+(e.settings.title?'
'+e.settings.title+"
":"")+'
'+(e.settings.html||"")+t.renderHtml(e)+"
"}}),dn=lt.extend({Defaults:{containerCls:"form",layout:"flex",direction:"column",align:"stretch",flex:1,padding:15,labelGap:30,spacing:10,callbacks:{submit:function(){this.submit()}}},preRender:function(){var i=this,e=i.items();i.settings.formItemDefaults||(i.settings.formItemDefaults={layout:"flex",autoResize:"overflow",defaults:{flex:1}}),e.each(function(e){var t,n=e.settings.label;n&&((t=new cn(w.extend({items:{type:"label",id:e._id+"-l",text:n,flex:0,forId:e._id,disabled:e.disabled()}},i.settings.formItemDefaults))).type="formitem",e.aria("labelledby",e._id+"-l"),"undefined"==typeof e.settings.flex&&(e.settings.flex=1),i.replace(e,t),t.add(e))})},submit:function(){return this.fire("submit",{data:this.toJSON()})},postRender:function(){this._super(),this.fromJSON(this.settings.data)},bindStates:function(){var n=this;function e(){var e,t,i=0,r=[];if(!1!==n.settings.labelGapCalc)for(("children"===n.settings.labelGapCalc?n.find("formitem"):n.items()).filter("formitem").each(function(e){var t=e.items()[0],n=t.getEl().clientWidth;i=i'+(e.settings.title?''+e.settings.title+" ":"")+''+(e.settings.html||"")+t.renderHtml(e)+"
"}}),hn=0,mn=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:k(e)}},gn={fromHtml:function(e,t){var n=(t||_.document).createElement("div");if(n.innerHTML=e,!n.hasChildNodes()||1",l)),null!==u&&a.push(di("",u)),a))],o=function(e,t){return 0===e.length||0===t.length?e.concat(t):e.concat(c,t)},s=[],K(n,function(e){s=o(s,e)}),s):mi(e,d(ui))},mi=function(e,t){var n=e.toLowerCase(),i=w.grep(t,function(e){return-1!==e.title.toLowerCase().indexOf(n)});return 1===i.length&&i[0].title===e?[]:i},gi=function(r,i,o,s){var t=function(e){var t=li(o),n=hi(e,t,s,i);r.showAutoComplete(n,e)};r.on("autocomplete",function(){t(r.value())}),r.on("selectitem",function(e){var t=e.value;r.value(t.url);var n,i=(n=t.title).raw?n.raw:n;"image"===s?r.fire("change",{meta:{alt:i,attach:t.attach}}):r.fire("change",{meta:{text:i,attach:t.attach}}),r.focus()}),r.on("click",function(e){0===r.value().length&&"INPUT"===e.target.nodeName&&t("")}),r.on("PostRender",function(){r.getRoot().on("submit",function(e){var t,n,i;e.isDefaultPrevented()||(t=r.value(),i=ui[n=s],/^https?/.test(t)&&(i?j(i,t).isNone()&&(ui[n]=i.slice(0,5).concat(t)):ui[n]=[t]))})})},pi=function(o,e,n){var i=e.filepicker_validator_handler;i&&o.state.on("change:value",function(e){var t;0!==(t=e.value).length?i({url:t,type:n},function(e){var t,n,i,r=(n=(t=e).status,i=t.message,"valid"===n?{status:"ok",message:i}:"unknown"===n?{status:"warn",message:i}:"invalid"===n?{status:"warn",message:i}:{status:"none",message:""});o.statusMessage(r.message),o.statusLevel(r.status)}):o.statusLevel("none")})},vi=Qt.extend({Statics:{clearHistory:function(){ui={}}},init:function(e){var t,n,i,r=this,o=window.tinymce?window.tinymce.activeEditor:l.activeEditor,s=o.settings,a=e.filetype;e.spellcheck=!1,(i=s.file_picker_types||s.file_browser_callback_types)&&(i=w.makeMap(i,/[, ]/)),i&&!i[a]||(!(n=s.file_picker_callback)||i&&!i[a]?!(n=s.file_browser_callback)||i&&!i[a]||(t=function(){n(r.getEl("inp").id,r.value(),a,window)}):t=function(){var e=r.fire("beforecall").meta;e=w.extend({filetype:a},e),n.call(o,function(e,t){r.value(e).fire("change",{meta:t})},r.value(),e)}),t&&(e.icon="browse",e.onaction=t),r._super(e),r.classes.add("filepicker"),gi(r,s,o.getBody(),a),pi(r,s,a)}}),bi=Xt.extend({recalc:function(e){var t=e.layoutRect(),n=e.paddingBox;e.items().filter(":visible").each(function(e){e.layoutRect({x:n.left,y:n.top,w:t.innerW-n.right-n.left,h:t.innerH-n.top-n.bottom}),e.recalc&&e.recalc()})}}),yi=Xt.extend({recalc:function(e){var t,n,i,r,o,s,a,l,u,c,d,f,h,m,g,p,v,b,y,x,w,_,R,C,E,k,H,S,T,M,N,P,W,D,O,A,B,L=[],z=Math.max,I=Math.min;for(i=e.items().filter(":visible"),r=e.layoutRect(),o=e.paddingBox,s=e.settings,f=e.isRtl()?s.direction||"row-reversed":s.direction,a=s.align,l=e.isRtl()?s.pack||"end":s.pack,u=s.spacing||0,"row-reversed"!==f&&"column-reverse"!==f||(i=i.set(i.toArray().reverse()),f=f.split("-")[0]),"column"===f?(C="y",_="h",R="minH",E="maxH",H="innerH",k="top",S="deltaH",T="contentH",D="left",P="w",M="x",N="innerW",W="minW",O="right",A="deltaW",B="contentW"):(C="x",_="w",R="minW",E="maxW",H="innerW",k="left",S="deltaW",T="contentW",D="top",P="h",M="y",N="innerH",W="minH",O="bottom",A="deltaH",B="contentH"),d=r[H]-o[k]-o[k],w=c=0,t=0,n=i.length;tT[d]?C:T[d],M[f]=E>M[f]?E:M[f];for(k=o.innerW-p.left-p.right,d=_=0;d'},src:function(e){this.getEl().src=e},html:function(e,t){var n=this,i=this.getEl().contentWindow.document.body;return i?(i.innerHTML=e,t&&t()):u.setTimeout(function(){n.html(e)}),this}}),Zi=Nt.extend({init:function(e){this._super(e),this.classes.add("widget").add("infobox"),this.canFocus=!1},severity:function(e){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(e)},help:function(e){this.state.set("help",e)},renderHtml:function(){var e=this,t=e.classPrefix;return''+e.encode(e.state.get("text"))+'
'},bindStates:function(){var t=this;return t.state.on("change:text",function(e){t.getEl("body").firstChild.data=t.encode(e.value),t.state.get("rendered")&&t.updateLayoutRect()}),t.state.on("change:help",function(e){t.classes.toggle("has-help",e.value),t.state.get("rendered")&&t.updateLayoutRect()}),t._super()}}),Qi=Nt.extend({init:function(e){var t=this;t._super(e),t.classes.add("widget").add("label"),t.canFocus=!1,e.multiline&&t.classes.add("autoscroll"),e.strong&&t.classes.add("strong")},initLayoutRect:function(){var e=this,t=e._super();return e.settings.multiline&&(we.getSize(e.getEl()).width>t.maxW&&(t.minW=t.maxW,e.classes.add("multiline")),e.getEl().style.width=t.minW+"px",t.startMinH=t.h=t.minH=Math.min(t.maxH,we.getSize(e.getEl()).height)),t},repaint:function(){return this.settings.multiline||(this.getEl().style.lineHeight=this.layoutRect().h+"px"),this._super()},severity:function(e){this.classes.remove("error"),this.classes.remove("warning"),this.classes.remove("success"),this.classes.add(e)},renderHtml:function(){var e,t,n=this,i=n.settings.forId,r=n.settings.html?n.settings.html:n.encode(n.state.get("text"));return!i&&(t=n.settings.forName)&&(e=n.getRoot().find("#"+t)[0])&&(i=e._id),i?'"+r+" ":''+r+" "},bindStates:function(){var t=this;return t.state.on("change:text",function(e){t.innerHtml(t.encode(e.value)),t.state.get("rendered")&&t.updateLayoutRect()}),t._super()}}),er=lt.extend({Defaults:{role:"toolbar",layout:"flow"},init:function(e){this._super(e),this.classes.add("toolbar")},postRender:function(){return this.items().each(function(e){e.classes.add("toolbar-item")}),this._super()}}),tr=er.extend({Defaults:{role:"menubar",containerCls:"menubar",ariaRoot:!0,defaults:{type:"menubutton"}}}),nr=jt.extend({init:function(e){var t=this;t._renderOpen=!0,t._super(e),e=t.settings,t.classes.add("menubtn"),e.fixedWidth&&t.classes.add("fixed-width"),t.aria("haspopup",!0),t.state.set("menu",e.menu||t.render())},showMenu:function(e){var t,n=this;if(n.menu&&n.menu.visible()&&!1!==e)return n.hideMenu();n.menu||(t=n.state.get("menu")||[],n.classes.add("opened"),t.length?t={type:"menu",animate:!0,items:t}:(t.type=t.type||"menu",t.animate=!0),t.renderTo?n.menu=t.parent(n).show().renderTo():n.menu=v.create(t).parent(n).renderTo(),n.fire("createmenu"),n.menu.reflow(),n.menu.on("cancel",function(e){e.control.parent()===n.menu&&(e.stopPropagation(),n.focus(),n.hideMenu())}),n.menu.on("select",function(){n.focus()}),n.menu.on("show hide",function(e){"hide"===e.type&&e.control.parent()===n&&n.classes.remove("opened-under"),e.control===n.menu&&(n.activeMenu("show"===e.type),n.classes.toggle("opened","show"===e.type)),n.aria("expanded","show"===e.type)}).fire("show")),n.menu.show(),n.menu.layoutRect({w:n.layoutRect().w}),n.menu.repaint(),n.menu.moveRel(n.getEl(),n.isRtl()?["br-tr","tr-br"]:["bl-tl","tl-bl"]);var i=n.menu.layoutRect(),r=n.$el.offset().top+n.layoutRect().h;r>i.y&&r'+t.encode(o)+""),r=t.settings.icon?i+"ico "+i+"i-"+r:"",t.aria("role",t.parent()instanceof tr?"menuitem":"button"),''+(r?' ":"")+s+'
'},postRender:function(){var r=this;return r.on("click",function(e){e.control===r&&function(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1}(e.target,r.getEl())&&(r.focus(),r.showMenu(!e.aria),e.aria&&r.menu.items().filter(":visible")[0].focus())}),r.on("mouseenter",function(e){var t,n=e.control,i=r.parent();n&&i&&n instanceof nr&&n.parent()===i&&(i.items().filter("MenuButton").each(function(e){e.hideMenu&&e!==n&&(e.menu&&e.menu.visible()&&(t=!0),e.hideMenu())}),t&&(n.focus(),n.showMenu()))}),r._super()},bindStates:function(){var e=this;return e.state.on("change:menu",function(){e.menu&&e.menu.remove(),e.menu=null}),e._super()},remove:function(){this._super(),this.menu&&this.menu.remove()}}),ir=Ct.extend({Defaults:{defaultType:"menuitem",border:1,layout:"stack",role:"application",bodyRole:"menu",ariaRoot:!0},init:function(e){if(e.autohide=!0,e.constrainToViewport=!0,"function"==typeof e.items&&(e.itemsFactory=e.items,e.items=[]),e.itemDefaults)for(var t=e.items,n=t.length;n--;)t[n]=w.extend({},e.itemDefaults,t[n]);this._super(e),this.classes.add("menu"),e.animate&&11!==ce.ie&&this.classes.add("animate")},repaint:function(){return this.classes.toggle("menu-align",!0),this._super(),this.getEl().style.height="",this.getEl("body").style.height="",this},cancel:function(){this.hideAll(),this.fire("select")},load:function(){var t,n=this;function i(){n.throbber&&(n.throbber.hide(),n.throbber=null)}n.settings.itemsFactory&&(n.throbber||(n.throbber=new Ht(n.getEl("body"),!0),0===n.items().length?(n.throbber.show(),n.fire("loading")):n.throbber.show(100,function(){n.items().remove(),n.fire("loading")}),n.on("hide close",i)),n.requestTime=t=(new Date).getTime(),n.settings.itemsFactory(function(e){0!==e.length?n.requestTime===t&&(n.getEl().style.width="",n.getEl("body").style.width="",i(),n.items().remove(),n.getEl("body").innerHTML="",n.add(e),n.renderNew(),n.fire("loaded")):n.hide()}))},hideAll:function(){return this.find("menuitem").exec("hideMenu"),this._super()},preRender:function(){var n=this;return n.items().each(function(e){var t=e.settings;if(t.icon||t.image||t.selectable)return!(n._hasIcons=!0)}),n.settings.itemsFactory&&n.on("postrender",function(){n.settings.itemsFactory&&n.load()}),n.on("show hide",function(e){e.control===n&&("show"===e.type?u.setTimeout(function(){n.classes.add("in")},0):n.classes.remove("in"))}),n._super()}}),rr=nr.extend({init:function(i){var t,r,o,n,s=this;s._super(i),i=s.settings,s._values=t=i.values,t&&("undefined"!=typeof i.value&&function e(t){for(var n=0;n").replace(new RegExp(c("]mce~match!"),"g"),"")}return s&&t.parent().classes.add("menu-has-icons"),i.image&&(a=" style=\"background-image: url('"+i.image+"')\""),l&&(l=function(e){var t,n,i={};for(i=ce.mac?{alt:"⌥",ctrl:"⌘",shift:"⇧",meta:"⌘"}:{meta:"Ctrl"},e=e.split("+"),t=0;t \xa0":"",o=f(t.encode(d(o))),u=f(t.encode(d(u))),''+e+("-"!==o?'
'+o+" ":"")+(l?'":"")+(i.menu?'
':"")+(u?'":"")+"
"},postRender:function(){var t=this,n=t.settings,e=n.textStyle;if("function"==typeof e&&(e=e.call(this)),e){var i=t.getEl("text");i&&(i.setAttribute("style",e),t._textStyle=e)}return t.on("mouseenter click",function(e){e.control===t&&(n.menu||"click"!==e.type?(t.showMenu(),e.aria&&t.menu.focus(!0)):(t.fire("select"),u.requestAnimationFrame(function(){t.parent().hideAll()})))}),t._super(),t},hover:function(){return this.parent().items().each(function(e){e.classes.remove("selected")}),this.classes.toggle("selected",!0),this},active:function(e){return function(e,t){var n=e._textStyle;if(n){var i=e.getEl("text");i.setAttribute("style",n),t&&(i.style.color="",i.style.backgroundColor="")}}(this,e),void 0!==e&&this.aria("checked",e),this._super(e)},remove:function(){this._super(),this.menu&&this.menu.remove()}}),sr=Kt.extend({Defaults:{classes:"radio",role:"radio"}}),ar=Nt.extend({renderHtml:function(){var e=this,t=e.classPrefix;return e.classes.add("resizehandle"),"both"===e.settings.direction&&e.classes.add("resizehandle-both"),e.canFocus=!1,'
'},postRender:function(){var t=this;t._super(),t.resizeDragHelper=new ct(this._id,{start:function(){t.fire("ResizeStart")},drag:function(e){"both"!==t.settings.direction&&(e.deltaX=0),t.fire("Resize",e)},stop:function(){t.fire("ResizeEnd")}})},remove:function(){return this.resizeDragHelper&&this.resizeDragHelper.destroy(),this._super()}});function lr(e){var t="";if(e)for(var n=0;n'+e[n]+"";return t}var ur=Nt.extend({Defaults:{classes:"selectbox",role:"selectbox",options:[]},init:function(e){var n=this;n._super(e),n.settings.size&&(n.size=n.settings.size),n.settings.options&&(n._options=n.settings.options),n.on("keydown",function(e){var t;13===e.keyCode&&(e.preventDefault(),n.parents().reverse().each(function(e){if(e.toJSON)return t=e,!1}),n.fire("submit",{data:t.toJSON()}))})},options:function(e){return arguments.length?(this.state.set("options",e),this):this.state.get("options")},renderHtml:function(){var e,t=this,n="";return e=lr(t._options),t.size&&(n=' size = "'+t.size+'"'),'"+e+" "},bindStates:function(){var t=this;return t.state.on("change:options",function(e){t.getEl().innerHTML=lr(e.value)}),t._super()}});function cr(e,t,n){return e
'},reset:function(){this.value(this._initValue).repaint()},postRender:function(){var e,t,n,i,r,o,s,a,l,u,c,d,f,h,m=this;e=m._minValue,t=m._maxValue,"v"===m.settings.orientation?(n="screenY",i="top",r="height",o="h"):(n="screenX",i="left",r="width",o="w"),m._super(),function(o,s){function t(e){var t,n,i,r;t=cr(t=(((t=m.value())+(r=n=o))/((i=s)-r)+.05*e)*(i-n)-n,o,s),m.value(t),m.fire("dragstart",{value:t}),m.fire("drag",{value:t}),m.fire("dragend",{value:t})}m.on("keydown",function(e){switch(e.keyCode){case 37:case 38:t(-1);break;case 39:case 40:t(1)}})}(e,t),s=e,a=t,l=m.getEl("handle"),m._dragHelper=new ct(m._id,{handle:m._id+"-handle",start:function(e){u=e[n],c=parseInt(m.getEl("handle").style[i],10),d=(m.layoutRect()[o]||100)-we.getSize(l)[r],m.fire("dragstart",{value:h})},drag:function(e){var t=e[n]-u;f=cr(c+t,0,d),l.style[i]=f+"px",h=s+f/d*(a-s),m.value(h),m.tooltip().text(""+m.settings.previewFilter(h)).show().moveRel(l,"bc tc"),m.fire("drag",{value:h})},stop:function(){m.tooltip().hide(),m.fire("dragend",{value:h})}})},repaint:function(){this._super(),fr(this,this.value())},bindStates:function(){var t=this;return t.state.on("change:value",function(e){fr(t,e.value)}),t._super()}}),mr=Nt.extend({renderHtml:function(){return this.classes.add("spacer"),this.canFocus=!1,'
'}}),gr=nr.extend({Defaults:{classes:"widget btn splitbtn",role:"button"},repaint:function(){var e,t,n=this.getEl(),i=this.layoutRect();return this._super(),e=n.firstChild,t=n.lastChild,ye(e).css({width:i.w-we.getSize(t).width,height:i.h-2}),ye(t).css({height:i.h-2}),this},activeMenu:function(e){ye(this.getEl().lastChild).toggleClass(this.classPrefix+"active",e)},renderHtml:function(){var e,t,n=this,i=n._id,r=n.classPrefix,o=n.state.get("icon"),s=n.state.get("text"),a=n.settings,l="";return(e=a.image)?(o="none","string"!=typeof e&&(e=_.window.getSelection?e[0]:e[1]),e=" style=\"background-image: url('"+e+"')\""):e="",o=a.icon?r+"ico "+r+"i-"+o:"",s&&(n.classes.add("btn-has-text"),l=''+n.encode(s)+" "),t="boolean"==typeof a.active?' aria-pressed="'+a.active+'"':"",''+(o?' ":"")+l+' '+(n._menuBtnText?(o?"\xa0":"")+n._menuBtnText:"")+'
'},postRender:function(){var n=this.settings.onclick;return this.on("click",function(e){var t=e.target;if(e.control===this)for(;t;){if(e.aria&&"down"!==e.aria.key||"BUTTON"===t.nodeName&&-1===t.className.indexOf("open"))return e.stopImmediatePropagation(),void(n&&n.call(this,e));t=t.parentNode}}),delete this.settings.onclick,this._super()}}),pr=xi.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}}),vr=pt.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(n){var e;this.activeTabId&&(e=this.getEl(this.activeTabId),ye(e).removeClass(this.classPrefix+"active"),e.setAttribute("aria-selected","false")),this.activeTabId="t"+n,(e=this.getEl("t"+n)).setAttribute("aria-selected","true"),ye(e).addClass(this.classPrefix+"active"),this.items()[n].show().fire("showtab"),this.reflow(),this.items().each(function(e,t){n!==t&&e.hide()})},renderHtml:function(){var i=this,e=i._layout,r="",o=i.classPrefix;return i.preRender(),e.preRender(i),i.items().each(function(e,t){var n=i._id+"-t"+t;e.aria("role","tabpanel"),e.aria("labelledby",n),r+=''+i.encode(e.settings.title)+"
"}),'"},postRender:function(){var i=this;i._super(),i.settings.activeTab=i.settings.activeTab||0,i.activateTab(i.settings.activeTab),this.on("click",function(e){var t=e.target.parentNode;if(t&&t.id===i._id+"-head")for(var n=t.childNodes.length;n--;)t.childNodes[n]===e.target&&i.activateTab(n)})},initLayoutRect:function(){var e,t,n,i=this;t=(t=we.getSize(i.getEl("head")).width)<0?0:t,n=0,i.items().each(function(e){t=Math.max(t,e.layoutRect().minW),n=Math.max(n,e.layoutRect().minH)}),i.items().each(function(e){e.settings.x=0,e.settings.y=0,e.settings.w=t,e.settings.h=n,e.layoutRect({x:0,y:0,w:t,h:n})});var r=we.getSize(i.getEl("head")).height;return i.settings.minWidth=t,i.settings.minHeight=n+r,(e=i._super()).deltaH+=r,e.innerH=e.h-e.deltaH,e}}),br=Nt.extend({init:function(e){var n=this;n._super(e),n.classes.add("textbox"),e.multiline?n.classes.add("multiline"):(n.on("keydown",function(e){var t;13===e.keyCode&&(e.preventDefault(),n.parents().reverse().each(function(e){if(e.toJSON)return t=e,!1}),n.fire("submit",{data:t.toJSON()}))}),n.on("keyup",function(e){n.state.set("value",e.target.value)}))},repaint:function(){var e,t,n,i,r,o=this,s=0;e=o.getEl().style,t=o._layoutRect,r=o._lastRepaintRect||{};var a=_.document;return!o.settings.multiline&&a.all&&(!a.documentMode||a.documentMode<=8)&&(e.lineHeight=t.h-s+"px"),i=(n=o.borderBox).left+n.right+8,s=n.top+n.bottom+(o.settings.multiline?8:0),t.x!==r.x&&(e.left=t.x+"px",r.x=t.x),t.y!==r.y&&(e.top=t.y+"px",r.y=t.y),t.w!==r.w&&(e.width=t.w-i+"px",r.w=t.w),t.h!==r.h&&(e.height=t.h-s+"px",r.h=t.h),o._lastRepaintRect=r,o.fire("repaint",{},!1),o},renderHtml:function(){var t,e,n=this,i=n.settings;return t={id:n._id,hidefocus:"1"},w.each(["rows","spellcheck","maxLength","size","readonly","min","max","step","list","pattern","placeholder","required","multiple"],function(e){t[e]=i[e]}),n.disabled()&&(t.disabled="disabled"),i.subtype&&(t.type=i.subtype),(e=we.create(i.multiline?"textarea":"input",t)).value=n.state.get("value"),e.className=n.classes.toString(),e.outerHTML},value:function(e){return arguments.length?(this.state.set("value",e),this):(this.state.get("rendered")&&this.state.set("value",this.getEl().value),this.state.get("value"))},postRender:function(){var t=this;t.getEl().value=t.state.get("value"),t._super(),t.$el.on("change",function(e){t.state.set("value",e.target.value),t.fire("change",e)})},bindStates:function(){var t=this;return t.state.on("change:value",function(e){t.getEl().value!==e.value&&(t.getEl().value=e.value)}),t.state.on("change:disabled",function(e){t.getEl().disabled=e.value}),t._super()},remove:function(){this.$el.off(),this._super()}}),yr=function(){return{Selector:Ie,Collection:Ve,ReflowQueue:Ke,Control:rt,Factory:v,KeyboardNavigation:st,Container:lt,DragHelper:ct,Scrollable:gt,Panel:pt,Movable:He,Resizable:vt,FloatPanel:Ct,Window:It,MessageBox:Yt,Tooltip:Mt,Widget:Nt,Progress:Pt,Notification:Dt,Layout:qt,AbsoluteLayout:Xt,Button:jt,ButtonGroup:Gt,Checkbox:Kt,ComboBox:Qt,ColorBox:en,PanelButton:tn,ColorButton:rn,ColorPicker:sn,Path:ln,ElementPath:un,FormItem:cn,Form:dn,FieldSet:fn,FilePicker:vi,FitLayout:bi,FlexLayout:yi,FlowLayout:xi,FormatControls:Ji,GridLayout:Gi,Iframe:Ki,InfoBox:Zi,Label:Qi,Toolbar:er,MenuBar:tr,MenuButton:nr,MenuItem:or,Throbber:Ht,Menu:ir,ListBox:rr,Radio:sr,ResizeHandle:ar,SelectBox:ur,Slider:hr,Spacer:mr,SplitButton:gr,StackLayout:pr,TabPanel:vr,TextBox:br,DropZone:an,BrowseButton:Jt}},xr=function(n){n.ui?w.each(yr(),function(e,t){n.ui[t]=e}):n.ui=yr()};w.each(yr(),function(e,t){v.add(t,e)}),xr(window.tinymce?window.tinymce:{}),r.add("modern",function(e){return Ji.setup(e),$t(e)})}(window); tinymce.min.js 0000644 00001312002 14740051667 0007345 0 ustar 00 // 4.9.11 (2020-07-13)
!function(V){"use strict";var o=function(){},H=function(n,r){return function(){for(var e=[],t=0;t+~]|"+at+")"+at+"*"),mt=new RegExp("="+at+"*([^\\]'\"]*?)"+at+"*\\]","g"),gt=new RegExp(ct),pt=new RegExp("^"+ut+"$"),ht={ID:new RegExp("^#("+ut+")"),CLASS:new RegExp("^\\.("+ut+")"),TAG:new RegExp("^("+ut+"|[*])"),ATTR:new RegExp("^"+st),PSEUDO:new RegExp("^"+ct),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+at+"*(even|odd|(([+-]|)(\\d*)n|)"+at+"*(?:([+-]|)"+at+"*(\\d+)|))"+at+"*\\)|)","i"),bool:new RegExp("^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$","i"),needsContext:new RegExp("^"+at+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+at+"*((?:-\\d)?\\d*)"+at+"*\\)|)(?=[^-]|$)","i")},vt=/^(?:input|select|textarea|button)$/i,yt=/^h\d$/i,bt=/^[^{]+\{\s*\[native \w/,Ct=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,xt=/[+~]/,wt=/'|\\/g,Nt=new RegExp("\\\\([\\da-f]{1,6}"+at+"?|("+at+")|.)","ig"),Et=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)};try{rt.apply(et=ot.call($e.childNodes),$e.childNodes),et[$e.childNodes.length].nodeType}catch(iE){rt={apply:et.length?function(e,t){nt.apply(e,ot.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}var St=function(e,t,n,r){var o,i,a,u,s,c,l,f,d,m;if((t?t.ownerDocument||t:$e)!==Me&&Fe(t),n=n||[],!e||"string"!=typeof e)return n;if(1!==(u=(t=t||Me).nodeType)&&9!==u)return[];if(Ue&&!r){if(o=Ct.exec(e))if(a=o[1]){if(9===u){if(!(i=t.getElementById(a))||!i.parentNode)return n;if(i.id===a)return n.push(i),n}else if(t.ownerDocument&&(i=t.ownerDocument.getElementById(a))&&He(t,i)&&i.id===a)return n.push(i),n}else{if(o[2])return rt.apply(n,t.getElementsByTagName(e)),n;if((a=o[3])&&ke.getElementsByClassName)return rt.apply(n,t.getElementsByClassName(a)),n}if(ke.qsa&&(!je||!je.test(e))){if(f=l=qe,d=t,m=9===u&&e,1===u&&"object"!==t.nodeName.toLowerCase()){for(c=De(e),(l=t.getAttribute("id"))?f=l.replace(wt,"\\$&"):t.setAttribute("id",f),f="[id='"+f+"'] ",s=c.length;s--;)c[s]=f+Pt(c[s]);d=xt.test(e)&&Ot(t.parentNode)||t,m=c.join(",")}if(m)try{return rt.apply(n,d.querySelectorAll(m)),n}catch(g){}finally{l||t.removeAttribute("id")}}}return Be(e.replace(lt,"$1"),t,n,r)};function Tt(){var r=[];return function e(t,n){return r.push(t+" ")>_e.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function kt(e){return e[qe]=!0,e}function _t(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||1<<31)-(~e.sourceIndex||1<<31);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function At(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function Rt(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function Dt(a){return kt(function(i){return i=+i,kt(function(e,t){for(var n,r=a([],e.length,i),o=r.length;o--;)e[n=r[o]]&&(e[n]=!(t[n]=e[n]))})})}function Ot(e){return e&&typeof e.getElementsByTagName!==Qe&&e}for(Te in ke=St.support={},Re=St.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},Fe=St.setDocument=function(e){var t,s=e?e.ownerDocument||e:$e,n=s.defaultView;return s!==Me&&9===s.nodeType&&s.documentElement?(ze=(Me=s).documentElement,Ue=!Re(s),n&&n!==function(e){try{return e.top}catch(t){}return null}(n)&&(n.addEventListener?n.addEventListener("unload",function(){Fe()},!1):n.attachEvent&&n.attachEvent("onunload",function(){Fe()})),ke.attributes=!0,ke.getElementsByTagName=!0,ke.getElementsByClassName=bt.test(s.getElementsByClassName),ke.getById=!0,_e.find.ID=function(e,t){if(typeof t.getElementById!==Qe&&Ue){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},_e.filter.ID=function(e){var t=e.replace(Nt,Et);return function(e){return e.getAttribute("id")===t}},_e.find.TAG=ke.getElementsByTagName?function(e,t){if(typeof t.getElementsByTagName!==Qe)return t.getElementsByTagName(e)}:function(e,t){var n,r=[],o=0,i=t.getElementsByTagName(e);if("*"===e){for(;n=i[o++];)1===n.nodeType&&r.push(n);return r}return i},_e.find.CLASS=ke.getElementsByClassName&&function(e,t){if(Ue)return t.getElementsByClassName(e)},Ve=[],je=[],ke.disconnectedMatch=!0,je=je.length&&new RegExp(je.join("|")),Ve=Ve.length&&new RegExp(Ve.join("|")),t=bt.test(ze.compareDocumentPosition),He=t||bt.test(ze.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},Je=t?function(e,t){if(e===t)return Le=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!ke.sortDetached&&t.compareDocumentPosition(e)===n?e===s||e.ownerDocument===$e&&He($e,e)?-1:t===s||t.ownerDocument===$e&&He($e,t)?1:Ie?it.call(Ie,e)-it.call(Ie,t):0:4&n?-1:1)}:function(e,t){if(e===t)return Le=!0,0;var n,r=0,o=e.parentNode,i=t.parentNode,a=[e],u=[t];if(!o||!i)return e===s?-1:t===s?1:o?-1:i?1:Ie?it.call(Ie,e)-it.call(Ie,t):0;if(o===i)return _t(e,t);for(n=e;n=n.parentNode;)a.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;a[r]===u[r];)r++;return r?_t(a[r],u[r]):a[r]===$e?-1:u[r]===$e?1:0},s):Me},St.matches=function(e,t){return St(e,null,null,t)},St.matchesSelector=function(e,t){if((e.ownerDocument||e)!==Me&&Fe(e),t=t.replace(mt,"='$1']"),ke.matchesSelector&&Ue&&(!Ve||!Ve.test(t))&&(!je||!je.test(t)))try{var n=(void 0).call(e,t);if(n||ke.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(iE){}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Nt,Et),e[3]=(e[3]||e[4]||e[5]||"").replace(Nt,Et),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||St.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&St.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return ht.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&>.test(n)&&(t=De(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Nt,Et).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=Xe[e+" "];return t||(t=new RegExp("(^|"+at+")"+e+"("+at+"|$)"))&&Xe(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==Qe&&e.getAttribute("class")||"")})},ATTR:function(n,r,o){return function(e){var t=St.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===o:"!="===r?t!==o:"^="===r?o&&0===t.indexOf(o):"*="===r?o&&-1)[^>]*$|#([\w\-]*)$)/,Zt=Se.Event,en=Xt.makeMap("children,contents,next,prev"),tn=function(e){return void 0!==e},nn=function(e){return"string"==typeof e},rn=function(e,t){var n,r,o;for(o=(t=t||Yt).createElement("div"),n=t.createDocumentFragment(),o.innerHTML=e;r=o.firstChild;)n.appendChild(r);return n},on=function(e,t,n,r){var o;if(nn(t))t=rn(t,bn(e[0]));else if(t.length&&!t.nodeType){if(t=gn.makeArray(t),r)for(o=t.length-1;0<=o;o--)on(e,t[o],n,r);else for(o=0;o"===e.charAt(e.length-1)&&3<=e.length?[null,e,null]:Qt.exec(e)))return gn(t).find(e);if(n[1])for(r=rn(e,bn(t)).firstChild;r;)Gt.call(o,r),r=r.nextSibling;else{if(!(r=bn(t).getElementById(n[2])))return o;if(r.id!==n[2])return o.find(e);o.length=1,o[0]=r}}else this.add(e,!1);return o},toArray:function(){return Xt.toArray(this)},add:function(e,t){var n,r,o=this;if(nn(e))return o.add(gn(e));if(!1!==t)for(n=gn.unique(o.toArray().concat(gn.makeArray(e))),o.length=n.length,r=0;r=a.length&&r(o)}))})})},co=function(e){return so(e,uo.nu)},lo=function(n){return{is:function(e){return n===e},isValue:C,isError:b,getOr:q(n),getOrThunk:q(n),getOrDie:q(n),or:function(e){return lo(n)},orThunk:function(e){return lo(n)},fold:function(e,t){return t(n)},map:function(e){return lo(e(n))},mapError:function(e){return lo(n)},each:function(e){e(n)},bind:function(e){return e(n)},exists:function(e){return e(n)},forall:function(e){return e(n)},toOption:function(){return _.some(n)}}},fo=function(n){return{is:b,isValue:b,isError:C,getOr:$,getOrThunk:function(e){return e()},getOrDie:function(){return e=String(n),function(){throw new Error(e)}();var e},or:function(e){return e},orThunk:function(e){return e()},fold:function(e,t){return e(n)},map:function(e){return fo(n)},mapError:function(e){return fo(e(n))},each:o,bind:function(e){return fo(n)},exists:b,forall:C,toOption:_.none}},mo={value:lo,error:fo,fromOption:function(e,t){return e.fold(function(){return fo(t)},lo)}};function go(e,u){var t=e,n=function(e,t,n,r){var o,i;if(e){if(!r&&e[t])return e[t];if(e!==u){if(o=e[n])return o;for(i=e.parentNode;i&&i!==u;i=i.parentNode)if(o=i[n])return o}}};this.current=function(){return t},this.next=function(e){return t=n(t,"firstChild","nextSibling",e)},this.prev=function(e){return t=n(t,"lastChild","previousSibling",e)},this.prev2=function(e){return t=function(e,t,n,r){var o,i,a;if(e){if(o=e[n],u&&o===u)return;if(o){if(!r)for(a=o[t];a;a=a[t])if(!a[t])return a;return o}if((i=e.parentNode)&&i!==u)return i}}(t,"lastChild","previousSibling",e)}}var po,ho,vo,yo=function(t){var n;return function(e){return(n=n||function(e,t){for(var n={},r=0,o=e.length;r\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ko=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Xo=/[<>&\"\']/g,Yo=/([a-z0-9]+);?|&([a-z0-9]+);/gi,Go={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"};ho={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},vo={"<":"<",">":">","&":"&",""":'"',"'":"'"};var Jo=function(e,t){var n,r,o,i={};if(e){for(e=e.split(","),t=t||10,n=0;n>10),56320+(1023&t))):Go[t]||String.fromCharCode(t):vo[e]||po[e]||(n=e,(r=ar.fromTag("div").dom()).innerHTML=n,r.textContent||r.innerText||n);var n,r})}},ni={},ri={},oi=Xt.makeMap,ii=Xt.each,ai=Xt.extend,ui=Xt.explode,si=Xt.inArray,ci=function(e,t){return(e=Xt.trim(e))?e.split(t||" "):[]},li=function(e){var u,t,n,r,o,i,s={},a=function(e,t,n){var r,o,i,a=function(e,t){var n,r,o={};for(n=0,r=e.length;n]*>","gi")});var S=function(e){return new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$")},y=function(e){var t,n,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,y,b,C=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/,x=/^([!\-])?(\w+[\\:]:\w+|[^=:<]+)?(?:([=:<])(.*))?$/,w=/[*?+]/;if(e)for(e=ci(e,","),N["@"]&&(h=N["@"].attributes,v=N["@"].attributesOrder),t=0,n=e.length;t"+r,t.removeChild(t.firstChild)}catch(n){gn("
").html(" "+r).contents().slice(1).appendTo(t)}return r}}):t.html(r)},R=function(e,n,r,o,i){return k(e,function(e){var t="string"==typeof n?a.createElement(n):n;return _(t,r),o&&("string"!=typeof o&&o.nodeType?t.appendChild(o):"string"==typeof o&&A(t,o)),i?t:e.appendChild(t)})},D=function(e,t,n){return R(a.createElement(e),e,t,n,!0)},O=ti.decode,B=ti.encodeAllRaw,P=function(e,t){var n=h(e);return t?n.each(function(){for(var e;e=this.firstChild;)3===e.nodeType&&0===e.data.length?this.removeChild(e):this.parentNode.insertBefore(e,this)}).remove():n.remove(),1"+n+""+e+">":o+" />"},createFragment:function(e){var t,n=a.createElement("div"),r=a.createDocumentFragment();for(r.appendChild(n),e&&(n.innerHTML=e);t=n.firstChild;)r.appendChild(t);return r.removeChild(n),r},remove:P,setStyle:function(e,t,n){var r=h(e).css(t,n);u.update_styles&&wi(d,r)},getStyle:w,setStyles:function(e,t){var n=h(e).css(t);u.update_styles&&wi(d,n)},removeAllAttribs:function(e){return k(e,function(e){var t,n=e.attributes;for(t=n.length-1;0<=t;t--)e.removeAttributeNode(n.item(t))})},setAttrib:b,setAttribs:_,getAttrib:v,getPos:x,parseStyle:function(e){return d.parse(e)},serializeStyle:function(e,t){return d.serialize(e,t)},addStyle:function(e){var t,n;if(j!==Ei.DOM&&a===V.document){if(r[e])return;r[e]=!0}(n=a.getElementById("mceDefaultStyles"))||((n=a.createElement("style")).id="mceDefaultStyles",n.type="text/css",(t=a.getElementsByTagName("head")[0]).firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(a.createTextNode(e))},loadCSS:function(e){var n;j===Ei.DOM||a!==V.document?(e||(e=""),n=a.getElementsByTagName("head")[0],hi(e.split(","),function(e){var t;e=Xt._addCacheSuffix(e),o[e]||(o[e]=!0,t=D("link",{rel:"stylesheet",href:e}),n.appendChild(t))})):Ei.DOM.loadCSS(e)},addClass:function(e,t){h(e).addClass(t)},removeClass:function(e,t){I(e,t,!1)},hasClass:function(e,t){return h(e).hasClass(t)},toggleClass:I,show:function(e){h(e).show()},hide:function(e){h(e).hide()},isHidden:function(e){return"none"===h(e).css("display")},uniqueId:function(e){return(e||"mce_")+t++},setHTML:A,getOuterHTML:function(e){var t="string"==typeof e?p(e):e;return jo.isElement(t)?t.outerHTML:gn("
").append(gn(t).clone()).html()},setOuterHTML:function(e,t){h(e).each(function(){try{if("outerHTML"in this)return void(this.outerHTML=t)}catch(e){}P(gn(this).html(t),!0)})},decode:O,encode:B,insertAfter:function(e,t){var r=p(t);return k(e,function(e){var t,n;return t=r.parentNode,(n=r.nextSibling)?t.insertBefore(e,n):t.appendChild(e),e})},replace:L,rename:function(t,e){var n;return t.nodeName!==e.toUpperCase()&&(n=D(e),hi(y(t),function(e){b(n,e.nodeName,v(t,e.nodeName))}),L(n,t,!0)),n||t},findCommonAncestor:function(e,t){for(var n,r=e;r;){for(n=t;n&&r!==n;)n=n.parentNode;if(r===n)break;r=r.parentNode}return!r&&e.ownerDocument?e.ownerDocument.documentElement:r},toHex:function(e){return d.toHex(Xt.trim(e))},run:k,getAttribs:y,isEmpty:function(e,t){var n,r,o,i,a,u,s=0;if(e=e.firstChild){a=new go(e,e.parentNode),t=t||(f?f.getNonEmptyElements():null),i=f?f.getWhiteSpaceElements():{};do{if(o=e.nodeType,jo.isElement(e)){var c=e.getAttribute("data-mce-bogus");if(c){e=a.next("all"===c);continue}if(u=e.nodeName.toLowerCase(),t&&t[u]){if("br"===u){s++,e=a.next();continue}return!1}for(n=(r=y(e)).length;n--;)if("name"===(u=r[n].nodeName)||"data-mce-bookmark"===u)return!1}if(8===o)return!1;if(3===o&&!Ci.test(e.nodeValue))return!1;if(3===o&&e.parentNode&&i[e.parentNode.nodeName]&&Ci.test(e.nodeValue))return!1;e=a.next()}while(e)}return s<=1},createRng:F,nodeIndex:Ni,split:function(e,t,n){var r,o,i,a=F();if(e&&t)return a.setStart(e.parentNode,Ni(e)),a.setEnd(t.parentNode,Ni(t)),r=a.extractContents(),(a=F()).setStart(t.parentNode,Ni(t)+1),a.setEnd(e.parentNode,Ni(e)+1),o=a.extractContents(),(i=e.parentNode).insertBefore(qo.trimNode(j,r),e),n?i.insertBefore(n,e):i.insertBefore(t,e),i.insertBefore(qo.trimNode(j,o),e),P(e),n||t},bind:M,unbind:z,fire:function(e,t,n){return m.fire(e,t,n)},getContentEditable:U,getContentEditableParent:function(e){for(var t=C(),n=null;e&&e!==t&&null===(n=U(e));e=e.parentNode);return n},destroy:function(){if(l)for(var e=l.length;e--;){var t=l[e];m.unbind(t[0],t[1],t[2])}St.setDocument&&St.setDocument()},isChildOf:function(e,t){for(;e;){if(t===e)return!0;e=e.parentNode}return!1},dumpRng:function(e){return"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset}};return s=xi(d,u,function(){return j}),j}(pi=Ei||(Ei={})).DOM=pi(V.document),pi.nodeIndex=Ni;var Si=Ei,Ti=Si.DOM,ki=Xt.each,_i=Xt.grep,Ai=function(e){return"function"==typeof e},Ri=function(){var l={},o=[],i={},a=[],f=0;this.isDone=function(e){return 2===l[e]},this.markDone=function(e){l[e]=2},this.add=this.load=function(e,t,n,r){l[e]===undefined&&(o.push(e),l[e]=0),t&&(i[e]||(i[e]=[]),i[e].push({success:t,failure:r,scope:n||this}))},this.remove=function(e){delete l[e],delete i[e]},this.loadQueue=function(e,t,n){this.loadScripts(o,e,t,n)},this.loadScripts=function(n,e,t,r){var u,s=[],c=function(t,e){ki(i[e],function(e){Ai(e[t])&&e[t].call(e.scope)}),i[e]=undefined};a.push({success:e,failure:r,scope:t||this}),(u=function(){var e=_i(n);if(n.length=0,ki(e,function(e){var t,n,r,o,i,a;2!==l[e]?3!==l[e]?1!==l[e]&&(l[e]=1,f++,t=e,n=function(){l[e]=2,f--,c("success",e),u()},r=function(){l[e]=3,f--,s.push(e),c("failure",e),u()},i=(a=Ti).uniqueId(),(o=V.document.createElement("script")).id=i,o.type="text/javascript",o.src=Xt._addCacheSuffix(t),o.onload=function(){a.remove(i),o&&(o.onreadystatechange=o.onload=o=null),n()},o.onerror=function(){Ai(r)?r():"undefined"!=typeof console&&console.log&&console.log("Failed to load script: "+t)},(V.document.getElementsByTagName("head")[0]||V.document.body).appendChild(o)):c("failure",e):c("success",e)}),!f){var t=a.slice(0);a.length=0,ki(t,function(e){0===s.length?Ai(e.success)&&e.success.call(e.scope):Ai(e.failure)&&e.failure.call(e.scope,s)})}})()}};Ri.ScriptLoader=new Ri;var Di,Oi=Xt.each;function Bi(){var r=this,o=[],a={},u={},i=[],s=function(e){var t;return u[e]&&(t=u[e].dependencies),t||[]},c=function(e,t){return"object"==typeof t?t:"string"==typeof e?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}},l=function(e,n,t,r){var o=s(e);Oi(o,function(e){var t=c(n,e);f(t.resource,t,undefined,undefined)}),t&&(r?t.call(r):t.call(Ri))},f=function(e,t,n,r,o){if(!a[e]){var i="string"==typeof t?t:t.prefix+t.resource+t.suffix;0!==i.indexOf("/")&&-1===i.indexOf("://")&&(i=Bi.baseURL+"/"+i),a[e]=i.substring(0,i.lastIndexOf("/")),u[e]?l(e,t,n,r):Ri.ScriptLoader.add(i,function(){return l(e,t,n,r)},r,o)}};return{items:o,urls:a,lookup:u,_listeners:i,get:function(e){return u[e]?u[e].instance:undefined},dependencies:s,requireLangPack:function(e,t){var n=Bi.language;if(n&&!1!==Bi.languageLoad){if(t)if(-1!==(t=","+t+",").indexOf(","+n.substr(0,2)+","))n=n.substr(0,2);else if(-1===t.indexOf(","+n+","))return;Ri.ScriptLoader.add(a[e]+"/langs/"+n+".js")}},add:function(t,e,n){o.push(e),u[t]={instance:e,dependencies:n};var r=K(i,function(e){return e.name===t});return i=r.fail,Oi(r.pass,function(e){e.callback()}),e},remove:function(e){delete a[e],delete u[e]},createUrl:c,addComponents:function(e,t){var n=r.urls[e];Oi(t,function(e){Ri.ScriptLoader.add(n+"/"+e)})},load:f,waitFor:function(e,t){u.hasOwnProperty(e)?t():i.push({name:e,callback:t})}}}(Di=Bi||(Bi={})).PluginManager=Di(),Di.ThemeManager=Di();var Pi=function(t,n){Vr(t).each(function(e){e.dom().insertBefore(n.dom(),t.dom())})},Ii=function(e,t){qr(e).fold(function(){Vr(e).each(function(e){Fi(e,t)})},function(e){Pi(e,t)})},Li=function(t,n){Yr(t).fold(function(){Fi(t,n)},function(e){t.dom().insertBefore(n.dom(),e.dom())})},Fi=function(e,t){e.dom().appendChild(t.dom())},Mi=function(t,e){z(e,function(e){Fi(t,e)})},zi=function(e){e.dom().textContent="",z(Kr(e),function(e){Ui(e)})},Ui=function(e){var t=e.dom();null!==t.parentNode&&t.parentNode.removeChild(t)},ji=function(e){var t,n=Kr(e);0t.bottom)&&Ya(t.top-e.bottom,e,t)},Ja=function(e,t){return e.top>t.bottom||!(e.bottom=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom},Za=function(e){var t=e.startContainer,n=e.startOffset;return t.hasChildNodes()&&e.endOffset===n+1?t.childNodes[n]:null},eu=function(e,t){return 1===e.nodeType&&e.hasChildNodes()&&(t>=e.childNodes.length&&(t=e.childNodes.length-1),e=e.childNodes[t]),e},tu=new RegExp("[\u0300-\u036f\u0483-\u0487\u0488-\u0489\u0591-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e3-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962-\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a02\u0a3c\u0a41-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a51\u0a70-\u0a71\u0a75\u0a81-\u0a82\u0abc\u0ac1-\u0ac5\u0ac7-\u0ac8\u0acd\u0ae2-\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62-\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c00\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c62-\u0c63\u0c81\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc-\u0ccd\u0cd5-\u0cd6\u0ce2-\u0ce3\u0d01\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62-\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039-\u103a\u103d-\u103e\u1058-\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b4-\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193b\u1a17-\u1a18\u1a1b\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1ab0-\u1abd\u1abe\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80-\u1b81\u1ba2-\u1ba5\u1ba8-\u1ba9\u1bab-\u1bad\u1be6\u1be8-\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1cf8-\u1cf9\u1dc0-\u1df5\u1dfc-\u1dff\u200c-\u200d\u20d0-\u20dc\u20dd-\u20e0\u20e1\u20e2-\u20e4\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u302e-\u302f\u3099-\u309a\ua66f\ua670-\ua672\ua674-\ua67d\ua69e-\ua69f\ua6f0-\ua6f1\ua802\ua806\ua80b\ua825-\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\ua9e5\uaa29-\uaa2e\uaa31-\uaa32\uaa35-\uaa36\uaa43\uaa4c\uaa7c\uaab0\uaab2-\uaab4\uaab7-\uaab8\uaabe-\uaabf\uaac1\uaaec-\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\uff9e-\uff9f]"),nu=function(e){return"string"==typeof e&&768<=e.charCodeAt(0)&&tu.test(e)},ru=function(e,t,n){return e.isSome()&&t.isSome()?_.some(n(e.getOrDie(),t.getOrDie())):_.none()},ou=[].slice,iu=function(){for(var e=[],t=0;t=t.data.length:n>=t.childNodes.length},isEqual:function(e){return e&&t===e.container()&&n===e.offset()},getNode:function(e){return hu(t,e?n-1:n)}}}(ea=Su||(Su={})).fromRangeStart=function(e){return ea(e.startContainer,e.startOffset)},ea.fromRangeEnd=function(e){return ea(e.endContainer,e.endOffset)},ea.after=function(e){return ea(e.parentNode,pu(e)+1)},ea.before=function(e){return ea(e.parentNode,pu(e))},ea.isAbove=function(e,t){return ru(Z(t.getClientRects()),ee(e.getClientRects()),Ga).getOr(!1)},ea.isBelow=function(e,t){return ru(ee(t.getClientRects()),Z(e.getClientRects()),Ja).getOr(!1)},ea.isAtStart=function(e){return!!e&&e.isAtStart()},ea.isAtEnd=function(e){return!!e&&e.isAtEnd()},ea.isTextPosition=function(e){return!!e&&jo.isText(e.container())},ea.isElementPosition=function(e){return!1===ea.isTextPosition(e)};var Tu,ku,_u=Su,Au=jo.isText,Ru=jo.isBogus,Du=Si.nodeIndex,Ou=function(e){var t=e.parentNode;return Ru(t)?Ou(t):t},Bu=function(e){return e?Ht.reduce(e.childNodes,function(e,t){return Ru(t)&&"BR"!==t.nodeName?e=e.concat(Bu(t)):e.push(t),e},[]):[]},Pu=function(t){return function(e){return t===e}},Iu=function(e){var t,r,n,o;return(Au(e)?"text()":e.nodeName.toLowerCase())+"["+(r=Bu(Ou(t=e)),n=Ht.findIndex(r,Pu(t),t),r=r.slice(0,n+1),o=Ht.reduce(r,function(e,t,n){return Au(t)&&Au(r[n-1])&&e++,e},0),r=Ht.filter(r,jo.matchNodeNames(t.nodeName)),(n=Ht.findIndex(r,Pu(t),t))-o)+"]"},Lu=function(e,t){var n,r,o,i,a,u=[];return n=t.container(),r=t.offset(),Au(n)?o=function(e,t){for(;(e=e.previousSibling)&&Au(e);)t+=e.data.length;return t}(n,r):(r>=(i=n.childNodes).length?(o="after",r=i.length-1):o="before",n=i[r]),u.push(Iu(n)),a=function(e,t,n){var r=[];for(t=t.parentNode;!(t===e||n&&n(t));t=t.parentNode)r.push(t);return r}(e,n),a=Ht.filter(a,y(jo.isBogus)),(u=u.concat(Ht.map(a,function(e){return Iu(e)}))).reverse().join("/")+","+o},Fu=function(e,t){var n,r,o;return t?(t=(n=t.split(","))[0].split("/"),o=1e.data.length&&(t=e.data.length),_u(e,t)}(r,parseInt(o,10)):(o="after"===o?Du(r)+1:Du(r),_u(r.parentNode,o)):null):null},Mu=function(e,t){jo.isText(t)&&0===t.data.length&&e.remove(t)},zu=function(e,t,n){var r,o,i,a,u,s,c;jo.isDocumentFragment(n)?(i=e,a=t,u=n,s=_.from(u.firstChild),c=_.from(u.lastChild),a.insertNode(u),s.each(function(e){return Mu(i,e.previousSibling)}),c.each(function(e){return Mu(i,e.nextSibling)})):(r=e,o=n,t.insertNode(o),Mu(r,o.previousSibling),Mu(r,o.nextSibling))},Uu=jo.isContentEditableFalse,ju=function(e,t,n,r,o){var i,a=r[o?"startContainer":"endContainer"],u=r[o?"startOffset":"endOffset"],s=[],c=0,l=e.getRoot();for(jo.isText(a)?s.push(n?function(e,t,n){var r,o;for(o=e(t.data.slice(0,n)).length,r=t.previousSibling;r&&jo.isText(r);r=r.previousSibling)o+=e(r.data).length;return o}(t,a,u):u):(u>=(i=a.childNodes).length&&i.length&&(c=1,u=Math.max(0,i.length-1)),s.push(e.nodeIndex(i[u],n)+c));a&&a!==l;a=a.parentNode)s.push(e.nodeIndex(a,n));return s},Vu=function(e,t,n){var r=0;return Xt.each(e.select(t),function(e){if("all"!==e.getAttribute("data-mce-bogus"))return e!==n&&void r++}),r},Hu=function(e,t){var n,r,o,i=t?"start":"end";n=e[i+"Container"],r=e[i+"Offset"],jo.isElement(n)&&"TR"===n.nodeName&&(n=(o=n.childNodes)[Math.min(t?r:r-1,o.length-1)])&&(r=t?0:n.childNodes.length,e["set"+(t?"Start":"End")](n,r))},qu=function(e){return Hu(e,!0),Hu(e,!1),e},$u=function(e,t){var n;if(jo.isElement(e)&&(e=eu(e,t),Uu(e)))return e;if(ka(e)){if(jo.isText(e)&&Sa(e)&&(e=e.parentNode),n=e.previousSibling,Uu(n))return n;if(n=e.nextSibling,Uu(n))return n}},Wu=function(e,t,n){var r=n.getNode(),o=r?r.nodeName:null,i=n.getRng();if(Uu(r)||"IMG"===o)return{name:o,index:Vu(n.dom,o,r)};var a,u,s,c,l,f,d,m=$u((a=i).startContainer,a.startOffset)||$u(a.endContainer,a.endOffset);return m?{name:o=m.tagName,index:Vu(n.dom,o,m)}:(u=e,c=t,l=i,f=(s=n).dom,(d={}).start=ju(f,u,c,l,!0),s.isCollapsed()||(d.end=ju(f,u,c,l,!1)),d)},Ku=function(e,t,n){var r={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return n?e.create("span",r,""):e.create("span",r)},Xu=function(e,t){var n=e.dom,r=e.getRng(),o=n.uniqueId(),i=e.isCollapsed(),a=e.getNode(),u=a.nodeName;if("IMG"===u)return{name:u,index:Vu(n,u,a)};var s=qu(r.cloneRange());if(!i){s.collapse(!1);var c=Ku(n,o+"_end",t);zu(n,s,c)}(r=qu(r)).collapse(!0);var l=Ku(n,o+"_start",t);return zu(n,r,l),e.moveToBookmark({id:o,keep:1}),{id:o}},Yu={getBookmark:function(e,t,n){return 2===t?Wu(wa,n,e):3===t?(o=(r=e).getRng(),{start:Lu(r.dom.getRoot(),_u.fromRangeStart(o)),end:Lu(r.dom.getRoot(),_u.fromRangeEnd(o))}):t?{rng:e.getRng()}:Xu(e,!1);var r,o},getUndoBookmark:d(Wu,$,!0),getPersistentBookmark:Xu},Gu="_mce_caret",Ju=function(e){return jo.isElement(e)&&e.id===Gu},Qu=function(e,t){for(;t&&t!==e;){if(t.id===Gu)return t;t=t.parentNode}return null},Zu=jo.isElement,es=jo.isText,ts=function(e){var t=e.parentNode;t&&t.removeChild(e)},ns=function(e,t){0===t.length?ts(e):e.nodeValue=t},rs=function(e){var t=wa(e);return{count:e.length-t.length,text:t}},os=function(e,t){return us(e),t},is=function(e,t){var n,r,o,i=t.container(),a=(n=te(i.childNodes),r=e,o=L(n,r),-1===o?_.none():_.some(o)).map(function(e){return e').css(n).appendTo(a)[0];return c.set(_.some({caret:i,element:e,before:t})),c.get().each(function(e){t&&gn(e.caret).addClass("mce-visual-caret-before")}),f(),(r=e.ownerDocument.createRange()).setStart(s,0),r.setEnd(s,0),r},hide:l,getCss:function(){return".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}"},reposition:function(){c.get().each(function(e){var t=fs(a,e.element,e.before);gn(e.caret).css(t)})},destroy:function(){return he.clearInterval(t)}}},ms=function(){return cs.isIE()||cs.isEdge()||cs.isFirefox()},gs=function(e){return ls(e)||jo.isTable(e)&&ms()},ps=jo.isContentEditableFalse,hs=jo.matchStyleValues("display","block table table-cell table-caption list-item"),vs=ka,ys=Sa,bs=jo.isElement,Cs=Ha,xs=function(e){return 0=o.data.length-1)return 1===e&&(r=s(o))?Rs(r):n;if(Oa(o)&&i<=1)return-1===e&&(r=u(o))?Ds(r):n;if(i===o.data.length)return(r=s(o))?Rs(r):n;if(0===i)return(r=u(o))?Ds(r):n}return n},Bs=function(e,t){return _.from(ks(e?0:-1,t)).filter(ps)},Ps=function(e,t,n){var r=Os(e,t,n);return-1===e?Su.fromRangeStart(r):Su.fromRangeEnd(r)},Is=function(e){return _.from(e.getNode()).map(ar.fromDom)},Ls=function(e,t){for(;t=e(t);)if(t.isVisible())return t;return t},Fs=function(e,t){var n=Ts(e,t);return!(n||!jo.isBr(e.getNode()))||n};(ku=Tu||(Tu={}))[ku.Backwards=-1]="Backwards",ku[ku.Forwards=1]="Forwards";var Ms,zs,Us,js=jo.isContentEditableFalse,Vs=jo.isText,Hs=jo.isElement,qs=jo.isBr,$s=Ha,Ws=function(e){return Ua(e)||!!qa(t=e)&&!0!==j(te(t.getElementsByTagName("*")),function(e,t){return e||Ia(t)},!1);var t},Ks=$a,Xs=function(e,t){return e.hasChildNodes()&&t '),t},lc=function(e,t){return sc.lastPositionIn(e).fold(function(){return!1},function(e){return t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0})},fc=function(e,t,n){return!(!1!==t.hasChildNodes()||!Qu(e,t)||(o=n,i=(r=t).ownerDocument.createTextNode(xa),r.appendChild(i),o.setStart(i,0),o.setEnd(i,0),0));var r,o,i},dc=function(e,t,n,r){var o,i,a,u,s=n[t?"start":"end"],c=e.getRoot();if(s){for(a=s[0],i=c,o=s.length-1;1<=o;o--){if(u=i.childNodes,fc(c,i,r))return!0;if(s[o]>u.length-1)return!!fc(c,i,r)||lc(i,r);i=u[s[o]]}3===i.nodeType&&(a=Math.min(s[0],i.nodeValue.length)),1===i.nodeType&&(a=Math.min(s[0],i.childNodes.length)),t?r.setStart(i,a):r.setEnd(i,a)}return!0},mc=function(e){return jo.isText(e)&&0=t.nodeValue.length&&e.splice(0,1),t=e[e.length-1],0===m&&0h.length-1?p=h.length-1:p<0&&(p=0),d=h[p]||g),l===d)return o(v([l]));for(n=e.findCommonAncestor(l,d),a=l;a;a=a.parentNode){if(a===d)return C(l,n,!0);if(a===n)break}for(a=d;a;a=a.parentNode){if(a===l)return C(d,n);if(a===n)break}r=b(l,n)||l,i=b(d,n)||d,C(l,r,!0),(s=y(r===l?r:r.nextSibling,"nextSibling",i===d?i.nextSibling:i)).length&&o(v(s)),C(d,i)}},Fc=(Ms=mr,zs="text",{get:function(e){if(!Ms(e))throw new Error("Can only get "+zs+" value of a "+zs+" node");return Us(e).getOr("")},getOption:Us=function(e){return Ms(e)?_.from(e.dom().nodeValue):_.none()},set:function(e,t){if(!Ms(e))throw new Error("Can only set raw "+zs+" value of a "+zs+" node");e.dom().nodeValue=t}}),Mc=function(e){return Fc.get(e)},zc=function(r,o,i,a){return Vr(o).fold(function(){return"skipping"},function(e){return"br"===a||mr(n=o)&&"\ufeff"===Mc(n)?"valid":dr(t=o)&&Gi(t,aa())?"existing":Ju(o)?"caret":wc.isValid(r,i,a)&&wc.isValid(r,lr(e),i)?"valid":"invalid-child";var t,n})},Uc=function(e,t,n,r){var o,i,a=t.uid,u=void 0===a?(o="mce-annotation",i=(new Date).getTime(),o+"_"+Math.floor(1e9*Math.random())+ ++ga+String(i)):a,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o=n.startOffset&&"\xa0"===n.startContainer.nodeValue[n.startOffset]),t.setStart(r.startContainer,r.startOffset),t.setEnd(r.endContainer,r.endOffset),e.selection.setRng(t)),s.selection.getRng().collapsed){var i=Uc(s.getDoc(),f,c,l.decorate);ya(i,"\xa0"),s.selection.getRng().insertNode(i.dom()),s.selection.select(i.dom())}else{var a=Yu.getPersistentBookmark(s.selection,!1),u=s.selection.getRng();jc(s,u,c,l.decorate,f),s.selection.moveToBookmark(a)}})};function Hc(s){var n,r=(n={},{register:function(e,t){n[e]={name:e,settings:t}},lookup:function(e){return n.hasOwnProperty(e)?_.from(n[e]).map(function(e){return e.settings}):_.none()}});da(s,r);var o=fa(s);return{register:function(e,t){r.register(e,t)},annotate:function(t,n){r.lookup(t).each(function(e){Vc(s,t,e,n)})},annotationChanged:function(e,t){o.addListener(e,t)},remove:function(e){ca(s,_.some(e)).each(function(e){var t=e.elements;z(t,ji)})},getAll:function(e){var t,n,r,o,i,a,u=(t=s,n=e,r=ar.fromDom(t.getBody()),o=Qi(r,"["+ua()+'="'+n+'"]'),i={},z(o,function(e){var t=Er(e,sa()),n=i.hasOwnProperty(t)?i[t]:[];i[t]=n.concat([e])}),i);return a=function(e){return W(e,function(e){return e.dom()})},vr(u,function(e,t){return{k:t,v:a(e,t)}})}}}var qc=function(e){return Xt.grep(e.childNodes,function(e){return"LI"===e.nodeName})},$c=function(e){return e&&e.firstChild&&e.firstChild===e.lastChild&&("\xa0"===(t=e.firstChild).data||jo.isBr(t));var t},Wc=function(e){return 0'))},rl=function(n){Gr(n).each(function(t){Hr(t).each(function(e){Co(n)&&wo(t)&&Co(e)&&Ui(t)})})},ol=Xt.makeMap;function il(e){var u,s,c,l,f,d=[];return u=(e=e||{}).indent,s=ol(e.indent_before||""),c=ol(e.indent_after||""),l=ti.getEncodeFunc(e.entity_encoding||"raw",e.entities),f="html"===e.element_format,{start:function(e,t,n){var r,o,i,a;if(u&&s[e]&&0":" />",n&&u&&c[e]&&0"),u&&c[e]&&0")},comment:function(e){d.push("\x3c!--",e,"--\x3e")},pi:function(e,t){t?d.push("",e," ",l(t),"?>"):d.push("",e,"?>"),u&&d.push("\n")},doctype:function(e){d.push("",u?"\n":"")},reset:function(){d.length=0},getContent:function(){return d.join("").replace(/\n$/,"")}}}function al(t,g){void 0===g&&(g=di());var p=il(t);return(t=t||{}).validate=!("validate"in t)||t.validate,{serialize:function(e){var f,d;d=t.validate,f={3:function(e){p.text(e.value,e.raw)},8:function(e){p.comment(e.value)},7:function(e){p.pi(e.name,e.value)},10:function(e){p.doctype(e.value)},4:function(e){p.cdata(e.value)},11:function(e){if(e=e.firstChild)for(;m(e),e=e.next;);}},p.reset();var m=function(e){var t,n,r,o,i,a,u,s,c,l=f[e.type];if(l)l(e);else{if(t=e.name,n=e.shortEnded,r=e.attributes,d&&r&&1|)$/," "):o("nextSibling")||(t=t.replace(/( | )( |)$/," "))),t}(g.getRng(),t)),r=e.parser,m=n.merge,o=al({validate:e.settings.validate},e.schema),d=' ',s={content:t,format:"html",selection:!0,paste:n.paste},(s=e.fire("BeforeSetContent",s)).isDefaultPrevented())e.fire("SetContent",{content:s.content,format:"html",selection:!0,paste:n.paste});else{-1===(t=s.content).indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,d);var h,v,y,b,C,x,w=(l=g.getRng()).startContainer||(l.parentElement?l.parentElement():null),N=e.getBody();w===N&&g.isCollapsed()&&p.isBlock(N.firstChild)&&(h=e,(v=N.firstChild)&&!h.schema.getShortEndedElements()[v.nodeName])&&p.isEmpty(N.firstChild)&&((l=p.createRng()).setStart(N.firstChild,0),l.setEnd(N.firstChild,0),g.setRng(l)),g.isCollapsed()||(e.selection.setRng(cl(e.selection.getRng())),e.getDoc().execCommand("Delete",!1,null),y=e.selection.getRng(),b=t,C=y.startContainer,x=y.startOffset,3===C.nodeType&&y.collapsed&&("\xa0"===C.data[x]?(C.deleteData(x,1),/[\u00a0| ]$/.test(b)||(b+=" ")):"\xa0"===C.data[x-1]&&(C.deleteData(x-1,1),/[\u00a0| ]$/.test(b)||(b=" "+b))),t=b);var E,S,T,k={context:(i=g.getNode()).nodeName.toLowerCase(),data:n.data,insert:!0};if(u=r.parse(t,k),!0===n.paste&&Gc(e.schema,u)&&Qc(p,i))return l=Jc(o,p,e.selection.getRng(),u),e.selection.setRng(l),void e.fire("SetContent",s);if(function(e){for(var t=e;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")}(u),"mce_marker"===(f=u.lastChild).attr("id"))for(f=(c=f).prev;f;f=f.walk(!0))if(3===f.type||!p.isBlock(f.name)){e.schema.isValidChild(f.parent.name,"span")&&f.parent.insert(c,f,"br"===f.name);break}if(e._selectionOverrides.showBlockCaretContainer(i),k.invalid){for(fl(e,d),i=g.getNode(),a=e.getBody(),9===i.nodeType?i=f=a:f=i;f!==a;)f=(i=f).parentNode;t=i===a?a.innerHTML:p.getOuterHTML(i),t=o.serialize(r.parse(t.replace(//i,function(){return o.serialize(u)}))),i===a?p.setHTML(a,t):p.setOuterHTML(i,t)}else!function(e,t,n){if("all"===n.getAttribute("data-mce-bogus"))n.parentNode.insertBefore(e.dom.createFragment(t),n);else{var r=n.firstChild,o=n.lastChild;!r||r===o&&"BR"===r.nodeName?e.dom.setHTML(n,t):fl(e,t)}}(e,t=o.serialize(u),i);!function(e,t){var n=e.schema.getTextInlineElements(),r=e.dom;if(t){var o=e.getBody(),i=new el(r);Xt.each(r.select("*[data-mce-fragment]"),function(e){for(var t=e.parentNode;t&&t!==o;t=t.parentNode)n[e.nodeName.toLowerCase()]&&i.compare(t,e)&&r.remove(e,!0)})}}(e,m),function(n,e){var t,r,o,i,a,u=n.dom,s=n.selection;if(e){if(n.selection.scrollIntoView(e),t=function(e){for(var t=n.getBody();e&&e!==t;e=e.parentNode)if("false"===n.dom.getContentEditable(e))return e;return null}(e))return u.remove(e),s.select(t);var c=u.createRng();(i=e.previousSibling)&&3===i.nodeType?(c.setStart(i,i.nodeValue.length),fe.ie||(a=e.nextSibling)&&3===a.nodeType&&(i.appendData(a.data),a.parentNode.removeChild(a))):(c.setStartBefore(e),c.setEndBefore(e)),r=u.getParent(e,u.isBlock),u.remove(e),r&&u.isEmpty(r)&&(n.$(r).empty(),c.setStart(r,0),c.setEnd(r,0),ll(r)||r.getAttribute("data-mce-fragment")||!(o=function(e){var t=_u.fromRangeStart(e);if(t=Js(n.getBody()).next(t))return t.toRange()}(c))?u.add(r,u.create("br",{"data-mce-bogus":"1"})):(c=o,u.remove(r))),s.setRng(c)}}(e,p.get("mce_marker")),E=e.getBody(),Xt.each(E.getElementsByTagName("*"),function(e){e.removeAttribute("data-mce-fragment")}),S=e.dom,T=e.selection.getStart(),_.from(S.getParent(T,"td,th")).map(ar.fromDom).each(rl),e.fire("SetContent",s),e.addVisual()}},ml=function(e,t){var n,r,o="string"!=typeof(n=t)?(r=Xt.extend({paste:n.paste,data:{paste:n.paste}},n),{content:n.content,details:r}):{content:n,details:{}};dl(e,o.content,o.details)},gl=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,pl=function(e,t,n){var r=e.getParam(t,n);if(-1!==r.indexOf("=")){var o=e.getParam(t,"","hash");return o.hasOwnProperty(e.id)?o[e.id]:n}return r},hl=function(e){return e.getParam("iframe_attrs",{})},vl=function(e){return e.getParam("doctype","")},yl=function(e){return e.getParam("document_base_url","")},bl=function(e){return pl(e,"body_id","tinymce")},Cl=function(e){return pl(e,"body_class","")},xl=function(e){return e.getParam("content_security_policy","")},wl=function(e){return e.getParam("br_in_pre",!0)},Nl=function(e){if(e.getParam("force_p_newlines",!1))return"p";var t=e.getParam("forced_root_block","p");return!1===t?"":t},El=function(e){return e.getParam("forced_root_block_attrs",{})},Sl=function(e){return e.getParam("br_newline_selector",".mce-toc h2,figcaption,caption")},Tl=function(e){return e.getParam("no_newline_selector","")},kl=function(e){return e.getParam("keep_styles",!0)},_l=function(e){return e.getParam("end_container_on_empty_block",!1)},Al=function(e){return Xt.explode(e.getParam("font_size_style_values",""))},Rl=function(e){return Xt.explode(e.getParam("font_size_classes",""))},Dl=function(e){return e.getParam("images_dataimg_filter",q(!0),"function")},Ol=function(e){return e.getParam("automatic_uploads",!0,"boolean")},Bl=function(e){return e.getParam("images_reuse_filename",!1,"boolean")},Pl=function(e){return e.getParam("images_replace_blob_uris",!0,"boolean")},Il=function(e){return e.getParam("images_upload_url","","string")},Ll=function(e){return e.getParam("images_upload_base_path","","string")},Fl=function(e){return e.getParam("images_upload_credentials",!1,"boolean")},Ml=function(e){return e.getParam("images_upload_handler",null,"function")},zl=function(e){return e.getParam("content_css_cors",!1,"boolean")},Ul=function(e){return e.getParam("inline_boundaries_selector","a[href],code,.mce-annotation","string")},jl=function(e,t){if(!t)return t;var n=t.container(),r=t.offset();return e?Ta(n)?jo.isText(n.nextSibling)?_u(n.nextSibling,0):_u.after(n):Aa(t)?_u(n,r+1):t:Ta(n)?jo.isText(n.previousSibling)?_u(n.previousSibling,n.previousSibling.data.length):_u.before(n):Ra(t)?_u(n,r-1):t},Vl={isInlineTarget:function(e,t){return Lr(ar.fromDom(t),Ul(e))},findRootInline:function(e,t,n){var r,o,i,a=(r=e,o=t,i=n,U(Si.DOM.getParents(i.container(),"*",o),r));return _.from(a[a.length-1])},isRtl:function(e){return"rtl"===Si.DOM.getStyle(e,"direction",!0)||(t=e.textContent,gl.test(t));var t},isAtZwsp:function(e){return Aa(e)||Ra(e)},normalizePosition:jl,normalizeForwards:d(jl,!0),normalizeBackwards:d(jl,!1),hasSameParentBlock:function(e,t,n){var r=Ss(t,e),o=Ss(n,e);return r&&r===o}},Hl=function(e,t){return zr(e,t)?na(t,function(e){return No(e)||So(e)},(n=e,function(e){return Mr(n,ar.fromDom(e.dom().parentNode))})):_.none();var n},ql=function(e){var t,n,r;e.dom.isEmpty(e.getBody())&&(e.setContent(""),n=(t=e).getBody(),r=n.firstChild&&t.dom.isBlock(n.firstChild)?n.firstChild:n,t.selection.setCursorLocation(r,0))},$l=function(i,a,u){return ru(sc.firstPositionIn(u),sc.lastPositionIn(u),function(e,t){var n=Vl.normalizePosition(!0,e),r=Vl.normalizePosition(!1,t),o=Vl.normalizePosition(!1,a);return i?sc.nextPosition(u,o).map(function(e){return e.isEqual(r)&&a.isEqual(n)}).getOr(!1):sc.prevPosition(u,o).map(function(e){return e.isEqual(n)&&a.isEqual(r)}).getOr(!1)}).getOr(!0)},Wl=function(e,t){var n,r,o,i=ar.fromDom(e),a=ar.fromDom(t);return n=a,r="pre,code",o=d(Mr,i),ra(n,r,o).isSome()},Kl=function(e,t){return Ha(t)&&!1===(r=e,o=t,jo.isText(o)&&/^[ \t\r\n]*$/.test(o.data)&&!1===Wl(r,o))||(n=t,jo.isElement(n)&&"A"===n.nodeName&&n.hasAttribute("name"))||Xl(t);var n,r,o},Xl=jo.hasAttribute("data-mce-bookmark"),Yl=jo.hasAttribute("data-mce-bogus"),Gl=jo.hasAttributeValue("data-mce-bogus","all"),Jl=function(e){return function(e){var t,n,r=0;if(Kl(e,e))return!1;if(!(n=e.firstChild))return!0;t=new go(n,e);do{if(Gl(n))n=t.next(!0);else if(Yl(n))n=t.next();else if(jo.isBr(n))r++,n=t.next();else{if(Kl(e,n))return!1;n=t.next()}}while(n);return r<=1}(e.dom())},Ql=Ar("block","position"),Zl=Ar("from","to"),ef=function(e,t){var n=ar.fromDom(e),r=ar.fromDom(t.container());return Hl(n,r).map(function(e){return Ql(e,t)})},tf=function(o,i,e){var t=ef(o,_u.fromRangeStart(e)),n=t.bind(function(e){return sc.fromPosition(i,o,e.position()).bind(function(e){return ef(o,e).map(function(e){return t=o,n=i,r=e,jo.isBr(r.position().getNode())&&!1===Jl(r.block())?sc.positionIn(!1,r.block().dom()).bind(function(e){return e.isEqual(r.position())?sc.fromPosition(n,t,e).bind(function(e){return ef(t,e)}):_.some(r)}).getOr(r):r;var t,n,r})})});return ru(t,n,Zl).filter(function(e){return!1===Mr((r=e).from().block(),r.to().block())&&Vr((n=e).from().block()).bind(function(t){return Vr(n.to().block()).filter(function(e){return Mr(t,e)})}).isSome()&&(t=e,!1===jo.isContentEditableFalse(t.from().block().dom())&&!1===jo.isContentEditableFalse(t.to().block().dom()));var t,n,r})},nf=function(e,t,n){return n.collapsed?tf(e,t,n):_.none()},rf=function(e,t,n){return zr(t,e)?function(e,t){for(var n=D(t)?t:b,r=e.dom(),o=[];null!==r.parentNode&&r.parentNode!==undefined;){var i=r.parentNode,a=ar.fromDom(i);if(o.push(a),!0===n(a))break;r=i}return o}(e,function(e){return n(e)||Mr(e,t)}).slice(0,-1):[]},of=function(e,t){return rf(e,t,q(!1))},af=of,uf=function(e,t){return[e].concat(of(e,t))},sf=function(e){var t,n=(t=Kr(e),Y(t,Co).fold(function(){return t},function(e){return t.slice(0,e)}));return z(n,Ui),n},cf=function(e,t){var n=uf(t,e);return X(n.reverse(),Jl).each(Ui)},lf=function(e,t,n,r){if(Jl(n))return nl(n),sc.firstPositionIn(n.dom());0===U($r(r),function(e){return!Jl(e)}).length&&Jl(t)&&Pi(r,ar.fromTag("br"));var o=sc.prevPosition(n.dom(),_u.before(r.dom()));return z(sf(t),function(e){Pi(r,e)}),cf(e,t),o},ff=function(e,t,n){if(Jl(n))return Ui(n),Jl(t)&&nl(t),sc.firstPositionIn(t.dom());var r=sc.lastPositionIn(n.dom());return z(sf(t),function(e){Fi(n,e)}),cf(e,t),r},df=function(e,t){return zr(t,e)?(n=uf(e,t),_.from(n[n.length-1])):_.none();var n},mf=function(e,t){sc.positionIn(e,t.dom()).map(function(e){return e.getNode()}).map(ar.fromDom).filter(wo).each(Ui)},gf=function(e,t,n){return mf(!0,t),mf(!1,n),df(t,n).fold(d(ff,e,t,n),d(lf,e,t,n))},pf=function(e,t,n,r){return t?gf(e,r,n):gf(e,n,r)},hf=function(t,n){var e,r=ar.fromDom(t.getBody());return(e=nf(r.dom(),n,t.selection.getRng()).bind(function(e){return pf(r,n,e.from().block(),e.to().block())})).each(function(e){t.selection.setRng(e.toRange())}),e.isSome()},vf=function(e,t){var n=ar.fromDom(t),r=d(Mr,e);return ta(n,_o,r).isSome()},yf=function(e,t){var n,r,o=sc.prevPosition(e.dom(),_u.fromRangeStart(t)).isNone(),i=sc.nextPosition(e.dom(),_u.fromRangeEnd(t)).isNone();return!(vf(n=e,(r=t).startContainer)||vf(n,r.endContainer))&&o&&i},bf=function(e){var n,r,o,t,i=ar.fromDom(e.getBody()),a=e.selection.getRng();return yf(i,a)?((t=e).setContent(""),t.selection.setCursorLocation(),!0):(n=i,r=e.selection,o=r.getRng(),ru(Hl(n,ar.fromDom(o.startContainer)),Hl(n,ar.fromDom(o.endContainer)),function(e,t){return!1===Mr(e,t)&&(o.deleteContents(),pf(n,!0,e,t).each(function(e){r.setRng(e.toRange())}),!0)}).getOr(!1))},Cf=function(e,t){return!e.selection.isCollapsed()&&bf(e)},xf=function(a){if(!k(a))throw new Error("cases must be an array");if(0===a.length)throw new Error("there must be at least one case");var u=[],n={};return z(a,function(e,r){var t=gr(e);if(1!==t.length)throw new Error("one and only one name per case");var o=t[0],i=e[o];if(n[o]!==undefined)throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!k(i))throw new Error("case arguments must be an array");u.push(o),n[o]=function(){var e=arguments.length;if(e!==i.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+i.length+" ("+i+"), got "+e);for(var n=new Array(e),t=0;t=e.data.length,s=0===t;e.replaceData(t,n,(o=s,i=u,j((r=a).split(""),function(e,t){return-1!==" \f\n\r\t\x0B".indexOf(t)||"\xa0"===t?e.previousCharIsSpace||""===e.str&&o||e.str.length===r.length-1&&i?{previousCharIsSpace:!1,str:e.str+"\xa0"}:{previousCharIsSpace:!0,str:e.str+" "}:{previousCharIsSpace:!1,str:e.str+t}},{previousCharIsSpace:!1,str:""}).str))}},Wf=function(e,t){var n,r=e.data.slice(t),o=r.length-(n=r,n.replace(/^\s+/g,"")).length;return $f(e,t,o)},Kf=function(e,t){return r=e,o=(n=t).container(),i=n.offset(),!1===_u.isTextPosition(n)&&o===r.parentNode&&i>_u.before(r).offset()?_u(t.container(),t.offset()-1):t;var n,r,o,i},Xf=function(e){return Ha(e.previousSibling)?_.some((t=e.previousSibling,jo.isText(t)?_u(t,t.data.length):_u.after(t))):e.previousSibling?sc.lastPositionIn(e.previousSibling):_.none();var t},Yf=function(e){return Ha(e.nextSibling)?_.some((t=e.nextSibling,jo.isText(t)?_u(t,0):_u.before(t))):e.nextSibling?sc.firstPositionIn(e.nextSibling):_.none();var t},Gf=function(r,o){return Xf(o).orThunk(function(){return Yf(o)}).orThunk(function(){return e=r,t=o,n=_u.before(t.previousSibling?t.previousSibling:t.parentNode),sc.prevPosition(e,n).fold(function(){return sc.nextPosition(e,_u.after(t))},_.some);var e,t,n})},Jf=function(n,r){return Yf(r).orThunk(function(){return Xf(r)}).orThunk(function(){return e=n,t=r,sc.nextPosition(e,_u.after(t)).fold(function(){return sc.prevPosition(e,_u.before(t))},_.some);var e,t})},Qf=function(e,t,n){return(r=e,o=t,i=n,r?Jf(o,i):Gf(o,i)).map(d(Kf,n));var r,o,i},Zf=function(t,n,e){e.fold(function(){t.focus()},function(e){t.selection.setRng(e.toRange(),n)})},ed=function(e,t){return t&&e.schema.getBlockElements().hasOwnProperty(lr(t))},td=function(e){if(Jl(e)){var t=ar.fromHtml(' ');return zi(e),Fi(e,t),_.some(_u.before(t.dom()))}return _.none()},nd=function(e,t,l){var n,r,o,i,a=Hr(e).filter(mr),u=qr(e).filter(mr);return Ui(e),(n=a,r=u,o=t,i=function(e,t,n){var r,o,i,a,u=e.dom(),s=t.dom(),c=u.data.length;return o=s,i=l,a=Jn((r=u).data).length,r.appendData(o.data),Ui(ar.fromDom(o)),i&&Wf(r,a),n.container()===s?_u(u,c):n},n.isSome()&&r.isSome()&&o.isSome()?_.some(i(n.getOrDie(),r.getOrDie(),o.getOrDie())):_.none()).orThunk(function(){return l&&(a.each(function(e){return t=e.dom(),n=e.dom().length,r=t.data.slice(0,n),o=r.length-Jn(r).length,$f(t,n-o,o);var t,n,r,o}),u.each(function(e){return Wf(e.dom(),0)})),t})},rd=function(t,n,e,r){void 0===r&&(r=!0);var o,i,a=Qf(n,t.getBody(),e.dom()),u=ta(e,d(ed,t),(o=t.getBody(),function(e){return e.dom()===o})),s=nd(e,a,(i=e,br(t.schema.getTextInlineElements(),lr(i))));t.dom.isEmpty(t.getBody())?(t.setContent(""),t.selection.setCursorLocation()):u.bind(td).fold(function(){r&&Zf(t,n,s)},function(e){r&&Zf(t,n,_.some(e))})},od=function(a,u){var e,t,n,r,o,i;return(e=a.getBody(),t=u,n=a.selection.getRng(),r=Os(t?1:-1,e,n),o=_u.fromRangeStart(r),i=ar.fromDom(e),!1===t&&Ff(o)?_.some(jf.remove(o.getNode(!0))):t&&Lf(o)?_.some(jf.remove(o.getNode())):!1===t&&Lf(o)&&Sf(i,o)?Tf(i,o).map(function(e){return jf.remove(e.getNode())}):t&&Ff(o)&&Ef(i,o)?kf(i,o).map(function(e){return jf.remove(e.getNode())}):qf(e,t,o)).map(function(e){return e.fold((o=a,i=u,function(e){return o._selectionOverrides.hideFakeCaret(),rd(o,i,ar.fromDom(e)),!0}),(n=a,r=u,function(e){var t=r?_u.before(e):_u.after(e);return n.selection.setRng(t.toRange()),!0}),(t=a,function(e){return t.selection.setRng(e.toRange()),!0}));var t,n,r,o,i}).getOr(!1)},id=function(e,t){var n,r=e.selection.getNode();return!!jo.isContentEditableFalse(r)&&(n=ar.fromDom(e.getBody()),z(Qi(n,".mce-offscreen-selection"),Ui),rd(e,t,ar.fromDom(e.selection.getNode())),ql(e),!0)},ad=function(e,t){return e.selection.isCollapsed()?od(e,t):id(e,t)},ud=function(e){var t,n=function(e,t){for(;t&&t!==e;){if(jo.isContentEditableTrue(t)||jo.isContentEditableFalse(t))return t;t=t.parentNode}return null}(e.getBody(),e.selection.getNode());return jo.isContentEditableTrue(n)&&e.dom.isBlock(n)&&e.dom.isEmpty(n)&&(t=e.dom.create("br",{"data-mce-bogus":"1"}),e.dom.setHTML(n,""),n.appendChild(t),e.selection.setRng(_u.before(t).toRange())),!0},sd=jo.isText,cd=function(e){return sd(e)&&e.data[0]===xa},ld=function(e){return sd(e)&&e.data[e.data.length-1]===xa},fd=function(e){return e.ownerDocument.createTextNode(xa)},dd=function(e,t){return e?function(e){if(sd(e.previousSibling))return ld(e.previousSibling)||e.previousSibling.appendData(xa),e.previousSibling;if(sd(e))return cd(e)||e.insertData(0,xa),e;var t=fd(e);return e.parentNode.insertBefore(t,e),t}(t):function(e){if(sd(e.nextSibling))return cd(e.nextSibling)||e.nextSibling.insertData(0,xa),e.nextSibling;if(sd(e))return ld(e)||e.appendData(xa),e;var t=fd(e);return e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t}(t)},md=d(dd,!0),gd=d(dd,!1),pd=function(e,t){return jo.isText(e.container())?dd(t,e.container()):dd(t,e.getNode())},hd=function(e,t){var n=t.get();return n&&e.container()===n&&Ta(n)},vd=function(n,e){return e.fold(function(e){ss.remove(n.get());var t=md(e);return n.set(t),_.some(_u(t,t.length-1))},function(e){return sc.firstPositionIn(e).map(function(e){if(hd(e,n))return _u(n.get(),1);ss.remove(n.get());var t=pd(e,!0);return n.set(t),_u(t,1)})},function(e){return sc.lastPositionIn(e).map(function(e){if(hd(e,n))return _u(n.get(),n.get().length-1);ss.remove(n.get());var t=pd(e,!1);return n.set(t),_u(t,t.length-1)})},function(e){ss.remove(n.get());var t=gd(e);return n.set(t),_.some(_u(t,1))})},yd=function(e,t){for(var n=0;ni.left&&a.rightr.top&&o.bottomo.childNodes.length-1&&(c=!1),jo.isDocument(o)&&(o=g,i=0),o===g){if(c&&(u=o.childNodes[0s.childNodes.length-1;s=s.childNodes[Math.min(u,s.childNodes.length-1)]||s,u=c&&3===s.nodeType?s.nodeValue.length:0}var l=i.getParent(s,i.isBlock),f=l?i.getParent(l.parentNode,i.isBlock):null,d=f?f.nodeName.toUpperCase():"",m=t&&t.ctrlKey;"LI"!==d||m||(l=f),s&&3===s.nodeType&&u>=s.nodeValue.length&&(function(e,t,n){for(var r,o=new go(t,n),i=e.getNonEmptyElements();r=o.next();)if(i[r.nodeName.toLowerCase()]||0 ")},mceToggleVisualAid:function(){s.hasVisual=!s.hasVisual,s.addVisual()},mceReplaceContent:function(e,t,n){s.execCommand("mceInsertContent",!1,n.replace(/\{\$selection\}/g,i.getContent({format:"text"})))},mceInsertLink:function(e,t,n){var r;"string"==typeof n&&(n={href:n}),r=o.getParent(i.getNode(),"a"),n.href=n.href.replace(" ","%20"),r&&n.href||a.remove("link"),n.href&&a.apply("link",n,r)},selectAll:function(){var e=o.getParent(i.getStart(),jo.isContentEditableTrue);if(e){var t=o.createRng();t.selectNodeContents(e),i.setRng(t)}},"delete":function(){hg(s)},forwardDelete:function(){vg(s)},mceNewDocument:function(){s.setContent("")},InsertLineBreak:function(e,t,n){return jg(s,n),!0}});var p=function(n){return function(){var e=i.isCollapsed()?[o.getParent(i.getNode(),o.isBlock)]:i.getSelectedBlocks(),t=mp(e,function(e){return!!a.matchNode(e,n)});return-1!==gp(t,!0)}};e({JustifyLeft:p("alignleft"),JustifyCenter:p("aligncenter"),JustifyRight:p("alignright"),JustifyFull:p("alignjustify"),"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){return f(e)},mceBlockQuote:function(){return f("blockquote")},Outdent:function(){var e;if(n.inline_styles){if((e=o.getParent(i.getStart(),o.isBlock))&&0"),u))[o.length-1]=Xt.extend(o[o.length-1],{func:n,scope:r||i}),Xt.extend(o[0],{desc:i.translate(t),subpatterns:o.slice(1)})},o=function(e,t){return!!t&&t.ctrl===e.ctrlKey&&t.meta===e.metaKey&&t.alt===e.altKey&&t.shift===e.shiftKey&&!!(e.keyCode===t.keyCode||e.charCode&&e.charCode===t.charCode)&&(e.preventDefault(),!0)},c=function(e){return e.func?e.func.call(e.scope):null};i.on("keyup keypress keydown",function(t){var e,n;((n=t).altKey||n.ctrlKey||n.metaKey||"keydown"===(e=t).type&&112<=e.keyCode&&e.keyCode<=123)&&!t.isDefaultPrevented()&&(Xp(a,function(e){if(o(t,e))return r=e.subpatterns.slice(0),"keydown"===t.type&&c(e),!0}),o(t,r[0])&&(1===r.length&&"keydown"===t.type&&c(r[0]),r.shift()))}),this.add=function(e,n,r,o){var t;return"string"==typeof(t=r)?r=function(){i.execCommand(t,!1,null)}:Xt.isArray(t)&&(r=function(){i.execCommand(t[0],t[1],t[2])}),Xp(Yp(Xt.trim(e.toLowerCase())),function(e){var t=s(e,n,r,o);a[t.id]=t}),!0},this.remove=function(e){var t=s(e);return!!a[t.id]&&(delete a[t.id],!0)}}var Zp=function(e){var t=Ur(e).dom();return e.dom()===t.activeElement},eh=function(t){return(e=Ur(t),n=e!==undefined?e.dom():V.document,_.from(n.activeElement).map(ar.fromDom)).filter(function(e){return t.dom().contains(e.dom())});var e,n},th=function(t,e){return(n=e,n.collapsed?_.from(eu(n.startContainer,n.startOffset)).map(ar.fromDom):_.none()).bind(function(e){return ko(e)?_.some(e):!1===zr(t,e)?_.some(t):_.none()});var n},nh=function(t,e){th(ar.fromDom(t.getBody()),e).bind(function(e){return sc.firstPositionIn(e.dom())}).fold(function(){t.selection.normalize()},function(e){return t.selection.setRng(e.toRange())})},rh=function(e){if(e.setActive)try{e.setActive()}catch(t){e.focus()}else e.focus()},oh=function(e){var t,n=e.getBody();return n&&(t=ar.fromDom(n),Zp(t)||eh(t).isSome())},ih=function(e){return e.inline?oh(e):(t=e).iframeElement&&Zp(ar.fromDom(t.iframeElement));var t},ah=function(e){return e.editorManager.setActive(e)},uh=function(e,t){e.removed||(t?ah(e):function(t){var e=t.selection,n=t.settings.content_editable,r=t.getBody(),o=e.getRng();t.quirks.refreshContentEditable();var i,a,u=(i=t,a=e.getNode(),i.dom.getParent(a,function(e){return"true"===i.dom.getContentEditable(e)}));if(t.$.contains(r,u))return rh(u),nh(t,o),ah(t);t.bookmark!==undefined&&!1===ih(t)&&up(t).each(function(e){t.selection.setRng(e),o=e}),n||(fe.opera||rh(r),t.getWin().focus()),(fe.gecko||n)&&(rh(r),nh(t,o)),ah(t)}(e))},sh=ih,ch=function(e,t){return t.dom()[e]},lh=function(e,t){return parseInt(kr(t,e),10)},fh=d(ch,"clientWidth"),dh=d(ch,"clientHeight"),mh=d(lh,"margin-top"),gh=d(lh,"margin-left"),ph=function(e,t,n){var r,o,i,a,u,s,c,l,f,d,m,g=ar.fromDom(e.getBody()),p=e.inline?g:(r=g,ar.fromDom(r.dom().ownerDocument.documentElement)),h=(o=e.inline,a=t,u=n,s=(i=p).dom().getBoundingClientRect(),{x:a-(o?s.left+i.dom().clientLeft+gh(i):0),y:u-(o?s.top+i.dom().clientTop+mh(i):0)});return l=h.x,f=h.y,d=fh(c=p),m=dh(c),0<=l&&0<=f&&l<=d&&f<=m},hh=function(e){var t,n=e.inline?e.getBody():e.getContentAreaContainer();return(t=n,_.from(t).map(ar.fromDom)).map(function(e){return zr(Ur(e),e)}).getOr(!1)};function vh(n){var t,o=[],i=function(){var e,t=n.theme;return t&&t.getNotificationManagerImpl?t.getNotificationManagerImpl():{open:e=function(){throw new Error("Theme did not provide a NotificationManager implementation.")},close:e,reposition:e,getArgs:e}},a=function(){0t;var t}},cv=function(n){return function(e){return t=n,e.line===t;var t}},lv=jo.isContentEditableFalse,fv=Es,dv=function(e,t){return Math.abs(e.left-t)},mv=function(e,t){return Math.abs(e.right-t)},gv=function(e,t){return e>=t.left&&e<=t.right},pv=function(e,o){return Ht.reduce(e,function(e,t){var n,r;return n=Math.min(dv(e,o),mv(e,o)),r=Math.min(dv(t,o),mv(t,o)),gv(o,t)?t:gv(o,e)?e:r===n&&lv(t.node)?t:r=e.top&&n<=e.bottom});return(r=pv(f,t))&&(r=pv((a=e,c=function(t,e){var n;return n=U(ov([e]),function(e){return!t(e,u)}),s=s.concat(n),0===n.length},(s=[]).push(u=r),hv(tv.Up,a,d(c,Ga),u.node),hv(tv.Down,a,d(c,Ja),u.node),s),t))&&gs(r.node)?(i=t,{node:(o=r).node,before:dv(o,i)i&&(u=n.pageX+r-i),n.pageY+o>a&&(s=n.pageY+o-a),t.style.width=r-u+"px",t.style.height=o-s+"px",v(e.clientX,e.clientY)}},o=Sv(c,e),u=c,i=function(){u.dragging&&s.fire("dragend"),Tv(u)},(s=e).on("mousedown",n),e.on("mousemove",r),e.on("mouseup",o),t.bind(a,"mousemove",r),t.bind(a,"mouseup",i),e.on("remove",function(){t.unbind(a,"mousemove",r),t.unbind(a,"mouseup",i)})},_v=function(e){var n;kv(e),(n=e).on("drop",function(e){var t="undefined"!=typeof e.clientX?n.getDoc().elementFromPoint(e.clientX,e.clientY):null;(xv(t)||xv(n.dom.getContentEditableParent(t)))&&e.preventDefault()})},Av=function(t){var e=Vi(function(){if(!t.removed&&t.selection.getRng().collapsed){var e=fg(t,t.selection.getRng(),!1);t.selection.setRng(e)}},0);t.on("focus",function(){e.throttle()}),t.on("blur",function(){e.cancel()})},Rv=jo.isContentEditableTrue,Dv=jo.isContentEditableFalse,Ov=function(e,t){for(var n=e.getBody();t&&t!==n;){if(Rv(t)||Dv(t))return t;t=t.parentNode}return null},Bv=function(g){var p,e,t,a=g.getBody(),o=ds(g.getBody(),function(e){return g.dom.isBlock(e)},function(){return sh(g)}),h="sel-"+g.dom.uniqueId(),u=function(e){e&&g.selection.setRng(e)},s=function(){return g.selection.getRng()},v=function(e,t,n,r){return void 0===r&&(r=!0),g.fire("ShowCaret",{target:t,direction:e,before:n}).isDefaultPrevented()?null:(r&&g.selection.scrollIntoView(t,-1===e),o.show(n,t))},y=function(e,t){return t=Os(e,a,t),-1===e?_u.fromRangeStart(t):_u.fromRangeEnd(t)},n=function(e){return ka(e)||Oa(e)||Ba(e)},b=function(e){return n(e.startContainer)||n(e.endContainer)},c=function(e){var t=g.schema.getShortEndedElements(),n=g.dom.createRng(),r=e.startContainer,o=e.startOffset,i=e.endContainer,a=e.endOffset;return br(t,r.nodeName.toLowerCase())?0===o?n.setStartBefore(r):n.setStartAfter(r):n.setStart(r,o),br(t,i.nodeName.toLowerCase())?0===a?n.setEndBefore(i):n.setEndAfter(i):n.setEnd(i,a),n},l=function(e,t){var n,r,o,i,a,u,s,c,l,f,d=g.$,m=g.dom;if(!e)return null;if(e.collapsed){if(!b(e))if(!1===t){if(c=y(-1,e),gs(c.getNode(!0)))return v(-1,c.getNode(!0),!1,!1);if(gs(c.getNode()))return v(-1,c.getNode(),!c.isAtEnd(),!1)}else{if(c=y(1,e),gs(c.getNode()))return v(1,c.getNode(),!c.isAtEnd(),!1);if(gs(c.getNode(!0)))return v(1,c.getNode(!0),!1,!1)}return null}return i=e.startContainer,a=e.startOffset,u=e.endOffset,3===i.nodeType&&0===a&&Dv(i.parentNode)&&(i=i.parentNode,a=m.nodeIndex(i),i=i.parentNode),1!==i.nodeType?null:(u===a+1&&i===e.endContainer&&(n=i.childNodes[a]),Dv(n)?(l=f=n.cloneNode(!0),(s=g.fire("ObjectSelected",{target:n,targetClone:l})).isDefaultPrevented()?null:(r=oa(ar.fromDom(g.getBody()),"#"+h).fold(function(){return d([])},function(e){return d([e.dom()])}),l=s.targetClone,0===r.length&&(r=d('
').attr("id",h)).appendTo(g.getBody()),e=g.dom.createRng(),l===f&&fe.ie?(r.empty().append('\xa0
').append(l),e.setStartAfter(r[0].firstChild.firstChild),e.setEndAfter(l)):(r.empty().append("\xa0").append(l).append("\xa0"),e.setStart(r[0].firstChild,1),e.setEnd(r[0].lastChild,0)),r.css({top:m.getPos(n,g.getBody()).y}),r[0].focus(),(o=g.selection.getSel()).removeAllRanges(),o.addRange(e),z(Qi(ar.fromDom(g.getBody()),"*[data-mce-selected]"),function(e){Sr(e,"data-mce-selected")}),n.setAttribute("data-mce-selected","1"),p=n,C(),e)):null)},f=function(){p&&(p.removeAttribute("data-mce-selected"),oa(ar.fromDom(g.getBody()),"#"+h).each(Ui),p=null),oa(ar.fromDom(g.getBody()),"#"+h).each(Ui),p=null},C=function(){o.hide()};return fe.ceFalse&&(function(){g.on("mouseup",function(e){var t=s();t.collapsed&&ph(g,e.clientX,e.clientY)&&u(lg(g,t,!1))}),g.on("click",function(e){var t;(t=Ov(g,e.target))&&(Dv(t)&&(e.preventDefault(),g.focus()),Rv(t)&&g.dom.isChildOf(t,g.selection.getNode())&&f())}),g.on("blur NewBlock",function(){f()}),g.on("ResizeWindow FullscreenStateChanged",function(){return o.reposition()});var n,r,i=function(e,t){var n,r,o=g.dom.getParent(e,g.dom.isBlock),i=g.dom.getParent(t,g.dom.isBlock);return!(!o||!g.dom.isChildOf(o,i)||!1!==Dv(Ov(g,o)))||o&&(n=o,r=i,!(g.dom.getParent(n,g.dom.isBlock)===g.dom.getParent(r,g.dom.isBlock)))&&function(e){var t=Js(e);if(!e.firstChild)return!1;var n=_u.before(e.firstChild),r=t.next(n);return r&&!Lf(r)&&!Ff(r)}(o)};r=!1,(n=g).on("touchstart",function(){r=!1}),n.on("touchmove",function(){r=!0}),n.on("touchend",function(e){var t=Ov(n,e.target);Dv(t)&&(r||(e.preventDefault(),l(cg(n,t))))}),g.on("mousedown",function(e){var t,n=e.target;if((n===a||"HTML"===n.nodeName||g.dom.isChildOf(n,a))&&!1!==ph(g,e.clientX,e.clientY))if(t=Ov(g,n))Dv(t)?(e.preventDefault(),l(cg(g,t))):(f(),Rv(t)&&e.shiftKey||yv(e.clientX,e.clientY,g.selection.getRng())||(C(),g.selection.placeCaretAt(e.clientX,e.clientY)));else if(!1===gs(n)){f(),C();var r=vv(a,e.clientX,e.clientY);if(r&&!i(e.target,r.node)){e.preventDefault();var o=v(1,r.node,r.before,!1);g.getBody().focus(),u(o)}}}),g.on("keypress",function(e){rv.modifierPressed(e)||(e.keyCode,Dv(g.selection.getNode())&&e.preventDefault())}),g.on("getSelectionRange",function(e){var t=e.range;if(p){if(!p.parentNode)return void(p=null);(t=t.cloneRange()).selectNode(p),e.range=t}}),g.on("setSelectionRange",function(e){e.range=c(e.range);var t=l(e.range,e.forward);t&&(e.range=t)}),g.on("AfterSetSelectionRange",function(e){var t,n=e.range;b(n)||"mcepastebin"===n.startContainer.parentNode.id||C(),t=n.startContainer.parentNode,g.dom.hasClass(t,"mce-offscreen-selection")||f()}),g.on("copy",function(e){var t,n=e.clipboardData;if(!e.isDefaultPrevented()&&e.clipboardData&&!fe.ie){var r=(t=g.dom.get(h))?t.getElementsByTagName("*")[0]:t;r&&(e.preventDefault(),n.clearData(),n.setData("text/html",r.outerHTML),n.setData("text/plain",r.outerText))}}),_v(g),Av(g)}(),e=g.contentStyles,t=".mce-content-body",e.push(o.getCss()),e.push(t+" .mce-offscreen-selection {position: absolute;left: -9999999999px;max-width: 1000000px;}"+t+" *[contentEditable=false] {cursor: default;}"+t+" *[contentEditable=true] {cursor: text;}")),{showCaret:v,showBlockCaretContainer:function(e){e.hasAttribute("data-mce-caret")&&(Pa(e),u(s()),g.selection.scrollIntoView(e[0]))},hideFakeCaret:C,destroy:function(){o.destroy(),p=null}}},Pv=function(e){for(var t=e;/)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*(()?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")};i--;)r=(n=e[i]).firstChild?n.firstChild.value:"","script"===t?((o=n.attr("type"))&&n.attr("type","mce-no/type"===o?null:o.replace(/^mce\-/,"")),"xhtml"===s.element_format&&0")):"xhtml"===s.element_format&&0k(n)?(C=_(b*y),b=_(C/y)):(b=_(C/y),C=_(b*y))),N.setStyles(D(s),{width:b,height:C}),r=0<(r=f.startPos.x+t)?r:0,o=0<(o=f.startPos.y+n)?o:0,N.setStyles(c,{left:r,top:o,display:"block"}),c.innerHTML=b+" × "+C,f[2]<0&&s.clientWidth<=b&&N.setStyle(s,"left",g+(h-b)),f[3]<0&&s.clientHeight<=C&&N.setStyle(s,"top",p+(v-C)),(t=A.scrollWidth-x)+(n=A.scrollHeight-w)!=0&&N.setStyles(c,{left:r-t,top:o-n}),i||(Tp(a,u,h,v),i=!0)},P=function(){i=!1;var e=function(e,t){t&&(u.style[e]||!a.schema.isValid(u.nodeName.toLowerCase(),e)?N.setStyle(D(u),e,t):N.setAttrib(D(u),e,t))};e("width",b),e("height",C),N.unbind(S,"mousemove",B),N.unbind(S,"mouseup",P),T!==S&&(N.unbind(T,"mousemove",B),N.unbind(T,"mouseup",P)),N.remove(s),N.remove(c),o(u),kp(a,u,b,C),N.setAttrib(u,"style",N.getAttrib(u,"style")),a.nodeChanged()},o=function(e){var t,r,o,n,i;I(),M(),t=N.getPos(e,A),g=t.x,p=t.y,i=e.getBoundingClientRect(),r=i.width||i.right-i.left,o=i.height||i.bottom-i.top,u!==e&&(u=e,b=C=0),n=a.fire("ObjectSelected",{target:e}),O(e)&&!n.isDefaultPrevented()?E(l,function(n,e){var t;(t=N.get("mceResizeHandle"+e))&&N.remove(t),t=N.add(A,"div",{id:"mceResizeHandle"+e,"data-mce-bogus":"all","class":"mce-resizehandle",unselectable:!0,style:"cursor:"+e+"-resize; margin:0; padding:0"}),11===fe.ie&&(t.contentEditable=!1),N.bind(t,"mousedown",function(e){var t;e.stopImmediatePropagation(),e.preventDefault(),d=(t=e).screenX,m=t.screenY,h=D(u).clientWidth,v=D(u).clientHeight,y=v/h,(f=n).startPos={x:r*n[0]+g,y:o*n[1]+p},x=A.scrollWidth,w=A.scrollHeight,s=u.cloneNode(!0),N.addClass(s,"mce-clonedresizable"),N.setAttrib(s,"data-mce-bogus","all"),s.contentEditable=!1,s.unSelectabe=!0,N.setStyles(s,{left:g,top:p,margin:0}),s.removeAttribute("data-mce-selected"),A.appendChild(s),N.bind(S,"mousemove",B),N.bind(S,"mouseup",P),T!==S&&(N.bind(T,"mousemove",B),N.bind(T,"mouseup",P)),c=N.add(A,"div",{"class":"mce-resize-helper","data-mce-bogus":"all"},h+" × "+v)}),n.elm=t,N.setStyles(t,{left:r*n[0]+g-t.offsetWidth/2,top:o*n[1]+p-t.offsetHeight/2})}):I(),u.setAttribute("data-mce-selected","1")},I=function(){var e,t;for(e in M(),u&&u.removeAttribute("data-mce-selected"),l)(t=N.get("mceResizeHandle"+e))&&(N.unbind(t),N.remove(t))},L=function(e){var t,n=function(e,t){if(e)do{if(e===t)return!0}while(e=e.parentNode)};i||a.removed||(E(N.select("img[data-mce-selected],hr[data-mce-selected]"),function(e){e.removeAttribute("data-mce-selected")}),t="mousedown"===e.type?e.target:r.getNode(),n(t=N.$(t).closest("table,img,figure.image,hr")[0],A)&&(z(),n(r.getStart(!0),t)&&n(r.getEnd(!0),t))?o(t):I())},F=function(e){return Ab(function(e,t){for(;t&&t!==e;){if(Rb(t)||Ab(t))return t;t=t.parentNode}return null}(a.getBody(),e))},M=function(){for(var e in l){var t=l[e];t.elm&&(N.unbind(t.elm),delete t.elm)}},z=function(){try{a.getDoc().execCommand("enableObjectResizing",!1,!1)}catch(e){}};return a.on("init",function(){z(),fe.ie&&11<=fe.ie&&(a.on("mousedown click",function(e){var t=e.target,n=t.nodeName;i||!/^(TABLE|IMG|HR)$/.test(n)||F(t)||(2!==e.button&&a.selection.select(t,"TABLE"===n),"mousedown"===e.type&&a.nodeChanged())}),a.dom.bind(A,"mscontrolselect",function(e){var t=function(e){he.setEditorTimeout(a,function(){a.selection.select(e)})};if(F(e.target))return e.preventDefault(),void t(e.target);/^(TABLE|IMG|HR)$/.test(e.target.nodeName)&&(e.preventDefault(),"IMG"===e.target.tagName&&t(e.target))}));var t=he.throttle(function(e){a.composing||L(e)});a.on("nodechange ResizeEditor ResizeWindow drop FullscreenStateChanged",t),a.on("keyup compositionend",function(e){u&&"TABLE"===u.nodeName&&t(e)}),a.on("hide blur",I),a.on("contextmenu",n)}),a.on("remove",M),{isResizable:O,showResizeRect:o,hideResizeRect:I,updateResizeRect:L,destroy:function(){u=s=null}}},Ob=function(e){return jo.isContentEditableTrue(e)||jo.isContentEditableFalse(e)},Bb=function(e,t,n){var r,o,i,a,u,s=n;if(s.caretPositionFromPoint)(o=s.caretPositionFromPoint(e,t))&&((r=n.createRange()).setStart(o.offsetNode,o.offset),r.collapse(!0));else if(n.caretRangeFromPoint)r=n.caretRangeFromPoint(e,t);else if(s.body.createTextRange){r=s.body.createTextRange();try{r.moveToPoint(e,t),r.collapse(!0)}catch(c){r=function(e,n,t){var r,o,i;if(r=t.elementFromPoint(e,n),o=t.body.createTextRange(),r&&"HTML"!==r.tagName||(r=t.body),o.moveToElementText(r),0<(i=(i=Xt.toArray(o.getClientRects())).sort(function(e,t){return(e=Math.abs(Math.max(e.top-n,e.bottom-n)))-(t=Math.abs(Math.max(t.top-n,t.bottom-n)))})).length){n=(i[0].bottom+i[0].top)/2;try{return o.moveToPoint(e,n),o.collapse(!0),o}catch(a){}}return null}(e,t,n)}return i=r,a=n.body,u=i&&i.parentElement?i.parentElement():null,jo.isContentEditableFalse(function(e,t,n){for(;e&&e!==t;){if(n(e))return e;e=e.parentNode}return null}(u,a,Ob))?null:i}return r},Pb=function(n,e){return W(e,function(e){var t=n.fire("GetSelectionRange",{range:e});return t.range!==e?t.range:e})},Ib=function(e,t){var n=(t||V.document).createDocumentFragment();return z(e,function(e){n.appendChild(e.dom())}),ar.fromDom(n)},Lb=Ar("element","width","rows"),Fb=Ar("element","cells"),Mb=Ar("x","y"),zb=function(e,t){var n=parseInt(Er(e,t),10);return isNaN(n)?1:n},Ub=function(e){return j(e,function(e,t){return t.cells().length>e?t.cells().length:e},0)},jb=function(e,t){for(var n=e.rows(),r=0;r_ ',s.startContainer===c&&s.endContainer===c?c.body.innerHTML=t:(s.deleteContents(),0===c.body.childNodes.length?c.body.innerHTML=t:s.createContextualFragment?s.insertNode(s.createContextualFragment(t)):(i=c.createDocumentFragment(),a=c.createElement("div"),i.appendChild(a),a.outerHTML=t,s.insertNode(i))),o=e.dom.get("__caret"),(s=c.createRange()).setStartBefore(o),s.setEndBefore(o),e.selection.setRng(s),e.dom.remove("__caret");try{e.selection.setRng(s)}catch(f){}}else{var l=s;l.item&&(c.execCommand("Delete",!1,null),l=e.selection.getRng()),/^\s+/.test(t)?(l.pasteHTML('_ '+t),e.dom.remove("__mce_tmp")):l.pasteHTML(t)}u.no_events||e.fire("SetContent",u)}else e.fire("SetContent",u)},eC=function(e,t,n,r,o){var i=n?t.startContainer:t.endContainer,a=n?t.startOffset:t.endOffset;return _.from(i).map(ar.fromDom).map(function(e){return r&&t.collapsed?e:Xr(e,o(e,a)).getOr(e)}).bind(function(e){return dr(e)?_.some(e):Vr(e)}).map(function(e){return e.dom()}).getOr(e)},tC=function(e,t,n){return eC(e,t,!0,n,function(e,t){return Math.min(e.dom().childNodes.length,t)})},nC=function(e,t,n){return eC(e,t,!1,n,function(e,t){return 0t.clientHeight){e=t;break}t=t.parentNode}return e},scrollIntoView:function(e,t){return og(c,e,t)},placeCaretAt:function(e,t){return i(Bb(e,t,c.getDoc()))},getBoundingClientRect:function(){var e=m();return e.collapsed?_u.fromRangeStart(e).getClientRects()[0]:e.getBoundingClientRect()},destroy:function(){s=l=f=null,t.destroy()}};return n=_b(p),t=Db(p,c),p.bookmarkManager=n,p.controlSelection=t,p};(kb=Tb||(Tb={}))[kb.Br=0]="Br",kb[kb.Block=1]="Block",kb[kb.Wrap=2]="Wrap",kb[kb.Eol=3]="Eol";var sC=function(e,t){return e===Tu.Backwards?t.reverse():t},cC=function(e,t,n,r){for(var o,i,a,u,s,c,l=Js(n),f=r,d=[];f&&(s=l,c=f,o=t===Tu.Forwards?s.next(c):s.prev(c));){if(jo.isBr(o.getNode(!1)))return t===Tu.Forwards?{positions:sC(t,d).concat([o]),breakType:Tb.Br,breakAt:_.some(o)}:{positions:sC(t,d),breakType:Tb.Br,breakAt:_.some(o)};if(o.isVisible()){if(e(f,o)){var m=(i=t,a=f,u=o,jo.isBr(u.getNode(i===Tu.Forwards))?Tb.Br:!1===Ts(a,u)?Tb.Block:Tb.Wrap);return{positions:sC(t,d),breakType:m,breakAt:_.some(o)}}d.push(o),f=o}else f=o}return{positions:sC(t,d),breakType:Tb.Eol,breakAt:_.none()}},lC=function(n,r,o,e){return r(o,e).breakAt.map(function(e){var t=r(o,e).positions;return n===Tu.Backwards?t.concat(e):[e].concat(t)}).getOr([])},fC=function(e,i){return j(e,function(e,o){return e.fold(function(){return _.some(o)},function(r){return ru(Z(r.getClientRects()),Z(o.getClientRects()),function(e,t){var n=Math.abs(i-e.left);return Math.abs(i-t.left)<=n?o:r}).or(e)})},_.none())},dC=function(t,e){return Z(e.getClientRects()).bind(function(e){return fC(t,e.left)})},mC=d(cC,Su.isAbove,-1),gC=d(cC,Su.isBelow,1),pC=d(lC,-1,mC),hC=d(lC,1,gC),vC=jo.isContentEditableFalse,yC=Za,bC=function(e,t,n,r){var o=e===Tu.Forwards,i=o?Lf:Ff;if(!r.collapsed){var a=yC(r);if(vC(a))return sg(e,t,a,e===Tu.Backwards,!0)}var u=Sa(r.startContainer),s=Ps(e,t.getBody(),r);if(i(s))return cg(t,s.getNode(!o));var c=Vl.normalizePosition(o,n(s));if(!c)return u?r:null;if(i(c))return sg(e,t,c.getNode(!o),o,!0);var l=n(c);return l&&i(l)&&Fs(c,l)?sg(e,t,l.getNode(!o),o,!0):u?fg(t,c.toRange(),!0):null},CC=function(e,t,n,r){var o,i,a,u,s,c,l,f,d;if(d=yC(r),o=Ps(e,t.getBody(),r),i=n(t.getBody(),sv(1),o),a=U(i,cv(1)),s=Ht.last(o.getClientRects()),(Lf(o)||zf(o))&&(d=o.getNode()),(Ff(o)||Uf(o))&&(d=o.getNode(!0)),!s)return null;if(c=s.left,(u=pv(a,c))&&vC(u.node))return l=Math.abs(c-u.left),f=Math.abs(c-u.right),sg(e,t,u.node,l'),o=a,1===t?e.$(r).after(o):e.$(r).before(o),e.selection.select(o,!0),e.selection.collapse())}},wC=function(l,f){return function(){var e,t,n,r,o,i,a,u,s,c=(t=f,r=Js((e=l).getBody()),o=d(Ls,r.next),i=d(Ls,r.prev),a=t?Tu.Forwards:Tu.Backwards,u=t?o:i,s=e.selection.getRng(),(n=bC(a,e,u,s))?n:(n=xC(e,a,s))||null);return!!c&&(dg(l,c),!0)}},NC=function(u,s){return function(){var e,t,n,r,o,i,a=(r=(t=s)?1:-1,o=t?uv:av,i=(e=u).selection.getRng(),(n=CC(r,e,o,i))?n:(n=xC(e,r,i))||null);return!!a&&(dg(u,a),!0)}},EC=function(r,o){return function(){var t,e=o?_u.fromRangeEnd(r.selection.getRng()):_u.fromRangeStart(r.selection.getRng()),n=o?gC(r.getBody(),e):mC(r.getBody(),e);return(o?ee(n.positions):Z(n.positions)).filter((t=o,function(e){return t?Ff(e):Lf(e)})).fold(q(!1),function(e){return r.selection.setRng(e.toRange()),!0})}},SC=function(e,t,n,r,o){var i,a,u,s,c=Qi(ar.fromDom(n),"td,th,caption").map(function(e){return e.dom()}),l=U((i=e,G(c,function(e){var t,n,r=(t=Ka(e.getBoundingClientRect()),n=-1,{left:t.left-n,top:t.top-n,right:t.right+2*n,bottom:t.bottom+2*n,width:t.width+n,height:t.height+n});return[{x:r.left,y:i(r),cell:e},{x:r.right,y:i(r),cell:e}]})),function(e){return t(e,o)});return(a=l,u=r,s=o,j(a,function(e,r){return e.fold(function(){return _.some(r)},function(e){var t=Math.sqrt(Math.abs(e.x-u)+Math.abs(e.y-s)),n=Math.sqrt(Math.abs(r.x-u)+Math.abs(r.y-s));return _.some(nt}),_C=function(t,n){return Z(n.getClientRects()).bind(function(e){return TC(t,e.left,e.top)}).bind(function(e){return dC((t=e,sc.lastPositionIn(t).map(function(e){return mC(t,e).positions.concat(e)}).getOr([])),n);var t})},AC=function(t,n){return ee(n.getClientRects()).bind(function(e){return kC(t,e.left,e.top)}).bind(function(e){return dC((t=e,sc.firstPositionIn(t).map(function(e){return[e].concat(gC(t,e).positions)}).getOr([])),n);var t})},RC=function(e,t,n){var r,o,i,a,u=e(t,n);return(a=u).breakType===Tb.Wrap&&0===a.positions.length||!jo.isBr(n.getNode())&&(i=u).breakType===Tb.Br&&1===i.positions.length?(r=e,o=t,!u.breakAt.map(function(e){return r(o,e).breakAt.isSome()}).getOr(!1)):u.breakAt.isNone()},DC=d(RC,mC),OC=d(RC,gC),BC=function(e,t,n,r){var o,i,a,u,s=e.selection.getRng(),c=t?1:-1;if(ms()&&(o=t,i=s,a=n,u=_u.fromRangeStart(i),sc.positionIn(!o,a).map(function(e){return e.isEqual(u)}).getOr(!1))){var l=sg(c,e,n,!t,!0);return dg(e,l),!0}return!1},PC=function(e,t){var n=t.getNode(e);return jo.isElement(n)&&"TABLE"===n.nodeName?_.some(n):_.none()},IC=function(u,s,c){var e=PC(!!s,c),t=!1===s;e.fold(function(){return dg(u,c.toRange())},function(a){return sc.positionIn(t,u.getBody()).filter(function(e){return e.isEqual(c)}).fold(function(){return dg(u,c.toRange())},function(e){return n=s,o=a,t=c,void((i=Nl(r=u))?r.undoManager.transact(function(){var e=ar.fromTag(i);Nr(e,El(r)),Fi(e,ar.fromTag("br")),n?Ii(ar.fromDom(o),e):Pi(ar.fromDom(o),e);var t=r.dom.createRng();t.setStart(e.dom(),0),t.setEnd(e.dom(),0),dg(r,t)}):dg(r,t.toRange()));var n,r,o,t,i})})},LC=function(e,t,n,r){var o,i,a,u,s,c,l=e.selection.getRng(),f=_u.fromRangeStart(l),d=e.getBody();if(!t&&DC(r,f)){var m=(u=d,_C(s=n,c=f).orThunk(function(){return Z(c.getClientRects()).bind(function(e){return fC(pC(u,_u.before(s)),e.left)})}).getOr(_u.before(s)));return IC(e,t,m),!0}return!(!t||!OC(r,f))&&(o=d,m=AC(i=n,a=f).orThunk(function(){return Z(a.getClientRects()).bind(function(e){return fC(hC(o,_u.after(i)),e.left)})}).getOr(_u.after(i)),IC(e,t,m),!0)},FC=function(t,n){return function(){return _.from(t.dom.getParent(t.selection.getNode(),"td,th")).bind(function(e){return _.from(t.dom.getParent(e,"table")).map(function(e){return BC(t,n,e)})}).getOr(!1)}},MC=function(n,r){return function(){return _.from(n.dom.getParent(n.selection.getNode(),"td,th")).bind(function(t){return _.from(n.dom.getParent(t,"table")).map(function(e){return LC(n,r,e,t)})}).getOr(!1)}},zC=function(e){return F(["figcaption"],lr(e))},UC=function(e){var t=V.document.createRange();return t.setStartBefore(e.dom()),t.setEndBefore(e.dom()),t},jC=function(e,t,n){n?Fi(e,t):Li(e,t)},VC=function(e,t,n,r){return""===t?(l=e,f=r,d=ar.fromTag("br"),jC(l,d,f),UC(d)):(o=e,i=r,a=t,u=n,s=ar.fromTag(a),c=ar.fromTag("br"),Nr(s,u),Fi(s,c),jC(o,s,i),UC(c));var o,i,a,u,s,c,l,f,d},HC=function(e,t,n){return t?(o=e.dom(),gC(o,n).breakAt.isNone()):(r=e.dom(),mC(r,n).breakAt.isNone());var r,o},qC=function(t,n){var e,r,o,i=ar.fromDom(t.getBody()),a=_u.fromRangeStart(t.selection.getRng()),u=Nl(t),s=El(t);return(e=a,r=i,o=d(Mr,r),na(ar.fromDom(e.container()),Co,o).filter(zC)).exists(function(){if(HC(i,n,a)){var e=VC(i,u,s,n);return t.selection.setRng(e),!0}return!1})},$C=function(e,t){return function(){return!!e.selection.isCollapsed()&&qC(e,t)}},WC=function(e,r){return G(W(e,function(e){return Zy({shiftKey:!1,altKey:!1,ctrlKey:!1,metaKey:!1,keyCode:0,action:o},e)}),function(e){return t=e,(n=r).keyCode===t.keyCode&&n.shiftKey===t.shiftKey&&n.altKey===t.altKey&&n.ctrlKey===t.ctrlKey&&n.metaKey===t.metaKey?[e]:[];var t,n})},KC=function(e){for(var t=[],n=1;n'},cx=function(e,t){return e.nodeName===t||e.previousSibling&&e.previousSibling.nodeName===t},lx=function(e,t){return t&&e.isBlock(t)&&!/^(TD|TH|CAPTION|FORM)$/.test(t.nodeName)&&!/^(fixed|absolute)/i.test(t.style.position)&&"true"!==e.getContentEditable(t)},fx=function(e,t,n){return!1===jo.isText(t)?n:e?1===n&&t.data.charAt(n-1)===xa?0:n:n===t.data.length-1&&t.data.charAt(n)===xa?t.data.length:n},dx=function(e,t){var n,r,o=e.getRoot();for(n=t;n!==o&&"false"!==e.getContentEditable(n);)"true"===e.getContentEditable(n)&&(r=n),n=n.parentNode;return n!==o?r:o},mx=function(o,i,e){_.from(e.style).map(o.dom.parseStyle).each(function(e){var t=function(e){var t={},n=e.dom();if(Cr(n))for(var r=0;rs.childNodes.length-1,s=s.childNodes[Math.min(i,s.childNodes.length-1)]||s,i=g&&jo.isText(s)?s.nodeValue.length:0),(u=dx(x,s))&&((m&&!n||!m&&n)&&(s=function(e,t,n,r,o){var i,a,u,s,c,l,f,d=t||"P",m=e.dom,g=dx(m,r);if(!(a=m.getParent(r,m.isBlock))||!lx(m,a)){if(l=(a=a||g)===e.getBody()||(f=a)&&/^(TD|TH|CAPTION)$/.test(f.nodeName)?a.nodeName.toLowerCase():a.parentNode.nodeName.toLowerCase(),!a.hasChildNodes())return i=m.create(d),gx(e,i),a.appendChild(i),n.setStart(i,0),n.setEnd(i,0),i;for(s=r;s.parentNode!==a;)s=s.parentNode;for(;s&&!m.isBlock(s);)s=(u=s).previousSibling;if(u&&e.schema.isValidChild(l,d.toLowerCase())){for(i=m.create(d),gx(e,i),u.parentNode.insertBefore(i,u),s=u;s&&!m.isBlock(s);)c=s.nextSibling,i.appendChild(s),s=c;n.setStart(r,o),n.setEnd(r,o)}}return r}(a,m,E,s,i)),c=x.getParent(s,x.isBlock),l=c?x.getParent(c.parentNode,x.isBlock):null,f=c?c.nodeName.toUpperCase():"","LI"!==(d=l?l.nodeName.toUpperCase():"")||e.ctrlKey||(l=(c=l).parentNode,f=d),/^(LI|DT|DD)$/.test(f)&&x.isEmpty(c)?ux(a,S,l,c,m):m&&c===a.getBody()||(m=m||"P",Sa(c)?(r=Pa(c),x.isEmpty(c)&&sx(c),gx(a,r),QC(a,r)):T()?k():T(!0)?(r=c.parentNode.insertBefore(S(),c),QC(a,cx(c,"HR")?r:c)):((t=(b=E,C=b.cloneRange(),C.setStart(b.startContainer,fx(!0,b.startContainer,b.startOffset)),C.setEnd(b.endContainer,fx(!1,b.endContainer,b.endOffset)),C).cloneRange()).setEndAfter(c),o=t.extractContents(),y=o,z(Ji(ar.fromDom(y),mr),function(e){var t=e.dom();t.nodeValue=wa(t.nodeValue)}),function(e){for(;jo.isText(e)&&(e.nodeValue=e.nodeValue.replace(/^[\r\n]+/,"")),e=e.firstChild;);}(o),r=o.firstChild,x.insertAfter(o,c),function(e,t,n){var r,o=n,i=[];if(o){for(;o=o.firstChild;){if(e.isBlock(o))return;jo.isElement(o)&&!t[o.nodeName.toLowerCase()]&&i.push(o)}for(r=i.length;r--;)!(o=i[r]).hasChildNodes()||o.firstChild===o.lastChild&&""===o.firstChild.nodeValue?e.remove(o):(a=e,(u=o)&&"A"===u.nodeName&&a.isEmpty(u)&&e.remove(o));var a,u}}(x,N,r),p=x,(h=c).normalize(),(v=h.lastChild)&&!/^(left|right)$/gi.test(p.getStyle(v,"float",!0))||p.add(h,"br"),x.isEmpty(c)&&sx(c),r.normalize(),x.isEmpty(r)?(x.remove(r),k()):(gx(a,r),QC(a,r))),x.setAttrib(r,"id",""),a.fire("NewBlock",{newBlock:r})))},hx=function(e,t){return ex(e).filter(function(e){return 0",yl(f)!==f.documentBaseUrl&&(g+=' '),g+=' ',d=bl(f),m=Cl(f),xl(f)&&(g+=' '),g+=' '),Cw.add(t.iframeContainer,l),p},ww=function(e,t){var n=xw(e,t);t.editorContainer&&(Cw.get(t.editorContainer).style.display=e.orgDisplay,e.hidden=Cw.isHidden(t.editorContainer)),e.getElement().style.display="none",Cw.setAttrib(e.id,"aria-hidden","true"),n||bw(e)},Nw=Si.DOM,Ew=function(t,n,e){var r=_h.get(e),o=_h.urls[e]||t.documentBaseUrl.replace(/\/$/,"");if(e=Xt.trim(e),r&&-1===Xt.inArray(n,e)){if(Xt.each(_h.dependencies(e),function(e){Ew(t,n,e)}),t.plugins[e])return;try{var i=new r(t,o,t.$);(t.plugins[e]=i).init&&(i.init(t,o),n.push(e))}catch(iE){kh.pluginInitError(t,e,iE)}}},Sw=function(e){return e.replace(/^\-/,"")},Tw=function(e){return{editorContainer:e,iframeContainer:e}},kw=function(e){var t,n,r=e.getElement();return e.inline?Tw(null):(t=r,n=Nw.create("div"),Nw.insertAfter(n,t),Tw(n))},_w=function(e){var t,n,r,o,i,a,u,s,c,l,f,d=e.settings,m=e.getElement();return e.orgDisplay=m.style.display,S(d.theme)?(l=(o=e).settings,f=o.getElement(),i=l.width||Nw.getStyle(f,"width")||"100%",a=l.height||Nw.getStyle(f,"height")||f.offsetHeight,u=l.min_height||100,(s=/^[0-9\.]+(|px)$/i).test(""+i)&&(i=Math.max(parseInt(i,10),100)),s.test(""+a)&&(a=Math.max(parseInt(a,10),u)),c=o.theme.renderUI({targetNode:f,width:i,height:a,deltaWidth:l.delta_width,deltaHeight:l.delta_height}),l.content_editable||(a=(c.iframeHeight||a)+("number"==typeof a?c.deltaHeight||0:""))=n.length)for(r=0,o=e.length;r=n.length||e[r]!==n[r]){i=r+1;break}if(e.length=e.length||e[r]!==n[r]){i=r+1;break}if(1===i)return t;for(r=0,o=e.length-(i-1);r]*>( | |\\s|\xa0| |)<\\/"+a+">[\r\n]*| [\r\n]*)$"),r=i.replace(u,"")}return"text"===t.format||Ao(ar.fromDom(n))?t.content=r:t.content=Xt.trim(r),t.no_events||e.fire("GetContent",t),t.content},jw=function(e,t){t(e),e.firstChild&&jw(e.firstChild,t),e.next&&jw(e.next,t)},Vw=function(e,t,n){var r=function(e,n,t){var r={},o={},i=[];for(var a in t.firstChild&&jw(t.firstChild,function(t){z(e,function(e){e.name===t.name&&(r[e.name]?r[e.name].nodes.push(t):r[e.name]={filter:e,nodes:[t]})}),z(n,function(e){"string"==typeof t.attr(e.name)&&(o[e.name]?o[e.name].nodes.push(t):o[e.name]={filter:e,nodes:[t]})})}),r)r.hasOwnProperty(a)&&i.push(r[a]);for(var a in o)o.hasOwnProperty(a)&&i.push(o[a]);return i}(e,t,n);z(r,function(t){z(t.filter.callbacks,function(e){e(t.nodes,t.filter.name,{})})})},Hw=function(e){return e instanceof sb},qw=function(e,t){var r;e.dom.setHTML(e.getBody(),t),sh(r=e)&&sc.firstPositionIn(r.getBody()).each(function(e){var t=e.getNode(),n=jo.isTable(t)?sc.firstPositionIn(t).getOr(e):e;r.selection.setRng(n.toRange())})},$w=function(u,s,c){return void 0===c&&(c={}),c.format=c.format?c.format:"html",c.set=!0,c.content=Hw(s)?"":s,Hw(s)||c.no_events||(u.fire("BeforeSetContent",c),s=c.content),_.from(u.getBody()).fold(q(s),function(e){return Hw(s)?function(e,t,n,r){Vw(e.parser.getNodeFilters(),e.parser.getAttributeFilters(),n);var o=al({validate:e.validate},e.schema).serialize(n);return r.content=Ao(ar.fromDom(t))?o:Xt.trim(o),qw(e,r.content),r.no_events||e.fire("SetContent",r),n}(u,e,s,c):(t=u,n=e,o=c,0===(r=s).length||/^\s+$/.test(r)?(a=' ',"TABLE"===n.nodeName?r=""+a+" ":/^(UL|OL)$/.test(n.nodeName)&&(r=""+a+" "),(i=Nl(t))&&t.schema.isValidChild(n.nodeName.toLowerCase(),i.toLowerCase())?(r=a,r=t.dom.createHTML(i,t.settings.forced_root_block_attrs,r)):r||(r=' '),qw(t,r),t.fire("SetContent",o)):("raw"!==o.format&&(r=al({validate:t.validate},t.schema).serialize(t.parser.parse(r,{isRootContent:!0,insert:!0}))),o.content=Ao(ar.fromDom(n))?r:Xt.trim(r),qw(t,o.content),o.no_events||t.fire("SetContent",o)),o.content);var t,n,r,o,i,a})},Ww=Si.DOM,Kw=function(e){return _.from(e).each(function(e){return e.destroy()})},Xw=function(e){if(!e.removed){var t=e._selectionOverrides,n=e.editorUpload,r=e.getBody(),o=e.getElement();r&&e.save({is_removing:!0}),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&o&&Ww.remove(o.nextSibling),Np(e),e.editorManager.remove(e),!e.inline&&r&&(i=e,Ww.setStyle(i.id,"display",i.orgDisplay)),Ep(e),Ww.remove(e.getContainer()),Kw(t),Kw(n),e.destroy()}var i},Yw=function(e,t){var n,r,o,i=e.selection,a=e.dom;e.destroyed||(t||e.removed?(t||(e.editorManager.off("beforeunload",e._beforeUnload),e.theme&&e.theme.destroy&&e.theme.destroy(),Kw(i),Kw(a)),(r=(n=e).formElement)&&(r._mceOldSubmit&&(r.submit=r._mceOldSubmit,r._mceOldSubmit=null),Ww.unbind(r,"submit reset",n.formEventDelegate)),(o=e).contentAreaContainer=o.formElement=o.container=o.editorContainer=null,o.bodyElement=o.contentDocument=o.contentWindow=null,o.iframeElement=o.targetElm=null,o.selection&&(o.selection=o.selection.win=o.selection.dom=o.selection.dom.doc=null),e.destroyed=!0):e.remove())},Gw=Si.DOM,Jw=Xt.extend,Qw=Xt.each,Zw=Xt.resolve,eN=fe.ie,tN=function(e,t,n){var r,o,i,a,u,s,c,l=this,f=l.documentBaseUrl=n.documentBaseURL,d=n.baseURI;r=l,o=e,i=f,a=n.defaultSettings,u=t,c={id:o,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:i,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,render_ui:!0,indentation:"40px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",entity_encoding:"named",url_converter:(s=r).convertURL,url_converter_scope:s,ie7_compat:!0},t=$p(zp,c,a,u),l.settings=t,Bi.language=t.language||"en",Bi.languageLoad=t.language_load,Bi.baseURL=n.baseURL,l.id=e,l.setDirty(!1),l.plugins={},l.documentBaseURI=new zw(t.document_base_url,{base_uri:d}),l.baseURI=d,l.contentCSS=[],l.contentStyles=[],l.shortcuts=new Qp(l),l.loadedCSS={},l.editorCommands=new pp(l),l.suffix=n.suffix,l.editorManager=n,l.inline=t.inline,l.buttons={},l.menuItems={},t.cache_suffix&&(fe.cacheSuffix=t.cache_suffix.replace(/^[\?\&]+/,"")),!1===t.override_viewport&&(fe.overrideViewPort=!1),n.fire("SetupEditor",{editor:l}),l.execCallback("setup",l),l.$=gn.overrideDefaults(function(){return{context:l.inline?l.getBody():l.getDoc(),element:l.getBody()}})};Jw(tN.prototype={render:function(){Bw(this)},focus:function(e){uh(this,e)},hasFocus:function(){return sh(this)},execCallback:function(e){for(var t=[],n=1;n=n.x&&o.x+o.w<=n.w+n.x&&o.y>=n.y&&o.y+o.h<=n.h+n.y)return r[i];return null},intersect:function(e,t){var n,r,o,i;return n=ON(e.x,t.x),r=ON(e.y,t.y),o=DN(e.x+e.w,t.x+t.w),i=DN(e.y+e.h,t.y+t.h),o-n<0||i-r<0?null:IN(n,r,o-n,i-r)},clamp:function(e,t,n){var r,o,i,a,u,s,c,l,f,d;return u=e.x,s=e.y,c=e.x+e.w,l=e.y+e.h,f=t.x+t.w,d=t.y+t.h,r=ON(0,t.x-u),o=ON(0,t.y-s),i=ON(0,c-f),a=ON(0,l-d),u+=r,s+=o,n&&(c+=r,l+=o,u-=i,s-=a),IN(u,s,(c-=i)-u,(l-=a)-s)},create:IN,fromClientRect:function(e){return IN(e.left,e.top,e.width,e.height)}},FN={},MN={add:function(e,t){FN[e.toLowerCase()]=t},has:function(e){return!!FN[e.toLowerCase()]},get:function(e){var t=e.toLowerCase(),n=FN.hasOwnProperty(t)?FN[t]:null;if(null===n)throw new Error("Could not find module for type: "+e);return n},create:function(e,t){var n;if("string"==typeof e?(t=t||{}).type=e:e=(t=e).type,e=e.toLowerCase(),!(n=FN[e]))throw new Error("Could not find control by type: "+e);return(n=new n(t)).type=e,n}},zN=Xt.each,UN=Xt.extend,jN=function(){};jN.extend=_N=function(n){var e,t,r,o=this.prototype,i=function(){var e,t,n;if(!AN&&(this.init&&this.init.apply(this,arguments),t=this.Mixins))for(e=t.length;e--;)(n=t[e]).init&&n.init.apply(this,arguments)},a=function(){return this},u=function(n,r){return function(){var e,t=this._super;return this._super=o[n],e=r.apply(this,arguments),this._super=t,e}};for(t in AN=!0,e=new this,AN=!1,n.Mixins&&(zN(n.Mixins,function(e){for(var t in e)"init"!==t&&(n[t]=e[t])}),o.Mixins&&(n.Mixins=o.Mixins.concat(n.Mixins))),n.Methods&&zN(n.Methods.split(","),function(e){n[e]=a}),n.Properties&&zN(n.Properties.split(","),function(e){var t="_"+e;n[e]=function(e){return e!==undefined?(this[t]=e,this):this[t]}}),n.Statics&&zN(n.Statics,function(e,t){i[t]=e}),n.Defaults&&o.Defaults&&(n.Defaults=UN({},o.Defaults,n.Defaults)),n)"function"==typeof(r=n[t])&&o[t]?e[t]=u(t,r):e[t]=r;return i.prototype=e,(i.constructor=i).extend=_N,i};var VN=Math.min,HN=Math.max,qN=Math.round,$N=function(e,n){var r,o,t,i;if(n=n||'"',null===e)return"null";if("string"==(t=typeof e))return o="\bb\tt\nn\ff\rr\"\"''\\\\",n+e.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=o.indexOf(t))+1?"\\"+o.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e)})+n;if("object"===t){if(e.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(e)){for(r=0,o="[";r