package gwtquery.client;\r
\r
import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.core.client.JavaScriptObject;\r
import com.google.gwt.dom.client.ButtonElement;\r
import com.google.gwt.dom.client.Document;\r
import com.google.gwt.dom.client.Element;\r
import com.google.gwt.dom.client.InputElement;\r
+import com.google.gwt.dom.client.NativeEvent;\r
import com.google.gwt.dom.client.Node;\r
import com.google.gwt.dom.client.NodeList;\r
import com.google.gwt.dom.client.OptionElement;\r
import com.google.gwt.dom.client.SelectElement;\r
+import com.google.gwt.dom.client.Style;\r
import com.google.gwt.dom.client.TextAreaElement;\r
import com.google.gwt.user.client.DOM;\r
import com.google.gwt.user.client.Event;\r
import java.util.HashMap;\r
import java.util.Map;\r
\r
+import gwtquery.client.impl.DocumentStyleImpl;\r
+\r
/**\r
*\r
*/\r
}\r
}\r
\r
+ private static class DataCache extends JavaScriptObject {\r
+\r
+ protected DataCache() {\r
+ }\r
+\r
+ public native void delete(String name) /*-{\r
+ delete this[name];\r
+ }-*/;\r
+\r
+ public native void delete(int name) /*-{\r
+ delete this[name];\r
+ }-*/;\r
+\r
+ public native boolean exists(int id) /*-{\r
+ return !!this[id];\r
+ }-*/;\r
+\r
+ public native JavaScriptObject get(String id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native JavaScriptObject get(int id) /*-{\r
+ return this[id];\r
+ }-*/; /*-{\r
+ delete this[name];\r
+ }-*/\r
+\r
+ public DataCache getCache(int id) {\r
+ return get(id).cast();\r
+ }\r
+\r
+ public native double getDouble(String id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native double getDouble(int id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native int getInt(String id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native int getInt(int id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native String getString(String id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native String getString(int id) /*-{\r
+ return this[id];\r
+ }-*/;\r
+\r
+ public native boolean isEmpty() /*-{\r
+ var foo = "";\r
+ for(foo in this) break;\r
+ return !foo;\r
+ }-*/;\r
+\r
+ public native void put(String id, Object obj) /*-{\r
+ return this[id]=obj;\r
+ }-*/;\r
+\r
+ public native void put(int id, Object obj) /*-{\r
+ return this[id]=obj;\r
+ }-*/;\r
+ }\r
+\r
+ private static class FastSet extends JavaScriptObject {\r
+\r
+ public static FastSet create() {\r
+ return JavaScriptObject.createObject().cast();\r
+ }\r
+\r
+ protected FastSet() {\r
+ }\r
+\r
+ public void add(Object o) {\r
+ add0(o.hashCode());\r
+ }\r
+\r
+ public boolean contains(Object o) {\r
+ return contains0(o.hashCode());\r
+ }\r
+\r
+ public void remove(Object o) {\r
+ remove0(o.hashCode());\r
+ }\r
+\r
+ private native void add0(int hc) /*-{\r
+ this[hc]=true;\r
+ }-*/;\r
+\r
+ private native boolean contains0(int hc) /*-{\r
+ return this[hc];\r
+ }-*/;\r
+\r
+ private native void remove0(int hc) /*-{\r
+ delete this[hc];\r
+ }-*/;\r
+ }\r
+\r
+ private static 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
private static Map<Class<? extends GQuery>, Plugin<? extends GQuery>> plugins;\r
\r
+ private static Element windowData = null;\r
+\r
+ private static DataCache dataCache = null;\r
+\r
+ private static DocumentStyleImpl styleImpl;\r
+\r
/**\r
* This function accepts a string containing a CSS selector which is then used\r
* to match a set of elements, or it accepts raw HTML creating a GQuery\r
}\r
\r
public static <T extends GQuery> T $(T gq) {\r
+\r
return gq;\r
}\r
\r
\r
protected NodeList<Element> elements = null;\r
\r
+ private String selector;\r
+\r
+ private GQuery previousObject;\r
+\r
+ public GQuery() {\r
+ elements = JavaScriptObject.createArray().cast();\r
+ }\r
+\r
public GQuery(NodeList<Element> list) {\r
elements = list;\r
}\r
throw new RuntimeException("No plugin registered for class " + plugin);\r
}\r
\r
+ /**\r
+ * Access a property on the first matched element. This method makes it easy\r
+ * to retrieve a property value from the first matched element. If the element\r
+ * does not have an attribute with such a name, undefined is returned.\r
+ * Attributes include title, alt, src, href, width, style, etc.\r
+ */\r
public String attr(String name) {\r
return elements.getItem(0).getAttribute(name);\r
}\r
\r
+ /**\r
+ * Set a single property to a value, on all matched elements.\r
+ */\r
public GQuery attr(String key, String value) {\r
for (Element e : elements()) {\r
e.setAttribute(key, value);\r
return this;\r
}\r
\r
+ /**\r
+ * Set a key/value object as properties to all matched elements.\r
+ */\r
public GQuery attr(Properties properties) {\r
for (Element e : elements()) {\r
for (String name : properties.keys()) {\r
return this;\r
}\r
\r
+ /**\r
+ * Set a single property to a computed value, on all matched elements.\r
+ */\r
+ public GQuery attr(String key, Function closure) {\r
+ for (int i = 0; i < elements.getLength(); i++) {\r
+ Element e = elements.getItem(i);\r
+ e.setAttribute(key, closure.f(e, i));\r
+ }\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Binds a handler to one or more events (like click) for each matched\r
+ * element.\r
+ */\r
public GQuery bind(int eventbits, final Object data, final Function f) {\r
EventListener listener = new EventListener() {\r
public void onBrowserEvent(Event event) {\r
return bind(Event.ONBLUR, null, f);\r
}\r
\r
+ public GQuery blur() {\r
+ return trigger(Document.get().createBlurEvent(), null);\r
+ }\r
+\r
public GQuery change(Function f) {\r
return bind(Event.ONCHANGE, null, f);\r
}\r
\r
+ public GQuery change() {\r
+ return trigger(Document.get().createChangeEvent(), null);\r
+ }\r
+\r
+ /**\r
+ * Get a set of elements containing all of the unique immediate children of\r
+ * each of the matched set of elements. Also note: while parents() will look\r
+ * at all ancestors, children() will only consider immediate child elements.\r
+ */\r
+ public GQuery children() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ allNextSiblingElements(e.getFirstChildElement(), result);\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
+ public GQuery click() {\r
+ return trigger(\r
+ Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false,\r
+ false), null);\r
+ }\r
+\r
+ /**\r
+ * Triggers the click event of each matched element. Causes all of the\r
+ * functions that have been bound to that click event to be executed.\r
+ */\r
public GQuery click(final Function f) {\r
return bind(Event.ONCLICK, null, f);\r
}\r
\r
+ /**\r
+ * Return a style property on the first matched element.\r
+ */\r
public String css(String name) {\r
return elements.getItem(0).getStyle().getProperty(name);\r
}\r
\r
+ /**\r
+ * Set a key/value object as style properties to all matched elements. This is\r
+ * the best way to set several style properties on all matched elements. Be\r
+ * aware, however, that when the key contains a hyphen, such as\r
+ * "background-color," it must either be placed within quotation marks or be\r
+ * written in camel case like so: backgroundColor. As "float" and "class" are\r
+ * reserved words in JavaScript, it's recommended to always surround those\r
+ * terms with quotes. gQuery normalizes the "opacity" property in Internet\r
+ * Explorer.\r
+ */\r
public GQuery css(Properties properties) {\r
for (String property : properties.keys()) {\r
css(property, properties.get(property));\r
return this;\r
}\r
\r
+ /**\r
+ * Set a single style property to a value on all matched elements. If a number\r
+ * is provided, it is automatically converted into a pixel value.\r
+ */\r
public GQuery css(String prop, String val) {\r
for (Element e : elements()) {\r
e.getStyle().setProperty(prop, val);\r
return this;\r
}\r
\r
+ /**\r
+ * Returns value at named data store for the element, as set by data(name,\r
+ * value).\r
+ */\r
+ public Object data(String name) {\r
+ return data(elements.getItem(0), name, null);\r
+ }\r
+\r
+ /**\r
+ * Returns value at named data store for the element, as set by data(name,\r
+ * value) with desired return type.\r
+ *\r
+ * @param clz return type class literal\r
+ */\r
+ public <T> T data(String name, Class<T> clz) {\r
+ return (T) data(elements.getItem(0), name, null);\r
+ }\r
+\r
+ /**\r
+ * Stores the value in the named spot with desired return type.\r
+ */\r
+ public void data(String name, String value) {\r
+ for (Element e : elements()) {\r
+ data(e, name, value);\r
+ }\r
+ }\r
+\r
+ public GQuery dblclick() {\r
+ return trigger(\r
+ Document.get().createDblClickEvent(0, 0, 0, 0, 0, false, false, false,\r
+ false), null);\r
+ }\r
+\r
public GQuery dblclick(Function f) {\r
return bind(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
*/\r
return asArray(elements);\r
}\r
\r
+ /**\r
+ * Revert the most recent 'destructive' operation, changing the set of matched\r
+ * elements to its previous state (right before the destructive operation).\r
+ */\r
+ public GQuery end() {\r
+ return previousObject != null ? previousObject : new GQuery();\r
+ }\r
+\r
/**\r
* Reduce GQuery to element in the specified position.\r
*/\r
return $(elements.getItem(pos));\r
}\r
\r
+ public GQuery error() {\r
+ return trigger(Document.get().createErrorEvent(), null);\r
+ }\r
+\r
public GQuery error(Function f) {\r
return bind(Event.ONERROR, null, f);\r
}\r
\r
+ /**\r
+ * Removes all elements from the set of matched elements that do not match the\r
+ * specified function. The function is called with a context equal to the\r
+ * current element. If the function returns false, then the element is removed\r
+ * - anything else and the element is kept.\r
+ */\r
+ public GQuery filter(Predicate filterFn) {\r
+ JSArray result = JSArray.create();\r
+ for (int i = 0; i < elements.getLength(); i++) {\r
+ Element e = elements.getItem(i);\r
+ if (filterFn.f(e, i)) {\r
+ result.addNode(e);\r
+ }\r
+ }\r
+ return pushStack(result, "filter", selector);\r
+ }\r
+\r
+ public GQuery focus() {\r
+ return trigger(Document.get().createFocusEvent(), null);\r
+ }\r
+\r
public GQuery focus(Function f) {\r
return bind(Event.ONFOCUS, null, f);\r
}\r
return elements.getItem(i);\r
}\r
\r
+ public GQuery getPreviousObject() {\r
+ return previousObject;\r
+ }\r
+\r
+ public String getSelector() {\r
+ return selector;\r
+ }\r
+\r
/**\r
* Returns true any of the specified classes are present on any of the matched\r
* elements.\r
return -1;\r
}\r
\r
+ public GQuery keydown() {\r
+ return trigger(\r
+ Document.get().createKeyDownEvent(false, false, false, false, 0, 0),\r
+ null);\r
+ }\r
+\r
public GQuery keydown(Function f) {\r
return bind(Event.ONKEYDOWN, null, f);\r
}\r
\r
+ public GQuery keypress() {\r
+ return trigger(\r
+ Document.get().createKeyPressEvent(false, false, false, false, 0, 0),\r
+ null);\r
+ }\r
+\r
public GQuery keypressed(Function f) {\r
return bind(Event.ONKEYPRESS, null, f);\r
}\r
\r
+ public GQuery keyup() {\r
+ return trigger(\r
+ Document.get().createKeyUpEvent(false, false, false, false, 0, 0),\r
+ null);\r
+ }\r
+\r
public GQuery keyup(Function f) {\r
return bind(Event.ONKEYUP, null, f);\r
}\r
return bind(Event.ONMOUSEUP, null, f);\r
}\r
\r
+ /**\r
+ * Get a set of elements containing the unique next siblings of each of the\r
+ * given set of elements. next only returns the very next sibling for each\r
+ * element, not all next siblings see {#nextAll}.\r
+ */\r
+ public GQuery next() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ Element next = e.getNextSiblingElement();\r
+ if (next != null) {\r
+ result.addNode(next);\r
+ }\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
+ /**\r
+ * Find all sibling elements after the current element.\r
+ */\r
+ public GQuery nextAll() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ allNextSiblingElements(e.getNextSiblingElement(), result);\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
public Offset offset() {\r
return new Offset(get(0).getOffsetLeft(), get(0).getOffsetTop());\r
}\r
\r
+ /**\r
+ * Returns a jQuery collection with the positioned parent of the first matched\r
+ * element. This is the first parent of the element that has position (as in\r
+ * relative or absolute). This method only works with visible elements.\r
+ */\r
+ public GQuery offsetParent() {\r
+ Element offParent = SelectorEngine\r
+ .or(elements.getItem(0).getOffsetParent(), Document.get().getBody());\r
+ while (offParent != null && !"body".equalsIgnoreCase(offParent.getTagName())\r
+ && !"html".equalsIgnoreCase(offParent.getTagName()) && "static"\r
+ .equals(curCSS(offParent, "position"))) {\r
+ offParent = offParent.getOffsetParent();\r
+ }\r
+ return new GQuery(offParent);\r
+ }\r
+\r
+ /**\r
+ * Get a set of elements containing the unique parents of the matched set of\r
+ * elements.\r
+ */\r
+ public GQuery parent() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ result.addNode(e.getParentElement());\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
+ /**\r
+ * Get a set of elements containing the unique ancestors of the matched set of\r
+ * elements (except for the root element).\r
+ */\r
+ public GQuery parents() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ Node par = e.getParentNode();\r
+ while (par != null && par != Document.get()) {\r
+ result.addNode(par);\r
+ par = par.getParentNode();\r
+ }\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
+ /**\r
+ * Get a set of elements containing the unique previous siblings of each of\r
+ * the matched set of elements. Only the immediately previous sibling is\r
+ * returned, not all previous siblings.\r
+ */\r
+ public GQuery prev() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ Element next = getPreviousSiblingElement(e);\r
+ if (next != null) {\r
+ result.addNode(next);\r
+ }\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
+ /**\r
+ * Find all sibling elements in front of the current element.\r
+ */\r
+ public GQuery prevAll() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ allPreviousSiblingElements(getPreviousSiblingElement(e), result);\r
+ }\r
+ return new GQuery(unique(result));\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
* Remove the named attribute from every element in the matched set.\r
*/\r
return this;\r
}\r
\r
+ /**\r
+ * Removes named data store from an element.\r
+ */\r
+ public GQuery removeData(String name) {\r
+ for (Element e : elements()) {\r
+ removeData(e, name);\r
+ }\r
+ return this;\r
+ }\r
+\r
public GQuery scroll(Function f) {\r
return bind(Event.ONSCROLL, null, f);\r
}\r
\r
+ public GQuery select() {\r
+ return trigger(Document.get().createHtmlEvent("select", false, false),\r
+ null);\r
+ }\r
+ \r
+ public void setPreviousObject(GQuery previousObject) {\r
+ this.previousObject = previousObject;\r
+ }\r
+\r
+ public void setSelector(String selector) {\r
+ this.selector = selector;\r
+ }\r
+\r
+ /**\r
+ * Get a set of elements containing all of the unique siblings of each of the\r
+ * matched set of elements.\r
+ */\r
+ public GQuery siblings() {\r
+ JSArray result = JSArray.create();\r
+ for (Element e : elements()) {\r
+ allNextSiblingElements(e.getParentElement().getFirstChildElement(),\r
+ result);\r
+ }\r
+ return new GQuery(unique(result));\r
+ }\r
+\r
/**\r
* Return the number of elements in the matched set.\r
*/\r
return elements.getLength();\r
}\r
\r
+ /**\r
+ * Selects a subset of the matched elements.\r
+ */\r
public GQuery slice(int start, int end) {\r
JSArray slice = JSArray.create();\r
if (end == -1 || end > elements.getLength()) {\r
return new GQuery(slice);\r
}\r
\r
+ public GQuery submit() {\r
+ return trigger(Document.get().createHtmlEvent("submit", false, false),\r
+ null);\r
+ }\r
+\r
/**\r
* Return the text contained in the first matched element.\r
*/\r
return this;\r
}\r
\r
+ /**\r
+ * Adds or removes the specified classes to each matched element.\r
+ */\r
+ public GQuery toggleClass(String clz, boolean sw) {\r
+ for (Element e : elements()) {\r
+ setStyleName(e, clz, sw);\r
+ }\r
+ return this;\r
+ }\r
+\r
+ /**\r
+ * Remove all duplicate elements from an array of elements. Note that this\r
+ * only works on arrays of DOM elements, not strings or numbers.\r
+ */\r
+ public JSArray unique(JSArray result) {\r
+ FastSet f = FastSet.create();\r
+ JSArray ret = JSArray.create();\r
+ for (int i = 0; i < result.getLength(); i++) {\r
+ Element e = result.getElement(i);\r
+ if (!f.contains(e)) {\r
+ f.add(e);\r
+ ret.addNode(e);\r
+ }\r
+ }\r
+ return ret;\r
+ }\r
+\r
/**\r
* Get the content of the value attribute of the first matched element,\r
* returns more than one value if it is a multiple select.\r
return this;\r
}\r
\r
+ protected GQuery pushStack(JSArray elts, String name, String selector) {\r
+ GQuery g = new GQuery(elts);\r
+ g.setPreviousObject(this);\r
+ g.setSelector(selector);\r
+ return g;\r
+ }\r
+\r
+ private void allNextSiblingElements(Element firstChildElement,\r
+ JSArray result) {\r
+ while (firstChildElement != null) {\r
+ result.addNode(firstChildElement);\r
+ firstChildElement = firstChildElement.getNextSiblingElement();\r
+ }\r
+ }\r
+\r
+ private void allPreviousSiblingElements(Element firstChildElement,\r
+ JSArray result) {\r
+ while (firstChildElement != null) {\r
+ result.addNode(firstChildElement);\r
+ firstChildElement = getPreviousSiblingElement(firstChildElement);\r
+ }\r
+ }\r
+\r
+ private String curCSS(Element elem, String name) {\r
+ Style s = elem.getStyle();\r
+ ensureStyleImpl();\r
+ name = styleImpl.getPropertyName(name);\r
+\r
+ if (SelectorEngine.truth(s.getProperty(name))) {\r
+ return s.getProperty(name);\r
+ }\r
+ return styleImpl.getCurrentStyle(elem, name);\r
+ }\r
+\r
+ private <S> Object data(Element item, String name, S value) {\r
+ if (dataCache == null) {\r
+ windowData = JavaScriptObject.createObject().cast();\r
+ dataCache = JavaScriptObject.createObject().cast();\r
+ }\r
+ item = item == window() ? windowData : item;\r
+ int id = item.hashCode();\r
+ if (name != null && !dataCache.exists(id)) {\r
+ dataCache.put(id, DataCache.createObject().cast());\r
+ }\r
+\r
+ DataCache d = dataCache.get(id).cast();\r
+ if (name != null && value != null) {\r
+ d.put(name, value);\r
+ }\r
+ return name != null ? value : id;\r
+ }\r
+\r
+ private void dequeue(Element elem, String type) {\r
+ Queue<Function> q = queue(elem, type, null);\r
+ Function f = q.dequeue();\r
+\r
+ if (q != null) {\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 void ensureStyleImpl() {\r
+ if (styleImpl != null) {\r
+ styleImpl = GWT.create(DocumentStyleImpl.class);\r
+ }\r
+ }\r
+\r
+ private native Element getPreviousSiblingElement(Element elem) /*-{\r
+ var sib = elem.previousSibling;\r
+ while (sib && sib.nodeType != 1)\r
+ sib = sib.previousSibling;\r
+ return sib;\r
+ }-*/;\r
+\r
private void init(GQuery gQuery) {\r
this.elements = gQuery.elements;\r
}\r
- \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, "__FX") && qq.length() == 1) {\r
+ data.f(elem);\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
+ dataCache = JavaScriptObject.createObject().cast();\r
+ }\r
+ item = item == window() ? windowData : item;\r
+ int id = item.hashCode();\r
+ if (name != null) {\r
+ if (!dataCache.exists(id)) {\r
+ dataCache.getCache(id).delete(name);\r
+ }\r
+ if (dataCache.getCache(id).isEmpty()) {\r
+ removeData(item, null);\r
+ }\r
+ } else {\r
+ dataCache.delete(id);\r
+ }\r
+ }\r
+\r
+ private void replacequeue(Element elem, String type, Queue data) {\r
+ if (elem != null) {\r
+ type = type + "queue";\r
+ Object q = (Queue) data(elem, type, null);\r
+ data(elem, type, data);\r
+ }\r
+ }\r
+\r
+ private GQuery trigger(NativeEvent event, Object o) {\r
+ for (Element e : elements()) {\r
+ e.dispatchEvent(event);\r
+ }\r
+ return this;\r
+ }\r
+\r
+ private native Element window() /*-{\r
+ return $wnd;\r
+ }-*/;\r
}\r