Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2011, The gwtquery team.
*
* 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.plugins;
import com.google.gwt.dom.client.Element;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.user.client.Timer;
import java.util.LinkedList;
import java.util.Queue;
/**
* Class used in plugins which need a queue system.
*/
public class QueuePlugin> extends GQuery {
@SuppressWarnings("rawtypes")
public static final Class Queue = GQuery.registerPlugin(
QueuePlugin.class, new Plugin() {
public QueuePlugin init(GQuery gq) {
return new QueuePlugin(gq);
}
});
protected class DelayFunction extends Function {
private class SimpleTimer extends Timer {
public void run() {
g.each(funcs);
for (Element e: g.elements()) {
dequeueIfNotDoneYet(e, name, DelayFunction.this);
}
}
}
private int delay;
Function[] funcs;
GQuery g;
String name;
public DelayFunction(GQuery gquery, String name, int delayInMilliseconds, Function... f) {
this.g = gquery;
this.delay = delayInMilliseconds;
this.funcs = f;
this.name = name;
}
@Override
public void f() {
new SimpleTimer().schedule(delay);
}
}
public static final String JUMP_TO_END = QueuePlugin.class.getName() + ".StopData";
protected static final String QUEUE_DATA_PREFIX = QueuePlugin.class.getName() + ".Queue-";
protected static String DEFAULT_NAME = QUEUE_DATA_PREFIX + "fx";
protected QueuePlugin(GQuery gq) {
super(gq);
}
/**
* remove all queued functions from the effects queue
*/
public T clearQueue() {
return clearQueue(DEFAULT_NAME);
}
/**
* remove all queued function from the named queue
*/
@SuppressWarnings("unchecked")
public T clearQueue(String name) {
for (Element e : elements()) {
queue(e, name, null).clear();
}
return (T) this;
}
/**
* Add a delay in the effects queue
*/
public T delay(int milliseconds, Function... f) {
return delay(milliseconds, DEFAULT_NAME, f);
}
/**
* Add a delay in the named queue
*/
@SuppressWarnings("unchecked")
public T delay(int milliseconds, String name, Function... funcs) {
queue(name, new DelayFunction(this, name, milliseconds, funcs));
return (T) this;
}
/**
* Removes a queued function from the front of the effects queue and executes it.
*/
public T dequeue() {
return dequeue(DEFAULT_NAME);
}
/**
* Removes a queued function from the front of the named queue and executes it.
*/
@SuppressWarnings("unchecked")
public T dequeue(String name) {
for (Element e : elements()) {
dequeueCurrentAndRunNext(e, name);
}
return (T) this;
}
/**
* Show the number of functions to be executed on the first matched element
* in the effects queue.
*/
public int queue() {
return queue(DEFAULT_NAME);
}
/**
* Show the number of functions to be executed on the first matched element
* in the named queue.
*/
public int queue(String name) {
Queue