Allow a user to edit its profile or avatar from a member popover

Fixes the data context on the member popover in the details pane. Also
change the way Popover detect if the click is initiated from a parent
popover -- from reading Blaze context, to looking at the event target
parents.
This commit is contained in:
Maxime Quandalle 2015-06-19 14:39:38 +02:00
parent fad4cba5e2
commit 8cf9ec2660
8 changed files with 70 additions and 55 deletions

View file

@ -16,6 +16,10 @@ Popup = {
var self = this;
var popupName = name + 'Popup';
var clickFromPopup = function(evt) {
return $(evt.target).closest('.js-pop-over').length !== 0;
};
return function(evt) {
// If a popup is already openened, clicking again on the opener element
// should close it -- and interupt the current `open` function.
@ -34,7 +38,7 @@ Popup = {
// has one. This allows us to position a sub-popup exactly at the same
// position than its parent.
var openerElement;
if (self._hasPopupParent()) {
if (clickFromPopup(evt)) {
openerElement = self._getTopStack().openerElement;
} else {
self._stack = [];
@ -47,9 +51,8 @@ Popup = {
// We push our popup data to the stack. The top of the stack is always
// used as the data source for our current popup.
self._stack.push({
__isPopup: true,
popupName: popupName,
hasPopupParent: self._hasPopupParent(),
hasPopupParent: clickFromPopup(evt),
title: self._getTitle(popupName),
openerElement: openerElement,
depth: self._stack.length,
@ -155,15 +158,6 @@ Popup = {
return this._stack[this._stack.length - 1];
},
// We use the blaze API to determine if the current popup has been opened from
// a parent popup. The number we give to the `Template.parentData` has been
// determined experimentally and is susceptible to change if you modify the
// `Popup.template`
_hasPopupParent: function() {
var tryParentData = Template.parentData(3);
return !! (tryParentData && tryParentData.__isPopup);
},
// We automatically calculate the popup offset from the reference element
// position and dimensions. We also reactively use the window dimensions to
// ensure that the popup is always visible on the screen.