}
close(F);
-my $class = "public interface $oclass";
+my $class = "/**\n * $oclass.\n * \@param <T>\n */\npublic interface $oclass";
if ($lazy) {
$class .= "<T> extends LazyBase<T>" if ($lazy);
$head .= "import com.google.gwt.query.client.GQuery.*;\n";
<property name="checkHtml" value="false"/>
<property name="tokens" value="CLASS_DEF,CTOR_DEF,INTERFACE_DEF,METHOD_DEF,VARIABLE_DEF"/>
</module>
- <module name="NeedBraces">
- <metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="make sure if has braces"/>
- </module>
<module name="JavadocMethod">
<metadata name="com.atlassw.tools.eclipse.checkstyle.lastEnabledSeverity" value="info"/>
<property name="severity" value="info"/>
</module>
<module name="MethodName">
<property name="severity" value="error"/>
- <property name="format" value="^[a-z$][a-zA-Z0-9]*$"/>
+ <property name="format" value="^[a-z$XJD:][a-zA-Z0-9$]*$"/>
</module>
<module name="MemberName">
<metadata name="com.atlassw.tools.eclipse.checkstyle.comment" value="Field names must start with [a-z], may not start with f[A-Z], and should not contain '_''s."/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="250"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
*/
package com.google.gwt.query.client;
-import com.google.gwt.query.rebind.BrowserGenerator;
-
/**
* This class is the equivalent to the jQuery.browser object in gQuery.
*
*/
public final boolean opera = isOpera();
/**
- * Maintained for jQuery compatibility
+ * Maintained for jQuery compatibility.
* @return true if webkit
* @deprecated use webkit() instead
*/
}
/**
- * Set the list of arguments to be passed to the function
+ * Set the list of arguments to be passed to the function.
*/
public Function setArguments(Object...arguments) {
this.arguments = arguments;
}
/**
- * Return the first element of the arguments list
+ * Return the first element of the arguments list.
+ *
* @deprecated use getArgument(idx) instead.
*/
@Deprecated
}
/**
- * @deprecated use getArgument instead
+ * @deprecated use getArgument instead.
*/
@Deprecated
public Object getDataObject(int idx) {
}
/**
- * Convenience alias for the getArguments(argIdx, pos) method;
+ * Convenience alias for the getArguments(argIdx, pos) method.
*/
public <T> T arguments(int argIdx, int pos) {
return getArgument(argIdx, pos);
}
/**
- * @deprecated use: getArgument()
+ * @deprecated use: getArgument() instead.
*/
@Deprecated
public Properties getDataProperties() {
}
/**
- * @deprecated use: getArgument(idx)
+ * @deprecated use: getArgument(idx) instead.
*/
@Deprecated
public Properties getDataProperties(int idx) {
}
/**
- * @deprecated use: setArguments()
+ * @deprecated use: setArguments() instead.
*/
@Deprecated
public void setData(boolean b) {
}
/**
- * @deprecated use: setArguments()
+ * @deprecated use: setArguments() instead.
*/
@Deprecated
public void setData(double b) {
}
/**
- * @deprecated use use setArguments instead
+ * @deprecated use use setArguments instead.
*/
@Deprecated
public void setData(Object...arguments) {
}
/**
- * Return the index in a loop execution. Used in GQuery.each()
+ * Return the index in a loop execution.
+ *
+ * Used in GQuery.each()
*/
public int getIndex() {
return index;
}
/**
- * Override this method for bound callbacks
+ * Override this method for bound callbacks.
*/
public Object f(Object... args) {
setArguments(args);
}
/**
- * Override this method for bound callbacks
+ * Override this method for bound callbacks.
*/
public void f(int i, Object arg) {
f(i, new Object[]{arg});
}
/**
- * Override this method for bound callbacks
+ * Override this method for bound callbacks.
*/
public void f(int i, Object... args) {
setIndex(i);
/**
* 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 arg) {
fe(new Object[]{arg});
/**
* 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 Object fe(Object... args) {
if (GWT.getUncaughtExceptionHandler() != null) {
/**
* 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... args) {
if (GWT.getUncaughtExceptionHandler() != null) {
/**
* 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) {
}
/**
- * Create an instance of a JsonBuilder object whose type is <T>
+ * Create an instance of a JsonBuilder object whose type is <T>.
*/
public static <T extends JsonBuilder> T create(Class<T> clz) {
return getFactory().create(clz);
/**
* Return the appropriate transport implementation depending on the runtime
- * environment: browser or JVM
+ * environment: browser or JVM.
*/
public static AjaxTransport getAjaxTransport() {
initFactory();
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
/**
* GwtQuery is a GWT clone of the popular jQuery library.
}
/**
- * Class used internally to create DOM element from html snippet
+ * Class used internally to create DOM element from html snippet.
*/
private static class TagWrapper {
public static final TagWrapper DEFAULT = new TagWrapper(0, "", "");
public static final Document document = GWT.isClient() ? Document.get() : null;
/**
- * Static reference Effects plugin
+ * Static reference Effects plugin.
*/
public static Class<Effects> Effects = com.google.gwt.query.client.plugins.Effects.Effects;
protected static SelectorEngine engine;
/**
- * Static reference Events plugin
+ * Static reference Events plugin.
*/
public static Class<Events> Events = com.google.gwt.query.client.plugins.Events.Events;
private static RegExp tagNameRegex = RegExp.compile("<([\\w:-]+)");
/**
- * Static reference to the Widgets plugin
+ * Static reference to the Widgets plugin.
*/
public static Class<Widgets> Widgets = com.google.gwt.query.client.plugins.Widgets.Widgets;
/**
* Wrap a GQuery around any object, supported objects are:
- * String, GQuery, Function, Widget, JavaScriptObject
+ * 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
/**
* Create a new GQuery given a list of {@link com.google.gwt.dom.client.Node} or
- * {@link com.google.gwt.user.client.ui.IsWidget}
+ * {@link com.google.gwt.user.client.ui.IsWidget}.
*/
public static GQuery $(List<?> nodesOrWidgets) {
JsNodeArray elms = JsNodeArray.create();
}
/**
- * Execute a function around each object
+ * Execute a function around each object.
*/
public static void each(JsArrayMixed objects, Function f) {
for (int i = 0, l = objects.length(); i < l; i++) {
}
/**
- * Execute a function around each object
+ * Execute a function around each object.
*/
public static <T> void each(List<T> objects, Function f) {
for (int i = 0, l = objects.size(); i < l; i++) {
}
/**
- * Execute a function around each object
+ * Execute a function around each object.
*/
public static <T> void each(T[] objects, Function f) {
for (int i = 0, l = objects.length; i < l; i++) {
/**
* A constructor function that returns a chainable utility object with methods to register
* multiple callbacks into callback queues, invoke callback queues, and relay the success
- * or failure state of any synchronous or asynchronous function
+ * or failure state of any synchronous or asynchronous function.
*/
public static Promise.Deferred Deferred() {
return new Deferred();
private static native void scrollIntoViewImpl(Node n)
/*-{
-
if (n)
n.scrollIntoView()
}-*/;
private static native void setElementValue(Element e, String value)
/*-{
-
e.value = value;
}-*/;
protected String currentSelector;
/**
- * Immutable array of matched elements, modify this using setArray
+ * Immutable array of matched elements, modify this using setArray.
*/
private Element[] elements = new Element[0];
/**
- * The nodeList of matched elements, modify this using setArray
+ * The nodeList of matched elements, modify this using setArray.
*/
// TODO: remove this and use elements, change return type of get()
private NodeList<Element> nodeList = JavaScriptObject.createArray().cast();
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px
+ * // move the element from its original position to left:500px
* $("#foo").animate("left:'500'");
*
* // Change the width html attribute of a table, note the symbol '$' to
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
*
* $("#foo").animate("left:'+=500'", new Function(){
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms using a swing easing
+ * // move the element from its original position to left:500px for 500ms using a swing easing
* $("#foo").animate("left:'500'", 500, Easing.SWING);
*
* // Change the width html attribute of a table, note the symbol '$' to
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'", 500);
*
* // Change the width html attribute of a table, note the symbol '$' to
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
- * @param funcs an array of {@link Function} called once the animation is complete
- * @param duration the duration in milliseconds of the animation
+ * @param stringOrProperties the set of properties to animate : "cssName:'value'"
+ * @param funcs an array of {@link Function} called once the animation is complete.
*/
public GQuery animate(Object stringOrProperties, int duration, Function... funcs) {
return as(Effects).animate(stringOrProperties, duration, funcs);
/**
* Remove all event handlers previously attached using {@link #live(String, Function)}. In order
* for this method to function correctly, the selector used with it must match exactly the
- * selector initially used with {@link #live(String, Function)}
+ * selector initially used with {@link #live(String, Function)}.
+ *
* @deprecated use {@link #off(String, String)} instead
*/
public GQuery die() {
/**
* Remove an event handlers previously attached using {@link #live(int, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(int, Function)}
+ * initially used with {@link #live(int, Function)}.
* @deprecated use {@link #off(String)}
*/
public GQuery die(int eventbits) {
/**
* Remove an event handlers previously attached using {@link #live(String, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(String, Function)}
+ * initially used with {@link #live(String, Function)}.
*/
public GQuery die(String eventName) {
return as(Events).die(eventName);
}
/**
- * Return true if the first element is visible.isVisible
+ * Return true if the first element is visible.isVisible.
*/
public boolean isVisible() {
return isEmpty() ? false : getStyleImpl().isVisible(get(0));
/**
* Get all following siblings of each element up to but not including the element matched by the
- * GQuery object, filtered by a selector
+ * GQuery object, filtered by a selector.
*
* @return
*/
*/
public GQuery offset(int top, int left) {
for (Element element : elements()){
- GQuery $element = $(element);
+ GQuery g = $(element);
- String position = $element.css("position", true);
+ String position = g.css("position", true);
if ("static".equals(position)) {
css("position", "relative");
}
- Offset curOffset = $element.offset();
- String curCSSTop = $element.css("top", true);
- String curCSSLeft = $element.css("left", true);
+ Offset curOffset = g.offset();
+ String curCSSTop = g.css("top", true);
+ String curCSSLeft = g.css("left", true);
long curTop = 0;
long curLeft = 0;
- if (("absolute".equals(position) || "fixed".equals(position)) && ("auto".equals(curCSSTop) || "auto".equals
- (curCSSLeft))) {
- Offset curPosition = $element.position();
+ if (("absolute".equals(position) || "fixed".equals(position)) && ("auto".equals(curCSSTop) || "auto".equals(curCSSLeft))) {
+ Offset curPosition = g.position();
curTop = curPosition.top;
curLeft = curPosition.left;
} else {
long newTop = top - curOffset.top + curTop;
long newLeft = left - curOffset.left + curLeft;
- $element.css("top", "" + newTop).css("left", "" + newLeft);
+ g.css("top", "" + newTop).css("left", "" + newLeft);
}
return this;
}
/**
- * Remove an event handler
+ * Remove an event handler.
*/
public GQuery off(String eventName) {
return unbind(eventName, null);
}
/**
- * Remove an event handler
+ * Remove an event handler.
*/
public GQuery off(String eventName, Function f) {
return unbind(eventName, f);
}
/**
- * Remove an event handler
+ * Remove an event handler.
*/
public GQuery off(String eventName, String selector) {
if (selector == null || selector.isEmpty()) {
List<Element> newElements = new ArrayList<Element>();
for (int i = 0, l = target.size(); i < l; i++) {
- GQuery _this = (i > 0 && mustBeCloned) ? this.clone() : this;
- $(target.get(i)).replaceWith(_this);
- newElements.addAll(Arrays.asList(_this.elements));
+ GQuery that = (i > 0 && mustBeCloned) ? this.clone() : this;
+ $(target.get(i)).replaceWith(that);
+ newElements.addAll(Arrays.asList(that.elements));
}
return $(newElements);
}
* Scrolls the first matched element into view.
*/
public GQuery scrollIntoView() {
- if (!isEmpty())
+ if (!isEmpty()) {
scrollIntoViewImpl(get(0));
+ }
return this;
}
}
/**
- * Make all matched elements visible
+ * Make all matched elements visible.
*/
public GQuery show() {
for (Element e : elements) {
/**
* Remove all event delegation that have been bound using
- * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods
+ * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods.
+ *
* @deprecated use {@link #off()}
*/
public GQuery undelegate() {
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
public GQuery undelegate(String selector) {
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
public GQuery undelegate(String selector, int eventBit) {
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String, String)}
*/
public GQuery undelegate(String selector, String eventName) {
/**
* This method removes the element's parent. The matched elements replaces their parents within
- * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method
+ * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method.
*
* @return
*/
for (Element parent : parent().elements) {
if (!"body".equalsIgnoreCase(parent.getTagName())) {
- GQuery $parent = $(parent);
- $parent.replaceWith($parent.children());
+ GQuery g = $(parent);
+ g.replaceWith(g.children());
}
}
return this;
/**
* Gets the content of the value attribute of the first matched element, returns only the first
* value even if it is a multivalued element. To get an array of all values in multivalues
- * elements use vals()
+ * elements use vals().
*
* When the first element is a radio-button and is not checked, then it looks for the first
* checked radio-button that has the same name in the list of matched elements.
}
/**
- * return the list of attached widgets matching the query
+ * return the list of attached widgets matching the query.
*/
public List<Widget> widgets() {
List<Widget> widgets = new ArrayList<Widget>();
String toQueryString();
/**
- * return the name for this type
+ * return the name for this type.
*/
String getJsonName();
* method calls to the class which implements the Lazy interface. Methods in the
* generated class do not execute but instead queue up a deferred execution of
* the method.
+ *
+ * @param <S>
+ * @param <T>
*/
public interface Lazy<S, T extends LazyBase> {
/**
* All lazy interfaces must extend this baseclass. This ensures the done()
* method exists and returns an executable function.
+ *
+ * @param <S>
*/
public interface LazyBase<S> {
-
Function done();
}
* the License.
*/
package com.google.gwt.query.client;
+
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
-import com.google.gwt.dom.client.Style.HasCssName;
import com.google.gwt.query.client.GQuery.Offset;
-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.SelectorEngine;
import com.google.gwt.query.client.js.JsNamedArray;
import com.google.gwt.query.client.js.JsNodeArray;
import com.google.gwt.query.client.plugins.Effects;
import com.google.gwt.user.client.ui.Widget;
import java.util.List;
-import java.util.Map;
-public interface LazyGQuery<T> extends LazyBase<T>{
+/**
+ * LazyGQuery.
+ * @param <T>
+ */
+public interface LazyGQuery<T> extends LazyBase<T> {
/**
* Add elements to the set of matched elements if they are not included yet.
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px
+ * // move the element from its original position to left:500px
* $("#foo").animate("left:'500'");
*
* // Change the width html attribute of a table, note the symbol '$' to
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
*
* $("#foo").animate("left:'+=500'", new Function(){
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms using a swing easing
+ * // move the element from its original position to left:500px for 500ms using a swing easing
* $("#foo").animate("left:'500'", 500, Easing.SWING);
*
* // Change the width html attribute of a table, note the symbol '$' to
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'", 500);
*
* // Change the width html attribute of a table, note the symbol '$' to
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
- * @param funcs an array of {@link Function} called once the animation is complete
- * @param duration the duration in milliseconds of the animation
+ * @param stringOrProperties the set of properties to animate : "cssName:'value'"
+ * @param funcs an array of {@link Function} called once the animation is complete.
*/
LazyGQuery<T> animate(Object stringOrProperties, int duration, Function... funcs);
/**
* Remove all event handlers previously attached using {@link #live(String, Function)}. In order
* for this method to function correctly, the selector used with it must match exactly the
- * selector initially used with {@link #live(String, Function)}
+ * selector initially used with {@link #live(String, Function)}.
+ *
* @deprecated use {@link #off(String, String)} instead
*/
LazyGQuery<T> die();
/**
* Remove an event handlers previously attached using {@link #live(int, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(int, Function)}
+ * initially used with {@link #live(int, Function)}.
* @deprecated use {@link #off(String)}
*/
LazyGQuery<T> die(int eventbits);
/**
* Remove an event handlers previously attached using {@link #live(String, Function)} In order for
* this method to function correctly, the selector used with it must match exactly the selector
- * initially used with {@link #live(String, Function)}
+ * initially used with {@link #live(String, Function)}.
*/
LazyGQuery<T> die(String eventName);
boolean isEmpty();
/**
- * Return true if the first element is visible.isVisible
+ * Return true if the first element is visible.isVisible.
*/
boolean isVisible();
/**
* Get all following siblings of each element up to but not including the element matched by the
- * GQuery object, filtered by a selector
+ * GQuery object, filtered by a selector.
*
* @return
*/
LazyGQuery<T> off();
/**
- * Remove an event handler
+ * Remove an event handler.
*/
LazyGQuery<T> off(String eventName);
/**
- * Remove an event handler
+ * Remove an event handler.
*/
LazyGQuery<T> off(String eventName, Function f);
/**
- * Remove an event handler
+ * Remove an event handler.
*/
LazyGQuery<T> off(String eventName, String selector);
/**
* Get the ancestors of each element in the current set of matched elements, up to but not
- * including the element matched by the selector.
+ * including the node.
*/
- LazyGQuery<T> parentsUntil(Node selector);
+ LazyGQuery<T> parentsUntil(Node node);
/**
* Gets the top and left position of an element relative to its offset parent. The returned object
LazyGQuery<T> setSelector(String selector);
/**
- * Make all matched elements visible
+ * Make all matched elements visible.
*/
LazyGQuery<T> show();
/**
* Remove all event delegation that have been bound using
- * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods
+ * {@link #delegate(String, int, Function...)} {@link #live(int, Function...)} methods.
+ *
* @deprecated use {@link #off()}
*/
LazyGQuery<T> undelegate();
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
LazyGQuery<T> undelegate(String selector);
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String)}
*/
LazyGQuery<T> undelegate(String selector, int eventBit);
/**
* Undelegate is a way of removing event handlers that have been bound using
- * {@link #delegate(String, int, Function...)} method
+ * {@link #delegate(String, int, Function...)} method.
+ *
* @deprecated use {@link #off(String, String)}
*/
LazyGQuery<T> undelegate(String selector, String eventName);
/**
* This method removes the element's parent. The matched elements replaces their parents within
- * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method
+ * the DOM structure. It is the inverse of {@link GQuery#wrap(GQuery)} method.
*
* @return
*/
/**
* Gets the content of the value attribute of the first matched element, returns only the first
* value even if it is a multivalued element. To get an array of all values in multivalues
- * elements use vals()
+ * elements use vals().
*
* When the first element is a radio-button and is not checked, then it looks for the first
* checked radio-button that has the same name in the list of matched elements.
<W extends Widget> W widget(int n);
/**
- * return the list of attached widgets matching the query
+ * return the list of attached widgets matching the query.
*/
List<Widget> widgets();
* everything else.
*/
LazyGQuery<T> wrapInner(String html);
+
}
*/
package com.google.gwt.query.client;
-
/**
* Definition of jquery Promise interface used in gquery.
*/
Deferred resolve(Object... o);
}
- public static final String PENDING = "pending";
- public static final String REJECTED = "rejected";
- public static final String RESOLVED = "resolved";
+ String PENDING = "pending";
+ String REJECTED = "rejected";
+ String RESOLVED = "resolved";
/**
* Add handlers to be called when the Deferred object is either resolved or rejected.
.replaceAll(";([^:]+):", ",$1:") // change semicolon
.replaceAll(";([^:]+):", ",$1:") // change semicolon second pass
.replaceAll(":\"(-?\\d[\\d\\.]*|null|false|true)\"[;,]", ":$1,") // numbers do not need quote
- .replaceAll("[;,]+([\\]\\}]|$)", "$1") // remove endings
- ;
+ .replaceAll("[;,]+([\\]\\}]|$)", "$1"); // remove endings
ret = ret.matches("(^[\\[\\{].*[\\]\\}]$)") ? ret : "{" + ret + "}";
return ret;
}
return this.<JsCache>cast();
}
- public final native Properties cloneProps()
- /*-{
-
+ public final native Properties cloneProps() /*-{
var props = {};
for(p in this) {
props[p] = this[p];
* Its useful for exporting or importing to javascript.
*
*/
- public final native <T> void setFunction(T name, Function f)
- /*-{
-
+ public final native <T> void setFunction(T name, Function f) /*-{
if (!f) return;
this[name] = function() {
f.@com.google.gwt.query.client.Function::fe(Ljava/lang/Object;)(arguments);
* Set the context for all the selectors.
* By default they are evaluated in all the document.
*/
- public void setRoot(Node node);
+ void setRoot(Node node);
/**
* Get the configured root context.
*/
- public Node getRoot();
+ Node getRoot();
/**
* Used for benchmarking purposes, it returns true if the selector engine
*
* It is useful to check if IE8 native selectors are being used.
*/
- public boolean isDegradated();
+ boolean isDegradated();
}
/**
* Returns the wrapped object, normally a Properties jso in client
- * but can be used to return the underlying Json implementation in JVM
- * @deprecated use asObject() instead
+ * but can be used to return the underlying Json implementation in JVM.
+ *
+ * @deprecated use asObject() instead.
*/
<J> J getProperties();
import com.google.gwt.query.client.js.JsObjectArray;
import com.google.gwt.query.client.js.JsUtils;
+/**
+ * Common class for all JsonBuilder implementations.
+ *
+ * @param <J>
+ */
public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements JsonBuilder {
protected Properties p = Properties.create();
import com.google.gwt.query.client.IsProperties;
+/**
+ * Factory interface.
+ */
public interface JsonFactory {
<T extends JsonBuilder> T create(Class<T> clz);
IsProperties create(String s);
Element getRootElement();
/**
- * Appends a node
+ * Appends a node.
*/
void append(XmlBuilder x);
/**
- * Appends xml content
+ * Appends xml content.
*/
void append(String x);
/**
- * Returns the text content of the element
+ * Returns the text content of the element.
*/
String getText();
/**
- * Sets the text content of the element
+ * Sets the text content of the element.
*/
<J> J setText(String t);
/**
- * Returns the text content of the element as a number
+ * Returns the text content of the element as a number.
*/
double getTextAsNumber();
/**
- * Returns the text content of the element as a date
+ * Returns the text content of the element as a date.
*/
Date getTextAsDate();
import java.util.Date;
+/**
+ * Common code in XmlBuilder implementations.
+ *
+ * @param <J>
+ */
public abstract class XmlBuilderBase<J extends XmlBuilderBase<?>> implements XmlBuilder {
- //TODO empty document
+ // TODO empty document
protected GQuery g = $((Element)JsUtils.parseXML("<root/>"));
public void append(String xml) {
public class BackgroundAttachmentProperty extends
CssProperty<BackgroundAttachmentProperty.BackgroundAttachment> {
+ /**
+ * BackgroundAttachment.
+ */
public static enum BackgroundAttachment implements HasCssName {
/**
* Background image is fixed.
package com.google.gwt.query.client.css;
/**
- * This property sets the background image of an element,
+ * This property sets the background image of an element.
*/
public class BackgroundImageProperty extends CssProperty<UriValue> {
/**
* Value for <i>background-position</i> property.
- *
- * @author Julien Dramaix (julien.dramaix@gmail.com)
- *
*/
public static class BackgroundPosition implements HasCssName {
/**
- * Equivalent to {@link BackgroundPosition#CENTER_BOTTOM}
+ * Equivalent to {@link BackgroundPosition#CENTER_BOTTOM}.
*/
public static BackgroundPosition BOTTOM;
/**
- * Equivalent to {@link BackgroundPosition#CENTER_CENTER}
+ * Equivalent to {@link BackgroundPosition#CENTER_CENTER}.
*/
public static BackgroundPosition CENTER;
public static BackgroundPosition CENTER_TOP;
/**
- * Equivalent to {@link BackgroundPosition#LEFT_CENTER}
+ * Equivalent to {@link BackgroundPosition#LEFT_CENTER}.
*/
public static BackgroundPosition LEFT;
public static BackgroundPosition LEFT_TOP;
/**
- * Equivalent to {@link BackgroundPosition#RIGHT_CENTER}
+ * Equivalent to {@link BackgroundPosition#RIGHT_CENTER}.
*/
public static BackgroundPosition RIGHT;
public static BackgroundPosition RIGHT_TOP;
/**
- * Equivalent to {@link BackgroundPosition#CENTER_TOP}
+ * Equivalent to {@link BackgroundPosition#CENTER_TOP}.
*/
public static BackgroundPosition TOP;
/**
* Return a {@link BackgroundPosition} by specifying the horizontal and
- * vertical position. Pixel will be used as Unit
+ * vertical position. Pixel will be used as Unit.
*/
public static BackgroundPosition position(int xpos, int ypos) {
return position(xpos, ypos, Unit.PX);
public class BorderCollapseProperty extends
CssProperty<BorderCollapseProperty.BorderCollapse> {
+ /**
+ * BorderCollapse.
+ */
public static enum BorderCollapse implements HasCssName {
/**
* Borders are collapsed into a single border when possible (border-spacing
/**
* Construct a {@link BorderSpacing} object with same horizontal and
- * vertical spacing
+ * vertical spacing.
*/
public BorderSpacing(Length spacing) {
this(spacing, spacing);
public class BorderStyleProperty extends
CssProperty<BorderStyleProperty.BorderStyle> {
+ /**
+ * BorderStyle.
+ */
public static enum BorderStyle implements HasCssName {
/**
* The border is a series of short line segments.
import com.google.gwt.query.client.css.MarginProperty.ShorthandMarginProperty;
import com.google.gwt.query.client.css.PaddingProperty.ShorthandPaddingProperty;
-import com.google.gwt.query.client.css.UnicodeBidiProperty.UnicodeBidi;
/**
* This class lists all CSS properties.
/**
* CSS value specifying that the setting of the related property should be
- * inherited from the parent element
+ * inherited from the parent element.
*/
public static final String INHERIT = "inherit";
public class CssProperty<T extends HasCssName> implements
TakesCssValue<T> {
+ /**
+ * CssSetterImpl.
+ */
protected class CssSetterImpl implements CssSetter {
private T cssValue;
/**
* The <i>cursor</i> property specifies the type of cursor to be displayed for
- * the pointing device
+ * the pointing device.
*/
public class CursorProperty extends CssProperty<Cursor> {
super(CSS_PROPERTY);
}
- public CssSetter with(UriValue url){
+ public CssSetter with(UriValue url) {
return new SimpleCssSetter(this, url);
}
}
/**
* All height css properties : <i>max-height</i>, <i>min-height</i>,
- * <i>height</i>
+ * <i>height</i>.
*/
public class HeightProperty extends CssProperty<Length> {
*/
public class MarginProperty extends CssProperty<Length> {
+ /**
+ * ShorthandMarginProperty.
+ */
public static class ShorthandMarginProperty implements HasCssValue {
private ShorthandMarginProperty() {
}
/**
- * Apply the same margin to all sides
+ * Apply the same margin to all sides.
*/
public CssSetter with(Length margin) {
return new MultipleValueCssSetter(getCssName(), margin);
/**
* The top and bottom margins are set to the first value and the right and
- * left margins are set to the second
+ * left margins are set to the second.
*/
public CssSetter with(Length topAndBottom, Length leftAndRight) {
return new MultipleValueCssSetter(getCssName(), topAndBottom, leftAndRight);
/**
* The top margin is set to the first value, the left and right margins are
- * set to the second, and the bottom margin is set to the third
+ * set to the second, and the bottom margin is set to the third.
*/
public CssSetter with(Length top, Length leftAndRight, Length bottom) {
return new MultipleValueCssSetter(getCssName(), top, leftAndRight, bottom);
import com.google.gwt.dom.client.Style.HasCssName;
+/**
+ * MultipleValueCssSetter.
+ */
public class MultipleValueCssSetter extends SimpleCssSetter {
public MultipleValueCssSetter(String cssPropertyName, HasCssName... values) {
super(cssPropertyName, computeValue(values));
}
- protected static String computeValue(HasCssName... values){
+ protected static String computeValue(HasCssName... values) {
StringBuilder valueBuilder = new StringBuilder();
- for (HasCssName cssValue : values){
+ for (HasCssName cssValue : values) {
valueBuilder.append(notNull(cssValue));
}
* declaration.
*/
public class OutlineProperty implements
- HasCssValue{
+ HasCssValue {
private static final String CSS_PROPERTY = "outline";
*/
public class PaddingProperty extends CssProperty<Length> {
+ /**
+ * ShorthandPaddingProperty.
+ */
public static class ShorthandPaddingProperty implements HasCssValue {
private ShorthandPaddingProperty() {
}
/**
- * Apply the same padding to all sides
+ * Apply the same padding to all sides.
*/
public CssSetter with(Length padding) {
return new MultipleValueCssSetter(getCssName(), padding);
/**
* The top and bottom paddings are set to the first value and the right and
- * left paddings are set to the second
+ * left paddings are set to the second.
*/
public CssSetter with(Length topAndBottom, Length leftAndRight) {
return new MultipleValueCssSetter(getCssName(), topAndBottom,
/**
* The top padding is set to the first value, the left and right paddings
- * are set to the second, and the bottom padding is set to the third
+ * are set to the second, and the bottom padding is set to the third.
*/
public CssSetter with(Length top, Length leftAndRight, Length bottom) {
return new MultipleValueCssSetter(getCssName(), top, leftAndRight, bottom);
/**
* An CSS property with values of type T.
+ *
+ * @param <T>
*/
public interface TakesCssValue<T> extends HasCssValue {
- public interface CssSetter {
- public void applyCss(Element e);
+ /**
+ * CssSetter.
+ */
+ interface CssSetter {
+ void applyCss(Element e);
}
CssSetter with(T value);
import com.google.gwt.dom.client.Style.HasCssName;
/**
- * This property defines the text direction/writing direction
+ * This property defines the text direction/writing direction.
*/
public class UnicodeBidiProperty extends
CssProperty<UnicodeBidiProperty.UnicodeBidi> {
/**
- * Define possible values for <i>unicode-bidi</i> property
+ * Define possible values for <i>unicode-bidi</i> property.
*
*/
public static enum UnicodeBidi implements HasCssName {
import com.google.gwt.dom.client.Style.HasCssName;
/**
- * Image as css value
+ * Image as css value.
*/
public class UriValue implements HasCssName {
/**
- * Define an uri by an url
+ * Define an uri by an url.
*/
public static UriValue url(String url) {
return new UriValue("url('" + url + "')");
/**
* The <i>white-space</i> property declares how white space inside the element
- * is handled
+ * is handled.
*/
public class WhiteSpaceProperty extends
CssProperty<WhiteSpaceProperty.WhiteSpace> {
+ /**
+ * WhiteSpace.
+ */
public enum WhiteSpace implements HasCssName {
/**
package com.google.gwt.query.client.css;
/**
- * All width css properties : <i>max-width</i>, <i>min-width</i>, <i>width</i>
+ * All width css properties : <i>max-width</i>, <i>min-width</i>, <i>width</i>.
*/
public class WidthProperty extends CssProperty<Length> {
/**
* returns a {@link CssSetter} object setting <i>z-index</i> property to the
- * specified <code>value</code>
+ * specified <code>value</code>.
*/
public CssSetter with(Integer value) {
return new SimpleCssSetter(CSS_PROPERTY, value != null ? value.toString() : null);
}
/**
- * See GWT issue 5548
+ * See GWT issue 5548.
* http://code.google.com/p/google-web-toolkit/issues/detail?id=5548
*/
- private native String getZIndex(Style s)
- /*-{
-
- //force to return a string
+ private native String getZIndex(Style s) /*-{
+ // force to return a string
return "" + s["zIndex"];
}-*/;
}
-/* Copyright 2011, The gwtquery team.
+/*
+ * 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
* 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. */
+ * the License.
+ */
package com.google.gwt.query.client.impl;
import com.google.gwt.dom.client.Element;
* Interface used for attribute setter implementations.
*/
public interface AttributeSetter {
- public boolean isRemoval(Object value);
+ boolean isRemoval(Object value);
- public void setAttribute(Element e, String name, Object value);
+ void setAttribute(Element e, String name, Object value);
}
/**
}
/**
- * value must be set on element directly
+ * value must be set on element directly.
*/
protected static class ValueAttrSetter extends DefaultSetter {
private static AttributeSetter INSTANCE;
}
/**
- * Boolean attribute :
+ * Boolean attribute.
* - Ensure to set a boolean value to the element's property with the same
* name if this last exists
* - Ensure to set an attribute having the value equals to the name (i.e
/**
* For button and inputs, the type cannot be changed once the element is
- * attached to the dom !
+ * attached to the DOM.
*/
private static class TypeAttrSetter extends DefaultSetter {
private static AttributeSetter INSTANCE;
String tag = e.getNodeName();
if (NOT_AUTHORIZED_NODE.test(tag)
&& GQuery.$(e).parents("body").length() > 0) {
- //TODO maybe it's better to simply do nothing...
+ // TODO maybe it's better to simply do nothing...
throw new RuntimeException(
"You cannot change type of button or input element if the element is already attached to the dom");
}
if ("input".equals(tag.toLowerCase()) && "radio".equals(value)) {
- //some browser (IE6-9) resets value property of the input when you change the type to radio button
+ // some browser (IE6-9) resets value property of the input when you change the type to radio button
InputElement ie = InputElement.as(e);
String keepValue = ie.getValue();
super.setAttribute(ie, "type", value);
value = fixValue(key, value);
for (Element e : gQuery.elements()) {
int nodeType = e.getNodeType();
- //don't set attribute on text, comment and attributes nodes
+ // don't set attribute on text, comment and attributes nodes
if (nodeType == 3 || nodeType == 8 || nodeType == 2) {
continue;
}
}
}
- private static native String getAttributeNode(Element e, String name)
- /*-{
-
+ private static native String getAttributeNode(Element e, String name) /*-{
var attrNode = e.getAttributeNode(name);
if (attrNode && attrNode.nodeValue !== "") {
return attrNode.nodeValue;
}-*/;
private static native boolean setAttributeNode(Element e, String name,
- Object value)
- /*-{
-
+ Object value) /*-{
var attrNode = e.getAttributeNode(name);
if (attrNode) {
attrNode.nodeValue = value;
public class ConsoleBrowser implements Console {
/**
- * http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object
+ * http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object.
*/
private static class ConsoleIe8 extends ConsoleIe9 {
@Override
- protected native void init()
- /*-{
-
+ protected native void init() /*-{
try {
Function.prototype.call.call($wnd.console.log, $wnd.console, Array.prototype.slice.call(arguments));
this.@com.google.gwt.query.client.impl.ConsoleBrowser.ConsoleIe9::initialized = true;
}
/**
- * See: http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object
+ * See: http://whattheheadsaid.com/2011/04/internet-explorer-9s-problematic-console-object.
*/
private static class ConsoleIe9 extends ConsoleImpl {
init();
}
- protected native void init()
- /*-{
-
+ protected native void init() /*-{
try {
[ "log", "info", "warn", "error", "dir", "clear", "profile", "profileEnd" ]
.forEach(function(method) {
@Override
public void clear() {
- if (initialized) super.clear();
+ if (initialized) {
+ super.clear();
+ }
}
@Override
public void dir(Object arg) {
- if (initialized) super.dir(arg);
+ if (initialized) {
+ super.dir(arg);
+ }
}
@Override
public void error(JavaScriptObject arg) {
- if (initialized) super.error(arg);
+ if (initialized) {
+ super.error(arg);
+ }
}
@Override
public void info(JavaScriptObject arg) {
- if (initialized) super.info(arg);
+ if (initialized) {
+ super.info(arg);
+ }
}
@Override
public void profile(String title) {
- if (initialized) super.profile(title);
+ if (initialized) {
+ super.profile(title);
+ }
}
@Override
public void profileEnd(String title) {
- if (initialized) super.profileEnd(title);
+ if (initialized) {
+ super.profileEnd(title);
+ }
}
@Override
public void warn(JavaScriptObject arg) {
- if (initialized) super.warn(arg);
+ if (initialized) {
+ super.warn(arg);
+ }
}
@Override
public void group(Object arg) {}
}
/**
- * Default implementation: webkit, opera, FF, ie10
+ * Default implementation: webkit, opera, FF, IE10.
*/
private static class ConsoleImpl {
- public native void clear()
- /*-{
-
+ public native void clear() /*-{
$wnd.console.clear();
}-*/;
- public native void dir(Object arg)
- /*-{
-
+ public native void dir(Object arg) /*-{
$wnd.console.dir(arg);
}-*/;
- public native void error(JavaScriptObject arg)
- /*-{
-
+ public native void error(JavaScriptObject arg) /*-{
$wnd.console.error.apply($wnd.console, arg);
}-*/;
- public native void group(Object arg)
- /*-{
-
+ public native void group(Object arg) /*-{
$wnd.console.group(arg);
}-*/;
- public native void groupCollapsed(Object arg)
- /*-{
-
+ public native void groupCollapsed(Object arg) /*-{
$wnd.console.groupCollapsed(arg);
}-*/;
- public native void groupEnd()
- /*-{
-
+ public native void groupEnd() /*-{
$wnd.console.groupEnd();
}-*/;
- public native void info(JavaScriptObject arg)
- /*-{
-
+ public native void info(JavaScriptObject arg) /*-{
$wnd.console.info.apply($wnd.console, arg);
}-*/;
- public native void log(JavaScriptObject arg)
- /*-{
-
+ public native void log(JavaScriptObject arg) /*-{
$wnd.console.log.apply($wnd.console, arg);
}-*/;
- public native void profile(String title)
- /*-{
-
+ public native void profile(String title) /*-{
$wnd.console.profile(title);
}-*/;
- public native void profileEnd(String title)
- /*-{
-
+ public native void profileEnd(String title) /*-{
$wnd.console.profileEnd(title);
}-*/;
- public native void time(String title)
- /*-{
-
+ public native void time(String title) /*-{
$wnd.console.time(title);
}-*/;
- public native void timeEnd(String title)
- /*-{
-
+ public native void timeEnd(String title) /*-{
$wnd.console.timeEnd(title);
}-*/;
- public native void timeStamp(Object arg)
- /*-{
-
+ public native void timeStamp(Object arg) /*-{
$wnd.console.timeStamp(arg);
}-*/;
- public native void warn(JavaScriptObject arg)
- /*-{
-
+ public native void warn(JavaScriptObject arg) /*-{
$wnd.console.warn.apply($wnd.console, arg);
}-*/;
}
return "";
}
name = fixPropertyName(name);
- //value defined in the element style
+ // value defined in the element style
String ret = elem.getStyle().getProperty(name);
if (force) {
Element lastParent = $(elem).parents().last().get(0);
if (lastParent == null){
- //the element itself is detached
+ // the element itself is detached
lastParent = elem;
}
}
protected native String getComputedStyle(Element elem, String hyphenName,
- String camelName, String pseudo)
- /*-{
-
+ String camelName, String pseudo) /*-{
try {
var cStyle = $doc.defaultView.getComputedStyle(elem, pseudo);
return cStyle && cStyle.getPropertyValue ? cStyle.getPropertyValue(hyphenName) : null;
return ret;
}
- public native Document getContentDocument(Node n)
- /*-{
-
+ public native Document getContentDocument(Node n) /*-{
var d = n.contentDocument || n.document || n.contentWindow.document;
if (!d.body)
this.@com.google.gwt.query.client.impl.DocumentStyleImpl::emptyDocument(Lcom/google/gwt/dom/client/Document;)(d);
return d;
}-*/;
- public native void emptyDocument(Document d)
- /*-{
-
+ public native void emptyDocument(Document d) /*-{
d.open();
d.write("<head/><body/>");
d.close();
/**
* Remove a style property from an element.
*/
- public native void removeStyleProperty(Element e, String prop)
- /*-{
-
+ public native void removeStyleProperty(Element e, String prop) /*-{
if (e && e.style && 'removeAttribute' in e)
e.style.removeAttribute(prop);
}-*/;
@Override
protected native String getComputedStyle(Element elem, String hyphenName,
- String camelName, String pseudo)
- /*-{
-
+ String camelName, String pseudo) /*-{
// code lifted from jQuery
if (!elem.style || !'currentStyle' in elem || !'runtimeStyle' in elem) return null;
var style = elem.style;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
+/**
+ *
+ */
public interface HasSelector {
/**
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
-import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.Predicate;
import com.google.gwt.query.client.js.JsMap;
import com.google.gwt.query.client.js.JsNodeArray;
private static DocumentStyleImpl styleImpl;
public static native NodeList<Element> getElementsByClassName(String clazz,
- Node ctx)
- /*-{
-
+ Node ctx) /*-{
return ctx.getElementsByClassName(clazz);
}-*/;
- public static native Node getNextSibling(Node n)
- /*-{
-
+ public static native Node getNextSibling(Node n) /*-{
return n.nextSibling || null;
}-*/;
- public static native Node getPreviousSibling(Node n)
- /*-{
-
+ public static native Node getPreviousSibling(Node n) /*-{
return n.previousSibling || null;
}-*/;
}
public static native NodeList<Element> querySelectorAllImpl(String selector,
- Node ctx)
- /*-{
-
+ Node ctx) /*-{
return ctx.querySelectorAll(selector);
}-*/;
public static native NodeList<Element> elementsByTagName(String selector,
- Node ctx)
- /*-{
-
+ Node ctx) /*-{
return ctx.getElementsByTagName(selector);
}-*/;
public static native NodeList<Element> elementsByClassName(String selector,
- Node ctx)
- /*-{
-
+ Node ctx) /*-{
return ctx.getElementsByClassName(selector);
}-*/;
}
public static native NodeList<Element> xpathEvaluate(String selector,
- Node ctx, JsNodeArray r)
- /*-{
-
+ Node ctx, JsNodeArray r) /*-{
var node;
var ownerDoc = ctx && (ctx.ownerDocument || ctx );
var evalDoc = ownerDoc ? ownerDoc : $doc;
}
}
- public native boolean contains(Element a, Element b)
- /*-{
-
+ public native boolean contains(Element a, Element b) /*-{
return a.contains ? a != b && a.contains(b) : !!(a.compareDocumentPosition(b) & 16)
}-*/;
}
/**
- * Check if the browser has native support for css selectors
+ * Check if the browser has native support for css selectors.
*/
- public static native boolean hasQuerySelectorAll()
- /*-{
-
+ public static native boolean hasQuerySelectorAll() /*-{
return $doc.location.href.indexOf("_force_no_native") < 0 &&
typeof $doc.querySelectorAll == 'function';
}-*/;
- public static native boolean hasXpathEvaluate()
- /*-{
-
+ public static native boolean hasXpathEvaluate() /*-{
return !!$doc.evaluate;
}-*/;
/**
* Interface for callbacks in replaceAll operations.
*/
- public static interface ReplaceCallback {
+ public interface ReplaceCallback {
String foundMatch(ArrayList<String> s);
}
/**
* Interface for replacer implementations (GWT and JVM).
*/
- public static interface Replacer {
+ public interface Replacer {
String replaceAll(String s, String expr, Object replacement);
}
"\\s*,\\s*", "|.//",
// , + ~ >
"\\s*(\\+|~|>)\\s*", "$1",
- //* ~ + >
+ // * ~ + >
"([\\w\\-\\*])~([\\w\\-\\*])", "$1/following-sibling::$2",
"([\\w\\-\\*])\\+([\\w\\-\\*])", "$1/following-sibling::*[1]/self::$2",
"([\\w\\-\\*])>([\\w\\-\\*])", "$1/$2",
if (!SelectorEngine.hasXpathEvaluate()) {
throw new RuntimeException("This Browser does not support Xpath selectors.", e);
}
- console.error("ERROR: xpathEvaluate invalid xpath expression:"
- + xsel + " css-selector:" + sel + " " + e.getMessage() + "\n");
+ console.error("ERROR: xpathEvaluate invalid xpath expression: "
+ + xsel + " css-selector: " + sel + " " + e.getMessage() + "\n");
}
return elm;
}
*/
public class SelectorEngineSizzle extends SelectorEngineImpl {
- public static native void initialize()
- /*-{
-
+ public static native void initialize() /*-{
(function(){
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
div = null; // release memory in IE
})();
-//if ( document.querySelectorAll ) {
+// if ( document.querySelectorAll ) {
// (function(){
// var oldGQS = GQS, div = document.createElement("div");
// div.innerHTML = "<p class='TEST'></p>";
//
// div = null; // release memory in IE
// })();
-//}
+// }
(function(){
var div = document.createElement("div");
})();
}-*/;
- private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed)
- /*-{
-
+ private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
return $wnd.GQS(selector, context, results, seed);
}-*/;
*/
public class SelectorEngineSizzleIE extends SelectorEngineImpl {
- public static native void initialize()
- /*-{
-
+ public static native void initialize() /*-{
(function(){
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
})();
}-*/;
- private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed)
- /*-{
-
+ private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
return $wnd.IES(selector, context, results, seed);
}-*/;
}
}
- public static native void clearAdded(Node node)
- /*-{
-
+ public static native void clearAdded(Node node) /*-{
node.added = null;
}-*/;
public static native NodeList<Element> getElementsByClassName(String clazz,
- Node ctx)
- /*-{
-
+ Node ctx) /*-{
return ctx.getElementsByClassName(clazz);
}-*/;
- public static native boolean isAdded(Node prevRef)
- /*-{
-
+ public static native boolean isAdded(Node prevRef) /*-{
return prevRef.added || false;
}-*/;
- public static native void setAdded(Node prevRef, boolean added)
- /*-{
-
+ public static native void setAdded(Node prevRef, boolean added) /*-{
prevRef.added = added;
}-*/;
- public static native void setSkipTag(JsNodeArray prevElem, boolean skip)
- /*-{
-
+ public static native void setSkipTag(JsNodeArray prevElem, boolean skip) /*-{
prevElem.skipTag = skip;
}-*/;
return JsUtils.truth(attrVal) ? "^" + attrVal + "$" : null;
}
- private static native boolean checked(Node previous)
- /*-{
-
+ private static native boolean checked(Node previous) /*-{
return previous.checked || false;
}-*/;
}
}
- private static native boolean enabled(Node node)
- /*-{
-
+ private static native boolean enabled(Node node) /*-{
return !node.disabled;
}-*/;
}
}
- private static native boolean hasChildElms(Node prevParent)
- /*-{
-
+ private static native boolean hasChildElms(Node prevParent) /*-{
return prevParent.childElms || false;
}-*/;
- private static native boolean isSkipped(JsNodeArray prevElem)
- /*-{
-
+ private static native boolean isSkipped(JsNodeArray prevElem) /*-{
return prevElem.skipTag || false;
}-*/;
- private static native void setHasChildElms(Node prevParent, boolean bool)
- /*-{
-
+ private static native void setHasChildElms(Node prevParent, boolean bool) /*-{
prevParent.childElms = bool ? bool : null;
}-*/;
private static native JsNodeArray subtractArray(JsNodeArray previousMatch,
- JsNodeArray elementsByPseudo)
- /*-{
-
+ JsNodeArray elementsByPseudo) /*-{
for (var i=0, src1; (src1=arr1[i]); i++) {
var found = false;
for (var j=0, src2; (src2=arr2[j]); j++) {
*/
public class SelectorEngineJSIE extends SelectorEngineJS {
- public native String getAttr(Element elm, String attr)
- /*-{
-
+ public native String getAttr(Element elm, String attr) /*-{
switch (attr) {
case "id":
return elm.id;
*/
public class SelectorEngineSizzleGwt extends SelectorEngineImpl {
- public static native boolean contains(Object a, Object b)
- /*-{
-
+ public static native boolean contains(Object a, Object b) /*-{
var ret =
document.compareDocumentPosition ?
(a.compareDocumentPosition(b) & 16):
return ret ? true : false;
}-*/;
- public static native JavaScriptObject createExpr()
- /*-{
-
+ public static native JavaScriptObject createExpr() /*-{
var done = 0;
$wnd.Expr = {
order: [ "ID", "NAME", "TAG" ],
return $wnd.Expr;
}-*/;
- public static native void dirCheck(String dir, Object cur, int doneName, Object checkSet)
- /*-{
-
+ public static native void dirCheck(String dir, Object cur, int doneName, Object checkSet) /*-{
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
if ( elem ) {
}
}-*/;
- public static native void dirNodeCheck(String dir, Object cur, int doneName, Object checkSet)
- /*-{
-
+ public static native void dirNodeCheck(String dir, Object cur, int doneName, Object checkSet) /*-{
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
if ( elem ) {
throw new IllegalArgumentException("Syntax error, unrecognized expression: " + msg);
}
- public static native JsArray<Node> filter(String expr, JsArray<Node> set, boolean inplace, Object not)
- /*-{
-
+ public static native JsArray<Node> filter(String expr, JsArray<Node> set, boolean inplace, Object not) /*-{
var old = expr, result = [], curLoop = set, match, anyFound;
while ( expr && set.length ) {
for ( var type in $wnd.Expr.filter ) {
return curLoop;
}-*/;
- public static native JavaScriptObject find(String expr, Node context)
- /*-{
-
+ public static native JavaScriptObject find(String expr, Node context) /*-{
var set, match;
if ( !expr ) {
return [];
return {set: set, expr: expr};
}-*/;
- public static native String getText(Object elems)
- /*-{
-
+ public static native String getText(Object elems) /*-{
var ret = "", elem;
for ( var i = 0; elems[i]; i++ ) {
elem = elems[i];
return ret;
}-*/;
- public static native JsArray<Node> makeArray(NodeList<Node> array, JsArray<Node> results)
- /*-{
-
+ public static native JsArray<Node> makeArray(NodeList<Node> array, JsArray<Node> results) /*-{
var ret = results || [];
if ( Object.prototype.toString.call(array) === "[object Array]" ) {
Array.prototype.push.apply( ret, array );
return ret;
}-*/;
- public static native JsArray<Element> posProcess(String selector, Node context)
- /*-{
-
+ public static native JsArray<Element> posProcess(String selector, Node context) /*-{
var tmpSet = [], later = "", match, root = context.nodeType ? [context] : context;
// Position selectors must be done after the filter
// And so must :not(positional) so we move all PSEUDOs to the end
return @com.google.gwt.query.client.impl.research.SelectorEngineSizzleGwt::filter(Ljava/lang/String;Lcom/google/gwt/core/client/JsArray;ZLjava/lang/Object;)( later, tmpSet, false );
}-*/;
- private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed)
- /*-{
-
+ private static native JsArray<Element> select(String selector, Node context, JsArray<Element> results, JsArray<Element> seed) /*-{
results = results || [];
var origContext = context = context || document;
var parts = [], m, set, checkSet, extra, prune = true, soFar = selector;
return xpath;
}
- private native String replaceAttr(String allAttr)
- /*-{
-
+ private native String replaceAttr(String allAttr) /*-{
if(!allAttr) return "";
return allAttr.replace(/["']+/g,'').replace(/(\w+)(\^|\$|\*|\||~)?=?([\w\u00C0-\uFFFF\s\-_\.]+)?/g,
function(a,b,c,d) {
});
}-*/;
- private native String replaceAttr2(String allAttr)
- /*-{
-
+ private native String replaceAttr2(String allAttr) /*-{
if(!allAttr) return "";
return allAttr.replace(/\[(\w+)(\^|\$|\*|\||~)?=?([\w\u00C0-\uFFFF\s\-_\.]+)?\]/g, @com.google.gwt.query.client.impl.research.SelectorEngineXPath::attrToXPath(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;));
}-*/;
return createObject().cast();
}
- public final native void concat(Object ary)
- /*-{
-
+ public final native void concat(Object ary) /*-{
if (ary) this.concat(ary);
}-*/;
}
}
- public final native void delete(Object name)
- /*-{
-
+ public final native void delete(Object name) /*-{
delete this[name];
}-*/;
}
}
- public final native boolean exists(Object name)
- /*-{
-
+ public final native boolean exists(Object name) /*-{
return !!this[name];
}-*/;
return (T)o;
}
- public final native <T> T get(Object id)
- /*-{
-
+ public final native <T> T get(Object id) /*-{
return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ this && this[id] ]);
}-*/;
return r == null ? 0 : r;
}
- public final native String getString(Object id)
- /*-{
-
+ public final native String getString(Object id) /*-{
return this[id] == null ? null : String(this[id]);
}-*/;
- public final native JsArrayMixed getArray(Object id)
- /*-{
-
+ public final native JsArrayMixed getArray(Object id) /*-{
var r = this[id];
if (Object.prototype.toString.call(r) == '[object Array]') {
return r;
return (o != null && o instanceof JavaScriptObject) ? ((JavaScriptObject)o).<T>cast() : null;
}
- public final native boolean isEmpty()
- /*-{
-
+ public final native boolean isEmpty() /*-{
for (k in this) return false;
return true;
}-*/;
- public final native boolean contains(Object o)
- /*-{
-
+ public final native boolean contains(Object o) /*-{
return this.indexOf(o) >= 0;
}-*/;
- public final native void remove(Object o)
- /*-{
-
+ public final native void remove(Object o) /*-{
var i = this.indexOf(o);
if (i >= 0) this.splice(i, 1);
}-*/;
- public final native int indexOf(Object o)
- /*-{
-
+ public final native int indexOf(Object o) /*-{
// HtmlUnit fails when this returns 0
return this.indexOf(o);
}-*/;
- public final native JsCache putBoolean(Object id, boolean b)
- /*-{
-
+ public final native JsCache putBoolean(Object id, boolean b) /*-{
this[id] = b;
return this;
}-*/;
- public final native JsCache putNumber(Object id, double n)
- /*-{
-
+ public final native JsCache putNumber(Object id, double n) /*-{
this[id] = n;
return this;
}-*/;
return this;
}
- public final native JsCache putObject(Object id, Object obj)
- /*-{
-
+ public final native JsCache putObject(Object id, Object obj) /*-{
this[id] = obj;
return this;
}-*/;
- public final native int length()
- /*-{
-
+ public final native int length() /*-{
if (typeof(this.length) == 'number')
return this.length;
checkNull(this);
}
- private final native JsArrayString keysImpl()
- /*-{
-
+ private final native JsArrayString keysImpl() /*-{
var key, keys=[];
// Chrome in DevMode sets '__gwt_ObjectId' to JS objects
// GWT sets '$H' when calling getHashCode (see com/google/gwt/core/client/impl/Impl.java)
}-*/;
/**
- * Throw a NPE when a js is null
+ * Throw a NPE when a js is null.
*/
public static final <T extends JavaScriptObject> T checkNull(T js) {
if (!GWT.isProdMode() && js == null) {
/**
* Gets an object wrapped in a js array and boxes it with the appropriate
- * Object in the GWT world.
+ * object in the GWT world.
*
* It is thought to be called from other jsni code without dealing with casting issues.
*
*
* Example
* <pre>
- * native Object myMethod()
- /*-{
-
+ * native Object myMethod() /*-{
* var myJsVar = ... ;
* return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ myJsVar ]);
* }-* /
* </pre>
*
*/
- public static native Object gwtBox(JavaScriptObject oneElementArray)
- /*-{
-
+ public static native Object gwtBox(JavaScriptObject oneElementArray) /*-{
var r = oneElementArray;
if (typeof r == 'object' && r.length == 1) {
var r = r[0], t = typeof r;
/**
* Invoke the closure with no arguments and expecting no return value.
*/
- public final native void invoke()
- /*-{
-
+ public final native void invoke() /*-{
return this();
}-*/;
}
/**
* Lightweight JSO backed implemented of a Map, using Object.hashCode() as key.
+ *
+ * @param <S>
+ * @param <T>
*/
-final public class JsMap<S, T> extends JavaScriptObject {
+public final class JsMap<S, T> extends JavaScriptObject {
protected JsMap() {
}
return old;
}
- public final String[] keys() {
+ public String[] keys() {
return c().keys();
}
import com.google.gwt.core.client.JavaScriptObject;
/**
- * Lightweight JSO backed implemented of a named array
+ * Lightweight JSO backed implemented of a named array.
+ *
+ * @param <T>
*/
-final public class JsNamedArray<T> extends JavaScriptObject {
+public final class JsNamedArray<T> extends JavaScriptObject {
protected JsNamedArray() {
}
c().put(key, val);
}
- public final String[] keys() {
+ public String[] keys() {
return c().keys();
}
return c().length();
}
- public final Object[] values() {
+ public Object[] values() {
return c().elements();
}
- public final boolean exists(String key){
+ public boolean exists(String key){
return c().exists(key);
}
- public final void delete(String key){
+ public void delete(String key){
c().delete(key);
}
- public final static <T> JsNamedArray<T> create() {
+ public static <T> JsNamedArray<T> create() {
return createObject().cast();
}
}
return create((Node)null);
}
- public static native JsNodeArray create(Node node)
- /*-{
-
+ public static native JsNodeArray create(Node node) /*-{
return node ? [node] : [];
}-*/;
/**
* Lightweight JSO based array class that can store objects.
+ *
+ * @param <T>
*/
public final class JsObjectArray<T> extends JavaScriptObject {
@Deprecated
public class JsRegexp {
- public static native JavaScriptObject compile(String pat)
- /*-{
-
+ public static native JavaScriptObject compile(String pat) /*-{
return new RegExp(pat);
}-*/;
- public static native JavaScriptObject compileFlags(String pat, String flags)
- /*-{
-
+ public static native JavaScriptObject compileFlags(String pat, String flags) /*-{
return new RegExp(pat, flags);
}-*/;
return new JsRegexp(regexp, flags).match(string);
}
- private static native JsObjectArray<String> exec0(JavaScriptObject regexp, String str)
- /*-{
-
+ private static native JsObjectArray<String> exec0(JavaScriptObject regexp, String str) /*-{
return regexp.exec(str);
}-*/;
return test0(regexp, rule);
}
- private native JsObjectArray<String> match0(JavaScriptObject regexp, String currentRule)
- /*-{
-
+ private native JsObjectArray<String> match0(JavaScriptObject regexp, String currentRule) /*-{
return currentRule.match(regexp);
}-*/;
- private native boolean test0(JavaScriptObject regexp, String rule)
- /*-{
-
+ private native boolean test0(JavaScriptObject regexp, String rule) /*-{
return regexp.test(rule);
}-*/;
return jso.equals(obj);
}
- private native Object exec(JavaScriptObject f, Object data)
- /*-{
+ public int hashCode() {
+ return jso.hashCode();
+ }
+ private native Object exec(JavaScriptObject f, Object data) /*-{
return @com.google.gwt.query.client.js.JsCache::gwtBox(*)([ f(data) ]);
}-*/;
* Wraps a GQuery function into a native javascript one so as we can
* export Java methods without using JSNI.
*/
- public static native JavaScriptObject wrapFunction (Function f)
- /*-{
-
+ public static native JavaScriptObject wrapFunction(Function f) /*-{
return function(r) {
var o = @java.util.ArrayList::new()();
for (i in arguments) {
}
}-*/;
+ /**
+ * Default JsUtils implementation.
+ */
public static class JsUtilsImpl {
- public native Properties parseJSON(String json)
- /*-{
-
+ public native Properties parseJSON(String json) /*-{
return $wnd.JSON.parse(json);
}-*/;
- public native String JSON2String(JavaScriptObject o)
- /*-{
-
+ public native String JSON2String(JavaScriptObject o) /*-{
return $wnd.JSON.stringify(o);
}-*/;
- public native Element parseXML(String xml)
- /*-{
-
+ public native Element parseXML(String xml) /*-{
return new DOMParser().parseFromString(xml, "text/xml").documentElement;
}-*/;
return ret;
}
- public native String XML2String(JavaScriptObject o)
- /*-{
-
+ public native String XML2String(JavaScriptObject o) /*-{
return (new XMLSerializer()).serializeToString(o);
}-*/;
}
+ /**
+ * IE JsUtils implemetation.
+ */
public static class JsUtilsImplIE6 extends JsUtilsImpl {
- public static final native Properties evalImpl(String properties)
- /*-{
-
+ public static final native Properties evalImpl(String properties) /*-{
return eval(properties);
}-*/;
}
@Override
- public native Element parseXML(String xml)
- /*-{
-
+ public native Element parseXML(String xml) /*-{
var d = new ActiveXObject("Microsoft.XmlDom");
d.loadXML(xml);
return d.documentElement;
}
@Override
- public native String XML2String(JavaScriptObject o)
- /*-{
-
+ public native String XML2String(JavaScriptObject o) /*-{
return o.xml;
}-*/;
- private native String xmlText(Element e)
- /*-{
-
+ private native String xmlText(Element e) /*-{
return e.text;
}-*/;
}
}
/**
- * Set a property to a javascript object
+ * Set a property to a javascript object.
*/
public static void prop(JavaScriptObject o, Object id, Object val) {
if (o != null) {
}
/**
- * Camelize style property names. for instance: font-name -> fontName
+ * Camelize style property names.
+ * for instance: font-name -> fontName
*/
- public static native String camelize(String s)
- /*-{
-
+ public static native String camelize(String s) /*-{
return s.replace(/\-(\w)/g, function(all, letter) {
return letter.toUpperCase();
});
}
/**
- * Use the method in the gquery class $(elem).cur(prop, force);
+ * Use the method in the gquery class.
+ * $(elem).cur(prop, force);
*/
@Deprecated
public static double cur(Element elem, String prop, boolean force) {
/**
* Compare two numbers using javascript equality.
*/
- public static native boolean eq(double s1, double s2)
- /*-{
-
+ public static native boolean eq(double s1, double s2) /*-{
return s1 == s2;
}-*/;
/**
* Compare two objects using javascript equality.
*/
- public static native boolean eq(Object s1, Object s2)
- /*-{
-
+ public static native boolean eq(Object s1, Object s2) /*-{
return s1 == s2;
}-*/;
* Check if an object has already a property with name <code>name</code>
* defined.
*/
- public static native boolean hasProperty(JavaScriptObject o, String name)
- /*-{
-
+ public static native boolean hasProperty(JavaScriptObject o, String name) /*-{
return o && name in o;
}-*/;
/**
* Check whether an element has an attribute, this is here since GWT Element.getAttribute
* implementation returns an empty string instead of null when the attribute is not
- * present
+ * present.
*/
- public static native boolean hasAttribute(Element o, String name)
- /*-{
-
+ public static native boolean hasAttribute(Element o, String name) /*-{
return !!(o && o.getAttribute(name));
}-*/;
/**
- * Hyphenize style property names. for instance: fontName -> font-name
+ * Hyphenize style property names.
+ * for instance: fontName -> font-name
*/
- public static native String hyphenize(String name)
- /*-{
-
+ public static native String hyphenize(String name) /*-{
return name.replace(/([A-Z])/g, "-$1").toLowerCase();
}-*/;
/**
- * Check is a javascript object can be used as an array
+ * Check is a javascript object can be used as an array.
*/
- public static native boolean isArray(JavaScriptObject o)
- /*-{
-
+ public static native boolean isArray(JavaScriptObject o) /*-{
return Object.prototype.toString.call(o) == '[object Array]'
|| typeof o.length == 'number';
}-*/;
/**
- * Check is a javascript object is a FormData
+ * Check is a javascript object is a FormData.
*/
- public static native boolean isFormData(JavaScriptObject o)
- /*-{
-
+ public static native boolean isFormData(JavaScriptObject o) /*-{
return Object.prototype.toString.call(o) == '[object FormData]';
}-*/;
/**
- * Return whether the event was prevented
+ * Return whether the event was prevented.
*/
- public static native boolean isDefaultPrevented(JavaScriptObject e)
- /*-{
-
+ public static native boolean isDefaultPrevented(JavaScriptObject e) /*-{
return e.defaultPrevented || e.returnValue === false || e.getPreventDefault
&& e.getPreventDefault() ? true : false;
}-*/;
/**
- * Return whether a node is detached to the dom
+ * Return whether a node is detached to the DOM.
+ *
* Be careful : This method works only on node that should be inserted within the body node.
*/
public static boolean isDetached(Node n) {
}
/**
- * Check is a javascript object can be cast to an Element
+ * Check is a javascript object can be cast to an Element.
*/
- public static native boolean isElement(Object o)
- /*-{
-
+ public static native boolean isElement(Object o) /*-{
return o && o.nodeType && o.nodeName ? true : false;
}-*/;
/**
- * Check is a javascript object can be cast to an Event
+ * Check is a javascript object can be cast to an Event.
*/
public static boolean isEvent(JavaScriptObject o) {
return hasProperty(o, "currentTarget");
}
/**
- * Check is a javascript object is a function
+ * Check is a javascript object is a function.
*/
- public static native boolean isFunction(JavaScriptObject o)
- /*-{
-
+ public static native boolean isFunction(JavaScriptObject o) /*-{
return Object.prototype.toString.call(o) == '[object Function]';
}-*/;
/**
- * Check is a javascript can be cast to a node list
+ * Check is a javascript can be cast to a node list.
*/
- public static native boolean isNodeList(JavaScriptObject o)
- /*-{
-
+ public static native boolean isNodeList(JavaScriptObject o) /*-{
var r = Object.prototype.toString.call(o);
return r == '[object HTMLCollection]' || r == '[object NodeList]'
|| (typeof o == 'object' && o.length && o[0].tagName) ? true : false;
}-*/;
/**
- * Check is a javascript object is a Window
+ * Check is a javascript object is a Window.
*/
public static boolean isWindow(JavaScriptObject o) {
return hasProperty(o, "alert");
}
/**
- * Check if an element is a DOM or a XML node
+ * Check if an element is a DOM or a XML node.
*/
public static boolean isXML(Node o) {
return o == null ? false
/**
* Return the element which is truth in the double scope.
*/
- public static native double or(double s1, double s2)
- /*-{
-
+ public static native double or(double s1, double s2) /*-{
return s1 || s2;
}-*/;
/**
* Return the element which is truth in the javascript scope.
*/
- public static native <T> T or(T s1, T s2)
- /*-{
-
+ public static native <T> T or(T s1, T s2) /*-{
return s1 || s2;
}-*/;
* Utility method to cast objects in production.
* Useful for casting native implementations to interfaces like JsInterop
*/
- public static native <T> T cast(Object o)
- /*-{
-
+ public static native <T> T cast(Object o) /*-{
return o;
}-*/;
/**
* Utility method to cast objects to array of string in production.
*/
- public static native String[] castArrayString(Object a)
- /*-{
-
+ public static native String[] castArrayString(Object a) /*-{
return a
}-*/;
return runJavascriptFunctionImpl(o, meth, JsObjectArray.create().add(args).<JsArrayMixed>cast());
}
- private static native <T> T runJavascriptFunctionImpl(JavaScriptObject o, String meth, JsArrayMixed args)
- /*-{
-
+ private static native <T> T runJavascriptFunctionImpl(JavaScriptObject o, String meth, JsArrayMixed args) /*-{
return (f = o && o[meth])
&& @com.google.gwt.query.client.js.JsUtils::isFunction(*)(f)
&& @com.google.gwt.query.client.js.JsCache::gwtBox(*)([f.apply(o, args)]);
/**
* Check if a number is true in the javascript scope.
*/
- public static native boolean truth(double a)
- /*-{
-
+ public static native boolean truth(double a) /*-{
return a ? true : false;
}-*/;
/**
* Check if an object is true in the javascript scope.
*/
- public static native boolean truth(Object a)
- /*-{
-
+ public static native boolean truth(Object a) /*-{
return a ? true : false;
}-*/;
/**
- * Remove duplicates from an elements array
+ * Remove duplicates from an elements array.
*/
public static JsArray<Element> unique(JsArray<Element> a) {
return utilsImpl.unique(a);
/**
* Returns a QueryString representation of a JavascriptObject.
+ *
* TODO: jquery implementation accepts a second parameter (traditional)
*/
public static String param(JavaScriptObject js) {
/**
* Class to access protected methods in Animation.
*/
- public static abstract class GQAnimation extends Animation {
+ public abstract static class GQAnimation extends Animation {
private static final String ACTUAL_ANIMATION = "EffectsRunnning";
* Example:
*
* <pre class="code">
- * //move the element from its original position to the position top:500px and left:500px for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to the position top:500px and left:500px for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, EasingCurve.swing);
* // Change the width and border attributes of a table
* $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, EasingCurve.linear);
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
* $("#foo").animate($$("{backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'}"), 400, EasingCurve.swing);
* </pre>
*
- * @param p a {@link Properties} object containing css properties to animate.
+ * @param stringOrProperties object containing css properties to animate.
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'");
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400, EasingCurve.swing);
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", new Function(){
*
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
*/
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 2s
+ * // move the element from its original position to left:500px for 2s
* $("#foo").animate("left:'500px'", 2000);
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400);
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
}
/**
- * Only valid for IE6-8
+ * Only valid for IE6-8.
* @param event
* @return
*/
package com.google.gwt.query.client.plugins;
import com.google.gwt.query.client.Function;
import com.google.gwt.query.client.LazyBase;
-import com.google.gwt.query.client.Properties;
import com.google.gwt.query.client.plugins.effects.PropertiesAnimation.Easing;
+/**
+ * LazyEffects.
+ * @param <T>
+ */
public interface LazyEffects<T> extends LazyBase<T>{
/**
* Example:
*
* <pre class="code">
- * //move the element from its original position to the position top:500px and left:500px for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to the position top:500px and left:500px for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'500px',left:'500px'}"), 400, EasingCurve.swing);
* // Change the width and border attributes of a table
* $("table").animate(Properties.create("{$width: '500', $border: '10'}"), 400, EasingCurve.linear);
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left and 5OOpx down for 400ms.
- * //use a swing easing function for the transition
+ * // move the element from its original position to 500px to the left and 5OOpx down for 400ms.
+ * // use a swing easing function for the transition
* $("#foo").animate(Properties.create("{top:'+=500px',left:'+=500px'}"), 400, Easing.SWING);
* </pre>
*
* $("#foo").animate($$("{backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'}"), 400, EasingCurve.swing);
* </pre>
*
- * @param p a {@link Properties} object containing css properties to animate.
+ * @param stringOrProperties {@link Properties} object containing css properties to animate.
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 500ms
+ * // move the element from its original position to left:500px for 500ms
* $("#foo").animate("left:'500'");
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400, EasingCurve.swing);
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 500ms and
+ * // move the element from its original position to 500px to the left for 500ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", new Function(){
*
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)'");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
*/
* Example:
*
* <pre class="code">
- * //move the element from its original position to left:500px for 2s
+ * // move the element from its original position to left:500px for 2s
* $("#foo").animate("left:'500px'", 2000);
* // Change the width attribute of a table
* $("table").animate("$width:'500'"), 400);
* Example:
*
* <pre class="code">
- * //move the element from its original position to 500px to the left for 1000ms and
+ * // move the element from its original position to 500px to the left for 1000ms and
* // change the background color of the element at the end of the animation
* $("#foo").animate("left:'+=500'", 1000, new Function(){
* public void f(Element e){
* $("#foo").animate("backgroundColor:'red', color:'#ffffff', borderColor:'rgb(129, 0, 70)', 1000");
* </pre>
*
- * @param prop the property to animate : "cssName:'value'"
+ * @param stringOrProperties the property to animate : "cssName:'value'"
* @param funcs an array of {@link Function} called once the animation is
* complete
* @param duration the duration in milliseconds of the animation
* layout of the page.
*/
LazyEffects<T> toggle(int millisecs, Function... f);
+
}
import com.google.gwt.query.client.GQuery;
import com.google.gwt.query.client.LazyBase;
+/**
+ * LazyEvents.
+ * @param <T>
+ */
public interface LazyEvents<T> extends LazyBase<T>{
/**
LazyEvents<T> unbind(String name, Function f);
LazyEvents<T> undelegate();
+
}
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
+/**
+ * LazyWidgets.
+ * @param <T>
+ */
public interface LazyWidgets<T> extends LazyBase<T>{
/**
*
*/
LazyWidgets<T> textArea(WidgetInitializer<TextArea> initializers);
+
}
}
/**
- * Prevents starting of the plugin on specified elements
+ * Prevents starting of the plugin on specified elements.
*
* @param cancel
* array of css selectors
protected abstract String getPluginName();
/**
- * This method initialize all needed handlers
+ * This method initialize all needed handlers.
*
*/
protected void initMouseHandler(MouseOptions options) {
/**
* Test if the mouse down event must be handled by the plugin or not.
- *
*/
protected boolean mouseCapture(Element draggable, GqEvent event) {
return true;
}
/**
- * Method called when mouse click
- *
+ * Method called when mouse click.
*/
protected boolean mouseClick(Element element, GqEvent event) {
return true;
* Method called when mouse down occur on the element.
*
* You should not override this method. Instead, override {@link #mouseStart(Element, GqEvent)}
- * method
- *
+ * method.
*/
protected boolean mouseDown(Element element, GqEvent event) {
bindOtherEvents(element);
- if (!touchSupported){ //click event are not triggered if we call preventDefault on touchstart event.
+ if (!touchSupported){ // click event are not triggered if we call preventDefault on touchstart event.
event.getOriginalEvent().preventDefault();
}
}
/**
- * Method called when the mouse is dragging
- *
+ * Method called when the mouse is dragging.
*/
protected abstract boolean mouseDrag(Element element, GqEvent event);
protected abstract boolean mouseStart(Element element, GqEvent event);
/**
- * Method called when the mouse button is released
- *
+ * Method called when the mouse button is released.
*/
protected abstract boolean mouseStop(Element element, GqEvent event);
* Method called when mouse is released..
*
* You should not override this method. Instead, override {@link #mouseStop(Element, GqEvent)}
- * method
- *
+ * method.
*/
protected boolean mouseUp(Element element, GqEvent event) {
/**
* Class used in plugins which need a queue system.
+ *
+ * @param <T>
*/
public class QueuePlugin<T extends QueuePlugin<?>> extends GQuery {
}
/**
- * remove all queued functions from the effects queue
+ * remove all queued functions from the effects queue.
*/
public T clearQueue() {
return clearQueue(DEFAULT_NAME);
}
/**
- * remove all queued function from the named queue
+ * remove all queued function from the named queue.
*/
@SuppressWarnings("unchecked")
public T clearQueue(String name) {
}
/**
- * Add a delay in the effects queue
+ * Add a delay in the effects queue.
*/
public T delay(int milliseconds, Function... f) {
return delay(milliseconds, DEFAULT_NAME, f);
}
/**
- * Add a delay in the named queue
+ * Add a delay in the named queue.
*/
@SuppressWarnings("unchecked")
public T delay(int milliseconds, String name, Function... funcs) {
public class UiPlugin extends GQuery {
/**
- * A POJO used to store dimension of an element
+ * A POJO used to store dimension of an element.
*
*/
public static class Dimension {
}
/**
- * return the width value
+ * return the width value.
*/
public int getWidth() {
return width;
scrollParent = gQueryUi.parents().filter(new Predicate() {
public boolean f(Element e, int index) {
- GQuery $e = GQuery.$(e);
- String position = $e.css("position", true);
+ GQuery g = GQuery.$(e);
+ String position = g.css("position", true);
return ("relative".equals(position) || "absolute".equals(position) || "fixed"
.equals(position))
- && isOverflowEnabled($e);
+ && isOverflowEnabled(g);
}
});
} else {
return "absolute".equals(gQueryUi.css("position"));
}
- private final Element getViewportElement() {
+ private Element getViewportElement() {
return GQuery.document.isCSS1Compat() ? GQuery.document
.getDocumentElement() : GQuery.document.getBody();
}
}
/**
- * Create and return a widget using the given factory and the given options
+ * Create and return a widget using the given factory and the given options.
*/
protected <W extends Widget> W widget(Element e, WidgetFactory<W> factory,
WidgetInitializer<W> initializer) {
}
/**
- * Create and return a widget using the given factory and the given options
+ * Create and return a widget using the given factory and the given options.
*/
protected <W extends Widget> W widget(WidgetFactory<W> factory,
WidgetInitializer<W> initializers) {
public static final String JSON_CONTENT_TYPE_UTF8 = JSON_CONTENT_TYPE + "; charset=utf-8";
- public static interface AjaxTransport {
+ /**
+ * Ajax Transport object.
+ */
+ public interface AjaxTransport {
Promise getJsonP(Settings settings);
Promise getLoadScript(Settings settings);
}
/**
- * Ajax Settings object
+ * Ajax Settings object.
*/
public interface Settings extends JsonBuilder {
String getContentType();
}, properties);
* </pre>
*
- * @param url The url to connect
- * @param onSuccess a function to execute in the case of success
- * @param onError the function to execute on error
- * @param settings a Properties object with the configuration of the Ajax request.
*/
public static Promise ajax(Settings settings) {
resolveSettings(settings);
}
/**
- * Load a JavaScript file from any url using the script tag mechanism
+ * Load a JavaScript file from any url using the script tag mechanism.
*/
public static Promise loadScript(String url) {
return loadScript(url, null);
/**
* Iterface used for callbacks which could cancel the execution
- * when returning false;
- *
+ * when returning false.
*/
- public static interface Callback {
+ public interface Callback {
/**
- * Return false to avoid executing the rest of functions
+ * Return false to avoid executing the rest of functions.
*/
boolean f(Object ...objects);
}
}
/**
- * lock
+ * lock.
*/
public Callbacks lock() {
if (!isMemory) {
*/
public abstract class FunctionDeferred extends Function {
+ /**
+ * Cache types.
+ */
public static enum CacheType {NONE, ALL, RESOLVED, REJECTED};
protected Deferred dfd;
* }
* });
* </pre>
+ *
+ * @param <T>
*/
public class PromiseRPC<T> extends DeferredPromiseImpl implements AsyncCallback<T> {
public void onFailure(Throwable caught) {
/**
* Using this constructor we access to some things in the xmlHttpRequest
* which are not available in GWT, like adding progress handles or sending
- * javascript data (like forms in modern html5 file api)
+ * javascript data (like forms in modern html5 file api).
*/
public PromiseReqBuilder(Settings settings) {
String httpMethod = settings.getType();
}
/**
- * Using violator pattern to execute private method
+ * Using violator pattern to execute private method.
*/
- private native void fireOnResponseReceivedVltr(Request rq, RequestCallback cb)
- /*-{
-
+ private native void fireOnResponseReceivedVltr(Request rq, RequestCallback cb) /*-{
rq.@com.google.gwt.http.client.Request::fireOnResponseReceived(Lcom/google/gwt/http/client/RequestCallback;)(cb);
}-*/;
/**
- * Using violator pattern to use protected constructor
+ * Using violator pattern to use protected constructor.
*/
- private native Request createRequestVltr(XMLHttpRequest rq, int ms, RequestCallback cb)
- /*-{
-
+ private native Request createRequestVltr(XMLHttpRequest rq, int ms, RequestCallback cb) /*-{
return @com.google.gwt.http.client.Request::new(Lcom/google/gwt/xhr/client/XMLHttpRequest;ILcom/google/gwt/http/client/RequestCallback;)(rq,ms,cb);
}-*/;
}
}
// Using jsni because method send in JsonpRequestBuilder is private
- private final native void send(JsonpRequestBuilder bld, String url, AsyncCallback<?> cb)
- /*-{
-
+ private native void send(JsonpRequestBuilder bld, String url, AsyncCallback<?> cb) /*-{
bld.@com.google.gwt.jsonp.client.JsonpRequestBuilder::send(Ljava/lang/String;Lcom/google/gwt/user/client/rpc/AsyncCallback;Z)(url,cb,false);
}-*/;
}
public class Fx {
/**
- * Public variable to enable/disable effects
+ * Public variable to enable/disable effects.
*/
public static boolean off = false;
public static class ColorFx extends Fx {
/**
- * Specific class handle specific borderColor shortcut properties
+ * Specific class handle specific borderColor shortcut properties.
*/
public static class BorderColorFx extends ColorFx {
endColor = parseColor(endColorString);
startColors = JsNamedArray.create();
- GQuery $e = GQuery.$(e);
+ GQuery g = GQuery.$(e);
for (String border : borderColorProperties) {
- int[] startColor = parseColor($e.css(border, true));
+ int[] startColor = parseColor(g.css(border, true));
startColors.put(border, startColor);
}
}
public void applyValue(GQuery g, double progress) {
double ret = (start + ((end - start) * progress));
- String value = ("px".equals(unit) ? ((int) ret) : ret) + unit;
+ String val = ("px".equals(unit) ? ((int) ret) : ret) + unit;
if ("scrollTop".equals(cssprop)) {
g.scrollTop((int)ret);
} else if ("scrollLeft".equals(cssprop)) {
g.scrollLeft((int)ret);
} else if (attribute != null) {
- g.attr(attribute, value);
+ g.attr(attribute, val);
} else {
- g.css(cssprop, value);
+ g.css(cssprop, val);
}
}
/**
* Easing method to use.
*/
- public static interface Easing {
- public double interpolate(double progress);
+ public interface Easing {
+ double interpolate(double progress);
/**
* @deprecated use EasingCurve.linear instead
*/
- public Easing LINEAR = EasingCurve.linear;
+ Easing LINEAR = EasingCurve.linear;
/**
* @deprecated use EasingCurve.swing instead
*/
- public Easing SWING = EasingCurve.swing;
+ Easing SWING = EasingCurve.swing;
}
/**
String attr = g.attr(rkey);
MatchResult parts = REGEX_NUMBER_UNIT.exec(attr);
if (parts != null) {
- String $1 = parts.getGroup(1);
- String $2 = parts.getGroup(2);
- cur = Double.parseDouble($1);
- unit = $2 == null ? "" : $2;
+ String p1 = parts.getGroup(1);
+ String p2 = parts.getGroup(2);
+ cur = Double.parseDouble(p1);
+ unit = p2 == null ? "" : p2;
} else {
cur = g.cur(key, true);
key = rkey;
MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);
if (parts != null) {
- String $1 = parts.getGroup(1);
- String $2 = parts.getGroup(2);
- String $3 = parts.getGroup(3);
- end = Double.parseDouble($2);
+ String p1 = parts.getGroup(1);
+ String p2 = parts.getGroup(2);
+ String p3 = parts.getGroup(3);
+ end = Double.parseDouble(p2);
if (rkey == null) {
unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : //
- $3 == null || $3.isEmpty() ? "px" : $3;
+ p3 == null || p3.isEmpty() ? "px" : p3;
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;
+ } else if (p3 != null && !p3.isEmpty()) {
+ unit = p3;
}
- if ($1 != null && !$1.isEmpty()) {
- end = (("-=".equals($1) ? -1 : 1) * end) + start;
+ if (p1 != null && !p1.isEmpty()) {
+ end = (("-=".equals(p1) ? -1 : 1) * end) + start;
}
}
}
/**
* Animation effects on any numeric CSS3 property or transformation
- * using CSS3 transitions
+ * using CSS3 transitions.
*/
public class TransitionsAnimation extends PropertiesAnimation {
+ /**
+ * TransitionAnimation with Clip capabilities.
+ */
public static class TransitionsClipAnimation extends TransitionsAnimation {
private Action action;
}
}
- private static native void cleanGQListeners(Element elem)
- /*-{
-
+ private static native void cleanGQListeners(Element elem) /*-{
if (elem.__gwtlistener) {
@com.google.gwt.user.client.DOM::setEventListener(*)(elem, elem.__gwtlistener);
}
elem.__gwtlistener = elem.__gqueryevent = elem.__gquery = null;
}-*/;
- private static native EventsListener getGQueryEventListener(Element elem)
- /*-{
-
+ private static native EventsListener getGQueryEventListener(Element elem) /*-{
return elem.__gqueryevent;
}-*/;
- private static native EventListener getGwtEventListener(Element elem)
- /*-{
-
+ private static native EventListener getGwtEventListener(Element elem) /*-{
return elem.__gwtlistener;
}-*/;
- private static native void init(Element elem, EventsListener gqevent)
- /*-{
-
+ private static native void init(Element elem, EventsListener gqevent) /*-{
elem.__gwtlistener = @com.google.gwt.user.client.DOM::getEventListener(*)(elem);
elem.__gqueryevent = gqevent;
// Someone has reported that in IE the init can be called multiple times
if (elem.__gwtlistener == gqevent) elem.__gwtlistener = null;
}-*/;
- private static native void sinkBitlessEvent(Element elem, String name)
- /*-{
-
+ private static native void sinkBitlessEvent(Element elem, String name) /*-{
if (!elem.__gquery)
elem.__gquery = [];
if (elem.__gquery[name])
String nameSpace = null;
String eventName = event;
- //seperate possible namespace
- //jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8...
+ // seperate possible namespace
+ // jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8...
String[] subparts = event.split("\\.", 2);
if (subparts.length == 2){
eventName = subparts[0];
}
- //handle special event like mouseenter or mouseleave
+ // handle special event like mouseenter or mouseleave
SpecialEvent hook = special.get(eventName);
eventName = hook != null ? hook.getDelegateType() : eventName;
String originalEventName = hook != null ? hook.getOriginalType() : null;
String nameSpace = null;
String eventName = event;
- //seperate possible namespace
- //jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8...
+ // seperate possible namespace
+ // jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8...
String[] subparts = event.split("\\.", 2);
if (subparts.length == 2) {
eventName = subparts[0];
}
- //handle special event like mouseenter or mouseleave
+ // handle special event like mouseenter or mouseleave
SpecialEvent hook = special.get(eventName);
eventName = hook != null ? hook.getDelegateType() : eventName;
String originalEventName = hook != null ? hook.getOriginalType() : null;
eventName = subparts[0];
}
- //handle special event like mouseenter or mouseleave
+ // handle special event like mouseenter or mouseleave
SpecialEvent hook = special.get(eventName);
eventName = hook != null ? hook.getDelegateType() : eventName;
String originalEventName = hook != null ? hook.getOriginalType() : null;
String nameSpace = null;
String eventName = event;
- //seperate possible namespace
- //jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8...
+ // seperate possible namespace
+ // jDramaix: I removed old regex ^([^.]*)\.?(.*$) because it didn't work on IE8...
String[] subparts = event.split("\\.", 2);
if (subparts.length == 2){
eventName = subparts[0];
}
- //handle special event
+ // handle special event
SpecialEvent hook = special.get(eventName);
eventName = hook != null ? hook.getDelegateType() : eventName;
String originalEventName = hook != null ? hook.getOriginalType() : null;
*/
public class GqEvent extends Event {
- public static native void setOriginalEventType(NativeEvent evt, String originalEventName)
- /*-{
-
+ public static native void setOriginalEventType(NativeEvent evt, String originalEventName) /*-{
evt["__gwtquery_originalEventName"] = originalEventName;
}-*/;
- public static native String getOriginalEventType(Event evt)
- /*-{
-
+ public static native String getOriginalEventType(Event evt) /*-{
return evt["__gwtquery_originalEventName"] || null;
}-*/;
}
private static native void copy(
- Event originalEvent, GqEvent gQueryEvent)
- /*-{
-
+ Event originalEvent, GqEvent gQueryEvent) /*-{
for ( var field in originalEvent) {
gQueryEvent[field] = originalEvent[field];
}
}
/**
- * Return the original event (the one created by the browser)
+ * Return the original event (the one created by the browser).
*/
- public final native Event getOriginalEvent()
- /*-{
-
+ public final native Event getOriginalEvent() /*-{
return this.originalEvent;
}-*/;
- public final native void setCurrentElementTarget(Element e)
- /*-{
-
+ public final native void setCurrentElementTarget(Element e) /*-{
this.currentTarget = e;
- //ie don't have a currentEventTarget field on event
+ // ie don't have a currentEventTarget field on event
try{
@com.google.gwt.dom.client.DOMImplTrident::currentEventTarget = e;
}catch(e){}
}-*/;
/**
- * Tell whether ctrl or cmd key is pressed
+ * Tell whether ctrl or cmd key is pressed.
*
*/
public final boolean isMetaKeyPressed() {
}
/**
- * The mouse position relative to the left edge of the document
+ * The mouse position relative to the left edge of the document.
*
*/
public final int pageX() {
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.HTMLPanel;
+/**
+ * HtmlPanelWidgetFactory.
+ */
public class HtmlPanelWidgetFactory implements WidgetFactory<HTMLPanel> {
public HTMLPanel create(Element e) {
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Label;
+/**
+ * LabelWidgetFactory.
+ */
public class LabelWidgetFactory implements WidgetFactory<Label> {
public Label create(Element e) {
import com.google.gwt.user.client.ui.TextBoxBase;
/**
+ * TextBoxBaseWidgetFactory.
*
+ * @param <T>
*/
public abstract class TextBoxBaseWidgetFactory<T extends TextBoxBase>
implements WidgetFactory<T> {
return (T) textBox;
}
- protected String getEquivalentTagName(){
+ protected String getEquivalentTagName() {
return "input";
}
destination.setAccessKey(source.getAccessKey());
destination.setDefaultValue(source.getDefaultValue());
destination.setDisabled(source.isDisabled());
- if (source.getMaxLength() > 0) destination.setMaxLength(source.getMaxLength());
+ if (source.getMaxLength() > 0)
+ destination.setMaxLength(source.getMaxLength());
destination.setReadOnly(source.isReadOnly());
destination.setSize(source.getSize());
destination.setName(source.getName());
import com.google.gwt.user.client.ui.Widget;
/**
- * Factory interface
- *
- * @param <W>
- * @param <O>
- */
- public interface WidgetFactory<W extends Widget> {
- public W create(Element e);
- }
+ * Factory interface.
+ *
+ * @param <W>
+ */
+public interface WidgetFactory<W extends Widget> {
+ W create(Element e);
+}
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Widget;
+/**
+ * WidgetInitializer.
+ *
+ * @param <W>
+ */
public interface WidgetInitializer<W extends Widget> {
- /**
- * Initialize the newly created widget <code>w</code>. The element <code>e</code>
- * is the element used to construct the widget.
- *
- */
- void initialize(W w, Element e);
- }
+ /**
+ * Initialize the newly created widget <code>w</code>. The element <code>e</code>
+ * is the element used to construct the widget.
+ *
+ */
+ void initialize(W w, Element e);
+}
}
/**
- * use jsni to access private attribute
+ * use jsni to access private attribute.
*/
- private native void setElementImpl(Element e)
- /*-{
-
+ private native void setElementImpl(Element e) /*-{
this.@com.google.gwt.user.client.ui.UIObject::element = e;
}-*/;
import java.util.Iterator;
+/**
+ * WidgetsUtils.
+ */
public class WidgetsUtils {
static final String[] appendingTags = {
}
/**
- * Test if the tag name of the element is one of tag names given in parameter
+ * Test if the tag name of the element is one of tag names given in parameter.
*
* @param tagNames
* @return
}
}
- /**
+ /**
* If the <code>oldElement</code> is a td, th, li tags, the new element will replaced its content.
* In other cases, the <code>oldElement</code> will be replaced by the <code>newElement</code>
* and the old element classes will be copied to the new element.
}else{
GQuery.$(oldElement).replaceWith(newElement);
- //copy class
+ // copy class
String c = oldElement.getClassName();
if (!c.isEmpty()) {
newElement.addClassName(c);
}
- //copy id
+ // copy id
newElement.setId(oldElement.getId());
- //ensure no duplicate id
+ // ensure no duplicate id
oldElement.setId("");
}
}
}
/**
- * Remove a widget from the detach list
+ * Remove a widget from the detach list.
*/
public static void detachWidget(final Widget widget) {
if (widget != null) {
/**
* This method detach a widget of its parent without doing a physical
- * detach (DOM manipulation)
- *
- * @param w
+ * detach (DOM manipulation).
*/
public static void doLogicalDetachFromHtmlPanel(Widget w) {
Widget parent = w.getParent();
}
/**
- * Return children of the first widget's panel
+ * Return children of the first widget's panel.
*/
public static Iterator<Widget> getChildren(Widget w){
if(w instanceof Panel){
return $(element).parents().widget();
}
- private static native void widgetOnAttach(Widget w)
- /*-{
-
+ private static native void widgetOnAttach(Widget w) /*-{
w.@com.google.gwt.user.client.ui.Widget::onAttach()();
}-*/;
- private static native void widgetSetParent(Widget w, Widget p)
- /*-{
-
+ private static native void widgetSetParent(Widget w, Widget p) /*-{
w.@com.google.gwt.user.client.ui.Widget::setParent(Lcom/google/gwt/user/client/ui/Widget;)(p);
}-*/;
- private static native Widget compositeGetWidget(Composite w)
- /*-{
-
+ private static native Widget compositeGetWidget(Composite w) /*-{
return w.@com.google.gwt.user.client.ui.Composite::getWidget()();
}-*/;
- private static native WidgetCollection complexPanelGetChildren(ComplexPanel w)
- /*-{
-
+ private static native WidgetCollection complexPanelGetChildren(ComplexPanel w) /*-{
return w.@com.google.gwt.user.client.ui.ComplexPanel::getChildren()();
}-*/;
}
import java.io.PrintWriter;
/**
- * Creates an implementation for {@link Browser}
+ * Creates an implementation for {@link Browser}.
*/
public class BrowserGenerator extends Generator {
@Override
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.query.client.builders.JsniBundle;
import com.google.gwt.query.client.builders.JsniBundle.LibrarySource;
import com.google.gwt.query.client.builders.JsniBundle.MethodSource;
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory;
Set<String> attrs = new HashSet<String>();
for (JMethod method : clazz.getInheritableMethods()) {
String methName = method.getName();
- //skip method from JsonBuilder
+ // skip method from JsonBuilder
if(jsonBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null ||
settingsType.findMethod(method.getName(), method.getParameterTypes()) != null ) {
continue;
System.err.println("Invalid XPath generated selector, please revise it: " + xselector);
if (!selector.equals(xselector)) {
System.err.println("If your css2 selector syntax is correct, open an issue in the gwtquery project. cssselector:"
- + selector + " xpath:" + xselector);
+ + selector + " xpath: " + xselector);
}
throw new UnableToCompleteException();
}
//
// if (notNull(mm.group(1))) {
// mode = mm.group(1).replaceAll(trimReStr, "");
-// debug("replacing q=" + q + " this part:" + mm.group(1));
+// debug("replacing q=" + q + " this part: " + mm.group(1));
// q = q.replaceFirst("\\Q" + mm.group(1) + "\\E", "");
// }
// }
t[1], requestedClass);
if (sw != null) {
for (JMethod method : clazz.getInheritableMethods()) {
- //skip method from JsonBuilder
+ // skip method from JsonBuilder
if(xmlBuilderType.findMethod(method.getName(), method.getParameterTypes()) != null){
continue;
}
followRedirections = b;
}
- private final String USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0";
+ private static final String USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0";
private final String jsonpCbRexp = "(?ms)^.*jre_callback\\((.*)\\).*$";
public Promise getJsonP(final Settings settings) {
import java.util.StringTokenizer;
/**
- * @author Ian Brown spam@hccp.org
- * http://www.hccp.org/java-net-cookie-how-to.html
+ * http://www.hccp.org/java-net-cookie-how-to.html.
*/
public class CookieManager {
* Functions in JVM.
*/
static class JreJsonFunction extends JreJsonNull {
- final private Function function;
+ private final Function function;
public JreJsonFunction(Function f) {
function = f;
}
}
}
+ /**
+ *
+ */
public static class JsonBuilderHandler implements InvocationHandler {
private JsonObject jsonObject;
import java.util.Map;
/**
- * Implementation of `Response` in the JVM
+ * Implementation of `Response` in the JVM.
*/
public class ResponseJre extends Response {
private int status;
*/
public PromiseRF(Request<?>[] requests) {
for (Request<?> request : requests) {
- total ++;
+ total++;
request.to(new Receiver<Object>() {
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
dfd.reject(new ServerFailure("ConstraintViolation"), violations);