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.Textbox");
|
13 |
dojo.provide("dojo.widget.Textbox");
|
12 |
dojo.require("dojo.widget.*");
|
14 |
dojo.require("dojo.widget.*");
|
13 |
dojo.require("dojo.widget.HtmlWidget");
|
15 |
dojo.require("dojo.widget.HtmlWidget");
|
14 |
dojo.require("dojo.widget.Manager");
|
16 |
dojo.require("dojo.widget.Manager");
|
15 |
dojo.require("dojo.widget.Parse");
|
17 |
dojo.require("dojo.widget.Parse");
|
16 |
dojo.require("dojo.xml.Parse");
|
18 |
dojo.require("dojo.xml.Parse");
|
17 |
dojo.require("dojo.lang.array");
|
19 |
dojo.require("dojo.lang.array");
|
18 |
dojo.require("dojo.lang.common");
|
20 |
dojo.require("dojo.lang.common");
|
19 |
dojo.require("dojo.i18n.common");
|
21 |
dojo.require("dojo.i18n.common");
|
20 |
dojo.requireLocalization("dojo.widget", "validate", null, "fr,ja,zh-cn,ROOT");
|
22 |
dojo.requireLocalization("dojo.widget", "validate", null, "zh-cn,ja,ROOT,fr");
|
21 |
dojo.widget.defineWidget("dojo.widget.Textbox", dojo.widget.HtmlWidget, {className:"", name:"", value:"", type:"", trim:false, uppercase:false, lowercase:false, ucFirst:false, digit:false, htmlfloat:"none", templateString:"<span style='float:${this.htmlfloat};'>\n\t<input dojoAttachPoint='textbox' dojoAttachEvent='onblur;onfocus'\n\t\tid='${this.widgetId}' name='${this.name}'\n\t\tclass='${this.className}' type='${this.type}' >\n</span>\n", textbox:null, fillInTemplate:function () {
|
23 |
dojo.widget.defineWidget("dojo.widget.Textbox", dojo.widget.HtmlWidget, {className:"", name:"", value:"", type:"", trim:false, uppercase:false, lowercase:false, ucFirst:false, digit:false, htmlfloat:"none", templateString:"<span style='float:${this.htmlfloat};'>\n\t<input dojoAttachPoint='textbox' dojoAttachEvent='onblur;onfocus'\n\t\tid='${this.widgetId}' name='${this.name}'\n\t\tclass='${this.className}' type='${this.type}' >\n</span>\n", textbox:null, fillInTemplate:function () {
|
22 |
this.textbox.value = this.value;
|
24 |
this.textbox.value = this.value;
|
23 |
}, filter:function () {
|
25 |
}, filter:function () {
|
24 |
if (this.trim) {
|
26 |
if (this.trim) {
|
25 |
this.textbox.value = this.textbox.value.replace(/(^\s*|\s*$)/g, "");
|
27 |
this.textbox.value = this.textbox.value.replace(/(^\s*|\s*$)/g, "");
|
26 |
}
|
28 |
}
|
27 |
if (this.uppercase) {
|
29 |
if (this.uppercase) {
|
28 |
this.textbox.value = this.textbox.value.toUpperCase();
|
30 |
this.textbox.value = this.textbox.value.toUpperCase();
|
29 |
}
|
31 |
}
|
30 |
if (this.lowercase) {
|
32 |
if (this.lowercase) {
|
31 |
this.textbox.value = this.textbox.value.toLowerCase();
|
33 |
this.textbox.value = this.textbox.value.toLowerCase();
|
32 |
}
|
34 |
}
|
33 |
if (this.ucFirst) {
|
35 |
if (this.ucFirst) {
|
34 |
this.textbox.value = this.textbox.value.replace(/\b\w+\b/g, function (word) {
|
36 |
this.textbox.value = this.textbox.value.replace(/\b\w+\b/g, function (word) {
|
35 |
return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase();
|
37 |
return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase();
|
36 |
});
|
38 |
});
|
37 |
}
|
39 |
}
|
38 |
if (this.digit) {
|
40 |
if (this.digit) {
|
39 |
this.textbox.value = this.textbox.value.replace(/\D/g, "");
|
41 |
this.textbox.value = this.textbox.value.replace(/\D/g, "");
|
40 |
}
|
42 |
}
|
41 |
}, onfocus:function () {
|
43 |
}, onfocus:function () {
|
42 |
}, onblur:function () {
|
44 |
}, onblur:function () {
|
43 |
this.filter();
|
45 |
this.filter();
|
44 |
}, mixInProperties:function (localProperties, frag) {
|
46 |
}, mixInProperties:function (localProperties, frag) {
|
45 |
dojo.widget.Textbox.superclass.mixInProperties.apply(this, arguments);
|
47 |
dojo.widget.Textbox.superclass.mixInProperties.apply(this, arguments);
|
46 |
if (localProperties["class"]) {
|
48 |
if (localProperties["class"]) {
|
47 |
this.className = localProperties["class"];
|
49 |
this.className = localProperties["class"];
|
48 |
}
|
50 |
}
|
49 |
}});
|
51 |
}});
|
50 |
|
52 |
|