1(function(){var e=CKEDITOR.tools.cssLength;var b=function(f){var g=this.id;if(!f.info){f.info={}}f.info[g]=this.getValue()};function a(n){var k=0,h=0;for(var g=0,o,p=n.$.rows.length;g<p;g++){o=n.$.rows[g],k=0;for(var f=0,l,m=o.cells.length;f<m;f++){l=o.cells[f];k+=l.colSpan}k>h&&(h=k)}return h}function d(f){return function(){var h=this.getValue(),g=!!(CKEDITOR.dialog.validate.integer()(h)&&h>0);if(!g){alert(f);this.select()}return g}}function c(h,j){var f=function(k){return new CKEDITOR.dom.element(k,h.document)};var g=h.editable();var i;return{title:h.lang.table.title,minWidth:310,minHeight:CKEDITOR.env.ie?310:280,onLoad:function(){var k=this;var l},onShow:function(){var q=h.getSelection(),m=q.getRanges(),r;var l=this.getContentElement("info","txtRows"),o=this.getContentElement("info","txtCols"),n=this.getContentElement("info","txtWidth"),k=this.getContentElement("info","txtHeight");if(j=="tableProperties"){var p=q.getSelectedElement();if(p&&p.is("table")){r=p}else{if(m.length>0){if(CKEDITOR.env.webkit){m[0].shrink(CKEDITOR.NODE_ELEMENT)}r=h.elementPath(m[0].getCommonAncestor(true)).contains("table",1)}}this._.selectedElement=r}if(r){this.setupContent(r);l&&l.disable();o&&o.disable()}else{l&&l.enable();o&&o.enable()}},onOk:function(){var D=h.getSelection(),z=this._.selectedElement&&D.createBookmarks();var x=this._.selectedElement||f("table"),B=this,C={};this.commitContent(C,x);if(C.info){var y=C.info;if(!this._.selectedElement){var k=x.append(f("tbody")),r=parseInt(y.txtRows,10)||0,s=parseInt(y.txtCols,10)||0;for(var v=0;v<r;v++){var q=k.append(f("tr"));for(var u=0;u<s;u++){var m=q.append(f("td"));m.appendBogus()}}}var o=y.selHeaders;if(!x.$.tHead&&(o=="row"||o=="both")){var w=new CKEDITOR.dom.element(x.$.createTHead());k=x.getElementsByTag("tbody").getItem(0);var n=k.getElementsByTag("tr").getItem(0);for(v=0;v<n.getChildCount();v++){var p=n.getChild(v);if(p.type==CKEDITOR.NODE_ELEMENT&&!p.data("cke-bookmark")){p.renameNode("th");p.setAttribute("scope","col")}}w.append(n.remove())}if(x.$.tHead!==null&&!(o=="row"||o=="both")){w=new CKEDITOR.dom.element(x.$.tHead);k=x.getElementsByTag("tbody").getItem(0);var l=k.getFirst();while(w.getChildCount()>0){n=w.getFirst();for(v=0;v<n.getChildCount();v++){var t=n.getChild(v);if(t.type==CKEDITOR.NODE_ELEMENT){t.renameNode("td");t.removeAttribute("scope")}}n.insertBefore(l)}w.remove()}if(!this.hasColumnHeaders&&(o=="col"||o=="both")){for(q=0;q<x.$.rows.length;q++){t=new CKEDITOR.dom.element(x.$.rows[q].cells[0]);t.renameNode("th");t.setAttribute("scope","row")}}if((this.hasColumnHeaders)&&!(o=="col"||o=="both")){for(v=0;v<x.$.rows.length;v++){q=new CKEDITOR.dom.element(x.$.rows[v]);if(q.getParent().getName()=="tbody"){t=new CKEDITOR.dom.element(q.$.cells[0]);t.renameNode("td");t.removeAttribute("scope")}}}y.txtHeight?x.setStyle("height",y.txtHeight):x.removeStyle("height");y.txtWidth?x.setStyle("width",y.txtWidth):x.removeStyle("width");if(!x.getAttribute("style")){x.removeAttribute("style")}}if(!this._.selectedElement){h.insertElement(x);setTimeout(function(){var F=new CKEDITOR.dom.element(x.$.rows[0].cells[0]);var E=h.createRange();E.moveToPosition(F,CKEDITOR.POSITION_AFTER_START);E.select()},0)}else{try{D.selectBookmarks(z)}catch(A){}}},contents:[{id:"info",label:h.lang.table.title,elements:[{type:"hbox",widths:[null,null],styles:["vertical-align:top"],children:[{type:"vbox",padding:0,children:[{type:"text",id:"txtRows","default":3,label:h.lang.table.rows,required:true,controlStyle:"width:5em",validate:d(h.lang.table.invalidRows),setup:function(k){this.setValue(k.$.rows.length)},commit:b},{type:"text",id:"txtCols","default":2,label:h.lang.table.columns,required:true,controlStyle:"width:5em",validate:d(h.lang.table.invalidCols),setup:function(k){this.setValue(a(k))},commit:b},{type:"html",html:"&nbsp;"},{type:"select",id:"selHeaders",requiredContent:"th","default":"",label:h.lang.table.headers,items:[[h.lang.table.headersNone,""],[h.lang.table.headersRow,"row"],[h.lang.table.headersColumn,"col"],[h.lang.table.headersBoth,"both"]],setup:function(l){var m=this.getDialog();m.hasColumnHeaders=true;for(var n=0;n<l.$.rows.length;n++){var k=l.$.rows[n].cells[0];if(k&&k.nodeName.toLowerCase()!="th"){m.hasColumnHeaders=false;break}}if((l.$.tHead!==null)){this.setValue(m.hasColumnHeaders?"both":"row")}else{this.setValue(m.hasColumnHeaders?"col":"")}},commit:b},{type:"text",id:"txtBorder",hidden:true,"default":1,label:h.lang.table.border,controlStyle:"width:3em",commit:function(l,k){}},{id:"cmbAlign",type:"select",hidden:true,"default":"",label:h.lang.common.align,items:[[h.lang.common.notSet,""],[h.lang.common.alignLeft,"left"],[h.lang.common.alignCenter,"center"],[h.lang.common.alignRight,"right"]],setup:function(k){this.setValue(k.getAttribute("align")||"")},commit:function(l,k){if(this.getValue()){k.setAttribute("align",this.getValue())}else{k.removeAttribute("align")}}}]},{type:"vbox",padding:0,children:[{type:"hbox",widths:["5em"],children:[{type:"text",id:"txtWidth",hidden:true,controlStyle:"width:5em",label:h.lang.common.width,title:h.lang.common.cssLengthTooltip,"default":h.filter.check("table{width}")?(g.getSize("width")<500?"100%":500):0,getValue:e,validate:CKEDITOR.dialog.validate.cssLength(h.lang.common.invalidCssLength.replace("%1",h.lang.common.width)),onChange:function(){var k=this.getDialog().getContentElement("advanced","advStyles");k&&k.updateStyle("width",this.getValue())},setup:function(k){var l=k.getStyle("width");this.setValue(l)},commit:b}]},{type:"hbox",widths:["5em"],children:[{type:"text",id:"txtHeight",hidden:true,controlStyle:"width:5em",label:h.lang.common.height,title:h.lang.common.cssLengthTooltip,setup:function(k){},commit:b}]},{type:"html",html:"&nbsp;"},{type:"text",id:"txtCellSpace",hidden:true,setup:function(k){},commit:function(l,k){}}]}]}]}]}}CKEDITOR.dialog.add("table",function(f){return c(f,"table")});CKEDITOR.dialog.add("tableProperties",function(f){return c(f,"tableProperties")})})();