From 8cf9ec266055f065c428216d53018c83b63675c6 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Fri, 19 Jun 2015 14:39:38 +0200 Subject: 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. --- client/lib/popup.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'client/lib/popup.js') diff --git a/client/lib/popup.js b/client/lib/popup.js index 3813319d..84d4b63a 100644 --- a/client/lib/popup.js +++ b/client/lib/popup.js @@ -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. -- cgit v1.2.3-1-g7c22