[Dojo-checkins] doughays - r11476 - in branches/1.0/dijit/trunk: form tests/form

dojo-checkins-admin at dojotoolkit.org dojo-checkins-admin at dojotoolkit.org
Sun Nov 11 19:05:43 UTC 2007


Author: doughays
Date: Sun Nov 11 19:05:43 2007
New Revision: 11476

Modified:
   branches/1.0/dijit/trunk/form/ComboBox.js
   branches/1.0/dijit/trunk/form/FilteringSelect.js
   branches/1.0/dijit/trunk/form/Slider.js
   branches/1.0/dijit/trunk/form/_FormWidget.js
   branches/1.0/dijit/trunk/form/_Spinner.js
   branches/1.0/dijit/trunk/tests/form/test_ComboBox.html
   branches/1.0/dijit/trunk/tests/form/test_DateTextBox.html
   branches/1.0/dijit/trunk/tests/form/test_FilteringSelect.html
   branches/1.0/dijit/trunk/tests/form/test_Spinner.html
   branches/1.0/dijit/trunk/tests/form/test_Textarea.html
   branches/1.0/dijit/trunk/tests/form/test_TimeTextBox.html
   branches/1.0/dijit/trunk/tests/form/test_validate.html
Log:
Fixes #5064 for 1.0.1.  See [11475] for a descripton of changes.

Modified: branches/1.0/dijit/trunk/form/ComboBox.js
==============================================================================
--- branches/1.0/dijit/trunk/form/ComboBox.js	(original)
+++ branches/1.0/dijit/trunk/form/ComboBox.js	Sun Nov 11 19:05:43 2007
@@ -247,7 +247,7 @@
 						this.setDisplayedValue(this._lastDisplayedValue);
 						dojo.stopEvent(evt);
 					}else{
-						this.setValue(this.getValue());
+						this.setValue(this.getValue(), false);
 					}
 					break;
 
@@ -402,7 +402,7 @@
 			// #4617: if value is now more choices or previous choices, revert the value
 			var newvalue=this.getDisplayedValue();
 			if(this._popupWidget&&(newvalue==this._popupWidget._messages["previousMessage"]||newvalue==this._popupWidget._messages["nextMessage"])){
-				this.setValue(this._lastValueReported);
+				this.setValue(this._lastValueReported, true);
 			}else{
 				this.setDisplayedValue(newvalue);
 			}

Modified: branches/1.0/dijit/trunk/form/FilteringSelect.js
==============================================================================
--- branches/1.0/dijit/trunk/form/FilteringSelect.js	(original)
+++ branches/1.0/dijit/trunk/form/FilteringSelect.js	Sun Nov 11 19:05:43 2007
@@ -39,7 +39,7 @@
 			return this._isvalid;
 		},
 
-		_callbackSetLabel: function(/*Array*/ result, /*Object*/ dataObject){
+		_callbackSetLabel: function(/*Array*/ result, /*Object*/ dataObject, /*Boolean, optional*/ priorityChange){
 			// summary
 			//	Callback function that dynamically sets the label of the ComboBox
 
@@ -57,7 +57,7 @@
 				this._isvalid=false;
 				this.validate(this._hasFocus);
 			}else{
-				this._setValueFromItem(result[0]);
+				this._setValueFromItem(result[0], priorityChange);
 			}
 		},
 
@@ -79,25 +79,25 @@
 			return "value";
 		},
 
-		_setValue:function(/*String*/ value, /*String*/ displayedValue){
+		_setValue:function(/*String*/ value, /*String*/ displayedValue, /*Boolean, optional*/ priorityChange){
 			this.valueNode.value = value;
-			dijit.form.FilteringSelect.superclass.setValue.call(this, value, true, displayedValue);
+			dijit.form.FilteringSelect.superclass.setValue.call(this, value, priorityChange, displayedValue);
 			this._lastDisplayedValue = displayedValue;
 		},
 
-		setValue: function(/*String*/ value){
+		setValue: function(/*String*/ value, /*Boolean, optional*/ priorityChange){
 			// summary
 			//	Sets the value of the select.
 			//	Also sets the label to the corresponding value by reverse lookup.
 
 			//#3347: fetchItemByIdentity if no keyAttr specified
 			var self=this;
-			var handleFetchByIdentity = function(item){
+			var handleFetchByIdentity = function(item, priorityChange){
 				if(item){
 					if(self.store.isItemLoaded(item)){
-						self._callbackSetLabel([item]);
+						self._callbackSetLabel([item], undefined, priorityChange);
 					}else{
-						self.store.loadItem({item:item, onItem: self._callbackSetLabel});
+						self.store.loadItem({item:item, onItem: function(result, dataObject){self._callbackSetLabel(result, dataObject, priorityChange)}});
 					}
 				}else{
 					self._isvalid=false;
@@ -105,15 +105,15 @@
 					self.validate(false);
 				}
 			}
-			this.store.fetchItemByIdentity({identity: value, onItem: handleFetchByIdentity});
+			this.store.fetchItemByIdentity({identity: value, onItem: function(item){handleFetchByIdentity(item, priorityChange)}});
 		},
 
-		_setValueFromItem: function(/*item*/ item){
+		_setValueFromItem: function(/*item*/ item, /*Boolean, optional*/ priorityChange){
 			// summary
 			//	Set the displayed valued in the input box, based on a selected item.
 			//	Users shouldn't call this function; they should be calling setDisplayedValue() instead
 			this._isvalid=true;
-			this._setValue(this.store.getIdentity(item), this.labelFunc(item, this.store));
+			this._setValue(this.store.getIdentity(item), this.labelFunc(item, this.store), priorityChange);
 		},
 
 		labelFunc: function(/*item*/ item, /*dojo.data.store*/ store){
@@ -133,7 +133,7 @@
 			//	ComboBox's menu callback function
 			//	FilteringSelect overrides this to set both the visible and hidden value from the information stored in the menu
 			this.item = tgt.item;
-			this._setValueFromItem(tgt.item);
+			this._setValueFromItem(tgt.item, true);
 		},
 
 		setDisplayedValue:function(/*String*/ label){

Modified: branches/1.0/dijit/trunk/form/Slider.js
==============================================================================
--- branches/1.0/dijit/trunk/form/Slider.js	(original)
+++ branches/1.0/dijit/trunk/form/Slider.js	Sun Nov 11 19:05:43 2007
@@ -59,10 +59,10 @@
 		if(this.disabled || e.altKey || e.ctrlKey){ return; }
 		switch(e.keyCode){
 			case dojo.keys.HOME:
-				this.setValue(this.minimum);
+				this.setValue(this.minimum, false);
 				break;
 			case dojo.keys.END:
-				this.setValue(this.maximum);
+				this.setValue(this.maximum, false);
 				break;
 			case dojo.keys.UP_ARROW:
 			case (this._isReversed() ? dojo.keys.LEFT_ARROW : dojo.keys.RIGHT_ARROW):

Modified: branches/1.0/dijit/trunk/form/_FormWidget.js
==============================================================================
--- branches/1.0/dijit/trunk/form/_FormWidget.js	(original)
+++ branches/1.0/dijit/trunk/form/_FormWidget.js	Sun Nov 11 19:05:43 2007
@@ -193,12 +193,14 @@
 			multiply("Disabled");
 		}else if(this._active){
 			multiply(this.stateModifier+"Active");
-		}else if(this._focused){
-			multiply("Focused");
-		}else if(this._hovering){
-			multiply(this.stateModifier+"Hover");
+		}else{
+			if(this._focused){
+				multiply("Focused");
+			}
+			if((this.stateModifier || !this._focused) && this._hovering){
+				multiply(this.stateModifier+"Hover");
+			}
 		}
-
 		(this.stateNode || this.domNode).className = this.staticClass + " " + classes.join(" ");
 	},
 
@@ -216,10 +218,12 @@
 		// summary: set the value of the widget.
 		this._lastValue = newValue;
 		dijit.setWaiState(this.focusNode || this.domNode, "valuenow", this.forWaiValuenow());
+		if(priorityChange === undefined){ priorityChange = true; } // setValue with value only should fire onChange
 		if(this._lastValueReported == undefined && priorityChange === null){ // don't report the initial value
 			this._lastValueReported = newValue;
 		}
-		if((this.intermediateChanges || priorityChange) && newValue !== this._lastValueReported){
+		if((this.intermediateChanges || priorityChange) && 
+			((newValue && newValue.toString)?newValue.toString():newValue) !== ((this._lastValueReported && this._lastValueReported.toString)?this._lastValueReported.toString():this._lastValueReported)){
 			this._lastValueReported = newValue;
 			this.onChange(newValue);
 		}

Modified: branches/1.0/dijit/trunk/form/_Spinner.js
==============================================================================
--- branches/1.0/dijit/trunk/form/_Spinner.js	(original)
+++ branches/1.0/dijit/trunk/form/_Spinner.js	Sun Nov 11 19:05:43 2007
@@ -49,7 +49,7 @@
 		_arrowPressed: function(/*Node*/ nodePressed, /*Number*/ direction){
 			if(this.disabled){ return; }
 			dojo.addClass(nodePressed, "dijitSpinnerButtonActive");
-			this.setValue(this.adjust(this.getValue(), direction*this.smallDelta));
+			this.setValue(this.adjust(this.getValue(), direction*this.smallDelta), false);
 		},
 
 		_arrowReleased: function(/*Node*/ node){

Modified: branches/1.0/dijit/trunk/tests/form/test_ComboBox.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_ComboBox.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_ComboBox.html	Sun Nov 11 19:05:43 2007
@@ -77,7 +77,7 @@
 			style="width:50%;font-size:15pt;"
 			name="foo.bar1"
 			autoComplete="false"
-			onChange="setVal1"
+			onChange="dojo.byId('oc1').value=arguments[0]"
 			pageSize="30"
 	>
 		<option></option>
@@ -143,8 +143,8 @@
 		<option>Wisconsin</option>
 		<option>Wyoming</option>
 	</select>
+	onChange:<input id="oc1" disabled value="not fired yet!" autocomplete="off">
 
-	<span>Value: <input id="value1" disabled value="Iowa"></span>
 	<hr>
 
 	<div dojoType="dojo.data.ItemFileReadStore" jsId="stateStore"

Modified: branches/1.0/dijit/trunk/tests/form/test_DateTextBox.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_DateTextBox.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_DateTextBox.html	Sun Nov 11 19:05:43 2007
@@ -2,7 +2,7 @@
 	"http://www.w3.org/TR/html4/strict.dtd">
 <html>
 	<head>
-		<title>Test TextBox Validation Widgets</title>
+		<title>Test DateTextBox Widget</title>
 
 
 		<script type="text/javascript" src="../../../dojo/dojo.js"
@@ -56,34 +56,36 @@
 			http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
 		<form id="form1" action="" name="example" method="post">
 			<div class="dojoTitlePaneLabel">
-				<label for="q14"> Date (local format) </label>
+				<label for="q1"> Date (local format) </label>
 				<span class="noticeMessage">DateTextBox class, no attributes</span>
 			</div>
 			<div class="testExample">
-				<input id="q14" name="noDOMvalue" type="text" dojoType="dijit.form.DateTextBox">
+				<input id="q1" name="noDOMvalue" type="text" dojoType="dijit.form.DateTextBox">
 			</div>
 			<div class="dojoTitlePaneLabel">
-				<label for="q14a"> Date (local format - long) </label>
+				<label for="q2"> Date (local format - long) </label>
 				<span class="noticeMessage">DateTextBox class,
 					Attributes: required="true", trim="true", constraints={min:'2004-01-01',max:'2006-12-31',formatLength:'long'}. Works for leap years</span>
 			</div>
 			<div class="testExample">
-				<input id="q14a" type="text" name="date1" class="medium" value="2005-12-30"
+				<input id="q2" type="text" name="date1" class="medium" value="2005-12-30"
 					dojoType="dijit.form.DateTextBox"
 					constraints="{min:'2004-01-01',max:'2006-12-31',formatLength:'long'}"
 					required="true"
 					trim="true"
 					promptMessage="mm/dd/yyyy"
+         				onChange="dojo.byId('oc2').value=arguments[0]"
 					invalidMessage="Invalid date. Use mm/dd/yyyy format." />
-				<input type="button" value="Destroy" onClick="dijit.byId('q14a').destroy(); return false;">
+ 				onChange:<input id="oc2" size="34" disabled value="not fired yet!" autocomplete="off">
+				<input type="button" value="Destroy" onClick="dijit.byId('q2').destroy(); return false;">
 			</div>
 			<div class="dojoTitlePaneLabel">
-				<label for="q14b"> Date (American format) </label>
+				<label for="q3"> Date (American format) </label>
 				<span class="noticeMessage">DateTextBox class,
 					Attributes: lang="en-us", required="true", constraints={min:'2004-01-01',max:'2006-12-31'}. Works for leap years</span>
 			</div>
 			<div class="testExample">
-				<input id="q14b" type="text" name="date2" class="medium" value="2005-12-30"
+				<input id="q3" type="text" name="date2" class="medium" value="2005-12-30"
 					dojoType="dijit.form.DateTextBox"
 					constraints="{min:'2004-01-01',max:'2006-12-31'}"
 					lang="en-us"
@@ -92,19 +94,19 @@
 					invalidMessage="Invalid date. Use mm/dd/yyyy format." />
 			</div>
 			<div class="dojoTitlePaneLabel">
-				<label for="q15"> Date (German format) </label>
+				<label for="q4"> Date (German format) </label>
 				<span class="noticeMessage">DateTextBox class,
 					Attributes: lang="de-de", constraints={min:2004-01-01, max:2006-12-31}. Works for leap years</span>
 			</div>
 			<div class="testExample">
-				<input id="q15" class="medium"/>
+				<input id="q4" class="medium"/>
 			</div>
 		
 			<script>
 			// See if we can make a widget in script and attach it to the DOM ourselves.
 			dojo.addOnLoad(function(){
 				var props = {
-					name: "date3",
+					name: "date4",
 					value: new Date(2006,10,29),
 					constraints: {min:new Date(2004,0,1),max:new Date(2006,11,31)},
 					lang: "de-de",
@@ -112,7 +114,7 @@
 					rangeMessage: "Enter a date in 2006.",
 					invalidMessage: "Invalid date. Use dd.mm.yy format."
 				};
-				var w = new dijit.form.DateTextBox(props, "q15");
+				var w = new dijit.form.DateTextBox(props, "q4");
 			});
 			</script>
 

Modified: branches/1.0/dijit/trunk/tests/form/test_FilteringSelect.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_FilteringSelect.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_FilteringSelect.html	Sun Nov 11 19:05:43 2007
@@ -64,7 +64,7 @@
 				name="state1"
 				autoComplete="false"
 				invalidMessage="Invalid state name"
-				onChange="setValue('value1', arguments[0]);"
+				onChange="dojo.byId('oc1').value=arguments[0]"
 		>
 			<option value="blank"></option>
 			<option value="AL">Alabama</option>
@@ -129,7 +129,7 @@
 			<option value="WI">Wisconsin</option>
 			<option value="WY">Wyoming</option>
 		</select>
-		<span>Value: <input id="value1" disabled value="CA"></span>
+		onChange:<input id="oc1" disabled value="not fired yet!" autocomplete="off">
 		<input type="button" value="Set displayed value to Kentucky (valid)" onClick="dijit.byId('setvaluetest2').setDisplayedValue('Kentucky')">
 		<input type="button" value="Set displayed value to Canada (invalid)" onClick="dijit.byId('setvaluetest2').setDisplayedValue('Canada')">
 		<hr>

Modified: branches/1.0/dijit/trunk/tests/form/test_Spinner.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_Spinner.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_Spinner.html	Sun Nov 11 19:05:43 2007
@@ -50,14 +50,15 @@
 	<form id="form1" action="" name="example" method="post">
 		<h1>number spinner</h1>
 		<br>
-		initial value=900, no delta specified, no min specified, max=1550, onChange debug message<br>
+		initial value=900, no delta specified, no min specified, max=1550, onChange captured<br>
 		<label for="integerspinner1">Spinbox #1: </label><br>
 		<input dojoType="dijit.form.NumberSpinner"
-			onChange="console.debug('onChange fired for widget id = ' + this.id + ' with value = ' + arguments[0]);"
+			onChange="dojo.byId('oc1').value=arguments[0]"
 			value="900"
 			constraints="{max:1550,places:0}"
 			name="integerspinner1"
 			id="integerspinner1">
+		onChange:<input id="oc1" disabled value="not fired yet!" autocomplete="off">
 		<br>
 		<br>
 		initial value=1000, delta=10, min=9 max=1550<br>

Modified: branches/1.0/dijit/trunk/tests/form/test_Textarea.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_Textarea.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_Textarea.html	Sun Nov 11 19:05:43 2007
@@ -37,8 +37,10 @@
 				w.setValue('we will create this one programatically');
 			});
 		</script>
-		<div name="simpleTextArea" dojoType="dijit.form.Textarea" style="width:33%;border:20px solid red;"
+		<br>Inline:<div name="simpleTextArea" dojoType="dijit.form.Textarea" style="width:33%;border:20px solid red;"
+         		onChange="dojo.byId('ocSimple').value=arguments[0]"
 			>this is a very simple resizable text area</div>
+		onChange:<textarea id="ocSimple" disabled>not fired yet!</textarea>
 		<textarea dojoType="dijit.form.Textarea" name="largeTextArea">
 this is a textarea with a LOT of content
 

Modified: branches/1.0/dijit/trunk/tests/form/test_TimeTextBox.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_TimeTextBox.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_TimeTextBox.html	Sun Nov 11 19:05:43 2007
@@ -56,31 +56,33 @@
 	</head>
 
 	<body>
-		<h1 class="testTitle">Dijit Validation Widgets</h1>
+		<h1 class="testTitle">Test TimeTextBox Widget</h1>
 		<!--	to test form submission, you'll need to create an action handler similar to
 			http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
 		<form id="form1" action="" name="example" method="post">
 
 	<div class="dojoTitlePaneLabel">
-		<label for="q16">Time using local conventions with seconds</label>
+		<label for="q1">Time using local conventions with seconds</label>
 		<span class="noticeMessage">TimeTextBox class,
 			Attributes: {formatLength:'medium'}</span>
 	</div>
 	<div class="testExample">
-		<input id="q16" type="text" name="time1" class="medium" value="T17:45:00"
+		<input id="q1" type="text" name="time1" class="medium" value="T17:45:00"
 			dojoType="dijit.form.TimeTextBox"
 			constraints="{formatLength:'medium'}"
 			required="true"
+			onChange="dojo.byId('oc1').value=arguments[0]"
 			invalidMessage="Invalid time." />
+		onChange:<input id="oc1" size="34" disabled value="not fired yet!" autocomplete="off">
 	</div>
 
 	<div class="dojoTitlePaneLabel">
-		<label for="q16a">Time using local conventions without seconds, required, no invalid message tooltip</label>
+		<label for="q2">Time using local conventions without seconds, required, no invalid message tooltip</label>
 		<span class="noticeMessage">TimeTextBox class,
 			Attributes: {formatLength:'short'}</span>
 	</div>
 	<div class="testExample">
-		<input id="q16a" type="text" name="time1a" class="medium" value="T17:45:00"
+		<input id="q2" type="text" name="time1a" class="medium" value="T17:45:00"
 			dojoType="dijit.form.TimeTextBox"
 			constraints="{formatLength:'short'}"
 			required="true"
@@ -88,12 +90,12 @@
 	</div>
 
 	<div class="dojoTitlePaneLabel">
-		<label for="q16b"> 12 Hour Time </label>
+		<label for="q3"> 12 Hour Time </label>
 		<span class="noticeMessage">TimeTextBox class,
 			Attributes: {timePattern:'h:mm:ss a'}</span>
 	</div>
 	<div class="testExample">
-		<input id="q16b" type="text" name="time1b" class="medium" value="T17:45:00"
+		<input id="q3" type="text" name="time1b" class="medium" value="T17:45:00"
 			dojoType="dijit.form.TimeTextBox"
 			constraints="{timePattern:'h:mm:ss a'}"
 			required="true"
@@ -101,22 +103,35 @@
 	</div>
 
 	<div class="dojoTitlePaneLabel">
-		<label for="q17"> 24 Hour Time</label>
+		<label for="q4"> 24 Hour Time</label>
 		<span class="noticeMessage">TimeTextBox class,
 			Attributes: {timePattern:'HH:mm:ss'}</span>
 	</div>
 	<div class="testExample">
-		<input id="q17" type="text" name="time2" class="medium" value="T17:45:00"
+		<input id="q4" type="text" name="time2" class="medium" value="T17:45:00"
 			dojoType="dijit.form.TimeTextBox"
 			constraints="{timePattern:'HH:mm:ss'}"
 			required="true"
 			invalidMessage="Invalid time. Use HH:mm:ss where HH is 00 - 23 hours.">
-			</div>
+	</div>
+
+	<script>
+	        function displayData() {
+	                var f = document.getElementById("form1");
+	                var s = "";
+	                for (var i = 0; i < f.elements.length; i++) {
+	                        var elem = f.elements[i];
+	                        if (elem.name == "button")  { continue; }
+	                        s += elem.name + ": " + elem.value + "\n";
+	                }
+	                alert(s);
+	        }
+	</script>
 
-			<div>
+		<div>
 			<button name="button" onclick="displayData(); return false;">view data</button>
 			<input type="submit" name="submit" />
-			</div>
+		</div>
 
 		</form>
 	</body>

Modified: branches/1.0/dijit/trunk/tests/form/test_validate.html
==============================================================================
--- branches/1.0/dijit/trunk/tests/form/test_validate.html	(original)
+++ branches/1.0/dijit/trunk/tests/form/test_validate.html	Sun Nov 11 19:05:43 2007
@@ -67,7 +67,9 @@
 				<input id="q01" type="text" name="firstname" value="testing testing" style="width: 700px;" tabIndex=2
 					dojoType="dijit.form.TextBox"
 					trim="true"
+				        onChange="dojo.byId('oc1').value=arguments[0]"
 					propercase="true" />
+				<br>onChange:<input id="oc1" size="34" disabled value="not fired yet!" autocomplete="off">
 			</div>
 
 			<div class="dojoTitlePaneLabel">
@@ -116,6 +118,7 @@
 			</div>
 			<div class="testExample">
 				<input id="q05" class="small"/>
+				onChange:<input id="oc5" size="10" disabled value="not fired yet!" autocomplete="off">
 			</div>
 <script>
 	// See if we can make a widget in script and attach it to the DOM ourselves.
@@ -127,6 +130,7 @@
 			promptMessage: "Enter a value between -20000 and +20000",
 			required: "true" ,
 			invalidMessage: "Invalid elevation.",
+			onChange: function(){dojo.byId('oc5').value=arguments[0]},
 			"class": "medium"
 		};
 		var w = new dijit.form.NumberTextBox(props, "q05");
@@ -199,7 +203,9 @@
 					required="true"
 					constraints="{fractional:true}"
 					currency="USD"
+				        onChange="dojo.byId('oc8').value=arguments[0]"
 					invalidMessage="Invalid amount.  Include dollar sign, commas, and cents.  Cents are mandatory." />USD
+				&nbsp;onChange:<input id="oc8" size="15" disabled value="not fired yet!" autocomplete="off">
 			</div>
 		
 			<div class="testExample">


More information about the Dojo-checkins mailing list