*/\r
package com.google.gwt.query.client;\r
\r
+import com.google.gwt.core.client.Duration;\r
import com.google.gwt.dom.client.Element;\r
import com.google.gwt.dom.client.NodeList;\r
-import com.google.gwt.core.client.Duration;\r
import com.google.gwt.user.client.Timer;\r
\r
/**\r
return elem.getPropertyDouble(prop);\r
}\r
double r = parseDouble(GQuery.curCSS(elem, prop, force));\r
- return !Double.isNaN(r) && r > -10000 ? r\r
+ r = !Double.isNaN(r) && r > -10000 ? r\r
: parseDouble(GQuery.curCSS(elem, prop, false));\r
+ if (Double.isNaN(r)) {\r
+ r = 0;\r
+ }\r
+ return r;\r
}\r
\r
public void hide() {\r
}\r
\r
/**\r
- * Fade out all matched elements by adjusting their opacity to 0, then\r
- * setting display to "none". Only the opacity is adjusted for this\r
- * animation, meaning that all of the matched elements should already have\r
- * some form of height and width associated with them.\r
+ * Fade out all matched elements by adjusting their opacity to 0, then setting\r
+ * display to "none". Only the opacity is adjusted for this animation, meaning\r
+ * that all of the matched elements should already have some form of height\r
+ * and width associated with them.\r
*/\r
public Effects fadeOut(int speed) {\r
return fadeOut(speed, null);\r
if (listener.hasEventType(etype)) {
if (!listener.fire(event)) {
event.cancelBubble(true);
+ event.stopPropagation();
event.preventDefault();
}
}
import com.google.gwt.dom.client.TextAreaElement;\r
import static com.google.gwt.query.client.Effects.Effects;\r
import static com.google.gwt.query.client.Events.Events;\r
-import com.google.gwt.query.client.impl.DocumentStyleImpl;\r
-import com.google.gwt.query.client.css.BackgroundColor;\r
-import com.google.gwt.query.client.css.RGBColor;\r
import com.google.gwt.query.client.css.CssProperty;\r
-import com.google.gwt.query.client.css.TakesLength;\r
import com.google.gwt.query.client.css.Length;\r
-import com.google.gwt.query.client.css.TakesPercentage;\r
import com.google.gwt.query.client.css.Percentage;\r
+import com.google.gwt.query.client.css.TakesLength;\r
+import com.google.gwt.query.client.css.TakesPercentage;\r
+import com.google.gwt.query.client.impl.DocumentStyleImpl;\r
import com.google.gwt.user.client.DOM;\r
import com.google.gwt.user.client.Event;\r
import com.google.gwt.user.client.Window;\r
return new GQuery(elements);\r
}\r
\r
+ /**\r
+ * Wrap a GQuery around an existing element.\r
+ */\r
public static GQuery $(Element element) {\r
JSArray a = JSArray.create();\r
a.addNode(element);\r
return new GQuery(a);\r
}\r
\r
+ /**\r
+ * Wrap a GQuery around an event's target element.\r
+ */\r
+ public static GQuery $(Event event) {\r
+ return $(event.getCurrentTarget());\r
+ }\r
+\r
+\r
/**\r
* Wrap a JSON object.\r
*/\r
if (name != null && value != null) {\r
d.put(name, value);\r
}\r
- return name != null ? value : id;\r
+ return name != null ? d.get(name) : id;\r
}\r
\r
private void dequeue(Element elem, String type) {\r
qq.enqueue(data);\r
}\r
if (SelectorEngine.eq(type, "__FXqueue") && qq.length() == 1) {\r
- data.f(elem);\r
+ if(data != null) {\r
+ data.f(elem);\r
+ }\r
}\r
return qq;\r
}\r
sw.outdent();
sw.println("}");
sw.outdent();
- sw.println("return true;");
+ sw.println("return false;");
sw.println("}");
sw.outdent();
sw.println("};");
package gwtquery.samples.client;\r
\r
import com.google.gwt.core.client.EntryPoint;\r
-import com.google.gwt.query.client.$;\r
-import com.google.gwt.query.client.Function;\r
import com.google.gwt.query.client.Effects;\r
+import com.google.gwt.query.client.Function;\r
import com.google.gwt.query.client.GQuery;\r
-import com.google.gwt.query.client.css.CSS;\r
import static com.google.gwt.query.client.GQuery.$;\r
+import static com.google.gwt.query.client.GQuery.$$;\r
import static com.google.gwt.query.client.GQuery.lazy;\r
-import static com.google.gwt.query.client.css.CSS.*;\r
-import static com.google.gwt.query.client.css.Length.*;\r
-import static com.google.gwt.query.client.css.Percentage.*;\r
-import static com.google.gwt.query.client.css.RGBColor.*;\r
+import com.google.gwt.user.client.Event;\r
\r
/**\r
* Copyright 2007 Timepedia.org Licensed under the Apache License, Version 2.0\r
\r
public void onModuleLoad() {\r
GQuery q = $(".note");\r
- q.setCss(CSS.BACKGROUND_COLOR, CSS.RED);\r
- q.setCss(TEXT_ALIGN, LEFT);\r
- q.setCss(VERTICAL_ALIGN, px(10));\r
\r
- $("div > div").hover(lazy().\r
- css("color", "red").\r
- done(), lazy().\r
+ $("div > div").\r
css("color", "blue").\r
- done());\r
-\r
-// $(".note").dblclick(\r
-// lazy().as(Effects.Effects).\r
-// fadeOut().\r
-// done());\r
-// $("div.outer").dblclick(new Function() {\r
-// @Override\r
-// public boolean f(Event e, Object data) {\r
-// $(e.getCurrentTarget()).as(Effects.Effects).slideUp();\r
-// return true;\r
-// }\r
-// });\r
-// $("div").wrapAll("<table border=2><tr><td></td></tr></table>");\r
+ hover(\r
+ lazy().\r
+ css("color", "red").\r
+ done(),\r
+ lazy().\r
+ css("color", "blue").\r
+ done());\r
+ $("div.outer > div").css("position", "relative").dblclick(new Function() {\r
+ public boolean f(Event e) {\r
+ $("div.outer > div").as(Effects.Effects).\r
+ animate($$("left: '+=100'"), 400, Effects.Easing.LINEAR, null).\r
+ animate($$("top: '+=100'"), 400, Effects.Easing.LINEAR, null).\r
+ animate($$("left: '-=100'"), 400, Effects.Easing.LINEAR, null).\r
+ animate($$("top: '-=100'"), 400, Effects.Easing.LINEAR, null);\r
+\r
+ return true;\r
+ }\r
+ });\r
+ $(".note").click(lazy().fadeOut().done());\r
+ $(".note").append(" Hello");\r
+\r
+\r
}\r
}\r