0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #3216 from novaugust/mobile-menu

Fix mobile sidebar menu
This commit is contained in:
Hannah Wolfe 2014-07-07 20:38:04 +01:00
commit 0febf71c97
4 changed files with 24 additions and 17 deletions

View file

@ -1,23 +1,10 @@
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
import mobileUtils from 'ghost/utils/mobile-utils';
var ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin, ShortcutsRoute, {
shortcuts: {
'esc': 'closePopups'
},
mobileInteractions: function () {
var responsiveAction = mobileUtils.responsiveAction;
Ember.run.scheduleOnce('afterRender', document, function () {
// ### Toggle the sidebar menu
$('[data-off-canvas]').on('click', function (event) {
responsiveAction(event, '(max-width: 650px)', function () {
$('body').toggleClass('off-canvas');
});
});
});
}.on('init'),
setupController: function () {
Ember.run.next(this, function () {

View file

@ -4,9 +4,9 @@
</a>
<nav id="global-nav" role="navigation">
<ul id="main-menu" >
{{gh-activating-list-item route="posts" title="Content" classNames="content"}}
{{gh-activating-list-item route="editor.new" title="New Post" classNames="editor"}}
{{gh-activating-list-item route="settings" title="Settings" classNames="settings"}}
{{gh-activating-list-item route="posts" title="Content" classNames="content js-close-sidebar"}}
{{gh-activating-list-item route="editor.new" title="New Post" classNames="editor js-close-sidebar"}}
{{gh-activating-list-item route="settings" title="Settings" classNames="settings js-close-sidebar"}}
<li id="usermenu" class="usermenu subnav">
{{#gh-popover-button popoverName="user-menu" tagName="a" href="#" classNames="dropdown"}}

View file

@ -39,7 +39,7 @@ responsiveAction = function responsiveAction(event, mediaCondition, cb) {
cb();
};
export { hasTouchScreen, smallScreen };
export { hasTouchScreen, smallScreen, responsiveAction };
export default {
hasTouchScreen: hasTouchScreen,
smallScreen: smallScreen,

View file

@ -0,0 +1,20 @@
import {responsiveAction} from 'ghost/utils/mobile-utils';
var ApplicationView = Ember.View.extend({
mobileInteractions: function () {
var body = $('body');
// ### Toggle the mobile sidebar menu
$('[data-off-canvas]').on('click', function (event) {
responsiveAction(event, '(max-width: 650px)', function () {
body.toggleClass('off-canvas');
});
});
// #### Navigating within the sidebar closes it.
$('.js-close-sidebar').on('click', function () {
body.removeClass('off-canvas');
});
}.on('didInsertElement')
});
export default ApplicationView;