diff options
author | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2012-11-07 19:11:44 +0100 |
---|---|---|
committer | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2012-11-07 19:11:44 +0100 |
commit | 1dfacce148279deeaeca092ac8971b13a3c6b61d (patch) | |
tree | 7a2855a382e3436ff378a4cc7e7b5fa693407208 /jsquery | |
parent | 989c9b115ab086f1dfdd8c993523d09b12e0c62c (diff) | |
download | gwtquery-1dfacce148279deeaeca092ac8971b13a3c6b61d.tar.gz gwtquery-1dfacce148279deeaeca092ac8971b13a3c6b61d.zip |
Adding a dollar method to handle any object and route it to the apropriate constructor. Handle js functions and arrays like jquery does
Diffstat (limited to 'jsquery')
-rw-r--r-- | jsquery/src/main/java/com/google/gwt/query/jsquery/client/GQueryOverlay.java | 2 | ||||
-rw-r--r-- | jsquery/src/main/java/com/google/gwt/query/jsquery/client/JsQueryUtils.java | 28 |
2 files changed, 2 insertions, 28 deletions
diff --git a/jsquery/src/main/java/com/google/gwt/query/jsquery/client/GQueryOverlay.java b/jsquery/src/main/java/com/google/gwt/query/jsquery/client/GQueryOverlay.java index e407a89e..a48266c5 100644 --- a/jsquery/src/main/java/com/google/gwt/query/jsquery/client/GQueryOverlay.java +++ b/jsquery/src/main/java/com/google/gwt/query/jsquery/client/GQueryOverlay.java @@ -77,7 +77,7 @@ public class GQueryOverlay implements ExportOverlay<GQuery> { @ExportStaticMethod("$wnd.$") public static GQuery $(Object o) { - return JsQueryUtils.dollar(o); + return GQuery.$(o); } @ExportStaticMethod("$wnd.$") diff --git a/jsquery/src/main/java/com/google/gwt/query/jsquery/client/JsQueryUtils.java b/jsquery/src/main/java/com/google/gwt/query/jsquery/client/JsQueryUtils.java index d5ca8bbc..b84d86b4 100644 --- a/jsquery/src/main/java/com/google/gwt/query/jsquery/client/JsQueryUtils.java +++ b/jsquery/src/main/java/com/google/gwt/query/jsquery/client/JsQueryUtils.java @@ -28,32 +28,6 @@ public abstract class JsQueryUtils { return s; }-*/; - public static GQuery dollar(Object o) { - if (o instanceof String) { - return GQuery.$((String) o); - } else if (o instanceof JavaScriptObject) { - JavaScriptObject jso = (JavaScriptObject) o; - if (JsUtils.isFunction(jso)) { - new JsUtils.JsFunction(jso).fe(); - } else { - GQuery r = GQuery.$(jso); - if (!JsUtils.isWindow(jso) && !JsUtils.isElement(jso) && JsUtils.isArray(jso)) { - JsCache c = jso.cast(); - JsNodeArray elms = JsNodeArray.create(); - for (int i = 0; i < c.length(); i++) { - Object obj = c.get(i); - if (obj instanceof Node) { - elms.addNode((Node) obj); - } - } - r = GQuery.$(elms); - } - return r; - } - } - return GQuery.$(); - } - public static GQuery dollar(String s, Element ctx) { return GQuery.$(s, ctx); } @@ -67,7 +41,7 @@ public abstract class JsQueryUtils { return ((List<?>)array).indexOf(object); } else if (object instanceof JavaScriptObject && JsUtils.isElement((JavaScriptObject) object)) { - return dollar(array).index((Element) object); + return GQuery.$(array).index((Element) object); } else if (array instanceof JavaScriptObject && JsUtils.isArray((JavaScriptObject) array)) { return ((JsCache) array).indexOf(object); |