PageSourceSearch

https://menditect.com/wp-content/themes/teamcreative/assets/js/scripts.js?ver=1.0.0

js menditect.com collected 2026-10-02 15:55:41 UTC 10,876 bytes, 315 lines download raw bytes

1(function ($) {
2	
3	$(function () { 
4
5        'use strict';                       
6
7        // ================================================ MENU FUCTIONS ================================================ region                                     
8                   
9        // HEADROOM           
10        $(".header100").headroom();  
11		
12		//$('.mobmenucontainer').doubleTapToGo();
13                         
14        // ================================================ MENU FUCTIONS ================================================ endregion   
15                                      
16        // ================================================ SLIDER FUCTIONS ================================================ region                   
17                   
18        // SLIDER FUNCTIONS  region
19        // $('.banner').slick({
20        //     dots: false,
21        //     infinite: true,
22        //     speed: 600,
23        //     fade: false,
24        //     slidesToShow: 1,
25        //     adaptiveHeight: true,
26        //     draggable: false,
27        //     easing: 'linear',
28        //     pauseOnHover: false,
29        //     swipe: true,
30        //     nextArrow: '<span class="nextarrow"><i class="far fa-angle-right"></i></span>',
31        //     prevArrow: '<span class="prevarrow"><i class="far fa-angle-left"></i></span>',
32        //     autoplay: true,
33        //     autoplaySpeed: 8000
34        // });
35		
36        // ================================================ SLIDER FUCTIONS ================================================ endregion     
37                   
38	});
39	
40//	$('.mobmenucontainer .menu-item-has-children').on('click', function(e){
41//		
42//		//e.preventDefault();
43//		
44//		$(this).toggleClass('menu-item-active-js'); 
45//	});
46	
47	$('.btn[href^="#popup-"]').on('click', function(e){
48		
49		e.preventDefault();
50		
51		var popupTrigger = $(this).attr('href');
52        var popupTrigger = popupTrigger.substring(1, popupTrigger.length);
53		
54		$('body').addClass('active-' + popupTrigger);
55		
56	});
57
58	$('.popup-demo .popup-wrapper .close-popup').on('click', function(e){
59		
60		var hidePopupType = $(this).parent().parent().attribute('class');
61		
62		$('body').removeClass('active-' + hidePopupType);
63		
64	});
65	
66//	$('.btn[href^="#"]').on('click', function(e){
67//		
68//		e.preventDefault();
69//		
70//		$('html, body').animate({scrollTop: $($(this).attr('href')).offset().top - $('.header100').height()},500,'linear');
71//		
72//	});
73	
74	//Hier komen je extra jquery functies zo als onload/resize etc
75    $(window).on('resize', function(){
76//		
77//		//Delay functions untill resize is totally done
78//        waitForFinalEvent(function(){ 
79//			
80//            //Your functions here
81//			
82//			
83//        }, 500, "TC");
84		
85    });
86	
87    $(window).on('load', function(){
88        tcSetupPopups();
89
90    });
91	
92	
93	//Line menu
94	var $el, leftPos, newWidth,
95        $mainNav = $(".main-menu-flex>ul");
96    
97    $mainNav.append("<li id='magic-line'></li>");
98    var $magicLine = $("#magic-line");
99
100    setTimeout(function(){
101        if($(".main-menu-flex>ul>.current_page_item").length) {
102            $magicLine
103                .width($(".current_page_item").width())
104                .css({"left": $(".current_page_item").find('a').position().left,"opacity":"1"})
105                .data("origLeft", $(".current_page_item").find('a').position().left)
106                .data("origWidth", $(".current_page_item").find('a').width());
107        }else if($(".main-menu-flex>ul>.menu-item>ul>.current_page_item").length) {
108            $magicLine
109                .width($(".current_page_item").parent().parent().width())
110                .css({"left": $(".current_page_item").parent().parent().find('a').position().left,"opacity":"1"})
111                .data("origLeft", $(".current_page_item").parent().parent().find('a').position().left)
112                .data("origWidth", $(".current_page_item").parent().parent().find('a').width());	
113        } else {
114            $magicLine
115                .width($(".main-menu-flex .menu li:first-of-type").width())
116                .css({"left": $(".main-menu-flex .menu li:first-of-type").find('a').position().left,"opacity":"1"})
117                .data("origLeft", $(".main-menu-flex .menu li:first-of-type").find('a').position().left)
118                .data("origWidth", $(".main-menu-flex .menu li:first-of-type").find('a').width());	
119        } }, 101);
120        
121	
122    $(window).scroll(function(){
123		
124		setTimeout(function(){
125		
126			if($(".current_page_item").length) {
127				$magicLine
128					.css("left", $(".current_page_item").find('a').position().left)
129					.data("origLeft", $(".current_page_item").find('a').position().left)
130			} else {
131				$magicLine
132					.css("left", $(".main-menu-flex .menu li:first-of-type").find('a').position().left)
133					.data("origLeft", $(".main-menu-flex .menu li:first-of-type").find('a').position().left)
134				
135			}
136		}, 501);
137    });
138        
139    $(".main-menu-flex>ul>li").hover(function() {
140		
141        $el = $(this);
142        leftPos = $el.find('a').position().left;
143        newWidth = $el.find('a').width();
144        $magicLine.stop().animate({
145            left: leftPos,
146            width: newWidth
147        });
148    }, function() {
149        $magicLine.stop().animate({
150            left: $magicLine.data("origLeft"),
151            width: $magicLine.data("origWidth")
152        });    
153    });
154	
155})(jQuery, this);
156
157
158function triggerMenu() {
159    jQuery('body').toggleClass('show-mobmenu');
160}
161
162//// TC POPUPS //// region
163
164//TC Popups turns all anchor tags with an href-attribute starting with '#popup-' into a trigger for a popup element with an ID-attribute matching the full href-attribute.
165//TC Popups zet alle anchor tags met een href-attribute dat begint met '#popup-' om in een trigger voor een popup element met een ID-attribute dat overeenkomt met het volledige href-attribute.
166function tcSetupPopups() {
167    //Setup popup anchor triggers
168    document.querySelectorAll('a[href^="#popup-"]').forEach(element=>{
169        element.addEventListener('click', event=>{
170            event.preventDefault();
171            tcShowPopup(document.querySelector(element.getAttribute('href')));
172
173            /*
174            ** This code takes an array of 'dynamic' field-parameter-names
175            ** Dynamic fields are gravity forms field that can be filled dynammically
176            ** If the target popup contains a form with such a field, the value of this field will be set dynamically
177            ** If the anchor element that triggered this event contains a dataset-attribute with the same field-parameter-name, the fields' value will be set to that dataset-attributes value
178            ** Else, the value of the field will be reset
179            */
180            let dynamicfields = [];
181            for(let i=0; i<dynamicfields.length; i++) {
182                let targetInput = document.querySelector(element.getAttribute('href')).querySelector('.gfield.'+dynamicfields[i]);
183                if(targetInput && element.dataset[dynamicfields[i]]) {
184                    targetInput.setAttribute('value', element.dataset[dynamicfields[i]]);
185                } else if (targetInput) {
186                    targetInput.setAttribute('value', '');
187                }
188            }
189            
190        });
191    });
192
193    //Setup popup closing
194    document.querySelectorAll('.popup-holder .closepop').forEach(element=>{
195        element.addEventListener('click', event=>{
196            event.preventDefault();
197            tcHidePopup(element);
198        });
199    });
200}
201function tcShowPopup(element) {
202	if(!element) { return; }
203	element.classList.remove('hide-popup');
204	element.classList.add('show-popup');
205}
206function tcHidePopup(element) {
207	//Element is probably an 'i' or something inside the actual popup.
208	element = parentSelector(element, '.popup-holder');
209	element.classList.remove('show-popup');
210	element.classList.add('hide-popup');
211}
212
213//// TC POPUPS //// endregion
214
215//// TC AJAX //// region
216/* usage example:
217
218	data = {
219		action: "tc_ajax_test",
220	}
221	tcAjax(data, function(response){
222		console.log(response);
223	});
224    
225*/
226function tcAjax(data, callback) {
227	jQuery.ajax({
228		type : "post",
229		dataType : "json",
230		url : tcAjaxObj.ajaxurl,
231		data : data,
232		complete: callback,
233	});
234}
235//// TC AJAX //// endregion
236
237//// GENERIC HELPER FUNCTIONS region
238
239//Similar to element.querySelector(), but this one traverses the DOM upwards
240//Vergelijkbaar met element.querySelector(), maar deze functie navigeert van parent naar parent
241function parentSelector(element, selector, forceParent=true) {
242	if(forceParent) {
243		element = element.parentNode;
244	}
245	while(!element.matches(selector)) {
246		if(element.nodeName == "BODY") {
247			return null;
248		}
249		element = element.parentNode;
250	}
251	return element;
252}
253
254//Get the value of the selected radio button with 'name'
255//Geeft de waarde terug van het geselecteerde radioveld met 'name'
256function getRadioValue(name, element=false) {
257    if(!element) {
258        element = document;
259    }
260    let radioButtons = element.querySelectorAll('[name="'+name+'"]');
261    for(let i=0; i<radioButtons.length; i++) {
262        if(radioButtons[i].checked) {
263            return radioButtons[i].value;
264            break;
265        }
266    }
267}
268
269//Creates an HTML element from an html-string, allows for dom manipulation and eventlistener coupling before further DOM manipulation
270//Maakt een HTML element van een string, maakt het o.a mogelijk om eventlisteners toe te voegen alvorens deze toe te voegen aan het DOM
271function createElementFromHTML(htmlString) {
272	let div = document.createElement('div');
273	div.innerHTML = htmlString.trim();
274	return div.firstChild;
275}
276
277//Collects the 'name':'value' pairs from a form and converts them to a JSON object
278//Verzamelt de 'name':'value' paren uit een formulier en vertaalt deze naar een JSON object
279function FormValuesToJSON(form) {
280	let inputItems = form.querySelectorAll('input, select, textarea');
281	let formData = {};
282	
283	for(let n=0; n<inputItems.length; n++) {
284		let input = inputItems[n];
285		
286		if(input.type=="submit") {continue;}
287
288		let inputName = input.name;
289		let index = inputName.match(/\[([0-9]+)\]/);
290		if(index) {
291			inputName = inputName.substring(0, inputName.length - index[0].length);
292			index = index[1];
293		}
294		
295		if( input.type != 'radio' || (input.type == 'radio' && input.checked) ) {
296			if(index) {
297				if(index == 0) { formData[inputName] = []; }
298				formData[inputName][index] = input.value;
299			} else {
300				formData[inputName] = input.value;	
301			}
302		}
303	}	
304	return formData;
305}
306
307//Prototype extension, gives all strings the ability to replace all instances of 'search' with 'replace'
308//Prototype extensie, maakt het mogelijk om op strings een replace all functie uit te voeren die alle 'search' vervangt met 'replace'
309String.prototype.replaceAll = function(search, replace) {
310    var target = this;
311    return target.replace(new RegExp(search, 'g'), replace);
312};
313
314//// GENERIC HELPER FUNCTIONS endregion
315

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.