From 845f0bd401078e0450f170ff9c379da3bcba55a9 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 16 Nov 2016 16:03:11 +0100 Subject: [PATCH] Fix position of menu Signed-off-by: Roeland Jago Douma --- settings/js/federationscopemenu.js | 14 ++++++++++++++ settings/js/federationsettingsview.js | 6 ------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/settings/js/federationscopemenu.js b/settings/js/federationscopemenu.js index 45937911f0..e129f69fe9 100644 --- a/settings/js/federationscopemenu.js +++ b/settings/js/federationscopemenu.js @@ -109,10 +109,24 @@ show: function(context) { this._context = context; + var $el = $(context.target); + var offsetIcon = $el.offset(); + var offsetHeading = $el.closest('h2').offset(); + this.render(); this.$el.removeClass('hidden'); OC.showMenu(null, this.$el); + + //Set the menuwidth + var menuWidth = this.$el.width(); + this.$el.css('width', menuWidth); + + //Calculate menu position + var l = offsetIcon.left - offsetHeading.left; + l = l - (menuWidth / 2) + ($el.width()/2); + this.$el.css('left', l); + } }); diff --git a/settings/js/federationsettingsview.js b/settings/js/federationsettingsview.js index 1054f13acf..7aaa225a86 100644 --- a/settings/js/federationsettingsview.js +++ b/settings/js/federationsettingsview.js @@ -72,12 +72,6 @@ $heading.append(scopeMenu.$el); $icon.on('click', _.bind(scopeMenu.show, scopeMenu)); - // Fix absolute position according to the heading text length - // TODO: find alternative to those magic number - var diff = field === 'avatar' ? 104 : 68; - var pos = ($heading.width() - $heading.find('label').width()) - diff; - scopeMenu.$el.css('right', pos); - // Restore initial state self._setFieldScopeIcon(field, self._config.get(field + 'Scope')); });