JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.1
[ckeditor.git] / _source / plugins / link / dialogs / link.js
index 3b05df2..56baa05 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -75,6 +75,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        else\r
                                element.hide();\r
                }\r
+\r
+               dialog.layout();\r
        };\r
 \r
        // Loads the parameters in a selected link to the link dialog fields.\r
@@ -94,7 +96,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
 \r
        var parseLink = function( editor, element )\r
        {\r
-               var href = ( element  && ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) ) || '',\r
+               var href = ( element  && ( element.data( 'cke-saved-href' ) || element.getAttribute( 'href' ) ) ) || '',\r
                        javascriptMatch,\r
                        emailMatch,\r
                        anchorMatch,\r
@@ -184,7 +186,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        // IE BUG: target attribute is an empty string instead of null in IE if it's not set.\r
                        if ( !target )\r
                        {\r
-                               var onclick = element.getAttribute( '_cke_pa_onclick' ) || element.getAttribute( 'onclick' ),\r
+                               var onclick = element.data( 'cke-pa-onclick' ) || element.getAttribute( 'onclick' ),\r
                                        onclickMatch = onclick && onclick.match( popupRegex );\r
                                if ( onclickMatch )\r
                                {\r
@@ -223,7 +225,11 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        advAttr( 'advId', 'id' );\r
                        advAttr( 'advLangDir', 'dir' );\r
                        advAttr( 'advAccessKey', 'accessKey' );\r
-                       advAttr( 'advName', 'name' );\r
+\r
+                       retval.adv.advName =\r
+                               element.data( 'cke-saved-name' )\r
+                               || element.getAttribute( 'name' )\r
+                               || '';\r
                        advAttr( 'advLangCode', 'lang' );\r
                        advAttr( 'advTabIndex', 'tabindex' );\r
                        advAttr( 'advTitle', 'title' );\r
@@ -242,10 +248,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                for ( var i = 0; i < elements.count() ; i++ )\r
                {\r
                        var item = elements.getItem( i );\r
-                       if ( item.getAttribute( '_cke_realelement' ) && item.getAttribute( '_cke_real_element_type' ) == 'anchor' )\r
-                       {\r
+                       if ( item.data( 'cke-realelement' ) && item.data( 'cke-real-element-type' ) == 'anchor' )\r
                                anchors.push( editor.restoreRealElement( item ) );\r
-                       }\r
                }\r
 \r
                for ( i = 0 ; i < realAnchors.count() ; i++ )\r
@@ -363,27 +367,30 @@ CKEDITOR.dialog.add( 'link', function( editor )
                return 'String.fromCharCode(' + encodedChars.join( ',' ) + ')';\r
        }\r
 \r
+       var commonLang = editor.lang.common,\r
+               linkLang = editor.lang.link;\r
+\r
        return {\r
-               title : editor.lang.link.title,\r
+               title : linkLang.title,\r
                minWidth : 350,\r
                minHeight : 230,\r
                contents : [\r
                        {\r
                                id : 'info',\r
-                               label : editor.lang.link.info,\r
-                               title : editor.lang.link.info,\r
+                               label : linkLang.info,\r
+                               title : linkLang.info,\r
                                elements :\r
                                [\r
                                        {\r
                                                id : 'linkType',\r
                                                type : 'select',\r
-                                               label : editor.lang.link.type,\r
+                                               label : linkLang.type,\r
                                                'default' : 'url',\r
                                                items :\r
                                                [\r
-                                                       [ editor.lang.link.toUrl, 'url' ],\r
-                                                       [ editor.lang.link.toAnchor, 'anchor' ],\r
-                                                       [ editor.lang.link.toEmail, 'email' ]\r
+                                                       [ linkLang.toUrl, 'url' ],\r
+                                                       [ linkLang.toAnchor, 'anchor' ],\r
+                                                       [ linkLang.toEmail, 'email' ]\r
                                                ],\r
                                                onChange : linkTypeChanged,\r
                                                setup : function( data )\r
@@ -409,7 +416,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        {\r
                                                                                id : 'protocol',\r
                                                                                type : 'select',\r
-                                                                               label : editor.lang.common.protocol,\r
+                                                                               label : commonLang.protocol,\r
                                                                                'default' : 'http://',\r
                                                                                items :\r
                                                                                [\r
@@ -418,7 +425,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        [ 'https://\u200E', 'https://' ],\r
                                                                                        [ 'ftp://\u200E', 'ftp://' ],\r
                                                                                        [ 'news://\u200E', 'news://' ],\r
-                                                                                       [ editor.lang.link.other , '' ]\r
+                                                                                       [ linkLang.other , '' ]\r
                                                                                ],\r
                                                                                setup : function( data )\r
                                                                                {\r
@@ -436,7 +443,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        {\r
                                                                                type : 'text',\r
                                                                                id : 'url',\r
-                                                                               label : editor.lang.common.url,\r
+                                                                               label : commonLang.url,\r
                                                                                required: true,\r
                                                                                onLoad : function ()\r
                                                                                {\r
@@ -447,8 +454,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        this.allowOnChange = false;\r
                                                                                        var     protocolCmb = this.getDialog().getContentElement( 'info', 'protocol' ),\r
                                                                                                url = this.getValue(),\r
-                                                                                               urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi,\r
-                                                                                               urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/gi;\r
+                                                                                               urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/i,\r
+                                                                                               urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/i;\r
 \r
                                                                                        var protocol = urlOnChangeProtocol.exec( url );\r
                                                                                        if ( protocol )\r
@@ -477,7 +484,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        if ( this.getDialog().fakeObj ) // Edit Anchor.\r
                                                                                                return true;\r
 \r
-                                                                                       var func = CKEDITOR.dialog.validate.notEmpty( editor.lang.link.noUrl );\r
+                                                                                       var func = CKEDITOR.dialog.validate.notEmpty( linkLang.noUrl );\r
                                                                                        return func.apply( this );\r
                                                                                },\r
                                                                                setup : function( data )\r
@@ -513,7 +520,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                id : 'browse',\r
                                                                hidden : 'true',\r
                                                                filebrowser : 'info:url',\r
-                                                               label : editor.lang.common.browseServer\r
+                                                               label : commonLang.browseServer\r
                                                        }\r
                                                ]\r
                                        },\r
@@ -528,7 +535,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'fieldset',\r
                                                                id : 'selectAnchorText',\r
-                                                               label : editor.lang.link.selectAnchor,\r
+                                                               label : linkLang.selectAnchor,\r
                                                                setup : function( data )\r
                                                                {\r
                                                                        if ( data.anchors.length > 0 )\r
@@ -547,7 +554,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                                type : 'select',\r
                                                                                                id : 'anchorName',\r
                                                                                                'default' : '',\r
-                                                                                               label : editor.lang.link.anchorName,\r
+                                                                                               label : linkLang.anchorName,\r
                                                                                                style : 'width: 100%;',\r
                                                                                                items :\r
                                                                                                [\r
@@ -582,7 +589,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                                type : 'select',\r
                                                                                                id : 'anchorId',\r
                                                                                                'default' : '',\r
-                                                                                               label : editor.lang.link.anchorId,\r
+                                                                                               label : linkLang.anchorId,\r
                                                                                                style : 'width: 100%;',\r
                                                                                                items :\r
                                                                                                [\r
@@ -624,7 +631,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( editor.lang.link.noAnchors ) + '</div>',\r
+                                                               html : '<div role="label" 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
@@ -651,7 +658,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'text',\r
                                                                id : 'emailAddress',\r
-                                                               label : editor.lang.link.emailAddress,\r
+                                                               label : linkLang.emailAddress,\r
                                                                required : true,\r
                                                                validate : function()\r
                                                                {\r
@@ -661,7 +668,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        dialog.getValueOf( 'info', 'linkType' ) != 'email' )\r
                                                                                return true;\r
 \r
-                                                                       var func = CKEDITOR.dialog.validate.notEmpty( editor.lang.link.noEmail );\r
+                                                                       var func = CKEDITOR.dialog.validate.notEmpty( linkLang.noEmail );\r
                                                                        return func.apply( this );\r
                                                                },\r
                                                                setup : function( data )\r
@@ -684,7 +691,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'text',\r
                                                                id : 'emailSubject',\r
-                                                               label : editor.lang.link.emailSubject,\r
+                                                               label : linkLang.emailSubject,\r
                                                                setup : function( data )\r
                                                                {\r
                                                                        if ( data.email )\r
@@ -701,7 +708,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'textarea',\r
                                                                id : 'emailBody',\r
-                                                               label : editor.lang.link.emailBody,\r
+                                                               label : linkLang.emailBody,\r
                                                                rows : 3,\r
                                                                'default' : '',\r
                                                                setup : function( data )\r
@@ -728,8 +735,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        },\r
                        {\r
                                id : 'target',\r
-                               label : editor.lang.link.target,\r
-                               title : editor.lang.link.target,\r
+                               label : linkLang.target,\r
+                               title : linkLang.target,\r
                                elements :\r
                                [\r
                                        {\r
@@ -740,24 +747,25 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'select',\r
                                                                id : 'linkTargetType',\r
-                                                               label : editor.lang.common.target,\r
+                                                               label : commonLang.target,\r
                                                                'default' : 'notSet',\r
                                                                style : 'width : 100%;',\r
                                                                'items' :\r
                                                                [\r
-                                                                       [ editor.lang.common.notSet, 'notSet' ],\r
-                                                                       [ editor.lang.link.targetFrame, 'frame' ],\r
-                                                                       [ editor.lang.link.targetPopup, 'popup' ],\r
-                                                                       [ editor.lang.common.targetNew, '_blank' ],\r
-                                                                       [ editor.lang.common.targetTop, '_top' ],\r
-                                                                       [ editor.lang.common.targetSelf, '_self' ],\r
-                                                                       [ editor.lang.common.targetParent, '_parent' ]\r
+                                                                       [ commonLang.notSet, 'notSet' ],\r
+                                                                       [ linkLang.targetFrame, 'frame' ],\r
+                                                                       [ linkLang.targetPopup, 'popup' ],\r
+                                                                       [ commonLang.targetNew, '_blank' ],\r
+                                                                       [ commonLang.targetTop, '_top' ],\r
+                                                                       [ commonLang.targetSelf, '_self' ],\r
+                                                                       [ commonLang.targetParent, '_parent' ]\r
                                                                ],\r
                                                                onChange : targetChanged,\r
                                                                setup : function( data )\r
                                                                {\r
                                                                        if ( data.target )\r
-                                                                               this.setValue( data.target.type );\r
+                                                                               this.setValue( data.target.type || 'notSet' );\r
+                                                                       targetChanged.call( this );\r
                                                                },\r
                                                                commit : function( data )\r
                                                                {\r
@@ -770,7 +778,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'text',\r
                                                                id : 'linkTargetName',\r
-                                                               label : editor.lang.link.targetFrameName,\r
+                                                               label : linkLang.targetFrameName,\r
                                                                'default' : '',\r
                                                                setup : function( data )\r
                                                                {\r
@@ -789,7 +797,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                        },\r
                                        {\r
                                                type : 'vbox',\r
-                                               width : 260,\r
+                                               width : '100%',\r
                                                align : 'center',\r
                                                padding : 2,\r
                                                id : 'popupFeatures',\r
@@ -797,7 +805,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                [\r
                                                        {\r
                                                                type : 'fieldset',\r
-                                                               label : editor.lang.link.popupFeatures,\r
+                                                               label : linkLang.popupFeatures,\r
                                                                children :\r
                                                                [\r
                                                                        {\r
@@ -807,14 +815,14 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'resizable',\r
-                                                                                               label : editor.lang.link.popupResizable,\r
+                                                                                               label : linkLang.popupResizable,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
                                                                                        },\r
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'status',\r
-                                                                                               label : editor.lang.link.popupStatusBar,\r
+                                                                                               label : linkLang.popupStatusBar,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -828,7 +836,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'location',\r
-                                                                                               label : editor.lang.link.popupLocationBar,\r
+                                                                                               label : linkLang.popupLocationBar,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -836,7 +844,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'toolbar',\r
-                                                                                               label : editor.lang.link.popupToolbar,\r
+                                                                                               label : linkLang.popupToolbar,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -850,7 +858,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'menubar',\r
-                                                                                               label : editor.lang.link.popupMenuBar,\r
+                                                                                               label : linkLang.popupMenuBar,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -858,7 +866,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'fullscreen',\r
-                                                                                               label : editor.lang.link.popupFullScreen,\r
+                                                                                               label : linkLang.popupFullScreen,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -872,7 +880,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'scrollbars',\r
-                                                                                               label : editor.lang.link.popupScrollBars,\r
+                                                                                               label : linkLang.popupScrollBars,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -880,7 +888,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type : 'checkbox',\r
                                                                                                id : 'dependent',\r
-                                                                                               label : editor.lang.link.popupDependent,\r
+                                                                                               label : linkLang.popupDependent,\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
 \r
@@ -893,9 +901,9 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                [\r
                                                                                        {\r
                                                                                                type :  'text',\r
-                                                                                               widths : [ '30%', '70%' ],\r
+                                                                                               widths : [ '50%', '50%' ],\r
                                                                                                labelLayout : 'horizontal',\r
-                                                                                               label : editor.lang.link.popupWidth,\r
+                                                                                               label : commonLang.width,\r
                                                                                                id : 'width',\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
@@ -904,8 +912,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type :  'text',\r
                                                                                                labelLayout : 'horizontal',\r
-                                                                                               widths : [ '55%', '45%' ],\r
-                                                                                               label : editor.lang.link.popupLeft,\r
+                                                                                               widths : [ '50%', '50%' ],\r
+                                                                                               label : linkLang.popupLeft,\r
                                                                                                id : 'left',\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
@@ -920,8 +928,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type :  'text',\r
                                                                                                labelLayout : 'horizontal',\r
-                                                                                               widths : [ '30%', '70%' ],\r
-                                                                                               label : editor.lang.link.popupHeight,\r
+                                                                                               widths : [ '50%', '50%' ],\r
+                                                                                               label : commonLang.height,\r
                                                                                                id : 'height',\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
@@ -930,8 +938,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        {\r
                                                                                                type :  'text',\r
                                                                                                labelLayout : 'horizontal',\r
-                                                                                               label : editor.lang.link.popupTop,\r
-                                                                                               widths : [ '55%', '45%' ],\r
+                                                                                               label : linkLang.popupTop,\r
+                                                                                               widths : [ '50%', '50%' ],\r
                                                                                                id : 'top',\r
                                                                                                setup : setupPopupParams,\r
                                                                                                commit : commitPopupParams\r
@@ -947,8 +955,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        },\r
                        {\r
                                id : 'upload',\r
-                               label : editor.lang.link.upload,\r
-                               title : editor.lang.link.upload,\r
+                               label : linkLang.upload,\r
+                               title : linkLang.upload,\r
                                hidden : true,\r
                                filebrowser : 'uploadButton',\r
                                elements :\r
@@ -956,14 +964,14 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                        {\r
                                                type : 'file',\r
                                                id : 'upload',\r
-                                               label : editor.lang.common.upload,\r
+                                               label : commonLang.upload,\r
                                                style: 'height:40px',\r
                                                size : 29\r
                                        },\r
                                        {\r
                                                type : 'fileButton',\r
                                                id : 'uploadButton',\r
-                                               label : editor.lang.common.uploadSubmit,\r
+                                               label : commonLang.uploadSubmit,\r
                                                filebrowser : 'info:url',\r
                                                'for' : [ 'upload', 'upload' ]\r
                                        }\r
@@ -971,8 +979,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        },\r
                        {\r
                                id : 'advanced',\r
-                               label : editor.lang.link.advanced,\r
-                               title : editor.lang.link.advanced,\r
+                               label : linkLang.advanced,\r
+                               title : linkLang.advanced,\r
                                elements :\r
                                [\r
                                        {\r
@@ -988,21 +996,21 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        {\r
                                                                                type : 'text',\r
                                                                                id : 'advId',\r
-                                                                               label : editor.lang.link.id,\r
+                                                                               label : linkLang.id,\r
                                                                                setup : setupAdvParams,\r
                                                                                commit : commitAdvParams\r
                                                                        },\r
                                                                        {\r
                                                                                type : 'select',\r
                                                                                id : 'advLangDir',\r
-                                                                               label : editor.lang.link.langDir,\r
+                                                                               label : linkLang.langDir,\r
                                                                                'default' : '',\r
                                                                                style : 'width:110px',\r
                                                                                items :\r
                                                                                [\r
-                                                                                       [ editor.lang.common.notSet, '' ],\r
-                                                                                       [ editor.lang.link.langDirLTR, 'ltr' ],\r
-                                                                                       [ editor.lang.link.langDirRTL, 'rtl' ]\r
+                                                                                       [ commonLang.notSet, '' ],\r
+                                                                                       [ linkLang.langDirLTR, 'ltr' ],\r
+                                                                                       [ linkLang.langDirRTL, 'rtl' ]\r
                                                                                ],\r
                                                                                setup : setupAdvParams,\r
                                                                                commit : commitAdvParams\r
@@ -1011,7 +1019,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                type : 'text',\r
                                                                                id : 'advAccessKey',\r
                                                                                width : '80px',\r
-                                                                               label : editor.lang.link.acccessKey,\r
+                                                                               label : linkLang.acccessKey,\r
                                                                                maxLength : 1,\r
                                                                                setup : setupAdvParams,\r
                                                                                commit : commitAdvParams\r
@@ -1026,7 +1034,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                [\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.name,\r
+                                                                               label : linkLang.name,\r
                                                                                id : 'advName',\r
                                                                                setup : setupAdvParams,\r
                                                                                commit : commitAdvParams\r
@@ -1034,7 +1042,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        },\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.langCode,\r
+                                                                               label : linkLang.langCode,\r
                                                                                id : 'advLangCode',\r
                                                                                width : '110px',\r
                                                                                'default' : '',\r
@@ -1044,7 +1052,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        },\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.tabIndex,\r
+                                                                               label : linkLang.tabIndex,\r
                                                                                id : 'advTabIndex',\r
                                                                                width : '80px',\r
                                                                                maxLength : 5,\r
@@ -1068,7 +1076,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                [\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.advisoryTitle,\r
+                                                                               label : linkLang.advisoryTitle,\r
                                                                                'default' : '',\r
                                                                                id : 'advTitle',\r
                                                                                setup : setupAdvParams,\r
@@ -1077,7 +1085,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        },\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.advisoryContentType,\r
+                                                                               label : linkLang.advisoryContentType,\r
                                                                                'default' : '',\r
                                                                                id : 'advContentType',\r
                                                                                setup : setupAdvParams,\r
@@ -1093,7 +1101,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                [\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.cssClasses,\r
+                                                                               label : linkLang.cssClasses,\r
                                                                                'default' : '',\r
                                                                                id : 'advCSSClasses',\r
                                                                                setup : setupAdvParams,\r
@@ -1102,7 +1110,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        },\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.charset,\r
+                                                                               label : linkLang.charset,\r
                                                                                'default' : '',\r
                                                                                id : 'advCharset',\r
                                                                                setup : setupAdvParams,\r
@@ -1117,7 +1125,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                [\r
                                                                        {\r
                                                                                type : 'text',\r
-                                                                               label : editor.lang.link.styles,\r
+                                                                               label : linkLang.styles,\r
                                                                                'default' : '',\r
                                                                                id : 'advStyles',\r
                                                                                setup : setupAdvParams,\r
@@ -1143,8 +1151,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) )\r
                                selection.selectElement( element );\r
                        else if ( ( element = selection.getSelectedElement() ) && element.is( 'img' )\r
-                                       && element.getAttribute( '_cke_real_element_type' )\r
-                                       && element.getAttribute( '_cke_real_element_type' ) == 'anchor' )\r
+                                       && element.data( 'cke-real-element-type' )\r
+                                       && element.data( 'cke-real-element-type' ) == 'anchor' )\r
                        {\r
                                this.fakeObj = element;\r
                                element = editor.restoreRealElement( this.fakeObj );\r
@@ -1157,9 +1165,9 @@ CKEDITOR.dialog.add( 'link', function( editor )
                },\r
                onOk : function()\r
                {\r
-                       var attributes = { href : 'javascript:void(0)/*' + CKEDITOR.tools.getNextNumber() + '*/' },\r
+                       var attributes = {},\r
                                removeAttributes = [],\r
-                               data = { href : attributes.href },\r
+                               data = {},\r
                                me = this,\r
                                editor = this.getParentEditor();\r
 \r
@@ -1171,12 +1179,12 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                case 'url':\r
                                        var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://',\r
                                                url = ( data.url && data.url.url ) || '';\r
-                                       attributes._cke_saved_href = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;\r
+                                       attributes[ 'data-cke-saved-href' ] = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;\r
                                        break;\r
                                case 'anchor':\r
                                        var name = ( data.anchor && data.anchor.name ),\r
                                                id = ( data.anchor && data.anchor.id );\r
-                                       attributes._cke_saved_href = '#' + ( name || id || '' );\r
+                                       attributes[ 'data-cke-saved-href' ] = '#' + ( name || id || '' );\r
                                        break;\r
                                case 'email':\r
 \r
@@ -1223,7 +1231,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                }\r
                                        }\r
 \r
-                                       attributes._cke_saved_href = linkHref.join( '' );\r
+                                       attributes[ 'data-cke-saved-href' ] = linkHref.join( '' );\r
                                        break;\r
                        }\r
 \r
@@ -1251,7 +1259,10 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                        addFeature( 'top' );\r
 \r
                                        onclickList.push( featureList.join( ',' ), '\'); return false;' );\r
-                                       attributes[ '_cke_pa_onclick' ] = onclickList.join( '' );\r
+                                       attributes[ 'data-cke-pa-onclick' ] = onclickList.join( '' );\r
+\r
+                                       // Add the "target" attribute. (#5074)\r
+                                       removeAttributes.push( 'target' );\r
                                }\r
                                else\r
                                {\r
@@ -1260,7 +1271,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                        else\r
                                                removeAttributes.push( 'target' );\r
 \r
-                                       removeAttributes.push( '_cke_pa_onclick', 'onclick' );\r
+                                       removeAttributes.push( 'data-cke-pa-onclick', 'onclick' );\r
                                }\r
                        }\r
 \r
@@ -1276,11 +1287,18 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                removeAttributes.push( attrName );\r
                                };\r
 \r
-                               if ( this._.selectedElement )\r
-                                       advAttr( 'advId', 'id' );\r
+                               advAttr( 'advId', 'id' );\r
                                advAttr( 'advLangDir', 'dir' );\r
                                advAttr( 'advAccessKey', 'accessKey' );\r
-                               advAttr( 'advName', 'name' );\r
+\r
+                               if ( data.adv[ 'advName' ] )\r
+                               {\r
+                                       attributes[ 'name' ] = attributes[ 'data-cke-saved-name' ] = data.adv[ 'advName' ];\r
+                                       attributes[ 'class' ] = ( attributes[ 'class' ] ? attributes[ 'class' ] + ' ' : '' ) + 'cke_anchor';\r
+                               }\r
+                               else\r
+                                       removeAttributes = removeAttributes.concat( [ 'data-cke-saved-name', 'name' ] );\r
+\r
                                advAttr( 'advLangCode', 'lang' );\r
                                advAttr( 'advTabIndex', 'tabindex' );\r
                                advAttr( 'advTitle', 'title' );\r
@@ -1290,16 +1308,20 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                advAttr( 'advStyles', 'style' );\r
                        }\r
 \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();\r
+                                       ranges = selection.getRanges( true );\r
                                if ( ranges.length == 1 && ranges[0].collapsed )\r
                                {\r
                                        // Short mailto link text view (#5736).\r
                                        var text = new CKEDITOR.dom.text( data.type == 'email' ?\r
-                                                       data.email.address : attributes._cke_saved_href, editor.document );\r
+                                                       data.email.address : attributes[ 'data-cke-saved-href' ], editor.document );\r
                                        ranges[0].insertNode( text );\r
                                        ranges[0].selectNodeContents( text );\r
                                        selection.selectRanges( ranges );\r
@@ -1309,26 +1331,12 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                var style = new CKEDITOR.style( { element : 'a', attributes : attributes } );\r
                                style.type = CKEDITOR.STYLE_INLINE;             // need to override... dunno why.\r
                                style.apply( editor.document );\r
-\r
-                               // Id. Apply only to the first link.\r
-                               if ( data.adv && data.adv.advId )\r
-                               {\r
-                                       var links = this.getParentEditor().document.$.getElementsByTagName( 'a' );\r
-                                       for ( i = 0 ; i < links.length ; i++ )\r
-                                       {\r
-                                               if ( links[i].href == attributes.href )\r
-                                               {\r
-                                                       links[i].id = data.adv.advId;\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-                               }\r
                        }\r
                        else\r
                        {\r
                                // We're only editing an existing link, so just overwrite the attributes.\r
                                var element = this._.selectedElement,\r
-                                       href = element.getAttribute( '_cke_saved_href' ),\r
+                                       href = element.data( 'cke-saved-href' ),\r
                                        textView = element.getHtml();\r
 \r
                                // IE BUG: Setting the name attribute to an existing link doesn't work.\r
@@ -1340,8 +1348,8 @@ CKEDITOR.dialog.add( 'link', function( editor )
 \r
                                        selection = editor.getSelection();\r
 \r
-                                       element.moveChildren( newElement );\r
                                        element.copyAttributes( newElement, { name : 1 } );\r
+                                       element.moveChildren( newElement );\r
                                        newElement.replace( element );\r
                                        element = newElement;\r
 \r
@@ -1355,7 +1363,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                {\r
                                        // Short mailto link text view (#5736).\r
                                        element.setHtml( data.type == 'email' ?\r
-                                               data.email.address : attributes._cke_saved_href );\r
+                                               data.email.address : attributes[ 'data-cke-saved-href' ] );\r
                                }\r
                                // Make the element display as an anchor if a name has been set.\r
                                if ( element.getAttribute( 'name' ) )\r
@@ -1383,7 +1391,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                {\r
                        var linkType = this.getContentElement( 'info', 'linkType' ),\r
                                        urlField;\r
-                       if ( linkType && linkType.getValue( ) == 'url' )\r
+                       if ( linkType && linkType.getValue() == 'url' )\r
                        {\r
                                urlField = this.getContentElement( 'info', 'url' );\r
                                urlField.select();\r