2014-07-13 12:03:48 -05:00
|
|
|
import {mobileQuery} from 'ghost/utils/mobile';
|
2014-07-25 02:52:17 -05:00
|
|
|
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
|
2014-03-20 21:55:32 -05:00
|
|
|
|
2014-07-25 02:52:17 -05:00
|
|
|
var SettingsIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, CurrentUserSettings, {
|
2014-07-13 12:03:48 -05:00
|
|
|
// redirect to general tab, unless on a mobile phone
|
|
|
|
beforeModel: function () {
|
2014-07-25 02:52:17 -05:00
|
|
|
var self = this;
|
|
|
|
this.currentUser()
|
|
|
|
.then(this.transitionAuthor())
|
|
|
|
.then(this.transitionEditor())
|
|
|
|
.then(function () {
|
|
|
|
if (!mobileQuery.matches) {
|
|
|
|
self.transitionTo('settings.general');
|
|
|
|
} else {
|
|
|
|
//fill the empty {{outlet}} in settings.hbs if the user
|
|
|
|
//goes to fullscreen
|
2014-07-13 12:03:48 -05:00
|
|
|
|
2014-07-25 02:52:17 -05:00
|
|
|
//fillOutlet needs special treatment so that it is
|
|
|
|
//properly bound to this when called from a MQ event
|
|
|
|
self.set('fillOutlet', _.bind(function fillOutlet(mq) {
|
|
|
|
if (!mq.matches) {
|
|
|
|
self.transitionTo('settings.general');
|
|
|
|
}
|
|
|
|
}, self));
|
|
|
|
mobileQuery.addListener(self.fillOutlet);
|
2014-07-13 12:03:48 -05:00
|
|
|
}
|
2014-07-25 02:52:17 -05:00
|
|
|
});
|
2014-07-13 12:03:48 -05:00
|
|
|
},
|
2014-07-25 02:52:17 -05:00
|
|
|
|
2014-07-13 12:03:48 -05:00
|
|
|
deactivate: function () {
|
|
|
|
if (this.get('fillOutlet')) {
|
|
|
|
mobileQuery.removeListener(this.fillOutlet);
|
|
|
|
}
|
2014-03-09 22:44:08 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-19 21:29:49 -05:00
|
|
|
export default SettingsIndexRoute;
|