PageSourceSearch

https://gadgetfee.com/wp-content/themes/spotlight/js/scripts.js?ver=1.7.7

js gadgetfee.com collected 2026-10-03 21:50:32 UTC 27,943 bytes, 1,131 lines download raw bytes

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