From 4d91ee517b619b6e0526c4464f698aa8eb0a0081 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Mon, 5 Sep 2011 18:20:04 +0000 Subject: Little changes to facilitate the export of gquery to javascript. Add snapshot suffix to version number --- archetype/pom.xml | 2 +- devtest/pom.xml | 2 +- .../java/com/google/gwt/query/client/GQuery.java | 8 +-- .../com/google/gwt/query/client/LazyGQuery.java | 5 +- .../gwt/query/client/impl/DocumentStyleImpl.java | 8 ++- .../gwt/query/client/impl/DocumentStyleImplIE.java | 4 +- .../google/gwt/query/client/plugins/Effects.java | 58 +++++++++++----------- .../gwt/query/client/plugins/LazyEffects.java | 4 +- samples/pom.xml | 2 +- 9 files changed, 50 insertions(+), 43 deletions(-) diff --git a/archetype/pom.xml b/archetype/pom.xml index 378dda55..9219a8ed 100644 --- a/archetype/pom.xml +++ b/archetype/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.googlecode.gwtquery gquery-archetype - 1.1.0.rc1-SNAPSHOT + 1.1.0-SNAPSHOT maven-archetype GwtQuery Archetype This archetype generates a Gwt-2.2.0 project with all set to use GwtQuery and its plugins diff --git a/devtest/pom.xml b/devtest/pom.xml index a648882d..14604e62 100644 --- a/devtest/pom.xml +++ b/devtest/pom.xml @@ -5,7 +5,7 @@ com.googlecode.gwtquery gwtquery-project - 1.1.0.rc1-SNAPSHOT + 1.1.0-SNAPSHOT devtest 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 0208b69f..4a4daffd 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 @@ -728,8 +728,8 @@ public class GQuery implements Lazy { * @param funcs an array of {@link Function} called once the animation is * complete */ - public GQuery animate(String prop, Function... funcs) { - return as(Effects).animate(prop, funcs); + public GQuery animate(Object stringOrProperties, Function... funcs) { + return as(Effects).animate(stringOrProperties, funcs); } /** @@ -787,8 +787,8 @@ public class GQuery implements Lazy { * complete * @param duration the duration in milliseconds of the animation */ - public GQuery animate(String prop, int duration, Function... funcs) { - return as(Effects).animate(prop, duration, funcs); + public GQuery animate(Object stringOrProperties, int duration, Function... funcs) { + return as(Effects).animate(stringOrProperties, duration, funcs); } /** diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java index 946a11e3..16ab8ec7 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/LazyGQuery.java @@ -32,6 +32,7 @@ import com.google.gwt.dom.client.OptionElement; import com.google.gwt.dom.client.SelectElement; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.HasCssName; +import com.google.gwt.dom.client.StyleInjector.StyleInjectorImpl; import com.google.gwt.dom.client.TextAreaElement; import com.google.gwt.query.client.css.HasCssValue; import com.google.gwt.query.client.css.TakesCssValue; @@ -218,7 +219,7 @@ public interface LazyGQuery extends LazyBase{ * @param funcs an array of {@link Function} called once the animation is * complete */ - LazyGQuery animate(String prop, Function... funcs); + LazyGQuery animate(Object stringOrProperties, Function... funcs); /** * The animate() method allows you to create animation effects on any numeric @@ -275,7 +276,7 @@ public interface LazyGQuery extends LazyBase{ * complete * @param duration the duration in milliseconds of the animation */ - LazyGQuery animate(String prop, int duration, Function... funcs); + LazyGQuery animate(Object stringOrProperties, int duration, Function... funcs); /** * Append content to the inside of every matched element. This operation is diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java index d24eeb41..7cd8b90f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImpl.java @@ -96,7 +96,11 @@ public class DocumentStyleImpl { if (!force) { return ret == null ? "" : ret; } else { - return getComputedStyle(elem, JsUtils.hyphenize(name), name, null); + try { + return getComputedStyle(elem, JsUtils.hyphenize(name), name, null); + } catch (Exception e) { + return ret; + } } } @@ -168,7 +172,7 @@ public class DocumentStyleImpl { protected native String getComputedStyle(Element elem, String hyphenName, String camelName, String pseudo) /*-{ var cStyle = $doc.defaultView.getComputedStyle(elem, pseudo); - return cStyle ? cStyle.getPropertyValue(hyphenName) : null; + return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null; }-*/; protected static final JsNamedArray elemdisplay = JsNamedArray.create(); diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java index b4d436a3..318a81a9 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/DocumentStyleImplIE.java @@ -63,7 +63,8 @@ public class DocumentStyleImplIE extends DocumentStyleImpl { * Remove a style property from an element. */ public native void removeStyleProperty(Element elem, String prop) /*-{ - elem.style.removeAttribute(prop); + if (elem && elem.style && elem.removeAttribute) + elem.style.removeAttribute(prop); }-*/; @@ -84,6 +85,7 @@ public class DocumentStyleImplIE extends DocumentStyleImpl { protected native String getComputedStyle(Element elem, String hyphenName, String camelName, String pseudo) /*-{ // code lifted from jQuery + if (!elem.style || !elem.currentStyle || !elem.runtimeStyle) return null; var style = elem.style; var ret = elem.currentStyle[hyphenName] || elem.currentStyle[camelName]; if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java index bb36a611..aa163633 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Effects.java @@ -66,6 +66,30 @@ public class Effects extends QueuePlugin { super(gq); } + private void queueAnimation(final Element e, final GQAnimation anim, final int duration) { + if (isOff()) { + anim.onStart(); + anim.onComplete(); + } else { + queue(e, DEFAULT_NAME, new Function() { + public void cancel(Element e) { + Animation anim = (Animation) data(e, ACTUAL_ANIMATION, null); + if (anim != null) { + anim.cancel(); + } + } + public void f(Element e) { + data(e, ACTUAL_ANIMATION, anim); + anim.run(duration); + } + }); + } + } + + protected boolean isOff() { + return Fx.off; + } + /** * The animate() method allows you to create animation effects on any numeric * Attribute, CSS property, or color CSS property. @@ -129,30 +153,6 @@ public class Effects extends QueuePlugin { } return this; } - - private void queueAnimation(final Element e, final GQAnimation anim, final int duration) { - if (isOff()) { - anim.onStart(); - anim.onComplete(); - } else { - queue(e, DEFAULT_NAME, new Function() { - public void cancel(Element e) { - Animation anim = (Animation) data(e, ACTUAL_ANIMATION, null); - if (anim != null) { - anim.cancel(); - } - } - public void f(Element e) { - data(e, ACTUAL_ANIMATION, anim); - anim.run(duration); - } - }); - } - } - - protected boolean isOff() { - return Fx.off; - } /** * @@ -211,10 +211,10 @@ public class Effects extends QueuePlugin { * @param funcs an array of {@link Function} called once the animation is * complete */ - public Effects animate(String prop, Function... funcs) { - return animate(prop, 500, funcs); + public Effects animate(Object stringOrProperties, Function... funcs) { + return animate(stringOrProperties, 500, funcs); } - + /** * The animate() method allows you to create animation effects on any numeric * Attribute, CSS properties, or color CSS property. @@ -270,8 +270,8 @@ public class Effects extends QueuePlugin { * complete * @param duration the duration in milliseconds of the animation */ - public Effects animate(String prop, int duration, Function... funcs) { - return animate($$(prop), duration, Easing.LINEAR, funcs); + public Effects animate(Object stringOrProperties, int duration, Function... funcs) { + return animate(stringOrProperties, duration, Easing.LINEAR, funcs); } /** diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java index 0f94e76a..da467921 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEffects.java @@ -140,7 +140,7 @@ public interface LazyEffects extends LazyBase{ * @param funcs an array of {@link Function} called once the animation is * complete */ - LazyEffects animate(String prop, Function... funcs); + LazyEffects animate(Object stringOrProperties, Function... funcs); /** * The animate() method allows you to create animation effects on any numeric @@ -197,7 +197,7 @@ public interface LazyEffects extends LazyBase{ * complete * @param duration the duration in milliseconds of the animation */ - LazyEffects animate(String prop, int duration, Function... funcs); + LazyEffects animate(Object stringOrProperties, int duration, Function... funcs); /** * Animate the set of matched elements using the clip property. It is possible diff --git a/samples/pom.xml b/samples/pom.xml index 217eb89e..0af9e8ae 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -3,7 +3,7 @@ com.googlecode.gwtquery gwtquery-project - 1.1.0.rc1-SNAPSHOT + 1.1.0-SNAPSHOT GwtQuery Samples -- cgit v1.2.3