PageSourceSearch

https://pub.mtrace.go.kr/public/mtrace/nexacro17lib/component/ComComp/DatePicker.js

js mtrace.go.kr collected 2026-10-07 13:15:00 UTC 57,617 bytes, 2,129 lines download raw bytes

1//==============================================================================
2//
3//  TOBESOFT Co., Ltd.
4//  Copyright 2017 TOBESOFT Co., Ltd.
5//  All Rights Reserved.
6//
7//  NOTICE: TOBESOFT permits you to use, modify, and distribute this file 
8//          in accordance with the terms of the license agreement accompanying it.
9//
10//  Readme URL: http://www.nexacro.co.kr/legal/nexacro17-public-license-readme-1.0.html
11//
12//==============================================================================
13
14if (!nexacro.DatePickerControl) {
15	nexacro.DatePickerControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
16		nexacro.Component.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
17	};
18
19	var _pDatePickerControl = nexacro._createPrototype(nexacro.Component, nexacro.DatePickerControl);
20	nexacro.DatePickerControl.prototype = _pDatePickerControl;
21	_pDatePickerControl._type_name = "DatePickerControl";
22	_pDatePickerControl.accessibilityrole = "datepicker";
23	_pDatePickerControl._is_subcontrol = true;
24
25
26	_pDatePickerControl.head = null;
27	_pDatePickerControl.body = null;
28
29
30
31
32	_pDatePickerControl._selected_year = "";
33	_pDatePickerControl._selected_month = "";
34	_pDatePickerControl._selected_day = "";
35
36
37	_pDatePickerControl._use_readonly_status = true;
38	_pDatePickerControl._is_locale_control = true;
39
40
41	_pDatePickerControl._event_list = {
42		"onclick" : 1, 
43		"ondayclick" : 1, 
44		"onspin" : 1, 
45		"oncloseup" : 1
46	};
47
48
49	_pDatePickerControl.accessibilityrole = "datepicker";
50	_pDatePickerControl._has_accessibility_value = false;
51
52	_pDatePickerControl.on_create_contents = function () {
53		var control_elem = this.getElement();
54		if (control_elem) {
55			var head = this.head = new nexacro._DatePickerHeadControl("head", 0, 0, 0, 0, null, null, null, null, null, null, this);
56			var body = this.body = new nexacro._DatePickerBodyControl("body", 0, 0, 0, 0, null, null, null, null, null, null, this);
57
58			head.createComponent(true);
59			body.createComponent(true);
60		}
61	};
62
63	_pDatePickerControl.on_created_contents = function (win) {
64		var control_elem = this.getElement();
65		if (control_elem) {
66			var head = this.head;
67			var body = this.body;
68
69			head._setEventHandler("onclick", this._on_head_onheadclick, this);
70			head._setEventHandler("onspin", this._on_head_onheadspin, this);
71
72			body._setEventHandler("ondayclick", this._on_body_ondayclick, this);
73			body._setEventHandler("onkeydown", this._on_body_onkeydown, this);
74
75			head.on_created(win);
76			body.on_created(win);
77
78			this._recalcLayout();
79		}
80	};
81
82	_pDatePickerControl.on_create_contents_command = function () {
83		var head = this.head;
84		var body = this.body;
85
86		var str = "";
87		if (head) {
88			str += head.createCommand();
89		}
90		if (body) {
91			str += body.createCommand();
92		}
93
94		return str;
95	};
96
97	_pDatePickerControl.on_attach_contents_handle = function (win) {
98		var head = this.head;
99		var body = this.body;
100
101		head._setEventHandler("onclick", this._on_head_onheadclick, this);
102		head._setEventHandler("onspin", this._on_head_onheadspin, this);
103
104		body._setEventHandler("ondayclick", this._on_body_ondayclick, this);
105		body._setEventHandler("onkeydown", this._on_body_onkeydown, this);
106
107		body.attachHandle(win);
108		head.attachHandle(win);
109
110		this._recalcLayout();
111	};
112
113	_pDatePickerControl.on_destroy_contents = function () {
114		if (this.head) {
115			this.head.destroy();
116			this.head = null;
117		}
118		if (this.body) {
119			this.body.destroy();
120			this.body = null;
121		}
122	};
123
124	_pDatePickerControl.on_change_containerRect = function (width, height) {
125		this._recalcLayout();
126	};
127
128	_pDatePickerControl.on_apply_prop_enable = function (v) {
129		var head = this.head;
130		var body = this.body;
131
132		if (head) {
133			head._setEnable(v);
134		}
135
136		if (body) {
137			body._setEnable(v);
138		}
139	};
140
141	_pDatePickerControl.set_readonly = function (v) {
142		v = nexacro._toBoolean(v);
143		if (this.readonly != v) {
144			this.readonly = v;
145			this.on_apply_readonly(v);
146		}
147	};
148
149	_pDatePickerControl.on_apply_readonly = function (readonly) {
150		this._changeStatus("readonly", readonly);
151
152		var head = this.head;
153		if (head) {
154			head.set_readonly(readonly);
155		}
156
157		var body = this.body;
158		if (body) {
159			body.set_readonly(readonly);
160		}
161	};
162
163	_pDatePickerControl._on_head_onheadclick = function (obj, e) {
164		if (!this.enable || this.readonly) {
165			return false;
166		}
167
168		var head = this.head;
169		var body = this.body;
170
171		body._setDate(head._date.str_year, head._date.str_month, body._date.str_day);
172	};
173
174	_pDatePickerControl._on_head_onheadspin = function (obj, e) {
175		if (!this.enable || this.readonly == true) {
176			return false;
177		}
178
179		var head = this.head;
180		var body = this.body;
181
182		body._setDate(head._date.str_year, head._date.str_month, body._date.str_day);
183	};
184
185	_pDatePickerControl._on_body_ondayclick = function (obj, e) {
186		this.on_fire_ondayclick(obj, e);
187	};
188
189	_pDatePickerControl._on_body_onkeydown = function (obj, e) {
190		var body = this.body;
191
192		var body_date = body._date;
193		var year = body_date.int_year;
194		var month = body_date.int_month;
195		var day = body_date.int_day;
196		var endday = this._getEndDay(year, month);
197
198		var is_full_changed = false;
199		var inc_month = false;
200		var inc_day = false;
201		var dec_month = false;
202		var dec_day = false;
203		var enableaccessibility = nexacro._enableaccessibility;
204		var keycode = e.keycode;
205
206		if (keycode == 37 || keycode == 38 || keycode == 39 || keycode == 40) {
207			switch (keycode) {
208				case 37:
209					if (e.ctrlkey) {
210						dec_month = true;
211					}
212					else {
213						dec_day = true;
214					}
215
216					if (dec_day) {
217						day -= 1;
218						if (day <= 0) {
219							dec_month = true;
220						}
221					}
222
223					if (dec_month) {
224						month -= 1;
225						if (month <= 0) {
226							if (year <= 0) {
227								year = 9999;
228							}
229							else {
230								year -= 1;
231							}
232
233							month = 12;
234						}
235
236						if (!e.ctrlkey) {
237							day += this._getEndDay(year, month);
238						}
239						is_full_changed = true;
240					}
241					break;
242				case 38:
243					if (e.ctrlkey) {
244						year -= 1;
245						is_full_changed = true;
246					}
247					else if (!enableaccessibility) {
248						day -= 7;
249						if (day <= 0) {
250							if (month <= 1) {
251								month = 12;
252
253								if (year <= 0) {
254									year = 9999;
255								}
256								else {
257									year -= 1;
258								}
259							}
260							else {
261								month -= 1;
262							}
263
264							day += this._getEndDay(year, month);
265						}
266					}
267					break;
268				case 39:
269					if (e.ctrlkey) {
270						inc_month = true;
271					}
272					else {
273						inc_day = true;
274					}
275
276					if (inc_day) {
277						day += 1;
278						if (day > endday) {
279							inc_month = true;
280						}
281					}
282
283					if (inc_month) {
284						month += 1;
285						if (month > 12) {
286							if (year >= 9999) {
287								year = 0;
288							}
289							else {
290								year += 1;
291							}
292
293							month = 1;
294						}
295
296						if (inc_day) {
297							day -= endday;
298						}
299						is_full_changed = true;
300					}
301					break;
302				case 40:
303					if (e.ctrlkey) {
304						year += 1;
305						is_full_changed = true;
306					}
307					else if (!enableaccessibility) {
308						day += 7;
309						if (day > endday) {
310							if (month >= 12) {
311								month = 1;
312
313								if (year >= 9999) {
314									year = 0;
315								}
316								else {
317									year += 1;
318								}
319							}
320							else {
321								month += 1;
322							}
323
324							day -= endday;
325						}
326					}
327					break;
328			}
329
330			year = nexacro._toString(year).padLeft(4, "0");
331			month = nexacro._toString(month).padLeft(2, "0");
332			day = nexacro._toString(day).padLeft(2, "0");
333			this._setValue(year + month + day);
334			if (nexacro._enableaccessibility) {
335				if (is_full_changed) {
336					var item = this.body._getDayItem(this._selected_day);
337					item._setAccessibilityLabel(year + " " + month + " " + day);
338				}
339				var calendar = this.parent;
340				if (calendar) {
341					var calendaredit = calendar.calendaredit;
342					calendaredit._setAccessibilityLabel(is_full_changed ? year + " " + month + " " + day : day);
343				}
344			}
345		}
346		if (enableaccessibility) {
347			if (keycode == 13) {
348				this.on_fire_ondayclick(obj);
349			}
350			else if (keycode == 27) {
351				this.parent._closePopup();
352			}
353		}
354		else if (!(obj instanceof nexacro._CalendarEditControl)) {
355			this.on_fire_ondayclick(obj);
356		}
357	};
358
359	_pDatePickerControl.on_lbuttondown_basic_action = function (elem, button, alt_key, ctrl_key, shift_key, canvasX, canvasY, screenX, screenY, refer_comp) {
360		var control_name = refer_comp.name;
361		if (control_name == "head" || control_name == "prevbutton" || control_name == "nextbutton" || 
362			control_name == "body" || control_name == "weekband" || control_name.indexOf("weekitem") > -1 || control_name.indexOf("dayitem") > -1) {
363			this._refreshSpindate();
364		}
365	};
366
367	_pDatePickerControl.on_touchend_basic_action = function (touch_manager, touchinfos, changedtouchinfos, refer_comp) {
368		var control_name = refer_comp.name;
369		if (control_name == "head" || control_name == "prevbutton" || control_name == "nextbutton" || 
370			control_name == "body" || control_name == "weekband" || control_name.indexOf("weekitem") > -1 || control_name.indexOf("dayitem") > -1) {
371			this._refreshSpindate();
372		}
373	};
374
375	_pDatePickerControl.on_fire_oncloseup = function (obj) {
376		if (this.oncloseup && this.oncloseup._has_handlers) {
377			return this.oncloseup._fireEvent(this);
378		}
379		return false;
380	};
381
382	_pDatePickerControl.on_fire_ondayclick = function (obj, e) {
383		if (this.ondayclick && this.ondayclick._has_handlers) {
384			if (!e) {
385				var item = this.body._getDayItem(this._selected_day);
386				e = new nexacro.CalendarDayClickEventInfo(item, "ondayclick", this._value);
387			}
388			return this.ondayclick._fireEvent(this, e);
389		}
390		return false;
391	};
392
393
394	_pDatePickerControl._setValue = function (v) {
395		if (this._value != v) {
396			this._value = v;
397			this.on_apply_value(v);
398		}
399	};
400
401	_pDatePickerControl.on_apply_value = function (value) {
402		var year = value.substr(0, 4);
403		var month = value.substr(4, 2);
404		var day = value.substr(6, 2);
405
406		this._selected_year = year;
407		this._selected_month = month;
408		this._selected_day = day;
409
410		var head = this.head;
411		if (head) {
412			head._setDate(year, month);
413			head._recalcLayout();
414		}
415
416		var body = this.body;
417		if (body) {
418			body._setDate(year, month, day);
419		}
420	};
421
422	_pDatePickerControl._setHeadformatText = function () {
423		var head = this.head;
424		if (head) {
425			head._setDate(head._date.str_year, head._date.str_month);
426			head._recalcLayout();
427		}
428	};
429
430	_pDatePickerControl._setWeekformatText = function () {
431		var body = this.body;
432		if (body) {
433			body._setWeekformatText();
434		}
435	};
436
437	_pDatePickerControl._getInnerDataset = function () {
438		var calendar = this.parent;
439		if (calendar) {
440			return calendar.getInnerDataset();
441		}
442
443		return null;
444	};
445
446	_pDatePickerControl._getBackgroundcolumn = function () {
447		var calendar = this.parent;
448		if (calendar) {
449			return calendar.backgroundcolumn;
450		}
451
452		return null;
453	};
454
455	_pDatePickerControl._getBordercolumn = function () {
456		var calendar = this.parent;
457		if (calendar) {
458			return calendar.bordercolumn;
459		}
460
461		return null;
462	};
463
464	_pDatePickerControl._getDatecolumn = function () {
465		var calendar = this.parent;
466		if (calendar) {
467			return calendar.datecolumn;
468		}
469
470		return null;
471	};
472
473	_pDatePickerControl._getTextcolorcolumn = function () {
474		var calendar = this.parent;
475		if (calendar) {
476			return calendar.textcolorcolumn;
477		}
478
479		return null;
480	};
481
482	_pDatePickerControl._getHeadheight = function () {
483		var calendar = this.parent;
484		if (calendar) {
485			return calendar.headheight;
486		}
487
488		return null;
489	};
490
491	_pDatePickerControl._getDaysize = function () {
492		var calendar = this.parent;
493		if (calendar) {
494			return calendar.daysize;
495		}
496
497		return "";
498	};
499
500	_pDatePickerControl._getHeadformat = function () {
501		var calendar = this.parent;
502		if (calendar) {
503			return calendar.headformat;
504		}
505
506		return null;
507	};
508
509	_pDatePickerControl._getWeekformat = function () {
510		var calendar = this.parent;
511		if (calendar) {
512			return calendar.weekformat;
513		}
514
515		return null;
516	};
517
518	_pDatePickerControl._getUsetrailingday = function () {
519		var calendar = this.parent;
520		if (calendar) {
521			return calendar.usetrailingday;
522		}
523
524		return false;
525	};
526
527	_pDatePickerControl._getShowmonthspin = function () {
528		var calendar = this.parent;
529		if (calendar) {
530			return calendar.showmonthspin;
531		}
532
533		return false;
534	};
535
536	_pDatePickerControl._getShowyearspin = function () {
537		var calendar = this.parent;
538		if (calendar) {
539			return calendar.showyearspin;
540		}
541
542		return false;
543	};
544
545	_pDatePickerControl._getCurrentDate = function () {
546		var calendar = this.parent;
547		if (calendar) {
548			return calendar._getCurrentDate();
549		}
550
551		return "";
552	};
553
554	_pDatePickerControl._getEndDay = function (year, month) {
555		var calendar = this.parent;
556		if (calendar) {
557			return calendar._getEndDay(year, month);
558		}
559
560		return "";
561	};
562
563	_pDatePickerControl._recalcLayout = function () {
564		if (this._is_created_contents) {
565			var headheight = this._getHeadheight();
566
567			var client_width = this._getClientWidth();
568			var client_height = this._getClientHeight();
569
570			if (!headheight) {
571				headheight = client_height / 8;
572			}
573
574			var body_l = 0;
575			var body_t = 0 + headheight;
576			var body_w = client_width;
577			var body_h = client_height - headheight;
578
579			var head_l = 0;
580			var head_t = 0;
581			var head_w = client_width;
582			var head_h = headheight;
583
584			this.body.move(body_l, body_t, body_w, body_h, null, null);
585			this.head.move(head_l, head_t, head_w, head_h, null, null);
586		}
587	};
588
589	_pDatePickerControl._refreshSpindate = function () {
590		var head = this.head;
591		if (head) {
592			head._refreshSpindate();
593		}
594	};
595
596	_pDatePickerControl._refreshDay = function () {
597		var body = this.body;
598		if (body) {
599			body._refreshDay();
600		}
601	};
602
603	delete _pDatePickerControl;
604
605	nexacro._DatePickerHeadControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
606		nexacro.Component.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
607
608		this._date = {
609			str_year : "", 
610			str_month : "", 
611			int_year : 0, 
612			int_month : 0
613		};
614	};
615
616	var _pDatePickerHeadControl = nexacro._createPrototype(nexacro.Component, nexacro._DatePickerHeadControl);
617	nexacro._DatePickerHeadControl.prototype = _pDatePickerHeadControl;
618	_pDatePickerHeadControl._type_name = "DatePickerHeadControl";
619	_pDatePickerHeadControl._is_subcontrol = true;
620
621
622	_pDatePickerHeadControl.prevbutton = null;
623	_pDatePickerHeadControl.nextbutton = null;
624	_pDatePickerHeadControl.yearstatic = null;
625	_pDatePickerHeadControl.monthstatic = null;
626	_pDatePickerHeadControl.yearspin = null;
627	_pDatePickerHeadControl.monthspin = null;
628
629
630
631
632	_pDatePickerHeadControl._use_readonly_status = true;
633
634
635	_pDatePickerHeadControl._event_list = {
636		"onclick" : 1, 
637		"onspin" : 1
638	};
639
640	_pDatePickerHeadControl.on_create_contents = function () {
641		var prevbutton = this.prevbutton = new nexacro.Button("prevbutton", 0, 0, 0, 0, null, null, null, null, null, null, this);
642		var nextbutton = this.nextbutton = new nexacro.Button("nextbutton", 0, 0, 0, 0, null, null, null, null, null, null, this);
643		var yearstatic = this.yearstatic = new nexacro.Static("yearstatic", 0, 0, 0, 0, null, null, null, null, null, null, this);
644		var monthstatic = this.monthstatic = new nexacro.Static("monthstatic", 0, 0, 0, 0, null, null, null, null, null, null, this);
645		var yearspin = this.yearspin = new nexacro._YearSpinControl("yearspin", 0, 0, 0, 0, null, null, null, null, null, null, this);
646		var monthspin = this.monthspin = new nexacro._MonthSpinControl("monthspin", 0, 0, 0, 0, null, null, null, null, null, null, this);
647
648		prevbutton._setControl();
649		nextbutton._setControl();
650		yearstatic._setControl();
651		monthstatic._setControl();
652		yearspin._setControl();
653		monthspin._setControl();
654
655		prevbutton.createComponent(true);
656		nextbutton.createComponent(true);
657		yearstatic.createComponent(true);
658		monthstatic.createComponent(true);
659		yearspin.createComponent(true);
660		monthspin.createComponent(true);
661
662		yearspin.set_visible(false);
663		yearspin.set_min("0");
664		yearspin.set_max("9999");
665		yearspin.set_circulation(true);
666		yearspin.set_displaycomma(false);
667
668		monthspin.set_visible(false);
669		monthspin.set_min("1");
670		monthspin.set_max("12");
671		monthspin.set_circulation(true);
672		monthspin.set_displaycomma(false);
673	};
674
675	_pDatePickerHeadControl.on_created_contents = function (win) {
676		this.on_apply_prop_enable(this.enable);
677
678		var prevbutton = this.prevbutton;
679		var nextbutton = this.nextbutton;
680		var yearstatic = this.yearstatic;
681		var monthstatic = this.monthstatic;
682		var yearspin = this.yearspin;
683		var monthspin = this.monthspin;
684
685		if (nexacro._isTouchInteraction && nexacro._SupportTouch) {
686			yearstatic._setEventHandler("onclick", this._on_static_mobile_onclick, this);
687			monthstatic._setEventHandler("onclick", this._on_static_mobile_onclick, this);
688		}
689		yearstatic._setEventHandler("onlbuttondown", this._on_static_onlbuttondown, this);
690		monthstatic._setEventHandler("onlbuttondown", this._on_static_onlbuttondown, this);
691		prevbutton._setEventHandler("onclick", this._on_button_onprevclick, this);
692		nextbutton._setEventHandler("onclick", this._on_button_onnextclick, this);
693		yearspin._setEventHandler("onspin", this._on_spin_onspin, this);
694		monthspin._setEventHandler("onspin", this._on_spin_onspin, this);
695		yearspin._setEventHandler("onkeydown", this._on_spin_onkeydown, this);
696		monthspin._setEventHandler("onkeydown", this._on_spin_onkeydown, this);
697
698		prevbutton.on_created(win);
699		nextbutton.on_created(win);
700		yearstatic.on_created(win);
701		monthstatic.on_created(win);
702		yearspin.on_created(win);
703		monthspin.on_created(win);
704
705		yearspin.set_value(this._date.str_year);
706		monthspin.set_value(this._date.str_month);
707
708		if (this.parent._is_popupcontains) {
709			yearspin._setEnableView(false);
710			monthspin._setEnableView(false);
711		}
712		this._refreshSpindate();
713	};
714
715	_pDatePickerHeadControl.on_create_contents_command = function () {
716		this._refreshSpindate();
717
718		var str = "";
719		if (this.prevbutton) {
720			str += this.prevbutton.createCommand();
721		}
722		if (this.nextbutton) {
723			str += this.nextbutton.createCommand();
724		}
725		if (this.yearstatic) {
726			str += this.yearstatic.createCommand();
727		}
728		if (this.monthstatic) {
729			str += this.monthstatic.createCommand();
730		}
731		if (this.yearspin) {
732			str += this.yearspin.createCommand();
733		}
734		if (this.monthspin) {
735			str += this.monthspin.createCommand();
736		}
737
738		return str;
739	};
740
741	_pDatePickerHeadControl.on_attach_contents_handle = function (win) {
742		var prevbutton = this.prevbutton;
743		var nextbutton = this.nextbutton;
744		var yearstatic = this.yearstatic;
745		var monthstatic = this.monthstatic;
746		var yearspin = this.yearspin;
747		var monthspin = this.monthspin;
748
749		if (nexacro._isTouchInteraction && nexacro._SupportTouch) {
750			yearstatic._setEventHandler("onclick", this._on_static_mobile_onclick, this);
751			monthstatic._setEventHandler("onclick", this._on_static_mobile_onclick, this);
752		}
753
754		yearstatic._setEventHandler("onlbuttondown", this._on_static_onlbuttondown, this);
755		monthstatic._setEventHandler("onlbuttondown", this._on_static_onlbuttondown, this);
756		prevbutton._setEventHandler("onclick", this._on_button_onprevclick, this);
757		nextbutton._setEventHandler("onclick", this._on_button_onnextclick, this);
758		yearspin._setEventHandler("onspin", this._on_spin_onspin, this);
759		monthspin._setEventHandler("onspin", this._on_spin_onspin, this);
760		yearspin._setEventHandler("onkeydown", this._on_spin_onkeydown, this);
761		monthspin._setEventHandler("onkeydown", this._on_spin_onkeydown, this);
762
763		prevbutton.attachHandle(win);
764		nextbutton.attachHandle(win);
765		yearstatic.attachHandle(win);
766		monthstatic.attachHandle(win);
767		yearspin.attachHandle(win);
768		monthspin.attachHandle(win);
769
770		yearspin.set_value(this._date.str_year);
771		monthspin.set_value(this._date.str_month);
772
773		if (this.parent._is_popupcontains) {
774			yearspin._setEnableView(false);
775			monthspin._setEnableView(false);
776		}
777	};
778
779	_pDatePickerHeadControl.on_destroy_contents = function () {
780		this._date = null;
781
782		if (this.prevbutton) {
783			this.prevbutton.destroy();
784			this.prevbutton = null;
785		}
786		if (this.nextbutton) {
787			this.nextbutton.destroy();
788			this.nextbutton = null;
789		}
790		if (this.yearstatic) {
791			this.yearstatic.destroy();
792			this.yearstatic = null;
793		}
794		if (this.monthstatic) {
795			this.monthstatic.destroy();
796			this.monthstatic = null;
797		}
798		if (this.yearspin) {
799			this.yearspin.destroy();
800			this.yearspin = null;
801		}
802		if (this.monthspin) {
803			this.monthspin.destroy();
804			this.monthspin = null;
805		}
806	};
807
808	_pDatePickerHeadControl.on_change_containerRect = function (widht, height) {
809		this._recalcLayout();
810	};
811
812	_pDatePickerHeadControl.on_apply_prop_enable = function (v) {
813		if (this.prevbutton) {
814			this.prevbutton._setEnable(v);
815		}
816		if (this.nextbutton) {
817			this.nextbutton._setEnable(v);
818		}
819		if (this.yearstatic) {
820			this.yearstatic._setEnable(v);
821		}
822		if (this.monthstatic) {
823			this.monthstatic._setEnable(v);
824		}
825		if (this.yearspin) {
826			this.yearspin._setEnable(v);
827		}
828		if (this.monthspin) {
829			this.monthspin._setEnable(v);
830		}
831	};
832
833	_pDatePickerHeadControl.set_readonly = function (v) {
834		v = nexacro._toBoolean(v);
835		if (this.readonly != v) {
836			this.readonly = v;
837			this.on_apply_readonly(v);
838		}
839	};
840
841	_pDatePickerHeadControl.on_apply_readonly = function (readonly) {
842		this._changeStatus("readonly", readonly);
843
844		var control_elem = this.getElement();
845		if (control_elem) {
846			var yearspin = this.yearspin;
847			if (yearspin) {
848				yearspin.set_readonly(readonly);
849			}
850			var monthspin = this.monthspin;
851			if (monthspin) {
852				monthspin.set_readonly(readonly);
853			}
854		}
855	};
856
857	_pDatePickerHeadControl._on_static_mobile_onclick = function (obj, e) {
858		var yearstatic = this.yearstatic;
859		var monthstatic = this.monthstatic;
860		var yearspin = this.yearspin;
861		var monthspin = this.monthspin;
862
863		var control_name = obj.name;
864		if (control_name == "yearstatic") {
865			yearstatic.set_visible(false);
866			yearspin.set_visible(true);
867		}
868		else if (control_name == "monthstatic") {
869			monthstatic.set_visible(false);
870			monthspin.set_visible(true);
871		}
872	};
873
874	_pDatePickerHeadControl._on_static_onlbuttondown = function (obj, e) {
875		var yearstatic = this.yearstatic;
876		var monthstatic = this.monthstatic;
877		var yearspin = this.yearspin;
878		var monthspin = this.monthspin;
879
880		var comp_name = obj.name;
881		if (comp_name == "yearstatic") {
882			yearstatic.set_visible(false);
883			yearspin.set_visible(true);
884		}
885		else if (comp_name == "monthstatic") {
886			monthstatic.set_visible(false);
887			monthspin.set_visible(true);
888		}
889	};
890
891	_pDatePickerHeadControl._on_button_onprevclick = function (obj, e) {
892		if (!this.enable || this.readonly) {
893			return false;
894		}
895
896		var year = this._date.int_year;
897		var month = this._date.int_month;
898		if ((month -= 1) <= 0) {
899			month = 12;
900			if ((year -= 1) < 0) {
901				year = 9999;
902			}
903		}
904
905		this._setDate(year, month);
906		this._refreshSpindate();
907
908		this.on_fire_onclick(e.button, e.alt_key, e.ctrl_key, e.shift_key, e.screenX, e.screenY, e.canvasX, e.canvasY, e.clientX, e.clientY, this, obj);
909	};
910
911	_pDatePickerHeadControl._on_button_onnextclick = function (obj, e) {
912		if (!this.enable || this.readonly) {
913			return false;
914		}
915
916		var year = this._date.int_year;
917		var month = this._date.int_month;
918		if ((month += 1) > 12) {
919			month = 1;
920			if ((year += 1) > 9999) {
921				year = 0;
922			}
923		}
924
925		this._setDate(year, month);
926		this._refreshSpindate();
927
928		this.on_fire_onclick(e.button, e.alt_key, e.ctrl_key, e.shift_key, e.screenX, e.screenY, e.canvasX, e.canvasY, e.clientX, e.clientY, this, obj);
929	};
930
931	_pDatePickerHeadControl._on_spin_onspin = function (obj, e) {
932		var v = nexacro._toString(e.postvalue);
933
934		var year = this._date.str_year;
935		var month = this._date.str_month;
936
937		var control_name = obj.name;
938		if (control_name == "yearspin") {
939			year = v;
940		}
941		else if (control_name == "monthspin") {
942			month = v;
943		}
944
945		this._setDate(year, month);
946		this.on_fire_onspin(obj, e);
947	};
948
949	_pDatePickerHeadControl._on_spin_onkeydown = function (obj, e) {
950		if (e.keycode == nexacro.Event.KEY_ENTER) {
951			var year = this._date.str_year;
952			var month = this._date.str_month;
953
954			var control_name = obj.name;
955			if (control_name == "yearspin") {
956				year = obj.text;
957			}
958			else if (control_name == "monthspin") {
959				month = obj.text;
960			}
961
962			this._setDate(year, month);
963			this.on_fire_onspin(obj, e);
964		}
965	};
966
967	_pDatePickerHeadControl.on_fire_onspin = function (obj, preText, preValue, postText, postValue, isUp) {
968		if (this.onspin && this.onspin._has_handlers) {
969			var evt = new nexacro.SpinEventInfo(obj, "onspin", preText, preValue, postText, postValue, isUp);
970			return this.onspin._fireEvent(this, evt);
971		}
972		return true;
973	};
974
975	_pDatePickerHeadControl._refreshSpindate = function () {
976		var yearstatic = this.yearstatic;
977		var monthstatic = this.monthstatic;
978		var yearspin = this.yearspin;
979		var monthspin = this.monthspin;
980		if (yearstatic || monthstatic) {
981			var bShowyear = this._getShowyearspin();
982			var bShowmonth = this._getShowmonthspin();
983			if (bShowyear) {
984				if (bShowmonth) {
985					yearstatic.set_visible(false);
986					monthstatic.set_visible(false);
987					yearspin.set_visible(true);
988					monthspin.set_visible(true);
989				}
990				else {
991					yearstatic.set_visible(false);
992					monthstatic.set_visible(true);
993					yearspin.set_visible(true);
994					monthspin.set_visible(false);
995				}
996			}
997			else {
998				if (bShowmonth) {
999					yearstatic.set_visible(true);
1000					monthstatic.set_visible(false);
1001					yearspin.set_visible(false);
1002					monthspin.set_visible(true);
1003				}
1004				else {
1005					yearstatic.set_visible(true);
1006					monthstatic.set_visible(true);
1007					yearspin.set_visible(false);
1008					monthspin.set_visible(false);
1009				}
1010			}
1011		}
1012	};
1013
1014	_pDatePickerHeadControl._recalcLayout = function () {
1015		if (this._is_created_contents) {
1016			var date = this._date;
1017
1018			var headformat = this._getHeadformat();
1019
1020			var client_w = this._getClientWidth();
1021			var client_h = this._getClientHeight();
1022
1023			var prevbutton = this.prevbutton;
1024			if (prevbutton) {
1025				prevbutton.move(0, 0, client_h, client_h, null, null);
1026			}
1027
1028			var nextbutton = this.nextbutton;
1029			if (nextbutton) {
1030				nextbutton.move(client_w - client_h, 0, client_h, client_h, null, null);
1031			}
1032
1033			var year_size = 0, year_l = 0, year_w = 0, year_h = 0;
1034			var yearstatic = this.yearstatic;
1035			if (yearstatic) {
1036				year_size = yearstatic._on_getFitSize();
1037				year_w = year_size[0];
1038			}
1039
1040			var month_size = 0, month_l = 0, month_w = 0, month_h = 0;
1041			var monthstatic = this.monthstatic;
1042			if (monthstatic) {
1043				month_size = monthstatic._on_getFitSize();
1044				month_w = month_size[0];
1045			}
1046
1047			var offset_x = ((client_w / 2) - ((year_w + month_w) / 2));
1048
1049			if (headformat == "MM.yyyy") {
1050				month_l = offset_x;
1051				year_l = offset_x + month_w;
1052			}
1053			else {
1054				year_l = offset_x;
1055				month_l = offset_x + year_w;
1056			}
1057
1058			if (yearstatic) {
1059				yearstatic.move(year_l, 0, year_w, client_h, null, null);
1060			}
1061
1062			if (monthstatic) {
1063				monthstatic.move(month_l, 0, month_w, client_h, null, null);
1064			}
1065
1066			year_size = year_l = year_w = year_h = 0;
1067			var yearspin = this.yearspin;
1068			if (yearspin) {
1069				year_size = this._getSpinControlSize("year");
1070				year_w = year_size + client_h;
1071			}
1072
1073			month_size = month_l = month_w = month_h = 0;
1074			var monthspin = this.monthspin;
1075			if (monthspin) {
1076				month_size = this._getSpinControlSize("month");
1077				month_w = month_size + client_h;
1078			}
1079
1080			offset_x = ((client_w / 2) - ((year_w + month_w) / 2));
1081
1082			if (headformat == "MM.yyyy") {
1083				month_l = offset_x;
1084				year_l = offset_x + month_w;
1085			}
1086			else {
1087				year_l = offset_x;
1088				month_l = offset_x + year_w;
1089			}
1090
1091			if (yearspin) {
1092				yearspin.move(year_l, 0, year_w, client_h, null, null);
1093			}
1094
1095			if (monthspin) {
1096				monthspin.move(month_l, 0, month_w, client_h, null, null);
1097			}
1098		}
1099	};
1100
1101	_pDatePickerHeadControl._setDate = function (year, month) {
1102		var date = this._date;
1103		if (date) {
1104			date.str_year = nexacro._toString(year).padLeft(4, "0");
1105			date.str_month = nexacro._toString(month).padLeft(2, "0");
1106			date.int_year = +year;
1107			date.int_month = +month;
1108		}
1109
1110		var yearstatic = this.yearstatic;
1111		var yearspin = this.yearspin;
1112		var monthstatic = this.monthstatic;
1113		var monthspin = this.monthspin;
1114
1115		if (this._getHeadformat() == "MM.yyyy") {
1116			yearstatic.set_text(date.str_year);
1117			monthstatic.set_text(date.str_month + ".");
1118		}
1119		else {
1120			yearstatic.set_text(date.str_year + ".");
1121			monthstatic.set_text(date.str_month);
1122		}
1123
1124		yearspin.set_value(date.str_year);
1125		monthspin.set_value(date.str_month);
1126	};
1127
1128	_pDatePickerHeadControl._getHeadheight = function () {
1129		var datepicker = this.parent;
1130		if (datepicker) {
1131			return datepicker._getHeadheight();
1132		}
1133
1134		return null;
1135	};
1136
1137	_pDatePickerHeadControl._getHeadformat = function () {
1138		var datepicker = this.parent;
1139		if (datepicker) {
1140			return datepicker._getHeadformat();
1141		}
1142
1143		return null;
1144	};
1145
1146	_pDatePickerHeadControl._getShowyearspin = function () {
1147		var calendar = this.parent;
1148		if (calendar) {
1149			return calendar._getShowyearspin();
1150		}
1151
1152		return null;
1153	};
1154
1155	_pDatePickerHeadControl._getShowmonthspin = function () {
1156		var datepicker = this.parent;
1157		if (datepicker) {
1158			return datepicker._getShowmonthspin();
1159		}
1160
1161		return null;
1162	};
1163
1164	_pDatePickerHeadControl._getSpinControlSize = function (type) {
1165		var control;
1166		switch (type) {
1167			case "year":
1168				control = this.yearspin;
1169				break;
1170			case "month":
1171				control = this.monthspin;
1172				break;
1173		}
1174
1175		var total_w = 0;
1176		if (control) {
1177			var border = control._getCurrentStyleBorder();
1178			if (border) {
1179				total_w += border._getBorderWidth();
1180			}
1181
1182			var padding = control._getCurrentStylePadding();
1183			if (padding) {
1184				total_w += padding.left + padding.right;
1185			}
1186
1187			var spinedit = control.spinedit;
1188			if (spinedit) {
1189				var tmp = spinedit.text;
1190				if (tmp.length == 1) {
1191					spinedit.text += ".0";
1192				}
1193				else {
1194					spinedit.text += ".";
1195				}
1196				total_w += spinedit._on_getFitSize()[0];
1197				spinedit.text = tmp;
1198			}
1199		}
1200
1201		return total_w;
1202	};
1203
1204	nexacro._DatePickerBodyControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
1205		nexacro.Component.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
1206
1207		this._weekitems = [];
1208		this._dayitems = [];
1209		this._changedDays = [];
1210
1211		this._date = {
1212			str_year : "", 
1213			str_month : "", 
1214			str_day : "", 
1215			int_year : 0, 
1216			int_month : 0, 
1217			int_day : 0
1218		};
1219	};
1220
1221	var _pDatePickerBodyControl = nexacro._createPrototype(nexacro.Component, nexacro._DatePickerBodyControl);
1222	nexacro._DatePickerBodyControl.prototype = _pDatePickerBodyControl;
1223	_pDatePickerBodyControl._type_name = "DatePickerBodyControl";
1224
1225
1226	_pDatePickerBodyControl.weekband = null;
1227
1228
1229	_pDatePickerBodyControl._preday = "";
1230	_pDatePickerBodyControl._maxWeek = 7;
1231	_pDatePickerBodyControl._maxDay = 42;
1232
1233
1234	_pDatePickerBodyControl._is_subcontrol = true;
1235	_pDatePickerBodyControl._use_readonly_status = true;
1236	_pDatePickerBodyControl._is_locale_control = true;
1237
1238
1239	_pDatePickerBodyControl._event_list = {
1240		"onclick" : 1, 
1241		"ondayclick" : 1, 
1242		"onkeydown" : 1
1243	};
1244
1245	_pDatePickerBodyControl.on_create_contents = function () {
1246		var control_elem = this.getElement();
1247		if (control_elem) {
1248			var weekband = this.weekband = new nexacro.Static("weekband", 0, 0, 0, 0, null, null, null, null, null, null, this);
1249			weekband._setControl();
1250			weekband.createComponent(true);
1251
1252			var weekformat = this._getWeekformat();
1253			var weeks = this._weekitems;
1254			var days = this._dayitems;
1255			var maxWeek = this._maxWeek;
1256			var maxDay = this._maxDay;
1257			var weekstatic, daystatic;
1258			for (var i = 0; i < maxWeek; i++) {
1259				weekstatic = weeks[i] = new nexacro._DatePickerWeekItemControl("weekitem" + i, 0, 0, 0, 0, null, null, null, null, null, null, this);
1260				weekstatic.set_text(weekformat[i]);
1261				weekstatic._setDaysOfWeek(i % 7);
1262
1263				weekstatic.createComponent(true);
1264			}
1265
1266			for (i = 0; i < maxDay; i++) {
1267				daystatic = days[i] = new nexacro._DatePickerDayItemControl("dayitem" + i, 0, 0, 0, 0, null, null, null, null, null, null, this);
1268				daystatic._setDaysOfWeek(i % 7);
1269
1270				daystatic.createComponent(true);
1271			}
1272		}
1273	};
1274
1275	_pDatePickerBodyControl.on_created_contents = function (win) {
1276		var control_elem = this.getElement();
1277		if (control_elem) {
1278			var weeks = this._weekitems;
1279			var days = this._dayitems;
1280			var maxWeek = this._maxWeek;
1281			var maxDay = this._maxDay;
1282
1283			this.weekband.on_created(win);
1284
1285			for (var i = 0; i < maxWeek; i++) {
1286				weeks[i].on_created(win);
1287			}
1288			for (i = 0; i < maxDay; i++) {
1289				days[i]._setEventHandler("onclick", this._on_dayitem_ondayclick, this);
1290				days[i].on_created(win);
1291			}
1292		}
1293	};
1294
1295	_pDatePickerBodyControl.on_create_contents_command = function () {
1296		var weekband = this.weekband;
1297		var weeks = this._weekitems;
1298		var days = this._dayitems;
1299		var maxWeek = this._maxWeek;
1300		var maxDay = this._maxDay;
1301
1302		var str = "";
1303		str += weekband.createCommand();
1304		for (var i = 0; i < maxWeek; i++) {
1305			str += weeks[i].createCommand();
1306		}
1307
1308		for (i = 0; i < maxDay; i++) {
1309			str += days[i].createCommand();
1310		}
1311
1312		return str;
1313	};
1314
1315	_pDatePickerBodyControl.on_attach_contents_handle = function (win) {
1316		var weekband = this.weekband;
1317		var weeks = this._weekitems;
1318		var days = this._dayitems;
1319		var maxWeek = this._maxWeek;
1320		var maxDay = this._maxDay;
1321
1322		weekband.attachHandle(win);
1323
1324		for (var i = 0; i < maxWeek; i++) {
1325			weeks[i].attachHandle(win);
1326		}
1327		for (i = 0; i < maxDay; i++) {
1328			days[i]._setEventHandler("onclick", this._on_dayitem_ondayclick, this);
1329			days[i].attachHandle(win);
1330		}
1331	};
1332
1333	_pDatePickerBodyControl.on_destroy_contents = function () {
1334		if (this.weekband) {
1335			this.weekband.destroy();
1336			this.weekband = null;
1337		}
1338
1339		var weeks = this._weekitems;
1340		var days = this._dayitems;
1341		var maxWeek = this._maxWeek;
1342		var maxDay = this._maxDay;
1343
1344		for (var i = 0; i < maxWeek; i++) {
1345			weeks[i].destroy();
1346		}
1347
1348		for (i = 0; i < maxDay; i++) {
1349			days[i].destroy();
1350		}
1351
1352		this._weekitems = null;
1353		this._dayitems = null;
1354		this._changedDays = null;
1355		this._date = null;
1356	};
1357
1358	_pDatePickerBodyControl.on_change_containerRect = function (width, height) {
1359		this._recalcLayout();
1360	};
1361
1362	_pDatePickerBodyControl.on_apply_prop_enable = function (enable) {
1363		var i = 0;
1364		var weeks = this._weekitems;
1365		var days = this._dayitems;
1366		var maxWeek = this._maxWeek;
1367		var maxDay = this._maxDay;
1368
1369		if (this.weekband) {
1370			this.weekband._setEnable(enable);
1371		}
1372
1373		for (i = 0; i < maxWeek; i++) {
1374			weeks[i]._setEnable(enable);
1375		}
1376
1377		for (i = 0; i < maxDay; i++) {
1378			days[i]._setEnable(enable);
1379		}
1380	};
1381
1382	_pDatePickerBodyControl.set_readonly = function (v) {
1383		v = nexacro._toBoolean(v);
1384		if (this.readonly != v) {
1385			this.readonly = v;
1386			this.on_apply_readonly(v);
1387		}
1388	};
1389
1390	_pDatePickerBodyControl.on_apply_readonly = function (readonly) {
1391		this._changeStatus("readonly", readonly);
1392
1393		var weeks = this._weekitems;
1394		var days = this._dayitems;
1395		var maxWeek = this._maxWeek;
1396		var maxDay = this._maxDay;
1397
1398		for (var i = 0; i < maxWeek; i++) {
1399			weeks[i].set_readonly(readonly);
1400		}
1401
1402		for (i = 0; i < maxDay; i++) {
1403			days[i].set_readonly(readonly);
1404		}
1405	};
1406
1407	_pDatePickerBodyControl._on_dayitem_ondayclick = function (obj, e) {
1408		this.on_fire_ondayclick(obj, e);
1409	};
1410
1411	_pDatePickerBodyControl.on_fire_ondayclick = function (obj, e) {
1412		if (this.ondayclick && this.ondayclick._has_handlers) {
1413			return this.ondayclick._fireEvent(this, e);
1414		}
1415		return false;
1416	};
1417
1418	_pDatePickerBodyControl._recalcLayout = function () {
1419		if (this._is_created_contents) {
1420			var weeks = this._weekitems;
1421			var days = this._dayitems;
1422			var maxWeek = this._maxWeek;
1423			var maxDay = this._maxDay;
1424
1425			var client_w = this._getClientWidth();
1426			var client_h = this._getClientHeight();
1427			var client_l = this._getClientLeft();
1428			var client_t = this._getClientTop();
1429
1430			var daysize = this._getDaysize();
1431
1432			var item_w = daysize.width;
1433			var item_h = daysize.height;
1434
1435			var drawWidth_daysize = item_w * 7;
1436			var drawHeight_daysize = item_h * 7;
1437
1438			var blankWidth = 0;
1439			var blankHeight = 0;
1440			if (drawWidth_daysize < client_w) {
1441				blankWidth = (client_w - drawWidth_daysize) / 14;
1442			}
1443			if (drawHeight_daysize < client_h) {
1444				blankHeight = (client_h - drawHeight_daysize) / 8;
1445			}
1446
1447			var week_l = client_l + blankWidth;
1448			var week_t = client_t + (blankHeight / 2);
1449
1450			this.weekband.move(client_l, week_t, client_w, item_h, null, null);
1451			var i;
1452			for (i = 0; i < maxWeek; i++) {
1453				weeks[i].move(week_l, week_t, item_w, item_h, null, null);
1454				week_l = week_l + item_w + (blankWidth * 2);
1455			}
1456
1457			var day_l = client_l + blankWidth;
1458			var day_t = week_t + item_h + blankHeight;
1459			for (i = 0; i < maxDay; i++) {
1460				days[i].move(day_l, day_t, item_w, item_h, null, null);
1461				day_l = day_l + item_w + (blankWidth * 2);
1462				if (((i + 1) % 7) == 0) {
1463					day_l = client_l + blankWidth;
1464					day_t = day_t + item_h + blankHeight;
1465				}
1466			}
1467		}
1468	};
1469
1470	_pDatePickerBodyControl._refreshDay = function () {
1471		var day, control_elem = this.getElement();
1472		if (control_elem) {
1473			var dayInfo = {
1474			};
1475			var trailingdayinfo = {
1476			};
1477
1478			var date = this._date;
1479			var year = date.int_year;
1480			var month = date.int_month;
1481			day = date.int_day;
1482
1483			var tempDate = new Date(year, month - 1, 1);
1484
1485			if (year < 100) {
1486				tempDate.setFullYear(year);
1487			}
1488
1489			var N = nexacro.Calendar.EndDayNormal;
1490			var L = nexacro.Calendar.EndDayLeap;
1491
1492			var firstDay = tempDate.getDay();
1493			var endDay = this._getLeapYear(year) ? L[month - 1] : N[month - 1];
1494
1495			var usetrailingday = this._getUsetrailingday();
1496			if (usetrailingday) {
1497				trailingdayinfo = this._getUseTrailingDayInfo(year, month, tempDate, endDay);
1498			}
1499
1500			var days = this._dayitems;
1501			var maxDay = this._maxDay;
1502			var dayCount = 1;
1503			var daysofweek = -1;
1504
1505			for (var i = 0; i < maxDay; i++) {
1506				if (firstDay <= i && endDay >= dayCount) {
1507					dayInfo = this._getDayInfo(dayCount, false, true, year, month);
1508
1509					this._setDayItemInfo(days[i], dayInfo.text, dayInfo.visible, dayInfo.year, dayInfo.month, dayInfo.trailingday);
1510
1511					daysofweek = i % 7;
1512					if (daysofweek == 0) {
1513						days[i]._changeUserStatus("sunday", true);
1514					}
1515					else if (daysofweek == 6) {
1516						days[i]._changeUserStatus("saturday", true);
1517					}
1518					else {
1519						if (this._isToday(dayInfo.day)) {
1520							days[i]._changeUserStatus("today", true);
1521						}
1522						else {
1523							days[i]._changeUserStatus("day", true);
1524						}
1525					}
1526
1527					dayCount++;
1528				}
1529				else {
1530					if (usetrailingday) {
1531						if (trailingdayinfo.idx >= 0) {
1532							dayInfo = this._getDayInfo(trailingdayinfo.pre_endDay - trailingdayinfo.idx, true, true, trailingdayinfo.prev_year, trailingdayinfo.prev_month);
1533							trailingdayinfo.idx--;
1534						}
1535						else {
1536							dayInfo = this._getDayInfo(trailingdayinfo.next_beginDay, true, true, trailingdayinfo.next_year, trailingdayinfo.next_month);
1537							trailingdayinfo.next_beginDay++;
1538							trailingdayinfo.endWeek++;
1539						}
1540
1541						this._setDayItemInfo(days[i], dayInfo.text, dayInfo.visible, dayInfo.year, dayInfo.month, dayInfo.trailingday);
1542
1543						days[i]._changeUserStatus("trailingday", true);
1544					}
1545					else {
1546						dayInfo = this._getDayInfo("", false, false, "", "");
1547						this._setDayItemInfo(days[i], dayInfo.text, dayInfo.visible, dayInfo.year, dayInfo.month, dayInfo.trailingday);
1548					}
1549				}
1550			}
1551		}
1552
1553		this._initChangedDays();
1554
1555		var dataset = this._getInnerDataset();
1556		if (dataset) {
1557			this._setDatasetStyle(dataset);
1558		}
1559
1560		if (this._isSelectedDay(day)) {
1561			this._on_apply_day(true);
1562		}
1563		else {
1564			this._on_apply_day(false);
1565		}
1566
1567		this._setCalendarAccessibility();
1568	};
1569
1570	_pDatePickerBodyControl._on_apply_day = function (flag) {
1571		var preDay = this._preday;
1572		var currDay = this._date.str_day;
1573		var predayObj = this._getDayItem(preDay);
1574		var dayObj = this._getDayItem(currDay);
1575
1576		this._preday = currDay;
1577
1578		if (predayObj) {
1579			predayObj._changeUserStatus("selected", false);
1580			if (predayObj._daysofweek == 6) {
1581				predayObj._changeUserStatus("saturday", true);
1582			}
1583			else if (predayObj._daysofweek == 0) {
1584				predayObj._changeUserStatus("sunday", true);
1585			}
1586			else {
1587				predayObj._changeUserStatus("day", true);
1588			}
1589		}
1590
1591		if (dayObj) {
1592			if (flag) {
1593				dayObj._changeUserStatus("selected", true);
1594			}
1595			else {
1596				dayObj._changeUserStatus("selected", false);
1597				if (dayObj._daysofweek == 6) {
1598					dayObj._changeUserStatus("saturday", true);
1599				}
1600				else if (dayObj._daysofweek == 0) {
1601					dayObj._changeUserStatus("sunday", true);
1602				}
1603				else {
1604					dayObj._changeUserStatus("day", true);
1605				}
1606			}
1607		}
1608
1609		var currtDate = new Date();
1610		var today = currtDate.getDate();
1611
1612		if (this._isToday(today)) {
1613			today = nexacro._toString(today).padLeft(2, "0");
1614			var todatObj = this._getDayItem(today);
1615			if (todatObj) {
1616				todatObj._changeUserStatus("today", true);
1617			}
1618		}
1619	};
1620
1621	_pDatePickerBodyControl._initChangedDays = function () {
1622		var len = this._changedDays.length;
1623		for (var i = (len - 1); i >= 0; i--) {
1624			this._changedDays[i].set_background(null);
1625			this._changedDays[i].set_color(null);
1626			this._changedDays[i].set_border(null);
1627
1628			this._changedDays.pop();
1629		}
1630	};
1631
1632	_pDatePickerBodyControl._setDate = function (year, month, day) {
1633		var date = this._date;
1634		if (date.str_year != (year = year.padLeft(4, "0"))) {
1635			date.str_year = year;
1636			date.int_year = +year;
1637		}
1638		if (date.str_month != (month = month.padLeft(2, "0"))) {
1639			date.str_month = month;
1640			date.int_month = +month;
1641		}
1642		if (date.str_day != (day = day.padLeft(2, "0"))) {
1643			this._preday = date.str_day;
1644			date.str_day = day;
1645			date.int_day = +day;
1646		}
1647
1648		this._refreshDay();
1649	};
1650
1651	_pDatePickerBodyControl._setDayItemInfo = function (day, text, visible, year, month, trailingday) {
1652		day.set_text(text);
1653		day.set_wordWrap("none");
1654		day.set_visible(visible);
1655
1656		day._year = year;
1657		day._month = month;
1658		day._trailingday = trailingday;
1659	};
1660
1661	_pDatePickerBodyControl._setWeekformatText = function () {
1662		var control_elem = this.getElement();
1663		if (control_elem) {
1664			var weekformat = this._getWeekformat();
1665			var weeks = this._weekitems;
1666			var weeks_len = weeks.length;
1667
1668			for (var i = 0; i < weeks_len; i++) {
1669				weeks[i].set_text(weekformat[i]);
1670			}
1671		}
1672	};
1673
1674	_pDatePickerBodyControl._setDatasetStyle = function (ds) {
1675		var day_item, date;
1676		var day_items = this._dayitems;
1677		var maxDay = this._maxDay;
1678		var cols = this._getInnerDatasetColumns();
1679		var background, border, color;
1680
1681		var rowCount = ds.getRowCount();
1682		for (var i = 0; i < rowCount; i++) {
1683			date = ds.getColumn(i, cols.datecolumn);
1684
1685			for (var j = 0; j < maxDay; j++) {
1686				day_item = day_items[j];
1687				var currDate = day_item._year + day_item._month + day_item.text.padLeft(2, "0");
1688				if (currDate == date) {
1689					background = ds.getColumn(i, cols.backgroundcolumn);
1690					border = ds.getColumn(i, cols.bordercolumn);
1691					color = ds.getColumn(i, cols.textcolorcolumn);
1692
1693					if (background) {
1694						day_item.set_background(background);
1695					}
1696					if (border) {
1697						day_item.set_border(border);
1698					}
1699					if (color) {
1700						day_item.set_color(color);
1701					}
1702					this._changedDays[this._changedDays.length] = day_item;
1703				}
1704			}
1705		}
1706	};
1707
1708	_pDatePickerBodyControl._getLeapYear = function (year) {
1709		if ((year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0) {
1710			return true;
1711		}
1712		else {
1713			return false;
1714		}
1715	};
1716
1717	_pDatePickerBodyControl._getCurrentDate = function () {
1718		var datepicker = this.parent;
1719		if (datepicker) {
1720			return datepicker._getCurrentDate();
1721		}
1722
1723		return;
1724	};
1725
1726	_pDatePickerBodyControl._getWeekformat = function () {
1727		var datepicker = this.parent;
1728		if (datepicker) {
1729			var format = datepicker._getWeekformat();
1730			if (format) {
1731				return format.split(/\s+/);
1732			}
1733			else if (format === " ") {
1734				return [" ", " ", " ", " ", " ", " ", " "];
1735			}
1736			else {
1737				var locale = this._getLocale();
1738				var locale_info = nexacro.Locale.getLocaleInfo(locale);
1739				return locale_info.weekday_names_short;
1740			}
1741		}
1742
1743		return null;
1744	};
1745
1746	_pDatePickerBodyControl._getDaysize = function () {
1747		var width = 0;
1748		var height = 0;
1749
1750		var datepicker = this.parent;
1751		if (datepicker) {
1752			var size = datepicker._getDaysize();
1753			if (!size) {
1754				size = (this._getClientWidth() / 7) + " " + (this._getClientHeight() / 7);
1755			}
1756
1757			size = size.split(/\s+/);
1758
1759			width = +size[0];
1760			height = size[1] ? +size[1] : width;
1761		}
1762
1763		return {
1764			width : width, 
1765			height : height
1766		};
1767	};
1768
1769	_pDatePickerBodyControl._getDayInfo = function (text, trailingday, visible, year, month) {
1770		year = nexacro._toString(year);
1771		year = year ? year.padLeft(4, "0") : "";
1772
1773		month = nexacro._toString(month);
1774		month = month ? month.padLeft(2, "0") : "";
1775
1776		var day = nexacro._toString(text);
1777		day = day ? day.padLeft(2, "0") : "";
1778
1779		return {
1780			text : text, 
1781			trailingday : trailingday, 
1782			visible : visible, 
1783			year : year, 
1784			month : month, 
1785			day : day
1786		};
1787	};
1788
1789	_pDatePickerBodyControl._getDayItem = function (day) {
1790		if (day == -1) {
1791			return null;
1792		}
1793
1794		var days = this._dayitems;
1795		var maxDay = this._maxDay;
1796		for (var i = 0; i < maxDay; i++) {
1797			if (!days[i]._trailingday && day == days[i].text.padLeft(2, "0")) {
1798				return days[i];
1799			}
1800		}
1801
1802		return null;
1803	};
1804
1805	_pDatePickerBodyControl._getUsetrailingday = function () {
1806		var datepicker = this.parent;
1807		if (datepicker) {
1808			return datepicker._getUsetrailingday();
1809		}
1810
1811		return null;
1812	};
1813
1814	_pDatePickerBodyControl._getUseTrailingDayInfo = function (year, month, dateObj, endDay) {
1815		var prev_year = year;
1816		var next_year = year;
1817		var prev_month = month;
1818		var next_month = month;
1819
1820		if (month == 1) {
1821			prev_year -= 1;
1822			prev_month = 12;
1823
1824			next_month += 1;
1825		}
1826		else {
1827			prev_month -= 1;
1828			if (month == 12) {
1829				next_year += 1;
1830				next_month = 1;
1831			}
1832			else {
1833				next_month += 1;
1834			}
1835		}
1836
1837		var idx = dateObj.getDay() - 1;
1838
1839		dateObj.setDate(endDay);
1840		var endWeek = dateObj.getDay();
1841
1842		var N = nexacro.Calendar.EndDayNormal;
1843		var L = nexacro.Calendar.EndDayLeap;
1844
1845		var is_pre_leapyear = this._getLeapYear(prev_year);
1846		var pre_endDay = is_pre_leapyear ? L[prev_month - 1] : N[prev_month - 1];
1847		var next_beginDay = 1;
1848
1849		return {
1850			prev_year : prev_year, 
1851			next_year : next_year, 
1852			prev_month : prev_month, 
1853			next_month : next_month, 
1854			endWeek : endWeek, 
1855			idx : idx, 
1856			pre_endDay : pre_endDay, 
1857			next_beginDay : next_beginDay
1858		};
1859	};
1860
1861	_pDatePickerBodyControl._getInnerDataset = function () {
1862		var datepicker = this.parent;
1863		if (datepicker) {
1864			return datepicker._getInnerDataset();
1865		}
1866		return null;
1867	};
1868
1869	_pDatePickerBodyControl._getInnerDatasetColumns = function () {
1870		var datepicker = this.parent;
1871		if (datepicker) {
1872			var background = datepicker._getBackgroundcolumn();
1873			var border = datepicker._getBordercolumn();
1874			var date = datepicker._getDatecolumn();
1875			var textcolor = datepicker._getTextcolorcolumn();
1876
1877			return {
1878				backgroundcolumn : background, 
1879				bordercolumn : border, 
1880				datecolumn : date, 
1881				textcolorcolumn : textcolor
1882			};
1883		}
1884
1885		return null;
1886	};
1887
1888	_pDatePickerBodyControl._isToday = function (v) {
1889		var year = this._date.int_year;
1890		var month = this._date.int_month;
1891		var day = parseInt(v, 10);
1892		var currDate = this._getCurrentDate();
1893
1894		if (!year) {
1895			year = currDate.year;
1896		}
1897		if (!month) {
1898			month = currDate.month;
1899		}
1900
1901		if (year == currDate.year && month == currDate.month && day == currDate.day) {
1902			return true;
1903		}
1904		return false;
1905	};
1906
1907	_pDatePickerBodyControl._isSelectedDay = function (v) {
1908		v = parseInt(v, 10);
1909		var year = this._date.int_year;
1910		var month = this._date.int_month;
1911		if (year == this.parent._selected_year && month == this.parent._selected_month && v == this.parent._selected_day) {
1912			return true;
1913		}
1914		return false;
1915	};
1916
1917	_pDatePickerBodyControl._setCalendarAccessibility = function () {
1918		if (nexacro._enableaccessibility) {
1919			var calendar = this.parent.parent;
1920			var date = this._date;
1921			var cal_value = date.str_year + date.str_month + date.str_day;
1922			var accessibility_value = calendar._masktypeobj.applyMask(cal_value);
1923			this.parent._setAccessibilityLabel(accessibility_value);
1924			this._setAccessibilityLabel(accessibility_value);
1925			nexacro._notifyAccessibilityValue(this._control_element, accessibility_value, "daychange");
1926		}
1927	};
1928	_pDatePickerBodyControl.on_get_accessibility_label = function () {
1929		var date = this._date;
1930		var cal_value = date.str_year + date.str_month + date.str_day;
1931		return cal_value;
1932	};
1933
1934	delete _pDatePickerBodyControl;
1935
1936	nexacro._DatePickerDayItemControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
1937		nexacro.Button.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
1938
1939		this._flag_dataset = -1;
1940		this._dataset_background = "";
1941		this._refObj = parent.parent;
1942	};
1943
1944	var _pDatePickerDayItemControl = nexacro._createPrototype(nexacro.Button, nexacro._DatePickerDayItemControl);
1945	nexacro._DatePickerDayItemControl.prototype = _pDatePickerDayItemControl;
1946	_pDatePickerDayItemControl._type_name = "DatePickerDayItemControl";
1947	_pDatePickerDayItemControl._is_subcontrol = true;
1948	_pDatePickerDayItemControl.accessibilityrole = "gridcell";
1949
1950	_pDatePickerDayItemControl._trailingday = false;
1951
1952	_pDatePickerDayItemControl._year = "";
1953	_pDatePickerDayItemControl._month = "";
1954
1955	_pDatePickerDayItemControl._daysofweek = -1;
1956
1957	_pDatePickerDayItemControl._use_readonly_status = true;
1958
1959	_pDatePickerDayItemControl.set_readonly = function (v) {
1960		v = nexacro._toBoolean(v);
1961		if (v != this.readonly) {
1962			this.readonly = v;
1963			this.on_apply_readonly();
1964		}
1965	};
1966
1967	_pDatePickerDayItemControl.on_apply_readonly = function () {
1968		var v = this.readonly;
1969
1970		this._changeStatus("readonly", v);
1971	};
1972
1973	_pDatePickerDayItemControl._setDaysOfWeek = function (daysofweek) {
1974		if (this._daysofweek != daysofweek) {
1975			this._daysofweek = daysofweek;
1976			this._on_apply_daysofweek(daysofweek);
1977		}
1978	};
1979
1980	_pDatePickerDayItemControl._on_apply_daysofweek = function (v) {
1981		var text = v;
1982		var status = this._status;
1983
1984		if (text && text.length > 0) {
1985			if (this.trailingday) {
1986				this._changeUserStatus("trailingday", true);
1987			}
1988			else if (this.parent._isSelectedDay(text)) {
1989				this._changeUserStatus("selected", true);
1990			}
1991			else if (this.parent._isToday(text)) {
1992				this._changeUserStatus("today", true);
1993			}
1994			else if (this._daysofweek == 6) {
1995				this._changeUserStatus("saturday", true);
1996			}
1997			else if (this._daysofweek == 0) {
1998				this._changeUserStatus("sunday", true);
1999			}
2000		}
2001	};
2002
2003	_pDatePickerDayItemControl.on_changeUserStatus = function (changestatus, value, applyuserstatus, currentstatus, currentuserstatus) {
2004		if (value) {
2005			return changestatus;
2006		}
2007		else {
2008			return applyuserstatus;
2009		}
2010	};
2011
2012	_pDatePickerDayItemControl.on_getIDCSSSelector = function () {
2013		return "dayitem";
2014	};
2015
2016	_pDatePickerDayItemControl.on_keydown_basic_action = function () {
2017		if (nexacro._enableaccessibility) {
2018			nexacro.Button.prototype.on_apply_accessibility.call(this);
2019		}
2020	};
2021
2022	delete _pDatePickerDayItemControl;
2023
2024	nexacro._DatePickerWeekItemControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
2025		nexacro.Static.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
2026		this._refObj = parent.parent;
2027	};
2028
2029	var _pDatePickerWeekItemControl = nexacro._createPrototype(nexacro.Static, nexacro._DatePickerWeekItemControl);
2030	nexacro._DatePickerWeekItemControl.prototype = _pDatePickerWeekItemControl;
2031	_pDatePickerWeekItemControl._type_name = "DatePickerWeekItemControl";
2032	_pDatePickerWeekItemControl._is_subcontrol = true;
2033	_pDatePickerWeekItemControl._daysofweek = -1;
2034
2035	_pDatePickerWeekItemControl._use_readonly_status = true;
2036
2037	_pDatePickerWeekItemControl.set_readonly = function (v) {
2038		v = nexacro._toBoolean(v);
2039		if (v != this.readonly) {
2040			this.readonly = v;
2041			this.on_apply_readonly();
2042		}
2043	};
2044
2045	_pDatePickerWeekItemControl.on_apply_readonly = function () {
2046		var v = this.readonly;
2047
2048		this._changeStatus("readonly", v);
2049	};
2050
2051	_pDatePickerWeekItemControl._setDaysOfWeek = function (daysofweek) {
2052		if (this._daysofweek != daysofweek) {
2053			this._daysofweek = daysofweek;
2054			this._on_apply_daysofweek(daysofweek);
2055		}
2056	};
2057
2058	_pDatePickerWeekItemControl._on_apply_daysofweek = function (v) {
2059		if (v == 0) {
2060			this._changeUserStatus("sunday", true);
2061		}
2062		else if (v == 6) {
2063			this._changeUserStatus("saturday", true);
2064		}
2065	};
2066
2067	_pDatePickerWeekItemControl.on_changeUserStatus = function (changestatus, value, applyuserstatus, currentstatus, currentuserstatus) {
2068		return changestatus;
2069	};
2070
2071	_pDatePickerWeekItemControl.on_getIDCSSSelector = function () {
2072		return "weekitem";
2073	};
2074
2075	delete _pDatePickerWeekItemControl;
2076
2077	nexacro._YearSpinControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
2078		nexacro.Spin.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
2079	};
2080
2081	var _pYearSpinControl = nexacro._createPrototype(nexacro.Spin, nexacro._YearSpinControl);
2082	nexacro._YearSpinControl.prototype = _pYearSpinControl;
2083	_pYearSpinControl._type_name = "Spin";
2084	_pYearSpinControl._default_mask = "9999";
2085	_pYearSpinControl._is_subcontrol = true;
2086
2087	_pYearSpinControl.on_create_contents = function () {
2088		var control = this.getElement();
2089		if (control) {
2090			var spinedit = this.spinedit = new nexacro._SpinEditControl("spinedit", 0, 0, 0, 0, null, null, null, null, null, null, this);
2091			var spinupbutton = this.spinupbutton = new nexacro._SpinButtonControl("spinupbutton", 0, 0, 0, 0, null, null, null, null, null, null, this);
2092			var spindownbutton = this.spindownbutton = new nexacro._SpinButtonControl("spindownbutton", 0, 0, 0, 0, null, null, null, null, null, null, this);
2093			spinedit.set_limitbymask("both");
2094
2095			spinedit.createComponent(true);
2096			spinupbutton.createComponent(true);
2097			spindownbutton.createComponent(true);
2098		}
2099	};
2100
2101	_pYearSpinControl = null;
2102
2103
2104	nexacro._MonthSpinControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {
2105		nexacro.Spin.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);
2106	};
2107
2108	var _pMonthSpinControl = nexacro._createPrototype(nexacro.Spin, nexacro._MonthSpinControl);
2109	nexacro._MonthSpinControl.prototype = _pMonthSpinControl;
2110	_pMonthSpinControl._type_name = "Spin";
2111	_pMonthSpinControl._is_subcontrol = true;
2112	_pMonthSpinControl._default_mask = "99";
2113
2114	_pMonthSpinControl.on_create_contents = function () {
2115		var control = this.getElement();
2116		if (control) {
2117			var spinedit = this.spinedit = new nexacro._SpinEditControl("spinedit", 0, 0, 0, 0, null, null, null, null, null, null, this);
2118			var spinupbutton = this.spinupbutton = new nexacro._SpinButtonControl("spinupbutton", 0, 0, 0, 0, null, null, null, null, null, null, this);
2119			var spindownbutton = this.spindownbutton = new nexacro._SpinButtonControl("spindownbutton", 0, 0, 0, 0, null, null, null, null, null, null, this);
2120			spinedit.set_limitbymask("both");
2121
2122			spinedit.createComponent(true);
2123			spinupbutton.createComponent(true);
2124			spindownbutton.createComponent(true);
2125		}
2126	};
2127
2128	_pMonthSpinControl = null;
2129}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.