]> source.dussan.org Git - jquery-ui.git/commitdiff
fixed: Position plugin API changes
authorFelix Nagel <info@felixnagel.com>
Fri, 23 Nov 2012 19:38:43 +0000 (20:38 +0100)
committerFelix Nagel <info@felixnagel.com>
Fri, 23 Nov 2012 19:38:43 +0000 (20:38 +0100)
ui/jquery.ui.selectmenu.js

index c9152ab5ef74c51ec2e945ddadd69712bc0bd503..11858be95fb503512486d62ff3e7f4b583be3c55 100644 (file)
@@ -15,11 +15,7 @@ $.widget("ui.selectmenu", {
                appendTo: "body",
                typeAhead: 1000,
                style: 'dropdown',
-               positionOptions: {
-                       my: "left top",
-                       at: "left bottom",
-                       offset: null
-               },
+               positionOptions: null,
                width: null,
                menuWidth: null,
                handleWidth: 26,
@@ -852,24 +848,25 @@ $.widget("ui.selectmenu", {
        },
 
        _refreshPosition: function() {
-               var o = this.options;
+               var o = this.options,
+                       positionDefault = {
+                               of: this.newelement,
+                               my: "left top",
+                               at: "left bottom",
+                               collision: 'flip'
+                       };
 
                // if its a pop-up we need to calculate the position of the selected li
-               if ( o.style == "popup" && !o.positionOptions.offset ) {
+               if ( o.style == "popup" ) {
                        var selected = this._selectedOptionLi();
-                       var _offset = "0 " + ( this.list.offset().top  - selected.offset().top - ( this.newelement.outerHeight() + selected.outerHeight() ) / 2);
+                       positionDefault.my = "left top" + (this.list.offset().top  - selected.offset().top - 1 - ( this.newelement.outerHeight(true) + selected.outerHeight(true) ) / 2);
+                       positionDefault.collision = "fit";
                }
+               
                this.listWrap
                        .removeAttr('style')
                        .zIndex( this.element.zIndex() + 1 )
-                       .position({
-                               // set options for position plugin
-                               of: o.positionOptions.of || this.newelement,
-                               my: o.positionOptions.my,
-                               at: o.positionOptions.at,
-                               offset: o.positionOptions.offset || _offset,
-                               collision: o.positionOptions.collision || (o.style == "popup" ? 'fit' :'flip')
-                       });
+                       .position($.extend(positionDefault, o.positionOptions));
        }
 });