PageSourceSearch

https://digitalhealthbuzz.com/wp-content/themes/newstar/framework/js/misc.js?ver=6.1.14

js digitalhealthbuzz.com collected 2026-09-28 06:44:38 UTC 4,890 bytes, 165 lines download raw bytes

1'use strict';
2
3var bt_initTheme;
4
5function bt_refresh_cart() {
6	jQuery( '.btCartWidgetIcon' ).unbind('click').on( 'click', function ( e ) {
7		jQuery(this).parent().parent().toggleClass( 'on' );
8		jQuery('body').toggleClass( 'btCartDropdownOn' );
9	});
10	jQuery('.verticalMenuCartToggler').unbind('click').on( 'click', function() {
11		jQuery(this).closest('.widget_shopping_cart_content').removeClass('on');
12		jQuery('body').removeClass('.btCartDropdownOn');
13	});
14}
15
16(function( $ ) {
17	
18	function initFancySelect() {
19		if ( typeof $.fn.fancySelect === 'function' ) {
20			$( '.no-touch .btSidebar select, .no-touch select.orderby, .no-touch #btSettingsPanelContent select, .no-touch .wpcf7-form select:not([multiple])' ).fancySelect().on( 'change.fs', function() {
21				$( this ).trigger( 'change.$' );
22			});	
23		} 
24	}
25	
26	function loadInitActions() {
27		// remove preloader
28		if(!$( 'body' ).hasClass( "btRemovePreloader" )) {
29			$( 'body' ).addClass( 'btRemovePreloader' );
30			if ( typeof bt_bb_animate_elements === "function" ) {
31				bt_bb_animate_elements();
32			}
33		}
34		
35		// trigger custom load event
36		setTimeout( function() { $( window ).trigger( 'btload' ); window.boldthemes_loaded = true; }, 500 );
37		
38		// gmaps with img overlay, iframes
39		$( window ).trigger( 'resize' );
40	}
41	
42	function initFooter() {
43		$( '#boldSiteFooterWidgetsRow' ).attr( 'data-width', $( '#boldSiteFooterWidgetsRow' ).children().length ).children().addClass('bt_bb_column');
44	}
45	
46	function initModernizrAndDetectBrowser() {
47		btModernizr.load([
48		{
49			test: window.matchMedia
50		}
51		]);
52		
53		// Browser detect
54	
55		var doc = document.documentElement;
56		doc.setAttribute('data-useragent', navigator.userAgent);
57
58		// IE startsWith/endsWith compatibility 
59		
60		if ( ! String.prototype.startsWith ) {
61			String.prototype.startsWith = function(searchString, position) {
62				position = position || 0;
63				return this.lastIndexOf(searchString, position) === position;
64			};
65		}
66
67		if ( ! String.prototype.endsWith ) {
68			String.prototype.endsWith = function(searchString, position) {
69				var subjectString = this.toString();
70				if (position === undefined || position > subjectString.length) {
71					position = subjectString.length;
72				}
73				position -= searchString.length;
74				var lastIndex = subjectString.indexOf(searchString, position);
75				return lastIndex !== -1 && lastIndex === position;
76			};
77		}
78	}
79	
80	function initPreloader() {
81		// delay click to allow on page leave screen
82		$( 'body.bodyPreloader .mainHeader .menu' ).unbind('click').on( 'click', 'a', function() {
83			var href = $( this ).attr( 'href' );
84			if ( 
85				href !== undefined && 
86				! href.startsWith( '#' ) && 
87				! href.startsWith( 'mailto' ) &&  
88				! href.startsWith( 'callto' ) && 
89				! $( this ).hasClass( 'lightbox' ) && 
90				! $( this ).hasClass( 'add_to_cart_button' ) && 
91				$( this ).attr( 'target' ) != '_blank'
92			) {
93				$( 'body' ).removeClass( 'btRemovePreloader' );
94				setTimeout( function() { window.location = href }, 750 );
95				return false;
96			}
97		});
98	}
99	
100	function initRefreshCart() {
101		$( '.cart-contents' ).each(function() {
102			bt_refresh_cart();
103		});
104		var cart_node = jQuery( '.widget_shopping_cart' )[0];
105		if ( cart_node !== undefined ) {
106			var config = { attributes: true, childList: true, subtree: true };
107			var callback = function( mutationsList, observer ) {
108				for ( var mutation of mutationsList ) {
109					if ( mutation.type == 'childList' ) {
110						jQuery( '.btCartWidgetIcon' ).unbind( 'click' ).on( 'click', function ( e ) { jQuery( this ).parent().parent().toggleClass( 'on' ); jQuery('body').toggleClass( 'btCartDropdownOn' ); });
111						jQuery( '.verticalMenuCartToggler' ).unbind( 'click' ).on( 'click', function ( e ) { jQuery( this ).closest( '.widget_shopping_cart_content' ).removeClass( 'on' ); jQuery('body').removeClass('.btCartDropdownOn'); });
112					}
113				}
114			};
115			var observer = new MutationObserver( callback );
116			observer.observe( cart_node, config );
117		}
118	}
119	
120	function shopEqualHeights() {
121		var maxHeight = Math.max.apply(null, $("ul.products li.product .btWooShopLoopItemInner").map(function () {
122			return $(this).outerHeight();
123		}).get());
124		console.log(maxHeight);
125		$("ul.products li.product .btWooShopLoopItemInner").css('min-height', maxHeight + 'px')
126	}
127	
128	function initTheme() {
129		initFancySelect();
130		initFooter();
131		initModernizrAndDetectBrowser();
132		initPreloader();
133		initRefreshCart();
134		loadInitActions();
135		
136	}
137	
138	// LOAD
139	$( window ).load(function() {
140		loadInitActions();
141	});
142	
143	// READY
144	
145	$( document ).ready(function() {
146		initRefreshCart();
147	});
148	
149	// RESIZE
150	
151	$( window ).resize(function() {
152		$("ul.products li.product .btWooShopLoopItemInner").css('min-height', 'auto')
153		shopEqualHeights();
154	});
155
156	initFancySelect();
157	initFooter();
158	initModernizrAndDetectBrowser();
159	initPreloader();
160	shopEqualHeights();
161	
162	bt_initTheme = initTheme;
163  
164})( jQuery );
165

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.