2015-09-17 14:51:14 +09:00
|
|
|
var getDateRoute = function (moment) {
|
|
|
|
FlowRouter.watchPathChange();
|
|
|
|
var currentQuery = _.clone(FlowRouter.current().queryParams);
|
|
|
|
var newQuery = _.extend(currentQuery, {
|
2015-05-02 13:44:41 +09:00
|
|
|
year: moment.year(),
|
|
|
|
month: moment.month() + 1,
|
2015-09-17 14:51:14 +09:00
|
|
|
date: moment.date()
|
2015-05-02 13:44:41 +09:00
|
|
|
});
|
2015-09-17 14:51:14 +09:00
|
|
|
return FlowRouter.path('postsDefault', FlowRouter.current().params, newQuery);
|
2015-05-02 13:44:41 +09:00
|
|
|
};
|
|
|
|
|
2015-06-09 20:59:46 -04:00
|
|
|
Template.single_day_nav.onDestroyed(function(){
|
|
|
|
|
|
|
|
$(document).unbind('keyup'); //clean up to prevent errors on other pages
|
2015-04-22 07:50:11 +09:00
|
|
|
|
2015-05-02 13:44:41 +09:00
|
|
|
});
|
2015-04-22 07:50:11 +09:00
|
|
|
|
2015-05-07 15:44:12 +09:00
|
|
|
Template.single_day_nav.helpers({
|
2015-04-22 07:50:11 +09:00
|
|
|
currentDate: function(){
|
2015-09-17 14:51:14 +09:00
|
|
|
return this.currentDate.format("dddd, MMMM Do YYYY");
|
2015-04-22 07:50:11 +09:00
|
|
|
},
|
|
|
|
previousDateURL: function(){
|
2015-09-17 14:51:14 +09:00
|
|
|
var newDate = this.currentDate.subtract(1, 'days');
|
|
|
|
return getDateRoute(newDate);
|
2015-04-22 07:50:11 +09:00
|
|
|
},
|
|
|
|
showPreviousDate: function(){
|
|
|
|
// TODO
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
nextDateURL: function(){
|
2015-09-17 14:51:14 +09:00
|
|
|
var newDate = this.currentDate.add(1, 'days');
|
|
|
|
return getDateRoute(newDate);
|
2015-04-22 07:50:11 +09:00
|
|
|
},
|
|
|
|
showNextDate: function(){
|
2015-09-17 14:51:14 +09:00
|
|
|
var today = moment().startOf('day');
|
|
|
|
return Users.is.admin(Meteor.user()) || (today.diff(this.currentDate, 'days') > 0);
|
2015-04-22 07:50:11 +09:00
|
|
|
}
|
2015-05-01 18:22:00 +02:00
|
|
|
});
|