diff --git a/app/assets/javascripts/discourse/components/bread-crumbs.js.es6 b/app/assets/javascripts/discourse/components/bread-crumbs.js.es6 index 66fcd65a378..c1cdb1f55a7 100644 --- a/app/assets/javascripts/discourse/components/bread-crumbs.js.es6 +++ b/app/assets/javascripts/discourse/components/bread-crumbs.js.es6 @@ -12,8 +12,8 @@ export default Ember.Component.extend({ return !c.get('parentCategory'); }), - hidden: function(){ - return Discourse.Mobile.mobileView && !this.get('category'); + hidden: function() { + return this.site.mobileView && !this.get('category'); }.property('category'), firstCategory: function() { diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6 index ff6193afa0b..816a7e37ded 100644 --- a/app/assets/javascripts/discourse/components/composer-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6 @@ -18,7 +18,7 @@ export default Ember.Component.extend({ @on('init') _setupPreview() { - const val = (Discourse.Mobile.mobileView ? false : (this.keyValueStore.get('composer.showPreview') || 'true')); + const val = (this.site.mobileView ? false : (this.keyValueStore.get('composer.showPreview') || 'true')); this.set('showPreview', val === 'true'); }, @@ -218,7 +218,7 @@ export default Ember.Component.extend({ } }); - if (Discourse.Mobile.mobileView) { + if (this.site.mobileView) { this.$(".mobile-file-upload").on("click.uploader", function () { // redirect the click on the hidden file input $("#mobile-uploader").click(); diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index e81f14c212a..767abc8707e 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -25,153 +25,156 @@ const OP = { const _createCallbacks = []; -function Toolbar() { - this.shortcuts = {}; +class Toolbar { - this.groups = [ - {group: 'fontStyles', buttons: []}, - {group: 'insertions', buttons: []}, - {group: 'extras', buttons: []} - ]; + constructor(site) { + this.shortcuts = {}; - this.addButton({ - id: 'bold', - group: 'fontStyles', - shortcut: 'B', - perform: e => e.applySurround('**', '**', 'bold_text') - }); - - this.addButton({ - id: 'italic', - group: 'fontStyles', - shortcut: 'I', - perform: e => e.applySurround('_', '_', 'italic_text') - }); - - this.addButton({id: 'link', group: 'insertions', shortcut: 'K', action: 'showLinkModal'}); - - this.addButton({ - id: 'quote', - group: 'insertions', - icon: 'quote-right', - shortcut: 'Shift+9', - perform: e => e.applySurround('> ', '', 'code_text') - }); - - this.addButton({ - id: 'code', - group: 'insertions', - shortcut: 'Shift+C', - perform(e) { - if (e.selected.value.indexOf("\n") !== -1) { - e.applySurround(' ', '', 'code_text'); - } else { - e.applySurround('`', '`', 'code_text'); - } - }, - }); - - this.addButton({ - id: 'bullet', - group: 'extras', - icon: 'list-ul', - shortcut: 'Shift+8', - title: 'composer.ulist_title', - perform: e => e.applyList('* ', 'list_item') - }); - - this.addButton({ - id: 'list', - group: 'extras', - icon: 'list-ol', - shortcut: 'Shift+7', - title: 'composer.olist_title', - perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item') - }); - - this.addButton({ - id: 'heading', - group: 'extras', - icon: 'font', - shortcut: 'Alt+1', - perform: e => e.applyList('## ', 'heading_text') - }); - - this.addButton({ - id: 'rule', - group: 'extras', - icon: 'minus', - shortcut: 'Alt+R', - title: 'composer.hr_title', - perform: e => e.addText("\n\n----------\n") - }); - - if (Discourse.Mobile.mobileView) { - this.groups.push({group: 'mobileExtras', buttons: []}); + this.groups = [ + {group: 'fontStyles', buttons: []}, + {group: 'insertions', buttons: []}, + {group: 'extras', buttons: []} + ]; this.addButton({ - id: 'preview', - group: 'mobileExtras', - icon: 'television', - title: 'composer.hr_preview', - perform: e => e.preview() + id: 'bold', + group: 'fontStyles', + shortcut: 'B', + perform: e => e.applySurround('**', '**', 'bold_text') }); - } - this.groups[this.groups.length-1].lastGroup = true; -}; + this.addButton({ + id: 'italic', + group: 'fontStyles', + shortcut: 'I', + perform: e => e.applySurround('_', '_', 'italic_text') + }); -Toolbar.prototype.addButton = function(button) { - const g = this.groups.findProperty('group', button.group); - if (!g) { - throw `Couldn't find toolbar group ${button.group}`; - } + this.addButton({id: 'link', group: 'insertions', shortcut: 'K', action: 'showLinkModal'}); - const createdButton = { - id: button.id, - className: button.className || button.id, - icon: button.icon || button.id, - action: button.action || 'toolbarButton', - perform: button.perform || Ember.K - }; + this.addButton({ + id: 'quote', + group: 'insertions', + icon: 'quote-right', + shortcut: 'Shift+9', + perform: e => e.applySurround('> ', '', 'code_text') + }); - if (button.sendAction) { - createdButton.sendAction = button.sendAction; - } + this.addButton({ + id: 'code', + group: 'insertions', + shortcut: 'Shift+C', + perform(e) { + if (e.selected.value.indexOf("\n") !== -1) { + e.applySurround(' ', '', 'code_text'); + } else { + e.applySurround('`', '`', 'code_text'); + } + }, + }); - const title = I18n.t(button.title || `composer.${button.id}_title`); - if (button.shortcut) { - const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform); - const mod = mac ? 'Meta' : 'Ctrl'; - var shortcutTitle = `${mod}+${button.shortcut}`; + this.addButton({ + id: 'bullet', + group: 'extras', + icon: 'list-ul', + shortcut: 'Shift+8', + title: 'composer.ulist_title', + perform: e => e.applyList('* ', 'list_item') + }); - // Mac users are used to glyphs for shortcut keys - if (mac) { - shortcutTitle = shortcutTitle - .replace('Shift', "\u21E7") - .replace('Meta', "\u2318") - .replace('Alt', "\u2325") - .replace(/\+/g, ''); - } else { - shortcutTitle = shortcutTitle - .replace('Shift', I18n.t('shortcut_modifier_key.shift')) - .replace('Ctrl', I18n.t('shortcut_modifier_key.ctrl')) - .replace('Alt', I18n.t('shortcut_modifier_key.alt')); + this.addButton({ + id: 'list', + group: 'extras', + icon: 'list-ol', + shortcut: 'Shift+7', + title: 'composer.olist_title', + perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item') + }); + + this.addButton({ + id: 'heading', + group: 'extras', + icon: 'font', + shortcut: 'Alt+1', + perform: e => e.applyList('## ', 'heading_text') + }); + + this.addButton({ + id: 'rule', + group: 'extras', + icon: 'minus', + shortcut: 'Alt+R', + title: 'composer.hr_title', + perform: e => e.addText("\n\n----------\n") + }); + + if (site.mobileView) { + this.groups.push({group: 'mobileExtras', buttons: []}); + + this.addButton({ + id: 'preview', + group: 'mobileExtras', + icon: 'television', + title: 'composer.hr_preview', + perform: e => e.preview() + }); } - createdButton.title = `${title} (${shortcutTitle})`; - - this.shortcuts[`${mod}+${button.shortcut}`.toLowerCase()] = createdButton; - } else { - createdButton.title = title; + this.groups[this.groups.length-1].lastGroup = true; } - if (button.unshift) { - g.buttons.unshift(createdButton); - } else { - g.buttons.push(createdButton); + addButton(button) { + const g = this.groups.findProperty('group', button.group); + if (!g) { + throw `Couldn't find toolbar group ${button.group}`; + } + + const createdButton = { + id: button.id, + className: button.className || button.id, + icon: button.icon || button.id, + action: button.action || 'toolbarButton', + perform: button.perform || Ember.K + }; + + if (button.sendAction) { + createdButton.sendAction = button.sendAction; + } + + const title = I18n.t(button.title || `composer.${button.id}_title`); + if (button.shortcut) { + const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform); + const mod = mac ? 'Meta' : 'Ctrl'; + var shortcutTitle = `${mod}+${button.shortcut}`; + + // Mac users are used to glyphs for shortcut keys + if (mac) { + shortcutTitle = shortcutTitle + .replace('Shift', "\u21E7") + .replace('Meta', "\u2318") + .replace('Alt', "\u2325") + .replace(/\+/g, ''); + } else { + shortcutTitle = shortcutTitle + .replace('Shift', I18n.t('shortcut_modifier_key.shift')) + .replace('Ctrl', I18n.t('shortcut_modifier_key.ctrl')) + .replace('Alt', I18n.t('shortcut_modifier_key.alt')); + } + + createdButton.title = `${title} (${shortcutTitle})`; + + this.shortcuts[`${mod}+${button.shortcut}`.toLowerCase()] = createdButton; + } else { + createdButton.title = title; + } + + if (button.unshift) { + g.buttons.unshift(createdButton); + } else { + g.buttons.push(createdButton); + } } -}; +} export function onToolbarCreate(func) { _createCallbacks.push(func); @@ -237,7 +240,7 @@ export default Ember.Component.extend({ @computed toolbar() { - const toolbar = new Toolbar(); + const toolbar = new Toolbar(this.site); _createCallbacks.forEach(cb => cb(toolbar)); this.sendAction('extraButtons', toolbar); return toolbar; diff --git a/app/assets/javascripts/discourse/components/hamburger-menu.js.es6 b/app/assets/javascripts/discourse/components/hamburger-menu.js.es6 index e10c01c84d8..9ec933bcd69 100644 --- a/app/assets/javascripts/discourse/components/hamburger-menu.js.es6 +++ b/app/assets/javascripts/discourse/components/hamburger-menu.js.es6 @@ -10,17 +10,17 @@ export default Ember.Component.extend({ @computed() showKeyboardShortcuts() { - return !Discourse.Mobile.mobileView && !this.capabilities.touch; + return !this.site.mobileView && !this.capabilities.touch; }, @computed() showMobileToggle() { - return Discourse.Mobile.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch); + return this.site.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch); }, @computed() mobileViewLinkTextKey() { - return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view"; + return this.site.mobileView ? "desktop_view" : "mobile_view"; }, @computed() @@ -68,7 +68,7 @@ export default Ember.Component.extend({ this.sendAction('showKeyboardAction'); }, toggleMobileView() { - Discourse.Mobile.toggleMobileView(); + this.site.toggleMobileView(); } } }); diff --git a/app/assets/javascripts/discourse/components/header-dropdown.js.es6 b/app/assets/javascripts/discourse/components/header-dropdown.js.es6 index 7a3f52f4552..c7479848554 100644 --- a/app/assets/javascripts/discourse/components/header-dropdown.js.es6 +++ b/app/assets/javascripts/discourse/components/header-dropdown.js.es6 @@ -17,7 +17,7 @@ export default Ember.Component.extend({ if (this.siteSettings.login_required && !this.currentUser) { this.sendAction('loginAction'); } else { - if (Discourse.Mobile.mobileView && this.get('mobileAction')) { + if (this.site.mobileView && this.get('mobileAction')) { this.sendAction('mobileAction'); return; } diff --git a/app/assets/javascripts/discourse/components/home-logo.js.es6 b/app/assets/javascripts/discourse/components/home-logo.js.es6 index 1cd706d09ed..c0846e268b8 100644 --- a/app/assets/javascripts/discourse/components/home-logo.js.es6 +++ b/app/assets/javascripts/discourse/components/home-logo.js.es6 @@ -14,11 +14,11 @@ export default Ember.Component.extend({ }.property('targetUrl'), showSmallLogo: function() { - return !Discourse.Mobile.mobileView && this.get("minimized"); + return !this.site.mobileView && this.get("minimized"); }.property("minimized"), showMobileLogo: function() { - return Discourse.Mobile.mobileView && !Ember.isBlank(this.get('mobileBigLogoUrl')); + return this.site.mobileView && !Ember.isBlank(this.get('mobileBigLogoUrl')); }.property(), smallLogoUrl: setting('logo_small_url'), diff --git a/app/assets/javascripts/discourse/components/menu-panel.js.es6 b/app/assets/javascripts/discourse/components/menu-panel.js.es6 index 372df605b54..ca017a1171f 100644 --- a/app/assets/javascripts/discourse/components/menu-panel.js.es6 +++ b/app/assets/javascripts/discourse/components/menu-panel.js.es6 @@ -120,17 +120,17 @@ export default Ember.Component.extend({ @computed() showKeyboardShortcuts() { - return !Discourse.Mobile.mobileView && !this.capabilities.touch; + return !this.site.mobileView && !this.capabilities.touch; }, @computed() showMobileToggle() { - return Discourse.Mobile.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch); + return this.site.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch); }, @computed() mobileViewLinkTextKey() { - return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view"; + return this.site.mobileView ? "desktop_view" : "mobile_view"; }, @computed() diff --git a/app/assets/javascripts/discourse/components/topic-list.js.es6 b/app/assets/javascripts/discourse/components/topic-list.js.es6 index 2cc0747b0ed..03a6a4a0a73 100644 --- a/app/assets/javascripts/discourse/components/topic-list.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-list.js.es6 @@ -19,7 +19,7 @@ export default Ember.Component.extend({ }.property(), skipHeader: function() { - return Discourse.Mobile.mobileView; + return this.site.mobileView; }.property(), showLikes: function(){ diff --git a/app/assets/javascripts/discourse/controllers/history.js.es6 b/app/assets/javascripts/discourse/controllers/history.js.es6 index 0a3d504344a..f799700046d 100644 --- a/app/assets/javascripts/discourse/controllers/history.js.es6 +++ b/app/assets/javascripts/discourse/controllers/history.js.es6 @@ -10,7 +10,7 @@ export default Ember.Controller.extend(ModalFunctionality, { revisionsTextKey: "post.revisions.controls.comparing_previous_to_current_out_of_total", _changeViewModeOnMobile: function() { - if (Discourse.Mobile.mobileView) { this.set("viewMode", "inline"); } + if (this.site.mobileView) { this.set("viewMode", "inline"); } }.on("init"), refresh(postId, postVersion) { diff --git a/app/assets/javascripts/discourse/controllers/quote-button.js.es6 b/app/assets/javascripts/discourse/controllers/quote-button.js.es6 index cfff408844d..51f89381aed 100644 --- a/app/assets/javascripts/discourse/controllers/quote-button.js.es6 +++ b/app/assets/javascripts/discourse/controllers/quote-button.js.es6 @@ -61,8 +61,10 @@ export default Ember.Controller.extend({ // containing a single invisible character markerElement.appendChild(document.createTextNode("\ufeff")); + const isMobileDevice = this.site.isMobileDevice; + // collapse the range at the beginning/end of the selection - range.collapse(!Discourse.Mobile.isMobileDevice); + range.collapse(!isMobileDevice); // and insert it at the start of our selection range range.insertNode(markerElement); @@ -83,7 +85,7 @@ export default Ember.Controller.extend({ let topOff = markerOffset.top; let leftOff = markerOffset.left; - if (Discourse.Mobile.isMobileDevice) { + if (isMobileDevice) { topOff = topOff + 20; leftOff = Math.min(leftOff + 10, $(window).width() - $quoteButton.outerWidth()); } else { diff --git a/app/assets/javascripts/discourse/controllers/user-card.js.es6 b/app/assets/javascripts/discourse/controllers/user-card.js.es6 index c67125cdb2c..a78407f225f 100644 --- a/app/assets/javascripts/discourse/controllers/user-card.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-card.js.es6 @@ -45,7 +45,7 @@ export default Ember.Controller.extend({ } // Don't show on mobile - if (Discourse.Mobile.mobileView) { + if (this.site.mobileView) { const url = "/users/" + username; DiscourseURL.routeTo(url); return; diff --git a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 index 73c8ff293a9..94a8db7c1bb 100644 --- a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 @@ -12,7 +12,7 @@ export default Ember.Controller.extend({ bulkSelectEnabled: Em.computed.alias('controllers.user-topics-list.bulkSelectEnabled'), mobileView: function() { - return Discourse.Mobile.mobileView; + return this.site.mobileView; }.property(), showNewPM: function(){ diff --git a/app/assets/javascripts/discourse/ember/resolver.js.es6 b/app/assets/javascripts/discourse/ember/resolver.js.es6 index 85d3ce61ac0..d7124c0900f 100644 --- a/app/assets/javascripts/discourse/ember/resolver.js.es6 +++ b/app/assets/javascripts/discourse/ember/resolver.js.es6 @@ -141,7 +141,7 @@ export default Ember.DefaultResolver.extend({ }, findMobileTemplate(parsedName) { - if (Discourse.Mobile.mobileView) { + if (this.mobileView) { var mobileParsedName = this.parseName(parsedName.fullName.replace("template:", "template:mobile/")); return this.findTemplate(mobileParsedName); } diff --git a/app/assets/javascripts/discourse/initializers/ensure-max-image-dimensions.js.es6 b/app/assets/javascripts/discourse/initializers/ensure-max-image-dimensions.js.es6 index 746abc38f48..99486215aa8 100644 --- a/app/assets/javascripts/discourse/initializers/ensure-max-image-dimensions.js.es6 +++ b/app/assets/javascripts/discourse/initializers/ensure-max-image-dimensions.js.es6 @@ -1,7 +1,7 @@ export default { name: 'ensure-image-dimensions', after: 'mobile', - initialize: function() { + initialize(container) { if (!window) { return; } // This enforces maximum dimensions of images based on site settings @@ -11,7 +11,8 @@ export default { var width = Discourse.SiteSettings.max_image_width; var height = Discourse.SiteSettings.max_image_height; - if (Discourse.Mobile.mobileView) { + const site = container.lookup('site:main'); + if (site.mobileView) { width = $(window).width() - 20; } diff --git a/app/assets/javascripts/discourse/initializers/mobile.js.es6 b/app/assets/javascripts/discourse/initializers/mobile.js.es6 index d39e0802570..d4bffb3569b 100644 --- a/app/assets/javascripts/discourse/initializers/mobile.js.es6 +++ b/app/assets/javascripts/discourse/initializers/mobile.js.es6 @@ -1,14 +1,19 @@ -/** - Initializes the `Discourse.Mobile` helper object. -**/ +import Mobile from 'discourse/lib/mobile'; + +// Initializes the `Mobile` helper object. export default { name: 'mobile', after: 'inject-objects', - initialize: function(container) { - Discourse.Mobile.init(); - var site = container.lookup('site:main'); - site.set('mobileView', Discourse.Mobile.mobileView); + initialize(container, app) { + Mobile.init(); + const site = container.lookup('site:main'); + + site.set('mobileView', Mobile.mobileView); + site.set('isMobileDevice', Mobile.isMobileDevice); + + // This is a bit weird but you can't seem to inject into the resolver? + app.registry.resolver.__resolver__.mobileView = Mobile.mobileView; } }; diff --git a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 index fd820d82021..63ef5104b4d 100644 --- a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 @@ -96,7 +96,7 @@ export default { }); if (!Ember.testing) { - if (!Discourse.Mobile.mobileView) { + if (!site.mobileView) { bus.subscribe("/notification-alert/" + user.get('id'), function(data){ onNotification(data, user); }); diff --git a/app/assets/javascripts/discourse/lib/autocomplete.js.es6 b/app/assets/javascripts/discourse/lib/autocomplete.js.es6 index 5da0fb6b02f..0fb1ed3a30c 100644 --- a/app/assets/javascripts/discourse/lib/autocomplete.js.es6 +++ b/app/assets/javascripts/discourse/lib/autocomplete.js.es6 @@ -3,7 +3,6 @@ @module $.fn.autocomplete **/ - export var CANCELLED_STATUS = "__CANCELLED"; const allowedLettersRegex = /[\s\t\[\{\(\/]/; @@ -226,7 +225,7 @@ export default function(options) { vOffset = div.height(); } - if (Discourse.Mobile.mobileView && !isInput) { + if (Discourse.Site.currentProp('mobileView') && !isInput) { div.css('width', 'auto'); if ((me.height() / 2) >= pos.top) { vOffset = -23; } diff --git a/app/assets/javascripts/discourse/lib/emoji/emoji-toolbar.js.es6 b/app/assets/javascripts/discourse/lib/emoji/emoji-toolbar.js.es6 index 7df7dd75cf2..47d77040dde 100644 --- a/app/assets/javascripts/discourse/lib/emoji/emoji-toolbar.js.es6 +++ b/app/assets/javascripts/discourse/lib/emoji/emoji-toolbar.js.es6 @@ -161,7 +161,7 @@ function showSelector(options) { options.appendTo.append('
'); $('.emoji-modal-wrapper').click(() => closeSelector()); - if (Discourse.Mobile.mobileView) PER_ROW = 9; + if (Discourse.Site.currentProp('mobileView')) { PER_ROW = 9; } const page = keyValueStore.getInt("emojiPage", 0); const offset = keyValueStore.getInt("emojiOffset", 0); diff --git a/app/assets/javascripts/discourse/lib/mobile.js b/app/assets/javascripts/discourse/lib/mobile.js.es6 similarity index 78% rename from app/assets/javascripts/discourse/lib/mobile.js rename to app/assets/javascripts/discourse/lib/mobile.js.es6 index 552e3f68733..561a05458ad 100644 --- a/app/assets/javascripts/discourse/lib/mobile.js +++ b/app/assets/javascripts/discourse/lib/mobile.js.es6 @@ -1,10 +1,10 @@ // An object that is responsible for logic related to mobile devices. -Discourse.Mobile = { +const Mobile = { isMobileDevice: false, mobileView: false, - init: function() { - var $html = $('html'); + init() { + const $html = $('html'); this.isMobileDevice = $html.hasClass('mobile-device'); this.mobileView = $html.hasClass('mobile-view'); @@ -42,3 +42,13 @@ Discourse.Mobile = { window.location.assign(window.location.pathname + '?mobile_view=' + (mobile ? '1' : '0')); } }; + +// Backwards compatibiltity, deprecated +Object.defineProperty(Discourse, 'Mobile', { + get: function() { + Ember.warn("DEPRECATION: `Discourse.Mobile` is deprecated, use `this.site.mobileView` instead"); + return Mobile; + } +}); + +export default Mobile; diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6 index cc094dc0846..9107fe62f1b 100644 --- a/app/assets/javascripts/discourse/models/composer.js.es6 +++ b/app/assets/javascripts/discourse/models/composer.js.es6 @@ -154,7 +154,7 @@ const Composer = RestModel.extend({ usernameLink }); - if (!Discourse.Mobile.mobileView) { + if (!this.site.mobileView) { const replyUsername = post.get('reply_to_user.username'); const replyAvatarTemplate = post.get('reply_to_user.avatar_template'); if (replyUsername && replyAvatarTemplate && this.get('action') === EDIT) { diff --git a/app/assets/javascripts/discourse/models/nav-item.js.es6 b/app/assets/javascripts/discourse/models/nav-item.js.es6 index 1d614c0d1d0..7eb1616485b 100644 --- a/app/assets/javascripts/discourse/models/nav-item.js.es6 +++ b/app/assets/javascripts/discourse/models/nav-item.js.es6 @@ -7,7 +7,7 @@ const NavItem = Discourse.Model.extend({ name = this.get('name'), count = this.get('count') || 0; - if (name === 'latest' && !Discourse.Mobile.mobileView) { + if (name === 'latest' && !Discourse.Site.currentProp('mobileView')) { count = 0; } diff --git a/app/assets/javascripts/discourse/routes/user-index.js.es6 b/app/assets/javascripts/discourse/routes/user-index.js.es6 index 24a536237e2..1653ef0bc8d 100644 --- a/app/assets/javascripts/discourse/routes/user-index.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-index.js.es6 @@ -4,7 +4,7 @@ export default Discourse.Route.extend({ // HACK: Something with the way the user card intercepts clicks seems to break how the // transition into a user's activity works. This makes the back button work on mobile // where there is no user card as well as desktop where there is. - if (Discourse.Mobile.mobileView) { + if (this.site.mobileView) { this.replaceWith('userActivity'); } else { this.transitionTo('userActivity'); diff --git a/app/assets/javascripts/discourse/views/modal-body.js.es6 b/app/assets/javascripts/discourse/views/modal-body.js.es6 index f164c8dbbe5..05998dac405 100644 --- a/app/assets/javascripts/discourse/views/modal-body.js.es6 +++ b/app/assets/javascripts/discourse/views/modal-body.js.es6 @@ -9,7 +9,7 @@ export default Ember.View.extend({ $('#discourse-modal').modal('show'); // Focus on first element - if (!Discourse.Mobile.mobileView && this.get('focusInput')) { + if (!this.site.mobileView && this.get('focusInput')) { Em.run.schedule('afterRender', () => this.$('input:first').focus()); } diff --git a/app/assets/javascripts/discourse/views/share.js.es6 b/app/assets/javascripts/discourse/views/share.js.es6 index 6c1d0f18481..d7139dcf630 100644 --- a/app/assets/javascripts/discourse/views/share.js.es6 +++ b/app/assets/javascripts/discourse/views/share.js.es6 @@ -82,7 +82,7 @@ export default Ember.View.extend({ $shareLink.css({top: "" + y + "px"}); - if (!Discourse.Mobile.mobileView) { + if (!this.site.mobileView) { $shareLink.css({left: "" + x + "px"}); } diff --git a/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 b/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 index bc63cd182a8..ab3992ec6df 100644 --- a/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-footer-main-buttons.js.es6 @@ -6,7 +6,7 @@ export default ContainerView.extend({ @on('init') createButtons() { - const mobileView = Discourse.Mobile.mobileView; + const mobileView = this.site.mobileView; if (!mobileView && this.currentUser.get('staff')) { const viewArgs = {action: 'showTopicAdminMenu', title: 'topic_admin_menu', icon: 'wrench', position: 'absolute'}; diff --git a/app/assets/javascripts/discourse/views/topic-progress.js.es6 b/app/assets/javascripts/discourse/views/topic-progress.js.es6 index 56e3c0ca713..7454c99d2dd 100644 --- a/app/assets/javascripts/discourse/views/topic-progress.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-progress.js.es6 @@ -76,7 +76,7 @@ export default Ember.View.extend({ _focusWhenOpened: function() { // Don't focus on mobile or touch - if (Discourse.Mobile.mobileView || this.capabilities.isIOS) { + if (this.site.mobileView || this.capabilities.isIOS) { return; } diff --git a/app/assets/javascripts/discourse/widgets/post-cooked.js.es6 b/app/assets/javascripts/discourse/widgets/post-cooked.js.es6 index e018f650dac..34f8b088995 100644 --- a/app/assets/javascripts/discourse/widgets/post-cooked.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-cooked.js.es6 @@ -58,7 +58,7 @@ export default class PostCooked { // deferring work only for posts with images // we got to use screen here, cause nothing is rendered yet. // long term we may want to allow for weird margins that are enforced, instead of hardcoding at 70/20 - maxWindowWidth = maxWindowWidth || $(window).width() - (Discourse.Mobile.mobileView ? 20 : 70); + maxWindowWidth = maxWindowWidth || $(window).width() - (this.attrs.mobileView ? 20 : 70); if (maxImageWidth < maxWindowWidth) { maxWindowWidth = maxImageWidth; } diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index 41d65a08f85..9186c80c80a 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -134,7 +134,7 @@ registerButton('reply', attrs => { if (!attrs.canCreatePost) { return; } - if (!Discourse.Mobile.mobileView) { + if (!attrs.mobileView) { args.label = 'topic.reply.title'; } diff --git a/app/assets/javascripts/discourse/widgets/post-stream.js.es6 b/app/assets/javascripts/discourse/widgets/post-stream.js.es6 index 49d14252228..f7fb75e1436 100644 --- a/app/assets/javascripts/discourse/widgets/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-stream.js.es6 @@ -19,6 +19,7 @@ export default createWidget('post-stream', { let prevPost; let prevDate; + const mobileView = this.site.mobileView; for (let i=0; i