@@ -713,129 +713,159 @@ $.ui.plugin.add("resizable", "animate", {
713
713
714
714
} ) ;
715
715
716
- $ . ui . plugin . add ( "resizable" , "containment" , {
716
+ $ . ui . plugin . add ( "resizable" , "containment" , {
717
717
718
718
start : function ( ) {
719
719
var element , p , co , ch , cw , width , height ,
720
- that = $ ( this ) . resizable ( "instance" ) ,
720
+ that = $ ( this ) . resizable ( "instance" ) ,
721
721
o = that . options ,
722
722
el = that . element ,
723
723
oc = o . containment ,
724
- ce = ( oc instanceof $ ) ? oc . get ( 0 ) : ( / p a r e n t / . test ( oc ) ) ? el . parent ( ) . get ( 0 ) : oc ;
724
+ ce = ( oc instanceof $ ) ? oc . get ( 0 ) : ( / p a r e n t / . test ( oc ) ) ? el . parent ( ) . get ( 0 ) : oc ;
725
725
726
- if ( ! ce ) {
726
+ if ( ! ce ) {
727
727
return ;
728
728
}
729
729
730
- that . containerElement = $ ( ce ) ;
730
+ that . containerElement = $ ( ce ) ;
731
731
732
- if ( / d o c u m e n t / . test ( oc ) || oc === document ) {
733
- that . containerOffset = { left : 0 , top : 0 } ;
734
- that . containerPosition = { left : 0 , top : 0 } ;
732
+ if ( / d o c u m e n t / . test ( oc ) || oc === document ) {
733
+ that . containerOffset = {
734
+ left : 0 ,
735
+ top : 0
736
+ } ;
737
+ that . containerPosition = {
738
+ left : 0 ,
739
+ top : 0
740
+ } ;
735
741
736
742
that . parentData = {
737
- element : $ ( document ) , left : 0 , top : 0 ,
738
- width : $ ( document ) . width ( ) , height : $ ( document ) . height ( ) || document . body . parentNode . scrollHeight
743
+ element : $ ( document ) ,
744
+ left : 0 ,
745
+ top : 0 ,
746
+ width : $ ( document ) . width ( ) ,
747
+ height : $ ( document ) . height ( ) || document . body . parentNode . scrollHeight
739
748
} ;
740
749
}
741
750
742
751
// i'm a node, so compute top, left, right, bottom
743
752
else {
744
- element = $ ( ce ) ;
753
+ element = $ ( ce ) ;
745
754
p = [ ] ;
746
- $ ( [ "Top" , "Right" , "Left" , "Bottom" ] ) . each ( function ( i , name ) { p [ i ] = that . _num ( element . css ( "padding" + name ) ) ; } ) ;
755
+ $ ( [ "Top" , "Right" , "Left" , "Bottom" ] ) . each ( function ( i , name ) {
756
+ p [ i ] = that . _num ( element . css ( "padding" + name ) ) ;
757
+ } ) ;
747
758
748
759
that . containerOffset = element . offset ( ) ;
749
760
that . containerPosition = element . position ( ) ;
750
- that . containerSize = { height : ( element . innerHeight ( ) - p [ 3 ] ) , width : ( element . innerWidth ( ) - p [ 1 ] ) } ;
761
+ that . containerSize = {
762
+ height : ( element . innerHeight ( ) - p [ 3 ] ) ,
763
+ width : ( element . innerWidth ( ) - p [ 1 ] )
764
+ } ;
751
765
752
766
co = that . containerOffset ;
753
767
ch = that . containerSize . height ;
754
768
cw = that . containerSize . width ;
755
- width = ( that . _hasScroll ( ce , "left" ) ? ce . scrollWidth : cw ) ;
756
- height = ( that . _hasScroll ( ce ) ? ce . scrollHeight : ch ) ;
769
+ width = ( that . _hasScroll ( ce , "left" ) ? ce . scrollWidth : cw ) ;
770
+ height = ( that . _hasScroll ( ce ) ? ce . scrollHeight : ch ) ;
757
771
758
772
that . parentData = {
759
- element : ce , left : co . left , top : co . top , width : width , height : height
773
+ element : ce ,
774
+ left : co . left ,
775
+ top : co . top ,
776
+ width : width ,
777
+ height : height
760
778
} ;
761
779
}
762
780
} ,
763
781
764
782
resize : function ( event ) {
765
783
var woset , hoset , isParent , isOffsetRelative ,
766
- that = $ ( this ) . resizable ( "instance" ) ,
784
+ that = $ ( this ) . resizable ( "instance" ) ,
767
785
o = that . options ,
768
- co = that . containerOffset , cp = that . position ,
786
+ co = that . containerOffset ,
787
+ cp = that . position ,
769
788
pRatio = that . _aspectRatio || event . shiftKey ,
770
- cop = { top :0 , left :0 } , ce = that . containerElement ;
789
+ cop = {
790
+ top : 0 ,
791
+ left : 0
792
+ } ,
793
+ ce = that . containerElement ;
771
794
772
- if ( ce [ 0 ] !== document && ( / s t a t i c / ) . test ( ce . css ( "position" ) ) ) {
795
+ if ( ce [ 0 ] !== document && ( / s t a t i c / ) . test ( ce . css ( "position" ) ) ) {
773
796
cop = co ;
774
797
}
775
798
776
- if ( cp . left < ( that . _helper ? co . left : 0 ) ) {
777
- that . size . width = that . size . width + ( that . _helper ? ( that . position . left - co . left ) : ( that . position . left - cop . left ) ) ;
778
- if ( pRatio ) {
799
+ if ( cp . left < ( that . _helper ? co . left : 0 ) ) {
800
+ that . size . width = that . size . width + ( that . _helper ? ( that . position . left - co . left ) : ( that . position . left - cop . left ) ) ;
801
+ if ( pRatio ) {
779
802
that . size . height = that . size . width / that . aspectRatio ;
780
803
}
781
804
that . position . left = o . helper ? co . left : 0 ;
782
805
}
783
806
784
- if ( cp . top < ( that . _helper ? co . top : 0 ) ) {
785
- that . size . height = that . size . height + ( that . _helper ? ( that . position . top - co . top ) : that . position . top ) ;
786
- if ( pRatio ) {
807
+ if ( cp . top < ( that . _helper ? co . top : 0 ) ) {
808
+ that . size . height = that . size . height + ( that . _helper ? ( that . position . top - co . top ) : that . position . top ) ;
809
+ if ( pRatio ) {
787
810
that . size . width = that . size . height * that . aspectRatio ;
788
811
}
789
812
that . position . top = that . _helper ? co . top : 0 ;
790
813
}
791
814
792
- that . offset . left = that . parentData . left + that . position . left ;
793
- that . offset . top = that . parentData . top + that . position . top ;
815
+ that . offset . left = that . parentData . left + that . position . left ;
816
+ that . offset . top = that . parentData . top + that . position . top ;
794
817
795
818
woset = Math . abs ( ( that . _helper ? that . offset . left - cop . left : ( that . offset . left - co . left ) ) + that . sizeDiff . width ) ;
796
819
hoset = Math . abs ( ( that . _helper ? that . offset . top - cop . top : ( that . offset . top - co . top ) ) + that . sizeDiff . height ) ;
797
820
798
- isParent = that . containerElement . get ( 0 ) === that . element . parent ( ) . get ( 0 ) ;
799
- isOffsetRelative = / r e l a t i v e | a b s o l u t e / . test ( that . containerElement . css ( "position" ) ) ;
821
+ isParent = that . containerElement . get ( 0 ) === that . element . parent ( ) . get ( 0 ) ;
822
+ isOffsetRelative = / r e l a t i v e | a b s o l u t e / . test ( that . containerElement . css ( "position" ) ) ;
800
823
801
824
if ( isParent && isOffsetRelative ) {
802
825
woset -= Math . abs ( that . parentData . left ) ;
803
826
}
804
827
805
- if ( woset + that . size . width >= that . parentData . width ) {
828
+ if ( woset + that . size . width >= that . parentData . width ) {
806
829
that . size . width = that . parentData . width - woset ;
807
- if ( pRatio ) {
830
+ if ( pRatio ) {
808
831
that . size . height = that . size . width / that . aspectRatio ;
809
832
}
810
833
}
811
834
812
- if ( hoset + that . size . height >= that . parentData . height ) {
835
+ if ( hoset + that . size . height >= that . parentData . height ) {
813
836
that . size . height = that . parentData . height - hoset ;
814
- if ( pRatio ) {
837
+ if ( pRatio ) {
815
838
that . size . width = that . size . height * that . aspectRatio ;
816
839
}
817
840
}
818
841
} ,
819
842
820
843
stop : function ( ) {
821
- var that = $ ( this ) . resizable ( "instance" ) ,
844
+ var that = $ ( this ) . resizable ( "instance" ) ,
822
845
o = that . options ,
823
846
co = that . containerOffset ,
824
847
cop = that . containerPosition ,
825
848
ce = that . containerElement ,
826
- helper = $ ( that . helper ) ,
849
+ helper = $ ( that . helper ) ,
827
850
ho = helper . offset ( ) ,
828
851
w = helper . outerWidth ( ) - that . sizeDiff . width ,
829
852
h = helper . outerHeight ( ) - that . sizeDiff . height ;
830
853
831
- if ( that . _helper && ! o . animate && ( / r e l a t i v e / ) . test ( ce . css ( "position" ) ) ) {
832
- $ ( this ) . css ( { left : ho . left - cop . left - co . left , width : w , height : h } ) ;
854
+ if ( that . _helper && ! o . animate && ( / r e l a t i v e / ) . test ( ce . css ( "position" ) ) ) {
855
+ $ ( this ) . css ( {
856
+ left : ho . left - cop . left - co . left ,
857
+ width : w ,
858
+ height : h
859
+ } ) ;
833
860
}
834
861
835
- if ( that . _helper && ! o . animate && ( / s t a t i c / ) . test ( ce . css ( "position" ) ) ) {
836
- $ ( this ) . css ( { left : ho . left - cop . left - co . left , width : w , height : h } ) ;
862
+ if ( that . _helper && ! o . animate && ( / s t a t i c / ) . test ( ce . css ( "position" ) ) ) {
863
+ $ ( this ) . css ( {
864
+ left : ho . left - cop . left - co . left ,
865
+ width : w ,
866
+ height : h
867
+ } ) ;
837
868
}
838
-
839
869
}
840
870
} ) ;
841
871
0 commit comments