Vulcan/client/views/posts/posts_digest.js

43 lines
1.4 KiB
JavaScript
Raw Normal View History

2012-10-10 13:54:48 +09:00
Template.posts_digest.helpers({
posts: function(){
return currentDigestHandle().fetch();
2012-10-09 12:02:37 +09:00
},
hasPosts: function(){
2012-12-13 18:46:09 +11:00
var handle = currentDigestHandle()
return handle && ! handle.loading() && handle.loaded() > 0;
},
2012-10-10 13:54:48 +09:00
currentDate: function(){
return moment(Session.get('currentDate')).format("dddd, MMMM Do YYYY");
2012-10-10 13:54:48 +09:00
},
previousDateURL: function(){
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(){
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(){
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(){
var currentDate=moment(Session.get('currentDate')).startOf('day');
var today=moment(new Date()).startOf('day');
$(document).bind('keydown', 'left', function(){
Meteor.Router.to($('.prev-link').attr('href'));
});
$(document).bind('keydown', 'right', function(){
2012-11-26 11:27:27 +09:00
if(isAdmin(Meteor.user()) || today.diff(currentDate, 'days') > 0)
Meteor.Router.to($('.next-link').attr('href'));
});
2012-10-22 09:28:42 +09:00
};