From 1d17e1a5ae5cbf05f7929ba3a2d5aa368bd2e814 Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Fri, 13 Jun 2014 14:29:31 -0700 Subject: [PATCH] when weekMode is variable/liquid, dont display weeks with no visible days --- src/basic/MonthView.js | 12 ++++++++---- tests/automated/weekMode.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/basic/MonthView.js b/src/basic/MonthView.js index 8502a67..fb330fa 100644 --- a/src/basic/MonthView.js +++ b/src/basic/MonthView.js @@ -24,11 +24,15 @@ function MonthView(element, calendar) { t.intervalStart = date.clone().stripTime().startOf('month'); t.intervalEnd = t.intervalStart.clone().add('months', 1); - t.start = t.intervalStart.clone().startOf('week'); - t.start = t.skipHiddenDays(t.start); + t.start = t.intervalStart.clone(); + t.start = t.skipHiddenDays(t.start); // move past the first week if no visible days + t.start.startOf('week'); + t.start = t.skipHiddenDays(t.start); // move past the first invisible days of the week - t.end = t.intervalEnd.clone().add('days', (7 - t.intervalEnd.weekday()) % 7); - t.end = t.skipHiddenDays(t.end, -1, true); + t.end = t.intervalEnd.clone(); + t.end = t.skipHiddenDays(t.end, -1, true); // move in from the last week if no visible days + t.end.add('days', (7 - t.end.weekday()) % 7); // move to end of week if not already + t.end = t.skipHiddenDays(t.end, -1, true); // move in from the last invisible days of the week var rowCnt = Math.ceil( // need to ceil in case there are hidden days t.end.diff(t.start, 'weeks', true) // returnfloat=true diff --git a/tests/automated/weekMode.js b/tests/automated/weekMode.js index 0dfbcca..3d891f3 100644 --- a/tests/automated/weekMode.js +++ b/tests/automated/weekMode.js @@ -113,6 +113,15 @@ describe('weekMode', function() { }); }); + it('should not display an empty week when no visible days and weekMode is set to liquid', function() { + $('#cal').fullCalendar({ + defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday! + weekMode: 'liquid', + weekends: false + }); + expect($('.fc-week').length).toBe(4); + }); + describe('when weekMode is set to variable', function() { beforeEach(function() { $('#cal').fullCalendar({ @@ -145,4 +154,13 @@ describe('weekMode', function() { expect(fiveWeekHeight).toEqual(sixWeekHeight); }); }); + + it('should not display an empty week when no visible days and weekMode is set to variable', function() { + $('#cal').fullCalendar({ + defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday! + weekMode: 'variable', + weekends: false + }); + expect($('.fc-week').length).toBe(4); + }); }); \ No newline at end of file