!function(){function t(t,e){var s;if(e)s=t.getComputedStyle("text-align");else{for(;(!t.hasAttribute||!t.hasAttribute("align")&&!t.getStyle("text-align"))&&(s=t.getParent());)t=s;s=t.getStyle("text-align")||t.getAttribute("align")||""}return s&&(s=s.replace(/(?:-(?:moz|webkit)-)?(?:start|auto)/i,"")),!s&&e&&(s="rtl"==t.getComputedStyle("direction")?"right":"left"),s}function e(t,e,s){this.editor=t,this.name=e,this.value=s,this.context="p",e=t.config.justifyClasses;var a=t.config.enterMode==NEW_CKEDITOR.ENTER_P?"p":"div";if(e){switch(s){case"left":this.cssClassName=e[0];break;case"center":this.cssClassName=e[1];break;case"right":this.cssClassName=e[2];break;case"justify":this.cssClassName=e[3]}this.cssClassRegex=new RegExp("(?:^|\\s+)(?:"+e.join("|")+")(?=$|\\s)"),this.requiredContent=a+"("+this.cssClassName+")"}else this.requiredContent=a+"{text-align}";this.allowedContent={"caption div h1 h2 h3 h4 h5 h6 p pre td th li":{propertiesOnly:!0,styles:this.cssClassName?null:"text-align",classes:this.cssClassName||null}},t.config.enterMode==NEW_CKEDITOR.ENTER_BR&&(this.allowedContent.div=!0)}function s(t){var e=t.editor,s=e.createRange();s.setStartBefore(t.data.node),s.setEndAfter(t.data.node);for(var a,i=new NEW_CKEDITOR.dom.walker(s);a=i.next();)if(a.type==NEW_CKEDITOR.NODE_ELEMENT)if(!a.equals(t.data.node)&&a.getDirection())s.setStartAfter(a),i=new NEW_CKEDITOR.dom.walker(s);else{var l=e.config.justifyClasses;l&&(a.hasClass(l[0])?(a.removeClass(l[0]),a.addClass(l[2])):a.hasClass(l[2])&&(a.removeClass(l[2]),a.addClass(l[0]))),"left"==(l=a.getStyle("text-align"))?a.setStyle("text-align","right"):"right"==l&&a.setStyle("text-align","left")}}e.prototype={exec:function(e){var s=e.getSelection(),a=e.config.enterMode;if(s){for(var i,l,n=s.createBookmarks(),o=s.getRanges(),r=this.cssClassName,c=e.config.useComputedState,g=o.length-1;0<=g;g--)for((i=o[g].createIterator()).enlargeBr=a!=NEW_CKEDITOR.ENTER_BR;l=i.getNextParagraph(a==NEW_CKEDITOR.ENTER_P?"p":"div");)if(!l.isReadOnly()){var d,f=l.getName();if(d=e.activeFilter.check(f+"{text-align}"),(f=e.activeFilter.check(f+"("+r+")"))||d){l.removeAttribute("align"),l.removeStyle("text-align");var u=r&&(l.$.className=NEW_CKEDITOR.tools.ltrim(l.$.className.replace(this.cssClassRegex,""))),h=this.state==NEW_CKEDITOR.TRISTATE_OFF&&(!c||t(l,!0)!=this.value);r&&f?h?l.addClass(r):u||l.removeAttribute("class"):h&&d&&l.setStyle("text-align",this.value)}}e.focus(),e.forceNextSelectionCheck(),s.selectBookmarks(n)}},refresh:function(e,s){var a=s.block||s.blockLimit,i=a.getName(),l=a.equals(e.editable());i=this.cssClassName?e.activeFilter.check(i+"("+this.cssClassName+")"):e.activeFilter.check(i+"{text-align}");l&&!NEW_CKEDITOR.dtd.$list[s.lastElement.getName()]?this.setState(NEW_CKEDITOR.TRISTATE_OFF):!l&&i?this.setState(t(a,this.editor.config.useComputedState)==this.value?NEW_CKEDITOR.TRISTATE_ON:NEW_CKEDITOR.TRISTATE_OFF):this.setState(NEW_CKEDITOR.TRISTATE_DISABLED)}},NEW_CKEDITOR.plugins.add("justify",{icons:"justifyblock,justifycenter,justifyleft,justifyright",hidpi:!0,init:function(t){if(!t.blockless){var a=new e(t,"justifyleft","left"),i=new e(t,"justifycenter","center"),l=new e(t,"justifyright","right"),n=new e(t,"justifyblock","justify");t.addCommand("justifyleft",a),t.addCommand("justifycenter",i),t.addCommand("justifyright",l),t.addCommand("justifyblock",n),t.ui.addButton&&(t.ui.addButton("JustifyLeft",{isToggle:!0,label:t.lang.common.alignLeft,command:"justifyleft",toolbar:"align,10"}),t.ui.addButton("JustifyCenter",{isToggle:!0,label:t.lang.common.center,command:"justifycenter",toolbar:"align,20"}),t.ui.addButton("JustifyRight",{isToggle:!0,label:t.lang.common.alignRight,command:"justifyright",toolbar:"align,30"}),t.ui.addButton("JustifyBlock",{isToggle:!0,label:t.lang.common.justify,command:"justifyblock",toolbar:"align,40"})),t.on("dirChanged",s)}}})}();