Skip to content

Commit

Permalink
[fixup]: Clean up from gh-1324
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Mar 3, 2015
1 parent adf427a commit 7eb0f76
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
6 changes: 3 additions & 3 deletions tests/unit/resizable/resizable_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,21 +435,21 @@ test( "alsoResize + containment", function() {
test( "alsoResize + multiple selection", function() {
expect( 6 );
var other1 = $( "<div>" )
.addClass("other")
.addClass( "other" )
.css({
width: 50,
height: 50
})
.appendTo( "body" ),
other2 = $( "<div>" )
.addClass("other")
.addClass( "other" )
.css({
width: 50,
height: 50
})
.appendTo( "body"),
element = $( "#resizable1" ).resizable({
alsoResize: $.merge(other1, other2),
alsoResize: other1.add( other2 ),
containment: "#container"
});

Expand Down
55 changes: 24 additions & 31 deletions ui/resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,17 +991,15 @@ $.ui.plugin.add("resizable", "alsoResize", {

start: function() {
var that = $(this).resizable( "instance" ),
o = that.options,
_store = function(exp) {
$(exp).each(function() {
var el = $(this);
el.data("ui-resizable-alsoresize", {
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
});
});
};
_store(o.alsoResize);
o = that.options;

$(o.alsoResize).each(function() {
var el = $(this);
el.data("ui-resizable-alsoresize", {
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
});
});
},

resize: function(event, ui) {
Expand All @@ -1014,28 +1012,23 @@ $.ui.plugin.add("resizable", "alsoResize", {
width: (that.size.width - os.width) || 0,
top: (that.position.top - op.top) || 0,
left: (that.position.left - op.left) || 0
},
};

$(o.alsoResize).each(function() {
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
css = el.parents(ui.originalElement[0]).length ?
[ "width", "height" ] :
[ "width", "height", "top", "left" ];

_alsoResize = function(exp, c) {
$(exp).each(function() {
var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
css = c && c.length ?
c :
el.parents(ui.originalElement[0]).length ?
[ "width", "height" ] :
[ "width", "height", "top", "left" ];

$.each(css, function(i, prop) {
var sum = (start[prop] || 0) + (delta[prop] || 0);
if (sum && sum >= 0) {
style[prop] = sum || null;
}
});

el.css(style);
$.each(css, function(i, prop) {
var sum = (start[prop] || 0) + (delta[prop] || 0);
if (sum && sum >= 0) {
style[prop] = sum || null;
}
});
};
_alsoResize(o.alsoResize);

el.css(style);
});
},

stop: function() {
Expand Down

0 comments on commit 7eb0f76

Please sign in to comment.