diff options
author | Ben Mosher <me@benmosher.com> | 2014-08-25 14:07:25 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2015-03-04 08:51:06 -0500 |
commit | 19783fd3e6a6e6e02a2030028e8820076c3b1295 (patch) | |
tree | 5f9e4fb9ad6d3cf46c52b624a47f844bff64f69c /ui/resizable.js | |
parent | 18e301f4e29c2080e9aa9dac87c00dee137cb6c9 (diff) | |
download | jquery-ui-19783fd3e6a6e6e02a2030028e8820076c3b1295.tar.gz jquery-ui-19783fd3e6a6e6e02a2030028e8820076c3b1295.zip |
Resizable: alsoResize more than one element of a jQuery selection
Fixes #4666
Closes gh-1324
Closes gh-1461
Diffstat (limited to 'ui/resizable.js')
-rw-r--r-- | ui/resizable.js | 68 |
1 files changed, 21 insertions, 47 deletions
diff --git a/ui/resizable.js b/ui/resizable.js index c4bc36529..09efc9a37 100644 --- a/ui/resizable.js +++ b/ui/resizable.js @@ -991,29 +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) - }); - }); - }; + o = that.options; - if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) { - if (o.alsoResize.length) { - o.alsoResize = o.alsoResize[0]; - _store(o.alsoResize); - } else { - $.each(o.alsoResize, function(exp) { - _store(exp); - }); - } - } else { - _store(o.alsoResize); - } + $(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) { @@ -1026,35 +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; + } }); - }; - if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) { - $.each(o.alsoResize, function(exp, c) { - _alsoResize(exp, c); + el.css(style); }); - } else { - _alsoResize(o.alsoResize); - } }, stop: function() { |