12345 |
- /*
- Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
- For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- CKEDITOR.dialog.add("cellProperties",function(t){function e(t){return{isSpacer:!0,type:"html",html:" ",requiredContent:t?t:void 0}}function o(){return{type:"vbox",padding:0,children:[]}}function i(e){return{requiredContent:"td{"+e+"}",type:"hbox",widths:["70%","30%"],children:[{type:"text",id:e,width:"100px",label:d[e],validate:s.number(c["invalid"+CKEDITOR.tools.capitalize(e)]),onLoad:function(){var t=this.getDialog().getContentElement("info",e+"Type").getElement(),o=this.getInputElement(),i=o.getAttribute("aria-labelledby");o.setAttribute("aria-labelledby",[i,t.$.id].join(" "))},setup:n(function(t){var o=parseFloat(t.getAttribute(e),10);return t=parseFloat(t.getStyle(e),10),isNaN(t)?isNaN(o)?void 0:o:t}),commit:function(t){var o=parseFloat(this.getValue(),10),i=this.getDialog().getValueOf("info",e+"Type")||r(t,e);isNaN(o)?t.removeStyle(e):t.setStyle(e,o+i),t.removeAttribute(e)},"default":""},{type:"select",id:e+"Type",label:t.lang.table[e+"Unit"],labelStyle:"visibility:hidden;display:block;width:0;overflow:hidden","default":"px",items:[[u.widthPx,"px"],[u.widthPc,"%"]],setup:n(function(t){return r(t,e)})}]}}function n(t){return function(e){for(var o=t(e[0]),i=1;i<e.length;i++)if(t(e[i])!==o){o=null;break}"undefined"!=typeof o&&(this.setValue(o),CKEDITOR.env.gecko&&"select"==this.type&&!o&&(this.getInputElement().$.selectedIndex=-1))}}function r(t,e){var o=/^(\d+(?:\.\d+)?)(px|%)$/.exec(t.getStyle(e)||t.getAttribute(e));return o?o[2]:void 0}function l(e,o){t.getColorFromDialog(function(t){t&&e.getDialog().getContentElement("info",o).setValue(t),e.focus()},e)}function a(t,e,o){(t=t.getValue())?e.setStyle(o,t):e.removeStyle(o),"background-color"==o?e.removeAttribute("bgColor"):"border-color"==o&&e.removeAttribute("borderColor")}var u=t.lang.table,c=u.cell,d=t.lang.common,s=CKEDITOR.dialog.validate,g="rtl"==t.lang.dir,p=t.plugins.colordialog,h=[i("width"),i("height"),e(["td{width}","td{height}"]),{type:"select",id:"wordWrap",requiredContent:"td{white-space}",label:c.wordWrap,"default":"yes",items:[[c.yes,"yes"],[c.no,"no"]],setup:n(function(t){var e=t.getAttribute("noWrap");return"nowrap"==t.getStyle("white-space")||e?"no":void 0}),commit:function(t){"no"==this.getValue()?t.setStyle("white-space","nowrap"):t.removeStyle("white-space"),t.removeAttribute("noWrap")}},e("td{white-space}"),{type:"select",id:"hAlign",requiredContent:"td{text-align}",label:c.hAlign,"default":"",items:[[d.notSet,""],[d.left,"left"],[d.center,"center"],[d.right,"right"],[d.justify,"justify"]],setup:n(function(t){var e=t.getAttribute("align");return t.getStyle("text-align")||e||""}),commit:function(t){var e=this.getValue();e?t.setStyle("text-align",e):t.removeStyle("text-align"),t.removeAttribute("align")}},{type:"select",id:"vAlign",requiredContent:"td{vertical-align}",label:c.vAlign,"default":"",items:[[d.notSet,""],[d.alignTop,"top"],[d.alignMiddle,"middle"],[d.alignBottom,"bottom"],[c.alignBaseline,"baseline"]],setup:n(function(t){var e=t.getAttribute("vAlign");switch(t=t.getStyle("vertical-align")){case"top":case"middle":case"bottom":case"baseline":break;default:t=""}return t||e||""}),commit:function(t){var e=this.getValue();e?t.setStyle("vertical-align",e):t.removeStyle("vertical-align"),t.removeAttribute("vAlign")}},e(["td{text-align}","td{vertical-align}"]),{type:"select",id:"cellType",requiredContent:"th",label:c.cellType,"default":"td",items:[[c.data,"td"],[c.header,"th"]],setup:n(function(t){return t.getName()}),commit:function(t){t.renameNode(this.getValue())}},e("th"),{type:"text",id:"rowSpan",requiredContent:"td[rowspan]",label:c.rowSpan,"default":"",validate:s.integer(c.invalidRowSpan),setup:n(function(t){return(t=parseInt(t.getAttribute("rowSpan"),10))&&1!=t?t:void 0}),commit:function(t){var e=parseInt(this.getValue(),10);e&&1!=e?t.setAttribute("rowSpan",this.getValue()):t.removeAttribute("rowSpan")}},{type:"text",id:"colSpan",requiredContent:"td[colspan]",label:c.colSpan,"default":"",validate:s.integer(c.invalidColSpan),setup:n(function(t){return(t=parseInt(t.getAttribute("colSpan"),10))&&1!=t?t:void 0}),commit:function(t){var e=parseInt(this.getValue(),10);e&&1!=e?t.setAttribute("colSpan",this.getValue()):t.removeAttribute("colSpan")}},e(["td[colspan]","td[rowspan]"]),{type:"hbox",padding:0,widths:p?["60%","40%"]:["100%"],requiredContent:"td{background-color}",children:function(){var t=[{type:"text",id:"bgColor",label:c.bgColor,"default":"",setup:n(function(t){var e=t.getAttribute("bgColor");return t.getStyle("background-color")||e}),commit:function(t){a(this,t,"background-color")}}];return p&&t.push({type:"button",id:"bgColorChoose","class":"colorChooser",label:c.chooseColor,onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){l(this,"bgColor")}}),t}()},{type:"hbox",padding:0,widths:p?["60%","40%"]:["100%"],requiredContent:"td{border-color}",children:function(){var t=[{type:"text",id:"borderColor",label:c.borderColor,"default":"",setup:n(function(t){var e=t.getAttribute("borderColor");return t.getStyle("border-color")||e}),commit:function(t){a(this,t,"border-color")}}];return p&&t.push({type:"button",id:"borderColorChoose","class":"colorChooser",label:c.chooseColor,style:(g?"margin-right":"margin-left")+": 10px",onLoad:function(){this.getElement().getParent().setStyle("vertical-align","bottom")},onClick:function(){l(this,"borderColor")}}),t}()}],f=0,b=-1,m=[o()],h=CKEDITOR.tools.array.filter(h,function(e){var o=e.requiredContent;return delete e.requiredContent,(o=t.filter.check(o))&&!e.isSpacer&&f++,o});return f>5&&(m=m.concat([e(),o()])),CKEDITOR.tools.array.forEach(h,function(t){t.isSpacer||b++,f>5&&b>=f/2?m[2].children.push(t):m[0].children.push(t)}),CKEDITOR.tools.array.forEach(m,function(t){t.isSpacer||(t=t.children,t[t.length-1].isSpacer&&t.pop())}),{title:c.title,minWidth:1===m.length?205:410,minHeight:50,contents:[{id:"info",label:c.title,accessKey:"I",elements:[{type:"hbox",widths:1===m.length?["100%"]:["40%","5%","40%"],children:m}]}],getModel:function(t){return CKEDITOR.plugins.tabletools.getSelectedCells(t.getSelection())},onShow:function(){var t=this.getModel(this.getParentEditor());this.setupContent(t)},onOk:function(){for(var t=this._.editor.getSelection(),e=t.createBookmarks(),o=this.getParentEditor(),i=this.getModel(o),n=0;n<i.length;n++)this.commitContent(i[n]);o.forceNextSelectionCheck(),t.selectBookmarks(e),o.selectionChange()},onLoad:function(){var t={};this.foreach(function(e){e.setup&&e.commit&&(e.setup=CKEDITOR.tools.override(e.setup,function(o){return function(){o.apply(this,arguments),t[e.id]=e.getValue()}}),e.commit=CKEDITOR.tools.override(e.commit,function(o){return function(){t[e.id]!==e.getValue()&&o.apply(this,arguments)}}))})}}});
|