JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / plugins / link / dialogs / link.js
index 3ad641b..238113a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -245,7 +245,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
 \r
                // Find out whether we have any anchors in the editor.\r
                var anchors = retval.anchors = [],\r
-                       item;\r
+                       i, count, item;\r
 \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
@@ -261,7 +261,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                else\r
                {\r
                        var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors );\r
-                       for ( var i = 0, count = anchorList.count(); i < count; i++ )\r
+                       for ( 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
@@ -653,7 +653,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                type : 'html',\r
                                                                id : 'noAnchors',\r
                                                                style : 'text-align: center;',\r
-                                                               html : '<div role="label" tabIndex="-1">' + CKEDITOR.tools.htmlEncode( linkLang.noAnchors ) + '</div>',\r
+                                                               html : '<div role="note" tabIndex="-1">' + CKEDITOR.tools.htmlEncode( linkLang.noAnchors ) + '</div>',\r
                                                                // Focus the first element defined in above html.\r
                                                                focus : true,\r
                                                                setup : function( data )\r
@@ -1328,14 +1328,15 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        }\r
 \r
 \r
+                       var selection = editor.getSelection();\r
+\r
                        // Browser need the "href" fro copy/paste link to work. (#6641)\r
                        attributes.href = attributes[ 'data-cke-saved-href' ];\r
 \r
                        if ( !this._.selectedElement )\r
                        {\r
                                // Create element if current selection is collapsed.\r
-                               var selection = editor.getSelection(),\r
-                                       ranges = selection.getRanges( true );\r
+                               var ranges = selection.getRanges( true );\r
                                if ( ranges.length == 1 && ranges[0].collapsed )\r
                                {\r
                                        // Short mailto link text view (#5736).\r
@@ -1372,6 +1373,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                data.email.address : attributes[ 'data-cke-saved-href' ] );\r
                                }\r
 \r
+                               selection.selectElement( element );\r
                                delete this._.selectedElement;\r
                        }\r
                },\r