1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/webtrees_ynh.git synced 2024-09-03 18:26:37 +02:00
webtrees_ynh/sources/packages/ckeditor-4.5.2-custom/plugins/table/dialogs/table.js

1 line
No EOL
8.4 KiB
JavaScript

(function(){function b(r){for(var k=0,h=0,i=0,f,j=r.$.rows.length;i<j;i++){f=r.$.rows[i];for(var l=k=0,o,q=f.cells.length;l<q;l++){o=f.cells[l],k+=o.colSpan}k>h&&(h=k)}return h}function d(f){return function(){var g=this.getValue();(g=!!(CKEDITOR.dialog.validate.integer()(g)&&0<g))||(alert(f),this.select());return g}}function e(f,i){var j=function(k){return new CKEDITOR.dom.element(k,f.document)},g=f.editable(),h=f.plugins.dialogadvtab;return{title:f.lang.table.title,minWidth:310,minHeight:CKEDITOR.env.ie?310:280,onLoad:function(){var l=this,k=l.getContentElement("advanced","advStyles");if(k){k.on("change",function(){var n=this.getStyle("width",""),m=l.getContentElement("info","txtWidth");m&&m.setValue(n,!0);n=this.getStyle("height","");(m=l.getContentElement("info","txtHeight"))&&m.setValue(n,!0)})}},onShow:function(){var n=f.getSelection(),p=n.getRanges(),q,k=this.getContentElement("info","txtRows"),m=this.getContentElement("info","txtCols"),l=this.getContentElement("info","txtWidth"),o=this.getContentElement("info","txtHeight");"tableProperties"==i&&((n=n.getSelectedElement())&&n.is("table")?q=n:0<p.length&&(CKEDITOR.env.webkit&&p[0].shrink(CKEDITOR.NODE_ELEMENT),q=f.elementPath(p[0].getCommonAncestor(!0)).contains("table",1)),this._.selectedElement=q);q?(this.setupContent(q),k&&k.disable(),m&&m.disable()):(k&&k.enable(),m&&m.enable());l&&l.onChange();o&&o.onChange()},onOk:function(){var t=f.getSelection(),w=this._.selectedElement&&t.createBookmarks(),x=this._.selectedElement||j("table"),y={};this.commitContent(y,x);if(y.info){y=y.info;if(!this._.selectedElement){for(var s=x.append(j("tbody")),v=parseInt(y.txtRows,10)||0,u=parseInt(y.txtCols,10)||0,r=0;r<v;r++){for(var q=s.append(j("tr")),o=0;o<u;o++){q.append(j("td")).appendBogus()}}}v=y.selHeaders;if(!x.$.tHead&&("row"==v||"both"==v)){q=new CKEDITOR.dom.element(x.$.createTHead());s=x.getElementsByTag("tbody").getItem(0);s=s.getElementsByTag("tr").getItem(0);for(r=0;r<s.getChildCount();r++){u=s.getChild(r),u.type==CKEDITOR.NODE_ELEMENT&&!u.data("cke-bookmark")&&(u.renameNode("th"),u.setAttribute("scope","col"))}q.append(s.remove())}if(null!==x.$.tHead&&"row"!=v&&"both"!=v){q=new CKEDITOR.dom.element(x.$.tHead);s=x.getElementsByTag("tbody").getItem(0);for(o=s.getFirst();0<q.getChildCount();){s=q.getFirst();for(r=0;r<s.getChildCount();r++){u=s.getChild(r),u.type==CKEDITOR.NODE_ELEMENT&&(u.renameNode("td"),u.removeAttribute("scope"))}s.insertBefore(o)}q.remove()}if(!this.hasColumnHeaders&&("col"==v||"both"==v)){for(q=0;q<x.$.rows.length;q++){u=new CKEDITOR.dom.element(x.$.rows[q].cells[0]),u.renameNode("th"),u.setAttribute("scope","row")}}if(this.hasColumnHeaders&&"col"!=v&&"both"!=v){for(r=0;r<x.$.rows.length;r++){q=new CKEDITOR.dom.element(x.$.rows[r]),"tbody"==q.getParent().getName()&&(u=new CKEDITOR.dom.element(q.$.cells[0]),u.renameNode("td"),u.removeAttribute("scope"))}}y.txtHeight?x.setStyle("height",y.txtHeight):x.removeStyle("height");y.txtWidth?x.setStyle("width",y.txtWidth):x.removeStyle("width");x.getAttribute("style")||x.removeAttribute("style")}if(this._.selectedElement){try{t.selectBookmarks(w)}catch(n){}}else{f.insertElement(x),setTimeout(function(){var l=new CKEDITOR.dom.element(x.$.rows[0].cells[0]),k=f.createRange();k.moveToPosition(l,CKEDITOR.POSITION_AFTER_START);k.select()},0)}},contents:[{id:"info",label:f.lang.table.title,elements:[{type:"hbox",widths:[null,null],styles:["vertical-align:top"],children:[{type:"vbox",padding:0,children:[{type:"text",id:"txtRows","default":3,label:f.lang.table.rows,required:!0,controlStyle:"width:5em",validate:d(f.lang.table.invalidRows),setup:function(k){this.setValue(k.$.rows.length)},commit:a},{type:"text",id:"txtCols","default":2,label:f.lang.table.columns,required:!0,controlStyle:"width:5em",validate:d(f.lang.table.invalidCols),setup:function(k){this.setValue(b(k))},commit:a},{type:"html",html:"&nbsp;"},{type:"select",id:"selHeaders",requiredContent:"th","default":"",label:f.lang.table.headers,items:[[f.lang.table.headersNone,""],[f.lang.table.headersRow,"row"],[f.lang.table.headersColumn,"col"],[f.lang.table.headersBoth,"both"]],setup:function(l){var m=this.getDialog();m.hasColumnHeaders=!0;for(var n=0;n<l.$.rows.length;n++){var k=l.$.rows[n].cells[0];if(k&&"th"!=k.nodeName.toLowerCase()){m.hasColumnHeaders=!1;break}}null!==l.$.tHead?this.setValue(m.hasColumnHeaders?"both":"row"):this.setValue(m.hasColumnHeaders?"col":"")},commit:a},{type:"text",id:"txtBorder",requiredContent:"table[border]","default":f.filter.check("table[border]")?1:0,label:f.lang.table.border,controlStyle:"width:3em",validate:CKEDITOR.dialog.validate.number(f.lang.table.invalidBorder),setup:function(k){this.setValue(k.getAttribute("border")||"")},commit:function(k,l){this.getValue()?l.setAttribute("border",this.getValue()):l.removeAttribute("border")}},{id:"cmbAlign",type:"select",requiredContent:"table[align]","default":"",label:f.lang.common.align,items:[[f.lang.common.notSet,""],[f.lang.common.alignLeft,"left"],[f.lang.common.alignCenter,"center"],[f.lang.common.alignRight,"right"]],setup:function(k){this.setValue(k.getAttribute("align")||"")},commit:function(k,l){this.getValue()?l.setAttribute("align",this.getValue()):l.removeAttribute("align")}}]},{type:"vbox",padding:0,children:[{type:"hbox",widths:["5em"],children:[{type:"text",id:"txtWidth",requiredContent:"table{width}",controlStyle:"width:5em",label:f.lang.common.width,title:f.lang.common.cssLengthTooltip,"default":f.filter.check("table{width}")?500>g.getSize("width")?"100%":500:0,getValue:c,validate:CKEDITOR.dialog.validate.cssLength(f.lang.common.invalidCssLength.replace("%1",f.lang.common.width)),onChange:function(){var k=this.getDialog().getContentElement("advanced","advStyles");k&&k.updateStyle("width",this.getValue())},setup:function(k){this.setValue(k.getStyle("width"))},commit:a}]},{type:"hbox",widths:["5em"],children:[{type:"text",id:"txtHeight",requiredContent:"table{height}",controlStyle:"width:5em",label:f.lang.common.height,title:f.lang.common.cssLengthTooltip,"default":"",getValue:c,validate:CKEDITOR.dialog.validate.cssLength(f.lang.common.invalidCssLength.replace("%1",f.lang.common.height)),onChange:function(){var k=this.getDialog().getContentElement("advanced","advStyles");k&&k.updateStyle("height",this.getValue())},setup:function(k){(k=k.getStyle("height"))&&this.setValue(k)},commit:a}]},{type:"html",html:"&nbsp;"},{type:"text",id:"txtCellSpace",requiredContent:"table[cellspacing]",controlStyle:"width:3em",label:f.lang.table.cellSpace,"default":f.filter.check("table[cellspacing]")?1:0,validate:CKEDITOR.dialog.validate.number(f.lang.table.invalidCellSpacing),setup:function(k){this.setValue(k.getAttribute("cellSpacing")||"")},commit:function(k,l){this.getValue()?l.setAttribute("cellSpacing",this.getValue()):l.removeAttribute("cellSpacing")}},{type:"text",id:"txtCellPad",requiredContent:"table[cellpadding]",controlStyle:"width:3em",label:f.lang.table.cellPad,"default":f.filter.check("table[cellpadding]")?1:0,validate:CKEDITOR.dialog.validate.number(f.lang.table.invalidCellPadding),setup:function(k){this.setValue(k.getAttribute("cellPadding")||"")},commit:function(k,l){this.getValue()?l.setAttribute("cellPadding",this.getValue()):l.removeAttribute("cellPadding")}}]}]},{type:"html",align:"right",html:""},{type:"vbox",padding:0,children:[{type:"text",id:"txtCaption",requiredContent:"caption",label:f.lang.table.caption,setup:function(k){this.enable();k=k.getElementsByTag("caption");if(0<k.count()){k=k.getItem(0);var l=k.getFirst(CKEDITOR.dom.walker.nodeType(CKEDITOR.NODE_ELEMENT));l&&!l.equals(k.getBogus())?(this.disable(),this.setValue(k.getText())):(k=CKEDITOR.tools.trim(k.getText()),this.setValue(k))}},commit:function(l,m){if(this.isEnabled()){var n=this.getValue(),k=m.getElementsByTag("caption");if(n){0<k.count()?(k=k.getItem(0),k.setHtml("")):(k=new CKEDITOR.dom.element("caption",f.document),m.getChildCount()?k.insertBefore(m.getFirst()):k.appendTo(m)),k.append(new CKEDITOR.dom.text(n,f.document))}else{if(0<k.count()){for(n=k.count()-1;0<=n;n--){k.getItem(n).remove()}}}}}},{type:"text",id:"txtSummary",bidi:!0,requiredContent:"table[summary]",label:f.lang.table.summary,setup:function(k){this.setValue(k.getAttribute("summary")||"")},commit:function(k,l){this.getValue()?l.setAttribute("summary",this.getValue()):l.removeAttribute("summary")}}]}]},h&&h.createAdvancedTab(f,null,"table")]}}var c=CKEDITOR.tools.cssLength,a=function(f){var g=this.id;f.info||(f.info={});f.info[g]=this.getValue()};CKEDITOR.dialog.add("table",function(f){return e(f,"table")});CKEDITOR.dialog.add("tableProperties",function(f){return e(f,"tableProperties")})})();