JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.2_full
[ckeditor.git] / plugins / tabletools / dialogs / tableCell.js
index d401ffd..a328cc9 100644 (file)
@@ -1,8 +1,16 @@
-/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-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,i={type:'html',html:' '};function j(k,l){var m=function(){o(this);l(this);},n=function(){o(this);},o=function(q){q.removeListener('ok',m);q.removeListener('cancel',n);},p=function(q){q.on('ok',m);q.on('cancel',n);};a.execCommand(k);if(a._.storedDialogs.colordialog)p(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(){p(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),onLoad:function(){var k=this.getDialog().getContentElement('info','widthType'),l=k.getElement(),m=this.getInputElement(),n=m.getAttribute('aria-labelledby');m.setAttribute('aria-labelledby',[n,l.$.id].join(' '));},setup:function(k){var l=parseInt(k.getAttribute('width'),10),m=parseInt(k.getStyle('width'),10);!isNaN(l)&&this.setValue(l);!isNaN(m)&&this.setValue(m);},commit:function(k){var l=parseInt(this.getValue(),10),m=this.getDialog().getValueOf('info','widthType');if(!isNaN(l))k.setStyle('width',l+m);else k.removeStyle('width');k.removeAttribute('width');},'default':''},{type:'select',id:'widthType',labelLayout:'horizontal',widths:['0%','100%'],label:a.lang.table.widthUnit,labelStyle:'display:none','default':'px',items:[[b.widthPx,'px'],[b.widthPc,'%']],setup:function(k){var l=f.exec(k.getStyle('width')||k.getAttribute('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),onLoad:function(){var k=this.getDialog().getContentElement('info','htmlHeightType'),l=k.getElement(),m=this.getInputElement(),n=m.getAttribute('aria-labelledby');m.setAttribute('aria-labelledby',[n,l.$.id].join(' '));},setup:function(k){var l=parseInt(k.getAttribute('height'),10),m=parseInt(k.getStyle('height'),10);\r
-!isNaN(l)&&this.setValue(l);!isNaN(m)&&this.setValue(m);},commit:function(k){var l=parseInt(this.getValue(),10);if(!isNaN(l))k.setStyle('height',CKEDITOR.tools.cssLength(l));else k.removeStyle('height');k.removeAttribute('height');}},{id:'htmlHeightType',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']],setup:function(k){var l=k.getAttribute('noWrap'),m=k.getStyle('white-space');if(m=='nowrap'||l)this.setValue('no');},commit:function(k){if(this.getValue()=='no')k.setStyle('white-space','nowrap');else k.removeStyle('white-space');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){var l=k.getAttribute('align'),m=k.getStyle('text-align');this.setValue(m||l||'');},commit:function(k){var l=this.getValue();if(l)k.setStyle('text-align',l);else k.removeStyle('text-align');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){var l=k.getAttribute('vAlign'),m=k.getStyle('vertical-align');switch(m){case 'top':case 'middle':case 'bottom':case 'baseline':break;default:m='';}this.setValue(m||l||'');},commit:function(k){var l=this.getValue();if(l)k.setStyle('vertical-align',l);else k.removeStyle('vertical-align');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){var l=parseInt(k.getAttribute('rowSpan'),10);if(l&&l!=1)this.setValue(l);},commit:function(k){var l=parseInt(this.getValue(),10);if(l&&l!=1)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){var l=parseInt(k.getAttribute('colSpan'),10);\r
-if(l&&l!=1)this.setValue(l);},commit:function(k){var l=parseInt(this.getValue(),10);if(l&&l!=1)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){var l=k.getAttribute('bgColor'),m=k.getStyle('background-color');this.setValue(m||l);},commit:function(k){var l=this.getValue();if(l)k.setStyle('background-color',this.getValue());else k.removeStyle('background-color');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){var l=k.getAttribute('borderColor'),m=k.getStyle('border-color');this.setValue(m||l);},commit:function(k){var l=this.getValue();if(l)k.setStyle('border-color',this.getValue());else k.removeStyle('border-color');k.removeAttribute('borderColor');}},{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._.editor.getSelection(),l=k.createBookmarks(),m=this.cells;for(var n=0;n<m.length;n++)this.commitContent(m[n]);k.selectBookmarks(l);}};});\r
+/*
+ Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
+ For licensing, see LICENSE.md or http://ckeditor.com/license
+*/
+CKEDITOR.dialog.add("cellProperties",function(f){var g=f.lang.table,c=g.cell,d=f.lang.common,h=CKEDITOR.dialog.validate,j=/^(\d+(?:\.\d+)?)(px|%)$/,e={type:"html",html:"&nbsp;"},k="rtl"==f.lang.dir,i=f.plugins.colordialog;return{title:c.title,minWidth:CKEDITOR.env.ie&&CKEDITOR.env.quirks?450:410,minHeight:CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks)?230:220,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",width:"100px",label:d.width,validate:h.number(c.invalidWidth),onLoad:function(){var a=this.getDialog().getContentElement("info","widthType").getElement(),b=this.getInputElement(),c=b.getAttribute("aria-labelledby");b.setAttribute("aria-labelledby",[c,a.$.id].join(" "))},setup:function(a){var b=parseInt(a.getAttribute("width"),10),a=parseInt(a.getStyle("width"),10);!isNaN(b)&&this.setValue(b);!isNaN(a)&&this.setValue(a)},
+commit:function(a){var b=parseInt(this.getValue(),10),c=this.getDialog().getValueOf("info","widthType");isNaN(b)?a.removeStyle("width"):a.setStyle("width",b+c);a.removeAttribute("width")},"default":""},{type:"select",id:"widthType",label:f.lang.table.widthUnit,labelStyle:"visibility:hidden","default":"px",items:[[g.widthPx,"px"],[g.widthPc,"%"]],setup:function(a){(a=j.exec(a.getStyle("width")||a.getAttribute("width")))&&this.setValue(a[2])}}]},{type:"hbox",widths:["70%","30%"],children:[{type:"text",
+id:"height",label:d.height,width:"100px","default":"",validate:h.number(c.invalidHeight),onLoad:function(){var a=this.getDialog().getContentElement("info","htmlHeightType").getElement(),b=this.getInputElement(),c=b.getAttribute("aria-labelledby");b.setAttribute("aria-labelledby",[c,a.$.id].join(" "))},setup:function(a){var b=parseInt(a.getAttribute("height"),10),a=parseInt(a.getStyle("height"),10);!isNaN(b)&&this.setValue(b);!isNaN(a)&&this.setValue(a)},commit:function(a){var b=parseInt(this.getValue(),
+10);isNaN(b)?a.removeStyle("height"):a.setStyle("height",CKEDITOR.tools.cssLength(b));a.removeAttribute("height")}},{id:"htmlHeightType",type:"html",html:"<br />"+g.widthPx}]},e,{type:"select",id:"wordWrap",label:c.wordWrap,"default":"yes",items:[[c.yes,"yes"],[c.no,"no"]],setup:function(a){var b=a.getAttribute("noWrap");("nowrap"==a.getStyle("white-space")||b)&&this.setValue("no")},commit:function(a){"no"==this.getValue()?a.setStyle("white-space","nowrap"):a.removeStyle("white-space");a.removeAttribute("noWrap")}},
+e,{type:"select",id:"hAlign",label:c.hAlign,"default":"",items:[[d.notSet,""],[d.alignLeft,"left"],[d.alignCenter,"center"],[d.alignRight,"right"]],setup:function(a){var b=a.getAttribute("align");this.setValue(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:[[d.notSet,""],[d.alignTop,"top"],[d.alignMiddle,"middle"],[d.alignBottom,
+"bottom"],[c.alignBaseline,"baseline"]],setup: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=""}this.setValue(a||b||"")},commit:function(a){var b=this.getValue();b?a.setStyle("vertical-align",b):a.removeStyle("vertical-align");a.removeAttribute("vAlign")}}]},e,{type:"vbox",padding:0,children:[{type:"select",id:"cellType",label:c.cellType,"default":"td",items:[[c.data,"td"],[c.header,"th"]],
+setup:function(a){this.setValue(a.getName())},commit:function(a){a.renameNode(this.getValue())}},e,{type:"text",id:"rowSpan",label:c.rowSpan,"default":"",validate:h.integer(c.invalidRowSpan),setup:function(a){(a=parseInt(a.getAttribute("rowSpan"),10))&&1!=a&&this.setValue(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:h.integer(c.invalidColSpan),
+setup:function(a){(a=parseInt(a.getAttribute("colSpan"),10))&&1!=a&&this.setValue(a)},commit:function(a){var b=parseInt(this.getValue(),10);b&&1!=b?a.setAttribute("colSpan",this.getValue()):a.removeAttribute("colSpan")}},e,{type:"hbox",padding:0,widths:["60%","40%"],children:[{type:"text",id:"bgColor",label:c.bgColor,"default":"",setup:function(a){var b=a.getAttribute("bgColor");this.setValue(a.getStyle("background-color")||b)},commit:function(a){this.getValue()?a.setStyle("background-color",this.getValue()):
+a.removeStyle("background-color");a.removeAttribute("bgColor")}},i?{type:"button",id:"bgColorChoose","class":"colorChooser",label:c.chooseColor,onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){f.getColorFromDialog(function(a){a&&this.getDialog().getContentElement("info","bgColor").setValue(a);this.focus()},this)}}:e]},e,{type:"hbox",padding:0,widths:["60%","40%"],children:[{type:"text",id:"borderColor",label:c.borderColor,"default":"",setup:function(a){var b=
+a.getAttribute("borderColor");this.setValue(a.getStyle("border-color")||b)},commit:function(a){this.getValue()?a.setStyle("border-color",this.getValue()):a.removeStyle("border-color");a.removeAttribute("borderColor")}},i?{type:"button",id:"borderColorChoose","class":"colorChooser",label:c.chooseColor,style:(k?"margin-right":"margin-left")+": 10px",onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){f.getColorFromDialog(function(a){a&&this.getDialog().getContentElement("info",
+"borderColor").setValue(a);this.focus()},this)}}:e]}]}]}]}],onShow:function(){this.cells=CKEDITOR.plugins.tabletools.getSelectedCells(this._.editor.getSelection());this.setupContent(this.cells[0])},onOk:function(){for(var a=this._.editor.getSelection(),b=a.createBookmarks(),c=this.cells,d=0;d<c.length;d++)this.commitContent(c[d]);this._.editor.forceNextSelectionCheck();a.selectBookmarks(b);this._.editor.selectionChange()}}});
\ No newline at end of file