(function(){var a={ol:1,ul:1},b=CKEDITOR.dom.walker.whitespaces(true),c=CKEDITOR.dom.walker.bookmark(false,true);function d(k,l){k.getCommand(this.name).setState(l);};function e(k){var t=this;var l=k.editor,m=k.data.path,n=m&&m.contains(a);if(n)return d.call(t,l,CKEDITOR.TRISTATE_OFF);if(!t.useIndentClasses&&t.name=='indent')return d.call(t,l,CKEDITOR.TRISTATE_OFF);var o=k.data.path,p=o.block||o.blockLimit;if(!p)return d.call(t,l,CKEDITOR.TRISTATE_DISABLED);if(t.useIndentClasses){var q=p.$.className.match(t.classNameRegex),r=0;if(q){q=q[1];r=t.indentClassMap[q];}if(t.name=='outdent'&&!r||t.name=='indent'&&r==l.config.indentClasses.length)return d.call(t,l,CKEDITOR.TRISTATE_DISABLED);return d.call(t,l,CKEDITOR.TRISTATE_OFF);}else{var s=parseInt(p.getStyle(t.indentCssProperty),10);if(isNaN(s))s=0;if(s<=0)return d.call(t,l,CKEDITOR.TRISTATE_DISABLED);return d.call(t,l,CKEDITOR.TRISTATE_OFF);}};function f(k,l,m){var n=l.startContainer,o=l.endContainer;while(n&&!n.getParent().equals(m))n=n.getParent();while(o&&!o.getParent().equals(m))o=o.getParent();if(!n||!o)return;var p=n,q=[],r=false;while(!r){if(p.equals(o))r=true;q.push(p);p=p.getNext();}if(q.length<1)return;var s=m.getParents(true);for(var t=0;t<s.length;t++){if(s[t].getName&&a[s[t].getName()]){m=s[t];break;}}var u=this.name=='indent'?1:-1,v=q[0],w=q[q.length-1],x={},y=CKEDITOR.plugins.list.listToArray(m,x),z=y[w.getCustomData('listarray_index')].indent;for(t=v.getCustomData('listarray_index');t<=w.getCustomData('listarray_index');t++){y[t].indent+=u;var A=y[t].parent;y[t].parent=new CKEDITOR.dom.element(A.getName(),A.getDocument());}for(t=w.getCustomData('listarray_index')+1;t<y.length&&y[t].indent>z;t++)y[t].indent+=u;var B=CKEDITOR.plugins.list.arrayToList(y,x,null,k.config.enterMode,0);if(this.name=='outdent'){var C;if((C=m.getParent())&&C.is('li')){var D=B.listNode.getChildren(),E=[],F=D.count(),G;for(t=F-1;t>=0;t--){if((G=D.getItem(t))&&G.is&&G.is('li'))E.push(G);}}}if(B)B.listNode.replace(m);if(E&&E.length)for(t=0;t<E.length;t++){var H=E[t],I=H;while((I=I.getNext())&&I.is&&I.getName() in a){if(CKEDITOR.env.ie&&!H.getFirst(function(J){return b(J)&&c(J);}))H.append(l.document.createText('\xa0'));H.append(I);}H.insertAfter(C);}CKEDITOR.dom.element.clearAllMarkers(x);};function g(k,l){var m=l.createIterator(),n=k.config.enterMode;m.enforceRealBlocks=true;m.enlargeBr=n!=CKEDITOR.ENTER_BR;var o;while(o=m.getNextParagraph())h.call(this,k,o);};function h(k,l){var q=this;if(q.useIndentClasses){var m=l.$.className.match(q.classNameRegex),n=0;
if(m){m=m[1];n=q.indentClassMap[m];}if(q.name=='outdent')n--;else n++;if(n<0)return false;n=Math.min(n,k.config.indentClasses.length);n=Math.max(n,0);var o=CKEDITOR.tools.ltrim(l.$.className.replace(q.classNameRegex,''));if(n<1)l.$.className=o;else l.addClass(k.config.indentClasses[n-1]);}else{var p=parseInt(l.getStyle(q.indentCssProperty),10);if(isNaN(p))p=0;p+=(q.name=='indent'?1:-1)*k.config.indentOffset;if(p<0)return false;p=Math.max(p,0);p=Math.ceil(p/k.config.indentOffset)*k.config.indentOffset;l.setStyle(q.indentCssProperty,p?p+k.config.indentUnit:'');if(l.getAttribute('style')==='')l.removeAttribute('style');}return true;};function i(k,l){var n=this;n.name=l;n.useIndentClasses=k.config.indentClasses&&k.config.indentClasses.length>0;if(n.useIndentClasses){n.classNameRegex=new RegExp('(?:^|\\s+)('+k.config.indentClasses.join('|')+')(?=$|\\s)');n.indentClassMap={};for(var m=0;m<k.config.indentClasses.length;m++)n.indentClassMap[k.config.indentClasses[m]]=m+1;}else n.indentCssProperty=k.config.contentsLangDirection=='ltr'?'margin-left':'margin-right';n.startDisabled=l=='outdent';};function j(k){return k.type=CKEDITOR.NODE_ELEMENT&&k.is('li');};i.prototype={exec:function(k){var l=k.getSelection(),m=l&&l.getRanges()[0],n=m.startContainer,o=m.endContainer,p=m.getCommonAncestor(),q=p;while(q&&!(q.type==CKEDITOR.NODE_ELEMENT&&a[q.getName()]))q=q.getParent();if(q&&n.type==CKEDITOR.NODE_ELEMENT&&n.getName() in a){var r=new CKEDITOR.dom.walker(m);r.evaluator=j;m.startContainer=r.next();}if(q&&o.type==CKEDITOR.NODE_ELEMENT&&o.getName() in a){r=new CKEDITOR.dom.walker(m);r.evaluator=j;m.endContainer=r.previous();}var s=l.createBookmarks(true);if(q){var t=q.getFirst(function(w){return w.type==CKEDITOR.NODE_ELEMENT&&w.is('li');}),u=m.startContainer,v=t.equals(u)||t.contains(u);if(!(v&&h.call(this,k,q)))f.call(this,k,m,q);}else g.call(this,k,m);k.focus();k.forceNextSelectionCheck();l.selectBookmarks(s);}};CKEDITOR.plugins.add('indent',{init:function(k){var l=new i(k,'indent'),m=new i(k,'outdent');k.addCommand('indent',l);k.addCommand('outdent',m);k.ui.addButton('Indent',{label:k.lang.indent,command:'indent'});k.ui.addButton('Outdent',{label:k.lang.outdent,command:'outdent'});k.on('selectionChange',CKEDITOR.tools.bind(e,l));k.on('selectionChange',CKEDITOR.tools.bind(e,m));if(CKEDITOR.env.ie6Compat||CKEDITOR.env.ie7Compat)k.addCss('ul,ol{\tmargin-left: 0px;\tpadding-left: 40px;}');},requires:['domiterator','list']});})();CKEDITOR.tools.extend(CKEDITOR.config,{indentOffset:40,indentUnit:'px',indentClasses:null});
