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.DatePicker");
|
|
|
14 |
dojo.require("dojo.date.common");
|
|
|
15 |
dojo.require("dojo.date.format");
|
|
|
16 |
dojo.require("dojo.date.serialize");
|
|
|
17 |
dojo.require("dojo.widget.*");
|
|
|
18 |
dojo.require("dojo.widget.HtmlWidget");
|
|
|
19 |
dojo.require("dojo.event.*");
|
|
|
20 |
dojo.require("dojo.dom");
|
|
|
21 |
dojo.require("dojo.html.style");
|
|
|
22 |
dojo.widget.defineWidget("dojo.widget.DatePicker", dojo.widget.HtmlWidget, {value:"", name:"", displayWeeks:6, adjustWeeks:false, startDate:"1492-10-12", endDate:"2941-10-12", weekStartsOn:"", staticDisplay:false, dayWidth:"narrow", classNames:{previous:"previousMonth", disabledPrevious:"previousMonthDisabled", current:"currentMonth", disabledCurrent:"currentMonthDisabled", next:"nextMonth", disabledNext:"nextMonthDisabled", currentDate:"currentDate", selectedDate:"selectedDate"}, templateString:"<div class=\"datePickerContainer\" dojoAttachPoint=\"datePickerContainerNode\">\n\t<table cellspacing=\"0\" cellpadding=\"0\" class=\"calendarContainer\">\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<td class=\"monthWrapper\" valign=\"top\">\n\t\t\t\t\t<table class=\"monthContainer\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"monthCurve monthCurveTL\" valign=\"top\"></td>\n\t\t\t\t\t\t\t<td class=\"monthLabelContainer\" valign=\"top\">\n\t\t\t\t\t\t\t\t<span dojoAttachPoint=\"increaseWeekNode\" \n\t\t\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: onIncrementWeek;\" \n\t\t\t\t\t\t\t\t\tclass=\"incrementControl increase\">\n\t\t\t\t\t\t\t\t\t<img src=\"${dojoWidgetModuleUri}templates/images/incrementMonth.png\" \n\t\t\t\t\t\t\t\t\talt=\"↓\" style=\"width:7px;height:5px;\" />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span \n\t\t\t\t\t\t\t\t\tdojoAttachPoint=\"increaseMonthNode\" \n\t\t\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: onIncrementMonth;\" class=\"incrementControl increase\">\n\t\t\t\t\t\t\t\t\t<img src=\"${dojoWidgetModuleUri}templates/images/incrementMonth.png\" \n\t\t\t\t\t\t\t\t\t\talt=\"↓\" dojoAttachPoint=\"incrementMonthImageNode\">\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span \n\t\t\t\t\t\t\t\t\tdojoAttachPoint=\"decreaseWeekNode\" \n\t\t\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: onIncrementWeek;\" \n\t\t\t\t\t\t\t\t\tclass=\"incrementControl decrease\">\n\t\t\t\t\t\t\t\t\t<img src=\"${dojoWidgetModuleUri}templates/images/decrementMonth.png\" alt=\"↑\" style=\"width:7px;height:5px;\" />\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span \n\t\t\t\t\t\t\t\t\tdojoAttachPoint=\"decreaseMonthNode\" \n\t\t\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: onIncrementMonth;\" class=\"incrementControl decrease\">\n\t\t\t\t\t\t\t\t\t<img src=\"${dojoWidgetModuleUri}templates/images/decrementMonth.png\" \n\t\t\t\t\t\t\t\t\t\talt=\"↑\" dojoAttachPoint=\"decrementMonthImageNode\">\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<span dojoAttachPoint=\"monthLabelNode\" class=\"month\"></span>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"monthCurve monthCurveTR\" valign=\"top\"></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td colspan=\"3\">\n\t\t\t\t\t<table class=\"calendarBodyContainer\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t<tr dojoAttachPoint=\"dayLabelsRow\">\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t<tbody dojoAttachPoint=\"calendarDatesContainerNode\" \n\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: _handleUiClick;\">\n\t\t\t\t\t\t\t<tr dojoAttachPoint=\"calendarWeekTemplate\">\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr>\n\t\t\t\t<td colspan=\"3\" class=\"yearWrapper\">\n\t\t\t\t\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"yearContainer\">\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td class=\"curveBL\" valign=\"top\"></td>\n\t\t\t\t\t\t\t<td valign=\"top\">\n\t\t\t\t\t\t\t\t<h3 class=\"yearLabel\">\n\t\t\t\t\t\t\t\t\t<span dojoAttachPoint=\"previousYearLabelNode\"\n\t\t\t\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: onIncrementYear;\" class=\"previousYear\"></span>\n\t\t\t\t\t\t\t\t\t<span class=\"selectedYear\" dojoAttachPoint=\"currentYearLabelNode\"></span>\n\t\t\t\t\t\t\t\t\t<span dojoAttachPoint=\"nextYearLabelNode\" \n\t\t\t\t\t\t\t\t\t\tdojoAttachEvent=\"onClick: onIncrementYear;\" class=\"nextYear\"></span>\n\t\t\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class=\"curveBR\" valign=\"top\"></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</tfoot>\n\t</table>\n</div>\n", templateCssString:".datePickerContainer {\n\twidth:164px; /* needed for proper user styling */\n}\n\n.calendarContainer {\n/*\tborder:1px solid #566f8f;*/\n}\n\n.calendarBodyContainer {\n\twidth:100%; /* needed for the explode effect (explain?) */\n\tbackground: #7591bc url(\"images/dpBg.gif\") top left repeat-x;\n}\n\n.calendarBodyContainer thead tr td {\n\tcolor:#293a4b;\n\tfont:bold 0.75em Helvetica, Arial, Verdana, sans-serif;\n\ttext-align:center;\n\tpadding:0.25em;\n\tbackground: url(\"images/dpHorizLine.gif\") bottom left repeat-x;\n}\n\n.calendarBodyContainer tbody tr td {\n\tcolor:#fff;\n\tfont:bold 0.7em Helvetica, Arial, Verdana, sans-serif;\n\ttext-align:center;\n\tpadding:0.4em;\n\tbackground: url(\"images/dpVertLine.gif\") top right repeat-y;\n\tcursor:pointer;\n\tcursor:hand;\n}\n\n\n.monthWrapper {\n\tpadding-bottom:2px;\n\tbackground: url(\"images/dpHorizLine.gif\") bottom left repeat-x;\n}\n\n.monthContainer {\n\twidth:100%;\n}\n\n.monthLabelContainer {\n\ttext-align:center;\n\tfont:bold 0.75em Helvetica, Arial, Verdana, sans-serif;\n\tbackground: url(\"images/dpMonthBg.png\") repeat-x top left !important;\n\tcolor:#293a4b;\n\tpadding:0.25em;\n}\n\n.monthCurve {\n\twidth:12px;\n}\n\n.monthCurveTL {\n\tbackground: url(\"images/dpCurveTL.png\") no-repeat top left !important;\n}\n\n.monthCurveTR {\n\t\tbackground: url(\"images/dpCurveTR.png\") no-repeat top right !important;\n}\n\n\n.yearWrapper {\n\tbackground: url(\"images/dpHorizLineFoot.gif\") top left repeat-x;\n\tpadding-top:2px;\n}\n\n.yearContainer {\n\twidth:100%;\n}\n\n.yearContainer td {\n\tbackground:url(\"images/dpYearBg.png\") top left repeat-x;\n}\n\n.yearContainer .yearLabel {\n\tmargin:0;\n\tpadding:0.45em 0 0.45em 0;\n\tcolor:#fff;\n\tfont:bold 0.75em Helvetica, Arial, Verdana, sans-serif;\n\ttext-align:center;\n}\n\n.curveBL {\n\tbackground: url(\"images/dpCurveBL.png\") bottom left no-repeat !important;\n\twidth:9px !important;\n\tpadding:0;\n\tmargin:0;\n}\n\n.curveBR {\n\tbackground: url(\"images/dpCurveBR.png\") bottom right no-repeat !important;\n\twidth:9px !important;\n\tpadding:0;\n\tmargin:0;\n}\n\n\n.previousMonth {\n\tbackground-color:#6782a8 !important;\n}\n\n.previousMonthDisabled {\n\tbackground-color:#a4a5a6 !important;\n\tcursor:default !important\n}\n.currentMonth {\n}\n\n.currentMonthDisabled {\n\tbackground-color:#bbbbbc !important;\n\tcursor:default !important\n}\n.nextMonth {\n\tbackground-color:#6782a8 !important;\n}\n.nextMonthDisabled {\n\tbackground-color:#a4a5a6 !important;\n\tcursor:default !important;\n}\n\n.currentDate {\n\ttext-decoration:underline;\n\tfont-style:italic;\n}\n\n.selectedDate {\n\tbackground-color:#fff !important;\n\tcolor:#6782a8 !important;\n}\n\n.yearLabel .selectedYear {\n\tpadding:0.2em;\n\tbackground-color:#9ec3fb !important;\n}\n\n.nextYear, .previousYear {\n\tcursor:pointer;cursor:hand;\n\tpadding:0;\n}\n\n.nextYear {\n\tmargin:0 0 0 0.55em;\n}\n\n.previousYear {\n\tmargin:0 0.55em 0 0;\n}\n\n.incrementControl {\n\tcursor:pointer;cursor:hand;\n\twidth:1em;\n}\n\n.increase {\n\tfloat:right;\n}\n\n.decrease {\n\tfloat:left;\n}\n\n.lastColumn {\n\tbackground-image:none !important;\n}\n\n\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/DatePicker.css"), postMixInProperties:function () {
|
|
|
23 |
dojo.widget.DatePicker.superclass.postMixInProperties.apply(this, arguments);
|
|
|
24 |
if (!this.weekStartsOn) {
|
|
|
25 |
this.weekStartsOn = dojo.date.getFirstDayOfWeek(this.lang);
|
|
|
26 |
}
|
|
|
27 |
this.today = new Date();
|
|
|
28 |
this.today.setHours(0, 0, 0, 0);
|
|
|
29 |
if (typeof (this.value) == "string" && this.value.toLowerCase() == "today") {
|
|
|
30 |
this.value = new Date();
|
|
|
31 |
} else {
|
|
|
32 |
if (this.value && (typeof this.value == "string") && (this.value.split("-").length > 2)) {
|
|
|
33 |
this.value = dojo.date.fromRfc3339(this.value);
|
|
|
34 |
this.value.setHours(0, 0, 0, 0);
|
|
|
35 |
}
|
|
|
36 |
}
|
|
|
37 |
}, fillInTemplate:function (args, frag) {
|
|
|
38 |
dojo.widget.DatePicker.superclass.fillInTemplate.apply(this, arguments);
|
|
|
39 |
var source = this.getFragNodeRef(frag);
|
|
|
40 |
dojo.html.copyStyle(this.domNode, source);
|
|
|
41 |
this.weekTemplate = dojo.dom.removeNode(this.calendarWeekTemplate);
|
|
|
42 |
this._preInitUI(this.value ? this.value : this.today, false, true);
|
|
|
43 |
var dayLabels = dojo.lang.unnest(dojo.date.getNames("days", this.dayWidth, "standAlone", this.lang));
|
|
|
44 |
if (this.weekStartsOn > 0) {
|
|
|
45 |
for (var i = 0; i < this.weekStartsOn; i++) {
|
|
|
46 |
dayLabels.push(dayLabels.shift());
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
var dayLabelNodes = this.dayLabelsRow.getElementsByTagName("td");
|
|
|
50 |
for (i = 0; i < 7; i++) {
|
|
|
51 |
dayLabelNodes.item(i).innerHTML = dayLabels[i];
|
|
|
52 |
}
|
|
|
53 |
if (this.value) {
|
|
|
54 |
this.setValue(this.value);
|
|
|
55 |
}
|
|
|
56 |
}, getValue:function () {
|
|
|
57 |
return dojo.date.toRfc3339(new Date(this.value), "dateOnly");
|
|
|
58 |
}, getDate:function () {
|
|
|
59 |
return this.value;
|
|
|
60 |
}, setValue:function (rfcDate) {
|
|
|
61 |
this.setDate(rfcDate);
|
|
|
62 |
}, setDate:function (dateObj) {
|
|
|
63 |
if (dateObj == "") {
|
|
|
64 |
this.value = "";
|
|
|
65 |
this._preInitUI(this.curMonth, false, true);
|
|
|
66 |
} else {
|
|
|
67 |
if (typeof dateObj == "string") {
|
|
|
68 |
this.value = dojo.date.fromRfc3339(dateObj);
|
|
|
69 |
this.value.setHours(0, 0, 0, 0);
|
|
|
70 |
} else {
|
|
|
71 |
this.value = new Date(dateObj);
|
|
|
72 |
this.value.setHours(0, 0, 0, 0);
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
if (this.selectedNode != null) {
|
|
|
76 |
dojo.html.removeClass(this.selectedNode, this.classNames.selectedDate);
|
|
|
77 |
}
|
|
|
78 |
if (this.clickedNode != null) {
|
|
|
79 |
dojo.debug("adding selectedDate");
|
|
|
80 |
dojo.html.addClass(this.clickedNode, this.classNames.selectedDate);
|
|
|
81 |
this.selectedNode = this.clickedNode;
|
|
|
82 |
} else {
|
|
|
83 |
this._preInitUI(this.value, false, true);
|
|
|
84 |
}
|
|
|
85 |
this.clickedNode = null;
|
|
|
86 |
this.onValueChanged(this.value);
|
|
|
87 |
}, _preInitUI:function (dateObj, initFirst, initUI) {
|
|
|
88 |
if (typeof (this.startDate) == "string") {
|
|
|
89 |
this.startDate = dojo.date.fromRfc3339(this.startDate);
|
|
|
90 |
}
|
|
|
91 |
if (typeof (this.endDate) == "string") {
|
|
|
92 |
this.endDate = dojo.date.fromRfc3339(this.endDate);
|
|
|
93 |
}
|
|
|
94 |
this.startDate.setHours(0, 0, 0, 0);
|
|
|
95 |
this.endDate.setHours(24, 0, 0, -1);
|
|
|
96 |
if (dateObj < this.startDate || dateObj > this.endDate) {
|
|
|
97 |
dateObj = new Date((dateObj < this.startDate) ? this.startDate : this.endDate);
|
|
|
98 |
}
|
|
|
99 |
this.firstDay = this._initFirstDay(dateObj, initFirst);
|
|
|
100 |
this.selectedIsUsed = false;
|
|
|
101 |
this.currentIsUsed = false;
|
|
|
102 |
var nextDate = new Date(this.firstDay);
|
|
|
103 |
var tmpMonth = nextDate.getMonth();
|
|
|
104 |
this.curMonth = new Date(nextDate);
|
|
|
105 |
this.curMonth.setDate(nextDate.getDate() + 6);
|
|
|
106 |
this.curMonth.setDate(1);
|
|
|
107 |
if (this.displayWeeks == "" || this.adjustWeeks) {
|
|
|
108 |
this.adjustWeeks = true;
|
|
|
109 |
this.displayWeeks = Math.ceil((dojo.date.getDaysInMonth(this.curMonth) + this._getAdjustedDay(this.curMonth)) / 7);
|
|
|
110 |
}
|
|
|
111 |
var days = this.displayWeeks * 7;
|
|
|
112 |
if (dojo.date.diff(this.startDate, this.endDate, dojo.date.dateParts.DAY) < days) {
|
|
|
113 |
this.staticDisplay = true;
|
|
|
114 |
if (dojo.date.diff(nextDate, this.endDate, dojo.date.dateParts.DAY) > days) {
|
|
|
115 |
this._preInitUI(this.startDate, true, false);
|
|
|
116 |
nextDate = new Date(this.firstDay);
|
|
|
117 |
}
|
|
|
118 |
this.curMonth = new Date(nextDate);
|
|
|
119 |
this.curMonth.setDate(nextDate.getDate() + 6);
|
|
|
120 |
this.curMonth.setDate(1);
|
|
|
121 |
var curClass = (nextDate.getMonth() == this.curMonth.getMonth()) ? "current" : "previous";
|
|
|
122 |
}
|
|
|
123 |
if (initUI) {
|
|
|
124 |
this._initUI(days);
|
|
|
125 |
}
|
|
|
126 |
}, _initUI:function (days) {
|
|
|
127 |
dojo.dom.removeChildren(this.calendarDatesContainerNode);
|
|
|
128 |
for (var i = 0; i < this.displayWeeks; i++) {
|
|
|
129 |
this.calendarDatesContainerNode.appendChild(this.weekTemplate.cloneNode(true));
|
|
|
130 |
}
|
|
|
131 |
var nextDate = new Date(this.firstDay);
|
|
|
132 |
this._setMonthLabel(this.curMonth.getMonth());
|
|
|
133 |
this._setYearLabels(this.curMonth.getFullYear());
|
|
|
134 |
var calendarNodes = this.calendarDatesContainerNode.getElementsByTagName("td");
|
|
|
135 |
var calendarRows = this.calendarDatesContainerNode.getElementsByTagName("tr");
|
|
|
136 |
var currentCalendarNode;
|
|
|
137 |
for (i = 0; i < days; i++) {
|
|
|
138 |
currentCalendarNode = calendarNodes.item(i);
|
|
|
139 |
currentCalendarNode.innerHTML = nextDate.getDate();
|
|
|
140 |
currentCalendarNode.setAttribute("djDateValue", nextDate.valueOf());
|
|
|
141 |
var curClass = (nextDate.getMonth() != this.curMonth.getMonth() && Number(nextDate) < Number(this.curMonth)) ? "previous" : (nextDate.getMonth() == this.curMonth.getMonth()) ? "current" : "next";
|
|
|
142 |
var mappedClass = curClass;
|
|
|
143 |
if (this._isDisabledDate(nextDate)) {
|
|
|
144 |
var classMap = {previous:"disabledPrevious", current:"disabledCurrent", next:"disabledNext"};
|
|
|
145 |
mappedClass = classMap[curClass];
|
|
|
146 |
}
|
|
|
147 |
dojo.html.setClass(currentCalendarNode, this._getDateClassName(nextDate, mappedClass));
|
|
|
148 |
if (dojo.html.hasClass(currentCalendarNode, this.classNames.selectedDate)) {
|
|
|
149 |
this.selectedNode = currentCalendarNode;
|
|
|
150 |
}
|
|
|
151 |
nextDate = dojo.date.add(nextDate, dojo.date.dateParts.DAY, 1);
|
|
|
152 |
}
|
|
|
153 |
this.lastDay = dojo.date.add(nextDate, dojo.date.dateParts.DAY, -1);
|
|
|
154 |
this._initControls();
|
|
|
155 |
}, _initControls:function () {
|
|
|
156 |
var d = this.firstDay;
|
|
|
157 |
var d2 = this.lastDay;
|
|
|
158 |
var decWeek, incWeek, decMonth, incMonth, decYear, incYear;
|
|
|
159 |
decWeek = incWeek = decMonth = incMonth = decYear = incYear = !this.staticDisplay;
|
|
|
160 |
with (dojo.date.dateParts) {
|
|
|
161 |
var add = dojo.date.add;
|
|
|
162 |
if (decWeek && add(d, DAY, (-1 * (this._getAdjustedDay(d) + 1))) < this.startDate) {
|
|
|
163 |
decWeek = decMonth = decYear = false;
|
|
|
164 |
}
|
|
|
165 |
if (incWeek && d2 > this.endDate) {
|
|
|
166 |
incWeek = incMonth = incYear = false;
|
|
|
167 |
}
|
|
|
168 |
if (decMonth && add(d, DAY, -1) < this.startDate) {
|
|
|
169 |
decMonth = decYear = false;
|
|
|
170 |
}
|
|
|
171 |
if (incMonth && add(d2, DAY, 1) > this.endDate) {
|
|
|
172 |
incMonth = incYear = false;
|
|
|
173 |
}
|
|
|
174 |
if (decYear && add(d2, YEAR, -1) < this.startDate) {
|
|
|
175 |
decYear = false;
|
|
|
176 |
}
|
|
|
177 |
if (incYear && add(d, YEAR, 1) > this.endDate) {
|
|
|
178 |
incYear = false;
|
|
|
179 |
}
|
|
|
180 |
}
|
|
|
181 |
function enableControl(node, enabled) {
|
|
|
182 |
dojo.html.setVisibility(node, enabled ? "" : "hidden");
|
|
|
183 |
}
|
|
|
184 |
enableControl(this.decreaseWeekNode, decWeek);
|
|
|
185 |
enableControl(this.increaseWeekNode, incWeek);
|
|
|
186 |
enableControl(this.decreaseMonthNode, decMonth);
|
|
|
187 |
enableControl(this.increaseMonthNode, incMonth);
|
|
|
188 |
enableControl(this.previousYearLabelNode, decYear);
|
|
|
189 |
enableControl(this.nextYearLabelNode, incYear);
|
|
|
190 |
}, _incrementWeek:function (evt) {
|
|
|
191 |
var d = new Date(this.firstDay);
|
|
|
192 |
switch (evt.target) {
|
|
|
193 |
case this.increaseWeekNode.getElementsByTagName("img").item(0):
|
|
|
194 |
case this.increaseWeekNode:
|
|
|
195 |
var tmpDate = dojo.date.add(d, dojo.date.dateParts.WEEK, 1);
|
|
|
196 |
if (tmpDate < this.endDate) {
|
|
|
197 |
d = dojo.date.add(d, dojo.date.dateParts.WEEK, 1);
|
|
|
198 |
}
|
|
|
199 |
break;
|
|
|
200 |
case this.decreaseWeekNode.getElementsByTagName("img").item(0):
|
|
|
201 |
case this.decreaseWeekNode:
|
|
|
202 |
if (d >= this.startDate) {
|
|
|
203 |
d = dojo.date.add(d, dojo.date.dateParts.WEEK, -1);
|
|
|
204 |
}
|
|
|
205 |
break;
|
|
|
206 |
}
|
|
|
207 |
this._preInitUI(d, true, true);
|
|
|
208 |
}, _incrementMonth:function (evt) {
|
|
|
209 |
var d = new Date(this.curMonth);
|
|
|
210 |
var tmpDate = new Date(this.firstDay);
|
|
|
211 |
switch (evt.currentTarget) {
|
|
|
212 |
case this.increaseMonthNode.getElementsByTagName("img").item(0):
|
|
|
213 |
case this.increaseMonthNode:
|
|
|
214 |
tmpDate = dojo.date.add(tmpDate, dojo.date.dateParts.DAY, this.displayWeeks * 7);
|
|
|
215 |
if (tmpDate < this.endDate) {
|
|
|
216 |
d = dojo.date.add(d, dojo.date.dateParts.MONTH, 1);
|
|
|
217 |
} else {
|
|
|
218 |
var revertToEndDate = true;
|
|
|
219 |
}
|
|
|
220 |
break;
|
|
|
221 |
case this.decreaseMonthNode.getElementsByTagName("img").item(0):
|
|
|
222 |
case this.decreaseMonthNode:
|
|
|
223 |
if (tmpDate > this.startDate) {
|
|
|
224 |
d = dojo.date.add(d, dojo.date.dateParts.MONTH, -1);
|
|
|
225 |
} else {
|
|
|
226 |
var revertToStartDate = true;
|
|
|
227 |
}
|
|
|
228 |
break;
|
|
|
229 |
}
|
|
|
230 |
if (revertToStartDate) {
|
|
|
231 |
d = new Date(this.startDate);
|
|
|
232 |
} else {
|
|
|
233 |
if (revertToEndDate) {
|
|
|
234 |
d = new Date(this.endDate);
|
|
|
235 |
}
|
|
|
236 |
}
|
|
|
237 |
this._preInitUI(d, false, true);
|
|
|
238 |
}, _incrementYear:function (evt) {
|
|
|
239 |
var year = this.curMonth.getFullYear();
|
|
|
240 |
var tmpDate = new Date(this.firstDay);
|
|
|
241 |
switch (evt.target) {
|
|
|
242 |
case this.nextYearLabelNode:
|
|
|
243 |
tmpDate = dojo.date.add(tmpDate, dojo.date.dateParts.YEAR, 1);
|
|
|
244 |
if (tmpDate < this.endDate) {
|
|
|
245 |
year++;
|
|
|
246 |
} else {
|
|
|
247 |
var revertToEndDate = true;
|
|
|
248 |
}
|
|
|
249 |
break;
|
|
|
250 |
case this.previousYearLabelNode:
|
|
|
251 |
tmpDate = dojo.date.add(tmpDate, dojo.date.dateParts.YEAR, -1);
|
|
|
252 |
if (tmpDate > this.startDate) {
|
|
|
253 |
year--;
|
|
|
254 |
} else {
|
|
|
255 |
var revertToStartDate = true;
|
|
|
256 |
}
|
|
|
257 |
break;
|
|
|
258 |
}
|
|
|
259 |
var d;
|
|
|
260 |
if (revertToStartDate) {
|
|
|
261 |
d = new Date(this.startDate);
|
|
|
262 |
} else {
|
|
|
263 |
if (revertToEndDate) {
|
|
|
264 |
d = new Date(this.endDate);
|
|
|
265 |
} else {
|
|
|
266 |
d = new Date(year, this.curMonth.getMonth(), 1);
|
|
|
267 |
}
|
|
|
268 |
}
|
|
|
269 |
this._preInitUI(d, false, true);
|
|
|
270 |
}, onIncrementWeek:function (evt) {
|
|
|
271 |
evt.stopPropagation();
|
|
|
272 |
if (!this.staticDisplay) {
|
|
|
273 |
this._incrementWeek(evt);
|
|
|
274 |
}
|
|
|
275 |
}, onIncrementMonth:function (evt) {
|
|
|
276 |
evt.stopPropagation();
|
|
|
277 |
if (!this.staticDisplay) {
|
|
|
278 |
this._incrementMonth(evt);
|
|
|
279 |
}
|
|
|
280 |
}, onIncrementYear:function (evt) {
|
|
|
281 |
evt.stopPropagation();
|
|
|
282 |
if (!this.staticDisplay) {
|
|
|
283 |
this._incrementYear(evt);
|
|
|
284 |
}
|
|
|
285 |
}, _setMonthLabel:function (monthIndex) {
|
|
|
286 |
this.monthLabelNode.innerHTML = dojo.date.getNames("months", "wide", "standAlone", this.lang)[monthIndex];
|
|
|
287 |
}, _setYearLabels:function (year) {
|
|
|
288 |
var y = year - 1;
|
|
|
289 |
var that = this;
|
|
|
290 |
function f(n) {
|
|
|
291 |
that[n + "YearLabelNode"].innerHTML = dojo.date.format(new Date(y++, 0), {formatLength:"yearOnly", locale:that.lang});
|
|
|
292 |
}
|
|
|
293 |
f("previous");
|
|
|
294 |
f("current");
|
|
|
295 |
f("next");
|
|
|
296 |
}, _getDateClassName:function (date, monthState) {
|
|
|
297 |
var currentClassName = this.classNames[monthState];
|
|
|
298 |
if ((!this.selectedIsUsed && this.value) && (Number(date) == Number(this.value))) {
|
|
|
299 |
currentClassName = this.classNames.selectedDate + " " + currentClassName;
|
|
|
300 |
this.selectedIsUsed = true;
|
|
|
301 |
}
|
|
|
302 |
if ((!this.currentIsUsed) && (Number(date) == Number(this.today))) {
|
|
|
303 |
currentClassName = currentClassName + " " + this.classNames.currentDate;
|
|
|
304 |
this.currentIsUsed = true;
|
|
|
305 |
}
|
|
|
306 |
return currentClassName;
|
|
|
307 |
}, onClick:function (evt) {
|
|
|
308 |
dojo.event.browser.stopEvent(evt);
|
|
|
309 |
}, _handleUiClick:function (evt) {
|
|
|
310 |
var eventTarget = evt.target;
|
|
|
311 |
if (eventTarget.nodeType != dojo.dom.ELEMENT_NODE) {
|
|
|
312 |
eventTarget = eventTarget.parentNode;
|
|
|
313 |
}
|
|
|
314 |
dojo.event.browser.stopEvent(evt);
|
|
|
315 |
this.selectedIsUsed = this.todayIsUsed = false;
|
|
|
316 |
if (dojo.html.hasClass(eventTarget, this.classNames["disabledPrevious"]) || dojo.html.hasClass(eventTarget, this.classNames["disabledCurrent"]) || dojo.html.hasClass(eventTarget, this.classNames["disabledNext"])) {
|
|
|
317 |
return;
|
|
|
318 |
}
|
|
|
319 |
this.clickedNode = eventTarget;
|
|
|
320 |
this.setDate(new Date(Number(dojo.html.getAttribute(eventTarget, "djDateValue"))));
|
|
|
321 |
}, onValueChanged:function (date) {
|
|
|
322 |
}, _isDisabledDate:function (dateObj) {
|
|
|
323 |
if (dateObj < this.startDate || dateObj > this.endDate) {
|
|
|
324 |
return true;
|
|
|
325 |
}
|
|
|
326 |
return this.isDisabledDate(dateObj, this.lang);
|
|
|
327 |
}, isDisabledDate:function (dateObj, locale) {
|
|
|
328 |
return false;
|
|
|
329 |
}, _initFirstDay:function (dateObj, adj) {
|
|
|
330 |
var d = new Date(dateObj);
|
|
|
331 |
if (!adj) {
|
|
|
332 |
d.setDate(1);
|
|
|
333 |
}
|
|
|
334 |
d.setDate(d.getDate() - this._getAdjustedDay(d, this.weekStartsOn));
|
|
|
335 |
d.setHours(0, 0, 0, 0);
|
|
|
336 |
return d;
|
|
|
337 |
}, _getAdjustedDay:function (dateObj) {
|
|
|
338 |
var days = [0, 1, 2, 3, 4, 5, 6];
|
|
|
339 |
if (this.weekStartsOn > 0) {
|
|
|
340 |
for (var i = 0; i < this.weekStartsOn; i++) {
|
|
|
341 |
days.unshift(days.pop());
|
|
|
342 |
}
|
|
|
343 |
}
|
|
|
344 |
return days[dateObj.getDay()];
|
|
|
345 |
}, destroy:function () {
|
|
|
346 |
dojo.widget.DatePicker.superclass.destroy.apply(this, arguments);
|
|
|
347 |
dojo.html.destroyNode(this.weekTemplate);
|
|
|
348 |
}});
|
|
|
349 |
|