]> git.mxchange.org Git - friendica.git/blobdiff - library/tinymce/jscripts/tiny_mce/themes/advanced/js/anchor.js
update tinymce to 3.5b2 to fix issues with FF 11 and pasting into code blocks
[friendica.git] / library / tinymce / jscripts / tiny_mce / themes / advanced / js / anchor.js
old mode 100755 (executable)
new mode 100644 (file)
index 7fe7810..2940db3
@@ -19,16 +19,23 @@ var AnchorDialog = {
        update : function() {\r
                var ed = this.editor, elm, name = document.forms[0].anchorName.value;\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
                elm = ed.dom.getParent(ed.selection.getNode(), 'A');\r
-               if (elm)\r
+               if (elm) {\r
+                       elm.setAttribute('name', name);\r
                        elm.name = name;\r
-               else\r
-                       ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, ''));\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
+                       ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, '\uFEFF'));\r
 \r
                tinyMCEPopup.close();\r
        }\r