forked from luwes/vimeowrap.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimeowrap.carousel.js
1 lines (1 loc) · 9.68 KB
/
vimeowrap.carousel.js
1
(function(t){t.carousel=function(e,i){var A=this;var n;var a;var s={position:"bottom",size:130,offsetx:50,offsety:10,autoplay:false,template:'<a href="{{url}}" title="{{title}}"><img src="{{thumbnail_'+(i.thumb&&i.thumb.quality?i.thumb.quality:"small")+'}}" alt="" /><span>{{title}}</span></a>',style:"",easing:TWEEN.Easing.Exponential.EaseInOut,speed:250,thumb:{width:100,height:75}};i=t.utils.extend(s,i);this.config=i;this.xx=0;this.visible=0;this.position=0;this.offset=0;this.length=0;TWEEN.start();this.setup=function(){var A=i.fontdir||"http://luwes.co/vimeowrap.js/fonts/";var s="@font-face {font-family:'Pictish'; src:url('"+A+"pictish.eot'); src:url('"+A+"pictish.eot?#iefix') format('embedded-opentype'), "+"url(data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAdcABEAAAAACsQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABgAAAABwAAAAcYSxV1EdERUYAAAGcAAAAHQAAACAARQAET1MvMgAAAbwAAAA5AAAAYGvYP5djbWFwAAAB+AAAAHkAAAGKB0p972N2dCAAAAJ0AAAAAgAAAAIAAAAAZnBnbQAAAngAAAGxAAACZVO0L6dnYXNwAAAELAAAAAgAAAAIAAAAEGdseWYAAAQ0AAAAlwAAAQTYqWcZaGVhZAAABMwAAAApAAAANv9CA39oaGVhAAAE+AAAAB0AAAAkEAIM6WhtdHgAAAUYAAAAOAAAAGBwhQGYbG9jYQAABVAAAAAWAAAAMgMkAt5tYXhwAAAFaAAAACAAAAAgATEAKm5hbWUAAAWIAAABGwAAAd/di13ccG9zdAAABqQAAAB9AAAA4MyBUi5wcmVwAAAHJAAAAC4AAAAusPIrFHdlYmYAAAdUAAAABgAAAAYqwk/iAAAAAQAAAADJiW8xAAAAAMubC2EAAAAAzAfbQXjaY2BkYGDgA2IJBhB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aBi/hAHjaY2BkYGAA4pfOe3zj+W2+MshzMIDAGfbbjsg0BwMHhGICUQAKeAf2AAAAeNpjYGRg4GD4f4OBgecHAwOIzcDIgAokAFHaAwYAAAB42uNggAAOIGZaxcDA8wPCBmEQmwXKZkFSwwSkGUOhGMSeCSQKwWrOANWcAfHBar4wMAAAUe4IiHjaY2BAAkoMbjhhEkMVGDYBAGH4BgMAAAABAAAAGAAHAAEAAAAAAAIAAQACABYAAAEAAB8AAAAAeNpdkDFOw0AQRf+SgISQoIiUEk2DBA0KCBpapBRUQJGUaJ0s9ia24zhxEocbcANOwQno4Vb8XRYkY8mzb2b+/B0bwAFeoeCeDs4YW1DtfZ6nzH5Y4RAPgXfIT4Fb5CxwG8d4CbyLLt4C71HzHriDR3wE/kRXHQX+Qk+d9O3KSGRjmVd6NLV5LFtTJHW5kMksXUpWy1pvJDJj3GKGAjVKWMRIsIQgRYU1DBbkS/RwwXjP/ohdy2rCqw3VFZWak04b4ZlOORVNpfzTDpiV7FivFnqf84bmTJ/nijqhq9tKMOe8pmLKPPeVLfsFtbV3E0zol/rtM9aEO2lsvIPBGMPGhr+3Dn1PcEf3PHyr613jhq+LV4x//+AbUAlLdwB42m3NOw6CUBSE4RlQ8A1q4zIuV/HRGEnApYAmxthYuC1dhNsSPVP6N18yzSCA9UaNfy0ABgzZQYg9DuwyYswe+xxwyBHHnDBhiidenHLGedRcHrdTZvj4fj0750qzcF99O8hMermUK5nLtdzIrdzJwvRHM/9ZtT8fxXkqqQAAALgB/4WwAY0AS7AIUFixAQGOWbFGBitYIbAQWUuwFFJYIbCAWR2wBitcWFmwFCsAAAABT+IqwQAA) format('woff'), "+"url('"+A+"pictish.ttf') format('truetype'), url('"+A+"pictish.svg#PictishRegular') format('svg'); font-weight:normal; font-style:normal;}"+"#{{id}} a {text-decoration:none;}"+"#{{id}} a:active, #{{id}} a:focus {outline:none;}"+"#{{id}} {font:bold 12px/14px helvetica,arial,sans-serif;-webkit-tap-highlight-color:rgba(0,0,0,0);}"+"#{{id}} ul {margin:0;padding:0;}"+"#{{id}} ul li {display:block;float:left;width:{{thumb_width}}px;line-height:14px;}"+"#{{id}} ul li a {display:block;color:#{{color}};text-align:center;}"+"#{{id}} ul li a img {border:none;width:{{thumb_width}}px;height:{{thumb_height}}px;}"+"#{{id}}_navleft, #{{id}}_navright {color:#000;display:block;font-family:'Pictish';font-size:19px;position:absolute;top:32px;width:20px;height:19px;padding:10px;}"+"#{{id}}_navright {right:0;}";if("ontouchstart"in window){s+="#{{id}} ul li a.pressed {color:#F75342;}"+"#{{id}}_navleft.pressed, #{{id}}_navright.pressed {color:#{{color}};}"}else{s+="#{{id}} ul li a:hover {color:#F75342;}"+"#{{id}}_navleft:hover, #{{id}}_navright:hover {color:#{{color}};}"}s+=i.style;var h=document.createTextNode(s.populate({id:e.id+"_carousel",color:e.config.color,thumb_width:i.thumb.width,thumb_height:i.thumb.height}));var l=document.createElement("style");l.type="text/css";t.utils.prepend(l,document.getElementsByTagName("head")[0]);if(l.styleSheet){l.styleSheet.cssText=h.nodeValue}else{l.appendChild(h)}n=document.createElement("div");n.id=e.id+"_carousel";e.container.appendChild(n);t.utils.css(n,{width:this.width,height:this.height,position:"absolute",left:this.x,top:this.y});new t.carousel.NoClickDelay(n);var u=document.createElement("div");u.id=n.id+"_wrap";n.appendChild(u);t.utils.css(u,{width:this.width-i.offsetx*2,height:this.height-i.offsety,overflow:"hidden",position:"absolute",left:i.offsetx,top:i.offsety});a=document.createElement("ul");a.id=n.id+"_list";u.appendChild(a);t.utils.css(a,{height:this.height,position:"absolute","list-style":"none"});a.onclick=r;var d=document.createElement("a");d.id=n.id+"_navleft";d.href="#left";d.innerHTML="<span>[</span>";n.appendChild(d);d.onclick=this.left;var c=document.createElement("a");c.id=n.id+"_navright";c.href="#right";c.innerHTML="<span>]</span>";n.appendChild(c);c.onclick=this.right;e.events.playlist.add(o)};function o(e){A.length=e.length;var a=A.width-i.offsetx*2;A.visible=i.visible>0?i.visible:Math.floor(a/i.thumb.width);var s=Math.round((a-A.visible*i.thumb.width)/Math.max(A.visible-1,1));var o=[];var r=i.template;for(var h=0;h<e.length;h++){o.push('<li style="margin-right:'+s+'px;">');o.push(r.populate(e[h]));o.push("</li>")}var l=document.getElementById(n.id+"_list");l.innerHTML=o.join("");A.offset=i.thumb.width+s;t.utils.css(l,{width:e.length*A.offset})}function r(t){var A=t||window.event;var n=A.target||A.srcElement;if(n&&n.nodeName.toLowerCase()!=="li"){while(n){n=n.parentNode;if(n.nodeName.toLowerCase()==="li")break}}var a=0;var s=n.parentNode.children;for(var o=0;o<s.length;o++){a=o;if(s[o]===n)break}if(a!==e.config.item){e.playlistItem(a,i.autoplay)}return false}this.left=function(t){if(A.position>0){A.to(A.position-A.visible)}return false};this.right=function(t){if(A.position<A.length-A.visible){A.to(A.position+A.visible)}return false};this.to=function(t){A.position=t;new TWEEN.Tween(A).to({xx:-t*A.offset},i.speed).onUpdate(h).easing(i.easing).start();return false};function h(){a.style.left=A.xx+"px"}}})(vimeowrap);(function(t){function e(t){if("ontouchstart"in window){this.element=typeof t==="object"?t:document.getElementById(t);this.element.addEventListener("touchstart",this,false);this.element.addEventListener("click",this,true)}}e.prototype={handleEvent:function(t){this[t.type](t)},touchstart:function(t){this.moved=false;this.theTarget=document.elementFromPoint(t.targetTouches[0].clientX,t.targetTouches[0].clientY);if(this.theTarget.nodeType==3)this.theTarget=theTarget.parentNode;this.theTarget.className+=" pressed";this.element.addEventListener("touchmove",this,false);this.element.addEventListener("touchend",this,false)},touchmove:function(t){this.moved=true;this.theTarget.className=this.theTarget.className.replace(/ ?pressed/gi,"")},touchend:function(t){t.preventDefault();this.element.removeEventListener("touchmove",this,false);this.element.removeEventListener("touchend",this,false);if(!this.moved&&this.theTarget){this.theTarget.className=this.theTarget.className.replace(/ ?pressed/gi,"");var e=document.createEvent("MouseEvents");e.initEvent("click",true,true);this.theTarget.dispatchEvent(e)}this.theTarget=undefined},click:function(t){if(this.theTarget===undefined){t.stopImmediatePropagation();t.preventDefault()}}};t["NoClickDelay"]=e})(vimeowrap.carousel);var TWEEN=TWEEN||function(){var t,e,i,A,n=60,a=false,s=[],o;return{setFPS:function(t){n=t||60},start:function(t){if(arguments.length!==0){this.setFPS(t)}i=setInterval(this.update,1e3/n)},stop:function(){clearInterval(i)},setAutostart:function(t){a=t;if(a&&!i){this.start()}},add:function(t){s.push(t);if(a&&!i){this.start()}},getAll:function(){return s},removeAll:function(){s=[]},remove:function(e){t=s.indexOf(e);if(t!==-1){s.splice(t,1)}},update:function(e){t=0;o=s.length;var i=e||(new Date).getTime();while(t<o){if(s[t].update(i)){t++}else{s.splice(t,1);o--}}if(o===0&&a===true){this.stop()}}}}();TWEEN.Tween=function(t){var e=t,i={},A={},n={},a=1e3,s=0,o=null,r=TWEEN.Easing.Linear.EaseNone,h=null,l=null,u=null;this.to=function(t,i){if(i!==null){a=i}for(var A in t){if(e[A]===null){continue}n[A]=t[A]}return this};this.start=function(t){TWEEN.add(this);o=t?t+s:(new Date).getTime()+s;for(var a in n){if(e[a]===null){continue}i[a]=e[a];A[a]=n[a]-e[a]}return this};this.stop=function(){TWEEN.remove(this);return this};this.delay=function(t){s=t;return this};this.easing=function(t){r=t;return this};this.chain=function(t){h=t;return this};this.onUpdate=function(t){l=t;return this};this.onComplete=function(t){u=t;return this};this.update=function(t){var n,s,d;if(t<o){return true}s=(t-o)/a;s=s>1?1:s;d=r(s);for(n in A){e[n]=i[n]+A[n]*d}if(l!==null){l.call(e,d)}if(s==1){if(u!==null){u.call(e)}if(h!==null){h.start()}return false}return true}};TWEEN.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};TWEEN.Easing.Exponential.EaseIn=function(t){return t===0?0:Math.pow(2,10*(t-1))};TWEEN.Easing.Exponential.EaseOut=function(t){return t==1?1:-Math.pow(2,-10*t)+1};TWEEN.Easing.Exponential.EaseInOut=function(t){if(t===0)return 0;if(t==1)return 1;if((t*=2)<1)return.5*Math.pow(2,10*(t-1));return.5*(-Math.pow(2,-10*(t-1))+2)}