Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / form / DateTextBox.js @ 13

History | View | Annotate | Download (2.75 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.form.DateTextBox"]){
9
dojo._hasResource["dojox.form.DateTextBox"]=true;
10
dojo.provide("dojox.form.DateTextBox");
11
dojo.experimental("dojox.form.DateTextBox");
12
dojo.require("dojox.widget.Calendar");
13
dojo.require("dojox.widget.CalendarViews");
14
dojo.require("dijit.form._DateTimeTextBox");
15
dojo.declare("dojox.form.DateTextBox",dijit.form._DateTimeTextBox,{popupClass:"dojox.widget.Calendar",_selector:"date",_open:function(){
16
this.inherited(arguments);
17
dojo.style(this._picker.domNode.parentNode,"position","absolute");
18
}});
19
dojo.declare("dojox.form.DayTextBox",dojox.form.DateTextBox,{popupClass:"dojox.widget.DailyCalendar",parse:function(_1){
20
return _1;
21
},format:function(_2){
22
return _2.getDate?_2.getDate():_2;
23
},validator:function(_3){
24
var _4=Number(_3);
25
var _5=/(^-?\d\d*$)/.test(String(_3));
26
return _3==""||_3==null||(_5&&_4>=1&&_4<=31);
27
},_open:function(){
28
this.inherited(arguments);
29
this._picker.onValueSelected=dojo.hitch(this,function(_6){
30
this.focus();
31
setTimeout(dojo.hitch(this,"_close"),1);
32
dijit.form.TextBox.prototype._setValueAttr.call(this,String(_6.getDate()),true,String(_6.getDate()));
33
});
34
}});
35
dojo.declare("dojox.form.MonthTextBox",dojox.form.DateTextBox,{popupClass:"dojox.widget.MonthlyCalendar",selector:"date",postMixInProperties:function(){
36
this.inherited(arguments);
37
this.constraints.datePattern="MM";
38
},format:function(_7){
39
return Number(_7)+1;
40
},parse:function(_8,_9){
41
return Number(_8)-1;
42
},serialize:function(_a,_b){
43
return String(_a);
44
},validator:function(_c){
45
var _d=Number(_c);
46
var _e=/(^-?\d\d*$)/.test(String(_c));
47
return _c==""||_c==null||(_e&&_d>=1&&_d<=12);
48
},_open:function(){
49
this.inherited(arguments);
50
this._picker.onValueSelected=dojo.hitch(this,function(_f){
51
this.focus();
52
setTimeout(dojo.hitch(this,"_close"),1);
53
dijit.form.TextBox.prototype._setValueAttr.call(this,_f,true,_f);
54
});
55
}});
56
dojo.declare("dojox.form.YearTextBox",dojox.form.DateTextBox,{popupClass:"dojox.widget.YearlyCalendar",format:function(_10){
57
if(typeof _10=="string"){
58
return _10;
59
}else{
60
if(_10.getFullYear){
61
return _10.getFullYear();
62
}
63
}
64
return _10;
65
},validator:function(_11){
66
return _11==""||_11==null||/(^-?\d\d*$)/.test(String(_11));
67
},_open:function(){
68
this.inherited(arguments);
69
this._picker.onValueSelected=dojo.hitch(this,function(_12){
70
this.focus();
71
setTimeout(dojo.hitch(this,"_close"),1);
72
dijit.form.TextBox.prototype._setValueAttr.call(this,_12,true,_12);
73
});
74
},parse:function(_13,_14){
75
return _13||(this._isEmpty(_13)?null:undefined);
76
},filter:function(val){
77
if(val&&val.getFullYear){
78
return val.getFullYear().toString();
79
}
80
return this.inherited(arguments);
81
}});
82
}