Files
CRM/libraries/jquery/lazyYT/lazyYT.min.js
BACHIR SOULDI 2794e62571 first commit
2025-09-28 08:49:37 +01:00

6 lines
1.3 KiB
JavaScript

/*!
* lazyyt
* v0.3.1 - 2014-03-07
* Copyright (c) 2014 Tyler Pearson <ty.pearson@gmail.com> (http://tylerp.me); Licensed MIT %>
*/!function(a){"use strict";function b(b){var c=b,d=c.data("width"),e=c.data("height"),f=c.data("youtube-id"),g=c.data("parameters")||"";if("undefined"==typeof d||"undefined"==typeof e||"undefined"==typeof f)throw new Error("lazyYT is missing a required data attribute.");c.css({position:"relative",height:e,width:d,background:"url(https://img.youtube.com/vi/"+f+"/maxresdefault.jpg) center center no-repeat",cursor:"pointer","-webkit-background-size":"cover","-moz-background-size":"cover","-o-background-size":"cover","background-size":"cover"}).html('<p id="lazyYT-title-'+f+'" class="lazyYT-title"></p><div class="lazyYT-button"></div>').addClass("lazyYT-image-loaded"),a.getJSON("https://gdata.youtube.com/feeds/api/videos/"+f+"?v=2&alt=json",function(b){a("#lazyYT-title-"+f).text(b.entry.title.$t)}),c.on("click",function(a){a.preventDefault(),!c.hasClass("lazyYT-video-loaded")&&c.hasClass("lazyYT-image-loaded")&&c.html('<iframe width="'+d+'" height="'+e+'" src="//www.youtube.com/embed/'+f+"?autoplay=1&"+g+'" frameborder="0" allowfullscreen></iframe>').removeClass("lazyYT-image-loaded").addClass("lazyYT-video-loaded")})}a.fn.lazyYT=function(){return this.each(function(){var c=a(this).css("cursor","pointer");b(c)})}}(jQuery);