Skip to content

Commit f9fcedb

Browse files
Merge branch 'calendar-chainable-methods' of https://github.com/asystance/yui3 into calendar-chainable
2 parents 8d2dfd7 + c8040b7 commit f9fcedb

File tree

3 files changed

+103
-94
lines changed

3 files changed

+103
-94
lines changed

src/calendar/js/calendar-base.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
365365
* Selects a given date or array of dates.
366366
* @method selectDates
367367
* @param {Date|Array} dates A `Date` or `Array` of `Date`s.
368+
* @return {CalendarBase} A reference to this object
369+
* @chainable
368370
*/
369371
selectDates : function (dates) {
370372
if (ydate.isValidDate(dates)) {
@@ -373,6 +375,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
373375
else if (L.isArray(dates)) {
374376
this._addDatesToSelection(dates);
375377
}
378+
return this;
376379
},
377380

378381
/**
@@ -381,6 +384,8 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
381384
* @method deselectDates
382385
* @param {Date|Array} [dates] A `Date` or `Array` of `Date`s, or no
383386
* argument if all dates should be deselected.
387+
* @return {CalendarBase} A reference to this object
388+
* @chainable
384389
*/
385390
deselectDates : function (dates) {
386391
if (!dates) {
@@ -392,6 +397,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
392397
else if (L.isArray(dates)) {
393398
this._removeDatesFromSelection(dates);
394399
}
400+
return this;
395401
},
396402

397403
/**
@@ -618,7 +624,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
618624
* @method _renderSelectedDates
619625
* @private
620626
*/
621-
_renderSelectedDates : function () {
627+
_renderSelectedDates : function () {
622628
this.get("contentBox").all("." + CAL_DAY_SELECTED).removeClass(CAL_DAY_SELECTED).setAttribute("aria-selected", false);
623629

624630
for (var paneNum = 0; paneNum < this._paneNumber; paneNum++) {
@@ -640,7 +646,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
640646
* @return {Node} The node wrapping the DOM element of the cell the date
641647
* corresponds to.
642648
*/
643-
_dateToNode : function (oDate) {
649+
_dateToNode : function (oDate) {
644650
var day = oDate.getDate(),
645651
col = 0,
646652
daymod = day%7,
@@ -713,7 +719,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
713719
* @protected
714720
* @return {Date} The date corresponding to the DOM element that the given node wraps.
715721
*/
716-
_nodeToDate : function (oNode) {
722+
_nodeToDate : function (oNode) {
717723

718724
var idParts = oNode.get("id").split("_").reverse(),
719725
paneNum = parseInt(idParts[2], 10),
@@ -731,7 +737,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
731737
* @method _bindCalendarEvents
732738
* @protected
733739
*/
734-
_bindCalendarEvents : function () {
740+
_bindCalendarEvents : function () {
735741

736742
},
737743

@@ -946,7 +952,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
946952
* @method _afterHeaderRendererChange
947953
* @private
948954
*/
949-
_afterHeaderRendererChange : function () {
955+
_afterHeaderRendererChange : function () {
950956
var headerCell = this.get("contentBox").one("." + CAL_HD_LABEL);
951957
headerCell.setContent(this._updateCalendarHeader(this.get('date')));
952958
},
@@ -968,7 +974,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
968974
* @method _afterDateChange
969975
* @private
970976
*/
971-
_afterDateChange : function () {
977+
_afterDateChange : function () {
972978

973979
var contentBox = this.get('contentBox'),
974980
headerCell = contentBox.one("." + CAL_HD).one("." + CAL_HD_LABEL),
@@ -1006,7 +1012,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
10061012
* element ids in the given pane.
10071013
* @private
10081014
*/
1009-
_initCalendarPane : function (baseDate, pane_id) {
1015+
_initCalendarPane : function (baseDate, pane_id) {
10101016
// Initialize final output HTML string
10111017
var calString = '',
10121018
// Get a list of short weekdays from the internationalization package, or else use default English ones.
@@ -1113,7 +1119,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
11131119
* @param {Node} pane The node corresponding to the calendar pane to be rerenders.
11141120
* @private
11151121
*/
1116-
_rerenderCalendarPane : function (newDate, pane) {
1122+
_rerenderCalendarPane : function (newDate, pane) {
11171123

11181124
// Get the first day of the week from the internationalization package, or else use Sunday as default.
11191125
var firstday = this.get('strings.first_weekday') || 0,
@@ -1250,7 +1256,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
12501256
* @param {Date} baseDate The date with which to initialize the calendar.
12511257
* @private
12521258
*/
1253-
_initCalendarHTML : function (baseDate) {
1259+
_initCalendarHTML : function (baseDate) {
12541260
// Instantiate the partials holder
12551261
var partials = {},
12561262
// Counter for iterative template replacement.

src/calendar/js/calendar.js

+12
Original file line numberDiff line numberDiff line change
@@ -369,45 +369,57 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
369369
/**
370370
* Subtracts one month from the current calendar view.
371371
* @method subtractMonth
372+
* @return {Calendar} A reference to this object
373+
* @chainable
372374
*/
373375
subtractMonth : function (e) {
374376
this.set("date", ydate.addMonths(this.get("date"), -1));
375377
if (e) {
376378
e.halt();
377379
}
380+
return this;
378381
},
379382

380383
/**
381384
* Subtracts one year from the current calendar view.
382385
* @method subtractYear
386+
* @return {Calendar} A reference to this object
387+
* @chainable
383388
*/
384389
subtractYear : function (e) {
385390
this.set("date", ydate.addYears(this.get("date"), -1));
386391
if (e) {
387392
e.halt();
388393
}
394+
return this;
389395
},
390396

391397
/**
392398
* Adds one month to the current calendar view.
393399
* @method addMonth
400+
* @return {Calendar} A reference to this object
401+
* @chainable
394402
*/
395403
addMonth : function (e) {
396404
this.set("date", ydate.addMonths(this.get("date"), 1));
397405
if (e) {
398406
e.halt();
399407
}
408+
return this;
400409
},
401410

402411
/**
403412
* Adds one year to the current calendar view.
404413
* @method addYear
414+
* @return {Calendar} A reference to this object
415+
* @chainable
405416
*/
406417
addYear : function (e) {
407418
this.set("date", ydate.addYears(this.get("date"), 1));
408419
if (e) {
409420
e.halt();
410421
}
422+
return this;
411423
}
412424
},
413425

0 commit comments

Comments
 (0)