+++ /dev/null
-tinyMCEPopup.requireLangPack();\r
-\r
-var AnchorDialog = {\r
- init : function(ed) {\r
- var action, elm, f = document.forms[0];\r
-\r
- this.editor = ed;\r
- elm = ed.dom.getParent(ed.selection.getNode(), 'A');\r
- v = ed.dom.getAttrib(elm, 'name') || ed.dom.getAttrib(elm, 'id');\r
-\r
- if (v) {\r
- this.action = 'update';\r
- f.anchorName.value = v;\r
- }\r
-\r
- f.insert.value = ed.getLang(elm ? 'update' : 'insert');\r
- },\r
-\r
- update : function() {\r
- var ed = this.editor, elm, name = document.forms[0].anchorName.value, attribName;\r
-\r
- if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {\r
- tinyMCEPopup.alert('advanced_dlg.anchor_invalid');\r
- return;\r
- }\r
-\r
- tinyMCEPopup.restoreSelection();\r
-\r
- if (this.action != 'update')\r
- ed.selection.collapse(1);\r
-\r
- var aRule = ed.schema.getElementRule('a');\r
- if (!aRule || aRule.attributes.name) {\r
- attribName = 'name';\r
- } else {\r
- attribName = 'id';\r
- }\r
-\r
- elm = ed.dom.getParent(ed.selection.getNode(), 'A');\r
- if (elm) {\r
- elm.setAttribute(attribName, name);\r
- elm[attribName] = name;\r
- ed.undoManager.add();\r
- } else {\r
- // create with zero-sized nbsp so that in Webkit where anchor is on last line by itself caret cannot be placed after it\r
- var attrs = {'class' : 'mceItemAnchor'};\r
- attrs[attribName] = name;\r
- ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', attrs, '\uFEFF'));\r
- ed.nodeChanged();\r
- }\r
-\r
- tinyMCEPopup.close();\r
- }\r
-};\r
-\r
-tinyMCEPopup.onInit.add(AnchorDialog.init, AnchorDialog);\r