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