11import { getDescribedElement , getDescribedOwner , hackTooltip , hackPopover , isDisabled , registerBootstrapBlazorModule } from "../../modules/utility.js"
2- import { showTooltip , removeTooltip } from "./Button.razor.js"
32import Data from "../../modules/data.js"
43import EventHandler from "../../modules/event-handler.js"
4+ export { showTooltip , removeTooltip } from "./Button.razor.js"
55
66const config = {
77 class : 'popover-confirm' ,
@@ -62,7 +62,7 @@ export function init(id) {
6262 EventHandler . on ( el , 'inserted.bs.popover' , confirm . inserted )
6363 EventHandler . on ( el , 'hide.bs.popover' , confirm . hide )
6464
65- confirm . checkCancel = el => {
65+ const checkCancel = el => {
6666 // check button
6767 let self = el === confirm . el || el . closest ( '.dropdown-toggle' ) === confirm . el
6868 self = self && confirm . popover && confirm . popover . _isShown ( )
@@ -74,7 +74,7 @@ export function init(id) {
7474
7575 confirm . closeConfirm = e => {
7676 const el = e . target
77- if ( ! confirm . checkCancel ( el ) ) {
77+ if ( ! checkCancel ( el ) ) {
7878 document . querySelectorAll ( config . popoverSelector ) . forEach ( function ( ele ) {
7979 const element = getDescribedOwner ( ele )
8080 if ( element ) {
@@ -87,19 +87,9 @@ export function init(id) {
8787 }
8888 }
8989
90- const module = registerBootstrapBlazorModule ( 'PopConfirmButton' , {
91- handle : false ,
92- items : [ ] ,
93- registerClosePopupHandler : function ( ) {
94- if ( this . handle === false ) {
95- this . handle = true ;
96-
97- EventHandler . on ( document , 'click' , confirm . closeConfirm ) ;
98- }
99- }
90+ registerBootstrapBlazorModule ( 'PopConfirmButton' , id , ( ) => {
91+ EventHandler . on ( document , 'click' , confirm . closeConfirm ) ;
10092 } ) ;
101- module . registerClosePopupHandler ( ) ;
102- module . items . push ( id ) ;
10393}
10494
10595export function showConfirm ( id ) {
@@ -152,13 +142,7 @@ export function dispose(id) {
152142 }
153143
154144 const { PopConfirmButton } = window . BootstrapBlazor ;
155- PopConfirmButton . items . pop ( id )
156- if ( PopConfirmButton . items . length === 0 ) {
145+ PopConfirmButton . dispose ( id , ( ) => {
157146 EventHandler . off ( document , 'click' , confirm . closeConfirm )
158- }
159- }
160-
161- export {
162- showTooltip ,
163- removeTooltip
147+ } ) ;
164148}
0 commit comments