tinymce
Version:
Web based JavaScript HTML WYSIWYG editor control.
1,562 lines (1,529 loc) • 1.07 MB
JavaScript
/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
* Version: 5.1.0 (2019-10-17)
*/
(function (domGlobals) {
'use strict';
var noop = function () {
};
var compose = function (fa, fb) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return fa(fb.apply(null, args));
};
};
var constant = function (value) {
return function () {
return value;
};
};
var identity = function (x) {
return x;
};
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 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 die = function (msg) {
return function () {
throw new Error(msg);
};
};
var never = constant(false);
var always = constant(true);
var none = function () {
return NONE;
};
var NONE = function () {
var eq = function (o) {
return o.isNone();
};
var call = function (thunk) {
return thunk();
};
var id = function (n) {
return n;
};
var me = {
fold: function (n, s) {
return n();
},
is: never,
isSome: never,
isNone: always,
getOr: id,
getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: constant(null),
getOrUndefined: constant(undefined),
or: id,
orThunk: call,
map: none,
each: noop,
bind: none,
exists: never,
forall: always,
filter: none,
equals: eq,
equals_: eq,
toArray: function () {
return [];
},
toString: constant('none()')
};
if (Object.freeze) {
Object.freeze(me);
}
return me;
}();
var some = function (a) {
var constant_a = constant(a);
var self = function () {
return me;
};
var bind = function (f) {
return f(a);
};
var me = {
fold: function (n, s) {
return s(a);
},
is: function (v) {
return a === v;
},
isSome: always,
isNone: never,
getOr: constant_a,
getOrThunk: constant_a,
getOrDie: constant_a,
getOrNull: constant_a,
getOrUndefined: constant_a,
or: self,
orThunk: self,
map: function (f) {
return some(f(a));
},
each: function (f) {
f(a);
},
bind: bind,
exists: bind,
forall: bind,
filter: function (f) {
return f(a) ? me : NONE;
},
toArray: function () {
return [a];
},
toString: function () {
return 'some(' + a + ')';
},
equals: function (o) {
return o.is(a);
},
equals_: function (o, elementEq) {
return o.fold(never, function (b) {
return elementEq(a, b);
});
}
};
return me;
};
var from = function (value) {
return value === null || value === undefined ? NONE : some(value);
};
var Option = {
some: some,
none: none,
from: from
};
var typeOf = function (x) {
if (x === null) {
return 'null';
}
var t = typeof x;
if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
return 'array';
}
if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
return 'string';
}
return t;
};
var isType = function (type) {
return function (value) {
return typeOf(value) === type;
};
};
var isString = isType('string');
var isObject = isType('object');
var isArray = isType('array');
var isNull = isType('null');
var isBoolean = isType('boolean');
var isFunction = isType('function');
var isNumber = isType('number');
var nativeSlice = Array.prototype.slice;
var nativeIndexOf = Array.prototype.indexOf;
var nativePush = Array.prototype.push;
var rawIndexOf = function (ts, t) {
return nativeIndexOf.call(ts, t);
};
var indexOf = function (xs, x) {
var r = rawIndexOf(xs, x);
return r === -1 ? Option.none() : Option.some(r);
};
var contains = function (xs, x) {
return rawIndexOf(xs, x) > -1;
};
var exists = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
var map = function (xs, f) {
var len = xs.length;
var r = new Array(len);
for (var i = 0; i < len; i++) {
var x = xs[i];
r[i] = f(x, i);
}
return r;
};
var each = function (xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i);
}
};
var eachr = function (xs, f) {
for (var i = xs.length - 1; i >= 0; i--) {
var x = xs[i];
f(x, i);
}
};
var partition = function (xs, pred) {
var pass = [];
var fail = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
var arr = pred(x, i) ? pass : fail;
arr.push(x);
}
return {
pass: pass,
fail: fail
};
};
var filter = function (xs, pred) {
var r = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
var foldr = function (xs, f, acc) {
eachr(xs, function (x) {
acc = f(acc, x);
});
return acc;
};
var foldl = function (xs, f, acc) {
each(xs, function (x) {
acc = f(acc, x);
});
return acc;
};
var find = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(x);
}
}
return Option.none();
};
var findIndex = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(i);
}
}
return Option.none();
};
var flatten = function (xs) {
var r = [];
for (var i = 0, len = xs.length; i < len; ++i) {
if (!isArray(xs[i])) {
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
}
nativePush.apply(r, xs[i]);
}
return r;
};
var bind = function (xs, f) {
var output = map(xs, f);
return flatten(output);
};
var forall = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; ++i) {
var x = xs[i];
if (pred(x, i) !== true) {
return false;
}
}
return true;
};
var reverse = function (xs) {
var r = nativeSlice.call(xs, 0);
r.reverse();
return r;
};
var difference = function (a1, a2) {
return filter(a1, function (x) {
return !contains(a2, x);
});
};
var mapToObject = function (xs, f) {
var r = {};
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
r[String(x)] = f(x, i);
}
return r;
};
var sort = function (xs, comparator) {
var copy = nativeSlice.call(xs, 0);
copy.sort(comparator);
return copy;
};
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 nativeSlice.call(x);
};
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
var isNodeType = function (type) {
return function (node) {
return !!node && node.nodeType === type;
};
};
var isRestrictedNode = function (node) {
return !!node && !Object.getPrototypeOf(node);
};
var isElement = isNodeType(1);
var matchNodeNames = function (names) {
var lowercasedNames = names.map(function (s) {
return s.toLowerCase();
});
return function (node) {
if (node && node.nodeName) {
var nodeName = node.nodeName.toLowerCase();
return contains(lowercasedNames, nodeName);
}
return false;
};
};
var matchStyleValues = function (name, values) {
var items = values.toLowerCase().split(' ');
return function (node) {
var i, cssValue;
if (isElement(node)) {
for (i = 0; i < items.length; i++) {
var computed = node.ownerDocument.defaultView.getComputedStyle(node, null);
cssValue = computed ? computed.getPropertyValue(name) : null;
if (cssValue === items[i]) {
return true;
}
}
}
return false;
};
};
var hasPropValue = function (propName, propValue) {
return function (node) {
return isElement(node) && node[propName] === propValue;
};
};
var hasAttribute = function (attrName, attrValue) {
return function (node) {
return isElement(node) && node.hasAttribute(attrName);
};
};
var hasAttributeValue = function (attrName, attrValue) {
return function (node) {
return isElement(node) && node.getAttribute(attrName) === attrValue;
};
};
var isBogus = function (node) {
return isElement(node) && node.hasAttribute('data-mce-bogus');
};
var isBogusAll = function (node) {
return isElement(node) && node.getAttribute('data-mce-bogus') === 'all';
};
var isTable = function (node) {
return isElement(node) && node.tagName === 'TABLE';
};
var hasContentEditableState = function (value) {
return function (node) {
if (isElement(node)) {
if (node.contentEditable === value) {
return true;
}
if (node.getAttribute('data-mce-contenteditable') === value) {
return true;
}
}
return false;
};
};
var isTextareaOrInput = matchNodeNames([
'textarea',
'input'
]);
var isText = isNodeType(3);
var isComment = isNodeType(8);
var isDocument = isNodeType(9);
var isDocumentFragment = isNodeType(11);
var isBr = matchNodeNames(['br']);
var isContentEditableTrue = hasContentEditableState('true');
var isContentEditableFalse = hasContentEditableState('false');
var NodeType = {
isText: isText,
isElement: isElement,
isComment: isComment,
isDocument: isDocument,
isDocumentFragment: isDocumentFragment,
isBr: isBr,
isContentEditableTrue: isContentEditableTrue,
isContentEditableFalse: isContentEditableFalse,
isRestrictedNode: isRestrictedNode,
matchNodeNames: matchNodeNames,
hasPropValue: hasPropValue,
hasAttribute: hasAttribute,
hasAttributeValue: hasAttributeValue,
matchStyleValues: matchStyleValues,
isBogus: isBogus,
isBogusAll: isBogusAll,
isTable: isTable,
isTextareaOrInput: isTextareaOrInput
};
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 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, mediaMatch) {
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
var isiPhone = os.isiOS() && !isiPad;
var isMobile = os.isiOS() || os.isAndroid();
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
var isPhone = isiPhone || isMobile && !isTablet;
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
var isDesktop = !isPhone && !isTablet && !iOSwebview;
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),
isDesktop: constant(isDesktop)
};
};
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 checkRange = function (str, substr, start) {
if (substr === '') {
return true;
}
if (str.length < substr.length) {
return false;
}
var x = str.substr(start, start + substr.length);
return x === substr;
};
var contains$1 = function (str, substr) {
return str.indexOf(substr) !== -1;
};
var startsWith = function (str, prefix) {
return checkRange(str, prefix, 0);
};
var trim = function (str) {
return str.replace(/^\s+|\s+$/g, '');
};
var lTrim = function (str) {
return str.replace(/^\s+/g, '');
};
var rTrim = function (str) {
return str.replace(/\s+$/g, '');
};
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) {
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
}
},
{
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, mediaMatch) {
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, mediaMatch);
return {
browser: browser,
os: os,
deviceType: deviceType
};
};
var PlatformDetection = { detect: detect$2 };
var mediaMatch = function (query) {
return domGlobals.window.matchMedia(query).matches;
};
var platform = Cell(PlatformDetection.detect(domGlobals.navigator.userAgent, mediaMatch));
var detect$3 = function () {
return platform.get();
};
var fromHtml = function (html, scope) {
var doc = scope || domGlobals.document;
var div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
domGlobals.console.error('HTML does not have a single root node', html);
throw new Error('HTML must have a single root node');
}
return fromDom(div.childNodes[0]);
};
var fromTag = function (tag, scope) {
var doc = scope || domGlobals.document;
var node = doc.createElement(tag);
return fromDom(node);
};
var fromText = function (text, scope) {
var doc = scope || domGlobals.document;
var node = doc.createTextNode(text);
return fromDom(node);
};
var fromDom = function (node) {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: constant(node) };
};
var fromPoint = function (docElm, x, y) {
var doc = docElm.dom();
return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
};
var Element = {
fromHtml: fromHtml,
fromTag: fromTag,
fromText: fromText,
fromDom: fromDom,
fromPoint: fromPoint
};
var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE;
var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE;
var COMMENT = domGlobals.Node.COMMENT_NODE;
var DOCUMENT = domGlobals.Node.DOCUMENT_NODE;
var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE;
var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE;
var ELEMENT = domGlobals.Node.ELEMENT_NODE;
var TEXT = domGlobals.Node.TEXT_NODE;
var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE;
var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE;
var ENTITY = domGlobals.Node.ENTITY_NODE;
var NOTATION = domGlobals.Node.NOTATION_NODE;
var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
var name = function (element) {
var r = element.dom().nodeName;
return r.toLowerCase();
};
var type = function (element) {
return element.dom().nodeType;
};
var isType$1 = function (t) {
return function (element) {
return type(element) === t;
};
};
var isElement$1 = isType$1(ELEMENT);
var isText$1 = isType$1(TEXT);
var keys = Object.keys;
var hasOwnProperty = Object.hasOwnProperty;
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);
}
};
var map$1 = function (obj, f) {
return tupleMap(obj, function (x, i) {
return {
k: i,
v: f(x, i)
};
});
};
var tupleMap = function (obj, f) {
var r = {};
each$1(obj, function (x, i) {
var tuple = f(x, i);
r[tuple.k] = tuple.v;
});
return r;
};
var bifilter = function (obj, pred) {
var t = {};
var f = {};
each$1(obj, function (x, i) {
var branch = pred(x, i) ? t : f;
branch[i] = x;
});
return {
t: t,
f: f
};
};
var get = function (obj, key) {
return has(obj, key) ? Option.from(obj[key]) : Option.none();
};
var has = function (obj, key) {
return hasOwnProperty.call(obj, key);
};
var isSupported = function (dom) {
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
};
var inBody = function (element) {
var dom = isText$1(element) ? element.dom().parentNode : element.dom();
return dom !== undefined && dom !== null && dom.ownerDocument.body.contains(dom);
};
var rawSet = function (dom, key, value) {
if (isString(value) || isBoolean(value) || isNumber(value)) {
dom.setAttribute(key, value + '');
} else {
domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
throw new Error('Attribute value was not simple');
}
};
var set = function (element, key, value) {
rawSet(element.dom(), key, value);
};
var setAll = function (element, attrs) {
var dom = element.dom();
each$1(attrs, function (v, k) {
rawSet(dom, k, v);
});
};
var get$1 = function (element, key) {
var v = element.dom().getAttribute(key);
return v === null ? undefined : v;
};
var has$1 = function (element, key) {
var dom = element.dom();
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
};
var remove = function (element, key) {
element.dom().removeAttribute(key);
};
var get$2 = function (element, property) {
var dom = element.dom();
var styles = domGlobals.window.getComputedStyle(dom);
var r = styles.getPropertyValue(property);
var v = r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
return v === null ? undefined : v;
};
var getUnsafeProperty = function (dom, property) {
return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
};
var getRaw = function (element, property) {
var dom = element.dom();
var raw = getUnsafeProperty(dom, property);
return Option.from(raw).filter(function (r) {
return r.length > 0;
});
};
var reflow = function (e) {
return e.dom().offsetWidth;
};
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 Recurse = { toArray: toArray };
var compareDocumentPosition = function (a, b, match) {
return (a.compareDocumentPosition(b) & match) !== 0;
};
var documentPositionPreceding = function (a, b) {
return compareDocumentPosition(a, b, domGlobals.Node.DOCUMENT_POSITION_PRECEDING);
};
var documentPositionContainedBy = function (a, b) {
return compareDocumentPosition(a, b, domGlobals.Node.DOCUMENT_POSITION_CONTAINED_BY);
};
var Node = {
documentPositionPreceding: documentPositionPreceding,
documentPositionContainedBy: documentPositionContainedBy
};
var ELEMENT$1 = ELEMENT;
var DOCUMENT$1 = DOCUMENT;
var is = function (element, selector) {
var dom = element.dom();
if (dom.nodeType !== ELEMENT$1) {
return false;
} else {
var elem = dom;
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$1 && dom.nodeType !== DOCUMENT$1 || dom.childElementCount === 0;
};
var all = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element.fromDom);
};
var one = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element.fromDom);
};
var eq = function (e1, e2) {
return e1.dom() === e2.dom();
};
var regularContains = function (e1, e2) {
var d1 = e1.dom();
var d2 = e2.dom();
return d1 === d2 ? false : d1.contains(d2);
};
var ieContains = function (e1, e2) {
return Node.documentPositionContainedBy(e1.dom(), e2.dom());
};
var browser = detect$3().browser;
var contains$2 = browser.isIE() ? ieContains : regularContains;
var owner = function (element) {
return Element.fromDom(element.dom().ownerDocument);
};
var documentElement = function (element) {
return Element.fromDom(element.dom().ownerDocument.documentElement);
};
var defaultView = function (element) {
return Element.fromDom(element.dom().ownerDocument.defaultView);
};
var parent = function (element) {
return Option.from(element.dom().parentNode).map(Element.fromDom);
};
var parents = function (element, isRoot) {
var stop = isFunction(isRoot) ? isRoot : never;
var dom = element.dom();
var ret = [];
while (dom.parentNode !== null && dom.parentNode !== undefined) {
var rawParent = dom.parentNode;
var p = Element.fromDom(rawParent);
ret.push(p);
if (stop(p) === true) {
break;
} else {
dom = rawParent;
}
}
return ret;
};
var prevSibling = function (element) {
return Option.from(element.dom().previousSibling).map(Element.fromDom);
};
var nextSibling = function (element) {
return Option.from(element.dom().nextSibling).map(Element.fromDom);
};
var prevSiblings = function (element) {
return reverse(Recurse.toArray(element, prevSibling));
};
var nextSiblings = function (element) {
return Recurse.toArray(element, nextSibling);
};
var children = function (element) {
return map(element.dom().childNodes, Element.fromDom);
};
var child = function (element, index) {
var cs = element.dom().childNodes;
return Option.from(cs[index]).map(Element.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 spot = Immutable('element', 'offset');
var browser$1 = detect$3().browser;
var firstElement = function (nodes) {
return find(nodes, isElement$1);
};
var getTableCaptionDeltaY = function (elm) {
if (browser$1.isFirefox() && name(elm) === 'table') {
return firstElement(children(elm)).filter(function (elm) {
return name(elm) === 'caption';
}).bind(function (caption) {
return firstElement(nextSiblings(caption)).map(function (body) {
var bodyTop = body.dom().offsetTop;
var captionTop = caption.dom().offsetTop;
var captionHeight = caption.dom().offsetHeight;
return bodyTop <= captionTop ? -captionHeight : 0;
});
}).getOr(0);
} else {
return 0;
}
};
var hasChild = function (elm, child) {
return elm.children && contains(elm.children, child);
};
var getPos = function (body, elm, rootElm) {
var x = 0, y = 0, offsetParent;
var doc = body.ownerDocument;
var pos;
rootElm = rootElm ? rootElm : body;
if (elm) {
if (rootElm === body && elm.getBoundingClientRect && get$2(Element.fromDom(body), 'position') === 'static') {
pos = elm.getBoundingClientRect();
x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - doc.documentElement.clientLeft;
y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - doc.documentElement.clientTop;
return {
x: x,
y: y
};
}
offsetParent = elm;
while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {
x += offsetParent.offsetLeft || 0;
y += offsetParent.offsetTop || 0;
offsetParent = offsetParent.offsetParent;
}
offsetParent = elm.parentNode;
while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {
x -= offsetParent.scrollLeft || 0;
y -= offsetParent.scrollTop || 0;
offsetParent = offsetParent.parentNode;
}
y += getTableCaptionDeltaY(Element.fromDom(elm));
}
return {
x: x,
y: y
};
};
var Position = { getPos: getPos };
var exports$1 = {}, module$1 = { exports: exports$1 };
(function (define, exports, module, require) {
(function (f) {
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = f();
} else if (typeof define === 'function' && define.amd) {
define([], f);
} else {
var g;
if (typeof window !== 'undefined') {
g = window;
} else if (typeof global !== 'undefined') {
g = global;
} else if (typeof self !== 'undefined') {
g = self;
} else {
g = this;
}
g.EphoxContactWrapper = f();
}
}(function () {
return function () {
function r(e, n, t) {
function o(i, f) {
if (!n[i]) {
if (!e[i]) {
var c = 'function' == typeof require && require;
if (!f && c)
return c(i, !0);
if (u)
return u(i, !0);
var a = new Error('Cannot find module \'' + i + '\'');
throw a.code = 'MODULE_NOT_FOUND', a;
}
var p = n[i] = { exports: {} };
e[i][0].call(p.exports, function (r) {
var n = e[i][1][r];
return o(n || r);
}, p, p.exports, r, e, n, t);
}
return n[i].exports;
}
for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++)
o(t[i]);
return o;
}
return r;
}()({
1: [
function (require, module, exports) {
var process = module.exports = {};
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout() {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
}());
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
return setTimeout(fun, 0);
}
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
return cachedSetTimeout(fun, 0);
} catch (e) {
try {
return cachedSetTimeout.call(null, fun, 0);
} catch (e) {
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
return clearTimeout(marker);
}
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
return cachedClearTimeout(marker);
} catch (e) {
try {
return cachedClearTimeout.call(null, marker);
} catch (e) {
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = '';
process.versions = {};
function noop() {
}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) {
return [];
};
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () {
return '/';
};
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function () {
return 0;
};
},
{}
],
2: [
function (require, module, exports) {
(function (setImmediate) {
(function (root) {
var setTimeoutFunc = setTimeout;
function noop() {
}
function bind(fn, thisArg) {
return function () {
fn.apply(thisArg, arguments);
};
}
function Promise(fn) {
if (typeof this !== 'object')
throw new TypeError('Promises must be constructed via new');
if (typeof fn !== 'function')
throw new TypeError('not a function');
this._state = 0;
this._handled = false;
this._value = undefined;
this._deferreds = [];
doResolve(fn, this);
}
function handle(self, deferred) {
while (self._state === 3) {
self = self._value;
}
if (self._state === 0) {
self._deferreds.push(deferred);
return;
}
self._handled = true;
Promise._immediateFn(function () {
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
if (cb === null) {
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
return;
}
var ret;
try {
ret = cb(self._value);
} catch (e) {
reject(deferred.promise, e);
return;
}
resolve(deferred.promise, ret);
});
}
function resolve(self, newValue) {
try {
if (newValue === self)
throw new TypeError('A promise cannot be resolved with itself.');
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
var then = newValue.then;
if (newValue instanceof Promise) {
self._state = 3;
self._value = newValue;
finale(self);
return;
} else if (typeof then === 'function') {
doResolve(bind(then, newValue), self);
return;
}
}
self._state = 1;
self._value = newValue;
finale(self);
} catch (e) {
reject(self, e);
}
}
function reject(self, newValue) {
self._state = 2;
self._value = newValue;
finale(self);
}
function finale(self) {
if (self._state === 2 && self._deferreds.length === 0) {
Promise._immediateFn(function () {
if (!self._handled) {
Promise._unhandledRejectionFn(self._value);
}
});
}
for (var i = 0, len = self._deferreds.length; i < len; i++) {
handle(self, self._deferreds[i]);
}
self._deferreds = null;
}
function Handler(onFulfilled, onRejected, promise) {
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
this.promise = promise;
}
function doResolve(fn, self) {
var done = false;
try {
fn(function (value) {
if (done)
return;
done = true;
resolve(self, value);
}, function (reason) {
if (done)
return;
done = true;
reject(self, reason);
});
} catch (ex) {
if (done)
return;
done = true;
reject(self, ex);
}
}
Promise.prototype['catch'] = function (onRejected) {
return this.then(null, onRejected);
};
Promise.prototype.then = function (onFulfilled, onRejected) {
var prom = new this.constructor(noop);
handle(this, new Handler(onFulfilled, onRejected, prom));
return prom;
};
Promise.all = function (arr) {
var args = Array.prototype.slice.call(arr);
return new Promise(function (resolve, reject) {
if (args.length === 0)
return resolve([]);
var remaining = args.length;
function res(i, val) {
try {
if (val && (typeof val === 'object' || typeof val === 'function')) {
var then = val.then;
if (typeof then === 'function') {
then.c