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