(function(){var a='cke_show_border',b,c=(CKEDITOR.env.ie6Compat?['.%1 table.%2,','.%1 table.%2 td, .%1 table.%2 th,','{','border : #d3d3d3 1px dotted','}']:['.%1 table.%2,','.%1 table.%2 > tr > td, .%1 table.%2 > tr > th,','.%1 table.%2 > tbody > tr > td, .%1 table.%2 > tbody > tr > th,','.%1 table.%2 > thead > tr > td, .%1 table.%2 > thead > tr > th,','.%1 table.%2 > tfoot > tr > td, .%1 table.%2 > tfoot > tr > th','{','border : #d3d3d3 1px dotted','}']).join('');b=c.replace(/%2/g,a).replace(/%1/g,'cke_show_borders ');var d={preserveState:true,editorFocus:false,readOnly:1,exec:function(e){this.toggleState();this.refresh(e);},refresh:function(e){if(e.document){var f=this.state==CKEDITOR.TRISTATE_ON?'addClass':'removeClass';e.document.getBody()[f]('cke_show_borders');}}};CKEDITOR.plugins.add('showborders',{requires:['wysiwygarea'],modes:{wysiwyg:1},init:function(e){var f=e.addCommand('showborders',d);f.canUndo=false;if(e.config.startupShowBorders!==false)f.setState(CKEDITOR.TRISTATE_ON);e.addCss(b);e.on('mode',function(){if(f.state!=CKEDITOR.TRISTATE_DISABLED)f.refresh(e);},null,null,100);e.on('contentDom',function(){if(f.state!=CKEDITOR.TRISTATE_DISABLED)f.refresh(e);});e.on('removeFormatCleanup',function(g){var h=g.data;if(e.getCommand('showborders').state==CKEDITOR.TRISTATE_ON&&h.is('table')&&(!h.hasAttribute('border')||parseInt(h.getAttribute('border'),10)<=0))h.addClass(a);});},afterInit:function(e){var f=e.dataProcessor,g=f&&f.dataFilter,h=f&&f.htmlFilter;if(g)g.addRules({elements:{table:function(i){var j=i.attributes,k=j['class'],l=parseInt(j.border,10);if(!l||l<=0)j['class']=(k||'')+' '+a;}}});if(h)h.addRules({elements:{table:function(i){var j=i.attributes,k=j['class'];k&&(j['class']=k.replace(a,'').replace(/\s{2}/,' ').replace(/^\s+|\s+$/,''));}}});}});CKEDITOR.on('dialogDefinition',function(e){var f=e.data.name;if(f=='table'||f=='tableProperties'){var g=e.data.definition,h=g.getContents('info'),i=h.get('txtBorder'),j=i.commit;i.commit=CKEDITOR.tools.override(j,function(m){return function(n,o){m.apply(this,arguments);var p=parseInt(this.getValue(),10);o[!p||p<=0?'addClass':'removeClass'](a);};});var k=g.getContents('advanced'),l=k&&k.get('advCSSClasses');if(l){l.setup=CKEDITOR.tools.override(l.setup,function(m){return function(){m.apply(this,arguments);this.setValue(this.getValue().replace(/cke_show_border/,''));};});l.commit=CKEDITOR.tools.override(l.commit,function(m){return function(n,o){m.apply(this,arguments);if(!parseInt(o.getAttribute('border'),10))o.addClass('cke_show_border');
};});}}});})();
