PageSourceSearch

https://www.mattfoxcoaching.com/wp-content/themes/rise/js/script.js?v=2.13

js mattfoxcoaching.com collected 2026-10-09 22:40:02 UTC 39,012 bytes, 1,303 lines download raw bytes

1/*  
2 *
3 * Namespace for all the scripts implemented in the frontend
4 */
5if ( ThriveApp === undefined ) {
6	var ThriveApp = {};
7}
8
9var _isAdmin = 0;
10var _is_blankPage = 0;
11
12ThriveApp.is_theme_layout = false;
13
14ThriveApp.winWidth = jQuery( window ).width();
15ThriveApp.viewportHeight = jQuery( window ).height();
16
17jQuery( function () {
18	_isAdmin = jQuery( '#wpadminbar' ).length;
19	_is_blankPage = jQuery( '.bp-t' ).length;
20	if ( ! _is_blankPage ) {
21		ThriveApp.menuPositionTop = (
22			jQuery( "nav.right" ).length
23		) ? jQuery( "nav.right" ).position().top : 0;
24	}
25	ThriveApp.is_theme_layout = jQuery( '.bSe .awr' ).length + jQuery( '.bp-t .wrp' ).length ? true : false;
26	ThriveApp.menuResponsive();
27	ThriveApp.shortcodeTabsResize();
28	ThriveApp.setPageSectionHeight();
29	ThriveApp.bind_comments_handlers();
30	ThriveApp.check_comments_hash();
31	ThriveApp.videoShorcode();
32	ThriveApp.image_post_resize();
33	ThriveApp.blog_gallery();
34	jQuery( '.cdt' ).thrive_timer();
35	ThriveApp.post_format_gallery();
36	ThriveApp.bold_first_paragraph();
37	ThriveApp.grid_layout();
38	ThriveApp.bind_share_buttons();
39
40	jQuery( '.sm_icons, .scfm .ss' ).each( function () {
41		jQuery( this ).mouseover( function () {
42			jQuery( '.bubb', this ).css( 'left', function () {
43				return (
44					       jQuery( this ).parent().width() - jQuery( this ).width()
45				       ) / 2;
46			} ).show( 0 );
47		} );
48		jQuery( this ).mouseout( function () {
49			jQuery( '.bubb', this ).hide();
50		} );
51	} );
52
53	jQuery( ".tmw" ).hover(
54		function () {
55			jQuery( this ).find( '.tmm' ).slideDown();
56		}, function () {
57			jQuery( this ).find( '.tmm' ).slideUp();
58		}
59	);
60
61	jQuery( '.faqB' ).click( function () {
62		var $toggle = jQuery( this ).parents( '.faq' );
63		$toggle.toggleClass( 'oFaq' );
64		jQuery( '.faqC', $toggle ).slideToggle( 'fast' );
65		return false;
66	} );
67
68	jQuery( '.accss .acc-h' ).click( function () {
69		var accordion_element = jQuery( this ),
70			accordion_context = jQuery( this ).parents( '.accs' ),
71			accordion_parent = accordion_context.find( '.accss' );
72		if ( accordion_element.parent().hasClass( 'opac' ) ) {
73			return false;
74		}
75		accordion_element.parents( '.accs' ).find( '.opac' ).find( '.accsi' ).slideUp( function () {
76			accordion_parent.removeClass( 'opac' );
77		} );
78		accordion_element.next( '.accsi' ).slideDown( function () {
79			accordion_element.parents( '.accss' ).addClass( 'opac' );
80		} );
81	} );
82
83	if ( jQuery( ".thrive-borderless .wp-video-shortcode" ).length > 0 ) {
84		jQuery( ".thrive-borderless .wp-video-shortcode" ).css( 'width', '100%' );
85		jQuery( ".thrive-borderless div" ).css( 'width', '100%' );
86	}
87
88	ThriveApp.comments_page = 1;
89	if ( ThriveApp.lazy_load_comments == 1 ) {
90		jQuery( window ).scroll( ThriveApp.bind_scroll );
91		ThriveApp.load_comments();
92	}
93
94	jQuery( window ).trigger( 'scroll' );
95
96	jQuery( '#shf' ).on( 'click', function () {
97		jQuery( '.lrp.hid' ).slideToggle();
98	} );
99
100	jQuery( window ).resize( function () {
101		var winNewWidth = jQuery( window ).width();
102		var winNewViewportHeight = jQuery( window ).height();
103
104		if ( ThriveApp.winWidth !== winNewWidth ) {
105			ThriveApp.delay( function () {
106				ThriveApp.menuResponsive();
107			}, 1 );
108		}
109		ThriveApp.winWidth = winNewWidth;
110		ThriveApp.viewportHeight = winNewViewportHeight;
111		ThriveApp.shortcodeTabsResize();
112		ThriveApp.videoShorcode();
113		ThriveApp.setVideoPosition();
114		ThriveApp.setPageSectionHeight();
115		ThriveApp.image_post_resize();
116		ThriveApp.grid_layout();
117	} );
118
119	jQuery( 'body' ).on( 'added_to_cart', function ( event, fragments, cart_hash, $thisbutton ) {
120		var _a = (
121			jQuery( fragments['.mini-cart-contents'] ).find( 'a.cart-contents-btn' )
122		);
123		jQuery( '.mobile-mini-cart' ).html( '' ).append( _a );
124	} );
125
126	if ( window.FB && window.FB.XFBML ) {
127		jQuery( '.fb-comments' ).each( function () {
128			window.FB.XFBML.parse( this.parentNode );
129		} );
130	}
131
132	ThriveApp.bind_masonry_layout();
133
134} );
135
136ThriveApp.grid_layout = function () {
137	if ( jQuery( '.gin' ).length > 0 ) {
138		var gridBlock = jQuery( '.gr-i' ),
139			noOfItems = gridBlock.length;
140
141		var setGridHeights = function ( noOfElementsOnRow ) {
142			var _condition = '';
143			for ( var i = 0; i < noOfItems; i += noOfElementsOnRow ) {
144				if ( noOfElementsOnRow == 3 ) {
145					_condition = ':eq(' + i + '),:eq(' + (i + 1) + '),:eq(' + (i + 2) + ')';
146				}
147
148				if ( noOfElementsOnRow == 2 ) {
149					_condition = ':eq(' + i + '),:eq(' + (i + 1) + ')';
150				}
151
152				var gridGroup = gridBlock.filter( _condition ),
153					elementHeights = jQuery( gridGroup ).map( function () {
154						gridGroup.css( 'height', '' );//reset height so that we can recalculate
155						return jQuery( this ).height();
156					} ),
157					maxHeight = Math.max.apply( null, elementHeights );
158				gridGroup.height( maxHeight );
159			}
160		}
161
162		if ( ThriveApp.winWidth >= 940 ) {
163			if ( jQuery( '.bSe' ).hasClass( 'fullWidth' ) ) {
164				setGridHeights( 3 );
165			} else {
166				setGridHeights( 2 );
167			}
168		} else if ( 940 > ThriveApp.winWidth && ThriveApp.winWidth >= 741 ) {
169			setGridHeights( 2 );
170		}
171
172		jQuery( '.bSe' ).find( '.tcb-window-width' ).removeClass( 'tcb-window-width' ).css( {
173			'width': 'auto',
174			'left': 'auto'
175		} );
176	}
177};
178
179ThriveApp.bold_first_paragraph = function () {
180	//bold first pagraph
181	if ( ThriveApp.post_type == 'post' ) {
182		jQuery( '.bSe .awr-i' ).children().each( function () {
183			var _this = jQuery( this );
184			var text = jQuery.trim( _this.text() ), html = _this.html().replace( /&nbsp;/g, '' );
185
186			if ( ! (
187					_this.is( ':hidden' )
188				) && ! (
189					_this.is( ':empty' )
190				) ) {
191				if ( _this.prop( "tagName" ) == 'P' ) {
192					if ( text != '' && html != '' ) {
193						_this.addClass( 'ifp' );
194						return false;
195					} else {
196						if ( ! (
197								text == '' && html == ''
198							) ) {
199							return false;
200						}
201					}
202				} else {
203					return false;
204				}
205			}
206		} );
207	}
208}
209
210ThriveApp.bind_masonry_layout = function () {
211	if ( jQuery( '.bSe' ).hasClass( 'mry' ) ) {
212		var container = document.querySelector( '.mry' ),
213			msnry = new Masonry( container, {
214				itemSelector: '.mry-i',
215				gutter: ".mry-g"
216			} );
217
218		jQuery( '.bSe' ).find( '.tcb-window-width' ).removeClass( 'tcb-window-width' ).css( {
219			'width': 'auto',
220			'left': 'auto'
221		} );
222	}
223};
224
225jQuery( window ).on( 'load', function () {
226	ThriveApp.bind_masonry_layout();
227	ThriveApp.resize_blank_page();
228} );
229
230ThriveApp.post_format_gallery = function () {
231	var _this_gallery = jQuery( ".hru" );
232	_this_gallery.each( function () {
233		jQuery( this ).attr( "data-count", jQuery( this ).find( ".thrive-gallery-item" ).length );
234		var _context = jQuery( this ),
235			_gallery_item = _context.find( '.hui' ),
236			_gallery_next_button = _context.find( '.gnext' ),
237			_gallery_prev_button = _context.find( '.gprev' ),
238			_gallery_dummy = _context.find( '.gallery-dmy' ),
239			_gallery_items = parseInt( _gallery_item.attr( 'data-count' ) ),
240			_gallery_carousel = _context.find( '.g-ul' );
241		_gallery_carousel.css( 'width', (
242			                                _gallery_items * 78
243		                                ) + 'px' );
244		jQuery( ".thrive-gallery-item", _context ).click( function () {
245			_gallery_item.attr( "data-index", jQuery( this ).attr( "data-index" ) );
246			_gallery_item.css( 'background-image', 'url(' + jQuery( this ).attr( "data-src" ) + ')' );
247			_gallery_dummy.attr( 'src', jQuery( this ).attr( "data-src" ) );
248			return false;
249		} );
250
251		_gallery_prev_button.click( function () {
252			var _current_index = parseInt( _gallery_item.attr( 'data-carousel' ) );
253			if ( _gallery_item.attr( 'data-carousel' ) > 0 ) {
254				_current_index --;
255				_gallery_item.attr( 'data-carousel', _current_index );
256				_gallery_carousel.css( 'left', - (
257					_current_index * 78
258				) + 'px' );
259			}
260			return false;
261		} );
262
263		_gallery_next_button.click( function () {
264			var _current_index = parseInt( _gallery_item.attr( 'data-carousel' ) );
265			if ( _current_index < _gallery_items - 4 ) {
266				_current_index ++;
267				_gallery_item.attr( 'data-carousel', _current_index );
268				_gallery_carousel.css( 'left', - (
269					_current_index * 78
270				) + 'px' );
271			}
272			return false;
273		} );
274	} );
275};
276
277ThriveApp.progress_bar = function () {
278	jQuery( '.pbfc:not(".stopCount")' ).each( function ( e ) {
279		if ( jQuery( this ).parents( '.nsd' ).hasClass( 'nsds' ) ) {
280			var progress_element = jQuery( this ),
281				progress = progress_element.attr( 'data-percent' ),
282				progress_box = progress_element.parents( '.pbs' ).find( '.pbbn' );
283			jQuery( {countNum: 0} ).animate( {countNum: progress}, {
284				duration: 3000,
285				easing: 'linear',
286				step: function () {
287					progress_box.text( Math.ceil( this.countNum ) );
288				},
289				done: function () {
290					if ( progress_box.text() == progress ) {
291						progress_element.addClass( 'stopCount' );
292					}
293				}
294			} );
295		}
296	} )
297}
298
299//ThriveApp.circle_fill = function () {
300//    jQuery('.fill-counter').each(function () {
301//        var percentage = jQuery(this).attr('data-percentage');
302//        if (jQuery(this).hasClass('nsds')) {
303//            jQuery('circle', this).attr('stroke-dasharray', percentage);
304//        }
305//    });
306//}
307
308ThriveApp.number_counter = function () {
309	jQuery( '.nbc.nsds' ).each( function () {
310		var counter_element = jQuery( '.nbcn', this ),
311			count_to = counter_element.attr( 'data-counter' );
312		var i = 0, t = null, step = 1;
313		if ( jQuery( this ).attr( 'data-started' ) == 'false' ) {
314			stepper( i, count_to );
315			jQuery( this ).attr( 'data-started', 'true' );
316		}
317
318		function stepper( i, count_to ) {
319			step = Math.ceil( count_to / 100 );
320
321			if ( i <= count_to ) {
322				counter_element.text( i );
323				i += step;
324				if ( i + step > count_to ) {
325					counter_element.text( count_to );
326					clearTimeout( t );
327				}
328				t = setTimeout( function () {
329					stepper( i, count_to )
330				}, 50 );
331			} else {
332				clearTimeout( t );
333			}
334		}
335	} );
336};
337
338ThriveApp.image_post_resize = function () {
339	jQuery( '.tt-dmy' ).css( {
340		'max-height': ThriveApp.viewportHeight,
341		'max-width': ThriveApp.winWidth
342	} );
343};
344
345ThriveApp.setPageSectionHeight = function () {
346	var containerWidthElement = jQuery( ' .wrp .bpd,.wrp .fullWidth , .wrp  .lnd ' ),
347		isFullWidth = containerWidthElement.length,
348		defaultWidth = isFullWidth ? (
349			ThriveApp.winWidth + 'px'
350		) : '100%';
351
352	//jQuery('.pdfbg.pdwbg').css({
353	//    'box-sizing': "border-box",
354	//    width: defaultWidth,
355	//    height: ThriveApp.viewportHeight + 'px'
356	//});
357
358	jQuery( '.pddbg, .scvps, .vt' ).css( 'max-width', ThriveApp.winWidth + 'px' );
359
360	jQuery( '.pdfbg' ).each( function () {
361		var img = jQuery( this ).css( "box-sizing", "border-box" ),
362			h = parseInt( img.attr( 'data-height' ) ),
363			w = parseInt( img.attr( 'data-width' ) ),
364			min_height = '100%';
365
366		if ( h && ! isNaN( h ) && w && ! isNaN( w ) ) {
367			var max_width = Math.min( ThriveApp.winWidth, img.parent().width() );
368			min_height = ( max_width < w ? (max_width * h / w) : h ) + 'px';
369		}
370
371		img.css( 'min-height', min_height );
372	} );
373};
374
375ThriveApp.showMenu = function () {
376	jQuery( 'header nav ul li' ).each( function () {
377		jQuery( this ).mouseenter( function () {
378			if ( jQuery( this ).hasClass( 'has-extended' ) && ThriveApp.winWidth >= 722 ) {
379				var _submenu_element = jQuery( this ).children( '.sub-menu' ),
380					_main_item_position = jQuery( this ).offset().left,
381					_submenu_width = _submenu_element.width(),
382					_contentElement = jQuery( '.wrp.cnt' ),
383					_contentWidth = _contentElement.width(),
384					_contentOffset = _contentElement.offset().left;
385				if ( _main_item_position < _contentOffset || _main_item_position + _submenu_width > _contentOffset + _contentWidth ) {
386					_submenu_element.addClass( 'position_menu' );
387					if ( _main_item_position < _contentOffset ) {
388						if ( ! _submenu_element.hasClass( 'position_right' ) ) {
389							_submenu_element.addClass( 'position_left' );
390						}
391					} else if ( _main_item_position + _submenu_width > _contentOffset + _contentWidth ) {
392						if ( ! _submenu_element.hasClass( 'position_left' ) ) {
393							_submenu_element.addClass( 'position_right' );
394						}
395					}
396				}
397				jQuery( this ).children( '.sub-menu' ).stop().fadeIn( 'fast' );
398			} else {
399				jQuery( this ).children( '.sub-menu' ).show();
400			}
401
402		} );
403		jQuery( this ).mouseleave( function () {
404			var _submenu_hidden = jQuery( this );
405			_submenu_hidden.children( '.sub-menu' ).stop().fadeOut( 'fast' );
406		} );
407
408	} );
409}
410
411ThriveApp.menuResponsive = function () {
412	if ( ThriveApp.winWidth < 774 ) {
413		jQuery( 'header nav ul li' ).each( function () {
414			jQuery( this ).unbind( 'mouseenter' );
415			jQuery( this ).unbind( 'mouseleave' );
416		} );
417		jQuery( '.hsm' ).unbind( 'click' ).on( 'click', function () {
418			var headerHeight = jQuery( '#floating_menu' ).height(),
419				topBar = jQuery( '#wpadminbar' ).length ? 46 : 0,
420				distanceFromTop = headerHeight + topBar,
421				menuMaxHeight = ThriveApp.viewportHeight - distanceFromTop;
422			jQuery( '.m-si' ).slideToggle( 'fast', function () {
423				var menuHeight = jQuery( '#floating_menu nav ul' ).height();
424				if ( ThriveApp.viewportHeight <= menuHeight + distanceFromTop ) {
425					jQuery( ".m-si" ).css( {
426						'max-height': menuMaxHeight + "px"
427					} );
428					jQuery( 'html' ).addClass( 'html-hidden' );
429				}
430				if ( menuHeight <= 0 ) {
431					jQuery( 'html' ).removeClass( 'html-hidden' );
432				}
433			} );
434		} );
435	} else if ( ThriveApp.winWidth >= 774 ) {
436		//jQuery(".m-si nav").css('max-height', 'auto').show();
437		ThriveApp.showMenu();
438	}
439}
440
441ThriveApp.shortcodeTabsResize = function () {
442	jQuery( ".scT ul.scT-tab li" ).on( 'click', function ( e ) {
443		var $li = jQuery( this ),
444			tabs_wrapper = $li.parents( ".shortcode_tabs, .tabs_widget" ).first(),
445			target_tab = tabs_wrapper.find( ".scTC" ).eq( $li.index() );
446		tabs_wrapper.find( ".tS" ).removeClass( "tS" );
447		$li.addClass( 'tS' );
448		tabs_wrapper.find( ".scTC" ).hide();
449		target_tab.show();
450		e.preventDefault();
451	} );
452};
453
454ThriveApp.delay = (function () {
455	var timer = 0;
456	return function ( callback, ms ) {
457		clearTimeout( timer );
458		timer = setTimeout( callback, ms );
459	};
460})();
461
462ThriveApp.check_comments_hash = function () {
463	if ( location.hash ) {
464//this part is commented because when you click on the comments link and the lazy load is on, it takes you to the bottom of the page and it freezes until all comments are loaded.
465		//if (location.hash.indexOf("#comments") >= 0) {
466		//    var aTag = jQuery("#commentform");
467		//    jQuery('html,body').animate({
468		//        scrollTop: aTag.offset().top
469		//    }, 'slow');
470		//    return;
471		//}
472		if ( location.hash.indexOf( "#comment-" ) !== - 1 ) {
473			var tempNo = location.hash.indexOf( "#comment-" ) + 9;
474			var comment_id = location.hash.substring( tempNo, location.hash.length );
475
476			var aTag = jQuery( "#comment-container-" + comment_id );
477			if ( aTag.length !== 0 ) {
478				jQuery( 'html,body' ).animate( {
479					scrollTop: aTag.offset().top - 30
480				}, 'slow' );
481			}
482		}
483	}
484};
485
486ThriveApp.videoShorcode = function () {
487
488	jQuery( ".scvps .pvb a" ).click( function ( event ) {
489		event.preventDefault();
490		//return false;
491	} );
492
493	jQuery( ".scvps .pvb" ).click( function () {
494		var eventTarget = jQuery( this ),
495			eventParent = eventTarget.parents( '.scvps' ),
496			elementHeight = eventParent.height();
497
498		//var elementHeight = jQuery(this).parents('.scvps').height();
499		jQuery( this ).parents( '.scvps' ).css( 'height', elementHeight + 'px' );
500
501		jQuery( this ).parents( ".vdc" ).find( "h2" ).hide();
502		jQuery( this ).parents( ".vdc" ).find( "h3" ).hide();
503		jQuery( this ).parents( ".vdc" ).find( "p" ).hide();
504		jQuery( this ).hide();
505		jQuery( this ).parents( ".scvps" ).find( ".video-container" ).show();
506
507		if ( eventParent.find( "iframe" ).length > 0 ) {
508			var _current_iframe = eventParent.find( "iframe" );
509			var _container_width = eventParent.outerWidth();
510			var _iframe_width = _current_iframe.attr( 'width' );
511			if ( jQuery( this ).hasClass( 'is-video-format' ) ) {
512				var _container_height = eventParent.outerHeight();
513			} else {
514				var _container_height = (
515					                        _container_width * 9
516				                        ) / 16;
517			}
518			if ( _container_width < _iframe_width ) {
519				_current_iframe.attr( 'width', _container_width );
520				_current_iframe.attr( 'height', _container_height );
521			}
522		}
523
524		var _video_element = jQuery( this ).parents( ".scvps" ).find( ".vwr" );
525		var _video_el_top = jQuery( this ).parents( ".scvps" ).outerHeight() / 2 - _video_element.height() / 2;
526		_video_element.css( {
527			top: (
528				_video_el_top < 0
529			) ? 0 : _video_el_top,
530			left: jQuery( this ).parents( ".scvps" ).outerWidth() / 2 - _video_element.width() / 2
531		} );
532
533		if ( eventParent.find( "video" ).length > 0 ) {
534			var _player_element = eventParent.find( "video" )[0];
535			if ( jQuery( this ).hasClass( 'is-video-format' ) ) {
536			}
537			_player_element.player.play();
538		}
539
540		if ( eventParent.find( "iframe" ).length > 0 ) {
541			var _current_iframe = eventParent.find( "iframe" );
542			var _iframe_id = _current_iframe.attr( 'id' );
543			var _iframe_src = _current_iframe.attr( 'src' );
544
545			if ( _iframe_src.indexOf( "vimeo" ) >= 0 ) {
546				_current_iframe.attr( 'src', ThriveApp.updateQueryStringParameter( _iframe_src, "autoplay", "1" ) );
547			} else if ( _iframe_src.indexOf( "youtube" ) >= 0 ) {
548				_current_iframe.attr( 'src', ThriveApp.updateQueryStringParameter( _iframe_src, "autoplay", "1" ) );
549			}
550			eventParent.find( "iframe" ).trigger( "click" );
551		}
552	} );
553
554};
555
556ThriveApp.bind_scroll = function () {
557	if ( jQuery( "#comment-bottom" ).length > 0 ) {
558		var top = jQuery( "#comment-bottom" ).offset().top;
559		if ( top > 0 && top < jQuery( window ).height() + jQuery( document ).scrollTop() ) {
560			ThriveApp.load_comments();
561		}
562	}
563};
564
565ThriveApp.load_comments = function () {
566	if ( ThriveApp.comments_loaded == 1 ) {
567		return;
568	} else {
569		ThriveApp.comments_loaded = 1;
570	}
571
572	if ( typeof _thriveCurrentPost === 'undefined' ) {
573		_thriveCurrentPost = 0;
574	}
575	jQuery( "#thrive_container_preload_comments" ).show();
576	var post_data = {
577		action: 'thrive_lazy_load_comments',
578		post_id: _thriveCurrentPost,
579		comment_page: ThriveApp.comments_page
580	};
581	if ( window.TVE_Dash && ! TVE_Dash.ajax_sent ) {
582		jQuery( document ).on( 'tve-dash.load', function () {
583			TVE_Dash.add_load_item( 'theme_comments', post_data, ThriveApp.load_comments_handle );
584		} );
585	} else {
586		jQuery.post( ThriveApp.ajax_url, post_data, ThriveApp.load_comments_handle );
587	}
588};
589
590ThriveApp.load_comments_handle = function ( response ) {
591	ThriveApp.comments_page ++;
592	if ( response == '' ) {
593		ThriveApp.comments_loaded = 1;
594	} else {
595		ThriveApp.comments_loaded = 0;
596	}
597
598	jQuery( "#thrive_container_preload_comments" ).hide();
599	jQuery( "#thrive_container_list_comments" ).append( response );
600	jQuery( "#thrive_container_form_add_comment" ).show();
601	ThriveApp.bind_comments_handlers();
602	ThriveApp.check_comments_hash();
603};
604
605ThriveApp.bind_comments_handlers = function () {
606
607	jQuery( document ).on( 'click', ".txt_thrive_link_to_comments", function () {
608		var aTag = jQuery( "#commentform" );
609		jQuery( 'html,body' ).animate( {
610			scrollTop: aTag.offset().top
611		}, 'slow' );
612	} );
613
614	jQuery( document ).on( 'click', ".reply", function () {
615		var comment_id = jQuery( this ).attr( 'cid' );
616		jQuery( "#respond-container-" + comment_id ).slideDown();
617		return false;
618	} );
619
620	jQuery( document ).on( 'click', '.cancel_reply', function () {
621		var comment_id = jQuery( this ).attr( 'cid' );
622		jQuery( "#respond-container-" + comment_id ).slideUp();
623		return false;
624	} );
625};
626
627ThriveApp.youtube_play = function ( vcode, width, height ) {
628	"use strict";
629	jQuery( "#videoContainer" ).html( '<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + vcode + '?autoplay=1&loop=1&rel=0&wmode=transparent" frameborder="0" allowfullscreen wmode="Opaque"></iframe>' );
630};
631
632ThriveApp._get_element_height = function ( elmID ) {
633	var elmHeight, elmMargin, elm = document.getElementById( elmID );
634	if ( document.all ) {// IE
635		elmHeight = elm.currentStyle.height;
636		elmMargin = parseInt( elm.currentStyle.marginTop, 10 ) + parseInt( elm.currentStyle.marginBottom, 10 ) + "px";
637	} else {// Mozilla
638		elmHeight = document.defaultView.getComputedStyle( elm, '' ).getPropertyValue( 'height' );
639		elmMargin = parseInt( document.defaultView.getComputedStyle( elm, '' ).getPropertyValue( 'margin-top' ) ) + parseInt( document.defaultView.getComputedStyle( elm, '' ).getPropertyValue( 'margin-bottom' ) ) + "px";
640	}
641	return (
642		elmHeight + elmMargin
643	);
644};
645
646ThriveApp.updateQueryStringParameter = function ( uri, key, value ) {
647	var re = new RegExp( "([?|&])" + key + "=.*?(&|$)", "i" );
648	separator = uri.indexOf( '?' ) !== - 1 ? "&" : "?";
649	if ( uri.match( re ) ) {
650		return uri.replace( re, '$1' + key + "=" + value + '$2' );
651	}
652	else {
653		return uri + separator + key + "=" + value;
654	}
655};
656
657ThriveApp.social_scripts = {
658	twitter: {src: "https://platform.twitter.com/widgets.js", loaded: 0},
659	google: {src: "https://apis.google.com/js/plusone.js?onload=onLoadCallback", loaded: 0},
660	facebook: {src: "://platform.twitter.com/widgets.js", loaded: 0},
661	linkedin: {src: "//platform.linkedin.com/in.js", loaded: 0},
662	pinterest: {src: "//assets.pinterest.com/js/pinit.js", loaded: 0},
663	youtube: {src: "https://apis.google.com/js/platform.js", loaded: 0}
664};
665
666ThriveApp.load_script = function ( script_name ) {
667	if ( ThriveApp.social_scripts[script_name].loaded === 0 ) {
668		/**
669		 * We did this to avoid a conflict when there is a pinterest button in THRIVE FOOTER WIDGET
670		 * and you add a pinterest button from the TCB (social sharing buttons - default design)
671		 * */
672		if ( ThriveApp.social_scripts[script_name].src == "//assets.pinterest.com/js/pinit.js" ) {
673			var s = document.createElement( "script" );
674			s.type = "text/javascript";
675			s.async = true;
676			s.src = "https://assets.pinterest.com/js/pinit.js";
677			s["data-pin-build"] = "parsePins";
678
679			var x = document.getElementsByTagName( "script" )[0];
680
681			x.parentNode.insertBefore( s, x );
682			ThriveApp.social_scripts[script_name].loaded = 1;
683		} else {
684			jQuery.getScript( ThriveApp.social_scripts[script_name].src, function () {
685				ThriveApp.social_scripts[script_name].loaded = 1;
686			} );
687		}
688	}
689};
690
691ThriveApp.setVideoPosition = function () {
692	jQuery( '.scvps .pvb' ).each( function () {
693		var _video_element = jQuery( this ).parents( ".scvps" ).find( ".vwr" );
694		_video_element.css( {
695			top: jQuery( this ).parents( ".scvps" ).outerHeight() / 2 - _video_element.height() / 2,
696			left: jQuery( this ).parents( ".scvps" ).outerWidth() / 2 - _video_element.width() / 2
697		} );
698	} );
699};
700
701ThriveApp.bind_share_buttons = function () {
702
703	if ( ThriveApp.is_singular != '0' && jQuery( '.cou .share-no' ).length ) {
704		ThriveApp.fetch_share_count();
705	}
706};
707
708ThriveApp.fetch_share_count = function ( post_id, bypass_cache ) {
709	if ( typeof bypass_cache === 'undefined' ) {
710		bypass_cache = 0;
711	}
712
713	function post_it( id, $share_count_total ) {
714		var post_data = {
715			action: 'thrive_get_share_count',
716			post_id: id,
717			no_cache: bypass_cache
718		}, _r = function ( response ) {
719			var nn = parseInt( response );
720			if ( ! isNaN( nn ) ) {
721				$share_count_total.html( response );
722			}
723		};
724
725		if ( window.TVE_Dash && ! TVE_Dash.ajax_sent ) {
726			jQuery( document ).on( 'tve-dash.load', function () {
727				TVE_Dash.add_load_item( 'theme_shares', post_data, _r );
728			} );
729		} else {
730			jQuery.post( ThriveApp.ajax_url, post_data ).done( _r );
731		}
732	}
733
734	/**
735	 * single page - update all instances from the page
736	 */
737	if ( typeof post_id === 'undefined' ) {
738		var $all = jQuery( '.mets .cou, .fl-s .cou.thive-share-count' );
739		var $share_count = $all.first();
740		if ( $share_count.length ) {
741			post_it( $share_count.data( 'id' ), $share_count.add( $all ) );
742		}
743	} else {
744		post_it( post_id, jQuery( '.thive-share-cnt-' + post_id ) );
745	}
746};
747
748ThriveApp.open_share_popup = function ( url, width, height, post_id ) {
749	var leftPosition, topPosition;
750	leftPosition = (
751		               window.screen.width / 2
752	               ) - (
753		               (
754			               width / 2
755		               ) + 10
756	               );
757	topPosition = (
758		              window.screen.height / 2
759	              ) - (
760		              (
761			              height / 2
762		              ) + 50
763	              );
764	/**
765	 * store a reference to the opened window, so we can refresh share count after the window closes
766	 * @type {Window}
767	 */
768	var child_window = window.open( url, "Window", "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no" ),
769		tt = 0;
770
771	function close_listener() {
772		if ( child_window.closed ) {
773			ThriveApp.fetch_share_count( post_id, 1 );
774			clearTimeout( tt );
775			return;
776		}
777		tt = setTimeout( close_listener, 1000 );
778	}
779
780	tt = setTimeout( close_listener, 4000 );
781	return false;
782};
783ThriveApp.hasFloatingMenu = jQuery( '#floating_menu' ).attr( 'data-float' ) === 'float';
784ThriveApp.hasSocialIcons = jQuery( '#floating_menu' ).attr( 'data-social' ) === '1';
785ThriveApp.menu_float = {
786	current_scroll_top: 0,
787	scroll_dir: 'down',
788	hasScroll: function () {
789		return this.current_scroll_top > 0;
790	},
791	onScroll: function ( st ) {
792		if ( this.current_scroll_top < st ) {
793			this.scroll_dir = 'down';
794		} else {
795			this.scroll_dir = 'up';
796		}
797		this.current_scroll_top = st;
798		return this.handle();
799	},
800	handle: function () {
801		var _socialElement = jQuery( '.fln' ),
802			_header = jQuery( '#floating_menu' ),
803			_theMenu = _header.find( 'header' ),
804			_headerHeight = _header.outerHeight(),
805			_nextElement = jQuery( '.bSe' ).offset().top,
806			_post_height = jQuery( '.bSe .awr-i' ).outerHeight(),
807			_bottom_limit = _nextElement + _post_height;
808
809		if ( _isAdmin ) {
810			_socialElement.addClass( 'adm' );
811			_theMenu.addClass( 'adm' );
812		}
813
814		if ( this.scroll_dir == 'down' ) {
815			if ( ThriveApp.winWidth > 774 ) {
816				_header.css( 'height', _headerHeight + 'px' );
817			}
818
819			if ( ThriveApp.hasFloatingMenu && ThriveApp.hasSocialIcons ) {
820				if ( this.current_scroll_top > _nextElement ) {
821					_socialElement.addClass( 'fff' );
822					if ( this.current_scroll_top > _bottom_limit ) {
823						_socialElement.removeClass( 'fff' );
824						_theMenu.addClass( 'fbh' );
825					}
826				}
827			}
828
829			if ( ThriveApp.hasFloatingMenu && ! ThriveApp.hasSocialIcons ) {
830				if ( this.current_scroll_top > 10 ) {
831					_theMenu.addClass( 'fbh' );
832				}
833			}
834
835			if ( ThriveApp.hasSocialIcons && ! ThriveApp.hasFloatingMenu ) {
836				if ( this.current_scroll_top > 10 ) {
837					_socialElement.addClass( 'fff' );
838				}
839			}
840
841		} else if ( this.scroll_dir == 'up' ) {
842			if ( ThriveApp.hasFloatingMenu && ThriveApp.hasSocialIcons ) {
843				if ( this.current_scroll_top < _bottom_limit ) {
844					_socialElement.addClass( 'fff' );
845					_theMenu.removeClass( 'fbh' );
846				}
847				if ( this.current_scroll_top < _nextElement ) {
848					_socialElement.removeClass( 'fff' );
849				}
850			}
851			if ( ThriveApp.hasFloatingMenu && ! ThriveApp.hasSocialIcons ) {
852				if ( this.current_scroll_top < _nextElement ) {
853					_theMenu.removeClass( 'fbh' );
854				}
855			}
856			if ( ThriveApp.hasSocialIcons && ! ThriveApp.hasFloatingMenu ) {
857				if ( this.current_scroll_top < _nextElement ) {
858					_socialElement.removeClass( 'fff' );
859				}
860			}
861
862		}
863	}
864};
865
866ThriveApp.show_shortcodes = function ( position ) {
867	jQuery( '.nsd' ).each( function () {
868		var $this = jQuery( this );
869		if ( position + ThriveApp.viewportHeight >= $this.offset().top + $this.outerHeight() ) {
870			$this.addClass( 'nsds' );
871			ThriveApp.number_counter();
872			ThriveApp.progress_bar();
873		}
874	} );
875};
876
877var _overlayElement = jQuery( '.galleryOverlay' );
878
879ThriveApp.blog_gallery = (
880	function ( $ ) {
881		return function () {
882			var currentImageIndex = 0,
883				timer = 0;
884
885			function createGalleryItem( $link, $container ) {
886				$( '<div class="galleryWrapper">
886<img data-pos="' + $link.attr( 'data-position' ) + '" data-cap="' + $link.attr( 'data-caption' ) + '" data-index="' + $link.attr( 'data-index' ) + '" src="' + $link.attr( 'data-src' ) + '" alt=""/></div>' )
887					.appendTo( $container );
888			}
889
890			function showImage( $container, index, animate ) {
891				if ( ! animate ) {
892					$container.addClass( 'g-n-a' );
893				} else {
894					$container.removeClass( 'g-n-a' );
895				}
896
897				var toBeShown = $container.find( 'img[data-index=' + index + ']' ),
898					_cap = toBeShown.attr( 'data-cap' ),
899					_pos = toBeShown.attr( 'data-pos' );
900
901				index = toBeShown.parent().index();
902				$container.css( {
903					left: '-' + (
904						index * 100
905					) + '%'
906				} );
907				currentImageIndex = index;
908				if ( ThriveApp.winWidth > 650 ) {
909					positionCloseBtn( toBeShown );
910				}
911				jQuery( '.img_count' ).text( _pos );
912				jQuery( '.cap_txt' ).text( _cap );
913				if ( _cap != "" ) {
914					jQuery( ".mob_text" ).text( _cap );
915				} else {
916					jQuery( ".mob_text" ).text( " - Swipe left/right to see more" );
917				}
918			}
919
920			function positionCloseBtn( $img ) {
921				var $closeBtn = $img.parents( '.galleryOverlay' ).first().find( '.nav_close' );
922				if ( ! $img.width() ) {
923					return $closeBtn.css( {
924						top: '20px',
925						right: '20px'
926					} );
927				}
928				var l = $img.position().left - $img.parent().position().left + $img.width(),
929					t = $img.position().top;
930
931				if ( $img.width() >= ThriveApp.winWidth ) {
932					l -= 16;
933					t += 16;
934				}
935
936				if ( _isAdmin && $img.position().top <= 32 ) {
937					t += 32;
938				}
939
940				$closeBtn.css( {
941					top: (
942						     t - 16
943					     ) + 'px',
944					left: (
945						      l - 16
946					      ) + 'px'
947				} );
948			}
949
950			$( '.thrive-gallery' ).each( function () {
951				var $gallery = $( this ), // images container
952					$overlay = $( this ).find( '.galleryOverlay' ),
953					$stage = $( this ).find( '.galleryStage' ),
954					total = $gallery.find( '.gallery-item a' ).length,
955					isOpen = false,
956					animating = false,
957					showNext = function () {
958						if ( animating ) {
959							return;
960						}
961						if ( currentImageIndex < total - 1 ) {
962							showImage( $stage, currentImageIndex + 1, true );
963						} else {
964							$stage.addClass( 'g-n-a' ).css( 'left', '100%' );
965							animating = true;
966							setTimeout( function () {
967								showImage( $stage, 0, true );
968								animating = false;
969							}, 20 );
970						}
971					},
972					showPrev = function () {
973						if ( animating ) {
974							return;
975						}
976						if ( currentImageIndex > 0 ) {
977							showImage( $stage, currentImageIndex - 1, true );
978						} else {
979							$stage.addClass( 'g-n-a' ).css( 'left', - 100 * (
980								total
981							) + '%' );
982							animating = true;
983							setTimeout( function () {
984								showImage( $stage, total - 1, true );
985								animating = false;
986							}, 20 );
987						}
988					};
989
990				$gallery.find( '.gallery-item a' ).each( function ( index ) {
991					$( this ).click( function () {
992						isOpen = true;
993						$overlay.show( 0 ).addClass( 'g-v' );
994						showImage( $stage, index, false );
995						return false;
996					} );
997					createGalleryItem( $( this ), $overlay.find( '.galleryStage' ) );
998				} );
999
1000				$gallery.find( 'a.nav_prev' ).click( function () {
1001					showPrev();
1002					return false;
1003				} );
1004				$gallery.find( 'a.nav_next' ).click( function () {
1005					showNext();
1006					return false;
1007				} );
1008				$gallery.find( '.nav_close' ).click( function () {
1009					isOpen = false;
1010					$overlay.removeClass( 'g-v' ).hide();
1011					return false;
1012				} );
1013				$gallery.find( '.galleryWrapper' ).touchwipe( {
1014					wipeLeft: function () {
1015						showNext();
1016					},
1017					wipeRight: function () {
1018						showPrev();
1019					},
1020					wipeUp: function () {
1021						isOpen = false;
1022						$overlay.removeClass( 'g-v' ).hide();
1023					},
1024					wipeDown: function () {
1025						return false
1026					},
1027					min_move_x: 20,
1028					min_move_y: 20,
1029					preventDefaultEvents: true
1030				} );
1031				if ( ThriveApp.winWidth <= 650 ) {
1032					$stage.click( function () {
1033						var $target = $( e.target );
1034						if ( $target.is( 'img' ) ) {
1035							return false;
1036						}
1037						isOpen = false;
1038						$overlay.removeClass( 'g-v' ).hide();
1039//                    jQuery(".gl_ctrl_mob").toggle();
1040//                    return false;
1041					} );
1042				} else {
1043					$stage.click( function ( e ) {
1044						var $target = $( e.target );
1045						if ( $target.is( 'img' ) ) {
1046							return false;
1047						}
1048						isOpen = false;
1049						$overlay.removeClass( 'g-v' ).hide();
1050					} );
1051					$gallery.mousemove( function ( e ) {
1052						clearTimeout( timer );
1053						$( '.gl_ctrl, .gl_ctrl_mob' ).fadeIn( 200 );
1054						if ( ThriveApp.winWidth <= 650 ) {
1055							return;
1056						}
1057						if ( ! $( e.target ).is( '.gl_ctrl,.gl_ctrl_mob' ) ) {
1058							timer = setTimeout( function () {
1059								jQuery( '.gl_ctrl, .gl_ctrl_mob' ).fadeOut( 200 );
1060							}, 1000 );
1061						}
1062					} );
1063				}
1064				$( 'html' ).unbind( 'keydown' ).keydown( function ( e ) {
1065					if ( ! isOpen ) {
1066						return true;
1067					}
1068					if ( e.keyCode == 37 ) {
1069						showPrev();
1070						return false;
1071					}
1072					if ( e.keyCode == 39 ) {
1073						showNext();
1074						return false;
1075					}
1076					if ( e.keyCode == 27 ) {
1077						$overlay.removeClass( 'g-v' ).hide();
1078						return false;
1079					}
1080				} );
1081			} );
1082		}
1083
1084	}( jQuery )
1085);
1086
1087jQuery.fn.thrive_timer = function () {
1088	return this.each( function () {
1089		var el = jQuery( this ),
1090			server_time = el.attr( 'data-server-now' ),
1091			now = server_time ? new Date( server_time ) : new Date(),
1092			event_date = new Date( el.attr( 'data-date' ) ),
1093			day = 0, hour = 0, min = 0, sec = 0, day_digits = 2,
1094			fade = el.attr( 'data-fade' ),
1095			message = el.attr( 'data-message' ),
1096			interval_id;
1097
1098		/* utility functions */
1099		/**
1100		 * setup html <span>s to hold each of the digits making up seconds, minutes, hours, days
1101		 *
1102		 * check the number of digits required for days (this might be bigger than 2)
1103		 */
1104		var htmlSetup = function () {
1105
1106			/**
1107			 * create a new span containing the value
1108			 *
1109			 * @param index
1110			 * @param value
1111			 * @returns {jQuery|jQuery}
1112			 * @private
1113			 */
1114			var _span = function ( index, value ) {
1115				return jQuery( '<span class="part-' + index + '">' + value + '</span>' );
1116			}
1117			el.find( '.second .cdfc' )
1118			  .append( _span( 2, Math.floor( sec / 10 ) ) )
1119			  .append( _span( 1, sec % 10 ) );
1120			el.find( '.minute .cdfc' )
1121			  .append( _span( 2, Math.floor( min / 10 ) ) )
1122			  .append( _span( 1, min % 10 ) );
1123			el.find( '.hour .cdfc' )
1124			  .append( _span( 2, Math.floor( hour / 10 ) ) )
1125			  .append( _span( 1, hour % 10 ) );
1126
1127			var $dayContainer = el.find( '.day .cdfc' ),
1128				total_days = day;
1129			for ( var i = 1; i <= day_digits; i ++ ) {
1130				$dayContainer.append( _span( i, total_days % 10 ) );
1131				total_days = Math.floor( total_days / 10 );
1132			}
1133			setValues( $dayContainer.css( 'min-width', (
1134				                                           28 * day_digits
1135			                                           ) + 'px' ), day, day_digits );
1136		};
1137
1138		/**
1139		 * if value is the same as current value, do nothing, else, we need to create animation
1140		 *
1141		 * @param $part
1142		 * @param value
1143		 */
1144		var setValue = function ( $part, value ) {
1145			if ( $part.html() == value ) {
1146				return $part;
1147			}
1148			$part.removeClass( 'next' );
1149			//create another span, and insert it before the original part, in order to animate it nicely
1150			var _new = $part.clone().removeClass( 'go-down' ).addClass( 'next' ).html( value );
1151			$part.before( _new ).next( '.go-down' ).remove();
1152			$part.addClass( 'go-down' );
1153			setTimeout( function () {
1154				_new.addClass( 'go-down' );
1155			}, 20 );
1156
1157			return $part;
1158		};
1159
1160		/**
1161		 * set each of the new values on a group (seconds, minutes, hours, days)
1162		 * @param container
1163		 * @param value
1164		 * @param number_length
1165		 */
1166		var setValues = function ( container, value, number_length ) {
1167
1168			if ( typeof number_length === 'undefined' ) {
1169				number_length = false;
1170			}
1171			var index = 0;
1172			if ( value <= 99 ) {
1173				setValue( container.find( '.part-1' ).first(), value % 10 );
1174				setValue( container.find( '.part-2' ).first(), Math.floor( value / 10 ) );
1175				index = 2;
1176			} else {
1177				while ( value ) {
1178					index ++;
1179					setValue( container.find( '.part-' + index ).first(), value % 10 );
1180					value = Math.floor( value / 10 );
1181				}
1182			}
1183			if ( number_length !== false && index < number_length ) {
1184				for ( var i = index + 1; i <= number_length; i ++ ) {
1185					setValue( container.find( '.part-' + i ).first(), 0 );
1186				}
1187			}
1188		}
1189
1190		/**
1191		 * called every second, it decrements the time and updates the HTML accordingly
1192		 */
1193		var step = function () {
1194			sec --;
1195
1196			if ( sec < 0 ) {
1197				sec = 59;
1198				min --;
1199			}
1200			if ( min < 0 ) {
1201				min = 59;
1202				hour --;
1203			}
1204			if ( hour < 0 ) {
1205				hour = 23;
1206				day --;
1207			}
1208			setValues( el.find( '.second .cdfc' ), sec );
1209			setValues( el.find( '.minute .cdfc' ), min );
1210			setValues( el.find( '.hour .cdfc' ), hour );
1211			setValues( el.find( '.day .cdfc' ), day, day_digits );
1212
1213			if ( day == 0 && hour == 0 && min == 0 && sec == 0 ) {
1214				//done!
1215				clearInterval( interval_id );
1216				finished();
1217			}
1218		}
1219
1220		/**
1221		 * finished counting, or the event time is somewhere in the past
1222		 */
1223		var finished = function () {
1224			if ( fade == '1' ) {
1225				el.find( '.cdti' ).addClass( 'fdtc' );
1226			} else {
1227				el.find( '.cdti' ).addClass( 'fv' );
1228			}
1229			if ( message == '1' ) {
1230				el.find( '.cdti' ).addClass( 'fdtc' );
1231				setTimeout( function () {
1232					el.find( '.cdtm' ).fadeIn( 2000 );
1233				}, 500 );
1234			}
1235		}
1236
1237		if ( now > event_date ) {
1238			finished();
1239		} else {
1240
1241			sec = Math.floor( (
1242				                  event_date.getTime() - now.getTime()
1243			                  ) / 1000 );
1244			min = Math.floor( sec / 60 );
1245			sec = sec % 60;
1246			hour = Math.floor( min / 60 );
1247			min = min % 60;
1248			day = Math.floor( hour / 24 );
1249			hour = hour % 24;
1250			if ( day > 99 ) {
1251				day_digits = day.toString().length;
1252			}
1253
1254			htmlSetup();
1255			el.find( '.cdti' ).addClass( 'init_done' );
1256			// setup the interval function
1257			interval_id = setInterval( step, 1000 );
1258		}
1259	} );
1260}
1261
1262jQuery( window ).scroll( function () {
1263	var position = jQuery( document ).scrollTop();
1264	ThriveApp.show_shortcodes( position );
1265	if ( ThriveApp.hasFloatingMenu && ThriveApp.is_singular == '1' ) {
1266		ThriveApp.menu_float.onScroll( position );
1267	}
1268} );
1269ThriveApp._get_share_count_display_text = function ( number, decPlaces ) {
1270	decPlaces = Math.pow( 10, decPlaces );
1271	var abbrev = ["k", "m"];
1272	for ( var i = abbrev.length - 1; i >= 0; i -- ) {
1273		var size = Math.pow( 10, (
1274			                         i + 1
1275		                         ) * 3 );
1276		if ( size <= number ) {
1277			number = Math.round( number * decPlaces / size ) / decPlaces;
1278			if ( (
1279				     number == 1000
1280			     ) && (
1281				     i < abbrev.length - 1
1282			     ) ) {
1283				number = 1;
1284				i ++;
1285			}
1286			number += abbrev[i];
1287			break;
1288		}
1289	}
1290	return number;
1291};
1292ThriveApp.resize_blank_page = function () {
1293	_is_blankPage = jQuery( 'html.bp-th' ).length;
1294	if ( _is_blankPage ) {
1295		var contentHeight = jQuery( '.wrp' ).outerHeight(),
1296			$body = jQuery( 'body' );
1297		if ( ThriveApp.viewportHeight >= contentHeight ) {
1298			$body.css( 'height', ThriveApp.viewportHeight );
1299		} else {
1300			$body.css( 'height', contentHeight );
1301		}
1302	}
1303};

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.