From 1313f0c0286cc31edf9874cedeb44f8689e7d0d0 Mon Sep 17 00:00:00 2001 From: Manuel Carrasco MoƱino Date: Mon, 26 Nov 2012 16:20:48 +0100 Subject: End lines with LF instead of CRLF --- .../main/java/com/google/gwt/query/Query.gwt.xml | 282 +- .../java/com/google/gwt/query/QueryMin.gwt.xml | 144 +- .../java/com/google/gwt/query/client/Function.java | 98 +- .../java/com/google/gwt/query/client/GQuery.java | 9312 ++++++++++---------- .../java/com/google/gwt/query/client/Lazy.java | 6 +- .../java/com/google/gwt/query/client/LazyBase.java | 6 +- .../com/google/gwt/query/client/LazyGQuery.java | 448 +- .../com/google/gwt/query/client/Predicate.java | 22 +- .../com/google/gwt/query/client/Properties.java | 374 +- .../java/com/google/gwt/query/client/Selector.java | 62 +- .../com/google/gwt/query/client/Selectors.java | 144 +- .../gwt/query/client/builders/JsonBuilder.java | 122 +- .../gwt/query/client/builders/JsonBuilderBase.java | 24 +- .../com/google/gwt/query/client/builders/Name.java | 62 +- .../gwt/query/client/builders/XmlBuilder.java | 162 +- .../gwt/query/client/builders/XmlBuilderBase.java | 42 +- .../client/css/BackgroundAttachmentProperty.java | 6 +- .../query/client/css/BackgroundColorProperty.java | 6 +- .../query/client/css/BackgroundImageProperty.java | 6 +- .../client/css/BackgroundPositionProperty.java | 12 +- .../gwt/query/client/css/BackgroundProperty.java | 8 +- .../query/client/css/BackgroundRepeatProperty.java | 6 +- .../query/client/css/BorderCollapseProperty.java | 6 +- .../gwt/query/client/css/BorderColorProperty.java | 6 +- .../gwt/query/client/css/BorderProperty.java | 12 +- .../query/client/css/BorderSpacingProperty.java | 8 +- .../gwt/query/client/css/BorderStyleProperty.java | 6 +- .../gwt/query/client/css/BorderWidthProperty.java | 6 +- .../java/com/google/gwt/query/client/css/CSS.java | 270 +- .../gwt/query/client/css/CaptionSideProperty.java | 8 +- .../google/gwt/query/client/css/ClearProperty.java | 8 +- .../google/gwt/query/client/css/ClipProperty.java | 8 +- .../google/gwt/query/client/css/ColorProperty.java | 6 +- .../google/gwt/query/client/css/CssProperty.java | 10 +- .../gwt/query/client/css/CursorProperty.java | 8 +- .../gwt/query/client/css/DirectionProperty.java | 8 +- .../gwt/query/client/css/DisplayProperty.java | 6 +- .../gwt/query/client/css/EdgePositionProperty.java | 8 +- .../gwt/query/client/css/EmptyCellsProperty.java | 8 +- .../google/gwt/query/client/css/FloatProperty.java | 6 +- .../gwt/query/client/css/FontSizeProperty.java | 6 +- .../gwt/query/client/css/FontStyleProperty.java | 6 +- .../gwt/query/client/css/FontVariantProperty.java | 6 +- .../gwt/query/client/css/FontWeightProperty.java | 6 +- .../google/gwt/query/client/css/HasCssValue.java | 8 +- .../gwt/query/client/css/HeightProperty.java | 6 +- .../com/google/gwt/query/client/css/Length.java | 8 +- .../query/client/css/LetterSpacingProperty.java | 6 +- .../gwt/query/client/css/LineHeightProperty.java | 8 +- .../query/client/css/ListStyleImageProperty.java | 6 +- .../client/css/ListStylePositionProperty.java | 8 +- .../gwt/query/client/css/ListStyleProperty.java | 6 +- .../query/client/css/ListStyleTypeProperty.java | 6 +- .../gwt/query/client/css/MarginProperty.java | 6 +- .../query/client/css/MultipleValueCssSetter.java | 8 +- .../gwt/query/client/css/OutlineColorProperty.java | 6 +- .../gwt/query/client/css/OutlineProperty.java | 8 +- .../gwt/query/client/css/OutlineStyleProperty.java | 6 +- .../gwt/query/client/css/OutlineWidthProperty.java | 8 +- .../gwt/query/client/css/OverflowProperty.java | 6 +- .../gwt/query/client/css/PaddingProperty.java | 6 +- .../gwt/query/client/css/PositionProperty.java | 6 +- .../com/google/gwt/query/client/css/RGBColor.java | 6 +- .../gwt/query/client/css/SimpleCssSetter.java | 8 +- .../google/gwt/query/client/css/TakesCssValue.java | 6 +- .../google/gwt/query/client/css/TakesInteger.java | 8 +- .../google/gwt/query/client/css/TakesLength.java | 6 +- .../google/gwt/query/client/css/TakesNumber.java | 8 +- .../gwt/query/client/css/TextAlignProperty.java | 8 +- .../query/client/css/TextDecorationProperty.java | 6 +- .../gwt/query/client/css/TextIdentProperty.java | 6 +- .../query/client/css/TextTransformProperty.java | 6 +- .../gwt/query/client/css/UnicodeBidiProperty.java | 8 +- .../com/google/gwt/query/client/css/UriValue.java | 6 +- .../query/client/css/VerticalAlignProperty.java | 6 +- .../gwt/query/client/css/VisibilityProperty.java | 6 +- .../gwt/query/client/css/WhiteSpaceProperty.java | 6 +- .../google/gwt/query/client/css/WidthProperty.java | 6 +- .../gwt/query/client/css/WordSpacingProperty.java | 6 +- .../gwt/query/client/css/ZIndexProperty.java | 12 +- .../gwt/query/client/impl/AttributeImpl.java | 14 +- .../query/client/impl/AttributeTridentImpl.java | 6 +- .../gwt/query/client/impl/DocumentStyleImpl.java | 66 +- .../gwt/query/client/impl/DocumentStyleImplIE.java | 16 +- .../google/gwt/query/client/impl/HasSelector.java | 8 +- .../gwt/query/client/impl/SelectorEngine.java | 364 +- .../client/impl/SelectorEngineCssToXPath.java | 550 +- .../gwt/query/client/impl/SelectorEngineImpl.java | 48 +- .../query/client/impl/SelectorEngineNative.java | 24 +- .../query/client/impl/SelectorEngineNativeIE8.java | 20 +- .../query/client/impl/SelectorEngineNativeMin.java | 14 +- .../client/impl/SelectorEngineNativeMinIE8.java | 8 +- .../query/client/impl/SelectorEngineSizzle.java | 66 +- .../query/client/impl/SelectorEngineSizzleIE.java | 64 +- .../client/impl/research/SelectorEngineJS.java | 1624 ++-- .../client/impl/research/SelectorEngineJSIE.java | 74 +- .../impl/research/SelectorEngineSizzleGwt.java | 68 +- .../client/impl/research/SelectorEngineXPath.java | 502 +- .../com/google/gwt/query/client/js/JsCache.java | 56 +- .../com/google/gwt/query/client/js/JsClosure.java | 6 +- .../java/com/google/gwt/query/client/js/JsMap.java | 12 +- .../google/gwt/query/client/js/JsNamedArray.java | 16 +- .../google/gwt/query/client/js/JsNodeArray.java | 176 +- .../google/gwt/query/client/js/JsObjectArray.java | 14 +- .../com/google/gwt/query/client/js/JsRegexp.java | 148 +- .../com/google/gwt/query/client/js/JsUtils.java | 30 +- .../google/gwt/query/client/plugins/Effects.java | 1198 +-- .../google/gwt/query/client/plugins/Events.java | 54 +- .../gwt/query/client/plugins/LazyEffects.java | 86 +- .../gwt/query/client/plugins/LazyEvents.java | 54 +- .../gwt/query/client/plugins/LazyWidgets.java | 20 +- .../gwt/query/client/plugins/MouseOptions.java | 18 +- .../gwt/query/client/plugins/MousePlugin.java | 678 +- .../google/gwt/query/client/plugins/Plugin.java | 66 +- .../gwt/query/client/plugins/QueuePlugin.java | 60 +- .../google/gwt/query/client/plugins/UiPlugin.java | 12 +- .../google/gwt/query/client/plugins/Widgets.java | 394 +- .../google/gwt/query/client/plugins/ajax/Ajax.java | 56 +- .../client/plugins/effects/ClipAnimation.java | 292 +- .../gwt/query/client/plugins/effects/Fx.java | 16 +- .../plugins/effects/PropertiesAnimation.java | 560 +- .../client/plugins/events/EventsListener.java | 32 +- .../gwt/query/client/plugins/events/GqEvent.java | 34 +- .../plugins/widgets/ButtonWidgetFactory.java | 10 +- .../plugins/widgets/HtmlPanelWidgetFactory.java | 10 +- .../client/plugins/widgets/LabelWidgetFactory.java | 10 +- .../widgets/PasswordTextBoxWidgetFactory.java | 8 +- .../plugins/widgets/TextAreaWidgetFactory.java | 16 +- .../plugins/widgets/TextBoxBaseWidgetFactory.java | 12 +- .../plugins/widgets/TextBoxWidgetFactory.java | 8 +- .../client/plugins/widgets/WidgetFactory.java | 8 +- .../client/plugins/widgets/WidgetInitializer.java | 6 +- .../client/plugins/widgets/WidgetsHtmlPanel.java | 16 +- .../query/client/plugins/widgets/WidgetsUtils.java | 48 +- .../gwt/query/linker/IFrameWithDocTypeLinker.java | 6 +- .../gwt/query/rebind/JsonBuilderGenerator.java | 564 +- .../com/google/gwt/query/rebind/LazyGenerator.java | 6 +- .../gwt/query/rebind/SelectorGeneratorBase.java | 410 +- .../query/rebind/SelectorGeneratorCssToXPath.java | 220 +- .../gwt/query/rebind/SelectorGeneratorJS.java | 80 +- .../query/rebind/SelectorGeneratorJSOptimal.java | 378 +- .../gwt/query/rebind/SelectorGeneratorNative.java | 132 +- .../query/rebind/SelectorGeneratorNativeIE8.java | 120 +- .../query/rebind/SelectorGeneratorNativeIE9.java | 120 +- .../gwt/query/rebind/SelectorGeneratorXPath.java | 662 +- .../gwt/query/rebind/XmlBuilderGenerator.java | 334 +- .../google/gwt/query/client/GQueryAjaxTestGwt.java | 50 +- .../google/gwt/query/client/GQueryCoreTestGwt.java | 404 +- .../google/gwt/query/client/GQueryCssTestGwt.java | 34 +- .../gwt/query/client/GQueryEffectsTestGwt.java | 94 +- .../gwt/query/client/GQueryEventsTestGwt.java | 10 +- .../google/gwt/query/client/GQueryJsTestGwt.java | 28 +- .../gwt/query/client/GQuerySelectorsTestGwt.java | 84 +- .../gwt/query/client/GQueryWidgetsTestGwt.java | 28 +- .../google/gwt/query/client/JreQueryCoreTest.java | 6 +- .../gwt/query/client/impl/SelectorEnginesTest.java | 64 +- .../query/client/impl/SelectorEnginesTestGwt.java | 8 +- .../gwt/query/rebind/SelectorGeneratorsTest.java | 68 +- 158 files changed, 11854 insertions(+), 11854 deletions(-) (limited to 'gwtquery-core') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml b/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml index 61cdd0df..c71a4361 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml +++ b/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml @@ -1,142 +1,142 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/QueryMin.gwt.xml b/gwtquery-core/src/main/java/com/google/gwt/query/QueryMin.gwt.xml index 9678a7ee..4a9b0fd0 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/QueryMin.gwt.xml +++ b/gwtquery-core/src/main/java/com/google/gwt/query/QueryMin.gwt.xml @@ -1,72 +1,72 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java index f6a7b82c..361eea1f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Function.java @@ -1,12 +1,12 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -25,33 +25,33 @@ import com.google.gwt.user.client.ui.Widget; * Extend this class to implement functions callbacks. */ public abstract class Function { - + private com.google.gwt.dom.client.Element element = null; private Event event = null; private int index = -1; private Object[] data = new Object[0]; - + public T getElement() { return element.cast(); } - + public void setElement(T e) { element = e; } - + public void setEvent(Event e) { event = e; element = e != null ? e.getCurrentEventTarget().cast() : null; } - + public Event getEvent() { return event; } - + public void setIndex(int i) { index = i; } - + public Object[] getData() { return data; } @@ -59,7 +59,7 @@ public abstract class Function { public void setData(Object...data) { this.data = data; } - + public Object getDataObject() { return getDataObject(0); } @@ -67,11 +67,11 @@ public abstract class Function { public Object getDataObject(int idx) { return data != null && data.length > idx ? data[idx] : null; } - + public Properties getDataProperties() { return getDataProperties(0); } - + public Properties getDataProperties(int idx) { Object o = getDataObject(idx); if (o != null && o instanceof JavaScriptObject) { @@ -87,20 +87,20 @@ public abstract class Function { public void setData(double b) { setData(Double.valueOf(b)); } - + public void setDataObject(Object data) { setData(data); } - + public int getIndex() { return index; } - + /** * Override this for methods which invoke a cancel action. - * + * * @param e takes a com.google.gwt.dom.client.Element. - * + * */ public void cancel(com.google.gwt.dom.client.Element e) { setElement(e); @@ -110,9 +110,9 @@ public abstract class Function { /** * Override this for methods which invoke a cancel action. - * + * * @param e takes a com.google.gwt.user.client.Element. - * + * */ public void cancel(com.google.gwt.user.client.Element e) { setElement(e); @@ -129,23 +129,23 @@ public abstract class Function { /** * Override this for GQuery methods which loop over matched elements and * invoke a callback on each element. - * + * * @param e takes a com.google.gwt.dom.client.Element. - * + * */ public Object f(com.google.gwt.dom.client.Element e, int i) { setElement(e); setIndex(i); // This has to be the order of calls - return f(e.cast(), i); + return f(e.cast(), i); } /** * Override this for GQuery methods which loop over matched elements and * invoke a callback on each element. - * + * * @param e takes a com.google.gwt.user.client.Element. - * + * */ public Object f(com.google.gwt.user.client.Element e, int i) { setElement(e); @@ -162,10 +162,10 @@ public abstract class Function { /** * Override this for GQuery methods which loop over matched widgets and * invoke a callback on each widget. - * - * NOTE: If your query has non-widget elements you might need to override + * + * NOTE: If your query has non-widget elements you might need to override * 'public void f()' or 'public void f(Element e)' to handle these elements and - * avoid a runtime exception. + * avoid a runtime exception. */ public Object f(Widget w, int i) { setElement(w.getElement()); @@ -173,21 +173,21 @@ public abstract class Function { f(w); return null; } - + /** * Override this method for bound callbacks */ public void f(Object... data) { fe(data); } - + /** * Override this method for bound callbacks */ public void f(int i, Object data) { f(i, new Object[]{data}); } - + /** * Override this method for bound callbacks */ @@ -206,7 +206,7 @@ public abstract class Function { } } } - + /** * Override this method for bound event handlers if you wish to deal with * per-handler user data. @@ -219,19 +219,19 @@ public abstract class Function { /** * Override this method for bound event handlers. - * - * @return boolean: false means stop propagation and prevent default + * + * @return boolean: false means stop propagation and prevent default */ public boolean f(Event e) { setEvent(e); f(element); return true; } - + /** * Override this for GQuery methods which take a callback and do not expect a * return value. - * + * * @param e takes a com.google.gwt.dom.client.Element */ public void f(com.google.gwt.dom.client.Element e) { @@ -239,11 +239,11 @@ public abstract class Function { // This has to be the order of calls f(e.cast()); } - + /** * Override this for GQuery methods which take a callback and do not expect a * return value. - * + * * @param e takes a com.google.gwt.user.client.Element */ private boolean loop = false; @@ -257,14 +257,14 @@ public abstract class Function { f(); } } - + /** * Override this for GQuery methods which take a callback, but do not expect a * return value, apply to a single widget. - * - * NOTE: If your query has non-widget elements you might need to override + * + * NOTE: If your query has non-widget elements you might need to override * 'public void f()' or 'public void f(Element e)' to handle these elements and - * avoid a runtime exception. + * avoid a runtime exception. */ public void f(Widget w){ setElement(w.getElement()); @@ -279,7 +279,7 @@ public abstract class Function { /** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler. - * They are intentionally final to avoid override them + * They are intentionally final to avoid override them */ public final void fe() { fe(data); @@ -288,16 +288,16 @@ public abstract class Function { /** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler - * They are intentionally final to avoid override them + * They are intentionally final to avoid override them */ public final void fe(Object data) { fe(new Object[]{data}); } - + /** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler - * They are intentionally final to avoid override them + * They are intentionally final to avoid override them */ public final void fe(Object... data) { setData(data); @@ -315,7 +315,7 @@ public abstract class Function { /** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler - * They are intentionally final to avoid override them + * They are intentionally final to avoid override them */ public final boolean fe(Event ev, Object data) { if (GWT.getUncaughtExceptionHandler() != null) { @@ -328,11 +328,11 @@ public abstract class Function { } return f(ev, data); } - + /** * Methods fe(...) should be used from asynchronous contexts so as we can * catch the exception and send it to the GWT UncaughtExceptionHandler - * They are intentionally final to avoid override them + * They are intentionally final to avoid override them */ public final void fe(com.google.gwt.dom.client.Element elem) { if (GWT.getUncaughtExceptionHandler() != null) { 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 f6912470..caf188f1 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 @@ -1,4656 +1,4656 @@ -/* - * Copyright 2011, The gwtquery team. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.query.client; - -import static com.google.gwt.query.client.plugins.QueuePlugin.Queue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -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.core.client.JsArrayString; -import com.google.gwt.dom.client.BodyElement; -import com.google.gwt.dom.client.ButtonElement; -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.InputElement; -import com.google.gwt.dom.client.Node; -import com.google.gwt.dom.client.NodeList; -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.TextAreaElement; -import com.google.gwt.query.client.css.CSS; -import com.google.gwt.query.client.css.HasCssValue; -import com.google.gwt.query.client.css.TakesCssValue; -import com.google.gwt.query.client.css.TakesCssValue.CssSetter; -import com.google.gwt.query.client.impl.AttributeImpl; -import com.google.gwt.query.client.impl.DocumentStyleImpl; -import com.google.gwt.query.client.impl.SelectorEngine; -import com.google.gwt.query.client.js.JsCache; -import com.google.gwt.query.client.js.JsMap; -import com.google.gwt.query.client.js.JsNamedArray; -import com.google.gwt.query.client.js.JsNodeArray; -import com.google.gwt.query.client.js.JsObjectArray; -import com.google.gwt.query.client.js.JsRegexp; -import com.google.gwt.query.client.js.JsUtils; -import com.google.gwt.query.client.plugins.Effects; -import com.google.gwt.query.client.plugins.Events; -import com.google.gwt.query.client.plugins.Plugin; -import com.google.gwt.query.client.plugins.Widgets; -import com.google.gwt.query.client.plugins.ajax.Ajax; -import com.google.gwt.query.client.plugins.ajax.Ajax.Settings; -import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing; -import com.google.gwt.query.client.plugins.events.EventsListener; -import com.google.gwt.query.client.plugins.widgets.WidgetsUtils; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Event; -import com.google.gwt.user.client.EventListener; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.IsWidget; -import com.google.gwt.user.client.ui.Widget; - -/** - * GwtQuery is a GWT clone of the popular jQuery library. - */ -public class GQuery implements Lazy { - - private enum DomMan { - AFTER, APPEND, BEFORE, PREPEND; - } - - /** - * A POJO used to store the top/left CSS positioning values of an element. - */ - public static class Offset { - public int left; - public int top; - - public Offset(int left, int top) { - this.left = left; - this.top = top; - } - - public Offset add(int left, int top) { - return new Offset(this.left + left, this.top + top); - } - - public String toString() { - return top + "+" + left; - } - } - - /** - * Class used internally to create DOM element from html snippet - */ - private static class TagWrapper { - public static final TagWrapper DEFAULT = new TagWrapper(0, "", ""); - private String postWrap; - private String preWrap; - private int wrapDepth; - - public TagWrapper(int wrapDepth, String preWrap, String postWrap) { - this.wrapDepth = wrapDepth; - this.postWrap = postWrap; - this.preWrap = preWrap; - } - } - - /** - * Implementation class to modify attributes. - */ - protected static AttributeImpl attributeImpl; - - /** - * The body element in the current page. - */ - public static final BodyElement body = Document.get().getBody(); - - /** - * Object to store element data (public so as we can access to it from tests). - */ - public static JsCache dataCache = null; - - /** - * The document element in the current page. - */ - public static final Document document = Document.get(); - - /** - * Static reference Effects plugin - */ - public static Class Effects = com.google.gwt.query.client.plugins.Effects.Effects; - - /** - * Implementation engine used for CSS selectors. - */ - protected static SelectorEngine engine; - - /** - * Static reference Events plugin - */ - public static Class Events = com.google.gwt.query.client.plugins.Events.Events; - - /** - * A static reference to the GQuery class. - */ - public static Class GQUERY = GQuery.class; - - private static final String OLD_DATA_PREFIX = "old-"; - - private static final String OLD_DISPLAY = OLD_DATA_PREFIX + "display"; - - private static JsMap, Plugin> plugins; - - // Sizzle POS regex : usefull in some methods - // TODO: Share this static with SelectorEngineSizzle - private static final String POS_REGEX = - ":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\))?(?=[^\\-]|$)"; - - /** - * Implementation class used for style manipulations. - */ - private static DocumentStyleImpl styleImpl; - - private static JsRegexp tagNameRegex = new JsRegexp("<([\\w:]+)"); - - /** - * Static reference to the Widgets plugin - */ - public static Class Widgets = com.google.gwt.query.client.plugins.Widgets.Widgets; - - /** - * The window object. - */ - public static final Element window = window(); - - private static Element windowData = null; - - private static JsNamedArray wrapperMap; - - /** - * Create an empty GQuery object. - */ - public static GQuery $() { - return new GQuery(JsNodeArray.create()); - } - - /** - * Wrap a GQuery around an existing element. - */ - public static GQuery $(Element element) { - return new GQuery(element); - } - - /** - * Wrap a GQuery around an event's target element. - */ - public static GQuery $(Event event) { - return event == null ? $() : $((Element) event.getCurrentEventTarget().cast()); - } - - /** - * Wrap a GQuery around the element of a Function callback. - */ - public static GQuery $(Function f) { - return $(f.getElement()); - } - - /** - * Wrap a GQuery around an existing javascript element, event, node, nodelist, function or array. - */ - public static GQuery $(JavaScriptObject jso) { - if (jso == null) { - return $(); - } - // Execute a native javascript function like jquery does - if (JsUtils.isFunction(jso)) { - new JsUtils.JsFunction(jso).fe(); - return $(); - } - // Wraps a native array like jquery does - if (!JsUtils.isWindow(jso) && !JsUtils.isElement(jso) && JsUtils.isArray(jso)) { - JsArrayMixed c = jso.cast(); - JsNodeArray elms = JsNodeArray.create(); - for (int i = 0; i < c.length(); i++) { - Object obj = c.getObject(i); - if (obj instanceof Node) { - elms.addNode((Node) obj); - } - } - return $((NodeList)elms); - } - - return JsUtils.isWindow(jso) ? $(jso. cast()) : - JsUtils.isElement(jso) ? $(jso. cast()) : - JsUtils.isEvent(jso) ? $(jso. cast()) : - JsUtils.isNodeList(jso) ? $(jso.> cast()) : $(); - } - - /** - * Wrap a GQuery around any object, supported objects are: - * String, GQuery, Function, Widget, JavaScriptObject - * - * In the case of string, we accept a CSS selector which is then used to match a set of - * elements, or a raw HTML to create a GQuery element containing those elements. Xpath - * selector is supported in browsers with native xpath engine. - * - * In the case of a JavaScriptObject we handle: - * Element, Event, Node, Nodelist and native functions or arrays. - * - * If the case of a native function, we execute it and return empty. - */ - public static GQuery $(Object o) { - if (o != null) { - if (o instanceof String) { - return $((String)o); - } - if (o instanceof GQuery) { - return (GQuery)o; - } - if (o instanceof Function) { - return $((Function)o); - } - if (o instanceof JavaScriptObject) { - return $((JavaScriptObject)o); - } - if (o instanceof IsWidget) { - return $(Arrays.asList(o)); - } - System.err.println("GQuery.$(Object o) could not wrap the type : " + o.getClass()); - } - return $(); - } - - /** - * Create a new GQuery given a list of nodes, elements or widgets - */ - public static GQuery $(List nodesOrWidgets) { - JsNodeArray elms = JsNodeArray.create(); - if (nodesOrWidgets != null) { - for (Object o : nodesOrWidgets) { - if (o instanceof Node) { - elms.addNode((Node) o); - } else if (o instanceof IsWidget) { - elms.addNode(((IsWidget)o).asWidget().getElement()); - } - } - } - return new GQuery(elms); - } - - /** - * Wrap a GQuery around an existing node. - */ - public static GQuery $(Node n) { - return $((Element) n); - } - - /** - * Wrap a GQuery around existing Elements. - */ - public static GQuery $(NodeList elms) { - return new GQuery(elms); - } - - /** - * This function accepts a string containing a CSS selector which is then used to match a set of - * elements, or it accepts raw HTML creating a GQuery element containing those elements. Xpath - * selector is supported in browsers with native xpath engine. - */ - public static GQuery $(String selectorOrHtml) { - return $(selectorOrHtml, document); - } - - /** - * This function accepts a string containing a CSS selector which is then used to match a set of - * elements, or it accepts raw HTML creating a GQuery element containing those elements. The - * second parameter is is a class reference to a plugin to be used. - * - * Xpath selector is supported in browsers with native xpath engine. - */ - public static T $(String selector, Class plugin) { - return $(selector, document, plugin); - } - - /** - * This function accepts a string containing a CSS selector which is then used to match a set of - * elements, or it accepts raw HTML creating a GQuery element containing those elements. The - * second parameter is the context to use for the selector, or the document where the new elements - * will be created. - * - * Xpath selector is supported in browsers with native xpath engine. - */ - public static GQuery $(String selectorOrHtml, Node ctx) { - String selector = null; - if (selectorOrHtml == null || (selector = selectorOrHtml.trim()).length() == 0) { - return $(); - } - if (selector.startsWith("<")) { - return innerHtml(selectorOrHtml, JsUtils.getOwnerDocument(ctx)); - } - return new GQuery().select(selectorOrHtml, ctx); - } - - /** - * This function accepts a string containing a CSS selector which is then used to match a set of - * elements, or it accepts raw HTML creating a GQuery element containing those elements. The - * second parameter is the context to use for the selector. The third parameter is the class - * plugin to use. - * - * Xpath selector is supported in browsers with native xpath engine. - */ - @SuppressWarnings("unchecked") - public static T $(String selector, Node context, Class plugin) { - try { - if (plugins != null) { - T gquery = (T) plugins.get(plugin).init(new GQuery().select(selector, context)); - return gquery; - } - throw new RuntimeException("No plugin for class " + plugin); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * This function accepts a string containing a CSS selector which is then used to match a set of - * elements, or it accepts raw HTML creating a GQuery element containing those elements. The - * second parameter is the context to use for the selector, or the document where the new elements - * will be created. - * - * Xpath selector is supported in browsers with native xpath engine. - */ - public static GQuery $(String selectorOrHtml, Widget context) { - return $(selectorOrHtml, context.getElement()); - } - - /** - * This function accepts a string containing a CSS selector which is then used to match a set of - * elements, or it accepts raw HTML creating a GQuery element containing those elements. The - * second parameter is the context to use for the selector. The third parameter is the class - * plugin to use. - * - * Xpath selector is supported in browsers with native xpath engine. - */ - public static T $(String selector, Widget context, Class plugin) { - return $(selector, context.getElement(), plugin); - } - - /** - * Wrap a GQuery around one widget or an array of existing ones. - */ - public static GQuery $(Widget... widgets) { - return $(Arrays.asList(widgets)); - } - - /** - * Wrap a JSON object. - */ - public static Properties $$(String properties) { - return Properties.create(properties); - } - - /** - * Perform an ajax request to the server. - */ - public static void ajax(Properties p) { - ajax(p); - } - - /** - * Perform an ajax request to the server. - */ - public static void ajax(Settings settings) { - Ajax.ajax(settings); - } - - /** - * Perform an ajax request to the server. - */ - public static void ajax(String url, Settings settings) { - Ajax.ajax(url, settings); - } - - @SuppressWarnings("unchecked") - 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"); - } - - if (wrapperMap == null) { - initWrapperMap(); - } - - TagWrapper wrapper = wrapperMap.get(tag.toLowerCase()); - - if (wrapper == null) { - wrapper = TagWrapper.DEFAULT; - } - - // TODO: fix IE link tag serialization - // TODO: fix IE \\s*", "") - .replaceAll("\\s*", ""); + .replaceAll("\\s*", ""); // We wrap the results in a div s = "
" + s + "
"; - + Ajax.this.empty().append(filter.isEmpty() ? $(s) : $(s).find(filter)); if (onSuccess != null) { onSuccess.setElement(Ajax.this.get(0)); @@ -385,9 +385,9 @@ public class Ajax extends GQuery { ajax(s); return this; } - + private static int callBackCounter = 0; - + public static native void getJsonpImpl(Element elem, String url, String charset, Function success, Function error, int timeout) /*-{ var fName = "__GQ_cb_" + @com.google.gwt.query.client.plugins.ajax.Ajax::callBackCounter ++; var done = false; @@ -408,7 +408,7 @@ public class Ajax extends GQuery { } if (timeout) { setTimeout(err, timeout); - } + } url = url.replace(/=\?/g,'=' + fName); var script = document.createElement("script" ); @@ -421,5 +421,5 @@ public class Ajax extends GQuery { err(); }; elem.insertBefore(script, elem.firstChild); - }-*/; + }-*/; } diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java index bb842815..e81e6340 100755 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/ClipAnimation.java @@ -1,146 +1,146 @@ -/* - * Copyright 2011, The gwtquery team. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.query.client.plugins.effects; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.query.client.Function; -import com.google.gwt.query.client.GQuery; -import com.google.gwt.query.client.plugins.Effects; -import com.google.gwt.query.client.plugins.Effects.GQAnimation; - -/** - * Animation wich uses the css clip property to show/hide an element. - */ -public class ClipAnimation extends GQAnimation { - - /** - * Type of the effect action. - */ - public static enum Action { - HIDE, SHOW, TOGGLE - } - - /** - * Corner from which the effect starts. - */ - public static enum Corner { - BOTTOM_LEFT, BOTTOM_RIGHT, CENTER, TOP_LEFT, TOP_RIGHT - } - - /** - * Direction of the effect. - */ - public static enum Direction { - BIDIRECTIONAL, HORIZONTAL, VERTICAL - } - - private static final String[] attrsToSave = new String[]{ - "position", "overflow", "visibility", "white-space", "top", "left"}; - - Action action; - Corner corner; - Direction direction; - int percent; - private GQuery back = Effects.$(); - private Function[] funcs; - private Effects g; - - public ClipAnimation(Element elem, Action a, Corner c, Direction d, - final Function... funcs) { - if (a == Action.TOGGLE) { - a = GQuery.$(elem).isVisible() ? Action.HIDE : Action.SHOW; - } - this.action = a; - this.corner = c; - this.direction = d; - this.funcs = funcs; - e = elem; - g = GQuery.$(e).as(Effects.Effects); - } - - @Override - public void onCancel() { - Boolean jumpToEnd = Effects.$(e).data(Effects.JUMP_TO_END, Boolean.class); - if (jumpToEnd != null && jumpToEnd){ - onComplete(); - } else { - g.dequeue(); - } - } - - @Override - public void onComplete() { - super.onComplete(); - if (action == Action.HIDE) { - g.hide(); - } - g.restoreCssAttrs(attrsToSave); - back.remove(); - back = Effects.$(); - g.css("clip", ""); - g.each(funcs); - g.dequeue(); - } - - @Override - public void onStart() { - g.show(); - g.saveCssAttrs(attrsToSave); - if (!"absolute".equalsIgnoreCase(g.css("position", true))) { - g.css("position", "absolute"); - g.css("top", g.offset().top + "px"); - g.css("left", g.offset().left + "px"); - back = back.add(g.before("
")).prev(); - back.height(g.height()); - back.width(g.width()); - } - g.css("overflow", "hidden"); - g.css("visivility", "visible"); - super.onStart(); - } - - @Override - public void onUpdate(double progress) { - if (action == Action.HIDE) { - progress = (1 - progress); - } - int top = 0; - int left = 0; - int right = g.width(); - int bottom = g.height(); - - if (direction == Direction.VERTICAL || direction == Direction.BIDIRECTIONAL) { - bottom = (int) (g.height() * progress); - } - if (direction == Direction.HORIZONTAL - || direction == Direction.BIDIRECTIONAL) { - right = (int) (g.width() * progress); - } - if (corner == Corner.CENTER) { - top = (g.height() - bottom) / 2; - left = (g.width() - right) / 2; - } else if (corner == Corner.BOTTOM_LEFT) { - top = (g.height() - bottom); - } else if (corner == Corner.TOP_RIGHT) { - left = (g.width() - right); - } else if (corner == Corner.BOTTOM_RIGHT) { - left = (g.width() - right); - top = (g.height() - bottom); - } - String rect = top + "px " + right + "px " + bottom + "px " + left + "px"; - g.css("clip", "rect(" + rect + ")"); - } -} +/* + * Copyright 2011, The gwtquery team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.query.client.plugins.effects; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.query.client.Function; +import com.google.gwt.query.client.GQuery; +import com.google.gwt.query.client.plugins.Effects; +import com.google.gwt.query.client.plugins.Effects.GQAnimation; + +/** + * Animation wich uses the css clip property to show/hide an element. + */ +public class ClipAnimation extends GQAnimation { + + /** + * Type of the effect action. + */ + public static enum Action { + HIDE, SHOW, TOGGLE + } + + /** + * Corner from which the effect starts. + */ + public static enum Corner { + BOTTOM_LEFT, BOTTOM_RIGHT, CENTER, TOP_LEFT, TOP_RIGHT + } + + /** + * Direction of the effect. + */ + public static enum Direction { + BIDIRECTIONAL, HORIZONTAL, VERTICAL + } + + private static final String[] attrsToSave = new String[]{ + "position", "overflow", "visibility", "white-space", "top", "left"}; + + Action action; + Corner corner; + Direction direction; + int percent; + private GQuery back = Effects.$(); + private Function[] funcs; + private Effects g; + + public ClipAnimation(Element elem, Action a, Corner c, Direction d, + final Function... funcs) { + if (a == Action.TOGGLE) { + a = GQuery.$(elem).isVisible() ? Action.HIDE : Action.SHOW; + } + this.action = a; + this.corner = c; + this.direction = d; + this.funcs = funcs; + e = elem; + g = GQuery.$(e).as(Effects.Effects); + } + + @Override + public void onCancel() { + Boolean jumpToEnd = Effects.$(e).data(Effects.JUMP_TO_END, Boolean.class); + if (jumpToEnd != null && jumpToEnd){ + onComplete(); + } else { + g.dequeue(); + } + } + + @Override + public void onComplete() { + super.onComplete(); + if (action == Action.HIDE) { + g.hide(); + } + g.restoreCssAttrs(attrsToSave); + back.remove(); + back = Effects.$(); + g.css("clip", ""); + g.each(funcs); + g.dequeue(); + } + + @Override + public void onStart() { + g.show(); + g.saveCssAttrs(attrsToSave); + if (!"absolute".equalsIgnoreCase(g.css("position", true))) { + g.css("position", "absolute"); + g.css("top", g.offset().top + "px"); + g.css("left", g.offset().left + "px"); + back = back.add(g.before("
")).prev(); + back.height(g.height()); + back.width(g.width()); + } + g.css("overflow", "hidden"); + g.css("visivility", "visible"); + super.onStart(); + } + + @Override + public void onUpdate(double progress) { + if (action == Action.HIDE) { + progress = (1 - progress); + } + int top = 0; + int left = 0; + int right = g.width(); + int bottom = g.height(); + + if (direction == Direction.VERTICAL || direction == Direction.BIDIRECTIONAL) { + bottom = (int) (g.height() * progress); + } + if (direction == Direction.HORIZONTAL + || direction == Direction.BIDIRECTIONAL) { + right = (int) (g.width() * progress); + } + if (corner == Corner.CENTER) { + top = (g.height() - bottom) / 2; + left = (g.width() - right) / 2; + } else if (corner == Corner.BOTTOM_LEFT) { + top = (g.height() - bottom); + } else if (corner == Corner.TOP_RIGHT) { + left = (g.width() - right); + } else if (corner == Corner.BOTTOM_RIGHT) { + left = (g.width() - right); + top = (g.height() - bottom); + } + String rect = top + "px " + right + "px " + bottom + "px " + left + "px"; + g.css("clip", "rect(" + rect + ")"); + } +} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java index 92c0ef42..408a993b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Fx.java @@ -12,17 +12,17 @@ import com.google.gwt.query.client.js.JsRegexp; * A pojo to store effect values. */ public class Fx { - + /** * Public variable to enable/disable effects */ public static boolean off = false; - + /** * A pojo to store color effect values. */ public static class ColorFx extends Fx { - + /** * Specific class handle specific borderColor shortcut properties */ @@ -33,7 +33,7 @@ public class Fx { BorderColorProperty.BORDER_TOP_COLOR_PROPERTY, BorderColorProperty.BORDER_LEFT_COLOR_PROPERTY, BorderColorProperty.BORDER_RIGHT_COLOR_PROPERTY}; - + private JsNamedArray startColors; public BorderColorFx(Element e, String endColorString) { @@ -62,7 +62,7 @@ public class Fx { // hexadecimal regex public static JsRegexp REGEX_HEX_COLOR_PATTERN = new JsRegexp( "#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})"); - + private static JsNamedArray htmlColorToRgb; // rgb and rgba regex @@ -209,7 +209,7 @@ public class Fx { } } - + public String cssprop; public double end; public double start; @@ -245,9 +245,9 @@ public class Fx { } public String toString() { - return ("cssprop=" + cssprop + (attribute != null ? " attr=" + attribute : "") + return ("cssprop=" + cssprop + (attribute != null ? " attr=" + attribute : "") + " value=" + value + " start=" + start + " end=" + end + " unit=" + unit).replaceAll("\\.0([^\\d])", "$1"); } - + } 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 52199ff6..80b73d2a 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 @@ -1,280 +1,280 @@ -/* - * Copyright 2011, The gwtquery team. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.query.client.plugins.effects; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.query.client.Function; -import com.google.gwt.query.client.GQuery; -import com.google.gwt.query.client.Properties; -import com.google.gwt.query.client.js.JsObjectArray; -import com.google.gwt.query.client.js.JsRegexp; -import com.google.gwt.query.client.plugins.Effects; -import com.google.gwt.query.client.plugins.Effects.GQAnimation; -import com.google.gwt.query.client.plugins.effects.Fx.ColorFx; -import com.google.gwt.query.client.plugins.effects.Fx.ColorFx.BorderColorFx; - -/** - * Animation effects on any numeric CSS property. - */ -public class PropertiesAnimation extends GQAnimation { - - /** - * Easing method to use. - */ - public static interface Easing { - public double interpolate(double progress); - - public Easing LINEAR = new Easing() { - public double interpolate(double progress) { - return progress; - } - }; - - public Easing SWING = new Easing() { - public double interpolate(double progress) { - return (1 + Math.cos(Math.PI + progress * Math.PI)) / 2; - } - }; - } - - private static final String[] ATTRS_TO_SAVE = new String[]{ - "overflow"}; - - private static final JsRegexp REGEX_NUMBER_UNIT = new JsRegexp( - "^([0-9+-.]+)(.*)?$"); - - private static final JsRegexp REGEX_SYMBOL_NUMBER_UNIT = new JsRegexp( - "^([+-]=)?([0-9+-.]+)(.*)?$"); - - private static final JsRegexp REGEX_NON_PIXEL_ATTRS = new JsRegexp( - "z-?index|font-?weight|opacity|zoom|line-?height|^\\$", "i"); - - private static final JsRegexp REGEX_COLOR_ATTR = new JsRegexp(".*color$", "i"); - - private static final JsRegexp REGEX_BORDERCOLOR = new JsRegexp("^bordercolor$", "i"); - - private static final JsRegexp REGEX_BACKGROUNDCOLOR = new JsRegexp("^backgroundcolor$", "i"); - - - - public static Fx computeFxProp(Element e, String key, String val, - boolean hidden) { - - if (REGEX_COLOR_ATTR.test(key)) { - return computeFxColorProp(e, key, val); - } - - return computeFxNumericProp(e, key, val, hidden); - } - - private static Fx computeFxColorProp(Element e, String key, String val) { - - if (REGEX_BORDERCOLOR.test(key)) { - return new BorderColorFx(e, val); - } - - String initialColor = null; - if (REGEX_BACKGROUNDCOLOR.test(key)) { - // find the first parent having a background-color value (other than - // transparent) - Element current = e; - - while ((initialColor == null || initialColor.length() == 0 || initialColor.equals("transparent")) - && current != null) { - initialColor = GQuery.$(current).css(key, false); - current = !"body".equalsIgnoreCase(current.getTagName()) - ? current.getParentElement() : null; - } - if (initialColor == null || initialColor.length() == 0 - || initialColor.equals("transparent")) { - initialColor = "white"; - } - } else { - initialColor = GQuery.$(e).css(key, true); - } - - return new ColorFx(key, initialColor, val); - } - - public static Fx computeFxNumericProp(Element e, String key, String val, - boolean hidden) { - - GQuery g = Effects.$(e); - String unit = ""; - if ("toggle".equals(val)) { - val = hidden ? "show" : "hide"; - } - - if (("show".equals(val) && !hidden) || ("hide").equals(val) && hidden) { - return null; - } - - if (hidden) { - g.show(); - } - - // If key starts with $ we animate node attributes, otherwise css properties - double cur; - String rkey = null; - if (key.startsWith("$")) { - rkey = key.substring(1).toLowerCase(); - String attr = g.attr(rkey); - JsObjectArray parts = REGEX_NUMBER_UNIT.match(attr); - if (parts != null) { - String $1 = parts.get(1); - String $2 = parts.get(2); - cur = Double.parseDouble($1); - unit = $2 == null ? "" : $2; - } else { - cur = g.cur(key, true); - key = rkey; - } - } else { - cur = g.cur(key, true); - } - - double start = cur, end = start; - - if ("show".equals(val)) { - g.saveCssAttrs(key); - start = 0; - unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px"; - } else if ("hide".equals(val)) { - if (hidden) { - return null; - } - g.saveCssAttrs(key); - end = 0; - unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px"; - } else { - JsObjectArray parts = REGEX_SYMBOL_NUMBER_UNIT.match(val); - - if (parts != null) { - String $1 = parts.get(1); - String $2 = parts.get(2); - String $3 = parts.get(3); - end = Double.parseDouble($2); - - if (rkey == null) { - unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : // - $3 == null || $3.isEmpty() ? "px" : $3; - if (!"px".equals(unit)) { - double to = end == 0 ? 1 : end; - g.css(key, to + unit); - start = to * start / g.cur(key, true); - g.css(key, start + unit); - } - } else if ($3 != null && !$3.isEmpty()) { - unit = $3; - } - - if ($1 != null && !$1.isEmpty()) { - end = (("-=".equals($1) ? -1 : 1) * end) + start; - } - } - } - - return new Fx(key, val, start, end, unit, rkey); - } - - private Easing easing = Easing.SWING; - private JsObjectArray effects = JsObjectArray.create(); - private Function[] funcs; - - private Effects g; - - private Properties prps; - - public PropertiesAnimation(Easing easing, Element elem, Properties p, - Function... funcs) { - this.easing = easing; - this.e = elem; - this.funcs = funcs; - this.prps = p; - g = Effects.$(e).as(Effects.Effects); - } - - @Override - public void onCancel() { - Boolean jumpToEnd = Effects.$(e).data(Effects.JUMP_TO_END, Boolean.class); - if (jumpToEnd != null && jumpToEnd){ - onComplete(); - } else { - g.dequeue(); - g.restoreCssAttrs(ATTRS_TO_SAVE); - } - } - - @Override - public void onComplete() { - super.onComplete(); - for (int i = 0; i < effects.length(); i++) { - Fx fx = effects.get(i); - if ("hide".equals(fx.value)) { - g.hide(); - g.restoreCssAttrs(fx.cssprop); - } else if ("show".equals(fx.value)) { - g.show(); - g.restoreCssAttrs(fx.cssprop); - } - } - g.restoreCssAttrs(ATTRS_TO_SAVE); - g.each(funcs); - g.dequeue(); - } - - @Override - public void onStart() { - boolean resize = false; - boolean move = false; - boolean hidden = !g.isVisible(); - Fx fx; - // g.show(); - for (String key : prps.keys()) { - String val = prps.getStr(key); - if ((fx = computeFxProp(e, key, val, hidden)) != null) { - effects.add(fx); - resize = resize || "height".equals(key) || "width".equals(key); - move = move || "top".equals(key) || "left".equals(key); - } - } - g.saveCssAttrs(ATTRS_TO_SAVE); - if (resize) { - g.css("overflow", "hidden"); - } - if (move && !g.css("position", true).matches("absolute|relative")) { - g.css("position", "relative"); - } - super.onStart(); - } - - @Override - public void onUpdate(double progress) { - for (int i = 0; i < effects.length(); i++) { - effects.get(i).applyValue(g, progress); - } - } - - @Override - protected double interpolate(double progress) { - if (easing != null) { - return easing.interpolate(progress); - } - // maybe return super.interpolate() instead ? - return progress; - } - -} +/* + * Copyright 2011, The gwtquery team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.query.client.plugins.effects; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.query.client.Function; +import com.google.gwt.query.client.GQuery; +import com.google.gwt.query.client.Properties; +import com.google.gwt.query.client.js.JsObjectArray; +import com.google.gwt.query.client.js.JsRegexp; +import com.google.gwt.query.client.plugins.Effects; +import com.google.gwt.query.client.plugins.Effects.GQAnimation; +import com.google.gwt.query.client.plugins.effects.Fx.ColorFx; +import com.google.gwt.query.client.plugins.effects.Fx.ColorFx.BorderColorFx; + +/** + * Animation effects on any numeric CSS property. + */ +public class PropertiesAnimation extends GQAnimation { + + /** + * Easing method to use. + */ + public static interface Easing { + public double interpolate(double progress); + + public Easing LINEAR = new Easing() { + public double interpolate(double progress) { + return progress; + } + }; + + public Easing SWING = new Easing() { + public double interpolate(double progress) { + return (1 + Math.cos(Math.PI + progress * Math.PI)) / 2; + } + }; + } + + private static final String[] ATTRS_TO_SAVE = new String[]{ + "overflow"}; + + private static final JsRegexp REGEX_NUMBER_UNIT = new JsRegexp( + "^([0-9+-.]+)(.*)?$"); + + private static final JsRegexp REGEX_SYMBOL_NUMBER_UNIT = new JsRegexp( + "^([+-]=)?([0-9+-.]+)(.*)?$"); + + private static final JsRegexp REGEX_NON_PIXEL_ATTRS = new JsRegexp( + "z-?index|font-?weight|opacity|zoom|line-?height|^\\$", "i"); + + private static final JsRegexp REGEX_COLOR_ATTR = new JsRegexp(".*color$", "i"); + + private static final JsRegexp REGEX_BORDERCOLOR = new JsRegexp("^bordercolor$", "i"); + + private static final JsRegexp REGEX_BACKGROUNDCOLOR = new JsRegexp("^backgroundcolor$", "i"); + + + + public static Fx computeFxProp(Element e, String key, String val, + boolean hidden) { + + if (REGEX_COLOR_ATTR.test(key)) { + return computeFxColorProp(e, key, val); + } + + return computeFxNumericProp(e, key, val, hidden); + } + + private static Fx computeFxColorProp(Element e, String key, String val) { + + if (REGEX_BORDERCOLOR.test(key)) { + return new BorderColorFx(e, val); + } + + String initialColor = null; + if (REGEX_BACKGROUNDCOLOR.test(key)) { + // find the first parent having a background-color value (other than + // transparent) + Element current = e; + + while ((initialColor == null || initialColor.length() == 0 || initialColor.equals("transparent")) + && current != null) { + initialColor = GQuery.$(current).css(key, false); + current = !"body".equalsIgnoreCase(current.getTagName()) + ? current.getParentElement() : null; + } + if (initialColor == null || initialColor.length() == 0 + || initialColor.equals("transparent")) { + initialColor = "white"; + } + } else { + initialColor = GQuery.$(e).css(key, true); + } + + return new ColorFx(key, initialColor, val); + } + + public static Fx computeFxNumericProp(Element e, String key, String val, + boolean hidden) { + + GQuery g = Effects.$(e); + String unit = ""; + if ("toggle".equals(val)) { + val = hidden ? "show" : "hide"; + } + + if (("show".equals(val) && !hidden) || ("hide").equals(val) && hidden) { + return null; + } + + if (hidden) { + g.show(); + } + + // If key starts with $ we animate node attributes, otherwise css properties + double cur; + String rkey = null; + if (key.startsWith("$")) { + rkey = key.substring(1).toLowerCase(); + String attr = g.attr(rkey); + JsObjectArray parts = REGEX_NUMBER_UNIT.match(attr); + if (parts != null) { + String $1 = parts.get(1); + String $2 = parts.get(2); + cur = Double.parseDouble($1); + unit = $2 == null ? "" : $2; + } else { + cur = g.cur(key, true); + key = rkey; + } + } else { + cur = g.cur(key, true); + } + + double start = cur, end = start; + + if ("show".equals(val)) { + g.saveCssAttrs(key); + start = 0; + unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px"; + } else if ("hide".equals(val)) { + if (hidden) { + return null; + } + g.saveCssAttrs(key); + end = 0; + unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px"; + } else { + JsObjectArray parts = REGEX_SYMBOL_NUMBER_UNIT.match(val); + + if (parts != null) { + String $1 = parts.get(1); + String $2 = parts.get(2); + String $3 = parts.get(3); + end = Double.parseDouble($2); + + if (rkey == null) { + unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : // + $3 == null || $3.isEmpty() ? "px" : $3; + if (!"px".equals(unit)) { + double to = end == 0 ? 1 : end; + g.css(key, to + unit); + start = to * start / g.cur(key, true); + g.css(key, start + unit); + } + } else if ($3 != null && !$3.isEmpty()) { + unit = $3; + } + + if ($1 != null && !$1.isEmpty()) { + end = (("-=".equals($1) ? -1 : 1) * end) + start; + } + } + } + + return new Fx(key, val, start, end, unit, rkey); + } + + private Easing easing = Easing.SWING; + private JsObjectArray effects = JsObjectArray.create(); + private Function[] funcs; + + private Effects g; + + private Properties prps; + + public PropertiesAnimation(Easing easing, Element elem, Properties p, + Function... funcs) { + this.easing = easing; + this.e = elem; + this.funcs = funcs; + this.prps = p; + g = Effects.$(e).as(Effects.Effects); + } + + @Override + public void onCancel() { + Boolean jumpToEnd = Effects.$(e).data(Effects.JUMP_TO_END, Boolean.class); + if (jumpToEnd != null && jumpToEnd){ + onComplete(); + } else { + g.dequeue(); + g.restoreCssAttrs(ATTRS_TO_SAVE); + } + } + + @Override + public void onComplete() { + super.onComplete(); + for (int i = 0; i < effects.length(); i++) { + Fx fx = effects.get(i); + if ("hide".equals(fx.value)) { + g.hide(); + g.restoreCssAttrs(fx.cssprop); + } else if ("show".equals(fx.value)) { + g.show(); + g.restoreCssAttrs(fx.cssprop); + } + } + g.restoreCssAttrs(ATTRS_TO_SAVE); + g.each(funcs); + g.dequeue(); + } + + @Override + public void onStart() { + boolean resize = false; + boolean move = false; + boolean hidden = !g.isVisible(); + Fx fx; + // g.show(); + for (String key : prps.keys()) { + String val = prps.getStr(key); + if ((fx = computeFxProp(e, key, val, hidden)) != null) { + effects.add(fx); + resize = resize || "height".equals(key) || "width".equals(key); + move = move || "top".equals(key) || "left".equals(key); + } + } + g.saveCssAttrs(ATTRS_TO_SAVE); + if (resize) { + g.css("overflow", "hidden"); + } + if (move && !g.css("position", true).matches("absolute|relative")) { + g.css("position", "relative"); + } + super.onStart(); + } + + @Override + public void onUpdate(double progress) { + for (int i = 0; i < effects.length(); i++) { + effects.get(i).applyValue(g, progress); + } + } + + @Override + protected double interpolate(double progress) { + if (easing != null) { + return easing.interpolate(progress); + } + // maybe return super.interpolate() instead ? + return progress; + } + +} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java index 682876ca..886df5b9 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java @@ -1,11 +1,11 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under @@ -35,12 +35,12 @@ import java.util.List; /** * 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 class takes care of calling the appropriate functions for each browser event and it also * calls sinkEvents method. - * + * */ public class EventsListener implements EventListener { @@ -149,9 +149,9 @@ public class EventsListener implements EventListener { /** * Remove a set of events. The bind function will not be fire anymore for those events - * + * * @param eventBits the set of events to unsink - * + * */ public int unsink(int eventBits) { if (eventBits <= 0) { @@ -183,7 +183,7 @@ public class EventsListener implements EventListener { /** * {@link BindFunction} used for live() method. - * + * */ private static class LiveBindFunction extends BindFunction { @@ -285,7 +285,7 @@ public class EventsListener implements EventListener { /** * Tell if no {@link BindFunction} are linked to this object - * + * * @return */ public boolean isEmpty() { @@ -301,7 +301,7 @@ public class EventsListener implements EventListener { /** * Return the element whose the listener fired last. It represent the context element where the * {@link LiveBindFunction} was binded - * + * */ private Element getCurrentEventTarget(Event e) { EventTarget currentEventTarget = e.getCurrentEventTarget(); @@ -446,14 +446,14 @@ public class EventsListener implements EventListener { String[] parts = events.split("[\\s,]+"); for (String event : parts) { - + String nameSpace = null; String eventName = event; - + //seperate possible namespace //jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8... String[] subparts = event.split("\\.", 2); - + if (subparts.length == 2){ nameSpace = subparts[1]; eventName = subparts[0]; @@ -601,11 +601,11 @@ public class EventsListener implements EventListener { for (String event : parts) { String nameSpace = null; String eventName = event; - + //seperate possible namespace //jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8... String[] subparts = event.split("\\.", 2); - + if (subparts.length == 2){ nameSpace = subparts[1]; eventName = subparts[0]; diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java index b8fbd90e..1a92374f 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/GqEvent.java @@ -8,34 +8,34 @@ import com.google.gwt.user.client.Event; /** * This object allows you to have a full copy of the original Event and * implements some useful method of the jQuery event model. - * + * * This is also useful in Internet Explorer because it use the same javascript * object to fire MouseDownEvent, MouseMoveEvent or MouseStopEvent on the same * element. So, we cannot keep a copy of the MouseDownEvent during a dragging * for example. - * - * - * + * + * + * * Be Careful : the methods preventDefault() and stopPropagation must be called directly on the * original event. - * - * + * + * */ public class GqEvent extends Event { - + public static native void setOriginalEventType(NativeEvent evt, String originalEventName)/*-{ evt["__gwtquery_originalEventName"] = originalEventName; }-*/; - + public static native String getOriginalEventType(Event evt)/*-{ return evt["__gwtquery_originalEventName"] || null; }-*/; - // Gwt Events class has not this event defined, - // so we have to select one power of 2 which is unused in Event class + // Gwt Events class has not this event defined, + // so we have to select one power of 2 which is unused in Event class public static int ONSUBMIT = 0x10000000; public static int ONRESIZE = 0x8000000; - + /** * Create a new {@link GqEvent} by copying the originalEvent. */ @@ -52,7 +52,7 @@ public class GqEvent extends Event { } gQueryEvent.originalEvent = originalEvent; }-*/; - + protected GqEvent() { } @@ -63,10 +63,10 @@ public class GqEvent extends Event { public final native Event getOriginalEvent()/*-{ return this.originalEvent; }-*/; - + public final native void setCurrentElementTarget(Element e)/*-{ this.currentTarget = e; - + //ie don't have a currentEventTarget field on event try{ @com.google.gwt.dom.client.DOMImplTrident::currentEventTarget = e; @@ -75,7 +75,7 @@ public class GqEvent extends Event { /** * Tell whether ctrl or cmd key is pressed - * + * */ public final boolean isMetaKeyPressed() { return getMetaKey() || getCtrlKey(); @@ -83,7 +83,7 @@ public class GqEvent extends Event { /** * The mouse position relative to the left edge of the document - * + * */ public final int pageX() { if (getTouches() != null && getTouches().length() > 0){ @@ -95,7 +95,7 @@ public class GqEvent extends Event { /** * The mouse position relative to the top edge of the document. - * + * */ public final int pageY() { if (getTouches() != null && getTouches().length() > 0){ diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java index 36d076f6..39028149 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/widgets/ButtonWidgetFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -32,11 +32,11 @@ public class ButtonWidgetFactory implements WidgetFactory" - + +"" - + +" check0" +" check1" +" check2" - + +" radio0" +" radio1" +" radio2" ); - + assertNull($().val()); assertEquals(0, $().vals().length); @@ -1000,7 +1000,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals("newval", $("#inputText", e).val()); assertEquals("newval", $("#textArea", e).val()); assertEquals("newval", $("#button", e).val()); - + assertEquals("v0", $("#selectSingle", e).val()); assertNull($("#selectMultiple", e).val()); $("#selectSingle, #selectMultiple", e).val("v2"); @@ -1017,16 +1017,16 @@ public class GQueryCoreTestGwt extends GWTTestCase { $("input[type='checkbox']", e).val(new String[]{"n0"}); assertEquals("n0", $("input[type='checkbox']", e).val()); assertNotNull($("input[type='checkbox']:checked", e).val()); - + assertEquals("v0", $("input[type='radio']", e).val()); assertNull($("input[type='radio']:checked", e).val()); $("input[type='radio']").eq(0).val("n0"); assertEquals("n0", $("input[type='radio']", e).val()); assertNull($("input[type='radio']:checked", e).val()); - + // evalJQuery("$('input, select, textarea, button').val(['whatever', 'v1', 'v2'])"); $("input, select, textarea, button").val("whatever", "v1", "v2"); - + String joinVals = "whatever,v1,v2"; assertEquals(joinVals, $("#inputText", e).val()); assertEquals(joinVals, $("#textArea", e).val()); @@ -1040,84 +1040,84 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals(1, $("input[type='radio']:checked", e).size()); assertEquals("v2", $("input[type='radio']:checked", e).val()); } - - + + public void testAttr_Issue97() { $(e).html(""); assertNull($("#cb:checked", e).val()); - + $("#cb", e).attr("checked", "checked"); assertEquals(1, $("#cb:checked", e).length()); assertEquals(true, InputElement.as($("#cb", e).get(0)).isChecked()); assertEquals("checked", $("#cb", e).get(0).getAttribute("checked")); assertEquals(true, $("#cb", e).get(0).getPropertyBoolean("checked")); - + $("#cb", e).removeAttr("checked"); assertEquals(0, $("#cb:checked", e).length()); assertEquals(false, InputElement.as($("#cb", e).get(0)).isChecked()); assertEquals("", $("#cb", e).get(0).getAttribute("checked")); assertEquals(false, $("#cb", e).get(0).getPropertyBoolean("checked")); - + $("#cb", e).attr("checked", true); assertEquals(1, $("#cb:checked", e).length()); assertEquals(true, InputElement.as($("#cb", e).get(0)).isChecked()); assertEquals("checked", $("#cb", e).get(0).getAttribute("checked")); assertEquals(true, $("#cb", e).get(0).getPropertyBoolean("checked")); - + $("#cb", e).attr("checked", false); assertEquals(0, $("#cb:checked", e).length()); assertEquals(false, InputElement.as($("#cb", e).get(0)).isChecked()); assertEquals("", $("#cb", e).get(0).getAttribute("checked")); assertEquals(false, $("#cb", e).get(0).getPropertyBoolean("checked")); - + $("#cb", e).attr("checked", ""); assertEquals(1, $("#cb:checked", e).length()); assertEquals(true, InputElement.as($("#cb", e).get(0)).isChecked()); assertEquals("checked", $("#cb", e).get(0).getAttribute("checked")); assertEquals(true, $("#cb", e).get(0).getPropertyBoolean("checked")); - + GQuery gq = $("
test"); gq.attr("class", "test1"); - + assertEquals("test1", gq.get(0).getClassName()); assertEquals("test1", gq.attr("class")); assertNull(gq.get(0).getPropertyString("class")); - + gq.removeAttr("class"); assertEquals("", gq.get(0).getClassName()); assertEquals("", gq.attr("class")); - + //test on value $("#cb", e).attr("value", "mail"); assertEquals("mail", InputElement.as($("#cb", e).get(0)).getValue()); assertEquals("mail", $("#cb", e).get(0).getAttribute("value")); - + $("#cb", e).removeAttr("value"); String val = InputElement.as($("#cb", e).get(0)).getValue(); assertTrue(String.valueOf(val).matches("^(|null|on)$")); - + val = $("#cb", e).get(0).getAttribute("value"); assertTrue(String.valueOf(val).matches("^(|null|on)$")); - + try{ $("#cb", e).attr("type", "hidden"); fail("Cannnot change a type of an element already attached to the dom"); }catch (Exception e){} - + gq = $(""); gq.attr("type", "radio"); assertEquals("radio", InputElement.as(gq.get(0)).getType()); assertEquals("blop", InputElement.as(gq.get(0)).getValue()); - + gq.attr(Properties.create("{class:'test2', disabled:true}")); InputElement ie = InputElement.as(gq.get(0)); - + assertEquals("test2", ie.getClassName()); assertEquals(true, ie.isDisabled()); assertEquals("disabled", ie.getAttribute("disabled")); - + } - + @DoNotRunWith({Platform.Prod}) // FIXME: the hidden part does not work in FF nor Chrome public void testWidthHeight() { @@ -1140,10 +1140,10 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals(122, g.outerWidth()); assertEquals(142, g.outerHeight(true)); assertEquals(142, g.outerWidth(true)); - + // When hiding the element we should get the same sizes $(e).hide(); - + assertEquals(100, g.width()); assertEquals(100, g.height()); assertEquals("h1", 120, g.innerWidth()); @@ -1161,7 +1161,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals(142, g.outerHeight(true)); assertEquals(142, g.outerWidth(true)); } - + public void testWidthHeightInlineElement() { $(e).html( "Content 1"); @@ -1186,7 +1186,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertHtmlEquals(expected, $(e).html()); } - + public void testFilterBody() { GQuery myNewElement = $("
my new div
"); boolean isAttachedToTheDOM = myNewElement.parents().filter("body").size() > 0; @@ -1196,35 +1196,35 @@ public class GQueryCoreTestGwt extends GWTTestCase { isAttachedToTheDOM = myNewElement.parents().filter("body").size() > 0; assertEquals(true, isAttachedToTheDOM); } - + public void testFilterMethod(){ // first test filter on element attached to the DOM String content = "
Hello blop
And
Goodbye
"; $(e).html(content); - + assertEquals(5, $("*", e).length()); assertEquals(4, $("*", e).filter("div").length()); assertEquals(1, $("*", e).filter("div.outer").length()); assertEquals(3, $("*", e).filter("div.inner").length()); assertEquals(1, $("*", e).filter("span").length()); - + GQuery $html = $("
div1
div2
div3
span1"); assertEquals(3, $html.filter("div").length()); assertEquals(1, $html.filter("span").length()); - + JsNodeArray array = JsNodeArray.create(); for (int i = 0 ; i < 3; i++){ array.addNode(DOM.createDiv()); } - assertEquals(3, $(array).filter("div").length()); - - + assertEquals(3, $(array).filter("div").length()); + + String content2 = "
Hello
And
Goodbye
"; $(e).html(content2); //the inner object contains the 3 div that are detached from the dom GQuery $inner = $(".inner").replaceWith("

blop

"); - assertEquals(3, $inner.filter("div").length()); + assertEquals(3, $inner.filter("div").length()); } public void testGQueryWidgets() { @@ -1253,9 +1253,9 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals(2, $(new Label(""), new TextArea()).size()); } - + public void testGQueryWidgetManipulation() { - + String content = "
"; $(e).html(content); Button b = new Button("b"); @@ -1263,14 +1263,14 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertTrue(b.isAttached()); $("button").remove(); assertFalse(b.isAttached()); - + RootPanel.get().add(b); assertTrue(b.isAttached()); $(e).append($(b)); assertTrue(b.isAttached()); $(e).empty(); // FIXME: assertFalse(b.isAttached()); - + } public void testGQueryMap() { @@ -1308,33 +1308,33 @@ public class GQueryCoreTestGwt extends GWTTestCase { } public void testHtmlSnippet(){ - - GQuery gq = $("
blop

test

test"); + + GQuery gq = $("
blop

test

test"); assertEquals(3, gq.size()); assertEquals("DIV", gq.get(0).getTagName().toUpperCase()); assertEquals("P", gq.get(1).getTagName().toUpperCase()); assertEquals("SPAN", gq.get(2).getTagName().toUpperCase()); - + //xhtml tag - gq = $("
"); + gq = $("
"); assertEquals(1, gq.size()); assertEquals("DIV", gq.get(0).getTagName().toUpperCase()); - - gq = $(""); + + gq = $(""); assertEquals(1, gq.size()); assertEquals("A", gq.get(0).getTagName().toUpperCase()); - - gq = $("
"); + + gq = $("
"); assertEquals(1, gq.size()); assertEquals("DIV", gq.get(0).getTagName().toUpperCase()); - + //issue 81 : trailing spaces - gq = $("
blop

test

test "); + gq = $("
blop

test

test "); assertEquals(3, gq.size()); assertEquals("DIV", gq.get(0).getTagName().toUpperCase()); assertEquals("P", gq.get(1).getTagName().toUpperCase()); assertEquals("SPAN", gq.get(2).getTagName().toUpperCase()); - + //wrapping gq = $("bloptest"); assertEquals(2, gq.size()); @@ -1345,42 +1345,42 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals(2, gq.size()); assertEquals("TR", gq.get(0).getTagName().toUpperCase()); assertEquals("TR", gq.get(1).getTagName().toUpperCase()); - + gq = $("bloptest"); assertEquals(2, gq.size()); assertEquals("TD", gq.get(0).getTagName().toUpperCase()); assertEquals("TD", gq.get(1).getTagName().toUpperCase()); - + gq = $("bloptest"); assertEquals(2, gq.size()); assertEquals("TH", gq.get(0).getTagName().toUpperCase()); assertEquals("TH", gq.get(1).getTagName().toUpperCase()); - + gq = $(""); assertEquals(2, gq.size()); assertEquals("COL", gq.get(0).getTagName().toUpperCase()); assertEquals("COL", gq.get(1).getTagName().toUpperCase()); - + gq = $(""); assertEquals(2, gq.size()); assertEquals("AREA", gq.get(0).getTagName().toUpperCase()); assertEquals("AREA", gq.get(1).getTagName().toUpperCase()); - + gq = $(""); assertEquals(2, gq.size()); assertEquals("OPTION", gq.get(0).getTagName().toUpperCase()); assertEquals("OPTION", gq.get(1).getTagName().toUpperCase()); - + gq = $("bloptest"); assertEquals(2, gq.size()); assertEquals("LEGEND", gq.get(0).getTagName().toUpperCase()); assertEquals("LEGEND", gq.get(1).getTagName().toUpperCase()); - + gq = $("bloptest"); assertEquals(2, gq.size()); assertEquals("THEAD", gq.get(0).getTagName().toUpperCase()); assertEquals("THEAD", gq.get(1).getTagName().toUpperCase()); - + //issue gq = $("

"; $(e).html(html); - + GQuery closeP = $("input", e).closest("p,div"); - + assertEquals(1, closeP.length()); assertEquals("firstP", closeP.get(0).getId()); - + GQuery closeDiv = $("input", e).closest("div"); - + assertEquals(1, closeDiv.length()); assertEquals("firstDiv", closeDiv.get(0).getId()); - + GQuery closeInput = $("input", e).closest("input"); - + assertEquals(1, closeInput.length()); assertEquals("firstInput", closeInput.get(0).getId()); - + GQuery closeUnknown = $("input", e).closest("h1"); - + assertEquals(0, closeUnknown.length()); - + GQuery closePWithContext = $("input", e).closest("p,div",$("#firstDiv",e).get(0)); - + assertEquals(1, closePWithContext.length()); assertEquals("firstP", closePWithContext.get(0).getId()); - + GQuery closeDivWithContext = $("input", e).closest("div",$("#firstP",e).get(0)); - - assertEquals(0, closeDivWithContext.length()); - + + assertEquals(0, closeDivWithContext.length()); + } - + public void testClosestMethodWithArrayOfString(){ - + String html = "

"; $(e).html(html); - + JsNamedArray> close = $("input", e).closest(new String[]{"p","div", ".test", "#unknown"}); - + assertEquals(3, close.length()); - + assertNotNull(close.get("p")); assertEquals(1,close.get("p").getLength()); assertEquals("mainP", close.get("p").getItem(0).getId()); - + assertNotNull(close.get("div")); assertEquals(3,close.get("div").getLength()); assertEquals("subSubDiv", close.get("div").getItem(0).getId()); assertEquals("subDiv", close.get("div").getItem(1).getId()); assertEquals("mainDiv", close.get("div").getItem(2).getId()); - + assertNotNull(close.get(".test")); assertEquals(2,close.get(".test").getLength()); assertEquals("testSpan", close.get(".test").getItem(0).getId()); assertEquals("subDiv", close.get(".test").getItem(1).getId()); - + assertNull(close.get("#unknown")); - + } - + public void testMap() { String html = "
" + "" + @@ -1654,10 +1654,10 @@ public class GQueryCoreTestGwt extends GWTTestCase { "" + ""; $(e).html(html); - + GQuery c = $(e).children(); assertEquals(7, c.size()); - + // A list of lists containing tag,class,id, remove elements without id List> m = $(e).children().map(new Function() { public List f(Element e, int i) { @@ -1673,7 +1673,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { } }); assertEquals(6, m.size()); - + // Sort the list by id assertEquals("div", m.get(0).get(0).toLowerCase()); assertEquals("i", m.get(5).get(0).toLowerCase()); @@ -1685,13 +1685,13 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals("div", m.get(5).get(0).toLowerCase()); assertEquals("i", m.get(0).get(0).toLowerCase()); } - + public void testWindowSize() { GQuery w = $(GQuery.window); assertTrue(w.width() > 0); assertTrue(w.height() > 0); } - + public void testFunction() { $(e).html("
0
"); GQuery g = $("#fid", e); @@ -1728,7 +1728,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { } }); assertEquals("D0", g.text()); - + // EVENTS g.unbind(Event.ONCLICK).click(new Function(){ @Override @@ -1760,13 +1760,13 @@ public class GQueryCoreTestGwt extends GWTTestCase { } }).click(); assertEquals("ED", g.text()); - + // ELEMENTS AND WIDGETS Label label = new Label("1"); RootPanel.get().add(label); g = $("#fid, .gwt-Label"); assertEquals(2, g.size()); - + g.each(new Function() { @Override public void f(com.google.gwt.user.client.Element e) { @@ -1781,7 +1781,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { } }); assertEquals("DD", g.text()); - + g.each(new Function() { @Override public void f(com.google.gwt.user.client.Element e) { @@ -1804,7 +1804,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { } }); assertEquals("DW", g.text()); - + g.each(new Function() { @Override public Object f(com.google.gwt.user.client.Element e, int idx) { @@ -1876,7 +1876,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { label.removeFromParent(); } - + public void testXpathSelector() { $(e).html("
A TextB
"); SelectorEngineCssToXPath s = new SelectorEngineCssToXPath(); @@ -1885,13 +1885,13 @@ public class GQueryCoreTestGwt extends GWTTestCase { assertEquals($(selector).size(), $(xselector).size()); } } - + public void testIssue81(){ GQuery test = $("
blop

test2

"); test.addClass("test"); test.removeClass("test"); } - + public void testHas() { $(e).html("
    " +"
  • list item 1
  • " @@ -1901,7 +1901,7 @@ public class GQueryCoreTestGwt extends GWTTestCase { +"
  • list item 2-b
  • " +"
" +"" - +"
  • list item 3 span" + +"
  • list item 3 span" +"
  • " +"
  • list item 4
  • " +""); @@ -1912,16 +1912,16 @@ public class GQueryCoreTestGwt extends GWTTestCase { Element span = $("span", e).get(0); assertEquals("l3", $("li", e).has(span).id()); } - + public void testDetachedElement(){ GQuery view = $("
    "); - + int viewWidth = view.width(); - + assertEquals(300, viewWidth); - + int innerViewWidth = view.children().width(); - + assertEquals(150, innerViewWidth); } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java index 10ed3caa..ea9b91dd 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCssTestGwt.java @@ -1,12 +1,12 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -70,7 +70,7 @@ public class GQueryCssTestGwt extends GWTTestCase { public String getModuleName() { return "com.google.gwt.query.Query"; } - + public void gwtTearDown() { $(e).remove(); e = null; @@ -135,12 +135,12 @@ public class GQueryCssTestGwt extends GWTTestCase { assertTrue($("#test").css("backgroundImage").contains("image.jpg")); assertTrue($("#test").css(CSS.BACKGROUND_IMAGE).contains("image.jpg")); } - + void assertMatches(String regex, String test) { boolean b = test.matches("^(" + regex + ")$"); assertTrue("assertMatches error, expected:" + regex + ", actual:" + test, b); } - + public void testBackgroundPositionProperty() { $(e).html("
    Content
    "); @@ -209,7 +209,7 @@ public class GQueryCssTestGwt extends GWTTestCase { CSS.BACKGROUND.with(RGBColor.TRANSPARENT, UriValue.url("back.jpg"), BackgroundRepeat.NO_REPEAT, BackgroundAttachment.SCROLL, BackgroundPosition.CENTER)); - + assertMatches(".*back.jpg.*no-repeat scroll (center|center center|50% 50%).*", $("#test").css("background")); } @@ -448,7 +448,7 @@ public class GQueryCssTestGwt extends GWTTestCase { $("#test").css(CSS.COLOR.with(RGBColor.BLACK)); assertEquals("black", $("#test").css(CSS.COLOR, false)); - + $("#test").css(CSS.COLOR.with(RGBColor.BLUE)); assertEquals("blue", $("#test").css(CSS.COLOR, false)); @@ -457,7 +457,7 @@ public class GQueryCssTestGwt extends GWTTestCase { $("#test").css(CSS.COLOR.with(RGBColor.GRAY)); assertEquals("gray", $("#test").css(CSS.COLOR, false)); - + $("#test").css(CSS.COLOR.with(RGBColor.GREY)); assertMatches("grey|rgb\\(128, *128, *128\\)", $("#test").css(CSS.COLOR, false)); @@ -663,7 +663,7 @@ public class GQueryCssTestGwt extends GWTTestCase { $("#test").css(CSS.HEIGHT.with(Length.pt(10))); assertEquals("10pt", $("#test").css(CSS.HEIGHT, false)); - + $("#test").css(CSS.HEIGHT.with(Length.px(10.1))); assertEquals("10.1px", $("#test").css(CSS.HEIGHT, false)); @@ -714,7 +714,7 @@ public class GQueryCssTestGwt extends GWTTestCase { $("#test").css(CSS.LINE_HEIGHT.with(2)); assertEquals("2", $("#test").css("lineHeight", false)); assertEquals("2", $("#test").css(CSS.LINE_HEIGHT, false)); - + $("#test").css(CSS.LINE_HEIGHT.with(2.5)); assertEquals("2.5", $("#test").css("lineHeight", false)); assertEquals("2.5", $("#test").css(CSS.LINE_HEIGHT, false)); @@ -746,7 +746,7 @@ public class GQueryCssTestGwt extends GWTTestCase { public void testListStyleProperty() { $(e).html("
    • Content
    "); - + assertMatches("(disc |)(outside |)(none|)", $("#test").css("listStyle")); $("#test").css( @@ -754,7 +754,7 @@ public class GQueryCssTestGwt extends GWTTestCase { null)); assertMatches("disc outside( none|)", $("#test").css("listStyle")); assertMatches("disc outside( none|)", $("#test").css(CSS.LIST_STYLE)); - + $("#test").css( CSS.LIST_STYLE.with(ListStyleType.DISC, null, UriValue.url("square.jpg"))); assertMatches("disc (outside |)url\\(.*square.jpg.*\\)", $("#test").css("listStyle")); @@ -784,7 +784,7 @@ public class GQueryCssTestGwt extends GWTTestCase { assertEquals("10px 20px", $("#test").css("margin")); assertEquals("10px 20px", $("#test").css(CSS.MARGIN)); - + $("#test").css(CSS.MARGIN.with(Length.px(10), Length.px(20), Length.px(30))); assertEquals("10px 20px 30px", $("#test").css("margin")); @@ -1019,11 +1019,11 @@ public class GQueryCssTestGwt extends GWTTestCase { public void testVerticalAlignProperty() { $(e).html("
    Content
    "); - + $("#test").css(CSS.VERTICAL_ALIGN.with(Length.px(120))); assertEquals("120px", $("#test").css("verticalAlign")); assertEquals("120px", $("#test").css(CSS.VERTICAL_ALIGN)); - + $("#test").css(CSS.VERTICAL_ALIGN.with(VerticalAlign.BASELINE)); assertEquals("baseline", $("#test").css("verticalAlign")); assertEquals("baseline", $("#test").css(CSS.VERTICAL_ALIGN)); @@ -1127,7 +1127,7 @@ public class GQueryCssTestGwt extends GWTTestCase { $("#test").css(CSS.ZINDEX.with(1000)); assertEquals("1000", $("#test").css("zIndex", true)); assertEquals("1000", $("#test").css(CSS.ZINDEX, true)); - + $("#test").css(CSS.ZINDEX.with(null)); assertMatches("0|auto", $("#test").css("zIndex", true)); assertMatches("0|auto", $("#test").css(CSS.ZINDEX, true)); diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java index 4ef2e86e..531f58c3 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEffectsTestGwt.java @@ -1,12 +1,12 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -64,10 +64,10 @@ public class GQueryEffectsTestGwt extends GWTTestCase { public void testClipAnimation() { $(e).html("

    Content 1

    "); - + final GQuery g = $("#idtest"); final int duration = 1000; - + // Clip effect places a relative div in the position of the original element // So check that there is not any div. GQuery back = $("div", e); @@ -78,10 +78,10 @@ public class GQueryEffectsTestGwt extends GWTTestCase { // Check that the back div has been created back = $("div", e); assertEquals(1, back.size()); - + // Configure the max duration for this test delayTestFinish(duration * 2); - + // each timer calls the next one //final Timer timer1 = new Timer() { //public void run() { @@ -102,24 +102,24 @@ public class GQueryEffectsTestGwt extends GWTTestCase { //timer1.schedule(duration/2 + 1); } }; - + // Start the first timer timer2.schedule(duration/2); - } + } public void testEffectsShouldBeQueued() { $(e).html("

    Content 1

    "); final GQuery g = $("#idtest").css("position", "absolute"); final Offset o = g.offset(); - + final int duration = 1000; g.as(Effects.Effects). animate($$("left: '+=100'"), duration, Easing.LINEAR). animate($$("top: '+=100'"), duration, Easing.LINEAR). animate($$("left: '-=100'"), duration, Easing.LINEAR). animate($$("top: '-=100'"), duration, Easing.LINEAR); - + // Configure the max duration for this test delayTestFinish(duration * 4); @@ -152,7 +152,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase { // Start the first timer timer4.schedule(duration/2); } - + public void testFade() { $(e) .html( @@ -160,7 +160,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase { final GQuery sectA = $("#id1"); final GQuery sectB = $("#id2"); - + // fadeIn() & fadeOut() are tested with delayed assertions sectA.hide(); sectA.fadeIn(2000); @@ -210,7 +210,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase { // schedule the delayed assertions timerShortTime.schedule(200); timerMidTime.schedule(1200); - timerLongTime.schedule(2200); + timerLongTime.schedule(2200); } public void testPropertiesAnimationComputeEffects() { @@ -295,36 +295,36 @@ public class GQueryEffectsTestGwt extends GWTTestCase { PropertiesAnimation.computeFxProp(g.get(0), "padding", "20px", false) .toString()); } - + public void testColorEffectParsing(){ String html = "
    Test
    "; $(e).html(html); - + ColorFx effect = (ColorFx) PropertiesAnimation.computeFxProp($("#test",e).get(0), "color", "#ffffff", false); assertEquals(17, effect.getStartColor()[0]); //#11 assertEquals(34, effect.getStartColor()[1]); //#22 assertEquals(51, effect.getStartColor()[2]); //#33 - + assertEquals(255, effect.getEndColor()[0]); assertEquals(255, effect.getEndColor()[1]); assertEquals(255, effect.getEndColor()[2]); - + effect = (ColorFx) PropertiesAnimation.computeFxProp(e, "color", "rgb(255,255,255)", false); assertEquals(255, effect.getEndColor()[0]); assertEquals(255, effect.getEndColor()[1]); assertEquals(255, effect.getEndColor()[2]); - + effect = (ColorFx) PropertiesAnimation.computeFxProp(e, "color", "rgb(100%, 100%, 100%)", false); assertEquals(255, effect.getEndColor()[0]); assertEquals(255, effect.getEndColor()[1]); assertEquals(255, effect.getEndColor()[2]); - + effect = (ColorFx) PropertiesAnimation.computeFxProp(e, "color", "white", false); assertEquals(255, effect.getEndColor()[0]); assertEquals(255, effect.getEndColor()[1]); assertEquals(255, effect.getEndColor()[2]); } - + private void assertPosition(GQuery g, Offset min, Offset max) { int a = Math.min(min.top, max.top); int b = Math.max(min.top, max.top); @@ -342,21 +342,21 @@ public class GQueryEffectsTestGwt extends GWTTestCase { + " - " + b; assertTrue(msg, c); } - + public void testAttrEffect() { $(e).html("
    AB
    "); final GQuery g = $("#idtest").css("position", "absolute"); final int duration = 500; - - assertEquals("cssprop=$width attr=width value=+=100 start=440 end=540 unit=", + + assertEquals("cssprop=$width attr=width value=+=100 start=440 end=540 unit=", PropertiesAnimation.computeFxProp(g.get(0), "$width", "+=100", false).toString()); - + delayTestFinish(duration * 3); g.as(Effects.Effects). animate($$("$width: +=100; $border: +=4"), duration, Easing.LINEAR); - + final Timer timer = new Timer() { public void run() { assertEquals(540.0, Double.parseDouble(g.attr("width"))); @@ -366,7 +366,7 @@ public class GQueryEffectsTestGwt extends GWTTestCase { }; timer.schedule(duration * 2); } - + public void testStop() { $(e) .html( @@ -375,28 +375,28 @@ public class GQueryEffectsTestGwt extends GWTTestCase { final GQuery sectA = $("#id1"); final GQuery sectB = $("#id2"); final GQuery sectC = $("#id2"); - + sectA.hide(); sectA.fadeIn(2000); sectB.fadeOut(2000).delay(500).fadeIn(1000); sectC.fadeOut(2000).delay(500).fadeIn(1000); - // Call stop + // Call stop Timer timerMidTime = new Timer() { public void run() { sectA.stop(); sectB.stop(true, true); sectC.stop(false, false); - + Double o = Double.valueOf(sectA.css("opacity")); sectA.data("opacityA", o); assertTrue( "'sectA' opacity must be in the interval 0.5-1 but is: " + o, o > 0.5 && o < 1); - + //animation should jump to the end assertEquals("none", sectB.css("display")); - + o = Double.valueOf(sectC.css("opacity")); sectC.data("opacityC", o); assertTrue( @@ -404,16 +404,16 @@ public class GQueryEffectsTestGwt extends GWTTestCase { o > 0 && o < 0.5); } }; - - + + Timer timerLongTime = new Timer() { public void run() { Double midAOpacity = sectA.data("opacityA", Double.class); //animation was stopped, opacity should not change assertEquals(midAOpacity, Double.valueOf(sectA.css("opacity"))); //animation was stopped and jumped to the end, the queue was cleared so no change too. - assertEquals("none", sectB.css("display")); - + assertEquals("none", sectB.css("display")); + //fadeOut was stopped but fadeIn should continue Double midCOpacity = sectC.data("opacityC", Double.class); Double laterCOpacity = Double.valueOf(sectC.css("opacity")); @@ -427,24 +427,24 @@ public class GQueryEffectsTestGwt extends GWTTestCase { timerMidTime.schedule(1200); // schedule timer timerLongTime.schedule(2200); - + } - + // This test is used to demonstrate the issue, dont run it normally to avoid // problems during the testing phase int animationRunCounter = 0; public void ignore_testQueuesAndDataLeaks_issue132() { - + final Widget w = new Label("some animation"); w.setVisible(false); RootPanel.get().add(w); w.getElement().setId("e"); GQuery g = $(w); - + int test_duration = 1000; int fx_duration = 200; final int loops = test_duration / fx_duration; - + // Queue a set of effects which will use the data cache for (int i = 0; i < loops ; i++) { final char[] bulk = new char[5*1024*1024]; // let's leak 5MBs @@ -455,14 +455,14 @@ public class GQueryEffectsTestGwt extends GWTTestCase { } }); } - + // Testing delay as well g.delay(fx_duration, new Function(){ public void f() { animationRunCounter ++; } }); - + // We do the assertions after all effects have been run g.queue(new Function() { public void f() { @@ -471,20 +471,20 @@ public class GQueryEffectsTestGwt extends GWTTestCase { $(this).dequeue(); // Check that all animations and the delayed function has been run assertEquals(loops + 1, animationRunCounter); - + // Check that nothings is left in the dataCache object assertEquals(0, GQuery.dataCache.length()); - + // Check that getting queue size does not initialize the data // object for this object assertEquals(0, $(this).queue()); assertEquals(0, GQuery.dataCache.length()); - + // Mark the test as success and stop delay timer finishTest(); }; }); - + // delay the test enough to run all animations delayTestFinish(test_duration * 2); } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java index abe708bb..fbc4c3e8 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java @@ -1,11 +1,11 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under @@ -880,7 +880,7 @@ public class GQueryEventsTestGwt extends GWTTestCase { $("p", e, Events.Events).bind("click", "red",new Function() { public void f(Element elem) { $(elem).css(CSS.FONT_SIZE.with(Length.px(24))); - + assertEquals("red", getData()[0]); } }); @@ -958,7 +958,7 @@ public class GQueryEventsTestGwt extends GWTTestCase { finishTest(); } }); - + Window.resizeTo(w.width(), w.height() + 100); } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java index 3884286c..f89c7aaa 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryJsTestGwt.java @@ -1,12 +1,12 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -55,7 +55,7 @@ public class GQueryJsTestGwt extends GWTTestCase { public void testJsCache() { String[] slist = new String[]{"A", "B", "C"}; - + JsCache c = JsCache.create(); assertTrue(c.isEmpty()); for (int i=0; i < slist.length; i++) { @@ -77,52 +77,52 @@ public class GQueryJsTestGwt extends GWTTestCase { assertEquals(7, c.length()); assertEquals(7, c.keys().length); assertEquals(7, c.elements().length); - + assertTrue(c.exists(2)); assertFalse(c.exists(3)); assertTrue(c.exists("X")); assertFalse(c.exists("V")); - + c.delete(2); c.delete("C"); assertEquals(5, c.length()); - + c.put(-1, "N"); assertEquals(6, c.length()); assertEquals("N", c.get(-1)); } - + public void testChrome__gwt_ObjectId() { JsCache a = JsCache.create(); assertEquals(0, a.length()); assertEquals(0, a.keys().length); assertEquals(0, a.elements().length); - + a.put("obj", new Long(21)); assertEquals(1, a.length()); assertEquals(1, a.keys().length); assertEquals(1, a.elements().length); - + JsNodeArray n = JsNodeArray.create(); assertEquals(0, n.getLength()); assertEquals(0, n.cast().keys().length); assertEquals(0, n.elements().length); - + n.addNode($("
    ").get(0)); assertEquals(1, n.getLength()); assertEquals(1, n.cast().keys().length); assertEquals(1, n.elements().length); } - + public void testProperties() { Properties p = $$("b: 'a'; c: 1, /*gg: aadf*/d: url('https://test.com');"); assertEquals(3, p.keys().length); assertEquals("url(https://test.com)", p.getStr("d")); - + p = $$("color: 'rgb(0, 0,139)', background: red"); assertEquals(2, p.keys().length); assertEquals("rgb(0,0,139)", p.getStr("color")); - + p = $$("a: 1, b: 0.5, c: null, d: whatever, e: true, f: false"); assertEquals(1, p.getInt("a")); assertEquals(0.5f, p.getFloat("b")); diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java index 96cce2e4..efd8953d 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQuerySelectorsTestGwt.java @@ -1,12 +1,12 @@ /* * Copyright 2011, The gwtquery team. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -42,22 +42,22 @@ import com.google.gwt.user.client.ui.RootPanel; * Test for selectors */ public class GQuerySelectorsTestGwt extends GWTTestCase { - + boolean runSlow = false; protected interface ParentSelector extends Selectors { @Selector("#parent") GQuery parentSelector(); - + } - + protected interface ExtendedSelector extends ParentSelector { - + @Selector("#child") GQuery childSelector(); } - - + + protected interface AllSelectors extends Selectors { @Selector("h1[id]:contains(Selectors)") NodeList h1IdContainsSelectors(); @@ -160,7 +160,7 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { GQuery branchB(); @Selector(".branchB") GQuery branchB(Node n); - + @Selector("div .target") GQuery divTarget(); @Selector("div .target") @@ -186,7 +186,7 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { $(e).remove(); e = null; } - + public void gwtSetUp() { if (e == null) { testPanel = new HTML(); @@ -197,19 +197,19 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { e.setInnerHTML(""); } } - + public void testInhiterance(){ final ExtendedSelector selector = GWT.create(ExtendedSelector.class); - + $(e).html("
    parent
    child
    "); - + assertEquals(1, selector.parentSelector().length()); assertEquals(1, selector.childSelector().length()); - + assertEquals("parentchild", selector.parentSelector().text()); assertEquals("child", selector.childSelector().text()); } - + public void testJQueryPseudoselectors() { $(e).html("
    A Text

    "); assertEquals(9, $("* ", e).size()); @@ -228,7 +228,7 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { // TODO: fix these selectors // sel.divWithClassNotContainsMadeup().getLength() // sel.divCommaPA().getLength() - + // assertArrayContains(sel.title().getLength(), 1); assertEquals(1, sel.body().getLength()); assertArrayContains(sel.bodyDiv().getLength(), 53, 55); @@ -270,13 +270,13 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { assertArrayContains(sel.ulTocline2().getLength(), 12); assertArrayContains(sel.ulTocLiTocLine2().getLength(), 12); } - + public void testIssue12() { $(e).html("

    1

    2
    "); executeSelectInAllImplementations(":checked", e, 1); executeSelectInAllImplementations(":disabled", e, 1); executeSelectInAllImplementations("input:enabled", e, 1); -// FIXME, these two selectors fails in prod with chrome when using both Xpath engines +// FIXME, these two selectors fails in prod with chrome when using both Xpath engines // executeSelectInAllImplementations("[myCustomAttr]", e, 2); // executeSelectInAllImplementations("*[myCustomAttr]", e, 2); executeSelectInAllImplementations("input[name=wantedName]", e, 1); @@ -325,7 +325,7 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { SelectorEngineImpl selEng = new SelectorEngineXPath(); executeSelectorEngineTests(selEng); } - + public void testSelectorsGeneratorNative() { $(e).html( "1" @@ -334,17 +334,17 @@ public class GQuerySelectorsTestGwt extends GWTTestCase { TestSelectors selectors = GWT.create(TestSelectors.class); assertEquals(1, selectors.allChecked().size()); } - + public void testSelectorsInIframe() { $(e).html("