Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build files for calendar chainable methods

  • Loading branch information...
commit 0404035087b820f5388a2da882c93a72091f59be 1 parent f9fcedb
@allenrabinovich authored
View
676 build/calendar-base/calendar-base-coverage.js
342 additions, 334 deletions not shown
View
24 build/calendar-base/calendar-base-debug.js
@@ -367,6 +367,8 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* Selects a given date or array of dates.
* @method selectDates
* @param {Date|Array} dates A `Date` or `Array` of `Date`s.
+ * @return {CalendarBase} A reference to this object
+ * @chainable
*/
selectDates : function (dates) {
if (ydate.isValidDate(dates)) {
@@ -375,6 +377,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
else if (L.isArray(dates)) {
this._addDatesToSelection(dates);
}
+ return this;
},
/**
@@ -383,6 +386,8 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method deselectDates
* @param {Date|Array} [dates] A `Date` or `Array` of `Date`s, or no
* argument if all dates should be deselected.
+ * @return {CalendarBase} A reference to this object
+ * @chainable
*/
deselectDates : function (dates) {
if (!dates) {
@@ -394,6 +399,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
else if (L.isArray(dates)) {
this._removeDatesFromSelection(dates);
}
+ return this;
},
/**
@@ -620,7 +626,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _renderSelectedDates
* @private
*/
- _renderSelectedDates : function () {
+ _renderSelectedDates : function () {
this.get("contentBox").all("." + CAL_DAY_SELECTED).removeClass(CAL_DAY_SELECTED).setAttribute("aria-selected", false);
for (var paneNum = 0; paneNum < this._paneNumber; paneNum++) {
@@ -642,7 +648,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @return {Node} The node wrapping the DOM element of the cell the date
* corresponds to.
*/
- _dateToNode : function (oDate) {
+ _dateToNode : function (oDate) {
var day = oDate.getDate(),
col = 0,
daymod = day%7,
@@ -715,7 +721,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @protected
* @return {Date} The date corresponding to the DOM element that the given node wraps.
*/
- _nodeToDate : function (oNode) {
+ _nodeToDate : function (oNode) {
var idParts = oNode.get("id").split("_").reverse(),
paneNum = parseInt(idParts[2], 10),
@@ -733,7 +739,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _bindCalendarEvents
* @protected
*/
- _bindCalendarEvents : function () {
+ _bindCalendarEvents : function () {
},
@@ -948,7 +954,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _afterHeaderRendererChange
* @private
*/
- _afterHeaderRendererChange : function () {
+ _afterHeaderRendererChange : function () {
var headerCell = this.get("contentBox").one("." + CAL_HD_LABEL);
headerCell.setContent(this._updateCalendarHeader(this.get('date')));
},
@@ -970,7 +976,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _afterDateChange
* @private
*/
- _afterDateChange : function () {
+ _afterDateChange : function () {
var contentBox = this.get('contentBox'),
headerCell = contentBox.one("." + CAL_HD).one("." + CAL_HD_LABEL),
@@ -1008,7 +1014,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* element ids in the given pane.
* @private
*/
- _initCalendarPane : function (baseDate, pane_id) {
+ _initCalendarPane : function (baseDate, pane_id) {
// Initialize final output HTML string
var calString = '',
// Get a list of short weekdays from the internationalization package, or else use default English ones.
@@ -1115,7 +1121,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @param {Node} pane The node corresponding to the calendar pane to be rerenders.
* @private
*/
- _rerenderCalendarPane : function (newDate, pane) {
+ _rerenderCalendarPane : function (newDate, pane) {
// Get the first day of the week from the internationalization package, or else use Sunday as default.
var firstday = this.get('strings.first_weekday') || 0,
@@ -1252,7 +1258,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @param {Date} baseDate The date with which to initialize the calendar.
* @private
*/
- _initCalendarHTML : function (baseDate) {
+ _initCalendarHTML : function (baseDate) {
// Instantiate the partials holder
var partials = {},
// Counter for iterative template replacement.
View
2  build/calendar-base/calendar-base-min.js
@@ -1 +1 @@
-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;n<this._paneNumber;n++){var r=D.addMonths(this.get("date"),n),i=D.listOfDatesInMonth(r);C(i,function(n){var r=this._getRulesForDate(n);if(r.length>0){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<this._paneNumber;e++){var t=D.addMonths(this.get("date"),e),n=this._getSelectedDatesInMonth(t);C(n,function(e){this._dateToNode(e).addClass(p).setAttribute("aria-selected",!0)},this)}},_dateToNode:function(e){var t=e.getDate(),n=0,r=t%7,i=(12+e.getMonth()-this.get("date").getMonth())%12,s=this._calendarId+"_pane_"+i,o=this._paneProperties[s].cutoffCol;switch(r){case 0:o>=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("&nbsp;")},_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;s<i+7;s++)e.one("#"+n+"_"+s+"_"+(s+23)).set("text",t++).addClass(y);var o=i;r==31&&i<=1?o=2:r==30&&i===0&&(o=1);for(var s=o;s<i+7;s++)e.one("#"+n+"_"+s+"_"+(s+30)).set("text",t++).addClass(y)},_turnNextMonthOff:function(e){var t=e.get("id"),n=this._paneProperties[t].daysInMonth,r=this._paneProperties[t].cutoffCol;for(var i=n-22;i<=12;i++)e.one("#"+t+"_"+i+"_"+(i+23)).setContent("&nbsp;").addClass(y);var s=0;n==31&&r<=1?s=2:n==30&&r===0&&(s=1);for(var i=s;i<=12;i++)e.one("#"+t+"_"+i+"_"+(i+30)).setContent("&nbsp;").addClass(y)},_afterShowNextMonthChange:function(){var e=this.get("contentBox"),t=e.one("#"+this._calendarId+"_pane_"+(this._paneNumber-1));this._cleanUpNextMonthCells(t),this.get("showNextMonth")?this._turnNextMonthOn(t):this._turnNextMonthOff(t)},_afterShowPrevMonthChange:function(){var e=this.get("contentBox"),t=e.one("#"+this._calendarId+"_pane_"+0);this.get("showPrevMonth")?this._turnPrevMonthOn(t):this._turnPrevMonthOff(t)},_afterHeaderRendererChange:function(){var e=this.get("contentBox").one("."+f);e.setContent(this._updateCalendarHeader(this.get("date")))},_afterCustomRendererChange:function(){this._restoreModifiedCells(),this._renderCustomRules()},_afterDateChange:function(){var e=this.get("contentBox"),t=e.one("."+a).one("."+f),n=e.all("."+i),r=this.get("date"),s=0;e.setStyle("visibility","hidden"),t.setContent(this._updateCalendarHeader(r)),this._restoreModifiedCells(),n.each(function(e){this._rerenderCalendarPane(D.addMonths(r,s++),e)},this),this._afterShowPrevMonthChange(),this._afterShowNextMonthChange(),this._renderCustomRules(),this._renderSelectedDates(),e.setStyle("visibility","visible")},_initCalendarPane:function(e,t){var n="",r=this.get("strings.very_short_weekdays")||["Su","Mo","Tu","We","Th","Fr","Sa"],i=this.get("strings.weekdays")||["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=this.get("strings.first_weekday")||0,o=this._getCutoffColumn(e,s),u=D.daysInMonth(e),a=["","","","","",""],f={};f.weekday_row="";for(var l=s;l<=s+6;l++)f.weekday_row+=N(P.WEEKDAY_TEMPLATE,{weekdayname:r[l%7],full_weekdayname:i[l%7]});f.weekday_row_template=N(P.WEEKDAY_ROW_TEMPLATE,f);for(var c=0;c<=5;c++)for(var p=0;p<=12;p++){var d=7*c-5+p,v=t+"_"+p+"_"+d,b=m;d<1?b=g:d>u&&(b=y);if(d<1||d>u)d="&nbsp;";var w=p>=o&&p<o+7?"":h;a[c]+=N(P.CALDAY_TEMPLATE,{day_content:d,calendar_col_class:"calendar_col"+p,calendar_col_visibility_class:w,calendar_day_class:b,calendar_day_id:v})}f.body_template="",C(a,function(e){f.body_template+=N(P.CALDAY_ROW_TEMPLATE,{calday_row:e})}),f.calendar_pane_id=t,f.calendar_pane_tabindex=this.get("tabIndex"),f.pane_arialabel=D.format(e,{format:"%B %Y"});var E=N(N(P.CALENDAR_GRID_TEMPLATE,f),P.CALENDAR_STRINGS);return this._paneProperties[t]={cutoffCol:o,daysInMonth:u,paneDate:e},E},_rerenderCalendarPane:function(e,t){var n=this.get("strings.first_weekday")||0,r=this._getCutoffColumn(e,n),i=D.daysInMonth(e),s=t.get("id");t.setStyle("visibility","hidden"),t.setAttribute("aria-label",D.format(e,{format:"%B %Y"}));for(var o=0;o<=12;o++){var u=t.all(".calendar_col"+o);u.removeClass(h);if(o<r||o>=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("&nbsp;"),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("&nbsp;"),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("&nbsp;"),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("&nbsp;"),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("&nbsp;"),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:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1">{calendar_grid_template}</div></div>',ONE_PANE_TEMPLATE:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1">{calendar_grid_template}</div></div>',TWO_PANE_TEMPLATE:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1-2"><div class = "{calendar_left_grid_class}">{calendar_grid_template}</div></div><div class="yui3-u-1-2"><div class = "{calendar_right_grid_class}">{calendar_grid_template}</div></div></div>',THREE_PANE_TEMPLATE:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1-3"><div class = "{calendar_left_grid_class}">{calendar_grid_template}</div></div><div class="yui3-u-1-3">{calendar_grid_template}</div><div class="yui3-u-1-3"><div class = "{calendar_right_grid_class}">{calendar_grid_template}</div></div></div>',CALENDAR_GRID_TEMPLATE:'<table class="{calendar_grid_class}" id="{calendar_pane_id}" role="grid" aria-readonly="true" aria-label="{pane_arialabel}" tabindex="{calendar_pane_tabindex}"><thead>{weekday_row_template}</thead><tbody>{body_template}</tbody></table>',HEADER_TEMPLATE:'<div class="yui3-g {calendar_hd_class}"><div class="yui3-u {calendar_hd_label_class}" id="{calendar_id}_header" aria-role="heading">{calheader}</div></div>',WEEKDAY_ROW_TEMPLATE:'<tr class="{calendar_weekdayrow_class}" role="row">{weekday_row}</tr>',CALDAY_ROW_TEMPLATE:'<tr class="{calendar_row_class}" role="row">{calday_row}</tr>',WEEKDAY_TEMPLATE:'<th class="{calendar_weekday_class}" role="columnheader" aria-label="{full_weekdayname}">{weekdayname}</th>',CALDAY_TEMPLATE:'<td class="{calendar_col_class} {calendar_day_class} {calendar_col_visibility_class}" id="{calendar_day_id}" role="gridcell" tabindex="-1">{day_content}</td>',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}}}})},"@VERSION@",{requires:["widget","substitute","datatype-date","datatype-date-math","cssgrids"],lang:["de","en","es","es-AR","fr","it","ja","nb-NO","nl","pt-BR","ru","zh-HANT-TW"],skinnable:!0});
+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){return D.isValidDate(e)?this._addDateToSelection(e):S.isArray(e)&&this._addDatesToSelection(e),this},deselectDates:function(e){return e?D.isValidDate(e)?this._removeDateFromSelection(e):S.isArray(e)&&this._removeDatesFromSelection(e):this._clearSelection(),this},_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;n<this._paneNumber;n++){var r=D.addMonths(this.get("date"),n),i=D.listOfDatesInMonth(r);C(i,function(n){var r=this._getRulesForDate(n);if(r.length>0){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<this._paneNumber;e++){var t=D.addMonths(this.get("date"),e),n=this._getSelectedDatesInMonth(t);C(n,function(e){this._dateToNode(e).addClass(p).setAttribute("aria-selected",!0)},this)}},_dateToNode:function(e){var t=e.getDate(),n=0,r=t%7,i=(12+e.getMonth()-this.get("date").getMonth())%12,s=this._calendarId+"_pane_"+i,o=this._paneProperties[s].cutoffCol;switch(r){case 0:o>=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("&nbsp;")},_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;s<i+7;s++)e.one("#"+n+"_"+s+"_"+(s+23)).set("text",t++).addClass(y);var o=i;r==31&&i<=1?o=2:r==30&&i===0&&(o=1);for(var s=o;s<i+7;s++)e.one("#"+n+"_"+s+"_"+(s+30)).set("text",t++).addClass(y)},_turnNextMonthOff:function(e){var t=e.get("id"),n=this._paneProperties[t].daysInMonth,r=this._paneProperties[t].cutoffCol;for(var i=n-22;i<=12;i++)e.one("#"+t+"_"+i+"_"+(i+23)).setContent("&nbsp;").addClass(y);var s=0;n==31&&r<=1?s=2:n==30&&r===0&&(s=1);for(var i=s;i<=12;i++)e.one("#"+t+"_"+i+"_"+(i+30)).setContent("&nbsp;").addClass(y)},_afterShowNextMonthChange:function(){var e=this.get("contentBox"),t=e.one("#"+this._calendarId+"_pane_"+(this._paneNumber-1));this._cleanUpNextMonthCells(t),this.get("showNextMonth")?this._turnNextMonthOn(t):this._turnNextMonthOff(t)},_afterShowPrevMonthChange:function(){var e=this.get("contentBox"),t=e.one("#"+this._calendarId+"_pane_"+0);this.get("showPrevMonth")?this._turnPrevMonthOn(t):this._turnPrevMonthOff(t)},_afterHeaderRendererChange:function(){var e=this.get("contentBox").one("."+f);e.setContent(this._updateCalendarHeader(this.get("date")))},_afterCustomRendererChange:function(){this._restoreModifiedCells(),this._renderCustomRules()},_afterDateChange:function(){var e=this.get("contentBox"),t=e.one("."+a).one("."+f),n=e.all("."+i),r=this.get("date"),s=0;e.setStyle("visibility","hidden"),t.setContent(this._updateCalendarHeader(r)),this._restoreModifiedCells(),n.each(function(e){this._rerenderCalendarPane(D.addMonths(r,s++),e)},this),this._afterShowPrevMonthChange(),this._afterShowNextMonthChange(),this._renderCustomRules(),this._renderSelectedDates(),e.setStyle("visibility","visible")},_initCalendarPane:function(e,t){var n="",r=this.get("strings.very_short_weekdays")||["Su","Mo","Tu","We","Th","Fr","Sa"],i=this.get("strings.weekdays")||["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],s=this.get("strings.first_weekday")||0,o=this._getCutoffColumn(e,s),u=D.daysInMonth(e),a=["","","","","",""],f={};f.weekday_row="";for(var l=s;l<=s+6;l++)f.weekday_row+=N(P.WEEKDAY_TEMPLATE,{weekdayname:r[l%7],full_weekdayname:i[l%7]});f.weekday_row_template=N(P.WEEKDAY_ROW_TEMPLATE,f);for(var c=0;c<=5;c++)for(var p=0;p<=12;p++){var d=7*c-5+p,v=t+"_"+p+"_"+d,b=m;d<1?b=g:d>u&&(b=y);if(d<1||d>u)d="&nbsp;";var w=p>=o&&p<o+7?"":h;a[c]+=N(P.CALDAY_TEMPLATE,{day_content:d,calendar_col_class:"calendar_col"+p,calendar_col_visibility_class:w,calendar_day_class:b,calendar_day_id:v})}f.body_template="",C(a,function(e){f.body_template+=N(P.CALDAY_ROW_TEMPLATE,{calday_row:e})}),f.calendar_pane_id=t,f.calendar_pane_tabindex=this.get("tabIndex"),f.pane_arialabel=D.format(e,{format:"%B %Y"});var E=N(N(P.CALENDAR_GRID_TEMPLATE,f),P.CALENDAR_STRINGS);return this._paneProperties[t]={cutoffCol:o,daysInMonth:u,paneDate:e},E},_rerenderCalendarPane:function(e,t){var n=this.get("strings.first_weekday")||0,r=this._getCutoffColumn(e,n),i=D.daysInMonth(e),s=t.get("id");t.setStyle("visibility","hidden"),t.setAttribute("aria-label",D.format(e,{format:"%B %Y"}));for(var o=0;o<=12;o++){var u=t.all(".calendar_col"+o);u.removeClass(h);if(o<r||o>=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("&nbsp;"),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("&nbsp;"),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("&nbsp;"),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("&nbsp;"),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("&nbsp;"),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:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1">{calendar_grid_template}</div></div>',ONE_PANE_TEMPLATE:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1">{calendar_grid_template}</div></div>',TWO_PANE_TEMPLATE:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1-2"><div class = "{calendar_left_grid_class}">{calendar_grid_template}</div></div><div class="yui3-u-1-2"><div class = "{calendar_right_grid_class}">{calendar_grid_template}</div></div></div>',THREE_PANE_TEMPLATE:'<div class="yui3-g {calendar_pane_class}" id="{calendar_id}">{header_template}<div class="yui3-u-1-3"><div class = "{calendar_left_grid_class}">{calendar_grid_template}</div></div><div class="yui3-u-1-3">{calendar_grid_template}</div><div class="yui3-u-1-3"><div class = "{calendar_right_grid_class}">{calendar_grid_template}</div></div></div>',CALENDAR_GRID_TEMPLATE:'<table class="{calendar_grid_class}" id="{calendar_pane_id}" role="grid" aria-readonly="true" aria-label="{pane_arialabel}" tabindex="{calendar_pane_tabindex}"><thead>{weekday_row_template}</thead><tbody>{body_template}</tbody></table>',HEADER_TEMPLATE:'<div class="yui3-g {calendar_hd_class}"><div class="yui3-u {calendar_hd_label_class}" id="{calendar_id}_header" aria-role="heading">{calheader}</div></div>',WEEKDAY_ROW_TEMPLATE:'<tr class="{calendar_weekdayrow_class}" role="row">{weekday_row}</tr>',CALDAY_ROW_TEMPLATE:'<tr class="{calendar_row_class}" role="row">{calday_row}</tr>',WEEKDAY_TEMPLATE:'<th class="{calendar_weekday_class}" role="columnheader" aria-label="{full_weekdayname}">{weekdayname}</th>',CALDAY_TEMPLATE:'<td class="{calendar_col_class} {calendar_day_class} {calendar_col_visibility_class}" id="{calendar_day_id}" role="gridcell" tabindex="-1">{day_content}</td>',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}}}})},"@VERSION@",{requires:["widget","substitute","datatype-date","datatype-date-math","cssgrids"],lang:["de","en","es","es-AR","fr","it","ja","nb-NO","nl","pt-BR","ru","zh-HANT-TW"],skinnable:!0});
View
24 build/calendar-base/calendar-base.js
@@ -367,6 +367,8 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* Selects a given date or array of dates.
* @method selectDates
* @param {Date|Array} dates A `Date` or `Array` of `Date`s.
+ * @return {CalendarBase} A reference to this object
+ * @chainable
*/
selectDates : function (dates) {
if (ydate.isValidDate(dates)) {
@@ -375,6 +377,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
else if (L.isArray(dates)) {
this._addDatesToSelection(dates);
}
+ return this;
},
/**
@@ -383,6 +386,8 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method deselectDates
* @param {Date|Array} [dates] A `Date` or `Array` of `Date`s, or no
* argument if all dates should be deselected.
+ * @return {CalendarBase} A reference to this object
+ * @chainable
*/
deselectDates : function (dates) {
if (!dates) {
@@ -394,6 +399,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
else if (L.isArray(dates)) {
this._removeDatesFromSelection(dates);
}
+ return this;
},
/**
@@ -620,7 +626,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _renderSelectedDates
* @private
*/
- _renderSelectedDates : function () {
+ _renderSelectedDates : function () {
this.get("contentBox").all("." + CAL_DAY_SELECTED).removeClass(CAL_DAY_SELECTED).setAttribute("aria-selected", false);
for (var paneNum = 0; paneNum < this._paneNumber; paneNum++) {
@@ -642,7 +648,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @return {Node} The node wrapping the DOM element of the cell the date
* corresponds to.
*/
- _dateToNode : function (oDate) {
+ _dateToNode : function (oDate) {
var day = oDate.getDate(),
col = 0,
daymod = day%7,
@@ -715,7 +721,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @protected
* @return {Date} The date corresponding to the DOM element that the given node wraps.
*/
- _nodeToDate : function (oNode) {
+ _nodeToDate : function (oNode) {
var idParts = oNode.get("id").split("_").reverse(),
paneNum = parseInt(idParts[2], 10),
@@ -733,7 +739,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _bindCalendarEvents
* @protected
*/
- _bindCalendarEvents : function () {
+ _bindCalendarEvents : function () {
},
@@ -948,7 +954,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _afterHeaderRendererChange
* @private
*/
- _afterHeaderRendererChange : function () {
+ _afterHeaderRendererChange : function () {
var headerCell = this.get("contentBox").one("." + CAL_HD_LABEL);
headerCell.setContent(this._updateCalendarHeader(this.get('date')));
},
@@ -970,7 +976,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _afterDateChange
* @private
*/
- _afterDateChange : function () {
+ _afterDateChange : function () {
var contentBox = this.get('contentBox'),
headerCell = contentBox.one("." + CAL_HD).one("." + CAL_HD_LABEL),
@@ -1008,7 +1014,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* element ids in the given pane.
* @private
*/
- _initCalendarPane : function (baseDate, pane_id) {
+ _initCalendarPane : function (baseDate, pane_id) {
// Initialize final output HTML string
var calString = '',
// Get a list of short weekdays from the internationalization package, or else use default English ones.
@@ -1115,7 +1121,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @param {Node} pane The node corresponding to the calendar pane to be rerenders.
* @private
*/
- _rerenderCalendarPane : function (newDate, pane) {
+ _rerenderCalendarPane : function (newDate, pane) {
// Get the first day of the week from the internationalization package, or else use Sunday as default.
var firstday = this.get('strings.first_weekday') || 0,
@@ -1252,7 +1258,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @param {Date} baseDate The date with which to initialize the calendar.
* @private
*/
- _initCalendarHTML : function (baseDate) {
+ _initCalendarHTML : function (baseDate) {
// Instantiate the partials holder
var partials = {},
// Counter for iterative template replacement.
View
106 build/calendar/calendar-coverage.js
@@ -26,10 +26,10 @@ _yuitest_coverage["build/calendar/calendar.js"] = {
path: "build/calendar/calendar.js",
code: []
};
-_yuitest_coverage["build/calendar/calendar.js"].code=["YUI.add('calendar', function (Y, NAME) {","","/**"," * The Calendar component is a UI widget that allows users"," * to view dates in a two-dimensional month grid, as well as"," * to select one or more dates, or ranges of dates. Calendar"," * is generated dynamically and relies on the developer to"," * provide for a progressive enhancement alternative."," *"," *"," * @module calendar"," */","","var getCN = Y.ClassNameManager.getClassName,"," CALENDAR = 'calendar',"," KEY_DOWN = 40,"," KEY_UP = 38,"," KEY_LEFT = 37,"," KEY_RIGHT = 39,"," KEY_ENTER = 13,"," KEY_SPACE = 32,"," CAL_HD = getCN(CALENDAR, 'header'),"," CAL_DAY_SELECTED = getCN(CALENDAR, 'day-selected'),"," CAL_DAY_HILITED = getCN(CALENDAR, 'day-highlighted'),"," CAL_DAY = getCN(CALENDAR, 'day'),"," CAL_PREVMONTH_DAY = getCN(CALENDAR, 'prevmonth-day'),"," CAL_NEXTMONTH_DAY = getCN(CALENDAR, 'nextmonth-day'),"," CAL_GRID = getCN(CALENDAR, 'grid'),"," ydate = Y.DataType.Date,"," delegate = Y.delegate,"," CAL_PANE = getCN(CALENDAR, 'pane'),"," os = Y.UA.os;","","/** Create a calendar view to represent a single or multiple"," * month range of dates, rendered as a grid with date and"," * weekday labels."," * "," * @class Calendar"," * @extends CalendarBase"," * @param config {Object} Configuration object (see Configuration attributes)"," * @constructor"," */","function Calendar(config) {"," Calendar.superclass.constructor.apply ( this, arguments );","}","","Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {",""," _keyEvents: [],",""," _highlightedDateNode: null,",""," /**"," * A property tracking the last selected date on the calendar, for the"," * purposes of multiple selection."," *"," * @property _lastSelectedDate"," * @type Date"," * @default null"," * @private"," */ "," _lastSelectedDate: null,",""," /**"," * Designated initializer. Activates the navigation plugin for the calendar."," *"," * @method initializer"," */ "," initializer : function () {"," this.plug(Y.Plugin.CalendarNavigator);","",""," this._keyEvents = [];"," this._highlightedDateNode = null;"," this._lastSelectedDate = null;"," },",""," /**"," * Overrides the _bindCalendarEvents placeholder in CalendarBase"," * and binds calendar events during bindUI stage."," * @method _bindCalendarEvents"," * @protected"," */ "," _bindCalendarEvents : function () {"," var contentBox = this.get('contentBox'),"," pane = contentBox.one(\".\" + CAL_PANE);"," pane.on(\"selectstart\", this._preventSelectionStart);"," pane.delegate(\"click\", this._clickCalendar, \".\" + CAL_DAY + \", .\" + CAL_PREVMONTH_DAY + \", .\" + CAL_NEXTMONTH_DAY, this);"," pane.delegate(\"keydown\", this._keydownCalendar, \".\" + CAL_GRID, this);"," pane.delegate(\"focus\", this._focusCalendarGrid, \".\" + CAL_GRID, this);"," pane.delegate(\"focus\", this._focusCalendarCell, \".\" + CAL_DAY, this);"," pane.delegate(\"blur\", this._blurCalendarGrid, \".\" + CAL_GRID + \",.\" + CAL_DAY, this);"," },",""," /**"," * Prevents text selection if it is started within the calendar pane"," * @method _preventSelectionStart"," * @param event {Event} The selectstart event"," * @protected"," */ "," _preventSelectionStart : function (event) {"," event.preventDefault();"," },",""," /**"," * Highlights a specific date node with keyboard highlight class"," * @method _highlightDateNode"," * @param oDate {Date} Date corresponding the node to be highlighted"," * @protected"," */ "," _highlightDateNode : function (oDate) {"," this._unhighlightCurrentDateNode();"," var newNode = this._dateToNode(oDate);"," newNode.focus();"," newNode.addClass(CAL_DAY_HILITED);"," },",""," /**"," * Unhighlights a specific date node currently highlighted with keyboard highlight class"," * @method _unhighlightCurrentDateNode"," * @protected"," */ "," _unhighlightCurrentDateNode : function () {"," var allHilitedNodes = this.get(\"contentBox\").all(\".\" + CAL_DAY_HILITED);"," if (allHilitedNodes) {"," allHilitedNodes.removeClass(CAL_DAY_HILITED);"," }"," },",""," /**"," * Returns the grid number for a specific calendar grid (for multi-grid templates)"," * @method _getGridNumber"," * @param gridNode {Node} Node corresponding to a specific grid"," * @protected"," */ "," _getGridNumber : function (gridNode) {"," var idParts = gridNode.get(\"id\").split(\"_\").reverse();"," return parseInt(idParts[0], 10);"," },",""," /**"," * Handler for loss of focus of calendar grid"," * @method _blurCalendarGrid"," * @protected"," */ "," _blurCalendarGrid : function (ev) {"," this._unhighlightCurrentDateNode();"," },","",""," /**"," * Handler for gain of focus of calendar cell"," * @method _focusCalendarCell"," * @protected"," */ "," _focusCalendarCell : function (ev) {"," this._highlightedDateNode = ev.target;"," ev.stopPropagation();"," },",""," /**"," * Handler for gain of focus of calendar grid"," * @method _focusCalendarGrid"," * @protected"," */ "," _focusCalendarGrid : function (ev) { "," this._unhighlightCurrentDateNode();"," this._highlightedDateNode = null;"," },",""," /**"," * Handler for keyboard press on a calendar grid"," * @method _keydownCalendar"," * @protected"," */ "," _keydownCalendar : function (ev) {"," var gridNum = this._getGridNumber(ev.target),"," curDate = !this._highlightedDateNode ? null : this._nodeToDate(this._highlightedDateNode),"," keyCode = ev.keyCode,"," dayNum = 0,"," dir = '';",""," switch(keyCode) {"," case KEY_DOWN: "," dayNum = 7;"," dir = 's';"," break;"," case KEY_UP: "," dayNum = -7;"," dir = 'n';"," break;"," case KEY_LEFT: "," dayNum = -1;"," dir = 'w';"," break;"," case KEY_RIGHT:"," dayNum = 1;"," dir = 'e';"," break;"," case KEY_SPACE: case KEY_ENTER:"," ev.preventDefault();"," if (this._highlightedDateNode) {"," var selMode = this.get(\"selectionMode\");"," if (selMode === \"single\" && !this._highlightedDateNode.hasClass(CAL_DAY_SELECTED)) {"," this._clearSelection(true);"," this._addDateToSelection(curDate);"," }"," else if (selMode === \"multiple\" || selMode === \"multiple-sticky\") {"," if (this._highlightedDateNode.hasClass(CAL_DAY_SELECTED)) {"," this._removeDateFromSelection(curDate);"," }"," else {"," this._addDateToSelection(curDate);"," }"," }"," }"," break;"," }"," ",""," if (keyCode == KEY_DOWN || keyCode == KEY_UP || keyCode == KEY_LEFT || keyCode == KEY_RIGHT) {",""," if (!curDate) {"," curDate = ydate.addMonths(this.get(\"date\"), gridNum);"," dayNum = 0;"," }"," ev.preventDefault();"," var newDate = ydate.addDays(curDate, dayNum),"," startDate = this.get(\"date\"),"," endDate = ydate.addMonths(this.get(\"date\"), this._paneNumber - 1),"," lastPaneDate = new Date(endDate);"," endDate.setDate(ydate.daysInMonth(endDate));"," "," if (ydate.isInRange(newDate, startDate, endDate)) {","/*"," var paneShift = (newDate.getMonth() - curDate.getMonth()) % 10;","",""," if (paneShift != 0) {"," var newGridNum = gridNum + paneShift,"," contentBox = this.get('contentBox'),"," newPane = contentBox.one(\"#\" + this._calendarId + \"_pane_\" + newGridNum);"," newPane.focus();"," }","*/"," this._highlightDateNode(newDate);"," }"," else if (ydate.isGreater(startDate, newDate)) {"," if (!ydate.isGreaterOrEqual(this.get(\"minimumDate\"), startDate)) {"," this.set(\"date\", ydate.addMonths(startDate, -1));"," this._highlightDateNode(newDate);"," }"," }"," else if (ydate.isGreater(newDate, endDate)) {"," if (!ydate.isGreaterOrEqual(lastPaneDate, this.get(\"maximumDate\"))) {"," this.set(\"date\", ydate.addMonths(startDate, 1));"," this._highlightDateNode(newDate);"," }"," }",""," }"," },",""," /**"," * Handles the calendar clicks based on selection mode."," * @method _clickCalendar"," * @param {Event} ev A click event"," * @private"," */ "," _clickCalendar : function (ev) {"," var clickedCell = ev.currentTarget,"," clickedCellIsDay = clickedCell.hasClass(CAL_DAY) && "," !clickedCell.hasClass(CAL_PREVMONTH_DAY) && "," !clickedCell.hasClass(CAL_NEXTMONTH_DAY),"," clickedCellIsSelected = clickedCell.hasClass(CAL_DAY_SELECTED);"," switch (this.get(\"selectionMode\")) {"," case(\"single\"):"," if (clickedCellIsDay) {"," if (!clickedCellIsSelected) {"," this._clearSelection(true); "," this._addDateToSelection(this._nodeToDate(clickedCell));"," }"," }"," break;"," case(\"multiple-sticky\"):"," if (clickedCellIsDay) {"," if (clickedCellIsSelected) {"," this._removeDateFromSelection(this._nodeToDate(clickedCell));"," }"," else {"," this._addDateToSelection(this._nodeToDate(clickedCell));"," }"," }"," break;"," case(\"multiple\"):"," if (clickedCellIsDay) {"," if (!ev.metaKey && !ev.ctrlKey && !ev.shiftKey) {"," this._clearSelection(true);"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," else if (((os == 'macintosh' && ev.metaKey) || (os != 'macintosh' && ev.ctrlKey)) && !ev.shiftKey) {"," if (clickedCellIsSelected) {"," this._removeDateFromSelection(this._nodeToDate(clickedCell));"," this._lastSelectedDate = null;"," }"," else {"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," }"," else if (((os == 'macintosh' && ev.metaKey) || (os != 'macintosh' && ev.ctrlKey)) && ev.shiftKey) {"," if (this._lastSelectedDate) {"," var selectedDate = this._nodeToDate(clickedCell);"," this._addDateRangeToSelection(selectedDate, this._lastSelectedDate);"," this._lastSelectedDate = selectedDate;"," }"," else {"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," "," }"," else if (ev.shiftKey) {"," if (this._lastSelectedDate) {"," var selectedDate = this._nodeToDate(clickedCell);"," this._clearSelection(true);"," this._addDateRangeToSelection(selectedDate, this._lastSelectedDate);"," this._lastSelectedDate = selectedDate;"," }"," else {"," this._clearSelection(true);"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," }"," }"," break;"," }",""," if (clickedCellIsDay) {"," /**"," * Fired when a specific date cell in the calendar is clicked. The event carries a "," * payload which includes a `cell` property corresponding to the node of the actual"," * date cell, and a `date` property, with the `Date` that was clicked."," *"," * @event dateClick"," */"," this.fire(\"dateClick\", {cell: clickedCell, date: this._nodeToDate(clickedCell)});"," }"," else if (clickedCell.hasClass(CAL_PREVMONTH_DAY)) {"," /**"," * Fired when any of the previous month's days displayed before the calendar grid"," * are clicked."," *"," * @event prevMonthClick"," */"," this.fire(\"prevMonthClick\");"," }"," else if (clickedCell.hasClass(CAL_NEXTMONTH_DAY)) {"," /**"," * Fired when any of the next month's days displayed after the calendar grid"," * are clicked."," *"," * @event nextMonthClick"," */"," this.fire(\"nextMonthClick\");"," }"," },",""," /**"," * Subtracts one month from the current calendar view."," * @method subtractMonth"," */ "," subtractMonth : function (e) {"," this.set(\"date\", ydate.addMonths(this.get(\"date\"), -1));"," if (e) {"," e.halt();"," }"," },",""," /**"," * Subtracts one year from the current calendar view."," * @method subtractYear"," */ "," subtractYear : function (e) {"," this.set(\"date\", ydate.addYears(this.get(\"date\"), -1));"," if (e) {"," e.halt();"," }"," },",""," /**"," * Adds one month to the current calendar view."," * @method addMonth"," */ "," addMonth : function (e) { "," this.set(\"date\", ydate.addMonths(this.get(\"date\"), 1));"," if (e) {"," e.halt();"," }"," },",""," /**"," * Adds one year to the current calendar view."," * @method addYear"," */ "," addYear : function (e) {"," this.set(\"date\", ydate.addYears(this.get(\"date\"), 1));"," if (e) {"," e.halt();"," }"," }","},","","{"," /**"," * The identity of the widget."," *"," * @property NAME"," * @type String"," * @default 'calendar'"," * @readOnly"," * @protected"," * @static"," */ "," NAME: \"calendar\",",""," /**"," * Static property used to define the default attribute configuration of"," * the Widget."," *"," * @property ATTRS"," * @type {Object}"," * @protected"," * @static"," */ "," ATTRS: {",""," /**"," * A setting specifying the type of selection the calendar allows."," * Possible values include:"," * <ul>"," * <li>`single` - One date at a time</li>"," * <li>`multiple-sticky` - Multiple dates, selected one at a time (the dates \"stick\"). This option"," * is appropriate for mobile devices, where function keys from the keyboard are not available.</li>"," * <li>`multiple` - Multiple dates, selected with Ctrl/Meta keys for additional single"," * dates, and Shift key for date ranges.</li>"," *"," * @attribute selectionMode"," * @type String"," * @default single"," */"," selectionMode: {"," value: \"single\""," },",""," /**"," * The date corresponding to the current calendar view. Always"," * normalized to the first of the month that contains the date"," * at assignment time. Used as the first date visible in the"," * calendar."," *"," * @attribute date"," * @type Date"," * @default Today's date as set on the user's computer."," */"," date: {"," value: new Date(),"," lazyAdd: false,"," setter: function (val) {",""," var newDate = this._normalizeDate(val),"," newTopDate = ydate.addMonths(newDate, this._paneNumber - 1);"," var minDate = this.get(\"minimumDate\");"," var maxDate = this.get(\"maximumDate\");"," if ((!minDate || ydate.isGreaterOrEqual(newDate, minDate)) && "," (!maxDate || ydate.isGreaterOrEqual(maxDate, newTopDate))) {"," return newDate;"," }",""," else if (minDate && ydate.isGreater(minDate, newDate)) {"," return minDate;"," }",""," else if (maxDate && ydate.isGreater(newTopDate, maxDate)) {"," var actualMaxDate = ydate.addMonths(maxDate, -1*(this._paneNumber - 1));"," return actualMaxDate;"," }"," }"," },",""," /**"," * The minimum date that can be displayed by the calendar. The calendar will not"," * allow dates earlier than this one to be set, and will reset any earlier date to"," * this date. Should be `null` if no minimum date is needed."," *"," * @attribute minimumDate"," * @type Date"," * @default null"," */"," minimumDate: {"," value: null,"," setter: function (val) {"," if (val) {"," var curDate = this.get('date'),"," newMinDate = this._normalizeDate(val);"," if (curDate && !ydate.isGreaterOrEqual(curDate, newMinDate)) {"," this.set('date', newMinDate);"," }"," return newMinDate;"," }"," else {"," return this._normalizeDate(val);"," }"," }"," },",""," /**"," * The maximum date that can be displayed by the calendar. The calendar will not"," * allow dates later than this one to be set, and will reset any later date to"," * this date. Should be `null` if no maximum date is needed."," *"," * @attribute maximumDate"," * @type Date"," * @default null"," */"," maximumDate: {"," value: null,"," setter: function (val) {"," if (val) {"," var curDate = this.get('date'),"," newMaxDate = this._normalizeDate(val);"," if (curDate && !ydate.isGreaterOrEqual(val, ydate.addMonths(curDate, this._paneNumber - 1))) {"," this.set('date', ydate.addMonths(newMaxDate, -1*(this._paneNumber -1)));"," }"," return newMaxDate;"," }"," else {"," return val;"," }"," }"," }"," }","});","","}, '@VERSION@', {\"requires\": [\"calendar-base\", \"calendarnavigator\"], \"lang\": [\"de\", \"en\", \"es\", \"es-AR\", \"fr\", \"it\", \"ja\", \"nb-NO\", \"nl\", \"pt-BR\", \"ru\", \"zh-HANT-TW\"], \"skinnable\": true});"];
-_yuitest_coverage["build/calendar/calendar.js"].lines = {"1":0,"14":0,"43":0,"44":0,"47":0,"70":0,"73":0,"74":0,"75":0,"85":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"102":0,"112":0,"113":0,"114":0,"115":0,"124":0,"125":0,"126":0,"137":0,"138":0,"147":0,"157":0,"158":0,"167":0,"168":0,"177":0,"183":0,"185":0,"186":0,"187":0,"189":0,"190":0,"191":0,"193":0,"194":0,"195":0,"197":0,"198":0,"199":0,"201":0,"202":0,"203":0,"204":0,"205":0,"206":0,"208":0,"209":0,"210":0,"213":0,"217":0,"221":0,"223":0,"224":0,"225":0,"227":0,"228":0,"232":0,"234":0,"246":0,"248":0,"249":0,"250":0,"251":0,"254":0,"255":0,"256":0,"257":0,"271":0,"276":0,"278":0,"279":0,"280":0,"281":0,"284":0,"286":0,"287":0,"288":0,"291":0,"294":0,"296":0,"297":0,"298":0,"299":0,"300":0,"302":0,"303":0,"304":0,"305":0,"308":0,"309":0,"312":0,"313":0,"314":0,"315":0,"316":0,"319":0,"320":0,"324":0,"325":0,"326":0,"327":0,"328":0,"329":0,"332":0,"333":0,"334":0,"338":0,"341":0,"349":0,"351":0,"358":0,"360":0,"367":0,"376":0,"377":0,"378":0,"387":0,"388":0,"389":0,"398":0,"399":0,"400":0,"409":0,"410":0,"411":0,"473":0,"475":0,"476":0,"477":0,"479":0,"482":0,"483":0,"486":0,"487":0,"488":0,"505":0,"506":0,"508":0,"509":0,"511":0,"514":0,"531":0,"532":0,"534":0,"535":0,"537":0,"540":0};
-_yuitest_coverage["build/calendar/calendar.js"].functions = {"Calendar:43":0,"initializer:69":0,"_bindCalendarEvents:84":0,"_preventSelectionStart:101":0,"_highlightDateNode:111":0,"_unhighlightCurrentDateNode:123":0,"_getGridNumber:136":0,"_blurCalendarGrid:146":0,"_focusCalendarCell:156":0,"_focusCalendarGrid:166":0,"_keydownCalendar:176":0,"_clickCalendar:270":0,"subtractMonth:375":0,"subtractYear:386":0,"addMonth:397":0,"addYear:408":0,"setter:471":0,"setter:504":0,"setter:530":0,"(anonymous 1):1":0};
-_yuitest_coverage["build/calendar/calendar.js"].coveredLines = 153;
+_yuitest_coverage["build/calendar/calendar.js"].code=["YUI.add('calendar', function (Y, NAME) {","","/**"," * The Calendar component is a UI widget that allows users"," * to view dates in a two-dimensional month grid, as well as"," * to select one or more dates, or ranges of dates. Calendar"," * is generated dynamically and relies on the developer to"," * provide for a progressive enhancement alternative."," *"," *"," * @module calendar"," */","","var getCN = Y.ClassNameManager.getClassName,"," CALENDAR = 'calendar',"," KEY_DOWN = 40,"," KEY_UP = 38,"," KEY_LEFT = 37,"," KEY_RIGHT = 39,"," KEY_ENTER = 13,"," KEY_SPACE = 32,"," CAL_HD = getCN(CALENDAR, 'header'),"," CAL_DAY_SELECTED = getCN(CALENDAR, 'day-selected'),"," CAL_DAY_HILITED = getCN(CALENDAR, 'day-highlighted'),"," CAL_DAY = getCN(CALENDAR, 'day'),"," CAL_PREVMONTH_DAY = getCN(CALENDAR, 'prevmonth-day'),"," CAL_NEXTMONTH_DAY = getCN(CALENDAR, 'nextmonth-day'),"," CAL_GRID = getCN(CALENDAR, 'grid'),"," ydate = Y.DataType.Date,"," delegate = Y.delegate,"," CAL_PANE = getCN(CALENDAR, 'pane'),"," os = Y.UA.os;","","/** Create a calendar view to represent a single or multiple"," * month range of dates, rendered as a grid with date and"," * weekday labels."," * "," * @class Calendar"," * @extends CalendarBase"," * @param config {Object} Configuration object (see Configuration attributes)"," * @constructor"," */","function Calendar(config) {"," Calendar.superclass.constructor.apply ( this, arguments );","}","","Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {",""," _keyEvents: [],",""," _highlightedDateNode: null,",""," /**"," * A property tracking the last selected date on the calendar, for the"," * purposes of multiple selection."," *"," * @property _lastSelectedDate"," * @type Date"," * @default null"," * @private"," */ "," _lastSelectedDate: null,",""," /**"," * Designated initializer. Activates the navigation plugin for the calendar."," *"," * @method initializer"," */ "," initializer : function () {"," this.plug(Y.Plugin.CalendarNavigator);","",""," this._keyEvents = [];"," this._highlightedDateNode = null;"," this._lastSelectedDate = null;"," },",""," /**"," * Overrides the _bindCalendarEvents placeholder in CalendarBase"," * and binds calendar events during bindUI stage."," * @method _bindCalendarEvents"," * @protected"," */ "," _bindCalendarEvents : function () {"," var contentBox = this.get('contentBox'),"," pane = contentBox.one(\".\" + CAL_PANE);"," pane.on(\"selectstart\", this._preventSelectionStart);"," pane.delegate(\"click\", this._clickCalendar, \".\" + CAL_DAY + \", .\" + CAL_PREVMONTH_DAY + \", .\" + CAL_NEXTMONTH_DAY, this);"," pane.delegate(\"keydown\", this._keydownCalendar, \".\" + CAL_GRID, this);"," pane.delegate(\"focus\", this._focusCalendarGrid, \".\" + CAL_GRID, this);"," pane.delegate(\"focus\", this._focusCalendarCell, \".\" + CAL_DAY, this);"," pane.delegate(\"blur\", this._blurCalendarGrid, \".\" + CAL_GRID + \",.\" + CAL_DAY, this);"," },",""," /**"," * Prevents text selection if it is started within the calendar pane"," * @method _preventSelectionStart"," * @param event {Event} The selectstart event"," * @protected"," */ "," _preventSelectionStart : function (event) {"," event.preventDefault();"," },",""," /**"," * Highlights a specific date node with keyboard highlight class"," * @method _highlightDateNode"," * @param oDate {Date} Date corresponding the node to be highlighted"," * @protected"," */ "," _highlightDateNode : function (oDate) {"," this._unhighlightCurrentDateNode();"," var newNode = this._dateToNode(oDate);"," newNode.focus();"," newNode.addClass(CAL_DAY_HILITED);"," },",""," /**"," * Unhighlights a specific date node currently highlighted with keyboard highlight class"," * @method _unhighlightCurrentDateNode"," * @protected"," */ "," _unhighlightCurrentDateNode : function () {"," var allHilitedNodes = this.get(\"contentBox\").all(\".\" + CAL_DAY_HILITED);"," if (allHilitedNodes) {"," allHilitedNodes.removeClass(CAL_DAY_HILITED);"," }"," },",""," /**"," * Returns the grid number for a specific calendar grid (for multi-grid templates)"," * @method _getGridNumber"," * @param gridNode {Node} Node corresponding to a specific grid"," * @protected"," */ "," _getGridNumber : function (gridNode) {"," var idParts = gridNode.get(\"id\").split(\"_\").reverse();"," return parseInt(idParts[0], 10);"," },",""," /**"," * Handler for loss of focus of calendar grid"," * @method _blurCalendarGrid"," * @protected"," */ "," _blurCalendarGrid : function (ev) {"," this._unhighlightCurrentDateNode();"," },","",""," /**"," * Handler for gain of focus of calendar cell"," * @method _focusCalendarCell"," * @protected"," */ "," _focusCalendarCell : function (ev) {"," this._highlightedDateNode = ev.target;"," ev.stopPropagation();"," },",""," /**"," * Handler for gain of focus of calendar grid"," * @method _focusCalendarGrid"," * @protected"," */ "," _focusCalendarGrid : function (ev) { "," this._unhighlightCurrentDateNode();"," this._highlightedDateNode = null;"," },",""," /**"," * Handler for keyboard press on a calendar grid"," * @method _keydownCalendar"," * @protected"," */ "," _keydownCalendar : function (ev) {"," var gridNum = this._getGridNumber(ev.target),"," curDate = !this._highlightedDateNode ? null : this._nodeToDate(this._highlightedDateNode),"," keyCode = ev.keyCode,"," dayNum = 0,"," dir = '';",""," switch(keyCode) {"," case KEY_DOWN: "," dayNum = 7;"," dir = 's';"," break;"," case KEY_UP: "," dayNum = -7;"," dir = 'n';"," break;"," case KEY_LEFT: "," dayNum = -1;"," dir = 'w';"," break;"," case KEY_RIGHT:"," dayNum = 1;"," dir = 'e';"," break;"," case KEY_SPACE: case KEY_ENTER:"," ev.preventDefault();"," if (this._highlightedDateNode) {"," var selMode = this.get(\"selectionMode\");"," if (selMode === \"single\" && !this._highlightedDateNode.hasClass(CAL_DAY_SELECTED)) {"," this._clearSelection(true);"," this._addDateToSelection(curDate);"," }"," else if (selMode === \"multiple\" || selMode === \"multiple-sticky\") {"," if (this._highlightedDateNode.hasClass(CAL_DAY_SELECTED)) {"," this._removeDateFromSelection(curDate);"," }"," else {"," this._addDateToSelection(curDate);"," }"," }"," }"," break;"," }"," ",""," if (keyCode == KEY_DOWN || keyCode == KEY_UP || keyCode == KEY_LEFT || keyCode == KEY_RIGHT) {",""," if (!curDate) {"," curDate = ydate.addMonths(this.get(\"date\"), gridNum);"," dayNum = 0;"," }"," ev.preventDefault();"," var newDate = ydate.addDays(curDate, dayNum),"," startDate = this.get(\"date\"),"," endDate = ydate.addMonths(this.get(\"date\"), this._paneNumber - 1),"," lastPaneDate = new Date(endDate);"," endDate.setDate(ydate.daysInMonth(endDate));"," "," if (ydate.isInRange(newDate, startDate, endDate)) {","/*"," var paneShift = (newDate.getMonth() - curDate.getMonth()) % 10;","",""," if (paneShift != 0) {"," var newGridNum = gridNum + paneShift,"," contentBox = this.get('contentBox'),"," newPane = contentBox.one(\"#\" + this._calendarId + \"_pane_\" + newGridNum);"," newPane.focus();"," }","*/"," this._highlightDateNode(newDate);"," }"," else if (ydate.isGreater(startDate, newDate)) {"," if (!ydate.isGreaterOrEqual(this.get(\"minimumDate\"), startDate)) {"," this.set(\"date\", ydate.addMonths(startDate, -1));"," this._highlightDateNode(newDate);"," }"," }"," else if (ydate.isGreater(newDate, endDate)) {"," if (!ydate.isGreaterOrEqual(lastPaneDate, this.get(\"maximumDate\"))) {"," this.set(\"date\", ydate.addMonths(startDate, 1));"," this._highlightDateNode(newDate);"," }"," }",""," }"," },",""," /**"," * Handles the calendar clicks based on selection mode."," * @method _clickCalendar"," * @param {Event} ev A click event"," * @private"," */ "," _clickCalendar : function (ev) {"," var clickedCell = ev.currentTarget,"," clickedCellIsDay = clickedCell.hasClass(CAL_DAY) && "," !clickedCell.hasClass(CAL_PREVMONTH_DAY) && "," !clickedCell.hasClass(CAL_NEXTMONTH_DAY),"," clickedCellIsSelected = clickedCell.hasClass(CAL_DAY_SELECTED);"," switch (this.get(\"selectionMode\")) {"," case(\"single\"):"," if (clickedCellIsDay) {"," if (!clickedCellIsSelected) {"," this._clearSelection(true); "," this._addDateToSelection(this._nodeToDate(clickedCell));"," }"," }"," break;"," case(\"multiple-sticky\"):"," if (clickedCellIsDay) {"," if (clickedCellIsSelected) {"," this._removeDateFromSelection(this._nodeToDate(clickedCell));"," }"," else {"," this._addDateToSelection(this._nodeToDate(clickedCell));"," }"," }"," break;"," case(\"multiple\"):"," if (clickedCellIsDay) {"," if (!ev.metaKey && !ev.ctrlKey && !ev.shiftKey) {"," this._clearSelection(true);"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," else if (((os == 'macintosh' && ev.metaKey) || (os != 'macintosh' && ev.ctrlKey)) && !ev.shiftKey) {"," if (clickedCellIsSelected) {"," this._removeDateFromSelection(this._nodeToDate(clickedCell));"," this._lastSelectedDate = null;"," }"," else {"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," }"," else if (((os == 'macintosh' && ev.metaKey) || (os != 'macintosh' && ev.ctrlKey)) && ev.shiftKey) {"," if (this._lastSelectedDate) {"," var selectedDate = this._nodeToDate(clickedCell);"," this._addDateRangeToSelection(selectedDate, this._lastSelectedDate);"," this._lastSelectedDate = selectedDate;"," }"," else {"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," "," }"," else if (ev.shiftKey) {"," if (this._lastSelectedDate) {"," var selectedDate = this._nodeToDate(clickedCell);"," this._clearSelection(true);"," this._addDateRangeToSelection(selectedDate, this._lastSelectedDate);"," this._lastSelectedDate = selectedDate;"," }"," else {"," this._clearSelection(true);"," this._lastSelectedDate = this._nodeToDate(clickedCell);"," this._addDateToSelection(this._lastSelectedDate);"," }"," }"," }"," break;"," }",""," if (clickedCellIsDay) {"," /**"," * Fired when a specific date cell in the calendar is clicked. The event carries a "," * payload which includes a `cell` property corresponding to the node of the actual"," * date cell, and a `date` property, with the `Date` that was clicked."," *"," * @event dateClick"," */"," this.fire(\"dateClick\", {cell: clickedCell, date: this._nodeToDate(clickedCell)});"," }"," else if (clickedCell.hasClass(CAL_PREVMONTH_DAY)) {"," /**"," * Fired when any of the previous month's days displayed before the calendar grid"," * are clicked."," *"," * @event prevMonthClick"," */"," this.fire(\"prevMonthClick\");"," }"," else if (clickedCell.hasClass(CAL_NEXTMONTH_DAY)) {"," /**"," * Fired when any of the next month's days displayed after the calendar grid"," * are clicked."," *"," * @event nextMonthClick"," */"," this.fire(\"nextMonthClick\");"," }"," },",""," /**"," * Subtracts one month from the current calendar view."," * @method subtractMonth"," * @return {Calendar} A reference to this object"," * @chainable"," */ "," subtractMonth : function (e) {"," this.set(\"date\", ydate.addMonths(this.get(\"date\"), -1));"," if (e) {"," e.halt();"," }"," return this;"," },",""," /**"," * Subtracts one year from the current calendar view."," * @method subtractYear"," * @return {Calendar} A reference to this object"," * @chainable"," */ "," subtractYear : function (e) {"," this.set(\"date\", ydate.addYears(this.get(\"date\"), -1));"," if (e) {"," e.halt();"," }"," return this;"," },",""," /**"," * Adds one month to the current calendar view."," * @method addMonth"," * @return {Calendar} A reference to this object"," * @chainable"," */ "," addMonth : function (e) { "," this.set(\"date\", ydate.addMonths(this.get(\"date\"), 1));"," if (e) {"," e.halt();"," }"," return this;"," },",""," /**"," * Adds one year to the current calendar view."," * @method addYear"," * @return {Calendar} A reference to this object"," * @chainable"," */ "," addYear : function (e) {"," this.set(\"date\", ydate.addYears(this.get(\"date\"), 1));"," if (e) {"," e.halt();"," }"," return this;"," }","},","","{"," /**"," * The identity of the widget."," *"," * @property NAME"," * @type String"," * @default 'calendar'"," * @readOnly"," * @protected"," * @static"," */ "," NAME: \"calendar\",",""," /**"," * Static property used to define the default attribute configuration of"," * the Widget."," *"," * @property ATTRS"," * @type {Object}"," * @protected"," * @static"," */ "," ATTRS: {",""," /**"," * A setting specifying the type of selection the calendar allows."," * Possible values include:"," * <ul>"," * <li>`single` - One date at a time</li>"," * <li>`multiple-sticky` - Multiple dates, selected one at a time (the dates \"stick\"). This option"," * is appropriate for mobile devices, where function keys from the keyboard are not available.</li>"," * <li>`multiple` - Multiple dates, selected with Ctrl/Meta keys for additional single"," * dates, and Shift key for date ranges.</li>"," *"," * @attribute selectionMode"," * @type String"," * @default single"," */"," selectionMode: {"," value: \"single\""," },",""," /**"," * The date corresponding to the current calendar view. Always"," * normalized to the first of the month that contains the date"," * at assignment time. Used as the first date visible in the"," * calendar."," *"," * @attribute date"," * @type Date"," * @default Today's date as set on the user's computer."," */"," date: {"," value: new Date(),"," lazyAdd: false,"," setter: function (val) {",""," var newDate = this._normalizeDate(val),"," newTopDate = ydate.addMonths(newDate, this._paneNumber - 1);"," var minDate = this.get(\"minimumDate\");"," var maxDate = this.get(\"maximumDate\");"," if ((!minDate || ydate.isGreaterOrEqual(newDate, minDate)) && "," (!maxDate || ydate.isGreaterOrEqual(maxDate, newTopDate))) {"," return newDate;"," }",""," else if (minDate && ydate.isGreater(minDate, newDate)) {"," return minDate;"," }",""," else if (maxDate && ydate.isGreater(newTopDate, maxDate)) {"," var actualMaxDate = ydate.addMonths(maxDate, -1*(this._paneNumber - 1));"," return actualMaxDate;"," }"," }"," },",""," /**"," * The minimum date that can be displayed by the calendar. The calendar will not"," * allow dates earlier than this one to be set, and will reset any earlier date to"," * this date. Should be `null` if no minimum date is needed."," *"," * @attribute minimumDate"," * @type Date"," * @default null"," */"," minimumDate: {"," value: null,"," setter: function (val) {"," if (val) {"," var curDate = this.get('date'),"," newMinDate = this._normalizeDate(val);"," if (curDate && !ydate.isGreaterOrEqual(curDate, newMinDate)) {"," this.set('date', newMinDate);"," }"," return newMinDate;"," }"," else {"," return this._normalizeDate(val);"," }"," }"," },",""," /**"," * The maximum date that can be displayed by the calendar. The calendar will not"," * allow dates later than this one to be set, and will reset any later date to"," * this date. Should be `null` if no maximum date is needed."," *"," * @attribute maximumDate"," * @type Date"," * @default null"," */"," maximumDate: {"," value: null,"," setter: function (val) {"," if (val) {"," var curDate = this.get('date'),"," newMaxDate = this._normalizeDate(val);"," if (curDate && !ydate.isGreaterOrEqual(val, ydate.addMonths(curDate, this._paneNumber - 1))) {"," this.set('date', ydate.addMonths(newMaxDate, -1*(this._paneNumber -1)));"," }"," return newMaxDate;"," }"," else {"," return val;"," }"," }"," }"," }","});","","}, '@VERSION@', {\"requires\": [\"calendar-base\", \"calendarnavigator\"], \"lang\": [\"de\", \"en\", \"es\", \"es-AR\", \"fr\", \"it\", \"ja\", \"nb-NO\", \"nl\", \"pt-BR\", \"ru\", \"zh-HANT-TW\"], \"skinnable\": true});"];
+_yuitest_coverage["build/calendar/calendar.js"].lines = {"1":0,"14":0,"43":0,"44":0,"47":0,"70":0,"73":0,"74":0,"75":0,"85":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"102":0,"112":0,"113":0,"114":0,"115":0,"124":0,"125":0,"126":0,"137":0,"138":0,"147":0,"157":0,"158":0,"167":0,"168":0,"177":0,"183":0,"185":0,"186":0,"187":0,"189":0,"190":0,"191":0,"193":0,"194":0,"195":0,"197":0,"198":0,"199":0,"201":0,"202":0,"203":0,"204":0,"205":0,"206":0,"208":0,"209":0,"210":0,"213":0,"217":0,"221":0,"223":0,"224":0,"225":0,"227":0,"228":0,"232":0,"234":0,"246":0,"248":0,"249":0,"250":0,"251":0,"254":0,"255":0,"256":0,"257":0,"271":0,"276":0,"278":0,"279":0,"280":0,"281":0,"284":0,"286":0,"287":0,"288":0,"291":0,"294":0,"296":0,"297":0,"298":0,"299":0,"300":0,"302":0,"303":0,"304":0,"305":0,"308":0,"309":0,"312":0,"313":0,"314":0,"315":0,"316":0,"319":0,"320":0,"324":0,"325":0,"326":0,"327":0,"328":0,"329":0,"332":0,"333":0,"334":0,"338":0,"341":0,"349":0,"351":0,"358":0,"360":0,"367":0,"378":0,"379":0,"380":0,"382":0,"392":0,"393":0,"394":0,"396":0,"406":0,"407":0,"408":0,"410":0,"420":0,"421":0,"422":0,"424":0,"485":0,"487":0,"488":0,"489":0,"491":0,"494":0,"495":0,"498":0,"499":0,"500":0,"517":0,"518":0,"520":0,"521":0,"523":0,"526":0,"543":0,"544":0,"546":0,"547":0,"549":0,"552":0};
+_yuitest_coverage["build/calendar/calendar.js"].functions = {"Calendar:43":0,"initializer:69":0,"_bindCalendarEvents:84":0,"_preventSelectionStart:101":0,"_highlightDateNode:111":0,"_unhighlightCurrentDateNode:123":0,"_getGridNumber:136":0,"_blurCalendarGrid:146":0,"_focusCalendarCell:156":0,"_focusCalendarGrid:166":0,"_keydownCalendar:176":0,"_clickCalendar:270":0,"subtractMonth:377":0,"subtractYear:391":0,"addMonth:405":0,"addYear:419":0,"setter:483":0,"setter:516":0,"setter:542":0,"(anonymous 1):1":0};
+_yuitest_coverage["build/calendar/calendar.js"].coveredLines = 157;
_yuitest_coverage["build/calendar/calendar.js"].coveredFunctions = 20;
_yuitest_coverline("build/calendar/calendar.js", 1);
YUI.add('calendar', function (Y, NAME) {
@@ -536,61 +536,77 @@ this.fire("nextMonthClick");
/**
* Subtracts one month from the current calendar view.
* @method subtractMonth
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
subtractMonth : function (e) {
- _yuitest_coverfunc("build/calendar/calendar.js", "subtractMonth", 375);
-_yuitest_coverline("build/calendar/calendar.js", 376);
+ _yuitest_coverfunc("build/calendar/calendar.js", "subtractMonth", 377);
+_yuitest_coverline("build/calendar/calendar.js", 378);
this.set("date", ydate.addMonths(this.get("date"), -1));
- _yuitest_coverline("build/calendar/calendar.js", 377);
+ _yuitest_coverline("build/calendar/calendar.js", 379);
if (e) {
- _yuitest_coverline("build/calendar/calendar.js", 378);
+ _yuitest_coverline("build/calendar/calendar.js", 380);
e.halt();
}
+ _yuitest_coverline("build/calendar/calendar.js", 382);
+return this;
},
/**
* Subtracts one year from the current calendar view.
* @method subtractYear
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
subtractYear : function (e) {
- _yuitest_coverfunc("build/calendar/calendar.js", "subtractYear", 386);
-_yuitest_coverline("build/calendar/calendar.js", 387);
+ _yuitest_coverfunc("build/calendar/calendar.js", "subtractYear", 391);
+_yuitest_coverline("build/calendar/calendar.js", 392);
this.set("date", ydate.addYears(this.get("date"), -1));
- _yuitest_coverline("build/calendar/calendar.js", 388);
+ _yuitest_coverline("build/calendar/calendar.js", 393);
if (e) {
- _yuitest_coverline("build/calendar/calendar.js", 389);
+ _yuitest_coverline("build/calendar/calendar.js", 394);
e.halt();
}
+ _yuitest_coverline("build/calendar/calendar.js", 396);
+return this;
},
/**
* Adds one month to the current calendar view.
* @method addMonth
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
addMonth : function (e) {
- _yuitest_coverfunc("build/calendar/calendar.js", "addMonth", 397);
-_yuitest_coverline("build/calendar/calendar.js", 398);
+ _yuitest_coverfunc("build/calendar/calendar.js", "addMonth", 405);
+_yuitest_coverline("build/calendar/calendar.js", 406);
this.set("date", ydate.addMonths(this.get("date"), 1));
- _yuitest_coverline("build/calendar/calendar.js", 399);
+ _yuitest_coverline("build/calendar/calendar.js", 407);
if (e) {
- _yuitest_coverline("build/calendar/calendar.js", 400);
+ _yuitest_coverline("build/calendar/calendar.js", 408);
e.halt();
}
+ _yuitest_coverline("build/calendar/calendar.js", 410);
+return this;
},
/**
* Adds one year to the current calendar view.
* @method addYear
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
addYear : function (e) {
- _yuitest_coverfunc("build/calendar/calendar.js", "addYear", 408);
-_yuitest_coverline("build/calendar/calendar.js", 409);
+ _yuitest_coverfunc("build/calendar/calendar.js", "addYear", 419);
+_yuitest_coverline("build/calendar/calendar.js", 420);
this.set("date", ydate.addYears(this.get("date"), 1));
- _yuitest_coverline("build/calendar/calendar.js", 410);
+ _yuitest_coverline("build/calendar/calendar.js", 421);
if (e) {
- _yuitest_coverline("build/calendar/calendar.js", 411);
+ _yuitest_coverline("build/calendar/calendar.js", 422);
e.halt();
}
+ _yuitest_coverline("build/calendar/calendar.js", 424);
+return this;
}
},
@@ -651,32 +667,32 @@ e.halt();
lazyAdd: false,
setter: function (val) {
- _yuitest_coverfunc("build/calendar/calendar.js", "setter", 471);
-_yuitest_coverline("build/calendar/calendar.js", 473);
+ _yuitest_coverfunc("build/calendar/calendar.js", "setter", 483);
+_yuitest_coverline("build/calendar/calendar.js", 485);
var newDate = this._normalizeDate(val),
newTopDate = ydate.addMonths(newDate, this._paneNumber - 1);
- _yuitest_coverline("build/calendar/calendar.js", 475);
+ _yuitest_coverline("build/calendar/calendar.js", 487);
var minDate = this.get("minimumDate");
- _yuitest_coverline("build/calendar/calendar.js", 476);
+ _yuitest_coverline("build/calendar/calendar.js", 488);
var maxDate = this.get("maximumDate");
- _yuitest_coverline("build/calendar/calendar.js", 477);
+ _yuitest_coverline("build/calendar/calendar.js", 489);
if ((!minDate || ydate.isGreaterOrEqual(newDate, minDate)) &&
(!maxDate || ydate.isGreaterOrEqual(maxDate, newTopDate))) {
- _yuitest_coverline("build/calendar/calendar.js", 479);
+ _yuitest_coverline("build/calendar/calendar.js", 491);
return newDate;
}
- else {_yuitest_coverline("build/calendar/calendar.js", 482);
+ else {_yuitest_coverline("build/calendar/calendar.js", 494);
if (minDate && ydate.isGreater(minDate, newDate)) {
- _yuitest_coverline("build/calendar/calendar.js", 483);
+ _yuitest_coverline("build/calendar/calendar.js", 495);
return minDate;
}
- else {_yuitest_coverline("build/calendar/calendar.js", 486);
+ else {_yuitest_coverline("build/calendar/calendar.js", 498);
if (maxDate && ydate.isGreater(newTopDate, maxDate)) {
- _yuitest_coverline("build/calendar/calendar.js", 487);
+ _yuitest_coverline("build/calendar/calendar.js", 499);
var actualMaxDate = ydate.addMonths(maxDate, -1*(this._paneNumber - 1));
- _yuitest_coverline("build/calendar/calendar.js", 488);
+ _yuitest_coverline("build/calendar/calendar.js", 500);
return actualMaxDate;
}}}
}
@@ -694,22 +710,22 @@ return actualMaxDate;
minimumDate: {
value: null,
setter: function (val) {
- _yuitest_coverfunc("build/calendar/calendar.js", "setter", 504);
-_yuitest_coverline("build/calendar/calendar.js", 505);
+ _yuitest_coverfunc("build/calendar/calendar.js", "setter", 516);
+_yuitest_coverline("build/calendar/calendar.js", 517);
if (val) {
- _yuitest_coverline("build/calendar/calendar.js", 506);
+ _yuitest_coverline("build/calendar/calendar.js", 518);
var curDate = this.get('date'),
newMinDate = this._normalizeDate(val);
- _yuitest_coverline("build/calendar/calendar.js", 508);
+ _yuitest_coverline("build/calendar/calendar.js", 520);
if (curDate && !ydate.isGreaterOrEqual(curDate, newMinDate)) {
- _yuitest_coverline("build/calendar/calendar.js", 509);
+ _yuitest_coverline("build/calendar/calendar.js", 521);
this.set('date', newMinDate);
}
- _yuitest_coverline("build/calendar/calendar.js", 511);
+ _yuitest_coverline("build/calendar/calendar.js", 523);
return newMinDate;
}
else {
- _yuitest_coverline("build/calendar/calendar.js", 514);
+ _yuitest_coverline("build/calendar/calendar.js", 526);
return this._normalizeDate(val);
}
}
@@ -727,22 +743,22 @@ return this._normalizeDate(val);
maximumDate: {
value: null,
setter: function (val) {
- _yuitest_coverfunc("build/calendar/calendar.js", "setter", 530);
-_yuitest_coverline("build/calendar/calendar.js", 531);
+ _yuitest_coverfunc("build/calendar/calendar.js", "setter", 542);
+_yuitest_coverline("build/calendar/calendar.js", 543);
if (val) {
- _yuitest_coverline("build/calendar/calendar.js", 532);
+ _yuitest_coverline("build/calendar/calendar.js", 544);
var curDate = this.get('date'),
newMaxDate = this._normalizeDate(val);
- _yuitest_coverline("build/calendar/calendar.js", 534);
+ _yuitest_coverline("build/calendar/calendar.js", 546);
if (curDate && !ydate.isGreaterOrEqual(val, ydate.addMonths(curDate, this._paneNumber - 1))) {
- _yuitest_coverline("build/calendar/calendar.js", 535);
+ _yuitest_coverline("build/calendar/calendar.js", 547);
this.set('date', ydate.addMonths(newMaxDate, -1*(this._paneNumber -1)));
}
- _yuitest_coverline("build/calendar/calendar.js", 537);
+ _yuitest_coverline("build/calendar/calendar.js", 549);
return newMaxDate;
}
else {
- _yuitest_coverline("build/calendar/calendar.js", 540);
+ _yuitest_coverline("build/calendar/calendar.js", 552);
return val;
}
}
View
12 build/calendar/calendar-debug.js
@@ -371,45 +371,57 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
/**
* Subtracts one month from the current calendar view.
* @method subtractMonth
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
subtractMonth : function (e) {
this.set("date", ydate.addMonths(this.get("date"), -1));
if (e) {
e.halt();
}
+ return this;
},
/**
* Subtracts one year from the current calendar view.
* @method subtractYear
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
subtractYear : function (e) {
this.set("date", ydate.addYears(this.get("date"), -1));
if (e) {
e.halt();
}
+ return this;
},
/**
* Adds one month to the current calendar view.
* @method addMonth
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
addMonth : function (e) {
this.set("date", ydate.addMonths(this.get("date"), 1));
if (e) {
e.halt();
}
+ return this;
},
/**
* Adds one year to the current calendar view.
* @method addYear
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
addYear : function (e) {
this.set("date", ydate.addYears(this.get("date"), 1));
if (e) {
e.halt();
}
+ return this;
}
},
View
2  build/calendar/calendar-min.js
@@ -1 +1 @@
-YUI.add("calendar",function(e,t){function E(e){E.superclass.constructor.apply(this,arguments)}var n=e.ClassNameManager.getClassName,r="calendar",i=40,s=38,o=37,u=39,a=13,f=32,l=n(r,"header"),c=n(r,"day-selected"),h=n(r,"day-highlighted"),p=n(r,"day"),d=n(r,"prevmonth-day"),v=n(r,"nextmonth-day"),m=n(r,"grid"),g=e.DataType.Date,y=e.delegate,b=n(r,"pane"),w=e.UA.os;e.Calendar=e.extend(E,e.CalendarBase,{_keyEvents:[],_highlightedDateNode:null,_lastSelectedDate:null,initializer:function(){this.plug(e.Plugin.CalendarNavigator),this._keyEvents=[],this._highlightedDateNode=null,this._lastSelectedDate=null},_bindCalendarEvents:function(){var e=this.get("contentBox"),t=e.one("."+b);t.on("selectstart",this._preventSelectionStart),t.delegate("click",this._clickCalendar,"."+p+", ."+d+", ."+v,this),t.delegate("keydown",this._keydownCalendar,"."+m,this),t.delegate("focus",this._focusCalendarGrid,"."+m,this),t.delegate("focus",this._focusCalendarCell,"."+p,this),t.delegate("blur",this._blurCalendarGrid,"."+m+",."+p,this)},_preventSelectionStart:function(e){e.preventDefault()},_highlightDateNode:function(e){this._unhighlightCurrentDateNode();var t=this._dateToNode(e);t.focus(),t.addClass(h)},_unhighlightCurrentDateNode:function(){var e=this.get("contentBox").all("."+h);e&&e.removeClass(h)},_getGridNumber:function(e){var t=e.get("id").split("_").reverse();return parseInt(t[0],10)},_blurCalendarGrid:function(e){this._unhighlightCurrentDateNode()},_focusCalendarCell:function(e){this._highlightedDateNode=e.target,e.stopPropagation()},_focusCalendarGrid:function(e){this._unhighlightCurrentDateNode(),this._highlightedDateNode=null},_keydownCalendar:function(e){var t=this._getGridNumber(e.target),n=this._highlightedDateNode?this._nodeToDate(this._highlightedDateNode):null,r=e.keyCode,l=0,h="";switch(r){case i:l=7,h="s";break;case s:l=-7,h="n";break;case o:l=-1,h="w";break;case u:l=1,h="e";break;case f:case a:e.preventDefault();if(this._highlightedDateNode){var p=this.get("selectionMode");if(p==="single"&&!this._highlightedDateNode.hasClass(c))this._clearSelection(!0),this._addDateToSelection(n);else if(p==="multiple"||p==="multiple-sticky")this._highlightedDateNode.hasClass(c)?this._removeDateFromSelection(n):this._addDateToSelection(n)}}if(r==i||r==s||r==o||r==u){n||(n=g.addMonths(this.get("date"),t),l=0),e.preventDefault();var d=g.addDays(n,l),v=this.get("date"),m=g.addMonths(this.get("date"),this._paneNumber-1),y=new Date(m);m.setDate(g.daysInMonth(m)),g.isInRange(d,v,m)?this._highlightDateNode(d):g.isGreater(v,d)?g.isGreaterOrEqual(this.get("minimumDate"),v)||(this.set("date",g.addMonths(v,-1)),this._highlightDateNode(d)):g.isGreater(d,m)&&(g.isGreaterOrEqual(y,this.get("maximumDate"))||(this.set("date",g.addMonths(v,1)),this._highlightDateNode(d)))}},_clickCalendar:function(e){var t=e.currentTarget,n=t.hasClass(p)&&!t.hasClass(d)&&!t.hasClass(v),r=t.hasClass(c);switch(this.get("selectionMode")){case"single":n&&(r||(this._clearSelection(!0),this._addDateToSelection(this._nodeToDate(t))));break;case"multiple-sticky":n&&(r?this._removeDateFromSelection(this._nodeToDate(t)):this._addDateToSelection(this._nodeToDate(t)));break;case"multiple":if(n)if(!e.metaKey&&!e.ctrlKey&&!e.shiftKey)this._clearSelection(!0),this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate);else if((w=="macintosh"&&e.metaKey||w!="macintosh"&&e.ctrlKey)&&!e.shiftKey)r?(this._removeDateFromSelection(this._nodeToDate(t)),this._lastSelectedDate=null):(this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate));else if((w=="macintosh"&&e.metaKey||w!="macintosh"&&e.ctrlKey)&&e.shiftKey)if(this._lastSelectedDate){var i=this._nodeToDate(t);this._addDateRangeToSelection(i,this._lastSelectedDate),this._lastSelectedDate=i}else this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate);else if(e.shiftKey)if(this._lastSelectedDate){var i=this._nodeToDate(t);this._clearSelection(!0),this._addDateRangeToSelection(i,this._lastSelectedDate),this._lastSelectedDate=i}else this._clearSelection(!0),this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate)}n?this.fire("dateClick",{cell:t,date:this._nodeToDate(t)}):t.hasClass(d)?this.fire("prevMonthClick"):t.hasClass(v)&&this.fire("nextMonthClick")},subtractMonth:function(e){this.set("date",g.addMonths(this.get("date"),-1)),e&&e.halt()},subtractYear:function(e){this.set("date",g.addYears(this.get("date"),-1)),e&&e.halt()},addMonth:function(e){this.set("date",g.addMonths(this.get("date"),1)),e&&e.halt()},addYear:function(e){this.set("date",g.addYears(this.get("date"),1)),e&&e.halt()}},{NAME:"calendar",ATTRS:{selectionMode:{value:"single"},date:{value:new Date,lazyAdd:!1,setter:function(e){var t=this._normalizeDate(e),n=g.addMonths(t,this._paneNumber-1),r=this.get("minimumDate"),i=this.get("maximumDate");if((!r||g.isGreaterOrEqual(t,r))&&(!i||g.isGreaterOrEqual(i,n)))return t;if(r&&g.isGreater(r,t))return r;if(i&&g.isGreater(n,i)){var s=g.addMonths(i,-1*(this._paneNumber-1));return s}}},minimumDate:{value:null,setter:function(e){if(e){var t=this.get("date"),n=this._normalizeDate(e);return t&&!g.isGreaterOrEqual(t,n)&&this.set("date",n),n}return this._normalizeDate(e)}},maximumDate:{value:null,setter:function(e){if(e){var t=this.get("date"),n=this._normalizeDate(e);return t&&!g.isGreaterOrEqual(e,g.addMonths(t,this._paneNumber-1))&&this.set("date",g.addMonths(n,-1*(this._paneNumber-1))),n}return e}}}})},"@VERSION@",{requires:["calendar-base","calendarnavigator"],lang:["de","en","es","es-AR","fr","it","ja","nb-NO","nl","pt-BR","ru","zh-HANT-TW"],skinnable:!0});
+YUI.add("calendar",function(e,t){function E(e){E.superclass.constructor.apply(this,arguments)}var n=e.ClassNameManager.getClassName,r="calendar",i=40,s=38,o=37,u=39,a=13,f=32,l=n(r,"header"),c=n(r,"day-selected"),h=n(r,"day-highlighted"),p=n(r,"day"),d=n(r,"prevmonth-day"),v=n(r,"nextmonth-day"),m=n(r,"grid"),g=e.DataType.Date,y=e.delegate,b=n(r,"pane"),w=e.UA.os;e.Calendar=e.extend(E,e.CalendarBase,{_keyEvents:[],_highlightedDateNode:null,_lastSelectedDate:null,initializer:function(){this.plug(e.Plugin.CalendarNavigator),this._keyEvents=[],this._highlightedDateNode=null,this._lastSelectedDate=null},_bindCalendarEvents:function(){var e=this.get("contentBox"),t=e.one("."+b);t.on("selectstart",this._preventSelectionStart),t.delegate("click",this._clickCalendar,"."+p+", ."+d+", ."+v,this),t.delegate("keydown",this._keydownCalendar,"."+m,this),t.delegate("focus",this._focusCalendarGrid,"."+m,this),t.delegate("focus",this._focusCalendarCell,"."+p,this),t.delegate("blur",this._blurCalendarGrid,"."+m+",."+p,this)},_preventSelectionStart:function(e){e.preventDefault()},_highlightDateNode:function(e){this._unhighlightCurrentDateNode();var t=this._dateToNode(e);t.focus(),t.addClass(h)},_unhighlightCurrentDateNode:function(){var e=this.get("contentBox").all("."+h);e&&e.removeClass(h)},_getGridNumber:function(e){var t=e.get("id").split("_").reverse();return parseInt(t[0],10)},_blurCalendarGrid:function(e){this._unhighlightCurrentDateNode()},_focusCalendarCell:function(e){this._highlightedDateNode=e.target,e.stopPropagation()},_focusCalendarGrid:function(e){this._unhighlightCurrentDateNode(),this._highlightedDateNode=null},_keydownCalendar:function(e){var t=this._getGridNumber(e.target),n=this._highlightedDateNode?this._nodeToDate(this._highlightedDateNode):null,r=e.keyCode,l=0,h="";switch(r){case i:l=7,h="s";break;case s:l=-7,h="n";break;case o:l=-1,h="w";break;case u:l=1,h="e";break;case f:case a:e.preventDefault();if(this._highlightedDateNode){var p=this.get("selectionMode");if(p==="single"&&!this._highlightedDateNode.hasClass(c))this._clearSelection(!0),this._addDateToSelection(n);else if(p==="multiple"||p==="multiple-sticky")this._highlightedDateNode.hasClass(c)?this._removeDateFromSelection(n):this._addDateToSelection(n)}}if(r==i||r==s||r==o||r==u){n||(n=g.addMonths(this.get("date"),t),l=0),e.preventDefault();var d=g.addDays(n,l),v=this.get("date"),m=g.addMonths(this.get("date"),this._paneNumber-1),y=new Date(m);m.setDate(g.daysInMonth(m)),g.isInRange(d,v,m)?this._highlightDateNode(d):g.isGreater(v,d)?g.isGreaterOrEqual(this.get("minimumDate"),v)||(this.set("date",g.addMonths(v,-1)),this._highlightDateNode(d)):g.isGreater(d,m)&&(g.isGreaterOrEqual(y,this.get("maximumDate"))||(this.set("date",g.addMonths(v,1)),this._highlightDateNode(d)))}},_clickCalendar:function(e){var t=e.currentTarget,n=t.hasClass(p)&&!t.hasClass(d)&&!t.hasClass(v),r=t.hasClass(c);switch(this.get("selectionMode")){case"single":n&&(r||(this._clearSelection(!0),this._addDateToSelection(this._nodeToDate(t))));break;case"multiple-sticky":n&&(r?this._removeDateFromSelection(this._nodeToDate(t)):this._addDateToSelection(this._nodeToDate(t)));break;case"multiple":if(n)if(!e.metaKey&&!e.ctrlKey&&!e.shiftKey)this._clearSelection(!0),this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate);else if((w=="macintosh"&&e.metaKey||w!="macintosh"&&e.ctrlKey)&&!e.shiftKey)r?(this._removeDateFromSelection(this._nodeToDate(t)),this._lastSelectedDate=null):(this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate));else if((w=="macintosh"&&e.metaKey||w!="macintosh"&&e.ctrlKey)&&e.shiftKey)if(this._lastSelectedDate){var i=this._nodeToDate(t);this._addDateRangeToSelection(i,this._lastSelectedDate),this._lastSelectedDate=i}else this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate);else if(e.shiftKey)if(this._lastSelectedDate){var i=this._nodeToDate(t);this._clearSelection(!0),this._addDateRangeToSelection(i,this._lastSelectedDate),this._lastSelectedDate=i}else this._clearSelection(!0),this._lastSelectedDate=this._nodeToDate(t),this._addDateToSelection(this._lastSelectedDate)}n?this.fire("dateClick",{cell:t,date:this._nodeToDate(t)}):t.hasClass(d)?this.fire("prevMonthClick"):t.hasClass(v)&&this.fire("nextMonthClick")},subtractMonth:function(e){return this.set("date",g.addMonths(this.get("date"),-1)),e&&e.halt(),this},subtractYear:function(e){return this.set("date",g.addYears(this.get("date"),-1)),e&&e.halt(),this},addMonth:function(e){return this.set("date",g.addMonths(this.get("date"),1)),e&&e.halt(),this},addYear:function(e){return this.set("date",g.addYears(this.get("date"),1)),e&&e.halt(),this}},{NAME:"calendar",ATTRS:{selectionMode:{value:"single"},date:{value:new Date,lazyAdd:!1,setter:function(e){var t=this._normalizeDate(e),n=g.addMonths(t,this._paneNumber-1),r=this.get("minimumDate"),i=this.get("maximumDate");if((!r||g.isGreaterOrEqual(t,r))&&(!i||g.isGreaterOrEqual(i,n)))return t;if(r&&g.isGreater(r,t))return r;if(i&&g.isGreater(n,i)){var s=g.addMonths(i,-1*(this._paneNumber-1));return s}}},minimumDate:{value:null,setter:function(e){if(e){var t=this.get("date"),n=this._normalizeDate(e);return t&&!g.isGreaterOrEqual(t,n)&&this.set("date",n),n}return this._normalizeDate(e)}},maximumDate:{value:null,setter:function(e){if(e){var t=this.get("date"),n=this._normalizeDate(e);return t&&!g.isGreaterOrEqual(e,g.addMonths(t,this._paneNumber-1))&&this.set("date",g.addMonths(n,-1*(this._paneNumber-1))),n}return e}}}})},"@VERSION@",{requires:["calendar-base","calendarnavigator"],lang:["de","en","es","es-AR","fr","it","ja","nb-NO","nl","pt-BR","ru","zh-HANT-TW"],skinnable:!0});
View
12 build/calendar/calendar.js
@@ -371,45 +371,57 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
/**
* Subtracts one month from the current calendar view.
* @method subtractMonth
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
subtractMonth : function (e) {
this.set("date", ydate.addMonths(this.get("date"), -1));
if (e) {
e.halt();
}
+ return this;
},
/**
* Subtracts one year from the current calendar view.
* @method subtractYear
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
subtractYear : function (e) {
this.set("date", ydate.addYears(this.get("date"), -1));
if (e) {
e.halt();
}
+ return this;
},
/**
* Adds one month to the current calendar view.
* @method addMonth
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
addMonth : function (e) {
this.set("date", ydate.addMonths(this.get("date"), 1));
if (e) {
e.halt();
}
+ return this;
},
/**
* Adds one year to the current calendar view.
* @method addYear
+ * @return {Calendar} A reference to this object
+ * @chainable
*/
addYear : function (e) {
this.set("date", ydate.addYears(this.get("date"), 1));
if (e) {
e.halt();
}
+ return this;
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.