diff options
author | Manolo Carrasco <manolo@apache.org> | 2011-08-19 14:42:33 +0000 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2011-08-19 14:42:33 +0000 |
commit | 8a5e5c2a1f8a53f6e1c77dfa7ba4ef1dae4896d0 (patch) | |
tree | a79c0018fbcdd1799f9954302156562151b14aea /gwtquery-core | |
parent | faad919e7f07539b5ebcd2f0d1eb8461b1615fd1 (diff) | |
download | gwtquery-8a5e5c2a1f8a53f6e1c77dfa7ba4ef1dae4896d0.tar.gz gwtquery-8a5e5c2a1f8a53f6e1c77dfa7ba4ef1dae4896d0.zip |
Fix visibility poperty when using stop(). Fix delay calling dequeue twice. Now named queue do not run dequeue like jquery does. Fix css2xpath when string literals contains # at the begining
Diffstat (limited to 'gwtquery-core')
7 files changed, 26 insertions, 34 deletions
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 6c8b3ee8..60941c6b 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 @@ -1427,7 +1427,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { * <pre class="code">
* $("#foo").queue("colorQueue", lazy().css(CSS.COLOR.with(RGBColor.RED)).dequeue("colorQueue").done())
* .delay(800, "colorQueue")
- * .queue("colorQueue", lazy().css(CSS.COLOR.with(RGBColor.BLACK)).done());
+ * .queue("colorQueue", lazy().css(CSS.COLOR.with(RGBColor.BLACK)).dequeue("colorQueue").done());
* </pre>
*
* When this statement is executed, the text color of the element changes to
@@ -1625,10 +1625,6 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { * Execute the next function on the queue named as queueName for the matched elements.
* This method is usefull to tell when a function you add in the Effects queue is
* ended and so the next function in the queue can start.
- *
- * If you are queuing functions in a named queue (not the Effects one),
- * you do not need to call dequeue(queueName) since it is preformed automatically.
- *
*/
public GQuery dequeue(String queueName) {
return as(Queue).dequeue(queueName);
@@ -2993,18 +2989,20 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { * $("#foo").queue("myQueue", new Function(){
* public void f(Element e){
* $(e).css(CSS.BACKGROUNG_COLOR.with(RGBColor.RED));
+ * dequeue("myQueue");
* }
* })
* .delay(500, "myQueue")
- * .queue("myQueue", lazy().css(CSS.COLOR.with(RGBColor.YELLOW)).done());
+ * .queue("myQueue", lazy().css(CSS.COLOR.with(RGBColor.YELLOW)).dequeue("myQueue").done());
* </pre>
*
* When this statement is executed, the background color of the element is set
* to red, then wait 500ms before to set the text color of the element to
* yellow. right for 400ms.
*
- * NOTE: {@link #dequeue()} function is not needed at the end of your
- * function unless you use the Effects ('fx') namespace.
+ * Please note that {@link #dequeue()} function is needed at the end of your
+ * function to start the next function in the queue. In lazy() methods you should
+ * call dequeue() just before the done() call.
* {@see #dequeue()}
*/
public GQuery queue(String queueName, Function... f) {
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 9b1a2739..db0a4ada 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 @@ -694,7 +694,7 @@ public interface LazyGQuery<T> extends LazyBase<T>{ * <pre class="code"> * $("#foo").queue("colorQueue", lazy().css(CSS.COLOR.with(RGBColor.RED)).dequeue("colorQueue").done()) * .delay(800, "colorQueue") - * .queue("colorQueue", lazy().css(CSS.COLOR.with(RGBColor.BLACK)).done()); + * .queue("colorQueue", lazy().css(CSS.COLOR.with(RGBColor.BLACK)).dequeue("colorQueue").done()); * </pre> * * When this statement is executed, the text color of the element changes to @@ -868,10 +868,6 @@ public interface LazyGQuery<T> extends LazyBase<T>{ * Execute the next function on the queue named as queueName for the matched elements. * This method is usefull to tell when a function you add in the Effects queue is * ended and so the next function in the queue can start. - * - * If you are queuing functions in a named queue (not the Effects one), - * you do not need to call dequeue(queueName) since it is preformed automatically. - * */ LazyGQuery<T> dequeue(String queueName); @@ -1732,18 +1728,20 @@ public interface LazyGQuery<T> extends LazyBase<T>{ * $("#foo").queue("myQueue", new Function(){ * public void f(Element e){ * $(e).css(CSS.BACKGROUNG_COLOR.with(RGBColor.RED)); + * dequeue("myQueue"); * } * }) * .delay(500, "myQueue") - * .queue("myQueue", lazy().css(CSS.COLOR.with(RGBColor.YELLOW)).done()); + * .queue("myQueue", lazy().css(CSS.COLOR.with(RGBColor.YELLOW)).dequeue("myQueue").done()); * </pre> * * When this statement is executed, the background color of the element is set * to red, then wait 500ms before to set the text color of the element to * yellow. right for 400ms. * - * NOTE: {@link #dequeue()} function is not needed at the end of your - * function unless you use the Effects ('fx') namespace. + * Please note that {@link #dequeue()} function is needed at the end of your + * function to start the next function in the queue. In lazy() methods you should + * call dequeue() just before the done() call. * {@see #dequeue()} */ LazyGQuery<T> queue(String queueName, Function... f); diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java index 5feec66f..9b172917 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/impl/SelectorEngineCssToXPath.java @@ -95,7 +95,7 @@ public class SelectorEngineCssToXPath extends SelectorEngineImpl { public static Object[] regs = new Object[]{
// scape some dots and spaces
- "(['\\[])([^'\\]]+)([\\s\\.#])([^'\\]]+)(['\\]])", rc_scp,
+ "(['\\[])([^'\\]]*)([\\s\\.#])([^'\\]]*)(['\\]])", rc_scp,
// add @ for attrib
"\\[([^@\\]~\\$\\*\\^\\|\\!]+)(=[^\\]]+)?\\]", "[@$1$2]",
// multiple queries
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java index 77ce4b1d..92deee6f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/QueuePlugin.java @@ -37,29 +37,30 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery { }); protected class DelayFunction extends Function { - private class SimpleTimer extends Timer { - @Override public void run() { - dequeue(); g.each(funcs); + for (Element e: g.elements()) { + dequeueIfNotDoneYet(e, name, DelayFunction.this); + } } } private int delay; Function[] funcs; GQuery g; + String name; - public DelayFunction(GQuery gquery, int delayInMilliseconds, Function... f) { + public DelayFunction(GQuery gquery, String name, int delayInMilliseconds, Function... f) { this.g = gquery; this.delay = delayInMilliseconds; this.funcs = f; + this.name = name; } @Override public void f() { new SimpleTimer().schedule(delay); - } } @@ -101,7 +102,7 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery { */ @SuppressWarnings("unchecked") public T delay(int milliseconds, String name, Function... funcs) { - queue(name, new DelayFunction(this, milliseconds)); + queue(name, new DelayFunction(this, name, milliseconds, funcs)); return (T) this; } @@ -161,13 +162,7 @@ public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery { public T queue(final String name, Function... funcs) { for (final Function f: funcs) { for (Element e: elements()) { - queue(e, name, new Function(){ - @Override - public void f(Element e) { - f.f(e.<com.google.gwt.dom.client.Element>cast()); - dequeueIfNotDoneYet(e, name, this); - } - }); + queue(e, name, f); } } return (T)this; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java index 72559a70..1c0ab2c6 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/PropertiesAnimation.java @@ -51,7 +51,7 @@ public class PropertiesAnimation extends GQAnimation { }
private static final String[] ATTRS_TO_SAVE = new String[]{
- "overflow", "visibility"};
+ "overflow"};
private static final JsRegexp REGEX_NUMBER_UNIT = new JsRegexp(
"^([0-9+-.]+)(.*)?$");
@@ -215,6 +215,7 @@ public class PropertiesAnimation extends GQAnimation { onComplete();
} else {
g.dequeue();
+ g.restoreCssAttrs(ATTRS_TO_SAVE);
}
}
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java index 63be9225..51a63104 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/impl/SelectorEnginesTest.java @@ -72,7 +72,6 @@ public class SelectorEnginesTest extends GWTTestCase { assertEquals(".//div[@class='comment' and (contains(string(.),'John'))]", sel.css2Xpath("div[@class='comment']:contains('John')")); - } } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java b/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java index 05b3c5fb..7ebf3fa3 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/rebind/SelectorGeneratorsTest.java @@ -90,11 +90,12 @@ public class SelectorGeneratorsTest extends GWTTestCase { assertEquals(".//*[@checked='checked']|.//*[not(@disabled)]|.//*[@disabled]", sel.css2Xpath(":checked, :enabled, :disabled")); - assertEquals(".//table[contains(string(.),'String With | @ ~= Space Points.s and Hash#es')]", - sel.css2Xpath("table:contains('String With | @ ~= Space Points.s and Hash#es')")); + assertEquals(".//table[contains(string(.),'#String With | @ ~= Space Points.s and Hash#es#')]", + sel.css2Xpath("table:contains('#String With | @ ~= Space Points.s and Hash#es#')")); assertEquals(".//div[@class='comment' and (contains(string(.),'John'))]", sel.css2Xpath("div[@class='comment']:contains('John')")); + } public void testReplaceAll() { |