X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=plugins%2Ftable%2Fdialogs%2Ftable.js;h=6c48c20388c8e341d0bec988927422d915a63dea;hb=refs%2Ftags%2Fv3.6.3;hp=d5e244ef566cdb5d5484f76e4a52dd9e7e12ed81;hpb=f0610347140239143439a511ee2bd48cb784f470;p=ckeditor.git diff --git a/plugins/table/dialogs/table.js b/plugins/table/dialogs/table.js index d5e244e..6c48c20 100644 --- a/plugins/table/dialogs/table.js +++ b/plugins/table/dialogs/table.js @@ -1,9 +1,9 @@ /* -Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ -(function(){var a=CKEDITOR.tools.cssLength,b=function(d){var e=this.id;if(!d.info)d.info={};d.info[e]=this.getValue();};function c(d,e){var f=function(h){return new CKEDITOR.dom.element(h,d.document);},g=d.plugins.dialogadvtab;return{title:d.lang.table.title,minWidth:310,minHeight:CKEDITOR.env.ie?310:280,onLoad:function(){var h=this,i=h.getContentElement('advanced','advStyles');if(i)i.on('change',function(j){var k=this.getStyle('width',''),l=h.getContentElement('info','txtWidth');l&&l.setValue(k,true);var m=this.getStyle('height',''),n=h.getContentElement('info','txtHeight');n&&n.setValue(m,true);});},onShow:function(){var p=this;var h=d.getSelection(),i=h.getRanges(),j=null,k=p.getContentElement('info','txtRows'),l=p.getContentElement('info','txtCols'),m=p.getContentElement('info','txtWidth'),n=p.getContentElement('info','txtHeight');if(e=='tableProperties'){if(j=h.getSelectedElement())j=j.getAscendant('table',true);else if(i.length>0){if(CKEDITOR.env.webkit)i[0].shrink(CKEDITOR.NODE_ELEMENT);var o=i[0].getCommonAncestor(true);j=o.getAscendant('table',true);}p._.selectedElement=j;}if(j){p.setupContent(j);k&&k.disable();l&&l.disable();}else{k&&k.enable();l&&l.enable();}m&&m.onChange();n&&n.onChange();},onOk:function(){var h=d.getSelection(),i=this._.selectedElement&&h.createBookmarks(),j=this._.selectedElement||f('table'),k=this,l={};this.commitContent(l,j);if(l.info){var m=l.info;if(!this._.selectedElement){var n=j.append(f('tbody')),o=parseInt(m.txtRows,10)||0,p=parseInt(m.txtCols,10)||0;for(var q=0;q0){w=v.getFirst();for(q=0;q0;if(!h){alert(d.lang.table.invalidRows);this.select();}return h;},setup:function(h){this.setValue(h.$.rows.length);},commit:b},{type:'text',id:'txtCols','default':2,label:d.lang.table.columns,required:true,controlStyle:'width:5em',validate:function(){var h=true,i=this.getValue();h=h&&CKEDITOR.dialog.validate.integer()(i)&&i>0;if(!h){alert(d.lang.table.invalidCols);this.select();}return h;},setup:function(h){this.setValue(h.$.rows[0].cells.length);},commit:b},{type:'html',html:' '},{type:'select',id:'selHeaders','default':'',label:d.lang.table.headers,items:[[d.lang.table.headersNone,''],[d.lang.table.headersRow,'row'],[d.lang.table.headersColumn,'col'],[d.lang.table.headersBoth,'both']],setup:function(h){var i=this.getDialog();i.hasColumnHeaders=true;for(var j=0;j0){var j=i.getItem(0),k=j.getFirst(CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT));if(k&&!k.equals(j.getBogus())){l.disable();l.setValue(j.getText());return;}j=CKEDITOR.tools.trim(j.getText());l.setValue(j);}},commit:function(h,i){if(!this.isEnabled())return;var j=this.getValue(),k=i.getElementsByTag('caption');if(j){if(k.count()>0){k=k.getItem(0);k.setHtml('');}else{k=new CKEDITOR.dom.element('caption',d.document);if(i.getChildCount())k.insertBefore(i.getFirst()); -else k.appendTo(i);}k.append(new CKEDITOR.dom.text(j,d.document));}else if(k.count()>0)for(var l=k.count()-1;l>=0;l--)k.getItem(l).remove();}},{type:'text',id:'txtSummary',label:d.lang.table.summary,setup:function(h){this.setValue(h.getAttribute('summary')||'');},commit:function(h,i){if(this.getValue())i.setAttribute('summary',this.getValue());else i.removeAttribute('summary');}}]}]},g&&g.createAdvancedTab(d)]};};CKEDITOR.dialog.add('table',function(d){return c(d,'table');});CKEDITOR.dialog.add('tableProperties',function(d){return c(d,'tableProperties');});})(); +(function(){var a=CKEDITOR.tools.cssLength,b=function(f){var g=this.id;if(!f.info)f.info={};f.info[g]=this.getValue();};function c(f){var g=0,h=0;for(var i=0,j,k=f.$.rows.length;ih&&(h=g);}return h;};function d(f){return function(){var g=this.getValue(),h=!!(CKEDITOR.dialog.validate.integer()(g)&&g>0);if(!h){alert(f);this.select();}return h;};};function e(f,g){var h=function(j){return new CKEDITOR.dom.element(j,f.document);},i=f.plugins.dialogadvtab;return{title:f.lang.table.title,minWidth:310,minHeight:CKEDITOR.env.ie?310:280,onLoad:function(){var j=this,k=j.getContentElement('advanced','advStyles');if(k)k.on('change',function(l){var m=this.getStyle('width',''),n=j.getContentElement('info','txtWidth');n&&n.setValue(m,true);var o=this.getStyle('height',''),p=j.getContentElement('info','txtHeight');p&&p.setValue(o,true);});},onShow:function(){var r=this;var j=f.getSelection(),k=j.getRanges(),l=null,m=r.getContentElement('info','txtRows'),n=r.getContentElement('info','txtCols'),o=r.getContentElement('info','txtWidth'),p=r.getContentElement('info','txtHeight');if(g=='tableProperties'){if(l=j.getSelectedElement())l=l.getAscendant('table',true);else if(k.length>0){if(CKEDITOR.env.webkit)k[0].shrink(CKEDITOR.NODE_ELEMENT);var q=k[0].getCommonAncestor(true);l=q.getAscendant('table',true);}r._.selectedElement=l;}if(l){r.setupContent(l);m&&m.disable();n&&n.disable();}else{m&&m.enable();n&&n.enable();}o&&o.onChange();p&&p.onChange();},onOk:function(){var j=f.getSelection(),k=this._.selectedElement&&j.createBookmarks(),l=this._.selectedElement||h('table'),m=this,n={};this.commitContent(n,l);if(n.info){var o=n.info;if(!this._.selectedElement){var p=l.append(h('tbody')),q=parseInt(o.txtRows,10)||0,r=parseInt(o.txtCols,10)||0;for(var s=0;s0){y=x.getFirst(); +for(s=0;s0){var l=k.getItem(0),m=l.getFirst(CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT));if(m&&!m.equals(l.getBogus())){n.disable(); +n.setValue(l.getText());return;}l=CKEDITOR.tools.trim(l.getText());n.setValue(l);}},commit:function(j,k){if(!this.isEnabled())return;var l=this.getValue(),m=k.getElementsByTag('caption');if(l){if(m.count()>0){m=m.getItem(0);m.setHtml('');}else{m=new CKEDITOR.dom.element('caption',f.document);if(k.getChildCount())m.insertBefore(k.getFirst());else m.appendTo(k);}m.append(new CKEDITOR.dom.text(l,f.document));}else if(m.count()>0)for(var n=m.count()-1;n>=0;n--)m.getItem(n).remove();}},{type:'text',id:'txtSummary',label:f.lang.table.summary,setup:function(j){this.setValue(j.getAttribute('summary')||'');},commit:function(j,k){if(this.getValue())k.setAttribute('summary',this.getValue());else k.removeAttribute('summary');}}]}]},i&&i.createAdvancedTab(f)]};};CKEDITOR.dialog.add('table',function(f){return e(f,'table');});CKEDITOR.dialog.add('tableProperties',function(f){return e(f,'tableProperties');});})();