Skip to content

Commit

Permalink
Fix position of menu
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Nov 16, 2016
1 parent 0951a9e commit a8b7b0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 14 additions & 0 deletions settings/js/federationscopemenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,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);

}
});

Expand Down
6 changes: 0 additions & 6 deletions settings/js/federationsettingsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
Expand Down

0 comments on commit a8b7b0c

Please sign in to comment.