0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/client/app/views/application.js

70 lines
2.4 KiB
JavaScript
Raw Normal View History

2015-02-12 21:22:32 -07:00
import Ember from 'ember';
import mobileQuery from 'ghost/utils/mobile';
var ApplicationView = Ember.View.extend({
2015-05-19 09:15:16 +01:00
classNames: 'gh-app',
didInsertElement: function () {
// #### Navigating within the sidebar closes it.
var self = this;
$('body').on('click tap', '.js-nav-item', function () {
Ember.run(function () {
if (mobileQuery.matches) {
self.set('controller.showGlobalMobileNav', false);
}
});
});
// #### Close the nav if mobile and clicking outside of the nav or not the burger toggle
$('.js-nav-cover').on('click tap', function () {
Ember.run(function () {
var isOpen = self.get('controller.showGlobalMobileNav');
if (isOpen) {
self.set('controller.showGlobalMobileNav', false);
}
});
});
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
$('.gh-nav').mouseenter(function () {
2015-05-20 16:37:06 +01:00
$('.gh-nav').addClass('open');
});
$('.gh-main').mouseenter(function () {
2015-05-20 16:37:06 +01:00
$('.gh-nav').removeClass('open');
});
mobileQuery.addListener(this.get('closeGlobalMobileNavOnDesktop'));
},
showGlobalMobileNavObserver: function () {
if (this.get('controller.showGlobalMobileNav')) {
$('body').addClass('global-nav-expanded');
} else {
$('body').removeClass('global-nav-expanded');
}
}.observes('controller.showGlobalMobileNav'),
willDestroyElement: function () {
mobileQuery.removeListener(this.get('closeGlobalMobileNavOnDesktop'));
mobileQuery.removeListener(this.get('swapUserMenuDropdownTriangleClasses'));
},
toggleSettingsMenuBodyClass: function () {
$('body').toggleClass('settings-menu-expanded', this.get('controller.showSettingsMenu'));
}.observes('controller.showSettingsMenu')
});
export default ApplicationView;