summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2011-12-28 19:03:18 +0100
committerFelix Nagel <info@felixnagel.com>2011-12-28 19:03:18 +0100
commit18d9a373d63033aa429e982179fa93c323ca7925 (patch)
tree84e5d9d6e22b6fa12a20329dfdaac341be941224
parent98d0dbc6d8cea8d5b994b5110501cacd8e62211a (diff)
downloadjquery-ui-18d9a373d63033aa429e982179fa93c323ca7925.tar.gz
jquery-ui-18d9a373d63033aa429e982179fa93c323ca7925.zip
improved: menu height calculation and collision detection, thx to @Cito , see #189
-rw-r--r--ui/jquery.ui.selectmenu.js14
1 files changed, 5 insertions, 9 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js
index 9d48582bb..7d66e7be9 100644
--- a/ui/jquery.ui.selectmenu.js
+++ b/ui/jquery.ui.selectmenu.js
@@ -420,13 +420,10 @@ $.widget("ui.selectmenu", {
// reset height to auto
this.list.css( 'height', 'auto' );
var listH = this.listWrap.height();
- // calculate default max height
- if ( o.maxHeight && o.maxHeight < listH ) {
- this.list.height( o.maxHeight );
- } else {
- var winH = $( window ).height() / 3;
- if ( winH < listH ) this.list.height( winH );
- }
+ var winH = $( window ).height();
+ // calculate default max height
+ var maxH = o.maxHeight ? Math.min( o.maxHeight, winH ) : winH / 3;
+ if ( listH > maxH ) this.list.height( maxH );
// save reference to actionable li's (not group label li's)
this._optionLis = this.list.find( 'li:not(.' + self.widgetBaseClass + '-group)' );
@@ -857,7 +854,6 @@ $.widget("ui.selectmenu", {
var selected = this._selectedOptionLi();
var _offset = "0 " + ( this.list.offset().top - selected.offset().top - ( this.newelement.outerHeight() + selected.outerHeight() ) / 2);
}
- // update zIndex if jQuery UI is able to process
this.listWrap
.zIndex( this.element.zIndex() + 1 )
.position({
@@ -866,7 +862,7 @@ $.widget("ui.selectmenu", {
my: o.positionOptions.my,
at: o.positionOptions.at,
offset: o.positionOptions.offset || _offset,
- collision: o.positionOptions.collision || 'flip'
+ collision: o.positionOptions.collision || o.style == "popup" ? 'fit' :'flip'
});
}
});