xheditor-1.1.14-zh-cn.min.js 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683
  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: "\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"}], hb = [{n: "\u5b8b\u4f53", c: "SimSun"}, {
  74. n: "\u4eff\u5b8b\u4f53",
  75. c: "FangSong_GB2312"
  76. }, {n: "\u9ed1\u4f53", c: "SimHei"}, {n: "\u6977\u4f53", c: "KaiTi_GB2312"}, {n: "\u5fae\u8f6f\u96c5\u9ed1", c: "Microsoft YaHei"}, {n: "Arial"}, {n: "Arial Black"},
  77. {n: "Comic Sans MS"}, {n: "Courier New"}, {n: "System"}, {n: "Times New Roman"}, {n: "Tahoma"}, {n: "Verdana"}], T = [{n: "x-small", s: "10px", t: "\u6781\u5c0f"}, {n: "small", s: "12px", t: "\u7279\u5c0f"}, {n: "medium", s: "16px", t: "\u5c0f"}, {n: "large", s: "18px", t: "\u4e2d"}, {n: "x-large", s: "24px", t: "\u5927"}, {n: "xx-large", s: "32px", t: "\u7279\u5927"}, {
  78. n: "-webkit-xxx-large",
  79. s: "48px",
  80. t: "\u6781\u5927"
  81. }], ib = [{s: "\u5de6\u5bf9\u9f50", v: "justifyleft"}, {s: "\u5c45\u4e2d", v: "justifycenter"}, {s: "\u53f3\u5bf9\u9f50", v: "justifyright"}, {
  82. s: "\u4e24\u7aef\u5bf9\u9f50",
  83. v: "justifyfull"
  84. }], jb = [{s: "\u6570\u5b57\u5217\u8868", v: "insertOrderedList"}, {s: "\u7b26\u53f7\u5217\u8868", v: "insertUnorderedList"}], kb = {
  85. "default": {
  86. name: "\u9ed8\u8ba4", width: 24, height: 24, line: 7, list: {
  87. 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",
  88. 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"
  89. }
  90. }
  91. }, ka = {
  92. Cut: {t: "\u526a\u5207 (Ctrl+X)"},
  93. Copy: {t: "\u590d\u5236 (Ctrl+C)"},
  94. Paste: {t: "\u7c98\u8d34 (Ctrl+V)"},
  95. Pastetext: {t: "\u7c98\u8d34\u6587\u672c", h: h ? 0 : 1},
  96. Blocktag: {t: "\u6bb5\u843d\u6807\u7b7e", h: 1},
  97. Fontface: {
  98. t: "\u5b57\u4f53",
  99. h: 1
  100. },
  101. FontSize: {t: "\u5b57\u4f53\u5927\u5c0f", h: 1},
  102. Bold: {t: "\u52a0\u7c97 (Ctrl+B)", s: "Ctrl+B"},
  103. Italic: {t: "\u659c\u4f53 (Ctrl+I)", s: "Ctrl+I"},
  104. Underline: {t: "\u4e0b\u5212\u7ebf (Ctrl+U)", s: "Ctrl+U"},
  105. Strikethrough: {t: "\u5220\u9664\u7ebf"},
  106. FontColor: {t: "\u5b57\u4f53\u989c\u8272", h: 1},
  107. BackColor: {t: "\u80cc\u666f\u989c\u8272", h: 1},
  108. SelectAll: {t: "\u5168\u9009 (Ctrl+A)"},
  109. Removeformat: {t: "\u5220\u9664\u6587\u5b57\u683c\u5f0f"},
  110. Align: {t: "\u5bf9\u9f50", h: 1},
  111. List: {t: "\u5217\u8868", h: 1},
  112. Outdent: {t: "\u51cf\u5c11\u7f29\u8fdb"},
  113. Indent: {t: "\u589e\u52a0\u7f29\u8fdb"},
  114. Link: {t: "\u8d85\u94fe\u63a5 (Ctrl+L)", s: "Ctrl+L", h: 1},
  115. Unlink: {t: "\u53d6\u6d88\u8d85\u94fe\u63a5"},
  116. Anchor: {t: "\u951a\u70b9", h: 1},
  117. Img: {t: "\u56fe\u7247", h: 1},
  118. Flash: {t: "Flash\u52a8\u753b", h: 1},
  119. Media: {t: "\u591a\u5a92\u4f53\u6587\u4ef6", h: 1},
  120. Hr: {t: "\u63d2\u5165\u6c34\u5e73\u7ebf"},
  121. Emot: {t: "\u8868\u60c5", s: "ctrl+e", h: 1},
  122. Table: {t: "\u8868\u683c", h: 1},
  123. Source: {t: "\u6e90\u4ee3\u7801"},
  124. Preview: {t: "\u9884\u89c8"},
  125. Print: {t: "\u6253\u5370 (Ctrl+P)", s: "Ctrl+P"},
  126. Fullscreen: {
  127. t: "\u5168\u5c4f\u7f16\u8f91 (Esc)",
  128. s: "Esc"
  129. },
  130. About: {t: "\u5173\u4e8e xhEditor"}
  131. }, Ia = {
  132. mini: "Bold,Italic,Underline,Strikethrough,|,Align,List,|,Link,Img",
  133. simple: "Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,|,Align,List,Outdent,Indent,|,Img",
  134. 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"
  135. };
  136. Ia.mfull = Ia.full.replace(/\|(,Align)/i, "/$1");
  137. var lb = {a: "Link", img: "Img", embed: "Embed"}, mb = {"<": "&lt;", ">": "&gt;", '"': "&quot;", "\u00ae": "&reg;", "\u00a9": "&copy;"}, nb = /[<>"\u00ae\u00a9]/g, ra = function (z, o) {
  138. function q(a) {
  139. var a = a.target, b = lb[a.tagName.toLowerCase()];
  140. b && ("Embed" === b && (b = {"application/x-shockwave-flash": "Flash", "application/x-mplayer2": "Media"}[a.type.toLowerCase()]), d.exec(b))
  141. }
  142. function I(a) {
  143. if (27 === a.which)return ta ? d.removeModal() : S && d.hidePanel(), !1
  144. }
  145. function J() {
  146. setTimeout(d.setSource,
  147. 10)
  148. }
  149. function U() {
  150. d.getSource()
  151. }
  152. function Ua(a) {
  153. var b, c, f;
  154. 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 () {
  155. var a = '<img src="' + event.target.result + '">', a = Va(a);
  156. d.pasteHTML(a)
  157. }, b.readAsDataURL(a), !1;
  158. var i = g.cleanPaste;
  159. if (0 === i || x || Ja)return !0;
  160. Ja = !0;
  161. d.saveBookmark();
  162. var a = h ? "pre" : "div", m = e("<" + a + ' class="xhe-paste">\ufeff\ufeff</' + a + ">", l).appendTo(l.body), a = m[0];
  163. b = d.getSel();
  164. c = d.getRng(!0);
  165. m.css("top", fa.scrollTop());
  166. h ? (c.moveToElementText(a), c.select()) : (c.selectNodeContents(a), b.removeAllRanges(), b.addRange(c));
  167. setTimeout(function () {
  168. var a = 3 === i, b;
  169. if (a)b = m.text(); else {
  170. var c = [];
  171. e(".xhe-paste", l.body).each(function (a, b) {
  172. 0 == e(b).find(".xhe-paste").length && c.push(b.innerHTML)
  173. });
  174. b = c.join("<br />")
  175. }
  176. m.remove();
  177. d.loadBookmark();
  178. 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 =
  179. Va(b), d.pasteHTML(b);
  180. Ja = !1
  181. }, 0)
  182. }
  183. function Va(a) {
  184. var b = g.localUrlTest, c = g.remoteImgSaveUrl;
  185. if (b && c) {
  186. var f = [], i = 0, a = a.replace(/(<img)((?:\s+[^>]*?)?(?:\s+src="\s*([^"]+)\s*")(?: [^>]*)?)(\/?>)/ig, function (a, c, d, e, s) {
  187. /^(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++ + '"'));
  188. return c + d + s
  189. });
  190. 0 < f.length && e.post(c, {urls: f.join("|")}, function (a) {
  191. a = a.split("|");
  192. e("img[remoteimg]",
  193. d.doc).each(function () {
  194. var b = e(this);
  195. L(b, "src", a[b.attr("remoteimg")]);
  196. b.removeAttr("remoteimg")
  197. })
  198. })
  199. }
  200. return a
  201. }
  202. function Ka(a) {
  203. try {
  204. d._exec("styleWithCSS", a, !0)
  205. } catch (b) {
  206. try {
  207. d._exec("useCSS", !a, !0)
  208. } catch (c) {
  209. }
  210. }
  211. }
  212. function La() {
  213. if (Ma && !x) {
  214. Ka(!1);
  215. try {
  216. d._exec("enableObjectResizing", !0, !0)
  217. } catch (a) {
  218. }
  219. if (h)try {
  220. d._exec("BackgroundImageCache", !0, !0)
  221. } catch (b) {
  222. }
  223. }
  224. }
  225. function Ba(a) {
  226. if (x || 13 !== a.which || a.shiftKey || a.ctrlKey || a.altKey)return !0;
  227. a = d.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li");
  228. if (a.is("li"))return !0;
  229. 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
  230. }
  231. function Na() {
  232. !qa && !R && (la && B.height("100%").css("height", B.outerHeight() - n.outerHeight()), h && n.hide().show())
  233. }
  234. function Da(a) {
  235. a = a.target;
  236. if (a.tagName.match(/(img|embed)/i)) {
  237. var b = d.getSel(), c = d.getRng(!0);
  238. c.selectNode(a);
  239. b.removeAllRanges();
  240. b.addRange(c)
  241. }
  242. }
  243. function L(a, b, c) {
  244. if (!b)return !1;
  245. var d = "_xhe_" + b;
  246. c && (va && (c = V(c,
  247. va, F)), a.attr(b, F ? V(c, "abs", F) : c).removeAttr(d).attr(d, c));
  248. return a.attr(d) || a.attr(b)
  249. }
  250. function Oa() {
  251. sa && d.hidePanel()
  252. }
  253. function ob(a) {
  254. if (x)return !0;
  255. var b = a.which, c = fb[b], b = c ? c : String.fromCharCode(b).toLowerCase();
  256. sKey = "";
  257. sKey += a.ctrlKey ? "ctrl+" : "";
  258. sKey += a.altKey ? "alt+" : "";
  259. sKey += a.shiftKey ? "shift+" : "";
  260. sKey += b;
  261. var a = ma[sKey], f;
  262. for (f in a)if (f = a[f], e.isFunction(f)) {
  263. if (!1 === f.call(d))return !1
  264. } else return d.exec(f), !1
  265. }
  266. function M(a, b) {
  267. var c = typeof a;
  268. return !b ? "undefined" != c : "array" === b && a.hasOwnProperty &&
  269. a instanceof Array ? !0 : c === b
  270. }
  271. function V(a, b, c) {
  272. if (a.match(/^(\w+):\/\//i) && !a.match(/^https?:/i) || /^#/i.test(a) || /^data:/i.test(a))return a;
  273. 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, "");
  274. "" === j && (j = "80");
  275. "" === d ? d = "/" : "/" !== d.charAt(0) && (d = "/" + d);
  276. a = e.trim(a);
  277. "abs" !== b && (a = a.replace(RegExp(c + "\\/\\/" + m.replace(/\./g, "\\.") + "(?::" + j + ")" + ("80" === j ? "?" : "") + "(/|$)", "i"), "/"));
  278. "rel" === b && (a = a.replace(RegExp("^" +
  279. d.replace(/([\/\.\+\[\]\(\)])/g, "\\$1"), "i"), ""));
  280. if ("rel" !== b && (a.match(/^(https?:\/\/|\/)/i) || (a = d + a), "/" === a.charAt(0))) {
  281. 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);
  282. "" === a[p - 1] && m.push("");
  283. a = "/" + m.join("/")
  284. }
  285. "abs" === b && !a.match(/^https?:\/\//i) && (a = c + "//" + i + a);
  286. return a = a.replace(/(https?:\/\/[^:\/?#]+):80(\/|$)/i, "$1$2")
  287. }
  288. function Wa(a, b) {
  289. if ("*" === b || a.match(RegExp(".(" + b.replace(/,/g, "|") + ")$", "i")))return !0;
  290. alert("\u4e0a\u4f20\u6587\u4ef6\u6269\u5c55\u540d\u5fc5\u9700\u4e3a: " +
  291. b);
  292. return !1
  293. }
  294. function Xa(a) {
  295. var b = Math.floor(Math.log(a) / Math.log(1024));
  296. return (a / Math.pow(1024, Math.floor(b))).toFixed(2) + "Byte,KB,MB,GB,TB,PB".split(",")[b]
  297. }
  298. function N() {
  299. return !1
  300. }
  301. 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 = [];
  302. xa && (ka = e.extend({}, ka, xa), e.each(xa, function (a) {
  303. ya.push(a)
  304. }), ya = ya.join(","));
  305. if (g.tools.match(/^\s*(m?full|simple|mini)\s*$/i)) {
  306. var $a =
  307. Ia[e.trim(g.tools)];
  308. g.tools = g.tools.match(/m?full/i) && xa ? $a.replace("Table", "Table," + ya) : $a
  309. }
  310. g.tools.match(/(^|,)\s*About\s*(,|$)/i) || (g.tools += ",About");
  311. g.tools = g.tools.split(",");
  312. if (g.editorRoot)A = g.editorRoot;
  313. !1 === eb && (A = V(A, "abs"));
  314. if (g.urlBase)g.urlBase = V(g.urlBase, "abs");
  315. 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,
  316. Y = Y ? Y : A + "xheditor_emot/", Ra = "", Aa = e.extend({}, Aa, g.emots), Y = V(Y, "rel", F ? F : null);
  317. (na = g.showBlocktag) && (Q += " showBlocktag");
  318. var ma = [];
  319. this.init = function () {
  320. 0 === e("#" + ab).length && e("head").append('<link id="' + ab + '" rel="stylesheet" type="text/css" href="' + ua + 'ui.css" />');
  321. var a = G.outerWidth(), b = G.outerHeight(), a = g.width || z.style.width || (10 < a ? a : 0);
  322. O = g.height || z.style.height || (10 < b ? b : 150);
  323. M(a, "number") && (a += "px");
  324. M(O, "string") && (O = O.replace(/[^\d]+/g, ""));
  325. var b = g.background || z.style.background, c = ['<span class="xheGStart"/>'],
  326. f, i, m = /\||\//i;
  327. e.each(g.tools, function (a, b) {
  328. b.match(m) && c.push('<span class="xheGEnd"/>');
  329. if ("|" === b)c.push('<span class="xheSeparator"/>'); else if ("/" === b)c.push("<br />"); else {
  330. f = ka[b];
  331. if (!f)return;
  332. i = f.c ? f.c : "xheIcon xheBtn" + b;
  333. 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>");
  334. f.s && d.addShortcuts(f.s, b)
  335. }
  336. b.match(m) &&
  337. c.push('<span class="xheGStart"/>')
  338. });
  339. c.push('<span class="xheGEnd"/><br />');
  340. 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="' +
  341. db + '" src="javascript:;" style="width:100%;"></iframe></td></tr></table></span>'));
  342. n = e("#" + bb);
  343. B = e("#" + cb);
  344. P = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="' + ua + 'iframe.css"/>';
  345. 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 + '"/>');
  346. j = "<html><head>" + P + "<title>\u53ef\u89c6\u5316\u7f16\u8f91\u5668,alt+1\u52309\u952e,\u5207\u6362\u5230\u5de5\u5177\u533a,tab\u952e,\u9009\u62e9\u6309\u94ae,esc\u952e,\u8fd4\u56de\u7f16\u8f91 " +
  347. (g.readTip ? g.readTip : "") + "</title>";
  348. b && (j += "<style>html{background:" + b + ";}</style>");
  349. j += '</head><body spellcheck="0" class="editMode' + Q + '"></body></html>';
  350. d.win = W = e("#" + db)[0].contentWindow;
  351. fa = e(W);
  352. try {
  353. this.doc = l = W.document, ga = e(l), l.open(), l.write(j), l.close(), h ? l.body.contentEditable = "true" : l.designMode = "On"
  354. } catch (p) {
  355. }
  356. setTimeout(La, 300);
  357. d.setSource();
  358. W.setInterval = null;
  359. n.append(c.join("")).bind("mousedown contextmenu", N).click(function (a) {
  360. var b = e(a.target).closest("a");
  361. b.is(".xheEnabled") && (clearTimeout(wa),
  362. n.find("a").attr("tabindex", "-1"), v = a, d.exec(b.attr("cmd")));
  363. return !1
  364. });
  365. n.find(".xheButton").hover(function (a) {
  366. var b = e(this), c = g.hoverExecDelay, k = X;
  367. X = null;
  368. if (-1 === c || oa || !b.is(".xheEnabled"))return !1;
  369. if (k && 10 < k)return oa = !0, setTimeout(function () {
  370. oa = !1
  371. }, 100), !1;
  372. var f = b.attr("cmd");
  373. if (1 !== ka[f].h)return d.hidePanel(), !1;
  374. Qa && (c = 0);
  375. 0 <= c && (wa = setTimeout(function () {
  376. v = a;
  377. ia = {x: v.clientX, y: v.clientY};
  378. d.exec(f)
  379. }, c))
  380. }, function () {
  381. ia = null;
  382. wa && clearTimeout(wa)
  383. }).mousemove(function (a) {
  384. if (ia) {
  385. var b = a.clientX - ia.x,
  386. c = a.clientY - ia.y;
  387. 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}
  388. }
  389. });
  390. t = e("#xhePanel");
  391. ba = e("#xheShadow");
  392. ca = e("#xheCntLine");
  393. 0 === t.length && (t = e('<div id="xhePanel"></div>').mousedown(function (a) {
  394. a.stopPropagation()
  395. }), ba = e('<div id="xheShadow"></div>'), ca = e('<div id="xheCntLine"></div>'), setTimeout(function () {
  396. e(document.body).append(t).append(ba).append(ca)
  397. }, 10));
  398. e("#" + ja).show();
  399. G.hide();
  400. B.css("height", O - n.outerHeight());
  401. h & 8 > pa && setTimeout(function () {
  402. B.css("height", O - n.outerHeight())
  403. }, 1);
  404. G.focus(d.focus);
  405. Ya.submit(U).bind("reset", J);
  406. g.submitID && e("#" + g.submitID).mousedown(U);
  407. e(window).bind("unload beforeunload", U).bind("resize", Na);
  408. e(document).mousedown(Oa);
  409. Sa || (e(document).keydown(I), Sa = !0);
  410. fa.focus(function () {
  411. g.focus && g.focus()
  412. }).blur(function () {
  413. g.blur && g.blur()
  414. });
  415. R && fa.click(Da);
  416. ga.mousedown(Oa).keydown(ob).keypress(Ba).dblclick(q).bind("mousedown click", function (a) {
  417. G.trigger(a.type)
  418. });
  419. if (h) {
  420. ga.keydown(function (a) {
  421. var b =
  422. d.getRng();
  423. if (8 === a.which && b.item)return e(b.item(0)).remove(), !1
  424. });
  425. var w = function (a) {
  426. var a = e(a.target), b;
  427. (b = a.css("width")) && a.css("width", "").attr("width", b.replace(/[^0-9%]+/g, ""));
  428. (b = a.css("height")) && a.css("height", "").attr("height", b.replace(/[^0-9%]+/g, ""))
  429. };
  430. ga.bind("controlselect", function (a) {
  431. a = a.target;
  432. e.nodeName(a, "IMG") && e(a).unbind("resizeend", w).bind("resizeend", w)
  433. })
  434. }
  435. ga.keydown(function (a) {
  436. var b = a.which;
  437. if (a.altKey && 49 <= b && 57 >= b)return n.find("a").attr("tabindex", "0"), n.find(".xheGStart").eq(b -
  438. 49).next().find("a").focus(), l.title = "\ufeff\ufeff", !1
  439. }).click(function () {
  440. n.find("a").attr("tabindex", "-1")
  441. });
  442. n.keydown(function (a) {
  443. var b = a.which;
  444. 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
  445. });
  446. j = e(l.documentElement);
  447. Ca ? j.bind("keydown", function (a) {
  448. a.ctrlKey && 86 === a.which && Ua()
  449. }) : j.bind(h ? "beforepaste" : "paste", Ua);
  450. g.disableContextmenu && j.bind("contextmenu", N);
  451. g.html5Upload && j.bind("dragenter dragover",
  452. function (a) {
  453. var b;
  454. if ((b = a.originalEvent.dataTransfer.types) && -1 !== e.inArray("Files", b))return !1
  455. }).bind("drop", function (a) {
  456. var a = a.originalEvent.dataTransfer, b;
  457. if (a && (b = a.files) && 0 < b.length) {
  458. var c, k, a = ["Link", "Img", "Flash", "Media"], f = [], j;
  459. for (c in a)k = a[c], g["up" + k + "Url"] && g["up" + k + "Url"].match(/^[^!].*/i) && f.push(k + ":," + g["up" + k + "Ext"]);
  460. if (0 === f.length)return !1;
  461. j = f.join(",");
  462. k = function (a) {
  463. var b, d;
  464. for (c = 0; c < a.length; c++)if (b = a[c].name.replace(/.+\./, ""), b = j.match(RegExp("(\\w+):[^:]*," + b + "(?:,|$)",
  465. "i")))if (d) {
  466. if (d !== b[1])return 2
  467. } else d = b[1]; else return 1;
  468. return d
  469. }(b);
  470. 1 === k ? alert("\u4e0a\u4f20\u6587\u4ef6\u7684\u6269\u5c55\u540d\u5fc5\u9700\u4e3a\uff1a" + j.replace(/\w+:,/g, "")) : 2 === k ? alert("\u6bcf\u6b21\u53ea\u80fd\u62d6\u653e\u4e0a\u4f20\u540c\u4e00\u7c7b\u578b\u6587\u4ef6") : k && d.startUpload(b, g["up" + k + "Url"], "*", function (a) {
  471. var b = [], c;
  472. (c = g.onUpload) && c(a);
  473. 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);
  474. d.exec(k);
  475. e("#xhe" +
  476. k + "Url").val(b.join(" "));
  477. e("#xheSave").click()
  478. });
  479. return !1
  480. }
  481. });
  482. (j = g.shortcuts) && e.each(j, function (a, b) {
  483. d.addShortcuts(a, b)
  484. });
  485. aa++;
  486. Ma = !0;
  487. g.fullscreen ? d.toggleFullscreen() : g.sourceMode && setTimeout(d.toggleSource, 20);
  488. return !0
  489. };
  490. this.remove = function () {
  491. d.hidePanel();
  492. U();
  493. G.unbind("focus", d.focus);
  494. Ya.unbind("submit", U).unbind("reset", J);
  495. g.submitID && e("#" + g.submitID).unbind("mousedown", U);
  496. e(window).unbind("unload beforeunload", U).unbind("resize", Na);
  497. e(document).unbind("mousedown", Oa);
  498. e("#" + ja).remove();
  499. e("#" +
  500. za).remove();
  501. G.show();
  502. Ma = !1
  503. };
  504. this.saveBookmark = function () {
  505. if (!x) {
  506. d.focus();
  507. var a = d.getRng(), a = a.cloneRange ? a.cloneRange() : a;
  508. ha = {top: fa.scrollTop(), rng: a}
  509. }
  510. };
  511. this.loadBookmark = function () {
  512. if (!x && ha) {
  513. d.focus();
  514. var a = ha.rng;
  515. if (h)a.select(); else {
  516. var b = d.getSel();
  517. b.removeAllRanges();
  518. b.addRange(a)
  519. }
  520. fa.scrollTop(ha.top);
  521. ha = null
  522. }
  523. };
  524. this.focus = function () {
  525. x ? e("#sourceCode", l).focus() : W.focus();
  526. if (h) {
  527. var a = d.getRng();
  528. a.parentElement && a.parentElement().ownerDocument !== l && d.setTextCursor()
  529. }
  530. return !1
  531. };
  532. this.setTextCursor =
  533. function (a) {
  534. var b = d.getRng(!0), c = l.body;
  535. if (h)b.moveToElementText(c); else {
  536. for (var e = a ? "lastChild" : "firstChild"; 3 != c.nodeType && c[e];)c = c[e];
  537. b.selectNode(c)
  538. }
  539. b.collapse(a ? !1 : !0);
  540. h ? b.select() : (a = d.getSel(), a.removeAllRanges(), a.addRange(b))
  541. };
  542. this.getSel = function () {
  543. return l.selection ? l.selection : W.getSelection()
  544. };
  545. this.getRng = function (a) {
  546. var b, c;
  547. try {
  548. 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())
  549. } catch (e) {
  550. }
  551. return c
  552. };
  553. this.getParent = function (a) {
  554. var b = d.getRng(), c;
  555. h ? c = b.item ? b.item(0) : 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]));
  556. a = a ? a : "*";
  557. c = e(c);
  558. c.is(a) || (c = e(c).closest(a));
  559. return c
  560. };
  561. this.getSelect = function (a) {
  562. var b = d.getSel(), c = d.getRng(), f = !0, f = !c || c.item ? !1 : !b || 0 === c.boundingWidth || c.collapsed;
  563. if ("text" === a)return f ? "" : c.text || (b.toString ? b.toString() :
  564. "");
  565. c.cloneContents ? (a = e("<div></div>"), (c = c.cloneContents()) && a.append(c), c = a.html()) : c = M(c.item) ? c.item(0).outerHTML : M(c.htmlText) ? c.htmlText : c.toString();
  566. f && (c = "");
  567. c = d.processHTML(c, "read");
  568. c = d.cleanHTML(c);
  569. return c = d.formatXHTML(c)
  570. };
  571. this.pasteHTML = function (a, b) {
  572. if (x)return !1;
  573. d.focus();
  574. var a = d.processHTML(a, "write"), c = d.getSel(), f = d.getRng();
  575. if (b !== $) {
  576. if (f.item) {
  577. var i = f.item(0), f = d.getRng(!0);
  578. f.moveToElementText(i);
  579. f.select()
  580. }
  581. f.collapse(b)
  582. }
  583. a += "<" + (h ? "img" : "span") + ' id="_xhe_temp" width="0" height="0" />';
  584. if (f.insertNode) {
  585. if (0 < e(f.startContainer).closest("style,script").length)return !1;
  586. f.deleteContents();
  587. f.insertNode(f.createContextualFragment(a))
  588. } else"control" === c.type.toLowerCase() && (c.clear(), f = d.getRng()), f.pasteHTML(a);
  589. var i = e("#_xhe_temp", l), m = i[0];
  590. h ? (f.moveToElementText(m), f.select()) : (f.selectNode(m), c.removeAllRanges(), c.addRange(f));
  591. i.remove()
  592. };
  593. this.pasteText = function (a, b) {
  594. a || (a = "");
  595. a = d.domEncode(a);
  596. a = a.replace(/\r?\n/g, "<br />");
  597. d.pasteHTML(a, b)
  598. };
  599. this.appendHTML = function (a) {
  600. if (x)return !1;
  601. d.focus();
  602. a = d.processHTML(a, "write");
  603. e(l.body).append(a);
  604. d.setTextCursor(!0)
  605. };
  606. this.domEncode = function (a) {
  607. return a.replace(nb, function (a) {
  608. return mb[a]
  609. })
  610. };
  611. this.setSource = function (a) {
  612. ha = null;
  613. if ("string" !== typeof a && "" !== a)a = z.value;
  614. 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)
  615. };
  616. this.processHTML = function (a,
  617. b) {
  618. if ("write" === b) {
  619. a = a.replace(/(<(\/?)(\w+))((?:\s+[\w\-:]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*((\/?)>)/g, function (a, b, c, d, e, f, i) {
  620. d = d.toLowerCase();
  621. 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;"')));
  622. var k, y = "";
  623. if ("del" === d)d = "strike"; else if ("img" === d)e = e.replace(/\s+emot\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i, function (a, b) {
  624. k = b.match(/^(["']?)(.*)\1/)[2];
  625. k = k.split(",");
  626. k[1] || (k[1] = k[0], k[0] = "");
  627. "default" === k[0] && (k[0] = "");
  628. return g.emotMark ? a : ""
  629. }); 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";
  630. var Z, e = e.replace(/\s+([\w\-:]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g,
  631. function (a, b, c) {
  632. b = b.toLowerCase();
  633. c = c.match(/^(["']?)(.*)\1/)[2];
  634. aft = "";
  635. if (h && b.match(/^(disabled|checked|readonly|selected)$/) && c.match(/^(false|0)$/i) || "img" === d && k && "src" === b)return "";
  636. b.match(/^(src|href)$/) && (aft = " _xhe_" + b + '="' + c + '"', F && (c = V(c, "abs", F)));
  637. y && "class" === b && (c += " " + y, y = "");
  638. R && "style" === b && "span" === d && c.match(/(^|;)\s*(font-family|font-size|color|background-color)\s*:\s*[^;]+\s*(;|$)/i) && (Z = !0);
  639. return " " + b + '="' + c + '"' + aft
  640. });
  641. k && (a = Y + (k[0] ? k[0] : "default") + "/" + k[1] + ".gif", e += ' src="' +
  642. a + '" _xhe_src="' + a + '"');
  643. Z && (e += ' class="Apple-style-span"');
  644. y && (e += ' class="' + y + '"');
  645. return "<" + c + d + e + f
  646. });
  647. h && (a = a.replace(/&apos;/ig, "&#39;"));
  648. if (!R)var c = function (a, b, c, d, e, f) {
  649. var b = "", i, k;
  650. (i = d.match(/font-family\s*:\s*([^;"]+)/i)) && (b += ' face="' + i[1] + '"');
  651. if (i = d.match(/font-size\s*:\s*([^;"]+)/i)) {
  652. i = i[1].toLowerCase();
  653. for (var y = 0; y < T.length; y++)if (i === T[y].n || i === T[y].s) {
  654. k = y + 1;
  655. break
  656. }
  657. k && (b += ' size="' + k + '"', d = d.replace(/(^|;)(\s*font-size\s*:\s*[^;"]+;?)+/ig, "$1"))
  658. }
  659. if (k = d.match(/(?:^|[\s;])color\s*:\s*([^;"]+)/i)) {
  660. if (i =
  661. k[1].match(/\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i)) {
  662. k[1] = "#";
  663. for (y = 1; 3 >= y; y++)k[1] += ("0" + (i[y] - 0).toString(16)).slice(-2)
  664. }
  665. k[1] = k[1].replace(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3");
  666. b += ' color="' + k[1] + '"'
  667. }
  668. d = d.replace(/(^|;)(\s*(font-family|color)\s*:\s*[^;"]+;?)+/ig, "$1");
  669. return "" !== b ? (d && (b += ' style="' + d + '"'), "<font" + (c ? c : "") + b + (e ? e : "") + ">" + f + "</font>") : a
  670. }, 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,
  671. 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);
  672. a = a.replace(/<(td|th)(\s+[^>]*?)?>(\s|&nbsp;)*<\/\1>/ig, "<$1$2>" + (h ? "" : "<br />") + "</$1>")
  673. } else {
  674. if (R)for (var d = [{
  675. r: /font-weight\s*:\s*bold;?/ig,
  676. t: "strong"
  677. }, {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) {
  678. 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 () {
  679. g.push("<" + k + ">");
  680. D.push("</" + k + ">");
  681. return ""
  682. });
  683. a = a.replace(/\s+style\s*=\s*"\s*"/i, "");
  684. return (a ? "<span" + a + ">" : "") + g.join("") + i + D.join("") + (a ? "</span>" : "")
  685. }, 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,
  686. 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);
  687. a = a.replace(/(<(\w+))((?:\s+[\w\-:]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/g, function (a, b, c, d, e) {
  688. var c = c.toLowerCase(), f, d = d.replace(/\s+_xhe_(?:src|href)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i, function (a,
  689. b) {
  690. f = b.match(/^(["']?)(.*)\1/)[2];
  691. return ""
  692. });
  693. f && va && (f = V(f, va, F));
  694. d = d.replace(/\s+([\w\-:]+)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/g, function (a, b, c) {
  695. b = b.toLowerCase();
  696. c = c.match(/^(["']?)(.*)\1/)[2].replace(/"/g, "'");
  697. if ("class" === b) {
  698. if (c.match(/^["']?(apple|webkit)/i))return "";
  699. c = c.replace(/\s?xhe-[a-z]+/ig, "");
  700. if ("" === c)return ""
  701. } else {
  702. if (b.match(/^((_xhe_|_moz_|_webkit_)|jquery\d+)/i))return "";
  703. if (f && b.match(/^(src|href)$/i))return " " + b + '="' + f + '"';
  704. "style" === b && (c = c.replace(/(^|;)\s*(font-size)\s*:\s*([a-z-]+)\s*(;|$)/i,
  705. function (a, b, c, d, e) {
  706. for (var f, i = 0; i < T.length; i++)if (a = T[i], d === a.n) {
  707. f = a.s;
  708. break
  709. }
  710. return b + c + ":" + f + e
  711. }))
  712. }
  713. return " " + b + '="' + c + '"'
  714. });
  715. "img" === c && !d.match(/\s+alt\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/i) && (d += ' alt=""');
  716. return b + d + e
  717. });
  718. a = a.replace(/(<(td|th)(?:\s+[^>]*?)?>)\s*([\s\S]*?)(<br(\s*\/)?>)?\s*<\/\2>/ig, function (a, b, c, d) {
  719. return b + (d ? d : "&nbsp;") + "</" + c + ">"
  720. });
  721. a = a.replace(/^\s*(?:<(p|div)(?:\s+[^>]*?)?>)?\s*(<span(?:\s+[^>]*?)?>\s*<\/span>|<br(?:\s+[^>]*?)?>|&nbsp;)*\s*(?:<\/\1>)?\s*$/i, "")
  722. }
  723. return a = a.replace(/(<pre(?:\s+[^>]*?)?>)([\s\S]+?)(<\/pre>)/gi,
  724. function (a, b, c, d) {
  725. return b + c.replace(/<br\s*\/?>/ig, "\r\n") + d
  726. })
  727. };
  728. this.getSource = function (a) {
  729. var b, c = g.beforeGetSource;
  730. 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)));
  731. return z.value = b
  732. };
  733. this.cleanWord = function (a) {
  734. var b = g.cleanPaste;
  735. if (0 < b && 3 > b && /mso(-|normal)|WordDocument|<table\s+[^>]*?x:str|\s+class\s*=\s*"?xl[67]\d"/i.test(a)) {
  736. a = a.replace(/<\!--[\s\S]*?--\>|<!(--)?\[[\s\S]+?\](--)?>|<style(\s+[^>]*?)?>[\s\S]*?<\/style>/ig,
  737. "");
  738. a = a.replace(/\r?\n/ig, "");
  739. 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) {
  740. if (a = c.match(/\s+src\s*=\s*("[^"]+"|'[^']+'|[^>\s]+)/i)) {
  741. a[1].match(/^(["']?)(.*)\1/);
  742. c = '<img src="' + A + 'xheditor_skin/blank.gif" _xhe_temp="true" class="wordImage"';
  743. if (a = b.match(/\s+style\s*=\s*("[^"]+"|'[^']+'|[^>\s]+)/i))a = a[1].match(/^(["']?)(.*)\1/)[2], c += ' style="' + a + '"';
  744. return c +
  745. " />"
  746. }
  747. return ""
  748. })) : a = a.replace(/<img( [^<>]*(v:shapes|msohtmlclip)[^<>]*)\/?>/ig, function (a, b) {
  749. var c, d = '<img src="' + A + 'xheditor_skin/blank.gif" _xhe_temp="true" class="wordImage"';
  750. (c = b.match(/ width\s*=\s*"([^"]+)"/i)) && (d += ' width="' + c[1] + '"');
  751. (c = b.match(/ height\s*=\s*"([^"]+)"/i)) && (d += ' height="' + c[1] + '"');
  752. return d + " />"
  753. });
  754. for (var a = a.replace(/(<(\/?)([\w\-:]+))((?:\s+[\w\-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?)*)\s*(\/?>)/g, function (a, c, d, e, f, g) {
  755. e = e.toLowerCase();
  756. if (e.match(/^(link)$/) && f.match(/file:\/\//i) ||
  757. e.match(/:/) || "span" === e && 2 === b)return "";
  758. d || (f = f.replace(/\s([\w\-:]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^>\s]+))?/ig, function (a, c, d) {
  759. c = c.toLowerCase();
  760. if (/:/.test(c))return "";
  761. d = d.match(/^(["']?)(.*)\1/)[2];
  762. if (1 === b)switch (e) {
  763. case "p":
  764. if ("style" === c)return (d = d.replace(/"|&quot;/ig, "'").replace(/\s*([^:]+)\s*:\s*(.*?)(;|$)/ig, function (a, b, c) {
  765. return /^(text-align)$/i.test(b) ? b + ":" + c + ";" : ""
  766. }).replace(/^\s+|\s+$/g, "")) ? " " + c + '="' + d + '"' : "";
  767. break;
  768. case "span":
  769. if ("style" === c)return (d = d.replace(/"|&quot;/ig, "'").replace(/\s*([^:]+)\s*:\s*(.*?)(;|$)/ig,
  770. function (a, b, c) {
  771. return /^(color|background|font-size|font-family)$/i.test(b) ? b + ":" + c + ";" : ""
  772. }).replace(/^\s+|\s+$/g, "")) ? " " + c + '="' + d + '"' : "";
  773. break;
  774. case "table":
  775. if (c.match(/^(cellspacing|cellpadding|border|width)$/i))return a;
  776. break;
  777. case "td":
  778. if (c.match(/^(rowspan|colspan)$/i))return a;
  779. if ("style" === c)return (d = d.replace(/"|&quot;/ig, "'").replace(/\s*([^:]+)\s*:\s*(.*?)(;|$)/ig, function (a, b, c) {
  780. return /^(width|height)$/i.test(b) ? b + ":" + c + ";" : ""
  781. }).replace(/^\s+|\s+$/g, "")) ? " " + c + '="' + d + '"' : "";
  782. break;
  783. case "a":
  784. if (c.match(/^(href)$/i))return a;
  785. break;
  786. case "font":
  787. case "img":
  788. return a
  789. } else if (2 === b)switch (e) {
  790. case "td":
  791. if (c.match(/^(rowspan|colspan)$/i))return a;
  792. break;
  793. case "img":
  794. return a
  795. }
  796. return ""
  797. }));
  798. return c + f + g
  799. }), c = 0; 3 > c; c++)a = a.replace(/<([^\s>]+)(\s+[^>]*)?>\s*<\/\1>/g, "");
  800. for (var d = function (a, b, c) {
  801. return c
  802. }, 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);
  803. for (c = 0; 3 > c; c++)a = a.replace(/<(span|a)>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,
  804. d);
  805. for (c = 0; 3 > c; c++)a = a.replace(/<(span|a)>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, d);
  806. for (c = 0; 3 > c; c++)a = a.replace(/<font(\s+[^>]+)><font(\s+[^>]+)>/ig, function (a, b, c) {
  807. return "<font" + b + c + ">"
  808. });
  809. a = a.replace(/(<(\/?)(tr|td)(?:\s+[^>]+)?>)[^<>]+/ig, function (a, b, c, d) {
  810. return !c && /^td$/i.test(d) ? a : b
  811. })
  812. }
  813. return a
  814. };
  815. this.cleanHTML = function (a) {
  816. var a = a.replace(/<!?\/?(DOCTYPE|html|body|meta)(\s+[^>]*?)?>/ig, ""), b, a = a.replace(/<head(?:\s+[^>]*?)?>([\s\S]*?)<\/head>/i, function (a, d) {
  817. b = d.match(/<(script|style)(\s+[^>]*?)?>[\s\S]*?<\/\1>/ig);
  818. return ""
  819. });
  820. b && (a = b.join("") + a);
  821. a = a.replace(/<\??xml(:\w+)?(\s+[^>]*?)?>([\s\S]*?<\/xml>)?/ig, "");
  822. g.internalScript || (a = a.replace(/<script(\s+[^>]*?)?>[\s\S]*?<\/script>/ig, ""));
  823. g.internalStyle || (a = a.replace(/<style(\s+[^>]*?)?>[\s\S]*?<\/style>/ig, ""));
  824. if (!g.linkTag || !g.inlineScript || !g.inlineStyle)a = a.replace(/(<(\w+))((?:\s+[\w-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))*)\s*(\/?>)/ig, function (a, b, d, e, j) {
  825. if (!g.linkTag && "link" === d.toLowerCase())return "";
  826. 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,
  827. ""));
  828. g.inlineStyle || (e = e.replace(/\s+(style|class)\s*=\s*("[^"]*"|'[^']*'|[^>\s]+)/ig, ""));
  829. return b + e + j
  830. });
  831. return a = a.replace(/<\/(strong|b|u|strike|em|i)>((?:\s|<br\/?>|&nbsp;)*?)<\1(\s+[^>]*?)?>/ig, "$2")
  832. };
  833. this.formatXHTML = function (a, b) {
  834. function c(a) {
  835. for (var b = {}, a = a.split(","), c = 0; c < a.length; c++)b[a[c]] = !0;
  836. return b
  837. }
  838. function e(a) {
  839. var a = a.toLowerCase(), b = o[a];
  840. return b ? b : a
  841. }
  842. function i(a, b, c) {
  843. if (k[a])for (; E.last() && y[E.last()];)g(E.last());
  844. Z[a] && E.last() === a && g(a);
  845. (c = D[a] || !!c) || E.push(a);
  846. var d = [];
  847. d.push("<" +
  848. a);
  849. b.replace(x, function (a, b, c, e, f) {
  850. b = b.toLowerCase();
  851. d.push(" " + b + '="' + (c ? c : e ? e : f ? f : l[b] ? b : "").replace(/"/g, "'") + '"')
  852. });
  853. d.push((c ? " /" : "") + ">");
  854. w(d.join(""), a, !0);
  855. "pre" === a && (B = !0)
  856. }
  857. function g(a) {
  858. if (a)for (b = E.length - 1; 0 <= b && !(E[b] === a); b--); else var b = 0;
  859. if (0 <= b) {
  860. for (var c = E.length - 1; c >= b; c--)w("</" + E[c] + ">", E[c]);
  861. E.length = b
  862. }
  863. "pre" === a && (B = !1, v--)
  864. }
  865. function j(a) {
  866. w(d.domEncode(a))
  867. }
  868. function p(a) {
  869. H.push(a.replace(/^[\s\r\n]+|[\s\r\n]+$/g, ""))
  870. }
  871. function w(a, c, d) {
  872. B || (a = a.replace(/(\t*\r?\n\t*)+/g, ""));
  873. if (!B &&
  874. !0 === b)if (a.match(/^\s*$/))H.push(a); else {
  875. var e = k[c];
  876. e ? (d && v++, "" === A && v--) : A && v++;
  877. ((e ? c : "") !== A || e) && s();
  878. H.push(a);
  879. "br" === c && s();
  880. e && (D[c] || !d) && v--;
  881. A = e ? c : ""
  882. } else H.push(a)
  883. }
  884. function s() {
  885. H.push("\r\n");
  886. if (0 < v)for (var a = v; a--;)H.push("\t")
  887. }
  888. function r(a, b, c, d) {
  889. if (!c)return d;
  890. var e = "", c = c.replace(/ face\s*=\s*"\s*([^"]*)\s*"/i, function (a, b) {
  891. b && (e += "font-family:" + b + ";");
  892. return ""
  893. }), c = c.replace(/ size\s*=\s*"\s*(\d+)\s*"/i, function (a, b) {
  894. e += "font-size:" + T[(7 < b ? 7 : 1 > b ? 1 : b) - 1].s + ";";
  895. return ""
  896. }), c = c.replace(/ color\s*=\s*"\s*([^"]*)\s*"/i,
  897. function (a, b) {
  898. b && (e += "color:" + b + ";");
  899. return ""
  900. }), c = c.replace(/ style\s*=\s*"\s*([^"]*)\s*"/i, function (a, b) {
  901. b && (e += b);
  902. return ""
  903. });
  904. return (c += ' style="' + e + '"') ? "<span" + c + ">" + d + "</span>" : d
  905. }
  906. 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"),
  907. 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 = {
  908. b: "strong",
  909. i: "em",
  910. s: "del",
  911. strike: "del"
  912. }, n = /<(?:\/([^\s>]+)|!([^>]*?)|([\w\-:]+)((?:"[^"]*"|'[^']*'|[^"'<>])*)\s*(\/?))>/g, x = /\s*([\w\-:]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?/g, H = [], E = [];
  913. E.last = function () {
  914. return this[this.length - 1]
  915. };
  916. for (var u, C, q = 0, t, z, v = -1, A = "body", B = !1; u = n.exec(a);) {
  917. C = u.index;
  918. C > q && (q =
  919. a.substring(q, C), t ? z.push(q) : j(q));
  920. q = n.lastIndex;
  921. if (C = u[1])if (C = e(C), t && C === t && (p(z.join("")), z = t = null), !t) {
  922. g(C);
  923. continue
  924. }
  925. 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])
  926. }
  927. a.length > q && j(a.substring(q, a.length));
  928. g();
  929. a = H.join("");
  930. H = null;
  931. 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);
  932. a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S]|<\1(\s+[^>]*?)?>((?!<\1(\s+[^>]*?)?>)[\s\S])*?<\/\1>)*?)<\/\1>/ig,
  933. r);
  934. a = a.replace(/<(font)(\s+[^>]*?)?>(((?!<\1(\s+[^>]*?)?>)[\s\S])*?)<\/\1>/ig, r);
  935. return a = a.replace(/^(\s*\r?\n)+|(\s*\r?\n)+$/g, "")
  936. };
  937. this.toggleShowBlocktag = function (a) {
  938. na !== a && (na = !na, a = e(l.body), na ? (Q += " showBlocktag", a.addClass("showBlocktag")) : (Q = Q.replace(" showBlocktag", ""), a.removeClass("showBlocktag")))
  939. };
  940. this.toggleSource = function (a) {
  941. if (x !== a) {
  942. n.find("[cmd=Source]").toggleClass("xheEnabled").toggleClass("xheActive");
  943. var b = l.body, c = e(b), f, i, a = 0, g = "";
  944. if (x)f = d.getSource(), c.html("").removeAttr("scroll").attr("class",
  945. "editMode" + Q), h ? b.contentEditable = "true" : l.designMode = "On", qa && (d._exec("inserthtml", "-"), e("#" + za).show().focus().hide()), g = "\u6e90\u4ee3\u7801"; else {
  946. d.pasteHTML('<span id="_xhe_cursor"></span>', !0);
  947. f = d.getSource(!0);
  948. a = f.indexOf('<span id="_xhe_cursor"></span>');
  949. if (!Ca)a = f.substring(0, a).replace(/\r/g, "").length;
  950. f = f.replace(/(\r?\n\s*|)<span id="_xhe_cursor"><\/span>(\s*\r?\n|)/, function (a, b, c) {
  951. return b && c ? "\r\n" : b + c
  952. });
  953. h ? b.contentEditable = "false" : l.designMode = "Off";
  954. c.attr("scroll", "no").attr("class",
  955. "sourceMode").html('<textarea id="sourceCode" wrap="soft" spellcheck="false" style="width:100%;height:100%" />');
  956. i = e("#sourceCode", c).blur(d.getSource)[0];
  957. g = "\u53ef\u89c6\u5316\u7f16\u8f91"
  958. }
  959. x = !x;
  960. d.setSource(f);
  961. d.focus();
  962. x ? i.setSelectionRange ? i.setSelectionRange(a, a) : (i = i.createTextRange(), i.move("character", a), i.select()) : d.setTextCursor();
  963. n.find("[cmd=Source]").attr("title", g).find("span").text(g);
  964. n.find("[cmd=Source],[cmd=Preview]").toggleClass("xheEnabled");
  965. n.find(".xheButton").not("[cmd=Source],[cmd=Fullscreen],[cmd=About]").toggleClass("xheEnabled").attr("aria-disabled",
  966. x ? !0 : !1);
  967. setTimeout(La, 300)
  968. }
  969. };
  970. this.showPreview = function () {
  971. var a = g.beforeSetSource, b = d.getSource();
  972. a && (b = a(b));
  973. var a = "<html><head>" + P + "<title>\u9884\u89c8</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;
  974. c.open();
  975. c.write(a);
  976. c.close();
  977. b.focus()
  978. };
  979. this.toggleFullscreen = function (a) {
  980. if (la !== a) {
  981. var a = e("#" + ja).find(".xheLayout"), b = e("#" + ja), c = jQuery.browser.version, c = h && (6 == c || 7 == c);
  982. la ? (c && G.after(b), a.attr("style", Za), B.height(O - n.outerHeight()), e(window).scrollTop(Pa), setTimeout(function () {
  983. e(window).scrollTop(Pa)
  984. }, 10)) : (c && e("body").append(b), Pa = e(window).scrollTop(), Za = a.attr("style"), a.removeAttr("style"), B.height("100%"), setTimeout(Na, 100));
  985. qa ? (e("#" + za).show().focus().hide(), setTimeout(d.focus, 1)) : c && d.setTextCursor();
  986. la = !la;
  987. b.toggleClass("xhe_Fullscreen");
  988. e("html").toggleClass("xhe_Fullfix");
  989. n.find("[cmd=Fullscreen]").toggleClass("xheActive");
  990. setTimeout(La, 300)
  991. }
  992. };
  993. this.showMenu = function (a, b) {
  994. var c = e('<div class="xheMenu"></div>'), f = a.length, i = [];
  995. e.each(a, function (a, b) {
  996. "-" === 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>")
  997. });
  998. c.append(i.join(""));
  999. c.click(function (a) {
  1000. a = a.target;
  1001. if (!e.nodeName(a,
  1002. "DIV"))return d.loadBookmark(), b(e(a).closest("a").attr("v")), d.hidePanel(), !1
  1003. }).mousedown(N);
  1004. d.saveBookmark();
  1005. d.showPanel(c)
  1006. };
  1007. this.showColor = function (a) {
  1008. var b = e('<div class="xheColor"></div>'), c = [], f = Ta.length, i = 0;
  1009. e.each(Ta, function (a, b) {
  1010. 0 === i % 7 && c.push((0 < i ? "</div>" : "") + "<div>");
  1011. c.push("<a href=\"javascript:void('" + b + '\')" xhev="' + b + '" title="' + b + '" style="background:' + b + '" role="option" aria-setsize="' + f + '" aria-posinset="' + (i + 1) + '"></a>');
  1012. i++
  1013. });
  1014. c.push("</div>");
  1015. b.append(c.join(""));
  1016. b.click(function (b) {
  1017. b =
  1018. b.target;
  1019. if (e.nodeName(b, "A"))return d.loadBookmark(), a(e(b).attr("xhev")), d.hidePanel(), !1
  1020. }).mousedown(N);
  1021. d.saveBookmark();
  1022. d.showPanel(b)
  1023. };
  1024. this.showPastetext = function () {
  1025. var a = e('<div><label for="xhePastetextValue">\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl+V)\u628a\u5185\u5bb9\u7c98\u8d34\u5230\u65b9\u6846\u91cc\uff0c\u6309 \u786e\u5b9a</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="\u786e\u5b9a" /></div>'),
  1026. b = e("#xhePastetextValue", a);
  1027. e("#xheSave", a).click(function () {
  1028. d.loadBookmark();
  1029. var a = b.val();
  1030. a && d.pasteText(a);
  1031. d.hidePanel();
  1032. return !1
  1033. });
  1034. d.saveBookmark();
  1035. d.showDialog(a)
  1036. };
  1037. this.showLink = function () {
  1038. var a = '<div><label for="xheLinkUrl">\u94fe\u63a5\u5730\u5740: </label><input type="text" id="xheLinkUrl" value="http://" class="xheText" /></div><div><label for="xheLinkTarget">\u6253\u5f00\u65b9\u5f0f: </label><select id="xheLinkTarget"><option selected="selected" value="">\u9ed8\u8ba4</option><option value="_blank">\u65b0\u7a97\u53e3</option><option value="_self">\u5f53\u524d\u7a97\u53e3</option><option value="_parent">\u7236\u7a97\u53e3</option></select></div><div style="display:none"><label for="xheLinkText">\u94fe\u63a5\u6587\u5b57: </label><input type="text" id="xheLinkText" value="" class="xheText" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>',
  1039. b = ga.find("a[name]").not("[href]"), c = 0 < b.length;
  1040. if (c) {
  1041. var f = [];
  1042. b.each(function () {
  1043. var a = e(this).attr("name");
  1044. f.push('<option value="#' + a + '">' + a + "</option>")
  1045. });
  1046. a = a.replace(/(<div><label for="xheLinkTarget)/, '<div><label for="xheLinkAnchor">\u9875\u5185\u951a\u70b9: </label><select id="xheLinkAnchor"><option value="">\u672a\u9009\u62e9</option>' + f.join("") + "</select></div>$1")
  1047. }
  1048. 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();
  1049. c && a.find("#xheLinkAnchor").change(function () {
  1050. var a = e(this).val();
  1051. "" != a && j.val(a)
  1052. });
  1053. if (1 === i.length) {
  1054. if (!i.attr("href"))return v = null, d.exec("Anchor");
  1055. j.val(L(i, "href"));
  1056. p.attr("value", i.attr("target"))
  1057. } else"" === w && m.val(g.defLinkText).closest("div").show();
  1058. g.upLinkUrl && d.uploadInit(j, g.upLinkUrl, g.upLinkExt);
  1059. b.click(function () {
  1060. d.loadBookmark();
  1061. var a = j.val();
  1062. ("" === a || 0 === i.length) && d._exec("unlink");
  1063. if ("" !== a && "http://" !== a) {
  1064. var b = a.split(" "), c = p.val(), f = m.val();
  1065. if (1 < b.length) {
  1066. d._exec("unlink");
  1067. w = d.getSelect();
  1068. var g = '<a href="xhe_tmpurl"', Z = [];
  1069. "" !== c && (g += ' target="' + c + '"');
  1070. 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));
  1071. d.pasteHTML(Z.join("&nbsp;"))
  1072. } 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", c) : i.removeAttr("target")
  1073. }
  1074. d.hidePanel();
  1075. return !1
  1076. });
  1077. d.saveBookmark();
  1078. d.showDialog(a)
  1079. };
  1080. this.showAnchor = function () {
  1081. var a = e('<div><label for="xheAnchorName">\u951a\u70b9\u540d\u79f0: </label><input type="text" id="xheAnchorName" value="" class="xheText" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'), b = d.getParent("a"), c = e("#xheAnchorName", a), f = e("#xheSave", a);
  1082. if (1 === b.length) {
  1083. if (b.attr("href"))return v =
  1084. null, d.exec("Link");
  1085. c.val(b.attr("name"))
  1086. }
  1087. f.click(function () {
  1088. d.loadBookmark();
  1089. var a = c.val();
  1090. a ? 0 === b.length ? d.pasteHTML('<a name="' + a + '"></a>') : b.attr("name", a) : 1 === b.length && b.remove();
  1091. d.hidePanel();
  1092. return !1
  1093. });
  1094. d.saveBookmark();
  1095. d.showDialog(a)
  1096. };
  1097. this.showImg = function () {
  1098. var a = e('<div><label for="xheImgUrl">\u56fe\u7247\u6587\u4ef6: </label><input type="text" id="xheImgUrl" value="http://" class="xheText" /></div><div><div><label for="xheImgAlt">\u66ff\u6362\u6587\u672c: </label><input type="text" id="xheImgAlt" /></div><div><label for="xheImgAlign">\u5bf9\u9f50\u65b9\u5f0f: </label><select id="xheImgAlign"><option selected="selected" value="">\u9ed8\u8ba4</option><option value="left">\u5de6\u5bf9\u9f50</option><option value="right">\u53f3\u5bf9\u9f50</option><option value="top">\u9876\u7aef</option><option value="middle">\u5c45\u4e2d</option><option value="baseline">\u57fa\u7ebf</option><option value="bottom">\u5e95\u8fb9</option></select></div><div><label for="xheImgWidth">\u5bbd\u3000\u3000\u5ea6: </label><input type="text" id="xheImgWidth" style="width:40px;" /> <label for="xheImgHeight">\u9ad8\u3000\u3000\u5ea6: </label><input type="text" id="xheImgHeight" style="width:40px;" /></div><div><label for="xheImgBorder">\u8fb9\u6846\u5927\u5c0f: </label><input type="text" id="xheImgBorder" style="width:40px;" /></div><div><label for="xheImgHspace">\u6c34\u5e73\u95f4\u8ddd: </label><input type="text" id="xheImgHspace" style="width:40px;" /> <label for="xheImgVspace">\u5782\u76f4\u95f4\u8ddd: </label><input type="text" id="xheImgVspace" style="width:40px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'),
  1099. 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);
  1100. if (1 === b.length) {
  1101. c.val(L(b, "src"));
  1102. f.val(b.attr("alt"));
  1103. i.val(b.attr("align"));
  1104. m.val(b.attr("width"));
  1105. j.val(b.attr("height"));
  1106. p.val(b.attr("border"));
  1107. var D = b.attr("vspace"), k = b.attr("hspace");
  1108. w.val(0 >= D ? "" : D);
  1109. s.val(0 >= k ? "" : k)
  1110. }
  1111. g.upImgUrl && d.uploadInit(c, g.upImgUrl, g.upImgExt);
  1112. r.click(function () {
  1113. d.loadBookmark();
  1114. var a = c.val();
  1115. if ("" !== a && "http://" !== a) {
  1116. 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();
  1117. if (1 < g.length) {
  1118. var u = '<img src="xhe_tmpurl"', t = [];
  1119. "" !== k && (u += ' alt="' + k + '"');
  1120. "" !== D && (u += ' align="' + D + '"');
  1121. "" !== r && (u += ' width="' + r + '"');
  1122. "" !== h && (u += ' height="' + h + '"');
  1123. "" !== o && (u += ' border="' + o + '"');
  1124. "" !== q && (u += ' vspace="' + q + '"');
  1125. "" !== n && (u += ' hspace="' + n + '"');
  1126. var u = u + " />", v;
  1127. 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="' +
  1128. a[1] + '" target="_blank">' + k + "</a>"), t.push(k));
  1129. d.pasteHTML(t.join("&nbsp;"))
  1130. } 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"),
  1131. "" !== 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"))))
  1132. } else 1 === b.length && b.remove();
  1133. d.hidePanel();
  1134. return !1
  1135. });
  1136. d.saveBookmark();
  1137. d.showDialog(a)
  1138. };
  1139. this.showEmbed = function (a, b, c, f, g, m, j) {
  1140. 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);
  1141. m && d.uploadInit(w, m, j);
  1142. 1 === p.length && (w.val(L(p,
  1143. "src")), s.val(p.attr("width")), r.val(p.attr("height")));
  1144. a.click(function () {
  1145. d.loadBookmark();
  1146. var a = w.val();
  1147. if ("" !== a && "http://" !== a) {
  1148. var b = s.val(), j = r.val(), m = /^\d+%?$/;
  1149. m.test(b) || (b = 412);
  1150. m.test(j) || (j = 300);
  1151. var h = '<embed type="' + c + '" classid="' + f + '" src="xhe_tmpurl"' + g, m = a.split(" ");
  1152. if (1 < m.length) {
  1153. var o, q = [], h = h + ' width="xhe_width" height="xhe_height" />', n;
  1154. 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), "" !==
  1155. a && q.push(o);
  1156. d.pasteHTML(q.join("&nbsp;"))
  1157. } 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))
  1158. } else 1 === p.length && p.remove();
  1159. d.hidePanel();
  1160. return !1
  1161. });
  1162. d.saveBookmark();
  1163. d.showDialog(b)
  1164. };
  1165. this.showEmot = function (a) {
  1166. 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,
  1167. s = c.count, c = c.list;
  1168. 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) {
  1169. g++;
  1170. 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>');
  1171. 0 === g % w && m.push("<br />")
  1172. });
  1173. var s = w * (j + 12), c = Math.ceil(g / w) * (p + 12), r = 0.75 * s;
  1174. c <= r &&
  1175. (r = "");
  1176. 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) {
  1177. var a = a.target, b = e(a);
  1178. if (e.nodeName(a, "A"))return d.loadBookmark(), d.pasteHTML('<img emot="' + b.attr("emot") + '" alt="' + b.attr("xhev") + '">'), d.hidePanel(), !1
  1179. }).mousedown(N);
  1180. b.append(j);
  1181. var h = 0, k = ['<ul role="tablist">'];
  1182. e.each(Aa, function (b, c) {
  1183. h++;
  1184. k.push("<li" + (a === b ? ' class="cur"' : "") + ' role="presentation"><a href="javascript:void(\'' +
  1185. c.name + '\')" group="' + b + '" role="tab" tabindex="0">' + c.name + "</a></li>")
  1186. });
  1187. 1 < h && (k.push('</ul><br style="clear:both;" />'), j = e(k.join("")).click(function (a) {
  1188. Ra = e(a.target).attr("group");
  1189. d.exec("Emot");
  1190. return !1
  1191. }).mousedown(N), b.append(j));
  1192. d.saveBookmark();
  1193. d.showPanel(b)
  1194. };
  1195. this.showTable = function () {
  1196. var a = e('<div><label for="xheTableRows">\u884c\u3000\u3000\u6570: </label><input type="text" id="xheTableRows" style="width:40px;" value="3" /> <label for="xheTableColumns">\u5217\u3000\u3000\u6570: </label><input type="text" id="xheTableColumns" style="width:40px;" value="2" /></div><div><label for="xheTableHeaders">\u6807\u9898\u5355\u5143: </label><select id="xheTableHeaders"><option selected="selected" value="">\u65e0</option><option value="row">\u7b2c\u4e00\u884c</option><option value="col">\u7b2c\u4e00\u5217</option><option value="both">\u7b2c\u4e00\u884c\u548c\u7b2c\u4e00\u5217</option></select></div><div><label for="xheTableWidth">\u5bbd\u3000\u3000\u5ea6: </label><input type="text" id="xheTableWidth" style="width:40px;" value="200" /> <label for="xheTableHeight">\u9ad8\u3000\u3000\u5ea6: </label><input type="text" id="xheTableHeight" style="width:40px;" value="" /></div><div><label for="xheTableBorder">\u8fb9\u6846\u5927\u5c0f: </label><input type="text" id="xheTableBorder" style="width:40px;" value="1" /></div><div><label for="xheTableCellSpacing">\u8868\u683c\u95f4\u8ddd: </label><input type="text" id="xheTableCellSpacing" style="width:40px;" value="1" /> <label for="xheTableCellPadding">\u8868\u683c\u586b\u5145: </label><input type="text" id="xheTableCellPadding" style="width:40px;" value="1" /></div><div><label for="xheTableAlign">\u5bf9\u9f50\u65b9\u5f0f: </label><select id="xheTableAlign"><option selected="selected" value="">\u9ed8\u8ba4</option><option value="left">\u5de6\u5bf9\u9f50</option><option value="center">\u5c45\u4e2d</option><option value="right">\u53f3\u5bf9\u9f50</option></select></div><div><label for="xheTableCaption">\u8868\u683c\u6807\u9898: </label><input type="text" id="xheTableCaption" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>'),
  1197. 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);
  1198. e("#xheSave", a).click(function () {
  1199. d.loadBookmark();
  1200. 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="' +
  1201. t + '"' : "") + ("" !== v ? ' cellspacing="' + v + '"' : "") + ("" !== z ? ' cellpadding="' + z + '"' : "") + ("" !== x ? ' align="' + x + '"' : "") + ">";
  1202. "" !== a && (e += "<caption>" + a + "</caption>");
  1203. if ("row" === q || "both" === q) {
  1204. e += "<tr>";
  1205. for (a = 0; a < o; a++)e += '<th scope="col"></th>';
  1206. e += "</tr>";
  1207. l--
  1208. }
  1209. e += "<tbody>";
  1210. for (a = 0; a < l; a++) {
  1211. e += "<tr>";
  1212. for (n = 0; n < o; n++)e = 0 === n && ("col" === q || "both" === q) ? e + '<th scope="row"></th>' : e + "<td></td>";
  1213. e += "</tr>"
  1214. }
  1215. d.pasteHTML(e + "</tbody></table>");
  1216. d.hidePanel();
  1217. return !1
  1218. });
  1219. d.saveBookmark();
  1220. d.showDialog(a)
  1221. };
  1222. this.showAbout = function () {
  1223. var a =
  1224. 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\u662f\u57fa\u4e8ejQuery\u5f00\u53d1\u7684\u8de8\u5e73\u53f0\u8f7b\u91cf\u53ef\u89c6\u5316XHTML\u7f16\u8f91\u5668\uff0c\u57fa\u4e8e<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">LGPL</a>\u5f00\u6e90\u534f\u8bae\u53d1\u5e03\u3002</p><p>Copyright &copy; <a href="http://xheditor.com/" target="_blank">xhEditor.com</a>. All rights reserved.</p></div>');
  1225. a.find("p").attr("role", "presentation");
  1226. d.showDialog(a, !0);
  1227. setTimeout(function () {
  1228. a.focus()
  1229. }, 100)
  1230. };
  1231. this.addShortcuts = function (a, b) {
  1232. a = a.toLowerCase();
  1233. ma[a] === $ && (ma[a] = []);
  1234. ma[a].push(b)
  1235. };
  1236. this.delShortcuts = function (a) {
  1237. delete ma[a]
  1238. };
  1239. this.uploadInit = function (a, b, c) {
  1240. function f(b) {
  1241. M(b, "string") && (b = [b]);
  1242. var c = !1, d, e = b.length, f, i = [];
  1243. (d = g.onUpload) && d(b);
  1244. 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);
  1245. a.val(i.join(" "));
  1246. c && a.closest(".xheDialog").find("#xheSave").click()
  1247. }
  1248. 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;
  1249. a.after(i);
  1250. m.before(a);
  1251. b = b.replace(/{editorRoot}/ig, A);
  1252. if ("!" === b.substr(0, 1))m.click(function () {
  1253. d.showIframeModal("\u4e0a\u4f20\u6587\u4ef6", b.substr(1), f, null, null)
  1254. }); else {
  1255. i.append('<input type="file"' + (1 < p ? ' multiple=""' : "") + ' class="xheFile" size="13" name="filedata" tabindex="-1" />');
  1256. var h = e(".xheFile", i);
  1257. h.change(function () {
  1258. d.startUpload(h[0], b, c, f)
  1259. });
  1260. setTimeout(function () {
  1261. a.closest(".xheDialog").bind("dragenter dragover", N).bind("drop", function (a) {
  1262. var a = a.originalEvent.dataTransfer, e;
  1263. j && a && (e = a.files) && 0 < e.length && d.startUpload(e, b, c, f);
  1264. return !1
  1265. })
  1266. }, 10)
  1267. }
  1268. };
  1269. this.startUpload = function (a, b, c, f) {
  1270. function i(a, c) {
  1271. var e = Object, g = !1;
  1272. try {
  1273. e = eval("(" + a + ")")
  1274. } catch (i) {
  1275. }
  1276. e.err === $ || e.msg === $ ? alert(b + " \u4e0a\u4f20\u63a5\u53e3\u53d1\u751f\u9519\u8bef\uff01\r\n\r\n\u8fd4\u56de\u7684\u9519\u8bef\u5185\u5bb9\u4e3a: \r\n\r\n" +
  1277. a) : e.err ? alert(e.err) : (m.push(e.msg), g = !0);
  1278. (!g || c) && d.removeModal();
  1279. c && g && f(m);
  1280. return g
  1281. }
  1282. var m = [], j = g.html5Upload, p = j ? g.upMultiple : 1, h, s = e('<div style="padding:22px 0;text-align:center;line-height:30px;">\u6587\u4ef6\u4e0a\u4f20\u4e2d\uff0c\u8bf7\u7a0d\u5019\u2026\u2026<br /></div>'), r = '<img src="' + ua + 'img/loading.gif">';
  1283. if (Ca || !j || a.nodeType && (!(h = a.files) || !h[0].name)) {
  1284. if (!Wa(a.value, c))return;
  1285. s.append(r);
  1286. c = new d.html4Upload(a, b, i)
  1287. } else {
  1288. h || (h = a);
  1289. a = h.length;
  1290. if (a > p) {
  1291. alert("\u8bf7\u4e0d\u8981\u4e00\u6b21\u4e0a\u4f20\u8d85\u8fc7" +
  1292. p + "\u4e2a\u6587\u4ef6");
  1293. return
  1294. }
  1295. for (p = 0; p < a; p++)if (!Wa(h[p].name, c))return;
  1296. var l = e('<div class="xheProgress"><div><span>0%</span></div></div>');
  1297. s.append(l);
  1298. c = new d.html5Upload("filedata", h, b, i, function (a) {
  1299. if (0 <= a.loaded) {
  1300. var b = Math.round(100 * a.loaded / a.total) + "%";
  1301. e("div", l).css("width", b);
  1302. e("span", l).text(b + " ( " + Xa(a.loaded) + " / " + Xa(a.total) + " )")
  1303. } else l.replaceWith(r)
  1304. })
  1305. }
  1306. d.showModal("\u6587\u4ef6\u4e0a\u4f20\u4e2d(Esc\u53d6\u6d88\u4e0a\u4f20)", s, 320, 150);
  1307. c.start()
  1308. };
  1309. this.html4Upload = function (a, b,
  1310. c) {
  1311. var d = "jUploadFrame" + (new Date).getTime(), g = this, h = e('<iframe name="' + d + '" class="xheHideArea" />').appendTo("body"), 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");
  1312. p.before(l).appendTo(j);
  1313. this.remove = function () {
  1314. null !== g && (l.before(p).remove(), h.remove(), j.remove(), g = null)
  1315. };
  1316. this.onLoad = function () {
  1317. var a = h[0].contentWindow.document, b = e(a.body).text();
  1318. a.write("");
  1319. g.remove();
  1320. c(b, !0)
  1321. };
  1322. this.start = function () {
  1323. j.submit();
  1324. h.load(g.onLoad)
  1325. };
  1326. return this
  1327. };
  1328. this.html5Upload = function (a, b, c, d, e) {
  1329. function g(b, c, d, e) {
  1330. h = new XMLHttpRequest;
  1331. upload = h.upload;
  1332. h.onreadystatechange = function () {
  1333. 4 === h.readyState && d(h.responseText)
  1334. };
  1335. upload ? upload.onprogress = function (a) {
  1336. e(a.loaded)
  1337. } : e(-1);
  1338. h.open("POST", c);
  1339. h.setRequestHeader("Content-Type", "application/octet-stream");
  1340. h.setRequestHeader("Content-Disposition", 'attachment; name="' + encodeURIComponent(a) + '"; filename="' + encodeURIComponent(b.name) + '"');
  1341. h.sendAsBinary && b.getAsBinary ? h.sendAsBinary(b.getAsBinary()) : h.send(b)
  1342. }
  1343. function j(a) {
  1344. e && e({loaded: r + a, total: o})
  1345. }
  1346. for (var h, l = 0, s = b.length, r = 0, o = 0, k = this, n = 0; n < s; n++)o += b[n].size;
  1347. this.remove = function () {
  1348. h && (h.abort(), h = null)
  1349. };
  1350. this.uploadNext = function (a) {
  1351. a && (r += b[l - 1].size, j(0));
  1352. (!a || a && !0 === d(a, l === s)) && l < s && g(b[l++], c, k.uploadNext, function (a) {
  1353. j(a)
  1354. })
  1355. };
  1356. this.start = function () {
  1357. k.uploadNext()
  1358. }
  1359. };
  1360. this.showIframeModal = function (a, b, c, f, g, h) {
  1361. function j() {
  1362. try {
  1363. r.callback = l, r.unloadme = d.removeModal, e(r.document).keydown(I),
  1364. n = r.name
  1365. } catch (a) {
  1366. }
  1367. }
  1368. function l(a) {
  1369. r.document.write("");
  1370. d.removeModal();
  1371. null != a && c(a)
  1372. }
  1373. var b = e('<iframe frameborder="0" src="' + 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);
  1374. d.showModal(a, b, f, g, h);
  1375. var r = o[0].contentWindow, n;
  1376. j();
  1377. o.load(function () {
  1378. j();
  1379. if (n) {
  1380. var a = !0;
  1381. try {
  1382. n = eval("(" + unescape(n) + ")")
  1383. } catch (b) {
  1384. a = !1
  1385. }
  1386. if (a)return l(n)
  1387. }
  1388. s.is(":visible") && (o.show().focus(),
  1389. s.remove())
  1390. })
  1391. };
  1392. this.showModal = function (a, b, c, f, i) {
  1393. if (ta)return !1;
  1394. d.panelState = S;
  1395. S = !1;
  1396. ea = g.layerShadow;
  1397. c = c ? c : g.modalWidth;
  1398. f = f ? f : g.modalHeight;
  1399. 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="\u5173\u95ed (Esc)" tabindex="0" role="button"></span>' + a + "</div>" : "") + '<div class="xheModalContent"></div></div>').appendTo("body");
  1400. Fa = e('<div class="xheModalOverlay"></div>').appendTo("body");
  1401. 0 < ea && (Ea = e('<div class="xheModalShadow" style="width:' + K.outerWidth() + "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" !== e(this).css("visibility")
  1411. }).eq(0).focus()
  1412. }, 10);
  1413. ta = !0;
  1414. Ha = i
  1415. };
  1416. this.removeModal = function () {
  1417. Ga && Ga.css("visibility", "visible");
  1418. K.html("").remove();
  1419. 0 < ea && Ea.remove();
  1420. Fa.remove();
  1421. Ha && Ha();
  1422. ta = !1;
  1423. S = d.panelState
  1424. };
  1425. this.showDialog = function (a, b) {
  1426. var c = e('<div class="xheDialog"></div>'), f = e(a), i = e("#xheSave", f);
  1427. if (1 === i.length) {
  1428. f.find("input[type=text],select").keypress(function (a) {
  1429. if (13 ===
  1430. 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="\u53d6\u6d88" />');
  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,
  1450. b) {
  1451. if (!v.target)return !1;
  1452. t.html("").append(a).css("left", -999).css("top", -999);
  1453. da = e(v.target).closest("a").addClass("xheActive");
  1454. var c = da.offset(), d = c.left, c = c.top, c = c + (da.outerHeight() - 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({left: d, top: c}).show();
  1462. b || setTimeout(function () {
  1463. t.find("a,input[type=text],textarea").filter(":visible").filter(function () {
  1464. return "hidden" !== e(this).css("visibility")
  1465. }).eq(0).focus()
  1466. }, 10);
  1467. Qa = S = !0
  1468. };
  1469. this.hidePanel = function () {
  1470. S && (da.removeClass("xheActive"), ba.hide(), ca.hide(), t.hide(), S = !1, sa || (e(".xheFixCancel").remove(), sa = !0), Qa = oa = !1,
  1471. X = null, d.focus(), d.loadBookmark())
  1472. };
  1473. this.exec = function (a) {
  1474. d.hidePanel();
  1475. var b = ka[a];
  1476. if (!b)return !1;
  1477. if (null === v) {
  1478. v = {};
  1479. var c = n.find(".xheButton[cmd=" + a + "]");
  1480. if (1 === c.length)v.target = c
  1481. }
  1482. if (b.e)b.e.call(d); else switch (a = a.toLowerCase(), a) {
  1483. case "cut":
  1484. try {
  1485. if (l.execCommand(a), !l.queryCommandSupported(a))throw"Error";
  1486. } catch (f) {
  1487. alert("\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u526a\u5207\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl + X)\u6765\u5b8c\u6210")
  1488. }
  1489. break;
  1490. case "copy":
  1491. try {
  1492. if (l.execCommand(a), !l.queryCommandSupported(a))throw"Error";
  1493. } catch (i) {
  1494. alert("\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u590d\u5236\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl + C)\u6765\u5b8c\u6210")
  1495. }
  1496. break;
  1497. case "paste":
  1498. try {
  1499. if (l.execCommand(a), !l.queryCommandSupported(a))throw"Error";
  1500. } catch (m) {
  1501. alert("\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u7c98\u8d34\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u952e\u76d8\u5feb\u6377\u952e(Ctrl + V)\u6765\u5b8c\u6210")
  1502. }
  1503. break;
  1504. case "pastetext":
  1505. window.clipboardData ? d.pasteText(window.clipboardData.getData("Text", !0)) : d.showPastetext();
  1506. break;
  1507. case "blocktag":
  1508. var j = [];
  1509. e.each(gb, function (a, b) {
  1510. j.push({s: "<" + b.n + ">" + b.t + "</" + b.n + ">", v: "<" + b.n + ">", t: b.t})
  1511. });
  1512. d.showMenu(j, function (a) {
  1513. d._exec("formatblock", a)
  1514. });
  1515. break;
  1516. case "fontface":
  1517. var o = [];
  1518. e.each(hb, function (a, b) {
  1519. b.c = b.c ? b.c : b.n;
  1520. o.push({s: '<span style="font-family:' + b.c + '">' + b.n + "</span>", v: b.c, t: b.n})
  1521. });
  1522. d.showMenu(o, function (a) {
  1523. d._exec("fontname", a)
  1524. });
  1525. break;
  1526. case "fontsize":
  1527. var q =
  1528. [];
  1529. e.each(T, function (a, b) {
  1530. q.push({s: '<span style="font-size:' + b.s + ';">' + b.t + "(" + b.s + ")</span>", v: a + 1, t: b.t})
  1531. });
  1532. d.showMenu(q, function (a) {
  1533. d._exec("fontsize", a)
  1534. });
  1535. break;
  1536. case "fontcolor":
  1537. d.showColor(function (a) {
  1538. d._exec("forecolor", a)
  1539. });
  1540. break;
  1541. case "backcolor":
  1542. d.showColor(function (a) {
  1543. h ? d._exec("backcolor", a) : (Ka(!0), d._exec("hilitecolor", a), Ka(!1))
  1544. });
  1545. break;
  1546. case "align":
  1547. d.showMenu(ib, function (a) {
  1548. d._exec(a)
  1549. });
  1550. break;
  1551. case "list":
  1552. d.showMenu(jb, function (a) {
  1553. d._exec(a)
  1554. });
  1555. break;
  1556. case "link":
  1557. d.showLink();
  1558. break;
  1559. case "anchor":
  1560. d.showAnchor();
  1561. break;
  1562. case "img":
  1563. d.showImg();
  1564. break;
  1565. case "flash":
  1566. d.showEmbed("Flash", '<div><label for="xheFlashUrl">\u52a8\u753b\u6587\u4ef6: </label><input type="text" id="xheFlashUrl" value="http://" class="xheText" /></div><div><label for="xheFlashWidth">\u5bbd\u3000\u3000\u5ea6: </label><input type="text" id="xheFlashWidth" style="width:40px;" value="320" /> <label for="xheFlashHeight">\u9ad8\u3000\u3000\u5ea6: </label><input type="text" id="xheFlashHeight" style="width:40px;" value="240" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>',
  1567. "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);
  1568. break;
  1569. case "media":
  1570. d.showEmbed("Media", '<div><label for="xheMediaUrl">\u5a92\u4f53\u6587\u4ef6: </label><input type="text" id="xheMediaUrl" value="http://" class="xheText" /></div><div><label for="xheMediaWidth">\u5bbd\u3000\u3000\u5ea6: </label><input type="text" id="xheMediaWidth" style="width:40px;" value="320" /> <label for="xheMediaHeight">\u9ad8\u3000\u3000\u5ea6: </label><input type="text" id="xheMediaHeight" style="width:40px;" value="240" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="\u786e\u5b9a" /></div>',
  1571. "application/x-mplayer2", "clsid:6bf52a52-394a-11d3-b153-00c04f79faa6", ' enablecontextmenu="false" autostart="false"', g.upMediaUrl, g.upMediaExt);
  1572. break;
  1573. case "hr":
  1574. d.pasteHTML("<hr />");
  1575. break;
  1576. case "emot":
  1577. d.showEmot();
  1578. break;
  1579. case "table":
  1580. d.showTable();
  1581. break;
  1582. case "source":
  1583. d.toggleSource();
  1584. break;
  1585. case "preview":
  1586. d.showPreview();
  1587. break;
  1588. case "print":
  1589. W.print();
  1590. break;
  1591. case "fullscreen":
  1592. d.toggleFullscreen();
  1593. break;
  1594. case "about":
  1595. d.showAbout();
  1596. break;
  1597. default:
  1598. d._exec(a)
  1599. }
  1600. v = null
  1601. };
  1602. this._exec = function (a, b, c) {
  1603. c || d.focus();
  1604. return b !==
  1605. $ ? l.execCommand(a, !1, b) : l.execCommand(a, !1, null)
  1606. }
  1607. };
  1608. ra.settings = {
  1609. skin: "default",
  1610. tools: "full",
  1611. clickCancelDialog: !0,
  1612. linkTag: !1,
  1613. internalScript: !1,
  1614. inlineScript: !1,
  1615. internalStyle: !0,
  1616. inlineStyle: !0,
  1617. showBlocktag: !1,
  1618. forcePtag: !0,
  1619. upLinkExt: "zip,rar,txt",
  1620. upImgExt: "jpg,jpeg,gif,png",
  1621. upFlashExt: "swf",
  1622. upMediaExt: "wmv,avi,wma,mp3,mid",
  1623. modalWidth: 350,
  1624. modalHeight: 220,
  1625. modalTitle: !0,
  1626. defLinkText: "\u70b9\u51fb\u6253\u5f00\u94fe\u63a5",
  1627. layerShadow: 3,
  1628. emotMark: !1,
  1629. upBtnText: "\u4e0a\u4f20",
  1630. cleanPaste: 1,
  1631. hoverExecDelay: 100,
  1632. html5Upload: !0,
  1633. upMultiple: 99
  1634. };
  1635. window.xheditor = ra;
  1636. e(function () {
  1637. e.fn.oldVal = e.fn.val;
  1638. e.fn.val = function (e) {
  1639. var h = this, q;
  1640. return e === $ ? h[0] && (q = h[0].xheditor) ? q.getSource() : h.oldVal() : h.each(function () {
  1641. (q = this.xheditor) ? q.setSource(e) : h.oldVal(e)
  1642. })
  1643. };
  1644. e("textarea").each(function () {
  1645. var h = e(this), o = h.attr("class");
  1646. if (o && (o = o.match(/(?:^|\s)xheditor(?:\-(m?full|simple|mini))?(?:\s|$)/i)))h.xheditor(o[1] ? {tools: o[1]} : null)
  1647. })
  1648. })
  1649. })(jQuery);