From 45e08d13acd4bb553663dcc5776844394f01c31d Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Sun, 3 Mar 2013 18:19:05 -0800 Subject: [PATCH] change the way BasicView cells are dynamically updated. change date format in data attr --- src/basic/BasicView.js | 75 +++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/basic/BasicView.js b/src/basic/BasicView.js index 38603af..5513c22 100644 --- a/src/basic/BasicView.js +++ b/src/basic/BasicView.js @@ -146,33 +146,58 @@ function BasicView(element, calendar, viewName) { var contentClass = tm + "-widget-content"; var month = t.start.getMonth(); var today = clearTime(new Date()); + var cellDate; // not to be confused with local function. TODO: better names + var cellClasses; var cell; - var date; html += "" + "" + ""; + if (showWeekNumbers) { html += "" + "" + ""; + for (i=0; i"; + html += ""; + if (showWeekNumbers) { html += ""; } + for (j=0; j" + // need fc- for setDayID + cellDate = _cellDate(i, j); // a little confusing. cellDate is local variable. _cellDate is private function + + cellClasses = [ + 'fc-day', + 'fc-' + dayIDs[cellDate.getDay()], + contentClass + ]; + if (cellDate.getMonth() != month) { + cellClasses.push('fc-other-month'); + } + if (+cellDate == +today) { + cellClasses.push('fc-today'); + cellClasses.push(tm + '-state-highlight'); + } + + html += "" + "
"; if (showNumbers) { - html += "
"; + html += "
" + cellDate.getDate() + "
"; } html += "
" + "
 
" + @@ -180,6 +205,7 @@ function BasicView(element, calendar, viewName) { "
" + ""; } + html += "
"; } html += "" + @@ -203,47 +229,29 @@ function BasicView(element, calendar, viewName) { markFirstLast(bodyRows); // marks first+last td's bodyRows.eq(0).addClass('fc-first'); bodyRows.filter(':last').addClass('fc-last'); - - dayBind(bodyCells); - - // update head cells if (showWeekNumbers) { head.find('.fc-week-number').text(weekNumberTitle); } headCells.each(function(i, _cell) { - cell = $(_cell); - date = indexDate(i); - cell.text(formatDate(date, colFormat)); - setDayID(cell, date); + var date = indexDate(i); + $(_cell).text(formatDate(date, colFormat)); }); - // update body cells (we should maybe move this into the HTML generation above) - if (showWeekNumbers) { - bodyRows.each(function(i, _row) { - var weekStartDate = _cellDate(i, 0); - $(_row).find('.fc-week-number > div').text( - formatDate(weekStartDate, weekNumberFormat) - ); + body.find('.fc-week-number > div').each(function(i, _cell) { + var weekStart = _cellDate(i, 0); + $(_cell).text(formatDate(weekStart, weekNumberFormat)); }); } bodyCells.each(function(i, _cell) { - cell = $(_cell); - date = indexDate(i); - if (date.getMonth() != month) { - cell.addClass('fc-other-month'); - } - if (+date == +today) { - cell.addClass(tm + '-state-highlight fc-today'); - } - cell.find('.fc-day-number').text(date.getDate()); - cell.attr('data-date', $.fullCalendar.formatDate(date, "yyyyMMdd")); - setDayID(cell, date); - trigger('dayRender', t, date, cell); + var date = indexDate(i); + trigger('dayRender', t, date, $(_cell)); }); + + dayBind(bodyCells); } @@ -304,8 +312,7 @@ function BasicView(element, calendar, viewName) { function dayClick(ev) { if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick - var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data - var date = indexDate(index); + var date = parseISO8601($(this).data('date')); trigger('dayClick', this, date, true, ev); } }
"; } + for (i=0; i"; // need fc- for setDayID + html += ""; } + html += "
" + "
" + "