]> source.dussan.org Git - gwtquery.git/commitdiff
JsQuery: Fix scrolls in JsMenu plugin
authorManolo Carrasco <manolo@apache.org>
Thu, 15 Mar 2012 12:30:33 +0000 (12:30 +0000)
committerManolo Carrasco <manolo@apache.org>
Thu, 15 Mar 2012 12:30:33 +0000 (12:30 +0000)
jsquery/src/main/java/gwtquery/jsquery/client/JsMenu.java
jsquery/src/main/java/gwtquery/jsquery/client/JsQuery.java
jsquery/src/main/java/gwtquery/jsquery/client/OverlayGQuery.java
jsquery/src/main/java/gwtquery/jsquery/client/jsmenu.diff
jsquery/src/main/java/gwtquery/jsquery/client/utils/JsQueryUtils.java

index 57c3cbdd86be81327964a4447b1b32ca0425774c..465b9ff2397b5e627e136a9e750f17a76b14ac49 100644 (file)
@@ -1,13 +1,19 @@
 package gwtquery.jsquery.client;
 
+/**
+ * 
+ * This class wraps the jquery menu plugin from:
+ * 
+ * http://p.sohei.org/jquery-plugins/menu/
+ *
+ */
 public abstract class JsMenu {
   
   public static native void loadPlugin() /*-{
   var l = @gwtquery.jsquery.client.utils.JsQueryUtils::log(Ljava/lang/Object;);
-  var jQuery = $wnd.$;
-  var $ = $wnd.$;
   var window = $wnd;
   var document = $doc;
+  var jQuery = $wnd.$;
   
 (function($)
 {
@@ -437,7 +443,7 @@ public abstract class JsMenu {
         }
 
         //y-pos
-        if (0) //$.fn.scrollTop )
+        if ($().scrollTop )
         {
           wst = $(window).scrollTop();
           if ( wh < height ) //menu is bigger than the window
@@ -476,7 +482,7 @@ public abstract class JsMenu {
           }
         }
         //x-pos
-        if (0) //$.fn.scrollLeft )
+        if ($().scrollLeft )
         {
           wsl = $(window).scrollLeft();
           if ( ww + wsl < posX + width )
index 9514ae7306794220a11e9a7602ec4518c1a9714d..0a929a875bf6ebdf74eba4a6fa82cd481553af34 100644 (file)
@@ -20,7 +20,9 @@ public class JsQuery implements EntryPoint {
     });    
     
     OverlayGQuery.export();
-//    JsMenu.loadPlugin();
+    JsMenu.loadPlugin();
+    OverlayGQuery.onLoad();
+
 //    testJs();
   }
   
index 59d70d4a5e2d8fc7b5826045c3be3e72e0596e04..070c0ceea4a8eb8c5bc4dfa3ed8c554754c2ff4a 100644 (file)
@@ -49,6 +49,12 @@ public class OverlayGQuery implements ExportOverlay<GQuery> {
     GWT.create(OverlayGQuery.class);
   }
   
+  @NoExport
+  public static native void onLoad() /*-{
+    $wnd.onJsQueryLoad && $wnd.onJsQueryLoad();
+    $wnd.JsQuery && $wnd.JsQuery.onLoad && $wnd.JsQuery.onLoad();
+  }-*/;
+  
   @ExportPackage("jsQuery")
   @Export("jFunction")
   @ExportClosure()
@@ -83,9 +89,6 @@ public class OverlayGQuery implements ExportOverlay<GQuery> {
     $ = $wnd.$;
     window = $wnd;
     document = $doc;
-    
-    $wnd.onJsQueryLoad && $wnd.onJsQueryLoad();
-    $wnd.JsQuery && $wnd.JsQuery.onLoad && $wnd.JsQuery.onLoad();
   }-*/;
   
   @ExportStaticMethod("$wnd.$")
index f5ce17a2a423a294e483e133b7944bcbe00dd9f5..9bcf60cdab4474a3b415090a9b16c480bb95be49 100644 (file)
@@ -1,6 +1,6 @@
 --- jquery.menu.js     2012-03-15 10:34:24.000000000 +0100
-+++ JsMenu.jsni        2012-03-15 10:36:20.000000000 +0100
-@@ -134,6 +113,14 @@
++++ JsMenu.java        2012-03-15 13:19:42.000000000 +0100
+@@ -134,6 +130,14 @@
                                t = t.parentNode;\r
                        \r
                        //is the found node one of the visible menu elements?\r
@@ -15,7 +15,7 @@
                        if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length )\r
                        {\r
                                $.Menu.closeAll();\r
-@@ -239,9 +226,7 @@
+@@ -239,9 +243,7 @@
                        $.extend(defaults, d);\r
                },\r
                prototype : {\r
@@ -26,7 +26,7 @@
                        init : function()\r
                        {\r
                                var self = this;\r
-@@ -397,7 +382,7 @@
+@@ -397,7 +399,7 @@
                                        this.$eDIV.css({display:'none', visibility: ''}).show();\r
  \r
                                        //IEs default width: auto is bad! ie6 and ie7 have are producing different errors.. (7 = 5px shadowbox + 2px border)\r
                                                this.$eUL.css('width', parseInt($.browser.version) == 6 ? this.$eDIV.width() - 7 : this.$eUL.width());\r
  \r
                                        if ( this.settings.onOpen )\r
-@@ -439,7 +426,7 @@
+@@ -439,7 +443,7 @@
                                }\r
  \r
                                //y-pos\r
 -                              if ( $.fn.scrollTop )\r
-+        if (0) //$.fn.scrollTop )
++        if ($().scrollTop )
                                {\r
                                        wst = $(window).scrollTop();\r
                                        if ( wh < height ) //menu is bigger than the window\r
-@@ -478,7 +465,7 @@
+@@ -478,7 +482,7 @@
                                        }\r
                                }\r
                                //x-pos\r
 -                              if ( $.fn.scrollLeft )\r
-+        if (0) //$.fn.scrollLeft )
++        if ($().scrollLeft )
                                {\r
                                        wsl = $(window).scrollLeft();\r
                                        if ( ww + wsl < posX + width )\r
index 5025f61b4c5ea4814991cc152c8fdc76fb0ae45e..66550a1c117fc92a9b4c75aa4c34fd90b19b2cc7 100644 (file)
@@ -37,7 +37,7 @@ public abstract class JsQueryUtils {
         new JsUtils.JsFunction(jso).fe();
       } else {
         GQuery r = GQuery.$(jso);
-        if (JsUtils.isArray(jso)) {
+        if (!JsUtils.isWindow(jso) && !JsUtils.isElement(jso) && JsUtils.isArray(jso)) {
           JsCache c = jso.cast();
           JsNodeArray elms = JsNodeArray.create();
           for (int i = 0; i < c.length(); i++) {