feat(popover): Add click-to-dismiss popover template to core
This commit is contained in:
parent
b64c9878af
commit
2ad86af12e
@ -36,3 +36,4 @@ import './input/text.html';
|
|||||||
import './notification';
|
import './notification';
|
||||||
|
|
||||||
import './popover/form.html';
|
import './popover/form.html';
|
||||||
|
import './popover/popoverSimple.html';
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
<template name="popoverSimple">
|
||||||
|
{{#if this.message}}{{this.message}}{{/if}}
|
||||||
|
{{>UI.contentBlock}}
|
||||||
|
</template>
|
||||||
@ -52,25 +52,33 @@ 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);
|
||||||
|
|
||||||
$element.one('shown.bs.popover', function(event) {
|
if (popoverOptions.trigger !== 'hover') {
|
||||||
const popoverId = $element.attr('aria-describedby');
|
$element.one('shown.bs.popover', function(event) {
|
||||||
const popover = document.getElementById(popoverId);
|
const popoverId = $element.attr('aria-describedby');
|
||||||
const $popover = $(popover);
|
const popover = document.getElementById(popoverId);
|
||||||
const $popoverContent = $popover.find('.popover-content');
|
const $popover = $(popover);
|
||||||
const dismissPopover = () => $element.popover('hide');
|
const $popoverContent = $popover.find('.popover-content');
|
||||||
|
const dismissPopover = () => $element.popover('hide');
|
||||||
|
|
||||||
$popoverContent.html('');
|
$popoverContent.html('');
|
||||||
|
|
||||||
const view = Blaze.renderWithData(template, templateData, $popoverContent[0]);
|
const view = Blaze.renderWithData(template, templateData, $popoverContent[0]);
|
||||||
$element.one('hidden.bs.popover', () => {
|
$element.one('hidden.bs.popover', () => {
|
||||||
Blaze.remove(view);
|
Blaze.remove(view);
|
||||||
$element.popover('destroy');
|
$element.popover('destroy');
|
||||||
|
});
|
||||||
|
|
||||||
|
promise.then(dismissPopover).catch(dismissPopover);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
promise.then(dismissPopover).catch(dismissPopover);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (popoverOptions.trigger === 'manual') {
|
if (popoverOptions.trigger === 'manual') {
|
||||||
$element.popover('show');
|
$element.popover('show');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user