diff options
author | Scott González <scott.gonzalez@gmail.com> | 2010-09-01 09:49:18 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2010-09-01 09:49:18 -0400 |
commit | 5de8ced5d9e8b18d96cb2e3868123dd41402fc00 (patch) | |
tree | 93d26b69a5a1e7fabf0972b489da4da5caca3bd4 /ui/jquery.ui.core.js | |
parent | 95a34593f98217e3a99f223e2ef3ca0a0fa8343b (diff) | |
download | jquery-ui-5de8ced5d9e8b18d96cb2e3868123dd41402fc00.tar.gz jquery-ui-5de8ced5d9e8b18d96cb2e3868123dd41402fc00.zip |
Core: Refactored .disableSelection() and .enableSelection().
Diffstat (limited to 'ui/jquery.ui.core.js')
-rw-r--r-- | ui/jquery.ui.core.js | 63 |
1 files changed, 12 insertions, 51 deletions
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index 364d7b668..f040ef5e1 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -115,59 +115,20 @@ $.fn.extend({ } return 0; - } -}); - -(function() { - var elem = document.createElement( "div" ), - style = elem.style, - userSelectProp = "userSelect" in style && "userSelect"; + }, + + disableSelection: function() { + return this.bind( + "mousedown.ui-disableSelection selectstart.ui-disableSelection", + function( event ) { + event.preventDefault(); + }); + }, - if ( !userSelectProp ) { - $.each( [ "Moz", "Webkit", "Khtml" ], function( i, prefix ) { - var vendorProp = prefix + "UserSelect"; - if ( vendorProp in style ) { - userSelectProp = vendorProp; - return false; - } - }); + enableSelection: function() { + return this.unbind( ".ui-disableSelection" ); } - 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 ) { var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], |