From 32cea9d8cc2a2c612a5f7c81730acc335eb4d09c Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 28 Jul 2014 11:48:38 +1000 Subject: [PATCH] Feature: Show keyboard shortcuts link on desktop hamburger (only shows up for desktop, hides "mobile view") If you really need mobile view add ?mobile_view=1 to end of URL (also fixed) --- .../javascripts/discourse/controllers/site-map.js.es6 | 11 ++++++++++- app/assets/javascripts/discourse/lib/mobile.js | 8 +++++++- .../discourse/templates/site_map.js.handlebars | 3 +++ config/locales/client.en.yml | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/site-map.js.es6 b/app/assets/javascripts/discourse/controllers/site-map.js.es6 index 5f5c97111..9e96862d1 100644 --- a/app/assets/javascripts/discourse/controllers/site-map.js.es6 +++ b/app/assets/javascripts/discourse/controllers/site-map.js.es6 @@ -11,7 +11,13 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, { badgesUrl: Discourse.getURL('/badges'), - showMobileToggle: Discourse.computed.setting('enable_mobile_theme'), + showKeyboardShortcuts: function(){ + return !Discourse.Mobile.mobileView && !Discourse.Mobile.isMobileDevice; + }.property(), + + showMobileToggle: function(){ + return Discourse.SiteSettings.enable_mobile_theme && Discourse.Mobile.isMobileDevice; + }.property(), mobileViewLinkTextKey: function() { return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view"; @@ -29,6 +35,9 @@ export default Ember.ArrayController.extend(Discourse.HasCurrentUser, { }.property(), actions: { + keyboardShortcuts: function(){ + Discourse.__container__.lookup('controller:application').send('showKeyboardShortcutsHelp'); + }, toggleMobileView: function() { Discourse.Mobile.toggleMobileView(); } diff --git a/app/assets/javascripts/discourse/lib/mobile.js b/app/assets/javascripts/discourse/lib/mobile.js index 4ad2c5b82..cb51b5888 100644 --- a/app/assets/javascripts/discourse/lib/mobile.js +++ b/app/assets/javascripts/discourse/lib/mobile.js @@ -14,7 +14,13 @@ Discourse.Mobile = { this.mobileView = $html.hasClass('mobile-view'); try{ - if (localStorage && localStorage.mobileView) { + if (window.location.search.test(/mobile_view=1/)){ + localStorage.mobileView = true; + } + if (window.location.search.test(/mobile_view=0/)){ + localStorage.mobileView = false; + } + if (localStorage.mobileView) { var savedValue = (localStorage.mobileView === 'true'); if (savedValue !== this.mobileView) { this.reloadPage(savedValue); diff --git a/app/assets/javascripts/discourse/templates/site_map.js.handlebars b/app/assets/javascripts/discourse/templates/site_map.js.handlebars index 4c91b7e47..99c5f0be7 100644 --- a/app/assets/javascripts/discourse/templates/site_map.js.handlebars +++ b/app/assets/javascripts/discourse/templates/site_map.js.handlebars @@ -8,6 +8,9 @@ {{#if showBadgesLink}}
  • {{partial "siteMap/badges"}}
  • {{/if}} + {{#if showKeyboardShortcuts}} +
  • {{i18n keyboard_shortcuts_help.title}} + {{/if}}
  • {{partial "siteMap/faqLink"}}
  • {{#if showMobileToggle}}
  • {{partial "siteMap/mobileToggleLink"}}
  • diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 4907c6e4e..0d351cba8 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1926,7 +1926,7 @@ en: download: "download" keyboard_shortcuts_help: - title: 'Keyboard Shortcuts (experimental)' + title: 'Keyboard Shortcuts' jump_to: title: 'Jump To' home: 'g then h Home (Latest)'