mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 15:18:58 +01:00
1 line
1.7 KiB
JavaScript
1 line
1.7 KiB
JavaScript
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=function(t){return/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)},n=function(t){var n=t.selection.getNode();return"A"===n.tagName&&""===t.dom.getAttrib(n,"href")?n.id||n.name:""},a=function(t,n){var e=t.selection.getNode();"A"===e.tagName&&""===t.dom.getAttrib(e,"href")?(e.removeAttribute("name"),e.id=n,t.undoManager.add()):(t.focus(),t.selection.collapse(!0),t.execCommand("mceInsertContent",!1,t.dom.createHTML("a",{id:n})))},e=function(o){var t=n(o);o.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{name:"id",type:"input",label:"Id"}]},buttons:[{type:"submit",name:"ok",text:"Ok",primary:!0},{type:"cancel",name:"cancel",text:"Cancel"}],initialData:{id:t},onSubmit:function(t){var n,e;n=o,e=t.getData().id,(r(e)?(a(n,e),0):(n.windowManager.alert("Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),1))||t.close()}})},o=function(t){t.addCommand("mceAnchor",function(){e(t)})},i=function(o){return function(t){for(var n=0;n<t.length;n++)(e=t[n]).attr("href")||!e.attr("id")&&!e.attr("name")||e.firstChild||t[n].attr("contenteditable",o);var e}},c=function(t){t.on("PreInit",function(){t.parser.addNodeFilter("a",i("false")),t.serializer.addNodeFilter("a",i(null))})},d=function(n){n.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:function(){return n.execCommand("mceAnchor")},onSetup:function(t){return n.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind}}),n.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor",onAction:function(){return n.execCommand("mceAnchor")}})};t.add("anchor",function(t){c(t),o(t),d(t)}),function u(){}}(); |