Core: Move disable-selection into its own module

Ref #9647
This commit is contained in:
Alexander Schmitz 2015-07-15 16:49:34 -04:00
parent f0260fd91b
commit 4916487440
3 changed files with 51 additions and 20 deletions

View File

@ -21,7 +21,9 @@
define( [
"jquery",
"./data",
"./version" ], factory );
"./disable-selection",
"./version"
], factory );
} else {
// Browser globals
@ -284,24 +286,6 @@ if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
// deprecated
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
$.fn.extend( {
disableSelection: ( function() {
var eventType = "onselectstart" in document.createElement( "div" ) ?
"selectstart" :
"mousedown";
return function() {
return this.on( eventType + ".ui-disableSelection", function( event ) {
event.preventDefault();
} );
};
} )(),
enableSelection: function() {
return this.off( ".ui-disableSelection" );
}
} );
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
$.ui.plugin = {
add: function( module, option, set ) {

46
ui/disable-selection.js Normal file
View File

@ -0,0 +1,46 @@
/*!
* jQuery UI Disable Selection @VERSION
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*/
//>>label: disableSelection
//>>group: Core
//>>description: Disable selection of text content within the set of matched elements.
//>>docs: http://api.jqueryui.com/disableSelection/
// This file is deprecated
( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery", "./version" ], factory );
} else {
// Browser globals
factory( jQuery );
}
} ( function( $ ) {
return $.fn.extend( {
disableSelection: ( function() {
var eventType = "onselectstart" in document.createElement( "div" ) ?
"selectstart" :
"mousedown";
return function() {
return this.on( eventType + ".ui-disableSelection", function( event ) {
event.preventDefault();
} );
};
} )(),
enableSelection: function() {
return this.off( ".ui-disableSelection" );
}
} );
} ) );

View File

@ -23,8 +23,9 @@
define([
"jquery",
"./core",
"./version",
"./disable-selection",
"./mouse",
"./version",
"./widget"
], factory );
} else {