1$(window).load(function () { 2 "use strict"; 3 $("body").removeClass("preload"); 4 //console.log(location.pathname.split('/')); 5 setTimeout(function(){ 6 $("div.preloader").css({ 7 opacity: 0, 8 display:'none' 9 }) 10 },250); 11 12 $('.progress').hide(); 13 14}); 15 16window.addEventListener("load", function(){ 17 var contenthref= window.location.pathname; 18window.cookieconsent.initialise({ 19 "palette": { 20 "popup": { 21 "background": "#eeeeee", 22 "text": "#2b3445" 23 }, 24 "button": { 25 "background": "#008A32", 26 "text": "#ffffff" 27 } 28 }, 29 "content": { 30 "href": "/privacy" 31 } 32}); 33}); 34/* 35function testSize() { 36 "use strict"; 37 38 var windowwidth = $(window).width(); 39 40 $('.testsize').empty().html(windowwidth); 41 42} // testsize 43*/ 44function pageheight() { 45 "use strict"; 46 47 var windowheight = $(window).height(), 48 footerheight = $('footer').height(), 49 headerheight = $('header').height(), 50 contentheight = windowheight - footerheight - headerheight; // navbar borderbottom 51 52 $('#main').css('min-height', contentheight); 53 54 55 /* 56 var windowwidth = $(window).width(); 57 58 var rightcolumn = $('.rightcolumn').height(); 59 //console.log(rightcolumn); 60 if (windowwidth > 991) { 61 $('.leftcolumn > div').css('min-height', contentheight - 84 - 42); 62 //$('.leftcolumn > div').css('height', rightcolumn); 63 } else { 64 $('.leftcolumn > div').css('min-height', ''); 65 } 66 */ 67 68} // pageheight 69 70$(document).ready(function () { 71 "use strict"; 72 73 74 //testSize(); 75 76 allfunctions(); 77 pageheight(); 78 ajaxinit(); 79 header(); 80 81 $(window).resize(function () { 82 // testSize(); 83 pageheight(); 84 }); 85 86 var currentpage = window.location.href; 87 if (currentpage === 'https://www.gcsrewards.org/') { 88 //if (currentpage === 'http://localhost/') { 89 subscribepopup(); 90 //holidaypopup(); 91 } 92 93 if (window.location.href.indexOf("information") > -1) { 94 $('body').addClass('infopage'); 95 information(); 96 } 97 98 var listItem = $("#accordion .accordion-collapse.show a.activelink"); 99 //console.log(listItem); 100 if (listItem.length){ 101 setTimeout( function () { 102 $('#accordion .accordion-collapse.show .accordion-body').mCustomScrollbar('scrollTo', listItem,{ 103 //timeout:500 104 }); 105 }, 500); 106 } 107 108}); // doc ready 109 110function holidaypopup(){ 111 const myModal3 = new bootstrap.Modal('#holidayoffers', {}); 112 const modalToggle3 = document.getElementById('holidayoffers'); 113 myModal3.show(modalToggle3); 114} 115 116function holidayoffers(){ 117 "use strict"; 118 119 $(".holidayoffers p.card-text.offertext").mCustomScrollbar({ 120 theme:"dark-thin", 121 setTop: '0', 122 axis: "y", 123 scrollbarPosition: 'outside', 124 scrollInertia: 500, 125 scrollButtons: {enable: true}, 126 autoHideScrollbar:false, 127 mouseWheel: { 128 enable: true, 129 preventDefault: true 130 }, 131 callbacks:{ 132 onCreate:function(){ 133 $('.mCSB_buttonUp').attr('aria-label', 'Scroll Up'); 134 $('.mCSB_buttonDown').attr('aria-label', 'Scroll Down'); 135 } 136 } 137 }); 138 139} 140function subscribepopup(){ 141 "use strict"; 142 143 144 var checkcookiesubscribe = Cookies.get('subscribe'); 145 //console.log(checkcookiesubscribe); 146 147 if (checkcookiesubscribe){ 148 //console.log('yes cookie'); 149 } else { 150 //console.log('no cookie'); 151 Cookies.set('subscribe', 'popup', { 152 expires: 30 153 }); 154 //$('#subscribemodal').modal(); 155 const myModal = new bootstrap.Modal('#subscribemodal', {}); 156 const modalToggle = document.getElementById('subscribemodal'); 157 myModal.show(modalToggle); 158 } 159 160 161} // subscribebpopup 162 163function showLoader() { 164 "use strict"; 165 $('.progress').fadeIn(200); 166} 167function hideLoader() { 168 "use strict"; 169 $('.progress').fadeOut(400); 170} 171 172function setModalMaxHeight(element) { 173 this.$element = $(element);
174 this.$content = this.$element.find('.modal-content'); 175 var borderWidth = this.$content.outerHeight() - this.$content.innerHeight(), 176 dialogMargin = $(window).width() < 768 ? 20 : 60, 177 contentHeight = $(window).height() - (dialogMargin + borderWidth), 178 headerHeight = this.$element.find('.modal-header').outerHeight() || 0, 179 footerHeight = this.$element.find('.modal-footer').outerHeight() || 0, 180 maxHeight = contentHeight - (headerHeight + footerHeight); 181 182 this.$content.css({ 183 'overflow': 'hidden' 184 }); 185 186 this.$element.find('.modal-body').css({ 187 'max-height': maxHeight, 188 'overflow-y': 'auto' 189 }); 190} // setModalMaxHeight 191 192function modalHeights() { 193 "use strict"; 194 195 196 $('.modal').on('show.bs.modal', function () { 197 $(this).show(); 198 setModalMaxHeight(this); 199 200 }); 201 202 $(window).resize(function () { 203 if ($('.modal.in').length !== 0) { 204 setModalMaxHeight($('.modal.in')); 205 206 } 207 }); 208 209} // modalheights 210 211function debounce(func, wait, immediate) { 212 "use strict"; 213 214 var timeout; 215 return function () { 216 var context = this, args = arguments; 217 var later = function() { 218 timeout = null; 219 if (!immediate) { 220 func.apply(context, args); 221 } 222 }; 223 var callNow = immediate && !timeout; 224 clearTimeout(timeout); 225 timeout = setTimeout(later, wait); 226 if (callNow) {func.apply(context, args);} 227 }; 228} 229 230$.fn.isInViewport = function() { 231 var elementTop = $(this).offset().top; 232 var elementBottom = elementTop + $(this).outerHeight(); 233 234 var viewportTop = $(window).scrollTop(); 235 var viewportBottom = viewportTop + $(window).height(); 236 237 return elementBottom > viewportTop && elementTop < viewportBottom; 238}; 239 240 241function scrollTop2(){ 242 "use strict"; 243 244 245 246window.onload = function() { 247 var container = document.querySelector('.progress__container'); 248 var svg = document.querySelector('svg.progress-circle'); 249 var progressBar = document.querySelector('.progress-circle path'); 250 var totalLength = progressBar.getTotalLength(); 251 252 setTopValue(svg); 253 254 progressBar.style.strokeDasharray = totalLength; 255 progressBar.style.strokeDashoffset = totalLength; 256 257 $(window).on("scroll", function() { 258 setProgress(container, progressBar, totalLength); 259 }); 260 261 $(window).on("resize", function() { 262 setTopValue(svg); 263 }); 264} 265 266function setTopValue(svg) { 267 svg.style.top = document.documentElement.clientHeight * 0.5 - (svg.getBoundingClientRect().height * 0.5) + 'px'; 268} 269 270 271function setProgress(container, progressBar, totalLength) { 272 var clientHeight = document.documentElement.clientHeight; 273 var scrollHeight = document.documentElement.scrollHeight; 274 var scrollTop = document.documentElement.scrollTop; 275 276 var percentage = scrollTop / (scrollHeight - clientHeight); 277 if(percentage === 1) { 278 container.classList.add('completed'); 279 } else { 280 container.classList.remove('completed'); 281 } 282 progressBar.style.strokeDashoffset = totalLength - totalLength * percentage; 283} 284 285 $(window).scroll(function(){ 286 if ($(this).scrollTop() > 150) { 287 $('.progress-gotop').addClass('show'); 288 } else { 289 $('.progress-gotop').removeClass('show'); 290 } 291 }); 292 293 $('.progress-gotop').click(function(){ 294 295 if ($('html.ie9').length) { 296 $("html, body").animate({ scrollTop: 0 }, 300); 297 } else if ($('html.mobile')){ 298 $("html, body").animate({ scrollTop: 0 }, 300); 299 } 300 else { 301 $(document).stop(true).scrollTo($('html, body'), 300, { interrupt:true, easing:'linear' }); 302 } 303 return false; 304 }); 305 306} // scrolltop2 307 308/* Function to animate height: auto */ 309function autoHeightAnimate(element, time){ 310 var curHeight = element.height(), // Get Default Height 311 autoHeight = element.css('height', 'auto').height(); // Get Auto Height 312 element.height(curHeight); // Reset to Default Height 313 element.stop().animate({ height: autoHeight }, time); // Animate to Auto Height 314 315 if (autoHeight > $(window).height()){ 316 // $('#mobileNav').addClass('shrink'); 317 318 319 } 320 else { 321 322 } 323} // function autoheight 324 325function allfunctions(){ 326 "use strict"; 327 328 AOS.init(); 329
330 modalHeights(); 331 scrollTop2(); 332 setmaincat(); 333 setnationalcat(); 334 insidepages(); 335 ajaxFormInit(); 336 errorpages(); 337 catbuspages(); 338 ltopage(); 339 privacypage(); 340 341 342 if ($('#indexslides').length) { 343 $('body').removeClass('insidepage'); 344 $('body').addClass('homepage'); 345 indexpage(); 346 } else { 347 $('body').removeClass('homepage'); 348 $('body').addClass('insidepage'); 349 } 350 351 if ($('#allCat').length){ 352 discountspage(); 353 } 354 355 if ($('#vendordiscounts').length){ 356 vendorpage(); 357 } 358 359 if ($('#newvendors').length){ 360 checknewvendorpage(); 361 } 362 363 if ($('#nationaldiscounts').length){ 364 nationaldiscounts(); 365 } 366 367 if ($('#main').hasClass('searchpage')) { 368 searchPage(); 369 } 370 371 if ($('.appbox').length) { 372 $('body').addClass('mobileapp'); 373 mobileapp(); 374 } else { 375 $('body').removeClass('mobileapp'); 376 } 377 378 var $currentUrl = window.location.pathname; 379 var $currentPage = $currentUrl.replace(/\/?$/, ''); 380 381 var lastPart = $currentPage.substr($currentPage.lastIndexOf('/') + 1); 382 var matches = lastPart.match('category'); 383 384 var checkcookie = Cookies.get('maincat'); 385 if (checkcookie){ 386 387 if (!matches){ 388 Cookies.remove('maincat'); 389 } 390 391 if (matches){ 392 var currentcookie = checkcookie; 393 var currentfilter = $('a[data-filter=".'+currentcookie+'"]'); 394 //console.log(currentfilter); 395 currentfilter.parent().addClass('active'); 396 } 397 398 } // checkcookie 399 400 var matches2 = lastPart.match('national-educator-discounts'); 401 402 var checkcookie2 = Cookies.get('nationalcat'); 403 if (checkcookie2){ 404 405 if (!matches2){ 406 Cookies.remove('nationalcat'); 407 } 408 409 } // checkcookie 410 411 412 413} // allfunctions 414 415function ajaxinit(){ 416 "use strict"; 417 418 var $body = $('body'), 419 $main = $('#main'), 420 $site = $('html, body'), 421 transition = 'fade', 422 smoothState; 423 424 smoothState = $main.smoothState({ 425 anchors: 'a.ajax', 426 blacklist : ".no-smoothstate, .no-smoothstate a, [target], a[href='#']", 427 forms: '', 428 scroll: false, 429 onBefore: function($anchor, $container) { 430 var current = $('[data-viewport]').first().data('viewport'), 431 target = $anchor.data('target'); 432 current = current ? current : 0; 433 target = target ? target : 0; 434 if (current === target) { 435 transition = 'fade'; 436 } else if (current < target) { 437 transition = 'moveright'; 438 } else { 439 transition = 'fade'; 440 } 441 $('.ajaxcontent').fadeTo(0,0); 442 //alert('before'); 443 }, 444 onStart: { 445 duration: 400, 446 render: function () { 447 //$('#navbarCollapse').collapse('hide'); 448 //$main.attr('data-transition', transition); 449 //$("#main").addClass('is-exiting'); 450 $body.addClass('preload'); 451 $site.animate({scrollTop: 0}); 452 } 453 }, 454 onProgress: { 455 duration: 200, 456 render: function (){ 457 } 458 }, 459 onReady: { 460 duration: 0, 461 render: function ($container, $newContent) { 462 //console.log($container); 463 //$container.html($newContent); 464 $('.ajaxcontent').fadeTo(100,1); 465 //$container.removeClass('is-exiting'); 466 var content = $($newContent).find('.ajaxcontent').html(); 467 $('.ajaxcontent').html($(content)); 468 //alert('ready'); 469 } 470 }, 471 onAfter: function() { 472 allfunctions(); 473 setTimeout(function(){ 474 $body.removeClass('preload'); 475 476 },200); 477 478 479 } 480 }).data('smoothState'); 481 482} // ajaxinit 483 484function setmaincat(){ 485 "use strict"; 486 487 $('a.setmaincat').click(function() { 488 Cookies.remove('maincat'); 489 var maincatId = $(this).attr('id'); 490 var inFiveMinutes = new Date(new Date().getTime() + 5 * 60 * 1000); 491 492 Cookies.set('maincat', maincatId, { 493 expires: inFiveMinutes 494 }); 495 }); 496 497 $('a.removemaincat').click(function() { 498 Cookies.remove('maincat'); 499 }); 500 501} // indexicon 502 503function setnationalcat(){ 504 "use strict"; 505 506 $('a.setnationalcat').click(function() { 507 Cookies.remove('nationalcat'); 508 var nationalcatId = $(this).attr('id'); 509 var inFiveMinutes = new Date(new Date().getTime() + 5 * 60 * 1000); 510 511 Cookies.set('nationalcat', nationalcatId, { 512 expires: inFiveMinutes 513 }); 514 }); 515 516 $('a.removenationalcat').click(function() { 517 Cookies.remove('nationalcat'); 518 }); 519 520} // national category cookie 521 522function navposition(){ 523 "use strict"; 524 525 var stickySidebar = $('.navbar').offset().top; 526 527$(window).scroll(function() { 528 if ($(window).scrollTop() > stickySidebar) { 529 $('.navbar').addClass('affix'); 530 } 531 else { 532 $('.navbar').removeClass('affix'); 533 } 534}); 535 536} 537 538function header(){ 539 "use strict"; 540 541 navposition(); 542 543 var $currentpage = window.location.pathname; 544
545 var navcollapse = document.getElementById('navbarCollapse'); 546 navcollapse.addEventListener('hide.bs.collapse', function () { 547 $('.sub-menu.show').collapse('hide'); 548 }); 549 550 var searchcollapse = document.getElementById('searchCollapse'); 551 searchcollapse.addEventListener('shown.bs.collapse', function () { 552 setTimeout(function(){ 553 $('#headsearch2 input').focus(); 554 },100); 555 }); 556 557 $('#navbarCollapse a.dd-menu[href=#]').click(function(){ 558 return false; 559 }); 560 561 $('#navbarCollapse li.hassub').hover(function() { 562 $(this).addClass('show'); 563 $(this).find('>a').attr('aria-expanded', 'true'); 564 }, function() { 565 $(this).removeClass('show'); 566 $(this).find('>a').attr('aria-expanded', 'false'); 567 }); 568 569 570 $('button.navbar-toggler').click(function() { 571 $('.navbar-toggler').toggleClass('toggle'); 572 }); 573 574 $(window).resize(function () { 575 $('#navbarCollapse').collapse('hide'); 576 $('.navbar-toggler').removeClass('toggle'); 577 $('#searchCollapse').collapse('hide'); 578 }); 579 580 // CLOSE SEARCH CLICK OUTSIDE // 581 $('body').click(function(e) { 582 if (!$(e.target).closest('#searchCollapse').length){ 583 $('#searchCollapse').collapse('hide'); 584 585 } 586 }); 587 588 589} // header 590 591function indexpage(){ 592 "use strict"; 593 594 var indexswiper = new Swiper("#indexslides", { 595 slidesPerView: 1, 596 speed: 800, 597 //effect: 'fade', 598 parallax: true, 599 loop:true, 600 keyboard: { 601 enabled: true 602 }, 603 pagination: { 604 el: ".swiper-pagination", 605 dynamicBullets: false, 606 clickable: true, 607 enabled: false 608 }, 609 navigation: { 610 nextEl: '.swiper-button-next', 611 prevEl: '.swiper-button-prev', 612 enabled: false 613 }, 614 autoplay: { // change when live 615 delay: 5000, 616 disableOnInteraction: true, 617 }, 618 breakpoints: { 619 992: { 620 pagination: { 621 enabled: true 622 } 623 } 624 } 625 }); 626 627 $('.swiper-button-pause-play').click(function(){ 628 if ($(this).hasClass('pause')){ 629 $(this).removeClass('pause').addClass('play'); 630 indexswiper.autoplay.pause(); 631 } else { 632 $(this).removeClass('play').addClass('pause'); 633 indexswiper.autoplay.resume(); 634 } 635 }); 636 637 638 639 $("body").keydown(function(e) { 640 if(e.keyCode == 37) { // left 641 indexswiper.slidePrev(); 642 } 643 else if(e.keyCode == 39) { // right 644 indexswiper.slideNext(); 645 } 646}); 647 648 var categoryswiper = new Swiper("#categoryslide", { 649 slidesPerView: 1, 650 slidesPerGroup: 1, 651 grid: { 652 rows: 15, 653 fill: 'row' 654 }, 655 spaceBetween: 10, 656 navigation: { 657 nextEl: '.swiper-button-next', 658 prevEl: '.swiper-button-prev', 659 //enabled: false 660 }, 661 pagination: { 662 el: ".swiper-pagination", 663 dynamicBullets: false, 664 clickable: true, 665 enabled: false 666 }, 667 breakpoints: { 668 576: { 669 slidesPerView: 2, 670 slidesPerGroup: 2, 671 grid: { 672 rows: 3 673 } 674 }, 675 992: { 676 /* navigation: { 677 enabled: true 678 }, 679 pagination: { 680 enabled: false 681 },*/ 682 slidesPerView: 4, 683 slidesPerGroup: 4, 684 grid: { 685 rows: 0 686 } 687 }, 688 1200: { 689 pagination: { 690 enabled: true 691 }, 692 slidesPerView: 5, 693 slidesPerGroup: 5, 694 grid: { 695 rows: 0 696 } 697 698 }, 699 } 700}); 701 702 if ($('#newvendorslide').length) { 703 var newvendorswiper = new Swiper("#newvendorslide", { 704 /*slidesPerView: 'auto', 705 centeredSlides: false, 706 spaceBetween: 16, 707 grabCursor: true, 708 loop: true, 709 autoplay: { 710 delay: 1, 711 disableOnInteraction: true 712 }, 713 infinite: true, 714 freeMode: true, 715 speed: 5000, 716 freeModeMomentum: false*/ 717 slidesPerView: 'auto', 718 centeredSlides: false, 719 spaceBetween: 16, 720 grabCursor: true, 721 autoplay: { 722 delay: 1000, 723 disableOnInteraction: true 724 }, 725 speed: 6000, 726 infinite: true 727 }); 728 } 729 730 731 732} // indexpage 733 734function insidepages(){ 735 "use strict"; 736 737 $('.breadcrumbs ul > li').siblings('li').removeClass('last'); 738 $('.breadcrumbs ul > li').last().addClass('last'); 739 740 var hashcrumb = $('.breadcrumbs a[href=#]'); 741 742 $(hashcrumb).on('click', function(){ 743 return false; 744 }); 745 746 if (!$('#bus').length) { 747 $('.breadcrumbs').find('span.remove').hide(); 748 } else { 749 $('.breadcrumbs').find('span.remove').css('display', 'inline-block'); 750 } 751 752 var $currentPage = window.location.pathname; 753 var windowwidth = window.innerWidth; 754 755 $('#accordion').find('a').each(function() { 756 $(this).toggleClass('activelink', $(this).attr('href') === $currentPage); 757 $(this).parent().removeClass('active'); 758 759 if ($(this).hasClass('activelink')) { 760 $(this).parent().addClass('active'); 761 } 762 }); 763 764 765 766 rightmenu(); 767 768 769} // insidepages 770 771function rightmenu(){ 772 "use strict"; 773 774 $('#accordion a.accordion-button').click(function(){ 775 var nextcollapse = $(this).data('target'); 776 777 if ($(nextcollapse).hasClass('show')) {} 778 else { 779 $(nextcollapse).collapse('toggle'); 780 } 781 }); 782 783 $('#accordion .accordion-item').on('hide.bs.collapse', function(){ 784 $(this).removeClass('active-item'); 785 }); 786 787 788 var currentcollapse = $('#accordion').find('a.activelink'); 789 if (currentcollapse.length) { 790 var currentcollapseexpand = currentcollapse.data('bs-target'); 791 //console.log(currentcollapseexpand); 792 //$(currentcollapse).collapse('show'); 793 currentcollapse.attr('aria-expanded', 'true'); 794 $(currentcollapseexpand).addClass('show'); 795 $(currentcollapseexpand).parent().addClass('active-item'); 796 797 } 798 799 800 $("#accordion .accordion-item .accordion-body").mCustomScrollbar({ 801 theme:"minimal-dark", 802 setTop: '0', 803 axis: "y", 804 scrollbarPosition: 'inside', 805 scrollInertia: 500, 806 scrollButtons: { 807 enable: true, 808 tabindex: '0' 809 }, 810 autoHideScrollbar:false, 811 mouseWheel: { 812 enable: true, 813 preventDefault: true 814 }, 815 callbacks:{ 816 onInit:function(){ 817 //console.log("Scrollbars initialized"); 818 }, 819 onCreate:function(){ 820 $('.mCSB_buttonUp').attr({ 821 'aria-label': 'Scroll Up', 822 'role': 'button' 823 }); 824 $('.mCSB_buttonDown').attr({ 825 'aria-label': 'Scroll Down', 826 'role': 'button' 827 }); 828 $('.mCSB_dragger').attr('tabindex', '0'); 829 } 830 } 831 }); 832 833 $("#accordion .accordion-item .accordion-body").on("click", ".mCSB_scrollTools > *", function(e) { 834 e.stopPropagation(); 835 }); 836 837 var windowwidth = window.innerWidth; 838 839 if (windowwidth < 992) { 840 $('#accordion').find('a').click(function(){ 841 $('#accordion').collapse('hide'); 842 }); 843 844 $('body').click(function(e) { 845 if (!$(e.target).closest('#accordion').length){ 846 $('#accordion').collapse('hide'); 847 } 848 }); 849 850 $(window).resize(function(){ 851 $('#accordion').collapse('hide'); 852 }); 853 } 854 855} // rightmenu 856 857function discountspage(){ 858 "use strict"; 859 860 var $discountgrid = $('#allCat .grid'); 861 showLoader(); 862 setTimeout(function() { 863 $discountgrid.addClass('items-visible'); 864 setTimeout(function() { 865 hideLoader(); 866 },500); 867 },800); 868 869 var responsiveIsotope = [ 870 [480, 12], 871 [768, 12], 872 [992, 15], 873 [1200, 18] 874 ]; 875 876 var itemsPerPageDefault = 20; 877 var itemsPerPage = defineItemsPerPage(); 878 879 function defineItemsPerPage() { 880 var pages = itemsPerPageDefault; 881 882 for( var i = 0; i < responsiveIsotope.length; i++ ) { 883 if( $(window).width() <= responsiveIsotope[i][0] ) { 884 pages = responsiveIsotope[i][1]; 885 break; 886 } 887 } 888 889 return pages; 890 } 891 892 function showall(){ 893 894 895 itemsPerPage = mixer.getState().totalTargets; 896 mixer.paginate({ 897 limit: itemsPerPage, 898 page: 1 899 }).then(function(state) { 900 901 //$('.mixitup-page-stats').html('<div>
901Showing <span>1-' +mixer.getState().totalShow+ '</span> of <span>' +mixer.getState().totalTargets+ '</span> Categories</div>'); 902 903 904 }); 905 } 906 907 $('button#showall').click(function(){ 908 showall(); 909 $(this).addClass('disable'); 910 //console.log(mixer.getState().activePagination.limit); 911 912 }); 913 914 function handleResize() { 915 itemsPerPage = defineItemsPerPage(); 916 917 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 918 mixer.paginate({ 919 limit: itemsPerPage 920 }, false); 921 922 923 $discountgrid.css('min-height', ''); 924 var setheight = $discountgrid.height(); 925 $discountgrid.css('min-height', setheight); 926 //mixer.paginate(1); 927 } 928 929 var mixer = mixitup('.gridouter', { 930 controls: { 931 scope: 'global' 932 }, 933 classNames: { 934 elementPager: 'pager', 935 elementPageList: 'mixitup-page-list' 936 937 }, 938 selectors: { 939 control: '.mixitup-control' 940 //target: '[data-ref~="mixitup-target"]', 941 //control: '[data-mixitup-control]' 942 }, 943 animation: { 944 945 easing: 'cubic-bezier(0.645, 0.045, 0.355, 1)' 946 }, 947 templates: { 948 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 949 //pagerPrev: '', 950 //pagerNext: '', 951 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 952 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>', 953 pageStats: '<div>Showing <span>${startPageAt}-${endPageAt}</span> of <span>${totalTargets}</span> Categories</div>' 954 }, 955 pagination: { 956 limit: itemsPerPage, 957 maintainActivePage: false, 958 loop: false, 959 hidePageListIfSinglePage: true, 960 maxPagers: 6 961 }, 962 callbacks: { 963 onMixStart: function(state, futureState) { 964 //console.log('Starting operation...'); 965 //console.log(futureState.totalPages); 966 var checkpages = futureState.totalPages; 967 if (checkpages === 1) { 968 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 969 } else { 970 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 971 } 972 //console.log(futureState.activePagination); 973 /* 974 var select = $('.selectview'); 975 var currentview = mixer.getState().activePagination.limit; 976 //console.log(currentview); 977 select.find('a').removeClass('active'); 978 select.find('a[data-value='+currentview+']').addClass('active'); 979 */ 980 981 982 /*** CUSTOM BUTTONS ON CATEGORY PAGE ***/ 983 var currentpage2 = futureState.activePagination.page; 984 if (currentpage2 === 1) { 985 $('button.prevpage').addClass('disabled'); 986 } 987 if (currentpage2 !== 1) { 988 $('button.prevpage').removeClass('disabled'); 989 } 990 991 var numberofpages2 = state.totalPages; 992 if (currentpage2 === numberofpages2) { 993 $('button.nextpage').addClass('disabled'); 994 } 995 if (currentpage2 !== numberofpages2) { 996 $('button.nextpage').removeClass('disabled'); 997 } 998 999 1000 }, 1001 onMixClick: function(state, originalEvent) { 1002 //console.log('The control "' + this.innerText + '" was clicked'); 1003 //console.log('clicked'); 1004 //this.trigger('click'); 1005 //var pageclicked = $(this).data('page'); 1006 //console.log($(this).data('page')); 1007 //mixer.paginate(pageclicked); 1008 1009 }, 1010 onMixEnd: function(state) { 1011 //console.log(mixer.getState().activePagination.limit); 1012 //console.log(mixer.getState().totalShow + ' targets are currently shown'); 1013 1014 1015 1016 //mixer.pageStats('test'); 1017 //var checkpages = mixer.getState().totalPages; 1018 //if (checkpages === 1) { 1019 // $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 1020 //} else { 1021 // $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 1022 //} 1023 } 1024 } 1025 }); 1026 1027 1028 1029 /* 1030 $('a.mainfilters').keypress(function(e) { 1031 if ((e.keyCode || e.which) == 13) { 1032 // Enter key pressed 1033 //$('a.mainfilters').trigger('click'); 1034 console.log('clicked'); 1035 } 1036}); 1037*/ 1038 1039 /*$('#allCat').find('.pagination a.page-link').each(function() { 1040 $(this).on('keypress', function (e) { 1041 if (e.key === 'Enter' || e.keyCode === 13) { 1042 var pageclicked = $(this).data('page'); 1043 //console.log(pageclicked); 1044 mixer.paginate(pageclicked); 1045 } 1046 }); 1047 });*/ 1048 1049 var setheight = $discountgrid.height(); 1050 $discountgrid.css('min-height', setheight); 1051 1052 window.addEventListener('resize', handleResize); 1053 1054 var filterAtribute = 'data-filter'; 1055 1056 $('.discountsfilter').find('ul li > a').click(function(e) { 1057 e.preventDefault(); 1058 var $this = $(this); 1059 var parent = $this.parent('li'); 1060 var parentsibs = parent.parent().parent().find('li'); 1061 var subtitletext = $this.text(); 1062 var subtitleicon = $this.find('i.hidden'); 1063 1064 if ($this.hasClass('viewall')){ 1065 1066 itemsPerPage = defineItemsPerPage(); 1067 1068 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 1069 mixer.paginate({ 1070 limit: itemsPerPage 1071 }, false); 1072 1073 $('.subtitle > h4').html('').removeClass('active'); 1074 parent.siblings('li.active').removeClass('active').find('.collapse').collapse('hide'); 1075 //parentsibs.find('.collapse').collapse('hide'); 1076 $('.top-pagination').show(); 1077 1078 1079 } else { 1080 $('.subtitle > h4').addClass('active').html(subtitletext); 1081 subtitleicon.clone().appendTo('.subtitle > h4'); 1082 $this.parent('li').addClass('active'); 1083 $('.top-pagination').hide(); 1084 } 1085 1086 var filtercategory = $(this).attr(filterAtribute); 1087 mixer.filter(filtercategory); 1088 //console.log(filtercategory); 1089 1090 parentsibs.removeClass('active'); 1091 parent.addClass('active'); 1092 1093 // if (parent.parent().hasClass('dropdown-menu')){ 1094 // parent.parent().dropdown('toggle'); 1095 // } 1096 1097 //return false;
1098 1099 $('#accordion').collapse('hide'); 1100 $('button#showall').removeClass('disable'); 1101 1102 1103 }); 1104 1105 var getcookie = Cookies.get('maincat'); 1106 if (getcookie){ 1107 var activefilter = '.'+getcookie; 1108 1109 $('.top-pagination').hide(); 1110 1111 $('.discountsfilter ul > li > a').each(function(){ 1112 var target = $(this).attr('data-filter'); 1113 1114 if (activefilter === target){ 1115 1116 var $this = $(this); 1117 1118 var subtitletext = $this.text(); 1119 var subtitleicon = $this.find('i.hidden'); 1120 1121 $('.subtitle > h4').addClass('active').html(subtitletext); 1122 subtitleicon.clone().appendTo('.subtitle > h4'); 1123 1124 $this.parent('li').addClass('active'); 1125 } 1126 }); 1127 1128 mixer.filter(activefilter); 1129 1130 } 1131 1132 if (!getcookie){ 1133 $('.discountsfilter ul > li > a.viewall').parent().addClass('active'); 1134 } 1135 1136 1137 1138} // discountspage 1139 1140function vendorpage(){ 1141 1142 1143 if ($('#vendordiscounts').length) { 1144 var windowwidth = $(window).width(); 1145 1146 var containerEl = document.querySelector('.gridouter'); 1147 1148 var $vendorgrid = $('#vendordiscounts .grid'); 1149 1150 1151 showLoader(); 1152 setTimeout(function() { 1153 $vendorgrid.addClass('items-visible'); 1154 setTimeout(function() { 1155 hideLoader(); 1156 },500); 1157 },700); 1158 1159 /* 1160 $('ul.vendorlist').mCustomScrollbar({ 1161 theme:"dark", 1162 setTop: '0', 1163 axis: "y", 1164 scrollbarPosition: 'inside', 1165 scrollInertia: 500, 1166 scrollButtons: { 1167 enable: true, 1168 tabindex: '0' 1169 }, 1170 mouseWheel: { 1171 enable: true, 1172 preventDefault: true 1173 }, 1174 callbacks:{ 1175 onInit:function(){ 1176 //console.log("Scrollbars initialized"); 1177 }, 1178 onCreate:function(){ 1179 $('.mCSB_buttonUp').attr({ 1180 'aria-label': 'Scroll Up', 1181 'role': 'button' 1182 }); 1183 $('.mCSB_buttonDown').attr({ 1184 'aria-label': 'Scroll Down', 1185 'role': 'button' 1186 }); 1187 $('.mCSB_dragger').attr('tabindex', '0'); 1188 } 1189 } 1190 }); 1191 */ 1192 1193 1194 1195 var responsiveIsotope = [ 1196 [575, 6], 1197 [767, 9], 1198 [992, 12], 1199 [1400, 12] 1200 ]; 1201 1202 var itemsPerPageDefault = 15; 1203 var itemsPerPage = defineItemsPerPage(); 1204 1205 function defineItemsPerPage() { 1206 var pages = itemsPerPageDefault; 1207 1208 for( var i = 0; i < responsiveIsotope.length; i++ ) { 1209 if( $(window).width() <= responsiveIsotope[i][0] ) { 1210 pages = responsiveIsotope[i][1]; 1211 break; 1212 } 1213 } 1214 1215 return pages; 1216 } 1217 1218 function showall(){ 1219 1220 itemsPerPage = vendormixer.getState().totalTargets; 1221 //console.log(itemsPerPage); 1222 1223 vendormixer.paginate({ 1224 limit: itemsPerPage, 1225 page: 1 1226 }); 1227 } 1228 1229 $('button#showall').click(function(){ 1230 showall(); 1231 $(this).addClass('disable'); 1232 //console.log(vendormixer.getState().activePagination.limit); 1233 1234 }); 1235 1236 1237 1238 function handleResize() { 1239 itemsPerPage = defineItemsPerPage(); 1240 1241 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 1242 1243 vendormixer.paginate({ 1244 limit: itemsPerPage 1245 }, false); 1246 1247 $vendorgrid.css('min-height', ''); 1248 var setheight = $vendorgrid.height(); 1249 $vendorgrid.css('min-height', setheight); 1250 //mixer.paginate(1); 1251 1252 $('button#showall').removeClass('disable'); 1253 } 1254 1255 var vendormixer = mixitup('.gridouter', { 1256 controls: { 1257 scope: 'global' 1258 }, 1259 classNames: { 1260 elementPager: 'pager', 1261 elementPageList: 'mixitup-page-list' 1262 1263 }, 1264 selectors: { 1265 control: '.mixitup-control' 1266 //target: '[data-ref~="mixitup-target"]', 1267 //control: '[data-mixitup-control]' 1268 }, 1269 animation: { 1270 easing: 'cubic-bezier(0.645, 0.045, 0.355, 1)' 1271 }, 1272 templates: { 1273 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 1274 //pagerPrev: '', 1275 //pagerNext: '', 1276 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 1277 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>', 1278 pageStats: '<div>
1278Showing <span>${startPageAt}-${endPageAt}</span> of <span>${totalTargets}</span> Vendors</div>' 1279 }, 1280 pagination: { 1281 limit: itemsPerPage, 1282 maintainActivePage: false, 1283 loop: false, 1284 hidePageListIfSinglePage: true, 1285 maxPagers: 5 1286 }, 1287 callbacks: { 1288 onMixStart: function(state, futureState) { 1289 //console.log('Starting operation...'); 1290 //console.log(futureState.totalPages); 1291 var checkpages = futureState.totalPages; 1292 if (checkpages === 1) { 1293 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 1294 } else { 1295 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 1296 } 1297 //console.log(futureState.activePagination); 1298 1299 1300 }, 1301 onMixClick: function(state, originalEvent) { 1302 //console.log('The control "' + this.innerText + '" was clicked'); 1303 1304 1305 }, 1306 onMixEnd: function(state) {
1307 //var checkpages = vendormixer.getState().totalPages; 1308 //if (checkpages === 1) { 1309 // $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 1310 //} else { 1311 // $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 1312 //} 1313 } 1314 } 1315 }); 1316 1317 1318 1319 var setheight = $vendorgrid.height(); 1320 $vendorgrid.css('min-height', setheight); 1321 1322 window.addEventListener('resize', handleResize); 1323 1324 } 1325 1326} // vendor page 1327 1328function checknewvendorpage(){ 1329 1330 var newvendors = $('#newvendors .grid > div'); 1331 //console.log(newvendors.length); 1332 if (newvendors.length > 10) { 1333 newvendorpage(); 1334 } else { 1335 $('#newvendors').addClass('hidepager'); 1336 showLoader(); 1337 setTimeout(function() { 1338 $('#newvendors .grid').addClass('items-visible'); 1339 setTimeout(function() { 1340 hideLoader(); 1341 },500); 1342 },700); 1343 } 1344 1345 if (!newvendors.length) { 1346 //console.log('0'); 1347 $('#newvendors').addClass('hidepager'); 1348 } 1349 1350} // checknewvendorpage 1351 1352function newvendorpage(){ 1353 1354 $('.newvendorfilter').show(); 1355 1356 1357 if ($('#newvendors').length) { 1358 var windowwidth = $(window).width(); 1359 1360 var containerEl = document.querySelector('.gridouter'); 1361 1362 var $newvendorgrid = $('#newvendors .grid'); 1363 1364 showLoader(); 1365 setTimeout(function() { 1366 $newvendorgrid.addClass('items-visible'); 1367 setTimeout(function() { 1368 hideLoader(); 1369 },500); 1370 },700); 1371 1372 1373 var responsiveIsotope = [ 1374 [575, 6], 1375 [767, 9], 1376 [992, 12], 1377 [1400, 12] 1378 ]; 1379 1380 var itemsPerPageDefault = 15; 1381 var itemsPerPage = defineItemsPerPage(); 1382 1383 function defineItemsPerPage() { 1384 var pages = itemsPerPageDefault; 1385 1386 for( var i = 0; i < responsiveIsotope.length; i++ ) { 1387 if( $(window).width() <= responsiveIsotope[i][0] ) { 1388 pages = responsiveIsotope[i][1]; 1389 break; 1390 } 1391 } 1392 1393 return pages; 1394 } 1395 1396 function showall(){ 1397 1398 itemsPerPage = newvendormixer.getState().totalTargets; 1399 //console.log(itemsPerPage); 1400 1401 newvendormixer.paginate({ 1402 limit: itemsPerPage, 1403 page: 1 1404 }); 1405 } 1406 1407 $('button#showall').click(function(){ 1408 showall(); 1409 $(this).addClass('disable'); 1410 //console.log(mixer.getState().activePagination.limit); 1411 1412 }); 1413 1414 function handleResize() { 1415 itemsPerPage = defineItemsPerPage(); 1416 1417 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 1418 1419 newvendormixer.paginate({ 1420 limit: itemsPerPage 1421 }, false); 1422 1423 $newvendorgrid.css('min-height', ''); 1424 var setheight = $newvendorgrid.height(); 1425 $newvendorgrid.css('min-height', setheight); 1426 //newvendormixer.paginate(1); 1427 } 1428 1429 var newvendormixer = mixitup('.gridouter', { 1430 controls: { 1431 scope: 'global' 1432 }, 1433 classNames: { 1434 elementPager: 'pager', 1435 elementPageList: 'mixitup-page-list' 1436 1437 }, 1438 selectors: { 1439 control: '.mixitup-control' 1440 //target: '[data-ref~="mixitup-target"]', 1441 //control: '[data-mixitup-control]' 1442 }, 1443 animation: { 1444 easing: 'cubic-bezier(0.645, 0.045, 0.355, 1)' 1445 }, 1446 templates: { 1447 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 1448 //pagerPrev: '', 1449 //pagerNext: '', 1450 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 1451 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>', 1452 pageStats: '<div>
1452Showing <span>${startPageAt}-${endPageAt}</span> of <span>${totalTargets}</span></div>' 1453 }, 1454 pagination: { 1455 limit: itemsPerPage, 1456 maintainActivePage: false, 1457 loop: false, 1458 hidePageListIfSinglePage: true, 1459 maxPagers: 5 1460 }, 1461 callbacks: { 1462 onMixStart: function(state, futureState) { 1463 //console.log('Starting operation...'); 1464 //console.log(futureState.totalPages); 1465 var checkpages = futureState.totalPages; 1466 if (checkpages === 1) { 1467 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 1468 } else { 1469 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 1470 } 1471 //console.log(futureState.activePagination); 1472 1473 1474 }, 1475 onMixClick: function(state, originalEvent) { 1476 //console.log('The control "' + this.innerText + '" was clicked'); 1477 1478 1479 }, 1480 onMixEnd: function(state) { 1481 //var checkpages = newvendormixer.getState().totalPages; 1482 //if (checkpages === 1) { 1483 // $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 1484 //} else { 1485 // $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 1486 //} 1487 } 1488 } 1489 }); 1490 1491 1492 var setheight = $newvendorgrid.height(); 1493 $newvendorgrid.css('min-height', setheight); 1494 1495 window.addEventListener('resize', handleResize); 1496 1497 function setfilters(){ 1498 1499 var cat = $('#newvendors').find('.item > div'); 1500 var items = {}; 1501 var items2 = {}; 1502 var categories = {}, 1503 category; 1504 1505 1506$(cat).each(function(i, el) { 1507 items[$(this).attr('data-catname')] = true; 1508 category = $(el).data('catname'); 1509 1510 if (categories.hasOwnProperty(category)) { 1511 categories[category] += 1; 1512 } 1513 else { 1514 categories[category] = 1; 1515 } 1516 1517}); 1518 1519//function asc_sort(a, b){ 1520 // return ($(b).text()) < ($(a).text()) ? 1 : -1; 1521//} 1522 1523String.prototype.capitalize = function() { 1524 return this.charAt(0).toUpperCase() + this.slice(1); 1525} 1526String.prototype.toProperCase = function () { 1527 return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); 1528}; 1529 1530 1531for(var key in categories){ 1532 var value = key.replace(/\-/g, " "); 1533 var catbtn = '<a class="dropdown-item" href="#" data-filter=".'+key+'"><span class="name">'+value.toProperCase()+'</span></a>'; 1534 $('#newvendordd').append(catbtn); 1535 1536 } 1537 1538function asc_sort(a, b){ 1539 return ($(b).text()) < ($(a).text()) ? 1 : -1; 1540} 1541 1542$('#newvendordd').find('a').sort(asc_sort).appendTo('#newvendordd'); 1543 1544 1545$('#newvendordd').prepend('<a id="all" data-filter="all" class="dropdown-item" href="#"><span class="name">All Results</span></a>'); 1546 1547 1548 1549 /* 1550 $('#resultsgrid .mix > div').each(function(){ 1551 var category = $(this).attr('data-catname'); 1552 var caticon = $(this).attr('data-caticon'); 1553 //var icon = '<i class="icon '+caticon+'"></i>'; 1554 1555 $('#filterdd a[data-filter=".'+category+'"]').find('i').addClass(caticon); 1556 }); 1557 */ 1558 $('#newvendordd a').each(function(){ 1559 var findempty = $(this).attr('data-filter'); 1560 //$('#newvendordd a[data-filter="."]').addClass('nothing'); 1561 $('#newvendordd a[data-filter="."]').remove(); 1562 }); 1563 1564 1565var filterAtribute = 'data-filter'; 1566$('#newvendordd').find('a').click(function() { 1567 var $this = $(this); 1568 var sibs = $(this).siblings(); 1569 //var parent = $this.parent('li'); 1570 //var parentsibs = parent.parent().parent().find('li'); 1571 var filterValue = $this.attr('data-filter'); 1572 1573 sibs.removeClass('mainactive'); 1574 $this.addClass('mainactive'); 1575 //$resultsgrid.isotope({ filter: filterValue }); 1576 var filtercategory = $(this).attr(filterAtribute); 1577 newvendormixer.filter(filtercategory); 1578 1579 1580 $('#newvendordd').dropdown('toggle'); 1581 $('.newvendorfilter > a').removeClass('show'); 1582 1583 if ($this.attr('id') !== 'all') { 1584 var newtext = $this.find('span.name').text(); 1585 $('.newvendorfilter > a').find('span.text').empty().text(newtext); 1586 } else { 1587 $('.newvendorfilter > a').find('span.text').empty().text('Filter'); 1588 } 1589 1590 $('button#showall').removeClass('disable'); 1591 1592 return false;
1593 }); 1594 1595 var setheight = $newvendorgrid.height(); 1596 $newvendorgrid.css('min-height', setheight); 1597 1598 //window.addEventListener('resize', handleResize); 1599 1600 $('.newvendorfilter').show(); 1601 1602 1603} // setfilters 1604 1605 setfilters(); 1606 1607 } 1608 1609 $("#newvendordd").mCustomScrollbar({ 1610 theme:"dark-thin", 1611 setTop: '0', 1612 axis: "y", 1613 scrollbarPosition: 'inside', 1614 scrollInertia: 500, 1615 scrollButtons: { 1616 enable: true, 1617 tabindex: '0' 1618 }, 1619 mouseWheel: { 1620 enable: true, 1621 preventDefault: true 1622 }, 1623 callbacks:{ 1624 onInit:function(){ 1625 //console.log("Scrollbars initialized"); 1626 }, 1627 onCreate:function(){ 1628 $('.mCSB_buttonUp').attr({ 1629 'aria-label': 'Scroll Up', 1630 'role': 'button' 1631 }); 1632 $('.mCSB_buttonDown').attr({ 1633 'aria-label': 'Scroll Down', 1634 'role': 'button' 1635 }); 1636 $('.mCSB_dragger').attr('tabindex', '0'); 1637 } 1638 } 1639 }); 1640 1641 $("#newvendordd").on("click", ".mCSB_scrollTools > *", function(e) { 1642 e.stopPropagation(); 1643 }); 1644 1645 $("#newvendordd").on("click", ".mCSB_draggerContainer > div", function(e) { 1646 e.stopPropagation(); 1647 }); 1648 1649} // new vendor page 1650 1651function nationaldiscounts(){ 1652 1653 1654 if ($('#nationaldiscounts').length) { 1655 //var windowwidth = $(window).width(); 1656 1657 var $national = $('#nationaldiscounts .grid'); 1658 $national.addClass('items-visible'); 1659 var responsiveIsotope = [ 1660 [567, 12], 1661 [767, 12], 1662 [992, 12], 1663 [1400, 12] 1664 ]; 1665 var itemsPerPageDefault = 15; 1666 var itemsPerPage = defineItemsPerPage(); 1667 1668 function defineItemsPerPage() { 1669 var pages = itemsPerPageDefault; 1670 1671 for( var i = 0; i < responsiveIsotope.length; i++ ) { 1672 if( $(window).width() <= responsiveIsotope[i][0] ) { 1673 pages = responsiveIsotope[i][1]; 1674 break; 1675 } 1676 } 1677 1678 return pages; 1679 } 1680 1681 1682 function handleResize() { 1683 itemsPerPage = defineItemsPerPage(); 1684 1685 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 1686 1687 nationalmixer.paginate({ 1688 limit: itemsPerPage 1689 }, false); 1690 1691 $national.css('min-height', ''); 1692 var setheight = $national.outerHeight(); 1693 $national.css('min-height', setheight); 1694 // mixer.paginate(1); 1695 1696 1697 } 1698 1699 var inputSearch = document.querySelector('[data-ref="input-search"]'); 1700 var keyupTimeout; 1701 var resulttext = $('.resulttext'); 1702 1703 var nationalmixer = mixitup('.gridouter', { 1704 controls: { 1705 scope: 'global' 1706 }, 1707 classNames: { 1708 elementPager: 'pager', 1709 elementPageList: 'mixitup-page-list' 1710 1711 }, 1712 selectors: { 1713 control: '.mixitup-control' 1714 //target: '[data-ref~="mixitup-target"]', 1715 //control: '[data-mixitup-control]' 1716 }, 1717 multifilter: { 1718 enable: true 1719 }, 1720 animation: { 1721 nudge: false 1722 }, 1723 templates: { 1724 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 1725 //pagerPrev: '', 1726 //pagerNext: '', 1727 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 1728 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>', 1729 pageStats: '<div>
1729Showing <span>${startPageAt}-${endPageAt}</span> of <span>${totalTargets}</span> Vendors</div>' 1730 }, 1731 pagination: { 1732 limit: itemsPerPage, 1733 maintainActivePage: false, 1734 loop: false, 1735 hidePageListIfSinglePage: true, 1736 maxPagers: 5 1737 1738 }, 1739 callbacks: { 1740 onMixClick: function() { 1741 // Reset the search if a filter is clicked 1742 if (this.matches('[data-filter]')) { 1743 inputSearch.value = ''; 1744 } 1745 }, 1746 onMixStart: function(state, futureState) { 1747 //console.log('starting'); 1748 resulttext.hide(); 1749 1750 var checkpages = futureState.totalPages; 1751 if (checkpages === 1) { 1752 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 1753 } else { 1754 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 1755 } 1756 //console.log(futureState.activePagination); 1757 /* 1758 var currentpage2 = futureState.activePagination.page; 1759 if (currentpage2 === 1) { 1760 $('button.prevpage').addClass('disabled'); 1761 } 1762 if (currentpage2 !== 1) { 1763 $('button.prevpage').removeClass('disabled'); 1764 } 1765 1766 var numberofpages2 = state.totalPages; 1767 if (currentpage2 === numberofpages2) { 1768 $('button.nextpage').addClass('disabled'); 1769 } 1770 if (currentpage2 !== numberofpages2) { 1771 $('button.nextpage').removeClass('disabled'); 1772 } 1773 */ 1774 }, 1775 onMixFail: function(state) { 1776 //console.log('No items could be found matching the requested filter'); 1777 resulttext.show(); 1778 }, 1779 onPaginateStart: function(){ 1780 // console.log('test'); 1781 $('a.pager').parent().removeClass('active'); 1782 //$('.mixitup-page-list').find('.mixitup-pager-active').parent().addClass('active'); 1783 1784 if ($('a.pager').hasClass('mixitup-pager-active')){ 1785 $('a.pager.mixitup-pager-active').parent('li').addClass('active'); 1786 } 1787 } 1788 } 1789 }); 1790 1791 1792 inputSearch.addEventListener('keyup', function() { 1793 var searchValue; 1794 1795 1796 if (inputSearch.value.length < 3) { 1797 // If the input value is less than 3 characters, don't send 1798 1799 searchValue = ''; 1800 //resulttext.show().text('Please enter at least 3 characters.'); 1801 } else { 1802 searchValue = inputSearch.value.toLowerCase().trim(); 1803 //resulttext.empty().hide(); 1804 } 1805 1806 // Very basic throttling to prevent mixer thrashing. Only search 1807 // once 350ms has passed since the last keyup event 1808 1809 clearTimeout(keyupTimeout); 1810 1811 keyupTimeout = setTimeout(function() { 1812 filterByString(searchValue); 1813 }, 350); 1814 }); 1815 1816 function filterByString(searchValue) { 1817 if (searchValue) { 1818 // Use an attribute wildcard selector to check for matches 1819 1820 nationalmixer.filter('[class*="' + searchValue + '"]'); 1821 1822 } else { 1823 // If no searchValue, treat as filter('all') 1824 1825 nationalmixer.filter('all'); 1826 resulttext.hide(); 1827 //resulttext.empty().text('No discounts were found matching "'+ searchValue +'".'); 1828 //resulttext.show(); 1829 } 1830 } 1831 1832 // $('.mixitup-page-list').find('.mixitup-pager-active').parent().addClass('active'); 1833 1834 var filterAtribute = 'data-filter'; 1835 $('.catlist').find('a.natlfilters').click(function(e) { 1836 e.preventDefault(); 1837 var $this = $(this); 1838 var parent = $this.parent('li'); 1839 var parentsibs = parent.parent().find('li'); 1840 1841 var filtercategory = $this.attr(filterAtribute); 1842 nationalmixer.filter(filtercategory); 1843 1844 //parent.parent().parent().find('>a').removeClass('activelink'); 1845 parentsibs.find('a').removeClass('activelink'); 1846 parentsibs.removeClass('active'); 1847 parent.addClass('active'); 1848 $this.addClass('activelink'); 1849 1850 var subtitle = $this.text(); 1851 if (subtitle != 'View All'){ 1852 $('div.subtitle > h4').empty().text(subtitle); 1853 $('div.subtitle > h4').addClass('active');
1854 $('fieldset.filter-group').hide(); 1855 1856 } else { 1857 1858 1859 $('div.subtitle > h4').empty(); 1860 $('div.subtitle > h4').removeClass('active'); 1861 $('fieldset.filter-group').show(); 1862 $this.parent('li').addClass('active'); 1863 1864 } 1865 1866 1867 inputSearch.value = ''; 1868 resulttext.hide(); 1869 1870 1871 //return false; 1872 }); 1873 1874 var setheight = $national.outerHeight(); 1875 $national.css('min-height', setheight); 1876 //console.log($discountgrid.outerHeight()); 1877 1878 window.addEventListener('resize', handleResize); 1879 1880 1881 var getcookie = Cookies.get('nationalcat'); 1882 1883 if (getcookie){ 1884 var activefilter = '.'+getcookie; 1885 //console.log(activefilter); 1886 1887 1888 $('.catlist').find('a.natlfilters').each(function(){ 1889 var target = $(this).attr('data-filter'); 1890 1891 if (activefilter === target){ 1892 1893 var $this = $(this); 1894 $this.parent().siblings().removeClass('active'); 1895 $this.parent().siblings().find('a').removeClass('activelink'); 1896 $this.parent().addClass('active'); 1897 $this.addClass('activelink'); 1898 1899 var subtitletext = $this.text(); 1900 1901 $('div.subtitle > h4').empty().text(subtitletext); 1902 $('div.subtitle > h4').addClass('active'); 1903 $('fieldset.filter-group').hide(); 1904 1905 } 1906 }); 1907 1908 nationalmixer.filter(activefilter); 1909 } 1910 1911 if (!getcookie){ 1912 $('.catlist > li > a#natl-all').parent().addClass('active'); 1913 } 1914 1915 1916 $(window).resize(function() { 1917 if(this.resizeTO) { 1918 clearTimeout(this.resizeTO); 1919 } 1920 this.resizeTO = setTimeout(function() { 1921 $(this).trigger('resizeEnd'); 1922 }, 500); 1923 1924}); 1925 1926 $(window).on('resizeEnd', function() { 1927 // nationalmixer.filter('all'); 1928 }); 1929 1930 1931 1932 1933} // if national page 1934 1935} // national discounts 1936 1937function errorpages(){ 1938 1939 1940 if ($('.outersearch').length) { 1941 1942 $('#errorpagesearch button').click(function(){ 1943 return false; 1944 }); 1945 1946 1947function search(){ 1948 var query_value = $('input#pagesearch').val(); 1949 var dataString = 'term='+ query_value; 1950 1951 if(query_value!=""){ 1952 //$("#results").html('<div id="loading"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div></div>'); 1953 //alert(query_value); 1954 $.ajax({ 1955 type:"get", 1956 url: "/templates/inpagesearch.php", 1957 data:dataString, 1958 success:function(data){ 1959 // $('.progress').fadeOut(); 1960 $('#searchgrid').fadeTo(150,1); 1961 $(".results").html(data); 1962 $('#searchfilter').show(); 1963 $('.filterdropdown').show(); 1964 $('span#search-string').html('"'+query_value+'"'); 1965 $("input#pagesearch").val(""); 1966 $('.searchresults').removeClass('nosearch'); 1967 $('#searchfilter').removeClass('nofilter'); 1968 $('#filterdd').find('>a').remove(); 1969 $('#list-tab').find('>a').remove(); 1970 1971 var searchresults = $('input#searchtotal'); 1972 var query_total = searchresults.val(); 1973 1974 $('span#searchnumber').text(query_total); 1975 1976 if (query_total > 0) { 1977 1978var $searchgrid = $('#searchgrid .grid'); 1979 1980var responsiveIsotope = [ 1981 [575, 8], 1982 [992, 10], 1983 [1200, 12] 1984 ]; 1985 1986var itemsPerPageDefault = 12; 1987 var itemsPerPage = defineItemsPerPage(); 1988 1989 function defineItemsPerPage() { 1990 var pages = itemsPerPageDefault; 1991 1992 for( var i = 0; i < responsiveIsotope.length; i++ ) { 1993 if( $(window).width() <= responsiveIsotope[i][0] ) { 1994 pages = responsiveIsotope[i][1]; 1995 break; 1996 } 1997 } 1998 1999 return pages; 2000 } 2001 2002function handleResize() { 2003 itemsPerPage = defineItemsPerPage(); 2004 2005 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 2006 2007 errormixer.paginate({ 2008 limit: itemsPerPage 2009 }, false); 2010 2011 $searchgrid.css('min-height', ''); 2012 var setheight = $searchgrid.height(); 2013 $searchgrid.css('min-height', setheight); 2014 //mixer.paginate(1); 2015 2016if ($('#filterdd').hasClass('show')){ 2017 $('#filterdd').dropdown('toggle'); 2018 } 2019 } 2020 2021var errormixer = mixitup('.gridouter', { 2022 controls: { 2023 scope: 'global' 2024 }, 2025 classNames: { 2026 elementPager: 'pager', 2027 elementPageList: 'mixitup-page-list' 2028 2029 }, 2030 selectors: { 2031 control: '.mixitup-control' 2032 //target: '[data-ref~="mixitup-target"]', 2033 //control: '[data-mixitup-control]' 2034 }, 2035 animation: { 2036 nudge: false 2037 }, 2038 templates: { 2039 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 2040 //pagerPrev: '', 2041 //pagerNext: '', 2042 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 2043 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>'//, 2044 //pageStats: '<div>
2044Showing <span>${startPageAt}-${endPageAt}</span> of <span>${totalTargets}</span> Search Results</div>' 2045 }, 2046 pagination: { 2047 limit: itemsPerPage, 2048 maintainActivePage: false, 2049 loop: false, 2050 hidePageListIfSinglePage: true, 2051 maxPagers: 6 2052 }, 2053 callbacks: { 2054 onMixStart: function(state, futureState) { 2055 //console.log('Starting operation...'); 2056 //console.log(futureState.totalPages); 2057 var checkpages = futureState.totalPages; 2058 if (checkpages === 1) { 2059 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2060 } else { 2061 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2062 } 2063 //console.log(futureState.activePagination); 2064 2065 2066 }, 2067 onMixClick: function(state, originalEvent) { 2068 //console.log('The control "' + this.innerText + '" was clicked'); 2069 2070 2071 }, 2072 onMixEnd: function(state) { 2073 //var checkpages = errormixer.getState().totalPages; 2074 //if (checkpages === 1) { 2075 // $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2076 //} else { 2077 // $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2078 //} 2079 } 2080 } 2081 }); 2082 2083 2084var cat = $('#searchgrid').find('.grid-item > div'); 2085var items = {}; 2086var items2 = {}; 2087var categories = {}, 2088 category; 2089 2090 2091$(cat).each(function(i, el) { 2092 items[$(this).attr('data-catname')] = true; 2093 category = $(el).data('catname'); 2094 2095 if (categories.hasOwnProperty(category)) { 2096 categories[category] += 1; 2097 } 2098 else { 2099 categories[category] = 1; 2100 } 2101 2102}); 2103 2104String.prototype.capitalize = function() { 2105 return this.charAt(0).toUpperCase() + this.slice(1); 2106} 2107String.prototype.toProperCase = function () { 2108 return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); 2109}; 2110 2111 2112for(var key in categories){ 2113 var value = key.replace(/\-/g, " "); 2114 var catbtn = '<a class="dropdown-item" href="#" data-filter=".'+key+'"><span class="name">'+value.toProperCase()+'</span><span class="num"> ('+categories[key] +')</span></a>'; 2115 2116 var catbtn2 = '<a class="nav-item" href="#" data-filter=".'+key+'"><span class="name">'+value.toProperCase()+'</span><span class="num"> ('+categories[key] +')</span></a>'; 2117 $('#filterdd').append(catbtn); 2118 $('#list-tab').append(catbtn2); 2119 } 2120 2121 2122function asc_sort(a, b){ 2123 return ($(b).text()) < ($(a).text()) ? 1 : -1; 2124} 2125 2126$('#filterdd').find('a').sort(asc_sort).appendTo('#filterdd'); 2127$('#list-tab').find('a').sort(asc_sort).appendTo('#list-tab'); 2128 2129$('#filterdd').prepend('<a id="all" data-filter="all" class="dropdown-item" href="#"><span class="name">All Results</span><span class="num"> ('+query_total+')</span></a>'); 2130 2131$('#list-tab').prepend('<a id="all" data-filter="all" class="nav-item mainactive" href="#"><span class="name">All Results</span><span class="num"> ('+query_total+')</span></a>'); 2132 2133var countcategories = $('#list-tab > a').length; 2134 if (countcategories > 5) { 2135 $('#list-tab').addClass('multiplecat'); 2136 } else { 2137 $('#list-tab').removeClass('multiplecat'); 2138 } 2139 2140 $('.filterdropdown > a').dropdown({ 2141 //offset: '0, -32' 2142 2143 }); 2144var filterAtribute = 'data-filter'; 2145$('#filterdd, #list-tab').find('a').click(function() { 2146 var $this = $(this); 2147 var sibs = $(this).siblings(); 2148 //var parent = $this.parent('li'); 2149 //var parentsibs = parent.parent().parent().find('li'); 2150 var filterValue = $this.attr('data-filter'); 2151 2152 sibs.removeClass('mainactive'); 2153 $this.addClass('mainactive'); 2154 //$searchgrid.isotope({ filter: filterValue }); 2155 var filtercategory = $(this).attr(filterAtribute); 2156 errormixer.filter(filtercategory); 2157 2158 if ($('#filterdd').hasClass('show')){ 2159 $('#filterdd').dropdown('toggle'); 2160 } 2161 2162 $('.filterdropdown a.btn').removeClass('show'); 2163 2164 return false;
2165 }); 2166 2167 var setheight = $searchgrid.height(); 2168 $searchgrid.css('min-height', setheight); 2169 2170 window.addEventListener('resize', handleResize); 2171 2172 2173 $('.filterdropdown').show(); 2174 2175if ($('.mixitup-page-list').hasClass('mixitup-mixitup-page-list-disabled')){ 2176 //console.log('hide on start'); 2177 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2178} else { 2179 //console.log('show on start'); 2180 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2181} 2182 2183 2184 } // if results 2185 else { 2186 //alert('0 results'); 2187 $('.searchresults').addClass('nosearch'); 2188 $('#searchfilter').addClass('nofilter'); 2189 $('#searchnumber').text('0'); 2190 $('.filterdropdown').hide(); 2191 //$('#searchouter').removeClass('noradius'); 2192 } 2193 2194 } // if success 2195 }); // ajax 2196 2197 } else { 2198 $('.searchresults').addClass('nosearch'); 2199 } 2200 2201 //$('#searchButton').text('Search'); 2202 //$('#searchButton').find('i').removeClass("spin"); 2203 $('.progress').fadeOut(); 2204 2205 } // search function 2206 2207$('input#pagesearch').keyup(function(e) { 2208 if(e.keyCode !== 13) { 2209 //$('#searchButton').find('i').addClass("spin"); 2210 $('.progress').fadeIn(); 2211 $(document).stop(true, true).scrollTo($('html, body'), 400, { interrupt:true, easing:'swing' }); 2212 $('#searchgrid').fadeTo(50,0); 2213 clearTimeout($.data(this, 'timer')); 2214 2215 $(this).data('timer', setTimeout(search, 1500)); 2216 2217} else { 2218 2219} 2220}); 2221 2222$('input#pagesearch').keydown(function(e) { 2223 if(e.keyCode === 13) { 2224 2225 return false; 2226 } 2227}); 2228 2229 } // if errorpage 2230 2231} // errorpage 2232 2233function searchPage(){ 2234 var $resultsgrid = $('#resultsgrid .grid'); 2235 if ($resultsgrid.length) { 2236 2237 var responsiveIsotope = [ 2238 [575, 8], 2239 [992, 8] 2240 ]; 2241 2242var itemsPerPageDefault = 12; 2243 var itemsPerPage = defineItemsPerPage(); 2244 2245 function defineItemsPerPage() { 2246 var pages = itemsPerPageDefault; 2247 2248 for( var i = 0; i < responsiveIsotope.length; i++ ) { 2249 if( $(window).width() <= responsiveIsotope[i][0] ) { 2250 pages = responsiveIsotope[i][1]; 2251 break; 2252 } 2253 } 2254 2255 return pages; 2256 } 2257 2258function handleResize() { 2259 itemsPerPage = defineItemsPerPage(); 2260 2261 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 2262 2263 searchmixer.paginate({ 2264 limit: itemsPerPage 2265 }, false); 2266 2267 $resultsgrid.css('min-height', ''); 2268 var setheight = $resultsgrid.height(); 2269 $resultsgrid.css('min-height', setheight); 2270 //mixer.paginate(1); 2271 2272 2273 } // handleresize 2274 2275var searchmixer = mixitup('.gridouter', { 2276 controls: { 2277 scope: 'global' 2278 }, 2279 classNames: { 2280 elementPager: 'pager', 2281 elementPageList: 'mixitup-page-list' 2282 2283 }, 2284 selectors: { 2285 control: '.mixitup-control' 2286 //target: '[data-ref~="mixitup-target"]', 2287 //control: '[data-mixitup-control]' 2288 }, 2289 animation: { 2290 nudge: false 2291 }, 2292 templates: { 2293 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 2294 //pagerPrev: '', 2295 //pagerNext: '', 2296 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 2297 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>'//, 2298 //pageStats: '${startPageAt} to ${endPageAt} of ${totalTargets}' 2299 }, 2300 pagination: { 2301 limit: itemsPerPage, 2302 maintainActivePage: false, 2303 loop: false, 2304 hidePageListIfSinglePage: true, 2305 maxPagers: 8 2306 }, 2307 callbacks: { 2308 onMixStart: function(state, futureState) { 2309 //console.log('Starting operation...'); 2310 //console.log(futureState.totalPages); 2311 var checkpages = futureState.totalPages; 2312 if (checkpages === 1) { 2313 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2314 } else { 2315 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2316 } 2317 //console.log(futureState.activePagination); 2318 2319 }, 2320 onMixClick: function(state, originalEvent) { 2321 //console.log('The control "' + this.innerText + '" was clicked'); 2322 2323 2324 }, 2325 onMixEnd: function(state) { 2326 //var checkpages = searchmixer.getState().totalPages; 2327 //if (checkpages === 1) { 2328 // $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2329 //} else { 2330 // $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2331 //} 2332 } 2333 } 2334 }); 2335 2336 2337 2338function setfilters(){ 2339 2340 var searchterm = $('input#searchterm').val(); 2341 var searchtotal = $('input#searchtotal').val(); 2342 2343 $('span#searchnumber').html('<span>'+searchtotal+'</span>'); 2344 if (!searchterm){ 2345 2346 } else { 2347 $('span#search-string').html('"<span>'+searchterm+'</span>"'); 2348 } 2349 2350 var cat = $('#resultsgrid').find('.grid-item > div'); 2351 var items = {}; 2352 var items2 = {}; 2353 var categories = {}, 2354 category; 2355 2356 $(cat).each(function(i, el) { 2357 items[$(this).attr('data-catname')] = true; 2358 category = $(el).data('catname'); 2359 2360 if (categories.hasOwnProperty(category)) { 2361 categories[category] += 1; 2362 } 2363 else { 2364 categories[category] = 1; 2365 } 2366 2367}); 2368 2369String.prototype.capitalize = function() { 2370 return this.charAt(0).toUpperCase() + this.slice(1); 2371} 2372String.prototype.toProperCase = function () { 2373 return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); 2374}; 2375 2376for(var key in categories){ 2377 var value = key.replace(/\-/g, " "); 2378 var catbtn = '<a class="dropdown-item" href="#" data-filter=".'+key+'"><span class="name">'+value.toProperCase()+'</span><span class="num"> ('+categories[key] +')</span></a>'; 2379 var catbtn2 = '<a class="nav-item" href="#" data-filter=".'+key+'"><span class="name">'+value.toProperCase()+'</span><span class="num"> ('+categories[key] +')</span></a>'; 2380 2381 $('#filterdd').append(catbtn); 2382 $('#list-tab').append(catbtn2); 2383 } 2384 2385function asc_sort(a, b){ 2386 return ($(b).text()) < ($(a).text()) ? 1 : -1; 2387} 2388 2389$('#filterdd').find('a').sort(asc_sort).appendTo('#filterdd'); 2390$('#list-tab').find('a').sort(asc_sort).appendTo('#list-tab'); 2391 2392$('#filterdd').prepend('<a id="all" data-filter="all" class="dropdown-item" href="#"><span class="name">All Results</span><span class="num"> ('+searchtotal+')</span></a>'); 2393 2394$('#list-tab').prepend('<a id="all" data-filter="all" class="nav-item mainactive" href="#"><span class="name">All Results</span><span class="num"> ('+searchtotal+')</span></a>'); 2395 2396var countcategories = $('#list-tab > a').length; 2397 if (countcategories > 5) { 2398 $('#list-tab').addClass('multiplecat'); 2399 } else { 2400 $('#list-tab').removeClass('multiplecat'); 2401 } 2402 2403 2404var filterAtribute = 'data-filter'; 2405$('#filterdd, #list-tab').find('a').click(function() { 2406 var $this = $(this); 2407 var sibs = $(this).siblings(); 2408 //var parent = $this.parent('li'); 2409 //var parentsibs = parent.parent().parent().find('li'); 2410 var filterValue = $this.attr('data-filter'); 2411 2412 sibs.removeClass('mainactive'); 2413 $this.addClass('mainactive'); 2414 //$searchgrid.isotope({ filter: filterValue }); 2415 var filtercategory = $(this).attr(filterAtribute); 2416 searchmixer.filter(filtercategory); 2417 2418 if ($('#filterdd').hasClass('show')){ 2419 $('#filterdd').dropdown('toggle'); 2420 } 2421 2422 $('.filterdropdown a.btn').removeClass('show'); 2423 2424 return false;
2425 }); 2426 2427 var setheight = $resultsgrid.height(); 2428 $resultsgrid.css('min-height', setheight); 2429 2430 window.addEventListener('resize', handleResize); 2431 2432 $('.filterdropdown').show(); 2433 2434} // setfilters 2435 2436 $('#list-tab').find('a').remove(); 2437 $('#filterdd').find('a').remove(); 2438 2439 setfilters(); 2440 2441if ($('.mixitup-page-list').hasClass('mixitup-mixitup-page-list-disabled')){ 2442 //console.log('hide on start'); 2443 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2444} else { 2445 //console.log('show on start'); 2446 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2447} 2448 2449 } // if resultsgrid exists 2450 2451 else { 2452 var searchterm2 = $('input#searchterm').val(); 2453 var searchtotal2 = $('input#searchtotal').val(); 2454 2455 2456 2457 $('span#searchnumber').html('<span>'+searchtotal2+'</span>'); 2458 2459 if (!searchterm2){ 2460 2461 2462 } else { 2463 $('span#search-string').html('"<span>'+searchterm2+'</span>"'); 2464 2465 } 2466 2467 if (!searchtotal2){ 2468 //$('#searchnumber').text('0'); 2469 2470 $('.filterdropdown').hide(); 2471 $('#searchfilter').hide(); 2472 // $('.leftcolumn .sidebar').hide(); 2473 2474 } 2475 2476 if ($('#searchresults > p.search').length) { 2477 $('input#pagesearch').attr('placeholder', 'Search Again...'); 2478 $('.filterdropdown').hide(); 2479 $('.resultsfilter').addClass('nothing'); 2480 $('#searchfilter').addClass('nofilter'); 2481 2482 } else { 2483 $('#searchfilter').show(); 2484 //$('.leftcolumn .sidebar').show(); 2485 2486 } 2487 2488 } // if no results 2489 2490 if (window.location.href.indexOf("?term=") > -1) { 2491 2492 } else { 2493 $('#searchfilter').hide(); 2494 $('#searchresults').hide(); 2495 //$('.leftcolumn .sidebar').hide(); 2496 $('.searchpage .pagetitle h2').text('Search Discounts'); 2497 $('input#pagesearch').attr('placeholder', 'Search Discounts...'); 2498 } 2499 2500} // searchpage 2501 2502function catbuspages(){ 2503 "use strict"; 2504 2505 if ($('#cat').length) { 2506 catpage(); 2507 } 2508 if ($('#bus').length) { 2509 buspage(); 2510 } 2511 2512} // catbuspages 2513 2514function catpage(){ 2515 "use strict"; 2516 2517 var pagetitletext = $('input#bustitle').val(); 2518 $('.pagetitle h2').empty().text(pagetitletext); 2519 2520 $('.breadcrumbs a.busname').empty(); 2521 $('.breadcrumbs a.activelink').remove(); 2522 var activecat = $('.sidebar a.activelink').text(); 2523 var activecatlink = $('.sidebar a.activelink').attr('href'); 2524 2525 $('.breadcrumbs a#catname').empty().text(activecat); 2526 $('.breadcrumbs a#catname').attr('href', activecatlink); 2527 2528 $('.breadcrumbs ul > li').siblings('li').removeClass('last'); 2529 $('.breadcrumbs ul > li').last().addClass('last'); 2530 2531 $('.breadcrumbs a#catname').parent('li').addClass('last'); 2532 2533 //showLoader(); 2534 setTimeout(function() { 2535 //hideLoader(); 2536 $('#cat .grid').addClass('items-visible'); 2537 }, 400); 2538 2539 2540 2541 //$('#cat .top-pagination').hide(); 2542 2543 var busitems = $('#cat').find('.item').length; 2544 if (busitems > 10) { 2545 $('#cat .gridouter').addClass('addmix'); 2546 $('#cat').removeClass('hidepager'); 2547 } else { 2548 $('#cat .gridouter').removeClass('addmix'); 2549 $('#cat').addClass('hidepager'); 2550 } 2551 2552 if ($('.addmix').length){ 2553 catpagination(); 2554 } 2555 2556} // catpage 2557 2558function catpagination(){ 2559 "use strict"; 2560 2561 var $catgrid = $('#cat .grid'); 2562 2563 showLoader(); 2564 setTimeout(function() { 2565 $catgrid.addClass('items-visible'); 2566 setTimeout(function() { 2567 hideLoader(); 2568 },200); 2569 },400); 2570 2571 2572 var responsiveIsotope = [ 2573 [575, 6], 2574 [767, 9], 2575 [992, 12], 2576 [1400, 12] 2577 ]; 2578 2579 var itemsPerPageDefault =10; 2580 var itemsPerPage = defineItemsPerPage(); 2581 2582 function defineItemsPerPage() { 2583 var pages = itemsPerPageDefault; 2584 2585 for( var i = 0; i < responsiveIsotope.length; i++ ) { 2586 if( $(window).width() <= responsiveIsotope[i][0] ) { 2587 pages = responsiveIsotope[i][1]; 2588 break; 2589 } 2590 } 2591 2592 return pages; 2593 } 2594 2595 function showall(){ 2596 2597 itemsPerPage = mixer.getState().totalTargets; 2598 //console.log(itemsPerPage); 2599 2600 mixer.paginate({ 2601 limit: itemsPerPage, 2602 page: 1 2603 }); 2604 } 2605 2606 $('button#showall').click(function(){ 2607 showall(); 2608 $(this).addClass('disable'); 2609 //console.log(mixer.getState().activePagination.limit); 2610 2611 }); 2612 2613 function handleResize() { 2614 itemsPerPage = defineItemsPerPage(); 2615 2616 //console.log('Changing to a limit of ' + itemsPerPage + ' items per page'); 2617 2618 mixer.paginate({ 2619 limit: itemsPerPage 2620 }, false); 2621 2622 $catgrid.css('min-height', ''); 2623 var setheight = $catgrid.outerHeight(); 2624 $catgrid.css('min-height', setheight); 2625 2626 $('button#showall').removeClass('disable'); 2627 2628 } 2629 2630 var mixer = mixitup('.addmix', { 2631 controls: { 2632 scope: 'global' 2633 }, 2634 classNames: { 2635 elementPager: 'pager', 2636 elementPageList: 'mixitup-page-list' 2637 2638 }, 2639 selectors: { 2640 control: '.mixitup-control' 2641 //target: '[data-ref~="mixitup-target"]', 2642 //control: '[data-mixitup-control]' 2643 }, 2644 animation: { 2645 easing: 'cubic-bezier(0.645, 0.045, 0.355, 1)' 2646 }, 2647 templates: { 2648 pager: '<li class="page-item"><button class="${classNames} pager mixitup-control page-link" role="button" tabindex="0" data-page="${pageNumber}">${pageNumber}</button></li>', 2649 //pagerPrev: '', 2650 //pagerNext: '', 2651 pagerNext: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="next" aria-label="Next"><i class="bi bi-arrow-right"></i></button></li>', 2652 pagerPrev: '<li class="page-arrow page-item"><button class="${classNames} mixitup-control page-link" role="button" tabindex="0" data-page="prev" aria-label="Previous"><i class="bi bi-arrow-left"></i></button></li>', 2653 pageStats: '<div>
2653Showing <span>${startPageAt}-${endPageAt}</span> of <span>${totalTargets}</span></div>' 2654 }, 2655 pagination: { 2656 limit: itemsPerPage, 2657 maintainActivePage: false, 2658 loop: false, 2659 hidePageListIfSinglePage: true, 2660 maxPagers: 8 2661 }, 2662 callbacks: { 2663 onMixStart: function(state, futureState) { 2664 //console.log('Starting operation...'); 2665 //console.log(futureState.totalPages); 2666 var checkpages = futureState.totalPages; 2667 if (checkpages === 1) { 2668 $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2669 } else { 2670 $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2671 } 2672 //console.log(futureState.activePagination); 2673 2674 2675 }, 2676 onMixClick: function(state, originalEvent) { 2677 //console.log('The control "' + this.innerText + '" was clicked'); 2678 2679 2680 2681 }, 2682 onMixEnd: function(state) { 2683 //var checkpages = mixer.getState().totalPages; 2684 //if (checkpages === 1) { 2685 // $('.pagination').addClass('mixitup-mixitup-page-list-disabled'); 2686 //} else { 2687 // $('.pagination').removeClass('mixitup-mixitup-page-list-disabled'); 2688 //} 2689 } 2690 } 2691 }); 2692 2693 setTimeout(function(){ 2694 var setheight = $catgrid.outerHeight(); 2695 $catgrid.css('min-height', setheight); 2696 window.addEventListener('resize', handleResize); 2697 },400); 2698 2699 2700 2701 2702 2703 2704 2705 2706} // catpagination 2707 2708 2709function buspage(){ 2710 "use strict"; 2711 2712 var checklanguagecookie = Cookies.get('language'); 2713 if (checklanguagecookie){ 2714 2715 //console.log(checklanguagecookie); 2716 2717 if (checklanguagecookie === 'alternatelng') { 2718 //$('.bus-image img').css('width', '0px'); 2719 $('.bus-image > div').hide(); 2720 $('#alternate-ad').show(); 2721 } 2722 if (checklanguagecookie === 'english') { 2723 //$('.bus-image img').css('width', ''); 2724 $('#alternate-ad').hide(); 2725 $('.bus-image > div').show(); 2726 } 2727 2728 2729 } // checkcookie 2730 2731 var breadcrumb = $('input#bustitle').val(); 2732 2733 $('.breadcrumbs a.busname').empty(); 2734 var activelink = $('.sidebar a.activelink').attr('href'); 2735 2736 $('.breadcrumbs a.busname').empty().text(breadcrumb); 2737 $('.breadcrumbs a.busname').attr('href', activelink); 2738 2739 $('.breadcrumbs ul > li').siblings('li').removeClass('last'); 2740 $('.breadcrumbs ul > li').last().addClass('last'); 2741 2742 $('#accordion').find('.accordion-item>h3').removeClass('active'); 2743 $('#accordion').find('a.activelink').closest('.accordion-item').find('>h3').addClass('active'); 2744 2745 var currentcollapse2 = $('#accordion').find('.accordion-item > h3.active'); 2746 if (currentcollapse2.length) { 2747 var currentcollapse3 = currentcollapse2.find('>a'); 2748 var currentcollapseexpand2 = currentcollapse3.data('bs-target'); 2749 //console.log(currentcollapseexpand2); 2750 //** DOESNT WORK $(currentcollapse2).collapse('show'); 2751 2752 currentcollapse3.attr('aria-expanded', 'true'); 2753 $(currentcollapseexpand2).addClass('show'); 2754 $(currentcollapseexpand2).parent().addClass('active-item'); 2755 2756 } 2757 2758 showLoader(); 2759 setTimeout(function() { 2760 hideLoader(); 2761 },500); 2762 2763 /* $('.accordion-item .accordion-body ul li a').on('click', function(){ 2764 $(".accordion-collapse.show .accordion-body").mCustomScrollbar("scrollTo", ".accordion-body a.activelink", { 2765 timeout:500 2766 }); 2767 });*/ 2768 2769 2770 var adzoom = $('.modal.adimage'); 2771 2772 $('#adLightbox').on('click', function(){ 2773 $(adzoom).modal({ 2774 //backdrop: 'static' 2775 }); 2776 return false;
2777 }); 2778 2779 $(adzoom).on('show.bs.modal', function (e) { 2780 setZoom(); 2781 2782 }); 2783 2784 $(adzoom).on('hidden.bs.modal', function(e) { 2785 $('.panzoom').panzoom("reset"); 2786 $('button.zoom-out').addClass('inactive'); 2787 $('button.zoom-in').removeClass('inactive'); 2788 }); 2789 2790 function setZoom(){ 2791 var $imagezoom = $('.panzoom'); 2792 2793 var $panzoom = $imagezoom.panzoom({ 2794 minScale: 1, 2795 maxScale: 3, 2796 contain: 'automatic', 2797 panOnlyWhenZoomed: false, 2798 $zoomIn: $('.zoom-in'), 2799 $zoomOut: $('.zoom-out') 2800 }); 2801 2802 $panzoom.on('mousewheel.focal', function( e ) { 2803 e.preventDefault(); 2804 var delta = e.delta || e.originalEvent.wheelDelta; 2805 var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0; 2806 $panzoom.panzoom('zoom', zoomOut, { 2807 increment: 0.1, 2808 animate: false, 2809 focal: e 2810 }); 2811 }); 2812 2813 $panzoom.on("panzoomzoom", function( e, panzoom, scale) { 2814 2815 var endscale = panzoom.scale; 2816 if (endscale === 1) { 2817 //$(this).addClass('scale1'); 2818 $panzoom.panzoom("setMatrix", [ 1, 0, 0, 1, 0, 0 ]); 2819 $('button.zoom-out').addClass('inactive'); 2820 } else { 2821 $('button.zoom-out').removeClass('inactive'); 2822 } 2823 2824 if (endscale === 3) { 2825 $('button.zoom-in').addClass('inactive'); 2826 } else { 2827 $('button.zoom-in').removeClass('inactive'); 2828 } 2829 2830 }); 2831 2832 $(window).on('resize', function(){ 2833 $panzoom.panzoom("reset"); 2834 }); 2835 $( window ).on( "orientationchange", function() { 2836 $panzoom.panzoom("reset"); 2837 }); 2838 2839 2840} // setzoom 2841 2842 2843} // buspage 2844 2845function scrolllightbox(){ 2846 "use strict"; 2847 var modalheight = $('.ltocontent').find('.modal.lto .modal-content').height(); 2848 var modalheader = $('.ltocontent').find('.modal.lto .modal-header').outerHeight(); 2849 var bodyouter = modalheight - modalheader - 56; 2850 2851 $('#main').find('.modal.lto .modal-body').css({ 2852 'max-height': bodyouter 2853 }); 2854 2855 $('.rightcolumn').find('.modal.lto .modal-body').mCustomScrollbar({ 2856 theme: "dark lto", 2857 axis: "y", 2858 scrollbarPosition: 'inside', 2859 scrollInertia: 500, 2860 scrollButtons: { 2861 enable: true, 2862 tabindex: '0' 2863 }, 2864 mouseWheel: { 2865 enable: true, 2866 preventDefault: true 2867 }, 2868 callbacks:{ 2869 onInit:function(){ 2870 //console.log("Scrollbars initialized"); 2871 }, 2872 onCreate:function(){ 2873 $('.mCSB_buttonUp').attr({ 2874 'aria-label': 'Scroll Up', 2875 'role': 'button' 2876 }); 2877 $('.mCSB_buttonDown').attr({ 2878 'aria-label': 'Scroll Down', 2879 'role': 'button' 2880 }); 2881 $('.mCSB_dragger').attr('tabindex', '0'); 2882 } 2883 } 2884 2885 }); 2886 2887 2888 2889} // scrolllightbox 2890 2891function ltopage(){ 2892 "use strict"; 2893 2894 if (location.href.match('lto')){ 2895 2896 if (!$('.ltocontent').length) { 2897 //$('#main').addClass('fullpage'); 2898 //$('.innercontent').addClass('onecolumn'); 2899 } 2900 2901 var $currentUrl = window.location.pathname; 2902 var $currentp = $currentUrl.replace(/\/?$/, ''); 2903 var lastPart = $currentp.substr($currentp.lastIndexOf('/') + 1); 2904 var matches = lastPart.match('lto'); 2905 2906 if (!matches){ 2907 $('.breadcrumbs').find('a[href="/lto"]').removeClass('ltolast'); 2908 2909 $('.breadcrumbs a').css('opacity', 1); 2910 var ltobreadcrumb = $('input#ltotitle').val(); 2911 2912 $('.breadcrumbs a#ltoname').empty(); 2913 var activeltolink = $('.rightnav a.activelink').attr('href'); 2914 2915 $('.breadcrumbs a#ltoname').empty().text(ltobreadcrumb); 2916 //$('.breadcrumbs a#ltoname').attr('href', activeltolink); 2917 $('.breadcrumbs a#ltoname').attr({ 2918 'href': activeltolink, 2919 'aria-label': ltobreadcrumb 2920 }); 2921 2922 2923 $('.breadcrumbs').find('span.remove').css('display', 'inline-block'); 2924 2925 $('.subtitle > h3').empty().text(ltobreadcrumb); 2926 $('.subtitle > h3').show(); 2927 2928 $('#all').hide(); 2929 showLoader(); 2930 $('#single').show(); 2931 2932 setTimeout(function() { 2933 $('.ltocontent .lto-wrapper').fadeTo(400,1); 2934 setTimeout(function() { 2935 hideLoader(); 2936 },400); 2937 },500); 2938 2939 var ltomodal = $('.modal.lto'); 2940 $('#lightbox_link').on('click', function(){ 2941 $(ltomodal).modal(); 2942 }); 2943 2944 $(ltomodal).on('show.bs.modal', function () { 2945
2946 /////// if lto is renfest 2947 var renfest = lastPart.match('renaissancefestival'); 2948 if (renfest) { 2949 $('.modal-body').find('#rf_button').remove(); 2950 $('.modal-header').find('h5').hide(); 2951 $('.modal-header').append('<a href="https://www.carolina.renfestinfo.com/" class="btn" id="rf_button" target="_blank">Click here to purchase tickets »</a>'); 2952 } 2953 2954 /////// if lto is renfest 2955 2956 2957 scrolllightbox(); 2958 2959 }); 2960 2961 $(ltomodal).on('shown.bs.modal', function () { 2962 $('.modal.lto .modal-body').mCustomScrollbar("update"); 2963 }); 2964 2965 $('#print-lto').on('click', function(){ 2966 var print = $('.printlto.show').find('.modal-body img.imgprintlto'); 2967 $(print).print({ 2968 stylesheet: '/assets/css/print.css' 2969 }); 2970 2971 //return false; 2972 }); 2973 2974 } // if single lto 2975 2976 if (matches){ 2977 $('.breadcrumbs').find('span.remove').hide(); 2978 $('.breadcrumbs a#ltoname').empty().attr('href', '').attr('aria-label', 'Empty'); 2979 2980 $('.breadcrumbs').find('a[href="/lto"]').addClass('ltolast'); 2981 2982 // $('.breadcrumbs > a').css('opacity', 0); 2983 2984 2985 $('#single').hide(); 2986 2987 setTimeout(function() { 2988 showLoader(); 2989 $('#all').fadeIn(400); 2990 setTimeout(function() { 2991 hideLoader(); 2992 },400); 2993 },500); 2994 2995 // $('.pagetitle > h2').empty().text('Limited Time Offers'); 2996 2997 } // if all lto 2998 2999 } 3000 3001} // ltopage 3002 3003function scrollinstructions(){ 3004 "use strict"; 3005 var modalheight = $('.modal.modal-instructions .modal-content').height(); 3006 var modalheader = $('.modal.modal-instructions .modal-header').outerHeight(); 3007 var bodyouter = modalheight - modalheader - 100; 3008 3009 $('body').find('.modal.modal-instructions .modal-body').css({ 3010 'max-height': bodyouter 3011 }); 3012 3013 $('body').find('.modal.modal-instructions .modal-body').mCustomScrollbar({ 3014 theme: "dark-thin", 3015 axis: "y", 3016 scrollbarPosition: 'inside', 3017 scrollInertia: 500, 3018 scrollButtons: { 3019 enable: true, 3020 tabindex: '0' 3021 }, 3022 mouseWheel: { 3023 enable: true, 3024 preventDefault: true 3025 }, 3026 callbacks:{ 3027 onInit:function(){ 3028 //console.log("Scrollbars initialized"); 3029 }, 3030 onCreate:function(){ 3031 $('.mCSB_buttonUp').attr({ 3032 'aria-label': 'Scroll Up', 3033 'role': 'button' 3034 }); 3035 $('.mCSB_buttonDown').attr({ 3036 'aria-label': 'Scroll Down', 3037 'role': 'button' 3038 }); 3039 $('.mCSB_dragger').attr('tabindex', '0'); 3040 } 3041 } 3042 3043 }); 3044 3045 3046 3047} // scrollinstructions 3048 3049function mobileapp(){ 3050 "use strict"; 3051 3052 // $('.instruct-list').matchHeight(); 3053 3054 3055 3056 var appmodal = $('.modal-instructions'); 3057 3058 3059 3060 $(appmodal).on('show.bs.modal', function () { 3061 scrollinstructions(); 3062 3063 }); 3064 3065 $('a.print-installation').click(function(){ 3066 3067 var print = $(this).next('img'); 3068 $(print).print({ 3069 stylesheet: '/assets/css/print.css' 3070 }); 3071 3072 return false; 3073 }); 3074 3075 $(appmodal).on('hide.bs.modal', function () { 3076 3077 }); 3078 3079 3080} // mobileapp 3081 3082function privacypage(){ 3083 "use strict"; 3084 3085 if ($('#privacytable').length) { 3086 3087 3088 3089 $('#privacytable a').click(function(){ 3090 //$(this).parent().parent().siblings().removeClass('active'); 3091 //$(this).parent().parent().addClass('active'); 3092 3093 var thislink = $(this).attr('href'); 3094 var target = $('#privacytable > div'+thislink); 3095 3096 $.scrollTo(target, 100, {offset:-150}); 3097 3098 return false; 3099 }); 3100 3101 3102 } // if privacy table exists 3103 3104 3105 3106}// privacy page 3107 3108function information(){ 3109 "use strict"; 3110 3111 /* $('.flex-item p').matchHeight({ 3112 property: 'height' 3113 });*/ 3114 3115 $('div.infobox').mCustomScrollbar("disable"); 3116 3117 $('#infoboxes a.inpagelink').click(function(){ 3118 3119 $("div.preloader").css({ 3120 opacity: 1, 3121 display:'table' 3122 }); 3123 3124 setTimeout(function(){ 3125 $("div.preloader").css({ 3126 opacity: 0, 3127 display:'none' 3128 }) 3129 },250); 3130 //$('body').mCustomScrollbar("disable"); 3131 $('body').css('overflow', 'hidden'); 3132 $('div.infobox').mCustomScrollbar("update"); 3133 $('div.infobox').mCustomScrollbar('scrollTo','top', { 3134 scrollInertia: 0 3135 }); 3136 3137 var infolinks = $(this).attr('rel'); 3138 var infotarget = $('div[id='+infolinks+']'); 3139 3140 $('div.infobox').removeClass('active'); 3141 infotarget.addClass('active'); 3142 3143 if (infolinks === 'enrollmentform'){ 3144 //$('form#enrollment').find('valid').removeClass('valid'); 3145 //$('form#enrollment').find('error').removeClass('error'); 3146 //$('#enrollform').find('.formbody').removeClass('success'); 3147 //$('#enrollform').find('.formhead').show(); 3148 //$('form#enrollment').show(); 3149 //$('#enrollform').find('#formresponse').empty().hide(); 3150 3151 } 3152 3153 return false;
vendor: 10,756 bytes, lines 3154-3445
3154 }); 3155 3156 $('div.infobox').find('#closebox').click(function(){ 3157 3158 $('div.infobox').removeClass('active'); 3159 $('div.infobox').mCustomScrollbar("disable"); 3160 $('body').css('overflow', ''); 3161 //$('body').mCustomScrollbar("update"); 3162 3163 return false; 3164 }); 3165 3166 $('div.infobox').mCustomScrollbar({ 3167 theme: 'minimal-dark', 3168 scrollbarPosition: 'inside', 3169 autoHideScrollbar: false, 3170 autoDraggerLength:false 3171 }); 3172 3173}// information page 3174 3175 3176$(document).ready(function() { 3177 3178 /* 3179 * jQuery accessible and keyboard-enhanced navigation with dropdown 3180 * Website: http://a11y.nicolas-hoffmann.net/subnav-dropdown/ 3181 * License MIT: https://github.com/nico3333fr/jquery-accessible-subnav-dropdown/blob/master/LICENSE 3182 */ 3183 // loading expand paragraphs 3184 var $nav_system = $('.js-nav-system'), 3185 $body = $('body'); 3186 if ($nav_system.length) { // if there is at least one :) 3187 3188 // initialization 3189 var $nav_system_link = $('.js-nav-system__link'); 3190 3191 $nav_system_link.each(function(index_to_expand) { 3192 var $this = $(this), 3193 index_lisible = index_to_expand + 1, 3194 $subnav = $this.next('.js-nav-system__subnav'); 3195 3196 // if there is a subnav adjacent to the link 3197 if ($subnav.length === 1) { 3198 $subnav.attr({ 3199 'data-visually-hidden': 'true' 3200 }); 3201 } 3202 }); 3203 3204 } 3205 3206 // events on main menu 3207 // mouse ! 3208 $body.on('mouseenter', '.js-nav-system__item', function(event) { 3209 var $this = $(this), 3210 $subnav_link = $this.children('.js-nav-system__link'), 3211 $subnav = $this.children('.js-nav-system__subnav'); 3212 3213 $this.attr({ 3214 'data-show-sub': 'true' 3215 }); 3216 3217 // show submenu 3218 if ($subnav.length === 1) { 3219 $subnav.attr({ 3220 'data-visually-hidden': 'false' 3221 }); 3222 } 3223 3224 }) 3225 .on('mouseleave', '.js-nav-system__item', function(event) { 3226 var $this = $(this), 3227 $subnav_link = $this.children('.js-nav-system__link'), 3228 $subnav = $this.children('.js-nav-system__subnav'); 3229 3230 $this.attr({ 3231 'data-show-sub': 'false' 3232 }); 3233 // show submenu 3234 if ($subnav.length === 1) { 3235 $subnav.attr({ 3236 'data-visually-hidden': 'true' 3237 }); 3238 } 3239 3240 }) 3241 // keyboard 3242 .on('focus', '.js-nav-system__link', function(event) { 3243 var $this = $(this), 3244 $parent = $this.parents('.js-nav-system'), 3245 $parent_item = $this.parents('.js-nav-system__item'), 3246 $subnav = $this.next('.js-nav-system__subnav'); 3247 3248 $parent_item.attr({ 3249 'data-show-sub': 'true' 3250 }); 3251 3252 // hide other menus and show submenu activated 3253 $parent.find('.js-nav-system__subnav').attr({ 3254 'data-visually-hidden': 'true' 3255 }); 3256 3257 if ($subnav.length === 1) { 3258 $subnav.attr({ 3259 'data-visually-hidden': 'false' 3260 }); 3261 } 3262 3263 }) 3264 .on('focusout', '.js-nav-system__link', function(event) { 3265 var $this = $(this), 3266 $parent = $this.parents('.js-nav-system'), 3267 $parent_item = $this.parents('.js-nav-system__item'); 3268 3269 $parent_item.attr({ 3270 'data-show-sub': 'false' 3271 }); 3272 }) 3273 .on('keydown', '.js-nav-system__link', function(event) { 3274 var $this = $(this), 3275 $parent = $this.parents('.js-nav-system'), 3276 $parent_item = $this.parents('.js-nav-system__item'), 3277 $subnav = $this.next('.js-nav-system__subnav'); 3278 3279 // event keyboard left 3280 if (event.keyCode == 37) { 3281 // select previous nav-system__link 3282 3283 // if we are on first => activate last 3284 if ($parent_item.is(".js-nav-system__item:first-child")) { 3285 $parent.find(" .js-nav-system__item:last-child ").children(".js-nav-system__link").focus(); 3286 } 3287 // else activate previous 3288 else { 3289 $parent_item.prev().children(".js-nav-system__link").focus(); 3290 } 3291 event.preventDefault(); 3292 } 3293 3294 // event keyboard right 3295 if (event.keyCode == 39) { 3296 // select previous nav-system__link 3297 3298 // if we are on last => activate first 3299 if ($parent_item.is(".js-nav-system__item:last-child")) { 3300 $parent.find(" .js-nav-system__item:first-child ").children(".js-nav-system__link").focus(); 3301 } 3302 // else activate next 3303 else { 3304 $parent_item.next().children(".js-nav-system__link").focus(); 3305 } 3306 event.preventDefault(); 3307 } 3308 3309 // event keyboard bottom 3310 if (event.keyCode == 40) { 3311 // select first nav-system__subnav__link 3312 if ($subnav.length === 1) { 3313 // if submenu has been closed => reopen 3314 $subnav.attr({ 3315 'data-visually-hidden': 'false' 3316 }); 3317 // and select first item 3318 $subnav.find(" .js-nav-system__subnav__item:first-child ").children(".js-nav-system__subnav__link").focus(); 3319 } 3320 event.preventDefault(); 3321 } 3322 3323 // event shift + tab 3324 if (event.shiftKey && event.keyCode == 9) { 3325 if ($parent_item.is(".js-nav-system__item:first-child")) { 3326 $subnav.attr({ 3327 'data-visually-hidden': 'true' 3328 }); 3329 } else { 3330 3331 var $prev_nav_link = $parent_item.prev('.js-nav-system__item').children(".js-nav-system__link"); 3332 $subnav_prev = $prev_nav_link.next('.js-nav-system__subnav'); 3333 if ($subnav_prev.length === 1) { // hide current subnav, show previous and select last element 3334 $subnav.attr({ 3335 'data-visually-hidden': 'true' 3336 }); 3337 $subnav_prev.attr({ 3338 'data-visually-hidden': 'false' 3339 }); 3340 $subnav_prev.find(" .js-nav-system__subnav__item:last-child ").children(".js-nav-system__subnav__link").focus(); 3341 event.preventDefault(); 3342 } 3343 } 3344 } 3345 3346 }); 3347 3348 // events on submenu item 3349 $body.on('keydown', '.js-nav-system__subnav__link', function(event) { 3350 var $this = $(this), 3351 $subnav = $this.parents('.js-nav-system__subnav'), 3352 $subnav_item = $this.parents('.js-nav-system__subnav__item'), 3353 $nav_link = $subnav.prev('.js-nav-system__link'), 3354 $nav_item = $nav_link.parents('.js-nav-system__item'), 3355 $nav = $nav_link.parents('.js-nav-system'); 3356 3357 // event keyboard bottom 3358 if (event.keyCode == 40) { 3359 // if we are on last => activate first 3360 if ($subnav_item.is(".js-nav-system__subnav__item:last-child")) { 3361 $subnav.find(".js-nav-system__subnav__item:first-child ").children(".js-nav-system__subnav__link").focus(); 3362 } 3363 // else activate next 3364 else { 3365 $subnav_item.next().children(".js-nav-system__subnav__link").focus(); 3366 } 3367 event.preventDefault(); 3368 } 3369 // event keyboard top 3370 if (event.keyCode == 38) { 3371 // if we are on first => activate last 3372 if ($subnav_item.is(".js-nav-system__subnav__item:first-child")) { 3373 $subnav.find(" .js-nav-system__subnav__item:last-child ").children(".js-nav-system__subnav__link").focus(); 3374 } 3375 // else activate previous 3376 else { 3377 $subnav_item.prev().children(".js-nav-system__subnav__link").focus(); 3378 } 3379 event.preventDefault(); 3380 } 3381 // event keyboard Esc 3382 if (event.keyCode == 27) { 3383 // close the menu 3384 $nav_link.focus(); 3385 $subnav.attr({ 3386 'data-visually-hidden': 'true' 3387 }); 3388 event.preventDefault(); 3389 } 3390 // event keyboard right 3391 if (event.keyCode == 39) { 3392 // select next nav-system__link 3393 $subnav.attr({ 3394 'data-visually-hidden': 'true' 3395 }); 3396 3397 // if we are on last => activate first and choose first item 3398 if ($nav_item.is(".js-nav-system__item:last-child")) { 3399 $next = $nav.find(" .js-nav-system__item:first-child ").children(".js-nav-system__link"); 3400 $next.focus(); 3401 $subnav_next = $next.next('.js-nav-system__subnav'); 3402 if ($subnav_next.length === 1) { 3403 $subnav_next.find(" .js-nav-system__subnav__item:first-child ").children(".js-nav-system__subnav__link").focus(); 3404 } 3405 } 3406 // else activate next 3407 else { 3408 $next = $nav_item.next().children(".js-nav-system__link"); 3409 $next.focus(); 3410 $subnav_next = $next.next('.js-nav-system__subnav'); 3411 if ($subnav_next.length === 1) { 3412 $subnav_next.find(" .js-nav-system__subnav__item:first-child ").children(".js-nav-system__subnav__link").focus(); 3413 } 3414 } 3415 event.preventDefault(); 3416 } 3417 // event keyboard left 3418 if (event.keyCode == 37) { 3419 // select prev nav-system__link 3420 $subnav.attr({ 3421 'data-visually-hidden': 'true' 3422 }); 3423 3424 // if we are on first => activate last and choose first item 3425 if ($nav_item.is(".js-nav-system__item:first-child")) { 3426 $prev = $nav.find(" .js-nav-system__item:last-child ").children(".js-nav-system__link"); 3427 $prev.focus(); 3428 $subnav_prev = $prev.next('.js-nav-system__subnav'); 3429 if ($subnav_prev.length === 1) { 3430 $subnav_prev.find(".js-nav-system__subnav__item:first-child ").children(".js-nav-system__subnav__link").focus(); 3431 } 3432 } 3433 // else activate prev 3434 else { 3435 $prev = $nav_item.prev().children(".js-nav-system__link"); 3436 $prev.focus(); 3437 $subnav_prev = $prev.next('.js-nav-system__subnav'); 3438 if ($subnav_prev.length === 1) { 3439 $subnav_prev.find(".js-nav-system__subnav__item:first-child ").children(".js-nav-system__subnav__link").focus(); 3440 } 3441 } 3442 event.preventDefault(); 3443 } 3444 // event tab 3445 if (event.keyCode == 9 && !event.shiftKey) { // if we are on last subnav of last item and we go forward => hide subnav
3446 if ($nav_item.is(".js-nav-system__item:last-child") && $subnav_item.is(".js-nav-system__subnav__item:last-child")) { 3447 $subnav.attr({ 3448 'data-visually-hidden': 'true' 3449 }); 3450 } 3451 } 3452 3453 }) 3454 .on('focus', '.js-nav-system__subnav__link', function(event) { 3455 var $this = $(this), 3456 $subnav = $this.parents('.js-nav-system__subnav'), 3457 $subnav_item = $this.parents('.js-nav-system__subnav__item'), 3458 $nav_link = $subnav.prev('.js-nav-system__link'), 3459 $nav_item = $nav_link.parents('.js-nav-system__item'), 3460 $nav = $nav_link.parents('.js-nav-system__item'); 3461 3462 $nav_item.attr({ 3463 'data-show-sub': 'true' 3464 }); 3465 }) 3466 .on('focusout', '.js-nav-system__subnav__link', function(event) { 3467 var $this = $(this), 3468 $subnav = $this.parents('.js-nav-system__subnav'), 3469 $subnav_item = $this.parents('.js-nav-system__subnav__item'), 3470 $nav_link = $subnav.prev('.js-nav-system__link'), 3471 $nav_item = $nav_link.parents('.js-nav-system__item'), 3472 $nav = $nav_link.parents('.js-nav-system__item'); 3473 3474 $nav_item.attr({ 3475 'data-show-sub': 'false' 3476 }); 3477 }); 3478 3479 3480 3481});
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.