Skip to content

Commit 4916487

Browse files
committed
Core: Move disable-selection into its own module
Ref #9647
1 parent f0260fd commit 4916487

File tree

3 files changed

+51
-20
lines changed

3 files changed

+51
-20
lines changed

ui/core.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
define( [
2222
"jquery",
2323
"./data",
24-
"./version" ], factory );
24+
"./disable-selection",
25+
"./version"
26+
], factory );
2527
} else {
2628

2729
// Browser globals
@@ -284,24 +286,6 @@ if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
284286
// deprecated
285287
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
286288

287-
$.fn.extend( {
288-
disableSelection: ( function() {
289-
var eventType = "onselectstart" in document.createElement( "div" ) ?
290-
"selectstart" :
291-
"mousedown";
292-
293-
return function() {
294-
return this.on( eventType + ".ui-disableSelection", function( event ) {
295-
event.preventDefault();
296-
} );
297-
};
298-
} )(),
299-
300-
enableSelection: function() {
301-
return this.off( ".ui-disableSelection" );
302-
}
303-
} );
304-
305289
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
306290
$.ui.plugin = {
307291
add: function( module, option, set ) {

ui/disable-selection.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*!
2+
* jQuery UI Disable Selection @VERSION
3+
* http://jqueryui.com
4+
*
5+
* Copyright jQuery Foundation and other contributors
6+
* Released under the MIT license.
7+
* http://jquery.org/license
8+
*/
9+
10+
//>>label: disableSelection
11+
//>>group: Core
12+
//>>description: Disable selection of text content within the set of matched elements.
13+
//>>docs: http://api.jqueryui.com/disableSelection/
14+
15+
// This file is deprecated
16+
( function( factory ) {
17+
if ( typeof define === "function" && define.amd ) {
18+
19+
// AMD. Register as an anonymous module.
20+
define( [ "jquery", "./version" ], factory );
21+
} else {
22+
23+
// Browser globals
24+
factory( jQuery );
25+
}
26+
} ( function( $ ) {
27+
28+
return $.fn.extend( {
29+
disableSelection: ( function() {
30+
var eventType = "onselectstart" in document.createElement( "div" ) ?
31+
"selectstart" :
32+
"mousedown";
33+
34+
return function() {
35+
return this.on( eventType + ".ui-disableSelection", function( event ) {
36+
event.preventDefault();
37+
} );
38+
};
39+
} )(),
40+
41+
enableSelection: function() {
42+
return this.off( ".ui-disableSelection" );
43+
}
44+
} );
45+
46+
} ) );

ui/resizable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
define([
2424
"jquery",
2525
"./core",
26-
"./version",
26+
"./disable-selection",
2727
"./mouse",
28+
"./version",
2829
"./widget"
2930
], factory );
3031
} else {

0 commit comments

Comments
 (0)