\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
\r
var parseLink = function( editor, element )\r
{\r
- var href = element ? ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) : '',\r
+ var href = ( element && ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) ) || '',\r
javascriptMatch,\r
emailMatch,\r
anchorMatch,\r
'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
type : 'select',\r
label : editor.lang.common.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
+ [ editor.lang.link.other , '' ]\r
],\r
setup : function( data )\r
{\r
type : 'text',\r
id : 'url',\r
label : editor.lang.common.url,\r
+ required: true,\r
onLoad : function ()\r
{\r
this.allowOnChange = true;\r
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
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
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
type : 'text',\r
id : 'emailAddress',\r
label : editor.lang.link.emailAddress,\r
+ required : true,\r
validate : function()\r
{\r
var dialog = this.getDialog();\r
{\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
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
children :\r
[\r
{\r
- type : 'html',\r
- html : CKEDITOR.tools.htmlEncode( editor.lang.link.popupFeatures )\r
- },\r
- {\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 : 'hbox',\r
+ type : 'fieldset',\r
+ label : editor.lang.link.popupFeatures,\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
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
\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.getAttribute( '_cke_real_element_type' )\r
+ && element.getAttribute( '_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
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