This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
timeslidertooltipplugin.js
executable file
·1 lines (1 loc) · 8.02 KB
/
timeslidertooltipplugin.js
1
(function(y){y().registerPlugin("timeslidertooltipplugin",function(o,b,z){function e(a){if(w)return o.config["timeslidertooltipplugin."+a];for(var a=a.split("."),c=a.length,g=b,d=0;d<c;d++)if(g=g[a[d]],d+1>=c)return g}function A(){if(0==j.length){d.html(f,'<div class="tstt-preview"></div><span class="tstt-time">...</span>');p=d.selectors.getElementsByTagAndClass("div","tstt-preview",f)[0];q=d.selectors.getElementsByTagAndClass("span","tstt-time",f)[0];u(!1);var a;a={position:"absolute",pointerEvents:"none"}; d.css(f,a);a={width:"108px",height:"60px",position:"absolute",top:"2px",left:"2px",overflow:"hidden"};d.css(p,a);a={display:"block"};a.color=b.fontcolor;a.fontFamily=b.font;a.fontSize=b.fontsize+"px";a.fontWeight=b.fontweight;a.color=b.fontcolor;a.fontStyle=b.fontstyle;a.textAlign="center";a.lineHeight=b.labelheight+"px";a.pointerEvents="none";d.css(q,a);B(b.preview.enabled);v=b.preview.enabled;null!=r&&null!=i&&(C=!0,d.append(i,f),i.addEventListener("mousemove",E),i.addEventListener("mouseout",F))}else null== s&&(s=new Image,s.onload=D,s.onerror=D),s.src=j[0].url}function D(a){var c=j.shift().target;switch(a.type){case "error":"config.image"==c?b.image="":"config.preview.image"==c&&(b.preview.image="")}A()}function B(a){var c={};if(a!=v){v=!v;if(""===(a?b.preview.image:b.image))a?(c.width="112px",c.height="82px",c.background="url('data:;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABSCAYAAACMhFB2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1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G2L6V00T5mG7PqlKFrzClm7AOw4v3YScp+Z3HZ2UPadhVwYQ9pW8zsIHcAAQqgAAIUQAEUQIACKIACCFAABVAAAQqgAAogQAEUQAEEKIACCFAABVAAAQqgAAogQAEUQAEEKIACKIAABVAABRCgAAqgAAIUQAEEKIACKIAABVAABRCgAAqgAAIUQAHUS8C7NaTtXgEv9pC2yzwuh5h6X8cs7SRFt5gx5tiXUpp5qmmazsMwfDrTxZmNj5jvbFOB3uHVM75CEyK2iNfyb8Q/xFbxak29A590/gNt9QEfAgwAsOgxqt8Lp7QAAAAASUVORK5CYII=') left top no-repeat transparent"): (c.width="41px",c.height="22px",c.background="url('data:;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAWCAYAAABdTLWOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyOTJFQjY1QjY4NUQxMUUxODU2NjlGRUZDNTQ3OERBRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyOTJFQjY1QzY4NUQxMUUxODU2NjlGRUZDNTQ3OERBRCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjI5MkVCNjU5Njg1RDExRTE4NTY2OUZFRkM1NDc4REFEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjI5MkVCNjVBNjg1RDExRTE4NTY2OUZFRkM1NDc4REFEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+uNEd5wAAAKlJREFUeNpi/P//PwMQBAKxBxArMgwecBuINwPxDkagI0EOzGQYvKCHCUj4Mwxu4A9yJP8gdyQ/E8MQAKOOHHXkqCNHHTnqyGHiyI+D3I0fQY7cN8gduY8FSCwBYhDtAsQig8hxr0BtSSBeywht9JINHjx4sEtBQYGQGgagGreBzDhuIEfgcyBIzWDI3VgdSg0HUrsIQnEotRwIAhSnSSxgF8zR1DIQIMAAyzExMof0JwMAAAAASUVORK5CYII=') left top no-repeat transparent"), d.css(f,c);else{var g=new Image;g.onload=function(){c.background="url('"+this.src+"') left top no-repeat transparent";c.width=this.width+"px";c.height=this.height+"px";d.css(f,c)};g.onerror=function(){};g.src=a?b.preview.image:b.image}a?(p.style.display="block",q.style.marginTop="62px"):(p.style.display="none",q.style.marginTop="0px")}}function u(a){z.style.display=!1===a?"none":"block"}function E(a){var c=o.getDuration();if(C&&0<c){var g=d.getBoundingClientRect(r),g=a.pageX-g.left,e=d.getElementWidth(r), i=g/e,l=d.parentNode(f),l=d.getBoundingClientRect(l),a=a.pageX-l.left,c=Math.round(i*c);if(b.preview.enabled){var l=Math.floor(c/b.preview.frequency),h=b.preview.spritelength/b.preview.linelength,i=l%b.preview.linelength,l=Math.floor(l/b.preview.linelength)%h,h=c,h=(0>h?0:h)/b.preview.frequency/b.preview.spritelength,m;null==b.preview.path?(m=o.getPlaylistItem().file,m=m.substr(0,m.lastIndexOf("/")+1)):m=b.preview.path;var n;if(null==b.preview.prefix){n=o.getPlaylistItem().file;n=n.substr(n.lastIndexOf("/")+ 1,n.length);var j=n.lastIndexOf(".");0<j&&(n=n.substr(0,j))}else n=b.preview.prefix;h=m+n+x(Math.floor(h),4);h+="."+b.preview.extension;m={};m.backgroundImage="url('"+h+"')";m.backgroundPosition="-"+108*i+"px -"+60*l+"px";d.css(p,m);B(-1!=G(h))}d.html(q,H(c));c=d.getElementWidth(f);a-=Math.ceil(c/2);f.style.left=a+"px";u(0<=g&&g<=e)}else u(!1)}function G(a){if("undefined"==typeof t[a]){t[a]=0;var b=new Image;b.onerror=function(){t[a]=-1};b.onload=function(){t[a]=1};b.src=a;return 0}return t[a]}function F(){u(!1)} function H(a){var c="";if(3600<=a&&!0===b.displayhours)var d=Math.floor(a/3600),c=c+(Math.floor(a/3600)+":"),a=a-3600*d;return c+=x(Math.floor(a/60),2)+":"+x(Math.floor(a%60),2)}function x(a,b){for(var d=a.toString();d.length<b;)d="0"+d;return d}var f=z,w;a:{for(k in b)if("pluginmode"!=k){w=!1;break a}w=!0}var i=null,r=null,p=null,q=null,C=!1,v,t={},j,s=null,d=y.utils;o.onReady(function(){i=d.selectors("#"+o.id+"_jwplayer_controlbar_elements",document);r=d.selectors("#"+o.id+"_jwplayer_controlbar_timeSliderRail", document);j=[];b.displayhours="true"==""+e("displayhours")?!0:!1;var a=parseInt(e("marginbottom"));b.marginbottom=isNaN(a)?0:a;a=parseInt(e("labelheight"));b.labelheight=isNaN(a)?17:a;a=e("font");b.font=!a?"Arial,sans-serif":a;a=parseInt(e("fontsize"));b.fontsize=isNaN(a)?11:a;a=""+e("fontcolor");0===a.indexOf("0x")&&(a="#"+a.substr(2));b.fontcolor=!a?"#000":a;a=e("fontweight");b.fontweight="normal"!=a&&"bold"!=a?"normal":a;a=e("fontstyle");b.fontstyle="normal"!=a&&"italic"!=a?"normal":a;a=e("image"); b.image=null!=a&&"undefined"!=a?a:"";""!=b.image&&j.push({target:"config.image",url:b.image});a="true"==""+e("preview.enabled")?!0:!1;o.getPlaylistItem();var c=""+e("preview.path"),g=""+e("preview.prefix"),f=""+e("preview.image"),f=null!=f&&"undefined"!=f?f:"",p=parseInt(e("preview.frequency")),l=parseInt(e("preview.linelength")),h=parseInt(e("preview.spritelength"));b.preview={};b.preview.preloadtext="Loading...";b.preview.extension="jpg";b.preview.preload=!1;b.preview.cache=!0;b.preview.enabled= a;b.preview.path=c;b.preview.prefix=g;b.preview.image=f;"undefined"==b.preview.path&&(b.preview.path=null);"undefined"==b.preview.prefix&&(b.preview.prefix=null);""!=b.preview.image&&j.push({target:"config.preview.image",url:b.preview.image});b.preview.frequency=isNaN(p)?1:p;b.preview.linelength=isNaN(l)?5:l;b.preview.spritelength=isNaN(h)?25:h;A()});this.resize=function(a){if(null!=f&&null!=r&&null!=i){d.append(i,f);var c={},e=isNaN(b.marginbottom)?0:b.marginbottom,j=d.getElementHeight(i);c.bottom= 0+j+e+"px";c.left=Math.round(a/2)+"px";d.css(f,c)}}},"timeslidertooltipplugin-3")})(jwplayer);