1(function($, root, undefined) { 2 3 $(function() { 4 5 'use strict'; // DOM ready, take it away 6 7 // smooth scrolling anchors 8 function filterPath(string) { 9 return string 10 .replace(/^\//, '') 11 .replace(/(index|default).[a-zA-Z]{3,4}$/, '') 12 .replace(/\/$/, ''); 13 } 14 15//Handle showing and hiding of search bar 16$('body').on('click', '.site-search-btn', function () { 17 toggleSearch(); 18}); 19 20function toggleSearch(){ 21 if ($('#search-bar').is(':visible')) { 22 $('#search-bar').slideUp(); 23 } else { 24 $('#search-bar').slideDown(); 25 $('#site-search').focus(); 26 } 27} 28 29 30$('#close-search').click(function () { 31 $('#search-bar').slideUp(); 32}); 33 34 //Slider timer 35 var slider_timer = setInterval(function(){ 36 $('.js-carrousel__button__next').trigger('click'); 37 }, 4000); 38 39 $('body').on('click','.js-carrousel__button__next', function(e){ 40 //If this is a user click, rather than a programatically generated one from the above interval timer 41 if(e.hasOwnProperty('originalEvent')){ 42 //Cancel timer, as user has now interacted with the slider 43 clearInterval(slider_timer); 44 } 45 }); 46 47 48 var locationPath = filterPath(location.pathname); 49 var scrollElem = scrollableElement('html', 'body');Â 50 //$('a[href^="#"]').each(function() { 51 $('body:not(.single-product):not(.members-page) a[href^="#"]').each(function() { 52 var thisPath = filterPath(this.pathname) || locationPath; 53 if (Â locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/, '')) { 54 var $target = $(this.hash), 55 target = this.hash; 56 if (target) { 57 var targetOffset = $target.offset(); 58 $(this).click(function(event) { 59 event.preventDefault(); 60 $(scrollElem).animate({ 61 scrollTop: targetOffset.top 62 }, 400, function() { 63 // location.hash = target; 64 }); 65 }); 66 } 67 } 68 });Â 69 // use the first element that is "scrollable" 70 function scrollableElement(els) { 71 for (var i = 0, argLength = arguments.length; i < argLength; i++) { 72 var el = arguments[i], 73 $scrollElement = $(el); 74 if ($scrollElement.scrollTop() > 0) { 75 return el; 76 } else { 77 $scrollElement.scrollTop(1); 78 var isScrollable = $scrollElement.scrollTop() > 0; 79 $scrollElement.scrollTop(0); 80 if (isScrollable) { 81 return el; 82 } 83 } 84 } 85 return []; 86 } 87 88 //display scroll up button 89 var target = 200; // distance to scroll before triggering 90 var timeout = null; // timeout used to prevent constant running of function, runs only every 250ms max 91 92 $(window).scroll(function() { 93 if (!timeout) { 94 timeout = setTimeout(function() { 95 clearTimeout(timeout); 96 timeout = null; 97 if ($(window).scrollTop() >= target) { 98 $('.scroll-to-top').addClass('active'); 99 } 100 }, 250); 101 } 102 }); 103 104 }); 105 106})(jQuery, this); 107 108$ = jQuery; 109 110 111$(document).ready(function() { 112 113 //BLACKOUT 114 115 function blackout_hide() { 116 117 //closes search bar and responsive nav 118 $('.open-newsletter-signup').removeClass('active'); 119 $('.newsletter-form-popup').removeClass('active'); 120 $('.personal-trainer-popup').removeClass('active'); 121 $('.search-top-wrap').removeClass('active'); 122 $('.search-bar-wrap').removeClass('active'); 123 $('.search-top-wrap .fa').removeClass('fa-times'); 124 $('.blackout').removeClass('active'); 125 126 //responsive menu 127 $('.responsive-menu-wrap').removeClass('active'); 128 $('header, main, footer').removeClass('rm-active'); 129 $('body').removeClass('overflow-h'); 130 $('.blackout').css('z-index', 6); 131 } 132 133 $('.blackout').click(function() { 134 blackout_hide(); 135 }); 136 137 138 //RESPONSIVE MENU 139 140 $('.nav-responsive-menu').click(function() { 141 142 $('.responsive-menu-wrap').addClass('active'); 143 $('header, main, footer').addClass('rm-active'); 144 $('body').addClass('overflow-h'); 145 $('.blackout').addClass('active').css('z-index', 100); 146 147 return false;
148 }); 149 150 $('.responsive-nav-close').click(function() { 151 152 blackout_hide(); 153 return false; 154 }); 155 156 157 $('.responsive-menu-wrap .menu-item-has-children > a').click(function() { 158 //lets you click on sub-menu anchors 159 if ($(this).hasClass('active')) { 160 return true; 161 } 162 $(this).toggleClass('active'); 163 $(this).next('.sub-menu').slideToggle() 164 165 return false; 166 }); 167 168 //Newsletter button 169 $('.open-newsletter-signup').on('click', function() { 170 171 if ($(this).hasClass('active')) { 172 blackout_hide(); 173 174 } else { 175 $(this).addClass('active'); 176 $('.blackout').addClass('active').css('z-index', 100); 177 $('.newsletter-form-popup').addClass('active'); 178 } 179 180 setTimeout(function () { 181 $('.newsletter-form-popup').find('input').focus(); 182 }, 500) 183 184 }); 185 186 187 $('.newsletter-form-popup .fa').click(function(event) { 188 blackout_hide(); 189 }); 190 191 //personal trainer button 192 $('.open-personal-trainer-bio').click(function() { 193 194 195 $('.personal-trainer-popup h3.name').html($(this).data('name')); 196 $('.personal-trainer-popup p.area').html($(this).data('area')); 197 $('.personal-trainer-popup p.content').html(descriptions[$(this).data('id')]).scrollTop(0); 198 $('.blackout').addClass('active').css('z-index', 100); 199 $('.personal-trainer-popup').addClass('active'); 200 201 202 203 }); 204 205 206 $('.personal-trainer-popup .btn-close').click(function(event) { 207 blackout_hide(); 208 }); 209 210 211 //SEARCH 212 213 $('.search-top-wrap').click(function() { 214 215 if ($(this).hasClass('active')) { 216 blackout_hide(); 217 218 } else { 219 $(this).addClass('active'); 220 $('.blackout').addClass('active'); 221 $('.search-bar-wrap').addClass('active'); 222 $(this).find('.fa').addClass('fa-times'); 223 } 224 225 setTimeout(function () { 226 $('.search-bar-wrap').find('input').focus(); 227 }, 500) 228 229 }); 230 231}); 232 233 234 235//matchHeight(); 236$(document).ready(function() { 237 238 $('.leisure-centre-row-inner').matchHeight(); 239 $('.fp-events-row .grid-content').matchHeight(); 240 $('.where-can-i-use-card .leisure-centre-row').matchHeight(); 241 $('.prices-wrap .prices-row .prices-row-inner').matchHeight(); 242 $('.pullout-link').matchHeight(); 243 $('.leisure-centres-small-inner .leisure-centre-row').matchHeight(); 244 $('.membership .leisure-centres-small-inner .leisure-centre-row h3').matchHeight(); 245 $('.leisure-centres-small-inner .leisure-centre-row .btn-box').matchHeight(); 246 $('.event-row .event-row-content').matchHeight(); 247 248}); 249 250 251$(document).ready(function() { 252 253var slider_looping = true; 254 255 function slide_right() { 256 id = $('.slider li.active').attr('data-attr-id'); 257 if (id == 3 ) { id = -1; } 258 $('.slider li').removeClass('active'); 259 $('.slider li').eq(parseInt(id) + 1).addClass('active'); 260 $('.fp-banner-small .slide-small').removeClass('active'); 261 $('.fp-banner-small .slide-small').eq(parseInt(id) + 1).addClass('active'); 262 } 263 function slide_left(){ 264 id = $('.slider li.active').attr('data-attr-id'); 265 if (id == 0 ) { id = 4; } 266 $('.slider li').removeClass('active'); 267 $('.slider li').eq(parseInt(id) - 1).addClass('active'); 268 $('.fp-banner-small .slide-small').removeClass('active'); 269 $('.fp-banner-small .slide-small').eq(parseInt(id) - 1).addClass('active'); 270 } 271 272 273 $('.slider-control .slide-right').click(function() { 274 slider_looping = false; 275 slide_right(); 276 }); 277 278 279 $('.slider-control .slide-left').click(function() { 280 slider_looping = false; 281 slide_left(); 282 }); 283 284 285 //smaller slider 286 $('.fp-banner-small .slide-small').click(function() { 287 slider_looping = false; 288 id = $(this).index(); 289 290 if (id == 3 ) { id = -1; } 291 292 $('.slider li').removeClass('active'); 293 $('.slider li').eq(parseInt(id)).addClass('active'); 294 295 $('.fp-banner-small .slide-small').removeClass('active'); 296 $(this).addClass('active'); 297 }); 298 299 300 function home_banner_loop() { 301 setTimeout(function () { 302 if(slider_looping == true){ 303 slide_right(); 304 home_banner_loop(); 305 } 306 }, 5000); 307 308 } 309 home_banner_loop(); 310 311 312 313 314 315 316 317 318 319}); 320 321 322$(document).ready(function() { 323 324 $('.faq-wrap h4').click(function() { 325 $(this).next().slideToggle('fast'); 326 }); 327 //Ensure URL value is in expected form 328 if(/^\#faq\-([0-9]{1,2})$/.test(window.location.hash)){ 329 $('.faq-wrap '+window.location.hash).next().toggle(); 330 } 331 332}); 333 334 335//GET ACTIVE FILTER 336 337$(document).ready(function() { 338 339 Isotope.Item.prototype._create = function() { 340 // assign id, used for original-order sorting 341 this.id = this.layout.itemGUID++; 342 // transition objects 343 this._transn = { 344 ingProperties: {}, 345 clean: {}, 346 onEnd: {} 347 }; 348 this.sortData = {}; 349 }; 350 351 Isotope.LayoutMode.create('none'); 352 353 var $grid = $('.activity-filter-grid').isotope({ 354 // options 355 itemSelector: '.activites-row', 356 layoutMode: 'none', 357 transitionDuration: 0, 358 hiddenStyle: { 359 opacity: 0 360 }, 361 visibleStyle: { 362 opacity: 1 363 } 364 }); 365 366 var iso = $grid.data('isotope'); 367 368 $grid.isotope( 'on', 'layoutComplete', function() { 369 370 var numItems = iso.filteredItems.length; 371 372 if (numItems == 0) { 373 $('.no-results').show(); 374 } else { 375 $('.no-results').hide(); 376 } 377 378 }); 379 380 //add active class to item 381 $('.activity-filter-options-bottom .filter-group a').click(function() { 382 383 if ($(this).hasClass('active')) { 384 $(this).removeClass('active'); 385 } else { 386 $(this).parent().parent().find('a').removeClass('active'); 387 $(this).addClass('active'); 388 } 389 390 }); 391 392 393 //find out which items have an active class, then filter results from that 394 $('.activity-filter-options-bottom').on( 'click', 'a', function() { 395 396 var $this = $(this); 397 398 var all_active = {}; 399 var all_active_name = {}; 400 401 402 $('.filter-group a.active').each(function(key, value) { 403 404 all_active[key] = $(value).attr('data-filter'); 405 all_active_name[key] = $(value).html(); 406 }); 407 408 active_filter = ""; 409 410 $.each(all_active_name, function(key, value) { 411 active_filter += '<span class="tag">' + value.toLowerCase() + '</span>'; 412 }); 413 414 if (active_filter.length > 0) { 415 $('.active-filters').html("<h6>Active Filters:</h6> " + active_filter); 416 } else { 417 $('.active-filters').html(""); 418 } 419 420 var filterValue = concatValues( all_active ); 421 $grid.isotope({ filter: filterValue }); 422 423 return false;
424 }); 425 426 // flatten object by concatting values 427 function concatValues( obj ) { 428 var value = ''; 429 for ( var prop in obj ) { 430 value += obj[ prop ]; 431 } 432 return value; 433 } 434 435 $('.activity-filter-options-top a').click(function() { 436 437 group = $(this).attr('data-attr-group'); 438 $('.activity-filter-options-top a').removeClass('active'); 439 $(this).addClass('active'); 440 441 $('.filter-group').removeClass('active'); 442 $('.filter-group-' + group).addClass('active'); 443 return false; 444 }); 445 446 $('.activity-filter-options-bottom li.reset').click(function() { 447 $('.activity-filter-options-bottom li.reset a').removeClass('active'); 448 $('.activity-filter-options-bottom a').removeClass('active'); 449 }); 450 451 //from leisure centre home pages, using the get query to auto select centres.. 452 //loop through all items that are active and click them to apply 453 if ($('body').hasClass('get-active')) { 454 $.each($('.filter-group a.leisure-active'),function(key,value) { 455 456 $(value).click(); //apply 457 $(value).removeClass('leisure-active'); 458 459 }); 460 } 461 462}); 463 464 465 466 467//Accessibility 468 469 470// Stylesheet Changes 471$(document).ready(function(){ 472 $('.colour-schemes ul li').click(function(){ 473 linkPath = 'https://www.lleisure.co.uk/wp-content/themes/liberty-leisure/css/'; 474 if ($(this).hasClass('dt') && $('#style-change').length > 0) { 475 $('#style-change').remove(); 476 if (Cookies.set('theme-check', { path: '/' }) !== 0) { 477 Cookies.remove('theme-check', { path: '/' }); 478 } 479 } else { 480 if ($(this).hasClass('hc')) { 481 if (Cookies.set('theme-check') == null) { 482 Cookies.set('theme-check', 'hc', { expires: 365, path: '/' }); 483 } else { 484 Cookies.set('theme-check', 'hc', { path: '/' }); 485 } 486 styleLink = $('.hc').attr('id'); 487 if ($('#style-change').length > 0) { 488 $('#style-change').attr('href',linkPath + styleLink + '.css'); 489 } else { 490 $('head').append('<link rel="stylesheet" href="'+linkPath+styleLink+'.css" id="style-change">'); 491 } 492 } 493 } 494 }); 495}); 496 497// Font Size Changes 498$(document).ready(function(){ 499 $('.font-size li').click(function(){ 500 if ($(this).hasClass('plus')) { 501 if (Cookies.get('font-check') === undefined) { 502 Cookies.set('font-check', '16', { expires: 365, path: '/' }); 503 } 504 currentSize = parseInt(Cookies.get('font-check'),10); 505 newSize = currentSize + 1; 506 Cookies.set('font-check', newSize, { path: '/' }); 507 $('body').attr('style','font-size:'+newSize+'px'); 508 } else { 509 if (Cookies.get('font-check') === undefined) { 510 Cookies.set('font-check', '16', { expires: 365, path: '/' }); 511 } 512 currentSize = parseInt(Cookies.get('font-check'),10); 513 newSize = currentSize - 1; 514 Cookies.set('font-check', newSize, { path: '/' }); 515 $('body').attr('style','font-size: '+newSize+'px'); 516 } 517 }); 518 $('.font-size .reset').click(function(){ 519 Cookies.remove('font-check', { path: '/' }); 520 $('body').attr('style','font-size:16px'); 521 }); 522}); 523 524// Cookie Checks and Accessibility Changes 525$(document).ready(function(){ 526 resetTheme = Cookies.get('theme-check'); 527 if (resetTheme == 'hc') { 528 $('.colour-schemes .hc').trigger('click'); 529 } 530 if (Cookies.get('font-check') !== undefined) { 531 currentSize = Cookies.get('font-check'); 532 if (currentSize !== 16) { 533 $('body').attr('style','font-size:'+currentSize+'px'); 534 } 535 } 536}); 537 538// Accessibility Trigger 539$(document).ready(function(){ 540 $('.accessibility-trigger').click(function(){ 541 if ($('.accessibility').hasClass('active')) { 542 $('.accessibility').removeClass('active'); 543 } else { 544 $('.accessibility').addClass('active'); 545 } 546 return false;
547 }); 548}); 549 550 551 552//EVENT FILTER 553 554$(document).ready(function() { 555 556 Isotope.Item.prototype._create = function() { 557 // assign id, used for original-order sorting 558 this.id = this.layout.itemGUID++; 559 // transition objects 560 this._transn = { 561 ingProperties: {}, 562 clean: {}, 563 onEnd: {} 564 }; 565 this.sortData = {}; 566 }; 567 568 Isotope.LayoutMode.create('none'); 569 570 var $grid = $('.event-filter-grid').isotope({ 571 // options 572 itemSelector: '.event-row', 573 layoutMode: 'none', 574 transitionDuration: 0, 575 hiddenStyle: { 576 opacity: 0 577 }, 578 visibleStyle: { 579 opacity: 1 580 } 581 }); 582 583 var iso = $grid.data('isotope'); 584 585 586 $grid.isotope( 'on', 'layoutComplete', function() { 587 588 var numItems = iso.filteredItems.length; 589 590 if (numItems == 0) { 591 $('.no-results').show(); 592 } else { 593 $('.no-results').hide(); 594 } 595 596 }); 597 598 function get_filter_values() { 599 600 var filterValue = ""; 601 602 filter_cat_val = $('.event-filter-category').val(); 603 filter_month_val = $('.event-filter-month').val(); 604 filter_year_val = $('.event-filter-year').val(); 605 606 607 if (filter_cat_val.length > 0) { 608 filterValue += ".term-"+ filter_cat_val; 609 } 610 611 if (filter_month_val.length > 0) { 612 filterValue += ".month-"+ filter_month_val; 613 } 614 615 if (filter_year_val.length > 0) { 616 filterValue += ".year-"+ filter_year_val; 617 } 618 619 $grid.isotope({ filter: filterValue }); 620 } 621 622 623 $('.event-filter-category').change(function() { 624 get_filter_values(); 625 }); 626 $('.event-filter-month').change(function() { 627 get_filter_values(); 628 }); 629 $('.event-filter-year').change(function() { 630 get_filter_values(); 631 }); 632 633 634 635}); 636 637 638//Make non-datatables tables responsive 639$(function() { 640 $('table:not(.dataTable)').wrap('<div style="overflow-x:auto;width:100%"></div>'); 641}); 642 643//LES MILLS NEWSLETTER SIGNUP 644 645$(document).ready(function() { 646 $('.lm-newsletter-form').submit(function(e) { 647 e.preventDefault(); 648 $('.lm-newsletter-wrap .email-error').remove(); 649 $('.lm-newsletter-wrap .terms-error').remove(); 650 651 if ($(this).find('.field-newsletter-email').val().length < 1) { 652 $(this).after("<p class='email-error'>Please enter your email address</p>"); 653 return false; 654 } 655 656 if ($(this).find('input.terms:checked').length < 1) { 657 $(this).after("<p class='terms-error'>Please confirm that you understand and accept the privacy notice</p>"); 658 return false; 659 } 660 661 662 $('.lm-newsletter-wrap .newsletter-loading').addClass('show'); 663 664 var url = "https://api.govdelivery.com/api/add_script_subscription"; 665 var values = {}; 666 667 values["e"] = $(this).find('.field-newsletter-email').val(); 668 values["t"] = 'UKBROXTOWE_LIBERTY_9'; 669 values["k"] = "uyWbUW3MDZbrQGqVhZJE3066YMg0YnMGOaHGiZgRYlZUvJqY9YyCtGbIYz_WEvFTm10RouNt7RbSK4vv3CHX9A"; 670 671 $.ajax({ 672 url: url, 673 data: values, 674 dataType: "jsonp", 675 jsonp : "c", 676 jsonpCallback: "newsletter_callback_lm" 677 }); 678 679 680 }); 681 682 683 $('.lm-newsletter-form .field-newsletter-email').on('input',function(e){ 684 $('.lm-newsletter-wrap .email-error').remove(); 685 }); 686 687 $('.lm-newsletter-form input.terms').click(function(e){ 688 $('.lm-newsletter-wrap .terms-error').remove(); 689 }); 690}); 691 692// Named callback function from the ajax call when jsonpbtn2 clicked 693function newsletter_callback_lm(response) { 694 695 $('.lm-newsletter-wrap .newsletter-loading').removeClass('show'); 696 697 if (response.errors) { 698 $('.lm-newsletter-wrap .newsletter-response-error').show(); 699 700 } else { 701 702 $('.lm-newsletter-form').hide(); 703 $('.lm-newsletter-wrap p').hide(); 704 $('.lm-newsletter-wrap .newsletter-response').show(); 705 } 706 707} 708 709// testimonial slider 710 711$(document).ready(function() { 712 713 $('.testimonial-list__item').matchHeight(); 714 715 $('.testimonial-list').css('height', $('.testimonial-list__item').outerHeight()); 716 717 function testimonial_slider() { 718 719 clearTimeout(timer); 720 721 $('.testimonial-list__item:last-of-type').fadeOut(500, 'linear', function() { 722 $('.testimonial-list__item:last-of-type').prependTo('.testimonial-list').show(); 723 724 timer = setTimeout(function() { 725 testimonial_slider(); 726 }, 5000); 727 728 }); 729 730 731 } 732 733 timer = setTimeout(function() { 734 testimonial_slider(); 735 }, 5000); 736 737}); 738 739 740//Tooltips 741var target; 742var title; 743var tooltip; 744var shown_by_touch = false;
745var shown_by_hover = false; 746$(function() { 747 748 749 $(document).on('touchstart', 'i[rel~="tooltip"]', function(e) { 750 e.stopImmediatePropagation(); 751 shown_by_touch = true; 752 hide(); 753 target = $(this); 754 show(); 755 }); 756 $(document).on('mouseover', 'i[rel~="tooltip"]', function(e) { 757 if (!shown_by_touch) { 758 target = $(this); 759 show(); 760 shown_by_hover = true; 761 } 762 }); 763 $(document).on('mouseleave', 'i[rel~="tooltip"]', function() { 764 if (shown_by_hover) { 765 shown_by_hover = false; 766 hide(); 767 } 768 }); 769 $(document).on('touchstart', function(e) { 770 shown_by_touch = false; 771 hide(); 772 773 }); 774}); 775 776function show() { 777 if (!$('#tooltip').is(':visible')) { 778 title = target.attr('title'); 779 if (!title || title == '') return false; 780 tooltip = $('<div id="tooltip"></div>'); 781 tooltip.hide(); 782 tooltip.html(title); 783 tooltip.appendTo('body') 784 target.removeAttr('title'); 785 if ($(window).width() < tooltip.outerWidth() * 1.5) { 786 tooltip.css('max-width', $(window).width() / 2); 787 } else { 788 tooltip.css('max-width', 340); 789 } 790 var pos_left = target.offset().left + (target.outerWidth() / 2) - (tooltip.outerWidth() / 2), 791 pos_top = target.offset().top - tooltip.outerHeight() - 20; 792 if (pos_left < 0) { 793 pos_left = target.offset().left + target.outerWidth() / 2 - 20; 794 tooltip.addClass('left'); 795 } else { 796 tooltip.removeClass('left'); 797 } 798 if (pos_left + tooltip.outerWidth() > $(window).width()) { 799 pos_left = target.offset().left - tooltip.outerWidth() + target.outerWidth() / 2 + 20; 800 tooltip.addClass('right'); 801 } else { 802 tooltip.removeClass('right'); 803 } 804 if (pos_top < 0) { 805 var pos_top = target.offset().top + target.outerHeight(); 806 tooltip.addClass('top'); 807 } else { 808 tooltip.removeClass('top'); 809 } 810 tooltip.css({ 811 left: pos_left, 812 top: pos_top + 10 813 }); 814 tooltip.show(); 815 } 816} 817 818function hide() { 819 if ($('#tooltip').is(':visible')) { 820 $('#tooltip').remove(); 821 target.attr('title', title); 822 } 823} 824 825 826 827 828
829//Type writer effect for site alerts 830document.addEventListener('DOMContentLoaded', function() { 831 if(document.getElementById('typed-strings') !== null){ 832 var typed = new Typed('#page_alert_typed', { 833 stringsElement: '#typed-strings', 834 //strings: ["First sentence.", "Second sentence."], 835 typeSpeed: 30, 836 loop:false, 837 backDelay: 5000, 838 backSpeed:30, 839 startDelay: 1000, 840 fadeOut:false, 841 showCursor:false 842 //onComplete: function() { $('.typed-cursor').fadeTo(400,0); }, 843 }); 844 } 845});
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.