JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.1
[ckeditor.git] / _source / plugins / link / dialogs / link.js
index a659616..51f5623 100644 (file)
@@ -244,14 +244,38 @@ CKEDITOR.dialog.add( 'link', function( editor )
                }\r
 \r
                // Find out whether we have any anchors in the editor.\r
-               var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors ),\r
-                       anchors = retval.anchors = [],\r
+               var anchors = retval.anchors = [],\r
                        item;\r
 \r
-               for ( var i = 0, count = anchorList.count(); i < count; i++ )\r
+               // For some browsers we set contenteditable="false" on anchors, making document.anchors not to include them, so we must traverse the links manually (#7893).\r
+               if ( CKEDITOR.plugins.link.emptyAnchorFix )\r
                {\r
-                       item = anchorList.getItem( i );\r
-                       anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };\r
+                       var links = editor.document.getElementsByTag( 'a' );\r
+                       for ( i = 0, count = links.count(); i < count; i++ )\r
+                       {\r
+                               item = links.getItem( i );\r
+                               if ( item.data( 'cke-saved-name' ) || item.hasAttribute( 'name' ) )\r
+                                       anchors.push( { name : item.data( 'cke-saved-name' ) || item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors );\r
+                       for ( var i = 0, count = anchorList.count(); i < count; i++ )\r
+                       {\r
+                               item = anchorList.getItem( i );\r
+                               anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };\r
+                       }\r
+               }\r
+\r
+               if ( CKEDITOR.plugins.link.fakeAnchor )\r
+               {\r
+                       var imgs = editor.document.getElementsByTag( 'img' );\r
+                       for ( i = 0, count = imgs.count(); i < count; i++ )\r
+                       {\r
+                               if ( ( item = CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, imgs.getItem( i ) ) ) )\r
+                                       anchors.push( { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );\r
+                       }\r
                }\r
 \r
                // Record down the selected element in the dialog.\r
@@ -1174,7 +1198,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        {\r
                                case 'url':\r
                                        var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://',\r
-                                               url = ( data.url && data.url.url ) || '';\r
+                                               url = ( data.url && CKEDITOR.tools.trim( data.url.url ) ) || '';\r
                                        attributes[ 'data-cke-saved-href' ] = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;\r
                                        break;\r
                                case 'anchor':\r