diff src/econnect/wp3_3/client/slider/JsSlider.java @ 3:cf06b77a8bbd

Committed branch of the e4D repos sti-gwt branch 16384. git-svn-id: http://dev.dariah.eu/svn/repos/eu.dariah.de/ap1/sti-gwt-dariah-geobrowser@36 f2b5be40-def6-11e0-8a09-b3c1cc336c6b
author StefanFunk <StefanFunk@f2b5be40-def6-11e0-8a09-b3c1cc336c6b>
date Tue, 17 Jul 2012 13:34:40 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/econnect/wp3_3/client/slider/JsSlider.java	Tue Jul 17 13:34:40 2012 +0000
@@ -0,0 +1,71 @@
+package econnect.wp3_3.client.slider;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.dom.client.DivElement; 
+import com.google.gwt.dom.client.Document;
+
+/**
+ * Implementation of the wrapper for the Slider class of the WebFX JavaScript source
+*/
+public class JsSlider extends JavaScriptObject {
+	
+	protected JsSlider(){
+	}
+	
+    /**
+     * Initializes a WebFX Slider element
+     *
+     * @param slider div element for the slider range
+     * @param input div element for the slider adjuster
+     * @param orientation if the slider should be vertical or horizontal
+     * @return a WebFX Slider object
+    */
+	public static native JsSlider createSlider( DivElement slider, DivElement input, String orientation  ) /*-{
+		return new $wnd.Slider( slider, input, orientation );
+	}-*/;
+	
+    /**
+     * Setter for the maximum possible value of the slider
+     *
+     * @param max maximum of the slider
+    */
+	public final native void setMaximum( int max )  /*-{
+		this.setMaximum(max);
+	}-*/;	
+	
+    /**
+     * Setter for the new value of the slider
+     *
+     * @param value the new value of the slider
+    */
+	public final native void setValue( int value )  /*-{
+		this.setValue(value);
+	}-*/;	
+
+    /**
+     * Getter for the actual value of the slider
+     *
+     * @return the actual value of the slider
+    */
+	public final native int getValue()  /*-{
+		return this.getValue();
+	}-*/;
+	
+    /**
+     * Adds a change listener to the javascript slider object
+    */
+	public final native void addChangeListener( JavaScriptObject jso, Document document, boolean direct )  /*-{
+		var slider = this;
+		this.handle.onmousedown = function(){
+			var oldValue = slider.getValue();
+			document.onmouseup = function(){
+				if( direct && !jso.zoom( slider.getValue() / slider.getMaximum() ) || 
+				 	!direct && !jso.zoom( slider.getValue() - oldValue ) ){
+					slider.setValue(oldValue);					
+				}
+				document.onmouseup = null;
+			}
+		}
+	}-*/;
+
+}
\ No newline at end of file