﻿!function (window, undefined) {
    function _isArray(e) { return e ? "[object Array]" === Object.prototype.toString.call(e) : !1 } function _isFunction(e) { return e ? "[object Function]" === Object.prototype.toString.call(e) : !1 } function _inArray(e, t) { for (var n = 0, i = t.length; i > n; n++) if (e === t[n]) return n; return -1 } function _each(e, t) { if (_isArray(e)) for (var n = 0, i = e.length; i > n && t.call(e[n], n, e[n]) !== !1; n++); else for (var o in e) if (e.hasOwnProperty(o) && t.call(e[o], o, e[o]) === !1) break } function _trim(e) { return e.replace(/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g, "") } function _inString(e, t, n) { return n = n === undefined ? "," : n, (n + t + n).indexOf(n + e + n) >= 0 } function _addUnit(e, t) { return t = t || "px", e && /^-?\d+(?:\.\d+)?$/.test(e) ? e + t : e } function _removeUnit(e) { var t; return e && (t = /(\d+)/.exec(e)) ? parseInt(t[1], 10) : 0 } function _escape(e) { return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;") } function _unescape(e) { return e.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&") } function _toCamel(e) { var t = e.split("-"); return e = "", _each(t, function (t, n) { e += t > 0 ? n.charAt(0).toUpperCase() + n.substr(1) : n }), e } function _toHex(e) { function t(e) { var t = parseInt(e, 10).toString(16).toUpperCase(); return t.length > 1 ? t : "0" + t } return e.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/gi, function (e, n, i, o) { return "#" + t(n) + t(i) + t(o) }) } function _toMap(e, t) { t = t === undefined ? "," : t; var n, i = {}, o = _isArray(e) ? e : e.split(t); return _each(o, function (e, t) { if (n = /^(\d+)\.\.(\d+)$/.exec(t)) for (var o = parseInt(n[1], 10) ; o <= parseInt(n[2], 10) ; o++) i[o.toString()] = !0; else i[t] = !0 }), i } function _toArray(e, t) { return Array.prototype.slice.call(e, t || 0) } function _undef(e, t) { return e === undefined ? t : e } function _invalidUrl(e) { return !e || /[<>"]/.test(e) } function _addParam(e, t) { return e.indexOf("?") >= 0 ? e + "&" + t : e + "?" + t } function _extend(e, t, n) { n || (n = t, t = null); var i; if (t) { var o = function () { }; o.prototype = t.prototype, i = new o, _each(n, function (e, t) { i[e] = t }) } else i = n; i.constructor = e, e.prototype = i, e.parent = t ? t.prototype : null } function _json(text) { var match; (match = /\{[\s\S]*\}|\[[\s\S]*\]/.exec(text)) && (text = match[0]); var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; if (cx.lastIndex = 0, cx.test(text) && (text = text.replace(cx, function (e) { return "\\u" + ("0000" + e.charCodeAt(0).toString(16)).slice(-4) })), /^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) return eval("(" + text + ")"); throw "JSON parse error" } function _getBasePath() { for (var e, t = document.getElementsByTagName("script"), n = 0, i = t.length; i > n; n++) if (e = t[n].src || "", /kindeditor[\w\-\.]*\.js/.test(e)) return e.substring(0, e.lastIndexOf("/") + 1); return "" } function _bindEvent(e, t, n) { e.addEventListener ? e.addEventListener(t, n, _useCapture) : e.attachEvent && e.attachEvent("on" + t, n) } function _unbindEvent(e, t, n) { e.removeEventListener ? e.removeEventListener(t, n, _useCapture) : e.detachEvent && e.detachEvent("on" + t, n) } function KEvent(e, t) { this.init(e, t) } function _getId(e) { return e[_eventExpendo] || null } function _setId(e) { return e[_eventExpendo] = ++_eventId, _eventId } function _removeId(e) { try { delete e[_eventExpendo] } catch (t) { e.removeAttribute && e.removeAttribute(_eventExpendo) } } function _bind(e, t, n) { if (t.indexOf(",") >= 0) return void _each(t.split(","), function () { _bind(e, this, n) }); var i = _getId(e); i || (i = _setId(e)), _eventData[i] === undefined && (_eventData[i] = {}); var o = _eventData[i][t]; o && o.length > 0 ? _unbindEvent(e, t, o[0]) : (_eventData[i][t] = [], _eventData[i].el = e), o = _eventData[i][t], 0 === o.length && (o[0] = function (t) { var n = t ? new KEvent(e, t) : undefined; _each(o, function (t, i) { t > 0 && i && i.call(e, n) }) }), _inArray(n, o) < 0 && o.push(n), _bindEvent(e, t, o[0]) } function _unbind(e, t, n) { if (t && t.indexOf(",") >= 0) return void _each(t.split(","), function () { _unbind(e, this, n) }); var i = _getId(e); if (i) { if (t === undefined) return void (i in _eventData && (_each(_eventData[i], function (t, n) { "el" != t && n.length > 0 && _unbindEvent(e, t, n[0]) }), delete _eventData[i], _removeId(e))); if (_eventData[i]) { var o = _eventData[i][t]; if (o && o.length > 0) { n === undefined ? (_unbindEvent(e, t, o[0]), delete _eventData[i][t]) : (_each(o, function (e, t) { e > 0 && t === n && o.splice(e, 1) }), 1 == o.length && (_unbindEvent(e, t, o[0]), delete _eventData[i][t])); var a = 0; _each(_eventData[i], function () { a++ }), 2 > a && (delete _eventData[i], _removeId(e)) } } } } function _fire(e, t) { if (t.indexOf(",") >= 0) return void _each(t.split(","), function () { _fire(e, this) }); var n = _getId(e); if (n) { var i = _eventData[n][t]; _eventData[n] && i && i.length > 0 && i[0]() } } function _ctrl(e, t, n) { t = /^\d{2,}$/.test(t) ? t : t.toUpperCase().charCodeAt(0), _bind(e, "keydown", function (i) { !i.ctrlKey || i.which != t || i.shiftKey || i.altKey || (n.call(e), i.stop()) }) } function _ready(e) { function t() { o || (o = !0, e(KindEditor), _readyFinished = !0) } function n() { if (!o) { try { document.documentElement.doScroll("left") } catch (e) { return void setTimeout(n, 100) } t() } } function i() { "complete" === document.readyState && t() } if (_readyFinished) return void e(KindEditor); var o = !1; if (document.addEventListener) _bind(document, "DOMContentLoaded", t); else if (document.attachEvent) { _bind(document, "readystatechange", i); var a = !1; try { a = null == window.frameElement } catch (r) { } document.documentElement.doScroll && a && n() } _bind(window, "load", t) } function _getCssList(e) { e = e.replace(/&quot;/g, '"'); for (var t, n = {}, i = /\s*([\w\-]+)\s*:([^;]*)(;|$)/g; t = i.exec(e) ;) { var o = _trim(t[1].toLowerCase()), a = _trim(_toHex(t[2])); n[o] = a } return n } function _getAttrList(e) { for (var t, n = {}, i = /\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g; t = i.exec(e) ;) { var o = (t[1] || t[2] || t[4] || t[6]).toLowerCase(), a = (t[2] ? t[3] : t[4] ? t[5] : t[7]) || ""; n[o] = a } return n } function _addClassToTag(e, t) { return e = /\s+class\s*=/.test(e) ? e.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/, function (e, n, i, o) { return (" " + i + " ").indexOf(" " + t + " ") < 0 ? "" === i ? n + t + o : n + i + " " + t + o : e }) : e.substr(0, e.length - 1) + ' class="' + t + '">' } function _formatCss(e) { var t = ""; return _each(_getCssList(e), function (e, n) { t += e + ":" + n + ";" }), t } function _formatUrl(e, t, n, i) { function o(e) { for (var t = e.split("/"), n = [], i = 0, o = t.length; o > i; i++) { var a = t[i]; ".." == a ? n.length > 0 && n.pop() : "" !== a && "." != a && n.push(a) } return "/" + n.join("/") } function a(t, n) { if (e.substr(0, t.length) === t) { for (var o = [], r = 0; n > r; r++) o.push(".."); var l = "."; return o.length > 0 && (l += "/" + o.join("/")), "/" == i && (l += "/"), l + e.substr(t.length) } return (s = /^(.*)\//.exec(t)) ? a(s[1], ++n) : void 0 } if (t = _undef(t, "").toLowerCase(), "data:" != e.substr(0, 5) && (e = e.replace(/([^:])\/\//g, "$1/")), _inArray(t, ["absolute", "relative", "domain"]) < 0) return e; if (n = n || location.protocol + "//" + location.host, i === undefined) { var r = location.pathname.match(/^(\/.*)\//); i = r ? r[1] : "" } var s; if (s = /^(\w+:\/\/[^\/]*)/.exec(e)) { if (s[1] !== n) return e } else if (/^\w+:/.test(e)) return e; return /^\//.test(e) ? e = n + o(e.substr(1)) : /^\w+:\/\//.test(e) || (e = n + o(i + "/" + e)), "relative" === t ? e = a(n + i, 0).substr(2) : "absolute" === t && e.substr(0, n.length) === n && (e = e.substr(n.length)), e } function _formatHtml(e, t, n, i, o) { null == e && (e = ""), n = n || "", i = _undef(i, !1), o = _undef(o, "	"); var a = "xx-small,x-small,small,medium,large,x-large,xx-large".split(","); e = e.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/gi, function (e, t, n, i) { return t + n.replace(/<(?:br|br\s[^>]*)>/gi, "\n") + i }), e = e.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/gi, "</p>"), e = e.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/gi, "$1<br />$2"), e = e.replace(/\u200B/g, ""), e = e.replace(/\u00A9/g, "&copy;"), e = e.replace(/\u00AE/g, "&reg;"), e = e.replace(/\u2003/g, "&emsp;"), e = e.replace(/\u3000/g, "&emsp;"), e = e.replace(/<[^>]+/g, function (e) { return e.replace(/\s+/g, " ") }); var r = {}; t && (_each(t, function (e, t) { for (var n = e.split(","), i = 0, o = n.length; o > i; i++) r[n[i]] = _toMap(t) }), r.script || (e = e.replace(/(<(?:script|script\s[^>]*)>)([\s\S]*?)(<\/script>)/gi, "")), r.style || (e = e.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/gi, ""))); var s = /(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g, l = []; return e = e.replace(s, function (e, s, d, c, u, f, h) { var p = e, m = s || "", g = d || "", _ = c.toLowerCase(), v = u || "", b = f ? " " + f : "", y = h || ""; if (t && !r[_]) return ""; if ("" === b && _SINGLE_TAG_MAP[_] && (b = " /"), _INLINE_TAG_MAP[_] && (m && (m = " "), y && (y = " ")), _PRE_TAG_MAP[_] && (g ? y = "\n" : m = "\n"), i && "br" == _ && (y = "\n"), _BLOCK_TAG_MAP[_] && !_PRE_TAG_MAP[_]) if (i) { g && l.length > 0 && l[l.length - 1] === _ ? l.pop() : l.push(_), m = "\n", y = "\n"; for (var k = 0, w = g ? l.length : l.length - 1; w > k; k++) m += o, g || (y += o); b ? l.pop() : g || (y += o) } else m = y = ""; if ("" !== v) { var C = _getAttrList(p); if ("font" === _) { var E = {}, T = ""; _each(C, function (e, t) { "color" === e && (E.color = t, delete C[e]), "size" === e && (E["font-size"] = a[parseInt(t, 10) - 1] || "", delete C[e]), "face" === e && (E["font-family"] = t, delete C[e]), "style" === e && (T = t) }), T && !/;$/.test(T) && (T += ";"), _each(E, function (e, t) { "" !== t && (/\s/.test(t) && (t = "'" + t + "'"), T += e + ":" + t + ";") }), C.style = T } _each(C, function (e, i) { if (_FILL_ATTR_MAP[e] && (C[e] = e), _inArray(e, ["src", "href"]) >= 0 && (C[e] = _formatUrl(i, n)), (t && "style" !== e && !r[_]["*"] && !r[_][e] || "body" === _ && "contenteditable" === e || /^kindeditor_\d+$/.test(e)) && delete C[e], "style" === e && "" !== i) { var o = _getCssList(i); _each(o, function (e, n) { !t || r[_].style || r[_]["." + e] || delete o[e] }); var a = ""; _each(o, function (e, t) { a += e + ":" + t + ";" }), C.style = a } }), v = "", _each(C, function (e, t) { ("style" !== e || "" !== t) && (t = t.replace(/"/g, "&quot;"), v += " " + e + '="' + t + '"') }) } return "font" === _ && (_ = "span"), m + "<" + g + _ + v + b + ">" + y }), e = e.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/gi, function (e, t, n, i) { return t + n.replace(/\n/g, '<span id="__kindeditor_pre_newline__">\n') + i }), e = e.replace(/\n\s*\n/g, "\n"), e = e.replace(/<span id="__kindeditor_pre_newline__">\n/g, "\n"), _trim(e) } function _clearMsWord(e, t) { return e = e.replace(/<meta[\s\S]*?>/gi, "").replace(/<![\s\S]*?>/gi, "").replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<w:[^>]+>[\s\S]*?<\/w:[^>]+>/gi, "").replace(/<o:[^>]+>[\s\S]*?<\/o:[^>]+>/gi, "").replace(/<xml>[\s\S]*?<\/xml>/gi, "").replace(/<(?:table|td)[^>]*>/gi, function (e) { return e.replace(/border-bottom:([#\w\s]+)/gi, "border:$1") }), _formatHtml(e, t) } function _mediaType(e) { return /\.(rm|rmvb)(\?|$)/i.test(e) ? "audio/x-pn-realaudio-plugin" : /\.(swf|flv)(\?|$)/i.test(e) ? "application/x-shockwave-flash" : "video/x-ms-asf-plugin" } function _mediaClass(e) { return /realaudio/i.test(e) ? "ke-rm" : /flash/i.test(e) ? "ke-flash" : "ke-media" } function _mediaAttrs(e) { return _getAttrList(unescape(e)) } function _mediaEmbed(e) { var t = "<embed "; return _each(e, function (e, n) { t += e + '="' + n + '" ' }), t += "/>" } function _mediaImg(e, t) { var n = t.width, i = t.height, o = t.type || _mediaType(t.src), a = _mediaEmbed(t), r = ""; /\D/.test(n) ? r += "width:" + n + ";" : n > 0 && (r += "width:" + n + "px;"), /\D/.test(i) ? r += "height:" + i + ";" : i > 0 && (r += "height:" + i + "px;"); var s = '<img class="' + _mediaClass(o) + '" src="' + e + '" '; return "" !== r && (s += 'style="' + r + '" '), s += 'data-ke-tag="' + escape(a) + '" alt="" />' } function _tmpl(e, t) { var n = new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('" + e.replace(/[\r\t\n]/g, " ").split("<%").join("	").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(/\t=(.*?)%>/g, "',$1,'").split("	").join("');").split("%>").join("p.push('").split("\r").join("\\'") + "');}return p.join('');"); return t ? n(t) : n } function _contains(e, t) { if (9 == e.nodeType && 9 != t.nodeType) return !0; for (; t = t.parentNode;) if (t == e) return !0; return !1 } function _getAttr(e, t) { t = t.toLowerCase(); var n = null; if (_GET_SET_ATTRIBUTE || "script" == e.nodeName.toLowerCase()) try { n = e.getAttribute(t, 2) } catch (i) { n = e.getAttribute(t, 1) } else { var o = e.ownerDocument.createElement("div"); o.appendChild(e.cloneNode(!1)); var a = _getAttrList(_unescape(o.innerHTML)); t in a && (n = a[t]) } return "style" === t && null !== n && (n = _formatCss(n)), n } function _queryAll(e, t) { function n(e) { return "string" != typeof e ? e : e.replace(/([^\w\-])/g, "\\$1") } function i(e) { return e.replace(/\\/g, "") } function o(e, t) { return "*" === e || e.toLowerCase() === n(t.toLowerCase()) } function a(e, t, n) { var a = [], r = n.ownerDocument || n, s = r.getElementById(i(e)); return s && o(t, s.nodeName) && _contains(n, s) && a.push(s), a } function r(e, t, n) { var a, r, s, l, d = n.ownerDocument || n, c = []; if (n.getElementsByClassName) for (a = n.getElementsByClassName(i(e)), r = 0, s = a.length; s > r; r++) l = a[r], o(t, l.nodeName) && c.push(l); else if (d.querySelectorAll) for (a = d.querySelectorAll(("#document" !== n.nodeName ? n.nodeName + " " : "") + t + "." + e), r = 0, s = a.length; s > r; r++) l = a[r], _contains(n, l) && c.push(l); else for (a = n.getElementsByTagName(t), e = " " + e + " ", r = 0, s = a.length; s > r; r++) if (l = a[r], 1 == l.nodeType) { var u = l.className; u && (" " + u + " ").indexOf(e) > -1 && c.push(l) } return c } function s(e, t, n) { for (var a, r = [], s = n.ownerDocument || n, l = s.getElementsByName(i(e)), d = 0, c = l.length; c > d; d++) a = l[d], o(t, a.nodeName) && _contains(n, a) && null !== a.getAttribute("name") && r.push(a); return r } function l(e, t, i, o) { for (var a, r = [], s = o.getElementsByTagName(i), l = 0, d = s.length; d > l; l++) a = s[l], 1 == a.nodeType && (null === t ? null !== _getAttr(a, e) && r.push(a) : t === n(_getAttr(a, e)) && r.push(a)); return r } function d(e, t) { var n, i = []; n = /^((?:\\.|[^.#\s\[<>])+)/.exec(e); var o = n ? n[1] : "*"; if (n = /#((?:[\w\-]|\\.)+)$/.exec(e)) i = a(n[1], o, t); else if (n = /\.((?:[\w\-]|\\.)+)$/.exec(e)) i = r(n[1], o, t); else if (n = /\[((?:[\w\-]|\\.)+)\]/.exec(e)) i = l(n[1].toLowerCase(), null, o, t); else if (n = /\[((?:[\w\-]|\\.)+)\s*=\s*['"]?((?:\\.|[^'"]+)+)['"]?\]/.exec(e)) { var d = n[1].toLowerCase(), c = n[2]; i = "id" === d ? a(c, o, t) : "class" === d ? r(c, o, t) : "name" === d ? s(c, o, t) : l(d, c, o, t) } else for (var u, f = t.getElementsByTagName(o), h = 0, p = f.length; p > h; h++) u = f[h], 1 == u.nodeType && i.push(u); return i } var c = e.split(","); if (c.length > 1) { var u = []; return _each(c, function () { _each(_queryAll(this, t), function () { _inArray(this, u) < 0 && u.push(this) }) }), u } t = t || document; for (var f, h = [], p = /((?:\\.|[^\s>])+|[\s>])/g; f = p.exec(e) ;) " " !== f[1] && h.push(f[1]); var m = []; if (1 == h.length) return d(h[0], t); var g, _, v, b, y, k, w, C, E, T, x = !1; for (k = 0, lenth = h.length; k < lenth; k++) if (g = h[k], ">" !== g) { if (k > 0) { for (_ = [], w = 0, E = m.length; E > w; w++) for (b = m[w], v = d(g, b), C = 0, T = v.length; T > C; C++) y = v[C], x ? b === y.parentNode && _.push(y) : _.push(y); m = _ } else m = d(g, t); if (0 === m.length) return [] } else x = !0; return m } function _query(e, t) { var n = _queryAll(e, t); return n.length > 0 ? n[0] : null } function _get(e) { return K(e)[0] } function _getDoc(e) { return e ? e.ownerDocument || e.document || e : document } function _getWin(e) { if (!e) return window; var t = _getDoc(e); return t.parentWindow || t.defaultView } function _setHtml(e, t) { if (1 == e.nodeType) { var n = _getDoc(e); try { e.innerHTML = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + t; var i = n.getElementById("__kindeditor_temp_tag__"); i.parentNode.removeChild(i) } catch (o) { K(e).empty(), K("@" + t, n).each(function () { e.appendChild(this) }) } } } function _hasClass(e, t) { return _inString(t, e.className, " ") } function _setAttr(e, t, n) { _IE && 8 > _V && "class" == t.toLowerCase() && (t = "className"), e.setAttribute(t, "" + n) } function _removeAttr(e, t) { _IE && 8 > _V && "class" == t.toLowerCase() && (t = "className"), _setAttr(e, t, ""), e.removeAttribute(t) } function _getNodeName(e) { return e && e.nodeName ? e.nodeName.toLowerCase() : "" } function _computedCss(e, t) { var n = _getWin(e), i = _toCamel(t), o = ""; if (n.getComputedStyle) { var a = n.getComputedStyle(e, null); o = a[i] || a.getPropertyValue(t) || e.style[i] } else e.currentStyle && (o = e.currentStyle[i] || e.style[i]); return o } function _hasVal(e) { return !!_VALUE_TAG_MAP[_getNodeName(e)] } function _docElement(e) { return e = e || document, _QUIRKS ? e.body : e.documentElement } function _docHeight(e) { var t = _docElement(e); return Math.max(t.scrollHeight, t.clientHeight) } function _docWidth(e) { var t = _docElement(e); return Math.max(t.scrollWidth, t.clientWidth) } function _getScrollPos(e) { e = e || document; var t, n; return _IE || _NEWIE || _OPERA ? (t = _docElement(e).scrollLeft, n = _docElement(e).scrollTop) : (t = _getWin(e).scrollX, n = _getWin(e).scrollY), { x: t, y: n } } function KNode(e) { this.init(e) } function _updateCollapsed(e) { return e.collapsed = e.startContainer === e.endContainer && e.startOffset === e.endOffset, e } function _copyAndDelete(e, t, n) { function i(i, o, a) { var r, l = i.nodeValue.length; if (t) { var d = i.cloneNode(!0); r = o > 0 ? d.splitText(o) : d, l > a && r.splitText(a - o) } if (n) { var c = i; if (o > 0 && (c = i.splitText(o), e.setStart(i, o)), l > a) { var u = c.splitText(a - o); e.setEnd(u, 0) } s.push(c) } return r } function o() { n && e.up().collapse(!0); for (var t = 0, i = s.length; i > t; t++) { var o = s[t]; o.parentNode && o.parentNode.removeChild(o) } } function a(o, h) { for (var p, m = o.firstChild; m;) { var g = new KRange(r).selectNode(m); if (d = g.compareBoundaryPoints(_START_TO_END, e), d >= 0 && 0 >= c && (c = g.compareBoundaryPoints(_START_TO_START, e)), c >= 0 && 0 >= u && (u = g.compareBoundaryPoints(_END_TO_END, e)), u >= 0 && 0 >= f && (f = g.compareBoundaryPoints(_END_TO_START, e)), f >= 0) return !1; if (p = m.nextSibling, d > 0) if (1 == m.nodeType) if (c >= 0 && 0 >= u) t && h.appendChild(m.cloneNode(!0)), n && s.push(m); else { var _; if (t && (_ = m.cloneNode(!1), h.appendChild(_)), a(m, _) === !1) return !1 } else if (3 == m.nodeType) { var v; if (v = m == l.startContainer ? i(m, l.startOffset, m.nodeValue.length) : m == l.endContainer ? i(m, 0, l.endOffset) : i(m, 0, m.nodeValue.length), t) try { h.appendChild(v) } catch (b) { } } m = p } } var r = e.doc, s = [], l = e.cloneRange().down(), d = -1, c = -1, u = -1, f = -1, h = e.commonAncestor(), p = r.createDocumentFragment(); if (3 == h.nodeType) { var m = i(h, e.startOffset, e.endOffset); return t && p.appendChild(m), o(), t ? p : e } a(h, p), n && e.up().collapse(!0); for (var g = 0, _ = s.length; _ > g; g++) { var v = s[g]; v.parentNode && v.parentNode.removeChild(v) } return t ? p : e } function _moveToElementText(e, t) { for (var n = t; n;) { var i = K(n); if ("marquee" == i.name || "select" == i.name) return; n = n.parentNode } try { e.moveToElementText(t) } catch (o) { } } function _getStartEnd(e, t) { var n = e.parentElement().ownerDocument, i = e.duplicate(); i.collapse(t); var o = i.parentElement(), a = o.childNodes; if (0 === a.length) return { node: o.parentNode, offset: K(o).index() }; var r = n, s = 0, l = -1, d = e.duplicate(); _moveToElementText(d, o); for (var c = 0, u = a.length; u > c; c++) { var f = a[c]; if (l = d.compareEndPoints("StartToStart", i), 0 === l) return { node: f.parentNode, offset: c }; if (1 == f.nodeType) { var h, p = e.duplicate(), m = K(f), g = f; m.isControl() && (h = n.createElement("span"), m.after(h), g = h, s += m.text().replace(/\r\n|\n|\r/g, "").length), _moveToElementText(p, g), d.setEndPoint("StartToEnd", p), l > 0 ? s += p.text.replace(/\r\n|\n|\r/g, "").length : s = 0, h && K(h).remove() } else 3 == f.nodeType && (d.moveStart("character", f.nodeValue.length), s += f.nodeValue.length); 0 > l && (r = f) } if (0 > l && 1 == r.nodeType) return { node: o, offset: K(o.lastChild).index() + 1 }; if (l > 0) for (; r.nextSibling && 1 == r.nodeType;) r = r.nextSibling; if (d = e.duplicate(), _moveToElementText(d, o), d.setEndPoint("StartToEnd", i), s -= d.text.replace(/\r\n|\n|\r/g, "").length, l > 0 && 3 == r.nodeType) for (var _ = r.previousSibling; _ && 3 == _.nodeType;) s -= _.nodeValue.length, _ = _.previousSibling; return { node: r, offset: s } } function _getEndRange(e, t) { var n = e.ownerDocument || e, i = n.body.createTextRange(); if (n == e) return i.collapse(!0), i; if (1 == e.nodeType && e.childNodes.length > 0) { var o, a, r = e.childNodes; if (0 === t ? (a = r[0], o = !0) : (a = r[t - 1], o = !1), !a) return i; if ("head" === K(a).name) return 1 === t && (o = !0), 2 === t && (o = !1), i.collapse(o), i; if (1 == a.nodeType) { var s, l = K(a); return l.isControl() && (s = n.createElement("span"), o ? l.before(s) : l.after(s), a = s), _moveToElementText(i, a), i.collapse(o), s && K(s).remove(), i } e = a, t = o ? 0 : a.nodeValue.length } var d = n.createElement("span"); return K(e).before(d), _moveToElementText(i, d), i.moveStart("character", t), K(d).remove(), i } function _toRange(e) { function t(e) { "tr" == K(e.node).name && (e.node = e.node.cells[e.offset], e.offset = 0) } var n, i; if (_IERANGE) { if (e.item) return n = _getDoc(e.item(0)), i = new KRange(n), i.selectNode(e.item(0)), i; n = e.parentElement().ownerDocument; var o = _getStartEnd(e, !0), a = _getStartEnd(e, !1); return t(o), t(a), i = new KRange(n), i.setStart(o.node, o.offset), i.setEnd(a.node, a.offset), i } var r = e.startContainer; return n = r.ownerDocument || r, i = new KRange(n), i.setStart(r, e.startOffset), i.setEnd(e.endContainer, e.endOffset), i } function KRange(e) { this.init(e) } function _range(e) { return e.nodeName ? new KRange(e) : e.constructor === KRange ? e : _toRange(e) } function _nativeCommand(e, t, n) { try { e.execCommand(t, !1, n) } catch (i) { } } function _nativeCommandValue(e, t) { var n = ""; try { n = e.queryCommandValue(t) } catch (i) { } return "string" != typeof n && (n = ""), n } function _getSel(e) { var t = _getWin(e); return _IERANGE ? e.selection : t.getSelection() } function _getRng(e) { var t, n = _getSel(e); try { t = n.rangeCount > 0 ? n.getRangeAt(0) : n.createRange() } catch (i) { } return !_IERANGE || t && (t.item || t.parentElement().ownerDocument === e) ? t : null } function _singleKeyMap(e) { var t, n, i = {}; return _each(e, function (e, o) { t = e.split(","); for (var a = 0, r = t.length; r > a; a++) n = t[a], i[n] = o }), i } function _hasAttrOrCss(e, t) { return _hasAttrOrCssByKey(e, t, "*") || _hasAttrOrCssByKey(e, t) } function _hasAttrOrCssByKey(e, t, n) { if (n = n || e.name, 1 !== e.type) return !1; var i = _singleKeyMap(t); if (!i[n]) return !1; for (var o = i[n].split(","), a = 0, r = o.length; r > a; a++) { var s = o[a]; if ("*" === s) return !0; var l = /^(\.?)([^=]+)(?:=([^=]*))?$/.exec(s), d = l[1] ? "css" : "attr"; s = l[2]; var c = l[3] || ""; if ("" === c && "" !== e[d](s)) return !0; if ("" !== c && e[d](s) === c) return !0 } return !1 } function _removeAttrOrCss(e, t) { 1 == e.type && (_removeAttrOrCssByKey(e, t, "*"), _removeAttrOrCssByKey(e, t)) } function _removeAttrOrCssByKey(e, t, n) { if (n = n || e.name, 1 === e.type) { var i = _singleKeyMap(t); if (i[n]) { for (var o = i[n].split(","), a = !1, r = 0, s = o.length; s > r; r++) { var l = o[r]; if ("*" === l) { a = !0; break } var d = /^(\.?)([^=]+)(?:=([^=]*))?$/.exec(l); l = d[2], d[1] ? (l = _toCamel(l), e[0].style[l] && (e[0].style[l] = "")) : e.removeAttr(l) } a && e.remove(!0) } } } function _getInnerNode(e) { for (var t = e; t.first() ;) t = t.first(); return t } function _isEmptyNode(e) { return 1 != e.type || e.isSingle() ? !1 : "" === e.html().replace(/<[^>]+>/g, "") } function _mergeWrapper(e, t) { e = e.clone(!0); for (var n = _getInnerNode(e), i = e, o = !1; t;) { for (; i;) i.name === t.name && (_mergeAttrs(i, t.attr(), t.css()), o = !0), i = i.first(); o || n.append(t.clone(!1)), o = !1, t = t.first() } return e } function _wrapNode(e, t) { if (t = t.clone(!0), 3 == e.type) return _getInnerNode(t).append(e.clone(!1)), e.replaceWith(t), t; for (var n, i = e; (n = e.first()) && 1 == n.children().length;) e = n; n = e.first(); for (var o = e.doc.createDocumentFragment() ; n;) o.appendChild(n[0]), n = n.next(); return t = _mergeWrapper(i, t), o.firstChild && _getInnerNode(t).append(o), i.replaceWith(t), t } function _mergeAttrs(e, t, n) { _each(t, function (t, n) { "style" !== t && e.attr(t, n) }), _each(n, function (t, n) { e.css(t, n) }) } function _inPreElement(e) { for (; e && "body" != e.name;) { if (_PRE_TAG_MAP[e.name] || "div" == e.name && e.hasClass("ke-script")) return !0; e = e.parent() } return !1 } function KCmd(e) { this.init(e) } function _cmd(e) { if (e.nodeName) { var t = _getDoc(e); e = _range(t).selectNodeContents(t.body).collapse(!1) } return new KCmd(e) } function _drag(e) { var t = e.moveEl, n = e.moveFn, i = e.clickEl || t, o = e.beforeDrag, a = e.iframeFix === undefined ? !0 : e.iframeFix, r = [document]; a && K("iframe").each(function () { var e = _formatUrl(this.src || "", "absolute"); if (!/^https?:\/\//.test(e)) { var t; try { t = _iframeDoc(this) } catch (n) { } if (t) { var i = K(this).pos(); K(t).data("pos-x", i.x), K(t).data("pos-y", i.y), r.push(t) } } }), i.mousedown(function (e) { function a(e) { e.preventDefault(); var t = K(_getDoc(e.target)), o = _round((t.data("pos-x") || 0) + e.pageX - p), a = _round((t.data("pos-y") || 0) + e.pageY - m); n.call(i, c, u, f, h, o, a) } function s(e) { e.preventDefault() } function l(e) { e.preventDefault(), K(r).unbind("mousemove", a).unbind("mouseup", l).unbind("selectstart", s), d.releaseCapture && d.releaseCapture() } if (0 === e.button || 1 === e.button) { e.stopPropagation(); var d = i.get(), c = _removeUnit(t.css("left")), u = _removeUnit(t.css("top")), f = t.width(), h = t.height(), p = e.pageX, m = e.pageY; o && o(), K(r).mousemove(a).mouseup(l).bind("selectstart", s), d.setCapture && d.setCapture() } }) } function KWidget(e) { this.init(e) } function _widget(e) { return new KWidget(e) } function _iframeDoc(e) { return e = _get(e), e.contentDocument || e.contentWindow.document } function _getInitHtml(e, t, n, i) { var o = ["" === _direction ? "<html>" : '<html dir="' + _direction + '">', '<head><meta charset="utf-8" /><title></title>', "<style>", "html {margin:0;padding:0;}", "body {margin:0;padding:5px;}", 'body, td {font:12px/1.5 "sans serif",tahoma,verdana,helvetica;}', "body, p, div {word-wrap: break-word;}", "p {margin:5px 0;}", "table {border-collapse:collapse;}", "img {border:0;}", "noscript {display:none;}", "table.ke-zeroborder td {border:1px dotted #AAA;}", "img.ke-flash {", "	border:1px solid #AAA;", "	background-image:url(" + e + "common/flash.gif);", "	background-position:center center;", "	background-repeat:no-repeat;", "	width:100px;", "	height:100px;", "}", "img.ke-rm {", "	border:1px solid #AAA;", "	background-image:url(" + e + "common/rm.gif);", "	background-position:center center;", "	background-repeat:no-repeat;", "	width:100px;", "	height:100px;", "}", "img.ke-media {", "	border:1px solid #AAA;", "	background-image:url(" + e + "common/media.gif);", "	background-position:center center;", "	background-repeat:no-repeat;", "	width:100px;", "	height:100px;", "}", "img.ke-anchor {", "	border:1px dashed #666;", "	width:16px;", "	height:16px;", "}", ".ke-script, .ke-noscript, .ke-display-none {", "	display:none;", "	font-size:0;", "	width:0;", "	height:0;", "}", ".ke-pagebreak {", "	border:1px dotted #AAA;", "	font-size:0;", "	height:2px;", "}", "</style>"]; return _isArray(n) || (n = [n]), _each(n, function (e, t) { t && o.push('<link href="' + t + '" rel="stylesheet" />') }), i && o.push("<style>" + i + "</style>"), o.push("</head><body " + (t ? 'class="' + t + '"' : "") + "></body></html>"), o.join("\n") } function _elementVal(e, t) { if (e.hasVal()) { if (t === undefined) { var n = e.val(); return n = n.replace(/(<(?:p|p\s[^>]*)>) *(<\/p>)/gi, "") } return e.val(t) } return e.html(t) } function KEdit(e) { this.init(e) } function _edit(e) { return new KEdit(e) } function _selectToolbar(e, t) { var n = this, i = n.get(e); if (i) { if (i.hasClass("ke-disabled")) return; t(i) } } function KToolbar(e) { this.init(e) } function _toolbar(e) { return new KToolbar(e) } function KMenu(e) { this.init(e) } function _menu(e) { return new KMenu(e) } function KColorPicker(e) { this.init(e) } function _colorpicker(e) { return new KColorPicker(e) } function KUploadButton(e) { this.init(e) } function _uploadbutton(e) { return new KUploadButton(e) } function _createButton(e) { e = e || {}; var t = e.name || "", n = K('<span class="ke-button-common ke-button-outer" title="' + t + '"></span>'), i = K('<input class="ke-button-common ke-button" type="button" value="' + t + '" />'); return e.click && i.click(e.click), n.append(i), n } function KDialog(e) { this.init(e) } function _dialog(e) { return new KDialog(e) } function _tabs(e) { var t = _widget(e), n = t.remove, i = e.afterSelect, o = t.div, a = []; o.addClass("ke-tabs").bind("contextmenu,mousedown,mousemove", function (e) { e.preventDefault() }); var r = K('<ul class="ke-tabs-ul ke-clearfix"></ul>'); return o.append(r), t.add = function (e) { var t = K('<li class="ke-tabs-li">' + e.title + "</li>"); t.data("tab", e), a.push(t), r.append(t) }, t.selectedIndex = 0, t.select = function (e) { t.selectedIndex = e, _each(a, function (n, i) { i.unbind(), n === e ? (i.addClass("ke-tabs-li-selected"), K(i.data("tab").panel).show("")) : (i.removeClass("ke-tabs-li-selected").removeClass("ke-tabs-li-on").mouseover(function () { K(this).addClass("ke-tabs-li-on") }).mouseout(function () { K(this).removeClass("ke-tabs-li-on") }).click(function () { t.select(n) }), K(i.data("tab").panel).hide()) }), i && i.call(t, e) }, t.remove = function () { _each(a, function () { this.remove() }), r.remove(), n.call(t) }, t } function _loadScript(e, t) { var n = document.getElementsByTagName("head")[0] || (_QUIRKS ? document.body : document.documentElement), i = document.createElement("script"); n.appendChild(i), i.src = e, i.charset = "utf-8", i.onload = i.onreadystatechange = function () { this.readyState && "loaded" !== this.readyState || (t && t(), i.onload = i.onreadystatechange = null, n.removeChild(i)) } } function _chopQuery(e) { var t = e.indexOf("?"); return t > 0 ? e.substr(0, t) : e } function _loadStyle(e) { for (var t = document.getElementsByTagName("head")[0] || (_QUIRKS ? document.body : document.documentElement), n = document.createElement("link"), i = _chopQuery(_formatUrl(e, "absolute")), o = K('link[rel="stylesheet"]', t), a = 0, r = o.length; r > a; a++) if (_chopQuery(_formatUrl(o[a].href, "absolute")) === i) return; t.appendChild(n), n.href = e, n.rel = "stylesheet" } function _ajax(e, t, n, i, o) { n = n || "GET", o = o || "json"; var a = window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"); if (a.open(n, e, !0), a.onreadystatechange = function () { if (4 == a.readyState && 200 == a.status && t) { var e = _trim(a.responseText); "json" == o && (e = _json(e)), t(e) } }, "POST" == n) { var r = []; _each(i, function (e, t) { r.push(encodeURIComponent(e) + "=" + encodeURIComponent(t)) }); try { a.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") } catch (s) { } a.send(r.join("&")) } else a.send(null) } function _plugin(e, t) { return e === undefined ? _plugins : t ? void (_plugins[e] = t) : _plugins[e] } function _parseLangKey(e) { var t, n = "core"; return (t = /^(\w+)\.(\w+)$/.exec(e)) && (n = t[1], e = t[2]), { ns: n, key: e } } function _lang(e, t) { if (t = t === undefined ? K.options.langType : t, "string" == typeof e) { if (!_language[t]) return "no language"; var n = e.length - 1; if ("." === e.substr(n)) return _language[t][e.substr(0, n)]; var i = _parseLangKey(e); return _language[t][i.ns][i.key] } _each(e, function (e, n) { var i = _parseLangKey(e); _language[t] || (_language[t] = {}), _language[t][i.ns] || (_language[t][i.ns] = {}), _language[t][i.ns][i.key] = n }) } function _getImageFromRange(e, t) { if (!e.collapsed) { e = e.cloneRange().up(); var n = e.startContainer, i = e.startOffset; if (_WEBKIT || e.isControl()) { var o = K(n.childNodes[i]); if (o && "img" == o.name) return t(o) ? o : void 0 } } } function _bindContextmenuEvent() { var e = this, t = e.edit.doc; K(t).contextmenu(function (t) { if (e.menu && e.hideMenu(), !e.useContextmenu) return void t.preventDefault(); if (0 !== e._contextmenus.length) { var n = 0, i = []; for (_each(e._contextmenus, function () { return "-" == this.title ? void i.push(this) : void (this.cond && this.cond() && (i.push(this), this.width && this.width > n && (n = this.width))) }) ; i.length > 0 && "-" == i[0].title;) i.shift(); for (; i.length > 0 && "-" == i[i.length - 1].title;) i.pop(); var o = null; if (_each(i, function (e) { "-" == this.title && "-" == o.title && delete i[e], o = this }), i.length > 0) { t.preventDefault(); var a = K(e.edit.iframe).pos(), r = _menu({ x: a.x + t.clientX, y: a.y + t.clientY, width: n, css: { visibility: "hidden" }, shadowMode: e.shadowMode }); _each(i, function () { this.title && r.addItem(this) }); var s = _docElement(r.doc), l = r.div.height(); t.clientY + l >= s.clientHeight - 100 && r.pos(r.x, _removeUnit(r.y) - l), r.div.css("visibility", "visible"), e.menu = r } } }) } function _bindNewlineEvent() { function e(e) { for (var t = K(e.commonAncestor()) ; t && (1 != t.type || t.isStyle()) ;) t = t.parent(); return t.name } var t = this, n = t.edit.doc, i = t.newlineTag; if (!(_IE && "br" !== i || _GECKO && 3 > _V && "p" !== i || _OPERA && 9 > _V)) { var o = _toMap("h1,h2,h3,h4,h5,h6,pre,li"), a = _toMap("p,h1,h2,h3,h4,h5,h6,pre,li,blockquote"); K(n).keydown(function (r) { if (!(13 != r.which || r.shiftKey || r.ctrlKey || r.altKey)) { t.cmd.selection(); var s = e(t.cmd.range); if ("marquee" != s && "select" != s) return "br" !== i || o[s] ? void (a[s] || _nativeCommand(n, "formatblock", "<p>")) : (r.preventDefault(), void t.insertHtml("<br />" + (_IE && 9 > _V ? "" : "​"))) } }), K(n).keyup(function (o) { if (!(13 != o.which || o.shiftKey || o.ctrlKey || o.altKey) && "br" != i) { if (_GECKO) { var r = t.cmd.commonAncestor("p"), s = t.cmd.commonAncestor("a"); return void (s && "" == s.text() && (s.remove(!0), t.cmd.range.selectNodeContents(r[0]).collapse(!0), t.cmd.select())) } t.cmd.selection(); var l = e(t.cmd.range); if ("marquee" != l && "select" != l) { a[l] || _nativeCommand(n, "formatblock", "<p>"); var d = t.cmd.commonAncestor("div"); if (d) { for (var c = K("<p></p>"), u = d[0].firstChild; u;) { var f = u.nextSibling; c.append(u), u = f } d.before(c), d.remove(), t.cmd.range.selectNodeContents(c[0]), t.cmd.select() } } } }) } } function _bindTabEvent() { var e = this, t = e.edit.doc; K(t).keydown(function (n) { if (9 == n.which) { if (n.preventDefault(), e.afterTab) return void e.afterTab.call(e, n); var i = e.cmd, o = i.range; o.shrink(), o.collapsed && 1 == o.startContainer.nodeType && (o.insertNode(K("@&nbsp;", t)[0]), i.select()), e.insertHtml("&nbsp;&nbsp;&nbsp;&nbsp;") } }) } function _bindFocusEvent() { var e = this; K(e.edit.textarea[0], e.edit.win).focus(function (t) { e.afterFocus && e.afterFocus.call(e, t) }).blur(function (t) { e.afterBlur && e.afterBlur.call(e, t) }) } function _removeBookmarkTag(e) { return _trim(e.replace(/<span [^>]*id="?__kindeditor_bookmark_\w+_\d+__"?[^>]*><\/span>/gi, "")) } function _removeTempTag(e) { return e.replace(/<div[^>]+class="?__kindeditor_paste__"?[^>]*>[\s\S]*?<\/div>/gi, "") } function _addBookmarkToStack(e, t) { if (0 === e.length) return void e.push(t); var n = e[e.length - 1]; _removeBookmarkTag(t.html) !== _removeBookmarkTag(n.html) && e.push(t) } function _undoToRedo(e, t) {
        var n, i, o = this, a = o.edit, r = a.doc.body; if (0 === e.length) return o;
        a.designMode ? (n = o.cmd.range, i = n.createBookmark(!0), i.html = r.innerHTML) : i = { html: r.innerHTML }, _addBookmarkToStack(t, i); var s = e.pop(); return _removeBookmarkTag(i.html) === _removeBookmarkTag(s.html) && e.length > 0 && (s = e.pop()), a.designMode ? (a.html(s.html), s.start && (n.moveToBookmark(s), o.select())) : K(r).html(_removeBookmarkTag(s.html)), o
    } function KEditor(e) { function t(e, t) { KEditor.prototype[e] === undefined && (n[e] = t), n.options[e] = t } var n = this; n.options = {}, _each(e, function (n, i) { t(n, e[n]) }), _each(K.options, function (e, i) { n[e] === undefined && t(e, i) }); var i = K(n.srcElement || "<textarea/>"); n.width || (n.width = i[0].style.width || i.width()), n.height || (n.height = i[0].style.height || i.height()), t("width", _undef(n.width, n.minWidth)), t("height", _undef(n.height, n.minHeight)), t("width", _addUnit(n.width)), t("height", _addUnit(n.height)), _MOBILE && (!_IOS || 534 > _V) && (n.designMode = !1), n.srcElement = i, n.initContent = "", n.plugin = {}, n.isCreated = !1, n._handlers = {}, n._contextmenus = [], n._undoStack = [], n._redoStack = [], n._firstAddBookmark = !0, n.menu = n.contextmenu = null, n.dialogs = [] } function _editor(e) { return new KEditor(e) } function _create(e, t) { function n(e) { return _each(_plugins, function (t, n) { _isFunction(n) && (n.call(e, KindEditor), e._pluginStatus || (e._pluginStatus = {}), e._pluginStatus[t] = "inited") }), e.create() } if (t = t || {}, t.basePath = _undef(t.basePath, K.basePath), t.themesPath = _undef(t.themesPath, t.basePath + "themes/"), t.langPath = _undef(t.langPath, t.basePath + "lang/"), t.pluginsPath = _undef(t.pluginsPath, t.basePath + "plugins/"), _undef(t.loadStyleMode, K.options.loadStyleMode)) { var i = _undef(t.themeType, K.options.themeType); _loadStyle(t.themesPath + "default/default.css"), _loadStyle(t.themesPath + i + "/" + i + ".css") } var o = K(e); if (o && 0 !== o.length) { if (o.length > 1) return o.each(function () { _create(this, t) }), _instances[0]; t.srcElement = o[0]; var a = new KEditor(t); return _instances.push(a), _language[a.langType] ? n(a) : (_loadScript(a.langPath + a.langType + ".js?ver=" + encodeURIComponent(K.DEBUG ? _TIME : _VERSION), function () { n(a) }), a) } } function _eachEditor(e, t) { K(e).each(function (e, n) { K.each(_instances, function (e, i) { return i && i.srcElement[0] == n ? (t.call(i, e), !1) : void 0 }) }) } if (!window.KindEditor) {
        window.console || (window.console = {}), console.log || (console.log = function () { }); var _VERSION = "4.1.12 (2017-04-12)", _ua = navigator.userAgent.toLowerCase(), _IE = _ua.indexOf("msie") > -1 && -1 == _ua.indexOf("opera"), _NEWIE = -1 == _ua.indexOf("msie") && _ua.indexOf("trident") > -1, _GECKO = _ua.indexOf("gecko") > -1 && -1 == _ua.indexOf("khtml"), _WEBKIT = _ua.indexOf("applewebkit") > -1, _OPERA = _ua.indexOf("opera") > -1, _MOBILE = _ua.indexOf("mobile") > -1, _IOS = /ipad|iphone|ipod/.test(_ua), _QUIRKS = "CSS1Compat" != document.compatMode, _IERANGE = !window.getSelection, _matches = /(?:msie|firefox|webkit|opera)[\/:\s](\d+)/.exec(_ua), _V = _matches ? _matches[1] : "0", _TIME = (new Date).getTime(), _round = Math.round, K = { DEBUG: !1, VERSION: _VERSION, IE: _IE, GECKO: _GECKO, WEBKIT: _WEBKIT, OPERA: _OPERA, V: _V, TIME: _TIME, each: _each, isArray: _isArray, isFunction: _isFunction, inArray: _inArray, inString: _inString, trim: _trim, addUnit: _addUnit, removeUnit: _removeUnit, escape: _escape, unescape: _unescape, toCamel: _toCamel, toHex: _toHex, toMap: _toMap, toArray: _toArray, undef: _undef, invalidUrl: _invalidUrl, addParam: _addParam, extend: _extend, json: _json }, _INLINE_TAG_MAP = _toMap("a,abbr,acronym,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,img,input,ins,kbd,label,map,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"), _BLOCK_TAG_MAP = _toMap("address,applet,blockquote,body,center,dd,dir,div,dl,dt,fieldset,form,frameset,h1,h2,h3,h4,h5,h6,head,hr,html,iframe,ins,isindex,li,map,menu,meta,noframes,noscript,object,ol,p,pre,script,style,table,tbody,td,tfoot,th,thead,title,tr,ul"), _SINGLE_TAG_MAP = _toMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"), _STYLE_TAG_MAP = _toMap("b,basefont,big,del,em,font,i,s,small,span,strike,strong,sub,sup,u"), _CONTROL_TAG_MAP = _toMap("img,table,input,textarea,button"), _PRE_TAG_MAP = _toMap("pre,style,script"), _NOSPLIT_TAG_MAP = _toMap("html,head,body,td,tr,table,ol,ul,li"), _AUTOCLOSE_TAG_MAP = _toMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"), _FILL_ATTR_MAP = _toMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"), _VALUE_TAG_MAP = _toMap("input,button,textarea,select"); K.basePath = _getBasePath(), K.options = { designMode: !0, fullscreenMode: !1, filterMode: !0, wellFormatMode: !0, shadowMode: !0, loadStyleMode: !0, basePath: K.basePath, themesPath: K.basePath + "themes/", langPath: K.basePath + "lang/", pluginsPath: K.basePath + "plugins/", themeType: "default", langType: "zh-CN", urlType: "", newlineTag: "p", resizeType: 2, syncType: "form", pasteType: 2, dialogAlignType: "page", useContextmenu: !0, fullscreenShortcut: !1, bodyClass: "ke-content", indentChar: "	", cssPath: "", cssData: "", minWidth: 650, minHeight: 100, minChangeSize: 50, zIndex: 811213, items: ["source", "|", "undo", "redo", "|", "preview", "print", "template", "code", "cut", "copy", "paste", "plainpaste", "wordpaste", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml", "quickformat", "selectall", "|", "fullscreen", "/", "formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "lineheight", "removeformat", "|", "image", "multiimage", "flash", "media", "insertfile", "table", "hr", "emoticons", "baidumap", "pagebreak", "anchor", "link", "unlink", "|", "about"], noDisableItems: ["source", "fullscreen"], colorTable: [["#E53333", "#E56600", "#FF9900", "#64451D", "#DFC5A4", "#FFE500"], ["#009900", "#006600", "#99BB00", "#B8D100", "#60D978", "#00D5FF"], ["#337FE5", "#003399", "#4C33E5", "#9933E5", "#CC33E5", "#EE33EE"], ["#FFFFFF", "#CCCCCC", "#999999", "#666666", "#333333", "#000000"]], fontSizeTable: ["9px", "10px", "12px", "14px", "16px", "18px", "24px", "32px"], htmlTags: { font: ["id", "class", "color", "size", "face", ".background-color"], span: ["id", "class", ".color", ".background-color", ".font-size", ".font-family", ".background", ".font-weight", ".font-style", ".text-decoration", ".vertical-align", ".line-height"], div: ["id", "class", "align", ".border", ".margin", ".padding", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".font-weight", ".background", ".font-style", ".text-decoration", ".vertical-align", ".margin-left"], table: ["id", "class", "border", "cellspacing", "cellpadding", "width", "height", "align", "bordercolor", ".padding", ".margin", ".border", "bgcolor", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".font-weight", ".font-style", ".text-decoration", ".background", ".width", ".height", ".border-collapse"], "td,th": ["id", "class", "align", "valign", "width", "height", "colspan", "rowspan", "bgcolor", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".font-weight", ".font-style", ".text-decoration", ".vertical-align", ".background", ".border"], a: ["id", "class", "href", "target", "name"], embed: ["id", "class", "src", "width", "height", "type", "loop", "autostart", "quality", ".width", ".height", "align", "allowscriptaccess", "wmode"], img: ["id", "class", "src", "width", "height", "border", "alt", "title", "align", ".width", ".height", ".border"], "p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6": ["id", "class", "align", ".text-align", ".color", ".background-color", ".font-size", ".font-family", ".background", ".font-weight", ".font-style", ".text-decoration", ".vertical-align", ".text-indent", ".margin-left"], pre: ["id", "class"], hr: ["id", "class", ".page-break-after"], "br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del": ["id", "class"], iframe: ["id", "class", "src", "frameborder", "width", "height", ".width", ".height"] }, layout: '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>' }; var _useCapture = !1, _INPUT_KEY_MAP = _toMap("8,9,13,32,46,48..57,59,61,65..90,106,109..111,188,190..192,219..222"), _CURSORMOVE_KEY_MAP = _toMap("33..40"), _CHANGE_KEY_MAP = {}; _each(_INPUT_KEY_MAP, function (e, t) { _CHANGE_KEY_MAP[e] = t }), _each(_CURSORMOVE_KEY_MAP, function (e, t) { _CHANGE_KEY_MAP[e] = t }); var _EVENT_PROPS = "altKey,attrChange,attrName,bubbles,button,cancelable,charCode,clientX,clientY,ctrlKey,currentTarget,data,detail,eventPhase,fromElement,handler,keyCode,metaKey,newValue,offsetX,offsetY,originalTarget,pageX,pageY,prevValue,relatedNode,relatedTarget,screenX,screenY,shiftKey,srcElement,target,toElement,view,wheelDelta,which".split(","); _extend(KEvent, { init: function (e, t) { var n = this, i = e.ownerDocument || e.document || e; if (n.event = t, _each(_EVENT_PROPS, function (e, i) { n[i] = t[i] }), n.target || (n.target = n.srcElement || i), 3 === n.target.nodeType && (n.target = n.target.parentNode), !n.relatedTarget && n.fromElement && (n.relatedTarget = n.fromElement === n.target ? n.toElement : n.fromElement), null == n.pageX && null != n.clientX) { var o = i.documentElement, a = i.body; n.pageX = n.clientX + (o && o.scrollLeft || a && a.scrollLeft || 0) - (o && o.clientLeft || a && a.clientLeft || 0), n.pageY = n.clientY + (o && o.scrollTop || a && a.scrollTop || 0) - (o && o.clientTop || a && a.clientTop || 0) } switch (!n.which && (n.charCode || 0 === n.charCode ? n.charCode : n.keyCode) && (n.which = n.charCode || n.keyCode), !n.metaKey && n.ctrlKey && (n.metaKey = n.ctrlKey), n.which || n.button === undefined || (n.which = 1 & n.button ? 1 : 2 & n.button ? 3 : 4 & n.button ? 2 : 0), n.which) { case 186: n.which = 59; break; case 187: case 107: case 43: n.which = 61; break; case 189: case 45: n.which = 109; break; case 42: n.which = 106; break; case 47: n.which = 111; break; case 78: n.which = 110 } n.which >= 96 && n.which <= 105 && (n.which -= 48) }, preventDefault: function () { var e = this.event; e.preventDefault ? e.preventDefault() : e.returnValue = !1 }, stopPropagation: function () { var e = this.event; e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0 }, stop: function () { this.preventDefault(), this.stopPropagation() } }); var _eventExpendo = "kindeditor_" + _TIME, _eventId = 0, _eventData = {}, _readyFinished = !1; window.attachEvent && window.attachEvent("onunload", function () { _each(_eventData, function (e, t) { t.el && _unbind(t.el) }) }), K.ctrl = _ctrl, K.ready = _ready, K.formatUrl = _formatUrl, K.formatHtml = _formatHtml, K.getCssList = _getCssList, K.getAttrList = _getAttrList, K.mediaType = _mediaType, K.mediaAttrs = _mediaAttrs, K.mediaEmbed = _mediaEmbed, K.mediaImg = _mediaImg, K.clearMsWord = _clearMsWord, K.tmpl = _tmpl; var _getSetAttrDiv = document.createElement("div"); _getSetAttrDiv.setAttribute("className", "t"); var _GET_SET_ATTRIBUTE = "t" !== _getSetAttrDiv.className; K.query = _query, K.queryAll = _queryAll, _extend(KNode, { init: function (e) { var t = this; e = _isArray(e) ? e : [e]; for (var n = 0, i = 0, o = e.length; o > i; i++) e[i] && (t[i] = e[i].constructor === KNode ? e[i][0] : e[i], n++); t.length = n, t.doc = _getDoc(t[0]), t.name = _getNodeName(t[0]), t.type = t.length > 0 ? t[0].nodeType : null, t.win = _getWin(t[0]) }, each: function (e) { for (var t = this, n = 0; n < t.length; n++) if (e.call(t[n], n, t[n]) === !1) return t; return t }, bind: function (e, t) { return this.each(function () { _bind(this, e, t) }), this }, unbind: function (e, t) { return this.each(function () { _unbind(this, e, t) }), this }, fire: function (e) { return this.length < 1 ? this : (_fire(this[0], e), this) }, hasAttr: function (e) { return this.length < 1 ? !1 : !!_getAttr(this[0], e) }, attr: function (e, t) { var n = this; return e === undefined ? _getAttrList(n.outer()) : "object" == typeof e ? (_each(e, function (e, t) { n.attr(e, t) }), n) : t === undefined ? (t = n.length < 1 ? null : _getAttr(n[0], e), null === t ? "" : t) : (n.each(function () { _setAttr(this, e, t) }), n) }, removeAttr: function (e) { return this.each(function () { _removeAttr(this, e) }), this }, get: function (e) { return this.length < 1 ? null : this[e || 0] }, eq: function (e) { return this.length < 1 ? null : this[e] ? new KNode(this[e]) : null }, hasClass: function (e) { return this.length < 1 ? !1 : _hasClass(this[0], e) }, addClass: function (e) { return this.each(function () { _hasClass(this, e) || (this.className = _trim(this.className + " " + e)) }), this }, removeClass: function (e) { return this.each(function () { _hasClass(this, e) && (this.className = _trim(this.className.replace(new RegExp("(^|\\s)" + e + "(\\s|$)"), " "))) }), this }, html: function (e) { var t = this; return e === undefined ? t.length < 1 || 1 != t.type ? "" : _formatHtml(t[0].innerHTML) : (t.each(function () { _setHtml(this, e) }), t) }, text: function () { var e = this; return e.length < 1 ? "" : _IE ? e[0].innerText : e[0].textContent }, hasVal: function () { return this.length < 1 ? !1 : _hasVal(this[0]) }, val: function (e) { var t = this; return e === undefined ? t.length < 1 ? "" : t.hasVal() ? t[0].value : t.attr("value") : (t.each(function () { _hasVal(this) ? this.value = e : _setAttr(this, "value", e) }), t) }, css: function (e, t) { var n = this; return e === undefined ? _getCssList(n.attr("style")) : "object" == typeof e ? (_each(e, function (e, t) { n.css(e, t) }), n) : t === undefined ? n.length < 1 ? "" : n[0].style[_toCamel(e)] || _computedCss(n[0], e) || "" : (n.each(function () { this.style[_toCamel(e)] = t }), n) }, width: function (e) { var t = this; return e === undefined ? t.length < 1 ? 0 : t[0].offsetWidth : t.css("width", _addUnit(e)) }, height: function (e) { var t = this; return e === undefined ? t.length < 1 ? 0 : t[0].offsetHeight : t.css("height", _addUnit(e)) }, opacity: function (e) { return this.each(function () { this.style.opacity === undefined ? this.style.filter = 1 == e ? "" : "alpha(opacity=" + 100 * e + ")" : this.style.opacity = 1 == e ? "" : e }), this }, data: function (e, t) { var n = this; return e = "kindeditor_data_" + e, t === undefined ? n.length < 1 ? null : n[0][e] : (this.each(function () { this[e] = t }), n) }, pos: function () { var e = this, t = e[0], n = 0, i = 0; if (t) if (t.getBoundingClientRect) { var o = t.getBoundingClientRect(), a = _getScrollPos(e.doc); n = o.left + a.x, i = o.top + a.y } else for (; t;) n += t.offsetLeft, i += t.offsetTop, t = t.offsetParent; return { x: _round(n), y: _round(i) } }, clone: function (e) { return new KNode(this.length < 1 ? [] : this[0].cloneNode(e)) }, append: function (e) { return this.each(function () { this.appendChild && this.appendChild(_get(e)) }), this }, appendTo: function (e) { return this.each(function () { _get(e).appendChild(this) }), this }, before: function (e) { return this.each(function () { this.parentNode.insertBefore(_get(e), this) }), this }, after: function (e) { return this.each(function () { this.nextSibling ? this.parentNode.insertBefore(_get(e), this.nextSibling) : this.parentNode.appendChild(_get(e)) }), this }, replaceWith: function (e) { var t = []; return this.each(function (n, i) { _unbind(i); var o = _get(e); i.parentNode.replaceChild(o, i), t.push(o) }), K(t) }, empty: function () { var e = this; return e.each(function (e, t) { for (var n = t.firstChild; n;) { if (!t.parentNode) return; var i = n.nextSibling; n.parentNode.removeChild(n), n = i } }), e }, remove: function (e) { var t = this; return t.each(function (n, i) { if (i.parentNode) { if (_unbind(i), e) for (var o = i.firstChild; o;) { var a = o.nextSibling; i.parentNode.insertBefore(o, i), o = a } i.parentNode.removeChild(i), delete t[n] } }), t.length = 0, t }, show: function (e) { var t = this; return e === undefined && (e = t._originDisplay || ""), "none" != t.css("display") ? t : t.css("display", e) }, hide: function () { var e = this; return e.length < 1 ? e : (e._originDisplay = e[0].style.display, e.css("display", "none")) }, outer: function () { var e = this; if (e.length < 1) return ""; var t, n = e.doc.createElement("div"); return n.appendChild(e[0].cloneNode(!0)), t = _formatHtml(n.innerHTML), n = null, t }, isSingle: function () { return !!_SINGLE_TAG_MAP[this.name] }, isInline: function () { return !!_INLINE_TAG_MAP[this.name] }, isBlock: function () { return !!_BLOCK_TAG_MAP[this.name] }, isStyle: function () { return !!_STYLE_TAG_MAP[this.name] }, isControl: function () { return !!_CONTROL_TAG_MAP[this.name] }, contains: function (e) { return this.length < 1 ? !1 : _contains(this[0], _get(e)) }, parent: function () { if (this.length < 1) return null; var e = this[0].parentNode; return e ? new KNode(e) : null }, children: function () { if (this.length < 1) return new KNode([]); for (var e = [], t = this[0].firstChild; t;) (3 != t.nodeType || "" !== _trim(t.nodeValue)) && e.push(t), t = t.nextSibling; return new KNode(e) }, first: function () { var e = this.children(); return e.length > 0 ? e.eq(0) : null }, last: function () { var e = this.children(); return e.length > 0 ? e.eq(e.length - 1) : null }, index: function () { if (this.length < 1) return -1; for (var e = -1, t = this[0]; t;) e++, t = t.previousSibling; return e }, prev: function () { if (this.length < 1) return null; var e = this[0].previousSibling; return e ? new KNode(e) : null }, next: function () { if (this.length < 1) return null; var e = this[0].nextSibling; return e ? new KNode(e) : null }, scan: function (e, t) { function n(i) { for (var o = t ? i.firstChild : i.lastChild; o;) { var a = t ? o.nextSibling : o.previousSibling; if (e(o) === !1) return !1; if (n(o) === !1) return !1; o = a } } if (!(this.length < 1)) return t = t === undefined ? !0 : t, n(this[0]), this } }), _each("blur,focus,focusin,focusout,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error,contextmenu".split(","), function (e, t) { KNode.prototype[t] = function (e) { return e ? this.bind(t, e) : this.fire(t) } }); var _K = K; K = function (e, t) { function n(e) { return e[0] || (e = []), new KNode(e) } if (e !== undefined && null !== e) { if ("string" == typeof e) { t && (t = _get(t)); var i = e.length; if ("@" === e.charAt(0) && (e = e.substr(1)), e.length !== i || /<.+>/.test(e)) { var o = t ? t.ownerDocument || t : document, a = o.createElement("div"), r = []; a.innerHTML = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + e; for (var s = 0, l = a.childNodes.length; l > s; s++) { var d = a.childNodes[s]; "__kindeditor_temp_tag__" != d.id && r.push(d) } return n(r) } return n(_queryAll(e, t)) } return e && e.constructor === KNode ? e : (e.toArray && (e = e.toArray()), n(_isArray(e) ? e : _toArray(arguments))) } }, _each(_K, function (e, t) { K[e] = t }), K.NodeClass = KNode, window.KindEditor = K; var _START_TO_START = 0, _START_TO_END = 1, _END_TO_END = 2, _END_TO_START = 3, _BOOKMARK_ID = 0; _extend(KRange, { init: function (e) { var t = this; t.startContainer = e, t.startOffset = 0, t.endContainer = e, t.endOffset = 0, t.collapsed = !0, t.doc = e }, commonAncestor: function () { function e(e) { for (var t = []; e;) t.push(e), e = e.parentNode; return t } for (var t, n, i = e(this.startContainer), o = e(this.endContainer), a = 0, r = i.length, s = o.length; ++a && (t = i[r - a], n = o[s - a], t && n && t === n) ;); return i[r - a + 1] }, setStart: function (e, t) { var n = this, i = n.doc; return n.startContainer = e, n.startOffset = t, n.endContainer === i && (n.endContainer = e, n.endOffset = t), _updateCollapsed(this) }, setEnd: function (e, t) { var n = this, i = n.doc; return n.endContainer = e, n.endOffset = t, n.startContainer === i && (n.startContainer = e, n.startOffset = t), _updateCollapsed(this) }, setStartBefore: function (e) { return this.setStart(e.parentNode || this.doc, K(e).index()) }, setStartAfter: function (e) { return this.setStart(e.parentNode || this.doc, K(e).index() + 1) }, setEndBefore: function (e) { return this.setEnd(e.parentNode || this.doc, K(e).index()) }, setEndAfter: function (e) { return this.setEnd(e.parentNode || this.doc, K(e).index() + 1) }, selectNode: function (e) { return this.setStartBefore(e).setEndAfter(e) }, selectNodeContents: function (e) { var t = K(e); if (3 == t.type || t.isSingle()) return this.selectNode(e); var n = t.children(); return n.length > 0 ? this.setStartBefore(n[0]).setEndAfter(n[n.length - 1]) : this.setStart(e, 0).setEnd(e, 0) }, collapse: function (e) { return e ? this.setEnd(this.startContainer, this.startOffset) : this.setStart(this.endContainer, this.endOffset) }, compareBoundaryPoints: function (e, t) { var n = this.get(), i = t.get(); if (!_IERANGE) return n.compareBoundaryPoints(e, i); var o = {}; o[_START_TO_START] = "StartToStart", o[_START_TO_END] = "EndToStart", o[_END_TO_END] = "EndToEnd", o[_END_TO_START] = "StartToEnd"; var a = n.compareEndPoints(o[e], i); if (0 !== a) return a; var r, s, l, d, c; if ((e === _START_TO_START || e === _END_TO_START) && (r = this.startContainer, d = this.startOffset), (e === _START_TO_END || e === _END_TO_END) && (r = this.endContainer, d = this.endOffset), (e === _START_TO_START || e === _START_TO_END) && (s = t.startContainer, c = t.startOffset), (e === _END_TO_END || e === _END_TO_START) && (s = t.endContainer, c = t.endOffset), r === s) { var u = d - c; return u > 0 ? 1 : 0 > u ? -1 : 0 } for (l = s; l && l.parentNode !== r;) l = l.parentNode; if (l) return K(l).index() >= d ? -1 : 1; for (l = r; l && l.parentNode !== s;) l = l.parentNode; return l ? K(l).index() >= c ? 1 : -1 : (l = K(s).next(), l && l.contains(r) ? 1 : (l = K(r).next(), l && l.contains(s) ? -1 : void 0)) }, cloneRange: function () { return new KRange(this.doc).setStart(this.startContainer, this.startOffset).setEnd(this.endContainer, this.endOffset) }, toString: function () { var e = this.get(), t = _IERANGE ? e.text : e.toString(); return t.replace(/\r\n|\n|\r/g, "") }, cloneContents: function () { return _copyAndDelete(this, !0, !1) }, deleteContents: function () { return _copyAndDelete(this, !1, !0) }, extractContents: function () { return _copyAndDelete(this, !0, !0) }, insertNode: function (e) { var t, n, i, o = this, a = o.startContainer, r = o.startOffset, s = o.endContainer, l = o.endOffset, d = 1; return "#document-fragment" === e.nodeName.toLowerCase() && (t = e.firstChild, n = e.lastChild, d = e.childNodes.length), 1 == a.nodeType ? (i = a.childNodes[r], i ? (a.insertBefore(e, i), a === s && (l += d)) : a.appendChild(e)) : 3 == a.nodeType && (0 === r ? (a.parentNode.insertBefore(e, a), a.parentNode === s && (l += d)) : r >= a.nodeValue.length ? a.nextSibling ? a.parentNode.insertBefore(e, a.nextSibling) : a.parentNode.appendChild(e) : (i = r > 0 ? a.splitText(r) : a, a.parentNode.insertBefore(e, i), a === s && (s = i, l -= r))), t ? o.setStartBefore(t).setEndAfter(n) : o.selectNode(e), o.compareBoundaryPoints(_END_TO_END, o.cloneRange().setEnd(s, l)) >= 1 ? o : o.setEnd(s, l) }, surroundContents: function (e) { return e.appendChild(this.extractContents()), this.insertNode(e).selectNode(e) }, isControl: function () { var e = this, t = e.startContainer, n = e.startOffset, i = e.endContainer, o = e.endOffset; return 1 == t.nodeType && t === i && n + 1 === o && K(t.childNodes[n]).isControl() }, get: function (e) { var t, n = this, i = n.doc; if (!_IERANGE) { t = i.createRange(); try { t.setStart(n.startContainer, n.startOffset), t.setEnd(n.endContainer, n.endOffset) } catch (o) { } return t } if (e && n.isControl()) return t = i.body.createControlRange(), t.addElement(n.startContainer.childNodes[n.startOffset]), t; var a = n.cloneRange().down(); return t = i.body.createTextRange(), t.setEndPoint("StartToStart", _getEndRange(a.startContainer, a.startOffset)), t.setEndPoint("EndToStart", _getEndRange(a.endContainer, a.endOffset)), t }, html: function () { return K(this.cloneContents()).outer() }, down: function () { function e(e, n, i) { if (1 == e.nodeType) { var o = K(e).children(); if (0 !== o.length) { var a, r, s, l; n > 0 && (a = o.eq(n - 1)), n < o.length && (r = o.eq(n)), a && 3 == a.type && (s = a[0], l = s.nodeValue.length), r && 3 == r.type && (s = r[0], l = 0), s && (i ? t.setStart(s, l) : t.setEnd(s, l)) } } } var t = this; return e(t.startContainer, t.startOffset, !0), e(t.endContainer, t.endOffset, !1), t }, up: function () { function e(e, n, i) { 3 == e.nodeType && (0 === n ? i ? t.setStartBefore(e) : t.setEndBefore(e) : n == e.nodeValue.length && (i ? t.setStartAfter(e) : t.setEndAfter(e))) } var t = this; return e(t.startContainer, t.startOffset, !0), e(t.endContainer, t.endOffset, !1), t }, enlarge: function (e) { function t(t, i, o) { var a, r = K(t); if (!(3 == r.type || _NOSPLIT_TAG_MAP[r.name] || !e && r.isBlock())) if (0 === i) { for (; !r.prev() && (a = r.parent(), a && !_NOSPLIT_TAG_MAP[a.name] && (e || !a.isBlock())) ;) r = a; o ? n.setStartBefore(r[0]) : n.setEndBefore(r[0]) } else if (i == r.children().length) { for (; !r.next() && (a = r.parent(), a && !_NOSPLIT_TAG_MAP[a.name] && (e || !a.isBlock())) ;) r = a; o ? n.setStartAfter(r[0]) : n.setEndAfter(r[0]) } } var n = this; return n.up(), t(n.startContainer, n.startOffset, !0), t(n.endContainer, n.endOffset, !1), n }, shrink: function () { for (var e, t = this, n = t.collapsed; 1 == t.startContainer.nodeType && (e = t.startContainer.childNodes[t.startOffset]) && 1 == e.nodeType && !K(e).isSingle() ;) t.setStart(e, 0); if (n) return t.collapse(n); for (; 1 == t.endContainer.nodeType && t.endOffset > 0 && (e = t.endContainer.childNodes[t.endOffset - 1]) && 1 == e.nodeType && !K(e).isSingle() ;) t.setEnd(e, e.childNodes.length); return t }, createBookmark: function (e) { var t, n = this, i = n.doc, o = K('<span style="display:none;"></span>', i)[0]; return o.id = "__kindeditor_bookmark_start_" + _BOOKMARK_ID++ + "__", n.collapsed || (t = o.cloneNode(!0), t.id = "__kindeditor_bookmark_end_" + _BOOKMARK_ID++ + "__"), t && n.cloneRange().collapse(!1).insertNode(t).setEndBefore(t), n.insertNode(o).setStartAfter(o), { start: e ? "#" + o.id : o, end: t ? e ? "#" + t.id : t : null } }, moveToBookmark: function (e) { var t = this, n = t.doc, i = K(e.start, n), o = e.end ? K(e.end, n) : null; return !i || i.length < 1 ? t : (t.setStartBefore(i[0]), i.remove(), o && o.length > 0 ? (t.setEndBefore(o[0]), o.remove()) : t.collapse(!0), t) }, dump: function () { console.log("--------------------"), console.log(3 == this.startContainer.nodeType ? this.startContainer.nodeValue : this.startContainer, this.startOffset), console.log(3 == this.endContainer.nodeType ? this.endContainer.nodeValue : this.endContainer, this.endOffset) } }), K.RangeClass = KRange, K.range = _range, K.START_TO_START = _START_TO_START, K.START_TO_END = _START_TO_END, K.END_TO_END = _END_TO_END, K.END_TO_START = _END_TO_START, _extend(KCmd, {
            init: function (e) { var t = this, n = e.doc; t.doc = n, t.win = _getWin(n), t.sel = _getSel(n), t.range = e }, selection: function (e) { var t = this, n = t.doc, i = _getRng(n); return t.sel = _getSel(n), i ? (t.range = _range(i), "html" == K(t.range.startContainer).name && t.range.selectNodeContents(n.body).collapse(!1), t) : (e && t.range.selectNodeContents(n.body).collapse(!1), t) }, select: function (e) { e = _undef(e, !0); var t, n = this, i = n.sel, o = n.range.cloneRange().shrink(), a = o.startContainer, r = o.startOffset, s = (o.endContainer, o.endOffset, _getDoc(a)), l = n.win, d = !1; if (e && 1 == a.nodeType && o.collapsed) { if (_IERANGE) { var c = K("<span>&nbsp;</span>", s); o.insertNode(c[0]), t = s.body.createTextRange(); try { t.moveToElementText(c[0]) } catch (u) { } return t.collapse(!1), t.select(), c.remove(), l.focus(), n } if (_WEBKIT) { var f = a.childNodes; (K(a).isInline() || r > 0 && K(f[r - 1]).isInline() || f[r] && K(f[r]).isInline()) && (o.insertNode(s.createTextNode("​")), d = !0) } } if (_IERANGE) try { t = o.get(!0), t.select() } catch (h) { } else if (d && o.collapse(!1), t = o.get(!0), i.removeAllRanges(), i.addRange(t), s !== document) { var p = K(t.endContainer).pos(); l.scrollTo(p.x, p.y) } return l.focus(), n }, wrap: function (e) { var t, n = this, i = n.doc, o = n.range; if (t = K(e, i), o.collapsed) return o.shrink(), o.insertNode(t[0]).selectNodeContents(t[0]), n; if (t.isBlock()) { for (var a = t.clone(!0), r = a; r.first() ;) r = r.first(); return r.append(o.extractContents()), o.insertNode(a[0]).selectNode(a[0]), n } o.enlarge(); var s = o.createBookmark(), l = o.commonAncestor(), d = !1; return K(l).scan(function (e) { if (!d && e == s.start) return void (d = !0); if (d) { if (e == s.end) return !1; var n = K(e); if (_inPreElement(n)) return; if (3 == n.type && _trim(e.nodeValue).length > 0) { for (var i; (i = n.parent()) && i.isStyle() && 1 == i.children().length;) n = i; _wrapNode(n, t) } } }), o.moveToBookmark(s), n }, split: function (e, t) { for (var n, i = this.range, o = i.doc, a = i.cloneRange().collapse(e), r = a.startContainer, s = a.startOffset, l = 3 == r.nodeType ? r.parentNode : r, d = !1; l && l.parentNode;) { if (n = K(l), t) { if (!n.isStyle()) break; if (!_hasAttrOrCss(n, t)) break } else if (_NOSPLIT_TAG_MAP[n.name]) break; d = !0, l = l.parentNode } if (d) { var c = o.createElement("span"); i.cloneRange().collapse(!e).insertNode(c), e ? a.setStartBefore(l.firstChild).setEnd(r, s) : a.setStart(r, s).setEndAfter(l.lastChild); var u = a.extractContents(), f = u.firstChild, h = u.lastChild; e ? (a.insertNode(u), i.setStartAfter(h).setEndBefore(c)) : (l.appendChild(u), i.setStartBefore(c).setEndBefore(f)); var p = c.parentNode; if (p == i.endContainer) { var m = K(c).prev(), g = K(c).next(); m && g && 3 == m.type && 3 == g.type ? i.setEnd(m[0], m[0].nodeValue.length) : e || i.setEnd(i.endContainer, i.endOffset - 1) } p.removeChild(c) } return this }, remove: function (e) { var t = this, n = t.doc, i = t.range; if (i.enlarge(), 0 === i.startOffset) { for (var o, a = K(i.startContainer) ; (o = a.parent()) && o.isStyle() && 1 == o.children().length;) a = o; i.setStart(a[0], 0), a = K(i.startContainer), a.isBlock() && _removeAttrOrCss(a, e); var r = a.parent(); r && r.isBlock() && _removeAttrOrCss(r, e) } var s, l; if (i.collapsed) { if (t.split(!0, e), s = i.startContainer, l = i.startOffset, l > 0) { var d = K(s.childNodes[l - 1]); d && _isEmptyNode(d) && (d.remove(), i.setStart(s, l - 1)) } var c = K(s.childNodes[l]); return c && _isEmptyNode(c) && c.remove(), _isEmptyNode(s) && (i.startBefore(s), s.remove()), i.collapse(!0), t } t.split(!0, e), t.split(!1, e); var u = n.createElement("span"), f = n.createElement("span"); i.cloneRange().collapse(!1).insertNode(f), i.cloneRange().collapse(!0).insertNode(u); var h = [], p = !1; K(i.commonAncestor()).scan(function (e) { return p || e != u ? e == f ? !1 : void (p && h.push(e)) : void (p = !0) }), K(u).remove(), K(f).remove(), s = i.startContainer, l = i.startOffset; var m = i.endContainer, g = i.endOffset; if (l > 0) { var _ = K(s.childNodes[l - 1]); _ && _isEmptyNode(_) && (_.remove(), i.setStart(s, l - 1), s == m && i.setEnd(m, g - 1)); var v = K(s.childNodes[l]); v && _isEmptyNode(v) && (v.remove(), s == m && i.setEnd(m, g - 1)) } var b = K(m.childNodes[i.endOffset]); b && _isEmptyNode(b) && b.remove(); var y = i.createBookmark(!0); return _each(h, function (t, n) { _removeAttrOrCss(K(n), e) }), i.moveToBookmark(y), t }, commonNode: function (e) { function t(t) { for (var n = t, i = t; i;) { if (_hasAttrOrCss(K(i), e)) return K(i); i = i.parentNode } for (; n && (n = n.lastChild) ;) if (_hasAttrOrCss(K(n), e)) return K(n); return null } var n = this.range, i = n.endContainer, o = n.endOffset, a = 3 == i.nodeType || 0 === o ? i : i.childNodes[o - 1], r = t(a); if (r) return r; if (1 == a.nodeType || 3 == i.nodeType && 0 === o) { var s = K(a).prev(); if (s) return t(s) } return null }, commonAncestor: function (e) { function t(t) { for (; t;) { if (1 == t.nodeType && t.tagName.toLowerCase() === e) return t; t = t.parentNode } return null } var n = this.range, i = n.startContainer, o = n.startOffset, a = n.endContainer, r = n.endOffset, s = 3 == i.nodeType || 0 === o ? i : i.childNodes[o - 1], l = 3 == a.nodeType || 0 === r ? a : a.childNodes[r - 1], d = t(s), c = t(l); return d && c && d === c ? K(d) : null }, state: function (e) { var t = this, n = t.doc, i = !1; try { i = n.queryCommandState(e) } catch (o) { } return i }, val: function (e) { function t(e) { return e.toLowerCase() } var n = this, i = n.doc; n.range; e = t(e); var o, a = ""; return "fontfamily" === e || "fontname" === e ? (a = _nativeCommandValue(i, "fontname"), a = a.replace(/['"]/g, ""), t(a)) : "formatblock" === e ? (a = _nativeCommandValue(i, e), "" === a && (o = n.commonNode({ "h1,h2,h3,h4,h5,h6,p,div,pre,address": "*" }), o && (a = o.name)), "Normal" === a && (a = "p"), t(a)) : "fontsize" === e ? (o = n.commonNode({ "*": ".font-size" }), o && (a = o.css("font-size")), t(a)) : "forecolor" === e ? (o = n.commonNode({ "*": ".color" }), o && (a = o.css("color")), a = _toHex(a), "" === a && (a = "default"), t(a)) : "hilitecolor" === e ? (o = n.commonNode({ "*": ".background-color" }), o && (a = o.css("background-color")), a = _toHex(a), "" === a && (a = "default"), t(a)) : a }, toggle: function (e, t) { var n = this; return n.commonNode(t) ? n.remove(t) : n.wrap(e), n.select() }, bold: function () { return this.toggle("<strong></strong>", { span: ".font-weight=bold", strong: "*", b: "*" }) }, italic: function () { return this.toggle("<em></em>", { span: ".font-style=italic", em: "*", i: "*" }) }, underline: function () { return this.toggle("<u></u>", { span: ".text-decoration=underline", u: "*" }) }, strikethrough: function () { return this.toggle("<s></s>", { span: ".text-decoration=line-through", s: "*" }) }, forecolor: function (e) { return this.wrap('<span style="color:' + e + ';"></span>').select() }, hilitecolor: function (e) { return this.wrap('<span style="background-color:' + e + ';"></span>').select() }, fontsize: function (e) { return this.wrap('<span style="font-size:' + e + ';"></span>').select() }, fontname: function (e) { return this.fontfamily(e) }, fontfamily: function (e) { return this.wrap('<span style="font-family:' + e + ';"></span>').select() }, removeformat: function () { var e = { "*": ".font-weight,.font-style,.text-decoration,.color,.background-color,.font-size,.font-family,.text-indent" }, t = _STYLE_TAG_MAP; return _each(t, function (t, n) { e[t] = "*" }), this.remove(e), this.select() }, inserthtml: function (e, t) { function n(e, t) { t = '<img id="__kindeditor_temp_tag__" width="0" height="0" style="display:none;" />' + t; var n = e.get(); n.item ? n.item(0).outerHTML = t : n.pasteHTML(t); var i = e.doc.getElementById("__kindeditor_temp_tag__"); i.parentNode.removeChild(i); var a = _toRange(n); e.setEnd(a.endContainer, a.endOffset), e.collapse(!1), o.select(!1) } function i(e, t) { var n = e.doc, i = n.createDocumentFragment(); K("@" + t, n).each(function () { i.appendChild(this) }), e.deleteContents(), e.insertNode(i), e.collapse(!1), o.select(!1) } var o = this, a = o.range; if ("" === e) return o; if (_IERANGE && t) { try { n(a, e) } catch (r) { i(a, e) } return o } return i(a, e), o }, hr: function () { return this.inserthtml("<hr />") }, print: function () { return this.win.print(), this }, insertimage: function (e, t, n, i, o, a) { t = _undef(t, ""), o = _undef(o, 0); var r = '<img src="' + _escape(e) + '" data-ke-src="' + _escape(e) + '" '; return n && (r += 'width="' + _escape(n) + '" '), i && (r += 'height="' + _escape(i) + '" '), t && (r += 'title="' + _escape(t) + '" '), a && (r += 'align="' + _escape(a) + '" '), r += 'alt="' + _escape(t) + '" ', r += "/>", this.inserthtml(r) }, createlink: function (e, t) {
                function n(e, t, n) { K(e).attr("href", t).attr("data-ke-src", t), n ? K(e).attr("target", n) : K(e).removeAttr("target") } var i = this, o = i.doc, a = i.range; i.select(); var r = i.commonNode({ a: "*" }); r && !a.isControl() && (a.selectNode(r.get()), i.select()); var s = '<a href="' + _escape(e) + '" data-ke-src="' + _escape(e) + '" '; if (t && (s += ' target="' + _escape(t) + '"'), a.collapsed) return s += ">" + _escape(e) + "</a>", i.inserthtml(s); if (a.isControl()) { var l = K(a.startContainer.childNodes[a.startOffset]); return s += "></a>", l.after(K(s, o)), l.next().append(l), a.selectNode(l[0]), i.select() } var d = a.startContainer, c = a.startOffset, u = a.endContainer, f = a.endOffset;
                if (1 == d.nodeType && d === u && c + 1 === f) { var h = d.childNodes[c]; if ("a" == h.nodeName.toLowerCase()) return n(h, e, t), i } return _nativeCommand(o, "createlink", "__kindeditor_temp_url__"), K('a[href="__kindeditor_temp_url__"]', o).each(function () { n(this, e, t) }), i
            }, unlink: function () { var e = this, t = e.doc, n = e.range; if (e.select(), n.collapsed) { var i = e.commonNode({ a: "*" }); if (i && (n.selectNode(i.get()), e.select()), _nativeCommand(t, "unlink", null), _WEBKIT && "img" === K(n.startContainer).name) { var o = K(n.startContainer).parent(); "a" === o.name && o.remove(!0) } } else _nativeCommand(t, "unlink", null); return e }
        }), _each("formatblock,selectall,justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,indent,outdent,subscript,superscript".split(","), function (e, t) { KCmd.prototype[t] = function (e) { var n = this; return n.select(), _nativeCommand(n.doc, t, e), _IERANGE && _inArray(t, "justifyleft,justifycenter,justifyright,justifyfull".split(",")) >= 0 && n.selection(), (!_IERANGE || _inArray(t, "formatblock,selectall,insertorderedlist,insertunorderedlist".split(",")) >= 0) && n.selection(), n } }), _each("cut,copy,paste".split(","), function (e, t) { KCmd.prototype[t] = function () { var e = this; if (!e.doc.queryCommandSupported(t)) throw "not supported"; return e.select(), _nativeCommand(e.doc, t, null), e } }), K.CmdClass = KCmd, K.cmd = _cmd, _extend(KWidget, { init: function (e) { var t = this; if (t.name = e.name || "", t.doc = e.doc || document, t.win = _getWin(t.doc), t.x = _addUnit(e.x), t.y = _addUnit(e.y), t.z = e.z, t.width = _addUnit(e.width), t.height = _addUnit(e.height), t.div = K('<div style="display:block;"></div>'), t.options = e, t._alignEl = e.alignEl, t.width && t.div.css("width", t.width), t.height && t.div.css("height", t.height), t.z && t.div.css({ position: "absolute", left: t.x, top: t.y, "z-index": t.z }), !t.z || t.x !== undefined && t.y !== undefined || t.autoPos(t.width, t.height), e.cls && t.div.addClass(e.cls), e.shadowMode && t.div.addClass("ke-shadow"), e.css && t.div.css(e.css), e.src ? K(e.src).replaceWith(t.div) : K(t.doc.body).append(t.div), e.html && t.div.html(e.html), e.autoScroll) if (_IE && 7 > _V || _QUIRKS) { var n = _getScrollPos(); K(t.win).bind("scroll", function (e) { var i = _getScrollPos(), o = i.x - n.x, a = i.y - n.y; t.pos(_removeUnit(t.x) + o, _removeUnit(t.y) + a, !1) }) } else t.div.css("position", "fixed") }, pos: function (e, t, n) { var i = this; return n = _undef(n, !0), null !== e && (e = 0 > e ? 0 : _addUnit(e), i.div.css("left", e), n && (i.x = e)), null !== t && (t = 0 > t ? 0 : _addUnit(t), i.div.css("top", t), n && (i.y = t)), i }, autoPos: function (e, t) { var n, i, o = this, a = _removeUnit(e) || 0, r = _removeUnit(t) || 0, s = _getScrollPos(); if (o._alignEl) { var l = K(o._alignEl), d = l.pos(), c = _round(l[0].clientWidth / 2 - a / 2), u = _round(l[0].clientHeight / 2 - r / 2); n = 0 > c ? d.x : d.x + c, i = 0 > u ? d.y : d.y + u } else { var f = _docElement(o.doc); n = _round(s.x + (f.clientWidth - a) / 2), i = _round(s.y + (f.clientHeight - r) / 2) } return _IE && 7 > _V || _QUIRKS || (n -= s.x, i -= s.y), o.pos(n, i) }, remove: function () { var e = this; return (_IE && 7 > _V || _QUIRKS) && K(e.win).unbind("scroll"), e.div.remove(), _each(e, function (t) { e[t] = null }), this }, show: function () { return this.div.show(), this }, hide: function () { return this.div.hide(), this }, draggable: function (e) { var t = this; return e = e || {}, e.moveEl = t.div, e.moveFn = function (e, n, i, o, a, r) { (e += a) < 0 && (e = 0), (n += r) < 0 && (n = 0), t.pos(e, n) }, _drag(e), t } }), K.WidgetClass = KWidget, K.widget = _widget; var html, _direction = ""; (html = document.getElementsByTagName("html")) && (_direction = html[0].dir), _extend(KEdit, KWidget, { init: function (e) { function t() { var t = _iframeDoc(n.iframe); t.open(), s && (t.domain = document.domain), t.write(_getInitHtml(i, o, a, r)), t.close(), n.win = n.iframe[0].contentWindow, n.doc = t; var l = _cmd(t); n.afterChange(function (e) { l.selection() }), _WEBKIT && K(t).click(function (e) { "img" === K(e.target).name && (l.selection(!0), l.range.selectNode(e.target), l.select()) }), _IE && (n._mousedownHandler = function () { var e = l.range.cloneRange(); e.shrink(), e.isControl() && n.blur() }, K(document).mousedown(n._mousedownHandler), K(t).keydown(function (e) { if (8 == e.which) { l.selection(); var t = l.range; t.isControl() && (t.collapse(!0), K(t.startContainer.childNodes[t.startOffset]).remove(), e.preventDefault()) } })), n.cmd = l, n.html(_elementVal(n.srcElement)), _IE ? (t.body.disabled = !0, t.body.contentEditable = !0, t.body.removeAttribute("disabled")) : t.designMode = "on", e.afterCreate && e.afterCreate.call(n) } var n = this; KEdit.parent.init.call(n, e), n.srcElement = K(e.srcElement), n.div.addClass("ke-edit"), n.designMode = _undef(e.designMode, !0), n.beforeGetHtml = e.beforeGetHtml, n.beforeSetHtml = e.beforeSetHtml, n.afterSetHtml = e.afterSetHtml; var i = _undef(e.themesPath, ""), o = e.bodyClass, a = e.cssPath, r = e.cssData, s = "res:" != location.protocol && location.host.replace(/:\d+/, "") !== document.domain, l = "document.open();" + (s ? 'document.domain="' + document.domain + '";' : "") + "document.close();", d = _IE ? ' src="javascript:void(function(){' + encodeURIComponent(l) + '}())"' : ""; n.iframe = K('<iframe class="ke-edit-iframe" hidefocus="true" frameborder="0"' + d + "></iframe>").css("width", "100%"), n.textarea = K('<textarea class="ke-edit-textarea" hidefocus="true"></textarea>').css("width", "100%"), n.tabIndex = isNaN(parseInt(e.tabIndex, 10)) ? n.srcElement.attr("tabindex") : parseInt(e.tabIndex, 10), n.iframe.attr("tabindex", n.tabIndex), n.textarea.attr("tabindex", n.tabIndex), n.width && n.setWidth(n.width), n.height && n.setHeight(n.height), n.designMode ? n.textarea.hide() : n.iframe.hide(), s && n.iframe.bind("load", function (e) { n.iframe.unbind("load"), _IE ? t() : setTimeout(t, 0) }), n.div.append(n.iframe), n.div.append(n.textarea), n.srcElement.hide(), !s && t() }, setWidth: function (e) { var t = this; return e = _addUnit(e), t.width = e, t.div.css("width", e), t }, setHeight: function (e) { var t = this; return e = _addUnit(e), t.height = e, t.div.css("height", e), t.iframe.css("height", e), (_IE && 8 > _V || _QUIRKS) && (e = _addUnit(_removeUnit(e) - 2)), t.textarea.css("height", e), t }, remove: function () { var e = this, t = e.doc; K(t.body).unbind(), K(t).unbind(), K(e.win).unbind(), e._mousedownHandler && K(document).unbind("mousedown", e._mousedownHandler), _elementVal(e.srcElement, e.html()), e.srcElement.show(), e.iframe.unbind(), e.textarea.unbind(), KEdit.parent.remove.call(e) }, html: function (e, t) { var n = this, i = n.doc; if (n.designMode) { var o = i.body; return e === undefined ? (e = t ? "<!doctype html><html>" + o.parentNode.innerHTML + "</html>" : o.innerHTML, n.beforeGetHtml && (e = n.beforeGetHtml(e)), _GECKO && "<br />" == e && (e = ""), e) : (n.beforeSetHtml && (e = n.beforeSetHtml(e)), _IE && _V >= 9 && (e = e.replace(/(<.*?checked=")checked(".*>)/gi, "$1$2")), K(o).html(e), n.afterSetHtml && n.afterSetHtml(), n) } return e === undefined ? n.textarea.val() : (n.textarea.val(e), n) }, design: function (e) { var t, n = this; if (e === undefined ? !n.designMode : e) { if (!n.designMode) { t = n.html(), n.designMode = !0, n.textarea.hide(), n.html(t); var i = n.iframe, o = _removeUnit(n.height); i.height(o - 2), i.show(), setTimeout(function () { i.height(o) }, 0) } } else n.designMode && (t = n.html(), n.designMode = !1, n.html(t), n.iframe.hide(), n.textarea.show()); return n.focus() }, focus: function () { var e = this; return e.designMode ? e.win.focus() : e.textarea[0].focus(), e }, blur: function () { var e = this; if (_IE) { var t = K('<input type="text" style="float:left;width:0;height:0;padding:0;margin:0;border:0;" value="" />', e.div); e.div.append(t), t[0].focus(), t.remove() } else e.designMode ? e.win.blur() : e.textarea[0].blur(); return e }, afterChange: function (e) { function t(t) { setTimeout(function () { e(t) }, 1) } var n = this, i = n.doc, o = i.body; return K(i).keyup(function (t) { t.ctrlKey || t.altKey || !_CHANGE_KEY_MAP[t.which] || e(t) }), K(i).mouseup(e).contextmenu(e), K(n.win).blur(e), K(o).bind("paste", t), K(o).bind("cut", t), n } }), K.EditClass = KEdit, K.edit = _edit, K.iframeDoc = _iframeDoc, _extend(KToolbar, KWidget, { init: function (e) { function t(e) { var t = K(e); return t.hasClass("ke-outline") ? t : t.hasClass("ke-toolbar-icon") ? t.parent() : void 0 } function n(e, n) { var i = t(e.target); if (i) { if (i.hasClass("ke-disabled")) return; if (i.hasClass("ke-selected")) return; i[n]("ke-on") } } var i = this; KToolbar.parent.init.call(i, e), i.disableMode = _undef(e.disableMode, !1), i.noDisableItemMap = _toMap(_undef(e.noDisableItems, [])), i._itemMap = {}, i.div.addClass("ke-toolbar").bind("contextmenu,mousedown,mousemove", function (e) { e.preventDefault() }).attr("unselectable", "on"), i.div.mouseover(function (e) { n(e, "addClass") }).mouseout(function (e) { n(e, "removeClass") }).click(function (e) { var n = t(e.target); if (n) { if (n.hasClass("ke-disabled")) return; i.options.click.call(this, e, n.attr("data-name")) } }) }, get: function (e) { return this._itemMap[e] ? this._itemMap[e] : this._itemMap[e] = K("span.ke-icon-" + e, this.div).parent() }, select: function (e) { return _selectToolbar.call(this, e, function (e) { e.addClass("ke-selected") }), self }, unselect: function (e) { return _selectToolbar.call(this, e, function (e) { e.removeClass("ke-selected").removeClass("ke-on") }), self }, enable: function (e) { var t = this, n = e.get ? e : t.get(e); return n && (n.removeClass("ke-disabled"), n.opacity(1)), t }, disable: function (e) { var t = this, n = e.get ? e : t.get(e); return n && (n.removeClass("ke-selected").addClass("ke-disabled"), n.opacity(.5)), t }, disableAll: function (e, t) { var n = this, i = n.noDisableItemMap; return t && (i = _toMap(t)), (e === undefined ? !n.disableMode : e) ? (K("span.ke-outline", n.div).each(function () { var e = K(this), t = e[0].getAttribute("data-name", 2); i[t] || n.disable(e) }), n.disableMode = !0) : (K("span.ke-outline", n.div).each(function () { var e = K(this), t = e[0].getAttribute("data-name", 2); i[t] || n.enable(e) }), n.disableMode = !1), n } }), K.ToolbarClass = KToolbar, K.toolbar = _toolbar, _extend(KMenu, KWidget, { init: function (e) { var t = this; e.z = e.z || 811213, KMenu.parent.init.call(t, e), t.centerLineMode = _undef(e.centerLineMode, !0), t.div.addClass("ke-menu").bind("click,mousedown", function (e) { e.stopPropagation() }).attr("unselectable", "on") }, addItem: function (e) { var t = this; if ("-" === e.title) return void t.div.append(K('<div class="ke-menu-separator"></div>')); var n = K('<div class="ke-menu-item" unselectable="on"></div>'), i = K('<div class="ke-inline-block ke-menu-item-left"></div>'), o = K('<div class="ke-inline-block ke-menu-item-right"></div>'), a = _addUnit(e.height), r = _undef(e.iconClass, ""); t.div.append(n), a && (n.css("height", a), o.css("line-height", a)); var s; return t.centerLineMode && (s = K('<div class="ke-inline-block ke-menu-item-center"></div>'), a && s.css("height", a)), n.mouseover(function (e) { K(this).addClass("ke-menu-item-on"), s && s.addClass("ke-menu-item-center-on") }).mouseout(function (e) { K(this).removeClass("ke-menu-item-on"), s && s.removeClass("ke-menu-item-center-on") }).click(function (t) { e.click.call(K(this)), t.stopPropagation() }).append(i), s && n.append(s), n.append(o), e.checked && (r = "ke-icon-checked"), "" !== r && i.html('<span class="ke-inline-block ke-toolbar-icon ke-toolbar-icon-url ' + r + '"></span>'), o.html(e.title), t }, remove: function () { var e = this; return e.options.beforeRemove && e.options.beforeRemove.call(e), K(".ke-menu-item", e.div[0]).unbind(), KMenu.parent.remove.call(e), e } }), K.MenuClass = KMenu, K.menu = _menu, _extend(KColorPicker, KWidget, { init: function (e) { var t = this; e.z = e.z || 811213, KColorPicker.parent.init.call(t, e); var n = e.colors || [["#E53333", "#E56600", "#FF9900", "#64451D", "#DFC5A4", "#FFE500"], ["#009900", "#006600", "#99BB00", "#B8D100", "#60D978", "#00D5FF"], ["#337FE5", "#003399", "#4C33E5", "#9933E5", "#CC33E5", "#EE33EE"], ["#FFFFFF", "#CCCCCC", "#999999", "#666666", "#333333", "#000000"]]; t.selectedColor = (e.selectedColor || "").toLowerCase(), t._cells = [], t.div.addClass("ke-colorpicker").bind("click,mousedown", function (e) { e.stopPropagation() }).attr("unselectable", "on"); var i = t.doc.createElement("table"); t.div.append(i), i.className = "ke-colorpicker-table", i.cellPadding = 0, i.cellSpacing = 0, i.border = 0; var o = i.insertRow(0), a = o.insertCell(0); a.colSpan = n[0].length, t._addAttr(a, "", "ke-colorpicker-cell-top"); for (var r = 0; r < n.length; r++) { o = i.insertRow(r + 1); for (var s = 0; s < n[r].length; s++) a = o.insertCell(s), t._addAttr(a, n[r][s], "ke-colorpicker-cell") } }, _addAttr: function (e, t, n) { var i = this; e = K(e).addClass(n), i.selectedColor === t.toLowerCase() && e.addClass("ke-colorpicker-cell-selected"), e.attr("title", t || i.options.noColor), e.mouseover(function (e) { K(this).addClass("ke-colorpicker-cell-on") }), e.mouseout(function (e) { K(this).removeClass("ke-colorpicker-cell-on") }), e.click(function (e) { e.stop(), i.options.click.call(K(this), t) }), t ? e.append(K('<div class="ke-colorpicker-cell-color" unselectable="on"></div>').css("background-color", t)) : e.html(i.options.noColor), K(e).attr("unselectable", "on"), i._cells.push(e) }, remove: function () { var e = this; return _each(e._cells, function () { this.unbind() }), KColorPicker.parent.remove.call(e), e } }), K.ColorPickerClass = KColorPicker, K.colorpicker = _colorpicker, _extend(KUploadButton, { init: function (e) { var t = this, n = K(e.button), i = e.fieldName || "file", o = e.url || "", a = n.val(), r = e.extraParams || {}, s = n[0].className || "", l = e.target || "kindeditor_upload_iframe_" + (new Date).getTime(); e.afterError = e.afterError || function (e) { alert(e) }; var d = []; for (var c in r) d.push('<input type="hidden" name="' + c + '" value="' + r[c] + '" />'); var u = ['<div class="ke-inline-block ' + s + '">', e.target ? "" : '<iframe name="' + l + '" style="display:none;"></iframe>', e.form ? '<div class="ke-upload-area">' : '<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + l + '" action="' + o + '">', '<span class="ke-button-common">', d.join(""), '<input type="button" class="ke-button-common ke-button" value="' + a + '" />', "</span>", '<input type="file" class="ke-upload-file" name="' + i + '" tabindex="-1" />', e.form ? "</div>" : "</form>", "</div>"].join(""), f = K(u, n.doc); n.hide(), n.before(f), t.div = f, t.button = n, t.iframe = e.target ? K('iframe[name="' + l + '"]') : K("iframe", f), t.form = e.form ? K(e.form) : K("form", f), t.fileBox = K(".ke-upload-file", f); var h = e.width || K(".ke-button-common", f).width(); K(".ke-upload-area", f).width(h), t.options = e }, submit: function () { var e = this, t = e.iframe; return t.bind("load", function () { t.unbind(); var n = document.createElement("form"); e.fileBox.before(n), K(n).append(e.fileBox), n.reset(), K(n).remove(!0); var i, o = K.iframeDoc(t), a = o.getElementsByTagName("pre")[0], r = ""; r = a ? a.innerHTML : o.body.innerHTML, r = _unescape(r), t[0].src = "javascript:false"; try { i = K.json(r) } catch (s) { e.options.afterError.call(e, "<!doctype html><html>" + o.body.parentNode.innerHTML + "</html>") } i && e.options.afterUpload.call(e, i) }), e.form[0].submit(), e }, remove: function () { var e = this; return e.fileBox && e.fileBox.unbind(), e.iframe.remove(), e.div.remove(), e.button.show(), e } }), K.UploadButtonClass = KUploadButton, K.uploadbutton = _uploadbutton, _extend(KDialog, KWidget, { init: function (e) { var t = this, n = _undef(e.shadowMode, !0); e.z = e.z || 811213, e.shadowMode = !1, e.autoScroll = _undef(e.autoScroll, !0), KDialog.parent.init.call(t, e); var i = e.title, o = K(e.body, t.doc), a = e.previewBtn, r = e.yesBtn, s = e.noBtn, l = e.closeBtn, d = _undef(e.showMask, !0); t.div.addClass("ke-dialog").bind("click,mousedown", function (e) { e.stopPropagation() }); var c = K('<div class="ke-dialog-content"></div>').appendTo(t.div); _IE && 7 > _V ? t.iframeMask = K('<iframe src="about:blank" class="ke-dialog-shadow"></iframe>').appendTo(t.div) : n && K('<div class="ke-dialog-shadow"></div>').appendTo(t.div); var u = K('<div class="ke-dialog-header"></div>'); c.append(u), u.html(i), t.closeIcon = K('<span class="ke-dialog-icon-close" title="' + l.name + '"></span>').click(l.click), u.append(t.closeIcon), t.draggable({ clickEl: u, beforeDrag: e.beforeDrag }); var f = K('<div class="ke-dialog-body"></div>'); c.append(f), f.append(o); var h = K('<div class="ke-dialog-footer"></div>'); if ((a || r || s) && c.append(h), _each([{ btn: a, name: "preview" }, { btn: r, name: "yes" }, { btn: s, name: "no" }], function () { if (this.btn) { var e = _createButton(this.btn); e.addClass("ke-dialog-" + this.name), h.append(e) } }), t.height && f.height(_removeUnit(t.height) - u.height() - h.height()), t.div.width(t.div.width()), t.div.height(t.div.height()), t.mask = null, d) { var p = _docElement(t.doc), m = Math.max(p.scrollWidth, p.clientWidth), g = Math.max(p.scrollHeight, p.clientHeight); t.mask = _widget({ x: 0, y: 0, z: t.z - 1, cls: "ke-dialog-mask", width: m, height: g }) } t.autoPos(t.div.width(), t.div.height()), t.footerDiv = h, t.bodyDiv = f, t.headerDiv = u, t.isLoading = !1 }, setMaskIndex: function (e) { var t = this; t.mask.div.css("z-index", e) }, showLoading: function (e) { e = _undef(e, ""); var t = this, n = t.bodyDiv; return t.loading = K('<div class="ke-dialog-loading"><div class="ke-inline-block ke-dialog-loading-content" style="margin-top:' + Math.round(n.height() / 3) + 'px;">' + e + "</div></div>").width(n.width()).height(n.height()).css("top", t.headerDiv.height() + "px"), n.css("visibility", "hidden").after(t.loading), t.isLoading = !0, t }, hideLoading: function () { return this.loading && this.loading.remove(), this.bodyDiv.css("visibility", "visible"), this.isLoading = !1, this }, remove: function () { var e = this; return e.options.beforeRemove && e.options.beforeRemove.call(e), e.mask && e.mask.remove(), e.iframeMask && e.iframeMask.remove(), e.closeIcon.unbind(), K("input", e.div).unbind(), K("button", e.div).unbind(), e.footerDiv.unbind(), e.bodyDiv.unbind(), e.headerDiv.unbind(), K("iframe", e.div).each(function () { K(this).remove() }), KDialog.parent.remove.call(e), e } }), K.DialogClass = KDialog, K.dialog = _dialog, K.tabs = _tabs, K.loadScript = _loadScript, K.loadStyle = _loadStyle, K.ajax = _ajax; var _plugins = {}, _language = {}; KEditor.prototype = { lang: function (e) { return _lang(e, this.langType) }, loadPlugin: function (e, t) { var n = this, i = this._pluginStatus; return i || (i = this._pluginStatus = {}), _plugins[e] ? _isFunction(_plugins[e]) ? (i[e] || (_plugins[e].call(n, KindEditor), i[e] = "inited"), t && t.call(n), n) : (setTimeout(function () { n.loadPlugin(e, t) }, 100), n) : (_plugins[e] = "loading", _loadScript(n.pluginsPath + e + "/" + e + ".js?ver=" + encodeURIComponent(K.DEBUG ? _TIME : _VERSION), function () { setTimeout(function () { _plugins[e] && n.loadPlugin(e, t) }, 0) }), n) }, handler: function (e, t) { var n = this; return n._handlers[e] || (n._handlers[e] = []), _isFunction(t) ? (n._handlers[e].push(t), n) : (_each(n._handlers[e], function () { t = this.call(n, t) }), t) }, clickToolbar: function (e, t) { var n = this, i = "clickToolbar" + e; return t === undefined ? n._handlers[i] ? n.handler(i) : (n.loadPlugin(e, function () { n.handler(i) }), n) : n.handler(i, t) }, updateState: function () { var e = this; return _each("justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,subscript,superscript,bold,italic,underline,strikethrough".split(","), function (t, n) { e.cmd.state(n) ? e.toolbar.select(n) : e.toolbar.unselect(n) }), e }, addContextmenu: function (e) { return this._contextmenus.push(e), this }, afterCreate: function (e) { return this.handler("afterCreate", e) }, beforeRemove: function (e) { return this.handler("beforeRemove", e) }, beforeGetHtml: function (e) { return this.handler("beforeGetHtml", e) }, beforeSetHtml: function (e) { return this.handler("beforeSetHtml", e) }, afterSetHtml: function (e) { return this.handler("afterSetHtml", e) }, create: function () { function e() { return 0 === l.height() ? void setTimeout(e, 100) : void t.resize(i, o, !1) } var t = this, n = t.fullscreenMode; if (t.isCreated) return t; if (t.srcElement.data("kindeditor")) return t; t.srcElement.data("kindeditor", "true"), n ? _docElement().style.overflow = "hidden" : _docElement().style.overflow = ""; var i = n ? _docElement().clientWidth + "px" : t.width, o = n ? _docElement().clientHeight + "px" : t.height; (_IE && 8 > _V || _QUIRKS) && (o = _addUnit(_removeUnit(o) + 2)); var a = t.container = K(t.layout); n ? K(document.body).append(a) : t.srcElement.before(a); var r = K(".toolbar", a), s = K(".edit", a), l = t.statusbar = K(".statusbar", a); a.removeClass("container").addClass("ke-container ke-container-" + t.themeType).css("width", i), n ? (a.css({ position: "absolute", left: 0, top: 0, "z-index": 811211 }), _GECKO || (t._scrollPos = _getScrollPos()), window.scrollTo(0, 0), K(document.body).css({ height: "1px", overflow: "hidden" }), K(document.body.parentNode).css("overflow", "hidden"), t._fullscreenExecuted = !0) : (t._fullscreenExecuted && (K(document.body).css({ height: "", overflow: "" }), K(document.body.parentNode).css("overflow", "")), t._scrollPos && window.scrollTo(t._scrollPos.x, t._scrollPos.y)); var d = []; K.each(t.items, function (e, n) { "|" == n ? d.push('<span class="ke-inline-block ke-separator"></span>') : "/" == n ? d.push('<div class="ke-hr"></div>') : (d.push('<span class="ke-outline" data-name="' + n + '" title="' + t.lang(n) + '" unselectable="on">'), d.push('<span class="ke-toolbar-icon ke-toolbar-icon-url ke-icon-' + n + '" unselectable="on"></span></span>')) }); var c = t.toolbar = _toolbar({ src: r, html: d.join(""), noDisableItems: t.noDisableItems, click: function (e, n) { if (e.stop(), t.menu) { var i = t.menu.name; if (t.hideMenu(), i === n) return } t.clickToolbar(n) } }), u = _removeUnit(o) - c.div.height(), f = t.edit = _edit({ height: u > 0 && _removeUnit(o) > t.minHeight ? u : t.minHeight, src: s, srcElement: t.srcElement, designMode: t.designMode, themesPath: t.themesPath, bodyClass: t.bodyClass, cssPath: t.cssPath, cssData: t.cssData, beforeGetHtml: function (e) { return e = t.beforeGetHtml(e), e = _removeBookmarkTag(_removeTempTag(e)), _formatHtml(e, t.filterMode ? t.htmlTags : null, t.urlType, t.wellFormatMode, t.indentChar) }, beforeSetHtml: function (e) { return e = _formatHtml(e, t.filterMode ? t.htmlTags : null, "", !1), t.beforeSetHtml(e) }, afterSetHtml: function () { t.edit = f = this, t.afterSetHtml() }, afterCreate: function () { if (t.edit = f = this, t.cmd = f.cmd, t._docMousedownFn = function (e) { t.menu && t.hideMenu() }, K(f.doc, document).mousedown(t._docMousedownFn), _bindContextmenuEvent.call(t), _bindNewlineEvent.call(t), _bindTabEvent.call(t), _bindFocusEvent.call(t), f.afterChange(function (e) { f.designMode && (t.updateState(), t.addBookmark(), t.options.afterChange && t.options.afterChange.call(t)) }), f.textarea.keyup(function (e) { e.ctrlKey || e.altKey || !_INPUT_KEY_MAP[e.which] || t.options.afterChange && t.options.afterChange.call(t) }), t.readonlyMode && t.readonly(), t.isCreated = !0, "" === t.initContent && (t.initContent = t.html()), t._undoStack.length > 0) { var e = t._undoStack.pop(); e.start && (t.html(e.html), f.cmd.range.moveToBookmark(e), t.select()) } t.afterCreate(), t.options.afterCreate && t.options.afterCreate.call(t) } }); return l.removeClass("statusbar").addClass("ke-statusbar").append('<span class="ke-inline-block ke-statusbar-center-icon"></span>').append('<span class="ke-inline-block ke-statusbar-right-icon"></span>'), t._fullscreenResizeHandler && (K(window).unbind("resize", t._fullscreenResizeHandler), t._fullscreenResizeHandler = null), e(), n ? (t._fullscreenResizeHandler = function (e) { t.isCreated && t.resize(_docElement().clientWidth, _docElement().clientHeight, !1) }, K(window).bind("resize", t._fullscreenResizeHandler), c.select("fullscreen"), l.first().css("visibility", "hidden"), l.last().css("visibility", "hidden")) : (_GECKO && K(window).bind("scroll", function (e) { t._scrollPos = _getScrollPos() }), t.resizeType > 0 ? _drag({ moveEl: a, clickEl: l, moveFn: function (e, n, i, o, a, r) { o += r, t.resize(null, o) } }) : l.first().css("visibility", "hidden"), 2 === t.resizeType ? _drag({ moveEl: a, clickEl: l.last(), moveFn: function (e, n, i, o, a, r) { i += a, o += r, t.resize(i, o) } }) : l.last().css("visibility", "hidden")), t }, remove: function () { var e = this; return e.isCreated ? (e.beforeRemove(), e.srcElement.data("kindeditor", ""), e.menu && e.hideMenu(), _each(e.dialogs, function () { e.hideDialog() }), K(document).unbind("mousedown", e._docMousedownFn), e.toolbar.remove(), e.edit.remove(), e.statusbar.last().unbind(), e.statusbar.unbind(), e.container.remove(), e.container = e.toolbar = e.edit = e.menu = null, e.dialogs = [], e.isCreated = !1, e) : e }, resize: function (e, t, n) { var i = this; if (n = _undef(n, !0), e && (/%/.test(e) || (e = _removeUnit(e), e = e < i.minWidth ? i.minWidth : e), i.container.css("width", _addUnit(e)), n && (i.width = _addUnit(e))), t) { t = _removeUnit(t); var o = _removeUnit(t) - i.toolbar.div.height() - i.statusbar.height(); o = o < i.minHeight ? i.minHeight : o, i.edit.setHeight(o), n && (i.height = _addUnit(t)) } return i }, select: function () { return this.isCreated && this.cmd.select(), this }, html: function (e) { var t = this; return e === undefined ? t.isCreated ? t.edit.html() : _elementVal(t.srcElement) : (t.isCreated ? t.edit.html(e) : _elementVal(t.srcElement, e), t.isCreated && t.cmd.selection(), t) }, fullHtml: function () { return this.isCreated ? this.edit.html(undefined, !0) : "" }, text: function (e) { var t = this; return e === undefined ? _trim(t.html().replace(/<(?!img|embed).*?>/gi, "").replace(/&nbsp;/gi, " ")) : t.html(_escape(e)) }, isEmpty: function () { return "" === _trim(this.text().replace(/\r\n|\n|\r/, "")) }, isDirty: function () { return _trim(this.initContent.replace(/\r\n|\n|\r|t/g, "")) !== _trim(this.html().replace(/\r\n|\n|\r|t/g, "")) }, selectedHtml: function () { var e = this.isCreated ? this.cmd.range.html() : ""; return e = _removeBookmarkTag(_removeTempTag(e)) }, count: function (e) { var t = this; return e = (e || "html").toLowerCase(), "html" === e ? t.html().length : "text" === e ? t.text().replace(/<(?:img|embed).*?>/gi, "K").replace(/\r\n|\n|\r/g, "").length : 0 }, exec: function (e) { e = e.toLowerCase(); var t = this, n = t.cmd, i = _inArray(e, "selectall,copy,paste,print".split(",")) < 0; return i && t.addBookmark(!1), n[e].apply(n, _toArray(arguments, 1)), i && (t.updateState(), t.addBookmark(!1), t.options.afterChange && t.options.afterChange.call(t)), t }, insertHtml: function (e, t) { return this.isCreated ? (e = this.beforeSetHtml(e), this.exec("inserthtml", e, t), this) : this }, appendHtml: function (e) { if (this.html(this.html() + e), this.isCreated) { var t = this.cmd; t.range.selectNodeContents(t.doc.body).collapse(!1), t.select() } return this }, sync: function () { return _elementVal(this.srcElement, this.html()), this }, focus: function () { return this.isCreated ? this.edit.focus() : this.srcElement[0].focus(), this }, blur: function () { return this.isCreated ? this.edit.blur() : this.srcElement[0].blur(), this }, addBookmark: function (e) { e = _undef(e, !0); var t, n = this, i = n.edit, o = i.doc.body, a = _removeTempTag(o.innerHTML); if (e && n._undoStack.length > 0) { var r = n._undoStack[n._undoStack.length - 1]; if (Math.abs(a.length - _removeBookmarkTag(r.html).length) < n.minChangeSize) return n } if (i.designMode && !n._firstAddBookmark) { var s = n.cmd.range; t = s.createBookmark(!0), t.html = _removeTempTag(o.innerHTML), s.moveToBookmark(t) } else t = { html: a }; return n._firstAddBookmark = !1, _addBookmarkToStack(n._undoStack, t), n }, undo: function () { return _undoToRedo.call(this, this._undoStack, this._redoStack) }, redo: function () { return _undoToRedo.call(this, this._redoStack, this._undoStack) }, fullscreen: function (e) { return this.fullscreenMode = e === undefined ? !this.fullscreenMode : e, this.addBookmark(!1), this.remove().create() }, readonly: function (e) { e = _undef(e, !0); var t = this, n = t.edit, i = n.doc; t.designMode ? t.toolbar.disableAll(e, []) : _each(t.noDisableItems, function () { t.toolbar[e ? "disable" : "enable"](this) }), _IE ? i.body.contentEditable = !e : i.designMode = e ? "off" : "on", n.textarea[0].disabled = e }, createMenu: function (e) { var t = this, n = e.name, i = t.toolbar.get(n), o = i.pos(); return e.x = o.x, e.y = o.y + i.height(), e.z = t.options.zIndex, e.shadowMode = _undef(e.shadowMode, t.shadowMode), e.selectedColor !== undefined ? (e.cls = "ke-colorpicker-" + t.themeType, e.noColor = t.lang("noColor"), t.menu = _colorpicker(e)) : (e.cls = "ke-menu-" + t.themeType, e.centerLineMode = !1, t.menu = _menu(e)), t.menu }, hideMenu: function () { return this.menu.remove(), this.menu = null, this }, hideContextmenu: function () { return this.contextmenu.remove(), this.contextmenu = null, this }, createDialog: function (e) { var t = this; e.name; if (e.z = t.options.zIndex, e.shadowMode = _undef(e.shadowMode, t.shadowMode), e.closeBtn = _undef(e.closeBtn, { name: t.lang("close"), click: function (e) { t.hideDialog(), _IE && t.cmd && t.cmd.select() } }), e.noBtn = _undef(e.noBtn, { name: t.lang(e.yesBtn ? "no" : "close"), click: function (e) { t.hideDialog(), _IE && t.cmd && t.cmd.select() } }), "page" != t.dialogAlignType && (e.alignEl = t.container), e.cls = "ke-dialog-" + t.themeType, t.dialogs.length > 0) { var n = t.dialogs[0], i = t.dialogs[t.dialogs.length - 1]; n.setMaskIndex(i.z + 2), e.z = i.z + 3, e.showMask = !1 } var o = _dialog(e); return t.dialogs.push(o), o }, hideDialog: function () { var e = this; if (e.dialogs.length > 0 && e.dialogs.pop().remove(), e.dialogs.length > 0) { var t = e.dialogs[0], n = e.dialogs[e.dialogs.length - 1]; t.setMaskIndex(n.z - 1) } return e }, errorDialog: function (e) { var t = this, n = t.createDialog({ width: 750, title: t.lang("uploadError"), body: '<div style="padding:10px 20px;"><iframe frameborder="0" style="width:708px;height:400px;"></iframe></div>' }), i = K("iframe", n.div), o = K.iframeDoc(i); return o.open(), o.write(e), o.close(), K(o.body).css("background-color", "#FFF"), i[0].contentWindow.focus(), t } }; var _instances = []; K.remove = function (e) { _eachEditor(e, function (e) { this.remove(), _instances.splice(e, 1) }) }, K.sync = function (e) { _eachEditor(e, function () { this.sync() }) }, K.html = function (e, t) { _eachEditor(e, function () { this.html(t) }) }, K.insertHtml = function (e, t) { _eachEditor(e, function () { this.insertHtml(t) }) }, K.appendHtml = function (e, t) { _eachEditor(e, function () { this.appendHtml(t) }) }, _IE && 7 > _V && _nativeCommand(document, "BackgroundImageCache", !0), K.EditorClass = KEditor, K.editor = _editor, K.create = _create, K.instances = _instances, K.plugin = _plugin, K.lang = _lang, _plugin("core", function (e) {
            var t = this, n = { undo: "Z", redo: "Y", bold: "B", italic: "I", underline: "U", print: "P", selectall: "A" }; if (t.afterSetHtml(function () { t.options.afterChange && t.options.afterChange.call(t) }), t.afterCreate(function () { if ("form" == t.syncType) { for (var n = e(t.srcElement), i = !1; n = n.parent() ;) if ("form" == n.name) { i = !0; break } if (i) { n.bind("submit", function (n) { t.sync(), e(window).bind("unload", function () { t.edit.textarea.remove() }) }); var o = e('[type="reset"]', n); o.click(function () { t.html(t.initContent), t.cmd.selection() }), t.beforeRemove(function () { n.unbind(), o.unbind() }) } } }), t.clickToolbar("source", function () { t.edit.designMode ? (t.toolbar.disableAll(!0), t.edit.design(!1), t.toolbar.select("source")) : (t.toolbar.disableAll(!1), t.edit.design(!0), t.toolbar.unselect("source"), _GECKO ? setTimeout(function () { t.cmd.selection() }, 0) : t.cmd.selection()), t.designMode = t.edit.designMode }), t.afterCreate(function () { t.designMode || t.toolbar.disableAll(!0).select("source") }), t.clickToolbar("fullscreen", function () { t.fullscreen() }), t.fullscreenShortcut) { var i = !1; t.afterCreate(function () { if (e(t.edit.doc, t.edit.textarea).keyup(function (e) { 27 == e.which && setTimeout(function () { t.fullscreen() }, 0) }), i) { if (_IE && !t.designMode) return; t.focus() } i || (i = !0) }) } _each("undo,redo".split(","), function (e, i) { n[i] && t.afterCreate(function () { _ctrl(this.edit.doc, n[i], function () { t.clickToolbar(i) }) }), t.clickToolbar(i, function () { t[i]() }) }), t.clickToolbar("formatblock", function () { var e = t.lang("formatblock.formatBlock"), n = { h1: 28, h2: 24, h3: 18, H4: 14, p: 12 }, i = t.cmd.val("formatblock"), o = t.createMenu({ name: "formatblock", width: "en" == t.langType ? 200 : 150 }); _each(e, function (e, a) { var r = "font-size:" + n[e] + "px;"; "h" === e.charAt(0) && (r += "font-weight:bold;"), o.addItem({ title: '<span style="' + r + '" unselectable="on">' + a + "</span>", height: n[e] + 12, checked: i === e || i === a, click: function () { t.select().exec("formatblock", "<" + e + ">").hideMenu() } }) }) }), t.clickToolbar("fontname", function () { var e = t.cmd.val("fontname"), n = t.createMenu({ name: "fontname", width: 150 }); _each(t.lang("fontname.fontName"), function (i, o) { n.addItem({ title: '<span style="font-family: ' + i + ';" unselectable="on">' + o + "</span>", checked: e === i.toLowerCase() || e === o.toLowerCase(), click: function () { t.exec("fontname", i).hideMenu() } }) }) }), t.clickToolbar("fontsize", function () { var e = t.cmd.val("fontsize"), n = t.createMenu({ name: "fontsize", width: 150 }); _each(t.fontSizeTable, function (i, o) { n.addItem({ title: '<span style="font-size:' + o + ';" unselectable="on">' + o + "</span>", height: _removeUnit(o) + 12, checked: e === o, click: function () { t.exec("fontsize", o).hideMenu() } }) }) }), _each("forecolor,hilitecolor".split(","), function (e, n) { t.clickToolbar(n, function () { t.createMenu({ name: n, selectedColor: t.cmd.val(n) || "default", colors: t.colorTable, click: function (e) { t.exec(n, e).hideMenu() } }) }) }), _each("cut,copy,paste".split(","), function (e, n) { t.clickToolbar(n, function () { t.focus(); try { t.exec(n, null) } catch (e) { alert(t.lang(n + "Error")) } }) }), t.clickToolbar("about", function () { var e = '<div style="margin:20px;"><div>KindEditor ' + _VERSION + '</div><div>Copyright &copy; <a href="http://www.kindsoft.net/" target="_blank">kindsoft.net</a> All rights reserved.</div></div>'; t.createDialog({ name: "about", width: 350, title: t.lang("about"), body: e }) }), t.plugin.getSelectedLink = function () { return t.cmd.commonAncestor("a") }, t.plugin.getSelectedImage = function () { return _getImageFromRange(t.edit.cmd.range, function (e) { return !/^ke-\w+$/i.test(e[0].className) }) }, t.plugin.getSelectedFlash = function () { return _getImageFromRange(t.edit.cmd.range, function (e) { return "ke-flash" == e[0].className }) }, t.plugin.getSelectedMedia = function () { return _getImageFromRange(t.edit.cmd.range, function (e) { return "ke-media" == e[0].className || "ke-rm" == e[0].className }) }, t.plugin.getSelectedAnchor = function () { return _getImageFromRange(t.edit.cmd.range, function (e) { return "ke-anchor" == e[0].className }) }, _each("link,image,flash,media,anchor".split(","), function (e, n) {
                var i = n.charAt(0).toUpperCase() + n.substr(1); _each("edit,delete".split(","), function (e, o) {
                    t.addContextmenu({
                        title: t.lang(o + i), click: function () {
                            t.loadPlugin(n, function () {
                                t.plugin[n][o](), t.hideMenu()
                            })
                        }, cond: t.plugin["getSelected" + i], width: 150, iconClass: "edit" == o ? "ke-icon-" + n : undefined
                    })
                }), t.addContextmenu({ title: "-" })
            }), t.plugin.getSelectedTable = function () { return t.cmd.commonAncestor("table") }, t.plugin.getSelectedRow = function () { return t.cmd.commonAncestor("tr") }, t.plugin.getSelectedCell = function () { return t.cmd.commonAncestor("td") }, _each("prop,cellprop,colinsertleft,colinsertright,rowinsertabove,rowinsertbelow,rowmerge,colmerge,rowsplit,colsplit,coldelete,rowdelete,insert,delete".split(","), function (e, n) { var i = _inArray(n, ["prop", "delete"]) < 0 ? t.plugin.getSelectedCell : t.plugin.getSelectedTable; t.addContextmenu({ title: t.lang("table" + n), click: function () { t.loadPlugin("table", function () { t.plugin.table[n](), t.hideMenu() }) }, cond: i, width: 170, iconClass: "ke-icon-table" + n }) }), t.addContextmenu({ title: "-" }), _each("selectall,justifyleft,justifycenter,justifyright,justifyfull,insertorderedlist,insertunorderedlist,indent,outdent,subscript,superscript,hr,print,bold,italic,underline,strikethrough,removeformat,unlink".split(","), function (e, i) { n[i] && t.afterCreate(function () { _ctrl(this.edit.doc, n[i], function () { t.cmd.selection(), t.clickToolbar(i) }) }), t.clickToolbar(i, function () { t.focus().exec(i, null) }) }), t.afterCreate(function () { function n() { i.range.moveToBookmark(o), i.select(), _WEBKIT && (e("div." + s, a).each(function () { e(this).after("<br />").remove(!0) }), e("span.Apple-style-span", a).remove(!0), e("span.Apple-tab-span", a).remove(!0), e("span[style]", a).each(function () { "nowrap" == e(this).css("white-space") && e(this).remove(!0) }), e("meta", a).remove()); var n = a[0].innerHTML; a.remove(), "" !== n && (_WEBKIT && (n = n.replace(/(<br>)\1/gi, "$1")), 2 === t.pasteType && (n = n.replace(/(<(?:p|p\s[^>]*)>) *(<\/p>)/gi, ""), /schemas-microsoft-com|worddocument|mso-\w+/i.test(n) ? n = _clearMsWord(n, t.filterMode ? t.htmlTags : e.options.htmlTags) : (n = _formatHtml(n, t.filterMode ? t.htmlTags : null), n = t.beforeSetHtml(n))), 1 === t.pasteType && (n = n.replace(/&nbsp;/gi, " "), n = n.replace(/\n\s*\n/g, "\n"), n = n.replace(/<br[^>]*>/gi, "\n"), n = n.replace(/<\/p><p[^>]*>/gi, "\n"), n = n.replace(/<[^>]+>/g, ""), n = n.replace(/ {2}/g, " &nbsp;"), "p" == t.newlineTag ? /\n/.test(n) && (n = n.replace(/^/, "<p>").replace(/$/, "<br /></p>").replace(/\n/g, "<br /></p><p>")) : n = n.replace(/\n/g, "<br />$&")), t.insertHtml(n, !0)) } var i, o, a, r = t.edit.doc, s = "__kindeditor_paste__", l = !1; e(r.body).bind("paste", function (d) { if (0 === t.pasteType) return void d.stop(); if (!l) { if (l = !0, e("div." + s, r).remove(), i = t.cmd.selection(), o = i.range.createBookmark(), a = e('<div class="' + s + '"></div>', r).css({ position: "absolute", width: "1px", height: "1px", overflow: "hidden", left: "-1981px", top: e(o.start).pos().y + "px", "white-space": "nowrap" }), e(r.body).append(a), _IE) { var c = i.range.get(!0); c.moveToElementText(a[0]), c.select(), c.execCommand("paste"), d.preventDefault() } else i.range.selectNodeContents(a[0]), i.select(), a[0].tabIndex = -1, a[0].focus(); setTimeout(function () { n(), l = !1 }, 0) } }) }), t.beforeGetHtml(function (e) { return _IE && 8 >= _V && (e = e.replace(/<div\s+[^>]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/gi, function (e, t) { return unescape(t) }), e = e.replace(/(<input)((?:\s+[^>]*)?>)/gi, function (e, t, n) { return /\s+type="[^"]+"/i.test(e) ? e : t + ' type="text"' + n })), e.replace(/(<(?:noscript|noscript\s[^>]*)>)([\s\S]*?)(<\/noscript>)/gi, function (e, t, n, i) { return t + _unescape(n).replace(/\s+/g, " ") + i }).replace(/<img[^>]*class="?ke-(flash|rm|media)"?[^>]*>/gi, function (e) { var t = _getAttrList(e), n = _getCssList(t.style || ""), i = _mediaAttrs(t["data-ke-tag"]), o = _undef(n.width, ""), a = _undef(n.height, ""); return /px/i.test(o) && (o = _removeUnit(o)), /px/i.test(a) && (a = _removeUnit(a)), i.width = _undef(t.width, o), i.height = _undef(t.height, a), _mediaEmbed(i) }).replace(/<img[^>]*class="?ke-anchor"?[^>]*>/gi, function (e) { var t = _getAttrList(e); return '<a name="' + unescape(t["data-ke-name"]) + '"></a>' }).replace(/<div\s+[^>]*data-ke-script-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/gi, function (e, t, n) { return "<script" + unescape(t) + ">" + unescape(n) + "</script>" }).replace(/<div\s+[^>]*data-ke-noscript-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/gi, function (e, t, n) { return "<noscript" + unescape(t) + ">" + unescape(n) + "</noscript>" }).replace(/(<[^>]*)data-ke-src="([^"]*)"([^>]*>)/gi, function (e, t, n, i) { return e = e.replace(/(\s+(?:href|src)=")[^"]*(")/i, function (e, t, i) { return t + _unescape(n) + i }), e = e.replace(/\s+data-ke-src="[^"]*"/i, "") }).replace(/(<[^>]+\s)data-ke-(on\w+="[^"]*"[^>]*>)/gi, function (e, t, n) { return t + n }) }), t.beforeSetHtml(function (e) { return _IE && 8 >= _V && (e = e.replace(/<input[^>]*>|<(select|button)[^>]*>[\s\S]*?<\/\1>/gi, function (e) { var t = _getAttrList(e), n = _getCssList(t.style || ""); return "none" == n.display ? '<div class="ke-display-none" data-ke-input-tag="' + escape(e) + '"></div>' : e })), e.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/gi, function (e) { var n = _getAttrList(e); return n.src = _undef(n.src, ""), n.width = _undef(n.width, 0), n.height = _undef(n.height, 0), _mediaImg(t.themesPath + "common/blank.gif", n) }).replace(/<a[^>]*name="([^"]+)"[^>]*>(?:<\/a>)?/gi, function (e) { var n = _getAttrList(e); return n.href !== undefined ? e : '<img class="ke-anchor" src="' + t.themesPath + 'common/anchor.gif" data-ke-name="' + escape(n.name) + '" />' }).replace(/<script([^>]*)>([\s\S]*?)<\/script>/gi, function (e, t, n) { return '<div class="ke-script" data-ke-script-attr="' + escape(t) + '">' + escape(n) + "</div>" }).replace(/<noscript([^>]*)>([\s\S]*?)<\/noscript>/gi, function (e, t, n) { return '<div class="ke-noscript" data-ke-noscript-attr="' + escape(t) + '">' + escape(n) + "</div>" }).replace(/(<[^>]*)(href|src)="([^"]*)"([^>]*>)/gi, function (e, t, n, i, o) { return e.match(/\sdata-ke-src="[^"]*"/i) ? e : e = t + n + '="' + i + '" data-ke-src="' + _escape(i) + '"' + o }).replace(/(<[^>]+\s)(on\w+="[^"]*"[^>]*>)/gi, function (e, t, n) { return t + "data-ke-" + n }).replace(/<table[^>]*\s+border="0"[^>]*>/gi, function (e) { return e.indexOf("ke-zeroborder") >= 0 ? e : _addClassToTag(e, "ke-zeroborder") }) })
        })
    }
}(window);