2015-02-12 21:22:32 -07:00
|
|
|
import Ember from 'ember';
|
2014-09-15 22:55:37 -06:00
|
|
|
import mobileQuery from 'ghost/utils/mobile';
|
2014-09-01 17:45:06 +01:00
|
|
|
|
2014-07-07 08:55:22 -06:00
|
|
|
var ApplicationView = Ember.View.extend({
|
2015-05-19 09:15:16 +01:00
|
|
|
classNames: 'gh-app',
|
2014-09-14 18:40:24 -06:00
|
|
|
|
2015-02-18 17:11:02 +00:00
|
|
|
didInsertElement: function () {
|
2014-07-07 08:55:22 -06:00
|
|
|
// #### Navigating within the sidebar closes it.
|
2014-09-01 17:45:06 +01:00
|
|
|
var self = this;
|
2015-02-18 17:11:02 +00:00
|
|
|
|
2014-09-25 16:33:47 +00:00
|
|
|
$('body').on('click tap', '.js-nav-item', function () {
|
2015-02-18 17:11:02 +00:00
|
|
|
Ember.run(function () {
|
|
|
|
if (mobileQuery.matches) {
|
|
|
|
self.set('controller.showGlobalMobileNav', false);
|
|
|
|
}
|
|
|
|
});
|
2014-07-07 08:55:22 -06:00
|
|
|
});
|
2014-09-01 17:45:06 +01:00
|
|
|
|
|
|
|
// #### Close the nav if mobile and clicking outside of the nav or not the burger toggle
|
2014-09-25 16:33:47 +00:00
|
|
|
$('.js-nav-cover').on('click tap', function () {
|
2015-02-18 17:11:02 +00:00
|
|
|
Ember.run(function () {
|
|
|
|
var isOpen = self.get('controller.showGlobalMobileNav');
|
|
|
|
|
|
|
|
if (isOpen) {
|
|
|
|
self.set('controller.showGlobalMobileNav', false);
|
|
|
|
}
|
|
|
|
});
|
2014-09-01 17:45:06 +01:00
|
|
|
});
|
|
|
|
|
2015-05-20 16:37:06 +01:00
|
|
|
// TODO: ABOVE - All of this can be removed
|
|
|
|
// TODO: BELOW - John wrote this, reimplement in a not-shit way
|
|
|
|
|
|
|
|
// #### Toggle nav between fixed and auto
|
|
|
|
$('.gh-autonav-toggle').on('click tap', function () {
|
|
|
|
$('.gh-viewport').toggleClass('gh-autonav');
|
|
|
|
$('.gh-autonav-toggle i').toggleClass('icon-minimise').toggleClass('icon-maximise');
|
|
|
|
$('.gh-nav').removeClass('open');
|
|
|
|
});
|
|
|
|
|
|
|
|
// #### Open and close the nav on hover
|
2015-05-22 09:38:46 +01:00
|
|
|
$('.gh-nav').mouseenter(function () {
|
2015-05-20 16:37:06 +01:00
|
|
|
$('.gh-nav').addClass('open');
|
|
|
|
});
|
2015-05-22 09:38:46 +01:00
|
|
|
$('.gh-main').mouseenter(function () {
|
2015-05-20 16:37:06 +01:00
|
|
|
$('.gh-nav').removeClass('open');
|
|
|
|
});
|
|
|
|
|
2015-02-18 17:11:02 +00:00
|
|
|
mobileQuery.addListener(this.get('closeGlobalMobileNavOnDesktop'));
|
2014-09-01 17:45:06 +01:00
|
|
|
},
|
2014-09-15 22:55:37 -06:00
|
|
|
|
2014-09-01 17:45:06 +01:00
|
|
|
showGlobalMobileNavObserver: function () {
|
|
|
|
if (this.get('controller.showGlobalMobileNav')) {
|
|
|
|
$('body').addClass('global-nav-expanded');
|
|
|
|
} else {
|
|
|
|
$('body').removeClass('global-nav-expanded');
|
2014-08-10 14:50:25 -06:00
|
|
|
}
|
2014-09-01 17:45:06 +01:00
|
|
|
}.observes('controller.showGlobalMobileNav'),
|
|
|
|
|
2015-02-18 17:11:02 +00:00
|
|
|
willDestroyElement: function () {
|
|
|
|
mobileQuery.removeListener(this.get('closeGlobalMobileNavOnDesktop'));
|
|
|
|
mobileQuery.removeListener(this.get('swapUserMenuDropdownTriangleClasses'));
|
|
|
|
},
|
2014-09-01 17:45:06 +01:00
|
|
|
|
2014-10-13 16:23:06 +01:00
|
|
|
toggleSettingsMenuBodyClass: function () {
|
|
|
|
$('body').toggleClass('settings-menu-expanded', this.get('controller.showSettingsMenu'));
|
|
|
|
}.observes('controller.showSettingsMenu')
|
2014-07-07 08:55:22 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
export default ApplicationView;
|