mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
09fb17a2be
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"
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import MobileIndexRoute from 'ghost/routes/mobile-index-route';
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
import mobileQuery from 'ghost/utils/mobile';
|
|
|
|
var PostsIndexRoute = MobileIndexRoute.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
|
|
// Transition to a specific post if we're not on mobile
|
|
beforeModel: function () {
|
|
if (!mobileQuery.matches) {
|
|
return this.goToPost();
|
|
}
|
|
},
|
|
|
|
goToPost: function () {
|
|
var self = this,
|
|
// the store has been populated by PostsRoute
|
|
posts = this.store.all('post'),
|
|
post;
|
|
return this.store.find('user', 'me').then(function (user) {
|
|
post = posts.find(function (post) {
|
|
// Authors can only see posts they've written
|
|
if (user.get('isAuthor')) {
|
|
return post.isAuthoredByUser(user);
|
|
}
|
|
return true;
|
|
});
|
|
if (post) {
|
|
return self.transitionTo('posts.post', post);
|
|
}
|
|
self.get('controller').set('noPosts', true);
|
|
});
|
|
},
|
|
|
|
//Mobile posts route callback
|
|
desktopTransition: function () {
|
|
this.goToPost();
|
|
}
|
|
});
|
|
|
|
export default PostsIndexRoute;
|