/* SCEditor v1.5.2 | (C) 2016, Sam Clarke | sceditor.com/license */ !function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){var d;d=function(a){"use strict";var b=c(1),d=c(2),e=c(3),f=c(6),g=c(7);b.sceditor=d,d.commands=c(9),d.defaultOptions=c(10),d.RangeHelper=c(4),d.dom=c(5),d.ie=f.ie,d.ios=f.ios,d.isWysiwygSupported=f.isWysiwygSupported,d.regexEscape=g.regex,d.escapeEntities=g.entities,d.escapeUriScheme=g.uriScheme,d.PluginManager=e,d.plugins=e.plugins,b.fn.sceditor=function(a){var c,e,g=[];if(a=a||{},a.runWithoutWysiwygSupport||f.isWysiwygSupported)return this.each(function(){c=this.jquery?this:b(this),e=c.data("sceditor"),c.parents(".sceditor-container").length>0||("state"===a?g.push(!!e):"instance"===a?g.push(e):e||new d(this,a))}),g.length?1===g.length?g[0]:b(g):this}}.call(b,c,b,a),!(void 0!==d&&(a.exports=d))},function(a,b){a.exports=jQuery},function(a,b,c){var d;d=function(a){"use strict";var b=c(1),d=c(3),e=c(4),f=c(5),g=c(7),h=c(6),i=c(8),j=window,k=document,l=b(j),m=b(k),n=h.ie,o=n&&n<11,p=function(a,c){var 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,$,_,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua=this,va=a.get?a.get(0):a,wa=b(va),xa=[],ya=[],za=[],Aa={},Ba=[],Ca={};ua.commands=b.extend(!0,{},c.commands||p.commands),ua.opts=c=b.extend({},p.defaultOptions,c),K=function(){wa.data("sceditor",ua),b.each(c,function(a,d){b.isPlainObject(d)&&(c[a]=b.extend(!0,{},d))}),c.locale&&"en"!==c.locale&&Q(),q=b('
').insertAfter(wa).css("z-index",c.zIndex),n&&q.addClass("ie ie"+n),H=!!wa.attr("required"),wa.removeAttr("required"),P(),W(),R(),O(!!c.startInSourceMode),U(),S(),T(),h.isWysiwygSupported||ua.toggleSourceMode(),ha();var a=function(){l.off("load",a),c.autofocus&&ma(),c.autoExpand&&ua.expandToContent(),fa(),C.call("ready")};l.on("load",a),k.readyState&&"complete"===k.readyState&&a()},P=function(){var a=c.plugins;a=a?a.toString().split(","):[],C=new d(ua),b.each(a,function(a,c){C.register(b.trim(c))})},Q=function(){var a;A=p.locale[c.locale],A||(a=c.locale.split("-"),A=p.locale[a[0]]),A&&A.dateFormat&&(c.dateFormat=A.dateFormat)},O=function(a){var d,f;w=b(""),s=b(''),a?(q.addClass("sourceMode"),s.hide()):(q.addClass("wysiwygMode"),w.hide()),c.spellcheck||w.attr("spellcheck","false"),"https:"===j.location.protocol&&s.attr("src","javascript:false"),q.append(s).append(w),t=s[0],x=w[0],ua.dimensions(c.width||wa.width(),c.height||wa.height()),d=X(),d.open(),d.write(i("html",{attrs:n?' class="ie ie'+n+'"':"",spellcheck:c.spellcheck?"":'spellcheck="false"',charset:c.charset,style:c.style})),d.close(),v=b(d),u=b(d.body),ua.readOnly(!!c.readOnly),(h.ios||n)&&(u.height("100%"),n||u.on("touchend",ua.focus)),f=wa.attr("tabindex"),w.attr("tabindex",f),s.attr("tabindex",f),B=new e(t.contentWindow),ua.val(wa.hide().val())},S=function(){c.autoUpdate&&(u.on("blur",ta),w.on("blur",ta)),null===c.rtl&&(c.rtl="rtl"===w.css("direction")),ua.rtl(!!c.rtl),c.autoExpand&&v.on("keyup",ua.expandToContent),c.resizeEnabled&&V(),q.attr("id",c.id),ua.emoticons(c.emoticonsEnabled)},T=function(){var a=n?"selectionchange":"keyup focus blur contextmenu mouseup touchend click",d="keydown keyup keypress focus blur contextmenu";m.click(ea),b(va.form).on("reset",ba).submit(ua.updateOriginal),l.on("resize orientationChanged",fa),u.keypress(aa).keydown($).keydown(_).keyup(ja).blur(ra).keyup(sa).on("paste",Y).on(a,ka).on(d,da),c.emoticonsCompat&&j.getSelection&&u.keyup(oa),w.blur(ra).keyup(sa).keydown($).on(d,da),v.mousedown(ca).blur(ra).on(a,ka).on("beforedeactivate keyup mouseup",N).keyup(ja).focus(function(){z=null}),q.on("selectionchanged",la).on("selectionchanged",ha).on("selectionchanged valuechanged nodechanged",da)},R=function(){var a,d=ua.commands,e=(c.toolbarExclude||"").split(","),f=c.toolbar.split("|");r=b('
'),b.each(f,function(c,f){a=b('
'),b.each(f.split(","),function(c,f){var g,h,j=d[f];!j||b.inArray(f,e)>-1||(h=j.shortcut,g=i("toolbarButton",{name:f,dispName:ua._(j.name||j.tooltip||f)},!0),g.data("sceditor-txtmode",!!j.txtExec).data("sceditor-wysiwygmode",!!j.exec).toggleClass("disabled",!j.exec).mousedown(function(){(!n||n<9)&&(J=!0)}).click(function(){var a=b(this);return a.hasClass("disabled")||M(a,j),ha(),!1}),j.tooltip&&g.attr("title",ua._(j.tooltip)+(h?" ("+h+")":"")),h&&ua.addShortcut(h,f),j.state?za.push({name:f,state:j.state}):"string"==typeof j.exec&&za.push({name:f,state:j.exec}),a.append(g),Ca[f]=g)}),a[0].firstChild&&r.append(a)}),b(c.toolbarContainer||q).append(r)},U=function(){b.each(ua.commands,function(a,c){c.forceNewLineAfter&&b.isArray(c.forceNewLineAfter)&&(ya=b.merge(ya,c.forceNewLineAfter))}),ja()},V=function(){var a,d,e,f,g,h,i=b('
'),k=b('
'),l="touchmove mousemove",o="touchcancel touchend mouseup",p=0,r=0,s=0,t=0,u=0,v=0,w=q.width(),x=q.height(),y=!1,z=ua.rtl();a=c.resizeMinHeight||x/1.5,d=c.resizeMaxHeight||2.5*x,e=c.resizeMinWidth||w/1.25,f=c.resizeMaxWidth||1.25*w,g=function(b){"touchmove"===b.type?(b=j.event,s=b.changedTouches[0].pageX,t=b.changedTouches[0].pageY):(s=b.pageX,t=b.pageY);var g=v+(t-r),h=z?u-(s-p):u+(s-p);f>0&&h>f&&(h=f),e>0&&h0&&g>d&&(g=d),a>0&&g-1&&(a=q.width()),s.width(a-s.data("outerWidthOffset")),w.width(a-w.data("outerWidthOffset")),h.ios&&u&&u.width(a-s.data("outerWidthOffset")-(u.outerWidth(!0)-u.width()))),b!==!1&&(d!==!1&&(c.height=b),b&&b.toString().indexOf("%")>-1&&(b=q.height(b).height(),q.height("auto")),b-=c.toolbarContainer?0:r.outerHeight(!0),s.height(b-s.data("outerHeightOffset")),w.height(b-f-w.data("outerHeightOffset"))),ua)},ua.updateStyleCache=function(){s.data("outerWidthOffset",s.outerWidth(!0)-s.width()),w.data("outerWidthOffset",w.outerWidth(!0)-w.width()),s.data("outerHeightOffset",s.outerHeight(!0)-s.height()),w.data("outerHeightOffset",w.outerHeight(!0)-w.height())},ua.height=function(a,b){return a||0===a?(ua.dimensions(null,a,b),ua):q.height()},ua.maximize=function(a){return"undefined"==typeof a?q.is(".sceditor-maximize"):(a=!!a,n<7&&b("html, body").toggleClass("sceditor-maximize",a),q.toggleClass("sceditor-maximize",a),ua.width(a?"100%":c.width,!1),ua.height(a?"100%":c.height,!1),ua)},ua.expandToContent=function(a){var b=q.height(),d=b-s.height(),e=u[0].scrollHeight||v[0].documentElement.scrollHeight,f=c.resizeMaxHeight||2*(c.height||wa.height());e+=d,(a===!0||e<=f)&&e>b&&ua.height(e)},ua.destroy=function(){C&&(C.destroy(),B=null,z=null,C=null,y&&y.off().remove(),m.off("click",ea),l.off("resize orientationChanged",fa),b(va.form).off("reset",ba).off("submit",ua.updateOriginal),u.off(),v.off().find("*").remove(),w.off().remove(),r.remove(),q.off().find("*").off().remove(),q.remove(),wa.removeData("sceditor").removeData("sceditorbbcode").show(),H&&wa.attr("required","required"))},ua.createDropDown=function(a,d,e,f){var g,h="sceditor-"+d,i=y&&y.is("."+h);ua.closeDropDown(!0),i||(f!==!1&&b(e).find(":not(input,textarea)").filter(function(){return 1===this.nodeType}).attr("unselectable","on"),g={top:a.offset().top,left:a.offset().left,marginTop:a.outerHeight()},b.extend(g,c.dropDownCss),y=b('
').css(g).append(e).appendTo(b("body")).on("click focusin",function(a){a.stopPropagation()}),setTimeout(function(){y&&y.find("input,textarea").first().focus()}))},ea=function(a){3!==a.which&&y&&(ta(),ua.closeDropDown())},Y=function(a){var b,d,e,f=u[0],g=v[0],h=0,i=k.createElement("div"),j=g.createDocumentFragment(),l=!!a&&a.clipboardData;if(c.disablePasting)return!1;if(c.enablePasteFiltering){if(B.saveRange(),k.body.appendChild(i),l&&l.getData&&((b=l.getData("text/html"))||(b=l.getData("text/plain"))))return i.innerHTML=b,Z(f,i),!1;for(e=u.scrollTop()||v.scrollTop();f.firstChild;)j.appendChild(f.firstChild);return d=function(a,b){if(a.childNodes.length>0||h>25){for(;a.firstChild;)b.appendChild(a.firstChild);for(;j.firstChild;)a.appendChild(j.firstChild);u.scrollTop(e),v.scrollTop(e),b.childNodes.length>0?Z(a,b):B.restoreRange()}else h++,setTimeout(function(){d(a,b)},20)},d(f,i),ua.focus(),!0}},Z=function(a,c){f.fixNesting(c);var d=c.innerHTML;C.hasHandler("toSource")&&(d=C.callOnlyFirst("toSource",d,b(c))),c.parentNode.removeChild(c),C.hasHandler("toWysiwyg")&&(d=C.callOnlyFirst("toWysiwyg",d,!0)),B.restoreRange(),ua.wysiwygEditorInsertHtml(d,null,!0)},ua.closeDropDown=function(a){y&&(y.off().remove(),y=null),a===!0&&ua.focus()},X=function(){return t.contentDocument?t.contentDocument:t.contentWindow&&t.contentWindow.document?t.contentWindow.document:t.document},ua.wysiwygEditorInsertHtml=function(a,c,d){var e,g,h,i=s.height();ua.focus(),(d||!b(E).is("code")&&0===b(E).parents("code").length)&&(B.insertHTML(a,c),B.saveRange(),L(u[0]),e=u.find("#sceditor-end-marker").show(),g=u.scrollTop()||v.scrollTop(),h=f.getOffset(e[0]).top+1.5*e.outerHeight(!0)-i,e.hide(),(h>g||h+i").appendTo(b("body")).hide().html(g);d!==!1&&C.hasHandler("toSource")&&(g=C.callOnlyFirst("toSource",g,h)),h.remove(),a+=g+c}return d!==!1&&C.hasHandler("toWysiwyg")&&(a=C.callOnlyFirst("toWysiwyg",a,!0)),d!==!1&&f===!0&&(a=a.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")),ua.wysiwygEditorInsertHtml(a),ua},ua.getWysiwygEditorValue=function(a){var c,d=b("
").appendTo(document.body).append(b(u[0].childNodes).clone());return f.fixNesting(d[0]),c=d.html(),a!==!1&&C.hasHandler("toSource")&&(c=C.callOnlyFirst("toSource",c,d)),d.remove(),c},ua.getBody=function(){return u},ua.getContentAreaContainer=function(){return s},ua.getSourceEditorValue=function(a){var b=w.val();return a!==!1&&C.hasHandler("toWysiwyg")&&(b=C.callOnlyFirst("toWysiwyg",b)),b},ua.setWysiwygEditorValue=function(a){a||(a="

"+(n?"":"
")+"

"),u[0].innerHTML=a,L(u[0]),ja(),qa()},ua.setSourceEditorValue=function(a){w.val(a),qa()},ua.updateOriginal=function(){wa.val(ua.val())},L=function(a){if(c.emoticonsEnabled&&!b(a).parents("code").length){var d=a.ownerDocument,e="\\s| | | | | ",h=[],j=[],k=b.extend({},c.emoticons.more,c.emoticons.dropdown,c.emoticons.hidden);b.each(k,function(a){c.emoticonsCompat&&(j[a]=new RegExp("(>|^|"+e+")"+g.regex(a)+"($|<|"+e+")")),h.push(a)});var l=function(a){for(a=a.firstChild;a;){var e,g,m,n,o,p,q,r=a.parentNode,s=a.nodeValue;if(3!==a.nodeType)b(a).is("code")||l(a);else if(s)for(o=h.length;o--;)g=h[o],q=c.emoticonsCompat?s.search(j[g]):s.indexOf(g),q>-1&&(p=a.nextSibling,m=k[g],e=s.substr(q).split(g),s=s.substr(0,q)+e.shift(),a.nodeValue=s,n=f.parseHTML(i("emoticon",{key:g,url:m.url||m,tooltip:m.tooltip||g}),d),r.insertBefore(n[0],p),r.insertBefore(d.createTextNode(e.join(g)),p));a=a.nextSibling}};l(a),c.emoticonsCompat&&(Ba=u.find("img[data-sceditor-emoticon]"))}},ua.inSourceMode=function(){return q.hasClass("sourceMode")},ua.sourceMode=function(a){var b=ua.inSourceMode();return"boolean"!=typeof a?b:((b&&!a||!b&&a)&&ua.toggleSourceMode(),ua)},ua.toggleSourceMode=function(){var a=ua.inSourceMode();!h.isWysiwygSupported&&a||(a||(B.saveRange(),B.clear()),ua.blur(),a?ua.setWysiwygEditorValue(ua.getSourceEditorValue()):ua.setSourceEditorValue(ua.getWysiwygEditorValue()),z=null,w.toggle(),s.toggle(),q.toggleClass("wysiwygMode",a).toggleClass("sourceMode",!a),ga(),ha())},ia=function(){return x.focus(),"undefined"!=typeof x.selectionStart?x.value.substring(x.selectionStart,x.selectionEnd):k.selection.createRange().text},M=function(a,c){ua.inSourceMode()?c.txtExec&&(b.isArray(c.txtExec)?ua.sourceEditorInsertText.apply(ua,c.txtExec):c.txtExec.call(ua,a,ia())):c.exec&&(b.isFunction(c.exec)?c.exec.call(ua,a):ua.execCommand(c.exec,c.hasOwnProperty("execParam")?c.execParam:null))},N=function(){n&&(z=B.selectedRange())},ua.execCommand=function(a,c){var d=!1,e=ua.commands[a],f=b(B.parentNode());if(ua.focus(),!f.is("code")&&0===f.parents("code").length){try{d=v[0].execCommand(a,!1,c)}catch(a){}!d&&e&&e.errorMessage&&alert(ua._(e.errorMessage)),ha()}},ka=function(){function a(){B&&!B.compare(F)&&(F=B.cloneSelected(),q.trigger(b.Event("selectionchanged"))),G=!1}G||(G=!0,n?a():setTimeout(a,100))},la=function(){var a,c=B.parentNode();D!==c&&(a=D,D=c,E=B.getFirstBlockParent(c),q.trigger(b.Event("nodechanged",{oldNode:a,newNode:D})))},ua.currentNode=function(){return D},ua.currentBlockNode=function(){return E},ha=function(a){var b,c,d="active",e=v[0],f=ua.sourceMode();if(ua.readOnly())return void r.find(d).removeClass(d);f||(c=a?a.newNode:B.parentNode(),b=B.getFirstBlockParent(c));for(var g=0;g-1&&(h=e.queryCommandState(j)?1:0)}catch(a){}}else k||(h=j.call(ua,c,b));i.toggleClass("disabled",k||h<0).toggleClass(d,h>0)}},aa=function(a){var c,d,e,g,h="code,blockquote,pre",i="li,ul,ol";if(!a.originalEvent.defaultPrevented)return ua.closeDropDown(),c=b(E).closest(h+","+i).first(),13===a.which&&c.length&&!c.is(i)?(z=null,d=v[0].createElement("br"),B.insertNode(d),o||(e=d.parentNode,g=e.lastChild,g&&3===g.nodeType&&""===g.nodeValue&&(e.removeChild(g),g=e.lastChild),!f.isInline(e,!0)&&g===d&&f.isInline(d.previousSibling)&&B.insertHTML("
")),!1):void 0},ja=function(){var a,c,d,e=u[0];f.rTraverse(e,function(g){if(a=g.nodeName.toLowerCase(),b.inArray(a,ya)>-1&&(c=!0),3===g.nodeType&&!/^\s*$/.test(g.nodeValue)||"br"===a||o&&!g.firstChild&&!f.isInline(g,!1))return c&&(d=v[0].createElement("p"),d.className="sceditor-nlf",d.innerHTML=o?"":"
",e.appendChild(d)),!1})},ba=function(){ua.val(wa.val())},ca=function(){ua.closeDropDown(),z=null},fa=function(){var a=c.height,b=c.width;ua.maximize()?ua.dimensions("100%","100%",!1):(a&&a.toString().indexOf("%")>-1||b&&b.toString().indexOf("%")>-1)&&ua.dimensions(b,a)},ua._=function(){var a,b=arguments;return A&&A[b[0]]&&(b[0]=A[b[0]]),b[0].replace(/\{(\d+)\}/g,function(c,d){return b[d-0+1]!==a?b[d-0+1]:"{"+d+"}"})},da=function(a){C.call(a.type+"Event",a,ua);var c=a.target===x?"scesrc":"scewys",d=b.Event(a);d.type=c+a.type,q.trigger(d,ua)},ua.bind=function(a,c,d,e){a=a.split(" ");for(var f=a.length;f--;)b.isFunction(c)&&(d||q.on("scewys"+a[f],c),e||q.on("scesrc"+a[f],c),"valuechanged"===a[f]&&(qa.hasHandler=!0));return ua},ua.unbind=function(a,c,d,e){a=a.split(" ");for(var f=a.length;f--;)b.isFunction(c)&&(d||q.off("scewys"+a[f],c),e||q.off("scesrc"+a[f],c));return ua},ua.blur=function(a,c,d){return b.isFunction(a)?ua.bind("blur",a,c,d):ua.sourceMode()?w.blur():u.blur(),ua},ua.focus=function(a,c,d){if(b.isFunction(a))ua.bind("focus",a,c,d);else if(ua.inSourceMode())x.focus();else{var e,f=B.selectedRange();F||B.hasSelection()||ma(),!o&&f&&1===f.endOffset&&f.collapsed&&(e=f.endContainer,e&&1===e.childNodes.length&&b(e.firstChild).is("br")&&(f.setStartBefore(e.firstChild),f.collapse(!0),B.selectRange(f))),t.contentWindow.focus(),u[0].focus(),z&&(B.selectRange(z),z=null)}return ha(),ua},ua.keyDown=function(a,b,c){return ua.bind("keydown",a,b,c)},ua.keyPress=function(a,b,c){return ua.bind("keypress",a,b,c)},ua.keyUp=function(a,b,c){return ua.bind("keyup",a,b,c)},ua.nodeChanged=function(a){return ua.bind("nodechanged",a,!1,!0)},ua.selectionChanged=function(a){return ua.bind("selectionchanged",a,!1,!0)},ua.valueChanged=function(a,b,c){return ua.bind("valuechanged",a,b,c)},na=function(a){var d,e=0,f=ua.emoticonsCache,g=String.fromCharCode(a.which);if(!b(E).is("code")&&!b(E).parents("code").length)return f||(f=[],b.each(b.extend({},c.emoticons.more,c.emoticons.dropdown,c.emoticons.hidden),function(a,b){f[e++]=[a,i("emoticon",{key:a,url:b.url||b,tooltip:b.tooltip||a})]}),f.sort(function(a,b){return a[0].length-b[0].length}),ua.emoticonsCache=f,ua.longestEmoticonCode=f[f.length-1][0].length),d=B.replaceKeyword(ua.emoticonsCache,!0,!0,ua.longestEmoticonCode,c.emoticonsCompat,g),d&&c.emoticonsCompat?(Ba=u.find("img[data-sceditor-emoticon]"),/^\s$/.test(g)):!d},oa=function(){if(Ba.length){var a,c,d,e,f,g,h=ua.currentBlockNode(),i=!1,j=/[^\s\xA0\u2002\u2003\u2009\u00a0]+/;Ba=b.map(Ba,function(k){return k&&k.parentNode?b.contains(h,k)?(a=k.previousSibling,c=k.nextSibling,f=a.nodeValue,null===f&&(f=a.innerText||""),a&&j.test(a.nodeValue.slice(-1))||c&&j.test((c.nodeValue||"")[0])?(d=k.parentNode,e=B.cloneSelected(),g=e.startContainer,f+=b(k).data("sceditor-emoticon"),g===c?i=f.length+e.startOffset:g===h&&h.childNodes[e.startOffset]===c?i=f.length:g===a&&(i=e.startOffset),c&&3===c.nodeType||(c=d.insertBefore(d.ownerDocument.createTextNode(""),c)),c.insertData(0,f),d.removeChild(a),d.removeChild(k),i!==!1&&(e.setStart(c,i),e.collapse(!0),B.selectRange(e)),null):k):k:null})}},ua.emoticons=function(a){return a||a===!1?(c.emoticonsEnabled=a,a?(u.keypress(na),ua.sourceMode()||(B.saveRange(),L(u[0]),Ba=u.find("img[data-sceditor-emoticon]"),qa(!1),B.restoreRange())):(u.find("img[data-sceditor-emoticon]").replaceWith(function(){return b(this).data("sceditor-emoticon")}),Ba=[],u.off("keypress",na),qa()),ua):c.emoticonsEnabled},ua.css=function(a){return I||(I=b('

',toolbarButton:'
{dispName}
',emoticon:'{key}',fontOpt:'{font}',sizeOpt:'{size}',pastetext:'
',table:'
',image:'
',email:'
',link:'
',youtubeMenu:'
',youtube:''};return function(b,c,d){var e=a[b];return $.each(c,function(a,b){e=e.replace(new RegExp("\\{"+a+"\\}","g"),b)}),d&&(e=$(e)),e}}.call(b,c,b,a),!(void 0!==d&&(a.exports=d))},function(a,b,c){var d;d=function(a){"use strict";var b=c(1),d=c(6).ie,e=c(8),f=d&&d<11,g={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(a,c,d){for(var f=0,g=a.opts.fonts.split(","),h=b("
"),i=function(){return d(b(this).data("font")),a.closeDropDown(!0),!1};f"),g=function(c){d(b(this).data("size")),a.closeDropDown(!0),c.preventDefault()},h=1;h<=7;h++)f.append(e("sizeOpt",{size:h},!0).click(g));a.createDropDown(c,"fontsize-picker",f)},exec:function(a){var b=this;g.size._dropDown(b,a,function(a){b.execCommand("fontsize",a)})},tooltip:"Font Size"},color:{_dropDown:function(a,c,d){var e,f,h,i,j={r:255,g:255,b:255},k=b("
"),l=a.opts.colors?a.opts.colors.split("|"):new Array(21),m=[],n=g.color;if(!n._htmlCache){for(e=0;e'),f=0;f'),f%5===0?(j.g-=51,j.b=255):j.b-=51;m.push("
"),e%5===0?(j.r-=51,j.g=255,j.b=255):(j.g=255,j.b=255)}n._htmlCache=m.join("")}k.append(n._htmlCache).find("a").click(function(c){d(b(this).attr("data-color")),a.closeDropDown(!0),c.preventDefault()}),a.createDropDown(c,"color-picker",k)},exec:function(a){var b=this;g.color._dropDown(b,a,function(a){b.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,d=this;c=e("pastetext",{label:d._("Paste your text inside the following box:"),insert:d._("Insert")},!0),c.find(".button").click(function(a){b=c.find("#txt").val(),b&&d.wysiwygEditorInsertText(b),d.closeDropDown(!0),a.preventDefault()}),d.createDropDown(a,"pastetext",c)},tooltip:"Paste Text"},bulletlist:{exec:"insertunorderedlist",tooltip:"Bullet list"},orderedlist:{exec:"insertorderedlist",tooltip:"Numbered list"},indent:{state:function(a,c){var d,e,f,g=b(c),h=g.parents("ul,ol,menu"),i=h.first();if(h.length>1||i.children().length>1)return 0;if(g.is("ul,ol,menu")){if(d=this.getRangeHelper().selectedRange(),!(window.Range&&d instanceof Range))return g.is("li,ul,ol,menu")?0:-1;if(e=d.startContainer.parentNode,f=d.endContainer.parentNode,e!==e.parentNode.firstElementChild||b(f).is("li")&&f!==f.parentNode.lastElementChild)return 0}return-1},exec:function(){var a=this,c=b(a.getRangeHelper().getFirstBlockParent());a.focus(),c.parents("ul,ol,menu")&&a.execCommand("indent")},tooltip:"Add indent"},outdent:{state:function(a,c){return b(c).is("ul,ol,menu")||b(c).parents("ul,ol,menu").length>0?0:-1},exec:function(){var a=this,c=b(a.getRangeHelper().getFirstBlockParent());c.parents("ul,ol,menu")&&a.execCommand("outdent")},tooltip:"Remove one indent"},table:{forceNewLineAfter:["table"],exec:function(a){var b=this,c=e("table",{rows:b._("Rows:"),cols:b._("Cols:"),insert:b._("Insert")},!0);c.find(".button").click(function(a){var d,e,g=c.find("#rows").val()-0,h=c.find("#cols").val()-0,i="";if(!(g<1||h<1)){for(d=0;d",e=0;e"+(f?"":"
")+"";i+=""}i+="
",b.wysiwygEditorInsertHtml(i),b.closeDropDown(!0),a.preventDefault()}}),b.createDropDown(a,"inserttable",c)},tooltip:"Insert a table"},horizontalrule:{exec:"inserthorizontalrule",tooltip:"Insert a horizontal rule"},code:{forceNewLineAfter:["code"],exec:function(){this.wysiwygEditorInsertHtml("",(f?"":"
")+"
")},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&&b.wysiwygEditorInsertHtml("'),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:"),desc:b._("Description (optional):"),insert:b._("Insert")},!0);c.find(".button").click(function(a){var d=c.find("#email").val(),e=c.find("#des").val();d&&(b.focus(),!b.getRangeHelper().selectedHtml()||e?(e=e||d,b.wysiwygEditorInsertHtml(''+e+"")):b.execCommand("createlink","mailto:"+d)),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&&(b.focus(),!b.getRangeHelper().selectedHtml()||e?(e=e||d,b.wysiwygEditorInsertHtml(''+e+"")):b.execCommand("createlink",d)),b.closeDropDown(!0),a.preventDefault()}),b.createDropDown(a,"insertlink",c)},tooltip:"Insert a link"},unlink:{state:function(){var a=b(this.currentNode());return a.is("a")||a.parents("a").length>0?0:-1},exec:function(){var a=b(this.currentNode()),c=a.is("a")?a:a.parents("a").first();c.length&&c.replaceWith(c.contents())},tooltip:"Unlink"},quote:{forceNewLineAfter:["blockquote"],exec:function(a,b,c){var d="
",e="
";b?(c=c?""+c+"":"",d=d+c+b+e,e=null):""===this.getRangeHelper().selectedHtml()&&(e=(f?"":"
")+e),this.wysiwygEditorInsertHtml(d,e)},tooltip:"Insert a Quote"},emoticon:{exec:function(a){var c=this,d=function(e){var f,g=c.opts.emoticonsCompat,h=c.getRangeHelper(),i=g&&" "!==h.getOuterText(!0,1)?" ":"",j=g&&" "!==h.getOuterText(!1,1)?" ":"",k=b("
"),l=b("
").appendTo(k),m=0,n=b.extend({},c.opts.emoticons.dropdown,e?c.opts.emoticons.more:{});return b.each(n,function(){m++}),m=Math.sqrt(m),b.each(n,function(a,d){l.append(b("").attr({src:d.url||d,alt:a,title:d.tooltip||a}).click(function(){return c.insert(i+b(this).attr("alt")+j,null,!1).closeDropDown(!0),!1})),l.children().length>=m&&(l=b("
").appendTo(k))}),!e&&c.opts.emoticons.more&&(f=b(''+c._("More")+"").click(function(){return c.createDropDown(a,"more-emoticons",d(!0)),!1}),k.append(f)),k};c.createDropDown(a,"emoticons",d(!1))},txtExec:function(a){g.emoticon.exec.call(this,a)},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();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(a){var b=this;g.youtube._dropDown(b,a,function(a){b.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 c<2e3&&(c=1900+c),d<10&&(d="0"+d),e<10&&(e="0"+e),a.opts.dateFormat.replace(/year/i,c).replace(/month/i,d).replace(/day/i,e)},exec:function(){this.insertText(g.date._date(this))},txtExec:function(){this.insertText(g.date._date(this))},tooltip:"Insert current date"},time:{_time:function(){var a=new Date,b=a.getHours(),c=a.getMinutes(),d=a.getSeconds();return b<10&&(b="0"+b),c<10&&(c="0"+c),d<10&&(d="0"+d),b+":"+c+":"+d},exec:function(){this.insertText(g.time._time())},txtExec:function(){this.insertText(g.time._time())},tooltip:"Insert current time"},ltr:{state:function(a,b){return b&&"ltr"===b.style.direction},exec:function(){var a=this,c=a.getRangeHelper().getFirstBlockParent(),d=b(c);a.focus(),(c&&!d.is("body")||(a.execCommand("formatBlock","p"),c=a.getRangeHelper().getFirstBlockParent(),d=b(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 a=this,c=a.getRangeHelper().getFirstBlockParent(),d=b(c);a.focus(),(c&&!d.is("body")||(a.execCommand("formatBlock","p"),c=a.getRangeHelper().getFirstBlockParent(),d=b(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:{state:function(){return this.sourceMode()},exec:function(){this.toggleSourceMode()},txtExec:function(){this.toggleSourceMode()},tooltip:"View source",shortcut:"Ctrl+Shift+S"},ignore:{}};return g}.call(b,c,b,a),!(void 0!==d&&(a.exports=d))},function(a,b,c){var d;d=function(a){"use strict";var b=c(1);return{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:b("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,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:{}}}.call(b,c,b,a),!(void 0!==d&&(a.exports=d))}]),function(a,b,c){"use strict";var d=a.sceditor,e=d.plugins,f=d.escapeEntities,g=d.escapeUriScheme,h=d.ie,i=h&&h<11,j=d.command.get,k={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;j("font")._dropDown(b,a,function(a){b.insertText("[font="+a+"]","[/font]")})}},size:{txtExec:function(a){var b=this;j("size")._dropDown(b,a,function(a){b.insertText("[size="+a+"]","[/size]")})}},color:{txtExec:function(a){var b=this;j("color")._dropDown(b,a,function(a){b.insertText("[color="+a+"]","[/color]")})}},bulletlist:{txtExec:function(b,c){var d="";a.each(c.split(/\r?\n/),function(){d+=(d?"\n":"")+"[li]"+this+"[/li]"}),this.insertText("[ul]\n"+d+"\n[/ul]")}},orderedlist:{txtExec:function(b,c){var d="";a.each(c.split(/\r?\n/),function(){d+=(d?"\n":"")+"[li]"+this+"[/li]"}),e.bbcode.bbcode.get(""),this.insertText("[ol]\n"+d+"\n[/ol]")}},table:{txtExec:["[table][tr][td]","[/td][/tr][/table]"]},horizontalrule:{txtExec:["[hr]"]},code:{txtExec:["[code]","[/code]"]},image:{txtExec:function(a,b){var c=this,d=prompt(c._("Enter the image URL:"),b);d&&c.insertText("[img]"+d+"[/img]")}},email:{txtExec:function(a,b){var c=this,d=b&&b.indexOf("@")>-1?null:b,e=prompt(c._("Enter the e-mail address:"),d?"":b),f=prompt(c._("Enter the displayed text:"),d||e)||e;e&&c.insertText("[email="+e+"]"+f+"[/email]")}},link:{txtExec:function(b,c){var d=this,e=/^[a-z]+:\/\//i.test(a.trim(c))?null:c,f=prompt(d._("Enter URL:"),e?"http://":a.trim(c)),g=prompt(d._("Enter the displayed text:"),e||f)||f;f&&d.insertText("[url="+f+"]"+g+"[/url]")}},quote:{txtExec:["[quote]","[/quote]"]},youtube:{txtExec:function(a){var b=this;j("youtube")._dropDown(b,a,function(a){b.insertText("[youtube]"+a+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}},l=function(a){return a?a.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2"):a},m=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+"}"})},n={OPEN:"open",CONTENT:"content",NEWLINE:"newline",CLOSE:"close"},o=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};o.prototype={clone:function(a){var b=this;return new o(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)),b<0||b>f)return null;for(;f--;)f>=b?e++:f=0;return c=d.clone(),c.children=d.children.splice(b,e),c}};var p=function(b){if(!(this instanceof p))return new p(b);var d,g,j,k,m,q,r,s,t,u,v,w,x,y,z,A=this;d=function(){A.bbcodes=e.bbcode.bbcodes,A.opts=a.extend({},p.defaults,b)},A.tokenize=function(a){var b,c,d,e=[],f=[{type:n.CLOSE,regex:/^\[\/[^\[\]]+\]/},{type:n.OPEN,regex:/^\[[^\[\]]+\]/},{type:n.NEWLINE,regex:/^(\r\n|\r|\n)/},{type:n.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(g(c,b[0])),a=a.substr(b[0].length);continue a}a.length&&e.push(g(n.CONTENT,a)),a=""}return e},g=function(b,c){var d,f,g,h=/\[([^\]\s=]+)(?:([^\]]+))?\]/,i=/\[\/([^\[\]]+)\]/;return b===n.OPEN&&(d=c.match(h))&&(g=y(d[1]),d[2]&&(d[2]=a.trim(d[2]))&&(f=j(d[2]))),b===n.CLOSE&&(d=c.match(i))&&(g=y(d[1])),b===n.NEWLINE&&(g="#newline"),g&&(b!==n.OPEN&&b!==n.CLOSE||e.bbcode.bbcodes[g])||(b=n.CONTENT,g="#"),new o(b,g,c,f)},j=function(a){var b,c=/([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g,d={};if("="===a.charAt(0)&&a.indexOf("=",1)<0)d.defaultattr=l(a.substr(1));else for("="===a.charAt(0)&&(a="defaultattr"+a);b=c.exec(a);)d[y(b[1])]=l(b[3])||b[4];return d},A.parse=function(a,b){var c=k(A.tokenize(a)),d=A.opts;return d.fixInvalidChildren&&t(c),d.removeEmptyTags&&s(c),d.fixInvalidNesting&&q(c),m(c,null,b),d.removeEmptyTags&&s(c),c},w=function(a,b,c){for(var d=c.length;d--;)if(c[d].type===b&&c[d].name===a)return!0;return!1},r=function(b,c){var d=b?A.bbcodes[b.name]:{},e=d.allowedChildren;return!A.opts.fixInvalidChildren||!e||a.inArray(c.name||"#",e)>-1},k=function(b){for(var c,d,e,f,g,h,i,j=[],k=[],l=[],m=function(){return z(l)},o=function(a){m()?m().children.push(a):k.push(a)},p=function(b){return m()&&(d=A.bbcodes[m().name])&&d.closedBy&&a.inArray(b,d.closedBy)>-1};c=b.shift();){switch(i=b[0],c.type){case n.OPEN:p(c.name)&&l.pop(),o(c),d=A.bbcodes[c.name],d&&d.isSelfClosing||!d.closedBy&&!w(c.name,n.CLOSE,b)?d&&d.isSelfClosing||(c.type=n.CONTENT):l.push(c);break;case n.CLOSE:if(m()&&c.name!==m().name&&p("/"+c.name)&&l.pop(),m()&&c.name===m().name)m().closing=c,l.pop();else if(w(c.name,n.OPEN,l)){for(;e=l.pop();){if(e.name===c.name){e.closing=c;break}f=e.clone(),j.length&&f.children.push(z(j)),j.push(f)}for(o(z(j)),g=j.length;g--;)l.push(j[g]);j.length=0}else c.type=n.CONTENT,o(c);break;case n.NEWLINE:m()&&i&&p((i.type===n.CLOSE?"/":"")+i.name)&&(i.type===n.CLOSE&&i.name===m().name||(d=A.bbcodes[m().name],d&&d.breakAfter?l.pop():d&&d.isInline===!1&&A.opts.breakAfterBlock&&d.breakAfter!==!1&&l.pop())),o(c);break;default:o(c)}h=c}return k},m=function(a,b,c){var d,e,f,g,h,i,j,k,l=a.length;b&&(g=A.bbcodes[b.name]);for(var o=l;o--;)if(d=a[o])if(d.type===n.NEWLINE){if(e=o>0?a[o-1]:null,f=o1?c[c.length-2].children:e,i=a.inArray(h,j),i>-1))return k.children.splice(a.inArray(f,k.children),1),void j.splice(i+1,0,f,k);c.push(f),q(f.children,c,d||l(f),e),c.pop(f)}},t=function(a,b){for(var c,d,e=a.length;e--;)(c=a[e])&&(r(b,c)||(c.name=null,c.type=n.CONTENT,r(b,c)?(d=[e+1,0].concat(c.children),c.closing&&(c.closing.name=null,c.closing.type=n.CONTENT,d.push(c.closing)),e+=d.length-1,Array.prototype.splice.apply(a,d)):b.children.splice(e,1)),c.type===n.OPEN&&t(c.children,c))},s=function(b){for(var c,d,e=function(a){for(var b=a.length;b--;){var c=a[b].type;if(c===n.OPEN||c===n.CLOSE)return!1;if(c===n.CONTENT&&/\S|\u00A0/.test(a[b].val))return!1}return!0},f=b.length;f--;)(c=b[f])&&c.type===n.OPEN&&(d=A.bbcodes[c.name],s(c.children),e(c.children)&&d&&!d.isSelfClosing&&!d.allowsEmpty&&b.splice.apply(b,a.merge([f,1],c.children)))},A.toHTML=function(a,b){return u(A.parse(a,b),!0)},u=function(b,d){var g,j,k,l,m,o,p,q,r,s=[];for(q=function(a){return(!a||(a.isHtmlInline!==g?a.isHtmlInline:a.isInline))!==!1};b.length>0;)if(j=b.shift()){if(j.type===n.OPEN)r=j.children[j.children.length-1]||{},k=A.bbcodes[j.name],o=d&&q(k),l=u(j.children,!1),k&&k.html?(q(k)||!q(A.bbcodes[r.name])||k.isPreFormatted||k.skipLastLineBreak||i||(l+="
"),a.isFunction(k.html)?m=k.html.call(A,j,j.attrs,l):(j.attrs[0]=l,m=e.bbcode.formatBBCodeString(k.html,j.attrs))):m=j.val+l+(j.closing?j.closing.val:"");else{if(j.type===n.NEWLINE){if(!d){s.push("
");continue}p||(s.push("
"),(h<8||c.documentMode&&c.documentMode<8)&&s.push(" ")),i||s.push("
"),b.length||s.push("
"),s.push("
\n"),p=!1;continue}o=d,m=f(j.val,!0)}o&&!p?(s.push("
"),p=!0):!o&&p&&(s.push("
\n"),p=!1),s.push(m)}return p&&s.push("
\n"),s.join("")},A.toBBCode=function(a,b){return v(A.parse(a,b))},v=function(a){for(var b,c,d,e,f,g,h,i,j,k,l=[];a.length>0;)if(b=a.shift())if(d=A.bbcodes[b.name],e=!(!d||d.isInline!==!1),f=d&&d.isSelfClosing,h=e&&A.opts.breakBeforeBlock&&d.breakBefore!==!1||d&&d.breakBefore,i=e&&!f&&A.opts.breakStartBlock&&d.breakStart!==!1||d&&d.breakStart,j=e&&A.opts.breakEndBlock&&d.breakEnd!==!1||d&&d.breakEnd,k=e&&A.opts.breakAfterBlock&&d.breakAfter!==!1||d&&d.breakAfter,g=(d?d.quoteType:null)||A.opts.quoteType||p.QuoteType.auto,d||b.type!==n.OPEN)if(b.type===n.OPEN){if(h&&l.push("\n"),l.push("["+b.name),b.attrs){b.attrs.defaultattr&&(l.push("=",x(b.attrs.defaultattr,g,"defaultattr")),delete b.attrs.defaultattr);for(c in b.attrs)b.attrs.hasOwnProperty(c)&&l.push(" ",c,"=",x(b.attrs[c],g,c))}l.push("]"),i&&l.push("\n"),b.children&&l.push(v(b.children)),f||d.excludeClosing||(j&&l.push("\n"),l.push("[/"+b.name+"]")),k&&l.push("\n"),b.closing&&f&&l.push(b.closing.val)}else l.push(b.val);else l.push(b.val),b.children&&l.push(v(b.children)),b.closing&&l.push(b.closing.val);return l.join("")},x=function(b,c,d){var e=p.QuoteType,f=/\s|=/.test(b);return a.isFunction(c)?c(b,d):c===e.never||c===e.auto&&!f?b:'"'+b.replace("\\","\\\\").replace('"','\\"')+'"'},z=function(a){return a.length?a[a.length-1]:null},y=function(a){return a.toLowerCase()},d()};p.QuoteType={always:1,never:2,auto:3},p.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:p.QuoteType.auto},a.sceditorBBCodePlugin=e.bbcode=function(){var b,f,g,h,j=this;j.bbcodes=e.bbcode.bbcodes,j.stripQuotes=l;var n={},o={},q={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(),this.commands=a.extend(!0,{},k,this.commands),this.toBBCode=j.signalToSource,this.fromBBCode=j.signalToWysiwyg},b=function(){a.each(j.bbcodes,function(b){var c,d=j.bbcodes[b].tags,e=j.bbcodes[b].styles;d&&a.each(d,function(a,d){c=j.bbcodes[b].isInline===!1,n[a]=n[a]||{},n[a][c]=n[a][c]||{},n[a][c][b]=d}),e&&a.each(e,function(a,d){c=j.bbcodes[b].isInline===!1,o[c]=o[c]||{},o[c][a]=o[c][a]||{},o[c][a][b]=d})})},f=function(b,c,e){var f,g,h=d.dom.getStyle;return e=!!e,o[e]?(a.each(o[e],function(d,e){f=h(b[0],d),f&&h(b.parent()[0],d)!==f&&a.each(e,function(d,e){(!e||a.inArray(f.toString(),e)>-1)&&(g=j.bbcodes[d].format,c=a.isFunction(g)?g.call(j,b,c):m(g,c))})}),c):c},g=function(b,c,e){var f,g,h=b[0],k=h.nodeName.toLowerCase();e=!!e,n[k]&&n[k][e]&&a.each(n[k][e],function(d,e){e&&(f=!1,a.each(e,function(c,d){if(b.attr(c)&&!(d&&a.inArray(b.attr(c),d)<0))return f=!0,!1}),!f)||(g=j.bbcodes[d].format,c=a.isFunction(g)?g.call(j,b,c):m(g,c))});var l=d.dom.isInline;if(e&&(!l(h,!0)||"br"===k)){for(var o,p,q,r=h.previousSibling;r&&1===r.nodeType&&!a(r).is("br")&&l(r,!0)&&!r.firstChild;)r=r.previousSibling;do p=h.parentNode,q=p.lastChild,o=q===h,h=p;while(p&&o&&l(p,!0));(!o||"li"===k||"br"===k&&i)&&(c+="\n"),"br"!==k&&r&&!a(r).is("br")&&l(r,!0)&&(c="\n"+c)}return c},j.signalToSource=function(b,e){var f,g,h=new p(j.opts.parserOptions);return e||("string"==typeof b?(f=a("
").css("visibility","hidden").appendTo(c.body).html(b),e=f):e=a(b)),e&&e.jquery?(d.dom.removeWhiteSpace(e[0]),a(".sceditor-ignore",e).remove(),g=j.elementToBbcode(e),f&&f.remove(),g=h.toBBCode(g,!0),j.opts.bbcodeTrim&&(g=a.trim(g)),g):""},j.elementToBbcode=function(b){var c=function(b,e){var h="";return d.dom.traverse(b,function(b){var d=a(b),j="",k=b.nodeType,l=b.nodeName.toLowerCase(),m=q[l],n=b.firstChild,o=!0;if("object"==typeof e&&(o=a.inArray(l,e)>-1,d.is("img")&&d.data("sceditor-emoticon")&&(o=!0),o||(m=e)),3===k||1===k)if(1===k){if(d.hasClass("sceditor-nlf")&&(!n||!i&&1===b.childNodes.length&&/br/i.test(n.nodeName)))return;"iframe"!==l&&(j=c(b,m)),o?("code"!==l&&(j=f(d,j),j=g(d,j),j=f(d,j,!0)),h+=g(d,j,!0)):h+=j}else h+=b.nodeValue},!1,!0),h};return c(b[0])},j.signalToWysiwyg=function(b,c){var d=new p(j.opts.parserOptions),e=d.toHTML(j.opts.bbcodeTrim?a.trim(b):b);return c?h(e):e},h=function(b){var e,f,g,h=a("
").hide().appendTo(c.body),j=h[0];return g=function(b,e){if(!d.dom.hasStyling(b)){if(i||1!==b.childNodes.length||!a(b.firstChild).is("br"))for(;f=b.firstChild;)j.insertBefore(f,b);if(e){var g=j.lastChild;b!==g&&a(g).is("div")&&b.nextSibling===g&&j.insertBefore(c.createElement("br"),b)}j.removeChild(b)}},j.innerHTML=b.replace(/<\/div>\n/g,"
"),(e=j.firstChild)&&a(e).is("div")&&g(e,!0),(e=j.lastChild)&&a(e).is("div")&&g(e),j=j.innerHTML,h.remove(),j}},e.bbcode.formatBBCodeString=function(a,b){return a.replace(/\{([^}]+)\}/g,function(a,c){ var d,e=!0;return"!"===c.charAt(0)&&(e=!1,c=c.substring(1)),"0"===c&&(e=!1),b[c]===d?a:e?f(b[c],!0):b[c]})};var q=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)},r=function(a){var b;return a=a||"#000",(b=a.match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+q(b[1])+q(b[2]-0)+q(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},s={b:{tags:{b:null,strong:null},styles:{"font-weight":["bold","bolder","401","700","800","900"]},format:"[b]{0}[/b]",html:"{0}"},i:{tags:{i:null,em:null},styles:{"font-style":["italic","oblique"]},format:"[i]{0}[/i]",html:"{0}"},u:{tags:{u:null},styles:{"text-decoration":["underline"]},format:"[u]{0}[/u]",html:"{0}"},s:{tags:{s:null,strike:null},styles:{"text-decoration":["line-through"]},format:"[s]{0}[/s]",html:"{0}"},sub:{tags:{sub:null},format:"[sub]{0}[/sub]",html:"{0}"},sup:{tags:{sup:null},format:"[sup]{0}[/sup]",html:"{0}"},font:{tags:{font:{face:null}},styles:{"font-family":null},quoteType:p.QuoteType.never,format:function(a,b){var c;return a.is("font")&&(c=a.attr("face"))||(c=a.css("font-family")),"[font="+l(c)+"]"+b+"[/font]"},html:'{0}'},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,c<12&&(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:'{!0}'},color:{tags:{font:{color:null}},styles:{color:null},quoteType:p.QuoteType.never,format:function(a,b){var c;return a.is("font")&&(c=a.attr("color"))||(c=a[0].style.color||a.css("color")),"[color="+r(c)+"]"+b+"[/color]"},html:function(a,b,c){return''+c+""}},ul:{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ul]{0}[/ul]",html:"
    {0}
"},list:{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:"
    {0}
"},ol:{tags:{ol:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ol]{0}[/ol]",html:"
    {0}
"},li:{tags:{li:null},isInline:!1,closedBy:["/ul","/ol","/list","*","li"],format:"[li]{0}[/li]",html:"
  • {0}
  • "},"*":{isInline:!1,closedBy:["/ul","/ol","/list","*","li"],html:"
  • {0}
  • "},table:{tags:{table:null},isInline:!1,isHtmlInline:!0,skipLastLineBreak:!0,format:"[table]{0}[/table]",html:"{0}
    "},tr:{tags:{tr:null},isInline:!1,skipLastLineBreak:!0,format:"[tr]{0}[/tr]",html:"{0}"},th:{tags:{th:null},allowsEmpty:!0,isInline:!1,format:"[th]{0}[/th]",html:"{0}"},td:{tags:{td:null},allowsEmpty:!0,isInline:!1,format:"[td]{0}[/td]",html:"{0}"},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:"
    "},img:{allowsEmpty:!0,tags:{img:{src:null}},allowedChildren:["#"],quoteType:p.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 d,e,h,i,j="";return e=b.width,h=b.height,b.defaultattr&&(i=b.defaultattr.split(/x/i),e=i[0],h=2===i.length?i[1]:i[0]),e!==d&&(j+=' width="'+f(e,!0)+'"'),h!==d&&(j+=' height="'+f(h,!0)+'"'),"'}},url:{allowsEmpty:!0,tags:{a:{href:null}},quoteType:p.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=f(b.defaultattr,!0)||c,''+c+""}},email:{quoteType:p.QuoteType.never,html:function(a,b,c){return''+c+""}},quote:{tags:{blockquote:null},isInline:!1,quoteType:p.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.replace(/(^\s+|\s+$)/g,""),e.prepend(f)),"[quote"+d+"]"+c+"[/quote]"},html:function(a,b,c){return b.defaultattr&&(c=""+f(b.defaultattr)+""+c),"
    "+c+"
    "}},code:{tags:{code:null},isInline:!1,allowedChildren:["#","#newline"],format:"[code]{0}[/code]",html:"{0}"},left:{styles:{"text-align":["left","-webkit-left","-moz-left","-khtml-left"]},isInline:!1,format:"[left]{0}[/left]",html:'
    {0}
    '},center:{styles:{"text-align":["center","-webkit-center","-moz-center","-khtml-center"]},isInline:!1,format:"[center]{0}[/center]",html:'
    {0}
    '},right:{styles:{"text-align":["right","-webkit-right","-moz-right","-khtml-right"]},isInline:!1,format:"[right]{0}[/right]",html:'
    {0}
    '},justify:{styles:{"text-align":["justify","-webkit-justify","-moz-justify","-khtml-justify"]},isInline:!1,format:"[justify]{0}[/justify]",html:'
    {0}
    '},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:''},rtl:{styles:{direction:["rtl"]},format:"[rtl]{0}[/rtl]",html:'
    {0}
    '},ltr:{styles:{direction:["ltr"]},format:"[ltr]{0}[/ltr]",html:'
    {0}
    '},ignore:{}};e.bbcode.bbcode={get:function(a){return s[a]||null},set:function(b,c){return!(!b||!c)&&(c=a.extend(s[b]||{},c),c.remove=function(){delete s[b]},s[b]=c,this)},rename:function(a,b){return a in s&&(s[b]=s[a],delete s[a],this)},remove:function(a){return a in s&&delete s[a],this}},a.fn.sceditorBBCodePlugin=function(b){return b=b||{},a.isPlainObject(b)&&(b.plugins=(b.plugins||"")+"bbcode"),this.sceditor(b)},e.bbcode.normaliseColour=r,e.bbcode.formatString=m,e.bbcode.stripQuotes=l,e.bbcode.bbcodes=s,d.BBCodeParser=p}(jQuery,window,document);