]> source.dussan.org Git - gwtquery.git/commitdiff
Seed plugins package
authorRay Cromwell <cromwellian@gmail.com>
Fri, 8 May 2009 00:03:12 +0000 (00:03 +0000)
committerRay Cromwell <cromwellian@gmail.com>
Fri, 8 May 2009 00:03:12 +0000 (00:03 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/Widgets.java [deleted file]
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Ratings.java [new file with mode: 0644]
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Widgets.java [new file with mode: 0644]

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 (file)
index 6fa411c..0000000
+++ /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<Widgets> {
-
-    public Widgets init(GQuery gq) {
-      return new Widgets(gq.get());
-    }
-  }
-
-  public static final Class<Widgets> 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 (file)
index 0000000..ae0bbcc
--- /dev/null
@@ -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<Ratings> {
+
+    public Ratings init(GQuery gq) {
+      return new Ratings(gq.get());
+    }
+  }
+
+  public static final Class<Ratings> 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<Element> 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 (file)
index 0000000..2a981a7
--- /dev/null
@@ -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<Widgets> {
+
+    public Widgets init(GQuery gq) {
+      return new Widgets(gq.get());
+    }
+  }
+
+  public static final Class<Widgets> 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;
+    }
+  }
+}