Procházet zdrojové kódy

code quality improvements (for jshint)

Adam Shaw před 12 roky
rodič
revize
758a235d19

+ 5 - 4
src/EventManager.js

@@ -315,10 +315,11 @@ function EventManager(options) { // assumed to be a calendar
 	
 	
 	
 	
 	function removeEvents(filter) {
 	function removeEvents(filter) {
+		var i;
 		if (!filter) { // remove all
 		if (!filter) { // remove all
 			cache = [];
 			cache = [];
 			// clear all array sources
 			// clear all array sources
-			for (var i=0; i<sources.length; i++) {
+			for (i=0; i<sources.length; i++) {
 				if ($.isArray(sources[i].events)) {
 				if ($.isArray(sources[i].events)) {
 					sources[i].events = [];
 					sources[i].events = [];
 				}
 				}
@@ -332,7 +333,7 @@ function EventManager(options) { // assumed to be a calendar
 			}
 			}
 			cache = $.grep(cache, filter, true);
 			cache = $.grep(cache, filter, true);
 			// remove events from array sources
 			// remove events from array sources
-			for (var i=0; i<sources.length; i++) {
+			for (i=0; i<sources.length; i++) {
 				if ($.isArray(sources[i].events)) {
 				if ($.isArray(sources[i].events)) {
 					sources[i].events = $.grep(sources[i].events, filter, true);
 					sources[i].events = $.grep(sources[i].events, filter, true);
 				}
 				}
@@ -362,14 +363,14 @@ function EventManager(options) { // assumed to be a calendar
 	
 	
 	
 	
 	function pushLoading() {
 	function pushLoading() {
-		if (!loadingLevel++) {
+		if (!(loadingLevel++)) {
 			trigger('loading', null, true, getView());
 			trigger('loading', null, true, getView());
 		}
 		}
 	}
 	}
 	
 	
 	
 	
 	function popLoading() {
 	function popLoading() {
-		if (!--loadingLevel) {
+		if (!(--loadingLevel)) {
 			trigger('loading', null, false, getView());
 			trigger('loading', null, false, getView());
 		}
 		}
 	}
 	}

+ 2 - 2
src/agenda/AgendaEventRenderer.js

@@ -279,7 +279,7 @@ function AgendaEventRenderer() {
 		// record event sides and title positions
 		// record event sides and title positions
 		for (i=0; i<segCnt; i++) {
 		for (i=0; i<segCnt; i++) {
 			seg = segs[i];
 			seg = segs[i];
-			if (eventElement = seg.element) {
+			if ((eventElement = seg.element)) {
 				seg.vsides = vsides(eventElement, true);
 				seg.vsides = vsides(eventElement, true);
 				seg.hsides = hsides(eventElement, true);
 				seg.hsides = hsides(eventElement, true);
 				titleElement = eventElement.find('.fc-event-title');
 				titleElement = eventElement.find('.fc-event-title');
@@ -292,7 +292,7 @@ function AgendaEventRenderer() {
 		// set all positions/dimensions at once
 		// set all positions/dimensions at once
 		for (i=0; i<segCnt; i++) {
 		for (i=0; i<segCnt; i++) {
 			seg = segs[i];
 			seg = segs[i];
-			if (eventElement = seg.element) {
+			if ((eventElement = seg.element)) {
 				eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
 				eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
 				height = Math.max(0, seg.outerHeight - seg.vsides);
 				height = Math.max(0, seg.outerHeight - seg.vsides);
 				eventElement[0].style.height = height + 'px';
 				eventElement[0].style.height = height + 'px';

+ 17 - 18
src/agenda/AgendaView.js

@@ -50,25 +50,25 @@ function AgendaView(element, calendar, viewName) {
 	t.afterRender = afterRender;
 	t.afterRender = afterRender;
 	t.computeDateTop = computeDateTop;
 	t.computeDateTop = computeDateTop;
 	t.getIsCellAllDay = getIsCellAllDay;
 	t.getIsCellAllDay = getIsCellAllDay;
-	t.allDayRow = function() { return allDayRow }; // badly named
-	t.getCoordinateGrid = function() { return coordinateGrid }; // specifically for AgendaEventRenderer
-	t.getHoverListener = function() { return hoverListener };
+	t.allDayRow = function() { return allDayRow; }; // badly named
+	t.getCoordinateGrid = function() { return coordinateGrid; }; // specifically for AgendaEventRenderer
+	t.getHoverListener = function() { return hoverListener; };
 	t.colLeft = colLeft;
 	t.colLeft = colLeft;
 	t.colRight = colRight;
 	t.colRight = colRight;
 	t.colContentLeft = colContentLeft;
 	t.colContentLeft = colContentLeft;
 	t.colContentRight = colContentRight;
 	t.colContentRight = colContentRight;
-	t.getDaySegmentContainer = function() { return daySegmentContainer };
-	t.getSlotSegmentContainer = function() { return slotSegmentContainer };
-	t.getSlotContainer = function() { return slotContainer };
-	t.getRowCnt = function() { return 1 };
-	t.getColCnt = function() { return colCnt };
-	t.getColWidth = function() { return colWidth };
-	t.getSnapHeight = function() { return snapHeight };
-	t.getSnapDuration = function() { return snapDuration };
-	t.getSlotHeight = function() { return slotHeight };
-	t.getSlotDuration = function() { return slotDuration };
-	t.getMinTime = function() { return minTime };
-	t.getMaxTime = function() { return maxTime };
+	t.getDaySegmentContainer = function() { return daySegmentContainer; };
+	t.getSlotSegmentContainer = function() { return slotSegmentContainer; };
+	t.getSlotContainer = function() { return slotContainer; };
+	t.getRowCnt = function() { return 1; };
+	t.getColCnt = function() { return colCnt; };
+	t.getColWidth = function() { return colWidth; };
+	t.getSnapHeight = function() { return snapHeight; };
+	t.getSnapDuration = function() { return snapDuration; };
+	t.getSlotHeight = function() { return slotHeight; };
+	t.getSlotDuration = function() { return slotDuration; };
+	t.getMinTime = function() { return minTime; };
+	t.getMaxTime = function() { return maxTime; };
 	t.defaultSelectionEnd = defaultSelectionEnd;
 	t.defaultSelectionEnd = defaultSelectionEnd;
 	t.renderDayOverlay = renderDayOverlay;
 	t.renderDayOverlay = renderDayOverlay;
 	t.renderSelection = renderSelection;
 	t.renderSelection = renderSelection;
@@ -94,7 +94,6 @@ function AgendaView(element, calendar, viewName) {
 	var cellToDate = t.cellToDate;
 	var cellToDate = t.cellToDate;
 	var dateToCell = t.dateToCell;
 	var dateToCell = t.dateToCell;
 	var rangeToSegments = t.rangeToSegments;
 	var rangeToSegments = t.rangeToSegments;
-	var calendar = t.calendar;
 	var formatDate = calendar.formatDate;
 	var formatDate = calendar.formatDate;
 	var calculateWeekNumber = calendar.calculateWeekNumber;
 	var calculateWeekNumber = calendar.calculateWeekNumber;
 	
 	
@@ -172,7 +171,7 @@ function AgendaView(element, calendar, viewName) {
 	function updateOptions() {
 	function updateOptions() {
 
 
 		tm = opt('theme') ? 'ui' : 'fc';
 		tm = opt('theme') ? 'ui' : 'fc';
-		rtl = opt('isRTL')
+		rtl = opt('isRTL');
 		colFormat = opt('columnFormat');
 		colFormat = opt('columnFormat');
 
 
 		minTime = moment.duration(opt('minTime'));
 		minTime = moment.duration(opt('minTime'));
@@ -196,7 +195,7 @@ function AgendaView(element, calendar, viewName) {
 		var slotTime;
 		var slotTime;
 		var slotDate;
 		var slotDate;
 		var minutes;
 		var minutes;
-		var slotNormal = slotDuration.asMinutes() % 15 == 0;
+		var slotNormal = slotDuration.asMinutes() % 15 === 0;
 		
 		
 		buildDayTable();
 		buildDayTable();
 		
 		

+ 6 - 7
src/basic/BasicView.js

@@ -19,17 +19,17 @@ function BasicView(element, calendar, viewName) {
 	t.reportDayClick = reportDayClick; // for selection (kinda hacky)
 	t.reportDayClick = reportDayClick; // for selection (kinda hacky)
 	t.dragStart = dragStart;
 	t.dragStart = dragStart;
 	t.dragStop = dragStop;
 	t.dragStop = dragStop;
-	t.getHoverListener = function() { return hoverListener };
+	t.getHoverListener = function() { return hoverListener; };
 	t.colLeft = colLeft;
 	t.colLeft = colLeft;
 	t.colRight = colRight;
 	t.colRight = colRight;
 	t.colContentLeft = colContentLeft;
 	t.colContentLeft = colContentLeft;
 	t.colContentRight = colContentRight;
 	t.colContentRight = colContentRight;
-	t.getIsCellAllDay = function() { return true };
+	t.getIsCellAllDay = function() { return true; };
 	t.allDayRow = allDayRow;
 	t.allDayRow = allDayRow;
-	t.getRowCnt = function() { return rowCnt };
-	t.getColCnt = function() { return colCnt };
-	t.getColWidth = function() { return colWidth };
-	t.getDaySegmentContainer = function() { return daySegmentContainer };
+	t.getRowCnt = function() { return rowCnt; };
+	t.getColCnt = function() { return colCnt; };
+	t.getColWidth = function() { return colWidth; };
+	t.getDaySegmentContainer = function() { return daySegmentContainer; };
 	
 	
 	
 	
 	// imports
 	// imports
@@ -45,7 +45,6 @@ function BasicView(element, calendar, viewName) {
 	var cellToDate = t.cellToDate;
 	var cellToDate = t.cellToDate;
 	var dateToCell = t.dateToCell;
 	var dateToCell = t.dateToCell;
 	var rangeToSegments = t.rangeToSegments;
 	var rangeToSegments = t.rangeToSegments;
-	var calendar = t.calendar;
 	var formatDate = calendar.formatDate;
 	var formatDate = calendar.formatDate;
 	var calculateWeekNumber = calendar.calculateWeekNumber;
 	var calculateWeekNumber = calendar.calculateWeekNumber;
 	
 	

+ 7 - 9
src/common/DayEventRenderer.js

@@ -22,13 +22,11 @@ function DayEventRenderer() {
 	var eventResize = t.eventResize;
 	var eventResize = t.eventResize;
 	var getRowCnt = t.getRowCnt;
 	var getRowCnt = t.getRowCnt;
 	var getColCnt = t.getColCnt;
 	var getColCnt = t.getColCnt;
-	var getColWidth = t.getColWidth;
 	var allDayRow = t.allDayRow; // TODO: rename
 	var allDayRow = t.allDayRow; // TODO: rename
 	var colLeft = t.colLeft;
 	var colLeft = t.colLeft;
 	var colRight = t.colRight;
 	var colRight = t.colRight;
 	var colContentLeft = t.colContentLeft;
 	var colContentLeft = t.colContentLeft;
 	var colContentRight = t.colContentRight;
 	var colContentRight = t.colContentRight;
-	var dateToCell = t.dateToCell;
 	var getDaySegmentContainer = t.getDaySegmentContainer;
 	var getDaySegmentContainer = t.getDaySegmentContainer;
 	var renderDayOverlay = t.renderDayOverlay;
 	var renderDayOverlay = t.renderDayOverlay;
 	var clearOverlays = t.clearOverlays;
 	var clearOverlays = t.clearOverlays;
@@ -351,17 +349,18 @@ function DayEventRenderer() {
 		var rowContentHeights = calculateVerticals(segments); // also sets segment.top
 		var rowContentHeights = calculateVerticals(segments); // also sets segment.top
 		var rowContentElements = getRowContentElements(); // returns 1 inner div per row
 		var rowContentElements = getRowContentElements(); // returns 1 inner div per row
 		var rowContentTops = [];
 		var rowContentTops = [];
+		var i;
 
 
 		// Set each row's height by setting height of first inner div
 		// Set each row's height by setting height of first inner div
 		if (doRowHeights) {
 		if (doRowHeights) {
-			for (var i=0; i<rowContentElements.length; i++) {
+			for (i=0; i<rowContentElements.length; i++) {
 				rowContentElements[i].height(rowContentHeights[i]);
 				rowContentElements[i].height(rowContentHeights[i]);
 			}
 			}
 		}
 		}
 
 
 		// Get each row's top, relative to the views's origin.
 		// Get each row's top, relative to the views's origin.
 		// Important to do this after setting each row's height.
 		// Important to do this after setting each row's height.
-		for (var i=0; i<rowContentElements.length; i++) {
+		for (i=0; i<rowContentElements.length; i++) {
 			rowContentTops.push(
 			rowContentTops.push(
 				rowContentElements[i].position().top
 				rowContentElements[i].position().top
 			);
 			);
@@ -387,6 +386,7 @@ function DayEventRenderer() {
 		var colCnt = getColCnt();
 		var colCnt = getColCnt();
 		var rowContentHeights = []; // content height for each row
 		var rowContentHeights = []; // content height for each row
 		var segmentRows = buildSegmentRows(segments); // an array of segment arrays, one for each row
 		var segmentRows = buildSegmentRows(segments); // an array of segment arrays, one for each row
+		var colI;
 
 
 		for (var rowI=0; rowI<rowCnt; rowI++) {
 		for (var rowI=0; rowI<rowCnt; rowI++) {
 			var segmentRow = segmentRows[rowI];
 			var segmentRow = segmentRows[rowI];
@@ -394,7 +394,7 @@ function DayEventRenderer() {
 			// an array of running total heights for each column.
 			// an array of running total heights for each column.
 			// initialize with all zeros.
 			// initialize with all zeros.
 			var colHeights = [];
 			var colHeights = [];
-			for (var colI=0; colI<colCnt; colI++) {
+			for (colI=0; colI<colCnt; colI++) {
 				colHeights.push(0);
 				colHeights.push(0);
 			}
 			}
 
 
@@ -412,7 +412,7 @@ function DayEventRenderer() {
 				);
 				);
 
 
 				// adjust the columns to account for the segment's height
 				// adjust the columns to account for the segment's height
-				for (var colI=segment.leftCol; colI<=segment.rightCol; colI++) {
+				for (colI=segment.leftCol; colI<=segment.rightCol; colI++) {
 					colHeights[colI] = segment.top + segment.outerHeight;
 					colHeights[colI] = segment.top + segment.outerHeight;
 				}
 				}
 			}
 			}
@@ -643,8 +643,6 @@ function DayEventRenderer() {
 			}
 			}
 			isResizing = true;
 			isResizing = true;
 			var hoverListener = getHoverListener();
 			var hoverListener = getHoverListener();
-			var rowCnt = getRowCnt();
-			var colCnt = getColCnt();
 			var elementTop = element.css('top');
 			var elementTop = element.css('top');
 			var dayDelta;
 			var dayDelta;
 			var eventEnd;
 			var eventEnd;
@@ -763,6 +761,6 @@ function compareDaySegments(a, b) {
 	return (b.rightCol - b.leftCol) - (a.rightCol - a.leftCol) || // put wider events first
 	return (b.rightCol - b.leftCol) - (a.rightCol - a.leftCol) || // put wider events first
 		b.event.allDay - a.event.allDay || // if tie, put all-day events first (booleans cast to 0/1)
 		b.event.allDay - a.event.allDay || // if tie, put all-day events first (booleans cast to 0/1)
 		a.event.start - b.event.start || // if a tie, sort by event start date
 		a.event.start - b.event.start || // if a tie, sort by event start date
-		(a.event.title || '').localeCompare(b.event.title) // if a tie, sort by event title
+		(a.event.title || '').localeCompare(b.event.title); // if a tie, sort by event title
 }
 }
 
 

+ 3 - 3
src/common/HorizontalPositionCache.js

@@ -7,15 +7,15 @@ function HorizontalPositionCache(getElement) {
 		rights = {};
 		rights = {};
 		
 		
 	function e(i) {
 	function e(i) {
-		return elements[i] = elements[i] || getElement(i);
+		return (elements[i] = (elements[i] || getElement(i)));
 	}
 	}
 	
 	
 	t.left = function(i) {
 	t.left = function(i) {
-		return lefts[i] = lefts[i] === undefined ? e(i).position().left : lefts[i];
+		return (lefts[i] = (lefts[i] === undefined ? e(i).position().left : lefts[i]));
 	};
 	};
 	
 	
 	t.right = function(i) {
 	t.right = function(i) {
-		return rights[i] = rights[i] === undefined ? t.left(i) + e(i).width() : rights[i];
+		return (rights[i] = (rights[i] === undefined ? t.left(i) + e(i).width() : rights[i]));
 	};
 	};
 	
 	
 	t.clear = function() {
 	t.clear = function() {

+ 4 - 1
src/common/HoverListener.js

@@ -22,7 +22,10 @@ function HoverListener(coordinateGrid) {
 	function mouse(ev) {
 	function mouse(ev) {
 		_fixUIEvent(ev); // see below
 		_fixUIEvent(ev); // see below
 		var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
 		var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
-		if (!newCell != !cell || newCell && (newCell.row != cell.row || newCell.col != cell.col)) {
+		if (
+			Boolean(newCell) !== Boolean(cell) ||
+			newCell && (newCell.row != cell.row || newCell.col != cell.col)
+		) {
 			if (newCell) {
 			if (newCell) {
 				if (!firstCell) {
 				if (!firstCell) {
 					firstCell = newCell;
 					firstCell = newCell;

+ 1 - 1
src/common/OverlayManager.js

@@ -28,7 +28,7 @@ function OverlayManager() {
 
 
 	function clearOverlays() {
 	function clearOverlays() {
 		var e;
 		var e;
-		while (e = usedOverlays.shift()) {
+		while ((e = usedOverlays.shift())) {
 			unusedOverlays.push(e.hide().unbind());
 			unusedOverlays.push(e.hide().unbind());
 		}
 		}
 	}
 	}

+ 0 - 1
src/common/SelectionManager.js

@@ -79,7 +79,6 @@ function SelectionManager() {
 
 
 		if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
 		if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
 			unselect(ev);
 			unselect(ev);
-			var _mousedownElement = this;
 			var dates;
 			var dates;
 			hoverListener.start(function(cell, origCell) { // TODO: maybe put cellToDate/getIsCellAllDay info in cell
 			hoverListener.start(function(cell, origCell) { // TODO: maybe put cellToDate/getIsCellAllDay info in cell
 				clearSelection();
 				clearSelection();

+ 8 - 9
src/common/View.js

@@ -28,7 +28,6 @@ function View(element, calendar, viewName) {
 	
 	
 	// imports
 	// imports
 	var reportEventChange = calendar.reportEventChange;
 	var reportEventChange = calendar.reportEventChange;
-	var getEventEnd = calendar.getEventEnd;
 	
 	
 	
 	
 	// locals
 	// locals
@@ -529,11 +528,11 @@ function View(element, calendar, viewName) {
 	function cellOffsetToDayOffset(cellOffset) {
 	function cellOffsetToDayOffset(cellOffset) {
 		var day0 = t.start.day(); // first date's day of week
 		var day0 = t.start.day(); // first date's day of week
 		cellOffset += dayToCellMap[day0]; // normlize cellOffset to beginning-of-week
 		cellOffset += dayToCellMap[day0]; // normlize cellOffset to beginning-of-week
-		return Math.floor(cellOffset / cellsPerWeek) * 7 // # of days from full weeks
-			+ cellToDayMap[ // # of days from partial last week
+		return Math.floor(cellOffset / cellsPerWeek) * 7 + // # of days from full weeks
+			cellToDayMap[ // # of days from partial last week
 				(cellOffset % cellsPerWeek + cellsPerWeek) % cellsPerWeek // crazy math to handle negative cellOffsets
 				(cellOffset % cellsPerWeek + cellsPerWeek) % cellsPerWeek // crazy math to handle negative cellOffsets
-			]
-			- day0; // adjustment for beginning-of-week normalization
+			] -
+			day0; // adjustment for beginning-of-week normalization
 	}
 	}
 
 
 	// day offset -> date
 	// day offset -> date
@@ -563,11 +562,11 @@ function View(element, calendar, viewName) {
 	function dayOffsetToCellOffset(dayOffset) {
 	function dayOffsetToCellOffset(dayOffset) {
 		var day0 = t.start.day(); // first date's day of week
 		var day0 = t.start.day(); // first date's day of week
 		dayOffset += day0; // normalize dayOffset to beginning-of-week
 		dayOffset += day0; // normalize dayOffset to beginning-of-week
-		return Math.floor(dayOffset / 7) * cellsPerWeek // # of cells from full weeks
-			+ dayToCellMap[ // # of cells from partial last week
+		return Math.floor(dayOffset / 7) * cellsPerWeek + // # of cells from full weeks
+			dayToCellMap[ // # of cells from partial last week
 				(dayOffset % 7 + 7) % 7 // crazy math to handle negative dayOffsets
 				(dayOffset % 7 + 7) % 7 // crazy math to handle negative dayOffsets
-			]
-			- dayToCellMap[day0]; // adjustment for beginning-of-week normalization
+			] -
+			dayToCellMap[day0]; // adjustment for beginning-of-week normalization
 	}
 	}
 
 
 	// cell offset -> cell (object with row & col keys)
 	// cell offset -> cell (object with row & col keys)

+ 11 - 10
src/date_util.js

@@ -216,7 +216,7 @@ moment.fn.format = function() {
 	else {
 	else {
 		return momentFormatMethod.apply(this, arguments); // pass along all arguments
 		return momentFormatMethod.apply(this, arguments); // pass along all arguments
 	}
 	}
-}
+};
 
 
 moment.fn.toISOString = function() {
 moment.fn.toISOString = function() {
 	if (this._ambigTime) {
 	if (this._ambigTime) {
@@ -254,24 +254,25 @@ $.each([
 
 
 	moment.fn[methodName] = function() {
 	moment.fn[methodName] = function() {
 		var newThis;
 		var newThis;
+		var args = Array.prototype.slice.call(arguments);
 		var i;
 		var i;
 
 
 		if (this._ambigZone) {
 		if (this._ambigZone) {
 			for (i=0; i<momentCount; i++) {
 			for (i=0; i<momentCount; i++) {
-				if (typeof arguments[i] === 'string') {
-					arguments[i] = fc.moment.parseZone(arguments[i]);
+				if (typeof args[i] === 'string') {
+					args[i] = fc.moment.parseZone(args[i]);
 				}
 				}
 			}
 			}
 		}
 		}
 
 
 		for (i=0; i<momentCount; i++) {
 		for (i=0; i<momentCount; i++) {
-			if (moment.isMoment(arguments[i]) && arguments[i]._ambigZone !== this._ambigZone) {
+			if (moment.isMoment(args[i]) && args[i]._ambigZone !== this._ambigZone) {
 				newThis = newThis || this.clone().stripZone();
 				newThis = newThis || this.clone().stripZone();
-				arguments[i] = arguments[i].clone().stripZone();
+				args[i] = args[i].clone().stripZone();
 			}
 			}
 		}
 		}
 
 
-		return origMethod.apply(newThis || this, arguments);
+		return origMethod.apply(newThis || this, args);
 	};
 	};
 });
 });
 
 
@@ -317,7 +318,7 @@ function formatDateWithChunk(date, chunk) {
 	if (typeof chunk === 'string') { // a literal string
 	if (typeof chunk === 'string') { // a literal string
 		return chunk;
 		return chunk;
 	}
 	}
-	else if (token = chunk.token) { // a token, like "YYYY"
+	else if ((token = chunk.token)) { // a token, like "YYYY"
 		if (tokenOverrides[token]) {
 		if (tokenOverrides[token]) {
 			return tokenOverrides[token](date); // use our custom token
 			return tokenOverrides[token](date); // use our custom token
 		}
 		}
@@ -431,7 +432,7 @@ function formatSimilarChunk(date1, date2, chunk) {
 	if (typeof chunk === 'string') { // a literal string
 	if (typeof chunk === 'string') { // a literal string
 		return chunk;
 		return chunk;
 	}
 	}
-	else if (token = chunk.token) {
+	else if ((token = chunk.token)) {
 		unit = similarUnitMap[token.charAt(0)];
 		unit = similarUnitMap[token.charAt(0)];
 		// are the dates the same for this unit of measurement?
 		// are the dates the same for this unit of measurement?
 		if (unit && date1.isSame(date2, unit)) {
 		if (unit && date1.isSame(date2, unit)) {
@@ -456,7 +457,7 @@ function getFormatStringChunks(formatStr) {
 	if (formatStr in formatStringChunkCache) {
 	if (formatStr in formatStringChunkCache) {
 		return formatStringChunkCache[formatStr];
 		return formatStringChunkCache[formatStr];
 	}
 	}
-	return formatStringChunkCache[formatStr] = chunkFormatString(formatStr);
+	return (formatStringChunkCache[formatStr] = chunkFormatString(formatStr));
 }
 }
 
 
 
 
@@ -466,7 +467,7 @@ function chunkFormatString(formatStr) {
 	var chunker = /\[([^\]]*)\]|\(([^\)]*)\)|((\w)\4*o?T?)|([^\w\[\(]+)/g; // TODO: more descrimination
 	var chunker = /\[([^\]]*)\]|\(([^\)]*)\)|((\w)\4*o?T?)|([^\w\[\(]+)/g; // TODO: more descrimination
 	var match;
 	var match;
 
 
-	while (match = chunker.exec(formatStr)) {
+	while ((match = chunker.exec(formatStr))) {
 		if (match[1]) { // a literal string instead [ ... ]
 		if (match[1]) { // a literal string instead [ ... ]
 			chunks.push(match[1]);
 			chunks.push(match[1]);
 		}
 		}

+ 6 - 6
src/gcal/gcal.js

@@ -68,13 +68,13 @@ function transformOptions(sourceOptions, start, end, timezone) {
 					});
 					});
 
 
 					events.push({
 					events.push({
-						id: entry['gCal$uid']['value'],
-						title: entry['title']['$t'],
-						start: entry['gd$when'][0]['startTime'],
-						end: entry['gd$when'][0]['endTime'],
+						id: entry.gCal$uid.value,
+						title: entry.title.$t,
+						start: entry.gd$when[0].startTime,
+						end: entry.gd$when[0].endTime,
 						url: url,
 						url: url,
-						location: entry['gd$where'][0]['valueString'],
-						description: entry['content']['$t']
+						location: entry.gd$where[0].valueString,
+						description: entry.content.$t
 					});
 					});
 
 
 				});
 				});

+ 1 - 1
src/lang.js

@@ -43,7 +43,7 @@ fc.datepickerLang = function(langCode, datepickerLangCode, options) {
 				options;
 				options;
 
 
 		// Alias 'en' to the default language data. Do this every time.
 		// Alias 'en' to the default language data. Do this every time.
-		$.datepicker.regional['en'] = $.datepicker.regional[''];
+		$.datepicker.regional.en = $.datepicker.regional[''];
 
 
 		// Set as Datepicker's global defaults.
 		// Set as Datepicker's global defaults.
 		$.datepicker.setDefaults(options);
 		$.datepicker.setDefaults(options);

+ 13 - 9
src/main.js

@@ -49,17 +49,21 @@ function setDefaults(d) {
 //     mergeOptions(target, obj1, obj2, ...)
 //     mergeOptions(target, obj1, obj2, ...)
 //
 //
 function mergeOptions(target) {
 function mergeOptions(target) {
+
+	function mergeIntoTarget(name, value) {
+		if ($.isPlainObject(value) && $.isPlainObject(target[name]) && !isForcedAtomicOption(name)) {
+			// merge into a new object to avoid destruction
+			target[name] = mergeOptions({}, target[name], value); // combine. `value` object takes precedence
+		}
+		else if (value !== undefined) { // only use values that are set and not undefined
+			target[name] = value;
+		}
+	}
+
 	for (var i=1; i<arguments.length; i++) {
 	for (var i=1; i<arguments.length; i++) {
-		$.each(arguments[i], function(name, value) {
-			if ($.isPlainObject(value) && $.isPlainObject(target[name]) && !isForcedAtomicOption(name)) {
-				// merge into a new object to avoid destruction
-				target[name] = mergeOptions({}, target[name], value); // combine. `value` object takes precedence
-			}
-			else if (value !== undefined) { // only use values that are set and not undefined
-				target[name] = value;
-			}
-		});
+		$.each(arguments[i], mergeIntoTarget);
 	}
 	}
+
 	return target;
 	return target;
 }
 }
 
 

+ 10 - 10
tests/automated/aspectRatio.js

@@ -7,7 +7,7 @@ describe('aspectRatio', function() {
 
 
 	describe('when default settings are used', function() {
 	describe('when default settings are used', function() {
 		beforeEach(function() {
 		beforeEach(function() {
-			$('#cal').width(675)
+			$('#cal').width(675);
 			$('#cal').fullCalendar();
 			$('#cal').fullCalendar();
 		});
 		});
 		it('fc-content should use the ratio 1:35 to set height', function() {
 		it('fc-content should use the ratio 1:35 to set height', function() {
@@ -24,7 +24,7 @@ describe('aspectRatio', function() {
 
 
 		describe('to 2', function() {
 		describe('to 2', function() {
 			beforeEach(function() {
 			beforeEach(function() {
-				$('#cal').width(1000)
+				$('#cal').width(1000);
 				$('#cal').fullCalendar({
 				$('#cal').fullCalendar({
 					aspectRatio: 2
 					aspectRatio: 2
 				});
 				});
@@ -43,7 +43,7 @@ describe('aspectRatio', function() {
 
 
 		describe('to 1', function() {
 		describe('to 1', function() {
 			beforeEach(function() {
 			beforeEach(function() {
-				$('#cal').width(1000)
+				$('#cal').width(1000);
 				$('#cal').fullCalendar({
 				$('#cal').fullCalendar({
 					aspectRatio: 1
 					aspectRatio: 1
 				});
 				});
@@ -56,13 +56,13 @@ describe('aspectRatio', function() {
 				var width = $('.fc-content').width();
 				var width = $('.fc-content').width();
 				var height = $('.fc-content').height();
 				var height = $('.fc-content').height();
 				var ratio = Math.round(width / height * 100);
 				var ratio = Math.round(width / height * 100);
-				expect(ratio).toEqual(100)
+				expect(ratio).toEqual(100);
 			});
 			});
 		});
 		});
 
 
 		describe('to less than 0.5', function() {
 		describe('to less than 0.5', function() {
 			beforeEach(function() {
 			beforeEach(function() {
-				$('#cal').width(1000)
+				$('#cal').width(1000);
 				$('#cal').fullCalendar({
 				$('#cal').fullCalendar({
 					aspectRatio: 0.4
 					aspectRatio: 0.4
 				});
 				});
@@ -81,7 +81,7 @@ describe('aspectRatio', function() {
 
 
 		describe('to negative', function() {
 		describe('to negative', function() {
 			beforeEach(function() {
 			beforeEach(function() {
-				$('#cal').width(1000)
+				$('#cal').width(1000);
 				$('#cal').fullCalendar({
 				$('#cal').fullCalendar({
 					aspectRatio: -2
 					aspectRatio: -2
 				});
 				});
@@ -94,13 +94,13 @@ describe('aspectRatio', function() {
 				var width = $('.fc-content').width();
 				var width = $('.fc-content').width();
 				var height = $('.fc-content').height();
 				var height = $('.fc-content').height();
 				var ratio = Math.round(width / height * 100);
 				var ratio = Math.round(width / height * 100);
-				expect(ratio).toEqual(50)
+				expect(ratio).toEqual(50);
 			});
 			});
 		});
 		});
 
 
 		describe('to zero', function() {
 		describe('to zero', function() {
 			beforeEach(function() {
 			beforeEach(function() {
-				$('#cal').width(1000)
+				$('#cal').width(1000);
 				$('#cal').fullCalendar({
 				$('#cal').fullCalendar({
 					aspectRatio: 0
 					aspectRatio: 0
 				});
 				});
@@ -119,7 +119,7 @@ describe('aspectRatio', function() {
 
 
 		describe('to very large', function() {
 		describe('to very large', function() {
 			beforeEach(function() {
 			beforeEach(function() {
-				$('#cal').width(1000)
+				$('#cal').width(1000);
 				$('#cal').fullCalendar({
 				$('#cal').fullCalendar({
 					aspectRatio: 4000
 					aspectRatio: 4000
 				});
 				});
@@ -132,7 +132,7 @@ describe('aspectRatio', function() {
 				var actualHeight = $('.fc-content').height();
 				var actualHeight = $('.fc-content').height();
 				$('tr.fc-week td:first-child > div').css('min-height', '').css('background', 'red');
 				$('tr.fc-week td:first-child > div').css('min-height', '').css('background', 'red');
 				var naturalHeight = $('.fc-content').height();
 				var naturalHeight = $('.fc-content').height();
-				expect(actualHeight).toEqual(naturalHeight)
+				expect(actualHeight).toEqual(naturalHeight);
 			});
 			});
 		});
 		});
 	});
 	});

+ 1 - 1
tests/automated/header.js

@@ -70,7 +70,7 @@ describe('header testing', function() {
 				header: false
 				header: false
 			};
 			};
 			$('#calendar').fullCalendar(options);
 			$('#calendar').fullCalendar(options);
-		})
+		});
 		it('should not have header table', function() {
 		it('should not have header table', function() {
 			var headerTableCount = $('table.fc-header').length;
 			var headerTableCount = $('table.fc-header').length;
 			expect(headerTableCount).toEqual(0);
 			expect(headerTableCount).toEqual(0);

+ 1 - 1
tests/automated/weekends.js

@@ -4,7 +4,7 @@ describe('when weekends option is set', function() {
 	beforeEach(function() {
 	beforeEach(function() {
 		affix('#calendar');
 		affix('#calendar');
 		var cal = $('#calendar');
 		var cal = $('#calendar');
-	})
+	});
 
 
 	it('should show sat and sun if true', function() {
 	it('should show sat and sun if true', function() {
 		var options = {
 		var options = {