PageSourceSearch

https://shagsmokes.com/wp-content/themes/shag-smokes-hello/assets/js/account-modal-1.1.16.js?ver=1.1.44

js shagsmokes.com collected 2026-10-09 21:48:43 UTC 4,812 bytes, 151 lines download raw bytes

1(function () {
2  'use strict';
3
4  function ready(callback) {
5    if (document.readyState === 'loading') {
6      document.addEventListener('DOMContentLoaded', callback);
7      return;
8    }
9
10    callback();
11  }
12
13  ready(function () {
14    var modal = document.querySelector('[data-ss-auth-modal]');
15    if (!modal) {
16      return;
17    }
18
19    var panel = modal.querySelector('[data-ss-auth-panel]');
20    var panes = Array.prototype.slice.call(modal.querySelectorAll('[data-ss-auth-pane]'));
21    var lastFocus = null;
22
23    function availableMode(mode) {
24      return panes.some(function (pane) {
25        return pane.getAttribute('data-ss-auth-pane') === mode;
26      }) ? mode : 'login';
27    }
28
29    function setMode(mode) {
30      mode = availableMode(mode);
31
32      panes.forEach(function (pane) {
33        var active = pane.getAttribute('data-ss-auth-pane') === mode;
34        pane.hidden = !active;
35      });
36
37      var title = modal.querySelector('#ss-auth-title-' + mode);
38      if (title) {
39        modal.setAttribute('aria-labelledby', title.id);
40      }
41
42      modal.setAttribute('data-ss-auth-current', mode);
43    }
44
45    function focusFirstField() {
46      var activePane = modal.querySelector('[data-ss-auth-pane]:not([hidden])');
47      var target = activePane ? activePane.querySelector('input:not([type="hidden"]), button, a[href]') : null;
48      if (target) {
49        target.focus();
50      }
51    }
52
53    function openModal(mode, trigger) {
54      lastFocus = trigger || document.activeElement;
55      setMode(mode || 'login');
56      modal.hidden = false;
57      modal.setAttribute('aria-hidden', 'false');
58      document.body.classList.add('ss-auth-modal-open');
59      document.querySelectorAll('[data-ss-auth-open]').forEach(function (item) {
60        item.setAttribute('aria-expanded', 'true');
61      });
62      window.requestAnimationFrame(focusFirstField);
63    }
64
65    function closeModal() {
66      modal.hidden = true;
67      modal.setAttribute('aria-hidden', 'true');
68      document.body.classList.remove('ss-auth-modal-open');
69      document.querySelectorAll('[data-ss-auth-open]').forEach(function (item) {
70        item.setAttribute('aria-expanded', 'false');
71      });
72
73      if (lastFocus && typeof lastFocus.focus === 'function') {
74        lastFocus.focus();
75      }
76    }
77
78    document.addEventListener('click', function (event) {
79      var opener = event.target.closest ? event.target.closest('[data-ss-auth-open]') : null;
80      if (opener) {
81        event.preventDefault();
82        openModal(opener.getAttribute('data-ss-auth-open'), opener);
83        return;
84      }
85
86      var switcher = event.target.closest ? event.target.closest('[data-ss-auth-switch]') : null;
87      if (switcher && modal.contains(switcher)) {
88        event.preventDefault();
89        setMode(switcher.getAttribute('data-ss-auth-switch'));
90        window.requestAnimationFrame(focusFirstField);
91        return;
92      }
93
94      var passwordToggle = event.target.closest ? event.target.closest('[data-ss-auth-password-toggle]') : null;
95      if (passwordToggle && modal.contains(passwordToggle)) {
96        var input = document.getElementById(passwordToggle.getAttribute('data-ss-auth-password-toggle'));
97        if (input) {
98          var showing = input.type === 'text';
99          input.type = showing ? 'password' : 'text';
100          passwordToggle.textContent = showing ? 'Show' : 'Hide';
101          input.focus();
102        }
103        return;
104      }
105
106      if ((event.target.closest && event.target.closest('[data-ss-auth-close]')) || event.target === modal) {
107        event.preventDefault();
108        closeModal();
109      }
110    });
111
112    document.addEventListener('keydown', function (event) {
113      if (modal.hidden) {
114        return;
115      }
116
117      if (event.key === 'Escape') {
118        event.preventDefault();
119        closeModal();
120        return;
121      }
122
123      if (event.key !== 'Tab' || !panel) {
124        return;
125      }
126
127      var focusable = Array.prototype.slice.call(panel.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled])')).filter(function (item) {
128        return !item.closest('[hidden]');
129      });
130
131      if (!focusable.length) {
132        return;
133      }
134
135      var first = focusable[0];
136      var last = focusable[focusable.length - 1];
137      if (event.shiftKey && document.activeElement === first) {
138        event.preventDefault();
139        last.focus();
140      } else if (!event.shiftKey && document.activeElement === last) {
141        event.preventDefault();
142        first.focus();
143      }
144    });
145
146    setMode(modal.getAttribute('data-ss-auth-initial') || 'login');
147    if (modal.getAttribute('data-ss-auth-open-on-load') === 'true') {
148      openModal(modal.getAttribute('data-ss-auth-initial') || 'login');
149    }
150  });
151}());

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.