2 // eslint-disable-next-line new-cap
3 YUI().use('yui2-container', 'yui2-calendar', function(Y
) {
6 document
.body
.className
+= ' yui-skin-sam';
8 YAHOO
.util
.Event
.onDOMReady(function() {
10 var Event
= YAHOO
.util
.Event
,
14 var showBtn
= Dom
.get("show");
16 Event
.on(showBtn
, "click", function() {
18 * Reset handler and set current day.
20 function resetHandler() {
21 calendar
.cfg
.setProperty("pagedate", calendar
.today
);
28 function closeHandler() {
32 // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners,
33 // until the first time the button is clicked.
36 // Hide Calendar if we click anywhere in the document other than the calendar.
37 Event
.on(document
, "click", function(e
) {
38 var el
= Event
.getTarget(e
);
39 var dialogEl
= dialog
.element
;
40 if (el
!= dialogEl
&& !Dom
.isAncestor(dialogEl
, el
) && el
!= showBtn
&& !Dom
.isAncestor(showBtn
, el
)) {
45 dialog
= new YAHOO
.widget
.Dialog("attcalendarcontainer", {
47 context
: ["show", "tl", "bl"],
48 buttons
: [{text
: M
.util
.get_string('caltoday', 'attendance'), handler
: resetHandler
, isDefault
: true},
49 {text
: M
.util
.get_string('calclose', 'attendance'), handler
: closeHandler
}],
54 dialog
.setBody('<div id="cal"></div>');
55 dialog
.render(document
.body
);
57 dialog
.showEvent
.subscribe(function() {
58 if (YAHOO
.env
.ua
.ie
) {
59 // Since we're hiding the table using yui-overlay-hidden, we
60 // want to let the dialog know that the content size has changed, when
62 dialog
.fireEvent("changeContent");
67 // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
70 calendar
= new YAHOO
.widget
.Calendar("cal", {
71 iframe
: false, // Turn iframe off, since container has iframe support.
72 // eslint-disable-next-line camelcase
73 hide_blank_weeks
: true // Enable, to demonstrate how we handle changing height, using changeContent.
76 calendar
.cfg
.setProperty("start_weekday", M
.attendance
.cal_start_weekday
);
77 calendar
.cfg
.setProperty("MONTHS_LONG", M
.attendance
.cal_months
);
78 calendar
.cfg
.setProperty("WEEKDAYS_SHORT", M
.attendance
.cal_week_days
);
79 calendar
.select(new Date(M
.attendance
.cal_cur_date
* 1000));
82 calendar
.selectEvent
.subscribe(function() {
83 if (calendar
.getSelectedDates().length
> 0) {
85 Dom
.get("curdate").value
= calendar
.getSelectedDates()[0] / 1000;
87 Dom
.get("currentdate").submit();
92 calendar
.renderEvent
.subscribe(function() {
93 // Tell Dialog it's contents have changed, which allows
94 // container to redraw the underlay (for IE6/Safari2
).
95 dialog
.fireEvent("changeContent");
99 var seldate
= calendar
.getSelectedDates();
101 if (seldate
.length
> 0) {
102 // Set the pagedate to show the selected date if it exists.
103 calendar
.cfg
.setProperty("pagedate", seldate
[0]);