PageSourceSearch

https://mydocumentedlife.org/wp-content/themes/opti/js/slider.js?ver=1.2

js mydocumentedlife.org collected 2026-09-24 10:24:40 UTC 3,315 bytes, 125 lines download raw bytes

1/**
2 * slider.js v1.2
3 * Created by Ben Gillbanks <http://www.binarymoon.co.uk/>
4 * Available under GPL2 license
5 */
6/* global js_i18n:true */
7
8( function( $ ) {
9	$.fn.elementalSlides = function( options ) {
10
11		var total_slides = 0;
12
13		var defaults = {
14			interval: 4000,
15			group_selector: 'article',
16			nav_arrows: false,
17		};
18		options = $.extend( defaults, options );
19
20		return this.each( function() {
21
22			var start_timer = function() {
23				clearInterval( timer );
24				timer = setInterval( function() { next(); }, interval );
25			};
26
27			var display = function( slide ) {
28				articles.fadeOut( 500 ).removeClass( 'current' ).filter( slide ).fadeIn( 500 ).addClass( 'current' );
29			};
30
31			var next = function() {
32				var next_slide = nav.find( '.selected' ).removeClass( 'selected' ).next();
33				if ( next_slide.length === 0 ) {
34					next_slide = nav.find( ':first' );
35				}
36				next_slide.addClass( 'selected' );
37				display( next_slide.attr( 'href' ) );
38			};
39
40			var previous = function() {
41				var next_slide = nav.find( '.selected' ).removeClass( 'selected' ).prev();
42				if ( next_slide.length === 0 ) {
43					next_slide = nav.find( ':last' );
44				}
45				next_slide.addClass( 'selected' );
46				display( next_slide.attr( 'href' ) );
47			};
48
49			var $this = $( this );
50			var timer;
51			var slide_count = 0;
52
53			// remove empty elements
54			$this.children( options.group_selector ).filter( function() {
55				return $.trim( this.innerHTML ).length < 1;
56			} ).remove();
57
58			var articles = $this.children( options.group_selector );
59			var nav = $this.find( 'nav' );
60			var interval = $this.data( 'interval' ) || options.interval;
61
62			// quit if there is nothing to display
63			if ( articles.length <= 1 ) {
64				// make sure the slides are visible
65				articles.fadeIn();
66				return;
67			}
68
69			// create nav if it doesn't exist
70			if ( nav.length === 0 ) {
71				nav = $( '<nav></nav>' );
72				$this.prepend( nav );
73			}
74
75			// loop through articles and create buttons for the nav
76			articles.each( function() {
77				slide_count++;
78				total_slides++;
79				$( this ).attr( 'id', 'slide_' + total_slides );
80				var tab = $( '<a href="#slide_' + total_slides + '">' + slide_count + '</a>' );
81				nav.append( tab );
82			} );
83
84			// click navigation items
85			nav.find( 'a' ).click( function() {
86				display( this.hash );
87				nav.find( 'a' ).removeClass( 'selected' );
88				$( this ).addClass( 'selected' );
89				start_timer();
90				return false;
91			} );
92
93			// stop the animation when the mouse hovers the content (so user is reading content)
94			$this[ ( $.fn.hoverIntent ) ? 'hoverIntent' : 'hover' ]( function() {
95				clearInterval( timer );
96			}, function() {
97				start_timer();
98			} );
99
100			// add next and previous links to the slider nav
101			if ( defaults.nav_arrows ) {
102				var arrow_next = $( '<a href="#next" class="arrow arrow-next"><span>' + js_i18n.next + '</span></a>' );
103				arrow_next.click( function() {
104					next();
105					start_timer();
106					return false;
107				} );
108				$this.append( arrow_next );
109
110				var arrow_prev = $( '<a href="#prev" class="arrow arrow-prev"><span>' + js_i18n.prev + '</span></a>' );
111				arrow_prev.click( function() {
112					previous();
113					start_timer();
114					return false;
115				} );
116				$this.append( arrow_prev );
117			}
118
119			nav.find( ':first' ).click();
120			start_timer();
121
122		} );
123
124	};
125} )( 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.