2014-09-16 08:55:37 +04:00
|
|
|
import mobileQuery from 'ghost/utils/mobile';
|
2014-09-01 20:45:06 +04:00
|
|
|
|
2014-07-07 18:55:22 +04:00
|
|
|
var ApplicationView = Ember.View.extend({
|
2014-09-15 04:40:24 +04:00
|
|
|
elementId: 'container',
|
|
|
|
|
2014-08-11 19:51:06 +04:00
|
|
|
blogRoot: Ember.computed.alias('controller.ghostPaths.blogRoot'),
|
2014-09-01 20:45:06 +04:00
|
|
|
|
|
|
|
setupGlobalMobileNav: function () {
|
2014-07-07 18:55:22 +04:00
|
|
|
// #### Navigating within the sidebar closes it.
|
2014-09-01 20:45:06 +04:00
|
|
|
var self = this;
|
|
|
|
$('body').on('click', '.js-nav-item', function () {
|
|
|
|
if (mobileQuery.matches) {
|
|
|
|
self.set('controller.showGlobalMobileNav', false);
|
|
|
|
}
|
2014-07-07 18:55:22 +04:00
|
|
|
});
|
2014-09-01 20:45:06 +04:00
|
|
|
|
|
|
|
// #### Close the nav if mobile and clicking outside of the nav or not the burger toggle
|
|
|
|
$('.js-nav-cover').on('click', function () {
|
|
|
|
var isOpen = self.get('controller.showGlobalMobileNav');
|
|
|
|
if (isOpen) {
|
|
|
|
self.set('controller.showGlobalMobileNav', false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// #### Listen to the viewport and change user-menu dropdown triangle classes accordingly
|
|
|
|
mobileQuery.addListener(this.swapUserMenuPopoverTriangleClasses);
|
|
|
|
this.swapUserMenuPopoverTriangleClasses(mobileQuery);
|
|
|
|
|
2014-08-11 00:50:25 +04:00
|
|
|
}.on('didInsertElement'),
|
2014-09-01 20:45:06 +04:00
|
|
|
|
|
|
|
swapUserMenuPopoverTriangleClasses: function (mq) {
|
|
|
|
if (mq.matches) {
|
|
|
|
$('.js-user-menu-dropdown-menu').removeClass('dropdown-triangle-top-right ').addClass('dropdown-triangle-bottom');
|
|
|
|
} else {
|
|
|
|
$('.js-user-menu-dropdown-menu').removeClass('dropdown-triangle-bottom').addClass('dropdown-triangle-top-right');
|
|
|
|
}
|
|
|
|
},
|
2014-09-16 08:55:37 +04:00
|
|
|
|
2014-09-01 20:45:06 +04:00
|
|
|
showGlobalMobileNavObserver: function () {
|
|
|
|
if (this.get('controller.showGlobalMobileNav')) {
|
|
|
|
$('body').addClass('global-nav-expanded');
|
|
|
|
} else {
|
|
|
|
$('body').removeClass('global-nav-expanded');
|
2014-08-11 00:50:25 +04:00
|
|
|
}
|
2014-09-01 20:45:06 +04:00
|
|
|
}.observes('controller.showGlobalMobileNav'),
|
|
|
|
|
|
|
|
setupCloseNavOnDesktop: function () {
|
|
|
|
this.set('closeGlobalMobileNavOnDesktop', _.bind(function closeGlobalMobileNavOnDesktop(mq) {
|
|
|
|
if (!mq.matches) {
|
|
|
|
// Is desktop sized
|
|
|
|
this.set('controller.showGlobalMobileNav', false);
|
|
|
|
}
|
|
|
|
}, this));
|
|
|
|
mobileQuery.addListener(this.closeGlobalMobileNavOnDesktop);
|
|
|
|
}.on('didInsertElement'),
|
|
|
|
|
|
|
|
removeCloseNavOnDesktop: function () {
|
|
|
|
mobileQuery.removeListener(this.closeGlobalMobileNavOnDesktop);
|
|
|
|
}.on('willDestroyElement'),
|
|
|
|
|
2014-09-15 04:40:24 +04:00
|
|
|
|
|
|
|
toggleRightOutletBodyClass: function () {
|
|
|
|
$('body').toggleClass('right-outlet-expanded', this.get('controller.showRightOutlet'));
|
|
|
|
}.observes('controller.showRightOutlet')
|
2014-07-07 18:55:22 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default ApplicationView;
|