PageSourceSearch

https://www.florsheim.com/shop/customers/resources/js/accessibility.js

js florsheim.com collected 2026-10-02 04:29:11 UTC 3,079 bytes, 108 lines download raw bytes

1/**
2 *  Mark a block of html entities as not participating in tab order and focus with class=unfocusable.
3 *  Mark a block of html entities as participating in tab order and focus with class=focusable.
4 *  When focusable and unfocusable blocks overlap unfocusable takes precendence.
5 *  Mark error messages with attribute alert to notify screen reader to immediately read.
6 *  Restore element focus following partial ajax refresh.
7 *  @param {boolean} workflow start with focus on first control within first class=focusable region
8 **/
9function setAccessibility(workflow = true) {
10  if (!accessibility) {
11    return; // off switch
12  }
13  root = $(".focusable");
14  root.ready(function () {
15    msgs = $(".msg, .msgAllCart");
16    msgs.attr("role", "alert");
17    if (refocus) {
18      restoreFocus();
19    }
20  });
21  focusables = root.find("input[type!=hidden], select, a");
22  if (workflow) {
23    if (focusables.length > 0) {
24      focusables.first().focus();
25    }
26  }
27  if (refocus) {
28    focusables.focus(function () {
29      markFocus();
30    });
31  }
32
33  root = $(".unfocusable");
34  nonfocusables = root.find("input[type!=hidden], select, a");
35  for (tabIndex = 0; tabIndex < nonfocusables.length; tabIndex++) {
36    nonfocusable = nonfocusables[tabIndex];
37    nonfocusable.setAttribute("tabindex", -1);
38}
39}
40function markFocus() {
41  tempFocused = $(":focus").first().attr("id");
42  if (tempFocused !== undefined) {
43    focused = $.escapeSelector(tempFocused);
44  }
45}
46function restoreFocus() {
47  if (focused !== undefined) {
48    theseElements = $("#" + focused);
49    if (theseElements !== undefined) {
50      thisElement = theseElements.first();
51      if (thisElement.is(":visible")) {
52        thisElement.focus();
53      } else {
54        focusables = root.find("input[type!=hidden], select, a");
55        if (focusables.length > 0) {
56          focusables.first().focus();
57        }
58      }
59    }
60  }
61}
62
63var focused = undefined;
64
65// configuration
66/**
67 * @param accessibility an on/off switch for all features
68 * @param refocus retain focus on last control even through ajax partial refresh
69 */
70var accessibility = true;
71var refocus = true;
72
73function setCheckoutFocus(data) {
74  if (data !== undefined && data.status !== "success") {
75    return;
76  }
77
78  try {
79    if (document.getElementById(data.source.id) !== null) {
80      document.getElementById(data.source.id).focus();
81      accessibility = false;
82      refocus = false;
83    }
84  } catch (e) {
85    console.log(e);
86  }
87}
88
89//**Seciont for adding focus to dropdown cart for accessibility
90function findCart() {
91    var cart = $('#sidebar');
92
93    if (cart) {
94        var focusables = cart.find("input[type!=hidden], select, a, i");
95        var cartProducts = $('#main\\:cartItems');
96
97        if (focusables.length !== 0) {
98            focusables.first().focus();
99        } 
100    }
101}
102
103$("#sidebarCollapse #productAdd").on('keydown', function (event) {
104    if (event.keyCode === 13 || event.keyCode === 32) {
105        findCart();
106    }
107});
108

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.