diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index 0e197733ea4..728f0ff5557 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -143,7 +143,8 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { bootbox.animate(false); bootbox.backdrop(true); // clicking outside a bootbox modal closes it - Discourse.Session.currentProp('mobile', $html.hasClass('mobile')) + Discourse.Session.currentProp('mobileDevice', $html.hasClass('mobile-device')); + Discourse.Session.currentProp('mobileView', $html.hasClass('mobile-view')); setInterval(function(){ Discourse.Formatter.updateRelativeAge($('.relative-date')); diff --git a/app/assets/javascripts/discourse/controllers/header_controller.js b/app/assets/javascripts/discourse/controllers/header_controller.js index d06849dd3f2..790a299ad83 100644 --- a/app/assets/javascripts/discourse/controllers/header_controller.js +++ b/app/assets/javascripts/discourse/controllers/header_controller.js @@ -22,7 +22,19 @@ Discourse.HeaderController = Discourse.Controller.extend({ showFavoriteButton: function() { return Discourse.User.current() && !this.get('topic.isPrivateMessage'); - }.property('topic.isPrivateMessage') + }.property('topic.isPrivateMessage'), + + mobileDevice: function() { + return Discourse.Session.currentProp('mobileDevice'); + }.property(), + + mobileView: function() { + return Discourse.Session.currentProp('mobileView'); + }.property(), + + toggleMobileView: function() { + window.location.assign(window.location.pathname + '?mobile_view=' + (Discourse.Session.currentProp('mobileView') ? '0' : '1')); + } }); diff --git a/app/assets/javascripts/discourse/ember/resolver.js b/app/assets/javascripts/discourse/ember/resolver.js index 25d5a98737c..00a09238b41 100644 --- a/app/assets/javascripts/discourse/ember/resolver.js +++ b/app/assets/javascripts/discourse/ember/resolver.js @@ -16,7 +16,7 @@ Discourse.Resolver = Ember.DefaultResolver.extend({ @returns {Template} the template (if found) **/ resolveTemplate: function(parsedName) { - if (Discourse.Session.currentProp('mobile')) { + if (Discourse.Session.currentProp('mobileView')) { var mobileParsedName = this.parseName(parsedName.fullName.replace("template:", "template:mobile/")); var mobileTemplate = this.findTemplate(mobileParsedName); if (mobileTemplate) return mobileTemplate; diff --git a/app/assets/javascripts/discourse/templates/header.js.handlebars b/app/assets/javascripts/discourse/templates/header.js.handlebars index 7349a442a93..b73f1bf83d7 100644 --- a/app/assets/javascripts/discourse/templates/header.js.handlebars +++ b/app/assets/javascripts/discourse/templates/header.js.handlebars @@ -123,6 +123,17 @@ {{#titledLinkTo "list.latest" titleKey="filters.latest.help"}}{{i18n filters.latest.title}}{{/titledLinkTo}}