]> source.dussan.org Git - gwtquery.git/commitdiff
checking nulls when creating or adding elements to JSArray. Added a couple of shortcu...
authorManolo Carrasco <manolo@apache.org>
Tue, 21 Dec 2010 08:26:38 +0000 (08:26 +0000)
committerManolo Carrasco <manolo@apache.org>
Tue, 21 Dec 2010 08:26:38 +0000 (08:26 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
gwtquery-core/src/main/java/com/google/gwt/query/client/JSArray.java
gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java
gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ClipAnimation.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java

index e99527cbbd1fc7fb0ed65c6a1277e43ade60af58..a14216d6eb6213ef589a991296dd22bd42d69dcd 100644 (file)
@@ -1030,7 +1030,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
   }\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
index 302219a0013828d1d119cf0f7e67a028af72bcf9..47a5e8076991f2cc33112e59910a5aedc13ce0b8 100644 (file)
@@ -29,7 +29,7 @@ public class JSArray extends NodeList<Element> {
   }\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
@@ -48,11 +48,11 @@ public class JSArray extends NodeList<Element> {
   }-*/;\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
index d3302452b7c9649a0f12fdee076f1ee21b6a2dac..f26352e55c20482b55dfd73489e958c0128a49f4 100644 (file)
@@ -362,7 +362,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{
   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();
index 2c331dbe574d8b897ee2d3d73c71a4e2e58bfead..563eb9dc14b3af505c5abd702bcc4c7b6c0eeb06 100644 (file)
@@ -117,6 +117,9 @@ public class DocumentStyleImpl {
    * 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
index 6aa219e6df368335f2cd16c973bb742e545a6427..9f1b291d71c51375e09ebccdc2bc2d06a0026904 100755 (executable)
@@ -29,7 +29,7 @@ public class ClipAnimation extends Animation {
    * Type of the effect action.\r
    */\r
   public static enum Action {\r
-    HIDE, SHOW\r
+    HIDE, SHOW, TOGGLE\r
   }\r
 \r
   /**\r
@@ -60,6 +60,9 @@ public class ClipAnimation extends Animation {
 \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
@@ -101,7 +104,6 @@ public class ClipAnimation extends Animation {
     }\r
     g.css("overflow", "hidden");\r
     g.css("visivility", "visible");\r
-    g.css("white-space", "nowrap");\r
     super.onStart();\r
   }\r
 \r
index 1c95f833a2272a5e05de2cb94b5a4e2bf98940f0..62fdb0ce5ff14a27be6b41b494af8e4015b711ab 100755 (executable)
@@ -245,6 +245,26 @@ public class Effects extends GQueryQueue<Effects>  {
     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
index 7596e8b027fbc135ac205cda78ce767e76046f40..8521baf0266314ba173b2bb9d80603ad90ae827a 100644 (file)
@@ -149,6 +149,20 @@ public interface LazyEffects<T> extends LazyBase<T>{
    */
   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.