PageSourceSearch

https://arthatama.cyou/wp-content/themes/viral-mag/js/custom.js?ver=2.0.60

js arthatama.cyou collected 2026-10-07 20:13:47 UTC 7,775 bytes, 267 lines download raw bytes

1/**
2 * Viral Mag Custom JS
3 *
4 * @package Viral Mag
5 *
6 * Distributed under the MIT license - http://opensource.org/licenses/MIT
7 */
8
9jQuery(function ($) {
10    /*---------scroll To Top---------*/
11    $(window).scroll(function () {
12        if ($(window).scrollTop() > 300) {
13            $('#back-to-top').addClass('vm-show');
14        } else {
15            $('#back-to-top').removeClass('vm-show');
16        }
17    });
18
19    $('#back-to-top').click(function (e) {
20        e.preventDefault();
21        $('html,body').animate({
22            scrollTop: 0
23        }, 800);
24    });
25
26    /*---------Popup Search---------*/
27    $('.vm-search-button a').click(function () {
28        $('.vm-search-wrapper').addClass('vm-search-triggered');
29        setTimeout(function () {
30            viralMagSearchModalFocus($('.vm-search-wrapper'));
31        }, 1000);
32        return false;
33    });
34
35    $('.vm-search-close').click(function () {
36        $('.vm-search-wrapper').removeClass('vm-search-triggered');
37        $('.vm-search-button a').focus();
38    });
39
40    /*---------OffCanvas Sidebar---------*/
41    $('.vm-offcanvas-nav a').click(function () {
42        $('body').addClass('vm-offcanvas-opened');
43        setTimeout(function () {
44            viralMagOffcanvasFocus($('.vm-offcanvas-sidebar'));
45        }, 1000);
46    });
47
48    $('.vm-offcanvas-close, .vm-offcanvas-sidebar-modal').click(function () {
49        $('body').removeClass('vm-offcanvas-opened');
50        $('.vm-offcanvas-nav a').focus();
51    });
52
53    $('.vm-offcanvas-sidebar .widget_nav_menu .menu-item-has-children > a').append('<span class="vm-dropdown"></span>');
54
55    $(document).keydown(function (e) {
56        // ESCAPE key pressed
57        if (e.keyCode == 27 && $('body').hasClass('vm-offcanvas-opened')) {
58            $('body').removeClass('vm-offcanvas-opened');
59        }
60    });
61
62    $('.vm-dropdown').on('click', function () {
63        $(this).parent('a').next('ul').slideToggle();
64        $(this).toggleClass('vm-opened');
65        return false;
66    })
67
68    /*---------Header Time---------*/
69    startTime();
70
71    /*---------Main Menu Dropdown---------*/
72    $('.vm-menu > ul').superfish({
73        delay: 500,
74        animation: {
75            opacity: 'show'
76        },
77        speed: 'fast'
78    });
79
80    $(' #vm-mobile-menu .menu-collapser').on('click', function () {
81        $(this).next('ul').slideToggle();
82        viralMagMenuFocus($(' #vm-mobile-menu'));
83    });
84
85    $(' #vm-responsive-menu .menu-item-has-children > a').append('<button class="dropdown-nav ei arrow_carrot-down"></button>');
86
87    $(' #vm-responsive-menu .dropdown-nav').on('click', function () {
88        $el = $(this);
89        if (!$el.hasClass('vm-opened')) {
90            $el.closest('a').next('ul').slideDown();
91            $el.addClass('vm-opened');
92        } else {
93            $el.closest('a').next('ul').slideUp();
94            $el.removeClass('vm-opened');
95        }
96
97        $el.off('keydown');
98        setTimeout(function () {
99            viralMagKeyboardLoop($(' #vm-mobile-menu'));
100            $el.focus();
101        }, 500);
102
103        return false;
104    })
105
106    /*---------Sticky Header---------*/
107    var hHeight = 0;
108    var adminbarHeight = 0;
109
110    if ($('body').hasClass('admin-bar')) {
111        adminbarHeight = 32;
112    }
113
114    var $stickyHeader = $('.vm-header');
115
116    if ($('.vm-sticky-header').length > 0 && $stickyHeader.length > 0) {
117        hHeight = $stickyHeader.outerHeight();
118
119        if ($('body').hasClass('vm-header-style4')) {
120            hHeight = hHeight + 38
121        }
122        var hOffset = $stickyHeader.offset().top;
123
124        var offset = hOffset - adminbarHeight;
125
126        $stickyHeader.headroom({
127            offset: offset,
128            onTop: function () {
129                $(' #vm-content').css({
130                    paddingTop: 0
131                });
132            },
133            onNotTop: function () {
134                $(' #vm-content').css({
135                    paddingTop: hHeight + 'px'
136                });
137            }
138        });
139
140        $('.vm-sticky-sidebar .secondary-wrap').css('top', (hHeight + adminbarHeight + 40) + 'px');
141    }
142
143
144    /*---------Widgets---------*/
145    $('.vm-post-tab').each(function (index) {
146        $(this).find('.vm-pt-header .vm-pt-tab:first').addClass('vm-pt-active');
147        $(this).find('.vm-pt-content-wrap .vm-pt-content:first').show();
148    });
149
150    $('.vm-pt-tab').on('click', function () {
151        var id = $(this).data('id');
152        $(this).closest('.vm-post-tab').find('.vm-pt-tab').removeClass('vm-pt-active');
153        $(this).addClass('vm-pt-active');
154
155        $(this).closest('.vm-post-tab').find('.vm-pt-content').hide();
156        $('#' + id).show();
157    });
158
159    if ($('.vm-post-carousel').length > 0) {
160        $('.vm-post-carousel').owlCarousel({
161            rtl: JSON.parse(viral_mag_options.rtl),
162            items: 1,
163            loop: true,
164            mouseDrag: false,
165            nav: false,
166            dots: true,
167            autoplayTimeout: 6000,
168            autoplay: true,
169            smartSpeed: 600,
170            margin: 5
171        });
172    }
173
174
175    var hHeight = 0;
176    var adminbarHeight = 0;
177
178    if ($('body').hasClass('admin-bar')) {
179        adminbarHeight = 32;
180    }
181    var $stickyHeader = $('.vm-header');
182
183    if ($('.vm-sticky-header').length > 0 && $stickyHeader.length > 0) {
184        hHeight = $stickyHeader.outerHeight();
185    }
186
187    /*---------Sticky Sidebar---------*/
188    $('.vm-sticky-sidebar #secondary').theiaStickySidebar({
189        additionalMarginTop: hHeight + adminbarHeight + 40,
190        additionalMarginBottom: 40
191    });
192
193
194    function checkTime(i) {
195        return (i < 10) ? "0" + i : i;
196    }
197
198    function startTime() {
199        var today = new Date(),
200            h = checkTime(today.getHours()),
201            m = checkTime(today.getMinutes()),
202            s = checkTime(today.getSeconds());
203        $('.vm-time').html(h + ":" + m + ":" + s);
204        t = setTimeout(function () {
205            startTime()
206        }, 500);
207    }
208
209    var viralMagMenuFocus = function (elem) {
210        viralMagKeyboardLoop(elem);
211
212        elem.on('keyup', function (e) {
213            if (e.keyCode === 27) {
214                $(' #vm-responsive-menu').hide();
215                $('.menu-collapser').focus();
216            }
217        });
218    };
219
220    var viralMagSearchModalFocus = function (elem) {
221        viralMagKeyboardLoop(elem);
222
223        elem.on('keydown', function (e) {
224            if (e.keyCode == 27 && elem.hasClass('vm-search-triggered')) {
225                elem.removeClass('vm-search-triggered');
226                $('.vm-search-button a').focus();
227            }
228        });
229    };
230
231    var viralMagOffcanvasFocus = function (elem) {
232        viralMagKeyboardLoop(elem);
233
234        elem.on('keydown', function (e) {
235            if (e.keyCode == 27 && $('body').hasClass('vm-offcanvas-opened')) {
236                $('body').removeClass('vm-offcanvas-opened');
237                $('.vm-offcanvas-nav a').focus();
238            }
239        });
240    };
241
242    var viralMagKeyboardLoop = function (elem) {
243        var tabbable = elem.find('select, input, textarea, button, a').filter(':visible');
244
245        var firstTabbable = tabbable.first();
246        var lastTabbable = tabbable.last();
247
248        /*set focus on first input*/
249        firstTabbable.focus();
250
251        /*redirect last tab to first input*/
252        lastTabbable.on('keydown', function (e) {
253            if ((e.which === 9 && !e.shiftKey)) {
254                e.preventDefault();
255                firstTabbable.focus();
256            }
257        });
258
259        /*redirect first shift+tab to last input*/
260        firstTabbable.on('keydown', function (e) {
261            if ((e.which === 9 && e.shiftKey)) {
262                e.preventDefault();
263                lastTabbable.focus();
264            }
265        });
266    }
267});

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.