wrapperMap.put("col", new TagWrapper(2, "<table><tbody></tbody><colgroup>",
"</colgroup></table>"));
wrapperMap.put("area", new TagWrapper(1, "<map>", "</map>"));
-
}
private static GQuery innerHtml(String html, Document doc) {
return engine;
}
- private static native void scrollIntoViewImpl(Node n) /*-{
+ private static native void scrollIntoViewImpl(Node n)
+ /*-{
+
if (n)
n.scrollIntoView()
}-*/;
- private static native void setElementValue(Element e, String value) /*-{
+ private static native void setElementValue(Element e, String value)
+ /*-{
+
e.value = value;
}-*/;
}
return $(unique(result));
-
}
/**
return end();
}
- private native Element getPreviousSiblingElement(Element elem) /*-{
+ private native Element getPreviousSiblingElement(Element elem)
+ /*-{
+
var sib = elem.previousSibling;
while (sib && sib.nodeType != 1)
sib = sib.previousSibling;
$(el).remove();
}
return this;
-
}
/**
* everything else.
*/
LazyGQuery<T> wrapInner(String html);
-
}
return this.<JsCache>cast();
}
- public final native Properties cloneProps() /*-{
+ public final native Properties cloneProps()
+ /*-{
+
var props = {};
for(p in this) {
props[p] = this[p];
* Its useful for exporting or importing to javascript.
*
*/
- public final native <T> void setFunction(T name, Function f) /*-{
+ public final native <T> void setFunction(T name, Function f)
+ /*-{
+
if (!f) return;
this[name] = function() {
f.@com.google.gwt.query.client.Function::fe(Ljava/lang/Object;)(arguments);
};
public abstract String getCssName();
-
}
private static final String CSS_PROPERTY = "backgroundAttachment";
RIGHT_TOP = new BackgroundPosition(RIGHT_VALUE + " " + TOP_VALUE);
TOP = new BackgroundPosition(TOP_VALUE);
BOTTOM = new BackgroundPosition(BOTTOM_VALUE);
-
}
/**
public static void init() {
CSS.BORDER_COLLAPSE = new BorderCollapseProperty();
-
}
private BorderCollapseProperty() {
public static void init() {
CSS.BORDER_SPACING = new BorderSpacingProperty();
-
}
private BorderSpacingProperty() {
*/
package com.google.gwt.query.client.css;
-import com.google.gwt.dom.client.Style.VerticalAlign;
-import com.google.gwt.query.client.css.BackgroundAttachmentProperty.BackgroundAttachment;
-import com.google.gwt.query.client.css.BackgroundPositionProperty.BackgroundPosition;
-import com.google.gwt.query.client.css.BackgroundRepeatProperty.BackgroundRepeat;
-import com.google.gwt.query.client.css.BorderCollapseProperty.BorderCollapse;
-import com.google.gwt.query.client.css.BorderSpacingProperty.BorderSpacing;
-import com.google.gwt.query.client.css.BorderWidthProperty.BorderWidth;
-import com.google.gwt.query.client.css.CaptionSideProperty.CaptionSide;
-import com.google.gwt.query.client.css.EmptyCellsProperty.EmptyCells;
-import com.google.gwt.query.client.css.FontVariantProperty.FontVariant;
-import com.google.gwt.query.client.css.ListStylePositionProperty.ListStylePosition;
import com.google.gwt.query.client.css.MarginProperty.ShorthandMarginProperty;
import com.google.gwt.query.client.css.PaddingProperty.ShorthandPaddingProperty;
import com.google.gwt.query.client.css.UnicodeBidiProperty.UnicodeBidi;
WhiteSpaceProperty.init();
WordSpacingProperty.init();
ZIndexProperty.init();
-
}
}
import com.google.gwt.dom.client.Style.HasCssName;
/**
- * Minimal contract for an object defining a css property
+ * Minimal contract for an object defining a css property.
*
*/
public interface HasCssValue extends HasCssName {
*/
public CssSetter with(Length margin) {
return new MultipleValueCssSetter(getCssName(), margin);
-
}
/**
*/
public CssSetter with(Length topAndBottom, Length leftAndRight) {
return new MultipleValueCssSetter(getCssName(), topAndBottom, leftAndRight);
-
}
/**
*/
public CssSetter with(Length top, Length leftAndRight, Length bottom) {
return new MultipleValueCssSetter(getCssName(), top, leftAndRight, bottom);
-
}
/**
Length margin4) {
return new MultipleValueCssSetter(getCssName(), margin1, margin2,
margin3, margin4);
-
}
}
*/
public CssSetter with(Length padding) {
return new MultipleValueCssSetter(getCssName(), padding);
-
}
/**
public CssSetter with(Length topAndBottom, Length leftAndRight) {
return new MultipleValueCssSetter(getCssName(), topAndBottom,
leftAndRight);
-
}
/**
*/
public CssSetter with(Length top, Length leftAndRight, Length bottom) {
return new MultipleValueCssSetter(getCssName(), top, leftAndRight, bottom);
-
}
/**
Length padding4) {
return new MultipleValueCssSetter(getCssName(), padding1, padding2,
padding3, padding4);
-
}
}
/**
* Simple implementation of {@link CssSetter} interface. It does its job for the
- * most CSS property
+ * most CSS property.
*
*/
public class SimpleCssSetter implements CssSetter {
public void applyCss(Element e) {
assert e != null : "Impossible to apply css to a null object";
e.getStyle().setProperty(property, value != null ? value : "");
-
}
}
}
CssSetter with(T value);
-
}
/**
* Interface to be implemented by properties which take a integer as defined in
- * css2 specification
+ * css2 specification.
*
* @see http://www.w3.org/TR/CSS21/syndata.html#value-def-number
*/
/**
* Interface to be implemented by properties which take a number as defined in
- * css2 specification
+ * css2 specification.
*
* @see http://www.w3.org/TR/CSS21/syndata.html#value-def-number
*/
* See GWT issue 5548
* http://code.google.com/p/google-web-toolkit/issues/detail?id=5548
*/
- private native String getZIndex(Style s) /*-{
+ private native String getZIndex(Style s)
+ /*-{
+
//force to return a string
return "" + s["zIndex"];
}-*/;
-
}
}
}
- private static native String getAttributeNode(Element e, String name)/*-{
+ private static native String getAttributeNode(Element e, String name)
+ /*-{
+
var attrNode = e.getAttributeNode(name);
if (attrNode && attrNode.nodeValue !== "") {
return attrNode.nodeValue;
}-*/;
private static native boolean setAttributeNode(Element e, String name,
- Object value)/*-{
+ Object value)
+ /*-{
+
var attrNode = e.getAttributeNode(name);
if (attrNode) {
attrNode.nodeValue = value;
*/
private static class ConsoleIe8 extends ConsoleIe9 {
@Override
- protected native void init()/*-{
+ protected native void init()
+ /*-{
+
try {
Function.prototype.call.call($wnd.console.log, $wnd.console, Array.prototype.slice.call(arguments));
this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initialized = true;
init();
}
- protected native void init()/*-{
+ protected native void init()
+ /*-{
+
try {
[ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ]
.forEach(function(method) {
* Default implementation: webkit, opera, FF, ie10
*/
private static class ConsoleImpl {
- public native void clear() /*-{
+ public native void clear()
+ /*-{
+
$wnd.console.clear();
}-*/;
- public native void dir(Object arg) /*-{
+ public native void dir(Object arg)
+ /*-{
+
$wnd.console.dir(arg);
}-*/;
- public native void error(JavaScriptObject arg) /*-{
+ public native void error(JavaScriptObject arg)
+ /*-{
+
$wnd.console.error.apply($wnd.console, arg);
}-*/;
- public native void group(Object arg) /*-{
+ public native void group(Object arg)
+ /*-{
+
$wnd.console.group(arg);
}-*/;
- public native void groupCollapsed(Object arg) /*-{
+ public native void groupCollapsed(Object arg)
+ /*-{
+
$wnd.console.groupCollapsed(arg);
}-*/;
- public native void groupEnd() /*-{
+ public native void groupEnd()
+ /*-{
+
$wnd.console.groupEnd();
}-*/;
- public native void info(JavaScriptObject arg) /*-{
+ public native void info(JavaScriptObject arg)
+ /*-{
+
$wnd.console.info.apply($wnd.console, arg);
}-*/;
- public native void log(JavaScriptObject arg) /*-{
+ public native void log(JavaScriptObject arg)
+ /*-{
+
$wnd.console.log.apply($wnd.console, arg);
}-*/;
- public native void profile(String title) /*-{
+ public native void profile(String title)
+ /*-{
+
$wnd.console.profile(title);
}-*/;
- public native void profileEnd(String title) /*-{
+ public native void profileEnd(String title)
+ /*-{
+
$wnd.console.profileEnd(title);
}-*/;
- public native void time(String title) /*-{
+ public native void time(String title)
+ /*-{
+
$wnd.console.time(title);
}-*/;
- public native void timeEnd(String title) /*-{
+ public native void timeEnd(String title)
+ /*-{
+
$wnd.console.timeEnd(title);
}-*/;
- public native void timeStamp(Object arg) /*-{
+ public native void timeStamp(Object arg)
+ /*-{
+
$wnd.console.timeStamp(arg);
}-*/;
- public native void warn(JavaScriptObject arg) /*-{
+ public native void warn(JavaScriptObject arg)
+ /*-{
+
$wnd.console.warn.apply($wnd.console, arg);
}-*/;
}
}
protected native String getComputedStyle(Element elem, String hyphenName,
- String camelName, String pseudo) /*-{
+ String camelName, String pseudo)
+ /*-{
+
try {
var cStyle = $doc.defaultView.getComputedStyle(elem, pseudo);
return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null;
return ret;
}
- public native Document getContentDocument(Node n) /*-{
+ 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) /*-{
+ public native void emptyDocument(Document d)
+ /*-{
+
d.open();
d.write("<head/><body/>");
d.close();
/**
* Remove a style property from an element.
*/
- public native void removeStyleProperty(Element e, String prop) /*-{
+ public native void removeStyleProperty(Element e, String prop)
+ /*-{
+
if (e && e.style && 'removeAttribute' in e)
e.style.removeAttribute(prop);
}-*/;
@Override
protected native String getComputedStyle(Element elem, String hyphenName,
- String camelName, String pseudo) /*-{
+ String camelName, String pseudo)
+ /*-{
+
// code lifted from jQuery
if (!elem.style || !'currentStyle' in elem || !'runtimeStyle' in elem) return null;
var style = elem.style;
* @return a list of matched nodes
*/
NodeList<Element> select(String selector, Node ctx);
-
}
private static DocumentStyleImpl styleImpl;
public static native NodeList<Element> getElementsByClassName(String clazz,
- Node ctx) /*-{
+ Node ctx)
+ /*-{
+
return ctx.getElementsByClassName(clazz);
}-*/;
- public static native Node getNextSibling(Node n) /*-{
+ public static native Node getNextSibling(Node n)
+ /*-{
+
return n.nextSibling || null;
}-*/;
- public static native Node getPreviousSibling(Node n) /*-{
+ public static native Node getPreviousSibling(Node n)
+ /*-{
+
return n.previousSibling || null;
}-*/;
}
public static native NodeList<Element> querySelectorAllImpl(String selector,
- Node ctx) /*-{
+ Node ctx)
+ /*-{
+
return ctx.querySelectorAll(selector);
}-*/;
public static native NodeList<Element> elementsByTagName(String selector,
- Node ctx) /*-{
+ Node ctx)
+ /*-{
+
return ctx.getElementsByTagName(selector);
}-*/;
public static native NodeList<Element> elementsByClassName(String selector,
- Node ctx) /*-{
+ Node ctx)
+ /*-{
+
return ctx.getElementsByClassName(selector);
}-*/;
}
public static native NodeList<Element> xpathEvaluate(String selector,
- Node ctx, JsNodeArray r) /*-{
+ Node ctx, JsNodeArray r)
+ /*-{
+
var node;
var ownerDoc = ctx && (ctx.ownerDocument || ctx );
var evalDoc = ownerDoc ? ownerDoc : $doc;
}
}
- public native boolean contains(Element a, Element b) /*-{
+ public native boolean contains(Element a, Element b)
+ /*-{
+
return a.contains ? a != b && a.contains(b) : !!(a.compareDocumentPosition(b) & 16)
}-*/;
/**
* Check if the browser has native support for css selectors
*/
- public static native boolean hasQuerySelectorAll() /*-{
+ public static native boolean hasQuerySelectorAll()
+ /*-{
+
return $doc.location.href.indexOf("_force_no_native") < 0 &&
typeof $doc.querySelectorAll == 'function';
}-*/;
- public static native boolean hasXpathEvaluate() /*-{
+ public static native boolean hasXpathEvaluate()
+ /*-{
+
return !!$doc.evaluate;
}-*/;
* Base/Utility class for runtime selector engine implementations.
*/
public abstract class SelectorEngineImpl implements HasSelector {
-
}
*/
public class SelectorEngineSizzle extends SelectorEngineImpl {
- public static native void initialize() /*-{
+ public static native void initialize()
+ /*-{
+
(function(){
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
window.GQS = GQS;
$wnd.GQS = GQS;
-
})();
-
}-*/;
- private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
+ private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed)
+ /*-{
+
return $wnd.GQS(selector, context, results, seed);
}-*/;
*/
public class SelectorEngineSizzleIE extends SelectorEngineImpl {
- public static native void initialize() /*-{
+ public static native void initialize()
+ /*-{
+
(function(){
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
window.IES = IES;
$wnd.IES = IES;
-
})();
-
}-*/;
- private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
+ private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed)
+ /*-{
+
return $wnd.IES(selector, context, results, seed);
}-*/;
}
}
- public static native void clearAdded(Node node) /*-{
+ public static native void clearAdded(Node node)
+ /*-{
+
node.added = null;
}-*/;
public static native NodeList<Element> getElementsByClassName(String clazz,
- Node ctx) /*-{
+ Node ctx)
+ /*-{
+
return ctx.getElementsByClassName(clazz);
}-*/;
- public static native boolean isAdded(Node prevRef) /*-{
+ public static native boolean isAdded(Node prevRef)
+ /*-{
+
return prevRef.added || false;
}-*/;
- public static native void setAdded(Node prevRef, boolean added) /*-{
+ public static native void setAdded(Node prevRef, boolean added)
+ /*-{
+
prevRef.added = added;
}-*/;
- public static native void setSkipTag(JsNodeArray prevElem, boolean skip) /*-{
+ public static native void setSkipTag(JsNodeArray prevElem, boolean skip)
+ /*-{
+
prevElem.skipTag = skip;
}-*/;
return JsUtils.truth(attrVal) ? "^" + attrVal + "$" : null;
}
- private static native boolean checked(Node previous) /*-{
+ private static native boolean checked(Node previous)
+ /*-{
+
return previous.checked || false;
}-*/;
}
}
- private static native boolean enabled(Node node) /*-{
+ private static native boolean enabled(Node node)
+ /*-{
+
return !node.disabled;
}-*/;
}
}
- private static native boolean hasChildElms(Node prevParent) /*-{
+ private static native boolean hasChildElms(Node prevParent)
+ /*-{
+
return prevParent.childElms || false;
}-*/;
- private static native boolean isSkipped(JsNodeArray prevElem) /*-{
+ private static native boolean isSkipped(JsNodeArray prevElem)
+ /*-{
+
return prevElem.skipTag || false;
}-*/;
- private static native void setHasChildElms(Node prevParent, boolean bool) /*-{
+ private static native void setHasChildElms(Node prevParent, boolean bool)
+ /*-{
+
prevParent.childElms = bool ? bool : null;
}-*/;
private static native JsNodeArray subtractArray(JsNodeArray previousMatch,
- JsNodeArray elementsByPseudo) /*-{
+ JsNodeArray elementsByPseudo)
+ /*-{
+
for (var i=0, src1; (src1=arr1[i]); i++) {
var found = false;
for (var j=0, src2; (src2=arr2[j]); j++) {
*/
public class SelectorEngineJSIE extends SelectorEngineJS {
- public native String getAttr(Element elm, String attr) /*-{
+ public native String getAttr(Element elm, String attr)
+ /*-{
+
switch (attr) {
case "id":
return elm.id;
* Sizzle CSS Selector Engine v1.0.
*
* It has so many JSNI code, the idea is to make an entire implementation
- * using Java. Right now it performs worse than pure JSNI implementation
+ * using Java. Right now it performs worse than pure JSNI implementation.
*
*/
public class SelectorEngineSizzleGwt extends SelectorEngineImpl {
- public static native boolean contains(Object a, Object b) /*-{
+ public static native boolean contains(Object a, Object b)
+ /*-{
+
var ret =
document.compareDocumentPosition ?
(a.compareDocumentPosition(b) & 16):
return ret ? true : false;
}-*/;
- public static native JavaScriptObject createExpr() /*-{
+ public static native JavaScriptObject createExpr()
+ /*-{
+
var done = 0;
$wnd.Expr = {
order: [ "ID", "NAME", "TAG" ],
return $wnd.Expr;
}-*/;
- public static native void dirCheck(String dir, Object cur, int doneName, Object checkSet) /*-{
+ public static native void dirCheck(String dir, Object cur, int doneName, Object checkSet)
+ /*-{
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
if ( elem ) {
}
}-*/;
- public static native void dirNodeCheck(String dir, Object cur, int doneName, Object checkSet) /*-{
+ public static native void dirNodeCheck(String dir, Object cur, int doneName, Object checkSet)
+ /*-{
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
if ( elem ) {
throw new IllegalArgumentException("Syntax error, unrecognized expression: " + msg);
}
- public static native JsArray<Node> filter(String expr, JsArray<Node> set, boolean inplace, Object not) /*-{
+ public static native JsArray<Node> filter(String expr, JsArray<Node> set, boolean inplace, Object not)
+ /*-{
+
var old = expr, result = [], curLoop = set, match, anyFound;
while ( expr && set.length ) {
for ( var type in $wnd.Expr.filter ) {
return curLoop;
}-*/;
- public static native JavaScriptObject find(String expr, Node context) /*-{
+ public static native JavaScriptObject find(String expr, Node context)
+ /*-{
+
var set, match;
if ( !expr ) {
return [];
return {set: set, expr: expr};
}-*/;
- public static native String getText(Object elems) /*-{
+ public static native String getText(Object elems)
+ /*-{
+
var ret = "", elem;
for ( var i = 0; elems[i]; i++ ) {
elem = elems[i];
return ret;
}-*/;
- public static native JsArray<Node> makeArray(NodeList<Node> array, JsArray<Node> results) /*-{
+ public static native JsArray<Node> makeArray(NodeList<Node> array, JsArray<Node> results)
+ /*-{
+
var ret = results || [];
if ( Object.prototype.toString.call(array) === "[object Array]" ) {
Array.prototype.push.apply( ret, array );
return ret;
}-*/;
- public static native JsArray<Element> posProcess(String selector, Node context) /*-{
+ public static native JsArray<Element> posProcess(String selector, Node context)
+ /*-{
+
var tmpSet = [], later = "", match, root = context.nodeType ? [context] : context;
// Position selectors must be done after the filter
// And so must :not(positional) so we move all PSEUDOs to the end
return @com.google.gwt.query.client.impl.research.SelectorEngineSizzleGwt::filter(Ljava/lang/String;Lcom/google/gwt/core/client/JsArray;ZLjava/lang/Object;)( later, tmpSet, false );
}-*/;
- private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
+ private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed)
+ /*-{
+
results = results || [];
var origContext = context = context || document;
var parts = [], m, set, checkSet, extra, prune = true, soFar = selector;
return xpath;
}
- private native String replaceAttr(String allAttr) /*-{
+ private native String replaceAttr(String allAttr)
+ /*-{
+
if(!allAttr) return "";
return allAttr.replace(/["']+/g,'').replace(/(\w+)(\^|\$|\*|\||~)?=?([\w\u00C0-\uFFFF\s\-_\.]+)?/g,
function(a,b,c,d) {
return @com.google.gwt.query.client.impl.research.SelectorEngineXPath::attrToXPath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)(a,b || "",c || "",d || "");
});
-
}-*/;
- private native String replaceAttr2(String allAttr) /*-{
+ private native String replaceAttr2(String allAttr)
+ /*-{
+
if(!allAttr) return "";
return allAttr.replace(/\[(\w+)(\^|\$|\*|\||~)?=?([\w\u00C0-\uFFFF\s\-_\.]+)?\]/g, @com.google.gwt.query.client.impl.research.SelectorEngineXPath::attrToXPath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;));
}-*/;
return createObject().cast();
}
- public final native void concat(Object ary) /*-{
+ public final native void concat(Object ary)
+ /*-{
+
if (ary) this.concat(ary);
}-*/;
}
}
- public final native void delete(Object name) /*-{
+ public final native void delete(Object name)
+ /*-{
+
delete this[name];
}-*/;
}
}
- public final native boolean exists(Object name) /*-{
+ public final native boolean exists(Object name)
+ /*-{
+
return !!this[name];
}-*/;
return (T)o;
}
- public final native <T> T get(Object id) /*-{
+ public final native <T> T get(Object id)
+ /*-{
+
return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ this && this[id] ]);
}-*/;
return r == null ? 0 : r;
}
- public final native String getString(Object id) /*-{
+ public final native String getString(Object id)
+ /*-{
+
return this[id] == null ? null : String(this[id]);
}-*/;
- public final native JsArrayMixed getArray(Object id) /*-{
+ public final native JsArrayMixed getArray(Object id)
+ /*-{
+
var r = this[id];
if (Object.prototype.toString.call(r) == '[object Array]') {
return r;
return (o != null && o instanceof JavaScriptObject) ? ((JavaScriptObject)o).<T>cast() : null;
}
- public final native boolean isEmpty() /*-{
+ public final native boolean isEmpty()
+ /*-{
+
for (k in this) return false;
return true;
}-*/;
- public final native boolean contains(Object o)/*-{
+ public final native boolean contains(Object o)
+ /*-{
+
return this.indexOf(o) >= 0;
}-*/;
- public final native void remove(Object o) /*-{
+ public final native void remove(Object o)
+ /*-{
+
var i = this.indexOf(o);
if (i >= 0) this.splice(i, 1);
}-*/;
- public final native int indexOf(Object o) /*-{
+ public final native int indexOf(Object o)
+ /*-{
+
// HtmlUnit fails when this returns 0
return this.indexOf(o);
}-*/;
- public final native JsCache putBoolean(Object id, boolean b) /*-{
+ public final native JsCache putBoolean(Object id, boolean b)
+ /*-{
+
this[id] = b;
return this;
}-*/;
- public final native JsCache putNumber(Object id, double n) /*-{
+ public final native JsCache putNumber(Object id, double n)
+ /*-{
+
this[id] = n;
return this;
}-*/;
return this;
}
- public final native JsCache putObject(Object id, Object obj) /*-{
+ public final native JsCache putObject(Object id, Object obj)
+ /*-{
+
this[id] = obj;
return this;
}-*/;
- public final native int length() /*-{
+ public final native int length()
+ /*-{
+
if (typeof(this.length) == 'number')
return this.length;
checkNull(this);
}
- private final native JsArrayString keysImpl() /*-{
+ private final native JsArrayString keysImpl()
+ /*-{
+
var key, keys=[];
// Chrome in DevMode sets '__gwt_ObjectId' to JS objects
// GWT sets '$H' when calling getHashCode (see com/google/gwt/core/client/impl/Impl.java)
*
* Example
* <pre>
- * native Object myMethod() /*-{
+ * native Object myMethod()
+ /*-{
+
* var myJsVar = ... ;
* return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ myJsVar ]);
* }-* /
* </pre>
*
*/
- public static native Object gwtBox(JavaScriptObject oneElementArray) /*-{
+ public static native Object gwtBox(JavaScriptObject oneElementArray)
+ /*-{
+
var r = oneElementArray;
if (typeof r == 'object' && r.length == 1) {
var r = r[0], t = typeof r;
/**
* Invoke the closure with no arguments and expecting no return value.
*/
- public final native void invoke() /*-{
+ public final native void invoke()
+ /*-{
+
return this();
}-*/;
}
return create((Node)null);
}
- public static native JsNodeArray create(Node node) /*-{
+ public static native JsNodeArray create(Node node)
+ /*-{
+
return node ? [node] : [];
}-*/;
@Deprecated
public class JsRegexp {
- public static native JavaScriptObject compile(String pat) /*-{
+ public static native JavaScriptObject compile(String pat)
+ /*-{
+
return new RegExp(pat);
}-*/;
- public static native JavaScriptObject compileFlags(String pat, String flags) /*-{
+ public static native JavaScriptObject compileFlags(String pat, String flags)
+ /*-{
+
return new RegExp(pat, flags);
}-*/;
return new JsRegexp(regexp, flags).match(string);
}
- private static native JsObjectArray<String> exec0(JavaScriptObject regexp, String str) /*-{
+ private static native JsObjectArray<String> exec0(JavaScriptObject regexp, String str)
+ /*-{
+
return regexp.exec(str);
}-*/;
return test0(regexp, rule);
}
- private native JsObjectArray<String> match0(JavaScriptObject regexp, String currentRule)/*-{
+ private native JsObjectArray<String> match0(JavaScriptObject regexp, String currentRule)
+ /*-{
+
return currentRule.match(regexp);
}-*/;
- private native boolean test0(JavaScriptObject regexp, String rule) /*-{
+ private native boolean test0(JavaScriptObject regexp, String rule)
+ /*-{
+
return regexp.test(rule);
}-*/;
return jso.equals(obj);
}
- private native Object exec(JavaScriptObject f, Object data) /*-{
+ private native Object exec(JavaScriptObject f, Object data)
+ /*-{
+
return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ f(data) ]);
}-*/;
* Wraps a GQuery function into a native javascript one so as we can
* export Java methods without using JSNI.
*/
- public static native JavaScriptObject wrapFunction (Function f) /*-{
+ public static native JavaScriptObject wrapFunction (Function f)
+ /*-{
+
return function(r) {
var o = @java.util.ArrayList::new()();
for (i in arguments) {
}-*/;
public static class JsUtilsImpl {
- public native Properties parseJSON(String json) /*-{
+ public native Properties parseJSON(String json)
+ /*-{
+
return $wnd.JSON.parse(json);
}-*/;
- public native String JSON2String(JavaScriptObject o) /*-{
+ public native String JSON2String(JavaScriptObject o)
+ /*-{
+
return $wnd.JSON.stringify(o);
}-*/;
- public native Element parseXML(String xml) /*-{
+ public native Element parseXML(String xml)
+ /*-{
+
return new DOMParser().parseFromString(xml, "text/xml").documentElement;
}-*/;
return ret;
}
- public native String XML2String(JavaScriptObject o) /*-{
+ public native String XML2String(JavaScriptObject o)
+ /*-{
+
return (new XMLSerializer()).serializeToString(o);
}-*/;
}
public static class JsUtilsImplIE6 extends JsUtilsImpl {
- public static final native Properties evalImpl(String properties) /*-{
+ public static final native Properties evalImpl(String properties)
+ /*-{
+
return eval(properties);
}-*/;
}
@Override
- public native Element parseXML(String xml) /*-{
+ public native Element parseXML(String xml)
+ /*-{
+
var d = new ActiveXObject("Microsoft.XmlDom");
d.loadXML(xml);
return d.documentElement;
}
@Override
- public native String XML2String(JavaScriptObject o) /*-{
+ public native String XML2String(JavaScriptObject o)
+ /*-{
+
return o.xml;
}-*/;
- private native String xmlText(Element e) /*-{
+ private native String xmlText(Element e)
+ /*-{
+
return e.text;
}-*/;
}
/**
* Camelize style property names. for instance: font-name -> fontName
*/
- public static native String camelize(String s)/*-{
+ public static native String camelize(String s)
+ /*-{
+
return s.replace(/\-(\w)/g, function(all, letter) {
return letter.toUpperCase();
});
/**
* Compare two numbers using javascript equality.
*/
- public static native boolean eq(double s1, double s2) /*-{
+ public static native boolean eq(double s1, double s2)
+ /*-{
+
return s1 == s2;
}-*/;
/**
* Compare two objects using javascript equality.
*/
- public static native boolean eq(Object s1, Object s2) /*-{
+ public static native boolean eq(Object s1, Object s2)
+ /*-{
+
return s1 == s2;
}-*/;
* Check if an object has already a property with name <code>name</code>
* defined.
*/
- public static native boolean hasProperty(JavaScriptObject o, String name)/*-{
+ public static native boolean hasProperty(JavaScriptObject o, String name)
+ /*-{
+
return o && name in o;
}-*/;
* implementation returns an empty string instead of null when the attribute is not
* present
*/
- public static native boolean hasAttribute(Element o, String name)/*-{
+ public static native boolean hasAttribute(Element o, String name)
+ /*-{
+
return !!(o && o.getAttribute(name));
}-*/;
/**
* Hyphenize style property names. for instance: fontName -> font-name
*/
- public static native String hyphenize(String name) /*-{
+ public static native String hyphenize(String name)
+ /*-{
+
return name.replace(/([A-Z])/g, "-$1").toLowerCase();
}-*/;
/**
* Check is a javascript object can be used as an array
*/
- public static native boolean isArray(JavaScriptObject o) /*-{
+ public static native boolean isArray(JavaScriptObject o)
+ /*-{
+
return Object.prototype.toString.call(o) == '[object Array]'
|| typeof o.length == 'number';
}-*/;
/**
* Check is a javascript object is a FormData
*/
- public static native boolean isFormData(JavaScriptObject o) /*-{
+ public static native boolean isFormData(JavaScriptObject o)
+ /*-{
+
return Object.prototype.toString.call(o) == '[object FormData]';
}-*/;
/**
* Return whether the event was prevented
*/
- public static native boolean isDefaultPrevented(JavaScriptObject e)/*-{
+ public static native boolean isDefaultPrevented(JavaScriptObject e)
+ /*-{
+
return e.defaultPrevented || e.returnValue === false || e.getPreventDefault
&& e.getPreventDefault() ? true : false;
}-*/;
/**
* Check is a javascript object can be cast to an Element
*/
- public static native boolean isElement(Object o) /*-{
+ public static native boolean isElement(Object o)
+ /*-{
+
return o && o.nodeType && o.nodeName ? true : false;
}-*/;
/**
* Check is a javascript object is a function
*/
- public static native boolean isFunction(JavaScriptObject o) /*-{
+ public static native boolean isFunction(JavaScriptObject o)
+ /*-{
+
return Object.prototype.toString.call(o) == '[object Function]';
}-*/;
/**
* Check is a javascript can be cast to a node list
*/
- public static native boolean isNodeList(JavaScriptObject o) /*-{
+ public static native boolean isNodeList(JavaScriptObject o)
+ /*-{
+
var r = Object.prototype.toString.call(o);
return r == '[object HTMLCollection]' || r == '[object NodeList]'
|| (typeof o == 'object' && o.length && o[0].tagName) ? true : false;
/**
* Return the element which is truth in the double scope.
*/
- public static native double or(double s1, double s2) /*-{
+ public static native double or(double s1, double s2)
+ /*-{
+
return s1 || s2;
}-*/;
/**
* Return the element which is truth in the javascript scope.
*/
- public static native <T> T or(T s1, T s2) /*-{
+ public static native <T> T or(T s1, T s2)
+ /*-{
+
return s1 || s2;
}-*/;
* Utility method to cast objects in production.
* Useful for casting native implementations to interfaces like JsInterop
*/
- public static native <T> T cast(Object o) /*-{
+ public static native <T> T cast(Object o)
+ /*-{
+
return o;
}-*/;
/**
* Utility method to cast objects to array of string in production.
*/
- public static native String[] castArrayString(Object a)/*-{
+ public static native String[] castArrayString(Object a)
+ /*-{
+
return a
}-*/;
return runJavascriptFunctionImpl(o, meth, JsObjectArray.create().add(args).<JsArrayMixed>cast());
}
- private static native <T> T runJavascriptFunctionImpl(JavaScriptObject o, String meth, JsArrayMixed args) /*-{
+ private static native <T> T runJavascriptFunctionImpl(JavaScriptObject o, String meth, JsArrayMixed args)
+ /*-{
+
return (f = o && o[meth])
&& @com.google.gwt.query.client.js.JsUtils::isFunction(*)(f)
&& @com.google.gwt.query.client.js.JsCache::gwtBox(*)([f.apply(o, args)]);
/**
* Check if a number is true in the javascript scope.
*/
- public static native boolean truth(double a) /*-{
+ public static native boolean truth(double a)
+ /*-{
+
return a ? true : false;
}-*/;
/**
* Check if an object is true in the javascript scope.
*/
- public static native boolean truth(Object a) /*-{
+ public static native boolean truth(Object a)
+ /*-{
+
return a ? true : false;
}-*/;
public GQuery live(int eventbits, final Object data, Function... funcs) {
return live(eventbits, null, data, funcs);
-
}
public GQuery live(int eventbits, String nameSpace, final Object data, Function... funcs) {
EventsListener.getInstance(Element.is(currentContext) ? (Element) currentContext : body).live(
eventbits, nameSpace, null, null, currentSelector, data, funcs);
return this;
-
}
public GQuery live(String eventName, final Object data, Function... funcs) {
}
return bind("mouseleave", null, fs);
-
}
/**
* layout of the page.
*/
LazyEffects<T> toggle(int millisecs, Function... f);
-
}
LazyEvents<T> unbind(String name, Function f);
LazyEvents<T> undelegate();
-
}
*
*/
LazyWidgets<T> textArea(WidgetInitializer<TextArea> initializers);
-
}
package com.google.gwt.query.client.plugins;
/**
- * Object use to configure a Plugin extending {@link MousePlugin}
+ * Object use to configure a Plugin extending {@link MousePlugin}.
*
*/
public class MouseOptions {
return true;
}
return mouseDown(e, GqEvent.create(event));
-
}
}).bind(Event.ONTOUCHSTART, getPluginName(), (Object) null, new Function() {
public boolean f(com.google.gwt.user.client.Event event) {
touchSupported = true;
return mouseDown(e, GqEvent.create(event));
-
}
}).bind(Event.ONCLICK, getPluginName(), (Object) null, new Function() {
@Override
}
return true;
-
}
private void bindOtherEvents(final Element element) {
return false;
}
});
-
}
}
return mouseDistance >= neededDistance;
}
- private native boolean isEventAlreadyHandled(GqEvent event)/*-{
+ private native boolean isEventAlreadyHandled(GqEvent event)
+ /*-{
+
var result = event.mouseHandled ? event.mouseHandled : false;
return result;
}-*/;
- private native void markEventAsHandled(GqEvent event)/*-{
+ private native void markEventAsHandled(GqEvent event)
+ /*-{
+
event.mouseHandled = true;
}-*/;
}
return isNotBoutonLeft || isElementCancel || !mouseCapture(element, mouseDownEvent);
-
}
private void reset(GqEvent nativeEvent) {
/**
* GWT clone of jQueryUi-core. This class define some function present in the
- * jQuery-ui core and not directly in jQuery
+ * jQuery-ui core and not directly in jQuery.
*
*/
public class UiPlugin extends GQuery {
&& isOverflowEnabled($e);
}
});
-
} else {
scrollParent = gQueryUi.parents().filter(new Predicate() {
}
return scrollParent.length() > 0 ? $(scrollParent.get(0))
: $(getViewportElement());
-
}
protected boolean scrollParentPositionTest(UiPlugin gQueryUi) {
/**
* Using violator pattern to execute private method
*/
- private native void fireOnResponseReceivedVltr(Request rq, RequestCallback cb) /*-{
+ private native void fireOnResponseReceivedVltr(Request rq, RequestCallback cb)
+ /*-{
+
rq.@com.google.gwt.http.client.Request::fireOnResponseReceived(Lcom/google/gwt/http/client/RequestCallback;)(cb);
}-*/;
/**
* Using violator pattern to use protected constructor
*/
- private native Request createRequestVltr(XMLHttpRequest rq, int ms, RequestCallback cb) /*-{
+ private native Request createRequestVltr(XMLHttpRequest rq, int ms, RequestCallback cb)
+ /*-{
+
return @com.google.gwt.http.client.Request::new(Lcom/google/gwt/xhr/client/XMLHttpRequest;ILcom/google/gwt/http/client/RequestCallback;)(rq,ms,cb);
}-*/;
}
}
// Using jsni because method send in JsonpRequestBuilder is private
- private final native void send(JsonpRequestBuilder bld, String url, AsyncCallback<?> cb) /*-{
+ private final native void send(JsonpRequestBuilder bld, String url, AsyncCallback<?> cb)
+ /*-{
+
bld.@com.google.gwt.jsonp.client.JsonpRequestBuilder::send(Ljava/lang/String;Lcom/google/gwt/user/client/rpc/AsyncCallback;Z)(url,cb,false);
}-*/;
}
color += color;
}
result[i] = Math.max(0, Math.min(255, Integer.parseInt(color, 16)));
-
}
return result;
/**
* Transitions and transformation plugin for gQuery.
*
- * It is inspired on jquery.transit (http://github.com/rstacruz/jquery.transit)
+ * It is inspired on jquery.transit (http://github.com/rstacruz/jquery.transit).
*
* Usage examples:
* <pre>
* This class implements an event queue instance for one Element. The queue instance is configured
* as the default event listener in GWT.
*
- * The reference to this queue is stored as a unique variable in the element's DOM
+ * The reference to this queue is stored as a unique variable in the element's DOM.
*
* The class takes care of calling the appropriate functions for each browser event and it also
* calls sinkEvents method.
}
}
- private static native void cleanGQListeners(Element elem) /*-{
+ private static native void cleanGQListeners(Element elem)
+ /*-{
+
if (elem.__gwtlistener) {
@com.google.gwt.user.client.DOM::setEventListener(*)(elem, elem.__gwtlistener);
}
elem.__gwtlistener = elem.__gqueryevent = elem.__gquery = null;
}-*/;
- private static native EventsListener getGQueryEventListener(Element elem) /*-{
+ private static native EventsListener getGQueryEventListener(Element elem)
+ /*-{
+
return elem.__gqueryevent;
}-*/;
- private static native EventListener getGwtEventListener(Element elem) /*-{
+ private static native EventListener getGwtEventListener(Element elem)
+ /*-{
+
return elem.__gwtlistener;
}-*/;
- private static native void init(Element elem, EventsListener gqevent)/*-{
+ private static native void init(Element elem, EventsListener gqevent)
+ /*-{
+
elem.__gwtlistener = @com.google.gwt.user.client.DOM::getEventListener(*)(elem);
elem.__gqueryevent = gqevent;
// Someone has reported that in IE the init can be called multiple times
if (elem.__gwtlistener == gqevent) elem.__gwtlistener = null;
}-*/;
- private static native void sinkBitlessEvent(Element elem, String name) /*-{
+ private static native void sinkBitlessEvent(Element elem, String name)
+ /*-{
+
if (!elem.__gquery)
elem.__gquery = [];
if (elem.__gquery[name])
newList.add(listener);
}
elementEvents = newList;
-
}
private boolean isNullOrEmpty(String s) {
}
DOM.sinkEvents((com.google.gwt.user.client.Element) element, eventBits
| DOM.getEventsSunk((com.google.gwt.user.client.Element) element));
-
} else {
sinkBitlessEvent(element, eventName);
}
*/
public class GqEvent extends Event {
- public static native void setOriginalEventType(NativeEvent evt, String originalEventName)/*-{
+ public static native void setOriginalEventType(NativeEvent evt, String originalEventName)
+ /*-{
+
evt["__gwtquery_originalEventName"] = originalEventName;
}-*/;
- public static native String getOriginalEventType(Event evt)/*-{
+ public static native String getOriginalEventType(Event evt)
+ /*-{
+
return evt["__gwtquery_originalEventName"] || null;
}-*/;
}
private static native void copy(
- Event originalEvent, GqEvent gQueryEvent) /*-{
+ Event originalEvent, GqEvent gQueryEvent)
+ /*-{
+
for ( var field in originalEvent) {
gQueryEvent[field] = originalEvent[field];
}
/**
* Return the original event (the one created by the browser)
*/
- public final native Event getOriginalEvent()/*-{
+ public final native Event getOriginalEvent()
+ /*-{
+
return this.originalEvent;
}-*/;
- public final native void setCurrentElementTarget(Element e)/*-{
+ public final native void setCurrentElementTarget(Element e)
+ /*-{
+
this.currentTarget = e;
//ie don't have a currentEventTarget field on event
/**
* use jsni to access private attribute
*/
- private native void setElementImpl(Element e)/*-{
+ private native void setElementImpl(Element e)
+ /*-{
+
this.@com.google.gwt.user.client.ui.UIObject::element = e;
}-*/;
}
adopt(w);
-
}
}
regExp.append(")$");
return e.getTagName().toUpperCase().matches(regExp.toString());
-
}
/**
newElement.setId(oldElement.getId());
//ensure no duplicate id
oldElement.setId("");
-
}
}
return $(element).parents().widget();
}
- private static native void widgetOnAttach(Widget w) /*-{
+ private static native void widgetOnAttach(Widget w)
+ /*-{
+
w.@com.google.gwt.user.client.ui.Widget::onAttach()();
}-*/;
- private static native void widgetSetParent(Widget w, Widget p) /*-{
+ private static native void widgetSetParent(Widget w, Widget p)
+ /*-{
+
w.@com.google.gwt.user.client.ui.Widget::setParent(Lcom/google/gwt/user/client/ui/Widget;)(p);
}-*/;
- private static native Widget compositeGetWidget(Composite w) /*-{
+ private static native Widget compositeGetWidget(Composite w)
+ /*-{
+
return w.@com.google.gwt.user.client.ui.Composite::getWidget()();
}-*/;
- private static native WidgetCollection complexPanelGetChildren(ComplexPanel w) /*-{
+ private static native WidgetCollection complexPanelGetChildren(ComplexPanel w)
+ /*-{
+
return w.@com.google.gwt.user.client.ui.ComplexPanel::getChildren()();
}-*/;
}
"GQuery IFrameWithDocTypeLinker is deprecated, remove <add-linker name=\"stddoctype\"/> from your module file");
return DOCTYPE
+ super.getModulePrefix(logger, context, strongName, numFragments);
-
}
}