JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2
[ckeditor.git] / _source / plugins / link / dialogs / link.js
index f904e03..c7388ca 100644 (file)
@@ -380,7 +380,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                'default' : 'url',\r
                                                items :\r
                                                [\r
-                                                       [ editor.lang.common.url, 'url' ],\r
+                                                       [ editor.lang.link.toUrl, 'url' ],\r
                                                        [ editor.lang.link.toAnchor, 'anchor' ],\r
                                                        [ editor.lang.link.toEmail, 'email' ]\r
                                                ],\r
@@ -436,6 +436,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                type : 'text',\r
                                                                                id : 'url',\r
                                                                                label : editor.lang.common.url,\r
+                                                                               required: true,\r
                                                                                onLoad : function ()\r
                                                                                {\r
                                                                                        this.allowOnChange = true;\r
@@ -485,10 +486,6 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                                this.setValue( data.url.url );\r
                                                                                        this.allowOnChange = true;\r
 \r
-                                                                                       var linkType = this.getDialog().getContentElement( 'info', 'linkType' );\r
-                                                                                       if ( linkType && linkType.getValue() == 'url' )\r
-                                                                                               this.select();\r
-\r
                                                                                },\r
                                                                                commit : function( data )\r
                                                                                {\r
@@ -528,105 +525,110 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                children :\r
                                                [\r
                                                        {\r
-                                                               type : 'html',\r
+                                                               type : 'fieldset',\r
                                                                id : 'selectAnchorText',\r
-                                                               html : CKEDITOR.tools.htmlEncode( editor.lang.link.selectAnchor ),\r
+                                                               label : editor.lang.link.selectAnchor,\r
                                                                setup : function( data )\r
                                                                {\r
                                                                        if ( data.anchors.length > 0 )\r
                                                                                this.getElement().show();\r
                                                                        else\r
                                                                                this.getElement().hide();\r
-                                                               }\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'html',\r
-                                                               id : 'noAnchors',\r
-                                                               style : 'text-align: center;',\r
-                                                               html : '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.link.noAnchors ) + '</div>',\r
-                                                               setup : function( data )\r
-                                                               {\r
-                                                                       if ( data.anchors.length < 1 )\r
-                                                                               this.getElement().show();\r
-                                                                       else\r
-                                                                               this.getElement().hide();\r
-                                                               }\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
-                                                               id : 'selectAnchor',\r
+                                                               },\r
                                                                children :\r
                                                                [\r
                                                                        {\r
-                                                                               type : 'select',\r
-                                                                               id : 'anchorName',\r
-                                                                               'default' : '',\r
-                                                                               label : editor.lang.link.anchorName,\r
-                                                                               style : 'width: 100%;',\r
-                                                                               items :\r
+                                                                               type : 'hbox',\r
+                                                                               id : 'selectAnchor',\r
+                                                                               children :\r
                                                                                [\r
-                                                                                       [ '' ]\r
-                                                                               ],\r
-                                                                               setup : function( data )\r
-                                                                               {\r
-                                                                                       this.clear();\r
-                                                                                       this.add( '' );\r
-                                                                                       for ( var i = 0 ; i < data.anchors.length ; i++ )\r
                                                                                        {\r
-                                                                                               if ( data.anchors[i].name )\r
-                                                                                                       this.add( data.anchors[i].name );\r
+                                                                                               type : 'select',\r
+                                                                                               id : 'anchorName',\r
+                                                                                               'default' : '',\r
+                                                                                               label : editor.lang.link.anchorName,\r
+                                                                                               style : 'width: 100%;',\r
+                                                                                               items :\r
+                                                                                               [\r
+                                                                                                       [ '' ]\r
+                                                                                               ],\r
+                                                                                               setup : function( data )\r
+                                                                                               {\r
+                                                                                                       this.clear();\r
+                                                                                                       this.add( '' );\r
+                                                                                                       for ( var i = 0 ; i < data.anchors.length ; i++ )\r
+                                                                                                       {\r
+                                                                                                               if ( data.anchors[i].name )\r
+                                                                                                                       this.add( data.anchors[i].name );\r
+                                                                                                       }\r
+\r
+                                                                                                       if ( data.anchor )\r
+                                                                                                               this.setValue( data.anchor.name );\r
+\r
+                                                                                                       var linkType = this.getDialog().getContentElement( 'info', 'linkType' );\r
+                                                                                                       if ( linkType && linkType.getValue() == 'email' )\r
+                                                                                                               this.focus();\r
+                                                                                               },\r
+                                                                                               commit : function( data )\r
+                                                                                               {\r
+                                                                                                       if ( !data.anchor )\r
+                                                                                                               data.anchor = {};\r
+\r
+                                                                                                       data.anchor.name = this.getValue();\r
+                                                                                               }\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type : 'select',\r
+                                                                                               id : 'anchorId',\r
+                                                                                               'default' : '',\r
+                                                                                               label : editor.lang.link.anchorId,\r
+                                                                                               style : 'width: 100%;',\r
+                                                                                               items :\r
+                                                                                               [\r
+                                                                                                       [ '' ]\r
+                                                                                               ],\r
+                                                                                               setup : function( data )\r
+                                                                                               {\r
+                                                                                                       this.clear();\r
+                                                                                                       this.add( '' );\r
+                                                                                                       for ( var i = 0 ; i < data.anchors.length ; i++ )\r
+                                                                                                       {\r
+                                                                                                               if ( data.anchors[i].id )\r
+                                                                                                                       this.add( data.anchors[i].id );\r
+                                                                                                       }\r
+\r
+                                                                                                       if ( data.anchor )\r
+                                                                                                               this.setValue( data.anchor.id );\r
+                                                                                               },\r
+                                                                                               commit : function( data )\r
+                                                                                               {\r
+                                                                                                       if ( !data.anchor )\r
+                                                                                                               data.anchor = {};\r
+\r
+                                                                                                       data.anchor.id = this.getValue();\r
+                                                                                               }\r
                                                                                        }\r
-\r
-                                                                                       if ( data.anchor )\r
-                                                                                               this.setValue( data.anchor.name );\r
-\r
-                                                                                       var linkType = this.getDialog().getContentElement( 'info', 'linkType' );\r
-                                                                                       if ( linkType && linkType.getValue() == 'email' )\r
-                                                                                               this.focus();\r
-                                                                               },\r
-                                                                               commit : function( data )\r
-                                                                               {\r
-                                                                                       if ( !data.anchor )\r
-                                                                                               data.anchor = {};\r
-\r
-                                                                                       data.anchor.name = this.getValue();\r
-                                                                               }\r
-                                                                       },\r
-                                                                       {\r
-                                                                               type : 'select',\r
-                                                                               id : 'anchorId',\r
-                                                                               'default' : '',\r
-                                                                               label : editor.lang.link.anchorId,\r
-                                                                               style : 'width: 100%;',\r
-                                                                               items :\r
-                                                                               [\r
-                                                                                       [ '' ]\r
                                                                                ],\r
                                                                                setup : function( data )\r
                                                                                {\r
-                                                                                       this.clear();\r
-                                                                                       this.add( '' );\r
-                                                                                       for ( var i = 0 ; i < data.anchors.length ; i++ )\r
-                                                                                       {\r
-                                                                                               if ( data.anchors[i].id )\r
-                                                                                                       this.add( data.anchors[i].id );\r
-                                                                                       }\r
-\r
-                                                                                       if ( data.anchor )\r
-                                                                                               this.setValue( data.anchor.id );\r
-                                                                               },\r
-                                                                               commit : function( data )\r
-                                                                               {\r
-                                                                                       if ( !data.anchor )\r
-                                                                                               data.anchor = {};\r
-\r
-                                                                                       data.anchor.id = this.getValue();\r
+                                                                                       if ( data.anchors.length > 0 )\r
+                                                                                               this.getElement().show();\r
+                                                                                       else\r
+                                                                                               this.getElement().hide();\r
                                                                                }\r
                                                                        }\r
-                                                               ],\r
+                                                               ]\r
+                                                       },\r
+                                                       {\r
+                                                               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
+                                                               // Focus the first element defined in above html.\r
+                                                               focus : true,\r
                                                                setup : function( data )\r
                                                                {\r
-                                                                       if ( data.anchors.length > 0 )\r
+                                                                       if ( data.anchors.length < 1 )\r
                                                                                this.getElement().show();\r
                                                                        else\r
                                                                                this.getElement().hide();\r
@@ -649,6 +651,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                type : 'text',\r
                                                                id : 'emailAddress',\r
                                                                label : editor.lang.link.emailAddress,\r
+                                                               required : true,\r
                                                                validate : function()\r
                                                                {\r
                                                                        var dialog = this.getDialog();\r
@@ -736,18 +739,18 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                        {\r
                                                                type : 'select',\r
                                                                id : 'linkTargetType',\r
-                                                               label : editor.lang.link.target,\r
+                                                               label : editor.lang.common.target,\r
                                                                'default' : 'notSet',\r
                                                                style : 'width : 100%;',\r
                                                                'items' :\r
                                                                [\r
-                                                                       [ editor.lang.link.targetNotSet, 'notSet' ],\r
+                                                                       [ editor.lang.common.notSet, 'notSet' ],\r
                                                                        [ editor.lang.link.targetFrame, 'frame' ],\r
                                                                        [ editor.lang.link.targetPopup, 'popup' ],\r
-                                                                       [ editor.lang.link.targetNew, '_blank' ],\r
-                                                                       [ editor.lang.link.targetTop, '_top' ],\r
-                                                                       [ editor.lang.link.targetSelf, '_self' ],\r
-                                                                       [ editor.lang.link.targetParent, '_parent' ]\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
                                                                ],\r
                                                                onChange : targetChanged,\r
                                                                setup : function( data )\r
@@ -792,145 +795,148 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                children :\r
                                                [\r
                                                        {\r
-                                                               type : 'html',\r
-                                                               html : CKEDITOR.tools.htmlEncode( editor.lang.link.popupFeatures )\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
+                                                               type : 'fieldset',\r
+                                                               label : editor.lang.link.popupFeatures,\r
                                                                children :\r
                                                                [\r
                                                                        {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'resizable',\r
-                                                                               label : editor.lang.link.popupResizable,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
-                                                                       },\r
-                                                                       {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'status',\r
-                                                                               label : editor.lang.link.popupStatusBar,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
-\r
-                                                                       }\r
-                                                               ]\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
-                                                               children :\r
-                                                               [\r
-                                                                       {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'location',\r
-                                                                               label : editor.lang.link.popupLocationBar,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                               type : 'hbox',\r
+                                                                               children :\r
+                                                                               [\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'resizable',\r
+                                                                                               label : editor.lang.link.popupResizable,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'status',\r
+                                                                                               label : editor.lang.link.popupStatusBar,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
+                                                                                       }\r
+                                                                               ]\r
                                                                        },\r
                                                                        {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'toolbar',\r
-                                                                               label : editor.lang.link.popupToolbar,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                               type : 'hbox',\r
+                                                                               children :\r
+                                                                               [\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'location',\r
+                                                                                               label : editor.lang.link.popupLocationBar,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
-                                                                       }\r
-                                                               ]\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
-                                                               children :\r
-                                                               [\r
-                                                                       {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'menubar',\r
-                                                                               label : editor.lang.link.popupMenuBar,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'toolbar',\r
+                                                                                               label : editor.lang.link.popupToolbar,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
+                                                                                       }\r
+                                                                               ]\r
                                                                        },\r
                                                                        {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'fullscreen',\r
-                                                                               label : editor.lang.link.popupFullScreen,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                               type : 'hbox',\r
+                                                                               children :\r
+                                                                               [\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'menubar',\r
+                                                                                               label : editor.lang.link.popupMenuBar,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
-                                                                       }\r
-                                                               ]\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
-                                                               children :\r
-                                                               [\r
-                                                                       {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'scrollbars',\r
-                                                                               label : editor.lang.link.popupScrollBars,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'fullscreen',\r
+                                                                                               label : editor.lang.link.popupFullScreen,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
+                                                                                       }\r
+                                                                               ]\r
                                                                        },\r
                                                                        {\r
-                                                                               type : 'checkbox',\r
-                                                                               id : 'dependent',\r
-                                                                               label : editor.lang.link.popupDependent,\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                               type : 'hbox',\r
+                                                                               children :\r
+                                                                               [\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'scrollbars',\r
+                                                                                               label : editor.lang.link.popupScrollBars,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
-                                                                       }\r
-                                                               ]\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
-                                                               children :\r
-                                                               [\r
-                                                                       {\r
-                                                                               type :  'text',\r
-                                                                               widths : [ '30%', '70%' ],\r
-                                                                               labelLayout : 'horizontal',\r
-                                                                               label : editor.lang.link.popupWidth,\r
-                                                                               id : 'width',\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type : 'checkbox',\r
+                                                                                               id : 'dependent',\r
+                                                                                               label : editor.lang.link.popupDependent,\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
+                                                                                       }\r
+                                                                               ]\r
                                                                        },\r
                                                                        {\r
-                                                                               type :  'text',\r
-                                                                               labelLayout : 'horizontal',\r
-                                                                               widths : [ '55%', '45%' ],\r
-                                                                               label : editor.lang.link.popupLeft,\r
-                                                                               id : 'left',\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
-\r
-                                                                       }\r
-                                                               ]\r
-                                                       },\r
-                                                       {\r
-                                                               type : 'hbox',\r
-                                                               children :\r
-                                                               [\r
-                                                                       {\r
-                                                                               type :  'text',\r
-                                                                               labelLayout : 'horizontal',\r
-                                                                               widths : [ '30%', '70%' ],\r
-                                                                               label : editor.lang.link.popupHeight,\r
-                                                                               id : 'height',\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                               type : 'hbox',\r
+                                                                               children :\r
+                                                                               [\r
+                                                                                       {\r
+                                                                                               type :  'text',\r
+                                                                                               widths : [ '30%', '70%' ],\r
+                                                                                               labelLayout : 'horizontal',\r
+                                                                                               label : editor.lang.link.popupWidth,\r
+                                                                                               id : 'width',\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
+\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type :  'text',\r
+                                                                                               labelLayout : 'horizontal',\r
+                                                                                               widths : [ '55%', '45%' ],\r
+                                                                                               label : editor.lang.link.popupLeft,\r
+                                                                                               id : 'left',\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
+                                                                                       }\r
+                                                                               ]\r
                                                                        },\r
                                                                        {\r
-                                                                               type :  'text',\r
-                                                                               labelLayout : 'horizontal',\r
-                                                                               label : editor.lang.link.popupTop,\r
-                                                                               widths : [ '55%', '45%' ],\r
-                                                                               id : 'top',\r
-                                                                               setup : setupPopupParams,\r
-                                                                               commit : commitPopupParams\r
+                                                                               type : 'hbox',\r
+                                                                               children :\r
+                                                                               [\r
+                                                                                       {\r
+                                                                                               type :  'text',\r
+                                                                                               labelLayout : 'horizontal',\r
+                                                                                               widths : [ '30%', '70%' ],\r
+                                                                                               label : editor.lang.link.popupHeight,\r
+                                                                                               id : 'height',\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
+\r
+                                                                                       },\r
+                                                                                       {\r
+                                                                                               type :  'text',\r
+                                                                                               labelLayout : 'horizontal',\r
+                                                                                               label : editor.lang.link.popupTop,\r
+                                                                                               widths : [ '55%', '45%' ],\r
+                                                                                               id : 'top',\r
+                                                                                               setup : setupPopupParams,\r
+                                                                                               commit : commitPopupParams\r
 \r
+                                                                                       }\r
+                                                                               ]\r
                                                                        }\r
                                                                ]\r
                                                        }\r
@@ -993,7 +999,7 @@ CKEDITOR.dialog.add( 'link', function( editor )
                                                                                style : 'width:110px',\r
                                                                                items :\r
                                                                                [\r
-                                                                                       [ editor.lang.link.langDirNotSet, '' ],\r
+                                                                                       [ editor.lang.common.notSet, '' ],\r
                                                                                        [ editor.lang.link.langDirLTR, 'ltr' ],\r
                                                                                        [ editor.lang.link.langDirRTL, 'rtl' ]\r
                                                                                ],\r
@@ -1373,6 +1379,17 @@ CKEDITOR.dialog.add( 'link', function( editor )
                        if ( !editor.config.linkShowTargetTab )\r
                                this.hidePage( 'target' );              //Hide Target tab.\r
 \r
+               },\r
+               // Inital focus on 'url' field if link is of type URL.\r
+               onFocus : function()\r
+               {\r
+                       var linkType = this.getContentElement( 'info', 'linkType' ),\r
+                                       urlField;\r
+                       if ( linkType && linkType.getValue( ) == 'url' )\r
+                       {\r
+                               urlField = this.getContentElement( 'info', 'url' );\r
+                               urlField.select();\r
+                       }\r
                }\r
        };\r
 });\r