1function string_to_number( string ) { 2 if ( typeof string === 'number' ) { 3 return string; 4 } 5 if ( typeof string === 'string' ) { 6 var n = string.match(/[^\d\.]+$/); 7 if ( ! n ) { 8 n = string.match(/[\d\.]+$/); 9 } 10 if (n) { 11 return parseFloat(n[0]); 12 } else { 13 return 0; 14 } 15 } 16 return 0; 17} 18 19function string_to_bool( v ) { 20 if ( typeof v === 'boolean' ){ 21 return v; 22 } 23 24 if ( typeof v === 'number' ){ 25 return v === 0 ? false : true; 26 } 27 28 if ( typeof v === 'string' ){ 29 if ( v === 'true' || v === '1' ) { 30 return true; 31 } else { 32 return false; 33 } 34 } 35 36 return false; 37} 38 39 40/** 41 * skip-link-focus-fix.js 42 * 43 * Helps with accessibility for keyboard only users. 44 * 45 * Learn more: https://git.io/vWdr2 46 */ 47( function() { 48 var is_webkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, 49 is_opera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, 50 is_ie = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; 51 52 if ( ( is_webkit || is_opera || is_ie ) && document.getElementById && window.addEventListener ) { 53 window.addEventListener( 'hashchange', function() { 54 var id = location.hash.substring( 1 ), 55 element; 56 57 if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { 58 return; 59 } 60 61 element = document.getElementById( id ); 62 63 if ( element ) { 64 if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { 65 element.tabIndex = -1; 66 } 67 68 element.focus(); 69 } 70 }, false ); 71 } 72})(); 73 74/** 75 * navigation.js 76 * 77 * Handles toggling the navigation menu for small screens and enables tab 78 * support for dropdown menus. 79 */ 80( function() { 81 var container, button, menu, links, subMenus; 82 83 container = document.getElementById( 'site-navigation' ); 84 if ( ! container ) { 85 return; 86 } 87 88 button = container.getElementsByTagName( 'button' )[0]; 89 if ( 'undefined' === typeof button ) { 90 return; 91 } 92 93 menu = container.getElementsByTagName( 'ul' )[0]; 94 95 // Hide menu toggle button if menu is empty and return early. 96 if ( 'undefined' === typeof menu ) { 97 button.style.display = 'none'; 98 return; 99 } 100 101 menu.setAttribute( 'aria-expanded', 'false' ); 102 if ( -1 === menu.className.indexOf( 'nav-menu' ) ) { 103 menu.className += ' nav-menu'; 104 } 105 106 button.onclick = function() { 107 if ( -1 !== container.className.indexOf( 'toggled' ) ) { 108 container.className = container.className.replace( ' toggled', '' ); 109 button.setAttribute( 'aria-expanded', 'false' ); 110 menu.setAttribute( 'aria-expanded', 'false' ); 111 } else { 112 container.className += ' toggled'; 113 button.setAttribute( 'aria-expanded', 'true' ); 114 menu.setAttribute( 'aria-expanded', 'true' ); 115 } 116 }; 117 118 // Get all the link elements within the menu. 119 links = menu.getElementsByTagName( 'a' ); 120 subMenus = menu.getElementsByTagName( 'ul' ); 121 122 // Set menu items with submenus to aria-haspopup="true". 123 for ( var i = 0, len = subMenus.length; i < len; i++ ) { 124 subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' ); 125 } 126 127 // Each time a menu link is focused or blurred, toggle focus. 128 for ( i = 0, len = links.length; i < len; i++ ) { 129 links[i].addEventListener( 'focus', toggleFocus, true ); 130 links[i].addEventListener( 'blur', toggleFocus, true ); 131 } 132 133 /** 134 * Sets or removes .focus class on an element. 135 */ 136 function toggleFocus() { 137 var self = this; 138 139 // Move up through the ancestors of the current link until we hit .nav-menu. 140 while ( -1 === self.className.indexOf( 'nav-menu' ) ) { 141 142 // On li elements toggle the class .focus. 143 if ( 'li' === self.tagName.toLowerCase() ) { 144 if ( -1 !== self.className.indexOf( 'focus' ) ) { 145 self.className = self.className.replace( ' focus', '' ); 146 } else { 147 self.className += ' focus'; 148 } 149 } 150 151 self = self.parentElement; 152 } 153 } 154 155 156} )(); 157 158 159jQuery( document ).ready( function( $ ){ 160 161 var mobile_max_width = 1140; // Media max width for mobile 162 var main_navigation = jQuery('.main-navigation .nav-menu'); 163 var stite_header = $( '.site-header' ); 164 165 /** 166 * Initialise Menu Toggle 167 */ 168 jQuery('#nav-toggle').on('click', function(event){ 169 event.preventDefault(); 170 jQuery('#nav-toggle').toggleClass('nav-is-visible'); 171 jQuery('body').toggleClass('body-nav-is-visible'); 172 jQuery('.main-navigation .nav-menu').toggleClass("nav-menu-mobile"); 173 jQuery('.header-widget').toggleClass("header-widget-mobile"); 174 175 if ( main_navigation.hasClass( 'nav-menu-mobile' ) && $( window).width() <= mobile_max_width ) { 176 var h = $( window).height( ) - stite_header.height(); 177 main_navigation.css( { 178 height: h, 179 overflow: 'auto', 180 }); 181 } else { 182 main_navigation.removeAttr( 'style' ); 183 } 184 185 }); 186 187 $( window).resize( function(){ 188 if ( main_navigation.hasClass( 'nav-menu-mobile' ) && $( window).width() <= mobile_max_width ) { 189 var h = $( window).height( ) - stite_header.height(); 190 main_navigation.css( { 191 height: h, 192 overflow: 'auto', 193 }); 194 } else { 195 main_navigation.removeAttr( 'style' ); 196 } 197 } ); 198 199 200 jQuery('.nav-menu li.menu-item-has-children, .nav-menu li.page_item_has_children').each( function() { 201 jQuery(this).prepend('<div class="nav-toggle-subarrow"><i class="fa fa-angle-down"></i></div>'); 202 }); 203 204 jQuery('.nav-toggle-subarrow, .nav-toggle-subarrow .nav-toggle-subarrow').click( 205 function () { 206 jQuery(this).parent().toggleClass("nav-toggle-dropdown"); 207 } 208 ); 209 210 211 /** 212 * Fixed header 213 * 214 */ 215 var is_fixed_header = $('.site-header.sticky-header').length > 0 ? true: false;
216 var is_transparent = false; 217 if ( $('.site-header.sticky-header').hasClass( 'transparent' ) ){ 218 is_fixed_header = true; 219 is_transparent = true; 220 } 221 222 if ( is_fixed_header ) { 223 224 $('.site-header.sticky-header').eq(0).wrap( '<div class="site-header-wrapper">' ); 225 var $wrap = $( '.site-header-wrapper'); 226 $wrap.addClass( 'no-scroll' ); 227 228 $( window ).scroll(function () { 229 230 var scrolled = $(window).scrollTop(); 231 if (scrolled > 0) { 232 $('body').addClass('scrolled'); 233 } else { 234 $('body').removeClass('scrolled'); 235 } 236 237 var header_fixed = $('.site-header').eq(0); 238 var header_parent = header_fixed.parent(); 239 var header_h = header_fixed.height() || 0; 240 var p_to_top = header_parent.position().top; 241 var topbar = $('#wpadminbar').height() || 0; 242 if (topbar > 0) { 243 var topbar_pos = $('#wpadminbar').css('position'); 244 if ('fixed' !== topbar_pos) { 245 p_to_top += topbar ; 246 topbar = 0; 247 } 248 } 249 var start = 0; 250 if ( is_fixed_header && is_transparent ) { 251 if ( $( '.swiper-slider' ).length ) { 252 start = $( '.swiper-slider' ).eq( 0 ).offset( ).top + $( '.swiper-slider' ).outerHeight(); 253 start = start - header_h - topbar ; 254 } else if ( $( '.page-header-cover' ).length ) { 255 start = $( '.page-header-cover' ).eq( 0 ).offset( ).top + $( '.page-header-cover' ).outerHeight(); 256 start = start - header_h - topbar ; 257 } 258 } 259 260 var scrollTop = $(document).scrollTop(); 261 262 if ( scrollTop > start ) { 263 if ( ! is_transparent ) { 264 $wrap.height(header_h); 265 } 266 $wrap.addClass('is-fixed').removeClass('no-scroll'); 267 header_fixed.addClass('header-fixed'); 268 269 if ( scrollTop < p_to_top + topbar ) { 270 header_fixed.css('top', scrollTop + 'px'); 271 } else { 272 header_fixed.css('top', topbar + 'px'); 273 } 274 275 header_fixed.css('top', topbar + 'px'); 276 header_fixed.stop().animate({}, 400); 277 } else { 278 header_fixed.removeClass('header-fixed'); 279 header_fixed.css('top', 'auto'); 280 header_fixed.stop().animate({}, 400); 281 if (!is_transparent) { 282 $wrap.height(''); 283 } 284 $wrap.removeClass('is-fixed').addClass('no-scroll'); 285 } 286 }); 287 288 } 289 290 function get_header_top_height(){ 291 var hh = ( jQuery('#wpadminbar').height() || 0 ) + ( jQuery('.site-header.sticky-header').height() || 0 ); 292 if ( $( '#masthead.site-header').hasClass( 'transparent' ) ){ 293 if ( $( window ).scrollTop() == 0 ) { 294 hh -= 15; 295 } 296 } 297 return hh; 298 } 299 300 // Add active class to menu when scroll to active section. 301 if ( string_to_bool( Screenr.is_home_front_page ) ) { 302 // Navigation click to section. 303 jQuery('.home #site-navigation li a[href*="#"]').on('click', function(event){ 304 event.preventDefault(); 305 var _h = this.hash; 306 if ( $( '.nav-menu' ).hasClass( 'nav-menu-mobile' ) ) { 307 $( '#nav-toggle' ).trigger( 'click' ); 308 } 309 smoothScroll ( _h ); 310 }); 311 312 jQuery( window ).scroll(function () { 313 var currentNode = null; 314 var header_top_height = get_header_top_height(); 315 jQuery('.site-main section').each(function () { 316 var s = $(this); 317 var currentId = s.attr('id') || ''; 318 if ( jQuery( window ).scrollTop() >= s.offset().top - header_top_height - 10 ) { 319 currentNode = currentId; 320 } 321 322 }); 323 324 jQuery('#site-navigation li').removeClass('current-menu-item'); 325 if ( currentNode ) { 326 jQuery('#site-navigation li').find('a[href$="#' + currentNode + '"]').parent().addClass('current-menu-item'); 327 } 328 }); 329 } else { 330 jQuery( '#site-navigation li.menu-item-type-custom' ).removeClass('current-menu-item'); 331 } 332 333 // Move to the right section on page load. 334 jQuery( window ).load( function(){ 335 var urlCurrent = location.hash; 336 if (jQuery(urlCurrent).length>0 ) { 337 smoothScroll(urlCurrent); 338 } 339 }); 340 341 // Other scroll to elements 342 jQuery( 'body' ).on('click', '.swiper-slide a[href*="#"]:not([href="#"]), .parallax-content a[href*="#"]:not([href="#"]), .back-top-top', function(event){ 343 if (this.host != window.location.host) return; 344 event.preventDefault(); 345 if ( $( '.nav-menu' ).hasClass( 'nav-menu-mobile' ) ) { 346 $( '#nav-toggle' ).trigger( 'click' ); 347 } 348 smoothScroll( jQuery( this.hash ) ); 349 }); 350 351 // Smooth scroll animation 352 function smoothScroll( urlhash ) { 353 if ( urlhash.length <= 0 ) { 354 return false;
355 } 356 var header_top_height = get_header_top_height(); 357 jQuery("html, body").animate({ 358 scrollTop: ( jQuery( urlhash ).offset().top - header_top_height + 3 ) + "px" 359 }, { 360 duration: 800, 361 easing: "swing" 362 }); 363 return false; 364 } 365 366 // Next section 367 $( 'body').on( 'click', '.btn-next-section', function( e ){ 368 e.preventDefault(); 369 var current_section = $( this).closest( 'section' ); 370 if ( current_section.next( ).length > 0 ) { 371 smoothScroll( '#'+ current_section.next().attr( 'id' ) ); 372 } 373 374 } ); 375 376 377 /** 378 * Custom Slider 379 */ 380 var video_support = function(){ 381 return !!document.createElement('video').canPlayType; 382 }; 383 var is_video_support = video_support(); 384 385 function set_swiper_full_screen_height(){ 386 387 if ( ! $( 'body' ).hasClass( 'page-template-template-frontpage' ) ) { 388 return false; 389 } 390 var h = $( window).height(); 391 392 var admin_bar_h = 0; 393 if ( $( '#wpadminbar').length > 0 ) { 394 admin_bar_h = $( '#wpadminbar').height(); 395 } 396 var header_h = 0; 397 if ( $( '.site-header').length > 0 && ! $( '.site-header').hasClass( 'transparent' ) ){ 398 header_h = $( '.site-header').eq( 0).height(); 399 } 400 401 h = h - admin_bar_h - header_h; 402 var header_pos = ''; 403 if ( $( '.site-header').length > 0 ){ 404 header_pos = $( '.site-header').eq(0).css('position'); 405 } 406 407 $( '.swiper-slider').each( function(){ 408 var s = $(this ); 409 if ( s.hasClass( 'full-screen' ) ) { 410 if ( header_pos === 'fixed' ) { 411 s.css({ 412 height: h+'px', 413 }); 414 } else { 415 s.css({ 416 height: h+'px', 417 }); 418 } 419 } 420 } ); 421 } 422 423 //---------------------------------------------- 424 425 function set_slider_padding(){ 426 var hh = 0; 427 // Set slider header padding 428 if ( $( '#page-header-cover' ).length > 0 ) { 429 hh = $( '.site-header.transparent' ).eq( 0 ).height(); 430 hh = hh / 2; 431 $( '.swiper-intro-inner' ).css( 'margin-top', hh + 'px' ); 432 } 433 434 } 435 436 set_slider_padding(); 437 $( window ).resize( function(){ 438 set_slider_padding(); 439 } ); 440 441 442 var slider_number_item = $( '.swiper-slider .swiper-slide').length; 443 var autoplay = $( '.swiper-container:not(.elementor-image-carousel-wrapper)' ).data( 'autoplay' ) || 0; 444 445 var swiper = new Swiper('.swiper-container:not(.elementor-image-carousel-wrapper):not(.jp-carousel-swiper-container)', { 446 // Disable preloading of all images 447 preloadImages: false, 448 loop: slider_number_item > 1 ? true: false, 449 // Enable lazy loading 450 lazyLoading: true, 451 //preloadImages: false, 452 autoplay: string_to_number( Screenr.autoplay ), 453 speed: string_to_number( Screenr.speed ) , 454 effect: Screenr.effect, // "slide", "fade", "cube", "coverflow" or "flip" 455 //direction: 'vertical', 456 pagination: '.swiper-pagination', 457 paginationClickable: true, 458 grabCursor: false, 459 460 nextButton: '.swiper-button-next', 461 prevButton: '.swiper-button-prev', 462 463 allowSwipeToPrev: slider_number_item > 1 ? true: false, 464 allowSwipeToNext: slider_number_item > 1 ? true: false, 465 466 onInit: function( swiper ){ 467 var slide = swiper.slides[ swiper.activeIndex ]; 468 $( slide ).addClass( 'activated' ); 469 var n = $( slide ) .attr( 'data-swiper-slide-index' ) || 0; 470 n = parseInt( n ); 471 $( '.slide-current').text( n + 1 ); 472 $( '.slide-total').text( slider_number_item ); 473 if ( ! is_video_support ) { 474 return; 475 } 476 // Need to pause all videos in the slider 477 swiper.slides.each(function (index, _slide) { 478 if ( $('video', _slide ).length > 0 ) { 479 $('video', _slide ).each(function () { 480 var v = $(this); 481 try { 482 483 v[0].currentTime = 0; 484 v[0].pause(); 485 486 if ( v[0].readyState >= 2 ) { 487 } 488 489 v.on( 'ended', function(){ 490 if ( slider_number_item === 1 ) { 491 v[0].pause(); 492 v[0].currentTime = 0; 493 v[0].play(); 494 } else { 495 v[0].pause(); 496 v[0].currentTime = 0;
497 if ( 0 !== autoplay ) { 498 swiper.slideNext(); 499 } 500 swiper.startAutoplay(); 501 } 502 } ); 503 504 } catch ( e ){ 505 506 } 507 508 }); 509 } 510 }); 511 512 if ( $('video', slide).length > 0 ) { 513 var v = $('video', slide).eq(0); 514 try { 515 swiper.stopAutoplay(); 516 v[0].currentTime = 0; 517 v[0].play(); 518 } catch ( e ){ 519 520 } 521 } 522 523 }, 524 onSlideChangeStart: function( swiper ) { 525 var slide = swiper.slides[ swiper.activeIndex ]; 526 527 // Current number slide 528 var n = $( slide ).attr( 'data-swiper-slide-index' ) || 0; 529 n = parseInt( n ); 530 $( '.slide-current').text( n + 1 ); 531 532 }, 533 onSlideChangeEnd: function( swiper ){ 534 var slide = swiper.slides[swiper.activeIndex]; 535 // Need to pause all videos in the slider 536 swiper.slides.each(function (index, slide) { 537 $( slide).removeClass( 'activated' ); 538 }); 539 540 $( slide).addClass( 'activated' ); 541 542 if ( ! is_video_support ) { 543 return; 544 } 545 546 // Need to pause all videos in the slider 547 swiper.slides.each(function (index, slide) { 548 if ($('video', slide).length > 0) { 549 $('video', slide).each(function () { 550 var v = $(this); 551 try { 552 v[0].currentTime = 0; 553 v[0].pause(); 554 } catch ( e ){ 555 556 } 557 }); 558 } 559 }); 560 561 if ( $('video', slide).length > 0 ) { 562 var v = $('video', slide).eq(0); 563 //v[0].readyState >= 2 564 try { 565 swiper.stopAutoplay(); 566 v[0].currentTime = 0; 567 v[0].play(); 568 } catch ( e ){ 569 570 } 571 } 572 } 573 574 }); 575 576 577 // Hide pagination if have 1 slide 578 if ( slider_number_item === 1 ) { 579 $( '.swiper-slider .swiper-pagination').hide(); 580 } 581 582 583 //hover on button 584 $( '.swiper-button-prev, .swiper-button-next').hover( function(){ 585 var b = $( this ); 586 var w = b.find( '.slide-count').width(); 587 b.animate({ 588 width: "+="+w, 589 }, 400 , function(){ 590 b.addClass( 'active' ); 591 }); 592 }, function(){ 593 var b = $( this ); 594 var w = b.find( '.slide-count').width(); 595 b.removeClass( 'active' ); 596 b.animate({ 597 width: "-="+w, 598 }, 400 , function(){ 599 b.removeClass( 'active' ); 600 }); 601 } ); 602 603 604 if ( string_to_bool( Screenr.slider_parallax ) || ( Screenr.header_layout !=='default' && $( '#page-header-cover' ).length > 0 ) ) { 605 var slider_overlay_opacity = $('.swiper-slider.fixed .swiper-container .overlay').eq( 0 ).css('opacity') || .35; 606 $( window ).scroll( function () { 607 var scrolled = $( window ).scrollTop(); 608 var header_pos = false; 609 if ( $('.site-header.sticky-header').length > 0 ) { 610 header_pos = $('.site-header').eq(0).hasClass('sticky-header'); 611 } 612 613 var admin_bar_h = 0; 614 if ( $( '#wpadminbar' ).length > 0 ) { 615 admin_bar_h = $( '#wpadminbar' ).height(); 616 } 617 var st = scrolled * 0.7; 618 // calc opactity 619 var _t = 0; 620 var slider_height = $('.swiper-slider').eq(0).height(); 621 var o = ( scrolled / ( slider_height / 2 ) ); 622 623 if ( o > 1 ) { 624 o = 1; 625 } 626 if ( o < 0 ) { 627 o = 0; 628 } 629 var _oo = ( o > .8 ) ? .8 : o; 630 if ( _oo < slider_overlay_opacity ) { 631 _oo = slider_overlay_opacity; 632 } 633 634 if ( header_pos && st > admin_bar_h ) { 635 _t = st - ( admin_bar_h ); 636 $('.swiper-slider .swiper-container .swiper-slide-intro').css({ 637 'opacity': 1 - o 638 }); 639 } else { 640 _t = 0; 641 $('.swiper-slider .swiper-container .swiper-slide-intro').css({ 642 'opacity': 1 - o 643 }); 644 } 645 646 $('.swiper-slider .swiper-container').css({ 647 'top': _t + 'px', 648 }); 649 $('.swiper-slider .swiper-container .overlay').css({ 650 'opacity': _oo 651 }); 652 653 if ( swiper && swiper.length ) { 654 var sch = swiper.container.outerHeight(); 655 656 if (scrolled >= sch / 4) { 657 swiper.container.addClass('over-1-4'); 658 } else { 659 swiper.container.removeClass('over-1-4'); 660 } 661 if (scrolled >= sch / 3) { 662 swiper.container.addClass('over-1-3'); 663 } else { 664 swiper.container.removeClass('over-1-3'); 665 } 666 if (scrolled >= sch / 2) { 667 swiper.container.addClass('over-1-2'); 668 } else { 669 swiper.container.removeClass('over-1-2'); 670 } 671 672 if (scrolled >= sch * 2 / 3) { 673 swiper.container.addClass('over-2-3'); 674 } else { 675 swiper.container.removeClass('over-2-3'); 676 } 677 678 var next_button = swiper.container.find('.btn-next-section'); 679 var _btn_top = next_button.attr('data-top') || ''; 680 681 var btop = 0; 682 if (!_btn_top || _btn_top === '') { 683 btop = next_button.css('top'); 684 } else { 685 btop = _btn_top; 686 } 687 if (top === '') { 688 btop = 0; 689 } else { 690 btop = parseInt(btop); 691 } 692 if (!_btn_top) { 693 next_button.attr('data-top', btop); 694 } 695 if (_t > 0) { 696 next_button.css({'top': (btop - _t) + 'px'}); 697 } else { 698 next_button.css({'top': ''}); 699 } 700 701 $.each(swiper.slides, function (index, slide) { 702 var slider = $(slide); 703 var intro = slider.find('.swiper-slide-intro'), intro_inner = intro.find('.swiper-intro-inner'); 704 var _padding_top = intro_inner.css('padding-top') || 0; 705 _padding_top = parseFloat(_padding_top); 706 var intro_top = _padding_top; 707 708 intro.css({'top': ''}); 709 var top = intro.css('top'); 710 top = parseInt(top); 711 712 if (scrolled > 0) { 713 var _s_t, pt_top = 0; 714 if (intro_top > 0) { 715 pt_top = scrolled / intro_top; 716 } else { 717 pt_top = .6; 718 } 719 if (pt_top >= 1) { 720 pt_top = 1; 721 } 722 if (pt_top < .3) { 723 pt_top = .3; 724 } 725 726 _s_t = top - scrolled + _t; 727 _s_t -= _s_t * pt_top; 728 intro.css({'top': (_s_t) + 'px'}); 729 } else { 730 intro.css({'top': ''}); 731 } 732 733 }); 734 } 735 }); 736 } 737 738 if ( Screenr.full_screen_slider == '1' ) { 739 set_swiper_full_screen_height(); 740 $( window ).resize( function(){ 741 set_swiper_full_screen_height(); 742 } ); 743 } 744 745 $( window ).resize( function(){ 746 if ( swiper && swiper.length ) { 747 swiper.container.find('.swiper-slide-intro, .btn-next-section').removeAttr('data-top').removeAttr('style'); 748 $(window).trigger('scroll'); 749 } 750 } ); 751 752 753 $( '.swiper-slider' ).bind( 'preview_event_changed', function(){ 754 alert( 'section_slider_changed' ); 755 } ); 756 757 758 $('.section-parallax, .parallax-hero').bind('inview', function ( event, visible ) { 759 if ( visible == true ) { 760 } else { 761 } 762 }); 763 764 var lastScrollTop = 0; 765 // Paralax effect 766 function parallaxPosition( scrollTop, direction ){ 767 var top = $( window ).scrollTop(); 768 var wh = $( window).height(); 769 var ww = $( window).width(); 770 $('.section-parallax, .parallax-hero').each( function( ){ 771 var $el = $( this ); 772 var h = $el.height(); 773 var r = .3; 774 if ( wh > h ) { 775 r = .3; 776 } else { 777 r = .6; 778 } 779 780 var pl = $( '.parallax-bg', $el ); 781 782 var w = $el.width(); 783 var h = $el.height(); 784 var img = $( 'img', pl ); 785 786 if ( img.length ) { 787
788 var imageNaturalWidth = img.prop('naturalWidth'); 789 var imageNaturalHeight = img.prop('naturalHeight'); 790 791 var containerHeight = h > 0 ? h : 500; 792 var imgHeight = img.height(); 793 var parallaxDist = imgHeight - containerHeight; 794 var top = $el.offset().top; 795 var windowHeight = window.innerHeight; 796 var windowBottom = scrollTop + windowHeight; 797 var percentScrolled = (windowBottom - top) / (containerHeight + windowHeight); 798 799 var parallaxTop = parallaxDist * percentScrolled; 800 var l; 801 var max_width = imageNaturalWidth; 802 803 if ( imageNaturalWidth > w ){ 804 } else { 805 max_width = ww; 806 } 807 808 if( max_width > ww*2 && imageNaturalHeight > containerHeight * 2) { 809 max_width = max_width - ww; 810 } 811 812 l = (max_width - ww ) / 2; 813 if ( l < 0 ) { 814 l = 0; 815 } 816 817 img.css( { 818 top: '-' + ( parallaxTop ) + 'px', 819 left: '-' + ( l ) + 'px', 820 //maxWidth: ww+'px' 821 maxWidth: max_width+'px' 822 }); 823 824 } else { 825 826 var section_h = $el.height(); 827 var is_inview = $el.data( 'inview' ); 828 if ( is_inview ) { 829 var offsetTop = $el.offset().top; 830 var diff, bgTop; 831 diff = top - offsetTop; 832 bgTop = Math.round( diff * r ); 833 if ( bgTop > h ) { 834 bgTop = h; 835 } 836 if ( wh > h * 2 ) { 837 $('.parallax-bg', $el).css('background-position', '50% ' + ( 0 - ( section_h + bgTop ) ) + 'px'); 838 } else { 839 $('.parallax-bg', $el).css('background-position', '50% ' + ( bgTop ) + 'px'); 840 } 841 } 842 843 } 844 845 846 847 848 } ); 849 } 850 $(window).scroll(function(e){ 851 var top = $( window ).scrollTop(); 852 var direction = ''; 853 if ( top > lastScrollTop ){ 854 direction = 'down'; 855 } else { 856 direction = 'up'; 857 } 858 lastScrollTop = top ; 859 parallaxPosition( top ); 860 }); 861 $(window).resize( function(){ 862 var top = $( window ).scrollTop(); 863 parallaxPosition( top ); 864 } ); 865 866 $(window).trigger('scroll'); 867 868 869} ); 870 871 872 873jQuery( document ).ready( function( $ ){ 874 875 /** 876 * Video lightbox 877 */ 878 if ($.fn.lightGallery ) { 879 $(".videolightbox-popup").lightGallery({}); 880 } 881 882 // Counter 883 $('.counter').counterUp({ 884 delay: 10, 885 time: 1000 886 }); 887 888 // Video 889 jQuery('.site-content').fitVids(); 890 891 // Ajax load more posts 892 $( 'body' ).on( 'click', '.content-grid-loadmore.blt-ajax', function( e ){ 893 e.preventDefault(); 894 var button = $( this ); 895 if ( ! button.prop( 'is_loading' ) ) { 896 button.prop( 'is_loading', true ); 897 button.addClass( 'loading' ); 898 899 button.find( 'i' ).removeClass( 'fa-angle-double-down' ).addClass( 'fa-spinner fa-spin' ); 900 901 var paged = button.prop('paged') || 2; 902 // It's always form 2 because page 1 already there. 903 if ( paged <= 2 ) { 904 paged = 2; 905 } 906 var data = { 907 'action': 'screenr_ajax_posts', 908 'paged': paged 909 }; 910 911 jQuery.get( Screenr.ajax_url, data, function ( response ) { 912 response = '<div>' + response + '</div>'; 913 response = $( response ); 914 button.prop( 'paged', paged + 1 ); 915 button.prop( 'is_loading', false ); 916 button.removeClass( 'loading' ); 917 button.find( 'i' ).removeClass( 'fa-spinner fa-spin' ).addClass( 'fa-angle-double-down' ); 918 919 var num_post = $( 'article', response ).length; 920 921 $('article', response).each(function (index, post) { 922 $('#section-news-posts').append( post ); 923 }); 924 925 if (num_post <= 0) { 926 button.hide(); 927 } else { 928 929 } 930 931 }); 932 } 933 934 } ); 935 936} ); 937 938 939// Gallery 940jQuery( document ).ready( function( $ ){ 941 942 /** 943 * Gallery 944 */ 945 function _gallery_init( $context ){ 946 // justified 947 if ( $.fn.justifiedGallery ) { 948 $( '.gallery-justified', $context ).imagesLoaded( function() { 949 $( '.gallery-justified', $context).each( function(){ 950 var margin = $( this).attr( 'data-spacing' ) || 20; 951 margin = string_to_number( margin ); 952 $( this ).justifiedGallery({ 953 rowHeight: 120, 954 margins: margin, 955 selector: 'a, div:not(.spinner), .inner' 956 }); 957 } ); 958 }); 959 } 960 961 962 // Slider 963 if ( $.fn.owlCarousel ) { 964 965 $( '.gallery-slider', $context ).imagesLoaded( function() { 966 // Slider 967 $( '.gallery-slider', $context ).owlCarousel({ 968 items: 1, 969 itemsCustom: false, 970 itemsDesktop: 1, 971 itemsDesktopSmall: 1, 972 itemsTablet: 1, 973 itemsTabletSmall: false, 974 itemsMobile: 1, 975 singleItem: true, 976 itemsScaleUp: false, 977 978 slideSpeed : 200, 979 paginationSpeed : 800, 980 rewindSpeed : 1000, 981 autoPlay : 4000, 982 stopOnHover : true, 983 984 navigation : true, 985 navigationText : ["<i class='lg-icon'></i>", "<i class='lg-icon'></i>"], 986 987 pagination : false, 988 paginationNumbers : false, 989 autoHeight : true, 990 }); 991 }); 992 993 $('.gallery-carousel', $context).imagesLoaded( function() { 994 $('.gallery-carousel', $context).each(function () { 995 var n = $(this).attr('data-col') || 5; 996 n = string_to_number(n); 997 if (n <= 0) { 998 n = 5; 999 } 1000 1001 $(this).owlCarousel({ 1002 items: n, 1003 itemsCustom: false,
1004 itemsDesktop: [1199, ( n > 4) ? 4 : n], 1005 itemsDesktopSmall: [979, ( n > 3) ? 3 : n], 1006 itemsTablet: [768, ( n > 2) ? 2 : n], 1007 itemsTabletSmall: false, 1008 itemsMobile: [479, ( n > 2) ? 2 : n], 1009 singleItem: false, 1010 itemsScaleUp: false, 1011 1012 slideSpeed: 200, 1013 paginationSpeed: 800, 1014 rewindSpeed: 1000, 1015 autoPlay: 4000, 1016 stopOnHover: true, 1017 1018 navigation: true, 1019 navigationText: ["<i class='lg-icon'></i>", "<i class='lg-icon'></i>"], 1020 1021 pagination: false, 1022 paginationNumbers: false, 1023 }); 1024 1025 }); 1026 }); 1027 1028 } 1029 1030 1031 function isotope_init (){ 1032 if ( $.fn.isotope ) { 1033 1034 $(".gallery-masonry", $context).imagesLoaded( function() { 1035 $(".gallery-masonry", $context).each(function () { 1036 var m = $(this); 1037 var gutter = m.attr('data-gutter') || 10; 1038 var columns = m.attr('data-col') || 5; 1039 1040 //console.log(columns); 1041 1042 gutter = string_to_number(gutter); 1043 columns = string_to_number(columns); 1044 1045 var w = $(window).width(); 1046 if (w <= 940) { 1047 columns = columns > 2 ? columns - 1 : columns; 1048 } 1049 1050 if (w <= 720) { 1051 columns = columns > 3 ? 3 : columns; 1052 } 1053 1054 if (w <= 576) { 1055 columns = columns > 2 ? 2 : columns; 1056 } 1057 1058 //gutter = gutter / 2; 1059 // m.parent().css({'margin-left': -gutter, 'margin-right': -gutter}); 1060 m.find('.g-item').css({'width': ( 100 / columns ) + '%', 'float': 'left', 'padding': 0}); 1061 // m.find('.g-item .inner').css({'padding': gutter / 2}); 1062 m.isotope({ 1063 // options 1064 itemSelector: '.g-item', 1065 percentPosition: true, 1066 masonry: { 1067 columnWidth: '.inner' 1068 } 1069 }); 1070 1071 }); 1072 }); 1073 } 1074 } 1075 1076 isotope_init(); 1077 $( window ).resize( function(){ 1078 isotope_init(); 1079 } ); 1080 1081 if ( $.fn.lightGallery ) { 1082 $('.enable-lightbox', $context).lightGallery({ 1083 mode: 'lg-fade', 1084 selector: 'a', 1085 // cssEasing : 'cubic-bezier(0.25, 0, 0.25, 1)' 1086 1087 }); 1088 } 1089 } 1090 1091 _gallery_init( $( '.gallery-content' ) ); 1092 1093 if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) { 1094 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { 1095 if ( placement.partial.id == 'section-gallery' ) { 1096 _gallery_init( placement.container.find( '.gallery-content' ) ); 1097 } 1098 } ); 1099 } 1100 1101} ); 1102
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.