@@ -99,8 +99,7 @@ $.widget( "ui.resizable", $.ui.mouse, {
99
99
100
100
_create : function ( ) {
101
101
102
- var n , i , handle , axis , hname , margins ,
103
- that = this ,
102
+ var margins ,
104
103
o = this . options ;
105
104
this . _addClass ( "ui-resizable" ) ;
106
105
@@ -159,6 +158,80 @@ $.widget( "ui.resizable", $.ui.mouse, {
159
158
this . _proportionallyResize ( ) ;
160
159
}
161
160
161
+ this . _setupHandles ( ) ;
162
+
163
+ if ( o . autoHide ) {
164
+ $ ( this . element )
165
+ . on ( "mouseenter" , function ( ) {
166
+ if ( o . disabled ) {
167
+ return ;
168
+ }
169
+ that . _removeClass ( "ui-resizable-autohide" ) ;
170
+ that . _handles . show ( ) ;
171
+ } )
172
+ . on ( "mouseleave" , function ( ) {
173
+ if ( o . disabled ) {
174
+ return ;
175
+ }
176
+ if ( ! that . resizing ) {
177
+ that . _addClass ( "ui-resizable-autohide" ) ;
178
+ that . _handles . hide ( ) ;
179
+ }
180
+ } ) ;
181
+ }
182
+
183
+ this . _mouseInit ( ) ;
184
+ } ,
185
+
186
+ _destroy : function ( ) {
187
+
188
+ this . _mouseDestroy ( ) ;
189
+
190
+ var wrapper ,
191
+ _destroy = function ( exp ) {
192
+ $ ( exp )
193
+ . removeData ( "resizable" )
194
+ . removeData ( "ui-resizable" )
195
+ . off ( ".resizable" )
196
+ . find ( ".ui-resizable-handle" )
197
+ . remove ( ) ;
198
+ } ;
199
+
200
+ // TODO: Unwrap at same DOM position
201
+ if ( this . elementIsWrapper ) {
202
+ _destroy ( this . element ) ;
203
+ wrapper = this . element ;
204
+ this . originalElement . css ( {
205
+ position : wrapper . css ( "position" ) ,
206
+ width : wrapper . outerWidth ( ) ,
207
+ height : wrapper . outerHeight ( ) ,
208
+ top : wrapper . css ( "top" ) ,
209
+ left : wrapper . css ( "left" )
210
+ } ) . insertAfter ( wrapper ) ;
211
+ wrapper . remove ( ) ;
212
+ }
213
+
214
+ this . originalElement . css ( "resize" , this . originalResizeStyle ) ;
215
+ _destroy ( this . originalElement ) ;
216
+
217
+ return this ;
218
+ } ,
219
+
220
+ _setOption : function ( key , value ) {
221
+ this . _super ( key , value ) ;
222
+
223
+ switch ( key ) {
224
+ case "handles" :
225
+ this . _removeHandles ( ) ;
226
+ this . _setupHandles ( ) ;
227
+ break ;
228
+ default :
229
+ break ;
230
+ }
231
+ } ,
232
+
233
+ _setupHandles : function ( ) {
234
+ var o = this . options , handle , i , n , hname , axis , that = this ;
162
235
this . handles = o . handles ||
163
236
( ! $ ( ".ui-resizable-handle" , this . element ) . length ?
164
237
"e,s,se" : {
@@ -250,60 +323,11 @@ $.widget( "ui.resizable", $.ui.mouse, {
250
323
if ( o . autoHide ) {
251
324
this . _handles . hide ( ) ;
252
325
this . _addClass ( "ui-resizable-autohide" ) ;
253
- $ ( this . element )
254
- . on ( "mouseenter" , function ( ) {
255
- if ( o . disabled ) {
256
- return ;
257
- }
258
- that . _removeClass ( "ui-resizable-autohide" ) ;
259
- that . _handles . show ( ) ;
260
- } )
261
- . on ( "mouseleave" , function ( ) {
262
- if ( o . disabled ) {
263
- return ;
264
- }
265
- if ( ! that . resizing ) {
266
- that . _addClass ( "ui-resizable-autohide" ) ;
267
- that . _handles . hide ( ) ;
268
- }
269
- } ) ;
270
326
}
271
-
272
- this . _mouseInit ( ) ;
273
327
} ,
274
328
275
- _destroy : function ( ) {
276
-
277
- this . _mouseDestroy ( ) ;
278
-
279
- var wrapper ,
280
- _destroy = function ( exp ) {
281
- $ ( exp )
282
- . removeData ( "resizable" )
283
- . removeData ( "ui-resizable" )
284
- . off ( ".resizable" )
285
- . find ( ".ui-resizable-handle" )
286
- . remove ( ) ;
287
- } ;
288
-
289
- // TODO: Unwrap at same DOM position
290
- if ( this . elementIsWrapper ) {
291
- _destroy ( this . element ) ;
292
- wrapper = this . element ;
293
- this . originalElement . css ( {
294
- position : wrapper . css ( "position" ) ,
295
- width : wrapper . outerWidth ( ) ,
296
- height : wrapper . outerHeight ( ) ,
297
- top : wrapper . css ( "top" ) ,
298
- left : wrapper . css ( "left" )
299
- } ) . insertAfter ( wrapper ) ;
300
- wrapper . remove ( ) ;
301
- }
302
-
303
- this . originalElement . css ( "resize" , this . originalResizeStyle ) ;
304
- _destroy ( this . originalElement ) ;
305
-
306
- return this ;
329
+ _removeHandles : function ( ) {
330
+ this . _handles . remove ( ) ;
307
331
} ,
308
332
309
333
_mouseCapture : function ( event ) {
0 commit comments