2015-04-13 14:52:03 +09:00
|
|
|
Template.singleDayNav.created = function(){
|
2015-01-06 14:46:38 +09:00
|
|
|
|
|
|
|
$(document).unbind('keyup'); //remove any potential existing bindings to avoid duplicates
|
|
|
|
|
2015-01-19 00:48:17 -08:00
|
|
|
var currentDate = moment(Session.get('currentDate')).startOf('day');
|
|
|
|
var today = moment(new Date()).startOf('day');
|
2015-01-06 14:46:38 +09:00
|
|
|
|
|
|
|
$(document).bind('keyup', 'left', function(){
|
|
|
|
Router.go($('.prev-link').attr('href'));
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('keyup', 'right', function(){
|
|
|
|
if(isAdmin(Meteor.user()) || today.diff(currentDate, 'days') > 0)
|
2015-01-19 00:48:17 -08:00
|
|
|
Router.go($('.next-link').attr('href'));
|
|
|
|
});
|
2015-01-06 14:46:38 +09:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-04-13 14:52:03 +09:00
|
|
|
Template.singleDayNav.helpers({
|
2015-01-06 14:46:38 +09:00
|
|
|
currentDate: function(){
|
2015-01-19 00:48:17 -08:00
|
|
|
var currentDate = moment(Session.get('currentDate'));
|
|
|
|
var today = moment(new Date());
|
|
|
|
var diff = today.diff(currentDate, 'days');
|
|
|
|
if (diff === 0) {
|
2015-01-06 14:46:38 +09:00
|
|
|
return i18n.t("today");
|
2015-01-19 00:48:17 -08:00
|
|
|
}
|
|
|
|
if (diff === 1) {
|
2015-01-06 14:46:38 +09:00
|
|
|
return i18n.t("yesterday");
|
2015-01-19 00:48:17 -08:00
|
|
|
}
|
2015-01-06 14:46:38 +09:00
|
|
|
return currentDate.format("dddd, MMMM Do YYYY");
|
2015-01-19 00:48:17 -08:00
|
|
|
},
|
2015-01-06 14:46:38 +09:00
|
|
|
previousDateURL: function(){
|
2015-01-19 00:48:17 -08:00
|
|
|
var currentDate = moment(Session.get('currentDate'));
|
|
|
|
var newDate = currentDate.subtract(1, 'days');
|
2015-01-08 16:01:51 +09:00
|
|
|
return getDateURL(newDate);
|
2015-01-06 14:46:38 +09:00
|
|
|
},
|
|
|
|
showPreviousDate: function(){
|
|
|
|
// TODO
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
nextDateURL: function(){
|
2015-01-19 00:48:17 -08:00
|
|
|
var currentDate = moment(Session.get('currentDate'));
|
|
|
|
var newDate = currentDate.add(1, 'days');
|
2015-01-08 16:01:51 +09:00
|
|
|
return getDateURL(newDate);
|
2015-01-06 14:46:38 +09:00
|
|
|
},
|
|
|
|
showNextDate: function(){
|
2015-01-19 00:48:17 -08:00
|
|
|
var currentDate = moment(Session.get('currentDate')).startOf('day');
|
|
|
|
var today = moment(new Date()).startOf('day');
|
|
|
|
return isAdmin(Meteor.user()) || (today.diff(currentDate, 'days') > 0);
|
2015-01-06 14:46:38 +09:00
|
|
|
}
|
|
|
|
})
|