1318 |
alexandre_ |
1 |
/*
|
|
|
2 |
Copyright (c) 2004-2006, The Dojo Foundation
|
|
|
3 |
All Rights Reserved.
|
|
|
4 |
|
|
|
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:
|
|
|
7 |
|
|
|
8 |
http://dojotoolkit.org/community/licensing.shtml
|
|
|
9 |
*/
|
|
|
10 |
|
1422 |
alexandre_ |
11 |
|
|
|
12 |
|
1318 |
alexandre_ |
13 |
dojo.provide("dojo.widget.Textbox");
|
|
|
14 |
dojo.require("dojo.widget.*");
|
|
|
15 |
dojo.require("dojo.widget.HtmlWidget");
|
|
|
16 |
dojo.require("dojo.widget.Manager");
|
|
|
17 |
dojo.require("dojo.widget.Parse");
|
|
|
18 |
dojo.require("dojo.xml.Parse");
|
|
|
19 |
dojo.require("dojo.lang.array");
|
|
|
20 |
dojo.require("dojo.lang.common");
|
|
|
21 |
dojo.require("dojo.i18n.common");
|
1422 |
alexandre_ |
22 |
dojo.requireLocalization("dojo.widget", "validate", null, "zh-cn,ja,ROOT,fr");
|
1318 |
alexandre_ |
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 () {
|
|
|
24 |
this.textbox.value = this.value;
|
|
|
25 |
}, filter:function () {
|
|
|
26 |
if (this.trim) {
|
|
|
27 |
this.textbox.value = this.textbox.value.replace(/(^\s*|\s*$)/g, "");
|
|
|
28 |
}
|
|
|
29 |
if (this.uppercase) {
|
|
|
30 |
this.textbox.value = this.textbox.value.toUpperCase();
|
|
|
31 |
}
|
|
|
32 |
if (this.lowercase) {
|
|
|
33 |
this.textbox.value = this.textbox.value.toLowerCase();
|
|
|
34 |
}
|
|
|
35 |
if (this.ucFirst) {
|
|
|
36 |
this.textbox.value = this.textbox.value.replace(/\b\w+\b/g, function (word) {
|
|
|
37 |
return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase();
|
|
|
38 |
});
|
|
|
39 |
}
|
|
|
40 |
if (this.digit) {
|
|
|
41 |
this.textbox.value = this.textbox.value.replace(/\D/g, "");
|
|
|
42 |
}
|
|
|
43 |
}, onfocus:function () {
|
|
|
44 |
}, onblur:function () {
|
|
|
45 |
this.filter();
|
|
|
46 |
}, mixInProperties:function (localProperties, frag) {
|
|
|
47 |
dojo.widget.Textbox.superclass.mixInProperties.apply(this, arguments);
|
|
|
48 |
if (localProperties["class"]) {
|
|
|
49 |
this.className = localProperties["class"];
|
|
|
50 |
}
|
|
|
51 |
}});
|
|
|
52 |
|