Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround: Oct 19 is duplicated if Min OR MaxDate #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions Source/Picker.Date.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,28 +495,40 @@ var renderers = {
}).inject(titles, where);
}

days.each(function(_date, i){
var date = new Date(_date);

if (i % 7 == 0){
weekcontainer = new Element('tr.week.week' + (Math.floor(i / 7))).set('role', 'row').inject(body);
if (weeknumbers) new Element('th.day.weeknumber', {text: date.get('week'), scope: 'row', role: 'rowheader'}).inject(weekcontainer);
}

dateString = date.toDateString();
classes = '.day.day' + date.get('day');
if (dateString == todayString) classes += '.today';
if (date.get('month') != month) classes += '.otherMonth';
element = new Element('td' + classes, {text: date.getDate(), role: 'gridcell'}).inject(weekcontainer, where);

if (dateString == currentString) element.addClass('selected').set('aria-selected', 'true');
else element.set('aria-selected', 'false');

dateElements.push({element: element, time: _date});

if (isUnavailable('date', date, options)) element.addClass('unavailable');
else element.addEvent('click', fn.pass(date.clone()));
});
var lastDay = 0;
days.each(function(_date, i){
var date = new Date(_date);
if(lastDay == date.getDate()){
/**
* Do nothing here
* Workaround: October 19 is duplicated if MinDate OR MaxDate is provide. See:
* @link: https://github.com/arian/mootools-datepicker/issues/137
* @todo: implement a fix for this issue
*/

}else{
if (i % 7 == 0 && date.get('day') ==0){ // October 19 (or 26 after fix) is not breaking correctly into a new line
weekcontainer = new Element('tr.week.week' + (Math.floor(i / 7))).set('role', 'row').inject(body);
if (weeknumbers) new Element('th.day.weeknumber', {text: date.get('week'), scope: 'row', role: 'rowheader'}).inject(weekcontainer);
lineCounter=0;
}

dateString = date.toDateString();
classes = '.day.day' + date.get('day');
if (dateString == todayString) classes += '.today';
if (date.get('month') != month) classes += '.otherMonth';
element = new Element('td' + classes, {text: date.getDate(), role: 'gridcell'}).inject(weekcontainer, where);

if (dateString == currentString) element.addClass('selected').set('aria-selected', 'true');
else element.set('aria-selected', 'false');

dateElements.push({element: element, time: _date});

if (isUnavailable('date', date, options)) element.addClass('unavailable');
else element.addEvent('click', fn.pass(date.clone()));
}
lastDay = date.getDate();
});

return container;
},
Expand Down