| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369 |
- !
- function(t) {
- "function" == typeof define && define.amd ? define(["jquery", "codemirror"], t) : t(window.jQuery, window.CodeMirror)
- }(function(t, e) {
- "function" != typeof Array.prototype.reduce && (Array.prototype.reduce = function(t, e) {
- var n, a, o = this.length >>> 0,
- i = !1;
- 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));
- if (!i) throw new TypeError("Reduce of empty array with no initial value");
- return a
- });
- var n = {
- bMac: navigator.appVersion.indexOf("Mac") > -1,
- bMSIE: navigator.userAgent.indexOf("MSIE") > -1,
- bFF: navigator.userAgent.indexOf("Firefox") > -1,
- bCodeMirror: !! e
- },
- a = function() {
- var t = function(t) {
- return function(e) {
- return t === e
- }
- },
- e = function(t, e) {
- return t === e
- },
- n = function() {
- return !1
- },
- a = function(t) {
- return function() {
- return !t.apply(t, arguments)
- }
- },
- o = function(t) {
- return t
- };
- return {
- eq: t,
- eq2: e,
- fail: n,
- not: a,
- self: o
- }
- }(),
- o = function() {
- var t = function(t) {
- return t[0]
- },
- e = function(t) {
- return t[t.length - 1]
- },
- n = function(t) {
- return t.slice(0, t.length - 1)
- },
- o = function(t) {
- return t.slice(1)
- },
- i = function(t, e) {
- return e = e || a.self, t.reduce(function(t, n) {
- return t + e(n)
- }, 0)
- },
- r = function(t) {
- for (var e = [], n = -1, a = t.length; ++n < a;) e[n] = t[n];
- return e
- },
- l = function(n, a) {
- if (0 === n.length) return [];
- var i = o(n);
- return i.reduce(function(t, n) {
- var o = e(t);
- return a(e(o), n) ? o[o.length] = n : t[t.length] = [n], t
- }, [
- [t(n)]
- ])
- },
- s = function(t) {
- for (var e = [], n = 0, a = t.length; a > n; n++) t[n] && e.push(t[n]);
- return e
- };
- return {
- head: t,
- last: e,
- initial: n,
- tail: o,
- sum: i,
- from: r,
- compact: s,
- clusterBy: l
- }
- }(),
- i = function() {
- var e = function(t) {
- return function(e) {
- return e && e.nodeName === t
- }
- },
- n = function(t) {
- return t && /^DIV|^P|^LI|^H[1-7]/.test(t.nodeName)
- },
- r = "<p><br/></p>",
- l = function(t) {
- return t && /^UL|^OL/.test(t.nodeName)
- },
- s = function(e) {
- return e && t(e).hasClass("note-editable")
- },
- d = function(e) {
- return e && t(e).hasClass("note-control-sizing")
- },
- c = function(t, e) {
- for (; t;) {
- if (e(t)) return t;
- t = t.parentNode
- }
- return null
- },
- u = function(t, e) {
- e = e || a.fail;
- var n = [];
- return c(t, function(t) {
- return n.push(t), e(t)
- }), n
- },
- f = function(e, n) {
- for (var a = u(e), o = n; o; o = o.parentNode) if (t.inArray(o, a) > -1) return o;
- return null
- },
- h = function(t, e) {
- var n = [],
- a = !1,
- o = !1,
- i = function(r) {
- if (r) {
- if (r === t && (a = !0), a && !o && n.push(r), r === e) return void(o = !0);
- for (var l = 0, s = r.childNodes.length; s > l; l++) i(r.childNodes[l])
- }
- };
- return i(f(t, e)), n
- },
- b = function(t, e) {
- e = e || a.fail;
- for (var n = []; t && (n.push(t), !e(t));) t = t.previousSibling;
- return n
- },
- v = function(t, e) {
- e = e || a.fail;
- for (var n = []; t && (n.push(t), !e(t));) t = t.nextSibling;
- return n
- },
- m = function(t, e) {
- var n = e.nextSibling,
- a = e.parentNode;
- return n ? a.insertBefore(t, n) : a.appendChild(t), t
- },
- g = function(e, n) {
- return t.each(n, function(t, n) {
- e.appendChild(n)
- }), e
- },
- p = e("#text"),
- y = function(t) {
- return p(t) ? t.nodeValue.length : t.childNodes.length
- },
- k = function(t) {
- for (var e = 0; t = t.previousSibling;) e += 1;
- return e
- },
- w = function(e, n) {
- var i = o.initial(u(n, a.eq(e)));
- return t.map(i, k).reverse()
- },
- C = function(t, e) {
- for (var n = t, a = 0, o = e.length; o > a; a++) n = n.childNodes[e[a]];
- return n
- },
- x = function(t, e) {
- if (0 === e) return t;
- if (e >= y(t)) return t.nextSibling;
- if (p(t)) return t.splitText(e);
- var n = t.childNodes[e];
- return t = m(t.cloneNode(!1), t), g(t, v(n))
- },
- F = function(t, e, n) {
- var o = u(e, a.eq(t));
- return 1 === o.length ? x(e, n) : o.reduce(function(t, a) {
- var o = a.cloneNode(!1);
- return m(o, a), t === e && (t = x(t, n)), g(o, v(t)), o
- })
- },
- S = function(t, e) {
- if (t && t.parentNode) {
- if (t.removeNode) return t.removeNode(e);
- var n = t.parentNode;
- if (!e) {
- var a, o, i = [];
- for (a = 0, o = t.childNodes.length; o > a; a++) i.push(t.childNodes[a]);
- for (a = 0, o = i.length; o > a; a++) n.insertBefore(i[a], t)
- }
- n.removeChild(t)
- }
- },
- A = function(t) {
- return i.isTextarea(t[0]) ? t.val() : t.html()
- };
- return {
- emptyPara: r,
- isText: p,
- isPara: n,
- isList: l,
- isEditable: s,
- isControlSizing: d,
- isAnchor: e("A"),
- isDiv: e("DIV"),
- isSpan: e("SPAN"),
- isB: e("B"),
- isU: e("U"),
- isS: e("S"),
- isI: e("I"),
- isImg: e("IMG"),
- isTextarea: e("TEXTAREA"),
- ancestor: c,
- listAncestor: u,
- listNext: v,
- listPrev: b,
- commonAncestor: f,
- listBetween: h,
- insertAfter: m,
- position: k,
- makeOffsetPath: w,
- fromOffsetPath: C,
- split: F,
- remove: S,
- html: A
- }
- }(),
- r = function() {
- var e = !! document.createRange,
- n = function(t, e) {
- var n, a, r = t.parentElement(),
- l = document.body.createTextRange(),
- s = o.from(r.childNodes);
- for (n = 0; n < s.length; n++) if (!i.isText(s[n])) {
- if (l.moveToElementText(s[n]), l.compareEndPoints("StartToStart", t) >= 0) break;
- a = s[n]
- }
- if (0 !== n && i.isText(s[n - 1])) {
- var d = document.body.createTextRange(),
- c = null;
- d.moveToElementText(a || r), d.collapse(!a), c = a ? a.nextSibling : r.firstChild;
- var u = t.duplicate();
- u.setEndPoint("StartToStart", d);
- for (var f = u.text.replace(/[\r\n]/g, "").length; f > c.nodeValue.length && c.nextSibling;) f -= c.nodeValue.length, c = c.nextSibling; {
- c.nodeValue
- }
- e && c.nextSibling && i.isText(c.nextSibling) && f === c.nodeValue.length && (f -= c.nodeValue.length, c = c.nextSibling), r = c, n = f
- }
- return {
- cont: r,
- offset: n
- }
- },
- r = function(t) {
- var e = function(t, n) {
- var r, l;
- if (i.isText(t)) {
- var s = i.listPrev(t, a.not(i.isText)),
- d = o.last(s).previousSibling;
- r = d || t.parentNode, n += o.sum(o.tail(s), i.length), l = !d
- } else {
- if (r = t.childNodes[n] || t, i.isText(r)) return e(r, n);
- n = 0, l = !1
- }
- return {
- cont: r,
- collapseToStart: l,
- offset: n
- }
- },
- n = document.body.createTextRange(),
- r = e(t.cont, t.offset);
- return n.moveToElementText(r.cont), n.collapse(r.collapseToStart), n.moveStart("character", r.offset), n
- },
- l = function(n, l, s, d) {
- this.sc = n, this.so = l, this.ec = s, this.eo = d;
- var c = function() {
- if (e) {
- var t = document.createRange();
- return t.setStart(n, l), t.setEnd(s, d), t
- }
- var a = r({
- cont: n,
- offset: l
- });
- return a.setEndPoint("EndToEnd", r({
- cont: s,
- offset: d
- })), a
- };
- this.select = function() {
- var t = c();
- if (e) {
- var n = document.getSelection();
- n.rangeCount > 0 && n.removeAllRanges(), n.addRange(t)
- } else t.select()
- }, this.listPara = function() {
- var e = i.listBetween(n, s),
- r = o.compact(t.map(e, function(t) {
- return i.ancestor(t, i.isPara)
- }));
- return t.map(o.clusterBy(r, a.eq2), o.head)
- };
- var u = function(t) {
- return function() {
- var e = i.ancestor(n, t);
- return e && e === i.ancestor(s, t)
- }
- };
- this.isOnEditable = u(i.isEditable), this.isOnList = u(i.isList), this.isOnAnchor = u(i.isAnchor), this.isCollapsed = function() {
- return n === s && l === d
- }, this.insertNode = function(t) {
- var n = c();
- e ? n.insertNode(t) : n.pasteHTML(t.outerHTML)
- }, this.toString = function() {
- var t = c();
- return e ? t.toString() : t.text
- }, this.bookmark = function(t) {
- return {
- s: {
- path: i.makeOffsetPath(t, n),
- offset: l
- },
- e: {
- path: i.makeOffsetPath(t, s),
- offset: d
- }
- }
- }
- };
- return {
- create: function(t, a, o, i) {
- if (0 === arguments.length) if (e) {
- var r = document.getSelection();
- if (0 === r.rangeCount) return null;
- var s = r.getRangeAt(0);
- t = s.startContainer, a = s.startOffset, o = s.endContainer, i = s.endOffset
- } else {
- var d = document.selection.createRange(),
- c = d.duplicate();
- c.collapse(!1);
- var u = d;
- u.collapse(!0);
- var f = n(u, !0),
- h = n(c, !1);
- t = f.cont, a = f.offset, o = h.cont, i = h.offset
- } else 2 === arguments.length && (o = t, i = a);
- return new l(t, a, o, i)
- },
- createFromBookmark: function(t, e) {
- var n = i.fromOffsetPath(t, e.s.path),
- a = e.s.offset,
- o = i.fromOffsetPath(t, e.e.path),
- r = e.e.offset;
- return new l(n, a, o, r)
- }
- }
- }(),
- l = function() {
- var e = function(e) {
- return t.Deferred(function(t) {
- var n = new FileReader;
- n.onload = function(e) {
- t.resolve(e.target.result)
- }, n.onerror = function() {
- t.reject(this)
- }, n.readAsDataURL(e)
- }).promise()
- },
- n = function(e) {
- return t.Deferred(function(t) {
- function n() {
- o(), t.resolve(i)
- }
- function a() {
- o(), t.reject(i)
- }
- function o() {
- i.onload = null, i.onerror = null, i.onabort = null
- }
- var i = new Image;
- i.onload = n, i.onerror = a, i.onabort = a, i.src = e
- }).promise()
- };
- return {
- readFile: e,
- loadImage: n
- }
- }(),
- s = function() {
- this.stylePara = function(e, n) {
- var a = e.listPara();
- t.each(a, function(e, a) {
- t.each(n, function(t, e) {
- a.style[t] = e
- })
- })
- }, this.current = function(e, n) {
- var a = t(i.isText(e.sc) ? e.sc.parentNode : e.sc),
- o = a.css(["font-size", "text-align", "list-style-type", "line-height"]) || {};
- 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()) {
- var r = ["circle", "disc", "disc-leading-zero", "square"],
- l = t.inArray(o["list-style-type"], r) > -1;
- o["list-style"] = l ? "unordered" : "ordered"
- } else o["list-style"] = "none";
- var s = i.ancestor(e.sc, i.isPara);
- if (s && s.style["line-height"]) o["line-height"] = s.style.lineHeight;
- else {
- var d = parseInt(o["line-height"]) / parseInt(o["font-size"]);
- o["line-height"] = d.toFixed(1)
- }
- 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
- }
- },
- d = function() {
- var t = [],
- e = [],
- n = function(t) {
- var e = t[0],
- n = r.create();
- return {
- contents: t.html(),
- bookmark: n.bookmark(e),
- scrollTop: t.scrollTop()
- }
- },
- a = function(t, e) {
- t.html(e.contents).scrollTop(e.scrollTop), r.createFromBookmark(t[0], e.bookmark).select()
- };
- this.undo = function(o) {
- var i = n(o);
- 0 !== t.length && (a(o, t.pop()), e.push(i))
- }, this.redo = function(o) {
- var i = n(o);
- 0 !== e.length && (a(o, e.pop()), t.push(i))
- }, this.recordUndo = function(a) {
- e = [], t.push(n(a))
- }
- },
- c = function() {
- this.saveRange = function(t) {
- t.data("range", r.create())
- }, this.restoreRange = function(t) {
- var e = t.data("range");
- e && e.select()
- };
- var e = new s;
- this.currentStyle = function(t) {
- var n = r.create();
- return n.isOnEditable() && e.current(n, t)
- }, this.tab = function(e) {
- a(e);
- var n = r.create(),
- o = new Array(e.data("tabsize") + 1).join(" ");
- n.insertNode(t('<span id="noteTab">' + o + "</span>")[0]);
- var l = t("#noteTab").removeAttr("id");
- n = r.create(l[0], 1), n.select(), i.remove(l[0])
- }, this.undo = function(t) {
- t.data("NoteHistory").undo(t)
- }, this.redo = function(t) {
- t.data("NoteHistory").redo(t)
- };
- for (var a = this.recordUndo = function(t) {
- t.data("NoteHistory").recordUndo(t)
- }, 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) {
- return function(e, n) {
- a(e), document.execCommand(t, !1, n)
- }
- }(o[d]);
- this.insertImage = function(e, n) {
- l.loadImage(n).done(function(o) {
- a(e);
- var i = t("<img>").attr("src", n);
- i.css("width", Math.min(e.width(), o.width)), r.create().insertNode(i[0])
- }).fail(function() {
- var t = e.data("callbacks");
- t.onImageUploadError && t.onImageUploadError()
- })
- }, this.insertVideo = function(e, n) {
- var a, o = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,
- i = n.match(o),
- l = /\/\/instagram.com\/p\/(.[a-zA-Z0-9]*)/,
- s = n.match(l),
- d = /\/\/vine.co\/v\/(.[a-zA-Z0-9]*)/,
- c = n.match(d),
- u = /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/,
- f = n.match(u),
- h = /.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/,
- b = n.match(h);
- if (i && 11 === i[2].length) {
- var v = i[2];
- a = t("<iframe>").attr("src", "http://www.youtube.com/embed/" + v).attr("width", "640").attr("height", "360")
- } 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"));
- a && (a.attr("frameborder", 0), r.create().insertNode(a[0]))
- }, this.formatBlock = function(t, e) {
- a(t), e = n.bMSIE ? "<" + e + ">" : e, document.execCommand("FormatBlock", !1, e)
- }, this.fontSize = function(t, e) {
- 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() {
- return "medium" === this.style.fontSize
- }).css("font-size", e + "px")
- }, this.lineHeight = function(t, n) {
- a(t), e.stylePara(r.create(), {
- lineHeight: n
- })
- }, this.unlink = function(t) {
- var e = r.create();
- if (e.isOnAnchor()) {
- a(t);
- var n = i.ancestor(e.sc, i.isAnchor);
- e = r.create(n, 0, n, 1), e.select(), document.execCommand("unlink")
- }
- }, this.setLinkDialog = function(e, o) {
- var l = r.create();
- if (l.isOnAnchor()) {
- var s = i.ancestor(l.sc, i.isAnchor);
- l = r.create(s, 0, s, 1)
- }
- o({
- range: l,
- text: l.toString(),
- url: l.isOnAnchor() ? i.ancestor(l.sc, i.isAnchor).href : ""
- }, function(o) {
- l.select(), a(e);
- var i;
- if (i = -1 !== o.indexOf("@") ? -1 !== o.indexOf(":") ? o : "mailto:" + o : -1 !== o.indexOf("://") ? o : "http://" + o, n.bMSIE && l.isCollapsed()) {
- l.insertNode(t('<A id="linkAnchor">' + o + "</A>")[0]);
- var s = t("#linkAnchor").removeAttr("id").attr("href", i);
- l = r.create(s[0], 0, s[0], 1), l.select()
- } else document.execCommand("createlink", !1, i)
- })
- }, this.setVideoDialog = function(t, e) {
- var n = r.create(),
- o = this;
- if (n.isOnAnchor()) {
- var l = i.ancestor(n.sc, i.isAnchor);
- n = r.create(l, 0, l, 1)
- }
- e({
- range: n,
- text: n.toString()
- }, function(e) {
- n.select(), a(t), o.insertVideo(t, e)
- })
- }, this.color = function(t, e) {
- var n = JSON.parse(e),
- o = n.foreColor,
- i = n.backColor;
- a(t), o && document.execCommand("foreColor", !1, o), i && document.execCommand("backColor", !1, i)
- }, this.insertTable = function(e, o) {
- a(e);
- for (var i, l = o.split("x"), s = l[0], d = l[1], c = [], u = n.bMSIE ? " " : "<br/>", f = 0; s > f; f++) c.push("<td>" + u + "</td>");
- i = c.join("");
- for (var h, b = [], v = 0; d > v; v++) b.push("<tr>" + i + "</tr>");
- h = b.join("");
- var m = '<table class="table table-bordered">' + h + "</table>";
- r.create().insertNode(t(m)[0])
- }, this.floatMe = function(t, e, n) {
- a(t), n.style.cssFloat = e
- }, this.resize = function(t, e, n) {
- a(t), n.style.width = t.width() * e + "px", n.style.height = ""
- }, this.resizeTo = function(t, e) {
- var n = t.y / t.x,
- a = e.data("ratio");
- e.css({
- width: a > n ? t.x : t.y / a,
- height: a > n ? t.x * a : t.y
- })
- }
- },
- u = function() {
- this.update = function(e, n) {
- var a = function(e, n) {
- e.find(".dropdown-menu li a").each(function() {
- var e = parseFloat(t(this).data("value")) === n;
- this.className = e ? "checked" : ""
- })
- },
- o = e.find(".note-fontsize");
- o.find(".note-current-fontsize").html(n["font-size"]), a(o, parseFloat(n["font-size"]));
- var i = e.find(".note-height");
- a(i, parseFloat(n["line-height"]));
- var r = function(t, n) {
- var a = e.find(t);
- a[n() ? "addClass" : "removeClass"]("active")
- };
- r('button[data-event="bold"]', function() {
- return "bold" === n["font-bold"]
- }), r('button[data-event="italic"]', function() {
- return "italic" === n["font-italic"]
- }), r('button[data-event="underline"]', function() {
- return "underline" === n["font-underline"]
- }), r('button[data-event="justifyLeft"]', function() {
- return "left" === n["text-align"] || "start" === n["text-align"]
- }), r('button[data-event="justifyCenter"]', function() {
- return "center" === n["text-align"]
- }), r('button[data-event="justifyRight"]', function() {
- return "right" === n["text-align"]
- }), r('button[data-event="justifyFull"]', function() {
- return "justify" === n["text-align"]
- }), r('button[data-event="insertUnorderedList"]', function() {
- return "unordered" === n["list-style"]
- }), r('button[data-event="insertOrderedList"]', function() {
- return "ordered" === n["list-style"]
- })
- }, this.updateRecentColor = function(e, n, a) {
- var o = t(e).closest(".note-color"),
- i = o.find(".note-recent-color"),
- r = JSON.parse(i.attr("data-value"));
- r[n] = a, i.attr("data-value", JSON.stringify(r));
- var l = "backColor" === n ? "background-color" : "color";
- i.find("i").css(l, a)
- }, this.updateFullscreen = function(t, e) {
- var n = t.find('button[data-event="fullscreen"]');
- n[e ? "addClass" : "removeClass"]("active")
- }, this.updateCodeview = function(t, e) {
- var n = t.find('button[data-event="codeview"]');
- n[e ? "addClass" : "removeClass"]("active")
- }, this.enable = function(t) {
- t.find("button").not('button[data-event="codeview"]').removeClass("disabled")
- }, this.disable = function(t) {
- t.find("button").not('button[data-event="codeview"]').addClass("disabled")
- }
- },
- f = function() {
- var e = function(e, n) {
- var a = t(n),
- o = a.position(),
- i = a.height();
- e.css({
- display: "block",
- left: o.left,
- top: o.top + i
- })
- };
- this.update = function(t, n) {
- var a = t.find(".note-link-popover"),
- o = t.find(".note-image-popover");
- if (n.anchor) {
- var i = a.find("a");
- i.attr("href", n.anchor.href).html(n.anchor.href), e(a, n.anchor)
- } else a.hide();
- n.image ? e(o, n.image) : o.hide()
- }, this.hide = function(t) {
- t.children().hide()
- }
- },
- h = function() {
- this.update = function(e, n) {
- var a = e.find(".note-control-selection");
- if (n.image) {
- var o = t(n.image),
- i = o.position(),
- r = {
- w: o.width(),
- h: o.height()
- };
- a.css({
- display: "block",
- left: i.left,
- top: i.top,
- width: r.w,
- height: r.h
- }).data("target", n.image);
- var l = r.w + "x" + r.h;
- a.find(".note-control-selection-info").text(l)
- } else a.hide()
- }, this.hide = function(t) {
- t.children().hide()
- }
- },
- b = function() {
- var e = function(t, e) {
- e ? t.removeClass("disabled").attr("disabled", !1) : t.addClass("disabled").attr("disabled", !0)
- };
- this.showImageDialog = function(n, a, o) {
- var i = n.find(".note-image-dialog"),
- r = n.find(".note-image-input"),
- l = n.find(".note-image-url"),
- s = n.find(".note-image-btn");
- i.on("shown.bs.modal", function() {
- r.on("change", function() {
- subimg(this), a(this.files), t(this).val(""), i.modal("hide")
- }), l.val("").keyup(function() {
- e(s, l.val())
- }).trigger("focus"), s.click(function(t) {
- i.modal("hide"), o(l.val()), t.preventDefault()
- })
- }).on("hidden.bs.modal", function() {
- r.off("change"), i.off("shown.bs.modal hidden.bs.modal"), l.off("keyup"), s.off("click")
- }).modal("show")
- }, this.showVideoDialog = function(t, n, a) {
- var o = t.find(".note-video-dialog"),
- i = o.find(".note-video-url"),
- r = o.find(".note-video-btn");
- o.on("shown.bs.modal", function() {
- i.val(n.text).keyup(function() {
- e(r, i.val())
- }).trigger("keyup").trigger("focus"), r.click(function(t) {
- o.modal("hide"), a(i.val()), t.preventDefault()
- })
- }).on("hidden.bs.modal", function() {
- i.off("keyup"), r.off("click"), o.off("show.bs.modal hidden.bs.modal")
- }).modal("show")
- }, this.showLinkDialog = function(t, n, a) {
- var o = t.find(".note-link-dialog"),
- i = o.find(".note-link-text"),
- r = o.find(".note-link-url"),
- l = o.find(".note-link-btn");
- o.on("shown.bs.modal", function() {
- i.html(n.text), r.val(n.url).keyup(function() {
- e(l, r.val()), n.text || i.html(r.val())
- }).trigger("focus"), l.click(function(t) {
- o.modal("hide"), a(r.val()), t.preventDefault()
- })
- }).on("hidden.bs.modal", function() {
- r.off("keyup"), l.off("click"), o.off("shown.bs.modal hidden.bs.modal")
- }).modal("show")
- }, this.showHelpDialog = function(t) {
- t.find(".note-help-dialog").modal("show")
- }
- function subimg(e) {
- console.log($(e).val());
- }
- },
- v = function() {
- var a = new c,
- o = new u,
- r = new f,
- s = new h,
- d = new b,
- v = {
- BACKSPACE: 8,
- TAB: 9,
- ENTER: 13,
- SPACE: 32,
- NUM0: 48,
- NUM1: 49,
- NUM6: 54,
- NUM7: 55,
- NUM8: 56,
- B: 66,
- E: 69,
- I: 73,
- J: 74,
- K: 75,
- L: 76,
- R: 82,
- S: 83,
- U: 85,
- Y: 89,
- Z: 90,
- SLASH: 191,
- LEFTBRACKET: 219,
- BACKSLACH: 220,
- RIGHTBRACKET: 221
- },
- m = function(e) {
- var n = t(e).closest(".note-editor");
- return {
- editor: function() {
- return n
- },
- toolbar: function() {
- return n.find(".note-toolbar")
- },
- editable: function() {
- return n.find(".note-editable")
- },
- codable: function() {
- return n.find(".note-codable")
- },
- statusbar: function() {
- return n.find(".note-statusbar")
- },
- popover: function() {
- return n.find(".note-popover")
- },
- handle: function() {
- return n.find(".note-handle")
- },
- dialog: function() {
- return n.find(".note-dialog")
- }
- }
- },
- g = function(t) {
- var e = n.bMac ? t.metaKey : t.ctrlKey,
- o = t.shiftKey,
- i = t.keyCode,
- r = e || o || i === v.TAB,
- l = r ? m(t.target) : null;
- if (i === v.TAB && l.editable().data("tabsize")) a.tab(l.editable());
- else if (e && (o && i === v.Z || i === v.Y)) a.redo(l.editable());
- else if (e && i === v.Z) a.undo(l.editable());
- else if (e && i === v.B) a.bold(l.editable());
- else if (e && i === v.I) a.italic(l.editable());
- else if (e && i === v.U) a.underline(l.editable());
- else if (e && o && i === v.S) a.strikethrough(l.editable());
- else if (e && i === v.BACKSLACH) a.removeFormat(l.editable());
- else if (e && i === v.K) l.editable(), a.setLinkDialog(l.editable(), function(t, e) {
- d.showLinkDialog(l.dialog(), t, e)
- });
- else if (e && i === v.SLASH) d.showHelpDialog(l.dialog());
- else if (e && o && i === v.L) a.justifyLeft(l.editable());
- else if (e && o && i === v.E) a.justifyCenter(l.editable());
- else if (e && o && i === v.R) a.justifyRight(l.editable());
- else if (e && o && i === v.J) a.justifyFull(l.editable());
- else if (e && o && i === v.NUM7) a.insertUnorderedList(l.editable());
- else if (e && o && i === v.NUM8) a.insertOrderedList(l.editable());
- else if (e && i === v.LEFTBRACKET) a.outdent(l.editable());
- else if (e && i === v.RIGHTBRACKET) a.indent(l.editable());
- else if (e && i === v.NUM0) a.formatBlock(l.editable(), "P");
- else if (e && v.NUM1 <= i && i <= v.NUM6) {
- var s = "H" + String.fromCharCode(i);
- a.formatBlock(l.editable(), s)
- } else {
- if (!e || i !== v.ENTER) return void((i === v.BACKSPACE || i === v.ENTER || i === v.SPACE) && a.recordUndo(m(t.target).editable()));
- a.insertHorizontalRule(l.editable())
- }
- t.preventDefault()
- },
- p = function(e, n) {
- var o = e.data("callbacks");
- a.restoreRange(e), o.onImageUpload ? o.onImageUpload(n, a, e) : t.each(n, function(t, n) {
- l.readFile(n).done(function(t) {
- a.insertImage(e, t)
- }).fail(function() {
- o.onImageUploadError && o.onImageUploadError()
- })
- })
- },
- y = function(t) {
- var e = t.originalEvent.dataTransfer;
- if (e && e.files) {
- var n = m(t.currentTarget || t.target);
- n.editable().focus(), p(n.editable(), e.files)
- }
- t.preventDefault()
- },
- k = function(t) {
- i.isImg(t.target) && t.preventDefault()
- },
- w = function(t) {
- var e = m(t.currentTarget || t.target),
- n = a.currentStyle(t.target);
- n && (o.update(e.toolbar(), n), r.update(e.popover(), n), s.update(e.handle(), n))
- },
- C = function(t) {
- var e = m(t.currentTarget || t.target);
- r.hide(e.popover()), s.hide(e.handle())
- },
- x = function(e) {
- if (i.isControlSizing(e.target)) {
- var n, o = m(e.target),
- l = o.handle(),
- d = o.popover(),
- c = o.editable(),
- u = o.editor(),
- f = l.find(".note-control-selection").data("target"),
- h = t(f),
- b = h.offset(),
- v = t(document).scrollTop();
- u.on("mousemove", function(t) {
- n = {
- x: t.clientX - b.left,
- y: t.clientY - (b.top - v)
- }, a.resizeTo(n, h), s.update(l, {
- image: f
- }), r.update(d, {
- image: f
- })
- }).on("mouseup", function() {
- u.off("mousemove").off("mouseup")
- }), h.data("ratio") || h.data("ratio", h.height() / h.width()), a.recordUndo(c), e.stopPropagation(), e.preventDefault()
- }
- },
- F = function(e) {
- var n = t(e.target).closest("[data-event]");
- n.length > 0 && e.preventDefault()
- },
- S = function(r) {
- var l = t(r.target).closest("[data-event]");
- if (l.length > 0) {
- var s, c = l.attr("data-event"),
- u = l.attr("data-value"),
- f = m(r.target),
- h = f.editor(),
- b = f.toolbar(),
- v = f.dialog(),
- g = f.editable(),
- y = f.codable();
- if (-1 !== t.inArray(c, ["resize", "floatMe"])) {
- var k = f.handle(),
- C = k.find(".note-control-selection");
- s = C.data("target")
- }
- if (a[c] && (g.trigger("focus"), a[c](g, u, s)), -1 !== t.inArray(c, ["backColor", "foreColor"])) o.updateRecentColor(l[0], c, u);
- else if ("showLinkDialog" === c) g.focus(), a.setLinkDialog(g, function(t, e) {
- d.showLinkDialog(v, t, e)
- });
- else if ("showImageDialog" === c) g.focus(), d.showImageDialog(v, function(t) {
- p(g, t)
- }, function(t) {
- a.restoreRange(g), a.insertImage(g, t)
- });
- else if ("showVideoDialog" === c) g.focus(), a.setVideoDialog(g, function(t, e) {
- d.showVideoDialog(v, t, e)
- });
- else if ("showHelpDialog" === c) d.showHelpDialog(v);
- else if ("fullscreen" === c) {
- h.toggleClass("fullscreen");
- var x = function() {
- var e = t(window).height() - b.outerHeight();
- g.css("height", e)
- },
- F = h.hasClass("fullscreen");
- if (F) g.data("orgHeight", g.css("height")), t(window).resize(x).trigger("resize");
- else {
- var S = !! g.data("optionHeight");
- g.css("height", S ? g.data("orgHeight") : "auto"), t(window).off("resize")
- }
- o.updateFullscreen(b, F)
- } else if ("codeview" === c) {
- h.toggleClass("codeview");
- var A = h.hasClass("codeview");
- if (A) {
- if (y.val(g.html()), y.height(g.height()), o.disable(b), y.focus(), n.bCodeMirror) {
- var E = e.fromTextArea(y[0], t.extend({
- mode: "text/html",
- lineNumbers: !0
- }, h.data("options").codemirror));
- E.setSize(null, g.outerHeight()), E.autoFormatRange && E.autoFormatRange({
- line: 0,
- ch: 0
- }, {
- line: E.lineCount(),
- ch: E.getTextArea().value.length
- }), y.data("cmEditor", E)
- }
- } 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();
- o.updateCodeview(f.toolbar(), A)
- }
- w(r)
- }
- },
- A = 24,
- E = function(e) {
- var n = t(document),
- a = m(e.target),
- o = a.editable(),
- i = o.offset().top - n.scrollTop(),
- r = function(t) {
- o.height(t.clientY - (i + A))
- },
- l = function() {
- n.unbind("mousemove", r).unbind("mouseup", l)
- };
- n.mousemove(r).mouseup(l), e.stopPropagation(), e.preventDefault()
- },
- T = 18,
- z = function(e) {
- var n, a = t(e.target.parentNode),
- o = a.next(),
- i = a.find(".note-dimension-picker-mousecatcher"),
- r = a.find(".note-dimension-picker-highlighted"),
- l = a.find(".note-dimension-picker-unhighlighted");
- if (void 0 === e.offsetX) {
- var s = t(e.target).offset();
- n = {
- x: e.pageX - s.left,
- y: e.pageY - s.top
- }
- } else n = {
- x: e.offsetX,
- y: e.offsetY
- };
- var d = {
- c: Math.ceil(n.x / T) || 1,
- r: Math.ceil(n.y / T) || 1
- };
- r.css({
- width: d.c + "em",
- height: d.r + "em"
- }), i.attr("data-value", d.c + "x" + d.r), 3 < d.c && d.c < 10 && l.css({
- width: d.c + 1 + "em"
- }), 3 < d.r && d.r < 10 && l.css({
- height: d.r + 1 + "em"
- }), o.html(d.c + " x " + d.r)
- },
- I = function(e) {
- var n = t(),
- a = e.dropzone,
- o = e.dropzone.find(".note-dropzone-message");
- t(document).on("dragenter", function(t) {
- var i = e.editor.hasClass("codeview");
- 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)
- }).on("dragleave", function(t) {
- n = n.not(t.target), 0 === n.length && e.editor.removeClass("dragover")
- }).on("drop", function() {
- n = t(), e.editor.removeClass("dragover")
- }), a.on("dragenter", function() {
- a.addClass("hover"), o.text("Drop Image")
- }).on("dragleave", function() {
- a.removeClass("hover"), o.text("Drag Image Here")
- }), a.on("drop", function(t) {
- y(t)
- }).on("dragover", !1)
- };
- this.attach = function(t, e) {
- 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);
- var n = t.toolbar,
- o = n.find(".note-dimension-picker-mousecatcher");
- o.on("mousemove", z), t.editable.on("blur", function() {
- a.saveRange(t.editable)
- }), e.onenter && t.editable.keypress(function(t) {
- t.keyCode === v.ENTER && e.onenter(t)
- }), 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", {
- onChange: e.onChange,
- onAutoSave: e.onAutoSave,
- onPasteBefore: e.onPasteBefore,
- onPasteAfter: e.onPasteAfter,
- onImageUpload: e.onImageUpload,
- onImageUploadError: e.onImageUpload,
- onFileUpload: e.onFileUpload,
- onFileUploadError: e.onFileUpload
- })
- }, this.dettach = function(t) {
- t.editable.off(), t.toolbar.off(), t.handle.off(), t.popover.off()
- }
- },
- m = function() {
- var e, a, o, r, l;
- e = {
- picture: function(t) {
- 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>'
- },
- link: function(t) {
- 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>'
- },
- video: function(t) {
- 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>'
- },
- table: function(t) {
- 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>'
- },
- style: function(t) {
- 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>"
- },
- fontsize: function(t) {
- 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>'
- },
- color: function(t) {
- 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>'
- },
- bold: function(t) {
- 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>'
- },
- italic: function(t) {
- 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>'
- },
- underline: function(t) {
- 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>'
- },
- clear: function(t) {
- 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>'
- },
- ul: function(t) {
- 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>'
- },
- ol: function(t) {
- 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>'
- },
- paragraph: function(t) {
- 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>'
- },
- height: function(t) {
- 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>'
- },
- help: function(t) {
- 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>'
- },
- fullscreen: function(t) {
- 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>'
- },
- codeview: function(t) {
- 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>'
- }
- }, a = function(t) {
- 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> <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>'
- }, 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>';
- var s = function(t) {
- 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>"
- },
- c = function(t) {
- 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>"
- },
- u = function(t) {
- 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>"
- },
- f = function(t) {
- 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>"
- },
- h = function(t) {
- 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>"
- },
- b = function(t) {
- return t.replace(/⌘/g, "Ctrl").replace(/⇧/g, "Shift")
- };
- r = function(t) {
- 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> <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>'
- }, l = '<div class="note-resizebar"><div class="note-icon-bar"></div><div class="note-icon-bar"></div><div class="note-icon-bar"></div></div>';
- var v = function(e, a) {
- e.find("button").each(function(e, a) {
- var o = t(a),
- i = o.attr(n.bMac ? "data-mac-shortcut" : "data-shortcut");
- i && o.attr("title", function(t, e) {
- return e + " (" + i + ")"
- })
- }).tooltip({
- container: "body",
- placement: a || "top"
- })
- },
- m = [
- ["#000000", "#424242", "#636363", "#9C9C94", "#CEC6CE", "#EFEFEF", "#F7F7F7", "#FFFFFF"],
- ["#FF0000", "#FF9C00", "#FFFF00", "#00FF00", "#00FFFF", "#0000FF", "#9C00FF", "#FF00FF"],
- ["#F7C6CE", "#FFE7CE", "#FFEFC6", "#D6EFD6", "#CEDEE7", "#CEE7F7", "#D6D6E7", "#E7D6DE"],
- ["#E79C9C", "#FFC69C", "#FFE79C", "#B5D6A5", "#A5C6CE", "#9CC6EF", "#B5A5D6", "#D6A5BD"],
- ["#E76363", "#F7AD6B", "#FFD663", "#94BD7B", "#73A5AD", "#6BADDE", "#8C7BC6", "#C67BA5"],
- ["#CE0000", "#E79439", "#EFC631", "#6BA54A", "#4A7B8C", "#3984C6", "#634AA5", "#A54A7B"],
- ["#9C0000", "#B56308", "#BD9400", "#397B21", "#104A5A", "#085294", "#311873", "#731842"],
- ["#630000", "#7B3900", "#846300", "#295218", "#083139", "#003163", "#21104A", "#4A1031"]
- ],
- g = function(e) {
- e.find(".note-color-palette").each(function() {
- for (var e = t(this), n = e.attr("data-target-event"), a = [], o = 0, i = m.length; i > o; o++) {
- for (var r = m[o], l = [], s = 0, d = r.length; d > s; s++) {
- var c = r[s];
- 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(""))
- }
- a.push("<div>" + l.join("") + "</div>")
- }
- e.html(a.join(""))
- })
- };
- this.createLayout = function(n, s) {
- var c = s.height,
- u = s.tabsize,
- f = s.toolbar,
- h = t.summernote.lang[s.lang];
- if (!n.next().hasClass("note-editor")) {
- var b = t('<div class="note-editor tile m-b-0"></div>');
- b.data("options", s), c > 0 && t('<div class="note-statusbar">' + l + "</div>").prependTo(b);
- var m = t('<div class="note-editable overflow" contentEditable="true"></div>').prependTo(b);
- 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() {
- document.execCommand("styleWithCSS", 0, !0)
- });
- for (var p = "", y = 0, k = f.length; k > y; y++) {
- var w = f[y];
- p += '<div class="note-' + w[0] + ' btn-group">';
- for (var C = 0, x = w[1].length; x > C; C++) p += e[w[1][C]](h);
- p += "</div>"
- }
- p = '<div class="note-toolbar btn-toolbar tile-title">' + p + "</div>";
- var F = t(p).prependTo(b);
- g(F), v(F, "bottom");
- var S = t(a(h)).prependTo(b);
- v(S), t(o).prependTo(b);
- var A = t(r(h)).prependTo(b);
- A.find("button.close, a.modal-close").click(function() {
- t(this).closest(".modal").modal("hide")
- }), t('<div class="note-dropzone"><div class="note-dropzone-message"></div></div>').prependTo(b), b.insertAfter(n), n.hide()
- }
- };
- var p = this.layoutInfoFromHolder = function(t) {
- var e = t.next();
- if (e.hasClass("note-editor")) return {
- editor: e,
- dropzone: e.find(".note-dropzone"),
- toolbar: e.find(".note-toolbar"),
- editable: e.find(".note-editable"),
- codable: e.find(".note-codable"),
- statusbar: e.find(".note-statusbar"),
- popover: e.find(".note-popover"),
- handle: e.find(".note-handle"),
- dialog: e.find(".note-dialog")
- }
- };
- this.removeLayout = function(t) {
- var e = p(t);
- e && (t.html(e.editable.html()), e.editor.remove(), t.show())
- }
- },
- g = new m,
- p = new v;
- t.summernote = t.summernote || {}, t.extend(t.summernote, {
- version: "0.5.0",
- lang: {
- "en-US": {
- font: {
- bold: "\u52a0\u7c97",
- italic: "\u659c\u4f53",
- underline: "\u4e0b\u5212\u7ebf",
- strike: "\u5220\u9664\u7ebf",
- clear: "\u6e05\u9664\u6837\u5f0f",
- height: "\u884c\u9ad8",
- size: "\u5b57\u53f7"
- },
- image: {
- image: "\u56fe\u7247",
- insert: "\u63d2\u5165\u56fe\u7247",
- resizeFull: "\u0031\u0030\u0030\u0025\u5c3a\u5bf8",
- resizeHalf: "\u0035\u0030\u0025\u5c3a\u5bf8",
- resizeQuarter: "\u0032\u0035\u0025\u5c3a\u5bf8",
- floatLeft: "\u5de6\u6d6e\u52a8",
- floatRight: "\u53f3\u6d6e\u52a8",
- floatNone: "\u65e0\u6d6e\u52a8",
- dragImageHere: "\u62d6\u52a8\u56fe\u7247\u5230\u8fd9\u91cc",
- selectFromFiles: "\u4e0a\u4f20\u56fe\u7247",
- url: "\u56fe\u7247\u5730\u5740"
- },
- link: {
- link: "\u94fe\u63a5",
- insert: "\u63d2\u5165\u94fe\u63a5",
- unlink: "\u6e05\u9664\u94fe\u63a5",
- edit: "\u7f16\u8f91",
- textToDisplay: "\u663e\u793a\u6587\u672c",
- url: "\u94fe\u63a5\u6307\u5411"
- },
- video: {
- video: "\u89c6\u9891",
- videoLink: "\u89c6\u9891\u5730\u5740",
- insert: "\u63d2\u5165\u89c6\u9891",
- url: "\u89c6\u9891\u5730\u5740",
- 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"
- },
- table: {
- table: "\u8868\u683c"
- },
- hr: {
- insert: "\u63d2\u5165\u5206\u5272\u7ebf"
- },
- style: {
- style: "\u6837\u5f0f",
- normal: "Normal",
- blockquote: "Quote",
- pre: "Code",
- h1: "Header 1",
- h2: "Header 2",
- h3: "Header 3",
- h4: "Header 4",
- h5: "Header 5",
- h6: "Header 6"
- },
- lists: {
- unordered: "\u65e0\u5e8f\u5217\u8868",
- ordered: "\u6709\u5e8f\u5217\u8868"
- },
- options: {
- help: "\u5e2e\u52a9",
- fullscreen: "\u5168\u5c4f\u002f\u53d6\u6d88",
- codeview: "\u4ee3\u7801\u6a21\u5f0f"
- },
- paragraph: {
- paragraph: "\u6bb5\u843d\u683c\u5f0f",
- outdent: "\u51cf\u5c11\u7f29\u8fdb",
- indent: "\u589e\u52a0\u7f29\u8fdb",
- left: "\u5de6\u5bf9\u9f50",
- center: "\u5c45\u4e2d\u5bf9\u9f50",
- right: "\u53f3\u5bf9\u9f50",
- justify: "\u4e24\u7aef\u5bf9\u9f50"
- },
- color: {
- recent: "Recent Color",
- more: "\u989c\u8272",
- background: "\u80cc\u666f\u989c\u8272",
- foreground: "\u5b57\u4f53\u989c\u8272",
- transparent: "\u900f\u660e",
- setTransparent: "\u80cc\u666f\u900f\u660e",
- reset: "\u91cd\u7f6e",
- resetToDefault: "\u6062\u590d\u9ed8\u8ba4"
- },
- shortcut: {
- shortcuts: "\u5feb\u6377\u952e",
- close: "\u5173\u95ed",
- textFormatting: "\u5b57\u4f53\u6837\u5f0f",
- action: "\u529f\u80fd",
- paragraphFormatting: "\u6bb5\u843d\u6a21\u5f0f",
- documentStyle: "\u6587\u6863\u6837\u5f0f"
- },
- history: {
- undo: "\u64a4\u9500",
- redo: "\u53d6\u6d88\u64a4\u9500"
- }
- }
- }
- }), t.fn.extend({
- summernote: function(e) {
- if (e = t.extend({
- toolbar: [
- ["style", ["style"]],
- ["font", ["bold", "italic", "underline", "clear"]],
- ["fontsize", ["fontsize"]],
- ["color", ["color"]],
- ["para", ["ul", "ol", "paragraph"]],
- ["height", ["height"]],
- ["table", ["table"]],
- ["insert", ["link", "picture", "video"]],
- ["view", ["fullscreen", "codeview"]],
- ["help", ["help"]]
- ],
- lang: "en-US"
- }, e), this.each(function(n, a) {
- var o = t(a);
- g.createLayout(o, e);
- var r = g.layoutInfoFromHolder(o);
- p.attach(r, e), i.isTextarea(o[0]) && o.closest("form").submit(function() {
- o.html(o.code())
- })
- }), this.first() && e.focus) {
- var n = g.layoutInfoFromHolder(this.first());
- n.editable.focus()
- }
- this.length > 0 && e.oninit && e.oninit()
- },
- code: function(e) {
- if (void 0 === e) {
- var a = this.first();
- if (0 === a.length) return;
- var o = g.layoutInfoFromHolder(a);
- if (o && o.editable) {
- var i = o.editor.hasClass("codeview");
- return i && n.bCodeMirror && o.codable.data("cmEditor").save(), i ? o.codable.val() : o.editable.html()
- }
- return a.html()
- }
- this.each(function(n, a) {
- var o = g.layoutInfoFromHolder(t(a));
- o && o.editable && o.editable.html(e)
- })
- },
- destroy: function() {
- this.each(function(e, n) {
- var a = t(n),
- o = g.layoutInfoFromHolder(a);
- o && o.editable && (p.dettach(o), g.removeLayout(a))
- })
- },
- summernoteInner: function() {
- return {
- dom: i,
- list: o,
- func: a,
- range: r
- }
- }
- })
- });
|