CKEDITOR.plugins.add("ipscode",{requires:"widget",icons:"ipscode",hidpi:!0,init:function(c){c.widgets.add("ipscode",{template:"<pre class='ipsCode'></pre>",upcast:function(a){return"pre"==a.name&&a.hasClass("ipsCode")}});c.addCommand("ipsCode",{exec:function(a){var c=ips.getString("editorCodeButton"),d="?app=core&module=system&controller=editor&do=code&editorId="+a.name,b=a.getSelection().getSelectedElement();b&&!b.hasClass("ipsCode")&&(b=b.findOne("pre.ipsCode"));if(b&&b.is("pre")&&b.hasClass("ipsCode")){var a=
"html",e=b.getAttribute("class").split(" "),f;for(f in e)"lang-"==e[f].substr(0,5)&&(a=e[f].substr(5));d=d+"&val="+encodeURIComponent(b.getText())+"&lang="+a}else d=d+"&val="+encodeURIComponent(a.getSelection().getSelectedText())+"&lang=html";ips.ui.dialog.create({title:c,fixed:!1,url:d}).show()}});c.ui.addButton("ipsCode",{label:ips.getString("editorCodeButton"),command:"ipsCode",toolbar:"insert"});c.on("doubleclick",function(a){a=a.data.element.getParents(!0);for(i in a){if(a[i].is("div")&&a[i].hasClass("cke_wysiwyg_div"))break;
if(a[i]&&a[i].is("pre")&&a[i].hasClass("ipsCode")){c.getSelection().selectElement(a[i].getParent());c.execCommand("ipsCode");break}}})}});