/*!pl SCEditor | (C) 2011-2013, Sam Clarke | sceditor.com/license */
(function(e,t,n){"use strict";e.sceditor.BBCodeParser=function(t){if(!(this instanceof e.sceditor.BBCodeParser))return new e.sceditor.BBCodeParser(t);var o,i,r,s,a,l,c,d,u,p,f,h,m,g,b,v=this,y={open:"open",content:"content",newline:"newline",close:"close"};Object.freeze&&Object.freeze(y);var x=function(e,t,n,o,i,r){var s=this;s.type=e,s.name=t,s.val=n,s.attrs=o||{},s.children=i||[],s.closing=r||null};x.prototype={clone:function(e){var t=this;return new x(t.type,t.name,t.val,t.attrs,e?t.children:[],t.closing?t.closing.clone():null)},splitAt:function(t){var n,o=this,i=0,r=o.children.length;if("number"!=typeof object&&(t=e.inArray(t,o.children)),0>t||t>r)return null;for(;r--;)r>=t?i++:r=0;return n=o.clone(),n.children=o.children.splice(t,i),n}},o=function(){v.opts=e.extend({},e.sceditor.BBCodeParser.defaults,t),v.bbcodes=e.sceditor.plugins.bbcode.bbcodes},v.tokenize=function(e){var t,n,o,r=[],s=[{type:"close",regex:/^\[\/[^\[\]]+\]/},{type:"open",regex:/^\[[^\[\]]+\]/},{type:"newline",regex:/^(\r\n|\r|\n)/},{type:"content",regex:/^([^\[\r\n]+|\[)/}];s.reverse();e:for(;e.length;){for(o=s.length;o--;)if(n=s[o].type,(t=e.match(s[o].regex))&&t[0]){r.push(i(n,t[0])),e=e.substr(t[0].length);continue e}e.length&&r.push(i(y.content,e)),e=""}return r},i=function(t,n){var o,i,s;return"open"===t&&(o=n.match(/\[([^\]\s=]+)(?:([^\]]+))?\]/))?(s=g(o[1]),o[2]&&(o[2]=e.trim(o[2]))&&(i=r(o[2]))):"close"===t&&(o=n.match(/\[\/([^\[\]]+)\]/))?s=g(o[1]):"newline"===t&&(s="#newline"),s&&("open"!==t&&"close"!==t||e.sceditor.plugins.bbcode.bbcodes[s])||(t="content",s="#"),new x(t,s,n,i)},r=function(t){var n,o=/([^\s=]+)=(?:(?:(["'])((?:\\\2|[^\2])*?)\2)|((?:.(?!\s\S+=))*.))/g,i=e.sceditor.plugins.bbcode.stripQuotes,r={};if("="===t.charAt(0)&&0>t.indexOf("=",1))r.defaultattr=i(t.substr(1));else for("="===t.charAt(0)&&(t="defaultattr"+t);n=o.exec(t);)r[g(n[1])]=i(n[3])||n[4];return r},v.parse=function(e,t){var n=s(v.tokenize(e));return v.opts.fixInvalidChildren&&u(n),v.opts.removeEmptyTags&&d(n),v.opts.fixInvalidNesting&&l(n),a(n,null,t),v.opts.removeEmptyTags&&d(n),n},h=function(e,t,n){for(var o=n.length;o--;)if(n[o].type===t&&n[o].name===e)return!0;return!1},c=function(t,n){var o=t?v.bbcodes[t.name]:null,i=o?o.allowedChildren:null;return v.opts.fixInvalidChildren&&i?i&&0>e.inArray(n.name||"#",i)?!1:!0:!0},s=function(t){for(var n,o,i,r,s,a,l,c=[],d=[],u=[],p=function(){return b(u)},f=function(e){p()?p().children.push(e):d.push(e)},m=function(t){return p()&&(o=v.bbcodes[p().name])&&o.closedBy&&e.inArray(t,o.closedBy)>-1};n=t.shift();){switch(l=t[0],n.type){case y.open:m(n.name)&&u.pop(),f(n),o=v.bbcodes[n.name],o&&o.isSelfClosing||!o.closedBy&&!h(n.name,y.close,t)?o&&o.isSelfClosing||(n.type=y.content):u.push(n);break;case y.close:if(p()&&n.name!==p().name&&m("/"+n.name)&&u.pop(),p()&&n.name===p().name)p().closing=n,u.pop();else if(h(n.name,y.open,u)){for(;i=u.pop();){if(i.name===n.name){i.closing=n;break}r=i.clone(),c.length>1&&r.children.push(b(c)),c.push(r)}for(f(b(c)),s=c.length;s--;)u.push(c[s]);c.length=0}else n.type=y.content,f(n);break;case y.newline:p()&&l&&m((l.type===y.close?"/":"")+l.name)&&(l.type!==y.close||l.name!==p().name)&&(o=v.bbcodes[p().name],o&&o.breakAfter?u.pop():o&&o.isInline===!1&&v.opts.breakAfterBlock&&o.breakAfter!==!1&&u.pop()),f(n);break;default:f(n)}a=n}return d},a=function(e,t,n){var o,i,r,s,l,c,d,u,p=e.length,f=p;for(t&&(s=v.bbcodes[t.name]);f--;)if(o=e[f])if(o.type===y.newline){if(i=f>0?e[f-1]:null,r=p-1>f?e[f+1]:null,u=!1,!n&&s&&s.isSelfClosing!==!0&&(i?c||r||(s.isInline===!1&&v.opts.breakEndBlock&&s.breakEnd!==!1&&(u=!0),s.breakEnd&&(u=!0),c=u):(s.isInline===!1&&v.opts.breakStartBlock&&s.breakStart!==!1&&(u=!0),s.breakStart&&(u=!0))),i&&i.type===y.open&&(l=v.bbcodes[i.name])&&(n?l.isInline===!1&&(u=!0):(l.isInline===!1&&v.opts.breakAfterBlock&&l.breakAfter!==!1&&(u=!0),l.breakAfter&&(u=!0))),!n&&!d&&r&&r.type===y.open&&(l=v.bbcodes[r.name])&&(l.isInline===!1&&v.opts.breakBeforeBlock&&l.breakBefore!==!1&&(u=!0),l.breakBefore&&(u=!0),d=u,u)){e.splice(f,1);continue}u&&e.splice(f,1),d=!1}else o.type===y.open&&a(o.children,o,n)},l=function(t,n,o,i){var r,s,a,c,d,u,p=function(e){var t=v.bbcodes[e.name];return!t||t.isInline!==!1};for(n=n||[],i=i||t,s=0;t.length>s;s++)if((r=t[s])&&r.type===y.open){if(!p(r)&&o&&(a=b(n),u=a.splitAt(r),d=n.length>1?n[n.length-2].children:i,(c=e.inArray(a,d))>-1))return u.children.splice(e.inArray(r,u.children),1),d.splice(c+1,0,r,u),void 0;n.push(r),l(r.children,n,o||p(r),i),n.pop(r)}},u=function(e,t){for(var n,o,i=e.length;i--;)(n=e[i])&&(c(t,n)||(n.name=null,n.type=y.content,c(t,n)?(o=[i+1,0].concat(n.children),n.closing&&(n.closing.name=null,n.closing.type=y.content,o.push(n.closing)),i+=o.length-1,Array.prototype.splice.apply(e,o)):t.children.splice(i,1)),n.type===y.open&&u(n.children,n))},d=function(t){var n,o,i,r=t.length;for(i=function(e){for(var t=e.length;t--;){if(e[t].type===y.open)return!1;if(e[t].type===y.close)return!1;if(e[t].type===y.content&&e[t].val&&/\S|\u00A0/.test(e[t].val))return!1}return!0};r--;)(n=t[r])&&n.type===y.open&&(o=v.bbcodes[n.name],d(n.children),i(n.children)&&o&&!o.isSelfClosing&&!o.allowsEmpty&&t.splice.apply(t,e.merge([r,1],n.children)))},v.toHTML=function(e,t){return p(v.parse(e,t),!0)},p=function(t,o){var i,r,s,a,l,c,d,u,f=[];for(d=function(e){return(!e||(e.isHtmlInline!==void 0?e.isHtmlInline:e.isInline))!==!1};t.length>0;)if(i=t.shift()){if(i.type===y.open)u=i.children[i.children.length-1]||{},r=v.bbcodes[i.name],l=o&&d(r),s=p(i.children,!1),r&&r.html?(d(r)||!d(v.bbcodes[u.name])||r.isPreFormatted||r.skipLastLineBreak||e.sceditor.ie||(s+="
"),a=e.isFunction(r.html)?r.html.call(v,i,i.attrs,s):e.sceditor.plugins.bbcode.formatString(r.html,s)):a=i.val+s+(i.closing?i.closing.val:"");else{if(i.type===y.newline){if(!o){f.push("
");continue}if(c){f.push("\n"),c=!1;continue}f.push("
"),e.sceditor.ie||f.push("
"),(n.documentMode&&8>n.documentMode||8>e.sceditor.ie)&&f.push(" "),f.push("
\n");continue}l=o,a=e.sceditor.escapeEntities(i.val)}l&&!c?(f.push(""),c=!0):!l&&c&&(f.push("
\n"),c=!1),f.push(a)}return c&&f.push("\n"),f.join("")},v.toBBCode=function(e,t){return f(v.parse(e,t))},f=function(t){for(var n,o,i,r,s,a,l,c,d,u,p=[];t.length>0;)if(n=t.shift())if(i=v.bbcodes[n.name],r=!(!i||i.isInline!==!1),s=i&&i.isSelfClosing,l=r&&v.opts.breakBeforeBlock&&i.breakBefore!==!1||i&&i.breakBefore,c=r&&!s&&v.opts.breakStartBlock&&i.breakStart!==!1||i&&i.breakStart,d=r&&v.opts.breakEndBlock&&i.breakEnd!==!1||i&&i.breakEnd,u=r&&v.opts.breakAfterBlock&&i.breakAfter!==!1||i&&i.breakAfter,a=(i?i.quoteType:null)||v.opts.quoteType||e.sceditor.BBCodeParser.QuoteType.auto,i||n.type!==y.open)if(n.type===y.open){if(l&&p.push("\n"),p.push("["+n.name),n.attrs){n.attrs.defaultattr&&(p.push("="+m(n.attrs.defaultattr,a,"defaultattr")),delete n.attrs.defaultattr);for(o in n.attrs)n.attrs.hasOwnProperty(o)&&p.push(" "+o+"="+m(n.attrs[o],a,o))}p.push("]"),c&&p.push("\n"),n.children&&p.push(f(n.children)),s||i.excludeClosing||(d&&p.push("\n"),p.push("[/"+n.name+"]")),u&&p.push("\n"),n.closing&&s&&p.push(n.closing.val)}else p.push(n.val);else p.push(n.val),n.children&&p.push(f(n.children)),n.closing&&p.push(n.closing.val);return p.join("")},m=function(t,n,o){var i=e.sceditor.BBCodeParser.QuoteType,r=/\s|=/.test(t);return e.isFunction(n)?n(t,o):n===i.never||n===i.auto&&!r?t:'"'+t.replace("\\","\\\\").replace('"','\\"')+'"'},b=function(e){return e.length?e[e.length-1]:null},g=function(e){return e.toLowerCase()},o()},e.sceditor.BBCodeParser.QuoteType={always:1,never:2,auto:3},Object.freeze&&Object.freeze(e.sceditor.BBCodeParser.QuoteType),e.sceditor.BBCodeParser.defaults={breakBeforeBlock:!1,breakStartBlock:!1,breakEndBlock:!1,breakAfterBlock:!0,removeEmptyTags:!0,fixInvalidNesting:!0,fixInvalidChildren:!0,quoteType:e.sceditor.BBCodeParser.QuoteType.auto},e.sceditorBBCodePlugin=e.sceditor.plugins.bbcode=function(){var t,o,i,r,s,a,l,c=this;r=e.sceditor.plugins.bbcode.formatString,c.bbcodes=e.sceditor.plugins.bbcode.bbcodes,c.stripQuotes=e.sceditor.plugins.bbcode.stripQuotes;var d={},u={},p={ul:["li","ol","ul"],ol:["li","ol","ul"],table:["tr"],tr:["td","th"],code:["br","p","div"]},f={};c.init=function(){c.opts=this.opts,t(),a(this),this.toBBCode=c.signalToSource,this.fromBBCode=c.signalToWysiwyg},a=function(t){var n={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(t){var n=this;e.sceditor.command.get("font")._dropDown(n,t,function(e){n.insertText("[font="+e+"]","[/font]")})}},size:{txtExec:function(t){var n=this;e.sceditor.command.get("size")._dropDown(n,t,function(e){n.insertText("[size="+e+"]","[/size]")})}},color:{txtExec:function(t){var n=this;e.sceditor.command.get("color")._dropDown(n,t,function(e){n.insertText("[color="+e+"]","[/color]")})}},bulletlist:{txtExec:["[ul][li]","[/li][/ul]"]},orderedlist:{txtExec:["[ol][li]","[/li][/ol]"]},table:{txtExec:["[table][tr][td]","[/td][/tr][/table]"]},horizontalrule:{txtExec:["[hr]"]},code:{txtExec:["[code]","[/code]"]},image:{txtExec:function(e,t){var n=prompt(this._("Enter the image URL:"),t);n&&this.insertText("[img]"+n+"[/img]")}},email:{txtExec:function(e,t){var n=t&&t.indexOf("@")>-1?null:t,o=prompt(this._("Enter the e-mail address:"),n?"":t),i=prompt(this._("Enter the displayed text:"),n||o)||o;o&&this.insertText("[email="+o+"]"+i+"[/email]")}},link:{txtExec:function(e,t){var n=t&&t.indexOf("http://")>-1?null:t,o=prompt(this._("Enter URL:"),n?"http://":t),i=prompt(this._("Enter the displayed text:"),n||o)||o;o&&this.insertText("[url="+o+"]"+i+"[/url]")}},quote:{txtExec:["[quote]","[/quote]"]},youtube:{txtExec:function(t){var n=this;e.sceditor.command.get("youtube")._dropDown(n,t,function(e){n.insertText("[youtube]"+e+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}};t.commands=e.extend(!0,{},n,t.commands)},t=function(){e.each(c.bbcodes,function(t){c.bbcodes[t].tags&&e.each(c.bbcodes[t].tags,function(e,n){var o=c.bbcodes[t].isInline===!1;d[e]=d[e]||{},d[e][o]=d[e][o]||{},d[e][o][t]=n}),c.bbcodes[t].styles&&e.each(c.bbcodes[t].styles,function(e,n){var o=c.bbcodes[t].isInline===!1;u[o]=u[o]||{},u[o][e]=u[o][e]||{},u[o][e][t]=n})})},s=function(t,n){var o,i,r,s,a,l=t.style;return l?(f[n]||(f[n]=e.camelCase(n)),a=f[n],"text-align"===n?(o=e(t),r=l.direction,s=l[a]||o.css(n),o.parent().css(n)===s||"block"!==o.css("display")||o.is("hr")||o.is("th")||(i=s),r&&i&&(/right/i.test(i)&&"rtl"===r||/left/i.test(i)&&"ltr"===r)?null:i):l[a]):null},o=function(t,n,o){var i;return o=!!o,u[o]?(e.each(u[o],function(o,a){i=s(t[0],o),i&&s(t.parent()[0],o)!==i&&e.each(a,function(o,s){(!s||e.inArray(""+i,s)>-1)&&(n=e.isFunction(c.bbcodes[o].format)?c.bbcodes[o].format.call(c,t,n):r(c.bbcodes[o].format,n))})}),n):n},i=function(t,n,o){var i=t[0].nodeName.toLowerCase();if(o=!!o,d[i]&&d[i][o]&&e.each(d[i][o],function(o,i){if(i){var s=!1;if(e.each(i,function(n,o){return!t.attr(n)||o&&0>e.inArray(t.attr(n),o)?void 0:(s=!0,!1)}),!s)return}n=e.isFunction(c.bbcodes[o].format)?c.bbcodes[o].format.call(c,t,n):r(c.bbcodes[o].format,n)}),o&&(!e.sceditor.dom.isInline(t[0],!0)||"br"===i)){for(var s=t[0].parentNode,a=t[0].previousSibling,l=e.sceditor.dom.isInline(s,!0)||"body"===s.nodeName.toLowerCase();a&&e(a).hasClass("sceditor-ignore");)a=a.previousSibling;(l||s.lastChild!==t[0]||"li"===i||"br"===i&&e.sceditor.ie)&&(n+="\n"),"br"!==i&&a&&"br"!=a.nodeName.toLowerCase()&&e.sceditor.dom.isInline(a,!0)&&(n="\n"+n)}return n},c.signalToSource=function(t,o){var i,r,s=new e.sceditor.BBCodeParser(c.opts.parserOptions);return o||("string"==typeof t?(i=e("").css("visibility","hidden").appendTo(n.body).html(t),o=i):o=e(t)),o&&o.jquery?(e.sceditor.dom.removeWhiteSpace(o[0]),r=c.elementToBbcode(o),i&&i.remove(),e.trim(s.toBBCode(r,!0))):""},c.elementToBbcode=function(t){return function n(t,r){var s="";return e.sceditor.dom.traverse(t,function(t){var a=e(t),l="",c=t.nodeType,d=t.nodeName.toLowerCase(),u=p[d],f=!0;if("object"==typeof r&&(f=e.inArray(d,r)>-1,f||(u=r)),3===c||1===c)if(1===c){if(a.hasClass("sceditor-ignore"))return;"iframe"!==d&&(l=n(t,u)),f?("code"!==d&&(l=o(a,l),l=i(a,l),l=o(a,l,!0)),s+=i(a,l,!0)):s+=l}else!t.wholeText||t.previousSibling&&3===t.previousSibling.nodeType?t.wholeText||(s+=t.nodeValue):s+=0===a.parents("code").length?t.wholeText.replace(/ +/g," "):t.wholeText},!1,!0),s}(t.get(0))},c.signalToWysiwyg=function(t,n){var o=new e.sceditor.BBCodeParser(c.opts.parserOptions),i=o.toHTML(e.trim(t));return n?l(i):i},l=function(t){var o,i,r,s=e("").hide().appendTo(n.body),a=s[0];return r=function(t,o){if(!t.className&&!e(t).attr("style")&&e.isEmptyObject(e(t).data())){for(;i=t.firstChild;)a.insertBefore(i,t);if(o){var r=a.lastChild;t!==r&&e(r).is("div")&&t.nextSibling===r&&a.insertBefore(n.createElement("br"),t)}a.removeChild(t)}},a.innerHTML=t.replace(/<\/div>\n/g,""),(o=a.firstChild)&&e(o).is("div")&&r(o,!0),(o=a.lastChild)&&e(o).is("div")&&r(o),a=a.innerHTML,s.remove(),a}},e.sceditor.plugins.bbcode.stripQuotes=function(e){return e?e.replace(/\\(.)/g,"$1").replace(/^(["'])(.*?)\1$/,"$2"):e},e.sceditor.plugins.bbcode.formatString=function(){var e=arguments;return e[0].replace(/\{(\d+)\}/g,function(t,n){return e[n-0+1]!==void 0?e[n-0+1]:"{"+n+"}"})},e.sceditor.plugins.bbcode.normaliseColour=function(e){function t(e){return e=parseInt(e,10),isNaN(e)?"00":(e=Math.max(0,Math.min(e,255)).toString(16),2>e.length?"0"+e:e)}var n;return(n=e.match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+t(n[1])+t(n[2]-0)+t(n[3]-0):(n=e.match(/#([0-f])([0-f])([0-f])\s*?$/i))?"#"+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]:e},e.sceditor.plugins.bbcode.bbcodes={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:e.sceditor.BBCodeParser.QuoteType.never,format:function(e,t){var n;return"font"===e[0].nodeName.toLowerCase()&&(n=e.attr("face"))||(n=e.css("font-family")),"[font="+this.stripQuotes(n)+"]"+t+"[/font]"},html:function(e,t,n){return''+n+""}},size:{tags:{font:{size:null}},styles:{"font-size":null},format:function(e,t){var n=e.attr("size"),o=1;return n||(n=e.css("fontSize")),n.indexOf("px")>-1?(n=n.replace("px","")-0,n>12&&(o=2),n>15&&(o=3),n>17&&(o=4),n>23&&(o=5),n>31&&(o=6),n>47&&(o=7)):o=n,"[size="+o+"]"+t+"[/size]"},html:function(e,t,n){return''+n+""}},color:{tags:{font:{color:null}},styles:{color:null},quoteType:e.sceditor.BBCodeParser.QuoteType.never,format:function(t,n){var o,i=t[0];return"font"===i.nodeName.toLowerCase()&&(o=t.attr("color"))||(o=i.style.color||t.css("color")),"[color="+e.sceditor.plugins.bbcode.normaliseColour(o)+"]"+n+"[/color]"},html:function(e,t,n){return''+n+""}},ul:{tags:{ul:null},breakStart:!0,isInline:!1,skipLastLineBreak:!0,format:"[ul]{0}[/ul]",html:""},list:{breakStart:!0,isInline:!1,skipLastLineBreak:!0,html:""},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:""},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(e,t){return e.attr("data-sceditor-emoticon")+t},html:"{0}"},hr:{tags:{hr:null},allowsEmpty:!0,isSelfClosing:!0,isInline:!1,format:"[hr]{0}",html:"
"},img:{allowsEmpty:!0,tags:{img:{src:null}},quoteType:e.sceditor.BBCodeParser.QuoteType.never,format:function(e,t){var n,o,i="",r=e[0],s=function(e){return r.style?r.style[e]:null};return e.attr("data-sceditor-emoticon")!==void 0?t:(n=e.attr("width")||s("width"),o=e.attr("height")||s("height"),(r.complete&&(n||o)||n&&o)&&(i="="+e.width()+"x"+e.height()),"[img"+i+"]"+e.attr("src")+"[/img]")},html:function(e,t,n){var o,i="";return t.width!==void 0&&(i+=' width="'+t.width+'"'),t.height!==void 0&&(i+=' height="'+t.height+'"'),t.defaultattr&&(o=t.defaultattr.split(/x/i),i=' width="'+o[0]+'"'+' height="'+(2===o.length?o[1]:o[0])+'"'),"'}},url:{allowsEmpty:!0,tags:{a:{href:null}},quoteType:e.sceditor.BBCodeParser.QuoteType.never,format:function(e,t){var n=e.attr("href");return"mailto:"===n.substr(0,7)?'[email="'+n.substr(7)+'"]'+t+"[/email]":"[url="+decodeURI(n)+"]"+t+"[/url]"},html:function(e,t,n){return(t.defaultattr===void 0||0===t.defaultattr.length)&&(t.defaultattr=n),''+n+""}},email:{quoteType:e.sceditor.BBCodeParser.QuoteType.never,html:function(e,t,n){return t.defaultattr===void 0&&(t.defaultattr=n),''+n+""}},quote:{tags:{blockquote:null},isInline:!1,quoteType:e.sceditor.BBCodeParser.QuoteType.never,format:function(t,n){var o="",i=e(t),r=i.children("cite").first();return(1===r.length||i.data("author"))&&(o=r.text()||i.data("author"),i.data("author",o),r.remove(),i.children("cite").replaceWith(function(){return e(this).text()}),n=this.elementToBbcode(e(t)),o="="+o),"[quote"+o+"]"+n+"[/quote]"},html:function(e,t,n){return t.defaultattr!==void 0&&(n=""+t.defaultattr+""+n),""+n+"
"}},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(e,t){return(e=e.attr("data-youtube-id"))?"[youtube]"+e+"[/youtube]":t},html:''},rtl:{styles:{direction:["rtl"]},format:"[rtl]{0}[/rtl]",html:'{0}
'},ltr:{styles:{direction:["ltr"]},format:"[ltr]{0}[/ltr]",html:'{0}
'},ignore:{}},e.sceditor.plugins.bbcode.bbcode={get:function(t){return e.sceditor.plugins.bbcode.bbcodes[t]||null},set:function(t,n){return t&&n?(n=e.extend(e.sceditor.plugins.bbcode.bbcodes[t]||{},n),n.remove=function(){e.sceditor.plugins.bbcode.bbcode.remove(t)},e.sceditor.plugins.bbcode.bbcodes[t]=n,this):!1},rename:function(e,t){return this.hasOwnProperty(e)?(this[t]=this[e],this.remove(e),this):!1},remove:function(t){return e.sceditor.plugins.bbcode.bbcodes[t]&&delete e.sceditor.plugins.bbcode.bbcodes[t],this}},e.fn.sceditorBBCodePlugin=function(t){return t=t||{},e.isPlainObject(t)&&(t.plugins=(t.plugins?t.plugins:"")+"bbcode"),this.sceditor(t)}})(jQuery,window,document);