FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / dialog / fck_anchor.html
index a9f2f50..0f08faa 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >\r
 <!--\r
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
+ * Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
  *\r
  * == BEGIN LICENSE ==\r
  *\r
                <script src="common/fck_dialog_common.js" type="text/javascript"></script>\r
                <script type="text/javascript">\r
 \r
-var oEditor    = window.parent.InnerDialogLoaded() ;\r
-var FCK                = oEditor.FCK ;\r
-var FCKBrowserInfo = oEditor.FCKBrowserInfo ;\r
-var FCKTools = oEditor.FCKTools ;\r
-var FCKRegexLib = oEditor.FCKRegexLib ;\r
+var dialog                     = window.parent ;\r
+var oEditor                    = dialog.InnerDialogLoaded() ;\r
 \r
-// Gets the document DOM\r
-var oDOM = oEditor.FCK.EditorDocument ;\r
+var FCK                                = oEditor.FCK ;\r
+var FCKBrowserInfo     = oEditor.FCKBrowserInfo ;\r
+var FCKTools           = oEditor.FCKTools ;\r
+var FCKRegexLib                = oEditor.FCKRegexLib ;\r
+\r
+var oDOM                       = FCK.EditorDocument ;\r
+\r
+var oFakeImage = dialog.Selection.GetSelectedElement() ;\r
 \r
-var oFakeImage = FCK.Selection.GetSelectedElement() ;\r
 var oAnchor ;\r
 \r
 if ( oFakeImage )\r
@@ -68,6 +70,9 @@ window.onload = function()
                oAnchor = null ;\r
 \r
        window.parent.SetOkButton( true ) ;\r
+       window.parent.SetAutoSize( true ) ;\r
+\r
+       SelectField( 'txtName' ) ;\r
 }\r
 \r
 function Ok()\r
@@ -83,7 +88,8 @@ function Ok()
                // Remove the anchor if the user leaves the name blank\r
                if ( oAnchor )\r
                {\r
-                       RemoveAnchor() ;\r
+                       // Removes the current anchor from the document using the new command\r
+                       FCK.Commands.GetCommand( 'AnchorDelete' ).Execute() ;\r
                        return true ;\r
                }\r
 \r
@@ -113,10 +119,7 @@ function Ok()
        var aNewAnchors = oEditor.FCK.CreateLink( '#' ) ;\r
 \r
        if ( aNewAnchors.length == 0 )\r
-       {\r
-               // Nothing was selected, so now just create a normal A\r
-               aNewAnchors.push( oEditor.FCK.CreateElement( 'a' ) ) ;\r
-       }\r
+                       aNewAnchors.push( oEditor.FCK.InsertElement( 'a' ) ) ;\r
        else\r
        {\r
                // Remove the fake href\r
@@ -130,7 +133,18 @@ function Ok()
                oAnchor = aNewAnchors[i] ;\r
 \r
                // Set the name\r
-               oAnchor.name = sNewName ;\r
+               if ( FCKBrowserInfo.IsIE )\r
+               {\r
+                       // Setting anchor names directly in IE will trash the HTML code stored\r
+                       // in FCKTempBin after undos. See #2263.\r
+                       var replaceAnchor = oEditor.FCK.EditorDocument.createElement( '<a name="' +\r
+                                       FCKTools.HTMLEncode( sNewName ).replace( '"', '&quot;' ) + '">' ) ;\r
+                       oEditor.FCKDomTools.MoveChildren( oAnchor, replaceAnchor ) ;\r
+                       oAnchor.parentNode.replaceChild( replaceAnchor, oAnchor ) ;\r
+                       oAnchor = replaceAnchor ;\r
+               }\r
+               else\r
+                       oAnchor.name = sNewName ;\r
 \r
                // IE does require special processing to show the Anchor's image\r
                // Opera doesn't allow to select empty anchors\r
@@ -157,36 +171,6 @@ function Ok()
        return true ;\r
 }\r
 \r
-// Removes the current anchor from the document\r
-function RemoveAnchor()\r
-{\r
-       // If it's also a link, then just remove the name and exit\r
-       if ( oAnchor.href.length != 0 )\r
-       {\r
-               oAnchor.removeAttribute( 'name' ) ;\r
-               // Remove temporary class for IE\r
-               if ( FCKBrowserInfo.IsIE )\r
-                       oAnchor.className = oAnchor.className.replace( FCKRegexLib.FCK_Class, '' ) ;\r
-               return ;\r
-       }\r
-\r
-       // We need to remove the anchor\r
-       // If we got a fake image, then just remove it and we're done\r
-       if ( oFakeImage )\r
-       {\r
-               oFakeImage.parentNode.removeChild( oFakeImage ) ;\r
-               return ;\r
-       }\r
-       // Empty anchor, so just remove it\r
-       if ( oAnchor.innerHTML.length == 0 )\r
-       {\r
-               oAnchor.parentNode.removeChild( oAnchor ) ;\r
-               return ;\r
-       }\r
-       // Anchor with content, leave the content\r
-       FCKTools.RemoveOuterTags( oAnchor ) ;\r
-}\r
-\r
 // Checks all the links in the current page pointing to the current name and changes them to the new name\r
 function ReadjustLinksToAnchor( sCurrent, sNew )\r
 {\r
@@ -217,7 +201,7 @@ function ReadjustLinksToAnchor( sCurrent, sNew )
 \r
                </script>\r
        </head>\r
-       <body style="OVERFLOW: hidden" scroll="no">\r
+       <body style="overflow: hidden">\r
                <table height="100%" width="100%">\r
                        <tr>\r
                                <td align="center">\r