mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
wpLink:
- Prepend 'http://' to pasted URLs. - Do not prepend it when typing an URL. - Do not prepend it when pasting the same URL for the second time (trying to correct wrong guess). Props iseulde. Fixes #18149. Built from https://develop.svn.wordpress.org/trunk@31602 git-svn-id: http://core.svn.wordpress.org/trunk@31583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a9f165915f
commit
1750c89afb
@ -2,7 +2,7 @@
|
|||||||
var wpLink;
|
var wpLink;
|
||||||
|
|
||||||
( function( $ ) {
|
( function( $ ) {
|
||||||
var editor, searchTimer, River, Query,
|
var editor, searchTimer, River, Query, correctedURL,
|
||||||
inputs = {},
|
inputs = {},
|
||||||
rivers = {},
|
rivers = {},
|
||||||
isTouch = ( 'ontouchend' in document );
|
isTouch = ( 'ontouchend' in document );
|
||||||
@ -72,6 +72,17 @@ var wpLink;
|
|||||||
wpLink.searchInternalLinks.call( self );
|
wpLink.searchInternalLinks.call( self );
|
||||||
}, 500 );
|
}, 500 );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
inputs.url.on( 'paste blur', function() {
|
||||||
|
setTimeout( function() {
|
||||||
|
var url = $.trim( inputs.url.val() );
|
||||||
|
|
||||||
|
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
|
||||||
|
inputs.url.val( 'http://' + url );
|
||||||
|
correctedURL = url;
|
||||||
|
}
|
||||||
|
}, 0 );
|
||||||
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function( editorId ) {
|
open: function( editorId ) {
|
||||||
@ -183,6 +194,9 @@ var wpLink;
|
|||||||
|
|
||||||
inputs.backdrop.hide();
|
inputs.backdrop.hide();
|
||||||
inputs.wrap.hide();
|
inputs.wrap.hide();
|
||||||
|
|
||||||
|
correctedURL = false;
|
||||||
|
|
||||||
$( document ).trigger( 'wplink-close', inputs.wrap );
|
$( document ).trigger( 'wplink-close', inputs.wrap );
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -211,7 +225,7 @@ var wpLink;
|
|||||||
attrs = wpLink.getAttrs();
|
attrs = wpLink.getAttrs();
|
||||||
|
|
||||||
// If there's no href, return.
|
// If there's no href, return.
|
||||||
if ( ! attrs.href || attrs.href == 'http://' )
|
if ( ! attrs.href )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Build HTML
|
// Build HTML
|
||||||
@ -309,7 +323,7 @@ var wpLink;
|
|||||||
inputs.url.val( selection.replace( /&|�?38;/gi, '&' ) );
|
inputs.url.val( selection.replace( /&|�?38;/gi, '&' ) );
|
||||||
} else {
|
} else {
|
||||||
// Set URL to default.
|
// Set URL to default.
|
||||||
inputs.url.val( 'http://' );
|
inputs.url.val( '' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set description to default.
|
// Set description to default.
|
||||||
|
2
wp-includes/js/wplink.min.js
vendored
2
wp-includes/js/wplink.min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31601';
|
$wp_version = '4.2-alpha-31602';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user