feat(popover): Add click-to-dismiss popover template to core

This commit is contained in:
Aysel Afsar 2018-05-25 15:15:15 -04:00 committed by Erik Ziegler
parent b64c9878af
commit 2ad86af12e
3 changed files with 27 additions and 14 deletions

View File

@ -36,3 +36,4 @@ import './input/text.html';
import './notification'; import './notification';
import './popover/form.html'; import './popover/form.html';
import './popover/popoverSimple.html';

View File

@ -0,0 +1,4 @@
<template name="popoverSimple">
{{#if this.message}}{{this.message}}{{/if}}
{{>UI.contentBlock}}
</template>

View File

@ -52,8 +52,15 @@ OHIF.ui.showPopover = (templateName, popoverData, options={}) => {
const popoverOptions = Object.assign({} , defaults, options); const popoverOptions = Object.assign({} , defaults, options);
popoverOptions.content = Blaze.toHTMLWithData(template, popoverData); popoverOptions.content = Blaze.toHTMLWithData(template, popoverData);
if (popoverOptions.hideOnClick) {
$element.click(function() {
$(this).popover('hide');
});
}
$element.popover(popoverOptions); $element.popover(popoverOptions);
if (popoverOptions.trigger !== 'hover') {
$element.one('shown.bs.popover', function(event) { $element.one('shown.bs.popover', function(event) {
const popoverId = $element.attr('aria-describedby'); const popoverId = $element.attr('aria-describedby');
const popover = document.getElementById(popoverId); const popover = document.getElementById(popoverId);
@ -71,6 +78,7 @@ OHIF.ui.showPopover = (templateName, popoverData, options={}) => {
promise.then(dismissPopover).catch(dismissPopover); promise.then(dismissPopover).catch(dismissPopover);
}); });
}
if (popoverOptions.trigger === 'manual') { if (popoverOptions.trigger === 'manual') {
$element.popover('show'); $element.popover('show');