]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js
Wordpress 2.3.2
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / themes / advanced / jscripts / anchor.js
index a89f9729d4682c16e8024c9d29c24f6a546cede5..f2e5d4829b0f3f356b729d069690ea85313811e4 100644 (file)
@@ -26,7 +26,7 @@ function init() {
 
 function insertAnchor() {
        var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
-       var name = document.forms[0].anchorName.value;
+       var name = document.forms[0].anchorName.value, e;
 
        tinyMCEPopup.execCommand("mceBeginUndoLevel");
 
@@ -44,11 +44,26 @@ function insertAnchor() {
                name = name.replace(/&/g, '&');
                name = name.replace(/\"/g, '"');
                name = name.replace(/</g, '&lt;');
-               name = name.replace(/>/g, '&gr;');
+               name = name.replace(/>/g, '&gt;');
 
-               html = '<a name="' + name + '"></a>';
+               // Fix for bug #1447335
+               if (tinyMCE.isGecko)
+                       html = '<a id="mceNewAnchor" name="' + name + '"></a>';
+               else
+                       html = '<a name="' + name + '"></a>';
 
                tinyMCEPopup.execCommand("mceInsertContent", false, html);
+
+               // Fix for bug #1447335 force cursor after the anchor element
+               if (tinyMCE.isGecko) {
+                       e = inst.getDoc().getElementById('mceNewAnchor');
+
+                       if (e) {
+                               inst.selection.selectNode(e, true, false, false);
+                               e.removeAttribute('id');
+                       }
+               }
+
                tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst);
        }