@@ -86,7 +86,7 @@ | |||
<replace-with class="com.google.gwt.query.client.impl.SelectorEngineNative"> | |||
<when-type-assignable | |||
class="com.google.gwt.query.client.impl.SelectorEngineImpl"/> | |||
<when-property-is name="selectorCapability" value="native"/> | |||
<when-property-is name="selectorCapability" value="native"/> | |||
</replace-with> | |||
<entry-point class='com.google.gwt.query.client.css.CSS'/> |
@@ -24,7 +24,7 @@ import com.google.gwt.dom.client.NodeList; | |||
* GQuery class as '$' if they desire. | |||
*/ | |||
public class $ { | |||
public static GQuery $(String selectorOrHtml) { | |||
return GQuery.$(selectorOrHtml); | |||
} | |||
@@ -88,7 +88,6 @@ public class $ { | |||
/** | |||
* Return a lazy version of the GQuery interface. Lazy function calls are | |||
* simply queued up and not executed immediately. | |||
* @return | |||
*/ | |||
public static LazyGQuery lazy() { | |||
return GQuery.lazy(); |
@@ -15,8 +15,8 @@ | |||
*/ | |||
package com.google.gwt.query.client; | |||
import com.google.gwt.dom.client.Node; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.Node; | |||
import com.google.gwt.dom.client.NodeList; | |||
/** |
@@ -147,8 +147,8 @@ public class Effects extends GQuery { | |||
public void show() { | |||
opt.cache.put(prop, elem.getStyle().getProperty(prop)); | |||
opt.show = true; | |||
custom("width".equals("width") || "height".equals(prop) ? 1 : 0, | |||
cur(false)); | |||
custom("width".equals(prop) || "height".equals(prop) ? 1 : 0, cur(false)); | |||
$(elem).show(); | |||
} | |||
public Effects toggle(Speed speed) { |
@@ -94,7 +94,7 @@ public class Events extends GQuery { | |||
*/ | |||
class FireEvents { | |||
public static void fire(Element element, int eventbits, int... keys) { | |||
public static void fire(Element element, int eventbits, int... keys) { | |||
Event event = null; | |||
String type = getEventTypeStr(eventbits); |
@@ -15,10 +15,10 @@ | |||
*/ | |||
package com.google.gwt.query.client; | |||
import com.google.gwt.user.client.EventListener; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.user.client.DOM; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.EventListener; | |||
/** | |||
* This class implements an event queue instance for one element. This queue | |||
@@ -123,7 +123,7 @@ class EventsListener implements EventListener { | |||
public void onBrowserEvent(Event event) { | |||
int etype = DOM.eventGetType(event); | |||
for (int i=0; i<elementEvents.length(); i++) { | |||
for (int i = 0; i < elementEvents.length(); i++) { | |||
EventsListener.BindFunction listener = elementEvents.get(i); | |||
if (listener.hasEventType(etype)) { | |||
if (!listener.fire(event)) { | |||
@@ -136,9 +136,9 @@ class EventsListener implements EventListener { | |||
} | |||
public void unbind(int eventbits) { | |||
JsObjectArray<EventsListener.BindFunction> newList | |||
= JsObjectArray.createArray().cast(); | |||
for (int i=0; i<elementEvents.length(); i++) { | |||
JsObjectArray<EventsListener.BindFunction> newList = JsObjectArray | |||
.createArray().cast(); | |||
for (int i = 0; i < elementEvents.length(); i++) { | |||
EventsListener.BindFunction listener = elementEvents.get(i); | |||
if (!listener.hasEventType(eventbits)) { | |||
newList.add(listener); |
@@ -19,25 +19,21 @@ import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.user.client.Event; | |||
/** | |||
* Extend this class to implement functions callbacks. | |||
* Extend this class to implement functions callbacks. | |||
*/ | |||
public abstract class Function { | |||
/** | |||
* Override this for GQuery methods which loop over matched elements and | |||
* invoke a callback on each element. | |||
* @param e | |||
* @param i | |||
* @return | |||
*/ | |||
public String f(Element e, int i) { | |||
return ""; | |||
public String f(Element e, int i) { | |||
return ""; | |||
} | |||
/** | |||
* Override this for GQuery methods which take a callback, but do not expect | |||
* a return value, apply to a single element only. | |||
* @param e | |||
* Override this for GQuery methods which take a callback, but do not expect a | |||
* return value, apply to a single element only. | |||
*/ | |||
public void f(Element e) { | |||
} | |||
@@ -45,9 +41,6 @@ public abstract class Function { | |||
/** | |||
* Override this method for bound event handlers if you wish to deal with | |||
* per-handler user data. | |||
* @param e | |||
* @param data | |||
* @return | |||
*/ | |||
public boolean f(Event e, Object data) { | |||
return f(e); | |||
@@ -55,8 +48,6 @@ public abstract class Function { | |||
/** | |||
* Override this method for bound event handlers. | |||
* @param e | |||
* @return | |||
*/ | |||
public boolean f(Event e) { | |||
f(e.getCurrentTarget()); |
@@ -199,7 +199,8 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { | |||
public static Class<GQuery> GQUERY = GQuery.class; | |||
private static JsMap<Class<? extends GQuery>, Plugin<? extends GQuery>> plugins; | |||
private static JsMap<Class<? extends GQuery>, Plugin<? extends GQuery>> | |||
plugins; | |||
private static Element windowData = null; | |||
@@ -338,8 +339,10 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { | |||
if (SelectorEngine.truth(s.getProperty(name))) { | |||
return s.getProperty(name); | |||
} | |||
return name.equals("opacity") ? "1" : ""; | |||
} else { | |||
return styleImpl.getCurrentStyle(elem, name); | |||
} | |||
return styleImpl.getCurrentStyle(elem, name); | |||
} | |||
/** | |||
@@ -359,13 +362,12 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { | |||
} | |||
protected static String[] jsArrayToString(JsArrayString array) { | |||
if(GWT.isScript()) { | |||
if (GWT.isScript()) { | |||
return jsArrayToString0(array); | |||
} | |||
else { | |||
String result[]=new String[array.length()]; | |||
for(int i=0; i<result.length; i++) { | |||
result[i]=array.get(i); | |||
} else { | |||
String result[] = new String[array.length()]; | |||
for (int i = 0; i < result.length; i++) { | |||
result[i] = array.get(i); | |||
} | |||
return result; | |||
} | |||
@@ -1716,7 +1718,7 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { | |||
for (Element e : elements()) { | |||
allPreviousSiblingElements(getPreviousSiblingElement(e), result); | |||
} | |||
return pushStack(unique(result),"prevAll", getSelector()); | |||
return pushStack(unique(result), "prevAll", getSelector()); | |||
} | |||
/** | |||
@@ -2048,6 +2050,13 @@ public class GQuery implements Lazy<GQuery, LazyGQuery> { | |||
return this; | |||
} | |||
/** | |||
* Toggle visibility of elements. | |||
*/ | |||
public GQuery toggle() { | |||
return as(Effects).toggle(); | |||
} | |||
/** | |||
* Toggle among two or more function calls every other click. | |||
*/ |
@@ -16,5 +16,4 @@ public class JsClosure extends JavaScriptObject { | |||
public final native void invoke() /*-{ | |||
return this(); | |||
}-*/; | |||
} |
@@ -3,11 +3,13 @@ package com.google.gwt.query.client; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
/** | |||
* Lightweight JSO backed implemented of a Map, using Object.hashCode() as | |||
* key. | |||
*/ | |||
final public class JsMap<S,T> extends JavaScriptObject { | |||
protected JsMap() {} | |||
* Lightweight JSO backed implemented of a Map, using Object.hashCode() as key. | |||
*/ | |||
final public class JsMap<S, T> extends JavaScriptObject { | |||
protected JsMap() { | |||
} | |||
public T get(S key) { | |||
return get(key.hashCode()); | |||
} |
@@ -7,7 +7,9 @@ import com.google.gwt.core.client.JavaScriptObject; | |||
* other JSOs. | |||
*/ | |||
public final class JsObjectArray<T> extends JavaScriptObject { | |||
protected JsObjectArray() {} | |||
protected JsObjectArray() { | |||
} | |||
public void add(T val) { | |||
set(length(), val); | |||
@@ -16,6 +18,7 @@ public final class JsObjectArray<T> extends JavaScriptObject { | |||
public native T get(int i) /*-{ | |||
return this[i]; | |||
}-*/; | |||
public native int length() /*-{ | |||
return this.length; | |||
}-*/; |
@@ -2,17 +2,16 @@ package com.google.gwt.query.client; | |||
/** | |||
* A tagging interface which triggers the LazyGenerator for type T. | |||
* LazyGenerator creates an implementation of Type T for the class by | |||
* forwarding 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. | |||
* LazyGenerator creates an implementation of Type T for the class by forwarding | |||
* 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. | |||
*/ | |||
public interface Lazy<S, T extends LazyBase> { | |||
/** | |||
* Create a lazy instance of the current class. Most implementing classes | |||
* will automate this by simply invoking GWT.create(). | |||
* @return | |||
* Create a lazy instance of the current class. Most implementing classes will | |||
* automate this by simply invoking GWT.create(). | |||
*/ | |||
T createLazy(); | |||
T createLazy(); | |||
} |
@@ -2,8 +2,9 @@ package com.google.gwt.query.client; | |||
/** | |||
* All lazy interfaces must extend this baseclass. This ensures the done() | |||
* method exists and returns an executable function. | |||
* method exists and returns an executable function. | |||
*/ | |||
public interface LazyBase<S> { | |||
Function done(); | |||
Function done(); | |||
} |
@@ -8,8 +8,8 @@ public interface LazyEffects extends LazyGQuery { | |||
LazyEffects animate(Properties properties, Effects.Speed speed, | |||
Effects.Easing easing, Function complete); | |||
LazyEffects animate(Properties properties, int speed, | |||
Effects.Easing easing, Function complete); | |||
LazyEffects animate(Properties properties, int speed, Effects.Easing easing, | |||
Function complete); | |||
LazyEffects fadeIn(); | |||
@@ -1,14 +1,14 @@ | |||
package com.google.gwt.query.client; | |||
import com.google.gwt.dom.client.Node; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.Node; | |||
//import com.google.gwt.query.client.css.CssProperty; | |||
/** | |||
* Created by IntelliJ IDEA. User: ray Date: May 2, 2009 Time: 10:48:07 PM To | |||
* change this template use File | Settings | File Templates. | |||
*/ | |||
public interface LazyGQuery<T> extends LazyBase<T> { | |||
public interface LazyGQuery<T> extends LazyBase<T> { | |||
/** | |||
* Add elements to the set of matched elements if they are not included yet. |
@@ -17,16 +17,15 @@ package com.google.gwt.query.client; | |||
/** | |||
* A GQuery plugin. All GQuery plugins must implement this interface. | |||
* | |||
* @param <T> the plugin class | |||
*/ | |||
public interface Plugin<T extends GQuery> { | |||
/** | |||
* Called by the GQuery.as() method in order to pass the current matched | |||
* set. Typically a plugin will want to call a super class copy constructor | |||
* in order to copy the internal matched set of elements. | |||
* @param gQuery | |||
* @return | |||
* Called by the GQuery.as() method in order to pass the current matched set. | |||
* Typically a plugin will want to call a super class copy constructor in | |||
* order to copy the internal matched set of elements. | |||
*/ | |||
T init(GQuery gQuery); | |||
T init(GQuery gQuery); | |||
} |
@@ -21,5 +21,6 @@ import com.google.gwt.dom.client.Element; | |||
* A predicate function used by some GQuery methods. | |||
*/ | |||
public interface Predicate { | |||
boolean f(Element e, int index); | |||
boolean f(Element e, int index); | |||
} |
@@ -34,7 +34,7 @@ public class Properties extends JavaScriptObject { | |||
protected Properties() { | |||
} | |||
public final Properties $$(String key, String value) { | |||
set(key, value); | |||
return this; |
@@ -15,10 +15,10 @@ | |||
*/ | |||
package com.google.gwt.query.client; | |||
import java.lang.annotation.Target; | |||
import static java.lang.annotation.ElementType.METHOD; | |||
import java.lang.annotation.Retention; | |||
import java.lang.annotation.RetentionPolicy; | |||
import static java.lang.annotation.ElementType.METHOD; | |||
import java.lang.annotation.Target; | |||
/** | |||
* Used to pass a CSS Selector to a generator at compile time | |||
@@ -26,5 +26,6 @@ import static java.lang.annotation.ElementType.METHOD; | |||
@Target({METHOD}) | |||
@Retention(RetentionPolicy.RUNTIME) | |||
public @interface Selector { | |||
String value(); | |||
String value(); | |||
} |
@@ -24,7 +24,7 @@ import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.query.client.impl.SelectorEngineImpl; | |||
/** | |||
* Core Selector engine functions, and native JS utility functions. | |||
* Core Selector engine functions, and native JS utility functions. | |||
*/ | |||
public class SelectorEngine { | |||
@@ -45,7 +45,7 @@ public class SelectorEngine { | |||
return n.previousSibling || null; | |||
}-*/; | |||
public static native <T> T or(T s1, T s2) /*-{ | |||
public static native <T> T or(T s1, T s2) /*-{ | |||
return s1 || s2; | |||
}-*/; | |||
@@ -19,5 +19,6 @@ package com.google.gwt.query.client; | |||
* Tagging interface used to generate compile time selectors. | |||
*/ | |||
public interface Selectors { | |||
DeferredGQuery[] getAllSelectors(); | |||
DeferredGQuery[] getAllSelectors(); | |||
} |
@@ -1,15 +1,12 @@ | |||
package com.google.gwt.query.client.css; | |||
import com.google.gwt.dom.client.Style; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
import com.google.gwt.core.client.GWT; | |||
/** | |||
* This property sets the background color of an element, either a <color> value | |||
* or the keyword 'transparent', to make the underlying colors shine through. | |||
*/ | |||
public class BackgroundColor | |||
implements CssProperty<RGBColor> { | |||
public class BackgroundColor implements CssProperty<RGBColor> { | |||
public static void init() { | |||
CSS.BACKGROUND_COLOR = new BackgroundColor(); |
@@ -1,26 +1,24 @@ | |||
package com.google.gwt.query.client.css; | |||
import com.google.gwt.dom.client.Style; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
import com.google.gwt.core.client.GWT; | |||
/** | |||
* This property describes the foreground color of an element's text content. | |||
*/ | |||
public class Color implements CssProperty<RGBColor> { | |||
public Color() { | |||
} | |||
public static void init() { | |||
CSS.COLOR = new Color(); | |||
} | |||
public void set(Style s, RGBColor value) { | |||
s.setProperty("color", value.value()); | |||
public Color() { | |||
} | |||
public String get(Style s) { | |||
return s.getProperty("color"); | |||
} | |||
public void set(Style s, RGBColor value) { | |||
s.setProperty("color", value.value()); | |||
} | |||
} |
@@ -9,7 +9,7 @@ public interface CssProperty<T> { | |||
/** | |||
* Set the style to the given value. | |||
* @param s | |||
* | |||
* @param value a value from the enumerated type T | |||
*/ | |||
void set(Style s, T value); | |||
@@ -17,8 +17,6 @@ public interface CssProperty<T> { | |||
/** | |||
* Return the value of the property as an enumerated type, or null, if the | |||
* value falls outside the enumerated set. | |||
* @param s | |||
* @return | |||
*/ | |||
String get(Style s); | |||
} |
@@ -4,9 +4,10 @@ import com.google.gwt.dom.client.Style; | |||
/** | |||
* An enumerated CSS property with values of type X,Y,W,Z. | |||
*/ | |||
public interface CssProperty4<X,Y,Z,W> { | |||
*/ | |||
public interface CssProperty4<X, Y, Z, W> { | |||
void set(Style s, X value1, Y value2, Z value3, W value4); | |||
String get(Style s); | |||
} |
@@ -11,6 +11,43 @@ import com.google.gwt.dom.client.Style; | |||
*/ | |||
public class Cursor implements CssProperty<Cursor.CursorValue> { | |||
final static public class CursorValue extends JavaScriptObject { | |||
protected static CursorValue create(String val) { | |||
return GWT.isScript() ? createWeb(val) : createHosted(val); | |||
} | |||
private static native CursorValue createHosted(String val) /*-{ | |||
return [val]; | |||
}-*/; | |||
private static native CursorValue createWeb(String val) /*-{ | |||
return val; | |||
}-*/; | |||
protected CursorValue() { | |||
} | |||
public String value() { | |||
return GWT.isScript() ? valueWeb() : valueHosted(); | |||
} | |||
private native String valueHosted() /*-{ | |||
return this[0]; | |||
}-*/; | |||
private native String valueWeb() /*-{ | |||
return this; | |||
}-*/; | |||
} | |||
/** | |||
* Returns a cursor located at the given uri. | |||
*/ | |||
public static CursorValue cursor(String uri) { | |||
return CursorValue.create("uri(" + uri + ")"); | |||
} | |||
public static void init() { | |||
CSS.CURSOR = new Cursor(); | |||
CSS.CURSOR_AUTO = CursorValue.create("auto"); | |||
@@ -32,48 +69,11 @@ public class Cursor implements CssProperty<Cursor.CursorValue> { | |||
CSS.CURSOR_W_RESIZE = CursorValue.create("w-resize"); | |||
} | |||
public void set(Style s, CursorValue value) { | |||
s.setProperty("float", value.value()); | |||
} | |||
public String get(Style s) { | |||
return s.getProperty("float"); | |||
} | |||
/** | |||
* Returns a cursor located at the given uri. | |||
*/ | |||
public static CursorValue cursor(String uri) { | |||
return CursorValue.create("uri(" + uri + ")"); | |||
} | |||
final static public class CursorValue extends JavaScriptObject { | |||
protected CursorValue() { | |||
} | |||
protected static CursorValue create(String val) { | |||
return GWT.isScript() ? createWeb(val) : createHosted(val); | |||
} | |||
public String value() { | |||
return GWT.isScript() ? valueWeb() : valueHosted(); | |||
} | |||
private static native CursorValue createWeb(String val) /*-{ | |||
return val; | |||
}-*/; | |||
private static native CursorValue createHosted(String val) /*-{ | |||
return [val]; | |||
}-*/; | |||
private native String valueWeb() /*-{ | |||
return this; | |||
}-*/; | |||
private native String valueHosted() /*-{ | |||
return this[0]; | |||
}-*/; | |||
public void set(Style s, CursorValue value) { | |||
s.setProperty("float", value.value()); | |||
} | |||
} |
@@ -1,8 +1,6 @@ | |||
package com.google.gwt.query.client.css; | |||
import com.google.gwt.dom.client.Style; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
import com.google.gwt.core.client.GWT; | |||
/** | |||
* This property specifies the content height of boxes generated by block-level, |
@@ -13,8 +13,6 @@ public class Length extends JavaScriptObject { | |||
/** | |||
* Size in pixels. | |||
* @param amt | |||
* @return | |||
*/ | |||
public static Length px(int amt) { | |||
return GWT.isScript() ? createWeb(amt + "px") : createHosted(amt + "px"); |
@@ -1,4 +1,5 @@ | |||
package com.google.gwt.query.client.css; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
@@ -12,8 +13,6 @@ public class Percentage extends JavaScriptObject { | |||
/** | |||
* Size in percentage units. | |||
* @param amt | |||
* @return | |||
*/ | |||
public static Percentage pct(int amt) { | |||
return GWT.isScript() ? createWeb(amt + "%") : createHosted(amt + "%"); |
@@ -12,24 +12,25 @@ public class RGBColor extends JavaScriptObject { | |||
} | |||
public static void init() { | |||
CSS.AQUA=rgb("aqua"); | |||
CSS.BLACK=rgb("black"); | |||
CSS.FUSCHIA=rgb("fuschia"); | |||
CSS.GRAY=rgb("gray"); | |||
CSS.GREEN=rgb("green"); | |||
CSS.LIME=rgb("lime"); | |||
CSS.MAROON=rgb("lime"); | |||
CSS.NAVY=rgb("navy"); | |||
CSS.OLIVE=rgb("olive"); | |||
CSS.ORANGE=rgb("orange"); | |||
CSS.PURPLE=rgb("purple"); | |||
CSS.RED=rgb("red"); | |||
CSS.SILVER=rgb("silver"); | |||
CSS.TEAL=rgb("teal"); | |||
CSS.WHITE=rgb("white"); | |||
CSS.YELLOW=rgb("yellow"); | |||
CSS.TRANSPARENT=rgb("transparent"); | |||
CSS.AQUA = rgb("aqua"); | |||
CSS.BLACK = rgb("black"); | |||
CSS.FUSCHIA = rgb("fuschia"); | |||
CSS.GRAY = rgb("gray"); | |||
CSS.GREEN = rgb("green"); | |||
CSS.LIME = rgb("lime"); | |||
CSS.MAROON = rgb("lime"); | |||
CSS.NAVY = rgb("navy"); | |||
CSS.OLIVE = rgb("olive"); | |||
CSS.ORANGE = rgb("orange"); | |||
CSS.PURPLE = rgb("purple"); | |||
CSS.RED = rgb("red"); | |||
CSS.SILVER = rgb("silver"); | |||
CSS.TEAL = rgb("teal"); | |||
CSS.WHITE = rgb("white"); | |||
CSS.YELLOW = rgb("yellow"); | |||
CSS.TRANSPARENT = rgb("transparent"); | |||
} | |||
/** | |||
* RGB color in hexidecimal. | |||
*/ |
@@ -6,5 +6,6 @@ import com.google.gwt.dom.client.Style; | |||
* Interface to be implemented by properties which take length units. | |||
*/ | |||
public interface TakesLength { | |||
void setLength(Style s, Length p); | |||
void setLength(Style s, Length p); | |||
} |
@@ -1,8 +1,6 @@ | |||
package com.google.gwt.query.client.css; | |||
import com.google.gwt.dom.client.Style; | |||
import com.google.gwt.core.client.JavaScriptObject; | |||
import com.google.gwt.core.client.GWT; | |||
/** | |||
* This property specifies the content width of boxes generated by block-level |
@@ -16,8 +16,8 @@ | |||
package com.google.gwt.query.client.impl; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.query.client.SelectorEngine; | |||
import com.google.gwt.query.client.GQuery; | |||
import com.google.gwt.query.client.SelectorEngine; | |||
/** | |||
* A helper class to get computed CSS styles for elements. |
@@ -125,8 +125,9 @@ public abstract class SelectorEngineImpl { | |||
/** | |||
* Parse and execute a given selector expression given a context. | |||
* | |||
* @param selector the CSS selector expression | |||
* @param ctx the DOM node to use as a context | |||
* @param ctx the DOM node to use as a context | |||
* @return a list of matched nodes | |||
*/ | |||
public abstract NodeList<Element> select(String selector, Node ctx); |
@@ -16,16 +16,16 @@ | |||
package com.google.gwt.query.client.impl; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.dom.client.Node; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.query.client.SelectorEngine; | |||
/** | |||
* Runtime selector engine implementation for browsers with native | |||
* Runtime selector engine implementation for browsers with native | |||
* querySelectorAll support. | |||
*/ | |||
public class SelectorEngineNative extends SelectorEngineImpl { | |||
public NodeList<Element> select(String selector, Node ctx) { | |||
return SelectorEngine.querySelectorAll(selector, ctx); | |||
} |
@@ -19,9 +19,8 @@ import com.google.gwt.core.client.GWT; | |||
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.Regexp; | |||
import com.google.gwt.query.client.JSArray; | |||
import com.google.gwt.query.client.Regexp; | |||
import com.google.gwt.query.client.SelectorEngine; | |||
import static com.google.gwt.query.client.SelectorEngine.eq; | |||
import static com.google.gwt.query.client.SelectorEngine.truth; |
@@ -22,9 +22,8 @@ import com.google.gwt.core.ext.UnableToCompleteException; | |||
import com.google.gwt.core.ext.typeinfo.JClassType; | |||
import com.google.gwt.core.ext.typeinfo.JMethod; | |||
import com.google.gwt.core.ext.typeinfo.JParameter; | |||
import com.google.gwt.core.ext.typeinfo.TypeOracle; | |||
import com.google.gwt.core.ext.typeinfo.JGenericType; | |||
import com.google.gwt.core.ext.typeinfo.JTypeParameter; | |||
import com.google.gwt.core.ext.typeinfo.TypeOracle; | |||
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | |||
import com.google.gwt.user.rebind.SourceWriter; | |||
@@ -149,7 +148,7 @@ public class LazyGenerator extends Generator { | |||
sw.print(")"); | |||
// special case, as() needs to invoke createLazy() | |||
if("as".equals(method.getName())) { | |||
if ("as".equals(method.getName())) { | |||
sw.print(".createLazy()"); | |||
} | |||
sw.println(";"); | |||
@@ -200,11 +199,13 @@ public class LazyGenerator extends Generator { | |||
sw.println("public void f(Element e) {"); | |||
sw.indent(); | |||
String classID = nonLazyType.getSimpleSourceName(); | |||
if("GQuery".equals(classID)) { | |||
classID="GQUERY"; | |||
if ("GQuery".equals(classID)) { | |||
classID = "GQUERY"; | |||
} | |||
sw.println("ctx = GQuery.$(e).as(" + nonLazyType.getQualifiedSourceName() + "."+classID+");"); | |||
sw.println( | |||
"ctx = GQuery.$(e).as(" + nonLazyType.getQualifiedSourceName() + "." | |||
+ classID + ");"); | |||
sw.println("for (int i = 0; i < closures.length(); i++) {"); | |||
sw.indent(); | |||
sw.println("closures.get(i).invoke();"); |
@@ -23,9 +23,9 @@ import com.google.gwt.core.ext.typeinfo.JClassType; | |||
import com.google.gwt.core.ext.typeinfo.JMethod; | |||
import com.google.gwt.core.ext.typeinfo.JParameter; | |||
import com.google.gwt.core.ext.typeinfo.TypeOracle; | |||
import com.google.gwt.query.client.Selector; | |||
import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; | |||
import com.google.gwt.user.rebind.SourceWriter; | |||
import com.google.gwt.query.client.Selector; | |||
import java.io.PrintWriter; | |||
@@ -23,7 +23,6 @@ import com.google.gwt.user.rebind.SourceWriter; | |||
import java.util.regex.Pattern; | |||
/** | |||
* | |||
*/ | |||
@@ -43,7 +42,7 @@ public class SelectorGeneratorJSOptimal extends SelectorGeneratorBase { | |||
protected static Pattern nonSpace = Pattern.compile("\\S/"); | |||
private static final String trimReStr = "^\\s+|\\s+$"; | |||
protected static final String trimReStr = "^\\s+|\\s+$"; | |||
protected static Pattern trimRe = Pattern.compile(trimReStr); | |||
@@ -68,7 +67,6 @@ public class SelectorGeneratorJSOptimal extends SelectorGeneratorBase { | |||
"n = byAttribute(n, \"{1}\", \"{3}\", \"{2}\", \"{0}\");"), | |||
new RuleMatcher("^#([a-zA-Z_0-9-]+)", "n = byId(n, null, \"{0}\");")}; | |||
protected void generateMethodBody(SourceWriter sw, JMethod method, | |||
TreeLogger treeLogger, boolean hasContext) | |||
throws UnableToCompleteException { |
@@ -18,12 +18,11 @@ package com.google.gwt.query.rebind; | |||
import com.google.gwt.core.ext.TreeLogger; | |||
import com.google.gwt.core.ext.UnableToCompleteException; | |||
import com.google.gwt.core.ext.typeinfo.JMethod; | |||
import com.google.gwt.user.rebind.SourceWriter; | |||
import com.google.gwt.query.client.Selector; | |||
import com.google.gwt.user.rebind.SourceWriter; | |||
/** | |||
* Compile time selector generator which delegates to native browser | |||
* methods. | |||
* Compile time selector generator which delegates to native browser methods. | |||
*/ | |||
public class SelectorGeneratorNative extends SelectorGeneratorBase { | |||
@@ -41,8 +40,9 @@ public class SelectorGeneratorNative extends SelectorGeneratorBase { | |||
throws UnableToCompleteException { | |||
String selector = method.getAnnotation(Selector.class).value(); | |||
if (!hasContext) { | |||
sw.println("return " | |||
+ wrap(method, "querySelectorAll(\"" + selector + "\"") + ");"); | |||
sw.println( | |||
"return " + wrap(method, "querySelectorAll(\"" + selector + "\"") | |||
+ ");"); | |||
} else { | |||
sw.println("return " | |||
+ wrap(method, "querySelectorAll(\"" + selector + "\", root)") |
@@ -0,0 +1,22 @@ | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>com.google.gwt</groupId> | |||
<artifactId>gwtquery-project</artifactId> | |||
<version>1.0-SNAPSHOT</version> | |||
</parent> | |||
<name>GwtQuery Plugins</name> | |||
<artifactId>gwtquery-plugins</artifactId> | |||
<packaging>jar</packaging> | |||
<dependencies> | |||
<dependency> | |||
<groupId>${groupId}</groupId> | |||
<artifactId>gwtquery</artifactId> | |||
<version>${version}</version> | |||
<type>jar</type> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -0,0 +1,6 @@ | |||
<module> | |||
<inherits name='com.google.gwt.query.Query'/> | |||
<source path="plugins"/> | |||
</module> | |||
@@ -0,0 +1,73 @@ | |||
/* | |||
* Copyright 2009 Google Inc. | |||
* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |||
* use this file except in compliance with the License. You may obtain a copy of | |||
* the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |||
* License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
package gwtquery.plugins.collapser; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.query.client.Effects; | |||
import com.google.gwt.query.client.Function; | |||
import com.google.gwt.query.client.GQuery; | |||
import com.google.gwt.query.client.Plugin; | |||
import com.google.gwt.user.client.Event; | |||
/** | |||
* Collapser sample plugin. For all matched elements, adds a clickable [X] next | |||
* to the element which toggles its visibility. | |||
*/ | |||
public class Collapser extends GQuery { | |||
/** | |||
* Used to register the plugin. | |||
*/ | |||
private static class CollapserPlugin implements Plugin<Collapser> { | |||
public Collapser init(GQuery gq) { | |||
return new Collapser(gq.get()); | |||
} | |||
} | |||
/** | |||
* Plugin key for Collapser. | |||
*/ | |||
public static final Class<Collapser> Collapser = Collapser.class; | |||
static { | |||
GQuery.registerPlugin(Collapser.class, new CollapserPlugin()); | |||
} | |||
public Collapser(NodeList<Element> list) { | |||
super(list); | |||
} | |||
/** | |||
* Adds a [X] link button before each matched element with a bound click | |||
* handler that toggles visibility of the element. | |||
*/ | |||
public Collapser apply() { | |||
for (final Element e : elements()) { | |||
GQuery button = $("<a href='#'>[X]</a>"); | |||
$(e).before(button); | |||
button.click(new Function() { | |||
public boolean f(Event evt) { | |||
$(e).as(Effects.Effects).toggle(); | |||
return true; | |||
} | |||
}); | |||
} | |||
return this; | |||
} | |||
} |
@@ -0,0 +1,516 @@ | |||
package gwtquery.plugins.ratings; | |||
import com.google.gwt.core.client.JsArray; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.query.client.Function; | |||
import com.google.gwt.query.client.GQuery; | |||
import com.google.gwt.query.client.JSArray; | |||
import com.google.gwt.query.client.Plugin; | |||
import com.google.gwt.query.client.Properties; | |||
import com.google.gwt.query.client.Regexp; | |||
import com.google.gwt.query.client.SelectorEngine; | |||
import com.google.gwt.user.client.Event; | |||
/** | |||
* Star Rating plugin. | |||
*/ | |||
public class Ratings extends GQuery { | |||
public static class Control { | |||
public GQuery cancelButton; | |||
private int count; | |||
private String cancel = "Cancel Rating"; | |||
private String cancelValue = ""; | |||
private int split = 0; | |||
private int starWidth = 16; | |||
private int serial; | |||
private boolean readOnly; | |||
private boolean half; | |||
private GQuery current; | |||
private GQuery context; | |||
private JsArray<Element> stars = JsArray.createArray().cast(); | |||
private JsArray<Element> inputs = JsArray.createArray().cast(); | |||
private GQuery rater; | |||
public void addInput(Element element) { | |||
inputs.set(inputs.length(), element); | |||
} | |||
public void addStar(Element element) { | |||
stars.set(stars.length(), element); | |||
} | |||
public int bumpCount() { | |||
return count++; | |||
} | |||
public int getCount() { | |||
return count; | |||
} | |||
public Object getCurrent() { | |||
return current; | |||
} | |||
public NodeList<Element> getInputs() { | |||
return inputs.cast(); | |||
} | |||
public int getSerial() { | |||
return serial; | |||
} | |||
public int getSplit() { | |||
return split; | |||
} | |||
public Element getStar(int value) { | |||
return stars.get(value); | |||
} | |||
public NodeList<Element> getStars() { | |||
return stars.cast(); | |||
} | |||
public int getStarWidth() { | |||
return starWidth; | |||
} | |||
public boolean isHalf() { | |||
return half; | |||
} | |||
public boolean isReadOnly() { | |||
return readOnly; | |||
} | |||
public void setContext(GQuery context) { | |||
this.context = context; | |||
} | |||
public void setCurrent(GQuery current) { | |||
this.current = current; | |||
} | |||
public void setRater(GQuery rater) { | |||
this.rater = rater; | |||
} | |||
public void setReadOnly(boolean readOnly) { | |||
this.readOnly = readOnly; | |||
} | |||
public void setSerial(int serial) { | |||
this.serial = serial; | |||
} | |||
public void setSplit(int split) { | |||
this.split = split; | |||
} | |||
} | |||
public static class Raters { | |||
private int calls; | |||
private int count; | |||
private GQuery.DataCache cache = GQuery.DataCache.createObject().cast(); | |||
public Raters(int count, int calls) { | |||
this.count = count; | |||
this.calls = calls; | |||
} | |||
public int bumpCount() { | |||
return count++; | |||
} | |||
public GQuery get(String eid) { | |||
return (GQuery) cache.getObject(eid); | |||
} | |||
public int getCalls() { | |||
return calls; | |||
} | |||
public void put(String eid, GQuery q) { | |||
cache.put(eid, q); | |||
} | |||
} | |||
/** | |||
* 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; | |||
private static int calls; | |||
static { | |||
GQuery.registerPlugin(Ratings.class, new RatingsPlugin()); | |||
} | |||
private static native Element getContext(Element e) /*-{ | |||
return this.form || $doc.body; | |||
}-*/; | |||
public Ratings(Element element) { | |||
super(element); | |||
} | |||
public Ratings(JSArray elements) { | |||
super(elements); | |||
} | |||
public Ratings(NodeList<Element> list) { | |||
super(list); | |||
} | |||
public Ratings blurStar() { | |||
return this; | |||
} | |||
public Ratings drain() { | |||
for (Element e : elements()) { | |||
GQuery self = $(e); | |||
Control control = nullControlIfShouldSkipStar(self); | |||
if (control == null) { | |||
continue; | |||
} | |||
control.rater.children().filter(".rater-" + control.getSerial()) | |||
.removeClass("star-rating-on").removeClass("star-rating-hover"); | |||
} | |||
return this; | |||
} | |||
public Ratings draw() { | |||
for (Element e : elements()) { | |||
GQuery self = $(e); | |||
Control control = nullControlIfShouldSkipStar(self); | |||
if (control == null) { | |||
continue; | |||
} | |||
// Clear all stars | |||
self.as(Ratings).drain(); | |||
// Set control value | |||
if (control.getCurrent() != null) { | |||
((GQuery) control.current.data("rating.input")) | |||
.attr("checked", "checked"); | |||
control.current.prevAll().andSelf().filter(".rater-" + control.serial) | |||
.addClass("star-rating-on"); | |||
} else { | |||
$(control.getInputs()).removeAttr("checked"); | |||
} | |||
self.siblings().toggleClass("star-rating-readonly", control.isReadOnly()); | |||
} | |||
return this; | |||
} | |||
public Ratings fill() { | |||
for (Element e : elements()) { | |||
GQuery self = $(e); | |||
Control control = nullControlIfShouldSkipStar(self); | |||
if (control == null) { | |||
continue; | |||
} | |||
// Reset all stars and highlight them up to this element | |||
self.as(Ratings).drain(); | |||
self.prevAll().andSelf().filter(".rater-" + control.getSerial()) | |||
.addClass("star-rating-hover"); | |||
} | |||
return this; | |||
} | |||
public Ratings focusStar() { | |||
Control control = (Control) this.data("rating"); | |||
if (control == null) { | |||
return this; | |||
} | |||
// GQuery input = data("rating.input"); | |||
return this; | |||
} | |||
public Ratings rating() { | |||
if (size() == 0) { | |||
return this; | |||
} | |||
calls++; | |||
not(".star-rating-applied").addClass("star-rating-applied"); | |||
Control control = null; | |||
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"); | |||
if (raters == null || raters.getCalls() != calls) { | |||
raters = new Raters(0, calls); | |||
} | |||
GQuery rater = raters.get(eid); | |||
if (rater != null) { | |||
control = (Control) rater.data("rating"); | |||
} | |||
if (rater != null && control != null) { | |||
control.bumpCount(); | |||
} else { | |||
control = new Control(); | |||
control.setSerial(raters.bumpCount()); | |||
Properties metadata = getMetaData(input.get(0).getClassName()); | |||
if (metadata != null && metadata.defined("split")) { | |||
control.setSplit(metadata.getInt("split")); | |||
} | |||
// create rating element | |||
rater = $("<span class=\"star-rating-control\"/>"); | |||
input.before(rater); | |||
// Mark element for initialization (once all stars are ready) | |||
rater.addClass("rating-to-be-drawn"); | |||
// Accept readOnly setting from 'disabled' property | |||
if (SelectorEngine.truth(input.attr("disabled"))) { | |||
control.setReadOnly(true); | |||
} | |||
// Create 'cancel' button | |||
GQuery query = $( | |||
"<div class=\"rating-cancel\"><a title=\"" + control.cancel + "\">" | |||
+ control.cancelValue + "</a></div>"). | |||
mouseover(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).drain(); | |||
$(e).addClass("star-rating-hover"); | |||
return true; | |||
} | |||
}). | |||
mouseout(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).draw(); | |||
$(e).removeClass("star-rating-hover"); | |||
return true; | |||
} | |||
}). | |||
click(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).selectStar(); | |||
return true; | |||
} | |||
}); | |||
control.cancelButton = query; | |||
query.data("rating", control); | |||
rater.append(query); | |||
} | |||
// insert rating star | |||
GQuery star = $("<div class=\"star-rating rater-" + control.getSerial() | |||
+ "\"><a title=\"" | |||
+ (SelectorEngine.or(e.getTitle(), e.getPropertyString("value"))) | |||
+ "\">" + e.getPropertyString("value") + "</a></div>"); | |||
rater.append(star); | |||
// inherit attributes from input element | |||
if (e.getId() != null) { | |||
star.attr("id", e.getId()); | |||
} | |||
if (e.getClassName() != null) { | |||
star.addClass(e.getClassName()); | |||
} | |||
// Half-stars? | |||
if (control.isHalf()) { | |||
control.setSplit(2); | |||
} | |||
// Prepare division control | |||
if (control.getSplit() > 0) { | |||
int stw = star.width(); | |||
if (stw == 0) { | |||
stw = control.getStarWidth(); | |||
} | |||
int spi = (control.getCount() % control.getSplit()); | |||
int spw = (int) Math.floor(stw / control.getSplit()); | |||
star.width(spw).find("a").css("margin-left", "-" + (spi * spw) + "px"); | |||
} | |||
// readOnly? | |||
if (control.isReadOnly()) { | |||
star.addClass("star-rating-readonly"); | |||
} else { | |||
star.addClass("star-rating-live") | |||
// Attach mouse events | |||
.mouseover(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).fill(); | |||
$(e).as(Ratings).focusStar(); | |||
return true; | |||
} | |||
}).mouseout(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).draw(); | |||
$(e).as(Ratings).blurStar(); | |||
return true; | |||
} | |||
}).click(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).selectStar(); | |||
return true; | |||
} | |||
}); | |||
} | |||
// set current selection | |||
if (e.getPropertyBoolean("checked")) { | |||
control.setCurrent(star); | |||
} | |||
// hide input element | |||
input.hide(); | |||
// backward compatibility, form element to plugin | |||
input.change(new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).as(Ratings).selectStar(); | |||
return true; | |||
} | |||
}); | |||
// attach reference to star to input element and vice-versa | |||
star.data("rating.input", input.data("rating.star", star)); | |||
// store control information in form (or body when form not available) | |||
control.addStar(star.get(0)); | |||
control.addInput(input.get(0)); | |||
control.setRater(rater); | |||
raters.put(eid, rater); | |||
control.setContext(context); | |||
input.data("rating", control); | |||
rater.data("rating", control); | |||
star.data("rating", control); | |||
context.data("rating", raters); | |||
} | |||
// Initialize ratings (first draw) | |||
$(".rating-to-be-drawn").as(Ratings).draw() | |||
.removeClass("rating-to-be-drawn"); | |||
return this; | |||
} | |||
public Ratings selectStar(int value) { | |||
for (Element e : elements()) { | |||
GQuery self = $(e); | |||
Control control = nullControlIfShouldSkipStar(self); | |||
if (control == null) { | |||
continue; | |||
} | |||
control.setCurrent(null); | |||
$(control.getStar(value)).as(Ratings).selectStar(); | |||
} | |||
return this; | |||
} | |||
public Ratings selectStar() { | |||
for (Element e : elements()) { | |||
GQuery self = $(e); | |||
Control control = nullControlIfShouldSkipStar(self); | |||
if (control == null) { | |||
continue; | |||
} | |||
control.current = self.get(0).getTagName().equalsIgnoreCase("INPUT") | |||
? (GQuery) self.data("rating.star") | |||
: self.is(".rater-" + control.getSerial()) ? this : null; | |||
// Update rating control state | |||
self.data("rating", control); | |||
// Update display | |||
self.as(Ratings).draw(); | |||
// find data for event | |||
GQuery input = $(control.current != null ? (GQuery) control.current | |||
.data("rating.input") : null); | |||
// click callback, as requested here: http://plugins.jquery.com/node/1655 | |||
// if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event | |||
} | |||
return this; | |||
} | |||
public Ratings selectStar(String value) { | |||
for (Element e : elements()) { | |||
GQuery self = $(e); | |||
Control control = nullControlIfShouldSkipStar(self); | |||
if (control == null) { | |||
continue; | |||
} | |||
control.setCurrent(null); | |||
NodeList<Element> stars = control.getStars(); | |||
for (int i = 0; i < stars.getLength(); i++) { | |||
String val = ((GQuery) $(stars.getItem(i)).data("rating.input")).val(); | |||
if (val != null && val.equals(value)) { | |||
$(stars.getItem(i)).as(Ratings).selectStar(); | |||
} | |||
} | |||
} | |||
return this; | |||
} | |||
private Properties getMetaData(String className) { | |||
if (className.indexOf("{") == -1) { | |||
return Properties.createObject().cast(); | |||
} | |||
Regexp re = new Regexp("{(.*)}"); | |||
JSArray match = re.exec(className); | |||
if (match != null && match.size() > 1) { | |||
return Properties.create(match.getStr(1)); | |||
} | |||
return Properties.createObject().cast(); | |||
} | |||
private Control nullControlIfShouldSkipStar(GQuery q) { | |||
Control control = (Control) q.data("rating"); | |||
if (control == null) { | |||
return null; | |||
} | |||
// do not execute when control is in read-only mode | |||
if (control.isReadOnly()) { | |||
return null; | |||
} | |||
return control; | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */ | |||
div.rating-cancel, div.star-rating { | |||
float: left; | |||
width: 17px; | |||
height: 15px; | |||
text-indent: -999em; | |||
cursor: pointer; | |||
display: block; | |||
background: transparent; | |||
overflow: hidden | |||
} | |||
div.rating-cancel, div.rating-cancel a { | |||
background: url(delete.gif) no-repeat 0 -16px | |||
} | |||
div.star-rating, div.star-rating a { | |||
background: url(star.gif) no-repeat 0 0px | |||
} | |||
div.rating-cancel a, div.star-rating a { | |||
display: block; | |||
width: 16px; | |||
height: 100%; | |||
background-position: 0 0px; | |||
border: 0 | |||
} | |||
div.star-rating-on a { | |||
background-position: 0 -16px !important | |||
} | |||
div.star-rating-hover a { | |||
background-position: 0 -32px | |||
} | |||
/* Read Only CSS */ | |||
div.star-rating-readonly a { | |||
cursor: default !important | |||
} | |||
/* Partial Star CSS */ | |||
div.star-rating { | |||
background: transparent !important; | |||
overflow: hidden !important | |||
} | |||
/* END jQuery.Rating Plugin CSS */ |
@@ -0,0 +1,107 @@ | |||
package gwtquery.plugins.widgets; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.event.dom.client.ClickHandler; | |||
import com.google.gwt.query.client.GQuery; | |||
import com.google.gwt.query.client.JSArray; | |||
import com.google.gwt.query.client.Plugin; | |||
import com.google.gwt.user.client.ui.Button; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
/** | |||
* 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 = null; | |||
private String labelSelector = null; | |||
private Collection<ClickHandler> handlers = new ArrayList<ClickHandler>(); | |||
public ButtonBuilder(String selector) { | |||
this.selector = selector; | |||
} | |||
public ButtonBuilder labelQuery(String label) { | |||
this.labelSelector = label; | |||
return this; | |||
} | |||
public ButtonBuilder label(String label) { | |||
this.label = label; | |||
return this; | |||
} | |||
public ButtonBuilder addClickHandler(ClickHandler handler) { | |||
handlers.add(handler); | |||
return this; | |||
} | |||
public Widgets end() { | |||
for (Element e : elements()) { | |||
Button b = null; | |||
if ("button".equalsIgnoreCase(e.getTagName())) { | |||
b = Button.wrap(e); | |||
} else { | |||
Element bElt = $("<button name='button' value='Click Me'>").get(0); | |||
$(e).hide().before(bElt); | |||
b = Button.wrap(bElt); | |||
} | |||
b.setText(label != null ? label | |||
: (labelSelector == null ? $(e) : $(labelSelector, e)).text()); | |||
for (ClickHandler handler : handlers) { | |||
b.addClickHandler(handler); | |||
} | |||
} | |||
return Widgets.this; | |||
} | |||
} | |||
} |
@@ -38,6 +38,7 @@ | |||
<modules> | |||
<module>gwtquery-core</module> | |||
<module>plugins</module> | |||
<module>samples</module> | |||
</modules> | |||
@@ -19,6 +19,12 @@ | |||
<type>jar</type> | |||
</dependency> | |||
<dependency> | |||
<groupId>${groupId}</groupId> | |||
<artifactId>gwtquery-plugins</artifactId> | |||
<version>${version}</version> | |||
<type>jar</type> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> |
@@ -1,7 +1,7 @@ | |||
<module> | |||
<inherits name='com.google.gwt.query.Query'/> | |||
<entry-point class='gwtquery.samples.client.GwtQueryDemoModule'/> | |||
</module> | |||
@@ -1,7 +1,7 @@ | |||
<module> | |||
<inherits name='com.google.gwt.query.Query'/> | |||
<entry-point class='gwtquery.samples.client.GwtQueryEffectsModule'/> | |||
</module> | |||
@@ -1,7 +1,10 @@ | |||
<module> | |||
<inherits name='com.google.gwt.query.Query'/> | |||
<!--<inherits name='com.google.gwt.query.Query'/>--> | |||
<!--<inherits name='gwtquery.Plugins'/>--> | |||
<inherits name='com.google.gwt.user.User'/> | |||
<entry-point class='gwtquery.samples.client.GwtQueryPluginModule'/> | |||
</module> | |||
@@ -1,7 +1,10 @@ | |||
<module> | |||
<inherits name='com.google.gwt.query.Query'/> | |||
<!--<inherits name='com.google.gwt.query.Query'/>--> | |||
<inherits name='com.google.gwt.user.User'/> | |||
<add-linker name="xs"/> | |||
<set-property name="user.agent" value="gecko1_8"/> | |||
<entry-point class='gwtquery.samples.client.GwtQuerySampleModule'/> | |||
</module> | |||
@@ -1,7 +1,6 @@ | |||
<module> | |||
<inherits name='com.google.gwt.query.Query'/> | |||
<inherits name='gwtquery.Plugins'/> | |||
<entry-point class='gwtquery.samples.client.GwtQueryWidgetModule'/> | |||
</module> | |||
@@ -44,7 +44,6 @@ public class GwtQueryBenchModule implements EntryPoint { | |||
new DojoBenchmark(), new PrototypeBenchmark()); | |||
} | |||
}); | |||
} | |||
public interface Benchmark { |
@@ -2,84 +2,84 @@ package gwtquery.samples.client; | |||
import com.google.gwt.core.client.EntryPoint; | |||
import com.google.gwt.core.client.GWT; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.dom.client.Document; | |||
import com.google.gwt.dom.client.Element; | |||
import com.google.gwt.dom.client.Node; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.dom.client.NodeList; | |||
import com.google.gwt.query.client.Function; | |||
import com.google.gwt.query.client.GQuery; | |||
import static com.google.gwt.query.client.GQuery.$; | |||
import com.google.gwt.query.client.Selector; | |||
import com.google.gwt.query.client.Function; | |||
import com.google.gwt.query.client.Selectors; | |||
import static com.google.gwt.query.client.GQuery.$; | |||
import static com.google.gwt.query.client.Effects.Effects; | |||
import com.google.gwt.user.client.Event; | |||
/** | |||
* | |||
* | |||
*/ | |||
public class GwtQueryDemoModule implements EntryPoint { | |||
// Compile-time Selectors! | |||
public interface Slide extends Selectors { | |||
// find all LI elements in DIV.slide elements | |||
@Selector("div.slide li") | |||
NodeList<Element> allSlideBullets(); | |||
// find all LI elements rooted at ctx | |||
@Selector("li") | |||
NodeList<Element> slideBulletsCtx(Node ctx); | |||
// Compile-time Selectors! | |||
public interface Slide extends Selectors { | |||
// find all LI elements in DIV.slide elements | |||
@Selector("div.slide li") | |||
NodeList<Element> allSlideBullets(); | |||
// Find all DIV elements with class 'slide' | |||
@Selector("div.slide") | |||
NodeList<Element> allSlides(); | |||
// Find all DIV elements with class 'slide' | |||
@Selector("div.slide") | |||
NodeList<Element> allSlides(); | |||
} | |||
// find all LI elements rooted at ctx | |||
@Selector("li") | |||
NodeList<Element> slideBulletsCtx(Node ctx); | |||
} | |||
public void onModuleLoad() { | |||
// Ask GWT compiler to generate our interface | |||
final Slide s = GWT.create(Slide.class); | |||
public void onModuleLoad() { | |||
// Ask GWT compiler to generate our interface | |||
final Slide s = GWT.create(Slide.class); | |||
$(s.allSlides()).hide().eq(0).show(); | |||
$(s.allSlides()).hide().eq(0).show(); | |||
// we initially hide all bullets | |||
$(s.allSlideBullets()).hide(); | |||
// we initially hide all bullets | |||
$(s.allSlideBullets()).hide(); | |||
// add onclick handler to body element | |||
$(Document.get().getBody()).click(new Function() { | |||
// two state variables to note current slide being shown | |||
// and current bullet | |||
int curSlide = 0; | |||
int curBullets = 0; | |||
// add onclick handler to body element | |||
$(Document.get().getBody()).click(new Function() { | |||
// two state variables to note current slide being shown | |||
// and current bullet | |||
int curSlide = 0; | |||
// query and store all slides, and bullets of current slide | |||
GQuery slides = $(s.allSlides()); | |||
GQuery bullets = $(s.slideBulletsCtx(slides.get(curSlide))); | |||
int curBullets = 0; | |||
public boolean f(Event e) { | |||
// onclick, if not all bullets shown, show a bullet and increment | |||
if (curBullets < bullets.size()) { | |||
bullets.eq(curBullets++).show(); | |||
} else { | |||
// all bullets shown, hide them and current slide | |||
// query and store all slides, and bullets of current slide | |||
GQuery slides = $(s.allSlides()); | |||
GQuery bullets = $(s.slideBulletsCtx(slides.get(curSlide))); | |||
public boolean f(Event e) { | |||
// onclick, if not all bullets shown, show a bullet and increment | |||
if (curBullets < bullets.size()) { | |||
bullets.eq(curBullets++).show(); | |||
} else { | |||
// all bullets shown, hide them and current slide | |||
// bullets.css("opacity","0"); | |||
bullets.hide(); | |||
slides.eq(curSlide).hide(); | |||
bullets.hide(); | |||
slides.eq(curSlide).hide(); | |||
// slides.eq(curSlide).css("display", "none"); | |||
// move to next slide, checking for wrap around | |||
curSlide++; | |||
if(curSlide == slides.size()) { | |||
curSlide = 0; | |||
} | |||
curBullets = 0; | |||
// query for new set of bullets, and show next slide | |||
// by changing opacity to 1 and display to block | |||
bullets = $(s.slideBulletsCtx(slides.get(curSlide))); | |||
slides.eq(curSlide).show(); | |||
} | |||
return true; | |||
} | |||
}); | |||
} | |||
// move to next slide, checking for wrap around | |||
curSlide++; | |||
if (curSlide == slides.size()) { | |||
curSlide = 0; | |||
} | |||
curBullets = 0; | |||
// query for new set of bullets, and show next slide | |||
// by changing opacity to 1 and display to block | |||
bullets = $(s.slideBulletsCtx(slides.get(curSlide))); | |||
slides.eq(curSlide).show(); | |||
} | |||
return true; | |||
} | |||
}); | |||
} | |||
} |
@@ -1,16 +1,14 @@ | |||
package gwtquery.samples.client; | |||
import com.google.gwt.core.client.EntryPoint; | |||
import com.google.gwt.query.client.Effects; | |||
import com.google.gwt.query.client.Function; | |||
import static com.google.gwt.query.client.Effects.Easing.LINEAR; | |||
import static com.google.gwt.query.client.Effects.Effects; | |||
import static com.google.gwt.query.client.Effects.Easing.*; | |||
import com.google.gwt.query.client.Function; | |||
import static com.google.gwt.query.client.GQuery.$; | |||
import static com.google.gwt.query.client.GQuery.$$; | |||
import static com.google.gwt.query.client.GQuery.lazy; | |||
import com.google.gwt.user.client.Event; | |||
public class GwtQueryEffectsModule implements EntryPoint { | |||
public void onModuleLoad() { | |||
@@ -23,7 +21,6 @@ public class GwtQueryEffectsModule implements EntryPoint { | |||
css("color", "blue"). | |||
done()); | |||
$("div.outer > div").css("position", "relative").dblclick(new Function() { | |||
public boolean f(Event e) { | |||
$("div.outer > div").as(Effects). |
@@ -5,11 +5,12 @@ import com.google.gwt.event.dom.client.ClickEvent; | |||
import com.google.gwt.event.dom.client.ClickHandler; | |||
import com.google.gwt.query.client.Function; | |||
import static com.google.gwt.query.client.GQuery.$; | |||
import com.google.gwt.query.client.plugins.Ratings; | |||
import com.google.gwt.query.client.plugins.Widgets; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Window; | |||
import gwtquery.plugins.collapser.Collapser; | |||
import static gwtquery.plugins.ratings.Ratings.Ratings; | |||
import static gwtquery.plugins.widgets.Widgets.Widgets; | |||
public class GwtQueryPluginModule implements EntryPoint { | |||
@@ -20,16 +21,17 @@ public class GwtQueryPluginModule implements EntryPoint { | |||
@Override | |||
public boolean f(Event e) { | |||
$(e).attr("disabled", "true"); | |||
$("input").as(Ratings.Ratings).rating(); | |||
$("input").as(Ratings).rating(); | |||
return true; | |||
} | |||
}); | |||
$(".btn:nth-child(odd)").as(Widgets.Widgets).button() | |||
$(".btn:nth-child(odd)").as(Widgets).button() | |||
.addClickHandler(new ClickHandler() { | |||
public void onClick(ClickEvent clickEvent) { | |||
Window.alert("You Clicked the Button"); | |||
} | |||
}).end(); | |||
$(".collapsible").as(Collapser.Collapser).apply(); | |||
} | |||
} |
@@ -5,10 +5,10 @@ import com.google.gwt.event.dom.client.ClickEvent; | |||
import com.google.gwt.event.dom.client.ClickHandler; | |||
import com.google.gwt.query.client.Function; | |||
import static com.google.gwt.query.client.GQuery.$; | |||
import com.google.gwt.query.client.plugins.Widgets; | |||
import com.google.gwt.user.client.Event; | |||
import com.google.gwt.user.client.Window; | |||
import static gwtquery.plugins.widgets.Widgets.Widgets; | |||
public class GwtQueryWidgetModule implements EntryPoint { | |||
@@ -18,7 +18,7 @@ public class GwtQueryWidgetModule implements EntryPoint { | |||
$("#enhance").one(Event.ONCLICK, null, new Function() { | |||
@Override | |||
public boolean f(Event e) { | |||
$(".btn:nth-child(odd)").as(Widgets.Widgets).button().label("Foo") | |||
$(".btn:nth-child(odd)").as(Widgets).button().label("Foo") | |||
.addClickHandler(new ClickHandler() { | |||
public void onClick(ClickEvent clickEvent) { | |||
Window.alert("You Clicked the Button"); | |||
@@ -28,6 +28,5 @@ public class GwtQueryWidgetModule implements EntryPoint { | |||
return true; | |||
} | |||
}); | |||
} | |||
} |
@@ -14,6 +14,7 @@ public interface MySelectors extends Selectors { | |||
// NodeList<Element> h1IdContainsSelectors(); | |||
// | |||
@Selector("a[href][lang][class]") | |||
NodeList<Element> aHrefLangClass(); | |||
@@ -36,6 +37,7 @@ public interface MySelectors extends Selectors { | |||
// NodeList<Element> allFirst(); | |||
// | |||
@Selector("div:not(.example)") | |||
NodeList<Element> divNotExample(); | |||
@@ -15,15 +15,14 @@ | |||
<!--</script>--> | |||
<style> | |||
* { | |||
font-family: "Lucida Grande",Helvetica,Arial,sans-serif; | |||
color: white; | |||
font-family: "Lucida Grande", Helvetica, Arial, sans-serif; | |||
color: white; | |||
} | |||
body { | |||
background-color: black; | |||
} | |||
.win { | |||
background-color: green; | |||
color: white | |||
@@ -44,22 +43,29 @@ | |||
color: white | |||
} | |||
</style> | |||
</style> | |||
</head> | |||
<body> | |||
<h2 style="width: 790px; color: white; border-bottom: 1px solid gray">GWTSpeed - GWT Query | |||
benchmarks<div id="startrace" style="float: right; color: red">Start Race</div></h2> | |||
<iframe id="racetrack" src="racetrack.html" width="800" height="310" frameborder="0" marginheight="0" marginwidth="0"></iframe> | |||
<h2 style="width: 790px; color: white; border-bottom: 1px solid gray">GWTSpeed - | |||
GWT Query | |||
benchmarks | |||
<div id="startrace" style="float: right; color: red">Start Race</div> | |||
</h2> | |||
<iframe id="racetrack" src="racetrack.html" width="800" height="310" | |||
frameborder="0" marginheight="0" marginwidth="0"></iframe> | |||
<iframe id="jquerybench" src="jquerybench.html" style="display: none"></iframe> | |||
<iframe id="dojobench" src="dojobench.html" style="display: none"></iframe> | |||
<iframe id="prototypebench" src="prototypebench.html" style="display: none"></iframe> | |||
<iframe id="prototypebench" src="prototypebench.html" | |||
style="display: none"></iframe> | |||
<!-- hack, we don't use DIV because we don't want to effect the result of the selectors --> | |||
<blockquote style="display: block; height: 200px; width:790px; overflow-y:scroll; overflow-x: hidden; margin: 0"> | |||
<table id="resultstable" border="1" style="width: 100%; border-collapse: collapse"> | |||
<blockquote | |||
style="display: block; height: 200px; width:790px; overflow-y:scroll; overflow-x: hidden; margin: 0"> | |||
<table id="resultstable" border="1" | |||
style="width: 100%; border-collapse: collapse"> | |||
</table> | |||
</table> | |||
</blockquote> | |||
<div style="display: none"> | |||
<div style="display: none" class="head"> |
@@ -1,36 +1,50 @@ | |||
<html> | |||
<head> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" src="gwtquery.samples.GwtQueryDemo.nocache.js"></script> | |||
<style type="text/css"> | |||
.slide { border: 1px solid black; width: 800px; height: 600px; display: none} | |||
.slide { | |||
background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#808080), color-stop(0.9, #808080)); | |||
-webkit-background-origin: padding-box; -webkit-background-clip: content-box; | |||
} | |||
.slide, .slide * { color: white; font-size: 150%; } | |||
</style> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" | |||
src="gwtquery.samples.GwtQueryDemo.nocache.js"></script> | |||
<style type="text/css"> | |||
.slide { | |||
border: 1px solid black; | |||
width: 800px; | |||
height: 600px; | |||
display: none | |||
} | |||
.slide { | |||
background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#808080), color-stop(0.9, #808080)); | |||
-webkit-background-origin: padding-box; | |||
-webkit-background-clip: content-box; | |||
} | |||
.slide, .slide * { | |||
color: white; | |||
font-size: 150%; | |||
} | |||
</style> | |||
</head> | |||
<body> | |||
<p> | |||
Short example of how to do progressively enhance DIV, UL, LI elements into powerpoint-like slides | |||
Short example of how to do progressively enhance DIV, UL, LI elements into | |||
powerpoint-like slides | |||
</p> | |||
<div class="slide transition-appear"> | |||
Slide 1 | |||
<ul class="transition-appear"> | |||
<li>jQuery is</li> | |||
<li>such a</li> | |||
<li>Cool Library</li> | |||
</ul> | |||
Slide 1 | |||
<ul class="transition-appear"> | |||
<li>jQuery is</li> | |||
<li>such a</li> | |||
<li>Cool Library</li> | |||
</ul> | |||
</div> | |||
<div class="slide transition-appear"> | |||
Slide 2 | |||
<ul class="transition-appear"> | |||
<li>Now GWT</li> | |||
<li>has a</li> | |||
<li>jQuery-like API Too!</li> | |||
<li>GwtQuery Rocks!</li> | |||
</ul> | |||
Slide 2 | |||
<ul class="transition-appear"> | |||
<li>Now GWT</li> | |||
<li>has a</li> | |||
<li>jQuery-like API Too!</li> | |||
<li>GwtQuery Rocks!</li> | |||
</ul> | |||
</div> | |||
</body> |
@@ -1,13 +1,14 @@ | |||
<html> | |||
<head> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" src="gwtquery.samples.GwtQueryEffects.nocache.js"></script> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" | |||
src="gwtquery.samples.GwtQueryEffects.nocache.js"></script> | |||
<link href='gquery-star-ratings.css' type="text/css" rel="stylesheet"/> | |||
</head> | |||
<body> | |||
<div class="outer"> | |||
<div>Foo <span class="note">bar</span> baz</div> | |||
<div>Foo <span class="note">bar</span> baz</div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
@@ -16,8 +17,8 @@ | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
</div> | |||
</body> | |||
</html> | |||
@@ -1,174 +1,206 @@ | |||
<html> | |||
<head> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" src="gwtquery.samples.GwtQueryPlugin.nocache.js"></script> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" | |||
src="gwtquery.samples.GwtQueryPlugin.nocache.js"></script> | |||
<link href='gquery-star-ratings.css' type="text/css" rel="stylesheet"/> | |||
</head> | |||
<body> | |||
<div class="outer"> | |||
<div id="tab-Overview"> | |||
<h2>What is this?</h2> | |||
<p> | |||
The <strong>Star Rating Plugin</strong> is a plugin | |||
for the jQuery Javascript library that creates a non-obstrusive | |||
star rating control based on a set of radio input boxes. | |||
</p> | |||
<h2>What does it do?</h2> | |||
<ul> | |||
<li> | |||
It turns a collection of radio boxes into a neat star-rating control. | |||
</li> | |||
<li> | |||
It creates the interface based on standard form elements, which means the | |||
basic functionality will still be available even if Javascript is disabled. | |||
</li> | |||
<li> | |||
<strong style="color: rgb(0, 153, 0);">NEW</strong> (12-Mar-08): | |||
In read only mode (using the 'readOnly' option or <code>disabled</code> property), the plugin is a neat way of | |||
displaying star-like values without any additional code | |||
</li> | |||
</ul> | |||
<h2>How do I use it?</h2> | |||
<p> | |||
Just add the <code><strong>star</strong></code> class to your radio boxes | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<p> | |||
Use the <code><strong>checked</strong></code> property to specify the initial/default value of the control | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star" checked="checked"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star" checked="checked"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<p> | |||
Use the <code><strong>disabled</strong></code> property to use a control for display purposes only | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled" checked="checked"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled" checked="checked"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<h2>What about split stars and 'half ratings'???</h2> | |||
<p> | |||
Use metadata plugin to pass advanced settings to the plugin via the class property. | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}" checked="checked"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}" checked="checked"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<p> | |||
Use custom selector | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<script>$(function(){ // wait for document to load | |||
$('input.wow').rating(); | |||
});</script> | |||
<pre class="code"><code class="js">$(function(){ // wait for document to load | |||
$('input.wow').rating(); | |||
});</code></pre> | |||
<pre class="code"><code class="html"><input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}" checked="checked"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}" checked="checked"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
</td> | |||
</tr> | |||
</table> | |||
</div><!--// tab-Overview //--> | |||
<div id="tab-Overview" class="collapsible"> | |||
<h2>What is this?</h2> | |||
<p> | |||
The <strong>Star Rating Plugin</strong> is a plugin | |||
for the jQuery Javascript library that creates a non-obstrusive | |||
star rating control based on a set of radio input boxes. | |||
</p> | |||
<h2>What does it do?</h2> | |||
<ul> | |||
<li> | |||
It turns a collection of radio boxes into a neat star-rating | |||
control. | |||
</li> | |||
<li> | |||
It creates the interface based on standard form elements, which | |||
means the | |||
basic functionality will still be available even if Javascript | |||
is disabled. | |||
</li> | |||
<li> | |||
<strong style="color: rgb(0, 153, 0);">NEW</strong> (12-Mar-08): | |||
In read only mode (using the 'readOnly' option or | |||
<code>disabled</code> property), the plugin is a neat way of | |||
displaying star-like values without any additional code | |||
</li> | |||
</ul> | |||
<h2>How do I use it?</h2> | |||
<p> | |||
Just add the <code><strong>star</strong></code> class to your radio | |||
boxes | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="star1" type="radio" | |||
class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
<input name="star1" type="radio" class="star"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<p> | |||
Use the <code><strong>checked</strong></code> property to specify | |||
the initial/default value of the control | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="star2" type="radio" | |||
class="star"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star" checked="checked"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star" | |||
checked="checked"/> | |||
<input name="star2" type="radio" class="star"/> | |||
<input name="star2" type="radio" class="star"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<p> | |||
Use the <code><strong>disabled</strong></code> property to use a | |||
control for display purposes only | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="star3" type="radio" | |||
class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled" | |||
checked="checked"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" disabled="disabled"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="star3" type="radio" class="star" | |||
disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" | |||
disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" | |||
disabled="disabled" checked="checked"/> | |||
<input name="star3" type="radio" class="star" | |||
disabled="disabled"/> | |||
<input name="star3" type="radio" class="star" | |||
disabled="disabled"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<h2>What about split stars and 'half ratings'???</h2> | |||
<p> | |||
Use metadata plugin to pass advanced settings to the plugin via the | |||
class property. | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<pre class="code"><code class="html"><input name="adv1" type="radio" | |||
class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}" | |||
checked="checked"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star | |||
{split:4}"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}" | |||
checked="checked"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
<input name="adv1" type="radio" class="star {split:4}"/> | |||
</td> | |||
</tr> | |||
</table> | |||
<p> | |||
Use custom selector | |||
</p> | |||
<table cellspacing="5" width="100%"> | |||
<tr> | |||
<td valign="top"> | |||
<script>$(function() { // wait for document to load | |||
$('input.wow').rating(); | |||
});</script> | |||
<pre class="code"><code class="js">$(function(){ // wait for document to | |||
load | |||
$('input.wow').rating(); | |||
});</code></pre> | |||
<pre class="code"><code class="html"><input name="adv2" type="radio" | |||
class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}" | |||
checked="checked"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow | |||
{split:4}"/></code></pre> | |||
</td> | |||
<td valign="top" width="10">»</td> | |||
<td valign="top" width="180"> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}" | |||
checked="checked"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
<input name="adv2" type="radio" class="wow {split:4}"/> | |||
</td> | |||
</tr> | |||
</table> | |||
</div> | |||
<!--// tab-Overview //--> | |||
</div> | |||
</body> | |||
</html> | |||
@@ -1,13 +1,18 @@ | |||
<html> | |||
<head> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" src="gwtquery.samples.GwtQuerySample.nocache.js"></script> | |||
<title>GQuery Demo</title> | |||
<script type="text/javascript"> | |||
function __gwtStatsEvent(evt) { | |||
} | |||
</script> | |||
<script language="javascript" | |||
src="gwtquery.samples.GwtQuerySample.nocache.js"></script> | |||
<link href='gquery-star-ratings.css' type="text/css" rel="stylesheet"/> | |||
</head> | |||
<body> | |||
<div class="outer"> | |||
<div>Foo <span class="note">bar</span> baz</div> | |||
<div>Foo <span class="note">bar</span> baz</div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
@@ -17,7 +22,7 @@ | |||
<div>Foo <span class="note">bar</span> <span class="xyz">baz</span></div> | |||
</div> | |||
</body> | |||
</html> | |||
@@ -1,21 +1,22 @@ | |||
<html> | |||
<head> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" src="gwtquery.samples.GwtQueryWidgets.nocache.js"></script> | |||
<title>GQuery Demo</title> | |||
<script language="javascript" | |||
src="gwtquery.samples.GwtQueryWidgets.nocache.js"></script> | |||
<link href='gquery-star-ratings.css' type="text/css" rel="stylesheet"/> | |||
</head> | |||
<body> | |||
<div class="outer"> | |||
<div class="btn">Make me a button 1!</div> | |||
<div class="btn">Make me a button 2!</div> | |||
<div class="btn">Make me a button 3!</div> | |||
<div class="btn">Make me a button 4!</div> | |||
<div class="btn">Make me a button 5!</div> | |||
<div class="btn">Make me a button 6!</div> | |||
</div> | |||
<div class="btn">Make me a button 1!</div> | |||
<div class="btn">Make me a button 2!</div> | |||
<div class="btn">Make me a button 3!</div> | |||
<div class="btn">Make me a button 4!</div> | |||
<div class="btn">Make me a button 5!</div> | |||
<div class="btn">Make me a button 6!</div> | |||
</div> | |||
</body> | |||
</html> | |||
@@ -36,10 +36,9 @@ | |||
.horse span { | |||
font-weight: bold; | |||
font-size: 150%; | |||
color: white; | |||
/*left: -70px;*/ | |||
/*top: -30px;*/ | |||
/*position: relative;*/ | |||
color: white; /*left: -70px;*/ | |||
/*top: -30px;*/ | |||
/*position: relative;*/ | |||
} | |||
</style> | |||
</head> | |||
@@ -47,10 +46,12 @@ | |||
<div id="racefield" | |||
style="width:790px; background-image: url(grass-texture-small.jpg); background-repeat: repeat;"> | |||
<div id="gwthorse" class="horse"> | |||
<nobr><img class="himg" src="horse.gif"><img src="gwt-logo-cs.gif"></nobr> | |||
<nobr><img class="himg" src="horse.gif"><img src="gwt-logo-cs.gif"> | |||
</nobr> | |||
</div> | |||
<div id="jqueryhorse" class="horse"> | |||
<nobr><img class="himg" src="horse.gif"><img src="logo_jquery.gif"></nobr> | |||
<nobr><img class="himg" src="horse.gif"><img src="logo_jquery.gif"> | |||
</nobr> | |||
</div> | |||
<div id="dojohorse" class="horse"> | |||