Ver código fonte

Merge branch 'columnHead' of https://github.com/caseyjhol/fullcalendar

Adam Shaw 8 anos atrás
pai
commit
b65e56a159
4 arquivos alterados com 112 adições e 13 exclusões
  1. 8 5
      src/agenda/AgendaView.js
  2. 8 5
      src/basic/BasicView.js
  3. 1 0
      src/defaults.js
  4. 95 3
      tests/legacy/columnFormat.js

+ 8 - 5
src/agenda/AgendaView.js

@@ -101,11 +101,14 @@ var AgendaView = FC.AgendaView = View.extend({
 
 		return '' +
 			'<table class="' + theme.getClass('tableGrid') + '">' +
-				'<thead class="fc-head">' +
-					'<tr>' +
-						'<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
-					'</tr>' +
-				'</thead>' +
+				(this.opt('columnHead') ?
+					'<thead class="fc-head">' +
+						'<tr>' +
+							'<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
+						'</tr>' +
+					'</thead>' :
+					''
+					) +
 				'<tbody class="fc-body">' +
 					'<tr>' +
 						'<td class="' + theme.getClass('widgetContent') + '">' +

+ 8 - 5
src/basic/BasicView.js

@@ -108,11 +108,14 @@ var BasicView = FC.BasicView = View.extend({
 
 		return '' +
 			'<table class="' + theme.getClass('tableGrid') + '">' +
-				'<thead class="fc-head">' +
-					'<tr>' +
-						'<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
-					'</tr>' +
-				'</thead>' +
+				(this.opt('columnHead') ?
+					'<thead class="fc-head">' +
+						'<tr>' +
+							'<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
+						'</tr>' +
+					'</thead>' :
+					''
+					) +
 				'<tbody class="fc-body">' +
 					'<tr>' +
 						'<td class="' + theme.getClass('widgetContent') + '"></td>' +

+ 1 - 0
src/defaults.js

@@ -10,6 +10,7 @@ Calendar.defaults = {
 	nextDayThreshold: '09:00:00', // 9am
 
 	// display
+	columnHead: true,
 	defaultView: 'month',
 	aspectRatio: 1.35,
 	header: {

+ 95 - 3
tests/legacy/columnFormat.js

@@ -1,9 +1,101 @@
-describe('columnFormat', function() {
+beforeEach(function() {
+    affix('#cal');
+});
+
+describe('columnHead', function() {
+
+    describe('when columnHead is not set', function() {
 
-    beforeEach(function() {
-        affix('#cal');
+        var viewWithFormat = [
+            { view: 'month' },
+            { view: 'basicWeek' },
+            { view: 'agendaWeek' },
+            { view: 'basicDay' },
+            { view: 'agendaDay' }
+        ];
+
+        beforeEach(function() {
+            $('#cal').fullCalendar({
+                defaultDate: '2014-05-11'
+            });
+        });
+
+        it('header should be visible', function() {
+            var cal = $('#cal');
+
+            for (var i = 0; i <  viewWithFormat.length; i++) {
+                var crtView = viewWithFormat[i];
+                cal.fullCalendar('changeView', crtView.view);
+                expect(cal.find('thead.fc-head').length).toBe(1);
+            };
+        });
     });
 
+    describe('when columnHead is set to false', function() {
+
+        var viewWithFormat = [
+            { view: 'month' },
+            { view: 'basicWeek' },
+            { view: 'agendaWeek' },
+            { view: 'basicDay' },
+            { view: 'agendaDay' }
+        ];
+
+        beforeEach(function() {
+            $('#cal').fullCalendar({
+                defaultDate: '2014-05-11',
+                columnHead: false
+            });
+        });
+
+        it('header should not be visible', function() {
+            var cal = $('#cal');
+
+            for (var i = 0; i <  viewWithFormat.length; i++) {
+                var crtView = viewWithFormat[i];
+                cal.fullCalendar('changeView', crtView.view);
+                expect(cal.find('thead.fc-head').length).toBe(0);
+            };
+        });
+    });
+
+    describe('when columnHead is set on a per-view basis', function() {
+
+        var viewWithFormat = [
+            { view: 'month', columnHeadLength: 0 },
+            { view: 'basicWeek', columnHeadLength: 1 },
+            { view: 'agendaWeek', columnHeadLength: 0 },
+            { view: 'basicDay', columnHeadLength: 0 },
+            { view: 'agendaDay', columnHeadLength: 1 }
+        ];
+
+        beforeEach(function() {
+            $('#cal').fullCalendar({
+                defaultDate: '2014-05-11',
+                views: {
+                    month: { columnHead: false },
+                    agendaDay: { columnHead: true },
+                    agendaWeek: { columnHead: false },
+                    basicDay: { columnHead: false },
+                    basicWeek: { columnHead: true }
+                }
+            });
+        });
+
+        it('if columnHead is false, header should not be visible', function() {
+            var cal = $('#cal');
+
+            for (var i = 0; i <  viewWithFormat.length; i++) {
+                var crtView = viewWithFormat[i];
+                cal.fullCalendar('changeView', crtView.view);
+                expect(cal.find('thead.fc-head').length).toBe(crtView.columnHeadLength);
+            };
+        });
+    });
+});
+
+describe('columnFormat', function() {
+
     describe('when columnFormat is not set', function() {
 
         var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },