aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.resizable.js
diff options
context:
space:
mode:
authorALLPRO <development@allpro.net>2010-06-10 05:06:53 +0800
committerScott González <scott.gonzalez@gmail.com>2010-06-10 09:33:00 +0800
commita78d5ee4c8c21b2da2631d51a74779e958793c9d (patch)
tree122f4105ebc4ed06dd3f93d5bd521bc199326aa7 /ui/jquery.ui.resizable.js
parenta8311f955a0cf3fef005955109dcdbfd1a7a08df (diff)
downloadjquery-ui-a78d5ee4c8c21b2da2631d51a74779e958793c9d.tar.gz
jquery-ui-a78d5ee4c8c21b2da2631d51a74779e958793c9d.zip
Resizable: Patched the alsoResize plugin to fix 2 critical bugs. Fixes #5694 - Invalid reference in UI Resizable hack for Opera. Fixes #5662/5695/3842 - When resizing from top or left edge, Dialog adds top/left CSS values to content element. Enhances Dialog - Allows dialog-content to have position:relative to 'contain' floated and positioned elements. Bug Demo for #5662 - http://layout.jquery-dev.net/samples/ui_dialog_bug.html
Diffstat (limited to 'ui/jquery.ui.resizable.js')
-rw-r--r--ui/jquery.ui.resizable.js53
1 files changed, 33 insertions, 20 deletions
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index 4ba723884..2b3a87e85 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -528,28 +528,29 @@ $.extend($.ui.resizable, {
$.ui.plugin.add("resizable", "alsoResize", {
- start: function(event, ui) {
-
+ start: function (event, ui) {
var self = $(this).data("resizable"), o = self.options;
- var _store = function(exp) {
+ var _store = function (exp) {
$(exp).each(function() {
- $(this).data("resizable-alsoresize", {
- width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10),
- left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)
+ var el = $(this);
+ el.data("resizable-alsoresize", {
+ width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
+ left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10),
+ position: el.css('position') // to reset Opera on stop()
});
});
};
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 (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
+ else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
}else{
_store(o.alsoResize);
}
},
- resize: function(event, ui){
+ resize: function (event, ui) {
var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
var delta = {
@@ -557,18 +558,19 @@ $.ui.plugin.add("resizable", "alsoResize", {
top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
},
- _alsoResize = function(exp, c) {
+ _alsoResize = function (exp, c) {
$(exp).each(function() {
- var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];
+ var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
+ css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['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;
});
- //Opera fixing relative position
- if (/relative/.test(el.css('position')) && $.browser.opera) {
+ // Opera fixing relative position
+ if ($.browser.opera && /relative/.test(el.css('position'))) {
self._revertToRelativePosition = true;
el.css({ position: 'absolute', top: 'auto', left: 'auto' });
}
@@ -578,22 +580,33 @@ $.ui.plugin.add("resizable", "alsoResize", {
};
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
- $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });
+ $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
}else{
_alsoResize(o.alsoResize);
}
},
- stop: function(event, ui){
+ stop: function (event, ui) {
var self = $(this).data("resizable");
- //Opera fixing relative position
- if (self._revertToRelativePosition && $.browser.opera) {
+ _reset = function (exp) {
+ $(exp).each(function() {
+ var el = $(this);
+ // reset position for Opera - no need to verify it was changed
+ el.css({ position: el.data("resizable-alsoresize").position });
+ });
+ }
+
+ if (self._revertToRelativePosition) {
self._revertToRelativePosition = false;
- el.css({ position: 'relative' });
+ if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
+ $.each(o.alsoResize, function (exp) { _reset(exp); });
+ }else{
+ _reset(o.alsoResize);
+ }
}
- $(this).removeData("resizable-alsoresize-start");
+ $(this).removeData("resizable-alsoresize");
}
});