2012-10-10 13:54:48 +09:00
|
|
|
Template.posts_digest.helpers({
|
|
|
|
posts: function(){
|
2012-11-25 19:10:10 +11:00
|
|
|
return postsForSub.digestPosts();
|
2012-10-09 12:02:37 +09:00
|
|
|
},
|
2012-10-19 09:05:02 +09:00
|
|
|
hasPosts: function(){
|
2012-11-25 19:10:10 +11:00
|
|
|
return !!postsForSub.digestPosts().length;
|
2012-10-19 09:05:02 +09:00
|
|
|
},
|
2012-10-10 13:54:48 +09:00
|
|
|
currentDate: function(){
|
2012-11-25 19:01:52 +11:00
|
|
|
return moment(Session.get('currentDate')).format("dddd, MMMM Do YYYY");
|
2012-10-10 13:54:48 +09:00
|
|
|
},
|
|
|
|
previousDateURL: function(){
|
2012-11-25 19:01:52 +11:00
|
|
|
var currentDate=moment(Session.get('currentDate'));
|
|
|
|
var newDate=currentDate.subtract('days', 1);
|
|
|
|
return getDigestURL(newDate);
|
2012-10-10 13:54:48 +09:00
|
|
|
},
|
|
|
|
showPreviousDate: function(){
|
|
|
|
// TODO
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
nextDateURL: function(){
|
2012-11-25 19:01:52 +11:00
|
|
|
var currentDate=moment(Session.get('currentDate'));
|
|
|
|
var newDate=currentDate.add('days', 1);
|
|
|
|
return getDigestURL(newDate);
|
2012-10-10 13:54:48 +09:00
|
|
|
},
|
|
|
|
showNextDate: function(){
|
2012-11-25 19:01:52 +11:00
|
|
|
var currentDate=moment(Session.get('currentDate')).startOf('day');
|
|
|
|
var today=moment(new Date()).startOf('day');
|
2012-11-26 11:27:27 +09:00
|
|
|
return isAdmin(Meteor.user()) || (today.diff(currentDate, 'days') > 0)
|
2012-10-09 12:02:37 +09:00
|
|
|
}
|
2012-10-22 09:28:42 +09:00
|
|
|
});
|
|
|
|
|
2012-10-22 14:00:47 +09:00
|
|
|
Template.posts_digest.created = function(){
|
2012-11-25 19:01:52 +11:00
|
|
|
var currentDate=moment(Session.get('currentDate')).startOf('day');
|
|
|
|
var today=moment(new Date()).startOf('day');
|
|
|
|
$(document).bind('keydown', 'left', function(){
|
2012-11-26 12:18:29 +09:00
|
|
|
Meteor.Router.to($('.prev-link').attr('href'));
|
2012-11-25 19:01:52 +11:00
|
|
|
});
|
|
|
|
$(document).bind('keydown', 'right', function(){
|
2012-11-26 11:27:27 +09:00
|
|
|
if(isAdmin(Meteor.user()) || today.diff(currentDate, 'days') > 0)
|
2012-11-26 12:18:29 +09:00
|
|
|
Meteor.Router.to($('.next-link').attr('href'));
|
2012-11-25 19:01:52 +11:00
|
|
|
});
|
2012-10-22 09:28:42 +09:00
|
|
|
};
|