@@ -73,18 +73,6 @@ $.fn.extend({
73
73
this . _focus . apply ( this , arguments ) ;
74
74
} ,
75
75
76
- enableSelection : function ( ) {
77
- return this
78
- . attr ( "unselectable" , "off" )
79
- . css ( "MozUserSelect" , "" ) ;
80
- } ,
81
-
82
- disableSelection : function ( ) {
83
- return this
84
- . attr ( "unselectable" , "on" )
85
- . css ( "MozUserSelect" , "none" ) ;
86
- } ,
87
-
88
76
scrollParent : function ( ) {
89
77
var scrollParent ;
90
78
if ( ( $ . browser . msie && ( / ( s t a t i c | r e l a t i v e ) / ) . test ( this . css ( 'position' ) ) ) || ( / a b s o l u t e / ) . test ( this . css ( 'position' ) ) ) {
@@ -130,6 +118,57 @@ $.fn.extend({
130
118
}
131
119
} ) ;
132
120
121
+ ( function ( ) {
122
+ var elem = document . createElement ( "div" ) ,
123
+ style = elem . style ,
124
+ userSelectProp = "userSelect" in style && "userSelect" ;
125
+
126
+ if ( ! userSelectProp ) {
127
+ $ . each ( [ "Moz" , "Webkit" , "Khtml" ] , function ( i , prefix ) {
128
+ var vendorProp = prefix + "UserSelect" ;
129
+ if ( vendorProp in style ) {
130
+ userSelectProp = vendorProp ;
131
+ return false ;
132
+ }
133
+ } ) ;
134
+ }
135
+ var selectStart = ! userSelectProp && "onselectstart" in elem && "selectstart.mouse" ;
136
+
137
+ elem = null ;
138
+
139
+ $ . fn . extend ( {
140
+ disableSelection : function ( ) {
141
+ if ( userSelectProp ) {
142
+ this . css ( userSelectProp , "none" ) ;
143
+ } else {
144
+ this . find ( "*" ) . andSelf ( ) . attr ( "unselectable" , "on" ) ;
145
+ }
146
+
147
+ if ( selectStart ) {
148
+ this . bind ( selectStart , function ( ) {
149
+ return false ;
150
+ } ) ;
151
+ }
152
+
153
+ return this ;
154
+ } ,
155
+
156
+ enableSelection : function ( ) {
157
+ if ( userSelectProp ) {
158
+ this . css ( userSelectProp , "" ) ;
159
+ } else {
160
+ this . find ( "*" ) . andSelf ( ) . attr ( "unselectable" , "off" ) ;
161
+ }
162
+
163
+ if ( selectStart ) {
164
+ this . unbind ( selectStart ) ;
165
+ }
166
+
167
+ return this ;
168
+ }
169
+ } ) ;
170
+ } ) ( ) ;
171
+
133
172
$ . each ( [ "Width" , "Height" ] , function ( i , name ) {
134
173
var side = name === "Width" ? [ "Left" , "Right" ] : [ "Top" , "Bottom" ] ,
135
174
type = name . toLowerCase ( ) ,
0 commit comments