summaryrefslogtreecommitdiffstats
path: root/js/yui3/calendarnavigator/calendarnavigator-min.js
blob: 8a1ff692cb1a9e5b4569f59c191a16459a604aa1 (plain)
1
2
3
4
5
6
7
8
/*
YUI 3.17.2 (build 9c3c78e)
Copyright 2014 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/

YUI.add("calendarnavigator",function(e,t){function v(){v.superclass.constructor.apply(this,arguments)}var n="contentBox",r="host",i=e.ClassNameManager.getClassName,s=e.Lang.sub,o=e.Node,u=o.create,a="calendar",f="calendarnav",l=i(a,"header"),c=i(f,"prevmonth"),h=i(f,"nextmonth"),p=i(f,"month-disabled"),d=e.DataType.Date;v.NS="navigator",v.NAME="pluginCalendarNavigator",v.ATTRS={shiftByMonths:{value:1}},v.CALENDARNAV_STRINGS={prev_month_class:c,next_month_class:h},v.PREV_MONTH_CONTROL_TEMPLATE='<a class="yui3-u {prev_month_class}" role="button" aria-label="{prev_month_arialabel}" tabindex="{control_tabindex}" />',v.NEXT_MONTH_CONTROL_TEMPLATE='<a class="yui3-u {next_month_class}" role="button" aria-label="{next_month_arialabel}" tabindex="{control_tabindex}" />',e.extend(v,e.Plugin.Base,{_eventAttachments:{},_controls:{},initializer:function(){this._controls={},this._eventAttachments={},this.afterHostMethod("renderUI",this._initNavigationControls)},destructor:function(){},_focusNavigation:function(e){e.currentTarget.focus()},_subtractMonths:function(e){if(e.type==="click"||e.type==="keydown"&&(e.keyCode===13||e.keyCode===32)){var t=this.get(r),n=t.get("date");t.set("date",d.addMonths(n,-1*this.get("shiftByMonths"))),e.preventDefault()}},_addMonths:function(e){if(e.type==="click"||e.type==="keydown"&&(e.keyCode===13||e.keyCode===32)){var t=this.get(r),n=t.get("date");t.set("date",d.addMonths(n,this.get("shiftByMonths"))),e.preventDefault()}},_updateControlState:function(){var e=this.get(r),t=e.get("date"),n=d.addMonths(t,e._paneNumber-1),i=e._normalizeDate(e.get("minimumDate")),s=e._normalizeDate(e.get("maximumDate"));d.areEqual(i,t)?(this._eventAttachments.prevMonth&&(this._eventAttachments.prevMonth.detach(),this._eventAttachments.prevMonth=!1),this._controls.prevMonth.hasClass(p)||this._controls.prevMonth.addClass(p).setAttribute("aria-disabled","true")):(this._eventAttachments.prevMonth||(this._eventAttachments.prevMonth=this._controls.prevMonth.on(["click","keydown"],this._subtractMonths,this)),this._controls.prevMonth.hasClass(p)&&this._controls.prevMonth.removeClass(p).setAttribute("aria-disabled","false")),d.areEqual(s,n)?(this._eventAttachments.nextMonth&&(this._eventAttachments.nextMonth.detach(),this._eventAttachments.nextMonth=!1),this._controls.nextMonth.hasClass(p)||this._controls.nextMonth.addClass(p).setAttribute("aria-disabled","true")):(this._eventAttachments.nextMonth||(this._eventAttachments.nextMonth=this._controls.nextMonth.on(["click","keydown"],this._addMonths,this)),this._controls.nextMonth.hasClass(p)&&this._controls.nextMonth.removeClass(p).setAttribute("aria-disabled","false")),this._controls.prevMonth.on(["click","keydown"],this._focusNavigation,this),this._controls.nextMonth.on(["click","keydown"],this._focusNavigation,this)},_renderPrevControls:function(){var e=u(s(v.PREV_MONTH_CONTROL_TEMPLATE,v.CALENDARNAV_STRINGS));return e.on("selectstart",this.get(r)._preventSelectionStart),e},_renderNextControls:function(){var e=u(s(v.NEXT_MONTH_CONTROL_TEMPLATE,v.CALENDARNAV_STRINGS));return e.on("selectstart",this.get(r)._preventSelectionStart),e},_initNavigationControls:function(){var e=this.get(r),t=e.get(n).one("."+l);v.CALENDARNAV_STRINGS.control_tabindex=e.get("tabIndex"),v.CALENDARNAV_STRINGS.prev_month_arialabel="Go to previous month",v.CALENDARNAV_STRINGS.next_month_arialabel="Go to next month",this._controls.prevMonth=this._renderPrevControls(),this._controls.nextMonth=this._renderNextControls(),this._updateControlState(),e.after(["dateChange","minimumDateChange","maximumDateChange"],this._updateControlState,this),t.prepend(this._controls.prevMonth),t.append(this._controls.nextMonth)}}),e.namespace("Plugin").CalendarNavigator=v},"3.17.2",{requires:["plugin","classnamemanager","datatype-date","node"],skinnable:!0});