From: Ray Cromwell Date: Fri, 8 May 2009 00:03:12 +0000 (+0000) Subject: Seed plugins package X-Git-Tag: release-1.3.2~780 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=60b8cb8b841707818511442e0cdfa008c7c344da;p=gwtquery.git Seed plugins package --- diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Widgets.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Widgets.java deleted file mode 100644 index 6fa411c5..00000000 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Widgets.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.google.gwt.query.client; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.dom.client.NodeList; -import com.google.gwt.user.client.ui.Button; - -/** - * Experimental Gwt Query plugin for integrating Gwt Widgets. - */ -public class Widgets extends GQuery { - /** - * Used to register the plugin. - */ - private static class WidgetsPlugin implements Plugin { - - public Widgets init(GQuery gq) { - return new Widgets(gq.get()); - } - } - - public static final Class Widgets = Widgets.class; - - static { - GQuery.registerPlugin(Widgets.class, new WidgetsPlugin()); - } - - public Widgets(Element element) { - super(element); - } - - public Widgets(JSArray elements) { - super(elements); - } - - public Widgets(NodeList list) { - super(list); - } - - /** - * Create a builder capable of instantiating a GWT Button object over - * every matched element. Call end() to execute builder and return to the - * current query object. - * @return a ButtonBuilder - */ - public ButtonBuilder button() { - return new ButtonBuilder("*"); - } - - public class ButtonBuilder { - - private String selector; - - private String label; - - private String labelSelector; - - public ButtonBuilder(String selector) { - this.selector=selector; - } - - public ButtonBuilder label(String label) { - this.labelSelector = label; - return this; - } - - public Widgets end() { - for(Element e: elements()) { - Button b = Button.wrap(e); - b.setText($(labelSelector, e).text()); - - } - return Widgets.this; - } - } -} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Ratings.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Ratings.java new file mode 100644 index 00000000..ae0bbccd --- /dev/null +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Ratings.java @@ -0,0 +1,73 @@ +package com.google.gwt.query.client.plugins; + +import com.google.gwt.query.client.GQuery; +import com.google.gwt.query.client.Plugin; +import com.google.gwt.query.client.JSArray; +import com.google.gwt.query.client.SelectorEngine; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.InputElement; + +/** + * Star Rating plugin. + */ +public class Ratings extends GQuery { + + /** + * Used to register the plugin. + */ + private static class RatingsPlugin implements Plugin { + + public Ratings init(GQuery gq) { + return new Ratings(gq.get()); + } + } + + public static final Class Ratings = Ratings.class; + + static { + GQuery.registerPlugin(Ratings.class, new RatingsPlugin()); + } + + public Ratings(Element element) { + super(element); + } + + public Ratings(JSArray elements) { + super(elements); + } + + public Ratings(NodeList list) { + super(list); + } + + public Ratings rating() { + if (size() == 0) { + return this; + } + not(".star-rating-applied").addClass("star-rating-applied"); + Control control; + for (Element e : elements()) { + GQuery input = $(e); + String eid = SelectorEngine + .or(e.getPropertyString("name"), "unnamed-rating") + .replaceAll("\\[|\\]", "_").replaceAll("^\\_+|\\_$", ""); + GQuery context = $(getContext(e)); + Raters raters = (Raters) context.data("rating"); + } + + return this; + } + + public static class Control { + + } + + public static class Raters { + + } + + private static native Element getContext(Element e) /*-{ + return this.form || $doc.body; + }-*/; +} diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java new file mode 100644 index 00000000..2a981a7e --- /dev/null +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java @@ -0,0 +1,78 @@ +package com.google.gwt.query.client.plugins; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.query.client.GQuery; +import com.google.gwt.query.client.Plugin; +import com.google.gwt.query.client.JSArray; + +/** + * Experimental Gwt Query plugin for integrating Gwt Widgets. + */ +public class Widgets extends GQuery { + /** + * Used to register the plugin. + */ + private static class WidgetsPlugin implements Plugin { + + public Widgets init(GQuery gq) { + return new Widgets(gq.get()); + } + } + + public static final Class Widgets = Widgets.class; + + static { + GQuery.registerPlugin(Widgets.class, new WidgetsPlugin()); + } + + public Widgets(Element element) { + super(element); + } + + public Widgets(JSArray elements) { + super(elements); + } + + public Widgets(NodeList list) { + super(list); + } + + /** + * Create a builder capable of instantiating a GWT Button object over + * every matched element. Call end() to execute builder and return to the + * current query object. + * @return a ButtonBuilder + */ + public ButtonBuilder button() { + return new ButtonBuilder("*"); + } + + public class ButtonBuilder { + + private String selector; + + private String label; + + private String labelSelector; + + public ButtonBuilder(String selector) { + this.selector=selector; + } + + public ButtonBuilder label(String label) { + this.labelSelector = label; + return this; + } + + public Widgets end() { + for(Element e: elements()) { + Button b = Button.wrap(e); + b.setText($(labelSelector, e).text()); + + } + return Widgets.this; + } + } +}