15
15
*/
16
16
( function ( $ , undefined ) {
17
17
18
- function num ( v ) {
19
- return parseInt ( v , 10 ) || 0 ;
20
- }
21
-
22
- function isNumber ( value ) {
23
- return ! isNaN ( parseInt ( value , 10 ) ) ;
24
- }
25
-
26
- function hasScroll ( el , a ) {
27
-
28
- //If overflow is hidden, the element might have extra content, but the user wants to hide it
29
- if ( $ ( el ) . css ( "overflow" ) === "hidden" ) {
30
- return false ;
31
- }
32
-
33
- var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop" ,
34
- has = false ;
35
-
36
- if ( el [ scroll ] > 0 ) {
37
- return true ;
38
- }
39
-
40
- // TODO: determine which cases actually cause this to happen
41
- // if the element doesn't have the scroll set, see if it's possible to
42
- // set the scroll
43
- el [ scroll ] = 1 ;
44
- has = ( el [ scroll ] > 0 ) ;
45
- el [ scroll ] = 0 ;
46
- return has ;
47
- }
48
-
49
18
$ . widget ( "ui.resizable" , $ . ui . mouse , {
50
19
version : "@VERSION" ,
51
20
widgetEventPrefix : "resize" ,
@@ -73,6 +42,38 @@ $.widget("ui.resizable", $.ui.mouse, {
73
42
start : null ,
74
43
stop : null
75
44
} ,
45
+
46
+ _num : function ( value ) {
47
+ return parseInt ( value , 10 ) || 0 ;
48
+ } ,
49
+
50
+ _isNumber : function ( value ) {
51
+ return ! isNaN ( parseInt ( value , 10 ) ) ;
52
+ } ,
53
+
54
+ _hasScroll : function ( el , a ) {
55
+
56
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
57
+ if ( $ ( el ) . css ( "overflow" ) === "hidden" ) {
58
+ return false ;
59
+ }
60
+
61
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop" ,
62
+ has = false ;
63
+
64
+ if ( el [ scroll ] > 0 ) {
65
+ return true ;
66
+ }
67
+
68
+ // TODO: determine which cases actually cause this to happen
69
+ // if the element doesn't have the scroll set, see if it's possible to
70
+ // set the scroll
71
+ el [ scroll ] = 1 ;
72
+ has = ( el [ scroll ] > 0 ) ;
73
+ el [ scroll ] = 0 ;
74
+ return has ;
75
+ } ,
76
+
76
77
_create : function ( ) {
77
78
78
79
var n , i , handle , axis , hname ,
@@ -305,8 +306,8 @@ $.widget("ui.resizable", $.ui.mouse, {
305
306
306
307
this . _renderProxy ( ) ;
307
308
308
- curleft = num ( this . helper . css ( "left" ) ) ;
309
- curtop = num ( this . helper . css ( "top" ) ) ;
309
+ curleft = this . _num ( this . helper . css ( "left" ) ) ;
310
+ curtop = this . _num ( this . helper . css ( "top" ) ) ;
310
311
311
312
if ( o . containment ) {
312
313
curleft += $ ( o . containment ) . scrollLeft ( ) || 0 ;
@@ -404,7 +405,7 @@ $.widget("ui.resizable", $.ui.mouse, {
404
405
405
406
pr = this . _proportionallyResizeElements ;
406
407
ista = pr . length && ( / t e x t a r e a / i) . test ( pr [ 0 ] . nodeName ) ;
407
- soffseth = ista && hasScroll ( pr [ 0 ] , "left" ) /* TODO - jump height */ ? 0 : that . sizeDiff . height ;
408
+ soffseth = ista && this . _hasScroll ( pr [ 0 ] , "left" ) /* TODO - jump height */ ? 0 : that . sizeDiff . height ;
408
409
soffsetw = ista ? 0 : that . sizeDiff . width ;
409
410
410
411
s = { width : ( that . helper . width ( ) - soffsetw ) , height : ( that . helper . height ( ) - soffseth ) } ;
@@ -442,10 +443,10 @@ $.widget("ui.resizable", $.ui.mouse, {
442
443
o = this . options ;
443
444
444
445
b = {
445
- minWidth : isNumber ( o . minWidth ) ? o . minWidth : 0 ,
446
- maxWidth : isNumber ( o . maxWidth ) ? o . maxWidth : Infinity ,
447
- minHeight : isNumber ( o . minHeight ) ? o . minHeight : 0 ,
448
- maxHeight : isNumber ( o . maxHeight ) ? o . maxHeight : Infinity
446
+ minWidth : this . _isNumber ( o . minWidth ) ? o . minWidth : 0 ,
447
+ maxWidth : this . _isNumber ( o . maxWidth ) ? o . maxWidth : Infinity ,
448
+ minHeight : this . _isNumber ( o . minHeight ) ? o . minHeight : 0 ,
449
+ maxHeight : this . _isNumber ( o . maxHeight ) ? o . maxHeight : Infinity
449
450
} ;
450
451
451
452
if ( this . _aspectRatio || forceAspectRatio ) {
@@ -474,16 +475,16 @@ $.widget("ui.resizable", $.ui.mouse, {
474
475
475
476
_updateCache : function ( data ) {
476
477
this . offset = this . helper . offset ( ) ;
477
- if ( isNumber ( data . left ) ) {
478
+ if ( this . _isNumber ( data . left ) ) {
478
479
this . position . left = data . left ;
479
480
}
480
- if ( isNumber ( data . top ) ) {
481
+ if ( this . _isNumber ( data . top ) ) {
481
482
this . position . top = data . top ;
482
483
}
483
- if ( isNumber ( data . height ) ) {
484
+ if ( this . _isNumber ( data . height ) ) {
484
485
this . size . height = data . height ;
485
486
}
486
- if ( isNumber ( data . width ) ) {
487
+ if ( this . _isNumber ( data . width ) ) {
487
488
this . size . width = data . width ;
488
489
}
489
490
} ,
@@ -494,9 +495,9 @@ $.widget("ui.resizable", $.ui.mouse, {
494
495
csize = this . size ,
495
496
a = this . axis ;
496
497
497
- if ( isNumber ( data . height ) ) {
498
+ if ( this . _isNumber ( data . height ) ) {
498
499
data . width = ( data . height * this . aspectRatio ) ;
499
- } else if ( isNumber ( data . width ) ) {
500
+ } else if ( this . _isNumber ( data . width ) ) {
500
501
data . height = ( data . width / this . aspectRatio ) ;
501
502
}
502
503
@@ -516,8 +517,8 @@ $.widget("ui.resizable", $.ui.mouse, {
516
517
517
518
var o = this . _vBoundaries ,
518
519
a = this . axis ,
519
- ismaxw = isNumber ( data . width ) && o . maxWidth && ( o . maxWidth < data . width ) , ismaxh = isNumber ( data . height ) && o . maxHeight && ( o . maxHeight < data . height ) ,
520
- isminw = isNumber ( data . width ) && o . minWidth && ( o . minWidth > data . width ) , isminh = isNumber ( data . height ) && o . minHeight && ( o . minHeight > data . height ) ,
520
+ ismaxw = this . _isNumber ( data . width ) && o . maxWidth && ( o . maxWidth < data . width ) , ismaxh = this . _isNumber ( data . height ) && o . maxHeight && ( o . maxHeight < data . height ) ,
521
+ isminw = this . _isNumber ( data . width ) && o . minWidth && ( o . minWidth > data . width ) , isminh = this . _isNumber ( data . height ) && o . minHeight && ( o . minHeight > data . height ) ,
521
522
dw = this . originalPosition . left + this . originalSize . width ,
522
523
dh = this . position . top + this . size . height ,
523
524
cw = / s w | n w | w / . test ( a ) , ch = / n w | n e | n / . test ( a ) ;
@@ -678,7 +679,7 @@ $.ui.plugin.add("resizable", "animate", {
678
679
o = that . options ,
679
680
pr = that . _proportionallyResizeElements ,
680
681
ista = pr . length && ( / t e x t a r e a / i) . test ( pr [ 0 ] . nodeName ) ,
681
- soffseth = ista && hasScroll ( pr [ 0 ] , "left" ) /* TODO - jump height */ ? 0 : that . sizeDiff . height ,
682
+ soffseth = ista && that . _hasScroll ( pr [ 0 ] , "left" ) /* TODO - jump height */ ? 0 : that . sizeDiff . height ,
682
683
soffsetw = ista ? 0 : that . sizeDiff . width ,
683
684
style = { width : ( that . size . width - soffsetw ) , height : ( that . size . height - soffseth ) } ,
684
685
left = ( parseInt ( that . element . css ( "left" ) , 10 ) + ( that . position . left - that . originalPosition . left ) ) || null ,
@@ -742,7 +743,7 @@ $.ui.plugin.add("resizable", "containment", {
742
743
else {
743
744
element = $ ( ce ) ;
744
745
p = [ ] ;
745
- $ ( [ "Top" , "Right" , "Left" , "Bottom" ] ) . each ( function ( i , name ) { p [ i ] = num ( element . css ( "padding" + name ) ) ; } ) ;
746
+ $ ( [ "Top" , "Right" , "Left" , "Bottom" ] ) . each ( function ( i , name ) { p [ i ] = that . _num ( element . css ( "padding" + name ) ) ; } ) ;
746
747
747
748
that . containerOffset = element . offset ( ) ;
748
749
that . containerPosition = element . position ( ) ;
@@ -751,8 +752,8 @@ $.ui.plugin.add("resizable", "containment", {
751
752
co = that . containerOffset ;
752
753
ch = that . containerSize . height ;
753
754
cw = that . containerSize . width ;
754
- width = ( hasScroll ( ce , "left" ) ? ce . scrollWidth : cw ) ;
755
- height = ( hasScroll ( ce ) ? ce . scrollHeight : ch ) ;
755
+ width = ( that . _hasScroll ( ce , "left" ) ? ce . scrollWidth : cw ) ;
756
+ height = ( that . _hasScroll ( ce ) ? ce . scrollHeight : ch ) ;
756
757
757
758
that . parentData = {
758
759
element : ce , left : co . left , top : co . top , width : width , height : height
0 commit comments