Fix position of menu

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2016-11-16 16:03:11 +01:00
parent a15809ceed
commit 845f0bd401
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 14 additions and 6 deletions

View file

@ -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);
}
});

View file

@ -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'));
});