1515 */
1616( function ( $ , undefined ) {
1717
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-
4918$ . widget ( "ui.resizable" , $ . ui . mouse , {
5019 version : "@VERSION" ,
5120 widgetEventPrefix : "resize" ,
@@ -73,6 +42,38 @@ $.widget("ui.resizable", $.ui.mouse, {
7342 start : null ,
7443 stop : null
7544 } ,
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+
7677 _create : function ( ) {
7778
7879 var n , i , handle , axis , hname ,
@@ -305,8 +306,8 @@ $.widget("ui.resizable", $.ui.mouse, {
305306
306307 this . _renderProxy ( ) ;
307308
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" ) ) ;
310311
311312 if ( o . containment ) {
312313 curleft += $ ( o . containment ) . scrollLeft ( ) || 0 ;
@@ -404,7 +405,7 @@ $.widget("ui.resizable", $.ui.mouse, {
404405
405406 pr = this . _proportionallyResizeElements ;
406407 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 ;
408409 soffsetw = ista ? 0 : that . sizeDiff . width ;
409410
410411 s = { width : ( that . helper . width ( ) - soffsetw ) , height : ( that . helper . height ( ) - soffseth ) } ;
@@ -442,10 +443,10 @@ $.widget("ui.resizable", $.ui.mouse, {
442443 o = this . options ;
443444
444445 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
449450 } ;
450451
451452 if ( this . _aspectRatio || forceAspectRatio ) {
@@ -474,16 +475,16 @@ $.widget("ui.resizable", $.ui.mouse, {
474475
475476 _updateCache : function ( data ) {
476477 this . offset = this . helper . offset ( ) ;
477- if ( isNumber ( data . left ) ) {
478+ if ( this . _isNumber ( data . left ) ) {
478479 this . position . left = data . left ;
479480 }
480- if ( isNumber ( data . top ) ) {
481+ if ( this . _isNumber ( data . top ) ) {
481482 this . position . top = data . top ;
482483 }
483- if ( isNumber ( data . height ) ) {
484+ if ( this . _isNumber ( data . height ) ) {
484485 this . size . height = data . height ;
485486 }
486- if ( isNumber ( data . width ) ) {
487+ if ( this . _isNumber ( data . width ) ) {
487488 this . size . width = data . width ;
488489 }
489490 } ,
@@ -494,9 +495,9 @@ $.widget("ui.resizable", $.ui.mouse, {
494495 csize = this . size ,
495496 a = this . axis ;
496497
497- if ( isNumber ( data . height ) ) {
498+ if ( this . _isNumber ( data . height ) ) {
498499 data . width = ( data . height * this . aspectRatio ) ;
499- } else if ( isNumber ( data . width ) ) {
500+ } else if ( this . _isNumber ( data . width ) ) {
500501 data . height = ( data . width / this . aspectRatio ) ;
501502 }
502503
@@ -516,8 +517,8 @@ $.widget("ui.resizable", $.ui.mouse, {
516517
517518 var o = this . _vBoundaries ,
518519 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 ) ,
521522 dw = this . originalPosition . left + this . originalSize . width ,
522523 dh = this . position . top + this . size . height ,
523524 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", {
678679 o = that . options ,
679680 pr = that . _proportionallyResizeElements ,
680681 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 ,
682683 soffsetw = ista ? 0 : that . sizeDiff . width ,
683684 style = { width : ( that . size . width - soffsetw ) , height : ( that . size . height - soffseth ) } ,
684685 left = ( parseInt ( that . element . css ( "left" ) , 10 ) + ( that . position . left - that . originalPosition . left ) ) || null ,
@@ -742,7 +743,7 @@ $.ui.plugin.add("resizable", "containment", {
742743 else {
743744 element = $ ( ce ) ;
744745 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 ) ) ; } ) ;
746747
747748 that . containerOffset = element . offset ( ) ;
748749 that . containerPosition = element . position ( ) ;
@@ -751,8 +752,8 @@ $.ui.plugin.add("resizable", "containment", {
751752 co = that . containerOffset ;
752753 ch = that . containerSize . height ;
753754 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 ) ;
756757
757758 that . parentData = {
758759 element : ce , left : co . left , top : co . top , width : width , height : height
0 commit comments