X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=plugins%2Ftabletools%2Fdialogs%2FtableCell.js;h=7ea200450aa968a44b65c735654e7583f22ff51f;hb=6e682412d5cc0dfaedb376482e585bf2989c6863;hp=f1eeecbc46eba9458d33795ac2f0817453be4f08;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/plugins/tabletools/dialogs/tableCell.js b/plugins/tabletools/dialogs/tableCell.js index f1eeecb..7ea2004 100644 --- a/plugins/tabletools/dialogs/tableCell.js +++ b/plugins/tabletools/dialogs/tableCell.js @@ -1,7 +1,8 @@ /* -Copyright (c) 2003-2009, 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 */ -CKEDITOR.dialog.add('cellProperties',function(a){var b=a.lang.table,c=b.cell,d=a.lang.common,e=CKEDITOR.dialog.validate,f=/^(\d+(?:\.\d+)?)(px|%)$/,g=/^(\d+(?:\.\d+)?)px$/,h=CKEDITOR.tools.bind;function i(){return{type:'html',html:' '};};return{title:c.title,minWidth:480,minHeight:140,contents:[{id:'info',label:c.title,accessKey:'I',elements:[{type:'hbox',widths:['45%','10%','45%'],children:[{type:'vbox',padding:0,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'text',id:'width',label:b.width,widths:['71%','29%'],labelLayout:'horizontal',validate:e.number(c.invalidWidth),setup:function(j){var k=f.exec(j.$.style.width);if(k)this.setValue(k[1]);},commit:function(j){var k=this.getDialog().getValueOf('info','widthType');if(this.getValue()!=='')j.$.style.width=this.getValue()+k;else j.$.style.width='';},'default':''},{type:'select',id:'widthType',labelLayout:'horizontal',widths:['0%','100%'],label:'','default':'px',items:[[b.widthPx,'px'],[b.widthPc,'%']],setup:function(j){var k=f.exec(j.$.style.width);if(k)this.setValue(k[2]);}}]},{type:'hbox',widths:['70%','30%'],children:[{type:'text',id:'height',label:b.height,'default':'',widths:['71%','29%'],labelLayout:'horizontal',validate:e.number(c.invalidHeight),setup:function(j){var k=g.exec(j.$.style.height);if(k)this.setValue(k[1]);},commit:function(j){if(this.getValue()!=='')j.$.style.height=this.getValue()+'px';else j.$.style.height='';}},{type:'html',html:b.widthPx}]},i(),{type:'select',id:'wordWrap',labelLayout:'horizontal',label:c.wordWrap,widths:['50%','50%'],'default':'yes',items:[[c.yes,'yes'],[c.no,'no']],commit:function(j){if(this.getValue()=='no')j.setAttribute('noWrap','nowrap');else j.removeAttribute('noWrap');}},i(),{type:'select',id:'hAlign',labelLayout:'horizontal',label:c.hAlign,widths:['50%','50%'],'default':'',items:[[d.notSet,''],[b.alignLeft,'left'],[b.alignCenter,'center'],[b.alignRight,'right']],setup:function(j){this.setValue(j.getAttribute('align')||'');},commit:function(j){if(this.getValue())j.setAttribute('align',this.getValue());else j.removeAttribute('align');}},{type:'select',id:'vAlign',labelLayout:'horizontal',label:c.vAlign,widths:['50%','50%'],'default':'',items:[[d.notSet,''],[c.alignTop,'top'],[c.alignMiddle,'middle'],[c.alignBottom,'bottom'],[c.alignBaseline,'baseline']],setup:function(j){this.setValue(j.getAttribute('vAlign')||'');},commit:function(j){if(this.getValue())j.setAttribute('vAlign',this.getValue());else j.removeAttribute('vAlign');}}]},i(),{type:'vbox',padding:0,children:[{type:'select',id:'cellType',label:c.cellType,labelLayout:'horizontal',widths:['50%','50%'],'default':'td',items:[[c.data,'td'],[c.header,'th']],setup:function(j){this.setValue(j.getName()); -},commit:function(j){j.renameNode(this.getValue());}},i(),{type:'text',id:'rowSpan',label:c.rowSpan,labelLayout:'horizontal',widths:['50%','50%'],'default':'',validate:e.integer(c.invalidRowSpan),setup:function(j){this.setValue(j.getAttribute('rowSpan')||'');},commit:function(j){if(this.getValue())j.setAttribute('rowSpan',this.getValue());else j.removeAttribute('rowSpan');}},{type:'text',id:'colSpan',label:c.colSpan,labelLayout:'horizontal',widths:['50%','50%'],'default':'',validate:e.integer(c.invalidColSpan),setup:function(j){this.setValue(j.getAttribute('colSpan')||'');},commit:function(j){if(this.getValue())j.setAttribute('colSpan',this.getValue());else j.removeAttribute('colSpan');}},i(),{type:'text',id:'bgColor',label:c.bgColor,labelLayout:'horizontal',widths:['50%','50%'],'default':'',setup:function(j){this.setValue(j.getAttribute('bgColor')||'');},commit:function(j){if(this.getValue())j.setAttribute('bgColor',this.getValue());else j.removeAttribute('bgColor');}},{type:'text',id:'borderColor',label:c.borderColor,labelLayout:'horizontal',widths:['50%','50%'],'default':'',setup:function(j){this.setValue(j.getAttribute('borderColor')||'');},commit:function(j){if(this.getValue())j.setAttribute('borderColor',this.getValue());else j.removeAttribute('borderColor');}}]}]}]}],onShow:function(){var j=this;j.cells=CKEDITOR.plugins.tabletools.getSelectedCells(j._.editor.getSelection());j.setupContent(j.cells[0]);},onOk:function(){var j=this.cells;for(var k=0;k'+b.widthPx}]},i,{type:'select',id:'wordWrap',label:c.wordWrap,'default':'yes',items:[[c.yes,'yes'],[c.no,'no']],setup:function(l){var m=l.getAttribute('noWrap'),n=l.getStyle('white-space');if(n=='nowrap'||m)this.setValue('no');},commit:function(l){if(this.getValue()=='no')l.setStyle('white-space','nowrap');else l.removeStyle('white-space');l.removeAttribute('noWrap');}},i,{type:'select',id:'hAlign',label:c.hAlign,'default':'',items:[[d.notSet,''],[d.alignLeft,'left'],[d.alignCenter,'center'],[d.alignRight,'right']],setup:function(l){var m=l.getAttribute('align'),n=l.getStyle('text-align');this.setValue(n||m||'');},commit:function(l){var m=this.getValue();if(m)l.setStyle('text-align',m);else l.removeStyle('text-align');l.removeAttribute('align');}},{type:'select',id:'vAlign',label:c.vAlign,'default':'',items:[[d.notSet,''],[d.alignTop,'top'],[d.alignMiddle,'middle'],[d.alignBottom,'bottom'],[c.alignBaseline,'baseline']],setup:function(l){var m=l.getAttribute('vAlign'),n=l.getStyle('vertical-align');switch(n){case 'top':case 'middle':case 'bottom':case 'baseline':break;default:n='';}this.setValue(n||m||'');},commit:function(l){var m=this.getValue();if(m)l.setStyle('vertical-align',m);else l.removeStyle('vertical-align');l.removeAttribute('vAlign');}}]},i,{type:'vbox',padding:0,children:[{type:'select',id:'cellType',label:c.cellType,'default':'td',items:[[c.data,'td'],[c.header,'th']],setup:function(l){this.setValue(l.getName());},commit:function(l){l.renameNode(this.getValue());}},i,{type:'text',id:'rowSpan',label:c.rowSpan,'default':'',validate:e.integer(c.invalidRowSpan),setup:function(l){var m=parseInt(l.getAttribute('rowSpan'),10);if(m&&m!=1)this.setValue(m);},commit:function(l){var m=parseInt(this.getValue(),10);if(m&&m!=1)l.setAttribute('rowSpan',this.getValue());else l.removeAttribute('rowSpan');}},{type:'text',id:'colSpan',label:c.colSpan,'default':'',validate:e.integer(c.invalidColSpan),setup:function(l){var m=parseInt(l.getAttribute('colSpan'),10);if(m&&m!=1)this.setValue(m);},commit:function(l){var m=parseInt(this.getValue(),10);if(m&&m!=1)l.setAttribute('colSpan',this.getValue());else l.removeAttribute('colSpan');}},i,{type:'hbox',padding:0,widths:['60%','40%'],children:[{type:'text',id:'bgColor',label:c.bgColor,'default':'',setup:function(l){var m=l.getAttribute('bgColor'),n=l.getStyle('background-color'); +this.setValue(n||m);},commit:function(l){var m=this.getValue();if(m)l.setStyle('background-color',this.getValue());else l.removeStyle('background-color');l.removeAttribute('bgColor');}},{type:'button',id:'bgColorChoose','class':'colorChooser',label:c.chooseColor,onLoad:function(){this.getElement().getParent().setStyle('vertical-align','bottom');},onClick:function(){var l=this;k('colordialog',function(m){l.getDialog().getContentElement('info','bgColor').setValue(m.getContentElement('picker','selectedColor').getValue());});}}]},i,{type:'hbox',padding:0,widths:['60%','40%'],children:[{type:'text',id:'borderColor',label:c.borderColor,'default':'',setup:function(l){var m=l.getAttribute('borderColor'),n=l.getStyle('border-color');this.setValue(n||m);},commit:function(l){var m=this.getValue();if(m)l.setStyle('border-color',this.getValue());else l.removeStyle('border-color');l.removeAttribute('borderColor');}},{type:'button',id:'borderColorChoose','class':'colorChooser',label:c.chooseColor,style:(j?'margin-right':'margin-left')+': 10px',onLoad:function(){this.getElement().getParent().setStyle('vertical-align','bottom');},onClick:function(){var l=this;k('colordialog',function(m){l.getDialog().getContentElement('info','borderColor').setValue(m.getContentElement('picker','selectedColor').getValue());});}}]}]}]}]}],onShow:function(){var l=this;l.cells=CKEDITOR.plugins.tabletools.getSelectedCells(l._.editor.getSelection());l.setupContent(l.cells[0]);},onOk:function(){var p=this;var l=p._.editor.getSelection(),m=l.createBookmarks(),n=p.cells;for(var o=0;o