diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-12 01:32:30 +0200 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-12 01:32:30 +0200 |
commit | d077f9b360ebee63df48b7195780016671f2613e (patch) | |
tree | 2da3004d12524d776aeaeea2477b5648de353503 | |
parent | 260261255baa3c891d265cf2266e66cbc2ac88b6 (diff) | |
download | jquery-ui-d077f9b360ebee63df48b7195780016671f2613e.tar.gz jquery-ui-d077f9b360ebee63df48b7195780016671f2613e.zip |
Position: Improve feedback API by giving the center/middle position more weight. Also removed themeswitcher from test pages, now load faster
-rw-r--r-- | tests/visual/position/position.html | 8 | ||||
-rw-r--r-- | tests/visual/position/position_feedback.html | 23 | ||||
-rw-r--r-- | tests/visual/position/position_fit.html | 1 | ||||
-rw-r--r-- | tests/visual/position/position_flip.html | 1 | ||||
-rw-r--r-- | tests/visual/position/position_flipfit.html | 1 | ||||
-rw-r--r-- | tests/visual/position/position_margin.html | 1 | ||||
-rw-r--r-- | ui/jquery.ui.position.js | 6 |
7 files changed, 31 insertions, 10 deletions
diff --git a/tests/visual/position/position.html b/tests/visual/position/position.html index 532774526..64c5d2300 100644 --- a/tests/visual/position/position.html +++ b/tests/visual/position/position.html @@ -10,7 +10,6 @@ <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { var inputs = $("input"); @@ -25,13 +24,14 @@ }); var menu = $(this).next().menu() menu.position({ - my: "left top+20", + my: "left+30 top+20", at: "left bottom", of: this, using: function( position, feedback ) { input.val(feedback.horizontal + " " + feedback.vertical) - $(this).offset( position ) - .removeClass("left right top bottom") + $(this).offset( position ); + $(this) + .removeClass("left right top bottom center middle") .addClass(feedback.horizontal) .addClass(feedback.vertical); } diff --git a/tests/visual/position/position_feedback.html b/tests/visual/position/position_feedback.html index 0bb483e4b..b35c3b025 100644 --- a/tests/visual/position/position_feedback.html +++ b/tests/visual/position/position_feedback.html @@ -10,7 +10,6 @@ <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { function using( position, feedback ) { @@ -52,8 +51,14 @@ var targetOffset = target.offset(); var oppositeElement = element.clone().width(50).appendTo('body'); + var leftElement = element.clone().width(50).height(150).appendTo('body'); + var rightElement = element.clone().height(150).width(150).appendTo('body'); element.width(150); $(document).on( "mousemove", function(event) { + // TODO explore allowing multiple option sets as argument to position + // .position(base, custom) + // should be pretty useful for plugins, which always have base options and user overrides + // first arg is required, if it looks good, look for argmuments.length > 1 element.position({ my: "left top", at: "left top", @@ -68,7 +73,21 @@ offset: (-1 * (event.pageX - targetOffset.left)) + " " + (-1 * (event.pageY - targetOffset.top)), using: using }); - } ) + leftElement.position({ + my: "left top", + at: "left top", + of: target, + offset: (-0.9 * (event.pageX - targetOffset.left)) + " " + (0.9 * (event.pageY - targetOffset.top)), + using: using + }); + rightElement.position({ + my: "left top", + at: "left top", + of: target, + offset: (0.9 * (event.pageX - targetOffset.left)) + " " + (-0.9 * (event.pageY - targetOffset.top)), + using: using + }); + }); }); </script> <style> diff --git a/tests/visual/position/position_fit.html b/tests/visual/position/position_fit.html index 9c60b78f6..dbd52550f 100644 --- a/tests/visual/position/position_fit.html +++ b/tests/visual/position/position_fit.html @@ -10,7 +10,6 @@ <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { var inputs = $("input"); diff --git a/tests/visual/position/position_flip.html b/tests/visual/position/position_flip.html index bae3c649b..29ad32f96 100644 --- a/tests/visual/position/position_flip.html +++ b/tests/visual/position/position_flip.html @@ -10,7 +10,6 @@ <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { var inputs = $("input"); diff --git a/tests/visual/position/position_flipfit.html b/tests/visual/position/position_flipfit.html index fcfb75b6b..fb99e4007 100644 --- a/tests/visual/position/position_flipfit.html +++ b/tests/visual/position/position_flipfit.html @@ -10,7 +10,6 @@ <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { var inputs = $("input"); diff --git a/tests/visual/position/position_margin.html b/tests/visual/position/position_margin.html index 71d8f0a3c..2e3b63266 100644 --- a/tests/visual/position/position_margin.html +++ b/tests/visual/position/position_margin.html @@ -9,7 +9,6 @@ <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script> - <script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script> <script type="text/javascript"> $(function() { $( "#elem" ).position({ diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 025d2c815..bf741871b 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -232,6 +232,12 @@ $.fn.position = function( options ) { horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" }; + if ( Math.abs( left + right ) < targetWidth ) { + feedback.horizontal = "center"; + } + if ( Math.abs( top + bottom ) < targetHeight ) { + feedback.vertical = "middle"; + } if ( Math.max( Math.abs( left ), Math.abs( right ) ) > Math.max( Math.abs( top ), Math.abs( bottom ) ) ) { feedback.important = "horizontal"; } else { |