From 8c6274ba883f5f2ecf85e68c169e111abd935a16 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 31 May 2016 15:13:57 -0400 Subject: [PATCH] FIX: Try to be a little smarter about which way topic menus open --- .../components/topic-admin-menu-button.js.es6 | 2 +- .../discourse/views/topic-footer-main-buttons.js.es6 | 2 +- .../discourse/widgets/topic-admin-menu.js.es6 | 10 ++++++++-- app/assets/stylesheets/desktop/topic-timeline.scss | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-admin-menu-button.js.es6 b/app/assets/javascripts/discourse/components/topic-admin-menu-button.js.es6 index 732e70bebe0..cb76f7997d4 100644 --- a/app/assets/javascripts/discourse/components/topic-admin-menu-button.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-admin-menu-button.js.es6 @@ -5,6 +5,6 @@ export default MountWidget.extend({ widget: "topic-admin-menu-button", buildArgs() { - return this.getProperties('topic', 'fixed'); + return this.getProperties('topic', 'fixed', 'openUpwards'); } }); 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 25a7e8a634c..60657c72041 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 @@ -11,7 +11,7 @@ export default ContainerView.extend({ const topic = this.get('topic'); if (!mobileView && this.currentUser.get('staff')) { - const viewArgs = { topic, delegated: this.get('topicDelegated') }; + const viewArgs = { topic, delegated: this.get('topicDelegated'), openUpwards: true }; this.attachViewWithArgs(viewArgs, 'topic-admin-menu-button'); } diff --git a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 index 29460ed92af..ad0a2a049dd 100644 --- a/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-admin-menu.js.es6 @@ -39,7 +39,8 @@ createWidget('topic-admin-menu-button', { if (state.expanded) { result.push(this.attach('topic-admin-menu', { position: state.position, fixed: attrs.fixed, - topic: attrs.topic })); + topic: attrs.topic, + openUpwards: attrs.openUpwards })); } return result; @@ -71,7 +72,12 @@ export default createWidget('topic-admin-menu', { const { top, left } = attrs.position; const position = attrs.fixed ? 'fixed' : 'absolute'; - return { style: `position: ${position}; top: ${top}px; left: ${left}px;` }; + if (attrs.openUpwards) { + const bottom = $(document).height() - top; + return { style: `position: ${position}; bottom: ${bottom}px; left: ${left}px;` }; + } else { + return { style: `position: ${position}; top: ${top}px; left: ${left}px;` }; + } }, html(attrs) { diff --git a/app/assets/stylesheets/desktop/topic-timeline.scss b/app/assets/stylesheets/desktop/topic-timeline.scss index 98e72bf9a27..61f3ff04a91 100644 --- a/app/assets/stylesheets/desktop/topic-timeline.scss +++ b/app/assets/stylesheets/desktop/topic-timeline.scss @@ -39,8 +39,8 @@ ul.dropdown-menu { right: 0.5em; - top: 23px; - bottom: auto; + top: auto; + bottom: 25px; left: auto; } }