text: (function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X={}.hasOwnProperty,Y=function(a,b){function c(){this.constructor=a}for(var d in b)X.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},Z=[].slice,_=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};t=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.sel=document.getSelection(),this.editor=this.widget}return Y(b,a),b.className="Selection",b.prototype._init=function(){},b.prototype.clear=function(){var a;try{return this.sel.removeAllRanges()}catch(b){a=b}},b.prototype.getRange=function(){return this.editor.inputManager.focused&&this.sel.rangeCount?this.sel.getRangeAt(0):null},b.prototype.selectRange=function(a){return this.clear(),this.sel.addRange(a),this.editor.inputManager.focused||!this.editor.util.browser.firefox&&!this.editor.util.browser.msie?void 0:this.editor.body.focus()},b.prototype.rangeAtEndOf=function(a,b){var c,d,e;return null==b&&(b=this.getRange()),null!=b&&b.collapsed?(a=$(a)[0],c=b.endContainer,d=this.editor.util.getNodeLength(c),b.endOffset===d-1&&$(c).contents().last().is("br")||b.endOffset===d?a===c?!0:$.contains(a,c)?(e=!0,$(c).parentsUntil(a).addBack().each(function(a,b){var c,d;return d=$(b).parent().contents().filter(function(){return!(this!==b&&3===this.nodeType&&!this.nodeValue)}),c=d.last(),c.get(0)===b||c.is("br")&&c.prev().get(0)===b?void 0:(e=!1,!1)}),e):!1:!1):void 0},b.prototype.rangeAtStartOf=function(a,b){var c,d;return null==b&&(b=this.getRange()),null!=b&&b.collapsed?(a=$(a)[0],d=b.startContainer,0!==b.startOffset?!1:a===d?!0:$.contains(a,d)?(c=!0,$(d).parentsUntil(a).addBack().each(function(a,b){var d;return d=$(b).parent().contents().filter(function(){return!(this!==b&&3===this.nodeType&&!this.nodeValue)}),d.first().get(0)!==b?c=!1:void 0}),c):!1):void 0},b.prototype.insertNode=function(a,b){return null==b&&(b=this.getRange()),null!=b?(a=$(a)[0],b.insertNode(a),this.setRangeAfter(a,b)):void 0},b.prototype.setRangeAfter=function(a,b){return null==b&&(b=this.getRange()),null!=b?(a=$(a)[0],b.setEndAfter(a),b.collapse(!1),this.selectRange(b)):void 0},b.prototype.setRangeBefore=function(a,b){return null==b&&(b=this.getRange()),null!=b?(a=$(a)[0],b.setEndBefore(a),b.collapse(!1),this.selectRange(b)):void 0},b.prototype.setRangeAtStartOf=function(a,b){return null==b&&(b=this.getRange()),a=$(a).get(0),b.setEnd(a,0),b.collapse(!1),this.selectRange(b)},b.prototype.setRangeAtEndOf=function(a,b){var c,d,e,f,g;return null==b&&(b=this.getRange()),c=$(a),a=c.get(0),c.is("pre")?(d=c.contents(),d.length>0?(e=d.last(),f=e.text(),"\n"===f.charAt(f.length-1)?b.setEnd(e[0],this.editor.util.getNodeLength(e[0])-1):b.setEnd(e[0],this.editor.util.getNodeLength(e[0]))):b.setEnd(a,0)):(g=this.editor.util.getNodeLength(a),3!==a.nodeType&&g>0&&$(a).contents().last().is("br")&&(g-=1),b.setEnd(a,g)),b.collapse(!1),this.selectRange(b)},b.prototype.deleteRangeContents=function(a){var b,c;return null==a&&(a=this.getRange()),c=a.cloneRange(),b=a.cloneRange(),c.collapse(!0),b.collapse(),!a.collapsed&&this.rangeAtStartOf(this.editor.body,c)&&this.rangeAtEndOf(this.editor.body,b)?(this.editor.body.empty(),a.setStart(this.editor.body[0],0),a.collapse(!0),this.selectRange(a)):a.deleteContents(),a},b.prototype.breakBlockEl=function(a,b){var c;return null==b&&(b=this.getRange()),c=$(a),b.collapsed?(b.setStartBefore(c.get(0)),b.collapsed?c:c.before(b.extractContents())):c},b.prototype.save=function(a){var b,c;return null==a&&(a=this.getRange()),this._selectionSaved?void 0:(c=$("<span/>").addClass("simditor-caret-start"),b=$("<span/>").addClass("simditor-caret-end"),a.insertNode(c[0]),a.collapse(!1),a.insertNode(b[0]),this.clear(),this._selectionSaved=!0)},b.prototype.restore=function(){var a,b,c,d,e,f,g;return this._selectionSaved?(e=this.editor.body.find(".simditor-caret-start"),a=this.editor.body.find(".simditor-caret-end"),e.length&&a.length?(f=e.parent(),g=f.contents().index(e),b=a.parent(),c=b.contents().index(a),f[0]===b[0]&&(c-=1),d=document.createRange(),d.setStart(f.get(0),g),d.setEnd(b.get(0),c),e.remove(),a.remove(),this.selectRange(d)):(e.remove(),a.remove()),this._selectionSaved=!1,d):!1},b}(Plugin),f=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.editor=this.widget}return Y(b,a),b.className="Formatter",b.prototype._init=function(){return this.editor.body.on("click","a",function(){return!1})},b.prototype._allowedTags=["br","a","img","b","strong","i","u","p","ul","ol","li","blockquote","pre","h1","h2","h3","h4","hr"],b.prototype._allowedAttributes={img:["src","alt","width","height","data-image-src","data-image-size","data-image-name","data-non-image"],a:["href","target"],pre:["data-lang","class"],p:["data-indent"],h1:["data-indent"],h2:["data-indent"],h3:["data-indent"],h4:["data-indent"]},b.prototype.decorate=function(a){return null==a&&(a=this.editor.body),this.editor.trigger("decorate",[a])},b.prototype.undecorate=function(a){return null==a&&(a=this.editor.body.clone()),this.editor.trigger("undecorate",[a]),$.trim(a.html())},b.prototype.autolink=function(a){var b,c,d,e,f,g,h,i,j,k,l;for(null==a&&(a=this.editor.body),e=[],c=function(b){return b.contents().each(function(b,d){var f,g;return f=$(d),f.is("a")||f.closest("a",a).length?void 0:f.contents().length?c(f):(g=f.text())&&/https?:\/\/|www\./gi.test(g)?e.push(f):void 0})},c(a),g=/(https?:\/\/|www\.)[\w\-\.\?&=\/#%:\!]+/gi,k=0,l=e.length;l>k;k++){for(b=e[k],i=b.text(),h=[],f=null,d=0;null!==(f=g.exec(i));)h.push(document.createTextNode(i.substring(d,f.index))),d=g.lastIndex,j=/^(http(s)?:\/\/|\/)/.test(f[0])?f[0]:"http://"+f[0],h.push($('<a href="'+j+'" rel="nofollow">'+f[0]+"</a>")[0]);h.push(document.createTextNode(i.substring(d))),b.replaceWith($(h))}return a},b.prototype.format=function(a){var b,c,d,e,f,g,h,i,j,k;if(null==a&&(a=this.editor.body),a.is(":empty"))return a.append("<p>"+this.editor.util.phBr+"</p>"),a;for(j=a.contents(),f=0,h=j.length;h>f;f++)d=j[f],this.cleanNode(d,!0);for(k=a.contents(),g=0,i=k.length;i>g;g++)e=k[g],b=$(e),b.is("br")?("undefined"!=typeof c&&null!==c&&(c=null),b.remove()):this.editor.util.isBlockNode(e)?b.is("li")?c&&c.is("ul, ol")?c.append(e):(c=$("<ul/>").insertBefore(e),c.append(e)):c=null:((!c||c.is("ul, ol"))&&(c=$("<p/>").insertBefore(e)),c.append(e));return a},b.prototype.cleanNode=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(c=$(a),3===c[0].nodeType)return k=c.text().replace(/(\r\n|\n|\r)/gm,""),void(k?(l=document.createTextNode(k),c.replaceWith(l)):c.remove());if(h=c.contents(),i=c.is('[class^="simditor-"]'),c.is(this._allowedTags.join(","))||i){if(c.is("a")&&c.find("img").length>0&&h.first().unwrap(),c.is("img")&&c.hasClass("uploading")&&c.remove(),!i)for(f=this._allowedAttributes[c[0].tagName.toLowerCase()],q=$.makeArray(c[0].attributes),m=0,o=q.length;o>m;m++)g=q[m],null!=f&&(r=g.name,_.call(f,r)>=0)||c.removeAttr(g.name)}else 1!==c[0].nodeType||c.is(":empty")?(c.remove(),h=null):c.is("div, article, dl, header, footer, tr")?(c.append("<br/>"),h.first().unwrap()):c.is("table")?(d=$("<p/>"),c.find("tr").each(function(a,b){return d.append($(b).text()+"<br/>")}),c.replaceWith(d),h=null):c.is("thead, tfoot")?(c.remove(),h=null):c.is("th")?(e=$("<td/>").append(c.contents()),c.replaceWith(e)):h.first().unwrap();if(b&&null!=h&&!c.is("pre"))for(n=0,p=h.length;p>n;n++)j=h[n],this.cleanNode(j,!0);return null},b.prototype.clearHtml=function(a,b){var c,d,e,f=this;return null==b&&(b=!0),c=$("<div/>").append(a),d=c.contents(),e="",d.each(function(a,c){var g;return 3===c.nodeType?e+=c.nodeValue:1===c.nodeType&&(g=$(c),d=g.contents(),d.length>0&&(e+=f.clearHtml(d)),b&&a<d.length-1&&g.is("br, p, div, li, tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2, h3, h4, header"))?e+="\n":void 0}),e},b.prototype.beautify=function(a){var b;return b=function(a){return!!(a.is("p")&&!a.text()&&a.children(":not(br)").length<1)},a.each(function(a,c){var d;return d=$(c),d.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty')&&d.remove(),b(d)&&d.remove(),d.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove()})},b}(Plugin),k=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.editor=this.widget,this.opts.pasteImage&&"string"!=typeof this.opts.pasteImage&&(this.opts.pasteImage="inline")}return Y(b,a),b.className="InputManager",b.prototype.opts={pasteImage:!1},b.prototype._modifierKeys=[16,17,18,91,93,224],b.prototype._arrowKeys=[37,38,39,40],b.prototype._init=function(){var a=this;return this._pasteArea=$("<div/>").css({width:"1px",height:"1px",overflow:"hidden",position:"fixed",right:"0",bottom:"100px"}).attr({tabIndex:"-1",contentEditable:!0}).addClass("simditor-paste-area").appendTo(this.editor.el),this.editor.on("valuechanged",function(){return a.editor.body.find("hr, pre, .simditor-table").each(function(b,c){var d,e;return d=$(c),(d.parent().is("blockquote")||d.parent()[0]===a.editor.body[0])&&(e=!1,0===d.next().length&&($("<p/>").append(a.editor.util.phBr).insertAfter(d),e=!0),0===d.prev().length&&($("<p/>").append(a.editor.util.phBr).insertBefore(d),e=!0),e)?setTimeout(function(){return a.editor.trigger("valuechanged")},10):void 0})}),this.editor.body.on("keydown",$.proxy(this._onKeyDown,this)).on("keypress",$.proxy(this._onKeyPress,this)).on("keyup",$.proxy(this._onKeyUp,this)).on("mouseup",$.proxy(this._onMouseUp,this)).on("focus",$.proxy(this._onFocus,this)).on("blur",$.proxy(this._onBlur,this)).on("paste",$.proxy(this._onPaste,this)).on("drop",$.proxy(this._onDrop,this)),this.editor.util.browser.firefox&&(this.addShortcut("cmd+37",function(b){return b.preventDefault(),a.editor.selection.sel.modify("move","backward","lineboundary"),!1}),this.addShortcut("cmd+39",function(b){return b.preventDefault(),a.editor.selection.sel.modify("move","forward","lineboundary"),!1})),this.editor.textarea.attr("autofocus")?setTimeout(function(){return a.editor.focus()},0):void 0},b.prototype._onFocus=function(){var a=this;return this.editor.el.addClass("focus").removeClass("error"),this.focused=!0,this.lastCaretPosition=null,setTimeout(function(){return a.editor.triggerHandler("focus")},0)},b.prototype._onBlur=function(){var a;return this.editor.el.removeClass("focus"),this.editor.sync(),this.focused=!1,this.lastCaretPosition=null!=(a=this.editor.undoManager.currentState())?a.caret:void 0,this.editor.triggerHandler("blur")},b.prototype._onMouseUp=function(){var a=this;return setTimeout(function(){return a.editor.trigger("selectionchanged"),a.editor.undoManager.update()},0)},b.prototype._onKeyDown=function(a){var b,c,d,e,f,g,h,i=this;if(this.editor.triggerHandler(a)===!1)return!1;if(e=this.editor.util.getShortcutKey(a),this._shortcuts[e])return this._shortcuts[e].call(this,a);if(a.which in this._keystrokeHandlers){if(d="function"==typeof(f=this._keystrokeHandlers[a.which])["*"]?f["*"](a):void 0)return this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged"),!1;if(this.editor.util.traverseUp(function(b){var c,e;if(1===b.nodeType)return c=null!=(e=i._keystrokeHandlers[a.which])?e[b.tagName.toLowerCase()]:void 0,d="function"==typeof c?c(a,$(b)):void 0,!d}),d)return this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged"),!1}return g=a.which,_.call(this._modifierKeys,g)>=0||(h=a.which,_.call(this._arrowKeys,h)>=0)||(c=this.editor.util.metaKey(a),b=this.editor.util.closestBlockEl(),c&&86===a.which)?void 0:(this._typing?(this._typing!==!0&&clearTimeout(this._typing),this._typing=setTimeout(function(){return i.editor.trigger("valuechanged"),i.editor.trigger("selectionchanged"),i._typing=!1},200)):(setTimeout(function(){return i.editor.trigger("valuechanged"),i.editor.trigger("selectionchanged")},10),this._typing=!0),null)},b.prototype._onKeyPress=function(a){return this.editor.triggerHandler(a)===!1?!1:void 0},b.prototype._onKeyUp=function(a){var b,c;return this.editor.triggerHandler(a)===!1?!1:(c=a.which,_.call(this._arrowKeys,c)>=0?(this.editor.trigger("selectionchanged"),void this.editor.undoManager.update()):void(8===a.which&&this.editor.util.isEmptyNode(this.editor.body)&&(this.editor.body.empty(),b=$("<p/>").append(this.editor.util.phBr).appendTo(this.editor.body),this.editor.selection.setRangeAtStartOf(b))))},b.prototype._onPaste=function(a){var b,c,d,e,f,g,h,i=this;if(this.editor.triggerHandler(a)===!1)return!1;if(a.originalEvent.clipboardData&&a.originalEvent.clipboardData.items&&a.originalEvent.clipboardData.items.length>0&&(e=a.originalEvent.clipboardData.items[0],/^image\//.test(e.type))){if(d=e.getAsFile(),null==d||!this.opts.pasteImage)return;return d.name||(d.name="Clipboard Image.png"),g={},g[this.opts.pasteImage]=!0,null!=(h=this.editor.uploader)&&h.upload(d,g),!1}return f=this.editor.selection.deleteRangeContents(),f.collapsed||f.collapse(!0),b=this.editor.util.closestBlockEl(),c=b.is("pre, table"),this.editor.selection.save(f),this._pasteArea.focus(),setTimeout(function(){var a,d,e,h,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;if(i._pasteArea.is(":empty")?n=null:c?n=i.editor.formatter.clearHtml(i._pasteArea.html()):(n=$("<div/>").append(i._pasteArea.contents()),i.editor.formatter.format(n),i.editor.formatter.decorate(n),i.editor.formatter.beautify(n.children()),n=n.contents()),i._pasteArea.empty(),f=i.editor.selection.restore(),i.editor.triggerHandler("pasting",[n])!==!1&&n){if(c)if(b.is("table")){for(l=n.split("\n"),j=l.pop(),o=0,s=l.length;s>o;o++)k=l[o],i.editor.selection.insertNode(document.createTextNode(k)),i.editor.selection.insertNode($("<br/>"));i.editor.selection.insertNode(document.createTextNode(j))}else for(n=$("<div/>").text(n),console.log(n.contents()),w=n.contents(),p=0,t=w.length;t>p;p++)m=w[p],i.editor.selection.insertNode($(m)[0],f);else if(b.is(i.editor.body))for(q=0,u=n.length;u>q;q++)m=n[q],i.editor.selection.insertNode(m,f);else{if(n.length<1)return;if(1===n.length)if(n.is("p"))if(e=n.contents(),1===e.length&&e.is("img")){if(a=e,/^data:image/.test(a.attr("src"))){if(!i.opts.pasteImage)return;return d=i.editor.util.dataURLtoBlob(a.attr("src")),d.name="Clipboard Image.png",g={},g[i.opts.pasteImage]=!0,void(null!=(x=i.editor.uploader)&&x.upload(d,g))}if(a.is('img[src^="webkit-fake-url://"]'))return}else for(r=0,v=e.length;v>r;r++)m=e[r],i.editor.selection.insertNode(m,f);else b.is("p")&&i.editor.util.isEmptyNode(b)?(b.replaceWith(n),i.editor.selection.setRangeAtEndOf(n,f)):n.is("ul, ol")&&b.is("li")?(b.parent().after(n),i.editor.selection.setRangeAtEndOf(n,f)):(b.after(n),i.editor.selection.setRangeAtEndOf(n,f));else b.is("li")&&(b=b.parent()),i.editor.selection.rangeAtStartOf(b,f)?h="before":i.editor.selection.rangeAtEndOf(b,f)?h="after":(i.editor.selection.breakBlockEl(b,f),h="before"),b[h](n),i.editor.selection.setRangeAtEndOf(n.last(),f)}return i.editor.trigger("valuechanged"),i.editor.trigger("selectionchanged")}},10)},b.prototype._onDrop=function(a){var b=this;return this.editor.triggerHandler(a)===!1?!1:setTimeout(function(){return b.editor.trigger("valuechanged"),b.editor.trigger("selectionchanged")},0)},b.prototype._keystrokeHandlers={},b.prototype.addKeystrokeHandler=function(a,b,c){return this._keystrokeHandlers[a]||(this._keystrokeHandlers[a]={}),this._keystrokeHandlers[a][b]=c},b.prototype._shortcuts={"cmd+13":function(){return this.editor.el.closest("form").find("button:submit").click(),!1}},b.prototype.addShortcut=function(a,b){return this._shortcuts[a]=$.proxy(b,this)},b}(Plugin),m=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.editor=this.widget}return Y(b,a),b.className="Keystroke",b.prototype._init=function(){var a,b=this;return this.editor.util.browser.safari&&this.editor.inputManager.addKeystrokeHandler("13","*",function(a){var c;if(a.shiftKey)return c=$("<br/>"),b.editor.selection.rangeAtEndOf($blockEl)?(b.editor.selection.insertNode(c),b.editor.selection.insertNode($("<br/>")),b.editor.selection.setRangeBefore(c)):b.editor.selection.insertNode(c),!0}),(this.editor.util.browser.webkit||this.editor.util.browser.msie)&&(a=function(a,c){var d;if(b.editor.selection.rangeAtEndOf(c))return d=$("<p/>").append(b.editor.util.phBr).insertAfter(c),b.editor.selection.setRangeAtStartOf(d),!0},this.editor.inputManager.addKeystrokeHandler("13","h1",a),this.editor.inputManager.addKeystrokeHandler("13","h2",a),this.editor.inputManager.addKeystrokeHandler("13","h3",a),this.editor.inputManager.addKeystrokeHandler("13","h4",a),this.editor.inputManager.addKeystrokeHandler("13","h5",a),this.editor.inputManager.addKeystrokeHandler("13","h6",a)),this.editor.inputManager.addKeystrokeHandler("8","*",function(){var a,c;return c=b.editor.util.furthestBlockEl(),a=c.prev(),a.is("hr")&&b.editor.selection.rangeAtStartOf(c)?(b.editor.selection.save(),a.remove(),b.editor.selection.restore(),!0):void 0}),this.editor.inputManager.addKeystrokeHandler("9","*",function(a){return b.editor.opts.tabIndent?(a.shiftKey?b.editor.util.outdent():b.editor.util.indent(),!0):void 0}),this.editor.inputManager.addKeystrokeHandler("13","li",function(a,c){var d,e,f,g;if(d=c.clone(),d.find("ul, ol").remove(),b.editor.util.isEmptyNode(d)&&c.is(b.editor.util.closestBlockEl())){if(e=c.parent(),c.next("li").length>0){if(!b.editor.util.isEmptyNode(c))return;e.parent("li").length>0?(f=$("<li/>").append(b.editor.util.phBr).insertAfter(e.parent("li")),g=$("<"+e[0].tagName+"/>").append(c.nextAll("li")),f.append(g)):(f=$("<p/>").append(b.editor.util.phBr).insertAfter(e),g=$("<"+e[0].tagName+"/>").append(c.nextAll("li")),f.after(g))}else e.parent("li").length>0?(f=$("<li/>").insertAfter(e.parent("li")),f.append(c.contents().length>0?c.contents():b.editor.util.phBr)):(f=$("<p/>").append(b.editor.util.phBr).insertAfter(e),c.children("ul, ol").length>0&&f.after(c.children("ul, ol")));return c.prev("li").length?c.remove():e.remove(),b.editor.selection.setRangeAtStartOf(f),!0}}),this.editor.inputManager.addKeystrokeHandler("13","pre",function(a,c){var d,e;return a.preventDefault(),e=b.editor.selection.getRange(),d=null,e.deleteContents(),!b.editor.util.browser.msie&&b.editor.selection.rangeAtEndOf(c)?(d=document.createTextNode("\n\n"),e.insertNode(d),e.setEnd(d,1)):(d=document.createTextNode("\n"),e.insertNode(d),e.setStartAfter(d)),e.collapse(!1),b.editor.selection.selectRange(e),!0}),this.editor.inputManager.addKeystrokeHandler("13","blockquote",function(a,c){var d;return d=b.editor.util.closestBlockEl(),d.is("p")&&!d.next().length&&b.editor.util.isEmptyNode(d)?(c.after(d),b.editor.selection.setRangeAtStartOf(d),!0):void 0}),this.editor.inputManager.addKeystrokeHandler("8","li",function(a,c){var d,e,f,g,h,i,j,k;if(e=c.children("ul, ol"),h=c.prev("li"),e.length>0&&h.length>0){if(k="",i=null,c.contents().each(function(a,b){return 3===b.nodeType&&b.nodeValue?(k+=b.nodeValue,i=$(b)):void 0}),i&&1===k.length&&b.editor.util.browser.firefox&&!i.next("br").length)return d=$(b.editor.util.phBr).insertAfter(i),i.remove(),b.editor.selection.setRangeBefore(d),!0;if(!(k.length>0))return j=document.createRange(),g=h.children("ul, ol"),g.length>0?(f=$("<li/>").append(b.editor.util.phBr).appendTo(g),g.append(e.children("li")),c.remove(),b.editor.selection.setRangeAtEndOf(f,j)):(b.editor.selection.setRangeAtEndOf(h,j),h.append(e),c.remove(),b.editor.selection.selectRange(j)),!0}}),this.editor.inputManager.addKeystrokeHandler("8","pre",function(a,c){var d,e;if(b.editor.selection.rangeAtStartOf(c))return e=c.html().replace("\n","<br/>"),d=$("<p/>").append(e||b.editor.util.phBr).insertAfter(c),c.remove(),b.editor.selection.setRangeAtStartOf(d),!0}),this.editor.inputManager.addKeystrokeHandler("8","blockquote",function(a,c){var d;if(b.editor.selection.rangeAtStartOf(c))return d=c.children().first().unwrap(),b.editor.selection.setRangeAtStartOf(d),!0})},b}(Plugin),C=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.editor=this.widget}return Y(b,a),b.className="UndoManager",b.prototype._stack=[],b.prototype._index=-1,b.prototype._capacity=50,b.prototype._timer=null,b.prototype._init=function(){var a,b,c=this;return this.editor.util.os.mac?(b="cmd+90",a="shift+cmd+90"):this.editor.util.os.win?(b="ctrl+90",a="ctrl+89"):(b="ctrl+90",a="shift+ctrl+90"),this.editor.inputManager.addShortcut(b,function(a){return a.preventDefault(),c.undo(),!1}),this.editor.inputManager.addShortcut(a,function(a){return a.preventDefault(),c.redo(),!1}),this.editor.on("valuechanged",function(a,b){return"undo"!==b?(c._timer&&(clearTimeout(c._timer),c._timer=null),c._timer=setTimeout(function(){return c._pushUndoState()},200)):void 0})},b.prototype._pushUndoState=function(){var a,b;return a=this.currentState(),b=this.editor.body.html(),a&&a.html===b?void 0:(this._index+=1,this._stack.length=this._index,this._stack.push({html:b,caret:this.caretPosition()}),this._stack.length>this._capacity?(this._stack.shift(),this._index-=1):void 0)},b.prototype.currentState=function(){return this._stack.length&&this._index>-1?this._stack[this._index]:null},b.prototype.undo=function(){var a;if(!(this._index<1||this._stack.length<2))return this.editor.hidePopover(),this._index-=1,a=this._stack[this._index],this.editor.body.html(a.html),this.caretPosition(a.caret),this.editor.body.find(".selected").removeClass("selected"),this.editor.sync(),this.editor.trigger("valuechanged",["undo"]),this.editor.trigger("selectionchanged",["undo"])},b.prototype.redo=function(){var a;if(!(this._index<0||this._stack.length<this._index+2))return this.editor.hidePopover(),this._index+=1,a=this._stack[this._index],this.editor.body.html(a.html),this.caretPosition(a.caret),this.editor.body.find(".selected").removeClass("selected"),this.editor.sync(),this.editor.trigger("valuechanged",["undo"]),this.editor.trigger("selectionchanged",["undo"])},b.prototype.update=function(){var a,b;return(a=this.currentState())?(b=this.editor.body.html(),a.html=b,a.caret=this.caretPosition()):void 0},b.prototype._getNodeOffset=function(a,b){var c,d,e;return c=b?$(a):$(a).parent(),e=0,d=!1,c.contents().each(function(c,f){return b===c||a===f?!1:(3===f.nodeType?d||(e+=1,d=!0):(e+=1,d=!1),null)}),e},b.prototype._getNodePosition=function(a,b){var c,d,e=this;if(3===a.nodeType)for(d=a.previousSibling;d&&3===d.nodeType;)a=d,b+=this.editor.util.getNodeLength(d),d=d.previousSibling;else b=this._getNodeOffset(a,b);return c=[],c.unshift(b),this.editor.util.traverseUp(function(a){return c.unshift(e._getNodeOffset(a))},a),c},b.prototype._getNodeByPosition=function(a){var b,c,d,e,f,g,h,i;for(e=this.editor.body[0],i=a.slice(0,a.length-1),d=g=0,h=i.length;h>g;d=++g){if(f=i[d],c=e.childNodes,f>c.length-1){if(d!==a.length-2||!$(e).is("pre")){e=null;break}b=document.createTextNode(""),e.appendChild(b),c=e.childNodes}e=c[f]}return e},b.prototype.caretPosition=function(a){var b,c,d,e,f;if(a){if(this.editor.inputManager.focused||this.editor.body.focus(),!a.start)return void this.editor.body.blur();if(e=this._getNodeByPosition(a.start),f=a.start[a.start.length-1],a.collapsed?(b=e,c=f):(b=this._getNodeByPosition(a.end),c=a.start[a.start.length-1]),!e||!b)throw new Error("simditor: invalid caret state");return d=document.createRange(),d.setStart(e,f),d.setEnd(b,c),this.editor.selection.selectRange(d)}return d=this.editor.selection.getRange(),this.editor.inputManager.focused&&null!=d?(a={start:[],end:null,collapsed:!0},a.start=this._getNodePosition(d.startContainer,d.startOffset),d.collapsed||(a.end=this._getNodePosition(d.endContainer,d.endOffset),a.collapsed=!1),a):{}},b}(Plugin),E=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.browser.msie&&this.browser.version<11&&(this.phBr=""),this.editor=this.widget}return Y(b,a),b.className="Util",b.prototype._init=function(){},b.prototype.phBr="<br/>",b.prototype.os=function(){return/Mac/.test(navigator.appVersion)?{mac:!0}:/Linux/.test(navigator.appVersion)?{linux:!0}:/Win/.test(navigator.appVersion)?{win:!0}:/X11/.test(navigator.appVersion)?{unix:!0}:{}}(),b.prototype.browser=function(){var a,b,c,d,e;return e=navigator.userAgent,c=/(msie|trident)/i.test(e),a=/chrome|crios/i.test(e),d=/safari/i.test(e)&&!a,b=/firefox/i.test(e),c?{msie:!0,version:e.match(/(msie |rv:)(\d+(\.\d+)?)/i)[2]}:a?{webkit:!0,chrome:!0,version:e.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)[1]}:d?{webkit:!0,safari:!0,version:e.match(/version\/(\d+(\.\d+)?)/i)[1]}:b?{mozilla:!0,firefox:!0,version:e.match(/firefox\/(\d+(\.\d+)?)/i)[1]}:{}}(),b.prototype.metaKey=function(a){var b;return b=/Mac/.test(navigator.userAgent),b?a.metaKey:a.ctrlKey},b.prototype.isEmptyNode=function(a){var b;return b=$(a),b.is(":empty")||!b.text()&&!b.find(":not(br, span, div)").length},b.prototype.isBlockNode=function(a){return a=$(a)[0],a&&3!==a.nodeType?/^(div|p|ul|ol|li|blockquote|hr|pre|h1|h2|h3|h4|table)$/.test(a.nodeName.toLowerCase()):!1},b.prototype.closestBlockEl=function(a){var b,c,d,e=this;return null==a&&(d=this.editor.selection.getRange(),a=null!=d?d.commonAncestorContainer:void 0),b=$(a),b.length?(c=b.parentsUntil(this.editor.body).addBack(),c=c.filter(function(a){return e.isBlockNode(c.eq(a))}),c.length?c.last():null):null},b.prototype.furthestNode=function(a,b){var c,d,e;return null==a&&(e=this.editor.selection.getRange(),a=null!=e?e.commonAncestorContainer:void 0),c=$(a),c.length?(d=c.parentsUntil(this.editor.body).addBack(),d=d.filter(function(a){var c;return c=d.eq(a),$.isFunction(b)?b(c):c.is(b)}),d.length?d.first():null):null},b.prototype.furthestBlockEl=function(a){return this.furthestNode(a,this.isBlockNode)},b.prototype.getNodeLength=function(a){switch(a.nodeType){case 7:case 10:return 0;case 3:case 8:return a.length;default:return a.childNodes.length}},b.prototype.traverseUp=function(a,b){var c,d,e,f,g,h,i;if(null==b&&(e=this.editor.selection.getRange(),b=null!=e?e.commonAncestorContainer:void 0),null==b||!$.contains(this.editor.body[0],b))return!1;for(d=$(b).parentsUntil(this.editor.body).get(),d.unshift(b),i=[],g=0,h=d.length;h>g&&(c=d[g],f=a(c),f!==!1);g++)i.push(void 0);return i},b.prototype.getShortcutKey=function(a){var b;return b=[],a.shiftKey&&b.push("shift"),a.ctrlKey&&b.push("ctrl"),a.altKey&&b.push("alt"),a.metaKey&&b.push("cmd"),b.push(a.which),b.join("+")},b.prototype.indent=function(){var a,b,c,d,e,f,g,h,i,j;if(a=this.editor.util.closestBlockEl(),!(a&&a.length>0))return!1;if(a.is("pre"))h=document.createTextNode("  "),this.editor.selection.insertNode(h);else if(a.is("li")){if(d=a.prev("li"),d.length<1)return!1;this.editor.selection.save(),i=a.parent()[0].tagName,b=d.children("ul, ol"),b.length>0?b.append(a):$("<"+i+"/>").append(a).appendTo(d),this.editor.selection.restore()}else if(a.is("p, h1, h2, h3, h4"))f=null!=(j=a.attr("data-indent"))?j:0,f=1*f+1,f>10&&(f=10),a.attr("data-indent",f);else if(a.is("table")){if(g=this.editor.selection.getRange(),e=$(g.commonAncestorContainer).closest("td"),c=e.next("td"),c.length>0||(c=e.parent("tr").next("tr").find("td:first")),!(e.length>0&&c.length>0))return!1;this.editor.selection.setRangeAtEndOf(c)}else h=document.createTextNode("    "),this.editor.selection.insertNode(h);return this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged"),!0},b.prototype.outdent=function(){var a,b,c,d,e,f,g,h,i;if(a=this.editor.util.closestBlockEl(),!(a&&a.length>0))return!1;if(a.is("pre"))return!1;if(a.is("li")){if(b=a.parent(),c=b.parent("li"),c.length<1)return f=this.editor.toolbar.findButton(b[0].tagName.toLowerCase()),null!=f&&f.command(),!1;this.editor.selection.save(),a.next("li").length>0&&$("<"+b[0].tagName+"/>").append(a.nextAll("li")).appendTo(a),a.insertAfter(c),b.children("li").length<1&&b.remove(),this.editor.selection.restore()}else if(a.is("p, h1, h2, h3, h4"))g=null!=(i=a.attr("data-indent"))?i:0,g=1*g-1,0>g&&(g=0),a.attr("data-indent",g);else{if(!a.is("table"))return!1;if(h=this.editor.selection.getRange(),e=$(h.commonAncestorContainer).closest("td"),d=e.prev("td"),d.length>0||(d=e.parent("tr").prev("tr").find("td:last")),!(e.length>0&&d.length>0))return!1;this.editor.selection.setRangeAtEndOf(d)}return this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged"),!0},b.prototype.dataURLtoBlob=function(a){var b,c,d,e,f,g,h,i,j,k,l;if(g=window.Blob&&function(){var a;try{return Boolean(new Blob)}catch(b){return a=b,!1}}(),f=g&&window.Uint8Array&&function(){var a;try{return 100===new Blob([new Uint8Array(100)]).size}catch(b){return a=b,!1}}(),b=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,!((g||b)&&window.atob&&window.ArrayBuffer&&window.Uint8Array))return!1;for(e=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),c=new ArrayBuffer(e.length),i=new Uint8Array(c),h=k=0,l=e.length;l>=0?l>=k:k>=l;h=l>=0?++k:--k)i[h]=e.charCodeAt(h);return j=a.split(",")[0].split(":")[1].split(";")[0],g?new Blob([f?i:c],{type:j}):(d=new b,d.append(c),d.getBlob(j))},b}(Plugin),A=function(a){function b(){var a;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),this.editor=this.widget}return Y(b,a),b.className="Toolbar",b.prototype.opts={toolbar:!0,toolbarFloat:!0},b.prototype._tpl={wrapper:'<div class="simditor-toolbar"><ul></ul></div>',separator:'<li><span class="separator"></span></li>'},b.prototype._init=function(){var a=this;if(this.opts.toolbar)return $.isArray(this.opts.toolbar)||(this.opts.toolbar=["bold","italic","underline","strikethrough","|","ol","ul","blockquote","code","|","link","image","|","indent","outdent"]),this._render(),this.list.on("click",function(){return!1}),this.wrapper.on("mousedown",function(){return a.list.find(".menu-on").removeClass(".menu-on")}),$(document).on("mousedown.simditor",function(){return a.list.find(".menu-on").removeClass(".menu-on")}),this.opts.toolbarFloat&&(this.wrapper.width(this.wrapper.outerWidth()),this.wrapper.css("left",this.wrapper.offset().left),$(window).on("scroll.simditor-"+this.editor.id,function(){var b,c,d;return d=a.editor.wrapper.offset().top,b=d+a.editor.wrapper.outerHeight()-80,c=$(document).scrollTop(),d>=c||c>=b?a.editor.wrapper.removeClass("toolbar-floating"):a.editor.wrapper.addClass("toolbar-floating")})),this.editor.on("selectionchanged focus",function(){return a.toolbarStatus()}),this.editor.on("destroy",function(){return a.buttons.length=0}),$(document).on("mousedown.simditor-"+this.editor.id,function(){return a.list.find("li.menu-on").removeClass("menu-on")})},b.prototype._render=function(){var a,b,c,d,e;for(this.buttons=[],this.wrapper=$(this._tpl.wrapper).prependTo(this.editor.wrapper),this.list=this.wrapper.find("ul"),d=this.opts.toolbar,e=[],b=0,c=d.length;c>b;b++)if(a=d[b],"|"!==a){if(!this.constructor.buttons[a])throw new Error('simditor: invalid toolbar button "'+a+'"');e.push(this.buttons.push(new this.constructor.buttons[a](this.editor)))}else $(this._tpl.separator).appendTo(this.list);return e},b.prototype.toolbarStatus=function(a){var b;if(this.editor.inputManager.focused)return b=this.buttons.slice(0),this.editor.util.traverseUp(function(c){var d,e,f,g,h,i,j;for(f=[],e=g=0,i=b.length;i>g;e=++g)d=b[e],(null==a||d.name===a)&&(d.status&&d.status($(c))!==!0||f.push(d));for(h=0,j=f.length;j>h;h++)d=f[h],e=$.inArray(d,b),b.splice(e,1);return 0===b.length?!1:void 0})},b.prototype.findButton=function(a){var b;return b=this.list.find(".toolbar-item-"+a).data("button"),null!=b?b:null},b.addButton=function(a){return this.buttons[a.prototype.name]=a},b.buttons={},b}(Plugin),u=function(a){function b(){return F=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.connect(E),b.connect(C),b.connect(k),b.connect(m),b.connect(f),b.connect(t),b.connect(A),b.count=0,b.prototype.opts={textarea:null,placeholder:"",defaultImage:"images/image.png",params:{},upload:!1,tabIndent:!0},b.prototype._init=function(){var a,c,d,e,f=this;
  if(this.textarea=$(this.opts.textarea),this.opts.placeholder=null!=(e=this.opts.placeholder)?e:this.textarea.attr("placeholder"),!this.textarea.length)throw new Error("simditor: param textarea is required.");return a=this.textarea.data("simditor"),null!=a&&a.destroy(),this.id=++b.count,this._render(),this.opts.upload&&("undefined"!=typeof simple&&null!==simple?simple.uploader:void 0)&&(d="object"==typeof this.opts.upload?this.opts.upload:{},this.uploader=simple.uploader(d)),c=this.textarea.closest("form"),c.length&&(c.on("submit.simditor-"+this.id,function(){return f.sync()}),c.on("reset.simditor-"+this.id,function(){return f.setValue("")})),this.on("pluginconnected",function(){return f.setValue(f.textarea.val()||""),f.opts.placeholder&&f.on("valuechanged",function(){return f._placeholder()}),setTimeout(function(){return f.trigger("valuechanged")},0)}),this.util.browser.mozilla?(document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)):void 0},b.prototype._tpl='<div class="simditor">\n  <div class="simditor-wrapper">\n    <div class="simditor-placeholder"></div>\n    <div class="simditor-body" contenteditable="true">\n    </div>\n  </div>\n</div>',b.prototype._render=function(){var a,b,c,d;if(this.el=$(this._tpl).insertBefore(this.textarea),this.wrapper=this.el.find(".simditor-wrapper"),this.body=this.wrapper.find(".simditor-body"),this.placeholderEl=this.wrapper.find(".simditor-placeholder").append(this.opts.placeholder),this.el.append(this.textarea).data("simditor",this),this.textarea.data("simditor",this).hide().blur(),this.body.attr("tabindex",this.textarea.attr("tabindex")),this.util.os.mac?this.el.addClass("simditor-mac"):this.util.os.linux&&this.el.addClass("simditor-linux"),this.opts.params){c=this.opts.params,d=[];for(a in c)b=c[a],d.push($("<input/>",{type:"hidden",name:a,value:b}).insertAfter(this.textarea));return d}},b.prototype._placeholder=function(){var a,b;return a=this.body.children(),0===a.length||1===a.length&&this.util.isEmptyNode(a)&&(null!=(b=a.data("indent"))?b:0)<1?this.placeholderEl.show():this.placeholderEl.hide()},b.prototype.setValue=function(a){return this.hidePopover(),this.textarea.val(a),this.body.html(a),this.formatter.format(),this.formatter.decorate()},b.prototype.getValue=function(){return this.sync()},b.prototype.sync=function(){var a,b,c,d,e,f;for(this.hidePopover,b=this.body.clone(),this.formatter.undecorate(b),this.formatter.format(b),this.formatter.autolink(b),a=b.children(),e=a.last("p"),d=a.first("p");e.is("p")&&this.util.isEmptyNode(e);)c=e,e=e.prev("p"),c.remove();for(;d.is("p")&&this.util.isEmptyNode(d);)c=d,d=e.next("p"),c.remove();return b.find("img.uploading").remove(),f=$.trim(b.html()),this.textarea.val(f),f},b.prototype.focus=function(){var a,b;return a=this.body.find("p, li, pre, h1, h2, h3, h4, td").first(),a.length>0?(b=document.createRange(),this.selection.setRangeAtStartOf(a,b),this.body.focus()):void 0},b.prototype.blur=function(){return this.body.blur()},b.prototype.hidePopover=function(){return this.wrapper.find(".simditor-popover").each(function(a,b){return b=$(b).data("popover"),b.active?b.hide():void 0})},b.prototype.destroy=function(){return this.triggerHandler("destroy"),this.textarea.closest("form").off(".simditor .simditor-"+this.id),this.selection.clear(),this.textarea.insertBefore(this.el).hide().val("").removeData("simditor"),this.el.remove(),$(document).off(".simditor-"+this.id),$(window).off(".simditor-"+this.id),this.off()},b}(Widget),window.Simditor=u,y=function(a){function b(){return G=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b}(Plugin),x=function(a){function b(){return P=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.connect(y),b}(Widget),c=function(a){function b(a){var b,c,d,e,f=this;for(this.editor=a,this.render(),this.el.on("mousedown",function(a){var b,c;return a.preventDefault(),f.menu?(f.wrapper.toggleClass("menu-on").siblings("li").removeClass("menu-on"),f.wrapper.is(".menu-on")&&(b=f.menuWrapper.offset().left+f.menuWrapper.outerWidth()+5-f.editor.wrapper.offset().left-f.editor.wrapper.outerWidth(),b>0&&f.menuWrapper.css({left:"auto",right:0})),!1):f.el.hasClass("disabled")||f.needFocus&&!f.editor.inputManager.focused?!1:(c=f.el.data("param"),f.command(c),!1)}),this.wrapper.on("click","a.menu-item",function(a){var b,c;return a.preventDefault(),b=$(a.currentTarget),f.wrapper.removeClass("menu-on"),b.hasClass("disabled")||f.needFocus&&!f.editor.inputManager.focused?!1:(f.editor.toolbar.wrapper.removeClass("menu-on"),c=b.data("param"),f.command(c),!1)}),this.wrapper.on("mousedown","a.menu-item",function(){return!1}),this.editor.on("blur",function(){return f.setActive(!1),f.setDisabled(!1)}),null!=this.shortcut&&this.editor.inputManager.addShortcut(this.shortcut,function(){return f.el.mousedown(),!1}),e=this.htmlTag.split(","),c=0,d=e.length;d>c;c++)b=e[c],b=$.trim(b),b&&$.inArray(b,this.editor.formatter._allowedTags)<0&&this.editor.formatter._allowedTags.push(b)}return Y(b,a),b.prototype._tpl={item:'<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>',menuWrapper:'<div class="toolbar-menu"></div>',menuItem:'<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>',separator:'<li><span class="separator"></span></li>'},b.prototype.name="",b.prototype.icon="",b.prototype.title="",b.prototype.text="",b.prototype.htmlTag="",b.prototype.disableTag="",b.prototype.menu=!1,b.prototype.active=!1,b.prototype.disabled=!1,b.prototype.needFocus=!0,b.prototype.shortcut=null,b.prototype.render=function(){return this.wrapper=$(this._tpl.item).appendTo(this.editor.toolbar.list),this.el=this.wrapper.find("a.toolbar-item"),this.el.attr("title",this.title).addClass("toolbar-item-"+this.name).data("button",this),this.el.find("span").addClass(this.icon?"fa fa-"+this.icon:"").text(this.text),this.menu?(this.menuWrapper=$(this._tpl.menuWrapper).appendTo(this.wrapper),this.menuWrapper.addClass("toolbar-menu-"+this.name),this.renderMenu()):void 0},b.prototype.renderMenu=function(){var a,b,c,d,e,f,g,h;if($.isArray(this.menu)){for(this.menuEl=$("<ul/>").appendTo(this.menuWrapper),f=this.menu,h=[],d=0,e=f.length;e>d;d++)c=f[d],"|"!==c?(b=$(this._tpl.menuItem).appendTo(this.menuEl),h.push(a=b.find("a.menu-item").attr({title:null!=(g=c.title)?g:c.text,"data-param":c.param}).addClass("menu-item-"+c.name).find("span").text(c.text))):$(this._tpl.separator).appendTo(this.menuEl);return h}},b.prototype.setActive=function(a){return this.active=a,this.el.toggleClass("active",this.active)},b.prototype.setDisabled=function(a){return this.disabled=a,this.el.toggleClass("disabled",this.disabled)},b.prototype.status=function(a){return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:(null!=a&&this.setActive(a.is(this.htmlTag)),this.active)},b.prototype.command=function(){},b}(Module),window.SimditorButton=c,s=function(a){function b(a){var b=this;this.editor=a,this.el=$('<div class="simditor-popover"></div>').appendTo(this.editor.wrapper).data("popover",this),this.render(),this.el.on("mouseenter",function(){return b.el.addClass("hover")}),this.el.on("mouseleave",function(){return b.el.removeClass("hover")})}return Y(b,a),b.prototype.offset={top:4,left:0},b.prototype.target=null,b.prototype.active=!1,b.prototype.render=function(){},b.prototype.show=function(a,b){var c=this;return null==b&&(b="bottom"),null!=a?(this.target=a.addClass("selected"),this.el.siblings(".simditor-popover").each(function(a,b){var c;return c=$(b).data("popover"),c.hide()}),this.active?(this.refresh(b),this.trigger("popovershow")):(this.active=!0,this.el.css({left:-9999}).show(),setTimeout(function(){return c.refresh(b),c.trigger("popovershow")},0))):void 0},b.prototype.hide=function(){return this.active?(this.target&&this.target.removeClass("selected"),this.target=null,this.active=!1,this.el.hide(),this.trigger("popoverhide")):void 0},b.prototype.refresh=function(a){var b,c,d,e,f;return null==a&&(a="bottom"),f=this.editor.wrapper.offset(),d=this.target.offset(),c=this.target.outerHeight(),"bottom"===a?e=d.top-f.top+c:"top"===a&&(e=d.top-f.top-this.el.height()),b=Math.min(d.left-f.left,this.editor.wrapper.width()-this.el.outerWidth()-10),this.el.css({top:e+this.offset.top,left:b+this.offset.left})},b.prototype.destroy=function(){return this.target=null,this.active=!1,this.editor.off(".linkpopover"),this.el.remove()},b}(Module),window.SimditorPopover=s,z=function(a){function b(){return Q=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="title",b.prototype.title="标题文字",b.prototype.htmlTag="h1, h2, h3, h4",b.prototype.disableTag="pre, table",b.prototype.menu=[{name:"normal",text:"普通文本",param:"p"},"|",{name:"h1",text:"标题 1",param:"h1"},{name:"h2",text:"标题 2",param:"h2"},{name:"h3",text:"标题 3",param:"h3"}],b.prototype.setActive=function(a,b){return this.active=a,a?this.el.addClass("active active-"+b):this.el.removeClass("active active-p active-h1 active-h2 active-h3")},b.prototype.status=function(a){var b,c;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:(null!=a&&(b=null!=(c=a[0].tagName)?c.toLowerCase():void 0,this.setActive(a.is(this.htmlTag),b)),this.active)},b.prototype.command=function(a){var b,c,d,e,f,g,h,i,j,k,l,m=this;for(g=this.editor.selection.getRange(),i=g.startContainer,e=g.endContainer,d=this.editor.util.closestBlockEl(i),c=this.editor.util.closestBlockEl(e),this.editor.selection.save(),g.setStartBefore(d[0]),g.setEndAfter(c[0]),b=$(g.extractContents()),h=[],b.children().each(function(b,c){var d,e,f,g,i;for(e=m._convertEl(c,a),i=[],f=0,g=e.length;g>f;f++)d=e[f],i.push(h.push(d));return i}),l=h.reverse(),j=0,k=l.length;k>j;j++)f=l[j],g.insertNode(f[0]);return this.editor.selection.restore(),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b.prototype._convertEl=function(a,b){var c,d,e;return d=$(a),e=[],d.is(b)?e.push(d):(c=$("<"+b+"/>").append(d.contents()),e.push(c)),e},b}(c),u.Toolbar.addButton(z),b=function(a){function b(){return R=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="bold",b.prototype.icon="bold",b.prototype.title="加粗文字",b.prototype.htmlTag="b, strong",b.prototype.disableTag="pre",b.prototype.shortcut="cmd+66",b.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + b )":(this.title=this.title+" ( Ctrl + b )",this.shortcut="ctrl+66"),b.__super__.render.call(this)},b.prototype.status=function(a){var b;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:(b=document.queryCommandState("bold")===!0,this.setActive(b),b)},b.prototype.command=function(){return document.execCommand("bold"),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b}(c),u.Toolbar.addButton(b),l=function(a){function b(){return S=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="italic",b.prototype.icon="italic",b.prototype.title="斜体文字",b.prototype.htmlTag="i",b.prototype.disableTag="pre",b.prototype.shortcut="cmd+73",b.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + i )":(this.title=this.title+" ( Ctrl + i )",this.shortcut="ctrl+73"),b.__super__.render.call(this)},b.prototype.status=function(a){var b;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?this.disabled:(b=document.queryCommandState("italic")===!0,this.setActive(b),b)},b.prototype.command=function(){return document.execCommand("italic"),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b}(c),u.Toolbar.addButton(l),B=function(a){function b(){return T=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="underline",b.prototype.icon="underline",b.prototype.title="下划线文字",b.prototype.htmlTag="u",b.prototype.disableTag="pre",b.prototype.shortcut="cmd+85",b.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + u )":(this.title=this.title+" ( Ctrl + u )",this.shortcut="ctrl+85"),b.__super__.render.call(this)},b.prototype.status=function(a){var b;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?this.disabled:(b=document.queryCommandState("underline")===!0,this.setActive(b),b)},b.prototype.command=function(){return document.execCommand("underline"),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b}(c),u.Toolbar.addButton(B),p=function(a){function b(){return U=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.type="",b.prototype.disableTag="pre, table",b.prototype.status=function(a){var b;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:null==a?this.active:(b="ul"===this.type?"ol":"ul",a.is(b)?(this.setActive(!1),!0):(this.setActive(a.is(this.htmlTag)),this.active))},b.prototype.command=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=this;for(k=this.editor.selection.getRange(),n=k.startContainer,h=k.endContainer,f=this.editor.util.closestBlockEl(n),b=this.editor.util.closestBlockEl(h),this.editor.selection.save(),k.setStartBefore(f[0]),k.setEndAfter(b[0]),f.is("li")&&b.is("li")&&(d=this.editor.util.furthestNode(f,"ul, ol"),c=this.editor.util.furthestNode(b,"ul, ol"),d.is(c)?(i=function(a){var b;for(b=1;!a.parent().is(d);)b+=1,a=a.parent();return b},m=i(f),g=i(b),e=m>g?b.parent():f.parent(),k.setStartBefore(e[0]),k.setEndAfter(e[0])):(k.setStartBefore(d[0]),k.setEndAfter(c[0]))),a=$(k.extractContents()),l=[],a.children().each(function(a,b){var c,d,e,f,g;for(d=r._convertEl(b),g=[],e=0,f=d.length;f>e;e++)c=d[e],g.push(l.length&&l[l.length-1].is(r.type)&&c.is(r.type)?l[l.length-1].append(c.children()):l.push(c));return g}),q=l.reverse(),o=0,p=q.length;p>o;o++)j=q[o],k.insertNode(j[0]);return this.editor.selection.restore(),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b.prototype._convertEl=function(a){var b,c,d,e,f,g,h,i,j,k=this;if(b=$(a),g=[],c="ul"===this.type?"ol":"ul",b.is(this.type))b.children("li").each(function(a,b){var c,d,e;return d=$(b),c=d.children("ul, ol").remove(),e=$("<p/>").append($(b).html()||k.editor.util.phBr),g.push(e),c.length>0?g.push(c):void 0});else if(b.is(c))d=$("<"+this.type+"/>").append(b.html()),g.push(d);else if(b.is("blockquote")){for(j=b.children().get(),h=0,i=j.length;i>h;h++)e=j[h],f=this._convertEl(e);$.merge(g,f)}else b.is("table")||(d=$("<"+this.type+"><li></li></"+this.type+">"),d.find("li").append(b.html()||this.editor.util.phBr),g.push(d));return g},b}(c),q=function(a){function b(){return V=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.type="ol",b.prototype.name="ol",b.prototype.title="有序列表",b.prototype.icon="list-ol",b.prototype.htmlTag="ol",b.prototype.shortcut="cmd+191",b.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + / )":(this.title=this.title+" ( ctrl + / )",this.shortcut="ctrl+191"),b.__super__.render.call(this)},b}(p),D=function(a){function b(){return W=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.type="ul",b.prototype.name="ul",b.prototype.title="无序列表",b.prototype.icon="list-ul",b.prototype.htmlTag="ul",b.prototype.shortcut="cmd+190",b.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + . )":(this.title=this.title+" ( Ctrl + . )",this.shortcut="ctrl+190"),b.__super__.render.call(this)},b}(p),u.Toolbar.addButton(q),u.Toolbar.addButton(D),a=function(a){function b(){return H=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="blockquote",b.prototype.icon="quote-left",b.prototype.title="引用",b.prototype.htmlTag="blockquote",b.prototype.disableTag="pre, table",b.prototype.command=function(){var a,b,c,d,e,f,g,h,i,j,k,l=this;for(f=this.editor.selection.getRange(),h=f.startContainer,d=f.endContainer,c=this.editor.util.furthestBlockEl(h),b=this.editor.util.furthestBlockEl(d),this.editor.selection.save(),f.setStartBefore(c[0]),f.setEndAfter(b[0]),a=$(f.extractContents()),g=[],a.children().each(function(a,b){var c,d,e,f,h;for(d=l._convertEl(b),h=[],e=0,f=d.length;f>e;e++)c=d[e],h.push(g.length&&g[g.length-1].is(l.htmlTag)&&c.is(l.htmlTag)?g[g.length-1].append(c.children()):g.push(c));return h}),k=g.reverse(),i=0,j=k.length;j>i;i++)e=k[i],f.insertNode(e[0]);return this.editor.selection.restore(),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b.prototype._convertEl=function(a){var b,c,d;return b=$(a),d=[],b.is(this.htmlTag)?b.children().each(function(a,b){return d.push($(b))}):(c=$("<"+this.htmlTag+"/>").append(b),d.push(c)),d},b}(c),u.Toolbar.addButton(a),d=function(a){function b(a){var c=this;this.editor=a,b.__super__.constructor.call(this,this.editor),this.editor.on("decorate",function(a,b){return b.find("pre").each(function(a,b){return c.decorate($(b))})}),this.editor.on("undecorate",function(a,b){return b.find("pre").each(function(a,b){return c.undecorate($(b))})})}return Y(b,a),b.prototype.name="code",b.prototype.icon="code",b.prototype.title="插入代码",b.prototype.htmlTag="pre",b.prototype.disableTag="li, table",b.prototype.render=function(){var a;return a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.render.apply(this,a),this.popover=new e(this.editor)},b.prototype.status=function(a){var c;return c=b.__super__.status.call(this,a),this.active?this.popover.show(a):this.editor.util.isBlockNode(a)&&this.popover.hide(),c},b.prototype.decorate=function(a){var b;return b=a.attr("data-lang"),a.removeClass(),b&&-1!==b?a.addClass("lang-"+b):void 0},b.prototype.undecorate=function(a){var b;return b=a.attr("data-lang"),a.removeClass(),b&&-1!==b?a.addClass("lang-"+b):void 0},b.prototype.command=function(){var a,b,c,d,e,f,g,h,i,j,k,l=this;for(f=this.editor.selection.getRange(),h=f.startContainer,d=f.endContainer,c=this.editor.util.closestBlockEl(h),b=this.editor.util.closestBlockEl(d),f.setStartBefore(c[0]),f.setEndAfter(b[0]),a=$(f.extractContents()),g=[],a.children().each(function(a,b){var c,d,e,f,h;for(d=l._convertEl(b),h=[],e=0,f=d.length;f>e;e++)c=d[e],h.push(g.length&&g[g.length-1].is(l.htmlTag)&&c.is(l.htmlTag)?g[g.length-1].append(c.contents()):g.push(c));return h}),k=g.reverse(),i=0,j=k.length;j>i;i++)e=k[i],f.insertNode(e[0]);return this.editor.selection.setRangeAtEndOf(g[0]),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b.prototype._convertEl=function(a){var b,c,d,e;return b=$(a),e=[],b.is(this.htmlTag)?(c=$("<p/>").append(b.html().replace("\n","<br/>")),e.push(c)):(d=!b.text()&&1===b.children().length&&b.children().is("br")?"\n":this.editor.formatter.clearHtml(b),c=$("<"+this.htmlTag+"/>").text(d),e.push(c)),e},b}(c),e=function(a){function b(){return I=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype._tpl='<div class="code-settings">\n  <div class="settings-field">\n    <select class="select-lang">\n      <option value="-1">选择程序语言</option>\n      <option value="c++">C++</option>\n      <option value="css">CSS</option>\n      <option value="coffeeScript">CoffeeScript</option>\n      <option value="html">Html,XML</option>\n      <option value="json">JSON</option>\n      <option value="java">Java</option>\n      <option value="js">JavaScript</option>\n      <option value="markdown">Markdown</option>\n      <option value="oc">Objective C</option>\n      <option value="php">PHP</option>\n      <option value="perl">Perl</option>\n      <option value="python">Python</option>\n      <option value="ruby">Ruby</option>\n      <option value="sql">SQL</option>\n    </select>\n  </div>\n</div>',b.prototype.render=function(){var a=this;return this.el.addClass("code-popover").append(this._tpl),this.selectEl=this.el.find(".select-lang"),this.selectEl.on("change",function(){var b;return a.lang=a.selectEl.val(),b=a.target.hasClass("selected"),a.target.removeClass().removeAttr("data-lang"),-1!==a.lang&&(a.target.addClass("lang-"+a.lang),a.target.attr("data-lang",a.lang)),b?a.target.addClass("selected"):void 0})},b.prototype.show=function(){var a;return a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.show.apply(this,a),this.lang=this.target.attr("data-lang"),null!=this.lang?this.selectEl.val(this.lang):void 0},b}(s),u.Toolbar.addButton(d),n=function(a){function b(){return J=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="link",b.prototype.icon="link",b.prototype.title="插入链接",b.prototype.htmlTag="a",b.prototype.disableTag="pre",b.prototype.render=function(){var a;return a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.render.apply(this,a),this.popover=new o(this.editor)},b.prototype.status=function(a){var b;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:null==a?this.active:(b=!0,!a.is(this.htmlTag)||a.is('[class^="simditor-"]')?(this.setActive(!1),b=!1):this.editor.selection.rangeAtEndOf(a)?(this.setActive(!0),b=!1):this.setActive(!0),b?this.popover.show(a):this.editor.util.isBlockNode(a)&&this.popover.hide(),this.active)},b.prototype.command=function(){var a,b,c,d,e,f,g,h,i,j,k=this;return h=this.editor.selection.getRange(),this.active?(c=$(h.commonAncestorContainer).closest("a"),j=document.createTextNode(c.text()),c.replaceWith(j),h.selectNode(j)):(i=h.startContainer,f=h.endContainer,e=this.editor.util.closestBlockEl(i),b=this.editor.util.closestBlockEl(f),a=$(h.extractContents()),g=this.editor.formatter.clearHtml(a.contents(),!1),c=$("<a/>",{href:"http://www.example.com",target:"_blank",text:g||"链接文字"}),e[0]===b[0]?h.insertNode(c[0]):(d=$("<p/>").append(c),h.insertNode(d[0])),h.selectNodeContents(c[0]),this.popover.one("popovershow",function(){return g?(k.popover.urlEl.focus(),k.popover.urlEl[0].select()):(k.popover.textEl.focus(),k.popover.textEl[0].select())})),this.editor.selection.selectRange(h),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b}(c),o=function(a){function b(){return K=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype._tpl='<div class="link-settings">\n  <div class="settings-field">\n    <label>文本</label>\n    <input class="link-text" type="text"/>\n    <a class="btn-unlink" href="javascript:;" title="取消链接" tabindex="-1"><span class="fa fa-unlink"></span></a>\n  </div>\n  <div class="settings-field">\n    <label>链接</label>\n    <input class="link-url" type="text"/>\n  </div>\n</div>',b.prototype.render=function(){var a=this;return this.el.addClass("link-popover").append(this._tpl),this.textEl=this.el.find(".link-text"),this.urlEl=this.el.find(".link-url"),this.unlinkEl=this.el.find(".btn-unlink"),this.textEl.on("keyup",function(b){return 13!==b.which?a.target.text(a.textEl.val()):void 0}),this.urlEl.on("keyup",function(b){return 13!==b.which?a.target.attr("href",a.urlEl.val()):void 0}),$([this.urlEl[0],this.textEl[0]]).on("keydown",function(b){return 13===b.which||27===b.which||!b.shiftKey&&9===b.which&&$(b.target).hasClass("link-url")?(b.preventDefault(),setTimeout(function(){var b;return b=document.createRange(),a.editor.selection.setRangeAfter(a.target,b),a.hide(),a.editor.trigger("valuechanged"),a.editor.trigger("selectionchanged")},0)):void 0}),this.unlinkEl.on("click",function(){var b,c;return c=document.createTextNode(a.target.text()),a.target.replaceWith(c),a.hide(),b=document.createRange(),a.editor.selection.setRangeAfter(c,b),a.editor.trigger("valuechanged"),a.editor.trigger("selectionchanged")})},b.prototype.show=function(){var a;return a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.show.apply(this,a),this.textEl.val(this.target.text()),this.urlEl.val(this.target.attr("href"))},b}(s),u.Toolbar.addButton(n),h=function(a){function b(a){var c=this;this.editor=a,null==this.editor.uploader&&(this.menu=!1),b.__super__.constructor.call(this,this.editor),this.defaultImage=this.editor.opts.defaultImage,this.maxWidth=this.editor.opts.maxImageWidth||this.editor.body.width(),this.maxHeight=this.editor.opts.maxImageHeight||$(window).height(),this.editor.body.on("click","img:not([data-non-image])",function(a){var b,d;return b=$(a.currentTarget),d=document.createRange(),d.selectNode(b[0]),c.editor.selection.selectRange(d),setTimeout(function(){return c.editor.body.focus(),c.editor.trigger("selectionchanged")},0),!1}),this.editor.body.on("mouseup","img:not([data-non-image])",function(){return!1}),this.editor.on("selectionchanged.image",function(){var a,b,d;return d=c.editor.selection.sel.getRangeAt(0),null!=d?(a=$(d.cloneContents()).contents(),1===a.length&&a.is("img:not([data-non-image])")?(b=$(d.startContainer).contents().eq(d.startOffset),c.popover.show(b)):c.popover.hide()):void 0})}return Y(b,a),b.prototype.name="image",b.prototype.icon="picture-o",b.prototype.title="插入图片",b.prototype.htmlTag="img",b.prototype.disableTag="pre, table",b.prototype.defaultImage="",b.prototype.maxWidth=0,b.prototype.maxHeight=0,b.prototype.menu=[{name:"upload-image",text:"本地图片"},{name:"external-image",text:"外链图片"}],b.prototype.render=function(){var a;return a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.render.apply(this,a),this.popover=new i(this)},b.prototype.renderMenu=function(){var a,c,d,e=this;return b.__super__.renderMenu.call(this),c=this.menuEl.find(".menu-item-upload-image"),a=null,d=function(){return a&&a.remove(),a=$('<input type="file" title="上传图片" name="upload_file" accept="image/*">').appendTo(c)},d(),c.on("click mousedown","input[name=upload_file]",function(a){return a.stopPropagation()}),c.on("change","input[name=upload_file]",function(){return e.editor.inputManager.focused?(e.editor.uploader.upload(a,{inline:!0}),d()):e.editor.inputManager.lastCaretPosition&&(e.editor.one("focus",function(){return e.editor.uploader.upload(a,{inline:!0}),d()}),e.editor.undoManager.caretPosition(e.editor.inputManager.lastCaretPosition)),e.wrapper.removeClass("menu-on")}),this._initUploader()},b.prototype._initUploader=function(){var a=this;return null==this.editor.uploader?void this.el.find(".btn-upload").remove():(this.editor.uploader.on("beforeupload",function(b,c){var d;if(c.inline)return c.img?d=$(c.img):(d=a.createImage(c.name),d.click(),c.img=d),d.addClass("uploading"),a.editor.uploader.readImageFile(c.obj,function(b){var c;if(d.hasClass("uploading"))return c=b?b.src:a.defaultImage,a.loadImage(d,c,function(){return a.popover.refresh(),a.popover.srcEl.val("正在上传...").prop("disabled",!0)})})}),this.editor.uploader.on("uploadprogress",function(a,b,c,d){var e,f;if(b.inline)return f=c/d,f=(100*f).toFixed(0),f>99&&(f=99),e=b.img.data("mask"),e?e.find("span").text(f):void 0}),this.editor.uploader.on("uploadsuccess",function(b,c,d){var e;if(c.inline)return e=c.img.removeClass("uploading"),a.loadImage(e,d.file_path,function(){return a.popover.srcEl.prop("disabled",!1),e.click(),a.editor.trigger("valuechanged"),a.editor.uploader.trigger("uploadready",[c,d])})}),this.editor.uploader.on("uploaderror",function(b,c,d){var e,f,g;if(c.inline&&"abort"!==d.statusText){if(d.responseText){try{g=$.parseJSON(d.responseText),f=g.msg}catch(h){b=h,f="上传出错了"}"undefined"!=typeof simple&&null!==simple&&null!=simple.message?simple.message(f):alert(f)}return e=c.img.removeClass("uploading"),a.loadImage(e,a.defaultImage,function(){return a.popover.refresh(),a.popover.srcEl.val(e.attr("src")).prop("disabled",!1),a.editor.trigger("valuechanged")})}}))},b.prototype.status=function(a){return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:void 0},b.prototype.loadImage=function(a,b,c){var d,e,f,g,h=this;return d=a.data("mask"),d||(d=$('<div class="simditor-image-loading"><span></span></div>').appendTo(this.editor.wrapper),a.hasClass("uploading")&&this.editor.uploader.html5&&d.addClass("uploading"),a.data("mask",d)),f=a.position(),g=this.editor.toolbar.wrapper.outerHeight(),d.css({top:f.top+g,left:f.left,width:a.width(),height:a.height()}),e=new Image,e.onload=function(){var f,g;return g=e.width,f=e.height,g>h.maxWidth&&(f=h.maxWidth*f/g,g=h.maxWidth),f>h.maxHeight&&(g=h.maxHeight*g/f,f=h.maxHeight),a.attr({src:b,width:g,height:f,"data-image-size":e.width+","+e.height}),a.hasClass("uploading")?d.css({width:g,height:f}):(d.remove(),a.removeData("mask")),c(e)},e.onerror=function(){return c(!1),d.remove(),a.removeData("mask")},e.src=b},b.prototype.createImage=function(a){var b,c;return null==a&&(a="Image"),c=this.editor.selection.getRange(),c.deleteContents(),b=$("<img/>").attr("alt",a),c.insertNode(b[0]),b},b.prototype.command=function(a){var b,c=this;return b=this.createImage(),this.loadImage(b,a||this.defaultImage,function(){return c.editor.trigger("valuechanged"),b.click(),c.popover.one("popovershow",function(){return c.popover.srcEl.focus(),c.popover.srcEl[0].select()})})},b}(c),i=function(a){function b(a){this.button=a,b.__super__.constructor.call(this,this.button.editor)}return Y(b,a),b.prototype._tpl='<div class="link-settings">\n  <div class="settings-field">\n    <label>图片地址</label>\n    <input class="image-src" type="text"/>\n    <a class="btn-upload" href="javascript:;" title="上传图片" tabindex="-1">\n      <span class="fa fa-upload"></span>\n    </a>\n  </div>\n</div>',b.prototype.offset={top:6,left:-4},b.prototype.render=function(){var a=this;return this.el.addClass("image-popover").append(this._tpl),this.srcEl=this.el.find(".image-src"),this.srcEl.on("keydown",function(b){var c;return 13===b.which||27===b.which||9===b.which?(b.preventDefault(),13!==b.which||a.target.hasClass("uploading")?(a.button.editor.body.focus(),a.button.editor.selection.setRangeAfter(a.target),a.hide()):(c=a.srcEl.val(),a.button.loadImage(a.target,c,function(b){return b?(a.button.editor.body.focus(),a.button.editor.selection.setRangeAfter(a.target),a.hide(),a.editor.trigger("valuechanged")):void 0}))):void 0}),this.editor.on("valuechanged",function(){return a.active?a.refresh():void 0}),this._initUploader()},b.prototype._initUploader=function(){var a,b,c=this;return a=this.el.find(".btn-upload"),null==this.editor.uploader?void a.remove():(b=function(){return c.input&&c.input.remove(),c.input=$('<input type="file" title="上传图片" name="upload_file" accept="image/*">').appendTo(a)},b(),this.el.on("click mousedown","input[name=upload_file]",function(a){return a.stopPropagation()}),this.el.on("change","input[name=upload_file]",function(){return c.editor.uploader.upload(c.input,{inline:!0,img:c.target}),b()}))},b.prototype.show=function(){var a,c;return c=1<=arguments.length?Z.call(arguments,0):[],b.__super__.show.apply(this,c),a=this.target,this.srcEl.val(a.hasClass("uploading")?"正在上传":a.attr("src"))},b}(s),u.Toolbar.addButton(h),j=function(a){function b(){return L=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="indent",b.prototype.icon="indent",b.prototype.title="向右缩进（Tab）",b.prototype.status=function(){return!0},b.prototype.command=function(){return this.editor.util.indent()},b}(c),u.Toolbar.addButton(j),r=function(a){function b(){return M=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="outdent",b.prototype.icon="outdent",b.prototype.title="向左缩进（Shift + Tab）",b.prototype.status=function(){return!0},b.prototype.command=function(){return this.editor.util.outdent()},b}(c),u.Toolbar.addButton(r),g=function(a){function b(){return N=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="hr",b.prototype.icon="minus",b.prototype.title="分隔线",b.prototype.htmlTag="hr",b.prototype.status=function(){return!0},b.prototype.command=function(){var a,b,c,d;return d=this.editor.util.furthestBlockEl(),c=d.next(),c.length>0?this.editor.selection.save():b=$("<p/>").append(this.editor.util.phBr),a=$("<hr/>").insertAfter(d),b?(b.insertAfter(a),this.editor.selection.setRangeAtStartOf(b)):this.editor.selection.restore(),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b}(c),u.Toolbar.addButton(g),w=function(a){function b(){var a,c=this;a=1<=arguments.length?Z.call(arguments,0):[],b.__super__.constructor.apply(this,a),$.merge(this.editor.formatter._allowedTags,["tbody","tr","td","colgroup","col"]),$.extend(this.editor.formatter._allowedAttributes,{td:["rowspan","colspan"],col:["width"]}),this.editor.on("decorate",function(a,b){return b.find("table").each(function(a,b){return c.decorate($(b))
  })}),this.editor.on("undecorate",function(a,b){return b.find("table").each(function(a,b){return c.undecorate($(b))})}),this.editor.on("selectionchanged.table",function(){var a,b;return c.editor.body.find(".simditor-table td").removeClass("active"),b=c.editor.selection.getRange(),null!=b?(a=$(b.commonAncestorContainer),b.collapsed&&a.is(".simditor-table")&&(a=a.find(c.editor.selection.rangeAtStartOf(a)?"td:first":"td:last"),c.editor.selection.setRangeAtEndOf(a)),a.closest("td",c.editor.body).addClass("active")):void 0}),this.editor.on("blur.table",function(){return c.editor.body.find(".simditor-table td").removeClass("active")}),this.editor.inputManager.addKeystrokeHandler("38","td",function(a,b){var d,e,f;return e=b.parent("tr"),d=e.prev("tr"),d.length>0?(f=e.find("td").index(b),c.editor.selection.setRangeAtEndOf(d.find("td").eq(f)),!0):!0}),this.editor.inputManager.addKeystrokeHandler("40","td",function(a,b){var d,e,f;return e=b.parent("tr"),d=e.next("tr"),d.length>0?(f=e.find("td").index(b),c.editor.selection.setRangeAtEndOf(d.find("td").eq(f)),!0):!0})}return Y(b,a),b.prototype.name="table",b.prototype.icon="table",b.prototype.title="表格",b.prototype.htmlTag="table",b.prototype.disableTag="pre, li, blockquote",b.prototype.menu=!0,b.prototype.initResize=function(a){var b,c,d;return d=a.parent(".simditor-table"),b=a.find("colgroup"),b.length<1&&(b=$("<colgroup/>").prependTo(a),a.find("tr:first td").each(function(){var a;return a=$("<col/>").appendTo(b)}),this.refreshTableWidth(a)),c=$('<div class="simditor-resize-handle" contenteditable="false"></div>').appendTo(d),d.on("mousemove","td",function(a){var e,f,g,h,i,j;if(!d.hasClass("resizing"))return f=$(a.currentTarget),h=a.pageX-$(a.currentTarget).offset().left,5>h&&f.prev().length>0&&(f=f.prev()),f.next("td").length<1?void c.hide():(null!=(i=c.data("td"))?i.is(f):void 0)?void c.show():(g=f.parent().find("td").index(f),e=b.find("col").eq(g),(null!=(j=c.data("col"))?j.is(e):void 0)?void c.show():c.css("left",f.position().left+f.outerWidth()-5).data("td",f).data("col",e).show())}),d.on("mouseleave",function(){return c.hide()}),d.on("mousedown",".simditor-resize-handle",function(a){var b,c,e,f,g,h,i,j,k,l,m;return b=$(a.currentTarget),e=b.data("td"),c=b.data("col"),g=e.next("td"),f=c.next("col"),l=a.pageX,j=1*e.outerWidth(),k=1*g.outerWidth(),i=parseFloat(b.css("left")),m=e.closest("table").width(),h=50,$(document).on("mousemove.simditor-resize-table",function(a){var d,e,g;return d=a.pageX-l,e=j+d,g=k-d,h>e?(e=h,d=h-j,g=k-d):h>g&&(g=h,d=k-h,e=j+d),c.attr("width",e/m*100+"%"),f.attr("width",g/m*100+"%"),b.css("left",i+d)}),$(document).one("mouseup.simditor-resize-table",function(){return $(document).off(".simditor-resize-table"),d.removeClass("resizing")}),d.addClass("resizing"),!1})},b.prototype.decorate=function(a){return a.parent(".simditor-table").length>0&&this.undecorate(a),a.wrap('<div class="simditor-table"></div>'),this.initResize(a),a.parent()},b.prototype.undecorate=function(a){return a.parent(".simditor-table").length>0?a.parent().replaceWith(a):void 0},b.prototype.renderMenu=function(){var a=this;return $('<div class="menu-create-table">\n</div>\n<div class="menu-edit-table">\n  <ul>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="deleteRow"><span>删除行</span></a></li>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="insertRowAbove"><span>在上面插入行</span></a></li>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="insertRowBelow"><span>在下面插入行</span></a></li>\n    <li><span class="separator"></span></li>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="deleteCol"><span>删除列</span></a></li>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="insertColLeft"><span>在左边插入列</span></a></li>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="insertColRight"><span>在右边插入列</span></a></li>\n    <li><span class="separator"></span></li>\n    <li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;" data-param="deleteTable"><span>删除表格</span></a></li>\n  </ul>\n</div>').appendTo(this.menuWrapper),this.createMenu=this.menuWrapper.find(".menu-create-table"),this.editMenu=this.menuWrapper.find(".menu-edit-table"),this.createTable(6,6).appendTo(this.createMenu),this.createMenu.on("mouseenter","td",function(b){var c,d,e;return a.createMenu.find("td").removeClass("selected"),c=$(b.currentTarget),d=c.parent(),e=d.find("td").index(c)+1,d.prevAll("tr").addBack().find("td:lt("+e+")").addClass("selected")}),this.createMenu.on("mouseleave",function(a){return $(a.currentTarget).find("td").removeClass("selected")}),this.createMenu.on("mousedown","td",function(b){var c,d,e,f,g,h;return a.wrapper.removeClass("menu-on"),a.editor.inputManager.focused?(e=$(b.currentTarget),f=e.parent(),g=f.find("td").index(e)+1,h=f.prevAll("tr").length+1,d=a.createTable(h,g,!0),c=a.editor.util.closestBlockEl(),a.editor.util.isEmptyNode(c)?c.replaceWith(d):c.after(d),a.decorate(d),a.editor.selection.setRangeAtStartOf(d.find("td:first")),a.editor.trigger("valuechanged"),a.editor.trigger("selectionchanged"),!1):void 0})},b.prototype.createTable=function(a,b,c){var d,e,f,g,h,i,j,k;for(d=$("<table/>"),e=$("<tbody/>").appendTo(d),i=j=0;a>=0?a>j:j>a;i=a>=0?++j:--j)for(g=$("<tr/>").appendTo(e),h=k=0;b>=0?b>k:k>b;h=b>=0?++k:--k)f=$("<td/>").appendTo(g),c&&f.append(this.editor.util.phBr);return d},b.prototype.refreshTableWidth=function(a){var b,c;return c=a.width(),b=a.find("col"),a.find("tr:first td").each(function(a,d){var e;return e=b.eq(a),e.attr("width",$(d).outerWidth()/c*100+"%")})},b.prototype.setActive=function(a){return b.__super__.setActive.call(this,a),a?(this.createMenu.hide(),this.editMenu.show()):(this.createMenu.show(),this.editMenu.hide())},b.prototype.deleteRow=function(a){var b,c,d;return c=a.parent("tr"),c.siblings("tr").length<1?this.deleteTable(a):(b=c.next("tr"),b.length>0||(b=c.prev("tr")),d=c.find("td").index(a),c.remove(),this.editor.selection.setRangeAtEndOf(b.find("td").eq(d)))},b.prototype.insertRow=function(a,b){var c,d,e,f,g,h,i;for(null==b&&(b="after"),e=a.parent("tr"),d=e.closest("table"),f=0,d.find("tr").each(function(a,b){return f=Math.max(f,$(b).find("td").length)}),c=$("<tr/>"),g=i=1;f>=1?f>=i:i>=f;g=f>=1?++i:--i)$("<td/>").append(this.editor.util.phBr).appendTo(c);return e[b](c),h=e.find("td").index(a),this.editor.selection.setRangeAtStartOf(c.find("td").eq(h))},b.prototype.deleteCol=function(a){var b,c,d,e;return d=a.parent("tr"),d.siblings("tr").length<1&&a.siblings("td").length<1?this.deleteTable(a):(e=d.find("td").index(a),b=a.next("td"),b.length>0||(b=d.prev("td")),c=d.closest("table"),c.find("col").eq(e).remove(),c.find("tr").each(function(a,b){return $(b).find("td").eq(e).remove()}),this.refreshTableWidth(c),this.editor.selection.setRangeAtEndOf(b))},b.prototype.insertCol=function(a,b){var c,d,e,f,g,h,i,j,k=this;return null==b&&(b="after"),g=a.parent("tr"),h=g.find("td").index(a),f=a.closest("table"),c=f.find("col").eq(h),f.find("tr").each(function(a,c){var d;return d=$("<td/>").append(k.editor.util.phBr),$(c).find("td").eq(h)[b](d)}),d=$("<col/>"),c[b](d),i=f.width(),j=Math.max(parseFloat(c.attr("width"))/2,50/i*100),c.attr("width",j+"%"),d.attr("width",j+"%"),this.refreshTableWidth(f),e="after"===b?a.next("td"):a.prev("td"),this.editor.selection.setRangeAtStartOf(e)},b.prototype.deleteTable=function(a){var b,c;return c=a.closest(".simditor-table"),b=c.next("p"),c.remove(),b.length>0?this.editor.selection.setRangeAtStartOf(b):void 0},b.prototype.command=function(a){var b,c;if(c=this.editor.selection.getRange(),b=$(c.commonAncestorContainer).closest("td"),b.length>0){if("deleteRow"===a)this.deleteRow(b);else if("insertRowAbove"===a)this.insertRow(b,"before");else if("insertRowBelow"===a)this.insertRow(b);else if("deleteCol"===a)this.deleteCol(b);else if("insertColLeft"===a)this.insertCol(b,"before");else if("insertColRight"===a)this.insertCol(b);else{if("deleteTable"!==a)return;this.deleteTable(b)}return this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")}},b}(c),u.Toolbar.addButton(w),v=function(a){function b(){return O=b.__super__.constructor.apply(this,arguments)}return Y(b,a),b.prototype.name="strikethrough",b.prototype.icon="strikethrough",b.prototype.title="删除线文字",b.prototype.htmlTag="strike",b.prototype.disableTag="pre",b.prototype.status=function(a){var b;return null!=a&&this.setDisabled(a.is(this.disableTag)),this.disabled?!0:(b=document.queryCommandState("strikethrough")===!0,this.setActive(b),b)},b.prototype.command=function(){return document.execCommand("strikethrough"),this.editor.trigger("valuechanged"),this.editor.trigger("selectionchanged")},b}(c),u.Toolbar.addButton(v)}).call(this);