mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00
Fix arrow key navigation for Single Day view. Fixes #986
This commit is contained in:
parent
af655c9571
commit
4ed59aadf2
1 changed files with 21 additions and 6 deletions
|
@ -14,15 +14,30 @@ Template.single_day_nav.onCreated(function(){
|
|||
var currentDate = moment(this.data.terms.date).startOf('day');
|
||||
var today = moment(new Date()).startOf('day');
|
||||
|
||||
$(document).bind('keyup', 'left', function(){
|
||||
$(document).bind('keyup', function(event){
|
||||
switch (event.which) {
|
||||
// left arrow
|
||||
case 37:
|
||||
Router.go($('.prev-link').attr('href'));
|
||||
currentDate.subtract(1, 'day');
|
||||
break;
|
||||
// right arrow
|
||||
case 39:
|
||||
if(Users.is.admin(Meteor.user()) || today.diff(currentDate, 'days') > 0) {
|
||||
Router.go($('.next-link').attr('href'));
|
||||
currentDate.add(1, 'day');
|
||||
}
|
||||
break;
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$(document).bind('keyup', 'right', function(){
|
||||
if(Users.is.admin(Meteor.user()) || today.diff(currentDate, 'days') > 0)
|
||||
Router.go($('.next-link').attr('href'));
|
||||
});
|
||||
|
||||
Template.single_day_nav.onDestroyed(function(){
|
||||
|
||||
$(document).unbind('keyup'); //clean up to prevent errors on other pages
|
||||
|
||||
});
|
||||
|
||||
Template.single_day_nav.helpers({
|
||||
|
|
Loading…
Add table
Reference in a new issue