diff --git a/app/assets/javascripts/discourse/components/mobile-nav.js.es6 b/app/assets/javascripts/discourse/components/mobile-nav.js.es6 new file mode 100644 index 000000000..939e3010f --- /dev/null +++ b/app/assets/javascripts/discourse/components/mobile-nav.js.es6 @@ -0,0 +1,38 @@ +export default Ember.Component.extend({ + + _init: function(){ + if (!this.get('site.mobileView')) { + var classes = this.get('desktopClass'); + if (classes) { + classes = classes.split(' '); + this.set('classNames', classes); + } + } + }.on('init'), + + tagName: 'ul', + + classNames: ['mobile-nav'], + + currentPathChanged: function(){ + this.set('expanded', false); + Em.run.next(() => this._updateSelectedHtml()); + }.observes('currentPath'), + + _updateSelectedHtml(){ + const active = this.$('.active'); + if (active && active.html) { + this.set('selectedHtml', active.html()); + } + }, + + didInsertElement(){ + this._updateSelectedHtml(); + }, + + actions: { + toggleExpanded(){ + this.toggleProperty('expanded'); + } + } +}); diff --git a/app/assets/javascripts/discourse/controllers/user-activity.js.es6 b/app/assets/javascripts/discourse/controllers/user-activity.js.es6 index 59c6b6dd8..55ab7846c 100644 --- a/app/assets/javascripts/discourse/controllers/user-activity.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-activity.js.es6 @@ -3,7 +3,7 @@ import { exportUserArchive } from 'discourse/lib/export-csv'; export default Ember.Controller.extend({ userActionType: null, needs: ["application", "user"], - + currentPath: Em.computed.alias('controllers.application.currentPath'), viewingSelf: Em.computed.alias("controllers.user.viewingSelf"), showBookmarks: Em.computed.alias("controllers.user.showBookmarks"), diff --git a/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 b/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 index 85865c16e..c06137a9e 100644 --- a/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 @@ -7,6 +7,8 @@ export default Ember.ArrayController.extend({ showDismissButton: Ember.computed.gt('user.total_unread_notifications', 0), + currentPath: Em.computed.alias('controllers.application.currentPath'), + actions: { resetNew: function() { Discourse.ajax('/notifications/mark-read', { method: 'PUT' }).then(() => { 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 eb8d13c72..73c8ff293 100644 --- a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 @@ -3,11 +3,11 @@ import Topic from 'discourse/models/topic'; export default Ember.Controller.extend({ - needs: ["user-topics-list", "user"], + needs: ["application", "user-topics-list", "user"], pmView: false, - viewingSelf: Em.computed.alias("controllers.user.viewingSelf"), + viewingSelf: Em.computed.alias('controllers.user.viewingSelf'), isGroup: Em.computed.equal('pmView', 'groups'), - + currentPath: Em.computed.alias('controllers.application.currentPath'), selected: Em.computed.alias('controllers.user-topics-list.selected'), bulkSelectEnabled: Em.computed.alias('controllers.user-topics-list.bulkSelectEnabled'), diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index 64202d098..24b26957d 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -6,7 +6,8 @@ import User from 'discourse/models/user'; export default Ember.Controller.extend(CanCheckEmails, { indexStream: false, userActionType: null, - needs: ['user-notifications', 'user-topics-list'], + needs: ['application','user-notifications', 'user-topics-list'], + currentPath: Em.computed.alias('controllers.application.currentPath'), @computed("content.username") viewingSelf(username) { diff --git a/app/assets/javascripts/discourse/templates/components/mobile-nav.hbs b/app/assets/javascripts/discourse/templates/components/mobile-nav.hbs new file mode 100644 index 000000000..889d9eead --- /dev/null +++ b/app/assets/javascripts/discourse/templates/components/mobile-nav.hbs @@ -0,0 +1 @@ +{{yield}} diff --git a/app/assets/javascripts/discourse/templates/mobile/components/mobile-nav.hbs b/app/assets/javascripts/discourse/templates/mobile/components/mobile-nav.hbs new file mode 100644 index 000000000..6b46d500e --- /dev/null +++ b/app/assets/javascripts/discourse/templates/mobile/components/mobile-nav.hbs @@ -0,0 +1,4 @@ +
  • {{{selectedHtml}}}
  • + diff --git a/app/assets/javascripts/discourse/templates/user/activity.hbs b/app/assets/javascripts/discourse/templates/user/activity.hbs index e94b740c9..4eb0971cc 100644 --- a/app/assets/javascripts/discourse/templates/user/activity.hbs +++ b/app/assets/javascripts/discourse/templates/user/activity.hbs @@ -1,26 +1,21 @@
    - + {{/mobile-nav}} {{#if viewingSelf}}
    diff --git a/app/assets/javascripts/discourse/templates/user/messages.hbs b/app/assets/javascripts/discourse/templates/user/messages.hbs index 9b02cc4f2..afc7d0f42 100644 --- a/app/assets/javascripts/discourse/templates/user/messages.hbs +++ b/app/assets/javascripts/discourse/templates/user/messages.hbs @@ -4,7 +4,8 @@ {{d-button class="btn-primary new-private-message" action="composePrivateMessage" icon="envelope" label="user.new_private_message"}} {{/if}} {{/unless}} - + {{/mobile-nav}}
    diff --git a/app/assets/javascripts/discourse/templates/user/notifications.hbs b/app/assets/javascripts/discourse/templates/user/notifications.hbs index aece3ca5c..385e029b6 100644 --- a/app/assets/javascripts/discourse/templates/user/notifications.hbs +++ b/app/assets/javascripts/discourse/templates/user/notifications.hbs @@ -1,6 +1,6 @@
    - + {{/mobile-nav}}
    diff --git a/app/assets/javascripts/discourse/templates/user/user.hbs b/app/assets/javascripts/discourse/templates/user/user.hbs index 6d9ac7af3..397182473 100644 --- a/app/assets/javascripts/discourse/templates/user/user.hbs +++ b/app/assets/javascripts/discourse/templates/user/user.hbs @@ -148,13 +148,12 @@ {{/unless}}
    - + {{/mobile-nav}}
    diff --git a/app/assets/stylesheets/mobile/discourse.scss b/app/assets/stylesheets/mobile/discourse.scss index a023c2e7e..acc5ab256 100644 --- a/app/assets/stylesheets/mobile/discourse.scss +++ b/app/assets/stylesheets/mobile/discourse.scss @@ -93,3 +93,69 @@ h2#site-text-logo .badge-wrapper { font-weight: normal; } + +.user-table { + position: relative; +} + +.mobile-view .mobile-nav { + &.messages-nav, &.notifications-nav, &.activity-nav { + position: absolute; + right: 0px; + top: -55px; + } +} + + +.mobile-view .mobile-nav { + a .fa { + margin-right: 8px; + } + a { + color: $primary; + } + margin: 0; + padding: 0; + background: dark-light-diff($primary, $secondary, 90%, -65%); + list-style: none; + overflow: visible; + position: relative; + width: 40%; + + > li > a { + padding: 8px 10px; + height: 100%; + width: 100%; + display: block; + } + .fa-caret-down { + position: absolute; + right: 0px; + } + + .drop { + display: none; + } + .drop.expanded { + left: 0; + display: block; + position: absolute; + z-index: 10000000; + background-color: $secondary; + width: 98%; + list-style: none; + margin: 0; + padding: 5px; + border: 1px solid #eaeaea; + li { + margin: 5px 0; + padding: 0; + a { + width: 100%; + height: 100%; + display: block; + padding: 5px 8px; + } + } + } +}