Newer
Older
dmpopidor / lib / assets / videos / index.files / html5video / html5ext.js
/**
 *	EasyHTML5Video JavaScript Extension API version 1.2
 *	Created by EasyHTML5Video.com
 *	Modified 13:05 25.07.2013
 *	This file content fullscreen api
 */
(function(){function j(t,s,i){if(t.addEventListener){t.addEventListener(s,i,false)}else{t.attachEvent("on"+s,i)}}function r(t,s,i){if(t.removeEventListener){t.removeEventListener(s,i)}else{t.detachEvent("on"+s,i)}}function o(u,t){if(!u.length){u=[u]}for(var v in t){for(var s=0;s<u.length;s++){u[s].style[v]=t[v]}}}function m(t,v){v=v||document;if(document.getElementsByClassName){return v.getElementsByClassName(t)}var w=v.getElementsByTagName("*"),s=[];for(var u=0;u<w.length;u++){if((new RegExp("(^|\\s+)"+t+"(\\s+|$)","g")).test(w[u].className)){s.push(w[u]);break}}return s}var h=0,n="";if(typeof document.cancelFullScreen!="undefined"){h=true}else{var e="webkit moz o ms khtml".split(" ");for(var f=0,l=e.length;f<l;f++){n=e[f];if(typeof document[n+"CancelFullScreen"]!="undefined"){h=true;break}}}function g(i){if(h){switch(n){case"":return document.fullScreen;case"webkit":return document.webkitIsFullScreen;default:return document[n+"FullScreen"]}}else{return !!i.eh5v}}var k=0;function c(i){if(h){return(n==="")?i.requestFullScreen():i[n+"RequestFullScreen"]()}else{if(!i){return}if(k){d(k)}var t={position:"fixed",left:0,top:0,right:"auto",bottom:"auto",width:window.innerWidth+"px",height:window.innerHeight+"px",backgroundColor:"rgba(0,0,0,0.9)",border:"none",zIndex:9999999};i.eh5v={};for(var s in t){i.eh5v[s]=i.style[s]}for(var s in t){i.style[s]=t[s]}j(document.body,"keydown",p);k=i}}function d(i){if(h){return(n==="")?document.cancelFullScreen():document[n+"CancelFullScreen"]()}else{if(!i){return}for(var s in i.eh5v){i.style[s]=i.eh5v[s]}i.eh5v=0;r(document.body,"keydown",p);k=0}}function p(i){if(i.keyCode==27){d(k)}}var q;function a(s,E){var t=s.getElementsByTagName("video")[0];if(t){if(/(iPad|iPhone|iPod)/ig.test(navigator.userAgent)){var w=new Image();w.style.visibility="hidden";w.src=t.poster;s.appendChild(w);t.style.position="absolute";t.style.height="100%"}if(t.eh5v){return}t.eh5v={fullScreen:function(i){if(i){c(t)}else{if(g(t)){d(t)}}return g(t)}};var y;if(!E.noFS&&t.getAttribute("controls")&&(window.opera||/MSIE/.test(navigator.userAgent)||navigator.mozVibrate)){var D=/(.*\/)[^\/]+/.exec(t.poster)[1]+"fullscreen.png";if(!q){q=new Image();q.src=D}y=document.createElement("div");o(y,{position:"absolute",zIndex:10,display:"none",right:"0px",top:"0px",width:"28px",height:"28px",background:'rgba(0,0,0,0.50) url("'+D+'") 50% 50% no-repeat',border:"none"});t.parentNode.appendChild(y);function z(){y.style.display="none"}j(t,"mouseover",function(){y.style.display="block"});j(t,"mouseout",function(){z()});j(y,"mouseover",function(){y.style.display="block"});j(y,"click",function(){c(t);z()})}j(t,"dblclick",function(){if(g(t)){d(t)}else{c(t)}if(y){setTimeout(z,100)}});if(!t.getAttribute("loop")){j(t,"ended",function(){setTimeout(function(){t.load();t.pause()},400)})}if(/Android/.test(navigator.userAgent)){var u=t.getElementsByTagName("source"),A;for(var v=u.length-1;v>=0;v--){if(!u[v].type){A=u[v].src}else{if(A&&/mp4/.test(u[v].type)){u[v].src=A;t.load()}}}}}if(!t||!t.canPlayType){var x=s.getElementsByTagName("object")[0]||s.getElementsByTagName("embed")[0];var C=x.height/x.width;x.setAttribute("width","100%");x.removeAttribute("height");var B=function(){x.style.height=s.offsetWidth*C+"px"};j(window,"resize",B);B()}}var b=m("easyhtml5video");for(var f=0;f<b.length;f++){a(b[f],{noFS:0})}})();