}\r
\r
/**\r
- * Returns the working set of nodes as a Java array. <b>Do NOT</b attempt to\r
+ * Returns the working set of nodes as a Java array. <b>Do NOT</b> attempt to\r
* modify this array, e.g. assign to its elements, or call Arrays.sort()\r
*/\r
public Element[] elements() {\r
}\r
\r
public static native JSArray create(Node node) /*-{\r
- return [node];\r
+ return node ? [node] : [];\r
}-*/;\r
\r
public static JSArray create(NodeList<?> nl) {\r
}-*/;\r
\r
public final native void addNode(Node n) /*-{\r
- this[this.length]=n;\r
+ if (n) this[this.length]=n;\r
}-*/;\r
\r
- public final native void addNode(Node ci, int i) /*-{\r
- this[i]=ci;\r
+ public final native void addNode(Node n, int i) /*-{\r
+ if (n) this[i]=n;\r
}-*/;\r
\r
public final native void concat(JSArray ary) /*-{\r
LazyGQuery<T> each(Function... f);
/**
- * Returns the working set of nodes as a Java array. <b>Do NOT</b attempt to
+ * Returns the working set of nodes as a Java array. <b>Do NOT</b> attempt to
* modify this array, e.g. assign to its elements, or call Arrays.sort()
*/
Element[] elements();
* Set the value of a style property of an element.
*/
public void setStyleProperty(Element e, String prop, String val) {
+ if (e == null || prop == null) {
+ return;
+ }
prop = fixPropertyName(prop);
// put it in lower-case only when all letters are upper-case, to avoid
// modifying already camelized properties
* Type of the effect action.\r
*/\r
public static enum Action {\r
- HIDE, SHOW\r
+ HIDE, SHOW, TOGGLE\r
}\r
\r
/**\r
\r
public ClipAnimation(Element elem, Action a, Corner c, Direction d,\r
final Function... funcs) {\r
+ if (a == Action.TOGGLE) {\r
+ a = GQuery.$(elem).visible() ? Action.HIDE : Action.SHOW; \r
+ }\r
this.action = a;\r
this.corner = c;\r
this.direction = d;\r
}\r
g.css("overflow", "hidden");\r
g.css("visivility", "visible");\r
- g.css("white-space", "nowrap");\r
super.onStart();\r
}\r
\r
return clip(Action.SHOW, ClipAnimation.Corner.TOP_LEFT,\r
ClipAnimation.Direction.BIDIRECTIONAL, millisecs, f);\r
}\r
+ \r
+ /**\r
+ * Toggle the visibility of all matched elements by adjusting the clip property\r
+ * and firing an optional callback after completion.\r
+ * The effect goes from the bottom to the top.\r
+ */\r
+ public Effects clipToggle(Function... f) {\r
+ return clipToggle(Speed.DEFAULT, f);\r
+ }\r
+\r
+ /**\r
+ * Toggle the visibility of all matched elements by adjusting the clip property\r
+ * and firing an optional callback after completion.\r
+ * The effect goes from the bottom to the top.\r
+ */\r
+ public Effects clipToggle(int millisecs, Function... f) {\r
+ return clip(Action.TOGGLE, ClipAnimation.Corner.TOP_LEFT,\r
+ ClipAnimation.Direction.VERTICAL, millisecs, f);\r
+ }\r
+\r
\r
/**\r
* Hide all matched elements by adjusting the clip property firing an\r
*/
LazyEffects<T> clipDown(int millisecs, Function... f);
+ /**
+ * Toggle the visibility of all matched elements by adjusting the clip property
+ * and firing an optional callback after completion.
+ * The effect goes from the bottom to the top.
+ */
+ LazyEffects<T> clipToggle(Function... f);
+
+ /**
+ * Toggle the visibility of all matched elements by adjusting the clip property
+ * and firing an optional callback after completion.
+ * The effect goes from the bottom to the top.
+ */
+ LazyEffects<T> clipToggle(int millisecs, Function... f);
+
/**
* Hide all matched elements by adjusting the clip property firing an
* optional callback after completion.