FIX: Try to be a little smarter about which way topic menus open

This commit is contained in:
Robin Ward 2016-05-31 15:13:57 -04:00
parent 6eb87e6f62
commit 8c6274ba88
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
4 changed files with 12 additions and 6 deletions

View File

@ -5,6 +5,6 @@ export default MountWidget.extend({
widget: "topic-admin-menu-button", widget: "topic-admin-menu-button",
buildArgs() { buildArgs() {
return this.getProperties('topic', 'fixed'); return this.getProperties('topic', 'fixed', 'openUpwards');
} }
}); });

View File

@ -11,7 +11,7 @@ export default ContainerView.extend({
const topic = this.get('topic'); const topic = this.get('topic');
if (!mobileView && this.currentUser.get('staff')) { 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'); this.attachViewWithArgs(viewArgs, 'topic-admin-menu-button');
} }

View File

@ -39,7 +39,8 @@ createWidget('topic-admin-menu-button', {
if (state.expanded) { if (state.expanded) {
result.push(this.attach('topic-admin-menu', { position: state.position, result.push(this.attach('topic-admin-menu', { position: state.position,
fixed: attrs.fixed, fixed: attrs.fixed,
topic: attrs.topic })); topic: attrs.topic,
openUpwards: attrs.openUpwards }));
} }
return result; return result;
@ -71,7 +72,12 @@ export default createWidget('topic-admin-menu', {
const { top, left } = attrs.position; const { top, left } = attrs.position;
const position = attrs.fixed ? 'fixed' : 'absolute'; 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) { html(attrs) {

View File

@ -39,8 +39,8 @@
ul.dropdown-menu { ul.dropdown-menu {
right: 0.5em; right: 0.5em;
top: 23px; top: auto;
bottom: auto; bottom: 25px;
left: auto; left: auto;
} }
} }