Skip to content
Browse files

Add ability to remove block elements by pressing backspace when the

cursor is at the start of them. #133
  • Loading branch information...
1 parent f4b1239 commit 3e692709775b12411174728b4d4aa3b633c4474c @samclarke committed
View
2 CHANGELOG.txt
@@ -33,6 +33,8 @@ Version 1.4.4:
Added bbcodeTrim option.
Fixed bug with stripWhiteSpace and saved ranges causing a space after the caret to be removed.
Added spellcheck option to disable the browsers built in spellchecker.
+ Added ability to remove block level elements by placing the cursor at the start of them and
+ pressing backspace.
Version 1.4.3:
Added css() method which allows getting/setting inline CSS for the WYSIWYG editor.
View
6 minified/jquery.sceditor.bbcode.min.js
3 additions, 3 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 minified/jquery.sceditor.min.js
@@ -1,3 +1,3 @@
/*! SCEditor | (C) 2011-2013, Sam Clarke | sceditor.com/license */
-(function(e,t,n){"use strict";var o={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"></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>'},i=function(t,n,i){var r=o[t];return e.each(n,function(e,t){r=r.replace(RegExp("\\{"+e+"\\}","g"),t)}),i&&(r=e(r)),r};e.sceditor=function(o,r){var s,a,c,l,d,u,p,f,h,m,g,v,y,b,x,w,C,S,k,E,T,D,M,H,R,N,O,z,I,W,_,P,A,L,F,B,V,j,q,$,U,Y,K,X,Q,G,J,Z,et,tt,nt,ot,it=this,rt=o.get?o.get(0):o,st=e(rt),at=[],ct=[],lt=[],dt=[],ut={},pt=[];it.commands=e.extend(!0,{},r.commands||e.sceditor.commands),it.opts=r=e.extend({},e.sceditor.defaultOptions,r),T=function(){st.data("sceditor",it),e.each(r,function(t,n){e.isPlainObject(n)&&(r[t]=e.extend(!0,{},n))}),r.locale&&"en"!==r.locale&&O(),s=e('<div class="sceditor-container" />').insertAfter(st).css("z-index",r.zIndex),e.sceditor.ie&&s.addClass("ie ie"+e.sceditor.ie),k=!!st.attr("required"),st.removeAttr("required"),N(),A(),z(),R(),_(),I(),W(),e.sceditor.isWysiwygSupported||it.toggleSourceMode();var o=function(){e(t).unbind("load",o),r.autofocus&&tt(),r.autoExpand&&it.expandToContent(),K()};e(t).load(o),n.readyState&&"complete"===n.readyState&&o(),Q(),b.call("ready")},N=function(){var t=r.plugins;t=t?(""+t).split(","):[],b=new e.sceditor.PluginManager(it),e.each(t,function(t,n){b.register(e.trim(n))})},O=function(){var t;e.sceditor.locale[r.locale]?g=e.sceditor.locale[r.locale]:(t=r.locale.split("-"),e.sceditor.locale[t[0]]&&(g=e.sceditor.locale[t[0]])),g&&g.dateFormat&&(r.dateFormat=g.dateFormat)},R=function(){var n,o;p=e("<textarea></textarea>").hide(),c=e('<iframe frameborder="0"></iframe>'),"https:"===t.location.protocol&&c.attr("src","javascript:false"),s.append(c).append(p),l=c[0],f=p[0],it.width(r.width||st.width()),it.height(r.height||st.height()),n=L(),n.open(),n.write(i("html",{charset:r.charset,style:r.style})),n.close(),u=e(n),d=e(n.body),it.readOnly(!!r.readOnly),e.sceditor.ie&&u.find("html").addClass("ie ie"+e.sceditor.ie),(e.sceditor.ios||e.sceditor.ie)&&(d.height("100%"),e.sceditor.ie||d.bind("touchend",it.focus)),v=new e.sceditor.rangeHelper(l.contentWindow),it.val(st.hide().val()),o=st.attr("tabindex"),p.attr("tabindex",o),c.attr("tabindex",o)},I=function(){r.autoUpdate&&(d.bind("blur",it.updateOriginal),p.bind("blur",it.updateOriginal)),null===r.rtl&&(r.rtl="rtl"===p.css("direction")),it.rtl(!!r.rtl),r.autoExpand&&u.bind("keyup",it.expandToContent),r.resizeEnabled&&P(),s.attr("id",r.id),it.emoticons(r.emoticonsEnabled)},W=function(){e(n).click(Y),e(rt.form).bind("reset",q).submit(it.updateOriginal),e(t).bind("resize orientationChanged",K),d.keypress(j).keydown(V).keyup(J).bind("paste",F).bind(e.sceditor.ie?"selectionchange":"keyup focus blur contextmenu mouseup touchend click",Z).bind("keydown keyup keypress focus blur contextmenu",U),r.emoticonsCompat&&t.getSelection&&d.keyup(ot),p.bind("keydown keyup keypress focus blur contextmenu",U).keydown(V),u.keypress(j).mousedown($).bind(e.sceditor.ie?"selectionchange":"focus blur contextmenu mouseup click",Z).bind("beforedeactivate keyup",H).keyup(J).focus(function(){m=null}),s.bind("selectionchanged",et).bind("selectionchanged",Q).bind("selectionchanged",U).bind("nodechanged",U)},z=function(){var t,n,o=(r.toolbarExclude||"").split(","),c=r.toolbar.split("|");a=e('<div class="sceditor-toolbar" unselectable="on" />'),e.each(c,function(r,s){t=e('<div class="sceditor-group" />'),e.each(s.split(","),function(r,s){!it.commands[s]||e.inArray(s,o)>-1||(n=i("toolbarButton",{name:s,dispName:it._(it.commands[s].tooltip||s)},!0),n.data("sceditor-txtmode",!!it.commands[s].txtExec),n.data("sceditor-wysiwygmode",!!it.commands[s].exec),n.click(function(){var t=e(this);return t.hasClass("disabled")||M(t,it.commands[s]),Q(),!1}),it.commands[s].tooltip&&n.attr("title",it._(it.commands[s].tooltip)),it.commands[s].exec||n.addClass("disabled"),it.commands[s].shortcut&&it.addShortcut(it.commands[s].shortcut,s),t.append(n))}),t[0].firstChild&&a.append(t)}),e(r.toolbarContainer||s).append(a)},_=function(){e.each(it.commands,function(t,n){n.keyPress&&at.push(n.keyPress),n.forceNewLineAfter&&e.isArray(n.forceNewLineAfter)&&(lt=e.merge(lt,n.forceNewLineAfter)),n.state?dt.push({name:t,state:n.state}):"string"==typeof n.exec&&dt.push({name:t,state:n.exec})}),J()},P=function(){var o,i,a,c,l,d,u=e('<div class="sceditor-grip" />'),p=e('<div class="sceditor-resize-cover" />'),f=0,h=0,m=0,g=0,v=s.width(),y=s.height(),b=!1,x=it.rtl();o=r.resizeMinHeight||y/1.5,i=r.resizeMaxHeight||2.5*y,a=r.resizeMinWidth||v/1.25,c=r.resizeMaxWidth||1.25*v,l=function(n){"touchmove"===n.type&&(n=t.event);var l=g+(n.pageY-h),d=x?m-(n.pageX-f):m+(n.pageX-f);c>0&&d>c&&(d=c),i>0&&l>i&&(l=i),(!r.resizeWidth||a>d||c>0&&d>c)&&(d=!1),(!r.resizeHeight||o>l||i>0&&l>i)&&(l=!1),(d||l)&&(it.dimensions(d,l),7>e.sceditor.ie&&s.height(l)),n.preventDefault()},d=function(t){b&&(b=!1,p.hide(),s.removeClass("resizing").height("auto"),e(n).unbind("touchmove mousemove",l),e(n).unbind("touchend mouseup",d),t.preventDefault())},s.append(u),s.append(p.hide()),u.bind("touchstart mousedown",function(o){"touchstart"===o.type&&(o=t.event),f=o.pageX,h=o.pageY,m=s.width(),g=s.height(),b=!0,s.addClass("resizing"),p.show(),e(n).bind("touchmove mousemove",l),e(n).bind("touchend mouseup",d),7>e.sceditor.ie&&s.height(g),o.preventDefault()})},A=function(){var t,o=r.emoticons,i=r.emoticonsRoot;e.isPlainObject(o)&&r.emoticonsEnabled&&e.each(o,function(r,s){e.each(s,function(e,s){i&&(s={url:i+(s.url||s),tooltip:s.tooltip||e},o[r][e]=s),t=n.createElement("img"),t.src=s.url||s,ct.push(t)})})},tt=function(){var t,n,o,i=u[0],a=d[0],c=!!r.autofocusEnd;if(s.is(":visible")){if(it.sourceMode())o=f.value.length,f.setSelectionRange?f.setSelectionRange(o,o):f.createTextRange&&(t=f.createTextRange(),t.moveEnd("character",o),t.moveStart("character",o),v.selectRange(t));else{if(e.sceditor.dom.removeWhiteSpace(a),c)for((n=a.lastChild)||d.append(n=i.createElement("div"));n.lastChild;)n=n.lastChild,/br/i.test(n.nodeName)&&n.previousSibling&&(n=n.previousSibling);else n=a.firstChild;i.createRange?(t=i.createRange(),/br/i.test(n.nodeName)?t.setStartBefore(n):t.selectNodeContents(n),t.collapse(!1)):(t=a.createTextRange(),t.moveToElementText(3!==n.nodeType?n:n.parentNode),t.collapse(!1)),v.selectRange(t),c&&(u.scrollTop(a.scrollHeight),d.scrollTop(a.scrollHeight))}it.focus()}},it.readOnly=function(e){return"boolean"!=typeof e?"readonly"===p.attr("readonly"):(d[0].contentEditable=!e,e?p.attr("readonly","readonly"):p.removeAttr("readonly"),X(e),this)},it.rtl=function(e){var t=e?"rtl":"ltr";return"boolean"!=typeof e?"rtl"===p.attr("dir"):(d.attr("dir",t),p.attr("dir",t),s.removeClass("rtl").removeClass("ltr").addClass(t),this)},X=function(t){var n=it.inSourceMode();a.find(".sceditor-button").removeClass("disabled").each(function(){var o=e(this);t===!0||n&&!o.data("sceditor-txtmode")?o.addClass("disabled"):n||o.data("sceditor-wysiwygmode")||o.addClass("disabled")})},it.width=function(e,t){return e||0===e?(it.dimensions(e,null,t),this):s.width()},it.dimensions=function(t,o,i){var l=8>e.sceditor.ie||8>n.documentMode?2:0;return t=t||0===t?t:!1,o=o||0===o?o:!1,t===!1&&o===!1?{width:it.width(),height:it.height()}:(c.data("outerWidthOffset")===void 0&&it.updateStyleCache(),t!==!1&&(i!==!1&&(r.width=t),o===!1&&(o=s.height(),i=!1),s.width(t),t&&(""+t).indexOf("%")>-1&&(t=s.width()),c.width(t-c.data("outerWidthOffset")),p.width(t-p.data("outerWidthOffset")),e.sceditor.ios&&d&&d.width(t-c.data("outerWidthOffset")-(d.outerWidth(!0)-d.width()))),o!==!1&&(i!==!1&&(r.height=o),o&&(""+o).indexOf("%")>-1&&(o=s.height(o).height(),s.height("auto")),o-=r.toolbarContainer?0:a.outerHeight(!0),c.height(o-c.data("outerHeightOffset")),p.height(o-l-p.data("outerHeightOffset"))),this)},it.updateStyleCache=function(){c.data("outerWidthOffset",c.outerWidth(!0)-c.width()),p.data("outerWidthOffset",p.outerWidth(!0)-p.width()),c.data("outerHeightOffset",c.outerHeight(!0)-c.height()),p.data("outerHeightOffset",p.outerHeight(!0)-p.height())},it.height=function(e,t){return e||0===e?(it.dimensions(null,e,t),this):s.height()},it.maximize=function(t){return t===void 0?s.is(".sceditor-maximize"):(t=!!t,7>e.sceditor.ie&&e("html, body").toggleClass("sceditor-maximize",t),s.toggleClass("sceditor-maximize",t),it.width(t?"100%":r.width,!1),it.height(t?"100%":r.height,!1),this)},it.expandToContent=function(e){var t=s.height(),n=d[0].scrollHeight||u[0].documentElement.scrollHeight,o=t-c.height(),i=r.resizeMaxHeight||2*(r.height||st.height());n+=o,e!==!0&&n>i&&(n=i),n>t&&it.height(n)},it.destroy=function(){b.destroy(),v=null,m=null,b=null,e(n).unbind("click",Y),e(t).unbind("resize orientationChanged",K),e(rt.form).unbind("reset",q).unbind("submit",it.updateOriginal),d.unbind(),u.unbind().find("*").remove(),p.unbind().remove(),a.remove(),s.unbind().find("*").unbind().remove(),s.remove(),st.removeData("sceditor").removeData("sceditorbbcode").show(),k&&st.attr("required","required")},it.createDropDown=function(t,n,o,i){var s,a=h&&h.is(".sceditor-"+n);it.closeDropDown(),a||(i!==!1&&e(o).find(":not(input,textarea)").filter(function(){return 1===this.nodeType}).attr("unselectable","on"),s={top:t.offset().top,left:t.offset().left,marginTop:t.outerHeight()},e.extend(s,r.dropDownCss),h=e('<div class="sceditor-dropdown sceditor-'+n+'" />').css(s).append(o).appendTo(e("body")).click(function(e){e.stopPropagation()}))},Y=function(e){3!==e.which&&it.closeDropDown()},F=function(e){var t,o,i=d[0],s=u[0],a=0,c=n.createElement("div"),l=s.createDocumentFragment();if(r.disablePasting)return!1;if(r.enablePasteFiltering){if(v.saveRange(),n.body.appendChild(c),e&&e.clipboardData&&e.clipboardData.getData&&((t=e.clipboardData.getData("text/html"))||(t=e.clipboardData.getData("text/plain"))))return c.innerHTML=t,B(i,c),!1;for(;i.firstChild;)l.appendChild(i.firstChild);return o=function(e,t){if(e.childNodes.length>0){for(;e.firstChild;)t.appendChild(e.firstChild);for(;l.firstChild;)e.appendChild(l.firstChild);B(e,t)}else{if(a>25){for(;l.firstChild;)e.appendChild(l.firstChild);return v.restoreRange(),void 0}++a,setTimeout(function(){o(e,t)},20)}},o(i,c),it.focus(),!0}},B=function(t,n){e.sceditor.dom.fixNesting(n);var o=n.innerHTML;b.hasHandler("toSource")&&(o=b.callOnlyFirst("toSource",o,e(n))),n.parentNode.removeChild(n),b.hasHandler("toWysiwyg")&&(o=b.callOnlyFirst("toWysiwyg",o,!0)),v.restoreRange(),v.insertHTML(D(o))},it.closeDropDown=function(e){h&&(h.unbind().remove(),h=null),e===!0&&it.focus()},L=function(){return l.contentDocument?l.contentDocument:l.contentWindow&&l.contentWindow.document?l.contentWindow.document:l.document?l.document:null},it.wysiwygEditorInsertHtml=function(t,n,o){it.focus(),(o||!e(v.parentNode()).is("code")&&0===e(v.parentNode()).parents("code").length)&&(v.insertHTML(t,n),J())},it.wysiwygEditorInsertText=function(t,n){it.wysiwygEditorInsertHtml(e.sceditor.escapeEntities(t),e.sceditor.escapeEntities(n))},it.insertText=function(e,t){return it.inSourceMode()?it.sourceEditorInsertText(e,t):it.wysiwygEditorInsertText(e,t),this},it.sourceEditorInsertText=function(e,t){var o,i,r,s,a;a=f.scrollTop,f.focus(),f.selectionStart!==void 0?(i=f.selectionStart,r=f.selectionEnd,s=e.length,t&&(e+=f.value.substring(i,r)+t),f.value=f.value.substring(0,i)+e+f.value.substring(r,f.value.length),f.selectionStart=i+e.length-(t?t.length:0),f.selectionEnd=f.selectionStart):n.selection.createRange!==void 0?(o=n.selection.createRange(),t&&(e+=o.text+t),o.text=e,t&&o.moveEnd("character",0-t.length),o.moveStart("character",o.End-o.Start),o.select()):f.value+=e+t,f.scrollTop=a,f.focus()},it.getRangeHelper=function(){return v},it.val=function(e,t){return"string"==typeof e?(it.inSourceMode()?it.setSourceEditorValue(e):(t!==!1&&b.hasHandler("toWysiwyg")&&(e=b.callOnlyFirst("toWysiwyg",e)),it.setWysiwygEditorValue(e)),this):it.inSourceMode()?it.getSourceEditorValue(!1):it.getWysiwygEditorValue()},it.insert=function(t,n,o,i,r){if(it.inSourceMode())it.sourceEditorInsertText(t,n);else{if(n){var s=it.getRangeHelper().selectedHtml(),a=e("<div>").appendTo(e("body")).hide().html(s);o!==!1&&b.hasHandler("toSource")&&(s=b.callOnlyFirst("toSource",s,a)),a.remove(),t+=s+n}o!==!1&&b.hasHandler("toWysiwyg")&&(t=b.callOnlyFirst("toWysiwyg",t,!0)),o!==!1&&r===!0&&(t=t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")),i!==!1&&(t=D(t)),it.wysiwygEditorInsertHtml(t)}return this},it.getWysiwygEditorValue=function(t){var n,o,i=v.hasSelection();return i?v.saveRange():m&&m.getBookmark&&(o=m.getBookmark()),e.sceditor.dom.fixNesting(d[0]),n=d.html(),t!==!1&&b.hasHandler("toSource")&&(n=b.callOnlyFirst("toSource",n,d)),i?(v.restoreRange(),m=null):o&&(m.moveToBookmark(o),m=null),n},it.getBody=function(){return d},it.getContentAreaContainer=function(){return c},it.getSourceEditorValue=function(e){var t=p.val();return e!==!1&&b.hasHandler("toWysiwyg")&&(t=b.callOnlyFirst("toWysiwyg",t)),t},it.setWysiwygEditorValue=function(t){t||(t="<p>"+(e.sceditor.ie?"":"<br />")+"</p>"),d[0].innerHTML=D(t),J()},it.setSourceEditorValue=function(e){p.val(e)},it.updateOriginal=function(){st.val(it.val())},D=function(t){if(!r.emoticonsEnabled)return t;var n=e.extend({},r.emoticons.more,r.emoticons.dropdown,r.emoticons.hidden);return e.each(n,function(n,o){var s=e.sceditor.regexEscape(e.sceditor.escapeEntities(n))+"(?=([^\\<\\>]*?<(?!/code)|[^\\<\\>]*?$))",a="";r.emoticonsCompat&&(s="((>|^|\\s| | | | |&nbsp;))"+s+"(?=(\\s|$|<| | | | |&nbsp;))",a="$1"),t=t.replace(RegExp(s,"gm"),a+i("emoticon",{key:n,url:o.url||o,tooltip:o.tooltip||n}))}),r.emoticonsCompat&&(pt=d.find("img[data-sceditor-emoticon]")),t},it.inSourceMode=function(){return s.hasClass("sourceMode")},it.sourceMode=function(e){return"boolean"!=typeof e?it.inSourceMode():((it.inSourceMode()&&!e||!it.inSourceMode()&&e)&&it.toggleSourceMode(),this)},it.toggleSourceMode=function(){(e.sceditor.isWysiwygSupported||!it.inSourceMode())&&(it.blur(),it.inSourceMode()?it.setWysiwygEditorValue(it.getSourceEditorValue()):it.setSourceEditorValue(it.getWysiwygEditorValue()),m=null,p.toggle(),c.toggle(),it.inSourceMode()?s.removeClass("sourceMode").addClass("wysiwygMode"):s.removeClass("wysiwygMode").addClass("sourceMode"),X(),Q())},G=function(){return f.focus(),null!=f.selectionStart?f.value.substring(f.selectionStart,f.selectionEnd):n.selection.createRange?n.selection.createRange().text:void 0},M=function(t,n){return it.inSourceMode()?(n.txtExec&&(e.isArray(n.txtExec)?it.sourceEditorInsertText.apply(it,n.txtExec):n.txtExec.call(it,t,G())),void 0):(n.exec&&(e.isFunction(n.exec)?n.exec.call(it,t):it.execCommand(n.exec,n.hasOwnProperty("execParam")?n.execParam:null)),void 0)},H=function(){e.sceditor.ie&&(m=v.selectedRange())},it.execCommand=function(t,n){var o=!1,i=e(v.parentNode());if(it.focus(),!i.is("code")&&0===i.parents("code").length){try{o=u[0].execCommand(t,!1,n)}catch(r){}!o&&it.commands[t]&&it.commands[t].errorMessage&&alert(it._(it.commands[t].errorMessage))}},Z=function(){var t=function(){v&&!v.compare(C)&&(C=v.cloneSelected(),s.trigger(e.Event("selectionchanged"))),S=!1};S||(S=!0,e.sceditor.ie?t():setTimeout(t,100))},et=function(){var t,n=v.parentNode();x!==n&&(t=x,x=n,w=v.getFirstBlockParent(n),s.trigger(e.Event("nodechanged",{oldNode:t,newNode:x})))},it.currentNode=function(){return x},it.currentBlockNode=function(){return w},Q=function(e){var t,n,o,i,r,s=u[0],c=dt.length,l=it.sourceMode();if(it.sourceMode()||it.readOnly())a.find(".sceditor-button").removeClass("active");else for(r=e?e.newNode:v.parentNode(),o=v.getFirstBlockParent(r);c--;)if(t=0,n=dt[c],i=a.find(".sceditor-button-"+n.name),l&&!i.data("sceditor-txtmode"))i.addClass("disabled");else if(l||i.data("sceditor-wysiwygmode")){if("string"==typeof n.state)try{t=s.queryCommandEnabled(n.state)?0:-1,t>-1&&(t=s.queryCommandState(n.state)?1:0)}catch(d){}else t=n.state.call(it,r,o);0>t?i.addClass("disabled"):i.removeClass("disabled"),t>0?i.addClass("active"):i.removeClass("active")}else i.addClass("disabled")},j=function(t){var n,o=at.length;if(it.closeDropDown(),n=e(v.parentNode()),13===t.which&&(n.is("code,blockquote,pre")||0!==n.parents("code,blockquote,pre").length))return m=null,it.wysiwygEditorInsertHtml("<br />",null,!0),!1;if(!n.is("code")&&0===n.parents("code").length)for(;o--;)at[o].call(it,t,l,p)},J=function(){var t,n,o;e.sceditor.dom.rTraverse(d[0],function(i){return t=i.nodeName.toLowerCase(),e.inArray(t,lt)>-1&&(n=!0),3===i.nodeType&&!/^\s*$/.test(i.nodeValue)||"br"===t||e.sceditor.ie&&!i.firstChild&&!e.sceditor.dom.isInline(i,!1)?(n&&(o=d[0].ownerDocument.createElement("div"),o.className="sceditor-nlf",o.innerHTML=e.sceditor.ie?"":"<br />",d[0].appendChild(o)),!1):void 0})},q=function(){it.val(st.val())},$=function(){it.closeDropDown(),m=null},K=function(){var e=r.height,t=r.width;it.maximize()?it.dimensions("100%","100%",!1):(e&&(""+e).indexOf("%")>-1&&it.height(e),t&&(""+t).indexOf("%")>-1&&it.width(t))},it._=function(){var e=arguments;return g&&g[e[0]]&&(e[0]=g[e[0]]),e[0].replace(/\{(\d+)\}/g,function(t,n){return e[n-0+1]!==void 0?e[n-0+1]:"{"+n+"}"})},U=function(t){var n,o=e.extend({},t);b.call(o.type+"Event",t,it),delete o.type,n=e.Event((t.target===f?"scesrc":"scewys")+t.type,o),s.trigger.apply(s,[n,it]),n.isDefaultPrevented()&&t.preventDefault(),n.isImmediatePropagationStopped()&&n.stopImmediatePropagation(),n.isPropagationStopped()&&n.stopPropagation()},it.bind=function(t,n,o,i){var r=t.length;for(t=t.split(" ");r--;)e.isFunction(n)&&(o||s.bind("scewys"+t[r],n),i||s.bind("scesrc"+t[r],n));return this},it.unbind=function(t,n,o,i){var r=t.length;for(t=t.split(" ");r--;)e.isFunction(n)&&(o||s.unbind("scewys"+t[r],n),i||s.unbind("scesrc"+t[r],n));return this},it.blur=function(t,n,o){return e.isFunction(t)?it.bind("blur",t,n,o):it.sourceMode()?p.blur():(y||(y=e('<input style="position:absolute;width:0;height:0;opacity:0;border:0;padding:0;filter:alpha(opacity=0)" type="text" />').appendTo(s)),y.removeAttr("disabled").show().focus().blur().hide().attr("disabled","disabled")),this},it.focus=function(t,n,o){return e.isFunction(t)?it.bind("focus",t,n,o):it.inSourceMode()?f.focus():(l.contentWindow.focus(),d[0].focus(),m&&(v.selectRange(m),m=null)),this},it.keyDown=function(e,t,n){return it.bind("keydown",e,t,n)},it.keyPress=function(e,t,n){return it.bind("keypress",e,t,n)},it.keyUp=function(e,t,n){return it.bind("keyup",e,t,n)},it.nodeChanged=function(e){return it.bind("nodechanged",e,!1,!0)},it.selectionChanged=function(e){return it.bind("selectionchanged",e,!1,!0)},nt=function(t){var n=0,o=String.fromCharCode(t.which);return it.emoticonsCache||(it.emoticonsCache=[],e.each(e.extend({},r.emoticons.more,r.emoticons.dropdown,r.emoticons.hidden),function(e,t){it.emoticonsCache[n++]=[e,i("emoticon",{key:e,url:t.url||t,tooltip:t.tooltip||e})]}),it.emoticonsCache.sort(function(e,t){return e[0].length-t[0].length}),it.longestEmoticonCode=it.emoticonsCache[it.emoticonsCache.length-1][0].length),it.getRangeHelper().raplaceKeyword(it.emoticonsCache,!0,!0,it.longestEmoticonCode,r.emoticonsCompat,o)?(r.emoticonsCompat&&(pt=d.find("img[data-sceditor-emoticon]")),/^\s$/.test(o)&&r.emoticonsCompat):void 0},ot=function(){if(pt.length){var t,n,o,i,r,s,a=it.currentBlockNode(),c=!1,l=/[^\s\xA0\u2002\u2003\u2009]+/;pt=e.map(pt,function(d){return d&&d.parentNode?e.contains(a,d)?(t=d.previousSibling,n=d.nextSibling,r=t.nodeValue,null===r&&(r=t.innerText||""),t&&l.test(t.nodeValue.slice(-1))||n&&l.test((n.nodeValue||"")[0])?(o=d.parentNode,i=v.cloneSelected(),s=i.startContainer,r+=e(d).data("sceditor-emoticon"),s===n?c=r.length+i.startOffset:s===a&&a.childNodes[i.startOffset]===n?c=r.length:s===t&&(c=i.startOffset),n&&3===n.nodeType||(n=o.insertBefore(o.ownerDocument.createTextNode(""),n)),n.insertData(0,r),o.removeChild(t),o.removeChild(d),c!==!1&&(i.setStart(n,c),i.collapse(!0),v.selectRange(i)),null):d):d:null})}},it.emoticons=function(t){return t||t===!1?(r.emoticonsEnabled=t,t?(d.keypress(nt),it.sourceMode()||(v.saveRange(),d.html(D(d.html())),pt=d.find("img[data-sceditor-emoticon]"),v.restoreRange())):(d.find("img[data-sceditor-emoticon]").replaceWith(function(){return e(this).data("sceditor-emoticon")}),pt=[],d.unbind("keypress",nt)),this):r.emoticonsEnabled},it.css=function(t){return E||(E=e('<style id="#inline" />').appendTo(u.find("head"))[0]),"string"!=typeof t?E.styleSheet?E.styleSheet.cssText:E.innerHTML:(E.styleSheet?E.styleSheet.cssText=t:E.innerHTML=t,this)},V=function(e){var t=[],n={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|","[":"{","]":"}"},o={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:"'"},i={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,s=o[r]||String.fromCharCode(r).toLowerCase();return e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&(t.push("shift"),i[r]?s=i[r]:n[s]&&(s=n[s])),s&&(16>r||r>18)&&t.push(s),t=t.join("+"),ut[t]?ut[t].call(it):void 0},it.addShortcut=function(e,t){return e=e.toLowerCase(),ut[e]="string"==typeof t?function(){return M(a.find(".sceditor-button-"+t),it.commands[t]),!1}:t,this},it.removeShortcut=function(e){return delete ut[e.toLowerCase()],this},T()},e.sceditor.ie=function(){var e,o=3,i=n.createElement("div"),r=i.getElementsByTagName("i");do i.innerHTML="<!--[if gt IE "+ ++o+"]><i></i><![endif]-->";while(r[0]);return n.all&&t.atob&&(o=10),o>4?o:e}(),e.sceditor.ios=/iPhone|iPod|iPad| wosbrowser\//i.test(navigator.userAgent),e.sceditor.isWysiwygSupported=function(){var t,n,o=e('<div contenteditable="true">')[0].contentEditable,i=o!==void 0&&"inherit"!==o,r=navigator.userAgent;return i?(n=/Opera Mobi|Opera Mini/i.test(r),/Android/i.test(r)&&(n=!0,/Safari/.test(r)&&(t=/Safari\/(\d+)/.exec(r),n=t&&t[1]?534>t[1]:!0)),/ Silk\//i.test(r)&&(t=/AppleWebKit\/(\d+)/.exec(r),n=t&&t[1]?534>t[1]:!0),e.sceditor.ios&&(n=!/OS [5-9](_\d)+ like Mac OS X/i.test(r)),/fennec/i.test(r)&&(n=!1),!n):!1}(),e.sceditor.regexEscape=function(e){return e.replace(/[\$\?\[\]\.\*\(\)\|\\]/g,"\\$&")},e.sceditor.escapeEntities=function(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ {2}/g," &nbsp;").replace(/\r\n|\r/g,"\n").replace(/\n/g,"<br />"):e},e.sceditor.locale={},e.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(t,n,o){for(var r=t.opts.fonts.split(","),s=e("<div />"),a=function(){return o(e(this).data("font")),t.closeDropDown(!0),!1},c=0;r.length>c;c++)s.append(i("fontOpt",{font:r[c]},!0).click(a));t.createDropDown(n,"font-picker",s)},exec:function(t){var n=this;e.sceditor.command.get("font")._dropDown(n,t,function(e){n.execCommand("fontname",e)})},tooltip:"Font Name"},size:{_dropDown:function(t,n,o){for(var r=e("<div />"),s=function(n){o(e(this).data("size")),t.closeDropDown(!0),n.preventDefault()},a=1;7>=a;a++)r.append(i("sizeOpt",{size:a},!0).click(s));t.createDropDown(n,"fontsize-picker",r)},exec:function(t){var n=this;e.sceditor.command.get("size")._dropDown(n,t,function(e){n.execCommand("fontsize",e)})},tooltip:"Font Size"},color:{_dropDown:function(t,n,o){var i,r,s,a,c={r:255,g:255,b:255},l=e("<div />"),d=t.opts.colors?t.opts.colors.split("|"):Array(21),u=[],p=e.sceditor.command.get("color");if(!p._htmlCache){for(i=0;d.length>i;++i){for(a=d[i]?d[i].split(","):Array(21),u.push('<div class="sceditor-color-column">'),r=0;a.length>r;++r)s=a[r]||"#"+c.r.toString(16)+c.g.toString(16)+c.b.toString(16),u.push('<a href="#" class="sceditor-color-option" style="background-color: '+s+'" data-color="'+s+'"></a>'),0===r%5?(c.g-=51,c.b=255):c.b-=51;u.push("</div>"),0===i%5?(c.r-=51,c.g=255,c.b=255):(c.g=255,c.b=255)}p._htmlCache=u.join("")}l.append(p._htmlCache).find("a").click(function(n){o(e(this).attr("data-color")),t.closeDropDown(!0),n.preventDefault()}),t.createDropDown(n,"color-picker",l)},exec:function(t){var n=this;e.sceditor.command.get("color")._dropDown(n,t,function(e){n.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=this,o=i("pastetext",{label:n._("Paste your text inside the following box:"),insert:n._("Insert")},!0);o.find(".button").click(function(e){t=o.find("#txt").val(),t&&n.wysiwygEditorInsertText(t),n.closeDropDown(!0),e.preventDefault()}),n.createDropDown(e,"pastetext",o)},tooltip:"Paste Text"},bulletlist:{exec:"insertunorderedlist",tooltip:"Bullet list"},orderedlist:{exec:"insertorderedlist",tooltip:"Numbered list"},table:{exec:function(t){var n=this,o=i("table",{rows:n._("Rows:"),cols:n._("Cols:"),insert:n._("Insert")},!0);o.find(".button").click(function(t){var i=o.find("#rows").val()-0,r=o.find("#cols").val()-0,s="<table>";if(!(1>i||1>r)){for(var a=0;i>a;a++){s+="<tr>";for(var c=0;r>c;c++)s+="<td>"+(e.sceditor.ie?"":"<br />")+"</td>";s+="</tr>"}s+="</table>",n.wysiwygEditorInsertHtml(s),n.closeDropDown(!0),t.preventDefault()}}),n.createDropDown(t,"inserttable",o)},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(e){var t=this,n=i("image",{url:t._("URL:"),width:t._("Width (optional):"),height:t._("Height (optional):"),insert:t._("Insert")},!0);n.find(".button").click(function(e){var o=n.find("#image").val(),i=n.find("#width").val(),r=n.find("#height").val(),s="";i&&(s+=' width="'+i+'"'),r&&(s+=' height="'+r+'"'),o&&"http://"!==o&&t.wysiwygEditorInsertHtml("<img"+s+' src="'+o+'" />'),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertimage",n)},tooltip:"Insert an image"},email:{exec:function(e){var t=this,n=i("email",{label:t._("E-mail:"),insert:t._("Insert")},!0);n.find(".button").click(function(e){var o=n.find("#email").val();o&&(t.focus(),t.getRangeHelper().selectedHtml()?t.execCommand("createlink","mailto:"+o):t.wysiwygEditorInsertHtml('<a href="mailto:'+o+'">'+o+"</a>")),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertemail",n)},tooltip:"Insert an email"},link:{exec:function(e){var t=this,n=i("link",{url:t._("URL:"),desc:t._("Description (optional):"),ins:t._("Insert")},!0);n.find(".button").click(function(e){var o=n.find("#link").val(),i=n.find("#des").val();o&&"http://"!==o&&(t.focus(),!t.getRangeHelper().selectedHtml()||i?(i||(i=o),t.wysiwygEditorInsertHtml('<a href="'+o+'">'+i+"</a>")):t.execCommand("createlink",o)),t.closeDropDown(!0),e.preventDefault()}),t.createDropDown(e,"insertlink",n)},tooltip:"Insert a link"},unlink:{state:function(){var t=e(this.currentNode());return t.is("a")||t.parents("a").length>0?0:-1},exec:function(){var t=e(this.currentNode()),n=t.is("a")?t:t.parents("a").first();n.length&&n.replaceWith(n.contents())},tooltip:"Unlink"},quote:{forceNewLineAfter:["blockquote"],exec:function(t,n,o){var i="<blockquote>",r="</blockquote>";n?(o=o?"<cite>"+o+"</cite>":"",i=i+o+n+r,r=null):""===this.getRangeHelper().selectedHtml()&&(r=e.sceditor.ie?"":"<br />"+r),this.wysiwygEditorInsertHtml(i,r)},tooltip:"Insert a Quote"},emoticon:{exec:function(t){var n=this,o=function(i){var r=n.opts.emoticonsCompat,s=n.getRangeHelper(),a=r&&" "!==s.getOuterText(!0,1)?" ":"",c=r&&" "!==s.getOuterText(!1,1)?" ":"",l=e("<div />"),d=e("<div />").appendTo(l),u=e.extend({},n.opts.emoticons.dropdown,i?n.opts.emoticons.more:{}),p=0;return e.each(u,function(){p++}),p=Math.sqrt(p),e.each(u,function(t,o){d.append(e("<img />").attr({src:o.url||o,alt:t,title:o.tooltip||t}).click(function(){return n.insert(a+e(this).attr("alt")+c,null,!1).closeDropDown(!0),!1})),d.children().length>=p&&(d=e("<div />").appendTo(l))}),i||l.append(e(n._('<a class="sceditor-more">{0}</a>',n._("More"))).click(function(){return n.createDropDown(t,"more-emoticons",o(!0)),!1})),l};n.createDropDown(t,"emoticons",o(!1))},txtExec:function(t){e.sceditor.command.get("emoticon").exec.call(this,t)},tooltip:"Insert an emoticon"},youtube:{_dropDown:function(e,t,n){var o,r=i("youtubeMenu",{label:e._("Video URL:"),insert:e._("Insert")},!0);r.find(".button").click(function(t){var i=r.find("#link").val().replace("http://","");""!==i&&(o=i.match(/(?:v=|v\/|embed\/|youtu.be\/)(.{11})/),o&&(i=o[1]),/^[a-zA-Z0-9_\-]{11}$/.test(i)?n(i):alert("Invalid YouTube video")),e.closeDropDown(!0),t.preventDefault()}),e.createDropDown(t,"insertlink",r)},exec:function(t){var n=this;e.sceditor.command.get("youtube")._dropDown(n,t,function(e){n.wysiwygEditorInsertHtml(i("youtube",{id:e}))
-})},tooltip:"Insert a YouTube video"},date:{_date:function(e){var t=new Date,n=t.getYear(),o=t.getMonth()+1,i=t.getDate();return 2e3>n&&(n=1900+n),10>o&&(o="0"+o),10>i&&(i="0"+i),e.opts.dateFormat.replace(/year/i,n).replace(/month/i,o).replace(/day/i,i)},exec:function(){this.insertText(e.sceditor.command.get("date")._date(this))},txtExec:function(){this.insertText(e.sceditor.command.get("date")._date(this))},tooltip:"Insert current date"},time:{_time:function(){var e=new Date,t=e.getHours(),n=e.getMinutes(),o=e.getSeconds();return 10>t&&(t="0"+t),10>n&&(n="0"+n),10>o&&(o="0"+o),t+":"+n+":"+o},exec:function(){this.insertText(e.sceditor.command.get("time")._time())},txtExec:function(){this.insertText(e.sceditor.command.get("time")._time())},tooltip:"Insert current time"},ltr:{state:function(e,t){return t&&"ltr"===t.style.direction},exec:function(){var t=this,n=t.getRangeHelper().getFirstBlockParent(),o=e(n);t.focus(),(n&&!o.is("body")||(t.execCommand("formatBlock","p"),n=t.getRangeHelper().getFirstBlockParent(),o=e(n),n&&!o.is("body")))&&("ltr"===o.css("direction")?o.css("direction",""):o.css("direction","ltr"))},tooltip:"Left-to-Right"},rtl:{state:function(e,t){return t&&"rtl"===t.style.direction},exec:function(){var t=this,n=t.getRangeHelper().getFirstBlockParent(),o=e(n);t.focus(),(n&&!o.is("body")||(t.execCommand("formatBlock","p"),n=t.getRangeHelper().getFirstBlockParent(),o=e(n),n&&!o.is("body")))&&("rtl"===o.css("direction")?o.css("direction",""):o.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:{}},e.sceditor.rangeHelper=function(t,n){var o,i,r,s,a,c=!0,l="sceditor-start-marker",d="sceditor-end-marker",u="character",p=this;r=function(e,t){i=t||e.contentDocument||e.document,o=e,c=!!e.getSelection}(t,n),p.insertHTML=function(e,t){var n,o,r=p.selectedRange();if(t&&(e+=p.selectedHtml()+t),c){for(o=i.createElement("div"),n=i.createDocumentFragment(),o.innerHTML=e;o.firstChild;)n.appendChild(o.firstChild);p.insertNode(n)}else{if(!r)return!1;r.pasteHTML(e)}},p.insertNode=function(e,t){if(c){var n,o,r=i.createDocumentFragment(),s=p.selectedRange();if(!s)return!1;if(r.appendChild(e),t&&(r.appendChild(s.extractContents()),r.appendChild(t)),o=r.lastChild,!o)return;s.deleteContents(),s.insertNode(r),n=i.createRange(),n.setStartAfter(o),p.selectRange(n)}else p.insertHTML(e.outerHTML,t?t.outerHTML:null)},p.cloneSelected=function(){var e=p.selectedRange();return e?c?e.cloneRange():e.duplicate():void 0},p.selectedRange=function(){var e,t,n=c?o.getSelection():i.selection;if(n){if(n.getRangeAt&&0>=n.rangeCount){for(t=i.body;t.firstChild;)t=t.firstChild;e=i.createRange(),e.setStart(t,0),n.addRange(e)}return c&&(e=n.getRangeAt(0)),c||"Control"===n.type||(e=n.createRange()),a(e)?e:null}},a=function(e){var t;return e&&e.parentElement&&(t=e.parentElement())?t.ownerDocument===i:!0},p.hasSelection=function(){var e,t=c?o.getSelection():i.selection;return c||!t?t&&t.rangeCount>0:(e=t.createRange(),e&&a(e))},p.selectedHtml=function(){var e,t=p.selectedRange();return t?!c&&""!==t.text&&t.htmlText?t.htmlText:c?(e=i.createElement("div"),e.appendChild(t.cloneContents()),e.innerHTML):"":""},p.parentNode=function(){var e=p.selectedRange();return e?e.parentElement?e.parentElement():e.commonAncestorContainer:void 0},p.getFirstBlockParent=function(t){var n=function(t){return e.sceditor.dom.isInline(t)?(t=t?t.parentNode:null,t?n(t):null):t};return n(t||p.parentNode())},p.insertNodeAt=function(e,t){var n=p.selectedRange(),o=p.cloneSelected();return o?(o.collapse(e),o.insertNode?o.insertNode(t):o.pasteHTML(t.outerHTML),p.selectRange(n),void 0):!1},s=function(e){p.removeMarker(e);var t=i.createElement("span");return t.id=e,t.style.lineHeight="0",t.style.display="none",t.className="sceditor-selection sceditor-ignore",t.innerHTML=" ",t},p.insertMarkers=function(){p.insertNodeAt(!0,s(l)),p.insertNodeAt(!1,s(d))},p.getMarker=function(e){return i.getElementById(e)},p.removeMarker=function(e){var t=p.getMarker(e);t&&t.parentNode.removeChild(t)},p.removeMarkers=function(){p.removeMarker(l),p.removeMarker(d)},p.saveRange=function(){p.insertMarkers()},p.selectRange=function(e){c?(o.getSelection().removeAllRanges(),o.getSelection().addRange(e)):e.select()},p.restoreRange=function(){var e,t=p.selectedRange(),n=p.getMarker(l),o=p.getMarker(d);return n&&o&&t?(c?(t=i.createRange(),t.setStartBefore(n),t.setEndAfter(o),p.selectRange(t)):(t=i.body.createTextRange(),e=i.body.createTextRange(),e.moveToElementText(n),t.setEndPoint("StartToStart",e),t.moveStart(u,0),e.moveToElementText(o),t.setEndPoint("EndToStart",e),t.moveEnd(u,0),p.selectRange(t)),p.removeMarkers(),void 0):!1},p.selectOuterText=function(e,t){var n=p.cloneSelected();return n?(n.collapse(!1),c?(n.setStart(n.startContainer,n.startOffset-e),n.setEnd(n.endContainer,n.endOffset+t)):(n.moveStart(u,0-e),n.moveEnd(u,t)),p.selectRange(n),void 0):!1},p.getOuterText=function(e,t){var n="",o=p.cloneSelected();return o?(o.collapse(!1),e?c?(n=o.startContainer.textContent.substr(0,o.startOffset),n=n.substr(Math.max(0,n.length-t))):(o.moveStart(u,0-t),n=o.text):c?n=o.startContainer.textContent.substr(o.startOffset,t):(o.moveEnd(u,t),n=o.text),n):""},p.raplaceKeyword=function(t,n,o,i,r,s){o||t.sort(function(e,t){return e.length-t.length});var a,l,d,u,f,h,m,g=t.length,v=i||t[g-1][0].length;if(r){if(!c)return!1;++v}for(a=p.getOuterText(!0,v),l=a+(null!=s?s:""),n&&(l+=p.getOuterText(!1,v));g--;)if(m=t[g][0],f=RegExp("(?:[\\s    ])"+e.sceditor.regexEscape(m)+"(?=[\\s    ])"),h=a.length-1-m.length,r&&--h,h=Math.max(0,h),(d=r?l.substr(h).search(f):l.indexOf(m,h))>-1){if(r&&(d+=h+1),d>a.length||d+m.length+(r?1:0)<a.length)continue;return u=a.length-d,p.selectOuterText(u,m.length-u-(null!=s&&/^\S/.test(s)?1:0)),p.insertHTML(t[g][1]),!0}return!1},p.compare=function(e,t){return t||(t=p.selectedRange()),e&&t?c?0===e.compareBoundaryPoints(Range.END_TO_END,t)&&0===e.compareBoundaryPoints(Range.START_TO_START,t):a(e)&&a(t)&&0===e.compareEndPoints("EndToEnd",t)&&0===e.compareEndPoints("StartToStart",t):!e&&!t}},e.sceditor.dom={traverse:function(e,t,n,o,i){if(e)for(e=i?e.lastChild:e.firstChild;null!=e;){var r=i?e.previousSibling:e.nextSibling;if(!n&&t(e)===!1)return!1;if(!o&&this.traverse(e,t,n,o,i)===!1)return!1;if(n&&t(e)===!1)return!1;e=r}},rTraverse:function(e,t,n,o){this.traverse(e,t,n,o,!0)},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|",isInline:function(t,n){return t&&1===t.nodeType?(t=t.tagName.toLowerCase(),"code"===t?!n:0>e.sceditor.dom.blockLevelList.indexOf("|"+t+"|")):!0},copyCSS:function(e,t){t.style.cssText=e.style.cssText+t.style.cssText},fixNesting:function(e){var t=this,n=function(e){for(;t.isInline(e.parentNode,!0);)e=e.parentNode;return e};t.traverse(e,function(e){if(1===e.nodeType&&!t.isInline(e,!0)&&t.isInline(e.parentNode,!0)){var o=n(e),i=o.parentNode,r=t.extractContents(o,e),s=e;t.copyCSS(o,s),i.insertBefore(r,o),i.insertBefore(s,o)}})},findCommonAncestor:function(t,n){return e(t).parents().has(e(n)).first()},getSibling:function(t,n){var o;return t?(o=t[n?"previousSibling":"nextSibling"])?o:e.sceditor.dom.getSibling(t.parentNode,n):null},removeWhiteSpace:function(t,n){for(var o,i,r,s,a,c,l,d,u=e.sceditor.dom.getSibling,p=e.sceditor.dom.isInline,f=t.firstChild,h=/[\t ]+/g,m=/[\t\n\r ]+/g;f;){if(c=f.nextSibling,o=f.nodeValue,i=f.nodeType,1===i&&f.firstChild&&(a=e(f).css("whiteSpace"),/pre(?:\-wrap)?$/i.test(a)||e.sceditor.dom.removeWhiteSpace(f,/line$/i.test(a))),3===i&&o){for(r=u(f),s=u(f,!0),d=s,l=!1;e(d).hasClass("sceditor-ignore");)d=u(d,!0);if(p(f)&&d){for(;d.lastChild;)d=d.lastChild;l=3===d.nodeType?/[\t\n\r ]$/.test(d.nodeValue):!p(d)}p(f)&&s&&p(s)&&!l||(o=o.replace(/^[\t\n\r ]+/,"")),p(f)&&r&&p(r)||(o=o.replace(/[\t\n\r ]+$/,"")),o.length?f.nodeValue=o.replace(n?h:m," "):t.removeChild(f)}f=c}},extractContents:function(e,t){var n=this,o=n.findCommonAncestor(e,t),i=o?o[0]:null,r=!1,s=!1;return function a(o){var i=e.ownerDocument.createDocumentFragment();return n.traverse(o,function(n){if(s||n===t&&r)return s=!0,!1;n===e&&(r=!0);var o,c;r?jQuery.contains(n,t)&&1===n.nodeType?(o=a(n),c=n.cloneNode(!1),c.appendChild(o),i.appendChild(c)):i.appendChild(n):jQuery.contains(n,e)&&1===n.nodeType&&(o=a(n),c=n.cloneNode(!1),c.appendChild(o),i.appendChild(c))},!1),i}(i)}},e.sceditor.plugins={},e.sceditor.PluginManager=function(t){var n=this,o=[],i=t,r=function(e){return"signal"+e.charAt(0).toUpperCase()+e.slice(1)},s=function(e,t){e=[].slice.call(e);for(var n=o.length,s=r(e.shift());n--;)if(s in o[n]){if(t)return o[n][s].apply(i,e);o[n][s].apply(i,e)}};n.call=function(){s(arguments,!1)},n.callOnlyFirst=function(){return s(arguments,!0)},n.iter=function(e){return e=r(e),function(){var t=o.length;return{callNext:function(n){for(;t--;)if(o[t]&&e in o[t])return o[t].apply(i,n)},hasNext:function(){for(var n=t;n--;)if(o[n]&&e in o[n])return!0;return!1}}}()},n.hasHandler=function(e){var t=o.length;for(e=r(e);t--;)if(e in o[t])return!0;return!1},n.exsists=function(t){return t in e.sceditor.plugins?(t=e.sceditor.plugins[t],"function"==typeof t&&"object"==typeof t.prototype):!1},n.isRegistered=function(t){var i=o.length;if(!n.exsists(t))return!1;for(;i--;)if(o[i]instanceof e.sceditor.plugins[t])return!0;return!1},n.register=function(t){return n.exsists(t)?(t=new e.sceditor.plugins[t],o.push(t),"init"in t&&t.init.apply(i),!0):!1},n.deregister=function(t){var r,s=o.length,a=!1;if(!n.isRegistered(t))return!1;for(;s--;)o[s]instanceof e.sceditor.plugins[t]&&(r=o.splice(s,1)[0],a=!0,"destroy"in r&&r.destroy.apply(i));return a},n.destroy=function(){for(var e=o.length;e--;)"destroy"in o[e]&&o[e].destroy.apply(i);o=null,i=null}},e.sceditor.command={get:function(t){return e.sceditor.commands[t]||null},set:function(t,n){return t&&n?(n=e.extend(e.sceditor.commands[t]||{},n),n.remove=function(){e.sceditor.command.remove(t)},e.sceditor.commands[t]=n,this):!1},remove:function(t){return e.sceditor.commands[t]&&delete e.sceditor.commands[t],this}},e.sceditor.defaultOptions={toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,paste,pastetext|bulletlist,orderedlist|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:"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,runWithoutWysiwygSupport:!1,id:null,plugins:"",zIndex:null,bbcodeTrim:!1,parserOptions:{},dropDownCss:{}},e.fn.sceditor=function(t){var n,o=[];return t=t||{},t.runWithoutWysiwygSupport||e.sceditor.isWysiwygSupported?(this.each(function(){n=this.jquery?this:e(this),n.parents(".sceditor-container").length>0||("state"===t?o.push(!!n.data("sceditor")):"instance"===t?o.push(n.data("sceditor")):n.data("sceditor")||new e.sceditor(this,t))}),o.length?1===o.length?o[0]:e(o):this):void 0}})(jQuery,window,document);
+!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=this,hb=d.get?d.get(0):d,ib=a(hb),jb=[],kb=[],lb=[],mb=[],nb={},ob=[];gb.commands=a.extend(!0,{},f.commands||a.sceditor.commands),gb.opts=f=a.extend({},a.sceditor.defaultOptions,f),A=function(){ib.data("sceditor",gb),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(ib).css("z-index",f.zIndex),a.sceditor.ie&&g.addClass("ie ie"+a.sceditor.ie),y=!!ib.attr("required"),ib.removeAttr("required"),F(),M(),H(),E(),K(),I(),J(),a.sceditor.isWysiwygSupported||gb.toggleSourceMode();var d=function(){a(b).unbind("load",d),f.autofocus&&cb(),f.autoExpand&&gb.expandToContent(),X()};a(b).load(d),c.readyState&&"complete"===c.readyState&&d(),Z(),t.call("ready")},F=function(){var b=f.plugins;b=b?b.toString().split(","):[],t=new a.sceditor.PluginManager(gb),a.each(b,function(b,c){t.register(a.trim(c))})},G=function(){var b;a.sceditor.locale[f.locale]?q=a.sceditor.locale[f.locale]:(b=f.locale.split("-"),a.sceditor.locale[b[0]]&&(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],gb.width(f.width||ib.width()),gb.height(f.height||ib.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),gb.readOnly(!!f.readOnly),a.sceditor.ie&&l.find("html").addClass("ie ie"+a.sceditor.ie),(a.sceditor.ios||a.sceditor.ie)&&(k.height("100%"),a.sceditor.ie||k.bind("touchend",gb.focus)),r=new a.sceditor.rangeHelper(j.contentWindow),gb.val(ib.hide().val()),d=ib.attr("tabindex"),m.attr("tabindex",d),i.attr("tabindex",d)},I=function(){f.autoUpdate&&(k.bind("blur",gb.updateOriginal),m.bind("blur",gb.updateOriginal)),null===f.rtl&&(f.rtl="rtl"===m.css("direction")),gb.rtl(!!f.rtl),f.autoExpand&&l.bind("keyup",gb.expandToContent),f.resizeEnabled&&L(),g.attr("id",f.id),gb.emoticons(f.emoticonsEnabled)},J=function(){a(c).click(W),a(hb.form).bind("reset",T).submit(gb.updateOriginal),a(b).bind("resize orientationChanged",X),k.keypress(S).keydown(Q).keydown(R).keyup(_).bind("paste",O).bind(a.sceditor.ie?"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("keydown keyup keypress focus blur contextmenu",V).keydown(Q),l.keypress(S).mousedown(U).bind(a.sceditor.ie?"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",V).bind("nodechanged",V)},H=function(){var b,c,d=(f.toolbarExclude||"").split(","),i=f.toolbar.split("|");h=a('<div class="sceditor-toolbar" unselectable="on" />'),a.each(i,function(f,g){b=a('<div class="sceditor-group" />'),a.each(g.split(","),function(f,g){!gb.commands[g]||a.inArray(g,d)>-1||(c=e("toolbarButton",{name:g,dispName:gb._(gb.commands[g].tooltip||g)},!0),c.data("sceditor-txtmode",!!gb.commands[g].txtExec),c.data("sceditor-wysiwygmode",!!gb.commands[g].exec),c.click(function(){var b=a(this);return b.hasClass("disabled")||C(b,gb.commands[g]),Z(),!1}),gb.commands[g].tooltip&&c.attr("title",gb._(gb.commands[g].tooltip)),gb.commands[g].exec||c.addClass("disabled"),gb.commands[g].shortcut&&gb.addShortcut(gb.commands[g].shortcut,g),b.append(c))}),b[0].firstChild&&h.append(b)}),a(f.toolbarContainer||g).append(h)},K=function(){a.each(gb.commands,function(b,c){c.keyPress&&jb.push(c.keyPress),c.forceNewLineAfter&&a.isArray(c.forceNewLineAfter)&&(lb=a.merge(lb,c.forceNewLineAfter)),c.state?mb.push({name:b,state:c.state}):"string"==typeof c.exec&&mb.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=gb.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(c){"touchmove"===c.type&&(c=b.event);var j=q+(c.pageY-o),k=u?p-(c.pageX-n):p+(c.pageX-n);i>0&&k>i&&(k=i),e>0&&j>e&&(j=e),(!f.resizeWidth||h>k||i>0&&k>i)&&(k=!1),(!f.resizeHeight||d>j||e>0&&j>e)&&(j=!1),(k||j)&&(gb.dimensions(k,j),a.sceditor.ie<7&&g.height(j)),c.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),a.sceditor.ie<7&&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,kb.push(b)})})},cb=function(){var b,c,d,e=l[0],h=k[0],i=!!f.autofocusEnd;if(g.is(":visible")){if(gb.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))}gb.focus()}},gb.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)},gb.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=gb.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")})},gb.width=function(a,b){return a||0===a?(gb.dimensions(a,null,b),this):g.width()},gb.dimensions=function(b,d,e){var j=a.sceditor.ie<8||c.documentMode<8?2:0;return b=b||0===b?b:!1,d=d||0===d?d:!1,b===!1&&d===!1?{width:gb.width(),height:gb.height()}:("undefined"==typeof i.data("outerWidthOffset")&&gb.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)},gb.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())},gb.height=function(a,b){return a||0===a?(gb.dimensions(null,a,b),this):g.height()},gb.maximize=function(b){return"undefined"==typeof b?g.is(".sceditor-maximize"):(b=!!b,a.sceditor.ie<7&&a("html, body").toggleClass("sceditor-maximize",b),g.toggleClass("sceditor-maximize",b),gb.width(b?"100%":f.width,!1),gb.height(b?"100%":f.height,!1),this)},gb.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||ib.height());c+=d,a!==!0&&c>e&&(c=e),c>b&&gb.height(c)},gb.destroy=function(){t.destroy(),r=null,p=null,t=null,a(c).unbind("click",W),a(b).unbind("resize orientationChanged",X),a(hb.form).unbind("reset",T).unbind("submit",gb.updateOriginal),k.unbind(),l.unbind().find("*").remove(),m.unbind().remove(),h.remove(),g.unbind().find("*").unbind().remove(),g.remove(),ib.removeData("sceditor").removeData("sceditorbbcode").show(),y&&ib.attr("required","required")},gb.createDropDown=function(b,c,d,e){var g,h=o&&o.is(".sceditor-"+c);gb.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")).click(function(a){a.stopPropagation()}))},W=function(a){3!==a.which&&gb.closeDropDown()},O=function(a){var b,d,e=k[0],g=l[0],h=0,i=c.createElement("div"),j=g.createDocumentFragment();if(f.disablePasting)return!1;if(f.enablePasteFiltering){if(r.saveRange(),c.body.appendChild(i),a&&a.clipboardData&&a.clipboardData.getData&&((b=a.clipboardData.getData("text/html"))||(b=a.clipboardData.getData("text/plain"))))return i.innerHTML=b,P(e,i),!1;for(;e.firstChild;)j.appendChild(e.firstChild);return d=function(a,b){if(a.childNodes.length>0){for(;a.firstChild;)b.appendChild(a.firstChild);for(;j.firstChild;)a.appendChild(j.firstChild);P(a,b)}else{if(h>25){for(;j.firstChild;)a.appendChild(j.firstChild);return r.restoreRange(),void 0}++h,setTimeout(function(){d(a,b)},20)}},d(e,i),gb.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(),r.insertHTML(B(d))},gb.closeDropDown=function(a){o&&(o.unbind().remove(),o=null),a===!0&&gb.focus()},N=function(){return j.contentDocument?j.contentDocument:j.contentWindow&&j.contentWindow.document?j.contentWindow.document:j.document?j.document:null},gb.wysiwygEditorInsertHtml=function(b,c,d){gb.focus(),(d||!a(r.parentNode()).is("code")&&0===a(r.parentNode()).parents("code").length)&&(r.insertHTML(b,c),_())},gb.wysiwygEditorInsertText=function(b,c){gb.wysiwygEditorInsertHtml(a.sceditor.escapeEntities(b),a.sceditor.escapeEntities(c))},gb.insertText=function(a,b){return gb.inSourceMode()?gb.sourceEditorInsertText(a,b):gb.wysiwygEditorInsertText(a,b),this},gb.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.getRangeHelper=function(){return r},gb.val=function(a,b){return"string"==typeof a?(gb.inSourceMode()?gb.setSourceEditorValue(a):(b!==!1&&t.hasHandler("toWysiwyg")&&(a=t.callOnlyFirst("toWysiwyg",a)),gb.setWysiwygEditorValue(a)),this):gb.inSourceMode()?gb.getSourceEditorValue(!1):gb.getWysiwygEditorValue()},gb.insert=function(b,c,d,e,f){if(gb.inSourceMode())gb.sourceEditorInsertText(b,c);else{if(c){var g=gb.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,"&")),e!==!1&&(b=B(b)),gb.wysiwygEditorInsertHtml(b)}return this},gb.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},gb.getBody=function(){return k},gb.getContentAreaContainer=function(){return i},gb.getSourceEditorValue=function(a){var b=m.val();return a!==!1&&t.hasHandler("toWysiwyg")&&(b=t.callOnlyFirst("toWysiwyg",b)),b},gb.setWysiwygEditorValue=function(b){b||(b="<p>"+(a.sceditor.ie?"":"<br />")+"</p>"),k[0].innerHTML=B(b),_()},gb.setSourceEditorValue=function(a){m.val(a)},gb.updateOriginal=function(){ib.val(gb.val())},B=function(b){if(!f.emoticonsEnabled)return b;var c=a.extend({},f.emoticons.more,f.emoticons.dropdown,f.emoticons.hidden);return a.each(c,function(c,d){var g=a.sceditor.regexEscape(a.sceditor.escapeEntities(c))+"(?=([^\\<\\>]*?<(?!/code)|[^\\<\\>]*?$))",h="";f.emoticonsCompat&&(g="((>|^|\\s| | | | |&nbsp;))"+g+"(?=(\\s|$|<| | | | |&nbsp;))",h="$1"),b=b.replace(new RegExp(g,"gm"),h+e("emoticon",{key:c,url:d.url||d,tooltip:d.tooltip||c}))}),f.emoticonsCompat&&(ob=k.find("img[data-sceditor-emoticon]")),b},gb.inSourceMode=function(){return g.hasClass("sourceMode")},gb.sourceMode=function(a){return"boolean"!=typeof a?gb.inSourceMode():((gb.inSourceMode()&&!a||!gb.inSourceMode()&&a)&&gb.toggleSourceMode(),this)},gb.toggleSourceMode=function(){(a.sceditor.isWysiwygSupported||!gb.inSourceMode())&&(gb.blur(),gb.inSourceMode()?gb.setWysiwygEditorValue(gb.getSourceEditorValue()):gb.setSourceEditorValue(gb.getWysiwygEditorValue()),p=null,m.toggle(),i.toggle(),gb.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 gb.inSourceMode()?(c.txtExec&&(a.isArray(c.txtExec)?gb.sourceEditorInsertText.apply(gb,c.txtExec):c.txtExec.call(gb,b,$())),void 0):(c.exec&&(a.isFunction(c.exec)?c.exec.call(gb,b):gb.execCommand(c.exec,c.hasOwnProperty("execParam")?c.execParam:null)),void 0)},D=function(){a.sceditor.ie&&(p=r.selectedRange())},gb.execCommand=function(b,c){var d=!1,e=a(r.parentNode());if(gb.focus(),!e.is("code")&&0===e.parents("code").length){try{d=l[0].execCommand(b,!1,c)}catch(f){}!d&&gb.commands[b]&&gb.commands[b].errorMessage&&alert(gb._(gb.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,a.sceditor.ie?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})))},gb.currentNode=function(){return u},gb.currentBlockNode=function(){return v},Z=function(a){var b,c,d,e,f,g=l[0],i=mb.length,j=gb.sourceMode();if(gb.sourceMode()||gb.readOnly())h.find(".sceditor-button").removeClass("active");else for(f=a?a.newNode:r.parentNode(),d=r.getFirstBlockParent(f);i--;)if(b=0,c=mb[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(gb,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=jb.length;if(gb.closeDropDown(),c=a(u),13===b.which&&(c.is("code,blockquote,pre")||0!==c.parents("code,blockquote,pre").length))return p=null,gb.wysiwygEditorInsertHtml("<br />",null,!0),!1;if(!c.is("code")&&0===c.parents("code").length)for(;d--;)jb[d].call(gb,b,j,m)},_=function(){var b,c,d;a.sceditor.dom.rTraverse(k[0],function(e){return b=e.nodeName.toLowerCase(),a.inArray(b,lb)>-1&&(c=!0),3===e.nodeType&&!/^\s*$/.test(e.nodeValue)||"br"===b||a.sceditor.ie&&!e.firstChild&&!a.sceditor.dom.isInline(e,!1)?(c&&(d=k[0].ownerDocument.createElement("div"),d.className="sceditor-nlf",d.innerHTML=a.sceditor.ie?"":"<br />",k[0].appendChild(d)),!1):void 0})},T=function(){gb.val(ib.val())},U=function(){gb.closeDropDown(),p=null},X=function(){var a=f.height,b=f.width;gb.maximize()?gb.dimensions("100%","100%",!1):(a&&a.toString().indexOf("%")>-1&&gb.height(a),b&&b.toString().indexOf("%")>-1&&gb.width(b))},gb._=function(){var a=arguments;return q&&q[a[0]]&&(a[0]=q[a[0]]),a[0].replace(/\{(\d+)\}/g,function(b,c){return"undefined"!=typeof a[c-0+1]?a[c-0+1]:"{"+c+"}"})},V=function(b){var c,d=a.extend({},b);t.call(d.type+"Event",b,gb),delete d.type,c=a.Event((b.target===n?"scesrc":"scewys")+b.type,d),g.trigger.apply(g,[c,gb]),c.isDefaultPrevented()&&b.preventDefault(),c.isImmediatePropagationStopped()&&c.stopImmediatePropagation(),c.isPropagationStopped()&&c.stopPropagation()},gb.bind=function(b,c,d,e){var f=b.length;for(b=b.split(" ");f--;)a.isFunction(c)&&(d||g.bind("scewys"+b[f],c),e||g.bind("scesrc"+b[f],c));return this},gb.unbind=function(b,c,d,e){var f=b.length;for(b=b.split(" ");f--;)a.isFunction(c)&&(d||g.unbind("scewys"+b[f],c),e||g.unbind("scesrc"+b[f],c));return this},gb.blur=function(b,c,d){return a.isFunction(b)?gb.bind("blur",b,c,d):gb.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},gb.focus=function(b,c,d){return a.isFunction(b)?gb.bind("focus",b,c,d):gb.inSourceMode()?n.focus():(j.contentWindow.focus(),k[0].focus(),p&&(r.selectRange(p),p=null)),this},gb.keyDown=function(a,b,c){return gb.bind("keydown",a,b,c)},gb.keyPress=function(a,b,c){return gb.bind("keypress",a,b,c)},gb.keyUp=function(a,b,c){return gb.bind("keyup",a,b,c)},gb.nodeChanged=function(a){return gb.bind("nodechanged",a,!1,!0)},gb.selectionChanged=function(a){return gb.bind("selectionchanged",a,!1,!0)},db=function(b){var c=0,d=String.fromCharCode(b.which);return gb.emoticonsCache||(gb.emoticonsCache=[],a.each(a.extend({},f.emoticons.more,f.emoticons.dropdown,f.emoticons.hidden),function(a,b){gb.emoticonsCache[c++]=[a,e("emoticon",{key:a,url:b.url||b,tooltip:b.tooltip||a})]}),gb.emoticonsCache.sort(function(a,b){return a[0].length-b[0].length}),gb.longestEmoticonCode=gb.emoticonsCache[gb.emoticonsCache.length-1][0].length),gb.getRangeHelper().raplaceKeyword(gb.emoticonsCache,!0,!0,gb.longestEmoticonCode,f.emoticonsCompat,d)?(f.emoticonsCompat&&(ob=k.find("img[data-sceditor-emoticon]")),/^\s$/.test(d)&&f.emoticonsCompat):void 0},eb=function(){if(ob.length){var b,c,d,e,f,g,h=gb.currentBlockNode(),i=!1,j=/[^\s\xA0\u2002\u2003\u2009]+/;ob=a.map(ob,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})}},gb.emoticons=function(b){return b||b===!1?(f.emoticonsEnabled=b,b?(k.keypress(db),gb.sourceMode()||(r.saveRange(),k.html(B(k.html())),ob=k.find("img[data-sceditor-emoticon]"),r.restoreRange())):(k.find("img[data-sceditor-emoticon]").replaceWith(function(){return a(this).data("sceditor-emoticon")}),ob=[],k.unbind("keypress",db)),this):f.emoticonsEnabled},gb.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("+"),nb[b]?nb[b].call(gb):void 0},gb.addShortcut=function(a,b){return a=a.toLowerCase(),nb[a]="string"==typeof b?function(){return C(h.find(".sceditor-button-"+b),gb.commands[b]),!1}:b,this},gb.removeShortcut=function(a){return delete nb[a.toLowerCase()],this},R=function(a){var c,d,e,g,h;if(!f.disableBlockRemove&&8===a.which&&(g=r.selectedRange())&&(b.getSelection?(c=g.startContainer,d=g.startOffset):(c=g.parentElement(),e=l[0].selection.createRange(),e.moveToElementText(c),e.setEndPoint("EndToStart",g),d=e.text.length),0===d&&(h=fb()))){for(;c!==h;){for(;c.previousSibling;)if(c=c.previousSibling,3!==c.nodeType||c.nodeValue)return;if(!(c=c.parentNode))return}return gb.clearBlockFormatting(h),!1}},fb=function(){for(var b=v;!a.sceditor.dom.hasStyling(b);)if(!(b=b.parentNode)||a(b).is("body"))return;return b},gb.clearBlockFormatting=function(b){b=b||fb(),b&&!a(b).is("body")&&(r.saveRange(),p=null,b.className="",a(b).attr("style",""),a(b).is("p,div")||a.sceditor.dom.convertElement(b,"p"),r.restoreRange())},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),3===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,"\\$&")},a.sceditor.escapeEntities=function(a){return 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 />"):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>'),0===f%5?(i.g-=51,i.b=255):i.b-=51;l.push("</div>"),0===e%5?(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"},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=d.find("#rows").val()-0,f=d.find("#cols").val()-0,g="<table>";if(!(1>e||1>f)){for(var h=0;e>h;h++){g+="<tr>";for(var i=0;f>i;i++)g+="<td>"+(a.sceditor.ie?"":"<br />")+"</td>";g+="</tr>"}g+="</table>",c.wysiwygEditorInsertHtml(g),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="<blockquote>",f="</blockquote>";c?(d=d?"<cite>"+d+"</cite>":"",e=e+d+c+f,f=null):""===this.getRangeHelper().selectedHtml()&&(f=a.sceditor.ie?"":"<br />"+f),this.wysiwygEditorInsertHtml(e,f)},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,h,i=!0,j="sceditor-start-marker",k="sceditor-end-marker",l="character",m=this;f=function(a,b){e=b||a.contentDocument||a.document,d=a,i=!!a.getSelection}(b,c),m.insertHTML=function(a,b){var c,d,f=m.selectedRange();if(b&&(a+=m.selectedHtml()+b),i){for(d=e.createElement("div"),c=e.createDocumentFragment(),d.innerHTML=a;d.firstChild;)c.appendChild(d.firstChild);m.insertNode(c)}else{if(!f)return!1;f.pasteHTML(a)}},m.insertNode=function(a,b){if(i){var c,d,f=e.createDocumentFragment(),g=m.selectedRange();if(!g)return!1;if(f.appendChild(a),b&&(f.appendChild(g.extractContents()),f.appendChild(b)),d=f.lastChild,!d)return;g.deleteContents(),g.insertNode(f),c=e.createRange(),c.setStartAfter(d),m.selectRange(c)}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?d.getSelection():e.selection;if(c){if(c.getRangeAt&&c.rangeCount<=0){for(b=e.body;b.firstChild;)b=b.firstChild;a=e.createRange(),a.setStart(b,0),c.addRange(a)}return i&&(a=c.getRangeAt(0)),i||"Control"===c.type||(a=c.createRange()),h(a)?a:null}},h=function(a){var b;return a&&a.parentElement&&(b=a.parentElement())?b.ownerDocument===e:!0},m.hasSelection=function(){var a,b=i?d.getSelection():e.selection;return i||!b?b&&b.rangeCount>0:(a=b.createRange(),a&&h(a))},m.selectedHtml=function(){var a,b=m.selectedRange();return b?!i&&""!==b.text&&b.htmlText?b.htmlText:i?(a=e.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)?(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),m.selectRange(c),void 0):!1},g=function(a){m.removeMarker(a);var b=e.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,g(j)),m.insertNodeAt(!1,g(k))},m.getMarker=function(a){return e.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?(d.getSelection().removeAllRanges(),d.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=e.createRange(),b.setStartBefore(c),b.setEndAfter(d),m.selectRange(b)):(b=e.body.createTextRange(),a=e.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)),m.removeMarkers(),void 0):!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)),m.selectRange(c),void 0):!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):h(a)&&h(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)},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|",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.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)}},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.exsists=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.exsists(b))return!1;for(;e--;)if(d[e]instanceof a.sceditor.plugins[b])return!0;return!1},c.register=function(b){return c.exsists(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|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:"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);
View
6 minified/jquery.sceditor.xhtml.min.js
3 additions, 3 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 minified/plugins/bbcode.js
@@ -1,2 +1,2 @@
/*!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+="<br />"),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("<br />");continue}c||(f.push("<div>"),(n.documentMode&&8>n.documentMode||8>e.sceditor.ie)&&f.push(" ")),e.sceditor.ie||f.push("<br />"),t.length||f.push("<br />"),f.push("</div>\n"),c=!1;continue}l=o,a=e.sceditor.escapeEntities(i.val)}l&&!c?(f.push("<div>"),c=!0):!l&&c&&(f.push("</div>\n"),c=!1),f.push(a)}return c&&f.push("</div>\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=e.sceditor.command.get,o={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;n("font")._dropDown(t,e,function(e){t.insertText("[font="+e+"]","[/font]")})}},size:{txtExec:function(e){var t=this;n("size")._dropDown(t,e,function(e){t.insertText("[size="+e+"]","[/size]")})}},color:{txtExec:function(e){var t=this;n("color")._dropDown(t,e,function(e){t.insertText("[color="+e+"]","[/color]")})}},bulletlist:{txtExec:function(n,o){var i="";e.each(o.split(/\r?\n/),function(){i+=(i?"\n":"")+"[li]"+this+"[/li]"}),t.insertText("[ul]\n"+i+"\n[/ul]")}},orderedlist:{txtExec:function(n,o){var i="";e.each(o.split(/\r?\n/),function(){i+=(i?"\n":"")+"[li]"+this+"[/li]"}),e.sceditor.plugins.bbcode.bbcode.get(""),t.insertText("[ol]\n"+i+"\n[/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(e){var t=this;n("youtube")._dropDown(t,e,function(e){t.insertText("[youtube]"+e+"[/youtube]")})}},rtl:{txtExec:["[rtl]","[/rtl]"]},ltr:{txtExec:["[ltr]","[/ltr]"]}};t.commands=e.extend(!0,{},o,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],s=i.nodeName.toLowerCase();if(o=!!o,d[s]&&d[s][o]&&e.each(d[s][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(i,!0)||"br"===s)){for(var a=i.parentNode,l=a.lastChild,u=i.previousSibling,p=e.sceditor.dom.isInline(a,!0);u&&e(u).hasClass("sceditor-ignore");)u=u.previousSibling;for(;e(l).hasClass("sceditor-ignore");)l=l.previousSibling;(p||l!==i||"li"===s||"br"===s&&e.sceditor.ie)&&(n+="\n"),"br"!==s&&u&&"br"!==u.nodeName.toLowerCase()&&e.sceditor.dom.isInline(u,!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("<div />").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(),r=s.toBBCode(r,!0),c.opts.bbcodeTrim&&(r=e.trim(r)),r):""},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=t.firstChild,h=!0;if("object"==typeof r&&(h=e.inArray(d,r)>-1,h||(u=r)),3===c||1===c)if(1===c){if(a.hasClass("sceditor-ignore"))return;if(a.hasClass("sceditor-nlf")&&(!f||!e.sceditor.ie&&(t.childNodes.length>1||"br"!==f.nodeName.toLowerCase())))return;"iframe"!==d&&(l=n(t,u)),h?("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[0])},c.signalToWysiwyg=function(t,n){var o=new e.sceditor.BBCodeParser(c.opts.parserOptions),i=o.toHTML(c.opts.bbcodeTrim?e.trim(t):t);return n?l(i):i},l=function(t){var o,i,r,s=e("<div />").hide().appendTo(n.body),a=s[0];return r=function(t,o){if(!t.className&&!e(t).attr("style")&&e.isEmptyObject(e(t).data())){if(e.sceditor.ie||1!==t.childNodes.length||!e(t.firstChild).is("br"))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,"</div>"),(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+"}"})};var o=e.sceditor.plugins.bbcode.normaliseColour=function(e){var t,n;return n=function(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)},e=e||"#000",(t=e.match(/rgb\((\d{1,3}),\s*?(\d{1,3}),\s*?(\d{1,3})\)/i))?"#"+n(t[1])+n(t[2]-0)+n(t[3]-0):(t=e.match(/#([0-f])([0-f])([0-f])\s*?$/i))?"#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[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:"<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: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'<font face="'+t.defaultattr+'">'+n+"</font>"}},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'<font size="'+t.defaultattr+'">'+n+"</font>"}},color:{tags:{font:{color:null}},styles:{color:null},quoteType:e.sceditor.BBCodeParser.QuoteType.never,format:function(e,t){var n,i=e[0];return"font"===i.nodeName.toLowerCase()&&(n=e.attr("color"))||(n=i.style.color||e.css("color")),"[color="+o(n)+"]"+t+"[/color]"},html:function(e,t,n){return'<font color="'+o(t.defaultattr)+'">'+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 e.attr("data-sceditor-emoticon")+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}},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])+'"'),"<img"+i+' src="'+n+'" />'}},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'<a href="'+encodeURI(t.defaultattr||n)+'">'+n+"</a>"}},email:{quoteType:e.sceditor.BBCodeParser.QuoteType.never,html:function(e,t,n){return'<a href="mailto:'+(t.defaultattr||n)+'">'+n+"</a>"}},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&&(n="<cite>"+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=e.attr("data-youtube-id"),e?"[youtube]"+e+"[/youtube]":t},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:{}},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);
+!function(a,b,c){"use strict";a.sceditor.BBCodeParser=function(b){if(!(this instanceof a.sceditor.BBCodeParser))return new a.sceditor.BBCodeParser(b);var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=this,t={open:"open",content:"content",newline:"newline",close:"close"},u=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};u.prototype={clone:function(a){var b=this;return new u(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 object&&(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}},d=function(){s.opts=a.extend({},a.sceditor.BBCodeParser.defaults,b),s.bbcodes=a.sceditor.plugins.bbcode.bbcodes},s.tokenize=function(a){var b,c,d,f=[],g=[{type:"close",regex:/^\[\/[^\[\]]+\]/},{type:"open",regex:/^\[[^\[\]]+\]/},{type:"newline",regex:/^(\r\n|\r|\n)/},{type:"content",regex:/^([^\[\r\n]+|\[)/}];g.reverse();a:for(;a.length;){for(d=g.length;d--;)if(c=g[d].type,(b=a.match(g[d].regex))&&b[0]){f.push(e(c,b[0])),a=a.substr(b[0].length);continue a}a.length&&f.push(e(t.content,a)),a=""}return f},e=function(b,c){var d,e,g;return"open"===b&&(d=c.match(/\[([^\]\s=]+)(?:([^\]]+))?\]/))?(g=q(d[1]),d[2]&&(d[2]=a.trim(d[2]))&&(e=f(d[2]))):"close"===b&&(d=c.match(/\[\/([^\[\]]+)\]/))?g=q(d[1]):"newline"===b&&(g="#newline"),g&&("open"!==b&&"close"!==b||a.sceditor.plugins.bbcode.bbcodes[g])||(b="content",g="#"),new u(b,g,c,e)},f=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[q(c[1])]=e(c[3])||c[4];return f},s.parse=function(a,b){var c=g(s.tokenize(a));return s.opts.fixInvalidChildren&&l(c),s.opts.removeEmptyTags&&k(c),s.opts.fixInvalidNesting&&i(c),h(c,null,b),s.opts.removeEmptyTags&&k(c),c},o=function(a,b,c){for(var d=c.length;d--;)if(c[d].type===b&&c[d].name===a)return!0;return!1},j=function(b,c){var d=b?s.bbcodes[b.name]:null,e=d?d.allowedChildren:null;return s.opts.fixInvalidChildren&&e?e&&a.inArray(c.name||"#",e)<0?!1:!0:!0},g=function(b){for(var c,d,e,f,g,h,i,j=[],k=[],l=[],m=function(){return r(l)},n=function(a){m()?m().children.push(a):k.push(a)},p=function(b){return m()&&(d=s.bbcodes[m().name])&&d.closedBy&&a.inArray(b,d.closedBy)>-1};c=b.shift();){switch(i=b[0],c.type){case t.open:p(c.name)&&l.pop(),n(c),d=s.bbcodes[c.name],d&&d.isSelfClosing||!d.closedBy&&!o(c.name,t.close,b)?d&&d.isSelfClosing||(c.type=t.content):l.push(c);break;case t.close:if(m()&&c.name!==m().name&&p("/"+c.name)&&l.pop(),m()&&c.name===m().name)m().closing=c,l.pop();else if(o(c.name,t.open,l)){for(;e=l.pop();){if(e.name===c.name){e.closing=c;break}f=e.clone(),j.length>1&&f.children.push(r(j)),j.push(f)}for(n(r(j)),g=j.length;g--;)l.push(j[g]);j.length=0}else c.type=t.content,n(c);break;case t.newline:m()&&i&&p((i.type===t.close?"/":"")+i.name)&&(i.type!==t.close||i.name!==m().name)&&(d=s.bbcodes[m().name],d&&d.breakAfter?l.pop():d&&d.isInline===!1&&s.opts.breakAfterBlock&&d.breakAfter!==!1&&l.pop()),n(c);break;default:n(c)}h=c}return k},h=function(a,b,c){var d,e,f,g,i,j,k,l,m=a.length,n=m;for(b&&(g=s.bbcodes[b.name]);n--;)if(d=a[n])if(d.type===t.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?j||f||(g.isInline===!1&&s.opts.breakEndBlock&&g.breakEnd!==!1&&(l=!0),g.breakEnd&&(l=!0),j=l):(g.isInline===!1&&s.opts.breakStartBlock&&g.breakStart!==!1&&(l=!0),g.breakStart&&(l=!0))),e&&e.type===t.open&&(i=s.bbcodes[e.name])&&(c?i.isInline===!1&&(l=!0):(i.isInline===!1&&s.opts.breakAfterBlock&&i.breakAfter!==!1&&(l=!0),i.breakAfter&&(l=!0))),!c&&!k&&f&&f.type===t.open&&(i=s.bbcodes[f.name])&&(i.isInline===!1&&s.opts.breakBeforeBlock&&i.breakBefore!==!1&&(l=!0),i.breakBefore&&(l=!0),k=l,l)){a.splice(n,1);continue}l&&a.splice(n,1),k=!1}else d.type===t.open&&h(d.children,d,c)},i=function(b,c,d,e){var f,g,h,j,k,l,m=function(a){var b=s.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===t.open){if(!m(f)&&d&&(h=r(c),l=h.splitAt(f),k=c.length>1?c[c.length-2].children:e,(j=a.inArray(h,k))>-1))return l.children.splice(a.inArray(f,l.children),1),k.splice(j+1,0,f,l),void 0;c.push(f),i(f.children,c,d||m(f),e),c.pop(f)}},l=function(a,b){for(var c,d,e=a.length;e--;)(c=a[e])&&(j(b,c)||(c.name=null,c.type=t.content,j(b,c)?(d=[e+1,0].concat(c.children),c.closing&&(c.closing.name=null,c.closing.type=t.content,d.push(c.closing)),e+=d.length-1,Array.prototype.splice.apply(a,d)):b.children.splice(e,1)),c.type===t.open&&l(c.children,c))},k=function(b){var c,d,e,f=b.length;for(e=function(a){for(var b=a.length;b--;){if(a[b].type===t.open)return!1;if(a[b].type===t.close)return!1;if(a[b].type===t.content&&a[b].val&&/\S|\u00A0/.test(a[b].val))return!1}return!0};f--;)(c=b[f])&&c.type===t.open&&(d=s.bbcodes[c.name],k(c.children),e(c.children)&&d&&!d.isSelfClosing&&!d.allowsEmpty&&b.splice.apply(b,a.merge([f,1],c.children)))},s.toHTML=function(a,b){return m(s.parse(a,b),!0)},m=function(b,d){var e,f,g,h,i,j,k,l,n=[];for(k=function(a){return(!a||("undefined"!=typeof a.isHtmlInline?a.isHtmlInline:a.isInline))!==!1};b.length>0;)if(e=b.shift()){if(e.type===t.open)l=e.children[e.children.length-1]||{},f=s.bbcodes[e.name],i=d&&k(f),g=m(e.children,!1),f&&f.html?(k(f)||!k(s.bbcodes[l.name])||f.isPreFormatted||f.skipLastLineBreak||a.sceditor.ie||(g+="<br />"),h=a.isFunction(f.html)?f.html.call(s,e,e.attrs,g):a.sceditor.plugins.bbcode.formatString(f.html,g)):h=e.val+g+(e.closing?e.closing.val:"");else{if(e.type===t.newline){if(!d){n.push("<br />");continue}j||(n.push("<div>"),(c.documentMode&&c.documentMode<8||a.sceditor.ie<8)&&n.push(" ")),a.sceditor.ie||n.push("<br />"),b.length||n.push("<br />"),n.push("</div>\n"),j=!1;continue}i=d,h=a.sceditor.escapeEntities(e.val)}i&&!j?(n.push("<div>"),j=!0):!i&&j&&(n.push("</div>\n"),j=!1),n.push(h)}return j&&n.push("</div>\n"),n.join("")},s.toBBCode=function(a,b){return n(s.parse(a,b))},n=function(b){for(var c,d,e,f,g,h,i,j,k,l,m=[];b.length>0;)if(c=b.shift())if(e=s.bbcodes[c.name],f=!(!e||e.isInline!==!1),g=e&&e.isSelfClosing,i=f&&s.opts.breakBeforeBlock&&e.breakBefore!==!1||e&&e.breakBefore,j=f&&!g&&s.opts.breakStartBlock&&e.breakStart!==!1||e&&e.breakStart,k=f&&s.opts.breakEndBlock&&e.breakEnd!==!1||e&&e.breakEnd,l=f&&s.opts.breakAfterBlock&&e.breakAfter!==!1||e&&e.breakAfter,h=(e?e.quoteType:null)||s.opts.quoteType||a.sceditor.BBCodeParser.QuoteType.auto,e||c.type!==t.open)if(c.type===t.open){if(i&&m.push("\n"),m.push("["+c.name),c.attrs){c.attrs.defaultattr&&(m.push("="+p(c.attrs.defaultattr,h,"defaultattr")),delete c.attrs.defaultattr);for(d in c.attrs)c.attrs.hasOwnProperty(d)&&m.push(" "+d+"="+p(c.attrs[d],h,d))}m.push("]"),j&&m.push("\n"),c.children&&m.push(n(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(n(c.children)),c.closing&&m.push(c.closing.val);return m.join("")},p=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('"','\\"')+'"'},r=function(a){return a.length?a[a.length-1]:null},q=function(a){return a.toLowerCase()},d()},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,g,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"]},n={};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(a,b){var c=b&&b.indexOf("http://")>-1?null:b,d=prompt(this._("Enter URL:"),c?"http://":b),e=prompt(this._("Enter the displayed text:"),c||d)||d;d&&this.insertText("[url="+d+"]"+e+"[/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})})},g=function(b,c){var d,e,f,g,h,i=b.style;return i?(n[c]||(n[c]=a.camelCase(c)),h=n[c],"text-align"===c?(d=a(b),f=i.direction,g=i[h]||d.css(c),d.parent().css(c)===g||"block"!==d.css("display")||d.is("hr")||d.is("th")||(e=g),f&&e&&(/right/i.test(e)&&"rtl"===f||/left/i.test(e)&&"ltr"===f)?null:e):i[h]):null},d=function(b,c,d){var e;return d=!!d,l[d]?(a.each(l[d],function(d,h){e=g(b[0],d),e&&g(b.parent()[0],d)!==e&&a.each(h,function(d,g){(!g||a.inArray(e.toString(),g)>-1)&&(c=a.isFunction(j.bbcodes[d].format)?j.bbcodes[d].format.call(j,b,c):f(j.bbcodes[d].format,c))})}),c):c},e=function(b,c,d){var e=b[0],g=e.nodeName.toLowerCase();if(d=!!d,k[g]&&k[g][d]&&a.each(k[g][d],function(d,e){if(e){var g=!1;if(a.each(e,function(c,d){return!b.attr(c)||d&&a.inArray(b.attr(c),d)<0?void 0:(g=!0,!1)}),!g)return}c=a.isFunction(j.bbcodes[d].format)?j.bbcodes[d].format.call(j,b,c):f(j.bbcodes[d].format,c)}),d&&(!a.sceditor.dom.isInline(e,!0)||"br"===g)){for(var h=e.parentNode,i=h.lastChild,l=e.previousSibling,m=a.sceditor.dom.isInline(h,!0);l&&a(l).hasClass("sceditor-ignore");)l=l.previousSibling;for(;a(i).hasClass("sceditor-ignore");)i=i.previousSibling;(m||i!==e||"li"===g||"br"===g&&a.sceditor.ie)&&(c+="\n"),"br"!==g&&l&&"br"!==l.nodeName.toLowerCase()&&a.sceditor.dom.isInline(l,!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 g="";return a.sceditor.dom.traverse(b,function(b){var h=a(b),i="",j=b.nodeType,k=b.nodeName.toLowerCase(),l=m[k],n=b.firstChild,o=!0;if("object"==typeof f&&(o=a.inArray(k,f)>-1,o||(l=f)),3===j||1===j)if(1===j){if(h.hasClass("sceditor-ignore"))return;if(h.hasClass("sceditor-nlf")&&(!n||!a.sceditor.ie&&(b.childNodes.length>1||"br"!==n.nodeName.toLowerCase())))return;"iframe"!==k&&(i=c(b,l)),o?("code"!==k&&(i=d(h,i),i=e(h,i),i=d(h,i,!0)),g+=e(h,i,!0)):g+=i}else!b.wholeText||b.previousSibling&&3===b.previousSibling.nodeType?b.wholeText||(g+=b.nodeValue):g+=0===h.parents("code").length?b.wholeText.replace(/ +/g," "):b.wholeText},!1,!0),g}(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,g=a("<div />").hide().appendTo(c.body),h=g[0];return f=function(b,d){if(!a.sceditor.dom.hasStyling(b)){if(a.sceditor.ie||1!==b.childNodes.length||!a(b.firstChild).is("br"))for(;e=b.firstChild;)h.insertBefore(e,b);if(d){var f=h.lastChild;b!==f&&a(f).is("div")&&b.nextSibling===f&&h.insertBefore(c.createElement("br"),b)}h.removeChild(b)}},h.innerHTML=b.replace(/<\/div>\n/g,"</div>"),(d=h.firstChild)&&a(d).is("div")&&f(d,!0),(d=h.lastChild)&&a(d).is("div")&&f(d),h=h.innerHTML,g.remove(),h}},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=arguments;return a[0].replace(/\{(\d+)\}/g,function(b,c){return"undefined"!=typeof a[c-0+1]?a[c-0+1]:"{"+c+"}"})};var d=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:function(a,b,c){return'<font face="'+b.defaultattr+'">'+c+"</font>"}},size:{tags:{font:{size:null}},styles:{"font-size":null},format:function(a,b){var c=a.attr("size"),d=1;return c||(c=a.css("fontSize")),c.indexOf("px")>-1?(c=c.replace("px","")-0,c>12&&(d=2),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:function(a,b,c){return'<font size="'+b.defaultattr+'">'+c+"</font>"}},color:{tags:{font:{color:null}},styles:{color:null},quoteType:a.sceditor.BBCodeParser.QuoteType.never,format:function(a,b){var c,e=a[0];return"font"===e.nodeName.toLowerCase()&&(c=a.attr("color"))||(c=e.style.color||a.css("color")),"[color="+d(c)+"]"+b+"[/color]"},html:function(a,b,c){return'<font color="'+d(b.defaultattr)+'">'+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.attr("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}},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"undefined"!=typeof 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="";return"undefined"!=typeof b.width&&(e+=' width="'+b.width+'"'),"undefined"!=typeof b.height&&(e+=' height="'+b.height+'"'),b.defaultattr&&(d=b.defaultattr.split(/x/i),e=' width="'+d[0]+'"'+' height="'+(2===d.length?d[1]:d[0])+'"'),"<img"+e+' src="'+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="+decodeURI(c)+"]"+b+"[/url]"},html:function(a,b,c){return'<a href="'+encodeURI(b.defaultattr||c)+'">'+c+"</a>"}},email:{quoteType:a.sceditor.BBCodeParser.QuoteType.never,html:function(a,b,c){return'<a href="mailto:'+(b.defaultattr||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(),e.children("cite").replaceWith(function(){return a(this).text()}),c=this.elementToBbcode(a(b)),d="="+d),"[quote"+d+"]"+c+"[/quote]"},html:function(a,b,c){return b.defaultattr&&(c="<cite>"+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){return b&&c?(c=a.extend(a.sceditor.plugins.bbcode.bbcodes[b]||{},c),c.remove=function(){a.sceditor.plugins.bbcode.bbcode.remove(b)},a.sceditor.plugins.bbcode.bbcodes[b]=c,this):!1},rename:function(a,b){return this.hasOwnProperty(a)?(this[b]=this[a],this.remove(a),this):!1},remove:function(b){return a.sceditor.plugins.bbcode.bbcodes[b]&&delete a.sceditor.plugins.bbcode.bbcodes[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);
View
2 minified/plugins/format.js
@@ -1,2 +1,2 @@
/*!pl SCEditor | (C) 2011-2013, Sam Clarke | sceditor.com/license */
-(function(e){"use strict";e.sceditor.plugins.format=function(){var t,n,o=this,i={p:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",address:"Address",pre:"Preformatted Text"};o.init=function(){var t=this.opts,o=t.paragraphformat;e.sceditor.plugins.bbcode&&t.plugins&&t.plugins.indexOf("bbcode")>-1||(o&&(o.tags&&(i=o.tags),o.excludeTags&&e.each(o.excludeTags,function(e,t){delete i[t]})),this.commands.format||(this.commands.format={exec:n,txtExec:n,tooltip:"Format Paragraph"}),t.toolbar===e.sceditor.defaultOptions.toolbar&&(t.toolbar=t.toolbar.replace(",color,",",color,format,")))},t=function(e,t){e.sourceMode()?e.insert("<"+t+">","</"+t+">"):e.execCommand("formatblock","<"+t+">")},n=function(n){var o=this,r=e("<div />");e.each(i,function(n,i){e('<a class="sceditor-option" href="#">'+(i.name||i)+"</a>").click(function(){return o.closeDropDown(!0),i.exec?i.exec(o):t(o,n),!1}).appendTo(r)}),o.createDropDown(n,"format",r)}}})(jQuery);
+!function(a){"use strict";a.sceditor.plugins.format=function(){var b,c,d=this,e={p:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",address:"Address",pre:"Preformatted Text"};d.init=function(){var b=this.opts,d=b.paragraphformat;a.sceditor.plugins.bbcode&&b.plugins&&b.plugins.indexOf("bbcode")>-1||(d&&(d.tags&&(e=d.tags),d.excludeTags&&a.each(d.excludeTags,function(a,b){delete e[b]})),this.commands.format||(this.commands.format={exec:c,txtExec:c,tooltip:"Format Paragraph"}),b.toolbar===a.sceditor.defaultOptions.toolbar&&(b.toolbar=b.toolbar.replace(",color,",",color,format,")))},b=function(a,b){a.sourceMode()?a.insert("<"+b+">","</"+b+">"):a.execCommand("formatblock","<"+b+">")},c=function(c){var d=this,f=a("<div />");a.each(e,function(c,e){a('<a class="sceditor-option" href="#">'+(e.name||e)+"</a>").click(function(){return d.closeDropDown(!0),e.exec?e.exec(d):b(d,c),!1}).appendTo(f)}),d.createDropDown(c,"format",f)}}}(jQuery);
View
2 minified/plugins/xhtml.js
@@ -1,2 +1,2 @@
/*!pl SCEditor | (C) 2011-2013, Sam Clarke | sceditor.com/license */
-(function(e){"use strict";e.sceditor.XHTMLSerializer=function(){var t,n,o,i,r,s,a,l,c,d,u=this,f={indentStr:" "},p=[],h=0;t=function(e){var t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};return e?e.replace(/[&<>"]/g,function(e){return t[e]||e}):""},n=function(e){return e.replace(/[\r\n]/,"").replace(/[^\S|\u00A0]+/g," ")},u.serialize=function(e,t){if(p=[],t)for(e=e.firstChild;e;)o(e),e=e.nextSibling;else o(e);return p.join("")},o=function(e,t){switch(e.nodeType){case 1:var n=e.nodeName.toLowerCase();"!"===n?a(e):r(e,t);break;case 3:l(e,t);break;case 4:s(e);break;case 8:a(e);break;case 9:case 11:i(e);break;case 2:case 5:case 6:case 7:case 10:case 12:}},i=function(e){var t;for(t=e.firstChild;t;)o(t),t=t.nextSibling},r=function(n,i){var r,s,a,l=n.nodeName.toLowerCase(),u=n.attributes.length,f=i||/pre(?:\-wrap)?$/i.test(e(n).css("whiteSpace")),p=!n.firstChild&&e.sceditor.XHTMLSerializer.emptyTags.indexOf("|"+l+"|")>-1;if(!e(n).hasClass("sceditor-ignore")){for(c("<"+l,!i&&d(n));u--;)s=n.attributes[u],(!e.sceditor.ie||s.specified)&&(a=8>e.sceditor.ie&&/style/i.test(s.name)?n.style.cssText:s.value,c(" "+s.name.toLowerCase()+'="'+t(a)+'"',!1));for(c(p?" />":">",!1),r=n.firstChild;r;)h++,o(r,f),r=r.nextSibling,h--;p||c("</"+l+">",!f&&d(n)&&n.firstChild&&d(n.firstChild))}},s=function(e){c("<![CDATA["+t(e.nodeValue)+"]]>")},a=function(e){c("<!-- "+t(e.nodeValue)+" -->")},l=function(e,o){var i=e.nodeValue;o||(i=n(i)),i&&c(t(i),!o&&d(e))},c=function(e,t){var n=h;if(t!==!1)for(p.length&&p.push("\n");n--;)p.push(f.indentStr);p.push(e)},d=function(t){var n=t.previousSibling;return 1!==t.nodeType&&n?!e.sceditor.dom.isInline(n):n||e.sceditor.dom.isInline(t.parentNode)?!e.sceditor.dom.isInline(t):!0}},e.sceditor.XHTMLSerializer.emptyTags="|area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param|command|embed|keygen|source|track|wbr|",e.sceditor.plugins.xhtml=function(){var t,n,o,i,r,s,a,l=this,c={},d={};l.init=function(){e.isEmptyObject(e.sceditor.plugins.xhtml.converters||{})||e.each(e.sceditor.plugins.xhtml.converters,function(t,n){e.each(n.tags,function(e){c[e]||(c[e]=[]),c[e].push(n)})}),t(this)},t=function(t){var n={bold:{txtExec:["<strong>","</strong>"]},italic:{txtExec:["<em>","</em>"]},underline:{txtExec:['<span style="text-decoration: underline;">',"<span>"]},strike:{txtExec:['<span style="text-decoration: line-through;">',"<span>"]},subscript:{txtExec:["<sub>","</sub>"]},superscript:{txtExec:["<sup>","</sup>"]},left:{txtExec:['<div style="text-align: left;">',"<div>"]},center:{txtExec:['<div style="text-align: center;">',"<div>"]},right:{txtExec:['<div style="text-align: right;">',"<div>"]},justify:{txtExec:['<div style="text-align: justify;">',"<div>"]},font:{txtExec:function(t){var n=this;e.sceditor.command.get("font")._dropDown(n,t,function(e){n.insertText('<span style="font-family: '+e+';">',"</span>")})}},size:{txtExec:function(t){var n=this;e.sceditor.command.get("size")._dropDown(n,t,function(e){n.insertText('<span style="font-size: '+e+';">',"</span>")})}},color:{txtExec:function(t){var n=this;e.sceditor.command.get("color")._dropDown(n,t,function(e){n.insertText('<span style="color: '+e+';">',"</span>")})}},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 src="'+n+'" />')}},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('<a href="mailto:'+o+'">'+i+"</a>")}},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('<a href="'+o+'">'+i+"</a>")}},quote:{txtExec:["<blockquote>","</blockquote>"]},youtube:{txtExec:function(t){var n=this;e.sceditor.command.get("youtube")._dropDown(n,t,function(e){n.insertText('<iframe width="560" height="315" src="http://www.youtube.com/embed/{id}?wmode=opaque" data-youtube-id="'+e+'" frameborder="0" allowfullscreen></iframe>')})}},rtl:{txtExec:['<div stlye="direction: rtl;">',"</div>"]},ltr:{txtExec:['<div stlye="direction: ltr;">',"</div>"]}};t.commands=e.extend(!0,{},n,t.commands)},l.signalToSource=function(t,o){return o=o.jquery?o[0]:o,n(o),r(o),a(o),(new e.sceditor.XHTMLSerializer).serialize(o,!0)},l.signalToWysiwyg=function(e){return e},l.convertTagTo=function(t,n){for(var o,i,r=t.attributes.length,s=t.ownerDocument.createElement(n);r--;)i=t.attributes[r],(!e.sceditor.ie||i.specified)&&(8>e.sceditor.ie&&/style/i.test(i.name)?t.style.cssText=t.style.cssText:s.setAttribute(i.name,i.value));for(;o=t.firstChild;)s.appendChild(o);return t.parentNode.replaceChild(s,t),s},o=function(t,n,o){c[t]&&e.each(c[t],function(i,r){r.tags[t]?e.each(r.tags[t],function(t,i){o.getAttributeNode&&(t=o.getAttributeNode(t),!t||8>e.sceditor.ie&&!t.specified||i&&0>e.inArray(t.value,i)||r.conv.call(l,o,n))}):r.conv&&r.conv.call(l,o,n)})},n=function(t){c&&e.sceditor.dom.traverse(t,function(t){var n=e(t),i=t.nodeName.toLowerCase();c&&(o("*",n,t),o(i,n,t))},!0)},i=function(t,n){var o=t.childNodes,r=t.nodeName.toLowerCase(),s=t.nodeValue,a=o.length;if(n&&"br"===r)return!0;if(e.sceditor.XHTMLSerializer.emptyTags.indexOf("|"+r+"|")>-1)return!1;if(s&&/\S|\u00A0/.test(s))return!1;for(;a--;)if(!i(o[a],!t.previousSibling&&!t.nextSibling))return!1;return!0},r=function(t){e.sceditor.dom.traverse(t,function(t){var n,o=i(t),r=t.nodeName.toLowerCase(),s=t.parentNode,a=t.nodeType,l=e.sceditor.plugins.xhtml.allowedTags,c=e.sceditor.plugins.xhtml.disallowedTags;if(3!==a&&(4===a?r="!cdata":("!"===r||8===a)&&(r="!comment"),o?n=!0:l&&l.length?n=0>e.inArray(r,l):c&&c.length&&(n=e.inArray(r,c)>-1),n)){for(;!o&&t.lastChild;)s.insertBefore(t.lastChild,t.nextSibling);s.removeChild(t)}},!0)},s=function(t,n){var o={};return t&&e.extend(o,t),n?(e.each(n,function(t,n){e.isArray(n)?o[t]=e.merge(o[t]||[],n):o[t]||(o[t]=null)}),o):o},a=function(t){var n,o,i,r,a,l,c=e.sceditor.plugins.xhtml.allowedAttribs,u=c&&!e.isEmptyObject(c),f=e.sceditor.plugins.xhtml.disallowedAttribs,p=f&&!e.isEmptyObject(f);d={},e.sceditor.dom.traverse(t,function(t){if(t.attributes&&(n=t.nodeName.toLowerCase(),r=t.attributes.length))for(d[n]||(d[n]=u?s(c["*"],c[n]):s(f["*"],f[n]));r--;)o=t.attributes[r],i=o.name,a=d[n][i],l=!1,u?l=null!==a&&(!e.isArray(a)||0>e.inArray(o.value,a)):p&&(l=null===a||e.isArray(a)&&e.inArray(o.value,a)>-1),l&&t.removeAttribute(i)})}},e.sceditor.plugins.xhtml.converters=[{tags:{"*":{width:null}},conv:function(e,t){t.css("width",t.attr("width")).removeAttr("width")}},{tags:{"*":{height:null}},conv:function(e,t){t.css("height",t.attr("height")).removeAttr("height")}},{tags:{li:{value:null}},conv:function(e,t){t.removeAttr("value")}},{tags:{"*":{text:null}},conv:function(e,t){t.css("color",t.attr("text")).removeAttr("text")}},{tags:{"*":{color:null}},conv:function(e,t){t.css("color",t.attr("color")).removeAttr("color")}},{tags:{"*":{face:null}},conv:function(e,t){t.css("fontFamily",t.attr("face")).removeAttr("face")}},{tags:{"*":{align:null}},conv:function(e,t){t.css("textAlign",t.attr("align")).removeAttr("align")}},{tags:{"*":{border:null}},conv:function(e,t){t.css("borderWidth",t.attr("border")).removeAttr("border")}},{tags:{applet:{name:null},img:{name:null},layer:{name:null},map:{name:null},object:{name:null},param:{name:null}},conv:function(e,t){t.attr("id")||t.attr("id",t.attr("name")),t.removeAttr("name")}},{tags:{"*":{vspace:null}},conv:function(e,t){t.css("marginTop",t.attr("vspace")-0).css("marginBottom",t.attr("vspace")-0).removeAttr("vspace")}},{tags:{"*":{hspace:null}},conv:function(e,t){t.css("marginLeft",t.attr("hspace")-0).css("marginRight",t.attr("hspace")-0).removeAttr("hspace")}},{tags:{hr:{noshade:null}},conv:function(e,t){t.css("borderStyle","solid").removeAttr("noshade")}},{tags:{"*":{nowrap:null}},conv:function(e,t){t.css("white-space","nowrap").removeAttr("nowrap")}},{tags:{big:null},conv:function(t){e(this.convertTagTo(t,"span")).css("fontSize","larger")}},{tags:{small:null},conv:function(t){e(this.convertTagTo(t,"span")).css("fontSize","smaller")}},{tags:{b:null},conv:function(t){e(this.convertTagTo(t,"strong"))}},{tags:{u:null},conv:function(t){e(this.convertTagTo(t,"span")).css("textDecoration","underline")}},{tags:{i:null},conv:function(t){e(this.convertTagTo(t,"em"))}},{tags:{s:null,strike:null},conv:function(t){e(this.convertTagTo(t,"span")).css("textDecoration","line-through")}},{tags:{dir:null},conv:function(e){this.convertTagTo(e,"ul")}},{tags:{center:null},conv:function(t){e(this.convertTagTo(t,"div")).css("textAlign","center")}},{tags:{font:{size:null}},conv:function(e,t){t.css("fontSize",t.css("fontSize")).removeAttr("size")}},{tags:{font:null},conv:function(e){this.convertTagTo(e,"span")}},{tags:{"*":{type:["_moz"]}},conv:function(e,t){t.removeAttr("type")}},{tags:{"*":{_moz_dirty:null}},conv:function(e,t){t.removeAttr("_moz_dirty")}},{tags:{"*":{_moz_editor_bogus_node:null}},conv:function(e,t){t.remove()}}],e.sceditor.plugins.xhtml.allowedAttribs={},e.sceditor.plugins.xhtml.disallowedAttribs={},e.sceditor.plugins.xhtml.allowedTags=[],e.sceditor.plugins.xhtml.disallowedTags=[]})(jQuery);
+!function(a){"use strict";a.sceditor.XHTMLSerializer=function(){var b,c,d,e,f,g,h,i,j,k,l=this,m={indentStr:" "},n=[],o=0;b=function(a){var b={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};return a?a.replace(/[&<>"]/g,function(a){return b[a]||a}):""},c=function(a){return a.replace(/[\r\n]/,"").replace(/[^\S|\u00A0]+/g," ")},l.serialize=function(a,b){if(n=[],b)for(a=a.firstChild;a;)d(a),a=a.nextSibling;else d(a);return n.join("")},d=function(a,b){switch(a.nodeType){case 1:var c=a.nodeName.toLowerCase();"!"===c?h(a):f(a,b);break;case 3:i(a,b);break;case 4:g(a);break;case 8:h(a);break;case 9:case 11:e(a);break;case 2:case 5:case 6:case 7:case 10:case 12:}},e=function(a){var b;for(b=a.firstChild;b;)d(b),b=b.nextSibling},f=function(c,e){var f,g,h,i=c.nodeName.toLowerCase(),l=c.attributes.length,m=e||/pre(?:\-wrap)?$/i.test(a(c).css("whiteSpace")),n=!c.firstChild&&a.sceditor.XHTMLSerializer.emptyTags.indexOf("|"+i+"|")>-1;if(!a(c).hasClass("sceditor-ignore")){for(j("<"+i,!e&&k(c));l--;)g=c.attributes[l],(!a.sceditor.ie||g.specified)&&(h=a.sceditor.ie<8&&/style/i.test(g.name)?c.style.cssText:g.value,j(" "+g.name.toLowerCase()+'="'+b(h)+'"',!1));for(j(n?" />":">",!1),f=c.firstChild;f;)o++,d(f,m),f=f.nextSibling,o--;n||j("</"+i+">",!m&&k(c)&&c.firstChild&&k(c.firstChild))}},g=function(a){j("<![CDATA["+b(a.nodeValue)+"]]>")},h=function(a){j("<!-- "+b(a.nodeValue)+" -->")},i=function(a,d){var e=a.nodeValue;d||(e=c(e)),e&&j(b(e),!d&&k(a))},j=function(a,b){var c=o;if(b!==!1)for(n.length&&n.push("\n");c--;)n.push(m.indentStr);n.push(a)},k=function(b){var c=b.previousSibling;return 1!==b.nodeType&&c?!a.sceditor.dom.isInline(c):c||a.sceditor.dom.isInline(b.parentNode)?!a.sceditor.dom.isInline(b):!0}},a.sceditor.XHTMLSerializer.emptyTags="|area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param|command|embed|keygen|source|track|wbr|",a.sceditor.plugins.xhtml=function(){var b,c,d,e,f,g,h,i=this,j={},k={};i.init=function(){a.isEmptyObject(a.sceditor.plugins.xhtml.converters||{})||a.each(a.sceditor.plugins.xhtml.converters,function(b,c){a.each(c.tags,function(a){j[a]||(j[a]=[]),j[a].push(c)})}),b(this)},b=function(b){var c={bold:{txtExec:["<strong>","</strong>"]},italic:{txtExec:["<em>","</em>"]},underline:{txtExec:['<span style="text-decoration: underline;">',"<span>"]},strike:{txtExec:['<span style="text-decoration: line-through;">',"<span>"]},subscript:{txtExec:["<sub>","</sub>"]},superscript:{txtExec:["<sup>","</sup>"]},left:{txtExec:['<div style="text-align: left;">',"<div>"]},center:{txtExec:['<div style="text-align: center;">',"<div>"]},right:{txtExec:['<div style="text-align: right;">',"<div>"]},justify:{txtExec:['<div style="text-align: justify;">',"<div>"]},font:{txtExec:function(b){var c=this;a.sceditor.command.get("font")._dropDown(c,b,function(a){c.insertText('<span style="font-family: '+a+';">',"</span>")})}},size:{txtExec:function(b){var c=this;a.sceditor.command.get("size")._dropDown(c,b,function(a){c.insertText('<span style="font-size: '+a+';">',"</span>")})}},color:{txtExec:function(b){var c=this;a.sceditor.command.get("color")._dropDown(c,b,function(a){c.insertText('<span style="color: '+a+';">',"</span>")})}},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(a,b){var c=prompt(this._("Enter the image URL:"),b);c&&this.insertText('<img src="'+c+'" />')}},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('<a href="mailto:'+d+'">'+e+"</a>")}},link:{txtExec:function(a,b){var c=b&&b.indexOf("http://")>-1?null:b,d=prompt(this._("Enter URL:"),c?"http://":b),e=prompt(this._("Enter the displayed text:"),c||d)||d;d&&this.insertText('<a href="'+d+'">'+e+"</a>")}},quote:{txtExec:["<blockquote>","</blockquote>"]},youtube:{txtExec:function(b){var c=this;a.sceditor.command.get("youtube")._dropDown(c,b,function(a){c.insertText('<iframe width="560" height="315" src="http://www.youtube.com/embed/{id}?wmode=opaque" data-youtube-id="'+a+'" frameborder="0" allowfullscreen></iframe>')})}},rtl:{txtExec:['<div stlye="direction: rtl;">',"</div>"]},ltr:{txtExec:['<div stlye="direction: ltr;">',"</div>"]}};b.commands=a.extend(!0,{},c,b.commands)},i.signalToSource=function(b,d){return d=d.jquery?d[0]:d,c(d),f(d),h(d),(new a.sceditor.XHTMLSerializer).serialize(d,!0)},i.signalToWysiwyg=function(a){return a},i.convertTagTo=a.sceditor.dom.convertElement,d=function(b,c,d){j[b]&&a.each(j[b],function(e,f){f.tags[b]?a.each(f.tags[b],function(b,e){d.getAttributeNode&&(b=d.getAttributeNode(b),!b||a.sceditor.ie<8&&!b.specified||e&&a.inArray(b.value,e)<0||f.conv.call(i,d,c))}):f.conv&&f.conv.call(i,d,c)})},c=function(b){j&&a.sceditor.dom.traverse(b,function(b){var c=a(b),e=b.nodeName.toLowerCase();j&&(d("*",c,b),d(e,c,b))},!0)},e=function(b,c){var d=b.childNodes,f=b.nodeName.toLowerCase(),g=b.nodeValue,h=d.length;if(c&&"br"===f)return!0;if(a.sceditor.XHTMLSerializer.emptyTags.indexOf("|"+f+"|")>-1)return!1;if(g&&/\S|\u00A0/.test(g))return!1;for(;h--;)if(!e(d[h],!b.previousSibling&&!b.nextSibling))return!1;return!0},f=function(b){a.sceditor.dom.traverse(b,function(b){var c,d=e(b),f=b.nodeName.toLowerCase(),g=b.parentNode,h=b.nodeType,i=a.sceditor.plugins.xhtml.allowedTags,j=a.sceditor.plugins.xhtml.disallowedTags;if(3!==h&&(4===h?f="!cdata":("!"===f||8===h)&&(f="!comment"),d?c=!0:i&&i.length?c=a.inArray(f,i)<0:j&&j.length&&(c=a.inArray(f,j)>-1),c)){for(;!d&&b.lastChild;)g.insertBefore(b.lastChild,b.nextSibling);g.removeChild(b)}},!0)},g=function(b,c){var d={};return b&&a.extend(d,b),c?(a.each(c,function(b,c){a.isArray(c)?d[b]=a.merge(d[b]||[],c):d[b]||(d[b]=null)}),d):d},h=function(b){var c,d,e,f,h,i,j=a.sceditor.plugins.xhtml.allowedAttribs,l=j&&!a.isEmptyObject(j),m=a.sceditor.plugins.xhtml.disallowedAttribs,n=m&&!a.isEmptyObject(m);k={},a.sceditor.dom.traverse(b,function(b){if(b.attributes&&(c=b.nodeName.toLowerCase(),f=b.attributes.length))for(k[c]||(k[c]=l?g(j["*"],j[c]):g(m["*"],m[c]));f--;)d=b.attributes[f],e=d.name,h=k[c][e],i=!1,l?i=null!==h&&(!a.isArray(h)||a.inArray(d.value,h)<0):n&&(i=null===h||a.isArray(h)&&a.inArray(d.value,h)>-1),i&&b.removeAttribute(e)})}},a.sceditor.plugins.xhtml.converters=[{tags:{"*":{width:null}},conv:function(a,b){b.css("width",b.attr("width")).removeAttr("width")}},{tags:{"*":{height:null}},conv:function(a,b){b.css("height",b.attr("height")).removeAttr("height")}},{tags:{li:{value:null}},conv:function(a,b){b.removeAttr("value")}},{tags:{"*":{text:null}},conv:function(a,b){b.css("color",b.attr("text")).removeAttr("text")}},{tags:{"*":{color:null}},conv:function(a,b){b.css("color",b.attr("color")).removeAttr("color")}},{tags:{"*":{face:null}},conv:function(a,b){b.css("fontFamily",b.attr("face")).removeAttr("face")}},{tags:{"*":{align:null}},conv:function(a,b){b.css("textAlign",b.attr("align")).removeAttr("align")}},{tags:{"*":{border:null}},conv:function(a,b){b.css("borderWidth",b.attr("border")).removeAttr("border")}},{tags:{applet:{name:null},img:{name:null},layer:{name:null},map:{name:null},object:{name:null},param:{name:null}},conv:function(a,b){b.attr("id")||b.attr("id",b.attr("name")),b.removeAttr("name")}},{tags:{"*":{vspace:null}},conv:function(a,b){b.css("marginTop",b.attr("vspace")-0).css("marginBottom",b.attr("vspace")-0).removeAttr("vspace")}},{tags:{"*":{hspace:null}},conv:function(a,b){b.css("marginLeft",b.attr("hspace")-0).css("marginRight",b.attr("hspace")-0).removeAttr("hspace")}},{tags:{hr:{noshade:null}},conv:function(a,b){b.css("borderStyle","solid").removeAttr("noshade")}},{tags:{"*":{nowrap:null}},conv:function(a,b){b.css("white-space","nowrap").removeAttr("nowrap")}},{tags:{big:null},conv:function(b){a(this.convertTagTo(b,"span")).css("fontSize","larger")}},{tags:{small:null},conv:function(b){a(this.convertTagTo(b,"span")).css("fontSize","smaller")}},{tags:{b:null},conv:function(b){a(this.convertTagTo(b,"strong"))}},{tags:{u:null},conv:function(b){a(this.convertTagTo(b,"span")).css("textDecoration","underline")}},{tags:{i:null},conv:function(b){a(this.convertTagTo(b,"em"))}},{tags:{s:null,strike:null},conv:function(b){a(this.convertTagTo(b,"span")).css("textDecoration","line-through")}},{tags:{dir:null},conv:function(a){this.convertTagTo(a,"ul")}},{tags:{center:null},conv:function(b){a(this.convertTagTo(b,"div")).css("textAlign","center")}},{tags:{font:{size:null}},conv:function(a,b){b.css("fontSize",b.css("fontSize")).removeAttr("size")}},{tags:{font:null},conv:function(a){this.convertTagTo(a,"span")}},{tags:{"*":{type:["_moz"]}},conv:function(a,b){b.removeAttr("type")}},{tags:{"*":{_moz_dirty:null}},conv:function(a,b){b.removeAttr("_moz_dirty")}},{tags:{"*":{_moz_editor_bogus_node:null}},conv:function(a,b){b.remove()}}],a.sceditor.plugins.xhtml.allowedAttribs={},a.sceditor.plugins.xhtml.disallowedAttribs={},a.sceditor.plugins.xhtml.allowedTags=[],a.sceditor.plugins.xhtml.disallowedTags=[]}(jQuery);
View
5 package.json
@@ -1,6 +1,11 @@
{
"name": "sceditor",
"version": "1.4.4",
+ "repository" :
+ {
+ "type" : "git",
+ "url" : "https://github.com/samclarke/SCEditor.git"
+ },
"engines": {
"node": ">= 0.10.0"
},
View
163 src/jquery.sceditor.js
@@ -308,6 +308,7 @@
handlePasteEvt,
handlePasteData,
handleKeyDown,
+ handleBackSpace,
handleKeyPress,
handleFormReset,
handleMouseDown,
@@ -322,7 +323,8 @@
checkNodeChanged,
autofocus,
emoticonsKeyPress,
- emoticonsCheckWhitespace;
+ emoticonsCheckWhitespace,
+ currentStyledBlockNode;
/**
* All the commands supported by the editor
@@ -538,6 +540,7 @@
$wysiwygBody
.keypress(handleKeyPress)
.keydown(handleKeyDown)
+ .keydown(handleBackSpace)
.keyup(appendNewLine)
.bind('paste', handlePasteEvt)
.bind($.sceditor.ie ? 'selectionchange' : 'keyup focus blur contextmenu mouseup touchend click', checkSelectionChanged)
@@ -2199,7 +2202,7 @@
base.closeDropDown();
- $parentNode = $(rangeHelper.parentNode());
+ $parentNode = $(currentNode);
// "Fix" (OK it's a cludge) for blocklevel elements being duplicated in some browsers when
// enter is pressed instead of inserting a newline
@@ -2213,6 +2216,7 @@
}
}
+// TODO: Remove keyPressFuncs, which are deprecated
// don't apply to code elements
if($parentNode.is('code') || $parentNode.parents('code').length !== 0)
return;
@@ -2877,6 +2881,106 @@
return this;
};
+ /**
+ * Handles the backspace key press
+ *
+ * Will remove block styling like quotes/code ect if at the start.
+ * @private
+ */
+ handleBackSpace = function(e) {
+ var node, offset, tmpRange, range, parent;
+
+ // 8 is the backspace key
+ if(options.disableBlockRemove || e.which !== 8 || !(range = rangeHelper.selectedRange()))
+ return;
+
+ if(!window.getSelection)
+ {
+ node = range.parentElement();
+ tmpRange = $wysiwygDoc[0].selection.createRange();
+
+ // Select te entire parent and set the end as start of the current range
+ tmpRange.moveToElementText(node);
+ tmpRange.setEndPoint('EndToStart', range);
+
+ // Number of characters selected is the start offset
+ // relative to the parent node
+ offset = tmpRange.text.length;
+ }
+ else
+ {
+ node = range.startContainer;
+ offset = range.startOffset;
+ }
+
+ if(offset !== 0 || !(parent = currentStyledBlockNode()))
+ return;
+
+ while(node !== parent)
+ {
+ while(node.previousSibling)
+ {
+ node = node.previousSibling;
+
+ // Everything but empty text nodes before the cursor
+ // should prevent the style from being removed
+ if(node.nodeType !== 3 || node.nodeValue)
+ return;
+ }
+
+ if(!(node = node.parentNode))
+ return;
+ }
+
+ // The backspace was pressed at the start of
+ // the container so clear the style
+ base.clearBlockFormatting(parent);
+ return false;
+ };
+
+ /**
+ * Gets the first styled block node that contains the cursor
+ * @return {HTMLElement}
+ */
+ currentStyledBlockNode = function() {
+ var block = currentBlockNode;
+
+ while(!$.sceditor.dom.hasStyling(block))
+ {
+ if(!(block = block.parentNode) || $(block).is('body'))
+ return;
+ }
+
+ return block;
+ };
+
+ /**
+ * Clears the formatting of the passed block element.
+ *
+ * If block is false, if will clear the styling of the first
+ * block level element that contains the cursor.
+ * @param {HTMLElement} block
+ * @since 1.4.4
+ */
+ base.clearBlockFormatting = function(block) {
+ block = block || currentStyledBlockNode();
+
+ if(!block || $(block).is('body'))
+ return;
+
+ rangeHelper.saveRange();
+
+ lastRange = null;
+ block.className = '';
+
+ $(block).attr('style', '');
+
+ if(!$(block).is('p,div'))
+ $.sceditor.dom.convertElement(block, 'p');
+
+ rangeHelper.restoreRange();
+ };
+
// run the initializer
init();
};
@@ -4478,6 +4582,55 @@
},
/**
+ * Checks if an element is not a p or div element and if it has any styling.
+ * @param {HTMLElement} elm
+ * @return {Boolean}
+ * @since 1.4.4
+ */
+ hasStyling: function(elm) {
+ var $elm = $(elm);
+
+ return elm && (!$elm.is('p,div') || elm.className || $elm.attr('style') || !$.isEmptyObject($elm.data()));
+ },
+
+ /**
+ * Converts an element from one type to another.
+ *
+ * For example it can convert the element <b> to <strong>
+ * @param {HTMLElement} elm
+ * @param {String} newElement
+ * @return {HTMLElement}
+ * @since 1.4.4
+ */
+ convertElement: function(elm, newElement) {
+ var child, attr,
+ i = elm.attributes.length,
+ newTag = elm.ownerDocument.createElement(newElement);
+
+ while(i--)
+ {
+ attr = elm.attributes[i];
+
+ // IE < 8 returns all possible attribtues, not just specified ones
+ if(!$.sceditor.ie || attr.specified)
+ {
+ // IE < 8 doesn't return the CSS for the style attribute
+ if($.sceditor.ie < 8 && /style/i.test(attr.name))
+ elm.style.cssText = elm.style.cssText;
+ else
+ newTag.setAttribute(attr.name, attr.value);
+ }
+ }
+
+ while((child = elm.firstChild))
+ newTag.appendChild(child);
+
+ elm.parentNode.replaceChild(newTag, elm);
+
+ return newTag;
+ },
+
+ /**
* List of block level elements separated by bars (|)
* @type {string}
*/
@@ -5326,6 +5479,12 @@
bbcodeTrim: false,
/**
+ * If to disable removing block level elements by pressing backspace at the start of them
+ * @type {Boolean}
+ */
+ disableBlockRemove: false,
+
+ /**
* BBCode parser options, only applies if using the editor in BBCode mode.
*
* See $.sceditor.BBCodeParser.defaults for list of valid options
View
2 src/plugins/bbcode.js
@@ -1739,7 +1739,7 @@
removeDiv = function(node, isFirst) {
// Don't remove divs that have styling
- if(node.className || $(node).attr('style') || !$.isEmptyObject($(node).data()))
+ if($.sceditor.dom.hasStyling(node))
return;
if($.sceditor.ie || (node.childNodes.length !== 1 || !$(node.firstChild).is('br')))
View
36 src/plugins/xhtml.js
@@ -517,40 +517,10 @@
};
/**
- * Converts a tags name to the name specified
- *
- * @param {Node} elm
- * @param {String} newtagName
- * @return {Node} The new node
- * @memberOf jQuery.sceditor.plugins.xhtml.prototype
+ * Deprecated, use $.sceditor.dom.convertElement() instead.
+ * @deprecated
*/
- base.convertTagTo = function(elm, newtagName) {
- var child, attr,
- i = elm.attributes.length,
- newTag = elm.ownerDocument.createElement(newtagName);
-
- while(i--)
- {
- attr = elm.attributes[i];
-
- // IE < 8 returns all possible attribtues, not just specified ones
- if(!$.sceditor.ie || attr.specified)
- {
- // IE < 8 doesn't return the CSS for the style attribute
- if($.sceditor.ie < 8 && /style/i.test(attr.name))
- elm.style.cssText = elm.style.cssText;
- else
- newTag.setAttribute(attr.name, attr.value);
- }
- }
-
- while((child = elm.firstChild))
- newTag.appendChild(child);
-
- elm.parentNode.replaceChild(newTag, elm);
-
- return newTag;
- };
+ base.convertTagTo = $.sceditor.dom.convertElement;
/**
* Runs all converters for the specified tagName

0 comments on commit 3e69270

Please sign in to comment.
Something went wrong with that request. Please try again.