Răsfoiți Sursa

fix bugs related to refactor

Adam Shaw 11 ani în urmă
părinte
comite
fabf5a6935

+ 6 - 5
src/Calendar.js

@@ -403,7 +403,7 @@ function Calendar(element, instanceOptions) {
 		var viewOptionsChain = [];
 		var viewOptions;
 		var viewClass;
-		var duration, unit;
+		var duration;
 
 		if (viewSpecCache[requestedViewType]) {
 			return viewSpecCache[requestedViewType];
@@ -436,10 +436,11 @@ function Calendar(element, instanceOptions) {
 			duration = viewOptions.duration || viewClass.duration;
 			if (duration) {
 				duration = moment.duration(duration);
-				unit = computeIntervalUnit(duration);
-				if (hash[unit]) {
-					viewOptions = $.extend({}, hash[unit], viewOptions); // lowest priority
-				}
+				$.each(intervalUnits, function(i, unit) {
+					if (hash[unit] && computeIntervalAs(unit, duration) === 1) {
+						viewOptions = $.extend({}, hash[unit], viewOptions); // lowest priority
+					}
+				});
 			}
 
 			return (viewSpecCache[requestedViewType] = {

+ 1 - 1
src/EventManager.js

@@ -711,7 +711,7 @@ function EventManager(options) { // assumed to be a calendar
 		if (props.end === undefined) {
 			props.end = event.end ? event.end.clone() : null;
 		}
-		if (props.allDay == undefined) { // is null or undefined?
+		if (props.allDay == null) { // is null or undefined?
 			props.allDay = event.allDay;
 		}
 

+ 2 - 1
src/agenda/AgendaView.js

@@ -16,7 +16,7 @@ setDefaults({
 
 var AGENDA_ALL_DAY_EVENT_LIMIT = 5;
 
-var AgendaView = fcViews.agenda = View.extend({
+fcViews.agenda = View.extend({ // AgendaView
 
 	timeGrid: null, // the main time-grid subcomponent of this view
 	dayGrid: null, // the "all-day" subcomponent. if all-day is turned off, this will be null
@@ -35,6 +35,7 @@ var AgendaView = fcViews.agenda = View.extend({
 
 		if (this.opt('allDaySlot')) { // should we display the "all-day" area?
 			this.dayGrid = new DayGrid(this); // the all-day subcomponent of this view
+			this.dayGrid.breakOnWeeks = false;
 
 			// the coordinate grid will be a combination of both subcomponents' grids
 			this.coordMap = new ComboCoordMap([

+ 1 - 1
src/basic/MonthView.js

@@ -6,7 +6,7 @@ setDefaults({
 	fixedWeekCount: true
 });
 
-var MonthView = fcViews.month = BasicView.extend({
+fcViews.month = BasicView.extend({ // MonthView
 
 	computeRange: function(date) {
 		var rowCnt;

+ 6 - 1
src/common/DayGrid.js

@@ -6,6 +6,7 @@ var DayGrid = Grid.extend({
 
 	numbersVisible: false, // should render a row for day/week numbers? set by outside view. TODO: make internal
 	bottomCoordPadding: 0, // hack for extending the hit area for the last row of the coordinate grid
+	breakOnWeeks: null, // allows the outside view to override this rendering setting
 
 	cellDates: null, // flat chronological array of each cell's dates
 	dayToCellOffsets: null, // maps days offsets from grid's start date, to cell offsets
@@ -125,12 +126,16 @@ var DayGrid = Grid.extend({
 
 	// Initializes row/col information
 	updateCells: function() {
-		var breakOnWeeks = /year|month|week/.test(this.view.intervalUnit);
+		var breakOnWeeks = this.breakOnWeeks; // look at the override first
 		var cellDates;
 		var firstDay;
 		var rowCnt;
 		var colCnt;
 
+		if (breakOnWeeks == null) { // not overridden. compute it
+			breakOnWeeks = /year|month|week/.test(this.view.intervalUnit);
+		}
+
 		this.updateCellDates(); // populates cellDates and dayToCellOffsets
 		cellDates = this.cellDates;
 

+ 2 - 3
tests/automated/views-specific-options.js

@@ -17,11 +17,10 @@ describe('view-specific options', function() {
 
 	function testEachView(viewsAndVals) {
 		$('#cal').fullCalendar(options);
-		for (var view in viewsAndVals) {
-			var val = viewsAndVals[view];
+		$.each(viewsAndVals, function(view, val) {
 			$('#cal').fullCalendar('changeView', view);
 			expect($('h2')).toHaveText(val);
-		}
+		});
 	}
 
 	it('can target a specific view (month)', function() {