/* YUI 3.7.3 (build 5687) Copyright 2012 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("calendar-base",function(e,t){function P(e){P.superclass.constructor.apply(this,arguments)}var n=e.ClassNameManager.getClassName,r="calendar",i=n(r,"grid"),s=n(r,"left-grid"),o=n(r,"right-grid"),u=n(r,"body"),a=n(r,"header"),f=n(r,"header-label"),l=n(r,"weekdayrow"),c=n(r,"weekday"),h=n(r,"column-hidden"),p=n(r,"day-selected"),d=n(r,"selection-disabled"),v=n(r,"row"),m=n(r,"day"),g=n(r,"prevmonth-day"),y=n(r,"nextmonth-day"),b=n(r,"anchor"),w=n(r,"pane"),E=n(r,"status"),S=e.Lang,x=e.Node,T=x.create,N=e.substitute,C=e.each,k=e.Array.hasValue,L=e.Array.indexOf,A=e.Object.hasKey,O=e.Object.setValue,M=e.Object.owns,_=e.Object.isEmpty,D=e.DataType.Date;e.CalendarBase=e.extend(P,e.Widget,{_paneProperties:{},_paneNumber:1,_calendarId:null,_selectedDates:{},_rules:{},_filterFunction:null,_storedDateCells:{},initializer:function(){this._paneProperties={},this._calendarId=e.guid("calendar"),this._selectedDates={},_(this._rules)&&(this._rules={}),this._storedDateCells={}},renderUI:function(){var e=this.get("contentBox");e.appendChild(this._initCalendarHTML(this.get("date"))),this.get("showPrevMonth")&&this._afterShowPrevMonthChange(),this.get("showNextMonth")&&this._afterShowNextMonthChange(),this._renderCustomRules(),this._renderSelectedDates(),this.get("boundingBox").setAttribute("aria-labelledby",this._calendarId+"_header")},bindUI:function(){this.after("dateChange",this._afterDateChange),this.after("showPrevMonthChange",this._afterShowPrevMonthChange),this.after("showNextMonthChange",this._afterShowNextMonthChange),this.after("headerRendererChange",this._afterHeaderRendererChange),this.after("customRendererChange",this._afterCustomRendererChange),this.after("enabledDatesRuleChange",this._afterCustomRendererChange),this.after("disabledDatesRuleChange",this._afterCustomRendererChange),this.after("focusedChange",this._afterFocusedChange),this.after("selectionChange",this._renderSelectedDates),this._bindCalendarEvents()},_getSelectedDatesList:function(){var e=[];return C(this._selectedDates,function(t){C(t,function(t){C(t,function(t){e.push(t)},this)},this)},this),e},_getSelectedDatesInMonth:function(t){var n=t.getFullYear(),r=t.getMonth();return A(this._selectedDates,n)&&A(this._selectedDates[n],r)?e.Object.values(this._selectedDates[n][r]):[]},_isNumInList:function(e,t){if(t=="all")return!0;var n=t.split(","),r=n.length;while(r--){var i=n[r].split("-");if(i.length==2&&e>=parseInt(i[0],10)&&e<=parseInt(i[1],10))return!0;if(i.length==1&&parseInt(n[r],10)==e)return!0}return!1},_getRulesForDate:function(e){var t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=e.getDay(),s=this._rules,o=[],u,a,f,l;for(u in s)if(this._isNumInList(t,u))if(S.isString(s[u]))o.push(s[u]);else for(a in s[u])if(this._isNumInList(n,a))if(S.isString(s[u][a]))o.push(s[u][a]);else for(f in s[u][a])if(this._isNumInList(r,f))if(S.isString(s[u][a][f]))o.push(s[u][a][f]);else for(l in s[u][a][f])this._isNumInList(i,l)&&S.isString(s[u][a][f][l])&&o.push(s[u][a][f][l]);return o},_matchesRule:function(e,t){return L(this._getRulesForDate(e),t)>=0},_canBeSelected:function(e){var t=this.get("enabledDatesRule"),n=this.get("disabledDatesRule");return t?this._matchesRule(e,t):n?!this._matchesRule(e,n):!0},selectDates:function(e){D.isValidDate(e)?this._addDateToSelection(e):S.isArray(e)&&this._addDatesToSelection(e)},deselectDates:function(e){e?D.isValidDate(e)?this._removeDateFromSelection(e):S.isArray(e)&&this._removeDatesFromSelection(e):this._clearSelection()},_addDateToSelection:function(e,t){if(this._canBeSelected(e)){var n=e.getFullYear(),r=e.getMonth(),i=e.getDate();A(this._selectedDates,n)?A(this._selectedDates[n],r)?this._selectedDates[n][r][i]=e:(this._selectedDates[n][r]={},this._selectedDates[n][r][i]=e):(this._selectedDates[n]={},this._selectedDates[n][r]={},this._selectedDates[n][r][i]=e),this._selectedDates=O(this._selectedDates,[n,r,i],e),t||this._fireSelectionChange()}},_addDatesToSelection:function(e){C(e,this._addDateToSelection,this),this._fireSelectionChange()},_addDateRangeToSelection:function(e,t){var n=(t.getTimezoneOffset()-e.getTimezoneOffset())*6e4,r=e.getTime(),i=t.getTime();if(r>i){var s=r;r=i,i=s+n}else i-=n;for(var o=r;o<=i;o+=864e5){var u=new Date(o);u.setHours(12),this._addDateToSelection(u,o)}this._fireSelectionChange()},_removeDateFromSelection:function(e,t){var n=e.getFullYear(),r=e.getMonth(),i=e.getDate();A(this._selectedDates,n)&&A(this._selectedDates[n],r)&&A(this._selectedDates[n][r],i)&&(delete this._selectedDates[n][r][i],t||this._fireSelectionChange())},_removeDatesFromSelection:function(e){C(e,this._removeDateFromSelection,this),this._fireSelectionChange()},_removeDateRangeFromSelection:function(e,t){var n=e.getTime(),r=t.getTime();for(var i=n;i<=r;i+=864e5)this._removeDateFromSelection(new Date(i),i);this._fireSelectionChange()},_clearSelection:function(e){this._selectedDates={},this.get("contentBox").all("."+p).removeClass(p).setAttribute("aria-selected",!1),e||this._fireSelectionChange()},_fireSelectionChange:function(){this.fire("selectionChange",{newSelection:this._getSelectedDatesList()})},_restoreModifiedCells:function(){var e=this.get("contentBox"),t;for(t in this._storedDateCells)e.one("#"+t).replace(this._storedDateCells[t]),delete this._storedDateCells[t]},_renderCustomRules:function(){this.get("contentBox").all("."+m+",."+y).removeClass(d).setAttribute("aria-disabled",!1);if(!_(this._rules)){var e=this.get("enabledDatesRule"),t=this.get("disabledDatesRule");for(var n=0;n0){var i=this._dateToNode(n);(e&&L(r,e)<0||!e&&t&&L(r,t)>=0)&&i.addClass(d).setAttribute("aria-disabled",!0),S.isFunction(this._filterFunction)&&(this._storedDateCells[i.get("id")]=i.cloneNode(!0),this._filterFunction(n,i,r))}else if(e){var i=this._dateToNode(n);i.addClass(d).setAttribute("aria-disabled",!0)}},this)}}},_renderSelectedDates:function(){this.get("contentBox").all("."+p).removeClass(p).setAttribute("aria-selected",!1);for(var e=0;e=6?n=12:n=5;break;case 1:n=6;break;case 2:o>0?n=7:n=0;break;case 3:o>1?n=8:n=1;break;case 4:o>2?n=9:n=2;break;case 5:o>3?n=10:n=3;break;case 6:o>4?n=11:n=4}return this.get("contentBox").one("#"+this._calendarId+"_pane_"+i+"_"+n+"_"+t)},_nodeToDate:function(e){var t=e.get("id").split("_").reverse(),n=parseInt(t[2],10),r=parseInt(t[0],10),i=D.addMonths(this.get("date"),n),s=i.getFullYear(),o=i.getMonth();return new Date(s,o,r,12,0,0,0)},_bindCalendarEvents:function(){},_normalizeDate:function(e){return e?new Date(e.getFullYear(),e.getMonth(),1,12,0,0,0):null},_getCutoffColumn:function(e,t){var n=this._normalizeDate(e).getDay()-t,r=6-(n+7)%7;return r},_turnPrevMonthOn:function(e){var t=e.get("id"),n=this._paneProperties[t].paneDate,r=D.daysInMonth(D.addMonths(n,-1));this._paneProperties[t].hasOwnProperty("daysInPrevMonth")||(this._paneProperties[t].daysInPrevMonth=0);if(r!=this._paneProperties[t].daysInPrevMonth){this._paneProperties[t].daysInPrevMonth=r;for(var i=5;i>=0;i--)e.one("#"+t+"_"+i+"_"+(i-5)).set("text",r--)}},_turnPrevMonthOff:function(e){var t=e.get("id");this._paneProperties[t].daysInPrevMonth=0;for(var n=5;n>=0;n--)e.one("#"+t+"_"+n+"_"+(n-5)).setContent(" ")},_cleanUpNextMonthCells:function(e){var t=e.get("id");e.one("#"+t+"_6_29").removeClass(y),e.one("#"+t+"_7_30").removeClass(y),e.one("#"+t+"_8_31").removeClass(y),e.one("#"+t+"_0_30").removeClass(y),e.one("#"+t+"_1_31").removeClass(y)},_turnNextMonthOn:function(e){var t=1,n=e.get("id"),r=this._paneProperties[n].daysInMonth,i=this._paneProperties[n].cutoffCol;for(var s=r-22;su&&(b=y);if(d<1||d>u)d=" ";var w=p>=o&&p=r+7)u.addClass(h);else switch(o){case 0:var a=t.one("#"+s+"_0_30");i>=30?(a.set("text","30"),a.removeClass(y).addClass(m)):(a.setContent(" "),a.addClass(y).addClass(m));break;case 1:var a=t.one("#"+s+"_1_31");i>=31?(a.set("text","31"),a.removeClass(y).addClass(m)):(a.setContent(" "),a.removeClass(m).addClass(y));break;case 6:var a=t.one("#"+s+"_6_29");i>=29?(a.set("text","29"),a.removeClass(y).addClass(m)):(a.setContent(" "),a.removeClass(m).addClass(y));break;case 7:var a=t.one("#"+s+"_7_30");i>=30?(a.set("text","30"),a.removeClass(y).addClass(m)):(a.setContent(" "),a.removeClass(m).addClass(y));break;case 8:var a=t.one("#"+s+"_8_31");i>=31?(a.set("text","31"),a.removeClass(y).addClass(m)):(a.setContent(" "),a.removeClass(m).addClass(y))}}this._paneProperties[s].cutoffCol=r,this._paneProperties[s].daysInMonth=i,this._paneProperties[s].paneDate=e,t.setStyle("visibility","visible")},_updateCalendarHeader:function(t){var n="",r=this.get("headerRenderer");return e.Lang.isString(r)?n=D.format(t,{format:r}):r instanceof Function&&(n=r.call(this,t)),n},_initCalendarHeader:function(e){return N(N(P.HEADER_TEMPLATE,{calheader:this._updateCalendarHeader(e),calendar_id:this._calendarId}),P.CALENDAR_STRINGS)},_initCalendarHTML:function(t){function i(){var e=this._initCalendarPane(D.addMonths(t,r),n.calendar_id+"_pane_"+r);return r++,e}var n={},r=0;n.header_template=this._initCalendarHeader(t),n.calendar_id=this._calendarId,n.body_template=N(N(P.CONTENT_TEMPLATE,n),P.CALENDAR_STRINGS);var s=n.body_template.replace(/\{calendar_grid_template\}/g,e.bind(i,this));return this._paneNumber=r,s}},{CALENDAR_STRINGS:{calendar_grid_class:i,calendar_body_class:u,calendar_hd_class:a,calendar_hd_label_class:f,calendar_weekdayrow_class:l,calendar_weekday_class:c,calendar_row_class:v,calendar_day_class:m,calendar_dayanchor_class:b,calendar_pane_class:w,calendar_right_grid_class:o,calendar_left_grid_class:s,calendar_status_class:E},CONTENT_TEMPLATE:'
{header_template}
{calendar_grid_template}
',ONE_PANE_TEMPLATE:'
{header_template}
{calendar_grid_template}
',TWO_PANE_TEMPLATE:'
{header_template}
{calendar_grid_template}
{calendar_grid_template}
',THREE_PANE_TEMPLATE:'
{header_template}
{calendar_grid_template}
{calendar_grid_template}
{calendar_grid_template}
',CALENDAR_GRID_TEMPLATE:'{weekday_row_template}{body_template}
',HEADER_TEMPLATE:'
{calheader}
',WEEKDAY_ROW_TEMPLATE:'{weekday_row}',CALDAY_ROW_TEMPLATE:'{calday_row}',WEEKDAY_TEMPLATE:'{weekdayname}',CALDAY_TEMPLATE:'{day_content}',NAME:"calendarBase",ATTRS:{tabIndex:{value:1},date:{value:new Date,setter:function(e){var t=this._normalizeDate(e);return D.areEqual(t,this.get("date"))?this.get("date"):t}},showPrevMonth:{value:!1},showNextMonth:{value:!1},strings:{valueFn:function(){return e.Intl.get("calendar-base")}},headerRenderer:{value:"%B %Y"},enabledDatesRule:{value:null},disabledDatesRule:{value:null},selectedDates:{readOnly:!0,getter:function(e){return this._getSelectedDatesList()}},customRenderer:{lazyAdd:!1,value:{},setter:function(e){this._rules=e.rules,this._filterFunction=e.filterFunction}}}})},"3.7.3",{requires:["widget","substitute","datatype-date","datatype-date-math","cssgrids"],lang:["de","en","fr","ja","nb-NO","pt-BR","ru","zh-HANT-TW"],skinnable:!0});