1 YUI().use('yui2-container', 'yui2-calendar', function(Y
) {
4 document
.body
.className
+= ' yui-skin-sam';
6 YAHOO
.util
.Event
.onDOMReady(function(){
8 var Event
= YAHOO
.util
.Event
,
12 var showBtn
= Dom
.get("show");
14 Event
.on(showBtn
, "click", function() {
16 function resetHandler() {
17 calendar
.cfg
.setProperty("pagedate", calendar
.today
);
21 function closeHandler() {
25 // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners,
26 // until the first time the button is clicked.
29 // Hide Calendar if we click anywhere in the document other than the calendar.
30 Event
.on(document
, "click", function(e
) {
31 var el
= Event
.getTarget(e
);
32 var dialogEl
= dialog
.element
;
33 if (el
!= dialogEl
&& !Dom
.isAncestor(dialogEl
, el
) && el
!= showBtn
&& !Dom
.isAncestor(showBtn
, el
)) {
38 dialog
= new YAHOO
.widget
.Dialog("attcalendarcontainer", {
40 context
:["show", "tl", "bl"],
41 buttons
:[{text
: M
.str
.attendance
.caltoday
, handler
: resetHandler
, isDefault
:true},
42 {text
: M
.str
.attendance
.calclose
, handler
: closeHandler
}],
47 dialog
.setBody('<div id="cal"></div>');
48 dialog
.render(document
.body
);
50 dialog
.showEvent
.subscribe(function() {
51 if (YAHOO
.env
.ua
.ie
) {
52 // Since we're hiding the table using yui-overlay-hidden, we
53 // want to let the dialog know that the content size has changed, when
55 dialog
.fireEvent("changeContent");
60 // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
63 calendar
= new YAHOO
.widget
.Calendar("cal", {
64 iframe
:false, // Turn iframe off, since container has iframe support.
65 hide_blank_weeks
:true // Enable, to demonstrate how we handle changing height, using changeContent.
68 calendar
.cfg
.setProperty("start_weekday", M
.attendance
.cal_start_weekday
);
69 calendar
.cfg
.setProperty("MONTHS_LONG", M
.attendance
.cal_months
);
70 calendar
.cfg
.setProperty("WEEKDAYS_SHORT", M
.attendance
.cal_week_days
);
71 calendar
.select(new Date(M
.attendance
.cal_cur_date
* 1000));
74 calendar
.selectEvent
.subscribe(function() {
75 if (calendar
.getSelectedDates().length
> 0) {
77 Dom
.get("curdate").value
= calendar
.getSelectedDates()[0] / 1000;
79 Dom
.get("currentdate").submit();
84 calendar
.renderEvent
.subscribe(function() {
85 // Tell Dialog it's contents have changed, which allows
86 // container to redraw the underlay (for IE6/Safari2
).
87 dialog
.fireEvent("changeContent");
91 var seldate
= calendar
.getSelectedDates();
93 if (seldate
.length
> 0) {
94 // Set the pagedate to show the selected date if it exists.
95 calendar
.cfg
.setProperty("pagedate", seldate
[0]);