]> source.dussan.org Git - gwtquery.git/commitdiff
moved especific FX queue methods to Effects class
authorManolo Carrasco <manolo@apache.org>
Sun, 30 May 2010 06:29:54 +0000 (06:29 +0000)
committerManolo Carrasco <manolo@apache.org>
Sun, 30 May 2010 06:29:54 +0000 (06:29 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/Effects.java
gwtquery-core/src/main/java/com/google/gwt/query/client/GQueryQueue.java

index b82baaa0289c43cf7bc56d7e3d3435efaabaa819..fd77124a589c8b73c47d2fde3c71014d2c9d3293 100644 (file)
@@ -60,17 +60,17 @@ public class Effects extends GQueryQueue {
   public enum Speed {\r
 \r
     /**\r
-     * 600 millisecond animation.\r
+     * 400 millisecond animation.\r
      */\r
-    SLOW(600),\r
+    DEFAULT(400),\r
     /**\r
      * 200 millisecond animation.\r
      */\r
     FAST(200),\r
     /**\r
-     * 400 millisecond animation.\r
+     * 600 millisecond animation.\r
      */\r
-    DEFAULT(400);\r
+    SLOW(600);\r
 \r
     private final int duration;\r
 \r
@@ -88,26 +88,26 @@ public class Effects extends GQueryQueue {
    */\r
   protected class PropFx {\r
 \r
-    public SpeedOpts opt;\r
-\r
     public Element elem;\r
 \r
-    public String prop;\r
-\r
-    private double startTime;\r
+    public SpeedOpts opt;\r
 \r
-    private double start;\r
+    public String prop;\r
 \r
     private double end;\r
 \r
-    private String unit;\r
-\r
     private double now;\r
 \r
     private double pos;\r
 \r
+    private double start;\r
+\r
+    private double startTime;\r
+\r
     private double state;\r
 \r
+    private String unit;\r
+\r
     public double cur(boolean force) {\r
       if (elem.getPropertyString(prop) != null && (elem.getStyle() == null\r
           || elem.getStyle().getProperty(prop) == null)) {\r
@@ -136,6 +136,13 @@ public class Effects extends GQueryQueue {
       return animate(genFx("hide", 3), speed, Easing.LINEAR, callback);\r
     }\r
 \r
+    public void show() {\r
+      opt.cache.put(prop, elem.getStyle().getProperty(prop));\r
+      opt.show = true;\r
+      custom("width".equals(prop) || "height".equals(prop) ? 1 : 0, cur(false));\r
+      $(elem).show();\r
+    }\r
+\r
     public Effects show(Speed speed) {\r
       return show(speed, null);\r
     }\r
@@ -144,13 +151,6 @@ public class Effects extends GQueryQueue {
       return animate(genFx("show", 3), speed, Easing.LINEAR, callback);\r
     }\r
 \r
-    public void show() {\r
-      opt.cache.put(prop, elem.getStyle().getProperty(prop));\r
-      opt.show = true;\r
-      custom("width".equals(prop) || "height".equals(prop) ? 1 : 0, cur(false));\r
-      $(elem).show();\r
-    }\r
-\r
     public Effects toggle(Speed speed) {\r
       return hide(speed, null);\r
     }\r
@@ -254,28 +254,28 @@ public class Effects extends GQueryQueue {
 \r
   private class SpeedOpts {\r
 \r
-    public String display;\r
-\r
-    public String overflow;\r
-\r
     public Properties curAnim;\r
 \r
+    public String display;\r
+\r
     public boolean hide;\r
 \r
+    public String overflow;\r
+\r
     public boolean show;\r
 \r
-    private Properties properties;\r
+    private GQuery.DataCache cache = DataCache.createObject().cast();\r
+\r
+    private Function complete;\r
 \r
     private int duration;\r
 \r
     private Effects.Easing easing;\r
 \r
-    private Function complete;\r
+    private Properties properties;\r
 \r
     private boolean queue = true;\r
 \r
-    private GQuery.DataCache cache = DataCache.createObject().cast();\r
-\r
     protected SpeedOpts(int speed, Easing easing, Function complete) {\r
       this.complete = complete;\r
       this.easing = easing;\r
@@ -378,11 +378,6 @@ public class Effects extends GQueryQueue {
     super(list);\r
   }\r
 \r
-  public Effects animate(final Properties properties, final Speed speed,\r
-      final Easing easing, final Function complete) {\r
-    return animate(properties, speed.getDuration(), easing, complete);\r
-  }\r
-\r
   public Effects animate(final Properties properties, final int speed,\r
       final Easing easing, final Function complete) {\r
     if (!"false".equals(properties.get("queue"))) {\r
@@ -456,13 +451,17 @@ public class Effects extends GQueryQueue {
     return this;\r
   }\r
 \r
+\r
+  public Effects animate(final Properties properties, final Speed speed,\r
+      final Easing easing, final Function complete) {\r
+    return animate(properties, speed.getDuration(), easing, complete);\r
+  }\r
+  \r
   /**\r
-   * Fade in all matched elements by adjusting their opacity. Only the opacity\r
-   * is adjusted for this animation, meaning that all of the matched elements\r
-   * should already have some form of height and width associated with them.\r
+   * Removes a queued function from the front of the FX queue and executes it.\r
    */\r
-  public Effects fadeIn() {\r
-    return fadeIn(Speed.DEFAULT);\r
+  public Effects dequeue() {\r
+    return (Effects)dequeue("__FX");\r
   }\r
 \r
   /**\r
@@ -470,8 +469,8 @@ public class Effects extends GQueryQueue {
    * is adjusted for this animation, meaning that all of the matched elements\r
    * should already have some form of height and width associated with them.\r
    */\r
-  public Effects fadeIn(Speed speed) {\r
-    return fadeIn(speed, null);\r
+  public Effects fadeIn() {\r
+    return fadeIn(Speed.DEFAULT);\r
   }\r
 \r
   /**\r
@@ -489,8 +488,17 @@ public class Effects extends GQueryQueue {
    * animation, meaning that all of the matched elements should already have\r
    * some form of height and width associated with them.\r
    */\r
-  public Effects fadeIn(Speed speed, Function callback) {\r
-    return fadeIn(speed.duration, callback);\r
+  public Effects fadeIn(int speed, Function callback) {\r
+    return animate($$("opacity: \"show\""), speed, Easing.LINEAR, callback);\r
+  }\r
+\r
+  /**\r
+   * Fade in all matched elements by adjusting their opacity. Only the opacity\r
+   * is adjusted for this animation, meaning that all of the matched elements\r
+   * should already have some form of height and width associated with them.\r
+   */\r
+  public Effects fadeIn(Speed speed) {\r
+    return fadeIn(speed, null);\r
   }\r
 \r
   /**\r
@@ -499,8 +507,8 @@ public class Effects extends GQueryQueue {
    * animation, meaning that all of the matched elements should already have\r
    * some form of height and width associated with them.\r
    */\r
-  public Effects fadeIn(int speed, Function callback) {\r
-    return animate($$("opacity: \"show\""), speed, Easing.LINEAR, callback);\r
+  public Effects fadeIn(Speed speed, Function callback) {\r
+    return fadeIn(speed.duration, callback);\r
   }\r
 \r
   /**\r
@@ -519,17 +527,28 @@ public class Effects extends GQueryQueue {
    * that all of the matched elements should already have some form of height\r
    * and width associated with them.\r
    */\r
-  public Effects fadeOut(Speed speed) {\r
+  public Effects fadeOut(int speed) {\r
     return fadeOut(speed, null);\r
   }\r
 \r
+  /**\r
+   * Fade out all matched elements by adjusting their opacity to 0, then setting\r
+   * display to "none" and firing an optional callback after completion. Only\r
+   * the opacity is adjusted for this animation, meaning that all of the matched\r
+   * elements should already have some form of height and width associated with\r
+   * them.\r
+   */\r
+  public Effects fadeOut(int speed, Function callback) {\r
+    return animate($$("opacity: \"hide\""), speed, Easing.LINEAR, callback);\r
+  }\r
+\r
   /**\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
+  public Effects fadeOut(Speed speed) {\r
     return fadeOut(speed, null);\r
   }\r
 \r
@@ -544,17 +563,6 @@ public class Effects extends GQueryQueue {
     return fadeOut(speed.duration, callback);\r
   }\r
 \r
-  /**\r
-   * Fade out all matched elements by adjusting their opacity to 0, then setting\r
-   * display to "none" and firing an optional callback after completion. Only\r
-   * the opacity is adjusted for this animation, meaning that all of the matched\r
-   * elements should already have some form of height and width associated with\r
-   * them.\r
-   */\r
-  public Effects fadeOut(int speed, Function callback) {\r
-    return animate($$("opacity: \"hide\""), speed, Easing.LINEAR, callback);\r
-  }\r
-\r
   /**\r
    * Fade the opacity of all matched elements to a specified opacity. Only the\r
    * opacity is adjusted for this animation, meaning that all of the matched\r
@@ -590,6 +598,14 @@ public class Effects extends GQueryQueue {
     return this;\r
   }\r
 \r
+  /**\r
+   * Adds a new function, to be executed, onto the end of the queue of all\r
+   * matched elements in the FX queue.\r
+   */\r
+  public GQueryQueue queue(Function data) {\r
+    return queue("__FX", data);\r
+  }\r
+\r
   /**\r
    * Displays each of the set of matched elements if they are hidden.\r
    */\r
index 23d8d23228a64774de354f71ff48bc19f9c2b738..f1d8dcd021aa2229c26fd4aa80c4d81be7fc7a06 100644 (file)
@@ -63,13 +63,6 @@ public abstract class GQueryQueue extends GQuery {
     super(list);
   }
 
-  /**
-   * Removes a queued function from the front of the FX queue and executes it.
-   */
-  public GQuery dequeue() {
-    return dequeue("__FX");
-  }
-
   /**
    * Removes a queued function from the front of the queue and executes it.
    */
@@ -80,20 +73,6 @@ public abstract class GQueryQueue extends GQuery {
     return this;
   }
 
-  /**
-   * Returns a reference to the FX queue.
-   */
-  public Queue<Function> queue() {
-    return queue(elements.getItem(0), "__FX", null);
-  }
-
-  /**
-   * Adds a new function, to be executed, onto the end of the queue of all
-   * matched elements in the FX queue.
-   */
-  public GQueryQueue queue(Function data) {
-    return queue("__FX", data);
-  }
 
   /**
    * Returns a reference to the first element's queue (which is an array of
@@ -143,19 +122,19 @@ public abstract class GQueryQueue extends GQuery {
   private Queue<Function> queue(Element elem, String type, Function data) {
     if (elem != null) {
       type = type + "queue";
-      Queue<Function> qq = (Queue<Function>) data(elem, type, null);
-      if (qq == null) {
-        qq = (Queue<Function>) data(elem, type, Queue.newInstance());
+      Queue<Function> q = (Queue<Function>) data(elem, type, null);
+      if (q == null) {
+        q = (Queue<Function>) data(elem, type, Queue.newInstance());
       }
       if (data != null) {
-        qq.enqueue(data);
+        q.enqueue(data);
       }
-      if (SelectorEngine.eq(type, "__FXqueue") && qq.length() == 1) {
+      if (SelectorEngine.eq(type, "__FXqueue") && q.length() == 1) {
         if (data != null) {
           data.f(elem);
         }
       }
-      return qq;
+      return q;
     }
     return null;
   }