PageSourceSearch

https://cycle-challenge.cyou/wp-content/themes/pubnews/assets/js/theme.js?ver=1.0.0

js cycle-challenge.cyou collected 2026-10-07 20:22:17 UTC 24,224 bytes, 587 lines download raw bytes

1/**
2 * Handles theme general events
3 * 
4 * @package Pubnews
5 * @since 1.0.0
6 */
7jQuery(document).ready(function($) {
8    "use strict"
9    var ajaxUrl = pubnewsObject.ajaxUrl, _wpnonce = pubnewsObject._wpnonce, sttOption = pubnewsObject.stt, query_vars = pubnewsObject.query_vars, paged = pubnewsObject.paged
10
11    if( ! pubnewsObject.is_customizer ) {
12        setTimeout(function() {
13            $('body .pubnews_loading_box').hide();
14        }, 2000);
15    } else {
16        $('body .pubnews_loading_box').hide();
17    }
18
19    var nrtl = false
20    var ndir = "left"
21    if ($('body').hasClass("rtl")) {
22        nrtl = true;
23        ndir = "right";
24    };
25    
26    // theme trigger modal close
27    function pubnewsclosemodal( elm, callback ) {
28        $(document).mouseup(function (e) {
29            var container = $(elm);
30            if (!container.is(e.target) && container.has(e.target).length === 0) callback();
31        });
32    }
33
34    // ticker news slider events
35    var tc = $( ".ticker-news-wrap" );
36    if( tc.length ) {
37        var tcSpeed = tc.data("speed")
38        var tcM = tc.find( ".ticker-item-wrap" ).marquee({
39            duration: tcSpeed,
40            gap: 0,
41            delayBeforeStart: 0,
42            direction: ndir,
43            duplicated: true,
44            startVisible: true,
45            pauseOnHover: true,
46        });
47        tc.on( "click", ".pubnews-ticker-pause", function() {
48            $(this).find( "i" ).toggleClass( "fa-pause fa-play" )
49            tcM.marquee( "toggle" );
50        })
51    }
52
53    // top date time
54    var timeElement = $( ".top-date-time .time" )
55    if( timeElement.length > 0 ) {
56        setInterval(function() {
57            timeElement.html(new Date().toLocaleTimeString())
58        },1000);
59    }
60    
61    // search form and off canvas trigger
62    $( "#masthead" ).on( "click", ".off-canvas-trigger", function() {
63        $(this).addClass('slideshow');
64        $('body').addClass('off-canvas-active');
65    });
66    $( "#masthead" ).on( "click", ".off-canvas-trigger.slideshow, .sidebar-toggle .off-canvas-close, .search_close_btn", function() {
67        $('.off-canvas-trigger').removeClass('slideshow');
68        $('body').removeClass('off-canvas-active');
69        $("#masthead .search-wrap").find(".search-results-wrap").remove()
70        $("#masthead .search-wrap form").removeClass( 'results-loaded' )
71    });
72
73     // search form 
74    $( "#masthead" ).on( "click", ".search-trigger", function() {
75        $(this).next().slideDown();
76        $( '#masthead .search-wrap input[type="search"]' ).focus()
77        $(this).addClass('slideshow');
78        $('body').addClass('bodynoscroll');
79    });
80
81    $( "#masthead" ).on( "click", ".search-trigger.slideshow", function() {
82        $(this).next().slideUp();
83        $(this).removeClass('slideshow');
84        $('body').removeClass('bodynoscroll');
85    });
86
87    $( ".search-popup--style-three #masthead" ).on( "click", ".search-trigger", function() {
88        $(this).parents( '#masthead' ).find( '.search-form-wrap' ).slideDown();
89        $(this).parents( '#masthead' ).find( '.search-form-wrap input[type="search"]' ).focus()
90        $(this).addClass('slideshow');
91        $('body').addClass('bodynoscroll');
92    });
93
94    $( ".search-popup--style-three #masthead" ).on( "click", ".search_close_btn", function() {
95        $(this).parents( '.main-header' ).find( '.search-form-wrap' ).slideUp();
96        $(this).siblings().removeClass('slideshow');
97        $('body').removeClass('bodynoscroll');
98    });
99
100    $( "body.search-popup--style-one #masthead" ).on( "click", ".search_close_btn", function() {
101        $(this).prev().fadeOut();
102        $(this).prev().prev().removeClass('slideshow');
103        $('body').removeClass('bodynoscroll');
104    });
105
106    pubnewsclosemodal( $( ".search-wrap, .search-form-wrap" ), function () {
107        $( ".search-wrap .search-trigger" ).removeClass( "slideshow" );
108        $( ".search-form-wrap" ).slideUp();
109        $('body').removeClass('bodynoscroll');
110    }); // trigger search close
111
112
113    pubnewsclosemodal( $( ".sidebar-toggle-wrap" ), function () {
114        $( ".sidebar-toggle-wrap .off-canvas-trigger" ).removeClass( "slideshow" );
115        $('body').removeClass('off-canvas-active');
116    }); // trigger htsidebar close
117
118    // top header ticker news slider events
119    var thtn = $( ".top-ticker-news" );
120    if( thtn.length ) {
121        var thtnitems = thtn.find( ".ticker-item-wrap" )
122        var thtDir = thtnitems.data("dir")
123        var thtAuto = thtnitems.data("auto")
124        thtnitems.slick({
125            dots: false,
126            infinite: true,
127            rtl: nrtl,
128            vertical: ( ! thtDir ),
129            arrows: true,
130            autoplay: thtAuto,
131            nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
132            prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
133        });
134    }
135
136    // main banner slider events
137    var bc = $( "#main-banner-section" );
138    if( bc.length ) {
139        var bic = bc.find( ".main-banner-slider" )
140        var bAuto = bic.data( "auto" )
141        var bArrows = bic.data( "arrows" )
142        var bDots = bic.data( "dots" )
143        var bSpeed = bic.data( "speed" )
144        bic.slick({
145            dots: bDots,
146            infinite: true,
147            rtl: nrtl,
148            arrows: bArrows,
149            autoplay: bAuto,
150            speed: bSpeed,
151            nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
152            prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
153        });
154    }
155
156    // main banner popular posts slider events
157    var bpc = bc.find( ".popular-posts-wrap" );
158    if( bpc.length ) {
159        var bpcAuto = bpc.data( "auto" )
160        var bpcArrows = bpc.data( "arrows" )
161        var bpcVertical = bpc.data( "vertical" );
162        if( bpcVertical) {
163            bpc.slick({
164                vertical: bpcVertical,
165                slidesToShow: 5,
166                dots: false,
167                infinite: true,
168                arrows: bpcArrows,
169                autoplay: bpcAuto,
170                nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
171                prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
172            })
173        } else {
174            bpc.slick({
175                dots: false,
176                infinite: true,
177                arrows: bpcArrows,
178                rtl: nrtl,
179                draggable: true,
180                autoplay: bpcAuto,
181                nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
182                prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
183            })
184        }  
185    }
186
187    // news carousel events
188    var nc = $( ".pubnews-section .news-carousel .news-carousel-post-wrap" );
189    if( nc.length ) {
190        nc.each(function() {
191            var _this = $(this)
192            var multiColumnSection = _this.parents('.pubnews-multi-column-section')
193            var ncDots= _this.data("dots") == '1'
194            var ncLoop= _this.data("loop") == '1'
195            var ncArrows= _this.data("arrows") == '1'
196            var ncAuto  = _this.data("auto") == '1'
197            var ncColumns  = _this.data("columns")
198            var ncColumnsTablet = 2
199            if( multiColumnSection.length > 0 ) {
200                ncColumnsTablet = 1
201                ncColumns = 1
202            }
203            _this.slick({
204                dots: ncDots,
205                infinite: ncLoop,
206                arrows: ncArrows,
207                autoplay: ncAuto,
208                rtl: nrtl,
209                slidesToShow: ncColumns,
210                nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
211                prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
212                responsive: [
213                  {
214                    breakpoint: 910,
215                    settings: {
216                      slidesToShow: ncColumnsTablet,
217                    },
218                  },
219                  {
220                    breakpoint: 640,
221                    settings: {
222                      slidesToShow: 1,
223                    },
224                  }
225                ]
226            });
227        })
228    }
229
230    // Filter posts
231     $( ".pubnews-section .news-filter" ).each(function() {
232        var $scope = $(this), $scopeOptions = $scope.data("args"), newTabs = $scope.find( ".filter-tab-wrapper" ), newTabsContent = $scope.find( ".filter-tab-content-wrapper" );
233        newTabs.on( "click", ".tab-title", function() {
234          var a = $(this), aT = a.data("tab")
235          a.addClass( "isActive" ).siblings().removeClass( "isActive" );
236          if( newTabsContent.find( ".tab-content.content-" + aT ).length < 1 ) {
237            $scopeOptions.category_id = aT
238            $.ajax({
239                method: 'get',
240                url: ajaxUrl,
241                data: {
242                    action: 'pubnews_filter_posts_load_tab_content',
243                    options : JSON.stringify( $scopeOptions ),
244                    _wpnonce: _wpnonce
245                },
246                beforeSend: function() {
247                    $scope.addClass( 'retrieving-posts' );
248                },
249                success : function(res) {
250                    if( res.data.loaded ) {
251                        newTabsContent.append( res.data.posts )
252                        $scope.removeClass( 'retrieving-posts' );
253                    }
254                },
255                complete: function() {
256                    newTabsContent.find( ".tab-content.content-" + aT ).show().siblings().hide()
257                }
258            })
259          } else {
260            newTabsContent.find( ".tab-content.content-" + aT ).show().siblings().hide()
261          }
262        })
263    })
264
265    if(pubnewsObject.ajaxPostsLoad == '1') {
266        $( "#primary .pagination .ajax-load-more" ).on( "click", function() {
267            var _this = $(this), $parent = _this.parents(".primary-content")
268            $.ajax({
269                method: 'post',
270                url: ajaxUrl,
271                data: {
272                    action: 'pubnews_posts_content',
273                    _wpnonce: _wpnonce,
274                    query_vars: JSON.stringify(query_vars),
275                    paged: paged + 1
276                },
277                beforeSend: function() {
278                    $parent.addClass( 'retrieving-posts' );
279                    _this.text( "Retrieving posts" )
280                },
281                success : function(res) {
282                    if( res.data.loaded ) {
283                        if( $parent.find(" > div:first-child").length > 0 ) {
284                            $parent.find(" > div:first-child").append( res.data.posts )
285                        } else {
286                            $parent.find(".pagination").before( res.data.posts )
287                        }
288                        if( res.data.continue ) {
289                            paged++;
290                        } else {
291                            _this.remove()
292                        }
293                    } else {
294                        _this.remove()
295                    }
296                },
297                complete: function() {
298                    _this.text( "Load More" )
299                    $parent.removeClass( 'retrieving-posts' );
300                }
301            })
302        })
303    }
304
305    // popular posts widgets
306    var ppWidgets = $( ".pubnews-widget-popular-posts" )
307    ppWidgets.each(function() {
308        var _this = $(this), parentWidgetContainerId = _this.parents( ".widget.widget_pubnews_popular_posts_widget" ).attr( "id" ), parentWidgetContainer = $( "#" + parentWidgetContainerId )
309        var ppWidget = parentWidgetContainer.find( ".popular-posts-wrap" );
310        if( ppWidget.length > 0 ) {
311            var ppWidgetAuto = ppWidget.data( "auto" )
312            var ppWidgetArrows = ppWidget.data( "arrows" )
313            var ppWidgetLoop = ppWidget.data( "loop" )
314            var ppWidgetVertical = ppWidget.data( "vertical" )
315            if( ppWidgetVertical == 'vertical' ) {
316                ppWidget.slick({
317                    vertical: true,
318                    slidesToShow: 4,
319                    dots: false,
320                    infinite: ppWidgetLoop,
321                    arrows: ppWidgetArrows,
322                    autoplay: ppWidgetAuto,
323                    nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
324                    prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`
325                })
326            } else {
327                ppWidget.slick({
328                    dots: false,
329                    infinite: ppWidgetLoop,
330                    rtl: nrtl,
331                    arrows: ppWidgetArrows,
332                    autoplay: ppWidgetAuto,
333                    nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
334                    prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`
335                })
336            }  
337        }
338    })
339
340    // carousel posts widgets
341    var cpWidgets = $( ".pubnews-widget-carousel-posts" )
342    cpWidgets.each(function() {
343        var _this = $(this), parentWidgetContainerId = _this.parents( ".widget.widget_pubnews_carousel_widget" ).attr( "id" ), parentWidgetContainer
344        if( typeof parentWidgetContainerId != 'undefined' ) {
345            parentWidgetContainer = $( "#" + parentWidgetContainerId )
346            var ppWidget = parentWidgetContainer.find( ".carousel-posts-wrap" );
347        } else {
348            var ppWidget = _this;
349        }
350        if( ppWidget.length > 0 ) {
351            var ppWidgetAuto = ppWidget.data( "auto" )
352            var ppWidgetArrows = ppWidget.data( "arrows" )
353            var ppWidgetLoop = ppWidget.data( "loop" )
354            var ppWidgetVertical = ppWidget.data( "vertical" )
355            if( ppWidgetVertical == 'vertical' ) {
356                ppWidget.slick({
357                    vertical: true,
358                    dots: false,
359                    infinite: ppWidgetLoop,
360                    arrows: ppWidgetArrows,
361                    autoplay: ppWidgetAuto,
362                    nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
363                    prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`
364                })
365            } else {
366                ppWidget.slick({
367                    dots: false,
368                    infinite: ppWidgetLoop,
369                    rtl: nrtl,
370                    arrows: ppWidgetArrows,
371                    autoplay: ppWidgetAuto,
372                    adaptiveHeight: true,
373                    nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
374                    prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`
375                })
376            }  
377        }
378    })
379
380    // tabbed posts
381    var tabpWidgets = $( ".pubnews-tabbed-widget-tabs-wrap" )
382    tabpWidgets.each(function() {
383        var _this = $(this), parentWidgetContainerId = _this.parents( ".widget.widget_pubnews_tabbed_posts_widget" ).attr( "id" ), parentWidgetContainer
384        if( typeof parentWidgetContainerId != 'undefined' ) {
385            parentWidgetContainer = $( "#" + parentWidgetContainerId )
386            var tabpWidget = parentWidgetContainer.find( ".pubnews-tabbed-widget-tabs-wrap" );
387        } else {
388            var tabpWidget = _this;
389        }
390        if( tabpWidget.length > 0 ) {
391            tabpWidget.on( "click", ".tabbed-widget-tabs li.tabbed-widget", function() {
392                var _this = $(this), tabItem = _this.attr( "tab-item" );
393                _this.addClass( "active" ).siblings().removeClass( "active" );
394                tabpWidget.find( '.widget-tabs-content div[tab-content="' + tabItem + '"]' ).addClass( "active" ).siblings().removeClass( "active" );
395            })
396        }
397    })
398
399    // news filter tabbed posts
400    var nftabpWidgets = $( ".pubnews-news-filter-tabbed-widget-tabs-wrap" )
401    nftabpWidgets.each(function() {
402        var _this = $(this), parentWidgetContainerId = _this.parents( ".widget.widget_pubnews_news_filter_tabbed_widget" ).attr( "id" ), parentWidgetContainer
403        if( typeof parentWidgetContainerId != 'undefined' ) {
404            parentWidgetContainer = $( "#" + parentWidgetContainerId )
405            var nftabpWidget = parentWidgetContainer.find( ".pubnews-news-filter-tabbed-widget-tabs-wrap" );
406        } else {
407            var nftabpWidget = _this;
408        }
409        if( nftabpWidget.length > 0 ) {
410            nftabpWidget.on( "click", ".widget-tabs li.widget-tab", function() {
411                var _this = $(this), tabItem = _this.attr( "tab-item" );
412                _this.addClass( "active" ).siblings().removeClass( "active" );
413                nftabpWidget.find( '.tabs-content-wrap div.tabs-content.' + tabItem ).addClass( "show" ).siblings().removeClass( "show" );
414            })
415        }
416    })
417
418    // check for dark mode drafts
419    if( localStorage.getItem( "themeMode" ) != null ) {
420        if( localStorage.getItem("themeMode") == "dark" ) {
421            $('body').addClass( 'pubnews_dark_mode' ).removeClass('pubnews_main_body')
422            $('body .blaze-switcher-button').addClass( 'active' )
423        } else {
424            $('body').addClass( 'pubnews_main_body' ).removeClass('pubnews_dark_mode')
425            $('body .blaze-switcher-button').removeClass( 'active' )
426        }
427    }
428    
429    // header - theme mode
430    var themeModeContainer = $('.blaze-switcher-button')
431    if( themeModeContainer.length > 0 ) {
432        themeModeContainer.on( 'click', function(){
433            var _this = $(this), bodyElement = _this.parents('body')
434            if( bodyElement.hasClass('pubnews_dark_mode') ) {
435                localStorage.setItem( 'themeMode', 'light' )
436                bodyElement.removeClass('pubnews_dark_mode').addClass('pubnews_main_body')
437                $('body .blaze-switcher-button').removeClass( 'active' )
438            } else {
439                localStorage.setItem( 'themeMode', 'dark' )
440                bodyElement.removeClass('pubnews_main_body').addClass('pubnews_dark_mode')
441                $('body .blaze-switcher-button').addClass( 'active' )
442            }
443        })
444    }
445
446    // back to top script
447    if( sttOption && $( "#pubnews-scroll-to-top" ).length ) {
448        var scrollContainer = $( "#pubnews-scroll-to-top" );
449        $(window).scroll(function() {
450            if ( $(this).scrollTop() > 800 ) {
451                scrollContainer.addClass('show');
452            } else {
453                scrollContainer.removeClass('show');
454            }
455        });
456        scrollContainer.click(function(event) {
457            event.preventDefault();
458            // Animate the scrolling motion.
459            $("html, body").animate({scrollTop:0},"slow");
460        });
461    }
462
463    // category archive hide featured post in list
464    var featuredPost = $( ".archive.category .featured-post.is-sticky" )
465    if( featuredPost.length > 0 ) {
466        var postHide = "#post-" + featuredPost.data("id")
467        $(postHide).addClass( "sticky-hide" );
468    }
469
470    // ads slide block
471    var adsSliderContainer = $(".ads-banner.ads-banner-slider")
472    if( adsSliderContainer.length > 0 ) {
473        adsSliderContainer.slick({
474            dots: false,
475            infinite: true,
476            rtl: nrtl,
477            vertical: false,
478            arrows: true,
479            autoplay: true,
480            nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
481            prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
482        })
483    }
484
485    // ads slider widget
486    var adsSliderWidget = $(".widget_pubnews_ads_slider_widget .pubnews-advertisement-block")
487    if( adsSliderWidget.length > 0 ) {
488        adsSliderWidget.slick({
489            dots: false,
490            infinite: true,
491            rtl: nrtl,
492            vertical: false,
493            arrows: true,
494            autoplay: true,
495            nextArrow: `<button type="button" class="slick-next"><i class="fas fa-chevron-right"></i></button>`,
496            prevArrow: `<button type="button" class="slick-prev"><i class="fas fa-chevron-left"></i></button>`,
497        })
498    }
499
500    /**
501     * Gallery Lightbox
502     * 
503     * @since 1.0.11
504     */
505    const GalleryLightbox = {
506        /**
507         * Container
508         * 
509         * @since 1.0.11
510         */
511        get container() {
512            if( ! this._container ) {
513                this._container = $('.wp-block-gallery')
514            }
515            return this._container
516        },
517        /**
518         * Initialization
519         * 
520         * @sine 1.0.11
521         */
522        init() {
523            if( this.container.length > 0 ) {
524                if( $( 'body' ).hasClass( 'single' ) ) {
525                    if( $( '#primary' ).hasClass( 'lightbox--on' ) ) {
526                        this.bindMagnificPopup()
527                    }
528                } else {
529                    this.bindMagnificPopup()
530                }
531            }
532        },
533        /**
534         * Bind Magnific Popup
535         * 
536         * @sine 1.0.11
537         */
538        bindMagnificPopup() {
539            this.container.each(function(){
540                var _this = $(this)
541                var findImageSrc = _this.find('.wp-block-image img')
542                var srcArgs = []
543                findImageSrc.each(function(){
544                    srcArgs.push({
545                        src: $(this).attr('src'),
546                        type: 'image'
547                    })
548                })
549                _this.magnificPopup({
550                    items: srcArgs,
551                    gallery: {
552                        enabled: true
553                    },
554                    type: 'image'
555                })
556            })
557        }
558    }
559    GalleryLightbox.init()
560
561    // news filter burger
562    var newsFilterContainer = $('.news-filter')
563    if( newsFilterContainer.length > 0 ) {
564        newsFilterContainer.each(function(){
565            $(this).on('click', '.pubnews-burger', function(){
566                var _this = $(this)
567                _this.siblings().toggleClass('isactive')
568            })
569        })
570    }
571
572     // cursor animation
573     var cursorContainer = $('.pubnews-cursor')
574     if( cursorContainer.length > 0 ) {
575         $(document).on( 'mousemove', function( event ){
576             cursorContainer[0].style.top = 'calc('+ event.pageY +'px - 15px)'
577             cursorContainer[0].style.left = 'calc('+ event.pageX +'px - 15px)'
578         })
579         var selector = 'a, button, input[type="submit"], #pubnews-scroll-to-top .icon-text, #pubnews-scroll-to-top .icon-holder, .thumb-video-highlight-text .thumb-controller, .pagination .ajax-load-more, .blaze-switcher-button, .pubnews-canvas-menu .canvas-menu-icon, .pubnews-table-of-content .toc-fixed-icon'
580         $( selector ).on( 'mouseover', function(){
581             $( cursorContainer ).addClass( 'isActive' )
582         })
583         $( selector ).on( 'mouseout', function(){
584             $( cursorContainer ).removeClass( 'isActive' )
585         })
586     }
587})

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.