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/div/dialogs/div.js

1 line
No EOL
4.4 KiB
JavaScript

(function(){function a(d,c,e){c.is&&c.getCustomData("block_processed")||(c.is&&CKEDITOR.dom.element.setMarker(e,c,"block_processed",!0),d.push(c))}function b(d,c){function f(){this.foreach(function(j){/^(?!vbox|hbox)/.test(j.type)&&(j.setup||(j.setup=function(k){j.setValue(k.getAttribute(j.id)||"",1)}),!j.commit)&&(j.commit=function(l){var k=this.getValue();"dir"==j.id&&l.getComputedStyle("direction")==k||(k?l.setAttribute(j.id,k):l.removeAttribute(j.id))})})}var g=function(){var j=CKEDITOR.tools.extend({},CKEDITOR.dtd.$blockLimit);d.config.div_wrapTable&&(delete j.td,delete j.th);return j}(),e=CKEDITOR.dtd.div,i={},h=[];return{title:d.lang.div.title,minWidth:400,minHeight:165,contents:[{id:"info",label:d.lang.common.generalTab,title:d.lang.common.generalTab,elements:[{type:"hbox",widths:["50%","50%"],children:[{id:"elementStyle",type:"select",style:"width: 100%;",label:d.lang.div.styleSelectLabel,"default":"",items:[[d.lang.common.notSet,""]],onChange:function(){var n=["info:elementStyle","info:class","advanced:dir","advanced:style"],p=this.getDialog(),m=p._element&&p._element.clone()||new CKEDITOR.dom.element("div",d.document);this.commit(m,!0);for(var n=[].concat(n),j=n.length,l,o=0;o<j;o++){(l=p.getContentElement.apply(p,n[o].split(":")))&&l.setup&&l.setup(m,!0)}},setup:function(j){for(var k in i){i[k].checkElementRemovable(j,!0,d)&&this.setValue(k,1)}},commit:function(j){var k;(k=this.getValue())?i[k].applyToObject(j,d):j.removeAttribute("style")}},{id:"class",type:"text",requiredContent:"div(cke-xyz)",label:d.lang.common.cssClass,"default":""}]}]},{id:"advanced",label:d.lang.common.advancedTab,title:d.lang.common.advancedTab,elements:[{type:"vbox",padding:1,children:[{type:"hbox",widths:["50%","50%"],children:[{type:"text",id:"id",requiredContent:"div[id]",label:d.lang.common.id,"default":""},{type:"text",id:"lang",requiredContent:"div[lang]",label:d.lang.common.langCode,"default":""}]},{type:"hbox",children:[{type:"text",id:"style",requiredContent:"div{cke-xyz}",style:"width: 100%;",label:d.lang.common.cssStyle,"default":"",commit:function(j){j.setAttribute("style",this.getValue())}}]},{type:"hbox",children:[{type:"text",id:"title",requiredContent:"div[title]",style:"width: 100%;",label:d.lang.common.advisoryTitle,"default":""}]},{type:"select",id:"dir",requiredContent:"div[dir]",style:"width: 100%;",label:d.lang.common.langDir,"default":"",items:[[d.lang.common.notSet,""],[d.lang.common.langDirLtr,"ltr"],[d.lang.common.langDirRtl,"rtl"]]}]}]}],onLoad:function(){f.call(this);var j=this,k=this.getContentElement("info","elementStyle");d.getStylesSet(function(n){var l,m;if(n){for(var o=0;o<n.length;o++){m=n[o],m.element&&"div"==m.element&&(l=m.name,i[l]=m=new CKEDITOR.style(m),d.filter.check(m)&&(k.items.push([l,l]),k.add(l,l)))}}k[1<k.items.length?"enable":"disable"]();setTimeout(function(){j._element&&k.setup(j._element)},0)})},onShow:function(){"editdiv"==c&&this.setupContent(this._element=CKEDITOR.plugins.div.getSurroundDiv(d))},onOk:function(){if("editdiv"==c){h=[this._element]}else{var r=[],u={},q=[],v,o=d.getSelection(),s=o.getRanges(),j=o.createBookmarks(),p,m;for(p=0;p<s.length;p++){for(m=s[p].createIterator();v=m.getNextParagraph();){if(v.getName() in g&&!v.isReadOnly()){var t=v.getChildren();for(v=0;v<t.count();v++){a(q,t.getItem(v),u)}}else{for(;!e[v.getName()]&&!v.equals(s[p].root);){v=v.getParent()}a(q,v,u)}}}CKEDITOR.dom.element.clearAllMarkers(u);s=[];p=null;for(m=0;m<q.length;m++){v=q[m],t=d.elementPath(v).blockLimit,t.isReadOnly()&&(t=t.getParent()),d.config.div_wrapTable&&t.is(["td","th"])&&(t=d.elementPath(t.getParent()).blockLimit),t.equals(p)||(p=t,s.push([])),s[s.length-1].push(v)}for(p=0;p<s.length;p++){t=s[p][0];q=t.getParent();for(v=1;v<s[p].length;v++){q=q.getCommonAncestor(s[p][v])}m=new CKEDITOR.dom.element("div",d.document);for(v=0;v<s[p].length;v++){for(t=s[p][v];!t.getParent().equals(q);){t=t.getParent()}s[p][v]=t}for(v=0;v<s[p].length;v++){(t=s[p][v],t.getCustomData&&t.getCustomData("block_processed"))||(t.is&&CKEDITOR.dom.element.setMarker(u,t,"block_processed",!0),v||m.insertBefore(t),m.append(t))}CKEDITOR.dom.element.clearAllMarkers(u);r.push(m)}o.selectBookmarks(j);h=r}r=h.length;for(u=0;u<r;u++){this.commitContent(h[u]),!h[u].getAttribute("style")&&h[u].removeAttribute("style")}this.hide()},onHide:function(){"editdiv"==c&&this._element.removeCustomData("elementStyle");delete this._element}}}CKEDITOR.dialog.add("creatediv",function(c){return b(c,"creatediv")});CKEDITOR.dialog.add("editdiv",function(c){return b(c,"editdiv")})})();