Bladeren bron

make all JS (mostly tests) es3-compliant, because we care about testing in IE8

Adam Shaw 12 jaren geleden
bovenliggende
commit
315a3dc0b6

+ 4 - 1
build/jscs.conf.js

@@ -45,6 +45,9 @@ module.exports = {
 		src: 'tests/automated/*.js'
 	},
 
-	misc: '*.js' // config files in root
+	misc: [
+		'*.js', // ex: Gruntfile.js
+		'build/*.js' // ex: this file
+	]
 
 };

+ 1 - 0
build/jshint.conf.js

@@ -8,6 +8,7 @@ module.exports = {
 			moment: false,
 			jQuery: false
 		},
+		es3: true,
 		bitwise: true,
 		camelcase: true,
 		curly: true,

+ 1 - 1
src/agenda/AgendaView.js

@@ -572,7 +572,7 @@ function AgendaView(element, calendar, viewName) {
 			var date = cellToDate(0, col);
 			var match = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data
 			if (match) {
-				var slotIndex = parseInt(match[1]);
+				var slotIndex = parseInt(match[1], 10);
 				date.add(minTime + slotIndex * slotDuration);
 				date = calendar.rezoneDate(date);
 				trigger(

+ 1 - 1
tests/automated/columnFormat.js

@@ -45,7 +45,7 @@ describe('columnFormat', function() {
                     agendaDay: 'dddd M/D',
                     agendaWeek: 'dddd D , M',
                     basicDay: 'dddd D | M',
-                    basicWeek: 'dddd D - M',
+                    basicWeek: 'dddd D - M'
                 }
             });
         });

+ 1 - 1
tests/automated/dayNames.js

@@ -11,7 +11,7 @@ describe('day names', function() {
     '.fc-wed',
     '.fc-thu',
     '.fc-fri',
-    '.fc-sat',
+    '.fc-sat'
   ];
   var referenceDate = '2014-05-25 06:00'; // A sunday
   var languages = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ];

+ 1 - 1
tests/automated/dayNamesShort.js

@@ -3,7 +3,7 @@ describe('short day names', function() {
   var testableClasses = [
     'month',
     'agendaWeek',
-    'basicWeek',
+    'basicWeek'
   ];
   var dayClasses = [
     '.fc-sun',

+ 1 - 1
tests/automated/moment-query.js

@@ -4,7 +4,7 @@
 	var momentTypeSuffixes = {
 		'ambiguously-timed': '',
 		'ambiguously-zoned': 'T00:30:00',
-		timed: 'T00:30:00-0500',
+		timed: 'T00:30:00-0500'
 	};
 
 	describe('isWithin', function() {

+ 1 - 1
tests/automated/updateEvent.js

@@ -360,7 +360,7 @@ describe('updateEvent', function() {
 			beforeEach(function() {
 				options.events = [
 					{ id: '1', start: '2014-05-01T06:00:00+05:00', end: '2014-05-03T06:00:00+05:00', allDay: false },
-					{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false },
+					{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false }
 				];
 				init();
 				event.end.add('hours', 2);

+ 14 - 14
tests/automated/weekMode.js

@@ -29,11 +29,11 @@ describe('weekMode', function() {
 		});
 		it('should not change height whether 4,5 or weeks', function() {
 			$('#cal').fullCalendar('gotoDate', '2009-02-01');
-			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-10-01');
-			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-06-01');
-			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			expect(fourWeekHeight).toEqual(fiveWeekHeight);
 			expect(fiveWeekHeight).toEqual(sixWeekHeight);
 		});
@@ -85,30 +85,30 @@ describe('weekMode', function() {
 		});
 		it('should increase height when moving from 6 week to 5 weeks', function() {
 			$('#cal').fullCalendar('gotoDate', '2013-10-01');
-			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-06-01');
-			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
 		});
 		it('should reduce height when moving from 5 weeks to 6 weeks', function() {
 			$('#cal').fullCalendar('gotoDate', '2013-06-01');
-			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-10-01');
-			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
 		});
 		it('should increase height when moving from 5 weeks to 4 weeks', function() {
 			$('#cal').fullCalendar('gotoDate', '2013-05-01');
-			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2009-02-01');
-			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
 		});
 		it('should reduce height when moving from 4 weeks to 5 weeks', function() {
 			$('#cal').fullCalendar('gotoDate', '2009-02-01');
-			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-05-01');
-			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
 		});
 	});
@@ -136,11 +136,11 @@ describe('weekMode', function() {
 		});
 		it('should not change height whether 4,5 or weeks', function() {
 			$('#cal').fullCalendar('gotoDate', '2009-02-01');
-			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fourWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-10-01');
-			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var fiveWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			$('#cal').fullCalendar('gotoDate', '2013-06-01');
-			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'));
+			var sixWeekHeight = parseInt($('.fc-week.fc-first .fc-first.fc-day div').css('min-height'), 10);
 			expect(fourWeekHeight).toEqual(fiveWeekHeight);
 			expect(fiveWeekHeight).toEqual(sixWeekHeight);
 		});

+ 1 - 1
tests/automated/weekNumberCalculation.js

@@ -12,7 +12,7 @@ describe('weekNumberCalculation', function() {
 	function getRenderedWeekNumber() {
 		// works for both kinds of views
 		var text = $('.fc-agenda-axis.fc-week-number, .fc-week:first .fc-week-number').text();
-		return parseInt(text.replace(/\D/g, ''));
+		return parseInt(text.replace(/\D/g, ''), 10);
 	}
 
 	beforeEach(function() {