<set-property name="export" value="yes" />
<entry-point class="gwtquery.jsquery.client.JsQuery" />
-
- <!-- cross-site -->
- <add-linker name="xsiframe"/>
</module>
<inherits name='gwtquery.jsquery.JsQuery' />
<!--
- Hack to put code into the jsquery.nocache.js so as $ is available
- to use the $().ready method which is widely used in jquery pages.
+ Hack to put code into the jsquery.nocache.js so as $ is available early
+ and we can handle the $().ready method which is widely used in jquery pages.
Otherwise $ wont be available until the async loading of the gwt permutation
which happens after the page was ready.
-->
<!-- Minimize JS -->
<set-property name="compiler.stackMode" value="strip"/>
+ <!-- cross-site -->
+ <add-linker name="xsiframe"/>
+
</module>
this.openTimer = null;
this.init();
- if ( items && items.constructor == Array )
+ if ( items && $.isArray(items) )
this.addItems(items);
}
});
while ( t.parentNode && t.parentNode != $rootDiv[0] )
t = t.parentNode;
- //is the found node one of the visible menu elements?
- for (k in visibleMenus) {
- if (visibleMenus[k].$eDIV[0] == t) {
- // FIXME: why do we need a timeout
- setTimeout($.Menu.closeAll, 100);
- break;
- }
- }
+ // FIXME: why do we need a timeout
+ setTimeout($.Menu.closeAll, 100);
+
// FIXME: JsQuery each doesn't work with arrays
- if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length )
- {
- $.Menu.closeAll();
- }
+ // if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length )
+ // {
+ // $.Menu.closeAll();
+ // }
return true;
},
checkKey : function(e)
var i, isStr,
src = this.src,
self = this;
-
+
this.$eLI = $(menuItemElement.cloneNode(1));
if ( this.addClass )
this.$eLI[0].setAttribute('class', this.addClass);
{
return this.each(function()
{
- if ( items && items.constructor == Array )
+ if ( items && $.isArray(items) )
new $.Menu(this, items, options);
else
{
private native static void testJs() /*-{
var l = @gwtquery.jsquery.client.utils.JsQueryUtils::log(Ljava/lang/Object;);
- l($.each);
- $.each(["a","b"], function(a, b){
- l("kk " + " " + a + " " + b);
- });
+
+ var options = {minWidth: 120, arrowSrc: 'arrow_right.gif', copyClassAttr: true, onClick: function(e, menuItem){
+ alert('you clicked item "' + $(this).text() + '"');
+ }};
+ $('#menuone').menu(options);
+
+ var items = [ {src: 'test', url:'http://www.jquery.com'},
+ {src: ''}, // separator
+ {src: 'test2', subMenu: [ {src: 'sub 1'},
+ {src: 'sub 2', url: 'http://p.sohei.org', target: '_blank'},
+ {src: 'sub 3'}]}];
+ $('#menutwo').menu(options, items);
+
+
}-*/;
}
import com.google.gwt.query.client.GQuery.Offset;
import com.google.gwt.query.client.Predicate;
import com.google.gwt.query.client.Properties;
+import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.query.client.plugins.Effects;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation;
import com.google.gwt.user.client.Event;
* override some methods in order to deal with complex cases.
*
*/
-@ExportPackage("jsQuery")
+@ExportPackage("JsQuery")
@Export(value="fn", all=false)
public class OverlayGQuery implements ExportOverlay<GQuery> {
$wnd.JsQuery && $wnd.JsQuery.onLoad && $wnd.JsQuery.onLoad();
}-*/;
- @ExportPackage("jsQuery")
+ @ExportPackage("JsQuery")
@Export("jFunction")
@ExportClosure()
protected interface OverlayFunction extends ExportOverlay<Function> {
public Object f(Element e, int i);
}
- @ExportPackage("jsQuery")
+ @ExportPackage("JsQuery")
@Export("jPredicate")
@ExportClosure()
protected interface OverlayPredicate extends ExportOverlay<Predicate> {
return JsQueryUtils.inArray(o, arr);
}
+ @ExportStaticMethod("$wnd.$.isArray")
+ public static boolean isArray(JavaScriptObject o) {
+ return JsUtils.isArray(o);
+ }
+
@ExportInstanceMethod
public static GQuery ready(GQuery g, Function f) {
f.fe();
---- jquery.menu.js 2012-03-15 10:34:24.000000000 +0100
-+++ 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
-+ for (k in visibleMenus) {
-+ if (visibleMenus[k].$eDIV[0] == t) {
-+ // FIXME: why do we need a timeout
-+ setTimeout($.Menu.closeAll, 100);
-+ break;
-+ }
-+ }
-+ // FIXME: JsQuery each doesn't work with arrays
- if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length )\r
- {\r
- $.Menu.closeAll();\r
-@@ -239,9 +243,7 @@
- $.extend(defaults, d);\r
- },\r
- prototype : {\r
-- /**\r
-- * create / initialize new menu\r
-- */\r
+--- query.menu.js 2012-03-17 21:13:29.000000000 +0100
++++ JsMenu.java 2012-03-17 21:04:09.000000000 +0100
+@@ -114,7 +113,7 @@
+ this.openTimer = null;
+
+ this.init();
+- if ( items && items.constructor == Array )
++ if ( items && $.isArray(items) )
+ this.addItems(items);
+ }
+ });
+@@ -132,11 +129,15 @@
+ while ( t.parentNode && t.parentNode != $rootDiv[0] )
+ t = t.parentNode;
+
+- //is the found node one of the visible menu elements?
+- if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length )
+- {
+- $.Menu.closeAll();
+- }
++ // FIXME: why do we need a timeout
++ setTimeout($.Menu.closeAll, 100);
+
- init : function()\r
- {\r
- var self = this;\r
-@@ -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
-- if ( $.browser.msie )\r
++ // FIXME: JsQuery each doesn't work with arrays
++ // if ( !$(visibleMenus).filter(function(){ return this.$eDIV[0] == t }).length )
++ // {
++ // $.Menu.closeAll();
++ // }
++ return true;
+ },
+ checkKey : function(e)
+ {
+@@ -395,7 +394,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)
+- if ( $.browser.msie )
+ if ( 0) //$.browser.msie )
- this.$eUL.css('width', parseInt($.browser.version) == 6 ? this.$eDIV.width() - 7 : this.$eUL.width());\r
- \r
- if ( this.settings.onOpen )\r
-@@ -439,7 +443,7 @@
- }\r
- \r
- //y-pos\r
-- if ( $.fn.scrollTop )\r
+ this.$eUL.css('width', parseInt($.browser.version) == 6 ? this.$eDIV.width() - 7 : this.$eUL.width());
+
+ if ( this.settings.onOpen )
+@@ -437,7 +438,7 @@
+ }
+
+ //y-pos
+- if ( $.fn.scrollTop )
+ if ($().scrollTop )
- {\r
- wst = $(window).scrollTop();\r
- if ( wh < height ) //menu is bigger than the window\r
-@@ -478,7 +482,7 @@
- }\r
- }\r
- //x-pos\r
-- if ( $.fn.scrollLeft )\r
+ {
+ wst = $(window).scrollTop();
+ if ( wh < height ) //menu is bigger than the window
+@@ -476,7 +477,7 @@
+ }
+ }
+ //x-pos
+- if ( $.fn.scrollLeft )
+ if ($().scrollLeft )
- {\r
- wsl = $(window).scrollLeft();\r
- if ( ww + wsl < posX + width )\r
+ {
+ wsl = $(window).scrollLeft();
+ if ( ww + wsl < posX + width )
+@@ -898,7 +897,7 @@
+ {
+ return this.each(function()
+ {
+- if ( items && items.constructor == Array )
++ if ( items && $.isArray(items) )
+ new $.Menu(this, items, options);
+ else
+ {
+
public static int inArray(Object object, Object array) {
if (array instanceof List) {
- return ((List)array).indexOf(object);
+ return ((List<?>)array).indexOf(object);
} else if (object instanceof JavaScriptObject
&& JsUtils.isElement((JavaScriptObject) object)) {
return dollar(array).index((Element) object);
}
private static native JavaScriptObject getDefaultPrototype() /*-{
- return $wnd.jsQuery && $wnd.jsQuery.fn ? $wnd.jsQuery.fn.prototype
+ return $wnd.JsQuery && $wnd.JsQuery.fn
+ ? $wnd.JsQuery.fn.prototype
: null;
}-*/;
private static native JavaScriptObject extendImpl(boolean deep,
JavaScriptObject ctx, Object s) /*-{
- var d = ctx ? ctx : $wnd.jsQuery.fn.prototype || {};
+ var d = ctx ? ctx : $wnd.JsQuery.fn.prototype || {};
for (k in s) {
d[k] = s[k];
if (!ctx)