diff --git a/app/assets/javascripts/discourse/ember/resolver.js.es6 b/app/assets/javascripts/discourse/ember/resolver.js.es6
index 8f41a2c5073..99ecb42d2a9 100644
--- a/app/assets/javascripts/discourse/ember/resolver.js.es6
+++ b/app/assets/javascripts/discourse/ember/resolver.js.es6
@@ -39,7 +39,6 @@ function parseName(fullName) {
}
export default Ember.DefaultResolver.extend({
-
parseName: parseName,
normalize(fullName) {
diff --git a/app/assets/javascripts/discourse/initializers/mobile.js.es6 b/app/assets/javascripts/discourse/initializers/mobile.js.es6
index d4bffb3569b..2ac54497b2c 100644
--- a/app/assets/javascripts/discourse/initializers/mobile.js.es6
+++ b/app/assets/javascripts/discourse/initializers/mobile.js.es6
@@ -1,6 +1,6 @@
import Mobile from 'discourse/lib/mobile';
-// Initializes the `Mobile` helper object.
+// Initializes the `Mobile` helper object.
export default {
name: 'mobile',
after: 'inject-objects',
@@ -16,4 +16,3 @@ export default {
app.registry.resolver.__resolver__.mobileView = Mobile.mobileView;
}
};
-
diff --git a/app/assets/javascripts/discourse/lib/mobile.js.es6 b/app/assets/javascripts/discourse/lib/mobile.js.es6
index 561a05458ad..9fef722aa4a 100644
--- a/app/assets/javascripts/discourse/lib/mobile.js.es6
+++ b/app/assets/javascripts/discourse/lib/mobile.js.es6
@@ -1,3 +1,5 @@
+let mobileForced = false;
+
// An object that is responsible for logic related to mobile devices.
const Mobile = {
isMobileDevice: false,
@@ -5,8 +7,10 @@ const Mobile = {
init() {
const $html = $('html');
- this.isMobileDevice = $html.hasClass('mobile-device');
- this.mobileView = $html.hasClass('mobile-view');
+ this.isMobileDevice = mobileForced || $html.hasClass('mobile-device');
+ this.mobileView = mobileForced || $html.hasClass('mobile-view');
+
+ if (mobileForced) { return; }
try{
if (window.location.search.match(/mobile_view=1/)){
@@ -27,8 +31,8 @@ const Mobile = {
}
},
- toggleMobileView: function() {
- try{
+ toggleMobileView() {
+ try {
if (localStorage) {
localStorage.mobileView = !this.mobileView;
}
@@ -38,11 +42,19 @@ const Mobile = {
this.reloadPage(!this.mobileView);
},
- reloadPage: function(mobile) {
+ reloadPage(mobile) {
window.location.assign(window.location.pathname + '?mobile_view=' + (mobile ? '1' : '0'));
}
};
+export function forceMobile() {
+ mobileForced = true;
+}
+
+export function resetMobile() {
+ mobileForced = false;
+}
+
// Backwards compatibiltity, deprecated
Object.defineProperty(Discourse, 'Mobile', {
get: function() {
diff --git a/app/assets/javascripts/discourse/templates/mobile/components/directory-item.hbs b/app/assets/javascripts/discourse/templates/mobile/components/directory-item.hbs
new file mode 100644
index 00000000000..cf592623fe1
--- /dev/null
+++ b/app/assets/javascripts/discourse/templates/mobile/components/directory-item.hbs
@@ -0,0 +1,11 @@
+{{user-info user=item.user}}
+{{user-stat value=item.likes_received label="directory.likes_received" icon="heart"}}
+{{user-stat value=item.likes_given label="directory.likes_given" icon="heart"}}
+{{user-stat value=item.topic_count label="directory.topic_count"}}
+{{user-stat value=item.post_count label="directory.post_count"}}
+{{user-stat value=item.topics_entered label="directory.topics_entered"}}
+{{user-stat value=item.posts_read label="directory.posts_read"}}
+{{user-stat value=item.days_visited label="directory.days_visited"}}
+{{#if showTimeRead}}
+
{{unbound item.time_read}}
+{{/if}}
diff --git a/app/assets/javascripts/discourse/templates/mobile/users.hbs b/app/assets/javascripts/discourse/templates/mobile/users.hbs
index b8cef9177a8..f0fabceb33d 100644
--- a/app/assets/javascripts/discourse/templates/mobile/users.hbs
+++ b/app/assets/javascripts/discourse/templates/mobile/users.hbs
@@ -9,24 +9,9 @@
{{#conditional-loading-spinner condition=model.loading}}
{{#if model.length}}
{{i18n "directory.total_rows" count=model.totalRows}}
-
- {{#each model itemController="directory-item"}}
-
- {{#with ic.model as |it|}}
- {{user-info user=it.user}}
- {{user-stat value=it.likes_received label="directory.likes_received" icon="heart"}}
- {{user-stat value=it.likes_given label="directory.likes_given" icon="heart"}}
- {{user-stat value=it.topic_count label="directory.topic_count"}}
- {{user-stat value=it.post_count label="directory.post_count"}}
- {{user-stat value=it.topics_entered label="directory.topics_entered"}}
- {{user-stat value=it.posts_read label="directory.posts_read"}}
- {{user-stat value=it.days_visited label="directory.days_visited"}}
- {{#if showTimeRead}}
-
{{unbound it.time_read}}
- {{/if}}
- {{/with}}
-
- {{/each}}
+ {{#each model as |item|}}
+ {{directory-item tagName="div" class="user" item=item showTimeRead=showTimeRead}}
+ {{/each}}
{{conditional-loading-spinner condition=model.loadingMore}}
{{else}}
diff --git a/test/javascripts/acceptance/mobile-discovery-test.js.es6 b/test/javascripts/acceptance/mobile-discovery-test.js.es6
new file mode 100644
index 00000000000..4d0198bffe7
--- /dev/null
+++ b/test/javascripts/acceptance/mobile-discovery-test.js.es6
@@ -0,0 +1,15 @@
+import { acceptance } from "helpers/qunit-helpers";
+acceptance("Topic Discovery - Mobile", { mobileView: true });
+
+test("Visit Discovery Pages", () => {
+ visit("/");
+ andThen(() => {
+ ok(exists(".topic-list"), "The list of topics was rendered");
+ ok(exists('.topic-list .topic-list-item'), "has topics");
+ });
+
+ visit("/categories");
+ andThen(() => {
+ ok(exists('.category'), "has a list of categories");
+ });
+});
diff --git a/test/javascripts/acceptance/mobile-sign-in-test.js.es6 b/test/javascripts/acceptance/mobile-sign-in-test.js.es6
new file mode 100644
index 00000000000..80831091317
--- /dev/null
+++ b/test/javascripts/acceptance/mobile-sign-in-test.js.es6
@@ -0,0 +1,11 @@
+import { acceptance } from "helpers/qunit-helpers";
+
+acceptance("Signing In - Mobile", { mobileView: true });
+
+test("sign in", () => {
+ visit("/");
+ click("header .login-button");
+ andThen(() => {
+ ok(exists('#login-form'), "it shows the login modal");
+ });
+});
diff --git a/test/javascripts/acceptance/mobile-users-test.js.es6 b/test/javascripts/acceptance/mobile-users-test.js.es6
new file mode 100644
index 00000000000..8cc2cb9da1b
--- /dev/null
+++ b/test/javascripts/acceptance/mobile-users-test.js.es6
@@ -0,0 +1,10 @@
+import { acceptance } from "helpers/qunit-helpers";
+
+acceptance("User Directory - Mobile", { mobileView: true });
+
+test("Visit Page", () => {
+ visit("/users");
+ andThen(() => {
+ ok(exists('.directory .user'), "has a list of users");
+ });
+});
diff --git a/test/javascripts/helpers/qunit-helpers.js.es6 b/test/javascripts/helpers/qunit-helpers.js.es6
index 63288ef7abd..c0bed4d486f 100644
--- a/test/javascripts/helpers/qunit-helpers.js.es6
+++ b/test/javascripts/helpers/qunit-helpers.js.es6
@@ -3,6 +3,7 @@
import sessionFixtures from 'fixtures/session-fixtures';
import siteFixtures from 'fixtures/site-fixtures';
import HeaderComponent from 'discourse/components/site-header';
+import { forceMobile, resetMobile } from 'discourse/lib/mobile';
function currentUser() {
return Discourse.User.create(sessionFixtures['/session/current.json'].current_user);
@@ -36,19 +37,25 @@ var oldAvatar = Discourse.Utilities.avatarImg;
function acceptance(name, options) {
module("Acceptance: " + name, {
- setup: function() {
+ setup() {
+ resetMobile();
+
// Don't render avatars in acceptance tests, it's faster and no 404s
Discourse.Utilities.avatarImg = () => "";
// For now don't do scrolling stuff in Test Mode
HeaderComponent.reopen({examineDockHeader: Ember.K});
- var siteJson = siteFixtures['site.json'].site;
+ const siteJson = siteFixtures['site.json'].site;
if (options) {
if (options.setup) {
options.setup.call(this);
}
+ if (options.mobileView) {
+ forceMobile();
+ }
+
if (options.loggedIn) {
logIn();
}
@@ -65,7 +72,7 @@ function acceptance(name, options) {
Discourse.reset();
},
- teardown: function() {
+ teardown() {
if (options && options.teardown) {
options.teardown.call(this);
}