(function (e) { if (e.xheditor) return false; e.fn.xheditor = function (z) { var C = []; this.each(function () { if (e.nodeName(this, "TEXTAREA")) if (z === false) { if (this.xheditor) { this.xheditor.remove(); this.xheditor = null } } else if (this.xheditor) C.push(this.xheditor); else { var I = /({.*})/.exec(e(this).attr("class")); if (I) { try { I = eval("(" + I[1] + ")") } catch ($a) { } z = e.extend({}, I, z) } I = new e.xheditor(this, z); if (I.init()) { this.xheditor = I; C.push(I) } } }); if (C.length === 0) C = false; if (C.length === 1) C = C[0]; return C }; var ga = 0, Ja = e.browser.version, y = e.browser.msie, za = e.browser.mozilla, U = e.browser.safari, pb = e.browser.opera, R = false, Aa = true, Ba = false, ab = false, N, na, oa, ha, Z, Ka, ia, La, Ma, Na, V; e("script[src*=xheditor]").each(function () { var z = this.src; if (z.match(/xheditor[^\/]*\.js/i)) { V = z.replace(/[\?#].*$/, "").replace(/(^|[\/\\])[^\/]*$/, "$1"); return false } }); var qb = { 27: "esc", 9: "tab", 32: "space", 13: "enter", 8: "backspace", 145: "scroll", 20: "capslock", 144: "numlock", 19: "pause", 45: "insert", 36: "home", 46: "del", 35: "end", 33: "pageup", 34: "pagedown", 37: "left", 38: "up", 39: "right", 40: "down", 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", 120: "f9", 121: "f10", 122: "f11", 123: "f12" }, rb = ["#FFFFFF", "#CCCCCC", "#C0C0C0", "#999999", "#666666", "#333333", "#000000", "#FFCCCC", "#FF6666", "#FF0000", "#CC0000", "#990000", "#660000", "#330000", "#FFCC99", "#FF9966", "#FF9900", "#FF6600", "#CC6600", "#993300", "#663300", "#FFFF99", "#FFFF66", "#FFCC66", "#FFCC33", "#CC9933", "#996633", "#663333", "#FFFFCC", "#FFFF33", "#FFFF00", "#FFCC00", "#999900", "#666600", "#333300", "#99FF99", "#66FF99", "#33FF33", "#33CC00", "#009900", "#006600", "#003300", "#99FFFF", "#33FFFF", "#66CCCC", "#00CCCC", "#339999", "#336666", "#003333", "#CCFFFF", "#66FFFF", "#33CCFF", "#3366FF", "#3333FF", "#000099", "#000066", "#CCCCFF", "#9999FF", "#6666CC", "#6633FF", "#6600CC", "#333399", "#330099", "#FFCCFF", "#FF99FF", "#CC66CC", "#CC33CC", "#993399", "#663366", "#330033"], sb = [{ n: "p", t: "\u666e\u901a\u6bb5\u843d" }, { n: "h1", t: "\u6807\u98981" }, { n: "h2", t: "\u6807\u98982" }, { n: "h3", t: "\u6807\u98983" }, { n: "h4", t: "\u6807\u98984" }, { n: "h5", t: "\u6807\u98985" }, { n: "h6", t: "\u6807\u98986" }, { n: "pre", t: "\u5df2\u7f16\u6392\u683c\u5f0f" }, { n: "address", t: "\u5730\u5740"}], tb = [{ n: "\u5b8b\u4f53", c: "SimSun" }, { n: "\u4eff\u5b8b\u4f53", c: "FangSong_GB2312" }, { n: "\u9ed1\u4f53", c: "SimHei" }, { n: "\u6977\u4f53", c: "KaiTi_GB2312" }, { n: "\u5fae\u8f6f\u96c5\u9ed1", c: "Microsoft YaHei" }, { n: "Arial" }, { n: "Arial Narrow" }, { n: "Arial Black" }, { n: "Comic Sans MS" }, { n: "Courier New" }, { n: "System" }, { n: "Times New Roman" }, { n: "Tahoma" }, { n: "Verdana"}], S = [{ n: "xx-small", wkn: "x-small", s: "8pt", t: "\u6781\u5c0f" }, { n: "x-small", wkn: "small", s: "10pt", t: "\u7279\u5c0f" }, { n: "small", wkn: "medium", s: "12pt", t: "\u5c0f" }, { n: "medium", wkn: "large", s: "14pt", t: "\u4e2d" }, { n: "large", wkn: "x-large", s: "18pt", t: "\u5927" }, { n: "x-large", wkn: "xx-large", s: "24pt", t: "\u7279\u5927" }, { n: "xx-large", wkn: "-webkit-xxx-large", s: "36pt", t: "\u6781\u5927"}], ub = [{ s: "\u5de6\u5bf9\u9f50", v: "justifyleft" }, { s: "\u5c45\u4e2d", v: "justifycenter" }, { s: "\u53f3\u5bf9\u9f50", v: "justifyright" }, { s: "\u4e24\u7aef\u5bf9\u9f50", v: "justifyfull"}], vb = [{ s: "\u6570\u5b57\u5217\u8868", v: "insertOrderedList" }, { s: "\u7b26\u53f7\u5217\u8868", v: "insertUnorderedList"}], wb = { "default": { name: "\u9ed8\u8ba4", width: 24, height: 24, line: 7, list: { smile: "\u5fae\u7b11", tongue: "\u5410\u820c\u5934", titter: "\u5077\u7b11", laugh: "\u5927\u7b11", sad: "\u96be\u8fc7", wronged: "\u59d4\u5c48", fastcry: "\u5feb\u54ed\u4e86", cry: "\u54ed", wail: "\u5927\u54ed", mad: "\u751f\u6c14", knock: "\u6572\u6253", curse: "\u9a82\u4eba", crazy: "\u6293\u72c2", angry: "\u53d1\u706b", ohmy: "\u60ca\u8bb6", awkward: "\u5c34\u5c2c", panic: "\u60ca\u6050", shy: "\u5bb3\u7f9e", cute: "\u53ef\u601c", envy: "\u7fa1\u6155", proud: "\u5f97\u610f", struggle: "\u594b\u6597", quiet: "\u5b89\u9759", shutup: "\u95ed\u5634", doubt: "\u7591\u95ee", despise: "\u9119\u89c6", sleep: "\u7761\u89c9", bye: "\u518d\u89c1" } } }, pa = { Cut: { t: "\u526a\u5207 (Ctrl+X)" }, Copy: { t: "\u590d\u5236 (Ctrl+C)" }, Paste: { t: "\u7c98\u8d34 (Ctrl+V)" }, Pastetext: { t: "\u7c98\u8d34\u6587\u672c", h: y ? 0 : 1 }, Blocktag: { t: "\u6bb5\u843d\u6807\u7b7e", h: 1 }, Fontface: { t: "\u5b57\u4f53", h: 1 }, FontSize: { t: "\u5b57\u4f53\u5927\u5c0f", h: 1 }, Bold: { t: "\u52a0\u7c97 (Ctrl+B)", s: "Ctrl+B" }, Italic: { t: "\u659c\u4f53 (Ctrl+I)", s: "Ctrl+I" }, Underline: { t: "\u4e0b\u5212\u7ebf (Ctrl+U)", s: "Ctrl+U" }, Strikethrough: { t: "\u5220\u9664\u7ebf" }, FontColor: { t: "\u5b57\u4f53\u989c\u8272", h: 1 }, BackColor: { t: "\u80cc\u666f\u989c\u8272", h: 1 }, SelectAll: { t: "\u5168\u9009 (Ctrl+A)" }, Removeformat: { t: "\u5220\u9664\u6587\u5b57\u683c\u5f0f" }, Align: { t: "\u5bf9\u9f50", h: 1 }, List: { t: "\u5217\u8868", h: 1 }, Outdent: { t: "\u51cf\u5c11\u7f29\u8fdb (Shift+Tab)", s: "Shift+Tab" }, Indent: { t: "\u589e\u52a0\u7f29\u8fdb (Tab)", s: "Tab" }, Link: { t: "\u8d85\u94fe\u63a5 (Ctrl+K)", s: "Ctrl+K", h: 1 }, Unlink: { t: "\u53d6\u6d88\u8d85\u94fe\u63a5" }, Img: { t: "\u56fe\u7247", h: 1 }, Flash: { t: "Flash\u52a8\u753b", h: 1 }, Media: { t: "\u591a\u5a92\u4f53\u6587\u4ef6", h: 1 }, Emot: { t: "\u8868\u60c5", s: "ctrl+e", h: 1 }, Table: { t: "\u8868\u683c", h: 1 }, Source: { t: "\u6e90\u4ee3\u7801" }, Preview: { t: "\u9884\u89c8" }, Print: { t: "\u6253\u5370 (Ctrl+P)", s: "Ctrl+P" }, Fullscreen: { t: "\u5168\u5c4f\u7f16\u8f91 (Esc)", s: "Esc" }, About: { t: "\u5173\u4e8e xhEditor"} }, Oa = { mini: "Bold,Italic,Underline,Strikethrough,|,Align,List,|,Link,Img", simple: "Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,|,Align,List,Outdent,Indent,|,Link,Img,Emot", full: "Cut,Copy,Paste,Pastetext,|,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,|,Align,List,Outdent,Indent,|,Link,Unlink,Img,Flash,Media,Emot,Table,|,Source,Preview,Print,Fullscreen" }; Oa.mfull = Oa.full.replace(/\|(,Align)/i, "/$1"); var xb = { a: "Link", img: "Img", embed: "Embed" }, yb = { "<": "<", ">": ">", '"': """, "\u00ae": "®", "\u00a9": "©" }, zb = /[<>"\u00ae\u00a9]/g; e.xheditor = function (z, C) { function I(a) { a = a.target; var b = xb[a.tagName.toLowerCase()]; if (b) { if (b === "Embed") b = { "application/x-shockwave-flash": "Flash", "application/x-mplayer2": "Media"}[a.type.toLowerCase()]; d.exec(b) } } function $a(a) { if (a.which === 27) { if (Ba) d.removeModal(); else R && d.hidePanel(); return false } } function bb() { setTimeout(d.setSource, 10) } function qa() { d.getSource() } function Ab(a) { var b = o.cleanPaste; if (b === 0 || H || Pa) return true; Pa = true; d.saveBookmark(); var c = e('
', w), h = c[0], p = d.getSel(), m = d.getRng(true); e(w.body).append(c); if (y) { m.moveToElementText(h); m.execCommand("Paste"); a.preventDefault() } else { m.selectNodeContents(h); p.removeAllRanges(); p.addRange(m) } setTimeout(function () { var l = b === 3, i; if (l) i = c.text(); else { i = e(".xhe-paste", c); var j = []; if (i.length === 0) i = c; i.each(function (f, g) { j.push(g.innerHTML) }); i = j.join("
") } c.remove(); d.loadBookmark(); if (l) d.pasteText(i); else { i = d.cleanHTML(i); i = d.cleanWord(i); i = d.formatXHTML(i); d.pasteHTML(i) } Pa = false }, 0) } function Qa(a) { try { d._exec("styleWithCSS", a, true) } catch (b) { try { d._exec("useCSS", !a, true) } catch (c) { } } } function Ra() { if (Sa && !H) { Qa(false); try { d._exec("enableObjectResizing", true, true) } catch (a) { } if (y) try { d._exec("BackgroundImageCache", true, true) } catch (b) { } } } function Bb(a) { if (H || a.which !== 13 || a.shiftKey || a.ctrlKey || a.altKey) return true; a = d.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li"); if (a.is("li")) return true; if (o.forcePtag) a.length === 0 && d._exec("formatblock", "

"); else { d.pasteHTML("
"); y && a.length > 0 && d.getRng().parentElement().childNodes.length === 2 && d.pasteHTML("
"); return false } } function Ta() { if (!za && !U) { ra && T.height("100%").css("height", T.outerHeight() - M.outerHeight()); y && M.hide().show() } } function Cb(a) { a = a.target; if (a.tagName.match(/(img|embed)/i)) { var b = d.getSel(), c = d.getRng(true); c.selectNode(a); b.removeAllRanges(); b.addRange(c) } } function aa(a, b, c) { if (!b) return false; var h = "_xhe_" + b; if (c) { if (Ca) c = ba(c, Ca, O); a.attr(b, O ? ba(c, "abs", O) : c).removeAttr(h).attr(h, c) } return a.attr(h) || a.attr(b) } function Ua() { Aa && d.hidePanel() } function Db(a) { if (H) return true; var b = a.which, c = qb[b]; b = c ? c : String.fromCharCode(b).toLowerCase(); sKey = ""; sKey += a.ctrlKey ? "ctrl+" : ""; sKey += a.altKey ? "alt+" : ""; sKey += a.shiftKey ? "shift+" : ""; sKey += b; a = sa[sKey]; for (var h in a) { h = a[h]; if (e.isFunction(h)) { if (h.call(d) === false) return false } else { d.exec(h); return false } } } function ca(a, b) { var c = typeof a; if (!b) return c != "undefined"; if (b === "array" && a.hasOwnProperty && a instanceof Array) return true; return c === b } function ba(a, b, c) { if (a.match(/^(file|mailto|ftp):/i)) return a; var h = c ? e('')[0] : location; c = h.protocol; var p = h.host, m = h.hostname, l = h.port; h = h.pathname.replace(/\\/g, "/").replace(/[^\/]+$/i, ""); if (l === "") l = "80"; if (h === "") h = "/"; else if (h.charAt(0) !== "/") h = "/" + h; a = e.trim(a); if (b !== "abs") a = a.replace(RegExp(c + "\\/\\/" + m.replace(/\./g, "\\.") + "(?::" + l + ")" + (l === "80" ? "?" : "") + "(/|$)", "i"), "/"); if (b === "rel") a = a.replace(RegExp("^" + h.replace(/([\/\.\+\[\]\(\)])/g, "\\$1"), "i"), ""); if (b !== "rel") { a.match(/^(https?:\/\/|\/)/i) || (a = h + a); if (a.charAt(0) === "/") { m = []; a = a.split("/"); var i = a.length; for (h = 0; h < i; h++) { l = a[h]; if (l === "..") m.pop(); else l !== "" && l !== "." && m.push(l) } a[i - 1] === "" && m.push(""); a = "/" + m.join("/") } } if (b === "abs" && !a.match(/^https?:\/\//i)) a = c + "//" + p + a; return a = a.replace(/(https?:\/\/[^:\/?#]+):80(\/|$)/i, "$1$2") } function cb(a, b) { if (b === "*" || a.match(RegExp(".(" + b.replace(/,/g, "|") + ")$", "i"))) return true; else { alert("\u4e0a\u4f20\u6587\u4ef6\u6269\u5c55\u540d\u5fc5\u9700\u4e3a: " + b); return false } } function db(a) { var b = Math.floor(Math.log(a) / Math.log(1024)); return (a / Math.pow(1024, Math.floor(b))).toFixed(2) + ["Byte", "KB", "MB", "GB", "TB", "PB"][b] } function W() { return false } var d = this, P = e(z), eb = P.closest("form"), M, T, X, $, w, Da, ja, Sa = false, H = false, ra = false, Pa = false, Va, ta = false, fb = "", Q = null, Wa, ua = false, Xa = false, ka = null, da = null, Y = 0, o = d.settings = e.extend({}, { skin: "default", tools: "full", clickCancelDialog: true, linkTag: false, internalScript: false, inlineScript: false, internalStyle: true, inlineStyle: true, showBlocktag: false, forcePtag: true, upLinkExt: "zip,rar,txt", upImgExt: "jpg,jpeg,gif,png", upFlashExt: "swf", upMediaExt: "wmv,avi,wma,mp3,mid", modalWidth: 350, modalHeight: 220, modalTitle: true, defLinkText: "\u70b9\u51fb\u6253\u5f00\u94fe\u63a5", layerShadow: 3, emotMark: false, upBtnText: "\u4e0a\u4f20", cleanPaste: 2, hoverExecDelay: 100, html5Upload: true, upMultiple: 99 }, C), Ea = o.plugins, Fa = []; if (Ea) { pa = e.extend({}, pa, Ea); e.each(Ea, function (a) { Fa.push(a) }); Fa = Fa.join(",") } if (o.tools.match(/^\s*(m?full|simple|mini)\s*$/i)) { var gb = Oa[e.trim(o.tools)]; o.tools = o.tools.match(/m?full/i) && Ea ? gb.replace("Table", "Table," + Fa) : gb } o.tools.match(/(^|,)\s*About\s*(,|$)/i) || (o.tools += ",About"); o.tools = o.tools.split(","); if (o.editorRoot) V = o.editorRoot; V = ba(V, "abs"); if (o.urlBase) o.urlBase = ba(o.urlBase, "abs"); var hb = "xheCSS_" + o.skin, va = "xhe" + ga + "_container", ib = "xhe" + ga + "_Tool", jb = "xhe" + ga + "_iframearea", kb = "xhe" + ga + "_iframe", Ga = "xhe" + ga + "_fixffcursor", wa = "", la = "", Ya = V + "xheditor_skin/" + o.skin + "/", Ha = wb, Ca = o.urlType, O = o.urlBase, ea = o.emotPath; ea = ea ? ea : V + "xheditor_emot/"; var Za = ""; Ha = e.extend({}, Ha, o.emots); ea = ba(ea, "rel", O ? O : null); if (ta = o.showBlocktag) la += " showBlocktag"; var sa = []; this.init = function () { e("#" + hb).length === 0 && e("head").append(''); var a = o.width || z.style.width || P.outerWidth(); Y = o.height || z.style.height || P.outerHeight(); if (ca(Y, "string")) Y = Y.replace(/[^\d]+/g, ""); if (a <= 0 || Y <= 0) { alert("\u5f53\u524dtextarea\u5904\u4e8e\u9690\u85cf\u72b6\u6001\uff0c\u8bf7\u5c06\u4e4b\u663e\u793a\u540e\u518d\u521d\u59cb\u5316xhEditor\uff0c\u6216\u8005\u76f4\u63a5\u8bbe\u7f6etextarea\u7684width\u548cheight\u6837\u5f0f"); return false } if (/^[0-9\.]+$/i.test("" + a)) a += "px"; var b = o.background || z.style.background, c = [''], h, p, m = /\||\//i; e.each(o.tools, function (f, g) { g.match(m) && c.push(''); if (g === "|") c.push(''); else if (g === "/") c.push("
"); else { h = pa[g]; if (!h) return; p = h.c ? h.c : "xheIcon xheBtn" + g; c.push('
'); h.s && d.addShortcuts(h.s, g) } g.match(m) && c.push('') }); c.push('
'); P.after(e('')); M = e("#" + ib); T = e("#" + jb); wa = ''; if (a = o.loadCSS) if (ca(a, "array")) for (var l in a) wa += ''; else wa += a.match(/\s*]*?)?>[\s\S]+?<\/style>\s*/i) ? a : ''; l = "" + wa; if (b) l += ""; l += ''; d.win = X = e("#" + kb)[0].contentWindow; $ = e(X); try { this.doc = w = X.document; Da = e(w); w.open(); w.write(l); w.close(); if (y) w.body.contentEditable = "true"; else w.designMode = "On" } catch (i) { } setTimeout(Ra, 300); d.setSource(); X.setInterval = null; M.append(c.join("")).bind("mousedown contextmenu", W).click(function (f) { var g = e(f.target).closest("a"); if (g.is(".xheEnabled")) { Q = f; d.exec(g.attr("name")) } return false }); M.find(".xheButton").hover(function (f) { var g = e(this), n = o.hoverExecDelay, k = da; da = null; if (n === -1 || ua || !g.is(".xheEnabled")) return false; if (k && k > 10) { ua = true; setTimeout(function () { ua = false }, 100); return false } var q = g.attr("name"); if (pa[q].h !== 1) { d.hidePanel(); return false } if (Xa) n = 0; if (n >= 0) Wa = setTimeout(function () { Q = f; ka = { x: Q.clientX, y: Q.clientY }; d.exec(q) }, n) }, function () { ka = null; Wa && clearTimeout(Wa) }).mousemove(function (f) { if (ka) { var g = { x: f.clientX - ka.x, y: f.clientY - ka.y }; if (Math.abs(g.x) > 1 || Math.abs(g.y) > 1) { if (g.x > 0 && g.y > 0) { g = Math.round(Math.atan(g.y / g.x) / 0.017453293); da = da ? (da + g) / 2 : g } else da = null; ka = { x: f.clientX, y: f.clientY} } } }); N = e("#xhePanel"); na = e("#xheShadow"); oa = e("#xheCntLine"); if (N.length === 0) { N = e('

').mousedown(function (f) { f.stopPropagation() }); na = e('
'); oa = e('
'); setTimeout(function () { e(document.body).append(N).append(na).append(oa) }, 10) } e("#" + va).show(); P.hide(); T.css("height", Y - M.outerHeight()); P.focus(d.focus); eb.submit(qa).bind("reset", bb); e(window).bind("unload beforeunload", qa).bind("resize", Ta); e(document).mousedown(Ua); if (!ab) { e(document).keydown($a); ab = true } $.focus(function () { o.focus && o.focus() }).blur(function () { o.blur && o.blur() }); U && $.click(Cb); Da.mousedown(Ua).keydown(Db).keypress(Bb).dblclick(I).bind("mousedown click", function (f) { P.trigger(f.type) }); if (y) { Da.keydown(function (f) { var g = d.getRng(); if (f.which === 8 && g.item) { e(g.item(0)).remove(); return false } }); var j = function (f) { f = e(f.target); var g; if (g = f.css("width")) f.css("width", "").attr("width", g.replace(/[^0-9%]+/g, "")); if (g = f.css("height")) f.css("height", "").attr("height", g.replace(/[^0-9%]+/g, "")) }; Da.bind("controlselect", function (f) { f = f.target; e.nodeName(f, "IMG") && e(f).unbind("resizeend", j).bind("resizeend", j) }) } b = e(w.documentElement); b.bind("paste", Ab); o.disableContextmenu && b.bind("contextmenu", W); o.html5Upload && b.bind("dragenter dragover", function (f) { var g; if ((g = f.originalEvent.dataTransfer.types) && e.inArray("Files", g) !== -1) return false }).bind("drop", function (f) { f = f.originalEvent.dataTransfer; var g; if (f && (g = f.files) && g.length > 0) { var n, k; f = ["Link", "Img", "Flash", "Media"]; var q = [], r; for (n in f) { k = f[n]; o["up" + k + "Url"] && o["up" + k + "Url"].match(/^[^!].*/i) && q.push(k + ":," + o["up" + k + "Ext"]) } if (q.length === 0) return false; else r = q.join(","); k = function (v) { var s, t; for (n = 0; n < v.length; n++) { s = v[n].fileName.replace(/.+\./, ""); if (s = r.match(RegExp("(\\w+):[^:]*," + s + "(?:,|$)", "i"))) if (t) { if (t !== s[1]) return 2 } else t = s[1]; else return 1 } return t } (g); if (k === 1) alert("\u4e0a\u4f20\u6587\u4ef6\u7684\u6269\u5c55\u540d\u5fc5\u9700\u4e3a\uff1a" + r.replace(/\w+:,/g, "")); else if (k === 2) alert("\u6bcf\u6b21\u53ea\u80fd\u62d6\u653e\u4e0a\u4f20\u540c\u4e00\u7c7b\u578b\u6587\u4ef6"); else k && d.startUpload(g, o["up" + k + "Url"], "*", function (v) { var s = [], t; (t = o.onUpload) && t(v); for (n in v) { t = v[n]; url = ca(t, "string") ? t : t.url; if (url.substr(0, 1) === "!") url = url.substr(1); s.push(url) } d.exec(k); e("#xhe" + k + "Url").val(s.join(" ")); e("#xheSave").click() }); return false } }); (b = o.shortcuts) && e.each(b, function (f, g) { d.addShortcuts(f, g) }); ga++; Sa = true; if (o.fullscreen) d.toggleFullscreen(); else o.sourceMode && setTimeout(d.toggleSource, 20); return true }; this.remove = function () { d.hidePanel(); qa(); P.unbind("focus", d.focus); eb.unbind("submit", qa).unbind("reset", bb); e(window).unbind("unload beforeunload", qa).unbind("resize", Ta); e(document).unbind("mousedown", Ua); e("#" + va).remove(); e("#" + Ga).remove(); P.show(); Sa = false }; this.saveBookmark = function () { if (!H) { var a = d.getRng(); a = a.cloneRange ? a.cloneRange() : a; ja = { top: $.scrollTop(), rng: a} } }; this.loadBookmark = function () { if (!(H || !ja)) { d.focus(); var a = ja.rng; if (y) a.select(); else { var b = d.getSel(); b.removeAllRanges(); b.addRange(a) } $.scrollTop(ja.top); ja = null } }; this.focus = function () { H ? e("#sourceCode", w).focus() : $.focus(); if (y) { var a = d.getRng(); a.parentElement && a.parentElement().ownerDocument !== w && d.setCursorFirst() } return false }; this.setCursorFirst = function (a) { X.scrollTo(0, 0); var b = d.getRng(true), c = w.body, h = c, p; if (a && h.firstChild && (p = h.firstChild.tagName) && p.match(/^p|div|h[1-6]$/i)) h = c.firstChild; y ? b.moveToElementText(h) : b.setStart(h, 0); b.collapse(true); if (y) b.select(); else { a = d.getSel(); a.removeAllRanges(); a.addRange(b) } }; this.getSel = function () { return X.getSelection ? X.getSelection() : w.selection }; this.getRng = function (a) { var b, c; try { if (!a) { b = d.getSel(); c = b.rangeCount > 0 ? b.getRangeAt(0) : b.createRange ? b.createRange() : null } c || (c = w.createRange ? w.createRange() : w.body.createTextRange()) } catch (h) { } return c }; this.getParent = function (a) { var b = d.getRng(), c; if (y) c = b.item ? b.item(0) : b.parentElement(); else { c = b.commonAncestorContainer; if (!b.collapsed) if (b.startContainer === b.endContainer && b.startOffset - b.endOffset < 2 && b.startContainer.hasChildNodes()) c = b.startContainer.childNodes[b.startOffset] } a = a ? a : "*"; c = e(c); c.is(a) || (c = e(c).closest(a)); return c }; this.getSelect = function (a) { var b = d.getSel(), c = d.getRng(), h = true; h = !c || c.item ? false : !b || c.boundingWidth === 0 || c.collapsed; if (a === "text") return h ? "" : c.text || (b.toString ? b.toString() : ""); if (c.cloneContents) { a = e("
"); (c = c.cloneContents()) && a.append(c); c = a.html() } else c = ca(c.item) ? c.item(0).outerHTML : ca(c.htmlText) ? c.htmlText : c.toString(); if (h) c = ""; c = d.processHTML(c, "read"); c = d.cleanHTML(c); return c = d.formatXHTML(c) }; this.pasteHTML = function (a, b) { if (H) return false; d.focus(); a = d.processHTML(a, "write"); var c = d.getSel(), h = d.getRng(); if (b !== undefined) { if (h.item) { var p = h.item(0); h = d.getRng(true); h.moveToElementText(p); h.select() } h.collapse(b) } a += "<" + (y ? "img" : "span") + ' id="_xhe_temp" width="0" height="0" />'; if (h.insertNode) { h.deleteContents(); h.insertNode(h.createContextualFragment(a)) } else { if (c.type.toLowerCase() === "control") { c.clear(); h = d.getRng() } h.pasteHTML(a) } p = e("#_xhe_temp", w); var m = p[0]; if (y) { h.moveToElementText(m); h.select() } else { h.selectNode(m); c.removeAllRanges(); c.addRange(h) } p.remove() }; this.pasteText = function (a, b) { a || (a = ""); a = d.domEncode(a); a = a.replace(/\r?\n/g, "
"); d.pasteHTML(a, b) }; this.appendHTML = function (a) { if (H) return false; d.focus(); a = d.processHTML(a, "write"); e(w.body).append(a) }; this.domEncode = function (a) { return a.replace(zb, function (b) { return yb[b] }) }; this.setSource = function (a) { ja = null; if (typeof a !== "string" && a !== "") a = z.value; if (H) e("#sourceCode", w).val(a); else { if (o.beforeSetSource) a = o.beforeSetSource(a); a = d.cleanHTML(a); a = d.formatXHTML(a); a = d.processHTML(a, "write"); if (y) { w.body.innerHTML = '' + a + "\n"; e("#_xhe_temp", w).remove() } else w.body.innerHTML = a } }; this.processHTML = function (a, b) { if (b === "write") { a = a.replace(/(<(\/?)(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*((\/?)>)/g, function (m, l, i, j, f, g, n) { j = j.toLowerCase(); if (za) if (j === "strong") j = "b"; else { if (j === "em") j = "i" } else if (U) if (j === "strong") { j = "span"; i || (f += ' class="Apple-style-span" style="font-weight: bold;"') } else if (j === "em") { j = "span"; i || (f += ' class="Apple-style-span" style="font-style: italic;"') } else if (j === "u") { j = "span"; i || (f += ' class="Apple-style-span" style="text-decoration: underline;"') } else if (j === "strike") { j = "span"; i || (f += ' class="Apple-style-span" style="text-decoration: line-through;"') } var k, q; if (j === "del") j = "strike"; else if (j === "img") f = f.replace(/\s+emot\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i, function (v, s) { k = s.match(/^(["']?)(.*)\1/)[2]; k = k.split(","); if (!k[1]) { k[1] = k[0]; k[0] = "" } if (k[0] === "default") k[0] = ""; return o.emotMark ? v : "" }); else if (j === "a" && n) g = ">"; else if (j === "table" && !i) { m = f.match(/\s+border\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i); if (!m || m[1].match(/^(["']?)\s*0\s*\1$/)) q = "xhe-border" } var r; f = f.replace(/\s+([\w-]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g, function (v, s, t) { s = s.toLowerCase(); t = t.match(/^(["']?)(.*)\1/)[2]; aft = ""; if (y && s.match(/^(disabled|checked|readonly|selected)$/) && t.match(/^(false|0)$/i)) return ""; if (j === "img" && k && s === "src") return ""; if (s.match(/^(src|href)$/)) { aft = " _xhe_" + s + '="' + t + '"'; if (O) t = ba(t, "abs", O) } if (q && s === "class") { t += " " + q; q = "" } if (U && s === "style") { t = t.replace(/(^|;)\s*(font-size)\s*:\s*([a-z-]+)\s*(;|$)/i, function (A, K, D, F, B) { for (var E, L = 0; L < S.length; L++) { A = S[L]; if (F === A.n) { E = A.wkn; break } } return K + D + ":" + E + B }); if (j === "span" && t.match(/(^|;)\s*(font-family|font-size|color|background-color)\s*:\s*[^;]+\s*(;|$)/i)) r = true } return " " + s + '="' + t + '"' + aft }); if (k) f += ' src="' + ea + (k[0] ? k[0] : "default") + "/" + k[1] + '.gif"'; if (r) f += ' class="Apple-style-span"'; if (q) f += ' class="' + q + '"'; return "<" + i + j + f + g }); if (y) a = a.replace(/'/ig, "'"); if (!U) { var c = function (m, l, i, j) { l = ""; var f, g; if (f = i.match(/font-family\s*:\s*([^;"]+)/i)) l += ' face="' + f[1] + '"'; if (f = i.match(/font-size\s*:\s*([^;"]+)/i)) { f = f[1].toLowerCase(); for (var n = 0; n < S.length; n++) if (f === S[n].n || f === S[n].s) { g = n + 1; break } if (g) { l += ' size="' + g + '"'; i = i.replace(/(^|;)(\s*font-size\s*:\s*[^;"]+;?)+/ig, "$1") } } if (g = i.match(/(?:^|[\s;])color\s*:\s*([^;"]+)/i)) { if (f = g[1].match(/\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i)) { g[1] = "#"; for (n = 1; n <= 3; n++) g[1] += (f[n] - 0).toString(16) } g[1] = g[1].replace(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3"); l += ' color="' + g[1] + '"' } i = i.replace(/(^|;)(\s*(font-family|color)\s*:\s*[^;"]+;?)+/ig, "$1"); if (l !== "") { if (i) l += ' style="' + i + '"'; return "" + j + "" } else return m }; a = a.replace(/<(span)(?:\s+[^>]*?)?\s+style\s*=\s*"((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]*)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig, c); a = a.replace(/<(span)(?:\s+[^>]*?)?\s+style\s*=\s*"((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]*)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig, c); a = a.replace(/<(span)(?:\s+[^>]*?)?\s+style\s*=\s*"((?:[^"]*?;)*\s*(?:font-family|font-size|color)\s*:[^"]*)"(?: [^>]*)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, c) } } else { if (U) { var h = [{ r: /font-weight:\sbold/ig, t: "strong" }, { r: /font-style:\sitalic/ig, t: "em" }, { r: /text-decoration:\sunderline/ig, t: "u" }, { r: /text-decoration:\sline-through/ig, t: "strike"}]; c = function (m, l, i, j, f) { l = i + j; i = ""; if (!l) return f; for (j = 0; j < h.length; j++) if (l.match(h[j].r)) { i = h[j].t; break } return i ? "<" + i + ">" + f + "" : m }; for (var p = 0; p < 2; p++) { a = a.replace(/<(span)(\s+[^>]*?)?\s+class\s*=\s*"Apple-style-span"(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig, c); a = a.replace(/<(span)(\s+[^>]*?)?\s+class\s*=\s*"Apple-style-span"(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig, c); a = a.replace(/<(span)(\s+[^>]*?)?\s+class\s*=\s*"Apple-style-span"(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, c) } } a = a.replace(/(<(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/g, function (m, l, i, j, f) { i = i.toLowerCase(); var g; j = j.replace(/\s+_xhe_(?:src|href)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i, function (n, k) { g = k.match(/^(["']?)(.*)\1/)[2]; return "" }); if (g && Ca) g = ba(g, Ca, O); j = j.replace(/\s+([\w-]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g, function (n, k, q) { k = k.toLowerCase(); q = q.match(/^(["']?)(.*)\1/)[2]; if (k === "class") { if (q.match(/^["']?(apple|webkit)/i)) return ""; if (i === "table") { q = q.replace(/\s?xhe-border/ig, ""); if (q === "") return "" } } else if (k.match(/^((_xhe_|_moz_|_webkit_)|jquery\d+)/i)) return ""; else if (g && k.match(/^(src|href)$/i)) return " " + k + '="' + g + '"'; else if (U && k === "style") q = q.replace(/(^|;)\s*(font-size)\s*:\s*([a-z-]+)\s*(;|$)/i, function (r, v, s, t, A) { for (var K, D = 0; D < S.length; D++) { r = S[D]; if (t === r.wkn) { K = r.n; break } } return v + s + ":" + K + A }); return " " + k + '="' + q + '"' }); if (i === "img" && !j.match(/\s+alt\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i)) j += ' alt=""'; return l + j + f }) } return a }; this.getSource = function (a) { var b, c = o.beforeGetSource; if (H) { b = e("#sourceCode", w).val(); c || (b = b.replace(/(?:(?!<(?:script|style)(?:\s+[^>]*?)?>)[\s\S])+|<(script|style)(?:\s+[^>]*?)?>[\s\S]+<\/\1>/g, function (h) { return h.match(/^<(script|style)(?:\s+[^>]*?)?>/i) ? h : h.replace(/(\t*\r?\n\t*)+/g, "") })) } else { b = d.processHTML(w.body.innerHTML, "read"); b = b.replace(/^\s*(?:<(p|div)(?:\s+[^>]*?)?>)?\s*(]*?)?>| )*\s*(?:<\/\1>)?\s*$/i, ""); b = d.cleanHTML(b); b = d.formatXHTML(b, a); if (c) b = c(b) } return z.value = b }; this.cleanWord = function (a) { var b = o.cleanPaste; if (b > 0 && b < 3 && a.match(/mso(-|normal)|WordDocument|||]*?)?>[\s\S]*?<\/style>/ig, ""); a = a.replace(/\r?\n/ig, ""); a = a.replace(/(<(\/?)([\w:]+))((?:\s[\w-:]+="[^"]*")*)\s*(\/?>)/ig, function (h, p, m, l, i, j) { l = l.toLowerCase(); if (l.match(/^(link|img)$/) && i.match(/file:\/\//i) || l.match(/:/) || l === "span" && b === 2) return ""; if (!m) { i = i.replace(/\s([\w-:]+)="\s*([^"]*)\s*"/ig, function (f, g, n) { g = g.toLowerCase(); if (g.match(/:/)) return ""; else if (g.match(/^(class|lang|language|span)$/)) return ""; else if (l === "td" && (g === "height" || g === "width" && !i.match(/\scolspan="\d+"/i))) return ""; else if (g === "style") { if (b === 2) return ""; return (n = e.trim(n.replace(/\s*(mso-[^:]+:.+?|margin\s*:\s*0cm 0cm 0pt\s*|(text-align|font-variant|line-height)\s*:\s*.+?)(;|$)\s*/ig, ""))) ? " " + g + '="' + n + '"' : "" } return f }); if (l === "a" && !i.match(/\s+href\s*=/)) return "" } return p + i + j }); for (var c = 0; c < 3; c++) a = a.replace(/<([^\s>]+)(\s+[^>]*)?>\s*<\/\1>/g, "") } return a }; this.cleanHTML = function (a) { a = a.replace(/]*?)?>/ig, ""); var b; a = a.replace(/]*?)?>([\s\S]*?)<\/head>/i, function (c, h) { b = h.match(/<(script|style)(\s+[^>]*?)?>[\s\S]*?<\/\1>/ig); return "" }); if (b) a = b.join("") + a; a = a.replace(/<\??xml(:\w+)?(\s+[^>]*?)?>([\s\S]*?<\/xml>)?/ig, ""); o.internalScript || (a = a.replace(/]*?)?>[\s\S]*?<\/script>/ig, "")); o.internalStyle || (a = a.replace(/]*?)?>[\s\S]*?<\/style>/ig, "")); if (!o.linkTag || !o.inlineScript || !o.inlineStyle) a = a.replace(/(<(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/ig, function (c, h, p, m, l) { if (!o.linkTag && p.toLowerCase() === "link") return ""; o.inlineScript || (m = m.replace(/\s+on(?:click|dblclick|mouse(down|up|move|over|out|enter|leave|wheel)|key(down|press|up)|change|select|submit|reset|blur|focus|load|unload)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/ig, "")); o.inlineStyle || (m = m.replace(/\s+(style|class)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/ig, "")); return h + m + l }); return a = a.replace(/<\/(strong|b|u|strike|em|i)>((?:\s|| )*?)<\1(\s+[^>]*?)?>/ig, "$2") }; this.formatXHTML = function (a, b) { function c(u) { var x = {}; u = u.split(","); for (var G = 0; G < u.length; G++) x[u[G]] = true; return x } function h(u) { u = u.toLowerCase(); var x = t[u]; return x ? x : u } function p(u, x, G) { if (k[u]) for (; F.last() && q[F.last()]; ) m(F.last()); r[u] && F.last() === u && m(u); (G = n[u] || !!G) || F.push(u); var J = []; J.push("<" + u); x.replace(K, function (lb, xa, mb, nb, ob) { xa = xa.toLowerCase(); J.push(" " + xa + '="' + (mb ? mb : nb ? nb : ob ? ob : v[xa] ? xa : "") + '"') }); J.push((G ? " /" : "") + ">"); j(J.join(""), u, true) } function m(u) { if (u) for (x = F.length - 1; x >= 0; x--) { if (F[x] === u) break } else var x = 0; if (x >= 0) { for (u = F.length - 1; u >= x; u--) j("", F[u]); F.length = x } } function l(u) { j(d.domEncode(u)) } function i(u) { j(u) } function j(u, x, G) { if (b === true) { u = u.replace(/(\t*\r?\n\t*)+/g, ""); if (!u.match(/^\s*$/)) { var J = k[x], lb = J ? x : ""; if (J) { G && ma++; Ia === "" && ma-- } else Ia && ma++; if (lb !== Ia || J) f(); D.push(u); x === "br" && f(); if (J && (n[x] || !G)) ma--; Ia = J ? x : "" } } else D.push(u) } function f() { D.push("\r\n"); if (ma > 0) for (var u = ma; u--; ) D.push("\t") } function g(u, x, G, J) { if (!G) return J; u = ""; if (x = G.match(/ face\s*=\s*"\s*([^"]+)\s*"/i)) u += "font-family:" + x[1] + ";"; if (x = G.match(/ size\s*=\s*"\s*(\d+)\s*"/i)) u += "font-size:" + S[(x[1] > 7 ? 7 : x[1] < 1 ? 1 : x[1]) - 1].n + ";"; if (x = G.match(/ color\s*=\s*"\s*([^"]+)\s*"/i)) u += "color:" + x[1] + ";"; if (G = G.match(/ style\s*=\s*"\s*([^"]+)\s*"/i)) u += G[1]; if (u) J = '' + J + ""; return J } var n = c("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed"), k = c("address,applet,blockquote,button,center,dd,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,style,table,tbody,td,tfoot,th,thead,tr,ul"), q = c("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"), r = c("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"), v = c("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"), s = c("script,style"), t = { b: "strong", i: "em", s: "del", strike: "del" }, A = /<(?:\/([\w:]+)|!--([^>]*?)--|([\w:]+)((?:\s+[\w-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?)*)\s*(\/?))>/g, K = /\s+([\w-:]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?/g, D = [], F = []; F.last = function () { return this[this.length - 1] }; for (var B, E, L = 0, fa, ya, ma = -1, Ia = "body"; B = A.exec(a); ) { E = B.index; if (E > L) { L = a.substring(L, E); fa ? ya.push(L) : l(L) } L = A.lastIndex; if (E = B[1]) { E = h(E); if (fa && E === fa) { i(ya.join("")); ya = fa = null } if (!fa) { m(E); continue } } if (fa) ya.push(B[0]); else if (E = B[3]) { E = h(E); p(E, B[4], B[5]); if (s[E]) { fa = E; ya = [] } } else B[2] && j(B[0]) } a.length > L && l(a.substring(L, a.length)); m(); a = D.join(""); D = null; a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig, g); a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig, g); a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, g); a = a.replace(/^(\s*\r?\n)+|(\s*\r?\n)+$/g, ""); return a = a.replace(/(\t*\r?\n)+/g, "\r\n") }; this.toggleShowBlocktag = function (a) { if (ta !== a) { ta = !ta; a = e(w.body); if (ta) { la += " showBlocktag"; a.addClass("showBlocktag") } else { la = la.replace(" showBlocktag", ""); a.removeClass("showBlocktag") } } }; this.toggleSource = function (a) { if (H !== a) { M.find("[name=Source]").toggleClass("xheEnabled").toggleClass("xheActive"); var b = w.body, c = e(b), h, p; a = 0; if (H) { h = d.getSource(); c.html("").removeAttr("scroll").attr("class", "editMode" + la); if (y) b.contentEditable = "true"; else w.designMode = "On"; if (za) { d._exec("inserthtml", "-"); e("#" + Ga).show().focus().hide() } } else { d.pasteHTML('', true); h = d.getSource(true); a = h.indexOf(''); if (!pb) a = h.substring(0, a).replace(/\r/g, "").length; h = h.replace(RegExp("(\r\n)?s*" + ''.replace("/", "\\/") + "s*"), ""); if (y) b.contentEditable = "false"; else w.designMode = "Off"; c.attr("scroll", "no").attr("class", "sourceMode").html('