Permalink
Browse files

Merge branch 'calendar-chainable-methods' of https://github.com/asyst…

…ance/yui3 into calendar-chainable
  • Loading branch information...
2 parents 8d2dfd7 + c8040b7 commit f9fcedb55c44f72133026d41bc5daf4debdf40ac @allenrabinovich committed Nov 2, 2012
Showing with 103 additions and 94 deletions.
  1. +15 −9 src/calendar/js/calendar-base.js
  2. +12 −0 src/calendar/js/calendar.js
  3. +76 −85 src/calendar/tests/unit/assets/calendar-tests.js
@@ -365,6 +365,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)) {
@@ -373,6 +375,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
else if (L.isArray(dates)) {
this._addDatesToSelection(dates);
}
+ return this;
},
/**
@@ -381,6 +384,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) {
@@ -392,6 +397,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
else if (L.isArray(dates)) {
this._removeDatesFromSelection(dates);
}
+ return this;
},
/**
@@ -618,7 +624,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++) {
@@ -640,7 +646,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,
@@ -713,7 +719,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),
@@ -731,7 +737,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
* @method _bindCalendarEvents
* @protected
*/
- _bindCalendarEvents : function () {
+ _bindCalendarEvents : function () {
},
@@ -946,7 +952,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')));
},
@@ -968,7 +974,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),
@@ -1006,7 +1012,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.
@@ -1113,7 +1119,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,
@@ -1250,7 +1256,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.
@@ -369,45 +369,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;
}
},
Oops, something went wrong.

0 comments on commit f9fcedb

Please sign in to comment.