PageSourceSearch

https://uca.edu/admissions/wp-content/plugins/image-widget-plus/src/resources/js/public.js?ver=1.0.2

js uca.edu collected 2026-09-24 08:54:48 UTC 4,597 bytes, 176 lines download raw bytes

1/**
2 * Image Widget Plus
3 *
4 * Copyright (c) 2017 Modern Tribe, Inc.
5 */
6( function( $, d ) {
7
8	/**
9	 * Prevents timer-based thickbox tweaks from restarting.
10	 */
11	t = {
12		thickbox_timer_start: null
13	};
14
15	/**
16	 * Init
17	 */
18	t.init = function() {
19
20		// Find all Image Widget Plus slideshows on the page.
21		$widgets = $( d.querySelectorAll( '.tribe-image--slideshow' ) );
22
23		// Instances of Wallop slideshows.
24		$slideshows = [];
25
26		// Setup Wallop slideshows and associated functions.
27		$widgets.each( function( i, widget ) {
28
29			// Init Wallop.
30			$slideshows[ i ] = new Wallop( widget, {
31				buttonPreviousClass : 'tribe-image--previous',
32				buttonNextClass     : 'tribe-image--next'
33			});
34
35			// Set up bullets.
36			t.bullets( widget, $slideshows[ i ] );
37
38			// Set up highlighting of current bullet and updating of meta.
39			$slideshows[ i ].on( 'change', function( e ) {
40				t.change( e.detail.currentItemIndex, widget, $slideshows[ i ] );
41			});
42		});
43
44		// Prevent ThickBox activation if viewport is <= 480px.
45		$( '.tribe_image_plus a.thickbox' ).click( function( e ) {
46			if ( document.body.clientWidth <= 480 ) {
47				return false;
48			}
49		});
50
51		// Ensure non-URL images don't open new windows/tabs when clicked.
52		$( d.querySelectorAll( '.tribe-image--no-link' ) ).on( 'click', function( e ) {
53			e.preventDefault();
54		});
55
56		$( 'body' ).on( 'click', '.thickbox', function( e ) {
57			t.thickbox_timer_start = Date.now();
58			setTimeout( t.update_thickbox_content, 50 );
59		} );
60
61		// add keyboard navigation of thickbox
62		$( document ).on( 'keydown', 'body.modal-open', function( e ) {
63			// left arrow
64			if ( 37 === e.which ) {
65				$( '#TB_prev' ).click();
66			}
67			// right arrow
68			else if ( 39 === e.which ) {
69				$( '#TB_next' ).click();
70			}
71		} );
72	};
73
74	/**
75	 * Updates thickbox content after the thickbox has rendered.
76	 */
77	t.update_thickbox_content = function() {
78
79		// Don't restart timer if TB_secondLine exists or we've exceeded 10 seconds.
80		if (
81			! $( document.getElementById( 'TB_secondLine' ) ).length
82			&& t.thickbox_timer_start + 10000 >= Date.now()
83		) {
84			setTimeout( t.update_thickbox_content, 5 );
85			return;
86		}
87
88		var $window = $( d.getElementById( 'TB_window' ) );
89
90		$( '#TB_next, #TB_prev' ).on( 'click', function( e ) {
91			t.thickbox_timer_start = Date.now();
92			setTimeout( t.update_thickbox_content, 50 );
93		} );
94
95		// If only 1 image in this thickbox, add a class we can use for styling.
96		if ( ! $( '#TB_next, #TB_prev' ).length ) {
97			$window.addClass( 'tribe-image--thickbox-single' );
98		}
99
100		// if there isn't a caption, add a class indicating that for styling
101		var $caption = $( document.getElementById( 'TB_caption' ) ).clone();
102		$caption.find( '#TB_secondLine' ).remove();
103
104		if ( '' === $.trim( $caption.text() ) ) {
105			$window.addClass( 'tribe-image--no-caption' );
106		}
107
108		// adjust the arrow height
109		$caption = $( document.getElementById( 'TB_caption' ) );
110		var $arrows = $( '#TB_next, #TB_prev' ).first();
111		var caption_height = $caption.outerHeight();
112		var arrow_height = $arrows.first().outerHeight();
113		var height_delta = caption_height - arrow_height;
114		$arrows.css( 'bottom', ( height_delta / 2 ) + 'px' );
115	};
116
117	/**
118	 * Set up bullets pager on Image Widget Plus slideshows.
119	 */
120	t.bullets = function( widget, $slideshow ) {
121
122		$( widget ).find( '.tribe-image--dot' ).each( function( pos, dot ) {
123
124			// Make each bullet go to corresponding slide on click.
125			$( dot ).on( 'click', function( e ) {
126				e.preventDefault();
127				$slideshow.goTo( pos );
128			});
129		});
130	};
131
132	/**
133	 * Ensure the current bullet is highlighted, and show/hide meta as needed.
134	 */
135	t.change = function( i, widget, $slideshows ) {
136
137		var $widget = $( widget );
138
139		// Unhighlight the old bullet.
140		$widget.find( '.tribe-image--dot--current' ).removeClass( 'tribe-image--dot--current' );
141
142		// Highlight the new bullet.
143		$( $widget.find( '.tribe-image--dot' )[ i ] ).addClass( 'tribe-image--dot--current' );
144
145		// Update the slide number if it exists.
146		$widget.find( '.tribe-image--num-current' ).text( i + 1 );
147
148		// Hide the old meta.
149		$widget.find( '.tribe-image--meta--item' ).hide();
150
151		// Show the new meta.
152		$( $widget.find( '.tribe-image--meta--item' )[ i ] ).show();
153	};
154
155	/**
156	 * Document.ready.
157	 */
158	$( d ).ready( t.init() );
159
160	/**
161	 * Lazy loading.
162	 */
163	$( window ).load( function() {
164		$( d.querySelectorAll( '.tribe-image--lazy' ) ).imageloader();
165	});
166
167	/**
168	 * Hide thickbox lightboxes on resize.
169	 */
170	$( window ).resize( function() {
171		if ( $( d.getElementById( 'TB_window' ) ).length ) {
172			tb_remove();
173		}
174	});
175
176})( jQuery, document );

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.