PageSourceSearch

https://masongroup.ca/wp-content/themes/consulting/assets/js/custom.js?ver=1.1476213211

js masongroup.ca collected 2026-10-06 18:12:27 UTC 24,498 bytes, 619 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    jQuery(document).ready(function ($) {
5
6        var windowSize = $(window).width();
7        l18W();
8        stm_services_carousel();
9
10        $(window).on( "resize", function() {
11            l18W();
12            stm_stretch_column();
13            full_height_columns();
14        });
15
16        $.fn.is_on_screen = function () {
17            var win = $(window);
18            var viewport = {
19                top: win.scrollTop(),
20                left: win.scrollLeft()
21            };
22            viewport.right = viewport.left + win.width();
23            viewport.bottom = viewport.top + win.height();
24
25            var bounds = this.offset();
26            bounds.right = bounds.left + this.outerWidth();
27            bounds.bottom = bounds.top + this.outerHeight();
28
29            return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
30        };
31
32        $(".stm-register-form form").on( "submit", function(e) {
33            e.preventDefault();
34            $.ajax({
35                type: "POST",
36                url: ajaxurl,
37                dataType: 'json',
38                context: this,
39                data: $(this).serialize() + '&action=stm_custom_register&security=' + stm_custom_register,
40                beforeSend: function () {
41                    $(this).find('input').removeClass('form-error');
42                    $('.stm-validation-message').empty();
43                },
44                success: function (data) {
45
46                    for (var err in data.errors) {
47                        $(this).find('input[name=' + err + ']').addClass('form-error');
48                    }
49
50                    if (data.message) {
51                        var message = $('<div class="stm-message-ajax-validation heading-font">' + data.message + '</div>').hide();
52
53                        $(this).find('.stm-validation-message').append(message);
54                        message.slideDown('fast');
55                    }
56                }
57            });
58        });
59
60        $(document).on("click", ".load_more_btn", function (e) {
61            e.preventDefault();
62            var page = $(this).attr("data-page");
63            var load_by = $(this).attr("data-load");
64            var filter = $(this).attr("data-filter");
65            var category = $(this).attr('data-category');
66            $.ajax({
67                url: ajaxurl,
68                type: "POST",
69                dataType: "json",
70                data: "&page=" + page + "&load_by=" + load_by + "&category=" + category + "&filter=" + filter + "&action=stm_ajax_load_events&security=" + stm_ajax_load_events,
71                context: this,
72                beforeSend: function (data) {
73                    $(this).parent().addClass("event_posts_loading");
74                },
75                success: function (data) {
76                    $(this).parent().removeClass("event_posts_loading");
77                    $(".stm_events_modern_list ").append(data.html);
78                    $(this).attr("data-page", data.new_page);
79                    if (!data.load_more) {
80                        $(this).remove();
81                    }
82                }
83            });
84        });
85
86        $('.scroll_to_event_form').on('click', function (e) {
87            event.preventDefault();
88            $('html,body').animate({scrollTop: $(this.hash).offset().top}, 500);
89        });
90
91        $('.show_popup').on('click', function (e) {
92            $(this).parents().find('#video').addClass('video_popup_box')
93        });
94
95        stm_stretch_column();
96
97        function stm_stretch_column() {
98            $('.wpb_column[data-stretch]').each(function () {
99                var stretch = $(this).data('stretch');
100                var xPos = $(this).offset().left;
101                var wW = $(window).width();
102                var xW = $(this).width();
103
104                var value = wW - (xW + xPos);
105                if (stretch == 'left') {
106                    value = xPos;
107                }
108
109                $(this).find('.vc_column-inner').css('width', xW + value + 'px');
110                $(this).find('.vc_column-inner').css('margin-' + stretch, '-' + value + 'px');
111            });
112        };
113
114        //Full height
115        full_height_columns();
116
117        function full_height_columns() {
118
119            $(".full_height_columns").each(function () {
120                var full_height_columns = $(this).find(".wpb_column:first").height();
121                $(this).find("iframe").css("height", full_height_columns);
122            });
123        };
124
125        stm_ajax_add_event_member();
126
127        function stm_ajax_add_event_member() {
128            $("#event-members-form").on("submit", function (event) {
129                event.preventDefault();
130
131                var $this = $(this),
132                    eventID = parseInt($($this).find('input[name="event_member_id"]').val()),
133                    addedEvents = localStorage.getItem('addedEvents'),
134                    eventAdded = false;
135
136                if (addedEvents) {
137                    addedEvents = JSON.parse(addedEvents);
138                    eventAdded = $.inArray(eventID, addedEvents) > -1;
139                }
140                if (!eventAdded) {
141                    $.ajax({
142                        url: ajaxurl,
143                        type: "POST",
144                        dataType: "json",
145                        context: this,
146                        data: $(this).serialize() + "&action=stm_ajax_add_event_member&security=" + stm_ajax_add_event_member_sc,
147                        beforeSend: function () {
148                            $(".alert-modal").remove();
149                            $(this).closest("form").find("input").removeClass("form-error");
150                            $(this).closest("form").find(".stm-ajax-loader").addClass("loading");
151                        },
152                        success: function (data) {
153                            $(this).closest("form").find(".stm-ajax-loader").removeClass("loading");
154
155                            $(this).closest("form").find(".event-members-box").append('<div class="alert-modal alert alert-' + data.status + ' text-left">' + data.response + '</div>');
156                            for (var key in data.errors) {
157                                $('#event-members-form input[name="' + key + '"]').addClass("form-error");
158                            }
159                            if (!$('#event-members-form input[name="' + key + '"]').hasClass('form-error')) {
160                                $(".event-members-box-table .event-attended-count").text(parseInt($(".event-members-box-table .event-attended-count").text()) + 1);
161                                $(".event-attended-count.event-new-count").text(parseInt($(".event-attended-count.event-new-count").text()) + 1);
162                                if (addedEvents) {
163                                    addedEvents.push(eventID);
164                                } else {
165                                    addedEvents = [eventID];
166                                }
167                                localStorage.setItem('addedEvents', JSON.stringify(addedEvents));
168                                $($this).find(".form__notice_success").fadeIn(300);
169                            }
170                            $("#event-members-form button").addClass("disabled").prop('disabled', true);
171                        },
172                        complete: function (data) {
173                            $("#event-members-form")[0].reset();
174                        }
175                    });
176                    $(this).closest("form").find(".form-error").on("hover", function () {
177                        $(this).removeClass("form-error");
178                    });
179                } else {
180                    $($this).find(".form__notice_information").fadeIn(300);
181                }
182                return false;
183            });
184        }
185
186        $(".event_terms_conditions #event_terms_conditions").on("click", function (e) {
187            if ($(this).is(':checked')) {
188                $("#event-members-form button").removeClass("disabled").prop('disabled', false);
189            } else {
190                $("#event-members-form button").addClass("disabled").prop('disabled', true);
191            }
192        });
193
194        $(".event_joining .show_event_list_form").on("click", function (e) {
195            var eventItemValId = $(this).parents(".item").find(".event-item-id").val();
196            $(".stm_events_classic #event-members-form .event_member_id").val(eventItemValId);
197            $(".stm_events_list_form").show();
198            $(this).parents(".item").find(".event-attended-count").addClass("event-new-count");
199        });
200        $(".notice__hide").on("click", function (e) {
201            $(".stm_events_list_form").hide();
202            $("#event-members-form")[0].reset();
203            $("#event-members-form .alert-modal").hide();
204            $("#event-members-form .form__notice_information").hide();
205            $(".stm_events_classic .item").find(".event-attended-count").removeClass("event-new-count");
206        });
207
208        $(".events_lessons_box .event_lesson_tabs:first-child").addClass("active");
209        $('.events_lessons_box .event_lesson_tabs a').each(function (e) {
210            if ($(this).parent().hasClass("active")) {
211                $($(this).attr('href')).show();
212            }
213        });
214        $('.events_lessons_box .event_lesson_tabs a').on('click', function (e) {
215            $(this).parents(".events_lessons_box").find(".event_lesson_info").hide();
216            $(this).parents(".events_lessons_box").find(".event_lesson_tabs").removeClass("active");
217            $(this).parent().addClass("active");
218            $($(this).attr("href")).show();
219            return false;
220        });
221
222        $(document).on("click", ".js-open-search-box", function () {
223            $(this).closest(".header_search").toggleClass("active");
224            return false;
225        });
226
227        if ($(".wpb_revslider_element").length && $('body').hasClass("header_style_7")) {
228            $(".wpb_revslider_element").closest(".vc_row-no-padding").addClass("stm-revslider-wrapper");
229        }
230
231        $(document).on("click", "body", function (e) {
232            if (!$(e.target).closest(".header_search").length) {
233                $(".header_search").removeClass("active");
234
235            }
236        });
237
238        $("body .wpb_video_widget .wpb_wrapper .wpb_video_wrapper .play_video").on('click', function () {
239            $(this).parent().find('iframe').attr('allow', 'autoplay');
240            $(this).parent().addClass('active');
241            $(this).parent().find('iframe').attr('src', $(this).parent().find('iframe').attr('src') + '?autoplay=1').delay();
242            $(this).hide();
243            $(this).parent().find('img').hide();
244            $(this).parent().find('.video').show();
245            $(this).parent().addClass('show_video');
246            return false;
247        });
248
249        $(".staff_read_more").on('click', function () {
250            $(this).closest('.stm_staff_2').find('.full_description').slideToggle(150);
251            return false;
252        });
253
254        $("select:not(.stm_not_select2)").each(function () {
255            if (!$(this).closest(".gfield").hasClass("stm_not_select2")) {
256                $(this).select2({width: '100%', minimumResultsForSearch: '-1'});
257            }
258        });
259        if ($("#rating").length) {
260            $("#rating").select2('destroy');
261        }
262
263        if ($("#demos_switcher").length) {
264            $("#demos_switcher").select2("destroy");
265
266            $("#demos_switcher").select2({
267                templateResult: demosItemTemplate,
268                width: '100%',
269                minimumResultsForSearch: '-1'
270            });
271
272        }
273
274        if ($('body').hasClass('customizer_page')) {
275            $(".customizer_page .ui-tabs").remove();
276        }
277
278        $('#menu_toggle').on('click', function () {
279            $(this).toggleClass('open');
280            $('.mobile_header .top_nav_mobile').slideToggle(300);
281            return false;
282        });
283        $('#menu_toggle_button').on('click', function () {
284            $(this).toggleClass('open');
285            $('.header_side').each(function () {
286                if (!$(this).hasClass('show')) {
287                    $(this).addClass('show');
288                    if ($('body').hasClass('rtl')) {
289                        $(this).animate({right: "0"}, 300);
290                    } else {
291                        $(this).animate({left: "0"}, 300);
292                    }
293                } else {
294                    $(this).removeClass('show');
295                    if ($('body').hasClass('rtl')) {
296                        $(this).animate({right: "-100%"}, 600);
297                    } else {
298                        $(this).animate({left: "-100%"}, 600);
299                    }
300                }
301            });
302
303            return false;
304        });
305
306        $(".mobile_header .top_nav_mobile .main_menu_nav > li.menu-item-has-children > a").after('<span class="arrow"><i></i></span>');
307        $(".mobile_header .top_nav_mobile .main_menu_nav > li.menu-item-has-children > .sub-menu > .menu-item-has-children > a").after('<span class="arrow"><i class="fa fa-chevron-down"></i></span>');
308
309        $(".mobile_header .top_nav_mobile .main_menu_nav > li.menu-item-has-children .arrow").on('click', function () {
310            $(this).toggleClass('active');
311            $(this).closest('li').find('ul').first().slideToggle(300);
312        });
313
314        $(".mobile_header .top_nav_mobile .main_menu_nav > li.menu-item-has-children > a").on('click', function () {
315            if ($(this).attr('href') == '#') {
316                $(this).closest('li').find('ul').slideToggle(300);
317                $(this).closest('li').find('.arrow').toggleClass('active');
318            }
319        });
320
321        // Quantity actions
322        $('body').on('click', '.quantity_actions span', function () {
323            var quantityContainer = $(this).closest('.quantity'),
324                quantityInput = quantityContainer.find('.qty'),
325                quantityVal = quantityInput.val();
326
327            $('.shop_table.cart .button').removeAttr("disabled");
328
329            if ($(this).hasClass('plus')) {
330                quantityInput.val(parseInt(quantityVal) + 1);
331            } else if ($(this).hasClass('minus')) {
332                if (quantityVal > 1) {
333                    quantityInput.val(parseInt(quantityVal) - 1);
334                }
335            }
336        });
337
338        // Stiky Header
339        var headerHeight = $("#header").height();
340        var headerTop = $(".header_top").height();
341        var topBar = $(".top_bar").height();
342
343        $("#header .top_nav, #header .header_top").affix({
344            offset: {
345                top: headerHeight
346            }
347        });
348
349        $("#menu_toggle_button").affix({
350            offset: {
351                top: topBar
352            }
353        });
354
355        $("#wrapper").on( "scroll", function() {
356            if ($(".sticky_menu .header_top, .sticky_menu .top_nav").hasClass('affix')) {
357                $("#header").css("paddingBottom", headerTop);
358            } else {
359                $("#header").css("paddingBottom", 0);
360            }
361        });
362
363        $(".top_bar_info_switcher .active").on('click', function () {
364
365            if ($(".top_bar_info_switcher ul").is(':visible')) {
366                $(".top_bar_info_switcher ul").slideUp(100);
367            } else {
368                $(".top_bar_info_switcher ul").slideDown(100);
369            }
370
371            return false;
372        });
373
374        $(".top_bar_info_switcher a").on('click', function () {
375            var id = $(this).attr('href');
376            var title = $(this).text();
377            $(".top_bar_info").hide();
378            $(id).show();
379            $(".top_bar_info_switcher .active span").text(title);
380            $(".top_bar_info_switcher ul").slideUp(100);
381            return false;
382        });
383
384        if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
385            stm_animate_block();
386        } else {
387            $(".stm_animation").css('opacity', 1);
388        }
389
390        jQuery(window).on( "scroll", function() {
391            if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
392                stm_animate_block();
393            } else {
394                $(".stm_animation").css('opacity', 1);
395            }
396        });
397
398        $('.single-product .product-type-variable table.variations select').on("change", function () {
399            $(this).parent().find('.select2-selection__rendered').text($(this).find('option[value="' + $(this).val() + '"]').text());
400        });
401
402        /*Adds*/
403        if (typeof($.fancybox) !== 'undefined') {
404            $('.stm_fancy-iframe').fancybox({
405                type: 'iframe',
406                padding: 0,
407                maxWidth: '800px',
408                width: '100%',
409                fitToView: false,
410                afterLoad: function () {
411                    var url = $(this.element).data('url');
412                    this.href = url;
413                }
414            });
415
416            $('.stm_fancybox').fancybox({
417                fitToView: false,
418                padding: 30,
419                maxWidth: '500px',
420                autoSize: true,
421                closeClick: false,
422                openEffect: 'none',
423                closeEffect: 'none'
424            });
425        }
426
427        $('[data-scroll-to]').on('click', function (e) {
428            var url = $(this).attr('data-scroll-to');
429            if (typeof(url) !== 'undefined') {
430                var url_parsed = url.split('#');
431                if (typeof(url_parsed[1]) !== 'undefined' && $('#' + url_parsed[1]).length > 0) {
432                    $('html, body').stop().animate({
433                        scrollTop: $('#' + url_parsed[1]).offset().top
434                    }, 700);
435                } else {
436                    window.location.href = url;
437                }
438            }
439        });
440
441        if ($('body').hasClass('site_layout_19')) {
442            $('.top_nav li a').on('click', function (e) {
443                e.preventDefault();
444                var url = $(this).attr('href');
445                if (typeof(url) !== 'undefined') {
446                    var url_parsed = url.split('#');
447                    if (typeof(url_parsed[1]) !== 'undefined' && $('#' + url_parsed[1]).length > 0) {
448                        $('html, body').stop().animate({
449                            scrollTop: $('#' + url_parsed[1]).offset().top - 50
450                        }, 700);
451                    } else {
452                        window.location.href = url;
453                    }
454                }
455            });
456        }
457
458        $('.stm_top_bar_l13-search button').on('click', function (e) {
459            var $wr = $(this).closest('.stm_top_bar_l13-search');
460            if ($wr.hasClass('active')) {
461                if ($wr.find('input').val() == '') {
462                    e.preventDefault();
463                    $wr.removeClass('active active-focus');
464                }
465            } else {
466                e.preventDefault();
467                $wr.addClass('active active-focus');
468                setTimeout(function () {
469                    $wr.find('input').focus();
470                }, 300);
471            }
472        });
473
474        $('body').on('click', function (e) {
475            if ($(e.target).closest('.stm_top_bar_l13-search').length === 0) {
476                var $wr = $('.stm_top_bar_l13-search');
477                $wr.find('input').focusout();
478                $wr.removeClass('active active-focus');
479            }
480        });
481
482    });
483
484    jQuery(window).on( "load", function() {
485        l18W();
486        if ($('html').hasClass('stm-site-preloader')) {
487            $('html').addClass('stm-site-loaded');
488
489            setTimeout(function () {
490                $('html').removeClass('stm-site-preloader stm-site-loaded');
491            }, 250);
492
493            $(window).on('onbeforeunload', function (e) {
494                $('html').addClass('stm-site-preloader stm-after-hidden');
495            });
496
497            if ($('a[href^=mailto], a[href^=skype], a[href^=tel]').on('click', function (e) {
498                    setTimeout(function () {
499                        $('html').removeClass('stm-site-preloader stm-site-loaded');
500                    });
501                })) ;
502        }
503    });
504
505    function stm_animate_block() {
506        jQuery('.stm_animation').each(function () {
507            if (jQuery(this).attr('data-animate')) {
508                var animation_blocks = jQuery(this).children('*');
509                var animationName = jQuery(this).attr('data-animate'),
510                    animationDuration = jQuery(this).attr('data-animation-duration') + 's',
511                    animationDelay = jQuery(this).attr('data-animation-delay');
512                var style = 'opacity:1;-webkit-animation-delay:' + animationDelay + 's;-webkit-animation-duration:' + animationDuration + '; -moz-animation-delay:' + animationDelay + 's;-moz-animation-duration:' + animationDuration + '; animation-delay:' + animationDelay + 's;';
513                var container_style = 'opacity:1;-webkit-transition-delay: ' + (animationDelay) + 's; -moz-transition-delay: ' + (animationDelay) + 's; transition-delay: ' + (animationDelay) + 's;';
514                if (isAppear(jQuery(this))) {
515                    jQuery(this).attr('style', container_style);
516                    jQuery.each(animation_blocks, function (index, value) {
517                        jQuery(this).attr('style', style);
518                        jQuery(this).addClass('animated').addClass(animationName);
519                    });
520                }
521            }
522        });
523    }
524
525    function isAppear(id) {
526        var window_scroll = jQuery(window).scrollTop();
527        var window_height = jQuery(window).height();
528
529        if (jQuery(id).hasClass('stm_viewport')) {
530            var start_effect = jQuery(id).data('viewport_position');
531        }
532
533        if (typeof(start_effect) === 'undefined' || start_effect == '') {
534            var percentage = 2;
535        } else {
536            var percentage = 100 - start_effect;
537        }
538        var element_top = jQuery(id).offset().top;
539        var position = element_top - window_scroll;
540
541        var cut = window_height - (window_height * (percentage / 100));
542        if (position <= cut) {
543            return true;
544        } else {
545            return false;
546        }
547    }
548
549    function demosItemTemplate(state) {
550        if (!state.id) {
551            return state.text;
552        }
553        var $state = jQuery(
554            '<span class="' + state.element.value + '"> ' + state.text + '</span>'
555        );
556        return $state;
557    }
558
559    function l18W() {
560        var $ = jQuery;
561        if ($('body').hasClass('site_layout_18')) {
562            var contentW = $('#fullpage').outerWidth();
563            var contentArea = $('.content-area').outerWidth();
564            var fullWleft = contentW / 2;
565
566            var marginArea = (contentW - contentArea) / 2;
567            //$('.stm_bg_right').css('width', contentW + 'px');
568            $('.stm_fullwidth_left').css({
569                'width': fullWleft + 'px'
570            });
571
572            $('.stm_fullwidth_content').css({
573                'width': contentW + 'px',
574                'margin-right': '-' + marginArea + 'px'
575            })
576
577        }
578    }
579
580    function stm_services_carousel() {
581        $('.stm_services.style_3').each(function () {
582            var perRow = $(this).attr('data-per-row');
583            $(this).owlCarousel({
584                nav: false,
585                dots: true,
586                responsive: {
587                    0: {
588                        items: 1
589                    },
590                    480: {
591                        items: 2
592                    },
593                    768: {
594                        items: 3
595                    },
596                    1024: {
597                        items: perRow
598                    },
599                    1110: {
600                        items: perRow
601                    }
602                }
603            });
604        });
605
606        $('.stm_services.style_7').each(function () {
607            $(this).owlCarousel({
608                nav: false,
609                dots: true,
610                responsive: {
611                    0: {
612                        items: 1
613                    }
614                }
615            });
616        })
617    }
618})(jQuery);
619

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.