af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * The Calendar component is a UI widget that allows users
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * to view dates in a two-dimensional month grid, as well as
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * to select one or more dates, or ranges of dates. Calendar
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * is generated dynamically.
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * @module calendar
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * @submodule calendar-base
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich/** Create a calendar view to represent a single or multiple
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * month range of dates, rendered as a grid with date and
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * weekday labels.
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * @class CalendarBase
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * @extends Widget
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * @param config {Object} Configuration object (see Configuration attributes)
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich * @constructor
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovichvar getCN = Y.ClassNameManager.getClassName,
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich CAL_HD_WRAP = getCN(CALENDAR, 'header-wrap'),
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich CAL_WDAYROW = getCN(CALENDAR, 'weekdayrow'),
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich CalendarBase.superclass.constructor.apply ( this, arguments );
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen RabinovichY.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich initializer : function () {
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich renderUI : function () {
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich contentBox.appendChild(this._initCalendarHTML(new Date("5/21/1947")));
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich bindUI : function () {
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich var normalizedDate = new Date(date.getFullYear(), date.getMonth(), 1);
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich cutoffCol = this._getCutoffColumn(startDate),
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich headerData = {calheader: (startDate.getMonth()+1) + "/" +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich partials["header_template"] = substitute(CalendarBase.HEADER_TEMPLATE,
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich partials["wdayrow_template"] = substitute(CalendarBase.WEEKDAY_ROW_TEMPLATE, partials);
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich calday_row += substitute (CalendarBase.CALDAY_TEMPLATE, {day_content: '' + (j+7*i),
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich day_display_status: (j >= cutoffCol && j <= (cutoffCol + 6)) ? '' : 'style="display:none;"'});
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich row_array.push(substitute(CalendarBase.CALDAY_ROW_TEMPLATE, {calday_row: calday_row} ));
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich partials["body_template"] = row_array.join('\n');
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich var header = substitute(substitute (CalendarBase.CONTENT_TEMPLATE, partials),
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich // Y.CalendarBase static properties
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich CONTENT_TEMPLATE: '<table class="{calendar_grid_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{header_template}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{wdayrow_template}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '<tbody class="{calendar_body_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{body_template}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '<th colspan="7" class="{calendar_hd_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '<div id="calheader" class="{calendar_hd_wrapper_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{calheader}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich WEEKDAY_ROW_TEMPLATE: '<tr class="{calendar_weekdayrow_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{weekday_row}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich CALDAY_ROW_TEMPLATE: '<tr class="{calendar_row_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{calday_row}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich WEEKDAY_TEMPLATE: '<th class="{calendar_weekday_class}">{weekdayname}</th>',
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich CALDAY_TEMPLATE: '<td class="{calendar_day_class}" {day_display_status}>' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '<a href="#" class="{calendar_dayanchor_class}">' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich '{day_content}' +
af588160cda24eb5a49cf49c51ae048cc5fdf664Allen Rabinovich}, '@VERSION@' ,{requires:['widget', 'datatype-date']});