Browse Source

make popover close when click anyway

pull/585/head
Darren Liew 11 years ago
parent
commit
53d36a6756
  1. 19
      js/popovers.js

19
js/popovers.js

@ -29,16 +29,18 @@
popover.removeEventListener('webkitTransitionEnd', onPopoverHidden); popover.removeEventListener('webkitTransitionEnd', onPopoverHidden);
}; };
var hide = function(){
popover.addEventListener('webkitTransitionEnd', onPopoverHidden);
popover.classList.remove('visible');
popover.parentNode.removeChild(backdrop);
});
var backdrop = (function () { var backdrop = (function () {
var element = document.createElement('div'); var element = document.createElement('div');
element.classList.add('backdrop'); element.classList.add('backdrop');
element.addEventListener('touchend', function () { element.addEventListener('touchend', hide());
popover.addEventListener('webkitTransitionEnd', onPopoverHidden);
popover.classList.remove('visible');
popover.parentNode.removeChild(backdrop);
});
return element; return element;
}()); }());
@ -69,9 +71,14 @@
}; };
var showHidePopover = function (e) { var showHidePopover = function (e) {
var popover = getPopover(e); var oldPopover = popover;
popover = getPopover(e);
if (!popover) { if (!popover) {
if (oldPopover && oldPopover.hasClass('visible')){
popover = oldPopover;
hide();
}
return; return;
} }

Loading…
Cancel
Save