X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Flink%2Fdialogs%2Flink.js;h=4ac6766aefebf192ffe005607e54c648a0db3ce1;hb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;hp=c7388ca639efad04b417e2349785a9e4f68305dc;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/link/dialogs/link.js b/_source/plugins/link/dialogs/link.js index c7388ca..4ac6766 100644 --- a/_source/plugins/link/dialogs/link.js +++ b/_source/plugins/link/dialogs/link.js @@ -5,6 +5,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.dialog.add( 'link', function( editor ) { + var plugin = CKEDITOR.plugins.link; // Handles the event when the "Target" selection box is changed. var targetChanged = function() { @@ -93,7 +94,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) var parseLink = function( editor, element ) { - var href = element ? ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) : '', + var href = ( element && ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) ) || '', javascriptMatch, emailMatch, anchorMatch, @@ -417,7 +418,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) [ 'https://' ], [ 'ftp://' ], [ 'news://' ], - [ '', '' ] + [ editor.lang.link.other , '' ] ], setup : function( data ) { @@ -447,7 +448,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) var protocolCmb = this.getDialog().getContentElement( 'info', 'protocol' ), url = this.getValue(), urlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi, - urlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi; + urlOnChangeTestOther = /^((javascript:)|[#\/\.\?])/gi; var protocol = urlOnChangeProtocol.exec( url ); if ( protocol ) @@ -781,7 +782,7 @@ CKEDITOR.dialog.add( 'link', function( editor ) if ( !data.target ) data.target = {}; - data.target.name = this.getValue(); + data.target.name = this.getValue().replace(/\W/gi, ''); } } ] @@ -1136,30 +1137,21 @@ CKEDITOR.dialog.add( 'link', function( editor ) var editor = this.getParentEditor(), selection = editor.getSelection(), - ranges = selection.getRanges(), - element = null, - me = this; + element = null; + // Fill in all the relevant fields if there's already one link selected. - if ( ranges.length == 1 ) + if ( ( element = plugin.getSelectedLink( editor ) ) && element.hasAttribute( 'href' ) ) + selection.selectElement( element ); + else if ( ( element = selection.getSelectedElement() ) && element.is( 'img' ) + && element.getAttribute( '_cke_real_element_type' ) + && element.getAttribute( '_cke_real_element_type' ) == 'anchor' ) { - - var rangeRoot = ranges[0].getCommonAncestor( true ); - element = rangeRoot.getAscendant( 'a', true ); - if ( element && element.getAttribute( 'href' ) ) - { - selection.selectElement( element ); - } - else if ( ( element = rangeRoot.getAscendant( 'img', true ) ) && - element.getAttribute( '_cke_real_element_type' ) && - element.getAttribute( '_cke_real_element_type' ) == 'anchor' ) - { - this.fakeObj = element; - element = editor.restoreRealElement( this.fakeObj ); - selection.selectElement( this.fakeObj ); - } - else - element = null; + this.fakeObj = element; + element = editor.restoreRealElement( this.fakeObj ); + selection.selectElement( this.fakeObj ); } + else + element = null; this.setupContent( parseLink.apply( this, [ editor, element ] ) ); },