X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=plugins%2Ftabletools%2Fdialogs%2FtableCell.js;h=6635e88b729ee0669e900c98ad2557ec1c5fbb4d;hp=831ad0ab247937c3e2e77f57d06c5ae48897df78;hb=1f91409c05f689832bd6dfbbb5161b6d18c3b50c;hpb=8761695d9b70afe75905deaac88f78c1f8aeb32d diff --git a/plugins/tabletools/dialogs/tableCell.js b/plugins/tabletools/dialogs/tableCell.js index 831ad0a..6635e88 100644 --- a/plugins/tabletools/dialogs/tableCell.js +++ b/plugins/tabletools/dialogs/tableCell.js @@ -1,8 +1,17 @@ -/* -Copyright (c) 2003-2009, 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:' '};};function j(k,l){var m=function(){p(this);l(this);},n=function(){p(this);},o=function(q){q.on('ok',m);q.on('cancel',n);},p=function(q){q.removeListener('ok',m);q.removeListener('cancel',n);};a.execCommand(k);if(a._.storedDialogs.colordialog)o(a._.storedDialogs.colordialog);else CKEDITOR.on('dialogDefinition',function(q){if(q.data.name!=k)return;var r=q.data.definition;q.removeListener();r.onLoad=CKEDITOR.tools.override(r.onLoad,function(s){return function(){o(this);r.onLoad=s;if(typeof s=='function')s.call(this);};});});};return{title:c.title,minWidth:CKEDITOR.env.ie&&CKEDITOR.env.quirks?550:480,minHeight:CKEDITOR.env.ie?CKEDITOR.env.quirks?180:150:140,contents:[{id:'info',label:c.title,accessKey:'I',elements:[{type:'hbox',widths:['40%','5%','40%'],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(k){var l=f.exec(k.$.style.width);if(l)this.setValue(l[1]);},commit:function(k){var l=this.getDialog().getValueOf('info','widthType');if(this.getValue()!=='')k.$.style.width=this.getValue()+l;else k.$.style.width='';},'default':''},{type:'select',id:'widthType',labelLayout:'horizontal',widths:['0%','100%'],label:'','default':'px',items:[[b.widthPx,'px'],[b.widthPc,'%']],setup:function(k){var l=f.exec(k.$.style.width);if(l)this.setValue(l[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(k){var l=g.exec(k.$.style.height);if(l)this.setValue(l[1]);},commit:function(k){if(this.getValue()!=='')k.$.style.height=this.getValue()+'px';else k.$.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(k){if(this.getValue()=='no')k.setAttribute('noWrap','nowrap');else k.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(k){this.setValue(k.getAttribute('align')||''); -},commit:function(k){if(this.getValue())k.setAttribute('align',this.getValue());else k.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(k){this.setValue(k.getAttribute('vAlign')||'');},commit:function(k){if(this.getValue())k.setAttribute('vAlign',this.getValue());else k.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(k){this.setValue(k.getName());},commit:function(k){k.renameNode(this.getValue());}},i(),{type:'text',id:'rowSpan',label:c.rowSpan,labelLayout:'horizontal',widths:['50%','50%'],'default':'',validate:e.integer(c.invalidRowSpan),setup:function(k){this.setValue(k.getAttribute('rowSpan')||'');},commit:function(k){if(this.getValue())k.setAttribute('rowSpan',this.getValue());else k.removeAttribute('rowSpan');}},{type:'text',id:'colSpan',label:c.colSpan,labelLayout:'horizontal',widths:['50%','50%'],'default':'',validate:e.integer(c.invalidColSpan),setup:function(k){this.setValue(k.getAttribute('colSpan')||'');},commit:function(k){if(this.getValue())k.setAttribute('colSpan',this.getValue());else k.removeAttribute('colSpan');}},i(),{type:'hbox',padding:0,widths:['80%','20%'],children:[{type:'text',id:'bgColor',label:c.bgColor,labelLayout:'horizontal',widths:['70%','30%'],'default':'',setup:function(k){this.setValue(k.getAttribute('bgColor')||'');},commit:function(k){if(this.getValue())k.setAttribute('bgColor',this.getValue());else k.removeAttribute('bgColor');}},{type:'button',id:'bgColorChoose',label:c.chooseColor,style:'margin-left: 10px',onClick:function(){var k=this;j('colordialog',function(l){k.getDialog().getContentElement('info','bgColor').setValue(l.getContentElement('picker','selectedColor').getValue());});}}]},i(),{type:'hbox',padding:0,widths:['80%','20%'],children:[{type:'text',id:'borderColor',label:c.borderColor,labelLayout:'horizontal',widths:['70%','30%'],'default':'',setup:function(k){this.setValue(k.getStyle('border-color')||'');},commit:function(k){if(this.getValue())k.setStyle('border-color',this.getValue());else k.removeStyle('border-color');}},{type:'button',id:'borderColorChoose',label:c.chooseColor,style:'margin-left: 10px',onClick:function(){var k=this; -j('colordialog',function(l){k.getDialog().getContentElement('info','borderColor').setValue(l.getContentElement('picker','selectedColor').getValue());});}}]}]}]}]}],onShow:function(){var k=this;k.cells=CKEDITOR.plugins.tabletools.getSelectedCells(k._.editor.getSelection());k.setupContent(k.cells[0]);},onOk:function(){var k=this.cells;for(var l=0;l"+h.widthPx}]},f,{type:"select",id:"wordWrap",label:c.wordWrap,"default":"yes",items:[[c.yes,"yes"],[c.no,"no"]],setup:d(function(a){var b=a.getAttribute("noWrap");if("nowrap"==a.getStyle("white-space")|| +b)return"no"}),commit:function(a){"no"==this.getValue()?a.setStyle("white-space","nowrap"):a.removeStyle("white-space");a.removeAttribute("noWrap")}},f,{type:"select",id:"hAlign",label:c.hAlign,"default":"",items:[[e.notSet,""],[e.alignLeft,"left"],[e.alignCenter,"center"],[e.alignRight,"right"]],setup:d(function(a){var b=a.getAttribute("align");return a.getStyle("text-align")||b||""}),commit:function(a){var b=this.getValue();b?a.setStyle("text-align",b):a.removeStyle("text-align");a.removeAttribute("align")}}, +{type:"select",id:"vAlign",label:c.vAlign,"default":"",items:[[e.notSet,""],[e.alignTop,"top"],[e.alignMiddle,"middle"],[e.alignBottom,"bottom"],[c.alignBaseline,"baseline"]],setup:d(function(a){var b=a.getAttribute("vAlign"),a=a.getStyle("vertical-align");switch(a){case "top":case "middle":case "bottom":case "baseline":break;default:a=""}return a||b||""}),commit:function(a){var b=this.getValue();b?a.setStyle("vertical-align",b):a.removeStyle("vertical-align");a.removeAttribute("vAlign")}}]},f,{type:"vbox", +padding:0,children:[{type:"select",id:"cellType",label:c.cellType,"default":"td",items:[[c.data,"td"],[c.header,"th"]],setup:d(function(a){return a.getName()}),commit:function(a){a.renameNode(this.getValue())}},f,{type:"text",id:"rowSpan",label:c.rowSpan,"default":"",validate:i.integer(c.invalidRowSpan),setup:d(function(a){if((a=parseInt(a.getAttribute("rowSpan"),10))&&1!=a)return a}),commit:function(a){var b=parseInt(this.getValue(),10);b&&1!=b?a.setAttribute("rowSpan",this.getValue()):a.removeAttribute("rowSpan")}}, +{type:"text",id:"colSpan",label:c.colSpan,"default":"",validate:i.integer(c.invalidColSpan),setup:d(function(a){if((a=parseInt(a.getAttribute("colSpan"),10))&&1!=a)return a}),commit:function(a){var b=parseInt(this.getValue(),10);b&&1!=b?a.setAttribute("colSpan",this.getValue()):a.removeAttribute("colSpan")}},f,{type:"hbox",padding:0,widths:["60%","40%"],children:[{type:"text",id:"bgColor",label:c.bgColor,"default":"",setup:d(function(a){var b=a.getAttribute("bgColor");return a.getStyle("background-color")|| +b}),commit:function(a){this.getValue()?a.setStyle("background-color",this.getValue()):a.removeStyle("background-color");a.removeAttribute("bgColor")}},k?{type:"button",id:"bgColorChoose","class":"colorChooser",label:c.chooseColor,onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){g.getColorFromDialog(function(a){a&&this.getDialog().getContentElement("info","bgColor").setValue(a);this.focus()},this)}}:f]},f,{type:"hbox",padding:0,widths:["60%","40%"], +children:[{type:"text",id:"borderColor",label:c.borderColor,"default":"",setup:d(function(a){var b=a.getAttribute("borderColor");return a.getStyle("border-color")||b}),commit:function(a){this.getValue()?a.setStyle("border-color",this.getValue()):a.removeStyle("border-color");a.removeAttribute("borderColor")}},k?{type:"button",id:"borderColorChoose","class":"colorChooser",label:c.chooseColor,style:(m?"margin-right":"margin-left")+": 10px",onLoad:function(){this.getElement().getParent().setStyle("vertical-align", +"bottom")},onClick:function(){g.getColorFromDialog(function(a){a&&this.getDialog().getContentElement("info","borderColor").setValue(a);this.focus()},this)}}:f]}]}]}]}],onShow:function(){this.cells=CKEDITOR.plugins.tabletools.getSelectedCells(this._.editor.getSelection());this.setupContent(this.cells)},onOk:function(){for(var a=this._.editor.getSelection(),b=a.createBookmarks(),c=this.cells,d=0;d