PageSourceSearch

https://www.ty.com/on/demandware.static/Sites-Ty-Site/-/en/v1790242033659/js/search.js

js ty.com collected 2026-09-24 09:37:32 UTC 17,114 bytes, 539 lines download raw bytes

1/******/ (function(modules) { // webpackBootstrap
2/******/ 	// The module cache
3/******/ 	var installedModules = {};
4/******/
5/******/ 	// The require function
6/******/ 	function __webpack_require__(moduleId) {
7/******/
8/******/ 		// Check if module is in cache
9/******/ 		if(installedModules[moduleId]) {
10/******/ 			return installedModules[moduleId].exports;
11/******/ 		}
12/******/ 		// Create a new module (and put it into the cache)
13/******/ 		var module = installedModules[moduleId] = {
14/******/ 			i: moduleId,
15/******/ 			l: false,
16/******/ 			exports: {}
17/******/ 		};
18/******/
19/******/ 		// Execute the module function
20/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ 		// Flag the module as loaded
23/******/ 		module.l = true;
24/******/
25/******/ 		// Return the exports of the module
26/******/ 		return module.exports;
27/******/ 	}
28/******/
29/******/
30/******/ 	// expose the modules object (__webpack_modules__)
31/******/ 	__webpack_require__.m = modules;
32/******/
33/******/ 	// expose the module cache
34/******/ 	__webpack_require__.c = installedModules;
35/******/
36/******/ 	// define getter function for harmony exports
37/******/ 	__webpack_require__.d = function(exports, name, getter) {
38/******/ 		if(!__webpack_require__.o(exports, name)) {
39/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
40/******/ 		}
41/******/ 	};
42/******/
43/******/ 	// define __esModule on exports
44/******/ 	__webpack_require__.r = function(exports) {
45/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47/******/ 		}
48/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
49/******/ 	};
50/******/
51/******/ 	// create a fake namespace object
52/******/ 	// mode & 1: value is a module id, require it
53/******/ 	// mode & 2: merge all properties of value into the ns
54/******/ 	// mode & 4: return value when already ns object
55/******/ 	// mode & 8|1: behave like require
56/******/ 	__webpack_require__.t = function(value, mode) {
57/******/ 		if(mode & 1) value = __webpack_require__(value);
58/******/ 		if(mode & 8) return value;
59/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60/******/ 		var ns = Object.create(null);
61/******/ 		__webpack_require__.r(ns);
62/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64/******/ 		return ns;
65/******/ 	};
66/******/
67/******/ 	// getDefaultExport function for compatibility with non-harmony modules
68/******/ 	__webpack_require__.n = function(module) {
69/******/ 		var getter = module && module.__esModule ?
70/******/ 			function getDefault() { return module['default']; } :
71/******/ 			function getModuleExports() { return module; };
72/******/ 		__webpack_require__.d(getter, 'a', getter);
73/******/ 		return getter;
74/******/ 	};
75/******/
76/******/ 	// Object.prototype.hasOwnProperty.call
77/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78/******/
79/******/ 	// __webpack_public_path__
80/******/ 	__webpack_require__.p = "";
81/******/
82/******/
83/******/ 	// Load entry module and return exports
84/******/ 	return __webpack_require__(__webpack_require__.s = 141);
85/******/ })
86/************************************************************************/
87/******/ ({
88
89/***/ 1:
90/***/ (function(module, exports, __webpack_require__) {
91
92"use strict";
93
94
95module.exports = function (include) {
96    if (typeof include === 'function') {
97        include();
98    } else if (typeof include === 'object') {
99        Object.keys(include).forEach(function (key) {
100            if (typeof include[key] === 'function') {
101                include[key]();
102            }
103        });
104    }
105};
106
107
108/***/ }),
109
110/***/ 135:
111/***/ (function(module, exports, __webpack_require__) {
112
113"use strict";
114
115
116/**
117 * appends params to a url
118 * @param {string} data - data returned from the server's ajax call
119 * @param {Object} icon - icon that was clicked to add a product to the wishlist
120 */
121function displayMessageAndChangeIcon(data, icon) {
122    $.spinner().stop();
123    var status;
124    if (data.success) {
125        status = 'alert-success';
126        if (icon.hasClass('fa-heart-o')) {
127            icon.removeClass('fa-heart-o').addClass('fa-heart');
128        }
129    } else {
130        status = 'alert-danger';
131    }
132
133    if ($('.add-to-wishlist-messages').length === 0) {
134        $('body').append(
135            '<div class="add-to-wishlist-messages "></div>'
136        );
137    }
138    $('.add-to-wishlist-messages')
139        .append('<div class="add-to-wishlist-alert text-center ' + status + '">' + data.msg + '</div>');
140
141    setTimeout(function () {
142        $('.add-to-wishlist-messages').remove();
143    }, 5000);
144}
145
146module.exports = {
147    addToWishlist: function () {
148        $('body').on('click', '.wishlistTile', function (e) {
149            e.preventDefault();
150            var icon = $(this).find($('i'));
151            var url = $(this).attr('href');
152            var pid = $(this).closest('.product').data('pid');
153            var optionId = $(this).closest('.product-detail').find('.product-option').attr('data-option-id');
154            var optionVal = $(this).closest('.product-detail').find('.options-select option:selected').attr('data-value-id');
155            optionId = optionId || null;
156            optionVal = optionVal || null;
157            if (!url || !pid) {
158                return;
159            }
160
161            $.spinner().start();
162            $.ajax({
163                url: url,
164                type: 'post',
165                dataType: 'json',
166                data: {
167                    pid: pid,
168                    optionId: optionId,
169                    optionVal: optionVal
170                },
171                success: function (data) {
172                    displayMessageAndChangeIcon(data, icon);
173                },
174                error: function (err) {
175                    displayMessageAndChangeIcon(err, icon);
176                }
177            });
178        });
179    }
180};
181
182
183/***/ }),
184
185/***/ 141:
186/***/ (function(module, exports, __webpack_require__) {
187
188"use strict";
189
190
191var processInclude = __webpack_require__(1);
192
193$(function() {
194    processInclude(__webpack_require__(142));
195    processInclude(__webpack_require__(135));
196});
197
198/***/ }),
199
200/***/ 142:
201/***/ (function(module, exports, __webpack_require__) {
202
203"use strict";
204
205
206var baseSearch = __webpack_require__(143);
207
208
209/**
210 * Keep refinement panes expanded/collapsed after Ajax refresh
211 *
212 * @param {Object} $results - jQuery DOM element
213 * @return {undefined}
214 */
215function handleRefinements($results) {
216    $('.refinement.active').each(function () {
217        $(this).removeClass('active');
218        var activeDiv = $results.find('.' + $(this)[0].className.replace(/ /g, '.'));
219        activeDiv.addClass('active');
220        activeDiv.find('button.title').attr('aria-expanded', 'true');
221    });
222
223    updateDom($results, '.refinements');
224}
225
226/**
227 * Update DOM elements with Ajax results
228 *
229 * @param {Object} $results - jQuery DOM element
230 * @param {string} selector - DOM element to look up in the $results
231 * @return {undefined}
232 */
233function updateDom($results, selector) {
234  var $updates = $results.find(selector);
235  $(selector).empty().html($updates.html());
236}
237
238/**
239 * Parse Ajax results and updated select DOM elements
240 *
241 * @param {string} response - Ajax response HTML code
242 * @return {undefined}
243 */
244function parseResults(response) {
245  var $results = $(response);
246  var specialHandlers = {
247      '.refinements': handleRefinements
248  };
249
250  // Update DOM elements that do not require special handling
251  [
252      '.grid-header',
253      '.header-bar',
254      '.header.page-title',
255      '.product-grid',
256      '.show-more',
257      '.filter-bar'
258  ].forEach(function (selector) {
259      updateDom($results, selector);
260  });
261
262  Object.keys(specialHandlers).forEach(function (selector) {
263      specialHandlers[selector]($results);
264  });
265}
266
267function handleAccordion(e) {
268  var accordionId = $(e.currentTarget).closest('.collapse').attr('id');
269  if(accordionId) {
270      $(`#${accordionId}`).collapse('show');
271  }
272}
273
274baseSearch.applyFilter = function () {
275    // Handle refinement value selection and reset click
276    $('body').on('click', '.refinements li button, .refinement-bar button.reset, .filter-value button, .swatch-filter button', function (e) {
277        e.preventDefault();
278        e.stopPropagation();
279
280        $.spinner().start();
281        $(this).trigger('search:filter', e);
282        $.ajax({
283            url: $(this).data('href'),
284            data: {
285                page: $('.grid-footer').data('page-number'),
286                selectedUrl: $(this).data('href')
287            },
288            method: 'GET',
289            success: function (response) {
290                parseResults(response);
291
292                handleAccordion(e);
293
294                $.spinner().stop();
295            },
296            error: function () {
297                $.spinner().stop();
298            }
299        });
300    });
301};
302
303module.exports = baseSearch;
304
305/***/ }),
306
307/***/ 143:
308/***/ (function(module, exports, __webpack_require__) {
309
310"use strict";
311
312
313/**
314 * Update DOM elements with Ajax results
315 *
316 * @param {Object} $results - jQuery DOM element
317 * @param {string} selector - DOM element to look up in the $results
318 * @return {undefined}
319 */
320function updateDom($results, selector) {
321    var $updates = $results.find(selector);
322    $(selector).empty().html($updates.html());
323}
324
325/**
326 * Keep refinement panes expanded/collapsed after Ajax refresh
327 *
328 * @param {Object} $results - jQuery DOM element
329 * @return {undefined}
330 */
331function handleRefinements($results) {
332    $('.refinement.active').each(function () {
333        $(this).removeClass('active');
334        var activeDiv = $results.find('.' + $(this)[0].className.replace(/ /g, '.'));
335        activeDiv.addClass('active');
336        activeDiv.find('button.title').attr('aria-expanded', 'true');
337    });
338
339    updateDom($results, '.refinements');
340}
341
342/**
343 * Parse Ajax results and updated select DOM elements
344 *
345 * @param {string} response - Ajax response HTML code
346 * @return {undefined}
347 */
348function parseResults(response) {
349    var $results = $(response);
350    var specialHandlers = {
351        '.refinements': handleRefinements
352    };
353
354    // Update DOM elements that do not require special handling
355    [
356        '.grid-header',
357        '.header-bar',
358        '.header.page-title',
359        '.product-grid',
360        '.show-more',
361        '.filter-bar'
362    ].forEach(function (selector) {
363        updateDom($results, selector);
364    });
365
366    Object.keys(specialHandlers).forEach(function (selector) {
367        specialHandlers[selector]($results);
368    });
369}
370
371/**
372 * This function retrieves another page of content to display in the content search grid
373 * @param {JQuery} $element - the jquery element that has the click event attached
374 * @param {JQuery} $target - the jquery element that will receive the response
375 * @return {undefined}
376 */
377function getContent($element, $target) {
378    var showMoreUrl = $element.data('url');
379    $.spinner().start();
380    $.ajax({
381        url: showMoreUrl,
382        method: 'GET',
383        success: function (response) {
384            $target.append(response);
385            $.spinner().stop();
386        },
387        error: function () {
388            $.spinner().stop();
389        }
390    });
391}
392
393/**
394 * Update sort option URLs from Ajax response
395 *
396 * @param {string} response - Ajax response HTML code
397 * @return {undefined}
398 */
399function updateSortOptions(response) {
400    var $tempDom = $('<div>').append($(response));
401    var sortOptions = $tempDom.find('.grid-footer').data('sort-options').options;
402    sortOptions.forEach(function (option) {
403        $('option.' + option.id).val(option.url);
404    });
405}
406
407module.exports = {
408    filter: function () {
409        // Display refinements bar when Menu icon clicked
410        $('.container').on('click', 'button.filter-results', function () {
411            $('.modal-background').show();
412            $('.refinement-bar').show().css('z-index', '1000');
413            $('.refinement-bar').siblings().attr('aria-hidden', true);
414            $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', true);
415            $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', true);
416            $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', true);
417            $('.refinement-bar .close').focus();
418        });
419    },
420
421    closeRefinements: function () {
422        // Refinements close button
423        $('.container').on('click', '.refinement-bar button.close, .modal-background', function () {
424            $('.refinement-bar, .modal-background').hide();
425            $('.refinement-bar').siblings().attr('aria-hidden', false);
426            $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', false);
427            $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', false);
428            $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', false);
429            $('.btn.filter-results').focus();
430        });
431    },
432
433    resize: function () {
434        // Close refinement bar and hide modal background if user resizes browser
435        $(window).resize(function () {
436            $('.refinement-bar, .modal-background').hide();
437            $('.refinement-bar').siblings().attr('aria-hidden', false);
438            $('.refinement-bar').closest('.row').siblings().attr('aria-hidden', false);
439            $('.refinement-bar').closest('.tab-pane.active').siblings().attr('aria-hidden', false);
440            $('.refinement-bar').closest('.container.search-results').siblings().attr('aria-hidden', false);
441        });
442    },
443
444    sort: function () {
445        // Handle sort order menu selection
446        $('.container').on('change', '[name=sort-order]', function (e) {
447            e.preventDefault();
448
449            $.spinner().start();
450            $(this).trigger('search:sort', this.value);
451            $.ajax({
452                url: this.value,
453                data: { selectedUrl: this.value },
454                method: 'GET',
455                success: function (response) {
456                    $('.product-grid').empty().html(response);
457                    $.spinner().stop();
458                },
459                error: function () {
460                    $.spinner().stop();
461                }
462            });
463        });
464    },
465
466    showMore: function () {
467        // Show more products
468        $('.container').on('click', '.show-more button', function (e) {
469            e.stopPropagation();
470            var showMoreUrl = $(this).data('url');
471            e.preventDefault();
472
473            $.spinner().start();
474            $(this).trigger('search:showMore', e);
475            $.ajax({
476                url: showMoreUrl,
477                data: { selectedUrl: showMoreUrl },
478                method: 'GET',
479                success: function (response) {
480                    $('.grid-footer').replaceWith(response);
481                    updateSortOptions(response);
482                    $.spinner().stop();
483                },
484                error: function () {
485                    $.spinner().stop();
486                }
487            });
488        });
489    },
490
491    applyFilter: function () {
492        // Handle refinement value selection and reset click
493        $('.container').on(
494            'click',
495            '.refinements li button, .refinement-bar button.reset, .filter-value button, .swatch-filter button',
496            function (e) {
497                e.preventDefault();
498                e.stopPropagation();
499
500                $.spinner().start();
501                $(this).trigger('search:filter', e);
502                $.ajax({
503                    url: $(this).data('href'),
504                    data: {
505                        page: $('.grid-footer').data('page-number'),
506                        selectedUrl: $(this).data('href')
507                    },
508                    method: 'GET',
509                    success: function (response) {
510                        parseResults(response);
511                        $.spinner().stop();
512                    },
513                    error: function () {
514                        $.spinner().stop();
515                    }
516                });
517            });
518    },
519
520    showContentTab: function () {
521        // Display content results from the search
522        $('.container').on('click', '.content-search', function () {
523            if ($('#content-search-results').html() === '') {
524                getContent($(this), $('#content-search-results'));
525            }
526        });
527
528        // Display the next page of content results from the search
529        $('.container').on('click', '.show-more-content button', function () {
530            getContent($(this), $('#content-search-results'));
531            $('.show-more-content').remove();
532        });
533    }
534};
535
536
537/***/ })
538
539/******/ });

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.