editor2.min.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  1. !
  2. function(t) {
  3. "function" == typeof define && define.amd ? define(["jquery", "codemirror"], t) : t(window.jQuery, window.CodeMirror)
  4. }(function(t, e) {
  5. "function" != typeof Array.prototype.reduce && (Array.prototype.reduce = function(t, e) {
  6. var n, a, o = this.length >>> 0,
  7. i = !1;
  8. for (1 < arguments.length && (a = e, i = !0), n = 0; o > n; ++n) this.hasOwnProperty(n) && (i ? a = t(a, this[n], n, this) : (a = this[n], i = !0));
  9. if (!i) throw new TypeError("Reduce of empty array with no initial value");
  10. return a
  11. });
  12. var n = {
  13. bMac: navigator.appVersion.indexOf("Mac") > -1,
  14. bMSIE: navigator.userAgent.indexOf("MSIE") > -1,
  15. bFF: navigator.userAgent.indexOf("Firefox") > -1,
  16. bCodeMirror: !! e
  17. },
  18. a = function() {
  19. var t = function(t) {
  20. return function(e) {
  21. return t === e
  22. }
  23. },
  24. e = function(t, e) {
  25. return t === e
  26. },
  27. n = function() {
  28. return !1
  29. },
  30. a = function(t) {
  31. return function() {
  32. return !t.apply(t, arguments)
  33. }
  34. },
  35. o = function(t) {
  36. return t
  37. };
  38. return {
  39. eq: t,
  40. eq2: e,
  41. fail: n,
  42. not: a,
  43. self: o
  44. }
  45. }(),
  46. o = function() {
  47. var t = function(t) {
  48. return t[0]
  49. },
  50. e = function(t) {
  51. return t[t.length - 1]
  52. },
  53. n = function(t) {
  54. return t.slice(0, t.length - 1)
  55. },
  56. o = function(t) {
  57. return t.slice(1)
  58. },
  59. i = function(t, e) {
  60. return e = e || a.self, t.reduce(function(t, n) {
  61. return t + e(n)
  62. }, 0)
  63. },
  64. r = function(t) {
  65. for (var e = [], n = -1, a = t.length; ++n < a;) e[n] = t[n];
  66. return e
  67. },
  68. l = function(n, a) {
  69. if (0 === n.length) return [];
  70. var i = o(n);
  71. return i.reduce(function(t, n) {
  72. var o = e(t);
  73. return a(e(o), n) ? o[o.length] = n : t[t.length] = [n], t
  74. }, [
  75. [t(n)]
  76. ])
  77. },
  78. s = function(t) {
  79. for (var e = [], n = 0, a = t.length; a > n; n++) t[n] && e.push(t[n]);
  80. return e
  81. };
  82. return {
  83. head: t,
  84. last: e,
  85. initial: n,
  86. tail: o,
  87. sum: i,
  88. from: r,
  89. compact: s,
  90. clusterBy: l
  91. }
  92. }(),
  93. i = function() {
  94. var e = function(t) {
  95. return function(e) {
  96. return e && e.nodeName === t
  97. }
  98. },
  99. n = function(t) {
  100. return t && /^DIV|^P|^LI|^H[1-7]/.test(t.nodeName)
  101. },
  102. r = "<p><br/></p>",
  103. l = function(t) {
  104. return t && /^UL|^OL/.test(t.nodeName)
  105. },
  106. s = function(e) {
  107. return e && t(e).hasClass("note-editable")
  108. },
  109. d = function(e) {
  110. return e && t(e).hasClass("note-control-sizing")
  111. },
  112. c = function(t, e) {
  113. for (; t;) {
  114. if (e(t)) return t;
  115. t = t.parentNode
  116. }
  117. return null
  118. },
  119. u = function(t, e) {
  120. e = e || a.fail;
  121. var n = [];
  122. return c(t, function(t) {
  123. return n.push(t), e(t)
  124. }), n
  125. },
  126. f = function(e, n) {
  127. for (var a = u(e), o = n; o; o = o.parentNode) if (t.inArray(o, a) > -1) return o;
  128. return null
  129. },
  130. h = function(t, e) {
  131. var n = [],
  132. a = !1,
  133. o = !1,
  134. i = function(r) {
  135. if (r) {
  136. if (r === t && (a = !0), a && !o && n.push(r), r === e) return void(o = !0);
  137. for (var l = 0, s = r.childNodes.length; s > l; l++) i(r.childNodes[l])
  138. }
  139. };
  140. return i(f(t, e)), n
  141. },
  142. b = function(t, e) {
  143. e = e || a.fail;
  144. for (var n = []; t && (n.push(t), !e(t));) t = t.previousSibling;
  145. return n
  146. },
  147. v = function(t, e) {
  148. e = e || a.fail;
  149. for (var n = []; t && (n.push(t), !e(t));) t = t.nextSibling;
  150. return n
  151. },
  152. m = function(t, e) {
  153. var n = e.nextSibling,
  154. a = e.parentNode;
  155. return n ? a.insertBefore(t, n) : a.appendChild(t), t
  156. },
  157. g = function(e, n) {
  158. return t.each(n, function(t, n) {
  159. e.appendChild(n)
  160. }), e
  161. },
  162. p = e("#text"),
  163. y = function(t) {
  164. return p(t) ? t.nodeValue.length : t.childNodes.length
  165. },
  166. k = function(t) {
  167. for (var e = 0; t = t.previousSibling;) e += 1;
  168. return e
  169. },
  170. w = function(e, n) {
  171. var i = o.initial(u(n, a.eq(e)));
  172. return t.map(i, k).reverse()
  173. },
  174. C = function(t, e) {
  175. for (var n = t, a = 0, o = e.length; o > a; a++) n = n.childNodes[e[a]];
  176. return n
  177. },
  178. x = function(t, e) {
  179. if (0 === e) return t;
  180. if (e >= y(t)) return t.nextSibling;
  181. if (p(t)) return t.splitText(e);
  182. var n = t.childNodes[e];
  183. return t = m(t.cloneNode(!1), t), g(t, v(n))
  184. },
  185. F = function(t, e, n) {
  186. var o = u(e, a.eq(t));
  187. return 1 === o.length ? x(e, n) : o.reduce(function(t, a) {
  188. var o = a.cloneNode(!1);
  189. return m(o, a), t === e && (t = x(t, n)), g(o, v(t)), o
  190. })
  191. },
  192. S = function(t, e) {
  193. if (t && t.parentNode) {
  194. if (t.removeNode) return t.removeNode(e);
  195. var n = t.parentNode;
  196. if (!e) {
  197. var a, o, i = [];
  198. for (a = 0, o = t.childNodes.length; o > a; a++) i.push(t.childNodes[a]);
  199. for (a = 0, o = i.length; o > a; a++) n.insertBefore(i[a], t)
  200. }
  201. n.removeChild(t)
  202. }
  203. },
  204. A = function(t) {
  205. return i.isTextarea(t[0]) ? t.val() : t.html()
  206. };
  207. return {
  208. emptyPara: r,
  209. isText: p,
  210. isPara: n,
  211. isList: l,
  212. isEditable: s,
  213. isControlSizing: d,
  214. isAnchor: e("A"),
  215. isDiv: e("DIV"),
  216. isSpan: e("SPAN"),
  217. isB: e("B"),
  218. isU: e("U"),
  219. isS: e("S"),
  220. isI: e("I"),
  221. isImg: e("IMG"),
  222. isTextarea: e("TEXTAREA"),
  223. ancestor: c,
  224. listAncestor: u,
  225. listNext: v,
  226. listPrev: b,
  227. commonAncestor: f,
  228. listBetween: h,
  229. insertAfter: m,
  230. position: k,
  231. makeOffsetPath: w,
  232. fromOffsetPath: C,
  233. split: F,
  234. remove: S,
  235. html: A
  236. }
  237. }(),
  238. r = function() {
  239. var e = !! document.createRange,
  240. n = function(t, e) {
  241. var n, a, r = t.parentElement(),
  242. l = document.body.createTextRange(),
  243. s = o.from(r.childNodes);
  244. for (n = 0; n < s.length; n++) if (!i.isText(s[n])) {
  245. if (l.moveToElementText(s[n]), l.compareEndPoints("StartToStart", t) >= 0) break;
  246. a = s[n]
  247. }
  248. if (0 !== n && i.isText(s[n - 1])) {
  249. var d = document.body.createTextRange(),
  250. c = null;
  251. d.moveToElementText(a || r), d.collapse(!a), c = a ? a.nextSibling : r.firstChild;
  252. var u = t.duplicate();
  253. u.setEndPoint("StartToStart", d);
  254. for (var f = u.text.replace(/[\r\n]/g, "").length; f > c.nodeValue.length && c.nextSibling;) f -= c.nodeValue.length, c = c.nextSibling; {
  255. c.nodeValue
  256. }
  257. e && c.nextSibling && i.isText(c.nextSibling) && f === c.nodeValue.length && (f -= c.nodeValue.length, c = c.nextSibling), r = c, n = f
  258. }
  259. return {
  260. cont: r,
  261. offset: n
  262. }
  263. },
  264. r = function(t) {
  265. var e = function(t, n) {
  266. var r, l;
  267. if (i.isText(t)) {
  268. var s = i.listPrev(t, a.not(i.isText)),
  269. d = o.last(s).previousSibling;
  270. r = d || t.parentNode, n += o.sum(o.tail(s), i.length), l = !d
  271. } else {
  272. if (r = t.childNodes[n] || t, i.isText(r)) return e(r, n);
  273. n = 0, l = !1
  274. }
  275. return {
  276. cont: r,
  277. collapseToStart: l,
  278. offset: n
  279. }
  280. },
  281. n = document.body.createTextRange(),
  282. r = e(t.cont, t.offset);
  283. return n.moveToElementText(r.cont), n.collapse(r.collapseToStart), n.moveStart("character", r.offset), n
  284. },
  285. l = function(n, l, s, d) {
  286. this.sc = n, this.so = l, this.ec = s, this.eo = d;
  287. var c = function() {
  288. if (e) {
  289. var t = document.createRange();
  290. return t.setStart(n, l), t.setEnd(s, d), t
  291. }
  292. var a = r({
  293. cont: n,
  294. offset: l
  295. });
  296. return a.setEndPoint("EndToEnd", r({
  297. cont: s,
  298. offset: d
  299. })), a
  300. };
  301. this.select = function() {
  302. var t = c();
  303. if (e) {
  304. var n = document.getSelection();
  305. n.rangeCount > 0 && n.removeAllRanges(), n.addRange(t)
  306. } else t.select()
  307. }, this.listPara = function() {
  308. var e = i.listBetween(n, s),
  309. r = o.compact(t.map(e, function(t) {
  310. return i.ancestor(t, i.isPara)
  311. }));
  312. return t.map(o.clusterBy(r, a.eq2), o.head)
  313. };
  314. var u = function(t) {
  315. return function() {
  316. var e = i.ancestor(n, t);
  317. return e && e === i.ancestor(s, t)
  318. }
  319. };
  320. this.isOnEditable = u(i.isEditable), this.isOnList = u(i.isList), this.isOnAnchor = u(i.isAnchor), this.isCollapsed = function() {
  321. return n === s && l === d
  322. }, this.insertNode = function(t) {
  323. var n = c();
  324. e ? n.insertNode(t) : n.pasteHTML(t.outerHTML)
  325. }, this.toString = function() {
  326. var t = c();
  327. return e ? t.toString() : t.text
  328. }, this.bookmark = function(t) {
  329. return {
  330. s: {
  331. path: i.makeOffsetPath(t, n),
  332. offset: l
  333. },
  334. e: {
  335. path: i.makeOffsetPath(t, s),
  336. offset: d
  337. }
  338. }
  339. }
  340. };
  341. return {
  342. create: function(t, a, o, i) {
  343. if (0 === arguments.length) if (e) {
  344. var r = document.getSelection();
  345. if (0 === r.rangeCount) return null;
  346. var s = r.getRangeAt(0);
  347. t = s.startContainer, a = s.startOffset, o = s.endContainer, i = s.endOffset
  348. } else {
  349. var d = document.selection.createRange(),
  350. c = d.duplicate();
  351. c.collapse(!1);
  352. var u = d;
  353. u.collapse(!0);
  354. var f = n(u, !0),
  355. h = n(c, !1);
  356. t = f.cont, a = f.offset, o = h.cont, i = h.offset
  357. } else 2 === arguments.length && (o = t, i = a);
  358. return new l(t, a, o, i)
  359. },
  360. createFromBookmark: function(t, e) {
  361. var n = i.fromOffsetPath(t, e.s.path),
  362. a = e.s.offset,
  363. o = i.fromOffsetPath(t, e.e.path),
  364. r = e.e.offset;
  365. return new l(n, a, o, r)
  366. }
  367. }
  368. }(),
  369. l = function() {
  370. var e = function(e) {
  371. return t.Deferred(function(t) {
  372. var n = new FileReader;
  373. n.onload = function(e) {
  374. t.resolve(e.target.result)
  375. }, n.onerror = function() {
  376. t.reject(this)
  377. }, n.readAsDataURL(e)
  378. }).promise()
  379. },
  380. n = function(e) {
  381. return t.Deferred(function(t) {
  382. function n() {
  383. o(), t.resolve(i)
  384. }
  385. function a() {
  386. o(), t.reject(i)
  387. }
  388. function o() {
  389. i.onload = null, i.onerror = null, i.onabort = null
  390. }
  391. var i = new Image;
  392. i.onload = n, i.onerror = a, i.onabort = a, i.src = e
  393. }).promise()
  394. };
  395. return {
  396. readFile: e,
  397. loadImage: n
  398. }
  399. }(),
  400. s = function() {
  401. this.stylePara = function(e, n) {
  402. var a = e.listPara();
  403. t.each(a, function(e, a) {
  404. t.each(n, function(t, e) {
  405. a.style[t] = e
  406. })
  407. })
  408. }, this.current = function(e, n) {
  409. var a = t(i.isText(e.sc) ? e.sc.parentNode : e.sc),
  410. o = a.css(["font-size", "text-align", "list-style-type", "line-height"]) || {};
  411. if (o["font-size"] = parseInt(o["font-size"]), o["font-bold"] = document.queryCommandState("bold") ? "bold" : "normal", o["font-italic"] = document.queryCommandState("italic") ? "italic" : "normal", o["font-underline"] = document.queryCommandState("underline") ? "underline" : "normal", e.isOnList()) {
  412. var r = ["circle", "disc", "disc-leading-zero", "square"],
  413. l = t.inArray(o["list-style-type"], r) > -1;
  414. o["list-style"] = l ? "unordered" : "ordered"
  415. } else o["list-style"] = "none";
  416. var s = i.ancestor(e.sc, i.isPara);
  417. if (s && s.style["line-height"]) o["line-height"] = s.style.lineHeight;
  418. else {
  419. var d = parseInt(o["line-height"]) / parseInt(o["font-size"]);
  420. o["line-height"] = d.toFixed(1)
  421. }
  422. return o.image = i.isImg(n) && n, o.anchor = e.isOnAnchor() && i.ancestor(e.sc, i.isAnchor), o.aAncestor = i.listAncestor(e.sc, i.isEditable), o
  423. }
  424. },
  425. d = function() {
  426. var t = [],
  427. e = [],
  428. n = function(t) {
  429. var e = t[0],
  430. n = r.create();
  431. return {
  432. contents: t.html(),
  433. bookmark: n.bookmark(e),
  434. scrollTop: t.scrollTop()
  435. }
  436. },
  437. a = function(t, e) {
  438. t.html(e.contents).scrollTop(e.scrollTop), r.createFromBookmark(t[0], e.bookmark).select()
  439. };
  440. this.undo = function(o) {
  441. var i = n(o);
  442. 0 !== t.length && (a(o, t.pop()), e.push(i))
  443. }, this.redo = function(o) {
  444. var i = n(o);
  445. 0 !== e.length && (a(o, e.pop()), t.push(i))
  446. }, this.recordUndo = function(a) {
  447. e = [], t.push(n(a))
  448. }
  449. },
  450. c = function() {
  451. this.saveRange = function(t) {
  452. t.data("range", r.create())
  453. }, this.restoreRange = function(t) {
  454. var e = t.data("range");
  455. e && e.select()
  456. };
  457. var e = new s;
  458. this.currentStyle = function(t) {
  459. var n = r.create();
  460. return n.isOnEditable() && e.current(n, t)
  461. }, this.tab = function(e) {
  462. a(e);
  463. var n = r.create(),
  464. o = new Array(e.data("tabsize") + 1).join("&nbsp;");
  465. n.insertNode(t('<span id="noteTab">' + o + "</span>")[0]);
  466. var l = t("#noteTab").removeAttr("id");
  467. n = r.create(l[0], 1), n.select(), i.remove(l[0])
  468. }, this.undo = function(t) {
  469. t.data("NoteHistory").undo(t)
  470. }, this.redo = function(t) {
  471. t.data("NoteHistory").redo(t)
  472. };
  473. for (var a = this.recordUndo = function(t) {
  474. t.data("NoteHistory").recordUndo(t)
  475. }, o = ["bold", "italic", "underline", "strikethrough", "justifyLeft", "justifyCenter", "justifyRight", "justifyFull", "insertOrderedList", "insertUnorderedList", "indent", "outdent", "formatBlock", "removeFormat", "backColor", "foreColor", "insertHorizontalRule"], d = 0, c = o.length; c > d; d++) this[o[d]] = function(t) {
  476. return function(e, n) {
  477. a(e), document.execCommand(t, !1, n)
  478. }
  479. }(o[d]);
  480. this.insertImage = function(e, n) {
  481. l.loadImage(n).done(function(o) {
  482. a(e);
  483. var i = t("<img>").attr("src", n);
  484. i.css("width", Math.min(e.width(), o.width)), r.create().insertNode(i[0])
  485. }).fail(function() {
  486. var t = e.data("callbacks");
  487. t.onImageUploadError && t.onImageUploadError()
  488. })
  489. }, this.insertVideo = function(e, n) {
  490. var a, o = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,
  491. i = n.match(o),
  492. l = /\/\/instagram.com\/p\/(.[a-zA-Z0-9]*)/,
  493. s = n.match(l),
  494. d = /\/\/vine.co\/v\/(.[a-zA-Z0-9]*)/,
  495. c = n.match(d),
  496. u = /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/,
  497. f = n.match(u),
  498. h = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/,
  499. b = n.match(h);
  500. if (i && 11 === i[2].length) {
  501. var v = i[2];
  502. a = t("<iframe>").attr("src", "http://www.youtube.com/embed/" + v).attr("width", "640").attr("height", "360")
  503. } else s && s[0].length > 0 ? a = t("<iframe>").attr("src", s[0] + "/embed/").attr("width", "612").attr("height", "710").attr("scrolling", "no").attr("allowtransparency", "true") : c && c[0].length > 0 ? a = t("<iframe>").attr("src", c[0] + "/embed/simple").attr("width", "600").attr("height", "600").attr("class", "vine-embed") : f && f[3].length > 0 ? a = t("<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>").attr("src", "//player.vimeo.com/video/" + f[3]).attr("width", "640").attr("height", "360") : b && b[2].length > 0 && (a = t("<iframe>").attr("src", "http://www.dailymotion.com/embed/video/" + b[2]).attr("width", "640").attr("height", "360"));
  504. a && (a.attr("frameborder", 0), r.create().insertNode(a[0]))
  505. }, this.formatBlock = function(t, e) {
  506. a(t), e = n.bMSIE ? "<" + e + ">" : e, document.execCommand("FormatBlock", !1, e)
  507. }, this.fontSize = function(t, e) {
  508. a(t), document.execCommand("fontSize", !1, 3), n.bFF ? t.find("font[size=3]").removeAttr("size").css("font-size", e + "px") : t.find("span").filter(function() {
  509. return "medium" === this.style.fontSize
  510. }).css("font-size", e + "px")
  511. }, this.lineHeight = function(t, n) {
  512. a(t), e.stylePara(r.create(), {
  513. lineHeight: n
  514. })
  515. }, this.unlink = function(t) {
  516. var e = r.create();
  517. if (e.isOnAnchor()) {
  518. a(t);
  519. var n = i.ancestor(e.sc, i.isAnchor);
  520. e = r.create(n, 0, n, 1), e.select(), document.execCommand("unlink")
  521. }
  522. }, this.setLinkDialog = function(e, o) {
  523. var l = r.create();
  524. if (l.isOnAnchor()) {
  525. var s = i.ancestor(l.sc, i.isAnchor);
  526. l = r.create(s, 0, s, 1)
  527. }
  528. o({
  529. range: l,
  530. text: l.toString(),
  531. url: l.isOnAnchor() ? i.ancestor(l.sc, i.isAnchor).href : ""
  532. }, function(o) {
  533. l.select(), a(e);
  534. var i;
  535. if (i = -1 !== o.indexOf("@") ? -1 !== o.indexOf(":") ? o : "mailto:" + o : -1 !== o.indexOf("://") ? o : "http://" + o, n.bMSIE && l.isCollapsed()) {
  536. l.insertNode(t('<A id="linkAnchor">' + o + "</A>")[0]);
  537. var s = t("#linkAnchor").removeAttr("id").attr("href", i);
  538. l = r.create(s[0], 0, s[0], 1), l.select()
  539. } else document.execCommand("createlink", !1, i)
  540. })
  541. }, this.setVideoDialog = function(t, e) {
  542. var n = r.create(),
  543. o = this;
  544. if (n.isOnAnchor()) {
  545. var l = i.ancestor(n.sc, i.isAnchor);
  546. n = r.create(l, 0, l, 1)
  547. }
  548. e({
  549. range: n,
  550. text: n.toString()
  551. }, function(e) {
  552. n.select(), a(t), o.insertVideo(t, e)
  553. })
  554. }, this.color = function(t, e) {
  555. var n = JSON.parse(e),
  556. o = n.foreColor,
  557. i = n.backColor;
  558. a(t), o && document.execCommand("foreColor", !1, o), i && document.execCommand("backColor", !1, i)
  559. }, this.insertTable = function(e, o) {
  560. a(e);
  561. for (var i, l = o.split("x"), s = l[0], d = l[1], c = [], u = n.bMSIE ? "&nbsp;" : "<br/>", f = 0; s > f; f++) c.push("<td>" + u + "</td>");
  562. i = c.join("");
  563. for (var h, b = [], v = 0; d > v; v++) b.push("<tr>" + i + "</tr>");
  564. h = b.join("");
  565. var m = '<table class="table table-bordered">' + h + "</table>";
  566. r.create().insertNode(t(m)[0])
  567. }, this.floatMe = function(t, e, n) {
  568. a(t), n.style.cssFloat = e
  569. }, this.resize = function(t, e, n) {
  570. a(t), n.style.width = t.width() * e + "px", n.style.height = ""
  571. }, this.resizeTo = function(t, e) {
  572. var n = t.y / t.x,
  573. a = e.data("ratio");
  574. e.css({
  575. width: a > n ? t.x : t.y / a,
  576. height: a > n ? t.x * a : t.y
  577. })
  578. }
  579. },
  580. u = function() {
  581. this.update = function(e, n) {
  582. var a = function(e, n) {
  583. e.find(".dropdown-menu li a").each(function() {
  584. var e = parseFloat(t(this).data("value")) === n;
  585. this.className = e ? "checked" : ""
  586. })
  587. },
  588. o = e.find(".note-fontsize");
  589. o.find(".note-current-fontsize").html(n["font-size"]), a(o, parseFloat(n["font-size"]));
  590. var i = e.find(".note-height");
  591. a(i, parseFloat(n["line-height"]));
  592. var r = function(t, n) {
  593. var a = e.find(t);
  594. a[n() ? "addClass" : "removeClass"]("active")
  595. };
  596. r('button[data-event="bold"]', function() {
  597. return "bold" === n["font-bold"]
  598. }), r('button[data-event="italic"]', function() {
  599. return "italic" === n["font-italic"]
  600. }), r('button[data-event="underline"]', function() {
  601. return "underline" === n["font-underline"]
  602. }), r('button[data-event="justifyLeft"]', function() {
  603. return "left" === n["text-align"] || "start" === n["text-align"]
  604. }), r('button[data-event="justifyCenter"]', function() {
  605. return "center" === n["text-align"]
  606. }), r('button[data-event="justifyRight"]', function() {
  607. return "right" === n["text-align"]
  608. }), r('button[data-event="justifyFull"]', function() {
  609. return "justify" === n["text-align"]
  610. }), r('button[data-event="insertUnorderedList"]', function() {
  611. return "unordered" === n["list-style"]
  612. }), r('button[data-event="insertOrderedList"]', function() {
  613. return "ordered" === n["list-style"]
  614. })
  615. }, this.updateRecentColor = function(e, n, a) {
  616. var o = t(e).closest(".note-color"),
  617. i = o.find(".note-recent-color"),
  618. r = JSON.parse(i.attr("data-value"));
  619. r[n] = a, i.attr("data-value", JSON.stringify(r));
  620. var l = "backColor" === n ? "background-color" : "color";
  621. i.find("i").css(l, a)
  622. }, this.updateFullscreen = function(t, e) {
  623. var n = t.find('button[data-event="fullscreen"]');
  624. n[e ? "addClass" : "removeClass"]("active")
  625. }, this.updateCodeview = function(t, e) {
  626. var n = t.find('button[data-event="codeview"]');
  627. n[e ? "addClass" : "removeClass"]("active")
  628. }, this.enable = function(t) {
  629. t.find("button").not('button[data-event="codeview"]').removeClass("disabled")
  630. }, this.disable = function(t) {
  631. t.find("button").not('button[data-event="codeview"]').addClass("disabled")
  632. }
  633. },
  634. f = function() {
  635. var e = function(e, n) {
  636. var a = t(n),
  637. o = a.position(),
  638. i = a.height();
  639. e.css({
  640. display: "block",
  641. left: o.left,
  642. top: o.top + i
  643. })
  644. };
  645. this.update = function(t, n) {
  646. var a = t.find(".note-link-popover"),
  647. o = t.find(".note-image-popover");
  648. if (n.anchor) {
  649. var i = a.find("a");
  650. i.attr("href", n.anchor.href).html(n.anchor.href), e(a, n.anchor)
  651. } else a.hide();
  652. n.image ? e(o, n.image) : o.hide()
  653. }, this.hide = function(t) {
  654. t.children().hide()
  655. }
  656. },
  657. h = function() {
  658. this.update = function(e, n) {
  659. var a = e.find(".note-control-selection");
  660. if (n.image) {
  661. var o = t(n.image),
  662. i = o.position(),
  663. r = {
  664. w: o.width(),
  665. h: o.height()
  666. };
  667. a.css({
  668. display: "block",
  669. left: i.left,
  670. top: i.top,
  671. width: r.w,
  672. height: r.h
  673. }).data("target", n.image);
  674. var l = r.w + "x" + r.h;
  675. a.find(".note-control-selection-info").text(l)
  676. } else a.hide()
  677. }, this.hide = function(t) {
  678. t.children().hide()
  679. }
  680. },
  681. b = function() {
  682. var e = function(t, e) {
  683. e ? t.removeClass("disabled").attr("disabled", !1) : t.addClass("disabled").attr("disabled", !0)
  684. };
  685. this.showImageDialog = function(n, a, o) {
  686. var i = n.find(".note-image-dialog"),
  687. r = n.find(".note-image-input"),
  688. l = n.find(".note-image-url"),
  689. s = n.find(".note-image-btn");
  690. i.on("shown.bs.modal", function() {
  691. r.on("change", function() {
  692. subimg(this), a(this.files), t(this).val(""), i.modal("hide")
  693. }), l.val("").keyup(function() {
  694. e(s, l.val())
  695. }).trigger("focus"), s.click(function(t) {
  696. i.modal("hide"), o(l.val()), t.preventDefault()
  697. })
  698. }).on("hidden.bs.modal", function() {
  699. r.off("change"), i.off("shown.bs.modal hidden.bs.modal"), l.off("keyup"), s.off("click")
  700. }).modal("show")
  701. }, this.showVideoDialog = function(t, n, a) {
  702. var o = t.find(".note-video-dialog"),
  703. i = o.find(".note-video-url"),
  704. r = o.find(".note-video-btn");
  705. o.on("shown.bs.modal", function() {
  706. i.val(n.text).keyup(function() {
  707. e(r, i.val())
  708. }).trigger("keyup").trigger("focus"), r.click(function(t) {
  709. o.modal("hide"), a(i.val()), t.preventDefault()
  710. })
  711. }).on("hidden.bs.modal", function() {
  712. i.off("keyup"), r.off("click"), o.off("show.bs.modal hidden.bs.modal")
  713. }).modal("show")
  714. }, this.showLinkDialog = function(t, n, a) {
  715. var o = t.find(".note-link-dialog"),
  716. i = o.find(".note-link-text"),
  717. r = o.find(".note-link-url"),
  718. l = o.find(".note-link-btn");
  719. o.on("shown.bs.modal", function() {
  720. i.html(n.text), r.val(n.url).keyup(function() {
  721. e(l, r.val()), n.text || i.html(r.val())
  722. }).trigger("focus"), l.click(function(t) {
  723. o.modal("hide"), a(r.val()), t.preventDefault()
  724. })
  725. }).on("hidden.bs.modal", function() {
  726. r.off("keyup"), l.off("click"), o.off("shown.bs.modal hidden.bs.modal")
  727. }).modal("show")
  728. }, this.showHelpDialog = function(t) {
  729. t.find(".note-help-dialog").modal("show")
  730. }
  731. function subimg(e) {
  732. console.log($(e).val());
  733. }
  734. },
  735. v = function() {
  736. var a = new c,
  737. o = new u,
  738. r = new f,
  739. s = new h,
  740. d = new b,
  741. v = {
  742. BACKSPACE: 8,
  743. TAB: 9,
  744. ENTER: 13,
  745. SPACE: 32,
  746. NUM0: 48,
  747. NUM1: 49,
  748. NUM6: 54,
  749. NUM7: 55,
  750. NUM8: 56,
  751. B: 66,
  752. E: 69,
  753. I: 73,
  754. J: 74,
  755. K: 75,
  756. L: 76,
  757. R: 82,
  758. S: 83,
  759. U: 85,
  760. Y: 89,
  761. Z: 90,
  762. SLASH: 191,
  763. LEFTBRACKET: 219,
  764. BACKSLACH: 220,
  765. RIGHTBRACKET: 221
  766. },
  767. m = function(e) {
  768. var n = t(e).closest(".note-editor");
  769. return {
  770. editor: function() {
  771. return n
  772. },
  773. toolbar: function() {
  774. return n.find(".note-toolbar")
  775. },
  776. editable: function() {
  777. return n.find(".note-editable")
  778. },
  779. codable: function() {
  780. return n.find(".note-codable")
  781. },
  782. statusbar: function() {
  783. return n.find(".note-statusbar")
  784. },
  785. popover: function() {
  786. return n.find(".note-popover")
  787. },
  788. handle: function() {
  789. return n.find(".note-handle")
  790. },
  791. dialog: function() {
  792. return n.find(".note-dialog")
  793. }
  794. }
  795. },
  796. g = function(t) {
  797. var e = n.bMac ? t.metaKey : t.ctrlKey,
  798. o = t.shiftKey,
  799. i = t.keyCode,
  800. r = e || o || i === v.TAB,
  801. l = r ? m(t.target) : null;
  802. if (i === v.TAB && l.editable().data("tabsize")) a.tab(l.editable());
  803. else if (e && (o && i === v.Z || i === v.Y)) a.redo(l.editable());
  804. else if (e && i === v.Z) a.undo(l.editable());
  805. else if (e && i === v.B) a.bold(l.editable());
  806. else if (e && i === v.I) a.italic(l.editable());
  807. else if (e && i === v.U) a.underline(l.editable());
  808. else if (e && o && i === v.S) a.strikethrough(l.editable());
  809. else if (e && i === v.BACKSLACH) a.removeFormat(l.editable());
  810. else if (e && i === v.K) l.editable(), a.setLinkDialog(l.editable(), function(t, e) {
  811. d.showLinkDialog(l.dialog(), t, e)
  812. });
  813. else if (e && i === v.SLASH) d.showHelpDialog(l.dialog());
  814. else if (e && o && i === v.L) a.justifyLeft(l.editable());
  815. else if (e && o && i === v.E) a.justifyCenter(l.editable());
  816. else if (e && o && i === v.R) a.justifyRight(l.editable());
  817. else if (e && o && i === v.J) a.justifyFull(l.editable());
  818. else if (e && o && i === v.NUM7) a.insertUnorderedList(l.editable());
  819. else if (e && o && i === v.NUM8) a.insertOrderedList(l.editable());
  820. else if (e && i === v.LEFTBRACKET) a.outdent(l.editable());
  821. else if (e && i === v.RIGHTBRACKET) a.indent(l.editable());
  822. else if (e && i === v.NUM0) a.formatBlock(l.editable(), "P");
  823. else if (e && v.NUM1 <= i && i <= v.NUM6) {
  824. var s = "H" + String.fromCharCode(i);
  825. a.formatBlock(l.editable(), s)
  826. } else {
  827. if (!e || i !== v.ENTER) return void((i === v.BACKSPACE || i === v.ENTER || i === v.SPACE) && a.recordUndo(m(t.target).editable()));
  828. a.insertHorizontalRule(l.editable())
  829. }
  830. t.preventDefault()
  831. },
  832. p = function(e, n) {
  833. var o = e.data("callbacks");
  834. a.restoreRange(e), o.onImageUpload ? o.onImageUpload(n, a, e) : t.each(n, function(t, n) {
  835. l.readFile(n).done(function(t) {
  836. a.insertImage(e, t)
  837. }).fail(function() {
  838. o.onImageUploadError && o.onImageUploadError()
  839. })
  840. })
  841. },
  842. y = function(t) {
  843. var e = t.originalEvent.dataTransfer;
  844. if (e && e.files) {
  845. var n = m(t.currentTarget || t.target);
  846. n.editable().focus(), p(n.editable(), e.files)
  847. }
  848. t.preventDefault()
  849. },
  850. k = function(t) {
  851. i.isImg(t.target) && t.preventDefault()
  852. },
  853. w = function(t) {
  854. var e = m(t.currentTarget || t.target),
  855. n = a.currentStyle(t.target);
  856. n && (o.update(e.toolbar(), n), r.update(e.popover(), n), s.update(e.handle(), n))
  857. },
  858. C = function(t) {
  859. var e = m(t.currentTarget || t.target);
  860. r.hide(e.popover()), s.hide(e.handle())
  861. },
  862. x = function(e) {
  863. if (i.isControlSizing(e.target)) {
  864. var n, o = m(e.target),
  865. l = o.handle(),
  866. d = o.popover(),
  867. c = o.editable(),
  868. u = o.editor(),
  869. f = l.find(".note-control-selection").data("target"),
  870. h = t(f),
  871. b = h.offset(),
  872. v = t(document).scrollTop();
  873. u.on("mousemove", function(t) {
  874. n = {
  875. x: t.clientX - b.left,
  876. y: t.clientY - (b.top - v)
  877. }, a.resizeTo(n, h), s.update(l, {
  878. image: f
  879. }), r.update(d, {
  880. image: f
  881. })
  882. }).on("mouseup", function() {
  883. u.off("mousemove").off("mouseup")
  884. }), h.data("ratio") || h.data("ratio", h.height() / h.width()), a.recordUndo(c), e.stopPropagation(), e.preventDefault()
  885. }
  886. },
  887. F = function(e) {
  888. var n = t(e.target).closest("[data-event]");
  889. n.length > 0 && e.preventDefault()
  890. },
  891. S = function(r) {
  892. var l = t(r.target).closest("[data-event]");
  893. if (l.length > 0) {
  894. var s, c = l.attr("data-event"),
  895. u = l.attr("data-value"),
  896. f = m(r.target),
  897. h = f.editor(),
  898. b = f.toolbar(),
  899. v = f.dialog(),
  900. g = f.editable(),
  901. y = f.codable();
  902. if (-1 !== t.inArray(c, ["resize", "floatMe"])) {
  903. var k = f.handle(),
  904. C = k.find(".note-control-selection");
  905. s = C.data("target")
  906. }
  907. if (a[c] && (g.trigger("focus"), a[c](g, u, s)), -1 !== t.inArray(c, ["backColor", "foreColor"])) o.updateRecentColor(l[0], c, u);
  908. else if ("showLinkDialog" === c) g.focus(), a.setLinkDialog(g, function(t, e) {
  909. d.showLinkDialog(v, t, e)
  910. });
  911. else if ("showImageDialog" === c) g.focus(), d.showImageDialog(v, function(t) {
  912. p(g, t)
  913. }, function(t) {
  914. a.restoreRange(g), a.insertImage(g, t)
  915. });
  916. else if ("showVideoDialog" === c) g.focus(), a.setVideoDialog(g, function(t, e) {
  917. d.showVideoDialog(v, t, e)
  918. });
  919. else if ("showHelpDialog" === c) d.showHelpDialog(v);
  920. else if ("fullscreen" === c) {
  921. h.toggleClass("fullscreen");
  922. var x = function() {
  923. var e = t(window).height() - b.outerHeight();
  924. g.css("height", e)
  925. },
  926. F = h.hasClass("fullscreen");
  927. if (F) g.data("orgHeight", g.css("height")), t(window).resize(x).trigger("resize");
  928. else {
  929. var S = !! g.data("optionHeight");
  930. g.css("height", S ? g.data("orgHeight") : "auto"), t(window).off("resize")
  931. }
  932. o.updateFullscreen(b, F)
  933. } else if ("codeview" === c) {
  934. h.toggleClass("codeview");
  935. var A = h.hasClass("codeview");
  936. if (A) {
  937. if (y.val(g.html()), y.height(g.height()), o.disable(b), y.focus(), n.bCodeMirror) {
  938. var E = e.fromTextArea(y[0], t.extend({
  939. mode: "text/html",
  940. lineNumbers: !0
  941. }, h.data("options").codemirror));
  942. E.setSize(null, g.outerHeight()), E.autoFormatRange && E.autoFormatRange({
  943. line: 0,
  944. ch: 0
  945. }, {
  946. line: E.lineCount(),
  947. ch: E.getTextArea().value.length
  948. }), y.data("cmEditor", E)
  949. }
  950. } else n.bCodeMirror && y.data("cmEditor").toTextArea(), g.html(y.val() || i.emptyPara), g.height(g.data("optionHeight") ? y.height() : "auto"), o.enable(b), g.focus();
  951. o.updateCodeview(f.toolbar(), A)
  952. }
  953. w(r)
  954. }
  955. },
  956. A = 24,
  957. E = function(e) {
  958. var n = t(document),
  959. a = m(e.target),
  960. o = a.editable(),
  961. i = o.offset().top - n.scrollTop(),
  962. r = function(t) {
  963. o.height(t.clientY - (i + A))
  964. },
  965. l = function() {
  966. n.unbind("mousemove", r).unbind("mouseup", l)
  967. };
  968. n.mousemove(r).mouseup(l), e.stopPropagation(), e.preventDefault()
  969. },
  970. T = 18,
  971. z = function(e) {
  972. var n, a = t(e.target.parentNode),
  973. o = a.next(),
  974. i = a.find(".note-dimension-picker-mousecatcher"),
  975. r = a.find(".note-dimension-picker-highlighted"),
  976. l = a.find(".note-dimension-picker-unhighlighted");
  977. if (void 0 === e.offsetX) {
  978. var s = t(e.target).offset();
  979. n = {
  980. x: e.pageX - s.left,
  981. y: e.pageY - s.top
  982. }
  983. } else n = {
  984. x: e.offsetX,
  985. y: e.offsetY
  986. };
  987. var d = {
  988. c: Math.ceil(n.x / T) || 1,
  989. r: Math.ceil(n.y / T) || 1
  990. };
  991. r.css({
  992. width: d.c + "em",
  993. height: d.r + "em"
  994. }), i.attr("data-value", d.c + "x" + d.r), 3 < d.c && d.c < 10 && l.css({
  995. width: d.c + 1 + "em"
  996. }), 3 < d.r && d.r < 10 && l.css({
  997. height: d.r + 1 + "em"
  998. }), o.html(d.c + " x " + d.r)
  999. },
  1000. I = function(e) {
  1001. var n = t(),
  1002. a = e.dropzone,
  1003. o = e.dropzone.find(".note-dropzone-message");
  1004. t(document).on("dragenter", function(t) {
  1005. var i = e.editor.hasClass("codeview");
  1006. i || 0 !== n.length || (e.editor.addClass("dragover"), a.width(e.editor.width()), a.height(e.editor.height()), o.text("Drag Image Here")), n = n.add(t.target)
  1007. }).on("dragleave", function(t) {
  1008. n = n.not(t.target), 0 === n.length && e.editor.removeClass("dragover")
  1009. }).on("drop", function() {
  1010. n = t(), e.editor.removeClass("dragover")
  1011. }), a.on("dragenter", function() {
  1012. a.addClass("hover"), o.text("Drop Image")
  1013. }).on("dragleave", function() {
  1014. a.removeClass("hover"), o.text("Drag Image Here")
  1015. }), a.on("drop", function(t) {
  1016. y(t)
  1017. }).on("dragover", !1)
  1018. };
  1019. this.attach = function(t, e) {
  1020. t.editable.on("keydown", g), t.editable.on("mousedown", k), t.editable.on("keyup mouseup", w), t.editable.on("scroll", C), I(t), t.handle.on("mousedown", x), t.toolbar.on("click", S), t.popover.on("click", S), t.toolbar.on("mousedown", F), t.popover.on("mousedown", F), t.statusbar.on("mousedown", E);
  1021. var n = t.toolbar,
  1022. o = n.find(".note-dimension-picker-mousecatcher");
  1023. o.on("mousemove", z), t.editable.on("blur", function() {
  1024. a.saveRange(t.editable)
  1025. }), e.onenter && t.editable.keypress(function(t) {
  1026. t.keyCode === v.ENTER && e.onenter(t)
  1027. }), e.onfocus && t.editable.focus(e.onfocus), e.onblur && t.editable.blur(e.onblur), e.onkeyup && t.editable.keyup(e.onkeyup), e.onkeydown && t.editable.keydown(e.onkeydown), t.editable.data("callbacks", {
  1028. onChange: e.onChange,
  1029. onAutoSave: e.onAutoSave,
  1030. onPasteBefore: e.onPasteBefore,
  1031. onPasteAfter: e.onPasteAfter,
  1032. onImageUpload: e.onImageUpload,
  1033. onImageUploadError: e.onImageUpload,
  1034. onFileUpload: e.onFileUpload,
  1035. onFileUploadError: e.onFileUpload
  1036. })
  1037. }, this.dettach = function(t) {
  1038. t.editable.off(), t.toolbar.off(), t.handle.off(), t.popover.off()
  1039. }
  1040. },
  1041. m = function() {
  1042. var e, a, o, r, l;
  1043. e = {
  1044. picture: function(t) {
  1045. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.image + '" data-event="showImageDialog" tabindex="-1"><i class="editor-picture icon-picture"></i></button>'
  1046. },
  1047. link: function(t) {
  1048. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.link.link + '" data-event="showLinkDialog" data-shortcut="Ctrl+K" data-mac-shortcut="⌘+K" tabindex="-1"><i class="editor-link icon-link"></i></button>'
  1049. },
  1050. video: function(t) {
  1051. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.video.video + '" data-event="showVideoDialog" tabindex="-1"><i class="editor-video icon-play"></i></button>'
  1052. },
  1053. table: function(t) {
  1054. return '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="' + t.table.table + '" data-toggle="dropdown" tabindex="-1"><i class="editor-table icon-table"></i></button><ul class="dropdown-menu animated flipInY"><div class="note-dimension-picker"><div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div><div class="note-dimension-picker-highlighted"></div><div class="note-dimension-picker-unhighlighted"></div></div><div class="note-dimension-display"> 1 x 1 </div></ul>'
  1055. },
  1056. style: function(t) {
  1057. return '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="' + t.style.style + '" data-toggle="dropdown" tabindex="-1"><i class="editor-text icon-magic"></i></span></button><ul class="dropdown-menu animated flipInY"><li><a data-event="formatBlock" data-value="p">' + t.style.normal + '</a></li><li><a data-event="formatBlock" data-value="blockquote"><blockquote>' + t.style.blockquote + '</blockquote></a></li><li><a data-event="formatBlock" data-value="pre">' + t.style.pre + '</a></li><li><a data-event="formatBlock" data-value="h1"><h1>' + t.style.h1 + '</h1></a></li><li><a data-event="formatBlock" data-value="h2"><h2>' + t.style.h2 + '</h2></a></li><li><a data-event="formatBlock" data-value="h3"><h3>' + t.style.h3 + '</h3></a></li><li><a data-event="formatBlock" data-value="h4"><h4>' + t.style.h4 + '</h4></a></li><li><a data-event="formatBlock" data-value="h5"><h5>' + t.style.h5 + '</h5></a></li><li><a data-event="formatBlock" data-value="h6"><h6>' + t.style.h6 + "</h6></a></li></ul>"
  1058. },
  1059. fontsize: function(t) {
  1060. return '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="' + t.font.size + '" tabindex="-1"><span class="note-current-fontsize">11</span></button><ul class="dropdown-menu animated flipInY"><li><a data-event="fontSize" data-value="8"><i class="fa fa-check icon-ok"></i> 8</a></li><li><a data-event="fontSize" data-value="9"><i class="fa fa-check icon-ok"></i> 9</a></li><li><a data-event="fontSize" data-value="10"><i class="fa fa-check icon-ok"></i> 10</a></li><li><a data-event="fontSize" data-value="11"><i class="fa fa-check icon-ok"></i> 11</a></li><li><a data-event="fontSize" data-value="12"><i class="fa fa-check icon-ok"></i> 12</a></li><li><a data-event="fontSize" data-value="14"><i class="fa fa-check icon-ok"></i> 14</a></li><li><a data-event="fontSize" data-value="18"><i class="fa fa-check icon-ok"></i> 18</a></li><li><a data-event="fontSize" data-value="24"><i class="fa fa-check icon-ok"></i> 24</a></li><li><a data-event="fontSize" data-value="36"><i class="fa fa-check icon-ok"></i> 36</a></li></ul>'
  1061. },
  1062. color: function(t) {
  1063. return '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="' + t.color.more + '" data-toggle="dropdown" tabindex="-1"><i class="editor-font icon-font"></i></button><ul class="dropdown-menu animated flipInY"><li><div class="btn-group"><div class="note-palette-title">' + t.color.background + '</div><div class="note-color-reset" data-event="backColor" data-value="inherit" title="' + t.color.transparent + '">' + t.color.setTransparent + '</div><div class="note-color-palette" data-target-event="backColor"></div></div><div class="btn-group"><div class="note-palette-title">' + t.color.foreground + '</div><div class="note-color-reset" data-event="foreColor" data-value="inherit" title="' + t.color.reset + '">' + t.color.resetToDefault + '</div><div class="note-color-palette" data-target-event="foreColor"></div></div></li></ul>'
  1064. },
  1065. bold: function(t) {
  1066. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.font.bold + '" data-shortcut="Ctrl+B" data-mac-shortcut="⌘+B" data-event="bold" tabindex="-1"><i class="editor-bold icon-bold"></i></button>'
  1067. },
  1068. italic: function(t) {
  1069. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.font.italic + '" data-shortcut="Ctrl+I" data-mac-shortcut="⌘+I" data-event="italic" tabindex="-1"><i class="editor-italic icon-italic"></i></button>'
  1070. },
  1071. underline: function(t) {
  1072. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.font.underline + '" data-shortcut="Ctrl+U" data-mac-shortcut="⌘+U" data-event="underline" tabindex="-1"><i class="editor-underline icon-underline"></i></button>'
  1073. },
  1074. clear: function(t) {
  1075. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.font.clear + '" data-shortcut="Ctrl+\\" data-mac-shortcut="⌘+\\" data-event="removeFormat" tabindex="-1"><i class="editor-unstyle icon-eraser"></i></button>'
  1076. },
  1077. ul: function(t) {
  1078. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.lists.unordered + '" data-shortcut="Ctrl+Shift+8" data-mac-shortcut="⌘+⇧+7" data-event="insertUnorderedList" tabindex="-1"><i class="editor-unlist icon-list-ul"></i></button>'
  1079. },
  1080. ol: function(t) {
  1081. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.lists.ordered + '" data-shortcut="Ctrl+Shift+7" data-mac-shortcut="⌘+⇧+8" data-event="insertOrderedList" tabindex="-1"><i class="editor-orderlist icon-list-ol"></i></button>'
  1082. },
  1083. paragraph: function(t) {
  1084. return '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="' + t.paragraph.paragraph + '" data-toggle="dropdown" tabindex="-1"><i class="editor-align icon-align-left"></i></button><ul class="dropdown-menu animated flipInY"><li><div class="note-align btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.paragraph.left + '" data-shortcut="Ctrl+Shift+L" data-mac-shortcut="⌘+⇧+L" data-event="justifyLeft" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.paragraph.center + '" data-shortcut="Ctrl+Shift+E" data-mac-shortcut="⌘+⇧+E" data-event="justifyCenter" tabindex="-1"><i class="fa fa-align-center icon-align-center"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.paragraph.right + '" data-shortcut="Ctrl+Shift+R" data-mac-shortcut="⌘+⇧+R" data-event="justifyRight" tabindex="-1"><i class="fa fa-align-right icon-align-right"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.paragraph.justify + '" data-shortcut="Ctrl+Shift+J" data-mac-shortcut="⌘+⇧+J" data-event="justifyFull" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"></i></button></div></li><li class="w-100 pull-left"><div class="note-list btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.paragraph.outdent + '" data-shortcut="Ctrl+[" data-mac-shortcut="⌘+[" data-event="outdent" tabindex="-1"><i class="fa fa-outdent icon-indent-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.paragraph.indent + '" data-shortcut="Ctrl+]" data-mac-shortcut="⌘+]" data-event="indent" tabindex="-1"><i class="fa fa-indent icon-indent-right"></i></button></li></ul>'
  1085. },
  1086. height: function(t) {
  1087. return '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="' + t.font.height + '" tabindex="-1"><i class="editor-line-height icon-text-height"></i></button><ul class="dropdown-menu animated flipInY"><li><a data-event="lineHeight" data-value="1.0"><i class="fa fa-check icon-ok"></i> 1.0</a></li><li><a data-event="lineHeight" data-value="1.2"><i class="fa fa-check icon-ok"></i> 1.2</a></li><li><a data-event="lineHeight" data-value="1.4"><i class="fa fa-check icon-ok"></i> 1.4</a></li><li><a data-event="lineHeight" data-value="1.5"><i class="fa fa-check icon-ok"></i> 1.5</a></li><li><a data-event="lineHeight" data-value="1.6"><i class="fa fa-check icon-ok"></i> 1.6</a></li><li><a data-event="lineHeight" data-value="1.8"><i class="fa fa-check icon-ok"></i> 1.8</a></li><li><a data-event="lineHeight" data-value="2.0"><i class="fa fa-check icon-ok"></i> 2.0</a></li><li><a data-event="lineHeight" data-value="3.0"><i class="fa fa-check icon-ok"></i> 3.0</a></li></ul>'
  1088. },
  1089. help: function(t) {
  1090. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.options.help + '" data-shortcut="Ctrl+/" data-mac-shortcut="⌘+/" data-event="showHelpDialog" tabindex="-1"><i class="editor-help icon-question"></i></button>'
  1091. },
  1092. fullscreen: function(t) {
  1093. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.options.fullscreen + '" data-event="fullscreen" tabindex="-1"><i class="editor-full-screen icon-fullscreen"></i></button>'
  1094. },
  1095. codeview: function(t) {
  1096. return '<button type="button" class="btn btn-default btn-sm btn-small" title="' + t.options.codeview + '" data-event="codeview" tabindex="-1"><i class="editor-code icon-code"></i></button>'
  1097. }
  1098. }, a = function(t) {
  1099. return '<div class="note-popover"><div class="note-link-popover popover bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-link-content"><a href="http://www.google.com" target="_blank">www.google.com</a>&nbsp;&nbsp;<div class="note-insert btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.link.edit + '" data-event="showLinkDialog" tabindex="-1"><i class="fa fa-edit icon-edit"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.link.unlink + '" data-event="unlink" tabindex="-1"><i class="fa fa-unlink icon-unlink"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.video.videoLink + '" data-event="showVideoDialog" tabindex="-1"><i class="fa fa-youtube-play icon-play"></i></button></div></div></div><div class="note-image-popover popover bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-image-content"><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.resizeFull + '" data-event="resize" data-value="1" tabindex="-1"><span class="note-fontsize-10">100%</span> </button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.resizeHalf + '" data-event="resize" data-value="0.5" tabindex="-1"><span class="note-fontsize-10">50%</span> </button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.resizeQuarter + '" data-event="resize" data-value="0.25" tabindex="-1"><span class="note-fontsize-10">25%</span> </button></div><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.floatLeft + '" data-event="floatMe" data-value="left" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.floatRight + '" data-event="floatMe" data-value="right" tabindex="-1"><i class="fa fa-align-right icon-align-right"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="' + t.image.floatNone + '" data-event="floatMe" data-value="none" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"></i></button></div></div></div></div>'
  1100. }, o = '<div class="note-handle"><div class="note-control-selection"><div class="note-control-selection-bg"></div><div class="note-control-holder note-control-nw"></div><div class="note-control-holder note-control-ne"></div><div class="note-control-holder note-control-sw"></div><div class="note-control-sizing note-control-se"></div><div class="note-control-selection-info"></div></div></div>';
  1101. var s = function(t) {
  1102. return '<table class="note-shortcut"><thead><tr><th></th><th>' + t.shortcut.textFormatting + "</th></tr></thead><tbody><tr><td>⌘ + B</td><td>" + t.font.bold + "</td></tr><tr><td>⌘ + I</td><td>" + t.font.italic + "</td></tr><tr><td>⌘ + U</td><td>" + t.font.underline + "</td></tr><tr><td>⌘ + ⇧ + S</td><td>" + t.font.strike + "</td></tr><tr><td>⌘ + \\</td><td>" + t.font.clear + "</td></tr></tr></tbody></table>"
  1103. },
  1104. c = function(t) {
  1105. return '<table class="note-shortcut"><thead><tr><th></th><th>' + t.shortcut.action + "</th></tr></thead><tbody><tr><td>⌘ + Z</td><td>" + t.history.undo + "</td></tr><tr><td>⌘ + ⇧ + Z</td><td>" + t.history.redo + "</td></tr><tr><td>⌘ + ]</td><td>" + t.paragraph.indent + "</td></tr><tr><td>⌘ + [</td><td>" + t.paragraph.outdent + "</td></tr><tr><td>⌘ + K</td><td>" + t.link.insert + "</td></tr><tr><td>⌘ + ENTER</td><td>" + t.hr.insert + "</td></tr></tbody></table>"
  1106. },
  1107. u = function(t) {
  1108. return '<table class="note-shortcut"><thead><tr><th></th><th>' + t.shortcut.paragraphFormatting + "</th></tr></thead><tbody><tr><td>⌘ + ⇧ + L</td><td>" + t.paragraph.left + "</td></tr><tr><td>⌘ + ⇧ + E</td><td>" + t.paragraph.center + "</td></tr><tr><td>⌘ + ⇧ + R</td><td>" + t.paragraph.right + "</td></tr><tr><td>⌘ + ⇧ + J</td><td>" + t.paragraph.justify + "</td></tr><tr><td>⌘ + ⇧ + NUM7</td><td>" + t.lists.ordered + "</td></tr><tr><td>⌘ + ⇧ + NUM8</td><td>" + t.lists.unordered + "</td></tr></tbody></table>"
  1109. },
  1110. f = function(t) {
  1111. return '<table class="note-shortcut"><thead><tr><th></th><th>' + t.shortcut.documentStyle + "</th></tr></thead><tbody><tr><td>⌘ + NUM0</td><td>" + t.style.normal + "</td></tr><tr><td>⌘ + NUM1</td><td>" + t.style.h1 + "</td></tr><tr><td>⌘ + NUM2</td><td>" + t.style.h2 + "</td></tr><tr><td>⌘ + NUM3</td><td>" + t.style.h3 + "</td></tr><tr><td>⌘ + NUM4</td><td>" + t.style.h4 + "</td></tr><tr><td>⌘ + NUM5</td><td>" + t.style.h5 + "</td></tr><tr><td>⌘ + NUM6</td><td>" + t.style.h6 + "</td></tr></tbody></table>"
  1112. },
  1113. h = function(t) {
  1114. return '<table class="note-shortcut-layout"><tbody><tr><td>' + c(t) + "</td><td>" + s(t) + "</td></tr><tr><td>" + f(t) + "</td><td>" + u(t) + "</td></tr></tbody></table>"
  1115. },
  1116. b = function(t) {
  1117. return t.replace(/⌘/g, "Ctrl").replace(/⇧/g, "Shift")
  1118. };
  1119. r = function(t) {
  1120. return '<div class="note-dialog"><div class="note-image-dialog modal" aria-hidden="false"><div class="modal-dialog animated bounceIn"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">×</button><h4 class="modal-title">' + t.image.insert + '</h4></div><div class="modal-body"><div class="row-fluid"><div class="m-b-5">' + t.image.selectFromFiles + '</div><div class="fileupload fileupload-new" data-provides="fileupload"><span class="btn btn-file btn-sm"><span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span><input class="note-image-input" type="file" name="files" accept="image/*" /></span><span class="fileupload-preview"></span><a href="#" class="close close-pic fileupload-exists" data-dismiss="fileupload"><i class="fa fa-times"></i></a></div><div class="m-b-5">' + t.image.url + '</div><input class="note-image-url form-control input-sm span12" type="text" /></div></div><div class="modal-footer"><button href="#" class="btn btn-primary note-image-btn disabled" disabled="disabled">' + t.image.insert + '</button></div></div></div></div><div class="note-link-dialog modal" aria-hidden="false"><div class="modal-dialog animated bounceIn"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">×</button><h4 class="modal-title">' + t.link.insert + '</h4></div><div class="modal-body"><div class="row-fluid"><div class="form-group"><label>' + t.link.textToDisplay + '</label><span class="note-link-text form-control input-xlarge uneditable-input" /></div><div class="form-group"><label>' + t.link.url + '</label><input class="note-link-url form-control span12" type="text" /></div></div></div><div class="modal-footer"><button href="#" class="btn btn-primary note-link-btn disabled" disabled="disabled">' + t.link.insert + '</button></div></div></div></div><div class="note-video-dialog modal" aria-hidden="false"><div class="modal-dialog animated bounceIn"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">×</button><h4 class="modal-title">' + t.video.insert + '</h4></div><div class="modal-body"><div class="row-fluid"><div class="form-group"><label>' + t.video.url + '</label>&nbsp;<small class="text-muted">' + t.video.providers + '</small><input class="note-video-url form-control span12" type="text" /></div></div></div><div class="modal-footer"><button href="#" class="btn btn-primary note-video-btn disabled" disabled="disabled">' + t.video.insert + '</button></div></div></div></div><div class="note-help-dialog modal" aria-hidden="false"><div class="modal-dialog animated bounceIn"><div class="modal-content"><div class="modal-body"><div class="modal-background"><a class="modal-close pull-right" aria-hidden="true" tabindex="-1">' + t.shortcut.close + '</a><div class="title">' + t.shortcut.shortcuts + "</div>" + (n.bMac ? h(t) : b(h(t))) + '</div></div></div></div></div>'
  1121. }, l = '<div class="note-resizebar"><div class="note-icon-bar"></div><div class="note-icon-bar"></div><div class="note-icon-bar"></div></div>';
  1122. var v = function(e, a) {
  1123. e.find("button").each(function(e, a) {
  1124. var o = t(a),
  1125. i = o.attr(n.bMac ? "data-mac-shortcut" : "data-shortcut");
  1126. i && o.attr("title", function(t, e) {
  1127. return e + " (" + i + ")"
  1128. })
  1129. }).tooltip({
  1130. container: "body",
  1131. placement: a || "top"
  1132. })
  1133. },
  1134. m = [
  1135. ["#000000", "#424242", "#636363", "#9C9C94", "#CEC6CE", "#EFEFEF", "#F7F7F7", "#FFFFFF"],
  1136. ["#FF0000", "#FF9C00", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#9C00FF", "#FF00FF"],
  1137. ["#F7C6CE", "#FFE7CE", "#FFEFC6", "#D6EFD6", "#CEDEE7", "#CEE7F7", "#D6D6E7", "#E7D6DE"],
  1138. ["#E79C9C", "#FFC69C", "#FFE79C", "#B5D6A5", "#A5C6CE", "#9CC6EF", "#B5A5D6", "#D6A5BD"],
  1139. ["#E76363", "#F7AD6B", "#FFD663", "#94BD7B", "#73A5AD", "#6BADDE", "#8C7BC6", "#C67BA5"],
  1140. ["#CE0000", "#E79439", "#EFC631", "#6BA54A", "#4A7B8C", "#3984C6", "#634AA5", "#A54A7B"],
  1141. ["#9C0000", "#B56308", "#BD9400", "#397B21", "#104A5A", "#085294", "#311873", "#731842"],
  1142. ["#630000", "#7B3900", "#846300", "#295218", "#083139", "#003163", "#21104A", "#4A1031"]
  1143. ],
  1144. g = function(e) {
  1145. e.find(".note-color-palette").each(function() {
  1146. for (var e = t(this), n = e.attr("data-target-event"), a = [], o = 0, i = m.length; i > o; o++) {
  1147. for (var r = m[o], l = [], s = 0, d = r.length; d > s; s++) {
  1148. var c = r[s];
  1149. l.push(['<button type="button" class="note-color-btn" style="background-color:', c, ';" data-event="', n, '" data-value="', c, '" title="', c, '" data-toggle="button" tabindex="-1"></button>'].join(""))
  1150. }
  1151. a.push("<div>" + l.join("") + "</div>")
  1152. }
  1153. e.html(a.join(""))
  1154. })
  1155. };
  1156. this.createLayout = function(n, s) {
  1157. var c = s.height,
  1158. u = s.tabsize,
  1159. f = s.toolbar,
  1160. h = t.summernote.lang[s.lang];
  1161. if (!n.next().hasClass("note-editor")) {
  1162. var b = t('<div class="note-editor tile m-b-0"></div>');
  1163. b.data("options", s), c > 0 && t('<div class="note-statusbar">' + l + "</div>").prependTo(b);
  1164. var m = t('<div class="note-editable overflow" contentEditable="true"></div>').prependTo(b);
  1165. c && (m.height(c), m.data("optionHeight", c)), u && m.data("tabsize", u), m.html(i.html(n) || i.emptyPara), m.data("NoteHistory", new d), t('<textarea class="note-codable"></textarea>').prependTo(b), setTimeout(function() {
  1166. document.execCommand("styleWithCSS", 0, !0)
  1167. });
  1168. for (var p = "", y = 0, k = f.length; k > y; y++) {
  1169. var w = f[y];
  1170. p += '<div class="note-' + w[0] + ' btn-group">';
  1171. for (var C = 0, x = w[1].length; x > C; C++) p += e[w[1][C]](h);
  1172. p += "</div>"
  1173. }
  1174. p = '<div class="note-toolbar btn-toolbar tile-title">' + p + "</div>";
  1175. var F = t(p).prependTo(b);
  1176. g(F), v(F, "bottom");
  1177. var S = t(a(h)).prependTo(b);
  1178. v(S), t(o).prependTo(b);
  1179. var A = t(r(h)).prependTo(b);
  1180. A.find("button.close, a.modal-close").click(function() {
  1181. t(this).closest(".modal").modal("hide")
  1182. }), t('<div class="note-dropzone"><div class="note-dropzone-message"></div></div>').prependTo(b), b.insertAfter(n), n.hide()
  1183. }
  1184. };
  1185. var p = this.layoutInfoFromHolder = function(t) {
  1186. var e = t.next();
  1187. if (e.hasClass("note-editor")) return {
  1188. editor: e,
  1189. dropzone: e.find(".note-dropzone"),
  1190. toolbar: e.find(".note-toolbar"),
  1191. editable: e.find(".note-editable"),
  1192. codable: e.find(".note-codable"),
  1193. statusbar: e.find(".note-statusbar"),
  1194. popover: e.find(".note-popover"),
  1195. handle: e.find(".note-handle"),
  1196. dialog: e.find(".note-dialog")
  1197. }
  1198. };
  1199. this.removeLayout = function(t) {
  1200. var e = p(t);
  1201. e && (t.html(e.editable.html()), e.editor.remove(), t.show())
  1202. }
  1203. },
  1204. g = new m,
  1205. p = new v;
  1206. t.summernote = t.summernote || {}, t.extend(t.summernote, {
  1207. version: "0.5.0",
  1208. lang: {
  1209. "en-US": {
  1210. font: {
  1211. bold: "\u52a0\u7c97",
  1212. italic: "\u659c\u4f53",
  1213. underline: "\u4e0b\u5212\u7ebf",
  1214. strike: "\u5220\u9664\u7ebf",
  1215. clear: "\u6e05\u9664\u6837\u5f0f",
  1216. height: "\u884c\u9ad8",
  1217. size: "\u5b57\u53f7"
  1218. },
  1219. image: {
  1220. image: "\u56fe\u7247",
  1221. insert: "\u63d2\u5165\u56fe\u7247",
  1222. resizeFull: "\u0031\u0030\u0030\u0025\u5c3a\u5bf8",
  1223. resizeHalf: "\u0035\u0030\u0025\u5c3a\u5bf8",
  1224. resizeQuarter: "\u0032\u0035\u0025\u5c3a\u5bf8",
  1225. floatLeft: "\u5de6\u6d6e\u52a8",
  1226. floatRight: "\u53f3\u6d6e\u52a8",
  1227. floatNone: "\u65e0\u6d6e\u52a8",
  1228. dragImageHere: "\u62d6\u52a8\u56fe\u7247\u5230\u8fd9\u91cc",
  1229. selectFromFiles: "\u4e0a\u4f20\u56fe\u7247",
  1230. url: "\u56fe\u7247\u5730\u5740"
  1231. },
  1232. link: {
  1233. link: "\u94fe\u63a5",
  1234. insert: "\u63d2\u5165\u94fe\u63a5",
  1235. unlink: "\u6e05\u9664\u94fe\u63a5",
  1236. edit: "\u7f16\u8f91",
  1237. textToDisplay: "\u663e\u793a\u6587\u672c",
  1238. url: "\u94fe\u63a5\u6307\u5411"
  1239. },
  1240. video: {
  1241. video: "\u89c6\u9891",
  1242. videoLink: "\u89c6\u9891\u5730\u5740",
  1243. insert: "\u63d2\u5165\u89c6\u9891",
  1244. url: "\u89c6\u9891\u5730\u5740",
  1245. providers: "\u0028\u5efa\u8bae\u4f7f\u7528\u4f18\u9177\uff0c\u571f\u8c46\uff0c\u7231\u5947\u827a\uff0c\u65b0\u6d6a\uff0c\u7f51\u6613\u7684\u5730\u5740\u0029"
  1246. },
  1247. table: {
  1248. table: "\u8868\u683c"
  1249. },
  1250. hr: {
  1251. insert: "\u63d2\u5165\u5206\u5272\u7ebf"
  1252. },
  1253. style: {
  1254. style: "\u6837\u5f0f",
  1255. normal: "Normal",
  1256. blockquote: "Quote",
  1257. pre: "Code",
  1258. h1: "Header 1",
  1259. h2: "Header 2",
  1260. h3: "Header 3",
  1261. h4: "Header 4",
  1262. h5: "Header 5",
  1263. h6: "Header 6"
  1264. },
  1265. lists: {
  1266. unordered: "\u65e0\u5e8f\u5217\u8868",
  1267. ordered: "\u6709\u5e8f\u5217\u8868"
  1268. },
  1269. options: {
  1270. help: "\u5e2e\u52a9",
  1271. fullscreen: "\u5168\u5c4f\u002f\u53d6\u6d88",
  1272. codeview: "\u4ee3\u7801\u6a21\u5f0f"
  1273. },
  1274. paragraph: {
  1275. paragraph: "\u6bb5\u843d\u683c\u5f0f",
  1276. outdent: "\u51cf\u5c11\u7f29\u8fdb",
  1277. indent: "\u589e\u52a0\u7f29\u8fdb",
  1278. left: "\u5de6\u5bf9\u9f50",
  1279. center: "\u5c45\u4e2d\u5bf9\u9f50",
  1280. right: "\u53f3\u5bf9\u9f50",
  1281. justify: "\u4e24\u7aef\u5bf9\u9f50"
  1282. },
  1283. color: {
  1284. recent: "Recent Color",
  1285. more: "\u989c\u8272",
  1286. background: "\u80cc\u666f\u989c\u8272",
  1287. foreground: "\u5b57\u4f53\u989c\u8272",
  1288. transparent: "\u900f\u660e",
  1289. setTransparent: "\u80cc\u666f\u900f\u660e",
  1290. reset: "\u91cd\u7f6e",
  1291. resetToDefault: "\u6062\u590d\u9ed8\u8ba4"
  1292. },
  1293. shortcut: {
  1294. shortcuts: "\u5feb\u6377\u952e",
  1295. close: "\u5173\u95ed",
  1296. textFormatting: "\u5b57\u4f53\u6837\u5f0f",
  1297. action: "\u529f\u80fd",
  1298. paragraphFormatting: "\u6bb5\u843d\u6a21\u5f0f",
  1299. documentStyle: "\u6587\u6863\u6837\u5f0f"
  1300. },
  1301. history: {
  1302. undo: "\u64a4\u9500",
  1303. redo: "\u53d6\u6d88\u64a4\u9500"
  1304. }
  1305. }
  1306. }
  1307. }), t.fn.extend({
  1308. summernote: function(e) {
  1309. if (e = t.extend({
  1310. toolbar: [
  1311. ["style", ["style"]],
  1312. ["font", ["bold", "italic", "underline", "clear"]],
  1313. ["fontsize", ["fontsize"]],
  1314. ["color", ["color"]],
  1315. ["para", ["ul", "ol", "paragraph"]],
  1316. ["height", ["height"]],
  1317. ["table", ["table"]],
  1318. ["insert", ["link", "picture", "video"]],
  1319. ["view", ["fullscreen", "codeview"]],
  1320. ["help", ["help"]]
  1321. ],
  1322. lang: "en-US"
  1323. }, e), this.each(function(n, a) {
  1324. var o = t(a);
  1325. g.createLayout(o, e);
  1326. var r = g.layoutInfoFromHolder(o);
  1327. p.attach(r, e), i.isTextarea(o[0]) && o.closest("form").submit(function() {
  1328. o.html(o.code())
  1329. })
  1330. }), this.first() && e.focus) {
  1331. var n = g.layoutInfoFromHolder(this.first());
  1332. n.editable.focus()
  1333. }
  1334. this.length > 0 && e.oninit && e.oninit()
  1335. },
  1336. code: function(e) {
  1337. if (void 0 === e) {
  1338. var a = this.first();
  1339. if (0 === a.length) return;
  1340. var o = g.layoutInfoFromHolder(a);
  1341. if (o && o.editable) {
  1342. var i = o.editor.hasClass("codeview");
  1343. return i && n.bCodeMirror && o.codable.data("cmEditor").save(), i ? o.codable.val() : o.editable.html()
  1344. }
  1345. return a.html()
  1346. }
  1347. this.each(function(n, a) {
  1348. var o = g.layoutInfoFromHolder(t(a));
  1349. o && o.editable && o.editable.html(e)
  1350. })
  1351. },
  1352. destroy: function() {
  1353. this.each(function(e, n) {
  1354. var a = t(n),
  1355. o = g.layoutInfoFromHolder(a);
  1356. o && o.editable && (p.dettach(o), g.removeLayout(a))
  1357. })
  1358. },
  1359. summernoteInner: function() {
  1360. return {
  1361. dom: i,
  1362. list: o,
  1363. func: a,
  1364. range: r
  1365. }
  1366. }
  1367. })
  1368. });