Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated MomentJS methods #121

Merged
merged 1 commit into from
Oct 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clndr.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<script src="json2.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src= "moment-2.5.1.js"></script>
<script src= "moment-2.8.3.js"></script>

<script src="../src/clndr.js"></script>
<script src="site.js"></script>
Expand Down
6 changes: 0 additions & 6 deletions example/moment-2.5.1.js

This file was deleted.

7 changes: 7 additions & 0 deletions example/moment-2.8.3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $(document).ready( function() {
startDate: 'startDate',
endDate: 'endDate'
},
startWithMonth: moment().add('month', 1),
startWithMonth: moment().add(1, 'month'),
clickEvents: {
click: function(target) {
console.log(target);
Expand Down
2 changes: 1 addition & 1 deletion example/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h4>These are the tests. If you are contributing to clndr.js, please take the ti
<script src="json2.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src= "moment-2.5.1.js"></script>
<script src= "moment-2.8.3.js"></script>

<script src="../src/clndr.js"></script>
<script src="test.js"></script>
Expand Down
8 changes: 4 additions & 4 deletions example/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ $( function() {
// test really long multi-day events
// ================================================================================
var multidayLongArray = [
{ startDate: moment().subtract('months', 3).format('YYYY-MM-') + '12', endDate: moment().format('YYYY-MM-') + '17', title: 'Multi1' },
{ startDate: moment().format('YYYY-MM-') + '24', endDate: moment().add('months', 4).format('YYYY-MM-') + '27', title: 'Multi2' }
{ startDate: moment().subtract(3, 'months').format('YYYY-MM-') + '12', endDate: moment().format('YYYY-MM-') + '17', title: 'Multi1' },
{ startDate: moment().format('YYYY-MM-') + '24', endDate: moment().add(4, 'months').format('YYYY-MM-') + '27', title: 'Multi2' }
];

clndr.multidayLong = $('#multiday-long').clndr({
Expand All @@ -112,7 +112,7 @@ $( function() {
clndr.constraints = $('#constraints').clndr({
constraints: {
startDate: moment().format('YYYY-MM-') + '04',
endDate: moment().add('months', 1).format('YYYY-MM-12')
endDate: moment().add(1, 'months').format('YYYY-MM-12')
},
clickEvents: {
click: function(target) {
Expand All @@ -139,7 +139,7 @@ $( function() {
// ================================================================================
clndr.endConstriant = $('#end-constraint').clndr({
constraints: {
endDate: moment().add('months', 1).format('YYYY-MM-') + '12'
endDate: moment().add(1, 'months').format('YYYY-MM-') + '12'
}
});

Expand Down
36 changes: 18 additions & 18 deletions src/clndr.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@
}).toArray();

if(this.options.showAdjacentMonths) {
var lastMonth = currentMonth.clone().subtract('months', 1);
var nextMonth = currentMonth.clone().add('months', 1);
var lastMonth = currentMonth.clone().subtract(1, 'months');
var nextMonth = currentMonth.clone().add(1, 'months');
this.eventsLastMonth = $(this.options.events).filter( function() {
// return this._clndrStartDateObject.format("YYYY-MM") <= lastMonth.format("YYYY-MM")
// || lastMonth.format("YYYY-MM") <= this._clndrEndDateObject.format("YYYY-MM");
Expand Down Expand Up @@ -284,8 +284,8 @@

// filter the adjacent months as well, if the option is true
if(this.options.showAdjacentMonths) {
var lastMonth = currentMonth.clone().subtract('months', 1);
var nextMonth = currentMonth.clone().add('months', 1);
var lastMonth = currentMonth.clone().subtract(1, 'months');
var nextMonth = currentMonth.clone().add(1, 'months');
this.eventsLastMonth = $(this.options.events).filter( function() {
return this._clndrDateObject.format("YYYY-MM") == lastMonth.format("YYYY-MM");
}).toArray();
Expand Down Expand Up @@ -337,11 +337,11 @@
// if we want to force six rows of calendar, now's our last chance to add another row.
// if the 42 seems explicit it's because we're creating a 7-row grid and 6 rows of 7 is always 42!
if(this.options.forceSixRows && daysArray.length !== 42 ) {
var start = moment(daysArray[daysArray.length - 1].date).add('days', 1);
var start = moment(daysArray[daysArray.length - 1].date).add(1, 'days');
while(daysArray.length < 42) {
if(this.options.showAdjacentMonths) {
daysArray.push( this.createDayObject(moment(start), this.eventsNextMonth) );
start.add('days', 1);
start.add(1, 'days');
} else {
daysArray.push( this.calendarDay({ classes: this.options.targets.empty + " next-month" }) );
}
Expand Down Expand Up @@ -490,11 +490,11 @@
this.element.find('.' + this.options.targets.nextButton).toggleClass('inactive', true);
}
// what's last year looking like?
if(start && moment(start).subtract('years', 1).isBefore(moment(this.month).subtract('years', 1)) ) {
if(start && moment(start).subtract(1, 'years').isBefore(moment(this.month).subtract(1, 'years')) ) {
this.element.find('.' + this.options.targets.previousYearButton).toggleClass('inactive', true);
}
// how about next year?
if(end && moment(end).add('years', 1).isAfter(moment(this.month).add('years', 1)) ) {
if(end && moment(end).add(1, 'years').isAfter(moment(this.month).add(1, 'years')) ) {
this.element.find('.' + this.options.targets.nextYearButton).toggleClass('inactive', true);
}
// today? we could put this in init(), but we want to support the user changing the constraints on a living instance.
Expand Down Expand Up @@ -622,8 +622,8 @@
}

// is subtracting one month going to switch the year?
var yearChanged = !self.month.isSame( moment(self.month).subtract('months', 1), 'year');
self.month.subtract('months', 1);
var yearChanged = !self.month.isSame( moment(self.month).subtract(1, 'months'), 'year');
self.month.subtract(1, 'months');

self.render();

Expand All @@ -648,8 +648,8 @@
}

// is adding one month going to switch the year?
var yearChanged = !self.month.isSame( moment(self.month).add('months', 1), 'year');
self.month.add('months', 1);
var yearChanged = !self.month.isSame( moment(self.month).add(1, 'months'), 'year');
self.month.add(1, 'months');

self.render();

Expand Down Expand Up @@ -706,7 +706,7 @@
return;
}

self.month.add('years', 1);
self.month.add(1, 'years');
self.render();

if(self.options.clickEvents.nextYear) {
Expand All @@ -728,7 +728,7 @@
return;
}

self.month.subtract('years', 1);
self.month.subtract(1, 'years');
self.render();

if(self.options.clickEvents.previousYear) {
Expand All @@ -743,7 +743,7 @@
};

Clndr.prototype.forward = function(options) {
this.month.add('months', 1);
this.month.add(1, 'months');
this.render();
if(options && options.withCallbacks) {
if(this.options.clickEvents.onMonthChange) {
Expand All @@ -760,7 +760,7 @@
}

Clndr.prototype.back = function(options) {
this.month.subtract('months', 1);
this.month.subtract(1, 'months');
this.render();
if(options && options.withCallbacks) {
if(this.options.clickEvents.onMonthChange) {
Expand Down Expand Up @@ -800,7 +800,7 @@
}

Clndr.prototype.nextYear = function(options) {
this.month.add('year', 1);
this.month.add(1, 'year');
this.render();
if(options && options.withCallbacks) {
if(this.options.clickEvents.onYearChange) {
Expand All @@ -811,7 +811,7 @@
}

Clndr.prototype.previousYear = function(options) {
this.month.subtract('year', 1);
this.month.subtract(1, 'year');
this.render();
if(options && options.withCallbacks) {
if(this.options.clickEvents.onYearChange) {
Expand Down