Ghost/ghost/admin/app/controllers/application.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

import Controller from 'ember-controller';
import computed from 'ember-computed';
import injectService from 'ember-service/inject';
export default Controller.extend({
dropdown: injectService(),
session: injectService(),
settings: injectService(),
showNavMenu: computed('currentPath', 'session.isAuthenticated', 'session.user.isFulfilled', function () {
// we need to defer showing the navigation menu until the session.user
// promise has fulfilled so that gh-user-can-admin has the correct data
if (!this.get('session.isAuthenticated') || !this.get('session.user.isFulfilled')) {
return false;
}
return (this.get('currentPath') !== 'error404' || this.get('session.isAuthenticated'))
&& !this.get('currentPath').match(/(signin|signup|setup|reset)/);
}),
topNotificationCount: 0,
showMobileMenu: false,
showSettingsMenu: false,
showMarkdownHelpModal: false,
2015-05-24 08:47:23 +03:00
autoNav: false,
autoNavOpen: computed('autoNav', {
get() {
return false;
},
set(key, value) {
if (this.get('autoNav')) {
return value;
}
return false;
}
}),
actions: {
topNotificationChange(count) {
this.set('topNotificationCount', count);
2015-05-24 08:47:23 +03:00
},
toggleAutoNav() {
this.toggleProperty('autoNav');
},
openAutoNav() {
this.set('autoNavOpen', true);
2015-05-24 08:47:23 +03:00
},
closeAutoNav() {
if (this.get('autoNavOpen')) {
this.get('dropdown').closeDropdowns();
}
this.set('autoNavOpen', false);
},
closeMobileMenu() {
this.set('showMobileMenu', false);
}
}
});