xheditor-1.1.14-en.min.js 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687
  1. (function (e, $) {
  2. if (window.xheditor)return !1;
  3. var I = navigator.userAgent.toLowerCase(), Ba = -1 !== I.indexOf("mobile"), J = e.browser, pa = parseFloat(J.version), h = J.msie, qa = J.mozilla, R = J.safari, Ca = J.opera, eb = -1 < I.indexOf(" adobeair/"), Da = /OS 5(_\d)+ like Mac OS X/i.test(I);
  4. e.fn.xheditor = function (h) {
  5. if (Ba && !Da)return !1;
  6. var o = [];
  7. this.each(function () {
  8. if (e.nodeName(this, "TEXTAREA"))if (!1 === h) {
  9. if (this.xheditor)this.xheditor.remove(), this.xheditor = null
  10. } else if (this.xheditor)o.push(this.xheditor); else {
  11. var q = /({.*})/.exec(e(this).attr("class"));
  12. if (q) {
  13. try {
  14. q = eval("(" + q[1] + ")")
  15. } catch (t) {
  16. }
  17. h = e.extend({}, q, h)
  18. }
  19. q = new ra(this, h);
  20. if (q.init())this.xheditor = q, o.push(q)
  21. }
  22. });
  23. 0 === o.length && (o = !1);
  24. 1 === o.length && (o = o[0]);
  25. return o
  26. };
  27. var aa = 0, S = !1, sa = !0, ta = !1, Sa = !1, t, ba, ca, da, K, Ea, ea, Fa, Ga, Ha, A;
  28. e("script[src*=xheditor]").each(function () {
  29. var e = this.src;
  30. if (e.match(/xheditor[^\/]*\.js/i))return A = e.replace(/[\?#].*$/, "").replace(/(^|[\/\\])[^\/]*$/, "$1"), !1
  31. });
  32. if (h) {
  33. try {
  34. document.execCommand("BackgroundImageCache", !1, !0)
  35. } catch (qb) {
  36. }
  37. (I = e.fn.jquery) && I.match(/^1\.[67]/) &&
  38. (e.attrHooks.width = e.attrHooks.height = null)
  39. }
  40. var fb = {
  41. 27: "esc",
  42. 9: "tab",
  43. 32: "space",
  44. 13: "enter",
  45. 8: "backspace",
  46. 145: "scroll",
  47. 20: "capslock",
  48. 144: "numlock",
  49. 19: "pause",
  50. 45: "insert",
  51. 36: "home",
  52. 46: "del",
  53. 35: "end",
  54. 33: "pageup",
  55. 34: "pagedown",
  56. 37: "left",
  57. 38: "up",
  58. 39: "right",
  59. 40: "down",
  60. 112: "f1",
  61. 113: "f2",
  62. 114: "f3",
  63. 115: "f4",
  64. 116: "f5",
  65. 117: "f6",
  66. 118: "f7",
  67. 119: "f8",
  68. 120: "f9",
  69. 121: "f10",
  70. 122: "f11",
  71. 123: "f12"
  72. }, Ta = "#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".split(","),
  73. gb = [{n: "p", t: "Paragraph"}, {n: "h1", t: "Heading 1"}, {n: "h2", t: "Heading 2"}, {n: "h3", t: "Heading 3"}, {n: "h4", t: "Heading 4"}, {n: "h5", t: "Heading 5"}, {n: "h6", t: "Heading 6"}, {n: "pre", t: "Preformatted"}, {
  74. n: "address",
  75. t: "Address"
  76. }], hb = [{n: "Arial"}, {n: "Arial Black"}, {n: "Comic Sans MS"}, {n: "Courier New"}, {n: "System"}, {n: "Times New Roman"}, {n: "Tahoma"}, {n: "Verdana"}], T = [{n: "x-small", s: "10px", t: "1"}, {n: "small", s: "13px", t: "2"}, {n: "medium", s: "16px", t: "3"}, {n: "large", s: "18px", t: "4"}, {n: "x-large", s: "24px", t: "5"}, {
  77. n: "xx-large",
  78. s: "32px", t: "6"
  79. }, {n: "-webkit-xxx-large", s: "48px", t: "7"}], ib = [{s: "Align left", v: "justifyleft"}, {s: "Align center", v: "justifycenter"}, {s: "Align right", v: "justifyright"}, {s: "Align full", v: "justifyfull"}], jb = [{s: "Ordered list", v: "insertOrderedList"}, {s: "Unordered list", v: "insertUnorderedList"}], kb = {
  80. "default": {
  81. name: "Default", width: 24, height: 24, line: 7, list: {
  82. smile: "Smile", tongue: "Tongue", titter: "Titter", laugh: "Laugh", sad: "Sad", wronged: "Wronged", fastcry: "Fast cry", cry: "Cry", wail: "Wail", mad: "Mad", knock: "Knock",
  83. curse: "Curse", crazy: "Crazy", angry: "Angry", ohmy: "Oh my", awkward: "Awkward", panic: "Panic", shy: "Shy", cute: "Cute", envy: "Envy", proud: "Proud", struggle: "Struggle", quiet: "Quiet", shutup: "Shut up", doubt: "Doubt", despise: "Despise", sleep: "Sleep", bye: "Bye"
  84. }
  85. }
  86. }, ka = {
  87. Cut: {t: "Cut (Ctrl+X)"},
  88. Copy: {t: "Copy (Ctrl+C)"},
  89. Paste: {t: "Paste (Ctrl+V)"},
  90. Pastetext: {t: "Paste as plain text", h: h ? 0 : 1},
  91. Blocktag: {t: "Block tag", h: 1},
  92. Fontface: {t: "Font family", h: 1},
  93. FontSize: {t: "Font size", h: 1},
  94. Bold: {t: "Bold (Ctrl+B)", s: "Ctrl+B"},
  95. Italic: {
  96. t: "Italic (Ctrl+I)",
  97. s: "Ctrl+I"
  98. },
  99. Underline: {t: "Underline (Ctrl+U)", s: "Ctrl+U"},
  100. Strikethrough: {t: "Strikethrough"},
  101. FontColor: {t: "Select text color", h: 1},
  102. BackColor: {t: "Select background color", h: 1},
  103. SelectAll: {t: "SelectAll (Ctrl+A)"},
  104. Removeformat: {t: "Remove formatting"},
  105. Align: {t: "Align", h: 1},
  106. List: {t: "List", h: 1},
  107. Outdent: {t: "Outdent"},
  108. Indent: {t: "Indent"},
  109. Link: {t: "Insert/edit link (Ctrl+L)", s: "Ctrl+L", h: 1},
  110. Unlink: {t: "Unlink"},
  111. Anchor: {t: "Anchor", h: 1},
  112. Img: {t: "Insert/edit image", h: 1},
  113. Flash: {t: "Insert/edit flash", h: 1},
  114. Media: {
  115. t: "Insert/edit media",
  116. h: 1
  117. },
  118. Hr: {t: "Horizontal rule"},
  119. Emot: {t: "Emotions", s: "ctrl+e", h: 1},
  120. Table: {t: "Insert a new table", h: 1},
  121. Source: {t: "Edit source code"},
  122. Preview: {t: "Preview"},
  123. Print: {t: "Print (Ctrl+P)", s: "Ctrl+P"},
  124. Fullscreen: {t: "Toggle fullscreen (Esc)", s: "Esc"},
  125. About: {t: "About xhEditor"}
  126. }, Ia = {
  127. mini: "Bold,Italic,Underline,Strikethrough,|,Align,List,|,Link,Img",
  128. simple: "Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,|,Align,List,Outdent,Indent,|,Img",
  129. full: "Cut,Copy,Paste,Pastetext,|,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,|,Align,List,Outdent,Indent,|,Link,Unlink,Anchor,Img,Flash,Media,Hr,Emot,Table,|,Source,Preview,Print,Fullscreen"
  130. };
  131. Ia.mfull = Ia.full.replace(/\|(,Align)/i, "/$1");
  132. var lb = {a: "Link", img: "Img", embed: "Embed"}, mb = {"<": "&lt;", ">": "&gt;", '"': "&quot;", "\u00ae": "&reg;", "\u00a9": "&copy;"}, nb = /[<>"\u00ae\u00a9]/g, ra = function (z, o) {
  133. function q(a) {
  134. var a = a.target, b = lb[a.tagName.toLowerCase()];
  135. b && ("Embed" === b && (b = {"application/x-shockwave-flash": "Flash", "application/x-mplayer2": "Media"}[a.type.toLowerCase()]), d.exec(b))
  136. }
  137. function I(a) {
  138. if (27 === a.which)return ta ? d.removeModal() : S && d.hidePanel(), !1
  139. }
  140. function J() {
  141. setTimeout(d.setSource,
  142. 10)
  143. }
  144. function U() {
  145. d.getSource()
  146. }
  147. function Ua(a) {
  148. var b, c, f;
  149. if (a && (b = a.originalEvent.clipboardData) && (c = b.items) && (f = c[0]) && "file" == f.kind && f.type.match(/^image\//i))return a = f.getAsFile(), b = new FileReader, b.onload = function () {
  150. var a = '<img src="' + event.target.result + '">', a = Va(a);
  151. d.pasteHTML(a)
  152. }, b.readAsDataURL(a), !1;
  153. var i = g.cleanPaste;
  154. if (0 === i || x || Ja)return !0;
  155. Ja = !0;
  156. d.saveBookmark();
  157. var a = h ? "pre" : "div", m = e("<" + a + ' class="xhe-paste">\ufeff\ufeff</' + a + ">", l).appendTo(l.body), a = m[0];
  158. b = d.getSel();
  159. c = d.getRng(!0);
  160. m.css("top", fa.scrollTop());
  161. h ? (c.moveToElementText(a), c.select()) : (c.selectNodeContents(a), b.removeAllRanges(), b.addRange(c));
  162. setTimeout(function () {
  163. var a = 3 === i, b;
  164. if (a)b = m.text(); else {
  165. var c = [];
  166. e(".xhe-paste", l.body).each(function (a, b) {
  167. 0 == e(b).find(".xhe-paste").length && c.push(b.innerHTML)
  168. });
  169. b = c.join("<br />")
  170. }
  171. m.remove();
  172. d.loadBookmark();
  173. if (b = b.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, ""))if (a)d.pasteText(b); else if (b = d.cleanHTML(b), b = d.cleanWord(b), b = d.formatXHTML(b), !g.onPaste || g.onPaste && !1 !== (b = g.onPaste(b)))b =
  174. Va(b), d.pasteHTML(b);
  175. Ja = !1
  176. }, 0)
  177. }
  178. function Va(a) {
  179. var b = g.localUrlTest, c = g.remoteImgSaveUrl;
  180. if (b && c) {
  181. var f = [], i = 0, a = a.replace(/(<img)((?:\s+[^>]*?)?(?:\s+src="\s*([^"]+)\s*")(?: [^>]*)?)(\/?>)/ig, function (a, c, d, e, s) {
  182. /^(https?|data:image)/i.test(e) && !/_xhe_temp/.test(d) && !b.test(e) && (f[i] = e, d = d.replace(/\s+(width|height)="[^"]*"/ig, "").replace(/\s+src="[^"]*"/ig, ' src="' + ua + 'img/waiting.gif" remoteimg="' + i++ + '"'));
  183. return c + d + s
  184. });
  185. 0 < f.length && e.post(c, {urls: f.join("|")}, function (a) {
  186. a = a.split("|");
  187. e("img[remoteimg]",
  188. d.doc).each(function () {
  189. var b = e(this);
  190. L(b, "src", a[b.attr("remoteimg")]);
  191. b.removeAttr("remoteimg")
  192. })
  193. })
  194. }
  195. return a
  196. }
  197. function Ka(a) {
  198. try {
  199. d._exec("styleWithCSS", a, !0)
  200. } catch (b) {
  201. try {
  202. d._exec("useCSS", !a, !0)
  203. } catch (c) {
  204. }
  205. }
  206. }
  207. function La() {
  208. if (Ma && !x) {
  209. Ka(!1);
  210. try {
  211. d._exec("enableObjectResizing", !0, !0)
  212. } catch (a) {
  213. }
  214. if (h)try {
  215. d._exec("BackgroundImageCache", !0, !0)
  216. } catch (b) {
  217. }
  218. }
  219. }
  220. function Ba(a) {
  221. if (x || 13 !== a.which || a.shiftKey || a.ctrlKey || a.altKey)return !0;
  222. a = d.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li");
  223. if (a.is("li"))return !0;
  224. if (g.forcePtag)0 === a.length && d._exec("formatblock", "<p>"); else return d.pasteHTML("<br />"), h && 0 < a.length && 2 === d.getRng().parentElement().childNodes.length && d.pasteHTML("<br />"), !1
  225. }
  226. function Na() {
  227. !qa && !R && (la && B.height("100%").css("height", B.outerHeight() - n.outerHeight()), h && n.hide().show())
  228. }
  229. function Da(a) {
  230. a = a.target;
  231. if (a.tagName.match(/(img|embed)/i)) {
  232. var b = d.getSel(), c = d.getRng(!0);
  233. c.selectNode(a);
  234. b.removeAllRanges();
  235. b.addRange(c)
  236. }
  237. }
  238. function L(a, b, c) {
  239. if (!b)return !1;
  240. var d = "_xhe_" + b;
  241. c && (va && (c = V(c,
  242. va, F)), a.attr(b, F ? V(c, "abs", F) : c).removeAttr(d).attr(d, c));
  243. return a.attr(d) || a.attr(b)
  244. }
  245. function Oa() {
  246. sa && d.hidePanel()
  247. }
  248. function ob(a) {
  249. if (x)return !0;
  250. var b = a.which, c = fb[b], b = c ? c : String.fromCharCode(b).toLowerCase();
  251. sKey = "";
  252. sKey += a.ctrlKey ? "ctrl+" : "";
  253. sKey += a.altKey ? "alt+" : "";
  254. sKey += a.shiftKey ? "shift+" : "";
  255. sKey += b;
  256. var a = ma[sKey], f;
  257. for (f in a)if (f = a[f], e.isFunction(f)) {
  258. if (!1 === f.call(d))return !1
  259. } else return d.exec(f), !1
  260. }
  261. function M(a, b) {
  262. var c = typeof a;
  263. return !b ? "undefined" != c : "array" === b && a.hasOwnProperty &&
  264. a instanceof Array ? !0 : c === b
  265. }
  266. function V(a, b, c) {
  267. if (a.match(/^(\w+):\/\//i) && !a.match(/^https?:/i) || /^#/i.test(a) || /^data:/i.test(a))return a;
  268. var d = c ? e('<a href="' + c + '" />')[0] : location, c = d.protocol, i = d.host, m = d.hostname, j = d.port, d = d.pathname.replace(/\\/g, "/").replace(/[^\/]+$/i, "");
  269. "" === j && (j = "80");
  270. "" === d ? d = "/" : "/" !== d.charAt(0) && (d = "/" + d);
  271. a = e.trim(a);
  272. "abs" !== b && (a = a.replace(RegExp(c + "\\/\\/" + m.replace(/\./g, "\\.") + "(?::" + j + ")" + ("80" === j ? "?" : "") + "(/|$)", "i"), "/"));
  273. "rel" === b && (a = a.replace(RegExp("^" +
  274. d.replace(/([\/\.\+\[\]\(\)])/g, "\\$1"), "i"), ""));
  275. if ("rel" !== b && (a.match(/^(https?:\/\/|\/)/i) || (a = d + a), "/" === a.charAt(0))) {
  276. for (var m = [], a = a.split("/"), p = a.length, d = 0; d < p; d++)j = a[d], ".." === j ? m.pop() : "" !== j && "." !== j && m.push(j);
  277. "" === a[p - 1] && m.push("");
  278. a = "/" + m.join("/")
  279. }
  280. "abs" === b && !a.match(/^https?:\/\//i) && (a = c + "//" + i + a);
  281. return a = a.replace(/(https?:\/\/[^:\/?#]+):80(\/|$)/i, "$1$2")
  282. }
  283. function Wa(a, b) {
  284. if ("*" === b || a.match(RegExp(".(" + b.replace(/,/g, "|") + ")$", "i")))return !0;
  285. alert("Upload file extension required for this: " +
  286. b);
  287. return !1
  288. }
  289. function Xa(a) {
  290. var b = Math.floor(Math.log(a) / Math.log(1024));
  291. return (a / Math.pow(1024, Math.floor(b))).toFixed(2) + "Byte,KB,MB,GB,TB,PB".split(",")[b]
  292. }
  293. function N() {
  294. return !1
  295. }
  296. var d = this, G = e(z), Ya = G.closest("form"), n, B, W, fa, l, ga, ha, Ma = !1, x = !1, la = !1, Ja = !1, Pa, na = !1, Za = "", v = null, wa, oa = !1, Qa = !1, ia = null, X = null, O = 0, g = d.settings = e.extend({}, ra.settings, o), xa = g.plugins, ya = [];
  297. xa && (ka = e.extend({}, ka, xa), e.each(xa, function (a) {
  298. ya.push(a)
  299. }), ya = ya.join(","));
  300. if (g.tools.match(/^\s*(m?full|simple|mini)\s*$/i)) {
  301. var $a =
  302. Ia[e.trim(g.tools)];
  303. g.tools = g.tools.match(/m?full/i) && xa ? $a.replace("Table", "Table," + ya) : $a
  304. }
  305. g.tools.match(/(^|,)\s*About\s*(,|$)/i) || (g.tools += ",About");
  306. g.tools = g.tools.split(",");
  307. if (g.editorRoot)A = g.editorRoot;
  308. !1 === eb && (A = V(A, "abs"));
  309. if (g.urlBase)g.urlBase = V(g.urlBase, "abs");
  310. var ab = "xheCSS_" + g.skin, ja = "xhe" + aa + "_container", bb = "xhe" + aa + "_Tool", cb = "xhe" + aa + "_iframearea", db = "xhe" + aa + "_iframe", za = "xhe" + aa + "_fixffcursor", P = "", Q = "", ua = A + "xheditor_skin/" + g.skin + "/", Aa = kb, va = g.urlType, F = g.urlBase, Y = g.emotPath,
  311. Y = Y ? Y : A + "xheditor_emot/", Ra = "", Aa = e.extend({}, Aa, g.emots), Y = V(Y, "rel", F ? F : null);
  312. (na = g.showBlocktag) && (Q += " showBlocktag");
  313. var ma = [];
  314. this.init = function () {
  315. 0 === e("#" + ab).length && e("head").append('<link id="' + ab + '" rel="stylesheet" type="text/css" href="' + ua + 'ui.css" />');
  316. var a = G.outerWidth(), b = G.outerHeight(), a = g.width || z.style.width || (10 < a ? a : 0);
  317. O = g.height || z.style.height || (10 < b ? b : 150);
  318. M(a, "number") && (a += "px");
  319. M(O, "string") && (O = O.replace(/[^\d]+/g, ""));
  320. var b = g.background || z.style.background, c = ['<span class="xheGStart"/>'],
  321. f, i, m = /\||\//i;
  322. e.each(g.tools, function (a, b) {
  323. b.match(m) && c.push('<span class="xheGEnd"/>');
  324. if ("|" === b)c.push('<span class="xheSeparator"/>'); else if ("/" === b)c.push("<br />"); else {
  325. f = ka[b];
  326. if (!f)return;
  327. i = f.c ? f.c : "xheIcon xheBtn" + b;
  328. c.push('<span><a href="#" title="' + f.t + '" cmd="' + b + '" class="xheButton xheEnabled" tabindex="-1" role="button"><span class="' + i + '" unselectable="on" style="font-size:0;color:transparent;text-indent:-999px;">' + f.t + "</span></a></span>");
  329. f.s && d.addShortcuts(f.s, b)
  330. }
  331. b.match(m) &&
  332. c.push('<span class="xheGStart"/>')
  333. });
  334. c.push('<span class="xheGEnd"/><br />');
  335. G.after(e('<input type="text" id="' + za + '" style="position:absolute;display:none;" /><span id="' + ja + '" class="xhe_' + g.skin + '" style="display:none"><table cellspacing="0" cellpadding="0" class="xheLayout" style="' + ("0px" != a ? "width:" + a + ";" : "") + "height:" + O + 'px;" role="presentation"><tr><td id="' + bb + '" class="xheTool" unselectable="on" style="height:1px;" role="presentation"></td></tr><tr><td id="' + cb + '" class="xheIframeArea" role="presentation"><iframe frameborder="0" id="' +
  336. db + '" src="javascript:;" style="width:100%;"></iframe></td></tr></table></span>'));
  337. n = e("#" + bb);
  338. B = e("#" + cb);
  339. P = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="' + ua + 'iframe.css"/>';
  340. if (a = g.loadCSS)if (M(a, "array"))for (var j in a)P += '<link rel="stylesheet" href="' + a[j] + '"/>'; else P = a.match(/\s*<style(\s+[^>]*?)?>[\s\S]+?<\/style>\s*/i) ? P + a : P + ('<link rel="stylesheet" href="' + a + '"/>');
  341. j = "<html><head>" + P + "<title>WYSIWYG Editor,press alt+1-9,toogle to tool area,press tab,select button,press esc,return editor " +
  342. (g.readTip ? g.readTip : "") + "</title>";
  343. b && (j += "<style>html{background:" + b + ";}</style>");
  344. j += '</head><body spellcheck="0" class="editMode' + Q + '"></body></html>';
  345. d.win = W = e("#" + db)[0].contentWindow;
  346. fa = e(W);
  347. try {
  348. this.doc = l = W.document, ga = e(l), l.open(), l.write(j), l.close(), h ? l.body.contentEditable = "true" : l.designMode = "On"
  349. } catch (p) {
  350. }
  351. setTimeout(La, 300);
  352. d.setSource();
  353. W.setInterval = null;
  354. n.append(c.join("")).bind("mousedown contextmenu", N).click(function (a) {
  355. var b = e(a.target).closest("a");
  356. b.is(".xheEnabled") && (clearTimeout(wa),
  357. n.find("a").attr("tabindex", "-1"), v = a, d.exec(b.attr("cmd")));
  358. return !1
  359. });
  360. n.find(".xheButton").hover(function (a) {
  361. var b = e(this), c = g.hoverExecDelay, k = X;
  362. X = null;
  363. if (-1 === c || oa || !b.is(".xheEnabled"))return !1;
  364. if (k && 10 < k)return oa = !0, setTimeout(function () {
  365. oa = !1
  366. }, 100), !1;
  367. var f = b.attr("cmd");
  368. if (1 !== ka[f].h)return d.hidePanel(), !1;
  369. Qa && (c = 0);
  370. 0 <= c && (wa = setTimeout(function () {
  371. v = a;
  372. ia = {x: v.clientX, y: v.clientY};
  373. d.exec(f)
  374. }, c))
  375. }, function () {
  376. ia = null;
  377. wa && clearTimeout(wa)
  378. }).mousemove(function (a) {
  379. if (ia) {
  380. var b = a.clientX - ia.x,
  381. c = a.clientY - ia.y;
  382. if (1 < Math.abs(b) || 1 < Math.abs(c))0 < b && 0 < c ? (b = Math.round(Math.atan(c / b) / 0.017453293), X = X ? (X + b) / 2 : b) : X = null, ia = {x: a.clientX, y: a.clientY}
  383. }
  384. });
  385. t = e("#xhePanel");
  386. ba = e("#xheShadow");
  387. ca = e("#xheCntLine");
  388. 0 === t.length && (t = e('<div id="xhePanel"></div>').mousedown(function (a) {
  389. a.stopPropagation()
  390. }), ba = e('<div id="xheShadow"></div>'), ca = e('<div id="xheCntLine"></div>'), setTimeout(function () {
  391. e(document.body).append(t).append(ba).append(ca)
  392. }, 10));
  393. e("#" + ja).show();
  394. G.hide();
  395. B.css("height", O - n.outerHeight());
  396. h & 8 > pa && setTimeout(function () {
  397. B.css("height", O - n.outerHeight())
  398. }, 1);
  399. G.focus(d.focus);
  400. Ya.submit(U).bind("reset", J);
  401. g.submitID && e("#" + g.submitID).mousedown(U);
  402. e(window).bind("unload beforeunload", U).bind("resize", Na);
  403. e(document).mousedown(Oa);
  404. Sa || (e(document).keydown(I), Sa = !0);
  405. fa.focus(function () {
  406. g.focus && g.focus()
  407. }).blur(function () {
  408. g.blur && g.blur()
  409. });
  410. R && fa.click(Da);
  411. ga.mousedown(Oa).keydown(ob).keypress(Ba).dblclick(q).bind("mousedown click", function (a) {
  412. G.trigger(a.type)
  413. });
  414. if (h) {
  415. ga.keydown(function (a) {
  416. var b =
  417. d.getRng();
  418. if (8 === a.which && b.item)return e(b.item(0)).remove(), !1
  419. });
  420. var w = function (a) {
  421. var a = e(a.target), b;
  422. (b = a.css("width")) && a.css("width", "").attr("width", b.replace(/[^0-9%]+/g, ""));
  423. (b = a.css("height")) && a.css("height", "").attr("height", b.replace(/[^0-9%]+/g, ""))
  424. };
  425. ga.bind("controlselect", function (a) {
  426. a = a.target;
  427. e.nodeName(a, "IMG") && e(a).unbind("resizeend", w).bind("resizeend", w)
  428. })
  429. }
  430. ga.keydown(function (a) {
  431. var b = a.which;
  432. if (a.altKey && 49 <= b && 57 >= b)return n.find("a").attr("tabindex", "0"), n.find(".xheGStart").eq(b -
  433. 49).next().find("a").focus(), l.title = "\ufeff\ufeff", !1
  434. }).click(function () {
  435. n.find("a").attr("tabindex", "-1")
  436. });
  437. n.keydown(function (a) {
  438. var b = a.which;
  439. if (27 == b)n.find("a").attr("tabindex", "-1"), d.focus(); else if (a.altKey && 49 <= b && 57 >= b)return n.find(".xheGStart").eq(b - 49).next().find("a").focus(), !1
  440. });
  441. j = e(l.documentElement);
  442. Ca ? j.bind("keydown", function (a) {
  443. a.ctrlKey && 86 === a.which && Ua()
  444. }) : j.bind(h ? "beforepaste" : "paste", Ua);
  445. g.disableContextmenu && j.bind("contextmenu", N);
  446. g.html5Upload && j.bind("dragenter dragover",
  447. function (a) {
  448. var b;
  449. if ((b = a.originalEvent.dataTransfer.types) && -1 !== e.inArray("Files", b))return !1
  450. }).bind("drop", function (a) {
  451. var a = a.originalEvent.dataTransfer, b;
  452. if (a && (b = a.files) && 0 < b.length) {
  453. var c, k, a = ["Link", "Img", "Flash", "Media"], f = [], j;
  454. for (c in a)k = a[c], g["up" + k + "Url"] && g["up" + k + "Url"].match(/^[^!].*/i) && f.push(k + ":," + g["up" + k + "Ext"]);
  455. if (0 === f.length)return !1;
  456. j = f.join(",");
  457. k = function (a) {
  458. var b, d;
  459. for (c = 0; c < a.length; c++)if (b = a[c].name.replace(/.+\./, ""), b = j.match(RegExp("(\\w+):[^:]*," + b + "(?:,|$)",
  460. "i")))if (d) {
  461. if (d !== b[1])return 2
  462. } else d = b[1]; else return 1;
  463. return d
  464. }(b);
  465. 1 === k ? alert("Upload file extension required for this: " + j.replace(/\w+:,/g, "")) : 2 === k ? alert("You can only drag and drop the same type of files.") : k && d.startUpload(b, g["up" + k + "Url"], "*", function (a) {
  466. var b = [], c;
  467. (c = g.onUpload) && c(a);
  468. for (var f = 0, j = a.length; f < j; f++)c = a[f], url = M(c, "string") ? c : c.url, "!" === url.substr(0, 1) && (url = url.substr(1)), b.push(url);
  469. d.exec(k);
  470. e("#xhe" + k + "Url").val(b.join(" "));
  471. e("#xheSave").click()
  472. });
  473. return !1
  474. }
  475. });
  476. (j = g.shortcuts) && e.each(j, function (a, b) {
  477. d.addShortcuts(a, b)
  478. });
  479. aa++;
  480. Ma = !0;
  481. g.fullscreen ? d.toggleFullscreen() : g.sourceMode && setTimeout(d.toggleSource, 20);
  482. return !0
  483. };
  484. this.remove = function () {
  485. d.hidePanel();
  486. U();
  487. G.unbind("focus", d.focus);
  488. Ya.unbind("submit", U).unbind("reset", J);
  489. g.submitID && e("#" + g.submitID).unbind("mousedown", U);
  490. e(window).unbind("unload beforeunload", U).unbind("resize", Na);
  491. e(document).unbind("mousedown", Oa);
  492. e("#" + ja).remove();
  493. e("#" + za).remove();
  494. G.show();
  495. Ma = !1
  496. };
  497. this.saveBookmark = function () {
  498. if (!x) {
  499. d.focus();
  500. var a = d.getRng(), a = a.cloneRange ? a.cloneRange() : a;
  501. ha = {top: fa.scrollTop(), rng: a}
  502. }
  503. };
  504. this.loadBookmark = function () {
  505. if (!x && ha) {
  506. d.focus();
  507. var a = ha.rng;
  508. if (h)a.select(); else {
  509. var b = d.getSel();
  510. b.removeAllRanges();
  511. b.addRange(a)
  512. }
  513. fa.scrollTop(ha.top);
  514. ha = null
  515. }
  516. };
  517. this.focus = function () {
  518. x ? e("#sourceCode", l).focus() : W.focus();
  519. if (h) {
  520. var a = d.getRng();
  521. a.parentElement && a.parentElement().ownerDocument !== l && d.setTextCursor()
  522. }
  523. return !1
  524. };
  525. this.setTextCursor = function (a) {
  526. var b = d.getRng(!0), c = l.body;
  527. if (h)b.moveToElementText(c); else {
  528. for (var e =
  529. a ? "lastChild" : "firstChild"; 3 != c.nodeType && c[e];)c = c[e];
  530. b.selectNode(c)
  531. }
  532. b.collapse(a ? !1 : !0);
  533. h ? b.select() : (a = d.getSel(), a.removeAllRanges(), a.addRange(b))
  534. };
  535. this.getSel = function () {
  536. return l.selection ? l.selection : W.getSelection()
  537. };
  538. this.getRng = function (a) {
  539. var b, c;
  540. try {
  541. a || (b = d.getSel(), c = b.createRange ? b.createRange() : 0 < b.rangeCount ? b.getRangeAt(0) : null), c || (c = l.body.createTextRange ? l.body.createTextRange() : l.createRange())
  542. } catch (e) {
  543. }
  544. return c
  545. };
  546. this.getParent = function (a) {
  547. var b = d.getRng(), c;
  548. h ? c = b.item ? b.item(0) :
  549. b.parentElement() : (c = b.commonAncestorContainer, b.collapsed || b.startContainer === b.endContainer && 2 > b.startOffset - b.endOffset && b.startContainer.hasChildNodes() && (c = b.startContainer.childNodes[b.startOffset]));
  550. a = a ? a : "*";
  551. c = e(c);
  552. c.is(a) || (c = e(c).closest(a));
  553. return c
  554. };
  555. this.getSelect = function (a) {
  556. var b = d.getSel(), c = d.getRng(), f = !0, f = !c || c.item ? !1 : !b || 0 === c.boundingWidth || c.collapsed;
  557. if ("text" === a)return f ? "" : c.text || (b.toString ? b.toString() : "");
  558. c.cloneContents ? (a = e("<div></div>"), (c = c.cloneContents()) && a.append(c),
  559. c = a.html()) : c = M(c.item) ? c.item(0).outerHTML : M(c.htmlText) ? c.htmlText : c.toString();
  560. f && (c = "");
  561. c = d.processHTML(c, "read");
  562. c = d.cleanHTML(c);
  563. return c = d.formatXHTML(c)
  564. };
  565. this.pasteHTML = function (a, b) {
  566. if (x)return !1;
  567. d.focus();
  568. var a = d.processHTML(a, "write"), c = d.getSel(), f = d.getRng();
  569. if (b !== $) {
  570. if (f.item) {
  571. var i = f.item(0), f = d.getRng(!0);
  572. f.moveToElementText(i);
  573. f.select()
  574. }
  575. f.collapse(b)
  576. }
  577. a += "<" + (h ? "img" : "span") + ' id="_xhe_temp" width="0" height="0" />';
  578. if (f.insertNode) {
  579. if (0 < e(f.startContainer).closest("style,script").length)return !1;
  580. f.deleteContents();
  581. f.insertNode(f.createContextualFragment(a))
  582. } else"control" === c.type.toLowerCase() && (c.clear(), f = d.getRng()), f.pasteHTML(a);
  583. var i = e("#_xhe_temp", l), m = i[0];
  584. h ? (f.moveToElementText(m), f.select()) : (f.selectNode(m), c.removeAllRanges(), c.addRange(f));
  585. i.remove()
  586. };
  587. this.pasteText = function (a, b) {
  588. a || (a = "");
  589. a = d.domEncode(a);
  590. a = a.replace(/\r?\n/g, "<br />");
  591. d.pasteHTML(a, b)
  592. };
  593. this.appendHTML = function (a) {
  594. if (x)return !1;
  595. d.focus();
  596. a = d.processHTML(a, "write");
  597. e(l.body).append(a);
  598. d.setTextCursor(!0)
  599. };
  600. this.domEncode =
  601. function (a) {
  602. return a.replace(nb, function (a) {
  603. return mb[a]
  604. })
  605. };
  606. this.setSource = function (a) {
  607. ha = null;
  608. if ("string" !== typeof a && "" !== a)a = z.value;
  609. x ? e("#sourceCode", l).val(a) : (g.beforeSetSource && (a = g.beforeSetSource(a)), a = d.cleanHTML(a), a = d.formatXHTML(a), a = d.processHTML(a, "write"), h ? (l.body.innerHTML = '<img id="_xhe_temp" width="0" height="0" />' + a, e("#_xhe_temp", l).remove()) : l.body.innerHTML = a)
  610. };
  611. this.processHTML = function (a, b) {
  612. if ("write" === b) {
  613. a = a.replace(/(<(\/?)(\w+))((?:\s+[\w\-:]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*((\/?)>)/g,
  614. function (a, b, c, d, e, f, i) {
  615. d = d.toLowerCase();
  616. qa ? "strong" === d ? d = "b" : "em" === d && (d = "i") : R && ("strong" === d ? (d = "span", c || (e += ' class="Apple-style-span" style="font-weight: bold;"')) : "em" === d ? (d = "span", c || (e += ' class="Apple-style-span" style="font-style: italic;"')) : "u" === d ? (d = "span", c || (e += ' class="Apple-style-span" style="text-decoration: underline;"')) : "strike" === d && (d = "span", c || (e += ' class="Apple-style-span" style="text-decoration: line-through;"')));
  617. var k, y = "";
  618. if ("del" === d)d = "strike"; else if ("img" === d)e =
  619. e.replace(/\s+emot\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i, function (a, b) {
  620. k = b.match(/^(["']?)(.*)\1/)[2];
  621. k = k.split(",");
  622. k[1] || (k[1] = k[0], k[0] = "");
  623. "default" === k[0] && (k[0] = "");
  624. return g.emotMark ? a : ""
  625. }); else if ("a" === d)!e.match(/ href=[^ ]/i) && e.match(/ name=[^ ]/i) && (y += " xhe-anchor"), i && (f = "></a>"); else if ("table" === d && !c && (a = e.match(/\s+border\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i), !a || a[1].match(/^(["']?)\s*0\s*\1$/)))y += " xhe-border";
  626. var Z, e = e.replace(/\s+([\w\-:]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g, function (a,
  627. b, c) {
  628. b = b.toLowerCase();
  629. c = c.match(/^(["']?)(.*)\1/)[2];
  630. aft = "";
  631. if (h && b.match(/^(disabled|checked|readonly|selected)$/) && c.match(/^(false|0)$/i) || "img" === d && k && "src" === b)return "";
  632. b.match(/^(src|href)$/) && (aft = " _xhe_" + b + '="' + c + '"', F && (c = V(c, "abs", F)));
  633. y && "class" === b && (c += " " + y, y = "");
  634. R && "style" === b && "span" === d && c.match(/(^|;)\s*(font-family|font-size|color|background-color)\s*:\s*[^;]+\s*(;|$)/i) && (Z = !0);
  635. return " " + b + '="' + c + '"' + aft
  636. });
  637. k && (a = Y + (k[0] ? k[0] : "default") + "/" + k[1] + ".gif", e += ' src="' + a + '" _xhe_src="' +
  638. a + '"');
  639. Z && (e += ' class="Apple-style-span"');
  640. y && (e += ' class="' + y + '"');
  641. return "<" + c + d + e + f
  642. });
  643. h && (a = a.replace(/&apos;/ig, "&#39;"));
  644. if (!R)var c = function (a, b, c, d, e, f) {
  645. var b = "", i, k;
  646. (i = d.match(/font-family\s*:\s*([^;"]+)/i)) && (b += ' face="' + i[1] + '"');
  647. if (i = d.match(/font-size\s*:\s*([^;"]+)/i)) {
  648. i = i[1].toLowerCase();
  649. for (var y = 0; y < T.length; y++)if (i === T[y].n || i === T[y].s) {
  650. k = y + 1;
  651. break
  652. }
  653. k && (b += ' size="' + k + '"', d = d.replace(/(^|;)(\s*font-size\s*:\s*[^;"]+;?)+/ig, "$1"))
  654. }
  655. if (k = d.match(/(?:^|[\s;])color\s*:\s*([^;"]+)/i)) {
  656. if (i =
  657. k[1].match(/\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i)) {
  658. k[1] = "#";
  659. for (y = 1; 3 >= y; y++)k[1] += ("0" + (i[y] - 0).toString(16)).slice(-2)
  660. }
  661. k[1] = k[1].replace(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3");
  662. b += ' color="' + k[1] + '"'
  663. }
  664. d = d.replace(/(^|;)(\s*(font-family|color)\s*:\s*[^;"]+;?)+/ig, "$1");
  665. return "" !== b ? (d && (b += ' style="' + d + '"'), "<font" + (c ? c : "") + b + (e ? e : "") + ">" + f + "</font>") : a
  666. }, 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,
  667. 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);
  668. a = a.replace(/<(td|th)(\s+[^>]*?)?>(\s|&nbsp;)*<\/\1>/ig, "<$1$2>" + (h ? "" : "<br />") + "</$1>")
  669. } else {
  670. if (R)for (var d = [{
  671. r: /font-weight\s*:\s*bold;?/ig,
  672. t: "strong"
  673. }, {r: /font-style\s*:\s*italic;?/ig, t: "em"}, {r: /text-decoration\s*:\s*underline;?/ig, t: "u"}, {r: /text-decoration\s*:\s*line-through;?/ig, t: "strike"}], c = function (a, b, c, e, i) {
  674. for (var a = (c ? c : "") + (e ? e : ""), g = [], D = [], k, c = 0; c < d.length; c++)b = d[c].r, k = d[c].t, a = a.replace(b, function () {
  675. g.push("<" + k + ">");
  676. D.push("</" + k + ">");
  677. return ""
  678. });
  679. a = a.replace(/\s+style\s*=\s*"\s*"/i, "");
  680. return (a ? "<span" + a + ">" : "") + g.join("") + i + D.join("") + (a ? "</span>" : "")
  681. }, e = 0; 2 > e; e++)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,
  682. 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);
  683. a = a.replace(/(<(\w+))((?:\s+[\w\-:]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/g, function (a, b, c, d, e) {
  684. var c = c.toLowerCase(), f, d = d.replace(/\s+_xhe_(?:src|href)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i, function (a,
  685. b) {
  686. f = b.match(/^(["']?)(.*)\1/)[2];
  687. return ""
  688. });
  689. f && va && (f = V(f, va, F));
  690. d = d.replace(/\s+([\w\-:]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g, function (a, b, c) {
  691. b = b.toLowerCase();
  692. c = c.match(/^(["']?)(.*)\1/)[2].replace(/"/g, "'");
  693. if ("class" === b) {
  694. if (c.match(/^["']?(apple|webkit)/i))return "";
  695. c = c.replace(/\s?xhe-[a-z]+/ig, "");
  696. if ("" === c)return ""
  697. } else {
  698. if (b.match(/^((_xhe_|_moz_|_webkit_)|jquery\d+)/i))return "";
  699. if (f && b.match(/^(src|href)$/i))return " " + b + '="' + f + '"';
  700. "style" === b && (c = c.replace(/(^|;)\s*(font-size)\s*:\s*([a-z-]+)\s*(;|$)/i,
  701. function (a, b, c, d, e) {
  702. for (var f, i = 0; i < T.length; i++)if (a = T[i], d === a.n) {
  703. f = a.s;
  704. break
  705. }
  706. return b + c + ":" + f + e
  707. }))
  708. }
  709. return " " + b + '="' + c + '"'
  710. });
  711. "img" === c && !d.match(/\s+alt\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i) && (d += ' alt=""');
  712. return b + d + e
  713. });
  714. a = a.replace(/(<(td|th)(?:\s+[^>]*?)?>)\s*([\s\S]*?)(<br(\s*\/)?>)?\s*<\/\2>/ig, function (a, b, c, d) {
  715. return b + (d ? d : "&nbsp;") + "</" + c + ">"
  716. });
  717. a = a.replace(/^\s*(?:<(p|div)(?:\s+[^>]*?)?>)?\s*(<span(?:\s+[^>]*?)?>\s*<\/span>|<br(?:\s+[^>]*?)?>|&nbsp;)*\s*(?:<\/\1>)?\s*$/i, "")
  718. }
  719. return a = a.replace(/(<pre(?:\s+[^>]*?)?>)([\s\S]+?)(<\/pre>)/gi,
  720. function (a, b, c, d) {
  721. return b + c.replace(/<br\s*\/?>/ig, "\r\n") + d
  722. })
  723. };
  724. this.getSource = function (a) {
  725. var b, c = g.beforeGetSource;
  726. x ? (b = e("#sourceCode", l).val(), c || (b = d.formatXHTML(b, !1))) : (b = d.processHTML(l.body.innerHTML, "read"), b = d.cleanHTML(b), b = d.formatXHTML(b, a), c && (b = c(b)));
  727. return z.value = b
  728. };
  729. this.cleanWord = function (a) {
  730. var b = g.cleanPaste;
  731. if (0 < b && 3 > b && /mso(-|normal)|WordDocument|<table\s+[^>]*?x:str|\s+class\s*=\s*"?xl[67]\d"/i.test(a)) {
  732. a = a.replace(/<\!--[\s\S]*?--\>|<!(--)?\[[\s\S]+?\](--)?>|<style(\s+[^>]*?)?>[\s\S]*?<\/style>/ig,
  733. "");
  734. a = a.replace(/\r?\n/ig, "");
  735. h ? (a = a.replace(/<v:shapetype(\s+[^>]*)?>[\s\S]*<\/v:shapetype>/ig, ""), a = a.replace(/<v:shape(\s+[^>]+)?>[\s\S]*?<v:imagedata(\s+[^>]+)?>\s*<\/v:imagedata>[\s\S]*?<\/v:shape>/ig, function (a, b, c) {
  736. if (a = c.match(/\s+src\s*=\s*("[^"]+"|'[^']+'|[^>\s]+)/i)) {
  737. a[1].match(/^(["']?)(.*)\1/);
  738. c = '<img src="' + A + 'xheditor_skin/blank.gif" _xhe_temp="true" class="wordImage"';
  739. if (a = b.match(/\s+style\s*=\s*("[^"]+"|'[^']+'|[^>\s]+)/i))a = a[1].match(/^(["']?)(.*)\1/)[2], c += ' style="' + a + '"';
  740. return c +
  741. " />"
  742. }
  743. return ""
  744. })) : a = a.replace(/<img( [^<>]*(v:shapes|msohtmlclip)[^<>]*)\/?>/ig, function (a, b) {
  745. var c, d = '<img src="' + A + 'xheditor_skin/blank.gif" _xhe_temp="true" class="wordImage"';
  746. (c = b.match(/ width\s*=\s*"([^"]+)"/i)) && (d += ' width="' + c[1] + '"');
  747. (c = b.match(/ height\s*=\s*"([^"]+)"/i)) && (d += ' height="' + c[1] + '"');
  748. return d + " />"
  749. });
  750. for (var a = a.replace(/(<(\/?)([\w\-:]+))((?:\s+[\w\-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?)*)\s*(\/?>)/g, function (a, c, d, e, f, g) {
  751. e = e.toLowerCase();
  752. if (e.match(/^(link)$/) && f.match(/file:\/\//i) ||
  753. e.match(/:/) || "span" === e && 2 === b)return "";
  754. d || (f = f.replace(/\s([\w\-:]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^>\s]+))?/ig, function (a, c, d) {
  755. c = c.toLowerCase();
  756. if (/:/.test(c))return "";
  757. d = d.match(/^(["']?)(.*)\1/)[2];
  758. if (1 === b)switch (e) {
  759. case "p":
  760. if ("style" === c)return (d = d.replace(/"|&quot;/ig, "'").replace(/\s*([^:]+)\s*:\s*(.*?)(;|$)/ig, function (a, b, c) {
  761. return /^(text-align)$/i.test(b) ? b + ":" + c + ";" : ""
  762. }).replace(/^\s+|\s+$/g, "")) ? " " + c + '="' + d + '"' : "";
  763. break;
  764. case "span":
  765. if ("style" === c)return (d = d.replace(/"|&quot;/ig, "'").replace(/\s*([^:]+)\s*:\s*(.*?)(;|$)/ig,
  766. function (a, b, c) {
  767. return /^(color|background|font-size|font-family)$/i.test(b) ? b + ":" + c + ";" : ""
  768. }).replace(/^\s+|\s+$/g, "")) ? " " + c + '="' + d + '"' : "";
  769. break;
  770. case "table":
  771. if (c.match(/^(cellspacing|cellpadding|border|width)$/i))return a;
  772. break;
  773. case "td":
  774. if (c.match(/^(rowspan|colspan)$/i))return a;
  775. if ("style" === c)return (d = d.replace(/"|&quot;/ig, "'").replace(/\s*([^:]+)\s*:\s*(.*?)(;|$)/ig, function (a, b, c) {
  776. return /^(width|height)$/i.test(b) ? b + ":" + c + ";" : ""
  777. }).replace(/^\s+|\s+$/g, "")) ? " " + c + '="' + d + '"' : "";
  778. break;
  779. case "a":
  780. if (c.match(/^(href)$/i))return a;
  781. break;
  782. case "font":
  783. case "img":
  784. return a
  785. } else if (2 === b)switch (e) {
  786. case "td":
  787. if (c.match(/^(rowspan|colspan)$/i))return a;
  788. break;
  789. case "img":
  790. return a
  791. }
  792. return ""
  793. }));
  794. return c + f + g
  795. }), c = 0; 3 > c; c++)a = a.replace(/<([^\s>]+)(\s+[^>]*)?>\s*<\/\1>/g, "");
  796. for (var d = function (a, b, c) {
  797. return c
  798. }, c = 0; 3 > c; c++)a = a.replace(/<(span|a)>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?<\/\1>)*?)<\/\1>/ig, d);
  799. for (c = 0; 3 > c; c++)a = a.replace(/<(span|a)>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,
  800. d);
  801. for (c = 0; 3 > c; c++)a = a.replace(/<(span|a)>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, d);
  802. for (c = 0; 3 > c; c++)a = a.replace(/<font(\s+[^>]+)><font(\s+[^>]+)>/ig, function (a, b, c) {
  803. return "<font" + b + c + ">"
  804. });
  805. a = a.replace(/(<(\/?)(tr|td)(?:\s+[^>]+)?>)[^<>]+/ig, function (a, b, c, d) {
  806. return !c && /^td$/i.test(d) ? a : b
  807. })
  808. }
  809. return a
  810. };
  811. this.cleanHTML = function (a) {
  812. var a = a.replace(/<!?\/?(DOCTYPE|html|body|meta)(\s+[^>]*?)?>/ig, ""), b, a = a.replace(/<head(?:\s+[^>]*?)?>([\s\S]*?)<\/head>/i, function (a, d) {
  813. b = d.match(/<(script|style)(\s+[^>]*?)?>[\s\S]*?<\/\1>/ig);
  814. return ""
  815. });
  816. b && (a = b.join("") + a);
  817. a = a.replace(/<\??xml(:\w+)?(\s+[^>]*?)?>([\s\S]*?<\/xml>)?/ig, "");
  818. g.internalScript || (a = a.replace(/<script(\s+[^>]*?)?>[\s\S]*?<\/script>/ig, ""));
  819. g.internalStyle || (a = a.replace(/<style(\s+[^>]*?)?>[\s\S]*?<\/style>/ig, ""));
  820. if (!g.linkTag || !g.inlineScript || !g.inlineStyle)a = a.replace(/(<(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/ig, function (a, b, d, e, j) {
  821. if (!g.linkTag && "link" === d.toLowerCase())return "";
  822. g.inlineScript || (e = e.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,
  823. ""));
  824. g.inlineStyle || (e = e.replace(/\s+(style|class)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/ig, ""));
  825. return b + e + j
  826. });
  827. return a = a.replace(/<\/(strong|b|u|strike|em|i)>((?:\s|<br\/?>|&nbsp;)*?)<\1(\s+[^>]*?)?>/ig, "$2")
  828. };
  829. this.formatXHTML = function (a, b) {
  830. function c(a) {
  831. for (var b = {}, a = a.split(","), c = 0; c < a.length; c++)b[a[c]] = !0;
  832. return b
  833. }
  834. function e(a) {
  835. var a = a.toLowerCase(), b = o[a];
  836. return b ? b : a
  837. }
  838. function i(a, b, c) {
  839. if (k[a])for (; E.last() && y[E.last()];)g(E.last());
  840. Z[a] && E.last() === a && g(a);
  841. (c = D[a] || !!c) || E.push(a);
  842. var d = [];
  843. d.push("<" +
  844. a);
  845. b.replace(x, function (a, b, c, e, f) {
  846. b = b.toLowerCase();
  847. d.push(" " + b + '="' + (c ? c : e ? e : f ? f : l[b] ? b : "").replace(/"/g, "'") + '"')
  848. });
  849. d.push((c ? " /" : "") + ">");
  850. w(d.join(""), a, !0);
  851. "pre" === a && (B = !0)
  852. }
  853. function g(a) {
  854. if (a)for (b = E.length - 1; 0 <= b && !(E[b] === a); b--); else var b = 0;
  855. if (0 <= b) {
  856. for (var c = E.length - 1; c >= b; c--)w("</" + E[c] + ">", E[c]);
  857. E.length = b
  858. }
  859. "pre" === a && (B = !1, v--)
  860. }
  861. function j(a) {
  862. w(d.domEncode(a))
  863. }
  864. function p(a) {
  865. H.push(a.replace(/^[\s\r\n]+|[\s\r\n]+$/g, ""))
  866. }
  867. function w(a, c, d) {
  868. B || (a = a.replace(/(\t*\r?\n\t*)+/g, ""));
  869. if (!B &&
  870. !0 === b)if (a.match(/^\s*$/))H.push(a); else {
  871. var e = k[c];
  872. e ? (d && v++, "" === A && v--) : A && v++;
  873. ((e ? c : "") !== A || e) && s();
  874. H.push(a);
  875. "br" === c && s();
  876. e && (D[c] || !d) && v--;
  877. A = e ? c : ""
  878. } else H.push(a)
  879. }
  880. function s() {
  881. H.push("\r\n");
  882. if (0 < v)for (var a = v; a--;)H.push("\t")
  883. }
  884. function r(a, b, c, d) {
  885. if (!c)return d;
  886. var e = "", c = c.replace(/ face\s*=\s*"\s*([^"]*)\s*"/i, function (a, b) {
  887. b && (e += "font-family:" + b + ";");
  888. return ""
  889. }), c = c.replace(/ size\s*=\s*"\s*(\d+)\s*"/i, function (a, b) {
  890. e += "font-size:" + T[(7 < b ? 7 : 1 > b ? 1 : b) - 1].s + ";";
  891. return ""
  892. }), c = c.replace(/ color\s*=\s*"\s*([^"]*)\s*"/i,
  893. function (a, b) {
  894. b && (e += "color:" + b + ";");
  895. return ""
  896. }), c = c.replace(/ style\s*=\s*"\s*([^"]*)\s*"/i, function (a, b) {
  897. b && (e += b);
  898. return ""
  899. });
  900. return (c += ' style="' + e + '"') ? "<span" + c + ">" + d + "</span>" : d
  901. }
  902. var D = 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,h1,h2,h3,h4,h5,h6,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,table,tbody,td,tfoot,th,thead,tr,ul,script"), y = 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"),
  903. Z = c("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"), l = c("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"), h = c("script,style"), o = {
  904. b: "strong",
  905. i: "em",
  906. s: "del",
  907. strike: "del"
  908. }, n = /<(?:\/([^\s>]+)|!([^>]*?)|([\w\-:]+)((?:"[^"]*"|'[^']*'|[^"'<>])*)\s*(\/?))>/g, x = /\s*([\w\-:]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?/g, H = [], E = [];
  909. E.last = function () {
  910. return this[this.length - 1]
  911. };
  912. for (var u, C, q = 0, t, z, v = -1, A = "body", B = !1; u = n.exec(a);) {
  913. C = u.index;
  914. C > q && (q =
  915. a.substring(q, C), t ? z.push(q) : j(q));
  916. q = n.lastIndex;
  917. if (C = u[1])if (C = e(C), t && C === t && (p(z.join("")), z = t = null), !t) {
  918. g(C);
  919. continue
  920. }
  921. t ? z.push(u[0]) : (C = u[3]) ? (C = e(C), i(C, u[4], u[5]), h[C] && (t = C, z = [])) : u[2] && H.push(u[0])
  922. }
  923. a.length > q && j(a.substring(q, a.length));
  924. g();
  925. a = H.join("");
  926. H = null;
  927. 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, r);
  928. a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,
  929. r);
  930. a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, r);
  931. return a = a.replace(/^(\s*\r?\n)+|(\s*\r?\n)+$/g, "")
  932. };
  933. this.toggleShowBlocktag = function (a) {
  934. na !== a && (na = !na, a = e(l.body), na ? (Q += " showBlocktag", a.addClass("showBlocktag")) : (Q = Q.replace(" showBlocktag", ""), a.removeClass("showBlocktag")))
  935. };
  936. this.toggleSource = function (a) {
  937. if (x !== a) {
  938. n.find("[cmd=Source]").toggleClass("xheEnabled").toggleClass("xheActive");
  939. var b = l.body, c = e(b), f, i, a = 0, g = "";
  940. if (x)f = d.getSource(), c.html("").removeAttr("scroll").attr("class",
  941. "editMode" + Q), h ? b.contentEditable = "true" : l.designMode = "On", qa && (d._exec("inserthtml", "-"), e("#" + za).show().focus().hide()), g = "Source mode"; else {
  942. d.pasteHTML('<span id="_xhe_cursor"></span>', !0);
  943. f = d.getSource(!0);
  944. a = f.indexOf('<span id="_xhe_cursor"></span>');
  945. if (!Ca)a = f.substring(0, a).replace(/\r/g, "").length;
  946. f = f.replace(/(\r?\n\s*|)<span id="_xhe_cursor"><\/span>(\s*\r?\n|)/, function (a, b, c) {
  947. return b && c ? "\r\n" : b + c
  948. });
  949. h ? b.contentEditable = "false" : l.designMode = "Off";
  950. c.attr("scroll", "no").attr("class", "sourceMode").html('<textarea id="sourceCode" wrap="soft" spellcheck="false" style="width:100%;height:100%" />');
  951. i = e("#sourceCode", c).blur(d.getSource)[0];
  952. g = "WYSIWYG mode"
  953. }
  954. x = !x;
  955. d.setSource(f);
  956. d.focus();
  957. x ? i.setSelectionRange ? i.setSelectionRange(a, a) : (i = i.createTextRange(), i.move("character", a), i.select()) : d.setTextCursor();
  958. n.find("[cmd=Source]").attr("title", g).find("span").text(g);
  959. n.find("[cmd=Source],[cmd=Preview]").toggleClass("xheEnabled");
  960. n.find(".xheButton").not("[cmd=Source],[cmd=Fullscreen],[cmd=About]").toggleClass("xheEnabled").attr("aria-disabled", x ? !0 : !1);
  961. setTimeout(La, 300)
  962. }
  963. };
  964. this.showPreview = function () {
  965. var a =
  966. g.beforeSetSource, b = d.getSource();
  967. a && (b = a(b));
  968. var a = "<html><head>" + P + "<title>Preview</title>" + (F ? '<base href="' + F + '"/>' : "") + "</head><body>" + b + "</body></html>", b = window.screen, b = window.open("", "xhePreview", "toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=" + Math.round(0.9 * b.width) + ",height=" + Math.round(0.8 * b.height) + ",left=" + Math.round(0.05 * b.width)), c = b.document;
  969. c.open();
  970. c.write(a);
  971. c.close();
  972. b.focus()
  973. };
  974. this.toggleFullscreen = function (a) {
  975. if (la !== a) {
  976. var a = e("#" + ja).find(".xheLayout"),
  977. b = e("#" + ja), c = jQuery.browser.version, c = h && (6 == c || 7 == c);
  978. la ? (c && G.after(b), a.attr("style", Za), B.height(O - n.outerHeight()), e(window).scrollTop(Pa), setTimeout(function () {
  979. e(window).scrollTop(Pa)
  980. }, 10)) : (c && e("body").append(b), Pa = e(window).scrollTop(), Za = a.attr("style"), a.removeAttr("style"), B.height("100%"), setTimeout(Na, 100));
  981. qa ? (e("#" + za).show().focus().hide(), setTimeout(d.focus, 1)) : c && d.setTextCursor();
  982. la = !la;
  983. b.toggleClass("xhe_Fullscreen");
  984. e("html").toggleClass("xhe_Fullfix");
  985. n.find("[cmd=Fullscreen]").toggleClass("xheActive");
  986. setTimeout(La, 300)
  987. }
  988. };
  989. this.showMenu = function (a, b) {
  990. var c = e('<div class="xheMenu"></div>'), f = a.length, i = [];
  991. e.each(a, function (a, b) {
  992. "-" === b.s ? i.push('<div class="xheMenuSeparator"></div>') : i.push("<a href=\"javascript:void('" + b.v + '\')" title="' + (b.t ? b.t : b.s) + '" v="' + b.v + '" role="option" aria-setsize="' + f + '" aria-posinset="' + (a + 1) + '" tabindex="0">' + b.s + "</a>")
  993. });
  994. c.append(i.join(""));
  995. c.click(function (a) {
  996. a = a.target;
  997. if (!e.nodeName(a, "DIV"))return d.loadBookmark(), b(e(a).closest("a").attr("v")), d.hidePanel(),
  998. !1
  999. }).mousedown(N);
  1000. d.saveBookmark();
  1001. d.showPanel(c)
  1002. };
  1003. this.showColor = function (a) {
  1004. var b = e('<div class="xheColor"></div>'), c = [], f = Ta.length, i = 0;
  1005. e.each(Ta, function (a, b) {
  1006. 0 === i % 7 && c.push((0 < i ? "</div>" : "") + "<div>");
  1007. c.push("<a href=\"javascript:void('" + b + '\')" xhev="' + b + '" title="' + b + '" style="background:' + b + '" role="option" aria-setsize="' + f + '" aria-posinset="' + (i + 1) + '"></a>');
  1008. i++
  1009. });
  1010. c.push("</div>");
  1011. b.append(c.join(""));
  1012. b.click(function (b) {
  1013. b = b.target;
  1014. if (e.nodeName(b, "A"))return d.loadBookmark(), a(e(b).attr("xhev")),
  1015. d.hidePanel(), !1
  1016. }).mousedown(N);
  1017. d.saveBookmark();
  1018. d.showPanel(b)
  1019. };
  1020. this.showPastetext = function () {
  1021. var a = e('<div><label for="xhePastetextValue">Use Ctrl+V on your keyboard to paste the text.</label></div><div><textarea id="xhePastetextValue" wrap="soft" spellcheck="false" style="width:300px;height:100px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>'), b = e("#xhePastetextValue", a);
  1022. e("#xheSave", a).click(function () {
  1023. d.loadBookmark();
  1024. var a = b.val();
  1025. a && d.pasteText(a);
  1026. d.hidePanel();
  1027. return !1
  1028. });
  1029. d.saveBookmark();
  1030. d.showDialog(a)
  1031. };
  1032. this.showLink = function () {
  1033. var a = '<div><label for="xheLinkUrl">Link URL: </label><input type="text" id="xheLinkUrl" value="http://" class="xheText" /></div><div><label for="xheLinkTarget">Target:&nbsp;&nbsp; </label><select id="xheLinkTarget"><option selected="selected" value="">Default</option><option value="_blank">New window</option><option value="_self">Same window</option><option value="_parent">Parent window</option></select></div><div style="display:none"><label for="xheLinkText">Link Text:</label><input type="text" id="xheLinkText" value="" class="xheText" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>',
  1034. b = ga.find("a[name]").not("[href]"), c = 0 < b.length;
  1035. if (c) {
  1036. var f = [];
  1037. b.each(function () {
  1038. var a = e(this).attr("name");
  1039. f.push('<option value="#' + a + '">' + a + "</option>")
  1040. });
  1041. a = a.replace(/(<div><label for="xheLinkTarget)/, '<div><label for="xheLinkAnchor">Anchor: &nbsp;&nbsp;</label><select id="xheLinkAnchor"><option value="">None selected</option>' + f.join("") + "</select></div>$1")
  1042. }
  1043. var a = e(a), i = d.getParent("a"), m = e("#xheLinkText", a), j = e("#xheLinkUrl", a), p = e("#xheLinkTarget", a), b = e("#xheSave", a), w = d.getSelect();
  1044. c && a.find("#xheLinkAnchor").change(function () {
  1045. var a =
  1046. e(this).val();
  1047. "" != a && j.val(a)
  1048. });
  1049. if (1 === i.length) {
  1050. if (!i.attr("href"))return v = null, d.exec("Anchor");
  1051. j.val(L(i, "href"));
  1052. p.attr("value", i.attr("target"))
  1053. } else"" === w && m.val(g.defLinkText).closest("div").show();
  1054. g.upLinkUrl && d.uploadInit(j, g.upLinkUrl, g.upLinkExt);
  1055. b.click(function () {
  1056. d.loadBookmark();
  1057. var a = j.val();
  1058. ("" === a || 0 === i.length) && d._exec("unlink");
  1059. if ("" !== a && "http://" !== a) {
  1060. var b = a.split(" "), c = p.val(), f = m.val();
  1061. if (1 < b.length) {
  1062. d._exec("unlink");
  1063. w = d.getSelect();
  1064. var g = '<a href="xhe_tmpurl"', Z = [];
  1065. "" !==
  1066. c && (g += ' target="' + c + '"');
  1067. for (var g = g + ">xhe_tmptext</a>", f = "" !== w ? w : f ? f : a, h = 0, pb = b.length; h < pb; h++)a = b[h], "" !== a && (a = a.split("||"), c = g, c = c.replace("xhe_tmpurl", a[0]), c = c.replace("xhe_tmptext", a[1] ? a[1] : f), Z.push(c));
  1068. d.pasteHTML(Z.join("&nbsp;"))
  1069. } else a = b[0].split("||"), f || (f = a[0]), f = a[1] ? a[1] : "" !== w ? "" : f ? f : a[0], 0 === i.length ? (f ? d.pasteHTML('<a href="#xhe_tmpurl">' + f + "</a>") : d._exec("createlink", "#xhe_tmpurl"), i = e('a[href$="#xhe_tmpurl"]', l)) : f && !R && i.text(f), L(i, "href", a[0]), "" !== c ? i.attr("target",
  1070. c) : i.removeAttr("target")
  1071. }
  1072. d.hidePanel();
  1073. return !1
  1074. });
  1075. d.saveBookmark();
  1076. d.showDialog(a)
  1077. };
  1078. this.showAnchor = function () {
  1079. var a = e('<div><label for="xheAnchorName">Anchor name: </label><input type="text" id="xheAnchorName" value="" class="xheText" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>'), b = d.getParent("a"), c = e("#xheAnchorName", a), f = e("#xheSave", a);
  1080. if (1 === b.length) {
  1081. if (b.attr("href"))return v = null, d.exec("Link");
  1082. c.val(b.attr("name"))
  1083. }
  1084. f.click(function () {
  1085. d.loadBookmark();
  1086. var a = c.val();
  1087. a ? 0 === b.length ? d.pasteHTML('<a name="' + a + '"></a>') : b.attr("name", a) : 1 === b.length && b.remove();
  1088. d.hidePanel();
  1089. return !1
  1090. });
  1091. d.saveBookmark();
  1092. d.showDialog(a)
  1093. };
  1094. this.showImg = function () {
  1095. var a = e('<div><label for="xheImgUrl">Img URL:&nbsp; </label><input type="text" id="xheImgUrl" value="http://" class="xheText" /></div><div><div><label for="xheImgAlt">Alt text: </label><input type="text" id="xheImgAlt" /></div><div><label for="xheImgAlign">Alignment:</label><select id="xheImgAlign"><option selected="selected" value="">Default</option><option value="left">Left</option><option value="right">Right</option><option value="top">Top</option><option value="middle">Middle</option><option value="baseline">Baseline</option><option value="bottom">Bottom</option></select></div><div><label for="xheImgWidth">Width:&nbsp; &nbsp; </label><input type="text" id="xheImgWidth" style="width:40px;" /> <label for="xheImgHeight">Height:&nbsp; &nbsp;</label><input type="text" id="xheImgHeight" style="width:40px;" /></div><div><label for="xheImgBorder">Border:&nbsp; &nbsp;</label><input type="text" id="xheImgBorder" style="width:40px;" /></div><div><label for="xheImgHspace">Hspace:&nbsp;&nbsp;&nbsp;</label><input type="text" id="xheImgHspace" style="width:40px;" /> <label for="xheImgVspace">Vspace:&nbsp; &nbsp;</label><input type="text" id="xheImgVspace" style="width:40px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>'),
  1096. b = d.getParent("img"), c = e("#xheImgUrl", a), f = e("#xheImgAlt", a), i = e("#xheImgAlign", a), m = e("#xheImgWidth", a), j = e("#xheImgHeight", a), p = e("#xheImgBorder", a), w = e("#xheImgVspace", a), s = e("#xheImgHspace", a), r = e("#xheSave", a);
  1097. if (1 === b.length) {
  1098. c.val(L(b, "src"));
  1099. f.val(b.attr("alt"));
  1100. i.val(b.attr("align"));
  1101. m.val(b.attr("width"));
  1102. j.val(b.attr("height"));
  1103. p.val(b.attr("border"));
  1104. var D = b.attr("vspace"), k = b.attr("hspace");
  1105. w.val(0 >= D ? "" : D);
  1106. s.val(0 >= k ? "" : k)
  1107. }
  1108. g.upImgUrl && d.uploadInit(c, g.upImgUrl, g.upImgExt);
  1109. r.click(function () {
  1110. d.loadBookmark();
  1111. var a = c.val();
  1112. if ("" !== a && "http://" !== a) {
  1113. var g = a.split(" "), k = f.val(), D = i.val(), r = m.val(), h = j.val(), o = p.val(), q = w.val(), n = s.val();
  1114. if (1 < g.length) {
  1115. var u = '<img src="xhe_tmpurl"', t = [];
  1116. "" !== k && (u += ' alt="' + k + '"');
  1117. "" !== D && (u += ' align="' + D + '"');
  1118. "" !== r && (u += ' width="' + r + '"');
  1119. "" !== h && (u += ' height="' + h + '"');
  1120. "" !== o && (u += ' border="' + o + '"');
  1121. "" !== q && (u += ' vspace="' + q + '"');
  1122. "" !== n && (u += ' hspace="' + n + '"');
  1123. var u = u + " />", v;
  1124. for (v in g)a = g[v], "" !== a && (a = a.split("||"), k = u, k = k.replace("xhe_tmpurl", a[0]), a[1] && (k = '<a href="' +
  1125. a[1] + '" target="_blank">' + k + "</a>"), t.push(k));
  1126. d.pasteHTML(t.join("&nbsp;"))
  1127. } else 1 === g.length && (a = g[0], "" !== a && (a = a.split("||"), 0 === b.length && (d.pasteHTML('<img src="' + a[0] + '#xhe_tmpurl" />'), b = e('img[src$="#xhe_tmpurl"]', l)), L(b, "src", a[0]), "" !== k && b.attr("alt", k), "" !== D ? b.attr("align", D) : b.removeAttr("align"), "" !== r ? b.attr("width", r) : b.removeAttr("width"), "" !== h ? b.attr("height", h) : b.removeAttr("height"), "" !== o ? b.attr("border", o) : b.removeAttr("border"), "" !== q ? b.attr("vspace", q) : b.removeAttr("vspace"),
  1128. "" !== n ? b.attr("hspace", n) : b.removeAttr("hspace"), a[1] && (g = b.parent("a"), 0 === g.length && (b.wrap("<a></a>"), g = b.parent("a")), L(g, "href", a[1]), g.attr("target", "_blank"))))
  1129. } else 1 === b.length && b.remove();
  1130. d.hidePanel();
  1131. return !1
  1132. });
  1133. d.saveBookmark();
  1134. d.showDialog(a)
  1135. };
  1136. this.showEmbed = function (a, b, c, f, g, m, j) {
  1137. var b = e(b), p = d.getParent('embed[type="' + c + '"],embed[classid="' + f + '"]'), w = e("#xhe" + a + "Url", b), s = e("#xhe" + a + "Width", b), r = e("#xhe" + a + "Height", b), a = e("#xheSave", b);
  1138. m && d.uploadInit(w, m, j);
  1139. 1 === p.length && (w.val(L(p,
  1140. "src")), s.val(p.attr("width")), r.val(p.attr("height")));
  1141. a.click(function () {
  1142. d.loadBookmark();
  1143. var a = w.val();
  1144. if ("" !== a && "http://" !== a) {
  1145. var b = s.val(), j = r.val(), m = /^\d+%?$/;
  1146. m.test(b) || (b = 412);
  1147. m.test(j) || (j = 300);
  1148. var h = '<embed type="' + c + '" classid="' + f + '" src="xhe_tmpurl"' + g, m = a.split(" ");
  1149. if (1 < m.length) {
  1150. var o, q = [], h = h + ' width="xhe_width" height="xhe_height" />', n;
  1151. for (n in m)a = m[n].split("||"), o = h, o = o.replace("xhe_tmpurl", a[0]), o = o.replace("xhe_width", a[1] ? a[1] : b), o = o.replace("xhe_height", a[2] ? a[2] : j), "" !==
  1152. a && q.push(o);
  1153. d.pasteHTML(q.join("&nbsp;"))
  1154. } else 1 === m.length && (a = m[0].split("||"), 0 === p.length && (d.pasteHTML(h.replace("xhe_tmpurl", a[0] + "#xhe_tmpurl") + " />"), p = e('embed[src$="#xhe_tmpurl"]', l)), L(p, "src", a[0]), p.attr("width", a[1] ? a[1] : b), p.attr("height", a[2] ? a[2] : j))
  1155. } else 1 === p.length && p.remove();
  1156. d.hidePanel();
  1157. return !1
  1158. });
  1159. d.saveBookmark();
  1160. d.showDialog(b)
  1161. };
  1162. this.showEmot = function (a) {
  1163. var b = e('<div class="xheEmot"></div>'), a = a ? a : Ra ? Ra : "default", c = Aa[a], f = Y + a + "/", g = 0, m = [], j = "", j = c.width, p = c.height, w = c.line,
  1164. s = c.count, c = c.list;
  1165. if (s)for (c = 1; c <= s; c++)g++, m.push("<a href=\"javascript:void('" + c + '\')" style="background-image:url(' + f + c + '.gif);" emot="' + a + "," + c + '" xhev="" title="' + c + '" role="option">&nbsp;</a>'), 0 === g % w && m.push("<br />"); else e.each(c, function (b, c) {
  1166. g++;
  1167. m.push("<a href=\"javascript:void('" + c + '\')" style="background-image:url(' + f + b + '.gif);" emot="' + a + "," + b + '" title="' + c + '" xhev="' + c + '" role="option">&nbsp;</a>');
  1168. 0 === g % w && m.push("<br />")
  1169. });
  1170. var s = w * (j + 12), c = Math.ceil(g / w) * (p + 12), r = 0.75 * s;
  1171. c <= r &&
  1172. (r = "");
  1173. j = e("<style>" + (r ? ".xheEmot div{width:" + (s + 20) + "px;height:" + r + "px;}" : "") + ".xheEmot div a{width:" + j + "px;height:" + p + "px;}</style><div>" + m.join("") + "</div>").click(function (a) {
  1174. var a = a.target, b = e(a);
  1175. if (e.nodeName(a, "A"))return d.loadBookmark(), d.pasteHTML('<img emot="' + b.attr("emot") + '" alt="' + b.attr("xhev") + '">'), d.hidePanel(), !1
  1176. }).mousedown(N);
  1177. b.append(j);
  1178. var h = 0, k = ['<ul role="tablist">'];
  1179. e.each(Aa, function (b, c) {
  1180. h++;
  1181. k.push("<li" + (a === b ? ' class="cur"' : "") + ' role="presentation"><a href="javascript:void(\'' +
  1182. c.name + '\')" group="' + b + '" role="tab" tabindex="0">' + c.name + "</a></li>")
  1183. });
  1184. 1 < h && (k.push('</ul><br style="clear:both;" />'), j = e(k.join("")).click(function (a) {
  1185. Ra = e(a.target).attr("group");
  1186. d.exec("Emot");
  1187. return !1
  1188. }).mousedown(N), b.append(j));
  1189. d.saveBookmark();
  1190. d.showPanel(b)
  1191. };
  1192. this.showTable = function () {
  1193. var a = e('<div><label for="xheTableRows">Rows:&nbsp; &nbsp; &nbsp; &nbsp;</label><input type="text" id="xheTableRows" style="width:40px;" value="3" /> <label for="xheTableColumns">Cols:&nbsp; &nbsp; &nbsp; &nbsp;</label><input type="text" id="xheTableColumns" style="width:40px;" value="2" /></div><div><label for="xheTableHeaders">Headers:&nbsp; &nbsp;&nbsp;</label><select id="xheTableHeaders"><option selected="selected" value="">None</option><option value="row">First row</option><option value="col">First column</option><option value="both">Both</option></select></div><div><label for="xheTableWidth">Width: &nbsp; &nbsp; &nbsp;</label><input type="text" id="xheTableWidth" style="width:40px;" value="200" /> <label for="xheTableHeight">Height:&nbsp; &nbsp; &nbsp;</label><input type="text" id="xheTableHeight" style="width:40px;" value="" /></div><div><label for="xheTableBorder">Border:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" id="xheTableBorder" style="width:40px;" value="1" /></div><div><label for="xheTableCellSpacing">CellSpacing:</label><input type="text" id="xheTableCellSpacing" style="width:40px;" value="1" /> <label for="xheTableCellPadding">CellPadding:</label><input type="text" id="xheTableCellPadding" style="width:40px;" value="1" /></div><div><label for="xheTableAlign">Align:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><select id="xheTableAlign"><option selected="selected" value="">Default</option><option value="left">Left</option><option value="center">Center</option><option value="right">Right</option></select></div><div><label for="xheTableCaption">Caption:&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" id="xheTableCaption" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>'),
  1194. b = e("#xheTableRows", a), c = e("#xheTableColumns", a), f = e("#xheTableHeaders", a), g = e("#xheTableWidth", a), m = e("#xheTableHeight", a), j = e("#xheTableBorder", a), p = e("#xheTableCellSpacing", a), h = e("#xheTableCellPadding", a), s = e("#xheTableAlign", a), r = e("#xheTableCaption", a);
  1195. e("#xheSave", a).click(function () {
  1196. d.loadBookmark();
  1197. var a = r.val(), e = j.val(), l = b.val(), o = c.val(), q = f.val(), n = g.val(), t = m.val(), v = p.val(), z = h.val(), x = s.val(), e = "<table" + ("" !== e ? ' border="' + e + '"' : "") + ("" !== n ? ' width="' + n + '"' : "") + ("" !== t ? ' height="' +
  1198. t + '"' : "") + ("" !== v ? ' cellspacing="' + v + '"' : "") + ("" !== z ? ' cellpadding="' + z + '"' : "") + ("" !== x ? ' align="' + x + '"' : "") + ">";
  1199. "" !== a && (e += "<caption>" + a + "</caption>");
  1200. if ("row" === q || "both" === q) {
  1201. e += "<tr>";
  1202. for (a = 0; a < o; a++)e += '<th scope="col"></th>';
  1203. e += "</tr>";
  1204. l--
  1205. }
  1206. e += "<tbody>";
  1207. for (a = 0; a < l; a++) {
  1208. e += "<tr>";
  1209. for (n = 0; n < o; n++)e = 0 === n && ("col" === q || "both" === q) ? e + '<th scope="row"></th>' : e + "<td></td>";
  1210. e += "</tr>"
  1211. }
  1212. d.pasteHTML(e + "</tbody></table>");
  1213. d.hidePanel();
  1214. return !1
  1215. });
  1216. d.saveBookmark();
  1217. d.showDialog(a)
  1218. };
  1219. this.showAbout = function () {
  1220. var a =
  1221. e('<div style="font:12px Arial;width:245px;word-wrap:break-word;word-break:break-all;outline:none;" role="dialog" tabindex="-1"><p><span style="font-size:20px;color:#1997DF;">xhEditor</span><br />v1.1.14 (build 120701)</p><p>xhEditor is a platform independent WYSWYG XHTML editor based by jQuery,released as Open Source under <a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">LGPL</a>.</p><p>Copyright &copy; <a href="http://xheditor.com/" target="_blank">xhEditor.com</a>. All rights reserved.</p></div>');
  1222. a.find("p").attr("role", "presentation");
  1223. d.showDialog(a, !0);
  1224. setTimeout(function () {
  1225. a.focus()
  1226. }, 100)
  1227. };
  1228. this.addShortcuts = function (a, b) {
  1229. a = a.toLowerCase();
  1230. ma[a] === $ && (ma[a] = []);
  1231. ma[a].push(b)
  1232. };
  1233. this.delShortcuts = function (a) {
  1234. delete ma[a]
  1235. };
  1236. this.uploadInit = function (a, b, c) {
  1237. function f(b) {
  1238. M(b, "string") && (b = [b]);
  1239. var c = !1, d, e = b.length, f, i = [];
  1240. (d = g.onUpload) && d(b);
  1241. for (d = 0; d < e; d++)f = b[d], f = M(f, "string") ? f : f.url, "!" === f.substr(0, 1) && (c = !0, f = f.substr(1)), i.push(f);
  1242. a.val(i.join(" "));
  1243. c && a.closest(".xheDialog").find("#xheSave").click()
  1244. }
  1245. var i = e('<span class="xheUpload"><input type="text" style="visibility:hidden;" tabindex="-1" /><input type="button" value="' + g.upBtnText + '" class="xheBtn" tabindex="-1" /></span>'), m = e(".xheBtn", i), j = g.html5Upload, p = j ? g.upMultiple : 1;
  1246. a.after(i);
  1247. m.before(a);
  1248. b = b.replace(/{editorRoot}/ig, A);
  1249. if ("!" === b.substr(0, 1))m.click(function () {
  1250. d.showIframeModal("Upload file", b.substr(1), f, null, null)
  1251. }); else {
  1252. i.append('<input type="file"' + (1 < p ? ' multiple=""' : "") + ' class="xheFile" size="13" name="filedata" tabindex="-1" />');
  1253. var h = e(".xheFile", i);
  1254. h.change(function () {
  1255. d.startUpload(h[0], b, c, f)
  1256. });
  1257. setTimeout(function () {
  1258. a.closest(".xheDialog").bind("dragenter dragover", N).bind("drop", function (a) {
  1259. var a = a.originalEvent.dataTransfer, e;
  1260. j && a && (e = a.files) && 0 < e.length && d.startUpload(e, b, c, f);
  1261. return !1
  1262. })
  1263. }, 10)
  1264. }
  1265. };
  1266. this.startUpload = function (a, b, c, f) {
  1267. function i(a, c) {
  1268. var e = Object, g = !1;
  1269. try {
  1270. e = eval("(" + a + ")")
  1271. } catch (i) {
  1272. }
  1273. e.err === $ || e.msg === $ ? alert(b + " upload interface error!\r\n\r\nreturn error:\r\n\r\n" + a) : e.err ? alert(e.err) : (m.push(e.msg),
  1274. g = !0);
  1275. (!g || c) && d.removeModal();
  1276. c && g && f(m);
  1277. return g
  1278. }
  1279. var m = [], j = g.html5Upload, p = j ? g.upMultiple : 1, h, s = e('<div style="padding:22px 0;text-align:center;line-height:30px;">File uploading,please wait...<br /></div>'), r = '<img src="' + ua + 'img/loading.gif">';
  1280. if (Ca || !j || a.nodeType && (!(h = a.files) || !h[0].name)) {
  1281. if (!Wa(a.value, c))return;
  1282. s.append(r);
  1283. c = new d.html4Upload(a, b, i)
  1284. } else {
  1285. h || (h = a);
  1286. a = h.length;
  1287. if (a > p) {
  1288. alert("Please do not upload more then " + p + " files.");
  1289. return
  1290. }
  1291. for (p = 0; p < a; p++)if (!Wa(h[p].name, c))return;
  1292. var l =
  1293. e('<div class="xheProgress"><div><span>0%</span></div></div>');
  1294. s.append(l);
  1295. c = new d.html5Upload("filedata", h, b, i, function (a) {
  1296. if (0 <= a.loaded) {
  1297. var b = Math.round(100 * a.loaded / a.total) + "%";
  1298. e("div", l).css("width", b);
  1299. e("span", l).text(b + " ( " + Xa(a.loaded) + " / " + Xa(a.total) + " )")
  1300. } else l.replaceWith(r)
  1301. })
  1302. }
  1303. d.showModal("File uploading(Esc cancel)", s, 320, 150);
  1304. c.start()
  1305. };
  1306. this.html4Upload = function (a, b, c) {
  1307. var d = "jUploadFrame" + (new Date).getTime(), g = this, h = e('<iframe name="' + d + '" class="xheHideArea" />').appendTo("body"),
  1308. j = e('<form action="' + b + '" target="' + d + '" method="post" enctype="multipart/form-data" class="xheHideArea"></form>').appendTo("body"), p = e(a), l = p.clone().attr("disabled", "true");
  1309. p.before(l).appendTo(j);
  1310. this.remove = function () {
  1311. null !== g && (l.before(p).remove(), h.remove(), j.remove(), g = null)
  1312. };
  1313. this.onLoad = function () {
  1314. var a = h[0].contentWindow.document, b = e(a.body).text();
  1315. a.write("");
  1316. g.remove();
  1317. c(b, !0)
  1318. };
  1319. this.start = function () {
  1320. j.submit();
  1321. h.load(g.onLoad)
  1322. };
  1323. return this
  1324. };
  1325. this.html5Upload = function (a, b, c, d, e) {
  1326. function g(b,
  1327. c, d, e) {
  1328. h = new XMLHttpRequest;
  1329. upload = h.upload;
  1330. h.onreadystatechange = function () {
  1331. 4 === h.readyState && d(h.responseText)
  1332. };
  1333. upload ? upload.onprogress = function (a) {
  1334. e(a.loaded)
  1335. } : e(-1);
  1336. h.open("POST", c);
  1337. h.setRequestHeader("Content-Type", "application/octet-stream");
  1338. h.setRequestHeader("Content-Disposition", 'attachment; name="' + encodeURIComponent(a) + '"; filename="' + encodeURIComponent(b.name) + '"');
  1339. h.sendAsBinary && b.getAsBinary ? h.sendAsBinary(b.getAsBinary()) : h.send(b)
  1340. }
  1341. function j(a) {
  1342. e && e({loaded: r + a, total: o})
  1343. }
  1344. for (var h,
  1345. l = 0, s = b.length, r = 0, o = 0, k = this, n = 0; n < s; n++)o += b[n].size;
  1346. this.remove = function () {
  1347. h && (h.abort(), h = null)
  1348. };
  1349. this.uploadNext = function (a) {
  1350. a && (r += b[l - 1].size, j(0));
  1351. (!a || a && !0 === d(a, l === s)) && l < s && g(b[l++], c, k.uploadNext, function (a) {
  1352. j(a)
  1353. })
  1354. };
  1355. this.start = function () {
  1356. k.uploadNext()
  1357. }
  1358. };
  1359. this.showIframeModal = function (a, b, c, f, g, h) {
  1360. function j() {
  1361. try {
  1362. r.callback = l, r.unloadme = d.removeModal, e(r.document).keydown(I), n = r.name
  1363. } catch (a) {
  1364. }
  1365. }
  1366. function l(a) {
  1367. r.document.write("");
  1368. d.removeModal();
  1369. null != a && c(a)
  1370. }
  1371. var b = e('<iframe frameborder="0" src="' +
  1372. b.replace(/{editorRoot}/ig, A) + (/\?/.test(b) ? "&" : "?") + "parenthost=" + location.host + '" style="width:100%;height:100%;display:none;" /><div class="xheModalIfmWait"></div>'), o = b.eq(0), s = b.eq(1);
  1373. d.showModal(a, b, f, g, h);
  1374. var r = o[0].contentWindow, n;
  1375. j();
  1376. o.load(function () {
  1377. j();
  1378. if (n) {
  1379. var a = !0;
  1380. try {
  1381. n = eval("(" + unescape(n) + ")")
  1382. } catch (b) {
  1383. a = !1
  1384. }
  1385. if (a)return l(n)
  1386. }
  1387. s.is(":visible") && (o.show().focus(), s.remove())
  1388. })
  1389. };
  1390. this.showModal = function (a, b, c, f, i) {
  1391. if (ta)return !1;
  1392. d.panelState = S;
  1393. S = !1;
  1394. ea = g.layerShadow;
  1395. c = c ? c : g.modalWidth;
  1396. f =
  1397. f ? f : g.modalHeight;
  1398. K = e('<div class="xheModal" style="width:' + (c - 1) + "px;height:" + f + "px;margin-left:-" + Math.ceil(c / 2) + "px;" + (h && 7 > pa ? "" : "margin-top:-" + Math.ceil(f / 2) + "px") + '">' + (g.modalTitle ? '<div class="xheModalTitle"><span class="xheModalClose" title="Close (Esc)" tabindex="0" role="button"></span>' + a + "</div>" : "") + '<div class="xheModalContent"></div></div>').appendTo("body");
  1399. Fa = e('<div class="xheModalOverlay"></div>').appendTo("body");
  1400. 0 < ea && (Ea = e('<div class="xheModalShadow" style="width:' + K.outerWidth() +
  1401. "px;height:" + K.outerHeight() + "px;margin-left:-" + (Math.ceil(c / 2) - ea - 2) + "px;" + (h && 7 > pa ? "" : "margin-top:-" + (Math.ceil(f / 2) - ea - 2) + "px") + '"></div>').appendTo("body"));
  1402. e(".xheModalContent", K).css("height", f - (g.modalTitle ? e(".xheModalTitle").outerHeight() : 0)).html(b);
  1403. h && 6 === pa && (Ga = e("select:visible").css("visibility", "hidden"));
  1404. e(".xheModalClose", K).click(d.removeModal);
  1405. Fa.show();
  1406. 0 < ea && Ea.show();
  1407. K.show();
  1408. setTimeout(function () {
  1409. K.find("a,input[type=text],textarea").filter(":visible").filter(function () {
  1410. return "hidden" !==
  1411. e(this).css("visibility")
  1412. }).eq(0).focus()
  1413. }, 10);
  1414. ta = !0;
  1415. Ha = i
  1416. };
  1417. this.removeModal = function () {
  1418. Ga && Ga.css("visibility", "visible");
  1419. K.html("").remove();
  1420. 0 < ea && Ea.remove();
  1421. Fa.remove();
  1422. Ha && Ha();
  1423. ta = !1;
  1424. S = d.panelState
  1425. };
  1426. this.showDialog = function (a, b) {
  1427. var c = e('<div class="xheDialog"></div>'), f = e(a), i = e("#xheSave", f);
  1428. if (1 === i.length) {
  1429. f.find("input[type=text],select").keypress(function (a) {
  1430. if (13 === a.which)return i.click(), !1
  1431. });
  1432. f.find("textarea").keydown(function (a) {
  1433. if (a.ctrlKey && 13 === a.which)return i.click(), !1
  1434. });
  1435. i.after(' <input type="button" id="xheCancel" value="Cancel" />');
  1436. e("#xheCancel", f).click(d.hidePanel);
  1437. if (!g.clickCancelDialog) {
  1438. sa = !1;
  1439. var h = e('<div class="xheFixCancel"></div>').appendTo("body").mousedown(N), j = B.offset();
  1440. h.css({left: j.left, top: j.top, width: B.outerWidth(), height: B.outerHeight()})
  1441. }
  1442. c.mousedown(function () {
  1443. oa = !0
  1444. })
  1445. }
  1446. c.append(f);
  1447. d.showPanel(c, b)
  1448. };
  1449. this.showPanel = function (a, b) {
  1450. if (!v.target)return !1;
  1451. t.html("").append(a).css("left", -999).css("top", -999);
  1452. da = e(v.target).closest("a").addClass("xheActive");
  1453. var c = da.offset(), d = c.left, c = c.top, c = c + (da.outerHeight() -
  1454. 1);
  1455. ca.css({left: d + 1, top: c, width: da.width()}).show();
  1456. var i = document.documentElement, h = document.body;
  1457. if (d + t.outerWidth() > (window.pageXOffset || i.scrollLeft || h.scrollLeft) + (i.clientWidth || h.clientWidth))d -= t.outerWidth() - da.outerWidth();
  1458. i = g.layerShadow;
  1459. 0 < i && ba.css({left: d + i, top: c + i, width: t.outerWidth(), height: t.outerHeight()}).show();
  1460. if ((i = e("#" + ja).offsetParent().css("zIndex")) && !isNaN(i))ba.css("zIndex", parseInt(i, 10) + 1), t.css("zIndex", parseInt(i, 10) + 2), ca.css("zIndex", parseInt(i, 10) + 3);
  1461. t.css({
  1462. left: d,
  1463. top: c
  1464. }).show();
  1465. b || setTimeout(function () {
  1466. t.find("a,input[type=text],textarea").filter(":visible").filter(function () {
  1467. return "hidden" !== e(this).css("visibility")
  1468. }).eq(0).focus()
  1469. }, 10);
  1470. Qa = S = !0
  1471. };
  1472. this.hidePanel = function () {
  1473. S && (da.removeClass("xheActive"), ba.hide(), ca.hide(), t.hide(), S = !1, sa || (e(".xheFixCancel").remove(), sa = !0), Qa = oa = !1, X = null, d.focus(), d.loadBookmark())
  1474. };
  1475. this.exec = function (a) {
  1476. d.hidePanel();
  1477. var b = ka[a];
  1478. if (!b)return !1;
  1479. if (null === v) {
  1480. v = {};
  1481. var c = n.find(".xheButton[cmd=" + a + "]");
  1482. if (1 === c.length)v.target =
  1483. c
  1484. }
  1485. if (b.e)b.e.call(d); else switch (a = a.toLowerCase(), a) {
  1486. case "cut":
  1487. try {
  1488. if (l.execCommand(a), !l.queryCommandSupported(a))throw"Error";
  1489. } catch (f) {
  1490. alert("Currently not supported by your browser, use keyboard shortcuts(Ctrl+X) instead.")
  1491. }
  1492. break;
  1493. case "copy":
  1494. try {
  1495. if (l.execCommand(a), !l.queryCommandSupported(a))throw"Error";
  1496. } catch (i) {
  1497. alert("Currently not supported by your browser, use keyboard shortcuts(Ctrl+C) instead.")
  1498. }
  1499. break;
  1500. case "paste":
  1501. try {
  1502. if (l.execCommand(a), !l.queryCommandSupported(a))throw"Error";
  1503. } catch (m) {
  1504. alert("Currently not supported by your browser, use keyboard shortcuts(Ctrl+V) instead.")
  1505. }
  1506. break;
  1507. case "pastetext":
  1508. window.clipboardData ? d.pasteText(window.clipboardData.getData("Text", !0)) : d.showPastetext();
  1509. break;
  1510. case "blocktag":
  1511. var j = [];
  1512. e.each(gb, function (a, b) {
  1513. j.push({s: "<" + b.n + ">" + b.t + "</" + b.n + ">", v: "<" + b.n + ">", t: b.t})
  1514. });
  1515. d.showMenu(j, function (a) {
  1516. d._exec("formatblock", a)
  1517. });
  1518. break;
  1519. case "fontface":
  1520. var o = [];
  1521. e.each(hb, function (a, b) {
  1522. b.c = b.c ? b.c : b.n;
  1523. o.push({s: '<span style="font-family:' + b.c + '">' + b.n + "</span>", v: b.c, t: b.n})
  1524. });
  1525. d.showMenu(o, function (a) {
  1526. d._exec("fontname", a)
  1527. });
  1528. break;
  1529. case "fontsize":
  1530. var q =
  1531. [];
  1532. e.each(T, function (a, b) {
  1533. q.push({s: '<span style="font-size:' + b.s + ';">' + b.t + "(" + b.s + ")</span>", v: a + 1, t: b.t})
  1534. });
  1535. d.showMenu(q, function (a) {
  1536. d._exec("fontsize", a)
  1537. });
  1538. break;
  1539. case "fontcolor":
  1540. d.showColor(function (a) {
  1541. d._exec("forecolor", a)
  1542. });
  1543. break;
  1544. case "backcolor":
  1545. d.showColor(function (a) {
  1546. h ? d._exec("backcolor", a) : (Ka(!0), d._exec("hilitecolor", a), Ka(!1))
  1547. });
  1548. break;
  1549. case "align":
  1550. d.showMenu(ib, function (a) {
  1551. d._exec(a)
  1552. });
  1553. break;
  1554. case "list":
  1555. d.showMenu(jb, function (a) {
  1556. d._exec(a)
  1557. });
  1558. break;
  1559. case "link":
  1560. d.showLink();
  1561. break;
  1562. case "anchor":
  1563. d.showAnchor();
  1564. break;
  1565. case "img":
  1566. d.showImg();
  1567. break;
  1568. case "flash":
  1569. d.showEmbed("Flash", '<div><label for="xheFlashUrl">Flash URL:</label><input type="text" id="xheFlashUrl" value="http://" class="xheText" /></div><div><label for="xheFlashWidth">Width:&nbsp; &nbsp; </label><input type="text" id="xheFlashWidth" style="width:40px;" value="480" /> <label for="xheFlashHeight">Height:&nbsp; &nbsp;</label><input type="text" id="xheFlashHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>',
  1570. "application/x-shockwave-flash", "clsid:d27cdb6e-ae6d-11cf-96b8-4445535400000", ' wmode="opaque" quality="high" menu="false" play="true" loop="true" allowfullscreen="true"', g.upFlashUrl, g.upFlashExt);
  1571. break;
  1572. case "media":
  1573. d.showEmbed("Media", '<div><label for="xheMediaUrl">Media URL:</label><input type="text" id="xheMediaUrl" value="http://" class="xheText" /></div><div><label for="xheMediaWidth">Width:&nbsp; &nbsp; </label><input type="text" id="xheMediaWidth" style="width:40px;" value="480" /> <label for="xheMediaHeight">Height:&nbsp; &nbsp;</label><input type="text" id="xheMediaHeight" style="width:40px;" value="400" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="Ok" /></div>',
  1574. "application/x-mplayer2", "clsid:6bf52a52-394a-11d3-b153-00c04f79faa6", ' enablecontextmenu="false" autostart="false"', g.upMediaUrl, g.upMediaExt);
  1575. break;
  1576. case "hr":
  1577. d.pasteHTML("<hr />");
  1578. break;
  1579. case "emot":
  1580. d.showEmot();
  1581. break;
  1582. case "table":
  1583. d.showTable();
  1584. break;
  1585. case "source":
  1586. d.toggleSource();
  1587. break;
  1588. case "preview":
  1589. d.showPreview();
  1590. break;
  1591. case "print":
  1592. W.print();
  1593. break;
  1594. case "fullscreen":
  1595. d.toggleFullscreen();
  1596. break;
  1597. case "about":
  1598. d.showAbout();
  1599. break;
  1600. default:
  1601. d._exec(a)
  1602. }
  1603. v = null
  1604. };
  1605. this._exec = function (a, b, c) {
  1606. c || d.focus();
  1607. return b !==
  1608. $ ? l.execCommand(a, !1, b) : l.execCommand(a, !1, null)
  1609. }
  1610. };
  1611. ra.settings = {
  1612. skin: "default",
  1613. tools: "full",
  1614. clickCancelDialog: !0,
  1615. linkTag: !1,
  1616. internalScript: !1,
  1617. inlineScript: !1,
  1618. internalStyle: !0,
  1619. inlineStyle: !0,
  1620. showBlocktag: !1,
  1621. forcePtag: !0,
  1622. upLinkExt: "zip,rar,txt",
  1623. upImgExt: "jpg,jpeg,gif,png",
  1624. upFlashExt: "swf",
  1625. upMediaExt: "wmv,avi,wma,mp3,mid",
  1626. modalWidth: 350,
  1627. modalHeight: 220,
  1628. modalTitle: !0,
  1629. defLinkText: "Click here",
  1630. layerShadow: 3,
  1631. emotMark: !1,
  1632. upBtnText: "Upload",
  1633. cleanPaste: 1,
  1634. hoverExecDelay: 100,
  1635. html5Upload: !0,
  1636. upMultiple: 99
  1637. };
  1638. window.xheditor =
  1639. ra;
  1640. e(function () {
  1641. e.fn.oldVal = e.fn.val;
  1642. e.fn.val = function (e) {
  1643. var h = this, q;
  1644. return e === $ ? h[0] && (q = h[0].xheditor) ? q.getSource() : h.oldVal() : h.each(function () {
  1645. (q = this.xheditor) ? q.setSource(e) : h.oldVal(e)
  1646. })
  1647. };
  1648. e("textarea").each(function () {
  1649. var h = e(this), o = h.attr("class");
  1650. if (o && (o = o.match(/(?:^|\s)xheditor(?:\-(m?full|simple|mini))?(?:\s|$)/i)))h.xheditor(o[1] ? {tools: o[1]} : null)
  1651. })
  1652. })
  1653. })(jQuery);