X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Flink%2Fdialogs%2Flink.js;h=56baa05b7291700c4a69ab86683429cc95a23335;hp=5362b16e3c2612aafd036bae6f5db6dd1f8f41a3;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hpb=9afde8772159bd3436f1f5b7862960307710ae5a diff --git a/_source/plugins/link/dialogs/link.js b/_source/plugins/link/dialogs/link.js index 5362b16..56baa05 100644 --- a/_source/plugins/link/dialogs/link.js +++ b/_source/plugins/link/dialogs/link.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -225,7 +225,11 @@ CKEDITOR.dialog.add( 'link', function( editor ) advAttr( 'advId', 'id' ); advAttr( 'advLangDir', 'dir' ); advAttr( 'advAccessKey', 'accessKey' ); - advAttr( 'advName', 'name' ); + + retval.adv.advName = + element.data( 'cke-saved-name' ) + || element.getAttribute( 'name' ) + || ''; advAttr( 'advLangCode', 'lang' ); advAttr( 'advTabIndex', 'tabindex' ); advAttr( 'advTitle', 'title' ); @@ -450,8 +454,8 @@ CKEDITOR.dialog.add( 'link', function( editor ) this.allowOnChange = false; var protocolCmb = this.getDialog().getContentElement( 'info', 'protocol' ), url = this.getValue(), - urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi, - urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/gi; + urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/i, + urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/i; var protocol = urlOnChangeProtocol.exec( url ); if ( protocol ) @@ -760,7 +764,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) setup : function( data ) { if ( data.target ) - this.setValue( data.target.type ); + this.setValue( data.target.type || 'notSet' ); targetChanged.call( this ); }, commit : function( data ) @@ -1161,9 +1165,9 @@ CKEDITOR.dialog.add( 'link', function( editor ) }, onOk : function() { - var attributes = { href : 'javascript:void(0)/*' + CKEDITOR.tools.getNextNumber() + '*/' }, + var attributes = {}, removeAttributes = [], - data = { href : attributes.href }, + data = {}, me = this, editor = this.getParentEditor(); @@ -1283,11 +1287,18 @@ CKEDITOR.dialog.add( 'link', function( editor ) removeAttributes.push( attrName ); }; - if ( this._.selectedElement ) - advAttr( 'advId', 'id' ); + advAttr( 'advId', 'id' ); advAttr( 'advLangDir', 'dir' ); advAttr( 'advAccessKey', 'accessKey' ); - advAttr( 'advName', 'name' ); + + if ( data.adv[ 'advName' ] ) + { + attributes[ 'name' ] = attributes[ 'data-cke-saved-name' ] = data.adv[ 'advName' ]; + attributes[ 'class' ] = ( attributes[ 'class' ] ? attributes[ 'class' ] + ' ' : '' ) + 'cke_anchor'; + } + else + removeAttributes = removeAttributes.concat( [ 'data-cke-saved-name', 'name' ] ); + advAttr( 'advLangCode', 'lang' ); advAttr( 'advTabIndex', 'tabindex' ); advAttr( 'advTitle', 'title' ); @@ -1297,6 +1308,10 @@ CKEDITOR.dialog.add( 'link', function( editor ) advAttr( 'advStyles', 'style' ); } + + // Browser need the "href" fro copy/paste link to work. (#6641) + attributes.href = attributes[ 'data-cke-saved-href' ]; + if ( !this._.selectedElement ) { // Create element if current selection is collapsed. @@ -1316,20 +1331,6 @@ CKEDITOR.dialog.add( 'link', function( editor ) var style = new CKEDITOR.style( { element : 'a', attributes : attributes } ); style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why. style.apply( editor.document ); - - // Id. Apply only to the first link. - if ( data.adv && data.adv.advId ) - { - var links = this.getParentEditor().document.$.getElementsByTagName( 'a' ); - for ( i = 0 ; i < links.length ; i++ ) - { - if ( links[i].href == attributes.href ) - { - links[i].id = data.adv.advId; - break; - } - } - } } else { @@ -1347,8 +1348,8 @@ CKEDITOR.dialog.add( 'link', function( editor ) selection = editor.getSelection(); - element.moveChildren( newElement ); element.copyAttributes( newElement, { name : 1 } ); + element.moveChildren( newElement ); newElement.replace( element ); element = newElement;