Parcourir la source

fix for IE8 not displaying "more" link with rowspans > 1

Adam Shaw il y a 11 ans
Parent
commit
83194def54
2 fichiers modifiés avec 22 ajouts et 5 suppressions
  1. 13 2
      src/common/DayGrid.limit.js
  2. 9 3
      tests/automated/eventLimit.js

+ 13 - 2
src/common/DayGrid.limit.js

@@ -51,11 +51,22 @@ DayGrid.mixin({
 		var rowHeight = rowEl.height(); // TODO: cache somehow?
 		var trEls = this.rowStructs[row].tbodyEl.children();
 		var i, trEl;
+		var trHeight;
 
 		// Reveal one level <tr> at a time and stop when we find one out of bounds
 		for (i = 0; i < trEls.length; i++) {
-			trEl = trEls.eq(i).removeClass('fc-limited'); // get and reveal
-			if (trEl.position().top + trEl.outerHeight() > rowHeight) {
+			trEl = trEls.eq(i).removeClass('fc-limited'); // reset to original state (reveal)
+
+			// with rowspans>1 and IE8, trEl.outerHeight() would return the height of the largest cell,
+			// so instead, find the tallest inner content element.
+			/*jshint -W083 */
+			trHeight = 0;
+			trEl.find('> td > :first-child').each(function(i, childNode) {
+				trHeight = Math.max(trHeight, $(childNode).outerHeight());
+			});
+			/*jshint +W083 */
+
+			if (trEl.position().top + trHeight > rowHeight) {
 				return i;
 			}
 		}

+ 9 - 3
tests/automated/eventLimit.js

@@ -151,9 +151,6 @@ describe('eventLimit', function() {
 
 			beforeEach(function() {
 				options.defaultView = 'month';
-			});
-
-			it('renders the heights of all the rows the same, regardless of # of events', function() {
 				options.events = [
 					{ title: 'event1', start: '2014-07-28', end: '2014-07-30' },
 					{ title: 'event2', start: '2014-07-28', end: '2014-07-30' },
@@ -169,6 +166,9 @@ describe('eventLimit', function() {
 					{ title: 'event2', start: '2014-07-29' },
 					{ title: 'event2', start: '2014-07-29' }
 				];
+			});
+
+			it('renders the heights of all the rows the same, regardless of # of events', function() {
 				$('#cal').fullCalendar(options);
 				var rowEls = $('.fc-day-grid .fc-row').slice(0, -1); // remove last b/c it will be a different height
 				expect(rowEls.length).toBeGreaterThan(0);
@@ -177,6 +177,12 @@ describe('eventLimit', function() {
 					expect($(node).height()).toBe(height);
 				});
 			});
+
+			it('renders a more link when there are obviously too many events', function() {
+				$('#cal').width(800);
+				$('#cal').fullCalendar(options);
+				expect($('#cal .fc-more').length).toBe(1);
+			});
 		});
 
 		[ 'month', 'basicWeek' ].forEach(function(viewName) {