From 61d8717ecf4ac52330ac83c07860e3b4cda44560 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 15 Jul 2011 09:41:29 +0000 Subject: [PATCH] queue method should return the number of elements in the queue if no functions are proviced like jquery does --- .../com/google/gwt/query/client/GQuery.java | 17 ++++++++++++++++- .../com/google/gwt/query/client/LazyGQuery.java | 12 ++++++++++++ .../gwt/query/client/plugins/QueuePlugin.java | 7 +++++++ .../query/client/plugins/SimpleNamedQueue.java | 8 +++++++- 4 files changed, 42 insertions(+), 2 deletions(-) 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 e58250cf..38b4472a 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 @@ -2966,7 +2966,22 @@ public class GQuery implements Lazy { return this; } - + + /** + * Show the number of functions in the efects queue to be executed on the + * first matched element. + */ + public int queue() { + return as(Effects).queue(); + } + + /** + * Show the number of functions in the queued named as queueName to be + * executed on the first matched element. + */ + public int queue(String queueName) { + return as(SimpleNamedQueue).queue(); + } /** * Put a set of {@link Function} at the end of the Effects queue. * diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java index 84753e54..2abdcde2 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java @@ -1685,6 +1685,18 @@ public interface LazyGQuery extends LazyBase{ */ LazyGQuery prop(String key, Function closure); + /** + * Show the number of functions in the efects queue to be executed on the + * first matched element. + */ + int queue(); + + /** + * Show the number of functions in the queued named as queueName to be + * executed on the first matched element. + */ + int queue(String queueName); + /** * Put a set of {@link Function} at the end of the Effects queue. * diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java index e4f1be98..a74848b5 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java @@ -94,6 +94,13 @@ public abstract class QueuePlugin> extends GQuery { } return (T) this; } + + /** + * Show the number of functions to be executed on the first matched element. + */ + public int queue() { + return isEmpty() ? 0 : queue(get(0), null).size(); + } /** * Adds new functions, to be executed, onto the end of the queue of all diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/SimpleNamedQueue.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/SimpleNamedQueue.java index 823ce857..00073555 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/SimpleNamedQueue.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/SimpleNamedQueue.java @@ -20,7 +20,13 @@ public class SimpleNamedQueue extends QueuePlugin{ } private String queueName; - + + @Override + public int queue(String queueName) { + this.queueName = queueName; + return queue(); + } + @Override public SimpleNamedQueue delay(int milliseconds, String queueName, Function... f) { this.queueName = queueName; -- 2.39.5