mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
e48b5edbb4
Closes #4032 - Created "mobile" views: `parent-view`, `content-view` and `index-view` - `mobile/parent-view` has three callbacks for managing layout, and a mediaQuery listener to keep in sync with the user - content-view and index-view use their parent-views callbacks to bring themselves into and out of the viewport as appropriate - fixed media queries for post content list from 800px to 900px - Created `mobile-index-route` to intelligently transition to a new route on desktops (used by both PostsIndexRoute and SettingsIndexRoute) - Extract mobile interactions from settings views to new mobile utility views - `js-` prefixed settings view transitions - removed unused openEditor action from PostsRoute - removed unused mobile util "responsiveAction"
73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
import styleBody from 'ghost/mixins/style-body';
|
|
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
import PaginationRouteMixin from 'ghost/mixins/pagination-route';
|
|
|
|
var paginationSettings = {
|
|
status: 'all',
|
|
staticPages: 'all',
|
|
page: 1
|
|
};
|
|
|
|
var PostsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, ShortcutsRoute, styleBody, loadingIndicator, PaginationRouteMixin, {
|
|
classNames: ['manage'],
|
|
|
|
model: function () {
|
|
var self = this;
|
|
|
|
return this.store.find('user', 'me').then(function (user) {
|
|
if (user.get('isAuthor')) {
|
|
paginationSettings.author = user.get('slug');
|
|
}
|
|
// using `.filter` allows the template to auto-update when new models are pulled in from the server.
|
|
// we just need to 'return true' to allow all models by default.
|
|
return self.store.filter('post', paginationSettings, function (post) {
|
|
if (user.get('isAuthor')) {
|
|
return post.isAuthoredByUser(user);
|
|
}
|
|
|
|
return true;
|
|
});
|
|
});
|
|
},
|
|
|
|
setupController: function (controller, model) {
|
|
this._super(controller, model);
|
|
this.setupPagination(paginationSettings);
|
|
},
|
|
|
|
stepThroughPosts: function (step) {
|
|
var currentPost = this.get('controller.currentPost'),
|
|
posts = this.get('controller.arrangedContent'),
|
|
length = posts.get('length'),
|
|
newPosition;
|
|
|
|
newPosition = posts.indexOf(currentPost) + step;
|
|
|
|
// if we are on the first or last item
|
|
// just do nothing (desired behavior is to not
|
|
// loop around)
|
|
if (newPosition >= length) {
|
|
return;
|
|
} else if (newPosition < 0) {
|
|
return;
|
|
}
|
|
this.transitionTo('posts.post', posts.objectAt(newPosition));
|
|
},
|
|
|
|
shortcuts: {
|
|
'up': 'moveUp',
|
|
'down': 'moveDown'
|
|
},
|
|
actions: {
|
|
moveUp: function () {
|
|
this.stepThroughPosts(-1);
|
|
},
|
|
moveDown: function () {
|
|
this.stepThroughPosts(1);
|
|
}
|
|
}
|
|
});
|
|
|
|
export default PostsRoute;
|