PageSourceSearch

https://www.loonwatch.com/files/wp-content/themes/canvas/includes/js/general.js

js loonwatch.com collected 2026-10-02 07:04:45 UTC 4,190 bytes, 119 lines download raw bytes

1/*-----------------------------------------------------------------------------------*/
2/* Run scripts on jQuery(document).ready() */
3/*-----------------------------------------------------------------------------------*/
4jQuery(document).ready(function(){
5
6	// FitVids - Responsive Videos
7	jQuery( '.widget_video, .panel, .video' ).fitVids();
8	if ( window.innerWidth < 768 ) {
9		jQuery( '.entry' ).fitVids();
10	}
11
12	// Add class to parent menu items with JS until WP does this natively
13	jQuery( 'ul.sub-menu, ul.children' ).parent( 'li' ).addClass( 'parent' );
14
15/*-----------------------------------------------------------------------------------*/
16/* Navigation */
17/*-----------------------------------------------------------------------------------*/
18
19	// Fix dropdowns in Android
20	if ( navigator.userAgent.match(/Android/i) ) {
21		jQuery( '.nav li:has(ul)' ).doubleTapToGo();
22	}
23
24	// Add the 'show-nav' class to the body when the nav toggle is clicked
25	jQuery( '.nav-toggle' ).click(function(e) {
26
27		// Prevent default behaviour
28		e.preventDefault();
29
30		// Add the 'show-nav' class
31		jQuery( 'body' ).toggleClass( 'show-nav' );
32
33		// Check if .top-navigation already exists
34		if ( jQuery( '#navigation' ).find( '.top-navigation' ).size() ) return;
35		if ( jQuery( '#navigation' ).find( '.top-menu' ).size() ) return;
36
37		// If it doesn't, clone it (so it will still appear when resizing the browser window in desktop orientation) and add it.
38		jQuery( '#top .top-menu' ).clone().appendTo( '#navigation .menus' );
39		jQuery( '#top .top-navigation' ).clone().appendTo( '#navigation .menus' );
40	});
41
42	// Remove the 'show-nav' class from the body when the nav-close anchor is clicked
43	jQuery('.nav-close').click(function(e) {
44
45		// Prevent default behaviour
46		e.preventDefault();
47
48		// Remove the 'show-nav' class
49		jQuery( 'body' ).removeClass( 'show-nav' );
50	});
51
52	// Remove 'show-nav' class from the body when user tabs outside of #navigation on handheld devices
53	var hasParent = function(el, id) {
54        if (el) {
55            do {
56                if (el.id === id) {
57                    return true;
58                }
59                if (el.nodeType === 9) {
60                    break;
61                }
62            }
63            while((el = el.parentNode));
64        }
65        return false;
66    };
67
68	if (jQuery(window).width() < 767) {
69		if (jQuery('body')[0].addEventListener){
70			document.addEventListener('touchstart', function(e) {
71	        if ( jQuery( 'body' ).hasClass( 'show-nav' ) && !hasParent( e.target, 'navigation' ) ) {
72		        // Prevent default behaviour
73		        e.preventDefault();
74
75		        // Remove the 'show-nav' class
76		        jQuery( 'body' ).removeClass( 'show-nav' );
77	        }
78	    }, false);
79		} else if (jQuery('body')[0].attachEvent){
80			document.attachEvent('ontouchstart', function(e) {
81	        if ( jQuery( 'body' ).hasClass( 'show-nav' ) && !hasParent( e.target, 'navigation' ) ) {
82		        // Prevent default behaviour
83		        e.preventDefault();
84
85		        // Remove the 'show-nav' class
86		        jQuery( 'body' ).removeClass( 'show-nav' );
87	        }
88	    });
89		}
90	}
91
92/*-----------------------------------------------------------------------------------*/
93/* Add rel="lightbox" to image links if the lightbox is enabled */
94/*-----------------------------------------------------------------------------------*/
95
96if ( jQuery( 'body' ).hasClass( 'has-lightbox' ) && ! jQuery( 'body' ).hasClass( 'portfolio-component' ) /* && ! jQuery( 'body' ).hasClass( 'woocommerce' ) */ ) {
97	jQuery( 'a[href$=".jpg"], a[href$=".jpeg"], a[href$=".gif"], a[href$=".png"]' ).each( function () {
98		var imageTitle = '';
99		if ( jQuery( this ).next().hasClass( 'wp-caption-text' ) ) {
100			imageTitle = jQuery( this ).next().text();
101		}
102
103		if ( '' != imageTitle ) {
104			jQuery( this ).attr( 'title', imageTitle );
105		}
106
107		if ( jQuery( this ).parents( '.gallery' ).length ) {
108			var galleryID = jQuery( this ).parents( '.gallery' ).attr( 'id' );
109			jQuery( this ).attr( 'rel', 'lightbox[' + galleryID + ']' );
110		} else {
111			jQuery( this ).attr( 'rel', 'lightbox' );
112		}
113	});
114
115	jQuery( 'a[rel^="lightbox"]' ).prettyPhoto({social_tools: false});
116}
117
118}); // End jQuery()
119

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.