PageSourceSearch

https://wigmoremedical.com/WMContent/js/wm-toast.js

js wigmoremedical.com collected 2026-10-05 01:56:08 UTC 10,355 bytes, 226 lines download raw bytes

1(function (win, doc) {
2    'use strict';
3
4    if (win.wmToast) return;
5
6    var FIXED_POSITION = 'bottom-center';
7
8    var DEFAULTS = {
9        type: 'default',
10        description: '',
11        duration: 4000,
12        html: ''
13    };
14
15    var ICONS = {
16        success: '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM16.7744 9.63269C17.1238 9.20501 17.0604 8.57503 16.6327 8.22559C16.2051 7.87615 15.5751 7.93957 15.2256 8.36725L10.6321 13.9892L8.65936 12.2524C8.24484 11.8874 7.61295 11.9276 7.248 12.3421C6.88304 12.7566 6.92322 13.3885 7.33774 13.7535L9.31046 15.4903C10.1612 16.2393 11.4637 16.1324 12.1808 15.2547L16.7744 9.63269Z" fill="currentColor"/></svg>',
17        info: '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM12 9C12.5523 9 13 8.55228 13 8C13 7.44772 12.5523 7 12 7C11.4477 7 11 7.44772 11 8C11 8.55228 11.4477 9 12 9ZM13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12V16C11 16.5523 11.4477 17 12 17C12.5523 17 13 16.5523 13 16V12Z" fill="currentColor"/></svg>',
18        warning: '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M9.44829 4.46472C10.5836 2.51208 13.4105 2.51168 14.5464 4.46401L21.5988 16.5855C22.7423 18.5509 21.3145 21 19.05 21L4.94967 21C2.68547 21 1.25762 18.5516 2.4004 16.5862L9.44829 4.46472ZM11.9995 8C12.5518 8 12.9995 8.44772 12.9995 9V13C12.9995 13.5523 12.5518 14 11.9995 14C11.4473 14 10.9995 13.5523 10.9995 13V9C10.9995 8.44772 11.4473 8 11.9995 8ZM12.0009 15.99C11.4486 15.9892 11.0003 16.4363 10.9995 16.9886L10.9995 16.9986C10.9987 17.5509 11.4458 17.9992 11.9981 18C12.5504 18.0008 12.9987 17.5537 12.9995 17.0014L12.9995 16.9914C13.0003 16.4391 12.5532 15.9908 12.0009 15.99Z" fill="currentColor"/></svg>',
19        danger: '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM11.9996 7C12.5519 7 12.9996 7.44772 12.9996 8V12C12.9996 12.5523 12.5519 13 11.9996 13C11.4474 13 10.9996 12.5523 10.9996 12V8C10.9996 7.44772 11.4474 7 11.9996 7ZM12.001 14.99C11.4488 14.9892 11.0004 15.4363 10.9997 15.9886L10.9996 15.9986C10.9989 16.5509 11.446 16.9992 11.9982 17C12.5505 17.0008 12.9989 16.5537 12.9996 16.0014L12.9996 15.9914C13.0004 15.4391 12.5533 14.9908 12.001 14.99Z" fill="currentColor"/></svg>'
20    };
21
22    var CLOSE_SVG = '<svg viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"/></svg>';
23
24    var MAX_VISIBLE = 3;
25    var PADDING = 12;
26
27    var containers = {};
28    var toastsByContainer = {};
29
30    function ensureContainer(position) {
31        if (containers[position]) return containers[position];
32        var ul = doc.createElement('ul');
33        ul.className = 'wm-toasts wm-toasts--' + position;
34        ul.setAttribute('role', 'region');
35        ul.setAttribute('aria-live', 'polite');
36        ul.setAttribute('aria-label', 'Notifications');
37        doc.body.appendChild(ul);
38        containers[position] = ul;
39        toastsByContainer[position] = [];
40
41        ul.addEventListener('mouseenter', function () { setHovered(position, true); });
42        ul.addEventListener('mouseleave', function () { setHovered(position, false); });
43        return ul;
44    }
45
46    function setHovered(position, isHovered) {
47        var ul = containers[position];
48        if (!ul) return;
49        if (isHovered) ul.classList.add('is-hovered');
50        else ul.classList.remove('is-hovered');
51        stackToasts(position);
52    }
53
54    function createToastEl(toast) {
55        var li = doc.createElement('li');
56        li.className = 'wm-toast wm-toast--' + toast.type + ' wm-toast--' + toast.position;
57        li.id = toast.id;
58
59        var inner = doc.createElement('div');
60        inner.className = 'wm-toast__inner';
61
62        if (toast.html) {
63            inner.classList.add('wm-toast__inner--custom');
64            inner.innerHTML = toast.html;
65        } else {
66            var body = doc.createElement('div');
67            body.className = 'wm-toast__body';
68
69            var head = doc.createElement('div');
70            head.className = 'wm-toast__head';
71
72            if (ICONS[toast.type]) {
73                var iconWrap = doc.createElement('span');
74                iconWrap.className = 'wm-toast__icon';
75                iconWrap.innerHTML = ICONS[toast.type];
76                head.appendChild(iconWrap);
77            }
78
79            var msg = doc.createElement('p');
80            msg.className = 'wm-toast__message';
81            msg.textContent = toast.message;
82            head.appendChild(msg);
83
84            body.appendChild(head);
85
86            if (toast.description) {
87                var desc = doc.createElement('p');
88                desc.className = 'wm-toast__description';
89                desc.textContent = toast.description;
90                body.appendChild(desc);
91            }
92
93            inner.appendChild(body);
94        }
95
96        var close = doc.createElement('button');
97        close.type = 'button';
98        close.className = 'wm-toast__close';
99        close.setAttribute('aria-label', 'Dismiss notification');
100        close.innerHTML = CLOSE_SVG;
101        close.addEventListener('click', function () { dismissToast(toast.id); });
102        inner.appendChild(close);
103
104        li.appendChild(inner);
105        return li;
106    }
107
108    function stackToasts(position) {
109        var list = toastsByContainer[position] || [];
110        var isBottom = position.indexOf('bottom') === 0;
111        var ul = containers[position];
112        if (!ul) return;
113        var expanded = ul.classList.contains('is-hovered');
114
115        var offset = 0;
116        for (var i = 0; i < list.length; i++) {
117            var entry = list[i];
118            var el = entry.el;
119            if (!el) continue;
120            el.style.zIndex = String(100 - i);
121
122            if (i >= MAX_VISIBLE) {
123                el.classList.add('is-burning');
124            }
125
126            if (expanded) {
127                var h = el.offsetHeight || 0;
128                var translate = isBottom ? -offset : offset;
129                el.style.transform = 'translateY(' + translate + 'px) scale(1)';
130                el.style.opacity = i >= MAX_VISIBLE ? '0' : '1';
131                offset += h + PADDING;
132            } else {
133                var scale = 1 - (Math.min(i, MAX_VISIBLE) * 0.06);
134                var shift = Math.min(i, MAX_VISIBLE) * 14;
135                var direction = isBottom ? -shift : shift;
136                el.style.transform = 'translateY(' + direction + 'px) scale(' + scale + ')';
137                el.style.opacity = i >= MAX_VISIBLE ? '0' : '1';
138            }
139        }
140    }
141
142    function dismissToast(id) {
143        var position, list, index = -1, entry;
144        for (var key in toastsByContainer) {
145            if (!toastsByContainer.hasOwnProperty(key)) continue;
146            var arr = toastsByContainer[key];
147            for (var i = 0; i < arr.length; i++) {
148                if (arr[i].id === id) { position = key; list = arr; index = i; entry = arr[i]; break; }
149            }
150            if (entry) break;
151        }
152        if (!entry) return;
153
154        if (entry.timer) { clearTimeout(entry.timer); entry.timer = null; }
155
156        entry.el.classList.add('is-leaving');
157        setTimeout(function () {
158            if (entry.el && entry.el.parentNode) entry.el.parentNode.removeChild(entry.el);
159            list.splice(index, 1);
160            stackToasts(position);
161        }, 280);
162    }
163
164    function showToast(message, options) {
165        options = options || {};
166        var type = options.type || DEFAULTS.type;
167        var position = FIXED_POSITION;
168        var duration = typeof options.duration === 'number' ? options.duration : DEFAULTS.duration;
169
170        var toast = {
171            id: 'wm-toast-' + Date.now() + '-' + Math.random().toString(16).slice(2, 8),
172            type: type,
173            message: message == null ? '' : String(message),
174            description: options.description || '',
175            position: position,
176            html: options.html || '',
177            duration: duration
178        };
179
180        ensureContainer(position);
181        var el = createToastEl(toast);
182        var ul = containers[position];
183        ul.insertBefore(el, ul.firstChild);
184
185        var entry = { id: toast.id, el: el, position: position, timer: null };
186        toastsByContainer[position].unshift(entry);
187
188        // Force reflow so the enter transition runs.
189        /* eslint-disable no-unused-expressions */
190        el.getBoundingClientRect().height;
191        /* eslint-enable no-unused-expressions */
192        el.classList.add('is-entered');
193
194        stackToasts(position);
195
196        if (duration > 0) {
197            entry.timer = setTimeout(function () { dismissToast(toast.id); }, duration);
198        }
199
200        return toast.id;
201    }
202
203    function toast(message, options) {
204        return showToast(message, options);
205    }
206
207    win.wmToast = toast;
208    win.wmToast.dismiss = dismissToast;
209
210    win.addEventListener('wm:toast-show', function (e) {
211        if (!e || !e.detail) return;
212        var d = e.detail;
213        showToast(d.message, {
214            type: d.type,
215            description: d.description,
216            position: d.position,
217            duration: d.duration,
218            html: d.html
219        });
220    });
221
222    win.addEventListener('wm:toast-dismiss', function (e) {
223        if (!e || !e.detail || !e.detail.id) return;
224        dismissToast(e.detail.id);
225    });
226})(window, document);

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.