aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Dramaix <julien.dramaix@gmail.com>2013-02-11 03:21:48 -0800
committerJulien Dramaix <julien.dramaix@gmail.com>2013-02-11 03:21:48 -0800
commite83aa522684e5af5f71a55d52221486ca8bbcb62 (patch)
tree06fbd8eba549c39e7341f473a1b82dcbbb4c3d91
parentd3412c8671f65b78f145f8547ef7f0c5197f3d56 (diff)
parent34c793e9f06b2ba864b9e92856e69f43e80c4733 (diff)
downloadgwtquery-e83aa522684e5af5f71a55d52221486ca8bbcb62.tar.gz
gwtquery-e83aa522684e5af5f71a55d52221486ca8bbcb62.zip
Merge pull request #14 from manolo/master
Last changes on manolo's branch
-rw-r--r--archetype/pom.xml13
-rw-r--r--archetype/src/main/resources/archetype-resources/pom.xml6
-rw-r--r--devtest/pom.xml2
-rw-r--r--gwtquery-core-2.0.1/pom.xml2
-rw-r--r--gwtquery-core-2.1.0/pom.xml2
-rw-r--r--gwtquery-core/pom.xml4
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java67
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java2
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java14
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java44
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java30
-rw-r--r--jsquery/pom.xml2
-rw-r--r--pom.xml25
-rw-r--r--samples/pom.xml2
14 files changed, 141 insertions, 74 deletions
diff --git a/archetype/pom.xml b/archetype/pom.xml
index 7e41f68b..1af510a6 100644
--- a/archetype/pom.xml
+++ b/archetype/pom.xml
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gquery-archetype</artifactId>
- <version>1.1.4-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<packaging>maven-archetype</packaging>
<name>GwtQuery Archetype</name>
@@ -17,9 +17,9 @@
<description>This archetype generates a Gwt-2.5.0-rc1 project with all set to use GwtQuery and its plugins.</description>
<scm>
- <connection>scm:svn:http://gwtquery.googlecode.com/svn/trunk/archetype</connection>
- <developerConnection>scm:svn:https://gwtquery.googlecode.com/svn/trunk/archetype</developerConnection>
- <url>http://code.google.com/p/gwtquery/source/browse/trunk/archetype</url>
+ <connection>scm:git:https://code.google.com/p/gwtquery/</connection>
+ <developerConnection>scm:git:git@github.com:gwtquery/gwtquery.git</developerConnection>
+ <url>http://code.google.com/p/gwtquery/source/browse/</url>
</scm>
<developers>
@@ -38,11 +38,6 @@
<build>
<extensions>
<extension>
- <groupId>org.jvnet.wagon-svn</groupId>
- <artifactId>wagon-svn</artifactId>
- <version>1.8</version>
- </extension>
- <extension>
<groupId>org.apache.maven.archetype</groupId>
<artifactId>archetype-packaging</artifactId>
<version>2.0-alpha-5</version>
diff --git a/archetype/src/main/resources/archetype-resources/pom.xml b/archetype/src/main/resources/archetype-resources/pom.xml
index dc350f81..80f3c6e7 100644
--- a/archetype/src/main/resources/archetype-resources/pom.xml
+++ b/archetype/src/main/resources/archetype-resources/pom.xml
@@ -12,9 +12,9 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
- <gQueryVersion>1.1.0</gQueryVersion>
- <gwtversion>2.5.0-rc1</gwtversion>
- <gwtmaven>2.4.0</gwtmaven>
+ <gQueryVersion>1.3.1</gQueryVersion>
+ <gwtversion>2.5.0</gwtversion>
+ <gwtmaven>2.5.0</gwtmaven>
</properties>
<repositories>
diff --git a/devtest/pom.xml b/devtest/pom.xml
index 5ae88756..72adfc01 100644
--- a/devtest/pom.xml
+++ b/devtest/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
</parent>
<artifactId>devtest</artifactId>
diff --git a/gwtquery-core-2.0.1/pom.xml b/gwtquery-core-2.0.1/pom.xml
index bb54d8fe..5812ec0f 100644
--- a/gwtquery-core-2.0.1/pom.xml
+++ b/gwtquery-core-2.0.1/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
</parent>
<description>Generates an artifact compiled with a concrete gwt version specified in the artifactId</description>
diff --git a/gwtquery-core-2.1.0/pom.xml b/gwtquery-core-2.1.0/pom.xml
index 47c40145..e8238181 100644
--- a/gwtquery-core-2.1.0/pom.xml
+++ b/gwtquery-core-2.1.0/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
- <version>1.1.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
</parent>
<description>Generates an artifact compiled with a concrete gwt version specified in the artifactId</description>
diff --git a/gwtquery-core/pom.xml b/gwtquery-core/pom.xml
index 88bf45d6..38a404d6 100644
--- a/gwtquery-core/pom.xml
+++ b/gwtquery-core/pom.xml
@@ -3,12 +3,12 @@
<parent>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
</parent>
<artifactId>gwtquery</artifactId>
<packaging>jar</packaging>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<name>Gwt Query Core API</name>
<url>http://gwtquery.com</url>
<dependencies>
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
index e64fdfb9..16b10b92 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java
@@ -424,9 +424,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
protected static GQuery cleanHtmlString(String elem, Document doc) {
String tag = tagNameRegex.exec(elem).get(1);
-
if (tag == null) {
- throw new RuntimeException("HTML snippet doesn't contain any tag");
+ return $(doc.createTextNode(elem));
}
if (wrapperMap == null) {
@@ -848,22 +847,27 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
/**
*
- * The animate() method allows you to create animation effects on any numeric Attribute, CSS
- * property, or color CSS property.
+ * The animate() method allows you to create animation effects on any numeric HTML Attribute,
+ * CSS property, or color CSS property.
*
* Concerning to numeric properties, values are treated as a number of pixels unless otherwise
* specified. The units em and % can be specified where applicable.
*
* By default animate considers css properties, if you wanted to animate element attributes you
- * should to prepend the symbol dollar to the attribute name.
+ * should to prepend the symbol dollar to the attribute name. It's useful to animate svg elements.
+ *
+ * NOTE: The ability of animating attribute values is only available in gquery but not jquery
+ *
*
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * //move the element from its original position to left:500px
* $("#foo").animate("left:'500'");
- * // Change the width attribute of a table
- * $("table").animate("width:'500'", 400, Easing.LINEAR);
+ *
+ * // Change the width html attribute of a table, note the symbol '$' to
+ * // tell gquery which it is an html-attribute instead of a css-property.
+ * $("table").animate("$width:'500'");
* </pre>
*
* In addition to numeric values, each property can take the strings 'show', 'hide', and 'toggle'.
@@ -877,16 +881,15 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* <pre class="code">
* //move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
+ *
* $("#foo").animate("left:'+=500'", new Function(){
- *
* public void f(Element e){
* $(e).css(CSS.BACKGROUND_COLOR.with(RGBColor.RED);
* }
- *
* });
* </pre>
*
- * The duration of the animation is 500ms.
+ * The default duration of the animation is 500ms.
*
* For color css properties, values can be specified via hexadecimal or rgb or literal values.
*
@@ -904,22 +907,28 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * The animate() method allows you to create animation effects on any numeric Attribute, CSS
- * property, or color CSS property.
+ *
+ * The animate() method allows you to create animation effects on any numeric HTML Attribute,
+ * CSS property, or color CSS property.
*
* Concerning to numeric properties, values are treated as a number of pixels unless otherwise
* specified. The units em and % can be specified where applicable.
*
* By default animate considers css properties, if you wanted to animate element attributes you
- * should to prepend the symbol dollar to the attribute name.
+ * should to prepend the symbol dollar to the attribute name. It's useful to animate svg elements.
+ *
+ * NOTE: The ability of animating attribute values is only available in gquery but not jquery
+ *
*
* Example:
*
* <pre class="code">
- * //move the element from its original position to the position top:500px and left:500px for 400ms.
- * //use a swing easing function for the transition
- * $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, Easing.SWING);
- * // Change the width and border attributes of a table
+ * //move the element from its original position to left:500px for 500ms using a swing easing
+ * $("#foo").animate("left:'500'", 500, Easing.SWING);
+ *
+ * // Change the width html attribute of a table, note the symbol '$' to
+ * // tell gquery which it is an html-attribute instead of a css-property.
+ * // the animation will last 400ms, and we use the LINEAR easing algorithm
* $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, Easing.LINEAR);
* </pre>
*
@@ -956,21 +965,27 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
}
/**
- * The animate() method allows you to create animation effects on any numeric Attribute, CSS
- * properties, or color CSS property.
+ * The animate() method allows you to create animation effects on any numeric HTML Attribute,
+ * CSS property, or color CSS property.
*
- * Concerning to numeric property, values are treated as a number of pixels unless otherwise
+ * Concerning to numeric properties, values are treated as a number of pixels unless otherwise
* specified. The units em and % can be specified where applicable.
*
* By default animate considers css properties, if you wanted to animate element attributes you
- * should to prepend the symbol dollar to the attribute name.
+ * should to prepend the symbol dollar to the attribute name. It's useful to animate svg elements.
+ *
+ * NOTE: The ability of animating attribute values is only available in gquery but not jquery
+ *
*
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 2s
- * $("#foo").animate("left:'500px'", 2000);
- * // Change the width attribute of a table
+ * //move the element from its original position to left:500px for 500ms
+ * $("#foo").animate("left:'500'", 500);
+ *
+ * // Change the width html attribute of a table, note the symbol '$' to
+ * // tell gquery which it is an html-attribute instead of a css-property.
+ * // the animation will last 400ms
* $("table").animate("$width:'500'"), 400);
* </pre>
*
@@ -3523,7 +3538,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> {
* matched element.
*/
public int queue(String queueName) {
- return as(Queue).queue();
+ return as(Queue).queue(queueName);
}
/**
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java
index 76fd335c..fcdba699 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/AttributeImpl.java
@@ -170,7 +170,6 @@ public class AttributeImpl {
if (e.getNodeType() != 1) {
continue;
}
- e.removeAttribute(key);
if (JsUtils.hasProperty(e, key)) {
if (BOOLEAN_ATTR_REGEX.test(key)) {
e.setPropertyBoolean(key, false);
@@ -178,6 +177,7 @@ public class AttributeImpl {
e.setPropertyObject(key, null);
}
}
+ e.removeAttribute(key);
}
}
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java
index 1e8cf6a6..9eac0d79 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsObjectArray.java
@@ -33,14 +33,22 @@ public final class JsObjectArray<T> extends JavaScriptObject {
return cast();
}
- public void add(T...vals) {
+ public JsObjectArray<T> add(T...vals) {
for (T t: vals) {
- c().put(length(), t);
+ if (t instanceof Number) {
+ c().putNumber(length(), (((Number)t).doubleValue()));
+ } else if (t instanceof Boolean) {
+ c().putBoolean(length(), ((Boolean)t).booleanValue());
+ } else {
+ c().put(length(), t);
+ }
}
+ return this;
}
- public void add(int i, T val) {
+ public JsObjectArray<T> add(int i, T val) {
c().put(i, val);
+ return this;
}
@SuppressWarnings("unchecked")
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
index 962eccf1..974462db 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsUtils.java
@@ -18,6 +18,7 @@ package com.google.gwt.query.client.js;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.core.client.JsArrayMixed;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
@@ -245,13 +246,22 @@ public class JsUtils {
}
/**
- * Check if an object have already a property with name <code>name</code>
+ * Check if an object has already a property with name <code>name</code>
* defined.
*/
public static native boolean hasProperty(JavaScriptObject o, String name)/*-{
return o && name in o;
}-*/;
-
+
+ /**
+ * Check whether an element has an attribute, this is here since GWT Element.getAttribute
+ * implementation returns an empty string instead of null when the attribute is not
+ * present
+ */
+ public static native boolean hasAttribute(Element o, String name)/*-{
+ return !!(o && o.getAttribute(name));
+ }-*/;
+
/**
* Hyphenize style property names. for instance: fontName -> font-name
*/
@@ -307,8 +317,7 @@ public class JsUtils {
* Check is a javascript object is a function
*/
public static native boolean isFunction(JavaScriptObject o) /*-{
- var r = Object.prototype.toString.call(o);
- return r == '[object Function]';
+ return Object.prototype.toString.call(o) == '[object Function]';
}-*/;
/**
@@ -390,6 +399,33 @@ public class JsUtils {
public static String text(Element e) {
return utilsImpl.text(e);
}
+
+ /**
+ * Call via jsni any arbitrary function present in a Javascript object.
+ *
+ * It's thought for avoiding to create jsni methods to call external functions and
+ * facilitate the writing of js wrappers.
+ *
+ * Example
+ * <pre>
+ * // Create a svg node in our document.
+ * Element svg = runJavascriptFunction(document, "createElementNS", "http://www.w3.org/2000/svg", "svg");
+ * // Append it to the dom
+ * $(svg).appendTo(document);
+ * </pre>
+ *
+ * @param o the javascript object where the function is.
+ * @param meth the literal name of the function to call.
+ * @param args an array with the arguments to pass to the function.
+ * @return the javascript object returned by the jsni method or null.
+ */
+ public static <T> T runJavascriptFunction(JavaScriptObject o, String meth, Object... args) {
+ return runJavascriptFunctionImpl(o, meth, JsObjectArray.create().add(args).<JsArrayMixed>cast());
+ }
+
+ 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) && f.apply(o, args) || null;
+ }-*/;
/**
* Check if a number is true in the javascript scope.
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
index 34fafb99..8f58b519 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
@@ -475,6 +475,15 @@ public class GQueryCoreTestGwt extends GWTTestCase {
assertEquals(1, g2.size());
assertEquals(expected, g2.toString());
}
+
+ public void test_issue128() {
+ GQuery g = $(e).html("<span>a</span><span>b</span><span>c</span>");
+ assertEquals(g.text(), "abc");
+ $("span", e).after(" ");
+ assertEquals(g.text(), "a b c ");
+ $("span", e).after("-");
+ assertEquals(g.text(), "a- b- c- ");
+ }
public void testAppendTo() {
String txt = "<h2>Greetings</h2><div class='container'><div class='inner'>Hello</div><div class='inner'>Goodbye</div></div>";
@@ -993,6 +1002,15 @@ public class GQueryCoreTestGwt extends GWTTestCase {
assertFalse(JsUtils.truth(null));
assertFalse(JsUtils.truth(""));
}
+
+ public void testUtilsCallFunc() {
+ Element e = JsUtils.runJavascriptFunction(document, "createElement", "div");
+ assertNotNull(e);
+ assertEquals(e.getTagName().toLowerCase(), "div");
+
+ e = JsUtils.runJavascriptFunction(document, "foo", "bar", 2, true);
+ assertNull(e);
+ }
public void testVal_issue98() {
$(e).html(""
@@ -1148,6 +1166,18 @@ public class GQueryCoreTestGwt extends GWTTestCase {
assertEquals("disabled", ie.getAttribute("disabled"));
}
+
+ public void testAttr_Issue165() {
+ $(e).html("<a href='#' title='a title'>anchor</a>");
+ Element a = $("a", e).get(0);
+
+ assertEquals("a title", a.getAttribute("title"));
+ assertTrue(JsUtils.hasAttribute(a, "title"));
+
+ $(a).removeAttr("title");
+ assertEquals("", a.getAttribute("title"));
+ assertFalse(JsUtils.hasAttribute(a, "title"));
+ }
@DoNotRunWith({Platform.Prod})
// FIXME: the hidden part does not work in FF nor Chrome
diff --git a/jsquery/pom.xml b/jsquery/pom.xml
index 9ac9e72b..01be3cb2 100644
--- a/jsquery/pom.xml
+++ b/jsquery/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
</parent>
<name>JsQuery</name>
diff --git a/pom.xml b/pom.xml
index f6a47a6d..92847895 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
<packaging>pom</packaging>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<name>Gwt Query Project</name>
<url>http://gwtquery.com</url>
<description>GwtQuery is a jQuery clone written in GWT.</description>
@@ -57,11 +57,9 @@
</developers>
<scm>
- <connection>scm:svn:http://gwtquery.googlecode.com/svn/trunk
- </connection>
- <developerConnection>scm:svn:https://gwtquery.googlecode.com/svn/trunk
- </developerConnection>
- <url>http://code.google.com/p/gwtquery/source/browse/trunk</url>
+ <connection>scm:git:https://code.google.com/p/gwtquery/</connection>
+ <developerConnection>scm:git:git@github.com:gwtquery/gwtquery.git</developerConnection>
+ <url>http://code.google.com/p/gwtquery/source/browse/</url>
</scm>
<modules>
@@ -77,11 +75,6 @@
<id>repo1</id>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
- <pluginRepository>
- <id>gcupload</id>
- <name>Repository for gcupload plugin</name>
- <url>http://gwtupload.googlecode.com/svn/mavenrepo</url>
- </pluginRepository>
</pluginRepositories>
<build>
@@ -101,9 +94,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <tagBase>
- https://gwtquery.googlecode.com/svn/tags
- </tagBase>
<preparationGoals>clean install</preparationGoals>
</configuration>
</plugin>
@@ -116,13 +106,6 @@
</configuration>
</plugin>
</plugins>
- <extensions>
- <extension>
- <groupId>org.jvnet.wagon-svn</groupId>
- <artifactId>wagon-svn</artifactId>
- <version>1.8</version>
- </extension>
- </extensions>
</build>
<reporting>
<plugins>
diff --git a/samples/pom.xml b/samples/pom.xml
index 7d737fe6..18a91e26 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>com.googlecode.gwtquery</groupId>
<artifactId>gwtquery-project</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
</parent>
<name>GwtQuery Samples</name>