From 2ce767141a2440afef231856b417247b3f4ab506 Mon Sep 17 00:00:00 2001 From: Ella Iseulde Van Dorpe <*@iseulde.com> Date: Tue, 29 Jan 2019 20:19:51 +0000 Subject: [PATCH] TinyMCE: Update to 4.9.2 https://github.com/tinymce/tinymce-dist/compare/4.8.0...4.9.2 Fixes #46094. Built from https://develop.svn.wordpress.org/trunk@44713 git-svn-id: http://core.svn.wordpress.org/trunk@44544 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/charmap/plugin.js | 2502 +- .../js/tinymce/plugins/colorpicker/plugin.js | 218 +- .../tinymce/plugins/directionality/plugin.js | 110 +- .../js/tinymce/plugins/fullscreen/plugin.js | 326 +- wp-includes/js/tinymce/plugins/hr/plugin.js | 60 +- .../js/tinymce/plugins/image/plugin.js | 2337 +- .../js/tinymce/plugins/image/plugin.min.js | 2 +- wp-includes/js/tinymce/plugins/link/plugin.js | 1354 +- .../js/tinymce/plugins/lists/plugin.js | 3181 ++- .../js/tinymce/plugins/lists/plugin.min.js | 2 +- .../js/tinymce/plugins/media/plugin.js | 2180 +- .../js/tinymce/plugins/paste/plugin.js | 3167 +-- .../js/tinymce/plugins/paste/plugin.min.js | 2 +- .../js/tinymce/plugins/tabfocus/plugin.js | 210 +- .../js/tinymce/plugins/textcolor/plugin.js | 652 +- .../tinymce/plugins/textcolor/plugin.min.js | 2 +- .../tinymce/skins/lightgray/fonts/tinymce.svg | 1 + .../js/tinymce/skins/lightgray/skin.min.css | 2 +- wp-includes/js/tinymce/themes/inlite/theme.js | 19504 ++++++++-------- .../js/tinymce/themes/inlite/theme.min.js | 2 +- wp-includes/js/tinymce/themes/modern/theme.js | 19132 ++++++++------- .../js/tinymce/themes/modern/theme.min.js | 2 +- wp-includes/js/tinymce/tinymce.min.js | 4 +- wp-includes/js/tinymce/wp-tinymce.js | 14 +- wp-includes/version.php | 4 +- 25 files changed, 27782 insertions(+), 27188 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/charmap/plugin.js b/wp-includes/js/tinymce/plugins/charmap/plugin.js index 10967338d2..48b26f1c56 100644 --- a/wp-includes/js/tinymce/plugins/charmap/plugin.js +++ b/wp-includes/js/tinymce/plugins/charmap/plugin.js @@ -1,1275 +1,1275 @@ (function () { var charmap = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var fireInsertCustomChar = function (editor, chr) { - return editor.fire('insertCustomChar', { chr: chr }); - }; - var $_ce2ncy9qjjgwebhk = { fireInsertCustomChar: fireInsertCustomChar }; - - var insertChar = function (editor, chr) { - var evtChr = $_ce2ncy9qjjgwebhk.fireInsertCustomChar(editor, chr).chr; - editor.execCommand('mceInsertContent', false, evtChr); - }; - var $_el68bd9pjjgwebhj = { insertChar: insertChar }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var getCharMap = function (editor) { - return editor.settings.charmap; - }; - var getCharMapAppend = function (editor) { - return editor.settings.charmap_append; - }; - var $_5e4nos9tjjgwebhr = { - getCharMap: getCharMap, - getCharMapAppend: getCharMapAppend - }; - - var isArray = global$1.isArray; - var getDefaultCharMap = function () { - return [ - [ - '160', - 'no-break space' - ], - [ - '173', - 'soft hyphen' - ], - [ - '34', - 'quotation mark' - ], - [ - '162', - 'cent sign' - ], - [ - '8364', - 'euro sign' - ], - [ - '163', - 'pound sign' - ], - [ - '165', - 'yen sign' - ], - [ - '169', - 'copyright sign' - ], - [ - '174', - 'registered sign' - ], - [ - '8482', - 'trade mark sign' - ], - [ - '8240', - 'per mille sign' - ], - [ - '181', - 'micro sign' - ], - [ - '183', - 'middle dot' - ], - [ - '8226', - 'bullet' - ], - [ - '8230', - 'three dot leader' - ], - [ - '8242', - 'minutes / feet' - ], - [ - '8243', - 'seconds / inches' - ], - [ - '167', - 'section sign' - ], - [ - '182', - 'paragraph sign' - ], - [ - '223', - 'sharp s / ess-zed' - ], - [ - '8249', - 'single left-pointing angle quotation mark' - ], - [ - '8250', - 'single right-pointing angle quotation mark' - ], - [ - '171', - 'left pointing guillemet' - ], - [ - '187', - 'right pointing guillemet' - ], - [ - '8216', - 'left single quotation mark' - ], - [ - '8217', - 'right single quotation mark' - ], - [ - '8220', - 'left double quotation mark' - ], - [ - '8221', - 'right double quotation mark' - ], - [ - '8218', - 'single low-9 quotation mark' - ], - [ - '8222', - 'double low-9 quotation mark' - ], - [ - '60', - 'less-than sign' - ], - [ - '62', - 'greater-than sign' - ], - [ - '8804', - 'less-than or equal to' - ], - [ - '8805', - 'greater-than or equal to' - ], - [ - '8211', - 'en dash' - ], - [ - '8212', - 'em dash' - ], - [ - '175', - 'macron' - ], - [ - '8254', - 'overline' - ], - [ - '164', - 'currency sign' - ], - [ - '166', - 'broken bar' - ], - [ - '168', - 'diaeresis' - ], - [ - '161', - 'inverted exclamation mark' - ], - [ - '191', - 'turned question mark' - ], - [ - '710', - 'circumflex accent' - ], - [ - '732', - 'small tilde' - ], - [ - '176', - 'degree sign' - ], - [ - '8722', - 'minus sign' - ], - [ - '177', - 'plus-minus sign' - ], - [ - '247', - 'division sign' - ], - [ - '8260', - 'fraction slash' - ], - [ - '215', - 'multiplication sign' - ], - [ - '185', - 'superscript one' - ], - [ - '178', - 'superscript two' - ], - [ - '179', - 'superscript three' - ], - [ - '188', - 'fraction one quarter' - ], - [ - '189', - 'fraction one half' - ], - [ - '190', - 'fraction three quarters' - ], - [ - '402', - 'function / florin' - ], - [ - '8747', - 'integral' - ], - [ - '8721', - 'n-ary sumation' - ], - [ - '8734', - 'infinity' - ], - [ - '8730', - 'square root' - ], - [ - '8764', - 'similar to' - ], - [ - '8773', - 'approximately equal to' - ], - [ - '8776', - 'almost equal to' - ], - [ - '8800', - 'not equal to' - ], - [ - '8801', - 'identical to' - ], - [ - '8712', - 'element of' - ], - [ - '8713', - 'not an element of' - ], - [ - '8715', - 'contains as member' - ], - [ - '8719', - 'n-ary product' - ], - [ - '8743', - 'logical and' - ], - [ - '8744', - 'logical or' - ], - [ - '172', - 'not sign' - ], - [ - '8745', - 'intersection' - ], - [ - '8746', - 'union' - ], - [ - '8706', - 'partial differential' - ], - [ - '8704', - 'for all' - ], - [ - '8707', - 'there exists' - ], - [ - '8709', - 'diameter' - ], - [ - '8711', - 'backward difference' - ], - [ - '8727', - 'asterisk operator' - ], - [ - '8733', - 'proportional to' - ], - [ - '8736', - 'angle' - ], - [ - '180', - 'acute accent' - ], - [ - '184', - 'cedilla' - ], - [ - '170', - 'feminine ordinal indicator' - ], - [ - '186', - 'masculine ordinal indicator' - ], - [ - '8224', - 'dagger' - ], - [ - '8225', - 'double dagger' - ], - [ - '192', - 'A - grave' - ], - [ - '193', - 'A - acute' - ], - [ - '194', - 'A - circumflex' - ], - [ - '195', - 'A - tilde' - ], - [ - '196', - 'A - diaeresis' - ], - [ - '197', - 'A - ring above' - ], - [ - '256', - 'A - macron' - ], - [ - '198', - 'ligature AE' - ], - [ - '199', - 'C - cedilla' - ], - [ - '200', - 'E - grave' - ], - [ - '201', - 'E - acute' - ], - [ - '202', - 'E - circumflex' - ], - [ - '203', - 'E - diaeresis' - ], - [ - '274', - 'E - macron' - ], - [ - '204', - 'I - grave' - ], - [ - '205', - 'I - acute' - ], - [ - '206', - 'I - circumflex' - ], - [ - '207', - 'I - diaeresis' - ], - [ - '298', - 'I - macron' - ], - [ - '208', - 'ETH' - ], - [ - '209', - 'N - tilde' - ], - [ - '210', - 'O - grave' - ], - [ - '211', - 'O - acute' - ], - [ - '212', - 'O - circumflex' - ], - [ - '213', - 'O - tilde' - ], - [ - '214', - 'O - diaeresis' - ], - [ - '216', - 'O - slash' - ], - [ - '332', - 'O - macron' - ], - [ - '338', - 'ligature OE' - ], - [ - '352', - 'S - caron' - ], - [ - '217', - 'U - grave' - ], - [ - '218', - 'U - acute' - ], - [ - '219', - 'U - circumflex' - ], - [ - '220', - 'U - diaeresis' - ], - [ - '362', - 'U - macron' - ], - [ - '221', - 'Y - acute' - ], - [ - '376', - 'Y - diaeresis' - ], - [ - '562', - 'Y - macron' - ], - [ - '222', - 'THORN' - ], - [ - '224', - 'a - grave' - ], - [ - '225', - 'a - acute' - ], - [ - '226', - 'a - circumflex' - ], - [ - '227', - 'a - tilde' - ], - [ - '228', - 'a - diaeresis' - ], - [ - '229', - 'a - ring above' - ], - [ - '257', - 'a - macron' - ], - [ - '230', - 'ligature ae' - ], - [ - '231', - 'c - cedilla' - ], - [ - '232', - 'e - grave' - ], - [ - '233', - 'e - acute' - ], - [ - '234', - 'e - circumflex' - ], - [ - '235', - 'e - diaeresis' - ], - [ - '275', - 'e - macron' - ], - [ - '236', - 'i - grave' - ], - [ - '237', - 'i - acute' - ], - [ - '238', - 'i - circumflex' - ], - [ - '239', - 'i - diaeresis' - ], - [ - '299', - 'i - macron' - ], - [ - '240', - 'eth' - ], - [ - '241', - 'n - tilde' - ], - [ - '242', - 'o - grave' - ], - [ - '243', - 'o - acute' - ], - [ - '244', - 'o - circumflex' - ], - [ - '245', - 'o - tilde' - ], - [ - '246', - 'o - diaeresis' - ], - [ - '248', - 'o slash' - ], - [ - '333', - 'o macron' - ], - [ - '339', - 'ligature oe' - ], - [ - '353', - 's - caron' - ], - [ - '249', - 'u - grave' - ], - [ - '250', - 'u - acute' - ], - [ - '251', - 'u - circumflex' - ], - [ - '252', - 'u - diaeresis' - ], - [ - '363', - 'u - macron' - ], - [ - '253', - 'y - acute' - ], - [ - '254', - 'thorn' - ], - [ - '255', - 'y - diaeresis' - ], - [ - '563', - 'y - macron' - ], - [ - '913', - 'Alpha' - ], - [ - '914', - 'Beta' - ], - [ - '915', - 'Gamma' - ], - [ - '916', - 'Delta' - ], - [ - '917', - 'Epsilon' - ], - [ - '918', - 'Zeta' - ], - [ - '919', - 'Eta' - ], - [ - '920', - 'Theta' - ], - [ - '921', - 'Iota' - ], - [ - '922', - 'Kappa' - ], - [ - '923', - 'Lambda' - ], - [ - '924', - 'Mu' - ], - [ - '925', - 'Nu' - ], - [ - '926', - 'Xi' - ], - [ - '927', - 'Omicron' - ], - [ - '928', - 'Pi' - ], - [ - '929', - 'Rho' - ], - [ - '931', - 'Sigma' - ], - [ - '932', - 'Tau' - ], - [ - '933', - 'Upsilon' - ], - [ - '934', - 'Phi' - ], - [ - '935', - 'Chi' - ], - [ - '936', - 'Psi' - ], - [ - '937', - 'Omega' - ], - [ - '945', - 'alpha' - ], - [ - '946', - 'beta' - ], - [ - '947', - 'gamma' - ], - [ - '948', - 'delta' - ], - [ - '949', - 'epsilon' - ], - [ - '950', - 'zeta' - ], - [ - '951', - 'eta' - ], - [ - '952', - 'theta' - ], - [ - '953', - 'iota' - ], - [ - '954', - 'kappa' - ], - [ - '955', - 'lambda' - ], - [ - '956', - 'mu' - ], - [ - '957', - 'nu' - ], - [ - '958', - 'xi' - ], - [ - '959', - 'omicron' - ], - [ - '960', - 'pi' - ], - [ - '961', - 'rho' - ], - [ - '962', - 'final sigma' - ], - [ - '963', - 'sigma' - ], - [ - '964', - 'tau' - ], - [ - '965', - 'upsilon' - ], - [ - '966', - 'phi' - ], - [ - '967', - 'chi' - ], - [ - '968', - 'psi' - ], - [ - '969', - 'omega' - ], - [ - '8501', - 'alef symbol' - ], - [ - '982', - 'pi symbol' - ], - [ - '8476', - 'real part symbol' - ], - [ - '978', - 'upsilon - hook symbol' - ], - [ - '8472', - 'Weierstrass p' - ], - [ - '8465', - 'imaginary part' - ], - [ - '8592', - 'leftwards arrow' - ], - [ - '8593', - 'upwards arrow' - ], - [ - '8594', - 'rightwards arrow' - ], - [ - '8595', - 'downwards arrow' - ], - [ - '8596', - 'left right arrow' - ], - [ - '8629', - 'carriage return' - ], - [ - '8656', - 'leftwards double arrow' - ], - [ - '8657', - 'upwards double arrow' - ], - [ - '8658', - 'rightwards double arrow' - ], - [ - '8659', - 'downwards double arrow' - ], - [ - '8660', - 'left right double arrow' - ], - [ - '8756', - 'therefore' - ], - [ - '8834', - 'subset of' - ], - [ - '8835', - 'superset of' - ], - [ - '8836', - 'not a subset of' - ], - [ - '8838', - 'subset of or equal to' - ], - [ - '8839', - 'superset of or equal to' - ], - [ - '8853', - 'circled plus' - ], - [ - '8855', - 'circled times' - ], - [ - '8869', - 'perpendicular' - ], - [ - '8901', - 'dot operator' - ], - [ - '8968', - 'left ceiling' - ], - [ - '8969', - 'right ceiling' - ], - [ - '8970', - 'left floor' - ], - [ - '8971', - 'right floor' - ], - [ - '9001', - 'left-pointing angle bracket' - ], - [ - '9002', - 'right-pointing angle bracket' - ], - [ - '9674', - 'lozenge' - ], - [ - '9824', - 'black spade suit' - ], - [ - '9827', - 'black club suit' - ], - [ - '9829', - 'black heart suit' - ], - [ - '9830', - 'black diamond suit' - ], - [ - '8194', - 'en space' - ], - [ - '8195', - 'em space' - ], - [ - '8201', - 'thin space' - ], - [ - '8204', - 'zero width non-joiner' - ], - [ - '8205', - 'zero width joiner' - ], - [ - '8206', - 'left-to-right mark' - ], - [ - '8207', - 'right-to-left mark' - ] - ]; - }; - var charmapFilter = function (charmap) { - return global$1.grep(charmap, function (item) { - return isArray(item) && item.length === 2; - }); - }; - var getCharsFromSetting = function (settingValue) { - if (isArray(settingValue)) { - return [].concat(charmapFilter(settingValue)); - } - if (typeof settingValue === 'function') { - return settingValue(); - } - return []; - }; - var extendCharMap = function (editor, charmap) { - var userCharMap = $_5e4nos9tjjgwebhr.getCharMap(editor); - if (userCharMap) { - charmap = getCharsFromSetting(userCharMap); - } - var userCharMapAppend = $_5e4nos9tjjgwebhr.getCharMapAppend(editor); - if (userCharMapAppend) { - return [].concat(charmap).concat(getCharsFromSetting(userCharMapAppend)); - } - return charmap; - }; - var getCharMap$1 = function (editor) { - return extendCharMap(editor, getDefaultCharMap()); - }; - var $_dc8shd9rjjgwebhl = { getCharMap: getCharMap$1 }; - - var get = function (editor) { - var getCharMap = function () { - return $_dc8shd9rjjgwebhl.getCharMap(editor); + var fireInsertCustomChar = function (editor, chr) { + return editor.fire('insertCustomChar', { chr: chr }); }; - var insertChar = function (chr) { - $_el68bd9pjjgwebhj.insertChar(editor, chr); + var Events = { fireInsertCustomChar: fireInsertCustomChar }; + + var insertChar = function (editor, chr) { + var evtChr = Events.fireInsertCustomChar(editor, chr).chr; + editor.execCommand('mceInsertContent', false, evtChr); }; - return { + var Actions = { insertChar: insertChar }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var getCharMap = function (editor) { + return editor.settings.charmap; + }; + var getCharMapAppend = function (editor) { + return editor.settings.charmap_append; + }; + var Settings = { getCharMap: getCharMap, - insertChar: insertChar + getCharMapAppend: getCharMapAppend }; - }; - var $_gbufu29ojjgwebhf = { get: get }; - var getHtml = function (charmap) { - var gridHtml, x, y; - var width = Math.min(charmap.length, 25); - var height = Math.ceil(charmap.length / width); - gridHtml = ''; - for (y = 0; y < height; y++) { - gridHtml += ''; - for (x = 0; x < width; x++) { - var index = y * width + x; - if (index < charmap.length) { - var chr = charmap[index]; - var charCode = parseInt(chr[0], 10); - var chrText = chr ? String.fromCharCode(charCode) : ' '; - gridHtml += ''; - } else { - gridHtml += ''; + return gridHtml; + }; + var GridHtml = { getHtml: getHtml }; - var getParentTd = function (elm) { - while (elm) { - if (elm.nodeName === 'TD') { - return elm; + var getParentTd = function (elm) { + while (elm) { + if (elm.nodeName === 'TD') { + return elm; + } + elm = elm.parentNode; } - elm = elm.parentNode; - } - }; - var open = function (editor) { - var win; - var charMapPanel = { - type: 'container', - html: $_6avwgq9wjjgwebi2.getHtml($_dc8shd9rjjgwebhl.getCharMap(editor)), - onclick: function (e) { - var target = e.target; - if (/^(TD|DIV)$/.test(target.nodeName)) { - var charDiv = getParentTd(target).firstChild; - if (charDiv && charDiv.hasAttribute('data-chr')) { - var charCodeString = charDiv.getAttribute('data-chr'); - var charCode = parseInt(charCodeString, 10); - if (!isNaN(charCode)) { - $_el68bd9pjjgwebhj.insertChar(editor, String.fromCharCode(charCode)); + }; + var open = function (editor) { + var win; + var charMapPanel = { + type: 'container', + html: GridHtml.getHtml(CharMap.getCharMap(editor)), + onclick: function (e) { + var target = e.target; + if (/^(TD|DIV)$/.test(target.nodeName)) { + var charDiv = getParentTd(target).firstChild; + if (charDiv && charDiv.hasAttribute('data-chr')) { + var charCodeString = charDiv.getAttribute('data-chr'); + var charCode = parseInt(charCodeString, 10); + if (!isNaN(charCode)) { + Actions.insertChar(editor, String.fromCharCode(charCode)); + } + if (!e.ctrlKey) { + win.close(); + } } - if (!e.ctrlKey) { + } + }, + onmouseover: function (e) { + var td = getParentTd(e.target); + if (td && td.firstChild) { + win.find('#preview').text(td.firstChild.firstChild.data); + win.find('#previewTitle').text(td.title); + } else { + win.find('#preview').text(' '); + win.find('#previewTitle').text(' '); + } + } + }; + win = editor.windowManager.open({ + title: 'Special character', + spacing: 10, + padding: 10, + items: [ + charMapPanel, + { + type: 'container', + layout: 'flex', + direction: 'column', + align: 'center', + spacing: 5, + minWidth: 160, + minHeight: 160, + items: [ + { + type: 'label', + name: 'preview', + text: ' ', + style: 'font-size: 40px; text-align: center', + border: 1, + minWidth: 140, + minHeight: 80 + }, + { + type: 'spacer', + minHeight: 20 + }, + { + type: 'label', + name: 'previewTitle', + text: ' ', + style: 'white-space: pre-wrap;', + border: 1, + minWidth: 140 + } + ] + } + ], + buttons: [{ + text: 'Close', + onclick: function () { win.close(); } - } - } - }, - onmouseover: function (e) { - var td = getParentTd(e.target); - if (td && td.firstChild) { - win.find('#preview').text(td.firstChild.firstChild.data); - win.find('#previewTitle').text(td.title); - } else { - win.find('#preview').text(' '); - win.find('#previewTitle').text(' '); - } - } + }] + }); }; - win = editor.windowManager.open({ - title: 'Special character', - spacing: 10, - padding: 10, - items: [ - charMapPanel, - { - type: 'container', - layout: 'flex', - direction: 'column', - align: 'center', - spacing: 5, - minWidth: 160, - minHeight: 160, - items: [ - { - type: 'label', - name: 'preview', - text: ' ', - style: 'font-size: 40px; text-align: center', - border: 1, - minWidth: 140, - minHeight: 80 - }, - { - type: 'spacer', - minHeight: 20 - }, - { - type: 'label', - name: 'previewTitle', - text: ' ', - style: 'white-space: pre-wrap;', - border: 1, - minWidth: 140 - } - ] - } - ], - buttons: [{ - text: 'Close', - onclick: function () { - win.close(); - } - }] - }); - }; - var $_3eaa3c9vjjgwebht = { open: open }; + var Dialog = { open: open }; - var register = function (editor) { - editor.addCommand('mceShowCharmap', function () { - $_3eaa3c9vjjgwebht.open(editor); - }); - }; - var $_b5cdu19ujjgwebhs = { register: register }; + var register = function (editor) { + editor.addCommand('mceShowCharmap', function () { + Dialog.open(editor); + }); + }; + var Commands = { register: register }; - var register$1 = function (editor) { - editor.addButton('charmap', { - icon: 'charmap', - tooltip: 'Special character', - cmd: 'mceShowCharmap' - }); - editor.addMenuItem('charmap', { - icon: 'charmap', - text: 'Special character', - cmd: 'mceShowCharmap', - context: 'insert' - }); - }; - var $_19iu2m9xjjgwebi3 = { register: register$1 }; + var register$1 = function (editor) { + editor.addButton('charmap', { + icon: 'charmap', + tooltip: 'Special character', + cmd: 'mceShowCharmap' + }); + editor.addMenuItem('charmap', { + icon: 'charmap', + text: 'Special character', + cmd: 'mceShowCharmap', + context: 'insert' + }); + }; + var Buttons = { register: register$1 }; - global.add('charmap', function (editor) { - $_b5cdu19ujjgwebhs.register(editor); - $_19iu2m9xjjgwebi3.register(editor); - return $_gbufu29ojjgwebhf.get(editor); - }); - function Plugin () { - } + global.add('charmap', function (editor) { + Commands.register(editor); + Buttons.register(editor); + return Api.get(editor); + }); + function Plugin () { + } - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/colorpicker/plugin.js b/wp-includes/js/tinymce/plugins/colorpicker/plugin.js index 12ebc25f85..04872b3c7a 100644 --- a/wp-includes/js/tinymce/plugins/colorpicker/plugin.js +++ b/wp-includes/js/tinymce/plugins/colorpicker/plugin.js @@ -1,126 +1,126 @@ (function () { var colorpicker = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var global$1 = tinymce.util.Tools.resolve('tinymce.util.Color'); + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Color'); - var showPreview = function (win, hexColor) { - win.find('#preview')[0].getEl().style.background = hexColor; - }; - var setColor = function (win, value) { - var color = global$1(value), rgb = color.toRgb(); - win.fromJSON({ - r: rgb.r, - g: rgb.g, - b: rgb.b, - hex: color.toHex().substr(1) - }); - showPreview(win, color.toHex()); - }; - var open = function (editor, callback, value) { - var win = editor.windowManager.open({ - title: 'Color', - items: { - type: 'container', - layout: 'flex', - direction: 'row', - align: 'stretch', - padding: 5, - spacing: 10, - items: [ - { - type: 'colorpicker', - value: value, - onchange: function () { - var rgb = this.rgb(); - if (win) { - win.find('#r').value(rgb.r); - win.find('#g').value(rgb.g); - win.find('#b').value(rgb.b); - win.find('#hex').value(this.value().substr(1)); - showPreview(win, this.value()); - } - } - }, - { - type: 'form', - padding: 0, - labelGap: 5, - defaults: { - type: 'textbox', - size: 7, - value: '0', - flex: 1, - spellcheck: false, + var showPreview = function (win, hexColor) { + win.find('#preview')[0].getEl().style.background = hexColor; + }; + var setColor = function (win, value) { + var color = global$1(value), rgb = color.toRgb(); + win.fromJSON({ + r: rgb.r, + g: rgb.g, + b: rgb.b, + hex: color.toHex().substr(1) + }); + showPreview(win, color.toHex()); + }; + var open = function (editor, callback, value) { + var win = editor.windowManager.open({ + title: 'Color', + items: { + type: 'container', + layout: 'flex', + direction: 'row', + align: 'stretch', + padding: 5, + spacing: 10, + items: [ + { + type: 'colorpicker', + value: value, onchange: function () { - var colorPickerCtrl = win.find('colorpicker')[0]; - var name, value; - name = this.name(); - value = this.value(); - if (name === 'hex') { - value = '#' + value; - setColor(win, value); - colorPickerCtrl.value(value); - return; + var rgb = this.rgb(); + if (win) { + win.find('#r').value(rgb.r); + win.find('#g').value(rgb.g); + win.find('#b').value(rgb.b); + win.find('#hex').value(this.value().substr(1)); + showPreview(win, this.value()); } - value = { - r: win.find('#r').value(), - g: win.find('#g').value(), - b: win.find('#b').value() - }; - colorPickerCtrl.value(value); - setColor(win, value); } }, - items: [ - { - name: 'r', - label: 'R', - autofocus: 1 + { + type: 'form', + padding: 0, + labelGap: 5, + defaults: { + type: 'textbox', + size: 7, + value: '0', + flex: 1, + spellcheck: false, + onchange: function () { + var colorPickerCtrl = win.find('colorpicker')[0]; + var name, value; + name = this.name(); + value = this.value(); + if (name === 'hex') { + value = '#' + value; + setColor(win, value); + colorPickerCtrl.value(value); + return; + } + value = { + r: win.find('#r').value(), + g: win.find('#g').value(), + b: win.find('#b').value() + }; + colorPickerCtrl.value(value); + setColor(win, value); + } }, - { - name: 'g', - label: 'G' - }, - { - name: 'b', - label: 'B' - }, - { - name: 'hex', - label: '#', - value: '000000' - }, - { - name: 'preview', - type: 'container', - border: 1 - } - ] - } - ] - }, - onSubmit: function () { - callback('#' + win.toJSON().hex); + items: [ + { + name: 'r', + label: 'R', + autofocus: 1 + }, + { + name: 'g', + label: 'G' + }, + { + name: 'b', + label: 'B' + }, + { + name: 'hex', + label: '#', + value: '000000' + }, + { + name: 'preview', + type: 'container', + border: 1 + } + ] + } + ] + }, + onSubmit: function () { + callback('#' + win.toJSON().hex); + } + }); + setColor(win, value); + }; + var Dialog = { open: open }; + + global.add('colorpicker', function (editor) { + if (!editor.settings.color_picker_callback) { + editor.settings.color_picker_callback = function (callback, value) { + Dialog.open(editor, callback, value); + }; } }); - setColor(win, value); - }; - var $_2gqaphanjjgwebmu = { open: open }; - - global.add('colorpicker', function (editor) { - if (!editor.settings.color_picker_callback) { - editor.settings.color_picker_callback = function (callback, value) { - $_2gqaphanjjgwebmu.open(editor, callback, value); - }; + function Plugin () { } - }); - function Plugin () { - } - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/directionality/plugin.js b/wp-includes/js/tinymce/plugins/directionality/plugin.js index 0c588e4d53..4b8669be27 100644 --- a/wp-includes/js/tinymce/plugins/directionality/plugin.js +++ b/wp-includes/js/tinymce/plugins/directionality/plugin.js @@ -1,66 +1,66 @@ (function () { var directionality = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - var setDir = function (editor, dir) { - var dom = editor.dom; - var curDir; - var blocks = editor.selection.getSelectedBlocks(); - if (blocks.length) { - curDir = dom.getAttrib(blocks[0], 'dir'); - global$1.each(blocks, function (block) { - if (!dom.getParent(block.parentNode, '*[dir="' + dir + '"]', dom.getRoot())) { - dom.setAttrib(block, 'dir', curDir !== dir ? dir : null); - } + var setDir = function (editor, dir) { + var dom = editor.dom; + var curDir; + var blocks = editor.selection.getSelectedBlocks(); + if (blocks.length) { + curDir = dom.getAttrib(blocks[0], 'dir'); + global$1.each(blocks, function (block) { + if (!dom.getParent(block.parentNode, '*[dir="' + dir + '"]', dom.getRoot())) { + dom.setAttrib(block, 'dir', curDir !== dir ? dir : null); + } + }); + editor.nodeChanged(); + } + }; + var Direction = { setDir: setDir }; + + var register = function (editor) { + editor.addCommand('mceDirectionLTR', function () { + Direction.setDir(editor, 'ltr'); }); - editor.nodeChanged(); + editor.addCommand('mceDirectionRTL', function () { + Direction.setDir(editor, 'rtl'); + }); + }; + var Commands = { register: register }; + + var generateSelector = function (dir) { + var selector = []; + global$1.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function (name) { + selector.push(name + '[dir=' + dir + ']'); + }); + return selector.join(','); + }; + var register$1 = function (editor) { + editor.addButton('ltr', { + title: 'Left to right', + cmd: 'mceDirectionLTR', + stateSelector: generateSelector('ltr') + }); + editor.addButton('rtl', { + title: 'Right to left', + cmd: 'mceDirectionRTL', + stateSelector: generateSelector('rtl') + }); + }; + var Buttons = { register: register$1 }; + + global.add('directionality', function (editor) { + Commands.register(editor); + Buttons.register(editor); + }); + function Plugin () { } - }; - var $_fd54yfb4jjgwebo5 = { setDir: setDir }; - var register = function (editor) { - editor.addCommand('mceDirectionLTR', function () { - $_fd54yfb4jjgwebo5.setDir(editor, 'ltr'); - }); - editor.addCommand('mceDirectionRTL', function () { - $_fd54yfb4jjgwebo5.setDir(editor, 'rtl'); - }); - }; - var $_cpb3fob3jjgwebo4 = { register: register }; - - var generateSelector = function (dir) { - var selector = []; - global$1.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function (name) { - selector.push(name + '[dir=' + dir + ']'); - }); - return selector.join(','); - }; - var register$1 = function (editor) { - editor.addButton('ltr', { - title: 'Left to right', - cmd: 'mceDirectionLTR', - stateSelector: generateSelector('ltr') - }); - editor.addButton('rtl', { - title: 'Right to left', - cmd: 'mceDirectionRTL', - stateSelector: generateSelector('rtl') - }); - }; - var $_8ch9fzb6jjgwebo7 = { register: register$1 }; - - global.add('directionality', function (editor) { - $_cpb3fob3jjgwebo4.register(editor); - $_8ch9fzb6jjgwebo7.register(editor); - }); - function Plugin () { - } - - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/fullscreen/plugin.js b/wp-includes/js/tinymce/plugins/fullscreen/plugin.js index 83da16b5e8..ee21331cb3 100644 --- a/wp-includes/js/tinymce/plugins/fullscreen/plugin.js +++ b/wp-includes/js/tinymce/plugins/fullscreen/plugin.js @@ -1,177 +1,177 @@ (function () { var fullscreen = (function () { - 'use strict'; + 'use strict'; - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; - }; - var set = function (v) { - value = v; - }; - var clone = function () { - return Cell(get()); - }; - return { - get: get, - set: set, - clone: clone - }; - }; - - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - - var get = function (fullscreenState) { - return { - isFullscreen: function () { - return fullscreenState.get() !== null; - } - }; - }; - var $_6qfcwucejjgwebu0 = { get: get }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var fireFullscreenStateChanged = function (editor, state) { - editor.fire('FullscreenStateChanged', { state: state }); - }; - var $_en5ltwcijjgwebu6 = { fireFullscreenStateChanged: fireFullscreenStateChanged }; - - var DOM = global$1.DOM; - var getWindowSize = function () { - var w; - var h; - var win = window; - var doc = document; - var body = doc.body; - if (body.offsetWidth) { - w = body.offsetWidth; - h = body.offsetHeight; - } - if (win.innerWidth && win.innerHeight) { - w = win.innerWidth; - h = win.innerHeight; - } - return { - w: w, - h: h - }; - }; - var getScrollPos = function () { - var vp = DOM.getViewPort(); - return { - x: vp.x, - y: vp.y - }; - }; - var setScrollPos = function (pos) { - window.scrollTo(pos.x, pos.y); - }; - var toggleFullscreen = function (editor, fullscreenState) { - var body = document.body; - var documentElement = document.documentElement; - var editorContainerStyle; - var editorContainer, iframe, iframeStyle; - var fullscreenInfo = fullscreenState.get(); - var resize = function () { - DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); - }; - var removeResize = function () { - DOM.unbind(window, 'resize', resize); - }; - editorContainer = editor.getContainer(); - editorContainerStyle = editorContainer.style; - iframe = editor.getContentAreaContainer().firstChild; - iframeStyle = iframe.style; - if (!fullscreenInfo) { - var newFullScreenInfo = { - scrollPos: getScrollPos(), - containerWidth: editorContainerStyle.width, - containerHeight: editorContainerStyle.height, - iframeWidth: iframeStyle.width, - iframeHeight: iframeStyle.height, - resizeHandler: resize, - removeHandler: removeResize + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; }; - iframeStyle.width = iframeStyle.height = '100%'; - editorContainerStyle.width = editorContainerStyle.height = ''; - DOM.addClass(body, 'mce-fullscreen'); - DOM.addClass(documentElement, 'mce-fullscreen'); - DOM.addClass(editorContainer, 'mce-fullscreen'); - DOM.bind(window, 'resize', resize); - editor.on('remove', removeResize); - resize(); - fullscreenState.set(newFullScreenInfo); - $_en5ltwcijjgwebu6.fireFullscreenStateChanged(editor, true); - } else { - iframeStyle.width = fullscreenInfo.iframeWidth; - iframeStyle.height = fullscreenInfo.iframeHeight; - if (fullscreenInfo.containerWidth) { - editorContainerStyle.width = fullscreenInfo.containerWidth; - } - if (fullscreenInfo.containerHeight) { - editorContainerStyle.height = fullscreenInfo.containerHeight; - } - DOM.removeClass(body, 'mce-fullscreen'); - DOM.removeClass(documentElement, 'mce-fullscreen'); - DOM.removeClass(editorContainer, 'mce-fullscreen'); - setScrollPos(fullscreenInfo.scrollPos); - DOM.unbind(window, 'resize', fullscreenInfo.resizeHandler); - editor.off('remove', fullscreenInfo.removeHandler); - fullscreenState.set(null); - $_en5ltwcijjgwebu6.fireFullscreenStateChanged(editor, false); - } - }; - var $_dvg07kcgjjgwebu3 = { toggleFullscreen: toggleFullscreen }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; + }; - var register = function (editor, fullscreenState) { - editor.addCommand('mceFullScreen', function () { - $_dvg07kcgjjgwebu3.toggleFullscreen(editor, fullscreenState); - }); - }; - var $_bebdcrcfjjgwebu1 = { register: register }; + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var postRender = function (editor) { - return function (e) { - var ctrl = e.control; - editor.on('FullscreenStateChanged', function (e) { - ctrl.active(e.state); + var get = function (fullscreenState) { + return { + isFullscreen: function () { + return fullscreenState.get() !== null; + } + }; + }; + var Api = { get: get }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var fireFullscreenStateChanged = function (editor, state) { + editor.fire('FullscreenStateChanged', { state: state }); + }; + var Events = { fireFullscreenStateChanged: fireFullscreenStateChanged }; + + var DOM = global$1.DOM; + var getWindowSize = function () { + var w; + var h; + var win = window; + var doc = document; + var body = doc.body; + if (body.offsetWidth) { + w = body.offsetWidth; + h = body.offsetHeight; + } + if (win.innerWidth && win.innerHeight) { + w = win.innerWidth; + h = win.innerHeight; + } + return { + w: w, + h: h + }; + }; + var getScrollPos = function () { + var vp = DOM.getViewPort(); + return { + x: vp.x, + y: vp.y + }; + }; + var setScrollPos = function (pos) { + window.scrollTo(pos.x, pos.y); + }; + var toggleFullscreen = function (editor, fullscreenState) { + var body = document.body; + var documentElement = document.documentElement; + var editorContainerStyle; + var editorContainer, iframe, iframeStyle; + var fullscreenInfo = fullscreenState.get(); + var resize = function () { + DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); + }; + var removeResize = function () { + DOM.unbind(window, 'resize', resize); + }; + editorContainer = editor.getContainer(); + editorContainerStyle = editorContainer.style; + iframe = editor.getContentAreaContainer().firstChild; + iframeStyle = iframe.style; + if (!fullscreenInfo) { + var newFullScreenInfo = { + scrollPos: getScrollPos(), + containerWidth: editorContainerStyle.width, + containerHeight: editorContainerStyle.height, + iframeWidth: iframeStyle.width, + iframeHeight: iframeStyle.height, + resizeHandler: resize, + removeHandler: removeResize + }; + iframeStyle.width = iframeStyle.height = '100%'; + editorContainerStyle.width = editorContainerStyle.height = ''; + DOM.addClass(body, 'mce-fullscreen'); + DOM.addClass(documentElement, 'mce-fullscreen'); + DOM.addClass(editorContainer, 'mce-fullscreen'); + DOM.bind(window, 'resize', resize); + editor.on('remove', removeResize); + resize(); + fullscreenState.set(newFullScreenInfo); + Events.fireFullscreenStateChanged(editor, true); + } else { + iframeStyle.width = fullscreenInfo.iframeWidth; + iframeStyle.height = fullscreenInfo.iframeHeight; + if (fullscreenInfo.containerWidth) { + editorContainerStyle.width = fullscreenInfo.containerWidth; + } + if (fullscreenInfo.containerHeight) { + editorContainerStyle.height = fullscreenInfo.containerHeight; + } + DOM.removeClass(body, 'mce-fullscreen'); + DOM.removeClass(documentElement, 'mce-fullscreen'); + DOM.removeClass(editorContainer, 'mce-fullscreen'); + setScrollPos(fullscreenInfo.scrollPos); + DOM.unbind(window, 'resize', fullscreenInfo.resizeHandler); + editor.off('remove', fullscreenInfo.removeHandler); + fullscreenState.set(null); + Events.fireFullscreenStateChanged(editor, false); + } + }; + var Actions = { toggleFullscreen: toggleFullscreen }; + + var register = function (editor, fullscreenState) { + editor.addCommand('mceFullScreen', function () { + Actions.toggleFullscreen(editor, fullscreenState); }); }; - }; - var register$1 = function (editor) { - editor.addMenuItem('fullscreen', { - text: 'Fullscreen', - shortcut: 'Ctrl+Shift+F', - selectable: true, - cmd: 'mceFullScreen', - onPostRender: postRender(editor), - context: 'view' - }); - editor.addButton('fullscreen', { - active: false, - tooltip: 'Fullscreen', - cmd: 'mceFullScreen', - onPostRender: postRender(editor) - }); - }; - var $_tne4sckjjgwebuo = { register: register$1 }; + var Commands = { register: register }; - global.add('fullscreen', function (editor) { - var fullscreenState = Cell(null); - if (editor.settings.inline) { - return $_6qfcwucejjgwebu0.get(fullscreenState); + var postRender = function (editor) { + return function (e) { + var ctrl = e.control; + editor.on('FullscreenStateChanged', function (e) { + ctrl.active(e.state); + }); + }; + }; + var register$1 = function (editor) { + editor.addMenuItem('fullscreen', { + text: 'Fullscreen', + shortcut: 'Ctrl+Shift+F', + selectable: true, + cmd: 'mceFullScreen', + onPostRender: postRender(editor), + context: 'view' + }); + editor.addButton('fullscreen', { + active: false, + tooltip: 'Fullscreen', + cmd: 'mceFullScreen', + onPostRender: postRender(editor) + }); + }; + var Buttons = { register: register$1 }; + + global.add('fullscreen', function (editor) { + var fullscreenState = Cell(null); + if (editor.settings.inline) { + return Api.get(fullscreenState); + } + Commands.register(editor, fullscreenState); + Buttons.register(editor); + editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen'); + return Api.get(fullscreenState); + }); + function Plugin () { } - $_bebdcrcfjjgwebu1.register(editor, fullscreenState); - $_tne4sckjjgwebuo.register(editor); - editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen'); - return $_6qfcwucejjgwebu0.get(fullscreenState); - }); - function Plugin () { - } - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/hr/plugin.js b/wp-includes/js/tinymce/plugins/hr/plugin.js index 5e47bda6bd..56f9d08ca3 100644 --- a/wp-includes/js/tinymce/plugins/hr/plugin.js +++ b/wp-includes/js/tinymce/plugins/hr/plugin.js @@ -1,39 +1,39 @@ (function () { var hr = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var register = function (editor) { - editor.addCommand('InsertHorizontalRule', function () { - editor.execCommand('mceInsertContent', false, '
'); + var register = function (editor) { + editor.addCommand('InsertHorizontalRule', function () { + editor.execCommand('mceInsertContent', false, '
'); + }); + }; + var Commands = { register: register }; + + var register$1 = function (editor) { + editor.addButton('hr', { + icon: 'hr', + tooltip: 'Horizontal line', + cmd: 'InsertHorizontalRule' + }); + editor.addMenuItem('hr', { + icon: 'hr', + text: 'Horizontal line', + cmd: 'InsertHorizontalRule', + context: 'insert' + }); + }; + var Buttons = { register: register$1 }; + + global.add('hr', function (editor) { + Commands.register(editor); + Buttons.register(editor); }); - }; - var $_cqh592cnjjgwebvk = { register: register }; + function Plugin () { + } - var register$1 = function (editor) { - editor.addButton('hr', { - icon: 'hr', - tooltip: 'Horizontal line', - cmd: 'InsertHorizontalRule' - }); - editor.addMenuItem('hr', { - icon: 'hr', - text: 'Horizontal line', - cmd: 'InsertHorizontalRule', - context: 'insert' - }); - }; - var $_13g834cojjgwebvl = { register: register$1 }; - - global.add('hr', function (editor) { - $_cqh592cnjjgwebvk.register(editor); - $_13g834cojjgwebvl.register(editor); - }); - function Plugin () { - } - - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/image/plugin.js b/wp-includes/js/tinymce/plugins/image/plugin.js index 7a72ed0d80..ba68a9bd94 100644 --- a/wp-includes/js/tinymce/plugins/image/plugin.js +++ b/wp-includes/js/tinymce/plugins/image/plugin.js @@ -1,1211 +1,1204 @@ (function () { var image = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var hasDimensions = function (editor) { - return editor.settings.image_dimensions === false ? false : true; - }; - var hasAdvTab = function (editor) { - return editor.settings.image_advtab === true ? true : false; - }; - var getPrependUrl = function (editor) { - return editor.getParam('image_prepend_url', ''); - }; - var getClassList = function (editor) { - return editor.getParam('image_class_list'); - }; - var hasDescription = function (editor) { - return editor.settings.image_description === false ? false : true; - }; - var hasImageTitle = function (editor) { - return editor.settings.image_title === true ? true : false; - }; - var hasImageCaption = function (editor) { - return editor.settings.image_caption === true ? true : false; - }; - var getImageList = function (editor) { - return editor.getParam('image_list', false); - }; - var hasUploadUrl = function (editor) { - return editor.getParam('images_upload_url', false); - }; - var hasUploadHandler = function (editor) { - return editor.getParam('images_upload_handler', false); - }; - var getUploadUrl = function (editor) { - return editor.getParam('images_upload_url'); - }; - var getUploadHandler = function (editor) { - return editor.getParam('images_upload_handler'); - }; - var getUploadBasePath = function (editor) { - return editor.getParam('images_upload_base_path'); - }; - var getUploadCredentials = function (editor) { - return editor.getParam('images_upload_credentials'); - }; - var $_1dn8wtctjjgwebvz = { - hasDimensions: hasDimensions, - hasAdvTab: hasAdvTab, - getPrependUrl: getPrependUrl, - getClassList: getClassList, - hasDescription: hasDescription, - hasImageTitle: hasImageTitle, - hasImageCaption: hasImageCaption, - getImageList: getImageList, - hasUploadUrl: hasUploadUrl, - hasUploadHandler: hasUploadHandler, - getUploadUrl: getUploadUrl, - getUploadHandler: getUploadHandler, - getUploadBasePath: getUploadBasePath, - getUploadCredentials: getUploadCredentials - }; - - var Global = typeof window !== 'undefined' ? 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 name + ' not available on this browser'; - return actual; - }; - var $_oab1bcwjjgwebwl = { getOrDie: getOrDie }; - - function FileReader () { - var f = $_oab1bcwjjgwebwl.getOrDie('FileReader'); - return new f(); - } - - var global$1 = tinymce.util.Tools.resolve('tinymce.util.Promise'); - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var global$3 = tinymce.util.Tools.resolve('tinymce.util.XHR'); - - var parseIntAndGetMax = function (val1, val2) { - return Math.max(parseInt(val1, 10), parseInt(val2, 10)); - }; - var getImageSize = function (url, callback) { - var img = document.createElement('img'); - function done(width, height) { - if (img.parentNode) { - img.parentNode.removeChild(img); - } - callback({ - width: width, - height: height - }); - } - img.onload = function () { - var width = parseIntAndGetMax(img.width, img.clientWidth); - var height = parseIntAndGetMax(img.height, img.clientHeight); - done(width, height); + var hasDimensions = function (editor) { + return editor.settings.image_dimensions === false ? false : true; }; - img.onerror = function () { - done(0, 0); + var hasAdvTab = function (editor) { + return editor.settings.image_advtab === true ? true : false; }; - var style = img.style; - style.visibility = 'hidden'; - style.position = 'fixed'; - style.bottom = style.left = '0px'; - style.width = style.height = 'auto'; - document.body.appendChild(img); - img.src = url; - }; - var buildListItems = function (inputList, itemCallback, startItems) { - function appendItems(values, output) { - output = output || []; - global$2.each(values, function (item) { - var menuItem = { text: item.text || item.title }; - if (item.menu) { - menuItem.menu = appendItems(item.menu); - } else { - menuItem.value = item.value; - itemCallback(menuItem); + var getPrependUrl = function (editor) { + return editor.getParam('image_prepend_url', ''); + }; + var getClassList = function (editor) { + return editor.getParam('image_class_list'); + }; + var hasDescription = function (editor) { + return editor.settings.image_description === false ? false : true; + }; + var hasImageTitle = function (editor) { + return editor.settings.image_title === true ? true : false; + }; + var hasImageCaption = function (editor) { + return editor.settings.image_caption === true ? true : false; + }; + var getImageList = function (editor) { + return editor.getParam('image_list', false); + }; + var hasUploadUrl = function (editor) { + return editor.getParam('images_upload_url', false); + }; + var hasUploadHandler = function (editor) { + return editor.getParam('images_upload_handler', false); + }; + var getUploadUrl = function (editor) { + return editor.getParam('images_upload_url'); + }; + var getUploadHandler = function (editor) { + return editor.getParam('images_upload_handler'); + }; + var getUploadBasePath = function (editor) { + return editor.getParam('images_upload_base_path'); + }; + var getUploadCredentials = function (editor) { + return editor.getParam('images_upload_credentials'); + }; + var Settings = { + hasDimensions: hasDimensions, + hasAdvTab: hasAdvTab, + getPrependUrl: getPrependUrl, + getClassList: getClassList, + hasDescription: hasDescription, + hasImageTitle: hasImageTitle, + hasImageCaption: hasImageCaption, + getImageList: getImageList, + hasUploadUrl: hasUploadUrl, + hasUploadHandler: hasUploadHandler, + getUploadUrl: getUploadUrl, + getUploadHandler: getUploadHandler, + getUploadBasePath: getUploadBasePath, + getUploadCredentials: getUploadCredentials + }; + + var Global = typeof window !== 'undefined' ? 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 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$1 = tinymce.util.Tools.resolve('tinymce.util.Promise'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var global$3 = tinymce.util.Tools.resolve('tinymce.util.XHR'); + + var parseIntAndGetMax = function (val1, val2) { + return Math.max(parseInt(val1, 10), parseInt(val2, 10)); + }; + var getImageSize = function (url, callback) { + var img = document.createElement('img'); + function done(width, height) { + if (img.parentNode) { + img.parentNode.removeChild(img); } - output.push(menuItem); - }); - return output; - } - return appendItems(inputList, startItems || []); - }; - var removePixelSuffix = function (value) { - if (value) { - value = value.replace(/px$/, ''); - } - return value; - }; - var addPixelSuffix = function (value) { - if (value.length > 0 && /^[0-9]+$/.test(value)) { - value += 'px'; - } - return value; - }; - var mergeMargins = function (css) { - if (css.margin) { - var splitMargin = css.margin.split(' '); - switch (splitMargin.length) { - case 1: - css['margin-top'] = css['margin-top'] || splitMargin[0]; - css['margin-right'] = css['margin-right'] || splitMargin[0]; - css['margin-bottom'] = css['margin-bottom'] || splitMargin[0]; - css['margin-left'] = css['margin-left'] || splitMargin[0]; - break; - case 2: - css['margin-top'] = css['margin-top'] || splitMargin[0]; - css['margin-right'] = css['margin-right'] || splitMargin[1]; - css['margin-bottom'] = css['margin-bottom'] || splitMargin[0]; - css['margin-left'] = css['margin-left'] || splitMargin[1]; - break; - case 3: - css['margin-top'] = css['margin-top'] || splitMargin[0]; - css['margin-right'] = css['margin-right'] || splitMargin[1]; - css['margin-bottom'] = css['margin-bottom'] || splitMargin[2]; - css['margin-left'] = css['margin-left'] || splitMargin[1]; - break; - case 4: - css['margin-top'] = css['margin-top'] || splitMargin[0]; - css['margin-right'] = css['margin-right'] || splitMargin[1]; - css['margin-bottom'] = css['margin-bottom'] || splitMargin[2]; - css['margin-left'] = css['margin-left'] || splitMargin[3]; - } - delete css.margin; - } - return css; - }; - var createImageList = function (editor, callback) { - var imageList = $_1dn8wtctjjgwebvz.getImageList(editor); - if (typeof imageList === 'string') { - global$3.send({ - url: imageList, - success: function (text) { - callback(JSON.parse(text)); - } - }); - } else if (typeof imageList === 'function') { - imageList(callback); - } else { - callback(imageList); - } - }; - var waitLoadImage = function (editor, data, imgElm) { - function selectImage() { - imgElm.onload = imgElm.onerror = null; - if (editor.selection) { - editor.selection.select(imgElm); - editor.nodeChanged(); - } - } - imgElm.onload = function () { - if (!data.width && !data.height && $_1dn8wtctjjgwebvz.hasDimensions(editor)) { - editor.dom.setAttribs(imgElm, { - width: imgElm.clientWidth, - height: imgElm.clientHeight + callback({ + width: width, + height: height }); } - selectImage(); + img.onload = function () { + var width = parseIntAndGetMax(img.width, img.clientWidth); + var height = parseIntAndGetMax(img.height, img.clientHeight); + done(width, height); + }; + img.onerror = function () { + done(0, 0); + }; + var style = img.style; + style.visibility = 'hidden'; + style.position = 'fixed'; + style.bottom = style.left = '0px'; + style.width = style.height = 'auto'; + document.body.appendChild(img); + img.src = url; }; - imgElm.onerror = selectImage; - }; - var blobToDataUri = function (blob) { - return new global$1(function (resolve, reject) { - var reader = new FileReader(); - reader.onload = function () { - resolve(reader.result); - }; - reader.onerror = function () { - reject(FileReader.error.message); - }; - reader.readAsDataURL(blob); - }); - }; - var $_1e8k4ncujjgwebw2 = { - getImageSize: getImageSize, - buildListItems: buildListItems, - removePixelSuffix: removePixelSuffix, - addPixelSuffix: addPixelSuffix, - mergeMargins: mergeMargins, - createImageList: createImageList, - waitLoadImage: waitLoadImage, - blobToDataUri: blobToDataUri - }; - - var global$4 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var hasOwnProperty = Object.prototype.hasOwnProperty; - var shallow = function (old, nu) { - return nu; - }; - var baseMerge = function (merger) { - return function () { - var objects = new Array(arguments.length); - for (var i = 0; i < objects.length; i++) - objects[i] = arguments[i]; - if (objects.length === 0) - throw new Error('Can\'t merge zero objects'); - var ret = {}; - for (var j = 0; j < objects.length; j++) { - var curObject = objects[j]; - for (var key in curObject) - if (hasOwnProperty.call(curObject, key)) { - ret[key] = merger(ret[key], curObject[key]); + var buildListItems = function (inputList, itemCallback, startItems) { + function appendItems(values, output) { + output = output || []; + global$2.each(values, function (item) { + var menuItem = { text: item.text || item.title }; + if (item.menu) { + menuItem.menu = appendItems(item.menu); + } else { + menuItem.value = item.value; + itemCallback(menuItem); } + output.push(menuItem); + }); + return output; } - return ret; + return appendItems(inputList, startItems || []); }; - }; - - var merge = baseMerge(shallow); - - var DOM = global$4.DOM; - var getHspace = function (image) { - if (image.style.marginLeft && image.style.marginRight && image.style.marginLeft === image.style.marginRight) { - return $_1e8k4ncujjgwebw2.removePixelSuffix(image.style.marginLeft); - } else { - return ''; - } - }; - var getVspace = function (image) { - if (image.style.marginTop && image.style.marginBottom && image.style.marginTop === image.style.marginBottom) { - return $_1e8k4ncujjgwebw2.removePixelSuffix(image.style.marginTop); - } else { - return ''; - } - }; - var getBorder = function (image) { - if (image.style.borderWidth) { - return $_1e8k4ncujjgwebw2.removePixelSuffix(image.style.borderWidth); - } else { - return ''; - } - }; - var getAttrib = function (image, name$$1) { - if (image.hasAttribute(name$$1)) { - return image.getAttribute(name$$1); - } else { - return ''; - } - }; - var getStyle = function (image, name$$1) { - return image.style[name$$1] ? image.style[name$$1] : ''; - }; - var hasCaption = function (image) { - return image.parentNode !== null && image.parentNode.nodeName === 'FIGURE'; - }; - var setAttrib = function (image, name$$1, value) { - image.setAttribute(name$$1, value); - }; - var wrapInFigure = function (image) { - var figureElm = DOM.create('figure', { class: 'image' }); - DOM.insertAfter(figureElm, image); - figureElm.appendChild(image); - figureElm.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); - figureElm.contentEditable = 'false'; - }; - var removeFigure = function (image) { - var figureElm = image.parentNode; - DOM.insertAfter(image, figureElm); - DOM.remove(figureElm); - }; - var toggleCaption = function (image) { - if (hasCaption(image)) { - removeFigure(image); - } else { - wrapInFigure(image); - } - }; - var normalizeStyle = function (image, normalizeCss) { - var attrValue = image.getAttribute('style'); - var value = normalizeCss(attrValue !== null ? attrValue : ''); - if (value.length > 0) { - image.setAttribute('style', value); - image.setAttribute('data-mce-style', value); - } else { - image.removeAttribute('style'); - } - }; - var setSize = function (name$$1, normalizeCss) { - return function (image, name$$1, value) { - if (image.style[name$$1]) { - image.style[name$$1] = $_1e8k4ncujjgwebw2.addPixelSuffix(value); - normalizeStyle(image, normalizeCss); - } else { - setAttrib(image, name$$1, value); + var removePixelSuffix = function (value) { + if (value) { + value = value.replace(/px$/, ''); } + return value; }; - }; - var getSize = function (image, name$$1) { - if (image.style[name$$1]) { - return $_1e8k4ncujjgwebw2.removePixelSuffix(image.style[name$$1]); - } else { - return getAttrib(image, name$$1); - } - }; - var setHspace = function (image, value) { - var pxValue = $_1e8k4ncujjgwebw2.addPixelSuffix(value); - image.style.marginLeft = pxValue; - image.style.marginRight = pxValue; - }; - var setVspace = function (image, value) { - var pxValue = $_1e8k4ncujjgwebw2.addPixelSuffix(value); - image.style.marginTop = pxValue; - image.style.marginBottom = pxValue; - }; - var setBorder = function (image, value) { - var pxValue = $_1e8k4ncujjgwebw2.addPixelSuffix(value); - image.style.borderWidth = pxValue; - }; - var setBorderStyle = function (image, value) { - image.style.borderStyle = value; - }; - var getBorderStyle = function (image) { - return getStyle(image, 'borderStyle'); - }; - var isFigure = function (elm) { - return elm.nodeName === 'FIGURE'; - }; - var defaultData = function () { - return { - src: '', - alt: '', - title: '', - width: '', - height: '', - class: '', - style: '', - caption: false, - hspace: '', - vspace: '', - border: '', - borderStyle: '' - }; - }; - var getStyleValue = function (normalizeCss, data) { - var image = document.createElement('img'); - setAttrib(image, 'style', data.style); - if (getHspace(image) || data.hspace !== '') { - setHspace(image, data.hspace); - } - if (getVspace(image) || data.vspace !== '') { - setVspace(image, data.vspace); - } - if (getBorder(image) || data.border !== '') { - setBorder(image, data.border); - } - if (getBorderStyle(image) || data.borderStyle !== '') { - setBorderStyle(image, data.borderStyle); - } - return normalizeCss(image.getAttribute('style')); - }; - var create = function (normalizeCss, data) { - var image = document.createElement('img'); - write(normalizeCss, merge(data, { caption: false }), image); - setAttrib(image, 'alt', data.alt); - if (data.caption) { - var figure = DOM.create('figure', { class: 'image' }); - figure.appendChild(image); - figure.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); - figure.contentEditable = 'false'; - return figure; - } else { - return image; - } - }; - var read = function (normalizeCss, image) { - return { - src: getAttrib(image, 'src'), - alt: getAttrib(image, 'alt'), - title: getAttrib(image, 'title'), - width: getSize(image, 'width'), - height: getSize(image, 'height'), - class: getAttrib(image, 'class'), - style: normalizeCss(getAttrib(image, 'style')), - caption: hasCaption(image), - hspace: getHspace(image), - vspace: getVspace(image), - border: getBorder(image), - borderStyle: getStyle(image, 'borderStyle') - }; - }; - var updateProp = function (image, oldData, newData, name$$1, set) { - if (newData[name$$1] !== oldData[name$$1]) { - set(image, name$$1, newData[name$$1]); - } - }; - var normalized = function (set, normalizeCss) { - return function (image, name$$1, value) { - set(image, value); - normalizeStyle(image, normalizeCss); - }; - }; - var write = function (normalizeCss, newData, image) { - var oldData = read(normalizeCss, image); - updateProp(image, oldData, newData, 'caption', function (image, _name, _value) { - return toggleCaption(image); - }); - updateProp(image, oldData, newData, 'src', setAttrib); - updateProp(image, oldData, newData, 'alt', setAttrib); - updateProp(image, oldData, newData, 'title', setAttrib); - updateProp(image, oldData, newData, 'width', setSize('width', normalizeCss)); - updateProp(image, oldData, newData, 'height', setSize('height', normalizeCss)); - updateProp(image, oldData, newData, 'class', setAttrib); - updateProp(image, oldData, newData, 'style', normalized(function (image, value) { - return setAttrib(image, 'style', value); - }, normalizeCss)); - updateProp(image, oldData, newData, 'hspace', normalized(setHspace, normalizeCss)); - updateProp(image, oldData, newData, 'vspace', normalized(setVspace, normalizeCss)); - updateProp(image, oldData, newData, 'border', normalized(setBorder, normalizeCss)); - updateProp(image, oldData, newData, 'borderStyle', normalized(setBorderStyle, normalizeCss)); - }; - - var normalizeCss = function (editor, cssText) { - var css = editor.dom.styles.parse(cssText); - var mergedCss = $_1e8k4ncujjgwebw2.mergeMargins(css); - var compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss)); - return editor.dom.styles.serialize(compressed); - }; - var getSelectedImage = function (editor) { - var imgElm = editor.selection.getNode(); - var figureElm = editor.dom.getParent(imgElm, 'figure.image'); - if (figureElm) { - return editor.dom.select('img', figureElm)[0]; - } - if (imgElm && (imgElm.nodeName !== 'IMG' || imgElm.getAttribute('data-mce-object') || imgElm.getAttribute('data-mce-placeholder'))) { - return null; - } - return imgElm; - }; - var splitTextBlock = function (editor, figure) { - var dom = editor.dom; - var textBlock = dom.getParent(figure.parentNode, function (node) { - return editor.schema.getTextBlockElements()[node.nodeName]; - }); - if (textBlock) { - return dom.split(textBlock, figure); - } else { - return figure; - } - }; - var readImageDataFromSelection = function (editor) { - var image = getSelectedImage(editor); - return image ? read(function (css) { - return normalizeCss(editor, css); - }, image) : defaultData(); - }; - var insertImageAtCaret = function (editor, data) { - var elm = create(function (css) { - return normalizeCss(editor, css); - }, data); - editor.dom.setAttrib(elm, 'data-mce-id', '__mcenew'); - editor.focus(); - editor.selection.setContent(elm.outerHTML); - var insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0]; - editor.dom.setAttrib(insertedElm, 'data-mce-id', null); - if (isFigure(insertedElm)) { - var figure = splitTextBlock(editor, insertedElm); - editor.selection.select(figure); - } else { - editor.selection.select(insertedElm); - } - }; - var syncSrcAttr = function (editor, image) { - editor.dom.setAttrib(image, 'src', image.getAttribute('src')); - }; - var deleteImage = function (editor, image) { - if (image) { - var elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image; - editor.dom.remove(elm); - editor.focus(); - editor.nodeChanged(); - if (editor.dom.isEmpty(editor.getBody())) { - editor.setContent(''); - editor.selection.setCursorLocation(); + var addPixelSuffix = function (value) { + if (value.length > 0 && /^[0-9]+$/.test(value)) { + value += 'px'; } - } - }; - var writeImageDataToSelection = function (editor, data) { - var image = getSelectedImage(editor); - write(function (css) { - return normalizeCss(editor, css); - }, data, image); - syncSrcAttr(editor, image); - if (isFigure(image.parentNode)) { - var figure = image.parentNode; - splitTextBlock(editor, figure); - editor.selection.select(image.parentNode); - } else { - editor.selection.select(image); - $_1e8k4ncujjgwebw2.waitLoadImage(editor, data, image); - } - }; - var insertOrUpdateImage = function (editor, data) { - var image = getSelectedImage(editor); - if (image) { - if (data.src) { - writeImageDataToSelection(editor, data); - } else { - deleteImage(editor, image); - } - } else if (data.src) { - insertImageAtCaret(editor, data); - } - }; - - var updateVSpaceHSpaceBorder = function (editor) { - return function (evt) { - var dom = editor.dom; - var rootControl = evt.control.rootControl; - if (!$_1dn8wtctjjgwebvz.hasAdvTab(editor)) { - return; - } - var data = rootControl.toJSON(); - var css = dom.parseStyle(data.style); - rootControl.find('#vspace').value(''); - rootControl.find('#hspace').value(''); - css = $_1e8k4ncujjgwebw2.mergeMargins(css); - if (css['margin-top'] && css['margin-bottom'] || css['margin-right'] && css['margin-left']) { - if (css['margin-top'] === css['margin-bottom']) { - rootControl.find('#vspace').value($_1e8k4ncujjgwebw2.removePixelSuffix(css['margin-top'])); - } else { - rootControl.find('#vspace').value(''); - } - if (css['margin-right'] === css['margin-left']) { - rootControl.find('#hspace').value($_1e8k4ncujjgwebw2.removePixelSuffix(css['margin-right'])); - } else { - rootControl.find('#hspace').value(''); + return value; + }; + var mergeMargins = function (css) { + if (css.margin) { + var splitMargin = css.margin.split(' '); + switch (splitMargin.length) { + case 1: + css['margin-top'] = css['margin-top'] || splitMargin[0]; + css['margin-right'] = css['margin-right'] || splitMargin[0]; + css['margin-bottom'] = css['margin-bottom'] || splitMargin[0]; + css['margin-left'] = css['margin-left'] || splitMargin[0]; + break; + case 2: + css['margin-top'] = css['margin-top'] || splitMargin[0]; + css['margin-right'] = css['margin-right'] || splitMargin[1]; + css['margin-bottom'] = css['margin-bottom'] || splitMargin[0]; + css['margin-left'] = css['margin-left'] || splitMargin[1]; + break; + case 3: + css['margin-top'] = css['margin-top'] || splitMargin[0]; + css['margin-right'] = css['margin-right'] || splitMargin[1]; + css['margin-bottom'] = css['margin-bottom'] || splitMargin[2]; + css['margin-left'] = css['margin-left'] || splitMargin[1]; + break; + case 4: + css['margin-top'] = css['margin-top'] || splitMargin[0]; + css['margin-right'] = css['margin-right'] || splitMargin[1]; + css['margin-bottom'] = css['margin-bottom'] || splitMargin[2]; + css['margin-left'] = css['margin-left'] || splitMargin[3]; } + delete css.margin; } - if (css['border-width']) { - rootControl.find('#border').value($_1e8k4ncujjgwebw2.removePixelSuffix(css['border-width'])); - } else { - rootControl.find('#border').value(''); - } - if (css['border-style']) { - rootControl.find('#borderStyle').value(css['border-style']); - } else { - rootControl.find('#borderStyle').value(''); - } - rootControl.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css)))); + return css; }; - }; - var updateStyle = function (editor, win) { - win.find('#style').each(function (ctrl) { - var value = getStyleValue(function (css) { - return normalizeCss(editor, css); - }, merge(defaultData(), win.toJSON())); - ctrl.value(value); - }); - }; - var makeTab = function (editor) { - return { - title: 'Advanced', - type: 'form', - pack: 'start', - items: [ - { - label: 'Style', - name: 'style', - type: 'textbox', - onchange: updateVSpaceHSpaceBorder(editor) - }, - { - type: 'form', - layout: 'grid', - packV: 'start', - columns: 2, - padding: 0, - defaults: { - type: 'textbox', - maxWidth: 50, - onchange: function (evt) { - updateStyle(editor, evt.control.rootControl); - } - }, - items: [ - { - label: 'Vertical space', - name: 'vspace' - }, - { - label: 'Border width', - name: 'border' - }, - { - label: 'Horizontal space', - name: 'hspace' - }, - { - label: 'Border style', - type: 'listbox', - name: 'borderStyle', - width: 90, - maxWidth: 90, - onselect: function (evt) { - updateStyle(editor, evt.control.rootControl); - }, - values: [ - { - text: 'Select...', - value: '' - }, - { - text: 'Solid', - value: 'solid' - }, - { - text: 'Dotted', - value: 'dotted' - }, - { - text: 'Dashed', - value: 'dashed' - }, - { - text: 'Double', - value: 'double' - }, - { - text: 'Groove', - value: 'groove' - }, - { - text: 'Ridge', - value: 'ridge' - }, - { - text: 'Inset', - value: 'inset' - }, - { - text: 'Outset', - value: 'outset' - }, - { - text: 'None', - value: 'none' - }, - { - text: 'Hidden', - value: 'hidden' - } - ] - } - ] - } - ] - }; - }; - var $_6dfy5vd3jjgwebxf = { makeTab: makeTab }; - - var doSyncSize = function (widthCtrl, heightCtrl) { - widthCtrl.state.set('oldVal', widthCtrl.value()); - heightCtrl.state.set('oldVal', heightCtrl.value()); - }; - var doSizeControls = function (win, f) { - var widthCtrl = win.find('#width')[0]; - var heightCtrl = win.find('#height')[0]; - var constrained = win.find('#constrain')[0]; - if (widthCtrl && heightCtrl && constrained) { - f(widthCtrl, heightCtrl, constrained.checked()); - } - }; - var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { - var oldWidth = widthCtrl.state.get('oldVal'); - var oldHeight = heightCtrl.state.get('oldVal'); - var newWidth = widthCtrl.value(); - var newHeight = heightCtrl.value(); - if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { - if (newWidth !== oldWidth) { - newHeight = Math.round(newWidth / oldWidth * newHeight); - if (!isNaN(newHeight)) { - heightCtrl.value(newHeight); - } - } else { - newWidth = Math.round(newHeight / oldHeight * newWidth); - if (!isNaN(newWidth)) { - widthCtrl.value(newWidth); - } - } - } - doSyncSize(widthCtrl, heightCtrl); - }; - var syncSize = function (win) { - doSizeControls(win, doSyncSize); - }; - var updateSize = function (win) { - doSizeControls(win, doUpdateSize); - }; - var createUi = function () { - var recalcSize = function (evt) { - updateSize(evt.control.rootControl); - }; - return { - type: 'container', - label: 'Dimensions', - layout: 'flex', - align: 'center', - spacing: 5, - items: [ - { - name: 'width', - type: 'textbox', - maxLength: 5, - size: 5, - onchange: recalcSize, - ariaLabel: 'Width' - }, - { - type: 'label', - text: 'x' - }, - { - name: 'height', - type: 'textbox', - maxLength: 5, - size: 5, - onchange: recalcSize, - ariaLabel: 'Height' - }, - { - name: 'constrain', - type: 'checkbox', - checked: true, - text: 'Constrain proportions' - } - ] - }; - }; - var $_ftlz5pdajjgweby4 = { - createUi: createUi, - syncSize: syncSize, - updateSize: updateSize - }; - - var onSrcChange = function (evt, editor) { - var srcURL, prependURL, absoluteURLPattern; - var meta = evt.meta || {}; - var control = evt.control; - var rootControl = control.rootControl; - var imageListCtrl = rootControl.find('#image-list')[0]; - if (imageListCtrl) { - imageListCtrl.value(editor.convertURL(control.value(), 'src')); - } - global$2.each(meta, function (value, key) { - rootControl.find('#' + key).value(value); - }); - if (!meta.width && !meta.height) { - srcURL = editor.convertURL(control.value(), 'src'); - prependURL = $_1dn8wtctjjgwebvz.getPrependUrl(editor); - absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i'); - if (prependURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, prependURL.length) !== prependURL) { - srcURL = prependURL + srcURL; - } - control.value(srcURL); - $_1e8k4ncujjgwebw2.getImageSize(editor.documentBaseURI.toAbsolute(control.value()), function (data) { - if (data.width && data.height && $_1dn8wtctjjgwebvz.hasDimensions(editor)) { - rootControl.find('#width').value(data.width); - rootControl.find('#height').value(data.height); - $_ftlz5pdajjgweby4.syncSize(rootControl); - } - }); - } - }; - var onBeforeCall = function (evt) { - evt.meta = evt.control.rootControl.toJSON(); - }; - var getGeneralItems = function (editor, imageListCtrl) { - var generalFormItems = [ - { - name: 'src', - type: 'filepicker', - filetype: 'image', - label: 'Source', - autofocus: true, - onchange: function (evt) { - onSrcChange(evt, editor); - }, - onbeforecall: onBeforeCall - }, - imageListCtrl - ]; - if ($_1dn8wtctjjgwebvz.hasDescription(editor)) { - generalFormItems.push({ - name: 'alt', - type: 'textbox', - label: 'Image description' - }); - } - if ($_1dn8wtctjjgwebvz.hasImageTitle(editor)) { - generalFormItems.push({ - name: 'title', - type: 'textbox', - label: 'Image Title' - }); - } - if ($_1dn8wtctjjgwebvz.hasDimensions(editor)) { - generalFormItems.push($_ftlz5pdajjgweby4.createUi()); - } - if ($_1dn8wtctjjgwebvz.getClassList(editor)) { - generalFormItems.push({ - name: 'class', - type: 'listbox', - label: 'Class', - values: $_1e8k4ncujjgwebw2.buildListItems($_1dn8wtctjjgwebvz.getClassList(editor), function (item) { - if (item.value) { - item.textStyle = function () { - return editor.formatter.getCssText({ - inline: 'img', - classes: [item.value] - }); - }; + var createImageList = function (editor, callback) { + var imageList = Settings.getImageList(editor); + if (typeof imageList === 'string') { + global$3.send({ + url: imageList, + success: function (text) { + callback(JSON.parse(text)); } - }) - }); - } - if ($_1dn8wtctjjgwebvz.hasImageCaption(editor)) { - generalFormItems.push({ - name: 'caption', - type: 'checkbox', - label: 'Caption' - }); - } - return generalFormItems; - }; - var makeTab$1 = function (editor, imageListCtrl) { - return { - title: 'General', - type: 'form', - items: getGeneralItems(editor, imageListCtrl) + }); + } else if (typeof imageList === 'function') { + imageList(callback); + } else { + callback(imageList); + } }; - }; - var $_78zck5d9jjgweby1 = { - makeTab: makeTab$1, - getGeneralItems: getGeneralItems - }; - - var url = function () { - return $_oab1bcwjjgwebwl.getOrDie('URL'); - }; - var createObjectURL = function (blob) { - return url().createObjectURL(blob); - }; - var revokeObjectURL = function (u) { - url().revokeObjectURL(u); - }; - var $_86i13edcjjgwebya = { - createObjectURL: createObjectURL, - revokeObjectURL: revokeObjectURL - }; - - var global$5 = tinymce.util.Tools.resolve('tinymce.ui.Factory'); - - function XMLHttpRequest () { - var f = $_oab1bcwjjgwebwl.getOrDie('XMLHttpRequest'); - return new f(); - } - - var noop = function () { - }; - var pathJoin = function (path1, path2) { - if (path1) { - return path1.replace(/\/$/, '') + '/' + path2.replace(/^\//, ''); - } - return path2; - }; - function Uploader (settings) { - var defaultHandler = function (blobInfo, success, failure, progress) { - var xhr, formData; - xhr = new XMLHttpRequest(); - xhr.open('POST', settings.url); - xhr.withCredentials = settings.credentials; - xhr.upload.onprogress = function (e) { - progress(e.loaded / e.total * 100); - }; - xhr.onerror = function () { - failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status); - }; - xhr.onload = function () { - var json; - if (xhr.status < 200 || xhr.status >= 300) { - failure('HTTP Error: ' + xhr.status); - return; + var waitLoadImage = function (editor, data, imgElm) { + function selectImage() { + imgElm.onload = imgElm.onerror = null; + if (editor.selection) { + editor.selection.select(imgElm); + editor.nodeChanged(); } - json = JSON.parse(xhr.responseText); - if (!json || typeof json.location !== 'string') { - failure('Invalid JSON: ' + xhr.responseText); - return; + } + imgElm.onload = function () { + if (!data.width && !data.height && Settings.hasDimensions(editor)) { + editor.dom.setAttribs(imgElm, { + width: imgElm.clientWidth, + height: imgElm.clientHeight + }); } - success(pathJoin(settings.basePath, json.location)); + selectImage(); }; - formData = new FormData(); - formData.append('file', blobInfo.blob(), blobInfo.filename()); - xhr.send(formData); + imgElm.onerror = selectImage; }; - var uploadBlob = function (blobInfo, handler) { + var blobToDataUri = function (blob) { return new global$1(function (resolve, reject) { - try { - handler(blobInfo, resolve, reject, noop); - } catch (ex) { - reject(ex.message); - } - }); - }; - var isDefaultHandler = function (handler) { - return handler === defaultHandler; - }; - var upload = function (blobInfo) { - return !settings.url && isDefaultHandler(settings.handler) ? global$1.reject('Upload url missing from the settings.') : uploadBlob(blobInfo, settings.handler); - }; - settings = global$2.extend({ - credentials: false, - handler: defaultHandler - }, settings); - return { upload: upload }; - } - - var onFileInput = function (editor) { - return function (evt) { - var Throbber = global$5.get('Throbber'); - var rootControl = evt.control.rootControl; - var throbber = new Throbber(rootControl.getEl()); - var file = evt.control.value(); - var blobUri = $_86i13edcjjgwebya.createObjectURL(file); - var uploader = Uploader({ - url: $_1dn8wtctjjgwebvz.getUploadUrl(editor), - basePath: $_1dn8wtctjjgwebvz.getUploadBasePath(editor), - credentials: $_1dn8wtctjjgwebvz.getUploadCredentials(editor), - handler: $_1dn8wtctjjgwebvz.getUploadHandler(editor) - }); - var finalize = function () { - throbber.hide(); - $_86i13edcjjgwebya.revokeObjectURL(blobUri); - }; - throbber.show(); - return $_1e8k4ncujjgwebw2.blobToDataUri(file).then(function (dataUrl) { - var blobInfo = editor.editorUpload.blobCache.create({ - blob: file, - blobUri: blobUri, - name: file.name ? file.name.replace(/\.[^\.]+$/, '') : null, - base64: dataUrl.split(',')[1] - }); - return uploader.upload(blobInfo).then(function (url) { - var src = rootControl.find('#src'); - src.value(url); - rootControl.find('tabpanel')[0].activateTab(0); - src.fire('change'); - finalize(); - return url; - }); - }).catch(function (err) { - editor.windowManager.alert(err); - finalize(); - }); - }; - }; - var acceptExts = '.jpg,.jpeg,.png,.gif'; - var makeTab$2 = function (editor) { - return { - title: 'Upload', - type: 'form', - layout: 'flex', - direction: 'column', - align: 'stretch', - padding: '20 20 20 20', - items: [ - { - type: 'container', - layout: 'flex', - direction: 'column', - align: 'center', - spacing: 10, - items: [ - { - text: 'Browse for an image', - type: 'browsebutton', - accept: acceptExts, - onchange: onFileInput(editor) - }, - { - text: 'OR', - type: 'label' - } - ] - }, - { - text: 'Drop an image here', - type: 'dropzone', - accept: acceptExts, - height: 100, - onchange: onFileInput(editor) - } - ] - }; - }; - var $_71qd7mdbjjgweby7 = { makeTab: makeTab$2 }; - - var curry = function (f) { - var x = []; - for (var _i = 1; _i < arguments.length; _i++) { - x[_i - 1] = arguments[_i]; - } - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) - args[i - 1] = arguments[i]; - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; - } - var newArgs = new Array(arguments.length); - for (var j = 0; j < newArgs.length; j++) - newArgs[j] = arguments[j]; - var all = args.concat(newArgs); - return f.apply(null, all); - }; - }; - - var submitForm = function (editor, evt) { - var win = evt.control.getRoot(); - $_ftlz5pdajjgweby4.updateSize(win); - editor.undoManager.transact(function () { - var data = merge(readImageDataFromSelection(editor), win.toJSON()); - insertOrUpdateImage(editor, data); - }); - editor.editorUpload.uploadImagesAuto(); - }; - function Dialog (editor) { - function showDialog(imageList) { - var data = readImageDataFromSelection(editor); - var win, imageListCtrl; - if (imageList) { - imageListCtrl = { - type: 'listbox', - label: 'Image list', - name: 'image-list', - values: $_1e8k4ncujjgwebw2.buildListItems(imageList, function (item) { - item.value = editor.convertURL(item.value || item.url, 'src'); - }, [{ - text: 'None', - value: '' - }]), - value: data.src && editor.convertURL(data.src, 'src'), - onselect: function (e) { - var altCtrl = win.find('#alt'); - if (!altCtrl.value() || e.lastControl && altCtrl.value() === e.lastControl.text()) { - altCtrl.value(e.control.text()); - } - win.find('#src').value(e.control.value()).fire('change'); - }, - onPostRender: function () { - imageListCtrl = this; - } + var reader = FileReader(); + reader.onload = function () { + resolve(reader.result); }; - } - if ($_1dn8wtctjjgwebvz.hasAdvTab(editor) || $_1dn8wtctjjgwebvz.hasUploadUrl(editor) || $_1dn8wtctjjgwebvz.hasUploadHandler(editor)) { - var body = [$_78zck5d9jjgweby1.makeTab(editor, imageListCtrl)]; - if ($_1dn8wtctjjgwebvz.hasAdvTab(editor)) { - body.push($_6dfy5vd3jjgwebxf.makeTab(editor)); - } - if ($_1dn8wtctjjgwebvz.hasUploadUrl(editor) || $_1dn8wtctjjgwebvz.hasUploadHandler(editor)) { - body.push($_71qd7mdbjjgweby7.makeTab(editor)); - } - win = editor.windowManager.open({ - title: 'Insert/edit image', - data: data, - bodyType: 'tabpanel', - body: body, - onSubmit: curry(submitForm, editor) - }); - } else { - win = editor.windowManager.open({ - title: 'Insert/edit image', - data: data, - body: $_78zck5d9jjgweby1.getGeneralItems(editor, imageListCtrl), - onSubmit: curry(submitForm, editor) - }); - } - $_ftlz5pdajjgweby4.syncSize(win); - } - function open() { - $_1e8k4ncujjgwebw2.createImageList(editor, showDialog); - } - return { open: open }; - } + reader.onerror = function () { + reject(reader.error.message); + }; + reader.readAsDataURL(blob); + }); + }; + var Utils = { + getImageSize: getImageSize, + buildListItems: buildListItems, + removePixelSuffix: removePixelSuffix, + addPixelSuffix: addPixelSuffix, + mergeMargins: mergeMargins, + createImageList: createImageList, + waitLoadImage: waitLoadImage, + blobToDataUri: blobToDataUri + }; - var register = function (editor) { - editor.addCommand('mceImage', Dialog(editor).open); - }; - var $_3lypdlcrjjgwebvs = { register: register }; + var global$4 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - var hasImageClass = function (node) { - var className = node.attr('class'); - return className && /\bimage\b/.test(className); - }; - var toggleContentEditableState = function (state) { - return function (nodes) { - var i = nodes.length, node; - var toggleContentEditable = function (node) { - node.attr('contenteditable', state ? 'true' : null); + var hasOwnProperty = Object.prototype.hasOwnProperty; + var shallow = function (old, nu) { + return nu; + }; + var baseMerge = function (merger) { + return function () { + var objects = new Array(arguments.length); + for (var i = 0; i < objects.length; i++) + objects[i] = arguments[i]; + if (objects.length === 0) + throw new Error('Can\'t merge zero objects'); + var ret = {}; + for (var j = 0; j < objects.length; j++) { + var curObject = objects[j]; + for (var key in curObject) + if (hasOwnProperty.call(curObject, key)) { + ret[key] = merger(ret[key], curObject[key]); + } + } + return ret; }; - while (i--) { - node = nodes[i]; - if (hasImageClass(node)) { - node.attr('contenteditable', state ? 'false' : null); - global$2.each(node.getAll('figcaption'), toggleContentEditable); + }; + var merge = baseMerge(shallow); + + var DOM = global$4.DOM; + var getHspace = function (image) { + if (image.style.marginLeft && image.style.marginRight && image.style.marginLeft === image.style.marginRight) { + return Utils.removePixelSuffix(image.style.marginLeft); + } else { + return ''; + } + }; + var getVspace = function (image) { + if (image.style.marginTop && image.style.marginBottom && image.style.marginTop === image.style.marginBottom) { + return Utils.removePixelSuffix(image.style.marginTop); + } else { + return ''; + } + }; + var getBorder = function (image) { + if (image.style.borderWidth) { + return Utils.removePixelSuffix(image.style.borderWidth); + } else { + return ''; + } + }; + var getAttrib = function (image, name$$1) { + if (image.hasAttribute(name$$1)) { + return image.getAttribute(name$$1); + } else { + return ''; + } + }; + var getStyle = function (image, name$$1) { + return image.style[name$$1] ? image.style[name$$1] : ''; + }; + var hasCaption = function (image) { + return image.parentNode !== null && image.parentNode.nodeName === 'FIGURE'; + }; + var setAttrib = function (image, name$$1, value) { + image.setAttribute(name$$1, value); + }; + var wrapInFigure = function (image) { + var figureElm = DOM.create('figure', { class: 'image' }); + DOM.insertAfter(figureElm, image); + figureElm.appendChild(image); + figureElm.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); + figureElm.contentEditable = 'false'; + }; + var removeFigure = function (image) { + var figureElm = image.parentNode; + DOM.insertAfter(image, figureElm); + DOM.remove(figureElm); + }; + var toggleCaption = function (image) { + if (hasCaption(image)) { + removeFigure(image); + } else { + wrapInFigure(image); + } + }; + var normalizeStyle = function (image, normalizeCss) { + var attrValue = image.getAttribute('style'); + var value = normalizeCss(attrValue !== null ? attrValue : ''); + if (value.length > 0) { + image.setAttribute('style', value); + image.setAttribute('data-mce-style', value); + } else { + image.removeAttribute('style'); + } + }; + var setSize = function (name$$1, normalizeCss) { + return function (image, name$$1, value) { + if (image.style[name$$1]) { + image.style[name$$1] = Utils.addPixelSuffix(value); + normalizeStyle(image, normalizeCss); + } else { + setAttrib(image, name$$1, value); + } + }; + }; + var getSize = function (image, name$$1) { + if (image.style[name$$1]) { + return Utils.removePixelSuffix(image.style[name$$1]); + } else { + return getAttrib(image, name$$1); + } + }; + var setHspace = function (image, value) { + var pxValue = Utils.addPixelSuffix(value); + image.style.marginLeft = pxValue; + image.style.marginRight = pxValue; + }; + var setVspace = function (image, value) { + var pxValue = Utils.addPixelSuffix(value); + image.style.marginTop = pxValue; + image.style.marginBottom = pxValue; + }; + var setBorder = function (image, value) { + var pxValue = Utils.addPixelSuffix(value); + image.style.borderWidth = pxValue; + }; + var setBorderStyle = function (image, value) { + image.style.borderStyle = value; + }; + var getBorderStyle = function (image) { + return getStyle(image, 'borderStyle'); + }; + var isFigure = function (elm) { + return elm.nodeName === 'FIGURE'; + }; + var defaultData = function () { + return { + src: '', + alt: '', + title: '', + width: '', + height: '', + class: '', + style: '', + caption: false, + hspace: '', + vspace: '', + border: '', + borderStyle: '' + }; + }; + var getStyleValue = function (normalizeCss, data) { + var image = document.createElement('img'); + setAttrib(image, 'style', data.style); + if (getHspace(image) || data.hspace !== '') { + setHspace(image, data.hspace); + } + if (getVspace(image) || data.vspace !== '') { + setVspace(image, data.vspace); + } + if (getBorder(image) || data.border !== '') { + setBorder(image, data.border); + } + if (getBorderStyle(image) || data.borderStyle !== '') { + setBorderStyle(image, data.borderStyle); + } + return normalizeCss(image.getAttribute('style')); + }; + var create = function (normalizeCss, data) { + var image = document.createElement('img'); + write(normalizeCss, merge(data, { caption: false }), image); + setAttrib(image, 'alt', data.alt); + if (data.caption) { + var figure = DOM.create('figure', { class: 'image' }); + figure.appendChild(image); + figure.appendChild(DOM.create('figcaption', { contentEditable: true }, 'Caption')); + figure.contentEditable = 'false'; + return figure; + } else { + return image; + } + }; + var read = function (normalizeCss, image) { + return { + src: getAttrib(image, 'src'), + alt: getAttrib(image, 'alt'), + title: getAttrib(image, 'title'), + width: getSize(image, 'width'), + height: getSize(image, 'height'), + class: getAttrib(image, 'class'), + style: normalizeCss(getAttrib(image, 'style')), + caption: hasCaption(image), + hspace: getHspace(image), + vspace: getVspace(image), + border: getBorder(image), + borderStyle: getStyle(image, 'borderStyle') + }; + }; + var updateProp = function (image, oldData, newData, name$$1, set) { + if (newData[name$$1] !== oldData[name$$1]) { + set(image, name$$1, newData[name$$1]); + } + }; + var normalized = function (set, normalizeCss) { + return function (image, name$$1, value) { + set(image, value); + normalizeStyle(image, normalizeCss); + }; + }; + var write = function (normalizeCss, newData, image) { + var oldData = read(normalizeCss, image); + updateProp(image, oldData, newData, 'caption', function (image, _name, _value) { + return toggleCaption(image); + }); + updateProp(image, oldData, newData, 'src', setAttrib); + updateProp(image, oldData, newData, 'alt', setAttrib); + updateProp(image, oldData, newData, 'title', setAttrib); + updateProp(image, oldData, newData, 'width', setSize('width', normalizeCss)); + updateProp(image, oldData, newData, 'height', setSize('height', normalizeCss)); + updateProp(image, oldData, newData, 'class', setAttrib); + updateProp(image, oldData, newData, 'style', normalized(function (image, value) { + return setAttrib(image, 'style', value); + }, normalizeCss)); + updateProp(image, oldData, newData, 'hspace', normalized(setHspace, normalizeCss)); + updateProp(image, oldData, newData, 'vspace', normalized(setVspace, normalizeCss)); + updateProp(image, oldData, newData, 'border', normalized(setBorder, normalizeCss)); + updateProp(image, oldData, newData, 'borderStyle', normalized(setBorderStyle, normalizeCss)); + }; + + var normalizeCss = function (editor, cssText) { + var css = editor.dom.styles.parse(cssText); + var mergedCss = Utils.mergeMargins(css); + var compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss)); + return editor.dom.styles.serialize(compressed); + }; + var getSelectedImage = function (editor) { + var imgElm = editor.selection.getNode(); + var figureElm = editor.dom.getParent(imgElm, 'figure.image'); + if (figureElm) { + return editor.dom.select('img', figureElm)[0]; + } + if (imgElm && (imgElm.nodeName !== 'IMG' || imgElm.getAttribute('data-mce-object') || imgElm.getAttribute('data-mce-placeholder'))) { + return null; + } + return imgElm; + }; + var splitTextBlock = function (editor, figure) { + var dom = editor.dom; + var textBlock = dom.getParent(figure.parentNode, function (node) { + return editor.schema.getTextBlockElements()[node.nodeName]; + }, editor.getBody()); + if (textBlock) { + return dom.split(textBlock, figure); + } else { + return figure; + } + }; + var readImageDataFromSelection = function (editor) { + var image = getSelectedImage(editor); + return image ? read(function (css) { + return normalizeCss(editor, css); + }, image) : defaultData(); + }; + var insertImageAtCaret = function (editor, data) { + var elm = create(function (css) { + return normalizeCss(editor, css); + }, data); + editor.dom.setAttrib(elm, 'data-mce-id', '__mcenew'); + editor.focus(); + editor.selection.setContent(elm.outerHTML); + var insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0]; + editor.dom.setAttrib(insertedElm, 'data-mce-id', null); + if (isFigure(insertedElm)) { + var figure = splitTextBlock(editor, insertedElm); + editor.selection.select(figure); + } else { + editor.selection.select(insertedElm); + } + }; + var syncSrcAttr = function (editor, image) { + editor.dom.setAttrib(image, 'src', image.getAttribute('src')); + }; + var deleteImage = function (editor, image) { + if (image) { + var elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image; + editor.dom.remove(elm); + editor.focus(); + editor.nodeChanged(); + if (editor.dom.isEmpty(editor.getBody())) { + editor.setContent(''); + editor.selection.setCursorLocation(); } } }; - }; - var setup = function (editor) { - editor.on('preInit', function () { - editor.parser.addNodeFilter('figure', toggleContentEditableState(true)); - editor.serializer.addNodeFilter('figure', toggleContentEditableState(false)); - }); - }; - var $_5op6l2dhjjgwebym = { setup: setup }; + var writeImageDataToSelection = function (editor, data) { + var image = getSelectedImage(editor); + write(function (css) { + return normalizeCss(editor, css); + }, data, image); + syncSrcAttr(editor, image); + if (isFigure(image.parentNode)) { + var figure = image.parentNode; + splitTextBlock(editor, figure); + editor.selection.select(image.parentNode); + } else { + editor.selection.select(image); + Utils.waitLoadImage(editor, data, image); + } + }; + var insertOrUpdateImage = function (editor, data) { + var image = getSelectedImage(editor); + if (image) { + if (data.src) { + writeImageDataToSelection(editor, data); + } else { + deleteImage(editor, image); + } + } else if (data.src) { + insertImageAtCaret(editor, data); + } + }; - var register$1 = function (editor) { - editor.addButton('image', { - icon: 'image', - tooltip: 'Insert/edit image', - onclick: Dialog(editor).open, - stateSelector: 'img:not([data-mce-object],[data-mce-placeholder]),figure.image' - }); - editor.addMenuItem('image', { - icon: 'image', - text: 'Image', - onclick: Dialog(editor).open, - context: 'insert', - prependToContext: true - }); - }; - var $_dm869adijjgwebyn = { register: register$1 }; + var updateVSpaceHSpaceBorder = function (editor) { + return function (evt) { + var dom = editor.dom; + var rootControl = evt.control.rootControl; + if (!Settings.hasAdvTab(editor)) { + return; + } + var data = rootControl.toJSON(); + var css = dom.parseStyle(data.style); + rootControl.find('#vspace').value(''); + rootControl.find('#hspace').value(''); + css = Utils.mergeMargins(css); + if (css['margin-top'] && css['margin-bottom'] || css['margin-right'] && css['margin-left']) { + if (css['margin-top'] === css['margin-bottom']) { + rootControl.find('#vspace').value(Utils.removePixelSuffix(css['margin-top'])); + } else { + rootControl.find('#vspace').value(''); + } + if (css['margin-right'] === css['margin-left']) { + rootControl.find('#hspace').value(Utils.removePixelSuffix(css['margin-right'])); + } else { + rootControl.find('#hspace').value(''); + } + } + if (css['border-width']) { + rootControl.find('#border').value(Utils.removePixelSuffix(css['border-width'])); + } else { + rootControl.find('#border').value(''); + } + if (css['border-style']) { + rootControl.find('#borderStyle').value(css['border-style']); + } else { + rootControl.find('#borderStyle').value(''); + } + rootControl.find('#style').value(dom.serializeStyle(dom.parseStyle(dom.serializeStyle(css)))); + }; + }; + var updateStyle = function (editor, win) { + win.find('#style').each(function (ctrl) { + var value = getStyleValue(function (css) { + return normalizeCss(editor, css); + }, merge(defaultData(), win.toJSON())); + ctrl.value(value); + }); + }; + var makeTab = function (editor) { + return { + title: 'Advanced', + type: 'form', + pack: 'start', + items: [ + { + label: 'Style', + name: 'style', + type: 'textbox', + onchange: updateVSpaceHSpaceBorder(editor) + }, + { + type: 'form', + layout: 'grid', + packV: 'start', + columns: 2, + padding: 0, + defaults: { + type: 'textbox', + maxWidth: 50, + onchange: function (evt) { + updateStyle(editor, evt.control.rootControl); + } + }, + items: [ + { + label: 'Vertical space', + name: 'vspace' + }, + { + label: 'Border width', + name: 'border' + }, + { + label: 'Horizontal space', + name: 'hspace' + }, + { + label: 'Border style', + type: 'listbox', + name: 'borderStyle', + width: 90, + maxWidth: 90, + onselect: function (evt) { + updateStyle(editor, evt.control.rootControl); + }, + values: [ + { + text: 'Select...', + value: '' + }, + { + text: 'Solid', + value: 'solid' + }, + { + text: 'Dotted', + value: 'dotted' + }, + { + text: 'Dashed', + value: 'dashed' + }, + { + text: 'Double', + value: 'double' + }, + { + text: 'Groove', + value: 'groove' + }, + { + text: 'Ridge', + value: 'ridge' + }, + { + text: 'Inset', + value: 'inset' + }, + { + text: 'Outset', + value: 'outset' + }, + { + text: 'None', + value: 'none' + }, + { + text: 'Hidden', + value: 'hidden' + } + ] + } + ] + } + ] + }; + }; + var AdvTab = { makeTab: makeTab }; - global.add('image', function (editor) { - $_5op6l2dhjjgwebym.setup(editor); - $_dm869adijjgwebyn.register(editor); - $_3lypdlcrjjgwebvs.register(editor); - }); - function Plugin () { - } + var doSyncSize = function (widthCtrl, heightCtrl) { + widthCtrl.state.set('oldVal', widthCtrl.value()); + heightCtrl.state.set('oldVal', heightCtrl.value()); + }; + var doSizeControls = function (win, f) { + var widthCtrl = win.find('#width')[0]; + var heightCtrl = win.find('#height')[0]; + var constrained = win.find('#constrain')[0]; + if (widthCtrl && heightCtrl && constrained) { + f(widthCtrl, heightCtrl, constrained.checked()); + } + }; + var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { + var oldWidth = widthCtrl.state.get('oldVal'); + var oldHeight = heightCtrl.state.get('oldVal'); + var newWidth = widthCtrl.value(); + var newHeight = heightCtrl.value(); + if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { + if (newWidth !== oldWidth) { + newHeight = Math.round(newWidth / oldWidth * newHeight); + if (!isNaN(newHeight)) { + heightCtrl.value(newHeight); + } + } else { + newWidth = Math.round(newHeight / oldHeight * newWidth); + if (!isNaN(newWidth)) { + widthCtrl.value(newWidth); + } + } + } + doSyncSize(widthCtrl, heightCtrl); + }; + var syncSize = function (win) { + doSizeControls(win, doSyncSize); + }; + var updateSize = function (win) { + doSizeControls(win, doUpdateSize); + }; + var createUi = function () { + var recalcSize = function (evt) { + updateSize(evt.control.rootControl); + }; + return { + type: 'container', + label: 'Dimensions', + layout: 'flex', + align: 'center', + spacing: 5, + items: [ + { + name: 'width', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Width' + }, + { + type: 'label', + text: 'x' + }, + { + name: 'height', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Height' + }, + { + name: 'constrain', + type: 'checkbox', + checked: true, + text: 'Constrain proportions' + } + ] + }; + }; + var SizeManager = { + createUi: createUi, + syncSize: syncSize, + updateSize: updateSize + }; - return Plugin; + var onSrcChange = function (evt, editor) { + var srcURL, prependURL, absoluteURLPattern; + var meta = evt.meta || {}; + var control = evt.control; + var rootControl = control.rootControl; + var imageListCtrl = rootControl.find('#image-list')[0]; + if (imageListCtrl) { + imageListCtrl.value(editor.convertURL(control.value(), 'src')); + } + global$2.each(meta, function (value, key) { + rootControl.find('#' + key).value(value); + }); + if (!meta.width && !meta.height) { + srcURL = editor.convertURL(control.value(), 'src'); + prependURL = Settings.getPrependUrl(editor); + absoluteURLPattern = new RegExp('^(?:[a-z]+:)?//', 'i'); + if (prependURL && !absoluteURLPattern.test(srcURL) && srcURL.substring(0, prependURL.length) !== prependURL) { + srcURL = prependURL + srcURL; + } + control.value(srcURL); + Utils.getImageSize(editor.documentBaseURI.toAbsolute(control.value()), function (data) { + if (data.width && data.height && Settings.hasDimensions(editor)) { + rootControl.find('#width').value(data.width); + rootControl.find('#height').value(data.height); + SizeManager.syncSize(rootControl); + } + }); + } + }; + var onBeforeCall = function (evt) { + evt.meta = evt.control.rootControl.toJSON(); + }; + var getGeneralItems = function (editor, imageListCtrl) { + var generalFormItems = [ + { + name: 'src', + type: 'filepicker', + filetype: 'image', + label: 'Source', + autofocus: true, + onchange: function (evt) { + onSrcChange(evt, editor); + }, + onbeforecall: onBeforeCall + }, + imageListCtrl + ]; + if (Settings.hasDescription(editor)) { + generalFormItems.push({ + name: 'alt', + type: 'textbox', + label: 'Image description' + }); + } + if (Settings.hasImageTitle(editor)) { + generalFormItems.push({ + name: 'title', + type: 'textbox', + label: 'Image Title' + }); + } + if (Settings.hasDimensions(editor)) { + generalFormItems.push(SizeManager.createUi()); + } + if (Settings.getClassList(editor)) { + generalFormItems.push({ + name: 'class', + type: 'listbox', + label: 'Class', + values: Utils.buildListItems(Settings.getClassList(editor), function (item) { + if (item.value) { + item.textStyle = function () { + return editor.formatter.getCssText({ + inline: 'img', + classes: [item.value] + }); + }; + } + }) + }); + } + if (Settings.hasImageCaption(editor)) { + generalFormItems.push({ + name: 'caption', + type: 'checkbox', + label: 'Caption' + }); + } + return generalFormItems; + }; + var makeTab$1 = function (editor, imageListCtrl) { + return { + title: 'General', + type: 'form', + items: getGeneralItems(editor, imageListCtrl) + }; + }; + var MainTab = { + makeTab: makeTab$1, + getGeneralItems: getGeneralItems + }; + + var url = function () { + return Global$1.getOrDie('URL'); + }; + var createObjectURL = function (blob) { + return url().createObjectURL(blob); + }; + var revokeObjectURL = function (u) { + url().revokeObjectURL(u); + }; + var URL = { + createObjectURL: createObjectURL, + revokeObjectURL: revokeObjectURL + }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.ui.Factory'); + + function XMLHttpRequest () { + var f = Global$1.getOrDie('XMLHttpRequest'); + return new f(); + } + + var noop = function () { + }; + var pathJoin = function (path1, path2) { + if (path1) { + return path1.replace(/\/$/, '') + '/' + path2.replace(/^\//, ''); + } + return path2; + }; + function Uploader (settings) { + var defaultHandler = function (blobInfo, success, failure, progress) { + var xhr, formData; + xhr = XMLHttpRequest(); + xhr.open('POST', settings.url); + xhr.withCredentials = settings.credentials; + xhr.upload.onprogress = function (e) { + progress(e.loaded / e.total * 100); + }; + xhr.onerror = function () { + failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status); + }; + xhr.onload = function () { + var json; + if (xhr.status < 200 || xhr.status >= 300) { + failure('HTTP Error: ' + xhr.status); + return; + } + json = JSON.parse(xhr.responseText); + if (!json || typeof json.location !== 'string') { + failure('Invalid JSON: ' + xhr.responseText); + return; + } + success(pathJoin(settings.basePath, json.location)); + }; + formData = new FormData(); + formData.append('file', blobInfo.blob(), blobInfo.filename()); + xhr.send(formData); + }; + var uploadBlob = function (blobInfo, handler) { + return new global$1(function (resolve, reject) { + try { + handler(blobInfo, resolve, reject, noop); + } catch (ex) { + reject(ex.message); + } + }); + }; + var isDefaultHandler = function (handler) { + return handler === defaultHandler; + }; + var upload = function (blobInfo) { + return !settings.url && isDefaultHandler(settings.handler) ? global$1.reject('Upload url missing from the settings.') : uploadBlob(blobInfo, settings.handler); + }; + settings = global$2.extend({ + credentials: false, + handler: defaultHandler + }, settings); + return { upload: upload }; + } + + var onFileInput = function (editor) { + return function (evt) { + var Throbber = global$5.get('Throbber'); + var rootControl = evt.control.rootControl; + var throbber = new Throbber(rootControl.getEl()); + var file = evt.control.value(); + var blobUri = URL.createObjectURL(file); + var uploader = Uploader({ + url: Settings.getUploadUrl(editor), + basePath: Settings.getUploadBasePath(editor), + credentials: Settings.getUploadCredentials(editor), + handler: Settings.getUploadHandler(editor) + }); + var finalize = function () { + throbber.hide(); + URL.revokeObjectURL(blobUri); + }; + throbber.show(); + return Utils.blobToDataUri(file).then(function (dataUrl) { + var blobInfo = editor.editorUpload.blobCache.create({ + blob: file, + blobUri: blobUri, + name: file.name ? file.name.replace(/\.[^\.]+$/, '') : null, + base64: dataUrl.split(',')[1] + }); + return uploader.upload(blobInfo).then(function (url) { + var src = rootControl.find('#src'); + src.value(url); + rootControl.find('tabpanel')[0].activateTab(0); + src.fire('change'); + finalize(); + return url; + }); + }).catch(function (err) { + editor.windowManager.alert(err); + finalize(); + }); + }; + }; + var acceptExts = '.jpg,.jpeg,.png,.gif'; + var makeTab$2 = function (editor) { + return { + title: 'Upload', + type: 'form', + layout: 'flex', + direction: 'column', + align: 'stretch', + padding: '20 20 20 20', + items: [ + { + type: 'container', + layout: 'flex', + direction: 'column', + align: 'center', + spacing: 10, + items: [ + { + text: 'Browse for an image', + type: 'browsebutton', + accept: acceptExts, + onchange: onFileInput(editor) + }, + { + text: 'OR', + type: 'label' + } + ] + }, + { + text: 'Drop an image here', + type: 'dropzone', + accept: acceptExts, + height: 100, + onchange: onFileInput(editor) + } + ] + }; + }; + var UploadTab = { makeTab: makeTab$2 }; + + function curry(fn) { + var initialArgs = []; + for (var _i = 1; _i < arguments.length; _i++) { + initialArgs[_i - 1] = arguments[_i]; + } + return function () { + var restArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + restArgs[_i] = arguments[_i]; + } + var all = initialArgs.concat(restArgs); + return fn.apply(null, all); + }; + } + + var submitForm = function (editor, evt) { + var win = evt.control.getRoot(); + SizeManager.updateSize(win); + editor.undoManager.transact(function () { + var data = merge(readImageDataFromSelection(editor), win.toJSON()); + insertOrUpdateImage(editor, data); + }); + editor.editorUpload.uploadImagesAuto(); + }; + function Dialog (editor) { + function showDialog(imageList) { + var data = readImageDataFromSelection(editor); + var win, imageListCtrl; + if (imageList) { + imageListCtrl = { + type: 'listbox', + label: 'Image list', + name: 'image-list', + values: Utils.buildListItems(imageList, function (item) { + item.value = editor.convertURL(item.value || item.url, 'src'); + }, [{ + text: 'None', + value: '' + }]), + value: data.src && editor.convertURL(data.src, 'src'), + onselect: function (e) { + var altCtrl = win.find('#alt'); + if (!altCtrl.value() || e.lastControl && altCtrl.value() === e.lastControl.text()) { + altCtrl.value(e.control.text()); + } + win.find('#src').value(e.control.value()).fire('change'); + }, + onPostRender: function () { + imageListCtrl = this; + } + }; + } + if (Settings.hasAdvTab(editor) || Settings.hasUploadUrl(editor) || Settings.hasUploadHandler(editor)) { + var body = [MainTab.makeTab(editor, imageListCtrl)]; + if (Settings.hasAdvTab(editor)) { + body.push(AdvTab.makeTab(editor)); + } + if (Settings.hasUploadUrl(editor) || Settings.hasUploadHandler(editor)) { + body.push(UploadTab.makeTab(editor)); + } + win = editor.windowManager.open({ + title: 'Insert/edit image', + data: data, + bodyType: 'tabpanel', + body: body, + onSubmit: curry(submitForm, editor) + }); + } else { + win = editor.windowManager.open({ + title: 'Insert/edit image', + data: data, + body: MainTab.getGeneralItems(editor, imageListCtrl), + onSubmit: curry(submitForm, editor) + }); + } + SizeManager.syncSize(win); + } + function open() { + Utils.createImageList(editor, showDialog); + } + return { open: open }; + } + + var register = function (editor) { + editor.addCommand('mceImage', Dialog(editor).open); + }; + var Commands = { register: register }; + + var hasImageClass = function (node) { + var className = node.attr('class'); + return className && /\bimage\b/.test(className); + }; + var toggleContentEditableState = function (state) { + return function (nodes) { + var i = nodes.length, node; + var toggleContentEditable = function (node) { + node.attr('contenteditable', state ? 'true' : null); + }; + while (i--) { + node = nodes[i]; + if (hasImageClass(node)) { + node.attr('contenteditable', state ? 'false' : null); + global$2.each(node.getAll('figcaption'), toggleContentEditable); + } + } + }; + }; + var setup = function (editor) { + editor.on('preInit', function () { + editor.parser.addNodeFilter('figure', toggleContentEditableState(true)); + editor.serializer.addNodeFilter('figure', toggleContentEditableState(false)); + }); + }; + var FilterContent = { setup: setup }; + + var register$1 = function (editor) { + editor.addButton('image', { + icon: 'image', + tooltip: 'Insert/edit image', + onclick: Dialog(editor).open, + stateSelector: 'img:not([data-mce-object],[data-mce-placeholder]),figure.image' + }); + editor.addMenuItem('image', { + icon: 'image', + text: 'Image', + onclick: Dialog(editor).open, + context: 'insert', + prependToContext: true + }); + }; + var Buttons = { register: register$1 }; + + global.add('image', function (editor) { + FilterContent.setup(editor); + Buttons.register(editor); + Commands.register(editor); + }); + function Plugin () { + } + + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/image/plugin.min.js b/wp-includes/js/tinymce/plugins/image/plugin.min.js index 4ab72c5e39..2bb78be4b3 100644 --- a/wp-includes/js/tinymce/plugins/image/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/image/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=function(e){return!1!==e.settings.image_dimensions},i=function(e){return!0===e.settings.image_advtab},g=function(e){return e.getParam("image_prepend_url","")},n=function(e){return e.getParam("image_class_list")},r=function(e){return!1!==e.settings.image_description},a=function(e){return!0===e.settings.image_title},o=function(e){return!0===e.settings.image_caption},l=function(e){return e.getParam("image_list",!1)},u=function(e){return e.getParam("images_upload_url",!1)},c=function(e){return e.getParam("images_upload_handler",!1)},s=function(e){return e.getParam("images_upload_url")},m=function(e){return e.getParam("images_upload_handler")},f=function(e){return e.getParam("images_upload_base_path")},p=function(e){return e.getParam("images_upload_credentials")},h="undefined"!=typeof window?window:Function("return this;")(),v=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:h,r=0;r 10) { - var link = document.createElement('a'); - link.target = '_blank'; - link.href = url; - link.rel = 'noreferrer noopener'; - var evt = document.createEvent('MouseEvents'); - evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); - appendClickRemove(link, evt); - } else { - var win = window.open('', '_blank'); - if (win) { - win.opener = null; - var doc = win.document; - doc.open(); - doc.write(''); - doc.close(); - } - } - }; - var $_du0gebfwjjgwechl = { open: open$$1 }; - - var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var toggleTargetRules = function (rel, isUnsafe) { - var rules = ['noopener']; - var newRel = rel ? rel.split(/\s+/) : []; - var toString = function (rel) { - return global$4.trim(rel.sort().join(' ')); + var assumeExternalTargets = function (editorSettings) { + return typeof editorSettings.link_assume_external_targets === 'boolean' ? editorSettings.link_assume_external_targets : false; }; - var addTargetRules = function (rel) { - rel = removeTargetRules(rel); - return rel.length ? rel.concat(rules) : rules; + var hasContextToolbar = function (editorSettings) { + return typeof editorSettings.link_context_toolbar === 'boolean' ? editorSettings.link_context_toolbar : false; }; - var removeTargetRules = function (rel) { - return rel.filter(function (val) { - return global$4.inArray(rules, val) === -1; - }); + var getLinkList = function (editorSettings) { + return editorSettings.link_list; }; - newRel = isUnsafe ? addTargetRules(newRel) : removeTargetRules(newRel); - return newRel.length ? toString(newRel) : null; - }; - var trimCaretContainers = function (text) { - return text.replace(/\uFEFF/g, ''); - }; - var getAnchorElement = function (editor, selectedElm) { - selectedElm = selectedElm || editor.selection.getNode(); - if (isImageFigure(selectedElm)) { - return editor.dom.select('a[href]', selectedElm)[0]; - } else { - return editor.dom.getParent(selectedElm, 'a[href]'); - } - }; - var getAnchorText = function (selection, anchorElm) { - var text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' }); - return trimCaretContainers(text); - }; - var isLink = function (elm) { - return elm && elm.nodeName === 'A' && elm.href; - }; - var hasLinks = function (elements) { - return global$4.grep(elements, isLink).length > 0; - }; - var isOnlyTextSelected = function (html) { - if (/]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') === -1)) { - return false; - } - return true; - }; - var isImageFigure = function (node) { - return node && node.nodeName === 'FIGURE' && /\bimage\b/i.test(node.className); - }; - var link = function (editor, attachState) { - return function (data) { - editor.undoManager.transact(function () { - var selectedElm = editor.selection.getNode(); - var anchorElm = getAnchorElement(editor, selectedElm); - var linkAttrs = { - href: data.href, - target: data.target ? data.target : null, - rel: data.rel ? data.rel : null, - class: data.class ? data.class : null, - title: data.title ? data.title : null - }; - if (!$_1b4wbxfvjjgwechi.hasRelList(editor.settings) && $_1b4wbxfvjjgwechi.allowUnsafeLinkTarget(editor.settings) === false) { - linkAttrs.rel = toggleTargetRules(linkAttrs.rel, linkAttrs.target === '_blank'); - } - if (data.href === attachState.href) { - attachState.attach(); - attachState = {}; - } - if (anchorElm) { - editor.focus(); - if (data.hasOwnProperty('text')) { - if ('innerText' in anchorElm) { - anchorElm.innerText = data.text; - } else { - anchorElm.textContent = data.text; - } - } - editor.dom.setAttribs(anchorElm, linkAttrs); - editor.selection.select(anchorElm); - editor.undoManager.add(); - } else { - if (isImageFigure(selectedElm)) { - linkImageFigure(editor, selectedElm, linkAttrs); - } else if (data.hasOwnProperty('text')) { - editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(data.text))); - } else { - editor.execCommand('mceInsertLink', false, linkAttrs); - } - } - }); + var hasDefaultLinkTarget = function (editorSettings) { + return typeof editorSettings.default_link_target === 'string'; }; - }; - var unlink = function (editor) { - return function () { - editor.undoManager.transact(function () { - var node = editor.selection.getNode(); - if (isImageFigure(node)) { - unlinkImageFigure(editor, node); - } else { - editor.execCommand('unlink'); - } - }); + var getDefaultLinkTarget = function (editorSettings) { + return editorSettings.default_link_target; + }; + var getTargetList = function (editorSettings) { + return editorSettings.target_list; + }; + var setTargetList = function (editor, list) { + editor.settings.target_list = list; + }; + var shouldShowTargetList = function (editorSettings) { + return getTargetList(editorSettings) !== false; + }; + var getRelList = function (editorSettings) { + return editorSettings.rel_list; + }; + var hasRelList = function (editorSettings) { + return getRelList(editorSettings) !== undefined; + }; + var getLinkClassList = function (editorSettings) { + return editorSettings.link_class_list; + }; + var hasLinkClassList = function (editorSettings) { + return getLinkClassList(editorSettings) !== undefined; + }; + var shouldShowLinkTitle = function (editorSettings) { + return editorSettings.link_title !== false; + }; + var allowUnsafeLinkTarget = function (editorSettings) { + return typeof editorSettings.allow_unsafe_link_target === 'boolean' ? editorSettings.allow_unsafe_link_target : false; + }; + var Settings = { + assumeExternalTargets: assumeExternalTargets, + hasContextToolbar: hasContextToolbar, + getLinkList: getLinkList, + hasDefaultLinkTarget: hasDefaultLinkTarget, + getDefaultLinkTarget: getDefaultLinkTarget, + getTargetList: getTargetList, + setTargetList: setTargetList, + shouldShowTargetList: shouldShowTargetList, + getRelList: getRelList, + hasRelList: hasRelList, + getLinkClassList: getLinkClassList, + hasLinkClassList: hasLinkClassList, + shouldShowLinkTitle: shouldShowLinkTitle, + allowUnsafeLinkTarget: allowUnsafeLinkTarget }; - }; - var unlinkImageFigure = function (editor, fig) { - var a, img; - img = editor.dom.select('img', fig)[0]; - if (img) { - a = editor.dom.getParents(img, 'a[href]', fig)[0]; - if (a) { - a.parentNode.insertBefore(img, a); - editor.dom.remove(a); - } - } - }; - var linkImageFigure = function (editor, fig, attrs) { - var a, img; - img = editor.dom.select('img', fig)[0]; - if (img) { - a = editor.dom.create('a', attrs); - img.parentNode.insertBefore(a, img); - a.appendChild(img); - } - }; - var $_5298ug0jjgweci0 = { - link: link, - unlink: unlink, - isLink: isLink, - hasLinks: hasLinks, - isOnlyTextSelected: isOnlyTextSelected, - getAnchorElement: getAnchorElement, - getAnchorText: getAnchorText, - toggleTargetRules: toggleTargetRules - }; - var global$5 = tinymce.util.Tools.resolve('tinymce.util.Delay'); + var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - var global$6 = tinymce.util.Tools.resolve('tinymce.util.XHR'); + var global$3 = tinymce.util.Tools.resolve('tinymce.Env'); - var attachState = {}; - var createLinkList = function (editor, callback) { - var linkList = $_1b4wbxfvjjgwechi.getLinkList(editor.settings); - if (typeof linkList === 'string') { - global$6.send({ - url: linkList, - success: function (text) { - callback(editor, JSON.parse(text)); - } - }); - } else if (typeof linkList === 'function') { - linkList(function (list) { - callback(editor, list); - }); - } else { - callback(editor, linkList); - } - }; - var buildListItems = function (inputList, itemCallback, startItems) { - var appendItems = function (values, output) { - output = output || []; - global$4.each(values, function (item) { - var menuItem = { text: item.text || item.title }; - if (item.menu) { - menuItem.menu = appendItems(item.menu); - } else { - menuItem.value = item.value; - if (itemCallback) { - itemCallback(menuItem); - } - } - output.push(menuItem); - }); - return output; + var appendClickRemove = function (link, evt) { + document.body.appendChild(link); + link.dispatchEvent(evt); + document.body.removeChild(link); }; - return appendItems(inputList, startItems || []); - }; - var delayedConfirm = function (editor, message, callback) { - var rng = editor.selection.getRng(); - global$5.setEditorTimeout(editor, function () { - editor.windowManager.confirm(message, function (state) { - editor.selection.setRng(rng); - callback(state); - }); - }); - }; - var showDialog = function (editor, linkList) { - var data = {}; - var selection = editor.selection; - var dom = editor.dom; - var anchorElm, initialText; - var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value; - var linkListChangeHandler = function (e) { - var textCtrl = win.find('#text'); - if (!textCtrl.value() || e.lastControl && textCtrl.value() === e.lastControl.text()) { - textCtrl.value(e.control.text()); - } - win.find('#href').value(e.control.value()); - }; - var buildAnchorListControl = function (url) { - var anchorList = []; - global$4.each(editor.dom.select('a:not([href])'), function (anchor) { - var id = anchor.name || anchor.id; - if (id) { - anchorList.push({ - text: id, - value: '#' + id, - selected: url.indexOf('#' + id) !== -1 - }); - } - }); - if (anchorList.length) { - anchorList.unshift({ - text: 'None', - value: '' - }); - return { - name: 'anchor', - type: 'listbox', - label: 'Anchors', - values: anchorList, - onselect: linkListChangeHandler - }; - } - }; - var updateText = function () { - if (!initialText && onlyText && !data.text) { - this.parent().parent().find('#text')[0].value(this.value()); - } - }; - var urlChange = function (e) { - var meta = e.meta || {}; - if (linkListCtrl) { - linkListCtrl.value(editor.convertURL(this.value(), 'href')); - } - global$4.each(e.meta, function (value, key) { - var inp = win.find('#' + key); - if (key === 'text') { - if (initialText.length === 0) { - inp.value(value); - data.text = value; - } - } else { - inp.value(value); - } - }); - if (meta.attach) { - attachState = { - href: this.value(), - attach: meta.attach - }; - } - if (!meta.text) { - updateText.call(this); - } - }; - var onBeforeCall = function (e) { - e.meta = win.toJSON(); - }; - onlyText = $_5298ug0jjgweci0.isOnlyTextSelected(selection.getContent()); - anchorElm = $_5298ug0jjgweci0.getAnchorElement(editor); - data.text = initialText = $_5298ug0jjgweci0.getAnchorText(editor.selection, anchorElm); - data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : ''; - if (anchorElm) { - data.target = dom.getAttrib(anchorElm, 'target'); - } else if ($_1b4wbxfvjjgwechi.hasDefaultLinkTarget(editor.settings)) { - data.target = $_1b4wbxfvjjgwechi.getDefaultLinkTarget(editor.settings); - } - if (value = dom.getAttrib(anchorElm, 'rel')) { - data.rel = value; - } - if (value = dom.getAttrib(anchorElm, 'class')) { - data.class = value; - } - if (value = dom.getAttrib(anchorElm, 'title')) { - data.title = value; - } - if (onlyText) { - textListCtrl = { - name: 'text', - type: 'textbox', - size: 40, - label: 'Text to display', - onchange: function () { - data.text = this.value(); - } - }; - } - if (linkList) { - linkListCtrl = { - type: 'listbox', - label: 'Link list', - values: buildListItems(linkList, function (item) { - item.value = editor.convertURL(item.value || item.url, 'href'); - }, [{ - text: 'None', - value: '' - }]), - onselect: linkListChangeHandler, - value: editor.convertURL(data.href, 'href'), - onPostRender: function () { - linkListCtrl = this; - } - }; - } - if ($_1b4wbxfvjjgwechi.shouldShowTargetList(editor.settings)) { - if ($_1b4wbxfvjjgwechi.getTargetList(editor.settings) === undefined) { - $_1b4wbxfvjjgwechi.setTargetList(editor, [ - { - text: 'None', - value: '' - }, - { - text: 'New window', - value: '_blank' - } - ]); - } - targetListCtrl = { - name: 'target', - type: 'listbox', - label: 'Target', - values: buildListItems($_1b4wbxfvjjgwechi.getTargetList(editor.settings)) - }; - } - if ($_1b4wbxfvjjgwechi.hasRelList(editor.settings)) { - relListCtrl = { - name: 'rel', - type: 'listbox', - label: 'Rel', - values: buildListItems($_1b4wbxfvjjgwechi.getRelList(editor.settings), function (item) { - if ($_1b4wbxfvjjgwechi.allowUnsafeLinkTarget(editor.settings) === false) { - item.value = $_5298ug0jjgweci0.toggleTargetRules(item.value, data.target === '_blank'); - } - }) - }; - } - if ($_1b4wbxfvjjgwechi.hasLinkClassList(editor.settings)) { - classListCtrl = { - name: 'class', - type: 'listbox', - label: 'Class', - values: buildListItems($_1b4wbxfvjjgwechi.getLinkClassList(editor.settings), function (item) { - if (item.value) { - item.textStyle = function () { - return editor.formatter.getCssText({ - inline: 'a', - classes: [item.value] - }); - }; - } - }) - }; - } - if ($_1b4wbxfvjjgwechi.shouldShowLinkTitle(editor.settings)) { - linkTitleCtrl = { - name: 'title', - type: 'textbox', - label: 'Title', - value: data.title - }; - } - win = editor.windowManager.open({ - title: 'Insert link', - data: data, - body: [ - { - name: 'href', - type: 'filepicker', - filetype: 'file', - size: 40, - autofocus: true, - label: 'Url', - onchange: urlChange, - onkeyup: updateText, - onpaste: updateText, - onbeforecall: onBeforeCall - }, - textListCtrl, - linkTitleCtrl, - buildAnchorListControl(data.href), - linkListCtrl, - relListCtrl, - targetListCtrl, - classListCtrl - ], - onSubmit: function (e) { - var assumeExternalTargets = $_1b4wbxfvjjgwechi.assumeExternalTargets(editor.settings); - var insertLink = $_5298ug0jjgweci0.link(editor, attachState); - var removeLink = $_5298ug0jjgweci0.unlink(editor); - var resultData = global$4.extend({}, data, e.data); - var href = resultData.href; - if (!href) { - removeLink(); - return; - } - if (!onlyText || resultData.text === initialText) { - delete resultData.text; - } - if (href.indexOf('@') > 0 && href.indexOf('//') === -1 && href.indexOf('mailto:') === -1) { - delayedConfirm(editor, 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?', function (state) { - if (state) { - resultData.href = 'mailto:' + href; - } - insertLink(resultData); - }); - return; - } - if (assumeExternalTargets === true && !/^\w+:/i.test(href) || assumeExternalTargets === false && /^\s*www[\.|\d\.]/i.test(href)) { - delayedConfirm(editor, 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?', function (state) { - if (state) { - resultData.href = 'http://' + href; - } - insertLink(resultData); - }); - return; - } - insertLink(resultData); - } - }); - }; - var open$1 = function (editor) { - createLinkList(editor, showDialog); - }; - var $_dxaplrg2jjgweci6 = { open: open$1 }; - - var getLink = function (editor, elm) { - return editor.dom.getParent(elm, 'a[href]'); - }; - var getSelectedLink = function (editor) { - return getLink(editor, editor.selection.getStart()); - }; - var getHref = function (elm) { - var href = elm.getAttribute('data-mce-href'); - return href ? href : elm.getAttribute('href'); - }; - var isContextMenuVisible = function (editor) { - var contextmenu = editor.plugins.contextmenu; - return contextmenu ? contextmenu.isContextMenuVisible() : false; - }; - var hasOnlyAltModifier = function (e) { - return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false; - }; - var gotoLink = function (editor, a) { - if (a) { - var href = getHref(a); - if (/^#/.test(href)) { - var targetEl = editor.$(href); - if (targetEl.length) { - editor.selection.scrollIntoView(targetEl[0], true); - } + var open$$1 = function (url) { + if (!global$3.ie || global$3.ie > 10) { + var link = document.createElement('a'); + link.target = '_blank'; + link.href = url; + link.rel = 'noreferrer noopener'; + var evt = document.createEvent('MouseEvents'); + evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + appendClickRemove(link, evt); } else { - $_du0gebfwjjgwechl.open(a.href); - } - } - }; - var openDialog = function (editor) { - return function () { - $_dxaplrg2jjgweci6.open(editor); - }; - }; - var gotoSelectedLink = function (editor) { - return function () { - gotoLink(editor, getSelectedLink(editor)); - }; - }; - var leftClickedOnAHref = function (editor) { - return function (elm) { - var sel, rng, node; - if ($_1b4wbxfvjjgwechi.hasContextToolbar(editor.settings) && !isContextMenuVisible(editor) && $_5298ug0jjgweci0.isLink(elm)) { - sel = editor.selection; - rng = sel.getRng(); - node = rng.startContainer; - if (node.nodeType === 3 && sel.isCollapsed() && rng.startOffset > 0 && rng.startOffset < node.data.length) { - return true; + var win = window.open('', '_blank'); + if (win) { + win.opener = null; + var doc = win.document; + doc.open(); + doc.write(''); + doc.close(); } } - return false; }; - }; - var setupGotoLinks = function (editor) { - editor.on('click', function (e) { - var link = getLink(editor, e.target); - if (link && global$1.metaKeyPressed(e)) { - e.preventDefault(); - gotoLink(editor, link); + var OpenUrl = { open: open$$1 }; + + var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var toggleTargetRules = function (rel, isUnsafe) { + var rules = ['noopener']; + var newRel = rel ? rel.split(/\s+/) : []; + var toString = function (rel) { + return global$4.trim(rel.sort().join(' ')); + }; + var addTargetRules = function (rel) { + rel = removeTargetRules(rel); + return rel.length ? rel.concat(rules) : rules; + }; + var removeTargetRules = function (rel) { + return rel.filter(function (val) { + return global$4.inArray(rules, val) === -1; + }); + }; + newRel = isUnsafe ? addTargetRules(newRel) : removeTargetRules(newRel); + return newRel.length ? toString(newRel) : null; + }; + var trimCaretContainers = function (text) { + return text.replace(/\uFEFF/g, ''); + }; + var getAnchorElement = function (editor, selectedElm) { + selectedElm = selectedElm || editor.selection.getNode(); + if (isImageFigure(selectedElm)) { + return editor.dom.select('a[href]', selectedElm)[0]; + } else { + return editor.dom.getParent(selectedElm, 'a[href]'); } - }); - editor.on('keydown', function (e) { - var link = getSelectedLink(editor); - if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) { - e.preventDefault(); - gotoLink(editor, link); + }; + var getAnchorText = function (selection, anchorElm) { + var text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' }); + return trimCaretContainers(text); + }; + var isLink = function (elm) { + return elm && elm.nodeName === 'A' && elm.href; + }; + var hasLinks = function (elements) { + return global$4.grep(elements, isLink).length > 0; + }; + var isOnlyTextSelected = function (html) { + if (/]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') === -1)) { + return false; } - }); - }; - var toggleActiveState = function (editor) { - return function () { - var self = this; - editor.on('nodechange', function (e) { - self.active(!editor.readonly && !!$_5298ug0jjgweci0.getAnchorElement(editor, e.element)); + return true; + }; + var isImageFigure = function (node) { + return node && node.nodeName === 'FIGURE' && /\bimage\b/i.test(node.className); + }; + var link = function (editor, attachState) { + return function (data) { + editor.undoManager.transact(function () { + var selectedElm = editor.selection.getNode(); + var anchorElm = getAnchorElement(editor, selectedElm); + var linkAttrs = { + href: data.href, + target: data.target ? data.target : null, + rel: data.rel ? data.rel : null, + class: data.class ? data.class : null, + title: data.title ? data.title : null + }; + if (!Settings.hasRelList(editor.settings) && Settings.allowUnsafeLinkTarget(editor.settings) === false) { + linkAttrs.rel = toggleTargetRules(linkAttrs.rel, linkAttrs.target === '_blank'); + } + if (data.href === attachState.href) { + attachState.attach(); + attachState = {}; + } + if (anchorElm) { + editor.focus(); + if (data.hasOwnProperty('text')) { + if ('innerText' in anchorElm) { + anchorElm.innerText = data.text; + } else { + anchorElm.textContent = data.text; + } + } + editor.dom.setAttribs(anchorElm, linkAttrs); + editor.selection.select(anchorElm); + editor.undoManager.add(); + } else { + if (isImageFigure(selectedElm)) { + linkImageFigure(editor, selectedElm, linkAttrs); + } else if (data.hasOwnProperty('text')) { + editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(data.text))); + } else { + editor.execCommand('mceInsertLink', false, linkAttrs); + } + } + }); + }; + }; + var unlink = function (editor) { + return function () { + editor.undoManager.transact(function () { + var node = editor.selection.getNode(); + if (isImageFigure(node)) { + unlinkImageFigure(editor, node); + } else { + editor.execCommand('unlink'); + } + }); + }; + }; + var unlinkImageFigure = function (editor, fig) { + var a, img; + img = editor.dom.select('img', fig)[0]; + if (img) { + a = editor.dom.getParents(img, 'a[href]', fig)[0]; + if (a) { + a.parentNode.insertBefore(img, a); + editor.dom.remove(a); + } + } + }; + var linkImageFigure = function (editor, fig, attrs) { + var a, img; + img = editor.dom.select('img', fig)[0]; + if (img) { + a = editor.dom.create('a', attrs); + img.parentNode.insertBefore(a, img); + a.appendChild(img); + } + }; + var Utils = { + link: link, + unlink: unlink, + isLink: isLink, + hasLinks: hasLinks, + isOnlyTextSelected: isOnlyTextSelected, + getAnchorElement: getAnchorElement, + getAnchorText: getAnchorText, + toggleTargetRules: toggleTargetRules + }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.util.Delay'); + + var global$6 = tinymce.util.Tools.resolve('tinymce.util.XHR'); + + var attachState = {}; + var createLinkList = function (editor, callback) { + var linkList = Settings.getLinkList(editor.settings); + if (typeof linkList === 'string') { + global$6.send({ + url: linkList, + success: function (text) { + callback(editor, JSON.parse(text)); + } + }); + } else if (typeof linkList === 'function') { + linkList(function (list) { + callback(editor, list); + }); + } else { + callback(editor, linkList); + } + }; + var buildListItems = function (inputList, itemCallback, startItems) { + var appendItems = function (values, output) { + output = output || []; + global$4.each(values, function (item) { + var menuItem = { text: item.text || item.title }; + if (item.menu) { + menuItem.menu = appendItems(item.menu); + } else { + menuItem.value = item.value; + if (itemCallback) { + itemCallback(menuItem); + } + } + output.push(menuItem); + }); + return output; + }; + return appendItems(inputList, startItems || []); + }; + var delayedConfirm = function (editor, message, callback) { + var rng = editor.selection.getRng(); + global$5.setEditorTimeout(editor, function () { + editor.windowManager.confirm(message, function (state) { + editor.selection.setRng(rng); + callback(state); + }); }); }; - }; - var toggleViewLinkState = function (editor) { - return function () { - var self = this; - var toggleVisibility = function (e) { - if ($_5298ug0jjgweci0.hasLinks(e.parents)) { - self.show(); + var showDialog = function (editor, linkList) { + var data = {}; + var selection = editor.selection; + var dom = editor.dom; + var anchorElm, initialText; + var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value; + var linkListChangeHandler = function (e) { + var textCtrl = win.find('#text'); + if (!textCtrl.value() || e.lastControl && textCtrl.value() === e.lastControl.text()) { + textCtrl.value(e.control.text()); + } + win.find('#href').value(e.control.value()); + }; + var buildAnchorListControl = function (url) { + var anchorList = []; + global$4.each(editor.dom.select('a:not([href])'), function (anchor) { + var id = anchor.name || anchor.id; + if (id) { + anchorList.push({ + text: id, + value: '#' + id, + selected: url.indexOf('#' + id) !== -1 + }); + } + }); + if (anchorList.length) { + anchorList.unshift({ + text: 'None', + value: '' + }); + return { + name: 'anchor', + type: 'listbox', + label: 'Anchors', + values: anchorList, + onselect: linkListChangeHandler + }; + } + }; + var updateText = function () { + if (!initialText && onlyText && !data.text) { + this.parent().parent().find('#text')[0].value(this.value()); + } + }; + var urlChange = function (e) { + var meta = e.meta || {}; + if (linkListCtrl) { + linkListCtrl.value(editor.convertURL(this.value(), 'href')); + } + global$4.each(e.meta, function (value, key) { + var inp = win.find('#' + key); + if (key === 'text') { + if (initialText.length === 0) { + inp.value(value); + data.text = value; + } + } else { + inp.value(value); + } + }); + if (meta.attach) { + attachState = { + href: this.value(), + attach: meta.attach + }; + } + if (!meta.text) { + updateText.call(this); + } + }; + var onBeforeCall = function (e) { + e.meta = win.toJSON(); + }; + onlyText = Utils.isOnlyTextSelected(selection.getContent()); + anchorElm = Utils.getAnchorElement(editor); + data.text = initialText = Utils.getAnchorText(editor.selection, anchorElm); + data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : ''; + if (anchorElm) { + data.target = dom.getAttrib(anchorElm, 'target'); + } else if (Settings.hasDefaultLinkTarget(editor.settings)) { + data.target = Settings.getDefaultLinkTarget(editor.settings); + } + if (value = dom.getAttrib(anchorElm, 'rel')) { + data.rel = value; + } + if (value = dom.getAttrib(anchorElm, 'class')) { + data.class = value; + } + if (value = dom.getAttrib(anchorElm, 'title')) { + data.title = value; + } + if (onlyText) { + textListCtrl = { + name: 'text', + type: 'textbox', + size: 40, + label: 'Text to display', + onchange: function () { + data.text = this.value(); + } + }; + } + if (linkList) { + linkListCtrl = { + type: 'listbox', + label: 'Link list', + values: buildListItems(linkList, function (item) { + item.value = editor.convertURL(item.value || item.url, 'href'); + }, [{ + text: 'None', + value: '' + }]), + onselect: linkListChangeHandler, + value: editor.convertURL(data.href, 'href'), + onPostRender: function () { + linkListCtrl = this; + } + }; + } + if (Settings.shouldShowTargetList(editor.settings)) { + if (Settings.getTargetList(editor.settings) === undefined) { + Settings.setTargetList(editor, [ + { + text: 'None', + value: '' + }, + { + text: 'New window', + value: '_blank' + } + ]); + } + targetListCtrl = { + name: 'target', + type: 'listbox', + label: 'Target', + values: buildListItems(Settings.getTargetList(editor.settings)) + }; + } + if (Settings.hasRelList(editor.settings)) { + relListCtrl = { + name: 'rel', + type: 'listbox', + label: 'Rel', + values: buildListItems(Settings.getRelList(editor.settings), function (item) { + if (Settings.allowUnsafeLinkTarget(editor.settings) === false) { + item.value = Utils.toggleTargetRules(item.value, data.target === '_blank'); + } + }) + }; + } + if (Settings.hasLinkClassList(editor.settings)) { + classListCtrl = { + name: 'class', + type: 'listbox', + label: 'Class', + values: buildListItems(Settings.getLinkClassList(editor.settings), function (item) { + if (item.value) { + item.textStyle = function () { + return editor.formatter.getCssText({ + inline: 'a', + classes: [item.value] + }); + }; + } + }) + }; + } + if (Settings.shouldShowLinkTitle(editor.settings)) { + linkTitleCtrl = { + name: 'title', + type: 'textbox', + label: 'Title', + value: data.title + }; + } + win = editor.windowManager.open({ + title: 'Insert link', + data: data, + body: [ + { + name: 'href', + type: 'filepicker', + filetype: 'file', + size: 40, + autofocus: true, + label: 'Url', + onchange: urlChange, + onkeyup: updateText, + onpaste: updateText, + onbeforecall: onBeforeCall + }, + textListCtrl, + linkTitleCtrl, + buildAnchorListControl(data.href), + linkListCtrl, + relListCtrl, + targetListCtrl, + classListCtrl + ], + onSubmit: function (e) { + var assumeExternalTargets = Settings.assumeExternalTargets(editor.settings); + var insertLink = Utils.link(editor, attachState); + var removeLink = Utils.unlink(editor); + var resultData = global$4.extend({}, data, e.data); + var href = resultData.href; + if (!href) { + removeLink(); + return; + } + if (!onlyText || resultData.text === initialText) { + delete resultData.text; + } + if (href.indexOf('@') > 0 && href.indexOf('//') === -1 && href.indexOf('mailto:') === -1) { + delayedConfirm(editor, 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?', function (state) { + if (state) { + resultData.href = 'mailto:' + href; + } + insertLink(resultData); + }); + return; + } + if (assumeExternalTargets === true && !/^\w+:/i.test(href) || assumeExternalTargets === false && /^\s*www[\.|\d\.]/i.test(href)) { + delayedConfirm(editor, 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?', function (state) { + if (state) { + resultData.href = 'http://' + href; + } + insertLink(resultData); + }); + return; + } + insertLink(resultData); + } + }); + }; + var open$1 = function (editor) { + createLinkList(editor, showDialog); + }; + var Dialog = { open: open$1 }; + + var getLink = function (editor, elm) { + return editor.dom.getParent(elm, 'a[href]'); + }; + var getSelectedLink = function (editor) { + return getLink(editor, editor.selection.getStart()); + }; + var getHref = function (elm) { + var href = elm.getAttribute('data-mce-href'); + return href ? href : elm.getAttribute('href'); + }; + var isContextMenuVisible = function (editor) { + var contextmenu = editor.plugins.contextmenu; + return contextmenu ? contextmenu.isContextMenuVisible() : false; + }; + var hasOnlyAltModifier = function (e) { + return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false; + }; + var gotoLink = function (editor, a) { + if (a) { + var href = getHref(a); + if (/^#/.test(href)) { + var targetEl = editor.$(href); + if (targetEl.length) { + editor.selection.scrollIntoView(targetEl[0], true); + } } else { + OpenUrl.open(a.href); + } + } + }; + var openDialog = function (editor) { + return function () { + Dialog.open(editor); + }; + }; + var gotoSelectedLink = function (editor) { + return function () { + gotoLink(editor, getSelectedLink(editor)); + }; + }; + var leftClickedOnAHref = function (editor) { + return function (elm) { + var sel, rng, node; + if (Settings.hasContextToolbar(editor.settings) && !isContextMenuVisible(editor) && Utils.isLink(elm)) { + sel = editor.selection; + rng = sel.getRng(); + node = rng.startContainer; + if (node.nodeType === 3 && sel.isCollapsed() && rng.startOffset > 0 && rng.startOffset < node.data.length) { + return true; + } + } + return false; + }; + }; + var setupGotoLinks = function (editor) { + editor.on('click', function (e) { + var link = getLink(editor, e.target); + if (link && global$1.metaKeyPressed(e)) { + e.preventDefault(); + gotoLink(editor, link); + } + }); + editor.on('keydown', function (e) { + var link = getSelectedLink(editor); + if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) { + e.preventDefault(); + gotoLink(editor, link); + } + }); + }; + var toggleActiveState = function (editor) { + return function () { + var self = this; + editor.on('nodechange', function (e) { + self.active(!editor.readonly && !!Utils.getAnchorElement(editor, e.element)); + }); + }; + }; + var toggleViewLinkState = function (editor) { + return function () { + var self = this; + var toggleVisibility = function (e) { + if (Utils.hasLinks(e.parents)) { + self.show(); + } else { + self.hide(); + } + }; + if (!Utils.hasLinks(editor.dom.getParents(editor.selection.getStart()))) { self.hide(); } + editor.on('nodechange', toggleVisibility); + self.on('remove', function () { + editor.off('nodechange', toggleVisibility); + }); }; - if (!$_5298ug0jjgweci0.hasLinks(editor.dom.getParents(editor.selection.getStart()))) { - self.hide(); + }; + var Actions = { + openDialog: openDialog, + gotoSelectedLink: gotoSelectedLink, + leftClickedOnAHref: leftClickedOnAHref, + setupGotoLinks: setupGotoLinks, + toggleActiveState: toggleActiveState, + toggleViewLinkState: toggleViewLinkState + }; + + var register = function (editor) { + editor.addCommand('mceLink', Actions.openDialog(editor)); + }; + var Commands = { register: register }; + + var setup = function (editor) { + editor.addShortcut('Meta+K', '', Actions.openDialog(editor)); + }; + var Keyboard = { setup: setup }; + + var setupButtons = function (editor) { + editor.addButton('link', { + active: false, + icon: 'link', + tooltip: 'Insert/edit link', + onclick: Actions.openDialog(editor), + onpostrender: Actions.toggleActiveState(editor) + }); + editor.addButton('unlink', { + active: false, + icon: 'unlink', + tooltip: 'Remove link', + onclick: Utils.unlink(editor), + onpostrender: Actions.toggleActiveState(editor) + }); + if (editor.addContextToolbar) { + editor.addButton('openlink', { + icon: 'newtab', + tooltip: 'Open link', + onclick: Actions.gotoSelectedLink(editor) + }); } - editor.on('nodechange', toggleVisibility); - self.on('remove', function () { - editor.off('nodechange', toggleVisibility); + }; + var setupMenuItems = function (editor) { + editor.addMenuItem('openlink', { + text: 'Open link', + icon: 'newtab', + onclick: Actions.gotoSelectedLink(editor), + onPostRender: Actions.toggleViewLinkState(editor), + prependToContext: true + }); + editor.addMenuItem('link', { + icon: 'link', + text: 'Link', + shortcut: 'Meta+K', + onclick: Actions.openDialog(editor), + stateSelector: 'a[href]', + context: 'insert', + prependToContext: true + }); + editor.addMenuItem('unlink', { + icon: 'unlink', + text: 'Remove link', + onclick: Utils.unlink(editor), + stateSelector: 'a[href]' }); }; - }; - var $_8hceq8ftjjgweche = { - openDialog: openDialog, - gotoSelectedLink: gotoSelectedLink, - leftClickedOnAHref: leftClickedOnAHref, - setupGotoLinks: setupGotoLinks, - toggleActiveState: toggleActiveState, - toggleViewLinkState: toggleViewLinkState - }; + var setupContextToolbars = function (editor) { + if (editor.addContextToolbar) { + editor.addContextToolbar(Actions.leftClickedOnAHref(editor), 'openlink | link unlink'); + } + }; + var Controls = { + setupButtons: setupButtons, + setupMenuItems: setupMenuItems, + setupContextToolbars: setupContextToolbars + }; - var register = function (editor) { - editor.addCommand('mceLink', $_8hceq8ftjjgweche.openDialog(editor)); - }; - var $_bauc80fsjjgwechc = { register: register }; - - var setup = function (editor) { - editor.addShortcut('Meta+K', '', $_8hceq8ftjjgweche.openDialog(editor)); - }; - var $_49u4p1g5jjgwecie = { setup: setup }; - - var setupButtons = function (editor) { - editor.addButton('link', { - active: false, - icon: 'link', - tooltip: 'Insert/edit link', - onclick: $_8hceq8ftjjgweche.openDialog(editor), - onpostrender: $_8hceq8ftjjgweche.toggleActiveState(editor) + global.add('link', function (editor) { + Controls.setupButtons(editor); + Controls.setupMenuItems(editor); + Controls.setupContextToolbars(editor); + Actions.setupGotoLinks(editor); + Commands.register(editor); + Keyboard.setup(editor); }); - editor.addButton('unlink', { - active: false, - icon: 'unlink', - tooltip: 'Remove link', - onclick: $_5298ug0jjgweci0.unlink(editor), - onpostrender: $_8hceq8ftjjgweche.toggleActiveState(editor) - }); - if (editor.addContextToolbar) { - editor.addButton('openlink', { - icon: 'newtab', - tooltip: 'Open link', - onclick: $_8hceq8ftjjgweche.gotoSelectedLink(editor) - }); + function Plugin () { } - }; - var setupMenuItems = function (editor) { - editor.addMenuItem('openlink', { - text: 'Open link', - icon: 'newtab', - onclick: $_8hceq8ftjjgweche.gotoSelectedLink(editor), - onPostRender: $_8hceq8ftjjgweche.toggleViewLinkState(editor), - prependToContext: true - }); - editor.addMenuItem('link', { - icon: 'link', - text: 'Link', - shortcut: 'Meta+K', - onclick: $_8hceq8ftjjgweche.openDialog(editor), - stateSelector: 'a[href]', - context: 'insert', - prependToContext: true - }); - editor.addMenuItem('unlink', { - icon: 'unlink', - text: 'Remove link', - onclick: $_5298ug0jjgweci0.unlink(editor), - stateSelector: 'a[href]' - }); - }; - var setupContextToolbars = function (editor) { - if (editor.addContextToolbar) { - editor.addContextToolbar($_8hceq8ftjjgweche.leftClickedOnAHref(editor), 'openlink | link unlink'); - } - }; - var $_bn93cg6jjgwecif = { - setupButtons: setupButtons, - setupMenuItems: setupMenuItems, - setupContextToolbars: setupContextToolbars - }; - global.add('link', function (editor) { - $_bn93cg6jjgwecif.setupButtons(editor); - $_bn93cg6jjgwecif.setupMenuItems(editor); - $_bn93cg6jjgwecif.setupContextToolbars(editor); - $_8hceq8ftjjgweche.setupGotoLinks(editor); - $_bauc80fsjjgwechc.register(editor); - $_49u4p1g5jjgwecie.setup(editor); - }); - function Plugin () { - } - - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/lists/plugin.js b/wp-includes/js/tinymce/plugins/lists/plugin.js index 46d742a65c..e6a4edda7f 100644 --- a/wp-includes/js/tinymce/plugins/lists/plugin.js +++ b/wp-includes/js/tinymce/plugins/lists/plugin.js @@ -1,1114 +1,2181 @@ (function () { var lists = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var global$1 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); - var global$2 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); + var global$2 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); - var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK'); + var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK'); - var global$4 = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager'); + var global$4 = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager'); - var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - var global$6 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + var global$6 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - var isTextNode = function (node) { - return node && node.nodeType === 3; - }; - var isListNode = function (node) { - return node && /^(OL|UL|DL)$/.test(node.nodeName); - }; - var isListItemNode = function (node) { - return node && /^(LI|DT|DD)$/.test(node.nodeName); - }; - var isTableCellNode = function (node) { - return node && /^(TH|TD)$/.test(node.nodeName); - }; - var isBr = function (node) { - return node && node.nodeName === 'BR'; - }; - var isFirstChild = function (node) { - return node.parentNode.firstChild === node; - }; - var isLastChild = function (node) { - return node.parentNode.lastChild === node; - }; - var isTextBlock = function (editor, node) { - return node && !!editor.schema.getTextBlockElements()[node.nodeName]; - }; - var isBlock = function (node, blockElements) { - return node && node.nodeName in blockElements; - }; - var isBogusBr = function (dom, node) { - if (!isBr(node)) { + var isTextNode = function (node) { + return node && node.nodeType === 3; + }; + var isListNode = function (node) { + return node && /^(OL|UL|DL)$/.test(node.nodeName); + }; + var isOlUlNode = function (node) { + return node && /^(OL|UL)$/.test(node.nodeName); + }; + var isListItemNode = function (node) { + return node && /^(LI|DT|DD)$/.test(node.nodeName); + }; + var isDlItemNode = function (node) { + return node && /^(DT|DD)$/.test(node.nodeName); + }; + var isTableCellNode = function (node) { + return node && /^(TH|TD)$/.test(node.nodeName); + }; + var isBr = function (node) { + return node && node.nodeName === 'BR'; + }; + var isFirstChild = function (node) { + return node.parentNode.firstChild === node; + }; + var isLastChild = function (node) { + return node.parentNode.lastChild === node; + }; + var isTextBlock = function (editor, node) { + return node && !!editor.schema.getTextBlockElements()[node.nodeName]; + }; + var isBlock = function (node, blockElements) { + return node && node.nodeName in blockElements; + }; + var isBogusBr = function (dom, node) { + if (!isBr(node)) { + return false; + } + if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) { + return true; + } return false; - } - if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) { - return true; - } - return false; - }; - var isEmpty = function (dom, elm, keepBookmarks) { - var empty = dom.isEmpty(elm); - if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) { - return false; - } - return empty; - }; - var isChildOfBody = function (dom, elm) { - return dom.isChildOf(elm, dom.getRoot()); - }; - var $_okk1ogljjgweckx = { - isTextNode: isTextNode, - isListNode: isListNode, - isListItemNode: isListItemNode, - isTableCellNode: isTableCellNode, - isBr: isBr, - isFirstChild: isFirstChild, - isLastChild: isLastChild, - isTextBlock: isTextBlock, - isBlock: isBlock, - isBogusBr: isBogusBr, - isEmpty: isEmpty, - isChildOfBody: isChildOfBody - }; + }; + var isEmpty = function (dom, elm, keepBookmarks) { + var empty = dom.isEmpty(elm); + if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) { + return false; + } + return empty; + }; + var isChildOfBody = function (dom, elm) { + return dom.isChildOf(elm, dom.getRoot()); + }; + var NodeType = { + isTextNode: isTextNode, + isListNode: isListNode, + isOlUlNode: isOlUlNode, + isDlItemNode: isDlItemNode, + isListItemNode: isListItemNode, + isTableCellNode: isTableCellNode, + isBr: isBr, + isFirstChild: isFirstChild, + isLastChild: isLastChild, + isTextBlock: isTextBlock, + isBlock: isBlock, + isBogusBr: isBogusBr, + isEmpty: isEmpty, + isChildOfBody: isChildOfBody + }; - var getNormalizedEndPoint = function (container, offset) { - var node = global$1.getNode(container, offset); - if ($_okk1ogljjgweckx.isListItemNode(container) && $_okk1ogljjgweckx.isTextNode(node)) { - var textNodeOffset = offset >= container.childNodes.length ? node.data.length : 0; + var getNormalizedPoint = function (container, offset) { + if (NodeType.isTextNode(container)) { + return { + container: container, + offset: offset + }; + } + var node = global$1.getNode(container, offset); + if (NodeType.isTextNode(node)) { + return { + container: node, + offset: offset >= container.childNodes.length ? node.data.length : 0 + }; + } else if (node.previousSibling && NodeType.isTextNode(node.previousSibling)) { + return { + container: node.previousSibling, + offset: node.previousSibling.data.length + }; + } else if (node.nextSibling && NodeType.isTextNode(node.nextSibling)) { + return { + container: node.nextSibling, + offset: 0 + }; + } return { - container: node, - offset: textNodeOffset + container: container, + offset: offset + }; + }; + var normalizeRange = function (rng) { + var outRng = rng.cloneRange(); + var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset); + outRng.setStart(rangeStart.container, rangeStart.offset); + var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset); + outRng.setEnd(rangeEnd.container, rangeEnd.offset); + return outRng; + }; + var Range = { + getNormalizedPoint: getNormalizedPoint, + normalizeRange: normalizeRange + }; + + var DOM = global$6.DOM; + var createBookmark = function (rng) { + var bookmark = {}; + var setupEndPoint = function (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 resolveBookmark = function (bookmark) { + function restoreEndPoint(start) { + var container, offset, node; + var nodeIndex = function (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); + if (!container.hasChildNodes() && DOM.isBlock(container)) { + container.appendChild(DOM.create('br')); + } + } + 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 Range.normalizeRange(rng); + }; + var Bookmark = { + createBookmark: createBookmark, + resolveBookmark: resolveBookmark + }; + + var constant = function (value) { + return function () { + return value; + }; + }; + function curry(fn) { + var initialArgs = []; + for (var _i = 1; _i < arguments.length; _i++) { + initialArgs[_i - 1] = arguments[_i]; + } + return function () { + var restArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + restArgs[_i] = arguments[_i]; + } + var all = initialArgs.concat(restArgs); + return fn.apply(null, all); }; } - return { - container: container, - offset: offset + var not = function (f) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !f.apply(null, args); + }; }; - }; - var normalizeRange = function (rng) { - var outRng = rng.cloneRange(); - var rangeStart = getNormalizedEndPoint(rng.startContainer, rng.startOffset); - outRng.setStart(rangeStart.container, rangeStart.offset); - var rangeEnd = getNormalizedEndPoint(rng.endContainer, rng.endOffset); - outRng.setEnd(rangeEnd.container, rangeEnd.offset); - return outRng; - }; - var $_a9cyhvgkjjgweckv = { - getNormalizedEndPoint: getNormalizedEndPoint, - normalizeRange: normalizeRange - }; + var never = constant(false); + var always = constant(true); - var DOM = global$6.DOM; - var createBookmark = function (rng) { - var bookmark = {}; - var setupEndPoint = function (start) { - var offsetNode, container, offset; + var never$1 = never; + var always$1 = always; + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call$$1 = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var noop$$1 = function () { + }; + var nul = function () { + return null; + }; + var undef = function () { + return undefined; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never$1, + isSome: never$1, + isNone: always$1, + getOr: id, + getOrThunk: call$$1, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: nul, + getOrUndefined: undef, + or: id, + orThunk: call$$1, + map: none, + ap: none, + each: noop$$1, + bind: none, + flatten: none, + exists: never$1, + forall: always$1, + 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 = function () { + return a; + }; + var self = function () { + return me; + }; + var map = function (f) { + return some(f(a)); + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always$1, + isNone: never$1, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: map, + ap: function (optfab) { + return optfab.fold(none, function (fab) { + return some(fab(a)); + }); + }, + each: function (f) { + f(a); + }, + bind: bind, + flatten: constant_a, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never$1, function (b) { + return elementEq(a, b); + }); + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + } + }; + 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)) + return 'array'; + if (t === 'object' && String.prototype.isPrototypeOf(x)) + return 'string'; + return t; + }; + var isType = function (type) { + return function (value) { + return typeOf(value) === type; + }; + }; + var isString = isType('string'); + var isBoolean = isType('boolean'); + var isFunction = isType('function'); + var isNumber = isType('number'); + + 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, xs); + } + return r; + }; + var each = function (xs, f) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + f(x, i, xs); + } + }; + 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, xs)) { + r.push(x); + } + } + return r; + }; + var groupBy = function (xs, f) { + if (xs.length === 0) { + return []; + } else { + var wasType = f(xs[0]); + var r = []; + var group = []; + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + var type = f(x); + if (type !== wasType) { + r.push(group); + group = []; + } + wasType = type; + group.push(x); + } + if (group.length !== 0) { + r.push(group); + } + 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, xs)) { + return Option.some(x); + } + } + return Option.none(); + }; + var push = Array.prototype.push; + var flatten = function (xs) { + var r = []; + for (var i = 0, len = xs.length; i < len; ++i) { + if (!Array.prototype.isPrototypeOf(xs[i])) + throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); + push.apply(r, xs[i]); + } + return r; + }; + var bind = function (xs, f) { + var output = map(xs, f); + return flatten(output); + }; + var slice = Array.prototype.slice; + var reverse = function (xs) { + var r = slice.call(xs, 0); + r.reverse(); + return r; + }; + var head = function (xs) { + return xs.length === 0 ? Option.none() : Option.some(xs[0]); + }; + var last = function (xs) { + return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]); + }; + var from$1 = isFunction(Array.from) ? Array.from : function (x) { + return slice.call(x); + }; + + var Global = typeof window !== 'undefined' ? 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 name + ' not available on this browser'; + return actual; + }; + var Global$1 = { getOrDie: getOrDie }; + + var htmlElement = function (scope) { + return Global$1.getOrDie('HTMLElement', scope); + }; + var isPrototypeOf = function (x) { + var scope = resolve('ownerDocument.defaultView', x); + return htmlElement(scope).prototype.isPrototypeOf(x); + }; + var HTMLElement = { isPrototypeOf: isPrototypeOf }; + + var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery'); + + var getParentList = function (editor) { + var selectionStart = editor.selection.getStart(true); + return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart)); + }; + var isParentListSelected = function (parentList, selectedBlocks) { + return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList; + }; + var findSubLists = function (parentList) { + return global$5.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm) { + return NodeType.isListNode(elm); + }); + }; + var getSelectedSubLists = function (editor) { + var parentList = getParentList(editor); + var selectedBlocks = editor.selection.getSelectedBlocks(); + if (isParentListSelected(parentList, selectedBlocks)) { + return findSubLists(parentList); + } else { + return global$5.grep(selectedBlocks, function (elm) { + return NodeType.isListNode(elm) && parentList !== elm; + }); + } + }; + var findParentListItemsNodes = function (editor, elms) { + var listItemsElms = global$5.map(elms, function (elm) { + var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm)); + return parentLi ? parentLi : elm; + }); + return global$7.unique(listItemsElms); + }; + var getSelectedListItems = function (editor) { + var selectedBlocks = editor.selection.getSelectedBlocks(); + return global$5.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) { + return NodeType.isListItemNode(block); + }); + }; + var getSelectedDlItems = function (editor) { + return filter(getSelectedListItems(editor), NodeType.isDlItemNode); + }; + var getClosestListRootElm = function (editor, elm) { + var parentTableCell = editor.dom.getParents(elm, 'TD,TH'); + var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody(); + return root; + }; + var findLastParentListNode = function (editor, elm) { + var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm)); + return last(parentLists); + }; + var getSelectedLists = function (editor) { + var firstList = findLastParentListNode(editor, editor.selection.getStart()); + var subsequentLists = filter(editor.selection.getSelectedBlocks(), NodeType.isOlUlNode); + return firstList.toArray().concat(subsequentLists); + }; + var getSelectedListRoots = function (editor) { + var selectedLists = getSelectedLists(editor); + return getUniqueListRoots(editor, selectedLists); + }; + var getUniqueListRoots = function (editor, lists) { + var listRoots = map(lists, function (list) { + return findLastParentListNode(editor, list).getOr(list); + }); + return global$7.unique(listRoots); + }; + var isList = function (editor) { + var list = getParentList(editor); + return HTMLElement.isPrototypeOf(list); + }; + var Selection = { + isList: isList, + getParentList: getParentList, + getSelectedSubLists: getSelectedSubLists, + getSelectedListItems: getSelectedListItems, + getClosestListRootElm: getClosestListRootElm, + getSelectedDlItems: getSelectedDlItems, + getSelectedListRoots: getSelectedListRoots + }; + + 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$1 = { + documentPositionPreceding: documentPositionPreceding, + documentPositionContainedBy: documentPositionContainedBy + }; + + 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 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 = '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, 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), + 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$1 = function (str, substr) { + return str.indexOf(substr) !== -1; + }; + + var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; + var checkContains = function (target) { + return function (uastring) { + return contains$1(uastring, target); + }; + }; + var browsers = [ + { + name: 'Edge', + versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], + search: function (uastring) { + var monstrosity = contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit'); + return monstrosity; + } + }, + { + name: 'Chrome', + versionRegexes: [ + /.*?chrome\/([0-9]+)\.([0-9]+).*/, + normalVersionRegex + ], + search: function (uastring) { + return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe'); + } + }, + { + name: 'IE', + versionRegexes: [ + /.*?msie\ ?([0-9]+)\.([0-9]+).*/, + /.*?rv:([0-9]+)\.([0-9]+).*/ + ], + search: function (uastring) { + return contains$1(uastring, 'msie') || contains$1(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$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit'); + } + } + ]; + var oses = [ + { + name: 'Windows', + search: checkContains('win'), + versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] + }, + { + name: 'iOS', + search: function (uastring) { + return contains$1(uastring, 'iphone') || contains$1(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 = navigator.userAgent; + return PlatformDetection.detect(userAgent); + }); + var PlatformDetection$1 = { detect: detect$3 }; + + var fromHtml = function (html, scope) { + var doc = scope || document; + var div = doc.createElement('div'); + div.innerHTML = html; + if (!div.hasChildNodes() || div.childNodes.length > 1) { + console.error('HTML does not have a single root node', html); + throw 'HTML must have a single root node'; + } + return fromDom(div.childNodes[0]); + }; + var fromTag = function (tag, scope) { + var doc = scope || document; + var node = doc.createElement(tag); + return fromDom(node); + }; + var fromText = function (text, scope) { + var doc = scope || 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$$1 = { + fromHtml: fromHtml, + fromTag: fromTag, + fromText: fromText, + fromDom: fromDom, + fromPoint: fromPoint + }; + + var ATTRIBUTE = Node.ATTRIBUTE_NODE; + var CDATA_SECTION = Node.CDATA_SECTION_NODE; + var COMMENT = Node.COMMENT_NODE; + var DOCUMENT = Node.DOCUMENT_NODE; + var DOCUMENT_TYPE = Node.DOCUMENT_TYPE_NODE; + var DOCUMENT_FRAGMENT = Node.DOCUMENT_FRAGMENT_NODE; + var ELEMENT = Node.ELEMENT_NODE; + var TEXT = Node.TEXT_NODE; + var PROCESSING_INSTRUCTION = Node.PROCESSING_INSTRUCTION_NODE; + var ENTITY_REFERENCE = Node.ENTITY_REFERENCE_NODE; + var ENTITY = Node.ENTITY_NODE; + var NOTATION = Node.NOTATION_NODE; + + var ELEMENT$1 = ELEMENT; + var is = function (element, selector) { + var elem = element.dom(); + if (elem.nodeType !== ELEMENT$1) + return false; + else if (elem.matches !== undefined) + return elem.matches(selector); + else if (elem.msMatchesSelector !== undefined) + return elem.msMatchesSelector(selector); + else if (elem.webkitMatchesSelector !== undefined) + return elem.webkitMatchesSelector(selector); + else if (elem.mozMatchesSelector !== undefined) + return elem.mozMatchesSelector(selector); + else + throw new Error('Browser lacks native selectors'); + }; + + var eq = function (e1, e2) { + return e1.dom() === e2.dom(); + }; + var regularContains = function (e1, e2) { + var d1 = e1.dom(), d2 = e2.dom(); + return d1 === d2 ? false : d1.contains(d2); + }; + var ieContains = function (e1, e2) { + return Node$1.documentPositionContainedBy(e1.dom(), e2.dom()); + }; + var browser = PlatformDetection$1.detect().browser; + var contains$2 = browser.isIE() ? ieContains : regularContains; + var is$1 = is; + + var keys = Object.keys; + var each$1 = function (obj, f) { + var props = keys(obj); + for (var k = 0, len = props.length; k < len; k++) { + var i = props[k]; + var x = obj[i]; + f(x, i, obj); + } + }; + + var name = function (element) { + var r = element.dom().nodeName; + return r.toLowerCase(); + }; + + var rawSet = function (dom, key, value$$1) { + if (isString(value$$1) || isBoolean(value$$1) || isNumber(value$$1)) { + dom.setAttribute(key, value$$1 + ''); + } else { + console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value$$1, ':: Element ', dom); + throw new Error('Attribute value was not simple'); + } + }; + var setAll = function (element, attrs) { + var dom = element.dom(); + each$1(attrs, function (v, k) { + rawSet(dom, k, v); + }); + }; + var clone = function (element) { + return foldl(element.dom().attributes, function (acc, attr) { + acc[attr.name] = attr.value; + return acc; + }, {}); + }; + + 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 parent = function (element) { + var dom = element.dom(); + return Option.from(dom.parentNode).map(Element$$1.fromDom); + }; + var children = function (element) { + var dom = element.dom(); + return map(dom.childNodes, Element$$1.fromDom); + }; + var child = function (element, index) { + var children = element.dom().childNodes; + return Option.from(children[index]).map(Element$$1.fromDom); + }; + var firstChild = function (element) { + return child(element, 0); + }; + var lastChild = function (element) { + return child(element, element.dom().childNodes.length - 1); + }; + var spot = Immutable('element', 'offset'); + + var before = function (marker, element) { + var parent$$1 = parent(marker); + parent$$1.each(function (v) { + v.dom().insertBefore(element.dom(), marker.dom()); + }); + }; + var append = function (parent$$1, element) { + parent$$1.dom().appendChild(element.dom()); + }; + + var before$1 = function (marker, elements) { + each(elements, function (x) { + before(marker, x); + }); + }; + var append$1 = function (parent, elements) { + each(elements, function (x) { + append(parent, x); + }); + }; + + var remove$1 = function (element) { + var dom = element.dom(); + if (dom.parentNode !== null) + dom.parentNode.removeChild(dom); + }; + + var clone$1 = function (original, deep) { + return Element$$1.fromDom(original.dom().cloneNode(deep)); + }; + var deep = function (original) { + return clone$1(original, true); + }; + var shallowAs = function (original, tag) { + var nu = Element$$1.fromTag(tag); + var attributes = clone(original); + setAll(nu, attributes); + return nu; + }; + var mutate = function (original, tag) { + var nu = shallowAs(original, tag); + before(original, nu); + var children$$1 = children(original); + append$1(nu, children$$1); + remove$1(original); + return nu; + }; + + var global$8 = tinymce.util.Tools.resolve('tinymce.Env'); + + var DOM$1 = global$6.DOM; + var createNewTextBlock = function (editor, contentNode, blockName) { + var node, textBlock; + var fragment = DOM$1.createFragment(); + var hasContentNode; + var blockElements = editor.schema.getBlockElements(); + if (editor.settings.forced_root_block) { + blockName = blockName || editor.settings.forced_root_block; + } + if (blockName) { + textBlock = DOM$1.create(blockName); + if (textBlock.tagName === editor.settings.forced_root_block) { + DOM$1.setAttribs(textBlock, editor.settings.forced_root_block_attrs); + } + if (!NodeType.isBlock(contentNode.firstChild, blockElements)) { + fragment.appendChild(textBlock); + } + } + if (contentNode) { + while (node = contentNode.firstChild) { + var nodeName = node.nodeName; + if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) { + hasContentNode = true; + } + if (NodeType.isBlock(node, blockElements)) { + fragment.appendChild(node); + textBlock = null; + } else { + if (blockName) { + if (!textBlock) { + textBlock = DOM$1.create(blockName); + fragment.appendChild(textBlock); + } + textBlock.appendChild(node); + } else { + fragment.appendChild(node); + } + } + } + } + if (!editor.settings.forced_root_block) { + fragment.appendChild(DOM$1.create('br')); + } else { + if (!hasContentNode && (!global$8.ie || global$8.ie > 10)) { + textBlock.appendChild(DOM$1.create('br', { 'data-mce-bogus': '1' })); + } + } + return fragment; + }; + var TextBlock = { createNewTextBlock: createNewTextBlock }; + + var DOM$2 = global$6.DOM; + var splitList = function (editor, ul, li, newBlock) { + var tmpRng, fragment, bookmarks, node; + var removeAndKeepBookmarks = function (targetNode) { + global$5.each(bookmarks, function (node) { + targetNode.parentNode.insertBefore(node, li.parentNode); + }); + DOM$2.remove(targetNode); + }; + bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', ul); + newBlock = newBlock || TextBlock.createNewTextBlock(editor, li); + tmpRng = DOM$2.createRng(); + tmpRng.setStartAfter(li); + tmpRng.setEndAfter(ul); + fragment = tmpRng.extractContents(); + for (node = fragment.firstChild; node; node = node.firstChild) { + if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) { + DOM$2.remove(node); + break; + } + } + if (!editor.dom.isEmpty(fragment)) { + DOM$2.insertAfter(fragment, ul); + } + DOM$2.insertAfter(newBlock, ul); + if (NodeType.isEmpty(editor.dom, li.parentNode)) { + removeAndKeepBookmarks(li.parentNode); + } + DOM$2.remove(li); + if (NodeType.isEmpty(editor.dom, ul)) { + DOM$2.remove(ul); + } + }; + var SplitList = { splitList: splitList }; + + var liftN = function (arr, f) { + var r = []; + for (var i = 0; i < arr.length; i++) { + var x = arr[i]; + if (x.isSome()) { + r.push(x.getOrDie()); + } else { + return Option.none(); + } + } + return Option.some(f.apply(null, r)); + }; + + var fromElements = function (elements, scope) { + var doc = scope || document; + var fragment = doc.createDocumentFragment(); + each(elements, function (element) { + fragment.appendChild(element.dom()); + }); + return Element$$1.fromDom(fragment); + }; + + var isSupported = function (dom) { + return dom.style !== undefined; + }; + + var internalSet = function (dom, property, value$$1) { + if (!isString(value$$1)) { + console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value$$1, ':: Element ', dom); + throw new Error('CSS value must be a string: ' + value$$1); + } + if (isSupported(dom)) + dom.style.setProperty(property, value$$1); + }; + var set$1 = function (element, property, value$$1) { + var dom = element.dom(); + internalSet(dom, property, value$$1); + }; + + var createSection = function (scope, listType) { + var section = { + list: Element$$1.fromTag(listType, scope), + item: Element$$1.fromTag('li', scope) + }; + append(section.list, section.item); + return section; + }; + var joinSections = function (parent, appendor) { + append(parent.item, appendor.list); + }; + var createJoinedSections = function (scope, length, listType) { + var sections = []; + var _loop_1 = function (i) { + var newSection = createSection(scope, listType); + last(sections).each(function (lastSection) { + return joinSections(lastSection, newSection); + }); + sections.push(newSection); + }; + for (var i = 0; i < length; i++) { + _loop_1(i); + } + return sections; + }; + var normalizeSection = function (section, entry) { + if (name(section.list).toUpperCase() !== entry.listType) { + section.list = mutate(section.list, entry.listType); + } + setAll(section.list, entry.listAttributes); + }; + var createItem = function (scope, attr, content) { + var item = Element$$1.fromTag('li', scope); + setAll(item, attr); + append$1(item, content); + return item; + }; + var setItem = function (section, item) { + append(section.list, item); + section.item = item; + }; + var writeShallow = function (scope, outline, entry) { + var newOutline = outline.slice(0, entry.depth); + last(newOutline).each(function (section) { + setItem(section, createItem(scope, entry.itemAttributes, entry.content)); + normalizeSection(section, entry); + }); + return newOutline; + }; + var populateSections = function (sections, entry) { + last(sections).each(function (section) { + setAll(section.list, entry.listAttributes); + setAll(section.item, entry.itemAttributes); + append$1(section.item, entry.content); + }); + for (var i = 0; i < sections.length - 1; i++) { + set$1(sections[i].item, 'list-style-type', 'none'); + } + }; + var writeDeep = function (scope, outline, entry) { + var newSections = createJoinedSections(scope, entry.depth - outline.length, entry.listType); + populateSections(newSections, entry); + liftN([ + last(outline), + head(newSections) + ], joinSections); + return outline.concat(newSections); + }; + var composeList = function (scope, entries) { + var outline = foldl(entries, function (outline, entry) { + return entry.depth > outline.length ? writeDeep(scope, outline, entry) : writeShallow(scope, outline, entry); + }, []); + return head(outline).map(function (section) { + return section.list; + }); + }; + + var isIndented = function (entry) { + return entry.depth > 0; + }; + var isSelected = function (entry) { + return entry.isSelected; + }; + + var indentEntry = function (indentation, entry) { + switch (indentation) { + case 'Indent': + entry.depth++; + break; + case 'Outdent': + entry.depth--; + break; + case 'Flatten': + entry.depth = 0; + } + }; + + var hasOwnProperty$1 = Object.prototype.hasOwnProperty; + var shallow$1 = function (old, nu) { + return nu; + }; + var baseMerge = function (merger) { + return function () { + var objects = new Array(arguments.length); + for (var i = 0; i < objects.length; i++) + objects[i] = arguments[i]; + if (objects.length === 0) + throw new Error('Can\'t merge zero objects'); + var ret = {}; + for (var j = 0; j < objects.length; j++) { + var curObject = objects[j]; + for (var key in curObject) + if (hasOwnProperty$1.call(curObject, key)) { + ret[key] = merger(ret[key], curObject[key]); + } + } + return ret; + }; + }; + var merge = baseMerge(shallow$1); + + var assimilateEntry = function (adherent, source) { + adherent.listType = source.listType; + adherent.listAttributes = merge({}, source.listAttributes); + }; + var normalizeShallow = function (outline, entry) { + var matchingEntryDepth = entry.depth - 1; + outline[matchingEntryDepth].each(function (matchingEntry) { + return assimilateEntry(entry, matchingEntry); + }); + var newOutline = outline.slice(0, matchingEntryDepth); + newOutline.push(Option.some(entry)); + return newOutline; + }; + var normalizeDeep = function (outline, entry) { + var newOutline = outline.slice(0); + var diff = entry.depth - outline.length; + for (var i = 1; i < diff; i++) { + newOutline.push(Option.none()); + } + newOutline.push(Option.some(entry)); + return newOutline; + }; + var normalizeEntries = function (entries) { + foldl(entries, function (outline, entry) { + return entry.depth > outline.length ? normalizeDeep(outline, entry) : normalizeShallow(outline, entry); + }, []); + }; + + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; + }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; + }; + + var ListType; + (function (ListType) { + ListType['OL'] = 'OL'; + ListType['UL'] = 'UL'; + ListType['DL'] = 'DL'; + }(ListType || (ListType = {}))); + var getListType = function (list) { + switch (name(list)) { + case 'ol': + return Option.some(ListType.OL); + case 'ul': + return Option.some(ListType.UL); + case 'dl': + return Option.some(ListType.DL); + default: + return Option.none(); + } + }; + var isList$1 = function (el) { + return is$1(el, 'OL,UL,DL'); + }; + + var hasFirstChildList = function (li) { + return firstChild(li).map(isList$1).getOr(false); + }; + var hasLastChildList = function (li) { + return lastChild(li).map(isList$1).getOr(false); + }; + + var getItemContent = function (li) { + var childNodes = children(li); + var contentLength = childNodes.length + (hasLastChildList(li) ? -1 : 0); + return map(childNodes.slice(0, contentLength), deep); + }; + var createEntry = function (li, depth, isSelected) { + var list = parent(li); + return { + depth: depth, + isSelected: isSelected, + content: getItemContent(li), + listType: list.bind(getListType).getOr(ListType.OL), + listAttributes: list.map(clone).getOr({}), + itemAttributes: clone(li) + }; + }; + var parseItem = function (depth, itemSelection, selectionState, item) { + var curriedParseList = curry(parseList, depth, itemSelection, selectionState); + var updateSelectionState = function (itemRange) { + return itemSelection.each(function (selection) { + if (eq(itemRange === 'Start' ? selection.start : selection.end, item)) { + selectionState.set(itemRange === 'Start'); + } + }); + }; + return firstChild(item).filter(isList$1).fold(function () { + updateSelectionState('Start'); + var fromCurrentItem = createEntry(item, depth, selectionState.get()); + updateSelectionState('End'); + var fromChildList = lastChild(item).filter(isList$1).map(curriedParseList).getOr([]); + return [fromCurrentItem].concat(fromChildList); + }, curriedParseList); + }; + var parseList = function (depth, itemSelection, selectionState, list) { + var newDepth = depth + 1; + return bind(children(list), function (child$$1) { + return isList$1(child$$1) ? parseList(newDepth, itemSelection, selectionState, child$$1) : parseItem(newDepth, itemSelection, selectionState, child$$1); + }); + }; + var parseLists = function (lists, itemSelection) { + var selectionState = Cell(false); + var initialDepth = 0; + return map(lists, function (list) { + return { + entries: parseList(initialDepth, itemSelection, selectionState, list), + sourceList: list + }; + }); + }; + + var outdentedComposer = function (editor, entries) { + return map(entries, function (entry) { + var content = fromElements(entry.content); + return Element$$1.fromDom(TextBlock.createNewTextBlock(editor, content.dom())); + }); + }; + var indentedComposer = function (editor, entries) { + normalizeEntries(entries); + return composeList(editor.contentDocument, entries).toArray(); + }; + var composeEntries = function (editor, entries) { + return bind(groupBy(entries, isIndented), function (entries) { + var groupIsIndented = head(entries).map(isIndented).getOr(false); + return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries); + }); + }; + var indentSelectedEntries = function (entries, indentation) { + each(filter(entries, isSelected), function (entry) { + return indentEntry(indentation, entry); + }); + }; + var getItemSelection = function (editor) { + var selectedListItems = map(Selection.getSelectedListItems(editor), Element$$1.fromDom); + return liftN([ + find(selectedListItems, not(hasFirstChildList)), + find(reverse(selectedListItems), not(hasFirstChildList)) + ], function (start, end) { + return { + start: start, + end: end + }; + }); + }; + var listsIndentation = function (editor, lists, indentation) { + var parsedLists = parseLists(lists, getItemSelection(editor)); + each(parsedLists, function (entrySet) { + indentSelectedEntries(entrySet.entries, indentation); + before$1(entrySet.sourceList, composeEntries(editor, entrySet.entries)); + remove$1(entrySet.sourceList); + }); + }; + + var outdentDlItem = function (editor, item) { + if (is$1(item, 'DD')) { + mutate(item, 'DT'); + } else if (is$1(item, 'DT')) { + parent(item).each(function (dl) { + return SplitList.splitList(editor, dl.dom(), item.dom()); + }); + } + }; + var indentDlItem = function (item) { + if (is$1(item, 'DT')) { + mutate(item, 'DD'); + } + }; + var dlIndentation = function (editor, indentation, dlItems) { + if (indentation === 'Indent') { + each(dlItems, indentDlItem); + } else { + each(dlItems, function (item) { + return outdentDlItem(editor, item); + }); + } + }; + var selectionIndentation = function (editor, indentation) { + var dlItems = map(Selection.getSelectedDlItems(editor), Element$$1.fromDom); + var lists = map(Selection.getSelectedListRoots(editor), Element$$1.fromDom); + if (dlItems.length || lists.length) { + var bookmark = editor.selection.getBookmark(); + dlIndentation(editor, indentation, dlItems); + listsIndentation(editor, lists, indentation); + editor.selection.moveToBookmark(bookmark); + editor.selection.setRng(Range.normalizeRange(editor.selection.getRng())); + editor.nodeChanged(); + } + }; + var indentListSelection = function (editor) { + selectionIndentation(editor, 'Indent'); + }; + var outdentListSelection = function (editor) { + selectionIndentation(editor, 'Outdent'); + }; + var flattenListSelection = function (editor) { + selectionIndentation(editor, 'Flatten'); + }; + + var updateListStyle = function (dom, el, detail) { + var type = detail['list-style-type'] ? detail['list-style-type'] : null; + dom.setStyle(el, 'list-style-type', type); + }; + var setAttribs = function (elm, attrs) { + global$5.each(attrs, function (value, key) { + elm.setAttribute(key, value); + }); + }; + var updateListAttrs = function (dom, el, detail) { + setAttribs(el, detail['list-attributes']); + global$5.each(dom.select('li', el), function (li) { + setAttribs(li, detail['list-item-attributes']); + }); + }; + var updateListWithDetails = function (dom, el, detail) { + updateListStyle(dom, el, detail); + updateListAttrs(dom, el, detail); + }; + var removeStyles = function (dom, element, styles) { + global$5.each(styles, function (style) { + var _a; + return dom.setStyle(element, (_a = {}, _a[style] = '', _a)); + }); + }; + var getEndPointNode = function (editor, rng, start, root) { + var 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; + container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container; } - bookmark[start ? 'startContainer' : 'endContainer'] = container; - bookmark[start ? 'startOffset' : 'endOffset'] = offset; - }; - setupEndPoint(true); - if (!rng.collapsed) { - setupEndPoint(); - } - return bookmark; - }; - var resolveBookmark = function (bookmark) { - function restoreEndPoint(start) { - var container, offset, node; - var nodeIndex = function (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 (!start && NodeType.isBr(container.nextSibling)) { + container = container.nextSibling; } - if (container.nodeType === 1) { - offset = nodeIndex(container); + while (container.parentNode !== root) { + if (NodeType.isTextBlock(editor, container)) { + return container; + } + if (/^(TD|TH)$/.test(container.parentNode.nodeName)) { + return container; + } container = container.parentNode; - DOM.remove(node); - if (!container.hasChildNodes() && DOM.isBlock(container)) { - container.appendChild(DOM.create('br')); - } } - 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 $_a9cyhvgkjjgweckv.normalizeRange(rng); - }; - var $_2nx1i4gjjjgweckt = { - createBookmark: createBookmark, - resolveBookmark: resolveBookmark - }; - - var DOM$1 = global$6.DOM; - var normalizeList = function (dom, ul) { - var sibling; - var parentNode = ul.parentNode; - if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) { - sibling = parentNode.previousSibling; - if (sibling && sibling.nodeName === 'LI') { - sibling.appendChild(ul); - if ($_okk1ogljjgweckx.isEmpty(dom, parentNode)) { - DOM$1.remove(parentNode); - } - } else { - DOM$1.setStyle(parentNode, 'listStyleType', 'none'); - } - } - if ($_okk1ogljjgweckx.isListNode(parentNode)) { - sibling = parentNode.previousSibling; - if (sibling && sibling.nodeName === 'LI') { - sibling.appendChild(ul); - } - } - }; - var normalizeLists = function (dom, element) { - global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) { - normalizeList(dom, ul); - }); - }; - var $_ekd4wzgmjjgwecl1 = { - normalizeList: normalizeList, - normalizeLists: normalizeLists - }; - - var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery'); - - var getParentList = function (editor) { - var selectionStart = editor.selection.getStart(true); - return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart)); - }; - var isParentListSelected = function (parentList, selectedBlocks) { - return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList; - }; - var findSubLists = function (parentList) { - return global$5.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm) { - return $_okk1ogljjgweckx.isListNode(elm); - }); - }; - var getSelectedSubLists = function (editor) { - var parentList = getParentList(editor); - var selectedBlocks = editor.selection.getSelectedBlocks(); - if (isParentListSelected(parentList, selectedBlocks)) { - return findSubLists(parentList); - } else { - return global$5.grep(selectedBlocks, function (elm) { - return $_okk1ogljjgweckx.isListNode(elm) && parentList !== elm; - }); - } - }; - var findParentListItemsNodes = function (editor, elms) { - var listItemsElms = global$5.map(elms, function (elm) { - var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm)); - return parentLi ? parentLi : elm; - }); - return global$7.unique(listItemsElms); - }; - var getSelectedListItems = function (editor) { - var selectedBlocks = editor.selection.getSelectedBlocks(); - return global$5.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) { - return $_okk1ogljjgweckx.isListItemNode(block); - }); - }; - var getClosestListRootElm = function (editor, elm) { - var parentTableCell = editor.dom.getParents(elm, 'TD,TH'); - var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody(); - return root; - }; - var $_3xb1cggnjjgwecl3 = { - getParentList: getParentList, - getSelectedSubLists: getSelectedSubLists, - getSelectedListItems: getSelectedListItems, - getClosestListRootElm: getClosestListRootElm - }; - - var global$8 = tinymce.util.Tools.resolve('tinymce.Env'); - - var DOM$2 = global$6.DOM; - var createNewTextBlock = function (editor, contentNode, blockName) { - var node, textBlock; - var fragment = DOM$2.createFragment(); - var hasContentNode; - var blockElements = editor.schema.getBlockElements(); - if (editor.settings.forced_root_block) { - blockName = blockName || editor.settings.forced_root_block; - } - if (blockName) { - textBlock = DOM$2.create(blockName); - if (textBlock.tagName === editor.settings.forced_root_block) { - DOM$2.setAttribs(textBlock, editor.settings.forced_root_block_attrs); - } - if (!$_okk1ogljjgweckx.isBlock(contentNode.firstChild, blockElements)) { - fragment.appendChild(textBlock); - } - } - if (contentNode) { - while (node = contentNode.firstChild) { - var nodeName = node.nodeName; - if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) { - hasContentNode = true; - } - if ($_okk1ogljjgweckx.isBlock(node, blockElements)) { - fragment.appendChild(node); - textBlock = null; - } else { - if (blockName) { - if (!textBlock) { - textBlock = DOM$2.create(blockName); - fragment.appendChild(textBlock); - } - textBlock.appendChild(node); - } else { - fragment.appendChild(node); - } - } - } - } - if (!editor.settings.forced_root_block) { - fragment.appendChild(DOM$2.create('br')); - } else { - if (!hasContentNode && (!global$8.ie || global$8.ie > 10)) { - textBlock.appendChild(DOM$2.create('br', { 'data-mce-bogus': '1' })); - } - } - return fragment; - }; - var $_kbc02gqjjgwecl9 = { createNewTextBlock: createNewTextBlock }; - - var DOM$3 = global$6.DOM; - var splitList = function (editor, ul, li, newBlock) { - var tmpRng, fragment, bookmarks, node; - var removeAndKeepBookmarks = function (targetNode) { - global$5.each(bookmarks, function (node) { - targetNode.parentNode.insertBefore(node, li.parentNode); - }); - DOM$3.remove(targetNode); + return container; }; - bookmarks = DOM$3.select('span[data-mce-type="bookmark"]', ul); - newBlock = newBlock || $_kbc02gqjjgwecl9.createNewTextBlock(editor, li); - tmpRng = DOM$3.createRng(); - tmpRng.setStartAfter(li); - tmpRng.setEndAfter(ul); - fragment = tmpRng.extractContents(); - for (node = fragment.firstChild; node; node = node.firstChild) { - if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) { - DOM$3.remove(node); - break; - } - } - if (!editor.dom.isEmpty(fragment)) { - DOM$3.insertAfter(fragment, ul); - } - DOM$3.insertAfter(newBlock, ul); - if ($_okk1ogljjgweckx.isEmpty(editor.dom, li.parentNode)) { - removeAndKeepBookmarks(li.parentNode); - } - DOM$3.remove(li); - if ($_okk1ogljjgweckx.isEmpty(editor.dom, ul)) { - DOM$3.remove(ul); - } - }; - var $_fikiq7gpjjgwecl5 = { splitList: splitList }; - - var DOM$4 = global$6.DOM; - var removeEmptyLi = function (dom, li) { - if ($_okk1ogljjgweckx.isEmpty(dom, li)) { - DOM$4.remove(li); - } - }; - var outdent = function (editor, li) { - var ul = li.parentNode; - var ulParent, newBlock; - if (ul) { - ulParent = ul.parentNode; - } else { - removeEmptyLi(editor.dom, li); - return true; - } - if (ul === editor.getBody()) { - return true; - } - if (li.nodeName === 'DD') { - DOM$4.rename(li, 'DT'); - return true; - } - if ($_okk1ogljjgweckx.isFirstChild(li) && $_okk1ogljjgweckx.isLastChild(li)) { - if (ulParent.nodeName === 'LI') { - DOM$4.insertAfter(li, ulParent); - removeEmptyLi(editor.dom, ulParent); - DOM$4.remove(ul); - } else if ($_okk1ogljjgweckx.isListNode(ulParent)) { - DOM$4.remove(ul, true); - } else { - ulParent.insertBefore($_kbc02gqjjgwecl9.createNewTextBlock(editor, li), ul); - DOM$4.remove(ul); - } - return true; - } else if ($_okk1ogljjgweckx.isFirstChild(li)) { - if (ulParent.nodeName === 'LI') { - DOM$4.insertAfter(li, ulParent); - li.appendChild(ul); - removeEmptyLi(editor.dom, ulParent); - } else if ($_okk1ogljjgweckx.isListNode(ulParent)) { - ulParent.insertBefore(li, ul); - } else { - ulParent.insertBefore($_kbc02gqjjgwecl9.createNewTextBlock(editor, li), ul); - DOM$4.remove(li); - } - return true; - } else if ($_okk1ogljjgweckx.isLastChild(li)) { - if (ulParent.nodeName === 'LI') { - DOM$4.insertAfter(li, ulParent); - } else if ($_okk1ogljjgweckx.isListNode(ulParent)) { - DOM$4.insertAfter(li, ul); - } else { - DOM$4.insertAfter($_kbc02gqjjgwecl9.createNewTextBlock(editor, li), ul); - DOM$4.remove(li); - } - return true; - } - if (ulParent.nodeName === 'LI') { - ul = ulParent; - newBlock = $_kbc02gqjjgwecl9.createNewTextBlock(editor, li, 'LI'); - } else if ($_okk1ogljjgweckx.isListNode(ulParent)) { - newBlock = $_kbc02gqjjgwecl9.createNewTextBlock(editor, li, 'LI'); - } else { - newBlock = $_kbc02gqjjgwecl9.createNewTextBlock(editor, li); - } - $_fikiq7gpjjgwecl5.splitList(editor, ul, li, newBlock); - $_ekd4wzgmjjgwecl1.normalizeLists(editor.dom, ul.parentNode); - return true; - }; - var outdentSelection = function (editor) { - var listElements = $_3xb1cggnjjgwecl3.getSelectedListItems(editor); - if (listElements.length) { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(editor.selection.getRng()); - var i = void 0, y = void 0; - var root = $_3xb1cggnjjgwecl3.getClosestListRootElm(editor, editor.selection.getStart(true)); - i = listElements.length; - while (i--) { - var node = listElements[i].parentNode; - while (node && node !== root) { - y = listElements.length; - while (y--) { - if (listElements[y] === node) { - listElements.splice(i, 1); - break; - } - } - node = node.parentNode; - } - } - for (i = 0; i < listElements.length; i++) { - if (!outdent(editor, listElements[i]) && i === 0) { + var getSelectedTextBlocks = function (editor, rng, root) { + var textBlocks = [], dom = editor.dom; + var startNode = getEndPointNode(editor, rng, true, root); + var endNode = getEndPointNode(editor, rng, false, root); + var block; + var siblings = []; + for (var node = startNode; node; node = node.nextSibling) { + siblings.push(node); + if (node === endNode) { break; } } - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); - editor.nodeChanged(); - return true; - } - }; - var $_6pbactghjjgweckp = { - outdent: outdent, - outdentSelection: outdentSelection - }; - - var updateListStyle = function (dom, el, detail) { - var type = detail['list-style-type'] ? detail['list-style-type'] : null; - dom.setStyle(el, 'list-style-type', type); - }; - var setAttribs = function (elm, attrs) { - global$5.each(attrs, function (value, key) { - elm.setAttribute(key, value); - }); - }; - var updateListAttrs = function (dom, el, detail) { - setAttribs(el, detail['list-attributes']); - global$5.each(dom.select('li', el), function (li) { - setAttribs(li, detail['list-item-attributes']); - }); - }; - var updateListWithDetails = function (dom, el, detail) { - updateListStyle(dom, el, detail); - updateListAttrs(dom, el, detail); - }; - var removeStyles = function (dom, element, styles) { - global$5.each(styles, function (style) { - var _a; - return dom.setStyle(element, (_a = {}, _a[style] = '', _a)); - }); - }; - var getEndPointNode = function (editor, rng, start, root) { - var container, offset; - container = rng[start ? 'startContainer' : 'endContainer']; - offset = rng[start ? 'startOffset' : 'endOffset']; - if (container.nodeType === 1) { - container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container; - } - if (!start && $_okk1ogljjgweckx.isBr(container.nextSibling)) { - container = container.nextSibling; - } - while (container.parentNode !== root) { - if ($_okk1ogljjgweckx.isTextBlock(editor, container)) { - return container; - } - if (/^(TD|TH)$/.test(container.parentNode.nodeName)) { - return container; - } - container = container.parentNode; - } - return container; - }; - var getSelectedTextBlocks = function (editor, rng, root) { - var textBlocks = [], dom = editor.dom; - var startNode = getEndPointNode(editor, rng, true, root); - var endNode = getEndPointNode(editor, rng, false, root); - var block; - var siblings = []; - for (var node = startNode; node; node = node.nextSibling) { - siblings.push(node); - if (node === endNode) { - break; - } - } - global$5.each(siblings, function (node) { - if ($_okk1ogljjgweckx.isTextBlock(editor, node)) { - textBlocks.push(node); - block = null; - return; - } - if (dom.isBlock(node) || $_okk1ogljjgweckx.isBr(node)) { - if ($_okk1ogljjgweckx.isBr(node)) { - dom.remove(node); - } - block = null; - return; - } - var nextSibling = node.nextSibling; - if (global$4.isBookmarkNode(node)) { - if ($_okk1ogljjgweckx.isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) { + global$5.each(siblings, function (node) { + if (NodeType.isTextBlock(editor, node)) { + textBlocks.push(node); block = null; return; } - } - if (!block) { - block = dom.create('p'); - node.parentNode.insertBefore(block, node); - textBlocks.push(block); - } - block.appendChild(node); - }); - return textBlocks; - }; - var hasCompatibleStyle = function (dom, sib, detail) { - var sibStyle = dom.getStyle(sib, 'list-style-type'); - var detailStyle = detail ? detail['list-style-type'] : ''; - detailStyle = detailStyle === null ? '' : detailStyle; - return sibStyle === detailStyle; - }; - var applyList = function (editor, listName, detail) { - if (detail === void 0) { - detail = {}; - } - var rng = editor.selection.getRng(true); - var bookmark; - var listItemName = 'LI'; - var root = $_3xb1cggnjjgwecl3.getClosestListRootElm(editor, editor.selection.getStart(true)); - var dom = editor.dom; - if (dom.getContentEditable(editor.selection.getNode()) === 'false') { - return; - } - listName = listName.toUpperCase(); - if (listName === 'DL') { - listItemName = 'DT'; - } - bookmark = $_2nx1i4gjjjgweckt.createBookmark(rng); - global$5.each(getSelectedTextBlocks(editor, rng, root), function (block) { - var listBlock, sibling; - sibling = block.previousSibling; - if (sibling && $_okk1ogljjgweckx.isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) { - listBlock = sibling; - block = dom.rename(block, listItemName); - sibling.appendChild(block); - } else { - listBlock = dom.create(listName); - block.parentNode.insertBefore(listBlock, block); - listBlock.appendChild(block); - block = dom.rename(block, listItemName); - } - removeStyles(dom, block, [ - 'margin', - 'margin-right', - 'margin-bottom', - 'margin-left', - 'margin-top', - 'padding', - 'padding-right', - 'padding-bottom', - 'padding-left', - 'padding-top' - ]); - updateListWithDetails(dom, listBlock, detail); - mergeWithAdjacentLists(editor.dom, listBlock); - }); - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); - }; - var removeList = function (editor) { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(editor.selection.getRng(true)); - var root = $_3xb1cggnjjgwecl3.getClosestListRootElm(editor, editor.selection.getStart(true)); - var listItems = $_3xb1cggnjjgwecl3.getSelectedListItems(editor); - var emptyListItems = global$5.grep(listItems, function (li) { - return editor.dom.isEmpty(li); - }); - listItems = global$5.grep(listItems, function (li) { - return !editor.dom.isEmpty(li); - }); - global$5.each(emptyListItems, function (li) { - if ($_okk1ogljjgweckx.isEmpty(editor.dom, li)) { - $_6pbactghjjgweckp.outdent(editor, li); - return; - } - }); - global$5.each(listItems, function (li) { - var node, rootList; - if (li.parentNode === editor.getBody()) { - return; - } - for (node = li; node && node !== root; node = node.parentNode) { - if ($_okk1ogljjgweckx.isListNode(node)) { - rootList = node; + if (dom.isBlock(node) || NodeType.isBr(node)) { + if (NodeType.isBr(node)) { + dom.remove(node); + } + block = null; + return; } - } - $_fikiq7gpjjgwecl5.splitList(editor, rootList, li); - $_ekd4wzgmjjgwecl1.normalizeLists(editor.dom, rootList.parentNode); - }); - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); - }; - var isValidLists = function (list1, list2) { - return list1 && list2 && $_okk1ogljjgweckx.isListNode(list1) && list1.nodeName === list2.nodeName; - }; - var hasSameListStyle = function (dom, list1, list2) { - var targetStyle = dom.getStyle(list1, 'list-style-type', true); - var style = dom.getStyle(list2, 'list-style-type', true); - return targetStyle === style; - }; - var hasSameClasses = function (elm1, elm2) { - return elm1.className === elm2.className; - }; - var shouldMerge = function (dom, list1, list2) { - return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2); - }; - var mergeWithAdjacentLists = function (dom, listBlock) { - var sibling, node; - sibling = listBlock.nextSibling; - if (shouldMerge(dom, listBlock, sibling)) { - while (node = sibling.firstChild) { - listBlock.appendChild(node); - } - dom.remove(sibling); - } - sibling = listBlock.previousSibling; - if (shouldMerge(dom, listBlock, sibling)) { - while (node = sibling.lastChild) { - listBlock.insertBefore(node, listBlock.firstChild); - } - dom.remove(sibling); - } - }; - var updateList = function (dom, list, listName, detail) { - if (list.nodeName !== listName) { - var newList = dom.rename(list, listName); - updateListWithDetails(dom, newList, detail); - } else { - updateListWithDetails(dom, list, detail); - } - }; - var toggleMultipleLists = function (editor, parentList, lists, listName, detail) { - if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { - removeList(editor); - } else { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(editor.selection.getRng(true)); - global$5.each([parentList].concat(lists), function (elm) { - updateList(editor.dom, elm, listName, detail); + var nextSibling = node.nextSibling; + if (global$4.isBookmarkNode(node)) { + if (NodeType.isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) { + block = null; + return; + } + } + if (!block) { + block = dom.create('p'); + node.parentNode.insertBefore(block, node); + textBlocks.push(block); + } + block.appendChild(node); }); - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); - } - }; - var hasListStyleDetail = function (detail) { - return 'list-style-type' in detail; - }; - var toggleSingleList = function (editor, parentList, listName, detail) { - if (parentList === editor.getBody()) { - return; - } - if (parentList) { - if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { - removeList(editor); - } else { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(editor.selection.getRng(true)); - updateListWithDetails(editor.dom, parentList, detail); - mergeWithAdjacentLists(editor.dom, editor.dom.rename(parentList, listName)); - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); + return textBlocks; + }; + var hasCompatibleStyle = function (dom, sib, detail) { + var sibStyle = dom.getStyle(sib, 'list-style-type'); + var detailStyle = detail ? detail['list-style-type'] : ''; + detailStyle = detailStyle === null ? '' : detailStyle; + return sibStyle === detailStyle; + }; + var applyList = function (editor, listName, detail) { + if (detail === void 0) { + detail = {}; } - } else { - applyList(editor, listName, detail); - } - }; - var toggleList = function (editor, listName, detail) { - var parentList = $_3xb1cggnjjgwecl3.getParentList(editor); - var selectedSubLists = $_3xb1cggnjjgwecl3.getSelectedSubLists(editor); - detail = detail ? detail : {}; - if (parentList && selectedSubLists.length > 0) { - toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail); - } else { - toggleSingleList(editor, parentList, listName, detail); - } - }; - var $_aek3i3gejjgwecki = { - toggleList: toggleList, - removeList: removeList, - mergeWithAdjacentLists: mergeWithAdjacentLists - }; - - var findNextCaretContainer = function (editor, rng, isForward, root) { - var node = rng.startContainer; - var offset = rng.startOffset; - var nonEmptyBlocks, walker; - if (node.nodeType === 3 && (isForward ? offset < node.data.length : offset > 0)) { - return node; - } - nonEmptyBlocks = editor.schema.getNonEmptyElements(); - if (node.nodeType === 1) { - node = global$1.getNode(node, offset); - } - walker = new global$2(node, root); - if (isForward) { - if ($_okk1ogljjgweckx.isBogusBr(editor.dom, node)) { - walker.next(); + var rng = editor.selection.getRng(true); + var bookmark; + var listItemName = 'LI'; + var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true)); + var dom = editor.dom; + if (dom.getContentEditable(editor.selection.getNode()) === 'false') { + return; } - } - while (node = walker[isForward ? 'next' : 'prev2']()) { - if (node.nodeName === 'LI' && !node.hasChildNodes()) { - return node; + listName = listName.toUpperCase(); + if (listName === 'DL') { + listItemName = 'DT'; } - if (nonEmptyBlocks[node.nodeName]) { - return node; - } - if (node.nodeType === 3 && node.data.length > 0) { - return node; - } - } - }; - var hasOnlyOneBlockChild = function (dom, elm) { - var childNodes = elm.childNodes; - return childNodes.length === 1 && !$_okk1ogljjgweckx.isListNode(childNodes[0]) && dom.isBlock(childNodes[0]); - }; - var unwrapSingleBlockChild = function (dom, elm) { - if (hasOnlyOneBlockChild(dom, elm)) { - dom.remove(elm.firstChild, true); - } - }; - var moveChildren = function (dom, fromElm, toElm) { - var node, targetElm; - targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm; - unwrapSingleBlockChild(dom, fromElm); - if (!$_okk1ogljjgweckx.isEmpty(dom, fromElm, true)) { - while (node = fromElm.firstChild) { - targetElm.appendChild(node); - } - } - }; - var mergeLiElements = function (dom, fromElm, toElm) { - var node, listNode; - var ul = fromElm.parentNode; - if (!$_okk1ogljjgweckx.isChildOfBody(dom, fromElm) || !$_okk1ogljjgweckx.isChildOfBody(dom, toElm)) { - return; - } - if ($_okk1ogljjgweckx.isListNode(toElm.lastChild)) { - listNode = toElm.lastChild; - } - if (ul === toElm.lastChild) { - if ($_okk1ogljjgweckx.isBr(ul.previousSibling)) { - dom.remove(ul.previousSibling); - } - } - node = toElm.lastChild; - if (node && $_okk1ogljjgweckx.isBr(node) && fromElm.hasChildNodes()) { - dom.remove(node); - } - if ($_okk1ogljjgweckx.isEmpty(dom, toElm, true)) { - dom.$(toElm).empty(); - } - moveChildren(dom, fromElm, toElm); - if (listNode) { - toElm.appendChild(listNode); - } - dom.remove(fromElm); - if ($_okk1ogljjgweckx.isEmpty(dom, ul) && ul !== dom.getRoot()) { - dom.remove(ul); - } - }; - var mergeIntoEmptyLi = function (editor, fromLi, toLi) { - editor.dom.$(toLi).empty(); - mergeLiElements(editor.dom, fromLi, toLi); - editor.selection.setCursorLocation(toLi); - }; - var mergeForward = function (editor, rng, fromLi, toLi) { - var dom = editor.dom; - if (dom.isEmpty(toLi)) { - mergeIntoEmptyLi(editor, fromLi, toLi); - } else { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(rng); - mergeLiElements(dom, fromLi, toLi); - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); - } - }; - var mergeBackward = function (editor, rng, fromLi, toLi) { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(rng); - mergeLiElements(editor.dom, fromLi, toLi); - var resolvedBookmark = $_2nx1i4gjjjgweckt.resolveBookmark(bookmark); - editor.selection.setRng(resolvedBookmark); - }; - var backspaceDeleteFromListToListCaret = function (editor, isForward) { - var dom = editor.dom, selection = editor.selection; - var selectionStartElm = selection.getStart(); - var root = $_3xb1cggnjjgwecl3.getClosestListRootElm(editor, selectionStartElm); - var li = dom.getParent(selection.getStart(), 'LI', root); - var ul, rng, otherLi; - if (li) { - ul = li.parentNode; - if (ul === editor.getBody() && $_okk1ogljjgweckx.isEmpty(dom, ul)) { - return true; - } - rng = $_a9cyhvgkjjgweckv.normalizeRange(selection.getRng(true)); - otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); - if (otherLi && otherLi !== li) { - if (isForward) { - mergeForward(editor, rng, otherLi, li); + bookmark = Bookmark.createBookmark(rng); + global$5.each(getSelectedTextBlocks(editor, rng, root), function (block) { + var listBlock, sibling; + sibling = block.previousSibling; + if (sibling && NodeType.isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) { + listBlock = sibling; + block = dom.rename(block, listItemName); + sibling.appendChild(block); } else { - mergeBackward(editor, rng, li, otherLi); + listBlock = dom.create(listName); + block.parentNode.insertBefore(listBlock, block); + listBlock.appendChild(block); + block = dom.rename(block, listItemName); } - return true; - } else if (!otherLi) { - if (!isForward && $_aek3i3gejjgwecki.removeList(editor)) { + removeStyles(dom, block, [ + 'margin', + 'margin-right', + 'margin-bottom', + 'margin-left', + 'margin-top', + 'padding', + 'padding-right', + 'padding-bottom', + 'padding-left', + 'padding-top' + ]); + updateListWithDetails(dom, listBlock, detail); + mergeWithAdjacentLists(editor.dom, listBlock); + }); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + }; + var isValidLists = function (list1, list2) { + return list1 && list2 && NodeType.isListNode(list1) && list1.nodeName === list2.nodeName; + }; + var hasSameListStyle = function (dom, list1, list2) { + var targetStyle = dom.getStyle(list1, 'list-style-type', true); + var style = dom.getStyle(list2, 'list-style-type', true); + return targetStyle === style; + }; + var hasSameClasses = function (elm1, elm2) { + return elm1.className === elm2.className; + }; + var shouldMerge = function (dom, list1, list2) { + return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2); + }; + var mergeWithAdjacentLists = function (dom, listBlock) { + var sibling, node; + sibling = listBlock.nextSibling; + if (shouldMerge(dom, listBlock, sibling)) { + while (node = sibling.firstChild) { + listBlock.appendChild(node); + } + dom.remove(sibling); + } + sibling = listBlock.previousSibling; + if (shouldMerge(dom, listBlock, sibling)) { + while (node = sibling.lastChild) { + listBlock.insertBefore(node, listBlock.firstChild); + } + dom.remove(sibling); + } + }; + var updateList = function (dom, list, listName, detail) { + if (list.nodeName !== listName) { + var newList = dom.rename(list, listName); + updateListWithDetails(dom, newList, detail); + } else { + updateListWithDetails(dom, list, detail); + } + }; + var toggleMultipleLists = function (editor, parentList, lists, listName, detail) { + if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { + flattenListSelection(editor); + } else { + var bookmark = Bookmark.createBookmark(editor.selection.getRng(true)); + global$5.each([parentList].concat(lists), function (elm) { + updateList(editor.dom, elm, listName, detail); + }); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + } + }; + var hasListStyleDetail = function (detail) { + return 'list-style-type' in detail; + }; + var toggleSingleList = function (editor, parentList, listName, detail) { + if (parentList === editor.getBody()) { + return; + } + if (parentList) { + if (parentList.nodeName === listName && !hasListStyleDetail(detail)) { + flattenListSelection(editor); + } else { + var bookmark = Bookmark.createBookmark(editor.selection.getRng(true)); + updateListWithDetails(editor.dom, parentList, detail); + mergeWithAdjacentLists(editor.dom, editor.dom.rename(parentList, listName)); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + } + } else { + applyList(editor, listName, detail); + } + }; + var toggleList = function (editor, listName, detail) { + var parentList = Selection.getParentList(editor); + var selectedSubLists = Selection.getSelectedSubLists(editor); + detail = detail ? detail : {}; + if (parentList && selectedSubLists.length > 0) { + toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail); + } else { + toggleSingleList(editor, parentList, listName, detail); + } + }; + var ToggleList = { + toggleList: toggleList, + mergeWithAdjacentLists: mergeWithAdjacentLists + }; + + var DOM$3 = global$6.DOM; + var normalizeList = function (dom, ul) { + var sibling; + var parentNode = ul.parentNode; + if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) { + sibling = parentNode.previousSibling; + if (sibling && sibling.nodeName === 'LI') { + sibling.appendChild(ul); + if (NodeType.isEmpty(dom, parentNode)) { + DOM$3.remove(parentNode); + } + } else { + DOM$3.setStyle(parentNode, 'listStyleType', 'none'); + } + } + if (NodeType.isListNode(parentNode)) { + sibling = parentNode.previousSibling; + if (sibling && sibling.nodeName === 'LI') { + sibling.appendChild(ul); + } + } + }; + var normalizeLists = function (dom, element) { + global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) { + normalizeList(dom, ul); + }); + }; + var NormalizeLists = { + normalizeList: normalizeList, + normalizeLists: normalizeLists + }; + + var findNextCaretContainer = function (editor, rng, isForward, root) { + var node = rng.startContainer; + var offset = rng.startOffset; + var nonEmptyBlocks, walker; + if (node.nodeType === 3 && (isForward ? offset < node.data.length : offset > 0)) { + return node; + } + nonEmptyBlocks = editor.schema.getNonEmptyElements(); + if (node.nodeType === 1) { + node = global$1.getNode(node, offset); + } + walker = new global$2(node, root); + if (isForward) { + if (NodeType.isBogusBr(editor.dom, node)) { + walker.next(); + } + } + while (node = walker[isForward ? 'next' : 'prev2']()) { + if (node.nodeName === 'LI' && !node.hasChildNodes()) { + return node; + } + if (nonEmptyBlocks[node.nodeName]) { + return node; + } + if (node.nodeType === 3 && node.data.length > 0) { + return node; + } + } + }; + var hasOnlyOneBlockChild = function (dom, elm) { + var childNodes = elm.childNodes; + return childNodes.length === 1 && !NodeType.isListNode(childNodes[0]) && dom.isBlock(childNodes[0]); + }; + var unwrapSingleBlockChild = function (dom, elm) { + if (hasOnlyOneBlockChild(dom, elm)) { + dom.remove(elm.firstChild, true); + } + }; + var moveChildren = function (dom, fromElm, toElm) { + var node, targetElm; + targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm; + unwrapSingleBlockChild(dom, fromElm); + if (!NodeType.isEmpty(dom, fromElm, true)) { + while (node = fromElm.firstChild) { + targetElm.appendChild(node); + } + } + }; + var mergeLiElements = function (dom, fromElm, toElm) { + var node, listNode; + var ul = fromElm.parentNode; + if (!NodeType.isChildOfBody(dom, fromElm) || !NodeType.isChildOfBody(dom, toElm)) { + return; + } + if (NodeType.isListNode(toElm.lastChild)) { + listNode = toElm.lastChild; + } + if (ul === toElm.lastChild) { + if (NodeType.isBr(ul.previousSibling)) { + dom.remove(ul.previousSibling); + } + } + node = toElm.lastChild; + if (node && NodeType.isBr(node) && fromElm.hasChildNodes()) { + dom.remove(node); + } + if (NodeType.isEmpty(dom, toElm, true)) { + dom.$(toElm).empty(); + } + moveChildren(dom, fromElm, toElm); + if (listNode) { + toElm.appendChild(listNode); + } + dom.remove(fromElm); + if (NodeType.isEmpty(dom, ul) && ul !== dom.getRoot()) { + dom.remove(ul); + } + }; + var mergeIntoEmptyLi = function (editor, fromLi, toLi) { + editor.dom.$(toLi).empty(); + mergeLiElements(editor.dom, fromLi, toLi); + editor.selection.setCursorLocation(toLi); + }; + var mergeForward = function (editor, rng, fromLi, toLi) { + var dom = editor.dom; + if (dom.isEmpty(toLi)) { + mergeIntoEmptyLi(editor, fromLi, toLi); + } else { + var bookmark = Bookmark.createBookmark(rng); + mergeLiElements(dom, fromLi, toLi); + editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); + } + }; + var mergeBackward = function (editor, rng, fromLi, toLi) { + var bookmark = Bookmark.createBookmark(rng); + mergeLiElements(editor.dom, fromLi, toLi); + var resolvedBookmark = Bookmark.resolveBookmark(bookmark); + editor.selection.setRng(resolvedBookmark); + }; + var backspaceDeleteFromListToListCaret = function (editor, isForward) { + var dom = editor.dom, selection = editor.selection; + var selectionStartElm = selection.getStart(); + var root = Selection.getClosestListRootElm(editor, selectionStartElm); + var li = dom.getParent(selection.getStart(), 'LI', root); + var ul, rng, otherLi; + if (li) { + ul = li.parentNode; + if (ul === editor.getBody() && NodeType.isEmpty(dom, ul)) { + return true; + } + rng = Range.normalizeRange(selection.getRng(true)); + otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); + if (otherLi && otherLi !== li) { + if (isForward) { + mergeForward(editor, rng, otherLi, li); + } else { + mergeBackward(editor, rng, li, otherLi); + } + return true; + } else if (!otherLi) { + if (!isForward) { + flattenListSelection(editor); + return true; + } + } + } + return false; + }; + var removeBlock = function (dom, block, root) { + var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root); + dom.remove(block); + if (parentBlock && dom.isEmpty(parentBlock)) { + dom.remove(parentBlock); + } + }; + var backspaceDeleteIntoListCaret = function (editor, isForward) { + var dom = editor.dom; + var selectionStartElm = editor.selection.getStart(); + var root = Selection.getClosestListRootElm(editor, selectionStartElm); + var block = dom.getParent(selectionStartElm, dom.isBlock, root); + if (block && dom.isEmpty(block)) { + var rng = Range.normalizeRange(editor.selection.getRng(true)); + var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); + if (otherLi_1) { + editor.undoManager.transact(function () { + removeBlock(dom, block, root); + ToggleList.mergeWithAdjacentLists(dom, otherLi_1.parentNode); + editor.selection.select(otherLi_1, true); + editor.selection.collapse(isForward); + }); return true; } } - } - return false; - }; - var removeBlock = function (dom, block, root) { - var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root); - dom.remove(block); - if (parentBlock && dom.isEmpty(parentBlock)) { - dom.remove(parentBlock); - } - }; - var backspaceDeleteIntoListCaret = function (editor, isForward) { - var dom = editor.dom; - var selectionStartElm = editor.selection.getStart(); - var root = $_3xb1cggnjjgwecl3.getClosestListRootElm(editor, selectionStartElm); - var block = dom.getParent(selectionStartElm, dom.isBlock, root); - if (block && dom.isEmpty(block)) { - var rng = $_a9cyhvgkjjgweckv.normalizeRange(editor.selection.getRng(true)); - var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root); - if (otherLi_1) { + return false; + }; + var backspaceDeleteCaret = function (editor, isForward) { + return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward); + }; + var backspaceDeleteRange = function (editor) { + var selectionStartElm = editor.selection.getStart(); + var root = Selection.getClosestListRootElm(editor, selectionStartElm); + var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root); + if (startListParent || Selection.getSelectedListItems(editor).length > 0) { editor.undoManager.transact(function () { - removeBlock(dom, block, root); - $_aek3i3gejjgwecki.mergeWithAdjacentLists(dom, otherLi_1.parentNode); - editor.selection.select(otherLi_1, true); - editor.selection.collapse(isForward); + editor.execCommand('Delete'); + NormalizeLists.normalizeLists(editor.dom, editor.getBody()); }); return true; } - } - return false; - }; - var backspaceDeleteCaret = function (editor, isForward) { - return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward); - }; - var backspaceDeleteRange = function (editor) { - var selectionStartElm = editor.selection.getStart(); - var root = $_3xb1cggnjjgwecl3.getClosestListRootElm(editor, selectionStartElm); - var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root); - if (startListParent || $_3xb1cggnjjgwecl3.getSelectedListItems(editor).length > 0) { - editor.undoManager.transact(function () { - editor.execCommand('Delete'); - $_ekd4wzgmjjgwecl1.normalizeLists(editor.dom, editor.getBody()); + return false; + }; + var backspaceDelete = function (editor, isForward) { + return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor); + }; + var setup = function (editor) { + editor.on('keydown', function (e) { + if (e.keyCode === global$3.BACKSPACE) { + if (backspaceDelete(editor, false)) { + e.preventDefault(); + } + } else if (e.keyCode === global$3.DELETE) { + if (backspaceDelete(editor, true)) { + e.preventDefault(); + } + } }); - return true; - } - return false; - }; - var backspaceDelete = function (editor, isForward) { - return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor); - }; - var setup = function (editor) { - editor.on('keydown', function (e) { - if (e.keyCode === global$3.BACKSPACE) { - if (backspaceDelete(editor, false)) { + }; + var Delete = { + setup: setup, + backspaceDelete: backspaceDelete + }; + + var get$3 = function (editor) { + return { + backspaceDelete: function (isForward) { + Delete.backspaceDelete(editor, isForward); + } + }; + }; + var Api = { get: get$3 }; + + var queryListCommandState = function (editor, listName) { + return function () { + var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL'); + return parentList && parentList.nodeName === listName; + }; + }; + var register = function (editor) { + editor.on('BeforeExecCommand', function (e) { + var cmd = e.command.toLowerCase(); + if (cmd === 'indent') { + indentListSelection(editor); + } else if (cmd === 'outdent') { + outdentListSelection(editor); + } + }); + editor.addCommand('InsertUnorderedList', function (ui, detail) { + ToggleList.toggleList(editor, 'UL', detail); + }); + editor.addCommand('InsertOrderedList', function (ui, detail) { + ToggleList.toggleList(editor, 'OL', detail); + }); + editor.addCommand('InsertDefinitionList', function (ui, detail) { + ToggleList.toggleList(editor, 'DL', detail); + }); + editor.addCommand('RemoveList', function () { + flattenListSelection(editor); + }); + editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL')); + editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL')); + editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL')); + }; + var Commands = { register: register }; + + var shouldIndentOnTab = function (editor) { + return editor.getParam('lists_indent_on_tab', true); + }; + var Settings = { shouldIndentOnTab: shouldIndentOnTab }; + + var setupTabKey = function (editor) { + editor.on('keydown', function (e) { + if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) { + return; + } + if (Selection.isList(editor)) { e.preventDefault(); + editor.undoManager.transact(function () { + if (e.shiftKey) { + outdentListSelection(editor); + } else { + indentListSelection(editor); + } + }); } - } else if (e.keyCode === global$3.DELETE) { - if (backspaceDelete(editor, true)) { - e.preventDefault(); - } - } - }); - }; - var $_brhyezgajjgweck7 = { - setup: setup, - backspaceDelete: backspaceDelete - }; - - var get = function (editor) { - return { - backspaceDelete: function (isForward) { - $_brhyezgajjgweck7.backspaceDelete(editor, isForward); - } - }; - }; - var $_nb3yvg9jjgweck5 = { get: get }; - - var DOM$5 = global$6.DOM; - var mergeLists = function (from, to) { - var node; - if ($_okk1ogljjgweckx.isListNode(from)) { - while (node = from.firstChild) { - to.appendChild(node); - } - DOM$5.remove(from); - } - }; - var indent = function (li) { - var sibling, newList, listStyle; - if (li.nodeName === 'DT') { - DOM$5.rename(li, 'DD'); - return true; - } - sibling = li.previousSibling; - if (sibling && $_okk1ogljjgweckx.isListNode(sibling)) { - sibling.appendChild(li); - return true; - } - if (sibling && sibling.nodeName === 'LI' && $_okk1ogljjgweckx.isListNode(sibling.lastChild)) { - sibling.lastChild.appendChild(li); - mergeLists(li.lastChild, sibling.lastChild); - return true; - } - sibling = li.nextSibling; - if (sibling && $_okk1ogljjgweckx.isListNode(sibling)) { - sibling.insertBefore(li, sibling.firstChild); - return true; - } - sibling = li.previousSibling; - if (sibling && sibling.nodeName === 'LI') { - newList = DOM$5.create(li.parentNode.nodeName); - listStyle = DOM$5.getStyle(li.parentNode, 'listStyleType'); - if (listStyle) { - DOM$5.setStyle(newList, 'listStyleType', listStyle); - } - sibling.appendChild(newList); - newList.appendChild(li); - mergeLists(li.lastChild, newList); - return true; - } - return false; - }; - var indentSelection = function (editor) { - var listElements = $_3xb1cggnjjgwecl3.getSelectedListItems(editor); - if (listElements.length) { - var bookmark = $_2nx1i4gjjjgweckt.createBookmark(editor.selection.getRng(true)); - for (var i = 0; i < listElements.length; i++) { - if (!indent(listElements[i]) && i === 0) { - break; - } - } - editor.selection.setRng($_2nx1i4gjjjgweckt.resolveBookmark(bookmark)); - editor.nodeChanged(); - return true; - } - }; - var $_3rkwagtjjgweclf = { indentSelection: indentSelection }; - - var queryListCommandState = function (editor, listName) { - return function () { - var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL'); - return parentList && parentList.nodeName === listName; - }; - }; - var register = function (editor) { - editor.on('BeforeExecCommand', function (e) { - var cmd = e.command.toLowerCase(); - var isHandled; - if (cmd === 'indent') { - if ($_3rkwagtjjgweclf.indentSelection(editor)) { - isHandled = true; - } - } else if (cmd === 'outdent') { - if ($_6pbactghjjgweckp.outdentSelection(editor)) { - isHandled = true; - } - } - if (isHandled) { - editor.fire('ExecCommand', { command: e.command }); - e.preventDefault(); - return true; - } - }); - editor.addCommand('InsertUnorderedList', function (ui, detail) { - $_aek3i3gejjgwecki.toggleList(editor, 'UL', detail); - }); - editor.addCommand('InsertOrderedList', function (ui, detail) { - $_aek3i3gejjgwecki.toggleList(editor, 'OL', detail); - }); - editor.addCommand('InsertDefinitionList', function (ui, detail) { - $_aek3i3gejjgwecki.toggleList(editor, 'DL', detail); - }); - editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL')); - editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL')); - editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL')); - }; - var $_blnfs1gsjjgwecld = { register: register }; - - var shouldIndentOnTab = function (editor) { - return editor.getParam('lists_indent_on_tab', true); - }; - var $_8obsbgvjjgweclk = { shouldIndentOnTab: shouldIndentOnTab }; - - var setupTabKey = function (editor) { - editor.on('keydown', function (e) { - if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) { - return; - } - if (editor.dom.getParent(editor.selection.getStart(), 'LI,DT,DD')) { - e.preventDefault(); - if (e.shiftKey) { - $_6pbactghjjgweckp.outdentSelection(editor); - } else { - $_3rkwagtjjgweclf.indentSelection(editor); - } - } - }); - }; - var setup$1 = function (editor) { - if ($_8obsbgvjjgweclk.shouldIndentOnTab(editor)) { - setupTabKey(editor); - } - $_brhyezgajjgweck7.setup(editor); - }; - var $_ees9z9gujjgwecli = { setup: setup$1 }; - - var findIndex = function (list, predicate) { - for (var index = 0; index < list.length; index++) { - var element = list[index]; - if (predicate(element)) { - return index; - } - } - return -1; - }; - var listState = function (editor, listName) { - return function (e) { - var ctrl = e.control; - editor.on('NodeChange', function (e) { - var tableCellIndex = findIndex(e.parents, $_okk1ogljjgweckx.isTableCellNode); - var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents; - var lists = global$5.grep(parents, $_okk1ogljjgweckx.isListNode); - ctrl.active(lists.length > 0 && lists[0].nodeName === listName); }); }; - }; - var indentPostRender = function (editor) { - return function (e) { - var ctrl = e.control; - editor.on('nodechange', function () { - var listItemBlocks = $_3xb1cggnjjgwecl3.getSelectedListItems(editor); - var disable = listItemBlocks.length > 0 && $_okk1ogljjgweckx.isFirstChild(listItemBlocks[0]); - ctrl.disabled(disable); + var setup$1 = function (editor) { + if (Settings.shouldIndentOnTab(editor)) { + setupTabKey(editor); + } + Delete.setup(editor); + }; + var Keyboard = { setup: setup$1 }; + + var findIndex$2 = function (list, predicate) { + for (var index = 0; index < list.length; index++) { + var element = list[index]; + if (predicate(element)) { + return index; + } + } + return -1; + }; + var listState = function (editor, listName) { + return function (e) { + var ctrl = e.control; + editor.on('NodeChange', function (e) { + var tableCellIndex = findIndex$2(e.parents, NodeType.isTableCellNode); + var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents; + var lists = global$5.grep(parents, NodeType.isListNode); + ctrl.active(lists.length > 0 && lists[0].nodeName === listName); + }); + }; + }; + var register$1 = function (editor) { + var hasPlugin = function (editor, plugin) { + var plugins = editor.settings.plugins ? editor.settings.plugins : ''; + return global$5.inArray(plugins.split(/[ ,]/), plugin) !== -1; + }; + if (!hasPlugin(editor, 'advlist')) { + editor.addButton('numlist', { + active: false, + title: 'Numbered list', + cmd: 'InsertOrderedList', + onPostRender: listState(editor, 'OL') + }); + editor.addButton('bullist', { + active: false, + title: 'Bullet list', + cmd: 'InsertUnorderedList', + onPostRender: listState(editor, 'UL') + }); + } + editor.addButton('indent', { + icon: 'indent', + title: 'Increase indent', + cmd: 'Indent' }); }; - }; - var register$1 = function (editor) { - var hasPlugin = function (editor, plugin) { - var plugins = editor.settings.plugins ? editor.settings.plugins : ''; - return global$5.inArray(plugins.split(/[ ,]/), plugin) !== -1; - }; - if (!hasPlugin(editor, 'advlist')) { - editor.addButton('numlist', { - active: false, - title: 'Numbered list', - cmd: 'InsertOrderedList', - onPostRender: listState(editor, 'OL') - }); - editor.addButton('bullist', { - active: false, - title: 'Bullet list', - cmd: 'InsertUnorderedList', - onPostRender: listState(editor, 'UL') - }); - } - editor.addButton('indent', { - icon: 'indent', - title: 'Increase indent', - cmd: 'Indent', - onPostRender: indentPostRender(editor) + var Buttons = { register: register$1 }; + + global.add('lists', function (editor) { + Keyboard.setup(editor); + Buttons.register(editor); + Commands.register(editor); + return Api.get(editor); }); - }; - var $_s7o0sgwjjgweclm = { register: register$1 }; + function Plugin () { + } - global.add('lists', function (editor) { - $_ees9z9gujjgwecli.setup(editor); - $_s7o0sgwjjgweclm.register(editor); - $_blnfs1gsjjgwecld.register(editor); - return $_nb3yvg9jjgweck5.get(editor); - }); - function Plugin () { - } - - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/lists/plugin.min.js b/wp-includes/js/tinymce/plugins/lists/plugin.min.js index 3df438fc4f..17fe490429 100644 --- a/wp-includes/js/tinymce/plugins/lists/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/lists/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),l=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),n=tinymce.util.Tools.resolve("tinymce.util.VK"),p=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),o=function(e){return e&&"BR"===e.nodeName},r=function(e){return e&&3===e.nodeType},h=function(e){return e&&/^(OL|UL|DL)$/.test(e.nodeName)},i=function(e){return e&&/^(LI|DT|DD)$/.test(e.nodeName)},a=function(e){return e&&/^(TH|TD)$/.test(e.nodeName)},C=o,s=function(e){return e.parentNode.firstChild===e},c=function(e){return e.parentNode.lastChild===e},y=function(e,t){return t&&!!e.schema.getTextBlockElements()[t.nodeName]},f=function(e,t){return e&&e.nodeName in t},u=function(e,t){return!!o(t)&&!(!e.isBlock(t.nextSibling)||o(t.previousSibling))},m=function(e,t,n){var o=e.isEmpty(t);return!(n&&0=e.childNodes.length?n.data.length:0}:{container:e,offset:t}},L=function(e){var t=e.cloneRange(),n=N(e.startContainer,e.startOffset);t.setStart(n.container,n.offset);var o=N(e.endContainer,e.endOffset);return t.setEnd(o.container,o.offset),t},S=t.DOM,b=function(r){var i={},e=function(e){var t,n,o;n=r[e?"startContainer":"endContainer"],o=r[e?"startOffset":"endOffset"],1===n.nodeType&&(t=S.create("span",{"data-mce-type":"bookmark"}),n.hasChildNodes()?(o=Math.min(o,n.childNodes.length-1),e?n.insertBefore(t,n.childNodes[o]):S.insertAfter(t,n.childNodes[o])):n.appendChild(t),n=t,o=0),i[e?"startContainer":"endContainer"]=n,i[e?"startOffset":"endOffset"]=o};return e(!0),r.collapsed||e(),i},D=function(r){function e(e){var t,n,o;t=o=r[e?"startContainer":"endContainer"],n=r[e?"startOffset":"endOffset"],t&&(1===t.nodeType&&(n=function(e){for(var t=e.parentNode.firstChild,n=0;t;){if(t===e)return n;1===t.nodeType&&"bookmark"===t.getAttribute("data-mce-type")||n++,t=t.nextSibling}return-1}(t),t=t.parentNode,S.remove(o),!t.hasChildNodes()&&S.isBlock(t)&&t.appendChild(S.create("br"))),r[e?"startContainer":"endContainer"]=t,r[e?"startOffset":"endOffset"]=n)}e(!0),e();var t=S.createRng();return t.setStart(r.startContainer,r.startOffset),r.endContainer&&t.setEnd(r.endContainer,r.endOffset),L(t)},k=t.DOM,T=function(e,t){var n,o=t.parentNode;"LI"===o.nodeName&&o.firstChild===t&&((n=o.previousSibling)&&"LI"===n.nodeName?(n.appendChild(t),m(e,o)&&k.remove(o)):k.setStyle(o,"listStyleType","none")),h(o)&&(n=o.previousSibling)&&"LI"===n.nodeName&&n.appendChild(t)},I=function(t,e){v.each(v.grep(t.select("ol,ul",e)),function(e){T(t,e)})},B=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),R=function(e){var t=e.selection.getStart(!0);return e.dom.getParent(t,"OL,UL,DL",O(e,t))},O=function(e,t){var n=e.dom.getParents(t,"TD,TH");return 0=e.childNodes.length?t.data.length:0}:t.previousSibling&&y(t.previousSibling)?{container:t.previousSibling,offset:t.previousSibling.data.length}:t.nextSibling&&y(t.nextSibling)?{container:t.nextSibling,offset:0}:{container:e,offset:n}},x=function(e){var n=e.cloneRange(),t=A(e.startContainer,e.startOffset);n.setStart(t.container,t.offset);var r=A(e.endContainer,e.endOffset);return n.setEnd(r.container,r.offset),n},R=g.DOM,I=function(o){var i={},e=function(e){var n,t,r;t=o[e?"startContainer":"endContainer"],r=o[e?"startOffset":"endOffset"],1===t.nodeType&&(n=R.create("span",{"data-mce-type":"bookmark"}),t.hasChildNodes()?(r=Math.min(r,t.childNodes.length-1),e?t.insertBefore(n,t.childNodes[r]):R.insertAfter(n,t.childNodes[r])):t.appendChild(n),t=n,r=0),i[e?"startContainer":"endContainer"]=t,i[e?"startOffset":"endOffset"]=r};return e(!0),o.collapsed||e(),i},B=function(o){function e(e){var n,t,r;n=r=o[e?"startContainer":"endContainer"],t=o[e?"startOffset":"endOffset"],n&&(1===n.nodeType&&(t=function(e){for(var n=e.parentNode.firstChild,t=0;n;){if(n===e)return t;1===n.nodeType&&"bookmark"===n.getAttribute("data-mce-type")||t++,n=n.nextSibling}return-1}(n),n=n.parentNode,R.remove(r),!n.hasChildNodes()&&R.isBlock(n)&&n.appendChild(R.create("br"))),o[e?"startContainer":"endContainer"]=n,o[e?"startOffset":"endOffset"]=t)}e(!0),e();var n=R.createRng();return n.setStart(o.startContainer,o.startOffset),o.endContainer&&n.setEnd(o.endContainer,o.endOffset),x(n)},_=function(e){return function(){return e}},P=function(t){return function(){for(var e=[],n=0;ne.length?function(e,n){for(var t=e.slice(0),r=n.depth-e.length,o=1;oe.length?Sn(t,e,n):Nn(t,e,n)},[]),oe(o).map(function(e){return e.list})).toArray();var t,r,o},Pn=function(e){var n,t,r=Y(ve.getSelectedListItems(e),We.fromDom);return pn([ee(r,P(An)),ee((n=r,t=re.call(n,0),t.reverse(),t),P(An))],function(e,n){return{start:e,end:n}})},Mn=function(a,e,s){var n,t,r,o=(n=e,t=Pn(a),r=En(!1),Y(n,function(e){return{entries:In(0,t,r,e),sourceList:e}}));G(o,function(e){var n,t,r,o,i,u;n=e.entries,t=s,G(J(n,Cn),function(e){return function(e,n){switch(e){case"Indent":n.depth++;break;case"Outdent":n.depth--;break;case"Flatten":n.depth=0}}(t,e)}),r=e.sourceList,i=a,u=e.entries,o=te(function(e,n){if(0===e.length)return[];for(var t=n(e[0]),r=[],o=[],i=0,u=e.length;i 0) { - return global$2.extend({}, pattern[0], { url: getUrl(pattern[0], url) }); - } else { - return null; - } - }; - - var getIframeHtml = function (data) { - var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : ''; - return ''; - }; - var getFlashHtml = function (data) { - var html = ''; - if (data.poster) { - html += ''; - } - html += ''; - return html; - }; - var getAudioHtml = function (data, audioTemplateCallback) { - if (audioTemplateCallback) { - return audioTemplateCallback(data); - } else { - return ''; - } - }; - var getVideoHtml = function (data, videoTemplateCallback) { - if (videoTemplateCallback) { - return videoTemplateCallback(data); - } else { - return ''; - } - }; - var getScriptHtml = function (data) { - return ''; - }; - var dataToHtml = function (editor, dataIn) { - var data = global$2.extend({}, dataIn); - if (!data.source1) { - global$2.extend(data, $_6mep3hh4jjgwecnt.htmlToData($_69rpmgh3jjgwecnr.getScripts(editor), data.embed)); - if (!data.source1) { - return ''; - } - } - if (!data.source2) { - data.source2 = ''; - } - if (!data.poster) { - data.poster = ''; - } - data.source1 = editor.convertURL(data.source1, 'source'); - data.source2 = editor.convertURL(data.source2, 'source'); - data.source1mime = $_d9gn6bhcjjgwecol.guess(data.source1); - data.source2mime = $_d9gn6bhcjjgwecol.guess(data.source2); - data.poster = editor.convertURL(data.poster, 'poster'); - var pattern = matchPattern(data.source1); - if (pattern) { - data.source1 = pattern.url; - data.type = pattern.type; - data.allowFullscreen = pattern.allowFullscreen; - data.width = data.width || pattern.w; - data.height = data.height || pattern.h; - } - if (data.embed) { - return $_s3qkohdjjgwecon.updateHtml(data.embed, data, true); - } else { - var videoScript = $_4q3fmh7jjgwecnw.getVideoScriptMatch($_69rpmgh3jjgwecnr.getScripts(editor), data.source1); - if (videoScript) { - data.type = 'script'; - data.width = videoScript.width; - data.height = videoScript.height; - } - var audioTemplateCallback = $_69rpmgh3jjgwecnr.getAudioTemplateCallback(editor); - var videoTemplateCallback = $_69rpmgh3jjgwecnr.getVideoTemplateCallback(editor); - data.width = data.width || 300; - data.height = data.height || 150; - global$2.each(data, function (value, key) { - data[key] = editor.dom.encode(value); - }); - if (data.type === 'iframe') { - return getIframeHtml(data); - } else if (data.source1mime === 'application/x-shockwave-flash') { - return getFlashHtml(data); - } else if (data.source1mime.indexOf('audio') !== -1) { - return getAudioHtml(data, audioTemplateCallback); - } else if (data.type === 'script') { - return getScriptHtml(data); - } else { - return getVideoHtml(data, videoTemplateCallback); - } - } - }; - var $_bc7nlthbjjgwecoh = { dataToHtml: dataToHtml }; - - var cache = {}; - var embedPromise = function (data, dataToHtml, handler) { - return new global$5(function (res, rej) { - var wrappedResolve = function (response) { - if (response.html) { - cache[data.source1] = response; - } - return res({ - url: data.source1, - html: response.html ? response.html : dataToHtml(data) - }); - }; - if (cache[data.source1]) { - wrappedResolve(cache[data.source1]); - } else { - handler({ url: data.source1 }, wrappedResolve, rej); - } - }); - }; - var defaultPromise = function (data, dataToHtml) { - return new global$5(function (res) { - res({ - html: dataToHtml(data), - url: data.source1 - }); - }); - }; - var loadedData = function (editor) { - return function (data) { - return $_bc7nlthbjjgwecoh.dataToHtml(editor, data); - }; - }; - var getEmbedHtml = function (editor, data) { - var embedHandler = $_69rpmgh3jjgwecnr.getUrlResolver(editor); - return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor)); - }; - var isCached = function (url) { - return cache.hasOwnProperty(url); - }; - var $_cwvqyth9jjgweco9 = { - getEmbedHtml: getEmbedHtml, - isCached: isCached - }; - - var doSyncSize = function (widthCtrl, heightCtrl) { - widthCtrl.state.set('oldVal', widthCtrl.value()); - heightCtrl.state.set('oldVal', heightCtrl.value()); - }; - var doSizeControls = function (win, f) { - var widthCtrl = win.find('#width')[0]; - var heightCtrl = win.find('#height')[0]; - var constrained = win.find('#constrain')[0]; - if (widthCtrl && heightCtrl && constrained) { - f(widthCtrl, heightCtrl, constrained.checked()); - } - }; - var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { - var oldWidth = widthCtrl.state.get('oldVal'); - var oldHeight = heightCtrl.state.get('oldVal'); - var newWidth = widthCtrl.value(); - var newHeight = heightCtrl.value(); - if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { - if (newWidth !== oldWidth) { - newHeight = Math.round(newWidth / oldWidth * newHeight); - if (!isNaN(newHeight)) { - heightCtrl.value(newHeight); - } - } else { - newWidth = Math.round(newHeight / oldHeight * newWidth); - if (!isNaN(newWidth)) { - widthCtrl.value(newWidth); - } - } - } - doSyncSize(widthCtrl, heightCtrl); - }; - var syncSize = function (win) { - doSizeControls(win, doSyncSize); - }; - var updateSize = function (win) { - doSizeControls(win, doUpdateSize); - }; - var createUi = function (onChange) { - var recalcSize = function () { - onChange(function (win) { - updateSize(win); - }); - }; - return { - type: 'container', - label: 'Dimensions', - layout: 'flex', - align: 'center', - spacing: 5, - items: [ - { - name: 'width', - type: 'textbox', - maxLength: 5, - size: 5, - onchange: recalcSize, - ariaLabel: 'Width' - }, - { - type: 'label', - text: 'x' - }, - { - name: 'height', - type: 'textbox', - maxLength: 5, - size: 5, - onchange: recalcSize, - ariaLabel: 'Height' - }, - { - name: 'constrain', - type: 'checkbox', - checked: true, - text: 'Constrain proportions' - } - ] - }; - }; - var $_ewaahuhhjjgwecow = { - createUi: createUi, - syncSize: syncSize, - updateSize: updateSize - }; - - var embedChange = global$1.ie && global$1.ie <= 8 ? 'onChange' : 'onInput'; - var handleError = function (editor) { - return function (error) { - var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.'; - editor.notificationManager.open({ - type: 'error', - text: errorMessage - }); - }; - }; - var getData = function (editor) { - var element = editor.selection.getNode(); - var dataEmbed = element.getAttribute('data-ephox-embed-iri'); - if (dataEmbed) { - return { - 'source1': dataEmbed, - 'data-ephox-embed-iri': dataEmbed, - 'width': $_jbvx7h8jjgwecnx.getMaxWidth(element), - 'height': $_jbvx7h8jjgwecnx.getMaxHeight(element) - }; - } - return element.getAttribute('data-mce-object') ? $_6mep3hh4jjgwecnt.htmlToData($_69rpmgh3jjgwecnr.getScripts(editor), editor.serializer.serialize(element, { selection: true })) : {}; - }; - var getSource = function (editor) { - var elm = editor.selection.getNode(); - if (elm.getAttribute('data-mce-object') || elm.getAttribute('data-ephox-embed-iri')) { - return editor.selection.getContent(); - } - }; - var addEmbedHtml = function (win, editor) { - return function (response) { - var html = response.html; - var embed = win.find('#embed')[0]; - var data = global$2.extend($_6mep3hh4jjgwecnt.htmlToData($_69rpmgh3jjgwecnr.getScripts(editor), html), { source1: response.url }); - win.fromJSON(data); - if (embed) { - embed.value(html); - $_ewaahuhhjjgwecow.updateSize(win); - } - }; - }; - var selectPlaceholder = function (editor, beforeObjects) { - var i; - var y; - var afterObjects = editor.dom.select('img[data-mce-object]'); - for (i = 0; i < beforeObjects.length; i++) { - for (y = afterObjects.length - 1; y >= 0; y--) { - if (beforeObjects[i] === afterObjects[y]) { - afterObjects.splice(y, 1); - } - } - } - editor.selection.select(afterObjects[0]); - }; - var handleInsert = function (editor, html) { - var beforeObjects = editor.dom.select('img[data-mce-object]'); - editor.insertContent(html); - selectPlaceholder(editor, beforeObjects); - editor.nodeChanged(); - }; - var submitForm = function (win, editor) { - var data = win.toJSON(); - data.embed = $_s3qkohdjjgwecon.updateHtml(data.embed, data); - if (data.embed && $_cwvqyth9jjgweco9.isCached(data.source1)) { - handleInsert(editor, data.embed); - } else { - $_cwvqyth9jjgweco9.getEmbedHtml(editor, data).then(function (response) { - handleInsert(editor, response.html); - }).catch(handleError(editor)); - } - }; - var populateMeta = function (win, meta) { - global$2.each(meta, function (value, key) { - win.find('#' + key).value(value); - }); - }; - var showDialog = function (editor) { - var win; - var data; - var generalFormItems = [{ - name: 'source1', - type: 'filepicker', - filetype: 'media', - size: 40, - autofocus: true, - label: 'Source', - onpaste: function () { - setTimeout(function () { - $_cwvqyth9jjgweco9.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); - }, 1); - }, - onchange: function (e) { - $_cwvqyth9jjgweco9.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); - populateMeta(win, e.meta); - }, - onbeforecall: function (e) { - e.meta = win.toJSON(); - } - }]; - var advancedFormItems = []; - var reserialise = function (update) { - update(win); - data = win.toJSON(); - win.find('#embed').value($_s3qkohdjjgwecon.updateHtml(data.embed, data)); - }; - if ($_69rpmgh3jjgwecnr.hasAltSource(editor)) { - advancedFormItems.push({ - name: 'source2', - type: 'filepicker', - filetype: 'media', - size: 40, - label: 'Alternative source' - }); - } - if ($_69rpmgh3jjgwecnr.hasPoster(editor)) { - advancedFormItems.push({ - name: 'poster', - type: 'filepicker', - filetype: 'image', - size: 40, - label: 'Poster' - }); - } - if ($_69rpmgh3jjgwecnr.hasDimensions(editor)) { - var control = $_ewaahuhhjjgwecow.createUi(reserialise); - generalFormItems.push(control); - } - data = getData(editor); - var embedTextBox = { - id: 'mcemediasource', - type: 'textbox', - flex: 1, - name: 'embed', - value: getSource(editor), - multiline: true, - rows: 5, - label: 'Source' - }; - var updateValueOnChange = function () { - data = global$2.extend({}, $_6mep3hh4jjgwecnt.htmlToData($_69rpmgh3jjgwecnr.getScripts(editor), this.value())); - this.parent().parent().fromJSON(data); - }; - embedTextBox[embedChange] = updateValueOnChange; - var body = [ + var urlPatterns = [ { - title: 'General', - type: 'form', - items: generalFormItems + regex: /youtu\.be\/([\w\-_\?&=.]+)/i, + type: 'iframe', + w: 560, + h: 314, + url: '//www.youtube.com/embed/$1', + allowFullscreen: true }, { - title: 'Embed', - type: 'container', - layout: 'flex', - direction: 'column', - align: 'stretch', - padding: 10, - spacing: 10, - items: [ - { - type: 'label', - text: 'Paste your embed code below:', - forId: 'mcemediasource' - }, - embedTextBox - ] + regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i, + type: 'iframe', + w: 560, + h: 314, + url: '//www.youtube.com/embed/$2?$4', + allowFullscreen: true + }, + { + regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i, + type: 'iframe', + w: 560, + h: 314, + url: '//www.youtube.com/embed/$1', + allowFullscreen: true + }, + { + regex: /vimeo\.com\/([0-9]+)/, + type: 'iframe', + w: 425, + h: 350, + url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc', + allowFullscreen: true + }, + { + regex: /vimeo\.com\/(.*)\/([0-9]+)/, + type: 'iframe', + w: 425, + h: 350, + url: '//player.vimeo.com/video/$2?title=0&byline=0', + allowFullscreen: true + }, + { + regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, + type: 'iframe', + w: 425, + h: 350, + url: '//maps.google.com/maps/ms?msid=$2&output=embed"', + allowFullscreen: false + }, + { + regex: /dailymotion\.com\/video\/([^_]+)/, + type: 'iframe', + w: 480, + h: 270, + url: '//www.dailymotion.com/embed/video/$1', + allowFullscreen: true + }, + { + regex: /dai\.ly\/([^_]+)/, + type: 'iframe', + w: 480, + h: 270, + url: '//www.dailymotion.com/embed/video/$1', + allowFullscreen: true } ]; - if (advancedFormItems.length > 0) { - body.push({ - title: 'Advanced', - type: 'form', - items: advancedFormItems + var getUrl = function (pattern, url) { + var match = pattern.regex.exec(url); + var newUrl = pattern.url; + var _loop_1 = function (i) { + newUrl = newUrl.replace('$' + i, function () { + return match[i] ? match[i] : ''; + }); + }; + for (var i = 0; i < match.length; i++) { + _loop_1(i); + } + return newUrl.replace(/\?$/, ''); + }; + var matchPattern = function (url) { + var pattern = urlPatterns.filter(function (pattern) { + return pattern.regex.test(url); }); - } - win = editor.windowManager.open({ - title: 'Insert/edit media', - data: data, - bodyType: 'tabpanel', - body: body, - onSubmit: function () { - $_ewaahuhhjjgwecow.updateSize(win); - submitForm(win, editor); + if (pattern.length > 0) { + return global$2.extend({}, pattern[0], { url: getUrl(pattern[0], url) }); + } else { + return null; } - }); - $_ewaahuhhjjgwecow.syncSize(win); - }; - var $_e3lvjbh0jjgwecnm = { showDialog: showDialog }; - - var get = function (editor) { - var showDialog = function () { - $_e3lvjbh0jjgwecnm.showDialog(editor); }; - return { showDialog: showDialog }; - }; - var $_9lh0mgzjjgwecnk = { get: get }; - var register = function (editor) { - var showDialog = function () { - $_e3lvjbh0jjgwecnm.showDialog(editor); + var getIframeHtml = function (data) { + var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : ''; + return ''; }; - editor.addCommand('mceMedia', showDialog); - }; - var $_3pne6fhijjgwecoz = { register: register }; - - var global$8 = tinymce.util.Tools.resolve('tinymce.html.Node'); - - var sanitize = function (editor, html) { - if ($_69rpmgh3jjgwecnr.shouldFilterHtml(editor) === false) { + var getFlashHtml = function (data) { + var html = ''; + if (data.poster) { + html += ''; + } + html += ''; return html; - } - var writer = global$6(); - var blocked; - global$3({ - validate: false, - allow_conditional_comments: false, - special: 'script,noscript', - comment: function (text) { - writer.comment(text); - }, - cdata: function (text) { - writer.cdata(text); - }, - text: function (text, raw) { - writer.text(text, raw); - }, - start: function (name, attrs, empty) { - blocked = true; - if (name === 'script' || name === 'noscript') { - return; - } - for (var i = 0; i < attrs.length; i++) { - if (attrs[i].name.indexOf('on') === 0) { - return; - } - if (attrs[i].name === 'style') { - attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name); - } - } - writer.start(name, attrs, empty); - blocked = false; - }, - end: function (name) { - if (blocked) { - return; - } - writer.end(name); + }; + var getAudioHtml = function (data, audioTemplateCallback) { + if (audioTemplateCallback) { + return audioTemplateCallback(data); + } else { + return ''; } - }, global$7({})).parse(html); - return writer.getContent(); - }; - var $_58i2qvhmjjgwecp7 = { sanitize: sanitize }; - - var createPlaceholderNode = function (editor, node) { - var placeHolder; - var name = node.name; - placeHolder = new global$8('img', 1); - placeHolder.shortEnded = true; - retainAttributesAndInnerHtml(editor, node, placeHolder); - placeHolder.attr({ - 'width': node.attr('width') || '300', - 'height': node.attr('height') || (name === 'audio' ? '30' : '150'), - 'style': node.attr('style'), - 'src': global$1.transparentSrc, - 'data-mce-object': name, - 'class': 'mce-object mce-object-' + name - }); - return placeHolder; - }; - var createPreviewIframeNode = function (editor, node) { - var previewWrapper; - var previewNode; - var shimNode; - var name = node.name; - previewWrapper = new global$8('span', 1); - previewWrapper.attr({ - 'contentEditable': 'false', - 'style': node.attr('style'), - 'data-mce-object': name, - 'class': 'mce-preview-object mce-object-' + name - }); - retainAttributesAndInnerHtml(editor, node, previewWrapper); - previewNode = new global$8(name, 1); - previewNode.attr({ - src: node.attr('src'), - allowfullscreen: node.attr('allowfullscreen'), - style: node.attr('style'), - class: node.attr('class'), - width: node.attr('width'), - height: node.attr('height'), - frameborder: '0' - }); - shimNode = new global$8('span', 1); - shimNode.attr('class', 'mce-shim'); - previewWrapper.append(previewNode); - previewWrapper.append(shimNode); - return previewWrapper; - }; - var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) { - var attrName; - var attrValue; - var attribs; - var ai; - var innerHtml; - attribs = sourceNode.attributes; - ai = attribs.length; - while (ai--) { - attrName = attribs[ai].name; - attrValue = attribs[ai].value; - if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') { - if (attrName === 'data' || attrName === 'src') { - attrValue = editor.convertURL(attrValue, attrName); - } - targetNode.attr('data-mce-p-' + attrName, attrValue); + }; + var getVideoHtml = function (data, videoTemplateCallback) { + if (videoTemplateCallback) { + return videoTemplateCallback(data); + } else { + return ''; } - } - innerHtml = sourceNode.firstChild && sourceNode.firstChild.value; - if (innerHtml) { - targetNode.attr('data-mce-html', escape($_58i2qvhmjjgwecp7.sanitize(editor, innerHtml))); - targetNode.firstChild = null; - } - }; - var isWithinEphoxEmbed = function (node) { - while (node = node.parent) { - if (node.attr('data-ephox-embed-iri')) { - return true; + }; + var getScriptHtml = function (data) { + return ''; + }; + var dataToHtml = function (editor, dataIn) { + var data = global$2.extend({}, dataIn); + if (!data.source1) { + global$2.extend(data, HtmlToData.htmlToData(Settings.getScripts(editor), data.embed)); + if (!data.source1) { + return ''; + } } - } - return false; - }; - var placeHolderConverter = function (editor) { - return function (nodes) { - var i = nodes.length; - var node; - var videoScript; - while (i--) { - node = nodes[i]; - if (!node.parent) { - continue; - } - if (node.parent.attr('data-mce-object')) { - continue; - } - if (node.name === 'script') { - videoScript = $_4q3fmh7jjgwecnw.getVideoScriptMatch($_69rpmgh3jjgwecnr.getScripts(editor), node.attr('src')); - if (!videoScript) { - continue; - } - } + if (!data.source2) { + data.source2 = ''; + } + if (!data.poster) { + data.poster = ''; + } + data.source1 = editor.convertURL(data.source1, 'source'); + data.source2 = editor.convertURL(data.source2, 'source'); + data.source1mime = Mime.guess(data.source1); + data.source2mime = Mime.guess(data.source2); + data.poster = editor.convertURL(data.poster, 'poster'); + var pattern = matchPattern(data.source1); + if (pattern) { + data.source1 = pattern.url; + data.type = pattern.type; + data.allowFullscreen = pattern.allowFullscreen; + data.width = data.width || pattern.w; + data.height = data.height || pattern.h; + } + if (data.embed) { + return UpdateHtml.updateHtml(data.embed, data, true); + } else { + var videoScript = VideoScript.getVideoScriptMatch(Settings.getScripts(editor), data.source1); if (videoScript) { - if (videoScript.width) { - node.attr('width', videoScript.width.toString()); - } - if (videoScript.height) { - node.attr('height', videoScript.height.toString()); - } + data.type = 'script'; + data.width = videoScript.width; + data.height = videoScript.height; } - if (node.name === 'iframe' && $_69rpmgh3jjgwecnr.hasLiveEmbeds(editor) && global$1.ceFalse) { - if (!isWithinEphoxEmbed(node)) { - node.replace(createPreviewIframeNode(editor, node)); + var audioTemplateCallback = Settings.getAudioTemplateCallback(editor); + var videoTemplateCallback = Settings.getVideoTemplateCallback(editor); + data.width = data.width || 300; + data.height = data.height || 150; + global$2.each(data, function (value, key) { + data[key] = editor.dom.encode(value); + }); + if (data.type === 'iframe') { + return getIframeHtml(data); + } else if (data.source1mime === 'application/x-shockwave-flash') { + return getFlashHtml(data); + } else if (data.source1mime.indexOf('audio') !== -1) { + return getAudioHtml(data, audioTemplateCallback); + } else if (data.type === 'script') { + return getScriptHtml(data); + } else { + return getVideoHtml(data, videoTemplateCallback); + } + } + }; + var DataToHtml = { dataToHtml: dataToHtml }; + + var cache = {}; + var embedPromise = function (data, dataToHtml, handler) { + return new global$5(function (res, rej) { + var wrappedResolve = function (response) { + if (response.html) { + cache[data.source1] = response; + } + return res({ + url: data.source1, + html: response.html ? response.html : dataToHtml(data) + }); + }; + if (cache[data.source1]) { + wrappedResolve(cache[data.source1]); + } else { + handler({ url: data.source1 }, wrappedResolve, rej); + } + }); + }; + var defaultPromise = function (data, dataToHtml) { + return new global$5(function (res) { + res({ + html: dataToHtml(data), + url: data.source1 + }); + }); + }; + var loadedData = function (editor) { + return function (data) { + return DataToHtml.dataToHtml(editor, data); + }; + }; + var getEmbedHtml = function (editor, data) { + var embedHandler = Settings.getUrlResolver(editor); + return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor)); + }; + var isCached = function (url) { + return cache.hasOwnProperty(url); + }; + var Service = { + getEmbedHtml: getEmbedHtml, + isCached: isCached + }; + + var doSyncSize = function (widthCtrl, heightCtrl) { + widthCtrl.state.set('oldVal', widthCtrl.value()); + heightCtrl.state.set('oldVal', heightCtrl.value()); + }; + var doSizeControls = function (win, f) { + var widthCtrl = win.find('#width')[0]; + var heightCtrl = win.find('#height')[0]; + var constrained = win.find('#constrain')[0]; + if (widthCtrl && heightCtrl && constrained) { + f(widthCtrl, heightCtrl, constrained.checked()); + } + }; + var doUpdateSize = function (widthCtrl, heightCtrl, isContrained) { + var oldWidth = widthCtrl.state.get('oldVal'); + var oldHeight = heightCtrl.state.get('oldVal'); + var newWidth = widthCtrl.value(); + var newHeight = heightCtrl.value(); + if (isContrained && oldWidth && oldHeight && newWidth && newHeight) { + if (newWidth !== oldWidth) { + newHeight = Math.round(newWidth / oldWidth * newHeight); + if (!isNaN(newHeight)) { + heightCtrl.value(newHeight); } } else { - if (!isWithinEphoxEmbed(node)) { - node.replace(createPlaceholderNode(editor, node)); + newWidth = Math.round(newHeight / oldHeight * newWidth); + if (!isNaN(newWidth)) { + widthCtrl.value(newWidth); } } } + doSyncSize(widthCtrl, heightCtrl); + }; + var syncSize = function (win) { + doSizeControls(win, doSyncSize); + }; + var updateSize = function (win) { + doSizeControls(win, doUpdateSize); + }; + var createUi = function (onChange) { + var recalcSize = function () { + onChange(function (win) { + updateSize(win); + }); + }; + return { + type: 'container', + label: 'Dimensions', + layout: 'flex', + align: 'center', + spacing: 5, + items: [ + { + name: 'width', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Width' + }, + { + type: 'label', + text: 'x' + }, + { + name: 'height', + type: 'textbox', + maxLength: 5, + size: 5, + onchange: recalcSize, + ariaLabel: 'Height' + }, + { + name: 'constrain', + type: 'checkbox', + checked: true, + text: 'Constrain proportions' + } + ] + }; + }; + var SizeManager = { + createUi: createUi, + syncSize: syncSize, + updateSize: updateSize }; - }; - var $_ggjz3ehljjgwecp4 = { - createPreviewIframeNode: createPreviewIframeNode, - createPlaceholderNode: createPlaceholderNode, - placeHolderConverter: placeHolderConverter - }; - var setup = function (editor) { - editor.on('preInit', function () { - var specialElements = editor.schema.getSpecialElements(); - global$2.each('video audio iframe object'.split(' '), function (name) { - specialElements[name] = new RegExp(']*>', 'gi'); + var embedChange = global$1.ie && global$1.ie <= 8 ? 'onChange' : 'onInput'; + var handleError = function (editor) { + return function (error) { + var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.'; + editor.notificationManager.open({ + type: 'error', + text: errorMessage + }); + }; + }; + var getData = function (editor) { + var element = editor.selection.getNode(); + var dataEmbed = element.getAttribute('data-ephox-embed-iri'); + if (dataEmbed) { + return { + 'source1': dataEmbed, + 'data-ephox-embed-iri': dataEmbed, + 'width': Size.getMaxWidth(element), + 'height': Size.getMaxHeight(element) + }; + } + return element.getAttribute('data-mce-object') ? HtmlToData.htmlToData(Settings.getScripts(editor), editor.serializer.serialize(element, { selection: true })) : {}; + }; + var getSource = function (editor) { + var elm = editor.selection.getNode(); + if (elm.getAttribute('data-mce-object') || elm.getAttribute('data-ephox-embed-iri')) { + return editor.selection.getContent(); + } + }; + var addEmbedHtml = function (win, editor) { + return function (response) { + var html = response.html; + var embed = win.find('#embed')[0]; + var data = global$2.extend(HtmlToData.htmlToData(Settings.getScripts(editor), html), { source1: response.url }); + win.fromJSON(data); + if (embed) { + embed.value(html); + SizeManager.updateSize(win); + } + }; + }; + var selectPlaceholder = function (editor, beforeObjects) { + var i; + var y; + var afterObjects = editor.dom.select('img[data-mce-object]'); + for (i = 0; i < beforeObjects.length; i++) { + for (y = afterObjects.length - 1; y >= 0; y--) { + if (beforeObjects[i] === afterObjects[y]) { + afterObjects.splice(y, 1); + } + } + } + editor.selection.select(afterObjects[0]); + }; + var handleInsert = function (editor, html) { + var beforeObjects = editor.dom.select('img[data-mce-object]'); + editor.insertContent(html); + selectPlaceholder(editor, beforeObjects); + editor.nodeChanged(); + }; + var submitForm = function (win, editor) { + var data = win.toJSON(); + data.embed = UpdateHtml.updateHtml(data.embed, data); + if (data.embed && Service.isCached(data.source1)) { + handleInsert(editor, data.embed); + } else { + Service.getEmbedHtml(editor, data).then(function (response) { + handleInsert(editor, response.html); + }).catch(handleError(editor)); + } + }; + var populateMeta = function (win, meta) { + global$2.each(meta, function (value, key) { + win.find('#' + key).value(value); }); - var boolAttrs = editor.schema.getBoolAttrs(); - global$2.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) { - boolAttrs[name] = {}; + }; + var showDialog = function (editor) { + var win; + var data; + var generalFormItems = [{ + name: 'source1', + type: 'filepicker', + filetype: 'media', + size: 40, + autofocus: true, + label: 'Source', + onpaste: function () { + setTimeout(function () { + Service.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); + }, 1); + }, + onchange: function (e) { + Service.getEmbedHtml(editor, win.toJSON()).then(addEmbedHtml(win, editor)).catch(handleError(editor)); + populateMeta(win, e.meta); + }, + onbeforecall: function (e) { + e.meta = win.toJSON(); + } + }]; + var advancedFormItems = []; + var reserialise = function (update) { + update(win); + data = win.toJSON(); + win.find('#embed').value(UpdateHtml.updateHtml(data.embed, data)); + }; + if (Settings.hasAltSource(editor)) { + advancedFormItems.push({ + name: 'source2', + type: 'filepicker', + filetype: 'media', + size: 40, + label: 'Alternative source' + }); + } + if (Settings.hasPoster(editor)) { + advancedFormItems.push({ + name: 'poster', + type: 'filepicker', + filetype: 'image', + size: 40, + label: 'Poster' + }); + } + if (Settings.hasDimensions(editor)) { + var control = SizeManager.createUi(reserialise); + generalFormItems.push(control); + } + data = getData(editor); + var embedTextBox = { + id: 'mcemediasource', + type: 'textbox', + flex: 1, + name: 'embed', + value: getSource(editor), + multiline: true, + rows: 5, + label: 'Source' + }; + var updateValueOnChange = function () { + data = global$2.extend({}, HtmlToData.htmlToData(Settings.getScripts(editor), this.value())); + this.parent().parent().fromJSON(data); + }; + embedTextBox[embedChange] = updateValueOnChange; + var body = [ + { + title: 'General', + type: 'form', + items: generalFormItems + }, + { + title: 'Embed', + type: 'container', + layout: 'flex', + direction: 'column', + align: 'stretch', + padding: 10, + spacing: 10, + items: [ + { + type: 'label', + text: 'Paste your embed code below:', + forId: 'mcemediasource' + }, + embedTextBox + ] + } + ]; + if (advancedFormItems.length > 0) { + body.push({ + title: 'Advanced', + type: 'form', + items: advancedFormItems + }); + } + win = editor.windowManager.open({ + title: 'Insert/edit media', + data: data, + bodyType: 'tabpanel', + body: body, + onSubmit: function () { + SizeManager.updateSize(win); + submitForm(win, editor); + } }); - editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', $_ggjz3ehljjgwecp4.placeHolderConverter(editor)); - editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) { + SizeManager.syncSize(win); + }; + var Dialog = { showDialog: showDialog }; + + var get = function (editor) { + var showDialog = function () { + Dialog.showDialog(editor); + }; + return { showDialog: showDialog }; + }; + var Api = { get: get }; + + var register = function (editor) { + var showDialog = function () { + Dialog.showDialog(editor); + }; + editor.addCommand('mceMedia', showDialog); + }; + var Commands = { register: register }; + + var global$8 = tinymce.util.Tools.resolve('tinymce.html.Node'); + + var sanitize = function (editor, html) { + if (Settings.shouldFilterHtml(editor) === false) { + return html; + } + var writer = global$6(); + var blocked; + global$3({ + validate: false, + allow_conditional_comments: false, + special: 'script,noscript', + comment: function (text) { + writer.comment(text); + }, + cdata: function (text) { + writer.cdata(text); + }, + text: function (text, raw) { + writer.text(text, raw); + }, + start: function (name, attrs, empty) { + blocked = true; + if (name === 'script' || name === 'noscript') { + return; + } + for (var i = 0; i < attrs.length; i++) { + if (attrs[i].name.indexOf('on') === 0) { + return; + } + if (attrs[i].name === 'style') { + attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name); + } + } + writer.start(name, attrs, empty); + blocked = false; + }, + end: function (name) { + if (blocked) { + return; + } + writer.end(name); + } + }, global$7({})).parse(html); + return writer.getContent(); + }; + var Sanitize = { sanitize: sanitize }; + + var createPlaceholderNode = function (editor, node) { + var placeHolder; + var name = node.name; + placeHolder = new global$8('img', 1); + placeHolder.shortEnded = true; + retainAttributesAndInnerHtml(editor, node, placeHolder); + placeHolder.attr({ + 'width': node.attr('width') || '300', + 'height': node.attr('height') || (name === 'audio' ? '30' : '150'), + 'style': node.attr('style'), + 'src': global$1.transparentSrc, + 'data-mce-object': name, + 'class': 'mce-object mce-object-' + name + }); + return placeHolder; + }; + var createPreviewIframeNode = function (editor, node) { + var previewWrapper; + var previewNode; + var shimNode; + var name = node.name; + previewWrapper = new global$8('span', 1); + previewWrapper.attr({ + 'contentEditable': 'false', + 'style': node.attr('style'), + 'data-mce-object': name, + 'class': 'mce-preview-object mce-object-' + name + }); + retainAttributesAndInnerHtml(editor, node, previewWrapper); + previewNode = new global$8(name, 1); + previewNode.attr({ + src: node.attr('src'), + allowfullscreen: node.attr('allowfullscreen'), + style: node.attr('style'), + class: node.attr('class'), + width: node.attr('width'), + height: node.attr('height'), + frameborder: '0' + }); + shimNode = new global$8('span', 1); + shimNode.attr('class', 'mce-shim'); + previewWrapper.append(previewNode); + previewWrapper.append(shimNode); + return previewWrapper; + }; + var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) { + var attrName; + var attrValue; + var attribs; + var ai; + var innerHtml; + attribs = sourceNode.attributes; + ai = attribs.length; + while (ai--) { + attrName = attribs[ai].name; + attrValue = attribs[ai].value; + if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') { + if (attrName === 'data' || attrName === 'src') { + attrValue = editor.convertURL(attrValue, attrName); + } + targetNode.attr('data-mce-p-' + attrName, attrValue); + } + } + innerHtml = sourceNode.firstChild && sourceNode.firstChild.value; + if (innerHtml) { + targetNode.attr('data-mce-html', escape(Sanitize.sanitize(editor, innerHtml))); + targetNode.firstChild = null; + } + }; + var isWithinEphoxEmbed = function (node) { + while (node = node.parent) { + if (node.attr('data-ephox-embed-iri')) { + return true; + } + } + return false; + }; + var placeHolderConverter = function (editor) { + return function (nodes) { var i = nodes.length; var node; - var realElm; - var ai; - var attribs; - var innerHtml; - var innerNode; - var realElmName; - var className; + var videoScript; while (i--) { node = nodes[i]; if (!node.parent) { continue; } - realElmName = node.attr(name); - realElm = new global$8(realElmName, 1); - if (realElmName !== 'audio' && realElmName !== 'script') { - className = node.attr('class'); - if (className && className.indexOf('mce-preview-object') !== -1) { - realElm.attr({ - width: node.firstChild.attr('width'), - height: node.firstChild.attr('height') - }); - } else { - realElm.attr({ - width: node.attr('width'), - height: node.attr('height') - }); + if (node.parent.attr('data-mce-object')) { + continue; + } + if (node.name === 'script') { + videoScript = VideoScript.getVideoScriptMatch(Settings.getScripts(editor), node.attr('src')); + if (!videoScript) { + continue; } } - realElm.attr({ style: node.attr('style') }); - attribs = node.attributes; - ai = attribs.length; - while (ai--) { - var attrName = attribs[ai].name; - if (attrName.indexOf('data-mce-p-') === 0) { - realElm.attr(attrName.substr(11), attribs[ai].value); + if (videoScript) { + if (videoScript.width) { + node.attr('width', videoScript.width.toString()); + } + if (videoScript.height) { + node.attr('height', videoScript.height.toString()); } } - if (realElmName === 'script') { - realElm.attr('type', 'text/javascript'); + if (node.name === 'iframe' && Settings.hasLiveEmbeds(editor) && global$1.ceFalse) { + if (!isWithinEphoxEmbed(node)) { + node.replace(createPreviewIframeNode(editor, node)); + } + } else { + if (!isWithinEphoxEmbed(node)) { + node.replace(createPlaceholderNode(editor, node)); + } } - innerHtml = node.attr('data-mce-html'); - if (innerHtml) { - innerNode = new global$8('#text', 3); - innerNode.raw = true; - innerNode.value = $_58i2qvhmjjgwecp7.sanitize(editor, unescape(innerHtml)); - realElm.append(innerNode); + } + }; + }; + var Nodes = { + createPreviewIframeNode: createPreviewIframeNode, + createPlaceholderNode: createPlaceholderNode, + placeHolderConverter: placeHolderConverter + }; + + var setup = function (editor) { + editor.on('preInit', function () { + var specialElements = editor.schema.getSpecialElements(); + global$2.each('video audio iframe object'.split(' '), function (name) { + specialElements[name] = new RegExp(']*>', 'gi'); + }); + var boolAttrs = editor.schema.getBoolAttrs(); + global$2.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) { + boolAttrs[name] = {}; + }); + editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', Nodes.placeHolderConverter(editor)); + editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) { + var i = nodes.length; + var node; + var realElm; + var ai; + var attribs; + var innerHtml; + var innerNode; + var realElmName; + var className; + while (i--) { + node = nodes[i]; + if (!node.parent) { + continue; + } + realElmName = node.attr(name); + realElm = new global$8(realElmName, 1); + if (realElmName !== 'audio' && realElmName !== 'script') { + className = node.attr('class'); + if (className && className.indexOf('mce-preview-object') !== -1) { + realElm.attr({ + width: node.firstChild.attr('width'), + height: node.firstChild.attr('height') + }); + } else { + realElm.attr({ + width: node.attr('width'), + height: node.attr('height') + }); + } + } + realElm.attr({ style: node.attr('style') }); + attribs = node.attributes; + ai = attribs.length; + while (ai--) { + var attrName = attribs[ai].name; + if (attrName.indexOf('data-mce-p-') === 0) { + realElm.attr(attrName.substr(11), attribs[ai].value); + } + } + if (realElmName === 'script') { + realElm.attr('type', 'text/javascript'); + } + innerHtml = node.attr('data-mce-html'); + if (innerHtml) { + innerNode = new global$8('#text', 3); + innerNode.raw = true; + innerNode.value = Sanitize.sanitize(editor, unescape(innerHtml)); + realElm.append(innerNode); + } + node.replace(realElm); } - node.replace(realElm); + }); + }); + editor.on('setContent', function () { + editor.$('span.mce-preview-object').each(function (index, elm) { + var $elm = editor.$(elm); + if ($elm.find('span.mce-shim', elm).length === 0) { + $elm.append(''); + } + }); + }); + }; + var FilterContent = { setup: setup }; + + var setup$1 = function (editor) { + editor.on('ResolveName', function (e) { + var name; + if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { + e.name = name; } }); - }); - editor.on('setContent', function () { - editor.$('span.mce-preview-object').each(function (index, elm) { - var $elm = editor.$(elm); - if ($elm.find('span.mce-shim', elm).length === 0) { - $elm.append(''); + }; + var ResolveName = { setup: setup$1 }; + + var setup$2 = function (editor) { + editor.on('click keyup', function () { + var selectedNode = editor.selection.getNode(); + if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { + if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { + selectedNode.setAttribute('data-mce-selected', '2'); + } } }); - }); - }; - var $_4o7ga9hjjjgwecp0 = { setup: setup }; - - var setup$1 = function (editor) { - editor.on('ResolveName', function (e) { - var name; - if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) { - e.name = name; - } - }); - }; - var $_1y6lb6hnjjgwecp9 = { setup: setup$1 }; - - var setup$2 = function (editor) { - editor.on('click keyup', function () { - var selectedNode = editor.selection.getNode(); - if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) { - if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) { - selectedNode.setAttribute('data-mce-selected', '2'); + editor.on('ObjectSelected', function (e) { + var objectType = e.target.getAttribute('data-mce-object'); + if (objectType === 'audio' || objectType === 'script') { + e.preventDefault(); } - } - }); - editor.on('ObjectSelected', function (e) { - var objectType = e.target.getAttribute('data-mce-object'); - if (objectType === 'audio' || objectType === 'script') { - e.preventDefault(); - } - }); - editor.on('objectResized', function (e) { - var target = e.target; - var html; - if (target.getAttribute('data-mce-object')) { - html = target.getAttribute('data-mce-html'); - if (html) { - html = unescape(html); - target.setAttribute('data-mce-html', escape($_s3qkohdjjgwecon.updateHtml(html, { - width: e.width, - height: e.height - }))); + }); + editor.on('objectResized', function (e) { + var target = e.target; + var html; + if (target.getAttribute('data-mce-object')) { + html = target.getAttribute('data-mce-html'); + if (html) { + html = unescape(html); + target.setAttribute('data-mce-html', escape(UpdateHtml.updateHtml(html, { + width: e.width, + height: e.height + }))); + } } - } - }); - }; - var $_dnm1d2hojjgwecpa = { setup: setup$2 }; + }); + }; + var Selection = { setup: setup$2 }; - var register$1 = function (editor) { - editor.addButton('media', { - tooltip: 'Insert/edit media', - cmd: 'mceMedia', - stateSelector: [ - 'img[data-mce-object]', - 'span[data-mce-object]', - 'div[data-ephox-embed-iri]' - ] - }); - editor.addMenuItem('media', { - icon: 'media', - text: 'Media', - cmd: 'mceMedia', - context: 'insert', - prependToContext: true - }); - }; - var $_94c7u1hpjjgwecpc = { register: register$1 }; + var register$1 = function (editor) { + editor.addButton('media', { + tooltip: 'Insert/edit media', + cmd: 'mceMedia', + stateSelector: [ + 'img[data-mce-object]', + 'span[data-mce-object]', + 'div[data-ephox-embed-iri]' + ] + }); + editor.addMenuItem('media', { + icon: 'media', + text: 'Media', + cmd: 'mceMedia', + context: 'insert', + prependToContext: true + }); + }; + var Buttons = { register: register$1 }; - global.add('media', function (editor) { - $_3pne6fhijjgwecoz.register(editor); - $_94c7u1hpjjgwecpc.register(editor); - $_1y6lb6hnjjgwecp9.setup(editor); - $_4o7ga9hjjjgwecp0.setup(editor); - $_dnm1d2hojjgwecpa.setup(editor); - return $_9lh0mgzjjgwecnk.get(editor); - }); - function Plugin () { - } + global.add('media', function (editor) { + Commands.register(editor); + Buttons.register(editor); + ResolveName.setup(editor); + FilterContent.setup(editor); + Selection.setup(editor); + return Api.get(editor); + }); + function Plugin () { + } - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/paste/plugin.js b/wp-includes/js/tinymce/plugins/paste/plugin.js index 2b9d71e56b..4a9f915e11 100644 --- a/wp-includes/js/tinymce/plugins/paste/plugin.js +++ b/wp-includes/js/tinymce/plugins/paste/plugin.js @@ -1,1497 +1,1858 @@ (function () { var paste = (function () { - 'use strict'; + 'use strict'; - var Cell = function (initial) { - var value = initial; - var get = function () { - return value; + var Cell = function (initial) { + var value = initial; + var get = function () { + return value; + }; + var set = function (v) { + value = v; + }; + var clone = function () { + return Cell(get()); + }; + return { + get: get, + set: set, + clone: clone + }; }; - var set = function (v) { - value = v; - }; - var clone = function () { - return Cell(get()); - }; - return { - get: get, - set: set, - clone: clone - }; - }; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var hasProPlugin = function (editor) { - if (/(^|[ ,])powerpaste([, ]|$)/.test(editor.settings.plugins) && global.get('powerpaste')) { - if (typeof window.console !== 'undefined' && window.console.log) { - window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.'); + var hasProPlugin = function (editor) { + if (/(^|[ ,])powerpaste([, ]|$)/.test(editor.settings.plugins) && global.get('powerpaste')) { + if (typeof window.console !== 'undefined' && window.console.log) { + window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.'); + } + return true; + } else { + return false; } - return true; - } else { - return false; - } - }; - var $_15bf6siejjgwect1 = { hasProPlugin: hasProPlugin }; - - var get = function (clipboard, quirks) { - return { - clipboard: clipboard, - quirks: quirks }; - }; - var $_6gtliyigjjgwecte = { get: get }; + var DetectProPlugin = { hasProPlugin: hasProPlugin }; - var firePastePreProcess = function (editor, html, internal, isWordHtml) { - return editor.fire('PastePreProcess', { - content: html, - internal: internal, - wordContent: isWordHtml - }); - }; - var firePastePostProcess = function (editor, node, internal, isWordHtml) { - return editor.fire('PastePostProcess', { - node: node, - internal: internal, - wordContent: isWordHtml - }); - }; - var firePastePlainTextToggle = function (editor, state) { - return editor.fire('PastePlainTextToggle', { state: state }); - }; - var firePaste = function (editor, ieFake) { - return editor.fire('paste', { ieFake: ieFake }); - }; - var $_8tki3zijjjgwectj = { - firePastePreProcess: firePastePreProcess, - firePastePostProcess: firePastePostProcess, - firePastePlainTextToggle: firePastePlainTextToggle, - firePaste: firePaste - }; + var get = function (clipboard, quirks) { + return { + clipboard: clipboard, + quirks: quirks + }; + }; + var Api = { get: get }; - var shouldPlainTextInform = function (editor) { - return editor.getParam('paste_plaintext_inform', true); - }; - var shouldBlockDrop = function (editor) { - return editor.getParam('paste_block_drop', false); - }; - var shouldPasteDataImages = function (editor) { - return editor.getParam('paste_data_images', false); - }; - var shouldFilterDrop = function (editor) { - return editor.getParam('paste_filter_drop', true); - }; - var getPreProcess = function (editor) { - return editor.getParam('paste_preprocess'); - }; - var getPostProcess = function (editor) { - return editor.getParam('paste_postprocess'); - }; - var getWebkitStyles = function (editor) { - return editor.getParam('paste_webkit_styles'); - }; - var shouldRemoveWebKitStyles = function (editor) { - return editor.getParam('paste_remove_styles_if_webkit', true); - }; - var shouldMergeFormats = function (editor) { - return editor.getParam('paste_merge_formats', true); - }; - var isSmartPasteEnabled = function (editor) { - return editor.getParam('smart_paste', true); - }; - var isPasteAsTextEnabled = function (editor) { - return editor.getParam('paste_as_text', false); - }; - var getRetainStyleProps = function (editor) { - return editor.getParam('paste_retain_style_properties'); - }; - var getWordValidElements = function (editor) { - var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'; - return editor.getParam('paste_word_valid_elements', defaultValidElements); - }; - var shouldConvertWordFakeLists = function (editor) { - return editor.getParam('paste_convert_word_fake_lists', true); - }; - var shouldUseDefaultFilters = function (editor) { - return editor.getParam('paste_enable_default_filters', true); - }; - var $_xr8b0ikjjgwectl = { - shouldPlainTextInform: shouldPlainTextInform, - shouldBlockDrop: shouldBlockDrop, - shouldPasteDataImages: shouldPasteDataImages, - shouldFilterDrop: shouldFilterDrop, - getPreProcess: getPreProcess, - getPostProcess: getPostProcess, - getWebkitStyles: getWebkitStyles, - shouldRemoveWebKitStyles: shouldRemoveWebKitStyles, - shouldMergeFormats: shouldMergeFormats, - isSmartPasteEnabled: isSmartPasteEnabled, - isPasteAsTextEnabled: isPasteAsTextEnabled, - getRetainStyleProps: getRetainStyleProps, - getWordValidElements: getWordValidElements, - shouldConvertWordFakeLists: shouldConvertWordFakeLists, - shouldUseDefaultFilters: shouldUseDefaultFilters - }; + var firePastePreProcess = function (editor, html, internal, isWordHtml) { + return editor.fire('PastePreProcess', { + content: html, + internal: internal, + wordContent: isWordHtml + }); + }; + var firePastePostProcess = function (editor, node, internal, isWordHtml) { + return editor.fire('PastePostProcess', { + node: node, + internal: internal, + wordContent: isWordHtml + }); + }; + var firePastePlainTextToggle = function (editor, state) { + return editor.fire('PastePlainTextToggle', { state: state }); + }; + var firePaste = function (editor, ieFake) { + return editor.fire('paste', { ieFake: ieFake }); + }; + var Events = { + firePastePreProcess: firePastePreProcess, + firePastePostProcess: firePastePostProcess, + firePastePlainTextToggle: firePastePlainTextToggle, + firePaste: firePaste + }; - var shouldInformUserAboutPlainText = function (editor, userIsInformedState) { - return userIsInformedState.get() === false && $_xr8b0ikjjgwectl.shouldPlainTextInform(editor); - }; - var displayNotification = function (editor, message) { - editor.notificationManager.open({ - text: editor.translate(message), - type: 'info' - }); - }; - var togglePlainTextPaste = function (editor, clipboard, userIsInformedState) { - if (clipboard.pasteFormat.get() === 'text') { - clipboard.pasteFormat.set('html'); - $_8tki3zijjjgwectj.firePastePlainTextToggle(editor, false); - } else { - clipboard.pasteFormat.set('text'); - $_8tki3zijjjgwectj.firePastePlainTextToggle(editor, true); - if (shouldInformUserAboutPlainText(editor, userIsInformedState)) { - displayNotification(editor, 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.'); - userIsInformedState.set(true); - } - } - editor.focus(); - }; - var $_2j7vw7iijjgwecti = { togglePlainTextPaste: togglePlainTextPaste }; + var shouldPlainTextInform = function (editor) { + return editor.getParam('paste_plaintext_inform', true); + }; + var shouldBlockDrop = function (editor) { + return editor.getParam('paste_block_drop', false); + }; + var shouldPasteDataImages = function (editor) { + return editor.getParam('paste_data_images', false); + }; + var shouldFilterDrop = function (editor) { + return editor.getParam('paste_filter_drop', true); + }; + var getPreProcess = function (editor) { + return editor.getParam('paste_preprocess'); + }; + var getPostProcess = function (editor) { + return editor.getParam('paste_postprocess'); + }; + var getWebkitStyles = function (editor) { + return editor.getParam('paste_webkit_styles'); + }; + var shouldRemoveWebKitStyles = function (editor) { + return editor.getParam('paste_remove_styles_if_webkit', true); + }; + var shouldMergeFormats = function (editor) { + return editor.getParam('paste_merge_formats', true); + }; + var isSmartPasteEnabled = function (editor) { + return editor.getParam('smart_paste', true); + }; + var isPasteAsTextEnabled = function (editor) { + return editor.getParam('paste_as_text', false); + }; + var getRetainStyleProps = function (editor) { + return editor.getParam('paste_retain_style_properties'); + }; + var getWordValidElements = function (editor) { + var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'; + return editor.getParam('paste_word_valid_elements', defaultValidElements); + }; + var shouldConvertWordFakeLists = function (editor) { + return editor.getParam('paste_convert_word_fake_lists', true); + }; + var shouldUseDefaultFilters = function (editor) { + return editor.getParam('paste_enable_default_filters', true); + }; + var Settings = { + shouldPlainTextInform: shouldPlainTextInform, + shouldBlockDrop: shouldBlockDrop, + shouldPasteDataImages: shouldPasteDataImages, + shouldFilterDrop: shouldFilterDrop, + getPreProcess: getPreProcess, + getPostProcess: getPostProcess, + getWebkitStyles: getWebkitStyles, + shouldRemoveWebKitStyles: shouldRemoveWebKitStyles, + shouldMergeFormats: shouldMergeFormats, + isSmartPasteEnabled: isSmartPasteEnabled, + isPasteAsTextEnabled: isPasteAsTextEnabled, + getRetainStyleProps: getRetainStyleProps, + getWordValidElements: getWordValidElements, + shouldConvertWordFakeLists: shouldConvertWordFakeLists, + shouldUseDefaultFilters: shouldUseDefaultFilters + }; - var register = function (editor, clipboard, userIsInformedState) { - editor.addCommand('mceTogglePlainTextPaste', function () { - $_2j7vw7iijjgwecti.togglePlainTextPaste(editor, clipboard, userIsInformedState); - }); - editor.addCommand('mceInsertClipboardContent', function (ui, value) { - if (value.content) { - clipboard.pasteHtml(value.content, value.internal); - } - if (value.text) { - clipboard.pasteText(value.text); - } - }); - }; - var $_fldd1mihjjgwecth = { register: register }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay'); - - var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var internalMimeType = 'x-tinymce/html'; - var internalMark = ''; - var mark = function (html) { - return internalMark + html; - }; - var unmark = function (html) { - return html.replace(internalMark, ''); - }; - var isMarked = function (html) { - return html.indexOf(internalMark) !== -1; - }; - var $_4x13hjirjjgwecu1 = { - mark: mark, - unmark: unmark, - isMarked: isMarked, - internalHtmlMime: function () { - return internalMimeType; - } - }; - - var global$5 = tinymce.util.Tools.resolve('tinymce.html.Entities'); - - var isPlainText = function (text) { - return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text); - }; - var toBRs = function (text) { - return text.replace(/\r?\n/g, '
'); - }; - var openContainer = function (rootTag, rootAttrs) { - var key; - var attrs = []; - var tag = '<' + rootTag; - if (typeof rootAttrs === 'object') { - for (key in rootAttrs) { - if (rootAttrs.hasOwnProperty(key)) { - attrs.push(key + '="' + global$5.encodeAllRaw(rootAttrs[key]) + '"'); + var shouldInformUserAboutPlainText = function (editor, userIsInformedState) { + return userIsInformedState.get() === false && Settings.shouldPlainTextInform(editor); + }; + var displayNotification = function (editor, message) { + editor.notificationManager.open({ + text: editor.translate(message), + type: 'info' + }); + }; + var togglePlainTextPaste = function (editor, clipboard, userIsInformedState) { + if (clipboard.pasteFormat.get() === 'text') { + clipboard.pasteFormat.set('html'); + Events.firePastePlainTextToggle(editor, false); + } else { + clipboard.pasteFormat.set('text'); + Events.firePastePlainTextToggle(editor, true); + if (shouldInformUserAboutPlainText(editor, userIsInformedState)) { + displayNotification(editor, 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.'); + userIsInformedState.set(true); } } - if (attrs.length) { - tag += ' ' + attrs.join(' '); - } - } - return tag + '>'; - }; - var toBlockElements = function (text, rootTag, rootAttrs) { - var blocks = text.split(/\n\n/); - var tagOpen = openContainer(rootTag, rootAttrs); - var tagClose = ''; - var paragraphs = global$3.map(blocks, function (p) { - return p.split(/\n/).join('
'); - }); - var stitch = function (p) { - return tagOpen + p + tagClose; + editor.focus(); }; - return paragraphs.length === 1 ? paragraphs[0] : global$3.map(paragraphs, stitch).join(''); - }; - var convert = function (text, rootTag, rootAttrs) { - return rootTag ? toBlockElements(text, rootTag, rootAttrs) : toBRs(text); - }; - var $_4h3hnrisjjgwecu2 = { - isPlainText: isPlainText, - convert: convert, - toBRs: toBRs, - toBlockElements: toBlockElements - }; + var Actions = { togglePlainTextPaste: togglePlainTextPaste }; - var global$6 = tinymce.util.Tools.resolve('tinymce.html.DomParser'); + var register = function (editor, clipboard, userIsInformedState) { + editor.addCommand('mceTogglePlainTextPaste', function () { + Actions.togglePlainTextPaste(editor, clipboard, userIsInformedState); + }); + editor.addCommand('mceInsertClipboardContent', function (ui, value) { + if (value.content) { + clipboard.pasteHtml(value.content, value.internal); + } + if (value.text) { + clipboard.pasteText(value.text); + } + }); + }; + var Commands = { register: register }; - var global$7 = tinymce.util.Tools.resolve('tinymce.html.Node'); + var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - var global$8 = tinymce.util.Tools.resolve('tinymce.html.Schema'); + var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay'); - var global$9 = tinymce.util.Tools.resolve('tinymce.html.Serializer'); + var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - function filter(content, items) { - global$3.each(items, function (v) { - if (v.constructor === RegExp) { - content = content.replace(v, ''); - } else { - content = content.replace(v[0], v[1]); + var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var internalMimeType = 'x-tinymce/html'; + var internalMark = ''; + var mark = function (html) { + return internalMark + html; + }; + var unmark = function (html) { + return html.replace(internalMark, ''); + }; + var isMarked = function (html) { + return html.indexOf(internalMark) !== -1; + }; + var InternalHtml = { + mark: mark, + unmark: unmark, + isMarked: isMarked, + internalHtmlMime: function () { + return internalMimeType; } - }); - return content; - } - function innerText(html) { - var schema = global$8(); - var domParser = global$6({}, schema); - var text = ''; - var shortEndedElements = schema.getShortEndedElements(); - var ignoreElements = global$3.makeMap('script noscript style textarea video audio iframe object', ' '); - var blockElements = schema.getBlockElements(); - function walk(node) { - var name$$1 = node.name, currentNode = node; - if (name$$1 === 'br') { - text += '\n'; - return; + }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.html.Entities'); + + var isPlainText = function (text) { + return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text); + }; + var toBRs = function (text) { + return text.replace(/\r?\n/g, '
'); + }; + var openContainer = function (rootTag, rootAttrs) { + var key; + var attrs = []; + var tag = '<' + rootTag; + if (typeof rootAttrs === 'object') { + for (key in rootAttrs) { + if (rootAttrs.hasOwnProperty(key)) { + attrs.push(key + '="' + global$5.encodeAllRaw(rootAttrs[key]) + '"'); + } + } + if (attrs.length) { + tag += ' ' + attrs.join(' '); + } } - if (shortEndedElements[name$$1]) { - text += ' '; + return tag + '>'; + }; + var toBlockElements = function (text, rootTag, rootAttrs) { + var blocks = text.split(/\n\n/); + var tagOpen = openContainer(rootTag, rootAttrs); + var tagClose = ''; + var paragraphs = global$3.map(blocks, function (p) { + return p.split(/\n/).join('
'); + }); + var stitch = function (p) { + return tagOpen + p + tagClose; + }; + return paragraphs.length === 1 ? paragraphs[0] : global$3.map(paragraphs, stitch).join(''); + }; + var convert = function (text, rootTag, rootAttrs) { + return rootTag ? toBlockElements(text, rootTag, rootAttrs) : toBRs(text); + }; + var Newlines = { + isPlainText: isPlainText, + convert: convert, + toBRs: toBRs, + toBlockElements: toBlockElements + }; + + var global$6 = tinymce.util.Tools.resolve('tinymce.html.DomParser'); + + var global$7 = tinymce.util.Tools.resolve('tinymce.html.Node'); + + var global$8 = tinymce.util.Tools.resolve('tinymce.html.Schema'); + + var global$9 = tinymce.util.Tools.resolve('tinymce.html.Serializer'); + + function filter(content, items) { + global$3.each(items, function (v) { + if (v.constructor === RegExp) { + content = content.replace(v, ''); + } else { + content = content.replace(v[0], v[1]); + } + }); + return content; + } + function innerText(html) { + var schema = global$8(); + var domParser = global$6({}, schema); + var text = ''; + var shortEndedElements = schema.getShortEndedElements(); + var ignoreElements = global$3.makeMap('script noscript style textarea video audio iframe object', ' '); + var blockElements = schema.getBlockElements(); + function walk(node) { + var name$$1 = node.name, currentNode = node; + if (name$$1 === 'br') { + text += '\n'; + return; + } + if (name$$1 === 'wbr') { + return; + } + if (shortEndedElements[name$$1]) { + text += ' '; + } + if (ignoreElements[name$$1]) { + text += ' '; + return; + } + if (node.type === 3) { + text += node.value; + } + if (!node.shortEnded) { + if (node = node.firstChild) { + do { + walk(node); + } while (node = node.next); + } + } + if (blockElements[name$$1] && currentNode.next) { + text += '\n'; + if (name$$1 === 'p') { + text += '\n'; + } + } } - if (ignoreElements[name$$1]) { - text += ' '; - return; + html = filter(html, [//g]); + walk(domParser.parse(html)); + return text; + } + function trimHtml(html) { + function trimSpaces(all, s1, s2) { + if (!s1 && !s2) { + return ' '; + } + return '\xA0'; } - if (node.type === 3) { - text += node.value; - } - if (!node.shortEnded) { + html = filter(html, [ + /^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig, + /|/g, + [ + /( ?)\u00a0<\/span>( ?)/g, + trimSpaces + ], + /
/g, + /
$/i + ]); + return html; + } + function createIdGenerator(prefix) { + var count = 0; + return function () { + return prefix + count++; + }; + } + var isMsEdge = function () { + return navigator.userAgent.indexOf(' Edge/') !== -1; + }; + var Utils = { + filter: filter, + innerText: innerText, + trimHtml: trimHtml, + createIdGenerator: createIdGenerator, + isMsEdge: isMsEdge + }; + + function isWordContent(content) { + return / 1) { + currentListNode.attr('start', '' + start); + } + paragraphNode.wrap(currentListNode); + } else { + currentListNode.append(paragraphNode); + } + paragraphNode.name = 'li'; + if (level > lastLevel && prevListNode) { + prevListNode.lastChild.append(currentListNode); + } + lastLevel = level; + removeIgnoredNodes(paragraphNode); + trimListStart(paragraphNode, /^\u00a0+/); + trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/); + trimListStart(paragraphNode, /^\u00a0+/); + } + var elements = []; + var child = node.firstChild; + while (typeof child !== 'undefined' && child !== null) { + elements.push(child); + child = child.walk(); + if (child !== null) { + while (typeof child !== 'undefined' && child.parent !== node) { + child = child.walk(); + } } } - } - html = filter(html, [//g]); - walk(domParser.parse(html)); - return text; - } - function trimHtml(html) { - function trimSpaces(all, s1, s2) { - if (!s1 && !s2) { - return ' '; - } - return '\xA0'; - } - html = filter(html, [ - /^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig, - /|/g, - [ - /( ?)\u00a0<\/span>( ?)/g, - trimSpaces - ], - /
/g, - /
$/i - ]); - return html; - } - function createIdGenerator(prefix) { - var count = 0; - return function () { - return prefix + count++; - }; - } - var isMsEdge = function () { - return navigator.userAgent.indexOf(' Edge/') !== -1; - }; - var $_4bi2o9j0jjgwecui = { - filter: filter, - innerText: innerText, - trimHtml: trimHtml, - createIdGenerator: createIdGenerator, - isMsEdge: isMsEdge - }; - - function isWordContent(content) { - return / 1) { - currentListNode.attr('start', '' + start); - } - paragraphNode.wrap(currentListNode); - } else { - currentListNode.append(paragraphNode); - } - paragraphNode.name = 'li'; - if (level > lastLevel && prevListNode) { - prevListNode.lastChild.append(currentListNode); - } - lastLevel = level; - removeIgnoredNodes(paragraphNode); - trimListStart(paragraphNode, /^\u00a0+/); - trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/); - trimListStart(paragraphNode, /^\u00a0+/); } - var elements = []; - var child = node.firstChild; - while (typeof child !== 'undefined' && child !== null) { - elements.push(child); - child = child.walk(); - if (child !== null) { - while (typeof child !== 'undefined' && child.parent !== node) { - child = child.walk(); - } - } - } - for (var i = 0; i < elements.length; i++) { - node = elements[i]; - if (node.name === 'p' && node.firstChild) { - var nodeText = getText(node); - if (isBulletList(nodeText)) { - convertParagraphToLi(node, 'ul'); - continue; - } - if (isNumericList(nodeText)) { - var matches = /([0-9]+)\./.exec(nodeText); - var start = 1; + function filterStyles(editor, validStyles, node, styleValue) { + var outputStyles = {}, matches; + var styles = editor.dom.parseStyle(styleValue); + global$3.each(styles, function (value, name) { + switch (name) { + case 'mso-list': + matches = /\w+ \w+([0-9]+)/i.exec(styleValue); if (matches) { - start = parseInt(matches[1], 10); + node._listLevel = parseInt(matches[1], 10); } - convertParagraphToLi(node, 'ol', start); - continue; + if (/Ignore/i.test(value) && node.firstChild) { + node._listIgnore = true; + node.firstChild._listIgnore = true; + } + break; + case 'horiz-align': + name = 'text-align'; + break; + case 'vert-align': + name = 'vertical-align'; + break; + case 'font-color': + case 'mso-foreground': + name = 'color'; + break; + case 'mso-background': + case 'mso-highlight': + name = 'background'; + break; + case 'font-weight': + case 'font-style': + if (value !== 'normal') { + outputStyles[name] = value; + } + return; + case 'mso-element': + if (/^(comment|comment-list)$/i.test(value)) { + node.remove(); + return; + } + break; } - if (node._listLevel) { - convertParagraphToLi(node, 'ul', 1); - continue; + if (name.indexOf('mso-comment') === 0) { + node.remove(); + return; } - currentListNode = null; - } else { - prevListNode = currentListNode; - currentListNode = null; - } - } - } - function filterStyles(editor, validStyles, node, styleValue) { - var outputStyles = {}, matches; - var styles = editor.dom.parseStyle(styleValue); - global$3.each(styles, function (value, name) { - switch (name) { - case 'mso-list': - matches = /\w+ \w+([0-9]+)/i.exec(styleValue); - if (matches) { - node._listLevel = parseInt(matches[1], 10); + if (name.indexOf('mso-') === 0) { + return; } - if (/Ignore/i.test(value) && node.firstChild) { - node._listIgnore = true; - node.firstChild._listIgnore = true; - } - break; - case 'horiz-align': - name = 'text-align'; - break; - case 'vert-align': - name = 'vertical-align'; - break; - case 'font-color': - case 'mso-foreground': - name = 'color'; - break; - case 'mso-background': - case 'mso-highlight': - name = 'background'; - break; - case 'font-weight': - case 'font-style': - if (value !== 'normal') { + if (Settings.getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) { outputStyles[name] = value; } - return; - case 'mso-element': - if (/^(comment|comment-list)$/i.test(value)) { - node.remove(); - return; - } - break; - } - if (name.indexOf('mso-comment') === 0) { - node.remove(); - return; - } - if (name.indexOf('mso-') === 0) { - return; - } - if ($_xr8b0ikjjgwectl.getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) { - outputStyles[name] = value; - } - }); - if (/(bold)/i.test(outputStyles['font-weight'])) { - delete outputStyles['font-weight']; - node.wrap(new global$7('b', 1)); - } - if (/(italic)/i.test(outputStyles['font-style'])) { - delete outputStyles['font-style']; - node.wrap(new global$7('i', 1)); - } - outputStyles = editor.dom.serializeStyle(outputStyles, node.name); - if (outputStyles) { - return outputStyles; - } - return null; - } - var filterWordContent = function (editor, content) { - var retainStyleProperties, validStyles; - retainStyleProperties = $_xr8b0ikjjgwectl.getRetainStyleProps(editor); - if (retainStyleProperties) { - validStyles = global$3.makeMap(retainStyleProperties.split(/[, ]/)); - } - content = $_4bi2o9j0jjgwecui.filter(content, [ - /
/gi, - /]+id="?docs-internal-[^>]*>/gi, - //gi, - /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, - [ - /<(\/?)s>/gi, - '<$1strike>' - ], - [ - / /gi, - '\xA0' - ], - [ - /([\s\u00a0]*)<\/span>/gi, - function (str, spaces) { - return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join('\xA0') : ''; - } - ] - ]); - var validElements = $_xr8b0ikjjgwectl.getWordValidElements(editor); - var schema = global$8({ - valid_elements: validElements, - valid_children: '-li[p]' - }); - global$3.each(schema.elements, function (rule) { - if (!rule.attributes.class) { - rule.attributes.class = {}; - rule.attributesOrder.push('class'); - } - if (!rule.attributes.style) { - rule.attributes.style = {}; - rule.attributesOrder.push('style'); - } - }); - var domParser = global$6({}, schema); - domParser.addAttributeFilter('style', function (nodes) { - var i = nodes.length, node; - while (i--) { - node = nodes[i]; - node.attr('style', filterStyles(editor, validStyles, node, node.attr('style'))); - if (node.name === 'span' && node.parent && !node.attributes.length) { - node.unwrap(); - } - } - }); - domParser.addAttributeFilter('class', function (nodes) { - var i = nodes.length, node, className; - while (i--) { - node = nodes[i]; - className = node.attr('class'); - if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) { - node.remove(); - } - node.attr('class', null); - } - }); - domParser.addNodeFilter('del', function (nodes) { - var i = nodes.length; - while (i--) { - nodes[i].remove(); - } - }); - domParser.addNodeFilter('a', function (nodes) { - var i = nodes.length, node, href, name; - while (i--) { - node = nodes[i]; - href = node.attr('href'); - name = node.attr('name'); - if (href && href.indexOf('#_msocom_') !== -1) { - node.remove(); - continue; - } - if (href && href.indexOf('file://') === 0) { - href = href.split('#')[1]; - if (href) { - href = '#' + href; - } - } - if (!href && !name) { - node.unwrap(); - } else { - if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) { - node.unwrap(); - continue; - } - node.attr({ - href: href, - name: name - }); - } - } - }); - var rootNode = domParser.parse(content); - if ($_xr8b0ikjjgwectl.shouldConvertWordFakeLists(editor)) { - convertFakeListsToProperLists(rootNode); - } - content = global$9({ validate: editor.settings.validate }, schema).serialize(rootNode); - return content; - }; - var preProcess = function (editor, content) { - return $_xr8b0ikjjgwectl.shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content; - }; - var $_dfatuiivjjgwecu8 = { - preProcess: preProcess, - isWordContent: isWordContent - }; - - var processResult = function (content, cancelled) { - return { - content: content, - cancelled: cancelled - }; - }; - var postProcessFilter = function (editor, html, internal, isWordHtml) { - var tempBody = editor.dom.create('div', { style: 'display:none' }, html); - var postProcessArgs = $_8tki3zijjjgwectj.firePastePostProcess(editor, tempBody, internal, isWordHtml); - return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented()); - }; - var filterContent = function (editor, content, internal, isWordHtml) { - var preProcessArgs = $_8tki3zijjjgwectj.firePastePreProcess(editor, content, internal, isWordHtml); - if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) { - return postProcessFilter(editor, preProcessArgs.content, internal, isWordHtml); - } else { - return processResult(preProcessArgs.content, preProcessArgs.isDefaultPrevented()); - } - }; - var process = function (editor, html, internal) { - var isWordHtml = $_dfatuiivjjgwecu8.isWordContent(html); - var content = isWordHtml ? $_dfatuiivjjgwecu8.preProcess(editor, html) : html; - return filterContent(editor, content, internal, isWordHtml); - }; - var $_3scw66iujjgwecu4 = { process: process }; - - var pasteHtml = function (editor, html) { - editor.insertContent(html, { - merge: $_xr8b0ikjjgwectl.shouldMergeFormats(editor), - paste: true - }); - return true; - }; - var isAbsoluteUrl = function (url) { - return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url); - }; - var isImageUrl = function (url) { - return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url); - }; - var createImage = function (editor, url, pasteHtmlFn) { - editor.undoManager.extra(function () { - pasteHtmlFn(editor, url); - }, function () { - editor.insertContent(''); - }); - return true; - }; - var createLink = function (editor, url, pasteHtmlFn) { - editor.undoManager.extra(function () { - pasteHtmlFn(editor, url); - }, function () { - editor.execCommand('mceInsertLink', false, url); - }); - return true; - }; - var linkSelection = function (editor, html, pasteHtmlFn) { - return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false; - }; - var insertImage = function (editor, html, pasteHtmlFn) { - return isImageUrl(html) ? createImage(editor, html, pasteHtmlFn) : false; - }; - var smartInsertContent = function (editor, html) { - global$3.each([ - linkSelection, - insertImage, - pasteHtml - ], function (action) { - return action(editor, html, pasteHtml) !== true; - }); - }; - var insertContent = function (editor, html) { - if ($_xr8b0ikjjgwectl.isSmartPasteEnabled(editor) === false) { - pasteHtml(editor, html); - } else { - smartInsertContent(editor, html); - } - }; - var $_d8pzpej1jjgwecum = { - isImageUrl: isImageUrl, - isAbsoluteUrl: isAbsoluteUrl, - insertContent: insertContent - }; - - var pasteHtml$1 = function (editor, html, internalFlag) { - var internal = internalFlag ? internalFlag : $_4x13hjirjjgwecu1.isMarked(html); - var args = $_3scw66iujjgwecu4.process(editor, $_4x13hjirjjgwecu1.unmark(html), internal); - if (args.cancelled === false) { - $_d8pzpej1jjgwecum.insertContent(editor, args.content); - } - }; - var pasteText = function (editor, text) { - text = editor.dom.encode(text).replace(/\r\n/g, '\n'); - text = $_4h3hnrisjjgwecu2.convert(text, editor.settings.forced_root_block, editor.settings.forced_root_block_attrs); - pasteHtml$1(editor, text, false); - }; - var getDataTransferItems = function (dataTransfer) { - var items = {}; - var mceInternalUrlPrefix = 'data:text/mce-internal,'; - if (dataTransfer) { - if (dataTransfer.getData) { - var legacyText = dataTransfer.getData('Text'); - if (legacyText && legacyText.length > 0) { - if (legacyText.indexOf(mceInternalUrlPrefix) === -1) { - items['text/plain'] = legacyText; - } - } - } - if (dataTransfer.types) { - for (var i = 0; i < dataTransfer.types.length; i++) { - var contentType = dataTransfer.types[i]; - try { - items[contentType] = dataTransfer.getData(contentType); - } catch (ex) { - items[contentType] = ''; - } - } - } - } - return items; - }; - var getClipboardContent = function (editor, clipboardEvent) { - var content = getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer); - return $_4bi2o9j0jjgwecui.isMsEdge() ? global$3.extend(content, { 'text/html': '' }) : content; - }; - var hasContentType = function (clipboardContent, mimeType) { - return mimeType in clipboardContent && clipboardContent[mimeType].length > 0; - }; - var hasHtmlOrText = function (content) { - return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain'); - }; - var getBase64FromUri = function (uri) { - var idx; - idx = uri.indexOf(','); - if (idx !== -1) { - return uri.substr(idx + 1); - } - return null; - }; - var isValidDataUriImage = function (settings, imgElm) { - return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true; - }; - var extractFilename = function (editor, str) { - var m = str.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i); - return m ? editor.dom.encode(m[1]) : null; - }; - var uniqueId = $_4bi2o9j0jjgwecui.createIdGenerator('mceclip'); - var pasteImage = function (editor, rng, reader, blob) { - if (rng) { - editor.selection.setRng(rng); - rng = null; - } - var dataUri = reader.result; - var base64 = getBase64FromUri(dataUri); - var id = uniqueId(); - var name$$1 = editor.settings.images_reuse_filename && blob.name ? extractFilename(editor, blob.name) : id; - var img = new Image(); - img.src = dataUri; - if (isValidDataUriImage(editor.settings, img)) { - var blobCache = editor.editorUpload.blobCache; - var blobInfo = void 0, existingBlobInfo = void 0; - existingBlobInfo = blobCache.findFirst(function (cachedBlobInfo) { - return cachedBlobInfo.base64() === base64; }); - if (!existingBlobInfo) { - blobInfo = blobCache.create(id, blob, base64, name$$1); - blobCache.add(blobInfo); - } else { - blobInfo = existingBlobInfo; + if (/(bold)/i.test(outputStyles['font-weight'])) { + delete outputStyles['font-weight']; + node.wrap(new global$7('b', 1)); } - pasteHtml$1(editor, '', false); - } else { - pasteHtml$1(editor, '', false); + if (/(italic)/i.test(outputStyles['font-style'])) { + delete outputStyles['font-style']; + node.wrap(new global$7('i', 1)); + } + outputStyles = editor.dom.serializeStyle(outputStyles, node.name); + if (outputStyles) { + return outputStyles; + } + return null; } - }; - var isClipboardEvent = function (event$$1) { - return event$$1.type === 'paste'; - }; - var pasteImageData = function (editor, e, rng) { - var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer; - function processItems(items) { - var i, item, reader, hadImage = false; - if (items) { - for (i = 0; i < items.length; i++) { - item = items[i]; - if (/^image\/(jpeg|png|gif|bmp)$/.test(item.type)) { - var blob = item.getAsFile ? item.getAsFile() : item; - reader = new window.FileReader(); - reader.onload = pasteImage.bind(null, editor, rng, reader, blob); - reader.readAsDataURL(blob); - e.preventDefault(); - hadImage = true; + var filterWordContent = function (editor, content) { + var retainStyleProperties, validStyles; + retainStyleProperties = Settings.getRetainStyleProps(editor); + if (retainStyleProperties) { + validStyles = global$3.makeMap(retainStyleProperties.split(/[, ]/)); + } + content = Utils.filter(content, [ + /
/gi, + /]+id="?docs-internal-[^>]*>/gi, + //gi, + /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi, + [ + /<(\/?)s>/gi, + '<$1strike>' + ], + [ + / /gi, + '\xA0' + ], + [ + /([\s\u00a0]*)<\/span>/gi, + function (str, spaces) { + return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join('\xA0') : ''; + } + ] + ]); + var validElements = Settings.getWordValidElements(editor); + var schema = global$8({ + valid_elements: validElements, + valid_children: '-li[p]' + }); + global$3.each(schema.elements, function (rule) { + if (!rule.attributes.class) { + rule.attributes.class = {}; + rule.attributesOrder.push('class'); + } + if (!rule.attributes.style) { + rule.attributes.style = {}; + rule.attributesOrder.push('style'); + } + }); + var domParser = global$6({}, schema); + domParser.addAttributeFilter('style', function (nodes) { + var i = nodes.length, node; + while (i--) { + node = nodes[i]; + node.attr('style', filterStyles(editor, validStyles, node, node.attr('style'))); + if (node.name === 'span' && node.parent && !node.attributes.length) { + node.unwrap(); } } - } - return hadImage; - } - if (editor.settings.paste_data_images && dataTransfer) { - return processItems(dataTransfer.items) || processItems(dataTransfer.files); - } - }; - var isBrokenAndroidClipboardEvent = function (e) { - var clipboardData = e.clipboardData; - return navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0; - }; - var isKeyboardPasteEvent = function (e) { - return global$4.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45; - }; - var registerEventHandlers = function (editor, pasteBin, pasteFormat) { - var keyboardPasteTimeStamp = 0; - var keyboardPastePlainTextState; - editor.on('keydown', function (e) { - function removePasteBinOnKeyUp(e) { - if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { - pasteBin.remove(); + }); + domParser.addAttributeFilter('class', function (nodes) { + var i = nodes.length, node, className; + while (i--) { + node = nodes[i]; + className = node.attr('class'); + if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) { + node.remove(); + } + node.attr('class', null); } - } - if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { - keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86; - if (keyboardPastePlainTextState && global$1.webkit && navigator.userAgent.indexOf('Version/') !== -1) { - return; - } - e.stopImmediatePropagation(); - keyboardPasteTimeStamp = new Date().getTime(); - if (global$1.ie && keyboardPastePlainTextState) { - e.preventDefault(); - $_8tki3zijjjgwectj.firePaste(editor, true); - return; - } - pasteBin.remove(); - pasteBin.create(); - editor.once('keyup', removePasteBinOnKeyUp); - editor.once('paste', function () { - editor.off('keyup', removePasteBinOnKeyUp); - }); - } - }); - function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) { - var content, isPlainTextHtml; - if (hasContentType(clipboardContent, 'text/html')) { - content = clipboardContent['text/html']; - } else { - content = pasteBin.getHtml(); - internal = internal ? internal : $_4x13hjirjjgwecu1.isMarked(content); - if (pasteBin.isDefaultContent(content)) { - plainTextMode = true; - } - } - content = $_4bi2o9j0jjgwecui.trimHtml(content); - pasteBin.remove(); - isPlainTextHtml = internal === false && $_4h3hnrisjjgwecu2.isPlainText(content); - if (!content.length || isPlainTextHtml) { - plainTextMode = true; - } - if (plainTextMode) { - if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) { - content = clipboardContent['text/plain']; - } else { - content = $_4bi2o9j0jjgwecui.innerText(content); - } - } - if (pasteBin.isDefaultContent(content)) { - if (!isKeyBoardPaste) { - editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.'); - } - return; - } - if (plainTextMode) { - pasteText(editor, content); - } else { - pasteHtml$1(editor, content, internal); - } - } - var getLastRng = function () { - return pasteBin.getLastRng() || editor.selection.getRng(); - }; - editor.on('paste', function (e) { - var clipboardTimer = new Date().getTime(); - var clipboardContent = getClipboardContent(editor, e); - var clipboardDelay = new Date().getTime() - clipboardTimer; - var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp - clipboardDelay < 1000; - var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState; - var internal = hasContentType(clipboardContent, $_4x13hjirjjgwecu1.internalHtmlMime()); - keyboardPastePlainTextState = false; - if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) { - pasteBin.remove(); - return; - } - if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) { - pasteBin.remove(); - return; - } - if (!isKeyBoardPaste) { - e.preventDefault(); - } - if (global$1.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) { - pasteBin.create(); - editor.dom.bind(pasteBin.getEl(), 'paste', function (e) { - e.stopPropagation(); - }); - editor.getDoc().execCommand('Paste', false, null); - clipboardContent['text/html'] = pasteBin.getHtml(); - } - if (hasContentType(clipboardContent, 'text/html')) { - e.preventDefault(); - if (!internal) { - internal = $_4x13hjirjjgwecu1.isMarked(clipboardContent['text/html']); - } - insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal); - } else { - global$2.setEditorTimeout(editor, function () { - insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal); - }, 0); - } - }); - }; - var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) { - registerEventHandlers(editor, pasteBin, pasteFormat); - var src; - editor.parser.addNodeFilter('img', function (nodes, name$$1, args) { - var isPasteInsert = function (args) { - return args.data && args.data.paste === true; - }; - var remove = function (node) { - if (!node.attr('data-mce-object') && src !== global$1.transparentSrc) { - node.remove(); - } - }; - var isWebKitFakeUrl = function (src) { - return src.indexOf('webkit-fake-url') === 0; - }; - var isDataUri = function (src) { - return src.indexOf('data:') === 0; - }; - if (!editor.settings.paste_data_images && isPasteInsert(args)) { + }); + domParser.addNodeFilter('del', function (nodes) { var i = nodes.length; while (i--) { - src = nodes[i].attributes.map.src; - if (!src) { + nodes[i].remove(); + } + }); + domParser.addNodeFilter('a', function (nodes) { + var i = nodes.length, node, href, name; + while (i--) { + node = nodes[i]; + href = node.attr('href'); + name = node.attr('name'); + if (href && href.indexOf('#_msocom_') !== -1) { + node.remove(); continue; } - if (isWebKitFakeUrl(src)) { - remove(nodes[i]); - } else if (!editor.settings.allow_html_data_urls && isDataUri(src)) { - remove(nodes[i]); + if (href && href.indexOf('file://') === 0) { + href = href.split('#')[1]; + if (href) { + href = '#' + href; + } + } + if (!href && !name) { + node.unwrap(); + } else { + if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) { + node.unwrap(); + continue; + } + node.attr({ + href: href, + name: name + }); + } + } + }); + var rootNode = domParser.parse(content); + if (Settings.shouldConvertWordFakeLists(editor)) { + convertFakeListsToProperLists(rootNode); + } + content = global$9({ validate: editor.settings.validate }, schema).serialize(rootNode); + return content; + }; + var preProcess = function (editor, content) { + return Settings.shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content; + }; + var WordFilter = { + preProcess: preProcess, + isWordContent: isWordContent + }; + + var processResult = function (content, cancelled) { + return { + content: content, + cancelled: cancelled + }; + }; + var postProcessFilter = function (editor, html, internal, isWordHtml) { + var tempBody = editor.dom.create('div', { style: 'display:none' }, html); + var postProcessArgs = Events.firePastePostProcess(editor, tempBody, internal, isWordHtml); + return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented()); + }; + var filterContent = function (editor, content, internal, isWordHtml) { + var preProcessArgs = Events.firePastePreProcess(editor, content, internal, isWordHtml); + if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) { + return postProcessFilter(editor, preProcessArgs.content, internal, isWordHtml); + } else { + return processResult(preProcessArgs.content, preProcessArgs.isDefaultPrevented()); + } + }; + var process = function (editor, html, internal) { + var isWordHtml = WordFilter.isWordContent(html); + var content = isWordHtml ? WordFilter.preProcess(editor, html) : html; + return filterContent(editor, content, internal, isWordHtml); + }; + var ProcessFilters = { process: process }; + + var removeMeta = function (editor, html) { + var body = editor.dom.create('body', {}, html); + global$3.each(body.querySelectorAll('meta'), function (elm) { + return elm.parentNode.removeChild(elm); + }); + return body.innerHTML; + }; + var pasteHtml = function (editor, html) { + editor.insertContent(removeMeta(editor, html), { + merge: Settings.shouldMergeFormats(editor), + paste: true + }); + return true; + }; + var isAbsoluteUrl = function (url) { + return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url); + }; + var isImageUrl = function (url) { + return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url); + }; + var createImage = function (editor, url, pasteHtmlFn) { + editor.undoManager.extra(function () { + pasteHtmlFn(editor, url); + }, function () { + editor.insertContent(''); + }); + return true; + }; + var createLink = function (editor, url, pasteHtmlFn) { + editor.undoManager.extra(function () { + pasteHtmlFn(editor, url); + }, function () { + editor.execCommand('mceInsertLink', false, url); + }); + return true; + }; + var linkSelection = function (editor, html, pasteHtmlFn) { + return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false; + }; + var insertImage = function (editor, html, pasteHtmlFn) { + return isImageUrl(html) ? createImage(editor, html, pasteHtmlFn) : false; + }; + var smartInsertContent = function (editor, html) { + global$3.each([ + linkSelection, + insertImage, + pasteHtml + ], function (action) { + return action(editor, html, pasteHtml) !== true; + }); + }; + var insertContent = function (editor, html) { + if (Settings.isSmartPasteEnabled(editor) === false) { + pasteHtml(editor, html); + } else { + smartInsertContent(editor, html); + } + }; + var SmartPaste = { + isImageUrl: isImageUrl, + isAbsoluteUrl: isAbsoluteUrl, + insertContent: insertContent + }; + + var constant = function (value) { + return function () { + return value; + }; + }; + function curry(fn) { + var initialArgs = []; + for (var _i = 1; _i < arguments.length; _i++) { + initialArgs[_i - 1] = arguments[_i]; + } + return function () { + var restArgs = []; + for (var _i = 0; _i < arguments.length; _i++) { + restArgs[_i] = arguments[_i]; + } + var all = initialArgs.concat(restArgs); + return fn.apply(null, all); + }; + } + var never = constant(false); + var always = constant(true); + + var never$1 = never; + var always$1 = always; + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call$$1 = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var noop$$1 = function () { + }; + var nul = function () { + return null; + }; + var undef = function () { + return undefined; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never$1, + isSome: never$1, + isNone: always$1, + getOr: id, + getOrThunk: call$$1, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: nul, + getOrUndefined: undef, + or: id, + orThunk: call$$1, + map: none, + ap: none, + each: noop$$1, + bind: none, + flatten: none, + exists: never$1, + forall: always$1, + 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 = function () { + return a; + }; + var self = function () { + return me; + }; + var map = function (f) { + return some(f(a)); + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always$1, + isNone: never$1, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: map, + ap: function (optfab) { + return optfab.fold(none, function (fab) { + return some(fab(a)); + }); + }, + each: function (f) { + f(a); + }, + bind: bind, + flatten: constant_a, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never$1, function (b) { + return elementEq(a, b); + }); + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + } + }; + 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)) + return 'array'; + if (t === 'object' && String.prototype.isPrototypeOf(x)) + return 'string'; + return t; + }; + var isType = function (type) { + return function (value) { + return typeOf(value) === type; + }; + }; + var isFunction = isType('function'); + + 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, xs); + } + return r; + }; + var each = function (xs, f) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + f(x, i, xs); + } + }; + var filter$1 = function (xs, pred) { + var r = []; + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + if (pred(x, i, xs)) { + r.push(x); + } + } + return r; + }; + var slice = Array.prototype.slice; + var from$1 = isFunction(Array.from) ? Array.from : function (x) { + return slice.call(x); + }; + + var nu = function (baseFn) { + var data = Option.none(); + var callbacks = []; + var map$$1 = function (f) { + return nu(function (nCallback) { + get(function (data) { + nCallback(f(data)); + }); + }); + }; + var get = function (nCallback) { + if (isReady()) + call(nCallback); + else + callbacks.push(nCallback); + }; + var set = function (x) { + data = Option.some(x); + run(callbacks); + callbacks = []; + }; + var isReady = function () { + return data.isSome(); + }; + var run = function (cbs) { + each(cbs, call); + }; + var call = function (cb) { + data.each(function (x) { + setTimeout(function () { + cb(x); + }, 0); + }); + }; + baseFn(set); + return { + get: get, + map: map$$1, + isReady: isReady + }; + }; + var pure$1 = function (a) { + return nu(function (callback) { + callback(a); + }); + }; + var LazyValue = { + nu: nu, + pure: pure$1 + }; + + var bounce = function (f) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var me = this; + setTimeout(function () { + f.apply(me, args); + }, 0); + }; + }; + + var nu$1 = function (baseFn) { + var get = function (callback) { + baseFn(bounce(callback)); + }; + var map = function (fab) { + return nu$1(function (callback) { + get(function (a) { + var value = fab(a); + callback(value); + }); + }); + }; + var bind = function (aFutureB) { + return nu$1(function (callback) { + get(function (a) { + aFutureB(a).get(callback); + }); + }); + }; + var anonBind = function (futureB) { + return nu$1(function (callback) { + get(function (a) { + futureB.get(callback); + }); + }); + }; + var toLazy = function () { + return LazyValue.nu(get); + }; + var toCached = function () { + var cache = null; + return nu$1(function (callback) { + if (cache === null) { + cache = toLazy(); + } + cache.get(callback); + }); + }; + return { + map: map, + bind: bind, + anonBind: anonBind, + toLazy: toLazy, + toCached: toCached, + get: get + }; + }; + var pure$2 = function (a) { + return nu$1(function (callback) { + callback(a); + }); + }; + var Future = { + nu: nu$1, + pure: pure$2 + }; + + var par = function (asyncValues, nu) { + return nu(function (callback) { + var r = []; + var count = 0; + var cb = function (i) { + return function (value) { + r[i] = value; + count++; + if (count >= asyncValues.length) { + callback(r); + } + }; + }; + if (asyncValues.length === 0) { + callback([]); + } else { + each(asyncValues, function (asyncValue, i) { + asyncValue.get(cb(i)); + }); + } + }); + }; + + var par$1 = function (futures) { + return par(futures, Future.nu); + }; + var mapM = function (array, fn) { + var futures = map(array, fn); + return par$1(futures); + }; + + var pasteHtml$1 = function (editor, html, internalFlag) { + var internal = internalFlag ? internalFlag : InternalHtml.isMarked(html); + var args = ProcessFilters.process(editor, InternalHtml.unmark(html), internal); + if (args.cancelled === false) { + SmartPaste.insertContent(editor, args.content); + } + }; + var pasteText = function (editor, text) { + text = editor.dom.encode(text).replace(/\r\n/g, '\n'); + text = Newlines.convert(text, editor.settings.forced_root_block, editor.settings.forced_root_block_attrs); + pasteHtml$1(editor, text, false); + }; + var getDataTransferItems = function (dataTransfer) { + var items = {}; + var mceInternalUrlPrefix = 'data:text/mce-internal,'; + if (dataTransfer) { + if (dataTransfer.getData) { + var legacyText = dataTransfer.getData('Text'); + if (legacyText && legacyText.length > 0) { + if (legacyText.indexOf(mceInternalUrlPrefix) === -1) { + items['text/plain'] = legacyText; + } + } + } + if (dataTransfer.types) { + for (var i = 0; i < dataTransfer.types.length; i++) { + var contentType = dataTransfer.types[i]; + try { + items[contentType] = dataTransfer.getData(contentType); + } catch (ex) { + items[contentType] = ''; + } } } } - }); - }; - - var getPasteBinParent = function (editor) { - return global$1.ie && editor.inline ? document.body : editor.getBody(); - }; - var isExternalPasteBin = function (editor) { - return getPasteBinParent(editor) !== editor.getBody(); - }; - var delegatePasteEvents = function (editor, pasteBinElm) { - if (isExternalPasteBin(editor)) { - editor.dom.bind(pasteBinElm, 'paste keyup', function (e) { - setTimeout(function () { - editor.fire('paste'); - }, 0); + return items; + }; + var getClipboardContent = function (editor, clipboardEvent) { + var content = getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer); + return Utils.isMsEdge() ? global$3.extend(content, { 'text/html': '' }) : content; + }; + var hasContentType = function (clipboardContent, mimeType) { + return mimeType in clipboardContent && clipboardContent[mimeType].length > 0; + }; + var hasHtmlOrText = function (content) { + return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain'); + }; + var getBase64FromUri = function (uri) { + var idx; + idx = uri.indexOf(','); + if (idx !== -1) { + return uri.substr(idx + 1); + } + return null; + }; + var isValidDataUriImage = function (settings, imgElm) { + return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true; + }; + var extractFilename = function (editor, str) { + var m = str.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i); + return m ? editor.dom.encode(m[1]) : null; + }; + var uniqueId = Utils.createIdGenerator('mceclip'); + var pasteImage = function (editor, imageItem) { + var base64 = getBase64FromUri(imageItem.uri); + var id = uniqueId(); + var name$$1 = editor.settings.images_reuse_filename && imageItem.blob.name ? extractFilename(editor, imageItem.blob.name) : id; + var img = new Image(); + img.src = imageItem.uri; + if (isValidDataUriImage(editor.settings, img)) { + var blobCache = editor.editorUpload.blobCache; + var blobInfo = void 0, existingBlobInfo = void 0; + existingBlobInfo = blobCache.findFirst(function (cachedBlobInfo) { + return cachedBlobInfo.base64() === base64; + }); + if (!existingBlobInfo) { + blobInfo = blobCache.create(id, imageItem.blob, base64, name$$1); + blobCache.add(blobInfo); + } else { + blobInfo = existingBlobInfo; + } + pasteHtml$1(editor, '', false); + } else { + pasteHtml$1(editor, '', false); + } + }; + var isClipboardEvent = function (event$$1) { + return event$$1.type === 'paste'; + }; + var readBlobsAsDataUris = function (items) { + return mapM(items, function (item) { + return Future.nu(function (resolve) { + var blob = item.getAsFile ? item.getAsFile() : item; + var reader = new window.FileReader(); + reader.onload = function () { + resolve({ + blob: blob, + uri: reader.result + }); + }; + reader.readAsDataURL(blob); + }); }); - } - }; - var create = function (editor, lastRngCell, pasteBinDefaultContent) { - var dom = editor.dom, body = editor.getBody(); - var pasteBinElm; - lastRngCell.set(editor.selection.getRng()); - pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', { - 'id': 'mcepastebin', - 'class': 'mce-pastebin', - 'contentEditable': true, - 'data-mce-bogus': 'all', - 'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0' - }, pasteBinDefaultContent); - if (global$1.ie || global$1.gecko) { - dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535); - } - dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) { - e.stopPropagation(); - }); - delegatePasteEvents(editor, pasteBinElm); - pasteBinElm.focus(); - editor.selection.select(pasteBinElm, true); - }; - var remove = function (editor, lastRngCell) { - if (getEl(editor)) { - var pasteBinClone = void 0; - var lastRng = lastRngCell.get(); - while (pasteBinClone = editor.dom.get('mcepastebin')) { - editor.dom.remove(pasteBinClone); - editor.dom.unbind(pasteBinClone); - } - if (lastRng) { - editor.selection.setRng(lastRng); - } - } - lastRngCell.set(null); - }; - var getEl = function (editor) { - return editor.dom.get('mcepastebin'); - }; - var getHtml = function (editor) { - var pasteBinElm, pasteBinClones, i, dirtyWrappers, cleanWrapper; - var copyAndRemove = function (toElm, fromElm) { - toElm.appendChild(fromElm); - editor.dom.remove(fromElm, true); }; - pasteBinClones = global$3.grep(getPasteBinParent(editor).childNodes, function (elm) { - return elm.id === 'mcepastebin'; - }); - pasteBinElm = pasteBinClones.shift(); - global$3.each(pasteBinClones, function (pasteBinClone) { - copyAndRemove(pasteBinElm, pasteBinClone); - }); - dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm); - for (i = dirtyWrappers.length - 1; i >= 0; i--) { - cleanWrapper = editor.dom.create('div'); - pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]); - copyAndRemove(cleanWrapper, dirtyWrappers[i]); - } - return pasteBinElm ? pasteBinElm.innerHTML : ''; - }; - var getLastRng = function (lastRng) { - return lastRng.get(); - }; - var isDefaultContent = function (pasteBinDefaultContent, content) { - return content === pasteBinDefaultContent; - }; - var isPasteBin = function (elm) { - return elm && elm.id === 'mcepastebin'; - }; - var isDefault = function (editor, pasteBinDefaultContent) { - var pasteBinElm = getEl(editor); - return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML); - }; - var PasteBin = function (editor) { - var lastRng = Cell(null); - var pasteBinDefaultContent = '%MCEPASTEBIN%'; - return { - create: function () { - return create(editor, lastRng, pasteBinDefaultContent); - }, - remove: function () { - return remove(editor, lastRng); - }, - getEl: function () { - return getEl(editor); - }, - getHtml: function () { - return getHtml(editor); - }, - getLastRng: function () { - return getLastRng(lastRng); - }, - isDefault: function () { - return isDefault(editor, pasteBinDefaultContent); - }, - isDefaultContent: function (content) { - return isDefaultContent(pasteBinDefaultContent, content); - } + var getImagesFromDataTransfer = function (dataTransfer) { + var items = dataTransfer.items ? map(from$1(dataTransfer.items), function (item) { + return item.getAsFile(); + }) : []; + var files = dataTransfer.files ? from$1(dataTransfer.files) : []; + var images = filter$1(items.length > 0 ? items : files, function (file) { + return /^image\/(jpeg|png|gif|bmp)$/.test(file.type); + }); + return images; }; - }; - - var Clipboard = function (editor, pasteFormat) { - var pasteBin = PasteBin(editor); - editor.on('preInit', function () { - return registerEventsAndFilters(editor, pasteBin, pasteFormat); - }); - return { - pasteFormat: pasteFormat, - pasteHtml: function (html, internalFlag) { - return pasteHtml$1(editor, html, internalFlag); - }, - pasteText: function (text) { - return pasteText(editor, text); - }, - pasteImageData: function (e, rng) { - return pasteImageData(editor, e, rng); - }, - getDataTransferItems: getDataTransferItems, - hasHtmlOrText: hasHtmlOrText, - hasContentType: hasContentType - }; - }; - - var noop = function () { - }; - var hasWorkingClipboardApi = function (clipboardData) { - return global$1.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && $_4bi2o9j0jjgwecui.isMsEdge() !== true; - }; - var setHtml5Clipboard = function (clipboardData, html, text) { - if (hasWorkingClipboardApi(clipboardData)) { - try { - clipboardData.clearData(); - clipboardData.setData('text/html', html); - clipboardData.setData('text/plain', text); - clipboardData.setData($_4x13hjirjjgwecu1.internalHtmlMime(), html); - return true; - } catch (e) { - return false; + var pasteImageData = function (editor, e, rng) { + var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer; + if (editor.settings.paste_data_images && dataTransfer) { + var images = getImagesFromDataTransfer(dataTransfer); + if (images.length > 0) { + e.preventDefault(); + readBlobsAsDataUris(images).get(function (blobResults) { + if (rng) { + editor.selection.setRng(rng); + } + each(blobResults, function (result) { + pasteImage(editor, result); + }); + }); + return true; + } } - } else { return false; - } - }; - var setClipboardData = function (evt, data, fallback, done) { - if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) { - evt.preventDefault(); - done(); - } else { - fallback(data.html, done); - } - }; - var fallback = function (editor) { - return function (html, done) { - var markedHtml = $_4x13hjirjjgwecu1.mark(html); - var outer = editor.dom.create('div', { - 'contenteditable': 'false', - 'data-mce-bogus': 'all' - }); - var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml); - editor.dom.setStyles(outer, { - position: 'fixed', - top: '0', - left: '-3000px', - width: '1000px', - overflow: 'hidden' - }); - outer.appendChild(inner); - editor.dom.add(editor.getBody(), outer); - var range = editor.selection.getRng(); - inner.focus(); - var offscreenRange = editor.dom.createRng(); - offscreenRange.selectNodeContents(inner); - editor.selection.setRng(offscreenRange); - setTimeout(function () { - editor.selection.setRng(range); - outer.parentNode.removeChild(outer); - done(); - }, 0); }; - }; - var getData = function (editor) { - return { - html: editor.selection.getContent({ contextual: true }), - text: editor.selection.getContent({ format: 'text' }) + var isBrokenAndroidClipboardEvent = function (e) { + var clipboardData = e.clipboardData; + return navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0; }; - }; - var cut = function (editor) { - return function (evt) { - if (editor.selection.isCollapsed() === false) { - setClipboardData(evt, getData(editor), fallback(editor), function () { - setTimeout(function () { - editor.execCommand('Delete'); + var isKeyboardPasteEvent = function (e) { + return global$4.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45; + }; + var registerEventHandlers = function (editor, pasteBin, pasteFormat) { + var keyboardPasteTimeStamp = 0; + var keyboardPastePlainTextState; + editor.on('keydown', function (e) { + function removePasteBinOnKeyUp(e) { + if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { + pasteBin.remove(); + } + } + if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) { + keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86; + if (keyboardPastePlainTextState && global$1.webkit && navigator.userAgent.indexOf('Version/') !== -1) { + return; + } + e.stopImmediatePropagation(); + keyboardPasteTimeStamp = new Date().getTime(); + if (global$1.ie && keyboardPastePlainTextState) { + e.preventDefault(); + Events.firePaste(editor, true); + return; + } + pasteBin.remove(); + pasteBin.create(); + editor.once('keyup', removePasteBinOnKeyUp); + editor.once('paste', function () { + editor.off('keyup', removePasteBinOnKeyUp); + }); + } + }); + function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) { + var content, isPlainTextHtml; + if (hasContentType(clipboardContent, 'text/html')) { + content = clipboardContent['text/html']; + } else { + content = pasteBin.getHtml(); + internal = internal ? internal : InternalHtml.isMarked(content); + if (pasteBin.isDefaultContent(content)) { + plainTextMode = true; + } + } + content = Utils.trimHtml(content); + pasteBin.remove(); + isPlainTextHtml = internal === false && Newlines.isPlainText(content); + if (!content.length || isPlainTextHtml) { + plainTextMode = true; + } + if (plainTextMode) { + if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) { + content = clipboardContent['text/plain']; + } else { + content = Utils.innerText(content); + } + } + if (pasteBin.isDefaultContent(content)) { + if (!isKeyBoardPaste) { + editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.'); + } + return; + } + if (plainTextMode) { + pasteText(editor, content); + } else { + pasteHtml$1(editor, content, internal); + } + } + var getLastRng = function () { + return pasteBin.getLastRng() || editor.selection.getRng(); + }; + editor.on('paste', function (e) { + var clipboardTimer = new Date().getTime(); + var clipboardContent = getClipboardContent(editor, e); + var clipboardDelay = new Date().getTime() - clipboardTimer; + var isKeyBoardPaste = new Date().getTime() - keyboardPasteTimeStamp - clipboardDelay < 1000; + var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState; + var internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime()); + keyboardPastePlainTextState = false; + if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) { + pasteBin.remove(); + return; + } + if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) { + pasteBin.remove(); + return; + } + if (!isKeyBoardPaste) { + e.preventDefault(); + } + if (global$1.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) { + pasteBin.create(); + editor.dom.bind(pasteBin.getEl(), 'paste', function (e) { + e.stopPropagation(); + }); + editor.getDoc().execCommand('Paste', false, null); + clipboardContent['text/html'] = pasteBin.getHtml(); + } + if (hasContentType(clipboardContent, 'text/html')) { + e.preventDefault(); + if (!internal) { + internal = InternalHtml.isMarked(clipboardContent['text/html']); + } + insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal); + } else { + global$2.setEditorTimeout(editor, function () { + insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal); }, 0); + } + }); + }; + var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) { + registerEventHandlers(editor, pasteBin, pasteFormat); + var src; + editor.parser.addNodeFilter('img', function (nodes, name$$1, args) { + var isPasteInsert = function (args) { + return args.data && args.data.paste === true; + }; + var remove = function (node) { + if (!node.attr('data-mce-object') && src !== global$1.transparentSrc) { + node.remove(); + } + }; + var isWebKitFakeUrl = function (src) { + return src.indexOf('webkit-fake-url') === 0; + }; + var isDataUri = function (src) { + return src.indexOf('data:') === 0; + }; + if (!editor.settings.paste_data_images && isPasteInsert(args)) { + var i = nodes.length; + while (i--) { + src = nodes[i].attributes.map.src; + if (!src) { + continue; + } + if (isWebKitFakeUrl(src)) { + remove(nodes[i]); + } else if (!editor.settings.allow_html_data_urls && isDataUri(src)) { + remove(nodes[i]); + } + } + } + }); + }; + + var getPasteBinParent = function (editor) { + return global$1.ie && editor.inline ? document.body : editor.getBody(); + }; + var isExternalPasteBin = function (editor) { + return getPasteBinParent(editor) !== editor.getBody(); + }; + var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) { + if (isExternalPasteBin(editor)) { + editor.dom.bind(pasteBinElm, 'paste keyup', function (e) { + if (!isDefault(editor, pasteBinDefaultContent)) { + editor.fire('paste'); + } }); } }; - }; - var copy = function (editor) { - return function (evt) { - if (editor.selection.isCollapsed() === false) { - setClipboardData(evt, getData(editor), fallback(editor), noop); + var create = function (editor, lastRngCell, pasteBinDefaultContent) { + var dom = editor.dom, body = editor.getBody(); + var pasteBinElm; + lastRngCell.set(editor.selection.getRng()); + pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', { + 'id': 'mcepastebin', + 'class': 'mce-pastebin', + 'contentEditable': true, + 'data-mce-bogus': 'all', + 'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0' + }, pasteBinDefaultContent); + if (global$1.ie || global$1.gecko) { + dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535); } - }; - }; - var register$1 = function (editor) { - editor.on('cut', cut(editor)); - editor.on('copy', copy(editor)); - }; - var $_32blojj3jjgwecv4 = { register: register$1 }; - - var global$10 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); - - var getCaretRangeFromEvent = function (editor, e) { - return global$10.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc()); - }; - var isPlainTextFileUrl = function (content) { - var plainTextContent = content['text/plain']; - return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false; - }; - var setFocusedRange = function (editor, rng) { - editor.focus(); - editor.selection.setRng(rng); - }; - var setup = function (editor, clipboard, draggingInternallyState) { - if ($_xr8b0ikjjgwectl.shouldBlockDrop(editor)) { - editor.on('dragend dragover draggesture dragdrop drop drag', function (e) { - e.preventDefault(); + dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) { e.stopPropagation(); }); - } - if (!$_xr8b0ikjjgwectl.shouldPasteDataImages(editor)) { - editor.on('drop', function (e) { - var dataTransfer = e.dataTransfer; - if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) { - e.preventDefault(); + delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent); + pasteBinElm.focus(); + editor.selection.select(pasteBinElm, true); + }; + var remove = function (editor, lastRngCell) { + if (getEl(editor)) { + var pasteBinClone = void 0; + var lastRng = lastRngCell.get(); + while (pasteBinClone = editor.dom.get('mcepastebin')) { + editor.dom.remove(pasteBinClone); + editor.dom.unbind(pasteBinClone); } + if (lastRng) { + editor.selection.setRng(lastRng); + } + } + lastRngCell.set(null); + }; + var getEl = function (editor) { + return editor.dom.get('mcepastebin'); + }; + var getHtml = function (editor) { + var pasteBinElm, pasteBinClones, i, dirtyWrappers, cleanWrapper; + var copyAndRemove = function (toElm, fromElm) { + toElm.appendChild(fromElm); + editor.dom.remove(fromElm, true); + }; + pasteBinClones = global$3.grep(getPasteBinParent(editor).childNodes, function (elm) { + return elm.id === 'mcepastebin'; }); - } - editor.on('drop', function (e) { - var dropContent, rng; - rng = getCaretRangeFromEvent(editor, e); - if (e.isDefaultPrevented() || draggingInternallyState.get()) { - return; + pasteBinElm = pasteBinClones.shift(); + global$3.each(pasteBinClones, function (pasteBinClone) { + copyAndRemove(pasteBinElm, pasteBinClone); + }); + dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm); + for (i = dirtyWrappers.length - 1; i >= 0; i--) { + cleanWrapper = editor.dom.create('div'); + pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]); + copyAndRemove(cleanWrapper, dirtyWrappers[i]); } - dropContent = clipboard.getDataTransferItems(e.dataTransfer); - var internal = clipboard.hasContentType(dropContent, $_4x13hjirjjgwecu1.internalHtmlMime()); - if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) { - return; + return pasteBinElm ? pasteBinElm.innerHTML : ''; + }; + var getLastRng = function (lastRng) { + return lastRng.get(); + }; + var isDefaultContent = function (pasteBinDefaultContent, content) { + return content === pasteBinDefaultContent; + }; + var isPasteBin = function (elm) { + return elm && elm.id === 'mcepastebin'; + }; + var isDefault = function (editor, pasteBinDefaultContent) { + var pasteBinElm = getEl(editor); + return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML); + }; + var PasteBin = function (editor) { + var lastRng = Cell(null); + var pasteBinDefaultContent = '%MCEPASTEBIN%'; + return { + create: function () { + return create(editor, lastRng, pasteBinDefaultContent); + }, + remove: function () { + return remove(editor, lastRng); + }, + getEl: function () { + return getEl(editor); + }, + getHtml: function () { + return getHtml(editor); + }, + getLastRng: function () { + return getLastRng(lastRng); + }, + isDefault: function () { + return isDefault(editor, pasteBinDefaultContent); + }, + isDefaultContent: function (content) { + return isDefaultContent(pasteBinDefaultContent, content); + } + }; + }; + + var Clipboard = function (editor, pasteFormat) { + var pasteBin = PasteBin(editor); + editor.on('preInit', function () { + return registerEventsAndFilters(editor, pasteBin, pasteFormat); + }); + return { + pasteFormat: pasteFormat, + pasteHtml: function (html, internalFlag) { + return pasteHtml$1(editor, html, internalFlag); + }, + pasteText: function (text) { + return pasteText(editor, text); + }, + pasteImageData: function (e, rng) { + return pasteImageData(editor, e, rng); + }, + getDataTransferItems: getDataTransferItems, + hasHtmlOrText: hasHtmlOrText, + hasContentType: hasContentType + }; + }; + + var noop$1 = function () { + }; + var hasWorkingClipboardApi = function (clipboardData) { + return global$1.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true; + }; + var setHtml5Clipboard = function (clipboardData, html, text) { + if (hasWorkingClipboardApi(clipboardData)) { + try { + clipboardData.clearData(); + clipboardData.setData('text/html', html); + clipboardData.setData('text/plain', text); + clipboardData.setData(InternalHtml.internalHtmlMime(), html); + return true; + } catch (e) { + return false; + } + } else { + return false; } - if (rng && $_xr8b0ikjjgwectl.shouldFilterDrop(editor)) { - var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain']; - if (content_1) { - e.preventDefault(); - global$2.setEditorTimeout(editor, function () { - editor.undoManager.transact(function () { - if (dropContent['mce-internal']) { - editor.execCommand('Delete'); - } - setFocusedRange(editor, rng); - content_1 = $_4bi2o9j0jjgwecui.trimHtml(content_1); - if (!dropContent['text/html']) { - clipboard.pasteText(content_1); - } else { - clipboard.pasteHtml(content_1, internal); - } - }); + }; + var setClipboardData = function (evt, data, fallback, done) { + if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) { + evt.preventDefault(); + done(); + } else { + fallback(data.html, done); + } + }; + var fallback = function (editor) { + return function (html, done) { + var markedHtml = InternalHtml.mark(html); + var outer = editor.dom.create('div', { + 'contenteditable': 'false', + 'data-mce-bogus': 'all' + }); + var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml); + editor.dom.setStyles(outer, { + position: 'fixed', + top: '0', + left: '-3000px', + width: '1000px', + overflow: 'hidden' + }); + outer.appendChild(inner); + editor.dom.add(editor.getBody(), outer); + var range = editor.selection.getRng(); + inner.focus(); + var offscreenRange = editor.dom.createRng(); + offscreenRange.selectNodeContents(inner); + editor.selection.setRng(offscreenRange); + setTimeout(function () { + editor.selection.setRng(range); + outer.parentNode.removeChild(outer); + done(); + }, 0); + }; + }; + var getData = function (editor) { + return { + html: editor.selection.getContent({ contextual: true }), + text: editor.selection.getContent({ format: 'text' }) + }; + }; + var isTableSelection = function (editor) { + return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody()); + }; + var hasSelectedContent = function (editor) { + return !editor.selection.isCollapsed() || isTableSelection(editor); + }; + var cut = function (editor) { + return function (evt) { + if (hasSelectedContent(editor)) { + setClipboardData(evt, getData(editor), fallback(editor), function () { + setTimeout(function () { + editor.execCommand('Delete'); + }, 0); }); } - } - }); - editor.on('dragstart', function (e) { - draggingInternallyState.set(true); - }); - editor.on('dragover dragend', function (e) { - if ($_xr8b0ikjjgwectl.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) { - e.preventDefault(); - setFocusedRange(editor, getCaretRangeFromEvent(editor, e)); - } - if (e.type === 'dragend') { - draggingInternallyState.set(false); - } - }); - }; - var $_b4etj0j4jjgwecv7 = { setup: setup }; + }; + }; + var copy = function (editor) { + return function (evt) { + if (hasSelectedContent(editor)) { + setClipboardData(evt, getData(editor), fallback(editor), noop$1); + } + }; + }; + var register$1 = function (editor) { + editor.on('cut', cut(editor)); + editor.on('copy', copy(editor)); + }; + var CutCopy = { register: register$1 }; - var setup$1 = function (editor) { - var plugin = editor.plugins.paste; - var preProcess = $_xr8b0ikjjgwectl.getPreProcess(editor); - if (preProcess) { + var global$a = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); + + var getCaretRangeFromEvent = function (editor, e) { + return global$a.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc()); + }; + var isPlainTextFileUrl = function (content) { + var plainTextContent = content['text/plain']; + return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false; + }; + var setFocusedRange = function (editor, rng) { + editor.focus(); + editor.selection.setRng(rng); + }; + var setup = function (editor, clipboard, draggingInternallyState) { + if (Settings.shouldBlockDrop(editor)) { + editor.on('dragend dragover draggesture dragdrop drop drag', function (e) { + e.preventDefault(); + e.stopPropagation(); + }); + } + if (!Settings.shouldPasteDataImages(editor)) { + editor.on('drop', function (e) { + var dataTransfer = e.dataTransfer; + if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) { + e.preventDefault(); + } + }); + } + editor.on('drop', function (e) { + var dropContent, rng; + rng = getCaretRangeFromEvent(editor, e); + if (e.isDefaultPrevented() || draggingInternallyState.get()) { + return; + } + dropContent = clipboard.getDataTransferItems(e.dataTransfer); + var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime()); + if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) { + return; + } + if (rng && Settings.shouldFilterDrop(editor)) { + var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain']; + if (content_1) { + e.preventDefault(); + global$2.setEditorTimeout(editor, function () { + editor.undoManager.transact(function () { + if (dropContent['mce-internal']) { + editor.execCommand('Delete'); + } + setFocusedRange(editor, rng); + content_1 = Utils.trimHtml(content_1); + if (!dropContent['text/html']) { + clipboard.pasteText(content_1); + } else { + clipboard.pasteHtml(content_1, internal); + } + }); + }); + } + } + }); + editor.on('dragstart', function (e) { + draggingInternallyState.set(true); + }); + editor.on('dragover dragend', function (e) { + if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) { + e.preventDefault(); + setFocusedRange(editor, getCaretRangeFromEvent(editor, e)); + } + if (e.type === 'dragend') { + draggingInternallyState.set(false); + } + }); + }; + var DragDrop = { setup: setup }; + + var setup$1 = function (editor) { + var plugin = editor.plugins.paste; + var preProcess = Settings.getPreProcess(editor); + if (preProcess) { + editor.on('PastePreProcess', function (e) { + preProcess.call(plugin, plugin, e); + }); + } + var postProcess = Settings.getPostProcess(editor); + if (postProcess) { + editor.on('PastePostProcess', function (e) { + postProcess.call(plugin, plugin, e); + }); + } + }; + var PrePostProcess = { setup: setup$1 }; + + function addPreProcessFilter(editor, filterFunc) { editor.on('PastePreProcess', function (e) { - preProcess.call(plugin, plugin, e); + e.content = filterFunc(editor, e.content, e.internal, e.wordContent); }); } - var postProcess = $_xr8b0ikjjgwectl.getPostProcess(editor); - if (postProcess) { + function addPostProcessFilter(editor, filterFunc) { editor.on('PastePostProcess', function (e) { - postProcess.call(plugin, plugin, e); + filterFunc(editor, e.node); }); } - }; - var $_c5bihmj6jjgwecva = { setup: setup$1 }; - - function addPreProcessFilter(editor, filterFunc) { - editor.on('PastePreProcess', function (e) { - e.content = filterFunc(editor, e.content, e.internal, e.wordContent); - }); - } - function addPostProcessFilter(editor, filterFunc) { - editor.on('PastePostProcess', function (e) { - filterFunc(editor, e.node); - }); - } - function removeExplorerBrElementsAfterBlocks(editor, html) { - if (!$_dfatuiivjjgwecu8.isWordContent(html)) { + function removeExplorerBrElementsAfterBlocks(editor, html) { + if (!WordFilter.isWordContent(html)) { + return html; + } + var blockElements = []; + global$3.each(editor.schema.getBlockElements(), function (block, blockName) { + blockElements.push(blockName); + }); + var explorerBlocksRegExp = new RegExp('(?:
 [\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
 [\\s\\r\\n]+|
)*', 'g'); + html = Utils.filter(html, [[ + explorerBlocksRegExp, + '$1' + ]]); + html = Utils.filter(html, [ + [ + /

/g, + '

' + ], + [ + /
/g, + ' ' + ], + [ + /

/g, + '
' + ] + ]); return html; } - var blockElements = []; - global$3.each(editor.schema.getBlockElements(), function (block, blockName) { - blockElements.push(blockName); - }); - var explorerBlocksRegExp = new RegExp('(?:
 [\\s\\r\\n]+|
)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:
 [\\s\\r\\n]+|
)*', 'g'); - html = $_4bi2o9j0jjgwecui.filter(html, [[ - explorerBlocksRegExp, - '$1' - ]]); - html = $_4bi2o9j0jjgwecui.filter(html, [ - [ - /

/g, - '

' - ], - [ - /
/g, - ' ' - ], - [ - /

/g, - '
' - ] - ]); - return html; - } - function removeWebKitStyles(editor, content, internal, isWordHtml) { - if (isWordHtml || internal) { - return content; - } - var webKitStylesSetting = $_xr8b0ikjjgwectl.getWebkitStyles(editor); - var webKitStyles; - if ($_xr8b0ikjjgwectl.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') { - return content; - } - if (webKitStylesSetting) { - webKitStyles = webKitStylesSetting.split(/[, ]/); - } - if (webKitStyles) { - var dom_1 = editor.dom, node_1 = editor.selection.getNode(); - content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) { - var inputStyles = dom_1.parseStyle(dom_1.decode(value)); - var outputStyles = {}; - if (webKitStyles === 'none') { - return before + after; - } - for (var i = 0; i < webKitStyles.length; i++) { - var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true); - if (/color/.test(webKitStyles[i])) { - inputValue = dom_1.toHex(inputValue); - currentValue = dom_1.toHex(currentValue); - } - if (currentValue !== inputValue) { - outputStyles[webKitStyles[i]] = inputValue; - } - } - outputStyles = dom_1.serializeStyle(outputStyles, 'span'); - if (outputStyles) { - return before + ' style="' + outputStyles + '"' + after; - } - return before + after; - }); - } else { - content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3'); - } - content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) { - return before + ' style="' + value + '"' + after; - }); - return content; - } - function removeUnderlineAndFontInAnchor(editor, root) { - editor.$('a', root).find('font,u').each(function (i, node) { - editor.dom.remove(node, true); - }); - } - var setup$2 = function (editor) { - if (global$1.webkit) { - addPreProcessFilter(editor, removeWebKitStyles); - } - if (global$1.ie) { - addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks); - addPostProcessFilter(editor, removeUnderlineAndFontInAnchor); - } - }; - var $_36tmgyj7jjgwecvc = { setup: setup$2 }; - - var curry = function (f) { - var x = []; - for (var _i = 1; _i < arguments.length; _i++) { - x[_i - 1] = arguments[_i]; - } - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) - args[i - 1] = arguments[i]; - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; + function removeWebKitStyles(editor, content, internal, isWordHtml) { + if (isWordHtml || internal) { + return content; } - var newArgs = new Array(arguments.length); - for (var j = 0; j < newArgs.length; j++) - newArgs[j] = arguments[j]; - var all = args.concat(newArgs); - return f.apply(null, all); - }; - }; - - var stateChange = function (editor, clipboard, e) { - var ctrl = e.control; - ctrl.active(clipboard.pasteFormat.get() === 'text'); - editor.on('PastePlainTextToggle', function (e) { - ctrl.active(e.state); - }); - }; - var register$2 = function (editor, clipboard) { - var postRender = curry(stateChange, editor, clipboard); - editor.addButton('pastetext', { - active: false, - icon: 'pastetext', - tooltip: 'Paste as text', - cmd: 'mceTogglePlainTextPaste', - onPostRender: postRender - }); - editor.addMenuItem('pastetext', { - text: 'Paste as text', - selectable: true, - active: clipboard.pasteFormat, - cmd: 'mceTogglePlainTextPaste', - onPostRender: postRender - }); - }; - var $_g9yhwdj8jjgwecvf = { register: register$2 }; - - global.add('paste', function (editor) { - if ($_15bf6siejjgwect1.hasProPlugin(editor) === false) { - var userIsInformedState = Cell(false); - var draggingInternallyState = Cell(false); - var pasteFormat = Cell($_xr8b0ikjjgwectl.isPasteAsTextEnabled(editor) ? 'text' : 'html'); - var clipboard = Clipboard(editor, pasteFormat); - var quirks = $_36tmgyj7jjgwecvc.setup(editor); - $_g9yhwdj8jjgwecvf.register(editor, clipboard); - $_fldd1mihjjgwecth.register(editor, clipboard, userIsInformedState); - $_c5bihmj6jjgwecva.setup(editor); - $_32blojj3jjgwecv4.register(editor); - $_b4etj0j4jjgwecv7.setup(editor, clipboard, draggingInternallyState); - return $_6gtliyigjjgwecte.get(clipboard, quirks); + var webKitStylesSetting = Settings.getWebkitStyles(editor); + var webKitStyles; + if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') { + return content; + } + if (webKitStylesSetting) { + webKitStyles = webKitStylesSetting.split(/[, ]/); + } + if (webKitStyles) { + var dom_1 = editor.dom, node_1 = editor.selection.getNode(); + content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) { + var inputStyles = dom_1.parseStyle(dom_1.decode(value)); + var outputStyles = {}; + if (webKitStyles === 'none') { + return before + after; + } + for (var i = 0; i < webKitStyles.length; i++) { + var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true); + if (/color/.test(webKitStyles[i])) { + inputValue = dom_1.toHex(inputValue); + currentValue = dom_1.toHex(currentValue); + } + if (currentValue !== inputValue) { + outputStyles[webKitStyles[i]] = inputValue; + } + } + outputStyles = dom_1.serializeStyle(outputStyles, 'span'); + if (outputStyles) { + return before + ' style="' + outputStyles + '"' + after; + } + return before + after; + }); + } else { + content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3'); + } + content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) { + return before + ' style="' + value + '"' + after; + }); + return content; } - }); - function Plugin () { - } + function removeUnderlineAndFontInAnchor(editor, root) { + editor.$('a', root).find('font,u').each(function (i, node) { + editor.dom.remove(node, true); + }); + } + var setup$2 = function (editor) { + if (global$1.webkit) { + addPreProcessFilter(editor, removeWebKitStyles); + } + if (global$1.ie) { + addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks); + addPostProcessFilter(editor, removeUnderlineAndFontInAnchor); + } + }; + var Quirks = { setup: setup$2 }; - return Plugin; + var stateChange = function (editor, clipboard, e) { + var ctrl = e.control; + ctrl.active(clipboard.pasteFormat.get() === 'text'); + editor.on('PastePlainTextToggle', function (e) { + ctrl.active(e.state); + }); + }; + var register$2 = function (editor, clipboard) { + var postRender = curry(stateChange, editor, clipboard); + editor.addButton('pastetext', { + active: false, + icon: 'pastetext', + tooltip: 'Paste as text', + cmd: 'mceTogglePlainTextPaste', + onPostRender: postRender + }); + editor.addMenuItem('pastetext', { + text: 'Paste as text', + selectable: true, + active: clipboard.pasteFormat, + cmd: 'mceTogglePlainTextPaste', + onPostRender: postRender + }); + }; + var Buttons = { register: register$2 }; + + global.add('paste', function (editor) { + if (DetectProPlugin.hasProPlugin(editor) === false) { + var userIsInformedState = Cell(false); + var draggingInternallyState = Cell(false); + var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html'); + var clipboard = Clipboard(editor, pasteFormat); + var quirks = Quirks.setup(editor); + Buttons.register(editor, clipboard); + Commands.register(editor, clipboard, userIsInformedState); + PrePostProcess.setup(editor); + CutCopy.register(editor); + DragDrop.setup(editor, clipboard, draggingInternallyState); + return Api.get(clipboard, quirks); + } + }); + function Plugin () { + } + + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/paste/plugin.min.js b/wp-includes/js/tinymce/plugins/paste/plugin.min.js index bc3fa2e000..a75c4534ce 100644 --- a/wp-includes/js/tinymce/plugins/paste/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/paste/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var u=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return u(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),o=function(e){return!(!/(^|[ ,])powerpaste([, ]|$)/.test(e.settings.plugins)||!t.get("powerpaste")||("undefined"!=typeof window.console&&window.console.log&&window.console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option."),0))},s=function(e,t){return{clipboard:e,quirks:t}},f=function(e,t,n,r){return e.fire("PastePreProcess",{content:t,internal:n,wordContent:r})},d=function(e,t,n,r){return e.fire("PastePostProcess",{node:t,internal:n,wordContent:r})},l=function(e,t){return e.fire("PastePlainTextToggle",{state:t})},n=function(e,t){return e.fire("paste",{ieFake:t})},m={shouldPlainTextInform:function(e){return e.getParam("paste_plaintext_inform",!0)},shouldBlockDrop:function(e){return e.getParam("paste_block_drop",!1)},shouldPasteDataImages:function(e){return e.getParam("paste_data_images",!1)},shouldFilterDrop:function(e){return e.getParam("paste_filter_drop",!0)},getPreProcess:function(e){return e.getParam("paste_preprocess")},getPostProcess:function(e){return e.getParam("paste_postprocess")},getWebkitStyles:function(e){return e.getParam("paste_webkit_styles")},shouldRemoveWebKitStyles:function(e){return e.getParam("paste_remove_styles_if_webkit",!0)},shouldMergeFormats:function(e){return e.getParam("paste_merge_formats",!0)},isSmartPasteEnabled:function(e){return e.getParam("smart_paste",!0)},isPasteAsTextEnabled:function(e){return e.getParam("paste_as_text",!1)},getRetainStyleProps:function(e){return e.getParam("paste_retain_style_properties")},getWordValidElements:function(e){return e.getParam("paste_word_valid_elements","-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody")},shouldConvertWordFakeLists:function(e){return e.getParam("paste_convert_word_fake_lists",!0)},shouldUseDefaultFilters:function(e){return e.getParam("paste_enable_default_filters",!0)}},r=function(e,t,n){var r,a,i;"text"===t.pasteFormat.get()?(t.pasteFormat.set("html"),l(e,!1)):(t.pasteFormat.set("text"),l(e,!0),i=e,!1===n.get()&&m.shouldPlainTextInform(i)&&(a="Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.",(r=e).notificationManager.open({text:r.translate(a),type:"info"}),n.set(!0))),e.focus()},c=function(e,n,t){e.addCommand("mceTogglePlainTextPaste",function(){r(e,n,t)}),e.addCommand("mceInsertClipboardContent",function(e,t){t.content&&n.pasteHtml(t.content,t.internal),t.text&&n.pasteText(t.text)})},v=tinymce.util.Tools.resolve("tinymce.Env"),h=tinymce.util.Tools.resolve("tinymce.util.Delay"),b=tinymce.util.Tools.resolve("tinymce.util.Tools"),a=tinymce.util.Tools.resolve("tinymce.util.VK"),e="x-tinymce/html",i="\x3c!-- "+e+" --\x3e",p=function(e){return i+e},g=function(e){return e.replace(i,"")},y=function(e){return-1!==e.indexOf(i)},x=function(){return e},P=tinymce.util.Tools.resolve("tinymce.html.Entities"),w=function(e){return e.replace(/\r?\n/g,"
")},_=function(e,t,n){var r=e.split(/\n\n/),a=function(e,t){var n,r=[],a="<"+e;if("object"==typeof t){for(n in t)t.hasOwnProperty(n)&&r.push(n+'="'+P.encodeAllRaw(t[n])+'"');r.length&&(a+=" "+r.join(" "))}return a+">"}(t,n),i="",o=b.map(r,function(e){return e.split(/\n/).join("
")});return 1===o.length?o[0]:b.map(o,function(e){return a+e+i}).join("")},D=function(e){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e)},T=function(e,t,n){return t?_(e,t,n):w(e)},C=tinymce.util.Tools.resolve("tinymce.html.DomParser"),k=tinymce.util.Tools.resolve("tinymce.html.Node"),R=tinymce.util.Tools.resolve("tinymce.html.Schema"),F=tinymce.util.Tools.resolve("tinymce.html.Serializer");function E(t,e){return b.each(e,function(e){t=e.constructor===RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}var S={filter:E,innerText:function(t){var n=R(),r=C({},n),a="",i=n.getShortEndedElements(),o=b.makeMap("script noscript style textarea video audio iframe object"," "),s=n.getBlockElements();return t=E(t,[//g]),function e(t){var n=t.name,r=t;if("br"!==n)if(i[n]&&(a+=" "),o[n])a+=" ";else{if(3===t.type&&(a+=t.value),!t.shortEnded&&(t=t.firstChild))for(;e(t),t=t.next;);s[n]&&r.next&&(a+="\n","p"===n&&(a+="\n"))}else a+="\n"}(r.parse(t)),a},trimHtml:function(e){return e=E(e,[/^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/|/g,[/( ?)\u00a0<\/span>( ?)/g,function(e,t,n){return t||n?"\xa0":" "}],/
/g,/
$/i])},createIdGenerator:function(e){var t=0;return function(){return e+t++}},isMsEdge:function(){return-1!==navigator.userAgent.indexOf(" Edge/")}};function I(t){var n,e;return e=[/^[IVXLMCD]{1,2}\.[ \u00a0]/,/^[ivxlmcd]{1,2}\.[ \u00a0]/,/^[a-z]{1,2}[\.\)][ \u00a0]/,/^[A-Z]{1,2}[\.\)][ \u00a0]/,/^[0-9]+\.[ \u00a0]/,/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/],t=t.replace(/^[\u00a0 ]+/,""),b.each(e,function(e){if(e.test(t))return!(n=!0)}),n}function M(e){var i,o,s=1;function n(e){var t="";if(3===e.type)return e.value;if(e=e.firstChild)for(;t+=n(e),e=e.next;);return t}function l(e,t){if(3===e.type&&t.test(e.value))return e.value=e.value.replace(t,""),!1;if(e=e.firstChild)do{if(!l(e,t))return!1}while(e=e.next);return!0}function t(t,n,r){var a=t._listLevel||s;a!==s&&(a/gi,/]+id="?docs-internal-[^>]*>/gi,//gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/([\s\u00a0]*)<\/span>/gi,function(e,t){return 0')}),!0);var r,a,i},z=function(e,t){var n,r;!1===m.isSmartPasteEnabled(e)?$(e,t):(n=e,r=t,b.each([N,V,$],function(e){return!0!==e(n,r,$)}))},K=function(e,t,n){var r=n||y(t),a=L(e,g(t),r);!1===a.cancelled&&z(e,a.content)},U=function(e,t){t=e.dom.encode(t).replace(/\r\n/g,"\n"),t=T(t,e.settings.forced_root_block,e.settings.forced_root_block_attrs),K(e,t,!1)},G=function(e){var t={};if(e){if(e.getData){var n=e.getData("Text");n&&0',!1)}else K(e,'',!1)},J=function(o,s,l){var e="paste"===s.type?s.clipboardData:s.dataTransfer;function t(e){var t,n,r,a=!1;if(e)for(t=0;t [\\s\\r\\n]+|
)*(<\\/?("+n.join("|")+")[^>]*>)(?:
 [\\s\\r\\n]+|
)*","g");return t=S.filter(t,[[r,"$1"]]),t=S.filter(t,[[/

/g,"

"],[/
/g," "],[/

/g,"
"]])}function xe(e,t,n,r){if(r||n)return t;var u,a=m.getWebkitStyles(e);if(!1===m.shouldRemoveWebKitStyles(e)||"all"===a)return t;if(a&&(u=a.split(/[, ]/)),u){var c=e.dom,f=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(e,t,n,r){var a=c.parseStyle(c.decode(n)),i={};if("none"===u)return t+r;for(var o=0;o]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(e,t,n,r){return t+' style="'+n+'"'+r})}function Pe(n,e){n.$("a",e).find("font,u").each(function(e,t){n.dom.remove(t,!0)})}var we=function(e){var t,n;v.webkit&&be(e,xe),v.ie&&(be(e,ye),n=Pe,(t=e).on("PastePostProcess",function(e){n(t,e.node)}))},_e=function(e,t,n){var r=n.control;r.active("text"===t.pasteFormat.get()),e.on("PastePlainTextToggle",function(e){r.active(e.state)})},De=function(e,t){var n=function(i){for(var e=[],t=1;t")},_=function(t,e,n){var r=t.split(/\n\n/),o=function(t,e){var n,r=[],o="<"+t;if("object"==typeof e){for(n in e)e.hasOwnProperty(n)&&r.push(n+'="'+P.encodeAllRaw(e[n])+'"');r.length&&(o+=" "+r.join(" "))}return o+">"}(e,n),i="",a=y.map(r,function(t){return t.split(/\n/).join("
")});return 1===a.length?a[0]:y.map(a,function(t){return o+t+i}).join("")},D=function(t){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(t)},T=function(t,e,n){return e?_(t,e,n):w(t)},C=tinymce.util.Tools.resolve("tinymce.html.DomParser"),k=tinymce.util.Tools.resolve("tinymce.html.Node"),S=tinymce.util.Tools.resolve("tinymce.html.Schema"),O=tinymce.util.Tools.resolve("tinymce.html.Serializer");function R(e,t){return y.each(t,function(t){e=t.constructor===RegExp?e.replace(t,""):e.replace(t[0],t[1])}),e}var F={filter:R,innerText:function(e){var n=S(),r=C({},n),o="",i=n.getShortEndedElements(),a=y.makeMap("script noscript style textarea video audio iframe object"," "),s=n.getBlockElements();return e=R(e,[//g]),function t(e){var n=e.name,r=e;if("br"!==n){if("wbr"!==n)if(i[n]&&(o+=" "),a[n])o+=" ";else{if(3===e.type&&(o+=e.value),!e.shortEnded&&(e=e.firstChild))for(;t(e),e=e.next;);s[n]&&r.next&&(o+="\n","p"===n&&(o+="\n"))}}else o+="\n"}(r.parse(e)),o},trimHtml:function(t){return t=R(t,[/^[\s\S]*]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/|/g,[/( ?)\u00a0<\/span>( ?)/g,function(t,e,n){return e||n?"\xa0":" "}],/
/g,/
$/i])},createIdGenerator:function(t){var e=0;return function(){return t+e++}},isMsEdge:function(){return-1!==navigator.userAgent.indexOf(" Edge/")}};function E(e){var n,t;return t=[/^[IVXLMCD]{1,2}\.[ \u00a0]/,/^[ivxlmcd]{1,2}\.[ \u00a0]/,/^[a-z]{1,2}[\.\)][ \u00a0]/,/^[A-Z]{1,2}[\.\)][ \u00a0]/,/^[0-9]+\.[ \u00a0]/,/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/],e=e.replace(/^[\u00a0 ]+/,""),y.each(t,function(t){if(t.test(e))return!(n=!0)}),n}function A(t){var i,a,s=1;function n(t){var e="";if(3===t.type)return t.value;if(t=t.firstChild)for(;e+=n(t),t=t.next;);return e}function u(t,e){if(3===t.type&&e.test(t.value))return t.value=t.value.replace(e,""),!1;if(t=t.firstChild)do{if(!u(t,e))return!1}while(t=t.next);return!0}function e(e,n,r){var o=e._listLevel||s;o!==s&&(o/gi,/]+id="?docs-internal-[^>]*>/gi,//gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/ /gi,"\xa0"],[/([\s\u00a0]*)<\/span>/gi,function(t,e){return 0')}),!0);var r,o,i},X=function(t,e){var n,r;!1===m.isSmartPasteEnabled(t)?U(t,e):(n=t,r=e,y.each([K,G,U],function(t){return!0!==t(n,r,U)}))},Y=function(t){return function(){return t}},Z=Y(!1),J=Y(!0),Q=Z,tt=J,et=function(){return nt},nt=(j={fold:function(t,e){return t()},is:Q,isSome:Q,isNone:tt,getOr:H=function(t){return t},getOrThunk:B=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:H,orThunk:B,map:et,ap:et,each:function(){},bind:et,flatten:et,exists:Q,forall:tt,filter:et,equals:M=function(t){return t.isNone()},equals_:M,toArray:function(){return[]},toString:Y("none()")},Object.freeze&&Object.freeze(j),j),rt=function(n){var t=function(){return n},e=function(){return o},r=function(t){return t(n)},o={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:tt,isNone:Q,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return rt(t(n))},ap:function(t){return t.fold(et,function(t){return rt(t(n))})},each:function(t){t(n)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(n)?o:nt},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(Q,function(t){return e(n,t)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},ot={some:rt,none:et,from:function(t){return null===t||t===undefined?nt:rt(t)}},it=(L="function",function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&Array.prototype.isPrototypeOf(t)?"array":"object"===e&&String.prototype.isPrototypeOf(t)?"string":e}(t)===L}),at=function(t,e){for(var n=t.length,r=new Array(n),o=0;o=a.length&&r(o)}))})})},pt=function(t,e){var n=at(t,e);return gt(n,mt.nu)},vt=function(t,e,n){var r=n||b(e),o=z(t,p(e),r);!1===o.cancelled&&X(t,o.content)},ht=function(t,e){e=t.dom.encode(e).replace(/\r\n/g,"\n"),e=T(e,t.settings.forced_root_block,t.settings.forced_root_block_attrs),vt(t,e,!1)},yt=function(t){var e={};if(t){if(t.getData){var n=t.getData("Text");n&&0',!1)}else vt(t,'',!1)}(e,t)})}),!0}return!1},_t=function(t){return o.metaKeyPressed(t)&&86===t.keyCode||t.shiftKey&&45===t.keyCode},Dt=function(c,f,d){var m,g=0;function p(t,e,n,r){var o,i;bt(t,"text/html")?o=t["text/html"]:(o=f.getHtml(),r=r||b(o),f.isDefaultContent(o)&&(n=!0)),o=F.trimHtml(o),f.remove(),i=!1===r&&D(o),o.length&&!i||(n=!0),n&&(o=bt(t,"text/plain")&&i?t["text/plain"]:F.innerText(o)),f.isDefaultContent(o)?e||c.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."):n?ht(c,o):vt(c,o,r)}c.on("keydown",function(t){function e(t){_t(t)&&!t.isDefaultPrevented()&&f.remove()}if(_t(t)&&!t.isDefaultPrevented()){if((m=t.shiftKey&&86===t.keyCode)&&v.webkit&&-1!==navigator.userAgent.indexOf("Version/"))return;if(t.stopImmediatePropagation(),g=(new Date).getTime(),v.ie&&m)return t.preventDefault(),void n(c,!0);f.remove(),f.create(),c.once("keyup",e),c.once("paste",function(){c.off("keyup",e)})}}),c.on("paste",function(t){var e,n,r,o=(new Date).getTime(),i=(e=c,n=yt(t.clipboardData||e.getDoc().dataTransfer),F.isMsEdge()?y.extend(n,{"text/html":""}):n),a=(new Date).getTime()-o,s=(new Date).getTime()-g-a<1e3,u="text"===d.get()||m,l=bt(i,x());m=!1,t.isDefaultPrevented()||(r=t.clipboardData,-1!==navigator.userAgent.indexOf("Android")&&r&&r.items&&0===r.items.length)?f.remove():xt(i)||!wt(c,t,f.getLastRng()||c.selection.getRng())?(s||t.preventDefault(),!v.ie||s&&!t.ieFake||bt(i,"text/html")||(f.create(),c.dom.bind(f.getEl(),"paste",function(t){t.stopPropagation()}),c.getDoc().execCommand("Paste",!1,null),i["text/html"]=f.getHtml()),bt(i,"text/html")?(t.preventDefault(),l||(l=b(i["text/html"])),p(i,s,u,l)):h.setEditorTimeout(c,function(){p(i,s,u,l)},0)):f.remove()})},Tt=function(t){return v.ie&&t.inline?document.body:t.getBody()},Ct=function(e,t,n){var r;Tt(r=e)!==r.getBody()&&e.dom.bind(t,"paste keyup",function(t){Ot(e,n)||e.fire("paste")})},kt=function(t){return t.dom.get("mcepastebin")},St=function(t,e){return e===t},Ot=function(t,e){var n,r=kt(t);return(n=r)&&"mcepastebin"===n.id&&St(e,r.innerHTML)},Rt=function(a){var s=l(null),u="%MCEPASTEBIN%";return{create:function(){return e=s,n=u,o=(t=a).dom,i=t.getBody(),e.set(t.selection.getRng()),r=t.dom.add(Tt(t),"div",{id:"mcepastebin","class":"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},n),(v.ie||v.gecko)&&o.setStyle(r,"left","rtl"===o.getStyle(i,"direction",!0)?65535:-65535),o.bind(r,"beforedeactivate focusin focusout",function(t){t.stopPropagation()}),Ct(t,r,n),r.focus(),void t.selection.select(r,!0);var t,e,n,r,o,i},remove:function(){return function(t,e){if(kt(t)){for(var n=void 0,r=e.get();n=t.dom.get("mcepastebin");)t.dom.remove(n),t.dom.unbind(n);r&&t.selection.setRng(r)}e.set(null)}(a,s)},getEl:function(){return kt(a)},getHtml:function(){return function(n){var e,t,r,o,i,a=function(t,e){t.appendChild(e),n.dom.remove(e,!0)};for(t=y.grep(Tt(n).childNodes,function(t){return"mcepastebin"===t.id}),e=t.shift(),y.each(t,function(t){a(e,t)}),r=(o=n.dom.select("div[id=mcepastebin]",e)).length-1;0<=r;r--)i=n.dom.create("div"),e.insertBefore(i,o[r]),a(i,o[r]);return e?e.innerHTML:""}(a)},getLastRng:function(){return s.get()},isDefault:function(){return Ot(a,u)},isDefaultContent:function(t){return St(u,t)}}},Ft=function(n,t){var e=Rt(n);return n.on("preInit",function(){return Dt(a=n,e,t),void a.parser.addNodeFilter("img",function(t,e,n){var r,o=function(t){t.attr("data-mce-object")||s===v.transparentSrc||t.remove()};if(!a.settings.paste_data_images&&(r=n).data&&!0===r.data.paste)for(var i=t.length;i--;)(s=t[i].attributes.map.src)&&(0===s.indexOf("webkit-fake-url")?o(t[i]):a.settings.allow_html_data_urls||0!==s.indexOf("data:")||o(t[i]))});var a,s}),{pasteFormat:t,pasteHtml:function(t,e){return vt(n,t,e)},pasteText:function(t){return ht(n,t)},pasteImageData:function(t,e){return wt(n,t,e)},getDataTransferItems:yt,hasHtmlOrText:xt,hasContentType:bt}},Et=function(){},At=function(t,e,n){if(r=t,!1!==v.iOS||r===undefined||"function"!=typeof r.setData||!0===F.isMsEdge())return!1;try{return t.clearData(),t.setData("text/html",e),t.setData("text/plain",n),t.setData(x(),e),!0}catch(o){return!1}var r},It=function(t,e,n,r){At(t.clipboardData,e.html,e.text)?(t.preventDefault(),r()):n(e.html,r)},Mt=function(s){return function(t,e){var n=g(t),r=s.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),o=s.dom.create("div",{contenteditable:"true"},n);s.dom.setStyles(r,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),r.appendChild(o),s.dom.add(s.getBody(),r);var i=s.selection.getRng();o.focus();var a=s.dom.createRng();a.selectNodeContents(o),s.selection.setRng(a),setTimeout(function(){s.selection.setRng(i),r.parentNode.removeChild(r),e()},0)}},Bt=function(t){return{html:t.selection.getContent({contextual:!0}),text:t.selection.getContent({format:"text"})}},Ht=function(t){return!t.selection.isCollapsed()||!!(e=t).dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody());var e},jt=function(t){var e,n;t.on("cut",(e=t,function(t){Ht(e)&&It(t,Bt(e),Mt(e),function(){setTimeout(function(){e.execCommand("Delete")},0)})})),t.on("copy",(n=t,function(t){Ht(n)&&It(t,Bt(n),Mt(n),Et)}))},Lt=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),Nt=function(t,e){return Lt.getCaretRangeFromPoint(e.clientX,e.clientY,t.getDoc())},$t=function(t,e){t.focus(),t.selection.setRng(e)},Wt=function(a,s,u){m.shouldBlockDrop(a)&&a.on("dragend dragover draggesture dragdrop drop drag",function(t){t.preventDefault(),t.stopPropagation()}),m.shouldPasteDataImages(a)||a.on("drop",function(t){var e=t.dataTransfer;e&&e.files&&0 [\\s\\r\\n]+|
)*(<\\/?("+n.join("|")+")[^>]*>)(?:
 [\\s\\r\\n]+|
)*","g");return e=F.filter(e,[[r,"$1"]]),e=F.filter(e,[[/

/g,"

"],[/
/g," "],[/

/g,"
"]])}function qt(t,e,n,r){if(r||n)return e;var l,o=m.getWebkitStyles(t);if(!1===m.shouldRemoveWebKitStyles(t)||"all"===o)return e;if(o&&(l=o.split(/[, ]/)),l){var c=t.dom,f=t.selection.getNode();e=e.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(t,e,n,r){var o=c.parseStyle(c.decode(n)),i={};if("none"===l)return e+r;for(var a=0;a]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return e=e.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(t,e,n,r){return e+' style="'+n+'"'+r})}function Kt(n,t){n.$("a",t).find("font,u").each(function(t,e){n.dom.remove(e,!0)})}var Gt=function(t){var e,n;v.webkit&&Ut(t,qt),v.ie&&(Ut(t,Vt),n=Kt,(e=t).on("PastePostProcess",function(t){n(e,t.node)}))},Xt=function(t,e,n){var r=n.control;r.active("text"===e.pasteFormat.get()),t.on("PastePlainTextToggle",function(t){r.active(t.state)})},Yt=function(t,e){var n=function(r){for(var o=[],t=1;t 0) { - for (i = x + 1; i < el.length; i++) { - if (canSelect(el[i])) { - return el[i]; - } - } - } else { - for (i = x - 1; i >= 0; i--) { - if (canSelect(el[i])) { - return el[i]; - } - } - } - return null; - } - v = global$5.explode($_8rita4kwjjgwed4m.getTabFocus(editor)); - if (v.length === 1) { - v[1] = v[0]; - v[0] = ':prev'; - } - if (e.shiftKey) { - if (v[0] === ':prev') { - el = find(-1); - } else { - el = DOM.get(v[0]); - } - } else { - if (v[1] === ':next') { - el = find(1); - } else { - el = DOM.get(v[1]); - } - } - if (el) { - var focusEditor = global$2.get(el.id || el.name); - if (el.id && focusEditor) { - focusEditor.focus(); - } else { - global$4.setTimeout(function () { - if (!global$3.webkit) { - window.focus(); - } - el.focus(); - }, 10); - } + var DOM = global$1.DOM; + var tabCancel = function (e) { + if (e.keyCode === global$6.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) { e.preventDefault(); } - } - editor.on('init', function () { - if (editor.inline) { - DOM.setAttrib(editor.getBody(), 'tabIndex', null); - } - editor.on('keyup', tabCancel); - if (global$3.gecko) { - editor.on('keypress keydown', tabHandler); - } else { - editor.on('keydown', tabHandler); + }; + var setup = function (editor) { + function tabHandler(e) { + var x, el, v, i; + if (e.keyCode !== global$6.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) { + return; + } + function find(direction) { + el = DOM.select(':input:enabled,*[tabindex]:not(iframe)'); + function canSelectRecursive(e) { + return e.nodeName === 'BODY' || e.type !== 'hidden' && e.style.display !== 'none' && e.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode); + } + function canSelect(el) { + return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$2.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el); + } + global$5.each(el, function (e, i) { + if (e.id === editor.id) { + x = i; + return false; + } + }); + if (direction > 0) { + for (i = x + 1; i < el.length; i++) { + if (canSelect(el[i])) { + return el[i]; + } + } + } else { + for (i = x - 1; i >= 0; i--) { + if (canSelect(el[i])) { + return el[i]; + } + } + } + return null; + } + v = global$5.explode(Settings.getTabFocus(editor)); + if (v.length === 1) { + v[1] = v[0]; + v[0] = ':prev'; + } + if (e.shiftKey) { + if (v[0] === ':prev') { + el = find(-1); + } else { + el = DOM.get(v[0]); + } + } else { + if (v[1] === ':next') { + el = find(1); + } else { + el = DOM.get(v[1]); + } + } + if (el) { + var focusEditor = global$2.get(el.id || el.name); + if (el.id && focusEditor) { + focusEditor.focus(); + } else { + global$4.setTimeout(function () { + if (!global$3.webkit) { + window.focus(); + } + el.focus(); + }, 10); + } + e.preventDefault(); + } } + editor.on('init', function () { + if (editor.inline) { + DOM.setAttrib(editor.getBody(), 'tabIndex', null); + } + editor.on('keyup', tabCancel); + if (global$3.gecko) { + editor.on('keypress keydown', tabHandler); + } else { + editor.on('keydown', tabHandler); + } + }); + }; + var Keyboard = { setup: setup }; + + global.add('tabfocus', function (editor) { + Keyboard.setup(editor); }); - }; - var $_6zogdykpjjgwed4h = { setup: setup }; + function Plugin () { + } - global.add('tabfocus', function (editor) { - $_6zogdykpjjgwed4h.setup(editor); - }); - function Plugin () { - } - - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/textcolor/plugin.js b/wp-includes/js/tinymce/plugins/textcolor/plugin.js index e3d53012b1..172916bd3a 100644 --- a/wp-includes/js/tinymce/plugins/textcolor/plugin.js +++ b/wp-includes/js/tinymce/plugins/textcolor/plugin.js @@ -1,346 +1,346 @@ (function () { var textcolor = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); - var getCurrentColor = function (editor, format) { - var color; - editor.dom.getParents(editor.selection.getStart(), function (elm) { - var value; - if (value = elm.style[format === 'forecolor' ? 'color' : 'background-color']) { - color = value; - } - }); - return color; - }; - var mapColors = function (colorMap) { - var i; - var colors = []; - for (i = 0; i < colorMap.length; i += 2) { - colors.push({ - text: colorMap[i + 1], - color: '#' + colorMap[i] + var getCurrentColor = function (editor, format) { + var color; + editor.dom.getParents(editor.selection.getStart(), function (elm) { + var value; + if (value = elm.style[format === 'forecolor' ? 'color' : 'background-color']) { + color = color ? color : value; + } }); - } - return colors; - }; - var applyFormat = function (editor, format, value) { - editor.undoManager.transact(function () { - editor.focus(); - editor.formatter.apply(format, { value: value }); - editor.nodeChanged(); - }); - }; - var removeFormat = function (editor, format) { - editor.undoManager.transact(function () { - editor.focus(); - editor.formatter.remove(format, { value: null }, null, true); - editor.nodeChanged(); - }); - }; - var $_b0p88yrijjgwefd2 = { - getCurrentColor: getCurrentColor, - mapColors: mapColors, - applyFormat: applyFormat, - removeFormat: removeFormat - }; - - var register = function (editor) { - editor.addCommand('mceApplyTextcolor', function (format, value) { - $_b0p88yrijjgwefd2.applyFormat(editor, format, value); - }); - editor.addCommand('mceRemoveTextcolor', function (format) { - $_b0p88yrijjgwefd2.removeFormat(editor, format); - }); - }; - var $_g2o2pirhjjgwefd1 = { register: register }; - - var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var defaultColorMap = [ - '000000', - 'Black', - '993300', - 'Burnt orange', - '333300', - 'Dark olive', - '003300', - 'Dark green', - '003366', - 'Dark azure', - '000080', - 'Navy Blue', - '333399', - 'Indigo', - '333333', - 'Very dark gray', - '800000', - 'Maroon', - 'FF6600', - 'Orange', - '808000', - 'Olive', - '008000', - 'Green', - '008080', - 'Teal', - '0000FF', - 'Blue', - '666699', - 'Grayish blue', - '808080', - 'Gray', - 'FF0000', - 'Red', - 'FF9900', - 'Amber', - '99CC00', - 'Yellow green', - '339966', - 'Sea green', - '33CCCC', - 'Turquoise', - '3366FF', - 'Royal blue', - '800080', - 'Purple', - '999999', - 'Medium gray', - 'FF00FF', - 'Magenta', - 'FFCC00', - 'Gold', - 'FFFF00', - 'Yellow', - '00FF00', - 'Lime', - '00FFFF', - 'Aqua', - '00CCFF', - 'Sky blue', - '993366', - 'Red violet', - 'FFFFFF', - 'White', - 'FF99CC', - 'Pink', - 'FFCC99', - 'Peach', - 'FFFF99', - 'Light yellow', - 'CCFFCC', - 'Pale green', - 'CCFFFF', - 'Pale cyan', - '99CCFF', - 'Light sky blue', - 'CC99FF', - 'Plum' - ]; - var getTextColorMap = function (editor) { - return editor.getParam('textcolor_map', defaultColorMap); - }; - var getForeColorMap = function (editor) { - return editor.getParam('forecolor_map', getTextColorMap(editor)); - }; - var getBackColorMap = function (editor) { - return editor.getParam('backcolor_map', getTextColorMap(editor)); - }; - var getTextColorRows = function (editor) { - return editor.getParam('textcolor_rows', 5); - }; - var getTextColorCols = function (editor) { - return editor.getParam('textcolor_cols', 8); - }; - var getForeColorRows = function (editor) { - return editor.getParam('forecolor_rows', getTextColorRows(editor)); - }; - var getBackColorRows = function (editor) { - return editor.getParam('backcolor_rows', getTextColorRows(editor)); - }; - var getForeColorCols = function (editor) { - return editor.getParam('forecolor_cols', getTextColorCols(editor)); - }; - var getBackColorCols = function (editor) { - return editor.getParam('backcolor_cols', getTextColorCols(editor)); - }; - var getColorPickerCallback = function (editor) { - return editor.getParam('color_picker_callback', null); - }; - var hasColorPicker = function (editor) { - return typeof getColorPickerCallback(editor) === 'function'; - }; - var $_2rfqb7rmjjgwefd9 = { - getForeColorMap: getForeColorMap, - getBackColorMap: getBackColorMap, - getForeColorRows: getForeColorRows, - getBackColorRows: getBackColorRows, - getForeColorCols: getForeColorCols, - getBackColorCols: getBackColorCols, - getColorPickerCallback: getColorPickerCallback, - hasColorPicker: hasColorPicker - }; - - var global$3 = tinymce.util.Tools.resolve('tinymce.util.I18n'); - - var getHtml = function (cols, rows, colorMap, hasColorPicker) { - var colors, color, html, last, x, y, i, count = 0; - var id = global$1.DOM.uniqueId('mcearia'); - var getColorCellHtml = function (color, title) { - var isNoColor = color === 'transparent'; - return '' + '
' + (isNoColor ? '×' : '') + '
' + ''; + return color; }; - colors = $_b0p88yrijjgwefd2.mapColors(colorMap); - colors.push({ - text: global$3.translate('No color'), - color: 'transparent' - }); - html = ''; - last = colors.length - 1; - for (y = 0; y < rows; y++) { - html += ''; - for (x = 0; x < cols; x++) { - i = y * cols + x; - if (i > last) { - html += ''; - } else { - color = colors[i]; - html += getColorCellHtml(color.color, color.text); - } - } - html += ''; - } - if (hasColorPicker) { - html += '' + '' + ''; - html += ''; - for (x = 0; x < cols; x++) { - html += getColorCellHtml('', 'Custom color'); - } - html += ''; - } - html += '
' + '
' + '' + '
' + '
'; - return html; - }; - var $_fihh7qrnjjgwefdb = { getHtml: getHtml }; - - var setDivColor = function setDivColor(div, value) { - div.style.background = value; - div.setAttribute('data-mce-color', value); - }; - var onButtonClick = function (editor) { - return function (e) { - var ctrl = e.control; - if (ctrl._color) { - editor.execCommand('mceApplyTextcolor', ctrl.settings.format, ctrl._color); - } else { - editor.execCommand('mceRemoveTextcolor', ctrl.settings.format); + var mapColors = function (colorMap) { + var i; + var colors = []; + for (i = 0; i < colorMap.length; i += 2) { + colors.push({ + text: colorMap[i + 1], + color: '#' + colorMap[i] + }); } + return colors; }; - }; - var onPanelClick = function (editor, cols) { - return function (e) { - var buttonCtrl = this.parent(); - var value; - var currentColor = $_b0p88yrijjgwefd2.getCurrentColor(editor, buttonCtrl.settings.format); - var selectColor = function (value) { - editor.execCommand('mceApplyTextcolor', buttonCtrl.settings.format, value); - buttonCtrl.hidePanel(); - buttonCtrl.color(value); + var applyFormat = function (editor, format, value) { + editor.undoManager.transact(function () { + editor.focus(); + editor.formatter.apply(format, { value: value }); + editor.nodeChanged(); + }); + }; + var removeFormat = function (editor, format) { + editor.undoManager.transact(function () { + editor.focus(); + editor.formatter.remove(format, { value: null }, null, true); + editor.nodeChanged(); + }); + }; + var TextColor = { + getCurrentColor: getCurrentColor, + mapColors: mapColors, + applyFormat: applyFormat, + removeFormat: removeFormat + }; + + var register = function (editor) { + editor.addCommand('mceApplyTextcolor', function (format, value) { + TextColor.applyFormat(editor, format, value); + }); + editor.addCommand('mceRemoveTextcolor', function (format) { + TextColor.removeFormat(editor, format); + }); + }; + var Commands = { register: register }; + + var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + + var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var defaultColorMap = [ + '000000', + 'Black', + '993300', + 'Burnt orange', + '333300', + 'Dark olive', + '003300', + 'Dark green', + '003366', + 'Dark azure', + '000080', + 'Navy Blue', + '333399', + 'Indigo', + '333333', + 'Very dark gray', + '800000', + 'Maroon', + 'FF6600', + 'Orange', + '808000', + 'Olive', + '008000', + 'Green', + '008080', + 'Teal', + '0000FF', + 'Blue', + '666699', + 'Grayish blue', + '808080', + 'Gray', + 'FF0000', + 'Red', + 'FF9900', + 'Amber', + '99CC00', + 'Yellow green', + '339966', + 'Sea green', + '33CCCC', + 'Turquoise', + '3366FF', + 'Royal blue', + '800080', + 'Purple', + '999999', + 'Medium gray', + 'FF00FF', + 'Magenta', + 'FFCC00', + 'Gold', + 'FFFF00', + 'Yellow', + '00FF00', + 'Lime', + '00FFFF', + 'Aqua', + '00CCFF', + 'Sky blue', + '993366', + 'Red violet', + 'FFFFFF', + 'White', + 'FF99CC', + 'Pink', + 'FFCC99', + 'Peach', + 'FFFF99', + 'Light yellow', + 'CCFFCC', + 'Pale green', + 'CCFFFF', + 'Pale cyan', + '99CCFF', + 'Light sky blue', + 'CC99FF', + 'Plum' + ]; + var getTextColorMap = function (editor) { + return editor.getParam('textcolor_map', defaultColorMap); + }; + var getForeColorMap = function (editor) { + return editor.getParam('forecolor_map', getTextColorMap(editor)); + }; + var getBackColorMap = function (editor) { + return editor.getParam('backcolor_map', getTextColorMap(editor)); + }; + var getTextColorRows = function (editor) { + return editor.getParam('textcolor_rows', 5); + }; + var getTextColorCols = function (editor) { + return editor.getParam('textcolor_cols', 8); + }; + var getForeColorRows = function (editor) { + return editor.getParam('forecolor_rows', getTextColorRows(editor)); + }; + var getBackColorRows = function (editor) { + return editor.getParam('backcolor_rows', getTextColorRows(editor)); + }; + var getForeColorCols = function (editor) { + return editor.getParam('forecolor_cols', getTextColorCols(editor)); + }; + var getBackColorCols = function (editor) { + return editor.getParam('backcolor_cols', getTextColorCols(editor)); + }; + var getColorPickerCallback = function (editor) { + return editor.getParam('color_picker_callback', null); + }; + var hasColorPicker = function (editor) { + return typeof getColorPickerCallback(editor) === 'function'; + }; + var Settings = { + getForeColorMap: getForeColorMap, + getBackColorMap: getBackColorMap, + getForeColorRows: getForeColorRows, + getBackColorRows: getBackColorRows, + getForeColorCols: getForeColorCols, + getBackColorCols: getBackColorCols, + getColorPickerCallback: getColorPickerCallback, + hasColorPicker: hasColorPicker + }; + + var global$3 = tinymce.util.Tools.resolve('tinymce.util.I18n'); + + var getHtml = function (cols, rows, colorMap, hasColorPicker) { + var colors, color, html, last, x, y, i, count = 0; + var id = global$1.DOM.uniqueId('mcearia'); + var getColorCellHtml = function (color, title) { + var isNoColor = color === 'transparent'; + return '' + '
' + (isNoColor ? '×' : '') + '
' + ''; }; - var resetColor = function () { - editor.execCommand('mceRemoveTextcolor', buttonCtrl.settings.format); - buttonCtrl.hidePanel(); - buttonCtrl.resetColor(); - }; - if (global$1.DOM.getParent(e.target, '.mce-custom-color-btn')) { - buttonCtrl.hidePanel(); - var colorPickerCallback = $_2rfqb7rmjjgwefd9.getColorPickerCallback(editor); - colorPickerCallback.call(editor, function (value) { - var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0]; - var customColorCells, div, i; - customColorCells = global$2.map(tableElm.rows[tableElm.rows.length - 1].childNodes, function (elm) { - return elm.firstChild; - }); - for (i = 0; i < customColorCells.length; i++) { - div = customColorCells[i]; - if (!div.getAttribute('data-mce-color')) { - break; - } + colors = TextColor.mapColors(colorMap); + colors.push({ + text: global$3.translate('No color'), + color: 'transparent' + }); + html = ''; + last = colors.length - 1; + for (y = 0; y < rows; y++) { + html += ''; + for (x = 0; x < cols; x++) { + i = y * cols + x; + if (i > last) { + html += ''; + } else { + color = colors[i]; + html += getColorCellHtml(color.color, color.text); } - if (i === cols) { - for (i = 0; i < cols - 1; i++) { - setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color')); - } - } - setDivColor(div, value); - selectColor(value); - }, currentColor); - } - value = e.target.getAttribute('data-mce-color'); - if (value) { - if (this.lastId) { - global$1.DOM.get(this.lastId).setAttribute('aria-selected', 'false'); } - e.target.setAttribute('aria-selected', true); - this.lastId = e.target.id; - if (value === 'transparent') { - resetColor(); + html += ''; + } + if (hasColorPicker) { + html += '' + '' + ''; + html += ''; + for (x = 0; x < cols; x++) { + html += getColorCellHtml('', 'Custom color'); + } + html += ''; + } + html += '
' + '
' + '' + '
' + '
'; + return html; + }; + var ColorPickerHtml = { getHtml: getHtml }; + + var setDivColor = function setDivColor(div, value) { + div.style.background = value; + div.setAttribute('data-mce-color', value); + }; + var onButtonClick = function (editor) { + return function (e) { + var ctrl = e.control; + if (ctrl._color) { + editor.execCommand('mceApplyTextcolor', ctrl.settings.format, ctrl._color); } else { - selectColor(value); + editor.execCommand('mceRemoveTextcolor', ctrl.settings.format); } - } else if (value !== null) { - buttonCtrl.hidePanel(); - } + }; }; - }; - var renderColorPicker = function (editor, foreColor) { - return function () { - var cols = foreColor ? $_2rfqb7rmjjgwefd9.getForeColorCols(editor) : $_2rfqb7rmjjgwefd9.getBackColorCols(editor); - var rows = foreColor ? $_2rfqb7rmjjgwefd9.getForeColorRows(editor) : $_2rfqb7rmjjgwefd9.getBackColorRows(editor); - var colorMap = foreColor ? $_2rfqb7rmjjgwefd9.getForeColorMap(editor) : $_2rfqb7rmjjgwefd9.getBackColorMap(editor); - var hasColorPicker = $_2rfqb7rmjjgwefd9.hasColorPicker(editor); - return $_fihh7qrnjjgwefdb.getHtml(cols, rows, colorMap, hasColorPicker); + var onPanelClick = function (editor, cols) { + return function (e) { + var buttonCtrl = this.parent(); + var value; + var currentColor = TextColor.getCurrentColor(editor, buttonCtrl.settings.format); + var selectColor = function (value) { + editor.execCommand('mceApplyTextcolor', buttonCtrl.settings.format, value); + buttonCtrl.hidePanel(); + buttonCtrl.color(value); + }; + var resetColor = function () { + editor.execCommand('mceRemoveTextcolor', buttonCtrl.settings.format); + buttonCtrl.hidePanel(); + buttonCtrl.resetColor(); + }; + if (global$1.DOM.getParent(e.target, '.mce-custom-color-btn')) { + buttonCtrl.hidePanel(); + var colorPickerCallback = Settings.getColorPickerCallback(editor); + colorPickerCallback.call(editor, function (value) { + var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0]; + var customColorCells, div, i; + customColorCells = global$2.map(tableElm.rows[tableElm.rows.length - 1].childNodes, function (elm) { + return elm.firstChild; + }); + for (i = 0; i < customColorCells.length; i++) { + div = customColorCells[i]; + if (!div.getAttribute('data-mce-color')) { + break; + } + } + if (i === cols) { + for (i = 0; i < cols - 1; i++) { + setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color')); + } + } + setDivColor(div, value); + selectColor(value); + }, currentColor); + } + value = e.target.getAttribute('data-mce-color'); + if (value) { + if (this.lastId) { + global$1.DOM.get(this.lastId).setAttribute('aria-selected', 'false'); + } + e.target.setAttribute('aria-selected', true); + this.lastId = e.target.id; + if (value === 'transparent') { + resetColor(); + } else { + selectColor(value); + } + } else if (value !== null) { + buttonCtrl.hidePanel(); + } + }; }; - }; - var register$1 = function (editor) { - editor.addButton('forecolor', { - type: 'colorbutton', - tooltip: 'Text color', - format: 'forecolor', - panel: { - role: 'application', - ariaRemember: true, - html: renderColorPicker(editor, true), - onclick: onPanelClick(editor, $_2rfqb7rmjjgwefd9.getForeColorCols(editor)) - }, - onclick: onButtonClick(editor) - }); - editor.addButton('backcolor', { - type: 'colorbutton', - tooltip: 'Background color', - format: 'hilitecolor', - panel: { - role: 'application', - ariaRemember: true, - html: renderColorPicker(editor, false), - onclick: onPanelClick(editor, $_2rfqb7rmjjgwefd9.getBackColorCols(editor)) - }, - onclick: onButtonClick(editor) - }); - }; - var $_8npvswrjjjgwefd5 = { register: register$1 }; + var renderColorPicker = function (editor, foreColor) { + return function () { + var cols = foreColor ? Settings.getForeColorCols(editor) : Settings.getBackColorCols(editor); + var rows = foreColor ? Settings.getForeColorRows(editor) : Settings.getBackColorRows(editor); + var colorMap = foreColor ? Settings.getForeColorMap(editor) : Settings.getBackColorMap(editor); + var hasColorPicker = Settings.hasColorPicker(editor); + return ColorPickerHtml.getHtml(cols, rows, colorMap, hasColorPicker); + }; + }; + var register$1 = function (editor) { + editor.addButton('forecolor', { + type: 'colorbutton', + tooltip: 'Text color', + format: 'forecolor', + panel: { + role: 'application', + ariaRemember: true, + html: renderColorPicker(editor, true), + onclick: onPanelClick(editor, Settings.getForeColorCols(editor)) + }, + onclick: onButtonClick(editor) + }); + editor.addButton('backcolor', { + type: 'colorbutton', + tooltip: 'Background color', + format: 'hilitecolor', + panel: { + role: 'application', + ariaRemember: true, + html: renderColorPicker(editor, false), + onclick: onPanelClick(editor, Settings.getBackColorCols(editor)) + }, + onclick: onButtonClick(editor) + }); + }; + var Buttons = { register: register$1 }; - global.add('textcolor', function (editor) { - $_g2o2pirhjjgwefd1.register(editor); - $_8npvswrjjjgwefd5.register(editor); - }); - function Plugin () { - } + global.add('textcolor', function (editor) { + Commands.register(editor); + Buttons.register(editor); + }); + function Plugin () { + } - return Plugin; + return Plugin; }()); })(); diff --git a/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js b/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js index 4e4a06b763..f0996f152b 100644 --- a/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=function(t,o){var r;return t.dom.getParents(t.selection.getStart(),function(t){var e;(e=t.style["forecolor"===o?"color":"background-color"])&&(r=e)}),r},g=function(t){var e,o=[];for(e=0;e
'+(o?"×":"")+"
"};for((n=g(o)).push({text:h.translate("No color"),color:"transparent"}),l='',c=n.length-1,u=0;u",i=0;i":f((a=n[m]).color,a.text);l+=""}if(r){for(l+='",l+="",i=0;i
'+(o?"×":"")+"
"};for((n=g(o)).push({text:h.translate("No color"),color:"transparent"}),l='
',c=n.length-1,u=0;u",i=0;i":f((a=n[m]).color,a.text);l+=""}if(r){for(l+='",l+="",i=0;i + diff --git a/wp-includes/js/tinymce/skins/lightgray/skin.min.css b/wp-includes/js/tinymce/skins/lightgray/skin.min.css index c734b7d421..f2e1ccc305 100644 --- a/wp-includes/js/tinymce/skins/lightgray/skin.min.css +++ b/wp-includes/js/tinymce/skins/lightgray/skin.min.css @@ -1 +1 @@ -.mce-container,.mce-container *,.mce-widget,.mce-widget *,.mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:#595959;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;-webkit-tap-highlight-color:transparent;line-height:normal;font-weight:normal;text-align:left;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-widget button{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.mce-container *[unselectable]{-moz-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none}.word-wrap{word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.mce-fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.mce-fade.mce-in{opacity:1}.mce-tinymce{visibility:inherit !important;position:relative}.mce-fullscreen{border:0;padding:0;margin:0;overflow:hidden;height:100%;z-index:100}div.mce-fullscreen{position:fixed;top:0;left:0;width:100%;height:auto}.mce-tinymce{display:block;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2)}.mce-statusbar>.mce-container-body{display:flex;padding-right:16px}.mce-statusbar>.mce-container-body .mce-path{flex:1}.mce-wordcount{font-size:inherit;text-transform:uppercase;padding:8px 0}div.mce-edit-area{background:#FFF;filter:none}.mce-statusbar{position:relative}.mce-statusbar .mce-container-body{position:relative;font-size:11px}.mce-fullscreen .mce-resizehandle{display:none}.mce-statusbar .mce-flow-layout-item{margin:0}.mce-charmap{border-collapse:collapse}.mce-charmap td{cursor:default;border:1px solid #c5c5c5;width:20px;height:20px;line-height:20px;text-align:center;vertical-align:middle;padding:2px}.mce-charmap td div{text-align:center}.mce-charmap td:hover{background:white}.mce-grid td.mce-grid-cell div{border:1px solid #c5c5c5;width:15px;height:15px;margin:0;cursor:pointer}.mce-grid td.mce-grid-cell div:focus{border-color:#91bbe9}.mce-grid td.mce-grid-cell div[disabled]{cursor:not-allowed}.mce-grid{border-spacing:2px;border-collapse:separate}.mce-grid a{display:block;border:1px solid transparent}.mce-grid a:hover,.mce-grid a:focus{border-color:#91bbe9}.mce-grid-border{margin:0 4px 0 4px}.mce-grid-border a{border-color:#c5c5c5;width:13px;height:13px}.mce-grid-border a:hover,.mce-grid-border a.mce-active{border-color:#91bbe9;background:#bdd6f2}.mce-text-center{text-align:center}div.mce-tinymce-inline{width:100%}.mce-colorbtn-trans div{text-align:center;vertical-align:middle;font-weight:bold;font-size:20px;line-height:16px;color:#8b8b8b}.mce-monospace{font-family:"Courier New",Courier,monospace}.mce-toolbar-grp .mce-flow-layout-item{margin-bottom:0}.mce-container b{font-weight:bold}.mce-container p{margin-bottom:5px}.mce-container a{cursor:pointer;color:#2276d2}.mce-container a:hover{text-decoration:underline}.mce-container ul{margin-left:15px}.mce-container .mce-table-striped{border-collapse:collapse;margin:10px}.mce-container .mce-table-striped thead>tr{background-color:#fafafa}.mce-container .mce-table-striped thead>tr th{font-weight:bold}.mce-container .mce-table-striped td,.mce-container .mce-table-striped th{padding:5px}.mce-container .mce-table-striped tr:nth-child(even){background-color:#fafafa}.mce-container .mce-table-striped tbody>tr:hover{background-color:#e1e1e1}.mce-branding{font-size:inherit;text-transform:uppercase;white-space:pre;padding:8px 0}.mce-branding a{font-size:inherit;color:inherit}.mce-top-part{position:relative}.mce-top-part::before{content:'';position:absolute;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);top:0;right:0;bottom:0;left:0;pointer-events:none}.mce-rtl .mce-wordcount{left:0;right:auto}.mce-rtl .mce-statusbar>.mce-container-body>*:last-child{padding-right:0;padding-left:10px}.mce-rtl .mce-path{text-align:right;padding-right:16px}.mce-croprect-container{position:absolute;top:0;left:0}.mce-croprect-handle{position:absolute;top:0;left:0;width:20px;height:20px;border:2px solid white}.mce-croprect-handle-nw{border-width:2px 0 0 2px;margin:-2px 0 0 -2px;cursor:nw-resize;top:100px;left:100px}.mce-croprect-handle-ne{border-width:2px 2px 0 0;margin:-2px 0 0 -20px;cursor:ne-resize;top:100px;left:200px}.mce-croprect-handle-sw{border-width:0 0 2px 2px;margin:-20px 2px 0 -2px;cursor:sw-resize;top:200px;left:100px}.mce-croprect-handle-se{border-width:0 2px 2px 0;margin:-20px 0 0 -20px;cursor:se-resize;top:200px;left:200px}.mce-croprect-handle-move{position:absolute;cursor:move;border:0}.mce-croprect-block{opacity:.5;filter:alpha(opacity=50);zoom:1;position:absolute;background:black}.mce-croprect-handle:focus{border-color:#2276d2}.mce-croprect-handle-move:focus{outline:1px solid #2276d2}.mce-imagepanel{overflow:auto;background:black}.mce-imagepanel-bg{position:absolute;background:url('data:image/gif;base64,R0lGODdhDAAMAIABAMzMzP///ywAAAAADAAMAAACFoQfqYeabNyDMkBQb81Uat85nxguUAEAOw==')}.mce-imagepanel img{position:absolute}.mce-imagetool.mce-btn .mce-ico{display:block;width:20px;height:20px;text-align:center;line-height:20px;font-size:20px;padding:5px}.mce-arrow-up{margin-top:12px}.mce-arrow-down{margin-top:-12px}.mce-arrow:before,.mce-arrow:after{position:absolute;left:50%;display:block;width:0;height:0;border-style:solid;border-color:transparent;content:""}.mce-arrow.mce-arrow-up:before{top:-9px;border-bottom-color:#c5c5c5;border-width:0 9px 9px;margin-left:-9px}.mce-arrow.mce-arrow-down:before{bottom:-9px;border-top-color:#c5c5c5;border-width:9px 9px 0;margin-left:-9px}.mce-arrow.mce-arrow-up:after{top:-8px;border-bottom-color:#fff;border-width:0 8px 8px;margin-left:-8px}.mce-arrow.mce-arrow-down:after{bottom:-8px;border-top-color:#fff;border-width:8px 8px 0;margin-left:-8px}.mce-arrow.mce-arrow-left:before,.mce-arrow.mce-arrow-left:after{margin:0}.mce-arrow.mce-arrow-left:before{left:8px}.mce-arrow.mce-arrow-left:after{left:9px}.mce-arrow.mce-arrow-right:before,.mce-arrow.mce-arrow-right:after{left:auto;margin:0}.mce-arrow.mce-arrow-right:before{right:8px}.mce-arrow.mce-arrow-right:after{right:9px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-left:before{left:-9px;top:50%;border-right-color:#c5c5c5;border-width:9px 9px 9px 0;margin-top:-9px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-left:after{left:-8px;top:50%;border-right-color:#fff;border-width:8px 8px 8px 0;margin-top:-8px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-left{margin-left:12px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-right:before{right:-9px;top:50%;border-left-color:#c5c5c5;border-width:9px 0 9px 9px;margin-top:-9px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-right:after{right:-8px;top:50%;border-left-color:#fff;border-width:8px 0 8px 8px;margin-top:-8px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-right{margin-left:-14px}.mce-edit-aria-container>.mce-container-body{display:flex}.mce-edit-aria-container>.mce-container-body .mce-edit-area{flex:1}.mce-edit-aria-container>.mce-container-body .mce-sidebar>.mce-container-body{display:flex;align-items:stretch;height:100%}.mce-edit-aria-container>.mce-container-body .mce-sidebar-panel{min-width:250px;max-width:250px;position:relative}.mce-edit-aria-container>.mce-container-body .mce-sidebar-panel>.mce-container-body{position:absolute;width:100%;height:100%;overflow:auto;top:0;left:0}.mce-sidebar-toolbar{border:0 solid #c5c5c5;border-left-width:1px}.mce-sidebar-toolbar .mce-btn{border-left:0;border-right:0}.mce-sidebar-toolbar .mce-btn.mce-active,.mce-sidebar-toolbar .mce-btn.mce-active:hover{background-color:#555c66}.mce-sidebar-toolbar .mce-btn.mce-active button,.mce-sidebar-toolbar .mce-btn.mce-active:hover button,.mce-sidebar-toolbar .mce-btn.mce-active button i,.mce-sidebar-toolbar .mce-btn.mce-active:hover button i{color:white;text-shadow:1px 1px none}.mce-sidebar-panel{border:0 solid #c5c5c5;border-left-width:1px}.mce-container,.mce-container-body{display:block}.mce-autoscroll{overflow:hidden}.mce-scrollbar{position:absolute;width:7px;height:100%;top:2px;right:2px;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-scrollbar-h{top:auto;right:auto;left:2px;bottom:2px;width:100%;height:7px}.mce-scrollbar-thumb{position:absolute;background-color:#000;border:1px solid #888;border-color:rgba(85,85,85,0.6);width:5px;height:100%}.mce-scrollbar-h .mce-scrollbar-thumb{width:100%;height:5px}.mce-scrollbar:hover,.mce-scrollbar.mce-active{background-color:#AAA;opacity:.6;filter:alpha(opacity=60);zoom:1}.mce-scroll{position:relative}.mce-panel{border:0 solid #f3f3f3;border:0 solid #c5c5c5;background-color:#fff}.mce-floatpanel{position:absolute;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2)}.mce-floatpanel.mce-fixed{position:fixed}.mce-floatpanel .mce-arrow,.mce-floatpanel .mce-arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.mce-floatpanel .mce-arrow{border-width:11px}.mce-floatpanel .mce-arrow:after{border-width:10px;content:""}.mce-floatpanel.mce-popover{filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);background:transparent;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);top:0;left:0;background:#FFF;border:1px solid #c5c5c5;border:1px solid rgba(0,0,0,0.25)}.mce-floatpanel.mce-popover.mce-bottom{margin-top:10px;*margin-top:0}.mce-floatpanel.mce-popover.mce-bottom>.mce-arrow{left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#c5c5c5;border-bottom-color:rgba(0,0,0,0.25);top:-11px}.mce-floatpanel.mce-popover.mce-bottom>.mce-arrow:after{top:1px;margin-left:-10px;border-top-width:0;border-bottom-color:#FFF}.mce-floatpanel.mce-popover.mce-top{margin-top:-10px;*margin-top:0}.mce-floatpanel.mce-popover.mce-top>.mce-arrow{left:50%;margin-left:-11px;border-bottom-width:0;border-top-color:#c5c5c5;top:auto;bottom:-11px}.mce-floatpanel.mce-popover.mce-top>.mce-arrow:after{bottom:1px;margin-left:-10px;border-bottom-width:0;border-top-color:#FFF}.mce-floatpanel.mce-popover.mce-bottom.mce-start,.mce-floatpanel.mce-popover.mce-top.mce-start{margin-left:-22px}.mce-floatpanel.mce-popover.mce-bottom.mce-start>.mce-arrow,.mce-floatpanel.mce-popover.mce-top.mce-start>.mce-arrow{left:20px}.mce-floatpanel.mce-popover.mce-bottom.mce-end,.mce-floatpanel.mce-popover.mce-top.mce-end{margin-left:22px}.mce-floatpanel.mce-popover.mce-bottom.mce-end>.mce-arrow,.mce-floatpanel.mce-popover.mce-top.mce-end>.mce-arrow{right:10px;left:auto}.mce-fullscreen{border:0;padding:0;margin:0;overflow:hidden;height:100%}div.mce-fullscreen{position:fixed;top:0;left:0}#mce-modal-block{opacity:0;filter:alpha(opacity=0);zoom:1;position:fixed;left:0;top:0;width:100%;height:100%;background:#FFF}#mce-modal-block.mce-in{opacity:.5;filter:alpha(opacity=50);zoom:1}.mce-window-move{cursor:move}.mce-window{-webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);background:transparent;background:#FFF;position:fixed;top:0;left:0;opacity:0;transform:scale(.1);transition:transform 100ms ease-in,opacity 150ms ease-in}.mce-window.mce-in{transform:scale(1);opacity:1}.mce-window-head{padding:9px 15px;border-bottom:1px solid #c5c5c5;position:relative}.mce-window-head .mce-close{position:absolute;right:0;top:0;height:38px;width:38px;text-align:center;cursor:pointer}.mce-window-head .mce-close i{color:#9b9b9b}.mce-close:hover i{color:#bdbdbd}.mce-window-head .mce-title{line-height:20px;font-size:20px;font-weight:bold;text-rendering:optimizelegibility;padding-right:20px}.mce-window .mce-container-body{display:block}.mce-foot{display:block;background-color:#FFF;border-top:1px solid #c5c5c5}.mce-window-head .mce-dragh{position:absolute;top:0;left:0;cursor:move;width:90%;height:100%}.mce-window iframe{width:100%;height:100%}.mce-window-body .mce-listbox{border-color:#e2e4e7}.mce-window .mce-btn:hover{border-color:#c5c5c5}.mce-window .mce-btn:focus{border-color:#2276d2}.mce-window-body .mce-btn,.mce-foot .mce-btn{border-color:#c5c5c5}.mce-foot .mce-btn.mce-primary{border-color:transparent}.mce-rtl .mce-window-head .mce-close{position:absolute;right:auto;left:0}.mce-rtl .mce-window-head .mce-dragh{left:auto;right:0}.mce-rtl .mce-window-head .mce-title{direction:rtl;text-align:right;padding-right:0;padding-left:20px}.mce-tooltip{position:absolute;padding:5px;opacity:.8;filter:alpha(opacity=80);zoom:1;margin-top:1px}.mce-tooltip-inner{font-size:11px;background-color:#000;color:white;max-width:200px;padding:5px 8px 4px 8px;text-align:center;white-space:normal}.mce-tooltip-inner{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-tooltip-arrow{position:absolute;width:0;height:0;line-height:0;border:5px dashed #000}.mce-tooltip-arrow-n{border-bottom-color:#000}.mce-tooltip-arrow-s{border-top-color:#000}.mce-tooltip-arrow-e{border-left-color:#000}.mce-tooltip-arrow-w{border-right-color:#000}.mce-tooltip-nw,.mce-tooltip-sw{margin-left:-14px}.mce-tooltip-ne,.mce-tooltip-se{margin-left:14px}.mce-tooltip-n .mce-tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-style:solid;border-top:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-nw .mce-tooltip-arrow{top:0;left:10px;border-bottom-style:solid;border-top:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-ne .mce-tooltip-arrow{top:0;right:10px;border-bottom-style:solid;border-top:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-s .mce-tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-style:solid;border-bottom:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-sw .mce-tooltip-arrow{bottom:0;left:10px;border-top-style:solid;border-bottom:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-se .mce-tooltip-arrow{bottom:0;right:10px;border-top-style:solid;border-bottom:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-e .mce-tooltip-arrow{right:0;top:50%;margin-top:-5px;border-left-style:solid;border-right:none;border-top-color:transparent;border-bottom-color:transparent}.mce-tooltip-w .mce-tooltip-arrow{left:0;top:50%;margin-top:-5px;border-right-style:solid;border-left:none;border-top-color:transparent;border-bottom-color:transparent}.mce-progress{display:inline-block;position:relative;height:20px}.mce-progress .mce-bar-container{display:inline-block;width:100px;height:100%;margin-right:8px;border:1px solid #ccc;overflow:hidden}.mce-progress .mce-text{display:inline-block;margin-top:auto;margin-bottom:auto;font-size:14px;width:40px;color:#595959}.mce-bar{display:block;width:0;height:100%;background-color:#dfdfdf;-webkit-transition:width .2s ease;transition:width .2s ease}.mce-notification{position:absolute;background-color:#fff;padding:5px;margin-top:5px;border-width:1px;border-style:solid;border-color:#c5c5c5;transition:transform 100ms ease-in,opacity 150ms ease-in;opacity:0;box-sizing:border-box}.mce-notification.mce-in{opacity:1}.mce-notification-success{background-color:#dff0d8;border-color:#d6e9c6}.mce-notification-info{background-color:#d9edf7;border-color:#779ECB}.mce-notification-warning{background-color:#fcf8e3;border-color:#faebcc}.mce-notification-error{background-color:#f2dede;border-color:#ebccd1}.mce-notification.mce-has-close{padding-right:15px}.mce-notification .mce-ico{margin-top:5px}.mce-notification-inner{word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;display:inline-block;font-size:14px;margin:5px 8px 4px 8px;text-align:center;white-space:normal;color:#31708f}.mce-notification-inner a{text-decoration:underline;cursor:pointer}.mce-notification .mce-progress{margin-right:8px}.mce-notification .mce-progress .mce-text{margin-top:5px}.mce-notification *,.mce-notification .mce-progress .mce-text{color:#595959}.mce-notification .mce-progress .mce-bar-container{border-color:#c5c5c5}.mce-notification .mce-progress .mce-bar-container .mce-bar{background-color:#595959}.mce-notification-success *,.mce-notification-success .mce-progress .mce-text{color:#3c763d}.mce-notification-success .mce-progress .mce-bar-container{border-color:#d6e9c6}.mce-notification-success .mce-progress .mce-bar-container .mce-bar{background-color:#3c763d}.mce-notification-info *,.mce-notification-info .mce-progress .mce-text{color:#31708f}.mce-notification-info .mce-progress .mce-bar-container{border-color:#779ECB}.mce-notification-info .mce-progress .mce-bar-container .mce-bar{background-color:#31708f}.mce-notification-warning *,.mce-notification-warning .mce-progress .mce-text{color:#8a6d3b}.mce-notification-warning .mce-progress .mce-bar-container{border-color:#faebcc}.mce-notification-warning .mce-progress .mce-bar-container .mce-bar{background-color:#8a6d3b}.mce-notification-error *,.mce-notification-error .mce-progress .mce-text{color:#a94442}.mce-notification-error .mce-progress .mce-bar-container{border-color:#ebccd1}.mce-notification-error .mce-progress .mce-bar-container .mce-bar{background-color:#a94442}.mce-notification .mce-close{position:absolute;top:6px;right:8px;font-size:20px;font-weight:bold;line-height:20px;color:#9b9b9b;cursor:pointer}.mce-abs-layout{position:relative}html .mce-abs-layout-item,.mce-abs-end{position:absolute}.mce-abs-end{width:1px;height:1px}.mce-container-body.mce-abs-layout{overflow:hidden}.mce-btn{border:1px solid #b3b3b3;border-color:transparent transparent transparent transparent;position:relative;text-shadow:0 1px 1px rgba(255,255,255,0.75);background:white;display:inline-block;*display:inline;*zoom:1;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-btn:hover,.mce-btn:active{background:white;color:#595959;border-color:#e2e4e7}.mce-btn:focus{background:white;color:#595959;border-color:#e2e4e7}.mce-btn.mce-disabled button,.mce-btn.mce-disabled:hover button{cursor:default;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-btn.mce-active,.mce-btn.mce-active:hover,.mce-btn.mce-active:focus,.mce-btn.mce-active:active{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;background:#555c66;color:white;border-color:transparent}.mce-btn.mce-active button,.mce-btn.mce-active:hover button,.mce-btn.mce-active i,.mce-btn.mce-active:hover i{color:white}.mce-btn:hover .mce-caret{border-top-color:#b5bcc2}.mce-btn.mce-active .mce-caret,.mce-btn.mce-active:hover .mce-caret{border-top-color:white}.mce-btn button{padding:4px 6px;font-size:14px;line-height:20px;*line-height:16px;cursor:pointer;color:#595959;text-align:center;overflow:visible;-webkit-appearance:none}.mce-btn button::-moz-focus-inner{border:0;padding:0}.mce-btn i{text-shadow:1px 1px none}.mce-primary.mce-btn-has-text{min-width:50px}.mce-primary{color:white;border:1px solid transparent;border-color:transparent;background-color:#2276d2}.mce-primary:hover,.mce-primary:focus{background-color:#1e6abc;border-color:transparent}.mce-primary.mce-disabled button,.mce-primary.mce-disabled:hover button{cursor:default;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-primary.mce-active,.mce-primary.mce-active:hover,.mce-primary:not(.mce-disabled):active{background-color:#1e6abc;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-primary button,.mce-primary button i{color:white;text-shadow:1px 1px none}.mce-btn .mce-txt{font-size:inherit;line-height:inherit;color:inherit}.mce-btn-large button{padding:9px 14px;font-size:16px;line-height:normal}.mce-btn-large i{margin-top:2px}.mce-btn-small button{padding:1px 5px;font-size:12px;*padding-bottom:2px}.mce-btn-small i{line-height:20px;vertical-align:top;*line-height:18px}.mce-btn .mce-caret{margin-top:8px;margin-left:0}.mce-btn-small .mce-caret{margin-top:8px;margin-left:0}.mce-caret{display:inline-block;*display:inline;*zoom:1;width:0;height:0;vertical-align:top;border-top:4px solid #b5bcc2;border-right:4px solid transparent;border-left:4px solid transparent;content:""}.mce-disabled .mce-caret{border-top-color:#aaa}.mce-caret.mce-up{border-bottom:4px solid #b5bcc2;border-top:0}.mce-btn-flat{border:0;background:transparent;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;filter:none}.mce-btn-flat:hover,.mce-btn-flat.mce-active,.mce-btn-flat:focus,.mce-btn-flat:active{border:0;background:#e6e6e6;filter:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-btn-has-text .mce-ico{padding-right:5px}.mce-rtl .mce-btn button{direction:rtl}.mce-toolbar .mce-btn-group{margin:0;padding:2px 0}.mce-btn-group .mce-btn{border-width:1px;margin:0;margin-left:2px}.mce-btn-group:not(:first-child){border-left:1px solid #d9d9d9;padding-left:0;margin-left:2px}.mce-btn-group{margin-left:2px}.mce-btn-group .mce-btn.mce-flow-layout-item{margin:0}.mce-rtl .mce-btn-group .mce-btn{margin-left:0;margin-right:2px}.mce-rtl .mce-btn-group .mce-first{margin-right:0}.mce-rtl .mce-btn-group:not(:first-child){border-left:none;border-right:1px solid #d9d9d9;padding-right:4px;margin-right:4px}.mce-checkbox{cursor:pointer}i.mce-i-checkbox{margin:0 3px 0 0;border:1px solid #c5c5c5;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;background-color:white;text-indent:-10em;overflow:hidden}.mce-checked i.mce-i-checkbox{color:#595959;font-size:16px;line-height:16px;text-indent:0}.mce-checkbox:focus i.mce-i-checkbox,.mce-checkbox.mce-focus i.mce-i-checkbox{border:1px solid #2276d2;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-checkbox.mce-disabled .mce-label,.mce-checkbox.mce-disabled i.mce-i-checkbox{color:#bdbdbd}.mce-checkbox .mce-label{vertical-align:middle}.mce-rtl .mce-checkbox{direction:rtl;text-align:right}.mce-rtl i.mce-i-checkbox{margin:0 0 0 3px}.mce-combobox{position:relative;display:inline-block;*display:inline;*zoom:1;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;*height:32px}.mce-combobox input{border:1px solid #c5c5c5;border-right-color:#c5c5c5;height:28px}.mce-combobox.mce-disabled input{color:#bdbdbd}.mce-combobox .mce-btn{border:1px solid #c5c5c5;border-left:0;margin:0}.mce-combobox button{padding-right:8px;padding-left:8px}.mce-combobox.mce-disabled .mce-btn button{cursor:default;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-combobox .mce-status{position:absolute;right:2px;top:50%;line-height:16px;margin-top:-8px;font-size:12px;width:15px;height:15px;text-align:center;cursor:pointer}.mce-combobox.mce-has-status input{padding-right:20px}.mce-combobox.mce-has-open .mce-status{right:37px}.mce-combobox .mce-status.mce-i-warning{color:#c09853}.mce-combobox .mce-status.mce-i-checkmark{color:#468847}.mce-menu.mce-combobox-menu{border-top:0;margin-top:0;max-height:200px}.mce-menu.mce-combobox-menu .mce-menu-item{padding:4px 6px 4px 4px;font-size:11px}.mce-menu.mce-combobox-menu .mce-menu-item-sep{padding:0}.mce-menu.mce-combobox-menu .mce-text,.mce-menu.mce-combobox-menu .mce-text b{font-size:11px}.mce-menu.mce-combobox-menu .mce-menu-item-link,.mce-menu.mce-combobox-menu .mce-menu-item-link b{font-size:11px}.mce-colorbox i{border:1px solid #c5c5c5;width:14px;height:14px}.mce-colorbutton .mce-ico{position:relative}.mce-colorbutton-grid{margin:4px}.mce-colorbutton .mce-preview{padding-right:3px;display:block;position:absolute;left:50%;top:50%;margin-left:-17px;margin-top:7px;background:gray;width:13px;height:2px;overflow:hidden}.mce-colorbutton.mce-btn-small .mce-preview{margin-left:-16px;padding-right:0;width:16px}.mce-rtl .mce-colorbutton{direction:rtl}.mce-rtl .mce-colorbutton .mce-preview{margin-left:0;padding-right:0;padding-left:3px}.mce-rtl .mce-colorbutton.mce-btn-small .mce-preview{margin-left:0;padding-right:0;padding-left:2px}.mce-rtl .mce-colorbutton .mce-open{padding-left:4px;padding-right:4px;border-left:0}.mce-colorpicker{position:relative;width:250px;height:220px}.mce-colorpicker-sv{position:absolute;top:0;left:0;width:90%;height:100%;border:1px solid #c5c5c5;cursor:crosshair;overflow:hidden}.mce-colorpicker-h-chunk{width:100%}.mce-colorpicker-overlay1,.mce-colorpicker-overlay2{width:100%;height:100%;position:absolute;top:0;left:0}.mce-colorpicker-overlay1{filter:progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr='#ffffff', endColorstr='#00ffffff');-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=1,startColorstr='#ffffff', endColorstr='#00ffffff')";background:linear-gradient(to right, #fff, rgba(255,255,255,0))}.mce-colorpicker-overlay2{filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#00000000', endColorstr='#000000');-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00000000', endColorstr='#000000')";background:linear-gradient(to bottom, rgba(0,0,0,0), #000)}.mce-colorpicker-selector1{background:none;position:absolute;width:12px;height:12px;margin:-8px 0 0 -8px;border:1px solid black;border-radius:50%}.mce-colorpicker-selector2{position:absolute;width:10px;height:10px;border:1px solid white;border-radius:50%}.mce-colorpicker-h{position:absolute;top:0;right:0;width:6.5%;height:100%;border:1px solid #c5c5c5;cursor:crosshair}.mce-colorpicker-h-marker{margin-top:-4px;position:absolute;top:0;left:-1px;width:100%;border:1px solid black;background:white;height:4px;z-index:100}.mce-path{display:inline-block;*display:inline;*zoom:1;padding:8px;white-space:normal;font-size:inherit}.mce-path .mce-txt{display:inline-block;padding-right:3px}.mce-path .mce-path-body{display:inline-block}.mce-path-item{display:inline-block;*display:inline;*zoom:1;cursor:pointer;color:#595959;font-size:inherit;text-transform:uppercase}.mce-path-item:hover{text-decoration:underline}.mce-path-item:focus{background:#555c66;color:white}.mce-path .mce-divider{display:inline;font-size:inherit}.mce-disabled .mce-path-item{color:#aaa}.mce-rtl .mce-path{direction:rtl}.mce-fieldset{border:0 solid #9E9E9E}.mce-fieldset>.mce-container-body{margin-top:-15px}.mce-fieldset-title{margin-left:5px;padding:0 5px 0 5px}.mce-fit-layout{display:inline-block;*display:inline;*zoom:1}.mce-fit-layout-item{position:absolute}.mce-flow-layout-item{display:inline-block;*display:inline;*zoom:1}.mce-flow-layout-item{margin:2px 0 2px 2px}.mce-flow-layout-item.mce-last{margin-right:2px}.mce-flow-layout{white-space:normal}.mce-tinymce-inline .mce-flow-layout{white-space:nowrap}.mce-rtl .mce-flow-layout{text-align:right;direction:rtl}.mce-rtl .mce-flow-layout-item{margin:2px 2px 2px 0}.mce-rtl .mce-flow-layout-item.mce-last{margin-left:2px}.mce-iframe{border:0 solid #c5c5c5;width:100%;height:100%}.mce-infobox{display:inline-block;*display:inline;*zoom:1;text-shadow:0 1px 1px rgba(255,255,255,0.75);overflow:hidden;border:1px solid red}.mce-infobox div{display:block;margin:5px}.mce-infobox div button{position:absolute;top:50%;right:4px;cursor:pointer;margin-top:-8px;display:none}.mce-infobox div button:focus{outline:2px solid #e2e4e7}.mce-infobox.mce-has-help div{margin-right:25px}.mce-infobox.mce-has-help button{display:block}.mce-infobox.mce-success{background:#dff0d8;border-color:#d6e9c6}.mce-infobox.mce-success div{color:#3c763d}.mce-infobox.mce-warning{background:#fcf8e3;border-color:#faebcc}.mce-infobox.mce-warning div{color:#8a6d3b}.mce-infobox.mce-error{background:#f2dede;border-color:#ebccd1}.mce-infobox.mce-error div{color:#a94442}.mce-rtl .mce-infobox div{text-align:right;direction:rtl}.mce-label{display:inline-block;*display:inline;*zoom:1;text-shadow:0 1px 1px rgba(255,255,255,0.75);overflow:hidden}.mce-label.mce-autoscroll{overflow:auto}.mce-label.mce-disabled{color:#aaa}.mce-label.mce-multiline{white-space:pre-wrap}.mce-label.mce-success{color:#468847}.mce-label.mce-warning{color:#c09853}.mce-label.mce-error{color:#b94a48}.mce-rtl .mce-label{text-align:right;direction:rtl}.mce-menubar{border:1px solid #e2e4e7}.mce-menubar .mce-menubtn{border-color:transparent;background:transparent;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;filter:none}.mce-menubar .mce-menubtn button span{color:#595959}.mce-menubar .mce-caret{border-top-color:#b5bcc2}.mce-menubar .mce-active .mce-caret,.mce-menubar .mce-menubtn:hover .mce-caret{border-top-color:#b5bcc2}.mce-menubar .mce-menubtn:hover,.mce-menubar .mce-menubtn.mce-active,.mce-menubar .mce-menubtn:focus{border-color:#e2e4e7;background:white;filter:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-menubar .mce-menubtn.mce-active{border-bottom:none;z-index:65537}div.mce-menubtn.mce-opened{border-bottom-color:white;z-index:65537}.mce-menubtn button{color:#595959}.mce-menubtn.mce-btn-small span{font-size:12px}.mce-menubtn.mce-fixed-width span{display:inline-block;overflow-x:hidden;text-overflow:ellipsis;width:90px}.mce-menubtn.mce-fixed-width.mce-btn-small span{width:70px}.mce-menubtn .mce-caret{*margin-top:6px}.mce-rtl .mce-menubtn button{direction:rtl;text-align:right}.mce-rtl .mce-menubtn.mce-fixed-width span{direction:rtl;text-align:right}.mce-menu-item{display:block;padding:6px 4px 6px 4px;clear:both;font-weight:normal;line-height:20px;color:#595959;white-space:nowrap;cursor:pointer;line-height:normal;border-left:4px solid transparent;margin-bottom:1px}.mce-menu-item .mce-text,.mce-menu-item .mce-text b{line-height:1;vertical-align:initial}.mce-menu-item .mce-caret{margin-top:4px;margin-right:6px;border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:4px solid #595959}.mce-menu-item .mce-menu-shortcut{display:inline-block;padding:0 10px 0 20px;color:#aaa}.mce-menu-item .mce-ico{padding-right:4px}.mce-menu-item:hover,.mce-menu-item:focus{background:#ededee}.mce-menu-item:hover .mce-menu-shortcut,.mce-menu-item:focus .mce-menu-shortcut{color:#aaa}.mce-menu-item:hover .mce-text,.mce-menu-item:focus .mce-text,.mce-menu-item:hover .mce-ico,.mce-menu-item:focus .mce-ico{color:#595959}.mce-menu-item.mce-selected{background:#ededee}.mce-menu-item.mce-selected .mce-text,.mce-menu-item.mce-selected .mce-ico{color:#595959}.mce-menu-item.mce-active.mce-menu-item-normal{background:#555c66}.mce-menu-item.mce-active.mce-menu-item-normal .mce-text,.mce-menu-item.mce-active.mce-menu-item-normal .mce-ico{color:white}.mce-menu-item.mce-active.mce-menu-item-checkbox .mce-ico{visibility:visible}.mce-menu-item.mce-disabled,.mce-menu-item.mce-disabled:hover{background:white}.mce-menu-item.mce-disabled:focus,.mce-menu-item.mce-disabled:hover:focus{background:#ededee}.mce-menu-item.mce-disabled .mce-text,.mce-menu-item.mce-disabled:hover .mce-text,.mce-menu-item.mce-disabled .mce-ico,.mce-menu-item.mce-disabled:hover .mce-ico{color:#aaa}.mce-menu-item.mce-menu-item-preview.mce-active{border-left:5px solid #555c66;background:white}.mce-menu-item.mce-menu-item-preview.mce-active .mce-text,.mce-menu-item.mce-menu-item-preview.mce-active .mce-ico{color:#595959}.mce-menu-item.mce-menu-item-preview.mce-active:hover{background:#ededee}.mce-menu-item-link{color:#093;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mce-menu-item-link b{color:#093}.mce-menu-item-ellipsis{display:block;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mce-menu-item:hover *,.mce-menu-item.mce-selected *,.mce-menu-item:focus *{color:#595959}div.mce-menu .mce-menu-item-sep,.mce-menu-item-sep:hover{border:0;padding:0;height:1px;margin:9px 1px;overflow:hidden;background:transparent;border-bottom:1px solid rgba(0,0,0,0.1);cursor:default;filter:none}div.mce-menu .mce-menu-item b{font-weight:bold}.mce-menu-item-indent-1{padding-left:20px}.mce-menu-item-indent-2{padding-left:35px}.mce-menu-item-indent-2{padding-left:35px}.mce-menu-item-indent-3{padding-left:40px}.mce-menu-item-indent-4{padding-left:45px}.mce-menu-item-indent-5{padding-left:50px}.mce-menu-item-indent-6{padding-left:55px}.mce-menu.mce-rtl{direction:rtl}.mce-rtl .mce-menu-item{text-align:right;direction:rtl;padding:6px 12px 6px 15px}.mce-rtl .mce-menu-item .mce-caret{margin-left:6px;margin-right:0;border-right:4px solid #595959;border-left:0}.mce-rtl .mce-menu-item.mce-selected .mce-caret,.mce-rtl .mce-menu-item:focus .mce-caret,.mce-rtl .mce-menu-item:hover .mce-caret{border-left-color:transparent;border-right-color:#595959}.mce-rtl .mce-menu-item .mce-ico{padding-right:0;padding-left:4px}.mce-throbber{position:absolute;top:0;left:0;width:100%;height:100%;opacity:.6;filter:alpha(opacity=60);zoom:1;background:#fff url('img/loader.gif') no-repeat center center}.mce-throbber-inline{position:static;height:50px}.mce-menu .mce-throbber-inline{height:25px;background-size:contain}.mce-menu{position:absolute;left:0;top:0;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);background:transparent;z-index:1000;padding:5px 0 5px 0;margin:-1px 0 0;min-width:180px;background:white;border:1px solid #c5c9cf;border:1px solid #e2e4e7;z-index:1002;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);max-height:500px;overflow:auto;overflow-x:hidden}.mce-menu.mce-animate{opacity:.01;transform:rotateY(10deg) rotateX(-10deg);transform-origin:left top}.mce-menu.mce-menu-align .mce-menu-shortcut,.mce-menu.mce-menu-align .mce-caret{position:absolute;right:0}.mce-menu i{display:none}.mce-menu-has-icons i{display:inline-block}.mce-menu.mce-in.mce-animate{opacity:1;transform:rotateY(0) rotateX(0);transition:opacity .075s ease,transform .1s ease}.mce-menu-sub-tr-tl{margin:-6px 0 0 -1px}.mce-menu-sub-br-bl{margin:6px 0 0 -1px}.mce-menu-sub-tl-tr{margin:-6px 0 0 1px}.mce-menu-sub-bl-br{margin:6px 0 0 1px}.mce-rtl .mce-menu-item .mce-ico{padding-right:0;padding-left:4px}.mce-rtl.mce-menu-align .mce-caret,.mce-rtl .mce-menu-shortcut{right:auto;left:0}.mce-listbox button{text-align:left;padding-right:20px;position:relative}.mce-listbox .mce-caret{position:absolute;margin-top:-2px;right:8px;top:50%}.mce-rtl .mce-listbox .mce-caret{right:auto;left:8px}.mce-rtl .mce-listbox button{padding-right:10px;padding-left:20px}.mce-container-body .mce-resizehandle{position:absolute;right:0;bottom:0;width:16px;height:16px;visibility:visible;cursor:s-resize;margin:0}.mce-container-body .mce-resizehandle-both{cursor:se-resize}i.mce-i-resize{color:#595959}.mce-selectbox{background:#fff;border:1px solid #c5c5c5}.mce-slider{border:1px solid #c5c5c5;background:#fff;width:100px;height:10px;position:relative;display:block}.mce-slider.mce-vertical{width:10px;height:100px}.mce-slider-handle{border:1px solid #c5c5c5;background:#e6e6e6;display:block;width:13px;height:13px;position:absolute;top:0;left:0;margin-left:-1px;margin-top:-2px}.mce-slider-handle:focus{border-color:#2276d2}.mce-spacer{visibility:hidden}.mce-splitbtn:hover .mce-open{border-left:1px solid #e2e4e7}.mce-splitbtn .mce-open{border-left:1px solid transparent;padding-right:4px;padding-left:4px}.mce-splitbtn .mce-open:focus{border-left:1px solid #e2e4e7}.mce-splitbtn .mce-open:hover,.mce-splitbtn .mce-open:active{border-left:1px solid #e2e4e7}.mce-splitbtn.mce-active:hover .mce-open{border-left:1px solid white}.mce-splitbtn.mce-opened{border-color:#e2e4e7}.mce-splitbtn.mce-btn-small .mce-open{padding:0 3px 0 3px}.mce-rtl .mce-splitbtn{direction:rtl;text-align:right}.mce-rtl .mce-splitbtn button{padding-right:4px;padding-left:4px}.mce-rtl .mce-splitbtn .mce-open{border-left:0}.mce-stack-layout-item{display:block}.mce-tabs{display:block;border-bottom:1px solid #c5c5c5}.mce-tabs,.mce-tabs+.mce-container-body{background:#fff}.mce-tab{display:inline-block;*display:inline;*zoom:1;border:1px solid #c5c5c5;border-width:0 1px 0 0;background:#fff;padding:8px 15px;text-shadow:0 1px 1px rgba(255,255,255,0.75);height:13px;cursor:pointer}.mce-tab:hover{background:#FDFDFD}.mce-tab.mce-active{background:#FDFDFD;border-bottom-color:transparent;margin-bottom:-1px;height:14px}.mce-tab:focus{color:#2276d2}.mce-rtl .mce-tabs{text-align:right;direction:rtl}.mce-rtl .mce-tab{border-width:0 0 0 1px}.mce-textbox{background:#fff;border:1px solid #c5c5c5;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;display:inline-block;-webkit-transition:border linear .2s, box-shadow linear .2s;transition:border linear .2s, box-shadow linear .2s;height:28px;resize:none;padding:0 4px 0 4px;white-space:pre-wrap;*white-space:pre;color:#595959}.mce-textbox:focus,.mce-textbox.mce-focus{border-color:#2276d2;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-placeholder .mce-textbox{color:#aaa}.mce-textbox.mce-multiline{padding:4px;height:auto}.mce-textbox.mce-disabled{color:#bdbdbd}.mce-rtl .mce-textbox{text-align:right;direction:rtl}.mce-dropzone{border:3px dashed gray;text-align:center}.mce-dropzone span{text-transform:uppercase;display:inline-block;vertical-align:middle}.mce-dropzone:after{content:"";height:100%;display:inline-block;vertical-align:middle}.mce-dropzone.mce-disabled{opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-dropzone.mce-disabled.mce-dragenter{cursor:not-allowed}.mce-browsebutton{position:relative;overflow:hidden}.mce-browsebutton button{position:relative;z-index:1}.mce-browsebutton input{opacity:0;filter:alpha(opacity=0);zoom:1;position:absolute;top:0;left:0;width:100%;height:100%;z-index:0}@font-face{font-family:'tinymce';src:url('fonts/tinymce.eot');src:url('fonts/tinymce.eot?#iefix') format('embedded-opentype'),url('fonts/tinymce.woff') format('woff'),url('fonts/tinymce.ttf') format('truetype'),url('fonts/tinymce.svg#tinymce') format('svg');font-weight:normal;font-style:normal}@font-face{font-family:'tinymce-small';src:url('fonts/tinymce-small.eot');src:url('fonts/tinymce-small.eot?#iefix') format('embedded-opentype'),url('fonts/tinymce-small.woff') format('woff'),url('fonts/tinymce-small.ttf') format('truetype'),url('fonts/tinymce-small.svg#tinymce') format('svg');font-weight:normal;font-style:normal}.mce-ico{font-family:'tinymce',Arial;font-style:normal;font-weight:normal;font-variant:normal;font-size:16px;line-height:16px;speak:none;vertical-align:text-top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:inline-block;background:transparent center center;background-size:cover;width:16px;height:16px;color:#595959}.mce-btn-small .mce-ico{font-family:'tinymce-small',Arial}.mce-i-save:before{content:"\e000"}.mce-i-newdocument:before{content:"\e001"}.mce-i-fullpage:before{content:"\e002"}.mce-i-alignleft:before{content:"\e003"}.mce-i-aligncenter:before{content:"\e004"}.mce-i-alignright:before{content:"\e005"}.mce-i-alignjustify:before{content:"\e006"}.mce-i-alignnone:before{content:"\e003"}.mce-i-cut:before{content:"\e007"}.mce-i-paste:before{content:"\e008"}.mce-i-searchreplace:before{content:"\e009"}.mce-i-bullist:before{content:"\e00a"}.mce-i-numlist:before{content:"\e00b"}.mce-i-indent:before{content:"\e00c"}.mce-i-outdent:before{content:"\e00d"}.mce-i-blockquote:before{content:"\e00e"}.mce-i-undo:before{content:"\e00f"}.mce-i-redo:before{content:"\e010"}.mce-i-link:before{content:"\e011"}.mce-i-unlink:before{content:"\e012"}.mce-i-anchor:before{content:"\e013"}.mce-i-image:before{content:"\e014"}.mce-i-media:before{content:"\e015"}.mce-i-help:before{content:"\e016"}.mce-i-code:before{content:"\e017"}.mce-i-insertdatetime:before{content:"\e018"}.mce-i-preview:before{content:"\e019"}.mce-i-forecolor:before{content:"\e01a"}.mce-i-backcolor:before{content:"\e01a"}.mce-i-table:before{content:"\e01b"}.mce-i-hr:before{content:"\e01c"}.mce-i-removeformat:before{content:"\e01d"}.mce-i-subscript:before{content:"\e01e"}.mce-i-superscript:before{content:"\e01f"}.mce-i-charmap:before{content:"\e020"}.mce-i-emoticons:before{content:"\e021"}.mce-i-print:before{content:"\e022"}.mce-i-fullscreen:before{content:"\e023"}.mce-i-spellchecker:before{content:"\e024"}.mce-i-nonbreaking:before{content:"\e025"}.mce-i-template:before{content:"\e026"}.mce-i-pagebreak:before{content:"\e027"}.mce-i-restoredraft:before{content:"\e028"}.mce-i-bold:before{content:"\e02a"}.mce-i-italic:before{content:"\e02b"}.mce-i-underline:before{content:"\e02c"}.mce-i-strikethrough:before{content:"\e02d"}.mce-i-visualchars:before{content:"\e02e"}.mce-i-visualblocks:before{content:"\e02e"}.mce-i-ltr:before{content:"\e02f"}.mce-i-rtl:before{content:"\e030"}.mce-i-copy:before{content:"\e031"}.mce-i-resize:before{content:"\e032"}.mce-i-browse:before{content:"\e034"}.mce-i-pastetext:before{content:"\e035"}.mce-i-rotateleft:before{content:"\eaa8"}.mce-i-rotateright:before{content:"\eaa9"}.mce-i-crop:before{content:"\ee78"}.mce-i-editimage:before{content:"\e915"}.mce-i-options:before{content:"\ec6a"}.mce-i-flipv:before{content:"\eaaa"}.mce-i-fliph:before{content:"\eaac"}.mce-i-zoomin:before{content:"\eb35"}.mce-i-zoomout:before{content:"\eb36"}.mce-i-sun:before{content:"\eccc"}.mce-i-moon:before{content:"\eccd"}.mce-i-arrowleft:before{content:"\edc0"}.mce-i-arrowright:before{content:"\e93c"}.mce-i-drop:before{content:"\e935"}.mce-i-contrast:before{content:"\ecd4"}.mce-i-sharpen:before{content:"\eba7"}.mce-i-resize2:before{content:"\edf9"}.mce-i-orientation:before{content:"\e601"}.mce-i-invert:before{content:"\e602"}.mce-i-gamma:before{content:"\e600"}.mce-i-remove:before{content:"\ed6a"}.mce-i-tablerowprops:before{content:"\e604"}.mce-i-tablecellprops:before{content:"\e605"}.mce-i-table2:before{content:"\e606"}.mce-i-tablemergecells:before{content:"\e607"}.mce-i-tableinsertcolbefore:before{content:"\e608"}.mce-i-tableinsertcolafter:before{content:"\e609"}.mce-i-tableinsertrowbefore:before{content:"\e60a"}.mce-i-tableinsertrowafter:before{content:"\e60b"}.mce-i-tablesplitcells:before{content:"\e60d"}.mce-i-tabledelete:before{content:"\e60e"}.mce-i-tableleftheader:before{content:"\e62a"}.mce-i-tabletopheader:before{content:"\e62b"}.mce-i-tabledeleterow:before{content:"\e800"}.mce-i-tabledeletecol:before{content:"\e801"}.mce-i-codesample:before{content:"\e603"}.mce-i-fill:before{content:"\e902"}.mce-i-borderwidth:before{content:"\e903"}.mce-i-line:before{content:"\e904"}.mce-i-count:before{content:"\e905"}.mce-i-translate:before{content:"\e907"}.mce-i-drag:before{content:"\e908"}.mce-i-home:before{content:"\e90b"}.mce-i-upload:before{content:"\e914"}.mce-i-bubble:before{content:"\e91c"}.mce-i-user:before{content:"\e91d"}.mce-i-lock:before{content:"\e926"}.mce-i-unlock:before{content:"\e927"}.mce-i-settings:before{content:"\e928"}.mce-i-remove2:before{content:"\e92a"}.mce-i-menu:before{content:"\e92d"}.mce-i-warning:before{content:"\e930"}.mce-i-question:before{content:"\e931"}.mce-i-pluscircle:before{content:"\e932"}.mce-i-info:before{content:"\e933"}.mce-i-notice:before{content:"\e934"}.mce-i-arrowup:before{content:"\e93b"}.mce-i-arrowdown:before{content:"\e93d"}.mce-i-arrowup2:before{content:"\e93f"}.mce-i-arrowdown2:before{content:"\e940"}.mce-i-menu2:before{content:"\e941"}.mce-i-newtab:before{content:"\e961"}.mce-i-a11y:before{content:"\e900"}.mce-i-plus:before{content:"\e93a"}.mce-i-insert:before{content:"\e93a"}.mce-i-minus:before{content:"\e939"}.mce-i-books:before{content:"\e911"}.mce-i-reload:before{content:"\e906"}.mce-i-toc:before{content:"\e901"}.mce-i-checkmark:before{content:"\e033"}.mce-i-checkbox:before,.mce-i-selected:before{content:"\e033"}.mce-i-insert{font-size:14px}.mce-i-selected{visibility:hidden}i.mce-i-backcolor{text-shadow:none;background:#BBB}.mce-rtl .mce-filepicker input{direction:ltr} +.mce-container,.mce-container *,.mce-widget,.mce-widget *,.mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:transparent;text-decoration:none;color:#595959;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;-webkit-tap-highlight-color:transparent;line-height:normal;font-weight:normal;text-align:left;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-widget button{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.mce-container *[unselectable]{-moz-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none}.word-wrap{word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.mce-fade{opacity:0;-webkit-transition:opacity .15s linear;transition:opacity .15s linear}.mce-fade.mce-in{opacity:1}.mce-tinymce{visibility:inherit !important;position:relative}.mce-fullscreen{border:0;padding:0;margin:0;overflow:hidden;height:100%;z-index:100}div.mce-fullscreen{position:fixed;top:0;left:0;width:100%;height:auto}.mce-tinymce{display:block;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2)}.mce-statusbar>.mce-container-body{display:flex;padding-right:16px}.mce-statusbar>.mce-container-body .mce-path{flex:1}.mce-wordcount{font-size:inherit;text-transform:uppercase;padding:8px 0}div.mce-edit-area{background:#FFF;filter:none}.mce-statusbar{position:relative}.mce-statusbar .mce-container-body{position:relative;font-size:11px}.mce-fullscreen .mce-resizehandle{display:none}.mce-statusbar .mce-flow-layout-item{margin:0}.mce-charmap{border-collapse:collapse}.mce-charmap td{cursor:default;border:1px solid #c5c5c5;width:20px;height:20px;line-height:20px;text-align:center;vertical-align:middle;padding:2px}.mce-charmap td div{text-align:center}.mce-charmap td:hover{background:white}.mce-grid td.mce-grid-cell div{border:1px solid #c5c5c5;width:15px;height:15px;margin:0;cursor:pointer}.mce-grid td.mce-grid-cell div:focus{border-color:#91bbe9}.mce-grid td.mce-grid-cell div[disabled]{cursor:not-allowed}.mce-grid{border-spacing:2px;border-collapse:separate}.mce-grid a{display:block;border:1px solid transparent}.mce-grid a:hover,.mce-grid a:focus{border-color:#91bbe9}.mce-grid-border{margin:0 4px 0 4px}.mce-grid-border a{border-color:#c5c5c5;width:13px;height:13px}.mce-grid-border a:hover,.mce-grid-border a.mce-active{border-color:#91bbe9;background:#bdd6f2}.mce-text-center{text-align:center}div.mce-tinymce-inline{width:100%}.mce-colorbtn-trans div{text-align:center;vertical-align:middle;font-weight:bold;font-size:20px;line-height:16px;color:#8b8b8b}.mce-monospace{font-family:"Courier New",Courier,monospace}.mce-toolbar-grp .mce-flow-layout-item{margin-bottom:0}.mce-container b{font-weight:bold}.mce-container p{margin-bottom:5px}.mce-container a{cursor:pointer;color:#2276d2}.mce-container a:hover{text-decoration:underline}.mce-container ul{margin-left:15px}.mce-container .mce-table-striped{border-collapse:collapse;margin:10px}.mce-container .mce-table-striped thead>tr{background-color:#fafafa}.mce-container .mce-table-striped thead>tr th{font-weight:bold}.mce-container .mce-table-striped td,.mce-container .mce-table-striped th{padding:5px}.mce-container .mce-table-striped tr:nth-child(even){background-color:#fafafa}.mce-container .mce-table-striped tbody>tr:hover{background-color:#e1e1e1}.mce-branding{font-size:inherit;text-transform:uppercase;white-space:pre;padding:8px 0}.mce-branding a{font-size:inherit;color:inherit}.mce-top-part{position:relative}.mce-top-part::before{content:'';position:absolute;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);top:0;right:0;bottom:0;left:0;pointer-events:none}.mce-rtl .mce-wordcount{left:0;right:auto}.mce-rtl .mce-statusbar>.mce-container-body>*:last-child{padding-right:0;padding-left:10px}.mce-rtl .mce-path{text-align:right;padding-right:16px}.mce-croprect-container{position:absolute;top:0;left:0}.mce-croprect-handle{position:absolute;top:0;left:0;width:20px;height:20px;border:2px solid white}.mce-croprect-handle-nw{border-width:2px 0 0 2px;margin:-2px 0 0 -2px;cursor:nw-resize;top:100px;left:100px}.mce-croprect-handle-ne{border-width:2px 2px 0 0;margin:-2px 0 0 -20px;cursor:ne-resize;top:100px;left:200px}.mce-croprect-handle-sw{border-width:0 0 2px 2px;margin:-20px 2px 0 -2px;cursor:sw-resize;top:200px;left:100px}.mce-croprect-handle-se{border-width:0 2px 2px 0;margin:-20px 0 0 -20px;cursor:se-resize;top:200px;left:200px}.mce-croprect-handle-move{position:absolute;cursor:move;border:0}.mce-croprect-block{opacity:.5;filter:alpha(opacity=50);zoom:1;position:absolute;background:black}.mce-croprect-handle:focus{border-color:#2276d2}.mce-croprect-handle-move:focus{outline:1px solid #2276d2}.mce-imagepanel{overflow:auto;background:black}.mce-imagepanel-bg{position:absolute;background:url('data:image/gif;base64,R0lGODdhDAAMAIABAMzMzP///ywAAAAADAAMAAACFoQfqYeabNyDMkBQb81Uat85nxguUAEAOw==')}.mce-imagepanel img{position:absolute}.mce-imagetool.mce-btn .mce-ico{display:block;width:20px;height:20px;text-align:center;line-height:20px;font-size:20px;padding:5px}.mce-arrow-up{margin-top:12px}.mce-arrow-down{margin-top:-12px}.mce-arrow:before,.mce-arrow:after{position:absolute;left:50%;display:block;width:0;height:0;border-style:solid;border-color:transparent;content:""}.mce-arrow.mce-arrow-up:before{top:-9px;border-bottom-color:#c5c5c5;border-width:0 9px 9px;margin-left:-9px}.mce-arrow.mce-arrow-down:before{bottom:-9px;border-top-color:#c5c5c5;border-width:9px 9px 0;margin-left:-9px}.mce-arrow.mce-arrow-up:after{top:-8px;border-bottom-color:#fff;border-width:0 8px 8px;margin-left:-8px}.mce-arrow.mce-arrow-down:after{bottom:-8px;border-top-color:#fff;border-width:8px 8px 0;margin-left:-8px}.mce-arrow.mce-arrow-left:before,.mce-arrow.mce-arrow-left:after{margin:0}.mce-arrow.mce-arrow-left:before{left:8px}.mce-arrow.mce-arrow-left:after{left:9px}.mce-arrow.mce-arrow-right:before,.mce-arrow.mce-arrow-right:after{left:auto;margin:0}.mce-arrow.mce-arrow-right:before{right:8px}.mce-arrow.mce-arrow-right:after{right:9px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-left:before{left:-9px;top:50%;border-right-color:#c5c5c5;border-width:9px 9px 9px 0;margin-top:-9px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-left:after{left:-8px;top:50%;border-right-color:#fff;border-width:8px 8px 8px 0;margin-top:-8px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-left{margin-left:12px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-right:before{right:-9px;top:50%;border-left-color:#c5c5c5;border-width:9px 0 9px 9px;margin-top:-9px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-right:after{right:-8px;top:50%;border-left-color:#fff;border-width:8px 0 8px 8px;margin-top:-8px}.mce-arrow.mce-arrow-center.mce-arrow.mce-arrow-right{margin-left:-14px}.mce-edit-aria-container>.mce-container-body{display:flex}.mce-edit-aria-container>.mce-container-body .mce-edit-area{flex:1}.mce-edit-aria-container>.mce-container-body .mce-sidebar>.mce-container-body{display:flex;align-items:stretch;height:100%}.mce-edit-aria-container>.mce-container-body .mce-sidebar-panel{min-width:250px;max-width:250px;position:relative}.mce-edit-aria-container>.mce-container-body .mce-sidebar-panel>.mce-container-body{position:absolute;width:100%;height:100%;overflow:auto;top:0;left:0}.mce-sidebar-toolbar{border:0 solid #c5c5c5;border-left-width:1px}.mce-sidebar-toolbar .mce-btn{border-left:0;border-right:0}.mce-sidebar-toolbar .mce-btn.mce-active,.mce-sidebar-toolbar .mce-btn.mce-active:hover{background-color:#555c66}.mce-sidebar-toolbar .mce-btn.mce-active button,.mce-sidebar-toolbar .mce-btn.mce-active:hover button,.mce-sidebar-toolbar .mce-btn.mce-active button i,.mce-sidebar-toolbar .mce-btn.mce-active:hover button i{color:white;text-shadow:1px 1px none}.mce-sidebar-panel{border:0 solid #c5c5c5;border-left-width:1px}.mce-container,.mce-container-body{display:block}.mce-autoscroll{overflow:hidden}.mce-scrollbar{position:absolute;width:7px;height:100%;top:2px;right:2px;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-scrollbar-h{top:auto;right:auto;left:2px;bottom:2px;width:100%;height:7px}.mce-scrollbar-thumb{position:absolute;background-color:#000;border:1px solid #888;border-color:rgba(85,85,85,0.6);width:5px;height:100%}.mce-scrollbar-h .mce-scrollbar-thumb{width:100%;height:5px}.mce-scrollbar:hover,.mce-scrollbar.mce-active{background-color:#AAA;opacity:.6;filter:alpha(opacity=60);zoom:1}.mce-scroll{position:relative}.mce-panel{border:0 solid #f3f3f3;border:0 solid #c5c5c5;background-color:#fff}.mce-floatpanel{position:absolute;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2)}.mce-floatpanel.mce-fixed{position:fixed}.mce-floatpanel .mce-arrow,.mce-floatpanel .mce-arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.mce-floatpanel .mce-arrow{border-width:11px}.mce-floatpanel .mce-arrow:after{border-width:10px;content:""}.mce-floatpanel.mce-popover{filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);background:transparent;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);top:0;left:0;background:#FFF;border:1px solid #c5c5c5;border:1px solid rgba(0,0,0,0.25)}.mce-floatpanel.mce-popover.mce-bottom{margin-top:10px;*margin-top:0}.mce-floatpanel.mce-popover.mce-bottom>.mce-arrow{left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#c5c5c5;border-bottom-color:rgba(0,0,0,0.25);top:-11px}.mce-floatpanel.mce-popover.mce-bottom>.mce-arrow:after{top:1px;margin-left:-10px;border-top-width:0;border-bottom-color:#FFF}.mce-floatpanel.mce-popover.mce-top{margin-top:-10px;*margin-top:0}.mce-floatpanel.mce-popover.mce-top>.mce-arrow{left:50%;margin-left:-11px;border-bottom-width:0;border-top-color:#c5c5c5;top:auto;bottom:-11px}.mce-floatpanel.mce-popover.mce-top>.mce-arrow:after{bottom:1px;margin-left:-10px;border-bottom-width:0;border-top-color:#FFF}.mce-floatpanel.mce-popover.mce-bottom.mce-start,.mce-floatpanel.mce-popover.mce-top.mce-start{margin-left:-22px}.mce-floatpanel.mce-popover.mce-bottom.mce-start>.mce-arrow,.mce-floatpanel.mce-popover.mce-top.mce-start>.mce-arrow{left:20px}.mce-floatpanel.mce-popover.mce-bottom.mce-end,.mce-floatpanel.mce-popover.mce-top.mce-end{margin-left:22px}.mce-floatpanel.mce-popover.mce-bottom.mce-end>.mce-arrow,.mce-floatpanel.mce-popover.mce-top.mce-end>.mce-arrow{right:10px;left:auto}.mce-fullscreen{border:0;padding:0;margin:0;overflow:hidden;height:100%}div.mce-fullscreen{position:fixed;top:0;left:0}#mce-modal-block{opacity:0;filter:alpha(opacity=0);zoom:1;position:fixed;left:0;top:0;width:100%;height:100%;background:#FFF}#mce-modal-block.mce-in{opacity:.5;filter:alpha(opacity=50);zoom:1}.mce-window-move{cursor:move}.mce-window{-webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);background:transparent;background:#FFF;position:fixed;top:0;left:0;opacity:0;transform:scale(.1);transition:transform 100ms ease-in,opacity 150ms ease-in}.mce-window.mce-in{transform:scale(1);opacity:1}.mce-window-head{padding:9px 15px;border-bottom:1px solid #c5c5c5;position:relative}.mce-window-head .mce-close{position:absolute;right:0;top:0;height:38px;width:38px;text-align:center;cursor:pointer}.mce-window-head .mce-close i{color:#9b9b9b}.mce-close:hover i{color:#bdbdbd}.mce-window-head .mce-title{line-height:20px;font-size:20px;font-weight:bold;text-rendering:optimizelegibility;padding-right:20px}.mce-window .mce-container-body{display:block}.mce-foot{display:block;background-color:#FFF;border-top:1px solid #c5c5c5}.mce-window-head .mce-dragh{position:absolute;top:0;left:0;cursor:move;width:90%;height:100%}.mce-window iframe{width:100%;height:100%}.mce-window-body .mce-listbox{border-color:#e2e4e7}.mce-window .mce-btn:hover{border-color:#c5c5c5}.mce-window .mce-btn:focus{border-color:#2276d2}.mce-window-body .mce-btn,.mce-foot .mce-btn{border-color:#c5c5c5}.mce-foot .mce-btn.mce-primary{border-color:transparent}.mce-rtl .mce-window-head .mce-close{position:absolute;right:auto;left:0}.mce-rtl .mce-window-head .mce-dragh{left:auto;right:0}.mce-rtl .mce-window-head .mce-title{direction:rtl;text-align:right;padding-right:0;padding-left:20px}.mce-tooltip{position:absolute;padding:5px;opacity:.8;filter:alpha(opacity=80);zoom:1;margin-top:1px}.mce-tooltip-inner{font-size:11px;background-color:#000;color:white;max-width:200px;padding:5px 8px 4px 8px;text-align:center;white-space:normal}.mce-tooltip-inner{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-tooltip-arrow{position:absolute;width:0;height:0;line-height:0;border:5px dashed #000}.mce-tooltip-arrow-n{border-bottom-color:#000}.mce-tooltip-arrow-s{border-top-color:#000}.mce-tooltip-arrow-e{border-left-color:#000}.mce-tooltip-arrow-w{border-right-color:#000}.mce-tooltip-nw,.mce-tooltip-sw{margin-left:-14px}.mce-tooltip-ne,.mce-tooltip-se{margin-left:14px}.mce-tooltip-n .mce-tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-style:solid;border-top:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-nw .mce-tooltip-arrow{top:0;left:10px;border-bottom-style:solid;border-top:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-ne .mce-tooltip-arrow{top:0;right:10px;border-bottom-style:solid;border-top:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-s .mce-tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-style:solid;border-bottom:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-sw .mce-tooltip-arrow{bottom:0;left:10px;border-top-style:solid;border-bottom:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-se .mce-tooltip-arrow{bottom:0;right:10px;border-top-style:solid;border-bottom:none;border-left-color:transparent;border-right-color:transparent}.mce-tooltip-e .mce-tooltip-arrow{right:0;top:50%;margin-top:-5px;border-left-style:solid;border-right:none;border-top-color:transparent;border-bottom-color:transparent}.mce-tooltip-w .mce-tooltip-arrow{left:0;top:50%;margin-top:-5px;border-right-style:solid;border-left:none;border-top-color:transparent;border-bottom-color:transparent}.mce-progress{display:inline-block;position:relative;height:20px}.mce-progress .mce-bar-container{display:inline-block;width:100px;height:100%;margin-right:8px;border:1px solid #ccc;overflow:hidden}.mce-progress .mce-text{display:inline-block;margin-top:auto;margin-bottom:auto;font-size:14px;width:40px;color:#595959}.mce-bar{display:block;width:0;height:100%;background-color:#dfdfdf;-webkit-transition:width .2s ease;transition:width .2s ease}.mce-notification{position:absolute;background-color:#fff;padding:5px;margin-top:5px;border-width:1px;border-style:solid;border-color:#c5c5c5;transition:transform 100ms ease-in,opacity 150ms ease-in;opacity:0;box-sizing:border-box}.mce-notification.mce-in{opacity:1}.mce-notification-success{background-color:#dff0d8;border-color:#d6e9c6}.mce-notification-info{background-color:#d9edf7;border-color:#779ECB}.mce-notification-warning{background-color:#fcf8e3;border-color:#faebcc}.mce-notification-error{background-color:#f2dede;border-color:#ebccd1}.mce-notification.mce-has-close{padding-right:15px}.mce-notification .mce-ico{margin-top:5px}.mce-notification-inner{word-wrap:break-word;-ms-word-break:break-all;word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;hyphens:auto;display:inline-block;font-size:14px;margin:5px 8px 4px 8px;text-align:center;white-space:normal;color:#31708f}.mce-notification-inner a{text-decoration:underline;cursor:pointer}.mce-notification .mce-progress{margin-right:8px}.mce-notification .mce-progress .mce-text{margin-top:5px}.mce-notification *,.mce-notification .mce-progress .mce-text{color:#595959}.mce-notification .mce-progress .mce-bar-container{border-color:#c5c5c5}.mce-notification .mce-progress .mce-bar-container .mce-bar{background-color:#595959}.mce-notification-success *,.mce-notification-success .mce-progress .mce-text{color:#3c763d}.mce-notification-success .mce-progress .mce-bar-container{border-color:#d6e9c6}.mce-notification-success .mce-progress .mce-bar-container .mce-bar{background-color:#3c763d}.mce-notification-info *,.mce-notification-info .mce-progress .mce-text{color:#31708f}.mce-notification-info .mce-progress .mce-bar-container{border-color:#779ECB}.mce-notification-info .mce-progress .mce-bar-container .mce-bar{background-color:#31708f}.mce-notification-warning *,.mce-notification-warning .mce-progress .mce-text{color:#8a6d3b}.mce-notification-warning .mce-progress .mce-bar-container{border-color:#faebcc}.mce-notification-warning .mce-progress .mce-bar-container .mce-bar{background-color:#8a6d3b}.mce-notification-error *,.mce-notification-error .mce-progress .mce-text{color:#a94442}.mce-notification-error .mce-progress .mce-bar-container{border-color:#ebccd1}.mce-notification-error .mce-progress .mce-bar-container .mce-bar{background-color:#a94442}.mce-notification .mce-close{position:absolute;top:6px;right:8px;font-size:20px;font-weight:bold;line-height:20px;color:#9b9b9b;cursor:pointer}.mce-abs-layout{position:relative}html .mce-abs-layout-item,.mce-abs-end{position:absolute}.mce-abs-end{width:1px;height:1px}.mce-container-body.mce-abs-layout{overflow:hidden}.mce-btn{border:1px solid #b3b3b3;border-color:transparent transparent transparent transparent;position:relative;text-shadow:0 1px 1px rgba(255,255,255,0.75);background:white;display:inline-block;*display:inline;*zoom:1;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-btn:hover,.mce-btn:active{background:white;color:#595959;border-color:#e2e4e7}.mce-btn:focus{background:white;color:#595959;border-color:#e2e4e7}.mce-btn.mce-disabled button,.mce-btn.mce-disabled:hover button{cursor:default;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-btn.mce-active,.mce-btn.mce-active:hover,.mce-btn.mce-active:focus,.mce-btn.mce-active:active{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;background:#555c66;color:white;border-color:transparent}.mce-btn.mce-active button,.mce-btn.mce-active:hover button,.mce-btn.mce-active i,.mce-btn.mce-active:hover i{color:white}.mce-btn:hover .mce-caret{border-top-color:#b5bcc2}.mce-btn.mce-active .mce-caret,.mce-btn.mce-active:hover .mce-caret{border-top-color:white}.mce-btn button{padding:4px 6px;font-size:14px;line-height:20px;*line-height:16px;cursor:pointer;color:#595959;text-align:center;overflow:visible;-webkit-appearance:none}.mce-btn button::-moz-focus-inner{border:0;padding:0}.mce-btn i{text-shadow:1px 1px none}.mce-primary.mce-btn-has-text{min-width:50px}.mce-primary{color:white;border:1px solid transparent;border-color:transparent;background-color:#2276d2}.mce-primary:hover,.mce-primary:focus{background-color:#1e6abc;border-color:transparent}.mce-primary.mce-disabled button,.mce-primary.mce-disabled:hover button{cursor:default;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-primary.mce-active,.mce-primary.mce-active:hover,.mce-primary:not(.mce-disabled):active{background-color:#1e6abc;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-primary button,.mce-primary button i{color:white;text-shadow:1px 1px none}.mce-btn .mce-txt{font-size:inherit;line-height:inherit;color:inherit}.mce-btn-large button{padding:9px 14px;font-size:16px;line-height:normal}.mce-btn-large i{margin-top:2px}.mce-btn-small button{padding:1px 5px;font-size:12px;*padding-bottom:2px}.mce-btn-small i{line-height:20px;vertical-align:top;*line-height:18px}.mce-btn .mce-caret{margin-top:8px;margin-left:0}.mce-btn-small .mce-caret{margin-top:8px;margin-left:0}.mce-caret{display:inline-block;*display:inline;*zoom:1;width:0;height:0;vertical-align:top;border-top:4px solid #b5bcc2;border-right:4px solid transparent;border-left:4px solid transparent;content:""}.mce-disabled .mce-caret{border-top-color:#aaa}.mce-caret.mce-up{border-bottom:4px solid #b5bcc2;border-top:0}.mce-btn-flat{border:0;background:transparent;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;filter:none}.mce-btn-flat:hover,.mce-btn-flat.mce-active,.mce-btn-flat:focus,.mce-btn-flat:active{border:0;background:#e6e6e6;filter:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-btn-has-text .mce-ico{padding-right:5px}.mce-rtl .mce-btn button{direction:rtl}.mce-toolbar .mce-btn-group{margin:0;padding:2px 0}.mce-btn-group .mce-btn{border-width:1px;margin:0;margin-left:2px}.mce-btn-group:not(:first-child){border-left:1px solid #d9d9d9;padding-left:0;margin-left:2px}.mce-btn-group{margin-left:2px}.mce-btn-group .mce-btn.mce-flow-layout-item{margin:0}.mce-rtl .mce-btn-group .mce-btn{margin-left:0;margin-right:2px}.mce-rtl .mce-btn-group .mce-first{margin-right:0}.mce-rtl .mce-btn-group:not(:first-child){border-left:none;border-right:1px solid #d9d9d9;padding-right:4px;margin-right:4px}.mce-checkbox{cursor:pointer}i.mce-i-checkbox{margin:0 3px 0 0;border:1px solid #c5c5c5;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;background-color:white;text-indent:-10em;overflow:hidden}.mce-checked i.mce-i-checkbox{color:#595959;font-size:16px;line-height:16px;text-indent:0}.mce-checkbox:focus i.mce-i-checkbox,.mce-checkbox.mce-focus i.mce-i-checkbox{border:1px solid #2276d2;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-checkbox.mce-disabled .mce-label,.mce-checkbox.mce-disabled i.mce-i-checkbox{color:#bdbdbd}.mce-checkbox .mce-label{vertical-align:middle}.mce-rtl .mce-checkbox{direction:rtl;text-align:right}.mce-rtl i.mce-i-checkbox{margin:0 0 0 3px}.mce-combobox{position:relative;display:inline-block;*display:inline;*zoom:1;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;*height:32px}.mce-combobox input{border:1px solid #c5c5c5;border-right-color:#c5c5c5;height:28px}.mce-combobox.mce-disabled input{color:#bdbdbd}.mce-combobox .mce-btn{border:1px solid #c5c5c5;border-left:0;margin:0}.mce-combobox button{padding-right:8px;padding-left:8px}.mce-combobox.mce-disabled .mce-btn button{cursor:default;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-combobox .mce-status{position:absolute;right:2px;top:50%;line-height:16px;margin-top:-8px;font-size:12px;width:15px;height:15px;text-align:center;cursor:pointer}.mce-combobox.mce-has-status input{padding-right:20px}.mce-combobox.mce-has-open .mce-status{right:37px}.mce-combobox .mce-status.mce-i-warning{color:#c09853}.mce-combobox .mce-status.mce-i-checkmark{color:#468847}.mce-menu.mce-combobox-menu{border-top:0;margin-top:0;max-height:200px}.mce-menu.mce-combobox-menu .mce-menu-item{padding:4px 6px 4px 4px;font-size:11px}.mce-menu.mce-combobox-menu .mce-menu-item-sep{padding:0}.mce-menu.mce-combobox-menu .mce-text,.mce-menu.mce-combobox-menu .mce-text b{font-size:11px}.mce-menu.mce-combobox-menu .mce-menu-item-link,.mce-menu.mce-combobox-menu .mce-menu-item-link b{font-size:11px}.mce-colorbox i{border:1px solid #c5c5c5;width:14px;height:14px}.mce-colorbutton .mce-ico{position:relative}.mce-colorbutton-grid{margin:4px}.mce-colorbutton .mce-preview{padding-right:3px;display:block;position:absolute;left:50%;top:50%;margin-left:-17px;margin-top:7px;background:gray;width:13px;height:2px;overflow:hidden}.mce-colorbutton.mce-btn-small .mce-preview{margin-left:-16px;padding-right:0;width:16px}.mce-rtl .mce-colorbutton{direction:rtl}.mce-rtl .mce-colorbutton .mce-preview{margin-left:0;padding-right:0;padding-left:3px}.mce-rtl .mce-colorbutton.mce-btn-small .mce-preview{margin-left:0;padding-right:0;padding-left:2px}.mce-rtl .mce-colorbutton .mce-open{padding-left:4px;padding-right:4px;border-left:0}.mce-colorpicker{position:relative;width:250px;height:220px}.mce-colorpicker-sv{position:absolute;top:0;left:0;width:90%;height:100%;border:1px solid #c5c5c5;cursor:crosshair;overflow:hidden}.mce-colorpicker-h-chunk{width:100%}.mce-colorpicker-overlay1,.mce-colorpicker-overlay2{width:100%;height:100%;position:absolute;top:0;left:0}.mce-colorpicker-overlay1{filter:progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr='#ffffff', endColorstr='#00ffffff');-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=1,startColorstr='#ffffff', endColorstr='#00ffffff')";background:linear-gradient(to right, #fff, rgba(255,255,255,0))}.mce-colorpicker-overlay2{filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#00000000', endColorstr='#000000');-ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00000000', endColorstr='#000000')";background:linear-gradient(to bottom, rgba(0,0,0,0), #000)}.mce-colorpicker-selector1{background:none;position:absolute;width:12px;height:12px;margin:-8px 0 0 -8px;border:1px solid black;border-radius:50%}.mce-colorpicker-selector2{position:absolute;width:10px;height:10px;border:1px solid white;border-radius:50%}.mce-colorpicker-h{position:absolute;top:0;right:0;width:6.5%;height:100%;border:1px solid #c5c5c5;cursor:crosshair}.mce-colorpicker-h-marker{margin-top:-4px;position:absolute;top:0;left:-1px;width:100%;border:1px solid black;background:white;height:4px;z-index:100}.mce-path{display:inline-block;*display:inline;*zoom:1;padding:8px;white-space:normal;font-size:inherit}.mce-path .mce-txt{display:inline-block;padding-right:3px}.mce-path .mce-path-body{display:inline-block}.mce-path-item{display:inline-block;*display:inline;*zoom:1;cursor:pointer;color:#595959;font-size:inherit;text-transform:uppercase}.mce-path-item:hover{text-decoration:underline}.mce-path-item:focus{background:#555c66;color:white}.mce-path .mce-divider{display:inline;font-size:inherit}.mce-disabled .mce-path-item{color:#aaa}.mce-rtl .mce-path{direction:rtl}.mce-fieldset{border:0 solid #9E9E9E}.mce-fieldset>.mce-container-body{margin-top:-15px}.mce-fieldset-title{margin-left:5px;padding:0 5px 0 5px}.mce-fit-layout{display:inline-block;*display:inline;*zoom:1}.mce-fit-layout-item{position:absolute}.mce-flow-layout-item{display:inline-block;*display:inline;*zoom:1}.mce-flow-layout-item{margin:2px 0 2px 2px}.mce-flow-layout-item.mce-last{margin-right:2px}.mce-flow-layout{white-space:normal}.mce-tinymce-inline .mce-flow-layout{white-space:nowrap}.mce-rtl .mce-flow-layout{text-align:right;direction:rtl}.mce-rtl .mce-flow-layout-item{margin:2px 2px 2px 0}.mce-rtl .mce-flow-layout-item.mce-last{margin-left:2px}.mce-iframe{border:0 solid #c5c5c5;width:100%;height:100%}.mce-infobox{display:inline-block;*display:inline;*zoom:1;text-shadow:0 1px 1px rgba(255,255,255,0.75);overflow:hidden;border:1px solid red}.mce-infobox div{display:block;margin:5px}.mce-infobox div button{position:absolute;top:50%;right:4px;cursor:pointer;margin-top:-8px;display:none}.mce-infobox div button:focus{outline:2px solid #e2e4e7}.mce-infobox.mce-has-help div{margin-right:25px}.mce-infobox.mce-has-help button{display:block}.mce-infobox.mce-success{background:#dff0d8;border-color:#d6e9c6}.mce-infobox.mce-success div{color:#3c763d}.mce-infobox.mce-warning{background:#fcf8e3;border-color:#faebcc}.mce-infobox.mce-warning div{color:#8a6d3b}.mce-infobox.mce-error{background:#f2dede;border-color:#ebccd1}.mce-infobox.mce-error div{color:#a94442}.mce-rtl .mce-infobox div{text-align:right;direction:rtl}.mce-label{display:inline-block;*display:inline;*zoom:1;text-shadow:0 1px 1px rgba(255,255,255,0.75);overflow:hidden}.mce-label.mce-autoscroll{overflow:auto}.mce-label.mce-disabled{color:#aaa}.mce-label.mce-multiline{white-space:pre-wrap}.mce-label.mce-success{color:#468847}.mce-label.mce-warning{color:#c09853}.mce-label.mce-error{color:#b94a48}.mce-rtl .mce-label{text-align:right;direction:rtl}.mce-menubar{border:1px solid #e2e4e7}.mce-menubar .mce-menubtn{border-color:transparent;background:transparent;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;filter:none}.mce-menubar .mce-menubtn button span{color:#595959}.mce-menubar .mce-caret{border-top-color:#b5bcc2}.mce-menubar .mce-active .mce-caret,.mce-menubar .mce-menubtn:hover .mce-caret{border-top-color:#b5bcc2}.mce-menubar .mce-menubtn:hover,.mce-menubar .mce-menubtn.mce-active,.mce-menubar .mce-menubtn:focus{border-color:#e2e4e7;background:white;filter:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-menubar .mce-menubtn.mce-active{border-bottom:none;z-index:65537}div.mce-menubtn.mce-opened{border-bottom-color:white;z-index:65537}div.mce-menubtn.mce-opened.mce-opened-under{z-index:0}.mce-menubtn button{color:#595959}.mce-menubtn.mce-btn-small span{font-size:12px}.mce-menubtn.mce-fixed-width span{display:inline-block;overflow-x:hidden;text-overflow:ellipsis;width:90px}.mce-menubtn.mce-fixed-width.mce-btn-small span{width:70px}.mce-menubtn .mce-caret{*margin-top:6px}.mce-rtl .mce-menubtn button{direction:rtl;text-align:right}.mce-rtl .mce-menubtn.mce-fixed-width span{direction:rtl;text-align:right}.mce-menu-item{display:block;padding:6px 4px 6px 4px;clear:both;font-weight:normal;line-height:20px;color:#595959;white-space:nowrap;cursor:pointer;line-height:normal;border-left:4px solid transparent;margin-bottom:1px}.mce-menu-item .mce-text,.mce-menu-item .mce-text b{line-height:1;vertical-align:initial}.mce-menu-item .mce-caret{margin-top:4px;margin-right:6px;border-top:4px solid transparent;border-bottom:4px solid transparent;border-left:4px solid #595959}.mce-menu-item .mce-menu-shortcut{display:inline-block;padding:0 10px 0 20px;color:#aaa}.mce-menu-item .mce-ico{padding-right:4px}.mce-menu-item:hover,.mce-menu-item:focus{background:#ededee}.mce-menu-item:hover .mce-menu-shortcut,.mce-menu-item:focus .mce-menu-shortcut{color:#aaa}.mce-menu-item:hover .mce-text,.mce-menu-item:focus .mce-text,.mce-menu-item:hover .mce-ico,.mce-menu-item:focus .mce-ico{color:#595959}.mce-menu-item.mce-selected{background:#ededee}.mce-menu-item.mce-selected .mce-text,.mce-menu-item.mce-selected .mce-ico{color:#595959}.mce-menu-item.mce-active.mce-menu-item-normal{background:#555c66}.mce-menu-item.mce-active.mce-menu-item-normal .mce-text,.mce-menu-item.mce-active.mce-menu-item-normal .mce-ico{color:white}.mce-menu-item.mce-active.mce-menu-item-checkbox .mce-ico{visibility:visible}.mce-menu-item.mce-disabled,.mce-menu-item.mce-disabled:hover{background:white}.mce-menu-item.mce-disabled:focus,.mce-menu-item.mce-disabled:hover:focus{background:#ededee}.mce-menu-item.mce-disabled .mce-text,.mce-menu-item.mce-disabled:hover .mce-text,.mce-menu-item.mce-disabled .mce-ico,.mce-menu-item.mce-disabled:hover .mce-ico{color:#aaa}.mce-menu-item.mce-menu-item-preview.mce-active{border-left:5px solid #555c66;background:white}.mce-menu-item.mce-menu-item-preview.mce-active .mce-text,.mce-menu-item.mce-menu-item-preview.mce-active .mce-ico{color:#595959}.mce-menu-item.mce-menu-item-preview.mce-active:hover{background:#ededee}.mce-menu-item-link{color:#093;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mce-menu-item-link b{color:#093}.mce-menu-item-ellipsis{display:block;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.mce-menu-item:hover *,.mce-menu-item.mce-selected *,.mce-menu-item:focus *{color:#595959}div.mce-menu .mce-menu-item-sep,.mce-menu-item-sep:hover{border:0;padding:0;height:1px;margin:9px 1px;overflow:hidden;background:transparent;border-bottom:1px solid rgba(0,0,0,0.1);cursor:default;filter:none}div.mce-menu .mce-menu-item b{font-weight:bold}.mce-menu-item-indent-1{padding-left:20px}.mce-menu-item-indent-2{padding-left:35px}.mce-menu-item-indent-2{padding-left:35px}.mce-menu-item-indent-3{padding-left:40px}.mce-menu-item-indent-4{padding-left:45px}.mce-menu-item-indent-5{padding-left:50px}.mce-menu-item-indent-6{padding-left:55px}.mce-menu.mce-rtl{direction:rtl}.mce-rtl .mce-menu-item{text-align:right;direction:rtl;padding:6px 12px 6px 15px}.mce-rtl .mce-menu-item .mce-caret{margin-left:6px;margin-right:0;border-right:4px solid #595959;border-left:0}.mce-rtl .mce-menu-item.mce-selected .mce-caret,.mce-rtl .mce-menu-item:focus .mce-caret,.mce-rtl .mce-menu-item:hover .mce-caret{border-left-color:transparent;border-right-color:#595959}.mce-rtl .mce-menu-item .mce-ico{padding-right:0;padding-left:4px}.mce-throbber{position:absolute;top:0;left:0;width:100%;height:100%;opacity:.6;filter:alpha(opacity=60);zoom:1;background:#fff url('img/loader.gif') no-repeat center center}.mce-throbber-inline{position:static;height:50px}.mce-menu .mce-throbber-inline{height:25px;background-size:contain}.mce-menu{position:absolute;left:0;top:0;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);background:transparent;z-index:1000;padding:5px 0 5px 0;margin:-1px 0 0;min-width:180px;background:white;border:1px solid #c5c9cf;border:1px solid #e2e4e7;z-index:1002;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);max-height:500px;overflow:auto;overflow-x:hidden}.mce-menu.mce-animate{opacity:.01;transform:rotateY(10deg) rotateX(-10deg);transform-origin:left top}.mce-menu.mce-menu-align .mce-menu-shortcut,.mce-menu.mce-menu-align .mce-caret{position:absolute;right:0}.mce-menu i{display:none}.mce-menu-has-icons i{display:inline-block}.mce-menu.mce-in.mce-animate{opacity:1;transform:rotateY(0) rotateX(0);transition:opacity .075s ease,transform .1s ease}.mce-menu-sub-tr-tl{margin:-6px 0 0 -1px}.mce-menu-sub-br-bl{margin:6px 0 0 -1px}.mce-menu-sub-tl-tr{margin:-6px 0 0 1px}.mce-menu-sub-bl-br{margin:6px 0 0 1px}.mce-rtl .mce-menu-item .mce-ico{padding-right:0;padding-left:4px}.mce-rtl.mce-menu-align .mce-caret,.mce-rtl .mce-menu-shortcut{right:auto;left:0}.mce-listbox button{text-align:left;padding-right:20px;position:relative}.mce-listbox .mce-caret{position:absolute;margin-top:-2px;right:8px;top:50%}.mce-rtl .mce-listbox .mce-caret{right:auto;left:8px}.mce-rtl .mce-listbox button{padding-right:10px;padding-left:20px}.mce-container-body .mce-resizehandle{position:absolute;right:0;bottom:0;width:16px;height:16px;visibility:visible;cursor:s-resize;margin:0}.mce-container-body .mce-resizehandle-both{cursor:se-resize}i.mce-i-resize{color:#595959}.mce-selectbox{background:#fff;border:1px solid #c5c5c5}.mce-slider{border:1px solid #c5c5c5;background:#fff;width:100px;height:10px;position:relative;display:block}.mce-slider.mce-vertical{width:10px;height:100px}.mce-slider-handle{border:1px solid #c5c5c5;background:#e6e6e6;display:block;width:13px;height:13px;position:absolute;top:0;left:0;margin-left:-1px;margin-top:-2px}.mce-slider-handle:focus{border-color:#2276d2}.mce-spacer{visibility:hidden}.mce-splitbtn:hover .mce-open{border-left:1px solid #e2e4e7}.mce-splitbtn .mce-open{border-left:1px solid transparent;padding-right:4px;padding-left:4px}.mce-splitbtn .mce-open:focus{border-left:1px solid #e2e4e7}.mce-splitbtn .mce-open:hover,.mce-splitbtn .mce-open:active{border-left:1px solid #e2e4e7}.mce-splitbtn.mce-active:hover .mce-open{border-left:1px solid white}.mce-splitbtn.mce-opened{border-color:#e2e4e7}.mce-splitbtn.mce-btn-small .mce-open{padding:0 3px 0 3px}.mce-rtl .mce-splitbtn{direction:rtl;text-align:right}.mce-rtl .mce-splitbtn button{padding-right:4px;padding-left:4px}.mce-rtl .mce-splitbtn .mce-open{border-left:0}.mce-stack-layout-item{display:block}.mce-tabs{display:block;border-bottom:1px solid #c5c5c5}.mce-tabs,.mce-tabs+.mce-container-body{background:#fff}.mce-tab{display:inline-block;*display:inline;*zoom:1;border:1px solid #c5c5c5;border-width:0 1px 0 0;background:#fff;padding:8px 15px;text-shadow:0 1px 1px rgba(255,255,255,0.75);height:13px;cursor:pointer}.mce-tab:hover{background:#FDFDFD}.mce-tab.mce-active{background:#FDFDFD;border-bottom-color:transparent;margin-bottom:-1px;height:14px}.mce-tab:focus{color:#2276d2}.mce-rtl .mce-tabs{text-align:right;direction:rtl}.mce-rtl .mce-tab{border-width:0 0 0 1px}.mce-textbox{background:#fff;border:1px solid #c5c5c5;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;display:inline-block;-webkit-transition:border linear .2s, box-shadow linear .2s;transition:border linear .2s, box-shadow linear .2s;height:28px;resize:none;padding:0 4px 0 4px;white-space:pre-wrap;*white-space:pre;color:#595959}.mce-textbox:focus,.mce-textbox.mce-focus{border-color:#2276d2;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.mce-placeholder .mce-textbox{color:#aaa}.mce-textbox.mce-multiline{padding:4px;height:auto}.mce-textbox.mce-disabled{color:#bdbdbd}.mce-rtl .mce-textbox{text-align:right;direction:rtl}.mce-dropzone{border:3px dashed gray;text-align:center}.mce-dropzone span{text-transform:uppercase;display:inline-block;vertical-align:middle}.mce-dropzone:after{content:"";height:100%;display:inline-block;vertical-align:middle}.mce-dropzone.mce-disabled{opacity:.4;filter:alpha(opacity=40);zoom:1}.mce-dropzone.mce-disabled.mce-dragenter{cursor:not-allowed}.mce-browsebutton{position:relative;overflow:hidden}.mce-browsebutton button{position:relative;z-index:1}.mce-browsebutton input{opacity:0;filter:alpha(opacity=0);zoom:1;position:absolute;top:0;left:0;width:100%;height:100%;z-index:0}@font-face{font-family:'tinymce';src:url('fonts/tinymce.eot');src:url('fonts/tinymce.eot?#iefix') format('embedded-opentype'),url('fonts/tinymce.woff') format('woff'),url('fonts/tinymce.ttf') format('truetype'),url('fonts/tinymce.svg#tinymce') format('svg');font-weight:normal;font-style:normal}@font-face{font-family:'tinymce-small';src:url('fonts/tinymce-small.eot');src:url('fonts/tinymce-small.eot?#iefix') format('embedded-opentype'),url('fonts/tinymce-small.woff') format('woff'),url('fonts/tinymce-small.ttf') format('truetype'),url('fonts/tinymce-small.svg#tinymce') format('svg');font-weight:normal;font-style:normal}.mce-ico{font-family:'tinymce',Arial;font-style:normal;font-weight:normal;font-variant:normal;font-size:16px;line-height:16px;speak:none;vertical-align:text-top;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:inline-block;background:transparent center center;background-size:cover;width:16px;height:16px;color:#595959}.mce-btn-small .mce-ico{font-family:'tinymce-small',Arial}.mce-i-save:before{content:"\e000"}.mce-i-newdocument:before{content:"\e001"}.mce-i-fullpage:before{content:"\e002"}.mce-i-alignleft:before{content:"\e003"}.mce-i-aligncenter:before{content:"\e004"}.mce-i-alignright:before{content:"\e005"}.mce-i-alignjustify:before{content:"\e006"}.mce-i-alignnone:before{content:"\e003"}.mce-i-cut:before{content:"\e007"}.mce-i-paste:before{content:"\e008"}.mce-i-searchreplace:before{content:"\e009"}.mce-i-bullist:before{content:"\e00a"}.mce-i-numlist:before{content:"\e00b"}.mce-i-indent:before{content:"\e00c"}.mce-i-outdent:before{content:"\e00d"}.mce-i-blockquote:before{content:"\e00e"}.mce-i-undo:before{content:"\e00f"}.mce-i-redo:before{content:"\e010"}.mce-i-link:before{content:"\e011"}.mce-i-unlink:before{content:"\e012"}.mce-i-anchor:before{content:"\e013"}.mce-i-image:before{content:"\e014"}.mce-i-media:before{content:"\e015"}.mce-i-help:before{content:"\e016"}.mce-i-code:before{content:"\e017"}.mce-i-insertdatetime:before{content:"\e018"}.mce-i-preview:before{content:"\e019"}.mce-i-forecolor:before{content:"\e01a"}.mce-i-backcolor:before{content:"\e01a"}.mce-i-table:before{content:"\e01b"}.mce-i-hr:before{content:"\e01c"}.mce-i-removeformat:before{content:"\e01d"}.mce-i-subscript:before{content:"\e01e"}.mce-i-superscript:before{content:"\e01f"}.mce-i-charmap:before{content:"\e020"}.mce-i-emoticons:before{content:"\e021"}.mce-i-print:before{content:"\e022"}.mce-i-fullscreen:before{content:"\e023"}.mce-i-spellchecker:before{content:"\e024"}.mce-i-nonbreaking:before{content:"\e025"}.mce-i-template:before{content:"\e026"}.mce-i-pagebreak:before{content:"\e027"}.mce-i-restoredraft:before{content:"\e028"}.mce-i-bold:before{content:"\e02a"}.mce-i-italic:before{content:"\e02b"}.mce-i-underline:before{content:"\e02c"}.mce-i-strikethrough:before{content:"\e02d"}.mce-i-visualchars:before{content:"\e02e"}.mce-i-visualblocks:before{content:"\e02e"}.mce-i-ltr:before{content:"\e02f"}.mce-i-rtl:before{content:"\e030"}.mce-i-copy:before{content:"\e031"}.mce-i-resize:before{content:"\e032"}.mce-i-browse:before{content:"\e034"}.mce-i-pastetext:before{content:"\e035"}.mce-i-rotateleft:before{content:"\eaa8"}.mce-i-rotateright:before{content:"\eaa9"}.mce-i-crop:before{content:"\ee78"}.mce-i-editimage:before{content:"\e915"}.mce-i-options:before{content:"\ec6a"}.mce-i-flipv:before{content:"\eaaa"}.mce-i-fliph:before{content:"\eaac"}.mce-i-zoomin:before{content:"\eb35"}.mce-i-zoomout:before{content:"\eb36"}.mce-i-sun:before{content:"\eccc"}.mce-i-moon:before{content:"\eccd"}.mce-i-arrowleft:before{content:"\edc0"}.mce-i-arrowright:before{content:"\e93c"}.mce-i-drop:before{content:"\e935"}.mce-i-contrast:before{content:"\ecd4"}.mce-i-sharpen:before{content:"\eba7"}.mce-i-resize2:before{content:"\edf9"}.mce-i-orientation:before{content:"\e601"}.mce-i-invert:before{content:"\e602"}.mce-i-gamma:before{content:"\e600"}.mce-i-remove:before{content:"\ed6a"}.mce-i-tablerowprops:before{content:"\e604"}.mce-i-tablecellprops:before{content:"\e605"}.mce-i-table2:before{content:"\e606"}.mce-i-tablemergecells:before{content:"\e607"}.mce-i-tableinsertcolbefore:before{content:"\e608"}.mce-i-tableinsertcolafter:before{content:"\e609"}.mce-i-tableinsertrowbefore:before{content:"\e60a"}.mce-i-tableinsertrowafter:before{content:"\e60b"}.mce-i-tablesplitcells:before{content:"\e60d"}.mce-i-tabledelete:before{content:"\e60e"}.mce-i-tableleftheader:before{content:"\e62a"}.mce-i-tabletopheader:before{content:"\e62b"}.mce-i-tabledeleterow:before{content:"\e800"}.mce-i-tabledeletecol:before{content:"\e801"}.mce-i-codesample:before{content:"\e603"}.mce-i-fill:before{content:"\e902"}.mce-i-borderwidth:before{content:"\e903"}.mce-i-line:before{content:"\e904"}.mce-i-count:before{content:"\e905"}.mce-i-translate:before{content:"\e907"}.mce-i-drag:before{content:"\e908"}.mce-i-home:before{content:"\e90b"}.mce-i-upload:before{content:"\e914"}.mce-i-bubble:before{content:"\e91c"}.mce-i-user:before{content:"\e91d"}.mce-i-lock:before{content:"\e926"}.mce-i-unlock:before{content:"\e927"}.mce-i-settings:before{content:"\e928"}.mce-i-remove2:before{content:"\e92a"}.mce-i-menu:before{content:"\e92d"}.mce-i-warning:before{content:"\e930"}.mce-i-question:before{content:"\e931"}.mce-i-pluscircle:before{content:"\e932"}.mce-i-info:before{content:"\e933"}.mce-i-notice:before{content:"\e934"}.mce-i-arrowup:before{content:"\e93b"}.mce-i-arrowdown:before{content:"\e93d"}.mce-i-arrowup2:before{content:"\e93f"}.mce-i-arrowdown2:before{content:"\e940"}.mce-i-menu2:before{content:"\e941"}.mce-i-newtab:before{content:"\e961"}.mce-i-a11y:before{content:"\e900"}.mce-i-plus:before{content:"\e93a"}.mce-i-insert:before{content:"\e93a"}.mce-i-minus:before{content:"\e939"}.mce-i-books:before{content:"\e911"}.mce-i-reload:before{content:"\e906"}.mce-i-toc:before{content:"\e901"}.mce-i-checkmark:before{content:"\e033"}.mce-i-format-painter:before{content:"\e909"}.mce-i-checkbox:before,.mce-i-selected:before{content:"\e033"}.mce-i-insert{font-size:14px}.mce-i-selected{visibility:hidden}i.mce-i-backcolor{text-shadow:none;background:#BBB}.mce-rtl .mce-filepicker input{direction:ltr}/*# sourceMappingURL=skin.min.css.map */ \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/inlite/theme.js b/wp-includes/js/tinymce/themes/inlite/theme.js index 38af088620..4f6c4fd8d1 100644 --- a/wp-includes/js/tinymce/themes/inlite/theme.js +++ b/wp-includes/js/tinymce/themes/inlite/theme.js @@ -1,10018 +1,5318 @@ (function () { var inlite = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.ThemeManager'); + var global = tinymce.util.Tools.resolve('tinymce.ThemeManager'); - var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); + var global$1 = tinymce.util.Tools.resolve('tinymce.Env'); - var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); + var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils'); - var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay'); + var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay'); - var flatten = function (arr) { - return arr.reduce(function (results, item) { - return Array.isArray(item) ? results.concat(flatten(item)) : results.concat(item); - }, []); - }; - var $_ccn98l17xjjgwejz7 = { flatten: flatten }; - - var result = function (id, rect) { - return { - id: id, - rect: rect + var flatten = function (arr) { + return arr.reduce(function (results, item) { + return Array.isArray(item) ? results.concat(flatten(item)) : results.concat(item); + }, []); }; - }; - var match = function (editor, matchers) { - for (var i = 0; i < matchers.length; i++) { - var f = matchers[i]; - var result_1 = f(editor); - if (result_1) { - return result_1; + var DeepFlatten = { flatten: flatten }; + + var result = function (id, rect) { + return { + id: id, + rect: rect + }; + }; + var match = function (editor, matchers) { + for (var i = 0; i < matchers.length; i++) { + var f = matchers[i]; + var result_1 = f(editor); + if (result_1) { + return result_1; + } } - } - return null; - }; - var $_6lg87517zjjgwejza = { - match: match, - result: result - }; - - var fromClientRect = function (clientRect) { - return { - x: clientRect.left, - y: clientRect.top, - w: clientRect.width, - h: clientRect.height + return null; }; - }; - 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 Matcher = { + match: match, + result: result }; - }; - var $_1x174x181jjgwejzd = { - fromClientRect: fromClientRect, - toClientRect: toClientRect - }; - var toAbsolute = function (rect) { - var vp = global$2.DOM.getViewPort(); - return { - x: rect.x + vp.x, - y: rect.y + vp.y, - w: rect.w, - h: rect.h + var fromClientRect = function (clientRect) { + return { + x: clientRect.left, + y: clientRect.top, + w: clientRect.width, + h: clientRect.height + }; + }; + 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 Convert = { + fromClientRect: fromClientRect, + toClientRect: toClientRect }; - }; - var measureElement = function (elm) { - var clientRect = elm.getBoundingClientRect(); - return toAbsolute({ - x: clientRect.left, - y: clientRect.top, - w: Math.max(elm.clientWidth, elm.offsetWidth), - h: Math.max(elm.clientHeight, elm.offsetHeight) - }); - }; - var getElementRect = function (editor, elm) { - return measureElement(elm); - }; - var getPageAreaRect = function (editor) { - return measureElement(editor.getElement().ownerDocument.body); - }; - var getContentAreaRect = function (editor) { - return measureElement(editor.getContentAreaContainer() || editor.getBody()); - }; - var getSelectionRect = function (editor) { - var clientRect = editor.selection.getBoundingClientRect(); - return clientRect ? toAbsolute($_1x174x181jjgwejzd.fromClientRect(clientRect)) : null; - }; - var $_51qgo2180jjgwejzb = { - getElementRect: getElementRect, - getPageAreaRect: getPageAreaRect, - getContentAreaRect: getContentAreaRect, - getSelectionRect: getSelectionRect - }; - var element = function (element, predicateIds) { - return function (editor) { - for (var i = 0; i < predicateIds.length; i++) { - if (predicateIds[i].predicate(element)) { - var result = $_6lg87517zjjgwejza.result(predicateIds[i].id, $_51qgo2180jjgwejzb.getElementRect(editor, element)); + var toAbsolute = function (rect) { + var vp = global$2.DOM.getViewPort(); + return { + x: rect.x + vp.x, + y: rect.y + vp.y, + w: rect.w, + h: rect.h + }; + }; + var measureElement = function (elm) { + var clientRect = elm.getBoundingClientRect(); + return toAbsolute({ + x: clientRect.left, + y: clientRect.top, + w: Math.max(elm.clientWidth, elm.offsetWidth), + h: Math.max(elm.clientHeight, elm.offsetHeight) + }); + }; + var getElementRect = function (editor, elm) { + return measureElement(elm); + }; + var getPageAreaRect = function (editor) { + return measureElement(editor.getElement().ownerDocument.body); + }; + var getContentAreaRect = function (editor) { + return measureElement(editor.getContentAreaContainer() || editor.getBody()); + }; + var getSelectionRect = function (editor) { + var clientRect = editor.selection.getBoundingClientRect(); + return clientRect ? toAbsolute(Convert.fromClientRect(clientRect)) : null; + }; + var Measure = { + getElementRect: getElementRect, + getPageAreaRect: getPageAreaRect, + getContentAreaRect: getContentAreaRect, + getSelectionRect: getSelectionRect + }; + + var element = function (element, predicateIds) { + return function (editor) { + for (var i = 0; i < predicateIds.length; i++) { + if (predicateIds[i].predicate(element)) { + var result = Matcher.result(predicateIds[i].id, Measure.getElementRect(editor, element)); + return result; + } + } + return null; + }; + }; + var parent = function (elements, predicateIds) { + return function (editor) { + for (var i = 0; i < elements.length; i++) { + for (var x = 0; x < predicateIds.length; x++) { + if (predicateIds[x].predicate(elements[i])) { + return Matcher.result(predicateIds[x].id, Measure.getElementRect(editor, elements[i])); + } + } + } + return null; + }; + }; + var ElementMatcher = { + element: element, + parent: parent + }; + + var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + + var create = function (id, predicate) { + return { + id: id, + predicate: predicate + }; + }; + var fromContextToolbars = function (toolbars) { + return global$4.map(toolbars, function (toolbar) { + return create(toolbar.id, toolbar.predicate); + }); + }; + var PredicateId = { + create: create, + fromContextToolbars: fromContextToolbars + }; + + var textSelection = function (id) { + return function (editor) { + if (!editor.selection.isCollapsed()) { + var result = Matcher.result(id, Measure.getSelectionRect(editor)); return result; } - } - return null; + return null; + }; }; - }; - var parent = function (elements, predicateIds) { - return function (editor) { - for (var i = 0; i < elements.length; i++) { - for (var x = 0; x < predicateIds.length; x++) { - if (predicateIds[x].predicate(elements[i])) { - return $_6lg87517zjjgwejza.result(predicateIds[x].id, $_51qgo2180jjgwejzb.getElementRect(editor, elements[i])); + var emptyTextBlock = function (elements, id) { + return function (editor) { + var i; + var textBlockElementsMap = editor.schema.getTextBlockElements(); + for (i = 0; i < elements.length; i++) { + if (elements[i].nodeName === 'TABLE') { + return null; } } - } - return null; - }; - }; - var $_egsucq17yjjgwejz9 = { - element: element, - parent: parent - }; - - var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools'); - - var create = function (id, predicate) { - return { - id: id, - predicate: predicate - }; - }; - var fromContextToolbars = function (toolbars) { - return global$4.map(toolbars, function (toolbar) { - return create(toolbar.id, toolbar.predicate); - }); - }; - var $_9rj8kx182jjgwejze = { - create: create, - fromContextToolbars: fromContextToolbars - }; - - var textSelection = function (id) { - return function (editor) { - if (!editor.selection.isCollapsed()) { - var result = $_6lg87517zjjgwejza.result(id, $_51qgo2180jjgwejzb.getSelectionRect(editor)); - return result; - } - return null; - }; - }; - var emptyTextBlock = function (elements, id) { - return function (editor) { - var i; - var textBlockElementsMap = editor.schema.getTextBlockElements(); - for (i = 0; i < elements.length; i++) { - if (elements[i].nodeName === 'TABLE') { - return null; - } - } - for (i = 0; i < elements.length; i++) { - if (elements[i].nodeName in textBlockElementsMap) { - if (editor.dom.isEmpty(elements[i])) { - return $_6lg87517zjjgwejza.result(id, $_51qgo2180jjgwejzb.getSelectionRect(editor)); + for (i = 0; i < elements.length; i++) { + if (elements[i].nodeName in textBlockElementsMap) { + if (editor.dom.isEmpty(elements[i])) { + return Matcher.result(id, Measure.getSelectionRect(editor)); + } + return null; } - return null; } + return null; + }; + }; + var SelectionMatcher = { + textSelection: textSelection, + emptyTextBlock: emptyTextBlock + }; + + var fireSkinLoaded = function (editor) { + editor.fire('SkinLoaded'); + }; + var fireBeforeRenderUI = function (editor) { + return editor.fire('BeforeRenderUI'); + }; + var Events = { + fireSkinLoaded: fireSkinLoaded, + fireBeforeRenderUI: fireBeforeRenderUI + }; + + var global$5 = tinymce.util.Tools.resolve('tinymce.EditorManager'); + + var isType = function (type) { + return function (value) { + return typeof value === type; + }; + }; + var isArray = function (value) { + return Array.isArray(value); + }; + var isNull = function (value) { + return value === null; + }; + var isObject = function (predicate) { + return function (value) { + return !isNull(value) && !isArray(value) && predicate(value); + }; + }; + var isString = function (value) { + return isType('string')(value); + }; + var isNumber = function (value) { + return isType('number')(value); + }; + var isFunction = function (value) { + return isType('function')(value); + }; + var isBoolean = function (value) { + return isType('boolean')(value); + }; + var Type = { + isString: isString, + isNumber: isNumber, + isBoolean: isBoolean, + isFunction: isFunction, + isObject: isObject(isType('object')), + isNull: isNull, + isArray: isArray + }; + + var validDefaultOrDie = function (value, predicate) { + if (predicate(value)) { + return true; } - return null; + throw new Error('Default value doesn\'t match requested type.'); + }; + var getByTypeOr = function (predicate) { + return function (editor, name, defaultValue) { + var settings = editor.settings; + validDefaultOrDie(defaultValue, predicate); + return name in settings && predicate(settings[name]) ? settings[name] : defaultValue; + }; + }; + var splitNoEmpty = function (str, delim) { + return str.split(delim).filter(function (item) { + return item.length > 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 $_fhwgeg184jjgwejzf = { - textSelection: textSelection, - emptyTextBlock: emptyTextBlock - }; - var fireSkinLoaded = function (editor) { - editor.fire('SkinLoaded'); - }; - var fireBeforeRenderUI = function (editor) { - return editor.fire('BeforeRenderUI'); - }; - var $_77u64d186jjgwejzi = { - fireSkinLoaded: fireSkinLoaded, - fireBeforeRenderUI: fireBeforeRenderUI - }; + var global$6 = tinymce.util.Tools.resolve('tinymce.geom.Rect'); - var global$5 = tinymce.util.Tools.resolve('tinymce.EditorManager'); - - var isType = function (type) { - return function (value) { - return typeof value === type; + var result$1 = function (rect, position) { + return { + rect: rect, + position: position + }; }; - }; - var isArray = function (value) { - return Array.isArray(value); - }; - var isNull = function (value) { - return value === null; - }; - var isObject = function (predicate) { - return function (value) { - return !isNull(value) && !isArray(value) && predicate(value); + var moveTo = function (rect, toRect) { + return { + x: toRect.x, + y: toRect.y, + w: rect.w, + h: rect.h + }; }; - }; - var isString = function (value) { - return isType('string')(value); - }; - var isNumber = function (value) { - return isType('number')(value); - }; - var isFunction = function (value) { - return isType('function')(value); - }; - var isBoolean = function (value) { - return isType('boolean')(value); - }; - var $_e4npq318ajjgwejzo = { - isString: isString, - isNumber: isNumber, - isBoolean: isBoolean, - isFunction: isFunction, - isObject: isObject(isType('object')), - isNull: isNull, - isArray: isArray - }; - - var validDefaultOrDie = function (value, predicate) { - if (predicate(value)) { - return true; - } - throw new Error('Default value doesn\'t match requested type.'); - }; - var getByTypeOr = function (predicate) { - return function (editor, name, defaultValue) { - var settings = editor.settings; - validDefaultOrDie(defaultValue, predicate); - return name in settings && predicate(settings[name]) ? settings[name] : defaultValue; - }; - }; - var splitNoEmpty = function (str, delim) { - return str.split(delim).filter(function (item) { - return item.length > 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 ($_e4npq318ajjgwejzo.isArray(value)) { - return value; - } else if ($_e4npq318ajjgwejzo.isString(value)) { - return stringToItemsArray(value); - } else if ($_e4npq318ajjgwejzo.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 $_c8umh189jjgwejzm = { - getStringOr: getByTypeOr($_e4npq318ajjgwejzo.isString), - getBoolOr: getByTypeOr($_e4npq318ajjgwejzo.isBoolean), - getNumberOr: getByTypeOr($_e4npq318ajjgwejzo.isNumber), - getHandlerOr: getByTypeOr($_e4npq318ajjgwejzo.isFunction), - getToolbarItemsOr: getToolbarItemsOr($_e4npq318ajjgwejzo.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); + 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); } - 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: $_1x174x181jjgwejzd.toClientRect(targetRect), - contentAreaRect: $_1x174x181jjgwejzd.toClientRect(contentAreaRect), - panelRect: $_1x174x181jjgwejzd.toClientRect(panelRect) - }); - return $_1x174x181jjgwejzd.fromClientRect(userConstrainedPanelRect); - } - return panelRect; - }; - var defaultHandler = function (rects) { - return rects.panelRect; - }; - var $_gir42l18bjjgwejzq = { - 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 $_c8umh189jjgwejzm.getToolbarItemsOr(editor, 'selection_toolbar', [ - 'bold', - 'italic', - '|', - 'quicklink', - 'h2', - 'h3', - 'blockquote' - ]); - }; - var getInsertToolbarItems = function (editor) { - return $_c8umh189jjgwejzm.getToolbarItemsOr(editor, 'insert_toolbar', [ - 'quickimage', - 'quicktable' - ]); - }; - var getPositionHandler = function (editor) { - return $_c8umh189jjgwejzm.getHandlerOr(editor, 'inline_toolbar_position_handler', $_gir42l18bjjgwejzq.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 $_4j2h42187jjgwejzk = { - getTextSelectionToolbarItems: getTextSelectionToolbarItems, - getInsertToolbarItems: getInsertToolbarItems, - getPositionHandler: getPositionHandler, - getSkinUrl: getSkinUrl, - isSkinDisabled: isSkinDisabled - }; - - var fireSkinLoaded$1 = function (editor, callback) { - var done = function () { - editor._skinLoaded = true; - $_77u64d186jjgwejzi.fireSkinLoaded(editor); - callback(); - }; - if (editor.initialized) { - done(); - } else { - editor.on('init', done); - } - }; - var load = function (editor, callback) { - var skinUrl = $_4j2h42187jjgwejzk.getSkinUrl(editor); - var done = function () { - fireSkinLoaded$1(editor, callback); - }; - if ($_4j2h42187jjgwejzk.isSkinDisabled(editor)) { - done(); - } else { - global$2.DOM.styleSheetLoader.load(skinUrl + '/skin.min.css', done); - editor.contentCSS.push(skinUrl + '/content.inline.min.css'); - } - }; - var $_93v08q185jjgwejzh = { 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 $_ccn98l17xjjgwejz7.flatten([ - contextToolbars ? contextToolbars : [], - createToolbar(editor, 'img', 'image', 'alignleft aligncenter alignright') - ]); - }; - var findMatchResult = function (editor, toolbars) { - var result, elements, contextToolbarsPredicateIds; - elements = getSelectionElements(editor); - contextToolbarsPredicateIds = $_9rj8kx182jjgwejze.fromContextToolbars(toolbars); - result = $_6lg87517zjjgwejza.match(editor, [ - $_egsucq17yjjgwejz9.element(elements[0], contextToolbarsPredicateIds), - $_fhwgeg184jjgwejzf.textSelection('text'), - $_fhwgeg184jjgwejzf.emptyTextBlock(elements, 'insert'), - $_egsucq17yjjgwejz9.parent(elements, contextToolbarsPredicateIds) - ]); - return result && result.rect ? result : null; - }; - var editorHasFocus = function (editor) { - return 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(); + 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 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 = $_6lg87517zjjgwejza.match(editor, [$_fhwgeg184jjgwejzf.textSelection('quicklink')]); - if (result) { - panel.show(editor, result.id, result.rect, toolbars); - } - }); - }; - var renderInlineUI = function (editor, panel) { - $_93v08q185jjgwejzh.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 $_b0wxh217tjjgwejyx = { renderUI: renderUI }; - - var noop = function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; - } - }; - - var compose = function (fa, fb) { - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; - } - return fa(fb.apply(null, arguments)); - }; - }; - var constant = function (value) { - return function () { - return value; - }; - }; - - - var curry = function (f) { - var x = []; - for (var _i = 1; _i < arguments.length; _i++) { - x[_i - 1] = arguments[_i]; - } - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) - args[i - 1] = arguments[i]; - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; - } - var newArgs = new Array(arguments.length); - for (var j = 0; j < newArgs.length; j++) - newArgs[j] = arguments[j]; - var all = args.concat(newArgs); - return f.apply(null, all); - }; - }; - - - - - var never = constant(false); - var always = constant(true); - - var never$1 = never; - var always$1 = always; - var none = function () { - return NONE; - }; - var NONE = function () { - var eq = function (o) { - return o.isNone(); - }; - var call$$1 = function (thunk) { - return thunk(); - }; - var id = function (n) { - return n; - }; - var noop$$1 = function () { - }; - var nul = function () { return null; }; - var undef = function () { - return undefined; + var calcInsert = function (targetRect, contentAreaRect, panelRect) { + return calcByPositions([ + 'cr-cl', + 'cl-cr' + ], [ + 'bc-tc', + 'bl-tl', + 'br-tr' + ], targetRect, contentAreaRect, panelRect); }; - var me = { - fold: function (n, s) { - return n(); - }, - is: never$1, - isSome: never$1, - isNone: always$1, - getOr: id, - getOrThunk: call$$1, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: nul, - getOrUndefined: undef, - or: id, - orThunk: call$$1, - map: none, - ap: none, - each: noop$$1, - bind: none, - flatten: none, - exists: never$1, - forall: always$1, - filter: none, - equals: eq, - equals_: eq, - toArray: function () { - return []; - }, - toString: constant('none()') + 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); }; - if (Object.freeze) - Object.freeze(me); - return me; - }(); - var some = function (a) { - var constant_a = function () { - return a; + 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 self = function () { + 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 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 args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + }; + var constant = function (value) { + return function () { + return value; + }; + }; + var never = constant(false); + var always = constant(true); + + var never$1 = never; + var always$1 = always; + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call$$1 = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var noop$$1 = function () { + }; + var nul = function () { + return null; + }; + var undef = function () { + return undefined; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never$1, + isSome: never$1, + isNone: always$1, + getOr: id, + getOrThunk: call$$1, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: nul, + getOrUndefined: undef, + or: id, + orThunk: call$$1, + map: none, + ap: none, + each: noop$$1, + bind: none, + flatten: none, + exists: never$1, + forall: always$1, + 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 = function () { + return a; + }; + var self = function () { + return me; + }; + var map = function (f) { + return some(f(a)); + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always$1, + isNone: never$1, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: map, + ap: function (optfab) { + return optfab.fold(none, function (fab) { + return some(fab(a)); + }); + }, + each: function (f) { + f(a); + }, + bind: bind, + flatten: constant_a, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never$1, function (b) { + return elementEq(a, b); + }); + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + } + }; return me; }; - var map = function (f) { - return some(f(a)); + var from = function (value) { + return value === null || value === undefined ? NONE : some(value); }; - var bind = function (f) { - return f(a); + var Option = { + some: some, + none: none, + from: from }; - var me = { - fold: function (n, s) { - return s(a); - }, - is: function (v) { - return a === v; - }, - isSome: always$1, - isNone: never$1, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: map, - ap: function (optfab) { - return optfab.fold(none, function (fab) { - return some(fab(a)); - }); - }, - each: function (f) { - f(a); - }, - bind: bind, - flatten: constant_a, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - equals: function (o) { - return o.is(a); - }, - equals_: function (o, elementEq) { - return o.fold(never$1, function (b) { - return elementEq(a, b); - }); - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } + + var typeOf = function (x) { + if (x === null) + return 'null'; + var t = typeof x; + if (t === 'object' && Array.prototype.isPrototypeOf(x)) + return 'array'; + if (t === 'object' && String.prototype.isPrototypeOf(x)) + return 'string'; + return t; }; - 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)) - return 'array'; - if (t === 'object' && String.prototype.isPrototypeOf(x)) - return 'string'; - return t; - }; - var isType$1 = function (type) { - return function (value) { - return typeOf(value) === type; - }; - }; - - - - - - - var isFunction$1 = isType$1('function'); - var isNumber$1 = isType$1('number'); - - var rawIndexOf = function () { - var pIndexOf = Array.prototype.indexOf; - var fastIndex = function (xs, x) { - return pIndexOf.call(xs, x); - }; - var slowIndex = function (xs, x) { - return slowIndexOf(xs, x); - }; - return pIndexOf === undefined ? slowIndex : fastIndex; - }(); - var indexOf = function (xs, x) { - var r = rawIndexOf(xs, x); - return r === -1 ? Option.none() : Option.some(r); - }; - - var exists = function (xs, pred) { - return findIndex(xs, pred).isSome(); - }; - - - 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, xs); - } - return r; - }; - var each = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i, xs); - } - }; - - - 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, xs)) { - 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, xs)) { - 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, xs)) { - return Option.some(i); - } - } - return Option.none(); - }; - var slowIndexOf = function (xs, x) { - for (var i = 0, len = xs.length; i < len; ++i) { - if (xs[i] === x) { - return i; - } - } - return -1; - }; - var push = Array.prototype.push; - var flatten$1 = function (xs) { - var r = []; - for (var i = 0, len = xs.length; i < len; ++i) { - if (!Array.prototype.isPrototypeOf(xs[i])) - throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); - push.apply(r, xs[i]); - } - return r; - }; - - - - var slice = Array.prototype.slice; - var reverse = function (xs) { - var r = slice.call(xs, 0); - r.reverse(); - return r; - }; - - - - - - - var from$1 = isFunction$1(Array.from) ? Array.from : function (x) { - return slice.call(x); - }; - - var count = 0; - var funcs = { - id: function () { - return 'mceu_' + count++; - }, - create: function (name$$1, attrs, children) { - var elm = document.createElement(name$$1); - 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 + var isType$1 = function (type) { + return function (value) { + return typeOf(value) === type; }; - }, - getPos: function (elm, root) { - return global$2.DOM.getPos(elm, root || funcs.getContainer()); - }, - getContainer: function () { - return global$1.container ? global$1.container : document.body; - }, - getViewPort: function (win) { - return global$2.DOM.getViewPort(win); - }, - get: function (id) { - return 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$$1, value) { - return global$2.DOM.setStyle(elm, name$$1, value); - }, - getRuntimeStyle: function (elm, name$$1) { - return global$2.DOM.getStyle(elm, name$$1, true); - }, - on: function (target, name$$1, callback, scope) { - return global$2.DOM.bind(target, name$$1, callback, scope); - }, - off: function (target, name$$1, callback) { - return global$2.DOM.unbind(target, name$$1, callback); - }, - fire: function (target, name$$1, args) { - return global$2.DOM.fire(target, name$$1, args); - }, - innerHtml: function (elm, html) { - global$2.DOM.setHTML(elm, html); - } - }; + }; + var isFunction$1 = isType$1('function'); + var isNumber$1 = isType$1('number'); - 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 $_4kbuyt18pjjgwek1w = { - parseBox: function (value) { - var len; - var radix = 10; - if (!value) { - return; + var rawIndexOf = function () { + var pIndexOf = Array.prototype.indexOf; + var fastIndex = function (xs, x) { + return pIndexOf.call(xs, x); + }; + var slowIndex = function (xs, x) { + return slowIndexOf(xs, x); + }; + return pIndexOf === undefined ? slowIndex : fastIndex; + }(); + var indexOf = function (xs, x) { + var r = rawIndexOf(xs, x); + return r === -1 ? Option.none() : Option.some(r); + }; + var exists = function (xs, pred) { + return findIndex(xs, pred).isSome(); + }; + 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, xs); } - if (typeof value === 'number') { - value = value || 0; + return r; + }; + var each = function (xs, f) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + f(x, i, xs); + } + }; + 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, xs)) { + 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, xs)) { + 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, xs)) { + return Option.some(i); + } + } + return Option.none(); + }; + var slowIndexOf = function (xs, x) { + for (var i = 0, len = xs.length; i < len; ++i) { + if (xs[i] === x) { + return i; + } + } + return -1; + }; + var push = Array.prototype.push; + var flatten$1 = function (xs) { + var r = []; + for (var i = 0, len = xs.length; i < len; ++i) { + if (!Array.prototype.isPrototypeOf(xs[i])) + throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); + push.apply(r, xs[i]); + } + return r; + }; + var slice = Array.prototype.slice; + var from$1 = isFunction$1(Array.from) ? Array.from : function (x) { + return slice.call(x); + }; + + var count = 0; + var funcs = { + id: function () { + return 'mceu_' + count++; + }, + create: function (name$$1, attrs, children) { + var elm = document.createElement(name$$1); + 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 { - top: value, - left: value, - bottom: value, - right: value + 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 : document.body; + }, + getViewPort: function (win) { + return global$2.DOM.getViewPort(win); + }, + get: function (id) { + return 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$$1, value) { + return global$2.DOM.setStyle(elm, name$$1, value); + }, + getRuntimeStyle: function (elm, name$$1) { + return global$2.DOM.getStyle(elm, name$$1, true); + }, + on: function (target, name$$1, callback, scope) { + return global$2.DOM.bind(target, name$$1, callback, scope); + }, + off: function (target, name$$1, callback) { + return global$2.DOM.unbind(target, name$$1, callback); + }, + fire: function (target, name$$1, args) { + return global$2.DOM.fire(target, name$$1, 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') }; } - 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); + function noop$1() { } - }); - ClassList.prototype.toString = function () { - var value; - if (this.clsValue) { - return this.clsValue; + function ClassList(onchange) { + this.cls = []; + this.cls._map = {}; + this.onchange = onchange || noop$1; + this.prefix = ''; } - 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; - }; + global$4.extend(ClassList.prototype, { + add: function (cls) { + if (cls && !this.contains(cls)) { + this.cls._map[cls] = true; + this.cls.push(cls); + this._change(); } - } - 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]; + 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; } } - } while (matches); - if (extra) { - parseChunks(extra, selectors); + this.cls.splice(i, 1); + delete this.cls._map[cls]; + this._change(); } - selector = []; - for (i = 0; i < parts.length; i++) { - if (parts[i] !== '>') { - selector.push(compile(parts[i], [], parts[i - 1] === '>')); + 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; + }; } } - 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) { + 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, index, length)) { + if (!filters[fi](item, i, l)) { fi = fl + 1; break; } } if (fi === fl) { - count++; - break; - } else { - if (si === sl - 1) { - break; + if (index === selector.length - 1) { + matches.push(item); + } else { + if (item.items) { + collect(item.items(), selector, index + 1); + } } + } else if (filters.direct) { + return; } - 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 (item.items) { + collect(item.items(), selector, index); } } - 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 (container.items) { + for (i = 0, l = selectors.length; i < l; i++) { + collect(container.items(), selectors[i], 0); } - if (item.items) { - collect(item.items(), selector, index); + if (l > 1) { + matches = unique(matches); } } - } - 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); } - if (!Collection) { - Collection = Selector.Collection; - } - return new Collection(matches); - } - }); + }); - var Collection$1; - var proto; - var push$1 = Array.prototype.push; - var slice$1 = 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()); + var Collection$1, proto; + var push$1 = Array.prototype.push, slice$1 = 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$1.call(self, items); + } } else { - push$1.call(self, items); + push$1.apply(self, items); } - } else { - push$1.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 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 new Collection$1(matches); - }, - slice: function () { - return new Collection$1(slice$1.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 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; } - } - 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) { + 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$1.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](value); + item[name].apply(item, args); } }); 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$10 = 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$10], - 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]); + }, + 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); + }); } - 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 = {}; - var animationFrameRequested; - var $_cqjgb518wjjgwek2f = { - add: function (ctrl) { - var parent$$1 = ctrl.parent(); - if (parent$$1) { - if (!parent$$1._layout || parent$$1._layout.isNative()) { - return; - } - if (!dirtyCtrls[parent$$1._id]) { - dirtyCtrls[parent$$1._id] = parent$$1; - } - 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 = {}; - }, 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 $_egt6ye18xjjgwek2h = { - getUiContainerDelta: getUiContainerDelta, - setUiContainer: setUiContainer, - getUiContainer: getUiContainer, - inheritUiContainer: inheritUiContainer - }; - - var hasMouseWheelEventSupport = 'onmousewheel' in document; - var hasWheelEventSupport = false; - var classPrefix = 'mce-'; - var Control; - var idCounter = 0; - var proto$1 = { - Statics: { classPrefix: classPrefix }, - isRtl: function () { - return Control.rtl; - }, - classPrefix: classPrefix, - init: function (settings) { - var self$$1 = this; - var classes, defaultClasses; - function applyClasses(classes) { - var i; - classes = classes.split(' '); - for (i = 0; i < classes.length; i++) { - self$$1.classes.add(classes[i]); - } - } - self$$1.settings = settings = global$4.extend({}, self$$1.Defaults, settings); - self$$1._id = settings.id || 'mceu_' + idCounter++; - self$$1._aria = { role: settings.role }; - self$$1._elmCache = {}; - self$$1.$ = global$7; - self$$1.state = new ObservableObject({ - visible: true, - active: false, - disabled: false, - value: '' - }); - self$$1.data = new ObservableObject(settings.data); - self$$1.classes = new ClassList(function () { - if (self$$1.state.get('rendered')) { - self$$1.getEl().className = this.toString(); - } - }); - self$$1.classes.prefix = self$$1.classPrefix; - classes = settings.classes; - if (classes) { - if (self$$1.Defaults) { - defaultClasses = self$$1.Defaults.classes; - if (defaultClasses && classes !== defaultClasses) { - applyClasses(defaultClasses); + }; + 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); } - } - applyClasses(classes); - } - global$4.each('title text name visible disabled active value'.split(' '), function (name$$1) { - if (name$$1 in settings) { - self$$1[name$$1](settings[name$$1]); - } - }); - self$$1.on('click', function () { - if (self$$1.disabled()) { - return false; - } - }); - self$$1.settings = settings; - self$$1.borderBox = $_4kbuyt18pjjgwek1w.parseBox(settings.border); - self$$1.paddingBox = $_4kbuyt18pjjgwek1w.parseBox(settings.padding); - self$$1.marginBox = $_4kbuyt18pjjgwek1w.parseBox(settings.margin); - if (settings.hidden) { - self$$1.hide(); - } - }, - Properties: 'parent,name', - getContainerElm: function () { - var uiContainer = $_egt6ye18xjjgwek2h.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$$1 = this; - var settings = self$$1.settings; - var borderBox, layoutRect; - var elm = self$$1.getEl(); - var width, height, minWidth, minHeight, autoResize; - var startMinWidth, startMinHeight, initialSize; - borderBox = self$$1.borderBox = self$$1.borderBox || $_4kbuyt18pjjgwek1w.measureBox(elm, 'border'); - self$$1.paddingBox = self$$1.paddingBox || $_4kbuyt18pjjgwek1w.measureBox(elm, 'padding'); - self$$1.marginBox = self$$1.marginBox || $_4kbuyt18pjjgwek1w.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$$1._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 + }); + return this; }; - self$$1._lastLayoutRect = {}; - return layoutRect; - }, - layoutRect: function (newRect) { - var self$$1 = this; - var curRect = self$$1._layoutRect, lastLayoutRect, size, deltaWidth, deltaHeight, repaintControls; - if (!curRect) { - curRect = self$$1.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$$1._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$$1._id]) { - repaintControls.push(self$$1); - repaintControls.map[self$$1._id] = true; - } - } - lastLayoutRect.x = curRect.x; - lastLayoutRect.y = curRect.y; - lastLayoutRect.w = curRect.w; - lastLayoutRect.h = curRect.h; - } - return self$$1; - } - return curRect; - }, - repaint: function () { - var self$$1 = this; - var style, bodyStyle, bodyElm, rect, borderBox; - var borderW, borderH, lastRepaintRect, round, value; - round = !document.createRange ? Math.round : function (value) { - return value; + }); + 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); }; - style = self$$1.getEl().style; - rect = self$$1._layoutRect; - lastRepaintRect = self$$1._lastRepaintRect || {}; - borderBox = self$$1.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$$1._hasBody && rect.innerW !== lastRepaintRect.innerW) { - value = round(rect.innerW); - bodyElm = self$$1.getEl('body'); - if (bodyElm) { - bodyStyle = bodyElm.style; - bodyStyle.width = (value >= 0 ? value : 0) + 'px'; - } - lastRepaintRect.innerW = rect.innerW; - } - if (self$$1._hasBody && rect.innerH !== lastRepaintRect.innerH) { - value = round(rect.innerH); - bodyElm = bodyElm || self$$1.getEl('body'); - if (bodyElm) { - bodyStyle = bodyStyle || bodyElm.style; - bodyStyle.height = (value >= 0 ? value : 0) + 'px'; - } - lastRepaintRect.innerH = rect.innerH; - } - self$$1._lastRepaintRect = lastRepaintRect; - self$$1.fire('repaint', {}, false); - }, - updateLayoutRect: function () { - var self$$1 = this; - self$$1.parent()._lastRect = null; - funcs.css(self$$1.getEl(), { - width: '', - height: '' - }); - self$$1._layoutRect = self$$1._lastRepaintRect = self$$1._lastLayoutRect = null; - self$$1.initLayoutRect(); - }, - on: function (name$$1, callback) { - var self$$1 = this; - function resolveCallbackName(name$$1) { - var callback, scope; - if (typeof name$$1 !== 'string') { - return name$$1; - } - return function (e) { - if (!callback) { - self$$1.parentsAndSelf().each(function (ctrl) { - var callbacks = ctrl.settings.callbacks; - if (callbacks && (callback = callbacks[name$$1])) { - scope = ctrl; - return false; + }); + 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](); } }); } - if (!callback) { - e.action = name$$1; - this.fire('execute', e); + 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$$1 = ctrl.parent(); + if (parent$$1) { + if (!parent$$1._layout || parent$$1._layout.isNative()) { return; } - return callback.call(scope, e); - }; - } - getEventDispatcher(self$$1).on(name$$1, resolveCallbackName(callback)); - return self$$1; - }, - off: function (name$$1, callback) { - getEventDispatcher(this).off(name$$1, callback); - return this; - }, - fire: function (name$$1, args, bubble) { - var self$$1 = this; - args = args || {}; - if (!args.control) { - args.control = self$$1; - } - args = getEventDispatcher(self$$1).fire(name$$1, args); - if (bubble !== false && self$$1.parent) { - var parent$$1 = self$$1.parent(); - while (parent$$1 && !args.isPropagationStopped()) { - parent$$1.fire(name$$1, args, false); - parent$$1 = parent$$1.parent(); - } - } - return args; - }, - hasEventListeners: function (name$$1) { - return getEventDispatcher(this).has(name$$1); - }, - parents: function (selector) { - var self$$1 = this; - var ctrl, parents = new Collection$2(); - for (ctrl = self$$1.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$$1, value) { - var self$$1 = this, elm = self$$1.getEl(self$$1.ariaTarget); - if (typeof value === 'undefined') { - return self$$1._aria[name$$1]; - } - self$$1._aria[name$$1] = value; - if (self$$1.state.get('rendered')) { - elm.setAttribute(name$$1 === 'role' ? name$$1 : 'aria-' + name$$1, value); - } - return self$$1; - }, - 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$$1 = this, parent$$1 = self$$1.parent(); - if (parent$$1) { - parent$$1.insert(items, parent$$1.items().indexOf(self$$1), true); - } - return self$$1; - }, - after: function (items) { - var self$$1 = this, parent$$1 = self$$1.parent(); - if (parent$$1) { - parent$$1.insert(items, parent$$1.items().indexOf(self$$1)); - } - return self$$1; - }, - remove: function () { - var self$$1 = this; - var elm = self$$1.getEl(); - var parent$$1 = self$$1.parent(); - var newItems, i; - if (self$$1.items) { - var controls = self$$1.items().toArray(); - i = controls.length; - while (i--) { - controls[i].remove(); - } - } - if (parent$$1 && parent$$1.items) { - newItems = []; - parent$$1.items().each(function (item) { - if (item !== self$$1) { - newItems.push(item); + if (!dirtyCtrls[parent$$1._id]) { + dirtyCtrls[parent$$1._id] = parent$$1; } - }); - parent$$1.items().set(newItems); - parent$$1._lastRect = null; - } - if (self$$1._eventsRoot && self$$1._eventsRoot === self$$1) { - global$7(elm).off(); - } - var lookup = self$$1.getRoot().controlIdLookup; - if (lookup) { - delete lookup[self$$1._id]; - } - if (elm && elm.parentNode) { - elm.parentNode.removeChild(elm); - } - self$$1.state.set('rendered', false); - self$$1.state.destroy(); - self$$1.fire('remove'); - return self$$1; - }, - 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$$1 = this; - var settings = self$$1.settings; - var elm, box, parent$$1, name$$1, parentEventsRoot; - self$$1.$el = global$7(self$$1.getEl()); - self$$1.state.set('rendered', true); - for (name$$1 in settings) { - if (name$$1.indexOf('on') === 0) { - self$$1.on(name$$1.substr(2), settings[name$$1]); - } - } - if (self$$1._eventsRoot) { - for (parent$$1 = self$$1.parent(); !parentEventsRoot && parent$$1; parent$$1 = parent$$1.parent()) { - parentEventsRoot = parent$$1._eventsRoot; - } - if (parentEventsRoot) { - for (name$$1 in parentEventsRoot._nativeEvents) { - self$$1._nativeEvents[name$$1] = true; + 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 = {}; + }, document.body); } } - } - bindPendingEvents(self$$1); - if (settings.style) { - elm = self$$1.getEl(); - if (elm) { - elm.setAttribute('style', settings.style); - elm.style.cssText = settings.style; + }, + remove: function (ctrl) { + if (dirtyCtrls[ctrl._id]) { + delete dirtyCtrls[ctrl._id]; } } - if (self$$1.settings.border) { - box = self$$1.borderBox; - self$$1.$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$$1.getRoot(); - if (!root.controlIdLookup) { - root.controlIdLookup = {}; - } - root.controlIdLookup[self$$1._id] = self$$1; - for (var key in self$$1._aria) { - self$$1.aria(key, self$$1._aria[key]); - } - if (self$$1.state.get('visible') === false) { - self$$1.getEl().style.display = 'none'; - } - self$$1.bindStates(); - self$$1.state.on('change:visible', function (e) { - var state = e.value; - var parentCtrl; - if (self$$1.state.get('rendered')) { - self$$1.getEl().style.display = state === false ? 'none' : ''; - self$$1.getEl().getBoundingClientRect(); - } - parentCtrl = self$$1.parent(); - if (parentCtrl) { - parentCtrl._lastRect = null; - } - self$$1.fire(state ? 'show' : 'hide'); - $_cqjgb518wjjgwek2f.add(self$$1); - }); - self$$1.fire('postrender', {}, false); - }, - bindStates: function () { - }, - scrollIntoView: function (align) { - function getOffset(elm, rootElm) { - var x, y, parent$$1 = elm; - x = y = 0; - while (parent$$1 && parent$$1 !== rootElm && parent$$1.nodeType) { - x += parent$$1.offsetLeft || 0; - y += parent$$1.offsetTop || 0; - parent$$1 = parent$$1.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 () { - $_cqjgb518wjjgwek2f.remove(this); - var parent$$1 = this.parent(); - if (parent$$1 && parent$$1._layout && !parent$$1._layout.isNative()) { - parent$$1.reflow(); - } - return this; - } - }; - global$4.each('text title visible disabled active value'.split(' '), function (name$$1) { - proto$1[name$$1] = function (value) { - if (arguments.length === 0) { - return this.state.get(name$$1); - } - if (typeof value !== 'undefined') { - this.state.set(name$$1, 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$$1, state) { - if (state && global$9.isNative(name$$1)) { - if (!obj._nativeEvents) { - obj._nativeEvents = {}; - } - obj._nativeEvents[name$$1] = true; - if (obj.state.get('rendered')) { - bindPendingEvents(obj); + + 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 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$$1 = this; + var classes, defaultClasses; + function applyClasses(classes) { + var i; + classes = classes.split(' '); + for (i = 0; i < classes.length; i++) { + self$$1.classes.add(classes[i]); + } + } + self$$1.settings = settings = global$4.extend({}, self$$1.Defaults, settings); + self$$1._id = settings.id || 'mceu_' + idCounter++; + self$$1._aria = { role: settings.role }; + self$$1._elmCache = {}; + self$$1.$ = global$7; + self$$1.state = new ObservableObject({ + visible: true, + active: false, + disabled: false, + value: '' + }); + self$$1.data = new ObservableObject(settings.data); + self$$1.classes = new ClassList(function () { + if (self$$1.state.get('rendered')) { + self$$1.getEl().className = this.toString(); + } + }); + self$$1.classes.prefix = self$$1.classPrefix; + classes = settings.classes; + if (classes) { + if (self$$1.Defaults) { + defaultClasses = self$$1.Defaults.classes; + if (defaultClasses && classes !== defaultClasses) { + applyClasses(defaultClasses); } } + applyClasses(classes); } - }); - } - return obj._eventDispatcher; - } - function bindPendingEvents(eventCtrl) { - var i, l, parents, eventRootCtrl, nativeEvents, name$$1; - 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$$1 in nativeEvents) { - if (!nativeEvents) { - return false; - } - if (name$$1 === 'wheel' && !hasWheelEventSupport) { - if (hasMouseWheelEventSupport) { - global$7(eventCtrl.getEl()).on('mousewheel', fixWheelEvent); - } else { - global$7(eventCtrl.getEl()).on('DOMMouseScroll', fixWheelEvent); - } - continue; - } - if (name$$1 === 'mouseenter' || name$$1 === 'mouseleave') { - if (!eventRootCtrl._hasMouseEnter) { - global$7(eventRootCtrl.getEl()).on('mouseleave', mouseLeaveHandler).on('mouseover', mouseEnterHandler); - eventRootCtrl._hasMouseEnter = 1; - } - } else if (!eventRootDelegates[name$$1]) { - global$7(eventRootCtrl.getEl()).on(name$$1, delegate); - eventRootDelegates[name$$1] = true; - } - nativeEvents[name$$1] = 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, $_egt6ye18xjjgwek2h.getUiContainer(ctrl)); - x = pos.x; - y = pos.y; - if (isFixed(ctrl) && isStatic(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 = window; - var x = Math.max(win.pageXOffset, document.body.scrollLeft, document.documentElement.scrollLeft); - var y = Math.max(win.pageYOffset, document.body.scrollTop, document.documentElement.scrollTop); - var w = win.innerWidth || document.documentElement.clientWidth; - var h = win.innerHeight || document.documentElement.clientHeight; - return { - x: x, - y: y, - w: x + w, - h: y + h - }; - }; - var getViewPortRect = function (ctrl) { - var customUiContainer = $_egt6ye18xjjgwek2h.getUiContainer(ctrl); - return customUiContainer && !isFixed(ctrl) ? getUiContainerViewPort(customUiContainer) : getWindowViewPort(); - }; - var $_8zu82i18yjjgwek2l = { - 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 && pos.y > viewPortRect.y && pos.y + pos.h < viewPortRect.h) { - 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$$1 = this, rect = self$$1.layoutRect(); - self$$1.moveTo(rect.x + dx, rect.y + dy); - return self$$1; - }, - moveTo: function (x, y) { - var self$$1 = 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$$1.settings.constrainToViewport) { - var viewPortRect = getViewPortRect(this); - var layoutRect = self$$1.layoutRect(); - x = constrain(x, viewPortRect.w, layoutRect.w); - y = constrain(y, viewPortRect.h, layoutRect.h); - } - var uiContainer = $_egt6ye18xjjgwek2h.getUiContainer(self$$1); - if (uiContainer && isStatic(uiContainer) && !isFixed(self$$1)) { - x -= uiContainer.scrollLeft; - y -= uiContainer.scrollTop; - } - if (uiContainer) { - x += 1; - y += 1; - } - if (self$$1.state.get('rendered')) { - self$$1.layoutRect({ - x: x, - y: y - }).repaint(); - } else { - self$$1.settings.x = x; - self$$1.settings.y = y; - } - self$$1.fire('move', { - x: x, - y: y - }); - return self$$1; - } - }; - - var Tooltip = Control$1.extend({ - Mixins: [$_8zu82i18yjjgwek2l], - Defaults: { classes: 'widget tooltip tooltip-n' }, - renderHtml: function () { - var self = this, prefix = self.classPrefix; - return ''; - }, - 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(); + global$4.each('title text name visible disabled active value'.split(' '), function (name$$1) { + if (name$$1 in settings) { + self$$1[name$$1](settings[name$$1]); } }); - self.on('mouseleave mousedown click', function () { - self.tooltip().remove(); - self._tooltip = null; + self$$1.on('click', function () { + if (self$$1.disabled()) { + return false; + } }); - } - self.aria('label', settings.ariaLabel || settings.tooltip); - }, - tooltip: function () { - if (!this._tooltip) { - this._tooltip = new Tooltip({ type: 'tooltip' }); - $_egt6ye18xjjgwek2h.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); + self$$1.settings = settings; + self$$1.borderBox = BoxUtils.parseBox(settings.border); + self$$1.paddingBox = BoxUtils.parseBox(settings.padding); + self$$1.marginBox = BoxUtils.parseBox(settings.margin); + if (settings.hidden) { + self$$1.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$$1 = this; + var settings = self$$1.settings; + var borderBox, layoutRect; + var elm = self$$1.getEl(); + var width, height, minWidth, minHeight, autoResize; + var startMinWidth, startMinHeight, initialSize; + borderBox = self$$1.borderBox = self$$1.borderBox || BoxUtils.measureBox(elm, 'border'); + self$$1.paddingBox = self$$1.paddingBox || BoxUtils.measureBox(elm, 'padding'); + self$$1.marginBox = self$$1.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$$1._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 }; - } - }, - renderHtml: function () { - var self = this, id = self._id, prefix = this.classPrefix; - return '
' + '
' + '
' + '
' + '
0%
' + '
'; - }, - 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: [$_8zu82i18yjjgwek2l], - 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(); + self$$1._lastLayoutRect = {}; + return layoutRect; + }, + layoutRect: function (newRect) { + var self$$1 = this; + var curRect = self$$1._layoutRect, lastLayoutRect, size, deltaWidth, deltaHeight, repaintControls; + if (!curRect) { + curRect = self$$1.initLayoutRect(); } - }); - }, - 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 = ''; - } - if (self.progressBar) { - progressBar = self.progressBar.renderHtml(); - } - return ''; - }, - 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'); + if (newRect) { + deltaWidth = curRect.deltaW; + deltaHeight = curRect.deltaH; + if (newRect.x !== undefined) { + curRect.x = newRect.x; } - }); - } - }; - 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 || document; - var downButton; - var start, stop$$1, 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 (window.getComputedStyle) { - cursor = 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$$1); - settings.start(e); - }; - drag = function (e) { - updateWithTouchData(e); - if (e.button !== downButton) { - return stop$$1(e); - } - e.deltaX = e.screenX - startX; - e.deltaY = e.screenY - startY; - e.preventDefault(); - settings.drag(e); - }; - stop$$1 = function (e) { - updateWithTouchData(e); - global$7(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop$$1); - $eventOverlay.remove(); - if (settings.stop) { - settings.stop(e); - } - }; - this.destroy = function () { - global$7(handleElement).off(); - }; - global$7(handleElement).on('mousedown touchstart', start); - } - - var global$11 = 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 = document.activeElement; - } catch (ex) { - focusedElement = 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$$1 = elm || focusedElement; - while (parent$$1 = parent$$1.parentNode) { - if (role = getRole(parent$$1)) { - return role; - } - } - } - function getAriaProp(name$$1) { - var elm = focusedElement; - if (isElement(elm)) { - return elm.getAttribute('aria-' + name$$1); - } - } - 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$11.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 }; + 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$$1._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$$1._id]) { + repaintControls.push(self$$1); + repaintControls.map[self$$1._id] = true; + } } - 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$11.create(settings); + lastLayoutRect.x = curRect.x; + lastLayoutRect.y = curRect.y; + lastLayoutRect.w = curRect.w; + lastLayoutRect.h = curRect.h; } - ctrlItems.push(item); + return self$$1; } - }); - 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(); - $_cqjgb518wjjgwek2f.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 curRect; + }, + repaint: function () { + var self$$1 = this; + var style, bodyStyle, bodyElm, rect, borderBox; + var borderW, borderH, lastRepaintRect, round, value; + round = !document.createRange ? Math.round : function (value) { + return value; }; - return true; - } - }, - reflow: function () { - var i; - $_cqjgb518wjjgwek2f.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(); + style = self$$1.getEl().style; + rect = self$$1._layoutRect; + lastRepaintRect = self$$1._lastRepaintRect || {}; + borderBox = self$$1.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 (this.settings.layout !== 'flow' && this.settings.layout !== 'stack') { - this.repaint(); + if (rect.y !== lastRepaintRect.y) { + style.top = round(rect.y) + 'px'; + lastRepaintRect.y = rect.y; } - Control$1.repaintControls = []; - } - return this; - } - }); - - var $_8woeth19ajjgwek4b = { - 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'); + 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$$1._hasBody && rect.innerW !== lastRepaintRect.innerW) { + value = round(rect.innerW); + bodyElm = self$$1.getEl('body'); + if (bodyElm) { + bodyStyle = bodyElm.style; + bodyStyle.width = (value >= 0 ? value : 0) + 'px'; + } + lastRepaintRect.innerW = rect.innerW; + } + if (self$$1._hasBody && rect.innerH !== lastRepaintRect.innerH) { + value = round(rect.innerH); + bodyElm = bodyElm || self$$1.getEl('body'); + if (bodyElm) { + bodyStyle = bodyStyle || bodyElm.style; + bodyStyle.height = (value >= 0 ? value : 0) + 'px'; + } + lastRepaintRect.innerH = rect.innerH; + } + self$$1._lastRepaintRect = lastRepaintRect; + self$$1.fire('repaint', {}, false); + }, + updateLayoutRect: function () { + var self$$1 = this; + self$$1.parent()._lastRect = null; + funcs.css(self$$1.getEl(), { + width: '', + height: '' + }); + self$$1._layoutRect = self$$1._lastRepaintRect = self$$1._lastLayoutRect = null; + self$$1.initLayoutRect(); + }, + on: function (name$$1, callback) { + var self$$1 = this; + function resolveCallbackName(name$$1) { + var callback, scope; + if (typeof name$$1 !== 'string') { + return name$$1; + } + return function (e) { + if (!callback) { + self$$1.parentsAndSelf().each(function (ctrl) { + var callbacks = ctrl.settings.callbacks; + if (callbacks && (callback = callbacks[name$$1])) { + scope = ctrl; + return false; + } + }); + } + if (!callback) { + e.action = name$$1; + this.fire('execute', e); 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); + return callback.call(scope, e); + }; + } + getEventDispatcher(self$$1).on(name$$1, resolveCallbackName(callback)); + return self$$1; + }, + off: function (name$$1, callback) { + getEventDispatcher(this).off(name$$1, callback); + return this; + }, + fire: function (name$$1, args, bubble) { + var self$$1 = this; + args = args || {}; + if (!args.control) { + args.control = self$$1; + } + args = getEventDispatcher(self$$1).fire(name$$1, args); + if (bubble !== false && self$$1.parent) { + var parent$$1 = self$$1.parent(); + while (parent$$1 && !args.isPropagationStopped()) { + parent$$1.fire(name$$1, args, false); + parent$$1 = parent$$1.parent(); } } - 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'); + return args; + }, + hasEventListeners: function (name$$1) { + return getEventDispatcher(this).has(name$$1); + }, + parents: function (selector) { + var self$$1 = this; + var ctrl, parents = new Collection$2(); + for (ctrl = self$$1.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$$1, value) { + var self$$1 = this, elm = self$$1.getEl(self$$1.ariaTarget); + if (typeof value === 'undefined') { + return self$$1._aria[name$$1]; + } + self$$1._aria[name$$1] = value; + if (self$$1.state.get('rendered')) { + elm.setAttribute(name$$1 === 'role' ? name$$1 : 'aria-' + name$$1, value); + } + return self$$1; + }, + 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$$1 = this, parent$$1 = self$$1.parent(); + if (parent$$1) { + parent$$1.insert(items, parent$$1.items().indexOf(self$$1), true); + } + return self$$1; + }, + after: function (items) { + var self$$1 = this, parent$$1 = self$$1.parent(); + if (parent$$1) { + parent$$1.insert(items, parent$$1.items().indexOf(self$$1)); + } + return self$$1; + }, + remove: function () { + var self$$1 = this; + var elm = self$$1.getEl(); + var parent$$1 = self$$1.parent(); + var newItems, i; + if (self$$1.items) { + var controls = self$$1.items().toArray(); + i = controls.length; + while (i--) { + controls[i].remove(); + } + } + if (parent$$1 && parent$$1.items) { + newItems = []; + parent$$1.items().each(function (item) { + if (item !== self$$1) { + newItems.push(item); } }); + parent$$1.items().set(newItems); + parent$$1._lastRect = null; } - 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(); + if (self$$1._eventsRoot && self$$1._eventsRoot === self$$1) { + global$7(elm).off(); + } + var lookup = self$$1.getRoot().controlIdLookup; + if (lookup) { + delete lookup[self$$1._id]; + } + if (elm && elm.parentNode) { + elm.parentNode.removeChild(elm); + } + self$$1.state.set('rendered', false); + self$$1.state.destroy(); + self$$1.fire('remove'); + return self$$1; + }, + 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$$1 = this; + var settings = self$$1.settings; + var elm, box, parent$$1, name$$1, parentEventsRoot; + self$$1.$el = global$7(self$$1.getEl()); + self$$1.state.set('rendered', true); + for (name$$1 in settings) { + if (name$$1.indexOf('on') === 0) { + self$$1.on(name$$1.substr(2), settings[name$$1]); + } + } + if (self$$1._eventsRoot) { + for (parent$$1 = self$$1.parent(); !parentEventsRoot && parent$$1; parent$$1 = parent$$1.parent()) { + parentEventsRoot = parent$$1._eventsRoot; + } + if (parentEventsRoot) { + for (name$$1 in parentEventsRoot._nativeEvents) { + self$$1._nativeEvents[name$$1] = true; + } + } + } + bindPendingEvents(self$$1); + if (settings.style) { + elm = self$$1.getEl(); + if (elm) { + elm.setAttribute('style', settings.style); + elm.style.cssText = settings.style; + } + } + if (self$$1.settings.border) { + box = self$$1.borderBox; + self$$1.$el.css({ + 'border-top-width': box.top, + 'border-right-width': box.right, + 'border-bottom-width': box.bottom, + 'border-left-width': box.left }); - global$7(self.getEl('body')).on('scroll', repaintScroll); } - repaintScroll(); - } - } - }; - - var Panel = Container.extend({ - Defaults: { - layout: 'fit', - containerCls: 'panel' - }, - Mixins: [$_8woeth19ajjgwek4b], - 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); + var root = self$$1.getRoot(); + if (!root.controlIdLookup) { + root.controlIdLookup = {}; } - self._hasBody = false; + root.controlIdLookup[self$$1._id] = self$$1; + for (var key in self$$1._aria) { + self$$1.aria(key, self$$1._aria[key]); + } + if (self$$1.state.get('visible') === false) { + self$$1.getEl().style.display = 'none'; + } + self$$1.bindStates(); + self$$1.state.on('change:visible', function (e) { + var state = e.value; + var parentCtrl; + if (self$$1.state.get('rendered')) { + self$$1.getEl().style.display = state === false ? 'none' : ''; + self$$1.getEl().getBoundingClientRect(); + } + parentCtrl = self$$1.parent(); + if (parentCtrl) { + parentCtrl._lastRect = null; + } + self$$1.fire(state ? 'show' : 'hide'); + ReflowQueue.add(self$$1); + }); + self$$1.fire('postrender', {}, false); + }, + bindStates: function () { + }, + scrollIntoView: function (align) { + function getOffset(elm, rootElm) { + var x, y, parent$$1 = elm; + x = y = 0; + while (parent$$1 && parent$$1 !== rootElm && parent$$1.nodeType) { + x += parent$$1.offsetLeft || 0; + y += parent$$1.offsetTop || 0; + parent$$1 = parent$$1.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$$1 = this.parent(); + if (parent$$1 && parent$$1._layout && !parent$$1._layout.isNative()) { + parent$$1.reflow(); + } + return this; } - return '
' + (self._preBodyHtml || '') + innerHtml + '
'; - } - }); - - var $_20hy1119bjjgwek4f = { - 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; + }; + global$4.each('text title visible disabled active value'.split(' '), function (name$$1) { + proto$1[name$$1] = function (value) { + if (arguments.length === 0) { + return this.state.get(name$$1); + } + if (typeof value !== 'undefined') { + this.state.set(name$$1, 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$$1, state) { + if (state && global$9.isNative(name$$1)) { + if (!obj._nativeEvents) { + obj._nativeEvents = {}; + } + obj._nativeEvents[name$$1] = true; + if (obj.state.get('rendered')) { + bindPendingEvents(obj); + } + } + } + }); } - 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); + return obj._eventDispatcher; } - }; - - var documentClickHandler; - var documentScrollHandler; - var windowResizeHandler; - var visiblePanels = []; - var zOrder = []; - var hasModal; - function isChildOf(ctrl, parent$$1) { - while (ctrl) { - if (ctrl === parent$$1) { - return true; + function bindPendingEvents(eventCtrl) { + var i, l, parents, eventRootCtrl, nativeEvents, name$$1; + function delegate(e) { + var control = eventCtrl.getParentCtrl(e.target); + if (control) { + control.fire(e.type, e); + } } - 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) { + 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$$1 in nativeEvents) { + if (!nativeEvents) { + return false; + } + if (name$$1 === 'wheel' && !hasWheelEventSupport) { + if (hasMouseWheelEventSupport) { + global$7(eventCtrl.getEl()).on('mousewheel', fixWheelEvent); + } else { + global$7(eventCtrl.getEl()).on('DOMMouseScroll', fixWheelEvent); + } continue; } - } - e = panel.fire('autohide', { target: e.target }); - if (!e.isDefaultPrevented()) { - panel.hide(); + if (name$$1 === 'mouseenter' || name$$1 === 'mouseleave') { + if (!eventRootCtrl._hasMouseEnter) { + global$7(eventRootCtrl.getEl()).on('mouseleave', mouseLeaveHandler).on('mouseover', mouseEnterHandler); + eventRootCtrl._hasMouseEnter = 1; + } + } else if (!eventRootDelegates[name$$1]) { + global$7(eventRootCtrl.getEl()).on(name$$1, delegate); + eventRootDelegates[name$$1] = true; + } + nativeEvents[name$$1] = false; } } } - } - function bindDocumentClickHandler() { - if (!documentClickHandler) { - documentClickHandler = function (e) { - if (e.button === 2) { + 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(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 = window; + var x = Math.max(win.pageXOffset, document.body.scrollLeft, document.documentElement.scrollLeft); + var y = Math.max(win.pageYOffset, document.body.scrollTop, document.documentElement.scrollTop); + var w = win.innerWidth || document.documentElement.clientWidth; + var h = win.innerHeight || 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$$1 = this, rect = self$$1.layoutRect(); + self$$1.moveTo(rect.x + dx, rect.y + dy); + return self$$1; + }, + moveTo: function (x, y) { + var self$$1 = 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$$1.settings.constrainToViewport) { + var viewPortRect = getViewPortRect(this); + var layoutRect = self$$1.layoutRect(); + x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w); + y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h); + } + var uiContainer = UiContainer.getUiContainer(self$$1); + if (uiContainer && isStatic(uiContainer) && !isFixed(self$$1)) { + x -= uiContainer.scrollLeft; + y -= uiContainer.scrollTop; + } + if (uiContainer) { + x += 1; + y += 1; + } + if (self$$1.state.get('rendered')) { + self$$1.layoutRect({ + x: x, + y: y + }).repaint(); + } else { + self$$1.settings.x = x; + self$$1.settings.y = y; + } + self$$1.fire('move', { + x: x, + y: y + }); + return self$$1; + } + }; + + var Tooltip = Control$1.extend({ + Mixins: [Movable], + Defaults: { classes: 'widget tooltip tooltip-n' }, + renderHtml: function () { + var self = this, prefix = self.classPrefix; + return ''; + }, + 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 '
' + '
' + '
' + '
' + '
0%
' + '
'; + }, + 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 = ''; + } + if (self.progressBar) { + progressBar = self.progressBar.renderHtml(); + } + return ''; + }, + 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 || document; + var downButton; + var start, stop$$1, 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 (window.getComputedStyle) { + cursor = 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$$1); + settings.start(e); + }; + drag = function (e) { + updateWithTouchData(e); + if (e.button !== downButton) { + return stop$$1(e); + } + e.deltaX = e.screenX - startX; + e.deltaY = e.screenY - startY; + e.preventDefault(); + settings.drag(e); + }; + stop$$1 = function (e) { + updateWithTouchData(e); + global$7(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop$$1); + $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 = document.activeElement; + } catch (ex) { + focusedElement = 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$$1 = elm || focusedElement; + while (parent$$1 = parent$$1.parentNode) { + if (role = getRole(parent$$1)) { + return role; + } + } + } + function getAriaProp(name$$1) { + var elm = focusedElement; + if (isElement(elm)) { + return elm.getAttribute('aria-' + name$$1); + } + } + 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; } - skipOrHidePanels(e); - }; - global$7(document).on('click touchstart', documentClickHandler); + 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 }; } - } - function bindDocumentScrollHandler() { - if (!documentScrollHandler) { - documentScrollHandler = function () { - var i; - i = visiblePanels.length; + + 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--) { - repositionPanel$1(visiblePanels[i]); + if (items[i] === oldItem) { + items[i] = newItem; + break; + } } - }; - global$7(window).on('scroll', documentScrollHandler); - } - } - function bindWindowResizeHandler() { - if (!windowResizeHandler) { - var docElm_1 = document.documentElement; - var clientWidth_1 = docElm_1.clientWidth, clientHeight_1 = docElm_1.clientHeight; - windowResizeHandler = function () { - if (!document.all || clientWidth_1 !== docElm_1.clientWidth || clientHeight_1 !== docElm_1.clientHeight) { - clientWidth_1 = docElm_1.clientWidth; - clientHeight_1 = docElm_1.clientHeight; - FloatPanel.hideAll(); + if (i >= 0) { + ctrlElm = newItem.getEl(); + if (ctrlElm) { + ctrlElm.parentNode.removeChild(ctrlElm); + } + ctrlElm = oldItem.getEl(); + if (ctrlElm) { + ctrlElm.parentNode.removeChild(ctrlElm); + } } - }; - global$7(window).on('resize', windowResizeHandler); - } - } - function repositionPanel$1(panel) { - var scrollY$$1 = funcs.getViewPort().y; - function toggleFixedChildPanels(fixed, deltaY) { - var parent$$1; - for (var i = 0; i < visiblePanels.length; i++) { - if (visiblePanels[i] !== panel) { - parent$$1 = visiblePanels[i].parent(); - while (parent$$1 && (parent$$1 = parent$$1.parent())) { - if (parent$$1 === panel) { - visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint(); + 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$$1) { + while (ctrl) { + if (ctrl === parent$$1) { + 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(); } } } } - if (panel.settings.autofix) { - if (!panel.state.get('fixed')) { - panel._autoFixY = panel.layoutRect().y; - if (panel._autoFixY < scrollY$$1) { - panel.fixed(true).layoutRect({ y: 0 }).repaint(); - toggleFixedChildPanels(true, scrollY$$1 - panel._autoFixY); + function bindDocumentClickHandler() { + if (!documentClickHandler) { + documentClickHandler = function (e) { + if (e.button === 2) { + return; + } + skipOrHidePanels(e); + }; + global$7(document).on('click touchstart', documentClickHandler); + } + } + function bindDocumentScrollHandler() { + if (!documentScrollHandler) { + documentScrollHandler = function () { + var i; + i = visiblePanels.length; + while (i--) { + repositionPanel$1(visiblePanels[i]); + } + }; + global$7(window).on('scroll', documentScrollHandler); + } + } + function bindWindowResizeHandler() { + if (!windowResizeHandler) { + var docElm_1 = document.documentElement; + var clientWidth_1 = docElm_1.clientWidth, clientHeight_1 = docElm_1.clientHeight; + windowResizeHandler = function () { + if (!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(window).on('resize', windowResizeHandler); + } + } + function repositionPanel$1(panel) { + var scrollY$$1 = funcs.getViewPort().y; + function toggleFixedChildPanels(fixed, deltaY) { + var parent$$1; + for (var i = 0; i < visiblePanels.length; i++) { + if (visiblePanels[i] !== panel) { + parent$$1 = visiblePanels[i].parent(); + while (parent$$1 && (parent$$1 = parent$$1.parent())) { + if (parent$$1 === panel) { + visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint(); + } + } + } } - } else { - if (panel._autoFixY > scrollY$$1) { - panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint(); - toggleFixedChildPanels(false, panel._autoFixY - scrollY$$1); + } + if (panel.settings.autofix) { + if (!panel.state.get('fixed')) { + panel._autoFixY = panel.layoutRect().y; + if (panel._autoFixY < scrollY$$1) { + panel.fixed(true).layoutRect({ y: 0 }).repaint(); + toggleFixedChildPanels(true, scrollY$$1 - panel._autoFixY); + } + } else { + if (panel._autoFixY > scrollY$$1) { + panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint(); + toggleFixedChildPanels(false, panel._autoFixY - scrollY$$1); + } } } } - } - function addRemove(add, ctrl) { - var i, zIndex = FloatPanel.zIndex || 65535, topModal; - if (add) { - zOrder.push(ctrl); - } else { + 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$$1 = this; + self$$1._super(settings); + self$$1._eventsRoot = self$$1; + self$$1.classes.add('floatpanel'); + if (settings.autohide) { + bindDocumentClickHandler(); + bindWindowResizeHandler(); + visiblePanels.push(self$$1); + } + if (settings.autofix) { + bindDocumentScrollHandler(); + self$$1.on('move', function () { + repositionPanel$1(this); + }); + } + self$$1.on('postrender show', function (e) { + if (e.control === self$$1) { + var $modalBlockEl_1; + var prefix_1 = self$$1.classPrefix; + if (self$$1.modal && !hasModal) { + $modalBlockEl_1 = global$7('#' + prefix_1 + 'modal-block', self$$1.getContainerElm()); + if (!$modalBlockEl_1[0]) { + $modalBlockEl_1 = global$7('
').appendTo(self$$1.getContainerElm()); + } + global$3.setTimeout(function () { + $modalBlockEl_1.addClass(prefix_1 + 'in'); + global$7(self$$1.getEl()).addClass(prefix_1 + 'in'); + }); + hasModal = true; + } + addRemove(true, self$$1); + } + }); + self$$1.on('show', function () { + self$$1.parents().each(function (ctrl) { + if (ctrl.state.get('fixed')) { + self$$1.fixed(true); + return false; + } + }); + }); + if (settings.popover) { + self$$1._preBodyHtml = '
'; + self$$1.classes.add('popover').add('bottom').add(self$$1.isRtl() ? 'end' : 'start'); + } + self$$1.aria('label', settings.ariaLabel); + self$$1.aria('labelledby', self$$1._id); + self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); + }, + fixed: function (state) { + var self$$1 = this; + if (self$$1.state.get('fixed') !== state) { + if (self$$1.state.get('rendered')) { + var viewport = funcs.getViewPort(); + if (state) { + self$$1.layoutRect().y -= viewport.y; + } else { + self$$1.layoutRect().y += viewport.y; + } + } + self$$1.classes.toggle('fixed', state); + self$$1.state.set('fixed', state); + } + return self$$1; + }, + show: function () { + var self$$1 = this; + var i; + var state = self$$1._super(); + i = visiblePanels.length; + while (i--) { + if (visiblePanels[i] === self$$1) { + break; + } + } + if (i === -1) { + visiblePanels.push(self$$1); + } + return state; + }, + hide: function () { + removeVisiblePanel(this); + addRemove(false, this); + return this._super(); + }, + hideAll: function () { + FloatPanel.hideAll(); + }, + close: function () { + var self$$1 = this; + if (!self$$1.fire('close').isDefaultPrevented()) { + self$$1.remove(); + addRemove(false, self$$1); + } + return self$$1; + }, + remove: function () { + removeVisiblePanel(this); + this._super(); + }, + postRender: function () { + var self$$1 = this; + if (self$$1.settings.bodyRole) { + this.getEl('body').setAttribute('role', self$$1.settings.bodyRole); + } + return self$$1._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] === ctrl) { + if (zOrder[i] === panel) { 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: [ - $_8zu82i18yjjgwek2l, - $_20hy1119bjjgwek4f - ], - init: function (settings) { - var self$$1 = this; - self$$1._super(settings); - self$$1._eventsRoot = self$$1; - self$$1.classes.add('floatpanel'); - if (settings.autohide) { - bindDocumentClickHandler(); - bindWindowResizeHandler(); - visiblePanels.push(self$$1); - } - if (settings.autofix) { - bindDocumentScrollHandler(); - self$$1.on('move', function () { - repositionPanel$1(this); - }); - } - self$$1.on('postrender show', function (e) { - if (e.control === self$$1) { - var $modalBlockEl_1; - var prefix_1 = self$$1.classPrefix; - if (self$$1.modal && !hasModal) { - $modalBlockEl_1 = global$7('#' + prefix_1 + 'modal-block', self$$1.getContainerElm()); - if (!$modalBlockEl_1[0]) { - $modalBlockEl_1 = global$7('
').appendTo(self$$1.getContainerElm()); - } - global$3.setTimeout(function () { - $modalBlockEl_1.addClass(prefix_1 + 'in'); - global$7(self$$1.getEl()).addClass(prefix_1 + 'in'); - }); - hasModal = true; - } - addRemove(true, self$$1); - } - }); - self$$1.on('show', function () { - self$$1.parents().each(function (ctrl) { - if (ctrl.state.get('fixed')) { - self$$1.fixed(true); - return false; - } - }); - }); - if (settings.popover) { - self$$1._preBodyHtml = '
'; - self$$1.classes.add('popover').add('bottom').add(self$$1.isRtl() ? 'end' : 'start'); - } - self$$1.aria('label', settings.ariaLabel); - self$$1.aria('labelledby', self$$1._id); - self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); - }, - fixed: function (state) { - var self$$1 = this; - if (self$$1.state.get('fixed') !== state) { - if (self$$1.state.get('rendered')) { - var viewport = funcs.getViewPort(); - if (state) { - self$$1.layoutRect().y -= viewport.y; - } else { - self$$1.layoutRect().y += viewport.y; - } - } - self$$1.classes.toggle('fixed', state); - self$$1.state.set('fixed', state); - } - return self$$1; - }, - show: function () { - var self$$1 = this; - var i; - var state = self$$1._super(); - i = visiblePanels.length; - while (i--) { - if (visiblePanels[i] === self$$1) { - break; - } - } - if (i === -1) { - visiblePanels.push(self$$1); - } - return state; - }, - hide: function () { - removeVisiblePanel(this); - addRemove(false, this); - return this._super(); - }, - hideAll: function () { - FloatPanel.hideAll(); - }, - close: function () { - var self$$1 = this; - if (!self$$1.fire('close').isDefaultPrevented()) { - self$$1.remove(); - addRemove(false, self$$1); - } - return self$$1; - }, - remove: function () { - removeVisiblePanel(this); - this._super(); - }, - postRender: function () { - var self$$1 = this; - if (self$$1.settings.bodyRole) { - this.getEl('body').setAttribute('role', self$$1.settings.bodyRole); - } - return self$$1._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; + 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 = document.createElement('meta'); + viewport.setAttribute('name', 'viewport'); + document.getElementsByTagName('head')[0].appendChild(viewport); + } + contentValue = viewport.getAttribute('content'); + if (contentValue && typeof oldMetaValue !== 'undefined') { + oldMetaValue = contentValue; + } + viewport.setAttribute('content', state ? noScaleMetaValue : oldMetaValue); } - if (!viewport) { - viewport = document.createElement('meta'); - viewport.setAttribute('name', 'viewport'); - 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([ - document.documentElement, - document.body - ]).removeClass(classPrefix + 'fullscreen'); - } - } - function checkFullscreenWindows() { - for (var i = 0; i < windows.length; i++) { - if (windows[i]._fullscreen) { - return true; + function toggleBodyFullScreenClasses(classPrefix, state) { + if (checkFullscreenWindows() && state === false) { + global$7([ + document.documentElement, + document.body + ]).removeClass(classPrefix + 'fullscreen'); } } - return false; - } - function handleWindowResize() { - if (!global$1.desktop) { - var lastSize_1 = { - w: window.innerWidth, - h: window.innerHeight - }; - global$3.setInterval(function () { - var w = window.innerWidth, h = window.innerHeight; - if (lastSize_1.w !== w || lastSize_1.h !== h) { - lastSize_1 = { - w: w, - h: h - }; - global$7(window).trigger('resize'); + function checkFullscreenWindows() { + for (var i = 0; i < windows.length; i++) { + if (windows[i]._fullscreen) { + return true; } - }, 100); + } + return false; } - 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(window).on('resize', reposition); - } - var Window$$1 = 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$$1 = this; - self$$1._super(settings); - if (self$$1.isRtl()) { - self$$1.classes.add('rtl'); - } - self$$1.classes.add('window'); - self$$1.bodyClasses.add('window-body'); - self$$1.state.set('fixed', true); - if (settings.buttons) { - self$$1.statusbar = new Panel({ - layout: 'flex', - border: '1 0 0 0', - spacing: 3, - padding: 10, - align: 'center', - pack: self$$1.isRtl() ? 'start' : 'end', - defaults: { type: 'button' }, - items: settings.buttons - }); - self$$1.statusbar.classes.add('foot'); - self$$1.statusbar.parent(self$$1); - } - self$$1.on('click', function (e) { - var closeClass = self$$1.classPrefix + 'close'; - if (funcs.hasClass(e.target, closeClass) || funcs.hasClass(e.target.parentNode, closeClass)) { - self$$1.close(); - } - }); - self$$1.on('cancel', function () { - self$$1.close(); - }); - self$$1.on('move', function (e) { - if (e.control === self$$1) { - FloatPanel.hideAll(); - } - }); - self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); - self$$1.aria('label', settings.title); - self$$1._fullscreen = false; - }, - recalc: function () { - var self$$1 = this; - var statusbar$$1 = self$$1.statusbar; - var layoutRect, width, x, needsRecalc; - if (self$$1._fullscreen) { - self$$1.layoutRect(funcs.getWindowSize()); - self$$1.layoutRect().contentH = self$$1.layoutRect().innerH; - } - self$$1._super(); - layoutRect = self$$1.layoutRect(); - if (self$$1.settings.title && !self$$1._fullscreen) { - width = layoutRect.headerW; - if (width > layoutRect.w) { - x = layoutRect.x - Math.max(0, width / 2); - self$$1.layoutRect({ - w: width, - x: x - }); - needsRecalc = true; - } - } - if (statusbar$$1) { - statusbar$$1.layoutRect({ w: self$$1.layoutRect().innerW }).recalc(); - width = statusbar$$1.layoutRect().minW + layoutRect.deltaW; - if (width > layoutRect.w) { - x = layoutRect.x - Math.max(0, width - layoutRect.w); - self$$1.layoutRect({ - w: width, - x: x - }); - needsRecalc = true; - } - } - if (needsRecalc) { - self$$1.recalc(); - } - }, - initLayoutRect: function () { - var self$$1 = this; - var layoutRect = self$$1._super(); - var deltaH = 0, headEl; - if (self$$1.settings.title && !self$$1._fullscreen) { - headEl = self$$1.getEl('head'); - var size = funcs.getSize(headEl); - layoutRect.headerW = size.width; - layoutRect.headerH = size.height; - deltaH += layoutRect.headerH; - } - if (self$$1.statusbar) { - deltaH += self$$1.statusbar.layoutRect().h; - } - layoutRect.deltaH += deltaH; - layoutRect.minH += deltaH; - layoutRect.h += deltaH; - var rect = funcs.getWindowSize(); - layoutRect.x = self$$1.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2); - layoutRect.y = self$$1.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2); - return layoutRect; - }, - renderHtml: function () { - var self$$1 = this, layout = self$$1._layout, id = self$$1._id, prefix = self$$1.classPrefix; - var settings = self$$1.settings; - var headerHtml = '', footerHtml = '', html = settings.html; - self$$1.preRender(); - layout.preRender(self$$1); - if (settings.title) { - headerHtml = '
' + '
' + self$$1.encode(settings.title) + '
' + '
' + '' + '
'; - } - if (settings.url) { - html = ''; - } - if (typeof html === 'undefined') { - html = layout.renderHtml(self$$1); - } - if (self$$1.statusbar) { - footerHtml = self$$1.statusbar.renderHtml(); - } - return '
' + '
' + headerHtml + '
' + html + '
' + footerHtml + '
' + '
'; - }, - fullscreen: function (state) { - var self$$1 = this; - var documentElement = document.documentElement; - var slowRendering; - var prefix = self$$1.classPrefix; - var layoutRect; - if (state !== self$$1._fullscreen) { - global$7(window).on('resize', function () { - var time; - if (self$$1._fullscreen) { - if (!slowRendering) { - time = new Date().getTime(); - var rect = funcs.getWindowSize(); - self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); - if (new Date().getTime() - time > 50) { - slowRendering = true; - } - } else { - if (!self$$1._timer) { - self$$1._timer = global$3.setTimeout(function () { - var rect = funcs.getWindowSize(); - self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); - self$$1._timer = 0; - }, 50); - } - } - } - }); - layoutRect = self$$1.layoutRect(); - self$$1._fullscreen = state; - if (!state) { - self$$1.borderBox = $_4kbuyt18pjjgwek1w.parseBox(self$$1.settings.border); - self$$1.getEl('head').style.display = ''; - layoutRect.deltaH += layoutRect.headerH; - global$7([ - documentElement, - document.body - ]).removeClass(prefix + 'fullscreen'); - self$$1.classes.remove('fullscreen'); - self$$1.moveTo(self$$1._initial.x, self$$1._initial.y).resizeTo(self$$1._initial.w, self$$1._initial.h); - } else { - self$$1._initial = { - x: layoutRect.x, - y: layoutRect.y, - w: layoutRect.w, - h: layoutRect.h - }; - self$$1.borderBox = $_4kbuyt18pjjgwek1w.parseBox('0'); - self$$1.getEl('head').style.display = 'none'; - layoutRect.deltaH -= layoutRect.headerH + 2; - global$7([ - documentElement, - document.body - ]).addClass(prefix + 'fullscreen'); - self$$1.classes.add('fullscreen'); - var rect = funcs.getWindowSize(); - self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); - } - } - return self$$1.reflow(); - }, - postRender: function () { - var self$$1 = this; - var startPos; - setTimeout(function () { - self$$1.classes.add('in'); - self$$1.fire('open'); - }, 0); - self$$1._super(); - if (self$$1.statusbar) { - self$$1.statusbar.postRender(); - } - self$$1.focus(); - this.dragHelper = new DragHelper(self$$1._id + '-dragh', { - start: function () { - startPos = { - x: self$$1.layoutRect().x, - y: self$$1.layoutRect().y - }; - }, - drag: function (e) { - self$$1.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY); - } - }); - self$$1.on('submit', function (e) { - if (!e.isDefaultPrevented()) { - self$$1.close(); - } - }); - windows.push(self$$1); - toggleFullScreenState(true); - }, - submit: function () { - return this.fire('submit', { data: this.toJSON() }); - }, - remove: function () { - var self$$1 = this; - var i; - self$$1.dragHelper.destroy(); - self$$1._super(); - if (self$$1.statusbar) { - this.statusbar.remove(); - } - toggleBodyFullScreenClasses(self$$1.classPrefix, false); - i = windows.length; - while (i--) { - if (windows[i] === self$$1) { - 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$$1.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 handleWindowResize() { + if (!global$1.desktop) { + var lastSize_1 = { + w: window.innerWidth, + h: window.innerHeight }; - function createButton(text, status$$1, primary) { - return { - type: 'button', - text: text, - subtype: primary ? 'primary' : '', - onClick: function (e) { - e.control.parents()[1].close(); - callback(status$$1); - } - }; - } - 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)); + global$3.setInterval(function () { + var w = window.innerWidth, h = window.innerHeight; + if (lastSize_1.w !== w || lastSize_1.h !== h) { + lastSize_1 = { + w: w, + h: h + }; + global$7(window).trigger('resize'); } - break; - default: - buttons = [createButton('Ok', true, true)]; - break; + }, 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)); } - return new Window$$1({ + } + global$7(window).on('resize', reposition); + } + var Window$$1 = 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$$1 = this; + self$$1._super(settings); + if (self$$1.isRtl()) { + self$$1.classes.add('rtl'); + } + self$$1.classes.add('window'); + self$$1.bodyClasses.add('window-body'); + self$$1.state.set('fixed', true); + if (settings.buttons) { + self$$1.statusbar = new Panel({ + layout: 'flex', + border: '1 0 0 0', + spacing: 3, + padding: 10, + align: 'center', + pack: self$$1.isRtl() ? 'start' : 'end', + defaults: { type: 'button' }, + items: settings.buttons + }); + self$$1.statusbar.classes.add('foot'); + self$$1.statusbar.parent(self$$1); + } + self$$1.on('click', function (e) { + var closeClass = self$$1.classPrefix + 'close'; + if (funcs.hasClass(e.target, closeClass) || funcs.hasClass(e.target.parentNode, closeClass)) { + self$$1.close(); + } + }); + self$$1.on('cancel', function () { + self$$1.close(); + }); + self$$1.on('move', function (e) { + if (e.control === self$$1) { + FloatPanel.hideAll(); + } + }); + self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); + self$$1.aria('label', settings.title); + self$$1._fullscreen = false; + }, + recalc: function () { + var self$$1 = this; + var statusbar$$1 = self$$1.statusbar; + var layoutRect, width, x, needsRecalc; + if (self$$1._fullscreen) { + self$$1.layoutRect(funcs.getWindowSize()); + self$$1.layoutRect().contentH = self$$1.layoutRect().innerH; + } + self$$1._super(); + layoutRect = self$$1.layoutRect(); + if (self$$1.settings.title && !self$$1._fullscreen) { + width = layoutRect.headerW; + if (width > layoutRect.w) { + x = layoutRect.x - Math.max(0, width / 2); + self$$1.layoutRect({ + w: width, + x: x + }); + needsRecalc = true; + } + } + if (statusbar$$1) { + statusbar$$1.layoutRect({ w: self$$1.layoutRect().innerW }).recalc(); + width = statusbar$$1.layoutRect().minW + layoutRect.deltaW; + if (width > layoutRect.w) { + x = layoutRect.x - Math.max(0, width - layoutRect.w); + self$$1.layoutRect({ + w: width, + x: x + }); + needsRecalc = true; + } + } + if (needsRecalc) { + self$$1.recalc(); + } + }, + initLayoutRect: function () { + var self$$1 = this; + var layoutRect = self$$1._super(); + var deltaH = 0, headEl; + if (self$$1.settings.title && !self$$1._fullscreen) { + headEl = self$$1.getEl('head'); + var size = funcs.getSize(headEl); + layoutRect.headerW = size.width; + layoutRect.headerH = size.height; + deltaH += layoutRect.headerH; + } + if (self$$1.statusbar) { + deltaH += self$$1.statusbar.layoutRect().h; + } + layoutRect.deltaH += deltaH; + layoutRect.minH += deltaH; + layoutRect.h += deltaH; + var rect = funcs.getWindowSize(); + layoutRect.x = self$$1.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2); + layoutRect.y = self$$1.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2); + return layoutRect; + }, + renderHtml: function () { + var self$$1 = this, layout = self$$1._layout, id = self$$1._id, prefix = self$$1.classPrefix; + var settings = self$$1.settings; + var headerHtml = '', footerHtml = '', html = settings.html; + self$$1.preRender(); + layout.preRender(self$$1); + if (settings.title) { + headerHtml = '
' + '
' + self$$1.encode(settings.title) + '
' + '
' + '' + '
'; + } + if (settings.url) { + html = ''; + } + if (typeof html === 'undefined') { + html = layout.renderHtml(self$$1); + } + if (self$$1.statusbar) { + footerHtml = self$$1.statusbar.renderHtml(); + } + return '
' + '
' + headerHtml + '
' + html + '
' + footerHtml + '
' + '
'; + }, + fullscreen: function (state) { + var self$$1 = this; + var documentElement = document.documentElement; + var slowRendering; + var prefix = self$$1.classPrefix; + var layoutRect; + if (state !== self$$1._fullscreen) { + global$7(window).on('resize', function () { + var time; + if (self$$1._fullscreen) { + if (!slowRendering) { + time = new Date().getTime(); + var rect = funcs.getWindowSize(); + self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); + if (new Date().getTime() - time > 50) { + slowRendering = true; + } + } else { + if (!self$$1._timer) { + self$$1._timer = global$3.setTimeout(function () { + var rect = funcs.getWindowSize(); + self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); + self$$1._timer = 0; + }, 50); + } + } + } + }); + layoutRect = self$$1.layoutRect(); + self$$1._fullscreen = state; + if (!state) { + self$$1.borderBox = BoxUtils.parseBox(self$$1.settings.border); + self$$1.getEl('head').style.display = ''; + layoutRect.deltaH += layoutRect.headerH; + global$7([ + documentElement, + document.body + ]).removeClass(prefix + 'fullscreen'); + self$$1.classes.remove('fullscreen'); + self$$1.moveTo(self$$1._initial.x, self$$1._initial.y).resizeTo(self$$1._initial.w, self$$1._initial.h); + } else { + self$$1._initial = { + x: layoutRect.x, + y: layoutRect.y, + w: layoutRect.w, + h: layoutRect.h + }; + self$$1.borderBox = BoxUtils.parseBox('0'); + self$$1.getEl('head').style.display = 'none'; + layoutRect.deltaH -= layoutRect.headerH + 2; + global$7([ + documentElement, + document.body + ]).addClass(prefix + 'fullscreen'); + self$$1.classes.add('fullscreen'); + var rect = funcs.getWindowSize(); + self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); + } + } + return self$$1.reflow(); + }, + postRender: function () { + var self$$1 = this; + var startPos; + setTimeout(function () { + self$$1.classes.add('in'); + self$$1.fire('open'); + }, 0); + self$$1._super(); + if (self$$1.statusbar) { + self$$1.statusbar.postRender(); + } + self$$1.focus(); + this.dragHelper = new DragHelper(self$$1._id + '-dragh', { + start: function () { + startPos = { + x: self$$1.layoutRect().x, + y: self$$1.layoutRect().y + }; + }, + drag: function (e) { + self$$1.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY); + } + }); + self$$1.on('submit', function (e) { + if (!e.isDefaultPrevented()) { + self$$1.close(); + } + }); + windows.push(self$$1); + toggleFullScreenState(true); + }, + submit: function () { + return this.fire('submit', { data: this.toJSON() }); + }, + remove: function () { + var self$$1 = this; + var i; + self$$1.dragHelper.destroy(); + self$$1._super(); + if (self$$1.statusbar) { + this.statusbar.remove(); + } + toggleBodyFullScreenClasses(self$$1.classPrefix, false); + i = windows.length; + while (i--) { + if (windows[i] === self$$1) { + 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$$1.extend({ + init: function (settings) { + settings = { + border: 1, 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', + containerCls: 'panel', + autoScroll: true, + buttons: { + type: 'button', + text: 'Ok', + action: 'ok' + }, 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); + maxHeight: 200 } - }).renderTo(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$$1 = 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$$1(args); - win.on('close', function () { - closeCallback(win); - }); - if (args.data) { - win.on('postRender', function () { - this.find('*').each(function (ctrl) { - var name$$1 = ctrl.name(); - if (name$$1 in args.data) { - ctrl.value(args.data[name$$1]); - } - }); - }); - } - win.features = args || {}; - win.params = params || {}; - win = win.renderTo(document.body).reflow(); - return win; - }; - var alert$$1 = function (message, choiceCallback, closeCallback) { - var win; - win = MessageBox.alert(message, function () { - choiceCallback(); - }); - win.on('close', function () { - closeCallback(win); - }); - return win; - }; - var confirm$$1 = function (message, choiceCallback, closeCallback) { - var win; - win = MessageBox.confirm(message, function (state) { - choiceCallback(state); - }); - win.on('close', function () { - closeCallback(win); - }); - return win; - }; - var close$$1 = function (window$$1) { - window$$1.close(); - }; - var getParams = function (window$$1) { - return window$$1.params; - }; - var setParams = function (window$$1, params) { - window$$1.params = params; - }; - return { - open: open$$1, - alert: alert$$1, - confirm: confirm$$1, - close: close$$1, - getParams: getParams, - setParams: setParams - }; - } - - var get = function (editor, panel) { - var renderUI = function () { - return $_b0wxh217tjjgwejyx.renderUI(editor, panel); - }; - return { - renderUI: renderUI, - getNotificationManagerImpl: function () { - return NotificationManagerImpl(editor); + this._super(settings); }, - getWindowManagerImpl: function () { - return WindowManagerImpl(editor); - } - }; - }; - var $_7y4x3k17sjjgwejyw = { get: get }; - - var Global = typeof window !== 'undefined' ? 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 name + ' not available on this browser'; - return actual; - }; - var $_8wnjhx19gjjgwek54 = { getOrDie: getOrDie }; - - function FileReader () { - var f = $_8wnjhx19gjjgwek54.getOrDie('FileReader'); - return new f(); - } - - var global$12 = tinymce.util.Tools.resolve('tinymce.util.Promise'); - - var blobToBase64 = function (blob) { - return new global$12(function (resolve) { - var reader = new FileReader(); - reader.onloadend = function () { - resolve(reader.result.split(',')[1]); - }; - reader.readAsDataURL(blob); - }); - }; - var $_c292419ejjgwek4z = { blobToBase64: blobToBase64 }; - - var pickFile = function () { - return new global$12(function (resolve) { - var fileInput; - fileInput = document.createElement('input'); - fileInput.type = 'file'; - fileInput.style.position = 'fixed'; - fileInput.style.left = 0; - fileInput.style.top = 0; - fileInput.style.opacity = 0.001; - document.body.appendChild(fileInput); - fileInput.onchange = function (e) { - resolve(Array.prototype.slice.call(e.target.files)); - }; - fileInput.click(); - fileInput.parentNode.removeChild(fileInput); - }); - }; - var $_edjfwb19kjjgwek5a = { 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 $_49gxzf19mjjgwek5f = { 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 $_3b24e19ojjgwek5i = { - create: create$1, - resolve: resolve$1 - }; - - var global$13 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker'); - - var global$14 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils'); - - var getSelectedElements = function (rootElm, startNode, endNode) { - var walker, node; - var elms = []; - walker = new global$13(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 = $_3b24e19ojjgwek5i.create(dom, selection.getRng()); - global$4.each(elms, function (elm) { - editor.dom.remove(elm, true); - }); - selection.setRng($_3b24e19ojjgwek5i.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$14.getNode(rng.startContainer, rng.startOffset)); - endElm = global$14.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 $_aunbnv19njjgwek5g = { 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($_49gxzf19mjjgwek5f.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(); - $_aunbnv19njjgwek5g.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 $_elxm3u19ljjgwek5d = { - insertTable: insertTable, - formatBlock: formatBlock, - insertBlob: insertBlob, - createLink: createLink, - unlink: unlink - }; - - var addHeaderButtons = function (editor) { - var formatBlock = function (name) { - return function () { - $_elxm3u19ljjgwek5d.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 () { - $_edjfwb19kjjgwek5a.pickFile().then(function (files) { - var blob = files[0]; - $_c292419ejjgwek4z.blobToBase64(blob).then(function (base64) { - $_elxm3u19ljjgwek5d.insertBlob(editor, base64, blob); - }); - }); - } - }); - editor.addButton('quicktable', { - icon: 'table', - tooltip: 'Insert table', - onclick: function () { - panel.hide(); - $_elxm3u19ljjgwek5d.insertTable(editor, 2, 2); - } - }); - addHeaderButtons(editor); - }; - var $_epdxt419djjgwek4l = { 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 $_9hbv4x19sjjgwek5q = { 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 $_5y05uk19ujjgwek5w = { - 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$11.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$12(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 !$_5y05uk19ujjgwek5w.isAbsolute(href) && $_5y05uk19ujjgwek5w.isDomainLike(href) ? askAboutPrefix(editor, href) : global$12.resolve(href); - }; - var createQuickLinkForm = function (editor, hide) { - var attachState = {}; - var unlink = function () { - editor.focus(); - $_elxm3u19ljjgwek5d.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 = {}; - } - $_elxm3u19ljjgwek5d.createLink(editor, url); - }); - hide(); - }); - } - }); - }; - var $_amewps19tjjgwek5t = { 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 ($_e4npq318ajjgwejzo.isArray(items)) { - return items; - } else if ($_e4npq318ajjgwejzo.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: [] + 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$$1, primary) { + return { + type: 'button', + text: text, + subtype: primary ? 'primary' : '', + onClick: function (e) { + e.control.parents()[1].close(); + callback(status$$1); + } }; - toolbarItems.push(buttonGroup); } - var button = editor.buttons[item]; - if ($_e4npq318ajjgwejzo.isFunction(button)) { - button = button(); + 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; } - button.type = button.type || 'button'; - button = global$11.create(button); - button.on('postRender', bindSelectorChanged(editor, item, button)); - buttonGroup.items.push(button); + return new Window$$1({ + 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(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); } } }); - return global$11.create({ - type: 'toolbar', - layout: 'flow', - name: name, - items: toolbarItems - }); - }; - var $_797pa819vjjgwek5x = { create: create$2 }; - var create$3 = function () { - var panel, currentRect; - var createToolbars = function (editor, toolbars) { - return global$4.map(toolbars, function (toolbar) { - return $_797pa819vjjgwek5x.create(editor, toolbar.id, toolbar.items); + function WindowManagerImpl (editor) { + var open$$1 = 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$$1(args); + win.on('close', function () { + closeCallback(win); + }); + if (args.data) { + win.on('postRender', function () { + this.find('*').each(function (ctrl) { + var name$$1 = ctrl.name(); + if (name$$1 in args.data) { + ctrl.value(args.data[name$$1]); + } + }); + }); + } + win.features = args || {}; + win.params = params || {}; + win = win.renderTo(document.body).reflow(); + return win; + }; + var alert$$1 = function (message, choiceCallback, closeCallback) { + var win; + win = MessageBox.alert(message, function () { + choiceCallback(); + }); + win.on('close', function () { + closeCallback(win); + }); + return win; + }; + var confirm$$1 = function (message, choiceCallback, closeCallback) { + var win; + win = MessageBox.confirm(message, function (state) { + choiceCallback(state); + }); + win.on('close', function () { + closeCallback(win); + }); + return win; + }; + var close$$1 = function (window$$1) { + window$$1.close(); + }; + var getParams = function (window$$1) { + return window$$1.params; + }; + var setParams = function (window$$1, params) { + window$$1.params = params; + }; + return { + open: open$$1, + alert: alert$$1, + confirm: confirm$$1, + close: close$$1, + 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(editor); + } + }; + }; + var ThemeApi = { get: get }; + + var Global = typeof window !== 'undefined' ? 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 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 hasToolbarItems = function (toolbar) { - return toolbar.items().length > 0; + var Conversions = { blobToBase64: blobToBase64 }; + + var pickFile = function () { + return new global$c(function (resolve) { + var fileInput; + fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.style.position = 'fixed'; + fileInput.style.left = 0; + fileInput.style.top = 0; + fileInput.style.opacity = 0.001; + document.body.appendChild(fileInput); + fileInput.onchange = function (e) { + resolve(Array.prototype.slice.call(e.target.files)); + }; + fileInput.click(); + fileInput.parentNode.removeChild(fileInput); + }); }; - var create = function (editor, toolbars) { - var items = createToolbars(editor, toolbars).concat([ - $_797pa819vjjgwek5x.create(editor, 'text', $_4j2h42187jjgwejzk.getTextSelectionToolbarItems(editor)), - $_797pa819vjjgwek5x.create(editor, 'insert', $_4j2h42187jjgwejzk.getInsertToolbarItems(editor)), - $_amewps19tjjgwek5t.createQuickLinkForm(editor, hide) - ]); - return global$11.create({ - type: 'floatpanel', - role: 'dialog', - classes: 'tinymce tinymce-inline arrow', - ariaLabel: 'Inline toolbar', + 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: 'column', - align: 'stretch', - autohide: false, - autofix: true, - fixed: true, - border: 1, - items: global$4.grep(items, hasToolbarItems), - oncancel: function () { - editor.focus(); + 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 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', true); - 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 = $_4j2h42187jjgwejzk.getPositionHandler(editor); - contentAreaRect = $_51qgo2180jjgwejzb.getContentAreaRect(editor); - panelRect = global$2.DOM.getRect(panel.getEl()); - if (id === 'insert') { - result = $_gir42l18bjjgwejzq.calcInsert(targetRect, contentAreaRect, panelRect); - } else { - result = $_gir42l18bjjgwejzq.calc(targetRect, contentAreaRect, panelRect); - } - if (result) { - var delta = $_9hbv4x19sjjgwek5q.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 + var Forms = { createQuickLinkForm: createQuickLinkForm }; + + var getSelectorStateResult = function (itemName, item) { + var result = function (selector, handler) { + return { + selector: selector, + handler: handler }; - currentRect = targetRect; - movePanelTo(panel, $_gir42l18bjjgwejzq.userConstrain(userConstainHandler, targetRect, contentAreaRect, transposedPanelRect)); - togglePositionClass(panel, result.position); - return true; - } else { - return false; + }; + 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 showPanelAt = function (panel, id, editor, targetRect) { - showPanel(panel); - panel.items().hide(); - if (!showToolbar(panel, id)) { - hide(); + 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; } - if (repositionPanelAt(panel, id, editor, targetRect) === false) { - hide(); - } + 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 hasFormVisible = function () { - return panel.items().filter('form:visible').length > 0; - }; - var showForm = function (editor, id) { - if (panel) { + 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; } - var contentAreaRect = void 0, panelRect = void 0, result = void 0, userConstainHandler = void 0; - showPanel(panel); - panel.items().hide(); - showToolbar(panel, id); - userConstainHandler = $_4j2h42187jjgwejzk.getPositionHandler(editor); - contentAreaRect = $_51qgo2180jjgwejzb.getContentAreaRect(editor); - panelRect = global$2.DOM.getRect(panel.getEl()); - result = $_gir42l18bjjgwejzq.calc(currentRect, contentAreaRect, panelRect); - if (result) { - panelRect = result.rect; - movePanelTo(panel, $_gir42l18bjjgwejzq.userConstrain(userConstainHandler, currentRect, contentAreaRect, panelRect)); - togglePositionClass(panel, result.position); + if (repositionPanelAt(panel, id, editor, targetRect) === false) { + hide(); } - } - }; - var show = function (editor, id, targetRect, toolbars) { - if (!panel) { - $_77u64d186jjgwejzi.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; + }; + 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; } - 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$$1 = this; - var size; - self$$1._super(settings); - settings = self$$1.settings; - size = self$$1.settings.size; - self$$1.on('click mousedown', function (e) { - e.preventDefault(); - }); - self$$1.on('touchstart', function (e) { - self$$1.fire('click', e); - e.preventDefault(); - }); - if (settings.subtype) { - self$$1.classes.add(settings.subtype); - } - if (size) { - self$$1.classes.add('btn-' + size); - } - if (settings.icon) { - self$$1.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$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; - var icon = self$$1.state.get('icon'), image; - var text = self$$1.state.get('text'); - var textHtml = ''; - var ariaPressed; - var settings = self$$1.settings; - image = settings.image; - if (image) { - icon = 'none'; - if (typeof image !== 'string') { - image = window.getSelection ? image[0] : image[1]; - } - image = ' style="background-image: url(\'' + image + '\')"'; - } else { - image = ''; - } - if (text) { - self$$1.classes.add('btn-has-text'); - textHtml = '' + self$$1.encode(text) + ''; - } - icon = icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; - ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; - return '
' + '' + '
'; - }, - bindStates: function () { - var self$$1 = this, $ = self$$1.$, textCls = self$$1.classPrefix + 'txt'; - function setButtonText(text) { - var $span = $('span.' + textCls, self$$1.getEl()); - if (text) { - if (!$span[0]) { - $('button:first', self$$1.getEl()).append(''); - $span = $('span.' + textCls, self$$1.getEl()); + 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); } - $span.html(self$$1.encode(text)); - } else { - $span.remove(); } - self$$1.classes.toggle('btn-has-text', !!text); - } - self$$1.state.on('change:text', function (e) { - setButtonText(e.value); - }); - self$$1.state.on('change:icon', function (e) { - var icon = e.value; - var prefix = self$$1.classPrefix; - self$$1.settings.icon = icon; - icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; - var btnElm = self$$1.getEl().firstChild; - var iconElm = btnElm.getElementsByTagName('i')[0]; - if (icon) { - if (!iconElm || iconElm !== btnElm.firstChild) { - iconElm = document.createElement('i'); - btnElm.insertBefore(iconElm, btnElm.firstChild); - } - iconElm.className = icon; - } else if (iconElm) { - btnElm.removeChild(iconElm); + }; + 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(); } - setButtonText(self$$1.state.get('text')); - }); - return self$$1._super(); - } - }); + 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 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', function (e) { - e.stopPropagation(); - input.click(); - }); - 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$$1 = this; - self$$1._super(settings); - self$$1.on('click mousedown', function (e) { - e.preventDefault(); - }); - self$$1.on('click', function (e) { - e.preventDefault(); - if (!self$$1.disabled()) { - self$$1.checked(!self$$1.checked()); - } - }); - self$$1.checked(self$$1.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$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; - return '
' + '' + '' + self$$1.encode(self$$1.state.get('text')) + '' + '
'; - }, - bindStates: function () { - var self$$1 = this; - function checked(state) { - self$$1.classes.toggle('checked', state); - self$$1.aria('checked', state); - } - self$$1.state.on('change:text', function (e) { - self$$1.getEl('al').firstChild.data = self$$1.translate(e.value); - }); - self$$1.state.on('change:checked change:value', function (e) { - self$$1.fire('change'); - checked(e.value); - }); - self$$1.state.on('change:icon', function (e) { - var icon = e.value; - var prefix = self$$1.classPrefix; - if (typeof icon === 'undefined') { - return self$$1.settings.icon; - } - self$$1.settings.icon = icon; - icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; - var btnElm = self$$1.getEl().firstChild; - var iconElm = btnElm.getElementsByTagName('i')[0]; - if (icon) { - if (!iconElm || iconElm !== btnElm.firstChild) { - iconElm = document.createElement('i'); - btnElm.insertBefore(iconElm, btnElm.firstChild); - } - iconElm.className = icon; - } else if (iconElm) { - btnElm.removeChild(iconElm); - } - }); - if (self$$1.state.get('checked')) { - checked(true); - } - return self$$1._super(); - } - }); - - var global$15 = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var ComboBox = Widget.extend({ - init: function (settings) { - var self$$1 = this; - self$$1._super(settings); - settings = self$$1.settings; - self$$1.classes.add('combobox'); - self$$1.subinput = true; - self$$1.ariaTarget = 'inp'; - settings.menu = settings.menu || settings.values; - if (settings.menu) { - settings.icon = 'caret'; - } - self$$1.on('click', function (e) { - var elm = e.target; - var root = self$$1.getEl(); - if (!global$7.contains(root, elm) && elm !== root) { - return; - } - while (elm && elm !== root) { - if (elm.id && elm.id.indexOf('-open') !== -1) { - self$$1.fire('action'); - if (settings.menu) { - self$$1.showMenu(); - if (e.aria) { - self$$1.menu.items()[0].focus(); - } + 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; } - } - elm = elm.parentNode; - } - }); - self$$1.on('keydown', function (e) { - var rootControl; - if (e.keyCode === 13 && e.target.nodeName === 'INPUT') { - e.preventDefault(); - self$$1.parents().reverse().each(function (ctrl) { - if (ctrl.toJSON) { - rootControl = ctrl; - return false; - } - }); - self$$1.fire('submit', { data: rootControl.toJSON() }); - } - }); - self$$1.on('keyup', function (e) { - if (e.target.nodeName === 'INPUT') { - var oldValue = self$$1.state.get('value'); - var newValue = e.target.value; - if (newValue !== oldValue) { - self$$1.state.set('value', newValue); - self$$1.fire('autocomplete', e); - } - } - }); - self$$1.on('mouseover', function (e) { - var tooltip = self$$1.tooltip().moveTo(-65535); - if (self$$1.statusLevel() && e.target.className.indexOf(self$$1.classPrefix + 'status') !== -1) { - var statusMessage = self$$1.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$$1 = this; - var settings = self$$1.settings; - var menu; - if (!self$$1.menu) { - menu = settings.menu || []; - if (menu.length) { - menu = { - type: 'menu', - items: menu - }; - } else { - menu.type = menu.type || 'menu'; - } - self$$1.menu = global$11.create(menu).parent(self$$1).renderTo(self$$1.getContainerElm()); - self$$1.fire('createmenu'); - self$$1.menu.reflow(); - self$$1.menu.on('cancel', function (e) { - if (e.control === self$$1.menu) { - self$$1.focus(); + lastItem = item; } }); - self$$1.menu.on('show hide', function (e) { - e.control.items().each(function (ctrl) { - ctrl.active(ctrl.value() === self$$1.value()); - }); - }).fire('show'); - self$$1.menu.on('select', function (e) { - self$$1.value(e.control.value()); + 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(); }); - self$$1.on('focusin', function (e) { - if (e.target.tagName.toUpperCase() === 'INPUT') { - self$$1.menu.hide(); - } - }); - self$$1.aria('expanded', true); - } - self$$1.menu.show(); - self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); - self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ - 'br-tr', - 'tr-br' - ] : [ - 'bl-tl', - 'tl-bl' - ]); - }, - focus: function () { - this.getEl('inp').focus(); - }, - repaint: function () { - var self$$1 = this, elm = self$$1.getEl(), openElm = self$$1.getEl('open'), rect = self$$1.layoutRect(); - var width, lineHeight, innerPadding = 0; - var inputElm = elm.firstChild; - if (self$$1.statusLevel() && self$$1.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 = document; - if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) { - lineHeight = self$$1.layoutRect().h - 2 + 'px'; - } - global$7(inputElm).css({ - width: width - innerPadding, - lineHeight: lineHeight - }); - self$$1._super(); - return self$$1; - }, - postRender: function () { - var self$$1 = this; - global$7(this.getEl('inp')).on('change', function (e) { - self$$1.state.set('value', e.target.value); - self$$1.fire('change', e); - }); - return self$$1._super(); - }, - renderHtml: function () { - var self$$1 = this, id = self$$1._id, settings = self$$1.settings, prefix = self$$1.classPrefix; - var value = self$$1.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$$1.disabled()) { - extraAttrs += ' disabled="disabled"'; - } - icon = settings.icon; - if (icon && icon !== 'caret') { - icon = prefix + 'ico ' + prefix + 'i-' + settings.icon; - } - text = self$$1.state.get('text'); - if (icon || text) { - openBtnHtml = '
' + '' + '
'; - self$$1.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$$1 = this; - if (items.length === 0) { - self$$1.hideMenu(); - return; - } - var insert = function (value, title) { - return function () { - self$$1.fire('selectitem', { - title: title, - value: value - }); - }; - }; - if (self$$1.menu) { - self$$1.menu.items().remove(); - } else { - self$$1.menu = global$11.create({ - type: 'menu', - classes: 'combobox-menu', - layout: 'flow' - }).parent(self$$1).renderTo(); - } - global$4.each(items, function (item) { - self$$1.menu.add({ - text: item.title, - url: item.previewUrl, - match: term, - classes: 'menu-item-ellipsis', - onclick: insert(item.value, item.title) - }); - }); - self$$1.menu.renderNew(); - self$$1.hideMenu(); - self$$1.menu.on('cancel', function (e) { - if (e.control.parent() === self$$1.menu) { - e.stopPropagation(); - self$$1.focus(); - self$$1.hideMenu(); - } - }); - self$$1.menu.on('select', function () { - self$$1.focus(); - }); - var maxW = self$$1.layoutRect().w; - self$$1.menu.layoutRect({ - w: maxW, - minW: 0, - maxW: maxW - }); - self$$1.menu.repaint(); - self$$1.menu.reflow(); - self$$1.menu.show(); - self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ - 'br-tr', - 'tr-br' - ] : [ - 'bl-tl', - 'tl-bl' - ]); - }, - hideMenu: function () { - if (this.menu) { - this.menu.hide(); - } - }, - bindStates: function () { - var self$$1 = this; - self$$1.state.on('change:value', function (e) { - if (self$$1.getEl('inp').value !== e.value) { - self$$1.getEl('inp').value = e.value; - } - }); - self$$1.state.on('change:disabled', function (e) { - self$$1.getEl('inp').disabled = e.value; - }); - self$$1.state.on('change:statusLevel', function (e) { - var statusIconElm = self$$1.getEl('status'); - var prefix = self$$1.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$$1.classes.toggle('has-status', value !== 'none'); - self$$1.repaint(); - }); - funcs.on(self$$1.getEl('status'), 'mouseleave', function () { - self$$1.tooltip().hide(); - }); - self$$1.on('cancel', function (e) { - if (self$$1.menu && self$$1.menu.visible()) { - e.stopPropagation(); - self$$1.hideMenu(); - } - }); - var focusIdx = function (idx, menu) { - if (menu && menu.items().length > 0) { - menu.items().eq(idx)[0].focus(); - } - }; - self$$1.on('keydown', function (e) { - var keyCode = e.keyCode; - if (e.target.nodeName === 'INPUT') { - if (keyCode === global$15.DOWN) { - e.preventDefault(); - self$$1.fire('autocomplete'); - focusIdx(0, self$$1.menu); - } else if (keyCode === global$15.UP) { - e.preventDefault(); - focusIdx(-1, self$$1.menu); - } - } - }); - return self$$1._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 '
' + '' + '' + '
'; - }, - 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$16 = 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$16({ - 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$16(); - } - 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 '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + hueHtml + '
'; - } - }); - - 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 ? '' : '') + '
' + 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; - } - } + }, + recalc: function () { + }, + postRender: function () { + }, + isNative: function () { 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 || document; - var div = doc.createElement('div'); - div.innerHTML = html; - if (!div.hasChildNodes() || div.childNodes.length > 1) { - console.error('HTML does not have a single root node', html); - throw 'HTML must have a single root node'; - } - return fromDom(div.childNodes[0]); - }; - var fromTag = function (tag, scope) { - var doc = scope || document; - var node = doc.createElement(tag); - return fromDom(node); - }; - var fromText = function (text, scope) { - var doc = scope || 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$$1 = { - 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 $_2jrgnk1apjjgwek8y = { - ATTRIBUTE: Node.ATTRIBUTE_NODE, - CDATA_SECTION: Node.CDATA_SECTION_NODE, - COMMENT: Node.COMMENT_NODE, - DOCUMENT: Node.DOCUMENT_NODE, - DOCUMENT_TYPE: Node.DOCUMENT_TYPE_NODE, - DOCUMENT_FRAGMENT: Node.DOCUMENT_FRAGMENT_NODE, - ELEMENT: Node.ELEMENT_NODE, - TEXT: Node.TEXT_NODE, - PROCESSING_INSTRUCTION: Node.PROCESSING_INSTRUCTION_NODE, - ENTITY_REFERENCE: Node.ENTITY_REFERENCE_NODE, - ENTITY: Node.ENTITY_NODE, - NOTATION: Node.NOTATION_NODE - }; - - var name = function (element) { - var r = element.dom().nodeName; - return r.toLowerCase(); - }; - var type = function (element) { - return element.dom().nodeType; - }; - var value = function (element) { - return element.dom().nodeValue; - }; - var isType$2 = function (t) { - return function (element) { - return type(element) === t; - }; - }; - var isComment = function (element) { - return type(element) === $_2jrgnk1apjjgwek8y.COMMENT || name(element) === '#comment'; - }; - var isElement = isType$2($_2jrgnk1apjjgwek8y.ELEMENT); - var isText = isType$2($_2jrgnk1apjjgwek8y.TEXT); - var isDocument = isType$2($_2jrgnk1apjjgwek8y.DOCUMENT); - var $_fv3as1aojjgwek8x = { - name: name, - type: type, - value: value, - isElement: isElement, - isText: isText, - isDocument: isDocument, - isComment: isComment - }; - - var inBody = function (element) { - var dom = $_fv3as1aojjgwek8x.isText(element) ? element.dom().parentNode : element.dom(); - return dom !== undefined && dom !== null && dom.ownerDocument.body.contains(dom); - }; - var body = cached(function () { - return getBody(Element$$1.fromDom(document)); - }); - var getBody = function (doc) { - var body = doc.dom().body; - if (body === null || body === undefined) - throw 'Body is not available yet'; - return Element$$1.fromDom(body); - }; - var $_d2glpe1amjjgwek8t = { - body: body, - getBody: getBody, - inBody: inBody - }; - - 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 toArray = function (target, f) { - var r = []; - var recurse = function (e) { - r.push(e); - return f(e); - }; - var cur = f(target); - do { - cur = cur.bind(recurse); - } while (cur.isSome()); - return r; - }; - var $_607sf01awjjgweka0 = { toArray: toArray }; - - var node = function () { - var f = $_8wnjhx19gjjgwek54.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 $_d0o64o1ayjjgwekaa = { - 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$2 = 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$2(versionRegexes, cleanedAgent); - }; - var unknown = function () { - return nu(0, 0); - }; - var nu = function (major, minor) { - return { - major: major, - minor: minor - }; - }; - var $_bhlk9t1b2jjgwekaq = { - 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: $_bhlk9t1b2jjgwekaq.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 $_3j4jht1b1jjgwekal = { - 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: $_bhlk9t1b2jjgwekaq.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 $_7je60a1b3jjgwekar = { - 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) - }; - - function DeviceType (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 = $_bhlk9t1b2jjgwekaq.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 = $_bhlk9t1b2jjgwekaq.detect(os.versionRegexes, userAgent); - return { - current: os.name, - version: version - }; - }); - }; - var $_1uo66k1b5jjgwekb9 = { - detectBrowser: detectBrowser, - detectOs: detectOs - }; - - var contains$1 = function (str, substr) { - return str.indexOf(substr) !== -1; - }; - - var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; - var checkContains = function (target) { - return function (uastring) { - return contains$1(uastring, target); - }; - }; - var browsers = [ - { - name: 'Edge', - versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], - search: function (uastring) { - var monstrosity = contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit'); - return monstrosity; - } - }, - { - name: 'Chrome', - versionRegexes: [ - /.*?chrome\/([0-9]+)\.([0-9]+).*/, - normalVersionRegex - ], - search: function (uastring) { - return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe'); - } - }, - { - name: 'IE', - versionRegexes: [ - /.*?msie\ ?([0-9]+)\.([0-9]+).*/, - /.*?rv:([0-9]+)\.([0-9]+).*/ - ], - search: function (uastring) { - return contains$1(uastring, 'msie') || contains$1(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$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit'); - } - } - ]; - var oses = [ - { - name: 'Windows', - search: checkContains('win'), - versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] - }, - { - name: 'iOS', - search: function (uastring) { - return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad'); + var AbsoluteLayout = Layout$1.extend({ + Defaults: { + containerClass: 'abs-layout', + controlClass: 'abs-layout-item' }, - 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 $_4f7v971b6jjgwekbd = { - browsers: constant(browsers), - oses: constant(oses) - }; - - var detect$2 = function (userAgent) { - var browsers = $_4f7v971b6jjgwekbd.browsers(); - var oses = $_4f7v971b6jjgwekbd.oses(); - var browser = $_1uo66k1b5jjgwekb9.detectBrowser(browsers, userAgent).fold($_3j4jht1b1jjgwekal.unknown, $_3j4jht1b1jjgwekal.nu); - var os = $_1uo66k1b5jjgwekb9.detectOs(oses, userAgent).fold($_7je60a1b3jjgwekar.unknown, $_7je60a1b3jjgwekar.nu); - var deviceType = DeviceType(os, browser, userAgent); - return { - browser: browser, - os: os, - deviceType: deviceType - }; - }; - var $_d71emz1b0jjgwekak = { detect: detect$2 }; - - var detect$3 = cached(function () { - var userAgent = navigator.userAgent; - return $_d71emz1b0jjgwekak.detect(userAgent); - }); - var $_9xrxmy1azjjgwekac = { detect: detect$3 }; - - var ELEMENT = $_2jrgnk1apjjgwek8y.ELEMENT; - var DOCUMENT = $_2jrgnk1apjjgwek8y.DOCUMENT; - var is = function (element, selector) { - var elem = element.dom(); - if (elem.nodeType !== ELEMENT) - return false; - else if (elem.matches !== undefined) - return elem.matches(selector); - else if (elem.msMatchesSelector !== undefined) - return elem.msMatchesSelector(selector); - else if (elem.webkitMatchesSelector !== undefined) - return elem.webkitMatchesSelector(selector); - else if (elem.mozMatchesSelector !== undefined) - return elem.mozMatchesSelector(selector); - else - throw new Error('Browser lacks native selectors'); - }; - var bypassSelector = function (dom) { - return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT || dom.childElementCount === 0; - }; - var all = function (selector, scope) { - var base = scope === undefined ? document : scope.dom(); - return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element$$1.fromDom); - }; - var one = function (selector, scope) { - var base = scope === undefined ? document : scope.dom(); - return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element$$1.fromDom); - }; - var $_e63uk51bajjgwekbq = { - all: all, - is: is, - one: one - }; - - var eq = function (e1, e2) { - return e1.dom() === e2.dom(); - }; - var isEqualNode = function (e1, e2) { - return e1.dom().isEqualNode(e2.dom()); - }; - var member = function (element, elements) { - return exists(elements, curry(eq, element)); - }; - var regularContains = function (e1, e2) { - var d1 = e1.dom(), d2 = e2.dom(); - return d1 === d2 ? false : d1.contains(d2); - }; - var ieContains = function (e1, e2) { - return $_d0o64o1ayjjgwekaa.documentPositionContainedBy(e1.dom(), e2.dom()); - }; - var browser = $_9xrxmy1azjjgwekac.detect().browser; - var contains$2 = browser.isIE() ? ieContains : regularContains; - var $_36s5ie1axjjgweka1 = { - eq: eq, - isEqualNode: isEqualNode, - member: member, - contains: contains$2, - is: $_e63uk51bajjgwekbq.is - }; - - var owner = function (element) { - return Element$$1.fromDom(element.dom().ownerDocument); - }; - var documentElement = function (element) { - return Element$$1.fromDom(element.dom().ownerDocument.documentElement); - }; - var defaultView = function (element) { - var el = element.dom(); - var defaultView = el.ownerDocument.defaultView; - return Element$$1.fromDom(defaultView); - }; - var parent$1 = function (element) { - var dom = element.dom(); - return Option.from(dom.parentNode).map(Element$$1.fromDom); - }; - var findIndex$1 = function (element) { - return parent$1(element).bind(function (p) { - var kin = children(p); - return findIndex(kin, function (elem) { - return $_36s5ie1axjjgweka1.eq(element, elem); - }); - }); - }; - var parents = function (element, isRoot) { - var stop = isFunction$1(isRoot) ? isRoot : constant(false); - var dom = element.dom(); - var ret = []; - while (dom.parentNode !== null && dom.parentNode !== undefined) { - var rawParent = dom.parentNode; - var parent = Element$$1.fromDom(rawParent); - ret.push(parent); - if (stop(parent) === true) - break; - else - dom = rawParent; - } - return ret; - }; - var siblings = function (element) { - var filterSelf = function (elements) { - return filter(elements, function (x) { - return !$_36s5ie1axjjgweka1.eq(element, x); - }); - }; - return parent$1(element).map(children).map(filterSelf).getOr([]); - }; - var offsetParent = function (element) { - var dom = element.dom(); - return Option.from(dom.offsetParent).map(Element$$1.fromDom); - }; - var prevSibling = function (element) { - var dom = element.dom(); - return Option.from(dom.previousSibling).map(Element$$1.fromDom); - }; - var nextSibling = function (element) { - var dom = element.dom(); - return Option.from(dom.nextSibling).map(Element$$1.fromDom); - }; - var prevSiblings = function (element) { - return reverse($_607sf01awjjgweka0.toArray(element, prevSibling)); - }; - var nextSiblings = function (element) { - return $_607sf01awjjgweka0.toArray(element, nextSibling); - }; - var children = function (element) { - var dom = element.dom(); - return map(dom.childNodes, Element$$1.fromDom); - }; - var child = function (element, index) { - var children = element.dom().childNodes; - return Option.from(children[index]).map(Element$$1.fromDom); - }; - var firstChild = function (element) { - return child(element, 0); - }; - var lastChild = function (element) { - return child(element, element.dom().childNodes.length - 1); - }; - var childNodesCount = function (element) { - return element.dom().childNodes.length; - }; - var hasChildNodes = function (element) { - return element.dom().hasChildNodes(); - }; - var spot = Immutable('element', 'offset'); - var leaf = function (element, offset) { - var cs = children(element); - return cs.length > 0 && offset < cs.length ? spot(cs[offset], 0) : spot(element, offset); - }; - var $_fk3hdw1aqjjgwek91 = { - owner: owner, - defaultView: defaultView, - documentElement: documentElement, - parent: parent$1, - findIndex: findIndex$1, - parents: parents, - siblings: siblings, - prevSibling: prevSibling, - offsetParent: offsetParent, - prevSiblings: prevSiblings, - nextSibling: nextSibling, - nextSiblings: nextSiblings, - children: children, - child: child, - firstChild: firstChild, - lastChild: lastChild, - childNodesCount: childNodesCount, - hasChildNodes: hasChildNodes, - leaf: leaf - }; - - var all$1 = function (predicate) { - return descendants($_d2glpe1amjjgwek8t.body(), predicate); - }; - var ancestors = function (scope, predicate, isRoot) { - return filter($_fk3hdw1aqjjgwek91.parents(scope, isRoot), predicate); - }; - var siblings$1 = function (scope, predicate) { - return filter($_fk3hdw1aqjjgwek91.siblings(scope), predicate); - }; - var children$1 = function (scope, predicate) { - return filter($_fk3hdw1aqjjgwek91.children(scope), predicate); - }; - var descendants = function (scope, predicate) { - var result = []; - each($_fk3hdw1aqjjgwek91.children(scope), function (x) { - if (predicate(x)) { - result = result.concat([x]); - } - result = result.concat(descendants(x, predicate)); - }); - return result; - }; - var $_4re57m1aljjgwek8p = { - all: all$1, - ancestors: ancestors, - siblings: siblings$1, - children: children$1, - descendants: descendants - }; - - var all$2 = function (selector) { - return $_e63uk51bajjgwekbq.all(selector); - }; - var ancestors$1 = function (scope, selector, isRoot) { - return $_4re57m1aljjgwek8p.ancestors(scope, function (e) { - return $_e63uk51bajjgwekbq.is(e, selector); - }, isRoot); - }; - var siblings$2 = function (scope, selector) { - return $_4re57m1aljjgwek8p.siblings(scope, function (e) { - return $_e63uk51bajjgwekbq.is(e, selector); - }); - }; - var children$2 = function (scope, selector) { - return $_4re57m1aljjgwek8p.children(scope, function (e) { - return $_e63uk51bajjgwekbq.is(e, selector); - }); - }; - var descendants$1 = function (scope, selector) { - return $_e63uk51bajjgwekbq.all(selector, scope); - }; - var $_1jc9su1akjjgwek8o = { - all: all$2, - ancestors: ancestors$1, - siblings: siblings$2, - children: children$2, - descendants: descendants$1 - }; - - var trim$1 = 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($_1jc9su1akjjgwek8o.descendants(Element$$1.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$1(target.title).length > 0; - }; - var find$3 = function (elm) { - var elms = getTargetElements(elm); - return filter(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle); - }; - var $_5ia43q1ahjjgwek7u = { find: find$3 }; - - 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 = $_5ia43q1ahjjgwek7u.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; - } - }); - - function ClosestOrAncestor (is, ancestor, scope, a, isRoot) { - return is(scope, a) ? Option.some(scope) : isFunction$1(isRoot) && isRoot(scope) ? Option.none() : ancestor(scope, a, isRoot); - } - - var first$1 = function (predicate) { - return descendant($_d2glpe1amjjgwek8t.body(), predicate); - }; - var ancestor = function (scope, predicate, isRoot) { - var element = scope.dom(); - var stop = isFunction$1(isRoot) ? isRoot : constant(false); - while (element.parentNode) { - element = element.parentNode; - var el = Element$$1.fromDom(element); - if (predicate(el)) - return Option.some(el); - else if (stop(el)) - break; - } - return Option.none(); - }; - var closest = function (scope, predicate, isRoot) { - var is = function (scope) { - return predicate(scope); - }; - return ClosestOrAncestor(is, ancestor, scope, predicate, isRoot); - }; - var sibling = function (scope, predicate) { - var element = scope.dom(); - if (!element.parentNode) - return Option.none(); - return child$1(Element$$1.fromDom(element.parentNode), function (x) { - return !$_36s5ie1axjjgweka1.eq(scope, x) && predicate(x); - }); - }; - var child$1 = function (scope, predicate) { - var result = find(scope.dom().childNodes, compose(predicate, Element$$1.fromDom)); - return result.map(Element$$1.fromDom); - }; - var descendant = function (scope, predicate) { - var descend = function (node) { - for (var i = 0; i < node.childNodes.length; i++) { - if (predicate(Element$$1.fromDom(node.childNodes[i]))) - return Option.some(Element$$1.fromDom(node.childNodes[i])); - var res = descend(node.childNodes[i]); - if (res.isSome()) - return res; - } - return Option.none(); - }; - return descend(scope.dom()); - }; - var $_df9cwz1bgjjgwekcd = { - first: first$1, - ancestor: ancestor, - closest: closest, - sibling: sibling, - child: child$1, - descendant: descendant - }; - - var first$2 = function (selector) { - return $_e63uk51bajjgwekbq.one(selector); - }; - var ancestor$1 = function (scope, selector, isRoot) { - return $_df9cwz1bgjjgwekcd.ancestor(scope, function (e) { - return $_e63uk51bajjgwekbq.is(e, selector); - }, isRoot); - }; - var sibling$1 = function (scope, selector) { - return $_df9cwz1bgjjgwekcd.sibling(scope, function (e) { - return $_e63uk51bajjgwekbq.is(e, selector); - }); - }; - var child$2 = function (scope, selector) { - return $_df9cwz1bgjjgwekcd.child(scope, function (e) { - return $_e63uk51bajjgwekbq.is(e, selector); - }); - }; - var descendant$1 = function (scope, selector) { - return $_e63uk51bajjgwekbq.one(selector, scope); - }; - var closest$1 = function (scope, selector, isRoot) { - return ClosestOrAncestor($_e63uk51bajjgwekbq.is, ancestor$1, scope, selector, isRoot); - }; - var $_6nlstg1bfjjgwekcb = { - first: first$2, - ancestor: ancestor$1, - sibling: sibling$1, - child: child$2, - descendant: descendant$1, - closest: closest$1 - }; - - 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)); + 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 }); - }); - }, - 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 $_7uh4c31bijjgwekcw = { 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 $_2g5ce1bkjjgwekcz = { 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 $_b15nsk1bljjgwekd9 = { 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 $_9qaa1r1bmjjgwekdc = { 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 $_a3xw9u1bnjjgwekdh = { 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, menuItems) { - return !isSeparator(menuItem) || !isSeparator(menuItems[i - 1]); - }); - return filter(menuItems2, function (menuItem, i, menuItems) { - return !isSeparator(menuItem) || i > 0 && i < menuItems.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 $_dvqvtt1bojjgwekdj = { 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 $_2ywvy11bpjjgwekdn = { 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 $_5qfrkx1bqjjgwekdq = { 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 $_ebb6rc1brjjgwekdr = { 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 = $_6nlstg1bfjjgwekcb.descendant(Element$$1.fromDom(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', function () { - FloatPanel.hideAll(); - }); - }; - var setup = function (editor) { - setupRtlMode(editor); - setupHideFloatPanels(editor); - setupUiContainer(editor); - setupEnvironment(); - $_a3xw9u1bnjjgwekdh.register(editor); - $_7uh4c31bijjgwekcw.register(editor); - $_2ywvy11bpjjgwekdn.register(editor); - $_5qfrkx1bqjjgwekdq.register(editor); - $_b15nsk1bljjgwekd9.register(editor); - $_2g5ce1bkjjgwekcz.register(editor); - $_9qaa1r1bmjjgwekdc.register(editor); - $_ebb6rc1brjjgwekdr.register(editor); - $_dvqvtt1bojjgwekdj.register(editor); - }; - var $_gg6ikw1bejjgwekc5 = { 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(); - } + }, + renderHtml: function (container) { + return '
' + this._super(container); } - 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 ''; - } - 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$$1) { - while (node) { - if (parent$$1 === node) { - return true; - } - node = node.parentNode; - } - return false; - } - var MenuButton = Button.extend({ - init: function (settings) { - var self$$1 = this; - self$$1._renderOpen = true; - self$$1._super(settings); - settings = self$$1.settings; - self$$1.classes.add('menubtn'); - if (settings.fixedWidth) { - self$$1.classes.add('fixed-width'); - } - self$$1.aria('haspopup', true); - self$$1.state.set('menu', settings.menu || self$$1.render()); - }, - showMenu: function (toggle) { - var self$$1 = this; - var menu; - if (self$$1.menu && self$$1.menu.visible() && toggle !== false) { - return self$$1.hideMenu(); - } - if (!self$$1.menu) { - menu = self$$1.state.get('menu') || []; - self$$1.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$$1.menu = global$11.create(menu).parent(self$$1).renderTo(); - } else { - self$$1.menu = menu.parent(self$$1).show().renderTo(); - } - self$$1.fire('createmenu'); - self$$1.menu.reflow(); - self$$1.menu.on('cancel', function (e) { - if (e.control.parent() === self$$1.menu) { - e.stopPropagation(); - self$$1.focus(); - self$$1.hideMenu(); - } - }); - self$$1.menu.on('select', function () { - self$$1.focus(); - }); - self$$1.menu.on('show hide', function (e) { - if (e.control === self$$1.menu) { - self$$1.activeMenu(e.type === 'show'); - self$$1.classes.toggle('opened', e.type === 'show'); - } - self$$1.aria('expanded', e.type === 'show'); - }).fire('show'); - } - self$$1.menu.show(); - self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); - self$$1.menu.repaint(); - self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ - 'br-tr', - 'tr-br' - ] : [ - 'bl-tl', - 'tl-bl' - ]); - self$$1.fire('showmenu'); - }, - hideMenu: function () { - var self$$1 = this; - if (self$$1.menu) { - self$$1.menu.items().each(function (item) { - if (item.hideMenu) { - item.hideMenu(); - } - }); - self$$1.menu.hide(); - } - }, - activeMenu: function (state) { - this.classes.toggle('active', state); - }, - renderHtml: function () { - var self$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; - var icon = self$$1.settings.icon, image; - var text = self$$1.state.get('text'); - var textHtml = ''; - image = self$$1.settings.image; - if (image) { - icon = 'none'; - if (typeof image !== 'string') { - image = window.getSelection ? image[0] : image[1]; - } - image = ' style="background-image: url(\'' + image + '\')"'; - } else { - image = ''; - } - if (text) { - self$$1.classes.add('btn-has-text'); - textHtml = '' + self$$1.encode(text) + ''; - } - icon = self$$1.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; - self$$1.aria('role', self$$1.parent() instanceof MenuBar ? 'menuitem' : 'button'); - return '
' + '' + '
'; - }, - postRender: function () { - var self$$1 = this; - self$$1.on('click', function (e) { - if (e.control === self$$1 && isChildOf$1(e.target, self$$1.getEl())) { - self$$1.focus(); - self$$1.showMenu(!e.aria); - if (e.aria) { - self$$1.menu.items().filter(':visible')[0].focus(); - } - } - }); - self$$1.on('mouseenter', function (e) { - var overCtrl = e.control; - var parent$$1 = self$$1.parent(); - var hasVisibleSiblingMenu; - if (overCtrl && parent$$1 && overCtrl instanceof MenuButton && overCtrl.parent() === parent$$1) { - parent$$1.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$$1._super(); - }, - bindStates: function () { - var self$$1 = this; - self$$1.state.on('change:menu', function () { - if (self$$1.menu) { - self$$1.menu.remove(); - } - self$$1.menu = null; - }); - return self$$1._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; - } - if (this.settings.values) { - var matchingValues = global$4.grep(this.settings.values, function (a) { - return a.value === value; - }); - if (matchingValues.length > 0) { - 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$11.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 ? '
' + 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 += ''; - } - } - 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) { + var Button = Widget.extend({ + Defaults: { + classes: 'widget btn', + role: 'button' + }, + init: function (settings) { + var self$$1 = this; + var size; + self$$1._super(settings); + settings = self$$1.settings; + size = self$$1.settings.size; + self$$1.on('click mousedown', function (e) { e.preventDefault(); - self.parents().reverse().each(function (ctrl) { - if (ctrl.toJSON) { - rootControl = ctrl; - return false; + }); + self$$1.on('touchstart', function (e) { + self$$1.fire('click', e); + e.preventDefault(); + }); + if (settings.subtype) { + self$$1.classes.add(settings.subtype); + } + if (size) { + self$$1.classes.add('btn-' + size); + } + if (settings.icon) { + self$$1.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$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; + var icon = self$$1.state.get('icon'), image; + var text = self$$1.state.get('text'); + var textHtml = ''; + var ariaPressed; + var settings = self$$1.settings; + image = settings.image; + if (image) { + icon = 'none'; + if (typeof image !== 'string') { + image = window.getSelection ? image[0] : image[1]; + } + image = ' style="background-image: url(\'' + image + '\')"'; + } else { + image = ''; + } + if (text) { + self$$1.classes.add('btn-has-text'); + textHtml = '' + self$$1.encode(text) + ''; + } + icon = icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; + ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; + return '
' + '' + '
'; + }, + bindStates: function () { + var self$$1 = this, $ = self$$1.$, textCls = self$$1.classPrefix + 'txt'; + function setButtonText(text) { + var $span = $('span.' + textCls, self$$1.getEl()); + if (text) { + if (!$span[0]) { + $('button:first', self$$1.getEl()).append(''); + $span = $('span.' + textCls, self$$1.getEl()); } - }); - self.fire('submit', { data: rootControl.toJSON() }); + $span.html(self$$1.encode(text)); + } else { + $span.remove(); + } + self$$1.classes.toggle('btn-has-text', !!text); } - }); - }, - options: function (state) { - if (!arguments.length) { - return this.state.get('options'); + self$$1.state.on('change:text', function (e) { + setButtonText(e.value); + }); + self$$1.state.on('change:icon', function (e) { + var icon = e.value; + var prefix = self$$1.classPrefix; + self$$1.settings.icon = icon; + icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; + var btnElm = self$$1.getEl().firstChild; + var iconElm = btnElm.getElementsByTagName('i')[0]; + if (icon) { + if (!iconElm || iconElm !== btnElm.firstChild) { + iconElm = document.createElement('i'); + btnElm.insertBefore(iconElm, btnElm.firstChild); + } + iconElm.className = icon; + } else if (iconElm) { + btnElm.removeChild(iconElm); + } + setButtonText(self$$1.state.get('text')); + }); + return self$$1._super(); } - 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 ''; - }, - 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 }); + 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'); } - self.on('keydown', function (e) { - switch (e.keyCode) { - case 37: - case 38: - alter(-1); - break; - case 39: - case 40: - alter(1); - break; + }, + 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', function (e) { + e.stopPropagation(); + input.click(); + }); + self.getEl().appendChild(input); + }, + remove: function () { + global$7(this.getEl('button')).off(); + global$7(this.getEl('input')).off(); + this._super(); } - 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 }); + }); + + 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$$1 = this; + self$$1._super(settings); + self$$1.on('click mousedown', function (e) { + e.preventDefault(); + }); + self$$1.on('click', function (e) { + e.preventDefault(); + if (!self$$1.disabled()) { + self$$1.checked(!self$$1.checked()); } }); - } - 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$$1 = this; - var elm = self$$1.getEl(); - var rect = self$$1.layoutRect(); - var mainButtonElm, menuButtonElm; - self$$1._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$$1; - }, - activeMenu: function (state) { - var self$$1 = this; - global$7(self$$1.getEl().lastChild).toggleClass(self$$1.classPrefix + 'active', state); - }, - renderHtml: function () { - var self$$1 = this; - var id = self$$1._id; - var prefix = self$$1.classPrefix; - var image; - var icon = self$$1.state.get('icon'); - var text = self$$1.state.get('text'); - var settings = self$$1.settings; - var textHtml = '', ariaPressed; - image = settings.image; - if (image) { - icon = 'none'; - if (typeof image !== 'string') { - image = window.getSelection ? image[0] : image[1]; + self$$1.checked(self$$1.settings.checked); + }, + checked: function (state) { + if (!arguments.length) { + return this.state.get('checked'); } - image = ' style="background-image: url(\'' + image + '\')"'; - } else { - image = ''; + this.state.set('checked', state); + return this; + }, + value: function (state) { + if (!arguments.length) { + return this.checked(); + } + return this.checked(state); + }, + renderHtml: function () { + var self$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; + return '
' + '' + '' + self$$1.encode(self$$1.state.get('text')) + '' + '
'; + }, + bindStates: function () { + var self$$1 = this; + function checked(state) { + self$$1.classes.toggle('checked', state); + self$$1.aria('checked', state); + } + self$$1.state.on('change:text', function (e) { + self$$1.getEl('al').firstChild.data = self$$1.translate(e.value); + }); + self$$1.state.on('change:checked change:value', function (e) { + self$$1.fire('change'); + checked(e.value); + }); + self$$1.state.on('change:icon', function (e) { + var icon = e.value; + var prefix = self$$1.classPrefix; + if (typeof icon === 'undefined') { + return self$$1.settings.icon; + } + self$$1.settings.icon = icon; + icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; + var btnElm = self$$1.getEl().firstChild; + var iconElm = btnElm.getElementsByTagName('i')[0]; + if (icon) { + if (!iconElm || iconElm !== btnElm.firstChild) { + iconElm = document.createElement('i'); + btnElm.insertBefore(iconElm, btnElm.firstChild); + } + iconElm.className = icon; + } else if (iconElm) { + btnElm.removeChild(iconElm); + } + }); + if (self$$1.state.get('checked')) { + checked(true); + } + return self$$1._super(); } - icon = settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; - if (text) { - self$$1.classes.add('btn-has-text'); - textHtml = '' + self$$1.encode(text) + ''; - } - ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; - return '
' + '' + '' + '
'; - }, - postRender: function () { - var self$$1 = this, onClickHandler = self$$1.settings.onclick; - self$$1.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); + }); + + var global$f = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var ComboBox = Widget.extend({ + init: function (settings) { + var self$$1 = this; + self$$1._super(settings); + settings = self$$1.settings; + self$$1.classes.add('combobox'); + self$$1.subinput = true; + self$$1.ariaTarget = 'inp'; + settings.menu = settings.menu || settings.values; + if (settings.menu) { + settings.icon = 'caret'; + } + self$$1.on('click', function (e) { + var elm = e.target; + var root = self$$1.getEl(); + if (!global$7.contains(root, elm) && elm !== root) { + return; + } + while (elm && elm !== root) { + if (elm.id && elm.id.indexOf('-open') !== -1) { + self$$1.fire('action'); + if (settings.menu) { + self$$1.showMenu(); + if (e.aria) { + self$$1.menu.items()[0].focus(); + } } - return; } - node = node.parentNode; + elm = elm.parentNode; } - } - }); - delete self$$1.settings.onclick; - return self$$1._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 += ''; - }); - 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$$1 = this; - self$$1._super(settings); - self$$1.classes.add('textbox'); - if (settings.multiline) { - self$$1.classes.add('multiline'); - } else { self$$1.on('keydown', function (e) { var rootControl; - if (e.keyCode === 13) { + if (e.keyCode === 13 && e.target.nodeName === 'INPUT') { e.preventDefault(); self$$1.parents().reverse().each(function (ctrl) { if (ctrl.toJSON) { @@ -10024,212 +5324,4498 @@ var inlite = (function () { } }); self$$1.on('keyup', function (e) { - self$$1.state.set('value', e.target.value); + if (e.target.nodeName === 'INPUT') { + var oldValue = self$$1.state.get('value'); + var newValue = e.target.value; + if (newValue !== oldValue) { + self$$1.state.set('value', newValue); + self$$1.fire('autocomplete', e); + } + } }); + self$$1.on('mouseover', function (e) { + var tooltip = self$$1.tooltip().moveTo(-65535); + if (self$$1.statusLevel() && e.target.className.indexOf(self$$1.classPrefix + 'status') !== -1) { + var statusMessage = self$$1.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$$1 = this; + var settings = self$$1.settings; + var menu; + if (!self$$1.menu) { + menu = settings.menu || []; + if (menu.length) { + menu = { + type: 'menu', + items: menu + }; + } else { + menu.type = menu.type || 'menu'; + } + self$$1.menu = global$b.create(menu).parent(self$$1).renderTo(self$$1.getContainerElm()); + self$$1.fire('createmenu'); + self$$1.menu.reflow(); + self$$1.menu.on('cancel', function (e) { + if (e.control === self$$1.menu) { + self$$1.focus(); + } + }); + self$$1.menu.on('show hide', function (e) { + e.control.items().each(function (ctrl) { + ctrl.active(ctrl.value() === self$$1.value()); + }); + }).fire('show'); + self$$1.menu.on('select', function (e) { + self$$1.value(e.control.value()); + }); + self$$1.on('focusin', function (e) { + if (e.target.tagName.toUpperCase() === 'INPUT') { + self$$1.menu.hide(); + } + }); + self$$1.aria('expanded', true); + } + self$$1.menu.show(); + self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); + self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ + 'br-tr', + 'tr-br' + ] : [ + 'bl-tl', + 'tl-bl' + ]); + }, + focus: function () { + this.getEl('inp').focus(); + }, + repaint: function () { + var self$$1 = this, elm = self$$1.getEl(), openElm = self$$1.getEl('open'), rect = self$$1.layoutRect(); + var width, lineHeight, innerPadding = 0; + var inputElm = elm.firstChild; + if (self$$1.statusLevel() && self$$1.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 = document; + if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) { + lineHeight = self$$1.layoutRect().h - 2 + 'px'; + } + global$7(inputElm).css({ + width: width - innerPadding, + lineHeight: lineHeight + }); + self$$1._super(); + return self$$1; + }, + postRender: function () { + var self$$1 = this; + global$7(this.getEl('inp')).on('change', function (e) { + self$$1.state.set('value', e.target.value); + self$$1.fire('change', e); + }); + return self$$1._super(); + }, + renderHtml: function () { + var self$$1 = this, id = self$$1._id, settings = self$$1.settings, prefix = self$$1.classPrefix; + var value = self$$1.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$$1.disabled()) { + extraAttrs += ' disabled="disabled"'; + } + icon = settings.icon; + if (icon && icon !== 'caret') { + icon = prefix + 'ico ' + prefix + 'i-' + settings.icon; + } + text = self$$1.state.get('text'); + if (icon || text) { + openBtnHtml = '
' + '' + '
'; + self$$1.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$$1 = this; + if (items.length === 0) { + self$$1.hideMenu(); + return; + } + var insert = function (value, title) { + return function () { + self$$1.fire('selectitem', { + title: title, + value: value + }); + }; + }; + if (self$$1.menu) { + self$$1.menu.items().remove(); + } else { + self$$1.menu = global$b.create({ + type: 'menu', + classes: 'combobox-menu', + layout: 'flow' + }).parent(self$$1).renderTo(); + } + global$4.each(items, function (item) { + self$$1.menu.add({ + text: item.title, + url: item.previewUrl, + match: term, + classes: 'menu-item-ellipsis', + onclick: insert(item.value, item.title) + }); + }); + self$$1.menu.renderNew(); + self$$1.hideMenu(); + self$$1.menu.on('cancel', function (e) { + if (e.control.parent() === self$$1.menu) { + e.stopPropagation(); + self$$1.focus(); + self$$1.hideMenu(); + } + }); + self$$1.menu.on('select', function () { + self$$1.focus(); + }); + var maxW = self$$1.layoutRect().w; + self$$1.menu.layoutRect({ + w: maxW, + minW: 0, + maxW: maxW + }); + self$$1.menu.repaint(); + self$$1.menu.reflow(); + self$$1.menu.show(); + self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ + 'br-tr', + 'tr-br' + ] : [ + 'bl-tl', + 'tl-bl' + ]); + }, + hideMenu: function () { + if (this.menu) { + this.menu.hide(); + } + }, + bindStates: function () { + var self$$1 = this; + self$$1.state.on('change:value', function (e) { + if (self$$1.getEl('inp').value !== e.value) { + self$$1.getEl('inp').value = e.value; + } + }); + self$$1.state.on('change:disabled', function (e) { + self$$1.getEl('inp').disabled = e.value; + }); + self$$1.state.on('change:statusLevel', function (e) { + var statusIconElm = self$$1.getEl('status'); + var prefix = self$$1.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$$1.classes.toggle('has-status', value !== 'none'); + self$$1.repaint(); + }); + funcs.on(self$$1.getEl('status'), 'mouseleave', function () { + self$$1.tooltip().hide(); + }); + self$$1.on('cancel', function (e) { + if (self$$1.menu && self$$1.menu.visible()) { + e.stopPropagation(); + self$$1.hideMenu(); + } + }); + var focusIdx = function (idx, menu) { + if (menu && menu.items().length > 0) { + menu.items().eq(idx)[0].focus(); + } + }; + self$$1.on('keydown', function (e) { + var keyCode = e.keyCode; + if (e.target.nodeName === 'INPUT') { + if (keyCode === global$f.DOWN) { + e.preventDefault(); + self$$1.fire('autocomplete'); + focusIdx(0, self$$1.menu); + } else if (keyCode === global$f.UP) { + e.preventDefault(); + focusIdx(-1, self$$1.menu); + } + } + }); + return self$$1._super(); + }, + remove: function () { + global$7(this.getEl('inp')).off(); + if (this.menu) { + this.menu.remove(); + } + this._super(); } - }, - repaint: function () { - var self$$1 = this; - var style, rect, borderBox, borderW, borderH = 0, lastRepaintRect; - style = self$$1.getEl().style; - rect = self$$1._layoutRect; - lastRepaintRect = self$$1._lastRepaintRect || {}; - var doc = document; - if (!self$$1.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) { - style.lineHeight = rect.h - borderH + 'px'; + }); + + 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(); } - borderBox = self$$1.borderBox; - borderW = borderBox.left + borderBox.right + 8; - borderH = borderBox.top + borderBox.bottom + (self$$1.settings.multiline ? 8 : 0); - if (rect.x !== lastRepaintRect.x) { - style.left = rect.x + 'px'; - lastRepaintRect.x = rect.x; + }); + + 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(); } - 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$$1._lastRepaintRect = lastRepaintRect; - self$$1.fire('repaint', {}, false); - return self$$1; - }, - renderHtml: function () { - var self$$1 = this; - var settings = self$$1.settings; - var attrs, elm; - attrs = { - id: self$$1._id, - hidefocus: '1' - }; - global$4.each([ - 'rows', - 'spellcheck', - 'maxLength', - 'size', - 'readonly', - 'min', - 'max', - 'step', - 'list', - 'pattern', - 'placeholder', - 'required', - 'multiple' - ], function (name$$1) { - attrs[name$$1] = settings[name$$1]; - }); - if (self$$1.disabled()) { - attrs.disabled = 'disabled'; - } - if (settings.subtype) { - attrs.type = settings.subtype; - } - elm = funcs.create(settings.multiline ? 'textarea' : 'input', attrs); - elm.value = self$$1.state.get('value'); - elm.className = self$$1.classes.toString(); - return elm.outerHTML; - }, - value: function (value) { - if (arguments.length) { - this.state.set('value', value); + }); + + 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 '
' + '' + '' + '
'; + }, + 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(); } - if (this.state.get('rendered')) { - this.state.set('value', this.getEl().value); + }); + + 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 '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + hueHtml + '
'; } - return this.state.get('value'); - }, - postRender: function () { - var self$$1 = this; - self$$1.getEl().value = self$$1.state.get('value'); - self$$1._super(); - self$$1.$el.on('change', function (e) { - self$$1.state.set('value', e.target.value); - self$$1.fire('change', e); + }); + + 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 ? '' : '') + '
' + 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 || document; + var div = doc.createElement('div'); + div.innerHTML = html; + if (!div.hasChildNodes() || div.childNodes.length > 1) { + console.error('HTML does not have a single root node', html); + throw 'HTML must have a single root node'; + } + return fromDom(div.childNodes[0]); + }; + var fromTag = function (tag, scope) { + var doc = scope || document; + var node = doc.createElement(tag); + return fromDom(node); + }; + var fromText = function (text, scope) { + var doc = scope || 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$$1 = { + 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 = Node.ATTRIBUTE_NODE; + var CDATA_SECTION = Node.CDATA_SECTION_NODE; + var COMMENT = Node.COMMENT_NODE; + var DOCUMENT = Node.DOCUMENT_NODE; + var DOCUMENT_TYPE = Node.DOCUMENT_TYPE_NODE; + var DOCUMENT_FRAGMENT = Node.DOCUMENT_FRAGMENT_NODE; + var ELEMENT = Node.ELEMENT_NODE; + var TEXT = Node.TEXT_NODE; + var PROCESSING_INSTRUCTION = Node.PROCESSING_INSTRUCTION_NODE; + var ENTITY_REFERENCE = Node.ENTITY_REFERENCE_NODE; + var ENTITY = Node.ENTITY_NODE; + var NOTATION = 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$1 = { + 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$2 = 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$2(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() }); - }, - bindStates: function () { - var self$$1 = this; - self$$1.state.on('change:value', function (e) { - if (self$$1.getEl().value !== e.value) { - self$$1.getEl().value = e.value; + }; + 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$1 = function (str, substr) { + return str.indexOf(substr) !== -1; + }; + + var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; + var checkContains = function (target) { + return function (uastring) { + return contains$1(uastring, target); + }; + }; + var browsers = [ + { + name: 'Edge', + versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], + search: function (uastring) { + var monstrosity = contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit'); + return monstrosity; + } + }, + { + name: 'Chrome', + versionRegexes: [ + /.*?chrome\/([0-9]+)\.([0-9]+).*/, + normalVersionRegex + ], + search: function (uastring) { + return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe'); + } + }, + { + name: 'IE', + versionRegexes: [ + /.*?msie\ ?([0-9]+)\.([0-9]+).*/, + /.*?rv:([0-9]+)\.([0-9]+).*/ + ], + search: function (uastring) { + return contains$1(uastring, 'msie') || contains$1(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$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit'); + } + } + ]; + var oses = [ + { + name: 'Windows', + search: checkContains('win'), + versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] + }, + { + name: 'iOS', + search: function (uastring) { + return contains$1(uastring, 'iphone') || contains$1(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 = 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 ? document : scope.dom(); + return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element$$1.fromDom); + }; + var one = function (selector, scope) { + var base = scope === undefined ? document : scope.dom(); + return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element$$1.fromDom); + }; + + var regularContains = function (e1, e2) { + var d1 = e1.dom(), d2 = e2.dom(); + return d1 === d2 ? false : d1.contains(d2); + }; + var ieContains = function (e1, e2) { + return Node$1.documentPositionContainedBy(e1.dom(), e2.dom()); + }; + var browser = PlatformDetection$1.detect().browser; + var contains$2 = browser.isIE() ? ieContains : regularContains; + + var spot = Immutable('element', 'offset'); + + var descendants$1 = function (scope, selector) { + return all(selector, scope); + }; + + var trim$1 = 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$1(Element$$1.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$1(target.title).length > 0; + }; + var find$3 = function (elm) { + var elms = getTargetElements(elm); + return filter(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle); + }; + var LinkTargets = { find: find$3 }; + + 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(''); } }); - self$$1.state.on('change:disabled', function (e) { - self$$1.getEl().disabled = e.value; + ctrl.on('PostRender', function () { + ctrl.getRoot().on('submit', function (e) { + if (!e.isDefaultPrevented()) { + addToHistory(ctrl.value(), fileType); + } + }); }); - return self$$1._super(); - }, - remove: function () { - this.$el.off(); - this._super(); - } - }); - - var getApi = function () { - return { - Selector: Selector, - Collection: Collection$2, - ReflowQueue: $_cqjgb518wjjgwek2f, - Control: Control$1, - Factory: global$11, - KeyboardNavigation: KeyboardNavigation, - Container: Container, - DragHelper: DragHelper, - Scrollable: $_8woeth19ajjgwek4b, - Panel: Panel, - Movable: $_8zu82i18yjjgwek2l, - Resizable: $_20hy1119bjjgwek4f, - FloatPanel: FloatPanel, - Window: Window$$1, - 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: $_gg6ikw1bejjgwekc5, - 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$11.add(key, ref); + 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 Api = { - appendTo: appendTo, - registerToFactory: registerToFactory - }; - Api.registerToFactory(); - Api.appendTo(window.tinymce ? window.tinymce : {}); - global.add('inlite', function (editor) { - var panel = create$3(); - $_gg6ikw1bejjgwekc5.setup(editor); - $_epdxt419djjgwek4l.addToEditor(editor, panel); - return $_7y4x3k17sjjgwejyw.get(editor, panel); - }); - function Theme () { - } + 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(); + } + }); + } + }); - return Theme; + 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$1 = 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, menuItems) { + return !isSeparator(menuItem) || !isSeparator(menuItems[i - 1]); + }); + return filter(menuItems2, function (menuItem, i, menuItems) { + return !isSeparator(menuItem) || i > 0 && i < menuItems.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$1(Element$$1.fromDom(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 ''; + } + 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$$1) { + while (node) { + if (parent$$1 === node) { + return true; + } + node = node.parentNode; + } + return false; + } + var MenuButton = Button.extend({ + init: function (settings) { + var self$$1 = this; + self$$1._renderOpen = true; + self$$1._super(settings); + settings = self$$1.settings; + self$$1.classes.add('menubtn'); + if (settings.fixedWidth) { + self$$1.classes.add('fixed-width'); + } + self$$1.aria('haspopup', true); + self$$1.state.set('menu', settings.menu || self$$1.render()); + }, + showMenu: function (toggle) { + var self$$1 = this; + var menu; + if (self$$1.menu && self$$1.menu.visible() && toggle !== false) { + return self$$1.hideMenu(); + } + if (!self$$1.menu) { + menu = self$$1.state.get('menu') || []; + self$$1.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$$1.menu = global$b.create(menu).parent(self$$1).renderTo(); + } else { + self$$1.menu = menu.parent(self$$1).show().renderTo(); + } + self$$1.fire('createmenu'); + self$$1.menu.reflow(); + self$$1.menu.on('cancel', function (e) { + if (e.control.parent() === self$$1.menu) { + e.stopPropagation(); + self$$1.focus(); + self$$1.hideMenu(); + } + }); + self$$1.menu.on('select', function () { + self$$1.focus(); + }); + self$$1.menu.on('show hide', function (e) { + if (e.type === 'hide' && e.control.parent() === self$$1) { + self$$1.classes.remove('opened-under'); + } + if (e.control === self$$1.menu) { + self$$1.activeMenu(e.type === 'show'); + self$$1.classes.toggle('opened', e.type === 'show'); + } + self$$1.aria('expanded', e.type === 'show'); + }).fire('show'); + } + self$$1.menu.show(); + self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); + self$$1.menu.repaint(); + self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ + 'br-tr', + 'tr-br' + ] : [ + 'bl-tl', + 'tl-bl' + ]); + var menuLayoutRect = self$$1.menu.layoutRect(); + var selfBottom = self$$1.$el.offset().top + self$$1.layoutRect().h; + if (selfBottom > menuLayoutRect.y && selfBottom < menuLayoutRect.y + menuLayoutRect.h) { + self$$1.classes.add('opened-under'); + } + self$$1.fire('showmenu'); + }, + hideMenu: function () { + var self$$1 = this; + if (self$$1.menu) { + self$$1.menu.items().each(function (item) { + if (item.hideMenu) { + item.hideMenu(); + } + }); + self$$1.menu.hide(); + } + }, + activeMenu: function (state) { + this.classes.toggle('active', state); + }, + renderHtml: function () { + var self$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; + var icon = self$$1.settings.icon, image; + var text = self$$1.state.get('text'); + var textHtml = ''; + image = self$$1.settings.image; + if (image) { + icon = 'none'; + if (typeof image !== 'string') { + image = window.getSelection ? image[0] : image[1]; + } + image = ' style="background-image: url(\'' + image + '\')"'; + } else { + image = ''; + } + if (text) { + self$$1.classes.add('btn-has-text'); + textHtml = '' + self$$1.encode(text) + ''; + } + icon = self$$1.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; + self$$1.aria('role', self$$1.parent() instanceof MenuBar ? 'menuitem' : 'button'); + return '
' + '' + '
'; + }, + postRender: function () { + var self$$1 = this; + self$$1.on('click', function (e) { + if (e.control === self$$1 && isChildOf$1(e.target, self$$1.getEl())) { + self$$1.focus(); + self$$1.showMenu(!e.aria); + if (e.aria) { + self$$1.menu.items().filter(':visible')[0].focus(); + } + } + }); + self$$1.on('mouseenter', function (e) { + var overCtrl = e.control; + var parent$$1 = self$$1.parent(); + var hasVisibleSiblingMenu; + if (overCtrl && parent$$1 && overCtrl instanceof MenuButton && overCtrl.parent() === parent$$1) { + parent$$1.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$$1._super(); + }, + bindStates: function () { + var self$$1 = this; + self$$1.state.on('change:menu', function () { + if (self$$1.menu) { + self$$1.menu.remove(); + } + self$$1.menu = null; + }); + return self$$1._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 ? '
' + 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 += ''; + } + } + 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 ''; + }, + 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$$1 = this; + var elm = self$$1.getEl(); + var rect = self$$1.layoutRect(); + var mainButtonElm, menuButtonElm; + self$$1._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$$1; + }, + activeMenu: function (state) { + var self$$1 = this; + global$7(self$$1.getEl().lastChild).toggleClass(self$$1.classPrefix + 'active', state); + }, + renderHtml: function () { + var self$$1 = this; + var id = self$$1._id; + var prefix = self$$1.classPrefix; + var image; + var icon = self$$1.state.get('icon'); + var text = self$$1.state.get('text'); + var settings = self$$1.settings; + var textHtml = '', ariaPressed; + image = settings.image; + if (image) { + icon = 'none'; + if (typeof image !== 'string') { + image = 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$$1.classes.add('btn-has-text'); + textHtml = '' + self$$1.encode(text) + ''; + } + ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; + return '
' + '' + '' + '
'; + }, + postRender: function () { + var self$$1 = this, onClickHandler = self$$1.settings.onclick; + self$$1.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$$1.settings.onclick; + return self$$1._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 += ''; + }); + 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$$1 = this; + self$$1._super(settings); + self$$1.classes.add('textbox'); + if (settings.multiline) { + self$$1.classes.add('multiline'); + } else { + self$$1.on('keydown', function (e) { + var rootControl; + if (e.keyCode === 13) { + e.preventDefault(); + self$$1.parents().reverse().each(function (ctrl) { + if (ctrl.toJSON) { + rootControl = ctrl; + return false; + } + }); + self$$1.fire('submit', { data: rootControl.toJSON() }); + } + }); + self$$1.on('keyup', function (e) { + self$$1.state.set('value', e.target.value); + }); + } + }, + repaint: function () { + var self$$1 = this; + var style, rect, borderBox, borderW, borderH = 0, lastRepaintRect; + style = self$$1.getEl().style; + rect = self$$1._layoutRect; + lastRepaintRect = self$$1._lastRepaintRect || {}; + var doc = document; + if (!self$$1.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) { + style.lineHeight = rect.h - borderH + 'px'; + } + borderBox = self$$1.borderBox; + borderW = borderBox.left + borderBox.right + 8; + borderH = borderBox.top + borderBox.bottom + (self$$1.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$$1._lastRepaintRect = lastRepaintRect; + self$$1.fire('repaint', {}, false); + return self$$1; + }, + renderHtml: function () { + var self$$1 = this; + var settings = self$$1.settings; + var attrs, elm; + attrs = { + id: self$$1._id, + hidefocus: '1' + }; + global$4.each([ + 'rows', + 'spellcheck', + 'maxLength', + 'size', + 'readonly', + 'min', + 'max', + 'step', + 'list', + 'pattern', + 'placeholder', + 'required', + 'multiple' + ], function (name$$1) { + attrs[name$$1] = settings[name$$1]; + }); + if (self$$1.disabled()) { + attrs.disabled = 'disabled'; + } + if (settings.subtype) { + attrs.type = settings.subtype; + } + elm = funcs.create(settings.multiline ? 'textarea' : 'input', attrs); + elm.value = self$$1.state.get('value'); + elm.className = self$$1.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$$1 = this; + self$$1.getEl().value = self$$1.state.get('value'); + self$$1._super(); + self$$1.$el.on('change', function (e) { + self$$1.state.set('value', e.target.value); + self$$1.fire('change', e); + }); + }, + bindStates: function () { + var self$$1 = this; + self$$1.state.on('change:value', function (e) { + if (self$$1.getEl().value !== e.value) { + self$$1.getEl().value = e.value; + } + }); + self$$1.state.on('change:disabled', function (e) { + self$$1.getEl().disabled = e.value; + }); + return self$$1._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$$1, + 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; }()); })(); diff --git a/wp-includes/js/tinymce/themes/inlite/theme.min.js b/wp-includes/js/tinymce/themes/inlite/theme.min.js index e79bdd02cf..4c56c7a1b3 100644 --- a/wp-includes/js/tinymce/themes/inlite/theme.min.js +++ b/wp-includes/js/tinymce/themes/inlite/theme.min.js @@ -1 +1 @@ -!function(){"use strict";var u,t,e,n,i,r,o=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"),s=function(t){return t.reduce(function(t,e){return Array.isArray(e)?t.concat(s(e)):t.concat(e)},[])},a={flatten:s},l=function(t,e){for(var n=0;n+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,Vt=/^\s*|\s*$/g,qt=Ot.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=Ft.exec(t.replace(Vt,"")))[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(Ut.exec(""),(i=Ut.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=Zt.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,St.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 le(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 le(this).off(t,e),this},fire:function(t,e,n){if((e=e||{}).control||(e.control=this),e=le(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 le(this).has(t)},parents:function(t){var e,n=new Xt;for(e=this.parent();e;e=e.parent())n.add(e);return t&&(n=n.filter(t)),n},parentsAndSelf:function(t){return new Xt(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]=Nt("#"+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 Zt.translate?Zt.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&&Nt(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 Nt(t).before(this.renderHtml()),this.postRender(),this},renderTo:function(t){return Nt(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=Nt(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}ue(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"),ee.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(){ee.remove(this);var t=this.parent();return t&&t._layout&&!t._layout.isNative()&&t.reflow(),this}};function le(n){return n._eventDispatcher||(n._eventDispatcher=new Dt({scope:n,toggleEvent:function(t,e){e&&Dt.isNative(t)&&(n._nativeEvents||(n._nativeEvents={}),n._nativeEvents[t]=!0,n.state.get("rendered")&&ue(n))}})),n._eventDispatcher}function ue(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}}),be=ce.extend({init:function(i){var r=this;r._super(i),i=r.settings,r.canFocus=!0,i.tooltip&&!1!==be.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 ve({type:"tooltip"}),ie.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)}}),ye=be.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'
0%
'},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()}}),xe=function(t,e){t.getEl().lastChild.textContent=e+(t.progressBar?" "+t.progressBar.value()+"%":"")},we=ce.extend({Mixins:[pe],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=''),e.progressBar&&(o=e.progressBar.renderHtml()),''},postRender:function(){var t=this;return c.setTimeout(function(){t.$el.addClass(t.classPrefix+"in"),xe(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,xe(e,t.value)}),e.progressBar&&(e.progressBar.bindStates(),e.progressBar.state.on("change:value",function(t){xe(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 _e(o){var s=function(t){return t.inline?t.getElement():t.getContentAreaContainer()};return{open:function(t,e){var n,i=C.extend(t,{maxWidth:(n=s(o),St.getSize(n).width)}),r=new we(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),Nt(x).on("mousemove touchmove",v).on("mouseup touchend",p),h.start(t)},v=function(t){if(Ce(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){Ce(t),Nt(x).off("mousemove touchmove",v).off("mouseup touchend",p),m.remove(),h.stop&&h.stop(t)},this.destroy=function(){Nt(w).off()},Nt(w).on("mousedown touchstart",e)}var Ee=tinymce.util.Tools.resolve("tinymce.ui.Factory"),ke=function(t){return!!t.getAttribute("data-mce-tabstop")};function Te(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||ke(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=Te({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(ee.remove(this),this.visible()){for(ce.repaintControls=[],ce.repaintControls.map={},this.recalc(),t=ce.repaintControls.length;t--;)ce.repaintControls[t].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),ce.repaintControls=[]}return this}}),Pe={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(),Nt(p.getEl("absend")).css(f,p.layoutRect()[i]-1),!r)return void Nt(a).css("display","none");Nt(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,Nt(a).css(d),(d={})[f]=s["scroll"+e]*c,d[h]=u*c,Nt(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;Nt(p.getEl()).append('
'),p.draghelper=new Re(t+"t",{start:function(){d=p.getEl("body")["scroll"+a],Nt("#"+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(){Nt("#"+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()}),Nt(p.getEl("body")).on("scroll",n)),n())}},We=De.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[Pe],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+"
"}}),Ae={resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(t,e){if(t<=1||e<=1){var n=St.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)}},Be=[],Le=[];function Ie(t,e){for(;t;){if(t===e)return!0;t=t.parent()}}function ze(){He||(He=function(t){2!==t.button&&function(t){for(var e=Be.length;e--;){var n=Be[e],i=n.getParentCtrl(t.target);if(n.settings.autohide){if(i&&(Ie(i,n)||n.parent()===i))continue;(t=n.fire("autohide",{target:t.target})).isDefaultPrevented()||n.hide()}}}(t)},Nt(document).on("click touchstart",He))}function Fe(r){var t=St.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"),Nt(i.getEl()).addClass(n+"in")}),Ne=!0),Ue(!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=St.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=Be.length;t--&&Be[t]!==this;);return-1===t&&Be.push(this),e},hide:function(){return qe(this),Ue(!1,this),this._super()},hideAll:function(){Ve.hideAll()},close:function(){return this.fire("close").isDefaultPrevented()||(this.remove(),Ue(!1,this)),this},remove:function(){qe(this),this._super()},postRender:function(){return this.settings.bodyRole&&this.getEl("body").setAttribute("role",this.settings.bodyRole),this._super()}});function qe(t){var e;for(e=Be.length;e--;)Be[e]===t&&Be.splice(e,1);for(e=Le.length;e--;)Le[e]===t&&Le.splice(e,1)}Ve.hideAll=function(){for(var t=Be.length;t--;){var e=Be[t];e&&e.settings.autohide&&(e.hide(),Be.splice(t,1))}};var Ye=[],$e="";function Xe(t){var e,n=Nt("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!==$e&&($e=e),n.setAttribute("content",t?"width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0":$e))}function je(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=St.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=St.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='
'+t.encode(r.title)+'
'),r.url&&(a=''),void 0===a&&(a=e.renderHtml(t)),t.statusbar&&(s=t.statusbar.renderHtml()),'
'+o+'
'+a+"
"+s+"
"},fullscreen:function(t){var n,e,i=this,r=document.documentElement,o=i.classPrefix;if(t!==i._fullscreen)if(Nt(window).on("resize",function(){var t;if(i._fullscreen)if(n)i._timer||(i._timer=c.setTimeout(function(){var t=St.getWindowSize();i.moveTo(0,0).resizeTo(t.w,t.h),i._timer=0},50));else{t=(new Date).getTime();var e=St.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=Pt("0"),i.getEl("head").style.display="none",e.deltaH-=e.headerH+2,Nt([r,document.body]).addClass(o+"fullscreen"),i.classes.add("fullscreen");var s=St.getWindowSize();i.moveTo(0,0).resizeTo(s.w,s.h)}else i.borderBox=Pt(i.settings.border),i.getEl("head").style.display="",e.deltaH+=e.headerH,Nt([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 Re(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()}),Ye.push(n),Xe(!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(),je(e.classPrefix,!1),t=Ye.length;t--;)Ye[t]===e&&Ye.splice(t,1);Xe(0",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)}))},yn=function(t,e){t.execCommand("FormatBlock",!1,e)},xn=function(t,e,n){var i,r;r=(i=t.editorUpload.blobCache).create(an("mceu"),n,e),i.add(r),t.insertContent(t.dom.createHTML("img",{src:r.blobUri()}))},wn=function(t,e){0===e.trim().length?pn(t):vn(t,e)},_n=pn,Cn=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(){on().then(function(t){var e=t[0];rn(e).then(function(t){xn(n,t,e)})})}}),n.addButton("quicktable",{icon:"table",tooltip:"Insert table",onclick:function(){t.hide(),bn(n,2,2)}}),function(e){for(var t=function(t){return function(){yn(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 pt.some({x:n,y:i})}return pt.none()},En=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())},Tn=function(t,e){return!kn(e)&&En(e)?(n=t,i=e,new nn(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)})})):nn.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(),_n(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){Tn(r,t.data.linkurl).then(function(t){r.undoManager.transact(function(){t===o.href&&(o.attach(),o={}),wn(r,t)}),e()})}},(i=Ee.create(C.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},Mn=function(n,t,e){var o,i,s=[];if(e)return C.each(B(i=e)?i:D(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=Ee.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}),Ee.create({type:"toolbar",layout:"flow",name:t,items:s})},Sn=function(){var l,c,o=function(t){return 0'+this._super(t)}}),Dn=be.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+'"':"",'
"},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()}}),Pn=Dn.extend({init:function(t){t=C.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=St.create("input",{type:"file",id:n._id+"-browse",accept:n.settings.accept});n._super(),Nt(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)}),Nt(e).on("click",function(t){t.stopPropagation()}),Nt(n.getEl("button")).on("click",function(t){t.stopPropagation(),e.click()}),n.getEl().appendChild(e)},remove:function(){Nt(this.getEl("button")).off(),Nt(this.getEl("input")).off(),this._super()}}),Wn=De.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)+"
"}}),An=be.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()}}),Bn=tinymce.util.Tools.resolve("tinymce.util.VK"),Ln=be.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(Nt.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
"),'
'},postRender:function(){var e=this,n=e.settings.onclick;return e.on("click",function(t){t.aria&&"down"===t.aria.key||t.control!==e||Fn.getParent(t.target,"."+e.classPrefix+"open")||(t.stopImmediatePropagation(),n.call(e,t))}),delete e.settings.onclick,e._super()}}),Vn=tinymce.util.Tools.resolve("tinymce.util.Color"),qn=be.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=St.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;St.css(r,{top:100*n+"%"}),e||St.css(s,{left:t.s+"%",top:100-t.v+"%"}),o.style.background=Vn({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 Re(a._id+"-sv",{start:t,drag:t}),a._hdraghelper=new Re(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=Vn()),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}()+'
','
'+t+"
"}}),Yn=be.extend({init:function(t){t=C.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=St.create("div",t,""+this.translate(n.text)+""),n.height&&St.css(e,"height",n.height+"px"),n.width&&St.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 C.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()}}),$n=be.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
"),'
'},postRender:function(){var e=this,n=e.settings.onclick;return e.on("click",function(t){t.aria&&"down"===t.aria.key||t.control!==e||Un.getParent(t.target,"."+e.classPrefix+"open")||(t.stopImmediatePropagation(),n.call(e,t))}),delete e.settings.onclick,e._super()}}),qn=tinymce.util.Tools.resolve("tinymce.util.Color"),Yn=ve.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=St.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;St.css(r,{top:100*n+"%"}),e||St.css(s,{left:t.s+"%",top:100-t.v+"%"}),o.style.background=qn({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 Re(a._id+"-sv",{start:t,drag:t}),a._hdraghelper=new Re(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=qn()),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}()+'
','
'+t+"
"}}),$n=ve.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=St.create("div",t,""+this.translate(n.text)+""),n.height&&St.css(e,"height",n.height+"px"),n.width&&St.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()}}),Xn=ve.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
"),r=e.settings.icon?i+"ico "+i+"i-"+r:"",e.aria("role",e.parent()instanceof zr?"menuitem":"button"),'
'},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 Fr&&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 Ur(i,r){var o,s,a=this,l=ue.classPrefix;a.show=function(t,e){function n(){o&&(Mt(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 Vr=Ue.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 Ur(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()}}),qr=Fr.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?'
'+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()}}),$r=Bn.extend({Defaults:{classes:"radio",role:"radio"}}),Xr=ve.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 Re(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 jr(t){var e="";if(t)for(var n=0;n'+t[n]+"";return e}var Jr=ve.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=jr(e._options),e.size&&(n=' size = "'+e.size+'"'),'"},bindStates:function(){var e=this;return e.state.on("change:options",function(t){e.getEl().innerHTML=jr(t.value)}),e._super()}});function Gr(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=Gr(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 Re(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)-St.getSize(l)[r],m.fire("dragstart",{value:h})},drag:function(t){var e=t[n]-u;f=Gr(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(),Zr(this,this.value())},bindStates:function(){var e=this;return e.state.on("change:value",function(t){Zr(e,t.value)}),e._super()}}),to=ve.extend({renderHtml:function(){return this.classes.add("spacer"),this.canFocus=!1,'
'}}),eo=Fr.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,Mt(t).css({width:i.w-St.getSize(e).width,height:i.h-2}),Mt(e).css({height:i.h-2}),this},activeMenu:function(t){Mt(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+'"':"",'
'},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()}}),no=or.extend({Defaults:{containerClass:"stack-layout",controlClass:"stack-layout-item",endClass:"break"},isNative:function(){return!0}}),io=We.extend({Defaults:{layout:"absolute",defaults:{type:"panel"}},activateTab:function(n){var t;this.activeTabId&&(t=this.getEl(this.activeTabId),Mt(t).removeClass(this.classPrefix+"active"),t.setAttribute("aria-selected","false")),this.activeTabId="t"+n,(t=this.getEl("t"+n)).setAttribute("aria-selected","true"),Mt(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+='"}),'
'+r+'
'+t.renderHtml(i)+"
"},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=St.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=St.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}}),ro=ve.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=St.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()}}),oo=function(){return{Selector:Vt,Collection:$t,ReflowQueue:te,Control:ue,Factory:Ce,KeyboardNavigation:Ee,Container:Oe,DragHelper:Re,Scrollable:Pe,Panel:We,Movable:ge,Resizable:De,FloatPanel:Ue,Window:je,MessageBox:Ze,Tooltip:pe,Widget:ve,Progress:be,Notification:xe,Layout:On,AbsoluteLayout:Pn,Button:Wn,ButtonGroup:An,Checkbox:Bn,ComboBox:In,ColorBox:zn,PanelButton:Fn,ColorButton:Vn,ColorPicker:Yn,Path:Xn,ElementPath:jn,FormItem:Jn,Form:Gn,FieldSet:Kn,FilePicker:nr,FitLayout:ir,FlexLayout:rr,FlowLayout:or,FormatControls:Wr,GridLayout:Dr,Iframe:Ar,InfoBox:Br,Label:Lr,Toolbar:Ir,MenuBar:zr,MenuButton:Fr,MenuItem:Yr,Throbber:Ur,Menu:Vr,ListBox:qr,Radio:$r,ResizeHandle:Xr,SelectBox:Jr,Slider:Qr,Spacer:to,SplitButton:eo,StackLayout:no,TabPanel:io,TextBox:ro,DropZone:$n,BrowseButton:Dn}},so=function(n){n.ui?R.each(oo(),function(t,e){n.ui[e]=t}):n.ui=oo()};R.each(oo(),function(t,e){Ce.add(e,t)}),so(window.tinymce?window.tinymce:{}),o.add("inlite",function(t){var e=Nn();return Wr.setup(t),Cn(t,e),Qe(t,e)})}(); \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/modern/theme.js b/wp-includes/js/tinymce/themes/modern/theme.js index d63a9d7830..6a2798c351 100644 --- a/wp-includes/js/tinymce/themes/modern/theme.js +++ b/wp-includes/js/tinymce/themes/modern/theme.js @@ -1,9826 +1,5136 @@ (function () { var modern = (function () { - 'use strict'; + 'use strict'; - var global = tinymce.util.Tools.resolve('tinymce.ThemeManager'); + var global = tinymce.util.Tools.resolve('tinymce.ThemeManager'); - var global$1 = tinymce.util.Tools.resolve('tinymce.EditorManager'); + var global$1 = tinymce.util.Tools.resolve('tinymce.EditorManager'); - var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools'); + 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); + 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 { - 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 $_5hpmustzjjgwefnb = { - fireSkinLoaded: fireSkinLoaded, - fireResizeEditor: fireResizeEditor, - fireBeforeRenderUI: fireBeforeRenderUI - }; - - var focus = function (panel, type) { - return function () { - var item = panel.find(type)[0]; - if (item) { - item.focus(true); + return 'vertical'; } }; - }; - 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 $_azwbz4u0jjgwefnc = { 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 x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; - } - }; - - var compose = function (fa, fb) { - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; + 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 fa(fb.apply(null, arguments)); + return skinUrl; }; - }; - var constant = function (value) { - return function () { - return value; - }; - }; - - - var curry = function (f) { - var x = []; - for (var _i = 1; _i < arguments.length; _i++) { - x[_i - 1] = arguments[_i]; - } - var args = new Array(arguments.length - 1); - for (var i = 1; i < arguments.length; i++) - args[i - 1] = arguments[i]; - return function () { - var x = []; - for (var _i = 0; _i < arguments.length; _i++) { - x[_i] = arguments[_i]; + 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 newArgs = new Array(arguments.length); - for (var j = 0; j < newArgs.length; j++) - newArgs[j] = arguments[j]; - var all = args.concat(newArgs); - return f.apply(null, all); + var mainToolbar = settings.toolbar ? [settings.toolbar] : [defaultToolbar]; + return toolbars.length > 0 ? toolbars : mainToolbar; }; - }; - - - - - var never = constant(false); - var always = constant(true); - - var never$1 = never; - var always$1 = always; - var none = function () { - return NONE; - }; - var NONE = function () { - var eq = function (o) { - return o.isNone(); - }; - var call$$1 = function (thunk) { - return thunk(); - }; - var id = function (n) { - return n; - }; - var noop$$1 = function () { - }; - var nul = function () { - return null; - }; - var undef = function () { - return undefined; - }; - var me = { - fold: function (n, s) { - return n(); - }, - is: never$1, - isSome: never$1, - isNone: always$1, - getOr: id, - getOrThunk: call$$1, - getOrDie: function (msg) { - throw new Error(msg || 'error: getOrDie called on none.'); - }, - getOrNull: nul, - getOrUndefined: undef, - or: id, - orThunk: call$$1, - map: none, - ap: none, - each: noop$$1, - bind: none, - flatten: none, - exists: never$1, - forall: always$1, - filter: none, - equals: eq, - equals_: eq, - toArray: function () { + 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 []; - }, - toString: constant('none()') + } else if (global$2.isArray(toolbar)) { + return global$2.grep(toolbar, function (toolbar) { + return toolbar.length > 0; + }); + } else { + return getIndexedToolbars(editor.settings, defaultToolbar); + } }; - if (Object.freeze) - Object.freeze(me); - return me; - }(); - var some = function (a) { - var constant_a = function () { - return a; + + 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 self = function () { + 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 args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + }; + var constant = function (value) { + return function () { + return value; + }; + }; + var never = constant(false); + var always = constant(true); + + var never$1 = never; + var always$1 = always; + var none = function () { + return NONE; + }; + var NONE = function () { + var eq = function (o) { + return o.isNone(); + }; + var call$$1 = function (thunk) { + return thunk(); + }; + var id = function (n) { + return n; + }; + var noop$$1 = function () { + }; + var nul = function () { + return null; + }; + var undef = function () { + return undefined; + }; + var me = { + fold: function (n, s) { + return n(); + }, + is: never$1, + isSome: never$1, + isNone: always$1, + getOr: id, + getOrThunk: call$$1, + getOrDie: function (msg) { + throw new Error(msg || 'error: getOrDie called on none.'); + }, + getOrNull: nul, + getOrUndefined: undef, + or: id, + orThunk: call$$1, + map: none, + ap: none, + each: noop$$1, + bind: none, + flatten: none, + exists: never$1, + forall: always$1, + 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 = function () { + return a; + }; + var self = function () { + return me; + }; + var map = function (f) { + return some(f(a)); + }; + var bind = function (f) { + return f(a); + }; + var me = { + fold: function (n, s) { + return s(a); + }, + is: function (v) { + return a === v; + }, + isSome: always$1, + isNone: never$1, + getOr: constant_a, + getOrThunk: constant_a, + getOrDie: constant_a, + getOrNull: constant_a, + getOrUndefined: constant_a, + or: self, + orThunk: self, + map: map, + ap: function (optfab) { + return optfab.fold(none, function (fab) { + return some(fab(a)); + }); + }, + each: function (f) { + f(a); + }, + bind: bind, + flatten: constant_a, + exists: bind, + forall: bind, + filter: function (f) { + return f(a) ? me : NONE; + }, + equals: function (o) { + return o.is(a); + }, + equals_: function (o, elementEq) { + return o.fold(never$1, function (b) { + return elementEq(a, b); + }); + }, + toArray: function () { + return [a]; + }, + toString: function () { + return 'some(' + a + ')'; + } + }; return me; }; - var map = function (f) { - return some(f(a)); + var from = function (value) { + return value === null || value === undefined ? NONE : some(value); }; - var bind = function (f) { - return f(a); + var Option = { + some: some, + none: none, + from: from }; - var me = { - fold: function (n, s) { - return s(a); - }, - is: function (v) { - return a === v; - }, - isSome: always$1, - isNone: never$1, - getOr: constant_a, - getOrThunk: constant_a, - getOrDie: constant_a, - getOrNull: constant_a, - getOrUndefined: constant_a, - or: self, - orThunk: self, - map: map, - ap: function (optfab) { - return optfab.fold(none, function (fab) { - return some(fab(a)); - }); - }, - each: function (f) { - f(a); - }, - bind: bind, - flatten: constant_a, - exists: bind, - forall: bind, - filter: function (f) { - return f(a) ? me : NONE; - }, - equals: function (o) { - return o.is(a); - }, - equals_: function (o, elementEq) { - return o.fold(never$1, function (b) { - return elementEq(a, b); - }); - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; - } - }; - 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 $_6344qfu4jjgwefnr = { - 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; + 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 { - 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)); + return Option.none(); } }; - 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 $_4udolhu7jjgwefo1 = { - createToolbar: createToolbar, - createToolbars: createToolbars - }; + 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 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) { + var createToolbar = function (editor, items, size) { + var toolbarItems = []; + var buttonGroup; + if (!items) { 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 = $_6344qfu4jjgwefnr.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)); + 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); } - } 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); + if (item.settings.disabledStateSelector) { + selection.selectorChanged(item.settings.disabledStateSelector, function (state) { + item.disabled(state); + }); } }; - global$7.requestAnimationFrame(execute); - }; - }; - var bindScrollEvent = function (panel) { - if (!scrollContainer) { - var reposition_1 = repositionHandler(true); - var uiContainer_1 = $_6344qfu4jjgwefnr.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: $_4udolhu7jjgwefo1.createToolbar(editor, match.toolbar.items), - oncancel: function () { - editor.focus(); + 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); + } + } } }); - $_6344qfu4jjgwefnr.setUiContainer(editor, panel); - bindScrollEvent(panel); - match.toolbar.panel = panel; - panel.renderTo().reflow(); - reposition(match); + return { + type: 'toolbar', + layout: 'flow', + items: toolbarItems + }; }; - var hideAllContextToolbars = function () { - global$2.each(getContextToolbars(), function (toolbar) { + 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 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; + var movePanelTo = function (panel, pos) { + panel.moveTo(pos.left, pos.top); }; - 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(); - } + 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))); }); - }); - 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(); - } + global$2.each({ + l: 'left', + r: 'right' + }, function (cls, pos) { + panel.classes.toggle('arrow-' + cls, predicate(pos, relPos.substr(1, 1))); }); - editor.contextToolbars = {}; - }); - editor.shortcuts.add('ctrl+shift+e > ctrl+shift+p', '', function () { - var match = findFrontMostMatch(editor.selection.getNode()); - if (match && match.toolbar.panel) { - match.toolbar.panel.items()[0].focus(); - } - }); - }; - var $_g1gegqu1jjgwefne = { addContextualToolbars: addContextualToolbars }; - - var typeOf = function (x) { - if (x === null) - return 'null'; - var t = typeof x; - if (t === 'object' && Array.prototype.isPrototypeOf(x)) - return 'array'; - if (t === 'object' && String.prototype.isPrototypeOf(x)) - return 'string'; - return t; - }; - var isType = function (type) { - return function (value) { - return typeOf(value) === type; }; - }; - - - - - - - var isFunction = isType('function'); - var isNumber = isType('number'); - - var rawIndexOf = function () { - var pIndexOf = Array.prototype.indexOf; - var fastIndex = function (xs, x) { - return pIndexOf.call(xs, x); - }; - var slowIndex = function (xs, x) { - return slowIndexOf(xs, x); - }; - return pIndexOf === undefined ? slowIndex : fastIndex; - }(); - var indexOf = function (xs, x) { - var r = rawIndexOf(xs, x); - return r === -1 ? Option.none() : Option.some(r); - }; - - var exists = function (xs, pred) { - return findIndex(xs, pred).isSome(); - }; - - - 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, xs); - } - return r; - }; - var each = function (xs, f) { - for (var i = 0, len = xs.length; i < len; i++) { - var x = xs[i]; - f(x, i, xs); - } - }; - - - 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, xs)) { - 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, xs)) { - 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, xs)) { - return Option.some(i); - } - } - return Option.none(); - }; - var slowIndexOf = function (xs, x) { - for (var i = 0, len = xs.length; i < len; ++i) { - if (xs[i] === x) { - return i; - } - } - return -1; - }; - var push = Array.prototype.push; - var flatten = function (xs) { - var r = []; - for (var i = 0, len = xs.length; i < len; ++i) { - if (!Array.prototype.isPrototypeOf(xs[i])) - throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); - push.apply(r, xs[i]); - } - return r; - }; - - - - var slice = Array.prototype.slice; - var reverse = function (xs) { - var r = slice.call(xs, 0); - r.reverse(); - return r; - }; - - - - - - - var from$1 = isFunction(Array.from) ? Array.from : function (x) { - return slice.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, namedMenuItems) { - return !isSeparator(namedMenuItem) || !isSeparator(namedMenuItems[i - 1]); - }); - return filter(menuItemsPass2, function (namedMenuItem, i, namedMenuItems) { - return !isSeparator(namedMenuItem) || i > 0 && i < namedMenuItems.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 $_bahgsqu8jjgwefo4 = { 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); - $_5hpmustzjjgwefnb.fireResizeEditor(editor); - }; - var resizeBy = function (editor, dw, dh) { - var elm = editor.getContentAreaContainer(); - resizeTo(editor, elm.clientWidth + dw, elm.clientHeight + dh); - }; - var $_sd6u0ubjjgwefok = { - 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); - } - $_5hpmustzjjgwefnb.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 $_b7ut9jucjjgwefom = { - hasSidebar: hasSidebar, - createSidebar: createSidebar - }; - - var fireSkinLoaded$1 = function (editor) { - var done = function () { - editor._skinLoaded = true; - $_5hpmustzjjgwefnb.fireSkinLoaded(editor); - }; - return function () { - if (editor.initialized) { - done(); - } else { - editor.on('init', done); - } - }; - }; - var $_awdosmuejjgwefop = { 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'), - $_b7ut9jucjjgwefom.createSidebar(editor) - ] - }; - }; - var render = function (editor, theme, args) { - var panel, resizeHandleCtrl, startSize; - if (isSkinDisabled(editor) === false && args.skinUiCss) { - DOM$2.styleSheetLoader.load(args.skinUiCss, $_awdosmuejjgwefop.fireSkinLoaded(editor)); - } else { - $_awdosmuejjgwefop.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: $_bahgsqu8jjgwefo4.createMenuButtons(editor) - }, - $_4udolhu7jjgwefo1.createToolbars(editor, getToolbarSize(editor)) - ] - }, - $_b7ut9jucjjgwefom.hasSidebar(editor) ? editAreaContainer(editor) : editArea('1 0 0 0') - ] - }); - $_6344qfu4jjgwefnr.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') { - $_sd6u0ubjjgwefok.resizeTo(editor, startSize.width + e.deltaX, startSize.height + e.deltaY); - } else { - $_sd6u0ubjjgwefok.resizeTo(editor, null, startSize.height + e.deltaY); - } - } - }; - } - if (hasStatusbar(editor)) { - var linkHtml = 'tinymce'; - 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 - ] - }); - } - $_5hpmustzjjgwefnb.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; - }); - $_azwbz4u0jjgwefnc.addKeys(editor, panel); - $_g1gegqu1jjgwefne.addContextualToolbars(editor); - return { - iframeContainer: panel.find('#iframe')[0].getEl(), - editorContainer: panel.getEl() - }; - }; - var $_vxdgetvjjgwefn7 = { 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$$1, attrs, children) { - var elm = document.createElement(name$$1); - 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 : document.body; - }, - getViewPort: function (win) { - return global$3.DOM.getViewPort(win); - }, - get: function (id) { - return 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$$1, value) { - return global$3.DOM.setStyle(elm, name$$1, value); - }, - getRuntimeStyle: function (elm, name$$1) { - return global$3.DOM.getStyle(elm, name$$1, true); - }, - on: function (target, name$$1, callback, scope) { - return global$3.DOM.bind(target, name$$1, callback, scope); - }, - off: function (target, name$$1, callback) { - return global$3.DOM.unbind(target, name$$1, callback); - }, - fire: function (target, name$$1, args) { - return global$3.DOM.fire(target, name$$1, 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, $_6344qfu4jjgwefnr.getUiContainer(ctrl)); - x = pos.x; - y = pos.y; - if (isFixed(ctrl) && isStatic(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 = window; - var x = Math.max(win.pageXOffset, document.body.scrollLeft, document.documentElement.scrollLeft); - var y = Math.max(win.pageYOffset, document.body.scrollTop, document.documentElement.scrollTop); - var w = win.innerWidth || document.documentElement.clientWidth; - var h = win.innerHeight || document.documentElement.clientHeight; - return { - x: x, - y: y, - w: x + w, - h: y + h - }; - }; - var getViewPortRect = function (ctrl) { - var customUiContainer = $_6344qfu4jjgwefnr.getUiContainer(ctrl); - return customUiContainer && !isFixed(ctrl) ? getUiContainerViewPort(customUiContainer) : getWindowViewPort(); - }; - var $_3fnh5iukjjgwefpt = { - 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 && pos.y > viewPortRect.y && pos.y + pos.h < viewPortRect.h) { - 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$$1 = this, rect = self$$1.layoutRect(); - self$$1.moveTo(rect.x + dx, rect.y + dy); - return self$$1; - }, - moveTo: function (x, y) { - var self$$1 = 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$$1.settings.constrainToViewport) { - var viewPortRect = getViewPortRect(this); - var layoutRect = self$$1.layoutRect(); - x = constrain(x, viewPortRect.w, layoutRect.w); - y = constrain(y, viewPortRect.h, layoutRect.h); - } - var uiContainer = $_6344qfu4jjgwefnr.getUiContainer(self$$1); - if (uiContainer && isStatic(uiContainer) && !isFixed(self$$1)) { - x -= uiContainer.scrollLeft; - y -= uiContainer.scrollTop; - } - if (uiContainer) { - x += 1; - y += 1; - } - if (self$$1.state.get('rendered')) { - self$$1.layoutRect({ - x: x, - y: y - }).repaint(); - } else { - self$$1.settings.x = x; - self$$1.settings.y = y; - } - self$$1.fire('move', { + var userConstrain = function (handler, x, y, elementRect, contentAreaRect, panelRect) { + panelRect = toClientRect({ x: x, - y: y + y: y, + w: panelRect.w, + h: panelRect.h }); - return self$$1; - } - }; - - var global$10 = tinymce.util.Tools.resolve('tinymce.util.Class'); - - var global$11 = tinymce.util.Tools.resolve('tinymce.util.EventDispatcher'); - - var $_fbr241uqjjgwefqo = { - parseBox: function (value) { - var len; - var radix = 10; - if (!value) { - return; + if (handler) { + panelRect = handler({ + elementRect: toClientRect(elementRect), + contentAreaRect: toClientRect(contentAreaRect), + panelRect: panelRect + }); } - 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 + return panelRect; + }; + var addContextualToolbars = function (editor) { + var scrollContainer; + var getContextToolbars = function () { + return editor.contextToolbars || []; }; - }, - 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; - } + 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; } - 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') + targetRect.x += pos.x; + targetRect.y += pos.y; + return targetRect; }; - } - }; - - 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; - } + var reposition = function (match, shouldShow) { + var relPos, panelRect, elementRect, contentAreaRect, panel, relRect, testPositions, smallElementWidthThreshold; + var handler = getInlineToolbarPositionHandler(editor); + if (editor.removed) { + return; } - 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); + 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 { - this.add(cls); + 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(); + } } - 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; - }; + 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 }; - function unique(array) { - var uniqueItems = []; - var i = array.length, item; - while (i--) { - item = array[i]; - if (!item.__checked) { - uniqueItems.push(item); - item.__checked = 1; + var typeOf = function (x) { + if (x === null) + return 'null'; + var t = typeof x; + if (t === 'object' && Array.prototype.isPrototypeOf(x)) + return 'array'; + if (t === 'object' && String.prototype.isPrototypeOf(x)) + return 'string'; + return t; + }; + var isType = function (type) { + return function (value) { + return typeOf(value) === type; + }; + }; + var isFunction = isType('function'); + var isNumber = isType('number'); + + var rawIndexOf = function () { + var pIndexOf = Array.prototype.indexOf; + var fastIndex = function (xs, x) { + return pIndexOf.call(xs, x); + }; + var slowIndex = function (xs, x) { + return slowIndexOf(xs, x); + }; + return pIndexOf === undefined ? slowIndex : fastIndex; + }(); + var indexOf = function (xs, x) { + var r = rawIndexOf(xs, x); + return r === -1 ? Option.none() : Option.some(r); + }; + var exists = function (xs, pred) { + return findIndex(xs, pred).isSome(); + }; + 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, xs); } - } - 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$10.extend({ - init: function (selector) { - var match = this.match; - function compileNameFilter(name) { - if (name) { - name = name.toLowerCase(); - return function (item) { - return name === '*' || item.type === name; - }; + return r; + }; + var each = function (xs, f) { + for (var i = 0, len = xs.length; i < len; i++) { + var x = xs[i]; + f(x, i, xs); + } + }; + 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, xs)) { + r.push(x); } } - function compileIdFilter(id) { - if (id) { - return function (item) { - return item._name === id; - }; + 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, xs)) { + return Option.some(x); } } - 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 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, xs)) { + return Option.some(i); + } + } + return Option.none(); + }; + var slowIndexOf = function (xs, x) { + for (var i = 0, len = xs.length; i < len; ++i) { + if (xs[i] === x) { + return i; + } + } + return -1; + }; + var push = Array.prototype.push; + var flatten = function (xs) { + var r = []; + for (var i = 0, len = xs.length; i < len; ++i) { + if (!Array.prototype.isPrototypeOf(xs[i])) + throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs); + push.apply(r, xs[i]); + } + return r; + }; + var slice = Array.prototype.slice; + var from$1 = isFunction(Array.from) ? Array.from : function (x) { + return slice.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, namedMenuItems) { + return !isSeparator(namedMenuItem) || !isSeparator(namedMenuItems[i - 1]); + }); + return filter(menuItemsPass2, function (namedMenuItem, i, namedMenuItems) { + return !isSeparator(namedMenuItem) || i > 0 && i < namedMenuItems.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()); } } - return true; - }; + }); + } + menuButton.menu = map(cleanupMenu(namedMenuItems, removedMenuItems), function (menuItem) { + return menuItem.item; + }); + if (!menuButton.menu.length) { + return null; } } - 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; - }; + 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); } } - 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; + 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); + } } - notSelectors = parseChunks(name[1], []); - return function (item) { - return !match(item, notSelectors); + }; + } + 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$$1, attrs, children) { + var elm = document.createElement(name$$1); + 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 : document.body; + }, + getViewPort: function (win) { + return global$3.DOM.getViewPort(win); + }, + get: function (id) { + return 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$$1, value) { + return global$3.DOM.setStyle(elm, name$$1, value); + }, + getRuntimeStyle: function (elm, name$$1) { + return global$3.DOM.getStyle(elm, name$$1, true); + }, + on: function (target, name$$1, callback, scope) { + return global$3.DOM.bind(target, name$$1, callback, scope); + }, + off: function (target, name$$1, callback) { + return global$3.DOM.unbind(target, name$$1, callback); + }, + fire: function (target, name$$1, args) { + return global$3.DOM.fire(target, name$$1, 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(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 = window; + var x = Math.max(win.pageXOffset, document.body.scrollLeft, document.documentElement.scrollLeft); + var y = Math.max(win.pageYOffset, document.body.scrollTop, document.documentElement.scrollTop); + var w = win.innerWidth || document.documentElement.clientWidth; + var h = win.innerHeight || 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$$1 = this, rect = self$$1.layoutRect(); + self$$1.moveTo(rect.x + dx, rect.y + dy); + return self$$1; + }, + moveTo: function (x, y) { + var self$$1 = 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$$1.settings.constrainToViewport) { + var viewPortRect = getViewPortRect(this); + var layoutRect = self$$1.layoutRect(); + x = constrain(x, viewPortRect.w + viewPortRect.x, layoutRect.w); + y = constrain(y, viewPortRect.h + viewPortRect.y, layoutRect.h); + } + var uiContainer = UiContainer.getUiContainer(self$$1); + if (uiContainer && isStatic(uiContainer) && !isFixed(self$$1)) { + x -= uiContainer.scrollLeft; + y -= uiContainer.scrollTop; + } + if (uiContainer) { + x += 1; + y += 1; + } + if (self$$1.state.get('rendered')) { + self$$1.layoutRect({ + x: x, + y: y + }).repaint(); + } else { + self$$1.settings.x = x; + self$$1.settings.y = y; + } + self$$1.fire('move', { + x: x, + y: y + }); + return self$$1; + } + }; + + 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 }; } - } - function compile(selector, filters, direct) { - var parts; - function add(filter) { - if (filter) { - filters.push(filter); - } + 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]; } - 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; + 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 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]; + }; + + 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; } } - } while (matches); - if (extra) { - parseChunks(extra, selectors); + this.cls.splice(i, 1); + delete this.cls._map[cls]; + this._change(); } - selector = []; - for (i = 0; i < parts.length; i++) { - if (parts[i] !== '>') { - selector.push(compile(parts[i], [], parts[i - 1] === '>')); + 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; + }; } } - 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) { + 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, index, length)) { + if (!filters[fi](item, i, l)) { fi = fl + 1; break; } } if (fi === fl) { - count++; - break; - } else { - if (si === sl - 1) { - break; + if (index === selector.length - 1) { + matches.push(item); + } else { + if (item.items) { + collect(item.items(), selector, index + 1); + } } + } else if (filters.direct) { + return; } - 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 (item.items) { + collect(item.items(), selector, index); } } - 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 (container.items) { + for (i = 0, l = selectors.length; i < l; i++) { + collect(container.items(), selectors[i], 0); } - if (item.items) { - collect(item.items(), selector, index); + if (l > 1) { + matches = unique(matches); } } - } - 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); } - if (!Collection) { - Collection = Selector.Collection; - } - return new Collection(matches); - } - }); + }); - var Collection$1; - var proto; - var push$1 = Array.prototype.push; - var slice$1 = 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()); + var Collection$1, proto; + var push$1 = Array.prototype.push, slice$1 = 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$1.call(self, items); + } } else { - push$1.call(self, items); + push$1.apply(self, items); } - } else { - push$1.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 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 new Collection$1(matches); - }, - slice: function () { - return new Collection$1(slice$1.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 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; } - } - 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) { + 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$1.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](value); + item[name].apply(item, args); } }); 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$10.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$12 = 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$10.extend({ - Mixins: [global$12], - 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]); + }, + 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); + }); } - 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 = {}; - var animationFrameRequested; - var $_p42hyuxjjgwefrk = { - add: function (ctrl) { - var parent$$1 = ctrl.parent(); - if (parent$$1) { - if (!parent$$1._layout || parent$$1._layout.isNative()) { - return; - } - if (!dirtyCtrls[parent$$1._id]) { - dirtyCtrls[parent$$1._id] = parent$$1; - } - 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 = {}; - }, document.body); - } - } - }, - remove: function (ctrl) { - if (dirtyCtrls[ctrl._id]) { - delete dirtyCtrls[ctrl._id]; - } - } - }; - - var hasMouseWheelEventSupport = 'onmousewheel' in document; - var hasWheelEventSupport = false; - var classPrefix = 'mce-'; - var Control; - var idCounter = 0; - var proto$1 = { - Statics: { classPrefix: classPrefix }, - isRtl: function () { - return Control.rtl; - }, - classPrefix: classPrefix, - init: function (settings) { - var self$$1 = this; - var classes, defaultClasses; - function applyClasses(classes) { - var i; - classes = classes.split(' '); - for (i = 0; i < classes.length; i++) { - self$$1.classes.add(classes[i]); - } - } - self$$1.settings = settings = global$2.extend({}, self$$1.Defaults, settings); - self$$1._id = settings.id || 'mceu_' + idCounter++; - self$$1._aria = { role: settings.role }; - self$$1._elmCache = {}; - self$$1.$ = global$9; - self$$1.state = new ObservableObject({ - visible: true, - active: false, - disabled: false, - value: '' - }); - self$$1.data = new ObservableObject(settings.data); - self$$1.classes = new ClassList(function () { - if (self$$1.state.get('rendered')) { - self$$1.getEl().className = this.toString(); - } - }); - self$$1.classes.prefix = self$$1.classPrefix; - classes = settings.classes; - if (classes) { - if (self$$1.Defaults) { - defaultClasses = self$$1.Defaults.classes; - if (defaultClasses && classes !== defaultClasses) { - applyClasses(defaultClasses); + }; + 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); } - } - applyClasses(classes); - } - global$2.each('title text name visible disabled active value'.split(' '), function (name$$1) { - if (name$$1 in settings) { - self$$1[name$$1](settings[name$$1]); - } - }); - self$$1.on('click', function () { - if (self$$1.disabled()) { - return false; - } - }); - self$$1.settings = settings; - self$$1.borderBox = $_fbr241uqjjgwefqo.parseBox(settings.border); - self$$1.paddingBox = $_fbr241uqjjgwefqo.parseBox(settings.padding); - self$$1.marginBox = $_fbr241uqjjgwefqo.parseBox(settings.margin); - if (settings.hidden) { - self$$1.hide(); - } - }, - Properties: 'parent,name', - getContainerElm: function () { - var uiContainer = $_6344qfu4jjgwefnr.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$$1 = this; - var settings = self$$1.settings; - var borderBox, layoutRect; - var elm = self$$1.getEl(); - var width, height, minWidth, minHeight, autoResize; - var startMinWidth, startMinHeight, initialSize; - borderBox = self$$1.borderBox = self$$1.borderBox || $_fbr241uqjjgwefqo.measureBox(elm, 'border'); - self$$1.paddingBox = self$$1.paddingBox || $_fbr241uqjjgwefqo.measureBox(elm, 'padding'); - self$$1.marginBox = self$$1.marginBox || $_fbr241uqjjgwefqo.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$$1._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 + }); + return this; }; - self$$1._lastLayoutRect = {}; - return layoutRect; - }, - layoutRect: function (newRect) { - var self$$1 = this; - var curRect = self$$1._layoutRect, lastLayoutRect, size, deltaWidth, deltaHeight, repaintControls; - if (!curRect) { - curRect = self$$1.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$$1._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$$1._id]) { - repaintControls.push(self$$1); - repaintControls.map[self$$1._id] = true; - } - } - lastLayoutRect.x = curRect.x; - lastLayoutRect.y = curRect.y; - lastLayoutRect.w = curRect.w; - lastLayoutRect.h = curRect.h; - } - return self$$1; - } - return curRect; - }, - repaint: function () { - var self$$1 = this; - var style, bodyStyle, bodyElm, rect, borderBox; - var borderW, borderH, lastRepaintRect, round, value; - round = !document.createRange ? Math.round : function (value) { - return value; + }); + 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); }; - style = self$$1.getEl().style; - rect = self$$1._layoutRect; - lastRepaintRect = self$$1._lastRepaintRect || {}; - borderBox = self$$1.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$$1._hasBody && rect.innerW !== lastRepaintRect.innerW) { - value = round(rect.innerW); - bodyElm = self$$1.getEl('body'); - if (bodyElm) { - bodyStyle = bodyElm.style; - bodyStyle.width = (value >= 0 ? value : 0) + 'px'; - } - lastRepaintRect.innerW = rect.innerW; - } - if (self$$1._hasBody && rect.innerH !== lastRepaintRect.innerH) { - value = round(rect.innerH); - bodyElm = bodyElm || self$$1.getEl('body'); - if (bodyElm) { - bodyStyle = bodyStyle || bodyElm.style; - bodyStyle.height = (value >= 0 ? value : 0) + 'px'; - } - lastRepaintRect.innerH = rect.innerH; - } - self$$1._lastRepaintRect = lastRepaintRect; - self$$1.fire('repaint', {}, false); - }, - updateLayoutRect: function () { - var self$$1 = this; - self$$1.parent()._lastRect = null; - funcs.css(self$$1.getEl(), { - width: '', - height: '' - }); - self$$1._layoutRect = self$$1._lastRepaintRect = self$$1._lastLayoutRect = null; - self$$1.initLayoutRect(); - }, - on: function (name$$1, callback) { - var self$$1 = this; - function resolveCallbackName(name$$1) { - var callback, scope; - if (typeof name$$1 !== 'string') { - return name$$1; - } - return function (e) { - if (!callback) { - self$$1.parentsAndSelf().each(function (ctrl) { - var callbacks = ctrl.settings.callbacks; - if (callbacks && (callback = callbacks[name$$1])) { - scope = ctrl; - return false; + }); + 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](); } }); } - if (!callback) { - e.action = name$$1; - this.fire('execute', e); + 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$$1 = ctrl.parent(); + if (parent$$1) { + if (!parent$$1._layout || parent$$1._layout.isNative()) { return; } - return callback.call(scope, e); + if (!dirtyCtrls[parent$$1._id]) { + dirtyCtrls[parent$$1._id] = parent$$1; + } + 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 = {}; + }, document.body); + } + } + }, + remove: function (ctrl) { + if (dirtyCtrls[ctrl._id]) { + delete dirtyCtrls[ctrl._id]; + } + } + }; + + var hasMouseWheelEventSupport = 'onmousewheel' in 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$$1 = this; + var classes, defaultClasses; + function applyClasses(classes) { + var i; + classes = classes.split(' '); + for (i = 0; i < classes.length; i++) { + self$$1.classes.add(classes[i]); + } + } + self$$1.settings = settings = global$2.extend({}, self$$1.Defaults, settings); + self$$1._id = settings.id || 'mceu_' + idCounter++; + self$$1._aria = { role: settings.role }; + self$$1._elmCache = {}; + self$$1.$ = global$9; + self$$1.state = new ObservableObject({ + visible: true, + active: false, + disabled: false, + value: '' + }); + self$$1.data = new ObservableObject(settings.data); + self$$1.classes = new ClassList(function () { + if (self$$1.state.get('rendered')) { + self$$1.getEl().className = this.toString(); + } + }); + self$$1.classes.prefix = self$$1.classPrefix; + classes = settings.classes; + if (classes) { + if (self$$1.Defaults) { + defaultClasses = self$$1.Defaults.classes; + if (defaultClasses && classes !== defaultClasses) { + applyClasses(defaultClasses); + } + } + applyClasses(classes); + } + global$2.each('title text name visible disabled active value'.split(' '), function (name$$1) { + if (name$$1 in settings) { + self$$1[name$$1](settings[name$$1]); + } + }); + self$$1.on('click', function () { + if (self$$1.disabled()) { + return false; + } + }); + self$$1.settings = settings; + self$$1.borderBox = BoxUtils.parseBox(settings.border); + self$$1.paddingBox = BoxUtils.parseBox(settings.padding); + self$$1.marginBox = BoxUtils.parseBox(settings.margin); + if (settings.hidden) { + self$$1.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$$1 = this; + var settings = self$$1.settings; + var borderBox, layoutRect; + var elm = self$$1.getEl(); + var width, height, minWidth, minHeight, autoResize; + var startMinWidth, startMinHeight, initialSize; + borderBox = self$$1.borderBox = self$$1.borderBox || BoxUtils.measureBox(elm, 'border'); + self$$1.paddingBox = self$$1.paddingBox || BoxUtils.measureBox(elm, 'padding'); + self$$1.marginBox = self$$1.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$$1._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 }; - } - getEventDispatcher(self$$1).on(name$$1, resolveCallbackName(callback)); - return self$$1; - }, - off: function (name$$1, callback) { - getEventDispatcher(this).off(name$$1, callback); - return this; - }, - fire: function (name$$1, args, bubble) { - var self$$1 = this; - args = args || {}; - if (!args.control) { - args.control = self$$1; - } - args = getEventDispatcher(self$$1).fire(name$$1, args); - if (bubble !== false && self$$1.parent) { - var parent$$1 = self$$1.parent(); - while (parent$$1 && !args.isPropagationStopped()) { - parent$$1.fire(name$$1, args, false); - parent$$1 = parent$$1.parent(); + self$$1._lastLayoutRect = {}; + return layoutRect; + }, + layoutRect: function (newRect) { + var self$$1 = this; + var curRect = self$$1._layoutRect, lastLayoutRect, size, deltaWidth, deltaHeight, repaintControls; + if (!curRect) { + curRect = self$$1.initLayoutRect(); } - } - return args; - }, - hasEventListeners: function (name$$1) { - return getEventDispatcher(this).has(name$$1); - }, - parents: function (selector) { - var self$$1 = this; - var ctrl, parents = new Collection$2(); - for (ctrl = self$$1.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$$1, value) { - var self$$1 = this, elm = self$$1.getEl(self$$1.ariaTarget); - if (typeof value === 'undefined') { - return self$$1._aria[name$$1]; - } - self$$1._aria[name$$1] = value; - if (self$$1.state.get('rendered')) { - elm.setAttribute(name$$1 === 'role' ? name$$1 : 'aria-' + name$$1, value); - } - return self$$1; - }, - 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$$1 = this, parent$$1 = self$$1.parent(); - if (parent$$1) { - parent$$1.insert(items, parent$$1.items().indexOf(self$$1), true); - } - return self$$1; - }, - after: function (items) { - var self$$1 = this, parent$$1 = self$$1.parent(); - if (parent$$1) { - parent$$1.insert(items, parent$$1.items().indexOf(self$$1)); - } - return self$$1; - }, - remove: function () { - var self$$1 = this; - var elm = self$$1.getEl(); - var parent$$1 = self$$1.parent(); - var newItems, i; - if (self$$1.items) { - var controls = self$$1.items().toArray(); - i = controls.length; - while (i--) { - controls[i].remove(); - } - } - if (parent$$1 && parent$$1.items) { - newItems = []; - parent$$1.items().each(function (item) { - if (item !== self$$1) { - newItems.push(item); + if (newRect) { + deltaWidth = curRect.deltaW; + deltaHeight = curRect.deltaH; + if (newRect.x !== undefined) { + curRect.x = newRect.x; } - }); - parent$$1.items().set(newItems); - parent$$1._lastRect = null; - } - if (self$$1._eventsRoot && self$$1._eventsRoot === self$$1) { - global$9(elm).off(); - } - var lookup = self$$1.getRoot().controlIdLookup; - if (lookup) { - delete lookup[self$$1._id]; - } - if (elm && elm.parentNode) { - elm.parentNode.removeChild(elm); - } - self$$1.state.set('rendered', false); - self$$1.state.destroy(); - self$$1.fire('remove'); - return self$$1; - }, - 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$$1 = this; - var settings = self$$1.settings; - var elm, box, parent$$1, name$$1, parentEventsRoot; - self$$1.$el = global$9(self$$1.getEl()); - self$$1.state.set('rendered', true); - for (name$$1 in settings) { - if (name$$1.indexOf('on') === 0) { - self$$1.on(name$$1.substr(2), settings[name$$1]); - } - } - if (self$$1._eventsRoot) { - for (parent$$1 = self$$1.parent(); !parentEventsRoot && parent$$1; parent$$1 = parent$$1.parent()) { - parentEventsRoot = parent$$1._eventsRoot; - } - if (parentEventsRoot) { - for (name$$1 in parentEventsRoot._nativeEvents) { - self$$1._nativeEvents[name$$1] = true; + 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$$1._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$$1._id]) { + repaintControls.push(self$$1); + repaintControls.map[self$$1._id] = true; + } + } + lastLayoutRect.x = curRect.x; + lastLayoutRect.y = curRect.y; + lastLayoutRect.w = curRect.w; + lastLayoutRect.h = curRect.h; + } + return self$$1; } - } - bindPendingEvents(self$$1); - if (settings.style) { - elm = self$$1.getEl(); - if (elm) { - elm.setAttribute('style', settings.style); - elm.style.cssText = settings.style; - } - } - if (self$$1.settings.border) { - box = self$$1.borderBox; - self$$1.$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$$1.getRoot(); - if (!root.controlIdLookup) { - root.controlIdLookup = {}; - } - root.controlIdLookup[self$$1._id] = self$$1; - for (var key in self$$1._aria) { - self$$1.aria(key, self$$1._aria[key]); - } - if (self$$1.state.get('visible') === false) { - self$$1.getEl().style.display = 'none'; - } - self$$1.bindStates(); - self$$1.state.on('change:visible', function (e) { - var state = e.value; - var parentCtrl; - if (self$$1.state.get('rendered')) { - self$$1.getEl().style.display = state === false ? 'none' : ''; - self$$1.getEl().getBoundingClientRect(); - } - parentCtrl = self$$1.parent(); - if (parentCtrl) { - parentCtrl._lastRect = null; - } - self$$1.fire(state ? 'show' : 'hide'); - $_p42hyuxjjgwefrk.add(self$$1); - }); - self$$1.fire('postrender', {}, false); - }, - bindStates: function () { - }, - scrollIntoView: function (align) { - function getOffset(elm, rootElm) { - var x, y, parent$$1 = elm; - x = y = 0; - while (parent$$1 && parent$$1 !== rootElm && parent$$1.nodeType) { - x += parent$$1.offsetLeft || 0; - y += parent$$1.offsetTop || 0; - parent$$1 = parent$$1.offsetParent; - } - return { - x: x, - y: y + return curRect; + }, + repaint: function () { + var self$$1 = this; + var style, bodyStyle, bodyElm, rect, borderBox; + var borderW, borderH, lastRepaintRect, round, value; + round = !document.createRange ? Math.round : function (value) { + return value; }; - } - 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; + style = self$$1.getEl().style; + rect = self$$1._layoutRect; + lastRepaintRect = self$$1._lastRepaintRect || {}; + borderBox = self$$1.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; } - 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 () { - $_p42hyuxjjgwefrk.remove(this); - var parent$$1 = this.parent(); - if (parent$$1 && parent$$1._layout && !parent$$1._layout.isNative()) { - parent$$1.reflow(); - } - return this; - } - }; - global$2.each('text title visible disabled active value'.split(' '), function (name$$1) { - proto$1[name$$1] = function (value) { - if (arguments.length === 0) { - return this.state.get(name$$1); - } - if (typeof value !== 'undefined') { - this.state.set(name$$1, value); - } - return this; - }; - }); - Control = global$10.extend(proto$1); - function getEventDispatcher(obj) { - if (!obj._eventDispatcher) { - obj._eventDispatcher = new global$11({ - scope: obj, - toggleEvent: function (name$$1, state) { - if (state && global$11.isNative(name$$1)) { - if (!obj._nativeEvents) { - obj._nativeEvents = {}; - } - obj._nativeEvents[name$$1] = true; - if (obj.state.get('rendered')) { - bindPendingEvents(obj); - } + 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$$1._hasBody && rect.innerW !== lastRepaintRect.innerW) { + value = round(rect.innerW); + bodyElm = self$$1.getEl('body'); + if (bodyElm) { + bodyStyle = bodyElm.style; + bodyStyle.width = (value >= 0 ? value : 0) + 'px'; } + lastRepaintRect.innerW = rect.innerW; } - }); - } - return obj._eventDispatcher; - } - function bindPendingEvents(eventCtrl) { - var i, l, parents, eventRootCtrl, nativeEvents, name$$1; - 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() }); + if (self$$1._hasBody && rect.innerH !== lastRepaintRect.innerH) { + value = round(rect.innerH); + bodyElm = bodyElm || self$$1.getEl('body'); + if (bodyElm) { + bodyStyle = bodyStyle || bodyElm.style; + bodyStyle.height = (value >= 0 ? value : 0) + 'px'; + } + lastRepaintRect.innerH = rect.innerH; + } + self$$1._lastRepaintRect = lastRepaintRect; + self$$1.fire('repaint', {}, false); + }, + updateLayoutRect: function () { + var self$$1 = this; + self$$1.parent()._lastRect = null; + funcs.css(self$$1.getEl(), { + width: '', + height: '' }); - 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; + self$$1._layoutRect = self$$1._lastRepaintRect = self$$1._lastLayoutRect = null; + self$$1.initLayoutRect(); + }, + on: function (name$$1, callback) { + var self$$1 = this; + function resolveCallbackName(name$$1) { + var callback, scope; + if (typeof name$$1 !== 'string') { + return name$$1; + } + return function (e) { + if (!callback) { + self$$1.parentsAndSelf().each(function (ctrl) { + var callbacks = ctrl.settings.callbacks; + if (callbacks && (callback = callbacks[name$$1])) { + scope = ctrl; + return false; + } + }); } - } - 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$$1 in nativeEvents) { - if (!nativeEvents) { - return false; - } - if (name$$1 === 'wheel' && !hasWheelEventSupport) { - if (hasMouseWheelEventSupport) { - global$9(eventCtrl.getEl()).on('mousewheel', fixWheelEvent); - } else { - global$9(eventCtrl.getEl()).on('DOMMouseScroll', fixWheelEvent); - } - continue; - } - if (name$$1 === 'mouseenter' || name$$1 === 'mouseleave') { - if (!eventRootCtrl._hasMouseEnter) { - global$9(eventRootCtrl.getEl()).on('mouseleave', mouseLeaveHandler).on('mouseover', mouseEnterHandler); - eventRootCtrl._hasMouseEnter = 1; - } - } else if (!eventRootDelegates[name$$1]) { - global$9(eventRootCtrl.getEl()).on(name$$1, delegate); - eventRootDelegates[name$$1] = true; - } - nativeEvents[name$$1] = 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 = document.activeElement; - } catch (ex) { - focusedElement = 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$$1 = elm || focusedElement; - while (parent$$1 = parent$$1.parentNode) { - if (role = getRole(parent$$1)) { - return role; - } - } - } - function getAriaProp(name$$1) { - var elm = focusedElement; - if (isElement(elm)) { - return elm.getAttribute('aria-' + name$$1); - } - } - 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(); - $_p42hyuxjjgwefrk.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; - $_p42hyuxjjgwefrk.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 || document; - var downButton; - var start, stop$$1, 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 (window.getComputedStyle) { - cursor = 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$$1); - settings.start(e); - }; - drag = function (e) { - updateWithTouchData(e); - if (e.button !== downButton) { - return stop$$1(e); - } - e.deltaX = e.screenX - startX; - e.deltaY = e.screenY - startY; - e.preventDefault(); - settings.drag(e); - }; - stop$$1 = function (e) { - updateWithTouchData(e); - global$9(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop$$1); - $eventOverlay.remove(); - if (settings.stop) { - settings.stop(e); - } - }; - this.destroy = function () { - global$9(handleElement).off(); - }; - global$9(handleElement).on('mousedown touchstart', start); - } - - var $_3rxloyuzjjgwefrs = { - 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'); + if (!callback) { + e.action = name$$1; + this.fire('execute', e); 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); + return callback.call(scope, e); + }; + } + getEventDispatcher(self$$1).on(name$$1, resolveCallbackName(callback)); + return self$$1; + }, + off: function (name$$1, callback) { + getEventDispatcher(this).off(name$$1, callback); + return this; + }, + fire: function (name$$1, args, bubble) { + var self$$1 = this; + args = args || {}; + if (!args.control) { + args.control = self$$1; + } + args = getEventDispatcher(self$$1).fire(name$$1, args); + if (bubble !== false && self$$1.parent) { + var parent$$1 = self$$1.parent(); + while (parent$$1 && !args.isPropagationStopped()) { + parent$$1.fire(name$$1, args, false); + parent$$1 = parent$$1.parent(); } } - 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'); + return args; + }, + hasEventListeners: function (name$$1) { + return getEventDispatcher(this).has(name$$1); + }, + parents: function (selector) { + var self$$1 = this; + var ctrl, parents = new Collection$2(); + for (ctrl = self$$1.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$$1, value) { + var self$$1 = this, elm = self$$1.getEl(self$$1.ariaTarget); + if (typeof value === 'undefined') { + return self$$1._aria[name$$1]; + } + self$$1._aria[name$$1] = value; + if (self$$1.state.get('rendered')) { + elm.setAttribute(name$$1 === 'role' ? name$$1 : 'aria-' + name$$1, value); + } + return self$$1; + }, + 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$$1 = this, parent$$1 = self$$1.parent(); + if (parent$$1) { + parent$$1.insert(items, parent$$1.items().indexOf(self$$1), true); + } + return self$$1; + }, + after: function (items) { + var self$$1 = this, parent$$1 = self$$1.parent(); + if (parent$$1) { + parent$$1.insert(items, parent$$1.items().indexOf(self$$1)); + } + return self$$1; + }, + remove: function () { + var self$$1 = this; + var elm = self$$1.getEl(); + var parent$$1 = self$$1.parent(); + var newItems, i; + if (self$$1.items) { + var controls = self$$1.items().toArray(); + i = controls.length; + while (i--) { + controls[i].remove(); + } + } + if (parent$$1 && parent$$1.items) { + newItems = []; + parent$$1.items().each(function (item) { + if (item !== self$$1) { + newItems.push(item); } }); + parent$$1.items().set(newItems); + parent$$1._lastRect = null; } - 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(); + if (self$$1._eventsRoot && self$$1._eventsRoot === self$$1) { + global$9(elm).off(); + } + var lookup = self$$1.getRoot().controlIdLookup; + if (lookup) { + delete lookup[self$$1._id]; + } + if (elm && elm.parentNode) { + elm.parentNode.removeChild(elm); + } + self$$1.state.set('rendered', false); + self$$1.state.destroy(); + self$$1.fire('remove'); + return self$$1; + }, + 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$$1 = this; + var settings = self$$1.settings; + var elm, box, parent$$1, name$$1, parentEventsRoot; + self$$1.$el = global$9(self$$1.getEl()); + self$$1.state.set('rendered', true); + for (name$$1 in settings) { + if (name$$1.indexOf('on') === 0) { + self$$1.on(name$$1.substr(2), settings[name$$1]); + } + } + if (self$$1._eventsRoot) { + for (parent$$1 = self$$1.parent(); !parentEventsRoot && parent$$1; parent$$1 = parent$$1.parent()) { + parentEventsRoot = parent$$1._eventsRoot; + } + if (parentEventsRoot) { + for (name$$1 in parentEventsRoot._nativeEvents) { + self$$1._nativeEvents[name$$1] = true; + } + } + } + bindPendingEvents(self$$1); + if (settings.style) { + elm = self$$1.getEl(); + if (elm) { + elm.setAttribute('style', settings.style); + elm.style.cssText = settings.style; + } + } + if (self$$1.settings.border) { + box = self$$1.borderBox; + self$$1.$el.css({ + 'border-top-width': box.top, + 'border-right-width': box.right, + 'border-bottom-width': box.bottom, + 'border-left-width': box.left }); - global$9(self.getEl('body')).on('scroll', repaintScroll); } - repaintScroll(); - } - } - }; - - var Panel = Container.extend({ - Defaults: { - layout: 'fit', - containerCls: 'panel' - }, - Mixins: [$_3rxloyuzjjgwefrs], - 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); + var root = self$$1.getRoot(); + if (!root.controlIdLookup) { + root.controlIdLookup = {}; } - self._hasBody = false; + root.controlIdLookup[self$$1._id] = self$$1; + for (var key in self$$1._aria) { + self$$1.aria(key, self$$1._aria[key]); + } + if (self$$1.state.get('visible') === false) { + self$$1.getEl().style.display = 'none'; + } + self$$1.bindStates(); + self$$1.state.on('change:visible', function (e) { + var state = e.value; + var parentCtrl; + if (self$$1.state.get('rendered')) { + self$$1.getEl().style.display = state === false ? 'none' : ''; + self$$1.getEl().getBoundingClientRect(); + } + parentCtrl = self$$1.parent(); + if (parentCtrl) { + parentCtrl._lastRect = null; + } + self$$1.fire(state ? 'show' : 'hide'); + ReflowQueue.add(self$$1); + }); + self$$1.fire('postrender', {}, false); + }, + bindStates: function () { + }, + scrollIntoView: function (align) { + function getOffset(elm, rootElm) { + var x, y, parent$$1 = elm; + x = y = 0; + while (parent$$1 && parent$$1 !== rootElm && parent$$1.nodeType) { + x += parent$$1.offsetLeft || 0; + y += parent$$1.offsetTop || 0; + parent$$1 = parent$$1.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$$1 = this.parent(); + if (parent$$1 && parent$$1._layout && !parent$$1._layout.isNative()) { + parent$$1.reflow(); + } + return this; } - return '
' + (self._preBodyHtml || '') + innerHtml + '
'; - } - }); - - var $_3m7770v1jjgwefrz = { - 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; + }; + global$2.each('text title visible disabled active value'.split(' '), function (name$$1) { + proto$1[name$$1] = function (value) { + if (arguments.length === 0) { + return this.state.get(name$$1); + } + if (typeof value !== 'undefined') { + this.state.set(name$$1, 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$$1, state) { + if (state && global$b.isNative(name$$1)) { + if (!obj._nativeEvents) { + obj._nativeEvents = {}; + } + obj._nativeEvents[name$$1] = true; + if (obj.state.get('rendered')) { + bindPendingEvents(obj); + } + } + } + }); } - 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); + return obj._eventDispatcher; } - }; - - var documentClickHandler; - var documentScrollHandler; - var windowResizeHandler; - var visiblePanels = []; - var zOrder = []; - var hasModal; - function isChildOf(ctrl, parent$$1) { - while (ctrl) { - if (ctrl === parent$$1) { - return true; + function bindPendingEvents(eventCtrl) { + var i, l, parents, eventRootCtrl, nativeEvents, name$$1; + function delegate(e) { + var control = eventCtrl.getParentCtrl(e.target); + if (control) { + control.fire(e.type, e); + } } - 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) { + 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$$1 in nativeEvents) { + if (!nativeEvents) { + return false; + } + if (name$$1 === 'wheel' && !hasWheelEventSupport) { + if (hasMouseWheelEventSupport) { + global$9(eventCtrl.getEl()).on('mousewheel', fixWheelEvent); + } else { + global$9(eventCtrl.getEl()).on('DOMMouseScroll', fixWheelEvent); + } continue; } - } - e = panel.fire('autohide', { target: e.target }); - if (!e.isDefaultPrevented()) { - panel.hide(); + if (name$$1 === 'mouseenter' || name$$1 === 'mouseleave') { + if (!eventRootCtrl._hasMouseEnter) { + global$9(eventRootCtrl.getEl()).on('mouseleave', mouseLeaveHandler).on('mouseover', mouseEnterHandler); + eventRootCtrl._hasMouseEnter = 1; + } + } else if (!eventRootDelegates[name$$1]) { + global$9(eventRootCtrl.getEl()).on(name$$1, delegate); + eventRootDelegates[name$$1] = true; + } + nativeEvents[name$$1] = false; } } } - } - function bindDocumentClickHandler() { - if (!documentClickHandler) { - documentClickHandler = function (e) { - if (e.button === 2) { + 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 = document.activeElement; + } catch (ex) { + focusedElement = 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$$1 = elm || focusedElement; + while (parent$$1 = parent$$1.parentNode) { + if (role = getRole(parent$$1)) { + return role; + } + } + } + function getAriaProp(name$$1) { + var elm = focusedElement; + if (isElement(elm)) { + return elm.getAttribute('aria-' + name$$1); + } + } + 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; } - skipOrHidePanels(e); - }; - global$9(document).on('click touchstart', documentClickHandler); + 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 }; } - } - function bindDocumentScrollHandler() { - if (!documentScrollHandler) { - documentScrollHandler = function () { - var i; - i = visiblePanels.length; + + 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--) { - repositionPanel(visiblePanels[i]); + if (items[i] === oldItem) { + items[i] = newItem; + break; + } } - }; - global$9(window).on('scroll', documentScrollHandler); - } - } - function bindWindowResizeHandler() { - if (!windowResizeHandler) { - var docElm_1 = document.documentElement; - var clientWidth_1 = docElm_1.clientWidth, clientHeight_1 = docElm_1.clientHeight; - windowResizeHandler = function () { - if (!document.all || clientWidth_1 !== docElm_1.clientWidth || clientHeight_1 !== docElm_1.clientHeight) { - clientWidth_1 = docElm_1.clientWidth; - clientHeight_1 = docElm_1.clientHeight; - FloatPanel.hideAll(); + if (i >= 0) { + ctrlElm = newItem.getEl(); + if (ctrlElm) { + ctrlElm.parentNode.removeChild(ctrlElm); + } + ctrlElm = oldItem.getEl(); + if (ctrlElm) { + ctrlElm.parentNode.removeChild(ctrlElm); + } } - }; - global$9(window).on('resize', windowResizeHandler); - } - } - function repositionPanel(panel) { - var scrollY$$1 = funcs.getViewPort().y; - function toggleFixedChildPanels(fixed, deltaY) { - var parent$$1; - for (var i = 0; i < visiblePanels.length; i++) { - if (visiblePanels[i] !== panel) { - parent$$1 = visiblePanels[i].parent(); - while (parent$$1 && (parent$$1 = parent$$1.parent())) { - if (parent$$1 === panel) { - visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint(); + 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 || document; + var downButton; + var start, stop$$1, 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 (window.getComputedStyle) { + cursor = 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$$1); + settings.start(e); + }; + drag = function (e) { + updateWithTouchData(e); + if (e.button !== downButton) { + return stop$$1(e); + } + e.deltaX = e.screenX - startX; + e.deltaY = e.screenY - startY; + e.preventDefault(); + settings.drag(e); + }; + stop$$1 = function (e) { + updateWithTouchData(e); + global$9(doc).off('mousemove touchmove', drag).off('mouseup touchend', stop$$1); + $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$$1) { + while (ctrl) { + if (ctrl === parent$$1) { + 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(); } } } } - if (panel.settings.autofix) { - if (!panel.state.get('fixed')) { - panel._autoFixY = panel.layoutRect().y; - if (panel._autoFixY < scrollY$$1) { - panel.fixed(true).layoutRect({ y: 0 }).repaint(); - toggleFixedChildPanels(true, scrollY$$1 - panel._autoFixY); + function bindDocumentClickHandler() { + if (!documentClickHandler) { + documentClickHandler = function (e) { + if (e.button === 2) { + return; + } + skipOrHidePanels(e); + }; + global$9(document).on('click touchstart', documentClickHandler); + } + } + function bindDocumentScrollHandler() { + if (!documentScrollHandler) { + documentScrollHandler = function () { + var i; + i = visiblePanels.length; + while (i--) { + repositionPanel(visiblePanels[i]); + } + }; + global$9(window).on('scroll', documentScrollHandler); + } + } + function bindWindowResizeHandler() { + if (!windowResizeHandler) { + var docElm_1 = document.documentElement; + var clientWidth_1 = docElm_1.clientWidth, clientHeight_1 = docElm_1.clientHeight; + windowResizeHandler = function () { + if (!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(window).on('resize', windowResizeHandler); + } + } + function repositionPanel(panel) { + var scrollY$$1 = funcs.getViewPort().y; + function toggleFixedChildPanels(fixed, deltaY) { + var parent$$1; + for (var i = 0; i < visiblePanels.length; i++) { + if (visiblePanels[i] !== panel) { + parent$$1 = visiblePanels[i].parent(); + while (parent$$1 && (parent$$1 = parent$$1.parent())) { + if (parent$$1 === panel) { + visiblePanels[i].fixed(fixed).moveBy(0, deltaY).repaint(); + } + } + } } - } else { - if (panel._autoFixY > scrollY$$1) { - panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint(); - toggleFixedChildPanels(false, panel._autoFixY - scrollY$$1); + } + if (panel.settings.autofix) { + if (!panel.state.get('fixed')) { + panel._autoFixY = panel.layoutRect().y; + if (panel._autoFixY < scrollY$$1) { + panel.fixed(true).layoutRect({ y: 0 }).repaint(); + toggleFixedChildPanels(true, scrollY$$1 - panel._autoFixY); + } + } else { + if (panel._autoFixY > scrollY$$1) { + panel.fixed(false).layoutRect({ y: panel._autoFixY }).repaint(); + toggleFixedChildPanels(false, panel._autoFixY - scrollY$$1); + } } } } - } - function addRemove(add, ctrl) { - var i, zIndex = FloatPanel.zIndex || 65535, topModal; - if (add) { - zOrder.push(ctrl); - } else { + 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$$1 = this; + self$$1._super(settings); + self$$1._eventsRoot = self$$1; + self$$1.classes.add('floatpanel'); + if (settings.autohide) { + bindDocumentClickHandler(); + bindWindowResizeHandler(); + visiblePanels.push(self$$1); + } + if (settings.autofix) { + bindDocumentScrollHandler(); + self$$1.on('move', function () { + repositionPanel(this); + }); + } + self$$1.on('postrender show', function (e) { + if (e.control === self$$1) { + var $modalBlockEl_1; + var prefix_1 = self$$1.classPrefix; + if (self$$1.modal && !hasModal) { + $modalBlockEl_1 = global$9('#' + prefix_1 + 'modal-block', self$$1.getContainerElm()); + if (!$modalBlockEl_1[0]) { + $modalBlockEl_1 = global$9('
').appendTo(self$$1.getContainerElm()); + } + global$7.setTimeout(function () { + $modalBlockEl_1.addClass(prefix_1 + 'in'); + global$9(self$$1.getEl()).addClass(prefix_1 + 'in'); + }); + hasModal = true; + } + addRemove(true, self$$1); + } + }); + self$$1.on('show', function () { + self$$1.parents().each(function (ctrl) { + if (ctrl.state.get('fixed')) { + self$$1.fixed(true); + return false; + } + }); + }); + if (settings.popover) { + self$$1._preBodyHtml = '
'; + self$$1.classes.add('popover').add('bottom').add(self$$1.isRtl() ? 'end' : 'start'); + } + self$$1.aria('label', settings.ariaLabel); + self$$1.aria('labelledby', self$$1._id); + self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); + }, + fixed: function (state) { + var self$$1 = this; + if (self$$1.state.get('fixed') !== state) { + if (self$$1.state.get('rendered')) { + var viewport = funcs.getViewPort(); + if (state) { + self$$1.layoutRect().y -= viewport.y; + } else { + self$$1.layoutRect().y += viewport.y; + } + } + self$$1.classes.toggle('fixed', state); + self$$1.state.set('fixed', state); + } + return self$$1; + }, + show: function () { + var self$$1 = this; + var i; + var state = self$$1._super(); + i = visiblePanels.length; + while (i--) { + if (visiblePanels[i] === self$$1) { + break; + } + } + if (i === -1) { + visiblePanels.push(self$$1); + } + return state; + }, + hide: function () { + removeVisiblePanel(this); + addRemove(false, this); + return this._super(); + }, + hideAll: function () { + FloatPanel.hideAll(); + }, + close: function () { + var self$$1 = this; + if (!self$$1.fire('close').isDefaultPrevented()) { + self$$1.remove(); + addRemove(false, self$$1); + } + return self$$1; + }, + remove: function () { + removeVisiblePanel(this); + this._super(); + }, + postRender: function () { + var self$$1 = this; + if (self$$1.settings.bodyRole) { + this.getEl('body').setAttribute('role', self$$1.settings.bodyRole); + } + return self$$1._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] === ctrl) { + if (zOrder[i] === panel) { 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: [ - $_3fnh5iukjjgwefpt, - $_3m7770v1jjgwefrz - ], - init: function (settings) { - var self$$1 = this; - self$$1._super(settings); - self$$1._eventsRoot = self$$1; - self$$1.classes.add('floatpanel'); - if (settings.autohide) { - bindDocumentClickHandler(); - bindWindowResizeHandler(); - visiblePanels.push(self$$1); - } - if (settings.autofix) { - bindDocumentScrollHandler(); - self$$1.on('move', function () { - repositionPanel(this); - }); - } - self$$1.on('postrender show', function (e) { - if (e.control === self$$1) { - var $modalBlockEl_1; - var prefix_1 = self$$1.classPrefix; - if (self$$1.modal && !hasModal) { - $modalBlockEl_1 = global$9('#' + prefix_1 + 'modal-block', self$$1.getContainerElm()); - if (!$modalBlockEl_1[0]) { - $modalBlockEl_1 = global$9('
').appendTo(self$$1.getContainerElm()); - } - global$7.setTimeout(function () { - $modalBlockEl_1.addClass(prefix_1 + 'in'); - global$9(self$$1.getEl()).addClass(prefix_1 + 'in'); - }); - hasModal = true; - } - addRemove(true, self$$1); - } - }); - self$$1.on('show', function () { - self$$1.parents().each(function (ctrl) { - if (ctrl.state.get('fixed')) { - self$$1.fixed(true); - return false; - } - }); - }); - if (settings.popover) { - self$$1._preBodyHtml = '
'; - self$$1.classes.add('popover').add('bottom').add(self$$1.isRtl() ? 'end' : 'start'); - } - self$$1.aria('label', settings.ariaLabel); - self$$1.aria('labelledby', self$$1._id); - self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); - }, - fixed: function (state) { - var self$$1 = this; - if (self$$1.state.get('fixed') !== state) { - if (self$$1.state.get('rendered')) { - var viewport = funcs.getViewPort(); - if (state) { - self$$1.layoutRect().y -= viewport.y; - } else { - self$$1.layoutRect().y += viewport.y; - } - } - self$$1.classes.toggle('fixed', state); - self$$1.state.set('fixed', state); - } - return self$$1; - }, - show: function () { - var self$$1 = this; - var i; - var state = self$$1._super(); - i = visiblePanels.length; - while (i--) { - if (visiblePanels[i] === self$$1) { - break; - } - } - if (i === -1) { - visiblePanels.push(self$$1); - } - return state; - }, - hide: function () { - removeVisiblePanel(this); - addRemove(false, this); - return this._super(); - }, - hideAll: function () { - FloatPanel.hideAll(); - }, - close: function () { - var self$$1 = this; - if (!self$$1.fire('close').isDefaultPrevented()) { - self$$1.remove(); - addRemove(false, self$$1); - } - return self$$1; - }, - remove: function () { - removeVisiblePanel(this); - this._super(); - }, - postRender: function () { - var self$$1 = this; - if (self$$1.settings.bodyRole) { - this.getEl('body').setAttribute('role', self$$1.settings.bodyRole); - } - return self$$1._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 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 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); + + 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(); } - 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 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 hide = function () { - if (panel) { - panel.hide(); - FloatPanel.hideAll(); - DOM.removeClass(editor.getBody(), 'mce-edit-focus'); + 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 ''; + }, + 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 render = function () { - if (panel) { - if (!panel.visible()) { - show(); + }); + + 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 '
' + '
' + '
' + '
' + '
0%
' + '
'; + }, + 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 = ''; + } + if (self.progressBar) { + progressBar = self.progressBar.renderHtml(); + } + return ''; + }, + 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; } - 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: isFixed$1(inlineToolbarContainer, editor), - fixed: isFixed$1(inlineToolbarContainer, editor), - border: 1, - items: [ - hasMenubar(editor) === false ? null : { - type: 'menubar', - border: '0 0 1 0', - items: $_bahgsqu8jjgwefo4.createMenuButtons(editor) - }, - $_4udolhu7jjgwefo1.createToolbars(editor, getToolbarSize(editor)) - ] - }); - $_6344qfu4jjgwefnr.setUiContainer(editor, panel); - $_5hpmustzjjgwefnb.fireBeforeRenderUI(editor); - if (inlineToolbarContainer) { - panel.renderTo(inlineToolbarContainer).reflow(); - } else { - panel.renderTo().reflow(); + if (!viewport) { + viewport = document.createElement('meta'); + viewport.setAttribute('name', 'viewport'); + document.getElementsByTagName('head')[0].appendChild(viewport); } - $_azwbz4u0jjgwefnc.addKeys(editor, panel); - show(); - $_g1gegqu1jjgwefne.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(); + contentValue = viewport.getAttribute('content'); + if (contentValue && typeof oldMetaValue !== 'undefined') { + oldMetaValue = contentValue; } - }); - 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, $_awdosmuejjgwefop.fireSkinLoaded(editor)); - } else { - $_awdosmuejjgwefop.fireSkinLoaded(editor)(); + viewport.setAttribute('content', state ? noScaleMetaValue : oldMetaValue); } - return {}; - }; - var $_fuoldxufjjgwefor = { 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(); - } + function toggleBodyFullScreenClasses(classPrefix, state) { + if (checkFullscreenWindows() && state === false) { + global$9([ + document.documentElement, + document.body + ]).removeClass(classPrefix + 'fullscreen'); + } + } + function checkFullscreenWindows() { + for (var i = 0; i < windows.length; i++) { + if (windows[i]._fullscreen) { + return true; } } - 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 $_18iiwkv2jjgwefs0 = { 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'); + return false; } - $_18iiwkv2jjgwefs0.setup(editor, theme); - return isInline(editor) ? $_fuoldxufjjgwefor.render(editor, theme, args) : $_vxdgetvjjgwefn7.render(editor, theme, args); - }; - var $_as4c3qtrjjgwefn1 = { renderUI: renderUI }; - - var Tooltip = Control$1.extend({ - Mixins: [$_3fnh5iukjjgwefpt], - Defaults: { classes: 'widget tooltip tooltip-n' }, - renderHtml: function () { - var self = this, prefix = self.classPrefix; - return ''; - }, - 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' }); - $_6344qfu4jjgwefnr.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); + function handleWindowResize() { + if (!global$8.desktop) { + var lastSize_1 = { + w: window.innerWidth, + h: window.innerHeight }; - } - }, - renderHtml: function () { - var self = this, id = self._id, prefix = this.classPrefix; - return '
' + '
' + '
' + '
' + '
0%
' + '
'; - }, - 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: [$_3fnh5iukjjgwefpt], - 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 = ''; - } - if (self.progressBar) { - progressBar = self.progressBar.renderHtml(); - } - return ''; - }, - 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'); + global$7.setInterval(function () { + var w = window.innerWidth, h = window.innerHeight; + if (lastSize_1.w !== w || lastSize_1.h !== h) { + lastSize_1 = { + w: w, + h: h + }; + global$9(window).trigger('resize'); } - }); + }, 100); } - }; - 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); + 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)); + } } - 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; + global$9(window).on('resize', reposition); } - if (!viewport) { - viewport = document.createElement('meta'); - viewport.setAttribute('name', 'viewport'); - 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([ - document.documentElement, - 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: window.innerWidth, - h: window.innerHeight - }; - global$7.setInterval(function () { - var w = window.innerWidth, h = window.innerHeight; - if (lastSize_1.w !== w || lastSize_1.h !== h) { - lastSize_1 = { - w: w, - h: h - }; - global$9(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(window).on('resize', reposition); - } - var Window$$1 = 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$$1 = this; - self$$1._super(settings); - if (self$$1.isRtl()) { - self$$1.classes.add('rtl'); - } - self$$1.classes.add('window'); - self$$1.bodyClasses.add('window-body'); - self$$1.state.set('fixed', true); - if (settings.buttons) { - self$$1.statusbar = new Panel({ - layout: 'flex', - border: '1 0 0 0', - spacing: 3, - padding: 10, - align: 'center', - pack: self$$1.isRtl() ? 'start' : 'end', - defaults: { type: 'button' }, - items: settings.buttons - }); - self$$1.statusbar.classes.add('foot'); - self$$1.statusbar.parent(self$$1); - } - self$$1.on('click', function (e) { - var closeClass = self$$1.classPrefix + 'close'; - if (funcs.hasClass(e.target, closeClass) || funcs.hasClass(e.target.parentNode, closeClass)) { - self$$1.close(); - } - }); - self$$1.on('cancel', function () { - self$$1.close(); - }); - self$$1.on('move', function (e) { - if (e.control === self$$1) { - FloatPanel.hideAll(); - } - }); - self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); - self$$1.aria('label', settings.title); - self$$1._fullscreen = false; - }, - recalc: function () { - var self$$1 = this; - var statusbar$$1 = self$$1.statusbar; - var layoutRect, width, x, needsRecalc; - if (self$$1._fullscreen) { - self$$1.layoutRect(funcs.getWindowSize()); - self$$1.layoutRect().contentH = self$$1.layoutRect().innerH; - } - self$$1._super(); - layoutRect = self$$1.layoutRect(); - if (self$$1.settings.title && !self$$1._fullscreen) { - width = layoutRect.headerW; - if (width > layoutRect.w) { - x = layoutRect.x - Math.max(0, width / 2); - self$$1.layoutRect({ - w: width, - x: x - }); - needsRecalc = true; - } - } - if (statusbar$$1) { - statusbar$$1.layoutRect({ w: self$$1.layoutRect().innerW }).recalc(); - width = statusbar$$1.layoutRect().minW + layoutRect.deltaW; - if (width > layoutRect.w) { - x = layoutRect.x - Math.max(0, width - layoutRect.w); - self$$1.layoutRect({ - w: width, - x: x - }); - needsRecalc = true; - } - } - if (needsRecalc) { - self$$1.recalc(); - } - }, - initLayoutRect: function () { - var self$$1 = this; - var layoutRect = self$$1._super(); - var deltaH = 0, headEl; - if (self$$1.settings.title && !self$$1._fullscreen) { - headEl = self$$1.getEl('head'); - var size = funcs.getSize(headEl); - layoutRect.headerW = size.width; - layoutRect.headerH = size.height; - deltaH += layoutRect.headerH; - } - if (self$$1.statusbar) { - deltaH += self$$1.statusbar.layoutRect().h; - } - layoutRect.deltaH += deltaH; - layoutRect.minH += deltaH; - layoutRect.h += deltaH; - var rect = funcs.getWindowSize(); - layoutRect.x = self$$1.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2); - layoutRect.y = self$$1.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2); - return layoutRect; - }, - renderHtml: function () { - var self$$1 = this, layout = self$$1._layout, id = self$$1._id, prefix = self$$1.classPrefix; - var settings = self$$1.settings; - var headerHtml = '', footerHtml = '', html = settings.html; - self$$1.preRender(); - layout.preRender(self$$1); - if (settings.title) { - headerHtml = '
' + '
' + self$$1.encode(settings.title) + '
' + '
' + '' + '
'; - } - if (settings.url) { - html = ''; - } - if (typeof html === 'undefined') { - html = layout.renderHtml(self$$1); - } - if (self$$1.statusbar) { - footerHtml = self$$1.statusbar.renderHtml(); - } - return '
' + '
' + headerHtml + '
' + html + '
' + footerHtml + '
' + '
'; - }, - fullscreen: function (state) { - var self$$1 = this; - var documentElement = document.documentElement; - var slowRendering; - var prefix = self$$1.classPrefix; - var layoutRect; - if (state !== self$$1._fullscreen) { - global$9(window).on('resize', function () { - var time; - if (self$$1._fullscreen) { - if (!slowRendering) { - time = new Date().getTime(); - var rect = funcs.getWindowSize(); - self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); - if (new Date().getTime() - time > 50) { - slowRendering = true; - } - } else { - if (!self$$1._timer) { - self$$1._timer = global$7.setTimeout(function () { - var rect = funcs.getWindowSize(); - self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); - self$$1._timer = 0; - }, 50); - } - } - } - }); - layoutRect = self$$1.layoutRect(); - self$$1._fullscreen = state; - if (!state) { - self$$1.borderBox = $_fbr241uqjjgwefqo.parseBox(self$$1.settings.border); - self$$1.getEl('head').style.display = ''; - layoutRect.deltaH += layoutRect.headerH; - global$9([ - documentElement, - document.body - ]).removeClass(prefix + 'fullscreen'); - self$$1.classes.remove('fullscreen'); - self$$1.moveTo(self$$1._initial.x, self$$1._initial.y).resizeTo(self$$1._initial.w, self$$1._initial.h); - } else { - self$$1._initial = { - x: layoutRect.x, - y: layoutRect.y, - w: layoutRect.w, - h: layoutRect.h - }; - self$$1.borderBox = $_fbr241uqjjgwefqo.parseBox('0'); - self$$1.getEl('head').style.display = 'none'; - layoutRect.deltaH -= layoutRect.headerH + 2; - global$9([ - documentElement, - document.body - ]).addClass(prefix + 'fullscreen'); - self$$1.classes.add('fullscreen'); - var rect = funcs.getWindowSize(); - self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); - } - } - return self$$1.reflow(); - }, - postRender: function () { - var self$$1 = this; - var startPos; - setTimeout(function () { - self$$1.classes.add('in'); - self$$1.fire('open'); - }, 0); - self$$1._super(); - if (self$$1.statusbar) { - self$$1.statusbar.postRender(); - } - self$$1.focus(); - this.dragHelper = new DragHelper(self$$1._id + '-dragh', { - start: function () { - startPos = { - x: self$$1.layoutRect().x, - y: self$$1.layoutRect().y - }; - }, - drag: function (e) { - self$$1.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY); - } - }); - self$$1.on('submit', function (e) { - if (!e.isDefaultPrevented()) { - self$$1.close(); - } - }); - windows.push(self$$1); - toggleFullScreenState(true); - }, - submit: function () { - return this.fire('submit', { data: this.toJSON() }); - }, - remove: function () { - var self$$1 = this; - var i; - self$$1.dragHelper.destroy(); - self$$1._super(); - if (self$$1.statusbar) { - this.statusbar.remove(); - } - toggleBodyFullScreenClasses(self$$1.classPrefix, false); - i = windows.length; - while (i--) { - if (windows[i] === self$$1) { - 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$$1.extend({ - init: function (settings) { - settings = { + var Window$$1 = FloatPanel.extend({ + modal: true, + Defaults: { 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$$1, primary) { - return { - type: 'button', - text: text, - subtype: primary ? 'primary' : '', - onClick: function (e) { - e.control.parents()[1].close(); - callback(status$$1); - } - }; - } - 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)); + role: 'dialog', + callbacks: { + submit: function () { + this.fire('submit', { data: this.toJSON() }); + }, + close: function () { + this.close(); } - break; - default: - buttons = [createButton('Ok', true, true)]; - break; } - return new Window$$1({ + }, + init: function (settings) { + var self$$1 = this; + self$$1._super(settings); + if (self$$1.isRtl()) { + self$$1.classes.add('rtl'); + } + self$$1.classes.add('window'); + self$$1.bodyClasses.add('window-body'); + self$$1.state.set('fixed', true); + if (settings.buttons) { + self$$1.statusbar = new Panel({ + layout: 'flex', + border: '1 0 0 0', + spacing: 3, + padding: 10, + align: 'center', + pack: self$$1.isRtl() ? 'start' : 'end', + defaults: { type: 'button' }, + items: settings.buttons + }); + self$$1.statusbar.classes.add('foot'); + self$$1.statusbar.parent(self$$1); + } + self$$1.on('click', function (e) { + var closeClass = self$$1.classPrefix + 'close'; + if (funcs.hasClass(e.target, closeClass) || funcs.hasClass(e.target.parentNode, closeClass)) { + self$$1.close(); + } + }); + self$$1.on('cancel', function () { + self$$1.close(); + }); + self$$1.on('move', function (e) { + if (e.control === self$$1) { + FloatPanel.hideAll(); + } + }); + self$$1.aria('describedby', self$$1.describedBy || self$$1._id + '-none'); + self$$1.aria('label', settings.title); + self$$1._fullscreen = false; + }, + recalc: function () { + var self$$1 = this; + var statusbar$$1 = self$$1.statusbar; + var layoutRect, width, x, needsRecalc; + if (self$$1._fullscreen) { + self$$1.layoutRect(funcs.getWindowSize()); + self$$1.layoutRect().contentH = self$$1.layoutRect().innerH; + } + self$$1._super(); + layoutRect = self$$1.layoutRect(); + if (self$$1.settings.title && !self$$1._fullscreen) { + width = layoutRect.headerW; + if (width > layoutRect.w) { + x = layoutRect.x - Math.max(0, width / 2); + self$$1.layoutRect({ + w: width, + x: x + }); + needsRecalc = true; + } + } + if (statusbar$$1) { + statusbar$$1.layoutRect({ w: self$$1.layoutRect().innerW }).recalc(); + width = statusbar$$1.layoutRect().minW + layoutRect.deltaW; + if (width > layoutRect.w) { + x = layoutRect.x - Math.max(0, width - layoutRect.w); + self$$1.layoutRect({ + w: width, + x: x + }); + needsRecalc = true; + } + } + if (needsRecalc) { + self$$1.recalc(); + } + }, + initLayoutRect: function () { + var self$$1 = this; + var layoutRect = self$$1._super(); + var deltaH = 0, headEl; + if (self$$1.settings.title && !self$$1._fullscreen) { + headEl = self$$1.getEl('head'); + var size = funcs.getSize(headEl); + layoutRect.headerW = size.width; + layoutRect.headerH = size.height; + deltaH += layoutRect.headerH; + } + if (self$$1.statusbar) { + deltaH += self$$1.statusbar.layoutRect().h; + } + layoutRect.deltaH += deltaH; + layoutRect.minH += deltaH; + layoutRect.h += deltaH; + var rect = funcs.getWindowSize(); + layoutRect.x = self$$1.settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2); + layoutRect.y = self$$1.settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2); + return layoutRect; + }, + renderHtml: function () { + var self$$1 = this, layout = self$$1._layout, id = self$$1._id, prefix = self$$1.classPrefix; + var settings = self$$1.settings; + var headerHtml = '', footerHtml = '', html = settings.html; + self$$1.preRender(); + layout.preRender(self$$1); + if (settings.title) { + headerHtml = '
' + '
' + self$$1.encode(settings.title) + '
' + '
' + '' + '
'; + } + if (settings.url) { + html = ''; + } + if (typeof html === 'undefined') { + html = layout.renderHtml(self$$1); + } + if (self$$1.statusbar) { + footerHtml = self$$1.statusbar.renderHtml(); + } + return '
' + '
' + headerHtml + '
' + html + '
' + footerHtml + '
' + '
'; + }, + fullscreen: function (state) { + var self$$1 = this; + var documentElement = document.documentElement; + var slowRendering; + var prefix = self$$1.classPrefix; + var layoutRect; + if (state !== self$$1._fullscreen) { + global$9(window).on('resize', function () { + var time; + if (self$$1._fullscreen) { + if (!slowRendering) { + time = new Date().getTime(); + var rect = funcs.getWindowSize(); + self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); + if (new Date().getTime() - time > 50) { + slowRendering = true; + } + } else { + if (!self$$1._timer) { + self$$1._timer = global$7.setTimeout(function () { + var rect = funcs.getWindowSize(); + self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); + self$$1._timer = 0; + }, 50); + } + } + } + }); + layoutRect = self$$1.layoutRect(); + self$$1._fullscreen = state; + if (!state) { + self$$1.borderBox = BoxUtils.parseBox(self$$1.settings.border); + self$$1.getEl('head').style.display = ''; + layoutRect.deltaH += layoutRect.headerH; + global$9([ + documentElement, + document.body + ]).removeClass(prefix + 'fullscreen'); + self$$1.classes.remove('fullscreen'); + self$$1.moveTo(self$$1._initial.x, self$$1._initial.y).resizeTo(self$$1._initial.w, self$$1._initial.h); + } else { + self$$1._initial = { + x: layoutRect.x, + y: layoutRect.y, + w: layoutRect.w, + h: layoutRect.h + }; + self$$1.borderBox = BoxUtils.parseBox('0'); + self$$1.getEl('head').style.display = 'none'; + layoutRect.deltaH -= layoutRect.headerH + 2; + global$9([ + documentElement, + document.body + ]).addClass(prefix + 'fullscreen'); + self$$1.classes.add('fullscreen'); + var rect = funcs.getWindowSize(); + self$$1.moveTo(0, 0).resizeTo(rect.w, rect.h); + } + } + return self$$1.reflow(); + }, + postRender: function () { + var self$$1 = this; + var startPos; + setTimeout(function () { + self$$1.classes.add('in'); + self$$1.fire('open'); + }, 0); + self$$1._super(); + if (self$$1.statusbar) { + self$$1.statusbar.postRender(); + } + self$$1.focus(); + this.dragHelper = new DragHelper(self$$1._id + '-dragh', { + start: function () { + startPos = { + x: self$$1.layoutRect().x, + y: self$$1.layoutRect().y + }; + }, + drag: function (e) { + self$$1.moveTo(startPos.x + e.deltaX, startPos.y + e.deltaY); + } + }); + self$$1.on('submit', function (e) { + if (!e.isDefaultPrevented()) { + self$$1.close(); + } + }); + windows.push(self$$1); + toggleFullScreenState(true); + }, + submit: function () { + return this.fire('submit', { data: this.toJSON() }); + }, + remove: function () { + var self$$1 = this; + var i; + self$$1.dragHelper.destroy(); + self$$1._super(); + if (self$$1.statusbar) { + this.statusbar.remove(); + } + toggleBodyFullScreenClasses(self$$1.classPrefix, false); + i = windows.length; + while (i--) { + if (windows[i] === self$$1) { + 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$$1.extend({ + init: function (settings) { + settings = { + border: 1, 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', + containerCls: 'panel', + autoScroll: true, + buttons: { + type: 'button', + text: 'Ok', + action: 'ok' + }, 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); + maxHeight: 200 } - }).renderTo(document.body).reflow(); + }; + this._super(settings); }, - 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$$1 = 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$$1(args); - win.on('close', function () { - closeCallback(win); - }); - if (args.data) { - win.on('postRender', function () { - this.find('*').each(function (ctrl) { - var name$$1 = ctrl.name(); - if (name$$1 in args.data) { - ctrl.value(args.data[name$$1]); - } - }); - }); - } - win.features = args || {}; - win.params = params || {}; - win = win.renderTo(document.body).reflow(); - return win; - }; - var alert$$1 = function (message, choiceCallback, closeCallback) { - var win; - win = MessageBox.alert(message, function () { - choiceCallback(); - }); - win.on('close', function () { - closeCallback(win); - }); - return win; - }; - var confirm$$1 = function (message, choiceCallback, closeCallback) { - var win; - win = MessageBox.confirm(message, function (state) { - choiceCallback(state); - }); - win.on('close', function () { - closeCallback(win); - }); - return win; - }; - var close$$1 = function (window$$1) { - window$$1.close(); - }; - var getParams = function (window$$1) { - return window$$1.params; - }; - var setParams = function (window$$1, params) { - window$$1.params = params; - }; - return { - open: open$$1, - alert: alert$$1, - confirm: confirm$$1, - close: close$$1, - getParams: getParams, - setParams: setParams - }; - } - - var get = function (editor) { - var renderUI = function (args) { - return $_as4c3qtrjjgwefn1.renderUI(editor, this, args); - }; - var resizeTo = function (w, h) { - return $_sd6u0ubjjgwefok.resizeTo(editor, w, h); - }; - var resizeBy = function (dw, dh) { - return $_sd6u0ubjjgwefok.resizeBy(editor, dw, dh); - }; - var getNotificationManagerImpl = function () { - return NotificationManagerImpl(editor); - }; - var getWindowManagerImpl = function () { - return WindowManagerImpl(editor); - }; - return { - renderUI: renderUI, - resizeTo: resizeTo, - resizeBy: resizeBy, - getNotificationManagerImpl: getNotificationManagerImpl, - getWindowManagerImpl: getWindowManagerImpl - }; - }; - var $_buaxbttqjjgwefn0 = { get: get }; - - var Layout = global$10.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$$1 = this; - var size; - self$$1._super(settings); - settings = self$$1.settings; - size = self$$1.settings.size; - self$$1.on('click mousedown', function (e) { - e.preventDefault(); - }); - self$$1.on('touchstart', function (e) { - self$$1.fire('click', e); - e.preventDefault(); - }); - if (settings.subtype) { - self$$1.classes.add(settings.subtype); - } - if (size) { - self$$1.classes.add('btn-' + size); - } - if (settings.icon) { - self$$1.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$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; - var icon = self$$1.state.get('icon'), image; - var text = self$$1.state.get('text'); - var textHtml = ''; - var ariaPressed; - var settings = self$$1.settings; - image = settings.image; - if (image) { - icon = 'none'; - if (typeof image !== 'string') { - image = window.getSelection ? image[0] : image[1]; - } - image = ' style="background-image: url(\'' + image + '\')"'; - } else { - image = ''; - } - if (text) { - self$$1.classes.add('btn-has-text'); - textHtml = '' + self$$1.encode(text) + ''; - } - icon = icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; - ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; - return '
' + '' + '
'; - }, - bindStates: function () { - var self$$1 = this, $ = self$$1.$, textCls = self$$1.classPrefix + 'txt'; - function setButtonText(text) { - var $span = $('span.' + textCls, self$$1.getEl()); - if (text) { - if (!$span[0]) { - $('button:first', self$$1.getEl()).append(''); - $span = $('span.' + textCls, self$$1.getEl()); - } - $span.html(self$$1.encode(text)); - } else { - $span.remove(); - } - self$$1.classes.toggle('btn-has-text', !!text); - } - self$$1.state.on('change:text', function (e) { - setButtonText(e.value); - }); - self$$1.state.on('change:icon', function (e) { - var icon = e.value; - var prefix = self$$1.classPrefix; - self$$1.settings.icon = icon; - icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; - var btnElm = self$$1.getEl().firstChild; - var iconElm = btnElm.getElementsByTagName('i')[0]; - if (icon) { - if (!iconElm || iconElm !== btnElm.firstChild) { - iconElm = document.createElement('i'); - btnElm.insertBefore(iconElm, btnElm.firstChild); - } - iconElm.className = icon; - } else if (iconElm) { - btnElm.removeChild(iconElm); - } - setButtonText(self$$1.state.get('text')); - }); - return self$$1._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', function (e) { - e.stopPropagation(); - input.click(); - }); - 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$$1 = this; - self$$1._super(settings); - self$$1.on('click mousedown', function (e) { - e.preventDefault(); - }); - self$$1.on('click', function (e) { - e.preventDefault(); - if (!self$$1.disabled()) { - self$$1.checked(!self$$1.checked()); - } - }); - self$$1.checked(self$$1.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$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; - return '
' + '' + '' + self$$1.encode(self$$1.state.get('text')) + '' + '
'; - }, - bindStates: function () { - var self$$1 = this; - function checked(state) { - self$$1.classes.toggle('checked', state); - self$$1.aria('checked', state); - } - self$$1.state.on('change:text', function (e) { - self$$1.getEl('al').firstChild.data = self$$1.translate(e.value); - }); - self$$1.state.on('change:checked change:value', function (e) { - self$$1.fire('change'); - checked(e.value); - }); - self$$1.state.on('change:icon', function (e) { - var icon = e.value; - var prefix = self$$1.classPrefix; - if (typeof icon === 'undefined') { - return self$$1.settings.icon; - } - self$$1.settings.icon = icon; - icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; - var btnElm = self$$1.getEl().firstChild; - var iconElm = btnElm.getElementsByTagName('i')[0]; - if (icon) { - if (!iconElm || iconElm !== btnElm.firstChild) { - iconElm = document.createElement('i'); - btnElm.insertBefore(iconElm, btnElm.firstChild); - } - iconElm.className = icon; - } else if (iconElm) { - btnElm.removeChild(iconElm); - } - }); - if (self$$1.state.get('checked')) { - checked(true); - } - return self$$1._super(); - } - }); - - var global$13 = tinymce.util.Tools.resolve('tinymce.util.VK'); - - var ComboBox = Widget.extend({ - init: function (settings) { - var self$$1 = this; - self$$1._super(settings); - settings = self$$1.settings; - self$$1.classes.add('combobox'); - self$$1.subinput = true; - self$$1.ariaTarget = 'inp'; - settings.menu = settings.menu || settings.values; - if (settings.menu) { - settings.icon = 'caret'; - } - self$$1.on('click', function (e) { - var elm = e.target; - var root = self$$1.getEl(); - if (!global$9.contains(root, elm) && elm !== root) { - return; - } - while (elm && elm !== root) { - if (elm.id && elm.id.indexOf('-open') !== -1) { - self$$1.fire('action'); - if (settings.menu) { - self$$1.showMenu(); - if (e.aria) { - self$$1.menu.items()[0].focus(); - } - } - } - elm = elm.parentNode; - } - }); - self$$1.on('keydown', function (e) { - var rootControl; - if (e.keyCode === 13 && e.target.nodeName === 'INPUT') { - e.preventDefault(); - self$$1.parents().reverse().each(function (ctrl) { - if (ctrl.toJSON) { - rootControl = ctrl; - return false; - } - }); - self$$1.fire('submit', { data: rootControl.toJSON() }); - } - }); - self$$1.on('keyup', function (e) { - if (e.target.nodeName === 'INPUT') { - var oldValue = self$$1.state.get('value'); - var newValue = e.target.value; - if (newValue !== oldValue) { - self$$1.state.set('value', newValue); - self$$1.fire('autocomplete', e); - } - } - }); - self$$1.on('mouseover', function (e) { - var tooltip = self$$1.tooltip().moveTo(-65535); - if (self$$1.statusLevel() && e.target.className.indexOf(self$$1.classPrefix + 'status') !== -1) { - var statusMessage = self$$1.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$$1 = this; - var settings = self$$1.settings; - var menu; - if (!self$$1.menu) { - menu = settings.menu || []; - if (menu.length) { - menu = { - type: 'menu', - items: menu + Statics: { + OK: 1, + OK_CANCEL: 2, + YES_NO: 3, + YES_NO_CANCEL: 4, + msgBox: function (settings) { + var buttons; + var callback = settings.callback || function () { }; - } else { - menu.type = menu.type || 'menu'; - } - self$$1.menu = global$4.create(menu).parent(self$$1).renderTo(self$$1.getContainerElm()); - self$$1.fire('createmenu'); - self$$1.menu.reflow(); - self$$1.menu.on('cancel', function (e) { - if (e.control === self$$1.menu) { - self$$1.focus(); - } - }); - self$$1.menu.on('show hide', function (e) { - e.control.items().each(function (ctrl) { - ctrl.active(ctrl.value() === self$$1.value()); - }); - }).fire('show'); - self$$1.menu.on('select', function (e) { - self$$1.value(e.control.value()); - }); - self$$1.on('focusin', function (e) { - if (e.target.tagName.toUpperCase() === 'INPUT') { - self$$1.menu.hide(); - } - }); - self$$1.aria('expanded', true); - } - self$$1.menu.show(); - self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); - self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ - 'br-tr', - 'tr-br' - ] : [ - 'bl-tl', - 'tl-bl' - ]); - }, - focus: function () { - this.getEl('inp').focus(); - }, - repaint: function () { - var self$$1 = this, elm = self$$1.getEl(), openElm = self$$1.getEl('open'), rect = self$$1.layoutRect(); - var width, lineHeight, innerPadding = 0; - var inputElm = elm.firstChild; - if (self$$1.statusLevel() && self$$1.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 = document; - if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) { - lineHeight = self$$1.layoutRect().h - 2 + 'px'; - } - global$9(inputElm).css({ - width: width - innerPadding, - lineHeight: lineHeight - }); - self$$1._super(); - return self$$1; - }, - postRender: function () { - var self$$1 = this; - global$9(this.getEl('inp')).on('change', function (e) { - self$$1.state.set('value', e.target.value); - self$$1.fire('change', e); - }); - return self$$1._super(); - }, - renderHtml: function () { - var self$$1 = this, id = self$$1._id, settings = self$$1.settings, prefix = self$$1.classPrefix; - var value = self$$1.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$$1.disabled()) { - extraAttrs += ' disabled="disabled"'; - } - icon = settings.icon; - if (icon && icon !== 'caret') { - icon = prefix + 'ico ' + prefix + 'i-' + settings.icon; - } - text = self$$1.state.get('text'); - if (icon || text) { - openBtnHtml = '
' + '' + '
'; - self$$1.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$$1 = this; - if (items.length === 0) { - self$$1.hideMenu(); - return; - } - var insert = function (value, title) { - return function () { - self$$1.fire('selectitem', { - title: title, - value: value - }); - }; - }; - if (self$$1.menu) { - self$$1.menu.items().remove(); - } else { - self$$1.menu = global$4.create({ - type: 'menu', - classes: 'combobox-menu', - layout: 'flow' - }).parent(self$$1).renderTo(); - } - global$2.each(items, function (item) { - self$$1.menu.add({ - text: item.title, - url: item.previewUrl, - match: term, - classes: 'menu-item-ellipsis', - onclick: insert(item.value, item.title) - }); - }); - self$$1.menu.renderNew(); - self$$1.hideMenu(); - self$$1.menu.on('cancel', function (e) { - if (e.control.parent() === self$$1.menu) { - e.stopPropagation(); - self$$1.focus(); - self$$1.hideMenu(); - } - }); - self$$1.menu.on('select', function () { - self$$1.focus(); - }); - var maxW = self$$1.layoutRect().w; - self$$1.menu.layoutRect({ - w: maxW, - minW: 0, - maxW: maxW - }); - self$$1.menu.repaint(); - self$$1.menu.reflow(); - self$$1.menu.show(); - self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ - 'br-tr', - 'tr-br' - ] : [ - 'bl-tl', - 'tl-bl' - ]); - }, - hideMenu: function () { - if (this.menu) { - this.menu.hide(); - } - }, - bindStates: function () { - var self$$1 = this; - self$$1.state.on('change:value', function (e) { - if (self$$1.getEl('inp').value !== e.value) { - self$$1.getEl('inp').value = e.value; - } - }); - self$$1.state.on('change:disabled', function (e) { - self$$1.getEl('inp').disabled = e.value; - }); - self$$1.state.on('change:statusLevel', function (e) { - var statusIconElm = self$$1.getEl('status'); - var prefix = self$$1.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$$1.classes.toggle('has-status', value !== 'none'); - self$$1.repaint(); - }); - funcs.on(self$$1.getEl('status'), 'mouseleave', function () { - self$$1.tooltip().hide(); - }); - self$$1.on('cancel', function (e) { - if (self$$1.menu && self$$1.menu.visible()) { - e.stopPropagation(); - self$$1.hideMenu(); - } - }); - var focusIdx = function (idx, menu) { - if (menu && menu.items().length > 0) { - menu.items().eq(idx)[0].focus(); - } - }; - self$$1.on('keydown', function (e) { - var keyCode = e.keyCode; - if (e.target.nodeName === 'INPUT') { - if (keyCode === global$13.DOWN) { - e.preventDefault(); - self$$1.fire('autocomplete'); - focusIdx(0, self$$1.menu); - } else if (keyCode === global$13.UP) { - e.preventDefault(); - focusIdx(-1, self$$1.menu); - } - } - }); - return self$$1._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 '
' + '' + '' + '
'; - }, - 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$14 = 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$14({ - 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$14(); - } - 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 '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + hueHtml + '
'; - } - }); - - 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 ? '' : '') + '
' + 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] - }); + function createButton(text, status$$1, primary) { + return { + type: 'button', + text: text, + subtype: primary ? 'primary' : '', + onClick: function (e) { + e.control.parents()[1].close(); + callback(status$$1); } - 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 || document; - var div = doc.createElement('div'); - div.innerHTML = html; - if (!div.hasChildNodes() || div.childNodes.length > 1) { - console.error('HTML does not have a single root node', html); - throw 'HTML must have a single root node'; - } - return fromDom(div.childNodes[0]); - }; - var fromTag = function (tag, scope) { - var doc = scope || document; - var node = doc.createElement(tag); - return fromDom(node); - }; - var fromText = function (text, scope) { - var doc = scope || 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$$1 = { - 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 $_vi4lpw5jjgwefvz = { - ATTRIBUTE: Node.ATTRIBUTE_NODE, - CDATA_SECTION: Node.CDATA_SECTION_NODE, - COMMENT: Node.COMMENT_NODE, - DOCUMENT: Node.DOCUMENT_NODE, - DOCUMENT_TYPE: Node.DOCUMENT_TYPE_NODE, - DOCUMENT_FRAGMENT: Node.DOCUMENT_FRAGMENT_NODE, - ELEMENT: Node.ELEMENT_NODE, - TEXT: Node.TEXT_NODE, - PROCESSING_INSTRUCTION: Node.PROCESSING_INSTRUCTION_NODE, - ENTITY_REFERENCE: Node.ENTITY_REFERENCE_NODE, - ENTITY: Node.ENTITY_NODE, - NOTATION: Node.NOTATION_NODE - }; - - var name = function (element) { - var r = element.dom().nodeName; - return r.toLowerCase(); - }; - var type = function (element) { - return element.dom().nodeType; - }; - var value = function (element) { - return element.dom().nodeValue; - }; - var isType$1 = function (t) { - return function (element) { - return type(element) === t; - }; - }; - var isComment = function (element) { - return type(element) === $_vi4lpw5jjgwefvz.COMMENT || name(element) === '#comment'; - }; - var isElement = isType$1($_vi4lpw5jjgwefvz.ELEMENT); - var isText = isType$1($_vi4lpw5jjgwefvz.TEXT); - var isDocument = isType$1($_vi4lpw5jjgwefvz.DOCUMENT); - var $_8bzgjvw4jjgwefvy = { - name: name, - type: type, - value: value, - isElement: isElement, - isText: isText, - isDocument: isDocument, - isComment: isComment - }; - - var inBody = function (element) { - var dom = $_8bzgjvw4jjgwefvy.isText(element) ? element.dom().parentNode : element.dom(); - return dom !== undefined && dom !== null && dom.ownerDocument.body.contains(dom); - }; - var body = cached(function () { - return getBody(Element$$1.fromDom(document)); - }); - var getBody = function (doc) { - var body = doc.dom().body; - if (body === null || body === undefined) - throw 'Body is not available yet'; - return Element$$1.fromDom(body); - }; - var $_g7jljiw2jjgwefvu = { - body: body, - getBody: getBody, - inBody: inBody - }; - - 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 toArray = function (target, f) { - var r = []; - var recurse = function (e) { - r.push(e); - return f(e); - }; - var cur = f(target); - do { - cur = cur.bind(recurse); - } while (cur.isSome()); - return r; - }; - var $_5edc27wcjjgwefwz = { toArray: toArray }; - - var Global = typeof window !== 'undefined' ? 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 name + ' not available on this browser'; - return actual; - }; - var $_eggz6rwfjjgwefxb = { getOrDie: getOrDie }; - - var node = function () { - var f = $_eggz6rwfjjgwefxb.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 $_d3tk25wejjgwefxa = { - 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$2 = 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$2(versionRegexes, cleanedAgent); - }; - var unknown = function () { - return nu(0, 0); - }; - var nu = function (major, minor) { - return { - major: major, - minor: minor - }; - }; - var $_f8xw27wljjgwefxn = { - 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: $_f8xw27wljjgwefxn.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 $_6jz8s6wkjjgwefxk = { - 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: $_f8xw27wljjgwefxn.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 $_ac4rxfwmjjgwefxp = { - 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) - }; - - function DeviceType (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 = $_f8xw27wljjgwefxn.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 = $_f8xw27wljjgwefxn.detect(os.versionRegexes, userAgent); - return { - current: os.name, - version: version - }; - }); - }; - var $_d66zk7wojjgwefxw = { - detectBrowser: detectBrowser, - detectOs: detectOs - }; - - var contains$1 = function (str, substr) { - return str.indexOf(substr) !== -1; - }; - - var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; - var checkContains = function (target) { - return function (uastring) { - return contains$1(uastring, target); - }; - }; - var browsers = [ - { - name: 'Edge', - versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], - search: function (uastring) { - var monstrosity = contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit'); - return monstrosity; - } - }, - { - name: 'Chrome', - versionRegexes: [ - /.*?chrome\/([0-9]+)\.([0-9]+).*/, - normalVersionRegex - ], - search: function (uastring) { - return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe'); - } - }, - { - name: 'IE', - versionRegexes: [ - /.*?msie\ ?([0-9]+)\.([0-9]+).*/, - /.*?rv:([0-9]+)\.([0-9]+).*/ - ], - search: function (uastring) { - return contains$1(uastring, 'msie') || contains$1(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$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit'); - } - } - ]; - var oses = [ - { - name: 'Windows', - search: checkContains('win'), - versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] - }, - { - name: 'iOS', - search: function (uastring) { - return contains$1(uastring, 'iphone') || contains$1(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 $_frphugwpjjgwefy0 = { - browsers: constant(browsers), - oses: constant(oses) - }; - - var detect$2 = function (userAgent) { - var browsers = $_frphugwpjjgwefy0.browsers(); - var oses = $_frphugwpjjgwefy0.oses(); - var browser = $_d66zk7wojjgwefxw.detectBrowser(browsers, userAgent).fold($_6jz8s6wkjjgwefxk.unknown, $_6jz8s6wkjjgwefxk.nu); - var os = $_d66zk7wojjgwefxw.detectOs(oses, userAgent).fold($_ac4rxfwmjjgwefxp.unknown, $_ac4rxfwmjjgwefxp.nu); - var deviceType = DeviceType(os, browser, userAgent); - return { - browser: browser, - os: os, - deviceType: deviceType - }; - }; - var $_2lmz7fwjjjgwefxj = { detect: detect$2 }; - - var detect$3 = cached(function () { - var userAgent = navigator.userAgent; - return $_2lmz7fwjjjgwefxj.detect(userAgent); - }); - var $_3d6uczwijjgwefxg = { detect: detect$3 }; - - var ELEMENT = $_vi4lpw5jjgwefvz.ELEMENT; - var DOCUMENT = $_vi4lpw5jjgwefvz.DOCUMENT; - var is = function (element, selector) { - var elem = element.dom(); - if (elem.nodeType !== ELEMENT) - return false; - else if (elem.matches !== undefined) - return elem.matches(selector); - else if (elem.msMatchesSelector !== undefined) - return elem.msMatchesSelector(selector); - else if (elem.webkitMatchesSelector !== undefined) - return elem.webkitMatchesSelector(selector); - else if (elem.mozMatchesSelector !== undefined) - return elem.mozMatchesSelector(selector); - else - throw new Error('Browser lacks native selectors'); - }; - var bypassSelector = function (dom) { - return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT || dom.childElementCount === 0; - }; - var all = function (selector, scope) { - var base = scope === undefined ? document : scope.dom(); - return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element$$1.fromDom); - }; - var one = function (selector, scope) { - var base = scope === undefined ? document : scope.dom(); - return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element$$1.fromDom); - }; - var $_ofcqhwtjjgwefyb = { - all: all, - is: is, - one: one - }; - - var eq = function (e1, e2) { - return e1.dom() === e2.dom(); - }; - var isEqualNode = function (e1, e2) { - return e1.dom().isEqualNode(e2.dom()); - }; - var member = function (element, elements) { - return exists(elements, curry(eq, element)); - }; - var regularContains = function (e1, e2) { - var d1 = e1.dom(), d2 = e2.dom(); - return d1 === d2 ? false : d1.contains(d2); - }; - var ieContains = function (e1, e2) { - return $_d3tk25wejjgwefxa.documentPositionContainedBy(e1.dom(), e2.dom()); - }; - var browser = $_3d6uczwijjgwefxg.detect().browser; - var contains$2 = browser.isIE() ? ieContains : regularContains; - var $_bdbghwwdjjgwefx0 = { - eq: eq, - isEqualNode: isEqualNode, - member: member, - contains: contains$2, - is: $_ofcqhwtjjgwefyb.is - }; - - var owner = function (element) { - return Element$$1.fromDom(element.dom().ownerDocument); - }; - var documentElement = function (element) { - return Element$$1.fromDom(element.dom().ownerDocument.documentElement); - }; - var defaultView = function (element) { - var el = element.dom(); - var defaultView = el.ownerDocument.defaultView; - return Element$$1.fromDom(defaultView); - }; - var parent = function (element) { - var dom = element.dom(); - return Option.from(dom.parentNode).map(Element$$1.fromDom); - }; - var findIndex$1 = function (element) { - return parent(element).bind(function (p) { - var kin = children(p); - return findIndex(kin, function (elem) { - return $_bdbghwwdjjgwefx0.eq(element, elem); - }); - }); - }; - var parents = function (element, isRoot) { - var stop = isFunction(isRoot) ? isRoot : constant(false); - var dom = element.dom(); - var ret = []; - while (dom.parentNode !== null && dom.parentNode !== undefined) { - var rawParent = dom.parentNode; - var parent = Element$$1.fromDom(rawParent); - ret.push(parent); - if (stop(parent) === true) - break; - else - dom = rawParent; - } - return ret; - }; - var siblings = function (element) { - var filterSelf = function (elements) { - return filter(elements, function (x) { - return !$_bdbghwwdjjgwefx0.eq(element, x); - }); - }; - return parent(element).map(children).map(filterSelf).getOr([]); - }; - var offsetParent = function (element) { - var dom = element.dom(); - return Option.from(dom.offsetParent).map(Element$$1.fromDom); - }; - var prevSibling = function (element) { - var dom = element.dom(); - return Option.from(dom.previousSibling).map(Element$$1.fromDom); - }; - var nextSibling = function (element) { - var dom = element.dom(); - return Option.from(dom.nextSibling).map(Element$$1.fromDom); - }; - var prevSiblings = function (element) { - return reverse($_5edc27wcjjgwefwz.toArray(element, prevSibling)); - }; - var nextSiblings = function (element) { - return $_5edc27wcjjgwefwz.toArray(element, nextSibling); - }; - var children = function (element) { - var dom = element.dom(); - return map(dom.childNodes, Element$$1.fromDom); - }; - var child = function (element, index) { - var children = element.dom().childNodes; - return Option.from(children[index]).map(Element$$1.fromDom); - }; - var firstChild = function (element) { - return child(element, 0); - }; - var lastChild = function (element) { - return child(element, element.dom().childNodes.length - 1); - }; - var childNodesCount = function (element) { - return element.dom().childNodes.length; - }; - var hasChildNodes = function (element) { - return element.dom().hasChildNodes(); - }; - var spot = Immutable('element', 'offset'); - var leaf = function (element, offset) { - var cs = children(element); - return cs.length > 0 && offset < cs.length ? spot(cs[offset], 0) : spot(element, offset); - }; - var $_r7112w6jjgwefw2 = { - owner: owner, - defaultView: defaultView, - documentElement: documentElement, - parent: parent, - findIndex: findIndex$1, - parents: parents, - siblings: siblings, - prevSibling: prevSibling, - offsetParent: offsetParent, - prevSiblings: prevSiblings, - nextSibling: nextSibling, - nextSiblings: nextSiblings, - children: children, - child: child, - firstChild: firstChild, - lastChild: lastChild, - childNodesCount: childNodesCount, - hasChildNodes: hasChildNodes, - leaf: leaf - }; - - var all$1 = function (predicate) { - return descendants($_g7jljiw2jjgwefvu.body(), predicate); - }; - var ancestors = function (scope, predicate, isRoot) { - return filter($_r7112w6jjgwefw2.parents(scope, isRoot), predicate); - }; - var siblings$1 = function (scope, predicate) { - return filter($_r7112w6jjgwefw2.siblings(scope), predicate); - }; - var children$1 = function (scope, predicate) { - return filter($_r7112w6jjgwefw2.children(scope), predicate); - }; - var descendants = function (scope, predicate) { - var result = []; - each($_r7112w6jjgwefw2.children(scope), function (x) { - if (predicate(x)) { - result = result.concat([x]); - } - result = result.concat(descendants(x, predicate)); - }); - return result; - }; - var $_3dx616w1jjgwefvq = { - all: all$1, - ancestors: ancestors, - siblings: siblings$1, - children: children$1, - descendants: descendants - }; - - var all$2 = function (selector) { - return $_ofcqhwtjjgwefyb.all(selector); - }; - var ancestors$1 = function (scope, selector, isRoot) { - return $_3dx616w1jjgwefvq.ancestors(scope, function (e) { - return $_ofcqhwtjjgwefyb.is(e, selector); - }, isRoot); - }; - var siblings$2 = function (scope, selector) { - return $_3dx616w1jjgwefvq.siblings(scope, function (e) { - return $_ofcqhwtjjgwefyb.is(e, selector); - }); - }; - var children$2 = function (scope, selector) { - return $_3dx616w1jjgwefvq.children(scope, function (e) { - return $_ofcqhwtjjgwefyb.is(e, selector); - }); - }; - var descendants$1 = function (scope, selector) { - return $_ofcqhwtjjgwefyb.all(selector, scope); - }; - var $_5wsttjw0jjgwefvp = { - all: all$2, - ancestors: ancestors$1, - siblings: siblings$2, - children: children$2, - descendants: descendants$1 - }; - - var trim$1 = 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($_5wsttjw0jjgwefvp.descendants(Element$$1.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$1(target.title).length > 0; - }; - var find$3 = function (elm) { - var elms = getTargetElements(elm); - return filter(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle); - }; - var $_7cacckvxjjgwefv6 = { find: find$3 }; - - 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 = $_7cacckvxjjgwefv6.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; - } - }); - - function ClosestOrAncestor (is, ancestor, scope, a, isRoot) { - return is(scope, a) ? Option.some(scope) : isFunction(isRoot) && isRoot(scope) ? Option.none() : ancestor(scope, a, isRoot); - } - - var first$1 = function (predicate) { - return descendant($_g7jljiw2jjgwefvu.body(), predicate); - }; - var ancestor = function (scope, predicate, isRoot) { - var element = scope.dom(); - var stop = isFunction(isRoot) ? isRoot : constant(false); - while (element.parentNode) { - element = element.parentNode; - var el = Element$$1.fromDom(element); - if (predicate(el)) - return Option.some(el); - else if (stop(el)) - break; - } - return Option.none(); - }; - var closest = function (scope, predicate, isRoot) { - var is = function (scope) { - return predicate(scope); - }; - return ClosestOrAncestor(is, ancestor, scope, predicate, isRoot); - }; - var sibling = function (scope, predicate) { - var element = scope.dom(); - if (!element.parentNode) - return Option.none(); - return child$1(Element$$1.fromDom(element.parentNode), function (x) { - return !$_bdbghwwdjjgwefx0.eq(scope, x) && predicate(x); - }); - }; - var child$1 = function (scope, predicate) { - var result = find(scope.dom().childNodes, compose(predicate, Element$$1.fromDom)); - return result.map(Element$$1.fromDom); - }; - var descendant = function (scope, predicate) { - var descend = function (node) { - for (var i = 0; i < node.childNodes.length; i++) { - if (predicate(Element$$1.fromDom(node.childNodes[i]))) - return Option.some(Element$$1.fromDom(node.childNodes[i])); - var res = descend(node.childNodes[i]); - if (res.isSome()) - return res; - } - return Option.none(); - }; - return descend(scope.dom()); - }; - var $_2htnvowzjjgwefz5 = { - first: first$1, - ancestor: ancestor, - closest: closest, - sibling: sibling, - child: child$1, - descendant: descendant - }; - - var first$2 = function (selector) { - return $_ofcqhwtjjgwefyb.one(selector); - }; - var ancestor$1 = function (scope, selector, isRoot) { - return $_2htnvowzjjgwefz5.ancestor(scope, function (e) { - return $_ofcqhwtjjgwefyb.is(e, selector); - }, isRoot); - }; - var sibling$1 = function (scope, selector) { - return $_2htnvowzjjgwefz5.sibling(scope, function (e) { - return $_ofcqhwtjjgwefyb.is(e, selector); - }); - }; - var child$2 = function (scope, selector) { - return $_2htnvowzjjgwefz5.child(scope, function (e) { - return $_ofcqhwtjjgwefyb.is(e, selector); - }); - }; - var descendant$1 = function (scope, selector) { - return $_ofcqhwtjjgwefyb.one(selector, scope); - }; - var closest$1 = function (scope, selector, isRoot) { - return ClosestOrAncestor($_ofcqhwtjjgwefyb.is, ancestor$1, scope, selector, isRoot); - }; - var $_4ftvxwwyjjgwefz3 = { - first: first$2, - ancestor: ancestor$1, - sibling: sibling$1, - child: child$2, - descendant: descendant$1, - closest: closest$1 - }; - - 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); + 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)); } - }); - }); - } - }); - 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 $_cz4u4px1jjgwefzl = { 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 $_f7ngpex3jjgwefzo = { 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 $_9a6bd5x4jjgwefzr = { 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 $_ejzqp9x5jjgwefzu = { 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 $_fp0lmzx6jjgwefzy = { 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, menuItems) { - return !isSeparator$1(menuItem) || !isSeparator$1(menuItems[i - 1]); - }); - return filter(menuItems2, function (menuItem, i, menuItems) { - return !isSeparator$1(menuItem) || i > 0 && i < menuItems.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 $_4j2o4hx7jjgweg01 = { 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 $_c2lkymx8jjgweg05 = { 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 $_9h432jx9jjgweg07 = { 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 $_eoil5jxajjgweg09 = { 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 = $_4ftvxwwyjjgwefz3.descendant(Element$$1.fromDom(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', function () { - FloatPanel.hideAll(); - }); - }; - var setup$1 = function (editor) { - setupRtlMode(editor); - setupHideFloatPanels(editor); - setupUiContainer(editor); - setupEnvironment(); - $_fp0lmzx6jjgwefzy.register(editor); - $_cz4u4px1jjgwefzl.register(editor); - $_c2lkymx8jjgweg05.register(editor); - $_9h432jx9jjgweg07.register(editor); - $_9a6bd5x4jjgwefzr.register(editor); - $_f7ngpex3jjgwefzo.register(editor); - $_ejzqp9x5jjgwefzu.register(editor); - $_eoil5jxajjgweg09.register(editor); - $_4j2o4hx7jjgweg01.register(editor); - }; - var $_5heykgwxjjgwefyx = { 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; + default: + buttons = [createButton('Ok', true, true)]; 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]; + return new Window$$1({ + 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(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); } } - 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(); - } + }); + + function WindowManagerImpl (editor) { + var open$$1 = 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); } - 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]; + if (args.body) { + args.items = { + defaults: args.defaults, + type: args.bodyType || 'form', + items: args.body, + data: args.data, + callbacks: args.commands + }; } - } else { - totalFlex = cols; + 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$$1(args); + win.on('close', function () { + closeCallback(win); + }); + if (args.data) { + win.on('postRender', function () { + this.find('*').each(function (ctrl) { + var name$$1 = ctrl.name(); + if (name$$1 in args.data) { + ctrl.value(args.data[name$$1]); + } + }); + }); + } + win.features = args || {}; + win.params = params || {}; + win = win.renderTo(document.body).reflow(); + return win; + }; + var alert$$1 = function (message, choiceCallback, closeCallback) { + var win; + win = MessageBox.alert(message, function () { + choiceCallback(); + }); + win.on('close', function () { + closeCallback(win); + }); + return win; + }; + var confirm$$1 = function (message, choiceCallback, closeCallback) { + var win; + win = MessageBox.confirm(message, function (state) { + choiceCallback(state); + }); + win.on('close', function () { + closeCallback(win); + }); + return win; + }; + var close$$1 = function (window$$1) { + window$$1.close(); + }; + var getParams = function (window$$1) { + return window$$1.params; + }; + var setParams = function (window$$1, params) { + window$$1.params = params; + }; + return { + open: open$$1, + alert: alert$$1, + confirm: confirm$$1, + close: close$$1, + 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(editor); + }; + 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 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; + }); + + 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(); } - } - 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(); - } + }, + renderHtml: function (container) { + return '
' + this._super(container); } - 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 ''; - } - 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$$1) { - while (node) { - if (parent$$1 === node) { - return true; - } - node = node.parentNode; - } - return false; - } - var MenuButton = Button.extend({ - init: function (settings) { - var self$$1 = this; - self$$1._renderOpen = true; - self$$1._super(settings); - settings = self$$1.settings; - self$$1.classes.add('menubtn'); - if (settings.fixedWidth) { - self$$1.classes.add('fixed-width'); - } - self$$1.aria('haspopup', true); - self$$1.state.set('menu', settings.menu || self$$1.render()); - }, - showMenu: function (toggle) { - var self$$1 = this; - var menu; - if (self$$1.menu && self$$1.menu.visible() && toggle !== false) { - return self$$1.hideMenu(); - } - if (!self$$1.menu) { - menu = self$$1.state.get('menu') || []; - self$$1.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$$1.menu = global$4.create(menu).parent(self$$1).renderTo(); - } else { - self$$1.menu = menu.parent(self$$1).show().renderTo(); - } - self$$1.fire('createmenu'); - self$$1.menu.reflow(); - self$$1.menu.on('cancel', function (e) { - if (e.control.parent() === self$$1.menu) { - e.stopPropagation(); - self$$1.focus(); - self$$1.hideMenu(); - } - }); - self$$1.menu.on('select', function () { - self$$1.focus(); - }); - self$$1.menu.on('show hide', function (e) { - if (e.control === self$$1.menu) { - self$$1.activeMenu(e.type === 'show'); - self$$1.classes.toggle('opened', e.type === 'show'); - } - self$$1.aria('expanded', e.type === 'show'); - }).fire('show'); - } - self$$1.menu.show(); - self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); - self$$1.menu.repaint(); - self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ - 'br-tr', - 'tr-br' - ] : [ - 'bl-tl', - 'tl-bl' - ]); - self$$1.fire('showmenu'); - }, - hideMenu: function () { - var self$$1 = this; - if (self$$1.menu) { - self$$1.menu.items().each(function (item) { - if (item.hideMenu) { - item.hideMenu(); - } - }); - self$$1.menu.hide(); - } - }, - activeMenu: function (state) { - this.classes.toggle('active', state); - }, - renderHtml: function () { - var self$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; - var icon = self$$1.settings.icon, image; - var text = self$$1.state.get('text'); - var textHtml = ''; - image = self$$1.settings.image; - if (image) { - icon = 'none'; - if (typeof image !== 'string') { - image = window.getSelection ? image[0] : image[1]; - } - image = ' style="background-image: url(\'' + image + '\')"'; - } else { - image = ''; - } - if (text) { - self$$1.classes.add('btn-has-text'); - textHtml = '' + self$$1.encode(text) + ''; - } - icon = self$$1.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; - self$$1.aria('role', self$$1.parent() instanceof MenuBar ? 'menuitem' : 'button'); - return '
' + '' + '
'; - }, - postRender: function () { - var self$$1 = this; - self$$1.on('click', function (e) { - if (e.control === self$$1 && isChildOf$1(e.target, self$$1.getEl())) { - self$$1.focus(); - self$$1.showMenu(!e.aria); - if (e.aria) { - self$$1.menu.items().filter(':visible')[0].focus(); - } - } - }); - self$$1.on('mouseenter', function (e) { - var overCtrl = e.control; - var parent$$1 = self$$1.parent(); - var hasVisibleSiblingMenu; - if (overCtrl && parent$$1 && overCtrl instanceof MenuButton && overCtrl.parent() === parent$$1) { - parent$$1.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$$1._super(); - }, - bindStates: function () { - var self$$1 = this; - self$$1.state.on('change:menu', function () { - if (self$$1.menu) { - self$$1.menu.remove(); - } - self$$1.menu = null; - }); - return self$$1._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; - } - if (this.settings.values) { - var matchingValues = global$2.grep(this.settings.values, function (a) { - return a.value === value; - }); - if (matchingValues.length > 0) { - 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 ? '
' + 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 += ''; - } - } - 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) { + var Button = Widget.extend({ + Defaults: { + classes: 'widget btn', + role: 'button' + }, + init: function (settings) { + var self$$1 = this; + var size; + self$$1._super(settings); + settings = self$$1.settings; + size = self$$1.settings.size; + self$$1.on('click mousedown', function (e) { e.preventDefault(); - self.parents().reverse().each(function (ctrl) { - if (ctrl.toJSON) { - rootControl = ctrl; - return false; + }); + self$$1.on('touchstart', function (e) { + self$$1.fire('click', e); + e.preventDefault(); + }); + if (settings.subtype) { + self$$1.classes.add(settings.subtype); + } + if (size) { + self$$1.classes.add('btn-' + size); + } + if (settings.icon) { + self$$1.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$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; + var icon = self$$1.state.get('icon'), image; + var text = self$$1.state.get('text'); + var textHtml = ''; + var ariaPressed; + var settings = self$$1.settings; + image = settings.image; + if (image) { + icon = 'none'; + if (typeof image !== 'string') { + image = window.getSelection ? image[0] : image[1]; + } + image = ' style="background-image: url(\'' + image + '\')"'; + } else { + image = ''; + } + if (text) { + self$$1.classes.add('btn-has-text'); + textHtml = '' + self$$1.encode(text) + ''; + } + icon = icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; + ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; + return '
' + '' + '
'; + }, + bindStates: function () { + var self$$1 = this, $ = self$$1.$, textCls = self$$1.classPrefix + 'txt'; + function setButtonText(text) { + var $span = $('span.' + textCls, self$$1.getEl()); + if (text) { + if (!$span[0]) { + $('button:first', self$$1.getEl()).append(''); + $span = $('span.' + textCls, self$$1.getEl()); } - }); - self.fire('submit', { data: rootControl.toJSON() }); + $span.html(self$$1.encode(text)); + } else { + $span.remove(); + } + self$$1.classes.toggle('btn-has-text', !!text); } - }); - }, - options: function (state) { - if (!arguments.length) { - return this.state.get('options'); + self$$1.state.on('change:text', function (e) { + setButtonText(e.value); + }); + self$$1.state.on('change:icon', function (e) { + var icon = e.value; + var prefix = self$$1.classPrefix; + self$$1.settings.icon = icon; + icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; + var btnElm = self$$1.getEl().firstChild; + var iconElm = btnElm.getElementsByTagName('i')[0]; + if (icon) { + if (!iconElm || iconElm !== btnElm.firstChild) { + iconElm = document.createElement('i'); + btnElm.insertBefore(iconElm, btnElm.firstChild); + } + iconElm.className = icon; + } else if (iconElm) { + btnElm.removeChild(iconElm); + } + setButtonText(self$$1.state.get('text')); + }); + return self$$1._super(); } - 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 ''; - }, - 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 }); + 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'); } - self.on('keydown', function (e) { - switch (e.keyCode) { - case 37: - case 38: - alter(-1); - break; - case 39: - case 40: - alter(1); - break; + }, + 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', function (e) { + e.stopPropagation(); + input.click(); + }); + self.getEl().appendChild(input); + }, + remove: function () { + global$9(this.getEl('button')).off(); + global$9(this.getEl('input')).off(); + this._super(); } - 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 }); + }); + + 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$$1 = this; + self$$1._super(settings); + self$$1.on('click mousedown', function (e) { + e.preventDefault(); + }); + self$$1.on('click', function (e) { + e.preventDefault(); + if (!self$$1.disabled()) { + self$$1.checked(!self$$1.checked()); } }); - } - 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$$1 = this; - var elm = self$$1.getEl(); - var rect = self$$1.layoutRect(); - var mainButtonElm, menuButtonElm; - self$$1._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$$1; - }, - activeMenu: function (state) { - var self$$1 = this; - global$9(self$$1.getEl().lastChild).toggleClass(self$$1.classPrefix + 'active', state); - }, - renderHtml: function () { - var self$$1 = this; - var id = self$$1._id; - var prefix = self$$1.classPrefix; - var image; - var icon = self$$1.state.get('icon'); - var text = self$$1.state.get('text'); - var settings = self$$1.settings; - var textHtml = '', ariaPressed; - image = settings.image; - if (image) { - icon = 'none'; - if (typeof image !== 'string') { - image = window.getSelection ? image[0] : image[1]; + self$$1.checked(self$$1.settings.checked); + }, + checked: function (state) { + if (!arguments.length) { + return this.state.get('checked'); } - image = ' style="background-image: url(\'' + image + '\')"'; - } else { - image = ''; + this.state.set('checked', state); + return this; + }, + value: function (state) { + if (!arguments.length) { + return this.checked(); + } + return this.checked(state); + }, + renderHtml: function () { + var self$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; + return '
' + '' + '' + self$$1.encode(self$$1.state.get('text')) + '' + '
'; + }, + bindStates: function () { + var self$$1 = this; + function checked(state) { + self$$1.classes.toggle('checked', state); + self$$1.aria('checked', state); + } + self$$1.state.on('change:text', function (e) { + self$$1.getEl('al').firstChild.data = self$$1.translate(e.value); + }); + self$$1.state.on('change:checked change:value', function (e) { + self$$1.fire('change'); + checked(e.value); + }); + self$$1.state.on('change:icon', function (e) { + var icon = e.value; + var prefix = self$$1.classPrefix; + if (typeof icon === 'undefined') { + return self$$1.settings.icon; + } + self$$1.settings.icon = icon; + icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; + var btnElm = self$$1.getEl().firstChild; + var iconElm = btnElm.getElementsByTagName('i')[0]; + if (icon) { + if (!iconElm || iconElm !== btnElm.firstChild) { + iconElm = document.createElement('i'); + btnElm.insertBefore(iconElm, btnElm.firstChild); + } + iconElm.className = icon; + } else if (iconElm) { + btnElm.removeChild(iconElm); + } + }); + if (self$$1.state.get('checked')) { + checked(true); + } + return self$$1._super(); } - icon = settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; - if (text) { - self$$1.classes.add('btn-has-text'); - textHtml = '' + self$$1.encode(text) + ''; - } - ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; - return '
' + '' + '' + '
'; - }, - postRender: function () { - var self$$1 = this, onClickHandler = self$$1.settings.onclick; - self$$1.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); + }); + + var global$d = tinymce.util.Tools.resolve('tinymce.util.VK'); + + var ComboBox = Widget.extend({ + init: function (settings) { + var self$$1 = this; + self$$1._super(settings); + settings = self$$1.settings; + self$$1.classes.add('combobox'); + self$$1.subinput = true; + self$$1.ariaTarget = 'inp'; + settings.menu = settings.menu || settings.values; + if (settings.menu) { + settings.icon = 'caret'; + } + self$$1.on('click', function (e) { + var elm = e.target; + var root = self$$1.getEl(); + if (!global$9.contains(root, elm) && elm !== root) { + return; + } + while (elm && elm !== root) { + if (elm.id && elm.id.indexOf('-open') !== -1) { + self$$1.fire('action'); + if (settings.menu) { + self$$1.showMenu(); + if (e.aria) { + self$$1.menu.items()[0].focus(); + } } - return; } - node = node.parentNode; + elm = elm.parentNode; } - } - }); - delete self$$1.settings.onclick; - return self$$1._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 += ''; - }); - 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$$1 = this; - self$$1._super(settings); - self$$1.classes.add('textbox'); - if (settings.multiline) { - self$$1.classes.add('multiline'); - } else { self$$1.on('keydown', function (e) { var rootControl; - if (e.keyCode === 13) { + if (e.keyCode === 13 && e.target.nodeName === 'INPUT') { e.preventDefault(); self$$1.parents().reverse().each(function (ctrl) { if (ctrl.toJSON) { @@ -9832,210 +5142,4486 @@ var modern = (function () { } }); self$$1.on('keyup', function (e) { - self$$1.state.set('value', e.target.value); + if (e.target.nodeName === 'INPUT') { + var oldValue = self$$1.state.get('value'); + var newValue = e.target.value; + if (newValue !== oldValue) { + self$$1.state.set('value', newValue); + self$$1.fire('autocomplete', e); + } + } }); + self$$1.on('mouseover', function (e) { + var tooltip = self$$1.tooltip().moveTo(-65535); + if (self$$1.statusLevel() && e.target.className.indexOf(self$$1.classPrefix + 'status') !== -1) { + var statusMessage = self$$1.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$$1 = this; + var settings = self$$1.settings; + var menu; + if (!self$$1.menu) { + menu = settings.menu || []; + if (menu.length) { + menu = { + type: 'menu', + items: menu + }; + } else { + menu.type = menu.type || 'menu'; + } + self$$1.menu = global$4.create(menu).parent(self$$1).renderTo(self$$1.getContainerElm()); + self$$1.fire('createmenu'); + self$$1.menu.reflow(); + self$$1.menu.on('cancel', function (e) { + if (e.control === self$$1.menu) { + self$$1.focus(); + } + }); + self$$1.menu.on('show hide', function (e) { + e.control.items().each(function (ctrl) { + ctrl.active(ctrl.value() === self$$1.value()); + }); + }).fire('show'); + self$$1.menu.on('select', function (e) { + self$$1.value(e.control.value()); + }); + self$$1.on('focusin', function (e) { + if (e.target.tagName.toUpperCase() === 'INPUT') { + self$$1.menu.hide(); + } + }); + self$$1.aria('expanded', true); + } + self$$1.menu.show(); + self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); + self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ + 'br-tr', + 'tr-br' + ] : [ + 'bl-tl', + 'tl-bl' + ]); + }, + focus: function () { + this.getEl('inp').focus(); + }, + repaint: function () { + var self$$1 = this, elm = self$$1.getEl(), openElm = self$$1.getEl('open'), rect = self$$1.layoutRect(); + var width, lineHeight, innerPadding = 0; + var inputElm = elm.firstChild; + if (self$$1.statusLevel() && self$$1.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 = document; + if (doc.all && (!doc.documentMode || doc.documentMode <= 8)) { + lineHeight = self$$1.layoutRect().h - 2 + 'px'; + } + global$9(inputElm).css({ + width: width - innerPadding, + lineHeight: lineHeight + }); + self$$1._super(); + return self$$1; + }, + postRender: function () { + var self$$1 = this; + global$9(this.getEl('inp')).on('change', function (e) { + self$$1.state.set('value', e.target.value); + self$$1.fire('change', e); + }); + return self$$1._super(); + }, + renderHtml: function () { + var self$$1 = this, id = self$$1._id, settings = self$$1.settings, prefix = self$$1.classPrefix; + var value = self$$1.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$$1.disabled()) { + extraAttrs += ' disabled="disabled"'; + } + icon = settings.icon; + if (icon && icon !== 'caret') { + icon = prefix + 'ico ' + prefix + 'i-' + settings.icon; + } + text = self$$1.state.get('text'); + if (icon || text) { + openBtnHtml = '
' + '' + '
'; + self$$1.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$$1 = this; + if (items.length === 0) { + self$$1.hideMenu(); + return; + } + var insert = function (value, title) { + return function () { + self$$1.fire('selectitem', { + title: title, + value: value + }); + }; + }; + if (self$$1.menu) { + self$$1.menu.items().remove(); + } else { + self$$1.menu = global$4.create({ + type: 'menu', + classes: 'combobox-menu', + layout: 'flow' + }).parent(self$$1).renderTo(); + } + global$2.each(items, function (item) { + self$$1.menu.add({ + text: item.title, + url: item.previewUrl, + match: term, + classes: 'menu-item-ellipsis', + onclick: insert(item.value, item.title) + }); + }); + self$$1.menu.renderNew(); + self$$1.hideMenu(); + self$$1.menu.on('cancel', function (e) { + if (e.control.parent() === self$$1.menu) { + e.stopPropagation(); + self$$1.focus(); + self$$1.hideMenu(); + } + }); + self$$1.menu.on('select', function () { + self$$1.focus(); + }); + var maxW = self$$1.layoutRect().w; + self$$1.menu.layoutRect({ + w: maxW, + minW: 0, + maxW: maxW + }); + self$$1.menu.repaint(); + self$$1.menu.reflow(); + self$$1.menu.show(); + self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ + 'br-tr', + 'tr-br' + ] : [ + 'bl-tl', + 'tl-bl' + ]); + }, + hideMenu: function () { + if (this.menu) { + this.menu.hide(); + } + }, + bindStates: function () { + var self$$1 = this; + self$$1.state.on('change:value', function (e) { + if (self$$1.getEl('inp').value !== e.value) { + self$$1.getEl('inp').value = e.value; + } + }); + self$$1.state.on('change:disabled', function (e) { + self$$1.getEl('inp').disabled = e.value; + }); + self$$1.state.on('change:statusLevel', function (e) { + var statusIconElm = self$$1.getEl('status'); + var prefix = self$$1.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$$1.classes.toggle('has-status', value !== 'none'); + self$$1.repaint(); + }); + funcs.on(self$$1.getEl('status'), 'mouseleave', function () { + self$$1.tooltip().hide(); + }); + self$$1.on('cancel', function (e) { + if (self$$1.menu && self$$1.menu.visible()) { + e.stopPropagation(); + self$$1.hideMenu(); + } + }); + var focusIdx = function (idx, menu) { + if (menu && menu.items().length > 0) { + menu.items().eq(idx)[0].focus(); + } + }; + self$$1.on('keydown', function (e) { + var keyCode = e.keyCode; + if (e.target.nodeName === 'INPUT') { + if (keyCode === global$d.DOWN) { + e.preventDefault(); + self$$1.fire('autocomplete'); + focusIdx(0, self$$1.menu); + } else if (keyCode === global$d.UP) { + e.preventDefault(); + focusIdx(-1, self$$1.menu); + } + } + }); + return self$$1._super(); + }, + remove: function () { + global$9(this.getEl('inp')).off(); + if (this.menu) { + this.menu.remove(); + } + this._super(); } - }, - repaint: function () { - var self$$1 = this; - var style, rect, borderBox, borderW, borderH = 0, lastRepaintRect; - style = self$$1.getEl().style; - rect = self$$1._layoutRect; - lastRepaintRect = self$$1._lastRepaintRect || {}; - var doc = document; - if (!self$$1.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) { - style.lineHeight = rect.h - borderH + 'px'; + }); + + 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(); } - borderBox = self$$1.borderBox; - borderW = borderBox.left + borderBox.right + 8; - borderH = borderBox.top + borderBox.bottom + (self$$1.settings.multiline ? 8 : 0); - if (rect.x !== lastRepaintRect.x) { - style.left = rect.x + 'px'; - lastRepaintRect.x = rect.x; + }); + + 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(); } - 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$$1._lastRepaintRect = lastRepaintRect; - self$$1.fire('repaint', {}, false); - return self$$1; - }, - renderHtml: function () { - var self$$1 = this; - var settings = self$$1.settings; - var attrs, elm; - attrs = { - id: self$$1._id, - hidefocus: '1' - }; - global$2.each([ - 'rows', - 'spellcheck', - 'maxLength', - 'size', - 'readonly', - 'min', - 'max', - 'step', - 'list', - 'pattern', - 'placeholder', - 'required', - 'multiple' - ], function (name$$1) { - attrs[name$$1] = settings[name$$1]; - }); - if (self$$1.disabled()) { - attrs.disabled = 'disabled'; - } - if (settings.subtype) { - attrs.type = settings.subtype; - } - elm = funcs.create(settings.multiline ? 'textarea' : 'input', attrs); - elm.value = self$$1.state.get('value'); - elm.className = self$$1.classes.toString(); - return elm.outerHTML; - }, - value: function (value) { - if (arguments.length) { - this.state.set('value', value); + }); + + 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 '
' + '' + '' + '
'; + }, + 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(); } - if (this.state.get('rendered')) { - this.state.set('value', this.getEl().value); + }); + + 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 '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + hueHtml + '
'; } - return this.state.get('value'); - }, - postRender: function () { - var self$$1 = this; - self$$1.getEl().value = self$$1.state.get('value'); - self$$1._super(); - self$$1.$el.on('change', function (e) { - self$$1.state.set('value', e.target.value); - self$$1.fire('change', e); + }); + + 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 ? '' : '') + '
' + 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 || document; + var div = doc.createElement('div'); + div.innerHTML = html; + if (!div.hasChildNodes() || div.childNodes.length > 1) { + console.error('HTML does not have a single root node', html); + throw 'HTML must have a single root node'; + } + return fromDom(div.childNodes[0]); + }; + var fromTag = function (tag, scope) { + var doc = scope || document; + var node = doc.createElement(tag); + return fromDom(node); + }; + var fromText = function (text, scope) { + var doc = scope || 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$$1 = { + 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 = Node.ATTRIBUTE_NODE; + var CDATA_SECTION = Node.CDATA_SECTION_NODE; + var COMMENT = Node.COMMENT_NODE; + var DOCUMENT = Node.DOCUMENT_NODE; + var DOCUMENT_TYPE = Node.DOCUMENT_TYPE_NODE; + var DOCUMENT_FRAGMENT = Node.DOCUMENT_FRAGMENT_NODE; + var ELEMENT = Node.ELEMENT_NODE; + var TEXT = Node.TEXT_NODE; + var PROCESSING_INSTRUCTION = Node.PROCESSING_INSTRUCTION_NODE; + var ENTITY_REFERENCE = Node.ENTITY_REFERENCE_NODE; + var ENTITY = Node.ENTITY_NODE; + var NOTATION = 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 Global = typeof window !== 'undefined' ? 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 name + ' not available on this browser'; + return actual; + }; + var Global$1 = { getOrDie: getOrDie }; + + 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$1 = { + 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$2 = 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$2(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() }); - }, - bindStates: function () { - var self$$1 = this; - self$$1.state.on('change:value', function (e) { - if (self$$1.getEl().value !== e.value) { - self$$1.getEl().value = e.value; + }; + 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$1 = function (str, substr) { + return str.indexOf(substr) !== -1; + }; + + var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/; + var checkContains = function (target) { + return function (uastring) { + return contains$1(uastring, target); + }; + }; + var browsers = [ + { + name: 'Edge', + versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], + search: function (uastring) { + var monstrosity = contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit'); + return monstrosity; + } + }, + { + name: 'Chrome', + versionRegexes: [ + /.*?chrome\/([0-9]+)\.([0-9]+).*/, + normalVersionRegex + ], + search: function (uastring) { + return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe'); + } + }, + { + name: 'IE', + versionRegexes: [ + /.*?msie\ ?([0-9]+)\.([0-9]+).*/, + /.*?rv:([0-9]+)\.([0-9]+).*/ + ], + search: function (uastring) { + return contains$1(uastring, 'msie') || contains$1(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$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit'); + } + } + ]; + var oses = [ + { + name: 'Windows', + search: checkContains('win'), + versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] + }, + { + name: 'iOS', + search: function (uastring) { + return contains$1(uastring, 'iphone') || contains$1(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 = 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 ? document : scope.dom(); + return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element$$1.fromDom); + }; + var one = function (selector, scope) { + var base = scope === undefined ? document : scope.dom(); + return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element$$1.fromDom); + }; + + var regularContains = function (e1, e2) { + var d1 = e1.dom(), d2 = e2.dom(); + return d1 === d2 ? false : d1.contains(d2); + }; + var ieContains = function (e1, e2) { + return Node$1.documentPositionContainedBy(e1.dom(), e2.dom()); + }; + var browser = PlatformDetection$1.detect().browser; + var contains$2 = browser.isIE() ? ieContains : regularContains; + + var spot = Immutable('element', 'offset'); + + var descendants$1 = function (scope, selector) { + return all(selector, scope); + }; + + var trim$1 = 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$1(Element$$1.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$1(target.title).length > 0; + }; + var find$3 = function (elm) { + var elms = getTargetElements(elm); + return filter(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle); + }; + var LinkTargets = { find: find$3 }; + + 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(''); } }); - self$$1.state.on('change:disabled', function (e) { - self$$1.getEl().disabled = e.value; + ctrl.on('PostRender', function () { + ctrl.getRoot().on('submit', function (e) { + if (!e.isDefaultPrevented()) { + addToHistory(ctrl.value(), fileType); + } + }); }); - return self$$1._super(); - }, - remove: function () { - this.$el.off(); - this._super(); - } - }); - - var getApi = function () { - return { - Selector: Selector, - Collection: Collection$2, - ReflowQueue: $_p42hyuxjjgwefrk, - Control: Control$1, - Factory: global$4, - KeyboardNavigation: KeyboardNavigation, - Container: Container, - DragHelper: DragHelper, - Scrollable: $_3rxloyuzjjgwefrs, - Panel: Panel, - Movable: $_3fnh5iukjjgwefpt, - Resizable: $_3m7770v1jjgwefrz, - FloatPanel: FloatPanel, - Window: Window$$1, - 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: $_5heykgwxjjgwefyx, - 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 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 Api = { - appendTo: appendTo, - registerToFactory: registerToFactory - }; - Api.registerToFactory(); - Api.appendTo(window.tinymce ? window.tinymce : {}); - global.add('modern', function (editor) { - $_5heykgwxjjgwefyx.setup(editor); - return $_buaxbttqjjgwefn0.get(editor); - }); - function Theme () { - } + 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(); + } + }); + } + }); - return Theme; + 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$1 = 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, menuItems) { + return !isSeparator$1(menuItem) || !isSeparator$1(menuItems[i - 1]); + }); + return filter(menuItems2, function (menuItem, i, menuItems) { + return !isSeparator$1(menuItem) || i > 0 && i < menuItems.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$1(Element$$1.fromDom(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 ''; + } + 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$$1) { + while (node) { + if (parent$$1 === node) { + return true; + } + node = node.parentNode; + } + return false; + } + var MenuButton = Button.extend({ + init: function (settings) { + var self$$1 = this; + self$$1._renderOpen = true; + self$$1._super(settings); + settings = self$$1.settings; + self$$1.classes.add('menubtn'); + if (settings.fixedWidth) { + self$$1.classes.add('fixed-width'); + } + self$$1.aria('haspopup', true); + self$$1.state.set('menu', settings.menu || self$$1.render()); + }, + showMenu: function (toggle) { + var self$$1 = this; + var menu; + if (self$$1.menu && self$$1.menu.visible() && toggle !== false) { + return self$$1.hideMenu(); + } + if (!self$$1.menu) { + menu = self$$1.state.get('menu') || []; + self$$1.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$$1.menu = global$4.create(menu).parent(self$$1).renderTo(); + } else { + self$$1.menu = menu.parent(self$$1).show().renderTo(); + } + self$$1.fire('createmenu'); + self$$1.menu.reflow(); + self$$1.menu.on('cancel', function (e) { + if (e.control.parent() === self$$1.menu) { + e.stopPropagation(); + self$$1.focus(); + self$$1.hideMenu(); + } + }); + self$$1.menu.on('select', function () { + self$$1.focus(); + }); + self$$1.menu.on('show hide', function (e) { + if (e.type === 'hide' && e.control.parent() === self$$1) { + self$$1.classes.remove('opened-under'); + } + if (e.control === self$$1.menu) { + self$$1.activeMenu(e.type === 'show'); + self$$1.classes.toggle('opened', e.type === 'show'); + } + self$$1.aria('expanded', e.type === 'show'); + }).fire('show'); + } + self$$1.menu.show(); + self$$1.menu.layoutRect({ w: self$$1.layoutRect().w }); + self$$1.menu.repaint(); + self$$1.menu.moveRel(self$$1.getEl(), self$$1.isRtl() ? [ + 'br-tr', + 'tr-br' + ] : [ + 'bl-tl', + 'tl-bl' + ]); + var menuLayoutRect = self$$1.menu.layoutRect(); + var selfBottom = self$$1.$el.offset().top + self$$1.layoutRect().h; + if (selfBottom > menuLayoutRect.y && selfBottom < menuLayoutRect.y + menuLayoutRect.h) { + self$$1.classes.add('opened-under'); + } + self$$1.fire('showmenu'); + }, + hideMenu: function () { + var self$$1 = this; + if (self$$1.menu) { + self$$1.menu.items().each(function (item) { + if (item.hideMenu) { + item.hideMenu(); + } + }); + self$$1.menu.hide(); + } + }, + activeMenu: function (state) { + this.classes.toggle('active', state); + }, + renderHtml: function () { + var self$$1 = this, id = self$$1._id, prefix = self$$1.classPrefix; + var icon = self$$1.settings.icon, image; + var text = self$$1.state.get('text'); + var textHtml = ''; + image = self$$1.settings.image; + if (image) { + icon = 'none'; + if (typeof image !== 'string') { + image = window.getSelection ? image[0] : image[1]; + } + image = ' style="background-image: url(\'' + image + '\')"'; + } else { + image = ''; + } + if (text) { + self$$1.classes.add('btn-has-text'); + textHtml = '' + self$$1.encode(text) + ''; + } + icon = self$$1.settings.icon ? prefix + 'ico ' + prefix + 'i-' + icon : ''; + self$$1.aria('role', self$$1.parent() instanceof MenuBar ? 'menuitem' : 'button'); + return '
' + '' + '
'; + }, + postRender: function () { + var self$$1 = this; + self$$1.on('click', function (e) { + if (e.control === self$$1 && isChildOf$1(e.target, self$$1.getEl())) { + self$$1.focus(); + self$$1.showMenu(!e.aria); + if (e.aria) { + self$$1.menu.items().filter(':visible')[0].focus(); + } + } + }); + self$$1.on('mouseenter', function (e) { + var overCtrl = e.control; + var parent$$1 = self$$1.parent(); + var hasVisibleSiblingMenu; + if (overCtrl && parent$$1 && overCtrl instanceof MenuButton && overCtrl.parent() === parent$$1) { + parent$$1.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$$1._super(); + }, + bindStates: function () { + var self$$1 = this; + self$$1.state.on('change:menu', function () { + if (self$$1.menu) { + self$$1.menu.remove(); + } + self$$1.menu = null; + }); + return self$$1._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 ? '
' + 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 += ''; + } + } + 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 ''; + }, + 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$$1 = this; + var elm = self$$1.getEl(); + var rect = self$$1.layoutRect(); + var mainButtonElm, menuButtonElm; + self$$1._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$$1; + }, + activeMenu: function (state) { + var self$$1 = this; + global$9(self$$1.getEl().lastChild).toggleClass(self$$1.classPrefix + 'active', state); + }, + renderHtml: function () { + var self$$1 = this; + var id = self$$1._id; + var prefix = self$$1.classPrefix; + var image; + var icon = self$$1.state.get('icon'); + var text = self$$1.state.get('text'); + var settings = self$$1.settings; + var textHtml = '', ariaPressed; + image = settings.image; + if (image) { + icon = 'none'; + if (typeof image !== 'string') { + image = 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$$1.classes.add('btn-has-text'); + textHtml = '' + self$$1.encode(text) + ''; + } + ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; + return '
' + '' + '' + '
'; + }, + postRender: function () { + var self$$1 = this, onClickHandler = self$$1.settings.onclick; + self$$1.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$$1.settings.onclick; + return self$$1._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 += ''; + }); + 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$$1 = this; + self$$1._super(settings); + self$$1.classes.add('textbox'); + if (settings.multiline) { + self$$1.classes.add('multiline'); + } else { + self$$1.on('keydown', function (e) { + var rootControl; + if (e.keyCode === 13) { + e.preventDefault(); + self$$1.parents().reverse().each(function (ctrl) { + if (ctrl.toJSON) { + rootControl = ctrl; + return false; + } + }); + self$$1.fire('submit', { data: rootControl.toJSON() }); + } + }); + self$$1.on('keyup', function (e) { + self$$1.state.set('value', e.target.value); + }); + } + }, + repaint: function () { + var self$$1 = this; + var style, rect, borderBox, borderW, borderH = 0, lastRepaintRect; + style = self$$1.getEl().style; + rect = self$$1._layoutRect; + lastRepaintRect = self$$1._lastRepaintRect || {}; + var doc = document; + if (!self$$1.settings.multiline && doc.all && (!doc.documentMode || doc.documentMode <= 8)) { + style.lineHeight = rect.h - borderH + 'px'; + } + borderBox = self$$1.borderBox; + borderW = borderBox.left + borderBox.right + 8; + borderH = borderBox.top + borderBox.bottom + (self$$1.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$$1._lastRepaintRect = lastRepaintRect; + self$$1.fire('repaint', {}, false); + return self$$1; + }, + renderHtml: function () { + var self$$1 = this; + var settings = self$$1.settings; + var attrs, elm; + attrs = { + id: self$$1._id, + hidefocus: '1' + }; + global$2.each([ + 'rows', + 'spellcheck', + 'maxLength', + 'size', + 'readonly', + 'min', + 'max', + 'step', + 'list', + 'pattern', + 'placeholder', + 'required', + 'multiple' + ], function (name$$1) { + attrs[name$$1] = settings[name$$1]; + }); + if (self$$1.disabled()) { + attrs.disabled = 'disabled'; + } + if (settings.subtype) { + attrs.type = settings.subtype; + } + elm = funcs.create(settings.multiline ? 'textarea' : 'input', attrs); + elm.value = self$$1.state.get('value'); + elm.className = self$$1.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$$1 = this; + self$$1.getEl().value = self$$1.state.get('value'); + self$$1._super(); + self$$1.$el.on('change', function (e) { + self$$1.state.set('value', e.target.value); + self$$1.fire('change', e); + }); + }, + bindStates: function () { + var self$$1 = this; + self$$1.state.on('change:value', function (e) { + if (self$$1.getEl().value !== e.value) { + self$$1.getEl().value = e.value; + } + }); + self$$1.state.on('change:disabled', function (e) { + self$$1.getEl().disabled = e.value; + }); + return self$$1._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$$1, + 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; }()); })(); diff --git a/wp-includes/js/tinymce/themes/modern/theme.min.js b/wp-includes/js/tinymce/themes/modern/theme.min.js index a99bb703cb..b5461f6802 100644 --- a/wp-includes/js/tinymce/themes/modern/theme.min.js +++ b/wp-includes/js/tinymce/themes/modern/theme.min.js @@ -1 +1 @@ -!function(){"use strict";var e,t,n,i,r,o=tinymce.util.Tools.resolve("tinymce.ThemeManager"),h=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")},m=function(e){return e.getParam("menu")},g=function(e){return!1===e.settings.skin},p=function(e){var t=e.getParam("resize","vertical");return!1===t?"none":"both"===t?"both":"vertical"},v=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),b=tinymce.util.Tools.resolve("tinymce.ui.Factory"),y=tinymce.util.Tools.resolve("tinymce.util.I18n"),s=function(e){return e.fire("SkinLoaded")},x=function(e){return e.fire("ResizeEditor")},_=function(e){return e.fire("BeforeRenderUI")},a=function(t,n){return function(){var e=t.find(n)[0];e&&e.focus(!0)}},C=function(e,t){e.shortcuts.add("Alt+F9","",a(t,"menubar")),e.shortcuts.add("Alt+F10,F10","",a(t,"toolbar")),e.shortcuts.add("Alt+F11","",a(t,"elementpath")),t.on("cancel",function(){e.focus()})},R=tinymce.util.Tools.resolve("tinymce.geom.Rect"),u=tinymce.util.Tools.resolve("tinymce.util.Delay"),E=function(){for(var e=[],t=0;t ctrl+shift+p","",function(){var e=a(x.selection.getNode());e&&e.toolbar.panel&&e.toolbar.panel.items()[0].focus()})},Y=function(t){return function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&Array.prototype.isPrototypeOf(e)?"array":"object"===t&&String.prototype.isPrototypeOf(e)?"string":t}(e)===t}},$=Y("function"),X=Y("number"),q=(r=Array.prototype.indexOf)===undefined?function(e,t){return ee(e,t)}:function(e,t){return r.call(e,t)},j=function(e,t){return Q(e,t).isSome()},J=function(e,t){for(var n=e.length,i=new Array(n),r=0;rtinymce']),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 _(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&&be.setStyle(i.getEl(),"width",n.width),t.on("remove",function(){i.remove(),i=null}),C(t,i),V(t),{iframeContainer:i.find("#iframe")[0].getEl(),editorContainer:i.getEl()}},we=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),_e=0,Ce={id:function(){return"mceu_"+_e++},create:function(e,t,n){var i=document.createElement(e);return v.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 v.DOM.createFragment(e)},getWindowSize:function(){return v.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 v.DOM.getPos(e,t||Ce.getContainer())},getContainer:function(){return fe.container?fe.container:document.body},getViewPort:function(e){return v.DOM.getViewPort(e)},get:function(e){return document.getElementById(e)},addClass:function(e,t){return v.DOM.addClass(e,t)},removeClass:function(e,t){return v.DOM.removeClass(e,t)},hasClass:function(e,t){return v.DOM.hasClass(e,t)},toggleClass:function(e,t,n){return v.DOM.toggleClass(e,t,n)},css:function(e,t,n){return v.DOM.setStyle(e,t,n)},getRuntimeStyle:function(e,t){return v.DOM.getStyle(e,t,!0)},on:function(e,t,n,i){return v.DOM.bind(e,t,n,i)},off:function(e,t,n){return v.DOM.unbind(e,t,n)},fire:function(e,t,n){return v.DOM.fire(e,t,n)},innerHtml:function(e,t){v.DOM.setHTML(e,t)}},Re=function(e){return"static"===Ce.getRuntimeStyle(e,"position")},Ee=function(e){return e.state.get("fixed")};function ke(e,t,n){var i,r,o,s,a,l,u,c,d,f;return d=Te(),o=(r=Ce.getPos(t,O.getUiContainer(e))).x,s=r.y,Ee(e)&&Re(document.body)&&(o-=d.x,s-=d.y),i=e.getEl(),a=(f=Ce.getSize(i)).width,l=f.height,u=(f=Ce.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 Te=function(){var e=window,t=Math.max(e.pageXOffset,document.body.scrollLeft,document.documentElement.scrollLeft),n=Math.max(e.pageYOffset,document.body.scrollTop,document.documentElement.scrollTop);return{x:t,y:n,w:t+(e.innerWidth||document.documentElement.clientWidth),h:n+(e.innerHeight||document.documentElement.clientHeight)}},He=function(e){var t,n=O.getUiContainer(e);return n&&!Ee(e)?{x:0,y:0,w:(t=n).scrollWidth-1,h:t.scrollHeight-1}:Te()},Se={testMoveRel:function(e,t){for(var n=He(this),i=0;in.x&&r.x+r.wn.y&&r.y+r.h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,Fe=/^\s*|\s*$/g,Ue=Me.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=Ie.exec(e.replace(Fe,"")))[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(ze.exec(""),(i=ze.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=Ge.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,Ce.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 rt(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 rt(this).off(e,t),this},fire:function(e,t,n){if((t=t||{}).control||(t.control=this),t=rt(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 rt(this).has(e)},parents:function(e){var t,n=new $e;for(t=this.parent();t;t=t.parent())n.add(t);return e&&(n=n.filter(e)),n},parentsAndSelf:function(e){return new $e(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]=we("#"+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 Ge.translate?Ge.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&&we(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 we(e).before(this.renderHtml()),this.postRender(),this},renderTo:function(e){return we(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=we(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}ot(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"),Qe.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(){Qe.remove(this);var e=this.parent();return e&&e._layout&&!e._layout.isNative()&&e.reflow(),this}};function rt(n){return n._eventDispatcher||(n._eventDispatcher=new Ne({scope:n,toggleEvent:function(e,t){t&&Ne.isNative(e)&&(n._nativeEvents||(n._nativeEvents={}),n._nativeEvents[e]=!0,n.state.get("rendered")&&ot(n))}})),n._eventDispatcher}function ot(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=lt({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(Qe.remove(this),this.visible()){for(st.repaintControls=[],st.repaintControls.map={},this.recalc(),e=st.repaintControls.length;e--;)st.repaintControls[e].repaint();"flow"!==this.settings.layout&&"stack"!==this.settings.layout&&this.repaint(),st.repaintControls=[]}return this}});function dt(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),we(x).on("mousemove touchmove",v).on("mouseup touchend",p),h.start(e)},v=function(e){if(dt(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){dt(e),we(x).off("mousemove touchmove",v).off("mouseup touchend",p),m.remove(),h.stop&&h.stop(e)},this.destroy=function(){we(w).off()},we(w).on("mousedown touchstart",t)}var ht,mt,gt,pt,vt={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(),we(p.getEl("absend")).css(f,p.layoutRect()[i]-1),!r)return void we(a).css("display","none");we(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,we(a).css(d),(d={})[f]=s["scroll"+t]*c,d[h]=u*c,we(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;we(p.getEl()).append('
'),p.draghelper=new ft(e+"t",{start:function(){d=p.getEl("body")["scroll"+a],we("#"+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(){we("#"+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()}),we(p.getEl("body")).on("scroll",n)),n())}},bt=ct.extend({Defaults:{layout:"fit",containerCls:"panel"},Mixins:[vt],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+"
"}}),yt={resizeToContent:function(){this._layoutRect.autoResize=!0,this._lastRect=null,this.reflow()},resizeTo:function(e,t){if(e<=1||t<=1){var n=Ce.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)}},xt=[],wt=[];function _t(e,t){for(;e;){if(e===t)return!0;e=e.parent()}}function Ct(){ht||(ht=function(e){2!==e.button&&function(e){for(var t=xt.length;t--;){var n=xt[t],i=n.getParentCtrl(e.target);if(n.settings.autohide){if(i&&(_t(i,n)||n.parent()===i))continue;(e=n.fire("autohide",{target:e.target})).isDefaultPrevented()||n.hide()}}}(e)},we(document).on("click touchstart",ht))}function Rt(r){var e=Ce.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"),we(i.getEl()).addClass(n+"in")}),pt=!0),Et(!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=Ce.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=xt.length;e--&&xt[e]!==this;);return-1===e&&xt.push(this),t},hide:function(){return Tt(this),Et(!1,this),this._super()},hideAll:function(){kt.hideAll()},close:function(){return this.fire("close").isDefaultPrevented()||(this.remove(),Et(!1,this)),this},remove:function(){Tt(this),this._super()},postRender:function(){return this.settings.bodyRole&&this.getEl("body").setAttribute("role",this.settings.bodyRole),this._super()}});function Tt(e){var t;for(t=xt.length;t--;)xt[t]===e&&xt.splice(t,1);for(t=wt.length;t--;)wt[t]===e&&wt.splice(t,1)}kt.hideAll=function(){for(var e=xt.length;e--;){var t=xt[e];t&&t.settings.autohide&&(t.hide(),xt.splice(e,1))}};var Ht=function(e,t){return!(!e||t.settings.ui_container)},St=function(s,e,t){var a,n,l=v.DOM,i=s.getParam("fixed_toolbar_container");i&&(n=l.select(i)[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(),kt.hideAll(),l.removeClass(s.getBody(),"mce-edit-focus"))},c=function(){a?a.visible()||o():(a=e.panel=b.create({type:n?"panel":"floatpanel",role:"application",classes:"tinymce tinymce-inline",layout:"flex",direction:"column",align:"stretch",autohide:!1,autofix:Ht(n,s),fixed:Ht(n,s),border:1,items:[!1===d(s)?null:{type:"menubar",border:"0 0 1 0",items:se(s)},L(s,f(s))]}),O.setUiContainer(s,a),_(s),n?a.renderTo(n).reflow():a.renderTo().reflow(),C(s,a),o(),V(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===g(s)&&t.skinUiCss?l.styleSheetLoader.load(t.skinUiCss,c,c):c()}),s.on("blur hide",u),s.on("remove",function(){a&&(a.remove(),a=null)}),!1===g(s)&&t.skinUiCss?l.styleSheetLoader.load(t.skinUiCss,ve(s)):ve(s)(),{}};function Mt(i,r){var o,s,a=this,l=st.classPrefix;a.show=function(e,t){function n(){o&&(we(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 Nt=function(e,t){var n;e.on("ProgressState",function(e){n=n||new Mt(t.panel.getEl("body")),e.state?n.show(e.time):n.hide()})},Pt=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):h.baseURL+"/skins/"+r}return i}(e);return i&&(n.skinUiCss=i+"/skin.min.css",e.contentCSS.push(i+"/content"+(e.inline?".inline":"")+".min.css")),Nt(e,t),e.getParam("inline",!1,"boolean")?St(e,t,n):xe(e,t,n)},Dt=st.extend({Mixins:[Se],Defaults:{classes:"widget tooltip tooltip-n"},renderHtml:function(){var e=this,t=e.classPrefix;return'"},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}}),Wt=st.extend({init:function(i){var r=this;r._super(i),i=r.settings,r.canFocus=!0,i.tooltip&&!1!==Wt.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 Dt({type:"tooltip"}),O.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)}}),Ot=Wt.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'
0%
'},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()}}),At=function(e,t){e.getEl().lastChild.textContent=t+(e.progressBar?" "+e.progressBar.value()+"%":"")},Bt=st.extend({Mixins:[Se],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=''),t.progressBar&&(o=t.progressBar.renderHtml()),''},postRender:function(){var e=this;return u.setTimeout(function(){e.$el.addClass(e.classPrefix+"in"),At(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,At(t,e.value)}),t.progressBar&&(t.progressBar.bindStates(),t.progressBar.state.on("change:value",function(e){At(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 Lt(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),Ce.getSize(n).width)}),r=new Bt(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){G(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=Ce.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=Ce.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='
'+e.encode(r.title)+'
'),r.url&&(a=''),void 0===a&&(a=t.renderHtml(e)),e.statusbar&&(s=e.statusbar.renderHtml()),'
'+o+'
'+a+"
"+s+"
"},fullscreen:function(e){var n,t,i=this,r=document.documentElement,o=i.classPrefix;if(e!==i._fullscreen)if(we(window).on("resize",function(){var e;if(i._fullscreen)if(n)i._timer||(i._timer=u.setTimeout(function(){var e=Ce.getWindowSize();i.moveTo(0,0).resizeTo(e.w,e.h),i._timer=0},50));else{e=(new Date).getTime();var t=Ce.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=Pe("0"),i.getEl("head").style.display="none",t.deltaH-=t.headerH+2,we([r,document.body]).addClass(o+"fullscreen"),i.classes.add("fullscreen");var s=Ce.getWindowSize();i.moveTo(0,0).resizeTo(s.w,s.h)}else i.borderBox=Pe(i.settings.border),i.getEl("head").style.display="",t.deltaH+=t.headerH,we([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 ft(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()}),It.push(n),Ft(!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(),Ut(t.classPrefix,!1),e=It.length;e--;)It[e]===t&&It.splice(e,1);Ft(0'+this._super(e)}}),jt=Wt.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+'"':"",'
"},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=Ce.create("input",{type:"file",id:n._id+"-browse",accept:n.settings.accept});n._super(),we(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)}),we(t).on("click",function(e){e.stopPropagation()}),we(n.getEl("button")).on("click",function(e){e.stopPropagation(),t.click()}),n.getEl().appendChild(t)},remove:function(){we(this.getEl("button")).off(),we(this.getEl("input")).off(),this._super()}}),Gt=ct.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=Wt.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=Wt.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(we.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
"),'
'},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=Wt.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=Ce.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;Ce.css(r,{top:100*n+"%"}),t||Ce.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 ft(a._id+"-sv",{start:e,drag:e}),a._hdraghelper=new ft(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}()+'
','
'+e+"
"}}),an=Wt.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=Ce.create("div",e,""+this.translate(n.text)+""),n.height&&Ce.css(t,"height",n.height+"px"),n.width&&Ce.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=Wt.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