Vergleich jscripts/sceditor/jquery.sceditor.bbcode.min.js - 1.8.3 - 1.8.30

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 1Zeile 1
/* SCEditor v1.4.5 | (C) 2011-2013, Sam Clarke | sceditor.com/license */
!function(a,b,c){"use strict";var d={html:'<!DOCTYPE html><html><head><style>.ie * {min-height: auto !important}</style><meta http-equiv="Content-Type" content="text/html;charset={charset}" /><link rel="stylesheet" type="text/css" href="{style}" /></head><body contenteditable="true" {spellcheck}></body></html>',toolbarButton:'<a class="sceditor-button sceditor-button-{name}" data-sceditor-command="{name}" unselectable="on"><div unselectable="on">{dispName}</div></a>',emoticon:'<img src="{url}" data-sceditor-emoticon="{key}" alt="{key}" title="{tooltip}" />',fontOpt:'<a class="sceditor-font-option" href="#" data-font="{font}"><font face="{font}">{font}</font></a>',sizeOpt:'<a class="sceditor-fontsize-option" data-size="{size}" href="#"><font size="{size}">{size}</font></a>',pastetext:'<div><label for="txt">{label}</label> <textarea cols="20" rows="7" id="txt"></textarea></div><div><input type="button" class="button" value="{insert}" /></div>',table:'<div><label for="rows">{rows}</label><input type="text" id="rows" value="2" /></div><div><label for="cols">{cols}</label><input type="text" id="cols" value="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',image:'<div><label for="link">{url}</label> <input type="text" id="image" value="http://" /></div><div><label for="width">{width}</label> <input type="text" id="width" size="2" /></div><div><label for="height">{height}</label> <input type="text" id="height" size="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',email:'<div><label for="email">{label}</label> <input type="text" id="email" /></div><div><input type="button" class="button" value="{insert}" /></div>',link:'<div><label for="link">{url}</label> <input type="text" id="link" value="http://" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{ins}" /></div>',youtubeMenu:'<div><label for="link">{label}</label> <input type="text" id="link" value="http://" /></div><div><input type="button" class="button" value="{insert}" /></div>',youtube:'<iframe width="560" height="315" src="http://www.youtube.com/embed/{id}?wmode=opaque" data-youtube-id="{id}" frameborder="0" allowfullscreen></iframe>'},e=function(b,c,e){var f=d[b];return a.each(c,function(a,b){f=f.replace(new RegExp("\\{"+a+"\\}","g"),b)}),e&&(f=a(f)),f};a.sceditor=function(d,f){var 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,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb,ib,jb=a.sceditor.ie,kb=jb&&11>jb,lb=this,mb=d.get?d.get(0):d,nb=a(mb),ob=[],pb=[],qb=[],rb=[],sb={},tb=[];lb.commands=a.extend(!0,{},f.commands||a.sceditor.commands),lb.opts=f=a.extend({},a.sceditor.defaultOptions,f),A=function(){nb.data("sceditor",lb),a.each(f,function(b,c){a.isPlainObject(c)&&(f[b]=a.extend(!0,{},c))}),f.locale&&"en"!==f.locale&&G(),g=a('<div class="sceditor-container" />').insertAfter(nb).css("z-index",f.zIndex),jb&&g.addClass("ie ie"+jb),y=!!nb.attr("required"),nb.removeAttr("required"),F(),M(),H(),E(),K(),I(),J(),a.sceditor.isWysiwygSupported||lb.toggleSourceMode(),Z();var d=function(){a(b).unbind("load",d),f.autofocus&&cb(),f.autoExpand&&lb.expandToContent(),X(),t.call("ready")};a(b).load(d),c.readyState&&"complete"===c.readyState&&d()},F=function(){var b=f.plugins;b=b?b.toString().split(","):[],t=new a.sceditor.PluginManager(lb),a.each(b,function(b,c){t.register(a.trim(c))})},G=function(){var b;q=a.sceditor.locale[f.locale],q||(b=f.locale.split("-"),q=a.sceditor.locale[b[0]]),q&&q.dateFormat&&(f.dateFormat=q.dateFormat)},E=function(){var c,d;m=a("<textarea></textarea>").hide(),i=a('<iframe frameborder="0"></iframe>'),f.spellcheck||m.attr("spellcheck","false"),"https:"===b.location.protocol&&i.attr("src","javascript:false"),g.append(i).append(m),j=i[0],n=m[0],lb.dimensions(f.width||nb.width(),f.height||nb.height()),c=N(),c.open(),c.write(e("html",{spellcheck:f.spellcheck?"":'spellcheck="false"',charset:f.charset,style:f.style})),c.close(),l=a(c),k=a(c.body),lb.readOnly(!!f.readOnly),jb&&l.find("html").addClass("ie ie"+jb),(a.sceditor.ios||jb)&&(k.height("100%"),jb||k.bind("touchend",lb.focus)),r=new a.sceditor.rangeHelper(j.contentWindow),lb.val(nb.hide().val()),d=nb.attr("tabindex"),m.attr("tabindex",d),i.attr("tabindex",d)},I=function(){f.autoUpdate&&(k.bind("blur",lb.updateOriginal),m.bind("blur",lb.updateOriginal)),null===f.rtl&&(f.rtl="rtl"===m.css("direction")),lb.rtl(!!f.rtl),f.autoExpand&&l.bind("keyup",lb.expandToContent),f.resizeEnabled&&L(),g.attr("id",f.id),lb.emoticons(f.emoticonsEnabled)},J=function(){a(c).click(W),a(mb.form).bind("reset",T).submit(lb.updateOriginal),a(b).bind("resize orientationChanged",X),k.keypress(S).keydown(Q).keydown(R).keyup(_).bind("blur",hb).keyup(ib).bind("paste",O).bind(jb?"selectionchange":"keyup focus blur contextmenu mouseup touchend click",ab).bind("keydown keyup keypress focus blur contextmenu",V),f.emoticonsCompat&&b.getSelection&&k.keyup(eb),m.bind("blur",hb).keyup(ib).bind("keydown keyup keypress focus blur contextmenu",V).keydown(Q),l.mousedown(U).bind("blur",hb).bind(jb?"selectionchange":"focus blur contextmenu mouseup click",ab).bind("beforedeactivate keyup",D).keyup(_).focus(function(){p=null}),g.bind("selectionchanged",bb).bind("selectionchanged",Z).bind("selectionchanged valuechanged nodechanged",V)},H=function(){var b,c,d,i=lb.commands,j=(f.toolbarExclude||"").split(","),k=f.toolbar.split("|");h=a('<div class="sceditor-toolbar" unselectable="on" />'),a.each(k,function(f,g){b=a('<div class="sceditor-group" />'),a.each(g.split(","),function(f,g){!i[g]||a.inArray(g,j)>-1||(d=i[g].shortcut?" ("+i[g].shortcut+")":"",c=e("toolbarButton",{name:g,dispName:lb._(i[g].tooltip||g)+d},!0),c.data("sceditor-txtmode",!!i[g].txtExec),c.data("sceditor-wysiwygmode",!!i[g].exec),c.click(function(){var b=a(this);return b.hasClass("disabled")||C(b,i[g]),Z(),!1}),i[g].tooltip&&c.attr("title",lb._(i[g].tooltip)),i[g].exec||c.addClass("disabled"),i[g].shortcut&&(lb.addShortcut(i[g].shortcut,g),c.attr("title",c.attr("title")+d)),b.append(c))}),b[0].firstChild&&h.append(b)}),a(f.toolbarContainer||g).append(h)},K=function(){a.each(lb.commands,function(b,c){c.keyPress&&ob.push(c.keyPress),c.forceNewLineAfter&&a.isArray(c.forceNewLineAfter)&&(qb=a.merge(qb,c.forceNewLineAfter)),c.state?rb.push({name:b,state:c.state}):"string"==typeof c.exec&&rb.push({name:b,state:c.exec})}),_()},L=function(){var d,e,h,i,j,k,l=a('<div class="sceditor-grip" />'),m=a('<div class="sceditor-resize-cover" />'),n=0,o=0,p=0,q=0,r=g.width(),s=g.height(),t=!1,u=lb.rtl();d=f.resizeMinHeight||s/1.5,e=f.resizeMaxHeight||2.5*s,h=f.resizeMinWidth||r/1.25,i=f.resizeMaxWidth||1.25*r,j=function(a){"touchmove"===a.type&&(a=b.event);var c=q+(a.pageY-o),j=u?p-(a.pageX-n):p+(a.pageX-n);i>0&&j>i&&(j=i),e>0&&c>e&&(c=e),(!f.resizeWidth||h>j||i>0&&j>i)&&(j=!1),(!f.resizeHeight||d>c||e>0&&c>e)&&(c=!1),(j||c)&&(lb.dimensions(j,c),7>jb&&g.height(c)),a.preventDefault()},k=function(b){t&&(t=!1,m.hide(),g.removeClass("resizing").height("auto"),a(c).unbind("touchmove mousemove",j),a(c).unbind("touchend mouseup",k),b.preventDefault())},g.append(l),g.append(m.hide()),l.bind("touchstart mousedown",function(d){"touchstart"===d.type&&(d=b.event),n=d.pageX,o=d.pageY,p=g.width(),q=g.height(),t=!0,g.addClass("resizing"),m.show(),a(c).bind("touchmove mousemove",j),a(c).bind("touchend mouseup",k),7>jb&&g.height(q),d.preventDefault()})},M=function(){var b,d=f.emoticons,e=f.emoticonsRoot;a.isPlainObject(d)&&f.emoticonsEnabled&&a.each(d,function(f,g){a.each(g,function(a,g){e&&(g={url:e+(g.url||g),tooltip:g.tooltip||a},d[f][a]=g),b=c.createElement("img"),b.src=g.url||g,pb.push(b)})})},cb=function(){var b,c,d,e=l[0],h=k[0],i=!!f.autofocusEnd;if(g.is(":visible")){if(lb.sourceMode())d=n.value.length,n.setSelectionRange?n.setSelectionRange(d,d):n.createTextRange&&(b=n.createTextRange(),b.moveEnd("character",d),b.moveStart("character",d),r.selectRange(b));else{if(a.sceditor.dom.removeWhiteSpace(h),i)for((c=h.lastChild)||k.append(c=e.createElement("div"));c.lastChild;)c=c.lastChild,/br/i.test(c.nodeName)&&c.previousSibling&&(c=c.previousSibling);else c=h.firstChild;e.createRange?(b=e.createRange(),/br/i.test(c.nodeName)?b.setStartBefore(c):b.selectNodeContents(c),b.collapse(!1)):(b=h.createTextRange(),b.moveToElementText(3!==c.nodeType?c:c.parentNode),b.collapse(!1)),r.selectRange(b),i&&(l.scrollTop(h.scrollHeight),k.scrollTop(h.scrollHeight))}lb.focus()}},lb.readOnly=function(a){return"boolean"!=typeof a?"readonly"===m.attr("readonly"):(k[0].contentEditable=!a,a?m.attr("readonly","readonly"):m.removeAttr("readonly"),Y(a),this)},lb.rtl=function(a){var b=a?"rtl":"ltr";return"boolean"!=typeof a?"rtl"===m.attr("dir"):(k.attr("dir",b),m.attr("dir",b),g.removeClass("rtl").removeClass("ltr").addClass(b),this)},Y=function(b){var c=lb.inSourceMode();h.find(".sceditor-button").removeClass("disabled").each(function(){var d=a(this);b===!0||c&&!d.data("sceditor-txtmode")?d.addClass("disabled"):c||d.data("sceditor-wysiwygmode")||d.addClass("disabled")})},lb.width=function(a,b){return a||0===a?(lb.dimensions(a,null,b),this):g.width()},lb.dimensions=function(b,d,e){var j=8>jb||c.documentMode<8?2:0;return b=b||0===b?b:!1,d=d||0===d?d:!1,b===!1&&d===!1?{width:lb.width(),height:lb.height()}:("undefined"==typeof i.data("outerWidthOffset")&&lb.updateStyleCache(),b!==!1&&(e!==!1&&(f.width=b),d===!1&&(d=g.height(),e=!1),g.width(b),b&&b.toString().indexOf("%")>-1&&(b=g.width()),i.width(b-i.data("outerWidthOffset")),m.width(b-m.data("outerWidthOffset")),a.sceditor.ios&&k&&k.width(b-i.data("outerWidthOffset")-(k.outerWidth(!0)-k.width()))),d!==!1&&(e!==!1&&(f.height=d),d&&d.toString().indexOf("%")>-1&&(d=g.height(d).height(),g.height("auto")),d-=f.toolbarContainer?0:h.outerHeight(!0),i.height(d-i.data("outerHeightOffset")),m.height(d-j-m.data("outerHeightOffset"))),this)},lb.updateStyleCache=function(){i.data("outerWidthOffset",i.outerWidth(!0)-i.width()),m.data("outerWidthOffset",m.outerWidth(!0)-m.width()),i.data("outerHeightOffset",i.outerHeight(!0)-i.height()),m.data("outerHeightOffset",m.outerHeight(!0)-m.height())},lb.height=function(a,b){return a||0===a?(lb.dimensions(null,a,b),this):g.height()},lb.maximize=function(b){return"undefined"==typeof b?g.is(".sceditor-maximize"):(b=!!b,7>jb&&a("html, body").toggleClass("sceditor-maximize",b),g.toggleClass("sceditor-maximize",b),lb.width(b?"100%":f.width,!1),lb.height(b?"100%":f.height,!1),this)},lb.expandToContent=function(a){var b=g.height(),c=k[0].scrollHeight||l[0].documentElement.scrollHeight,d=b-i.height(),e=f.resizeMaxHeight||2*(f.height||nb.height());c+=d,a!==!0&&c>e&&(c=e),c>b&&lb.height(c)},lb.destroy=function(){t&&(t.destroy(),r=null,p=null,t=null,a(c).unbind("click",W),a(b).unbind("resize orientationChanged",X),a(mb.form).unbind("reset",T).unbind("submit",lb.updateOriginal),k.unbind(),l.unbind().find("*").remove(),m.unbind().remove(),h.remove(),g.unbind().find("*").unbind().remove(),g.remove(),nb.removeData("sceditor").removeData("sceditorbbcode").show(),y&&nb.attr("required","required"))},lb.createDropDown=function(b,c,d,e){var g,h=o&&o.is(".sceditor-"+c);lb.closeDropDown(),h||(e!==!1&&a(d).find(":not(input,textarea)").filter(function(){return 1===this.nodeType}).attr("unselectable","on"),g={top:b.offset().top,left:b.offset().left,marginTop:b.outerHeight()},a.extend(g,f.dropDownCss),o=a('<div class="sceditor-dropdown sceditor-'+c+'" />').css(g).append(d).appendTo(a("body")).on("click focusin",function(a){a.stopPropagation()}))},W=function(a){3!==a.which&&lb.closeDropDown()},O=function(a){var b,d,e,g=k[0],h=l[0],i=0,j=c.createElement("div"),m=h.createDocumentFragment();if(f.disablePasting)return!1;if(f.enablePasteFiltering){if(r.saveRange(),c.body.appendChild(j),a&&a.clipboardData&&a.clipboardData.getData&&((b=a.clipboardData.getData("text/html"))||(b=a.clipboardData.getData("text/plain"))))return j.innerHTML=b,P(g,j),!1;for(e=k.scrollTop()||l.scrollTop();g.firstChild;)m.appendChild(g.firstChild);return d=function(a,b){if(a.childNodes.length>0||i>25){for(;a.firstChild;)b.appendChild(a.firstChild);for(;m.firstChild;)a.appendChild(m.firstChild);k.scrollTop(e),l.scrollTop(e),b.childNodes.length>0?P(a,b):r.restoreRange()}else i++,setTimeout(function(){d(a,b)},20)},d(g,j),lb.focus(),!0}},P=function(b,c){a.sceditor.dom.fixNesting(c);var d=c.innerHTML;t.hasHandler("toSource")&&(d=t.callOnlyFirst("toSource",d,a(c))),c.parentNode.removeChild(c),t.hasHandler("toWysiwyg")&&(d=t.callOnlyFirst("toWysiwyg",d,!0)),r.restoreRange(),lb.wysiwygEditorInsertHtml(d,null,!0)},lb.closeDropDown=function(a){o&&(o.unbind().remove(),o=null),a===!0&&lb.focus()},N=function(){return j.contentDocument?j.contentDocument:j.contentWindow&&j.contentWindow.document?j.contentWindow.document:j.document?j.document:null},lb.wysiwygEditorInsertHtml=function(b,c,d){var e,f,g,h=i.height();lb.focus(),(d||!a(v).is("code")&&0===a(v).parents("code").length)&&(r.insertHTML(b,c),r.saveRange(),B(k[0]),e=k.find("#sceditor-end-marker").show(),f=k.scrollTop()||l.scrollTop(),g=a.sceditor.dom.getOffset(e[0]).top+1.5*e.outerHeight(!0)-h,e.hide(),(g>f||f>g+h)&&(k.scrollTop(g),l.scrollTop(g)),gb(!1),r.restoreRange(),_())},lb.wysiwygEditorInsertText=function(b,c){lb.wysiwygEditorInsertHtml(a.sceditor.escapeEntities(b),a.sceditor.escapeEntities(c))},lb.insertText=function(a,b){return lb.inSourceMode()?lb.sourceEditorInsertText(a,b):lb.wysiwygEditorInsertText(a,b),this},lb.sourceEditorInsertText=function(a,b){var d,e,f,g,h;h=n.scrollTop,n.focus(),"undefined"!=typeof n.selectionStart?(e=n.selectionStart,f=n.selectionEnd,g=a.length,b&&(a+=n.value.substring(e,f)+b),n.value=n.value.substring(0,e)+a+n.value.substring(f,n.value.length),n.selectionStart=e+a.length-(b?b.length:0),n.selectionEnd=n.selectionStart):"undefined"!=typeof c.selection.createRange?(d=c.selection.createRange(),b&&(a+=d.text+b),d.text=a,b&&d.moveEnd("character",0-b.length),d.moveStart("character",d.End-d.Start),d.select()):n.value+=a+b,n.scrollTop=h,n.focus(),gb()},lb.getRangeHelper=function(){return r},lb.sourceEditorCaret=function(a){var b={};return"undefined"!=typeof n.selectionStart?a?(n.selectionStart=a.start,n.selectionEnd=a.end):(b.start=n.selectionStart,b.end=n.selectionEnd):(range=c.selection.createRange(),a?(range.moveStart("character",a.start),range.moveEnd("character",a.end),range.select()):(b.start=range.Start,b.end=range.End)),a?this:b},lb.val=function(a,b){return"string"==typeof a?(lb.inSourceMode()?lb.setSourceEditorValue(a):(b!==!1&&t.hasHandler("toWysiwyg")&&(a=t.callOnlyFirst("toWysiwyg",a)),lb.setWysiwygEditorValue(a)),this):lb.inSourceMode()?lb.getSourceEditorValue(!1):lb.getWysiwygEditorValue()},lb.insert=function(b,c,d,e,f){if(lb.inSourceMode())lb.sourceEditorInsertText(b,c);else{if(c){var g=lb.getRangeHelper().selectedHtml(),h=a("<div>").appendTo(a("body")).hide().html(g);d!==!1&&t.hasHandler("toSource")&&(g=t.callOnlyFirst("toSource",g,h)),h.remove(),b+=g+c}d!==!1&&t.hasHandler("toWysiwyg")&&(b=t.callOnlyFirst("toWysiwyg",b,!0)),d!==!1&&f===!0&&(b=b.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")),lb.wysiwygEditorInsertHtml(b)}return this},lb.getWysiwygEditorValue=function(b){var c,d,e=r.hasSelection();return e?r.saveRange():p&&p.getBookmark&&(d=p.getBookmark()),a.sceditor.dom.fixNesting(k[0]),c=k.html(),b!==!1&&t.hasHandler("toSource")&&(c=t.callOnlyFirst("toSource",c,k)),e?(r.restoreRange(),p=null):d&&(p.moveToBookmark(d),p=null),c},lb.getBody=function(){return k},lb.getContentAreaContainer=function(){return i},lb.getSourceEditorValue=function(a){var b=m.val();return a!==!1&&t.hasHandler("toWysiwyg")&&(b=t.callOnlyFirst("toWysiwyg",b)),b},lb.setWysiwygEditorValue=function(a){a||(a="<p>"+(jb?"":"<br />")+"</p>"),k[0].innerHTML=a,B(k[0]),_(),gb()},lb.setSourceEditorValue=function(a){m.val(a),gb()},lb.updateOriginal=function(){nb.val(lb.val())},B=function(b){if(f.emoticonsEnabled&&!a(b).parents("code").length){var c=b.ownerDocument,d=[],g=[],h=a.extend({},f.emoticons.more,f.emoticons.dropdown,f.emoticons.hidden);a.each(h,function(b){f.emoticonsCompat&&(g[b]=new RegExp("(>|^|\\s| | | | |&nbsp;)"+a.sceditor.regexEscape(b)+"(\\s|$|<| | | | |&nbsp;)")),d.push(b)}),function i(b){for(b=b.firstChild;null!=b;){var j,k,l,m,n,o,p,q=b.parentNode,r=b.nodeValue;if(3!==b.nodeType)a(b).is("code")||i(b);else if(r)for(n=d.length;n--;)k=d[n],p=f.emoticonsCompat?r.search(g[k]):r.indexOf(k),p>-1&&(o=b.nextSibling,l=h[k],j=r.substr(p).split(k),r=r.substr(0,p)+j.shift(),b.nodeValue=r,m=a.sceditor.dom.parseHTML(e("emoticon",{key:k,url:l.url||l,tooltip:l.tooltip||k}),c),q.insertBefore(m[0],o),q.insertBefore(c.createTextNode(j.join(k)),o));b=b.nextSibling}}(b),f.emoticonsCompat&&(tb=k.find("img[data-sceditor-emoticon]"))}},lb.inSourceMode=function(){return g.hasClass("sourceMode")},lb.sourceMode=function(a){return"boolean"!=typeof a?lb.inSourceMode():((lb.inSourceMode()&&!a||!lb.inSourceMode()&&a)&&lb.toggleSourceMode(),this)},lb.toggleSourceMode=function(){(a.sceditor.isWysiwygSupported||!lb.inSourceMode())&&(lb.blur(),lb.inSourceMode()?lb.setWysiwygEditorValue(lb.getSourceEditorValue()):lb.setSourceEditorValue(lb.getWysiwygEditorValue()),p=null,m.toggle(),i.toggle(),lb.inSourceMode()?g.removeClass("sourceMode").addClass("wysiwygMode"):g.removeClass("wysiwygMode").addClass("sourceMode"),Y(),Z())},$=function(){return n.focus(),null!=n.selectionStart?n.value.substring(n.selectionStart,n.selectionEnd):c.selection.createRange?c.selection.createRange().text:void 0},C=function(b,c){return lb.inSourceMode()?void(c.txtExec&&(a.isArray(c.txtExec)?lb.sourceEditorInsertText.apply(lb,c.txtExec):c.txtExec.call(lb,b,$()))):void(c.exec&&(a.isFunction(c.exec)?c.exec.call(lb,b):lb.execCommand(c.exec,c.hasOwnProperty("execParam")?c.execParam:null)))},D=function(){jb&&(p=r.selectedRange())},lb.execCommand=function(b,c){var d=!1,e=a(r.parentNode());if(lb.focus(),!e.is("code")&&0===e.parents("code").length){try{d=l[0].execCommand(b,!1,c)}catch(f){}!d&&lb.commands[b]&&lb.commands[b].errorMessage&&alert(lb._(lb.commands[b].errorMessage))}},ab=function(){var b=function(){r&&!r.compare(w)&&(w=r.cloneSelected(),g.trigger(a.Event("selectionchanged"))),x=!1};x||(x=!0,jb?b():setTimeout(b,100))},bb=function(){var b,c=r.parentNode();u!==c&&(b=u,u=c,v=r.getFirstBlockParent(c),g.trigger(a.Event("nodechanged",{oldNode:b,newNode:u})))},lb.currentNode=function(){return u},lb.currentBlockNode=function(){return v},Z=function(a){var b,c,d,e,f,g=l[0],i=rb.length,j=lb.sourceMode();if(lb.sourceMode()||lb.readOnly())h.find(".sceditor-button").removeClass("active");else for(f=a?a.newNode:r.parentNode(),d=r.getFirstBlockParent(f);i--;)if(b=0,c=rb[i],e=h.find(".sceditor-button-"+c.name),j&&!e.data("sceditor-txtmode"))e.addClass("disabled");else if(j||e.data("sceditor-wysiwygmode")){if("string"==typeof c.state)try{b=g.queryCommandEnabled(c.state)?0:-1,b>-1&&(b=g.queryCommandState(c.state)?1:0)}catch(k){}else b=c.state.call(lb,f,d);0>b?e.addClass("disabled"):e.removeClass("disabled"),b>0?e.addClass("active"):e.removeClass("active")}else e.addClass("disabled")},S=function(b){var c,d;if(!b.originalEvent.defaultPrevented){if(lb.closeDropDown(),c=a(u),13===b.which&&(c.is("code,blockquote,pre")||0!==c.parents("code,blockquote,pre").length))return p=null,lb.wysiwygEditorInsertHtml("<br />",null,!0),!1;if(!c.is("code")&&0===c.parents("code").length)for(d=ob.length;d--;)ob[d].call(lb,b,j,m)}},_=function(){var b,c,d;a.sceditor.dom.rTraverse(k[0],function(e){return b=e.nodeName.toLowerCase(),a.inArray(b,qb)>-1&&(c=!0),3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||"br"===b||kb&&!e.firstChild&&!a.sceditor.dom.isInline(e,!1)?(c&&(d=k[0].ownerDocument.createElement("div"),d.className="sceditor-nlf",d.innerHTML=kb?"":"<br />",k[0].appendChild(d)),!1):void 0})},T=function(){lb.val(nb.val())},U=function(){lb.closeDropDown(),p=null},X=function(){var a=f.height,b=f.width;lb.maximize()?lb.dimensions("100%","100%",!1):(a&&a.toString().indexOf("%")>-1||b&&b.toString().indexOf("%")>-1)&&lb.dimensions(b,a)},lb._=function(){var a,b=arguments;return q&&q[b[0]]&&(b[0]=q[b[0]]),b[0].replace(/\{(\d+)\}/g,function(c,d){return b[d-0+1]!==a?b[d-0+1]:"{"+d+"}"})},V=function(b){var c,d=a.extend({},b);t.call(d.type+"Event",b,lb),delete d.type,c=a.Event((b.target===n?"scesrc":"scewys")+b.type,d),g.trigger(c,lb),c.isDefaultPrevented()&&b.preventDefault(),c.isImmediatePropagationStopped()&&c.stopImmediatePropagation(),c.isPropagationStopped()&&c.stopPropagation()},lb.bind=function(b,c,d,e){b=b.split(" ");for(var f=b.length;f--;)a.isFunction(c)&&(d||g.bind("scewys"+b[f],c),e||g.bind("scesrc"+b[f],c),"valuechanged"===b[f]&&(gb.hasHandler=!0));return this},lb.unbind=function(b,c,d,e){b=b.split(" ");for(var f=b.length;f--;)a.isFunction(c)&&(d||g.unbind("scewys"+b[f],c),e||g.unbind("scesrc"+b[f],c));return this},lb.blur=function(b,c,d){return a.isFunction(b)?lb.bind("blur",b,c,d):lb.sourceMode()?m.blur():(s||(s=a('<input style="position:absolute;width:0;height:0;opacity:0;border:0;padding:0;filter:alpha(opacity=0)" type="text" />').appendTo(g)),s.removeAttr("disabled").show().focus().blur().hide().attr("disabled","disabled")),this},lb.focus=function(b,c,d){return a.isFunction(b)?lb.bind("focus",b,c,d):lb.inSourceMode()?n.focus():(j.contentWindow.focus(),k[0].focus(),p&&(r.selectRange(p),p=null)),this},lb.keyDown=function(a,b,c){return lb.bind("keydown",a,b,c)},lb.keyPress=function(a,b,c){return lb.bind("keypress",a,b,c)},lb.keyUp=function(a,b,c){return lb.bind("keyup",a,b,c)},lb.nodeChanged=function(a){return lb.bind("nodechanged",a,!1,!0)},lb.selectionChanged=function(a){return lb.bind("selectionchanged",a,!1,!0)},lb.valueChanged=function(a,b,c){return lb.bind("valuechanged",a,b,c)},db=function(b){var c=0,d=String.fromCharCode(b.which);if(!a(v).is("code")&&!a(v).parents("code").length)return lb.emoticonsCache||(lb.emoticonsCache=[],a.each(a.extend({},f.emoticons.more,f.emoticons.dropdown,f.emoticons.hidden),function(a,b){lb.emoticonsCache[c++]=[a,e("emoticon",{key:a,url:b.url||b,tooltip:b.tooltip||a})]}),lb.emoticonsCache.sort(function(a,b){return a[0].length-b[0].length}),lb.longestEmoticonCode=lb.emoticonsCache[lb.emoticonsCache.length-1][0].length),lb.getRangeHelper().raplaceKeyword(lb.emoticonsCache,!0,!0,lb.longestEmoticonCode,f.emoticonsCompat,d)?(f.emoticonsCompat&&(tb=k.find("img[data-sceditor-emoticon]")),/^\s$/.test(d)&&f.emoticonsCompat):void 0},eb=function(){if(tb.length){var b,c,d,e,f,g,h=lb.currentBlockNode(),i=!1,j=/[^\s\xA0\u2002\u2003\u2009\u00a0]+/;tb=a.map(tb,function(k){return k&&k.parentNode?a.contains(h,k)?(b=k.previousSibling,c=k.nextSibling,f=b.nodeValue,null===f&&(f=b.innerText||""),b&&j.test(b.nodeValue.slice(-1))||c&&j.test((c.nodeValue||"")[0])?(d=k.parentNode,e=r.cloneSelected(),g=e.startContainer,f+=a(k).data("sceditor-emoticon"),g===c?i=f.length+e.startOffset:g===h&&h.childNodes[e.startOffset]===c?i=f.length:g===b&&(i=e.startOffset),c&&3===c.nodeType||(c=d.insertBefore(d.ownerDocument.createTextNode(""),c)),c.insertData(0,f),d.removeChild(b),d.removeChild(k),i!==!1&&(e.setStart(c,i),e.collapse(!0),r.selectRange(e)),null):k):k:null})}},lb.emoticons=function(b){return b||b===!1?(f.emoticonsEnabled=b,b?(k.keypress(db),lb.sourceMode()||(r.saveRange(),B(k[0]),tb=k.find("img[data-sceditor-emoticon]"),gb(!1),r.restoreRange())):(k.find("img[data-sceditor-emoticon]").replaceWith(function(){return a(this).data("sceditor-emoticon")}),tb=[],k.unbind("keypress",db),gb()),this):f.emoticonsEnabled},lb.css=function(b){return z||(z=a('<style id="#inline" />').appendTo(l.find("head"))[0]),"string"!=typeof b?z.styleSheet?z.styleSheet.cssText:z.innerHTML:(z.styleSheet?z.styleSheet.cssText=b:z.innerHTML=b,this)},Q=function(a){var b=[],c={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},d={8:"backspace",9:"tab",13:"enter",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"win",92:"win",93:"select",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},e={109:"-",110:"del",111:"/",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},f=a.which,g=d[f]||String.fromCharCode(f).toLowerCase();return a.ctrlKey&&b.push("ctrl"),a.altKey&&b.push("alt"),a.shiftKey&&(b.push("shift"),e[f]?g=e[f]:c[g]&&(g=c[g])),g&&(16>f||f>18)&&b.push(g),b=b.join("+"),sb[b]?sb[b].call(lb):void 0},lb.addShortcut=function(a,b){return a=a.toLowerCase(),sb[a]="string"==typeof b?function(){return C(h.find(".sceditor-button-"+b),lb.commands[b]),!1}:b,this},lb.removeShortcut=function(a){return delete sb[a.toLowerCase()],this},R=function(c){var d,e,g,h,i;if(!jb&&!f.disableBlockRemove&&8===c.which&&(h=r.selectedRange())&&(b.getSelection?(d=h.startContainer,e=h.startOffset):(d=h.parentElement(),g=l[0].selection.createRange(),g.moveToElementText(d),g.setEndPoint("EndToStart",h),e=g.text.length),0===e&&(i=fb()))){for(;d!==i;){for(;d.previousSibling;)if(d=d.previousSibling,3!==d.nodeType||d.nodeValue)return;if(!(d=d.parentNode))return}if(i&&!a(i).is("body"))return lb.clearBlockFormatting(i),!1}},fb=function(){for(var b=v;!a.sceditor.dom.hasStyling(b);)if(!(b=b.parentNode)||a(b).is("body"))return;return b},lb.clearBlockFormatting=function(b){return b=b||fb(),!b||a(b).is("body")?this:(r.saveRange(),p=null,b.className="",a(b).attr("style",""),a(b).is("p,div")||a.sceditor.dom.convertElement(b,"p"),r.restoreRange(),this)},gb=function(b){if(t.hasHandler("valuechangedEvent")||gb.hasHandler){var c,d=lb.sourceMode(),e=!d&&r.hasSelection();b=b!==!1&&!l[0].getElementById("sceditor-start-marker"),ib.timer&&(clearTimeout(ib.timer),ib.timer=!1),e&&b&&r.saveRange(),c=k.html(),c!==gb.lastHtmlValue&&(gb.lastHtmlValue=c,g.trigger(a.Event("valuechanged",{rawValue:d?lb.val():c}))),e&&b&&r.removeMarkers()}},hb=function(){ib.timer&&gb()},ib=function(a){var b=a.which,c=ib.lastChar,d=13===c||32===c,e=8===c||46===c;ib.lastChar=b,13===b||32===b?d?ib.triggerNextChar=!0:gb():8===b||46===b?e?ib.triggerNextChar=!0:gb():ib.triggerNextChar&&(gb(),ib.triggerNextChar=!1),ib.timer&&clearTimeout(ib.timer),ib.timer=setTimeout(function(){gb()},1500)},A()},a.sceditor.ie=function(){var a,d=3,e=c.createElement("div"),f=e.getElementsByTagName("i");do e.innerHTML="<!--[if gt IE "+ ++d+"]><i></i><![endif]-->";while(f[0]);return c.documentMode&&c.all&&b.atob&&(d=10),4===d&&c.documentMode&&(d=11),d>4?d:a}(),a.sceditor.ios=/iPhone|iPod|iPad| wosbrowser\//i.test(navigator.userAgent),a.sceditor.isWysiwygSupported=function(){var b,c,d=a('<div contenteditable="true">')[0].contentEditable,e="undefined"!=typeof d&&"inherit"!==d,f=navigator.userAgent;return e?(c=/Opera Mobi|Opera Mini/i.test(f),/Android/i.test(f)&&(c=!0,/Safari/.test(f)&&(b=/Safari\/(\d+)/.exec(f),c=b&&b[1]?b[1]<534:!0)),/ Silk\//i.test(f)&&(b=/AppleWebKit\/(\d+)/.exec(f),c=b&&b[1]?b[1]<534:!0),a.sceditor.ios&&(c=!/OS [5-9](_\d)+ like Mac OS X/i.test(f)),/fennec/i.test(f)&&(c=!1),/OneBrowser/i.test(f)&&(c=!1),"UCWEB"===navigator.vendor&&(c=!1),!c):!1}(),a.sceditor.regexEscape=function(a){return a.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")},a.sceditor.escapeEntities=function(a,b){return a?(a=a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ {2}/g," &nbsp;").replace(/\r\n|\r/g,"\n").replace(/\n/g,"<br />"),b&&(a=a.replace(/"/g,"&#34;").replace(/'/g,"&#39;")),a):a},a.sceditor.escapeUriScheme=function(a){var c,d=/^(?:https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(?:\/\/)/i,e=/^[^\/]*:/i,f=b.location;return a&&e.test(a)&&!d.test(a)?(c=f.pathname.split("/"),c.pop(),f.protocol+"://"+f.host+c.join("/")+"/"+a):a},a.sceditor.locale={},a.sceditor.commands={bold:{exec:"bold",tooltip:"Bold",shortcut:"ctrl+b"},italic:{exec:"italic",tooltip:"Italic",shortcut:"ctrl+i"},underline:{exec:"underline",tooltip:"Underline",shortcut:"ctrl+u"},strike:{exec:"strikethrough",tooltip:"Strikethrough"},subscript:{exec:"subscript",tooltip:"Subscript"},superscript:{exec:"superscript",tooltip:"Superscript"},left:{exec:"justifyleft",tooltip:"Align left"},center:{exec:"justifycenter",tooltip:"Center"},right:{exec:"justifyright",tooltip:"Align right"},justify:{exec:"justifyfull",tooltip:"Justify"},font:{_dropDown:function(b,c,d){for(var f=b.opts.fonts.split(","),g=a("<div />"),h=function(){return d(a(this).data("font")),b.closeDropDown(!0),!1},i=0;i<f.length;i++)g.append(e("fontOpt",{font:f[i]},!0).click(h));b.createDropDown(c,"font-picker",g)},exec:function(b){var c=this;a.sceditor.command.get("font")._dropDown(c,b,function(a){c.execCommand("fontname",a)})},tooltip:"Font Name"},size:{_dropDown:function(b,c,d){for(var f=a("<div />"),g=function(c){d(a(this).data("size")),b.closeDropDown(!0),c.preventDefault()},h=1;7>=h;h++)f.append(e("sizeOpt",{size:h},!0).click(g));b.createDropDown(c,"fontsize-picker",f)},exec:function(b){var c=this;a.sceditor.command.get("size")._dropDown(c,b,function(a){c.execCommand("fontsize",a)})},tooltip:"Font Size"},color:{_dropDown:function(b,c,d){var e,f,g,h,i={r:255,g:255,b:255},j=a("<div />"),k=b.opts.colors?b.opts.colors.split("|"):new Array(21),l=[],m=a.sceditor.command.get("color");if(!m._htmlCache){for(e=0;e<k.length;++e){for(h=k[e]?k[e].split(","):new Array(21),l.push('<div class="sceditor-color-column">'),f=0;f<h.length;++f)g=h[f]||"#"+i.r.toString(16)+i.g.toString(16)+i.b.toString(16),l.push('<a href="#" class="sceditor-color-option" style="background-color: '+g+'" data-color="'+g+'"></a>'),f%5===0?(i.g-=51,i.b=255):i.b-=51;l.push("</div>"),e%5===0?(i.r-=51,i.g=255,i.b=255):(i.g=255,i.b=255)}m._htmlCache=l.join("")}j.append(m._htmlCache).find("a").click(function(c){d(a(this).attr("data-color")),b.closeDropDown(!0),c.preventDefault()}),b.createDropDown(c,"color-picker",j)},exec:function(b){var c=this;a.sceditor.command.get("color")._dropDown(c,b,function(a){c.execCommand("forecolor",a)})},tooltip:"Font Color"},removeformat:{exec:"removeformat",tooltip:"Remove Formatting"},cut:{exec:"cut",tooltip:"Cut",errorMessage:"Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X"},copy:{exec:"copy",tooltip:"Copy",errorMessage:"Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C"},paste:{exec:"paste",tooltip:"Paste",errorMessage:"Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V"},pastetext:{exec:function(a){var b,c=this,d=e("pastetext",{label:c._("Paste your text inside the following box:"),insert:c._("Insert")},!0);d.find(".button").click(function(a){b=d.find("#txt").val(),b&&c.wysiwygEditorInsertText(b),c.closeDropDown(!0),a.preventDefault()}),c.createDropDown(a,"pastetext",d)},tooltip:"Paste Text"},bulletlist:{exec:"insertunorderedlist",tooltip:"Bullet list"},orderedlist:{exec:"insertorderedlist",tooltip:"Numbered list"},indent:{state:function(c,d){var e,f,g,h=a(d),i=h.parents("ul,ol,menu"),j=i.first();if(i.length>1||j.children().length>1)return 0;if(h.is("ul,ol,menu")){if(e=this.getRangeHelper().selectedRange(),!(b.Range&&e instanceof Range))return h.is("li,ul,ol,menu")?0:-1;if(f=e.startContainer.parentNode,g=e.endContainer.parentNode,f!==f.parentNode.firstElementChild||a(g).is("li")&&g!==g.parentNode.lastElementChild)return 0}return-1},exec:function(){var b=this,c=a(b.getRangeHelper().getFirstBlockParent());b.focus(),c.parents("ul,ol,menu")&&b.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(b,c){return a(c).is("ul,ol,menu")||a(c).parents("ul,ol,menu").length>0?0:-1},exec:function(){var b=this,c=a(b.getRangeHelper().getFirstBlockParent());c.parents("ul,ol,menu")&&b.execCommand("outdent")},tooltip:"Remove one indent"},table:{exec:function(b){var c=this,d=e("table",{rows:c._("Rows:"),cols:c._("Cols:"),insert:c._("Insert")},!0);
d.find(".button").click(function(b){var e=a.sceditor.ie,f=d.find("#rows").val()-0,g=d.find("#cols").val()-0,h="<table>";if(!(1>f||1>g)){for(var i=0;f>i;i++){h+="<tr>";for(var j=0;g>j;j++)h+="<td>"+(e&&11>e?"":"<br />")+"</td>";h+="</tr>"}h+="</table>",c.wysiwygEditorInsertHtml(h),c.closeDropDown(!0),b.preventDefault()}}),c.createDropDown(b,"inserttable",d)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{forceNewLineAfter:["code"],exec:function(){this.wysiwygEditorInsertHtml("<code>","<br /></code>")},tooltip:"Code"},image:{exec:function(a){var b=this,c=e("image",{url:b._("URL:"),width:b._("Width (optional):"),height:b._("Height (optional):"),insert:b._("Insert")},!0);c.find(".button").click(function(a){var d=c.find("#image").val(),e=c.find("#width").val(),f=c.find("#height").val(),g="";e&&(g+=' width="'+e+'"'),f&&(g+=' height="'+f+'"'),d&&"http://"!==d&&b.wysiwygEditorInsertHtml("<img"+g+' src="'+d+'" />'),b.closeDropDown(!0),a.preventDefault()}),b.createDropDown(a,"insertimage",c)},tooltip:"Insert an image"},email:{exec:function(a){var b=this,c=e("email",{label:b._("E-mail:"),insert:b._("Insert")},!0);c.find(".button").click(function(a){var d=c.find("#email").val();d&&(b.focus(),b.getRangeHelper().selectedHtml()?b.execCommand("createlink","mailto:"+d):b.wysiwygEditorInsertHtml('<a href="mailto:'+d+'">'+d+"</a>")),b.closeDropDown(!0),a.preventDefault()}),b.createDropDown(a,"insertemail",c)},tooltip:"Insert an email"},link:{exec:function(a){var b=this,c=e("link",{url:b._("URL:"),desc:b._("Description (optional):"),ins:b._("Insert")},!0);c.find(".button").click(function(a){var d=c.find("#link").val(),e=c.find("#des").val();d&&"http://"!==d&&(b.focus(),!b.getRangeHelper().selectedHtml()||e?(e||(e=d),b.wysiwygEditorInsertHtml('<a href="'+d+'">'+e+"</a>")):b.execCommand("createlink",d)),b.closeDropDown(!0),a.preventDefault()}),b.createDropDown(a,"insertlink",c)},tooltip:"Insert a link"},unlink:{state:function(){var b=a(this.currentNode());return b.is("a")||b.parents("a").length>0?0:-1},exec:function(){var b=a(this.currentNode()),c=b.is("a")?b:b.parents("a").first();c.length&&c.replaceWith(c.contents())},tooltip:"Unlink"},quote:{forceNewLineAfter:["blockquote"],exec:function(b,c,d){var e=a.sceditor.ie,f="<blockquote>",g="</blockquote>";c?(d=d?"<cite>"+d+"</cite>":"",f=f+d+c+g,g=null):""===this.getRangeHelper().selectedHtml()&&(g=e&&11>e?"":"<br />"+g),this.wysiwygEditorInsertHtml(f,g)},tooltip:"Insert a Quote"},emoticon:{exec:function(b){var c=this,d=function(e){var f=c.opts.emoticonsCompat,g=c.getRangeHelper(),h=f&&" "!==g.getOuterText(!0,1)?" ":"",i=f&&" "!==g.getOuterText(!1,1)?" ":"",j=a("<div />"),k=a("<div />").appendTo(j),l=a.extend({},c.opts.emoticons.dropdown,e?c.opts.emoticons.more:{}),m=0;return a.each(l,function(){m++}),m=Math.sqrt(m),a.each(l,function(b,d){k.append(a("<img />").attr({src:d.url||d,alt:b,title:d.tooltip||b}).click(function(){return c.insert(h+a(this).attr("alt")+i,null,!1).closeDropDown(!0),!1})),k.children().length>=m&&(k=a("<div />").appendTo(j))}),e||j.append(a(c._('<a class="sceditor-more">{0}</a>',c._("More"))).click(function(){return c.createDropDown(b,"more-emoticons",d(!0)),!1})),j};c.createDropDown(b,"emoticons",d(!1))},txtExec:function(b){a.sceditor.command.get("emoticon").exec.call(this,b)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(a,b,c){var d,f=e("youtubeMenu",{label:a._("Video URL:"),insert:a._("Insert")},!0);f.find(".button").click(function(b){var e=f.find("#link").val().replace("http://","");""!==e&&(d=e.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/),d&&(e=d[1]),/^[a-zA-Z0-9_\-]{11}$/.test(e)?c(e):alert("Invalid YouTube video")),a.closeDropDown(!0),b.preventDefault()}),a.createDropDown(b,"insertlink",f)},exec:function(b){var c=this;a.sceditor.command.get("youtube")._dropDown(c,b,function(a){c.wysiwygEditorInsertHtml(e("youtube",{id:a}))})},tooltip:"Insert a YouTube video"},date:{_date:function(a){var b=new Date,c=b.getYear(),d=b.getMonth()+1,e=b.getDate();return 2e3>c&&(c=1900+c),10>d&&(d="0"+d),10>e&&(e="0"+e),a.opts.dateFormat.replace(/year/i,c).replace(/month/i,d).replace(/day/i,e)},exec:function(){this.insertText(a.sceditor.command.get("date")._date(this))},txtExec:function(){this.insertText(a.sceditor.command.get("date")._date(this))},tooltip:"Insert current date"},time:{_time:function(){var a=new Date,b=a.getHours(),c=a.getMinutes(),d=a.getSeconds();return 10>b&&(b="0"+b),10>c&&(c="0"+c),10>d&&(d="0"+d),b+":"+c+":"+d},exec:function(){this.insertText(a.sceditor.command.get("time")._time())},txtExec:function(){this.insertText(a.sceditor.command.get("time")._time())},tooltip:"Insert current time"},ltr:{state:function(a,b){return b&&"ltr"===b.style.direction},exec:function(){var b=this,c=b.getRangeHelper().getFirstBlockParent(),d=a(c);b.focus(),(c&&!d.is("body")||(b.execCommand("formatBlock","p"),c=b.getRangeHelper().getFirstBlockParent(),d=a(c),c&&!d.is("body")))&&("ltr"===d.css("direction")?d.css("direction",""):d.css("direction","ltr"))},tooltip:"Left-to-Right"},rtl:{state:function(a,b){return b&&"rtl"===b.style.direction},exec:function(){var b=this,c=b.getRangeHelper().getFirstBlockParent(),d=a(c);b.focus(),(c&&!d.is("body")||(b.execCommand("formatBlock","p"),c=b.getRangeHelper().getFirstBlockParent(),d=a(c),c&&!d.is("body")))&&("rtl"===d.css("direction")?d.css("direction",""):d.css("direction","rtl"))},tooltip:"Right-to-Left"},print:{exec:"print",tooltip:"Print"},maximize:{state:function(){return this.maximize()},exec:function(){this.maximize(!this.maximize())},txtExec:function(){this.maximize(!this.maximize())},tooltip:"Maximize",shortcut:"ctrl+shift+m"},source:{exec:function(){this.toggleSourceMode()},txtExec:function(){this.toggleSourceMode()},tooltip:"View source",shortcut:"ctrl+shift+s"},ignore:{}},a.sceditor.rangeHelper=function(b,c){var d,e,f,g=c||b.contentDocument||b.document,h=b,i=!!b.getSelection,j="sceditor-start-marker",k="sceditor-end-marker",l="character",m=this;m.insertHTML=function(a,b){var c,d,e=m.selectedRange();if(i){for(b&&(a+=m.selectedHtml()+b),d=g.createElement("div"),c=g.createDocumentFragment(),d.innerHTML=a;d.firstChild;)c.appendChild(d.firstChild);m.insertNode(c)}else{if(!e)return!1;e.pasteHTML(f(a,b,!0))}},f=function(b,c,e){var f,h,i,l=g.createElement("div");if("string"==typeof b?(c&&(b+=m.selectedHtml()+c),l.innerHTML=b):(l.appendChild(b),c&&(l.appendChild(range.extractContents()),l.appendChild(c))),f=l.lastChild){if(m.removeMarkers(),h=a(f),a.sceditor.dom.canHaveChildren(f)?(f.lastChild||h.append(g.createTextNode("​")),h.append(d(k)).append(d(j))):h.after(d(j)).after(d(k)),e)return l.innerHTML;for(i=g.createDocumentFragment();l.firstChild;)i.appendChild(l.firstChild);return i}},m.insertNode=function(a,b){if(i){var c=f(a,b),d=m.selectedRange(),e=d.commonAncestorContainer;if(!c)return!1;d.deleteContents(),e&&/^(br|hr)$/i.test(e.nodeName)?e.parentNode.insertBefore(c,e):d.insertNode(c),m.restoreRange()}else m.insertHTML(a.outerHTML,b?b.outerHTML:null)},m.cloneSelected=function(){var a=m.selectedRange();return a?i?a.cloneRange():a.duplicate():void 0},m.selectedRange=function(){var a,b,c=i?h.getSelection():g.selection;if(c){if(c.getRangeAt&&c.rangeCount<=0){for(b=g.body;b.firstChild;)b=b.firstChild;a=g.createRange(),a.setStart(b,0),c.addRange(a)}return i&&(a=c.getRangeAt(0)),i||"Control"===c.type||(a=c.createRange()),e(a)?a:null}},e=function(a){var b;return a&&a.parentElement&&(b=a.parentElement())?b.ownerDocument===g:!0},m.hasSelection=function(){var a,b=i?h.getSelection():g.selection;return i||!b?b&&b.rangeCount>0:(a=b.createRange(),a&&e(a))},m.selectedHtml=function(){var a,b=m.selectedRange();return b?!i&&""!==b.text&&b.htmlText?b.htmlText:i?(a=g.createElement("div"),a.appendChild(b.cloneContents()),a.innerHTML):"":""},m.parentNode=function(){var a=m.selectedRange();return a?a.parentElement?a.parentElement():a.commonAncestorContainer:void 0},m.getFirstBlockParent=function(b){var c=function(b){return a.sceditor.dom.isInline(b,!0)?(b=b?b.parentNode:null,b?c(b):null):b};return c(b||m.parentNode())},m.insertNodeAt=function(a,b){var c=m.selectedRange(),d=m.cloneSelected();return d?(d.collapse(a),d.insertNode?d.insertNode(b):d.pasteHTML(b.outerHTML),void m.selectRange(c)):!1},d=function(a){m.removeMarker(a);var b=g.createElement("span");return b.id=a,b.style.lineHeight="0",b.style.display="none",b.className="sceditor-selection sceditor-ignore",b.innerHTML=" ",b},m.insertMarkers=function(){m.insertNodeAt(!0,d(j)),m.insertNodeAt(!1,d(k))},m.getMarker=function(a){return g.getElementById(a)},m.removeMarker=function(a){var b=m.getMarker(a);b&&b.parentNode.removeChild(b)},m.removeMarkers=function(){m.removeMarker(j),m.removeMarker(k)},m.saveRange=function(){m.insertMarkers()},m.selectRange=function(a){i?(h.getSelection().removeAllRanges(),h.getSelection().addRange(a)):a.select()},m.restoreRange=function(){var a,b=m.selectedRange(),c=m.getMarker(j),d=m.getMarker(k);return c&&d&&b?(i?(b=g.createRange(),b.setStartBefore(c),b.setEndAfter(d)):(b=g.body.createTextRange(),a=g.body.createTextRange(),a.moveToElementText(c),b.setEndPoint("StartToStart",a),b.moveStart(l,0),a.moveToElementText(d),b.setEndPoint("EndToStart",a),b.moveEnd(l,0)),m.selectRange(b),void m.removeMarkers()):!1},m.selectOuterText=function(a,b){var c=m.cloneSelected();return c?(c.collapse(!1),i?(c.setStart(c.startContainer,c.startOffset-a),c.setEnd(c.endContainer,c.endOffset+b)):(c.moveStart(l,0-a),c.moveEnd(l,b)),void m.selectRange(c)):!1},m.getOuterText=function(a,b){var c="",d=m.cloneSelected();return d?(d.collapse(!1),a?i?(c=d.startContainer.textContent.substr(0,d.startOffset),c=c.substr(Math.max(0,c.length-b))):(d.moveStart(l,0-b),c=d.text):i?c=d.startContainer.textContent.substr(d.startOffset,b):(d.moveEnd(l,b),c=d.text),c):""},m.raplaceKeyword=function(b,c,d,e,f,g){d||b.sort(function(a,b){return a.length-b.length});var h,j,k,l,n,o,p,q=b.length,r=e||b[q-1][0].length;if(f){if(!i)return!1;++r}for(h=m.getOuterText(!0,r),j=h+(null!=g?g:""),c&&(j+=m.getOuterText(!1,r));q--;)if(p=b[q][0],n=new RegExp("(?:[\\s    ])"+a.sceditor.regexEscape(p)+"(?=[\\s    ])"),o=h.length-1-p.length,f&&--o,o=Math.max(0,o),(k=f?j.substr(o).search(n):j.indexOf(p,o))>-1){if(f&&(k+=o+1),k>h.length||k+p.length+(f?1:0)<h.length)continue;return l=h.length-k,m.selectOuterText(l,p.length-l-(null!=g&&/^\S/.test(g)?1:0)),m.insertHTML(b[q][1]),!0}return!1},m.compare=function(a,b){return b||(b=m.selectedRange()),a&&b?i?0===a.compareBoundaryPoints(Range.END_TO_END,b)&&0===a.compareBoundaryPoints(Range.START_TO_START,b):e(a)&&e(b)&&0===a.compareEndPoints("EndToEnd",b)&&0===a.compareEndPoints("StartToStart",b):!a&&!b}},a.sceditor.dom={traverse:function(a,b,c,d,e){if(a)for(a=e?a.lastChild:a.firstChild;null!=a;){var f=e?a.previousSibling:a.nextSibling;if(!c&&b(a)===!1)return!1;if(!d&&this.traverse(a,b,c,d,e)===!1)return!1;if(c&&b(a)===!1)return!1;a=f}},rTraverse:function(a,b,c,d){this.traverse(a,b,c,d,!0)},parseHTML:function(b,d){var e=[],f=(d||c).createElement("div");return f.innerHTML=b,a.merge(e,f.childNodes),e},hasStyling:function(b){var c=a(b);return b&&(!c.is("p,div")||b.className||c.attr("style")||!a.isEmptyObject(c.data()))},convertElement:function(b,c){for(var d,e,f=b.attributes.length,g=b.ownerDocument.createElement(c);f--;)e=b.attributes[f],(!a.sceditor.ie||e.specified)&&(a.sceditor.ie<8&&/style/i.test(e.name)?b.style.cssText=b.style.cssText:g.setAttribute(e.name,e.value));for(;d=b.firstChild;)g.appendChild(d);return b.parentNode.replaceChild(g,b),g},blockLevelList:"|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|",canHaveChildren:function(a){return/11?|9/.test(a.nodeType)?"hr,br,img,input,meta,link,iframe,".indexOf(a.nodeName.toLowerCase()+",")<0:!1},isInline:function(b,c){return b&&1===b.nodeType?(b=b.tagName.toLowerCase(),"code"===b?!c:a.sceditor.dom.blockLevelList.indexOf("|"+b+"|")<0):!0},copyCSS:function(a,b){b.style.cssText=a.style.cssText+b.style.cssText},fixNesting:function(a){var b=this,c=function(a){for(;b.isInline(a.parentNode,!0);)a=a.parentNode;return a};b.traverse(a,function(a){if(1===a.nodeType&&!b.isInline(a,!0)&&b.isInline(a.parentNode,!0)){var d=c(a),e=d.parentNode,f=b.extractContents(d,a),g=a;b.copyCSS(d,g),e.insertBefore(f,d),e.insertBefore(g,d)}})},findCommonAncestor:function(b,c){return a(b).parents().has(a(c)).first()},getSibling:function(b,c){var d;return b?(d=b[c?"previousSibling":"nextSibling"])?d:a.sceditor.dom.getSibling(b.parentNode,c):null},removeWhiteSpace:function(b,c){for(var d,e,f,g,h,i,j,k,l=a.sceditor.dom.getSibling,m=a.sceditor.dom.isInline,n=b.firstChild,o=/[\t ]+/g,p=/[\t\n\r ]+/g;n;){if(i=n.nextSibling,d=n.nodeValue,e=n.nodeType,1===e&&n.firstChild&&(h=a(n).css("whiteSpace"),/pre(?:\-wrap)?$/i.test(h)||a.sceditor.dom.removeWhiteSpace(n,/line$/i.test(h))),3===e&&d){for(f=l(n),g=l(n,!0),k=g,j=!1;a(k).hasClass("sceditor-ignore");)k=l(k,!0);if(m(n)&&k){for(;k.lastChild;)k=k.lastChild;j=3===k.nodeType?/[\t\n\r ]$/.test(k.nodeValue):!m(k)}m(n)&&g&&m(g)&&!j||(d=d.replace(/^[\t\n\r ]+/,"")),m(n)&&f&&m(f)||(d=d.replace(/[\t\n\r ]+$/,"")),d=d.replace(/\u200B/g,""),d.length?n.nodeValue=d.replace(c?o:p," "):b.removeChild(n)}n=i}},extractContents:function(a,b){var c=this,d=c.findCommonAncestor(a,b),e=d?d[0]:null,f=!1,g=!1;return function h(d){var e=a.ownerDocument.createDocumentFragment();return c.traverse(d,function(c){if(g||c===b&&f)return g=!0,!1;c===a&&(f=!0);var d,i;f?jQuery.contains(c,b)&&1===c.nodeType?(d=h(c),i=c.cloneNode(!1),i.appendChild(d),e.appendChild(i)):e.appendChild(c):jQuery.contains(c,a)&&1===c.nodeType&&(d=h(c),i=c.cloneNode(!1),i.appendChild(d),e.appendChild(i))},!1),e}(e)},getOffset:function(a){for(var b=0,c=0;a;)b+=a.offsetLeft,c+=a.offsetTop,a=a.offsetParent;return{left:b,top:c}},getStyle:function(b,c){var d,e,f,g,h=b.style;if(!h)return null;if(a.sceditor.dom._propertyCache||(a.sceditor.dom._propertyCache={}),f=a.sceditor.dom._propertyCache,f[c]||(f[c]=a.camelCase(c)),c=f[c],g=h[c],"textAlign"===c){if(d=a(b),e=h.direction,g=g||d.css(c),d.parent().css(c)===g||"block"!==d.css("display")||d.is("hr")||d.is("th"))return null;if(e&&g&&(/right/i.test(g)&&"rtl"===e||/left/i.test(g)&&"ltr"===e))return null}return g},hasStyle:function(b,c,d){var e=a.sceditor.dom.getStyle(b,c);return e?!1:!d||e===d||a.isArray(d)&&a.inArray(e,d)>-1}},a.sceditor.plugins={},a.sceditor.PluginManager=function(b){var c=this,d=[],e=b,f=function(a){return"signal"+a.charAt(0).toUpperCase()+a.slice(1)},g=function(a,b){a=[].slice.call(a);for(var c=d.length,g=f(a.shift());c--;)if(g in d[c]){if(b)return d[c][g].apply(e,a);d[c][g].apply(e,a)}};c.call=function(){g(arguments,!1)},c.callOnlyFirst=function(){return g(arguments,!0)},c.iter=function(a){return a=f(a),function(){var b=d.length;return{callNext:function(c){for(;b--;)if(d[b]&&a in d[b])return d[b].apply(e,c)},hasNext:function(){for(var c=b;c--;)if(d[c]&&a in d[c])return!0;return!1}}}()},c.hasHandler=function(a){var b=d.length;for(a=f(a);b--;)if(a in d[b])return!0;return!1},c.exists=function(b){return b in a.sceditor.plugins?(b=a.sceditor.plugins[b],"function"==typeof b&&"object"==typeof b.prototype):!1},c.isRegistered=function(b){var e=d.length;if(!c.exists(b))return!1;for(;e--;)if(d[e]instanceof a.sceditor.plugins[b])return!0;return!1},c.register=function(b){return c.exists(b)?(b=new a.sceditor.plugins[b],d.push(b),"init"in b&&b.init.apply(e),!0):!1},c.deregister=function(b){var f,g=d.length,h=!1;if(!c.isRegistered(b))return!1;for(;g--;)d[g]instanceof a.sceditor.plugins[b]&&(f=d.splice(g,1)[0],h=!0,"destroy"in f&&f.destroy.apply(e));return h},c.destroy=function(){for(var a=d.length;a--;)"destroy"in d[a]&&d[a].destroy.apply(e);d=null,e=null}},a.sceditor.command={get:function(b){return a.sceditor.commands[b]||null},set:function(b,c){return b&&c?(c=a.extend(a.sceditor.commands[b]||{},c),c.remove=function(){a.sceditor.command.remove(b)},a.sceditor.commands[b]=c,this):!1},remove:function(b){return a.sceditor.commands[b]&&delete a.sceditor.commands[b],this}},a.sceditor.defaultOptions={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,paste,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source",toolbarExclude:null,style:"jquery.sceditor.default.css",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana",colors:null,locale:a("html").attr("lang")||"en",charset:"utf-8",emoticonsCompat:!1,emoticonsEnabled:!0,emoticonsRoot:"",emoticons:{dropdown:{":)":"emoticons/smile.png",":angel:":"emoticons/angel.png",":angry:":"emoticons/angry.png","8-)":"emoticons/cool.png",":'(":"emoticons/cwy.png",":ermm:":"emoticons/ermm.png",":D":"emoticons/grin.png","<3":"emoticons/heart.png",":(":"emoticons/sad.png",":O":"emoticons/shocked.png",":P":"emoticons/tongue.png",";)":"emoticons/wink.png"},more:{":alien:":"emoticons/alien.png",":blink:":"emoticons/blink.png",":blush:":"emoticons/blush.png",":cheerful:":"emoticons/cheerful.png",":devil:":"emoticons/devil.png",":dizzy:":"emoticons/dizzy.png",":getlost:":"emoticons/getlost.png",":happy:":"emoticons/happy.png",":kissing:":"emoticons/kissing.png",":ninja:":"emoticons/ninja.png",":pinch:":"emoticons/pinch.png",":pouty:":"emoticons/pouty.png",":sick:":"emoticons/sick.png",":sideways:":"emoticons/sideways.png",":silly:":"emoticons/silly.png",":sleeping:":"emoticons/sleeping.png",":unsure:":"emoticons/unsure.png",":woot:":"emoticons/w00t.png",":wassat:":"emoticons/wassat.png"},hidden:{":whistling:":"emoticons/whistling.png",":love:":"emoticons/wub.png"}},width:null,height:null,resizeEnabled:!0,resizeMinWidth:null,resizeMinHeight:null,resizeMaxHeight:null,resizeMaxWidth:null,resizeHeight:!0,resizeWidth:!0,getHtmlHandler:null,getTextHandler:null,dateFormat:"year-month-day",toolbarContainer:null,enablePasteFiltering:!1,disablePasting:!1,readOnly:!1,rtl:!1,autofocus:!1,autofocusEnd:!0,autoExpand:!1,autoUpdate:!1,spellcheck:!0,runWithoutWysiwygSupport:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,disableBlockRemove:!1,parserOptions:{},dropDownCss:{}},a.fn.sceditor=function(b){var c,d=[];return b=b||{},b.runWithoutWysiwygSupport||a.sceditor.isWysiwygSupported?(this.each(function(){c=this.jquery?this:a(this),c.parents(".sceditor-container").length>0||("state"===b?d.push(!!c.data("sceditor")):"instance"===b?d.push(c.data("sceditor")):c.data("sceditor")||new a.sceditor(this,b))}),d.length?1===d.length?d[0]:a(d):this):void 0}}(jQuery,window,document),function(a,b,c){"use strict";var d=a.sceditor.escapeEntities,e=a.sceditor.escapeUriScheme,f=a.sceditor.ie,g=f&&11>f;a.sceditor.BBCodeParser=function(b){if(!(this instanceof a.sceditor.BBCodeParser))return new a.sceditor.BBCodeParser(b);var e,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=this,w={open:"open",content:"content",newline:"newline",close:"close"},x=function(a,b,c,d,e,f){var g=this;g.type=a,g.name=b,g.val=c,g.attrs=d||{},g.children=e||[],g.closing=f||null};x.prototype={clone:function(a){var b=this;return new x(b.type,b.name,b.val,b.attrs,a?b.children:[],b.closing?b.closing.clone():null)},splitAt:function(b){var c,d=this,e=0,f=d.children.length;if("number"!=typeof b&&(b=a.inArray(b,d.children)),0>b||b>f)return null;for(;f--;)f>=b?e++:f=0;return c=d.clone(),c.children=d.children.splice(b,e),c}},e=function(){v.opts=a.extend({},a.sceditor.BBCodeParser.defaults,b),v.bbcodes=a.sceditor.plugins.bbcode.bbcodes},v.tokenize=function(a){var b,c,d,e=[],f=[{type:"close",regex:/^\[\/[^\[\]]+\]/},{type:"open",regex:/^\[[^\[\]]+\]/},{type:"newline",regex:/^(\r\n|\r|\n)/},{type:"content",regex:/^([^\[\r\n]+|\[)/}];f.reverse();a:for(;a.length;){for(d=f.length;d--;)if(c=f[d].type,(b=a.match(f[d].regex))&&b[0]){e.push(h(c,b[0])),a=a.substr(b[0].length);continue a}a.length&&e.push(h(w.content,a)),a=""}return e},h=function(b,c){var d,e,f;return"open"===b&&(d=c.match(/\[([^\]\s=]+)(?:([^\]]+))?\]/))?(f=t(d[1]),d[2]&&(d[2]=a.trim(d[2]))&&(e=i(d[2]))):"close"===b&&(d=c.match(/\[\/([^\[\]]+)\]/))?f=t(d[1]):"newline"===b&&(f="#newline"),f&&("open"!==b&&"close"!==b||a.sceditor.plugins.bbcode.bbcodes[f])||(b="content",f="#"),new x(b,f,c,e)},i=function(b){var c,d=/([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g,e=a.sceditor.plugins.bbcode.stripQuotes,f={};if("="===b.charAt(0)&&b.indexOf("=",1)<0)f.defaultattr=e(b.substr(1));else for("="===b.charAt(0)&&(b="defaultattr"+b);c=d.exec(b);)f[t(c[1])]=e(c[3])||c[4];return f},v.parse=function(a,b){var c=j(v.tokenize(a));return v.opts.fixInvalidChildren&&o(c),v.opts.removeEmptyTags&&n(c),v.opts.fixInvalidNesting&&l(c),k(c,null,b),v.opts.removeEmptyTags&&n(c),c},r=function(a,b,c){for(var d=c.length;d--;)if(c[d].type===b&&c[d].name===a)return!0;return!1},m=function(b,c){var d=b?v.bbcodes[b.name]:null,e=d?d.allowedChildren:null;return v.opts.fixInvalidChildren&&e&&e&&a.inArray(c.name||"#",e)<0?!1:!0},j=function(b){for(var c,d,e,f,g,h,i,j=[],k=[],l=[],m=function(){return u(l)},n=function(a){m()?m().children.push(a):k.push(a)},o=function(b){return m()&&(d=v.bbcodes[m().name])&&d.closedBy&&a.inArray(b,d.closedBy)>-1};c=b.shift();){switch(i=b[0],c.type){case w.open:o(c.name)&&l.pop(),n(c),d=v.bbcodes[c.name],d&&d.isSelfClosing||!d.closedBy&&!r(c.name,w.close,b)?d&&d.isSelfClosing||(c.type=w.content):l.push(c);break;case w.close:if(m()&&c.name!==m().name&&o("/"+c.name)&&l.pop(),m()&&c.name===m().name)m().closing=c,l.pop();else if(r(c.name,w.open,l)){for(;e=l.pop();){if(e.name===c.name){e.closing=c;break}f=e.clone(),j.length>1&&f.children.push(u(j)),j.push(f)}for(n(u(j)),g=j.length;g--;)l.push(j[g]);j.length=0}else c.type=w.content,n(c);break;case w.newline:m()&&i&&o((i.type===w.close?"/":"")+i.name)&&(i.type!==w.close||i.name!==m().name)&&(d=v.bbcodes[m().name],d&&d.breakAfter?l.pop():d&&d.isInline===!1&&v.opts.breakAfterBlock&&d.breakAfter!==!1&&l.pop()),n(c);break;default:n(c)}h=c}return k},k=function(a,b,c){var d,e,f,g,h,i,j,l,m=a.length,n=m;for(b&&(g=v.bbcodes[b.name]);n--;)if(d=a[n])if(d.type===w.newline){if(e=n>0?a[n-1]:null,f=m-1>n?a[n+1]:null,l=!1,!c&&g&&g.isSelfClosing!==!0&&(e?i||f||(g.isInline===!1&&v.opts.breakEndBlock&&g.breakEnd!==!1&&(l=!0),g.breakEnd&&(l=!0),i=l):(g.isInline===!1&&v.opts.breakStartBlock&&g.breakStart!==!1&&(l=!0),g.breakStart&&(l=!0))),e&&e.type===w.open&&(h=v.bbcodes[e.name])&&(c?h.isInline===!1&&(l=!0):(h.isInline===!1&&v.opts.breakAfterBlock&&h.breakAfter!==!1&&(l=!0),h.breakAfter&&(l=!0))),!c&&!j&&f&&f.type===w.open&&(h=v.bbcodes[f.name])&&(h.isInline===!1&&v.opts.breakBeforeBlock&&h.breakBefore!==!1&&(l=!0),h.breakBefore&&(l=!0),j=l,l)){a.splice(n,1);continue}l&&a.splice(n,1),j=!1}else d.type===w.open&&k(d.children,d,c)},l=function(b,c,d,e){var f,g,h,i,j,k,m=function(a){var b=v.bbcodes[a.name];return!b||b.isInline!==!1};for(c=c||[],e=e||b,g=0;g<b.length;g++)if((f=b[g])&&f.type===w.open){if(!m(f)&&d&&(h=u(c),k=h.splitAt(f),j=c.length>1?c[c.length-2].children:e,(i=a.inArray(h,j))>-1))return k.children.splice(a.inArray(f,k.children),1),void j.splice(i+1,0,f,k);c.push(f),l(f.children,c,d||m(f),e),c.pop(f)}},o=function(a,b){for(var c,d,e=a.length;e--;)(c=a[e])&&(m(b,c)||(c.name=null,c.type=w.content,m(b,c)?(d=[e+1,0].concat(c.children),c.closing&&(c.closing.name=null,c.closing.type=w.content,d.push(c.closing)),e+=d.length-1,Array.prototype.splice.apply(a,d)):b.children.splice(e,1)),c.type===w.open&&o(c.children,c))},n=function(b){var c,d,e,f=b.length;for(e=function(a){for(var b=a.length;b--;){if(a[b].type===w.open)return!1;if(a[b].type===w.close)return!1;if(a[b].type===w.content&&a[b].val&&/\S|\u00A0/.test(a[b].val))return!1}return!0};f--;)(c=b[f])&&c.type===w.open&&(d=v.bbcodes[c.name],n(c.children),e(c.children)&&d&&!d.isSelfClosing&&!d.allowsEmpty&&b.splice.apply(b,a.merge([f,1],c.children)))},v.toHTML=function(a,b){return p(v.parse(a,b),!0)},p=function(b,e){var h,i,j,k,l,m,n,o,q=[];for(n=function(a){return(!a||("undefined"!=typeof a.isHtmlInline?a.isHtmlInline:a.isInline))!==!1};b.length>0;)if(h=b.shift()){if(h.type===w.open)o=h.children[h.children.length-1]||{},i=v.bbcodes[h.name],l=e&&n(i),j=p(h.children,!1),i&&i.html?(n(i)||!n(v.bbcodes[o.name])||i.isPreFormatted||i.skipLastLineBreak||g||(j+="<br />"),a.isFunction(i.html)?k=i.html.call(v,h,h.attrs,j):(h.attrs[0]=j,k=a.sceditor.plugins.bbcode.formatBBCodeString(i.html,h.attrs))):k=h.val+j+(h.closing?h.closing.val:"");else{if(h.type===w.newline){if(!e){q.push("<br />");continue}m||(q.push("<div>"),(c.documentMode&&c.documentMode<8||8>f)&&q.push(" ")),g||q.push("<br />"),b.length||q.push("<br />"),q.push("</div>\n"),m=!1;continue}l=e,k=d(h.val,!0)}l&&!m?(q.push("<div>"),m=!0):!l&&m&&(q.push("</div>\n"),m=!1),q.push(k)}return m&&q.push("</div>\n"),q.join("")},v.toBBCode=function(a,b){return q(v.parse(a,b))},q=function(b){for(var c,d,e,f,g,h,i,j,k,l,m=[];b.length>0;)if(c=b.shift())if(e=v.bbcodes[c.name],f=!(!e||e.isInline!==!1),g=e&&e.isSelfClosing,i=f&&v.opts.breakBeforeBlock&&e.breakBefore!==!1||e&&e.breakBefore,j=f&&!g&&v.opts.breakStartBlock&&e.breakStart!==!1||e&&e.breakStart,k=f&&v.opts.breakEndBlock&&e.breakEnd!==!1||e&&e.breakEnd,l=f&&v.opts.breakAfterBlock&&e.breakAfter!==!1||e&&e.breakAfter,h=(e?e.quoteType:null)||v.opts.quoteType||a.sceditor.BBCodeParser.QuoteType.auto,e||c.type!==w.open)if(c.type===w.open){if(i&&m.push("\n"),m.push("["+c.name),c.attrs){c.attrs.defaultattr&&(m.push("="+s(c.attrs.defaultattr,h,"defaultattr")),delete c.attrs.defaultattr);for(d in c.attrs)c.attrs.hasOwnProperty(d)&&m.push(" "+d+"="+s(c.attrs[d],h,d))}m.push("]"),j&&m.push("\n"),c.children&&m.push(q(c.children)),g||e.excludeClosing||(k&&m.push("\n"),m.push("[/"+c.name+"]")),l&&m.push("\n"),c.closing&&g&&m.push(c.closing.val)}else m.push(c.val);else m.push(c.val),c.children&&m.push(q(c.children)),c.closing&&m.push(c.closing.val);return m.join("")},s=function(b,c,d){var e=a.sceditor.BBCodeParser.QuoteType,f=/\s|=/.test(b);return a.isFunction(c)?c(b,d):c===e.never||c===e.auto&&!f?b:'"'+b.replace("\\","\\\\").replace('"','\\"')+'"'},u=function(a){return a.length?a[a.length-1]:null},t=function(a){return a.toLowerCase()},e()},a.sceditor.BBCodeParser.QuoteType={always:1,never:2,auto:3},a.sceditor.BBCodeParser.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:a.sceditor.BBCodeParser.QuoteType.auto},a.sceditorBBCodePlugin=a.sceditor.plugins.bbcode=function(){var b,d,e,f,h,i,j=this;f=a.sceditor.plugins.bbcode.formatString,j.bbcodes=a.sceditor.plugins.bbcode.bbcodes,j.stripQuotes=a.sceditor.plugins.bbcode.stripQuotes;var k={},l={},m={ul:["li","ol","ul"],ol:["li","ol","ul"],table:["tr"],tr:["td","th"],code:["br","p","div"]};j.init=function(){j.opts=this.opts,b(),h(this),this.toBBCode=j.signalToSource,this.fromBBCode=j.signalToWysiwyg},h=function(b){var c=a.sceditor.command.get,d={bold:{txtExec:["[b]","[/b]"]},italic:{txtExec:["[i]","[/i]"]},underline:{txtExec:["[u]","[/u]"]},strike:{txtExec:["[s]","[/s]"]},subscript:{txtExec:["[sub]","[/sub]"]},superscript:{txtExec:["[sup]","[/sup]"]},left:{txtExec:["[left]","[/left]"]},center:{txtExec:["[center]","[/center]"]},right:{txtExec:["[right]","[/right]"]},justify:{txtExec:["[justify]","[/justify]"]},font:{txtExec:function(a){var b=this;c("font")._dropDown(b,a,function(a){b.insertText("[font="+a+"]","[/font]")})}},size:{txtExec:function(a){var b=this;c("size")._dropDown(b,a,function(a){b.insertText("[size="+a+"]","[/size]")})}},color:{txtExec:function(a){var b=this;c("color")._dropDown(b,a,function(a){b.insertText("[color="+a+"]","[/color]")})}},bulletlist:{txtExec:function(c,d){var e="";a.each(d.split(/\r?\n/),function(){e+=(e?"\n":"")+"[li]"+this+"[/li]"}),b.insertText("[ul]\n"+e+"\n[/ul]")}},orderedlist:{txtExec:function(c,d){var e="";a.each(d.split(/\r?\n/),function(){e+=(e?"\n":"")+"[li]"+this+"[/li]"}),a.sceditor.plugins.bbcode.bbcode.get(""),b.insertText("[ol]\n"+e+"\n[/ol]")}},table:{txtExec:["[table][tr][td]","[/td][/tr][/table]"]},horizontalrule:{txtExec:["[hr]"]},code:{txtExec:["[code]","[/code]"]},image:{txtExec:function(a,b){var c=prompt(this._("Enter the image URL:"),b);c&&this.insertText("[img]"+c+"[/img]")}},email:{txtExec:function(a,b){var c=b&&b.indexOf("@")>-1?null:b,d=prompt(this._("Enter the e-mail address:"),c?"":b),e=prompt(this._("Enter the displayed text:"),c||d)||d;d&&this.insertText("[email="+d+"]"+e+"[/email]")}},link:{txtExec:function(b,c){var d=/^[a-z]+:\/\//i.test(a.trim(c))?null:c,e=prompt(this._("Enter URL:"),d?"http://":a.trim(c)),f=prompt(this._("Enter the displayed text:"),d||e)||e;e&&this.insertText("[url="+e+"]"+f+"[/url]")}},quote:{txtExec:["[quote]","[/quote]"]},youtube:{txtExec:function(a){var b=this;c("youtube")._dropDown(b,a,function(a){b.insertText("[youtube]"+a+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}};b.commands=a.extend(!0,{},d,b.commands)},b=function(){a.each(j.bbcodes,function(b){j.bbcodes[b].tags&&a.each(j.bbcodes[b].tags,function(a,c){var d=j.bbcodes[b].isInline===!1;k[a]=k[a]||{},k[a][d]=k[a][d]||{},k[a][d][b]=c}),j.bbcodes[b].styles&&a.each(j.bbcodes[b].styles,function(a,c){var d=j.bbcodes[b].isInline===!1;l[d]=l[d]||{},l[d][a]=l[d][a]||{},l[d][a][b]=c})})},d=function(b,c,d){var e,g,h=a.sceditor.dom.getStyle;return d=!!d,l[d]?(a.each(l[d],function(d,i){e=h(b[0],d),e&&h(b.parent()[0],d)!==e&&a.each(i,function(d,h){(!h||a.inArray(e.toString(),h)>-1)&&(g=j.bbcodes[d].format,c=a.isFunction(g)?g.call(j,b,c):f(g,c))})}),c):c},e=function(b,c,d){var e,h,i=b[0],l=i.nodeName.toLowerCase();d=!!d,k[l]&&k[l][d]&&a.each(k[l][d],function(d,g){(!g||(e=!1,a.each(g,function(c,d){return!b.attr(c)||d&&a.inArray(b.attr(c),d)<0?void 0:(e=!0,!1)}),e))&&(h=j.bbcodes[d].format,c=a.isFunction(h)?h.call(j,b,c):f(h,c))});var m=a.sceditor.dom.isInline;if(d&&(!m(i,!0)||"br"===l)){for(var n=i.parentNode,o=n.lastChild,p=i.previousSibling,q=m(n,!0);p&&(a(p).hasClass("sceditor-ignore")||1===p.nodeType&&m(p,!0)&&!p.firstChild);)p=p.previousSibling;for(;a(o).hasClass("sceditor-ignore");)o=o.previousSibling;(q||o!==i||"li"===l||"br"===l&&g)&&(c+="\n"),"br"!==l&&p&&"br"!==p.nodeName.toLowerCase()&&m(p,!0)&&(c="\n"+c)}return c},j.signalToSource=function(b,d){var e,f,g=new a.sceditor.BBCodeParser(j.opts.parserOptions);return d||("string"==typeof b?(e=a("<div />").css("visibility","hidden").appendTo(c.body).html(b),d=e):d=a(b)),d&&d.jquery?(a.sceditor.dom.removeWhiteSpace(d[0]),f=j.elementToBbcode(d),e&&e.remove(),f=g.toBBCode(f,!0),j.opts.bbcodeTrim&&(f=a.trim(f)),f):""},j.elementToBbcode=function(b){return function c(b,f){var h="";return a.sceditor.dom.traverse(b,function(b){var i=a(b),j="",k=b.nodeType,l=b.nodeName.toLowerCase(),n=m[l],o=b.firstChild,p=!0;if("object"==typeof f&&(p=a.inArray(l,f)>-1,i.is("img")&&i.data("sceditor-emoticon")&&(p=!0),p||(n=f)),3===k||1===k)if(1===k){if(i.hasClass("sceditor-ignore"))return;if(i.hasClass("sceditor-nlf")&&(!o||!g&&1===b.childNodes.length&&/br/i.test(o.nodeName)))return;"iframe"!==l&&(j=c(b,n)),p?("code"!==l&&(j=d(i,j),j=e(i,j),j=d(i,j,!0)),h+=e(i,j,!0)):h+=j}else!b.wholeText||b.previousSibling&&3===b.previousSibling.nodeType?b.wholeText||(h+=b.nodeValue):h+=0===i.parents("code").length?b.wholeText.replace(/ +/g," "):b.wholeText},!1,!0),h}(b[0])},j.signalToWysiwyg=function(b,c){var d=new a.sceditor.BBCodeParser(j.opts.parserOptions),e=d.toHTML(j.opts.bbcodeTrim?a.trim(b):b);return c?i(e):e},i=function(b){var d,e,f,h=a("<div />").hide().appendTo(c.body),i=h[0];return f=function(b,d){if(!a.sceditor.dom.hasStyling(b)){if(g||1!==b.childNodes.length||!a(b.firstChild).is("br"))for(;e=b.firstChild;)i.insertBefore(e,b);if(d){var f=i.lastChild;b!==f&&a(f).is("div")&&b.nextSibling===f&&i.insertBefore(c.createElement("br"),b)}i.removeChild(b)}},i.innerHTML=b.replace(/<\/div>\n/g,"</div>"),(d=i.firstChild)&&a(d).is("div")&&f(d,!0),(d=i.lastChild)&&a(d).is("div")&&f(d),i=i.innerHTML,h.remove(),i
}},a.sceditor.plugins.bbcode.stripQuotes=function(a){return a?a.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2"):a},a.sceditor.plugins.bbcode.formatString=function(){var a,b=arguments;return b[0].replace(/\{(\d+)\}/g,function(c,d){return b[d-0+1]!==a?b[d-0+1]:"{"+d+"}"})},a.sceditor.plugins.bbcode.formatBBCodeString=function(a,b){return a.replace(/\{(!?[^}]+)\}/g,function(a,c){var e,f=!0;return"!"===c[0]&&(f=!1,c=c.substring(1)),"0"===c[0]&&(f=!1),b[c]===e?a:f?d(b[c],!0):b[c]})};var h=a.sceditor.plugins.bbcode.normaliseColour=function(a){var b,c;return c=function(a){return a=parseInt(a,10),isNaN(a)?"00":(a=Math.max(0,Math.min(a,255)).toString(16),a.length<2?"0"+a:a)},a=a||"#000",(b=a.match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+c(b[1])+c(b[2]-0)+c(b[3]-0):(b=a.match(/#([0-f])([0-f])([0-f])\s*?$/i))?"#"+b[1]+b[1]+b[2]+b[2]+b[3]+b[3]:a};a.sceditor.plugins.bbcode.bbcodes={b:{tags:{b:null,strong:null},styles:{"font-weight":["bold","bolder","401","700","800","900"]},format:"[b]{0}[/b]",html:"<strong>{0}</strong>"},i:{tags:{i:null,em:null},styles:{"font-style":["italic","oblique"]},format:"[i]{0}[/i]",html:"<em>{0}</em>"},u:{tags:{u:null},styles:{"text-decoration":["underline"]},format:"[u]{0}[/u]",html:"<u>{0}</u>"},s:{tags:{s:null,strike:null},styles:{"text-decoration":["line-through"]},format:"[s]{0}[/s]",html:"<s>{0}</s>"},sub:{tags:{sub:null},format:"[sub]{0}[/sub]",html:"<sub>{0}</sub>"},sup:{tags:{sup:null},format:"[sup]{0}[/sup]",html:"<sup>{0}</sup>"},font:{tags:{font:{face:null}},styles:{"font-family":null},quoteType:a.sceditor.BBCodeParser.QuoteType.never,format:function(a,b){var c;return"font"===a[0].nodeName.toLowerCase()&&(c=a.attr("face"))||(c=a.css("font-family")),"[font="+this.stripQuotes(c)+"]"+b+"[/font]"},html:'<font face="{defaultattr}">{0}</font>'},size:{tags:{font:{size:null}},styles:{"font-size":null},format:function(a,b){var c=a.attr("size"),d=2;return c||(c=a.css("fontSize")),c.indexOf("px")>-1?(c=c.replace("px","")-0,12>c&&(d=1),c>15&&(d=3),c>17&&(d=4),c>23&&(d=5),c>31&&(d=6),c>47&&(d=7)):d=c,"[size="+d+"]"+b+"[/size]"},html:'<font size="{defaultattr}">{!0}</font>'},color:{tags:{font:{color:null}},styles:{color:null},quoteType:a.sceditor.BBCodeParser.QuoteType.never,format:function(a,b){var c,d=a[0];return"font"===d.nodeName.toLowerCase()&&(c=a.attr("color"))||(c=d.style.color||a.css("color")),"[color="+h(c)+"]"+b+"[/color]"},html:function(a,b,c){return'<font color="'+d(h(b.defaultattr),!0)+'">'+c+"</font>"}},ul:{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ul]{0}[/ul]",html:"<ul>{0}</ul>"},list:{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:"<ul>{0}</ul>"},ol:{tags:{ol:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ol]{0}[/ol]",html:"<ol>{0}</ol>"},li:{tags:{li:null},isInline:!1,closedBy:["/ul","/ol","/list","*","li"],format:"[li]{0}[/li]",html:"<li>{0}</li>"},"*":{isInline:!1,closedBy:["/ul","/ol","/list","*","li"],html:"<li>{0}</li>"},table:{tags:{table:null},isInline:!1,isHtmlInline:!0,skipLastLineBreak:!0,format:"[table]{0}[/table]",html:"<table>{0}</table>"},tr:{tags:{tr:null},isInline:!1,skipLastLineBreak:!0,format:"[tr]{0}[/tr]",html:"<tr>{0}</tr>"},th:{tags:{th:null},allowsEmpty:!0,isInline:!1,format:"[th]{0}[/th]",html:"<th>{0}</th>"},td:{tags:{td:null},allowsEmpty:!0,isInline:!1,format:"[td]{0}[/td]",html:"<td>{0}</td>"},emoticon:{allowsEmpty:!0,tags:{img:{src:null,"data-sceditor-emoticon":null}},format:function(a,b){return a.data("sceditor-emoticon")+b},html:"{0}"},hr:{tags:{hr:null},allowsEmpty:!0,isSelfClosing:!0,isInline:!1,format:"[hr]{0}",html:"<hr />"},img:{allowsEmpty:!0,tags:{img:{src:null}},allowedChildren:["#"],quoteType:a.sceditor.BBCodeParser.QuoteType.never,format:function(a,b){var c,d,e="",f=a[0],g=function(a){return f.style?f.style[a]:null};return a.attr("data-sceditor-emoticon")?b:(c=a.attr("width")||g("width"),d=a.attr("height")||g("height"),(f.complete&&(c||d)||c&&d)&&(e="="+a.width()+"x"+a.height()),"[img"+e+"]"+a.attr("src")+"[/img]")},html:function(a,b,c){var f,g,h,i,j="";return b.width!==f&&(g=b.width),b.height!==f&&(h=b.height),b.defaultattr&&(i=b.defaultattr.split(/x/i),g=i[0],h=2===i.length?i[1]:i[0]),g!==f&&(j+=' width="'+d(g,!0)+'"'),h!==f&&(j+=' height="'+d(h,!0)+'"'),"<img"+j+' src="'+e(c)+'" />'}},url:{allowsEmpty:!0,tags:{a:{href:null}},quoteType:a.sceditor.BBCodeParser.QuoteType.never,format:function(a,b){var c=a.attr("href");return"mailto:"===c.substr(0,7)?'[email="'+c.substr(7)+'"]'+b+"[/email]":"[url="+c+"]"+b+"[/url]"},html:function(a,b,c){return b.defaultattr=d(b.defaultattr,!0)||c,'<a href="'+e(b.defaultattr)+'">'+c+"</a>"}},email:{quoteType:a.sceditor.BBCodeParser.QuoteType.never,html:function(a,b,c){return'<a href="mailto:'+(d(b.defaultattr,!0)||c)+'">'+c+"</a>"}},quote:{tags:{blockquote:null},isInline:!1,quoteType:a.sceditor.BBCodeParser.QuoteType.never,format:function(b,c){var d="",e=a(b),f=e.children("cite").first();return(1===f.length||e.data("author"))&&(d=f.text()||e.data("author"),e.data("author",d),f.remove(),c=this.elementToBbcode(a(b)),d="="+d,e.prepend(f)),"[quote"+d+"]"+c+"[/quote]"},html:function(a,b,c){return b.defaultattr&&(c="<cite>"+d(b.defaultattr)+"</cite>"+c),"<blockquote>"+c+"</blockquote>"}},code:{tags:{code:null},isInline:!1,allowedChildren:["#","#newline"],format:"[code]{0}[/code]",html:"<code>{0}</code>"},left:{styles:{"text-align":["left","-webkit-left","-moz-left","-khtml-left"]},isInline:!1,format:"[left]{0}[/left]",html:'<div align="left">{0}</div>'},center:{styles:{"text-align":["center","-webkit-center","-moz-center","-khtml-center"]},isInline:!1,format:"[center]{0}[/center]",html:'<div align="center">{0}</div>'},right:{styles:{"text-align":["right","-webkit-right","-moz-right","-khtml-right"]},isInline:!1,format:"[right]{0}[/right]",html:'<div align="right">{0}</div>'},justify:{styles:{"text-align":["justify","-webkit-justify","-moz-justify","-khtml-justify"]},isInline:!1,format:"[justify]{0}[/justify]",html:'<div align="justify">{0}</div>'},youtube:{allowsEmpty:!0,tags:{iframe:{"data-youtube-id":null}},format:function(a,b){return a=a.attr("data-youtube-id"),a?"[youtube]"+a+"[/youtube]":b},html:'<iframe width="560" height="315" src="http://www.youtube.com/embed/{0}?wmode=opaque" data-youtube-id="{0}" frameborder="0" allowfullscreen></iframe>'},rtl:{styles:{direction:["rtl"]},format:"[rtl]{0}[/rtl]",html:'<div style="direction: rtl">{0}</div>'},ltr:{styles:{direction:["ltr"]},format:"[ltr]{0}[/ltr]",html:'<div style="direction: ltr">{0}</div>'},ignore:{}},a.sceditor.plugins.bbcode.bbcode={get:function(b){return a.sceditor.plugins.bbcode.bbcodes[b]||null},set:function(b,c){var d=a.sceditor.plugins.bbcode.bbcodes;return b&&c?(c=a.extend(d[b]||{},c),c.remove=function(){delete d[b]},d[b]=c,this):!1},rename:function(b,c){var d=a.sceditor.plugins.bbcode.bbcodes;return b in d?(d[c]=d[b],delete d[b],this):!1},remove:function(b){var c=a.sceditor.plugins.bbcode.bbcodes;return b in c&&delete c[b],this}},a.fn.sceditorBBCodePlugin=function(b){return b=b||{},a.isPlainObject(b)&&(b.plugins=(b.plugins?b.plugins:"")+"bbcode"),this.sceditor(b)}}(jQuery,window,document);

/* SCEditor v2.1.3 | (C) 2017, Sam Clarke | sceditor.com/license */

!function(o){"use strict";function e(e,t){return typeof t===e}o=o&&o.hasOwnProperty("default")?o.default:o;var be=e.bind(null,"string"),xe=e.bind(null,"undefined"),we=e.bind(null,"function"),r=e.bind(null,"number");function t(e){return!Object.keys(e).length}function ke(e,t){for(var n=e===!!e,o=n?2:1,r=n?t:e,i=!!n&&e;o<arguments.length;o++){var l=arguments[o];for(var a in l){var s=l[a];if(!xe(s)){var c=null!==s&&"object"==typeof s&&Object.getPrototypeOf(s)===Object.prototype,u=Array.isArray(s);r[a]=i&&(c||u)?ke(!0,r[a]||(u?[]:{}),s):s}}}return r}function Ce(e,t){var n=e.indexOf(t);-1<n&&e.splice(n,1)}function Ee(t,n){if(Array.isArray(t)||"length"in t&&r(t.length))for(var e=0;e<t.length;e++)n(e,t[e]);else Object.keys(t).forEach(function(e){n(e,t[e])})}var i={},Se=1,Te=3;function l(e){return e=parseFloat(e),isFinite(e)?e:0}function De(e,t,n){var o=(n||document).createElement(e);return Ee(t||{},function(e,t){"style"===e?o.style.cssText=t:e in o?o[e]=t:o.setAttribute(e,t)}),o}function Me(e,t){for(var n=e||{};(n=n.parentNode)&&!/(9|11)/.test(n.nodeType);)if(!t||qe(n,t))return n}function Ne(e,t){return qe(e,t)?e:Me(e,t)}function Be(e){e.parentNode&&e.parentNode.removeChild(e)}function Re(e,t){e.appendChild(t)}function He(e,t){return e.querySelectorAll(t)}var Ie=!0;function Fe(n,e,o,r,i){e.split(" ").forEach(function(e){var t;be(o)?(t=r["_sce-event-"+e+o]||function(e){for(var t=e.target;t&&t!==n;){if(qe(t,o))return void r.call(t,e);t=t.parentNode}},r["_sce-event-"+e+o]=t):(t=o,i=r),n.addEventListener(e,t,i||!1)})}function ze(n,e,o,r,i){e.split(" ").forEach(function(e){var t;be(o)?t=r["_sce-event-"+e+o]:(t=o,i=r),n.removeEventListener(e,t,i||!1)})}function Ae(e,t,n){if(arguments.length<3)return e.getAttribute(t);null==n?a(e,t):e.setAttribute(t,n)}function a(e,t){e.removeAttribute(t)}function Oe(e){je(e,"display","none")}function _e(e){je(e,"display","")}function Le(e){Ge(e)?Oe(e):_e(e)}function je(n,e,t){if(arguments.length<3){if(be(e))return 1===n.nodeType?getComputedStyle(n)[e]:null;Ee(e,function(e,t){je(n,e,t)})}else{var o=(t||0===t)&&!isNaN(t);n.style[e]=o?t+"px":t}}function Pe(e,t,n){var o=arguments.length,r={};if(e.nodeType===Se){if(1===o)return Ee(e.attributes,function(e,t){/^data\-/i.test(t.name)&&(r[t.name.substr(5)]=t.value)}),r;if(2===o)return Ae(e,"data-"+t);Ae(e,"data-"+t,String(n))}}function qe(e,t){var n=!1;return e&&e.nodeType===Se&&(n=(e.matches||e.msMatchesSelector||e.webkitMatchesSelector).call(e,t)),n}function Ve(e,t){return t.parentNode.insertBefore(e,t)}function s(e){return e.className.trim().split(/\s+/)}function We(e,t){return qe(e,"."+t)}function $e(e,t){var n=s(e);n.indexOf(t)<0&&n.push(t),e.className=n.join(" ")}function Ue(e,t){var n=s(e);Ce(n,t),e.className=n.join(" ")}function Ye(e,t,n){(n=xe(n)?!We(e,t):n)?$e(e,t):Ue(e,t)}function Ke(e,t){if(xe(t)){var n=getComputedStyle(e),o=l(n.paddingLeft)+l(n.paddingRight),r=l(n.borderLeftWidth)+l(n.borderRightWidth);return e.offsetWidth-o-r}je(e,"width",t)}function Xe(e,t){if(xe(t)){var n=getComputedStyle(e),o=l(n.paddingTop)+l(n.paddingBottom),r=l(n.borderTopWidth)+l(n.borderBottomWidth);return e.offsetHeight-o-r}je(e,"height",t)}function Qe(e,t,n){var o;we(window.CustomEvent)?o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(o=e.ownerDocument.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(o)}function Ge(e){return!!e.getClientRects().length}function Je(e,t,n,o,r){for(e=r?e.lastChild:e.firstChild;e;){var i=r?e.previousSibling:e.nextSibling;if(!n&&!1===t(e)||!o&&!1===Je(e,t,n,o,r)||n&&!1===t(e))return!1;e=i}}function Ze(e,t,n,o){Je(e,t,n,o,!0)}function et(e,t){var n=(t=t||document).createDocumentFragment(),o=De("div",{},t);for(o.innerHTML=e;o.firstChild;)Re(n,o.firstChild);return n}function tt(e){return e&&(!qe(e,"p,div")||e.className||Ae(e,"style")||!t(Pe(e)))}function nt(e,t){var n=De(t,{},e.ownerDocument);for(Ee(e.attributes,function(e,t){try{Ae(n,t.name,t.value)}catch(e){}});e.firstChild;)Re(n,e.firstChild);return e.parentNode.replaceChild(n,e),n}var c="|body|hr|p|div|h1|h2|h3|h4|h5|h6|address|pre|form|table|tbody|thead|tfoot|th|tr|td|li|ol|ul|blockquote|center|";function ot(e){return!!/11?|9/.test(e.nodeType)&&"|iframe|area|base|basefont|br|col|frame|hr|img|input|wbr|isindex|link|meta|param|command|embed|keygen|source|track|object|".indexOf("|"+e.nodeName.toLowerCase()+"|")<0}function rt(e,t){var n,o=(e||{}).nodeType||Te;return o!==Se?o===Te:"code"===(n=e.tagName.toLowerCase())?!t:c.indexOf("|"+n+"|")<0}function u(e,t){t.style.cssText=e.style.cssText+t.style.cssText}function it(e){Je(e,function(e){var t,n=!rt(e,!0);if(n&&rt(e.parentNode,!0)){var o=function(e){for(;rt(e.parentNode,!0);)e=e.parentNode;return e}(e),r=f(o,e),i=e;u(o,i),Ve(r,o),Ve(i,o)}if(n&&qe(e,"ul,ol")&&qe(e.parentNode,"ul,ol")){var l=("li",(t=e.previousElementSibling)?qe(t,"li")?t:null:t);l||Ve(l=De("li"),e),Re(l,e)}})}function d(e,t){return e?(t?e.previousSibling:e.nextSibling)||d(e.parentNode,t):null}function lt(e){var t,n,o,r,i,l,a,s=je(e,"whiteSpace"),c=/line$/i.test(s),u=e.firstChild;if(!/pre(\-wrap)?$/i.test(s))for(;u;){if(l=u.nextSibling,t=u.nodeValue,(n=u.nodeType)===Se&&u.firstChild&&lt(u),n===Te){for(o=d(u),r=d(u,!0),a=!1;We(r,"sceditor-ignore");)r=d(r,!0);if(rt(u)&&r){for(i=r;i.lastChild;)for(i=i.lastChild;We(i,"sceditor-ignore");)i=d(i,!0);a=i.nodeType===Te?/[\t\n\r ]$/.test(i.nodeValue):!rt(i)}t=t.replace(/\u200B/g,""),r&&rt(r)&&!a||(t=t.replace(c?/^[\t ]+/:/^[\t\n\r ]+/,"")),o&&rt(o)||(t=t.replace(c?/[\t ]+$/:/[\t\n\r ]+$/,"")),t.length?u.nodeValue=t.replace(c?/[\t ]+/g:/[\t\n\r ]+/g," "):Be(u)}u=l}}function f(e,t){var n=e.ownerDocument.createRange();return n.setStartBefore(e),n.setEndAfter(t),n.extractContents()}function at(e){for(var t=0,n=0;e;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;return{left:t,top:n}}function p(e,t){var n,o,r=e.style;if(i[t]||(i[t]=t.replace(/^-ms-/,"ms-").replace(/-(\w)/g,function(e,t){return t.toUpperCase()})),o=r[t=i[t]],"textAlign"===t){if(n=r.direction,o=o||je(e,t),je(e.parentNode,t)===o||"block"!==je(e,"display")||qe(e,"hr,th"))return"";if(/right/i.test(o)&&"rtl"===n||/left/i.test(o)&&"ltr"===n)return""}return o}var st={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source",toolbarExclude:null,style:"jquery.sceditor.default.css",fonts:"Arial,Arial Black,Comic Sans MS,Courier New,Georgia,Impact,Sans-serif,Serif,Times New Roman,Trebuchet MS,Verdana",colors:"#000000,#44B8FF,#1E92F7,#0074D9,#005DC2,#00369B,#b3d5f4|#444444,#C3FFFF,#9DF9FF,#7FDBFF,#68C4E8,#419DC1,#d9f4ff|#666666,#72FF84,#4CEA5E,#2ECC40,#17B529,#008E02,#c0f0c6|#888888,#FFFF44,#FFFA1E,#FFDC00,#E8C500,#C19E00,#fff5b3|#aaaaaa,#FFC95F,#FFA339,#FF851B,#E86E04,#C14700,#ffdbbb|#cccccc,#FF857A,#FF5F54,#FF4136,#E82A1F,#C10300,#ffc6c3|#eeeeee,#FF56FF,#FF30DC,#F012BE,#D900A7,#B20080,#fbb8ec|#ffffff,#F551FF,#CF2BE7,#B10DC9,#9A00B2,#9A00B2,#e8b6ef",locale:Ae(document.documentElement,"lang")||"en",charset:"utf-8",emoticonsCompat:!1,emoticonsEnabled:!0,emoticonsRoot:"",emoticons:{dropdown:{":)":"emoticons/smile.png",":angel:":"emoticons/angel.png",":angry:":"emoticons/angry.png","8-)":"emoticons/cool.png",":'(":"emoticons/cwy.png",":ermm:":"emoticons/ermm.png",":D":"emoticons/grin.png","<3":"emoticons/heart.png",":(":"emoticons/sad.png",":O":"emoticons/shocked.png",":P":"emoticons/tongue.png",";)":"emoticons/wink.png"},more:{":alien:":"emoticons/alien.png",":blink:":"emoticons/blink.png",":blush:":"emoticons/blush.png",":cheerful:":"emoticons/cheerful.png",":devil:":"emoticons/devil.png",":dizzy:":"emoticons/dizzy.png",":getlost:":"emoticons/getlost.png",":happy:":"emoticons/happy.png",":kissing:":"emoticons/kissing.png",":ninja:":"emoticons/ninja.png",":pinch:":"emoticons/pinch.png",":pouty:":"emoticons/pouty.png",":sick:":"emoticons/sick.png",":sideways:":"emoticons/sideways.png",":silly:":"emoticons/silly.png",":sleeping:":"emoticons/sleeping.png",":unsure:":"emoticons/unsure.png",":woot:":"emoticons/w00t.png",":wassat:":"emoticons/wassat.png"},hidden:{":whistling:":"emoticons/whistling.png",":love:":"emoticons/wub.png"}},width:null,height:null,resizeEnabled:!0,resizeMinWidth:null,resizeMinHeight:null,resizeMaxHeight:null,resizeMaxWidth:null,resizeHeight:!0,resizeWidth:!0,dateFormat:"year-month-day",toolbarContainer:null,enablePasteFiltering:!1,disablePasting:!1,readOnly:!1,rtl:!1,autofocus:!1,autofocusEnd:!0,autoExpand:!1,autoUpdate:!1,spellcheck:!0,runWithoutWysiwygSupport:!1,startInSourceMode:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,disableBlockRemove:!1,parserOptions:{},dropDownCss:{}},h=/^(https?|s?ftp|mailto|spotify|skype|ssh|teamspeak|tel):|(\/\/)|data:image\/(png|bmp|gif|p?jpe?g);/i;function ct(e){return e.replace(/([\-.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function ut(e,t){if(!e)return e;var n={"&":"&amp;","<":"&lt;",">":"&gt;"," ":"&nbsp; ","\r\n":"<br />","\r":"<br />","\n":"<br />"};return!1!==t&&(n['"']="&#34;",n["'"]="&#39;",n["`"]="&#96;"),e.replace(/ {2}|\r\n|[&<>\r\n'"`]/g,function(e){return n[e]||e})}var n,m,g,v=navigator.userAgent,y=function(){for(var e=3,t=document,n=t.createElement("div"),o=n.getElementsByTagName("i");n.innerHTML="\x3c!--[if gt IE "+ ++e+"]><i></i><![endif]--\x3e",o[0];);return t.documentMode&&t.all&&window.atob&&(e=10),4===e&&t.documentMode&&(e=11),4<e?e:void 0}(),dt="-ms-ime-align"in document.documentElement.style,ft=/iPhone|iPod|iPad| wosbrowser\//i.test(v),pt=((g=document.createElement("div")).contentEditable=!0,"contentEditable"in document.documentElement&&"true"===g.contentEditable&&(m=/Opera Mobi|Opera Mini/i.test(v),/Android/i.test(v)&&(m=!0,/Safari/.test(v)&&(m=!(n=/Safari\/(\d+)/.exec(v))||!n[1]||n[1]<534)),/ Silk\//i.test(v)&&(m=!(n=/AppleWebKit\/(\d+)/.exec(v))||!n[1]||n[1]<534),ft&&(m=/OS [0-4](_\d)+ like Mac/i.test(v)),/Firefox/i.test(v)&&(m=!1),/OneBrowser/i.test(v)&&(m=!1),"UCWEB"===navigator.vendor&&(m=!1),y<=9&&(m=!0),!m)),b={html:'<!DOCTYPE html><html{attrs}><head><style>.ie * {min-height: auto !important} .ie table td {height:15px} @supports (-ms-ime-align:auto) { * { min-height: auto !important; } }</style><meta http-equiv="Content-Type" content="text/html;charset={charset}" /><link rel="stylesheet" type="text/css" href="{style}" /></head><body contenteditable="true" {spellcheck}><p></p></body></html>',toolbarButton:'<a class="sceditor-button sceditor-button-{name}" data-sceditor-command="{name}" unselectable="on"><div unselectable="on">{dispName}</div></a>',emoticon:'<img src="{url}" data-sceditor-emoticon="{key}" alt="{key}" title="{tooltip}" />',fontOpt:'<a class="sceditor-font-option" href="#" data-font="{font}"><font face="{font}">{font}</font></a>',sizeOpt:'<a class="sceditor-fontsize-option" data-size="{size}" href="#"><font size="{size}">{size}</font></a>',pastetext:'<div><label for="txt">{label}</label> <textarea cols="20" rows="7" id="txt"></textarea></div><div><input type="button" class="button" value="{insert}" /></div>',table:'<div><label for="rows">{rows}</label><input type="text" id="rows" value="2" /></div><div><label for="cols">{cols}</label><input type="text" id="cols" value="2" /></div><div><input type="button" class="button" value="{insert}" /></div>',image:'<div><label for="link">{url}</label> <input type="text" id="image" dir="ltr" placeholder="https://" /></div><div><label for="width">{width}</label> <input type="text" id="width" size="2" dir="ltr" /></div><div><label for="height">{height}</label> <input type="text" id="height" size="2" dir="ltr" /></div><div><input type="button" class="button" value="{insert}" /></div>',email:'<div><label for="email">{label}</label> <input type="text" id="email" dir="ltr" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{insert}" /></div>',link:'<div><label for="link">{url}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><label for="des">{desc}</label> <input type="text" id="des" /></div><div><input type="button" class="button" value="{ins}" /></div>',youtubeMenu:'<div><label for="link">{label}</label> <input type="text" id="link" dir="ltr" placeholder="https://" /></div><div><input type="button" class="button" value="{insert}" /></div>',youtube:'<iframe width="560" height="315" frameborder="0" allowfullscreen src="https://www.youtube.com/embed/{id}?wmode=opaque&start={time}" data-youtube-id="{id}"></iframe>'};function ht(e,t,n){var o=b[e];return Object.keys(t).forEach(function(e){o=o.replace(new RegExp(ct("{"+e+"}"),"g"),t[e])}),n&&(o=et(o)),o}var x=y&&y<11;function w(e){if("mozHidden"in document)for(var t,n=e.getBody();n;){if((t=n).firstChild)t=t.firstChild;else{for(;t&&!t.nextSibling;)t=t.parentNode;t&&(t=t.nextSibling)}3===n.nodeType&&/[\n\r\t]+/.test(n.nodeValue)&&(/^pre/.test(je(n.parentNode,"whiteSpace"))||Be(n)),n=t}}var mt={bold:{exec:"bold",tooltip:"Bold",shortcut:"Ctrl+B"},italic:{exec:"italic",tooltip:"Italic",shortcut:"Ctrl+I"},underline:{exec:"underline",tooltip:"Underline",shortcut:"Ctrl+U"},strike:{exec:"strikethrough",tooltip:"Strikethrough"},subscript:{exec:"subscript",tooltip:"Subscript"},superscript:{exec:"superscript",tooltip:"Superscript"},left:{state:function(e){if(e&&3===e.nodeType&&(e=e.parentNode),e){var t="ltr"===je(e,"direction"),n=je(e,"textAlign");return"left"===n||n===(t?"start":"end")}},exec:"justifyleft",tooltip:"Align left"},center:{exec:"justifycenter",tooltip:"Center"},right:{state:function(e){if(e&&3===e.nodeType&&(e=e.parentNode),e){var t="ltr"===je(e,"direction"),n=je(e,"textAlign");return"right"===n||n===(t?"end":"start")}},exec:"justifyright",tooltip:"Align right"},justify:{exec:"justifyfull",tooltip:"Justify"},font:{_dropDown:function(t,e,n){var o=De("div");Fe(o,"click","a",function(e){n(Pe(this,"font")),t.closeDropDown(!0),e.preventDefault()}),t.opts.fonts.split(",").forEach(function(e){Re(o,ht("fontOpt",{font:e},!0))}),t.createDropDown(e,"font-picker",o)},exec:function(e){var t=this;mt.font._dropDown(t,e,function(e){t.execCommand("fontname",e)})},tooltip:"Font Name"},size:{_dropDown:function(t,e,n){var o=De("div");Fe(o,"click","a",function(e){n(Pe(this,"size")),t.closeDropDown(!0),e.preventDefault()});for(var r=1;r<=7;r++)Re(o,ht("sizeOpt",{size:r},!0));t.createDropDown(e,"fontsize-picker",o)},exec:function(e){var t=this;mt.size._dropDown(t,e,function(e){t.execCommand("fontsize",e)})},tooltip:"Font Size"},color:{_dropDown:function(t,e,n){var o=De("div"),r="",i=mt.color;i._htmlCache||(t.opts.colors.split("|").forEach(function(e){r+='<div class="sceditor-color-column">',e.split(",").forEach(function(e){r+='<a href="#" class="sceditor-color-option" style="background-color: '+e+'" data-color="'+e+'"></a>'}),r+="</div>"}),i._htmlCache=r),Re(o,et(i._htmlCache)),Fe(o,"click","a",function(e){n(Pe(this,"color")),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"color-picker",o)},exec:function(e){var t=this;mt.color._dropDown(t,e,function(e){t.execCommand("forecolor",e)})},tooltip:"Font Color"},removeformat:{exec:"removeformat",tooltip:"Remove Formatting"},cut:{exec:"cut",tooltip:"Cut",errorMessage:"Your browser does not allow the cut command. Please use the keyboard shortcut Ctrl/Cmd-X"},copy:{exec:"copy",tooltip:"Copy",errorMessage:"Your browser does not allow the copy command. Please use the keyboard shortcut Ctrl/Cmd-C"},paste:{exec:"paste",tooltip:"Paste",errorMessage:"Your browser does not allow the paste command. Please use the keyboard shortcut Ctrl/Cmd-V"},pastetext:{exec:function(e){var t,n=De("div"),o=this;Re(n,ht("pastetext",{label:o._("Paste your text inside the following box:"),insert:o._("Insert")},!0)),Fe(n,"click",".button",function(e){(t=He(n,"#txt")[0].value)&&o.wysiwygEditorInsertText(t),o.closeDropDown(!0),e.preventDefault()}),o.createDropDown(e,"pastetext",n)},tooltip:"Paste Text"},bulletlist:{exec:function(){w(this),this.execCommand("insertunorderedlist")},tooltip:"Bullet list"},orderedlist:{exec:function(){w(this),this.execCommand("insertorderedlist")},tooltip:"Numbered list"},indent:{state:function(e,t){var n,o,r;return qe(t,"li")?0:qe(t,"ul,ol,menu")&&(o=(n=this.getRangeHelper().selectedRange()).startContainer.parentNode,r=n.endContainer.parentNode,o!==o.parentNode.firstElementChild||qe(r,"li")&&r!==r.parentNode.lastElementChild)?0:-1},exec:function(){var e=this.getRangeHelper().getFirstBlockParent();this.focus(),Ne(e,"ul,ol,menu")&&this.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(e,t){return Ne(t,"ul,ol,menu")?0:-1},exec:function(){Ne(this.getRangeHelper().getFirstBlockParent(),"ul,ol,menu")&&this.execCommand("outdent")},tooltip:"Remove one indent"},table:{exec:function(e){var r=this,i=De("div");Re(i,ht("table",{rows:r._("Rows:"),cols:r._("Cols:"),insert:r._("Insert")},!0)),Fe(i,"click",".button",function(e){var t=Number(He(i,"#rows")[0].value),n=Number(He(i,"#cols")[0].value),o="<table>";0<t&&0<n&&(o+=Array(t+1).join("<tr>"+Array(n+1).join("<td>"+(x?"":"<br />")+"</td>")+"</tr>"),o+="</table>",r.wysiwygEditorInsertHtml(o),r.closeDropDown(!0),e.preventDefault())}),r.createDropDown(e,"inserttable",i)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{exec:function(){this.wysiwygEditorInsertHtml("<code>",(x?"":"<br />")+"</code>")},tooltip:"Code"},image:{_dropDown:function(t,e,n,o){var r=De("div");Re(r,ht("image",{url:t._("URL:"),width:t._("Width (optional):"),height:t._("Height (optional):"),insert:t._("Insert")},!0));var i=He(r,"#image")[0];i.value=n,Fe(r,"click",".button",function(e){i.value&&o(i.value,He(r,"#width")[0].value,He(r,"#height")[0].value),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertimage",r)},exec:function(e){var r=this;mt.image._dropDown(r,e,"",function(e,t,n){var o="";t&&(o+=' width="'+parseInt(t)+'"'),n&&(o+=' height="'+parseInt(n)+'"'),o+=' src="'+ut(e)+'"',r.wysiwygEditorInsertHtml("<img"+o+" />")})},tooltip:"Insert an image"},email:{_dropDown:function(n,e,o){var r=De("div");Re(r,ht("email",{label:n._("E-mail:"),desc:n._("Description (optional):"),insert:n._("Insert")},!0)),Fe(r,"click",".button",function(e){var t=He(r,"#email")[0].value;t&&o(t,He(r,"#des")[0].value),n.closeDropDown(!0),e.preventDefault()}),n.createDropDown(e,"insertemail",r)},exec:function(e){var n=this;mt.email._dropDown(n,e,function(e,t){n.focus(),!n.getRangeHelper().selectedHtml()||t?n.wysiwygEditorInsertHtml('<a href="mailto:'+ut(e)+'">'+ut(t||e)+"</a>"):n.execCommand("createlink","mailto:"+e)})},tooltip:"Insert an email"},link:{_dropDown:function(t,e,n){var o=De("div");Re(o,ht("link",{url:t._("URL:"),desc:t._("Description (optional):"),ins:t._("Insert")},!0));var r=He(o,"#link")[0];function i(e){r.value&&n(r.value,He(o,"#des")[0].value),t.closeDropDown(!0),e.preventDefault()}Fe(o,"click",".button",i),Fe(o,"keypress",function(e){13===e.which&&r.value&&i(e)},Ie),t.createDropDown(e,"insertlink",o)},exec:function(e){var n=this;mt.link._dropDown(n,e,function(e,t){n.focus(),t||!n.getRangeHelper().selectedHtml()?(t=t||e,n.wysiwygEditorInsertHtml('<a href="'+ut(e)+'">'+ut(t)+"</a>")):n.execCommand("createlink",e)})},tooltip:"Insert a link"},unlink:{state:function(){return Ne(this.currentNode(),"a")?0:-1},exec:function(){var e=Ne(this.currentNode(),"a");if(e){for(;e.firstChild;)Ve(e.firstChild,e);Be(e)}},tooltip:"Unlink"},quote:{exec:function(e,t,n){var o="<blockquote>",r="</blockquote>";t?(o=o+(n=n?"<cite>"+ut(n)+"</cite>":"")+t+r,r=null):""===this.getRangeHelper().selectedHtml()&&(r=(x?"":"<br />")+r),this.wysiwygEditorInsertHtml(o,r)},tooltip:"Insert a Quote"},emoticon:{exec:function(f){var p=this,h=function(e){var t,n,o=p.opts,r=o.emoticonsRoot||"",i=o.emoticonsCompat,l=p.getRangeHelper(),a=i&&" "!==l.getOuterText(!0,1)?" ":"",s=i&&" "!==l.getOuterText(!1,1)?" ":"",c=De("div"),u=De("div"),d=ke({},o.emoticons.dropdown,e?o.emoticons.more:{});return Re(c,u),n=Math.sqrt(Object.keys(d).length),Fe(c,"click","img",function(e){p.insert(a+Ae(this,"alt")+s,null,!1).closeDropDown(!0),e.preventDefault()}),Ee(d,function(e,t){Re(u,De("img",{src:r+(t.url||t),alt:e,title:t.tooltip||e})),u.children.length>=n&&(u=De("div"),Re(c,u))}),!e&&o.emoticons.more&&(Re(t=De("a",{className:"sceditor-more"}),document.createTextNode(p._("More"))),Fe(t,"click",function(e){p.createDropDown(f,"more-emoticons",h(!0)),e.preventDefault()}),Re(c,t)),c};p.createDropDown(f,"emoticons",h(!1))},txtExec:function(e){mt.emoticon.exec.call(this,e)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(i,e,l){var a=De("div");Re(a,ht("youtubeMenu",{label:i._("Video URL:"),insert:i._("Insert")},!0)),Fe(a,"click",".button",function(e){var t=He(a,"#link")[0].value,n=t.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/),o=t.match(/[&|?](?:star)?t=((\d+[hms]?){1,3})/),r=0;o&&Ee(o[1].split(/[hms]/),function(e,t){""!==t&&(r=60*r+Number(t))}),n&&/^[a-zA-Z0-9_\-]{11}$/.test(n[1])&&l(n[1],r),i.closeDropDown(!0),e.preventDefault()}),i.createDropDown(e,"insertlink",a)},exec:function(e){var n=this;mt.youtube._dropDown(n,e,function(e,t){n.wysiwygEditorInsertHtml(ht("youtube",{id:e,time:t}))})},tooltip:"Insert a YouTube video"},date:{_date:function(e){var t=new Date,n=t.getYear(),o=t.getMonth()+1,r=t.getDate();return n<2e3&&(n=1900+n),o<10&&(o="0"+o),r<10&&(r="0"+r),e.opts.dateFormat.replace(/year/i,n).replace(/month/i,o).replace(/day/i,r)},exec:function(){this.insertText(mt.date._date(this))},txtExec:function(){this.insertText(mt.date._date(this))},tooltip:"Insert current date"},time:{_time:function(){var e=new Date,t=e.getHours(),n=e.getMinutes(),o=e.getSeconds();return t<10&&(t="0"+t),n<10&&(n="0"+n),o<10&&(o="0"+o),t+":"+n+":"+o},exec:function(){this.insertText(mt.time._time())},txtExec:function(){this.insertText(mt.time._time())},tooltip:"Insert current time"},ltr:{state:function(e,t){return t&&"ltr"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!qe(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!qe(t,"body")))&&je(t,"direction","ltr"===je(t,"direction")?"":"ltr")},tooltip:"Left-to-Right"},rtl:{state:function(e,t){return t&&"rtl"===t.style.direction},exec:function(){var e=this.getRangeHelper(),t=e.getFirstBlockParent();this.focus(),(t&&!qe(t,"body")||(this.execCommand("formatBlock","p"),(t=e.getFirstBlockParent())&&!qe(t,"body")))&&je(t,"direction","rtl"===je(t,"direction")?"":"rtl")},tooltip:"Right-to-Left"},print:{exec:"print",tooltip:"Print"},maximize:{state:function(){return this.maximize()},exec:function(){this.maximize(!this.maximize())},txtExec:function(){this.maximize(!this.maximize())},tooltip:"Maximize",shortcut:"Ctrl+Shift+M"},source:{state:function(){return this.sourceMode()},exec:function(){this.toggleSourceMode()},txtExec:function(){this.toggleSourceMode()},tooltip:"View source",shortcut:"Ctrl+Shift+S"},ignore:{}},k={};function gt(i){var r=this,l=[],a=function(e){return"signal"+e.charAt(0).toUpperCase()+e.slice(1)},e=function(e,t){e=[].slice.call(e);var n,o,r=a(e.shift());for(n=0;n<l.length;n++)if(r in l[n]&&(o=l[n][r].apply(i,e),t))return o};r.call=function(){e(arguments,!1)},r.callOnlyFirst=function(){return e(arguments,!0)},r.hasHandler=function(e){var t=l.length;for(e=a(e);t--;)if(e in l[t])return!0;return!1},r.exists=function(e){return e in k&&"function"==typeof(e=k[e])&&"object"==typeof e.prototype},r.isRegistered=function(e){if(r.exists(e))for(var t=l.length;t--;)if(l[t]instanceof k[e])return!0;return!1},r.register=function(e){return!(!r.exists(e)||r.isRegistered(e)||(e=new k[e],l.push(e),"init"in e&&e.init.call(i),0))},r.deregister=function(e){var t,n=l.length,o=!1;if(!r.isRegistered(e))return o;for(;n--;)l[n]instanceof k[e]&&(o=!0,"destroy"in(t=l.splice(n,1)[0])&&t.destroy.call(i));return o},r.destroy=function(){for(var e=l.length;e--;)"destroy"in l[e]&&l[e].destroy.call(i);l=[],i=null}}gt.plugins=k;var C=y&&y<11,E=function(e,t,n){var o,r,i,l,a,s="",c=e.startContainer,u=e.startOffset;for(c&&3!==c.nodeType&&(c=c.childNodes[u],u=0),i=l=u;n>s.length&&c&&3===c.nodeType;)o=c.nodeValue,r=n-s.length,a&&(l=o.length,i=0),a=c,t?(u=i=Math.max(l-r,0),s=o.substr(i,l-i)+s,c=a.previousSibling):(u=i+(l=Math.min(r,o.length)),s+=o.substr(i,l),c=a.nextSibling);return{node:a||c,offset:u,text:s}};function vt(i,e){var l,a,s=e||i.contentDocument||i.document,c="sceditor-start-marker",u="sceditor-end-marker",y=this;y.insertHTML=function(e,t){var n,o;if(!y.selectedRange())return!1;for(t&&(e+=y.selectedHtml()+t),o=De("p",{},s),n=s.createDocumentFragment(),o.innerHTML=e;o.firstChild;)Re(n,o.firstChild);y.insertNode(n)},a=function(e,t,n){var o,r=s.createDocumentFragment();if("string"==typeof e?(t&&(e+=y.selectedHtml()+t),r=et(e)):(Re(r,e),t&&(Re(r,y.selectedRange().extractContents()),Re(r,t))),o=r.lastChild){for(;!rt(o.lastChild,!0);)o=o.lastChild;if(ot(o)?o.lastChild||Re(o,document.createTextNode("​")):o=r,y.removeMarkers(),Re(o,l(c)),Re(o,l(u)),n){var i=De("div");return Re(i,r),i.innerHTML}return r}},y.insertNode=function(e,t){var n=a(e,t),o=y.selectedRange(),r=o.commonAncestorContainer;if(!n)return!1;o.deleteContents(),r&&3!==r.nodeType&&!ot(r)?Ve(n,r):o.insertNode(n),y.restoreRange()},y.cloneSelected=function(){var e=y.selectedRange();if(e)return e.cloneRange()},y.selectedRange=function(){var e,t,n=i.getSelection();if(n){if(n.rangeCount<=0){for(t=s.body;t.firstChild;)t=t.firstChild;(e=s.createRange()).setStartBefore(t),n.addRange(e)}return 0<n.rangeCount&&(e=n.getRangeAt(0)),e}},y.hasSelection=function(){var e=i.getSelection();return e&&0<e.rangeCount},y.selectedHtml=function(){var e,t=y.selectedRange();return t?(Re(e=De("p",{},s),t.cloneContents()),e.innerHTML):""},y.parentNode=function(){var e=y.selectedRange();if(e)return e.commonAncestorContainer},y.getFirstBlockParent=function(e){var t=function(e){return rt(e,!0)&&(e=e?e.parentNode:null)?t(e):e};return t(e||y.parentNode())},y.insertNodeAt=function(e,t){var n=y.selectedRange(),o=y.cloneSelected();if(!o)return!1;o.collapse(e),o.insertNode(t),y.selectRange(n)},l=function(e){y.removeMarker(e);var t=De("span",{id:e,className:"sceditor-selection sceditor-ignore",style:"display:none;line-height:0"},s);return t.innerHTML=" ",t},y.insertMarkers=function(){var e=y.selectedRange(),t=l(c);y.removeMarkers(),y.insertNodeAt(!0,t),e&&e.collapsed?t.parentNode.insertBefore(l(u),t.nextSibling):y.insertNodeAt(!1,l(u))},y.getMarker=function(e){return s.getElementById(e)},y.removeMarker=function(e){var t=y.getMarker(e);t&&Be(t)},y.removeMarkers=function(){y.removeMarker(c),y.removeMarker(u)},y.saveRange=function(){y.insertMarkers()},y.selectRange=function(e){var t,n=i.getSelection(),o=e.endContainer;if(!C&&e.collapsed&&o&&!rt(o,!0)){for(t=o.lastChild;t&&qe(t,".sceditor-ignore");)t=t.previousSibling;if(qe(t,"br")){var r=s.createRange();r.setEndAfter(t),r.collapse(!1),y.compare(e,r)&&(e.setStartBefore(t),e.collapse(!0))}}n&&(y.clear(),n.addRange(e))},y.restoreRange=function(){var e,t=y.selectedRange(),n=y.getMarker(c),o=y.getMarker(u);if(!n||!o||!t)return!1;e=n.nextSibling===o,(t=s.createRange()).setStartBefore(n),t.setEndAfter(o),e&&t.collapse(!0),y.selectRange(t),y.removeMarkers()},y.selectOuterText=function(e,t){var n,o,r=y.cloneSelected();if(!r)return!1;r.collapse(!1),n=E(r,!0,e),o=E(r,!1,t),r.setStart(n.node,n.offset),r.setEnd(o.node,o.offset),y.selectRange(r)},y.getOuterText=function(e,t){var n=y.cloneSelected();return n?(n.collapse(!e),E(n,e,t).text):""},y.replaceKeyword=function(e,t,n,o,r,i){n||e.sort(function(e,t){return e[0].length-t[0].length});var l,a,s,c,u,d,f,p,h="(^|[\\s    ])",m=e.length,g=r?1:0,v=o||e[m-1][0].length;for(r&&v++,i=i||"",u=(l=y.getOuterText(!0,v)).length,l+=i,t&&(l+=y.getOuterText(!1,v));m--;)if(p=(f=e[m][0]).length,c=Math.max(0,u-p-g),s=-1,r?(a=l.substr(c).match(new RegExp(h+ct(f)+h)))&&(s=a.index+c+a[1].length):s=l.indexOf(f,c),-1<s&&s<=u&&u<=s+p+g)return d=u-s,y.selectOuterText(d,p-d-(/^\S/.test(i)?1:0)),y.insertHTML(e[m][1]),!0;return!1},y.compare=function(e,t){return t||(t=y.selectedRange()),e&&t?0===e.compareBoundaryPoints(Range.END_TO_END,t)&&0===e.compareBoundaryPoints(Range.START_TO_START,t):!e&&!t},y.clear=function(){var e=i.getSelection();e&&(e.removeAllRanges?e.removeAllRanges():e.empty&&e.empty())}}var yt=window,bt=document,xt=y,wt=xt&&xt<11,kt=/^image\/(p?jpe?g|gif|png|bmp)$/i;function Ct(a,e){var l,w,u,s,i,h,d,c,f,p,m,g,t,v,r,y,b,x,k,n,o,C,E,S,T,D,M,N,B,R,H,I,F,z,A,O,_,L,j,P,q,V,W,$,U,Y,K,X,Q,G,J,Z,ee,te,ne,oe,re,ie,le,ae,se,ce,ue,de=this,fe={},pe=[],he=[],me={},ge={},ve={};de.commands=ke(!0,{},e.commands||mt);var ye=de.opts=ke(!0,{},st,e);de.opts.emoticons=e.emoticons||st.emoticons,M=function(){a._sceditor=de,ye.locale&&"en"!==ye.locale&&F(),Ve(w=De("div",{className:"sceditor-container"}),a),je(w,"z-index",ye.zIndex),xt&&$e(w,"ie ie"+xt),n=a.required,a.required=!1;var e=Ct.formats[ye.format];"init"in(l=e?new e:{})&&l.init.call(de),I(),L(),z(),H(),A(),O(),pt||de.toggleSourceMode(),G();var t=function(){ze(yt,"load",t),ye.autofocus&&ne(),ue(),Z(),r.call("ready"),"onReady"in l&&l.onReady.call(de)};Fe(yt,"load",t),"complete"===bt.readyState&&t()},I=function(){var e=ye.plugins;e=e?e.toString().split(","):[],r=new gt(de),e.forEach(function(e){r.register(e.trim())})},F=function(){var e;(t=Ct.locale[ye.locale])||(e=ye.locale.split("-"),t=Ct.locale[e[0]]),t&&t.dateFormat&&(ye.dateFormat=t.dateFormat)},H=function(){c=De("textarea"),s=De("iframe",{frameborder:0,allowfullscreen:!0}),ye.startInSourceMode?($e(w,"sourceMode"),Oe(s)):($e(w,"wysiwygMode"),Oe(c)),ye.spellcheck||Ae(w,"spellcheck","false"),"https:"===yt.location.protocol&&Ae(s,"src","javascript:false"),Re(w,s),Re(w,c),de.dimensions(ye.width||Ke(a),ye.height||Xe(a));var e=xt?"ie ie"+xt:"";e+=ft?" ios":"",(d=s.contentDocument).open(),d.write(ht("html",{attrs:' class="'+e+'"',spellcheck:ye.spellcheck?"":'spellcheck="false"',charset:ye.charset,style:ye.style})),d.close(),h=d.body,i=s.contentWindow,de.readOnly(!!ye.readOnly),(ft||dt||xt)&&(Xe(h,"100%"),xt||Fe(h,"touchend",de.focus));var t=Ae(a,"tabindex");Ae(c,"tabindex",t),Ae(s,"tabindex",t),v=new vt(i),Oe(a),de.val(a.value);var n=ye.placeholder||Ae(a,"placeholder");n&&(c.placeholder=n,Ae(h,"placeholder",n))},A=function(){ye.autoUpdate&&(Fe(h,"blur",ce),Fe(c,"blur",ce)),null===ye.rtl&&(ye.rtl="rtl"===je(c,"direction")),de.rtl(!!ye.rtl),ye.autoExpand&&(Fe(h,"load",ue,Ie),Fe(h,"input keyup",ue)),ye.resizeEnabled&&_(),Ae(w,"id",ye.id),de.emoticons(ye.emoticonsEnabled)},O=function(){var e=a.form,t="compositionstart compositionend",n="keydown keyup keypress focus blur contextmenu",o="onselectionchange"in d?"selectionchange":"keyup focus blur contextmenu mouseup touchend click";Fe(bt,"click",X),e&&(Fe(e,"reset",$),Fe(e,"submit",de.updateOriginal,Ie)),Fe(h,"keypress",W),Fe(h,"keydown",q),Fe(h,"keydown",V),Fe(h,"keyup",Z),Fe(h,"blur",ae),Fe(h,"keyup",se),Fe(h,"paste",j),Fe(h,t,Y),Fe(h,o,ee),Fe(h,n,K),ye.emoticonsCompat&&yt.getSelection&&Fe(h,"keyup",re),Fe(h,"blur",function(){de.val()||$e(h,"placeholder")}),Fe(h,"focus",function(){Ue(h,"placeholder")}),Fe(c,"blur",ae),Fe(c,"keyup",se),Fe(c,"keydown",q),Fe(c,t,Y),Fe(c,n,K),Fe(d,"mousedown",U),Fe(d,o,ee),Fe(d,"beforedeactivate keyup mouseup",R),Fe(d,"keyup",Z),Fe(d,"focus",function(){p=null}),Fe(w,"selectionchanged",te),Fe(w,"selectionchanged",G),Fe(w,"selectionchanged valuechanged nodechanged pasteraw paste",K)},z=function(){var i,l=de.commands,a=(ye.toolbarExclude||"").split(","),e=ye.toolbar.split("|");u=De("div",{className:"sceditor-toolbar",unselectable:"on"}),ye.icons in Ct.icons&&(D=new Ct.icons[ye.icons]),Ee(e,function(e,t){i=De("div",{className:"sceditor-group"}),Ee(t.split(","),function(e,t){var n,o,r=l[t];!r||-1<a.indexOf(t)||(o=r.shortcut,n=ht("toolbarButton",{name:t,dispName:de._(r.name||r.tooltip||t)},!0).firstChild,D&&D.create&&D.create(t)&&(Ve(D.create(t),n.firstChild),$e(n,"has-icon")),n._sceTxtMode=!!r.txtExec,n._sceWysiwygMode=!!r.exec,Ye(n,"disabled",!r.exec),Fe(n,"click",function(e){We(n,"disabled")||B(n,r),G(),e.preventDefault()}),Fe(n,"mousedown",function(e){de.closeDropDown(),e.preventDefault()}),r.tooltip&&Ae(n,"title",de._(r.tooltip)+(o?" ("+o+")":"")),o&&de.addShortcut(o,t),r.state?he.push({name:t,state:r.state}):be(r.exec)&&he.push({name:t,state:r.exec}),Re(i,n),ge[t]=n)}),i.firstChild&&Re(u,i)}),Re(ye.toolbarContainer||w,u)},_=function(){var o,r,i,l,t,n,e=De("div",{className:"sceditor-grip"}),a=De("div",{className:"sceditor-resize-cover"}),s="touchmove mousemove",c="touchcancel touchend mouseup",u=0,d=0,f=0,p=0,h=0,m=0,g=Ke(w),v=Xe(w),y=!1,b=de.rtl();if(o=ye.resizeMinHeight||v/1.5,r=ye.resizeMaxHeight||2.5*v,i=ye.resizeMinWidth||g/1.25,l=ye.resizeMaxWidth||1.25*g,t=function(e){"touchmove"===e.type?(e=yt.event,f=e.changedTouches[0].pageX,p=e.changedTouches[0].pageY):(f=e.pageX,p=e.pageY);var t=m+(p-d),n=b?h-(f-u):h+(f-u);0<l&&l<n&&(n=l),0<i&&n<i&&(n=i),ye.resizeWidth||(n=!1),0<r&&r<t&&(t=r),0<o&&t<o&&(t=o),ye.resizeHeight||(t=!1),(n||t)&&de.dimensions(n,t),e.preventDefault()},n=function(e){y&&(y=!1,Oe(a),Ue(w,"resizing"),ze(bt,s,t),ze(bt,c,n),e.preventDefault())},D&&D.create){var x=D.create("grip");x&&(Re(e,x),$e(e,"has-icon"))}Re(w,e),Re(w,a),Oe(a),Fe(e,"touchstart mousedown",function(e){"touchstart"===e.type?(e=yt.event,u=e.touches[0].pageX,d=e.touches[0].pageY):(u=e.pageX,d=e.pageY),h=Ke(w),m=Xe(w),y=!0,$e(w,"resizing"),_e(a),Fe(bt,s,t),Fe(bt,c,n),e.preventDefault()})},L=function(){var e=ye.emoticons,n=ye.emoticonsRoot||"";e&&(ve=ke({},e.more,e.dropdown,e.hidden)),Ee(ve,function(e,t){ve[e]=ht("emoticon",{key:e,url:n+(t.url||t),tooltip:t.tooltip||e}),ye.emoticonsEnabled&&pe.push(De("img",{src:n+(t.url||t)}))})},ne=function(){var e,t,n=h.firstChild,o=!!ye.autofocusEnd;if(Ge(w)){if(de.sourceMode())return t=o?c.value.length:0,void c.setSelectionRange(t,t);if(lt(h),o)for((n=h.lastChild)||(n=De("p",{},d),Re(h,n));n.lastChild;)n=n.lastChild,!wt&&qe(n,"br")&&n.previousSibling&&(n=n.previousSibling);e=d.createRange(),ot(n)?e.selectNodeContents(n):(e.setStartBefore(n),o&&e.setStartAfter(n)),e.collapse(!o),v.selectRange(e),x=e,o&&(h.scrollTop=h.scrollHeight),de.focus()}},de.readOnly=function(e){return"boolean"!=typeof e?!c.readonly:(h.contentEditable=!e,c.readonly=!e,Q(e),de)},de.rtl=function(e){var t=e?"rtl":"ltr";return"boolean"!=typeof e?"rtl"===Ae(c,"dir"):(Ae(h,"dir",t),Ae(c,"dir",t),Ue(w,"rtl"),Ue(w,"ltr"),$e(w,t),D&&D.rtl&&D.rtl(e),de)},Q=function(n){var o=de.inSourceMode()?"_sceTxtMode":"_sceWysiwygMode";Ee(ge,function(e,t){Ye(t,"disabled",n||!t[o])})},de.width=function(e,t){return e||0===e?(de.dimensions(e,null,t),de):Ke(w)},de.dimensions=function(e,t,n){return t=!(!t&&0!==t)&&t,!1===(e=!(!e&&0!==e)&&e)&&!1===t?{width:de.width(),height:de.height()}:(!1!==e&&(!1!==n&&(ye.width=e),Ke(w,e)),!1!==t&&(!1!==n&&(ye.height=t),Xe(w,t)),de)},de.height=function(e,t){return e||0===e?(de.dimensions(null,e,t),de):Xe(w)},de.maximize=function(e){var t="sceditor-maximize";return xe(e)?We(w,t):((e=!!e)&&(S=yt.pageYOffset),Ye(bt.documentElement,t,e),Ye(bt.body,t,e),Ye(w,t,e),de.width(e?"100%":ye.width,!1),de.height(e?"100%":ye.height,!1),e||yt.scrollTo(0,S),ue(),de)},ue=function(){ye.autoExpand&&!E&&(E=setTimeout(de.expandToContent,200))},de.expandToContent=function(e){if(!de.maximize()){if(clearTimeout(E),E=!1,!C){var t=ye.resizeMinHeight||ye.height||Xe(a);C={min:t,max:ye.resizeMaxHeight||2*t}}var n=bt.createRange();n.selectNodeContents(h);var o=n.getBoundingClientRect(),r=d.documentElement.clientHeight-1,i=o.bottom-o.top,l=de.height()+1+(i-r);e||-1===C.max||(l=Math.min(l,C.max)),de.height(Math.ceil(Math.max(l,C.min)))}},de.destroy=function(){if(r){r.destroy(),r=p=v=null,f&&Be(f),ze(bt,"click",X);var e=a.form;e&&(ze(e,"reset",$),ze(e,"submit",de.updateOriginal)),Be(c),Be(u),Be(w),delete a._sceditor,_e(a),a.required=n}},de.createDropDown=function(e,t,n,o){var r,i="sceditor-"+t;de.closeDropDown(!0),f&&We(f,i)||(!1!==o&&Ee(He(n,":not(input):not(textarea)"),function(e,t){t.nodeType===Se&&Ae(t,"unselectable","on")}),r=ke({top:e.offsetTop,left:e.offsetLeft,marginTop:e.clientHeight},ye.dropDownCss),je(f=De("div",{className:"sceditor-dropdown "+i}),r),Re(f,n),Re(w,f),Fe(f,"click focusin",function(e){e.stopPropagation()}),setTimeout(function(){if(f){var e=He(f,"input,textarea")[0];e&&e.focus()}}))},X=function(e){3!==e.which&&f&&!e.defaultPrevented&&(ce(),de.closeDropDown())},j=function(e){var t,n,o=xt||dt,r=h,i=e.clipboardData;if(i&&!o){var l={},a=i.types,s=i.items;e.preventDefault();for(var c=0;c<a.length;c++){if(yt.FileReader&&s&&kt.test(s[c].type))return t=i.items[c].getAsFile(),n=void 0,(n=new FileReader).onload=function(e){P({html:'<img src="'+e.target.result+'" />'})},void n.readAsDataURL(t);l[a[c]]=i.getData(a[c])}l.text=l["text/plain"],l.html=l["text/html"],P(l)}else if(!T){var u=r.scrollTop;for(v.saveRange(),T=bt.createDocumentFragment();r.firstChild;)Re(T,r.firstChild);setTimeout(function(){var e=r.innerHTML;r.innerHTML="",Re(r,T),r.scrollTop=u,T=!1,v.restoreRange(),P({html:e})},0)}},P=function(e){var t=De("div",{},d);r.call("pasteRaw",e),Qe(w,"pasteraw",e),e.html?(t.innerHTML=e.html,it(t)):t.innerHTML=ut(e.text||"");var n={val:t.innerHTML};"fragmentToSource"in l&&(n.val=l.fragmentToSource(n.val,d,y)),r.call("paste",n),Qe(w,"paste",n),"fragmentToHtml"in l&&(n.val=l.fragmentToHtml(n.val,y)),r.call("pasteHtml",n),de.wysiwygEditorInsertHtml(n.val,null,!0)},de.closeDropDown=function(e){f&&(Be(f),f=null),!0===e&&de.focus()},de.wysiwygEditorInsertHtml=function(e,t,n){var o,r,i,l=Xe(s);de.focus(),!n&&Ne(b,"code")||(v.insertHTML(e,t),v.saveRange(),N(),_e(o=He(h,"#sceditor-end-marker")[0]),r=h.scrollTop,i=at(o).top+1.5*o.offsetHeight-l,Oe(o),(r<i||i+l<r)&&(h.scrollTop=i),le(!1),v.restoreRange(),Z())},de.wysiwygEditorInsertText=function(e,t){de.wysiwygEditorInsertHtml(ut(e),ut(t))},de.insertText=function(e,t){return de.inSourceMode()?de.sourceEditorInsertText(e,t):de.wysiwygEditorInsertText(e,t),de},de.sourceEditorInsertText=function(e,t){var n,o,r=c.selectionStart,i=c.selectionEnd;n=c.scrollTop,c.focus(),o=c.value,t&&(e+=o.substring(r,i)+t),c.value=o.substring(0,r)+e+o.substring(i,o.length),c.selectionStart=r+e.length-(t?t.length:0),c.selectionEnd=c.selectionStart,c.scrollTop=n,c.focus(),le()},de.getRangeHelper=function(){return v},de.sourceEditorCaret=function(e){return c.focus(),e?(c.selectionStart=e.start,c.selectionEnd=e.end,this):{start:c.selectionStart,end:c.selectionEnd}},de.val=function(e,t){return be(e)?(de.inSourceMode()?de.setSourceEditorValue(e):(!1!==t&&"toHtml"in l&&(e=l.toHtml(e)),de.setWysiwygEditorValue(e)),de):de.inSourceMode()?de.getSourceEditorValue(!1):de.getWysiwygEditorValue(t)},de.insert=function(e,t,n,o,r){if(de.inSourceMode())return de.sourceEditorInsertText(e,t),de;if(t){var i=v.selectedHtml();!1!==n&&"fragmentToSource"in l&&(i=l.fragmentToSource(i,d,y)),e+=i+t}return!1!==n&&"fragmentToHtml"in l&&(e=l.fragmentToHtml(e,y)),!1!==n&&!0===r&&(e=e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")),de.wysiwygEditorInsertHtml(e),de},de.getWysiwygEditorValue=function(e){for(var t,n=De("div",{},d),o=h.childNodes,r=0;r<o.length;r++)Re(n,o[r].cloneNode(!0));return Re(h,n),it(n),Be(n),t=n.innerHTML,!1!==e&&l.hasOwnProperty("toSource")&&(t=l.toSource(t,d)),t},de.getBody=function(){return h},de.getContentAreaContainer=function(){return s},de.getSourceEditorValue=function(e){var t=c.value;return!1!==e&&"toHtml"in l&&(t=l.toHtml(t)),t},de.setWysiwygEditorValue=function(e){e||(e="<p>"+(xt?"":"<br />")+"</p>"),h.innerHTML=e,N(),Z(),le(),ue()},de.setSourceEditorValue=function(e){c.value=e,le()},de.updateOriginal=function(){a.value=de.val()},N=function(){var e,c,u,d,t,f,p;ye.emoticonsEnabled&&(e=h,c=ve,u=ye.emoticonsCompat,d=e.ownerDocument,t="(^|\\s| | | | |$)",f=[],p={},Me(e,"code")||(Ee(c,function(e){p[e]=new RegExp(t+ct(e)+t),f.push(e)}),f.sort(function(e,t){return t.length-e.length}),function e(t){for(t=t.firstChild;t;){if(t.nodeType!==Se||qe(t,"code")||e(t),t.nodeType===Te)for(var n=0;n<f.length;n++){var o=t.nodeValue,r=f[n],i=u?o.search(p[r]):o.indexOf(r);if(-1<i){var l=o.indexOf(r,i),a=et(c[r],d),s=o.substr(l+r.length);a.appendChild(d.createTextNode(s)),t.nodeValue=o.substr(0,l),t.parentNode.insertBefore(a,t.nextSibling)}}t=t.nextSibling}}(e)))},de.inSourceMode=function(){return We(w,"sourceMode")},de.sourceMode=function(e){var t=de.inSourceMode();return"boolean"!=typeof e?t:((t&&!e||!t&&e)&&de.toggleSourceMode(),de)},de.toggleSourceMode=function(){var e=de.inSourceMode();!pt&&e||(e||(v.saveRange(),v.clear()),de.blur(),e?de.setWysiwygEditorValue(de.getSourceEditorValue()):de.setSourceEditorValue(de.getWysiwygEditorValue()),p=null,Le(c),Le(s),Ye(w,"wysiwygMode",e),Ye(w,"sourceMode",!e),Q(),G())},J=function(){return c.focus(),c.value.substring(c.selectionStart,c.selectionEnd)},B=function(e,t){de.inSourceMode()?t.txtExec&&(Array.isArray(t.txtExec)?de.sourceEditorInsertText.apply(de,t.txtExec):t.txtExec.call(de,e,J())):t.exec&&(we(t.exec)?t.exec.call(de,e):de.execCommand(t.exec,t.hasOwnProperty("execParam")?t.execParam:null))},R=function(){xt&&(p=v.selectedRange())},de.execCommand=function(e,t){var n=!1,o=de.commands[e];if(de.focus(),!Ne(v.parentNode(),"code")){try{n=d.execCommand(e,!1,t)}catch(e){}!n&&o&&o.errorMessage&&alert(de._(o.errorMessage)),G()}},ee=function(){function e(){if(i.getSelection()&&i.getSelection().rangeCount<=0)x=null;else if(v&&!v.compare(x)){if((x=v.cloneSelected())&&x.collapsed){var e=x.startContainer,t=x.startOffset;for(t&&e.nodeType!==Te&&(e=e.childNodes[t]);e&&e.parentNode!==h;)e=e.parentNode;e&&rt(e,!0)&&(v.saveRange(),n=d,Je(h,function(e){rt(e,!0)?(o||Ve(o=De("p",{},n),e),e.nodeType===Te&&""===e.nodeValue||Re(o,e)):o=null},!1,!0),v.restoreRange())}Qe(w,"selectionchanged")}var n,o;k=!1}k||(k=!0,"onselectionchange"in d?e():setTimeout(e,100))},te=function(){var e,t=v.parentNode();y!==t&&(e=y,y=t,b=v.getFirstBlockParent(t),Qe(w,"nodechanged",{oldNode:e,newNode:y}))},de.currentNode=function(){return y},de.currentBlockNode=function(){return b},G=function(){var e,t,n="active",o=d,r=de.sourceMode();if(de.readOnly())Ee(He(u,n),function(e,t){Ue(t,n)});else{r||(t=v.parentNode(),e=v.getFirstBlockParent(t));for(var i=0;i<he.length;i++){var l=0,a=ge[he[i].name],s=he[i].state,c=r&&!a._sceTxtMode||!r&&!a._sceWysiwygMode;if(be(s)){if(!r)try{-1<(l=o.queryCommandEnabled(s)?0:-1)&&(l=o.queryCommandState(s)?1:0)}catch(e){}}else c||(l=s.call(de,t,e));Ye(a,"disabled",c||l<0),Ye(a,n,0<l)}D&&D.update&&D.update(r,t,e)}},W=function(e){if(!e.defaultPrevented&&(de.closeDropDown(),13===e.which)&&!qe(b,"li,ul,ol")&&tt(b)){p=null;var t=De("br",{},d);if(v.insertNode(t),!wt){var n=t.parentNode,o=n.lastChild;o&&o.nodeType===Te&&""===o.nodeValue&&(Be(o),o=n.lastChild),!rt(n,!0)&&o===t&&rt(t.previousSibling)&&v.insertHTML("<br>")}e.preventDefault()}},Z=function(){Ze(h,function(e){if(e.nodeType===Se&&!/inline/.test(je(e,"display"))&&!qe(e,".sceditor-nlf")&&tt(e)){var t=De("p",{},d);return t.className="sceditor-nlf",t.innerHTML=wt?"":"<br />",Re(h,t),!1}if(3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||qe(e,"br"))return!1})},$=function(){de.val(a.value)},U=function(){de.closeDropDown(),p=null},de._=function(){var n=arguments;return t&&t[n[0]]&&(n[0]=t[n[0]]),n[0].replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[t-0+1]?n[t-0+1]:"{"+t+"}"})},K=function(t){r&&r.call(t.type+"Event",t,de);var e=(t.target===c?"scesrc":"scewys")+t.type;fe[e]&&fe[e].forEach(function(e){e.call(de,t)})},de.bind=function(e,t,n,o){for(var r=(e=e.split(" ")).length;r--;)if(we(t)){var i="scewys"+e[r],l="scesrc"+e[r];n||(fe[i]=fe[i]||[],fe[i].push(t)),o||(fe[l]=fe[l]||[],fe[l].push(t)),"valuechanged"===e[r]&&(le.hasHandler=!0)}return de},de.unbind=function(e,t,n,o){for(var r=(e=e.split(" ")).length;r--;)we(t)&&(n||Ce(fe["scewys"+e[r]]||[],t),o||Ce(fe["scesrc"+e[r]]||[],t));return de},de.blur=function(e,t,n){return we(e)?de.bind("blur",e,t,n):de.sourceMode()?c.blur():h.blur(),de},de.focus=function(e,t,n){if(we(e))de.bind("focus",e,t,n);else if(de.inSourceMode())c.focus();else{if(He(d,":focus").length)return;var o,r=v.selectedRange();x||ne(),!wt&&r&&1===r.endOffset&&r.collapsed&&(o=r.endContainer)&&1===o.childNodes.length&&qe(o.firstChild,"br")&&(r.setStartBefore(o.firstChild),r.collapse(!0),v.selectRange(r)),i.focus(),h.focus(),p&&(v.selectRange(p),p=null)}return G(),de},de.keyDown=function(e,t,n){return de.bind("keydown",e,t,n)},de.keyPress=function(e,t,n){return de.bind("keypress",e,t,n)},de.keyUp=function(e,t,n){return de.bind("keyup",e,t,n)},de.nodeChanged=function(e){return de.bind("nodechanged",e,!1,!0)},de.selectionChanged=function(e){return de.bind("selectionchanged",e,!1,!0)},de.valueChanged=function(e,t,n){return de.bind("valuechanged",e,t,n)},oe=function(e){var n=0,o=de.emoticonsCache,t=String.fromCharCode(e.which);Ne(b,"code")||(o||(o=[],Ee(ve,function(e,t){o[n++]=[e,t]}),o.sort(function(e,t){return e[0].length-t[0].length}),de.emoticonsCache=o,de.longestEmoticonCode=o[o.length-1][0].length),v.replaceKeyword(de.emoticonsCache,!0,!0,de.longestEmoticonCode,ye.emoticonsCompat,t)&&(ye.emoticonsCompat&&/^\s$/.test(t)||e.preventDefault()))},re=function(){!function(e,t){var n=/[^\s\xA0\u2002\u2003\u2009\u00a0]+/,o=e&&He(e,"img[data-sceditor-emoticon]");if(e&&o.length)for(var r=0;r<o.length;r++){var i=o[r],l=i.parentNode,a=i.previousSibling,s=i.nextSibling;if(a&&n.test(a.nodeValue.slice(-1))||s&&n.test((s.nodeValue||"")[0])){var c=t.cloneSelected(),u=-1,d=c.startContainer,f=a.nodeValue;null===f&&(f=a.innerText||""),f+=Pe(i,"sceditor-emoticon"),d===s&&(u=f.length+c.startOffset),d===e&&e.childNodes[c.startOffset]===s&&(u=f.length),d===a&&(u=c.startOffset),s&&s.nodeType===Te||(s=l.insertBefore(l.ownerDocument.createTextNode(""),s)),s.insertData(0,f),Be(a),Be(i),-1<u&&(c.setStart(s,u),c.collapse(!0),t.selectRange(c))}}}(b,v)},de.emoticons=function(e){return e||!1===e?((ye.emoticonsEnabled=e)?(Fe(h,"keypress",oe),de.sourceMode()||(v.saveRange(),N(),le(!1),v.restoreRange())):(Ee(He(h,"img[data-sceditor-emoticon]"),function(e,t){var n=Pe(t,"sceditor-emoticon"),o=d.createTextNode(n);t.parentNode.replaceChild(o,t)}),ze(h,"keypress",oe),le()),de):ye.emoticonsEnabled},de.css=function(e){return o||(o=De("style",{id:"inline"},d),Re(d.head,o)),be(e)?(o.styleSheet?o.styleSheet.cssText=e:o.innerHTML=e,de):o.styleSheet?o.styleSheet.cssText:o.innerHTML},q=function(e){var t=[],n={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},o={109:"-",110:"del",111:"/",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},r=e.which,i={8:"backspace",9:"tab",13:"enter",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",91:"win",92:"win",93:"select",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scrolllock",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"}[r]||String.fromCharCode(r).toLowerCase();(e.ctrlKey||e.metaKey)&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&(t.push("shift"),o[r]?i=o[r]:n[i]&&(i=n[i])),i&&(r<16||18<r)&&t.push(i),t=t.join("+"),me[t]&&!1===me[t].call(de)&&(e.stopPropagation(),e.preventDefault())},de.addShortcut=function(e,t){return e=e.toLowerCase(),be(t)?me[e]=function(){return B(ge[t],de.commands[t]),!1}:me[e]=t,de},de.removeShortcut=function(e){return delete me[e.toLowerCase()],de},V=function(e){var t,n,o;if(!ye.disableBlockRemove&&8===e.which&&(n=v.selectedRange())&&(t=n.startContainer,0===n.startOffset&&(o=ie())&&!qe(o,"body"))){for(;t!==o;){for(;t.previousSibling;)if((t=t.previousSibling).nodeType!==Te||t.nodeValue)return;if(!(t=t.parentNode))return}de.clearBlockFormatting(o),e.preventDefault()}},ie=function(){for(var e=b;!tt(e)||rt(e,!0);)if(!(e=e.parentNode)||qe(e,"body"))return;return e},de.clearBlockFormatting=function(e){return!(e=e||ie())||qe(e,"body")||(v.saveRange(),e.className="",p=null,Ae(e,"style",""),qe(e,"p,div,td")||nt(e,"p"),v.restoreRange()),de},le=function(e){if(r&&(r.hasHandler("valuechangedEvent")||le.hasHandler)){var t,n=de.sourceMode(),o=!n&&v.hasSelection();e=(m=!1)!==e&&!d.getElementById("sceditor-start-marker"),g&&(clearTimeout(g),g=!1),o&&e&&v.saveRange(),(t=n?c.value:h.innerHTML)!==le.lastVal&&(le.lastVal=t,Qe(w,"valuechanged",{rawValue:n?de.val():t})),o&&e&&v.removeMarkers()}},ae=function(){g&&le()},se=function(e){var t=e.which,n=se.lastChar,o=13===n||32===n,r=8===n||46===n;se.lastChar=t,m||(13===t||32===t?o?se.triggerNext=!0:le():8===t||46===t?r?se.triggerNext=!0:le():se.triggerNext&&(le(),se.triggerNext=!1),clearTimeout(g),g=setTimeout(function(){m||le()},1500))},Y=function(e){(m=/start/i.test(e.type))||le()},ce=function(){de.updateOriginal()},M()}Ct.locale={},Ct.formats={},Ct.icons={},Ct.command={get:function(e){return mt[e]||null},set:function(e,t){return!(!e||!t)&&((t=ke(mt[e]||{},t)).remove=function(){Ct.command.remove(e)},mt[e]=t,this)},remove:function(e){return mt[e]&&delete mt[e],this}},window.sceditor={command:Ct.command,commands:mt,defaultOptions:st,ie:y,ios:ft,isWysiwygSupported:pt,regexEscape:ct,escapeEntities:ut,escapeUriScheme:function(e){var t,n=window.location;return e&&/^[^\/]*:/i.test(e)&&!h.test(e)?((t=n.pathname.split("/")).pop(),n.protocol+"//"+n.host+t.join("/")+"/"+e):e},dom:{css:je,attr:Ae,removeAttr:a,is:qe,closest:Ne,width:Ke,height:Xe,traverse:Je,rTraverse:Ze,parseHTML:et,hasStyling:tt,convertElement:nt,blockLevelList:c,canHaveChildren:ot,isInline:rt,copyCSS:u,fixNesting:it,findCommonAncestor:function(e,t){for(;e=e.parentNode;)if((n=e)!==(o=t)&&n.contains&&n.contains(o))return e;var n,o},getSibling:d,removeWhiteSpace:lt,extractContents:f,getOffset:at,getStyle:p,hasStyle:function(e,t,n){var o=p(e,t);return!!o&&(!n||o===n||Array.isArray(n)&&-1<n.indexOf(o))}},locale:Ct.locale,icons:Ct.icons,utils:{each:Ee,isEmptyObject:t,extend:ke},plugins:gt.plugins,formats:Ct.formats,create:function(e,t){t=t||{},Me(e,".sceditor-container")||(t.runWithoutWysiwygSupport||pt)&&new Ct(e,t)},instance:function(e){return e._sceditor}},o.sceditor=window.sceditor,o.fn.sceditor=function(e){var t,n=[];return this.each(function(){t=this._sceditor,"state"===e?n.push(!!t):"instance"===e?n.push(t):t||o.sceditor.create(this,e)}),n.length?1===n.length?n[0]:n:this}}(jQuery),function(e){"use strict";var f=e.escapeEntities,a=e.escapeUriScheme,h=e.dom,t=e.utils,m=h.css,g=h.attr,v=h.is,n=t.extend,s=t.each,o=e.ie,y=o&&o<11,b="data-sceditor-emoticon",i=e.command.get,x={always:1,never:2,auto:3},r={bold:{txtExec:["[b]","[/b]"]},italic:{txtExec:["[i]","[/i]"]},underline:{txtExec:["[u]","[/u]"]},strike:{txtExec:["[s]","[/s]"]},subscript:{txtExec:["[sub]","[/sub]"]},superscript:{txtExec:["[sup]","[/sup]"]},left:{txtExec:["[left]","[/left]"]},center:{txtExec:["[center]","[/center]"]},right:{txtExec:["[right]","[/right]"]},justify:{txtExec:["[justify]","[/justify]"]},font:{txtExec:function(e){var t=this;i("font")._dropDown(t,e,function(e){t.insertText("[font="+e+"]","[/font]")})}},size:{txtExec:function(e){var t=this;i("size")._dropDown(t,e,function(e){t.insertText("[size="+e+"]","[/size]")})}},color:{txtExec:function(e){var t=this;i("color")._dropDown(t,e,function(e){t.insertText("[color="+e+"]","[/color]")})}},bulletlist:{txtExec:function(e,t){var n="";s(t.split(/\r?\n/),function(){n+=(n?"\n":"")+"[li]"+this+"[/li]"}),this.insertText("[ul]\n"+n+"\n[/ul]")}},orderedlist:{txtExec:function(e,t){var n="";s(t.split(/\r?\n/),function(){n+=(n?"\n":"")+"[li]"+this+"[/li]"}),this.insertText("[ol]\n"+n+"\n[/ol]")}},table:{txtExec:["[table][tr][td]","[/td][/tr][/table]"]},horizontalrule:{txtExec:["[hr]"]},code:{txtExec:["[code]","[/code]"]},image:{txtExec:function(e,t){var r=this;i("image")._dropDown(r,e,t,function(e,t,n){var o="";t&&(o+=" width="+t),n&&(o+=" height="+n),r.insertText("[img"+o+"]"+e+"[/img]")})}},email:{txtExec:function(e,n){var o=this;i("email")._dropDown(o,e,function(e,t){o.insertText("[email="+e+"]"+(t||n||e)+"[/email]")})}},link:{txtExec:function(e,n){var o=this;i("link")._dropDown(o,e,function(e,t){o.insertText("[url="+e+"]"+(t||n||e)+"[/url]")})}},quote:{txtExec:["[quote]","[/quote]"]},youtube:{txtExec:function(e){var t=this;i("youtube")._dropDown(t,e,function(e){t.insertText("[youtube]"+e+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}},w={b:{tags:{b:null,strong:null},styles:{"font-weight":["bold","bolder","401","700","800","900"]},format:"[b]{0}[/b]",html:"<strong>{0}</strong>"},i:{tags:{i:null,em:null},styles:{"font-style":["italic","oblique"]},format:"[i]{0}[/i]",html:"<em>{0}</em>"},u:{tags:{u:null},styles:{"text-decoration":["underline"]},format:"[u]{0}[/u]",html:"<u>{0}</u>"},s:{tags:{s:null,strike:null},styles:{"text-decoration":["line-through"]},format:"[s]{0}[/s]",html:"<s>{0}</s>"},sub:{tags:{sub:null},format:"[sub]{0}[/sub]",html:"<sub>{0}</sub>"},sup:{tags:{sup:null},format:"[sup]{0}[/sup]",html:"<sup>{0}</sup>"},font:{tags:{font:{face:null}},styles:{"font-family":null},quoteType:x.never,format:function(e,t){var n;return v(e,"font")&&(n=g(e,"face"))||(n=m(e,"font-family")),"[font="+E(n)+"]"+t+"[/font]"},html:'<font face="{defaultattr}">{0}</font>'},size:{tags:{font:{size:null}},styles:{"font-size":null},format:function(e,t){var n=g(e,"size"),o=2;return n||(n=m(e,"fontSize")),-1<n.indexOf("px")?((n=n.replace("px","")-0)<12&&(o=1),15<n&&(o=3),17<n&&(o=4),23<n&&(o=5),31<n&&(o=6),47<n&&(o=7)):o=n,"[size="+o+"]"+t+"[/size]"},html:'<font size="{defaultattr}">{!0}</font>'},color:{tags:{font:{color:null}},styles:{color:null},quoteType:x.never,format:function(e,t){var n;return v(e,"font")&&(n=g(e,"color"))||(n=e.style.color||m(e,"color")),"[color="+u(n)+"]"+t+"[/color]"},html:function(e,t,n){return'<font color="'+f(u(t.defaultattr),!0)+'">'+n+"</font>"}},ul:{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ul]{0}[/ul]",html:"<ul>{0}</ul>"},list:{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:"<ul>{0}</ul>"},ol:{tags:{ol:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ol]{0}[/ol]",html:"<ol>{0}</ol>"},li:{tags:{li:null},isInline:!1,closedBy:["/ul","/ol","/list","*","li"],format:"[li]{0}[/li]",html:"<li>{0}</li>"},"*":{isInline:!1,closedBy:["/ul","/ol","/list","*","li"],html:"<li>{0}</li>"},table:{tags:{table:null},isInline:!1,isHtmlInline:!0,skipLastLineBreak:!0,format:"[table]{0}[/table]",html:"<table>{0}</table>"},tr:{tags:{tr:null},isInline:!1,skipLastLineBreak:!0,format:"[tr]{0}[/tr]",html:"<tr>{0}</tr>"},th:{tags:{th:null},allowsEmpty:!0,isInline:!1,format:"[th]{0}[/th]",html:"<th>{0}</th>"},td:{tags:{td:null},allowsEmpty:!0,isInline:!1,format:"[td]{0}[/td]",html:"<td>{0}</td>"},emoticon:{allowsEmpty:!0,tags:{img:{src:null,"data-sceditor-emoticon":null}},format:function(e,t){return g(e,b)+t},html:"{0}"},hr:{tags:{hr:null},allowsEmpty:!0,isSelfClosing:!0,isInline:!1,format:"[hr]{0}",html:"<hr />"},img:{allowsEmpty:!0,tags:{img:{src:null}},allowedChildren:["#"],quoteType:x.never,format:function(t,e){var n,o,r="",i=function(e){return t.style?t.style[e]:null};return g(t,b)?e:(n=g(t,"width")||i("width"),o=g(t,"height")||i("height"),(t.complete&&(n||o)||n&&o)&&(r="="+h.width(t)+"x"+h.height(t)),"[img"+r+"]"+g(t,"src")+"[/img]")},html:function(e,t,n){var o,r,i,l="";return o=t.width,r=t.height,t.defaultattr&&(o=(i=t.defaultattr.split(/x/i))[0],r=2===i.length?i[1]:i[0]),void 0!==o&&(l+=' width="'+f(o,!0)+'"'),void 0!==r&&(l+=' height="'+f(r,!0)+'"'),"<img"+l+' src="'+a(n)+'" />'}},url:{allowsEmpty:!0,tags:{a:{href:null}},quoteType:x.never,format:function(e,t){var n=g(e,"href");return"mailto:"===n.substr(0,7)?'[email="'+n.substr(7)+'"]'+t+"[/email]":"[url="+n+"]"+t+"[/url]"},html:function(e,t,n){return t.defaultattr=f(t.defaultattr,!0)||n,'<a href="'+a(t.defaultattr)+'">'+n+"</a>"}},email:{quoteType:x.never,html:function(e,t,n){return'<a href="mailto:'+(f(t.defaultattr,!0)||n)+'">'+n+"</a>"}},quote:{tags:{blockquote:null},isInline:!1,quoteType:x.never,format:function(e,t){for(var n,o="data-author",r="",i=e.children,l=0;!n&&l<i.length;l++)v(i[l],"cite")&&(n=i[l]);return(n||g(e,o))&&(r=n&&n.textContent||g(e,o),g(e,o,r),n&&e.removeChild(n),t=this.elementToBbcode(e),r="="+r.replace(/(^\s+|\s+$)/g,""),n&&e.insertBefore(n,e.firstChild)),"[quote"+r+"]"+t+"[/quote]"},html:function(e,t,n){return t.defaultattr&&(n="<cite>"+f(t.defaultattr)+"</cite>"+n),"<blockquote>"+n+"</blockquote>"}},code:{tags:{code:null},isInline:!1,allowedChildren:["#","#newline"],format:"[code]{0}[/code]",html:"<code>{0}</code>"},left:{styles:{"text-align":["left","-webkit-left","-moz-left","-khtml-left"]},isInline:!1,format:"[left]{0}[/left]",html:'<div align="left">{0}</div>'},center:{styles:{"text-align":["center","-webkit-center","-moz-center","-khtml-center"]},isInline:!1,format:"[center]{0}[/center]",html:'<div align="center">{0}</div>'},right:{styles:{"text-align":["right","-webkit-right","-moz-right","-khtml-right"]},isInline:!1,format:"[right]{0}[/right]",html:'<div align="right">{0}</div>'},justify:{styles:{"text-align":["justify","-webkit-justify","-moz-justify","-khtml-justify"]},isInline:!1,format:"[justify]{0}[/justify]",html:'<div align="justify">{0}</div>'},youtube:{allowsEmpty:!0,tags:{iframe:{"data-youtube-id":null}},format:function(e,t){return(e=g(e,"data-youtube-id"))?"[youtube]"+e+"[/youtube]":t},html:'<iframe width="560" height="315" frameborder="0" src="https://www.youtube.com/embed/{0}?wmode=opaque" data-youtube-id="{0}" allowfullscreen></iframe>'},rtl:{styles:{direction:["rtl"]},isInline:!1,format:"[rtl]{0}[/rtl]",html:'<div style="direction: rtl">{0}</div>'},ltr:{styles:{direction:["ltr"]},isInline:!1,format:"[ltr]{0}[/ltr]",html:'<div style="direction: ltr">{0}</div>'},ignore:{}};function k(e,o){return e.replace(/\{([^}]+)\}/g,function(e,t){var n=!0;return"!"===t.charAt(0)&&(n=!1,t=t.substring(1)),"0"===t&&(n=!1),void 0===o[t]?e:n?f(o[t],!0):o[t]})}function C(e){return"function"==typeof e}function E(e){return e?e.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2"):e}function S(e){var n=arguments;return e.replace(/\{(\d+)\}/g,function(e,t){return void 0!==n[t-0+1]?n[t-0+1]:"{"+t+"}"})}var T="open",D="content",M="newline",N="close";function c(e,t,n,o,r,i){var l=this;l.type=e,l.name=t,l.val=n,l.attrs=o||{},l.children=r||[],l.closing=i||null}function B(e){var h=this;function l(e,t){var n,o,r;return e===T&&(n=t.match(/\[([^\]\s=]+)(?:([^\]]+))?\]/))&&(r=i(n[1]),n[2]&&(n[2]=n[2].trim())&&(o=function(e){var t,n=/([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g,o={};if("="===e.charAt(0)&&e.indexOf("=",1)<0)o.defaultattr=E(e.substr(1));else for("="===e.charAt(0)&&(e="defaultattr"+e);t=n.exec(e);)o[i(t[1])]=E(t[3])||t[4];return o}(n[2]))),e===N&&(n=t.match(/\[\/([^\[\]]+)\]/))&&(r=i(n[1])),e===M&&(r="#newline"),r&&(e!==T&&e!==N||w[r])||(e=D,r="#"),new c(e,r,t,o)}function p(e,t,n){for(var o=n.length;o--;)if(n[o].type===t&&n[o].name===e)return!0;return!1}function m(e,t){var n=(e?w[e.name]:{}).allowedChildren;return!h.opts.fixInvalidChildren||!n||-1<n.indexOf(t.name||"#")}function g(e,t,n){var o=/\s|=/.test(e);return C(t)?t(e,n):t===x.never||t===x.auto&&!o?e:'"'+e.replace("\\","\\\\").replace('"','\\"')+'"'}function v(e){return e.length?e[e.length-1]:null}function i(e){return e.toLowerCase()}h.opts=n({},B.defaults,e),h.tokenize=function(e){var t,n,o,r=[],i=[{type:D,regex:/^([^\[\r\n]+|\[)/},{type:M,regex:/^(\r\n|\r|\n)/},{type:T,regex:/^\[[^\[\]]+\]/},{type:N,regex:/^\[\/[^\[\]]+\]/}];e:for(;e.length;){for(o=i.length;o--;)if(n=i[o].type,(t=e.match(i[o].regex))&&t[0]){r.push(l(n,t[0])),e=e.substr(t[0].length);continue e}e.length&&r.push(l(D,e)),e=""}return r},h.parse=function(e,t){var n=function(e){var t,n,o,r,i,l,a=[],s=[],c=[],u=function(){return v(c)},d=function(e){u()?u().children.push(e):s.push(e)},f=function(e){return u()&&(n=w[u().name])&&n.closedBy&&-1<n.closedBy.indexOf(e)};for(;t=e.shift();)switch(l=e[0],m(u(),t)||t.type===N&&u()&&t.name===u().name||(t.name="#",t.type=D),t.type){case T:f(t.name)&&c.pop(),d(t),(n=w[t.name])&&!n.isSelfClosing&&(n.closedBy||p(t.name,N,e))?c.push(t):n&&n.isSelfClosing||(t.type=D);break;case N:if(u()&&t.name!==u().name&&f("/"+t.name)&&c.pop(),u()&&t.name===u().name)u().closing=t,c.pop();else if(p(t.name,T,c)){for(;o=c.pop();){if(o.name===t.name){o.closing=t;break}r=o.clone(),a.length&&r.children.push(v(a)),a.push(r)}for(l&&l.type===M&&(n=w[t.name])&&!1===n.isInline&&(d(l),e.shift()),d(v(a)),i=a.length;i--;)c.push(a[i]);a.length=0}else t.type=D,d(t);break;case M:u()&&l&&f((l.type===N?"/":"")+l.name)&&(l.type===N&&l.name===u().name||((n=w[u().name])&&n.breakAfter?c.pop():n&&!1===n.isInline&&h.opts.breakAfterBlock&&!1!==n.breakAfter&&c.pop())),d(t);break;default:d(t)}return s}(h.tokenize(e)),o=h.opts;return o.fixInvalidNesting&&function e(t,n,o,r){var i,l,a,s,c,u;var d=function(e){var t=w[e.name];return!t||!1!==t.isInline};n=n||[];r=r||t;for(l=0;l<t.length;l++)if((i=t[l])&&i.type===T){if(o&&!d(i)){if(a=v(n),u=a.splitAt(i),c=1<n.length?n[n.length-2].children:r,m(i,a)){var f=a.clone();f.children=i.children,i.children=[f]}if(-1<(s=c.indexOf(a))){u.children.splice(0,1),c.splice(s+1,0,i,u);var p=u.children[0];return void(p&&p.type===M&&(d(i)||(u.children.splice(0,1),c.splice(s+2,0,p))))}}n.push(i),e(i.children,n,o||d(i),r),n.pop()}}(n),function e(t,n,o){var r,i,l,a,s,c,u,d;var f=t.length;n&&(a=w[n.name]);var p=f;for(;p--;)if(r=t[p])if(r.type===M){if(i=0<p?t[p-1]:null,l=p<f-1?t[p+1]:null,d=!1,!o&&a&&!0!==a.isSelfClosing&&(i?c||l||(!1===a.isInline&&h.opts.breakEndBlock&&!1!==a.breakEnd&&(d=!0),a.breakEnd&&(d=!0),c=d):(!1===a.isInline&&h.opts.breakStartBlock&&!1!==a.breakStart&&(d=!0),a.breakStart&&(d=!0))),i&&i.type===T&&(s=w[i.name])&&(o?!1===s.isInline&&(d=!0):(!1===s.isInline&&h.opts.breakAfterBlock&&!1!==s.breakAfter&&(d=!0),s.breakAfter&&(d=!0))),!o&&!u&&l&&l.type===T&&(s=w[l.name])&&(!1===s.isInline&&h.opts.breakBeforeBlock&&!1!==s.breakBefore&&(d=!0),s.breakBefore&&(d=!0),u=d)){t.splice(p,1);continue}d&&t.splice(p,1),u=!1}else r.type===T&&e(r.children,r,o)}(n,null,t),o.removeEmptyTags&&function e(t){var n,o;var r=function(e){for(var t=e.length;t--;){var n=e[t].type;if(n===T||n===N)return!1;if(n===D&&/\S|\u00A0/.test(e[t].val))return!1}return!0};var i=t.length;for(;i--;)(n=t[i])&&n.type===T&&(o=w[n.name],e(n.children),r(n.children)&&o&&!o.isSelfClosing&&!o.allowsEmpty&&t.splice.apply(t,[i,1].concat(n.children)))}(n),n},h.toHTML=function(e,t){return function e(t,n){var o,r,i,l,a,s,c,u,d=[];c=function(e){return!1!==(!e||(void 0!==e.isHtmlInline?e.isHtmlInline:e.isInline))};for(;0<t.length;)if(o=t.shift()){if(o.type===T)u=o.children[o.children.length-1]||{},r=w[o.name],a=n&&c(r),i=e(o.children,!1),r&&r.html?(c(r)||!c(w[u.name])||r.isPreFormatted||r.skipLastLineBreak||y||(i+="<br />"),C(r.html)?l=r.html.call(h,o,o.attrs,i):(o.attrs[0]=i,l=k(r.html,o.attrs))):l=o.val+i+(o.closing?o.closing.val:"");else{if(o.type===M){if(!n){d.push("<br />");continue}s||d.push("<div>"),y||d.push("<br />"),t.length||d.push("<br />"),d.push("</div>\n"),s=!1;continue}a=n,l=f(o.val,!0)}a&&!s?(d.push("<div>"),s=!0):!a&&s&&(d.push("</div>\n"),s=!1),d.push(l)}s&&d.push("</div>\n");return d.join("")}(h.parse(e,t),!0)},h.toBBCode=function(e,t){return function e(t){var n,o,r,i,l,a,s,c,u,d,f=[];for(;0<t.length;)if(n=t.shift())if(r=w[n.name],i=!(!r||!1!==r.isInline),l=r&&r.isSelfClosing,s=i&&h.opts.breakBeforeBlock&&!1!==r.breakBefore||r&&r.breakBefore,c=i&&!l&&h.opts.breakStartBlock&&!1!==r.breakStart||r&&r.breakStart,u=i&&h.opts.breakEndBlock&&!1!==r.breakEnd||r&&r.breakEnd,d=i&&h.opts.breakAfterBlock&&!1!==r.breakAfter||r&&r.breakAfter,a=(r?r.quoteType:null)||h.opts.quoteType||x.auto,r||n.type!==T)if(n.type===T){if(s&&f.push("\n"),f.push("["+n.name),n.attrs)for(o in n.attrs.defaultattr&&(f.push("=",g(n.attrs.defaultattr,a,"defaultattr")),delete n.attrs.defaultattr),n.attrs)n.attrs.hasOwnProperty(o)&&f.push(" ",o,"=",g(n.attrs[o],a,o));f.push("]"),c&&f.push("\n"),n.children&&f.push(e(n.children)),l||r.excludeClosing||(u&&f.push("\n"),f.push("[/"+n.name+"]")),d&&f.push("\n"),n.closing&&l&&f.push(n.closing.val)}else f.push(n.val);else f.push(n.val),n.children&&f.push(e(n.children)),n.closing&&f.push(n.closing.val);return f.join("")}(h.parse(e,t))}}function l(e){return e=parseInt(e,10),isNaN(e)?"00":(e=Math.max(0,Math.min(e,255)).toString(16)).length<2?"0"+e:e}function u(e){var t;return(t=(e=e||"#000").match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+l(t[1])+l(t[2])+l(t[3]):(t=e.match(/#([0-f])([0-f])([0-f])\s*?$/i))?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:e}function d(){var c=this;c.stripQuotes=E;var l={},a={},u={ul:["li","ol","ul"],ol:["li","ol","ul"],table:["tr"],tr:["td","th"],code:["br","p","div"]};function d(n,o,e){var r,i,l=h.getStyle;return a[e=!!e]&&s(a[e],function(e,t){(r=l(n,e))&&l(n.parentNode,e)!==r&&s(t,function(e,t){(!t||-1<t.indexOf(r.toString()))&&(i=w[e].format,o=C(i)?i.call(c,n,o):S(i,o))})}),o}function f(n,o,e){var r,i,t=n.nodeName.toLowerCase();return e=!!e,l[t]&&l[t][e]&&s(l[t][e],function(e,t){t&&(r=!1,s(t,function(e,t){if(g(n,e)&&!(t&&t.indexOf(g(n,e))<0))return!(r=!0)}),!r)||(i=w[e].format,o=C(i)?i.call(c,n,o):S(i,o))}),o}function p(e){var c=function(e,a){var s="";return h.traverse(e,function(e){var t="",n=e.nodeType,o=e.nodeName.toLowerCase(),r=u[o],i=e.firstChild,l=!0;if("object"==typeof a&&(l=-1<a.indexOf(o),v(e,"img")&&g(e,b)&&(l=!0),l||(r=a)),3===n||1===n)if(1===n){if(v(e,".sceditor-nlf")&&(!i||!y&&1===e.childNodes.length&&/br/i.test(i.nodeName)))return;"iframe"!==o&&(t=c(e,r)),l?("code"!==o&&(t=d(e,t=f(e,t=d(e,t)),!0)),t=f(e,t,!0),s+=function(e,t){var n=e.nodeName.toLowerCase(),o=h.isInline;if(!o(e,!0)||"br"===n){for(var r,i,l=e.previousSibling;l&&1===l.nodeType&&!v(l,"br")&&o(l,!0)&&!l.firstChild;)l=l.previousSibling;for(;r=((i=e.parentNode)&&i.lastChild)===e,(e=i)&&r&&o(i,!0););(!r||"li"===n||"br"===n&&y)&&(t+="\n"),"br"!==n&&l&&!v(l,"br")&&o(l,!0)&&(t="\n"+t)}return t}(e,t)):s+=t}else s+=e.nodeValue},!1,!0),s};return c(e)}function e(e,t,n){var o,r,i,l,a,s=new B(c.opts.parserOptions).toHTML(c.opts.bbcodeTrim?t.trim():t);return e||n?(o=s,a=document.createElement("div"),l=function(e,t){if(!h.hasStyling(e)){if(y||1!==e.childNodes.length||!v(e.firstChild,"br"))for(;i=e.firstChild;)a.insertBefore(i,e);if(t){var n=a.lastChild;e!==n&&v(n,"div")&&e.nextSibling===n&&a.insertBefore(document.createElement("br"),e)}a.removeChild(e)}},m(a,"display","none"),a.innerHTML=o.replace(/<\/div>\n/g,"</div>"),(r=a.firstChild)&&v(r,"div")&&l(r,!0),(r=a.lastChild)&&v(r,"div")&&l(r),a.innerHTML):s}function t(e,t,n,o){var r,i,l=(n=n||document).createElement("div"),a=n.createElement("div"),s=new B(c.opts.parserOptions);for(a.innerHTML=t,m(l,"visibility","hidden"),l.appendChild(a),n.body.appendChild(l),e&&(l.insertBefore(n.createTextNode("#"),l.firstChild),l.appendChild(n.createTextNode("#"))),o&&m(a,"whiteSpace",m(o,"whiteSpace")),i=a.getElementsByClassName("sceditor-ignore");i.length;)i[0].parentNode.removeChild(i[0]);return h.removeWhiteSpace(l),r=p(a),n.body.removeChild(l),r=s.toBBCode(r,!0),c.opts.bbcodeTrim&&(r=r.trim()),r}c.init=function(){c.opts=this.opts,c.elementToBbcode=p,s(w,function(n){var o,e=w[n].tags,t=w[n].styles;e&&s(e,function(e,t){o=!1===w[n].isInline,l[e]=l[e]||{},l[e][o]=l[e][o]||{},l[e][o][n]=t}),t&&s(t,function(e,t){o=!1===w[n].isInline,a[o]=a[o]||{},a[o][e]=a[o][e]||{},a[o][e][n]=t})}),this.commands=n(!0,{},r,this.commands),this.toBBCode=c.toSource,this.fromBBCode=c.toHtml},c.toHtml=e.bind(null,!1),c.fragmentToHtml=e.bind(null,!0),c.toSource=t.bind(null,!1),c.fragmentToSource=t.bind(null,!0)}c.prototype={clone:function(){var e=this;return new c(e.type,e.name,e.val,n({},e.attrs),[],e.closing?e.closing.clone():null)},splitAt:function(e){var t,n=this.clone(),o=this.children.indexOf(e);return-1<o&&(t=this.children.length-o,n.children=this.children.splice(o,t)),n}},B.QuoteType=x,B.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:x.auto},d.get=function(e){return w[e]||null},d.set=function(e,t){return e&&t&&((t=n(w[e]||{},t)).remove=function(){delete w[e]},w[e]=t),this},d.rename=function(e,t){return e in w&&(w[t]=w[e],delete w[e]),this},d.remove=function(e){return e in w&&delete w[e],this},d.formatBBCodeString=k,e.formats.bbcode=d,e.BBCodeParser=B}(sceditor);