/**\r
* Effects plugin for Gwt Query.\r
*/\r
-public class Effects extends GQuery {\r
+public class Effects extends GQueryQueue {\r
\r
/**\r
* Built in easing functions.\r
\r
public void complete(Element elem) {\r
if (queue) {\r
- $(elem).dequeue();\r
+ new Effects(elem).dequeue();\r
}\r
if (complete != null) {\r
complete.f(elem);\r
this[id]=obj;\r
}-*/;\r
}\r
-\r
- public static final class Queue<T> extends JavaScriptObject {\r
-\r
- public static Queue newInstance() {\r
- return createArray().cast();\r
- }\r
-\r
- protected Queue() {\r
- }\r
-\r
- public native T dequeue() /*-{\r
- return this.shift();\r
- }-*/;\r
-\r
- public native void enqueue(T foo) /*-{\r
- this.push(foo);\r
- }-*/;\r
-\r
- public native int length() /*-{\r
- return this.length;\r
- }-*/;\r
-\r
- public native T peek(int i) /*-{\r
- return this[i];\r
- }-*/;\r
- }\r
\r
public static final Element window = window();\r
public static final Document document = Document.get();\r
return bindOrFire(Event.ONDBLCLICK, null, f);\r
}\r
\r
- /**\r
- * Removes a queued function from the front of the queue and executes it.\r
- */\r
- public GQuery dequeue(String type) {\r
- for (Element e : elements()) {\r
- dequeue(e, type);\r
- }\r
- return this;\r
- }\r
-\r
- /**\r
- * Removes a queued function from the front of the FX queue and executes it.\r
- */\r
- public GQuery dequeue() {\r
- return dequeue("__FX");\r
- }\r
-\r
/**\r
* Run one or more Functions over each element of the GQuery.\r
* You have to override one of these funcions:\r
return pushStack(unique(result), "prevAll", getSelector());\r
}\r
\r
- /**\r
- * Returns a reference to the first element's queue (which is an array of\r
- * functions).\r
- */\r
- public Queue<Function> queue(String type) {\r
- return queue(elements.getItem(0), type, null);\r
- }\r
-\r
- /**\r
- * Returns a reference to the FX queue.\r
- */\r
- public Queue<Function> queue() {\r
- return queue(elements.getItem(0), "__FX", null);\r
- }\r
-\r
- /**\r
- * Adds a new function, to be executed, onto the end of the queue of all\r
- * matched elements.\r
- */\r
- public GQuery queue(String type, Function data) {\r
- for (Element e : elements()) {\r
- queue(e, type, data);\r
- }\r
- return this;\r
- }\r
-\r
- /**\r
- * Replaces the current queue with the given queue on all matched elements.\r
- */\r
- public GQuery queue(String type, Queue data) {\r
- for (Element e : elements()) {\r
- replacequeue(e, type, data);\r
- }\r
- 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 GQuery queue(Function data) {\r
- return queue("__FX", data);\r
- }\r
-\r
/**\r
* Removes all matched elements from the DOM.\r
*/\r
return name != null ? d.getObject(name) : id;\r
}\r
\r
- private void dequeue(Element elem, String type) {\r
- Queue<Function> q = queue(elem, type, null);\r
-\r
- if (q != null) {\r
- Function f = q.dequeue();\r
-\r
- if (SelectorEngine.eq(type, "__FX")) {\r
- f = q.peek(0);\r
- }\r
- if (f != null) {\r
- f.f(elem);\r
- }\r
- }\r
- }\r
-\r
private GQuery domManip(String html, int func) {\r
return domManip(clean(html), func);\r
}\r
return 0;\r
}\r
\r
- private Queue<Function> queue(Element elem, String type, Function data) {\r
- if (elem != null) {\r
- type = type + "queue";\r
- Object q = (Queue) data(elem, type, null);\r
- if (q == null) {\r
- q = data(elem, type, Queue.newInstance());\r
- }\r
- Queue<Function> qq = (Queue<Function>) q;\r
- if (data != null) {\r
- qq.enqueue(data);\r
- }\r
- if (SelectorEngine.eq(type, "__FXqueue") && qq.length() == 1) {\r
- if (data != null) {\r
- data.f(elem);\r
- }\r
- }\r
- return qq;\r
- }\r
- return null;\r
- }\r
-\r
private void removeData(Element item, String name) {\r
if (dataCache == null) {\r
windowData = JavaScriptObject.createObject().cast();\r
}\r
}\r
\r
- private void replacequeue(Element elem, String type, Queue data) {\r
- if (elem != null) {\r
- type = type + "queue";\r
- data(elem, type, data);\r
- }\r
- }\r
-\r
private static native Element window() /*-{\r
return $wnd;\r
}-*/;\r
--- /dev/null
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.query.client;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.NodeList;
+
+/**
+ * Class used in plugins which need a queue system.
+ */
+public abstract class GQueryQueue extends GQuery {
+
+ private static final class Queue<T> extends JavaScriptObject {
+
+ public static Queue<?> newInstance() {
+ return createArray().cast();
+ }
+
+ @SuppressWarnings("unused")
+ protected Queue() {
+ }
+
+ public native T dequeue() /*-{
+ return this.shift();
+ }-*/;
+
+ public native void enqueue(T foo) /*-{
+ this.push(foo);
+ }-*/;
+
+ public native int length() /*-{
+ return this.length;
+ }-*/;
+
+ public native T peek(int i) /*-{
+ return this[i];
+ }-*/;
+ }
+
+ public GQueryQueue(Element element) {
+ super(element);
+ }
+
+ public GQueryQueue(JSArray elements) {
+ super(elements);
+ }
+
+ public GQueryQueue(NodeList<Element> list) {
+ 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.
+ */
+ public GQueryQueue dequeue(String type) {
+ for (Element e : elements()) {
+ dequeue(e, type);
+ }
+ 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
+ * functions).
+ */
+ public Queue<Function> 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 data) {
+ for (Element e : elements()) {
+ queue(e, type, data);
+ }
+ return this;
+ }
+
+ /**
+ * Replaces the current queue with the given queue on all matched elements.
+ */
+ public GQueryQueue queue(String type, Queue<?> data) {
+ for (Element e : elements()) {
+ replacequeue(e, type, data);
+ }
+ return this;
+ }
+
+ private void dequeue(Element elem, String type) {
+ Queue<Function> q = queue(elem, type, null);
+
+ if (q != null) {
+ Function f = q.dequeue();
+
+ if (SelectorEngine.eq(type, "__FX")) {
+ f = q.peek(0);
+ }
+ if (f != null) {
+ f.f(elem);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ 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());
+ }
+ if (data != null) {
+ qq.enqueue(data);
+ }
+ if (SelectorEngine.eq(type, "__FXqueue") && qq.length() == 1) {
+ if (data != null) {
+ data.f(elem);
+ }
+ }
+ return qq;
+ }
+ return null;
+ }
+
+ private void replacequeue(Element elem, String type, Queue<?> data) {
+ if (elem != null) {
+ type = type + "queue";
+ data(elem, type, data);
+ }
+ }
+}
LazyEffects animate(Properties properties, int speed, Effects.Easing easing,
Function complete);
+ GQueryQueue dequeue();
+
+ GQueryQueue dequeue(String type);
+
LazyEffects fadeIn();
LazyEffects fadeIn(Effects.Speed speed);
- LazyEffects fadeIn(int speed);
-
LazyEffects fadeIn(Effects.Speed speed, Function callback);
+ LazyEffects fadeIn(int speed);
+
LazyEffects fadeIn(int speed, Function callback);
LazyEffects fadeOut();
LazyEffects fadeOut(Effects.Speed speed);
- LazyEffects fadeOut(int speed);
-
LazyEffects fadeOut(Effects.Speed speed, Function callback);
+ LazyEffects fadeOut(int speed);
+
LazyEffects fadeOut(int speed, Function callback);
LazyEffects fadeTo(Effects.Speed speed, double opacity);
LazyEffects hide();
+ GQueryQueue queue(Function data);
+
+ GQueryQueue queue(String type, Function data);
+
LazyEffects show();
LazyEffects slideDown();
*/
LazyGQuery<T> dblclick(Function... f);
- /**
- * Removes a queued function from the front of the queue and executes it.
- */
- LazyGQuery<T> dequeue(String type);
-
- /**
- * Removes a queued function from the front of the FX queue and executes it.
- */
- LazyGQuery<T> dequeue();
-
/**
* Run one or more Functions over each element of the GQuery. You have to
* override one of these funcions: public void f(Element e) public String
*/
LazyGQuery<T> prevAll();
- /**
- * Adds a new function, to be executed, onto the end of the queue of all
- * matched elements.
- */
- LazyGQuery<T> queue(String type, Function data);
-
- /**
- * Adds a new function, to be executed, onto the end of the queue of all
- * matched elements in the FX queue.
- */
- LazyGQuery<T> queue(Function data);
-
/**
* Removes all matched elements from the DOM.
*/