PageSourceSearch

https://www.dickmorris.com/wp-content/plugins/promotion-slider/js/promo_slider.js?ver=7.1.1

js dickmorris.com collected 2026-09-25 18:47:06 UTC 6,171 bytes, 174 lines download raw bytes

1// Function returns a random number between 1 and n
2function rand(n){return(Math.floor(Math.random()*n+1));}
3
4jQuery(document).ready(function(){
5 
6  // Disable HTML title attribute for slider images
7  jQuery('.promo_slider img').removeAttr('title');
8 
9  // Get all instances of promo_slider on the page
10  var sliders = jQuery('.promo_slider_wrapper');
11  
12  // Cycle through each slider
13  jQuery.each(sliders, function(){
14	
15	// Define current slider
16	var currentSlider = jQuery(this);
17	var thisSlider = jQuery('.promo_slider', currentSlider);
18	
19	// Get all panels
20    var panels = jQuery('.panel', thisSlider);
21	
22	// Get total count of panels
23    var panelCount = panels.length;
24	
25	// Set number for first panel
26	if( promo_slider_options.startOn == 'first' ) var initialPanel = 1;
27	else var initialPanel = rand(panelCount);
28	if( currentSlider.hasClass('random') ) initialPanel = rand(panelCount);
29	if( currentSlider.hasClass('first') ) initialPanel = 1;
30	
31	// Should we pause the slider on mouseover?
32	var pauseOnMouseover;
33	if( currentSlider.hasClass('pause') ) pauseOnMouseover = true;
34	else pauseOnMouseover = false;
35	
36	// Assign variable for setInterval
37	var sliderInterval;
38	
39	// Set time delay
40	var timeDelay = promo_slider_options.timeDelay;
41	if( jQuery('.promo_slider_time_delay', thisSlider).html() ){
42		timeDelay = jQuery('.promo_slider_time_delay', thisSlider).html();
43	}
44	
45	// Set auto advance variable
46	var autoAdvance = promo_slider_options.autoAdvance;
47	if( thisSlider.hasClass('auto_advance') ) autoAdvance = true;
48	if( thisSlider.hasClass('no_auto_advance') ) autoAdvance = false;
49	if( panelCount < 2 ) autoAdvance = false;
50	
51	// Set navigation option
52	var navOption = promo_slider_options.nav_option;
53	if( currentSlider.hasClass('default_nav') ) navOption = 'default';
54	else if( currentSlider.hasClass('fancy_nav') ) navOption = 'fancy';
55	else if( currentSlider.hasClass('links_nav') ) navOption = 'links';
56	else if( currentSlider.hasClass('thumb_nav') ) navOption = 'thumb';
57	else navOption = false;
58	
59	// Hide all panels
60	panels.hide();
61	
62	// Show initial panel and add class 'current' to active panel
63	jQuery('.panel-' + initialPanel, currentSlider).show().addClass('current');
64	
65	if(panelCount > 1 && (navOption == 'default' || navOption == 'fancy' || navOption == 'thumb') ){
66
67	  jQuery('.promo_slider_nav').show();
68	  jQuery('.promo_slider_thumb_nav').show();
69	
70	  if(navOption == 'fancy' || navOption == 'default'){
71		  // Generate HTML for navigation
72		  var navHTML = '';
73		  jQuery.each(panels, function(index, object){
74			// Set panel title
75			panelTitle = jQuery('.panel-'+(index+1)+' span.panel-title', currentSlider).html();
76			  newSpan = '<span class="'+(index+1)+'" title="'+panelTitle+'">'+(index+1)+'</span>';
77			  if( (index + 1) != panelCount){newSpan = newSpan + '<b class="promo_slider_sep"> | </b>';}
78			navHTML = navHTML + newSpan;
79		  });
80		  
81		  // Insert HTML into nav
82		  jQuery('.slider_selections', currentSlider).html(navHTML);
83	  }
84	  
85	  // Set click functions for each span in the slider nav
86	  var slideNav = jQuery('.slider_selections span', currentSlider);
87	  jQuery.each(slideNav, function(index, object){
88		jQuery(object).click(function(){ 
89		  clearInterval(sliderInterval);
90		  if( !jQuery(object).hasClass('current') ) progress(jQuery(object).attr('class'), currentSlider, panelCount);
91		  if(autoAdvance) sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000));
92		});
93	  });
94	  
95	  // Set active span class to 'current'
96	  jQuery('.slider_selections span[class=' + initialPanel + ']', currentSlider).addClass('current');
97	  
98	}
99	
100	// Create click functions for navigational elements
101	jQuery('.move_forward', currentSlider).click(function(){ 
102	  clearInterval(sliderInterval);
103	  progress('forward', currentSlider, panelCount);
104	  if(autoAdvance) sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000));
105	});
106	jQuery('.move_backward', currentSlider).click(function(){
107	  clearInterval(sliderInterval);
108	  progress('backward', currentSlider, panelCount);
109	  if(autoAdvance) sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000));
110	});
111	
112	
113	if( autoAdvance ){
114	
115		// Begin auto advancement of slides
116		sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000));
117	
118		if( pauseOnMouseover ){
119		
120			// Pause slide advancement on mouseover
121			jQuery(thisSlider).mouseover(function(){
122				clearInterval(sliderInterval);
123			});
124		
125			// Continue slide advancement on mouseout
126			jQuery(thisSlider).mouseout(function(){
127				sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000));
128			});
129		
130		}
131		
132	}
133	
134  });
135  
136  // Progress to selected panel
137  function progress(value, currentSlider, panelCount){
138	  
139	  // Find number of current panel
140	  var currentValue = jQuery('div.promo_slider > .panel', currentSlider).index(jQuery('div.panel.current', currentSlider)) + 1;
141
142	  // Set value of new panel
143  	  if(value == 'forward'){
144		var newValue = currentValue + 1;
145		if(newValue > panelCount){newValue = 1;}
146	  }
147	  else if(value == 'backward'){
148		var newValue = currentValue - 1;
149		if(newValue == 0){newValue = panelCount;}
150	  }
151	  else{
152		var newValue = value;
153	  }
154	  
155	  // Assign variables for ease of use
156	  var currentItem = jQuery('.panel-' + currentValue, currentSlider);
157	  var newItem = jQuery('.panel-' + newValue, currentSlider);
158	  var currentSpan = jQuery('.slider_selections span.current', currentSlider);
159	  var newSpan = jQuery('.slider_selections span.' + newValue, currentSlider);
160	  
161	  // Add / Remove classes
162	  currentItem.removeClass('current');
163	  newItem.addClass('current');
164	  currentSpan.removeClass('current');
165	  newSpan.addClass('current');
166	  
167	  // Fade in / out
168	  currentItem.fadeOut('fast', function(){
169		newItem.fadeIn('fast');
170	  });
171
172  }
173
174});

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.