PageSourceSearch

https://jobprogress.com/index_files/rotating_tweet.js

js jobprogress.com collected 2026-10-02 16:47:07 UTC 13,458 bytes, 310 lines download raw bytes

1/*
2 Script to cycle the rotating tweets
3*/
4jQuery(document).ready(function() {
5	if(navigator.doNotTrack != 'yes' && navigator.doNotTrack != 1 && window.doNotTrack != 1 && navigator.msDoNotTrack != 1 && jQuery('div.follow-button').length ) {
6		// Do (or don't do) stuff.
7		/* And call the Twitter script while we're at it! */
8		window.twttr = (function(d, s, id) {
9		  var js, fjs = d.getElementsByTagName(s)[0],
10			t = window.twttr || {};
11		  if (d.getElementById(id)) return t;
12		  js = d.createElement(s);
13		  js.id = id;
14		  js.src = "https://platform.twitter.com/widgets.js";
15		  fjs.parentNode.insertBefore(js, fjs);
16		 
17		  t._e = [];
18		  t.ready = function(f) {
19			t._e.push(f);
20		  };
21		 
22		  return t;
23		}(document, "script", "twitter-wjs"));
24	};
25	jQuery('.rotatingtweets').each(function() {
26		/* Get the ID of the rotating tweets div - and parse it to get rotation speed and rotation fx */
27		var rotate_id = "#"+this.id,
28			rotate_class = "."+this.id,
29			rotate_timeout = jQuery(this).data('cycle-timeout'),
30			rotate_fx = jQuery(this).data('cycle-fx'),
31			rotate_speed = jQuery(this).data('cycle-speed'),
32			rotate_pager = jQuery(this).data('cycle-pager'),
33			rotate_pager_template = jQuery(this).data('cycle-pager-template'),
34			rotate_wp_debug = jQuery(this).hasClass('wp_debug');
35		/* Handling old versions of jQuery that handle .data differently */
36		if ( rotate_timeout === undefined ) {
37			var rotate_id_split = rotate_id.split('_');
38			rotate_timeout = rotate_id_split[1];
39			rotate_fx = rotate_id_split[2];
40			rotate_speed = rotate_id_split[3];
41		}
42		if( typeof console === "undefined" || typeof console.log === "undefined" ) {
43			rotate_wp_debug = false;
44		}
45		/* If the rotation type has not been set - then set it to scrollUp */
46		if(rotate_fx == null){rotate_fx = 'scrollUp'};
47		var rt_height_px = 'auto';
48		/* Now find the widget container width */
49		// Take the smaller of the parent and grandparent
50		var rt_parent = jQuery(rotate_id).parent(),
51			rt_grandparent = jQuery(rotate_id).parent().parent();
52		var rt_target_container_width = Math.min (
53				rt_parent.innerWidth() - parseFloat(rt_parent.css('padding-left')) - parseFloat(rt_parent.css('padding-right')),
54				rt_grandparent.innerWidth() - parseFloat(rt_grandparent.css('padding-left')) - parseFloat(rt_grandparent.css('padding-right'))  - parseFloat(rt_parent.css('padding-left')) - parseFloat(rt_parent.css('padding-right')) - parseFloat(rt_parent.css('margin-left')) - parseFloat(rt_parent.css('margin-right'))
55			);
56		// Get the size of the parent box and subtract any padding
57		var rt_target_width = rt_target_container_width - parseFloat(jQuery(this).css('padding-left')) - parseFloat(jQuery(this).css('padding-right'))  - parseFloat(jQuery(this).css('margin-left')) - parseFloat(jQuery(this).css('margin-right'))  - parseFloat(jQuery(this).css('border-left')) - parseFloat(jQuery(this).css('border-right') ) ;
58		var rt_fit = 1;
59		if( rt_target_width == null ) {
60			rt_fit = 0;
61		}
62		if(rotate_wp_debug) {
63			console.log('============================');
64			console.log('self_width = '+jQuery(rotate_id).innerWidth());
65			console.log('parent_width = '+rt_parent.innerWidth());
66			console.log('grandparent_width = '+rt_grandparent.innerWidth());
67			console.log('rt_target_container_width = '+rt_target_container_width);
68			console.log('rt_target_width = '+rt_target_width);
69			console.log('rotate_timeout = '+rotate_timeout);
70			console.log('rotate_speed = '+rotate_speed);
71			console.log('rotate_fx = '+rotate_fx);
72			console.log('rotate_pager = '+rotate_pager);
73			console.log('rotate_pager_template = '+rotate_pager_template);
74		}
75		/* If we're displaying an 'official' tweet, reset all the heights - this option is currently switched off! */
76//		var rt_official_child = rotate_id + ' .twitter-tweet';
77//		var rt_official_num = jQuery(rt_official_child).length;
78//		if (rt_official_num > 0) rt_height_px = '211px';
79		var rotate_vars = {	
80			pause: 1,
81			height: rt_height_px,
82			timeout: rotate_timeout,
83			cleartypeNoBg: true,
84			width: rt_target_width,
85			prev: rotate_class + '_rtw_prev',
86			next: rotate_class + '_rtw_next',
87			fx: rotate_fx,
88			fit: rt_fit,
89			speed: rotate_speed
90		}
91		if( rotate_timeout > 0) {
92			rotate_vars.timeout = rotate_timeout;
93		} else {
94			rotate_vars.continuous = true;
95			rotate_vars.easing = 'linear';
96		}
97		if(typeof rotate_pager !== "undefined" ) {
98			rotate_vars.pager = rotate_id + '_rtw_pager';
99			if(typeof rotate_pager_template !== "undefined") {
100				rotate_vars.pagerAnchorBuilder = function(idx, slide) { 
101					return rotate_pager_template; 
102				} 
103			}
104		}
105		if(rotate_wp_debug) {
106			console.log(rotate_vars);
107		}
108		/* Call the rotation */
109		jQuery(rotate_id).cycle(rotate_vars);
110		/* If the height of the rotating tweet box is zero - kill the box and start again */
111		var rt_height = jQuery(rotate_id).height();
112		if(rotate_wp_debug) {
113			console.log('Initial height: '+rt_height );
114		}
115		if( rt_height < 1 ) {	
116			var rt_children_id = rotate_id + ' .rotatingtweet';
117			var rt_height = 0;
118			/* Go through the tweets - get their height - and set the minimum height */
119			jQuery(rt_children_id).each(function() {
120				var rt_tweet_height = jQuery(this).height();
121				if(rt_tweet_height > rt_height) {
122					rt_height = rt_tweet_height;
123				}
124			});
125			rt_height = rt_height + 20;
126			rt_height_px = rt_height + 'px';
127			rotate_vars.height = rt_height_px;
128			if(rotate_wp_debug) {
129				console.log('Resetting height to rt_height_px '+rt_height_px);
130			}
131			jQuery(rotate_id).cycle('destroy');
132			jQuery(rotate_id).cycle(rotate_vars);
133		}
134
135		/* Only do this if we're showing the official tweets - the first select is the size of the info box at the top of the tweet */
136		var rt_children_id = rotate_id + ' .rtw_info';
137		/* This shows the width of the icon on 'official version 2' - i.e. the one where the whole tweet is indented */
138		var rt_icon_id = rotate_id + ' .rtw_wide_icon a img';
139		/* This shows the width of the block containing the icon on 'official version 2' - i.e. the one where the whole tweet is indented */
140		var rt_block_id = rotate_id + ' .rtw_wide_block';
141		var rt_official_num = jQuery(rt_children_id).length;
142		var rt_children_meta_id = rotate_id + ' .rtw_meta';
143		if(rt_official_num > 0) {
144			/* Now run through and make sure all the boxes are the right size */
145			if(jQuery(rt_icon_id).length > 0) {
146				if(rotate_wp_debug) {
147					console.log('Adjusting widths for \'Official Twitter Version 2\'');
148					console.log('- Width of Rotating Tweets container: ' + jQuery(this).width());
149					console.log('- Width of the icon container: ' + jQuery(rt_icon_id).show().width());
150				};
151				var rt_icon_width = 0;
152				jQuery(rt_icon_id).each( function() {
153					newiconsize = jQuery(this).width();
154					if(newiconsize>rt_icon_width) {
155						rt_icon_width = newiconsize;
156					}
157				});
158				if(rotate_wp_debug) {
159					console.log('- Width of the icon: '+rt_icon_width);
160				};
161				if(rt_icon_width > 0) {
162/*
163					jQuery(rt_block_id).each( function() {
164						jQuery(this).css('padding-left', ( rt_icon_width + 10 ) + 'px');
165					});
166*/
167					jQuery(rt_block_id).css('padding-left', ( rt_icon_width + 10 ) + 'px');
168				}
169			}
170			/* Now get the padding-left dimension (if it exists) and subtract it from the max width	*/
171			if(rotate_wp_debug) {
172				console.log ('Now check for \'padding-left\'');
173				console.log ('- leftpadding - text : '+ jQuery(rt_block_id).css('padding-left') + ' and value: ' +parseFloat(jQuery(rt_block_id).css('padding-left')));
174			};
175			var rt_max_width = jQuery(rotate_id).width();
176			if( typeof jQuery(rt_block_id).css('padding-left') != 'undefined' ) {
177				rt_max_width = rt_max_width - parseFloat(jQuery(rt_block_id).css('padding-left')) - 1 ;
178				if(rotate_wp_debug) {
179					console.log('- Padding is not undefined');
180				};
181			} else if(rotate_wp_debug) {
182 				console.log('- Padding IS undefined - leave width unchanged');
183			}
184			if(rotate_wp_debug) {
185				console.log('- rt_max_width: ' + rt_max_width);
186			};
187			/* Go through the tweets - and set the minimum width */
188			jQuery(rt_children_id).width(rt_max_width);
189			/* Go through the tweets - and set the minimum width */
190			jQuery(rt_children_meta_id).width(rt_max_width);
191		};
192		// Now the responsiveness code
193		// First get the measures we will use to track change
194		var rt_resize_width_old_parent = rt_parent.innerWidth(),
195			rt_resize_width_old_grandparent = rt_grandparent.innerWidth(),
196			rt_resize_width_new_parent = rt_resize_width_old_parent,
197			rt_resize_width_new_grandparent = rt_resize_width_old_grandparent,
198			rt_resize_parent_change = 0,
199			rt_resize_grandparent_change = 0;
200		// Now get the starting measures
201		var rt_resize_target_width = jQuery(rotate_id).width(),
202			rt_resize_target_main = jQuery(rotate_id + ' .rtw_main').width(),
203			rt_resize_target_tweet = jQuery(rotate_id + ' .rotatingtweet').width(),
204			rt_resize_target_meta = jQuery(rotate_id + ' .rtw_meta').width();
205		jQuery(window).resize(function() {
206			if(rotate_wp_debug) {
207				console.log("== Window Resize Detected ==");
208			}
209			rt_parent = jQuery(rotate_id).parent();
210			rt_grandparent = rt_parent.parent();
211			rt_resize_width_new_parent = rt_parent.innerWidth();
212			rt_resize_width_new_grandparent = rt_grandparent.innerWidth();
213			
214			// Now calculate the largest and smallest change in size
215			rt_resize_parent_change = rt_resize_width_new_parent - rt_resize_width_old_parent;
216			rt_resize_grandparent_change = rt_resize_width_new_grandparent - rt_resize_width_old_grandparent;		
217			
218			// Now decide how much to change things
219			rt_resize_change = rt_resize_parent_change;
220			if(rt_resize_change == 0) {
221				rt_resize_change = rt_resize_grandparent_change;
222			}			
223			if(rotate_wp_debug) {
224				console.log('Parent change: '+rt_resize_parent_change);
225				console.log('Grandparent change: '+rt_resize_grandparent_change);
226				console.log('Old box width: '+rt_resize_target_width);
227				console.log('New target width: '+ (rt_resize_target_width + rt_resize_change));
228				console.log('rt_max_width: '+ (rt_resize_target_width + rt_resize_change));
229			}
230			if(rt_max_width == null) {
231				rt_max_width = rt_resize_target_tweet;
232			}
233			if(rt_resize_change != 0) {
234				var rt_oldheight = 0;
235				var rt_oldcontainerheight = jQuery(rotate_id).height();
236				jQuery(rotate_id + ' .rotatingtweet').height('auto');
237				jQuery(rotate_id + ' .rotatingtweet').each( function() {
238					var rt_test_height = jQuery(this).height();
239					if(rotate_wp_debug) {
240						console.log('Old tweet height: '+ rt_test_height);
241					}
242					if(rt_test_height > rt_oldheight ) {
243						rt_oldheight = rt_test_height;
244					};
245				});
246				if(rotate_wp_debug) {
247					console.log('Old container height: '+ rt_oldcontainerheight);
248					console.log('Old height: '+ rt_oldheight);
249				}
250				var rt_old_box_height = jQuery(rotate_id).height();
251				if(rotate_wp_debug) {
252					console.log('Old container height' + rt_old_box_height )
253				}
254				jQuery(rt_children_id).width(rt_max_width + rt_resize_change );
255				jQuery(rt_children_meta_id).width(rt_max_width  + rt_resize_change );
256				jQuery(rotate_id + ' .rtw_main').width(rt_resize_target_main  + rt_resize_change );
257				jQuery(rotate_id + ' .rotatingtweet').width(rt_resize_target_tweet  + rt_resize_change );
258				jQuery(rotate_id + ' .rtw_meta').width(rt_resize_target_meta  + rt_resize_change );
259				jQuery(rotate_id).width(rt_resize_target_width + rt_resize_change );
260				// Now update the variables
261				rt_resize_target_width = rt_resize_target_width + rt_resize_change;
262				rt_resize_target_main = rt_resize_target_main +  rt_resize_change;
263				rt_resize_target_tweet = rt_resize_target_tweet  + rt_resize_change;
264				rt_max_width = rt_max_width   + rt_resize_change;
265				rt_resize_target_meta = rt_resize_target_meta   + rt_resize_change;
266				rt_resize_width_old_parent = rt_parent.innerWidth();
267				rt_resize_width_old_grandparent = rt_grandparent.innerWidth();
268				// Now we need to fix the heights
269				var rt_newheight = 0;
270				jQuery(rotate_id + ' .rotatingtweet').height('auto');
271				jQuery(rotate_id + ' .rotatingtweet').each( function() {
272					var rt_test_height = jQuery(this).height();
273					if(rotate_wp_debug) {
274						console.log('New tweet height: '+ rt_test_height);
275					}
276					if(rt_test_height > rt_newheight ) {
277						rt_newheight = rt_test_height;
278					};
279				});
280				if(rotate_wp_debug) {
281					console.log('New height: '+ rt_newheight);
282				}
283				if(rt_newheight > 0) {
284					jQuery(rotate_id).height( Math.max( rt_oldcontainerheight + rt_newheight - rt_oldheight,rt_newheight) );
285				}
286			}
287		});
288	});
289	// Script to show mouseover effects when going over the Twitter intents
290	jQuery('.rtw_intents a').hover(function() {
291		var rtw_src = jQuery(this).find('img').attr('src');
292		var clearOutHovers = /_hover.png$/;
293		jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
294		var rtw_src = jQuery(this).find('img').attr('src');
295		var srcReplacePattern = /.png$/;
296		jQuery(this).find('img').attr('src',rtw_src.replace(srcReplacePattern,"_hover.png"));
297	},function() {
298		var rtw_src = jQuery(this).find('img').attr('src');
299		var clearOutHovers = /_hover.png/;
300		jQuery(this).find('img').attr('src',rtw_src.replace(clearOutHovers,".png"));
301	});
302	jQuery('.rtw_wide .rtw_intents').hide();
303	jQuery('.rtw_expand').show();
304	jQuery('.rotatingtweets').has('.rtw_wide').hover(function() {
305		jQuery(this).find('.rtw_intents').show();
306	},function() {
307		jQuery(this).find('.rtw_intents').hide();
308	});
309});
310

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.