calendarnavigator.js revision e66eba403ebf8a09e090b3785e8ea63aa1de7f3d
/**
* Provides a plugin which adds navigation controls to Calendar.
*
* @module calendarnavigator
*/
var CONTENT_BOX = "contentBox",
HOST = "host",
RENDERED = "rendered",
substitute = Y.substitute,
CALENDAR = 'calendar',
CALENDARNAV = 'calendarnav',
/**
* A plugin class which adds navigation controls to Calendar.
*
* @class CalendarNavigator
* @extends Plugin.Base
* @namespace Plugin
*/
function CalendarNavigator(config) {
}
/**
* The namespace for the plugin. This will be the property on the widget, which will
* reference the plugin instance, when it's plugged in.
*
* @property NS
* @static
* @type String
* @default "navigator"
*/
/**
* The NAME of the CalendarNavigator class. Used to prefix events generated
* by the plugin class.
*
* @property NAME
* @static
* @type String
* @default "pluginCalendarNavigator"
*/
/**
* Static property used to define the default attribute
* configuration for the plugin.
*
* @property ATTRS
* @type Object
* @static
*/
/**
* The number of months to shift by when the control arrows are clicked.
*
* @attribute shiftByMonths
* @type Number
* @default 1 (months)
*/
shiftByMonths : {
value: 1
}
};
/**
* The CSS classnames for the calendar navigator controls.
* @property CALENDARNAV_STRINGS
* @type Object
* @readOnly
* @protected
* @static
*/
};
/**
* The template for the calendar navigator previous month control.
* @property PREV_MONTH_CONTROL_TEMPLATE
* @type String
* @protected
* @static
*/
CalendarNavigator.PREV_MONTH_CONTROL_TEMPLATE = '<a class="yui3-u {prev_month_class}" role="button" aria-label="{prev_month_arialabel}" tabindex="{control_tabindex}">' +
"<span><</span>" +
'</a>';
/**
* The template for the calendar navigator next month control.
* @property NEXT_MONTH_CONTROL_TEMPLATE
* @type String
* @readOnly
* @protected
* @static
*/
CalendarNavigator.NEXT_MONTH_CONTROL_TEMPLATE = '<a class="yui3-u {next_month_class}" role="button" aria-label="{next_month_arialabel}" tabindex="{control_tabindex}">' +
"<span>></span>" +
'</a>';
_eventAttachments : {},
_controls: {},
/**
* The initializer lifecycle implementation. Modifies the host widget's
* render to add navigation controls.
*
* @method initializer
* @param {Object} config The user configuration for the plugin
*/
initializer : function(config) {
// After the host has rendered its UI, place the navigation cotnrols
this._controls = {};
this._eventAttachments = {};
},
/**
* The initializer destructor implementation. Responsible for destroying the initialized
* control mechanisms.
*
* @method destructor
*/
destructor : function() {
},
/**
* Private utility method that subtracts months from the host calendar date
* based on the control click and the shiftByMonths property.
*
* @method _subtractMonths
* @param {Event} ev Click event from the controls
* @protected
*/
_subtractMonths : function (ev) {
ev.preventDefault();
},
/**
* Private utility method that adds months to the host calendar date
* based on the control click and the shiftByMonths property.
*
* @method _addMonths
* @param {Event} ev Click event from the controls
* @protected
*/
_addMonths : function (ev) {
ev.preventDefault();
},
_updateControlState : function () {
if (this._eventAttachments.prevMonth) {
this._eventAttachments.prevMonth = false;
}
}
}
else {
if (!this._eventAttachments.prevMonth) {
this._eventAttachments.prevMonth = this._controls.prevMonth.on("click", this._subtractMonths, this);
}
}
}
if (ydate.areEqual(host.get("maximumDate"), ydate.addMonths(host.get("date"), host._paneNumber - 1))) {
if (this._eventAttachments.nextMonth) {
this._eventAttachments.nextMonth = false;
}
}
}
else {
if (!this._eventAttachments.nextMonth) {
}
}
}
},
/**
* Private render assist method that renders the previous month control
*
* @method _renderPrevControls
* @private
*/
_renderPrevControls : function () {
return prevControlNode;
},
/**
* Private render assist method that renders the next month control
*
* @method _renderNextControls
* @private
*/
_renderNextControls : function () {
return nextControlNode;
},
/**
* Protected render assist method that initialized and renders the navigation controls.
* @method _initNavigationControls
* @protected
*/
_initNavigationControls : function() {
this._updateControlState();
}
});