From 552eef35ea1db134e52f5dfe314d3f03877eff34 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 15 Mar 2012 12:30:33 +0000 Subject: JsQuery: Fix scrolls in JsMenu plugin --- .../src/main/java/gwtquery/jsquery/client/JsMenu.java | 14 ++++++++++---- .../src/main/java/gwtquery/jsquery/client/JsQuery.java | 4 +++- .../main/java/gwtquery/jsquery/client/OverlayGQuery.java | 9 ++++++--- .../src/main/java/gwtquery/jsquery/client/jsmenu.diff | 16 ++++++++-------- .../java/gwtquery/jsquery/client/utils/JsQueryUtils.java | 2 +- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/jsquery/src/main/java/gwtquery/jsquery/client/JsMenu.java b/jsquery/src/main/java/gwtquery/jsquery/client/JsMenu.java index 57c3cbdd..465b9ff2 100644 --- a/jsquery/src/main/java/gwtquery/jsquery/client/JsMenu.java +++ b/jsquery/src/main/java/gwtquery/jsquery/client/JsMenu.java @@ -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 ) diff --git a/jsquery/src/main/java/gwtquery/jsquery/client/JsQuery.java b/jsquery/src/main/java/gwtquery/jsquery/client/JsQuery.java index 9514ae73..0a929a87 100644 --- a/jsquery/src/main/java/gwtquery/jsquery/client/JsQuery.java +++ b/jsquery/src/main/java/gwtquery/jsquery/client/JsQuery.java @@ -20,7 +20,9 @@ public class JsQuery implements EntryPoint { }); OverlayGQuery.export(); -// JsMenu.loadPlugin(); + JsMenu.loadPlugin(); + OverlayGQuery.onLoad(); + // testJs(); } diff --git a/jsquery/src/main/java/gwtquery/jsquery/client/OverlayGQuery.java b/jsquery/src/main/java/gwtquery/jsquery/client/OverlayGQuery.java index 59d70d4a..070c0cee 100644 --- a/jsquery/src/main/java/gwtquery/jsquery/client/OverlayGQuery.java +++ b/jsquery/src/main/java/gwtquery/jsquery/client/OverlayGQuery.java @@ -49,6 +49,12 @@ public class OverlayGQuery implements ExportOverlay { 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 { $ = $wnd.$; window = $wnd; document = $doc; - - $wnd.onJsQueryLoad && $wnd.onJsQueryLoad(); - $wnd.JsQuery && $wnd.JsQuery.onLoad && $wnd.JsQuery.onLoad(); }-*/; @ExportStaticMethod("$wnd.$") diff --git a/jsquery/src/main/java/gwtquery/jsquery/client/jsmenu.diff b/jsquery/src/main/java/gwtquery/jsquery/client/jsmenu.diff index f5ce17a2..9bcf60cd 100644 --- a/jsquery/src/main/java/gwtquery/jsquery/client/jsmenu.diff +++ b/jsquery/src/main/java/gwtquery/jsquery/client/jsmenu.diff @@ -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; //is the found node one of the visible menu elements? @@ -15,7 +15,7 @@ if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length ) { $.Menu.closeAll(); -@@ -239,9 +226,7 @@ +@@ -239,9 +243,7 @@ $.extend(defaults, d); }, prototype : { @@ -26,7 +26,7 @@ init : function() { var self = this; -@@ -397,7 +382,7 @@ +@@ -397,7 +399,7 @@ this.$eDIV.css({display:'none', visibility: ''}).show(); //IEs default width: auto is bad! ie6 and ie7 have are producing different errors.. (7 = 5px shadowbox + 2px border) @@ -35,21 +35,21 @@ this.$eUL.css('width', parseInt($.browser.version) == 6 ? this.$eDIV.width() - 7 : this.$eUL.width()); if ( this.settings.onOpen ) -@@ -439,7 +426,7 @@ +@@ -439,7 +443,7 @@ } //y-pos - if ( $.fn.scrollTop ) -+ if (0) //$.fn.scrollTop ) ++ if ($().scrollTop ) { wst = $(window).scrollTop(); if ( wh < height ) //menu is bigger than the window -@@ -478,7 +465,7 @@ +@@ -478,7 +482,7 @@ } } //x-pos - if ( $.fn.scrollLeft ) -+ if (0) //$.fn.scrollLeft ) ++ if ($().scrollLeft ) { wsl = $(window).scrollLeft(); if ( ww + wsl < posX + width ) diff --git a/jsquery/src/main/java/gwtquery/jsquery/client/utils/JsQueryUtils.java b/jsquery/src/main/java/gwtquery/jsquery/client/utils/JsQueryUtils.java index 5025f61b..66550a1c 100644 --- a/jsquery/src/main/java/gwtquery/jsquery/client/utils/JsQueryUtils.java +++ b/jsquery/src/main/java/gwtquery/jsquery/client/utils/JsQueryUtils.java @@ -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++) { -- cgit v1.2.3