PageSourceSearch

https://kebs.org/wp-content/themes/kebs/framework/js/misc.js?ver=6.6

js kebs.org collected 2026-09-24 18:06:12 UTC 5,889 bytes, 190 lines download raw bytes

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

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.