From d70bb0e58be5f53b06e17b06463d443e6029b166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 13 Oct 2014 22:38:22 +0200 Subject: [PATCH] UX: fix post admin menu positioning & closing on mobile --- app/assets/javascripts/discourse/views/post-menu.js.es6 | 9 ++++++--- app/assets/javascripts/discourse/views/post_view.js | 6 ------ app/assets/stylesheets/desktop/topic-post.scss | 4 ++-- app/assets/stylesheets/mobile/topic-post.scss | 9 +++++---- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/views/post-menu.js.es6 b/app/assets/javascripts/discourse/views/post-menu.js.es6 index 81d51729289..de2ddd298b2 100644 --- a/app/assets/javascripts/discourse/views/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/views/post-menu.js.es6 @@ -304,9 +304,12 @@ export default Discourse.View.extend({ }, clickAdmin: function() { - var $adminMenu = this.$('.post-admin-menu'); - this.set('adminMenu', $adminMenu); - $adminMenu.show(); + var $postAdminMenu = this.$(".post-admin-menu"); + $postAdminMenu.show(); + $("html").on("mouseup.post-admin-menu", function() { + $postAdminMenu.hide(); + $("html").off("mouseup.post-admin-menu"); + }); }, clickToggleWiki: function() { diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index a6b170ab0a4..3fa57384b97 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -52,12 +52,6 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) { this.get('controller').toggledSelectedPost(this.get('post')); } - - var $adminMenu = this.get('adminMenu'); - if ($adminMenu && !$(e.target).is($adminMenu)) { - $adminMenu.hide(); - this.set('adminMenu', null); - } }, selected: function() { diff --git a/app/assets/stylesheets/desktop/topic-post.scss b/app/assets/stylesheets/desktop/topic-post.scss index 313d1ad7dc5..e8377a1c757 100644 --- a/app/assets/stylesheets/desktop/topic-post.scss +++ b/app/assets/stylesheets/desktop/topic-post.scss @@ -206,8 +206,8 @@ nav.post-controls { border: 1px solid scale-color-diff(); position: absolute; text-align: left; - bottom: 0; - right: 0; + bottom: -2px; + right: 15px; z-index: 1000; display: none; diff --git a/app/assets/stylesheets/mobile/topic-post.scss b/app/assets/stylesheets/mobile/topic-post.scss index 495b1a209e3..7f0ca6f9ba3 100644 --- a/app/assets/stylesheets/mobile/topic-post.scss +++ b/app/assets/stylesheets/mobile/topic-post.scss @@ -77,12 +77,13 @@ button { border: 1px solid scale-color-diff(); position: absolute; text-align: left; - bottom: -26px; - left: 0; + bottom: 0; + left: 135px; z-index: 1000; display: none; h3 { + margin-top: 0; color: $primary; font-size: 1em; } @@ -140,6 +141,7 @@ a.star { padding-top: 5px; padding-bottom: 0px; clear: both; + position: relative; } .topic-map { @@ -446,8 +448,7 @@ blockquote > *:last-child { .gutter { display: none; } -.posts-wrapper { position: relative; -} +.posts-wrapper { position: relative; } .topic-body.highlighted { background-color: scale-color($tertiary, $lightness: 75%);