2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichYUI.add('calendarnavigator', function(Y) {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich/**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Provides a plugin which adds navigation controls to Calendar.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @module calendarnavigator
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovichvar CONTENT_BOX = "contentBox",
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich HOST = "host",
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich RENDERED = "rendered",
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich getCN = Y.ClassNameManager.getClassName,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich substitute = Y.substitute,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich node = Y.Node,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich create = node.create,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CALENDAR = 'calendar',
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CALENDARNAV = 'calendarnav',
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CAL_HD = getCN(CALENDAR, 'header'),
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CAL_PREV_M = getCN(CALENDARNAV, 'prevmonth'),
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CAL_NEXT_M = getCN(CALENDARNAV, 'nextmonth'),
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich CAL_DIS_M = getCN(CALENDARNAV, 'month-disabled'),
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich ydate = Y.DataType.Date;
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich/**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * A plugin class which adds navigation controls to Calendar.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @class CalendarNavigator
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @extends Plugin.Base
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @namespace Plugin
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovichfunction CalendarNavigator(config) {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CalendarNavigator.superclass.constructor.apply(this, arguments);
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich}
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich/**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The namespace for the plugin. This will be the property on the widget, which will
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * reference the plugin instance, when it's plugged in.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property NS
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @static
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type String
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @default "navigator"
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichCalendarNavigator.NS = "navigator";
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich/**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The NAME of the CalendarNavigator class. Used to prefix events generated
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * by the plugin class.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property NAME
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @static
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type String
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @default "pluginCalendarNavigator"
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichCalendarNavigator.NAME = "pluginCalendarNavigator";
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich/**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Static property used to define the default attribute
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * configuration for the plugin.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property ATTRS
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type Object
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @static
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichCalendarNavigator.ATTRS = {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The number of months to shift by when the control arrows are clicked.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @attribute shiftByMonths
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type Number
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @default 1 (months)
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich shiftByMonths : {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich value: 1
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich }
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich};
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The CSS classnames for the calendar navigator controls.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property CALENDARNAV_STRINGS
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type Object
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @readOnly
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @protected
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @static
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichCalendarNavigator.CALENDARNAV_STRINGS = {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich prev_month_class: CAL_PREV_M,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich next_month_class: CAL_NEXT_M
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich};
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The template for the calendar navigator previous month control.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property PREV_MONTH_CONTROL_TEMPLATE
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type String
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @protected
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @static
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
829f44d633f4910c12181f3295e5c6b996d7e559Allen RabinovichCalendarNavigator.PREV_MONTH_CONTROL_TEMPLATE = '<a class="yui3-u {prev_month_class}" role="button" aria-label="{prev_month_arialabel}" tabindex="{control_tabindex}">' +
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich "<span>&lt;</span>" +
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich '</a>';
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The template for the calendar navigator next month control.
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith * @property NEXT_MONTH_CONTROL_TEMPLATE
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @type String
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @readOnly
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @protected
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @static
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
829f44d633f4910c12181f3295e5c6b996d7e559Allen RabinovichCalendarNavigator.NEXT_MONTH_CONTROL_TEMPLATE = '<a class="yui3-u {next_month_class}" role="button" aria-label="{next_month_arialabel}" tabindex="{control_tabindex}">' +
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich "<span>&gt;</span>" +
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich '</a>';
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichY.extend(CalendarNavigator, Y.Plugin.Base, {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich _eventAttachments : {},
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich _controls: {},
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The initializer lifecycle implementation. Modifies the host widget's
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * render to add navigation controls.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method initializer
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @param {Object} config The user configuration for the plugin
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich initializer : function(config) {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich // After the host has rendered its UI, place the navigation cotnrols
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._controls = {};
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._eventAttachments = {};
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich this.afterHostMethod("renderUI", this._initNavigationControls);
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich },
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * The initializer destructor implementation. Responsible for destroying the initialized
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * control mechanisms.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method destructor
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich destructor : function() {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich },
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Private utility method that subtracts months from the host calendar date
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * based on the control click and the shiftByMonths property.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method _subtractMonths
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @param {Event} ev Click event from the controls
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @protected
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich _subtractMonths : function (ev) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich if ( (ev.type === "click") || (ev.type === "keydown" && (ev.keyCode == 13 || ev.keyCode == 32)) ) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich var host = this.get(HOST);
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich var oldDate = host.get("date");
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich host.set("date", ydate.addMonths(oldDate, -1*this.get("shiftByMonths")));
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich ev.preventDefault();
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich }
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich },
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Private utility method that adds months to the host calendar date
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * based on the control click and the shiftByMonths property.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method _addMonths
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @param {Event} ev Click event from the controls
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @protected
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich _addMonths : function (ev) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich if ( (ev.type === "click") || (ev.type === "keydown" && (ev.keyCode == 13 || ev.keyCode == 32)) ) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich var host = this.get(HOST);
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich var oldDate = host.get("date");
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich host.set("date", ydate.addMonths(oldDate, this.get("shiftByMonths")));
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich ev.preventDefault();
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich }
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich },
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich _updateControlState : function () {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich var host = this.get(HOST);
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (ydate.areEqual(host.get("minimumDate"), host.get("date"))) {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (this._eventAttachments.prevMonth) {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._eventAttachments.prevMonth.detach();
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._eventAttachments.prevMonth = false;
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (!this._controls.prevMonth.hasClass(CAL_DIS_M)) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich this._controls.prevMonth.addClass(CAL_DIS_M).setAttribute("aria-disabled", "true");
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich else {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (!this._eventAttachments.prevMonth) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich this._eventAttachments.prevMonth = this._controls.prevMonth.on(["click", "keydown"], this._subtractMonths, this);
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (this._controls.prevMonth.hasClass(CAL_DIS_M)) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich this._controls.prevMonth.removeClass(CAL_DIS_M).setAttribute("aria-disabled", "false");
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (ydate.areEqual(host.get("maximumDate"), ydate.addMonths(host.get("date"), host._paneNumber - 1))) {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (this._eventAttachments.nextMonth) {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._eventAttachments.nextMonth.detach();
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._eventAttachments.nextMonth = false;
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (!this._controls.nextMonth.hasClass(CAL_DIS_M)) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich this._controls.nextMonth.addClass(CAL_DIS_M).setAttribute("aria-disabled", "true");
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich else {
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (!this._eventAttachments.nextMonth) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich this._eventAttachments.nextMonth = this._controls.nextMonth.on(["click", "keydown"], this._addMonths, this);
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich if (this._controls.nextMonth.hasClass(CAL_DIS_M)) {
71bbbe94567d63ab107a7eab263595bcc6e47833Allen Rabinovich this._controls.nextMonth.removeClass(CAL_DIS_M).setAttribute("aria-disabled", "false");
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich }
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich },
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Private render assist method that renders the previous month control
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method _renderPrevControls
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @private
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich _renderPrevControls : function () {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich var prevControlNode = create(substitute (CalendarNavigator.PREV_MONTH_CONTROL_TEMPLATE,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CalendarNavigator.CALENDARNAV_STRINGS));
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich prevControlNode.on("selectstart", function (ev) {ev.preventDefault();});
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich return prevControlNode;
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich },
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Private render assist method that renders the next month control
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich *
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method _renderNextControls
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @private
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich _renderNextControls : function () {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich var nextControlNode = create(substitute (CalendarNavigator.NEXT_MONTH_CONTROL_TEMPLATE,
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich CalendarNavigator.CALENDARNAV_STRINGS));
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich nextControlNode.on("selectstart", function (ev) {ev.preventDefault();});
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich return nextControlNode;
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich },
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich /**
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * Protected render assist method that initialized and renders the navigation controls.
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @method _initNavigationControls
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich * @protected
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich */
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich _initNavigationControls : function() {
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich var host = this.get(HOST);
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich CalendarNavigator.CALENDARNAV_STRINGS["control_tabindex"] = host.get("tabIndex");
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich CalendarNavigator.CALENDARNAV_STRINGS["prev_month_arialabel"] = "Go to previous month";
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich CalendarNavigator.CALENDARNAV_STRINGS["next_month_arialabel"] = "Go to next month";
829f44d633f4910c12181f3295e5c6b996d7e559Allen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich var headerCell = host.get(CONTENT_BOX).one("." + CAL_HD);
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._controls.prevMonth = this._renderPrevControls();
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._controls.nextMonth = this._renderNextControls();
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich this._updateControlState();
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich host.after("dateChange", this._updateControlState, this);
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich headerCell.prepend(this._controls.prevMonth);
e66eba403ebf8a09e090b3785e8ea63aa1de7f3dAllen Rabinovich headerCell.append(this._controls.nextMonth);
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich }
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich});
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen RabinovichY.namespace("Plugin").CalendarNavigator = CalendarNavigator;
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
2f17bc2f9d34cb9377a0c15ea9519471bb83e4ecAllen Rabinovich
9724a6e829470b07523eddcd9df488b799e57a6aDav Glass}, '@VERSION@' ,{requires:['plugin', 'classnamemanager', 'datatype-date', 'node', 'substitute']});