|
|
@ -40,22 +40,21 @@ |
|
|
|
var element = document.createElement('div'); |
|
|
|
var element = document.createElement('div'); |
|
|
|
|
|
|
|
|
|
|
|
element.classList.add('backdrop'); |
|
|
|
element.classList.add('backdrop'); |
|
|
|
|
|
|
|
|
|
|
|
element.addEventListener('touchend', hidePopover); |
|
|
|
element.addEventListener('touchend', hidePopover); |
|
|
|
element.addEventListener('click', hidePopover); |
|
|
|
element.addEventListener('click', hidePopover); |
|
|
|
|
|
|
|
|
|
|
|
return element; |
|
|
|
return element; |
|
|
|
}()); |
|
|
|
}()); |
|
|
|
|
|
|
|
|
|
|
|
var getPopover = function (e) { |
|
|
|
var getPopover = function (e, id) { |
|
|
|
var anchor = findPopovers(e.target); |
|
|
|
var anchor = e && findPopovers(e.target); |
|
|
|
|
|
|
|
|
|
|
|
if (!anchor || !anchor.hash || (anchor.hash.indexOf('/') > 0)) { |
|
|
|
if ((!anchor || !anchor.hash || (anchor.hash.indexOf('/') > 0)) && !id) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
popover = document.querySelector(anchor.hash); |
|
|
|
popover = document.querySelector(id || anchor.hash); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (error) { |
|
|
|
catch (error) { |
|
|
|
popover = null; |
|
|
|
popover = null; |
|
|
@ -72,8 +71,8 @@ |
|
|
|
return popover; |
|
|
|
return popover; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var showHidePopover = function (e) { |
|
|
|
var showHidePopover = function (e, id) { |
|
|
|
var popover = getPopover(e); |
|
|
|
var popover = getPopover(e, id); |
|
|
|
|
|
|
|
|
|
|
|
if (!popover || !!listener) { |
|
|
|
if (!popover || !!listener) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -92,5 +91,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('touchend', showHidePopover); |
|
|
|
window.addEventListener('touchend', showHidePopover); |
|
|
|
window.addEventListener('click', showHidePopover); |
|
|
|
window.addEventListener('click', showHidePopover); |
|
|
|
|
|
|
|
window.POPOVER = { |
|
|
|
|
|
|
|
show: function (id) { |
|
|
|
|
|
|
|
showHidePopover(null, id); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
hide: function () { |
|
|
|
|
|
|
|
popover && hidePopover(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}()); |
|
|
|
}()); |
|
|
|