]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Further refactoring of next/previousPage
authorjzaefferer <joern.zaefferer@gmail.com>
Thu, 28 Oct 2010 17:22:57 +0000 (19:22 +0200)
committerjzaefferer <joern.zaefferer@gmail.com>
Thu, 28 Oct 2010 17:22:57 +0000 (19:22 +0200)
ui/jquery.ui.menu.js

index 58127566d567fd239ba81bcd1dcb697d88a2ddb8..a67bc34bfd25fad0bc74d66fb952039c8d027cc5 100644 (file)
@@ -192,18 +192,14 @@ $.widget("ui.menu", {
                                height = this.element.height(),
                                result;
                        this.active.nextAll( ".ui-menu-item" ).each( function() {
-                               var close = $( this ).offset().top - base - height;
-                               if (close >= 0) {
-                                       result = $( this );
-                                       return false;
-                               }
+                               result = $( this );
+                               return $( this ).offset().top - base - height < 0;
                        });
 
-                       this.activate( event, result || this.element.children( ".ui-menu-item" ).last() );
+                       this.activate( event, result );
                } else {
                        this.activate( event, this.element.children( ".ui-menu-item" )
-                               // TODO use .first()/.last()
-                               .filter( !this.active || this.last() ? ":first" : ":last" ) );
+                               [ !this.active || this.last() ? "first" : "last" ]() );
                }
        },
 
@@ -219,18 +215,14 @@ $.widget("ui.menu", {
                                height = this.element.height(),
                                result;
                        this.active.prevAll( ".ui-menu-item" ).each( function() {
-                               var close = $(this).offset().top - base + height;
-                               if (close <= 0) {
-                                       result = $( this );
-                                       return false;
-                               }
+                               result = $( this );
+                               return $(this).offset().top - base + height > 0;
                        });
 
-                       this.activate( event, result || this.element.children( ".ui-menu-item" ).first() );
+                       this.activate( event, result );
                } else {
                        this.activate( event, this.element.children( ".ui-menu-item" )
-                               // TODO use .first()/.last()
-                               .filter( !this.active || this.first() ? ":last" : ":first" ) );
+                               [ !this.active || this.first() ? ":last" : ":first" ]() );
                }
        },