PageSourceSearch

https://www.theatricalrights.com/wp-content/themes/trw/js/main.js?ver=1.0.3

js theatricalrights.com collected 2026-10-02 03:28:22 UTC 46,650 bytes, 1,140 lines download raw bytes

1/* global wp, jQuery */
2/**
3 * File main.js.
4 *
5 * Custom JS for site
6 */
7	
8
9( function( $ ) {
10	
11	$(document).ready(function() {
12
13		gsap.registerPlugin(ScrollTrigger);
14
15		SVGInjector(document.querySelectorAll('img.svgInject'), {}, function(){
16            calcNavBarHeight();
17        });
18
19        const defaultSwiperEl = document.querySelectorAll('.default-carousel');
20        let defaultSwipers = [];
21
22        [...defaultSwiperEl].map((v,i) => {
23            defaultSwipers.push(
24                new Swiper(v, {
25                    freeMode: true,
26                    loop: true,
27                    //allowTouchMove: false,
28                    pagination: {
29                        el: v.querySelector(".swiper-pagination"),
30                    },
31                    navigation: {
32                        prevEl: v.querySelector(".swiper-button-prev"),
33                        nextEl: v.querySelector(".swiper-button-next"),
34                    },
35                    autoplay: {
36                        disableOnInteraction: false,
37                    },
38                    slidesPerView: 'auto',
39                    slidesPerGroup: 1,
40                    spaceBetween: 30,
41                    disableOnInteraction: false,
42                    breakpoints: {
43                        768: {
44                            slidesPerView: 4,
45                            slidesPerGroup: 4
46                        },
47                    }
48                })
49            );
50        })
51
52        const defaultSmallSwiperEl = document.querySelectorAll('.default-small-carousel');
53        let defaultSmallSwipers = [];
54
55        [...defaultSmallSwiperEl].map((v,i) => {
56            defaultSmallSwipers.push(
57                new Swiper(v, {
58                    freeMode: true,
59                    loop: true,
60                    //allowTouchMove: false,
61                    pagination: {
62                        el: v.querySelector(".swiper-pagination"),
63                    },
64                    navigation: {
65                        prevEl: v.querySelector(".swiper-button-prev"),
66                        nextEl: v.querySelector(".swiper-button-next"),
67                    },
68                    autoplay: {
69                        disableOnInteraction: false,
70                    },
71                    slidesPerView: 'auto',
72                    slidesPerGroup: 1,
73                    spaceBetween: 30,
74                    disableOnInteraction: false,
75                    breakpoints: {
76                        768: {
77                            slidesPerView: 2,
78                            slidesPerGroup: 1
79                        },
80                    }
81                })
82            );
83        })
84
85        const defaultFlexSwiperEl = document.querySelectorAll('.default-flex-carousel');
86        let defaultFlexSwipers = [];
87
88        [...defaultFlexSwiperEl].map((v,i) => {
89            defaultFlexSwipers.push(
90                new Swiper(v, {
91                    freeMode: true,
92                    loop: true,
93                    //allowTouchMove: false,
94                    pagination: {
95                        el: v.querySelector(".swiper-pagination"),
96                    },
97                    navigation: {
98                        prevEl: v.querySelector(".swiper-button-prev"),
99                        nextEl: v.querySelector(".swiper-button-next"),
100                    },
101                    autoplay: {
102                        disableOnInteraction: false,
103                    },
104                    slidesPerView: 'auto',
105                    slidesPerGroup: 1,
106                    spaceBetween: 30,
107                })
108            );
109        })
110
111        const defaultMobileOnlySwiperEl = document.querySelectorAll('.default-mobile-only-carousel');
112        let defaultMobileOnlySwipers = [];
113
114        [...defaultMobileOnlySwiperEl].map((v,i) => {
115            defaultMobileOnlySwipers.push(
116                new Swiper(v, {
117                    freeMode: true,
118                    loop: true,
119                    //allowTouchMove: false,
120                    pagination: {
121                        el: v.querySelector(".swiper-pagination"),
122                    },
123                    navigation: {
124                        prevEl: v.querySelector(".swiper-button-prev"),
125                        nextEl: v.querySelector(".swiper-button-next"),
126                    },
127                    autoplay: false,
128                    slidesPerView: 'auto',
129                    slidesPerGroup: 1,
130                    spaceBetween: 30,
131                    disableOnInteraction: false,
132                })
133            );
134        })
135
136        var licensePage = 1;
137        var licensePageForm = null;
138        var licensePageTotal = $('.form-display-musical .gform_page').length + 1;
139
140        document.addEventListener('gform/post_render', (event) => {
141            if(event.detail.currentPage){
142                licensePage = parseInt(event.detail.currentPage) + 1;
143                updateProgressBar();
144                setupCalculation();
145            } else {
146                $('.license-section .license-back, .license-steps, .license-bar').hide();
147            }
148        });
149        
150        
151        if(window.location.search.indexOf('gf_token') > 0) {
152            if(getCookie('licenseReturn')){
153                licensePageForm = getCookie('licenseReturn');
154                $('.license-section').removeClass('license-musical license-play').addClass('license-'+licensePageForm);
155                $('.license-holder').removeClass('license-show-1').addClass('license-show-2');
156            }
157        }
158
159        $('.license-section .license-steps span.total-step').html(licensePageTotal);
160
161        $( document ).on( 'click', '.license-form-select', function(e) {
162            licensePageForm = e.currentTarget.getAttribute('form-select');
163            $('.license-section').removeClass('license-musical license-play').addClass('license-'+licensePageForm);
164        })
165
166        $( document ).on( 'click', '.license-next', function(e) {
167            $('.license-holder').removeClass('license-show-1').addClass('license-show-2');
168            setCookie('licenseReturn', licensePageForm, 7);
169            licensePage++;
170            updateProgressBar();
171        })
172
173        $( document ).on( 'click', '.license-back', function(e) {
174            $('.license-holder').removeClass('license-show-2').addClass('license-show-1');
175            setCookie('licenseReturn', '', 0);
176            licensePage--;
177            updateProgressBar();
178        })
179
180        $('.nav-search button, #navSearch .close-button').click(function(e){
181            $('#nav-holder').toggleClass('show-search');
182        })
183
184        $( document ).on( 'click', '.single-staff .hover-inner', function(e) {
185            $(e.currentTarget).closest('.single-staff').find('.overlay').addClass('show-overlay');
186        })
187
188        $('.single-staff .close-button').click(function(e){
189            $(e.currentTarget).closest('.overlay').removeClass('show-overlay');
190        })
191
192        $( document ).on( 'click', '.post-type-archive-product .display_order-control', function(e) {
193            $(e.currentTarget).closest('.filters').toggleClass('show-filters');
194        })
195
196        function updateProgressBar() {
197            $('.license-section .license-steps span.current-step').html(licensePage);
198            $('.license-section .license-bar .license-bar-inner').attr('perc', Math.round((100/licensePageTotal) * licensePage));
199            if(licensePage > 2) {
200                $('.license-section .license-back').hide();
201            } else {
202                $('.license-section .license-back').show();
203            }
204        }
205
206        if($( '.trw-variation-radios input' ).length > 0 ){
207
208            if($( '.trw-variation-radios input' ).val() == 'Print'){
209                $('.product-image').addClass('print-image');
210            }
211            
212
213            if($( '.trw-variation-radios input' ).val()){
214                $('.isbn:not(.'+$( '.trw-variation-radios input' ).val().replaceAll(" ", "_")+')').addClass('d-none').removeClass('d-block');
215                $('.isbn.'+$( '.trw-variation-radios input' ).val().replaceAll(" ", "_")).removeClass('d-none').addClass('d-block');
216            }
217        }
218
219        if($('.woocommerce-variation-add-to-cart .quantity')){
220            if($('.woocommerce-variation-add-to-cart .quantity input').attr('type') == 'hidden'){
221                $('.woocommerce-variation-add-to-cart .quantity').hide();
222            }
223        }
224
225        $( document ).on( 'change', '.trw-variation-radios input', function(e) {
226            $( '.trw-variation-radios input[value="'+e.currentTarget.value+'"][name="'+e.currentTarget.name+'"]' ).prop("checked", true);
227
228            if($('.isbn.'+e.currentTarget.value.replaceAll(" ", "_")).length > 0){
229                $('.isbn:not(.'+e.currentTarget.value.replaceAll(" ", "_")+')').addClass('d-none').removeClass('d-block');
230                $('.isbn.'+e.currentTarget.value.replaceAll(" ", "_")).removeClass('d-none').addClass('d-block');
231            } else {
232                $('.isbn').removeClass('d-none').removeClass('d-block');
233            }
234
235            if(e.currentTarget.value == 'Print'){
236                $('.product-image').addClass('print-image');
237            } else {
238                $('.product-image').removeClass('print-image');
239            }
240
241            // for each checked radio button we reflect the same changes to select dropdowns
242            $( '.trw-variation-radios input:checked' ).each( function( index, element ) {
243                const radio = $(element)
244                const radioName = radio.attr( 'name' )
245                const radioValue  = radio.attr( 'value' )
246                $( 'select[name="' + radioName + '"]' ).val( radioValue ).trigger( 'change' );
247            })
248        })
249
250        // Setup audio playlist on show pages
251        if( $('#audio').length ){
252            // Setup the player to autoplay the next track
253            var a = audiojs.createAll({
254                trackEnded: function() {
255                    var next = $('ol li.playing').next();
256                    if (!next.length) next = $('ol li').first();
257                    next.addClass('playing').siblings().removeClass('playing');
258                    audio.load($('a', next).attr('data-src'));
259                    audio.play();
260                }
261            });
262
263            // Load in the first track
264            var audio = a[0];
265            var first = $('ol a:first-child').attr('data-src');
266            $('ol li').first().addClass('playing');
267            audio.load(first);
268
269            // Load in a track on click
270            $('ol li').on('click', function(e) {
271                e.preventDefault();
272                $(this).addClass('playing').siblings().removeClass('playing');
273                audio.load($('a', this).attr('data-src'));
274                audio.play();
275                return false;
276            });
277        }
278
279        // Gallery lightbox display
280        if( $('.gallery a ').length ){
281            $('.gallery a').featherlightGallery({
282                gallery: {
283                    fadeIn: 300,
284                    fadeOut: 300
285                },
286                openSpeed:  300,
287                closeSpeed: 200
288            });
289            // Add caption to lightbox
290            $.featherlightGallery.prototype.afterContent = function() {
291                var caption = this.$currentTarget.find('figcaption').text();
292                this.$instance.find('.caption').remove();
293                $('<div class="caption">').text(caption).appendTo(this.$instance.find('.featherlight-content'));
294            };
295        }
296
297        // Range sliders
298
299        $(".length-range-slider").ionRangeSlider({
300            type: "double",
301            skin: "round",
302            grid: false,
303            min: 0,
304            max: 120,
305            from: 0,
306            to: 120,
307            step: 5,
308            max_postfix: "+",
309            postfix: "",
310            onStart: function(data){
311                $('input[type="checkbox"][name="length[]"].no-clear').each(function(i,v){
312                    if(data.min == data.from && data.max == data.to){
313                            if (v.checked) {
314                                v.click();
315                            }
316                    } else {
317                        var lengthObj = v.getAttribute('length-parse');
318                        lengthObj = JSON.parse(lengthObj);
319
320                        if(lengthObj){
321                            if(lengthObj.length == 1){
322                                if(lengthObj[0] >= data.from && lengthObj[0] <= data.to){
323                                    if (!v.checked) {
324                                        v.click();
325                                    }
326                                } else {
327                                    if (v.checked) {
328                                        v.click();
329                                    }
330                                }
331                            } else {
332                                if(!((lengthObj[0] < data.from && lengthObj[1] < data.from) || (lengthObj[0] > data.to && lengthObj[1] > data.to))){
333                                    if (!v.checked) {
334                                        v.click();
335                                    }
336                                } else {
337                                    if (v.checked) {
338                                        v.click();
339                                    }
340                                }
341                            }
342                        }
343                    }
344                })
345            },
346            onChange: function (data) {
347                $('input[type="checkbox"][name="length[]"].no-clear').each(function(i,v){
348                    if(data.min == data.from && data.max == data.to){
349                            if (v.checked) {
350                                v.click();
351                            }
352                    } else {
353                        var lengthObj = v.getAttribute('length-parse');
354                        lengthObj = JSON.parse(lengthObj);
355
356                        if(lengthObj){
357                            if(lengthObj.length == 1){
358                                if(lengthObj[0] >= data.from && lengthObj[0] <= data.to){
359                                    if (!v.checked) {
360                                        v.click();
361                                    }
362                                } else {
363                                    if (v.checked) {
364                                        v.click();
365                                    }
366                                }
367                            } else {
368                                if(!((lengthObj[0] < data.from && lengthObj[1] < data.from) || (lengthObj[0] > data.to && lengthObj[1] > data.to))){
369                                    if (!v.checked) {
370                                        v.click();
371                                    }
372                                } else {
373                                    if (v.checked) {
374                                        v.click();
375                                    }
376                                }
377                            }
378                        }
379                    }
380                })
381            },
382            onUpdate: function (data) {
383                $('input[type="checkbox"][name="length[]"].no-clear').each(function(i,v){
384                    if(data.min == data.from && data.max == data.to){
385                            if (v.checked) {
386                                
387                                v.click();
388                            }
389                    } else {
390                        var lengthObj = v.getAttribute('length-parse');
391                        lengthObj = JSON.parse(lengthObj);
392
393                        if(lengthObj){
394                            if(lengthObj.length == 1){
395                                if(lengthObj[0] >= data.from && lengthObj[0] <= data.to){
396                                    if (!v.checked) {
397                                        v.click();
398                                    }
399                                } else {
400                                    if (v.checked) {
401                                        v.click();
402                                    }
403                                }
404                            } else {
405                                if(!((lengthObj[0] < data.from && lengthObj[1] < data.from) || (lengthObj[0] > data.to && lengthObj[1] > data.to))){
406                                    if (!v.checked) {
407                                        v.click();
408                                    }
409                                } else {
410                                    if (v.checked) {
411                                        v.click();
412                                    }
413                                }
414                            }
415                        }
416                    }
417                })
418            },
419        });
420
421        $(".cast-range-slider").ionRangeSlider({
422            type: "double",
423            skin: "round",
424            grid: false,
425            min: 1,
426            max: 10,
427            from: 1,
428            to: 10,
429            step: 1,
430            max_postfix: "+",
431            postfix: "",
432            onStart: function(data){
433                $('input[type="checkbox"][name="cast_size[]"].no-clear').each(function(i,v){
434                    if(data.min == data.from && data.max == data.to){
435                            if (v.checked) {
436                                v.click();
437                            }
438                    } else {
439                        var castSize = v.getAttribute('cast_size-parse');
440
441                        if(castSize){
442                            if(castSize >= data.from && castSize <= data.to){
443                                if (!v.checked) {
444                                    v.click();
445                                }
446                            } else {
447                                if (v.checked) {
448                                    v.click();
449                                }
450                            }
451                        }
452                    }
453                })
454            },
455            onChange: function (data) {
456                $('input[type="checkbox"][name="cast_size[]"].no-clear').each(function(i,v){
457                    if(data.min == data.from && data.max == data.to){
458                            if (v.checked) {
459                                v.click();
460                            }
461                    } else {
462                        var castSize = v.getAttribute('cast_size-parse');
463
464                        if(castSize){
465                            if(castSize >= data.from && castSize <= data.to){
466                                if (!v.checked) {
467                                    v.click();
468                                }
469                            } else {
470                                if (v.checked) {
471                                    v.click();
472                                }
473                            }
474                        }
475                    }
476                })
477            },
478            onUpdate: function (data) {
479                $('input[type="checkbox"][name="cast_size[]"].no-clear').each(function(i,v){
480                    if(data.min == data.from && data.max == data.to){
481                            if (v.checked) {
482                                v.click();
483                            }
484                    } else {
485                        var castSize = v.getAttribute('cast_size-parse');
486
487                        if(castSize){
488                            if(castSize >= data.from && castSize <= data.to){
489                                if (!v.checked) {
490                                    v.click();
491                                }
492                            } else {
493                                if (v.checked) {
494                                    v.click();
495                                }
496                            }
497                        }
498                    }
499                })
500            },
501        });
502        
503        let leftHover = false;
504        $('.left-bar-menu').hover(function(e){
505            leftHover = e.currentTarget;
506            calcLeftBarHeight();
507        }, function(e){
508            $(leftHover).find('.left-bar-submenu > .dropdown-menu').each(function() {
509                $(this).css("height", "");;
510            })
511            leftHover = false;
512        })
513
514        function calcLeftBarHeight() {
515            if(leftHover){
516                let innerBarHeight = 0;
517                $(leftHover).find('.left-bar-submenu > .dropdown-menu, .left-bar-submenu > .sub-menu').each(function() {
518                    innerBarHeight = innerBarHeight > $(this).height() ? innerBarHeight : $(this).height();
519                }).each(function() {
520                    $(this).height(innerBarHeight);
521                });
522                $(leftHover).find('> .dropdown-menu, > .sub-menu').css('min-height', (innerBarHeight + 60) + "px");
523            } else {
524                
525            }
526        }
527
528        function calcNavBarHeight() {
529            var navBar = $('header#masthead'),
530                navHeight = navBar.height();
531            if($('.site-message')){
532                navBar.find('#menu-main-menu > .menu-item-has-children.dropdown > .dropdown-menu, #menu-main-menu > .menu-item-has-children > .sub-menu').css('top', navHeight + 'px');
533                $('.article-quick-links').css('top', navHeight + 'px');
534                $('.sidebar-wrap').css('top', (navHeight + 50) + 'px');
535            }
536        }
537
538        const leftBarCalcResize = throttle(() => calcLeftBarHeight());
539        const messageCalcHeight = throttle(() => calcNavBarHeight());
540
541        const countriesInEU = ["BE","EL","LT","PT","BG","ES","LU","RO","CZ","FR","HU","SI","DK","HR","MT","SK","DE","IT","NL","FI","EE","CY","AT","SE","IE","LV","PL","UK", "GB"];
542
543        const geoCookie = getCookie('TWRGeoSelected');
544
545        console.log(geoCookie);
546        
547        
548        if(!geoCookie){
549            $.get("https://ipinfo.io", function(response) {
550                let regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
551                let countryName = regionNames.of(response.country);
552                if((countriesInEU.indexOf(response.country) >= 0 && $('.footer-geo-site-select a.selected').attr('geo-location') == "US") || (countriesInEU.indexOf(response.country) == -1 && $('.footer-geo-site-select a.selected').attr('geo-location') == "UK")){
553                    $('.footer-geo-site-select').addClass('show').find('h4 span').html(countryName);
554                }
555                setCookie('TWRGeoSelected', JSON.stringify(response), 3);
556                $(document).click(function(e){
557                    if (!$(e.target).closest(".footer-geo-site-select").length || $(e.target).closest(".close-button").length || $(e.target).hasClass("current-location")) {
558                        if($(e.target).hasClass("current-location")){
559                            e.preventDefault();
560                        }
561                        $('.footer-geo-site-select').removeClass('show');
562                        setCookie('TWRGeoSelected', 'ignore', 3);
563                    }
564                })
565            }, "jsonp");
566        } else if(geoCookie != 'ignore'){
567            response = JSON.parse(geoCookie);
568            let regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
569            let countryName = regionNames.of(response.country);
570            if((countriesInEU.indexOf(response.country) >= 0 && $('.footer-geo-site-select a.selected').attr('geo-location') == "US") || (countriesInEU.indexOf(response.country) == -1 && $('.footer-geo-site-select a.selected').attr('geo-location') == "UK")){
571                $('.footer-geo-site-select').addClass('show').find('h4 span').html(countryName);
572            }
573            $(document).click(function(e){
574                if (!$(e.target).closest(".footer-geo-site-select").length || $(e.target).closest(".close-button").length || $(e.target).hasClass("current-location")) {
575                    $('.footer-geo-site-select').removeClass('show');
576                    setCookie('TWRGeoSelected', 'ignore', 3);
577                }
578            })
579        }
580
581        $(window).resize(leftBarCalcResize);
582        $(window).resize(messageCalcHeight);
583
584        var permascroll = true;
585
586        // Fire reload on every checkbox
587        $('#show_type_filter input, .filter-list-order input').on('change', function(){
588            trw.paged = 0;
589            updateFilters(true);
590        });
591
592        // Submit on mobile button press
593        $('#filters .filter-group-apply').on('click', function(e){
594            e.preventDefault();
595            trw.paged = 0;
596            updateFilters(true);
597            
598        });
599
600        $('#filters').on('submit', function(e){
601            e.preventDefault();
602            trw.paged = 0;
603            updateFilters(true);
604        });
605            
606        // Clear filters
607        $('.filter-group-clear').on('click', function(e){
608            e.preventDefault();
609            $(e.currentTarget).closest('.filter-group-inner').find('input[type="checkbox"]:not(.no-clear)').prop('checked', false);
610        });
611            
612        // Clear filters
613        $('.filter-group-clear-all').on('click', function(e){
614            e.preventDefault();
615            $(e.currentTarget).closest('#tax_filters').find('input[type="checkbox"]:not(.no-clear)').prop('checked', false);
616            var varCastSlider = $(".cast-range-slider").data("ionRangeSlider");
617            if(varCastSlider){
618                varCastSlider.update({
619                    from: varCastSlider.result.min,
620                    to: varCastSlider.result.max,
621                });
622            }
623            var varLengthSlider = $(".length-range-slider").data("ionRangeSlider");
624            if(varLengthSlider){
625                varLengthSlider.update({
626                    from: varLengthSlider.result.min,
627                    to: varLengthSlider.result.max,
628                });
629            }
630        });
631
632        $('.filter-tags').on('click', 'button', function(e){
633            
634            if(e.currentTarget.hasAttribute('tag-name')){
635                if(e.currentTarget.getAttribute('tag-name') == 'search'){
636                    $('#showSearch input').val('');
637                } else {
638                    $('input[type="checkbox"][name="'+e.currentTarget.getAttribute('tag-name')+'"][value="'+e.currentTarget.getAttribute('tag-value')+'"]').click();
639                }
640            } else {
641                var varSlider = $("."+e.currentTarget.getAttribute('slider-name')).data("ionRangeSlider");
642                if(varSlider){
643                    varSlider.update({
644                        from: varSlider.result.min,
645                        to: varSlider.result.max,
646                    });
647                }
648            }
649            trw.paged = 0;
650            updateFilters(true);
651        })
652
653        $('.pd').click(function(e) {
654            e.preventDefault();
655        })
656        
657        function updateFilters(replace = false){
658            $('body').addClass('trw-ajax');
659
660            $('.loading-animation').addClass('show');
661
662            val = $('.filters input[type="checkbox"]').serializeArray();
663            
664            val.push({name: 'action', value: $('#filters').data('action')});
665            val.push({name: 'sort', value: $('input[name=display_order]:checked').val()});
666            
667            // Add per_page value if set
668            if( trw.per_page != '' ){
669                val.push({name: 'per_page', value: trw.per_page});
670            }
671        
672            // Add page number value if set
673            if( trw.paged != 0 ){
674                val.push({name: 'paged', value: trw.paged});
675            } else {
676                val.push({name: 'paged', value: 1});
677                trw.paged = 1;
678            }
679            
680            if( $('input#search').val() ){
681                val.push({name: 'search', value: $('input#search').val()});
682            }
683
684            permascroll = false;
685
686            $.get(trw.ajaxurl, $.param(val), function(data){
687            
688                $('.loading-animation').removeClass('show');
689
690                $('.filter-tags').empty();
691                
692
693                $('#tax_filters input[type="checkbox"]:checked:not(.no-clear), #showSearch input').each(function(i, v) {
694                    if(v.type == 'checkbox'){
695                        $('.filter-tags').append($('<button tag-name="'+v.name+'" tag-value="'+v.value+'" class="plain p small nowrap">'+$(v).siblings('span').text()+' <img class="icon" src="/wp-content/themes/trw/assets/img/clear.svg"/> </button>'));
696                    } else {
697                        if (v.value.length > 0){
698                            $('.filter-tags').append($('<button tag-name="'+v.name+'" tag-value="'+v.value+'" class="plain p small nowrap">search: '+v.value+' <img class="icon" src="/wp-content/themes/trw/assets/img/clear.svg"/> </button>'));
699                        }
700                    }
701                });
702
703                var lengthSlider = $(".length-range-slider").data("ionRangeSlider");
704                if (lengthSlider){
705                    lengthSlider = lengthSlider.result;
706
707                    if(!(lengthSlider.from == lengthSlider.min && lengthSlider.to == lengthSlider.max)){
708                        $('.filter-tags').append($('<button slider-name="length-range-slider" class="plain p small">'+lengthSlider.from+'-'+lengthSlider.to+'min <img class="icon" src="/wp-content/themes/trw/assets/img/clear.svg"/> </button>'));
709                    }
710                }
711
712                var castSlider = $(".cast-range-slider").data("ionRangeSlider");
713                if (castSlider){
714                    castSlider = castSlider.result;
715
716                    if(!(castSlider.from == castSlider.min && castSlider.to == castSlider.max)){
717                        $('.filter-tags').append($('<button slider-name="cast-range-slider" class="plain p small">cast: '+castSlider.from+'-'+castSlider.to+' <img class="icon" src="/wp-content/themes/trw/assets/img/clear.svg"/> </button>'));
718                    }
719                }
720        
721                $('#apply-filter').text(data.count);
722
723                // Display posts
724                if(replace){
725                    $('#grid-content').fadeOut(100).html(data.posts).fadeIn(function(){
726                        if($('#grid-content')[0].ScrollTrigger){
727                            $('#grid-content')[0].ScrollTrigger.refresh();
728                        }
729                        permascroll = true;
730                    });
731                } else {
732                    $('#grid-content').append($(data.posts).hide().fadeIn(function(){
733                        if($('#grid-content')[0].ScrollTrigger){
734                            $('#grid-content')[0].ScrollTrigger.refresh();
735                        }
736                        permascroll = true;
737                    }));
738                }
739
740                $('.loading-message').removeClass('loading-message-show-end loading-message-show-none');
741        
742                // Add new URL to pushState for browser updating
743                pageUrl = '';
744                val = $('.filters input').serialize();
745                pageUrl = '?'+val;
746                
747                trw.paged++;
748                
749                if( $('input#search').val() ){
750                    pageUrl += '&search='+$('input#search').val();
751                }
752        
753                //console.log(pageUrl, val);
754                if( val != '' ){
755                    history.pushState(null, $(document).find('title').text(), trw.archiveurl + pageUrl);
756                }
757                
758
759                if(data.posts.length == 0){
760                    if(trw.paged == 2){
761                        $('.loading-message').removeClass('loading-message-show-end').addClass('loading-message-show-none');
762                    } else {
763                        $('.loading-message').addClass('loading-message-show-end').removeClass('loading-message-show-none');
764                    }
765                }
766            }, 'json');
767        }
768
769        if($('#filters').length){
770            if($('#filters').data('action') == 'shop_query'){
771                trw.archiveurl = trw.shopurl;
772            }
773            updateFilters();
774        }
775
776
777        function aboutArrowAnimation() {
778            $({ value: 0 }).animate({ value: 1 }, {
779                duration: 1500,
780                step: function(now) {
781                    var translation = now * 10;
782                    
783                    $('#about-arrow').css({
784                        'transform': 'translateY(' + translation + 'px)'
785                    });
786
787                    $('#about-arrow .offset-animate').attr('offset', (.5 + (.065 * now)) )
788                },
789                complete: function() {
790                     $({ value: 1 }).animate({ value: 0 }, {
791                        duration: 1500,
792                        step: function(now) {
793                            var translation = now * 10;
794                            
795                            $('#about-arrow').css({
796                                'transform': 'translateY(' + translation + 'px)'
797                            });
798
799                            $('#about-arrow .offset-animate').attr('offset', (.5 + (.065 * now)) )
800                        },
801                        complete: aboutArrowAnimation
802                    });
803                }
804            });
805        }
806
807        if($('#about-arrow').length){
808            aboutArrowAnimation()
809        }
810
811		const loadMoreSections = document.querySelectorAll("*[load-more]");
812
813		loadMoreSections.forEach((section, index) => {
814
815          section.ScrollTrigger = ScrollTrigger.create({
816              trigger: section,
817              start: "bottom bottom-=200px",
818              scrub: 1,  // Smooth scrolling
819              markers: false,
820              onEnter: () => {
821                if(permascroll){
822                    var trigger = section.getAttribute('load-more');
823                    switch (trigger) {
824                        case 'shows':
825                        case 'shop':
826                                updateFilters();
827                            break;
828                        
829                        default:
830                            break;
831                    }
832                }
833              },
834          });
835        })
836
837		const desnapSections = document.querySelectorAll(".desnap-mobile");
838
839		desnapSections.forEach((section, index) => {
840
841          section.ScrollTrigger = ScrollTrigger.create({
842              trigger: section,
843              start: "bottom bottom-=500px",
844              scrub: 1,  // Smooth scrolling
845              markers: false,
846              onEnter: () => {
847                console.log('TEST');
848                
849                document.querySelector('.checkout-holder').classList.add('desnap');
850              },
851              onLeaveBack:  () => {
852                document.querySelector('.checkout-holder').classList.remove('desnap');
853              },
854          });
855        })
856
857
858        if( typeof gform !== "undefined" ){
859            // Allow price-weight field to be calculated accordingly
860            var priceVal,
861                percentVal;
862
863            $(document).on('keyup blur', 'form[id^=gform_]'+' .price-weight .gfield_list_cell input', calculatePricingPercentage);
864            
865            $('form[id^=gform_]').on('keypress', '.price-weight .gfield_list_cell input', function(evt){
866                // Only allow digits and a decimal place for entering
867                if (evt.which != 8 && evt.which != 0 && evt.which != 46 && evt.which < 48 || evt.which > 57){
868                    evt.preventDefault();
869                }
870            });
871        }
872
873        function setupCalculation(event){
874            if( typeof gform !== "undefined" ){
875                // Reformat input fields on load
876                if( $('form[id^=gform_]') ){
877                    $('form[id^=gform_]'+' table tr').each(function(i, e){
878                        $(this).find('td:nth-child(1)').prepend('Price ');
879                        $(this).find('td:nth-child(2)').append('% of total seating ');
880                    });
881                    $('form[id^=gform_]'+' table td:nth-child(1) input').addClass('field-weight-price').prop('placeholder', 'ex: 10');
882                    $('form[id^=gform_]'+' table td:nth-child(2) input').addClass('field-weight-percent').prop('placeholder', 'ex: 50').prop('type', 'number');
883                    $('form[id^=gform_]'+' .price-weight-average input').prop('readonly', true).closest('tr').find('.add_list_item').click().click();
884                }
885                // gform.addAction( 'gform_list_post_item_delete', calculatePricingPercentage );
886                // gform.addAction( 'gform_list_post_item_add', calculatePricingPercentage );
887            }
888        }
889        
890        function calculatePricingPercentage(event){
891
892            console.log("test");
893            
894            
895            $this = $(this);
896            var price = 0,
897                percent = 0,
898                remainder = 0,
899                average = 0;
900
901            // Loop through table and calculate some stuff
902            $this.closest('table').find('tr').each(function(){
903                $e = $(this);
904                priceVal = $e.find('td:nth-child(1) input').val();
905                percentVal = $e.find('td:nth-child(2) input').val();
906
907                // Update overall price
908                if( parseFloat( priceVal ) ){
909                    price = parseFloat( priceVal ) + price;
910                }
911
912                // Update percentage
913                if( parseInt( percentVal ) ){
914                    percent = parseInt( percentVal ) + percent;
915
916                    // Make sure percent stays at 100 on blur/focusout
917                    if( percent > 100 && event.type == 'focusout' ){
918                        remainder = percent - 100;
919                        // Reset our val to the remainder of over 100, or 0
920                        percentVal = Math.max(parseInt(percentVal - remainder), 0);
921                        $e.find('td:nth-child(2) input').val(percentVal);
922                        percent = 100;
923                    }
924                }
925
926                // Calculate weighted average
927                if( parseFloat(priceVal) && parseInt(percentVal) ){
928                    average += parseFloat(parseFloat(priceVal) * parseInt(percentVal)/100);
929                }
930            });
931
932            if( percent == 100 ){
933                $('.price-weight-average input').val(average.toFixed(2));
934            } else {
935                $('.price-weight-average input').val("Percentage total is not 100");
936            }
937        }
938
939        if(document.querySelector('.showAccordion')){
940            ScrollTrigger.create({
941                trigger: document.querySelector('#stickyStart'),
942                start: "top bottom-=100px",
943                scrub: 1,  // Smooth scrolling
944                markers: false,
945                onEnter: () => {
946                    document.querySelector('.mobile-show-bug').classList.add('fixed-bottom');
947                },
948                onLeaveBack: () => {
949                    document.querySelector('.mobile-show-bug').classList.remove('fixed-bottom');
950                },
951            });
952
953            ScrollTrigger.create({
954                trigger: document.querySelector('.footer-mailing-list'),
955                start: "top bottom-=20px",
956                scrub: 1,  // Smooth scrolling
957                markers: false,
958                onEnter: () => {
959                    document.querySelector('.mobile-show-bug').classList.remove('fixed-bottom');
960                },
961                onLeaveBack: () => {
962                    document.querySelector('.mobile-show-bug').classList.add('fixed-bottom');
963                },
964            });
965        }
966
967        $('#upcomingContent button, .maskedContent .show-button').click(function(e){
968            console.log(e);
969            
970            $(e.currentTarget).closest('#upcomingContent, .maskedContent').toggleClass('show-inner');
971            if($(e.currentTarget).closest('#upcomingContent, .maskedContent').hasClass('show-inner')){
972                $(e.currentTarget).html('show less');
973            } else {
974                $(e.currentTarget).html('show more');
975            }
976        })
977
978        $(document).on('keyup', '.autocomplete', throttle((e) => searchAutocomplete(e)))
979
980        $(document).on('click', '.autocomplete-datafetch a', function(e){
981            var form = e.currentTarget.closest('.search-form').querySelector('.autocomplete');
982            form.value = e.currentTarget.getAttribute('data-title');
983            form.focus();
984            $(e.currentTarget.closest('.search-form')).submit();
985            e.currentTarget.closest('.autocomplete-datafetch').classList.remove('show');
986        })
987
988        $('.show-search button, #showSearch .close-button').click(function(e){
989            e.preventDefault();
990            $('#filters').toggleClass('show-search');
991        })
992
993        function searchAutocomplete(e){
994            console.log(e);
995            
996            if(e.currentTarget.value.length){
997                var action = null,
998                    post_type = null;
999
1000                switch (e.currentTarget.getAttribute('autocomplete-type')) {
1001                    case 'show':
1002                            action = 'show_fetch';
1003                            action = 'search_fetch';
1004                            post_type = ['trw-shows'];
1005                        break;
1006                    case 'search':
1007                    default:
1008                            action = 'search_fetch';
1009                            post_type = ['trw-shows', 'trw-authors'];
1010                        break;
1011                }
1012                jQuery.ajax({
1013                    url: trw.ajaxurl,
1014                    type: 'post',
1015                    data: { action: action, keyword: e.currentTarget.value, post_type: post_type },
1016                    success: function(data) {
1017                        const datafetch = e.currentTarget.closest('.search-form').querySelector('.autocomplete-datafetch');
1018                        datafetch.classList.add('show');
1019                        datafetch.innerHTML = data;
1020                    }
1021                });
1022            }
1023        }
1024
1025        $(document).click(function(e){
1026            if (!$(e.currentTarget).closest(".autocomplete-datafetch").length) {
1027                $('.autocomplete-datafetch').removeClass('show');
1028            }
1029        })
1030
1031        
1032        var checkout_form = $('form.checkout');
1033
1034        checkout_form.on('checkout_place_order', function() {
1035
1036            const stateFieldHolder = checkout_form.find('#billing_state_field');
1037            const stateField = checkout_form.find('#billing_state');
1038
1039            console.log(stateFieldHolder, stateFieldHolder[0].classList.contains('hiddenFix'));
1040
1041            if (stateFieldHolder[0].classList.contains('hiddenFix')) {
1042                stateField.val('none');
1043                stateField[0].setAttribute('value', 'none');
1044            }
1045
1046            return true; // or return false;
1047        });
1048
1049        checkSetState(checkout_form.find('#billing_country').val());
1050
1051        $('#billing_country').on('change', function() {
1052            var selectedCountry = $(this).val();
1053            checkSetState(selectedCountry);
1054        });
1055
1056        $('[aria-controls="checkoutSummary"]').click(function(e){
1057            e.preventDefault();
1058            $('#checkoutSummary').toggleClass('show');
1059            if($('#checkoutSummary').hasClass('show')){
1060                $('[aria-controls="checkoutSummary"]').attr('aria-expanded', 'true');
1061            } else {
1062                $('[aria-controls="checkoutSummary"]').attr('aria-expanded', 'false');
1063            }
1064        })
1065
1066	});
1067
1068    function checkSetState(selectedCountry = 'US'){
1069        var countryInfo = JSON.parse(wc_address_i18n_params.locale);
1070        console.log('Billing country changed to: ' + selectedCountry);
1071        console.log(countryInfo, countryInfo[selectedCountry]);
1072
1073        const stateFieldHolder = $('form.woocommerce-checkout #billing_state_field');
1074        
1075        
1076        if (countryInfo[selectedCountry] && countryInfo[selectedCountry].state && countryInfo[selectedCountry].state.hidden){
1077            stateFieldHolder[0].classList.add('hiddenFix');
1078        } else {
1079            stateFieldHolder[0].classList.remove('hiddenFix');
1080        }
1081    }
1082
1083}( jQuery ) );
1084
1085function setCookie(cName, cValue, expDays) {
1086        let date = new Date();
1087        date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
1088        const expires = "expires=" + date.toUTCString();
1089        document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
1090}
1091
1092function getCookie(cName) {
1093      const name = cName + "=";
1094      const cDecoded = decodeURIComponent(document.cookie); //to be careful
1095      const cArr = cDecoded .split('; ');
1096      let res;
1097      cArr.forEach(val => {
1098          if (val.indexOf(name) === 0) res = val.substring(name.length);
1099      })
1100      return res;
1101}
1102
1103function debounce(func, wait = 500, immediate = true) {
1104    var timeout;
1105    return function() {
1106        var context = this, args = arguments;
1107        var later = function() {
1108            timeout = null;
1109            if (!immediate) func.apply(context, args);
1110        };
1111        var callNow = immediate && !timeout;
1112        clearTimeout(timeout);
1113        timeout = setTimeout(later, wait);
1114        if (callNow) func.apply(context, args);
1115    };
1116}
1117
1118function throttle(func, delay = 500) {
1119  let lastRan = false, //last time the function got ex ecuted
1120      trailingArgs = null; //last arguments
1121
1122  return function (...args) { //returns function
1123    if (!lastRan) { //if the function didnt get executed before
1124      func.apply(this, args) // call the function
1125      lastRan = true; //update the flag
1126      let timer = () => setTimeout(() => { //while executing 
1127        lastRan = false; //update the flag
1128        if (trailingArgs) { // if last arguments exist
1129          func.apply(this, trailingArgs); //invoke the function with those last arguments
1130          lastRan = true; //update the flag
1131          trailingArgs = null; //reset the arguments
1132          timer(); 
1133        }
1134      }, delay);
1135      timer(); 
1136    }
1137    else // if function got executed before
1138      trailingArgs = args //else update the last arguments with passed arguments
1139  }
1140}

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.