2014-07-13 21:03:48 +04:00
|
|
|
import {mobileQuery} from 'ghost/utils/mobile';
|
2014-07-25 11:52:17 +04:00
|
|
|
import CurrentUserSettings from 'ghost/mixins/current-user-settings';
|
2014-03-21 06:55:32 +04:00
|
|
|
|
2014-07-25 11:52:17 +04:00
|
|
|
var SettingsIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, CurrentUserSettings, {
|
2014-07-13 21:03:48 +04:00
|
|
|
// redirect to general tab, unless on a mobile phone
|
|
|
|
beforeModel: function () {
|
2014-07-25 11:52:17 +04: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 21:03:48 +04:00
|
|
|
|
2014-07-25 11:52:17 +04: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 21:03:48 +04:00
|
|
|
}
|
2014-07-25 11:52:17 +04:00
|
|
|
});
|
2014-07-13 21:03:48 +04:00
|
|
|
},
|
2014-07-25 11:52:17 +04:00
|
|
|
|
2014-07-13 21:03:48 +04:00
|
|
|
deactivate: function () {
|
|
|
|
if (this.get('fillOutlet')) {
|
|
|
|
mobileQuery.removeListener(this.fillOutlet);
|
|
|
|
}
|
2014-03-10 07:44:08 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-20 06:29:49 +04:00
|
|
|
export default SettingsIndexRoute;
|