forked from mike-zarandona/PrettyEmbed.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.prettyembed.min.js
4 lines (4 loc) · 9.33 KB
/
jquery.prettyembed.min.js
1
2
3
4
/**
* prettyEmbed.js | v1.1.0 | https://github.com/mike-zarandona/prettyembed.js
*/
(function(a,b){a.fn.prettyEmbed=function(e){e=a.extend({},a.fn.prettyEmbed.options,e);var d=(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent))?true:false;if(a("#pretty-embed-style").length===0){var h=a("<style />",{id:"pretty-embed-style",html:'.pretty-embed{position:relative;background-color:#000;cursor:pointer;display:block}.pretty-embed img{width:100%;height:auto}.pretty-embed iframe{border:0 solid transparent}.pretty-embed:after{display:block;content:"";position:absolute;top:50%;margin-top:-19px;left:50%;margin-left:-27px;width:54px;height:38px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABMCAYAAACIylL7AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAABmxJREFUeF7t3W9MVlUcB3BNs3Kt1h/XC9eL6kWCAg6E8h/YMLKFm4v+GNZCfYHQnDoNVzjLYbZG8SLCVqSrHGgWtnDWbK1CK/sHi5oF8n+9IMcqiIqA6PT9Xs6Nx+tPAkSec+9zfu7zgnvuOffhfr3Avc997pk0XjUrahZNgytgJsyCRFgC6XAfZEEObIZ8KIBCeB5eglehHN6Cd+Bd+AA+huPwBXwF30At/KDVQ9P/OAXu+t8Cx/gaOOYnUAXc1ntQCRWwH16Dl6EYnoWdsA22QC6shvthOdwGSRAN18OVcAlM1rtpYgsbZiCLYRO8CIeBO7AZfoG/4B9QloP7gvvkV2iBGuB/Qv4HyINUmK537/gVBo2BV6ATpBdmjd0fwJ8qt4Le42MsDHA17IW/QdqYNX54NB6CmXr3j67QMQHaQBrcunA6IFXHMLJChx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5zY3PhFUajSKG1h/f79zvS91aaq4XsCVM7DHPQuNlDAvwbnfcNmdy8T2CFHCwHzxYQjLUcDAfPFxI8vhfNzIFx/osxyrGBj/SY2WeZyPzPJBzPbR5f4Qw8CmgH3sgz9c6z5YxT7JzXyDD1bRgfniAnCEq3fCYuELzisirWSZ45COywnsIU+jZZ7HdFxOYDd4Gi3zLNJxOYERp2uSVrTCjxM/nPlkbSzwxVX7CFWuYxoqLIz3rGSZI13HNFRYSJytTupghU8rDJ5/eQsNd4esaJlhvY7n7EIjp/PgXJBSR2vicb7OoefVS4UV+Az7n3UHK3z+hEQdy/CFFTkfIychlQayLrweuEvHMbJCBz5a9ns9gDVx2mGxjmF0hY6XwZPAuT+kwa3xMwCcbfa6wb1/HoVBroL1cAz6QNqgNTa8isGZfOeC3uPjWBj0cuDk29nwDLwBnHybE5N1g51CeAj3Bd/H+gn4F9+nwBnYOTM8D4CFMPxfgReysHHOoTkdZsCNEAvzYSlw6nd3evt1sAG2wnZ4Ctwp7jkD+x54HfgsR36DnGr+CHDqeU47wiP9c/gS+Pm20GnuvVPau9z274B9qoEXCrgTOZ47rT0/a8D5lLltTmtfCi/Ac8DXydf7KHCHr4VMWAFpsAD4PfN75z7gvpiid8841KRJ/wIcsey9MCgPGwAAAABJRU5ErkJggg==);-webkit-background-size:cover;background-size:cover}.pretty-embed.play:after{display:none}.pretty-embed:hover:after{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABMCAYAAACIylL7AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAABwhJREFUeF7t3GlsVFUYBuCDIi4xGreA1O6dmXbaYQ2oCAriGjUuRDSiETVRISGCu2BcAH8gagKKpnWJ5UcBFVQIGhMDFGwVGcqU0m2WtkPpIqNSbEHaQj/fM5yh9HLAAlP6TTlv8iSdc+899/a8P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bCb/A7eKAYypXAcUSOl4C8ZitshgKQ88m5f4Q1sArkvXPhU/gI3gf5nPJ5X4IZ8BQ8AvfBbTAG5O8sf3e5BnItzlXLE4UI8R86m8y4ltOs9gAAAABJRU5ErkJggg==)}'}).appendTo("head")}if(e.useFitVids){if(!a.isFunction(a.fn.fitVids)){console.error("PrettyEmbed.js Error: options.useFitVids is set to true; FitVids not found!")}}var g;if(a(this).length===0){g=a(".pretty-embed")}else{g=a(this).add(".pretty-embed")}g.each(function(){a(this).addClass("pretty-embed");var i,q="",r="",l="",j,p,m,n,o;if(a(this).attr("data-pe-videoid")!==b){q=a(this).attr("data-pe-videoid")}else{if(a(this).attr("href")!==b){q=c(a(this).attr("href"))}else{q=e.videoID}}if(a(this).attr("data-pe-preview-size")!==b){r=a(this).attr("data-pe-preview-size")}else{if(e.previewSize!==b){r=e.previewSize}else{r=b}}if(a(this).attr("data-pe-custom-preview-image")!==b){l=a(this).attr("data-pe-custom-preview-image")}else{if(e.customPreviewImage!==b){l=e.customPreviewImage}else{l=b}}if(a(this).attr("data-pe-show-info")!==b){j=a(this).attr("data-pe-show-info")}else{if(e.showInfo!==b){j=e.showInfo}else{j=b}}if(a(this).attr("data-pe-show-controls")!==b){p=a(this).attr("data-pe-show-controls")}else{if(e.showControls!==b){p=e.showControls}else{p=b}}if(a(this).attr("data-pe-loop")!==b){m=a(this).attr("data-pe-loop")}else{if(e.loop!==b){m=e.loop}else{m=b}}if(a(this).attr("data-pe-color-scheme")!==b){n=a(this).attr("data-pe-color-scheme")}else{if(e.colorScheme!==b){n=e.colorScheme}else{n=b}}if(a(this).attr("data-pe-show-related")!==b){o=a(this).attr("data-pe-show-related")}else{if(e.showRelated!==b){o=e.showRelated}else{o=b}}if(a(this).is("a")){i=a("<div />").addClass("pretty-embed");i.attr("data-pe-videoid",q).attr("data-pe-preview-size",r).attr("data-pe-custom-preview-image",l).attr("data-pe-show-info",j).attr("data-pe-show-controls",p).attr("data-pe-loop",m).attr("data-pe-color-scheme",n).attr("data-pe-show-related",o);a(this).after(i)}if(l!==b){a(this).html('<img src="'+l+'" width="100%" alt="YouTube Video Preview" />')}else{var k="";switch(r){case"thumb-default":k="default";break;case"thumb-1":k="1";break;case"thumb-2":k="2";break;case"thumb-3":k="3";break;case"default":k="mqdefault";break;case"medium":k="0";break;case"high":k="hqdefault";break;default:k="maxresdefault";break}a(this).html('<img src="http://img.youtube.com/vi/'+q+"/"+k+'.jpg" width="100%" alt="YouTube Video Preview" />')}if(a(this).is("a")){i.html(a(this).html());a(this).remove()}if(d){a(this).waitForImages(function(){f(a(this))})}});a("body").on("click",".pretty-embed",function(i){i.preventDefault();f(a(this))});function f(m){var j=m.outerWidth(true),l=m.outerHeight(true),i="",k="";if(m.attr("data-pe-videoid")!==b){k=m.attr("data-pe-videoid")}else{if(e.videoID!==b){k=e.videoID}else{k=b;console.error("PrettyEmbed.js Error: Misformed or missing video ID.")}}if((m.attr("data-pe-show-info")===false)||(e.showInfo===false)){i+="&showinfo=0"}if((m.attr("data-pe-show-controls")===false)||(e.showControls===false)){i+="&controls=0"}if((m.attr("data-pe-loop")===true)||(e.loop===true)){i+="&loop=1"}if((m.attr("data-pe-color-scheme")=="light")||(e.colorScheme=="light")){i+="&theme=light"}if((m.attr("data-pe-show-related")===false)||(e.showRelated===false)){i+="&rel=0"}else{i+="&rel=1"}m.html('<iframe width="'+j+'" height="'+l+'" style="border:none;" src="http://www.youtube.com/embed/'+k+"?autoplay=1"+i+'"></iframe>').addClass("play");if(e.useFitVids){if(a.isFunction(a.fn.fitVids)){m.parent().fitVids()}}}function c(k){var j=/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;var i=k.match(j);if(i&&i[7].length==11){return i[7]}else{console.error("PrettyEmbed.js Error: Bad URL.")}}a.fn.prettyEmbed.options={videoID:"",previewSize:"",customPreviewImage:"",showInfo:true,showControls:true,loop:false,colorScheme:"dark",showRelated:false,useFitVids:false}}})(jQuery);