1( function( $ ) { 2 "use strict"; 3 4 /** 5 * Global Vars 6 */ 7 var windowWidth = window.innerWidth, 8 windowHeight = window.innerHeight, 9 adminBarHeight = $( '#wpadminbar' ).innerHeight(), 10 headerHeight = $( '.site-header' ).innerHeight(), 11 navBarHeight = $( '.navbar-primary' ).innerHeight(); 12 13 if ( $( 'body' ).hasClass( 'admin-bar' ) ) { 14 if ( window.innerWidth > 782 ) { 15 adminBarHeight = 32; 16 } else { 17 adminBarHeight = 46; 18 } 19 } 20 21 $( document ).ready( function() { 22 headerHeight = $( '.site-header' ).innerHeight(); 23 navBarHeight = $( '.navbar-primary' ).innerHeight(); 24 } ); 25 26 $( window ).resize( function() { 27 windowWidth = window.innerWidth; 28 windowHeight = window.innerHeight; 29 adminBarHeight = $( '#wpadminbar' ).innerHeight(); 30 headerHeight = $( '.site-header' ).innerHeight(); 31 navBarHeight = $( '.navbar-primary' ).innerHeight(); 32 } ); 33 34 var isIE = /MSIE|Trident/i.test( navigator.userAgent ); 35 36 var isRetina = false; 37 38 if ( window.matchMedia ) { 39 var mq = window.matchMedia( "only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)" ); 40 if ( mq && mq.matches || ( window.devicePixelRatio > 1 ) ) { 41 isRetina = true; 42 } 43 } 44 45 var rtl = false; 46 47 if ( $( 'body' ).hasClass( 'rtl' ) ) { 48 rtl = true; 49 } 50 51 // Create csco object. 52 var csco = { 53 addAction: function( x, y, z ) { 54 return; 55 } 56 }; 57 58 if ( 'undefined' !== typeof wp && 'undefined' !== typeof wp.hooks ) { 59 csco.addAction = wp.hooks.addAction; 60 } 61 62 /** 63 * Cookies 64 */ 65 function csGetCookie( name ) { 66 let matches = document.cookie.match( new RegExp( 67 "(?:^|; )" + name.replace( /([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1' ) + "=([^;]*)" 68 ) ); 69 return matches ? decodeURIComponent( matches[ 1 ] ) : undefined; 70 } 71 72 function csSetCookie( name, value, props = {} ) { 73 74 props = { 75 path: '/' 76 }; 77 78 if ( props.expires instanceof Date ) { 79 props.expires = props.expires.toUTCString(); 80 } 81 82 let updatedCookie = encodeURIComponent( name ) + "=" + encodeURIComponent( value ); 83 84 for ( let optionKey in props ) { 85 updatedCookie += "; " + optionKey; 86 let optionValue = props[ optionKey ]; 87 if ( optionValue !== true ) { 88 updatedCookie += "=" + optionValue; 89 } 90 } 91 92 document.cookie = updatedCookie; 93 } 94 95 /** 96 * Google AdSense 97 */ 98 99 try { 100 $( '.adsbygoogle' ).each( function() { 101 ( adsbygoogle = window.adsbygoogle || [] ).push( {} ); 102 } ); 103 } catch ( ex ) {} 104 /** 105 * Carousel 106 */ 107 108 function initCarouselLoop() { 109 var CarouselLoop = $( '.cs-block-carousel .slider-loop' ); 110 111 CarouselLoop.each( function() { 112 113 var container = this; 114 var owl = $( '.owl-carousel', this ); 115 116 $( owl ).imagesLoaded( function() { 117 118 owl.owlCarousel( { 119 dragEndSpeed: 250, 120 smartSpeed: 250, 121 autoHeight: true, 122 dots: true, 123 dotsContainer: $( '> .owl-dots', container ), 124 rtl: rtl, 125 responsive: { 126 0: { 127 items: 1, 128 margin: 0, 129 }, 130 760: { 131 items: 2, 132 margin: 40, 133 }, 134 1020: { 135 items: 3, 136 margin: 30, 137 }, 138 1120: { 139 items: 3, 140 margin: 40, 141 }, 142 1240: { 143 items: $( container ).data( 'columns' ), 144 margin: 30, 145 }, 146 1640: { 147 items: $( container ).data( 'columns' ), 148 margin: 40, 149 }, 150 }, 151 } ); 152 153 } ); 154 155 } ); 156 } 157 158 $( document ).ready( function() { 159 initCarouselLoop(); 160 $( document.body ).on( 'post-load', function() { 161 initCarouselLoop(); 162 } ); 163 164 csco.addAction( 'canvas.components.serverSideRender.onChange', 'posts-init-carousel', function( props ) { 165 if ( 'canvas/posts' === props.block ) { 166 initCarouselLoop(); 167 } 168 } ); 169 } ); 170 /* 171 * ---------------------------------------------------------------------------- 172 * Block Sliders 173 */ 174 175 var cscoBlockSliders = {}; 176 177 ( function() { 178 var $this; 179 180 cscoBlockSliders = { 181 182 windowWidth: 0, 183 184 /* 185 * Initialize 186 */ 187 init: function( e ) { 188 $this = cscoBlockSliders; 189 190 // Init events. 191 $this.events( e ); 192 }, 193 194 /* 195 * Events 196 */ 197 events: function( e ) { 198 // DOM Load 199 window.addEventListener( 'load', function( e ) { 200 $this.initSliderCenter(); 201 $this.initSliderBoxed(); 202 $this.initSliderWide(); 203 $this.initSliderMultiple(); 204 $this.initSliderLarge(); 205 } ); 206 207 // Triggers. 208 window.addEventListener( 'post-load', function( e ) { 209 $this.initSliderCenter(); 210 $this.initSliderBoxed(); 211 $this.initSliderWide(); 212 $this.initSliderMultiple(); 213 $this.initSliderLarge(); 214 } ); 215 216 // Gutenberg. 217 csco.addAction( 'canvas.components.serverSideRender.onChange', 'init-slider', function( props ) { 218 if ( 'canvas/posts' === props.block ) { 219 $this.initSliderCenter(); 220 $this.initSliderBoxed(); 221 $this.initSliderWide(); 222 $this.initSliderMultiple(); 223 $this.initSliderLarge(); 224 } 225 } ); 226 227 // Resize 228 window.addEventListener( 'resize', function( event ) { 229 if ( $( window ).width() === $this.windowWidth ) { 230 return; 231 } 232 233 $this.windowWidth = $( window ).width(); 234 235 $this.sliderLargeResized( event ); 236 } ); 237 }, 238 239 /* 240 * Initialized Hook 241 */ 242 onInitialized: function( event ) { 243 244 if ( $( 'body' ).hasClass( 'parallax-enabled' ) ) { 245 246 var $container = $( event.target ); 247 248 $( $container ).closest( '.cs-block-slider-featured' ).find( 'article' ).each( function() { 249 var $article = $( this ); 250 251 // Slide media. 252 $article.find( '.slide-parallax:not(.slide-video) .overlay-media' ).each( function() { 253 254 $( this ).jarallax( { 255 speed: 0.8, 256 elementInViewport: $container, 257 noIos: false, 258 } ); 259
260 $( this ).attr( 'data-parallax', 'image' ); 261 262 } ); 263 264 // Slide Video. 265 $article.find( '.slide-video' ).each( function() { 266 267 var videoSrc = $( this ).data( 'video' ), 268 videoStartTime = $( this ).data( 'start' ), 269 videoEndTime = $( this ).data( 'end' ), 270 speed = 0.8; 271 272 if ( !$( this ).hasClass( 'slide-parallax' ) ) { 273 speed = 1; 274 } 275 276 $( '.overlay-media', this ).jarallax( { 277 speed: speed, 278 videoSrc: videoSrc, 279 videoStartTime: videoStartTime, 280 videoEndTime: videoEndTime, 281 elementInViewport: $container, 282 videoPlayOnlyVisible: true, 283 noIos: false, 284 } ); 285 286 $( '.overlay-media', this ).attr( 'data-parallax', 'video' ); 287 } ); 288 } ); 289 } 290 291 // Recalc. 292 $( window ).trigger( 'slider-refresh' ); 293 }, 294 295 /* 296 * Resize Hook 297 */ 298 onResized: function( event ) { 299 300 if ( $( 'body' ).hasClass( 'parallax-enabled' ) ) { 301 // Reinit Parallax. 302 $( event.target ).find( '.slide-parallax .overlay-media' ).each( function() { 303 304 if ( $( this ).attr( 'data-parallax' ) ) { 305 $( this ).jarallax( 'clipContainer' ).jarallax( 'coverImage' ).jarallax( 'onScroll' ); 306 } 307 } ); 308 } 309 }, 310 311 /* 312 * Slider Center 313 */ 314 initSliderCenter: function() { 315 var sliderCenter = $( '.cs-block-slider-center' ); 316 317 sliderCenter.imagesLoaded( function( instance ) { 318 319 $( instance.elements ).each( function() { 320 321 function setArrowWidth( event ) { 322 var carousel = $( event.target ); 323 $( '.owl-arrows > button', carousel.parent() ).css( 'width', ( carousel.innerWidth() - $( '.owl-item.center', carousel ).innerWidth() - carousel.parent().data( 'padding' ) * 2 ) / 2 + 'px' ); 324 } 325 326 function sliderCenterInitialized( event ) { 327 setArrowWidth( event ); 328 329 $this.onInitialized( event ); 330 } 331 332 function sliderCenterResized( event ) { 333 setArrowWidth( event ); 334 335 $this.onResized( event ); 336 } 337 338 var container = $( this ); 339 340 var owl = $( '.owl-carousel', container ); 341 342 owl.owlCarousel( { 343 autoplayHoverPause: true, 344 dragEndSpeed: 500, 345 smartSpeed: 500, 346 dotsContainer: $( '.owl-dots', container ), 347 navContainer: $( '.owl-arrows', container ), 348 navText: [ '', '' ], 349 autoHeight: true, 350 rtl: rtl, 351 responsive: { 352 0: { 353 items: 1, 354 loop: false, 355 margin: 0, 356 dots: true, 357 nav: false, 358 }, 359 1020: { 360 autoplay: $( this ).data( 'autoplay' ), 361 autoplayTimeout: $( this ).data( 'timeout' ), 362 loop: false, 363 margin: 0, 364 items: 1, 365 dots: true, 366 nav: false, 367 }, 368 1240: { 369 autoplay: $( this ).data( 'autoplay' ), 370 autoplayTimeout: $( this ).data( 'timeout' ), 371 margin: $( this ).data( 'padding' ), 372 center: true, 373 items: 3, 374 loop: true, 375 autoWidth: true, 376 dots: false, 377 nav: true, 378 } 379 }, 380 onInitialized: sliderCenterInitialized, 381 onResized: sliderCenterResized, 382 onRefresh: sliderCenterResized, 383 onChanged: sliderCenterResized, 384 } ); 385 } ); 386 } ); 387 }, 388 389 /* 390 * Slider Boxed 391 */ 392 initSliderBoxed: function() { 393 var sliderBoxed = $( '.cs-block-slider-boxed' ); 394 395 sliderBoxed.imagesLoaded( function( instance ) { 396 397 $( instance.elements ).each( function() { 398 399 var container = this; 400 401 var owl = $( '.owl-carousel', this ); 402 403 owl.owlCarousel( { 404 autoplayHoverPause: true, 405 dragEndSpeed: 500, 406 smartSpeed: 500, 407 items: 1, 408 margin: 0, 409 autoHeight: true, 410 navText: [ 411 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.previous + '</span></div>', 412 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.next + '</span></div>' 413 ], 414 dots: true, 415 dotsContainer: $( '.owl-dots', container ), 416 navContainer: $( '.owl-arrows', container ), 417 rtl: rtl, 418 responsive: { 419 0: { 420 nav: false, 421 }, 422 1020: { 423 autoplay: $( this ).data( 'autoplay' ), 424 autoplayTimeout: $( this ).data( 'timeout' ), 425 nav: true, 426 loop: true 427 } 428 }, 429 onInitialized: $this.onInitialized, 430 onResized: $this.onResized, 431 onRefresh: $this.onResized, 432 onChanged: $this.onResized, 433 } ); 434 435 } ); 436 } ); 437 }, 438 439 /* 440 * Slider Wide 441 */ 442 initSliderWide: function() { 443 var sliderWide = $( '.cs-block-slider-wide' ); 444 445 sliderWide.imagesLoaded( function( instance ) { 446 447 $( instance.elements ).each( function() { 448 449 var container = this; 450 var owl = $( '.owl-carousel', this ); 451 452 owl.owlCarousel( { 453 autoplayHoverPause: true, 454 dragEndSpeed: 500, 455 smartSpeed: 500, 456 items: 1, 457 margin: 0, 458 autoHeight: true, 459 navText: [ 460 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.previous + '</span></div>', 461 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.next + '</span></div>' 462 ], 463 dots: true, 464 dotsContainer: $( '.owl-dots', container ), 465 navContainer: $( '.owl-arrows', container ), 466 rtl: rtl, 467 responsive: { 468 0: { 469 nav: false, 470 }, 471 1020: { 472 autoplay: $( this ).data( 'autoplay' ), 473 autoplayTimeout: $( this ).data( 'timeout' ), 474 nav: true, 475 loop: true 476 } 477 }, 478 onInitialized: $this.onInitialized, 479 onResized: $this.onResized, 480 onRefresh: $this.onResized, 481 onChanged: $this.onResized, 482 } ); 483 484 } ); 485 } ); 486 }, 487 488 /* 489 * Slider Multiple 490 */ 491 initSliderMultiple: function() { 492 var sliderMultiple = $( '.cs-block-slider-multiple' ); 493 494 sliderMultiple.imagesLoaded( function( instance ) { 495 496 $( instance.elements ).each( function() { 497 498 var container = this; 499 500 var owl = $( '.owl-carousel', this ); 501 502 owl.owlCarousel( { 503 autoplayHoverPause: true, 504 dragEndSpeed: 500, 505 smartSpeed: 500, 506 navContainer: $( '.owl-arrows', container ), 507 navText: [ '', '' ], 508 dots: true, 509 dotsContainer: $( '.owl-dots', container ), 510 autoHeight: true, 511 rtl: rtl, 512 responsive: { 513 0: { 514 nav: false, 515 loop: false, 516 margin: 0, 517 stagePadding: 0, 518 items: 1, 519 }, 520 1020: { 521 autoplay: $( this ).data( 'autoplay' ), 522 autoplayTimeout: $( this ).data( 'timeout' ), 523 }, 524 1120: { 525 autoplay: $( this ).data( 'autoplay' ), 526 autoplayTimeout: $( this ).data( 'timeout' ), 527 margin: $( this ).data( 'padding' ), 528 items: $( this ).data( 'slides-visible' ), 529 nav: true, 530 loop: true, 531 stagePadding: 90, 532 } 533 }, 534 onInitialized: $this.onInitialized, 535 onResized: $this.onResized, 536 onRefresh: $this.onResized, 537 onChanged: $this.onResized, 538 } ); 539 540 } ); 541 } ); 542 }, 543 544 /* 545 * Slider Large 546 */ 547 initSliderLarge: function() { 548 var sliderLarge = $( '.cs-block-slider-large' ); 549 550 sliderLarge.imagesLoaded( function( instance ) { 551 552 $( instance.elements ).each( function() { 553 554 var container = this, 555 owl = $( '.owl-carousel', this ), 556 autoHeight = false;
557 558 if ( $( document.body ).hasClass( 'style-type-classic' ) ) { 559 autoHeight = true; 560 } 561 562 owl.owlCarousel( { 563 autoplayHoverPause: true, 564 dragEndSpeed: 500, 565 smartSpeed: 500, 566 autoHeight: autoHeight, 567 items: 1, 568 margin: 0, 569 navText: [ 570 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.previous + '</span></div>', 571 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.next + '</span></div>' 572 ], 573 dots: true, 574 dotsContainer: $( '.owl-dots', container ), 575 navContainer: $( '.owl-arrows', container ), 576 rtl: rtl, 577 responsive: { 578 0: { 579 nav: false, 580 }, 581 1020: { 582 autoplay: $( this ).data( 'autoplay' ), 583 autoplayTimeout: $( this ).data( 'timeout' ), 584 nav: true, 585 loop: true, 586 } 587 }, 588 onInitialized: $this.sliderLargeInitialized, 589 onTranslated: $this.sliderLargePosition, 590 onResized: $this.sliderLargeResized, 591 onRefresh: $this.sliderLargeResized, 592 onChanged: $this.sliderLargeResized, 593 } ); 594 } ); 595 } ); 596 }, 597 598 /* 599 * Slider Large Change Position 600 */ 601 sliderLargePosition: function() { 602 603 var siteContentTop = 0; 604 605 // Redefine variables. 606 var sectionLarge = $( '.has-slider-large .cnvs-block-section-layout-align-full:first-child' ); 607 var sliderLarge = $( sectionLarge ).find( '.cnvs-block-posts-layout-slider-large:first-child .cs-block-slider-large' ); 608 var sliderLargeOuter = $( '.overlay-outer', sliderLarge ); 609 610 if ( $( '.site-content' ).length > 0 ) { 611 siteContentTop = $( '.site-content' ).css( 'margin-top' ).replace( 'px', '' ); 612 } 613 614 // Define heights. 615 var owlSlide = $( '.post-outer', sliderLarge ),
616 contentHeight = $( '.overlay-inner', owlSlide ).innerHeight(), 617 offsetHeight = ( parseInt( adminBarHeight ) || 0 ) + ( parseInt( siteContentTop ) || 0 ) + ( parseInt( headerHeight ) || 0 ), 618 availableHeight = windowHeight - offsetHeight, 619 viewPortHeight = '100vh'; 620 621 // Offset page header. 622 sliderLarge.css( 'margin-top', -offsetHeight + 'px' ); 623 sliderLargeOuter.css( 'padding-top', offsetHeight + 'px' ); 624 625 // Set the slider height. 626 if ( availableHeight >= contentHeight ) { 627 sliderLargeOuter.css( 'height', viewPortHeight ); 628 } else { 629 sliderLargeOuter.css( 'height', contentHeight + offsetHeight + 'px' ); 630 } 631 632 // Return if overlay variant is set to bottom. 633 if ( $( document.body ).hasClass( 'style-align-left' ) ) { 634 return; 635 } 636 637 // Add extra padding, if possible. 638 if ( availableHeight - offsetHeight >= contentHeight ) { 639 sliderLargeOuter.css( 'padding-bottom', offsetHeight + 'px' ); 640 } else { 641 sliderLargeOuter.css( 'padding-bottom', 0 ); 642 } 643 }, 644 645 /* 646 * Slider Large Initialized 647 */ 648 sliderLargeInitialized: function( event ) { 649 $this.sliderLargePosition(); 650 651 $this.onInitialized( event ); 652 }, 653 654 /* 655 * Slider Large Resized 656 */ 657 sliderLargeResized: function( event ) { 658 $this.sliderLargePosition(); 659 660 $this.onResized( event ); 661 } 662 }; 663 664 } )(); 665 666 // Initialize. 667 cscoBlockSliders.init(); 668 669 ( function() { 670 var ticking = false; 671 672 var update = function() { 673 674 // Sidebar. 675 // -----------------------------------. 676 $( '.content-area .site-main' ).each( function() { 677 678 var content = $( this ).find( '.entry-content' ); 679 var sidebar = $( this ).find( '.post-sidebar .pk-share-buttons-wrap' ); 680 681 // Vars offset. 682 var offsetTop = 20; 683 var offsetBottom = -20; 684 685 // Search elements. 686 var elements = []; 687 688 elements.push( '> .alignfull' ); 689 elements.push( '> .alignwide' ); 690 691 var layouts = $( content ).find( elements.join( ',' ) ); 692 693 if ( 0 === sidebar.length ) { 694 return; 695 } 696 if ( 0 === layouts.length ) { 697 return; 698 } 699 700 var disabled = false; 701 702 // Get sidebar values. 703 var sidebarTop = $( sidebar ).offset().top; 704 var sidebarHeight = $( sidebar ).outerHeight( true ); 705 706 for ( let i = 0; i < $( layouts ).length; ++i ) { 707 if ( 'none' === $( layouts[ i ] ).css( 'transform' ) ) { 708 continue; 709 } 710 711 // Get layout values. 712 let layoutTop = $( layouts[ i ] ).offset().top; 713 let layoutHeight = $( layouts[ i ] ).outerHeight( true ); 714 715 // Calc points. 716 let pointTop = layoutTop - offsetTop; 717 let pointBottom = layoutTop + layoutHeight + offsetBottom; 718 719 // Detect sidebar location. 720 if ( sidebarTop + sidebarHeight >= pointTop && sidebarTop <= pointBottom ) { 721 disabled = true; 722 } 723 } 724 725 726 if ( disabled ) { 727 $( sidebar ).css( 'opacity', '0' ); 728 } else { 729 $( sidebar ).css( 'opacity', '1' ); 730 } 731 } ); 732 733 // Pagination. 734 // -----------------------------------. 735 $( '.content-area .site-main' ).each( function() { 736 737 var content = $( this ).find( '.entry-content' ); 738 var pagination = $( this ).find( '.posts-pagination article:first-child' ); 739 740 // Vars offset. 741 var offsetTop = -20; 742 var offsetBottom = -140; 743 744 // Search elements. 745 var elements = []; 746 747 elements.push( '> .alignfull' ); 748 749 var layouts = $( content ).find( elements.join( ',' ) ); 750 751 if ( 0 === pagination.length ) { 752 return; 753 } 754 if ( 0 === layouts.length ) { 755 return; 756 } 757 758 var disabled = false; 759 760 // Get pagination values. 761 var paginationTop = $( pagination ).find( '> a' ).offset().top; 762 var paginationHeight = $( pagination ).find( '> a' ).outerWidth( true ); 763 764 for ( let i = 0; i < $( layouts ).length; ++i ) { 765 if ( 'none' === $( layouts[ i ] ).css( 'transform' ) ) { 766 continue; 767 } 768 769 // Get layout values. 770 let layoutTop = $( layouts[ i ] ).offset().top; 771 let layoutHeight = $( layouts[ i ] ).outerHeight( true ); 772 773 // Calc points. 774 let pointTop = layoutTop - offsetTop; 775 let pointBottom = layoutTop + layoutHeight + offsetBottom; 776 777 // Detect pagination location. 778 if ( paginationTop + paginationHeight >= pointTop && paginationTop <= pointBottom ) { 779 disabled = true; 780 } 781 } 782 783 if ( disabled ) { 784 $( pagination ).parent().css( 'opacity', '0' ); 785 $( pagination ).parent().css( 'visibility', 'hidden' ); 786 } else { 787 $( pagination ).parent().css( 'opacity', '1' ); 788 $( pagination ).parent().css( 'visibility', 'visible' ); 789 } 790 } ); 791 792 // Ticking. 793 ticking = false;
794 }; 795 796 var requestTick = function() { 797 if ( !ticking ) { 798 window.requestAnimationFrame( update ); 799 ticking = true; 800 } 801 }; 802 803 var onProcess = function() { 804 requestTick(); 805 }; 806 807 $( window ).on( 'scroll', onProcess ); 808 $( window ).on( 'resize', onProcess ); 809 $( window ).on( 'image-load', onProcess ); 810 $( window ).on( 'post-load', onProcess ); 811 $( window ).on( 'slider-refresh', onProcess ); 812 813 } )(); 814 815 // Init slider for powerkit featured posts. 816 817 function initFeaturedSlider() { 818 // Widget Post Featured 819 $( '.pk-widget-posts-template-slider, .cnvs-block-posts-sidebar-slider .cnvs-block-posts-sidebar-inner' ).each( function() { 820 if ( $( this ).hasClass( 'init-slider' ) ) { 821 return; 822 } 823 824 $( this ).addClass( 'init-slider' ); 825 826 // Wrap inner of slider-container. 827 $( this ).wrapInner( '<div class="slider-container slider-flip"></div>' ); 828 829 // Add owl-carousel class. 830 $( this ).find( '.slider-flip > ul' ).addClass( 'owl-carousel' ); 831 832 // Add owl dots. 833 $( this ).find( '.slider-flip' ).append( '<div class="owl-dots"></div>' ); 834 } ); 835 } 836 837 $( document ).ready( function() { 838 initFeaturedSlider(); 839 initSliderFlip(); 840 841 $( document.body ).on( 'post-load', function() { 842 initFeaturedSlider(); 843 initSliderFlip(); 844 } ); 845 846 csco.addAction( 'canvas.components.serverSideRender.onChange', 'initFeaturedSlider', function( props ) { 847 initFeaturedSlider(); 848 initSliderFlip(); 849 } ); 850 851 } ); 852 853 /** 854 * AJAX Load More. 855 * 856 * Contains functions for AJAX Load More. 857 */ 858 859 $( function() { 860 861 if ( 'undefined' === typeof window.load_more_query ) { 862 window.load_more_query = []; 863 } 864 865 /** 866 * Get next posts 867 */ 868 function csco_ajax_get_posts( object ) { 869 var container = $( object ).closest( '.post-archive' ); 870 871 var settings = $( object ).data( 'settings' ); 872 var page = $( object ).data( 'page' ); 873 874 $( object ).data( 'loading', true ); 875 876 // Set button text to Load More. 877 $( object ).text( settings.translation.loading ); 878 879 var data = { 880 action: 'csco_ajax_load_more', 881 page: page, 882 posts_per_page: settings.posts_per_page, 883 query_data: settings.query_data, 884 attributes: settings.attributes, 885 options: settings.options, 886 _ajax_nonce: settings.nonce, 887 }; 888 889 if ( settings.hasOwnProperty( 'current_lang' ) && settings.current_lang ) { 890 data.current_lang = settings.current_lang; 891 } 892 if ( settings.hasOwnProperty( 'current_locale' ) && settings.current_locale ) { 893 data.current_locale = settings.current_locale; 894 } 895 896 // Request Url. 897 var csco_pagination_url; 898 899 if ( 'ajax_restapi' === settings.type ) { 900 csco_pagination_url = settings.rest_url; 901 } else { 902 csco_pagination_url = settings.url; 903 } 904 905 // Send Request. 906 $.post( csco_pagination_url, data, function( res ) { 907 if ( res.success ) { 908 909 // Get the posts. 910 var data = $( res.data.content ); 911 912 // Check if there're any posts. 913 if ( data.length ) { 914 915 data.imagesLoaded( function() { 916 917 // Append new posts to list, standard and grid archives. 918 $( container ).find( '.archive-main.archive-list, .archive-main.archive-standard, .archive-main.archive-grid' ).append( data ); 919 920 // Append new posts to masonry layout. 921 $( container ).find( '.archive-main.archive-masonry' ).colcade( 'append', data ); 922 923 // WP Post Load trigger. 924 $( document.body ).trigger( 'post-load' ); 925 926 // Reinit Facebook widgets. 927 if ( $( '#fb-root' ).length && 'object' === typeof FB ) { 928 FB.XFBML.parse(); 929 } 930 931 // Set button text to Load More. 932 $( object ).text( settings.translation.load_more ); 933 934 // Increment a page. 935 page = page + 1; 936 937 $( object ).data( 'page', page ); 938 939 // Set the loading state. 940 $( object ).data( 'loading', false ); 941 } ); 942 943 } 944 945 // Remove Button on Posts End. 946 if ( res.data.posts_end || !data.length ) { 947 948 // Remove Load More button. 949 $( object ).remove(); 950 } 951 952 } else { 953 // console.log(res); 954 } 955 } ).fail( function( xhr, textStatus, e ) { 956 // console.log(xhr.responseText); 957 } ); 958 } 959 960 /** 961 * Initialization Load More 962 */ 963 function csco_load_more_init( infinite ) { 964 $( '.post-archive' ).each( function() { 965 966 if ( $( this ).data( 'init' ) ) { 967 return; 968 } 969 970 var csco_ajax_settings; 971 972 if ( typeof csco_ajax_pagination !== 'undefined' ) { 973 csco_ajax_settings = csco_ajax_pagination; 974 } 975 976 var archive_data = $( this ).data( 'archive-data' ); 977 978 if ( archive_data ) { 979 csco_ajax_settings = JSON.parse( window.atob( archive_data ) ); 980 } 981 982 if ( csco_ajax_settings ) { 983 984 if ( !infinite && csco_ajax_settings.infinite_load ) { 985 return; 986 } 987 988 // Add load more button. 989 $( this ).find( '.archive-pagination' ).append( '<span class="load-more button btn-lg button-primary">' + csco_ajax_settings.translation.load_more + '</span>' ); 990 991 // Set load more settings. 992 $( this ).find( '.load-more' ).data( 'settings', csco_ajax_settings ); 993 $( this ).find( '.load-more' ).data( 'page', 2 ); 994 $( this ).find( '.load-more' ).data( 'loading', false ); 995 $( this ).find( '.load-more' ).data( 'scrollHandling', { 996 allow: $.parseJSON( csco_ajax_settings.infinite_load ), 997 delay: 400 998 } ); 999 } 1000 1001 $( this ).data( 'init', true ); 1002 } ); 1003 } 1004 1005 csco_load_more_init( true ); 1006 1007 csco.addAction( 'canvas.components.serverSideRender.onChange', 'posts-init-loadmore', function( props ) { 1008 if ( 'canvas/posts' === props.block ) { 1009 csco_load_more_init( false ); 1010 } 1011 } ); 1012 1013 // On Scroll Event. 1014 $( window ).scroll( function() { 1015 1016 $( '.post-archive .load-more' ).each( function() { 1017 1018 var loading = $( this ).data( 'loading' ); 1019 var scrollHandling = $( this ).data( 'scrollHandling' ); 1020 1021 if ( $( this ).length && !loading && scrollHandling.allow ) { 1022 scrollHandling.allow = false;
1023 1024 $( this ).data( 'scrollHandling', scrollHandling ); 1025 1026 var object = this; 1027 1028 setTimeout( function() { 1029 var scrollHandling = $( object ).data( 'scrollHandling' ); 1030 1031 scrollHandling.allow = true; 1032 1033 $( object ).data( 'scrollHandling', scrollHandling ); 1034 }, scrollHandling.delay ); 1035 1036 var offset = $( this ).offset().top - $( window ).scrollTop(); 1037 if ( 4000 > offset ) { 1038 csco_ajax_get_posts( this ); 1039 } 1040 } 1041 } ); 1042 } ); 1043 1044 // On Click Event. 1045 $( 'body' ).on( 'click', '.load-more', function() { 1046 var loading = $( this ).data( 'loading' ); 1047 1048 if ( !loading ) { 1049 csco_ajax_get_posts( this ); 1050 } 1051 } ); 1052 } ); 1053 1054 /** 1055 * AJAX Auto Load Next Post. 1056 * 1057 * Contains functions for AJAX Auto Load Next Post. 1058 */ 1059 1060 ( function() { 1061 /** 1062 * Check if Load Nextpost is defined by the wp_localize_script 1063 */ 1064 if ( typeof csco_ajax_nextpost !== 'undefined' ) { 1065 1066 var objNextparent = $( '.site-inner > .site-content' ), 1067 objNextsect = '.cs-nextpost-section', 1068 objNextpost = null, 1069 currentNTitle = document.title, 1070 currentNLink = window.location.href, 1071 loadingNextpost = false, 1072 scrollNextpost = { 1073 allow: true, 1074 reallow: function() { 1075 scrollNextpost.allow = true; 1076 }, 1077 delay: 400 //(milliseconds) adjust to the highest acceptable value 1078 }; 1079 1080 // Init. 1081 if ( csco_ajax_nextpost.next_post ) { 1082 $( objNextparent ).after( '<div class="cs-nextpost-inner"></div>' ); 1083 1084 objNextpost = $( '.cs-nextpost-inner' ); 1085 } 1086 } 1087 1088 /** 1089 * Get next post 1090 */ 1091 function csco_ajax_get_nextpost() { 1092 loadingNextpost = true; 1093 1094 // Set class loading. 1095 var data = { 1096 action: 'csco_ajax_load_nextpost', 1097 not_in: csco_ajax_nextpost.not_in, 1098 current_user: csco_ajax_nextpost.current_user, 1099 nonce: csco_ajax_nextpost.nonce, 1100 next_post: csco_ajax_nextpost.next_post, 1101 }; 1102 1103 if ( csco_ajax_nextpost.hasOwnProperty( 'current_lang' ) && csco_ajax_nextpost.current_lang ) { 1104 data.current_lang = csco_ajax_nextpost.current_lang; 1105 } 1106 if ( csco_ajax_nextpost.hasOwnProperty( 'current_locale' ) && csco_ajax_nextpost.current_locale ) { 1107 data.current_locale = csco_ajax_nextpost.current_locale; 1108 } 1109 1110 // Request Url. 1111 var csco_ajax_nextpost_url; 1112 if ( 'ajax_restapi' === csco_ajax_nextpost.type ) { 1113 csco_ajax_nextpost_url = csco_ajax_nextpost.rest_url; 1114 } else { 1115 csco_ajax_nextpost_url = csco_ajax_nextpost.url; 1116 } 1117 1118 // Send Request. 1119 $.post( csco_ajax_nextpost_url, data, function( res ) { 1120 1121 csco_ajax_nextpost.next_post = false; 1122 1123 if ( res.success ) { 1124 1125 // Get the posts. 1126 var data = $( res.data.content ); 1127 1128 // Check if there're any posts. 1129 if ( data.length ) { 1130 // Set the loading state. 1131 loadingNextpost = false; 1132 1133 // Set not_in. 1134 csco_ajax_nextpost.not_in = res.data.not_in; 1135 1136 // Set next data. 1137 csco_ajax_nextpost.next_post = res.data.next_post; 1138 1139 // Remove loader. 1140 $( objNextpost ).siblings( '.cs-nextpost-loading' ).remove(); 1141 1142 // Append new post. 1143 $( objNextpost ).append( data ); 1144 1145 // Reinit facebook. 1146 if ( $( '#fb-root' ).length && 'object' === typeof FB ) { 1147 FB.XFBML.parse(); 1148 } 1149 1150 $( document.body ).trigger( 'post-load' ); 1151 } 1152 } else { 1153 // console.log(res); 1154 } 1155 } ).fail( function( xhr, textStatus, e ) { 1156 // console.log(xhr.responseText); 1157 } ); 1158 } 1159 1160 /** 1161 * Check if Load Nextpost is defined by the wp_localize_script 1162 */ 1163 if ( typeof csco_ajax_nextpost !== 'undefined' ) { 1164 1165 // On Scroll Event. 1166 $( window ).scroll( function() { 1167 var scrollTop = $( window ).scrollTop(); 1168 1169 // Init nextpost. 1170 if ( csco_ajax_nextpost.next_post ) { 1171 1172 if ( objNextpost.length && !loadingNextpost && scrollNextpost.allow ) { 1173 scrollNextpost.allow = false; 1174 setTimeout( scrollNextpost.reallow, scrollNextpost.delay ); 1175 // Calc current offset. 1176 let offset = objNextpost.offset().top + objNextpost.innerHeight() - scrollTop; 1177 // Load nextpost. 1178 if ( 4000 > offset ) { 1179 $( objNextpost ).after( '<div class="cs-nextpost-loading"></div>' ); 1180 1181 csco_ajax_get_nextpost(); 1182 } 1183 } 1184 } 1185 1186 // Reset browser data link. 1187 let objFirst = $( objNextsect ).first(); 1188 1189 if ( objFirst.length ) { 1190 let firstTop = $( objFirst ).offset().top; 1191 // If there has been a change. 1192 if ( scrollTop < firstTop && window.location.href !== currentNLink ) { 1193 document.title = currentNTitle; 1194 window.history.pushState( null, currentNTitle, currentNLink ); 1195 } 1196 } 1197 1198 // Set browser data link. 1199 $( objNextsect ).each( function( index, elem ) { 1200 1201 let elemTop = $( elem ).offset().top; 1202 let elemHeight = $( elem ).innerHeight(); 1203 1204 if ( scrollTop > elemTop && scrollTop < elemTop + elemHeight ) { 1205 // If there has been a change. 1206 if ( window.location.href !== $( elem ).data( 'url' ) ) { 1207 // New title. 1208 document.title = $( elem ).data( 'title' ); 1209 // New link. 1210 window.history.pushState( null, $( elem ).data( 'title' ), $( elem ).data( 'url' ) ); 1211 // Google Analytics. 1212 if ( typeof gtag === 'function' && typeof window.gaData === 'object' ) { 1213 1214 var trackingId = Object.keys( window.gaData )[ 0 ]; 1215 if ( trackingId ) { 1216 gtag( 'config', trackingId, { 1217 'page_title': $( elem ).data( 'title' ), 1218 'page_location': $( elem ).data( 'url' ) 1219 } ); 1220 1221 gtag( 'event', 'page_view', { 'send_to': trackingId } ); 1222 } 1223 } 1224 } 1225 } 1226 } ); 1227 } ); 1228 } 1229 1230 } )(); 1231 1232 /** 1233 * Masonry Archive 1234 */ 1235 1236 function initMasonry() { 1237 1238 var masonryArchive = $( '.archive-masonry' ), 1239 masonryArchiveOptions = { 1240 columns: '.archive-col', 1241 items: '.post-masonry, .post-featured, .widget' 1242 }; 1243 1244 $( masonryArchive ).imagesLoaded( function() { 1245 $( masonryArchive ).colcade( masonryArchiveOptions ); 1246 } ); 1247 1248 /**
1249 * Masonry Sidebar 1250 */ 1251 1252 var masonrySidebar = $( '.sidebar-area' ), 1253 masonrySidebarOptions = { 1254 columns: '.sidebar', 1255 items: ' .widget' 1256 }; 1257 1258 $( masonrySidebar ).imagesLoaded( function() { 1259 $( masonrySidebar ).colcade( masonrySidebarOptions ); 1260 } ); 1261 1262 } 1263 1264 $( document ).ready( function() { 1265 initMasonry(); 1266 1267 csco.addAction( 'canvas.components.serverSideRender.onChange', 'posts-init-masonry', function( props ) { 1268 if ( 'canvas/posts' === props.block ) { 1269 initMasonry(); 1270 } 1271 } ); 1272 } ); 1273 1274 /* 1275 * Load Mega Menu Posts 1276 */ 1277 function cscoLoadMenuPosts( menuItem ) { 1278 var dataTerm = menuItem.children( 'a' ).data( 'term' ), 1279 dataPosts = menuItem.children( 'a' ).data( 'posts' ), 1280 dataNumberposts = menuItem.children( 'a' ).data( 'numberposts' ), 1281 menuContainer, 1282 postsContainer; 1283 1284 // Containers. 1285 if ( menuItem.hasClass( 'csco-mega-menu-term' ) ) { 1286 menuContainer = menuItem; 1287 postsContainer = menuContainer.find( '.cs-mm-posts' ); 1288 } 1289 1290 if ( menuItem.hasClass( 'csco-mega-menu-posts' ) ) { 1291 menuContainer = menuItem; 1292 postsContainer = menuContainer.find( '.cs-mm-posts' ); 1293 } 1294 1295 if ( menuItem.hasClass( 'csco-mega-menu-child-term' ) ) { 1296 menuContainer = menuItem.closest( '.sub-menu' ); 1297 postsContainer = menuContainer.find( '.cs-mm-posts[data-term="' + dataTerm + '"]' ); 1298 } 1299 1300 // Check Menu Container. 1301 if ( !menuContainer || typeof menuContainer === 'undefined' ) { 1302 return false; 1303 } 1304 1305 // Check Container. 1306 if ( !postsContainer || typeof postsContainer === 'undefined' ) { 1307 return false; 1308 } 1309 1310 // Set Active. 1311 menuContainer.find( '.menu-item, .cs-mm-posts' ).removeClass( 'active-item' ); 1312 1313 menuItem.addClass( 'active-item' ); 1314 1315 if ( postsContainer ) { 1316 postsContainer.addClass( 'active-item' ); 1317 } 1318 1319 // Check Loading. 1320 if ( menuItem.hasClass( 'cs-mm-loading' ) || menuItem.hasClass( 'loaded' ) ) { 1321 return false; 1322 } 1323 1324 // Create Data. 1325 var data = { 1326 'term': dataTerm, 1327 'posts': dataPosts, 1328 'per_page': dataNumberposts 1329 }; 1330 1331 if ( csco_mega_menu.hasOwnProperty( 'current_lang' ) && csco_mega_menu.current_lang ) { 1332 data.current_lang = csco_mega_menu.current_lang; 1333 } 1334 if ( csco_mega_menu.hasOwnProperty( 'current_locale' ) && csco_mega_menu.current_locale ) { 1335 data.current_locale = csco_mega_menu.current_locale; 1336 } 1337 1338 // Get Results. 1339 $.ajax( { 1340 url: csco_mega_menu.rest_url, 1341 type: 'GET', 1342 data: data, 1343 global: false, 1344 async: true, 1345 beforeSend: function() { 1346 menuItem.addClass( 'cs-mm-loading' ); 1347 postsContainer.addClass( 'cs-mm-loading' ); 1348 }, 1349 success: function( res ) { 1350 if ( res.status && 'success' === res.status ) { 1351 1352 // Set the loaded state. 1353 menuItem.addClass( 'loaded' ); 1354 postsContainer.addClass( 'loaded' ); 1355 1356 // Check if there're any posts. 1357 if ( res.content && res.content.length ) { 1358 1359 $( res.content ).imagesLoaded( function() { 1360 1361 // Append Data. 1362 postsContainer.html( res.content ); 1363 } ); 1364 } 1365 } 1366 }, 1367 complete: function() { 1368 // Set the loading state. 1369 menuItem.removeClass( 'cs-mm-loading' ); 1370 postsContainer.removeClass( 'cs-mm-loading' ); 1371 } 1372 } ); 1373 } 1374 1375 /* 1376 * Get First Tab 1377 */ 1378 function cscoGetFirstTab( container ) { 1379 1380 var firstTab = false; 1381 1382 container.find( '.csco-mega-menu-child' ).each( function( index, el ) { 1383 if ( $( el ).hasClass( 'csco-mega-menu-child' ) ) { 1384 firstTab = $( el ); 1385 return false; 1386 } 1387 } ); 1388 1389 return firstTab; 1390 } 1391 1392 /* 1393 * Menu on document ready 1394 */ 1395 $( document ).ready( function() { 1396 1397 /* 1398 * Get Menu Posts on Hover 1399 */ 1400 $( '.navbar-nav .menu-item.csco-mega-menu-posts' ).on( 'mouseenter', function() { 1401 cscoLoadMenuPosts( $( this ) ); 1402 } ); 1403 $( '.navbar-nav .menu-item.csco-mega-menu-term' ).on( 'mouseenter', function() { 1404 cscoLoadMenuPosts( $( this ) ); 1405 } ); 1406 $( '.navbar-nav .menu-item.csco-mega-menu-child' ).on( 'mouseenter', function() { 1407 cscoLoadMenuPosts( $( this ) ); 1408 } ); 1409 1410 /* 1411 * Load First Tab on Mega Menu Hover 1412 */ 1413 $( '.navbar-nav .menu-item.csco-mega-menu-terms' ).on( 'mouseenter', function() { 1414 var tab = cscoGetFirstTab( $( this ) ); 1415 1416 if ( tab ) { 1417 cscoLoadMenuPosts( tab ); 1418 } 1419 } ); 1420 } ); 1421 1422 /* 1423 * Load First Tab on Navbar Ready. 1424 */ 1425 $( document, '.navbar-nav' ).ready( function() { 1426 var tab = false;
1427 1428 // Autoload First Tab. 1429 $( '.navbar-nav .menu-item.csco-mega-menu-terms' ).each( function( index, el ) { 1430 tab = cscoGetFirstTab( $( this ) ); 1431 1432 if ( tab ) { 1433 cscoLoadMenuPosts( tab ); 1434 } 1435 } ); 1436 1437 // Autoload Posts. 1438 $( '.navbar-nav .menu-item.csco-mega-menu-posts' ).each( function( index, el ) { 1439 cscoLoadMenuPosts( $( this ) ); 1440 } ); 1441 1442 // Autoload Term. 1443 $( '.navbar-nav .menu-item.csco-mega-menu-term' ).each( function( index, el ) { 1444 cscoLoadMenuPosts( $( this ) ); 1445 } ); 1446 } ); 1447 1448 /** 1449 * Responsive Navigation Menu 1450 */ 1451 1452 $.fn.responsiveNav = function() { 1453 this.removeClass( 'menu-item-expanded' ); 1454 if ( this.prev().hasClass( 'submenu-visible' ) ) { 1455 this.prev().removeClass( 'submenu-visible' ).slideUp( 350 ); 1456 this.parent().removeClass( 'menu-item-expanded' ); 1457 } else { 1458 this.parent().parent().find( '.menu-item .sub-menu' ).removeClass( 'submenu-visible' ).slideUp( 350 ); 1459 this.parent().parent().find( '.menu-item-expanded' ).removeClass( 'menu-item-expanded' ); 1460 this.prev().toggleClass( 'submenu-visible' ).hide().slideToggle( 350 ); 1461 this.parent().toggleClass( 'menu-item-expanded' ); 1462 } 1463 }; 1464 1465 function initNavMenu() { 1466 $( '.widget_nav_menu .menu-item-has-children' ).each( function( e ) { 1467 1468 if ( $( this ).data( 'init' ) ) { 1469 return; 1470 } 1471 1472 $( this ).data( 'init', true ); 1473 1474 // Add a caret. 1475 $( this ).append( '<span></span>' ); 1476 1477 // Fire responsiveNav() when clicking a caret. 1478 $( '> span', this ).on( 'click', function( e ) { 1479 e.preventDefault(); 1480 $( this ).responsiveNav(); 1481 } ); 1482 1483 // Fire responsiveNav() when clicking a parent item with # href attribute. 1484 if ( '#' === $( '> a', this ).attr( 'href' ) ) { 1485 $( '> a', this ).on( 'click', function( e ) { 1486 e.preventDefault(); 1487 $( this ).next().next().responsiveNav(); 1488 } ); 1489 } 1490 1491 } ); 1492 } 1493 1494 // Make widget nav responsive. 1495 $( document ).ready( function() { 1496 initNavMenu(); 1497 1498 $( 'body' ).on( 'post-load', function() { 1499 initNavMenu(); 1500 } ); 1501 1502 csco.addAction( 'canvas.components.serverSideRender.onChange', 'initNavMenu', function( props ) { 1503 initNavMenu(); 1504 } ); 1505 } ); 1506 1507 /* 1508 * ---------------------------------------------------------------------------- 1509 * Navigation 1510 */ 1511 1512 var cscoNavigation = {}; 1513 1514 ( function() { 1515 var $this; 1516 1517 cscoNavigation = { 1518 sScrollAllow: false, 1519 sInFirst: true, 1520 sInterval: 0, 1521 sPrevious: 0, 1522 sDirection: 0, 1523 1524 loadStickyOffset: 0, 1525 loadAdminBar: false, 1526 1527 Sticky: $( 'body' ).hasClass( 'navbar-sticky-enabled' ), 1528 StickyUp: $( 'body' ).hasClass( 'navbar-smart-enabled' ), 1529 StickyNav: $( '.site-header .navbar-primary' ), 1530 StickyHeader: $( '.site-header' ), 1531 StickyOffsetType: 'auto', 1532 StickyOffset: 0, 1533 StickyOffsetFull: 0, 1534 1535 /* 1536 * Initialize 1537 */ 1538 init: function( e ) { 1539 $this = cscoNavigation; 1540 1541 // Init events. 1542 $this.events( e ); 1543 }, 1544 1545 /* 1546 * Events 1547 */ 1548 events: function( e ) { 1549 // DOM Load 1550 window.addEventListener( 'load', function( e ) { 1551 $this.stickyInit( e ); 1552 $this.smartLevels( e ); 1553 $this.adaptTablet( e ); 1554 } ); 1555 // Resize 1556 window.addEventListener( 'resize', function( e ) { 1557 $this.stickyInit( e ); 1558 $this.smartLevels( e ); 1559 $this.adaptTablet( e ); 1560 } ); 1561 // Scroll 1562 window.addEventListener( 'scroll', function( e ) { 1563 window.requestAnimationFrame( $this.stickyScroll ); 1564 } ); 1565 }, 1566 1567 /* 1568 * Init nav bar sticky 1569 */ 1570 stickyInit: function( e ) { 1571 1572 if ( !$this.Sticky ) { 1573 return; 1574 } 1575 1576 $this.sScrollAllow = false; 1577 1578 // Calc sticky offset. 1579 if ( $this.StickyOffsetType !== 'size' ) { 1580 1581 var calcbar = 0; 1582 var wpadminbar = 0; 1583 1584 if ( $( '#wpadminbar' ).length > 0 ) { 1585 calcbar = $( '#wpadminbar' ).outerHeight(); 1586 1587 wpadminbar = calcbar; 1588 1589 if ( 'resize' !== e.type ) { 1590 $this.loadAdminBar = wpadminbar; 1591 } 1592 1593 if ( 'absolute' === $( '#wpadminbar' ).css( 'position' ) ) { 1594 wpadminbar = 0; 1595 1596 if ( 'resize' !== e.type ) { 1597 $this.loadAdminBar = 0; 1598 } 1599 } 1600 } 1601 1602 // Calc outside header. 1603 $this.StickyOffsetFull = $this.StickyHeader.outerHeight(); 1604 1605 // Calc on load offset top. 1606 var elOffset = $this.StickyNav.not( '.sticky-nav' ).offset(); 1607 1608 if ( elOffset && !$this.StickyNav.hasClass( '.sticky-nav' ) ) { 1609 1610 $this.StickyOffset = elOffset.top; 1611 1612 $this.loadStickyOffset = elOffset.top; 1613 } else { 1614 $this.StickyOffset = $this.loadStickyOffset; 1615 } 1616 1617 // Consider the size of the wpadminbar. 1618 if ( 32 === $this.loadAdminBar ) { 1619 if ( 46 === calcbar ) { 1620 $this.StickyOffset = $this.StickyOffset - wpadminbar + 14; 1621 } else { 1622 $this.StickyOffset = $this.StickyOffset - wpadminbar; 1623 } 1624 } else if ( 46 === $this.loadAdminBar || 0 === $this.loadAdminBar ) { 1625 1626 if ( 32 === calcbar ) { 1627 $this.StickyOffset = $this.StickyOffset - wpadminbar - 14; 1628 } else { 1629 $this.StickyOffset = $this.StickyOffset - wpadminbar; 1630 } 1631 } 1632 } 1633 1634 // Nav Height. 1635 var navHeight = $this.StickyNav.outerHeight(); 1636 1637 // Set the min-height default of the header. 1638 $this.StickyHeader.data( 'min-height', $this.StickyOffsetFull - navHeight ); 1639 1640 // Document ready. 1641 if ( 'resize' !== e.type ) { 1642 1643 // Add nav dummy. 1644 $this.StickyNav.after( '<div class="navbar-dummy"></div>' );
1645 $this.StickyHeader.find( '.navbar-dummy' ).height( navHeight ); 1646 1647 // Set type slide. 1648 if ( $this.StickyUp ) { 1649 $this.StickyHeader.addClass( 'sticky-type-slide' ); 1650 } 1651 } 1652 1653 // Allow. 1654 $this.sScrollAllow = true; 1655 }, 1656 1657 /* 1658 * Make nav bar sticky 1659 */ 1660 stickyScroll: function( e ) { 1661 if ( !$this.sScrollAllow ) { 1662 return; 1663 } 1664 1665 var scrollCurrent = $( window ).scrollTop(); 1666 1667 if ( $this.StickyUp ) { 1668 1669 if ( scrollCurrent > $this.StickyOffsetFull ) { 1670 $this.StickyNav.addClass( 'sticky-nav' ); 1671 } 1672 1673 if ( scrollCurrent <= $this.StickyOffset ) { 1674 $this.StickyNav.removeClass( 'sticky-nav' ); 1675 } 1676 1677 // Set scroll temporary vars. 1678 if ( scrollCurrent > $this.sPrevious ) { 1679 $this.sInterval = 0; 1680 $this.sDirection = 'down'; 1681 1682 $this.StickyNav.addClass( 'sticky-down' ).removeClass( 'sticky-up' ); 1683 } else { 1684 $this.sInterval += $this.sPrevious - scrollCurrent; 1685 $this.sDirection = 'up'; 1686 1687 $this.StickyNav.addClass( 'sticky-up' ).removeClass( 'sticky-down' ); 1688 } 1689 1690 // Сonditions. 1691 if ( $this.sInterval > 150 && 'up' === $this.sDirection ) { 1692 $this.StickyNav.addClass( 'sticky-nav-slide-visible' ); 1693 1694 $( document ).trigger( 'sticky-nav-visible' ); 1695 } else { 1696 $this.StickyNav.removeClass( 'sticky-nav-slide-visible' ); 1697 1698 $( document ).trigger( 'sticky-nav-hide' ); 1699 } 1700 1701 if ( scrollCurrent > $this.StickyOffsetFull + 150 ) { 1702 $this.StickyNav.addClass( 'sticky-nav-slide' ); 1703 } else { 1704 $this.StickyNav.removeClass( 'sticky-nav-slide' ); 1705 } 1706 1707 // Show onload document. 1708 if ( $this.sInFirst && scrollCurrent > $this.StickyOffsetFull + 150 ) { 1709 $this.StickyNav.addClass( ' sticky-nav-slide-visible sticky-up' ); 1710 $this.StickyNav.addClass( 'sticky-nav-slide' ); 1711 1712 $( document ).trigger( 'sticky-nav-visible' ); 1713 1714 $this.sDirection = 'up'; 1715 $this.sInterval = 151; 1716 $this.sInFirst = false; 1717 } 1718 } else { 1719 // Сonditions. 1720 if ( scrollCurrent > $this.StickyOffset ) { 1721 $this.StickyNav.addClass( 'sticky-nav' ); 1722 1723 $( document ).trigger( 'sticky-nav-visible' ); 1724 } else { 1725 $this.StickyNav.removeClass( 'sticky-nav' ); 1726 $( document ).trigger( 'sticky-nav-hide' ); 1727 } 1728 } 1729 1730 $this.sPrevious = scrollCurrent; 1731 }, 1732 1733 /* 1734 * Smart multi-Level menu 1735 */ 1736 smartLevels: function( e ) { 1737 1738 var windowWidth = $( window ).width(); 1739 1740 // Reset Calc. 1741 $( '.navbar-nav li' ).removeClass( 'cs-mm-level' ); 1742 $( '.navbar-nav li' ).removeClass( 'cs-mm-position-left cs-mm-position-right' ); 1743 $( '.navbar-nav li .sub-menu' ).removeClass( 'cs-mm-position-init' ); 1744 1745 // Set Settings. 1746 $( '.navbar-nav > li.menu-item' ).not( '.cs-mega-menu' ).each( function( index, parent ) { 1747 var position = 'cs-mm-position-right'; 1748 var objPrevWidth = 0; 1749 1750 $( parent ).find( '.sub-menu' ).each( function( index, el ) { 1751 1752 // Reset child levels. 1753 $( el ).parent().next( 'li' ).addClass( 'cs-mm-level' ); 1754 1755 if ( $( el ).parent().hasClass( 'cs-mm-level' ) ) { 1756 1757 $( el ).parent().removeClass( 'cs-mm-level' ); 1758 1759 position = 'cs-mm-position-right'; 1760 objPrevWidth = 0; 1761 } 1762 1763 // Find out position items. 1764 var offset = $( el ).offset(); 1765 var objOffset = offset.left; 1766 1767 if ( 'cs-mm-position-right' === position && $( el ).outerWidth() + objOffset > windowWidth ) { 1768 position = 'cs-mm-position-left'; 1769 } 1770 1771 if ( 'cs-mm-position-left' === position && objOffset - ( $( el ).outerWidth() + objPrevWidth ) < 0 ) { 1772 position = 'cs-mm-position-right'; 1773 } 1774 1775 objPrevWidth = $( el ).outerWidth(); 1776 1777 $( el ).addClass( 'cs-mm-position-init' ).parent().addClass( position ); 1778 } ); 1779 1780 } ); 1781 }, 1782 1783 /* 1784 * Adapting nav bar for tablet 1785 */ 1786 adaptTablet: function( e ) { 1787 // Click outside. 1788 $( document ).on( 'touchstart', function( e ) { 1789 1790 if ( !$( e.target ).closest( '.navbar-nav' ).length ) { 1791 $( '.navbar-nav .menu-item-has-children' ).removeClass( 'submenu-visible' ); 1792 } else { 1793 $( e.target ).parents( '.menu-item' ).siblings().find( '.menu-item' ).removeClass( 'submenu-visible' ); 1794 $( e.target ).parents( '.menu-item' ).siblings().closest( '.menu-item' ).removeClass( 'submenu-visible' ); 1795 } 1796 } ); 1797 1798 $( '.navbar-nav .menu-item-has-children' ).each( function( e ) { 1799 1800 // Reset class. 1801 $( this ).removeClass( 'submenu-visible' ); 1802 1803 // Remove expanded. 1804 $( this ).find( '> a > .expanded' ).remove(); 1805 1806 // Add a caret. 1807 if ( 'ontouchstart' in document.documentElement ) { 1808 $( this ).find( '> a' ).append( '<span class="expanded"></span>' ); 1809 } 1810 1811 // Check touch device. 1812 $( this ).addClass( 'ontouchstart' in document.documentElement ? 'touch-device' : '' ); 1813 1814 $( '> a .expanded', this ).on( 'touchstart', function( e ) { 1815 e.preventDefault(); 1816 1817 $( this ).closest( '.menu-item-has-children' ).toggleClass( 'submenu-visible' ); 1818 } ); 1819 1820 1821 if ( '#' === $( '> a', this ).attr( 'href' ) ) { 1822 $( '> a', this ).on( 'touchstart', function( e ) { 1823 e.preventDefault(); 1824 1825 if ( !$( e.target ).hasClass( 'expanded' ) ) { 1826 $( this ).closest( '.menu-item-has-children' ).toggleClass( 'submenu-visible' ); 1827 } 1828 } ); 1829 } 1830 } ); 1831 } 1832 }; 1833 1834 } )(); 1835 1836 // Initialize. 1837 cscoNavigation.init(); 1838 1839 /** 1840 * Offcanvas Navigation 1841 */ 1842 1843 $( '.offcanvas-toggle, .site-overlay' ).on( 'click', function( e ) { 1844 e.preventDefault(); 1845 $( 'body' ).toggleClass( 'offcanvas-active' ); 1846 1847 // recalc sticky sidebar by simulating window resize 1848 // with a delay equal to the animation speed 1849 setTimeout( function() { $( window ).trigger( 'resize' ); }, 401 ); 1850 } ); 1851 1852 /** 1853 * Large Page Header 1854 */ 1855 1856 var pageHeader = $( '.page-header-large' ), 1857 pageHeaderOuter = $( '.overlay-outer', pageHeader ); 1858 1859 // Function for calculating Page Header height. 1860 1861 function setPageHeaderHeight() { 1862 1863 // Redefine variables. 1864 pageHeader = $( '.page-header-large' ); 1865 pageHeaderOuter = $( '.overlay-outer', pageHeader ); 1866 1867 // Define heights. 1868 var contentHeight = $( '.overlay-inner', pageHeader ).innerHeight(), 1869 offsetHeight = adminBarHeight + headerHeight, 1870 availableHeight = windowHeight - offsetHeight, 1871 viewPortHeight = '100vh'; 1872 1873 // Offset page header. 1874 pageHeader.css( 'margin-top', '-' + offsetHeight + 'px' ); 1875 pageHeaderOuter.css( 'padding-top', offsetHeight + 'px' ); 1876 1877 // Set the page header height. 1878 if ( availableHeight >= contentHeight ) { 1879 pageHeaderOuter.css( 'height', viewPortHeight ); 1880 } else { 1881 pageHeaderOuter.css( 'height', contentHeight + offsetHeight + 'px' ); 1882 } 1883 1884 // Return if overlay position is set to bottom. 1885 if ( $( 'body' ).hasClass( 'style-align-left' ) ) { 1886 return; 1887 } 1888 1889 // Add extra padding, if possible. 1890 if ( availableHeight - offsetHeight >= contentHeight ) { 1891 pageHeaderOuter.css( 'padding-bottom', offsetHeight + 'px' ); 1892 } else { 1893 pageHeaderOuter.css( 'padding-bottom', 0 ); 1894 } 1895 } 1896 1897 // Set initial height. 1898 1899 $( document ).ready( function() { 1900 setPageHeaderHeight(); 1901 } ); 1902 1903 // Recalculate height on resize. 1904 1905 $( window ).resize( function() { 1906 setPageHeaderHeight(); 1907 } ); 1908 1909 /** 1910 * Parallax 1911 */ 1912 1913 function initParallax() { 1914 1915 $( '.parallax-enabled .parallax:not(.parallax-video)' ).each( function() { 1916 1917 $( this ).jarallax( { 1918 speed: 0.8, 1919 } ); 1920 1921 } ); 1922 1923 var parallaxVideo = $( '.parallax-video' ), 1924 speed = 0.8; 1925 1926 if ( !$( 'body' ).hasClass( 'parallax-enabled' ) ) { 1927 speed = 1; 1928 } 1929 1930 $( parallaxVideo ).each( function() { 1931 1932 if ( !$( this ).hasClass( 'parallax' ) ) { 1933 speed = 1; 1934 } 1935 1936 $( this ).jarallax( { 1937 speed: speed,
1938 videoSrc: $( this ).attr( 'data-video' ), 1939 videoStartTime: $( this ).data( 'start' ), 1940 videoEndTime: $( this ).data( 'end' ), 1941 videoPlayOnlyVisible: true, 1942 } ); 1943 1944 } ); 1945 1946 } 1947 1948 $( document ).ready( function() { 1949 initParallax(); 1950 1951 $( 'body' ).on( 'post-load', function() { 1952 initParallax(); 1953 } ); 1954 1955 csco.addAction( 'canvas.components.serverSideRender.onChange', 'initParallax', function( props ) { 1956 initParallax(); 1957 } ); 1958 } ); 1959 1960 /** 1961 * Object Fit Images 1962 */ 1963 1964 jQuery( document ).ready( function( $ ) { 1965 objectFitImages(); 1966 } ); 1967 1968 ( function() { 1969 var viewport = $( window ).height(); 1970 var lastScrollY = 0; 1971 var ticking = false; 1972 var offset = 200; 1973 1974 var update = function() { 1975 var article = $( '.single-post .site-main > article' ); 1976 1977 if ( 1 === article.length ) { 1978 let articleHeight = $( article ).innerHeight(); 1979 1980 // Pagination points. 1981 let topPoint = $( article ).offset().top; 1982 let bottomPoint = topPoint + articleHeight + offset; 1983 1984 if ( lastScrollY > topPoint && lastScrollY + viewport < bottomPoint ) { 1985 $( '.post-pagination' ).addClass( 'pagination-visible' ); 1986 } else { 1987 $( '.post-pagination' ).removeClass( 'pagination-visible' ); 1988 } 1989 } 1990 1991 ticking = false; 1992 }; 1993 1994 var requestTick = function() { 1995 if ( !ticking ) { 1996 window.requestAnimationFrame( update ); 1997 ticking = true; 1998 } 1999 }; 2000 2001 var onProcess = function() { 2002 lastScrollY = window.scrollY; 2003 2004 requestTick(); 2005 }; 2006 2007 $( window ).on( 'scroll', onProcess ); 2008 $( window ).on( 'resize', onProcess ); 2009 $( window ).on( 'slider-refresh', onProcess ); 2010 2011 } )(); 2012 2013 /** 2014 * Responsive Embeds 2015 */ 2016 2017 ( function() { 2018 /** 2019 * Add max-width & max-height to <iframe> elements, depending on their width & height props. 2020 */ 2021 function initResponsiveEmbeds() { 2022 var proportion, parentWidth; 2023 2024 // Loop iframe elements. 2025 $( '.entry-content' ).find( 'figure iframe, p iframe' ).each( function( index, iframe ) { 2026 // Don't handle if the parent automatically resizes itself. 2027 if ( $( iframe ).closest( 'div' ).is( '[data-video], [data-video-start], [data-video-end]' ) ) { 2028 return; 2029 } 2030 // Only continue if the iframe has a width & height defined. 2031 if ( iframe.width && iframe.height ) { 2032 // Calculate the proportion/ratio based on the width & height. 2033 proportion = parseFloat( iframe.width ) / parseFloat( iframe.height ); 2034 // Get the parent element's width. 2035 parentWidth = parseFloat( window.getComputedStyle( iframe.parentElement, null ).width.replace( 'px', '' ) ); 2036 // Set the max-width & height. 2037 iframe.style.maxWidth = '100%'; 2038 iframe.style.maxHeight = Math.round( parentWidth / proportion ).toString() + 'px'; 2039 } 2040 } ); 2041 } 2042 2043 // Document ready. 2044 $( document ).ready( function() { 2045 initResponsiveEmbeds(); 2046 } ); 2047 2048 // Document resize. 2049 $( window ).on( 'resize', function() { 2050 initResponsiveEmbeds(); 2051 } ); 2052 2053 // Post load. 2054 $( 'body' ).on( 'post-load', function() { 2055 initResponsiveEmbeds(); 2056 } ); 2057 2058 // Run on initial load. 2059 initResponsiveEmbeds(); 2060 } )(); 2061 2062 /** ---------------------------------------------------------------------------- 2063 * Color Scheme Toogle */ 2064 2065 var cscoDarkMode = {}; 2066 2067 ( function() { 2068 var $this; 2069 2070 cscoDarkMode = { 2071 2072 /** Initialize */ 2073 init: function( e ) { 2074 $this = cscoDarkMode; 2075 2076 if ( 'undefined' === typeof csSchemeLocalize ) { 2077 return; 2078 } 2079 2080 // Init events. 2081 $this.events( e ); 2082 }, 2083 2084 /** Events */ 2085 events: function( e ) { 2086 if ( $( 'body' ).hasClass( 'wp-admin' ) ) { 2087 return; 2088 } 2089 2090 // DOM Load 2091 window.addEventListener( 'load', function( e ) { 2092 $this.initMode( e ); 2093 } ); 2094 2095 window.matchMedia( '(prefers-color-scheme: dark)' ).addListener( ( e ) => { 2096 $this.initMode( e ); 2097 } ); 2098 2099 // Switch 2100 $( document ).on( 'click', '.cs-site-scheme-toggle', function( e ) { 2101 $this.changeMode( e ); 2102 } ); 2103 }, 2104 2105 /** Init Mode */ 2106 initMode: function( e ) { 2107 2108 // Get system scheme. 2109 var systemSchema = 'default'; 2110 2111 if ( window.matchMedia && window.matchMedia( '(prefers-color-scheme: dark)' ).matches ) { 2112 systemSchema = 'dark'; 2113 } 2114 2115 csSetCookie( '_color_system_schema', systemSchema, { expires: 2592000 } ); 2116 2117 // Set site scheme. 2118 var siteScheme = 'default'; 2119 2120 switch ( csSchemeLocalize.siteSchemeMode ) { 2121 case 'dark': 2122 siteScheme = 'dark'; 2123 break; 2124 case 'light': 2125 siteScheme = 'default'; 2126 break; 2127 case 'system': 2128 siteScheme = systemSchema; 2129 break; 2130 } 2131 2132 if ( csSchemeLocalize.siteSchemeToogle ) { 2133 if ( 'default' === csGetCookie( '_color_schema' ) ) { 2134 siteScheme = 'default'; 2135 } 2136 if ( 'dark' === csGetCookie( '_color_schema' ) ) { 2137 siteScheme = 'dark'; 2138 } 2139 } 2140 2141 // Change site scheme 2142 if ( siteScheme !== $( 'html' ).attr( 'data-scheme' ) ) { 2143 $this.changeScheme( siteScheme, false ); 2144 } 2145 }, 2146 2147 /** Change Mode */ 2148 changeMode: function( e ) { 2149 if ( 'dark' === $( 'html' ).attr( 'data-scheme' ) ) { 2150 $this.changeScheme( 'default', true ); 2151 } else { 2152 $this.changeScheme( 'dark', true ); 2153 } 2154 }, 2155 2156 /** Change Scheme */ 2157 changeScheme: function( scheme, cookie ) { 2158 $( 'html' ).addClass( 'cs-scheme-toggled' ); 2159 2160 $( 'html' ).attr( 'data-scheme', scheme ); 2161 2162 if ( 'dark' === scheme ) { 2163 document.getElementById( 'csco-customizer-output-dark-styles' ).removeAttribute( 'media' ); 2164 document.getElementById( 'csco-customizer-output-default-styles' ).setAttribute( 'media', "max-width: 1px" ); 2165 } else { 2166 document.getElementById( 'csco-customizer-output-default-styles' ).removeAttribute( 'media' ); 2167 document.getElementById( 'csco-customizer-output-dark-styles' ).setAttribute( 'media', "max-width: 1px" ); 2168 } 2169 2170 if ( cookie ) { 2171 csSetCookie( '_color_schema', scheme, { expires: 2592000 } ); 2172 csSetCookie( '_color_system_schema', null, { expires: 2592000 } ); 2173 } 2174 2175 setTimeout( () => { 2176 $( 'html' ).removeClass( 'cs-scheme-toggled' ); 2177 }, 100 ); 2178 } 2179 }; 2180 2181 } )(); 2182 2183 // Initialize. 2184 cscoDarkMode.init(); 2185 2186 /** 2187 * Fullscreen Search 2188 */ 2189 2190 $( 'a[href="#search"]' ).on( 'click', function( event ) { 2191 event.preventDefault(); 2192 $( '#search' ).addClass( 'open' ); 2193 $( '#search input[type="search"]' ).focus(); 2194 $( 'body' ).addClass( 'search-open' ); 2195 } ); 2196 2197 $( '#search, #search button.close' ).on( 'click keyup', function( event ) { 2198 if ( event.target === this || event.target.className === 'close' || event.keyCode === 27 ) { 2199 event.preventDefault(); 2200 $( this ).removeClass( 'open' ); 2201 $( 'body' ).removeClass( 'search-open' ); 2202 } 2203 } ); 2204 2205 /** 2206 * Sliders 2207 */ 2208 2209 // Simple 2210 2211 function initSliderSimple() { 2212 2213 var sliderSimple = $( '.gallery-type-slider' ); 2214 2215 function onTranslated( event ) { 2216 setTimeout( function() { 2217 $( window ).trigger( 'slider-refresh' ); 2218 }, 1000 ); 2219 } 2220 2221 function onInitialized( event ) { 2222 $( window ).trigger( 'slider-refresh' ); 2223 } 2224 2225 sliderSimple.each( function() { 2226 2227 $( this ).wrapInner( '<div class="owl-carousel"></div>' ); 2228 2229 $( this ).append( '<div class="owl-arrows"></div>' ); 2230 $( this ).append( '<div class="owl-dots"></div>' ); 2231 2232 var container = this, 2233 owl = $( this ).find( '.owl-carousel' ); 2234 2235 if ( $( owl ).hasClass( 'owl-loaded' ) ) { 2236 return; 2237 } 2238 2239 $( owl ).imagesLoaded( function() { 2240 2241 owl.owlCarousel( { 2242 dragEndSpeed: 250, 2243 smartSpeed: 250, 2244 autoHeight: true, 2245 items: 1, 2246 margin: 0, 2247 navText: [ 2248 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.previous + '</span></div>', 2249 '<div class="button button-primary button-effect"><span><i class="cs-icon cs-icon-chevron-up"></i></span><span>' + translation.next + '</span></div>' 2250 ], 2251 navContainer: $( '.owl-arrows', container ), 2252 dots: true, 2253 dotsContainer: $( '.owl-dots', container ), 2254 rtl: rtl, 2255 responsive: { 2256 0: { 2257 nav: false, 2258 }, 2259 1020: { 2260 nav: true, 2261 } 2262 }, 2263 onInitialized: onInitialized, 2264 onTranslated: onTranslated, 2265 } ); 2266 2267 } ); 2268 2269 } ); 2270 } 2271 2272 $( document ).ready( function() { 2273 initSliderSimple(); 2274 $( document.body ).on( 'post-load', function() { 2275 initSliderSimple(); 2276 } ); 2277 2278 csco.addAction( 'canvas.components.serverSideRender.onChange', 'posts-init-slider', function( props ) { 2279 if ( 'canvas/posts' === props.block ) { 2280 initSliderSimple(); 2281 } 2282 } ); 2283 } ); 2284 2285 // Flip 2286 2287 function initSliderFlip() { 2288 2289 var sliderFlip = $( '.slider-flip' ); 2290 2291 function sliderFlipInitialized() { 2292 $( window ).trigger( 'slider-refresh' ); 2293 } 2294 2295 sliderFlip.each( function() { 2296 2297 var container = this, 2298 owl = $( '.owl-carousel', this ), 2299 effectOut = 'flipOut', 2300 effectIn = 'flipIn'; 2301 2302 if ( isIE ) { 2303 effectOut = 'fadeOut'; 2304 effectIn = 'fadeIn'; 2305 } 2306 2307 $( owl ).imagesLoaded( function() { 2308 2309 owl.owlCarousel( { 2310 dragEndSpeed: 250, 2311 smartSpeed: 250, 2312 autoHeight: true, 2313 animateOut: effectOut, 2314 animateIn: effectIn, 2315 items: 1, 2316 margin: 0, 2317 dots: true, 2318 dotsContainer: $( '> .owl-dots', container ), 2319 rtl: rtl, 2320 onInitialized: sliderFlipInitialized, 2321 } ); 2322 2323 } ); 2324 2325 } ); 2326 2327 } 2328 2329 $( document ).ready( function() { 2330 initSliderFlip(); 2331 2332 $( document.body ).on( 'post-load', function() { 2333 initSliderFlip(); 2334 } ); 2335 2336 csco.addAction( 'canvas.components.serverSideRender.onChange', 'initNavMenu', function( props ) { 2337 initSliderFlip(); 2338 } ); 2339 } ); 2340 2341 /** 2342 * Sticky Post Sidebar 2343 */ 2344 2345 var stickyPostElements = $( '.sticky-sidebar-enabled .post-sidebar .pk-s
2345hare-buttons-wrap' ); 2346 2347 $( document ).ready( function() { 2348 2349 $( document ).on( 'sticky-nav-visible', function() { 2350 var navBarHeight = $( '.navbar-primary' ).innerHeight(); 2351 2352 $( stickyPostElements ).css( 'top', 60 + navBarHeight + 'px' ); 2353 } ); 2354 2355 $( document ).on( 'sticky-nav-hide', function() { 2356 $( stickyPostElements ).css( 'top', 60 + 'px' ); 2357 } ); 2358 2359 } ); 2360 2361 /** 2362 * Sticky Sidebar 2363 */ 2364 2365 var stickyElements = []; 2366 2367 stickyElements.push( '.sticky-sidebar-enabled.stick-to-top .sidebar-1' ); 2368 stickyElements.push( '.sticky-sidebar-enabled.stick-last .sidebar .widget:last-child' ); 2369 stickyElements.push( '.cnvs-block-section-sidebar-sticky-top .cnvs-block-section-sidebar-inner' ); 2370 stickyElements.push( '.cnvs-block-section-sidebar-sticky-top-last-block .cnvs-block-section-sidebar-inner > *:last-child' ); 2371 2372 $( document ).ready( function() { 2373 2374 // Sticky sidebar for mozilla. 2375 if ( navigator.userAgent.toLowerCase().indexOf( 'firefox' ) > -1 ) { 2376 stickyElements.push( '.sticky-sidebar-enabled.stick-to-bottom .sidebar-1' ); 2377 } 2378 2379 // Join elements. 2380 stickyElements = stickyElements.join( ',' ); 2381 2382 // Sticky nav visible. 2383 $( document ).on( 'sticky-nav-visible', function() { 2384 var navBarHeight = $( '.navbar-primary' ).innerHeight(); 2385 2386 $( stickyElements ).css( 'top', 32 + navBarHeight + 'px' ); 2387 } ); 2388 2389 // Sticky nav hide. 2390 $( document ).on( 'sticky-nav-hide', function() { 2391 $( stickyElements ).css( 'top', 32 + 'px' ); 2392 } ); 2393 2394 } ); 2395 2396 // Init slider for powerkit twitter. 2397 2398 function initTwitterSlider() { 2399 $( '.pk-twitter-slider, .cnvs-block-twitter-layout-slider' ).each( function() { 2400 if ( $( this ).hasClass( 'init-slider' ) ) { 2401 return; 2402 } 2403 2404 $( this ).addClass( 'init-slider' ); 2405 2406 // Wrap tweet of owl-slide. 2407 $( this ).find( '.pk-twitter-tweet' ).wrap( '<div class="owl-slide"></div>' ); 2408 2409 // Wrap tweets of owl-carousel. 2410 $( this ).find( '.pk-tweets' ).wrapInner( '<div class="owl-carousel"></div>' ); 2411 2412 // Add owl dots. 2413 $( this ).find( '.pk-tweets' ).append( '<div class="owl-dots"></div>' ); 2414 2415 // Wrap tweets of slider-container. 2416 $( this ).find( '.pk-tweets' ).wrapInner( '<div class="slider-container slider-flip"></div>' ); 2417 } ); 2418 } 2419 2420 $( document ).ready( function() { 2421 initTwitterSlider(); 2422 initSliderFlip(); 2423 2424 $( document.body ).on( 'post-load', function() { 2425 initTwitterSlider(); 2426 initSliderFlip(); 2427 } ); 2428 2429 csco.addAction( 'canvas.components.serverSideRender.onChange', 'initTwitterSlider', function( props ) { 2430 initTwitterSlider(); 2431 initSliderFlip(); 2432 } ); 2433 } ); 2434 2435 $( document ).ready( function() { 2436 $( document.body ).on( 'editor-render', function() { 2437 $( '.owl-carousel' ).trigger( 'refresh.owl.carousel' ); 2438 } ); 2439 } ); 2440 2441 /** 2442 * Product Thumbnail Slider 2443 */ 2444 2445 var owlProductGallery = $( '.product-gallery-wrapper' ); 2446 2447 owlProductGallery.each( function() { 2448 2449 var container = this; 2450 var owl = $( '.owl-carousel', this ); 2451 2452 $( owl ).imagesLoaded( function() { 2453 2454 owl.owlCarousel( { 2455 dragEndSpeed: 250, 2456 smartSpeed: 250, 2457 autoHeight: true, 2458 dots: true, 2459 dotsContainer: $( '> .owl-dots', container ), 2460 rtl: rtl, 2461 responsive: { 2462 0: { 2463 items: 1, 2464 margin: 0, 2465 }, 2466 760: { 2467 items: 2, 2468 margin: 15, 2469 }, 2470 1020: { 2471 items: 3, 2472 margin: 15, 2473 }, 2474 1240: { 2475 items: 4, 2476 margin: 15, 2477 } 2478 }, 2479 } ); 2480 2481 } ); 2482 2483 } ); 2484 2485} )( jQuery );
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.