Author: konstantin.mishin
Date: 2010-09-29 07:19:09 -0400 (Wed, 29 Sep 2010)
New Revision: 19367
Modified:
trunk/ui/input/ui/src/main/config/faces-config.xml
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js
trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml
Log:
RF-9218
Modified: trunk/ui/input/ui/src/main/config/faces-config.xml
===================================================================
--- trunk/ui/input/ui/src/main/config/faces-config.xml 2010-09-29 11:01:54 UTC (rev
19366)
+++ trunk/ui/input/ui/src/main/config/faces-config.xml 2010-09-29 11:19:09 UTC (rev
19367)
@@ -151,6 +151,14 @@
</property-extension>
</property>
<property>
+ <property-name>onchange</property-name>
+ <property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:event-name default="true">change</cdk:event-name>
+ </property-extension>
+ </property>
+ <property>
<property-name>showArrows</property-name>
<property-class>boolean</property-class>
<default-value>false</default-value>
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js 2010-09-29
11:01:54 UTC (rev 19366)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js 2010-09-29
11:19:09 UTC (rev 19367)
@@ -68,20 +68,20 @@
},
decrease: function (event) {
- this.setValue(this.value - this.step);
+ this.setValue(this.value - this.step, event);
},
increase: function (event) {
- this.setValue(this.value + this.step);
+ this.setValue(this.value + this.step, event);
},
- setValue: function (value) {
+ setValue: function (value, event) {
if (!this.disabled) {
- this.__setValue(value);
+ this.__setValue(value, event);
}
},
- __setValue: function (value) {
+ __setValue: function (value, event) {
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) {
@@ -96,34 +96,37 @@
this.tooltip.text(value);
this.tooltip.setPosition(this.handle,{from: 'LT', offset: [0, -3]});
//TODO Seems offset doesn't work now.
this.value = value;
+ if (this.onchange && (!event || event.type)) {
+ this.onchange.call(this.element[0], event);
+ }
}
}
},
- __inputHandler: function () {
+ __inputHandler: function (event) {
var value = Number(this.input.val());
if (isNaN(value)) {
this.input.val(this.value);
} else {
- this.__setValue(value);
+ this.__setValue(value, event);
}
},
__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);
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);
event.preventDefault();
}
},
__decreaseHandler: function (event) {
var component = this;
- component.decrease();
+ component.decrease(event);
this.intervalId = window.setInterval(function() {
- component.decrease();
+ component.decrease(event);
}, this.delay);
jQuery(document).one("mouseup", true, jQuery.proxy(this.__clearInterval,
this));
this.decreaseButton.addClass(this.decreaseSelectedClass);
@@ -132,9 +135,9 @@
__increaseHandler: function (event) {
var component = this;
- component.increase();
+ component.increase(event);
this.intervalId = window.setInterval(function() {
- component.increase();
+ component.increase(event);
}, this.delay);
jQuery(document).one("mouseup",jQuery.proxy(this.__clearInterval,
this));
this.increaseButton.addClass(this.increaseSelectedClass);
@@ -163,7 +166,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);
event.preventDefault();
},
Modified: trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml 2010-09-29
11:01:54 UTC (rev 19366)
+++ trunk/ui/input/ui/src/main/templates/inputnumberslider.template.xml 2010-09-29
11:19:09 UTC (rev 19367)
@@ -68,11 +68,14 @@
<c:if test="#{component.attributes['showToolTip']}">
<span class="rf-insl-tt
#{component.attributes['toolTipClass']}">#{getInputValue(facesContext,
component)}</span>
</c:if>
+ <!-- TODO Rewrite the next line when the CDK will support normal way to take event
handlers from attributes and behaviors. -->
+ <cdk:object name="onchange" type="String"
value="#{convertToString(RenderKitUtils.getAttributeAndBehaviorsValue(facesContext,
component, RenderKitUtils.attributes().generic('onchange', 'onchange',
'change').first()))}" />
<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']},
+ onchange: #{onchange.length() > 0 ? 'function (event) {' + onchange +
'}' : 'null' },
step: #{component.attributes['step']},
tabIndex:
#{RenderKitUtils.shouldRenderAttribute(component.attributes['tabindex']) ?
component.attributes['tabindex'] : 'null'}
}, {