From ef02b168ef7abe243ae25b60bb20c6268f8198aa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 10 Nov 2009 16:35:55 +0000 Subject: [PATCH] Effects: Cleaned up createWrapper(). --- ui/jquery.effects.core.js | 42 +++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 90ae82abb..07d73ce49 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -331,36 +331,48 @@ $.extend($.effects, { // Wraps the element around a wrapper that copies position properties createWrapper: function(element) { - //if the element is already wrapped, return it - if (element.parent().is('.ui-effects-wrapper')) + // if the element is already wrapped, return it + if (element.parent().is('.ui-effects-wrapper')) { return element.parent(); + } + + // wrap the element + var props = { + width: element.outerWidth(true), + height: element.outerHeight(true), + 'float': element.css('float') + }, + wrapper = $('
') + .addClass('ui-effects-wrapper') + .css({ + fontSize: '100%', + background: 'transparent', + border: 'none', + margin: 0, + padding: 0 + }); - //Cache width,height and float properties of the element, and create a wrapper around it - var props = { width: element.outerWidth(true), height: element.outerHeight(true), 'float': element.css('float') }; - element.wrap('
'); - var wrapper = element.parent(); + element.wrap(wrapper); - //Transfer the positioning of the element to the wrapper + // transfer positioning properties to the wrapper if (element.css('position') == 'static') { wrapper.css({ position: 'relative' }); element.css({ position: 'relative' }); } else { - var cssProps = { + $.extend(props, { position: element.css('position'), zIndex: element.css('z-index') - }; + }); $.each(['top', 'left', 'bottom', 'right'], function(i, pos) { - cssProps[pos] = element.css(pos); - if (isNaN(parseInt(cssProps[pos], 10))) { - cssProps[pos] = 'auto'; + props[pos] = element.css(pos); + if (isNaN(parseInt(props[pos], 10))) { + props[pos] = 'auto'; } }); - wrapper.css(cssProps).show(); element.css({position: 'relative', top: 0, left: 0 }); } - wrapper.css(props); - return wrapper; + return wrapper.css(props).show(); }, removeWrapper: function(element) { -- 2.39.5