Skip to content

Commit

Permalink
LPD-34947 Consider month change cases
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-franca authored and dsanz committed Sep 25, 2024
1 parent 454eea9 commit fd79f2a
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions src/calendar/js/calendar-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
this._paneProperties[pane_id].daysInPrevMonth = daysInPrevMonth;

for (cell = 5; cell >= 0; cell--) {
pane.one("#" + pane_id + "_" + cell + "_" + (cell-5)).set('text', daysInPrevMonth--);
pane.one("#" + pane_id + "_" + cell + "_" + (cell-5)).one('button').set('text', daysInPrevMonth--);
}
}
},
Expand All @@ -868,7 +868,7 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
this._paneProperties[pane_id].daysInPrevMonth = 0;

for (cell = 5; cell >= 0; cell--) {
pane.one("#" + pane_id + "_" + cell + "_" + (cell-5)).setContent(" ");
pane.one("#" + pane_id + "_" + cell + "_" + (cell-5)).one('button').setContent(" ");
}
},

Expand Down Expand Up @@ -905,7 +905,10 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
startingCell;

for (cell = daysInMonth - 22; cell < cutoffCol + 7; cell++) {
pane.one("#" + pane_id + "_" + cell + "_" + (cell+23)).set("text", dayCounter++).addClass(CAL_NEXTMONTH_DAY);
var currCell = pane.one("#" + pane_id + "_" + cell + "_" + (cell+23));

currCell.addClass(CAL_NEXTMONTH_DAY);
currCell.one('button').set("text", dayCounter++);
}

startingCell = cutoffCol;
Expand All @@ -917,7 +920,10 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
}

for (cell = startingCell ; cell < cutoffCol + 7; cell++) {
pane.one("#" + pane_id + "_" + cell + "_" + (cell+30)).set("text", dayCounter++).addClass(CAL_NEXTMONTH_DAY);
var currCell = pane.one("#" + pane_id + "_" + cell + "_" + (cell+30));

currCell.addClass(CAL_NEXTMONTH_DAY);
currCell.one('button').set("text", dayCounter++)
}
},

Expand All @@ -937,7 +943,10 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
startingCell;

for (cell = daysInMonth - 22; cell <= 12; cell++) {
pane.one("#" + pane_id + "_" + cell + "_" + (cell+23)).setContent("&nbsp;").addClass(CAL_NEXTMONTH_DAY);
var currCell = pane.one("#" + pane_id + "_" + cell + "_" + (cell+23));

currCell.addClass(CAL_NEXTMONTH_DAY);
currCell.one('button').setContent("&nbsp;")
}

startingCell = 0;
Expand All @@ -949,7 +958,10 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
}

for (cell = startingCell ; cell <= 12; cell++) {
pane.one("#" + pane_id + "_" + cell + "_" + (cell+30)).setContent("&nbsp;").addClass(CAL_NEXTMONTH_DAY);
var currCell = pane.one("#" + pane_id + "_" + cell + "_" + (cell+30));

currCell.addClass(CAL_NEXTMONTH_DAY)
currCell.one('button').setContent("&nbsp;");
}
},

Expand Down Expand Up @@ -1203,51 +1215,56 @@ Y.CalendarBase = Y.extend( CalendarBase, Y.Widget, {
switch(column) {
case 0:
curCell = pane.one("#" + paneId + "_0_30");
curCellButton = curCell.one('button');
if (daysInMonth >= 30) {
curCell.set("text", "30");
curCellButton.set("text", "30");
curCell.removeClass(CAL_NEXTMONTH_DAY).addClass(CAL_DAY);
} else {
curCell.setContent("&nbsp;");
curCellButton.setContent("&nbsp;");
curCell.removeClass(CAL_DAY).addClass(CAL_NEXTMONTH_DAY);
}
break;
case 1:
curCell = pane.one("#" + paneId + "_1_31");
curCellButton = curCell.one('button');
if (daysInMonth >= 31) {
curCell.set("text", "31");
curCellButton.set("text", "31");
curCell.removeClass(CAL_NEXTMONTH_DAY).addClass(CAL_DAY);
} else {
curCell.setContent("&nbsp;");
curCellButton.setContent("&nbsp;");
curCell.removeClass(CAL_DAY).addClass(CAL_NEXTMONTH_DAY);
}
break;
case 6:
curCell = pane.one("#" + paneId + "_6_29");
curCellButton = curCell.one('button');
if (daysInMonth >= 29) {
curCell.set("text", "29");
curCellButton.set("text", "29");
curCell.removeClass(CAL_NEXTMONTH_DAY).addClass(CAL_DAY);
} else {
curCell.setContent("&nbsp;");
curCellButton.setContent("&nbsp;");
curCell.removeClass(CAL_DAY).addClass(CAL_NEXTMONTH_DAY);
}
break;
case 7:
curCell = pane.one("#" + paneId + "_7_30");
curCellButton = curCell.one('button');
if (daysInMonth >= 30) {
curCell.set("text", "30");
curCellButton.set("text", "30");
curCell.removeClass(CAL_NEXTMONTH_DAY).addClass(CAL_DAY);
} else {
curCell.setContent("&nbsp;");
curCellButton.setContent("&nbsp;");
curCell.removeClass(CAL_DAY).addClass(CAL_NEXTMONTH_DAY);
}
break;
case 8:
curCell = pane.one("#" + paneId + "_8_31");
curCellButton = curCell.one('button');
if (daysInMonth >= 31) {
curCell.set("text", "31");
curCellButton.set("text", "31");
curCell.removeClass(CAL_NEXTMONTH_DAY).addClass(CAL_DAY);
} else {
curCell.setContent("&nbsp;");
curCellButton.setContent("&nbsp;");
curCell.removeClass(CAL_DAY).addClass(CAL_NEXTMONTH_DAY);
}
break;
Expand Down

0 comments on commit fd79f2a

Please sign in to comment.