")},observe:function(){if(this.is()){var t,e;for(var i in this.setButtonsInactive(),this.buttonsObservers)e=this.buttonsObservers[i],t=this.getButton(i),this.app.broadcast("button."+e+".observe",t);var s=this.opts.activeButtons,n=this.selection.getInlinesAllSelected(),r=this.selection.getInline();this.selection.isCollapsed()&&r&&n.push(r);var o=this._inlinesToTags(n);for(var a in s)-1!==o.indexOf(a)&&(t=this.getButton(s[a]))&&t.setActive()}},is:function(){return!(!this.opts.toolbar||this.detector.isMobile()&&this.opts.air)},isAir:function(){return!!this.is()&&this.$toolbar.hasClass("redactor-air")},isFixed:function(){return!!this.is()&&this.$toolbar.hasClass("redactor-toolbar-fixed")},isContextBar:function(){return this.$body.find("#redactor-context-toolbar-"+this.uuid).hasClass("open")},isTarget:function(){return this.opts.toolbarFixedTarget!==document},getElement:function(){return this.$toolbar},getWrapper:function(){return this.$wrapper},getDropdown:function(){return this.dropdownOpened},getTargetElement:function(){return $R.dom(this.opts.toolbarFixedTarget)},getButton:function(t){var e=this._findButton(".re-"+t);return 0!==e.length&&e.dataget("data-button-instance")},getButtons:function(){var i=[];return this._findButtons().each(function(t){var e=$R.dom(t);i.push(e.dataget("data-button-instance"))}),i},getButtonsKeys:function(){var i=[];return this._findButtons().each(function(t){var e=$R.dom(t);i.push(e.attr("data-re-name"))}),i},addButton:function(t,e,i,s,n){i=i||"end";var r=$R.create("toolbar.button",this.app,t,e);if(e.observe&&(this.opts.activeButtonsObservers[t]={observe:e.observe,button:r}),this.is())if("first"===i)this.$toolbar.prepend(r);else if("after"===i)s.after(r);else if("before"===i)s.before(r);else{var o=this.opts.buttons.indexOf(t);if(!0!==n&&-1!==o)if(0===o)this.$toolbar.prepend(r);else this._findButtons().eq(o-1).after(r);else this.$toolbar.append(r)}return r},addButtonFirst:function(t,e){return this.addButton(t,e,"first")},addButtonAfter:function(t,e,i){var s=this.getButton(t);return s?this.addButton(e,i,"after",s):this.addButton(e,i)},addButtonBefore:function(t,e,i){var s=this.getButton(t);return s?this.addButton(e,i,"before",s):this.addButton(e,i)},addButtonObserver:function(t,e){this.buttonsObservers[t]=e},setButtons:function(t){this.buttons=t},setDropdown:function(t){this.dropdownOpened=t},setButtonsInactive:function(){for(var t=this.getButtons(),e=0;e
"),this.addClass("re-button re-"+this.name),this.attr("data-re-name",this.name),this.dataset("data-button-instance",this),this.obj.dropdown&&this.setDropdown(this.obj.dropdown)},_buildCallback:function(){this.on("click",this.toggle.bind(this))},_buildAttributes:function(){var t={href:"#",alt:this.obj.tooltip,rel:this.name,role:"button","aria-label":this.obj.tooltip,tabindex:"-1"};this.attr(t)},_buildObserver:function(){void 0!==this.obj.observe&&this.toolbar.addButtonObserver(this.name,this.obj.observe)},_buildIcon:function(){var t=this.obj.icon,e=/(<([^>]+)>)/gi.test(t);this.$icon=e?$R.dom(t):$R.dom(""),e||this.$icon.addClass("re-icon-"+this.name),this.append(this.$icon),this.attr("data-re-icon",!0),this.addClass("re-button-icon")},_buildTooltip:function(){this.detector.isDesktop()&&(this.tooltip=$R.create("toolbar.button.tooltip",this.app,this))}}),$R.add("class","toolbar.button.tooltip",{mixins:["dom"],init:function(t,e){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.$body=t.$body,this.toolbar=t.toolbar,this.$button=e,this.created=!1,this._init()},open:function(){if(!this.$button.hasClass("redactor-button-disabled")&&!this.$button.hasClass("redactor-button-active")){this.created=!0,this.parse(""),this.addClass("re-button-tooltip re-button-tooltip-"+this.uuid),this.$body.append(this),this.html(this.$button.attr("alt"));var t=this.$button.offset(),e=this.$button.height(),i=this.$button.width();this.css({top:t.top+e+4+"px",left:t.left+i/2-this.width()/2+"px",position:"absolute"}),this.show()}},close:function(){this.created&&!this.$button.hasClass("redactor-button-disabled")&&(this.remove(),this.created=!1)},_init:function(){this.$button.on("mouseover",this.open.bind(this)),this.$button.on("mouseout",this.close.bind(this))}}),$R.add("class","toolbar.dropdown",{mixins:["dom"],init:function(t,e,i){this.app=t,this.uuid=t.uuid,this.opts=t.opts,this.$win=t.$win,this.$doc=t.$doc,this.$body=t.$body,this.animate=t.animate,this.toolbar=t.toolbar,this.name=e,this.started=!1,this.items="format"===e?$R.extend({},!0,i):i,this.$items=[]},toggle:function(t){this.started||this._build(),this.isOpened()&&this.isActive()?this.close(!1):this.open(t)},isOpened:function(){var t=this.$body.find(".redactor-dropdown-"+this.uuid+".open");return 0!==t.length&&t.attr("data-re-name")===this.name},isActive:function(){return 0!==this.$body.find("#redactor-dropdown-"+this.uuid+"-"+this.name+".open").length},getName:function(){return this.attr("data-re-name")},getItem:function(t){return this.$items[t]},getItemsByClass:function(t){var e=[];for(var i in this.$items){var s=this.$items[i];"object"==typeof s&&s.attr("data-re-name")&&s.hasClass(t)&&e.push(s)}return e},open:function(t){this._closeAll(),this.$btn=this.toolbar.getButton(this.name),this.app.broadcast("dropdown.open",t,this,this.$btn),this.toolbar.setDropdown(this),this.show(),this.removeClass("redactor-animate-hide"),this.addClass("open"),this._observe(),this.$btn.hideTooltip(),this.$btn.setActive(),this.$doc.on("keyup.redactor.dropdown-"+this.uuid,this._handleKeyboard.bind(this)),this.$doc.on("click.redactor.dropdown-"+this.uuid,this.close.bind(this)),this.updatePosition(),this.app.broadcast("dropdown.opened",t,this,this.$btn)},close:function(t,e){if(t){var i=$R.dom(t.target);if(this._isButton(t)||i.hasClass("redactor-dropdown-not-close")||i.hasClass("redactor-dropdown-item-disabled"))return void t.preventDefault()}this.app.broadcast("dropdown.close",this,this.$btn),this.toolbar.setDropdown(!1),this.$btn.setInactive(),!1===e?this._close():this.animate.start(this,"fadeOut",this._close.bind(this))},updatePosition:function(){this.toolbar.isFixed(),this.toolbar.isTarget();var t=this.$btn.height(),e=this.$btn.width(),i=this.$btn.offset(),s=i.left+0,n=parseFloat(this.css("width")),r=s-(this.$win.width()"),this.attr("dir",this.opts.direction),this.attr("id","redactor-dropdown-"+this.uuid+"-"+this.name),this.attr("data-re-name",this.name),this.addClass("redactor-dropdown redactor-dropdown-"+this.uuid+" redactor-dropdown-"+this.name),this.dataset("data-dropdown-instance",this),this.items.sdom||"string"==typeof this.items?this._buildDom():this._buildItems(),this.$body.append(this),this.started=!0},_buildDom:function(){this.html("").append($R.dom(this.items))},_buildItems:function(){for(var t in this.items="format"===this.name?this._buildFormattingItems():this.items,this.items){var e=this.items[t];if("observe"===t)this.attr("data-observe",this.items[t]);else{var i=$R.create("toolbar.dropdown.item",this.app,t,e,this);this.$items[t]=i,this.append(i)}}},_buildFormattingItems:function(){for(var t in this.items)-1===this.opts.formatting.indexOf(t)&&delete this.items[t];if(this.opts.formattingHide)for(var t in this.items)-1!==this.opts.formattingHide.indexOf(t)&&delete this.items[t];if(this.opts.formattingAdd)for(var t in this.opts.formattingAdd)this.items[t]=this.opts.formattingAdd[t];return this.items},_handleKeyboard:function(t){27===t.which&&this.close()},_isButton:function(t){return $R.dom(t.target).closest(".re-button").get()===this.$btn.get()},_close:function(){this.$btn.setInactive(),this.$doc.off(".redactor.dropdown-"+this.uuid),this.removeClass("open"),this.addClass("redactor-animate-hide"),this.app.broadcast("dropdown.closed",this,this.$btn)},_closeAll:function(){this.$body.find(".redactor-dropdown-"+this.uuid+".open").each(function(t){$R.dom(t).dataget("data-dropdown-instance")._close()})},_observe:function(){var t=this.attr("data-observe");t&&this.app.broadcast("dropdown."+t+".observe",this)}}),$R.add("class","toolbar.dropdown.item",{mixins:["dom"],init:function(t,e,i,s){this.app=t,this.lang=t.lang,this.dropdown=s,this.name=e,this.obj=i,this._init()},setTitle:function(t){this.$span.html(t)},getTitle:function(){return this.$span.html()},enable:function(){this.removeClass("redactor-dropdown-item-disabled")},disable:function(){this.addClass("redactor-dropdown-item-disabled")},toggle:function(t){t&&t.preventDefault(),this.hasClass("redactor-dropdown-item-disabled")||(this.obj.message?this.app.broadcast(this.obj.message,this.obj.args,this.name):this.obj.api&&this.app.api(this.obj.api,this.obj.args,this.name))},_init:function(){this.parse(""),this.attr("href","#"),this.addClass("redactor-dropdown-item-"+this.name),this.obj.classname&&this.addClass(this.obj.classname),this.attr("data-re-name",this.name),this.on("click",this.toggle.bind(this)),this.$span=$R.dom(""),this.append(this.$span),this.setTitle(this.lang.parse(this.obj.title))}}),$R.add("service","cleaner",{init:function(t){this.app=t,this.opts=t.opts,this.storedComponents=[],this.storedComments=[],this.storedImages=[],this.storedLinks=[],this.deniedTags=["font","html","head","link","title","body","meta","applet"],this.convertRules={},this.unconvertRules={},this.reComments=/\n?/g,this.reSpacedEmpty=/^(||\s||
|| )$/i,this.reScriptTag=/