JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5
[ckeditor.git] / _source / plugins / link / dialogs / link.js
index c7388ca..5362b16 100644 (file)
@@ -5,6 +5,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
 CKEDITOR.dialog.add( 'link', function( editor )\r
 {\r
+       var plugin = CKEDITOR.plugins.link;\r
        // Handles the event when the "Target" selection box is changed.\r
        var targetChanged = function()\r
        {\r
@@ -74,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
@@ -93,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
@@ -183,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
@@ -241,10 +244,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
@@ -362,27 +363,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
@@ -408,16 +412,16 @@ 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
-                                                                               style : 'width : 100%;',\r
                                                                                items :\r
                                                                                [\r
-                                                                                       [ 'http://' ],\r
-                                                                                       [ 'https://' ],\r
-                                                                                       [ 'ftp://' ],\r
-                                                                                       [ 'news://' ],\r
-                                                                                       [ '<other>', '' ]\r
+                                                                                       // Force 'ltr' for protocol names in BIDI. (#5433)\r
+                                                                                       [ 'http://\u200E', 'http://' ],\r
+                                                                                       [ 'https://\u200E', 'https://' ],\r
+                                                                                       [ 'ftp://\u200E', 'ftp://' ],\r
+                                                                                       [ 'news://\u200E', 'news://' ],\r
+                                                                                       [ linkLang.other , '' ]\r
                                                                                ],\r
                                                                                setup : function( data )\r
                                                                                {\r
@@ -435,7 +439,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,7 +451,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                        var     protocolCmb = this.getDialog().getContentElement( 'info', 'protocol' ),\r
                                                                                                url = this.getValue(),\r
                                                                                                urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi,\r
-                                                                                               urlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi;\r
+                                                                                               urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/gi;\r
 \r
                                                                                        var protocol = urlOnChangeProtocol.exec( url );\r
                                                                                        if ( protocol )\r
@@ -476,7 +480,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
@@ -512,7 +516,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
@@ -527,7 +531,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
@@ -546,7 +550,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
@@ -581,7 +585,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
@@ -623,7 +627,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
@@ -650,7 +654,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
@@ -660,7 +664,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
@@ -683,7 +687,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
@@ -700,7 +704,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
@@ -727,8 +731,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
@@ -739,24 +743,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
+                                                                       targetChanged.call( this );\r
                                                                },\r
                                                                commit : function( data )\r
                                                                {\r
@@ -769,7 +774,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
@@ -781,14 +786,14 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                        if ( !data.target )\r
                                                                                data.target = {};\r
 \r
-                                                                       data.target.name = this.getValue();\r
+                                                                       data.target.name = this.getValue().replace(/\W/gi, '');\r
                                                                }\r
                                                        }\r
                                                ]\r
                                        },\r
                                        {\r
                                                type : 'vbox',\r
-                                               width : 260,\r
+                                               width : '100%',\r
                                                align : 'center',\r
                                                padding : 2,\r
                                                id : 'popupFeatures',\r
@@ -796,7 +801,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
@@ -806,14 +811,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
@@ -827,7 +832,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
@@ -835,7 +840,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
@@ -849,7 +854,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
@@ -857,7 +862,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
@@ -871,7 +876,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
@@ -879,7 +884,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
@@ -892,9 +897,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
@@ -903,8 +908,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
@@ -919,8 +924,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
@@ -929,8 +934,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
@@ -946,8 +951,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
@@ -955,14 +960,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
@@ -970,8 +975,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
@@ -987,21 +992,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
@@ -1010,7 +1015,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
@@ -1025,7 +1030,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
@@ -1033,7 +1038,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
@@ -1043,7 +1048,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
@@ -1067,7 +1072,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
@@ -1076,7 +1081,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
@@ -1092,7 +1097,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
@@ -1101,7 +1106,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
@@ -1116,7 +1121,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
@@ -1136,30 +1141,21 @@ CKEDITOR.dialog.add( 'link', function( editor )
 \r
                        var editor = this.getParentEditor(),\r
                                selection = editor.getSelection(),\r
-                               ranges = selection.getRanges(),\r
-                               element = null,\r
-                               me = this;\r
+                               element = null;\r
+\r
                        // Fill in all the relevant fields if there's already one link selected.\r
-                       if ( ranges.length == 1 )\r
+                       if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) )\r
+                               selection.selectElement( element );\r
+                       else if ( ( element = selection.getSelectedElement() ) && element.is( 'img' )\r
+                                       && element.data( 'cke-real-element-type' )\r
+                                       && element.data( 'cke-real-element-type' ) == 'anchor' )\r
                        {\r
-\r
-                               var rangeRoot = ranges[0].getCommonAncestor( true );\r
-                               element = rangeRoot.getAscendant( 'a', true );\r
-                               if ( element && element.getAttribute( 'href' ) )\r
-                               {\r
-                                       selection.selectElement( element );\r
-                               }\r
-                               else if ( ( element = rangeRoot.getAscendant( 'img', true ) ) &&\r
-                                                element.getAttribute( '_cke_real_element_type' ) &&\r
-                                                element.getAttribute( '_cke_real_element_type' ) == 'anchor' )\r
-                               {\r
-                                       this.fakeObj = element;\r
-                                       element = editor.restoreRealElement( this.fakeObj );\r
-                                       selection.selectElement( this.fakeObj );\r
-                               }\r
-                               else\r
-                                       element = null;\r
+                               this.fakeObj = element;\r
+                               element = editor.restoreRealElement( this.fakeObj );\r
+                               selection.selectElement( this.fakeObj );\r
                        }\r
+                       else\r
+                               element = null;\r
 \r
                        this.setupContent( parseLink.apply( this, [ editor, element ] ) );\r
                },\r
@@ -1179,12 +1175,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
@@ -1231,7 +1227,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
@@ -1259,7 +1255,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
@@ -1268,7 +1267,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
@@ -1302,10 +1301,12 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        {\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
-                                       var text = new CKEDITOR.dom.text( attributes._cke_saved_href, editor.document );\r
+                                       // Short mailto link text view (#5736).\r
+                                       var text = new CKEDITOR.dom.text( data.type == 'email' ?\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
@@ -1334,7 +1335,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        {\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
@@ -1356,9 +1357,13 @@ CKEDITOR.dialog.add( 'link', function( editor )
 \r
                                element.setAttributes( attributes );\r
                                element.removeAttributes( removeAttributes );\r
-                               // Update text view when user changes protocol #4612.\r
-                               if (href == textView)\r
-                                       element.setHtml( attributes._cke_saved_href );\r
+                               // Update text view when user changes protocol (#4612).\r
+                               if ( href == textView || data.type == 'email' && textView.indexOf( '@' ) != -1 )\r
+                               {\r
+                                       // Short mailto link text view (#5736).\r
+                                       element.setHtml( data.type == 'email' ?\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
                                        element.addClass( 'cke_anchor' );\r
@@ -1385,7 +1390,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