PATH:
home
/
letacommog
/
crmleta
/
libraries
/
jquery
/
lazyYT
/*! LazyYT (lazy load Youtube videos plugin) - v0.3.0 - 2014-03-07 * Usage: <div class="lazyYT" data-youtube-id="laknj093n" data-width="300" data-height="200" data-parameters="rel=0">loading...</div> * Copyright (c) 2014 Tyler Pearson; Licensed MIT */ ;(function ($) { 'use strict'; function setUp(el) { var $el = el, width = $el.data('width'), height = $el.data('height'), id = $el.data('youtube-id'), youtubeParameters = $el.data('parameters') || ''; if (typeof width === 'undefined' || typeof height === 'undefined' || typeof id === 'undefined') { throw new Error('lazyYT is missing a required data attribute.'); } $el.css({ 'position': 'relative', 'height': height, 'width': width, 'background': 'url(https://img.youtube.com/vi/' + id + '/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-' + id + '" class="lazyYT-title"></p><div class="lazyYT-button"></div>') .addClass('lazyYT-image-loaded'); $.getJSON('https://gdata.youtube.com/feeds/api/videos/' + id + '?v=2&alt=json', function (data) { $('#lazyYT-title-' + id).text(data.entry.title.$t); }); $el.on('click', function (e) { e.preventDefault(); console.log('clicked'); if (!$el.hasClass('lazyYT-video-loaded') && $el.hasClass('lazyYT-image-loaded')) { console.log(id); $el.html('<iframe width="' + width + '" height="' + height + '" src="//www.youtube.com/embed/' + id + '?autoplay=1&' + youtubeParameters + '" frameborder="0" allowfullscreen></iframe>') .removeClass('lazyYT-image-loaded') .addClass('lazyYT-video-loaded'); } }); } $.fn.lazyYT = function () { return this.each(function () { var $el = $(this).css('cursor', 'pointer'); setUp($el); }); }; }(jQuery));
[+]
..
[-] lazyYT.min.js
[edit]
[-] LICENSE
[edit]
[-] package.json
[edit]
[-] lazyYT.jquery.json
[edit]
[+]
demo
[-] README.md
[edit]
[-] lazyYT.min.css
[edit]
[-] .gitignore
[edit]
[-] lazyYT.js
[edit]
[-] lazyYT.css
[edit]
[-] Gruntfile.js
[edit]