@aw-webflow/pricing_page_js 1.0.1 → 1.2.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/.claude/settings.local.json +5 -1
- package/package.json +1 -1
- package/script.js +204 -0
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
"Bash(gh release create v1.0.0 --title v1.0.0 --notes ' *)",
|
|
20
20
|
"Bash(curl -sL \"https://atomicwork.webflow.io/pricing-new?cb=$\\(date +%s\\)\" -o live.html)",
|
|
21
21
|
"Bash(curl -sL \"https://cdn.prod.website-files.com/64f08da4e7effe6dcb06d456/css/atomicwork.6a195ea2d503d973ad3d9f0b.6d732586d.opt.min.css\" -o page.css)",
|
|
22
|
-
"Bash(gh release create v1.0.1 --title v1.0.1 --notes ' *)"
|
|
22
|
+
"Bash(gh release create v1.0.1 --title v1.0.1 --notes ' *)",
|
|
23
|
+
"Bash(gh release create v1.1.0 --title v1.1.0 --notes ' *)",
|
|
24
|
+
"Bash(npm view *)",
|
|
25
|
+
"mcp__chrome-devtools__evaluate_script",
|
|
26
|
+
"Bash(git commit -m ' *)"
|
|
23
27
|
]
|
|
24
28
|
}
|
|
25
29
|
}
|
package/package.json
CHANGED
package/script.js
CHANGED
|
@@ -219,3 +219,207 @@
|
|
|
219
219
|
bootstrap();
|
|
220
220
|
}
|
|
221
221
|
})();
|
|
222
|
+
|
|
223
|
+
/* Tooltips
|
|
224
|
+
*
|
|
225
|
+
* Markup built in Webflow (positioning + styling are Webflow's job):
|
|
226
|
+
*
|
|
227
|
+
* .tooltip-wrap (position: relative)
|
|
228
|
+
* .tooltip-trigger (the hover/tap target)
|
|
229
|
+
* .tooltip-content (the bubble, hidden by default)
|
|
230
|
+
*
|
|
231
|
+
* This script only toggles classes:
|
|
232
|
+
* - .tooltip-content gets `is-visible`
|
|
233
|
+
* - .tooltip-wrap gets `is-open`
|
|
234
|
+
* Style the visible state in Webflow off either of those.
|
|
235
|
+
*
|
|
236
|
+
* Behaviour: hover on devices that support it; tap-to-toggle on touch
|
|
237
|
+
* devices (with outside-tap + Escape to close). Keyboard focus also opens.
|
|
238
|
+
* Auto-wires every .tooltip-wrap on the page, including ones injected later
|
|
239
|
+
* (e.g. Finsweet table rows).
|
|
240
|
+
*
|
|
241
|
+
* ES5 only (var / no arrow functions) for browser compatibility.
|
|
242
|
+
*/
|
|
243
|
+
(function () {
|
|
244
|
+
'use strict';
|
|
245
|
+
|
|
246
|
+
var WRAP_SELECTOR = '.tooltip-wrap';
|
|
247
|
+
var TRIGGER_SELECTOR = '.tooltip-trigger';
|
|
248
|
+
var CONTENT_SELECTOR = '.tooltip-content';
|
|
249
|
+
var VISIBLE_CLASS = 'is-visible';
|
|
250
|
+
var OPEN_CLASS = 'is-open';
|
|
251
|
+
var INIT_FLAG = 'awTooltipBound';
|
|
252
|
+
// grace period (ms) for the cursor to travel from the trigger across any
|
|
253
|
+
// gap onto the bubble before it closes — lets users reach links inside.
|
|
254
|
+
var HIDE_DELAY = 250;
|
|
255
|
+
|
|
256
|
+
// Hover devices use mouseenter/leave; touch devices use tap-to-toggle.
|
|
257
|
+
var hoverCapable = !(
|
|
258
|
+
window.matchMedia && window.matchMedia('(hover: none)').matches
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
var uid = 0;
|
|
262
|
+
|
|
263
|
+
function matches(el, selector) {
|
|
264
|
+
if (!el || el.nodeType !== 1) return false;
|
|
265
|
+
var fn =
|
|
266
|
+
el.matches ||
|
|
267
|
+
el.webkitMatchesSelector ||
|
|
268
|
+
el.msMatchesSelector ||
|
|
269
|
+
el.mozMatchesSelector;
|
|
270
|
+
return fn ? fn.call(el, selector) : false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function closest(el, selector) {
|
|
274
|
+
while (el && el.nodeType === 1) {
|
|
275
|
+
if (matches(el, selector)) return el;
|
|
276
|
+
el = el.parentNode;
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function addClass(el, cls) {
|
|
282
|
+
if (el && el.className.indexOf(cls) === -1) el.className += ' ' + cls;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function removeClass(el, cls) {
|
|
286
|
+
if (el) {
|
|
287
|
+
el.className = el.className.replace(
|
|
288
|
+
new RegExp('\\s*\\b' + cls + '\\b', 'g'),
|
|
289
|
+
''
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function hide(wrap) {
|
|
295
|
+
if (!wrap) return;
|
|
296
|
+
removeClass(wrap.querySelector(CONTENT_SELECTOR), VISIBLE_CLASS);
|
|
297
|
+
removeClass(wrap, OPEN_CLASS);
|
|
298
|
+
var trigger = wrap.querySelector(TRIGGER_SELECTOR);
|
|
299
|
+
if (trigger) trigger.setAttribute('aria-expanded', 'false');
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function hideAll(except) {
|
|
303
|
+
var open = document.querySelectorAll(WRAP_SELECTOR + '.' + OPEN_CLASS);
|
|
304
|
+
for (var i = 0; i < open.length; i++) {
|
|
305
|
+
if (open[i] !== except) hide(open[i]);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function show(wrap) {
|
|
310
|
+
hideAll(wrap); // one at a time
|
|
311
|
+
addClass(wrap.querySelector(CONTENT_SELECTOR), VISIBLE_CLASS);
|
|
312
|
+
addClass(wrap, OPEN_CLASS);
|
|
313
|
+
var trigger = wrap.querySelector(TRIGGER_SELECTOR);
|
|
314
|
+
if (trigger) trigger.setAttribute('aria-expanded', 'true');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function toggle(wrap) {
|
|
318
|
+
if (wrap.className.indexOf(OPEN_CLASS) === -1) show(wrap);
|
|
319
|
+
else hide(wrap);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// delayed-close helpers so the cursor can cross the gap onto the bubble
|
|
323
|
+
function cancelHide(wrap) {
|
|
324
|
+
if (wrap.awHideTimer) {
|
|
325
|
+
window.clearTimeout(wrap.awHideTimer);
|
|
326
|
+
wrap.awHideTimer = null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function scheduleHide(wrap) {
|
|
331
|
+
cancelHide(wrap);
|
|
332
|
+
wrap.awHideTimer = window.setTimeout(function () {
|
|
333
|
+
wrap.awHideTimer = null;
|
|
334
|
+
hide(wrap);
|
|
335
|
+
}, HIDE_DELAY);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function bind(wrap) {
|
|
339
|
+
if (wrap[INIT_FLAG]) return;
|
|
340
|
+
var trigger = wrap.querySelector(TRIGGER_SELECTOR);
|
|
341
|
+
var content = wrap.querySelector(CONTENT_SELECTOR);
|
|
342
|
+
if (!trigger || !content) return; // incomplete markup, skip for now
|
|
343
|
+
|
|
344
|
+
wrap[INIT_FLAG] = true;
|
|
345
|
+
|
|
346
|
+
// accessibility wiring
|
|
347
|
+
if (!content.id) content.id = 'aw-tip-' + ++uid;
|
|
348
|
+
content.setAttribute('role', 'tooltip');
|
|
349
|
+
trigger.setAttribute('aria-describedby', content.id);
|
|
350
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
351
|
+
var tag = trigger.tagName;
|
|
352
|
+
if (!trigger.hasAttribute('tabindex') && tag !== 'BUTTON' && tag !== 'A') {
|
|
353
|
+
trigger.setAttribute('tabindex', '0');
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (hoverCapable) {
|
|
357
|
+
// mouseenter/leave on the wrap treat the trigger + bubble (a descendant)
|
|
358
|
+
// as one region; the delayed hide bridges any visual gap between them.
|
|
359
|
+
wrap.addEventListener('mouseenter', function () {
|
|
360
|
+
cancelHide(wrap);
|
|
361
|
+
show(wrap);
|
|
362
|
+
});
|
|
363
|
+
wrap.addEventListener('mouseleave', function () {
|
|
364
|
+
scheduleHide(wrap);
|
|
365
|
+
});
|
|
366
|
+
} else {
|
|
367
|
+
trigger.addEventListener('click', function (e) {
|
|
368
|
+
e.stopPropagation(); // don't trip the outside-tap handler below
|
|
369
|
+
toggle(wrap);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// keyboard focus opens; closing handled when focus leaves the wrap
|
|
374
|
+
wrap.addEventListener('focusin', function () {
|
|
375
|
+
show(wrap);
|
|
376
|
+
});
|
|
377
|
+
wrap.addEventListener('focusout', function (e) {
|
|
378
|
+
var to = e.relatedTarget;
|
|
379
|
+
if (!to || !wrap.contains(to)) hide(wrap);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function scan(root) {
|
|
384
|
+
var wraps = (root || document).querySelectorAll(WRAP_SELECTOR);
|
|
385
|
+
for (var i = 0; i < wraps.length; i++) bind(wraps[i]);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function init() {
|
|
389
|
+
scan(document);
|
|
390
|
+
|
|
391
|
+
// outside tap closes (tap mode only — hover mode closes on mouseleave)
|
|
392
|
+
document.addEventListener('click', function (e) {
|
|
393
|
+
if (hoverCapable) return;
|
|
394
|
+
if (!closest(e.target, WRAP_SELECTOR)) hideAll(null);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// Escape closes any open tooltip
|
|
398
|
+
document.addEventListener('keydown', function (e) {
|
|
399
|
+
var key = e.key || e.keyCode;
|
|
400
|
+
if (key === 'Escape' || key === 'Esc' || key === 27) hideAll(null);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// wire up tooltips injected after load (e.g. Finsweet table rows)
|
|
404
|
+
if (window.MutationObserver) {
|
|
405
|
+
var observer = new MutationObserver(function (mutations) {
|
|
406
|
+
for (var i = 0; i < mutations.length; i++) {
|
|
407
|
+
var added = mutations[i].addedNodes;
|
|
408
|
+
for (var j = 0; j < added.length; j++) {
|
|
409
|
+
var node = added[j];
|
|
410
|
+
if (!node || node.nodeType !== 1) continue;
|
|
411
|
+
if (matches(node, WRAP_SELECTOR)) bind(node);
|
|
412
|
+
if (node.querySelectorAll) scan(node);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (document.readyState === 'loading') {
|
|
421
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
422
|
+
} else {
|
|
423
|
+
init();
|
|
424
|
+
}
|
|
425
|
+
})();
|