PageSourceSearch

https://ettyhillesumcentrum.nl/wp-content/themes/sieronline_master/assets/js/custom.js?ver=1.0

js ettyhillesumcentrum.nl collected 2026-10-02 22:08:17 UTC 19,472 bytes, 543 lines download raw bytes

1(function ($, window, document, undefined) {
2    "use strict";
3
4    // Create the defaults once
5    var pluginName = "usps",
6        defaults = {
7            slideSpeed: 400
8        };
9
10    // The actual plugin constructor
11    function Plugin(element, options) {
12        this.element = element;
13        this.settings = $.extend({}, defaults, options);
14        this._defaults = defaults;
15        this._name = pluginName;
16        this.init();
17    }
18
19    // Avoid Plugin.prototype conflicts
20    $.extend(Plugin.prototype, {
21        wrapper: [],
22        headers: [],
23        descriptions: [],
24        gridSettings: {
25            keys: ["lg", "md", "sm", "xs", "xxs"],
26            get: function (classes, size) {
27                // If we reached the final key xxs, return 12.
28                // XXS is always full size
29                if (size === "xxs")
30                    return 12;
31
32                // Create a regex with the current size-key to check if it exists
33                var regex = new RegExp("\\bcol-" + size + "-([1-9]|1[012])\\b"),
34                    nextIndex = this.keys.indexOf(size) + 1;
35
36                // Apply the regex and store the matches
37                var matches = classes.match(regex);
38
39                // If the key and value is found, return the value
40                if (classes.match(regex))
41                    return matches[1];
42
43                // If there is no match, we want to dig deeper
44                // Use recursion to go to the next index and repeat the steps above
45                return this.get(classes, this.keys[nextIndex]);
46            }
47        },
48
49        init: function () {
50            var instance = this,
51                element = $(this.element);
52            this.wrapper = element.find(".usps").first();
53            this.headers = this.wrapper.children('.usp-header');
54            this.descriptions = this.wrapper.children('.usp-description');
55
56            this.setupGridSettings();
57
58            // Set click eventhandler for each icon
59            this.headers.on('click', function () {
60                // If we are already animating, we don't want to do anything to prevent
61                // continuous sliding up and down when clicked multiple times
62                if (instance.wrapper.hasClass("animating")) return;
63
64                var current = $(this),
65                    // Find the clicked index of all icon
66                    clickedIndex = instance.headers.index(this);
67
68                // Get the current active block (+ index) and icon
69                var activeBlock = instance.wrapper.children('.usp-description.active'),
70                    activeBlockIndex = instance.descriptions.index(activeBlock),
71                    activeIcon = instance.wrapper.children('.usp-header.active');
72
73                // Slide up the current active block and remove active class
74                activeBlock.slideUp(instance.settings.slideSpeed).removeClass('active');
75                instance.wrapper.addClass("animating");
76
77                // Remove active class from icon
78                activeBlock.promise().done(function () {
79                    activeIcon.removeClass('active');
80                    instance.wrapper.removeClass("animating");
81
82                    // If: the clicked icon is the same as the active one, return.
83                    if (activeBlockIndex === clickedIndex) return;
84                    // Else: wait until animation is done and slide down clicked icon, add classes
85                    instance.descriptions.eq(clickedIndex).slideDown(instance.settings.slideSpeed).addClass('active');
86
87                    current.addClass('active');
88                });
89            });
90
91            // Add a click event handler for closing the description
92            this.descriptions.find('.close-usp').click(function () {
93                var activeBlock = instance.descriptions.filter('.active').first();
94
95                // Slide up (hide) the block and remove the active class
96                activeBlock.slideUp(instance.settings.slideSpeed).removeClass("active");
97
98                // When the animation is done, remove the active class from the icon too
99                activeBlock.promise().done(function () {
100                    instance.headers.filter('.active').first()
101                        .removeClass('active');
102                });
103            });
104
105            // Trigger the resizeEvent function when we resize the window
106            $(window).bind("resize", function () {
107                instance.resizeEvent();
108            });
109            this.resizeEvent();
110        },
111
112        resizeEvent: function () {
113            var instance = this,
114                alignCount = instance.gridSettings.lg,
115                windowWidth = window.innerWidth,
116                uspCount = instance.headers.length;
117
118            // If resolution is mobile, small device or tablet, change the aligncount
119            if (windowWidth < 425) {
120                alignCount = instance.gridSettings.xxs;
121            } else if (windowWidth < 768) {
122                alignCount = instance.gridSettings.xs;
123            } else if (windowWidth < 992) {
124                alignCount = instance.gridSettings.sm;
125            } else if (windowWidth < 1200) {
126                alignCount = instance.gridSettings.md
127            }
128
129            for (var i = uspCount - 1; i >= 0; i--) {
130                // Get the index of the icon to append after, so with 2 rows and 3 elements
131                // we want to get 3x5 and 3x2 when we have 6 elements
132                // Math.floor(4 / 3) = 1 * 3 + 3 - 1 = 5
133                // Math.floor(2 / 3) = 0 * 3 + 3 - 1 = 2
134                var index = Math.floor(i / alignCount) * alignCount + alignCount - 1;
135
136                // Clamp the index so it appends after the last element if the uspCount % alignCount != 0
137                // For instance, when we have 2 rows of 5 elements, there is no 6th element (5th index) to insert after
138                index = Math.min(Math.max(index, 0), uspCount - 1);
139
140                // Get the loopnumber nth description, and append it after the icon index calculated above
141                instance.descriptions.eq(i).insertAfter(instance.headers.eq(index));
142
143                // Set the headers height to auto (we later recalculate the height)
144                instance.headers.eq(i).css("height", "auto");
145            }
146
147            // If we only have one description, we don't need to recalculate the height
148            if (alignCount <= 1) return;
149
150            // Set the heights equal of the headers in the same row
151            var rows = GetRows(this.headers);
152            for (var i = 0, j = rows.length; i < j; i++) {
153                EqualElementHeights(rows[i]);
154            }
155        },
156
157        setupGridSettings: function () {
158            var instance = this;
159
160            // If there are not upss found, return
161            if (instance.headers.length <= 0) return;
162
163            // Get the classes of the first index (all elements have the same classes)
164            var classes = instance.headers.eq(0).attr('class');
165
166            // Calculate the amounts of elements per row per column key
167            for (var i = 0, j = instance.gridSettings.keys.length; i < j; i++) {
168                var gridProperty = instance.gridSettings.keys[i];
169
170                // 12 is the maximum bootstrap column number, so we divide 12 by the result
171                instance.gridSettings[gridProperty] = 12 / +instance.gridSettings.get(classes, gridProperty);
172            }
173        }
174    });
175
176    // A really plugin wrapper around the constructor preventing against multiple instantiations
177    $.fn[pluginName] = function (options) {
178        return this.each(function () {
179            if (!$.data(this, "plugin_" + pluginName)) {
180                $.data(this, "plugin_" +
181                    pluginName, new Plugin(this, options));
182            }
183        });
184    };
185
186})(jQuery, window, document);
187
188// Cache for performance
189// var $window = $(window);
190var $document = $(document);
191var dimensions = GetDimensionBools();
192var mixer;
193var mixElement = document.querySelectorAll('#portfoliolist');
194
195//========================================
196//  DOCUMENT READY
197//========================================
198
199$document.ready(function () {
200
201    var cocoen = document.querySelectorAll('.cocoen');
202    for (var i = 0, j = cocoen.length; i < j; i++) {
203        new Cocoen(cocoen[i]);
204    }
205
206    if (mixElement.length > 0) {
207        mixer = mixitup($(mixElement), {
208            load: {sort: 'random'},
209            selectors: {target: '.portfolio'}
210        });
211    }
212
213    // Initialize ObjectFitImages
214    objectFitImages();
215
216    // Scale youtube embeds
217    ScaleYoutubeEmbeds();
218
219    // Activate equal heights
220    eqSelection = document.querySelectorAll(".eq .row > .kolom");
221    SetEqualHeights(GetRows(eqSelection), dimensions.isXS());
222
223    // Initialize WOW
224    var wow = new WOW({
225        // Remove the animation property when done animating to enable hover.css
226        callback: function (box) {
227            var animationEvent = GetAnimationEvent();
228
229            function RemoveAnimationProperty() {
230                box.style.removeProperty("animation-name");
231                box.removeEventListener(animationEvent, RemoveAnimationProperty);
232            }
233
234            animationEvent && box.addEventListener(animationEvent, RemoveAnimationProperty);
235        }
236    });
237    wow.init();
238
239    // Initialize Jarallax
240    if (jQuery.fn.jarallax)
241        $('.parallax-image').jarallax({speed: 0.5, noIos: false});
242
243    // Initialize Fancybox
244    if (jQuery.fn.fancybox)
245        $("[data-fancybox]").fancybox({toolbar: true, buttons: ['fullScreen', 'close']}); // slideShow | thumbs
246
247    // Initialize BxSlider
248    $('.slider.normal').each(function () {
249        var $this = $(this);
250
251        if(jQuery.fn.bxSlider) {
252            $this.find('.bxslider').bxSlider({
253                mode: $this.data("mode"),
254                speed: +$this.data("speed"),
255                pager: !!+$this.data("pager"),
256                controls: !!+$this.data("controls"),
257                auto: !!+$this.data("auto"),
258                pause: +$this.data("duration")
259            });
260        }
261    });
262
263    /* Parallax Fade Slider */
264    $(".slider.parallax").each(function () {
265        var $this = $(this),
266            speed = $this.data("speed"),
267            duration = $this.data("duration"),
268
269            slideContainer = $this.find(".slides").first(),
270            slides = slideContainer.children(".slide"),
271
272            maxSlideIndex = slides.length,
273            i = -1;
274
275        setInterval(function () {
276            i = ++i % maxSlideIndex;
277            $(slides[maxSlideIndex - i - 1])
278                .fadeOut(speed, function () {
279                    var slide = $(this);
280                    slide.prependTo(slideContainer);
281                    slide.show();
282                });
283        }, duration);
284    });
285
286    $(".usps_wrapper").usps({
287        slideSpeed: 400
288    });
289});
290
291
292//========================================
293//  RESIZE
294//========================================
295
296window.onresize = function () {
297    EqualContainerHeights();
298
299    if (dimensions.isXS())
300        ScaleYoutubeEmbeds();
301
302    // Get the new dimensions
303    var newDimensions = GetDimensionBools();
304    // If the new dimensions are equal to the old, return
305    if (JSON.stringify(dimensions) === JSON.stringify(newDimensions))
306        return;
307    // If the new dimensions differentiate, set them as the current
308    dimensions = newDimensions;
309
310    // Trigger function
311    SetEqualHeights(GetRows(eqSelection), dimensions.isXS());
312    ScaleYoutubeEmbeds();
313};
314
315// Returns the current active grids
316function GetDimensionBools() {
317    var width = window.innerWidth;
318    return {
319        lg: width >= 1200, md: width >= 992, sm: width >= 768, xs: width >= 0,
320        isXS: function () {
321            return !this.sm && this.xs;
322        },
323        isSM: function () {
324            return !this.md && this.sm;
325        },
326        isMD: function () {
327            return !this.lg && this.md;
328        },
329        isLG: function () {
330            return this.lg;
331        }
332    };
333}
334
335//========================================
336//  HELPER FUNCTIONS
337//========================================
338
339function GetAnimationEvent() {
340    var a, el = document.createElement("xanim"),
341        animations = {
342            "animation": "animationend",
343            "OAnimation": "oAnimationEnd",
344            "MozAnimation": "animationend",
345            "WebkitAnimation": "webkitAnimationEnd"
346        };
347    for (a in animations) {
348        if (el.style[a] !== undefined) {
349            return animations[a];
350        }
351    }
352}
353
354//==================================================
355//  YOUTUBE EMBED (Pure JS)
356//==================================================
357
358var videos = document.getElementsByClassName('ytvideo'),
359    ratio = 9 / 16;
360
361function ScaleYoutubeEmbeds() {
362    for (var i = 0, j = videos.length; i < j; i++) {
363        var video = videos[i],
364            iframe = video.children[0],
365            maxHeight = parseInt(video.style.maxHeight),
366            maxWidth = maxHeight / ratio;
367
368        if (maxHeight) {
369            video.style.maxWidth = maxWidth;
370            iframe.style.maxWidth = maxWidth;
371        }
372
373        var height = maxHeight / maxWidth * maxHeight + "px";
374        video.style.height = height;
375        iframe.style.height = height;
376    }
377}
378
379//==================================================
380//  EQUAL HEIGHT (Pure JS)
381//==================================================
382
383var eqSelection;
384
385// Returns all the rows with components that are in the same row
386function GetRows(elements) {
387    var tolerance = 1,
388        lastTop = null,
389        rows = [];
390
391    // Group elements by their top position
392    for (var i = 0, j = elements.length; i < j; i++) {
393        var element = elements[i],
394            // Get the distance between the element and the top
395            top = (element.getBoundingClientRect().top + document.body.scrollTop) -
396                (element.style.marginTop || 0),
397            lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
398
399        // If there exists a row and the row top is the same, add to the row group
400        if (lastRow !== null && Math.floor(Math.abs(lastTop - top)) <= tolerance) {
401            rows[rows.length - 1].push(element);
402        } else {
403            // Else we create a new row group
404            rows.push([element]);
405        }
406
407        // Keep track of the last row top
408        lastTop = top;
409    }
410
411    return rows;
412}
413
414function SetEqualHeights(rows, auto) {
415    // Loop through each row detected
416    for (var i = 0, j = rows.length; i < j; i++) {
417        var row = rows[i],
418            // Get the count of the elements in a column
419            // First column > get children length
420            elementCount = row[0].children.length;
421
422        for (var ii = 0; ii < elementCount; ii++) {
423            // Get all the same elements from the column and set their height to auto
424            var elements = row.map(function (obj) {
425                // Get the child based on the index
426                var element = obj.children[ii];
427                element.style.height = "auto";
428                return element;
429            });
430
431            // If we don't want to enable maxheight, go to the next element
432            if (auto) continue;
433
434            // Get the maximum height of the collected elements above
435            var maxHeight = Math.max.apply(Math, elements.map(function (obj) {
436                return obj.offsetHeight;
437            }));
438
439            // Apply the max height to each element
440            elements.map(function (obj) {
441                obj.style.height = maxHeight + "px";
442            });
443        }
444    }
445}
446
447function EqualElementHeights(elements) {
448    // Get the maximum height of all given elements
449    var maxHeight = Math.max.apply(Math, elements.map(function (obj) {
450        return obj.offsetHeight;
451    }));
452
453    // Apply the max height to each element
454    elements.map(function (obj) {
455        obj.style.height = maxHeight + "px";
456    });
457}
458
459function EqualContainerHeights(elements) {
460    // If the elements are passed manually, set them
461    if (elements && elements instanceof Array) {
462        EqualElementHeights(elements);
463        return;
464    }
465
466    // Convert to array - Array.from is not supported by IE
467    // Get all elements which have a class starting with eq-
468    var eqElements = Array.prototype.slice.call(document.querySelectorAll("[class*=eq-]"));
469
470    // Create object to store the elements in arrays sorted by classname
471    var sortedElements = {};
472
473    // Loop through every element starting with eq-
474    for (var i = 0, j = eqElements.length; i < j; i++) {
475        var eqElement = eqElements[i];
476
477        // Loop through the elements class list
478        for (var ii = 0, jj = eqElement.classList.length; ii < jj; ii++) {
479            var className = eqElement.classList[ii];
480
481            // If the current class does not start with eq-, go to the next class
482            if (!className.startsWith("eq-")) continue;
483
484            // If there exists a key identical to the className in the sortedElements,
485            // add the current element to the array
486            if (className in sortedElements) {
487                sortedElements[className].push(eqElement);
488            } else {
489                // Else create a new array with the element in it
490                sortedElements[className] = [eqElement];
491            }
492            break;
493        }
494    }
495
496    // Loop through every key in the sortedElements and pass the elements to
497    // EqualElementsHeights which handles the equal height functionality
498    for (var key in sortedElements) {
499        if (!sortedElements.hasOwnProperty(key)) continue;
500        EqualElementHeights(sortedElements[key]);
501    }
502}
503
504// //==================================================
505// //  GRAVITY FORMS
506// //==================================================
507//
508// /* Gravity Forms Required Stars */
509// function addStars() {
510//     var req = $('<span/>').addClass('gfield_required star').css({
511//         'font-size': '18px',
512//         position: 'absolute',
513//         right: '16px',
514//         top: '14px',
515//         color: '#A63232'
516//     }).text('*');
517//     $('.gfield_contains_required > .ginput_container').css('position', 'relative').prepend(req);
518// }
519// addStars();
520// $document.bind('gform_post_render', addStars);
521
522
523//==================================================
524//  FAQ
525//==================================================
526
527$(".faq-q").click(function () {
528    var $this = $(this),
529        container = $this.closest(".faq-c"),
530        answer = container.children(".faq-a"),
531        trigger = $this.children(".faq-t");
532
533    answer.slideToggle(200);
534
535    trigger.toggleClass("faq-o");
536    container.toggleClass("open");
537});
538
539
540//==================================================
541//  CUSTOM
542//==================================================
543

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.