mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Core: Refactored .disableSelection() and .enableSelection().
This commit is contained in:
parent
95a34593f9
commit
5de8ced5d9
63
ui/jquery.ui.core.js
vendored
63
ui/jquery.ui.core.js
vendored
@ -115,60 +115,21 @@ $.fn.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
disableSelection: function() {
|
||||||
|
return this.bind(
|
||||||
|
"mousedown.ui-disableSelection selectstart.ui-disableSelection",
|
||||||
|
function( event ) {
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
enableSelection: function() {
|
||||||
|
return this.unbind( ".ui-disableSelection" );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(function() {
|
|
||||||
var elem = document.createElement( "div" ),
|
|
||||||
style = elem.style,
|
|
||||||
userSelectProp = "userSelect" in style && "userSelect";
|
|
||||||
|
|
||||||
if ( !userSelectProp ) {
|
|
||||||
$.each( [ "Moz", "Webkit", "Khtml" ], function( i, prefix ) {
|
|
||||||
var vendorProp = prefix + "UserSelect";
|
|
||||||
if ( vendorProp in style ) {
|
|
||||||
userSelectProp = vendorProp;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var selectStart = !userSelectProp && "onselectstart" in elem && "selectstart.mouse";
|
|
||||||
|
|
||||||
elem = null;
|
|
||||||
|
|
||||||
$.fn.extend({
|
|
||||||
disableSelection: function() {
|
|
||||||
if ( userSelectProp ) {
|
|
||||||
this.css( userSelectProp, "none" );
|
|
||||||
} else {
|
|
||||||
this.find( "*" ).andSelf().attr( "unselectable", "on" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( selectStart ) {
|
|
||||||
this.bind( selectStart, function() {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
enableSelection: function() {
|
|
||||||
if ( userSelectProp ) {
|
|
||||||
this.css( userSelectProp, "" );
|
|
||||||
} else {
|
|
||||||
this.find( "*" ).andSelf().attr( "unselectable", "off" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( selectStart ) {
|
|
||||||
this.unbind( selectStart );
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
|
|
||||||
$.each( [ "Width", "Height" ], function( i, name ) {
|
$.each( [ "Width", "Height" ], function( i, name ) {
|
||||||
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
|
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
|
||||||
type = name.toLowerCase(),
|
type = name.toLowerCase(),
|
||||||
|
Loading…
Reference in New Issue
Block a user