* Wrap a GQuery around an existing element, event, node or nodelist.\r
*/\r
public static GQuery $(JavaScriptObject e) {\r
- return JsUtils.isElement(e) ? GQuery.$(e.<Element>cast()) :\r
+ return \r
+ JsUtils.isWindow(e) ? GQuery.$(e.<Element>cast()) :\r
+ JsUtils.isElement(e) ? GQuery.$(e.<Element>cast()) :\r
JsUtils.isEvent(e) ? GQuery.$(e.<Event>cast()) :\r
JsUtils.isNodeList(e) ? GQuery.$(e.<NodeList<Element>>cast()) :\r
- $(); \r
+ $();\r
}\r
\r
/**\r
}\r
}\r
\r
- private static native void emptyDocument(Document d) /*-{\r
- d.open();\r
- d.write("<head/><body/>");\r
- d.close();\r
- }-*/;\r
-\r
/**\r
* Perform an ajax request to the server using GET.\r
*/\r
return attributeImpl;\r
}\r
\r
- private native static Document getContentDocument(Node n) /*-{\r
- var d = n.contentDocument || n.document || n.contentWindow.document;\r
- if (!d.body)\r
- @com.google.gwt.query.client.GQuery::emptyDocument(Lcom/google/gwt/dom/client/Document;)(d);\r
- return d;\r
- }-*/;\r
- \r
/**\r
* Perform an ajax request to the server using POST and\r
* parsing the json response.\r
JsNodeArray result = JsNodeArray.create();\r
for (Element e : elements) {\r
if (JsUtils.isWindow(e) || "iframe".equalsIgnoreCase(e.getTagName())) {\r
- result.addNode(getContentDocument(e));\r
+ result.addNode(styleImpl.getContentDocument(e));\r
} else {\r
NodeList<Node> children = e.getChildNodes();\r
for (int i = 0, l = children.getLength(); i < l; i++) {\r
public GQuery empty() {\r
for (Element e : elements) {\r
if (e.getNodeType() == Element.DOCUMENT_NODE) {\r
- emptyDocument(e.<Document> cast());\r
+ styleImpl.emptyDocument(e.<Document> cast());\r
} else {\r
Node c = e.getFirstChild();\r
while (c != null) {\r
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Node;
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.js.JsNamedArray;
import com.google.gwt.query.client.js.JsRegexp;
import com.google.gwt.query.client.js.JsUtils;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Window;
/**
* A helper class to get computed CSS styles for elements.
* - Otherwise it returns the real computed value.
*/
public double cur(Element elem, String prop, boolean force) {
- if (elem.equals(GQuery.window)) {
+ if (JsUtils.isWindow(elem)) {
if ("width".equals(prop)) {
- return Window.getClientWidth();
+ return getContentDocument(elem).getClientWidth();
}
if ("height".equals(prop)) {
- return Window.getClientHeight();
+ return getContentDocument(elem).getClientHeight();
}
elem = GQuery.body;
}
return ret;
}
+ public native Document getContentDocument(Node n) /*-{
+ var d = n.contentDocument || n.document || n.contentWindow.document;
+ if (!d.body)
+ this.@com.google.gwt.query.client.impl.DocumentStyleImpl::emptyDocument(Lcom/google/gwt/dom/client/Document;)(d);
+ return d;
+ }-*/;
+
+ public native void emptyDocument(Document d) /*-{
+ d.open();
+ d.write("<head/><body/>");
+ d.close();
+ }-*/;
}