PageSourceSearch

https://www.turiweb.pe/wp-content/themes/vinkmag/assets/js/script.js?ver=24341303

js turiweb.pe collected 2026-10-02 07:49:15 UTC 24,957 bytes, 735 lines download raw bytes

1/*
2    Template Name: Vinkmag
3    Author: Themewinter
4    Author URI: https://themeforest.net/user/tripples
5    Description: vinkmag
6   Version: 1.0
7
8   ================================
9   table of content
10   =================================
11   1.   dropdown menu
12   2.   breking news slider
13   3.   featured post slider
14   4.   Most populer slider
15   5.   Gallery popup
16   6.   video popup
17   7.   video slider
18
19
20*/
21jQuery(document).ready(function ($) {
22    "use strict";
23
24    function DoPrevent(e) {
25        e.preventDefault();
26        e.stopPropagation();
27    }
28    if ($('#breaking_slider').length > 0) {
29        new Swiper($('#breaking_slider')[0], {
30            // Optional parameters
31            direction: 'horizontal',
32            loop: true,
33            effect: 'slide',
34            slidesPerView: 1,
35            speed: 600,
36            mousewheelControl: 1,
37            navigation: {
38                nextEl: '.swiper-button-next',
39                prevEl: '.swiper-button-prev',
40            },
41            breakpoints: {
42                0: {
43                    slidesPerView: 1,
44                },
45                // breakpoint from 480 up
46                480: {
47                    slidesPerView: 1,
48                },
49                // breakpoint from 768 up
50                768: {
51                    slidesPerView: 1,
52                },
53                // breakpoint from 768 up
54                1200: {
55                    slidesPerView: 1,
56                    allowTouchMove: true,
57                    mousewheel: {
58                        invert: true,
59                    },
60                }
61
62            }
63
64        });
65    }
66    if ($('#breaking_slider1').length > 0) {
67        new Swiper($('#breaking_slider1')[0], {
68            // Optional parameters
69            direction: 'horizontal',
70            loop: true,
71            effect: 'slide',
72            slidesPerView: 1,
73            speed: 600,
74            mousewheelControl: 1,
75            navigation: {
76                nextEl: '.swiper-button-next',
77                prevEl: '.swiper-button-prev',
78            },
79            breakpoints: {
80                0: {
81                    slidesPerView: 1,
82                },
83                // breakpoint from 480 up
84                480: {
85                    slidesPerView: 1,
86                },
87                // breakpoint from 768 up
88                768: {
89                    slidesPerView: 1,
90                },
91                // breakpoint from 768 up
92                1200: {
93                    slidesPerView: 1,
94                    allowTouchMove: true,
95                    mousewheel: {
96                        invert: true,
97                    },
98                }
99
100            }
101
102        });
103    }
104
105    if ($('.vinkmag-breaking-slider').length > 0) {
106        let controls = $('.vinkmag-breaking-slider').data('controls');
107        let widget_id = controls.widget_id;
108        new Swiper($('.vinkmag-breaking-slider')[0], {
109            // Optional parameters
110            direction: 'horizontal',
111            loop: true,
112            effect: 'slide',
113            slidesPerView: 1,
114            speed: 600,
115            mousewheelControl: 1,
116            navigation: {
117                nextEl: `.swiper-next-${widget_id}`,
118                prevEl: `.swiper-prev-${widget_id}`,
119            },
120            breakpoints: {
121                0: {
122                    slidesPerView: 1,
123                },
124                // breakpoint from 480 up
125                480: {
126                    slidesPerView: 1,
127                },
128                // breakpoint from 768 up
129                768: {
130                    slidesPerView: 1,
131                },
132                // breakpoint from 768 up
133                1200: {
134                    slidesPerView: 1,
135                    allowTouchMove: true,
136                    mousewheel: {
137                        invert: true,
138                    },
139                }
140
141            }
142
143        });
144    }
145
146    if ($('.vinkmag-featured-slider').length > 0) {
147        new Swiper('.vinkmag-featured-slider', {
148            // Optional parameters
149            direction: 'horizontal',
150            loop: true,
151            effect: 'slide',
152            slidesPerView: 1,
153            speed: 600,
154            mousewheelControl: 1,
155            navigation: {
156                nextEl: 'swiper-next-featured-slider',
157                prevEl: '.swiper-prev-featured-slider',
158            },
159            breakpoints: {
160                0: {
161                    slidesPerView: 1,
162                },
163                // breakpoint from 480 up
164                480: {
165                    slidesPerView: 1,
166                },
167                // breakpoint from 768 up
168                768: {
169                    slidesPerView: 1,
170                },
171                // breakpoint from 768 up
172                1200: {
173                    slidesPerView: 1,
174                    allowTouchMove: true,
175                    mousewheel: {
176                        invert: true,
177                    },
178                }
179
180            }
181
182        });
183    }
184    // Dynamic webfont loads
185    if (fontList) {
186        //eslint-disable-next-line
187        const observeFontList = fontList.map((fontName) => {
188            //eslint-disable-next-line
189            const observer = new FontFaceObserver(fontName);
190            return observer.load();
191        });
192
193        Promise.all(observeFontList).then(function () {
194            document.documentElement.className += 'fonts-loaded';
195        });
196    } else {
197        const arimoObserver = new FontFaceObserver('Arimo');
198        const heeboObserver = new FontFaceObserver('Heebo');
199        Promise.all([
200            arimoObserver.load(),
201            heeboObserver.load()
202        ]).then(function () {
203            document.documentElement.className += ' fonts-loaded';
204        });
205    }
206
207    // background image lazy load
208    const loadScripts_PreloadTimer = setTimeout(triggerScriptLoader_Preload, 8e3), userInteractionEvents_Preload = ["mouseover", "keydown", "touchstart", "touchmove", "wheel"]; function triggerScriptLoader_Preload() { document.querySelector("html").classList.add("is-active-page"), clearTimeout(loadScripts_PreloadTimer) } userInteractionEvents_Preload.forEach(function (e) { window.addEventListener(e, triggerScriptLoader_Preload, { passive: !0 }) });
209
210
211    $('.ekit-menu-nav-link.has-submenu').each(function () {
212        $(this).find('.sub-arrow').on('click', function (e) {
213            e.preventDefault();
214            $(this).parent().siblings().slideToggle()
215        })
216    });
217
218    if ($('.ekit-menu-init').find('.menu-item-has-children').length > 0) {
219        $('.ekit-menu-init').find('.menu-item-has-children').each(function () {
220            if ($(this).find('.sub-arrow').length > 1) {
221                $(this).find('.sub-arrow').not($(this).find('.sub-arrow').eq(1)).remove();
222            }
223        })
224    }
225
226    /**-------------------------------------------------
227      *Fixed HEader
228      *----------------------------------------------------**/
229    $(window).on('scroll', function () {
230
231        /**Fixed header**/
232        if ($(window).scrollTop() > 250) {
233            $('.navbar-fixed').addClass('sticky fade_down_effect');
234        } else {
235            $('.navbar-fixed').removeClass('sticky fade_down_effect');
236        }
237    });
238
239
240    $(window).on('load', function () {
241
242        /*==========================================================
243                    4. Preloader
244        =======================================================================*/
245        setTimeout(() => {
246            $('#preloader').addClass('loaded');
247        }, 1000);
248
249
250        $('.preloader-cancel-btn').on('click', function (event) {
251            event.preventDefault();
252            if (!$('#preloader').hasClass('loaded')) {
253                $('#preloader').addClass('loaded');
254            }
255        });
256
257        /* ---------------------------------------------
258                             Menu Toggle 
259           ------------------------------------------------ */
260
261        $('.dropdown > a').on('click', function (e) {
262            var dropdown = $(this).parent('.dropdown');
263            dropdown.find('>.dropdown-menu').slideToggle('show');
264            $(this).toggleClass('opened');
265            return false;
266        });
267
268
269        /* ----------------------------------------------------------- */
270        /*  index search
271        /* ----------------------------------------------------------- */
272        $(".header-search-btn-toggle").on("click", function (e) {
273            e.preventDefault();
274            if ($('.navbar-container .vinkmag-serach').length > 0) {
275                $('.navbar-container .vinkmag-serach').stop().fadeToggle(500);
276                $('.navbar-container .vinkmag-serach').find('input').focus();
277            }
278        });
279
280        function fix_menu() {
281            var h = $('#right-menu-element').width();
282            $('#navbar-main-container .navbar').css({
283                'padding-right': h + 'px'
284            });
285        }
286        fix_menu();
287        /* ----------------------------------------------------------- */
288        /*  popular slider on single post
289        /* ----------------------------------------------------------- */
290        function popular_grid_slider($) {
291            if ($('.popular-grid-slider').length > 0) {
292                new Swiper('.popular-grid-slider', {
293                    // Optional parameters
294                    direction: 'horizontal',
295                    loop: true,
296                    effect: 'slide',
297                    slidesPerView: 1,
298                    speed: 600,
299                    mousewheelControl: 1,
300                    navigation: {
301                        nextEl: '.swiper-next-popular-slider',
302                        prevEl: '.swiper-prev-popular-slider',
303                    },
304                    breakpoints: {
305                        0: {
306                            slidesPerView: 1,
307                        },
308                        // breakpoint from 480 up
309                        480: {
310                            slidesPerView: 2,
311                        },
312                        // breakpoint from 768 up
313                        768: {
314                            slidesPerView: 2,
315                        },
316                        // breakpoint from 768 up
317                        1200: {
318                            slidesPerView: 3,
319                            spaceBetween: 30,
320                            allowTouchMove: true,
321                            mousewheel: {
322                                invert: true,
323                            },
324                        }
325
326                    }
327
328                });
329            }
330
331        }
332        popular_grid_slider($);
333
334
335
336        /* ----------------------------------------------------------- */
337        /*  marquee slider for crypto
338        /* ----------------------------------------------------------- */
339        // if ($('.slick.marquee').length > 0) {
340        //     $('.slick.marquee').slick({
341        //         dots: false,
342        //         infinite: true,
343        //         speed: 500,
344        //         fade: true,
345        //         cssEase: 'linear',
346        //         arrows: false,
347        //         autoplay: true,
348        //         autoplaySpeed: 3000,
349        //         buttons: false
350        //     });
351        // }
352
353
354
355        /* ----------------------------------------------------------- */
356        /*  Popup
357        /* ----------------------------------------------------------- */
358
359        if ($('.gallery-popup').length > 0) {
360            $('.gallery-popup').magnificPopup({
361                type: 'image',
362                mainClass: 'mfp-with-zoom',
363                zoom: {
364                    enabled: true, // By default it's false, so don't forget to enable it
365
366                    duration: 300, // duration of the effect, in milliseconds
367                    easing: 'ease-in-out', // CSS transition easing function
368
369                    opener: function (openerElement) {
370                        return openerElement.is('img') ? openerElement : openerElement.find('img');
371                    }
372                }
373            });
374        }
375
376        /* ----------------------------------------------------------- */
377        /*  single post video
378        /* ----------------------------------------------------------- */
379        if ($('.ts-play-btn').length > 0) {
380            $('.ts-play-btn').magnificPopup({
381                type: 'iframe',
382                mainClass: 'mfp-with-zoom',
383                zoom: {
384                    enabled: true, // By default it's false, so don't forget to enable it
385
386                    duration: 300, // duration of the effect, in milliseconds
387                    easing: 'ease-in-out', // CSS transition easing function
388
389                    opener: function (openerElement) {
390                        return openerElement.is('img') ? openerElement : openerElement.find('img');
391                    }
392                }
393            });
394        }
395
396        if ($('.ts-video-btn').length > 0) {
397            $('.ts-video-btn').magnificPopup({
398                type: 'iframe',
399                mainClass: 'mfp-with-zoom',
400                zoom: {
401                    enabled: true, // By default it's false, so don't forget to enable it
402
403                    duration: 300, // duration of the effect, in milliseconds
404                    easing: 'ease-in-out', // CSS transition easing function
405
406                    opener: function (openerElement) {
407                        return openerElement.is('img') ? openerElement : openerElement.find('img');
408                    }
409                }
410            });
411
412        }
413
414
415        if ($('.ts-video-icon').length > 0) {
416            $('.ts-video-icon').magnificPopup({
417                type: 'iframe',
418                mainClass: 'mfp-with-zoom',
419                zoom: {
420                    enabled: true, // By default it's false, so don't forget to enable it
421
422                    duration: 300, // duration of the effect, in milliseconds
423                    easing: 'ease-in-out', // CSS transition easing function
424
425                    opener: function (openerElement) {
426                        return openerElement.is('img') ? openerElement : openerElement.find('img');
427                    }
428                }
429            });
430
431        }
432
433
434
435        /*==========================================================
436                        39. magnific modal popup
437            ======================================================================*/
438        if ($('.xs-modal-popup').length > 0) {
439            $('.xs-modal-popup').magnificPopup({
440                type: 'inline',
441                fixedContentPos: false,
442                fixedBgPos: true,
443                overflowY: 'auto',
444                closeBtnInside: false,
445                callbacks: {
446                    beforeOpen: function beforeOpen() {
447                        this.st.mainClass = "my-mfp-slide-bottom xs-promo-popup";
448                    }
449                }
450            });
451        }
452
453        /*==========================================================
454                        39. scroll bar
455            ======================================================================*/
456
457        if ($(".video-tab-scrollbar").length > 0) {
458            $(".video-tab-scrollbar").mCustomScrollbar({
459                mouseWheel: true,
460                scrollButtons: {
461                    enable: true
462                }
463            });
464        }
465
466        $(window).on('resize', function () {
467            if ($(window).width() <= 991) {
468                $('.menu-item-has-children > a').on('click', DoPrevent);
469            } else {
470                $('.menu-item-has-children > a').off('click', DoPrevent);
471            }
472        })
473
474        // instragra feed
475
476        var access_token = $("#ins_access_token").data('token');
477        var ins_userId = $("#ins_userId").data('user');
478        var ins_limit = $("#ins_limit").data('limit');
479
480        let accessToken = access_token,
481            get = "user",
482            userId = ins_userId,
483            resolution = "standard_resolution",
484            useHttp = "true",
485            limit = ins_limit;
486
487        if ($('#instafeed-gallery-feed').length > 0) {
488            let galleryFeed = new Instafeed({
489                get: get,
490                userId: userId,
491                accessToken: accessToken,
492                resolution: resolution,
493                useHttp: useHttp,
494                limit: limit,
495                target: "instafeed-gallery-feed",
496            });
497            galleryFeed.run();
498        }
499
500        // backto top
501        $(window).scroll(function () {
502            if ($(this).scrollTop() > 50) {
503                $('#back-to-top').fadeIn();
504            } else {
505                $('#back-to-top').fadeOut();
506            }
507        });
508
509        // scroll body to 0px on click
510        $('#back-to-top').on('click', function () {
511            $('#back-to-top').tooltip('hide');
512            $('body,html').animate({
513                scrollTop: 0
514            }, 800);
515            return false;
516        });
517
518        $('#back-to-top').tooltip('hide');
519
520
521
522        // Post Loading
523        $('#post-loading-button').on('click', function (event) {
524            event.preventDefault();
525
526            var $that = $(this);
527            if ($that.hasClass('disable')) {
528                return false;
529            }
530
531            var contentwrap = $('.main-content-inner'), // item contentwrap
532                postperpage = $that.data('post_per_page'), // post per page number
533                showallposts = $that.data('show_total_posts'); // total posts count
534
535            var items = contentwrap.find('.card'),
536                totalpostnumber = items.length,
537                paged = (totalpostnumber / postperpage) + 1; // paged number
538
539            $.ajax({
540                url: vinkmag_ajax.ajax_url,
541                type: 'POST',
542                data: { action: 'vinkmag_post_ajax_loading', postperpage: postperpage, paged: paged },
543                beforeSend: function () {
544                    $that.addClass('disable');
545                    $('<i class="fa fa-spinner fa-spin" style="margin-left:10px"></i>').appendTo("#post-loading-button").fadeIn(100);
546                },
547                complete: function () {
548                    $('#post-loading-button .fa-spinner ').remove();
549                }
550            })
551
552                .done(function (data) {
553                    var newLenght = contentwrap.find('.card').length;
554                    if (showallposts <= newLenght) {
555                        $('.post-content-loading').fadeOut(300, function () {
556                            $('.post-content-loading').remove();
557                        });
558                    }
559                    $that.removeClass('disable');
560
561                    var $pstitems = $(data);
562                    console.log($pstitems.html());
563                    $('.main-content-inner').append($pstitems);
564                })
565
566                .fail(function () {
567                    alert('Loading Failed');
568                });
569
570        });
571
572
573        /*===================================
574                        scroll
575        ===================================== */
576
577        $.fn.isInViewport = function () {
578            let elementTop = $(this).offset().top;
579            let elementBottom = elementTop + $(this).outerHeight();
580
581            let viewportTop = $(window).scrollTop();
582            let viewportBottom = viewportTop + $(window).height();
583
584            return elementBottom > viewportTop && elementTop < viewportBottom;
585        };
586
587
588        $(window).on('scroll', function () {
589
590            $('.ajax-loader-current-url').each(function () {
591                if ($(this).isInViewport()) {
592                    var current_url = $(this).data('current-url');
593                    if (window.location.href != current_url) {
594                        window.history.pushState('html', 'title', current_url);
595                    }
596                }
597            });
598
599            $('.blog-ajax-load-more-trigger').each(function (index) {
600                if ($(this).isInViewport()) {
601                    var current_post = index + 1;
602                    var _this = $(this);
603                    var next_post_url = $(this).data('next-post-url');
604                    var max_posts = $(this).data('max-posts');
605                    var content_loaded = $(this).data('content-loaded');
606
607                    if (current_post >= max_posts) {
608                        _this.fadeOut(2000);
609                        return;
610                    }
611
612                    if (content_loaded == 'no') {
613                        $.ajax({
614                            type: "GET",
615                            url: next_post_url,
616                            success: function (content) {
617                                var content = $(content).find('#blog-ajax-load-more-container').html();
618                                _this.after(content);
619                                popular_grid_slider($);
620                            }
621                        });
622                    }
623                    _this.fadeOut(2000);
624                    _this.data('content-loaded', 'yes');
625                }
626            });
627        });
628        /*--------------scroll end---------*/
629
630
631        /*============================
632            Dark-light mode
633        =============================== */
634        $(document).on('click', '.change-mode', function () {
635
636            var defaultSkin = $('html').data('skin'),
637                siteSkin = 'light';
638
639            if ($('html').hasClass('dark-themes')) {
640                siteSkin = 'dark';
641            }
642
643            var switchTo = (siteSkin == 'dark') ? 'light' : 'dark';
644            if ('undefined' != typeof localStorage) {
645                localStorage.setItem('digi-skin', switchTo);
646            }
647
648            if (defaultSkin == switchTo) {
649                $('html').removeClass('digi-skin-switch');
650            }
651            else {
652                $('html').addClass('digi-skin-switch');
653            }
654
655            if (switchTo == 'dark') {
656                $('html').addClass('dark-themes');
657            }
658            else {
659                $('html').removeClass('dark-themes');
660            }
661        });
662
663
664        /*==========================================================
665                  reading progressbar
666       ======================================================================*/
667
668        window.onscroll = function () { reading_progressbar() };
669
670        function reading_progressbar() {
671            var vinkmag_winScroll = document.body.scrollTop || document.documentElement.scrollTop;
672            var vinkmag_height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
673            var vinkmag_scrolled = (vinkmag_winScroll / vinkmag_height) * 100;
674            if (document.getElementById("readingProgressbar")) {
675                document.getElementById("readingProgressbar").style.width = vinkmag_scrolled + "%";
676            }
677        }
678
679        reading_progress_bar_post();
680
681        function reading_progress_bar_post() {
682
683            var progressWrap = $('.vinkmag_progress_container');
684
685
686            if (progressWrap.length > 0) {
687                var didScroll = false,
688                    windowWrap = $(window),
689
690                    contentWrap = $('.entry-content'),
691                    contentHeight = contentWrap.height(),
692                    windowHeight = windowWrap.height() * .85;
693
694                $(window).scroll(function () {
695                    didScroll = true;
696                });
697
698                $(window).on('resize', function () {
699                    windowHeight = windowWrap.height() * .85;
700                    progressReading();
701                });
702
703                setInterval(function () {
704                    if (didScroll) {
705                        didScroll = false;
706                        progressReading();
707                    }
708                }, 150);
709
710                var progressReading = function () {
711
712                    var windowScroll = windowWrap.scrollTop(),
713                        contentOffset = contentWrap.offset().top,
714                        contentScroll = (windowHeight - contentOffset) + windowScroll,
715                        progress = 0;
716
717                    if (windowHeight > contentHeight + contentOffset) {
718                        progressWrap.find('.progress-bar').width(0);
719                    } else {
720                        if (contentScroll > contentHeight) {
721                            progress = 100;
722                        } else if (contentScroll > 0) {
723                            progress = (contentScroll / contentHeight) * 100;
724
725                        }
726
727                        progressWrap.find('.progress-bar').width(progress + '%');
728                    }
729                }
730            }
731        }
732
733    });
734});
735

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.