2016-07-06 22:47:30 +03:00
|
|
|
import Controller from 'ember-controller';
|
|
|
|
import computed from 'ember-computed';
|
|
|
|
import injectService from 'ember-service/inject';
|
2015-05-26 05:10:50 +03:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
export default Controller.extend({
|
2016-07-06 22:47:30 +03:00
|
|
|
dropdown: injectService(),
|
|
|
|
session: injectService(),
|
2017-04-19 19:57:56 +03:00
|
|
|
settings: injectService(),
|
2015-10-28 14:36:45 +03:00
|
|
|
|
2017-02-01 22:19:42 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-11-14 16:16:51 +03:00
|
|
|
return (this.get('currentPath') !== 'error404' || this.get('session.isAuthenticated'))
|
|
|
|
&& !this.get('currentPath').match(/(signin|signup|setup|reset)/);
|
2016-05-14 04:02:55 +03:00
|
|
|
}),
|
2014-05-15 03:36:13 +04:00
|
|
|
|
2014-07-17 21:28:53 +04:00
|
|
|
topNotificationCount: 0,
|
2015-05-27 17:39:56 +03:00
|
|
|
showMobileMenu: false,
|
2014-10-13 19:23:06 +04:00
|
|
|
showSettingsMenu: false,
|
2015-11-18 13:50:48 +03:00
|
|
|
showMarkdownHelpModal: false,
|
2014-07-17 21:28:53 +04:00
|
|
|
|
2015-05-24 08:47:23 +03:00
|
|
|
autoNav: false,
|
2015-10-28 14:36:45 +03:00
|
|
|
autoNavOpen: computed('autoNav', {
|
|
|
|
get() {
|
2015-05-27 17:39:56 +03:00
|
|
|
return false;
|
|
|
|
},
|
2015-10-28 14:36:45 +03:00
|
|
|
set(key, value) {
|
2015-05-27 17:39:56 +03:00
|
|
|
if (this.get('autoNav')) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}),
|
2014-10-21 20:02:11 +04:00
|
|
|
|
2014-04-07 02:11:22 +04:00
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
topNotificationChange(count) {
|
2014-07-17 21:28:53 +04:00
|
|
|
this.set('topNotificationCount', count);
|
2015-05-24 08:47:23 +03:00
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
toggleAutoNav() {
|
2015-05-27 17:39:56 +03:00
|
|
|
this.toggleProperty('autoNav');
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
openAutoNav() {
|
2015-05-27 17:39:56 +03:00
|
|
|
this.set('autoNavOpen', true);
|
2015-05-24 08:47:23 +03:00
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
closeAutoNav() {
|
2017-04-05 17:26:01 +03:00
|
|
|
if (this.get('autoNavOpen')) {
|
|
|
|
this.get('dropdown').closeDropdowns();
|
|
|
|
}
|
2015-05-27 17:39:56 +03:00
|
|
|
this.set('autoNavOpen', false);
|
2015-06-09 19:25:45 +03:00
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
closeMobileMenu() {
|
2015-06-09 19:25:45 +03:00
|
|
|
this.set('showMobileMenu', false);
|
2014-04-07 02:11:22 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-11 20:23:32 +04:00
|
|
|
});
|