PageSourceSearch

https://atrobushing.com/_content/Havit.Blazor.Components.Web.Bootstrap/HxOffcanvas.ctsjs3h0u0.js

js atrobushing.com collected 2026-09-26 14:03:56 UTC 3,663 bytes, 117 lines download raw bytes

1export function show(element, hxOffcanvasDotnetObjectReference, closeOnEscape, scrollingEnabled, subscribeToHideEvent) {
2	if (window.offcanvasElement) {
3		const previousOffcanvas = bootstrap.Offcanvas.getInstance(window.offcanvasElement);
4		if (previousOffcanvas) {
5            // Although opening a new offcanvas should close the previous one,
6			// we do not set previousOffcanvas.hidePreventionDisabled = true and force the hide() here (when handling the OnHiding event)
7			// We want the developer to handle such specific scenarios on their own.
8			// This might be subject to change in the future.
9            previousOffcanvas.hide();
10		}
11	}
12
13	if (!element) {
14		return;
15	}
16
17	element.hxOffcanvasDotnetObjectReference = hxOffcanvasDotnetObjectReference;
18	if (subscribeToHideEvent) {
19		element.addEventListener('hide.bs.offcanvas', handleOffcanvasHide);
20	}
21	element.addEventListener('hidden.bs.offcanvas', handleOffcanvasHidden);
22	element.addEventListener('shown.bs.offcanvas', handleOffcanvasShown);
23	window.offcanvasElement = element;
24
25	const offcanvas = new bootstrap.Offcanvas(element, {
26		keyboard: closeOnEscape,
27		scroll: scrollingEnabled
28	});
29	if (offcanvas) {
30		offcanvas.show();
31	}
32}
33
34export function hide(element) {
35	if (!element) {
36		return;
37	}
38	element.hxOffcanvasHiding = true;
39	const o = bootstrap.Offcanvas.getInstance(element);
40	if (o) {
41		o.hide();
42	}
43}
44
45function handleOffcanvasShown(event) {
46	event.target.hxOffcanvasDotnetObjectReference.invokeMethodAsync('HxOffcanvas_HandleOffcanvasShown');
47}
48
49async function handleOffcanvasHide(event) {
50	const o = bootstrap.Offcanvas.getInstance(event.target);
51
52	if (o.hidePreventionDisabled || event.target.hxOffcanvasDisposing) {
53		o.hidePreventionDisabled = false;
54		return;
55	}
56
57	event.preventDefault();
58
59	const cancel = await event.target.hxOffcanvasDotnetObjectReference.invokeMethodAsync('HxOffcanvas_HandleOffcanvasHide');
60	if (!cancel) {
61		o.hidePreventionDisabled = true;
62		event.target.hxOffcanvasHiding = true;
63		o.hide();
64	}
65};
66
67function handleOffcanvasHidden(event) {
68	event.target.hxOffcanvasHiding = false;
69
70	if (event.target === window.offcanvasElement) {
71		window.offcanvasElement = null;
72	}
73
74	if (event.target.hxOffcanvasDisposing) {
75		// fix for #110 where the dispose() gets called while the offcanvas is still in hiding-transition
76		dispose(event.target, false);
77		return;
78	}
79
80	event.target.hxOffcanvasDotnetObjectReference.invokeMethodAsync('HxOffcanvas_HandleOffcanvasHidden');
81}
82
83export function dispose(element, opened) {
84	if (!element) {
85		return;
86	}
87
88	element.hxOffcanvasDisposing = true;
89
90	if (element.hxOffcanvasHiding) {
91		// fix for #110 where the dispose() gets called while the offcanvas is still in hiding-transition
92		return;
93	}
94
95	if (opened) {
96		// #110 Scrolling not working when offcanvas is removed (even if disposed is called)
97		// Compensates https://github.com/twbs/bootstrap/issues/36397,
98		// where the o.dispose() does not reset the ScrollBarHelper() and the scrolling remains deactivated.
99		// The dispose() is re-called from hidden.bs.offcanvas event handler.
100		// Remove when the issue is fixed.
101		hide(element);
102		return;
103	}
104
105	element.removeEventListener('hidden.bs.offcanvas', handleOffcanvasHidden);
106	element.removeEventListener('shown.bs.offcanvas', handleOffcanvasShown);
107	element.hxOffcanvasDotnetObjectReference = null;
108
109	const o = bootstrap.Offcanvas.getInstance(element);
110	if (o) {
111		o.dispose();
112	}
113
114	if (element === window.offcanvasElement) { // another offcanvas might be already open
115		window.offcanvasElement = null;
116	}
117}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.