Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1372 Rev 1422
1
/*
1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
3
	All Rights Reserved.
4
 
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
9
*/
-
 
10
 
-
 
11
 
10
 
12
 
11
dojo.provide("dojo.widget.Spinner");
13
dojo.provide("dojo.widget.Spinner");
12
dojo.require("dojo.io.*");
14
dojo.require("dojo.io.*");
13
dojo.require("dojo.lfx.*");
15
dojo.require("dojo.lfx.*");
14
dojo.require("dojo.html.*");
16
dojo.require("dojo.html.*");
15
dojo.require("dojo.html.layout");
17
dojo.require("dojo.html.layout");
16
dojo.require("dojo.string");
18
dojo.require("dojo.string");
17
dojo.require("dojo.widget.*");
19
dojo.require("dojo.widget.*");
18
dojo.require("dojo.widget.IntegerTextbox");
20
dojo.require("dojo.widget.IntegerTextbox");
19
dojo.require("dojo.widget.RealNumberTextbox");
21
dojo.require("dojo.widget.RealNumberTextbox");
20
dojo.require("dojo.widget.DateTextbox");
22
dojo.require("dojo.widget.DateTextbox");
21
dojo.require("dojo.experimental");
23
dojo.require("dojo.experimental");
22
dojo.declare("dojo.widget.Spinner", null, {_typamaticTimer:null, _typamaticFunction:null, _currentTimeout:this.defaultTimeout, _eventCount:0, defaultTimeout:500, timeoutChangeRate:0.9, templateString:"<span _=\"weird end tag formatting is to prevent whitespace from becoming &nbsp;\"\n\tstyle='float:${this.htmlfloat};'\n\t><table cellpadding=0 cellspacing=0 class=\"dojoSpinner\">\n\t\t<tr>\n\t\t\t<td\n\t\t\t\t><input\n\t\t\t\t\tdojoAttachPoint='textbox' type='${this.type}'\n\t\t\t\t\tdojoAttachEvent='onblur;onfocus;onkey:_handleKeyEvents;onKeyUp:_onSpinnerKeyUp;onresize:_resize'\n\t\t\t\t\tid='${this.widgetId}' name='${this.name}' size='${this.size}' maxlength='${this.maxlength}'\n\t\t\t\t\tvalue='${this.value}' class='${this.className}' autocomplete=\"off\"\n\t\t\t></td>\n\t\t\t<td\n\t\t\t\t><img dojoAttachPoint=\"upArrowNode\"\n\t\t\t\t\tdojoAttachEvent=\"onDblClick: _upArrowDoubleClicked;  onMouseDown: _upArrowPressed; onMouseUp: _arrowReleased; onMouseOut: _arrowReleased; onMouseMove: _discardEvent;\"\n\t\t\t\t\tsrc=\"${this.incrementSrc}\" style=\"width: ${this.buttonSize.width}px; height: ${this.buttonSize.height}px;\"\n\t\t\t\t><img dojoAttachPoint=\"downArrowNode\"\n\t\t\t\t\tdojoAttachEvent=\"onDblClick: _downArrowDoubleClicked;  onMouseDown: _downArrowPressed; onMouseUp: _arrowReleased; onMouseOut: _arrowReleased; onMouseMove: _discardEvent;\"\n\t\t\t\t\tsrc=\"${this.decrementSrc}\" style=\"width: ${this.buttonSize.width}px; height: ${this.buttonSize.height}px;\"\n\t\t\t></td>\n\t\t</tr>\n\t</table\n\t><span dojoAttachPoint='invalidSpan' class='${this.invalidClass}'>${this.messages.invalidMessage}</span\n\t><span dojoAttachPoint='missingSpan' class='${this.missingClass}'>${this.messages.missingMessage}</span\n\t><span dojoAttachPoint='rangeSpan' class='${this.rangeClass}'>${this.messages.rangeMessage}</span\n></span>\n", templateCssString:"/* inline the table holding the <input> and buttons (method varies by browser) */\n.ie .dojoSpinner, .safari .dojoSpinner {\n\tdisplay: inline;\n}\n\n.moz .dojoSpinner {\n\tdisplay: -moz-inline-box;\n}\n\n.opera .dojoSpinner {\n\tdisplay: inline-table;\n}\n\n/* generic stuff for the table */\n.dojoSpinner td {\n\tpadding:0px;\n\tmargin:0px;\n\tvertical-align: middle;\n}\ntable.dojoSpinner {\n\tborder:0px;\n\tborder-spacing:0px;\n\tline-height:0px;\n\tpadding:0px;\n\tmargin: 0px;\n\tvertical-align: middle;\n}\n\n/* the buttons */\n.dojoSpinner img {\n\tdisplay: block;\n\tborder-width:0px 1px 1px 0px;\n\tborder-style:outset;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/Spinner.css"), incrementSrc:dojo.uri.moduleUri("dojo.widget", "templates/images/spinnerIncrement.gif"), decrementSrc:dojo.uri.moduleUri("dojo.widget", "templates/images/spinnerDecrement.gif"), _handleKeyEvents:function (evt) {
24
dojo.declare("dojo.widget.Spinner", null, {_typamaticTimer:null, _typamaticFunction:null, _currentTimeout:this.defaultTimeout, _eventCount:0, defaultTimeout:500, timeoutChangeRate:0.9, templateString:"<span _=\"weird end tag formatting is to prevent whitespace from becoming &nbsp;\"\n\tstyle='float:${this.htmlfloat};'\n\t><table cellpadding=0 cellspacing=0 class=\"dojoSpinner\">\n\t\t<tr>\n\t\t\t<td\n\t\t\t\t><input\n\t\t\t\t\tdojoAttachPoint='textbox' type='${this.type}'\n\t\t\t\t\tdojoAttachEvent='onblur;onfocus;onkey:_handleKeyEvents;onKeyUp:_onSpinnerKeyUp;onresize:_resize'\n\t\t\t\t\tid='${this.widgetId}' name='${this.name}' size='${this.size}' maxlength='${this.maxlength}'\n\t\t\t\t\tvalue='${this.value}' class='${this.className}' autocomplete=\"off\"\n\t\t\t></td>\n\t\t\t<td\n\t\t\t\t><img dojoAttachPoint=\"upArrowNode\"\n\t\t\t\t\tdojoAttachEvent=\"onDblClick: _upArrowDoubleClicked;  onMouseDown: _upArrowPressed; onMouseUp: _arrowReleased; onMouseOut: _arrowReleased; onMouseMove: _discardEvent;\"\n\t\t\t\t\tsrc=\"${this.incrementSrc}\" style=\"width: ${this.buttonSize.width}px; height: ${this.buttonSize.height}px;\"\n\t\t\t\t><img dojoAttachPoint=\"downArrowNode\"\n\t\t\t\t\tdojoAttachEvent=\"onDblClick: _downArrowDoubleClicked;  onMouseDown: _downArrowPressed; onMouseUp: _arrowReleased; onMouseOut: _arrowReleased; onMouseMove: _discardEvent;\"\n\t\t\t\t\tsrc=\"${this.decrementSrc}\" style=\"width: ${this.buttonSize.width}px; height: ${this.buttonSize.height}px;\"\n\t\t\t></td>\n\t\t</tr>\n\t</table\n\t><span dojoAttachPoint='invalidSpan' class='${this.invalidClass}'>${this.messages.invalidMessage}</span\n\t><span dojoAttachPoint='missingSpan' class='${this.missingClass}'>${this.messages.missingMessage}</span\n\t><span dojoAttachPoint='rangeSpan' class='${this.rangeClass}'>${this.messages.rangeMessage}</span\n></span>\n", templateCssString:"/* inline the table holding the <input> and buttons (method varies by browser) */\n.ie .dojoSpinner, .safari .dojoSpinner {\n\tdisplay: inline;\n}\n\n.moz .dojoSpinner {\n\tdisplay: -moz-inline-box;\n}\n\n.opera .dojoSpinner {\n\tdisplay: inline-table;\n}\n\n/* generic stuff for the table */\n.dojoSpinner td {\n\tpadding:0px;\n\tmargin:0px;\n\tvertical-align: middle;\n}\ntable.dojoSpinner {\n\tborder:0px;\n\tborder-spacing:0px;\n\tline-height:0px;\n\tpadding:0px;\n\tmargin: 0px;\n\tvertical-align: middle;\n}\n\n/* the buttons */\n.dojoSpinner img {\n\tdisplay: block;\n\tborder-width:0px 1px 1px 0px;\n\tborder-style:outset;\n}\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/Spinner.css"), incrementSrc:dojo.uri.moduleUri("dojo.widget", "templates/images/spinnerIncrement.gif"), decrementSrc:dojo.uri.moduleUri("dojo.widget", "templates/images/spinnerDecrement.gif"), _handleKeyEvents:function (evt) {
23
	if (!evt.key) {
25
	if (!evt.key) {
24
		return;
26
		return;
25
	}
27
	}
26
	if (!evt.ctrlKey && !evt.altKey) {
28
	if (!evt.ctrlKey && !evt.altKey) {
27
		switch (evt.key) {
29
		switch (evt.key) {
28
		  case evt.KEY_DOWN_ARROW:
30
		  case evt.KEY_DOWN_ARROW:
29
			dojo.event.browser.stopEvent(evt);
31
			dojo.event.browser.stopEvent(evt);
30
			this._downArrowPressed(evt);
32
			this._downArrowPressed(evt);
31
			return;
33
			return;
32
		  case evt.KEY_UP_ARROW:
34
		  case evt.KEY_UP_ARROW:
33
			dojo.event.browser.stopEvent(evt);
35
			dojo.event.browser.stopEvent(evt);
34
			this._upArrowPressed(evt);
36
			this._upArrowPressed(evt);
35
			return;
37
			return;
36
		}
38
		}
37
	}
39
	}
38
	this._eventCount++;
40
	this._eventCount++;
39
}, _onSpinnerKeyUp:function (evt) {
41
}, _onSpinnerKeyUp:function (evt) {
40
	this._arrowReleased(evt);
42
	this._arrowReleased(evt);
41
	this.onkeyup(evt);
43
	this.onkeyup(evt);
42
}, _resize:function () {
44
}, _resize:function () {
43
	var inputSize = dojo.html.getBorderBox(this.textbox);
45
	var inputSize = dojo.html.getBorderBox(this.textbox);
44
	this.buttonSize = {width:inputSize.height / 2, height:inputSize.height / 2};
46
	this.buttonSize = {width:inputSize.height / 2, height:inputSize.height / 2};
45
	if (this.upArrowNode) {
47
	if (this.upArrowNode) {
46
		dojo.html.setMarginBox(this.upArrowNode, this.buttonSize);
48
		dojo.html.setMarginBox(this.upArrowNode, this.buttonSize);
47
		dojo.html.setMarginBox(this.downArrowNode, this.buttonSize);
49
		dojo.html.setMarginBox(this.downArrowNode, this.buttonSize);
48
	}
50
	}
49
}, _pressButton:function (node) {
51
}, _pressButton:function (node) {
50
	node.style.borderWidth = "1px 0px 0px 1px";
52
	node.style.borderWidth = "1px 0px 0px 1px";
51
	node.style.borderStyle = "inset";
53
	node.style.borderStyle = "inset";
52
}, _releaseButton:function (node) {
54
}, _releaseButton:function (node) {
53
	node.style.borderWidth = "0px 1px 1px 0px";
55
	node.style.borderWidth = "0px 1px 1px 0px";
54
	node.style.borderStyle = "outset";
56
	node.style.borderStyle = "outset";
55
}, _arrowPressed:function (evt, direction) {
57
}, _arrowPressed:function (evt, direction) {
56
	var nodePressed = (direction == -1) ? this.downArrowNode : this.upArrowNode;
58
	var nodePressed = (direction == -1) ? this.downArrowNode : this.upArrowNode;
57
	var nodeReleased = (direction == +1) ? this.downArrowNode : this.upArrowNode;
59
	var nodeReleased = (direction == +1) ? this.downArrowNode : this.upArrowNode;
58
	if (typeof evt != "number") {
60
	if (typeof evt != "number") {
59
		if (this._typamaticTimer != null) {
61
		if (this._typamaticTimer != null) {
60
			if (this._typamaticNode == nodePressed) {
62
			if (this._typamaticNode == nodePressed) {
61
				return;
63
				return;
62
			}
64
			}
63
			dojo.lang.clearTimeout(this._typamaticTimer);
65
			dojo.lang.clearTimeout(this._typamaticTimer);
64
		}
66
		}
65
		this._releaseButton(nodeReleased);
67
		this._releaseButton(nodeReleased);
66
		this._eventCount++;
68
		this._eventCount++;
67
		this._typamaticTimer = null;
69
		this._typamaticTimer = null;
68
		this._currentTimeout = this.defaultTimeout;
70
		this._currentTimeout = this.defaultTimeout;
69
	} else {
71
	} else {
70
		if (evt != this._eventCount) {
72
		if (evt != this._eventCount) {
71
			this._releaseButton(nodePressed);
73
			this._releaseButton(nodePressed);
72
			return;
74
			return;
73
		}
75
		}
74
	}
76
	}
75
	this._pressButton(nodePressed);
77
	this._pressButton(nodePressed);
76
	this._setCursorX(this.adjustValue(direction, this._getCursorX()));
78
	this._setCursorX(this.adjustValue(direction, this._getCursorX()));
77
	this._typamaticNode = nodePressed;
79
	this._typamaticNode = nodePressed;
78
	this._typamaticTimer = dojo.lang.setTimeout(this, "_arrowPressed", this._currentTimeout, this._eventCount, direction);
80
	this._typamaticTimer = dojo.lang.setTimeout(this, "_arrowPressed", this._currentTimeout, this._eventCount, direction);
79
	this._currentTimeout = Math.round(this._currentTimeout * this.timeoutChangeRate);
81
	this._currentTimeout = Math.round(this._currentTimeout * this.timeoutChangeRate);
80
}, _downArrowPressed:function (evt) {
82
}, _downArrowPressed:function (evt) {
81
	return this._arrowPressed(evt, -1);
83
	return this._arrowPressed(evt, -1);
82
}, _downArrowDoubleClicked:function (evt) {
84
}, _downArrowDoubleClicked:function (evt) {
83
	var rc = this._downArrowPressed(evt);
85
	var rc = this._downArrowPressed(evt);
84
	dojo.lang.setTimeout(this, "_arrowReleased", 50, null);
86
	dojo.lang.setTimeout(this, "_arrowReleased", 50, null);
85
	return rc;
87
	return rc;
86
}, _upArrowPressed:function (evt) {
88
}, _upArrowPressed:function (evt) {
87
	return this._arrowPressed(evt, +1);
89
	return this._arrowPressed(evt, +1);
88
}, _upArrowDoubleClicked:function (evt) {
90
}, _upArrowDoubleClicked:function (evt) {
89
	var rc = this._upArrowPressed(evt);
91
	var rc = this._upArrowPressed(evt);
90
	dojo.lang.setTimeout(this, "_arrowReleased", 50, null);
92
	dojo.lang.setTimeout(this, "_arrowReleased", 50, null);
91
	return rc;
93
	return rc;
92
}, _arrowReleased:function (evt) {
94
}, _arrowReleased:function (evt) {
93
	this.textbox.focus();
95
	this.textbox.focus();
94
	if (evt != null && typeof evt == "object" && evt.keyCode && evt.keyCode != null) {
96
	if (evt != null && typeof evt == "object" && evt.keyCode && evt.keyCode != null) {
95
		var keyCode = evt.keyCode;
97
		var keyCode = evt.keyCode;
96
		var k = dojo.event.browser.keys;
98
		var k = dojo.event.browser.keys;
97
		switch (keyCode) {
99
		switch (keyCode) {
98
		  case k.KEY_DOWN_ARROW:
100
		  case k.KEY_DOWN_ARROW:
99
		  case k.KEY_UP_ARROW:
101
		  case k.KEY_UP_ARROW:
100
			dojo.event.browser.stopEvent(evt);
102
			dojo.event.browser.stopEvent(evt);
101
			break;
103
			break;
102
		}
104
		}
103
	}
105
	}
104
	this._releaseButton(this.upArrowNode);
106
	this._releaseButton(this.upArrowNode);
105
	this._releaseButton(this.downArrowNode);
107
	this._releaseButton(this.downArrowNode);
106
	this._eventCount++;
108
	this._eventCount++;
107
	if (this._typamaticTimer != null) {
109
	if (this._typamaticTimer != null) {
108
		dojo.lang.clearTimeout(this._typamaticTimer);
110
		dojo.lang.clearTimeout(this._typamaticTimer);
109
	}
111
	}
110
	this._typamaticTimer = null;
112
	this._typamaticTimer = null;
111
	this._currentTimeout = this.defaultTimeout;
113
	this._currentTimeout = this.defaultTimeout;
112
}, _mouseWheeled:function (evt) {
114
}, _mouseWheeled:function (evt) {
113
	var scrollAmount = 0;
115
	var scrollAmount = 0;
114
	if (typeof evt.wheelDelta == "number") {
116
	if (typeof evt.wheelDelta == "number") {
115
		scrollAmount = evt.wheelDelta;
117
		scrollAmount = evt.wheelDelta;
116
	} else {
118
	} else {
117
		if (typeof evt.detail == "number") {
119
		if (typeof evt.detail == "number") {
118
			scrollAmount = -evt.detail;
120
			scrollAmount = -evt.detail;
119
		}
121
		}
120
	}
122
	}
121
	if (scrollAmount > 0) {
123
	if (scrollAmount > 0) {
122
		this._upArrowPressed(evt);
124
		this._upArrowPressed(evt);
123
		this._arrowReleased(evt);
125
		this._arrowReleased(evt);
124
	} else {
126
	} else {
125
		if (scrollAmount < 0) {
127
		if (scrollAmount < 0) {
126
			this._downArrowPressed(evt);
128
			this._downArrowPressed(evt);
127
			this._arrowReleased(evt);
129
			this._arrowReleased(evt);
128
		}
130
		}
129
	}
131
	}
130
}, _discardEvent:function (evt) {
132
}, _discardEvent:function (evt) {
131
	dojo.event.browser.stopEvent(evt);
133
	dojo.event.browser.stopEvent(evt);
132
}, _getCursorX:function () {
134
}, _getCursorX:function () {
133
	var x = -1;
135
	var x = -1;
134
	try {
136
	try {
135
		this.textbox.focus();
137
		this.textbox.focus();
136
		if (typeof this.textbox.selectionEnd == "number") {
138
		if (typeof this.textbox.selectionEnd == "number") {
137
			x = this.textbox.selectionEnd;
139
			x = this.textbox.selectionEnd;
138
		} else {
140
		} else {
139
			if (document.selection && document.selection.createRange) {
141
			if (document.selection && document.selection.createRange) {
140
				var range = document.selection.createRange().duplicate();
142
				var range = document.selection.createRange().duplicate();
141
				if (range.parentElement() == this.textbox) {
143
				if (range.parentElement() == this.textbox) {
142
					range.moveStart("textedit", -1);
144
					range.moveStart("textedit", -1);
143
					x = range.text.length;
145
					x = range.text.length;
144
				}
146
				}
145
			}
147
			}
146
		}
148
		}
147
	}
149
	}
148
	catch (e) {
150
	catch (e) {
149
	}
151
	}
150
	return x;
152
	return x;
151
}, _setCursorX:function (x) {
153
}, _setCursorX:function (x) {
152
	try {
154
	try {
153
		this.textbox.focus();
155
		this.textbox.focus();
154
		if (!x) {
156
		if (!x) {
155
			x = 0;
157
			x = 0;
156
		}
158
		}
157
		if (typeof this.textbox.selectionEnd == "number") {
159
		if (typeof this.textbox.selectionEnd == "number") {
158
			this.textbox.selectionEnd = x;
160
			this.textbox.selectionEnd = x;
159
		} else {
161
		} else {
160
			if (this.textbox.createTextRange) {
162
			if (this.textbox.createTextRange) {
161
				var range = this.textbox.createTextRange();
163
				var range = this.textbox.createTextRange();
162
				range.collapse(true);
164
				range.collapse(true);
163
				range.moveEnd("character", x);
165
				range.moveEnd("character", x);
164
				range.moveStart("character", x);
166
				range.moveStart("character", x);
165
				range.select();
167
				range.select();
166
			}
168
			}
167
		}
169
		}
168
	}
170
	}
169
	catch (e) {
171
	catch (e) {
170
	}
172
	}
171
}, _spinnerPostMixInProperties:function (args, frag) {
173
}, _spinnerPostMixInProperties:function (args, frag) {
172
	var inputNode = this.getFragNodeRef(frag);
174
	var inputNode = this.getFragNodeRef(frag);
173
	var inputSize = dojo.html.getBorderBox(inputNode);
175
	var inputSize = dojo.html.getBorderBox(inputNode);
174
	this.buttonSize = {width:inputSize.height / 2 - 1, height:inputSize.height / 2 - 1};
176
	this.buttonSize = {width:inputSize.height / 2 - 1, height:inputSize.height / 2 - 1};
175
}, _spinnerPostCreate:function (args, frag) {
177
}, _spinnerPostCreate:function (args, frag) {
176
	if (this.textbox.addEventListener) {
178
	if (this.textbox.addEventListener) {
177
		this.textbox.addEventListener("DOMMouseScroll", dojo.lang.hitch(this, "_mouseWheeled"), false);
179
		this.textbox.addEventListener("DOMMouseScroll", dojo.lang.hitch(this, "_mouseWheeled"), false);
178
	} else {
180
	} else {
179
		dojo.event.connect(this.textbox, "onmousewheel", this, "_mouseWheeled");
181
		dojo.event.connect(this.textbox, "onmousewheel", this, "_mouseWheeled");
180
	}
182
	}
181
}});
183
}});
182
dojo.widget.defineWidget("dojo.widget.IntegerSpinner", [dojo.widget.IntegerTextbox, dojo.widget.Spinner], {delta:"1", postMixInProperties:function (args, frag) {
184
dojo.widget.defineWidget("dojo.widget.IntegerSpinner", [dojo.widget.IntegerTextbox, dojo.widget.Spinner], {delta:"1", postMixInProperties:function (args, frag) {
183
	dojo.widget.IntegerSpinner.superclass.postMixInProperties.apply(this, arguments);
185
	dojo.widget.IntegerSpinner.superclass.postMixInProperties.apply(this, arguments);
184
	this._spinnerPostMixInProperties(args, frag);
186
	this._spinnerPostMixInProperties(args, frag);
185
}, postCreate:function (args, frag) {
187
}, postCreate:function (args, frag) {
186
	dojo.widget.IntegerSpinner.superclass.postCreate.apply(this, arguments);
188
	dojo.widget.IntegerSpinner.superclass.postCreate.apply(this, arguments);
187
	this._spinnerPostCreate(args, frag);
189
	this._spinnerPostCreate(args, frag);
188
}, adjustValue:function (direction, x) {
190
}, adjustValue:function (direction, x) {
189
	var val = this.getValue().replace(/[^\-+\d]/g, "");
191
	var val = this.getValue().replace(/[^\-+\d]/g, "");
190
	if (val.length == 0) {
192
	if (val.length == 0) {
191
		return;
193
		return;
192
	}
194
	}
193
	var num = Math.min(Math.max((parseInt(val) + (parseInt(this.delta) * direction)), (this.flags.min ? this.flags.min : -Infinity)), (this.flags.max ? this.flags.max : +Infinity));
195
	var num = Math.min(Math.max((parseInt(val) + (parseInt(this.delta) * direction)), (this.flags.min ? this.flags.min : -Infinity)), (this.flags.max ? this.flags.max : +Infinity));
194
	val = num.toString();
196
	val = num.toString();
195
	if (num >= 0) {
197
	if (num >= 0) {
196
		val = ((this.flags.signed == true) ? "+" : " ") + val;
198
		val = ((this.flags.signed == true) ? "+" : " ") + val;
197
	}
199
	}
198
	if (this.flags.separator.length > 0) {
200
	if (this.flags.separator.length > 0) {
199
		for (var i = val.length - 3; i > 1; i -= 3) {
201
		for (var i = val.length - 3; i > 1; i -= 3) {
200
			val = val.substr(0, i) + this.flags.separator + val.substr(i);
202
			val = val.substr(0, i) + this.flags.separator + val.substr(i);
201
		}
203
		}
202
	}
204
	}
203
	if (val.substr(0, 1) == " ") {
205
	if (val.substr(0, 1) == " ") {
204
		val = val.substr(1);
206
		val = val.substr(1);
205
	}
207
	}
206
	this.setValue(val);
208
	this.setValue(val);
207
	return val.length;
209
	return val.length;
208
}});
210
}});
209
dojo.widget.defineWidget("dojo.widget.RealNumberSpinner", [dojo.widget.RealNumberTextbox, dojo.widget.Spinner], function () {
211
dojo.widget.defineWidget("dojo.widget.RealNumberSpinner", [dojo.widget.RealNumberTextbox, dojo.widget.Spinner], function () {
210
	dojo.experimental("dojo.widget.RealNumberSpinner");
212
	dojo.experimental("dojo.widget.RealNumberSpinner");
211
}, {delta:"1e1", postMixInProperties:function (args, frag) {
213
}, {delta:"1e1", postMixInProperties:function (args, frag) {
212
	dojo.widget.RealNumberSpinner.superclass.postMixInProperties.apply(this, arguments);
214
	dojo.widget.RealNumberSpinner.superclass.postMixInProperties.apply(this, arguments);
213
	this._spinnerPostMixInProperties(args, frag);
215
	this._spinnerPostMixInProperties(args, frag);
214
}, postCreate:function (args, frag) {
216
}, postCreate:function (args, frag) {
215
	dojo.widget.RealNumberSpinner.superclass.postCreate.apply(this, arguments);
217
	dojo.widget.RealNumberSpinner.superclass.postCreate.apply(this, arguments);
216
	this._spinnerPostCreate(args, frag);
218
	this._spinnerPostCreate(args, frag);
217
}, adjustValue:function (direction, x) {
219
}, adjustValue:function (direction, x) {
218
	var val = this.getValue().replace(/[^\-+\.eE\d]/g, "");
220
	var val = this.getValue().replace(/[^\-+\.eE\d]/g, "");
219
	if (!val.length) {
221
	if (!val.length) {
220
		return;
222
		return;
221
	}
223
	}
222
	var num = parseFloat(val);
224
	var num = parseFloat(val);
223
	if (isNaN(num)) {
225
	if (isNaN(num)) {
224
		return;
226
		return;
225
	}
227
	}
226
	var delta = this.delta.split(/[eE]/);
228
	var delta = this.delta.split(/[eE]/);
227
	if (!delta.length) {
229
	if (!delta.length) {
228
		delta = [1, 1];
230
		delta = [1, 1];
229
	} else {
231
	} else {
230
		delta[0] = parseFloat(delta[0].replace(/[^\-+\.\d]/g, ""));
232
		delta[0] = parseFloat(delta[0].replace(/[^\-+\.\d]/g, ""));
231
		if (isNaN(delta[0])) {
233
		if (isNaN(delta[0])) {
232
			delta[0] = 1;
234
			delta[0] = 1;
233
		}
235
		}
234
		if (delta.length > 1) {
236
		if (delta.length > 1) {
235
			delta[1] = parseInt(delta[1]);
237
			delta[1] = parseInt(delta[1]);
236
		}
238
		}
237
		if (isNaN(delta[1])) {
239
		if (isNaN(delta[1])) {
238
			delta[1] = 1;
240
			delta[1] = 1;
239
		}
241
		}
240
	}
242
	}
241
	val = this.getValue().split(/[eE]/);
243
	val = this.getValue().split(/[eE]/);
242
	if (!val.length) {
244
	if (!val.length) {
243
		return;
245
		return;
244
	}
246
	}
245
	var numBase = parseFloat(val[0].replace(/[^\-+\.\d]/g, ""));
247
	var numBase = parseFloat(val[0].replace(/[^\-+\.\d]/g, ""));
246
	if (val.length == 1) {
248
	if (val.length == 1) {
247
		var numExp = 0;
249
		var numExp = 0;
248
	} else {
250
	} else {
249
		var numExp = parseInt(val[1].replace(/[^\-+\d]/g, ""));
251
		var numExp = parseInt(val[1].replace(/[^\-+\d]/g, ""));
250
	}
252
	}
251
	if (x <= val[0].length) {
253
	if (x <= val[0].length) {
252
		x = 0;
254
		x = 0;
253
		numBase += delta[0] * direction;
255
		numBase += delta[0] * direction;
254
	} else {
256
	} else {
255
		x = Number.MAX_VALUE;
257
		x = Number.MAX_VALUE;
256
		numExp += delta[1] * direction;
258
		numExp += delta[1] * direction;
257
		if (this.flags.eSigned == false && numExp < 0) {
259
		if (this.flags.eSigned == false && numExp < 0) {
258
			numExp = 0;
260
			numExp = 0;
259
		}
261
		}
260
	}
262
	}
261
	num = Math.min(Math.max((numBase * Math.pow(10, numExp)), (this.flags.min ? this.flags.min : -Infinity)), (this.flags.max ? this.flags.max : +Infinity));
263
	num = Math.min(Math.max((numBase * Math.pow(10, numExp)), (this.flags.min ? this.flags.min : -Infinity)), (this.flags.max ? this.flags.max : +Infinity));
262
	if ((this.flags.exponent == true || (this.flags.exponent != false && x != 0)) && num.toExponential) {
264
	if ((this.flags.exponent == true || (this.flags.exponent != false && x != 0)) && num.toExponential) {
263
		if (isNaN(this.flags.places) || this.flags.places == Infinity) {
265
		if (isNaN(this.flags.places) || this.flags.places == Infinity) {
264
			val = num.toExponential();
266
			val = num.toExponential();
265
		} else {
267
		} else {
266
			val = num.toExponential(this.flags.places);
268
			val = num.toExponential(this.flags.places);
267
		}
269
		}
268
	} else {
270
	} else {
269
		if (num.toFixed && num.toPrecision) {
271
		if (num.toFixed && num.toPrecision) {
270
			if (isNaN(this.flags.places) || this.flags.places == Infinity) {
272
			if (isNaN(this.flags.places) || this.flags.places == Infinity) {
271
				val = num.toPrecision((1 / 3).toString().length - 1);
273
				val = num.toPrecision((1 / 3).toString().length - 1);
272
			} else {
274
			} else {
273
				val = num.toFixed(this.flags.places);
275
				val = num.toFixed(this.flags.places);
274
			}
276
			}
275
		} else {
277
		} else {
276
			val = num.toString();
278
			val = num.toString();
277
		}
279
		}
278
	}
280
	}
279
	if (num >= 0) {
281
	if (num >= 0) {
280
		if (this.flags.signed == true) {
282
		if (this.flags.signed == true) {
281
			val = "+" + val;
283
			val = "+" + val;
282
		}
284
		}
283
	}
285
	}
284
	val = val.split(/[eE]/);
286
	val = val.split(/[eE]/);
285
	if (this.flags.separator.length > 0) {
287
	if (this.flags.separator.length > 0) {
286
		if (num >= 0 && val[0].substr(0, 1) != "+") {
288
		if (num >= 0 && val[0].substr(0, 1) != "+") {
287
			val[0] = " " + val[0];
289
			val[0] = " " + val[0];
288
		}
290
		}
289
		var i = val[0].lastIndexOf(".");
291
		var i = val[0].lastIndexOf(".");
290
		if (i >= 0) {
292
		if (i >= 0) {
291
			i -= 3;
293
			i -= 3;
292
		} else {
294
		} else {
293
			i = val[0].length - 3;
295
			i = val[0].length - 3;
294
		}
296
		}
295
		for (; i > 1; i -= 3) {
297
		for (; i > 1; i -= 3) {
296
			val[0] = val[0].substr(0, i) + this.flags.separator + val[0].substr(i);
298
			val[0] = val[0].substr(0, i) + this.flags.separator + val[0].substr(i);
297
		}
299
		}
298
		if (val[0].substr(0, 1) == " ") {
300
		if (val[0].substr(0, 1) == " ") {
299
			val[0] = val[0].substr(1);
301
			val[0] = val[0].substr(1);
300
		}
302
		}
301
	}
303
	}
302
	if (val.length > 1) {
304
	if (val.length > 1) {
303
		if ((this.flags.eSigned == true) && (val[1].substr(0, 1) != "+")) {
305
		if ((this.flags.eSigned == true) && (val[1].substr(0, 1) != "+")) {
304
			val[1] = "+" + val[1];
306
			val[1] = "+" + val[1];
305
		} else {
307
		} else {
306
			if ((!this.flags.eSigned) && (val[1].substr(0, 1) == "+")) {
308
			if ((!this.flags.eSigned) && (val[1].substr(0, 1) == "+")) {
307
				val[1] = val[1].substr(1);
309
				val[1] = val[1].substr(1);
308
			} else {
310
			} else {
309
				if ((!this.flags.eSigned) && (val[1].substr(0, 1) == "-") && (num.toFixed && num.toPrecision)) {
311
				if ((!this.flags.eSigned) && (val[1].substr(0, 1) == "-") && (num.toFixed && num.toPrecision)) {
310
					if (isNaN(this.flags.places)) {
312
					if (isNaN(this.flags.places)) {
311
						val[0] = num.toPrecision((1 / 3).toString().length - 1);
313
						val[0] = num.toPrecision((1 / 3).toString().length - 1);
312
					} else {
314
					} else {
313
						val[0] = num.toFixed(this.flags.places).toString();
315
						val[0] = num.toFixed(this.flags.places).toString();
314
					}
316
					}
315
					val[1] = "0";
317
					val[1] = "0";
316
				}
318
				}
317
			}
319
			}
318
		}
320
		}
319
		val[0] += "e" + val[1];
321
		val[0] += "e" + val[1];
320
	}
322
	}
321
	this.setValue(val[0]);
323
	this.setValue(val[0]);
322
	if (x > val[0].length) {
324
	if (x > val[0].length) {
323
		x = val[0].length;
325
		x = val[0].length;
324
	}
326
	}
325
	return x;
327
	return x;
326
}});
328
}});
327
dojo.widget.defineWidget("dojo.widget.TimeSpinner", [dojo.widget.TimeTextbox, dojo.widget.Spinner], function () {
329
dojo.widget.defineWidget("dojo.widget.TimeSpinner", [dojo.widget.TimeTextbox, dojo.widget.Spinner], function () {
328
	dojo.experimental("dojo.widget.TimeSpinner");
330
	dojo.experimental("dojo.widget.TimeSpinner");
329
}, {postMixInProperties:function (args, frag) {
331
}, {postMixInProperties:function (args, frag) {
330
	dojo.widget.TimeSpinner.superclass.postMixInProperties.apply(this, arguments);
332
	dojo.widget.TimeSpinner.superclass.postMixInProperties.apply(this, arguments);
331
	this._spinnerPostMixInProperties(args, frag);
333
	this._spinnerPostMixInProperties(args, frag);
332
}, postCreate:function (args, frag) {
334
}, postCreate:function (args, frag) {
333
	dojo.widget.TimeSpinner.superclass.postCreate.apply(this, arguments);
335
	dojo.widget.TimeSpinner.superclass.postCreate.apply(this, arguments);
334
	this._spinnerPostCreate(args, frag);
336
	this._spinnerPostCreate(args, frag);
335
}, adjustValue:function (direction, x) {
337
}, adjustValue:function (direction, x) {
336
	var val = this.getValue();
338
	var val = this.getValue();
337
	var format = (this.flags.format && this.flags.format.search(/[Hhmst]/) >= 0) ? this.flags.format : "hh:mm:ss t";
339
	var format = (this.flags.format && this.flags.format.search(/[Hhmst]/) >= 0) ? this.flags.format : "hh:mm:ss t";
338
	if (direction == 0 || !val.length || !this.isValid()) {
340
	if (direction == 0 || !val.length || !this.isValid()) {
339
		return;
341
		return;
340
	}
342
	}
341
	if (!this.flags.amSymbol) {
343
	if (!this.flags.amSymbol) {
342
		this.flags.amSymbol = "AM";
344
		this.flags.amSymbol = "AM";
343
	}
345
	}
344
	if (!this.flags.pmSymbol) {
346
	if (!this.flags.pmSymbol) {
345
		this.flags.pmSymbol = "PM";
347
		this.flags.pmSymbol = "PM";
346
	}
348
	}
347
	var re = dojo.regexp.time(this.flags);
349
	var re = dojo.regexp.time(this.flags);
348
	var qualifiers = format.replace(/H/g, "h").replace(/[^hmst]/g, "").replace(/([hmst])\1/g, "$1");
350
	var qualifiers = format.replace(/H/g, "h").replace(/[^hmst]/g, "").replace(/([hmst])\1/g, "$1");
349
	var hourPos = qualifiers.indexOf("h") + 1;
351
	var hourPos = qualifiers.indexOf("h") + 1;
350
	var minPos = qualifiers.indexOf("m") + 1;
352
	var minPos = qualifiers.indexOf("m") + 1;
351
	var secPos = qualifiers.indexOf("s") + 1;
353
	var secPos = qualifiers.indexOf("s") + 1;
352
	var ampmPos = qualifiers.indexOf("t") + 1;
354
	var ampmPos = qualifiers.indexOf("t") + 1;
353
	var cursorFormat = format;
355
	var cursorFormat = format;
354
	var ampm = "";
356
	var ampm = "";
355
	if (ampmPos > 0) {
357
	if (ampmPos > 0) {
356
		ampm = val.replace(new RegExp(re), "$" + ampmPos);
358
		ampm = val.replace(new RegExp(re), "$" + ampmPos);
357
		cursorFormat = cursorFormat.replace(/t+/, ampm.replace(/./g, "t"));
359
		cursorFormat = cursorFormat.replace(/t+/, ampm.replace(/./g, "t"));
358
	}
360
	}
359
	var hour = 0;
361
	var hour = 0;
360
	var deltaHour = 1;
362
	var deltaHour = 1;
361
	if (hourPos > 0) {
363
	if (hourPos > 0) {
362
		hour = val.replace(new RegExp(re), "$" + hourPos);
364
		hour = val.replace(new RegExp(re), "$" + hourPos);
363
		if (dojo.lang.isString(this.delta)) {
365
		if (dojo.lang.isString(this.delta)) {
364
			deltaHour = this.delta.replace(new RegExp(re), "$" + hourPos);
366
			deltaHour = this.delta.replace(new RegExp(re), "$" + hourPos);
365
		}
367
		}
366
		if (isNaN(deltaHour)) {
368
		if (isNaN(deltaHour)) {
367
			deltaHour = 1;
369
			deltaHour = 1;
368
		} else {
370
		} else {
369
			deltaHour = parseInt(deltaHour);
371
			deltaHour = parseInt(deltaHour);
370
		}
372
		}
371
		if (hour.length == 2) {
373
		if (hour.length == 2) {
372
			cursorFormat = cursorFormat.replace(/([Hh])+/, "$1$1");
374
			cursorFormat = cursorFormat.replace(/([Hh])+/, "$1$1");
373
		} else {
375
		} else {
374
			cursorFormat = cursorFormat.replace(/([Hh])+/, "$1");
376
			cursorFormat = cursorFormat.replace(/([Hh])+/, "$1");
375
		}
377
		}
376
		if (isNaN(hour)) {
378
		if (isNaN(hour)) {
377
			hour = 0;
379
			hour = 0;
378
		} else {
380
		} else {
379
			hour = parseInt(hour.replace(/^0(\d)/, "$1"));
381
			hour = parseInt(hour.replace(/^0(\d)/, "$1"));
380
		}
382
		}
381
	}
383
	}
382
	var min = 0;
384
	var min = 0;
383
	var deltaMin = 1;
385
	var deltaMin = 1;
384
	if (minPos > 0) {
386
	if (minPos > 0) {
385
		min = val.replace(new RegExp(re), "$" + minPos);
387
		min = val.replace(new RegExp(re), "$" + minPos);
386
		if (dojo.lang.isString(this.delta)) {
388
		if (dojo.lang.isString(this.delta)) {
387
			deltaMin = this.delta.replace(new RegExp(re), "$" + minPos);
389
			deltaMin = this.delta.replace(new RegExp(re), "$" + minPos);
388
		}
390
		}
389
		if (isNaN(deltaMin)) {
391
		if (isNaN(deltaMin)) {
390
			deltaMin = 1;
392
			deltaMin = 1;
391
		} else {
393
		} else {
392
			deltaMin = parseInt(deltaMin);
394
			deltaMin = parseInt(deltaMin);
393
		}
395
		}
394
		cursorFormat = cursorFormat.replace(/m+/, min.replace(/./g, "m"));
396
		cursorFormat = cursorFormat.replace(/m+/, min.replace(/./g, "m"));
395
		if (isNaN(min)) {
397
		if (isNaN(min)) {
396
			min = 0;
398
			min = 0;
397
		} else {
399
		} else {
398
			min = parseInt(min.replace(/^0(\d)/, "$1"));
400
			min = parseInt(min.replace(/^0(\d)/, "$1"));
399
		}
401
		}
400
	}
402
	}
401
	var sec = 0;
403
	var sec = 0;
402
	var deltaSec = 1;
404
	var deltaSec = 1;
403
	if (secPos > 0) {
405
	if (secPos > 0) {
404
		sec = val.replace(new RegExp(re), "$" + secPos);
406
		sec = val.replace(new RegExp(re), "$" + secPos);
405
		if (dojo.lang.isString(this.delta)) {
407
		if (dojo.lang.isString(this.delta)) {
406
			deltaSec = this.delta.replace(new RegExp(re), "$" + secPos);
408
			deltaSec = this.delta.replace(new RegExp(re), "$" + secPos);
407
		}
409
		}
408
		if (isNaN(deltaSec)) {
410
		if (isNaN(deltaSec)) {
409
			deltaSec = 1;
411
			deltaSec = 1;
410
		} else {
412
		} else {
411
			deltaSec = parseInt(deltaSec);
413
			deltaSec = parseInt(deltaSec);
412
		}
414
		}
413
		cursorFormat = cursorFormat.replace(/s+/, sec.replace(/./g, "s"));
415
		cursorFormat = cursorFormat.replace(/s+/, sec.replace(/./g, "s"));
414
		if (isNaN(sec)) {
416
		if (isNaN(sec)) {
415
			sec = 0;
417
			sec = 0;
416
		} else {
418
		} else {
417
			sec = parseInt(sec.replace(/^0(\d)/, "$1"));
419
			sec = parseInt(sec.replace(/^0(\d)/, "$1"));
418
		}
420
		}
419
	}
421
	}
420
	if (isNaN(x) || x >= cursorFormat.length) {
422
	if (isNaN(x) || x >= cursorFormat.length) {
421
		x = cursorFormat.length - 1;
423
		x = cursorFormat.length - 1;
422
	}
424
	}
423
	var cursorToken = cursorFormat.charAt(x);
425
	var cursorToken = cursorFormat.charAt(x);
424
	switch (cursorToken) {
426
	switch (cursorToken) {
425
	  case "t":
427
	  case "t":
426
		if (ampm == this.flags.amSymbol) {
428
		if (ampm == this.flags.amSymbol) {
427
			ampm = this.flags.pmSymbol;
429
			ampm = this.flags.pmSymbol;
428
		} else {
430
		} else {
429
			if (ampm == this.flags.pmSymbol) {
431
			if (ampm == this.flags.pmSymbol) {
430
				ampm = this.flags.amSymbol;
432
				ampm = this.flags.amSymbol;
431
			}
433
			}
432
		}
434
		}
433
		break;
435
		break;
434
	  default:
436
	  default:
435
		if (hour >= 1 && hour < 12 && ampm == this.flags.pmSymbol) {
437
		if (hour >= 1 && hour < 12 && ampm == this.flags.pmSymbol) {
436
			hour += 12;
438
			hour += 12;
437
		}
439
		}
438
		if (hour == 12 && ampm == this.flags.amSymbol) {
440
		if (hour == 12 && ampm == this.flags.amSymbol) {
439
			hour = 0;
441
			hour = 0;
440
		}
442
		}
441
		switch (cursorToken) {
443
		switch (cursorToken) {
442
		  case "s":
444
		  case "s":
443
			sec += deltaSec * direction;
445
			sec += deltaSec * direction;
444
			while (sec < 0) {
446
			while (sec < 0) {
445
				min--;
447
				min--;
446
				sec += 60;
448
				sec += 60;
447
			}
449
			}
448
			while (sec >= 60) {
450
			while (sec >= 60) {
449
				min++;
451
				min++;
450
				sec -= 60;
452
				sec -= 60;
451
			}
453
			}
452
		  case "m":
454
		  case "m":
453
			if (cursorToken == "m") {
455
			if (cursorToken == "m") {
454
				min += deltaMin * direction;
456
				min += deltaMin * direction;
455
			}
457
			}
456
			while (min < 0) {
458
			while (min < 0) {
457
				hour--;
459
				hour--;
458
				min += 60;
460
				min += 60;
459
			}
461
			}
460
			while (min >= 60) {
462
			while (min >= 60) {
461
				hour++;
463
				hour++;
462
				min -= 60;
464
				min -= 60;
463
			}
465
			}
464
		  case "h":
466
		  case "h":
465
		  case "H":
467
		  case "H":
466
			if (cursorToken == "h" || cursorToken == "H") {
468
			if (cursorToken == "h" || cursorToken == "H") {
467
				hour += deltaHour * direction;
469
				hour += deltaHour * direction;
468
			}
470
			}
469
			while (hour < 0) {
471
			while (hour < 0) {
470
				hour += 24;
472
				hour += 24;
471
			}
473
			}
472
			while (hour >= 24) {
474
			while (hour >= 24) {
473
				hour -= 24;
475
				hour -= 24;
474
			}
476
			}
475
			break;
477
			break;
476
		  default:
478
		  default:
477
			return;
479
			return;
478
		}
480
		}
479
		if (hour >= 12) {
481
		if (hour >= 12) {
480
			ampm = this.flags.pmSymbol;
482
			ampm = this.flags.pmSymbol;
481
			if (format.indexOf("h") >= 0 && hour >= 13) {
483
			if (format.indexOf("h") >= 0 && hour >= 13) {
482
				hour -= 12;
484
				hour -= 12;
483
			}
485
			}
484
		} else {
486
		} else {
485
			ampm = this.flags.amSymbol;
487
			ampm = this.flags.amSymbol;
486
			if (format.indexOf("h") >= 0 && hour == 0) {
488
			if (format.indexOf("h") >= 0 && hour == 0) {
487
				hour = 12;
489
				hour = 12;
488
			}
490
			}
489
		}
491
		}
490
	}
492
	}
491
	cursorFormat = format;
493
	cursorFormat = format;
492
	if (hour >= 0 && hour < 10 && format.search(/[hH]{2}/) >= 0) {
494
	if (hour >= 0 && hour < 10 && format.search(/[hH]{2}/) >= 0) {
493
		hour = "0" + hour.toString();
495
		hour = "0" + hour.toString();
494
	}
496
	}
495
	if (hour >= 10 && cursorFormat.search(/[hH]{2}/) < 0) {
497
	if (hour >= 10 && cursorFormat.search(/[hH]{2}/) < 0) {
496
		cursorFormat = cursorFormat.replace(/(h|H)/, "$1$1");
498
		cursorFormat = cursorFormat.replace(/(h|H)/, "$1$1");
497
	}
499
	}
498
	if (min >= 0 && min < 10 && cursorFormat.search(/mm/) >= 0) {
500
	if (min >= 0 && min < 10 && cursorFormat.search(/mm/) >= 0) {
499
		min = "0" + min.toString();
501
		min = "0" + min.toString();
500
	}
502
	}
501
	if (min >= 10 && cursorFormat.search(/mm/) < 0) {
503
	if (min >= 10 && cursorFormat.search(/mm/) < 0) {
502
		cursorFormat = cursorFormat.replace(/m/, "$1$1");
504
		cursorFormat = cursorFormat.replace(/m/, "$1$1");
503
	}
505
	}
504
	if (sec >= 0 && sec < 10 && cursorFormat.search(/ss/) >= 0) {
506
	if (sec >= 0 && sec < 10 && cursorFormat.search(/ss/) >= 0) {
505
		sec = "0" + sec.toString();
507
		sec = "0" + sec.toString();
506
	}
508
	}
507
	if (sec >= 10 && cursorFormat.search(/ss/) < 0) {
509
	if (sec >= 10 && cursorFormat.search(/ss/) < 0) {
508
		cursorFormat = cursorFormat.replace(/s/, "$1$1");
510
		cursorFormat = cursorFormat.replace(/s/, "$1$1");
509
	}
511
	}
510
	x = cursorFormat.indexOf(cursorToken);
512
	x = cursorFormat.indexOf(cursorToken);
511
	if (x == -1) {
513
	if (x == -1) {
512
		x = format.length;
514
		x = format.length;
513
	}
515
	}
514
	format = format.replace(/[hH]+/, hour);
516
	format = format.replace(/[hH]+/, hour);
515
	format = format.replace(/m+/, min);
517
	format = format.replace(/m+/, min);
516
	format = format.replace(/s+/, sec);
518
	format = format.replace(/s+/, sec);
517
	format = format.replace(/t/, ampm);
519
	format = format.replace(/t/, ampm);
518
	this.setValue(format);
520
	this.setValue(format);
519
	if (x > format.length) {
521
	if (x > format.length) {
520
		x = format.length;
522
		x = format.length;
521
	}
523
	}
522
	return x;
524
	return x;
523
}});
525
}});
524
 
526