1( function( $ ) { 2 "use strict"; 3 4 // 5 // Comments show 6 // 7 8 $( document ).on( 'click', '.post-comments-show button', function( e ) { 9 $( this ).parent().siblings( '.post-comments' ).show(); 10 $( this ).parent().remove(); 11 } ); 12 13 ( function() { 14 var ticking = false; 15 16 var update = function() { 17 18 // Sidebar. 19 // -----------------------------------. 20 $( '.content-area .site-main' ).each( function() { 21 22 var content = $( this ).find( '.entry-content' ); 23 var sidebar = $( this ).find( '.post-sidebar-inner' ); 24 25 // Vars offset. 26 var offsetTop = 20; 27 var offsetBottom = -20; 28 29 // Search elements. 30 var elements = []; 31 32 elements.push( '> .alignfull' ); 33 elements.push( '> .alignwide' ); 34 35 var layouts = $( content ).find( elements.join( ',' ) ); 36 37 if ( 0 === sidebar.length ) { 38 return; 39 } 40 if ( 0 === layouts.length ) { 41 return; 42 } 43 44 var disabled = false; 45 46 // Get sidebar values. 47 var sidebarTop = $( sidebar ).offset().top; 48 var sidebarHeight = $( sidebar ).outerHeight( true ); 49 50 for ( let i = 0; i < $( layouts ).length; ++i ) { 51 if ( 'none' === $( layouts[ i ] ).css( 'transform' ) ) { 52 continue; 53 } 54 55 // Get layout values. 56 let layoutTop = $( layouts[ i ] ).offset().top; 57 let layoutHeight = $( layouts[ i ] ).outerHeight( true ); 58 59 // Calc points. 60 let pointTop = layoutTop - offsetTop; 61 let pointBottom = layoutTop + layoutHeight + offsetBottom; 62 63 // Detect sidebar location. 64 if ( sidebarTop + sidebarHeight >= pointTop && sidebarTop <= pointBottom ) { 65 disabled = true; 66 } 67 } 68 69 70 if ( disabled ) { 71 $( sidebar ).css( 'opacity', '0' ); 72 } else { 73 $( sidebar ).css( 'opacity', '1' ); 74 } 75 } ); 76 77 // Ticking. 78 ticking = false; 79 }; 80 81 var requestTick = function() { 82 if ( !ticking ) { 83 window.requestAnimationFrame( update ); 84 ticking = true; 85 } 86 }; 87 88 var onProcess = function() { 89 requestTick(); 90 }; 91 92 $( window ).on( 'scroll', onProcess ); 93 $( window ).on( 'resize', onProcess ); 94 $( window ).on( 'image-load', onProcess ); 95 $( window ).on( 'post-load', onProcess ); 96 97 } )(); 98 99 /** 100 * AJAX Load More. 101 * 102 * Contains functions for AJAX Load More. 103 */ 104 105 106 /** 107 * Check if Load More is defined by the wp_localize_script 108 */ 109 if ( typeof csco_ajax_pagination !== 'undefined' ) { 110 111 $( '.post-archive' ).append( '<div class="ajax-navigation"><button class="load-more">' + csco_ajax_pagination.translation.load_more + '</button></div>' ); 112 113 var query_data = $.parseJSON( csco_ajax_pagination.query_data ), 114 infinite = $.parseJSON( query_data.infinite_load ), 115 button = $( '.ajax-navigation .load-more' ), 116 page = 2, 117 loading = false, 118 scrollHandling = { 119 allow: infinite, 120 reallow: function() { 121 scrollHandling.allow = true; 122 }, 123 delay: 400 //(milliseconds) adjust to the highest acceptable value 124 }; 125 126 } 127 128 /** 129 * Get next posts 130 */ 131 function csco_ajax_get_posts() { 132 loading = true; 133 // Set class loading. 134 button.addClass( 'loading' ); 135 var data = { 136 action: 'csco_ajax_load_more', 137 page: page, 138 posts_per_page: csco_ajax_pagination.posts_per_page, 139 query_data: csco_ajax_pagination.query_data, 140 _ajax_nonce: csco_ajax_pagination.nonce, 141 }; 142 143 // Request Url. 144 var csco_pagination_url; 145 if ( 'ajax_restapi' === csco_ajax_pagination.type ) { 146 csco_pagination_url = csco_ajax_pagination.rest_url; 147 } else { 148 csco_pagination_url = csco_ajax_pagination.url; 149 } 150 151 // Send Request. 152 $.post( csco_pagination_url, data, function( res ) { 153 if ( res.success ) { 154 155 // Get the posts. 156 var data = $( res.data.content ); 157 158 // Check if there're any posts. 159 if ( data.length ) { 160 161 var cscoAppendEnd = function() { 162 163 // WP Post Load trigger. 164 $( document.body ).trigger( 'post-load' ); 165 166 // Reinit Facebook widgets. 167 if ( $( '#fb-root' ).length ) { 168 FB.XFBML.parse(); 169 } 170 171 // Remove class loading. 172 button.removeClass( 'loading' ); 173 174 // Increment a page. 175 page = page + 1; 176 177 // Set the loading state. 178 loading = false;
179 }; 180 181 // Append new posts to archives. 182 if ( $( '.post-archive .archive-main' ).hasClass( 'archive-masonry' ) ) { 183 data.imagesLoaded( function() { 184 // Append new posts to masonry layout. 185 $( '.post-archive .archive-main' ).colcade( 'append', data ); 186 187 cscoAppendEnd(); 188 } ); 189 } else { 190 $( '.post-archive .archive-main' ).append( data ); 191 192 cscoAppendEnd(); 193 } 194 } 195 196 // Remove Button on Posts End. 197 if ( res.data.posts_end || !data.length ) { 198 199 // Remove Load More button. 200 button.remove(); 201 } 202 203 } else { 204 // console.log(res); 205 } 206 } ).fail( function( xhr, textStatus, e ) { 207 // console.log(xhr.responseText); 208 } ); 209 } 210 211 /** 212 * Check if Load More is defined by the wp_localize_script 213 */ 214 if ( typeof csco_ajax_pagination !== 'undefined' ) { 215 216 // On Scroll Event. 217 $( window ).scroll( function() { 218 if ( button.length && !loading && scrollHandling.allow ) { 219 scrollHandling.allow = false; 220 setTimeout( scrollHandling.reallow, scrollHandling.delay ); 221 var offset = $( button ).offset().top - $( window ).scrollTop(); 222 if ( 4000 > offset ) { 223 csco_ajax_get_posts(); 224 } 225 } 226 } ); 227 228 // On Click Event. 229 $( 'body' ).on( 'click', '.load-more', function() { 230 if ( !loading ) { 231 csco_ajax_get_posts(); 232 } 233 } ); 234 235 } 236 237 /** 238 * AJAX Auto Load Next Post. 239 * 240 * Contains functions for AJAX Auto Load Next Post. 241 */ 242 243 244 /** 245 * Check if Load Nextpost is defined by the wp_localize_script 246 */ 247 if ( typeof csco_ajax_nextpost !== 'undefined' ) { 248 249 var objNextpost = $( '.site-main' ), 250 objNextsect = '.cs-nextpost-section', 251 currentNTitle = document.title, 252 currentNLink = window.location.href, 253 loadingNextpost = false, 254 scrollNextpost = { 255 allow: true, 256 reallow: function() { 257 scrollNextpost.allow = true; 258 }, 259 delay: 400 //(milliseconds) adjust to the highest acceptable value 260 }; 261 } 262 263 /** 264 * Get next post 265 */ 266 function csco_ajax_get_nextpost() { 267 loadingNextpost = true; 268 269 // Set class loading. 270 var data = { 271 action: 'csco_ajax_load_nextpost', 272 not_in: csco_ajax_nextpost.not_in, 273 sidebar: csco_ajax_nextpost.sidebar, 274 current_user: csco_ajax_nextpost.current_user, 275 nonce: csco_ajax_nextpost.nonce, 276 next_post: csco_ajax_nextpost.next_post, 277 }; 278 279 // Request Url. 280 var csco_ajax_nextpost_url; 281 if ( 'ajax_restapi' === csco_ajax_nextpost.type ) { 282 csco_ajax_nextpost_url = csco_ajax_nextpost.rest_url; 283 } else { 284 csco_ajax_nextpost_url = csco_ajax_nextpost.url; 285 } 286 287 // Send Request. 288 $.post( csco_ajax_nextpost_url, data, function( res ) { 289 290 csco_ajax_nextpost.next_post = false; 291 292 if ( res.success ) { 293 294 // Get the posts. 295 var data = $( res.data.content ); 296 297 // Check if there're any posts. 298 if ( data.length ) { 299 // Set the loading state. 300 loadingNextpost = false; 301 302 // Set not_in. 303 csco_ajax_nextpost.not_in = res.data.not_in; 304 305 // Set next data. 306 csco_ajax_nextpost.next_post = res.data.next_post; 307 308 // Remove loader. 309 $( objNextpost ).siblings( '.cs-nextpost-loading' ).remove(); 310 311 // Append new post. 312 $( objNextpost ).append( data ); 313 314 // Reinit facebook. 315 if ( $( '#fb-root' ).length ) { 316 FB.XFBML.parse(); 317 } 318 319 $( document.body ).trigger( 'post-load' ); 320 } 321 } else { 322 // console.log(res); 323 } 324 } ).fail( function( xhr, textStatus, e ) { 325 // console.log(xhr.responseText); 326 } ); 327 } 328 329 /** 330 * Check if Load Nextpost is defined by the wp_localize_script 331 */ 332 if ( typeof csco_ajax_nextpost !== 'undefined' ) { 333 334 // On Scroll Event. 335 $( window ).scroll( function() { 336 var scrollTop = $( window ).scrollTop(); 337 338 // Init nextpost. 339 if ( csco_ajax_nextpost.next_post ) { 340 341 if ( objNextpost.length && !loadingNextpost && scrollNextpost.allow ) { 342 scrollNextpost.allow = false; 343 setTimeout( scrollNextpost.reallow, scrollNextpost.delay ); 344 // Calc current offset. 345 let offset = objNextpost.offset().top + objNextpost.innerHeight() - scrollTop; 346 // Load nextpost. 347 if ( 4000 > offset ) { 348 $( objNextpost ).after( '<div class="cs-nextpost-loading"></div>' ); 349 350 csco_ajax_get_nextpost(); 351 } 352 } 353 } 354 355 // Reset browser data link. 356 let objFirst = $( objNextsect ).first(); 357 358 if ( objFirst.length ) { 359 let firstTop = $( objFirst ).offset().top; 360 // If there has been a change. 361 if ( scrollTop < firstTop && window.location.href !== currentNLink ) { 362 document.title = currentNTitle; 363 window.history.pushState( null, currentNTitle, currentNLink ); 364 } 365 } 366 367 // Set browser data link. 368 $( objNextsect ).each( function( index, elem ) { 369 let elemTop = $( elem ).offset().top; 370 let elemHeight = $( elem ).innerHeight(); 371 372 if ( scrollTop > elemTop && scrollTop < elemTop + elemHeight ) { 373 // If there has been a change. 374 if ( window.location.href !== $( elem ).data( 'url' ) ) { 375 // New title. 376 document.title = $( elem ).data( 'title' ); 377 // New link. 378 window.history.pushState( null, $( elem ).data( 'title' ), $( elem ).data( 'url' ) ); 379 // Google Analytics. 380 if ( typeof gtag === 'function' && typeof window.gaData === 'object' ) { 381 382 var trackingId = Object.keys( window.gaData )[ 0 ]; 383 if ( trackingId ) { 384 gtag( 'config', trackingId, { 385 'page_title': $( elem ).data( 'title' ), 386 'page_location': $( elem ).data( 'url' ) 387 } ); 388 389 gtag( 'event', 'page_view', { 'send_to': trackingId } ); 390 } 391 } 392 } 393 } 394 } ); 395 } ); 396 } 397 398 /** 399 * Masonry Widget Area 400 */ 401 402 function initMasonrySidebar() { 403 404 /** 405 * Masonry Options 406 */ 407 var masonrySidebar = $( '.widget-area' ), 408 masonrySidebarOptions = { 409 columns: '.sidebar', 410 items: ' .widget' 411 }; 412 413 // Set Masonry. 414 $( masonrySidebar ).imagesLoaded( function() { 415 $( masonrySidebar ).colcade( masonrySidebarOptions ); 416 } ); 417 } 418 419 $( document ).ready( function() { 420 initMasonrySidebar(); 421 } ); 422 423 /** 424 * Masonry Archive 425 */ 426 427 function initMasonry() { 428 429 var masonryArchive = $( '.archive-masonry' ), 430 masonryArchiveOptions = { 431 columns: '.archive-col', 432 items: 'article' 433 }; 434 435 $( masonryArchive ).imagesLoaded( function() { 436 $( masonryArchive ).colcade( masonryArchiveOptions ); 437 } ); 438 } 439 440 $( document ).ready( function() { 441 initMasonry(); 442 } ); 443 444 /* 445 * Load Mega Menu Posts 446 */ 447 function cscoLoadMenuPosts( menuItem ) { 448 var dataCat = menuItem.children( 'a' ).data( 'cat' ), 449 dataType = menuItem.children( 'a' ).data( 'type' ), 450 dataNumberposts = menuItem.children( 'a' ).data( 'numberposts' ), 451 menuContainer, 452 postsContainer; 453 454 // Containers. 455 if ( menuItem.hasClass( 'cs-mega-menu-has-category' ) ) { 456 menuContainer = menuItem; 457 postsContainer = menuContainer.find( '.cs-mm-posts' ); 458 } else { 459 menuContainer = menuItem.closest( '.sub-menu' ); 460 postsContainer = menuContainer.find( '.cs-mm-posts[data-cat="' + dataCat + '"]' ); 461 } 462 463 // Set Active. 464 menuContainer.find( '.menu-item, .cs-mm-posts' ).removeClass( 'active-item' ); 465 menuItem.addClass( 'active-item' ); 466 467 if ( postsContainer ) { 468 postsContainer.addClass( 'active-item' ); 469 } 470
471 // Check Loading. 472 if ( menuItem.hasClass( 'cs-mm-loading' ) || menuItem.hasClass( 'cs-mm-loaded' ) ) { 473 return false; 474 } 475 476 // Check Category. 477 if ( !dataCat || typeof dataCat === 'undefined' ) { 478 return false; 479 } 480 481 // Check Container. 482 if ( !postsContainer || typeof postsContainer === 'undefined' ) { 483 return false; 484 } 485 486 // Create Data. 487 var data = { 488 'cat': dataCat, 489 'type': dataType, 490 'per_page': dataNumberposts 491 }; 492 493 // Get Results. 494 $.ajax( { 495 url: csco_mega_menu.rest_url, 496 type: 'GET', 497 data: data, 498 global: false, 499 async: true, 500 beforeSend: function() { 501 menuItem.addClass( 'cs-mm-loading' ); 502 postsContainer.addClass( 'cs-mm-loading' ); 503 }, 504 success: function( res ) { 505 if ( res.status && 'success' === res.status ) { 506 507 // Set the loaded state. 508 menuItem.addClass( 'cs-mm-loaded' ); 509 postsContainer.addClass( 'cs-mm-loaded' ); 510 511 // Check if there're any posts. 512 if ( res.content && res.content.length ) { 513 514 $( res.content ).imagesLoaded( function() { 515 516 // Append Data. 517 postsContainer.html( res.content ); 518 } ); 519 } 520 } 521 }, 522 complete: function() { 523 menuItem.removeClass( 'cs-mm-loading' ); 524 postsContainer.removeClass( 'cs-mm-loading' ); 525 } 526 } ); 527 } 528 529 /* 530 * Get First Tab 531 */ 532 function cscoGetFirstTab( container ) { 533 var firstTab = false; 534 535 container.find( '.cs-mega-menu-child' ).each( function( index, el ) { 536 if ( $( el ).hasClass( 'menu-item-object-category' ) ) { 537 firstTab = $( el ); 538 return false; 539 } 540 if ( $( el ).hasClass( 'menu-item-object-post_tag' ) ) { 541 firstTab = $( el ); 542 return false; 543 } 544 } ); 545 546 return firstTab; 547 } 548 549 /* 550 * Menu on document ready 551 */ 552 $( document ).ready( function() { 553 554 /* 555 * Get Menu Posts on Hover 556 */ 557 $( '.navbar-nav .menu-item.cs-mega-menu-has-category, .navbar-nav .menu-item.cs-mega-menu-child' ).on( 'hover', function() { 558 cscoLoadMenuPosts( $( this ) ); 559 } ); 560 561 /* 562 * Load First Tab on Mega Menu Hover 563 */ 564 $( '.navbar-nav .menu-item.cs-mega-menu-has-categories' ).on( 'hover', function() { 565 var tab = cscoGetFirstTab( $( this ) ); 566 567 if ( tab ) { 568 cscoLoadMenuPosts( tab ); 569 } 570 } ); 571 } ); 572 573 /* 574 * Load First Tab on Navbar Ready. 575 */ 576 $( document, '.navbar-nav' ).ready( function() { 577 var tab = false; 578 579 // Autoload First Tab. 580 $( '.navbar-nav .menu-item.cs-mega-menu-has-categories' ).each( function( index, el ) { 581 tab = cscoGetFirstTab( $( this ) ); 582 if ( tab ) { 583 cscoLoadMenuPosts( tab ); 584 } 585 } ); 586 587 // Autoload Category. 588 $( '.navbar-nav .menu-item.cs-mega-menu-has-category' ).each( function( index, el ) { 589 cscoLoadMenuPosts( $( this ) ); 590 } ); 591 } ); 592 593 // 594 // Responsive Navigation 595 // 596 597 $.fn.responsiveNav = function() { 598 this.removeClass( 'menu-item-expanded' ); 599 if ( this.prev().hasClass( 'submenu-visible' ) ) { 600 this.prev().removeClass( 'submenu-visible' ).slideUp( 350 ); 601 this.parent().removeClass( 'menu-item-expanded' ); 602 } else { 603 this.parent().parent().find( '.menu-item .sub-menu' ).removeClass( 'submenu-visible' ).slideUp( 350 ); 604 this.parent().parent().find( '.menu-item-expanded' ).removeClass( 'menu-item-expanded' ); 605 this.prev().toggleClass( 'submenu-visible' ).hide().slideToggle( 350 ); 606 this.parent().toggleClass( 'menu-item-expanded' ); 607 } 608 }; 609 610 // 611 // Navigation Menu Widget 612 // 613 614 $( document ).ready( function( e ) { 615 616 $( '.widget_nav_menu .menu-item-has-children' ).each( function( e ) { 617 618 // Add a caret. 619 $( this ).append( '<span></span>' ); 620 621 // Fire responsiveNav() when clicking a caret. 622 $( '> span', this ).on( 'click', function( e ) { 623 e.preventDefault(); 624 $( this ).responsiveNav(); 625 } ); 626 627 // Fire responsiveNav() when clicking a parent item with # href attribute. 628 if ( '#' === $( '> a', this ).attr( 'href' ) ) { 629 $( '> a', this ).on( 'click', function( e ) { 630 e.preventDefault(); 631 $( this ).next().next().responsiveNav(); 632 } ); 633 } 634 635 } ); 636 637 } ); 638 639 /* 640 * ---------------------------------------------------------------------------- 641 * Navigation 642 */ 643 644 var cscoNavigation = {}; 645 646 ( function() { 647 var $this; 648 649 cscoNavigation = { 650 sScrollAllow: false, 651 sInFirst: true, 652 sInterval: 0, 653 sPrevious: 0, 654 sDirection: 0, 655 656 loadStickyOffset: 0, 657 loadAdminBar: false, 658 659 Sticky: $( 'body' ).hasClass( 'navbar-sticky-enabled' ), 660 StickyUp: $( 'body' ).hasClass( 'navbar-smart-enabled' ), 661 StickyNav: $( '.site-header .navbar-primary' ), 662 StickyHeader: $( '.site-header' ), 663 StickyOffsetType: 'auto', 664 StickyOffset: 0, 665 StickyOffsetFull: 0, 666 667 /* 668 * Initialize 669 */ 670 init: function( e ) { 671 $this = cscoNavigation; 672 673 // Init events. 674 $this.events( e ); 675 }, 676 677 /* 678 * Events 679 */ 680 events: function( e ) { 681 // DOM Load 682 document.addEventListener( 'DOMContentLoaded', function( e ) { 683 $this.stickyInit( e ); 684 $this.smartLevels( e ); 685 $this.adaptTablet( e ); 686 } ); 687 // Resize 688 window.addEventListener( 'resize', function( e ) { 689 $this.stickyInit( e ); 690 $this.smartLevels( e ); 691 $this.adaptTablet( e ); 692 } ); 693 // Scroll 694 window.addEventListener( 'scroll', function( e ) { 695 window.requestAnimationFrame( $this.stickyScroll ); 696 } ); 697 698 // Add dynamic search support. 699 $( document ).on( 'animate-search', function( e ) { 700 $this.animateSearch( e ); 701 } ); 702 $( document ).on( 'animate-search-start', function( e ) { 703 $this.animateSearchStart( e ); 704 } ); 705 $( document ).on( 'animate-search-done', function( e ) { 706 $this.animateSearchDone( e ); 707 } ); 708 }, 709 710 /* 711 * Init nav bar sticky 712 */ 713 stickyInit: function( e ) { 714 715 if ( !$this.Sticky ) { 716 return; 717 } 718 719 $this.sScrollAllow = false;
720 721 // Calc sticky offset. 722 if ( $this.StickyOffsetType !== 'size' ) { 723 724 var calcbar = 0; 725 var wpadminbar = 0; 726 727 if ( $( '#wpadminbar' ).length > 0 ) { 728 calcbar = $( '#wpadminbar' ).outerHeight(); 729 730 wpadminbar = calcbar; 731 732 if ( 'resize' !== e.type ) { 733 $this.loadAdminBar = wpadminbar; 734 } 735 736 if ( 'absolute' === $( '#wpadminbar' ).css( 'position' ) ) { 737 wpadminbar = 0; 738 739 if ( 'resize' !== e.type ) { 740 $this.loadAdminBar = 0; 741 } 742 } 743 } 744 745 // Calc outside header. 746 $this.StickyOffsetFull = $this.StickyHeader.outerHeight(); 747 748 // Calc on load offset top. 749 var elOffset = $this.StickyNav.not( '.sticky-nav' ).offset(); 750 751 if ( elOffset && !$this.StickyNav.hasClass( '.sticky-nav' ) ) { 752 753 $this.StickyOffset = elOffset.top; 754 755 $this.loadStickyOffset = elOffset.top; 756 } else { 757 $this.StickyOffset = $this.loadStickyOffset; 758 } 759 760 // Consider the size of the wpadminbar. 761 if ( 32 === $this.loadAdminBar ) { 762 if ( 46 === calcbar ) { 763 $this.StickyOffset = $this.StickyOffset - wpadminbar + 14; 764 } else { 765 $this.StickyOffset = $this.StickyOffset - wpadminbar; 766 } 767 } else if ( 46 === $this.loadAdminBar || 0 === $this.loadAdminBar ) { 768 769 if ( 32 === calcbar ) { 770 $this.StickyOffset = $this.StickyOffset - wpadminbar - 14; 771 } else { 772 $this.StickyOffset = $this.StickyOffset - wpadminbar; 773 } 774 } 775 } 776 777 // Nav Height. 778 var navHeight = $this.StickyNav.outerHeight(); 779 780 // Set the min-height default of the header. 781 $this.StickyHeader.data( 'min-height', $this.StickyOffsetFull - navHeight ); 782 783 // Document ready. 784 if ( 'resize' !== e.type ) { 785 786 // Add nav dummy. 787 $this.StickyNav.after( '<div class="navbar-dummy"></div>' ); 788 $this.StickyHeader.find( '.navbar-dummy' ).height( navHeight ); 789 790 // Set type slide. 791 if ( $this.StickyUp ) { 792 $this.StickyHeader.addClass( 'sticky-type-slide' ); 793 } 794 } 795 796 // Allow. 797 $this.sScrollAllow = true; 798 }, 799 800 /* 801 * Make nav bar sticky 802 */ 803 stickyScroll: function( e ) { 804 if ( !$this.sScrollAllow ) { 805 return; 806 } 807 808 var scrollCurrent = $( window ).scrollTop(); 809 810 if ( $this.StickyUp ) { 811 812 if ( scrollCurrent > $this.StickyOffsetFull ) { 813 $this.StickyNav.addClass( 'sticky-nav' ); 814 } 815 816 if ( scrollCurrent <= $this.StickyOffset ) { 817 $this.StickyNav.removeClass( 'sticky-nav' ); 818 } 819 820 // Set scroll temporary vars. 821 if ( scrollCurrent > $this.sPrevious ) { 822 $this.sInterval = 0; 823 $this.sDirection = 'down'; 824 825 $this.StickyNav.addClass( 'sticky-down' ).removeClass( 'sticky-up' ); 826 } else { 827 $this.sInterval += $this.sPrevious - scrollCurrent; 828 $this.sDirection = 'up'; 829 830 $this.StickyNav.addClass( 'sticky-up' ).removeClass( 'sticky-down' ); 831 } 832 833 // Сonditions. 834 if ( $this.sInterval > 150 && 'up' === $this.sDirection ) { 835 $this.StickyNav.addClass( 'sticky-nav-slide-visible' ); 836 837 $( document ).trigger( 'sticky-nav-visible' ); 838 } else { 839 $this.StickyNav.removeClass( 'sticky-nav-slide-visible' ); 840 841 $( document ).trigger( 'sticky-nav-hide' ); 842 } 843 844 if ( scrollCurrent > $this.StickyOffsetFull + 150 ) { 845 $this.StickyNav.addClass( 'sticky-nav-slide' ); 846 } else { 847 $this.StickyNav.removeClass( 'sticky-nav-slide' ); 848 } 849 850 // Show onload document. 851 if ( $this.sInFirst && scrollCurrent > $this.StickyOffsetFull + 150 ) { 852 $this.StickyNav.addClass( ' sticky-nav-slide-visible sticky-up' ); 853 $this.StickyNav.addClass( 'sticky-nav-slide' ); 854 855 $( document ).trigger( 'sticky-nav-visible' ); 856 857 $this.sDirection = 'up'; 858 $this.sInterval = 151; 859 $this.sInFirst = false; 860 } 861 } else { 862 // Сonditions. 863 if ( scrollCurrent > $this.StickyOffset ) { 864 $this.StickyNav.addClass( 'sticky-nav' ); 865 866 $( document ).trigger( 'sticky-nav-visible' ); 867 } else { 868 $this.StickyNav.removeClass( 'sticky-nav' ); 869 $( document ).trigger( 'sticky-nav-hide' ); 870 } 871 } 872 873 $this.sPrevious = scrollCurrent; 874 }, 875 876 /* 877 * Dynamic search support 878 */ 879 animateSearch: function( e ) { 880 var minHeightMain = $this.StickyHeader.data( 'min-height' ); 881 var navHeight = $this.StickyNav.outerHeight(); 882 883 $this.StickyOffsetFull = ( minHeightMain + navHeight ); 884
885 $this.StickyHeader.find( '.navbar-dummy' ).height( navHeight ); 886 }, 887 888 /* 889 * Start: Dynamic search support 890 */ 891 animateSearchStart: function( e ) { 892 $this.sScrollAllow = false; 893 }, 894 895 /* 896 * Done: Dynamic search support 897 */ 898 animateSearchDone: function( e ) { 899 var minHeightMain = $this.StickyHeader.data( 'min-height' ); 900 var navHeight = $this.StickyNav.outerHeight(); 901 902 $this.sScrollAllow = true; 903 904 $this.sPrevious = $this.sPrevious + ( navHeight - minHeightMain ); 905 }, 906 907 /* 908 * Smart multi-Level menu 909 */ 910 smartLevels: function( e ) { 911 912 var windowWidth = $( window ).width(); 913 914 // Reset Calc. 915 $( '.navbar-nav li' ).removeClass( 'cs-mm-level' ); 916 $( '.navbar-nav li' ).removeClass( 'cs-mm-position-left cs-mm-position-right' ); 917 $( '.navbar-nav li .sub-menu' ).removeClass( 'cs-mm-position-init' ); 918 919 // Set Settings. 920 $( '.navbar-nav > li.menu-item' ).not( '.cs-mega-menu' ).each( function( index, parent ) { 921 var position = 'cs-mm-position-right'; 922 var objPrevWidth = 0; 923 924 $( parent ).find( '.sub-menu' ).each( function( index, el ) { 925 926 // Reset child levels. 927 $( el ).parent().next( 'li' ).addClass( 'cs-mm-level' ); 928 929 if ( $( el ).parent().hasClass( 'cs-mm-level' ) ) { 930 931 $( el ).parent().removeClass( 'cs-mm-level' ); 932 933 position = 'cs-mm-position-right'; 934 objPrevWidth = 0; 935 } 936 937 // Find out position items. 938 var offset = $( el ).offset(); 939 var objOffset = offset.left; 940 941 if ( 'cs-mm-position-right' === position && $( el ).outerWidth() + objOffset > windowWidth ) { 942 position = 'cs-mm-position-left'; 943 } 944 945 if ( 'cs-mm-position-left' === position && objOffset - ( $( el ).outerWidth() + objPrevWidth ) < 0 ) { 946 position = 'cs-mm-position-right'; 947 } 948 949 objPrevWidth = $( el ).outerWidth(); 950 951 $( el ).addClass( 'cs-mm-position-init' ).parent().addClass( position ); 952 } ); 953 954 } ); 955 }, 956 957 /* 958 * Adapting nav bar for tablet 959 */ 960 adaptTablet: function( e ) { 961 // Click outside. 962 $( document ).on( 'touchstart', function( e ) { 963 964 if ( !$( e.target ).closest( '.navbar-nav' ).length ) { 965 $( '.navbar-nav .menu-item-has-children' ).removeClass( 'submenu-visible' ); 966 } else { 967 $( e.target ).parents( '.menu-item' ).siblings().find( '.menu-item' ).removeClass( 'submenu-visible' ); 968 $( e.target ).parents( '.menu-item' ).siblings().closest( '.menu-item' ).removeClass( 'submenu-visible' ); 969 } 970 } ); 971 972 $( '.navbar-nav .menu-item-has-children' ).each( function( e ) { 973 974 // Reset class. 975 $( this ).removeClass( 'submenu-visible' ); 976 977 // Remove expanded. 978 $( this ).find( '> a > .expanded' ).remove(); 979 980 // Add a caret. 981 if ( 'ontouchstart' in document.documentElement ) { 982 $( this ).find( '> a' ).append( '<span class="expanded"></span>' ); 983 } 984 985 // Check touch device. 986 $( this ).addClass( 'ontouchstart' in document.documentElement ? 'touch-device' : '' ); 987 988 $( '> a .expanded', this ).on( 'touchstart', function( e ) { 989 e.preventDefault(); 990 991 $( this ).closest( '.menu-item-has-children' ).toggleClass( 'submenu-visible' ); 992 } ); 993 994 995 if ( '#' === $( '> a', this ).attr( 'href' ) ) { 996 $( '> a', this ).on( 'touchstart', function( e ) { 997 e.preventDefault(); 998 999 if ( !$( e.target ).hasClass( 'expanded' ) ) { 1000 $( this ).closest( '.menu-item-has-children' ).toggleClass( 'submenu-visible' ); 1001 } 1002 } ); 1003 } 1004 } ); 1005 } 1006 }; 1007 1008 } )(); 1009 1010 // Initialize. 1011 cscoNavigation.init(); 1012 1013 // 1014 // Mobile Menu 1015 // 1016 1017 $( '.toggle-offcanvas, .site-overlay' ).on( 'click', function( e ) { 1018 e.preventDefault(); 1019 $( 'body' ).toggleClass( 'offcanvas-active' ); 1020 } ); 1021 1022 /** 1023 * Site Search 1024 */ 1025 1026 $( '.toggle-search' ).on( 'click', function( event ) { 1027 1028 event.preventDefault(); 1029 1030 var container = $( '#search' ), 1031 field = $( 'input[type="search"]', container ); 1032 1033 // Toggle class on search button. 1034 $( this ).toggleClass( 'toggle-close' ); 1035 1036 // Add class to container. 1037 container.toggleClass( 'search-open' ); 1038 1039 // Slide toggle the container. 1040 container.slideToggle( { 1041 duration: 400, 1042 progress: function() { 1043 $( document ).trigger( 'animate-search' ); 1044 }, 1045 start: function() { 1046 $( document ).trigger( 'animate-search-start' ); 1047 }, 1048 done: function() { 1049 $( document ).trigger( 'animate-search-done' ); 1050 } 1051 } ); 1052 1053 // Focus on / blur input field. 1054 if ( container.hasClass( 'search-open' ) ) { 1055 field.focus(); 1056 } else { 1057 field.blur(); 1058 } 1059 } ); 1060 1061 $( '#search, .search-close' ).on( 'click keyup', function( event ) { 1062 // Fire only when pressing Escape or clicking the .search-toggle button. 1063 if ( event.target.className === 'search-close' || event.keyCode === 27 ) { 1064 event.preventDefault(); 1065 $( '.toggle-search' ).removeClass( 'toggle-close' ); 1066 $( '#search' ).removeClass( 'search-open' ); 1067 $( '#search input[type="search"]' ).blur();
1068 $( '#search' ).slideUp( { 1069 duration: 400, 1070 progress: function() { 1071 $( document ).trigger( 'animate-search' ); 1072 }, 1073 start: function() { 1074 $( document ).trigger( 'animate-search-start' ); 1075 }, 1076 done: function() { 1077 $( document ).trigger( 'animate-search-done' ); 1078 } 1079 } ); 1080 } 1081 } ); 1082 1083 /** 1084 * Focus Shadow on Search Field 1085 */ 1086 1087 $( '.search-form input' ).focus( function() { 1088 $( this ).closest( '.search-form' ).addClass( 'cs-form-focus' ); 1089 } ); 1090 1091 $( '.search-form input' ).blur( function() { 1092 $( this ).closest( '.search-form' ).removeClass( 'cs-form-focus' ); 1093 } ); 1094 1095 /** 1096 * Sticky Sidebar 1097 */ 1098 1099 var stickyElements = []; 1100 1101 stickyElements.push( '.sticky-sidebar-enabled.stick-to-top .sidebar-1' ); 1102 stickyElements.push( '.sticky-sidebar-enabled.stick-last .sidebar .widget:last-child' ); 1103 1104 $( document ).ready( function() { 1105 1106 // Sticky sidebar for mozilla. 1107 if ( $.browser.mozilla ) { 1108 stickyElements.push( '.sticky-sidebar-enabled.stick-to-bottom .sidebar-1' ); 1109 } 1110 1111 // Join elements. 1112 stickyElements = stickyElements.join( ',' ); 1113 1114 // Sticky nav visible. 1115 $( document ).on( 'sticky-nav-visible', function() { 1116 var navBarHeight = $( '.navbar-primary' ).innerHeight(); 1117 1118 $( stickyElements ).css( 'top', 32 + navBarHeight + 'px' ); 1119 } ); 1120 1121 // Sticky nav hide. 1122 $( document ).on( 'sticky-nav-hide', function() { 1123 $( stickyElements ).css( 'top', 32 + 'px' ); 1124 } ); 1125 1126 } ); 1127 /** 1128 * Focus Shadow on Subscribe Field 1129 */ 1130 1131 $( '.pk-subscribe-form-wrap input' ).focus( function() { 1132 $( this ).closest( 'form' ).addClass( 'cs-form-focus' ); 1133 } ); 1134 1135 $( '.pk-subscribe-form-wrap input' ).blur( function() { 1136 $( this ).closest( 'form' ).removeClass( 'cs-form-focus' ); 1137 } ); 1138 $( document ).ready( function() { 1139 objectFitImages(); 1140 } ); 1141 1142} )( 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.