PageSourceSearch

https://siciliainformazioni.com/wp-content/plugins/featured-video-plus/js/frontend.js?ver=2.3.3

js siciliainformazioni.com collected 2026-10-02 08:35:40 UTC 5,938 bytes, 229 lines download raw bytes

1var initFeaturedVideoPlus;
2
3(function($) {
4  'use strict';
5  /* global fvpdata */
6
7  var videoCache = {};
8  var selectorCache;
9  var initTimeout = 0;
10
11
12  /**
13   * Remove the link wrapping featured images on index pages and the
14   * possibile repetition of .post-thumbnail-classes.
15   */
16  function unwrap() {
17    // Remove links around videos.
18    $('.has-post-video a>.featured-video-plus,' +
19      '.has-post-video a>.fvp-dynamic,' +
20      '.has-post-video a>.fvp-overlay,' +
21      '.has-post-video a>.wp-video,' +
22      '.has-post-video a>.wp-video-shortcode'
23    ).unwrap();
24
25    // Remove wrapped .post-thumbnail-classes
26    $('.has-post-video .post-thumbnail>.post-thumbnail')
27      .removeClass('post-thumbnail');
28
29    // There might still be some empty .post-thumbnail links to be removed.
30    $('a.post-thumbnail:empty').not('.fvp-dynamic, .fvp-overlay').remove();
31  }
32
33
34  /**
35   * Autosize videos using fitvids for responsive videos
36   */
37  function fitVids() {
38    if (fvpdata.fitvids) {
39      $('.featured-video-plus.fvp-responsive').fitVids({
40        customSelector: ['iframe', 'object', 'embed']
41      });
42    }
43  }
44
45
46  /**
47   * WordPress forces a maximum size of the global $contentwidth onto local
48   * videos - overwrite it.
49   */
50  function sizeLocal() {
51    if (fvpdata.width && ! fvpdata.fitvids) {
52      $('.fvp-local .wp-video').css({width: fvpdata.width, height: 'auto'});
53      var video = $('.fvp-local .wp-video .wp-video-shortcode');
54      video.attr({
55        width: fvpdata.width,
56        height: (fvpdata.width / video.attr('width') ) * video.attr('heigth')
57      });
58    }
59  }
60
61
62  /**
63   * Get the actionicon element from the provided container.
64   */
65  function getActioniconElem(elem) {
66    var $elem = $(elem);
67    var $icon = $elem.children('.fvp-actionicon');
68    $icon.css({
69      height: $elem.height(),
70      width : $elem.width(),
71      margin: $elem.css('margin')
72    });
73
74    return $icon;
75  }
76
77
78  /**
79   * Handle mouseover and mouseout events.
80   */
81  function hoverAction(event) {
82    var $img = $(event.currentTarget).children('img');
83    var $icon = getActioniconElem(event.currentTarget);
84
85    $icon.toggleClass('play');
86    if ($icon.hasClass('play')) {
87      $img.animate({ opacity: fvpdata.opacity });
88    } else {
89      $img.animate({ opacity: 1 });
90    }
91  }
92
93
94  /**
95   * Replace a featured image with its featured video on-click.
96   */
97  function dynamicTrigger(event) {
98    event.preventDefault();
99    var $self = $(event.currentTarget);
100    var id = parseInt($self.attr('data-id'), 10);
101
102    var $icon = getActioniconElem(event.currentTarget);
103    $icon.addClass('load ' + fvpdata.color);
104
105    $.post(fvpdata.ajaxurl, {
106      'action'    : 'fvp_get_embed',
107      'fvp_nonce' : fvpdata.nonce,
108      'id'        : id
109    }, function(response){
110      if (response.success) {
111        var $parent = $self.parent();
112        $self.replaceWith(response.data);
113
114        // Initialize mediaelement.js, autosize and unwrap the new videos.
115        $parent.find('.wp-audio-shortcode, .wp-video-shortcode')
116          .mediaelementplayer();
117        fitVids();
118        unwrap();
119      }
120
121      $icon.removeClass('load ' + fvpdata.color);
122    });
123  }
124
125
126  /**
127   * Show the overlay on-click.
128   */
129  function overlayTrigger(event) {
130    event.preventDefault();
131    var $self = $(event.currentTarget);
132    var id = parseInt($self.attr('data-id'), 10);
133
134    $self.openDOMWindow({
135      eventType     : null,
136      windowPadding : 0,
137      borderSize    : 0,
138      windowBGColor : 'transparent',
139      overlayOpacity: fvpdata.opacity * 100,
140      width : '100%',
141      height: '100%'
142    });
143
144    // Check if the result is already cached
145    if (! videoCache[id]) {
146      $.post(fvpdata.ajaxurl, {
147        'action'    : 'fvp_get_embed',
148        'fvp_nonce' : fvpdata.nonce,
149        'id'        : id
150      }, function(response) {
151        if (response.success) {
152          // cache the result to not reload when opened again
153          videoCache[id] = response.data;
154
155          $('#DOMWindow').html(response.data);
156          sizeLocal();
157          $(window).trigger('scroll');
158        }
159      });
160    } else {
161      // From cache
162      $('#DOMWindow').html( videoCache[id] );
163      sizeLocal();
164      $(window).trigger('scroll');
165    }
166  }
167
168
169  /**
170   * Initialize the plugins JS functionality.
171   */
172  function init() {
173    var newSet = $('.featured-video-plus, .fvp-overlay, .fvp-dynamic');
174    if (newSet.is(selectorCache)) { return false; }
175    selectorCache = newSet;
176
177    // remove wrapping anchors
178    // doing this twice with a 1 second delay to fix wrapped local video posters
179    unwrap();
180    setTimeout(unwrap, 1000);
181
182    // initialize fitvids if available
183    fitVids();
184
185    sizeLocal();
186
187    // add hover effect and preload icons
188    $('.fvp-overlay, .fvp-dynamic')
189      .off('mouseenter').on('mouseenter', hoverAction)
190      .off('mouseleave').on('mouseleave', hoverAction);
191
192    // on-demand video insertion click handler
193    $('.fvp-dynamic').off('click').on('click', dynamicTrigger);
194
195    // overlay click handler
196    $('.fvp-overlay').off('click').on('click', overlayTrigger);
197  }
198
199
200  /**
201   * Debounced version of the init function.
202   */
203  initFeaturedVideoPlus = function() {
204    if (0 === initTimeout) {
205      init();
206      initTimeout = setTimeout(function() {}, 100);
207    } else {
208      clearTimeout(initTimeout);
209      initTimeout = setTimeout(init, 100);
210    }
211  };
212
213
214  // Initialization after DOM is completly loaded.
215  $(document).ready(function() {
216    // Wordaround for chrome bug
217    // See https://code.google.com/p/chromium/issues/detail?id=395791
218    if (!! window.chrome) {
219      $('.featured-video-plus iframe').each(function() {
220        this.src = this.src;
221      });
222    }
223
224    // preload images
225    [fvpdata.playicon, fvpdata.loadicon].forEach(function(val) {
226      $('body').append($('<img/>', {src: val, alt: 'preload image'}).hide());
227    });
228  });
229})(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.