JBoss Rich Faces SVN: r604 - in trunk/richfaces/suggestionbox/src/main: java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-05-02 08:53:26 -0400 (Wed, 02 May 2007)
New Revision: 604
Modified:
trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-133 fixed
Modified: trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml
===================================================================
--- trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml 2007-05-02 02:04:34 UTC (rev 603)
+++ trunk/richfaces/suggestionbox/src/main/config/component/suggestionbox.xml 2007-05-02 12:53:26 UTC (rev 604)
@@ -123,13 +123,13 @@
</description>
</property>
-
+
<property>
<name>onsubmit</name>
<classname>java.lang.String</classname>
<description>JavaScript code for call before submission of ajax event.</description>
</property>
-
+
<property>
<name>selectedClass</name>
<classname>java.lang.String</classname>
@@ -299,5 +299,14 @@
<classname>java.lang.String</classname>
<description>align</description>
</property>
+
+ <property>
+ <name>zindex</name>
+ <classname>int</classname>
+ <description>
+ Attribute is similar to the standard HTML attribute and can specify window placement relative to the content.
+ </description>
+ <defaultvalue>200</defaultvalue>
+ </property>
</component>
</components>
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-05-02 02:04:34 UTC (rev 603)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-05-02 12:53:26 UTC (rev 604)
@@ -249,7 +249,7 @@
/**
* Getter for submitted.
- *
+ *
* @return TRUE if submited
*/
public boolean isSubmitted() {
@@ -265,6 +265,10 @@
this.submitted = s;
}
+ public abstract int getZindex();
+
+ public abstract void setZindex(int zindex);
+
/* (non-Javadoc)
* @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
*/
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-05-02 02:04:34 UTC (rev 603)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-05-02 12:53:26 UTC (rev 604)
@@ -192,8 +192,10 @@
}
writer.writeAttribute("class", clazz, "popupClass");
- StringBuffer style = new StringBuffer("display:none; z-index: 201;");
+ int zIndex = suggestionBox.getZindex();
+ StringBuffer style = new StringBuffer("display:none; z-index: " + (zIndex + 1) + ";");
+
style.append(getSizeForStyle(component, "width", null, false));
style.append(getSizeForStyle(component, "height", null, false));
@@ -222,7 +224,7 @@
writer.writeAttribute("id", component.getClientId(context)
+ "_iframe", null);
writer.writeAttribute(
- "style", "position:absolute;display:none;z-index:200;", null);
+ "style", "position:absolute;display:none;z-index:" + zIndex + ";", null);
writer.endElement("iframe");
} else {
suggestionBox.setSubmitted(false);
17 years, 8 months
JBoss Rich Faces SVN: r603 - in trunk: richfaces/dataTable/src/main/java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-05-01 22:04:34 -0400 (Tue, 01 May 2007)
New Revision: 603
Added:
trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/colgroup.jsp
Modified:
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java
Log:
fix RF-70 issue : encoding rowOnXXX JavaScript handlers for columnGroup
Modified: trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
--- trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2007-05-02 00:05:01 UTC (rev 602)
+++ trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2007-05-02 02:04:34 UTC (rev 603)
@@ -42,7 +42,18 @@
*/
public abstract class AbstractRowsRenderer extends HeaderResourcesRendererBase implements
DataVisitor {
+
+ public static final String[][] TABLE_EVENT_ATTRS = {
+ {"onclick","onRowClick"},
+ {"ondblclick","onRowDblClick"},
+ {"onmousemove","onRowMouseMove"},
+ {"onmouseup","onRowMouseUp"},
+ {"onmousedown","onRowMouseDown"},
+ {"onmouseover","onRowMouseOver"},
+ {"onmouseout","onRowMouseOut"}
+ };
+
public static final Object ROW_CLASS_KEY = AbstractRowsRenderer.class
.getName()
+ ".rowClass";
@@ -158,13 +169,10 @@
protected void encodeRowEvents(FacesContext context, UIDataAdaptor table)
throws IOException {
RendererUtils utils2 = getUtils();
- utils2.encodeAttribute(context, table, "onRowClick", "onclick");
- utils2.encodeAttribute(context, table, "onRowDblClick", "ondblclick");
- utils2.encodeAttribute(context, table, "onRowMouseMove", "onmousemove");
- utils2.encodeAttribute(context, table, "onRowMouseUp", "onmouseup");
- utils2.encodeAttribute(context, table, "onRowMouseDown", "onmousedown");
- utils2.encodeAttribute(context, table, "onRowMouseOver", "onmouseover");
- utils2.encodeAttribute(context, table, "onRowMouseOut", "onmouseout");
+ for (int i = 0; i < TABLE_EVENT_ATTRS.length; i++) {
+ String[] attrs = TABLE_EVENT_ATTRS[i];
+ utils2.encodeAttribute(context, table, attrs[1], attrs[0]);
+ }
}
/**
Modified: trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java
===================================================================
--- trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java 2007-05-02 00:05:01 UTC (rev 602)
+++ trunk/richfaces/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java 2007-05-02 02:04:34 UTC (rev 603)
@@ -42,7 +42,14 @@
public class ColgroupRenderer extends AbstractRowsRenderer {
private static final String[] STYLE_ATTRS = { "style", "class" };
+ public static final String[] EVENT_ATTRS ;
+ static {
+ EVENT_ATTRS = new String[AbstractRowsRenderer.TABLE_EVENT_ATTRS.length];
+ for (int i = 0; i < AbstractRowsRenderer.TABLE_EVENT_ATTRS.length; i++) {
+ EVENT_ATTRS[i]=AbstractRowsRenderer.TABLE_EVENT_ATTRS[i][0];
+ }
+ }
/*
* (non-Javadoc)
*
@@ -152,7 +159,21 @@
"dr-tablerow rich-tablerow", requestMap
.get(AbstractRowsRenderer.ROW_CLASS_KEY), styleClass);
encodeStyle(context.getResponseWriter(),null, null, null, style);
- getUtils().encodePassThru(context, colspan);
+ getUtils().encodePassThruWithExclusionsArray(context, colspan,EVENT_ATTRS);
+ // Search for enclosed DataAdaptor.
+ UIComponent parent = colspan.getParent();
+ // ENCODE event attributes. If component don't have own attribute, search in the parent table.
+ boolean inRow = null != parent && parent.getChildren().contains(colspan);
+ for (int i = 0; i < AbstractRowsRenderer.TABLE_EVENT_ATTRS.length; i++) {
+ String[] attrs = AbstractRowsRenderer.TABLE_EVENT_ATTRS[i];
+ String event = (String) colspan.getAttributes().get(attrs[0]);
+ if(null == event && inRow){
+ event = (String) parent.getAttributes().get(attrs[1]);
+ }
+ if(null != event){
+ writer.writeAttribute(attrs[0], event, attrs[0]);
+ }
+ }
}
/*
Added: trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/colgroup.jsp
===================================================================
--- trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/colgroup.jsp (rev 0)
+++ trunk/richfaces-samples/dataTableDemo/src/main/webapp/pages/colgroup.jsp 2007-05-02 02:04:34 UTC (rev 603)
@@ -0,0 +1,81 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://richfaces.ajax4jsf.org/dataTable" prefix="data"%>
+<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<f:view>
+ <h:form>
+ <h:panelGrid columns="1" border="1">
+ <data:dataTable id="master" var="master" value="#{data.mounths}"
+ rowKeyVar="key"
+ styleClass="table" captionClass="caption"
+ rowClasses="rowa,rowb,rowc rowcc" headerClass="header"
+ footerClass="footer" onRowClick="alert('row #{key}')">
+ <f:facet name="caption">
+ <h:outputText value="caption" />
+ </f:facet>
+ <f:facet name="header">
+ <data:columnGroup columnClasses="cola, colb ,rowc rowcc">
+ <data:column rowspan="2">
+ <h:outputText value="2-row head" />
+ </data:column>
+ <h:column>
+ <h:outputText value="head in UIColumn" />
+ </h:column>
+ <data:column breakBefore="true">
+ <h:outputText value="2-d row head" />
+ </data:column>
+ </data:columnGroup>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="table foot" />
+ </f:facet>
+ <data:columnGroup >
+ <data:column id="mounth" styleClass="column" rowspan="2"
+ headerClass="cheader" footerClass="cfooter">
+ <f:facet name="header">
+ <h:outputText value="mounth" />
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="-//-" />
+ </f:facet>
+ <h:outputText value="#{master.mounth}" />
+ </data:column>
+ <data:column styleClass="column" >
+ headerClass="cheader" footerClass="cfooter">
+ <f:facet name="header">
+ <h:outputText value="mounth" />
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="-//-" />
+ </f:facet>
+ <h:outputText value="#{master.mounth}" />
+ </data:column>
+ </data:columnGroup>
+ <data:column styleClass="column"
+ headerClass="cheader" footerClass="cfooter">
+ <h:outputText value="#{master.mounth}" />
+ </data:column>
+ <data:subTable id="detail" var="detail" value="#{master.detail}">
+ <data:column id="name">
+ <h:outputText value="#{detail.name}" />
+ </data:column>
+ <data:column id="qty">
+ <h:outputText value="#{detail.qty}" />
+ </data:column>
+ </data:subTable>
+ <data:column id="total" styleClass="total" colspan="2">
+ <h:outputText value="#{master.total}" />
+ </data:column>
+ </data:dataTable>
+
+ </h:panelGrid>
+ </h:form>
+ <a4j:log hotkey="D" />
+</f:view>
+</body>
+</html>
17 years, 8 months
JBoss Rich Faces SVN: r602 - trunk/richfaces-samples/richfaces-demo/src/main/webapp/css.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-05-01 20:05:01 -0400 (Tue, 01 May 2007)
New Revision: 602
Modified:
trunk/richfaces-samples/richfaces-demo/src/main/webapp/css/common.css
Log:
typo fixed
Modified: trunk/richfaces-samples/richfaces-demo/src/main/webapp/css/common.css
===================================================================
--- trunk/richfaces-samples/richfaces-demo/src/main/webapp/css/common.css 2007-05-02 00:04:14 UTC (rev 601)
+++ trunk/richfaces-samples/richfaces-demo/src/main/webapp/css/common.css 2007-05-02 00:05:01 UTC (rev 602)
@@ -136,7 +136,7 @@
}
.panel_menu{
- background-color : transparency;
+ background-color : transparent;
border : 1px solid #FFFFFF;
border-bottom : 0px;
background-position : left;
17 years, 8 months
JBoss Rich Faces SVN: r601 - trunk/richfaces-samples/richfaces-demo/src/main/webapp/richfaces/dropDownMenu.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-05-01 20:04:14 -0400 (Tue, 01 May 2007)
New Revision: 601
Modified:
trunk/richfaces-samples/richfaces-demo/src/main/webapp/richfaces/dropDownMenu/usage.xhtml
Log:
test content for dropdown demo
Modified: trunk/richfaces-samples/richfaces-demo/src/main/webapp/richfaces/dropDownMenu/usage.xhtml
===================================================================
--- trunk/richfaces-samples/richfaces-demo/src/main/webapp/richfaces/dropDownMenu/usage.xhtml 2007-05-01 01:28:03 UTC (rev 600)
+++ trunk/richfaces-samples/richfaces-demo/src/main/webapp/richfaces/dropDownMenu/usage.xhtml 2007-05-02 00:04:14 UTC (rev 601)
@@ -12,10 +12,92 @@
.optionList {
height:30px;
}
+ .vertical-menu .rich-menu-item-hover,.vertical-menu .rich-menu-group-hover {
+ background-image:none;
+ background-color: transparent !important;
+ }
+
</style>
<p>Description
</p>
+ <a4j:log hotkey="M" />
+ <div class="sample-container">
+ <h:form>
+Output: <h:outputText id="out" value="#{paintData.text}" />
+ <rich:toolBar>
+ <rich:dropDownMenu value="File">
+ <rich:menuItem width="40px" mode="ajax" value="Open" action="open"/>
+ <rich:menuSeparator id="menuSeparator11"/>
+
+ <rich:menuItem mode="none" onclick="document.location.href='http://www.exadel.com'">
+ <h:outputLink value="http://www.exadel.com">output Link</h:outputLink>
+ </rich:menuItem>
+ <rich:menuItem>
+ <h:inputText style="z-index:100000" value="#{paintData.text}">
+ <a4j:support event="onkeyup" reRender="out" />
+ </h:inputText>
+ </rich:menuItem>
+ </rich:dropDownMenu>
+ <rich:dropDownMenu showDelay="100" hideDelay="100">
+ <f:facet name="label">
+ <h:panelGrid columns="2" style="vertical-align:middle">
+ <h:graphicImage value="/richfaces/toolBar/images/palette_edit.gif"/>
+ <h:outputText value="Options" />
+ </h:panelGrid>
+ </f:facet>
+ <rich:menuItem value="Read" />
+ <rich:menuItem value="Print">
+ <f:facet name="icon">
+ <h:graphicImage id="print" value="/richfaces/toolBar/images/print.gif" />
+ </f:facet>
+ </rich:menuItem>
+ <rich:menuItem value="Remove" />
+ <rich:menuGroup value="Drop Out and Foget About It">
+ <rich:menuItem value="Forever" />
+ <rich:menuGroup value="And Ever">
+ <rich:menuGroup value="And Ever">
+ <rich:menuGroup value="And Ever">
+ <rich:menuGroup value="And Ever">
+ <rich:menuGroup value="And Ever">
+ <rich:menuGroup value="And Ever">
+ <rich:menuItem value="But Never" />
+ </rich:menuGroup>
+ </rich:menuGroup>
+ </rich:menuGroup>
+ </rich:menuGroup>
+ </rich:menuGroup>
+ </rich:menuGroup>
+ </rich:menuGroup>
+ </rich:dropDownMenu>
+ </rich:toolBar>
+ <rich:spacer height="20" />
+ <h:panelGrid class="vertical-menu" style="background-color:#{a4jSkin.additionalBackgroundColor}" columns="1" cellspacing="0" cellpadding="0">
+ <rich:dropDownMenu style="border:1px solid #{a4jSkin.panelBorderColor}" value="Option1" direction="bottom-right" jointPoint="tr">
+ <rich:menuItem value="Suboption1-1" />
+ <rich:menuItem value="Suboption1-2" />
+ <rich:menuItem value="Suboption1-3" />
+ </rich:dropDownMenu>
+ <rich:dropDownMenu style="border:1px solid #{a4jSkin.panelBorderColor}" value="Option2" direction="bottom-right" jointPoint="tr">
+ <rich:menuItem value="Suboption2-1" />
+ <rich:menuItem value="Suboption2-2" />
+ <rich:menuGroup value="Group2" direction="#{bean.groupDirection}">
+ <rich:menuItem value="SuboptionG2-2-1" />
+ <rich:menuItem value="SuboptionG2-2-2" />
+ </rich:menuGroup>
+
+ <rich:menuItem value="Suboption2-3" />
+ </rich:dropDownMenu>
+ <rich:dropDownMenu style="border:1px solid #{a4jSkin.panelBorderColor}" value="Option3" direction="bottom-right" jointPoint="tr">
+ <rich:menuItem value="Suboption3-1" />
+ <rich:menuItem value="Suboption3-2" />
+ <rich:menuItem value="Suboption3-3" />
+ </rich:dropDownMenu>
+
+ </h:panelGrid>
+
+ </h:form>
+ </div>
</ui:define>
<ui:define name="sources">
17 years, 8 months
JBoss Rich Faces SVN: r600 - trunk/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-30 21:28:03 -0400 (Mon, 30 Apr 2007)
New Revision: 600
Modified:
trunk/richfaces/pom.xml
Log:
Default build put versions numbers to manifest of a all generated jar's RF-29
Modified: trunk/richfaces/pom.xml
===================================================================
--- trunk/richfaces/pom.xml 2007-05-01 01:13:07 UTC (rev 599)
+++ trunk/richfaces/pom.xml 2007-05-01 01:28:03 UTC (rev 600)
@@ -104,6 +104,33 @@
</executions>
</plugin>
</plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <index>true</index>
+ <manifest>
+ <addDefaultSpecificationEntries>
+ true
+ </addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>
+ true
+ </addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <mode>development</mode>
+ <Build-Number>
+ ${buildNumber}
+ </Build-Number>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<modules>
<module>common</module>
17 years, 8 months
JBoss Rich Faces SVN: r599 - in trunk: richfaces-samples and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-30 21:13:07 -0400 (Mon, 30 Apr 2007)
New Revision: 599
Modified:
trunk/richfaces-samples/pom.xml
trunk/richfaces/pom.xml
Log:
Correct versions for a commons-collections & jetty plugin
Modified: trunk/richfaces/pom.xml
===================================================================
--- trunk/richfaces/pom.xml 2007-05-01 00:22:26 UTC (rev 598)
+++ trunk/richfaces/pom.xml 2007-05-01 01:13:07 UTC (rev 599)
@@ -227,7 +227,7 @@
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
- <version>3.0</version>
+ <version>3.2</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
Modified: trunk/richfaces-samples/pom.xml
===================================================================
--- trunk/richfaces-samples/pom.xml 2007-05-01 00:22:26 UTC (rev 598)
+++ trunk/richfaces-samples/pom.xml 2007-05-01 01:13:07 UTC (rev 599)
@@ -12,8 +12,10 @@
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.1</version>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <!--
+ <version>6.1.1</version>
+ -->
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<connectors>
@@ -111,20 +113,6 @@
<url>richfaces-samples/</url>
</site>
</distributionManagement>
- <pluginRepositories>
- <pluginRepository>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- </snapshots>
- <id>maven2-snapshots.jboss.org</id>
- <name>Jboss Repository for Maven Snapshots</name>
- <url>http://snapshots.jboss.com/</url>
- </pluginRepository>
- </pluginRepositories>
<repositories>
<repository>
<releases />
@@ -147,9 +135,9 @@
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
- <id>maven2-snapshots.jboss.org</id>
+ <id>maven.exadel.com</id>
<name>Jboss Repository for Maven Snapshots</name>
- <url>http://snapshots.jboss.com/</url>
+ <url>http://maven.exadel.com/</url>
</repository>
</repositories>
<profiles>
17 years, 8 months
JBoss Rich Faces SVN: r598 - trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src.
by richfaces-svn-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-04-30 20:22:26 -0400 (Mon, 30 Apr 2007)
New Revision: 598
Modified:
trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js
Log:
fixed formatting from previous commit for future prototype upgrades
Modified: trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js
===================================================================
--- trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js 2007-05-01 00:18:18 UTC (rev 597)
+++ trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js 2007-05-01 00:22:26 UTC (rev 598)
@@ -5,7 +5,7 @@
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
-if (!Control) var Control = {};
+if(!Control) var Control = {};
Control.Slider = Class.create();
// options:
@@ -15,283 +15,270 @@
// onChange(value)
// onSlide(value)
Control.Slider.prototype = {
- initialize: function(handle, track, options) {
- var slider = this;
+ initialize: function(handle, track, options) {
+ var slider = this;
- if (handle instanceof Array) {
- this.handles = handle.collect(function(e) {
- return $(e)
- });
- } else {
- this.handles = [$(handle)];
- }
+ if(handle instanceof Array) {
+ this.handles = handle.collect( function(e) { return $(e) });
+ } else {
+ this.handles = [$(handle)];
+ }
- this.track = $(track);
- this.options = options || {};
+ this.track = $(track);
+ this.options = options || {};
- this.axis = this.options.axis || 'horizontal';
- this.increment = this.options.increment || 1;
- this.step = parseInt(this.options.step || '1');
- this.range = this.options.range || $R(0, 1);
+ this.axis = this.options.axis || 'horizontal';
+ this.increment = this.options.increment || 1;
+ this.step = parseInt(this.options.step || '1');
+ this.range = this.options.range || $R(0,1);
- this.value = 0;
- // assure backwards compat
- this.values = this.handles.map(function() {
- return 0
- });
- this.spans = this.options.spans ? this.options.spans.map(function(s) {
- return $(s)
- }) : false;
- this.options.startSpan = $(this.options.startSpan || null);
- this.options.endSpan = $(this.options.endSpan || null);
+ this.value = 0; // assure backwards compat
+ this.values = this.handles.map( function() { return 0 });
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
+ this.options.startSpan = $(this.options.startSpan || null);
+ this.options.endSpan = $(this.options.endSpan || null);
- this.restricted = this.options.restricted || false;
+ this.restricted = this.options.restricted || false;
- this.maximum = this.options.maximum || this.range.end;
- this.minimum = this.options.minimum || this.range.start;
+ this.maximum = this.options.maximum || this.range.end;
+ this.minimum = this.options.minimum || this.range.start;
- // Will be used to align the handle onto the track, if necessary
- this.alignX = parseInt(this.options.alignX || '0');
- this.alignY = parseInt(this.options.alignY || '0');
+ // Will be used to align the handle onto the track, if necessary
+ this.alignX = parseInt(this.options.alignX || '0');
+ this.alignY = parseInt(this.options.alignY || '0');
- this.trackLength = this.maximumOffset() - this.minimumOffset();
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
- this.handleLength = this.isVertical() ?
- (this.handles[0].offsetHeight != 0 ?
- this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/, "")) :
- (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
- this.handles[0].style.width.replace(/px$/, ""));
+ this.handleLength = this.isVertical() ?
+ (this.handles[0].offsetHeight != 0 ?
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
+ this.handles[0].style.width.replace(/px$/,""));
- this.active = false;
- this.dragging = false;
- this.disabled = false;
+ this.active = false;
+ this.dragging = false;
+ this.disabled = false;
- if (this.options.disabled) this.setDisabled();
+ if(this.options.disabled) this.setDisabled();
- // Allowed values array
- this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
- if (this.allowedValues) {
- this.minimum = this.allowedValues.min();
- this.maximum = this.allowedValues.max();
- }
+ // Allowed values array
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+ if(this.allowedValues) {
+ this.minimum = this.allowedValues.min();
+ this.maximum = this.allowedValues.max();
+ }
- this.eventMouseDown = this.startDrag.bindAsEventListener(this);
- this.eventMouseUp = this.endDrag.bindAsEventListener(this);
- this.eventMouseMove = this.update.bindAsEventListener(this);
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
- // Initialize handles in reverse (make sure first handle is active)
- this.handles.each(function(h, i) {
- i = slider.handles.length - 1 - i;
- slider.setValue(parseFloat(
- (slider.options.sliderValue instanceof Array ?
- slider.options.sliderValue[i] : slider.options.sliderValue) ||
- slider.range.start), i);
- Element.makePositioned(h);
- // fix IE
- Event.observe(h, "mousedown", slider.eventMouseDown);
- });
+ // Initialize handles in reverse (make sure first handle is active)
+ this.handles.each( function(h,i) {
+ i = slider.handles.length-1-i;
+ slider.setValue(parseFloat(
+ (slider.options.sliderValue instanceof Array ?
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
+ slider.range.start), i);
+ Element.makePositioned(h); // fix IE
+ Event.observe(h, "mousedown", slider.eventMouseDown);
+ });
- Event.observe(this.track, "mousedown", this.eventMouseDown);
- Event.observe(document, "mouseup", this.eventMouseUp);
- Event.observe(document, "mousemove", this.eventMouseMove);
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
- this.initialized = true;
- },
- dispose: function() {
- var slider = this;
- Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
- Event.stopObserving(document, "mouseup", this.eventMouseUp);
- Event.stopObserving(document, "mousemove", this.eventMouseMove);
- this.handles.each(function(h) {
- Event.stopObserving(h, "mousedown", slider.eventMouseDown);
- });
- },
- setDisabled: function() {
- this.disabled = true;
- },
- setEnabled: function() {
- this.disabled = false;
- },
- getNearestValue: function(value) {
- if (this.allowedValues) {
- if (value >= this.allowedValues.max()) return(this.allowedValues.max());
- if (value <= this.allowedValues.min()) return(this.allowedValues.min());
+ this.initialized = true;
+ },
+ dispose: function() {
+ var slider = this;
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ this.handles.each( function(h) {
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+ });
+ },
+ setDisabled: function(){
+ this.disabled = true;
+ },
+ setEnabled: function(){
+ this.disabled = false;
+ },
+ getNearestValue: function(value){
+ if(this.allowedValues){
+ if(value >= this.allowedValues.max()) return(this.allowedValues.max());
+ if(value <= this.allowedValues.min()) return(this.allowedValues.min());
- var offset = Math.abs(this.allowedValues[0] - value);
- var newValue = this.allowedValues[0];
- this.allowedValues.each(function(v) {
- var currentOffset = Math.abs(v - value);
- if (currentOffset <= offset) {
- newValue = v;
- offset = currentOffset;
- }
- });
- return newValue;
+ var offset = Math.abs(this.allowedValues[0] - value);
+ var newValue = this.allowedValues[0];
+ this.allowedValues.each( function(v) {
+ var currentOffset = Math.abs(v - value);
+ if(currentOffset <= offset){
+ newValue = v;
+ offset = currentOffset;
}
- if (value > this.range.end) return this.range.end;
- if (value < this.range.start) return this.range.start;
- return value;
- },
- setValue: function(sliderValue, handleIdx) {
- if (!this.active) {
- this.activeHandleIdx = handleIdx || 0;
- this.activeHandle = this.handles[this.activeHandleIdx];
- this.updateStyles();
- }
- handleIdx = handleIdx || this.activeHandleIdx || 0;
- if (this.initialized && this.restricted) {
- if ((handleIdx > 0) && (sliderValue < this.values[handleIdx - 1]))
- sliderValue = this.values[handleIdx - 1];
- if ((handleIdx < (this.handles.length - 1)) && (sliderValue > this.values[handleIdx + 1]))
- sliderValue = this.values[handleIdx + 1];
- }
- sliderValue = this.getNearestValue(sliderValue);
- this.values[handleIdx] = sliderValue;
- this.value = this.values[0];
- // assure backwards compat
+ });
+ return newValue;
+ }
+ if(value > this.range.end) return this.range.end;
+ if(value < this.range.start) return this.range.start;
+ return value;
+ },
+ setValue: function(sliderValue, handleIdx){
+ if(!this.active) {
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
+ this.updateStyles();
+ }
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
+ if(this.initialized && this.restricted) {
+ if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
+ sliderValue = this.values[handleIdx-1];
+ if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
+ sliderValue = this.values[handleIdx+1];
+ }
+ sliderValue = this.getNearestValue(sliderValue);
+ this.values[handleIdx] = sliderValue;
+ this.value = this.values[0]; // assure backwards compat
- this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
- this.translateToPx(sliderValue);
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
- this.drawSpans();
- if (!this.dragging || !this.event) this.updateFinished();
- },
- setValueBy: function(delta, handleIdx) {
- this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
- handleIdx || this.activeHandleIdx || 0);
- },
- translateToPx: function(value) {
- return Math.round(
- ((this.trackLength - this.handleLength) / (this.range.end - this.range.start)) *
- (value - this.range.start)) + "px";
- },
- translateToValue: function(offset) {
- return ((offset / (this.trackLength - this.handleLength) *
- (this.range.end - this.range.start)) + this.range.start);
- },
- getRange: function(range) {
- var v = this.values.sortBy(Prototype.K);
- range = range || 0;
- return $R(v[range], v[range + 1]);
- },
- minimumOffset: function() {
- return(this.isVertical() ? this.alignY : this.alignX);
- },
- maximumOffset: function() {
- return(this.isVertical() ?
- (this.track.offsetHeight != 0 ? this.track.offsetHeight :
- this.track.style.height.replace(/px$/, "")) - this.alignY :
- (this.track.offsetWidth != 0 ? this.track.offsetWidth :
- this.track.style.width.replace(/px$/, "")) - this.alignY);
- },
- isVertical: function() {
- return (this.axis == 'vertical');
- },
- drawSpans: function() {
- var slider = this;
- if (this.spans)
- $R(0, this.spans.length - 1).each(function(r) {
- slider.setSpan(slider.spans[r], slider.getRange(r))
- });
- if (this.options.startSpan)
- this.setSpan(this.options.startSpan,
- $R(0, this.values.length > 1 ? this.getRange(0).min() : this.value));
- if (this.options.endSpan)
- this.setSpan(this.options.endSpan,
- $R(this.values.length > 1 ? this.getRange(this.spans.length - 1).max() : this.value, this.maximum));
- },
- setSpan: function(span, range) {
- if (this.isVertical()) {
- span.style.top = this.translateToPx(range.start);
- span.style.height = this.translateToPx(range.end - range.start + this.range.start);
- } else {
- span.style.left = this.translateToPx(range.start);
+ this.drawSpans();
+ if(!this.dragging || !this.event) this.updateFinished();
+ },
+ setValueBy: function(delta, handleIdx) {
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+ handleIdx || this.activeHandleIdx || 0);
+ },
+ translateToPx: function(value) {
+ return Math.round(
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
+ (value - this.range.start)) + "px";
+ },
+ translateToValue: function(offset) {
+ return ((offset/(this.trackLength-this.handleLength) *
+ (this.range.end-this.range.start)) + this.range.start);
+ },
+ getRange: function(range) {
+ var v = this.values.sortBy(Prototype.K);
+ range = range || 0;
+ return $R(v[range],v[range+1]);
+ },
+ minimumOffset: function(){
+ return(this.isVertical() ? this.alignY : this.alignX);
+ },
+ maximumOffset: function(){
+ return(this.isVertical() ?
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
+ this.track.style.height.replace(/px$/,"")) - this.alignY :
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
+ this.track.style.width.replace(/px$/,"")) - this.alignY);
+ },
+ isVertical: function(){
+ return (this.axis == 'vertical');
+ },
+ drawSpans: function() {
+ var slider = this;
+ if(this.spans)
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
+ if(this.options.startSpan)
+ this.setSpan(this.options.startSpan,
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
+ if(this.options.endSpan)
+ this.setSpan(this.options.endSpan,
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
+ },
+ setSpan: function(span, range) {
+ if(this.isVertical()) {
+ span.style.top = this.translateToPx(range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
+ } else {
+ span.style.left = this.translateToPx(range.start);
- this.handles.each(function(h) {
- span.style.width = $(h.id).offsetLeft + 'px';
- });
-
- //original code from prototype 1.6.5
- //span.style.width = this.translateToPx(range.end - range.start + this.range.start);
- }
- },
- updateStyles: function() {
this.handles.each(function(h) {
- Element.removeClassName(h, 'selected')
+ span.style.width = $(h.id).offsetLeft + 'px';
});
- Element.addClassName(this.activeHandle, 'selected');
- },
- startDrag: function(event) {
- if (Event.isLeftClick(event)) {
- if (!this.disabled) {
- this.active = true;
- var handle = Event.element(event);
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var track = handle;
- if (track == this.track) {
- var offsets = Position.cumulativeOffset(this.track);
- this.event = event;
- this.setValue(this.translateToValue(
- (this.isVertical() ? pointer[1] - offsets[1] : pointer[0] - offsets[0]) - (this.handleLength / 2)
- ));
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
- } else {
- // find the handle (prevents issues with Safari)
- while ((this.handles.indexOf(handle) == -1) && handle.parentNode)
- handle = handle.parentNode;
+ //original code from prototype 1.6.5
+ //span.style.width = this.translateToPx(range.end - range.start + this.range.start);
+ }
+ },
+ updateStyles: function() {
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
+ Element.addClassName(this.activeHandle, 'selected');
+ },
+ startDrag: function(event) {
+ if(Event.isLeftClick(event)) {
+ if(!this.disabled){
+ this.active = true;
- if (this.handles.indexOf(handle) != -1) {
- this.activeHandle = handle;
- this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
- this.updateStyles();
+ var handle = Event.element(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var track = handle;
+ if(track==this.track) {
+ var offsets = Position.cumulativeOffset(this.track);
+ this.event = event;
+ this.setValue(this.translateToValue(
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
+ ));
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ } else {
+ // find the handle (prevents issues with Safari)
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
+ handle = handle.parentNode;
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
- }
- }
- }
- Event.stop(event);
+ if(this.handles.indexOf(handle)!=-1) {
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
}
- },
- update: function(event) {
- if (this.active) {
- if (!this.dragging) this.dragging = true;
- this.draw(event);
- // fix AppleWebKit rendering
- if (navigator.appVersion.indexOf('AppleWebKit') > 0) window.scrollBy(0, 0);
- Event.stop(event);
- }
- },
- draw: function(event) {
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var offsets = Position.cumulativeOffset(this.track);
- pointer[0] -= this.offsetX + offsets[0];
- pointer[1] -= this.offsetY + offsets[1];
- this.event = event;
- this.setValue(this.translateToValue(this.isVertical() ? pointer[1] : pointer[0]));
- if (this.initialized && this.options.onSlide)
- this.options.onSlide(this.values.length > 1 ? this.values : this.value, this);
- },
- endDrag: function(event) {
- if (this.active && this.dragging) {
- this.finishDrag(event, true);
- Event.stop(event);
- }
- this.active = false;
- this.dragging = false;
- },
- finishDrag: function(event, success) {
- this.active = false;
- this.dragging = false;
- this.updateFinished();
- },
- updateFinished: function() {
- if (this.initialized && this.options.onChange)
- this.options.onChange(this.values.length > 1 ? this.values : this.value, this);
- this.event = null;
+ }
+ Event.stop(event);
}
+ },
+ update: function(event) {
+ if(this.active) {
+ if(!this.dragging) this.dragging = true;
+ this.draw(event);
+ // fix AppleWebKit rendering
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
+ Event.stop(event);
+ }
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.track);
+ pointer[0] -= this.offsetX + offsets[0];
+ pointer[1] -= this.offsetY + offsets[1];
+ this.event = event;
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
+ if(this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
+ },
+ endDrag: function(event) {
+ if(this.active && this.dragging) {
+ this.finishDrag(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.dragging = false;
+ },
+ finishDrag: function(event, success) {
+ this.active = false;
+ this.dragging = false;
+ this.updateFinished();
+ },
+ updateFinished: function() {
+ if(this.initialized && this.options.onChange)
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
+ this.event = null;
+ }
}
\ No newline at end of file
17 years, 8 months
JBoss Rich Faces SVN: r597 - trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src.
by richfaces-svn-commits@lists.jboss.org
Author: wesleyhales
Date: 2007-04-30 20:18:18 -0400 (Mon, 30 Apr 2007)
New Revision: 597
Modified:
trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js
Log:
RF-104 Fixed slider and fixed issue with multiple sliders on one page
Modified: trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js
===================================================================
--- trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js 2007-04-30 23:40:12 UTC (rev 596)
+++ trunk/richfaces/dataFilterSlider/src/main/resources/org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/slider.js 2007-05-01 00:18:18 UTC (rev 597)
@@ -5,7 +5,7 @@
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
-if(!Control) var Control = {};
+if (!Control) var Control = {};
Control.Slider = Class.create();
// options:
@@ -15,266 +15,283 @@
// onChange(value)
// onSlide(value)
Control.Slider.prototype = {
- initialize: function(handle, track, options) {
- var slider = this;
+ initialize: function(handle, track, options) {
+ var slider = this;
- if(handle instanceof Array) {
- this.handles = handle.collect( function(e) { return $(e) });
- } else {
- this.handles = [$(handle)];
- }
+ if (handle instanceof Array) {
+ this.handles = handle.collect(function(e) {
+ return $(e)
+ });
+ } else {
+ this.handles = [$(handle)];
+ }
- this.track = $(track);
- this.options = options || {};
+ this.track = $(track);
+ this.options = options || {};
- this.axis = this.options.axis || 'horizontal';
- this.increment = this.options.increment || 1;
- this.step = parseInt(this.options.step || '1');
- this.range = this.options.range || $R(0,1);
+ this.axis = this.options.axis || 'horizontal';
+ this.increment = this.options.increment || 1;
+ this.step = parseInt(this.options.step || '1');
+ this.range = this.options.range || $R(0, 1);
- this.value = 0; // assure backwards compat
- this.values = this.handles.map( function() { return 0 });
- this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
- this.options.startSpan = $(this.options.startSpan || null);
- this.options.endSpan = $(this.options.endSpan || null);
+ this.value = 0;
+ // assure backwards compat
+ this.values = this.handles.map(function() {
+ return 0
+ });
+ this.spans = this.options.spans ? this.options.spans.map(function(s) {
+ return $(s)
+ }) : false;
+ this.options.startSpan = $(this.options.startSpan || null);
+ this.options.endSpan = $(this.options.endSpan || null);
- this.restricted = this.options.restricted || false;
+ this.restricted = this.options.restricted || false;
- this.maximum = this.options.maximum || this.range.end;
- this.minimum = this.options.minimum || this.range.start;
+ this.maximum = this.options.maximum || this.range.end;
+ this.minimum = this.options.minimum || this.range.start;
- // Will be used to align the handle onto the track, if necessary
- this.alignX = parseInt(this.options.alignX || '0');
- this.alignY = parseInt(this.options.alignY || '0');
+ // Will be used to align the handle onto the track, if necessary
+ this.alignX = parseInt(this.options.alignX || '0');
+ this.alignY = parseInt(this.options.alignY || '0');
- this.trackLength = this.maximumOffset() - this.minimumOffset();
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
- this.handleLength = this.isVertical() ?
- (this.handles[0].offsetHeight != 0 ?
- this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
- (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
- this.handles[0].style.width.replace(/px$/,""));
+ this.handleLength = this.isVertical() ?
+ (this.handles[0].offsetHeight != 0 ?
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/, "")) :
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
+ this.handles[0].style.width.replace(/px$/, ""));
- this.active = false;
- this.dragging = false;
- this.disabled = false;
+ this.active = false;
+ this.dragging = false;
+ this.disabled = false;
- if(this.options.disabled) this.setDisabled();
+ if (this.options.disabled) this.setDisabled();
- // Allowed values array
- this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
- if(this.allowedValues) {
- this.minimum = this.allowedValues.min();
- this.maximum = this.allowedValues.max();
- }
+ // Allowed values array
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
+ if (this.allowedValues) {
+ this.minimum = this.allowedValues.min();
+ this.maximum = this.allowedValues.max();
+ }
- this.eventMouseDown = this.startDrag.bindAsEventListener(this);
- this.eventMouseUp = this.endDrag.bindAsEventListener(this);
- this.eventMouseMove = this.update.bindAsEventListener(this);
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
+ this.eventMouseMove = this.update.bindAsEventListener(this);
- // Initialize handles in reverse (make sure first handle is active)
- this.handles.each( function(h,i) {
- i = slider.handles.length-1-i;
- slider.setValue(parseFloat(
- (slider.options.sliderValue instanceof Array ?
- slider.options.sliderValue[i] : slider.options.sliderValue) ||
- slider.range.start), i);
- Element.makePositioned(h); // fix IE
- Event.observe(h, "mousedown", slider.eventMouseDown);
- });
+ // Initialize handles in reverse (make sure first handle is active)
+ this.handles.each(function(h, i) {
+ i = slider.handles.length - 1 - i;
+ slider.setValue(parseFloat(
+ (slider.options.sliderValue instanceof Array ?
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
+ slider.range.start), i);
+ Element.makePositioned(h);
+ // fix IE
+ Event.observe(h, "mousedown", slider.eventMouseDown);
+ });
- Event.observe(this.track, "mousedown", this.eventMouseDown);
- Event.observe(document, "mouseup", this.eventMouseUp);
- Event.observe(document, "mousemove", this.eventMouseMove);
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
+ Event.observe(document, "mouseup", this.eventMouseUp);
+ Event.observe(document, "mousemove", this.eventMouseMove);
- this.initialized = true;
- },
- dispose: function() {
- var slider = this;
- Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
- Event.stopObserving(document, "mouseup", this.eventMouseUp);
- Event.stopObserving(document, "mousemove", this.eventMouseMove);
- this.handles.each( function(h) {
- Event.stopObserving(h, "mousedown", slider.eventMouseDown);
- });
- },
- setDisabled: function(){
- this.disabled = true;
- },
- setEnabled: function(){
- this.disabled = false;
- },
- getNearestValue: function(value){
- if(this.allowedValues){
- if(value >= this.allowedValues.max()) return(this.allowedValues.max());
- if(value <= this.allowedValues.min()) return(this.allowedValues.min());
+ this.initialized = true;
+ },
+ dispose: function() {
+ var slider = this;
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
+ this.handles.each(function(h) {
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
+ });
+ },
+ setDisabled: function() {
+ this.disabled = true;
+ },
+ setEnabled: function() {
+ this.disabled = false;
+ },
+ getNearestValue: function(value) {
+ if (this.allowedValues) {
+ if (value >= this.allowedValues.max()) return(this.allowedValues.max());
+ if (value <= this.allowedValues.min()) return(this.allowedValues.min());
- var offset = Math.abs(this.allowedValues[0] - value);
- var newValue = this.allowedValues[0];
- this.allowedValues.each( function(v) {
- var currentOffset = Math.abs(v - value);
- if(currentOffset <= offset){
- newValue = v;
- offset = currentOffset;
+ var offset = Math.abs(this.allowedValues[0] - value);
+ var newValue = this.allowedValues[0];
+ this.allowedValues.each(function(v) {
+ var currentOffset = Math.abs(v - value);
+ if (currentOffset <= offset) {
+ newValue = v;
+ offset = currentOffset;
+ }
+ });
+ return newValue;
}
- });
- return newValue;
- }
- if(value > this.range.end) return this.range.end;
- if(value < this.range.start) return this.range.start;
- return value;
- },
- setValue: function(sliderValue, handleIdx){
- if(!this.active) {
- this.activeHandleIdx = handleIdx || 0;
- this.activeHandle = this.handles[this.activeHandleIdx];
- this.updateStyles();
- }
- handleIdx = handleIdx || this.activeHandleIdx || 0;
- if(this.initialized && this.restricted) {
- if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
- sliderValue = this.values[handleIdx-1];
- if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
- sliderValue = this.values[handleIdx+1];
- }
- sliderValue = this.getNearestValue(sliderValue);
- this.values[handleIdx] = sliderValue;
- this.value = this.values[0]; // assure backwards compat
+ if (value > this.range.end) return this.range.end;
+ if (value < this.range.start) return this.range.start;
+ return value;
+ },
+ setValue: function(sliderValue, handleIdx) {
+ if (!this.active) {
+ this.activeHandleIdx = handleIdx || 0;
+ this.activeHandle = this.handles[this.activeHandleIdx];
+ this.updateStyles();
+ }
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
+ if (this.initialized && this.restricted) {
+ if ((handleIdx > 0) && (sliderValue < this.values[handleIdx - 1]))
+ sliderValue = this.values[handleIdx - 1];
+ if ((handleIdx < (this.handles.length - 1)) && (sliderValue > this.values[handleIdx + 1]))
+ sliderValue = this.values[handleIdx + 1];
+ }
+ sliderValue = this.getNearestValue(sliderValue);
+ this.values[handleIdx] = sliderValue;
+ this.value = this.values[0];
+ // assure backwards compat
- this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
- this.translateToPx(sliderValue);
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
+ this.translateToPx(sliderValue);
- this.drawSpans();
- if(!this.dragging || !this.event) this.updateFinished();
- },
- setValueBy: function(delta, handleIdx) {
- this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
- handleIdx || this.activeHandleIdx || 0);
- },
- translateToPx: function(value) {
- return Math.round(
- ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
- (value - this.range.start)) + "px";
- },
- translateToValue: function(offset) {
- return ((offset/(this.trackLength-this.handleLength) *
- (this.range.end-this.range.start)) + this.range.start);
- },
- getRange: function(range) {
- var v = this.values.sortBy(Prototype.K);
- range = range || 0;
- return $R(v[range],v[range+1]);
- },
- minimumOffset: function(){
- return(this.isVertical() ? this.alignY : this.alignX);
- },
- maximumOffset: function(){
- return(this.isVertical() ?
- (this.track.offsetHeight != 0 ? this.track.offsetHeight :
- this.track.style.height.replace(/px$/,"")) - this.alignY :
- (this.track.offsetWidth != 0 ? this.track.offsetWidth :
- this.track.style.width.replace(/px$/,"")) - this.alignY);
- },
- isVertical: function(){
- return (this.axis == 'vertical');
- },
- drawSpans: function() {
- var slider = this;
- if(this.spans)
- $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
- if(this.options.startSpan)
- this.setSpan(this.options.startSpan,
- $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
- if(this.options.endSpan)
- this.setSpan(this.options.endSpan,
- $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
- },
- setSpan: function(span, range) {
- if(this.isVertical()) {
- span.style.top = this.translateToPx(range.start);
- span.style.height = this.translateToPx(range.end - range.start + this.range.start);
- } else {
- span.style.left = this.translateToPx(range.start);
- //temporary hard coded fix for oversized trailer
- span.style.width = this.handles[0].offsetLeft + 'px';//document.getElementById('slider-handle').offsetLeft + 'px';
- //span.style.width = this.translateToPx(range.end - range.start + this.range.start);
- }
- },
- updateStyles: function() {
- this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
- Element.addClassName(this.activeHandle, 'selected');
- },
- startDrag: function(event) {
- if(Event.isLeftClick(event)) {
- if(!this.disabled){
- this.active = true;
-
- var handle = Event.element(event);
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var track = handle;
- if(track==this.track) {
- var offsets = Position.cumulativeOffset(this.track);
- this.event = event;
- this.setValue(this.translateToValue(
- (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
- ));
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
+ this.drawSpans();
+ if (!this.dragging || !this.event) this.updateFinished();
+ },
+ setValueBy: function(delta, handleIdx) {
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
+ handleIdx || this.activeHandleIdx || 0);
+ },
+ translateToPx: function(value) {
+ return Math.round(
+ ((this.trackLength - this.handleLength) / (this.range.end - this.range.start)) *
+ (value - this.range.start)) + "px";
+ },
+ translateToValue: function(offset) {
+ return ((offset / (this.trackLength - this.handleLength) *
+ (this.range.end - this.range.start)) + this.range.start);
+ },
+ getRange: function(range) {
+ var v = this.values.sortBy(Prototype.K);
+ range = range || 0;
+ return $R(v[range], v[range + 1]);
+ },
+ minimumOffset: function() {
+ return(this.isVertical() ? this.alignY : this.alignX);
+ },
+ maximumOffset: function() {
+ return(this.isVertical() ?
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
+ this.track.style.height.replace(/px$/, "")) - this.alignY :
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
+ this.track.style.width.replace(/px$/, "")) - this.alignY);
+ },
+ isVertical: function() {
+ return (this.axis == 'vertical');
+ },
+ drawSpans: function() {
+ var slider = this;
+ if (this.spans)
+ $R(0, this.spans.length - 1).each(function(r) {
+ slider.setSpan(slider.spans[r], slider.getRange(r))
+ });
+ if (this.options.startSpan)
+ this.setSpan(this.options.startSpan,
+ $R(0, this.values.length > 1 ? this.getRange(0).min() : this.value));
+ if (this.options.endSpan)
+ this.setSpan(this.options.endSpan,
+ $R(this.values.length > 1 ? this.getRange(this.spans.length - 1).max() : this.value, this.maximum));
+ },
+ setSpan: function(span, range) {
+ if (this.isVertical()) {
+ span.style.top = this.translateToPx(range.start);
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
} else {
- // find the handle (prevents issues with Safari)
- while((this.handles.indexOf(handle) == -1) && handle.parentNode)
- handle = handle.parentNode;
+ span.style.left = this.translateToPx(range.start);
- if(this.handles.indexOf(handle)!=-1) {
- this.activeHandle = handle;
- this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
- this.updateStyles();
+ this.handles.each(function(h) {
+ span.style.width = $(h.id).offsetLeft + 'px';
+ });
- var offsets = Position.cumulativeOffset(this.activeHandle);
- this.offsetX = (pointer[0] - offsets[0]);
- this.offsetY = (pointer[1] - offsets[1]);
- }
+ //original code from prototype 1.6.5
+ //span.style.width = this.translateToPx(range.end - range.start + this.range.start);
}
- }
- Event.stop(event);
+ },
+ updateStyles: function() {
+ this.handles.each(function(h) {
+ Element.removeClassName(h, 'selected')
+ });
+ Element.addClassName(this.activeHandle, 'selected');
+ },
+ startDrag: function(event) {
+ if (Event.isLeftClick(event)) {
+ if (!this.disabled) {
+ this.active = true;
+
+ var handle = Event.element(event);
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var track = handle;
+ if (track == this.track) {
+ var offsets = Position.cumulativeOffset(this.track);
+ this.event = event;
+ this.setValue(this.translateToValue(
+ (this.isVertical() ? pointer[1] - offsets[1] : pointer[0] - offsets[0]) - (this.handleLength / 2)
+ ));
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ } else {
+ // find the handle (prevents issues with Safari)
+ while ((this.handles.indexOf(handle) == -1) && handle.parentNode)
+ handle = handle.parentNode;
+
+ if (this.handles.indexOf(handle) != -1) {
+ this.activeHandle = handle;
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
+ this.updateStyles();
+
+ var offsets = Position.cumulativeOffset(this.activeHandle);
+ this.offsetX = (pointer[0] - offsets[0]);
+ this.offsetY = (pointer[1] - offsets[1]);
+ }
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ update: function(event) {
+ if (this.active) {
+ if (!this.dragging) this.dragging = true;
+ this.draw(event);
+ // fix AppleWebKit rendering
+ if (navigator.appVersion.indexOf('AppleWebKit') > 0) window.scrollBy(0, 0);
+ Event.stop(event);
+ }
+ },
+ draw: function(event) {
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
+ var offsets = Position.cumulativeOffset(this.track);
+ pointer[0] -= this.offsetX + offsets[0];
+ pointer[1] -= this.offsetY + offsets[1];
+ this.event = event;
+ this.setValue(this.translateToValue(this.isVertical() ? pointer[1] : pointer[0]));
+ if (this.initialized && this.options.onSlide)
+ this.options.onSlide(this.values.length > 1 ? this.values : this.value, this);
+ },
+ endDrag: function(event) {
+ if (this.active && this.dragging) {
+ this.finishDrag(event, true);
+ Event.stop(event);
+ }
+ this.active = false;
+ this.dragging = false;
+ },
+ finishDrag: function(event, success) {
+ this.active = false;
+ this.dragging = false;
+ this.updateFinished();
+ },
+ updateFinished: function() {
+ if (this.initialized && this.options.onChange)
+ this.options.onChange(this.values.length > 1 ? this.values : this.value, this);
+ this.event = null;
}
- },
- update: function(event) {
- if(this.active) {
- if(!this.dragging) this.dragging = true;
- this.draw(event);
- // fix AppleWebKit rendering
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
- Event.stop(event);
- }
- },
- draw: function(event) {
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
- var offsets = Position.cumulativeOffset(this.track);
- pointer[0] -= this.offsetX + offsets[0];
- pointer[1] -= this.offsetY + offsets[1];
- this.event = event;
- this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
- if(this.initialized && this.options.onSlide)
- this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
- },
- endDrag: function(event) {
- if(this.active && this.dragging) {
- this.finishDrag(event, true);
- Event.stop(event);
- }
- this.active = false;
- this.dragging = false;
- },
- finishDrag: function(event, success) {
- this.active = false;
- this.dragging = false;
- this.updateFinished();
- },
- updateFinished: function() {
- if(this.initialized && this.options.onChange)
- this.options.onChange(this.values.length>1 ? this.values : this.value, this);
- this.event = null;
- }
}
\ No newline at end of file
17 years, 8 months