Skip to content

Commit adf427a

Browse files
benmosherscottgonzalez
authored andcommitted
Resizable: alsoResize more than one element of a jQuery selection
Fixes #4666 Closes jquerygh-1324
1 parent 18e301f commit adf427a

File tree

2 files changed

+32
-21
lines changed

2 files changed

+32
-21
lines changed

tests/unit/resizable/resizable_options.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,34 @@ test( "alsoResize + containment", function() {
432432
equal( other.height(), 150, "alsoResize constrained height at containment edge" );
433433
});
434434

435+
test( "alsoResize + multiple selection", function() {
436+
expect( 6 );
437+
var other1 = $( "<div>" )
438+
.addClass("other")
439+
.css({
440+
width: 50,
441+
height: 50
442+
})
443+
.appendTo( "body" ),
444+
other2 = $( "<div>" )
445+
.addClass("other")
446+
.css({
447+
width: 50,
448+
height: 50
449+
})
450+
.appendTo( "body"),
451+
element = $( "#resizable1" ).resizable({
452+
alsoResize: $.merge(other1, other2),
453+
containment: "#container"
454+
});
455+
456+
TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 );
457+
equal( element.width(), 300, "resizable constrained width at containment edge" );
458+
equal( element.height(), 200, "resizable constrained height at containment edge" );
459+
equal( other1.width(), 250, "alsoResize o1 constrained width at containment edge" );
460+
equal( other1.height(), 150, "alsoResize o1 constrained height at containment edge" );
461+
equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" );
462+
equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" );
463+
});
464+
435465
})(jQuery);

ui/resizable.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,19 +1001,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
10011001
});
10021002
});
10031003
};
1004-
1005-
if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
1006-
if (o.alsoResize.length) {
1007-
o.alsoResize = o.alsoResize[0];
1008-
_store(o.alsoResize);
1009-
} else {
1010-
$.each(o.alsoResize, function(exp) {
1011-
_store(exp);
1012-
});
1013-
}
1014-
} else {
1015-
_store(o.alsoResize);
1016-
}
1004+
_store(o.alsoResize);
10171005
},
10181006

10191007
resize: function(event, ui) {
@@ -1047,14 +1035,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
10471035
el.css(style);
10481036
});
10491037
};
1050-
1051-
if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
1052-
$.each(o.alsoResize, function(exp, c) {
1053-
_alsoResize(exp, c);
1054-
});
1055-
} else {
1056-
_alsoResize(o.alsoResize);
1057-
}
1038+
_alsoResize(o.alsoResize);
10581039
},
10591040

10601041
stop: function() {

0 commit comments

Comments
 (0)