1var AvrilThemeJs; 2 3(function( $, avrilConfig ) { 4 'use strict'; 5 6 AvrilThemeJs = { 7 8 eventID: 'AvrilThemeJs', 9 10 $document: $( document ), 11 $window: $( window ), 12 $body: $( 'body' ), 13 14 classes: { 15 toggled: 'toggled', 16 isOverlay: 'overlay-enabled', 17 headerMenuActive: 'header-menu-active', 18 headerSearchActive: 'header-search-active' 19 }, 20 21 init: function() { 22 // Document ready event check 23 this.$document.on( 'ready', this.documentReadyRender.bind( this ) ); 24 this.$document.on( 'ready', this.processAutoheight.bind( this ) ); 25 this.$window.on( 'ready', this.documentReadyRender.bind( this ) ); 26 }, 27 28 documentReadyRender: function() { 29 30 // Document Events 31 this.$document 32 .on( 'click.' + this.eventID, '.menu-toggle', this.menuToggleHandler.bind( this ) ) 33 .on( 'click.' + this.eventID, '.header-close-menu', this.menuToggleHandler.bind( this ) ) 34 35 .on( 'click.' + this.eventID, this.hideHeaderMobilePopup.bind( this ) ) 36 37 .on( 'click.' + this.eventID, '.mobile-toggler', this.verticalMobileSubMenuLinkHandle.bind( this ) ) 38 39 .on( 'click.' + this.eventID, '.header-close-menu', this.resetVerticalMobileMenu.bind( this ) ) 40 .on( 'hideHeaderMobilePopup.' + this.eventID, this.resetVerticalMobileMenu.bind( this ) ) 41 42 .on( 'resize.' + this.eventID, this.processAutoheight.bind( this ) ) 43 44 .on( 'click.' + this.eventID, '.header-search-toggle', this.searchToggleHandler.bind( this ) ) 45 .on( 'click.' + this.eventID, '.header-search-close', this.searchToggleHandler.bind( this ) ) 46 47 .on( 'click.' + this.eventID, this.hideSearchHeader.bind( this ) ) 48 49 .on( 'click.' + this.eventID, '.scrollup', this.scrollUpClick.bind( this ) ); 50 51 // Window Events 52 this.$window 53 .on( 'load.' + this.eventID, this.preloader.bind( this ) ) 54 55 .on('scroll.' + this.eventID, this.scrollToSticky.bind( this ) ) 56 57 .on('scroll.' + this.eventID, this.scrollUp.bind( this ) ) 58 59 .on('load.' + this.eventID, this.mobileMenuRight.bind( this ) ) 60 61 .on('load.' + this.eventID, this.mobileMenuClone.bind( this ) ) 62 63 .on( 'load.' + this.eventID, this.menuFocusAccessibility.bind( this ) ) 64 65 .on( 'load.' + this.eventID, this.customQuery.bind( this ) ) 66 67 .on( 'resize.' + this.eventID, this.processAutoheight.bind( this ) ); 68 }, 69 70 // Preloader 71 preloader: function( event ) { 72 $(".preloader").fadeOut('slow'); 73 }, 74 75 // Scroll UP 76 scrollUp: function( event ) { 77 var self = this, 78 $scrollup = $( '.scrollup' ); 79 if (self.$window.scrollTop() > 100) { 80 $scrollup.addClass('is-active'); 81 } 82 else { 83 $scrollup.removeClass('is-active'); 84 } 85 }, 86 scrollUpClick: function( event ) { 87 $("html, body").animate({ 88 scrollTop: 0 89 }, 600); 90 return false; 91 }, 92 93 // Sticky Header 94 scrollToSticky: function( event ) { 95 var self = this, 96 $stickyNav = $( '.sticky-nav' ); 97 if (self.$window.scrollTop() >= 220) { 98 $stickyNav.addClass('sticky-menu'); 99 } 100 else { 101 $stickyNav.removeClass('sticky-menu'); 102 } 103 }, 104 105 // Auto Height Manage On Header 106 processAutoheight: function( event ) { 107 var self = this; 108 var $naviWrap = $( '.navigator-wrapper' ); 109 var $naviWrapAll = $( '.navigator-wrapper > .theme-mobile-nav' ); 110 var $naviWrapAllDesk = $( '.navigator-wrapper > .nav-area *:not(.logo):not(.search-button *):not(.cart-wrapper *):not(.dropdown-menu)' ); 111 var maxHeight = 0; 112 113 // This will check first level children ONLY as intended. 114 if ($('body').find('div').hasClass("sticky-nav")) { 115 if ($('div.theme-mobile-nav').css('display') == 'block') { 116 $naviWrapAll.each(function(){ 117 var height = $(this).outerHeight(true); // outerHeight will add padding and margin to height total 118 if (height > maxHeight ) { 119 maxHeight = height; 120 } 121 }); 122 $naviWrap.css('min-height', maxHeight); 123 } 124 else { 125 $naviWrapAllDesk.each(function(){ 126 var height = $(this).outerHeight(true); // outerHeight will add padding and margin to height total 127 if (height > maxHeight ) { 128 maxHeight = height; 129 } 130 }); 131 $naviWrap.css('min-height', maxHeight); 132 } 133 } 134 }, 135 136 // Add/Remove focus classess for accessibility 137 menuFocusAccessibility: function( event ) { 138 $('.menubar, .widget_nav_menu').find('a').on('focus blur', function() { 139 $( this ).parents('ul, li').toggleClass('focus'); 140 }); 141 }, 142 143 // Mobile Menu Clone 144 mobileMenuRight: function( event ) {
145 $(".header-wrap-right").clone().appendTo(".mobile-menu-right"); 146 }, 147 148 // Mobile Menu Clone 149 mobileMenuClone: function( event ) { 150 $(".menubar .menu-wrap").clone().appendTo(".mobile-menu"); 151 }, 152 153 // Mobile Menu Toggle Handler 154 menuToggleHandler: function( event ) { 155 var self = this, 156 $toggle = $( '.menu-toggle' ); 157 158 self.$body.toggleClass( self.classes.headerMenuActive ); 159 self.$body.toggleClass( self.classes.isOverlay ); 160 $toggle.toggleClass( self.classes.toggled ); 161 162 if ( self.$body.hasClass( self.classes.headerMenuActive ) ) { 163 $( '.header-close-menu' ).focus(); 164 } else { 165 $toggle.focus(); 166 } 167 168 self.menuAccessibility(); 169 }, 170 171 // Mobile Menu Popup Hide 172 hideHeaderMobilePopup: function( event ) { 173 var self = this, 174 $toggle = $( '.menu-toggle' ), 175 $mobileMenuBar = $( '.mobile-menu' ); 176 177 if ( $( event.target ).closest( $toggle ).length || $( event.target ).closest( $mobileMenuBar ).length ) { 178 return; 179 } 180 181 if ( ! self.$body.hasClass( self.classes.headerMenuActive ) ) { 182 return; 183 } 184 185 self.$body.removeClass( self.classes.headerMenuActive ); 186 self.$body.removeClass( self.classes.isOverlay ); 187 $toggle.removeClass( self.classes.toggled ); 188 189 self.$document.trigger( 'hideHeaderMobilePopup.' + self.eventID ); 190 191 event.stopPropagation(); 192 }, 193 194 // Mobile Sub Menu Link Handler 195 verticalMobileSubMenuLinkHandle: function( event ) { 196 event.preventDefault(); 197 198 var self = this, 199 $target = $( event.currentTarget ), 200 $menu = $target.closest( '.mobile-menu .menu-wrap' ), 201 deep = $target.parents( '.dropdown-menu' ).length, 202 direction = self.isRTL ? 1 : -1, 203 translate = direction * deep * 100; 204 205 //$menu.css( 'transform', 'translateX(' + translate + '%)' ); 206 207 setTimeout( function() { 208 $target.parent().toggleClass("current"); 209 $target.next().slideToggle(); 210 }, 250 ); 211 }, 212 213 // Reset Mobile Menu Popup 214 resetVerticalMobileMenu: function( event ) { 215 var self = this, 216 $menu = $( '.mobile-menu .menu-wrap' ), 217 $menuItems = $( '.mobile-menu .menu-item' ), 218 $deep = $( '.mobile-menu .dropdown-menu'); 219 220 setTimeout( function() { 221 $menuItems.removeClass("current"); 222 $deep.hide(); 223 }, 250 ); 224 }, 225 226 // Active focus on menu popup 227 menuAccessibility: function() { 228 var links, i, len, 229 menu = document.querySelector( '.mobile-menu' ), 230 iconToggle = document.querySelector( '.header-close-menu' ); 231 232 let focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; 233 let firstFocusableElement = iconToggle; // get first element to be focused inside menu 234 let focusableContent = menu.querySelectorAll(focusableElements); 235 let lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside menu 236 237 if ( ! menu ) { 238 return false; 239 } 240 241 links = menu.getElementsByTagName( 'a' ); 242 243 // Each time a menu link is focused or blurred, toggle focus. 244 for ( i = 0, len = links.length; i < len; i++ ) { 245 links[i].addEventListener( 'focus', toggleFocus, true ); 246 links[i].addEventListener( 'blur', toggleFocus, true ); 247 } 248 249 // Sets or removes the .focus class on an element. 250 function toggleFocus() { 251 var self = this; 252 253 // Move up through the ancestors of the current link until we hit .mobile-menu. 254 while (-1 === self.className.indexOf( 'mobile-menu' ) ) { 255 // On li elements toggle the class .focus. 256 if ( 'li' === self.tagName.toLowerCase() ) { 257 if ( -1 !== self.className.indexOf( 'focus' ) ) { 258 self.className = self.className.replace( ' focus', '' ); 259 } else { 260 self.className += ' focus'; 261 } 262 } 263 self = self.parentElement; 264 } 265 } 266 267 // Trap focus inside modal to make it ADA compliant 268 document.addEventListener('keydown', function (e) { 269 let isTabPressed = e.key === 'Tab' || e.keyCode === 9; 270 271 if ( ! isTabPressed ) { 272 return; 273 } 274 275 if ( e.shiftKey ) { // if shift key pressed for shift + tab combination 276 if (document.activeElement === firstFocusableElement) { 277 lastFocusableElement.focus();
277 // add focus for the last focusable element 278 e.preventDefault(); 279 } 280 } else { // if tab key is pressed 281 if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab 282 firstFocusableElement.focus(); // add focus for the first focusable element 283 e.preventDefault(); 284 } 285 } 286 }); 287 288 }, 289 290 // Search Box Toggle Handler 291 searchToggleHandler: function( event ) { 292 var self = this, 293 $toggle = $( '.header-search-toggle' ), 294 $field = $( '.header-search-field' ); 295 296 self.$body.toggleClass( self.classes.headerSearchActive ); 297 self.$body.toggleClass( self.classes.isOverlay ); 298 299 if ( self.$body.hasClass( self.classes.headerSearchActive ) ) { 300 $field.focus(); 301 } else { 302 $toggle.focus(); 303 } 304 305 self.searchPopupAccessibility(); 306 }, 307 308 // Search Box Hide 309 hideSearchHeader: function( event ) { 310 var self = this, 311 $toggle = $( '.header-search-toggle' ), 312 $popup = $( '.header-search-popup' ); 313 314 if ( $( event.target ).closest( $toggle ).length || $( event.target ).closest( $popup ).length ) { 315 return; 316 } 317 318 if ( ! self.$body.hasClass( self.classes.headerSearchActive ) ) { 319 return; 320 } 321 322 self.$body.removeClass( self.classes.headerSearchActive ); 323 self.$body.removeClass( self.classes.isOverlay ); 324 $toggle.focus(); 325 326 event.stopPropagation(); 327 }, 328 329 // Active focus on search popup 330 searchPopupAccessibility: function() { 331 $( document ).on( 'keydown', function( e ) { 332 if ( $( 'body' ).hasClass( 'header-search-active' ) ) { 333 var activeElement = document.activeElement; 334 var searchItems = $( '.header-search-popup button, .header-search-popup input' ); 335 var firstEl = $( '.header-search-close' ); 336 var lastEl = searchItems[ searchItems.length - 1 ]; 337 var tabKey = event.keyCode === 9; 338 var shiftKey = event.shiftKey; 339 if ( ! shiftKey && tabKey && lastEl === activeElement ) { 340 event.preventDefault(); 341 firstEl.focus(); 342 } 343 if ( shiftKey && tabKey && firstEl === activeElement ) { 344 event.preventDefault(); 345 lastEl.focus(); 346 } 347 } 348 } ); 349 }, 350 351 // Custom Carousel 352 customQuery: function() { 353 //First Word 354 // $(".site-title").html(function(){ 355 // var text= $(this).text().trim().split(" "); 356 // var first = text.shift(); 357 // return (text.length > 0 ? "<span class='site-first-letter'>"+ first + "</span> " : first) + text.join(" "); 358 // }); 359 //Last Word 360 $(".site-title").html(function(){ 361 var text= $(this).text().trim().split(" "); 362 var last = text.pop(); 363 return text.join(" ") + (text.length > 0 ? " <span class='site-first-letter'>" + last + "</span>" : last); 364 }); 365 366 // Header Widget 367 if( !$('.header-widget').children().length > 0 ) { 368 $(".header-widget").hide(); 369 $(".headtop-mobi").hide(); 370 } 371 else { 372 $(".headtop-mobi").show(); 373 $(".header-widget").clone().appendTo(".mobi-head-top"); 374 var $mob_h_top = $("#mob-h-top"); 375 $('.header-above-toggle').on('click', function(e) { 376 $mob_h_top.toggleClass("active"); 377 $('.header-above-toggle').toggleClass("active"); 378 e.preventDefault(); 379 }); 380 } 381 382 // Blog Images Carousel 383 var blogImgCarousel = $(".post-image-carousel"); 384 blogImgCarousel.owlCarousel({ 385 items: 1, 386 loop: true, 387 dots: false, 388 navText: ['<i class="icofont-simple-left"></i>', '<i class="icofont-simple-right"></i>'], 389 autoplay: false, 390 smartSpeed: 1000, 391 responsive: { 392 0: { 393 nav: false, 394 }, 395 768: { 396 nav: true 397 }, 398 992: { 399 nav: true 400 } 401 } 402 }); 403 404 // MagnificPopup 405 $('.mgf-popup').magnificPopup({ 406 delegate: 'a', 407 type: 'image', 408 gallery: { 409 enabled: true, 410 navigateByImgClick: true, 411 preload: [0,1] // Will preload 0 - before current, and 1 after the current image 412 }, 413 callbacks: { 414 elementParse: function(item) { 415 //console.log(item.el[0].className); 416 if(item.el[0].className == 'video') { 417 item.type = 'iframe', 418 item.iframe = { 419 patterns: { 420 youtube: { 421 index: 'youtube.com/', // String that detects type of video (in this case YouTube). Simply via url.indexOf(index). 422 423 id: 'v=', // String that splits URL in a two parts, second part should be %id% 424 // Or null - full URL will be returned 425 // Or a function that should return %id%, for example: 426 // id: function(url) { return 'parsed id'; } 427 428 src: '//www.youtube.com/embed/%id%?autoplay=1' // URL that will be set as a source for iframe. 429 }, 430 vimeo: { 431 index: 'vimeo.com/', 432 id: '/', 433 src: '//player.vimeo.com/video/%id%?autoplay=1' 434 }, 435 gmaps: { 436 index: '//maps.google.', 437 src: '%id%&output=embed' 438 } 439 } 440 } 441 } else { 442 item.type = 'image', 443 item.tLoading = 'Loading image #%curr%...', 444 item.mainClass = 'mfp-img-mobile', 445 item.image = { 446 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.' 447 } 448 } 449 450 } 451 } 452 }); 453 454 // Single Magnific Popup Video 455 $('.popup-single-video').magnificPopup({ 456 type: 'iframe' 457 }); 458 459 // counter up 460 $('.counter').counterUp({ 461 delay: 10, 462 time: 1000 463 }); 464 465 //AV Filter Tab 466 activePostFilter(); 467 function activePostFilter(){ 468 var postFilter = $('.av-filter-init'); 469 $.each(postFilter,function (index,value) { 470 var el = $(this); 471 var parentClass = $(this).parent().attr('class'); 472 var $selector = $('#'+el.attr('id')); 473 $($selector).imagesLoaded(function () { 474 var festivarMasonry = $($selector).isotope({ 475 itemSelector: '.av-filter-item', 476 percentPosition: true, 477 masonry: { 478 columnWidth: 0, 479 gutter:0 480 } 481 }); 482 $(document).on('click', '.'+parentClass+' .av-tab-filter a', function () { 483 var filterValue = $(this).attr('data-filter'); 484 festivarMasonry.isotope({ 485 filter: filterValue 486 }); 487 }); 488 }); 489 }); 490 } 491 $(document).on('click', '.av-tab-filter a', function () { 492 $(this).siblings().removeClass('active'); 493 $(this).addClass('active'); 494 }); 495 496 // Load Button Filter 497 $(".av-load-3").slice(0, 6).show(); 498 $(".av-load-4").slice(0, 8).show(); 499 $(".av-load-btn").on('click', function (e) { 500 e.preventDefault(); 501 $(".av-load-btn").addClass("loadspinner"); 502 $(".av-load-btn").animate({ 503 display: "block" 504 }, 2000, 505 function () { 506 // Animation complete. 507 // $(".load-2:hidden").slice(0, 2).slideDown() 508 // .each(function() { 509 // $('#grid').shuffle('appended', $(this)); 510 // }); 511 $(".av-load-3:hidden").slice(0, 3).slideDown(); 512 $(".av-load-4:hidden").slice(0, 4).slideDown(); 513 if ($(".av-load-item:hidden").length === 0) { 514 $(".av-load-btn").text("No more"); 515 } 516 $(".av-load-btn").removeClass("loadspinner"); 517 } 518 ); 519 }); 520 521 // Toggle-Comments 522 $('#avril-toggle-comments').on('click', function () {
523 $(".avril-is-toggle-comments").toggleClass('comments-visible'); 524 if($('body').hasClass('comments-visible')) 525 { 526 $('.toggle-comment').text('Hide'); 527 } 528 else { 529 $('.toggle-comment').text('Show'); 530 } 531 }); 532 533 $('.funfact-section, .breadcrumb-area').ripples({ 534 resolution: 500, 535 //dropRadius: 20, 536 perturbance: 0.04, 537 }); 538 539 if ($(".service-section-hover").length > 0) { 540 $(".service-section-hover").each(function () { 541 if ($(window).width() < 991) { 542 return; 543 } 544 545 $(this) 546 .find(".services-carousel .owl-stage, .service-row") 547 .append('<div class="indicator"></div>'); 548 549 var leftPos = $(this) 550 .find(".services-carousel .owl-stage .owl-item, .service-row [class*='av-column-']") 551 .eq(1) 552 .position().left, 553 column = $(this).find(".services-carousel .owl-stage .owl-item, .service-row [class*='av-column-']"), 554 indicator = ".indicator"; 555 556 var topPos = $(this) 557 .find(".services-carousel .owl-stage .owl-item, .service-row [class*='av-column-']") 558 .eq(1) 559 .position().top, 560 column = $(this).find(".services-carousel .owl-stage .owl-item, .service-row [class*='av-column-']"), 561 indicator = ".indicator"; 562 563 column.siblings(indicator).css("width", column.outerWidth()); 564 column.siblings(indicator).css("height", $('.service-item').innerHeight()); 565 column.siblings(indicator).css("left", leftPos); 566 column.siblings(indicator).css("top", topPos); 567 568 column.on("mouseenter mouseleave", function (event) { 569 if (event.type === "mouseenter") { 570 $(this) 571 .siblings(indicator) 572 .css({left: $(this).position().left, top: $(this).position().top}); 573 } 574 if (event.type === "mouseleave") { 575 $(this) 576 .siblings(indicator) 577 .css({left: leftPos, top: topPos}); 578 } 579 }); 580 }); 581 } 582 // Button Effect 583 document.querySelectorAll('.av-btn:not(.av-search-submit)').forEach(button => button.innerHTML = '<div><span>' + button.textContent.trim().split('').join('</span><span>') + '</span></div>'); 584 } 585 }; 586 587 AvrilThemeJs.init(); 588 589}( jQuery, window.avrilConfig ));
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.