From 12378d115baaf341beb0537e9d9c20555070a349 Mon Sep 17 00:00:00 2001 From: Zenobius Jiricek Date: Fri, 10 May 2013 12:40:49 +0930 Subject: [PATCH] remove backdrop from proper element. When a popover is displayed, a backdrop is appened to the popovers parent node. We need to remove it from that node instead of assuming that node will be `document.body` --- lib/js/popovers.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/js/popovers.js b/lib/js/popovers.js index 6cdf1c6..a208c64 100644 --- a/lib/js/popovers.js +++ b/lib/js/popovers.js @@ -16,7 +16,7 @@ }; var onPopoverHidden = function () { - document.body.removeChild(backdrop); + popover.parentNode.removeChild(backdrop); popover.style.display = 'none'; popover.removeEventListener('webkitTransitionEnd', onPopoverHidden); } @@ -46,7 +46,7 @@ return popover; } - window.addEventListener('touchend', function (e) { + var showHidePopover = function (e) { var popover = getPopover(e); if (!popover) return; @@ -56,8 +56,9 @@ popover.classList.add('visible'); popover.parentNode.appendChild(backdrop); - }); + }; - window.addEventListener('click', function (e) { if (getPopover(e)) e.preventDefault(); }); + window.addEventListener('touchend', showHidePopover); + window.addEventListener('click', showHidePopover); }();