Explorar el Código

have dateprofilebuilding pass in an existing dateprofile

Adam Shaw hace 8 años
padre
commit
fef148e8d4
Se han modificado 3 ficheros con 14 adiciones y 12 borrados
  1. 4 2
      src/Calendar.js
  2. 2 2
      src/Calendar.toolbar.js
  3. 8 8
      src/View.date-range.js

+ 4 - 2
src/Calendar.js

@@ -179,7 +179,8 @@ var Calendar = FC.Calendar = Class.extend(EmitterMixin, ListenerMixin, {
 
 
 	prev: function() {
-		var prevInfo = this.view.buildPrevDateProfile(this.currentDate);
+		var view = this.view;
+		var prevInfo = view.buildPrevDateProfile(view.get('dateProfile'));
 
 		if (prevInfo.isValid) {
 			this.currentDate = prevInfo.date;
@@ -189,7 +190,8 @@ var Calendar = FC.Calendar = Class.extend(EmitterMixin, ListenerMixin, {
 
 
 	next: function() {
-		var nextInfo = this.view.buildNextDateProfile(this.currentDate);
+		var view = this.view;
+		var nextInfo = view.buildNextDateProfile(view.get('dateProfile'));
 
 		if (nextInfo.isValid) {
 			this.currentDate = nextInfo.date;

+ 2 - 2
src/Calendar.toolbar.js

@@ -64,8 +64,8 @@ Calendar.mixin({
 		var now = this.getNow();
 		var view = this.view;
 		var todayInfo = view.buildDateProfile(now);
-		var prevInfo = view.buildPrevDateProfile(this.currentDate);
-		var nextInfo = view.buildNextDateProfile(this.currentDate);
+		var prevInfo = view.buildPrevDateProfile(view.get('dateProfile'));
+		var nextInfo = view.buildNextDateProfile(view.get('dateProfile'));
 
 		this.toolbarsManager.proxyCall(
 			(todayInfo.isValid && !dateProfile.currentUnzonedRange.containsDate(now)) ?

+ 8 - 8
src/View.date-range.js

@@ -9,20 +9,20 @@ View.mixin({
 
 
 	// Builds a structure with info about what the dates/ranges will be for the "prev" view.
-	buildPrevDateProfile: function(date) {
-		var dateProfile = this.get('dateProfile');
-		var prevDate = date.clone().startOf(dateProfile.currentRangeUnit)
-			.subtract(dateProfile.dateIncrement);
+	buildPrevDateProfile: function(currentDateProfile) {
+		var prevDate = currentDateProfile.date.clone()
+			.startOf(currentDateProfile.currentRangeUnit)
+			.subtract(currentDateProfile.dateIncrement);
 
 		return this.buildDateProfile(prevDate, -1);
 	},
 
 
 	// Builds a structure with info about what the dates/ranges will be for the "next" view.
-	buildNextDateProfile: function(date) {
-		var dateProfile = this.get('dateProfile');
-		var nextDate = date.clone().startOf(dateProfile.currentRangeUnit)
-			.add(dateProfile.dateIncrement);
+	buildNextDateProfile: function(currentDateProfile) {
+		var nextDate = currentDateProfile.date.clone()
+			.startOf(currentDateProfile.currentRangeUnit)
+			.add(currentDateProfile.dateIncrement);
 
 		return this.buildDateProfile(nextDate, 1);
 	},