1
|
|
|
!function(a,b){var c={embed:{attr:"href",overflow:!1,fullscreen:!0,showCaptions:!1,regex:/^#/i,findSelector:function(a,b){if(!b)return"";var c=b.attr(a.options.embed.attr);return"string"==typeof c?b.attr(a.options.embed.attr):""}}};b.EmbedHandler=function(c){this.FooBox=c,this.type="embed",this.regex=/^#/i;var d=this;this.init=function(a){d.handlers.unbind(),a.on("foobox.close",d.handlers.onClose)},this.destroy=function(){d.handlers.unbind()},this.handlers={unbind:function(){d.FooBox.element.off("foobox.close",d.handlers.onClose)},onClose:function(){var c,e;for(c=0;c<d.FooBox.items.array.length;c++)if(e=d.FooBox.items.array[c],e.type==d.type&&b.isjQuery(e.content)&&0==e.error&&a(e.selector).length>0){var f=e.content.children().detach();a(e.selector).append(f),e.content=null}}},this.handles=function(b){var c=d.FooBox.options.embed.findSelector(d.FooBox,b),e="foobox"===a(b).attr("target")&&"string"==typeof c&&null!=c.match(d.FooBox.options.embed.regex)&&a(c).length>0&&"embed"==a(b).data("type"),f=d.FooBox.raise("foobox.handlesEmbed",{element:b,handle:e});return f.fb.handle},this.defaults=function(a){a.fullscreen=a.fullscreen||d.FooBox.options.embed.fullscreen,a.overflow=a.overflow||d.FooBox.options.embed.overflow,a.social=a.social||!0,a.proportion=a.proportion||!0,a.captions=a.captions||d.FooBox.options.embed.showCaptions},this.parse=function(c){var e=new b.Item(d.type,c,this);d.defaults(e),e.url=e.selector=d.FooBox.options.embed.findSelector(d.FooBox,c)||null;var f=null!=e.selector?a(e.selector):null;return null!=f&&f.length>0?(e.width=b.Size.check(f.data("width")||c.data("width")||e.width||null),e.height=b.Size.check(f.data("height")||c.data("height")||e.height||null)):(e.width=b.Size.check(c.data("width")||e.width||null),e.height=b.Size.check(c.data("height")||e.height||null)),e.overflow="boolean"==typeof c.data("overflow")?c.data("overflow"):e.overflow,e.fullscreen="boolean"==typeof c.data("fullscreen")?c.data("fullscreen"):e.fullscreen,e.proportion="boolean"==typeof c.data("proportion")?c.data("proportion"):e.proportion,e.image_url=c.data("image")||"",e},this.load=function(c,e,f,g){try{var h=a("<div/>").addClass("fbx-item fbx-item-embed");if(null==c.content&&"string"==typeof c.selector){if(0==a(c.selector).length){var i=d.FooBox.raise("foobox.loadEmbed",{container:h,selector:c.selector,success:function(){c.content=i.fb.container,e.empty().append(c.content),a.isFunction(f)&&f(d.getSize(c))},error:function(b){b=b||"Unable to load embed.",a.isFunction(g)&&g(b)}});return}var j=a(c.selector);j.length>0&&(c.content=h.append(j.children()))}b.isjQuery(c.content)?(e.empty().append(c.content),a.isFunction(f)&&f(d.getSize(c))):a.isFunction(g)&&g("No valid HTML found to display.")}catch(k){a.isFunction(g)&&g(k)}},this.preload=function(a){},this.getCSS=function(a){return{font:a.css("font"),padding:a.css("padding"),margin:a.css("margin"),border:a.css("border")}},this.getSize=function(c){if((c.auto||null==c.width||0==c.width||null==c.height||0==c.height)&&"string"==typeof c.selector){c.auto=c.auto||{width:!1,height:!1};var e,f,g=a(c.selector);if(g.length>0&&g.children().length>0?(f=d.getCSS(g),e=g.clone().css(f)):b.isjQuery(c.content)&&(f=d.getCSS(c.content),e=c.content.clone().css(f)),b.isjQuery(e)){var h=d.FooBox.modal.element.find(".fbx-inner-spacer"),i=parseInt(h.css("padding-left")),j=parseInt(h.css("padding-right")),k=(isNaN(i)?0:i)+(isNaN(j)?0:j),l=d.FooBox.modal.element.find(".fbx-inner"),m=parseInt(l.css("border-left")),n=parseInt(l.css("border-right")),o=(isNaN(m)?0:m)+(isNaN(n)?0:n),p=Math.max(document.documentElement.clientWidth,window.innerWidth,0)-k-o;e.css({position:"absolute",visibility:"hidden",display:"block",top:-1e4,left:-1e4,maxWidth:p}).appendTo("body"),1==c.auto.width||null==c.width||0==c.width?(c.auto.width=!0,c.width=e.outerWidth(!0)):c.width&&e.width(c.width),(1==c.auto.height||null==c.height||0==c.height)&&(c.auto.height=!0,c.height=e.outerHeight(!0)),e.remove()}}return null!=c.width&&null!=c.height?new b.Size(c.width,c.height):new b.Size(0,0)},this.hasChanged=function(){return!1}},b.handlers.register(b.EmbedHandler,c)}(jQuery,window.FooBox),function(a,b){var c={videos:{attr:"href",fullscreen:!0,regex:/(youtube(-nocookie)?\.com\/(watch|v|embed)|youtu\.be|vimeo\.com(?!(\/user))|\.mp4|\.ogv|\.wmv|\.webm|(.+)?(wistia\.(com|net)|wi\.st)\/.*|(www.)?dailymotion\.com|dai\.ly)/i,findUrl:function(a,c){if(!c)return"";var d=c.attr(a.options.videos.attr);return"string"==typeof d?b.qualifiedURL(c.attr(a.options.videos.attr)):""},autoPlay:!1,defaultWidth:640,defaultHeight:385,showCaptions:!1,showImmediate:!1}};b.Item.prototype.video_url=null,b.Item.prototype.image_url=null,b.Item.prototype.mimeType=null,b.Item.prototype.player=null,b.Item.prototype.$player=null,b.VideoUrl=function(c,d){if(!(this instanceof b.VideoUrl))return new b.VideoUrl(c);this.autoPlay=d;var e=c.split("#");this.hash=2==e.length?"#"+e[1]:"",e=e[0].split("?"),this.url=e[0];var f=this.url.match(/.*\/(.*)$/);this.id=f&&f.length>=2?f[1]:null,this.protocol="https:"===window.location.protocol?"https:":"https"==c.substring(0,5)?"https:":"http:",this.params=[];for(var g,h=(2==e.length?e[1]:"").split(/[&;]/g),i=0,j=h.length;j>i;i++)g=h[i].split("="),2==g.length&&this.params.push({key:decodeURIComponent(g[0]),value:decodeURIComponent(g[1])});this.mimeTypes={"video/youtube":/(www.)?youtube|youtu\.be/i,"video/vimeo":/(player.)?vimeo\.com/i,"video/wistia":/(.+)?(wistia\.(com|net)|wi\.st)\/.*/i,"video/daily":/(www.)?dailymotion\.com|dai\.ly/i,"video/mp4":/\.mp4/i,"video/webm":/\.webm/i,"video/wmv":/\.wmv/i,"video/ogg":/\.ogv/i},this.mimeType=null;for(var k in this.mimeTypes)this.mimeTypes.hasOwnProperty(k)&&this.mimeTypes[k].test(c)&&(this.mimeType=k);var l=navigator.userAgent.toLowerCase(),m=l.indexOf("msie ")>-1||l.indexOf("trident/")>-1||l.indexOf("edge/")>-1,n=!document.addEventListener;if(this.isDirectLink=-1!==a.inArray(this.mimeType,["video/mp4","video/wmv","video/ogg","video/webm"]),this.isBrowserSupported=-1!==a.inArray(this.mimeType,m?n?[]:["video/mp4","video/wmv"]:["video/mp4","video/ogg","video/webm"]),"video/youtube"==this.mimeType)this.id=/embed\//i.test(this.url)?this.url.split(/embed\//i)[1].split(/[?&]/)[0]:c.split(/v\/|v=|youtu\.be\//i)[1].split(/[?&]/)[0],this.url=this.protocol+"//www.youtube-nocookie.com/embed/"+this.id,this.autoPlay&&this.param("autoplay","1"),this.param("modestbranding","1"),this.param("rel","0"),this.param("wmode","transparent"),this.param("showinfo","0");else if("video/vimeo"==this.mimeType)this.id=this.url.substr(this.url.lastIndexOf("/")+1),this.url=this.protocol+"//player.vimeo.com/video/"+this.id,this.autoPlay&&this.param("autoplay","1"),this.param("badge","0"),this.param("portrait","0");else if("video/wistia"==this.mimeType){this.id=/embed\//i.test(this.url)?this.url.split(/embed\/.*?\//i)[1].split(/[?&]/)[0]:this.url.split(/medias\//)[1].split(/[?&]/)[0];var o=/playlists\//i.test(this.url);this.url=this.protocol+"//fast.wistia.net/embed/"+(o?"playlists":"iframe")+"/"+this.id,this.autoPlay&&(o?this.param("media_0_0[autoPlay]","1"):this.param("autoPlay","1")),this.param("theme","")}else"video/daily"==this.mimeType&&(this.id=/\/video\//i.test(this.url)?this.url.split(/\/video\//i)[1].split(/[?&]/)[0].split(/[_]/)[0]:c.split(/dai\.ly/i)[1].split(/[?&]/)[0],this.url=this.protocol+"//www.dailymotion.com/embed/video/"+this.id,this.autoPlay&&this.param("autoplay","1"),this.param("wmode","opaque"),this.param("info","0"),this.param("logo","0"),this.param("related","0"));this.autoPlay=/[?&](autoplay|autoPlay|media_0_0(\[|%5B)autoPlay(]|%5D))=(1|true)&/.test(this.toString())},b.VideoUrl.prototype.param=function(a,b){for(var c="undefined"==typeof b,d="string"==typeof b&&""===b,e=this.params.length;e-- >0;)if(this.params[e].key==a)return c?this.params[e].value:void(d?this.params.splice(e,1):this.params[e].value=b);c||d||this.params.push({key:a,value:b})},b.VideoUrl.prototype.toString=function(){for(var a=this.params.length>0?"?":"",b=0,c=this.params.length;c>b;b++)0!=b&&(a+="&"),a+=encodeURIComponent(this.params[b].key)+"="+encodeURIComponent(this.params[b].value);return this.url+a+this.hash},b.VideoHandler=function(c){this.FooBox=c,this.type="video",this.hasMediaElement="MediaElementPlayer"in window;var d=this;this.handles=function(a){var b=d.FooBox.options.videos.findUrl(d.FooBox,a),c="string"==typeof b&&null!=b.match(d.FooBox.options.videos.regex),e=d.FooBox.raise("foobox.handlesVideo",{element:a,handle:c});return e.fb.handle},this.defaults=function(a){a.width=a.width||d.FooBox.options.videos.defaultWidth,a.height=a.height||d.FooBox.options.videos.defaultHeight,a.fullscreen=a.fullscreen||d.FooBox.options.videos.fullscreen,a.social=a.social||!0,a.captions=a.captions||d.FooBox.options.videos.showCaptions,a.proportion=a.proportion||!0},this.parse=function(c){var e=new b.Item(d.type,c,this);if(d.defaults(e),e.url=d.FooBox.options.videos.findUrl(d.FooBox,c)||null,e.width=b.Size.check(c.data("width")||e.width||null),e.height=b.Size.check(c.data("height")||e.height||null),e.image_url=c.data("image")||c.find("img").attr("src")||null,e.fullscreen="boolean"==typeof c.data("fullscreen")?c.data("fullscreen"):e.fullscreen,e.proportion="boolean"==typeof c.data("proportion")?c.data("proportion"):e.proportion,e.autoPlay=!1,e.video_url=[],null!==e.url){e.video_url=decodeURI(e.url).split(",");for(var f=0,g=e.video_url.length;g>f;f++)e.video_url[f]=new b.VideoUrl(a.trim(e.video_url[f]),d.FooBox.options.videos.autoPlay),e.video_url[f].autoPlay&&(e.autoPlay=!0)}return e},this.isDirectLink=function(a){if(!document.addEventListener)return!1;for(var b=0,c=a.video_url.length;c>b;b++)if(a.video_url[b].isDirectLink&&a.video_url[b].isBrowserSupported)return!0;return!1},this.load=function(b,c,e,f){function g(){a.isFunction(f)&&f("The video ["+b.url+"] is not supported")}function h(){m.removeEventListener("loadeddata",h,!1),m.removeEventListener("error",g,!1),b.autoPlay&&m.play(),a.isFunction(e)&&e(d.getSize(b))}try{var i,j,k,l;if(this.isDirectLink(b)){for(i=a("<div/>",{"class":"fbx-item fbx-item-video"}),j=a("<video/>",{"class":"fbx-video",width:b.width,height:b.height,controls:!0,controlsList:"nodownload",preload:!1}).css({width:"100%",height:"100%"}),k=0,l=b.video_url.length;l>k;k++)j.append(a("<source/>",{type:b.video_url[k].mimeType,src:b.video_url[k].toString()}));if(document.addEventListener){var m=j[0];m.addEventListener("error",g,!1),m.addEventListener("loadeddata",h,!1),c.empty().append(i.append(j)),m.readyState<4?m.load():h()}}else if(1!==b.video_url.length||b.video_url[0].isDirectLink)a.isFunction(f)&&f("The video ["+b.url+"] is not supported");else{var n=a('<iframe style="width:100%; height:100%" frameborder="no" allowfullscreen />').addClass("fbx-item fbx-item-video"),o=d.getSize(b);c.empty().append(n),d.FooBox.options.videos.showImmediate?(n.attr("src",b.video_url[0].toString()),a.isFunction(e)&&e(o)):n.one("load",function(){a.isFunction(e)&&e(o)}).attr("src",b.video_url[0].toString())}}catch(p){a.isFunction(f)&&f(p)}},this.preload=function(a){},this.getSize=function(a){return(null==a.width||null==a.height)&&(a.width=d.FooBox.options.videos.defaultWidth,a.height=d.FooBox.options.videos.defaultHeight),null!=a.width&&null!=a.height?new b.Size(a.width,a.height):new b.Size(0,0)},this.hasChanged=function(){return!1},this.getUrlVar=function(a,b){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c=new RegExp("[\\?&]"+a+"=([^&#]*)"),d=c.exec(b);return null==d?"":decodeURIComponent(d[1].replace(/\+/g," "))},this.appendUrlVar=function(a,b){var c=-1!==b.indexOf("?")?"&":"?";return b+c+a}},b.handlers.register(b.VideoHandler,c)}(jQuery,window.FooBox); |
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.
Further Readings: