diff --git a/core/client/routes/posts.js b/core/client/routes/posts.js index 877f1adf80..9df1982cbd 100644 --- a/core/client/routes/posts.js +++ b/core/client/routes/posts.js @@ -24,7 +24,25 @@ var PostsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, Shortcut this._super(controller, model); this.setupPagination(paginationSettings); }, - + + stepThroughPosts: function (step) { + var currentPost = this.get('controller.currentPost'), + posts = this.get('controller.model'), + length = posts.get('length'), + newPosition; + + newPosition = posts.indexOf(currentPost) + step; + + //Make sure we're inbounds + if (newPosition >= length) { + newPosition = 0; + } + else if (newPosition < 0) { + newPosition = length - 1; + } + this.transitionTo('posts.post', posts.objectAt(newPosition)); + }, + shortcuts: { 'up': 'moveUp', 'down': 'moveDown' @@ -34,10 +52,10 @@ var PostsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, Shortcut this.transitionTo('editor.edit', post); }, moveUp: function () { - window.alert('@todo keyboard post navigation: up'); + this.stepThroughPosts(-1); }, moveDown: function () { - window.alert('@todo keyboard post navigation: down'); + this.stepThroughPosts(1); } } }); diff --git a/core/client/routes/posts/post.js b/core/client/routes/posts/post.js index 99738b26fb..87a7cd4764 100644 --- a/core/client/routes/posts/post.js +++ b/core/client/routes/posts/post.js @@ -34,6 +34,12 @@ var PostsPostRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, load return self.transitionTo('posts.index'); }); }, + setupController: function (controller, model) { + this._super(controller, model); + + this.controllerFor('posts').set('currentPost', model); + }, + shortcuts: { 'enter': 'openEditor' },