PageSourceSearch

https://farnleyclayshoot.cyou/wp-content/themes/ogma-blog/assets/js/main-scripts.js?ver=1.0.0

js farnleyclayshoot.cyou collected 2026-10-07 20:22:54 UTC 11,047 bytes, 322 lines download raw bytes

1/**
2 * Files to manage theme scripts.
3 *
4 * @package Ogma Blog
5 */
6
7jQuery(document).ready(function($) {
8
9    var headerSticky    = OG_JSObject.header_sticky,
10        sidebarSticky   = OG_JSObject.sidebar_sticky,
11        liveSearch      = OG_JSObject.live_search,
12        ajaxUrl         = OG_JSObject.ajaxUrl,
13        _wpnonce        = OG_JSObject._wpnonce,
14        KEYCODE_TAB     = 9;
15
16
17    var rtl = false;
18    var dir = "left";
19    if ($('body').hasClass("rtl")) {
20        rtl = true;
21        dir = "right";
22    };
23
24    /**
25     * Preloader
26     */
27    if ($('#ogma-blog-preloader').length > 0) {
28        setTimeout(function() {
29            $('#ogma-blog-preloader').hide();
30        }, 600);
31    }
32
33    // top header time
34    var timeElement = $(".top-header-date-wrap .time")
35    if (timeElement.length > 0) {
36        setInterval(function() {
37            timeElement.html(new Date().toLocaleTimeString())
38        }, 1000);
39    }
40
41    /**
42     * Default widget tabbed
43     */
44    $("#banner-tabbed").tabs();
45
46    // site mode switcher
47    function siteModeToggle(siteModeVal) {
48        $.removeCookie('ogma-blog-site-mode-cookie', {
49            path: '/'
50        });
51        if (siteModeVal === 'light-mode') {
52            updateVal = 'dark-mode';
53        } else {
54            updateVal = 'light-mode';
55        }
56        $("#mode-switcher").removeClass(siteModeVal);
57        $("#mode-switcher").addClass(updateVal);
58        $('body').removeClass(siteModeVal);
59        $('body').addClass(updateVal);
60        var exDate = new Date();
61        exDate.setTime(exDate.getTime() + (3600 * 1000)); // expire in 1 hr
62        $.cookie('ogma-blog-site-mode-cookie', updateVal, {
63            expires: exDate,
64            path: '/'
65        });
66    }
67
68    $("#mode-switcher").click(function(event) {
69        event.preventDefault();
70        var siteModeClass = $(this).attr('class');
71        siteModeAttr = $(this).data('site-mode');
72
73        if ($(this).hasClass(siteModeAttr)) {
74            siteModeToggle(siteModeAttr);
75        } else {
76            siteModeToggle(siteModeClass);
77        }
78    });
79
80    /**
81     * Scripts for Header Sticky Sidebar
82     */
83    $('.sidebar-menu-toggle').click(function() {
84        $('.sticky-header-sidebar').toggleClass('isActive');
85    });
86
87    $('.sticky-sidebar-close,.sticky-header-sidebar-overlay').click(function() {
88        $('.sticky-header-sidebar').removeClass('isActive');
89    });
90
91    // header news ticker
92    $('.ticker-posts').marquee({
93        duration: 50000,
94        delayBeforeStart: 0,
95        gap: 0,
96        direction: dir,
97        duplicated: true,
98        startVisible: true,
99        pauseOnHover: true,
100    });
101
102    // main banner slider
103    var mainSlider = $(".ogma-blog-banner-wrapper");
104    if (mainSlider.length) {
105        var secSlider = mainSlider.find(".slider-wrapper");
106        var slideControl = secSlider.data("control");
107        secSlider.lightSlider({
108            item: 1,
109            auto: false,
110            pager: false,
111            loop: true,
112            slideMargin: 0,
113            speed: 1000,
114            pause: 6000,
115            enableTouch: true,
116            rtl: rtl,
117            enableDrag: true,
118            pauseOnHover: true,
119            prevHtml: '<i class="bx bx-chevron-left"></i>',
120            nextHtml: '<i class="bx bx-chevron-right"></i>',
121            onSliderLoad: function() {
122                $('.slider-wrapper').removeClass('cS-hidden');
123            }
124        });
125    }
126
127    $('.ogma-blog-banner-wrapper .lSAction').appendTo('.ogma-blog-banner-wrapper .ogma-blog-container');
128
129    // carousel trending posts
130    $('.trending-posts-wrapper .trending-posts').lightSlider({
131        item: 4,
132        auto: true,
133        pager: false,
134        loop: true,
135        slideMargin: 0,
136        vertical: true,
137        speed: 1000,
138        pause: 6000,
139        enableTouch: true,
140        rtl: false,
141        enableDrag: true,
142        pauseOnHover: true,
143        prevHtml: '<i class="bx bx-chevron-up"></i>',
144        nextHtml: '<i class="bx bx-chevron-down"></i>',
145        onSliderLoad: function() {
146            $('.trending-posts').removeClass('cS-hidden');
147        }
148    });
149
150    /**
151     * Settings of the header sticky menu
152     */
153    if ('true' === headerSticky) {
154        var windowWidth = $(window).width();
155        if (windowWidth > 600) {
156            var wpAdminBar = $('#wpadminbar');
157            if (wpAdminBar.length) {
158                $("#masthead .primary-menu-wrapper").sticky({
159                    topSpacing: wpAdminBar.height()
160                });
161            } else {
162                $("#masthead .primary-menu-wrapper").sticky({
163                    topSpacing: 0
164                });
165            }
166        }
167    }
168
169    /**
170     * theia sticky sidebar
171     */
172
173    if ('true' === sidebarSticky) {
174        $('#primary, #secondary').theiaStickySidebar({
175            additionalMarginTop: 30
176        });
177
178        $('#primary, #left-secondary').theiaStickySidebar({
179            additionalMarginTop: 30
180        });
181
182        $('.primary-content-wrapper, .secondary-content-wrapper').theiaStickySidebar({
183            additionalMarginTop: 30
184        });
185    }
186
187
188    /**
189     * Scroll To Top
190     */
191    $(window).scroll(function() {
192        if ($(this).scrollTop() > 1000) {
193            $('#ogma-blog-scrollup').fadeIn('slow');
194        } else {
195            $('#ogma-blog-scrollup').fadeOut('slow');
196        }
197    });
198    $('#ogma-blog-scrollup').click(function() {
199        $("html, body").animate({
200            scrollTop: 0
201        }, 600);
202        return false;
203    });
204
205    //Search toggle
206    $('.header-search-wrapper .search-icon').click(function() {
207        $('.search-form-wrap').toggleClass('active-search');
208        $('.search-form-wrap .search-field').focus();
209        var element = document.querySelector('.header-search-wrapper');
210        if (element) {
211            $(document).on('keydown', function(e) {
212                if (element.querySelectorAll('.search-form-wrap.active-search').length === 1) {
213                    var focusable = element.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
214                    var firstFocusable = focusable[0];
215                    var lastFocusable = focusable[focusable.length - 1];
216                    ogma_blog_focus_trap(firstFocusable, lastFocusable, e);
217                }
218            })
219        }
220    });
221
222    //responsive menu toggle
223    $('.primary-menu-wrapper .ogma-blog-menu-toogle').click(function(event) {
224        $('#site-navigation .primary-menu-wrap').toggleClass('isActive').slideToggle('slow');
225        var element = document.querySelector('.primary-menu-wrapper');
226        if (element) {
227            $(document).on('keydown', function(e) {
228                if (element.querySelectorAll('#site-navigation .primary-menu-wrap.isActive').length === 1) {
229                    var focusable = element.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
230                    var firstFocusable = focusable[0];
231                    var lastFocusable = focusable[focusable.length - 1];
232                    ogma_blog_focus_trap(firstFocusable, lastFocusable, e);
233                }
234            })
235        }
236    });
237
238    //responsive sub menu toggle
239    $('<a class="ogma-blog-sub-toggle" href="javascript:void(0);"><i class="bx bx-chevron-down"></i></a>').insertAfter('#site-navigation .menu-item-has-children>a, #site-navigation .page_item_has_children>a');
240
241    $('#site-navigation .ogma-blog-sub-toggle').click(function() {
242        $(this).parent('.menu-item-has-children').children('ul.sub-menu').first().slideToggle('1000');
243        $(this).parent('.page_item_has_children').children('ul.children').first().slideToggle('1000');
244        $(this).children('.bx-chevron-up').first().toggleClass('bx-chevron-down');
245    });
246
247    //-------------------------------live search------------------------------------------------
248    if (liveSearch === 'true') {
249        var searchContainer = $(".header-search-wrapper");
250
251        if (searchContainer.length > 0) {
252            var searchFormContainer = searchContainer.find("form");
253
254            searchContainer.on('input', 'input[type="search"]', function() {
255                var searchKey = $(this).val();
256
257                if (searchKey) {
258                    $.ajax({
259                        method: 'post',
260                        url: ajaxUrl,
261                        data: {
262                            action: 'ogma_blog_search_posts_content',
263                            search_key: searchKey,
264                            security: _wpnonce
265                        },
266                        beforeSend: function() {
267                            searchFormContainer.addClass('retrieving-posts');
268                            searchFormContainer.removeClass('results-loaded');
269                        },
270                        success: function(res) {
271                            var parsedRes = JSON.parse(res);
272                            searchContainer.find(".ogma-blog-search-results-wrap").remove();
273                            searchFormContainer.after(parsedRes.posts);
274                            searchFormContainer.removeClass('retrieving-posts').addClass('results-loaded');
275                        },
276                        complete: function() {
277                            // Render search content here
278                        }
279                    });
280                } else {
281                    searchContainer.find(".ogma-blog-search-results-wrap").remove();
282                    searchFormContainer.removeClass('results-loaded');
283                }
284            });
285        }
286    }
287
288    /**
289     * close live search
290     * 
291     * @since 1.0.0
292     */
293    $(document).mouseup(function (e) {
294        var container = $(".header-search-wrapper");
295        if (!container.is(e.target) && container.has(e.target).length === 0) {
296            container.find(".ogma-blog-search-results-wrap").remove();
297            container.removeClass('results-loaded');
298        }
299    });
300
301    /**
302     * focus trap
303     * 
304     * @returns void
305     * @since 1.0.0
306     */
307    function ogma_blog_focus_trap( firstFocusable, lastFocusable, e ) {
308        if (e.key === 'Tab' || e.keyCode === KEYCODE_TAB) {
309            if ( e.shiftKey ) /* shift + tab */ {
310                if (document.activeElement === firstFocusable) {
311                    lastFocusable.focus();
312                    e.preventDefault();
313                }
314            } else /* tab */ {
315                if ( document.activeElement === lastFocusable ) {
316                    firstFocusable.focus();
317                    e.preventDefault();
318                }
319            }
320        }
321    }   
322});

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.