Author: sergeyhalipov
Date: 2007-07-30 09:21:11 -0400 (Mon, 30 Jul 2007)
New Revision: 1920
Modified:
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js
trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx
Log:
Fix "required" attribute for spinner like
http://jira.jboss.com/jira/browse/RF-504
Modified:
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js
===================================================================
---
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js 2007-07-30
12:44:17 UTC (rev 1919)
+++
trunk/ui/inputnumber-spinner/src/main/resources/org/richfaces/renderkit/html/script/SpinnerScript.js 2007-07-30
13:21:11 UTC (rev 1920)
@@ -33,6 +33,7 @@
this.max = null;
this.min = null;
this.delta = null;
+ this.required = options.required;
this._attachBehaviors();
this._load();
@@ -158,7 +159,7 @@
this.edit = $ (edit);
this.originalColor = edit.style.color;
- this.prevEditValue = (this.edit.value || this.spinner.min);
+ this.prevEditValue = (this.edit.value || !this.spinner.required) ? this.edit.value :
this.spinner.min;
this.edit.value = this.prevEditValue;
this.previousMU = window.document.onmouseup;
this.previousMM = window.document.onmousemove;
@@ -265,14 +266,17 @@
},
inputChange: function(e) {
- if (this.edit.value == "" || isNaN(Number(this.edit.value))){
+ if ((this.edit.value == "" && this.spinner.required) ||
isNaN(Number(this.edit.value))){
this.edit.value = this.prevEditValue;
- } else if (this.edit.value > this.spinner.max){
- this.edit.value = this.spinner.max;
- } else if (this.edit.value < this.spinner.min) {
- this.edit.value = this.spinner.min;
+ } else if ("" != this.edit.value) {
+ if (this.edit.value > this.spinner.max){
+ this.edit.value = this.spinner.max;
+ } else if (this.edit.value < this.spinner.min) {
+ this.edit.value = this.spinner.min;
+ }
}
- this.prevEditValue = this.edit.value;
+ if ("" != this.edit.value)
+ this.prevEditValue = this.edit.value;
if (this.eventEditOnChange)
this.eventEditOnChange();
@@ -283,7 +287,8 @@
this.prevEditValue = this.edit.value;
}
if (e.keyCode == 13){
- this.edit.value = this.getValidValue(this.edit.value);
+ if (this.spinner.required || "" != this.edit.value)
+ this.edit.value = this.getValidValue(this.edit.value);
this.edit.form.submit();
}
},
Modified: trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx
===================================================================
--- trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx 2007-07-30
12:44:17 UTC (rev 1919)
+++ trunk/ui/inputnumber-spinner/src/main/templates/inputNumberSpinner.jspx 2007-07-30
13:21:11 UTC (rev 1920)
@@ -102,7 +102,8 @@
cycled:#{component.attributes['cycled']},
edited:#{component.attributes['enableManualInput']},
disabled:#{component.attributes['disabled']},
- chameleon:false
+ chameleon:false,
+ required: #{component.attributes['required']}
},
{
min:#{component.attributes['minValue']},