PageSourceSearch

https://rsaqua.co.uk/wp-content/themes/bespoke/js/scripts.min.js?ver=1.22

js rsaqua.co.uk collected 2026-10-02 03:58:38 UTC 42,242 bytes, 1,341 lines download raw bytes

1/*
2Bespoke javascript
3
4Built by Jonathan Brain
5http://jonathanbrain.com
6*/
7
8var maps = [];
9var scroll_position = 0;
10var animations = [];
11var animations_event = false;
12var lazyload = false;
13var ie = 100;
14
15
16// set up page and events
17$(document).ready( function() {
18
19    ie_check();
20    init();
21
22	// resize trigger
23	setTimeout( function() {
24		//$(window).trigger('resize').trigger('scroll');
25	}, 500 );
26
27});
28
29function init() {
30
31    // Initialise
32    header();
33    responsive_nav();
34
35    lazy_load();
36    ajax_post_more();
37    ajax_post_filter();
38
39    carousel();
40    anchors();
41
42    product_filter();
43
44    partners();
45    video_play();
46    //video_launch();
47    //audio_launch();
48
49    lightbox();
50
51    map();
52
53    animation_init();
54
55    popup_form();
56
57    search_init();
58}
59
60
61function ie_check() {
62
63    // IE11
64    var ua = window.navigator.userAgent;
65    var trident = ua.indexOf('Trident/');
66    var rv = ua.indexOf('rv:11');
67    if (trident > 0 && rv > 0) {
68        document.documentElement.className += ' ie11';
69        ie = 11;
70    }
71
72    // IE10
73    if (Function('/*@cc_on return document.documentMode===10@*/')()){
74        document.documentElement.className += ' ie10';
75        ie = 10;
76    }
77
78    // IE9
79    if ( $('html').hasClass('ie9') ) {
80        ie = 9;
81    }
82
83}
84
85
86function header() {
87
88    // set up scroll event
89    $(window).scroll( function() {
90
91        var scroll_offset = scroll_pos();
92        var header = $('#header');
93
94        // Show / hide header
95        if ( (screen_size('small') && scroll_offset > scroll_position-1 && scroll_offset > 100) || (screen_size('full') && scroll_offset > 100) ) {
96
97            // hide header
98            if ( !header.hasClass('header-hidden') ) {
99                header.addClass('header-hidden').removeClass('header-visible');
100            }
101        }
102        else {
103            // show header
104            if ( header.hasClass('header-hidden') ) {
105                header.addClass('header-visible').removeClass('header-hidden');
106            }
107        }
108
109        // Scroll offset
110        if ( scroll_offset <= 100 ) {
111            header.addClass('header-top');
112        }
113        else {
114            header.removeClass('header-top');
115        }
116
117        scroll_position = scroll_offset;
118
119    }).trigger('scroll');
120}
121
122function responsive_nav() {
123
124    $('#header-nav-button')
125        .click( function() {
126
127            var html = $('html');
128
129            if ( html.hasClass('nav-active') ) {
130
131                // Get saved scroll position
132                var scroll_position = html.attr('data-scroll');
133                if ( scroll_position < 150 ) {
134                    scroll_position = 0;
135                }
136
137                // Hide nav (and show other content)
138                html.removeClass('nav-active');
139
140                // Restore current scroll position
141                $('html, body').stop().animate({ scrollTop: scroll_position }, 0 );
142            }
143            else {
144
145                // Close search
146                if ( $('html').hasClass('search-active') ) {
147                    $('#search-close').trigger('click');
148                }
149
150                // Save current scroll position
151                html.attr('data-scroll', scroll_pos());
152
153                // Display nav (and remove other content)
154                html.addClass('nav-active');
155
156                // Ensure nav is displayed without scroll
157                $('html, body').stop().animate({ scrollTop: 0 }, 0 );
158            }
159
160            return false;
161        });
162
163    $(window).resize( function() {
164        if ( $('html').hasClass('nav-active') && screen_size('full') ) {
165            $('#header-nav-button').trigger('click');
166        }
167    });
168}
169
170
171/** get new scroll position - target is jquery element */
172function get_scroll_to_position(target) {
173    return $( target ).offset().top;
174}
175
176
177/** scroll to new page position */
178function scroll_to( target_position ) {
179
180    //get current scroll position
181    var scroll_top = scroll_pos();
182
183    //scroll
184    $('html, body').stop().animate({ scrollTop: target_position }, 800, 'swing');
185}
186
187function scroll_pos() {
188    return ( document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop );
189}
190
191
192function screen_size(size) {
193    var screen_width = window.getComputedStyle(document.body, ':after').getPropertyValue('content');
194    return (screen_width.indexOf(size) != -1);
195}
196
197function anchors() {
198
199    $('a[href^="#"]').click( function() {
200        var id = $(this).attr('href');
201        if ( id.length > 1 && $(id).length == 1 ) {
202            var offset = $(id).offset();
203            scroll_to(offset.top);
204            return false;
205        }
206    });
207}
208
209
210function lazy_load() {
211
212    lazyload = $('.lazy').Lazy({
213        effect: "fadeIn",
214        effectTime: 1000,
215        chainable: false
216    });
217}
218
219
220function animation_init() {
221
222    // Reset animations array - in case we're using Barba
223    animations = [];
224
225    // get all animation items and store them in an array
226    // we'll animate them when they appear on screen (upon scroll)
227    animation_positions();
228
229    // initialise states of animated items
230    animation_init_increment();
231
232    //set interval
233    if ( animations.length > 0 ) {
234        setTimeout( function() { animations_event = setInterval( function() { animate(); }, 20 ); }, 100 );
235    }
236
237    // scroll event
238    $(window).scroll( function() {
239        animation_status();
240    }).trigger('scroll');
241
242}
243
244
245function animation_positions() {
246
247    // get all animation items and store them in an array
248    // we'll animate them when they appear on screen (upon scroll)
249    $('.animation-scroll-trigger').each(function (index) {
250
251        var offset = $(this).offset();
252
253        if (animations[index]) {
254            animations[index].top = Math.floor(offset.top);
255        }
256        else {
257            animations[index] = {
258                'top': Math.floor(offset.top),
259                'status': 'waiting'
260            };
261        }
262
263        $(this).attr('data-animation-id', index);
264    });
265
266
267    // Slightly different routine to re-calculate positions after resize
268    $(window).resize( function() {
269
270        //console.log('RESIZE');
271
272        $('.animation-scroll-trigger[data-animation-id]').each(function () {
273
274            var id = parseInt($(this).attr('data-animation-id'));
275            var offset = $(this).offset();
276            animations[id].top = Math.floor(offset.top);
277
278            //console.log(id + ' - ' + animations[id].top + ' - ' + animations[id].status);
279        });
280
281    });
282
283}
284
285
286function animation_status() {
287
288    var threshold = Math.floor(scroll_pos() + ( $(window).height() * 0.75 ));
289
290    for ( i = 0; i < animations.length; i++ ) {
291
292        if (threshold > animations[i].top && animations[i].status != 'complete' ) {
293            animations[i].status = 'active';
294        }
295    }
296
297}
298
299
300function animate() {
301
302    for ( i = 0; i < animations.length; i++ ) {
303
304        if ( animations[i].status == 'active' ) {
305
306            var element = $('[data-animation-id="' + i + '"]');
307
308            //console.log(i+': '+animations[i].status);
309
310            // banner
311            if ( element.hasClass('animation-fade-in') ) {
312
313                element.addClass('animation-fade-in-action');
314                animations[i].status = 'complete';
315            }
316            else if ( element.hasClass('animation-slide-up') ) {
317
318                element.addClass('animation-slide-up-action');
319                animations[i].status = 'complete';
320            }
321            else if ( element.hasClass('animation-staggered-slide-up') ) {
322
323                element.addClass('animation-staggered-slide-up-action');
324                animations[i].status = 'complete';
325            }
326            else if ( element.hasClass('animation-slide-left') ) {
327
328                element.addClass('animation-slide-left-action');
329                animations[i].status = 'complete';
330            }
331            else if ( element.hasClass('animation-slide-right') ) {
332
333                element.addClass('animation-slide-right-action');
334                animations[i].status = 'complete';
335            }
336            else if ( element.hasClass('animation-multiple') ) {
337
338                element.addClass('animation-multiple-action');
339                animations[i].status = 'complete';
340            }
341            else if ( element.hasClass('animation-scale-up') ) {
342
343                element.addClass('animation-scale-up-action');
344                animations[i].status = 'complete';
345            }
346            else if ( element.hasClass('animation-timeline') ) {
347
348                element.addClass('animation-timeline-action');
349
350                element.find('.animation-timeline-target').each(function(index) {
351                    var delay = index*1000;
352                    var elem = element.find('.animation-timeline-target');
353                    setTimeout( timeline_class, delay, $(this), 1); // Dot filled
354                    setTimeout( timeline_class, delay, $(this), 2); // Text slide in
355                    setTimeout( timeline_class, delay + 600, $(this), 3); // Draw line
356                    setTimeout( timeline_class, delay + 1200, $(this), 4); // Dot outline
357                });
358
359                animations[i].status = 'complete';
360            }
361            else if ( element.hasClass('animation-increment') ) {
362
363                var target_element = element.find('.animation-increment-target');
364                var target_number = parseInt(target_element.attr('data-animation-increment-target'));
365                var current_number = parseFloat(target_element.attr('data-animation-increment-current'));
366
367                if ( target_number !== '' ) {
368
369                    target_element.parent().addClass('active');
370                    element.addClass('animation-increment-action');
371
372                    var target_step = parseFloat(target_element.attr('data-animation-increment-step'));
373
374                    if ( (target_step > 0 && current_number < target_number) || (target_step < 0 && current_number > target_number) ) {
375                        current_number = current_number + target_step;
376                        target_element.attr('data-animation-increment-current', current_number );
377                        target_element.text(numberWithCommas(parseInt(current_number)));
378                    }
379                    else {
380                        target_element.text(numberWithCommas(target_number));
381                        target_element.parent().removeClass('active').addClass('complete');
382                        animations[i].status = 'complete';
383                    }
384
385                }
386                else {
387                    target_element.parent().removeClass('active').addClass('complete');
388                    animations[i].status = 'complete';
389                }
390            }
391            else if ( element.hasClass('animation-spin') ) {
392
393                var deg = ((scroll_pos() /10) % 360);
394                element.css('transform', 'rotate(' + deg + 'deg)');
395
396                // never completes
397                //animations[i].status = 'complete';
398            }
399            else {
400                // no associated animation
401                animations[i].status = 'complete';
402            }
403        }
404    }
405}
406
407
408function animation_init_increment() {
409
410    // initialise
411    $('.animation-increment').each( function() {
412        var target = $(this).find('.animation-increment-target');
413        var stat_start = parseInt(target.attr('data-value-start'));
414        var stat_end = parseInt(target.attr('data-value-end'));
415        var step = Math.abs(stat_start - stat_end)/75;
416        if ( stat_start > stat_end ) {
417            step = (step * -1);
418        }
419        if ( $.isNumeric(stat_end) ) {
420            target.attr({'data-animation-increment-target': stat_end, 'data-animation-increment-step': step, 'data-animation-increment-current': stat_start }).text(stat_start);
421        }
422        else {
423            target.attr('data-animation-increment-target', '');
424        }
425    });
426}
427
428function numberWithCommas(x) {
429    var parts = x.toString().split(".");
430    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
431    return parts.join(".");
432}
433
434
435function timeline_class( elem, step ) {
436    elem.addClass('animation-step-' + step);
437}
438
439
440function video_play() {
441
442    $('.video-play').click( function() {
443
444        var parent = $(this).closest('.video-parent');
445        var container = parent.find('.video-container');
446        var service = container.attr('data-video-service');
447        var id = container.attr('data-video-id');
448        var src = '';
449
450        if ( service == 'youtube' ) {
451            src = '//www.youtube.com/embed/' + id + '?rel=0&showinfo=0&autoplay=1'
452        }
453        else if ( service == 'vimeo' ) {
454            src = '//player.vimeo.com/video/' + id + '?badge=0&byline=0&portrait=0&title=0&autoplay=1&autopause=0'
455        }
456
457        parent.addClass('video-active');
458        container.append('<iframe src="' + src + '" webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder="0"></iframe>');
459
460        return false;
461    });
462}
463
464
465function video_launch() {
466
467    $('.video-launch').click(function() {
468        
469        var src = $(this).attr('href');
470
471        $('#video-overlay').remove();
472        $('body').append('<div id="video-overlay" style="display: none;"><div id="video-overlay-wrapper"><div id="video-overlay-inner"><iframe src="' + src + '" webkitallowfullscreen mozallowfullscreen allowfullscreen frameborder="0"></iframe></div><div id="video-overlay-close"><span></span><span></span></div></div></div>');
473        $('html').addClass('overlay-active');
474        $('#video-overlay').fadeIn(250);
475
476        $('#video-overlay').click(function() {
477
478            $(this).fadeOut(250, function() { $('#video-overlay').remove(); });
479            $('html').removeClass('overlay-active');
480
481            return false;
482        });
483
484        return false;
485    });
486}
487
488
489function audio_launch() {
490
491    $('.audio-launch').click(function() {
492
493        var src = $(this).attr('href');
494        var meta = $.parseJSON($(this).attr('data-audio').replace('&quot;', '"'));
495        var length = '';
496
497        $('#audio-overlay').remove();
498        $('body').append('<div id="audio-overlay" style="display: none;"><div id="audio-overlay-wrapper"><div id="audio-overlay-inner"><div id="audio-overlay-content"><h3>' + meta['title'] + '</h3><p>' + meta['caption'] + '</p><audio src="' + src + '" controls autoplay></audio></div><div id="audio-overlay-close"><span></span><span></span></div></div></div></div>');
499
500        $('html').addClass('overlay-active');
501        $('#audio-overlay').fadeIn(250);
502
503        $('#audio-overlay').click(function() {
504
505            $(this).fadeOut(250, function() { $('#audio-overlay').remove(); });
506            $('html').removeClass('overlay-active');
507
508            return false;
509        });
510
511        return false;
512    });
513}
514
515
516function ajax_post_more() {
517
518    $('.ajax-more a').click(function () {
519
520        var parent = $(this).closest('.ajax-more-parent'); // Main content block to capture
521        var target = parent.find('.ajax-more-target'); // List to add the new articles to
522        var url = $(this).attr('href') + ' #' + parent.attr('id');
523
524        //console.log(url);
525
526
527        // display loader
528        parent.find('.ajax-more a').replaceWith('<span class="popper" />');
529
530        // create temporary element to store loaded data into
531        $('#ajax-more-temp').remove();
532        $('body').append('<div id="ajax-more-temp" />');
533        var temp = $('#ajax-more-temp');
534        temp.hide();
535
536        // request new page from server
537        temp
538            .load(
539                url,
540                function() {
541
542                    // Replace or remove "more" button
543                    if ( temp.find('.ajax-more').length > 0 ) {
544                        parent.find('.ajax-more').replaceWith(temp.find('.ajax-more'));
545                    }
546                    else {
547                        parent.find('.ajax-more').remove();
548                    }
549
550                    // Add new content to display
551                    if ( temp.find('.ajax-more-content').length > 0 ) {
552
553                        target.append(temp.find('.ajax-more-content'));
554
555                        // Lazy-load any new images
556                        lazy_load();
557                    }
558
559                    // Remove temp
560                    temp.remove();
561
562                    // bind any "show more" button
563                    ajax_post_more();
564
565                    // bind any video/audio posts
566                    video_launch();
567                    audio_launch();
568
569                    //trigger resize (to recalculate any animation positions below the article list)
570                    $(window).trigger('resize');
571
572                });
573
574        return false;
575    });
576
577}
578
579function ajax_post_filter() {
580
581    $('.ajax-filter a').click(function () {
582
583        if ( $(this).hasClass('active') ) {
584            return false;
585        }
586
587        var parent = $(this).closest('.ajax-filter-parent'); // Main content block to capture
588        var target = parent.find('.ajax-filter-target'); // List to add the new articles to
589        var url = $(this).attr('href') + ' #' + parent.attr('id');
590
591        // Swap link
592        $(this).closest('ul').find('.active').removeClass('active');
593        $(this).addClass('active');
594
595        //console.log(url);
596
597
598        // display loader
599        target.prepend('<span class="popper" />');
600        target.find('article').css('opacity', '0');
601
602
603        // create temporary element to store loaded data into
604        $('#ajax-filter-temp').remove();
605        $('body').append('<div id="ajax-filter-temp" />');
606        var temp = $('#ajax-filter-temp');
607        temp.hide();
608
609        // request new page from server
610        temp
611            .load(
612                url,
613                function() {
614
615                    // Get content
616                    if ( temp.find('.ajax-filter-target').length > 0  ) {
617                        parent.find('.ajax-filter-target').replaceWith(temp.find('.ajax-filter-target'));
618
619                        // Lazy-load any new images
620                        lazy_load();
621                    }
622
623
624                    // Remove temp
625                    temp.remove();
626
627                    // bind any "load more" button
628                    ajax_post_more();
629
630                    // bind any video/audio posts
631                    video_launch();
632                    audio_launch();
633
634
635                    //trigger resize (to recalculate any animation positions below the article list)
636                    $(window).trigger('resize');
637
638                });
639
640        return false;
641    });
642
643}
644
645function carousel() {
646
647    // Blocks
648    if ($('.carousel-blocks .carousel-blocks-slide').length > 1) {
649        $('.carousel-blocks')
650            .slick({
651                dots: true,
652                arrows: false,
653                infinite: true,
654                speed: 250,
655                fade: false,
656                cssEase: 'linear',
657                autoplay: true,
658                autoplaySpeed: 8000
659            });
660    }
661
662    // Testimonials
663    if ($('.carousel-testimonials .carousel-testimonials-slide').length > 1) {
664        $('.carousel-testimonials')
665            .slick({
666                dots: true,
667                arrows: false,
668                infinite: true,
669                speed: 250,
670                fade: false,
671                cssEase: 'linear',
672                autoplay: true,
673                autoplaySpeed: 8000
674            });
675    }
676
677    // Events Carousel
678    if ($('.events-carousel li').length > 4) {
679        $('.events-carousel')
680            .slick({
681                dots: false,
682                slidesToShow: 4,
683                slidesToScroll: 1,
684                arrows: true,
685                infinite: true,
686                speed: 750,
687                fade: false,
688                cssEase: 'ease-in-out',
689                autoplay: true,
690                autoplaySpeed: 8000,
691                appendArrows: $('.events-carousel-nav'),
692                prevArrow:'<a href="javascript:void(0);" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="1px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="1px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>',
693                nextArrow:'<a href="javascript:void(0);" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="1px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="1px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>',
694                responsive: [
695                    {
696                      breakpoint: 1024,
697                      settings: {
698                        slidesToShow: 2,
699                        slidesToScroll: 1
700                      }
701                    }
702                ]
703            });
704    }
705
706
707    // Events Carousel
708    if ($('.image-carousel .image-wrapper').length > 4) {
709        $('.image-carousel')
710            .slick({
711                dots: false,
712                slidesToShow: 4,
713                slidesToScroll: 1,
714                arrows: true,
715                infinite: true,
716                speed: 750,
717                fade: false,
718                cssEase: 'ease-in-out',
719                autoplay: true,
720                autoplaySpeed: 8000,
721                appendArrows: $('.image-carousel-nav'),
722                prevArrow:'<a href="javascript:void(0);" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="0.5px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="0.5px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>',
723                nextArrow:'<a href="javascript:void(0);" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="0.5px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="0.5px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>',
724                responsive: [
725                    {
726                      breakpoint: 1024,
727                      settings: {
728                        slidesToShow: 2,
729                        slidesToScroll: 1
730                      }
731                    }
732                ]
733            });
734    }
735
736    // section-specialisms Carousel
737    if ($('.section-specialisms-carousel .slide').length > 1) {
738        $('.section-specialisms-carousel')
739            .slick({
740                dots: false,
741                slidesToShow: 1,
742                slidesToScroll: 1,
743                arrows: true,
744                infinite: true,
745                speed: 750,
746                fade: false,
747                cssEase: 'ease-in-out',
748                autoplay: true,
749                autoplaySpeed: 8000,
750                appendArrows: $('.section-specialisms-carousel-nav'),
751                prevArrow:'<a href="javascript:void(0);" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="0.5px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="0.5px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>',
752                nextArrow:'<a href="javascript:void(0);" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="0.5px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="0.5px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>'
753            });
754    }
755
756
757    // section-articles Carousel
758    if ($('.section-articles-carousel .slide').length > 1) {
759        $('.section-articles-carousel')
760            .slick({
761                dots: false,
762                slidesToShow: 1,
763                slidesToScroll: 1,
764                arrows: true,
765                infinite: true,
766                speed: 750,
767                fade: false,
768                cssEase: 'ease-in-out',
769                autoplay: true,
770                autoplaySpeed: 8000,
771                appendArrows: $('.section-articles-carousel-nav'),
772                prevArrow:'<a href="javascript:void(0);" class="slick-prev"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="0.5px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="0.5px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>',
773                nextArrow:'<a href="javascript:void(0);" class="slick-next"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 66.5 66.5"><circle fill="none" stroke="#16393e" stroke-width="0.5px" stroke-miterlimit="10" cx="33.25" cy="33.25" r="33"/><polyline fill="none" stroke="#16393e" stroke-width="0.5px" stroke-linecap="round" stroke-linejoin="round" points="30.59 25.16 39.15 33.72 30.59 42.29"/></svg></a>'
774            });
775    }
776
777    // Product carousel
778    if ($('.carousel-products .carousel-products-slide').length > 1) {
779        $('.carousel-products')
780            .slick({
781                dots: false,
782                arrows: false,
783                infinite: false,
784                speed: 250,
785                fade: false,
786                cssEase: 'ease',
787                autoplay: false,
788                draggable: false,
789                adaptiveHeight: true
790            }
791        )
792        .on('afterChange', function(event, slick, currentSlide){
793            lazy_load();
794        });
795
796        $('.carousel-products-nav-item').click(function() {
797            $('.carousel-products').slick('slickGoTo', $(this).index());
798            return false;
799        });
800    }
801
802    // header submenu toogle in mb view
803    $('#menu-mobile-menu li.menu-item-has-children a.sub-menu-arrow').click(function(){
804        $(this).parent().toggleClass('submenu-open');
805    });
806
807}
808
809function map() {
810
811    $('.map').each( function(index) {
812
813        // Add an ID
814        $(this).attr('id', 'map-' + index);
815
816        // Get map centre
817        var lat = $(this).attr('data-lat');
818        var lng = $(this).attr('data-lng');
819        var centre = new google.maps.LatLng(lat,lng);
820        var zoom = parseInt($(this).attr('data-zoom'));
821
822        // Define map
823        var map_options = {
824            zoom: zoom,
825            center: centre,
826            mapTypeId: 'roadmap',
827            mapTypeControl: false,
828            scrollwheel: false,
829            zoomControl: false,
830            zoomControlOptions: {
831                position: google.maps.ControlPosition.RIGHT_TOP
832            },
833            scaleControl: false,
834            streetViewControl: false,
835            fullscreenControl: false,
836            styles: [
837                {
838                    "elementType": "geometry",
839                    "stylers": [
840                        {
841                            "color": "#f7f7f7"
842                        }
843                    ]
844                },
845                {
846                    "elementType": "labels.icon",
847                    "stylers": [
848                        {
849                            "visibility": "off"
850                        }
851                    ]
852                },
853                {
854                    "elementType": "labels.text.fill",
855                    "stylers": [
856                        {
857                            "color": "#858585"
858                        }
859                    ]
860                },
861                {
862                    "elementType": "labels.text.stroke",
863                    "stylers": [
864                        {
865                            "color": "#f7f7f7"
866                        }
867                    ]
868                },
869                {
870                    "featureType": "administrative.land_parcel",
871                    "elementType": "labels.text.fill",
872                    "stylers": [
873                        {
874                            "color": "#858585"
875                        }
876                    ]
877                },
878                {
879                    "featureType": "poi",
880                    "elementType": "geometry",
881                    "stylers": [
882                        {
883                            "color": "#eeeeee"
884                        }
885                    ]
886                },
887                {
888                    "featureType": "poi",
889                    "elementType": "labels.text.fill",
890                    "stylers": [
891                        {
892                            "color": "#858585"
893                        }
894                    ]
895                },
896                {
897                    "featureType": "poi.park",
898                    "elementType": "geometry",
899                    "stylers": [
900                        {
901                            "color": "#e5e5e5"
902                        }
903                    ]
904                },
905                {
906                    "featureType": "poi.park",
907                    "elementType": "labels.text.fill",
908                    "stylers": [
909                        {
910                            "color": "#858585"
911                        }
912                    ]
913                },
914                {
915                    "featureType": "road",
916                    "elementType": "geometry",
917                    "stylers": [
918                        {
919                            "color": "#ffffff"
920                        }
921                    ]
922                },
923                {
924                    "featureType": "road.arterial",
925                    "elementType": "labels.text.fill",
926                    "stylers": [
927                        {
928                            "color": "#858585"
929                        }
930                    ]
931                },
932                {
933                    "featureType": "road.highway",
934                    "elementType": "geometry",
935                    "stylers": [
936                        {
937                            "color": "#dadada"
938                        }
939                    ]
940                },
941                {
942                    "featureType": "road.highway",
943                    "elementType": "labels.text.fill",
944                    "stylers": [
945                        {
946                            "color": "#858585"
947                        }
948                    ]
949                },
950                {
951                    "featureType": "road.local",
952                    "elementType": "labels.text.fill",
953                    "stylers": [
954                        {
955                            "color": "#858585"
956                        }
957                    ]
958                },
959                {
960                    "featureType": "transit.line",
961                    "elementType": "geometry",
962                    "stylers": [
963                        {
964                            "color": "#e5e5e5"
965                        }
966                    ]
967                },
968                {
969                    "featureType": "transit.station",
970                    "elementType": "geometry",
971                    "stylers": [
972                        {
973                            "color": "#eeeeee"
974                        }
975                    ]
976                },
977                {
978                    "featureType": "water",
979                    "elementType": "geometry",
980                    "stylers": [
981                        {
982                            "color": "#ededed"
983                        }
984                    ]
985                },
986                {
987                    "featureType": "water",
988                    "elementType": "geometry.fill",
989                    "stylers": [
990                        {
991                            "color": "#ededed"
992                        }
993                    ]
994                },
995                {
996                    "featureType": "water",
997                    "elementType": "labels.text.fill",
998                    "stylers": [
999                        {
1000                            "color": "#858585"
1001                        }
1002                    ]
1003                }
1004            ]
1005        };
1006
1007
1008        // Draw the map
1009        maps[index] = new google.maps.Map(document.getElementById('map-' + index), map_options);
1010
1011
1012        // Create a marker
1013        var marker = new google.maps.Marker({
1014            position: centre,
1015            map: maps[index],
1016            icon: {
1017                url: bespoke_wp.wp_theme_dir + '/images/map_marker.png',
1018                size: new google.maps.Size(352, 352),
1019                origin: new google.maps.Point(0, 0),
1020                anchor: new google.maps.Point(44, 44),
1021                scaledSize: new google.maps.Size(88, 88)
1022            }
1023        });
1024    });
1025}
1026
1027
1028function bespoke_article_submission() {
1029    cookie_set('academy-article', '1', 30);
1030    location.reload();
1031}
1032
1033/** create cookie */
1034function cookie_set( name, value, days ) {
1035
1036    if (days) {
1037        var date = new Date();
1038        date.setTime(date.getTime()+(days*24*60*60*1000));
1039        var expires = "; expires="+date.toGMTString();
1040    }
1041    else {
1042        var expires = "";
1043    }
1044
1045    document.cookie = name + "=" + value + expires + "; path=/";
1046}
1047
1048
1049
1050function product_filter() {
1051
1052    $('#product-filter .product-nav a[href^="http"]').click(function () {
1053
1054        if ( $(this).hasClass('active') ) {
1055            return false;
1056        }
1057
1058        var target = $('#product-filter'); // Main content block to capture
1059        var url = $(this).attr('href') + ' #' + target.attr('id');
1060
1061
1062        //console.log(url);
1063
1064
1065        // display loader
1066        target.find('.product-nav').prepend('<span class="popper" />');
1067        target.find('.product-filter-inner').css({'opacity': '0.3', 'pointer-events': 'none'});
1068
1069        // create temporary element to store loaded data into
1070        $('#ajax-filter-temp').remove();
1071        $('body').append('<div id="ajax-filter-temp" />');
1072        var temp = $('#ajax-filter-temp');
1073        temp.hide();
1074
1075        // request new page from server
1076        temp
1077            .load(
1078                url,
1079                function() {
1080
1081                    // Get content
1082                    if ( temp.find('#product-filter').length > 0  ) {
1083                        target.replaceWith(temp.find('#product-filter'));
1084
1085                        // Lazy-load any new images
1086                        lazy_load();
1087                    }
1088
1089
1090                    // Remove temp
1091                    temp.remove();
1092
1093
1094                    // Re-bind filer
1095                    product_filter();
1096                    anchors();
1097
1098                    //trigger resize (to recalculate any animation positions below the article list)
1099                    $(window).trigger('resize');
1100
1101                });
1102
1103        return false;
1104    });
1105}
1106
1107
1108function partners() {
1109
1110    $('.section-partners').each( function() {
1111
1112        var number = parseInt($(this).attr('data-number'));
1113        var cards = $(this).find('.section-partners-list');
1114
1115        if ( number < cards.find('.section-partners-partner').length ) {
1116            cards.find('.section-partners-partner:gt(' + (number-1) + ')').addClass('hidden');
1117            $(this).addClass('collapsed');
1118        }
1119
1120    });
1121
1122    $('.section-partners.collapsed .section-partners-more').click( function() {
1123
1124        var parent = $(this).closest('.section-partners');
1125        var number = parseInt(parent.attr('data-number'));
1126        var cards = parent.find('.section-partners-list');
1127
1128        cards.find('.section-partners-partner:not(:visible)').removeClass('hidden');
1129
1130        parent.removeClass('collapsed');
1131
1132        return false;
1133    });
1134
1135}
1136
1137
1138function popup_form() {
1139
1140    if ( $('#popup-box').length > 0 ) {
1141
1142        var box = $('#popup-box');
1143
1144        // Open form
1145        box.find('#popup-box-button').click(function() {
1146            box.addClass('active');
1147            return false;
1148        });
1149
1150        // Close form
1151        box.find('#popup-box-close').click(function() {
1152            box.removeClass('active');
1153            return false;
1154        });
1155
1156    }
1157}
1158
1159
1160function search_init() {
1161
1162    var search_data = [];
1163
1164    $('#search-open').click(function () {
1165
1166        var html = $('html');
1167
1168        if ( !html.hasClass('search-active') ) {
1169
1170            // Close nav
1171            if ( $('html').hasClass('nav-active') ) {
1172                $('#header-nav-button').trigger('click');
1173            }
1174
1175            // Get post data via ajax
1176            if (search_data.length == 0) {
1177                $.ajax({
1178                    url: bespoke_wp.wp_ajax_dir + '?action=bespoke_search_data',
1179                    dataType: 'json',
1180                    success: bind_search
1181                });
1182            }
1183
1184            // Save current scroll position
1185            html.attr('data-scroll', scroll_pos());
1186
1187            // Display nav (and remove other content)
1188            html.addClass('search-active');
1189
1190            // Ensure nav is displayed without scroll
1191            $('html, body').stop().animate({ scrollTop: 0 }, 0 );
1192
1193            // Clear current search term
1194            $('#search-box-input').val('');
1195
1196            // Show search box
1197            $('#search-box').show();
1198
1199        }
1200
1201        return false;
1202    });
1203
1204    $('#search-close').click(function () {
1205
1206        search_close();
1207
1208        return false;
1209    });
1210
1211    var window_width = $(window).width();
1212    $(window).resize( function() {
1213
1214        if ( $(window).width() == window_width ) {
1215            return;
1216        }
1217        else {
1218            window_width = $(window).width();
1219        }
1220
1221        if ( $('html').hasClass('search-active') ) {
1222            $('#search-close').trigger('click');
1223        }
1224    });
1225
1226    function search_close() {
1227
1228        var html = $('html');
1229
1230        // Get saved scroll position
1231        var scroll_position = html.attr('data-scroll');
1232        if ( scroll_position < 150 ) {
1233            scroll_position = 0;
1234        }
1235
1236        // Hide nav (and show other content)
1237        html.removeClass('search-active');
1238
1239        // Restore current scroll position
1240        $('html, body').stop().animate({ scrollTop: scroll_position }, 0 );
1241
1242        // Hide search box
1243        $('#search-box-input').autocomplete('close');
1244        $('#search-box').hide();
1245    }
1246
1247    function bind_search(data) {
1248
1249        search_data = data;
1250
1251        $('#search-box-input')
1252            .autocomplete({
1253                minLength: 1,
1254                source: search_data,
1255                position: { my: "left top+50", at: "left bottom" },
1256                focus: function (event, ui) {
1257                    $('#search-box-input').val(ui.item.value);
1258                    return false;
1259                },
1260                response: function( event, ui ) {
1261                    // Add search results count
1262                    var results = ui.content.length;
1263                    var results_text = 'results';
1264                    if ( results == 1 ) {
1265                        results_text = 'result';
1266                    }
1267                    $('#search-box-count').html(results + ' ' + results_text);
1268                },
1269                close: function( event, ui ) {
1270                    // Remove search results count
1271                    $('#search-box-count').html('');
1272                }
1273            })
1274            .autocomplete('instance')._renderItem = function (ul, item) {
1275
1276                // Highlight search value
1277                var val_lower = $('#search-box-input').val().toLowerCase();
1278                var label_lower = item.label.toLowerCase();
1279
1280                // Split lowercase version of label
1281                var label_lower_split = label_lower.replaceAll(val_lower, '|' + val_lower).split('|');
1282
1283                // Split mixed case version of label at same place(s)
1284                var label_mixed_split = Array();
1285                var pos = 0;
1286                for ( sub in label_lower_split ) {
1287                    label_mixed_split.push(item.label.substring(pos,pos+label_lower_split[sub].length));
1288                    pos = pos + label_lower_split[sub].length;
1289                }
1290
1291                // Combine
1292                var combined_string = '';
1293                var first = true;
1294                for ( sub in label_mixed_split ) {
1295                    if ( first ) {
1296                        combined_string = label_mixed_split[sub];
1297                    }
1298                    else {
1299                    //if (!first && label_mixed_split[sub].length >= val_lower.length) {
1300                        var sub_substring = label_mixed_split[sub].substring(0, val_lower.length);
1301                        combined_string = combined_string + label_mixed_split[sub].replace(sub_substring, '<em>' + sub_substring + '</em>');
1302                    }
1303
1304                    first = false;
1305                }
1306
1307                return $('<li>')
1308                    .append('<a href="' + item.url + '"><strong>' + item.type + ': </strong>' + combined_string + '</a>')
1309                    .appendTo(ul);
1310            };
1311    }
1312}
1313
1314function lightbox() {
1315
1316    // Modify default Fancybox settings
1317    $('[data-fancybox]:not(.slick-cloned)').fancybox({
1318        loop : true,
1319        smallBtn: true,
1320        toolbar: false,
1321        infobar: false,
1322        backFocus : false
1323    });
1324}
1325
1326
1327
1328
1329$('.specialism-tabs ul li a').on('click', function() {
1330    var sid = $(this).closest('li').attr('id');
1331    $('.specialism-tabs ul li.active').removeClass('active');
1332    $(this).closest('li').addClass('active');
1333    $('.specialism-tabs-content-inner.active').removeClass('active');
1334    $('.specialism-tabs-content-inner#'+sid+'_content').addClass('active');
1335});
1336
1337
1338
1339$('#product-contact-btn').on('click', function() {
1340    $('#popup-box-button').trigger('click');
1341});

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.