@@ -528,47 +528,49 @@ $.extend($.ui.resizable, {
528
528
529
529
$ . ui . plugin . add ( "resizable" , "alsoResize" , {
530
530
531
- start : function ( event , ui ) {
532
-
531
+ start : function ( event , ui ) {
533
532
var self = $ ( this ) . data ( "resizable" ) , o = self . options ;
534
533
535
- var _store = function ( exp ) {
534
+ var _store = function ( exp ) {
536
535
$ ( exp ) . each ( function ( ) {
537
- $ ( this ) . data ( "resizable-alsoresize" , {
538
- width : parseInt ( $ ( this ) . width ( ) , 10 ) , height : parseInt ( $ ( this ) . height ( ) , 10 ) ,
539
- left : parseInt ( $ ( this ) . css ( 'left' ) , 10 ) , top : parseInt ( $ ( this ) . css ( 'top' ) , 10 )
536
+ var el = $ ( this ) ;
537
+ el . data ( "resizable-alsoresize" , {
538
+ width : parseInt ( el . width ( ) , 10 ) , height : parseInt ( el . height ( ) , 10 ) ,
539
+ left : parseInt ( el . css ( 'left' ) , 10 ) , top : parseInt ( el . css ( 'top' ) , 10 ) ,
540
+ position : el . css ( 'position' ) // to reset Opera on stop()
540
541
} ) ;
541
542
} ) ;
542
543
} ;
543
544
544
545
if ( typeof ( o . alsoResize ) == 'object' && ! o . alsoResize . parentNode ) {
545
- if ( o . alsoResize . length ) { o . alsoResize = o . alsoResize [ 0 ] ; _store ( o . alsoResize ) ; }
546
- else { $ . each ( o . alsoResize , function ( exp , c ) { _store ( exp ) ; } ) ; }
546
+ if ( o . alsoResize . length ) { o . alsoResize = o . alsoResize [ 0 ] ; _store ( o . alsoResize ) ; }
547
+ else { $ . each ( o . alsoResize , function ( exp ) { _store ( exp ) ; } ) ; }
547
548
} else {
548
549
_store ( o . alsoResize ) ;
549
550
}
550
551
} ,
551
552
552
- resize : function ( event , ui ) {
553
+ resize : function ( event , ui ) {
553
554
var self = $ ( this ) . data ( "resizable" ) , o = self . options , os = self . originalSize , op = self . originalPosition ;
554
555
555
556
var delta = {
556
557
height : ( self . size . height - os . height ) || 0 , width : ( self . size . width - os . width ) || 0 ,
557
558
top : ( self . position . top - op . top ) || 0 , left : ( self . position . left - op . left ) || 0
558
559
} ,
559
560
560
- _alsoResize = function ( exp , c ) {
561
+ _alsoResize = function ( exp , c ) {
561
562
$ ( exp ) . each ( function ( ) {
562
- var el = $ ( this ) , start = $ ( this ) . data ( "resizable-alsoresize" ) , style = { } , css = c && c . length ? c : [ 'width' , 'height' , 'top' , 'left' ] ;
563
+ var el = $ ( this ) , start = $ ( this ) . data ( "resizable-alsoresize" ) , style = { } ,
564
+ css = c && c . length ? c : el . parents ( ui . originalElement [ 0 ] ) . length ? [ 'width' , 'height' ] : [ 'width' , 'height' , 'top' , 'left' ] ;
563
565
564
- $ . each ( css || [ 'width' , 'height' , 'top' , 'left' ] , function ( i , prop ) {
566
+ $ . each ( css , function ( i , prop ) {
565
567
var sum = ( start [ prop ] || 0 ) + ( delta [ prop ] || 0 ) ;
566
568
if ( sum && sum >= 0 )
567
569
style [ prop ] = sum || null ;
568
570
} ) ;
569
571
570
- //Opera fixing relative position
571
- if ( / r e l a t i v e / . test ( el . css ( 'position' ) ) && $ . browser . opera ) {
572
+ // Opera fixing relative position
573
+ if ( $ . browser . opera && / r e l a t i v e / . test ( el . css ( 'position' ) ) ) {
572
574
self . _revertToRelativePosition = true ;
573
575
el . css ( { position : 'absolute' , top : 'auto' , left : 'auto' } ) ;
574
576
}
@@ -578,22 +580,33 @@ $.ui.plugin.add("resizable", "alsoResize", {
578
580
} ;
579
581
580
582
if ( typeof ( o . alsoResize ) == 'object' && ! o . alsoResize . nodeType ) {
581
- $ . each ( o . alsoResize , function ( exp , c ) { _alsoResize ( exp , c ) ; } ) ;
583
+ $ . each ( o . alsoResize , function ( exp , c ) { _alsoResize ( exp , c ) ; } ) ;
582
584
} else {
583
585
_alsoResize ( o . alsoResize ) ;
584
586
}
585
587
} ,
586
588
587
- stop : function ( event , ui ) {
589
+ stop : function ( event , ui ) {
588
590
var self = $ ( this ) . data ( "resizable" ) ;
589
591
590
- //Opera fixing relative position
591
- if ( self . _revertToRelativePosition && $ . browser . opera ) {
592
+ _reset = function ( exp ) {
593
+ $ ( exp ) . each ( function ( ) {
594
+ var el = $ ( this ) ;
595
+ // reset position for Opera - no need to verify it was changed
596
+ el . css ( { position : el . data ( "resizable-alsoresize" ) . position } ) ;
597
+ } ) ;
598
+ }
599
+
600
+ if ( self . _revertToRelativePosition ) {
592
601
self . _revertToRelativePosition = false ;
593
- el . css ( { position : 'relative' } ) ;
602
+ if ( typeof ( o . alsoResize ) == 'object' && ! o . alsoResize . nodeType ) {
603
+ $ . each ( o . alsoResize , function ( exp ) { _reset ( exp ) ; } ) ;
604
+ } else {
605
+ _reset ( o . alsoResize ) ;
606
+ }
594
607
}
595
608
596
- $ ( this ) . removeData ( "resizable-alsoresize-start " ) ;
609
+ $ ( this ) . removeData ( "resizable-alsoresize" ) ;
597
610
}
598
611
} ) ;
599
612
0 commit comments