Skip to main content

Search and Top Navigation

Ticket #4666: resizable-alsoresize.patch


File resizable-alsoresize.patch, 2.2 KB (added by Mikko Rantanen, July 10, 2009 07:02PM UTC)

Patch for fixing the bug

Index: ui.resizable.js
===================================================================
--- ui.resizable.js	(revision 2900)
+++ ui.resizable.js	(working copy)
@@ -531,6 +531,9 @@
 
 		var self = $(this).data("resizable"), o = self.options;
 
+		// The supported values for alsoResize are html elements,
+		// selector string and jQuery object. All of these can be
+		// iterated with the each statement.
 		_store = function(exp) {
 			$(exp).each(function() {
 				$(this).data("resizable-alsoresize", {
@@ -538,12 +541,16 @@
 					left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)
 				});
 			});
-		};
-
-		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, c) { _store(exp); }); }
+		};	
+		
+		if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode && !o.alsoResize.length) {
+			// A dictionary of selectors, where the key stands for the
+			// resizable item and the value is a list of properties that
+			// are modified while being resized.
+			$each(o.alsoResize, function(exp, c) { _store(exp); });
 		}else{
+			// The objects that can be iterated normally with $(exp).each:
+			// html elements, jQuery object, simple selector string.
 			_store(o.alsoResize);
 		}
 	},
@@ -560,7 +567,7 @@
 			$(exp).each(function() {
 				var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];
 
-				$.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {
+				$.each(css, function(i, prop) {
 					var sum = (start[prop]||0) + (delta[prop]||0);
 					if (sum && sum >= 0)
 						style[prop] = sum || null;
@@ -576,11 +583,12 @@
 			});
 		};
 
-		if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
+		// See the start event for the explanation for this conditional.
+		if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType && !o.alsoResize.length) {
 			$.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });
 		}else{
 			_alsoResize(o.alsoResize);
-		}
+		}		
 	},
 
 	stop: function(event, ui){

Download in other formats:

Original Format