PageSourceSearch

https://hnmag.ca/wp-content/themes/retina-blog/js/custom-script.js?ver=1.1.7

js hnmag.ca collected 2026-10-03 17:43:41 UTC 10,505 bytes, 287 lines download raw bytes

1(function (e) {
2    "use strict";
3    var n = window.Thememattic_JS || {};
4    var iScrollPos = 0;
5    var loadType, loadButton, loader, pageNo, loading, morePost, scrollHandling;
6
7    function retina_blog_is_on_scrn(elem) {
8        // if the element doesn't exist, abort
9        if (elem.length == 0) {
10            return;
11        }
12        var tmtwindow = jQuery(window);
13        var viewport_top = tmtwindow.scrollTop();
14        var viewport_height = tmtwindow.height();
15        var viewport_bottom = viewport_top + viewport_height;
16        var tmtelem = jQuery(elem);
17        var top = tmtelem.offset().top;
18        var height = tmtelem.height();
19        var bottom = top + height;
20        return (top >= viewport_top && top < viewport_bottom) ||
21            (bottom > viewport_top && bottom <= viewport_bottom) ||
22            (height > viewport_height && top <= viewport_top && bottom >= viewport_bottom);
23    }
24
25    n.stickyMenu = function () {
26        if (e(window).scrollTop() > 350) {
27            e("#masthead").addClass("nav-affix");
28        } else {
29            e("#masthead").removeClass("nav-affix");
30        }
31    };
32    n.mobileMenu = {
33        init: function () {
34            this.toggleMenu();
35            this.menuMobile();
36            this.menuArrow();
37        },
38        toggleMenu: function () {
39            e('#masthead').on('click', '.toggle-menu', function (event) {
40                var ethis = e('.main-navigation .menu .menu-mobile');
41                if (ethis.css('display') == 'block') {
42                    ethis.slideUp('300');
43                } else {
44                    ethis.slideDown('300');
45                }
46                e('.ham').toggleClass('exit');
47            });
48            e('#masthead').on('keypress', function(event) {
49                var ethis = e('.main-navigation .menu .menu-mobile');
50                if (ethis.css('display') == 'block') {
51                    ethis.slideUp('300');
52                } else {
53                    ethis.slideDown('300');
54                }
55                e('.ham').toggleClass('exit');
56            });
57            e('#masthead .main-navigation ').on('click', '.menu-mobile a i', function (event) {
58                event.preventDefault();
59                var ethis = e(this),
60                    eparent = ethis.closest('li'),
61                    esub_menu = eparent.find('> .sub-menu');
62                if (esub_menu.css('display') == 'none') {
63                    esub_menu.slideDown('300');
64                    ethis.addClass('active');
65                } else {
66                    esub_menu.slideUp('300');
67                    ethis.removeClass('active');
68                }
69                return false;
70            });
71        },
72        menuMobile: function () {
73            if (e('.main-navigation .menu > ul').length) {
74                var ethis = e('.main-navigation .menu > ul'),
75                    eparent = ethis.closest('.main-navigation'),
76                    pointbreak = eparent.data('epointbreak'),
77                    window_width = window.innerWidth;
78                if (typeof pointbreak == 'undefined') {
79                    pointbreak = 991;
80                }
81                if (pointbreak >= window_width) {
82                    ethis.addClass('menu-mobile').removeClass('menu-desktop');
83                    e('.main-navigation .toggle-menu').css('display', 'block');
84                } else {
85                    ethis.addClass('menu-desktop').removeClass('menu-mobile').css('display', '');
86                    e('.main-navigation .toggle-menu').css('display', '');
87                }
88            }
89        },
90        menuArrow: function () {
91            if (e('#masthead .main-navigation div.menu > ul').length) {
92                e('#masthead .main-navigation div.menu > ul .sub-menu').parent('li').find('> a').append('<i class="icon-arrow-down icons">');
93            }
94        }
95    };
96    n.RetinaSearch = function () {
97        e('.icon-search').on('click', function (event) {
98            e('body').toggleClass('reveal-search');
99        });
100        e('.close-popup').on('click', function (event) {
101            e('body').removeClass('reveal-search');
102        });
103    };
104    n.DataBackground = function () {
105        var pageSection = e(".data-bg");
106        pageSection.each(function (indx) {
107            if (e(this).attr("data-background")) {
108                e(this).css("background-image", "url(" + e(this).data("background") + ")");
109            }
110        });
111        e('.bg-image').each(function () {
112            var src = e(this).children('img').attr('src');
113            e(this).css('background-image', 'url(' + src + ')').children('img').hide();
114        });
115    };
116    n.SlickCarousel = function () {
117        e(".main-slider").slick({
118            slidesToShow: 1,
119            slidesToScroll: 1,
120            fade: true,
121            autoplay: true,
122            autoplaySpeed: 8000,
123            infinite: true,
124            dots: true,
125            nextArrow: '<i class="slide-icon slide-next icon-arrow-right icons"></i>',
126            prevArrow: '<i class="slide-icon slide-prev icon-arrow-left icons"></i>',
127        });
128        e(".gallery-columns-1, ul.wp-block-gallery.columns-1, .wp-block-gallery.columns-1 .blocks-gallery-grid").each(function () {
129            e(this).slick({
130                slidesToShow: 1,
131                slidesToScroll: 1,
132                fade: true,
133                autoplay: true,
134                autoplaySpeed: 8000,
135                infinite: true,
136                dots: false,
137                nextArrow: '<i class="slide-icon slide-next icon-arrow-right icons"></i>',
138                prevArrow: '<i class="slide-icon slide-prev icon-arrow-left icons"></i>',
139            });
140        });
141    };
142    n.Thememattic_preloader = function () {
143  
144            e("body").addClass("page-loaded");
145
146    };
147    n.MagnificPopup = function () {
148        e('.widget .gallery, .entry-content .gallery, .wp-block-gallery').each(function () {
149            e(this).magnificPopup({
150                delegate: 'a',
151                type: 'image',
152                gallery: {
153                    enabled: true
154                },
155                zoom: {
156                    enabled: true,
157                    duration: 300,
158                    opener: function (element) {
159                        return element.find('img');
160                    }
161                }
162            });
163        });
164    };
165    n.show_hide_scroll_top = function () {
166        if (e(window).scrollTop() > e(window).height() / 2) {
167            e("#scroll-up").fadeIn(300);
168        } else {
169            e("#scroll-up").fadeOut(300);
170        }
171    };
172    n.scroll_up = function () {
173        e("#scroll-up").on("click", function () {
174            e("html, body").animate({
175                scrollTop: 0
176            }, 800);
177            return false;
178        });
179    };
180    n.thememattic_matchheight = function () {
181        e('.widget-area').theiaStickySidebar({
182            additionalMarginTop: 30
183        });
184    };
185    n.nav_tab = function () {
186        e('.tab-trigger').on('click', function () {
187            e([e(this).parent()[0], e(e(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
188        });
189    };
190    n.setLoadPostDefaults = function () {
191        if (e('.load-more-posts').length > 0) {
192            loadButton = e('.load-more-posts');
193            loader = e('.load-more-posts .ajax-loader');
194            loadType = loadButton.attr('data-load-type');
195            pageNo = 2;
196            loading = false;
197            morePost = true;
198            scrollHandling = {
199                allow: true,
200                reallow: function () {
201                    scrollHandling.allow = true;
202                },
203                delay: 400
204            };
205        }
206    };
207    n.fetchPostsOnScroll = function () {
208        if ( !e('.load-more-posts').hasClass('tmt-no-post') && !e('.load-more-posts').hasClass('tmt-post-loding') && e('.load-more-posts').hasClass('scroll') && retina_blog_is_on_scrn('.load-more-posts')) {
209
210            e('.load-more-posts').addClass('tmt-post-loding');
211            n.ShowPostsAjax();
212
213        }
214    };
215    n.fetchPostsOnClick = function () {
216        if (e('.load-more-posts').length > 0 && 'click' === loadType) {
217            e('.load-more-posts a').on('click', function (event) {
218                event.preventDefault();
219                n.ShowPostsAjax(loadType);
220            });
221        }
222    };
223    n.ShowPostsAjax = function (loadType) {
224        e.ajax({
225            type: 'GET',
226            url: retinaVal.ajaxurl,
227            data: {
228                action: 'retina_blog_load_more',
229                nonce: retinaVal.nonce,
230                page: pageNo,
231                post_type: retinaVal.post_type,
232                search: retinaVal.search,
233                cat: retinaVal.cat,
234                taxonomy: retinaVal.taxonomy,
235                author: retinaVal.author,
236                year: retinaVal.year,
237                month: retinaVal.month,
238                day: retinaVal.day
239            },
240            dataType: 'json',
241            beforeSend: function () {
242                loader.addClass('ajax-loader-enabled');
243            },
244            success: function (response) {
245                e('.load-more-posts').removeClass('tmt-post-loding');
246                loader.removeClass('ajax-loader-enabled');
247                if (response.success) {
248                    e('.retina-posts-lists').append(response.data.content);
249                    pageNo++;
250                    loading = false;
251                    if (!response.data.more_post) {
252                        morePost = false;
253                        loadButton.fadeOut();
254                    }
255                } else {
256                    e('.load-more-posts').addClass('tmt-no-post');
257                    loadButton.fadeOut();
258                }
259            }
260        });
261    };
262	
263	e(window).load(function () {
264        n.Thememattic_preloader();
265	});
266	
267    e(document).ready(function () {
268        n.mobileMenu.init();
269        n.RetinaSearch();
270        n.DataBackground();
271        n.SlickCarousel();
272        n.MagnificPopup();
273        n.scroll_up();
274        n.thememattic_matchheight();
275        n.nav_tab();
276        n.setLoadPostDefaults();
277        n.fetchPostsOnClick();
278    });
279    e(window).scroll(function () {
280        n.stickyMenu();
281        n.show_hide_scroll_top();
282        n.fetchPostsOnScroll();
283    });
284    e(window).resize(function () {
285        n.mobileMenu.menuMobile();
286    });
287})(jQuery);

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.