text: /*
  Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
  For licensing, see LICENSE.html or http://ckeditor.com/license
  */
  !function(){function e(e){for(var t,i=0,n=0,a=0,o=e.$.rows.length;o>a;a++){t=e.$.rows[a],i=0;for(var r,s=0,l=t.cells.length;l>s;s++)r=t.cells[s],i+=r.colSpan;i>n&&(n=i)}return n}function t(e){return function(){var t=this.getValue(),i=!!(CKEDITOR.dialog.validate.integer()(t)&&t>0);return i||(alert(e),this.select()),i}}function i(i,o){var r=function(e){return new CKEDITOR.dom.element(e,i.document)},s=i.plugins.dialogadvtab;return{title:i.lang.table.title,minWidth:310,minHeight:CKEDITOR.env.ie?310:280,onLoad:function(){var e=this,t=e.getContentElement("advanced","advStyles");t&&t.on("change",function(){var t=this.getStyle("width",""),i=e.getContentElement("info","txtWidth");i&&i.setValue(t,!0);var n=this.getStyle("height",""),a=e.getContentElement("info","txtHeight");a&&a.setValue(n,!0)})},onShow:function(){var e=this,t=i.getSelection(),n=t.getRanges(),a=null,r=e.getContentElement("info","txtRows"),s=e.getContentElement("info","txtCols"),l=e.getContentElement("info","txtWidth"),c=e.getContentElement("info","txtHeight");if("tableProperties"==o){if(a=t.getSelectedElement())a=a.getAscendant("table",!0);else if(n.length>0){CKEDITOR.env.webkit&&n[0].shrink(CKEDITOR.NODE_ELEMENT);var d=n[0].getCommonAncestor(!0);a=d.getAscendant("table",!0)}e._.selectedElement=a}a?(e.setupContent(a),r&&r.disable(),s&&s.disable()):(r&&r.enable(),s&&s.enable()),l&&l.onChange(),c&&c.onChange()},onOk:function(){var e=i.getSelection(),t=this._.selectedElement&&e.createBookmarks(),n=this._.selectedElement||r("table"),a={};if(this.commitContent(a,n),a.info){var o=a.info;if(!this._.selectedElement)for(var s=n.append(r("tbody")),l=parseInt(o.txtRows,10)||0,c=parseInt(o.txtCols,10)||0,d=0;l>d;d++)for(var u=s.append(r("tr")),h=0;c>h;h++){var p=u.append(r("td"));CKEDITOR.env.ie||p.append(r("br"))}var m=o.selHeaders;if(!n.$.tHead&&("row"==m||"both"==m)){var f=new CKEDITOR.dom.element(n.$.createTHead());s=n.getElementsByTag("tbody").getItem(0);var g=s.getElementsByTag("tr").getItem(0);for(d=0;d<g.getChildCount();d++){var v=g.getChild(d);v.type!=CKEDITOR.NODE_ELEMENT||v.data("cke-bookmark")||(v.renameNode("th"),v.setAttribute("scope","col"))}f.append(g.remove())}if(null!==n.$.tHead&&"row"!=m&&"both"!=m){f=new CKEDITOR.dom.element(n.$.tHead),s=n.getElementsByTag("tbody").getItem(0);for(var b=s.getFirst();f.getChildCount()>0;){for(g=f.getFirst(),d=0;d<g.getChildCount();d++){var y=g.getChild(d);y.type==CKEDITOR.NODE_ELEMENT&&(y.renameNode("td"),y.removeAttribute("scope"))}g.insertBefore(b)}f.remove()}if(!this.hasColumnHeaders&&("col"==m||"both"==m))for(u=0;u<n.$.rows.length;u++)y=new CKEDITOR.dom.element(n.$.rows[u].cells[0]),y.renameNode("th"),y.setAttribute("scope","row");if(this.hasColumnHeaders&&"col"!=m&&"both"!=m)for(d=0;d<n.$.rows.length;d++)u=new CKEDITOR.dom.element(n.$.rows[d]),"tbody"==u.getParent().getName()&&(y=new CKEDITOR.dom.element(u.$.cells[0]),y.renameNode("td"),y.removeAttribute("scope"));o.txtHeight?n.setStyle("height",o.txtHeight):n.removeStyle("height"),o.txtWidth?n.setStyle("width",o.txtWidth):n.removeStyle("width"),n.getAttribute("style")||n.removeAttribute("style")}if(this._.selectedElement)try{e.selectBookmarks(t)}catch(k){}else i.insertElement(n),setTimeout(function(){var e=new CKEDITOR.dom.element(n.$.rows[0].cells[0]),t=new CKEDITOR.dom.range(i.document);t.moveToPosition(e,CKEDITOR.POSITION_AFTER_START),t.select(1)},0)},contents:[{id:"info",label:i.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:i.lang.table.rows,required:!0,controlStyle:"width:5em",validate:t(i.lang.table.invalidRows),setup:function(e){this.setValue(e.$.rows.length)},commit:a},{type:"text",id:"txtCols","default":2,label:i.lang.table.columns,required:!0,controlStyle:"width:5em",validate:t(i.lang.table.invalidCols),setup:function(t){this.setValue(e(t))},commit:a},{type:"html",html:"&nbsp;"},{type:"select",id:"selHeaders","default":"",label:i.lang.table.headers,items:[[i.lang.table.headersNone,""],[i.lang.table.headersRow,"row"],[i.lang.table.headersColumn,"col"],[i.lang.table.headersBoth,"both"]],setup:function(e){var t=this.getDialog();t.hasColumnHeaders=!0;for(var i=0;i<e.$.rows.length;i++){var n=e.$.rows[i].cells[0];if(n&&"th"!=n.nodeName.toLowerCase()){t.hasColumnHeaders=!1;break}}null!==e.$.tHead?this.setValue(t.hasColumnHeaders?"both":"row"):this.setValue(t.hasColumnHeaders?"col":"")},commit:a},{type:"text",id:"txtBorder","default":1,label:i.lang.table.border,controlStyle:"width:3em",validate:CKEDITOR.dialog.validate.number(i.lang.table.invalidBorder),setup:function(e){this.setValue(e.getAttribute("border")||"")},commit:function(e,t){this.getValue()?t.setAttribute("border",this.getValue()):t.removeAttribute("border")}},{id:"cmbAlign",type:"select","default":"",label:i.lang.common.align,items:[[i.lang.common.notSet,""],[i.lang.common.alignLeft,"left"],[i.lang.common.alignCenter,"center"],[i.lang.common.alignRight,"right"]],setup:function(e){this.setValue(e.getAttribute("align")||"")},commit:function(e,t){this.getValue()?t.setAttribute("align",this.getValue()):t.removeAttribute("align")}}]},{type:"vbox",padding:0,children:[{type:"hbox",widths:["5em"],children:[{type:"text",id:"txtWidth",controlStyle:"width:5em",label:i.lang.common.width,title:i.lang.common.cssLengthTooltip,"default":500,getValue:n,validate:CKEDITOR.dialog.validate.cssLength(i.lang.common.invalidCssLength.replace("%1",i.lang.common.width)),onChange:function(){var e=this.getDialog().getContentElement("advanced","advStyles");e&&e.updateStyle("width",this.getValue())},setup:function(e){var t=e.getStyle("width");t&&this.setValue(t)},commit:a}]},{type:"hbox",widths:["5em"],children:[{type:"text",id:"txtHeight",controlStyle:"width:5em",label:i.lang.common.height,title:i.lang.common.cssLengthTooltip,"default":"",getValue:n,validate:CKEDITOR.dialog.validate.cssLength(i.lang.common.invalidCssLength.replace("%1",i.lang.common.height)),onChange:function(){var e=this.getDialog().getContentElement("advanced","advStyles");e&&e.updateStyle("height",this.getValue())},setup:function(e){var t=e.getStyle("height");t&&this.setValue(t)},commit:a}]},{type:"html",html:"&nbsp;"},{type:"text",id:"txtCellSpace",controlStyle:"width:3em",label:i.lang.table.cellSpace,"default":1,validate:CKEDITOR.dialog.validate.number(i.lang.table.invalidCellSpacing),setup:function(e){this.setValue(e.getAttribute("cellSpacing")||"")},commit:function(e,t){this.getValue()?t.setAttribute("cellSpacing",this.getValue()):t.removeAttribute("cellSpacing")}},{type:"text",id:"txtCellPad",controlStyle:"width:3em",label:i.lang.table.cellPad,"default":1,validate:CKEDITOR.dialog.validate.number(i.lang.table.invalidCellPadding),setup:function(e){this.setValue(e.getAttribute("cellPadding")||"")},commit:function(e,t){this.getValue()?t.setAttribute("cellPadding",this.getValue()):t.removeAttribute("cellPadding")}}]}]},{type:"html",align:"right",html:""},{type:"vbox",padding:0,children:[{type:"text",id:"txtCaption",label:i.lang.table.caption,setup:function(e){var t=this;t.enable();var i=e.getElementsByTag("caption");if(i.count()>0){var n=i.getItem(0),a=n.getFirst(CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT));if(a&&!a.equals(n.getBogus()))return t.disable(),t.setValue(n.getText()),void 0;n=CKEDITOR.tools.trim(n.getText()),t.setValue(n)}},commit:function(e,t){if(this.isEnabled()){var n=this.getValue(),a=t.getElementsByTag("caption");if(n)a.count()>0?(a=a.getItem(0),a.setHtml("")):(a=new CKEDITOR.dom.element("caption",i.document),t.getChildCount()?a.insertBefore(t.getFirst()):a.appendTo(t)),a.append(new CKEDITOR.dom.text(n,i.document));else if(a.count()>0)for(var o=a.count()-1;o>=0;o--)a.getItem(o).remove()}}},{type:"text",id:"txtSummary",label:i.lang.table.summary,setup:function(e){this.setValue(e.getAttribute("summary")||"")},commit:function(e,t){this.getValue()?t.setAttribute("summary",this.getValue()):t.removeAttribute("summary")}}]}]},s&&s.createAdvancedTab(i)]}}var n=CKEDITOR.tools.cssLength,a=function(e){var t=this.id;e.info||(e.info={}),e.info[t]=this.getValue()};CKEDITOR.dialog.add("table",function(e){return i(e,"table")}),CKEDITOR.dialog.add("tableProperties",function(e){return i(e,"tableProperties")})}();