diff options
author | Julien Dramaix <julien.dramaix@gmail.com> | 2011-03-03 22:45:25 +0000 |
---|---|---|
committer | Julien Dramaix <julien.dramaix@gmail.com> | 2011-03-03 22:45:25 +0000 |
commit | 11b54244a60443d7a5a8edd1deb13833e8d24e59 (patch) | |
tree | 93d362732362a3ecbdd71e9b2d799834e0b325eb /samples | |
parent | 477fb6941d2b99634bbd532e4bf087c13393cccd (diff) | |
download | gwtquery-11b54244a60443d7a5a8edd1deb13833e8d24e59.tar.gz gwtquery-11b54244a60443d7a5a8edd1deb13833e8d24e59.zip |
improve widgets plugins
Diffstat (limited to 'samples')
-rw-r--r-- | samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java | 100 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html | 6 |
2 files changed, 29 insertions, 77 deletions
diff --git a/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java b/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java index e2bb19dc..cff828dd 100644 --- a/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java +++ b/samples/src/main/java/gwtquery/samples/client/GwtQueryWidgetModule.java @@ -22,94 +22,42 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.query.client.Function;
-import com.google.gwt.query.client.GQuery;
-import com.google.gwt.query.client.css.CSS;
-import com.google.gwt.query.client.css.Length;
-import com.google.gwt.query.client.css.RGBColor;
-import com.google.gwt.query.client.css.UriValue;
-import com.google.gwt.query.client.css.BackgroundAttachmentProperty.BackgroundAttachment;
-import com.google.gwt.query.client.css.BackgroundPositionProperty.BackgroundPosition;
-import com.google.gwt.query.client.css.BackgroundRepeatProperty.BackgroundRepeat;
-import com.google.gwt.query.client.plugins.widgets.ButtonWidgetFactory.ButtonOptions;
-import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.Widget;
public class GwtQueryWidgetModule implements EntryPoint {
-/* public void onModuleLoad() {
- $("<button>Enhance</button>").appendTo(".outer").one(Event.ONCLICK, null, new Function() {
- public boolean f(Event e) {
- $(".btn:nth-child(odd)").each(new Function(){
- public void f(Element el) {
- // Replace odd labels by a button
- GQuery g = $("<button/>");
- $(el).hide().after(g);
-
- // Use the Widgets plugin to convert the button element to a button.
- Button b = g.as(Widgets.Widgets).widget();
- b.setText("Foo");
- b.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- Window.alert("You Clicked the Button");
- }
- });
- }
- });
- return true;
- }
- });
- }*/
-
public void onModuleLoad() {
+
+ $(".inputText").as(Widgets).textBoxes();
-
- // Let gquery syntax to help gwt developers.
- GQuery buttons = $(".btn").as(Widgets).buttons().click(new Function() {
- public void f() {
- Label l = new Label("You click on a GWT Button !");
- PopupPanel panel = new PopupPanel(true, true);
- panel.setGlassEnabled(true);
- panel.add(l);
- panel.center();
- }
- });
-
- // The user use a widget in the traditional way
- buttons.eq(0).<Button>widget().addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- Window.alert("You clicked in the first button");
- }
- });
-
- $("#tabs").as(Widgets).tabPanel();
-
- // IDE suggestions are not available with this syntax. -> I agree
- // Also it implies that the css method in GQuery needs more overloads
- // $("#aaa").css(CSS.POSITION, Position.ABSOLUTE);
- // $("#aaa").css(CSS.TOP, Length.cm(15));
- // $("#aaa").css(CSS.BACKGROUND, RGBColor.RED, ImageValue.url(""), BackgroundRepeat.NO_REPEAT, BackgroundAttachment.FIXED, BackgroundPosition.CENTER);
-
- $("#aaa").css(CSS.TOP.with(Length.cm(15)));
- $("#aaa").css(CSS.BACKGROUND.with(RGBColor.SILVER, UriValue.url(""), BackgroundRepeat.NO_REPEAT, BackgroundAttachment.FIXED, BackgroundPosition.CENTER));
- $("#aaa").css(CSS.BACKGROUND_ATTACHMENT.with(BackgroundAttachment.FIXED));
- }
-
- private ButtonOptions createButtonOptions(){
- ButtonOptions options = new ButtonOptions();
- options.addClickHandler(new ClickHandler() {
+ $(".btn").as(Widgets).buttons(new Function() {
- public void onClick(ClickEvent event) {
- Label l = new Label("You click on a GWT Button !");
- PopupPanel panel = new PopupPanel(true, true);
- panel.setGlassEnabled(true);
- panel.add(l);
- panel.center();
+ public void f(Widget w) {
+ Button button = (Button) w;
+ button.addClickHandler(new ClickHandler() {
+
+ public void onClick(ClickEvent event) {
+ Label l = new Label("You click on a GWT Button !");
+ PopupPanel panel = new PopupPanel(true, true);
+ panel.setGlassEnabled(true);
+ panel.add(l);
+ panel.center();
+
+ }
+ });
+
}
+
});
+
+ $("#tabs").as(Widgets).tabPanel();
- return options;
+
+
}
+
}
diff --git a/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html b/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html index 0b189ab4..8e95b165 100644 --- a/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html +++ b/samples/src/main/java/gwtquery/samples/public/GwtQueryWidgets.html @@ -5,7 +5,7 @@ src="gwtquery.samples.GwtQueryWidgets.nocache.js"></script>
</head>
<body>
-<div id='aaa'>aaa</div>
+
<div class="outer">
<div class="btn">Make me a button 1!</div>
<a class="btn">Make me a button 2!</a> <span class="btn">Make me
@@ -15,6 +15,10 @@ a button 3!</span> <div class="btn">Make me a button 6!</div>
</div>
+<div class="inputText">I will be an Input</div>
+<span class="inputText">I will be an Input</span>
+<input class="inputText" type="text"></input>
+
<div id="tabs">
<h3>First tab</h3>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut
|