Permalink
Browse files

Latest changes to calendar and calendar tests

  • Loading branch information...
allenrabinovich committed May 23, 2012
1 parent 6b691fb commit e814c617a097896c9bcd3a5552549ee060eecdb7
@@ -85,7 +85,7 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
var contentBox = this.get('contentBox'),
pane = contentBox.one("." + CAL_PANE);
pane.on("selectstart", function (ev) { ev.preventDefault();});
- pane.delegate("click", this._clickCalendar, "." + CAL_DAY, this);
+ 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);
@@ -283,47 +283,49 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
}
break;
case("multiple"):
- 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 (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._clearSelection(true);
this._addDateRangeToSelection(selectedDate, this._lastSelectedDate);
this._lastSelectedDate = selectedDate;
}
else {
- this._clearSelection(true);
this._lastSelectedDate = this._nodeToDate(clickedCell);
- this._addDateToSelection(this._lastSelectedDate);
+ this._addDateToSelection(this._lastSelectedDate);
}
- }
- break;
+
+ }
+ 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) {
@@ -362,7 +364,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
*/
subtractMonth : function (e) {
this.set("date", ydate.addMonths(this.get("date"), -1));
- e.halt();
+ if (e) {
+ e.halt();
+ }
},
/**
@@ -371,7 +375,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
*/
subtractYear : function (e) {
this.set("date", ydate.addYears(this.get("date"), -1));
- e.halt();
+ if (e) {
+ e.halt();
+ }
},
/**
@@ -380,7 +386,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
*/
addMonth : function (e) {
this.set("date", ydate.addMonths(this.get("date"), 1));
- e.halt();
+ if (e) {
+ e.halt();
+ }
},
/**
@@ -389,7 +397,9 @@ Y.Calendar = Y.extend(Calendar, Y.CalendarBase, {
*/
addYear : function (e) {
this.set("date", ydate.addYears(this.get("date"), 1));
- e.halt();
+ if (e) {
+ e.halt();
+ }
}
},

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit e814c61

Please sign in to comment.