(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,exec:function(e){this.toggleState();this.refresh(e);},refresh:function(e){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);});},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(k){return function(l,m){k.apply(this,arguments);var n=parseInt(this.getValue(),10);m[!n||n<=0?'addClass':'removeClass'](a);};});}});})();
