minora 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +292 -0
- package/dist/minora.css +7499 -0
- package/dist/minora.js +779 -0
- package/dist/minora.min.css +7 -0
- package/dist/minora.min.js +2 -0
- package/dist/tokens.css +542 -0
- package/package.json +45 -0
- package/src/components/alert.css +659 -0
- package/src/components/avatar.css +463 -0
- package/src/components/badge.css +577 -0
- package/src/components/button.css +493 -0
- package/src/components/checkbox.css +605 -0
- package/src/components/divider.css +295 -0
- package/src/components/form-validation.css +700 -0
- package/src/components/input.css +625 -0
- package/src/components/modal.css +437 -0
- package/src/components/select.css +616 -0
- package/src/components/toast.css +586 -0
- package/src/components/toggle.css +457 -0
- package/src/components/tooltip.css +401 -0
- package/src/js/modal.js +127 -0
- package/src/js/select.js +272 -0
- package/src/js/toast.js +140 -0
- package/src/js/tooltip.js +224 -0
- package/src/tokens.css +542 -0
package/src/js/select.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minora — Select & Multiselect Manager
|
|
3
|
+
* ─────────────────────────────────────
|
|
4
|
+
* Custom dropdowns with search, keyboard navigation,
|
|
5
|
+
* grouped options, and tag-based multiselect.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* <div class="select select-md" data-select>
|
|
9
|
+
* <div class="select-trigger" role="combobox" tabindex="0">
|
|
10
|
+
* <span class="select-placeholder">Choose…</span>
|
|
11
|
+
* <span class="select-value" hidden></span>
|
|
12
|
+
* <span class="select-chevron"><svg>…</svg></span>
|
|
13
|
+
* </div>
|
|
14
|
+
* <select name="field" hidden>
|
|
15
|
+
* <option value="a">Option A</option>
|
|
16
|
+
* </select>
|
|
17
|
+
* <div class="select-dropdown">
|
|
18
|
+
* <div class="select-search-wrapper"><input class="select-search-input" /></div>
|
|
19
|
+
* <div class="select-options">
|
|
20
|
+
* <div class="select-option" data-value="a"><span>Option A</span><svg class="select-check">…</svg></div>
|
|
21
|
+
* </div>
|
|
22
|
+
* </div>
|
|
23
|
+
* </div>
|
|
24
|
+
*/
|
|
25
|
+
(function() {
|
|
26
|
+
'use strict';
|
|
27
|
+
|
|
28
|
+
/* ─── Utility: Close all open selects ─── */
|
|
29
|
+
function closeAllSelects(except) {
|
|
30
|
+
document.querySelectorAll('.select-open').forEach(function(el) {
|
|
31
|
+
if (el !== except) {
|
|
32
|
+
el.classList.remove('select-open');
|
|
33
|
+
var trigger = el.querySelector('.select-trigger');
|
|
34
|
+
if (trigger) trigger.setAttribute('aria-expanded', 'false');
|
|
35
|
+
el.classList.remove('select-flip-up');
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* ─── SINGLE SELECT ─── */
|
|
41
|
+
function initSingleSelect(selectEl) {
|
|
42
|
+
if (selectEl.classList.contains('select-disabled')) return;
|
|
43
|
+
|
|
44
|
+
var trigger = selectEl.querySelector('.select-trigger');
|
|
45
|
+
var dropdown = selectEl.querySelector('.select-dropdown');
|
|
46
|
+
var nativeSelect = selectEl.querySelector('select');
|
|
47
|
+
var searchInput = selectEl.querySelector('.select-search-input');
|
|
48
|
+
var options = selectEl.querySelectorAll('.select-option');
|
|
49
|
+
var placeholder = selectEl.querySelector('.select-placeholder');
|
|
50
|
+
var valueEl = selectEl.querySelector('.select-value');
|
|
51
|
+
|
|
52
|
+
if (!trigger || !dropdown || !nativeSelect) return;
|
|
53
|
+
|
|
54
|
+
if (nativeSelect.value) {
|
|
55
|
+
var initialOption = nativeSelect.options[nativeSelect.selectedIndex];
|
|
56
|
+
if (initialOption && initialOption.value) {
|
|
57
|
+
if (placeholder) placeholder.hidden = true;
|
|
58
|
+
if (valueEl) { valueEl.hidden = false; valueEl.textContent = initialOption.text; }
|
|
59
|
+
var matchingOpt = selectEl.querySelector('.select-option[data-value="' + initialOption.value + '"]');
|
|
60
|
+
if (matchingOpt) matchingOpt.classList.add('is-selected');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
trigger.addEventListener('click', function(e) {
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
var isOpen = selectEl.classList.contains('select-open');
|
|
67
|
+
if (isOpen) {
|
|
68
|
+
selectEl.classList.remove('select-open');
|
|
69
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
70
|
+
selectEl.classList.remove('select-flip-up');
|
|
71
|
+
} else {
|
|
72
|
+
closeAllSelects();
|
|
73
|
+
selectEl.classList.add('select-open');
|
|
74
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
75
|
+
if (searchInput) setTimeout(function() { searchInput.focus(); }, 50);
|
|
76
|
+
requestAnimationFrame(function() {
|
|
77
|
+
var rect = dropdown.getBoundingClientRect();
|
|
78
|
+
if (rect.bottom > window.innerHeight - 16) selectEl.classList.add('select-flip-up');
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
options.forEach(function(opt) {
|
|
84
|
+
opt.addEventListener('click', function(e) {
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
if (opt.classList.contains('is-disabled')) return;
|
|
87
|
+
var val = opt.getAttribute('data-value');
|
|
88
|
+
var text = opt.querySelector('span').textContent;
|
|
89
|
+
options.forEach(function(o) { o.classList.remove('is-selected'); });
|
|
90
|
+
opt.classList.add('is-selected');
|
|
91
|
+
nativeSelect.value = val;
|
|
92
|
+
if (placeholder) placeholder.hidden = true;
|
|
93
|
+
if (valueEl) { valueEl.hidden = false; valueEl.textContent = text; }
|
|
94
|
+
selectEl.classList.remove('select-open');
|
|
95
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
96
|
+
selectEl.classList.remove('select-flip-up');
|
|
97
|
+
if (searchInput) { searchInput.value = ''; options.forEach(function(o) { o.classList.remove('is-hidden'); }); }
|
|
98
|
+
nativeSelect.dispatchEvent(new Event('change', { bubbles: true }));
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (searchInput) {
|
|
103
|
+
searchInput.addEventListener('input', function(e) {
|
|
104
|
+
e.stopPropagation();
|
|
105
|
+
var query = searchInput.value.toLowerCase().trim();
|
|
106
|
+
options.forEach(function(opt) {
|
|
107
|
+
var text = opt.querySelector('span').textContent.toLowerCase();
|
|
108
|
+
opt.classList.toggle('is-hidden', query && text.indexOf(query) === -1);
|
|
109
|
+
});
|
|
110
|
+
selectEl.querySelectorAll('.select-group-label').forEach(function(label) {
|
|
111
|
+
var next = label.nextElementSibling, hasVisible = false;
|
|
112
|
+
while (next && !next.classList.contains('select-group-label')) {
|
|
113
|
+
if (next.classList.contains('select-option') && !next.classList.contains('is-hidden')) { hasVisible = true; break; }
|
|
114
|
+
next = next.nextElementSibling;
|
|
115
|
+
}
|
|
116
|
+
label.style.display = hasVisible ? '' : 'none';
|
|
117
|
+
});
|
|
118
|
+
options.forEach(function(o) { o.classList.remove('is-focused'); });
|
|
119
|
+
});
|
|
120
|
+
searchInput.addEventListener('click', function(e) { e.stopPropagation(); });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
trigger.addEventListener('keydown', function(e) {
|
|
124
|
+
var isOpen = selectEl.classList.contains('select-open');
|
|
125
|
+
var visibleOptions = Array.from(options).filter(function(o) { return !o.classList.contains('is-hidden') && !o.classList.contains('is-disabled'); });
|
|
126
|
+
if (!isOpen && (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown')) { e.preventDefault(); trigger.click(); return; }
|
|
127
|
+
if (isOpen) {
|
|
128
|
+
var focusedOpt = selectEl.querySelector('.select-option.is-focused');
|
|
129
|
+
var focusedIdx = visibleOptions.indexOf(focusedOpt);
|
|
130
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); if (focusedOpt) focusedOpt.classList.remove('is-focused'); var n = focusedIdx < visibleOptions.length - 1 ? focusedIdx + 1 : 0; visibleOptions[n].classList.add('is-focused'); visibleOptions[n].scrollIntoView({ block: 'nearest' }); }
|
|
131
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); if (focusedOpt) focusedOpt.classList.remove('is-focused'); var p = focusedIdx > 0 ? focusedIdx - 1 : visibleOptions.length - 1; visibleOptions[p].classList.add('is-focused'); visibleOptions[p].scrollIntoView({ block: 'nearest' }); }
|
|
132
|
+
else if (e.key === 'Enter') { e.preventDefault(); if (focusedOpt) focusedOpt.click(); }
|
|
133
|
+
else if (e.key === 'Escape') { e.preventDefault(); selectEl.classList.remove('select-open'); trigger.setAttribute('aria-expanded', 'false'); selectEl.classList.remove('select-flip-up'); }
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
document.addEventListener('click', function(e) {
|
|
138
|
+
if (!selectEl.contains(e.target)) {
|
|
139
|
+
selectEl.classList.remove('select-open');
|
|
140
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
141
|
+
selectEl.classList.remove('select-flip-up');
|
|
142
|
+
if (searchInput) { searchInput.value = ''; options.forEach(function(o) { o.classList.remove('is-hidden'); }); }
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ─── MULTISELECT ─── */
|
|
148
|
+
function initMultiselect(multiEl) {
|
|
149
|
+
if (multiEl.classList.contains('select-disabled')) return;
|
|
150
|
+
|
|
151
|
+
var trigger = multiEl.querySelector('.select-trigger');
|
|
152
|
+
var dropdown = multiEl.querySelector('.select-dropdown');
|
|
153
|
+
var nativeSelect = multiEl.querySelector('select');
|
|
154
|
+
var options = multiEl.querySelectorAll('.select-option');
|
|
155
|
+
var tagsContainer = multiEl.querySelector('.multiselect-tags');
|
|
156
|
+
var searchInput = multiEl.querySelector('.multiselect-search-input');
|
|
157
|
+
var placeholder = multiEl.querySelector('.multiselect-tag-placeholder');
|
|
158
|
+
var MAX_VISIBLE = 2;
|
|
159
|
+
var selectedValues = [];
|
|
160
|
+
|
|
161
|
+
if (!trigger || !dropdown || !nativeSelect || !tagsContainer) return;
|
|
162
|
+
|
|
163
|
+
Array.from(nativeSelect.selectedOptions).forEach(function(opt) { selectedValues.push(opt.value); });
|
|
164
|
+
|
|
165
|
+
function renderTags() {
|
|
166
|
+
tagsContainer.querySelectorAll('.multiselect-tag, .multiselect-counter').forEach(function(el) { el.remove(); });
|
|
167
|
+
if (selectedValues.length === 0) { if (placeholder) placeholder.style.display = ''; return; }
|
|
168
|
+
if (placeholder) placeholder.style.display = 'none';
|
|
169
|
+
var visibleCount = Math.min(selectedValues.length, MAX_VISIBLE);
|
|
170
|
+
for (var i = 0; i < visibleCount; i++) {
|
|
171
|
+
var val = selectedValues[i];
|
|
172
|
+
var optEl = multiEl.querySelector('.select-option[data-value="' + val + '"]');
|
|
173
|
+
var text = optEl ? optEl.querySelector('span').textContent : val;
|
|
174
|
+
var tag = document.createElement('span');
|
|
175
|
+
tag.className = 'multiselect-tag';
|
|
176
|
+
tag.setAttribute('data-value', val);
|
|
177
|
+
tag.innerHTML = '<span class="multiselect-tag-label">' + text + '</span>' +
|
|
178
|
+
'<button class="multiselect-tag-remove" type="button" aria-label="Remove">' +
|
|
179
|
+
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>';
|
|
180
|
+
tagsContainer.insertBefore(tag, searchInput);
|
|
181
|
+
tag.querySelector('.multiselect-tag-remove').addEventListener('click', function(e) { e.stopPropagation(); removeValue(val); });
|
|
182
|
+
}
|
|
183
|
+
var remaining = selectedValues.length - MAX_VISIBLE;
|
|
184
|
+
if (remaining > 0) {
|
|
185
|
+
var counter = document.createElement('span');
|
|
186
|
+
counter.className = 'multiselect-counter';
|
|
187
|
+
counter.textContent = '+' + remaining;
|
|
188
|
+
tagsContainer.insertBefore(counter, searchInput);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function removeValue(val) { selectedValues = selectedValues.filter(function(v) { return v !== val; }); updateNativeSelect(); renderTags(); var o = multiEl.querySelector('.select-option[data-value="' + val + '"]'); if (o) o.classList.remove('is-selected'); }
|
|
193
|
+
function addValue(val) { if (selectedValues.indexOf(val) === -1) selectedValues.push(val); updateNativeSelect(); renderTags(); var o = multiEl.querySelector('.select-option[data-value="' + val + '"]'); if (o) o.classList.add('is-selected'); }
|
|
194
|
+
function updateNativeSelect() { Array.from(nativeSelect.options).forEach(function(opt) { opt.selected = selectedValues.indexOf(opt.value) !== -1; }); nativeSelect.dispatchEvent(new Event('change', { bubbles: true })); }
|
|
195
|
+
|
|
196
|
+
function openDropdown() {
|
|
197
|
+
closeAllSelects();
|
|
198
|
+
multiEl.classList.add('select-open');
|
|
199
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
200
|
+
if (searchInput) { searchInput.style.display = ''; setTimeout(function() { searchInput.focus(); }, 50); }
|
|
201
|
+
requestAnimationFrame(function() {
|
|
202
|
+
var rect = dropdown.getBoundingClientRect();
|
|
203
|
+
if (rect.bottom > window.innerHeight - 16) multiEl.classList.add('select-flip-up');
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function closeDropdown() {
|
|
208
|
+
multiEl.classList.remove('select-open');
|
|
209
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
210
|
+
multiEl.classList.remove('select-flip-up');
|
|
211
|
+
if (selectedValues.length === 0 && searchInput) searchInput.style.display = 'none';
|
|
212
|
+
if (searchInput) { searchInput.value = ''; options.forEach(function(o) { o.classList.remove('is-hidden'); }); }
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
trigger.addEventListener('click', function(e) { e.stopPropagation(); multiEl.classList.contains('select-open') ? closeDropdown() : openDropdown(); });
|
|
216
|
+
|
|
217
|
+
options.forEach(function(opt) {
|
|
218
|
+
opt.addEventListener('click', function(e) {
|
|
219
|
+
e.stopPropagation();
|
|
220
|
+
if (opt.classList.contains('is-disabled')) return;
|
|
221
|
+
var val = opt.getAttribute('data-value');
|
|
222
|
+
opt.classList.contains('is-selected') ? removeValue(val) : addValue(val);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
if (searchInput) {
|
|
227
|
+
searchInput.addEventListener('input', function(e) {
|
|
228
|
+
e.stopPropagation();
|
|
229
|
+
var query = searchInput.value.toLowerCase().trim();
|
|
230
|
+
options.forEach(function(opt) { var t = opt.querySelector('span').textContent.toLowerCase(); opt.classList.toggle('is-hidden', query && t.indexOf(query) === -1); });
|
|
231
|
+
multiEl.querySelectorAll('.select-group-label').forEach(function(label) {
|
|
232
|
+
var next = label.nextElementSibling, hasVisible = false;
|
|
233
|
+
while (next && !next.classList.contains('select-group-label')) { if (next.classList.contains('select-option') && !next.classList.contains('is-hidden')) { hasVisible = true; break; } next = next.nextElementSibling; }
|
|
234
|
+
label.style.display = hasVisible ? '' : 'none';
|
|
235
|
+
});
|
|
236
|
+
options.forEach(function(o) { o.classList.remove('is-focused'); });
|
|
237
|
+
});
|
|
238
|
+
searchInput.addEventListener('click', function(e) { e.stopPropagation(); });
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
var selectAllBtn = multiEl.querySelector('.multiselect-select-all');
|
|
242
|
+
if (selectAllBtn) selectAllBtn.addEventListener('click', function(e) { e.stopPropagation(); options.forEach(function(opt) { if (!opt.classList.contains('is-disabled')) { addValue(opt.getAttribute('data-value')); opt.classList.add('is-selected'); } }); });
|
|
243
|
+
|
|
244
|
+
var clearAllBtn = multiEl.querySelector('.multiselect-clear-all');
|
|
245
|
+
if (clearAllBtn) clearAllBtn.addEventListener('click', function(e) { e.stopPropagation(); selectedValues = []; updateNativeSelect(); renderTags(); options.forEach(function(opt) { opt.classList.remove('is-selected'); }); });
|
|
246
|
+
|
|
247
|
+
trigger.addEventListener('keydown', function(e) {
|
|
248
|
+
var isOpen = multiEl.classList.contains('select-open');
|
|
249
|
+
var visibleOptions = Array.from(options).filter(function(o) { return !o.classList.contains('is-hidden') && !o.classList.contains('is-disabled'); });
|
|
250
|
+
if (!isOpen && (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown')) { e.preventDefault(); openDropdown(); return; }
|
|
251
|
+
if (isOpen) {
|
|
252
|
+
var focusedOpt = multiEl.querySelector('.select-option.is-focused');
|
|
253
|
+
var focusedIdx = visibleOptions.indexOf(focusedOpt);
|
|
254
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); if (focusedOpt) focusedOpt.classList.remove('is-focused'); var n = focusedIdx < visibleOptions.length - 1 ? focusedIdx + 1 : 0; visibleOptions[n].classList.add('is-focused'); visibleOptions[n].scrollIntoView({ block: 'nearest' }); }
|
|
255
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); if (focusedOpt) focusedOpt.classList.remove('is-focused'); var p = focusedIdx > 0 ? focusedIdx - 1 : visibleOptions.length - 1; visibleOptions[p].classList.add('is-focused'); visibleOptions[p].scrollIntoView({ block: 'nearest' }); }
|
|
256
|
+
else if (e.key === 'Enter') { e.preventDefault(); if (focusedOpt) focusedOpt.click(); }
|
|
257
|
+
else if (e.key === 'Escape') { e.preventDefault(); closeDropdown(); }
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
renderTags();
|
|
262
|
+
document.addEventListener('click', function(e) { if (!multiEl.contains(e.target)) closeDropdown(); });
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* ─── Init on DOM ready ─── */
|
|
266
|
+
function init() {
|
|
267
|
+
document.querySelectorAll('[data-select]').forEach(initSingleSelect);
|
|
268
|
+
document.querySelectorAll('[data-multiselect]').forEach(initMultiselect);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); }
|
|
272
|
+
})();
|
package/src/js/toast.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minora — Toast Manager
|
|
3
|
+
* ──────────────────────
|
|
4
|
+
* Queue-based toast system with position control,
|
|
5
|
+
* auto-dismiss, progress bar, and action buttons.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ToastManager.show({ type: 'success', message: 'Saved!' });
|
|
9
|
+
* ToastManager.show({ type: 'error', message: 'Failed', duration: 6000 });
|
|
10
|
+
* ToastManager.show({ type: 'info', message: 'Hint', action: { label: 'Undo', onClick: fn } });
|
|
11
|
+
* ToastManager.setPosition('top-left');
|
|
12
|
+
* ToastManager.clearAll();
|
|
13
|
+
*/
|
|
14
|
+
(function() {
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
var ToastManager = (function() {
|
|
18
|
+
var queue = [];
|
|
19
|
+
var active = [];
|
|
20
|
+
var stackEl = null;
|
|
21
|
+
var position = 'bottom-right';
|
|
22
|
+
var MAX_VISIBLE = 5;
|
|
23
|
+
var DEFAULT_DURATION = 4000;
|
|
24
|
+
|
|
25
|
+
/* SVG icons by type */
|
|
26
|
+
var ICONS = {
|
|
27
|
+
success: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>',
|
|
28
|
+
error: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>',
|
|
29
|
+
warning: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>',
|
|
30
|
+
info: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>',
|
|
31
|
+
neutral: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"></path><polyline points="17 21 17 13 7 13 7 21"></polyline><polyline points="7 3 7 8 15 8"></polyline></svg>',
|
|
32
|
+
loading: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" stroke-dasharray="20" stroke-dashoffset="15"></circle></svg>'
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function init() {
|
|
36
|
+
if (!stackEl) {
|
|
37
|
+
stackEl = document.createElement('div');
|
|
38
|
+
stackEl.className = 'toast-stack toast-stack-' + position;
|
|
39
|
+
stackEl.id = 'toast-stack';
|
|
40
|
+
document.body.appendChild(stackEl);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function show(opts) {
|
|
45
|
+
opts = opts || {};
|
|
46
|
+
var type = opts.type || 'neutral';
|
|
47
|
+
var message = opts.message || '';
|
|
48
|
+
var duration = opts.duration || DEFAULT_DURATION;
|
|
49
|
+
var action = opts.action || null;
|
|
50
|
+
var item = { type: type, message: message, duration: duration, action: action };
|
|
51
|
+
|
|
52
|
+
if (active.length < MAX_VISIBLE) {
|
|
53
|
+
renderToast(item);
|
|
54
|
+
} else {
|
|
55
|
+
queue.push(item);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function renderToast(item) {
|
|
60
|
+
init();
|
|
61
|
+
|
|
62
|
+
var toast = document.createElement('div');
|
|
63
|
+
toast.className = 'toast toast-' + item.type + ' toast-enter';
|
|
64
|
+
toast.setAttribute('role', 'alert');
|
|
65
|
+
toast.setAttribute('aria-live', 'assertive');
|
|
66
|
+
|
|
67
|
+
var actionHTML = item.action
|
|
68
|
+
? '<button class="toast-action" data-action="1">' + item.action.label + '</button>'
|
|
69
|
+
: '';
|
|
70
|
+
|
|
71
|
+
toast.innerHTML =
|
|
72
|
+
'<span class="toast-icon">' + (ICONS[item.type] || ICONS.neutral) + '</span>' +
|
|
73
|
+
'<div class="toast-body">' +
|
|
74
|
+
'<span class="toast-message">' + item.message + '</span>' +
|
|
75
|
+
actionHTML +
|
|
76
|
+
'</div>' +
|
|
77
|
+
'<button class="toast-close" aria-label="Close">' +
|
|
78
|
+
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>' +
|
|
79
|
+
'</button>' +
|
|
80
|
+
(item.type !== 'loading' ? '<div class="toast-progress running" style="animation-duration:' + item.duration + 'ms"></div>' : '<div class="toast-progress"></div>');
|
|
81
|
+
|
|
82
|
+
var closeBtn = toast.querySelector('.toast-close');
|
|
83
|
+
closeBtn.addEventListener('click', function() { dismissToast(toast); });
|
|
84
|
+
|
|
85
|
+
var actionBtn = toast.querySelector('.toast-action');
|
|
86
|
+
if (actionBtn && item.action && item.action.onClick) {
|
|
87
|
+
actionBtn.addEventListener('click', function() { dismissToast(toast); item.action.onClick(); });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var progressEl = toast.querySelector('.toast-progress.running');
|
|
91
|
+
if (progressEl) {
|
|
92
|
+
toast.addEventListener('mouseenter', function() { progressEl.style.animationPlayState = 'paused'; });
|
|
93
|
+
toast.addEventListener('mouseleave', function() { progressEl.style.animationPlayState = 'running'; });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
stackEl.appendChild(toast);
|
|
97
|
+
active.push(toast);
|
|
98
|
+
|
|
99
|
+
if (item.type !== 'loading') {
|
|
100
|
+
toast._dismissTimer = setTimeout(function() { dismissToast(toast); }, item.duration + 200);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function dismissToast(toast) {
|
|
105
|
+
clearTimeout(toast._dismissTimer);
|
|
106
|
+
toast.classList.remove('toast-enter');
|
|
107
|
+
toast.classList.add('toast-exit');
|
|
108
|
+
toast.addEventListener('animationend', function handler() {
|
|
109
|
+
toast.removeEventListener('animationend', handler);
|
|
110
|
+
if (toast.parentNode) toast.parentNode.removeChild(toast);
|
|
111
|
+
var idx = active.indexOf(toast);
|
|
112
|
+
if (idx !== -1) active.splice(idx, 1);
|
|
113
|
+
processQueue();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function processQueue() {
|
|
118
|
+
while (queue.length > 0 && active.length < MAX_VISIBLE) {
|
|
119
|
+
renderToast(queue.shift());
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function clearAll() {
|
|
124
|
+
active.slice().forEach(function(t) { dismissToast(t); });
|
|
125
|
+
queue = [];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function setPosition(pos) {
|
|
129
|
+
position = pos;
|
|
130
|
+
if (stackEl) {
|
|
131
|
+
stackEl.className = 'toast-stack';
|
|
132
|
+
stackEl.classList.add('toast-stack-' + position);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { show: show, clearAll: clearAll, setPosition: setPosition };
|
|
137
|
+
})();
|
|
138
|
+
|
|
139
|
+
window.ToastManager = ToastManager;
|
|
140
|
+
})();
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minora — Tooltip & Popover Manager
|
|
3
|
+
* ───────────────────────────────────
|
|
4
|
+
* Tooltips with 9 positions, auto-flip, rich content,
|
|
5
|
+
* interactive variants, and click-triggered popovers.
|
|
6
|
+
*
|
|
7
|
+
* Usage (tooltip):
|
|
8
|
+
* data-tooltip="text"
|
|
9
|
+
* data-tooltip-title="Title" data-tooltip-body="Body text"
|
|
10
|
+
* data-tooltip-position="top|bottom|left|right|top-start|..."
|
|
11
|
+
* data-tooltip-variant="light"
|
|
12
|
+
* data-tooltip-trigger="hover|focus|click|hover-focus"
|
|
13
|
+
* data-tooltip-interactive
|
|
14
|
+
*
|
|
15
|
+
* Usage (popover):
|
|
16
|
+
* data-popover="popover-id" data-popover-position="bottom|top|bottom-end|..."
|
|
17
|
+
*/
|
|
18
|
+
(function() {
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
var ICONS = {
|
|
22
|
+
info: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="16" x2="12" y2="12"></line><line x1="12" y1="8" x2="12.01" y2="8"></line></svg>',
|
|
23
|
+
star: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>',
|
|
24
|
+
check: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>',
|
|
25
|
+
alert: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/* ─── TooltipManager ─── */
|
|
29
|
+
var TooltipManager = (function() {
|
|
30
|
+
var tooltips = [];
|
|
31
|
+
|
|
32
|
+
function escapeHtml(str) { var div = document.createElement('div'); div.textContent = str; return div.innerHTML; }
|
|
33
|
+
|
|
34
|
+
function buildContent(trigger) {
|
|
35
|
+
var text = trigger.getAttribute('data-tooltip');
|
|
36
|
+
var title = trigger.getAttribute('data-tooltip-title');
|
|
37
|
+
var body = trigger.getAttribute('data-tooltip-body');
|
|
38
|
+
var icon = trigger.getAttribute('data-tooltip-icon');
|
|
39
|
+
var isInteractive = trigger.hasAttribute('data-tooltip-interactive');
|
|
40
|
+
var html = '<span class="tooltip-arrow"></span><div>';
|
|
41
|
+
if (title || body) {
|
|
42
|
+
html += '<span class="tooltip-rich">';
|
|
43
|
+
if (title) html += '<span class="tooltip-title">' + escapeHtml(title) + '</span>';
|
|
44
|
+
if (body) html += '<span class="tooltip-body">' + escapeHtml(body) + '</span>';
|
|
45
|
+
html += '</span>';
|
|
46
|
+
} else if (icon) {
|
|
47
|
+
html += '<span class="tooltip-with-icon"><span class="tooltip-icon-img">' + (ICONS[icon] || ICONS.info) + '</span><span>' + escapeHtml(text) + '</span></span>';
|
|
48
|
+
} else if (text) { html += escapeHtml(text); }
|
|
49
|
+
if (isInteractive) {
|
|
50
|
+
html += '<div class="tooltip-actions"><button class="tooltip-action-btn" data-tooltip-action>Learn More</button><button class="tooltip-action-btn" data-tooltip-dismiss>Dismiss</button></div>';
|
|
51
|
+
}
|
|
52
|
+
return html + '</div>';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function positionTooltip(trigger, tooltip, position) {
|
|
56
|
+
var triggerRect = trigger.getBoundingClientRect();
|
|
57
|
+
var tooltipRect = tooltip.getBoundingClientRect();
|
|
58
|
+
var gap = 10;
|
|
59
|
+
var basePos = position.replace(/-(start|end)$/, '');
|
|
60
|
+
var align = position.indexOf('-start') !== -1 ? 'start' : position.indexOf('-end') !== -1 ? 'end' : 'center';
|
|
61
|
+
var top, left;
|
|
62
|
+
|
|
63
|
+
switch (basePos) {
|
|
64
|
+
case 'top': top = triggerRect.top - gap - tooltipRect.height; left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2; break;
|
|
65
|
+
case 'bottom': top = triggerRect.bottom + gap; left = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2; break;
|
|
66
|
+
case 'left': top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2; left = triggerRect.left - gap - tooltipRect.width; break;
|
|
67
|
+
case 'right': top = triggerRect.top + triggerRect.height / 2 - tooltipRect.height / 2; left = triggerRect.right + gap; break;
|
|
68
|
+
}
|
|
69
|
+
if (align === 'start') { if (basePos === 'top' || basePos === 'bottom') left = triggerRect.left; else top = triggerRect.top; }
|
|
70
|
+
else if (align === 'end') { if (basePos === 'top' || basePos === 'bottom') left = triggerRect.right - tooltipRect.width; else top = triggerRect.bottom - tooltipRect.height; }
|
|
71
|
+
|
|
72
|
+
if (top < 4 && basePos === 'top') { basePos = 'bottom'; top = triggerRect.bottom + gap; }
|
|
73
|
+
if (top + tooltipRect.height > window.innerHeight - 4 && basePos === 'bottom') { basePos = 'top'; top = triggerRect.top - gap - tooltipRect.height; }
|
|
74
|
+
if (left < 4 && basePos === 'left') { basePos = 'right'; left = triggerRect.right + gap; }
|
|
75
|
+
if (left + tooltipRect.width > window.innerWidth - 4 && basePos === 'right') { basePos = 'left'; left = triggerRect.left - gap - tooltipRect.width; }
|
|
76
|
+
|
|
77
|
+
left = Math.max(4, Math.min(left, window.innerWidth - tooltipRect.width - 4));
|
|
78
|
+
top = Math.max(4, Math.min(top, window.innerHeight - tooltipRect.height - 4));
|
|
79
|
+
tooltip.style.left = left + 'px';
|
|
80
|
+
tooltip.style.top = top + 'px';
|
|
81
|
+
|
|
82
|
+
var arrow = tooltip.querySelector('.tooltip-arrow');
|
|
83
|
+
if (arrow) {
|
|
84
|
+
if (basePos === 'top') { arrow.style.bottom = 'calc(var(--tooltip-arrow-size) * -1 + 1px)'; arrow.style.top = ''; var c = (triggerRect.left + triggerRect.width / 2) - left; arrow.style.left = Math.max(8, Math.min(c - 3, tooltipRect.width - 16)) + 'px'; arrow.style.right = ''; }
|
|
85
|
+
else if (basePos === 'bottom') { arrow.style.top = 'calc(var(--tooltip-arrow-size) * -1 + 1px)'; arrow.style.bottom = ''; var c2 = (triggerRect.left + triggerRect.width / 2) - left; arrow.style.left = Math.max(8, Math.min(c2 - 3, tooltipRect.width - 16)) + 'px'; arrow.style.right = ''; }
|
|
86
|
+
else if (basePos === 'left') { arrow.style.right = 'calc(var(--tooltip-arrow-size) * -1 + 1px)'; arrow.style.left = ''; var c3 = (triggerRect.top + triggerRect.height / 2) - top; arrow.style.top = Math.max(8, Math.min(c3 - 3, tooltipRect.height - 16)) + 'px'; arrow.style.bottom = ''; }
|
|
87
|
+
else if (basePos === 'right') { arrow.style.left = 'calc(var(--tooltip-arrow-size) * -1 + 1px)'; arrow.style.right = ''; var c4 = (triggerRect.top + triggerRect.height / 2) - top; arrow.style.top = Math.max(8, Math.min(c4 - 3, tooltipRect.height - 16)) + 'px'; arrow.style.bottom = ''; }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function show(trigger) {
|
|
92
|
+
hide(trigger);
|
|
93
|
+
var position = trigger.getAttribute('data-tooltip-position') || 'top';
|
|
94
|
+
var variant = trigger.getAttribute('data-tooltip-variant') || '';
|
|
95
|
+
var isInteractive = trigger.hasAttribute('data-tooltip-interactive');
|
|
96
|
+
var tooltip = document.createElement('div');
|
|
97
|
+
tooltip.className = 'tooltip tooltip-' + position;
|
|
98
|
+
if (variant === 'light') tooltip.classList.add('tooltip-light');
|
|
99
|
+
if (isInteractive) tooltip.classList.add('tooltip-interactive');
|
|
100
|
+
tooltip.setAttribute('role', 'tooltip');
|
|
101
|
+
tooltip.innerHTML = buildContent(trigger);
|
|
102
|
+
document.body.appendChild(tooltip);
|
|
103
|
+
positionTooltip(trigger, tooltip, position);
|
|
104
|
+
tooltip._showTimer = setTimeout(function() { tooltip.classList.add('is-visible'); }, 100);
|
|
105
|
+
tooltips.push({ trigger: trigger, tooltip: tooltip });
|
|
106
|
+
|
|
107
|
+
if (isInteractive) {
|
|
108
|
+
tooltip.addEventListener('mouseenter', function() { clearTimeout(tooltip._hideTimer); });
|
|
109
|
+
tooltip.addEventListener('mouseleave', function() { tooltip._hideTimer = setTimeout(function() { hide(trigger); }, 100); });
|
|
110
|
+
tooltip.addEventListener('click', function(e) {
|
|
111
|
+
if (e.target.hasAttribute('data-tooltip-dismiss')) hide(trigger);
|
|
112
|
+
if (e.target.hasAttribute('data-tooltip-action')) { hide(trigger); if (window.ToastManager) ToastManager.show({ type: 'info', message: 'Action clicked!' }); }
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function hide(trigger) {
|
|
118
|
+
var entry = tooltips.find(function(t) { return t.trigger === trigger; });
|
|
119
|
+
if (!entry) return;
|
|
120
|
+
clearTimeout(entry.tooltip._showTimer);
|
|
121
|
+
entry.tooltip.classList.remove('is-visible');
|
|
122
|
+
entry.tooltip._hideTimer = setTimeout(function() {
|
|
123
|
+
if (entry.tooltip.parentNode) entry.tooltip.parentNode.removeChild(entry.tooltip);
|
|
124
|
+
tooltips = tooltips.filter(function(t) { return t !== entry; });
|
|
125
|
+
}, 100);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function init() {
|
|
129
|
+
document.querySelectorAll('[data-tooltip]').forEach(function(trigger) {
|
|
130
|
+
var triggerType = trigger.getAttribute('data-tooltip-trigger') || 'hover';
|
|
131
|
+
if (triggerType === 'hover' || triggerType === 'hover-focus') {
|
|
132
|
+
trigger.addEventListener('mouseenter', function() { show(trigger); });
|
|
133
|
+
trigger.addEventListener('mouseleave', function() { hide(trigger); });
|
|
134
|
+
}
|
|
135
|
+
if (triggerType === 'focus' || triggerType === 'hover-focus') {
|
|
136
|
+
trigger.addEventListener('focus', function() { show(trigger); });
|
|
137
|
+
trigger.addEventListener('blur', function() { hide(trigger); });
|
|
138
|
+
}
|
|
139
|
+
if (triggerType === 'click') {
|
|
140
|
+
trigger.addEventListener('click', function(e) {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
var entry = tooltips.find(function(t) { return t.trigger === trigger; });
|
|
143
|
+
entry ? hide(trigger) : show(trigger);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
var scrollTimer;
|
|
148
|
+
window.addEventListener('scroll', function() {
|
|
149
|
+
clearTimeout(scrollTimer);
|
|
150
|
+
scrollTimer = setTimeout(function() { tooltips.slice().forEach(function(entry) { hide(entry.trigger); }); }, 50);
|
|
151
|
+
}, { passive: true });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return { init: init, show: show, hide: hide };
|
|
155
|
+
})();
|
|
156
|
+
|
|
157
|
+
/* ─── PopoverManager ─── */
|
|
158
|
+
var PopoverManager = (function() {
|
|
159
|
+
var openPopovers = [];
|
|
160
|
+
|
|
161
|
+
function positionPopover(trigger, popover, position) {
|
|
162
|
+
document.body.appendChild(popover);
|
|
163
|
+
var triggerRect = trigger.getBoundingClientRect();
|
|
164
|
+
var popoverRect = popover.getBoundingClientRect();
|
|
165
|
+
var gap = 8;
|
|
166
|
+
var pos = position || 'bottom';
|
|
167
|
+
var align = pos.indexOf('-end') !== -1 ? 'end' : pos.indexOf('-start') !== -1 ? 'start' : 'center';
|
|
168
|
+
var base = pos.replace(/-(start|end)$/, '');
|
|
169
|
+
var top, left;
|
|
170
|
+
|
|
171
|
+
if (base === 'bottom') { top = triggerRect.bottom + gap; if (align === 'end') left = triggerRect.right - popoverRect.width; else if (align === 'start') left = triggerRect.left; else left = triggerRect.left + triggerRect.width / 2 - popoverRect.width / 2; }
|
|
172
|
+
else if (base === 'top') { top = triggerRect.top - gap - popoverRect.height; if (align === 'end') left = triggerRect.right - popoverRect.width; else if (align === 'start') left = triggerRect.left; else left = triggerRect.left + triggerRect.width / 2 - popoverRect.width / 2; }
|
|
173
|
+
|
|
174
|
+
left = Math.max(8, Math.min(left, window.innerWidth - popoverRect.width - 8));
|
|
175
|
+
top = Math.max(8, Math.min(top, window.innerHeight - popoverRect.height - 8));
|
|
176
|
+
popover.style.left = left + 'px';
|
|
177
|
+
popover.style.top = top + 'px';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function show(trigger, popoverId, position) {
|
|
181
|
+
var popover = document.getElementById(popoverId);
|
|
182
|
+
if (!popover) return;
|
|
183
|
+
closeAll();
|
|
184
|
+
popover.classList.add('is-visible');
|
|
185
|
+
popover.classList.remove('is-hidden');
|
|
186
|
+
openPopovers.push(popover);
|
|
187
|
+
positionPopover(trigger, popover, position);
|
|
188
|
+
popover._closeHandler = function(e) { if (!popover.contains(e.target) && e.target !== trigger && !trigger.contains(e.target)) close(popoverId); };
|
|
189
|
+
setTimeout(function() { document.addEventListener('click', popover._closeHandler); }, 0);
|
|
190
|
+
popover.querySelectorAll('[data-popover-close]').forEach(function(btn) { btn.addEventListener('click', function() { close(popoverId); }); });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function close(popoverId) {
|
|
194
|
+
var popover = document.getElementById(popoverId);
|
|
195
|
+
if (!popover) return;
|
|
196
|
+
popover.classList.remove('is-visible');
|
|
197
|
+
popover.classList.add('is-hidden');
|
|
198
|
+
if (popover._closeHandler) document.removeEventListener('click', popover._closeHandler);
|
|
199
|
+
openPopovers = openPopovers.filter(function(p) { return p !== popover; });
|
|
200
|
+
setTimeout(function() { popover.classList.remove('is-hidden'); }, 200);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function closeAll() { openPopovers.slice().forEach(function(popover) { close(popover.id); }); }
|
|
204
|
+
|
|
205
|
+
function init() {
|
|
206
|
+
document.querySelectorAll('[data-popover]').forEach(function(trigger) {
|
|
207
|
+
var popoverId = trigger.getAttribute('data-popover');
|
|
208
|
+
var position = trigger.getAttribute('data-popover-position') || 'bottom';
|
|
209
|
+
trigger.addEventListener('click', function(e) {
|
|
210
|
+
e.stopPropagation();
|
|
211
|
+
var popover = document.getElementById(popoverId);
|
|
212
|
+
if (popover && popover.classList.contains('is-visible')) close(popoverId); else show(trigger, popoverId, position);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return { init: init, close: close, closeAll: closeAll };
|
|
218
|
+
})();
|
|
219
|
+
|
|
220
|
+
window.TooltipManager = TooltipManager;
|
|
221
|
+
window.PopoverManager = PopoverManager;
|
|
222
|
+
|
|
223
|
+
if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function() { TooltipManager.init(); PopoverManager.init(); }); } else { TooltipManager.init(); PopoverManager.init(); }
|
|
224
|
+
})();
|