Vulcan/packages/telescope-singleday/lib/client/templates/single_day_nav.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-09-17 14:51:14 +09:00
var getDateRoute = function (moment) {
FlowRouter.watchPathChange();
var currentQuery = _.clone(FlowRouter.current().queryParams);
var newQuery = _.extend(currentQuery, {
year: moment.year(),
month: moment.month() + 1,
2015-09-17 14:51:14 +09:00
date: moment.date()
});
2015-09-17 14:51:14 +09:00
return FlowRouter.path('postsDefault', FlowRouter.current().params, newQuery);
};
Template.single_day_nav.onDestroyed(function(){
$(document).unbind('keyup'); //clean up to prevent errors on other pages
});
2015-05-07 15:44:12 +09:00
Template.single_day_nav.helpers({
currentDate: function(){
2015-09-17 14:51:14 +09:00
return this.currentDate.format("dddd, MMMM Do YYYY");
},
previousDateURL: function(){
2015-09-17 14:51:14 +09:00
var newDate = this.currentDate.subtract(1, 'days');
return getDateRoute(newDate);
},
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);
},
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);
}
});