PageSourceSearch

https://www.t6harvard.com/wp-content/themes/bootstrap-to-wp/js/global.js?ver=1789087128

js t6harvard.com collected 2026-10-02 18:53:30 UTC 9,710 bytes, 314 lines download raw bytes

1jQuery(function ($) {
2
3  $('.t6-site-nav__menu .menu-item-has-children').each(function () {
4    const $parentLink = $(this).children('.nav-link').first();
5    const $megaMenu = $(this).children('.dropdown-menu').first();
6    const parentLabel = $.trim($parentLink.clone().children().remove().end().text());
7
8    if (!$megaMenu.length || !$parentLink.attr('href') || $parentLink.attr('href') === '#') {
9      return;
10    }
11
12    $('<a>', {
13      class: 'dropdown-item t6-mega-menu__overview',
14      href: $parentLink.attr('href'),
15      'aria-label': 'View all ' + parentLabel,
16      text: 'View all ' + parentLabel
17    }).prependTo($megaMenu);
18  });
19
20  $(document).on("click", ".top-nav-menu-book-now > a", function (e) {
21    if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || (e.button && e.button !== 0)) {
22      return;
23    }
24
25    const btn = Array.from(document.querySelectorAll(".tngbh-btn")).find(function (button) {
26      return !button.closest('.top-nav-menu-book-now');
27    });
28
29    // Use the page's booking widget or the shared widget supplied in the footer.
30    // The direct link is only a fallback if the provider fails to load.
31    if (btn) {
32      e.preventDefault();
33      btn.click();
34    }
35  });
36
37  $('.variations_form .variations select').each(function () {
38    const $select = $(this);
39    const $row = $select.closest('tr');
40    const $label = $row.find('label').first();
41    const labelId = ($select.attr('id') || 'product-option') + '-label';
42    const $options = $('<div>', {
43      class: 't6-variation-options',
44      role: 'group',
45      'aria-labelledby': labelId
46    });
47    const $current = $('<span>', {
48      class: 't6-variation-current',
49      'aria-live': 'polite'
50    });
51
52    $label.attr('id', labelId);
53    $row.find('.label').append($current);
54
55    $select.find('option').each(function () {
56      if (!this.value) {
57        return;
58      }
59
60      $('<button>', {
61        class: 't6-variation-option',
62        type: 'button',
63        text: $(this).text(),
64        'data-value': this.value,
65        'aria-pressed': 'false'
66      }).appendTo($options);
67    });
68
69    if (!$options.children().length) {
70      return;
71    }
72
73    $select.addClass('t6-variation-select').attr({
74      'aria-hidden': 'true',
75      tabindex: '-1'
76    });
77    $options.insertAfter($select);
78
79    function syncVariationOptions() {
80      const selectedValue = $select.val();
81      const selectedText = $select.find('option:selected').text();
82
83      $options.children('.t6-variation-option').each(function () {
84        const $button = $(this);
85        const value = $button.attr('data-value');
86        const $matchingOption = $select.find('option').filter(function () {
87          return this.value === value;
88        });
89        const unavailable = !$matchingOption.length || $matchingOption.prop('disabled');
90        const selected = value === selectedValue;
91
92        $button
93          .prop('disabled', unavailable)
94          .toggleClass('is-unavailable', unavailable)
95          .toggleClass('is-selected', selected)
96          .attr('aria-pressed', selected ? 'true' : 'false');
97      });
98
99      $current.text(selectedValue ? selectedText : 'Not selected');
100    }
101
102    $options.on('click', '.t6-variation-option', function () {
103      if (this.disabled) {
104        return;
105      }
106
107      $select.val($(this).attr('data-value')).trigger('change');
108      syncVariationOptions();
109    });
110
111    $select.on('change', syncVariationOptions);
112    $select.closest('.variations_form').on(
113      'woocommerce_update_variation_values reset_data',
114      function () {
115        window.setTimeout(syncVariationOptions, 0);
116      }
117    );
118
119    syncVariationOptions();
120  });
121
122  $('.t6-shop-catalog').each(function () {
123    const $catalog = $(this);
124    const $switcher = $catalog.find('.t6-shop-category-switch');
125    const $tabs = $switcher.find('[role="tab"]');
126    const $panels = $catalog.find('[role="tabpanel"]');
127    const availableCollections = $tabs.map(function () {
128      return $(this).attr('data-collection');
129    }).get();
130
131    function activateCollection(collection, updateUrl, focusTab) {
132      if (availableCollections.indexOf(collection) === -1) {
133        return;
134      }
135
136      const $activeTab = $tabs.filter('[data-collection="' + collection + '"]');
137      const $activePanel = $panels.filter('[data-collection-panel="' + collection + '"]');
138
139      $tabs
140        .removeClass('is-active')
141        .attr({'aria-selected': 'false', tabindex: '-1'});
142      $activeTab
143        .addClass('is-active')
144        .attr({'aria-selected': 'true', tabindex: '0'});
145
146      $panels.removeClass('is-active').prop('hidden', true);
147      $activePanel.prop('hidden', false);
148      window.requestAnimationFrame(function () {
149        $activePanel.addClass('is-active');
150      });
151
152      $switcher
153        .removeClass('t6-shop-category-switch--aircraft-spare-parts t6-shop-category-switch--merchandise')
154        .addClass('t6-shop-category-switch--' + collection);
155      $catalog.attr('data-active-collection', collection);
156
157      if (updateUrl && window.history && window.history.replaceState) {
158        const url = new URL(window.location.href);
159        url.searchParams.set('collection', collection);
160        window.history.replaceState({}, '', url.toString());
161      }
162
163      if (focusTab) {
164        $activeTab.trigger('focus');
165      }
166    }
167
168    $tabs.on('click', function () {
169      activateCollection($(this).attr('data-collection'), true, false);
170    });
171
172    $tabs.on('keydown', function (event) {
173      const currentIndex = $tabs.index(this);
174      let nextIndex = currentIndex;
175
176      if (event.key === 'ArrowRight') {
177        nextIndex = (currentIndex + 1) % $tabs.length;
178      } else if (event.key === 'ArrowLeft') {
179        nextIndex = (currentIndex - 1 + $tabs.length) % $tabs.length;
180      } else if (event.key === 'Home') {
181        nextIndex = 0;
182      } else if (event.key === 'End') {
183        nextIndex = $tabs.length - 1;
184      } else {
185        return;
186      }
187
188      event.preventDefault();
189      activateCollection($tabs.eq(nextIndex).attr('data-collection'), true, true);
190    });
191
192    const requestedCollection = new URL(window.location.href).searchParams.get('collection');
193    if (availableCollections.indexOf(requestedCollection) !== -1) {
194      activateCollection(requestedCollection, false, false);
195    }
196  });
197
198  function enhanceCheckoutShippingMethods() {
199    $('.woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals, .cart_totals tr.woocommerce-shipping-totals').each(function () {
200      const $row = $(this);
201
202      if ($row.hasClass('t6-shipping-methods-enhanced')) {
203        return;
204      }
205
206      const $headingCell = $row.children('th').first();
207      const $methodsCell = $row.children('td').first();
208
209      $('<div>', {
210        class: 't6-shipping-methods-heading',
211        text: $.trim($headingCell.text())
212      }).prependTo($methodsCell);
213
214      $headingCell.attr('aria-hidden', 'true');
215      $methodsCell.attr('colspan', '2');
216      $row.addClass('t6-shipping-methods-enhanced');
217    });
218  }
219
220  enhanceCheckoutShippingMethods();
221  $(document.body).on(
222    'updated_checkout updated_wc_div updated_cart_totals',
223    enhanceCheckoutShippingMethods
224  );
225
226  let postcodeUpdateTimer = null;
227
228  $(document).on('input change', '#billing_postcode, #shipping_postcode', function () {
229    window.clearTimeout(postcodeUpdateTimer);
230    postcodeUpdateTimer = window.setTimeout(function () {
231      $(document.body).trigger('update_checkout');
232    }, 500);
233  });
234
235  $(document.body).on('update_checkout', function () {
236    window.clearTimeout(postcodeUpdateTimer);
237    postcodeUpdateTimer = null;
238  });
239
240  let checkoutLightboxTrigger = null;
241  const $checkoutLightbox = $('<div>', {
242    class: 't6-checkout-lightbox',
243    hidden: true,
244    role: 'dialog',
245    'aria-modal': 'true',
246    'aria-labelledby': 't6-checkout-lightbox-title'
247  });
248  const $checkoutLightboxPanel = $('<div>', {
249    class: 't6-checkout-lightbox__panel'
250  });
251  const $checkoutLightboxClose = $('<button>', {
252    class: 't6-checkout-lightbox__close',
253    type: 'button',
254    'aria-label': 'Close product image',
255    html: '&times;'
256  });
257  const $checkoutLightboxImage = $('<img>', {
258    class: 't6-checkout-lightbox__image',
259    alt: ''
260  });
261  const $checkoutLightboxTitle = $('<div>', {
262    class: 't6-checkout-lightbox__title',
263    id: 't6-checkout-lightbox-title'
264  });
265
266  $checkoutLightboxPanel.append(
267    $checkoutLightboxClose,
268    $checkoutLightboxImage,
269    $checkoutLightboxTitle
270  );
271  $checkoutLightbox.append($checkoutLightboxPanel).appendTo(document.body);
272
273  function closeCheckoutLightbox() {
274    if ($checkoutLightbox.prop('hidden')) {
275      return;
276    }
277
278    $checkoutLightbox.prop('hidden', true);
279    $checkoutLightboxImage.removeAttr('src');
280    $(document.body).removeClass('t6-lightbox-open');
281
282    if (checkoutLightboxTrigger) {
283      checkoutLightboxTrigger.focus();
284    }
285  }
286
287  $(document).on('click', '.t6-checkout-product__image', function (event) {
288    event.preventDefault();
289    checkoutLightboxTrigger = this;
290
291    const title = $(this).attr('data-product-title') || '';
292    $checkoutLightboxImage.attr({
293      src: this.href,
294      alt: title
295    });
296    $checkoutLightboxTitle.text(title);
297    $checkoutLightbox.prop('hidden', false);
298    $(document.body).addClass('t6-lightbox-open');
299    $checkoutLightboxClose.trigger('focus');
300  });
301
302  $checkoutLightboxClose.on('click', closeCheckoutLightbox);
303  $checkoutLightbox.on('click', function (event) {
304    if (event.target === this) {
305      closeCheckoutLightbox();
306    }
307  });
308  $(document).on('keydown', function (event) {
309    if (event.key === 'Escape') {
310      closeCheckoutLightbox();
311    }
312  });
313
314});

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.