From 95ddf5b769e98e2497caf938787ea0d90b1ee386 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Sat, 5 Jun 2010 06:59:17 +0000 Subject: [PATCH] Use className as type in queue --- .../com/google/gwt/query/client/Effects.java | 15 ----- .../com/google/gwt/query/client/GQuery.java | 12 +++- .../google/gwt/query/client/GQueryQueue.java | 60 ++++++++----------- 3 files changed, 35 insertions(+), 52 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Effects.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Effects.java index fd77124a..9c103c8e 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Effects.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Effects.java @@ -456,13 +456,6 @@ public class Effects extends GQueryQueue { final Easing easing, final Function complete) { return animate(properties, speed.getDuration(), easing, complete); } - - /** - * Removes a queued function from the front of the FX queue and executes it. - */ - public Effects dequeue() { - return (Effects)dequeue("__FX"); - } /** * Fade in all matched elements by adjusting their opacity. Only the opacity @@ -598,14 +591,6 @@ public class Effects extends GQueryQueue { return this; } - /** - * 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); - } - /** * Displays each of the set of matched elements if they are hidden. */ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index 91dd9a84..b278c203 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -392,6 +392,10 @@ public class GQuery implements Lazy { public GQuery(Element element) { elements = JSArray.create(element); } + + public GQuery(GQuery gq) { + this(gq.get()); + } /** * Add elements to the set of matched elements if they are not included yet. @@ -810,9 +814,11 @@ public class GQuery implements Lazy { * public String f(Element e, int i) */ public GQuery each(Function... f) { - for (Function f1 : f) { - for (int i = 0; i < elements.getLength(); i++) { - f1.f(elements.getItem(i), i); + if (f != null) { + for (Function f1 : f) { + for (int i = 0; i < elements.getLength(); i++) { + f1.f(elements.getItem(i), i); + } } } return this; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQueryQueue.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQueryQueue.java index 13d75c7d..16c95069 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQueryQueue.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQueryQueue.java @@ -51,8 +51,8 @@ public abstract class GQueryQueue extends GQuery { }-*/; } - public GQueryQueue(Element element) { - super(element); + public GQueryQueue(GQuery gq) { + super(gq); } public GQueryQueue(JSArray elements) { @@ -63,32 +63,28 @@ public abstract class GQueryQueue extends GQuery { super(list); } + public GQueryQueue(Element element) { + super(element); + } + /** * Removes a queued function from the front of the queue and executes it. */ - public GQueryQueue dequeue(String type) { + public GQueryQueue dequeue() { for (Element e : elements()) { - dequeue(e, type); + dequeue(e); } return this; } - /** - * Returns a reference to the first element's queue (which is an array of - * functions). - */ - public Queue queue(String type) { - return queue(elements.getItem(0), type, null); - } - /** * Adds a new function, to be executed, onto the end of the queue of all * matched elements. */ - public GQueryQueue queue(String type, Function func) { + public GQueryQueue queue(Function func) { for (Element e : elements()) { - queue(e, type, func); + queue(e, func); } return this; } @@ -96,22 +92,18 @@ public abstract class GQueryQueue extends GQuery { /** * Replaces the current queue with the given queue on all matched elements. */ - public GQueryQueue queue(String type, Queue queue) { + public GQueryQueue queue(Queue queue) { for (Element e : elements()) { - replacequeue(e, type, queue); + replacequeue(e, queue); } return this; } - private void dequeue(Element elem, String type) { - Queue q = queue(elem, type, null); - + private void dequeue(Element elem) { + Queue q = queue(elem, null); if (q != null) { Function f = q.dequeue(); - - if (SelectorEngine.eq(type, "__FX")) { - f = q.peek(0); - } + f = q.peek(0); if (f != null) { f.f(elem); } @@ -119,30 +111,30 @@ public abstract class GQueryQueue extends GQuery { } @SuppressWarnings("unchecked") - private Queue queue(Element elem, String type, Function func) { + private Queue queue(Element elem, Function func) { if (elem != null) { - type = type + "queue"; - Queue q = (Queue) data(elem, type, null); + Queue q = (Queue) data(elem, getQueueType(), null); if (q == null) { - q = (Queue) data(elem, type, Queue.newInstance()); + q = (Queue) data(elem, getQueueType(), Queue.newInstance()); } if (func != null) { q.enqueue(func); } - if (SelectorEngine.eq(type, "__FXqueue") && q.length() == 1) { - if (func != null) { - func.f(elem); - } + if (q.length() == 1 && func != null) { + func.f(elem); } return q; } return null; } - private void replacequeue(Element elem, String type, Queue queue) { + private void replacequeue(Element elem, Queue queue) { if (elem != null) { - type = type + "queue"; - data(elem, type, queue); + data(elem, getQueueType(), queue); } } + + protected String getQueueType() { + return "GQueryQueue_" + this.getClass().getName(); + } } -- 2.39.5