0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Merge pull request #4285 from novaugust/read-draft-shortcuts

Go between post list / post content with keyboard
This commit is contained in:
Hannah Wolfe 2014-10-28 13:02:17 +02:00
commit 1c7450bd04
5 changed files with 64 additions and 5 deletions

View file

@ -57,3 +57,17 @@
animation: fade-out 0.5s; animation: fade-out 0.5s;
animation-fill-mode: forwards; animation-fill-mode: forwards;
} }
//
// Fade out inset box shadow for content page keyboard focus
// --------------------------------------------------
@keyframes keyboard-focus-style-fade-out {
from {
box-shadow: inset 0 0 30px 1px lighten($midgrey, 20%);
}
to {
box-shadow: none;
}
}

View file

@ -63,6 +63,21 @@
} }
} }
&.keyboard-focused {
// This has to be a pseudo element to sit over the top of everything else in the content list
&:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 500;
pointer-events: none;
animation: keyboard-focus-style-fade-out 1.5s 1 forwards;
}
}
.btn-green { .btn-green {
@include icon($i-add); @include icon($i-add);
position: absolute; position: absolute;
@ -203,6 +218,10 @@
overflow: visible; overflow: visible;
} }
&.keyboard-focused {
animation: keyboard-focus-style-fade-out 1.5s 1 forwards;
}
.unfeatured { .unfeatured {
@include icon($i-unfeatured, 14px); @include icon($i-unfeatured, 14px);
vertical-align: -6%; vertical-align: -6%;

View file

@ -20,6 +20,9 @@ function publishedAtCompare(item1, item2) {
} }
var PostsController = Ember.ArrayController.extend(PaginationControllerMixin, { var PostsController = Ember.ArrayController.extend(PaginationControllerMixin, {
// See PostsRoute's shortcuts
postListFocused: Ember.computed.equal('keyboardFocus', 'postList'),
postContentFocused: Ember.computed.equal('keyboardFocus', 'postContent'),
// this will cause the list to re-sort when any of these properties change on any of the models // this will cause the list to re-sort when any of these properties change on any of the models
sortProperties: ['status', 'published_at', 'updated_at'], sortProperties: ['status', 'published_at', 'updated_at'],

View file

@ -60,25 +60,48 @@ PostsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, ShortcutsRou
this.transitionTo('posts.post', posts.objectAt(newPosition)); this.transitionTo('posts.post', posts.objectAt(newPosition));
}, },
scrollContent: function (amount) {
var content = Ember.$('.js-content-preview'),
scrolled = content.scrollTop();
content.scrollTop(scrolled + 50 * amount);
},
shortcuts: { shortcuts: {
'up, k': 'moveUp', 'up, k': 'moveUp',
'down, j': 'moveDown', 'down, j': 'moveDown',
left: 'focusList',
right: 'focusContent',
c: 'newPost' c: 'newPost'
}, },
actions: { actions: {
focusList: function () {
this.controller.set('keyboardFocus', 'postList');
},
focusContent: function () {
this.controller.set('keyboardFocus', 'postContent');
},
newPost: function () { newPost: function () {
this.transitionTo('editor.new'); this.transitionTo('editor.new');
}, },
moveUp: function () { moveUp: function () {
if (this.controller.get('postContentFocused')) {
this.scrollContent(-1);
} else {
this.stepThroughPosts(-1); this.stepThroughPosts(-1);
}
}, },
moveDown: function () { moveDown: function () {
if (this.controller.get('postContentFocused')) {
this.scrollContent(1);
} else {
this.stepThroughPosts(1); this.stepThroughPosts(1);
} }
} }
}
}); });
export default PostsRoute; export default PostsRoute;

View file

@ -4,7 +4,7 @@
</header> </header>
<div class="page-content"> <div class="page-content">
<section class="content-list js-content-list"> <section {{bind-attr class=":content-list :js-content-list postListFocused:keyboard-focused"}}>
<header class="floatingheader"> <header class="floatingheader">
<section class="content-filter"> <section class="content-filter">
<small>All Posts</small> <small>All Posts</small>
@ -36,7 +36,7 @@
</ol> </ol>
{{/view}} {{/view}}
</section> </section>
<section class="content-preview js-content-preview"> <section {{bind-attr class=":content-preview :js-content-preview postContentFocused:keyboard-focused"}}>
{{outlet}} {{outlet}}
</section> </section>
</div> </div>