/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
}\r
\r
// Find out whether we have any anchors in the editor.\r
- var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors ),\r
- anchors = retval.anchors = [],\r
- item;\r
+ var anchors = retval.anchors = [],\r
+ i, count, item;\r
\r
- for ( var i = 0, count = anchorList.count(); i < count; i++ )\r
+ // For some browsers we set contenteditable="false" on anchors, making document.anchors not to include them, so we must traverse the links manually (#7893).\r
+ if ( CKEDITOR.plugins.link.emptyAnchorFix )\r
{\r
- item = anchorList.getItem( i );\r
- anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };\r
+ var links = editor.document.getElementsByTag( 'a' );\r
+ for ( i = 0, count = links.count(); i < count; i++ )\r
+ {\r
+ item = links.getItem( i );\r
+ if ( item.data( 'cke-saved-name' ) || item.hasAttribute( 'name' ) )\r
+ anchors.push( { name : item.data( 'cke-saved-name' ) || item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );\r
+ }\r
+ }\r
+ else\r
+ {\r
+ var anchorList = new CKEDITOR.dom.nodeList( editor.document.$.anchors );\r
+ for ( i = 0, count = anchorList.count(); i < count; i++ )\r
+ {\r
+ item = anchorList.getItem( i );\r
+ anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };\r
+ }\r
+ }\r
+\r
+ if ( CKEDITOR.plugins.link.fakeAnchor )\r
+ {\r
+ var imgs = editor.document.getElementsByTag( 'img' );\r
+ for ( i = 0, count = imgs.count(); i < count; i++ )\r
+ {\r
+ if ( ( item = CKEDITOR.plugins.link.tryRestoreFakeAnchor( editor, imgs.getItem( i ) ) ) )\r
+ anchors.push( { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );\r
+ }\r
}\r
\r
// Record down the selected element in the dialog.\r
type : 'html',\r
id : 'noAnchors',\r
style : 'text-align: center;',\r
- html : '<div role="label" tabIndex="-1">' + CKEDITOR.tools.htmlEncode( linkLang.noAnchors ) + '</div>',\r
+ html : '<div role="note" tabIndex="-1">' + CKEDITOR.tools.htmlEncode( linkLang.noAnchors ) + '</div>',\r
// Focus the first element defined in above html.\r
focus : true,\r
setup : function( data )\r
label : linkLang.styles,\r
'default' : '',\r
id : 'advStyles',\r
+ validate : CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ),\r
setup : setupAdvParams,\r
commit : commitAdvParams\r
}\r
{\r
case 'url':\r
var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://',\r
- url = ( data.url && data.url.url ) || '';\r
+ url = ( data.url && CKEDITOR.tools.trim( data.url.url ) ) || '';\r
attributes[ 'data-cke-saved-href' ] = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;\r
break;\r
case 'anchor':\r
}\r
\r
\r
+ var selection = editor.getSelection();\r
+\r
// Browser need the "href" fro copy/paste link to work. (#6641)\r
attributes.href = attributes[ 'data-cke-saved-href' ];\r
\r
if ( !this._.selectedElement )\r
{\r
// Create element if current selection is collapsed.\r
- var selection = editor.getSelection(),\r
- ranges = selection.getRanges( true );\r
+ var ranges = selection.getRanges( true );\r
if ( ranges.length == 1 && ranges[0].collapsed )\r
{\r
// Short mailto link text view (#5736).\r
data.email.address : attributes[ 'data-cke-saved-href' ] );\r
}\r
\r
+ selection.selectElement( element );\r
delete this._.selectedElement;\r
}\r
},\r