Author: konstantin.mishin
Date: 2010-08-03 12:18:22 -0400 (Tue, 03 Aug 2010)
New Revision: 18396
Added:
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowBottom.java
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowLeft.java
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowRight.java
Modified:
root/sandbox/examples/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java
root/sandbox/examples/components/inputnumberslider-demo/src/main/webapp/index.xhtml
root/sandbox/ui/inputs/inputnumberslider/src/main/config/faces-config.xml
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
root/sandbox/ui/inputs/inputnumberslider/src/main/templates/inputnumberslider.template.xml
Log:
RF-8983
Modified:
root/sandbox/examples/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java
===================================================================
---
root/sandbox/examples/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java 2010-08-03
13:56:28 UTC (rev 18395)
+++
root/sandbox/examples/components/inputnumberslider-demo/src/main/java/org/richfaces/demo/Bean.java 2010-08-03
16:18:22 UTC (rev 18396)
@@ -37,6 +37,7 @@
private double value;
private String accesskey;
private int delay = 200;
+ private boolean disabled = false;
private boolean enableManualInput = true;
private PositionType inputPosition = PositionType.right;
private double maxValue = 100;
@@ -158,4 +159,12 @@
public String[] getSkins() {
return SKINS;
}
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public boolean isDisabled() {
+ return disabled;
+ }
}
Modified:
root/sandbox/examples/components/inputnumberslider-demo/src/main/webapp/index.xhtml
===================================================================
---
root/sandbox/examples/components/inputnumberslider-demo/src/main/webapp/index.xhtml 2010-08-03
13:56:28 UTC (rev 18395)
+++
root/sandbox/examples/components/inputnumberslider-demo/src/main/webapp/index.xhtml 2010-08-03
16:18:22 UTC (rev 18396)
@@ -39,11 +39,11 @@
<f:selectItems value="#{bean.skins}"/>
</h:selectOneMenu>
<br />
- <ins:inputnumberslider id="ins" value="#{bean.value}"
accesskey="#{bean.accesskey}"
- delay="#{bean.delay}"
enableManualInput="#{bean.enableManualInput}"
showArrows="#{bean.showArrows}"
- showBoundaryValues="#{bean.showBoundaryValues}"
showInput="#{bean.showInput}"
- showToolTip="#{bean.showToolTip}" maxValue="#{bean.maxValue}"
minValue="#{bean.minValue}"
- step="#{bean.step}" inputPosition="#{bean.inputPosition}"/>
+ <ins:inputnumberslider id="ins" value="#{bean.value}"
accesskey="#{bean.accesskey}" delay="#{bean.delay}"
+ disabled="#{bean.disabled}"
enableManualInput="#{bean.enableManualInput}"
+ showArrows="#{bean.showArrows}"
showBoundaryValues="#{bean.showBoundaryValues}"
+ showInput="#{bean.showInput}" showToolTip="#{bean.showToolTip}"
maxValue="#{bean.maxValue}"
+ minValue="#{bean.minValue}" step="#{bean.step}"
inputPosition="#{bean.inputPosition}"/>
<br />
<h:outputText value="Accesskey: "/>
<h:inputText value="#{bean.accesskey}">
@@ -55,6 +55,11 @@
<f:ajax render="ins"/>
</h:selectBooleanCheckbox>
<br />
+ <h:outputText value="Disabled "/>
+ <h:selectBooleanCheckbox value="#{bean.disabled}">
+ <f:ajax render="ins"/>
+ </h:selectBooleanCheckbox>
+ <br />
<h:outputText value="Delay: "/>
<h:inputText value="#{bean.delay}">
<f:ajax render="ins"/>
Modified: root/sandbox/ui/inputs/inputnumberslider/src/main/config/faces-config.xml
===================================================================
--- root/sandbox/ui/inputs/inputnumberslider/src/main/config/faces-config.xml 2010-08-03
13:56:28 UTC (rev 18395)
+++ root/sandbox/ui/inputs/inputnumberslider/src/main/config/faces-config.xml 2010-08-03
16:18:22 UTC (rev 18396)
@@ -60,6 +60,14 @@
</property-extension>
</property>
<property>
+ <property-name>disabled</property-name>
+ <property-class>boolean</property-class>
+ <default-value>false</default-value>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
+ </property>
+ <property>
<property-name>enableManualInput</property-name>
<property-class>boolean</property-class>
<default-value>true</default-value>
Added:
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowBottom.java
===================================================================
---
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowBottom.java
(rev 0)
+++
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowBottom.java 2010-08-03
16:18:22 UTC (rev 18396)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderDisabledArrowBottom extends SliderArrowBottom {
+
+ public SliderDisabledArrowBottom() {
+ setColorName("tabDisabledTextColor");
+ }
+}
Added:
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowLeft.java
===================================================================
---
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowLeft.java
(rev 0)
+++
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowLeft.java 2010-08-03
16:18:22 UTC (rev 18396)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderDisabledArrowLeft extends SliderArrowLeft {
+
+ public SliderDisabledArrowLeft() {
+ setColorName("tabDisabledTextColor");
+ }
+}
Added:
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowRight.java
===================================================================
---
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowRight.java
(rev 0)
+++
root/sandbox/ui/inputs/inputnumberslider/src/main/java/org/richfaces/renderkit/html/images/SliderDisabledArrowRight.java 2010-08-03
16:18:22 UTC (rev 18396)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html.images;
+
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SliderDisabledArrowRight extends SliderArrowRight {
+
+ public SliderDisabledArrowRight() {
+ setColorName("tabDisabledTextColor");
+ }
+}
Modified:
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss
===================================================================
---
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-08-03
13:56:28 UTC (rev 18395)
+++
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.ecss 2010-08-03
16:18:22 UTC (rev 18396)
@@ -77,7 +77,7 @@
clear: both;
}
-.rf-ins-h, .rf-ins-db, .rf-ins-ib {
+.rf-ins-h, .rf-ins-db, .rf-ins-ib, .rf-ins-h-d, .rf-ins-db-d, .rf-ins-ib-d {
display: inline-block;
width: 7px;
height: 7px;
@@ -91,6 +91,10 @@
background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderSelectedArrowBottom']}");
}
+.rf-ins-h-d {
+ background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderDisabledArrowBottom']}");
+}
+
.rf-ins-db {
background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderArrowLeft']}");
}
@@ -99,10 +103,18 @@
background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderSelectedArrowLeft']}");
}
+.rf-ins-db-d {
+ background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderDisabledArrowLeft']}");
+}
+
.rf-ins-ib {
background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderArrowRight']}");
}
.rf-ins-ib-s {
background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderSelectedArrowRight']}");
+}
+
+.rf-ins-ib-d {
+ background-image:
url("#{resource['org.richfaces.renderkit.html.images.SliderDisabledArrowRight']}");
}
\ No newline at end of file
Modified:
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js
===================================================================
---
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-08-03
13:56:28 UTC (rev 18395)
+++
root/sandbox/ui/inputs/inputnumberslider/src/main/resources/META-INF/resources/inputNumberSlider.js 2010-08-03
16:18:22 UTC (rev 18396)
@@ -37,32 +37,50 @@
init: function (id, options, selectedClasses) {
jQuery.extend(this, options);
- for (var i in selectedClasses) {
- this[i] += " " + selectedClasses[i];
- }
this.range = this.maxValue - this.minValue;
this.id = id;
this.element = jQuery(this.attachToDom());
this.input = this.element.children(".rf-ins-i");
this.track =
this.element.children(".rf-ins-ta").children(".rf-ins-t");
- this.handle = this.track.children(".rf-ins-h");
+ this.handle = this.track.children(".rf-ins-h, .rf-ins-h-d");
this.tooltip = this.element.children(".rf-ins-tt");
- this.decrease = this.element.children(".rf-ins-db");
- this.increase = this.element.children(".rf-ins-ib");
-
+
this.__inputHandler();
- this.track[0].tabIndex = 0;
-
- var proxy = jQuery.proxy(this.__inputHandler, this)
- this.input.change(proxy);
- this.input.submit(proxy);
- this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
- this.decrease.mousedown(jQuery.proxy(this.__decreaseHandler, this));
- this.increase.mousedown(jQuery.proxy(this.__increaseHandler, this));
- this.track.mousedown(jQuery.proxy(this.__mousedownHandler, this));
+
+ if (!this.disabled) {
+ this.decreaseButton = this.element.children(".rf-ins-db");
+ this.increaseButton = this.element.children(".rf-ins-ib");
+
+ this.track[0].tabIndex = 0;
+
+ for (var i in selectedClasses) {
+ this[i] += " " + selectedClasses[i];
+ }
+ var proxy = jQuery.proxy(this.__inputHandler, this)
+ this.input.change(proxy);
+ this.input.submit(proxy);
+ this.track.keydown(jQuery.proxy(this.__keydownHandler, this));
+ this.decreaseButton.mousedown(jQuery.proxy(this.__decreaseHandler, this));
+ this.increaseButton.mousedown(jQuery.proxy(this.__increaseHandler, this));
+ this.track.mousedown(jQuery.proxy(this.__mousedownHandler, this));
+ }
},
+ decrease: function (event) {
+ this.setValue(this.value - this.step);
+ },
+
+ increase: function (event) {
+ this.setValue(this.value + this.step);
+ },
+
setValue: function (value) {
+ if (!this.disabled) {
+ this.__setValue(value);
+ }
+ },
+
+ __setValue: function (value) {
if (!isNaN(value)) {
value = Math.round(value / this.step) * this.step; //TODO Add normal support of
float values. E.g. '0.3' should be instead of '0.30000000000000004'.
if (value > this.maxValue) {
@@ -86,46 +104,48 @@
if (isNaN(value)) {
this.input.val(this.value);
} else {
- this.setValue(value);
+ this.__setValue(value);
}
},
__keydownHandler: function (event) {
if (event.keyCode == 37) { //LEFT
- this.setValue(Number(this.input.val()) - this.step);
+ this.__setValue(Number(this.input.val()) - this.step);
event.preventDefault();
} else if (event.keyCode == 39) { //RIGHT
- this.setValue(Number(this.input.val()) + this.step);
+ this.__setValue(Number(this.input.val()) + this.step);
event.preventDefault();
}
},
__decreaseHandler: function (event) {
var component = this;
+ component.decrease();
this.intervalId = window.setInterval(function() {
- component.setValue(Number(component.input.val()) - component.step);
+ component.decrease();
}, this.delay);
jQuery(document).one("mouseup", true, jQuery.proxy(this.__clearInterval,
this));
- this.decrease.addClass(this.decreaseSelectedClass);
+ this.decreaseButton.addClass(this.decreaseSelectedClass);
event.preventDefault();
},
__increaseHandler: function (event) {
var component = this;
+ component.increase();
this.intervalId = window.setInterval(function() {
- component.setValue(Number(component.input.val()) + component.step);
+ component.increase();
}, this.delay);
jQuery(document).one("mouseup",jQuery.proxy(this.__clearInterval,
this));
- this.increase.addClass(this.increaseSelectedClass);
+ this.increaseButton.addClass(this.increaseSelectedClass);
event.preventDefault();
},
__clearInterval: function (event) {
window.clearInterval(this.intervalId);
- if (event.data) { // decrease
- this.decrease.removeClass(this.decreaseSelectedClass);
+ if (event.data) { // decreaseButton
+ this.decreaseButton.removeClass(this.decreaseSelectedClass);
} else {
- this.increase.removeClass(this.increaseSelectedClass);
+ this.increaseButton.removeClass(this.increaseSelectedClass);
}
},
@@ -142,7 +162,7 @@
__mousemoveHandler: function (event) {
var value = this.range * (event.pageX - this.track.position().left) /
(this.track.width()
- this.handle.width()) + this.minValue;
- this.setValue(value);
+ this.__setValue(value);
event.preventDefault();
},
Modified:
root/sandbox/ui/inputs/inputnumberslider/src/main/templates/inputnumberslider.template.xml
===================================================================
---
root/sandbox/ui/inputs/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-08-03
13:56:28 UTC (rev 18395)
+++
root/sandbox/ui/inputs/inputnumberslider/src/main/templates/inputnumberslider.template.xml 2010-08-03
16:18:22 UTC (rev 18396)
@@ -44,14 +44,14 @@
|| PositionType.valueOf('top') ==
component.attributes['inputPosition']}">
<input name="#{clientId}" type="text"
class="rf-ins-i" size="3"
value="#{getInputValue(facesContext, component)}"
accesskey="#{component.attributes['accesskey']}"
- readonly="#{!component.attributes['enableManualInput']}"
+ disabled="#{component.attributes['disabled']}"
readonly="#{!component.attributes['enableManualInput']}"
style="#{component.attributes['showInput'] ? null : 'display:
none;'}" />
<c:if test="#{PositionType.valueOf('top') ==
component.attributes['inputPosition'] and
component.attributes['showInput']}">
<br />
</c:if>
</c:if>
<c:if test="#{component.attributes['showArrows']}">
- <a class="rf-ins-db #{component.attributes['decreaseClass']}"
href="javascript:void(0);" />
+ <span class="rf-ins-db#{component.attributes['disabled'] ?
'-d' : ''} #{component.attributes['decreaseClass']}" />
</c:if>
<span class="rf-ins-ta">
<c:if test="#{component.attributes['showBoundaryValues']}">
@@ -59,11 +59,11 @@
<span
class="rf-ins-mx">#{component.attributes['maxValue']}</span>
</c:if>
<span class="rf-ins-t
#{component.attributes['trackClass']}">
- <span class="rf-ins-h #{component.attributes['handleClass']}"
/>
+ <span class="rf-ins-h#{component.attributes['disabled'] ?
'-d' : ''} #{component.attributes['handleClass']}" />
</span>
</span>
<c:if test="#{component.attributes['showArrows']}">
- <a class="rf-ins-ib #{component.attributes['increaseClass']}"
href="javascript:void(0);" />
+ <span class="rf-ins-ib#{component.attributes['disabled'] ?
'-d' : ''} #{component.attributes['increaseClass']}" />
</c:if>
<c:if test="#{PositionType.valueOf('right') ==
component.attributes['inputPosition']
|| PositionType.valueOf('bottom') ==
component.attributes['inputPosition']}">
@@ -72,7 +72,7 @@
</c:if>
<input name="#{clientId}" type="text"
class="rf-ins-i" size="3"
value="#{getInputValue(facesContext, component)}"
accesskey="#{component.attributes['accesskey']}"
- readonly="#{!component.attributes['enableManualInput']}"
+ disabled="#{component.attributes['disabled']}"
readonly="#{!component.attributes['enableManualInput']}"
style="#{component.attributes['showInput'] ? null : 'display:
none;'}" />
</c:if>
<c:if test="#{component.attributes['showToolTip']}">
@@ -80,6 +80,7 @@
</c:if>
<script type="text/javascript">new
RichFaces.ui.InputNumberSlider('#{clientId}', {
delay: #{component.attributes['delay']},
+ disabled: #{component.attributes['disabled']},
maxValue: #{component.attributes['maxValue']},
minValue: #{component.attributes['minValue']},
step: #{component.attributes['step']}