1/** 2 * Graceful Pixel Blog Scripts 3 * 4 * Contains all JavaScript for the theme including: 5 * - Trending ticker speed calculation 6 * - Latest posts Owl Carousel initialization 7 * - Post slider Owl Carousel initialization 8 * 9 * @package Graceful Pixel Blog 10 */ 11( function ( $ ) { 12 'use strict'; 13 14 /** 15 * Trending Ticker â dynamic speed based on pixels per second. 16 * Speed value is passed via wp_localize_script as gracefulTickerSettings.pxPerSec. 17 */ 18 function setTickerSpeed() { 19 var track = document.getElementById( 'trending-ticker-track' ); 20 if ( ! track ) { 21 return; 22 } 23 24 var pxPerSec = ( window.gracefulTickerSettings && window.gracefulTickerSettings.pxPerSec ) 25 ? parseInt( window.gracefulTickerSettings.pxPerSec, 10 ) 26 : 150; 27 28 // scrollWidth is double the real content width because items are duplicated. 29 var trackWidth = track.scrollWidth / 2; 30 var duration = trackWidth / pxPerSec; 31 32 track.style.animationDuration = duration.toFixed( 2 ) + 's'; 33 } 34 35 if ( document.readyState === 'loading' ) { 36 document.addEventListener( 'DOMContentLoaded', setTickerSpeed ); 37 } else { 38 setTickerSpeed(); 39 } 40 41 var resizeTimer; 42 window.addEventListener( 'resize', function () { 43 clearTimeout( resizeTimer ); 44 resizeTimer = setTimeout( setTickerSpeed, 150 ); 45 } ); 46 47 /** 48 * Initialize Owl Carousel for Latest Posts Ticker 49 */ 50 $( document ).ready( function () { 51 if ( $( '#graceful-latest-posts-ticker' ).length ) { 52 $( '#graceful-latest-posts-ticker' ).owlCarousel( { 53 items: 1, 54 loop: true, 55 margin: 0, 56 autoplay: true, 57 autoplayTimeout: 4000, 58 autoplayHoverPause: true, 59 nav: true, 60 dots: true, 61 navText: [ 62 '<span>‹</span>', 63 '<span>›</span>' 64 ], 65 responsive: { 66 0: { items: 1 }, 67 768: { items: 1 }, 68 1200: { items: 1 } 69 } 70 } ); 71 } 72 73 /** 74 * Initialize Owl Carousel for Post Slider 75 */ 76 if ( $( '#graceful-post-slider' ).length ) { 77 $( '#graceful-post-slider' ).owlCarousel( { 78 loop: false, 79 margin: 10, 80 nav: true, 81 dots: true, 82 animateIn: 'fadeIn', 83 animateOut: 'fadeOut', 84 autoplay: false, 85 margin: 40, 86 autoHeight: true, 87 responsive: { 88 0: { 89 items: 1 90 }, 91 640: { 92 items: 1 93 }, 94 1000: { 95 items: 1 96 } 97 } 98 } ); 99 100 // Disable tabindex for prev/next in slider for accessibility. 101 $( '#graceful-post-slider .owl-prev' ).attr( 'tabindex', '-1' ); 102 $( '#graceful-post-slider .owl-next' ).attr( 'tabindex', '-1' ); 103 } 104 } ); 105 106}( jQuery ) );
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.