From de8b6ffa3c686256030df04a6dd56025fe6de8ac Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Sep 2016 13:31:36 -0400 Subject: remove 2h site and bump to 0.1.40 --- site/public/assets/app.min.js | 8 - site/public/assets/fonts/BellGotBol.eot | Bin 24220 -> 0 bytes site/public/assets/fonts/BellGotBol.svg | 576 --- site/public/assets/fonts/BellGotBol.woff | Bin 17136 -> 0 bytes site/public/assets/fonts/BellGotLig.eot | Bin 24038 -> 0 bytes site/public/assets/fonts/BellGotLig.svg | 574 --- site/public/assets/fonts/BellGotLig.woff | Bin 16720 -> 0 bytes site/public/assets/images/2H_LOGOMARK.png | Bin 2466 -> 0 bytes site/public/assets/images/2H_LOGOMARK.svg | 58 - site/public/assets/images/2H_WORDMARK.png | Bin 4738 -> 0 bytes site/public/assets/images/dither.gif | Bin 52 -> 0 bytes site/public/assets/images/favicon.ico | Bin 1406 -> 0 bytes site/public/assets/images/fb.png | Bin 3203 -> 0 bytes site/public/assets/images/fb2.png | Bin 3203 -> 0 bytes site/public/assets/images/full.png | Bin 2969 -> 0 bytes site/public/assets/images/next.png | Bin 1063 -> 0 bytes site/public/assets/images/noise.png | Bin 28981 -> 0 bytes site/public/assets/images/play-button.png | Bin 17932 -> 0 bytes site/public/assets/images/play-button2.png | Bin 11901 -> 0 bytes site/public/assets/images/prev.png | Bin 1069 -> 0 bytes site/public/assets/images/tw.png | Bin 3298 -> 0 bytes site/public/assets/images/tw2.png | Bin 3121 -> 0 bytes site/public/assets/javascripts/_env.js | 771 --- site/public/assets/javascripts/app.js | 92 - .../javascripts/mx/extensions/mx.movements.js | 367 -- .../mx/extensions/mx.movementsMobile.js | 237 - .../javascripts/mx/extensions/mx.orbitCamera.js | 102 - .../mx/extensions/mx.rotationControl.js | 265 - .../assets/javascripts/mx/extensions/mx.scene.js | 165 - .../javascripts/mx/extensions/mx.scrubber.js | 191 - .../mx/extensions/mx.unclampedOrbitCamera.js | 130 - .../mx/extensions/mx.unclampedOrbitCameraMobile.js | 225 - site/public/assets/javascripts/mx/mx.js | 593 --- site/public/assets/javascripts/mx/mx.min.js | 1 - site/public/assets/javascripts/mx/mx.quaternion.js | 414 -- site/public/assets/javascripts/mx/mx.skew.js | 610 --- .../assets/javascripts/mx/primitives/mx.image.js | 50 - .../javascripts/mx/primitives/mx.soundcloud.js | 125 - .../assets/javascripts/mx/primitives/mx.text.js | 59 - .../assets/javascripts/mx/primitives/mx.video.js | 110 - .../assets/javascripts/mx/primitives/mx.vimeo.js | 162 - .../assets/javascripts/mx/primitives/mx.youtube.js | 196 - site/public/assets/javascripts/vendor/fastclick.js | 790 --- .../assets/javascripts/vendor/flickity.pkgd.js | 5090 -------------------- .../public/assets/javascripts/vendor/froogaloop.js | 287 -- .../public/assets/javascripts/vendor/jquery.min.js | 5 - .../assets/javascripts/vendor/jquery.min.map | 1 - site/public/assets/javascripts/vendor/loader.js | 85 - site/public/assets/javascripts/vendor/polyfill.js | 130 - site/public/assets/javascripts/vendor/tween.js | 691 --- site/public/assets/javascripts/vendor/util.js | 277 -- site/public/assets/javascripts/vendor/wheel.js | 82 - site/public/assets/style.css | 1167 ----- 53 files changed, 14686 deletions(-) delete mode 100644 site/public/assets/app.min.js delete mode 100644 site/public/assets/fonts/BellGotBol.eot delete mode 100644 site/public/assets/fonts/BellGotBol.svg delete mode 100644 site/public/assets/fonts/BellGotBol.woff delete mode 100644 site/public/assets/fonts/BellGotLig.eot delete mode 100644 site/public/assets/fonts/BellGotLig.svg delete mode 100644 site/public/assets/fonts/BellGotLig.woff delete mode 100644 site/public/assets/images/2H_LOGOMARK.png delete mode 100644 site/public/assets/images/2H_LOGOMARK.svg delete mode 100644 site/public/assets/images/2H_WORDMARK.png delete mode 100644 site/public/assets/images/dither.gif delete mode 100644 site/public/assets/images/favicon.ico delete mode 100755 site/public/assets/images/fb.png delete mode 100755 site/public/assets/images/fb2.png delete mode 100755 site/public/assets/images/full.png delete mode 100644 site/public/assets/images/next.png delete mode 100644 site/public/assets/images/noise.png delete mode 100644 site/public/assets/images/play-button.png delete mode 100644 site/public/assets/images/play-button2.png delete mode 100644 site/public/assets/images/prev.png delete mode 100755 site/public/assets/images/tw.png delete mode 100755 site/public/assets/images/tw2.png delete mode 100644 site/public/assets/javascripts/_env.js delete mode 100644 site/public/assets/javascripts/app.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.movements.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.movementsMobile.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.orbitCamera.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.rotationControl.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.scene.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.scrubber.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCamera.js delete mode 100644 site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCameraMobile.js delete mode 100644 site/public/assets/javascripts/mx/mx.js delete mode 100644 site/public/assets/javascripts/mx/mx.min.js delete mode 100644 site/public/assets/javascripts/mx/mx.quaternion.js delete mode 100644 site/public/assets/javascripts/mx/mx.skew.js delete mode 100644 site/public/assets/javascripts/mx/primitives/mx.image.js delete mode 100644 site/public/assets/javascripts/mx/primitives/mx.soundcloud.js delete mode 100644 site/public/assets/javascripts/mx/primitives/mx.text.js delete mode 100644 site/public/assets/javascripts/mx/primitives/mx.video.js delete mode 100644 site/public/assets/javascripts/mx/primitives/mx.vimeo.js delete mode 100644 site/public/assets/javascripts/mx/primitives/mx.youtube.js delete mode 100644 site/public/assets/javascripts/vendor/fastclick.js delete mode 100644 site/public/assets/javascripts/vendor/flickity.pkgd.js delete mode 100644 site/public/assets/javascripts/vendor/froogaloop.js delete mode 100644 site/public/assets/javascripts/vendor/jquery.min.js delete mode 100644 site/public/assets/javascripts/vendor/jquery.min.map delete mode 100644 site/public/assets/javascripts/vendor/loader.js delete mode 100644 site/public/assets/javascripts/vendor/polyfill.js delete mode 100755 site/public/assets/javascripts/vendor/tween.js delete mode 100644 site/public/assets/javascripts/vendor/util.js delete mode 100644 site/public/assets/javascripts/vendor/wheel.js delete mode 100644 site/public/assets/style.css (limited to 'site/public') diff --git a/site/public/assets/app.min.js b/site/public/assets/app.min.js deleted file mode 100644 index a550860..0000000 --- a/site/public/assets/app.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/* okfoc.us 2o15 */ -function FastClick(a,b){"use strict";function c(a,b){return function(){return a.apply(b,arguments)}}var d;if(b=b||{},this.trackingClick=!1,this.trackingClickStart=0,this.targetElement=null,this.touchStartX=0,this.touchStartY=0,this.lastTouchIdentifier=0,this.touchBoundary=b.touchBoundary||10,this.layer=a,this.tapDelay=b.tapDelay||200,!FastClick.notNeeded(a)){for(var e=["onMouse","onClick","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel"],f=this,g=0,h=e.length;h>g;g++)f[e[g]]=c(f[e[g]],f);deviceIsAndroid&&(a.addEventListener("mouseover",this.onMouse,!0),a.addEventListener("mousedown",this.onMouse,!0),a.addEventListener("mouseup",this.onMouse,!0)),a.addEventListener("click",this.onClick,!0),a.addEventListener("touchstart",this.onTouchStart,!1),a.addEventListener("touchmove",this.onTouchMove,!1),a.addEventListener("touchend",this.onTouchEnd,!1),a.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(a.removeEventListener=function(b,c,d){var e=Node.prototype.removeEventListener;"click"===b?e.call(a,b,c.hijacked||c,d):e.call(a,b,c,d)},a.addEventListener=function(b,c,d){var e=Node.prototype.addEventListener;"click"===b?e.call(a,b,c.hijacked||(c.hijacked=function(a){a.propagationStopped||c(a)}),d):e.call(a,b,c,d)}),"function"==typeof a.onclick&&(d=a.onclick,a.addEventListener("click",function(a){d(a)},!1),a.onclick=null)}}function wheel(a){function b(b){if(!a.locked){a.propagate||(b.stopPropagation(),b.preventDefault());var c=0,d=0;event.deltaY?(d-=event.deltaY*a.ratio,c-=event.deltaX*a.ratio):event.wheelDeltaY?(d-=event.wheelDeltaY*a.ratio,c-=event.wheelDeltaX*a.ratio):event.wheelDelta?d-=event.wheelDelta*a.ratio:event.detail&&(d+=2*event.detail),!a.reversible&&0>d&&0>c||a.update(b,d,c)}}a=defaults(a,{el:document,update:function(a,b){},propagate:!1,locked:!1,reversible:!0,ratio:.02,val:0});var c=1;return a.el.addEventListener("gesturestart",function(a){c=a.scale},!1),a.el.addEventListener("gesturechange",function(b){var d=(c-b.scale)*window.innerWidth;c=b.scale,a.update(b,d)},!1),a.el.addEventListener("wheel",b,!1),a.el.addEventListener("DOMMouseScroll",b,!1),a.lock=function(){a.locked=!0},a.unlock=function(){a.locked=!1},a}function has3d(){var a,b,c=$("

")[0],d=$("');a.append(c);var d=$f(a.find("iframe")[0]);a.data("player",d),d.addEvent("ready",function(){a.addClass("playing"),d.addEvent("play",function(){a.addClass("playing")}),d.addEvent("pause",function(){a.removeClass("playing")})}),videos.push(d)}}function HustleLoader(){function a(){b()}function b(){setTimeout(function(){$("#loader_svg").addClass("slide")},100)}var c=document.getElementById("loader_svg_status");this.update=function(a){var b=lerp(1-a,336,118);c.setAttribute("y",b)},this.finish=function(a){$("#loader_rapper").addClass("hidden"),setTimeout(a,100),setTimeout(function(){$("#loader_rapper").hide()},500)},a()}var MX=MX||function(a){function b(){var a=document.body.style;r.prefix="webkitTransform"in a?"webkit":"mozTransform"in a?"moz":"msTransform"in a?"ms":"",k=r.transformProp=h("transform"),l=r.transitionProp=h("transition"),m=r.transformOriginProp=h("transformOrigin"),n=r.transformStyleProp=h("transformStyle"),o=r.perspectiveProp=h("perspective"),p=r.transitionEndEvent="webkit"===r.prefix?"webkitTransitionEnd":"transitionend";for(var b=["webkit","moz","ms"],d=0;d0?1:-1;return b.y=g*Math.atan2(c*Math.cos(b.x),f*-g),b.z=Math.atan2(Math.cos(b.x),Math.sin(b.x)*Math.sin(b.y))-Math.PI/2,"deg"===r.rotationUnit&&(b.x=e(b.x),b.y=e(b.y),b.z=e(b.z)),b},add:function(){if(this.el){var a=this;return Array.prototype.forEach.call(arguments,function(b){!b instanceof i||(a.el.appendChild(b.el),a.children||(a.children=[]),a.children.push(b),b.parent=a)}),this}},remove:function(){var b=this;return Array.prototype.forEach.call(arguments,function(c){var d=b.children.indexOf(c);-1!==d&&(b.children.splice(d,1),b.el.removeChild(c.el),c.parent=a)}),this},addTo:function(a){return"string"==typeof a&&(a=document.querySelector(a)),a instanceof HTMLElement&&a.appendChild?a.appendChild(this.el):(a instanceof i||a instanceof r.Scene)&&a.add(this),this},removeElement:function(){this.el.parentNode&&this.el.parentNode.removeChild(this.el)},setPosition:function(a){this.x=a.x||0===a.x?a.x:this.x,this.y=a.y||0===a.y?a.y:this.y,this.z=a.z||0===a.z?a.z:this.z},setRotation:function(a){this.rotationX=a.x||0===a.x?a.x:this.rotationX,this.rotationY=a.y||0===a.y?a.y:this.rotationY,this.rotationZ=a.z||0===a.z?a.z:this.rotationZ},setScale:function(a){this.scaleX=a.x||0===a.x?a.x:this.scaleX,this.scaleY=a.y||0===a.y?a.y:this.scaleY,this.scaleZ=a.z||0===a.z?a.z:this.scaleZ},setSkew:function(a){this.skewX=a.x||0===a.x?a.x:this.skewX,this.skewY=a.y||0===a.y?a.y:this.skewY},setCSSTransformOrigin:function(a){return this.el&&(this.el.style[m]=a),this},setCSSTransformStyle:function(a){return this.el&&(this.el.style[n]=a),this},setCSSTransition:function(a){return this.el&&(this.el.style[l]=a),this},setCSSPerspective:function(a){return this.el&&(this.el.style[o]=a),this},move:function(a){var b=this;b.ops=defaults(a,b.ops);for(var c in a)b[c]=a[c];b.dirty=!0,b.update()},onTransitionEnd:function(a){function b(){c.removeEventListener(p,b),a()}this.cancelTransitionEnd();var c=this.el;c.addEventListener(p,b)},cancelTransitionEnd:function(){this.el.removeEventListener(p)},toString:function(a){return a=a||"id width height depth x y z rotationX rotationY rotationZ scale".split(" "),this.__toString(a)},__toString:function(b,c){this.id=this.id||"undef";var d,e,f={},g=this.type||"Object3d",h=g.toLowerCase();for(var i in b)e=b[i],d=this[e],(0!==d||c)&&("number"==typeof d?-1!=e.indexOf("rotation")?f[e]=Number(d.toFixed(3)):f[e]=~~d:f[e]=d);return(c||"var "+h+" = new MX."+g)+"("+JSON.stringify(f,a,2)+")\n"+(c?"":"scene.add("+h+")")},contains:function(a,b,c){var d=!1,e=!1,f=!1;return d=null===a?!0:abs(this.x-a)<=this.width/2,e=null===b?!0:abs(this.y-b)<=this.height/2,f=null===c?!0:abs(this.z-c)<=this.depth/2,d&&e&&f}},i.extend=j.bind(i),r.Object3D=i,r.toRad=f,r.toDeg=e,Object.defineProperty(r,"positionAtCenter",{get:function(){return t},set:function(a){"boolean"==typeof a&&(t=a,t?c():d())}}),r}();MX.Camera=MX.Object3D.extend({init:function(){this.el=null,this.type="Camera"},move:function(a){for(var b in a)this[b]=a[b]},toString:function(){var a="x y z rotationX rotationY".split(" ");return this.__toString(a,"scene.camera.move")},getCameraEuler:function(a){var b=a.x-this.x,c=a.y-this.y,d=a.z-this.z;return r={},r.y=Math.atan2(-b,d),r.x=Math.atan2(-c,Math.sqrt(b*b+d*d)),r.z=0,"deg"===MX.rotationUnit&&(r.x=MX.toDeg(r.x),r.y=MX.toDeg(r.y)),r}}),MX.Scene=function(){function a(){this.el=document.createElement("div"),this.el.classList.add("mx-scene");var a=this.el.style;a[MX.transformProp]="preserve-3d",a.webkitPerspectiveOrigin="50% 50%",a.mozPerspectiveOrigin="50% 50%",a.perspectiveOrigin="50% 50%",a.webkitUserSelect="none",a.mozUserSelect="none",a.userSelect="none",a.overflow="hidden",this.inner=(new MX.Object3D).addTo(this.el),this.inner.el.style.width="0",this.inner.el.style.height="0";var b,c,d,e=this;Object.defineProperty(this,"width",{get:function(){return b},set:function(a){b=a,e.el.style.width=a+"px"}}),Object.defineProperty(this,"height",{get:function(){return c},set:function(a){c=a,e.el.style.height=a+"px"}}),Object.defineProperty(this,"perspective",{get:function(){return d},set:function(a){d=a,e.el.style[MX.perspectiveProp]=a+"px",e.inner.z=-a-e.camera.z,e.inner.rotationOrigin.z=-a}});this.camera=new MX.Camera;this.inner.rotationOrigin={x:0,y:0,z:0},this.perspective=0}var b=MX.Object3D.prototype.add,c=MX.Object3D.prototype.remove;return a.prototype={constructor:a,add:function(){return b.apply(this.inner,arguments),this},remove:function(){return c.apply(this.inner,arguments),this},addTo:function(a){return"string"==typeof a&&(a=document.querySelector(a)),a instanceof HTMLElement&&a.appendChild?a.appendChild(this.el):console.warn("You can only add a Scene to an HTML element."),this},update:function(){var a=this.inner,b=this.camera;return b.update(),a.z=-this.perspective-b.z,a.x=-b.x,a.y=-b.y,a.rotationX=-b.rotationX,a.rotationY=-b.rotationY,a.update(),this}},a}(),MX.OrbitCamera=function(a){function b(a){return function(b){a(b.touches[0])}}function c(a){k=a.pageX,l=a.pageY,f.dragging=!0}function d(a){f.dragging&&(f.delta(k-a.pageX,l-a.pageY),k=a.pageX,l=a.pageY)}function e(a){f.dragging=!1}var f={},g=!1;f.opt=a=defaults(a,{el:window,camera:scene.camera,radius:100,radiusRange:[10,1e3],rotationX:PI/2,rotationY:0,center:{x:0,y:0,z:0},sensitivity:10,wheelSensitivity:10,ease:10,wheelEase:10});var h,i,j,k,l,m=1e-10;return f.dragging=!1,f.init=function(){i=a.rotationY,h=a.rotationX,j=a.radius,f.wheel=new wheel({el:a.el,update:function(b,c){a.radius=clamp(a.radius+c*a.wheelSensitivity,a.radiusRange[0],a.radiusRange[1])}}),f.bind()},f.toggle=function(a){a?f.bind():f.unbind()},f.bind=function(){g||(g=!0,a.el.addEventListener("mousedown",c),window.addEventListener("mousemove",d),window.addEventListener("mouseup",e),a.el.addEventListener("touchstart",b(c)),window.addEventListener("touchmove",b(d)),window.addEventListener("touchend",b(e)),f.wheel.unlock())},f.unbind=function(){g&&(g=!1,a.el.removeEventListener("mousedown",c),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",e),f.wheel.lock())},f.delta=function(b,c){a.rotationY+=b/window.innerWidth*a.sensitivity,a.rotationX=a.rotationX+c/window.innerHeight*a.sensitivity},f.move=function(b,c){a.rotationY=b,"number"==typeof c&&(a.rotationX=c)},f.zoom=function(b){a.radius=b},f.setZoom=function(b){j=a.radius=b},f.zoomPercent=function(b){a.radius=lerp(b,a.radiusRange[0],a.radiusRange[1])},f.zoomDelta=function(b){a.radius+=b},f.pause=function(){var b=sign(a.rotationY-i),c=sign(a.rotationX-h);a.rotationY=i+.1*b,a.rotationX=h+.1*c},f.update=function(){i=abs(i-a.rotationY)>m?avg(i,a.rotationY,a.ease):a.rotationY,h=abs(h-a.rotationX)>m?avg(h,a.rotationX,a.ease):a.rotationX,j=abs(j-a.radius)>m?avg(j,a.radius,a.wheelEase):a.radius,a.camera.x=a.center.x+j*sin(h)*cos(i),a.camera.z=a.center.y+j*sin(h)*sin(i),a.camera.y=a.center.z+j*cos(h),a.camera.rotationX=PI/2-h,a.camera.rotationY=i+PI/2},f},MX.OrbitCameraMobile=function(a){function b(a){return function(b){a(b.touches[0])}}function c(a){k=a.pageX,l=a.pageY,f.dragging=!0}function d(a){f.dragging&&(f.delta(k-a.pageX,l-a.pageY),k=a.pageX,l=a.pageY)}function e(a){f.dragging=!1}var f={},g=!1;f.opt=a=defaults(a,{el:window,camera:scene.camera,radius:100,radiusRange:[10,1e3],rotationX:PI/2,rotationY:0,center:{x:0,y:0,z:0},sensitivity:10,wheelSensitivity:10,ease:10,wheelEase:10});var h,i,j,k,l,m,n=1e-10,o=0,p=0,q=0,r=0,s=20;return f.dragging=!1,f.init=function(){i=a.rotationY,h=a.rotationX,j=a.radius,f.wheel=new wheel({el:a.el,update:function(b,c){a.radius=clamp(a.radius+c*a.wheelSensitivity,a.radiusRange[0],a.radiusRange[1])}}),f.bind(),f.orientationchange()},f.toggle=function(a){a?f.bind():f.unbind()},f.bind=function(){g||(g=!0,a.el.addEventListener("touchstart",b(c)),window.addEventListener("touchmove",b(d)),window.addEventListener("touchend",b(e)),window.addEventListener("orientationchange",f.orientationchange),window.addEventListener("devicemotion",f.devicemotion),window.addEventListener("deviceorientation",f.deviceorientation),f.wheel.unlock())},f.unbind=function(){g&&(g=!1,f.wheel.lock())},f.orientationchange=function(a){is_portrait=window.innerWidthq&&(q=b.beta,p=o);b.beta+7;d=!is_android&&r>s?o>p?b.beta-90:90-b.beta:0,(Math.abs(c-m)<100||Math.abs(c-m)>300)&&(e=c-m,m=c),e>300?e-=360:-300>e&&(e+=360),a.rotationX=MX.toRad(-5*d),a.rotationY+=MX.toRad(10*e)},f.landscapeorientation=function(b){var c,d;c=b.gamma>0?90-b.gamma:90+b.gamma,d=b.alpha-m,m=b.alpha,d>300?d-=360:-300>d&&(d+=360),a.rotationX=c>45?0:MX.toRad(c),a.rotationY+=MX.toRad(d)},f.delta=function(b,c){a.rotationY+=b/window.innerWidth*a.sensitivity,a.rotationX=a.rotationX+c/window.innerHeight*a.sensitivity},f.move=function(b,c){a.rotationY=b,"number"==typeof c&&(a.rotationX=c)},f.zoom=function(b){a.radius=b},f.setZoom=function(b){j=a.radius=b},f.zoomPercent=function(b){a.radius=lerp(b,a.radiusRange[0],a.radiusRange[1])},f.zoomDelta=function(b){a.radius+=b},f.pause=function(){var b=sign(a.rotationY-i),c=sign(a.rotationX-h);a.rotationY=i+.1*b,a.rotationX=h+.1*c},f.update=function(){i=abs(i-a.rotationY)>n?avg(i,a.rotationY,a.ease):a.rotationY,h=abs(h-a.rotationX)>n?avg(h,a.rotationX,a.ease):a.rotationX,j=abs(j-a.radius)>n?avg(j,a.radius,a.wheelEase):a.radius,a.camera.x=a.center.x+j*sin(h)*cos(i),a.camera.z=a.center.y+j*sin(h)*sin(i),a.camera.y=a.center.z+j*cos(h),a.camera.rotationX=PI/2-h,a.camera.rotationY=i+PI/2},f},MX.Image=MX.Object3D.extend({init:function(a){this.type="Image",this.media=a.media,this.width=0,this.height=0,this.x=a.x||0,this.y=a.y||0,this.z=a.z||0,this.scale=a.scale||1,this.backface=a.backface||!1,a.className&&this.el.classList.add(a.className),this.backface&&this.el.classList.add("backface-visible"),this.el.classList.add("image"),this.el.classList.add("mx-scenery"),this.el.style.backgroundRepeat="no-repeat",this.load(a)},load:function(a){var b=this;b.ops=defaults(a,b.ops);var c=new Image;c.onload=function(){b.ops&&(b.scale=b.ops.scale||1,b.width=b.ops.width||c.naturalWidth,b.height=b.ops.height||c.naturalHeight,b.el.style.backgroundImage="url("+c.src+")",b.el.classList.add("image"),b.dirty=!0,b.ops.onload&&b.ops.onload(c),b.update())},c.src=a.src,c.complete&&setTimeout(c.onload)}}),!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=a.length,c=fa.type(a);return"function"===c||fa.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(fa.isFunction(b))return fa.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return fa.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(na.test(b))return fa.filter(b,a,c);b=fa.filter(b,a)}return fa.grep(a,function(a){return fa.inArray(a,b)>=0!==c})}function e(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}function f(a){var b=va[a]={};return fa.each(a.match(ua)||[],function(a,c){b[c]=!0}),b}function g(){pa.addEventListener?(pa.removeEventListener("DOMContentLoaded",h,!1),a.removeEventListener("load",h,!1)):(pa.detachEvent("onreadystatechange",h),a.detachEvent("onload",h))}function h(){(pa.addEventListener||"load"===event.type||"complete"===pa.readyState)&&(g(),fa.ready())}function i(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(Aa,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:za.test(c)?fa.parseJSON(c):c}catch(e){}fa.data(a,b,c)}else c=void 0}return c}function j(a){var b;for(b in a)if(("data"!==b||!fa.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function k(a,b,c,d){if(fa.acceptData(a)){var e,f,g=fa.expando,h=a.nodeType,i=h?fa.cache:a,j=h?a[g]:a[g]&&g;if(j&&i[j]&&(d||i[j].data)||void 0!==c||"string"!=typeof b)return j||(j=h?a[g]=W.pop()||fa.guid++:g),i[j]||(i[j]=h?{}:{toJSON:fa.noop}),("object"==typeof b||"function"==typeof b)&&(d?i[j]=fa.extend(i[j],b):i[j].data=fa.extend(i[j].data,b)),f=i[j],d||(f.data||(f.data={}), -f=f.data),void 0!==c&&(f[fa.camelCase(b)]=c),"string"==typeof b?(e=f[b],null==e&&(e=f[fa.camelCase(b)])):e=f,e}}function l(a,b,c){if(fa.acceptData(a)){var d,e,f=a.nodeType,g=f?fa.cache:a,h=f?a[fa.expando]:fa.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){fa.isArray(b)?b=b.concat(fa.map(b,fa.camelCase)):b in d?b=[b]:(b=fa.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;for(;e--;)delete d[b[e]];if(c?!j(d):!fa.isEmptyObject(d))return}(c||(delete g[h].data,j(g[h])))&&(f?fa.cleanData([a],!0):da.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}function m(){return!0}function n(){return!1}function o(){try{return pa.activeElement}catch(a){}}function p(a){var b=La.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function q(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==ya?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==ya?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||fa.nodeName(d,b)?f.push(d):fa.merge(f,q(d,b));return void 0===b||b&&fa.nodeName(a,b)?fa.merge([a],f):f}function r(a){Fa.test(a.type)&&(a.defaultChecked=a.checked)}function s(a,b){return fa.nodeName(a,"table")&&fa.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function t(a){return a.type=(null!==fa.find.attr(a,"type"))+"/"+a.type,a}function u(a){var b=Wa.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function v(a,b){for(var c,d=0;null!=(c=a[d]);d++)fa._data(c,"globalEval",!b||fa._data(b[d],"globalEval"))}function w(a,b){if(1===b.nodeType&&fa.hasData(a)){var c,d,e,f=fa._data(a),g=fa._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)fa.event.add(b,c,h[c][d])}g.data&&(g.data=fa.extend({},g.data))}}function x(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!da.noCloneEvent&&b[fa.expando]){e=fa._data(b);for(d in e.events)fa.removeEvent(b,d,e.handle);b.removeAttribute(fa.expando)}"script"===c&&b.text!==a.text?(t(b).text=a.text,u(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),da.html5Clone&&a.innerHTML&&!fa.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&Fa.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}function y(b,c){var d=fa(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:fa.css(d[0],"display");return d.detach(),e}function z(a){var b=pa,c=ab[a];return c||(c=y(a,b),"none"!==c&&c||(_a=(_a||fa("') - $el.append($embed) - if (! is_mobile) { -// var $mask = $('

') -// $el.append($mask) - } - var player = $f( $el.find("iframe")[0] ) - $el.data('player', player) - player.addEvent('ready', function(){ -// console.log("ready") - $el.addClass('playing') - player.addEvent('play', function(){ -// console.log("playing") - $el.addClass('playing') - }) - player.addEvent('pause', function(){ - $el.removeClass('playing') - }) - }) - videos.push(player) -} -environment.update = noop -environment.updateOnReady = function(t){ - // strips.forEach(function(strip){ strip.update(t) }) - controls.delta( menu_open ? 0 : 1/16, 0) - scene.update() - controls.update() -} - -var Strip = function( opt ){ - this.opt = opt - - var root = this.root = new MX.Object3D () - root.x = opt.x || 0 - root.y = opt.y || 0 - root.z = opt.z || 0 - root.rotationX = opt.rotationX || 0 - root.rotationY = opt.rotationY || 0 - root.rotationZ = opt.rotationZ || 0 - root.addTo(scene) - - var prev = root - this.els = ( opt.images.toArray ? opt.images.toArray() : opt.images ).map(function(el, i){ - var url - if (typeof el == "string") { - url = el - } - else { - var data = $(el).data() - url = data.image - } - var el = new MX.Image({ - src: url, - onload: function(img){ - } - }) - el.setCSSTransformOrigin( "50% 100%" ) - el.addTo(prev) - el.update() - prev = el - return el - }) -} -Strip.prototype.update = function(t){ - var count = this.els.length - var offset = this.opt.offset - - t += offset - - // this.root.rotationZ = t/10000 - this.els.forEach(function(el, i){ - el.rotationX = i/count * Math.PI * 2 - el.skewY = cos( (1 + i) * 2 * Math.PI * t/100000 + 100 ) / 10 - el.y = el.height / 2 - }) -} - -function HustleLoader () { - var svg = document.getElementById("loader_svg_status") - function init(){ - build() - } - function build(){ - setTimeout(function(){ $("#loader_svg").addClass("slide") }, 100) - } - this.update = function (i) { - var y = lerp(1-i, 336, 118) - svg.setAttribute("y", y ) - } - this.finish = function(cb){ - $("#loader_rapper").addClass("hidden") - setTimeout(cb, 100) - setTimeout(function(){ - $("#loader_rapper").hide() - }, 500) - } - init() -} - -var Share = { - init: function(){ - $(document).on("click", ".fb", Share.facebook) - $(document).on("click", ".tw", Share.twitter) - setTimeout(function(){ - window.fbAsyncInit = function() { - FB.init({ - appId : '643786815755427', - xfbml : true, - version : 'v2.3' - }); - }; - - (function(d, s, id){ - var js, fjs = d.getElementsByTagName(s)[0]; - if (d.getElementById(id)) {return;} - js = d.createElement(s); js.id = id; - js.src = "//connect.facebook.net/en_US/sdk.js"; - fjs.parentNode.insertBefore(js, fjs); - }(document, 'script', 'facebook-jssdk')); - }, 1000) - }, - - facebook: function (e) { - e.preventDefault() - // var link = window.location.href - // var msg = $(".postname").html() - // var url = "https://www.facebook.com/share.php?u=" + encodeURIComponent(link) + "&t=" + encodeURIComponent(msg) - // window.open(url, "_blank") - - var picture = $(".gallery img").first().attr("src") || ($(".gallery .underlay").css('background-image') || "").replace("url(","").replace(")","") || "http://twohustlers.com/assets/images/2H_LOGOMARK.png" - FB.ui({ - method: 'feed', - link: window.location.href, - caption: $(".postname").html(), - picture: picture, - }, function(response){}); - }, - - twitter: function (e) { - e.preventDefault() - var link = window.location.href - var msg = $(".postname").html() - var url = "https://twitter.com/home?status=" + encodeURIComponent(msg + " " + link) - window.open(url, "_blank") - }, -} \ No newline at end of file diff --git a/site/public/assets/javascripts/app.js b/site/public/assets/javascripts/app.js deleted file mode 100644 index 4e00f30..0000000 --- a/site/public/assets/javascripts/app.js +++ /dev/null @@ -1,92 +0,0 @@ - -if (is_mobile) { - $("html").addClass("mobile") -} -else { - $("html").addClass("desktop") -} - - -var scene, cam, map; - -var app = new function(){} - -app.mode = { editor: false, builder: false } - -app.init = function () { - app.launch() -} - -app.launch = function () { - // if ($.browser.msie || ! has3d()) { return app.fallback() } - if ($.browser.msie) { - $("html").addClass("msie") - } - else { - $("html").addClass("notmsie") - } - - scene = new MX.Scene().addTo('#scene') - - $(window).resize(app.resize) - app.resize() - - cam = scene.camera - - var last_t = 0 - function animate (t) { - var dt = t - last_t - last_t = t - requestAnimationFrame(animate) - environment.update(t) - // app.movements.update(dt || 0) - } - - FastClick.attach(document.body) - - window.environment && window.environment.init() - animate() - - window.scrollTo(0,0) -} - -app.resize = function () { - scene.width = window.innerWidth - scene.height = window.innerHeight - scene.perspective = min(window.innerWidth, scene.height) - scene.update() -} - -app.fallback = function(){ - app.unsupported = true - var msg = "Sorry, your browser is not supported.

" + - "Please use Chrome or Safari or Firefox." - var $fallback = $("
") - $fallback.attr('id', 'fallback') - $fallback.html(msg) - $('body').append($fallback) -} - -app.on = function(){ - app.tube.on.apply(app.tube, arguments) -} - -app.off = function(){ - app.tube.off.apply(app.tube, arguments) -} - -app.position = function(obj){ - var pos = { - x: obj.x, - y: obj.y, - z: obj.z, - rotationX: obj.rotationX, - rotationY: obj.rotationY - } - if (obj.scale !== 1) { - pos.scale = obj.scale - } - return pos -} - -document.addEventListener('DOMContentLoaded', app.init) diff --git a/site/public/assets/javascripts/mx/extensions/mx.movements.js b/site/public/assets/javascripts/mx/extensions/mx.movements.js deleted file mode 100644 index 9af2c8d..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.movements.js +++ /dev/null @@ -1,367 +0,0 @@ - - -MX.Movements = function (cam) { - - var moveForward, - moveLeft, - moveBackward, - moveRight, - moveUp, - moveDown, - turnLeft, - turnRight, - turnUp, - turnDown, - jumping = false, - creeping = false, - locked = false, - gravity = false, - rotationX_min = PI/-4, - rotationX_max = PI/6 - - var v = 12, - vr = Math.PI * 0.012, - jumpV = 23, - vx = vy = vz = 0, - creepFactor = 0.3 - - var mouseX, mouseY, dx, dy, rotX, rotY, dragging = false - - var trackpad - - var DEFAULT_SCALE = 1.0, scale = DEFAULT_SCALE - - var pos = { x: 0, y: 0, z: 0, rotationX: 0, rotationY: 0 } - - $(document).one("keydown", function(){ - $("#keyhint").fadeOut(250); - $('.reader #minimap').addClass('active'); - }) - - function clampRotation( vr ) { - if (Rooms.mover.noclip) { - return clamp(vr, PI/-2, PI/2 ) - } - else { - return clamp(vr, PI/-4, PI/6 ) - } - } - - var exports = { - - init: function () { - - trackpad = new wheel ({ - el: scene.el, - update: exports.mousewheel, - }) - - document.addEventListener('keydown', exports.keydown) - document.addEventListener('keyup', exports.keyup) - document.addEventListener('mousedown', exports.mousedown) - document.addEventListener('mousemove', exports.mousemove) - document.addEventListener('mouseup', exports.mouseup) - window.addEventListener('blur', exports.reset) - window.addEventListener('focus', exports.reset) - }, - - keydown: function (e) { - // console.log(e.keyCode) - if (locked || e.altKey || e.metaKey || e.ctrlKey) { - return - } - switch ( e.keyCode ) { - - case 16: // shift - creeping = true - break - - case 38: // up - case 87: // w - moveForward = true - break - - case 65: // a - moveLeft = true - break - - case 40: // down - case 83: // s - moveBackward = true - break - - case 68: // d - moveRight = true - break - - case 37: // left - case 81: // q - turnLeft = true - break - - case 39: // right - case 69: // e - turnRight = true - break - - case 82: // r - turnUp = true - break - - case 70: // f - turnDown = true - break - - case 32: // space - if (gravity) { - jumping = true - vy = abs(vy) + jumpV * scale - if (e.shiftKey) { - vy *= -1 - } - } - else { - if (e.shiftKey) { - moveDown = true - } - else { - moveUp = true - } - } - break - - case 27: // esc - if (Scenery.nextMedia) { - Scenery.nextMedia = null - app.tube('cancel-scenery') - } - else if (Scenery.nextWallpaper) { - Scenery.nextWallpaper = null - app.tube('cancel-wallpaper') - } - else if (app.controller.mediaViewer && app.controller.mediaViewer.$el.hasClass("active")) { - app.controller.mediaViewer.hide() - $(".inuse").removeClass("inuse") - } - else if (app.controller.colorControl && app.controller.colorControl.$el.hasClass('active')) { - app.controller.colorControl.hide() - $(".inuse").removeClass("inuse") - } - else if (app.controller.wallpaperPicker && app.controller.wallpaperPicker.$el.hasClass('active')) { - app.controller.wallpaperPicker.hide() - $(".inuse").removeClass("inuse") - } - else if (app.controller.presets && app.controller.presets.$el.hasClass('active')) { - app.controller.presets.hide() - $(".inuse").removeClass("inuse") - } - else { - app.controller.toolbar.toggleMap() - } - break - - case 8: // backspace - e.preventDefault() - if (app.controller.mediaEditor.scenery) { - app.controller.mediaEditor.scenery.remove() - } - else if (app.controller.textEditor.scenery) { - app.controller.textEditor.scenery.remove() - } - } - }, - - keyup: function (e) { - if (locked) return; - switch ( e.keyCode ) { - - case 16: // shift - creeping = false - break - - case 38: // up - case 87: // w - moveForward = false - break - - case 65: // a - moveLeft = false - break - - case 40: // down - case 83: // s - moveBackward = false - break - - case 68: // d - moveRight = false - break - - case 37: // left - case 81: // q - turnLeft = false - break - - case 39: // right - case 69: // e - turnRight = false - break - - case 82: // r - turnUp = false - break - - case 70: // f - turnDown = false - break - - case 32: // space - moveUp = moveDown = false - break - -/* - case 48: // 0 - cam.rotationX = 0 - cam.rotationY = 0 - cam.x = 0 - cam.y = viewHeight - cam.z = 0 - break -*/ - } - }, - - mousedown: function (e) { - if (locked) return; - mouseX = e.pageX - mouseY = e.pageY - rotX = cam.rotationX - rotY = cam.rotationY - dragging = true - }, - - mousemove: function (e) { - if (locked || ! dragging) return - var dx = (e.pageX - mouseX) / window.innerWidth * Math.PI/3 - var dy = (e.pageY - mouseY) / window.innerHeight * Math.PI/3 - cam.rotationY = rotY + dx - cam.rotationX = clampRotation( rotX - dy ) - }, - - mouseup: function (e) { - dragging = false - }, - - reset: function(){ - moveForward = moveLeft = moveBackward = moveRight = moveUp = moveDown = turnLeft = turnRight = jumping = dragging = creeping = false - }, - - mousewheel: function (e, deltaY, deltaX) { - if (e.shiftKey) { - cam.rotationY -= deltaY / 150 - } - else { - pos.x += deltaY * Math.cos(cam.rotationY + Math.PI / 2) * 10 - pos.z += deltaY * Math.sin(cam.rotationY + Math.PI / 2) * 10 - app.tube("move", pos) - } - }, - - update: function (dt) { - - if (locked) { return } - - var ry = cam.rotationY - var s = creeping ? scale * creepFactor : scale - var vrrrr = creeping ? vr * creepFactor * 5 : vr * 0.5 - var moving = moveForward || moveBackward || moveRight || moveLeft || moveUp || moveDown || turnLeft || turnRight || turnUp || turnDown - vx = vz = 0 - - var vv = v -// vv *= dt / 100 * 8 -// s *= dt / 100 * 8 -// console.log(dt / 100 * 8) - - pos.x = cam.x - pos.z = cam.z - - if (moving) { - - if (moveForward) { - vx += vv * Math.cos(ry + Math.PI / 2) * s - vz += vv * Math.sin(ry + Math.PI / 2) * s - } - if (moveBackward) { - vx -= vv * Math.cos(ry + Math.PI / 2) * s - vz -= vv * Math.sin(ry + Math.PI / 2) * s - } - if (moveLeft) { - vx -= vv * Math.cos(ry) * s - vz -= vv * Math.sin(ry) * s - } - if (moveRight) { - vx += vv * Math.cos(ry) * s - vz += vv * Math.sin(ry) * s - } - if (moveUp) { - pos.y += vv * scale - } - if (moveDown) { - pos.y -= vv * scale - } - - if (turnUp) { - cam.rotationX = clampRotation( cam.rotationX - vrrrr*s ) - } - if (turnDown) { - cam.rotationX = clampRotation( cam.rotationX + vrrrr*s ) - } - if (turnLeft) { - cam.rotationY += vrrrr*s - } - if (turnRight) { - cam.rotationY -= vrrrr*s - } - - pos.x += vx - pos.z += vz - } - - if (gravity) { - vy -= 1 * scale - - pos.y += vy - - if (vy) { - moving = true - } - if (pos.y <= viewHeight) { - pos.y = viewHeight - vy = 0 - jumping = false - } - - var ceiling = (Rooms.mover.room ? Rooms.mover.room.height : 5000) - - if (pos.y >= ceiling-5) { - vy = 0 - pos.y = ceiling-5 - } - } - - if (moving) { - app.tube("move", pos) - } - }, - - lock: function(){ locked = true }, - unlock: function(){ locked = false }, - scale: function(n){ if (n) scale = n; return scale }, - resetScale: function(n){ scale = DEFAULT_SCALE }, - gravity: function(g){ return typeof g == "boolean" ? gravity = g : gravity }, - velocity: function(n){ v = clamp(n, 1, 50) }, - jumpVelocity: function(n){ jumpV = clamp(n, 1, 50) }, - } - - return exports -} diff --git a/site/public/assets/javascripts/mx/extensions/mx.movementsMobile.js b/site/public/assets/javascripts/mx/extensions/mx.movementsMobile.js deleted file mode 100644 index 95b61d1..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.movementsMobile.js +++ /dev/null @@ -1,237 +0,0 @@ - -MX.MobileMovements = function (cam) { - - var touching = true, - moving = false, - startTime = null, - v = 12, - vr = Math.PI * 0.012, - vx = vy = vz = 0; - - var directionLocked = false, - directionLockThreshold = 5 - - var pos = { x: 0, y: viewHeight, z: 0, rotationX: 0, rotationY: 0 } - - var pointX, pointY, deltaX, deltaY, distX = 0, distY = 0, absDistX = 0, absDistY = 0, startTime - - var rotationX = 0, rotationY = 0, destRotationX = 0, destRotationY = 0 - var rotationSum = 0 - var rotationMedian = 0 - var orientationMax = 0 - var samples = 0 - var sampleThreshold = 120 - var lastAlpha - - var is_portrait - - var exports = { - - init: function () { - exports.orientationchange() - - document.addEventListener("touchstart", exports.touchstart) - document.addEventListener("touchmove", exports.touchmove) - document.addEventListener("touchend", exports.touchend) - window.addEventListener('orientationchange', exports.orientationchange) - window.addEventListener("devicemotion", exports.devicemotion) - window.addEventListener("deviceorientation", exports.deviceorientation) - }, - touchstart: function(e){ - if (e.touches.length == 1) { - touching = true - - startTime = Date.now() - - var point = event.touches[0] - pointX = point.pageX - pointY = point.pageY - distX = distY = 0 - pos.x = cam.x - pos.z = cam.z - pos.rotationY = cam.rotationY - } - }, - touchmove: function(e){ - e.preventDefault() - if (e.touches.length == 1) { - - var timestamp = Date.now() - var point = event.touches[0] - deltaX = point.pageX - pointX - deltaY = point.pageY - pointY - - pointX = point.pageX - pointY = point.pageY - - distX += deltaX - distY += deltaY - absDistX = abs(distX) - absDistY = abs(distY) - } - }, - touchend: function(e){ - e.preventDefault() - if (e.touches.length == 0) { - touching = directionLocked = false - var timestamp = Date.now() - var duration = startTime - timestamp - if (duration < 300) { - } - } - }, - orientationchange: function(e){ - is_portrait = window.innerWidth < window.innerHeight - if (is_portrait) { - lastAlpha = 0 - } - }, - devicemotion: function(e) { - if (! is_portrait) return; - var rotationBeta = e.rotationRate.alpha; // weird! - rotationSum += rotationBeta; - samples += 1; - }, - deviceorientation: function (e) { - if (! lastAlpha) { lastAlpha = e.alpha } - is_portrait ? exports.portraitorientation(e) : exports.landscapeorientation(e) - }, - portraitorientation: function(e) { - // compass gives most accurate orientation in portrait mode - var alpha, dx = 0, dy = 0 - - if (e.webkitCompassHeading) { - alpha = 180 - e.webkitCompassHeading; - } - else { - alpha = 180 - e.alpha; - } - - // android rotates in reverse - if (is_android) { - alpha = 360 - alpha - } - - // use rotationRate to gauge if we've tilted the screen past vertical - // for looking at ceiling - if (e.beta > orientationMax) { - orientationMax = e.beta - rotationMedian = rotationSum - } - - // this number was only going to 83 max.. not 90.. weird - var beta = e.beta + 7; - - // if we've got enough motion data, we should be able to determine - // if we've tilted backwards. otherwise, lock to the horizon. - if (! is_android && samples > sampleThreshold) { - dx = rotationSum > rotationMedian ? e.beta - 90 : 90 - e.beta - } - else { - dx = 0 - } - - // avoid jumping around in a circle - if (Math.abs(alpha - lastAlpha) < 100 || Math.abs(alpha - lastAlpha) > 300) { - dy = alpha - lastAlpha - lastAlpha = alpha - } - - // avoid jumping around in a circle #2 - if (dy > 300) { - dy -= 360 - } else if (dy < -300) { - dy += 360 - } - - destRotationX = MX.toRad(dx) - destRotationY += MX.toRad(dy) - }, - - landscapeorientation: function (e) { - var dx, dy - - dx = e.gamma > 0 ? 90 - e.gamma : 90 + e.gamma - dy = e.alpha - lastAlpha - lastAlpha = e.alpha - - // avoid the sudden jump from 0 to -360 - if (dy > 300) { - dy -= 360 - } - else if (dy < -300) { - dy += 360 - } - - destRotationX = dx > 45 ? 0 : MX.toRad(dx) - destRotationY += MX.toRad(dy) - }, - - update: function () { - var drx, dry - - dry = (destRotationY - rotationY) / 6 - drx = (destRotationX - rotationX) / 6 - rotationY += dry - rotationX += drx - cam.rotationY = pos.rotationY += dry - cam.rotationX = pos.rotationX += drx - - if (distX || distY) { - var oldDistY = absDistY, oldDistX = absDistX - absDistY = avg(absDistY, 0, 5) - var dy = (oldDistY - absDistY) * sign(distY) * 2 - - absDistX = avg(absDistX, 0, 5) - var dx = (oldDistX - absDistX) * sign(distX) * 2 - - distY = sign(distY) * absDistY - distX = sign(distX) * absDistX - - pos.x -= dy * Math.cos(pos.rotationY + Math.PI / 2) - pos.z -= dy * Math.sin(pos.rotationY + Math.PI / 2) - cam.rotationY = pos.rotationY += dx / (window.innerWidth) * Math.PI / 2 - - app.tube("move", pos) - } - }, - - lock: function(){ locked = true }, - unlock: function(){ locked = false }, - scale: function(n){ if (n) scale = n; return scale }, - resetScale: function(n){ scale = DEFAULT_SCALE }, - gravity: function(g){ return typeof g == "boolean" ? gravity = g : gravity }, - velocity: function(n){ v = clamp(n, 1, 50) }, - jumpVelocity: function(n){ jumpV = clamp(n, 1, 50) }, - } - - return exports -} - - -// function momentum (current, start, time, lowerMargin, wrapperSize, deceleration) { -// var distance = current - start, -// speed = Math.abs(distance) / time, -// destination, -// duration; -// -// deceleration = deceleration === undefined ? 0.0006 : deceleration; -// -// destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); -// duration = speed / deceleration; -// -// if ( destination < lowerMargin ) { -// destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin; -// distance = Math.abs(destination - current); -// duration = distance / speed; -// } else if ( destination > 0 ) { -// destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0; -// distance = Math.abs(current) + destination; -// duration = distance / speed; -// } -// -// return { -// destination: Math.round(destination), -// duration: duration -// }; -// } diff --git a/site/public/assets/javascripts/mx/extensions/mx.orbitCamera.js b/site/public/assets/javascripts/mx/extensions/mx.orbitCamera.js deleted file mode 100644 index 6603ff4..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.orbitCamera.js +++ /dev/null @@ -1,102 +0,0 @@ -MX.OrbitCamera = function(opt){ - var exports = {}, bound = false - exports.opt = opt = defaults(opt, { - el: window, // object to bind events on - camera: scene.camera, // camera object we'll be moving - radius: 100, - radiusRange: [ 10, 1000 ], - rotationX: PI/2, - rotationY: 0, - center: { x: 0, y: 0, z: 0 }, - sensitivity: 10, // moving 1 pixel is like moving N radians - wheelSensitivity: 10, - ease: 10, - }) - var rx, ry, radius, px, py, epsilon = 1e-10, dragging = false - exports.init = function(){ - ry = opt.rotationY - rx = opt.rotationX - radius = opt.radius - exports.wheel = new wheel({ - el: opt.el, - update: function(e, delta){ - opt.radius = clamp( opt.radius + delta * opt.wheelSensitivity, opt.radiusRange[0], opt.radiusRange[1] ) - }, - }) - exports.bind() - } - exports.toggle = function(state){ - if (state) exports.bind() - else exports.unbind() - } - exports.bind = function(){ - if (bound) return; - bound = true - opt.el.addEventListener("mousedown", down) - window.addEventListener("mousemove", move) - window.addEventListener("mouseup", up) - exports.wheel.unlock() - } - exports.unbind = function(){ - if (! bound) return; - bound = false - opt.el.removeEventListener("mousedown", down) - window.removeEventListener("mousemove", move) - window.removeEventListener("mouseup", up) - exports.wheel.lock() - } - function down (e) { - px = e.pageX - py = e.pageY - dragging = true - } - function move (e) { - if (! dragging) return - exports.delta(px- e.pageX, py - e.pageY) - px = e.pageX - py = e.pageY - } - function up (e) { - dragging = false - } - exports.delta = function(x,y){ - opt.rotationY += x/window.innerWidth * opt.sensitivity - opt.rotationX = clamp( opt.rotationX + y/window.innerHeight * opt.sensitivity, 0, PI) - } - exports.zoom = function(r){ - opt.radius = r - } - exports.zoomDelta = function(r){ - opt.radius += r - } - exports.move = function(y, x){ - opt.rotationY = y - if (typeof x == "number") { opt.rotationX = x } - } - exports.update = function(){ - if (abs(ry - opt.rotationY) > epsilon) { - ry = avg(ry, opt.rotationY, opt.ease) - } - else { - ry = opt.rotationY - } - if (abs(rx - opt.rotationX) > epsilon) { - rx = avg(rx, opt.rotationX, opt.ease) - } - else { - rx = opt.rotationX - } - if (abs(radius - opt.radius) > epsilon) { - radius = avg(radius, opt.radius, opt.ease) - } - else { - radius = opt.radius - } - opt.camera.x = opt.center.x + radius * sin(rx) * cos(ry) - opt.camera.z = opt.center.y + radius * sin(rx) * sin(ry) - opt.camera.y = opt.center.z + radius * cos(rx) - opt.camera.rotationX = PI/2 - rx - opt.camera.rotationY = ry + PI/2 - } - return exports -} diff --git a/site/public/assets/javascripts/mx/extensions/mx.rotationControl.js b/site/public/assets/javascripts/mx/extensions/mx.rotationControl.js deleted file mode 100644 index 9adb627..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.rotationControl.js +++ /dev/null @@ -1,265 +0,0 @@ -// Usage: -// -// var control = new MX.RotationControl() -// control.init( object{MX.Object3D} [, listener{HTMLElement}] ) -// -// In animation loop: -// -// control.update() -// -// The above code will register handler functions on `listener` -// and will be updating `object`s rotationX and rotationY -// If no `listener` is provided, will default to `object`s el. - -MX.RotationControl = function () { - - var object, - locked = false - - var down = false, - active = false, - lastX, - lastY - - var pointerLockPrefix = - 'pointerLockElement' in document ? '' : - 'mozPointerLockElement' in document ? 'moz' : - 'webkitPointerLockElement' in document ? 'webkit' : null, - hasPointerLock = !(pointerLockPrefix === null) - pointerLockEnabled = false - - var pub = { - - sensitivity : .5, - ease : 10, - drag : true, - - inverseX : false, - inverseY : false, - - disableX : false, - disableY : false, - - rotationX : 0, - rotationY : 0, - - upperBoundX : undefined, - lowerBoundX : undefined, - - upperBoundY : undefined, - lowerBoundY : undefined, - - usePreset: function (name) { - var ops = presets[name] - if (ops) { - if (currentPreset && presets[currentPreset].teardown) { - presets[currentPreset].teardown() - } - for (var op in ops) { - if (op !== 'setup' && op !== 'teardown') { - pub[op] = ops[op] - } - } - if (op.setup) ops.setup() - } - } - } - - var currentPreset - var presets = { - firstPerson: { - drag: false, - ease: 2, - sensitivity: .18, - inverseX: true, - inverseY: true, - upperBoundX: MX.rotationUnit === 'deg' ? 90 : Math.PI / 2, - lowerBoundX: MX.rotationUnit === 'deg' ? -90 : -Math.PI / 2 - }, - skybox: { - sensitivity: .18, - inverseX: true, - inverseY: true, - upperBoundX: MX.rotationUnit === 'deg' ? 90 : Math.PI / 2, - lowerBoundX: MX.rotationUnit === 'deg' ? -90 : -Math.PI / 2 - } - } - - function init (obj, lis) { - if (active) return - - object = obj - pub.rotationX = object.rotationX - pub.rotationY = object.rotationY - - if (lis instanceof HTMLElement) { - listener = lis - } else if (lis instanceof MX.Object3D) { - listener = lis.el - } else { - listener = window.document - } - - listener.addEventListener('mousedown', onDown) - listener.addEventListener('mousemove', onMove) - listener.addEventListener('mouseup', onUp) - listener.addEventListener('touchstart', onDown) - listener.addEventListener('touchmove', onMove) - listener.addEventListener('touchend', onUp) - - active = true - } - - function changeObject (obj) { - object = obj - pub.rotationX = object.rotationX - pub.rotationY = object.rotationY - } - - function changeListener (lis) { - remove() - active = false - init(object, lis) - if (pointerLockEnabled) { - initPointerLock() - } - } - - function remove () { - if (!active) return - listener.removeEventListener('mousedown', onDown) - listener.removeEventListener('mousemove', onMove) - listener.removeEventListener('mouseup', onUp) - listener.removeEventListener('touchstart', onDown) - listener.removeEventListener('touchmove', onMove) - listener.removeEventListener('touchend', onUp) - - if (hasPointerLock) { - document.removeEventListener(pointerLockPrefix + 'pointerlockchange', onPointerLockChange) - document.removeEventListener('mousemove', onPointerLockMove) - document.body[pointerLockPrefix + (pointerLockPrefix ? 'E' : 'e') + 'xitPointerLock']() - } - active = false - } - - function onDown (e) { - e = normalizeEvent(e) - if (!e) return - down = true - lastX = e.pageX - lastY = e.pageY - } - - function onMove (e) { - if (e.type = 'touchmove') { - e.preventDefault() - } - if (pub.drag && !down) return - e = normalizeEvent(e) - if (!e) return - lastX = lastX || e.pageX - lastY = lastY || e.pageY - var dx = e.pageX - lastX, - dy = e.pageY - lastY - lastX = e.pageX - lastY = e.pageY - updateTarget(dx, dy) - } - - function onUp () { - down = false - } - - function initPointerLock () { - - if (pointerLockEnabled) return - - document.addEventListener(pointerLockPrefix + 'pointerlockchange', onPointerLockChange) - document.addEventListener('mousemove', onPointerLockMove) - - document.body[pointerLockPrefix + (pointerLockPrefix ? 'R' : 'r') + 'equestPointerLock']() - } - - function onPointerLockChange () { - var el = document.body - if (document[pointerLockPrefix + (pointerLockPrefix ? 'P' : 'p') + 'ointerLockElement'] === el) { - pointerLockEnabled = true - } else { - pointerLockEnabled = false - } - } - - function onPointerLockMove (e) { - if (!pointerLockEnabled) return - var dx = e[pointerLockPrefix + (pointerLockPrefix ? 'M' : 'm') + 'ovementX'], - dy = e[pointerLockPrefix + (pointerLockPrefix ? 'M' : 'm') + 'ovementY'] - updateTarget(dx, dy) - } - - function normalizeEvent (e) { - if (e.touches) { - return e.touches.length > 1 ? false : e.touches[0] - } else { - return e - } - } - - function updateTarget (dx, dy) { - if (pub.inverseX) dx = -dx - if (pub.inverseY) dy = -dy - if (MX.rotationUnit !== 'deg') { - dx = MX.toRad(dx) - dy = MX.toRad(dy) - } - - if (!pub.disableX) { - pub.rotationX -= dy * pub.sensitivity - if (pub.upperBoundX) pub.rotationX = Math.min(pub.rotationX, pub.upperBoundX) - if (pub.lowerBoundX) pub.rotationX = Math.max(pub.rotationX, pub.lowerBoundX) - } - - if (!pub.disableY) { - pub.rotationY += dx * pub.sensitivity - if (pub.upperBoundY) pub.rotationY = Math.min(pub.rotationY, pub.upperBoundY) - if (pub.lowerBoundY) pub.rotationY = Math.max(pub.rotationY, pub.lowerBoundY) - } - } - - function update () { - if (!object || locked) return - var dx = pub.rotationX - object.rotationX, - dy = pub.rotationY - object.rotationY - if (Math.abs(dx) < 0.0001) { - object.rotationX = pub.rotationX - } else { - object.rotationX += dx / pub.ease - } - if (Math.abs(dy) < 0.0001) { - object.rotationY = pub.rotationY - } else { - object.rotationY += dy / pub.ease - } - } - - function lock () { - locked = true - } - - function unlock () { - pub.rotationX = object.rotationX - pub.rotationY = object.rotationY - locked = false - } - - pub.init = init - pub.remove = remove - pub.update = update - pub.lock = lock - pub.unlock = unlock - pub.initPointerLock = initPointerLock - pub.changeObject = changeObject - pub.changeListener = changeListener - - return pub - -} \ No newline at end of file diff --git a/site/public/assets/javascripts/mx/extensions/mx.scene.js b/site/public/assets/javascripts/mx/extensions/mx.scene.js deleted file mode 100644 index 8f11fb0..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.scene.js +++ /dev/null @@ -1,165 +0,0 @@ -// NOTE -// -// This is not a fully functional 3d scene as you might expect. -// The camera can only do pitch (rotationX) and yaw (rotationY), but no roll (rotationZ) -// because I haven't implemented alternative euler orders or quaternions. -// -// For serious 3D scenes with more functionalities you should use -// THREE.js with CSS3D Renderer. - -MX.Camera = MX.Object3D.extend({ - - init: function(){ - this.el = null - this.type = "Camera" - }, - - move: function(s){ - for (var i in s) { - this[i] = s[i] - } - }, - - toString: function(){ - var params = "x y z rotationX rotationY".split(" ") - return this.__toString(params, "scene.camera.move") - }, - - getCameraEuler: function (target) { - var dx = target.x - this.x, - dy = target.y - this.y, - dz = target.z - this.z - r = {} - r.y = Math.atan2(-dx, dz) - r.x = Math.atan2(-dy, Math.sqrt(dx*dx + dz*dz)) - r.z = 0 - if (MX.rotationUnit === 'deg') { - r.x = MX.toDeg(r.x) - r.y = MX.toDeg(r.y) - } - return r - } - -}) - -MX.Scene = (function () { - - var add = MX.Object3D.prototype.add, - remove = MX.Object3D.prototype.remove - - function Scene () { - - this.el = document.createElement('div') - this.el.classList.add('mx-scene') - - var s = this.el.style - - s[MX.transformProp] = 'preserve-3d' - - s.webkitPerspectiveOrigin = '50% 50%' - s.mozPerspectiveOrigin = '50% 50%' - s.perspectiveOrigin = '50% 50%' - - s.webkitUserSelect = 'none' - s.mozUserSelect = 'none' - s.userSelect = 'none' - - s.overflow = 'hidden' - - this.inner = new MX.Object3D().addTo(this.el) - this.inner.el.style.width = '0' - this.inner.el.style.height = '0' - - var self = this - var width, height, perspective - - Object.defineProperty(this, 'width', { - get: function () { - return width - }, - set: function (val) { - width = val - self.el.style.width = val + 'px' - } - }) - - Object.defineProperty(this, 'height', { - get: function () { - return height - }, - set: function (val) { - height = val - self.el.style.height = val + 'px' - } - }) - - Object.defineProperty(this, 'perspective', { - get: function () { - return perspective - }, - set: function (val) { - perspective = val - self.el.style[MX.perspectiveProp] = val + 'px' - self.inner.z = -val - self.camera.z - self.inner.rotationOrigin.z = -val - } - }) - - var cam = this.camera = new MX.Camera() - - this.inner.rotationOrigin = { x:0, y:0, z:0 } - - this.perspective = 0 - } - - Scene.prototype = { - - constructor: Scene, - - add: function () { - add.apply(this.inner, arguments) - return this - }, - - remove: function () { - remove.apply(this.inner, arguments) - return this - }, - - addTo: function (target) { - if (typeof target === 'string') { - target = document.querySelector(target) - } - if (target instanceof HTMLElement && target.appendChild) { - target.appendChild(this.el) - } else { - console.warn('You can only add a Scene to an HTML element.') - } - return this - }, - - update: function () { - // update inner based on camera - - var i = this.inner, - c = this.camera - - c.update() - - i.z = -this.perspective - c.z - i.x = -c.x - i.y = -c.y - - i.rotationX = -c.rotationX - i.rotationY = -c.rotationY - //i.rotationZ = -c.rotationZ - - i.update() - return this - }, - - } - - return Scene - -})() \ No newline at end of file diff --git a/site/public/assets/javascripts/mx/extensions/mx.scrubber.js b/site/public/assets/javascripts/mx/extensions/mx.scrubber.js deleted file mode 100644 index 54612f2..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.scrubber.js +++ /dev/null @@ -1,191 +0,0 @@ -/* - Use the scrollwheel to tween between different points and orientations - - scrubber = new MX.Scrubber(cam, [ - { - position: [0, viewHeight, -1000], - rotation: [0, 0] - }, - { - position: [0, 1000, 1000], - rotation: [0, Math.PI] - }, - { - position: [0, viewHeight, -1000], - rotation: [0, 2*Math.PI] - }, - { - position: [0, viewHeight, -2000], - rotation: [0, 0] - } - ]) - - // in your animate function: - scrubber.update() - -*/ - -MX.Scrubber = function (obj, points) { - - obj = obj || {} - points = points || {} - - var reversible = true, loop = false; - - var total = points.length * 100, - distance = 0 - destination = 0, - last_index = -1, - last_name = null, - locked = false, - point_count = points.length + (loop+0) - - var avg_speed = scroll_avg_speed = 5, - click_avg_speed = 20, - webkit_ratio = 0.02 - - if (points[0].position) { - points.forEach(function(p){ - p.x = p.position[0] - p.y = p.position[1] - p.z = p.position[2] - p.rotationX = p.rotation[0] - p.rotationY = p.rotation[1] - }) - } - - document.addEventListener('touchstart', next, false); - document.addEventListener('mousedown', next, false); - document.addEventListener('mousewheel', onDocumentMouseWheel, false); - document.addEventListener('DOMMouseScroll', onDocumentMouseWheel, false); - function onDocumentMouseWheel (e) { - - if (locked) return - - var delta = 0; - - // WebKit - if ( event.wheelDeltaY ) { - delta -= event.wheelDeltaY * webkit_ratio - } - // Opera / Explorer 9 - else if ( event.wheelDelta ) { - delta -= event.wheelDelta * webkit_ratio - } - // Firefox - else if ( event.detail ) { - delta += event.detail * 2 - } - if (! reversible && delta < 0) return; - - if (destination < total-100 || delta < 0) { - e.preventDefault() - } - else { - return - } - - destination += delta - - avg_speed = scroll_avg_speed - } - - function add_point(point){ - if (point.type == "Camera") { - point = { - position: [ point.x, point.y, point.z ], - rotation: [ point.rotationX, point.rotationY ], - callback: noop - } - } - points.push(point) - total = points.length * 100 - } - - function reset(){ - distance = destination = 0 - last_index = -1 - last_name = null - } - - function next(){ - destination = ~~(destination/100) * 100 - destination += 100 - avg_speed = click_avg_speed - } - - function update(){ - if (locked) return - - if (destination > total-100) destination = total-100 - - distance = avg(distance, destination, avg_speed) - var ratio = distance / total - - if (! loop) { - if (ratio < 0) { - destination = 0 - ratio = 0 - } - else if (ratio > 1) { - destination = total - ratio = 1 - } - } - - var diff = ratio * point_count - var step = (distance % 100) / 100 - var src = ~~clamp(diff, 0, point_count-1) - var halfway = ~~clamp(diff + 0.5, 0, point_count-1) - var dest = ~~clamp(diff + 1, 0, point_count-1) - - if (halfway != last_index) { - last_index = halfway - if (points[last_index].name != last_name) { - last_name = points[last_index].name - } - $("#info .active").removeClass("active") - $("#info div[data-name='" + last_name + "']").addClass("active") - points[halfway].callback && points[halfway].callback() - } - - var ry0 = points[src].rotationY - var ry1 = points[dest].rotationY - if (abs(ry0 - ry1) == TWO_PI) { - ry0 = ry1 - } - - obj.x = lerp(step, points[src].x, points[dest].x) - obj.y = lerp(step, points[src].y, points[dest].y) - obj.z = lerp(step, points[src].z, points[dest].z) - obj.rotationX = lerp(step, points[src].rotationX, points[dest].rotationX) - obj.rotationY = lerp(step, ry0, ry1) - if (obj.rotationY > PI) { obj.rotationY -= TWO_PI } - } - - var scrubber = { - init: function(){ - app && app.movements && app.movements.lock() - }, - lock: function(){ - app && app.movements && app.movements.unlock() - locked = true - }, - unlock: function(){ - app && app.movements && app.movements.lock() - locked = false - }, - step: function(n){ - distance = destination = n * 100 - }, - add_point: add_point, - reset: reset, - next: next, - update: update, - - obj: obj, - points: points - } - - return scrubber; -} diff --git a/site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCamera.js b/site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCamera.js deleted file mode 100644 index 28b1aac..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCamera.js +++ /dev/null @@ -1,130 +0,0 @@ -MX.OrbitCamera = function(opt){ - var exports = {}, bound = false - exports.opt = opt = defaults(opt, { - el: window, // object to bind events on - camera: scene.camera, // camera object we'll be moving - radius: 100, - radiusRange: [ 10, 1000 ], - rotationX: PI/2, - rotationY: 0, - center: { x: 0, y: 0, z: 0 }, - sensitivity: 10, // moving 1 pixel is like moving N radians - wheelSensitivity: 10, - ease: 10, - wheelEase: 10, - }) - var rx, ry, radius, px, py, epsilon = 1e-10 - exports.dragging = false - exports.init = function(){ - ry = opt.rotationY - rx = opt.rotationX - radius = opt.radius - exports.wheel = new wheel({ - el: opt.el, - update: function(e, delta){ - opt.radius = clamp( opt.radius + delta * opt.wheelSensitivity, opt.radiusRange[0], opt.radiusRange[1] ) - }, - }) - exports.bind() - } - exports.toggle = function(state){ - if (state) exports.bind() - else exports.unbind() - } - exports.bind = function(){ - if (bound) return; - bound = true - opt.el.addEventListener("mousedown", down) - window.addEventListener("mousemove", move) - window.addEventListener("mouseup", up) - opt.el.addEventListener("touchstart", touch(down)) - window.addEventListener("touchmove", touch(move)) - window.addEventListener("touchend", touch(up)) - exports.wheel.unlock() - } - exports.unbind = function(){ - if (! bound) return; - bound = false - opt.el.removeEventListener("mousedown", down) - window.removeEventListener("mousemove", move) - window.removeEventListener("mouseup", up) - exports.wheel.lock() - } - function cancelable (fn) { - return function(e){ - e.preventDefault() - fn(e) - } - } - function touch (fn){ - return function(e){ - fn(e.touches[0]) - } - } - function down (e) { - px = e.pageX - py = e.pageY - exports.dragging = true - } - function move (e) { - if (! exports.dragging) return - exports.delta(px- e.pageX, py - e.pageY) - px = e.pageX - py = e.pageY - } - function up (e) { - exports.dragging = false - } - exports.delta = function(x,y){ - opt.rotationY += x/window.innerWidth * opt.sensitivity - opt.rotationX = opt.rotationX + y/window.innerHeight * opt.sensitivity - } - exports.move = function(y, x){ - opt.rotationY = y - if (typeof x == "number") { opt.rotationX = x } - } - exports.zoom = function(r){ - opt.radius = r - } - exports.setZoom = function(r){ - radius = opt.radius = r - } - exports.zoomPercent = function(n){ - opt.radius = lerp(n, opt.radiusRange[0], opt.radiusRange[1]) - } - exports.zoomDelta = function(r){ - opt.radius += r - } - exports.pause = function(){ - var sy = sign(opt.rotationY-ry) - var sx = sign(opt.rotationX-rx) - opt.rotationY = ry + sy * 0.1 - opt.rotationX = rx + sx * 0.1 - } - exports.update = function(){ - if (abs(ry - opt.rotationY) > epsilon) { - ry = avg(ry, opt.rotationY, opt.ease) - } - else { - ry = opt.rotationY - } - if (abs(rx - opt.rotationX) > epsilon) { - rx = avg(rx, opt.rotationX, opt.ease) - } - else { - rx = opt.rotationX - } - if (abs(radius - opt.radius) > epsilon) { - radius = avg(radius, opt.radius, opt.wheelEase) - } - else { - radius = opt.radius - } - opt.camera.x = opt.center.x + radius * sin(rx) * cos(ry) - opt.camera.z = opt.center.y + radius * sin(rx) * sin(ry) - opt.camera.y = opt.center.z + radius * cos(rx) - opt.camera.rotationX = PI/2 - rx - opt.camera.rotationY = ry + PI/2 - } - return exports -} diff --git a/site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCameraMobile.js b/site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCameraMobile.js deleted file mode 100644 index 510a002..0000000 --- a/site/public/assets/javascripts/mx/extensions/mx.unclampedOrbitCameraMobile.js +++ /dev/null @@ -1,225 +0,0 @@ -MX.OrbitCameraMobile = function(opt){ - var exports = {}, bound = false - exports.opt = opt = defaults(opt, { - el: window, // object to bind events on - camera: scene.camera, // camera object we'll be moving - radius: 100, - radiusRange: [ 10, 1000 ], - rotationX: PI/2, - rotationY: 0, - center: { x: 0, y: 0, z: 0 }, - sensitivity: 10, // moving 1 pixel is like moving N radians - wheelSensitivity: 10, - ease: 10, - wheelEase: 10, - }) - var rx, ry, radius, px, py, epsilon = 1e-10 - var rotationSum = 0 - var rotationMedian = 0 - var orientationMax = 0 - var samples = 0 - var sampleThreshold = 20 - var lastAlpha - - exports.dragging = false - exports.init = function(){ - ry = opt.rotationY - rx = opt.rotationX - radius = opt.radius - exports.wheel = new wheel({ - el: opt.el, - update: function(e, delta){ - opt.radius = clamp( opt.radius + delta * opt.wheelSensitivity, opt.radiusRange[0], opt.radiusRange[1] ) - }, - }) - exports.bind() - - exports.orientationchange() - } - exports.toggle = function(state){ - if (state) exports.bind() - else exports.unbind() - } - exports.bind = function(){ - if (bound) return; - bound = true - opt.el.addEventListener("touchstart", touch(down)) - window.addEventListener("touchmove", touch(move)) - window.addEventListener("touchend", touch(up)) - - window.addEventListener('orientationchange', exports.orientationchange) - window.addEventListener("devicemotion", exports.devicemotion) - window.addEventListener("deviceorientation", exports.deviceorientation) - - exports.wheel.unlock() - } - exports.unbind = function(){ - if (! bound) return; - bound = false - exports.wheel.lock() - } - function cancelable (fn) { - return function(e){ - e.preventDefault() - fn(e) - } - } - function touch (fn){ - return function(e){ - fn(e.touches[0]) - } - } - function down (e) { - px = e.pageX - py = e.pageY - exports.dragging = true - } - function move (e) { - if (! exports.dragging) return - exports.delta(px- e.pageX, py - e.pageY) - px = e.pageX - py = e.pageY - } - function up (e) { - exports.dragging = false - } - - exports.orientationchange = function(e){ - is_portrait = window.innerWidth < window.innerHeight - if (is_portrait) { - lastAlpha = 0 - } - } - exports.devicemotion = function(e) { - if (! is_portrait) return; - var rotationBeta = e.rotationRate.alpha; // weird! - rotationSum += rotationBeta; - samples += 1; - } - exports.deviceorientation = function (e) { - if (! lastAlpha) { lastAlpha = e.alpha } - is_portrait ? exports.portraitorientation(e) : exports.landscapeorientation(e) - } - exports.portraitorientation = function(e) { - // compass gives most accurate orientation in portrait mode - var alpha, dx = 0, dy = 0 - - if (e.webkitCompassHeading) { - alpha = 180 - e.webkitCompassHeading; - } - else { - alpha = 180 - e.alpha; - } - - // android rotates in reverse - if (is_android) { - alpha = 360 - alpha - } - - // use rotationRate to gauge if we've tilted the screen past vertical - // for looking at ceiling - if (e.beta > orientationMax) { - orientationMax = e.beta - rotationMedian = rotationSum - } - - // this number was only going to 83 max.. not 90.. weird - var beta = e.beta + 7; - - // if we've got enough motion data, we should be able to determine - // if we've tilted backwards. otherwise, lock to the horizon. - if (! is_android && samples > sampleThreshold) { - dx = rotationSum > rotationMedian ? e.beta - 90 : 90 - e.beta - } - else { - dx = 0 - } - - // avoid jumping around in a circle - if (Math.abs(alpha - lastAlpha) < 100 || Math.abs(alpha - lastAlpha) > 300) { - dy = alpha - lastAlpha - lastAlpha = alpha - } - - // avoid jumping around in a circle #2 - if (dy > 300) { - dy -= 360 - } else if (dy < -300) { - dy += 360 - } - opt.rotationX = MX.toRad(dx * -5) - opt.rotationY += MX.toRad(dy * 10) - } - exports.landscapeorientation = function (e) { - var dx, dy - - dx = e.gamma > 0 ? 90 - e.gamma : 90 + e.gamma - dy = e.alpha - lastAlpha - lastAlpha = e.alpha - - // avoid the sudden jump from 0 to -360 - if (dy > 300) { - dy -= 360 - } - else if (dy < -300) { - dy += 360 - } - - opt.rotationX = dx > 45 ? 0 : MX.toRad(dx) - opt.rotationY += MX.toRad(dy) - } - - - exports.delta = function(x,y){ - opt.rotationY += x/window.innerWidth * opt.sensitivity - opt.rotationX = opt.rotationX + y/window.innerHeight * opt.sensitivity - } - exports.move = function(y, x){ - opt.rotationY = y - if (typeof x == "number") { opt.rotationX = x } - } - exports.zoom = function(r){ - opt.radius = r - } - exports.setZoom = function(r){ - radius = opt.radius = r - } - exports.zoomPercent = function(n){ - opt.radius = lerp(n, opt.radiusRange[0], opt.radiusRange[1]) - } - exports.zoomDelta = function(r){ - opt.radius += r - } - exports.pause = function(){ - var sy = sign(opt.rotationY-ry) - var sx = sign(opt.rotationX-rx) - opt.rotationY = ry + sy * 0.1 - opt.rotationX = rx + sx * 0.1 - } - exports.update = function(){ - if (abs(ry - opt.rotationY) > epsilon) { - ry = avg(ry, opt.rotationY, opt.ease) - } - else { - ry = opt.rotationY - } - if (abs(rx - opt.rotationX) > epsilon) { - rx = avg(rx, opt.rotationX, opt.ease) - } - else { - rx = opt.rotationX - } - if (abs(radius - opt.radius) > epsilon) { - radius = avg(radius, opt.radius, opt.wheelEase) - } - else { - radius = opt.radius - } - opt.camera.x = opt.center.x + radius * sin(rx) * cos(ry) - opt.camera.z = opt.center.y + radius * sin(rx) * sin(ry) - opt.camera.y = opt.center.z + radius * cos(rx) - opt.camera.rotationX = PI/2 - rx - opt.camera.rotationY = ry + PI/2 - } - return exports -} diff --git a/site/public/assets/javascripts/mx/mx.js b/site/public/assets/javascripts/mx/mx.js deleted file mode 100644 index 1ce7cda..0000000 --- a/site/public/assets/javascripts/mx/mx.js +++ /dev/null @@ -1,593 +0,0 @@ -/** - * Copyright (C) 2013 by Evan You - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -var MX = MX || (function (undefined) { - - var MX = { - version: '0.1.0', - prefix: undefined, - rotationUnit: 'rad', - } - - var floatPrecision = 5 - - // ======================================================================== - // Setup & Compatibility - // ======================================================================== - - var transformProp, - transitionProp, - transformOriginProp, - transformStyleProp, - perspectiveProp, - transitionEndEvent - - var positionAtCenter = true, // whether to auto center objects - centeringCSS // styles to inject for center positioning - - document.addEventListener('DOMContentLoaded', setup) - - function setup () { - - // sniff prefix - - var s = document.body.style - - MX.prefix = - 'webkitTransform' in s ? 'webkit' : - 'mozTransform' in s ? 'moz' : - 'msTransform' in s ? 'ms' : '' - - transformProp = MX.transformProp = addPrefix('transform') - transitionProp = MX.transitionProp = addPrefix('transition') - transformOriginProp = MX.transformOriginProp = addPrefix('transformOrigin') - transformStyleProp = MX.transformStyleProp = addPrefix('transformStyle') - perspectiveProp = MX.perspectiveProp = addPrefix('perspective') - transitionEndEvent = MX.transitionEndEvent = MX.prefix === 'webkit' ? 'webkitTransitionEnd' : 'transitionend' - - // shiv rAF - - var vendors = ['webkit', 'moz', 'ms'] - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'] - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || - window[vendors[x]+'CancelRequestAnimationFrame'] - } - - // inject centering css - - centeringCSS = document.createElement('style') - centeringCSS.type = 'text/css' - centeringCSS.innerHTML = - '.mx-object3d {' - + 'position: absolute;' - + 'top: 50%;' - + 'left: 50%;}' - injectCenteringCSS() - - window.scrollTo(0,0) - } - - function injectCenteringCSS () { - document.head.appendChild(centeringCSS) - } - - function removeCenteringCSS () { - document.head.removeChild(centeringCSS) - } - - // ======================================================================== - // Utils - // ======================================================================== - - function toDeg (rad) { - return rad / Math.PI * 180 - } - - function toRad (deg) { - return deg / 180 * Math.PI - } - - function buildRotationTranslation (obj) { - - // used when rotationOrigin is set - - var origin = obj.rotationOrigin - if (!origin) { - return - } else { - var dx = origin.x - obj.x, - dy = -(origin.y - obj.y), - dz = -(origin.z - obj.z) - return { - before: 'translate3d(' + dx.toFixed(floatPrecision) +'px,' + dy.toFixed(floatPrecision) + 'px,' + dz.toFixed(floatPrecision) + 'px) ', - after: 'translate3d(' + (-dx).toFixed(floatPrecision) + 'px,' + (-dy).toFixed(floatPrecision) + 'px,' + (-dz).toFixed(floatPrecision) + 'px) ' - } - } - } - - function addPrefix (string) { - if (MX.prefix) { - string = MX.prefix + string.charAt(0).toUpperCase() + string.slice(1) - } - return string - } - - // ======================================================================== - // Base Object3D - // ======================================================================== - - function Object3D (el) { - - this.setupDomElement(el) - this.setCSSTransformStyle('preserve-3d') - this.el.classList.add('mx-object3d') - - this.parent = undefined - this.children = [] - this.updateChildren = true - - this.inverseLookAt = false - - this.persisted = true - - this.reset() - -// this.quaternion = new MX.Quaternion () -// this.quaternion._euler = this - - var width, height, - self = this - - Object.defineProperty(this, 'width', { - get: function () { - return width - || parseInt(self.el.style.width, 10) * app_devicePixelRatio - || 0 - }, - set: function (val) { - width = val - this.el.style.width = (width/app_devicePixelRatio) + 'px' - } - }) - - Object.defineProperty(this, 'height', { - get: function () { - return height - || parseInt(self.el.style.height, 10) * app_devicePixelRatio - || 0 - }, - set: function (val) { - height = val - this.el.style.height = (height/app_devicePixelRatio) + 'px' - } - }) - } - - Object3D.prototype = { - - constructor: Object3D, - - reset: function () { - this.x = this.__x = 0 - this.y = this.__y = 0 - this.z = this.__z = 0 - this.rotationX = this.__rotationX = 0 - this.rotationY = this.__rotationY = 0 - this.rotationZ = this.__rotationZ = 0 - this.scaleX = this.__scaleX = 1 - this.scaleY = this.__scaleY = 1 - this.scaleZ = this.__scaleZ = 1 - this.scale = this.__scale = 1 - this.perspective = this.__perspective = 0 - this.rotationOrigin = undefined - this.followTarget = undefined -// this.quaternion = new MX.Quaternion() - this.dirty = true - this.update() - }, - - setupDomElement: function (el) { - this.el = undefined - if (el instanceof HTMLElement) { - this.el = el - } else if (typeof el === 'string') { - var tag = el.match(/^[^.#\s]*/)[1], - id = el.match(/#[^.#\s]*/), - classes = el.match(/\.[^.#\s]*/g) - this.el = document.createElement(tag || 'div') - if (id) { - this.el.id = id[0].slice(1) - } - if (classes) { - var i = classes.length - while (i--) { - this.el.classList.add(classes[i].slice(1)) - } - } - } else { - this.el = document.createElement('div') - } - }, - - update: function () { - - if (this.updateChildren) { - var i = this.children.length - while (i--) { - this.children[i].update() - } - } - - if (this.followTarget) { - this.lookAt(this.followTarget, false) - } - - if (this.scaleX !== this.__scaleX || - this.scaleY !== this.__scaleY || - this.scaleZ !== this.__scaleZ) { - this.__scaleX = this.scaleX - this.__scaleY = this.scaleY - this.__scaleZ = this.scaleZ - this.dirty = true - } - - if (this.scale !== this.__scale) { - this.scaleX = - this.scaleY = - this.scaleZ = - this.__scaleX = - this.__scaleY = - this.__scaleZ = - this.__scale = - this.scale - this.dirty = true - } - - if (this.rotationX !== this.__rotationX || - this.rotationY !== this.__rotationY || - this.rotationZ !== this.__rotationZ) { - this.__rotationX = this.rotationX - this.__rotationY = this.rotationY - this.__rotationZ = this.rotationZ - this.dirty = true - } - - if (this.x !== this.__x || - this.y !== this.__y || - this.z !== this.__z) { - this.__x = this.x - this.__y = this.y - this.__z = this.z - this.dirty = true - } - - if (this.perspective !== this.__perspective) { - this.__perspective = this.perspective - this.dirty = true - } - - if (this.dirty && this.el) { - - var rotationTranslation = buildRotationTranslation(this), - rotation = 'rotateX(' + this.rotationX.toFixed(floatPrecision) + MX.rotationUnit + ') ' - + 'rotateY(' + this.rotationY.toFixed(floatPrecision) + MX.rotationUnit + ') ' - + 'rotateZ(' + this.rotationZ.toFixed(floatPrecision) + MX.rotationUnit + ') ' - - var transformString = - (MX.positionAtCenter ? 'translate3d(-50%, -50%, 0) ' : '') - + (this.perspective ? 'perspective(' + this.perspective + 'px) ' : '') - + 'translate3d(' - + this.x.toFixed(floatPrecision || 0) + 'px,' - + (-this.y).toFixed(floatPrecision) + 'px,' - + (-this.z).toFixed(floatPrecision) + 'px) ' - + 'scale3d(' - + (app_devicePixelRatio * this.scaleX).toFixed(floatPrecision) + ',' - + (app_devicePixelRatio * this.scaleY).toFixed(floatPrecision) + ',' - + (app_devicePixelRatio * this.scaleZ).toFixed(floatPrecision) + ') ' - - if (rotationTranslation) { - transformString += rotationTranslation.before - + rotation - + rotationTranslation.after - - } else { - transformString += rotation - } - - this.el.style[transformProp] = transformString - this.dirty = false - } - - return this - - }, - - // taken from three.js - setFromQuaternion: function ( q, order, update ) { - // q is assumed to be normalized - - // http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m - - var sqx = q.x * q.x; - var sqy = q.y * q.y; - var sqz = q.z * q.z; - var sqw = q.w * q.w; - - this.rotationX = Math.atan2( 2 * ( q.x * q.w - q.y * q.z ), ( sqw - sqx - sqy + sqz ) ); - this.rotationY = Math.asin( clamp( 2 * ( q.x * q.z + q.y * q.w ), -1, 1 ) ); - this.rotationZ = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw + sqx - sqy - sqz ) ); - }, - - lookAt: function (target, update) { - var r = this.getLookAtEuler(target) - this.setRotation(r) - if (update !== false) this.update() - return this - }, - - getLookAtEuler: function (target) { - // euler order XYZ - var r = {}, - dx = target.x - this.x, - dy = target.y - this.y, - dz = target.z - this.z - if (this.inverseLookAt) { - dx = -dx - dy = -dy - dz = -dz - } - if (dz === 0) dz = 0.001 - r.x = -Math.atan2(dy, dz) - var flip = dz > 0 ? 1 : -1 - r.y = flip * Math.atan2(dx * Math.cos(r.x), dz * -flip) - r.z = Math.atan2(Math.cos(r.x), Math.sin(r.x) * Math.sin(r.y)) - Math.PI / 2 - if (MX.rotationUnit === 'deg') { - r.x = toDeg(r.x) - r.y = toDeg(r.y) - r.z = toDeg(r.z) - } - return r - }, - - add: function () { - if (!this.el) return - var parent = this - Array.prototype.forEach.call(arguments, function (child) { - if (!child instanceof Object3D) return - parent.el.appendChild(child.el) - if (!parent.children) parent.children = [] - parent.children.push(child) - child.parent = parent - }) - return this - }, - - remove: function () { - var parent = this - Array.prototype.forEach.call(arguments, function (child) { - var index = parent.children.indexOf(child) - if (index !== -1) { - parent.children.splice(index, 1) - parent.el.removeChild(child.el) - child.parent = undefined - } - }) - return this - }, - - addTo: function (target) { - if (typeof target === 'string') { - target = document.querySelector(target) - } - if (target instanceof HTMLElement && target.appendChild) { - target.appendChild(this.el) - } else if (target instanceof Object3D || target instanceof MX.Scene) { - target.add(this) - } - return this - }, - - removeElement: function () { - if (this.el.parentNode) { - this.el.parentNode.removeChild(this.el) - } - }, - - setPosition: function (tar) { - this.x = (tar.x || tar.x === 0) ? tar.x : this.x - this.y = (tar.y || tar.y === 0) ? tar.y : this.y - this.z = (tar.z || tar.z === 0) ? tar.z : this.z - }, - - setRotation: function (tar) { - this.rotationX = (tar.x || tar.x === 0) ? tar.x : this.rotationX - this.rotationY = (tar.y || tar.y === 0) ? tar.y : this.rotationY - this.rotationZ = (tar.z || tar.z === 0) ? tar.z : this.rotationZ - }, - - setScale: function (tar) { - this.scaleX = (tar.x || tar.x === 0) ? tar.x : this.scaleX - this.scaleY = (tar.y || tar.y === 0) ? tar.y : this.scaleY - this.scaleZ = (tar.z || tar.z === 0) ? tar.z : this.scaleZ - }, - - setCSSTransformOrigin: function (origin) { - this.el && (this.el.style[transformOriginProp] = origin) - return this - }, - - setCSSTransformStyle: function (style) { - this.el && (this.el.style[transformStyleProp] = style) - return this - }, - - setCSSTransition: function (trans) { - this.el && (this.el.style[transitionProp] = trans) - return this - }, - - setCSSPerspective: function (pers) { - this.el && (this.el.style[perspectiveProp] = pers) - return this - }, - - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() - }, - - onTransitionEnd: function (callback) { - this.cancelTransitionEnd() - var el = this.el - el.addEventListener(transitionEndEvent, onEnd) - function onEnd () { - el.removeEventListener(transitionEndEvent, onEnd) - callback() - } - }, - - cancelTransitionEnd: function () { - this.el.removeEventListener(transitionEndEvent) - }, - - toString: function(params){ - params = params || "id width height depth x y z rotationX rotationY rotationZ scale".split(" ") - return this.__toString(params) - }, - - __toString: function(params, func){ - this.id = this.id || 'undef' // _.uniqueId() - var list = [], - obj = {}, - type = this.type || "Object3d", - name = type.toLowerCase(), - val, - param - for (var i in params) { - param = params[i] - val = this[param] - if (val === 0 && ! func) continue; - if (typeof val == "number") { - if (param.indexOf("rotation") != -1) { - obj[param] = Number(val.toFixed(3)) - } - else { - obj[param] = ~~val - } - } - else { - obj[param] = val - } - } - - return (func || "var " + name + " = new MX." + type ) + "(" + - JSON.stringify(obj, undefined, 2) + - ")\n" + (func ? "" : "scene.add(" + name + ")") - }, - - contains: function(x,y,z){ - var containsX = false, - containsY = false, - containsZ = false - - if (x === null) { - containsX = true - } - else { - containsX = abs(this.x - x) <= this.width/2 - } - - if (y === null) { - containsY = true - } - else { - containsY = abs(this.y - y) <= this.height/2 - } - - if (z === null) { - containsZ = true - } - else { - containsZ = abs(this.z - z) <= this.depth/2 - } - - return (containsX && containsY && containsZ) - } - - } - - // ======================================================================== - // Inheritance - // ======================================================================== - - Object3D.extend = extend.bind(Object3D) - - function extend (props) { - var Super = this - var ExtendedObject3D = function () { - Super.call(this) - props.init && props.init.apply(this, arguments) - } - ExtendedObject3D.prototype = Object.create(Super.prototype) - for (var prop in props) { - if (props.hasOwnProperty(prop) && prop !== 'init') { - ExtendedObject3D.prototype[prop] = props[prop] - } - } - ExtendedObject3D.extend = extend.bind(ExtendedObject3D) - return ExtendedObject3D - } - - // ======================================================================== - // Expose API - // ======================================================================== - - MX.Object3D = Object3D - MX.toRad = toRad - MX.toDeg = toDeg - - // center positioning getter setter - Object.defineProperty(MX, 'positionAtCenter', { - get: function () { - return positionAtCenter - }, - set: function (val) { - if (typeof val !== 'boolean') return - positionAtCenter = val - if (positionAtCenter) { - injectCenteringCSS() - } else { - removeCenteringCSS() - } - } - }) - - return MX - -})() \ No newline at end of file diff --git a/site/public/assets/javascripts/mx/mx.min.js b/site/public/assets/javascripts/mx/mx.min.js deleted file mode 100644 index b0f0cdd..0000000 --- a/site/public/assets/javascripts/mx/mx.min.js +++ /dev/null @@ -1 +0,0 @@ -var MX=MX||function(undefined){var MX={prefix:undefined,rotationUnit:"rad"};var floatPrecision=5;var transformProp,transitionProp,transformOriginProp,transformStyleProp,perspectiveProp;var positionAtCenter=true,centeringCSS;document.addEventListener("DOMContentLoaded",setup);function setup(){var s=document.body.style;MX.prefix="webkitTransform"in s?"webkit":"mozTransform"in s?"moz":"msTransform"in s?"ms":"";transformProp=MX.transformProp=addPrefix("transform");transitionProp=MX.transitionProp=addPrefix("transition");transformOriginProp=MX.transformOriginProp=addPrefix("transformOrigin");transformStyleProp=MX.transformStyleProp=addPrefix("transformStyle");perspectiveProp=MX.perspectiveProp=addPrefix("perspective");var vendors=["webkit","moz","ms"];for(var x=0;x0?1:-1;r.y=flip*Math.atan2(dx*Math.cos(r.x),dz*-flip);r.z=Math.atan2(Math.cos(r.x),Math.sin(r.x)*Math.sin(r.y))-Math.PI/2;if(MX.rotationUnit==="deg"){r.x=toDeg(r.x);r.y=toDeg(r.y);r.z=toDeg(r.z)}return r},add:function(){if(!this.el)return;var parent=this;Array.prototype.forEach.call(arguments,function(child){if(!child instanceof Object3D)return;parent.el.appendChild(child.el);if(!parent.children)parent.children=[];parent.children.push(child);child.parent=parent});return this},remove:function(){var parent=this;Array.prototype.forEach.call(arguments,function(child){var index=parent.children.indexOf(child);if(index!==-1){parent.children.splice(index,1);child.parent=undefined}});return this},addTo:function(target){if(typeof target==="string"){target=document.querySelector(target)}if(target instanceof HTMLElement&&target.appendChild){target.appendChild(this.el)}else if(target instanceof Object3D||target instanceof Scene){target.add(this)}return this},removeElement:function(){if(this.el.parentNode){this.el.parentNode.removeChild(this.el)}},setPosition:function(tar){this.x=tar.x||tar.x===0?tar.x:this.x;this.y=tar.y||tar.y===0?tar.y:this.y;this.z=tar.z||tar.z===0?tar.z:this.z},setRotation:function(tar){this.rotationX=tar.x||tar.x===0?tar.x:this.rotationX;this.rotationY=tar.y||tar.y===0?tar.y:this.rotationY;this.rotationZ=tar.z||tar.z===0?tar.z:this.rotationZ},setScale:function(tar){this.scaleX=tar.x||tar.x===0?tar.x:this.scaleX;this.scaleY=tar.y||tar.y===0?tar.y:this.scaleY;this.scaleZ=tar.z||tar.z===0?tar.z:this.scaleZ},setCSSTransformOrigin:function(origin){this.el&&(this.el.style[transformOriginProp]=addPrefix(origin));return this},setCSSTransformStyle:function(style){this.el&&(this.el.style[transformStyleProp]=addPrefix(style));return this},setCSSTransition:function(trans){this.el&&(this.el.style[transitionProp]=addPrefix(trans));return this},setCSSPerspective:function(pers){this.el&&(this.el.style[perspectiveProp]=addPrefix(pers));return this}};Object3D.extend=extend.bind(Object3D);function extend(props){var Super=this;var ExtendedObject3D=function(){Super.call(this);props.init&&props.init.apply(this,arguments)};ExtendedObject3D.prototype=Object.create(Super.prototype);for(var prop in props){if(props.hasOwnProperty(prop)&&prop!=="init"){ExtendedObject3D.prototype[prop]=props[prop]}}ExtendedObject3D.extend=extend.bind(ExtendedObject3D);return ExtendedObject3D}MX.Object3D=Object3D;MX.toRad=toRad;MX.toDeg=toDeg;Object.defineProperty(MX,"positionAtCenter",{get:function(){return positionAtCenter},set:function(val){if(typeof val!=="boolean")return;positionAtCenter=val;if(positionAtCenter){injectCenteringCSS()}else{removeCenteringCSS()}}});return MX}(); \ No newline at end of file diff --git a/site/public/assets/javascripts/mx/mx.quaternion.js b/site/public/assets/javascripts/mx/mx.quaternion.js deleted file mode 100644 index 783f887..0000000 --- a/site/public/assets/javascripts/mx/mx.quaternion.js +++ /dev/null @@ -1,414 +0,0 @@ -/** - * quaternion taken from three.js - * @author mikael emtinger / http://gomo.se/ - * @author alteredq / http://alteredqualia.com/ - * @author WestLangley / http://github.com/WestLangley - * @author bhouston / http://exocortex.com - */ - -MX.Quaternion = function ( x, y, z, w ) { - - this._x = x || 0; - this._y = y || 0; - this._z = z || 0; - this._w = ( w !== undefined ) ? w : 1; - -}; - -MX.Quaternion.prototype = { - - constructor: MX.Quaternion, - - _x: 0,_y: 0, _z: 0, _w: 0, - - _euler: undefined, - - _updateEuler: function ( callback ) { - - if ( this._euler !== undefined ) { - - this._euler.setFromQuaternion( this, undefined, false ); - - } - - }, - - get x () { - - return this._x; - - }, - - set x ( value ) { - - this._x = value; - this._updateEuler(); - - }, - - get y () { - - return this._y; - - }, - - set y ( value ) { - - this._y = value; - this._updateEuler(); - - }, - - get z () { - - return this._z; - - }, - - set z ( value ) { - - this._z = value; - this._updateEuler(); - - }, - - get w () { - - return this._w; - - }, - - set w ( value ) { - - this._w = value; - this._updateEuler(); - - }, - - set: function ( x, y, z, w ) { - - this._x = x; - this._y = y; - this._z = z; - this._w = w; - - this._updateEuler(); - - return this; - - }, - - copy: function ( quaternion ) { - - this._x = quaternion._x; - this._y = quaternion._y; - this._z = quaternion._z; - this._w = quaternion._w; - - this._updateEuler(); - - return this; - - }, - - setFromEuler: function ( euler, update ) { - - if ( euler instanceof MX.Euler === false ) { - throw new Error( 'ERROR: Quaternion\'s .setFromEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.' ); - } - - // http://www.mathworks.com/matlabcentral/fileexchange/ - // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ - // content/SpinCalc.m - - var c1 = Math.cos( euler._x / 2 ); - var c2 = Math.cos( euler._y / 2 ); - var c3 = Math.cos( euler._z / 2 ); - var s1 = Math.sin( euler._x / 2 ); - var s2 = Math.sin( euler._y / 2 ); - var s3 = Math.sin( euler._z / 2 ); - - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; - - if ( update !== false ) this._updateEuler(); - - return this; - - }, - - setFromAxisAngle: function ( axis, angle ) { - - // from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm - // axis have to be normalized - - var halfAngle = angle / 2, s = Math.sin( halfAngle ); - - this._x = axis.x * s; - this._y = axis.y * s; - this._z = axis.z * s; - this._w = Math.cos( halfAngle ); - - this._updateEuler(); - - return this; - - }, - - setFromRotationMatrix: function ( m ) { - - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - - // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) - - var te = m.elements, - - m11 = te[0], m12 = te[4], m13 = te[8], - m21 = te[1], m22 = te[5], m23 = te[9], - m31 = te[2], m32 = te[6], m33 = te[10], - - trace = m11 + m22 + m33, - s; - - if ( trace > 0 ) { - - s = 0.5 / Math.sqrt( trace + 1.0 ); - - this._w = 0.25 / s; - this._x = ( m32 - m23 ) * s; - this._y = ( m13 - m31 ) * s; - this._z = ( m21 - m12 ) * s; - - } else if ( m11 > m22 && m11 > m33 ) { - - s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); - - this._w = (m32 - m23 ) / s; - this._x = 0.25 * s; - this._y = (m12 + m21 ) / s; - this._z = (m13 + m31 ) / s; - - } else if ( m22 > m33 ) { - - s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); - - this._w = (m13 - m31 ) / s; - this._x = (m12 + m21 ) / s; - this._y = 0.25 * s; - this._z = (m23 + m32 ) / s; - - } else { - - s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); - - this._w = ( m21 - m12 ) / s; - this._x = ( m13 + m31 ) / s; - this._y = ( m23 + m32 ) / s; - this._z = 0.25 * s; - - } - - this._updateEuler(); - - return this; - - }, - - inverse: function () { - - this.conjugate().normalize(); - - return this; - - }, - - conjugate: function () { - - this._x *= -1; - this._y *= -1; - this._z *= -1; - - this._updateEuler(); - - return this; - - }, - - lengthSq: function () { - - return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; - - }, - - length: function () { - - return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); - - }, - - normalize: function () { - - var l = this.length(); - - if ( l === 0 ) { - - this._x = 0; - this._y = 0; - this._z = 0; - this._w = 1; - - } else { - - l = 1 / l; - - this._x = this._x * l; - this._y = this._y * l; - this._z = this._z * l; - this._w = this._w * l; - - } - - return this; - - }, - - multiply: function ( q, p ) { - - if ( p !== undefined ) { - - console.warn( 'DEPRECATED: Quaternion\'s .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); - return this.multiplyQuaternions( q, p ); - - } - - return this.multiplyQuaternions( this, q ); - - }, - - multiplyQuaternions: function ( a, b ) { - - // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm - - var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; - var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; - - this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; - this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; - this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; - this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; - - this._updateEuler(); - - return this; - - }, - - multiplyVector3: function ( vector ) { - - console.warn( 'DEPRECATED: Quaternion\'s .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); - return vector.applyQuaternion( this ); - - }, - - slerp: function ( qb, t ) { - - var x = this._x, y = this._y, z = this._z, w = this._w; - - // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ - - var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; - - if ( cosHalfTheta < 0 ) { - - this._w = -qb._w; - this._x = -qb._x; - this._y = -qb._y; - this._z = -qb._z; - - cosHalfTheta = -cosHalfTheta; - - } else { - - this.copy( qb ); - - } - - if ( cosHalfTheta >= 1.0 ) { - - this._w = w; - this._x = x; - this._y = y; - this._z = z; - - return this; - - } - - var halfTheta = Math.acos( cosHalfTheta ); - var sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta ); - - if ( Math.abs( sinHalfTheta ) < 0.001 ) { - - this._w = 0.5 * ( w + this._w ); - this._x = 0.5 * ( x + this._x ); - this._y = 0.5 * ( y + this._y ); - this._z = 0.5 * ( z + this._z ); - - return this; - - } - - var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, - ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; - - this._w = ( w * ratioA + this._w * ratioB ); - this._x = ( x * ratioA + this._x * ratioB ); - this._y = ( y * ratioA + this._y * ratioB ); - this._z = ( z * ratioA + this._z * ratioB ); - - this._updateEuler(); - - return this; - - }, - - equals: function ( quaternion ) { - - return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); - - }, - - fromArray: function ( array ) { - - this._x = array[ 0 ]; - this._y = array[ 1 ]; - this._z = array[ 2 ]; - this._w = array[ 3 ]; - - this._updateEuler(); - - return this; - - }, - - toArray: function () { - - return [ this._x, this._y, this._z, this._w ]; - - }, - - clone: function () { - - return new MX.Quaternion( this._x, this._y, this._z, this._w ); - - } - -}; - -MX.Quaternion.slerp = function ( qa, qb, qm, t ) { - - return qm.copy( qa ).slerp( qb, t ); - -} diff --git a/site/public/assets/javascripts/mx/mx.skew.js b/site/public/assets/javascripts/mx/mx.skew.js deleted file mode 100644 index 73296bd..0000000 --- a/site/public/assets/javascripts/mx/mx.skew.js +++ /dev/null @@ -1,610 +0,0 @@ -/** - * Copyright (C) 2013 by Evan You - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -var MX = MX || (function (undefined) { - - var MX = { - version: '0.1.0', - prefix: undefined, - rotationUnit: 'rad', - } - - var floatPrecision = 5 - - // ======================================================================== - // Setup & Compatibility - // ======================================================================== - - var transformProp, - transitionProp, - transformOriginProp, - transformStyleProp, - perspectiveProp, - transitionEndEvent - - var positionAtCenter = true, // whether to auto center objects - centeringCSS // styles to inject for center positioning - - document.addEventListener('DOMContentLoaded', setup) - - function setup () { - - // sniff prefix - - var s = document.body.style - - MX.prefix = - 'webkitTransform' in s ? 'webkit' : - 'mozTransform' in s ? 'moz' : - 'msTransform' in s ? 'ms' : '' - - transformProp = MX.transformProp = addPrefix('transform') - transitionProp = MX.transitionProp = addPrefix('transition') - transformOriginProp = MX.transformOriginProp = addPrefix('transformOrigin') - transformStyleProp = MX.transformStyleProp = addPrefix('transformStyle') - perspectiveProp = MX.perspectiveProp = addPrefix('perspective') - transitionEndEvent = MX.transitionEndEvent = MX.prefix === 'webkit' ? 'webkitTransitionEnd' : 'transitionend' - - // shiv rAF - - var vendors = ['webkit', 'moz', 'ms'] - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'] - window.cancelAnimationFrame = - window[vendors[x]+'CancelAnimationFrame'] || - window[vendors[x]+'CancelRequestAnimationFrame'] - } - - // inject centering css - - centeringCSS = document.createElement('style') - centeringCSS.type = 'text/css' - centeringCSS.innerHTML = - '.mx-object3d {' - + 'position: absolute;' - + 'top: 50%;' - + 'left: 50%;}' - injectCenteringCSS() - - window.scrollTo(0,0) - } - - function injectCenteringCSS () { - document.head.appendChild(centeringCSS) - } - - function removeCenteringCSS () { - document.head.removeChild(centeringCSS) - } - - // ======================================================================== - // Utils - // ======================================================================== - - function toDeg (rad) { - return rad / Math.PI * 180 - } - - function toRad (deg) { - return deg / 180 * Math.PI - } - - function buildRotationTranslation (obj) { - - // used when rotationOrigin is set - - var origin = obj.rotationOrigin - if (!origin) { - return - } else { - var dx = origin.x - obj.x, - dy = -(origin.y - obj.y), - dz = -(origin.z - obj.z) - return { - before: 'translate3d(' + dx.toFixed(floatPrecision) +'px,' + dy.toFixed(floatPrecision) + 'px,' + dz.toFixed(floatPrecision) + 'px) ', - after: 'translate3d(' + (-dx).toFixed(floatPrecision) + 'px,' + (-dy).toFixed(floatPrecision) + 'px,' + (-dz).toFixed(floatPrecision) + 'px) ' - } - } - } - - function addPrefix (string) { - if (MX.prefix) { - string = MX.prefix + string.charAt(0).toUpperCase() + string.slice(1) - } - return string - } - - // ======================================================================== - // Base Object3D - // ======================================================================== - - function Object3D (el) { - - this.setupDomElement(el) - this.setCSSTransformStyle('preserve-3d') - this.el.classList.add('mx-object3d') - - this.parent = undefined - this.children = [] - this.updateChildren = true - - this.inverseLookAt = false - - this.persisted = true - - this.reset() - -// this.quaternion = new MX.Quaternion () -// this.quaternion._euler = this - - var width, height, - self = this - - Object.defineProperty(this, 'width', { - get: function () { - return width - || parseInt(self.el.style.width, 10) * app_devicePixelRatio - || 0 - }, - set: function (val) { - width = val - this.el.style.width = (width/app_devicePixelRatio) + 'px' - } - }) - - Object.defineProperty(this, 'height', { - get: function () { - return height - || parseInt(self.el.style.height, 10) * app_devicePixelRatio - || 0 - }, - set: function (val) { - height = val - this.el.style.height = (height/app_devicePixelRatio) + 'px' - } - }) - } - - Object3D.prototype = { - - constructor: Object3D, - - reset: function () { - this.x = this.__x = 0 - this.y = this.__y = 0 - this.z = this.__z = 0 - this.rotationX = this.__rotationX = 0 - this.rotationY = this.__rotationY = 0 - this.rotationZ = this.__rotationZ = 0 - this.scaleX = this.__scaleX = 1 - this.scaleY = this.__scaleY = 1 - this.scaleZ = this.__scaleZ = 1 - this.skewX = this.__skewX = 0 - this.skewY = this.__skewY = 0 - this.scale = this.__scale = 1 - this.perspective = this.__perspective = 0 - this.rotationOrigin = undefined - this.followTarget = undefined -// this.quaternion = new MX.Quaternion() - this.dirty = true - this.update() - }, - - setupDomElement: function (el) { - this.el = undefined - if (el instanceof HTMLElement) { - this.el = el - } else if (typeof el === 'string') { - var tag = el.match(/^[^.#\s]*/)[1], - id = el.match(/#[^.#\s]*/), - classes = el.match(/\.[^.#\s]*/g) - this.el = document.createElement(tag || 'div') - if (id) { - this.el.id = id[0].slice(1) - } - if (classes) { - var i = classes.length - while (i--) { - this.el.classList.add(classes[i].slice(1)) - } - } - } else { - this.el = document.createElement('div') - } - }, - - update: function () { - - if (this.updateChildren) { - var i = this.children.length - while (i--) { - this.children[i].update() - } - } - - if (this.followTarget) { - this.lookAt(this.followTarget, false) - } - - if (this.scaleX !== this.__scaleX || - this.scaleY !== this.__scaleY || - this.scaleZ !== this.__scaleZ) { - this.__scaleX = this.scaleX - this.__scaleY = this.scaleY - this.__scaleZ = this.scaleZ - this.dirty = true - } - - if (this.skewX !== this.__skewX || - this.skewY !== this.__skewY) { - this.__skewX = this.skewX - this.__skewY = this.skewY - this.dirty = true - } - - if (this.scale !== this.__scale) { - this.scaleX = - this.scaleY = - this.scaleZ = - this.__scaleX = - this.__scaleY = - this.__scaleZ = - this.__scale = - this.scale - this.dirty = true - } - - if (this.rotationX !== this.__rotationX || - this.rotationY !== this.__rotationY || - this.rotationZ !== this.__rotationZ) { - this.__rotationX = this.rotationX - this.__rotationY = this.rotationY - this.__rotationZ = this.rotationZ - this.dirty = true - } - - if (this.x !== this.__x || - this.y !== this.__y || - this.z !== this.__z) { - this.__x = this.x - this.__y = this.y - this.__z = this.z - this.dirty = true - } - - if (this.perspective !== this.__perspective) { - this.__perspective = this.perspective - this.dirty = true - } - - if (this.dirty && this.el) { - - var rotationTranslation = buildRotationTranslation(this), - rotation = 'rotateX(' + this.rotationX.toFixed(floatPrecision) + MX.rotationUnit + ') ' - + 'rotateY(' + this.rotationY.toFixed(floatPrecision) + MX.rotationUnit + ') ' - + 'rotateZ(' + this.rotationZ.toFixed(floatPrecision) + MX.rotationUnit + ') ' - - var transformString = - (MX.positionAtCenter ? 'translate3d(-50%, -50%, 0) ' : '') - + (this.perspective ? 'perspective(' + this.perspective + 'px) ' : '') - + 'translate3d(' - + this.x.toFixed(floatPrecision || 0) + 'px,' - + (-this.y).toFixed(floatPrecision) + 'px,' - + (-this.z).toFixed(floatPrecision) + 'px) ' - + 'scale3d(' - + (app_devicePixelRatio * this.scaleX).toFixed(floatPrecision) + ',' - + (app_devicePixelRatio * this.scaleY).toFixed(floatPrecision) + ',' - + (app_devicePixelRatio * this.scaleZ).toFixed(floatPrecision) + ') ' - + 'skew(' - + (app_devicePixelRatio * this.skewX).toFixed(floatPrecision) + 'rad,' - + (app_devicePixelRatio * this.skewY).toFixed(floatPrecision) + 'rad) ' - - if (rotationTranslation) { - transformString += rotationTranslation.before - + rotation - + rotationTranslation.after - - } else { - transformString += rotation - } - - this.el.style[transformProp] = transformString - this.dirty = false - } - - return this - - }, - - // taken from three.js - setFromQuaternion: function ( q, order, update ) { - // q is assumed to be normalized - - // http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m - - var sqx = q.x * q.x; - var sqy = q.y * q.y; - var sqz = q.z * q.z; - var sqw = q.w * q.w; - - this.rotationX = Math.atan2( 2 * ( q.x * q.w - q.y * q.z ), ( sqw - sqx - sqy + sqz ) ); - this.rotationY = Math.asin( clamp( 2 * ( q.x * q.z + q.y * q.w ), -1, 1 ) ); - this.rotationZ = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw + sqx - sqy - sqz ) ); - }, - - lookAt: function (target, update) { - var r = this.getLookAtEuler(target) - this.setRotation(r) - if (update !== false) this.update() - return this - }, - - getLookAtEuler: function (target) { - // euler order XYZ - var r = {}, - dx = target.x - this.x, - dy = target.y - this.y, - dz = target.z - this.z - if (this.inverseLookAt) { - dx = -dx - dy = -dy - dz = -dz - } - if (dz === 0) dz = 0.001 - r.x = -Math.atan2(dy, dz) - var flip = dz > 0 ? 1 : -1 - r.y = flip * Math.atan2(dx * Math.cos(r.x), dz * -flip) - r.z = Math.atan2(Math.cos(r.x), Math.sin(r.x) * Math.sin(r.y)) - Math.PI / 2 - if (MX.rotationUnit === 'deg') { - r.x = toDeg(r.x) - r.y = toDeg(r.y) - r.z = toDeg(r.z) - } - return r - }, - - add: function () { - if (!this.el) return - var parent = this - Array.prototype.forEach.call(arguments, function (child) { - if (!child instanceof Object3D) return - parent.el.appendChild(child.el) - if (!parent.children) parent.children = [] - parent.children.push(child) - child.parent = parent - }) - return this - }, - - remove: function () { - var parent = this - Array.prototype.forEach.call(arguments, function (child) { - var index = parent.children.indexOf(child) - if (index !== -1) { - parent.children.splice(index, 1) - parent.el.removeChild(child.el) - child.parent = undefined - } - }) - return this - }, - - addTo: function (target) { - if (typeof target === 'string') { - target = document.querySelector(target) - } - if (target instanceof HTMLElement && target.appendChild) { - target.appendChild(this.el) - } else if (target instanceof Object3D || target instanceof MX.Scene) { - target.add(this) - } - return this - }, - - removeElement: function () { - if (this.el.parentNode) { - this.el.parentNode.removeChild(this.el) - } - }, - - setPosition: function (tar) { - this.x = (tar.x || tar.x === 0) ? tar.x : this.x - this.y = (tar.y || tar.y === 0) ? tar.y : this.y - this.z = (tar.z || tar.z === 0) ? tar.z : this.z - }, - - setRotation: function (tar) { - this.rotationX = (tar.x || tar.x === 0) ? tar.x : this.rotationX - this.rotationY = (tar.y || tar.y === 0) ? tar.y : this.rotationY - this.rotationZ = (tar.z || tar.z === 0) ? tar.z : this.rotationZ - }, - - setScale: function (tar) { - this.scaleX = (tar.x || tar.x === 0) ? tar.x : this.scaleX - this.scaleY = (tar.y || tar.y === 0) ? tar.y : this.scaleY - this.scaleZ = (tar.z || tar.z === 0) ? tar.z : this.scaleZ - }, - - setSkew: function (tar) { - this.skewX = (tar.x || tar.x === 0) ? tar.x : this.skewX - this.skewY = (tar.y || tar.y === 0) ? tar.y : this.skewY - }, - - setCSSTransformOrigin: function (origin) { - this.el && (this.el.style[transformOriginProp] = origin) - return this - }, - - setCSSTransformStyle: function (style) { - this.el && (this.el.style[transformStyleProp] = style) - return this - }, - - setCSSTransition: function (trans) { - this.el && (this.el.style[transitionProp] = trans) - return this - }, - - setCSSPerspective: function (pers) { - this.el && (this.el.style[perspectiveProp] = pers) - return this - }, - - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() - }, - - onTransitionEnd: function (callback) { - this.cancelTransitionEnd() - var el = this.el - el.addEventListener(transitionEndEvent, onEnd) - function onEnd () { - el.removeEventListener(transitionEndEvent, onEnd) - callback() - } - }, - - cancelTransitionEnd: function () { - this.el.removeEventListener(transitionEndEvent) - }, - - toString: function(params){ - params = params || "id width height depth x y z rotationX rotationY rotationZ scale".split(" ") - return this.__toString(params) - }, - - __toString: function(params, func){ - this.id = this.id || 'undef' // _.uniqueId() - var list = [], - obj = {}, - type = this.type || "Object3d", - name = type.toLowerCase(), - val, - param - for (var i in params) { - param = params[i] - val = this[param] - if (val === 0 && ! func) continue; - if (typeof val == "number") { - if (param.indexOf("rotation") != -1) { - obj[param] = Number(val.toFixed(3)) - } - else { - obj[param] = ~~val - } - } - else { - obj[param] = val - } - } - - return (func || "var " + name + " = new MX." + type ) + "(" + - JSON.stringify(obj, undefined, 2) + - ")\n" + (func ? "" : "scene.add(" + name + ")") - }, - - contains: function(x,y,z){ - var containsX = false, - containsY = false, - containsZ = false - - if (x === null) { - containsX = true - } - else { - containsX = abs(this.x - x) <= this.width/2 - } - - if (y === null) { - containsY = true - } - else { - containsY = abs(this.y - y) <= this.height/2 - } - - if (z === null) { - containsZ = true - } - else { - containsZ = abs(this.z - z) <= this.depth/2 - } - - return (containsX && containsY && containsZ) - } - - } - - // ======================================================================== - // Inheritance - // ======================================================================== - - Object3D.extend = extend.bind(Object3D) - - function extend (props) { - var Super = this - var ExtendedObject3D = function () { - Super.call(this) - props.init && props.init.apply(this, arguments) - } - ExtendedObject3D.prototype = Object.create(Super.prototype) - for (var prop in props) { - if (props.hasOwnProperty(prop) && prop !== 'init') { - ExtendedObject3D.prototype[prop] = props[prop] - } - } - ExtendedObject3D.extend = extend.bind(ExtendedObject3D) - return ExtendedObject3D - } - - // ======================================================================== - // Expose API - // ======================================================================== - - MX.Object3D = Object3D - MX.toRad = toRad - MX.toDeg = toDeg - - // center positioning getter setter - Object.defineProperty(MX, 'positionAtCenter', { - get: function () { - return positionAtCenter - }, - set: function (val) { - if (typeof val !== 'boolean') return - positionAtCenter = val - if (positionAtCenter) { - injectCenteringCSS() - } else { - removeCenteringCSS() - } - } - }) - - return MX - -})() \ No newline at end of file diff --git a/site/public/assets/javascripts/mx/primitives/mx.image.js b/site/public/assets/javascripts/mx/primitives/mx.image.js deleted file mode 100644 index 39bb0b5..0000000 --- a/site/public/assets/javascripts/mx/primitives/mx.image.js +++ /dev/null @@ -1,50 +0,0 @@ -MX.Image = MX.Object3D.extend({ - init: function (ops) { - - this.type = "Image" - this.media = ops.media - this.width = 0 - this.height = 0 - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.scale = ops.scale || 1 - this.backface = ops.backface || false - - ops.className && this.el.classList.add(ops.className) - this.backface && this.el.classList.add("backface-visible") - this.el.classList.add("image") - this.el.classList.add("mx-scenery") - - this.el.style.backgroundRepeat = 'no-repeat' - - this.load(ops) - }, - - load: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - - var image = new Image() - image.onload = function(){ - if (! layer.ops) return - layer.scale = layer.ops.scale || 1 - layer.width = layer.ops.width || image.naturalWidth - layer.height = layer.ops.height || image.naturalHeight -// layer.x = layer.ops.x || 0 -// layer.y = layer.ops.y || 0 -// layer.z = layer.ops.z || 0 -// layer.rotationX = layer.ops.rotationX || 0 -// layer.rotationY = layer.ops.rotationY || 0 -// layer.rotationZ = layer.ops.rotationZ || 0 - layer.el.style.backgroundImage = "url(" + image.src + ")" - layer.el.classList.add('image') - layer.dirty = true - layer.ops.onload && layer.ops.onload( image ) - layer.update() - } - image.src = ops.src; - if (image.complete) setTimeout(image.onload) - }, - -}) diff --git a/site/public/assets/javascripts/mx/primitives/mx.soundcloud.js b/site/public/assets/javascripts/mx/primitives/mx.soundcloud.js deleted file mode 100644 index 75286d9..0000000 --- a/site/public/assets/javascripts/mx/primitives/mx.soundcloud.js +++ /dev/null @@ -1,125 +0,0 @@ -MX.Soundcloud = MX.Object3D.extend({ - init: function (ops) { - - this.type = "Soundcloud" - this.media = ops.media - this.width = 0 - this.height = 0 - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.scale = ops.scale || 1 - this.backface = ops.backface || false - - ops.className && this.el.classList.add(ops.className) - this.backface && this.el.classList.add("backface-visible") - this.el.classList.add("audio") - this.el.classList.add("mx-scenery") - - this.el.style.backgroundRepeat = 'no-repeat' - this.paused = true - - this.ops = ops - }, - - load: function(ops){ - if (ops) { - ops = this.ops = defaults(ops, this.ops) - } - else { - ops = this.ops - } - - this.width = ops.media.width - this.height = ops.media.height - - var tag = Parser.lookup.soundcloud.tag(ops.media) - var $iframe = $(tag) - var iframe = $iframe[0] - $iframe.css('z-index', '-1') - this.el.appendChild( iframe ) - - var overlay = this.overlay = document.createElement("div") - overlay.style.width = "100%" - overlay.style.height = "100%" - overlay.style.position = "absolute" - overlay.style.top = "0" - overlay.style.left = "0" - overlay.style.zIndex = "2" - overlay.className = "overlay" - this.el.appendChild(overlay) - - this.player = SC.Widget( iframe ) - this.player.setVolume(80) - - this.duration = 0 - - this.player.bind(SC.Widget.Events.READY, this.ready.bind(this)) -// this.player.bind(SC.Widget.Events.LOAD_PROGRESS, this.loadProgress.bind(this)) -// this.player.bind(SC.Widget.Events.PLAY_PROGRESS, this.playProgress.bind(this)) - this.player.bind(SC.Widget.Events.PLAY, this.didPlay.bind(this)) - this.player.bind(SC.Widget.Events.PAUSE, this.didPause.bind(this)) - this.player.bind(SC.Widget.Events.FINISH, this.finished.bind(this)) - }, - - ready: function(){ - this.seek( this.media.keyframe || 0 ) - - if (this.media.autoplay) { - this.play() - } - - this.player.getDuration(function(duration){ - this.duration = duration - }.bind(this)) - }, - - play: function(){ - this.player.play() - }, - - pause: function(){ - this.player.pause() - }, - - toggle: function(state){ - if (typeof state === "boolean") { - if (state) this.play() - else this.pause() - } - else { - this.player.toggle() - } - }, - - seek: function(n){ - if (n < 1) { - n = n * this.duration - } - this.player.seekTo(n) - }, - - setLoop: function(state){ - this.media.loop = state - }, - - didPlay: function(){ - this.paused = false - }, - - didPause: function(){ - this.paused = true - }, - - finished: function(){ - console.log("soundcloud finished") - if (this.media.loop) { - this.seek(0) - this.play() - } - else if (this.bound) { - $(".playButton").removeClass('playing') - } - }, - -}) diff --git a/site/public/assets/javascripts/mx/primitives/mx.text.js b/site/public/assets/javascripts/mx/primitives/mx.text.js deleted file mode 100644 index 6b5681b..0000000 --- a/site/public/assets/javascripts/mx/primitives/mx.text.js +++ /dev/null @@ -1,59 +0,0 @@ -MX.Text = MX.Object3D.extend({ - - init: function (ops) { - - this.type = "Text" - - this.type = "Image" - this.media = ops.media - this.width = 0 - this.height = 0 - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.scale = ops.scale || 1 - this.backface = ops.backface || false - - this.scale = ops.scale || 1 - this.width = ops.media.width - this.height = ops.media.height - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.rotationX = ops.rotationX || 0 - this.rotationY = ops.rotationY || 0 - this.rotationZ = ops.rotationZ || 0 - - ops.className && this.el.classList.add(ops.className) - this.backface && this.el.classList.add("backface-visible") - this.el.classList.add("mx-text") - this.el.classList.add("mx-scenery") - - this.inner = document.createElement("div") - this.inner.classList.add("inner") - this.el.appendChild(this.inner) - - this.load(ops) - }, - - load: function(ops){ - var media = ops.media - if (media.font) this.setFont(media.font) - - this.setText( media.description ) - }, - - setFont: function(font){ - if (! font.color || font.color[0] == "#") { font.color = [0,0,0] } - - this.inner.style.fontFamily = "'" + font.family + "',sans-serif" - this.el.style.fontSize = (2 * font.size / devicePixelRatio) + "pt" - this.el.style.textAlign = font.align - this.el.style.color = rgb_string(font.color) - }, - - setText: function(text){ - this.inner.innerHTML = marked( text || "" ) - }, - -}) diff --git a/site/public/assets/javascripts/mx/primitives/mx.video.js b/site/public/assets/javascripts/mx/primitives/mx.video.js deleted file mode 100644 index c281f02..0000000 --- a/site/public/assets/javascripts/mx/primitives/mx.video.js +++ /dev/null @@ -1,110 +0,0 @@ -MX.Video = MX.Object3D.extend({ - - init: function (ops) { - - this.type = "Video" - - this.media = ops.media - this.width = ops.media.width - this.height = ops.media.height - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.rotationX = ops.rotationX || 0 - this.rotationY = ops.rotationY || 0 - this.rotationZ = ops.rotationZ || 0 - this.scale = ops.scale || 1 - this.backface = ops.backface || false - - ops.className && this.el.classList.add(ops.className) - this.backface && this.el.classList.add("backface-visible") - this.el.classList.add("video") - this.el.classList.add("mx-scenery") - this.paused = !! this.media.autoplay - this.muted = app.muted || !! this.media.mute - }, - - load: function(ops){ - this.paused = true - - this.player = document.createElement('video') - this.player.addEventListener("loadedmetadata", this.ready.bind(this)) - this.player.addEventListener("error", this.error.bind(this)) - this.player.addEventListener("ended", this.finished.bind(this)) - this.player.width = "100%" - this.player.height = "100%" - this.player.src = this.media.url - this.player.load() - - this.el.appendChild(this.player) - }, - - ready: function(){ - this.seek( this.media.keyframe || 0 ) - - if (this.media.mute) { - this.mute() - } - else { - this.unmute() - } - - if (this.media.autoplay) { - this.play() - } - }, - - error: function(err){ - console.log("video error", err) - }, - - play: function(){ - this.paused = false - this.player.play() - }, - - pause: function(){ - this.paused = true - this.player.pause() - }, - - seek: function(n){ - if (n < 1) { - n = n * this.duration() - } - this.player.currentTime = n - }, - - mute: function(){ - this.player.muted = true - this.player.volume = 0 - this.muted = true - }, - - unmute: function(){ - this.player.muted = false - this.player.volume = 0.8 - this.muted = false - }, - - setLoop: function(state){ - this.media.loop = state - }, - - duration: function(){ - return this.player.duration - }, - - finished: function(){ - console.log("video finished") - if (this.media.loop) { - this.seek(0) - this.play() - } - else if (this.bound) { - $(".playButton").removeClass('playing') - } - }, - - -}) diff --git a/site/public/assets/javascripts/mx/primitives/mx.vimeo.js b/site/public/assets/javascripts/mx/primitives/mx.vimeo.js deleted file mode 100644 index fe5ce86..0000000 --- a/site/public/assets/javascripts/mx/primitives/mx.vimeo.js +++ /dev/null @@ -1,162 +0,0 @@ -MX.Vimeo = MX.Object3D.extend({ - - init: function (ops) { - - this.type = "Vimeo" - - this.media = ops.media - this.width = ops.media.width - this.height = ops.media.height - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.rotationX = ops.rotationX || 0 - this.rotationY = ops.rotationY || 0 - this.rotationZ = ops.rotationZ || 0 - this.scale = ops.scale || 1 - this.backface = ops.backface || false - - ops.className && this.el.classList.add(ops.className) - this.backface && this.el.classList.add("backface-visible") - this.el.classList.add("video") - this.el.classList.add("mx-scenery") - this.paused = !! this.media.autoplay - this.muted = app.muted || !! this.media.mute - this.started = false - }, - - load: function (ops) { - var uid = 'player-' + Uid () - var loop = this.media.loop ? 'loop=1' : "" - var preload = document.createElement("iframe") - preload.id = uid - preload.setAttribute("src", "//player.vimeo.com/video/" + this.media.token + "?api=1&badge=0&controls=0branding=0&byline=0&portrait=0&title=0&" + loop + "&player_id=" + uid) - preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" - preload.style.width = "100%" - preload.style.height = "100%" - preload.style.border = "0" - preload.style.pointerEvents = "none" - preload.className = "preload" - this.el.appendChild(preload) - this.player = $f(preload) - - this.player.addEvent('ready', $.proxy(this.ready, this)) - }, - - ready: function(){ - console.log("vimeo ready") - - this.started = true - - // wait until ready before binding events. other events: play, pause - this.player.addEvent('play', $.proxy(this.onPlay, this)) - this.player.addEvent('pause', $.proxy(this.onPause, this)) - this.player.addEvent('finish', $.proxy(this.finished, this)) - - // this is async on vimeo so call it asap - this.player.api('getDuration', $.proxy(function(n){ - console.log("vimeo duration", n) - this.player.duration = n - }, this)) - - if (this.media.mute) { - this.mute() - } - else { - this.unmute() - } - - this.seek( this.media.keyframe || 0 ) - - if (this.media.autoplay) { - this.play() - } - else { - this.pause() - } - }, - - error: function(err){ - console.log("vimeo error", err) - }, - - play: function(){ - this.paused = false - this.player.api('play') - }, - - pause: function(){ - this.paused = true - this.player.api('pause') - }, - - seek: function(n){ - // defer seek until we have duration - if (! this.duration()) { - setTimeout($.proxy(function(){ - this.seek(n) - }, this), 300) - return - } - - if (! this.started || n === 0) { - return - } - - if (n < 1) { - n = n * this.duration() - } - this.player.api('seekTo', max(0, n-1)) - if (this.paused) { - this.paused = false - this.play() - this.pause() - setTimeout($.proxy(function(){ - this.pause() - }, this), 100) - } - }, - - duration: function(){ - return this.player.duration - }, - - mute: function(){ - this.player.api('setVolume', 0.0) - this.muted = true - }, - - unmute: function(){ - this.player.api('setVolume', 0.8) - this.muted = false - }, - - setLoop: function(state){ - this.media.loop = state - this.player.api('setLoop', state) - }, - - onPlay: function(){ - if (this.paused) { - this.pause() - } - }, - - onPause: function(){ - if (! this.paused) { - this.play() - } - }, - - finished: function(){ -// if (this.media.loop) { -// this.seek(0) -// this.play() -// } -// else if (this.bound) { - if (! this.media.loop && this.bound) { - $(".playButton").removeClass('playing') - } - } - -}) diff --git a/site/public/assets/javascripts/mx/primitives/mx.youtube.js b/site/public/assets/javascripts/mx/primitives/mx.youtube.js deleted file mode 100644 index 5c92378..0000000 --- a/site/public/assets/javascripts/mx/primitives/mx.youtube.js +++ /dev/null @@ -1,196 +0,0 @@ -MX.Youtube = MX.Object3D.extend({ - - init: function (ops) { - - this.type = "Youtube" - - this.media = ops.media - this.width = ops.media.width - this.height = ops.media.height - this.x = ops.x || 0 - this.y = ops.y || 0 - this.z = ops.z || 0 - this.rotationX = ops.rotationX || 0 - this.rotationY = ops.rotationY || 0 - this.rotationZ = ops.rotationZ || 0 - this.scale = ops.scale || 1 - this.backface = ops.backface || false - - ops.className && this.el.classList.add(ops.className) - this.backface && this.el.classList.add("backface-visible") - this.el.classList.add("video") - this.el.classList.add("mx-scenery") - this.paused = !! this.media.autoplay - this.muted = app.muted || !! this.media.mute - }, - - load: function (ops) { - var base = this - var uid = 'player-' + Uid () - var preload = document.createElement("div") - preload.id = uid - preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" - preload.style.backgroundSize = "cover" - preload.style.width = "100%" - preload.style.height = "100%" - preload.style.pointerEvents = "none" - preload.style.position = "absolute" - preload.style.top = "0" - preload.style.left = "0" - preload.style.zIndex = "1" - preload.className = "preload" - this.el.appendChild(preload) - - var overlay = this.overlay = document.createElement("div") - overlay.style.width = "100%" - overlay.style.height = "100%" - overlay.style.position = "absolute" - overlay.style.top = "0" - overlay.style.left = "0" - overlay.style.zIndex = "2" - overlay.className = "overlay" - this.el.appendChild(overlay) - this.defer(uid) - }, - - defer: function (uid){ - if (! YT || ! YT.loaded) { - setTimeout(function(){ - this.defer(uid) - }.bind(this), 300) - } - else { - // not sure why i need to delay here.. - // stopped working until i added the setTimeout - setTimeout(function(){ - this.build(uid) - }.bind(this), 20) - } - }, - - build: function(uid){ - this.player = new YT.Player(uid, { - videoId: this.media.token, - width: this.width, - height: this.height, - events: { - onReady: this.ready.bind(this), - onError: this.error.bind(this), - onStateChange: this.statechange.bind(this), - }, - playerVars: { - autohide: 1, - autoplay: 0, - disablekb: 1, - controls: 0, - enablejsapi: 1, - origin: window.location.origin, - fs: 0, - modestbranding: 1, - iv_load_policy: 3, // no annotations - loop: 0, - showinfo: 0, - rel: 0, - wmode: 'opaque', - }, - }) - }, - - ready: function(){ - console.log("youtube ready") - - if (this.media.autoplay) { - this.play() - } - else { - this.pause() - } - - if (this.media.mute) { - this.mute() - } - else { - this.unmute() - } - - this.seek( this.media.keyframe || 0 ) - }, - - error: function(err){ - console.log("youtube error", err) - }, - - statechange: function(e){ - switch (e.data) { - case -1: // unstarted - break - case 0: // finished - this.finished() - break - case 1: // play - if (this.paused) { - this.pause() - } - break - case 2: // pause - break - case 3: // buffering - break - case 5: // cued - break - } - }, - - play: function(){ - this.paused = false - this.player.playVideo() - }, - - pause: function(){ - this.paused = true - this.player.pauseVideo() - }, - - seek: function(n, allowSeekAhead){ - if (n < 1) { - n = n * this.duration() - } - allowSeekAhead = typeof allowSeekAhead == "boolean" ? allowSeekAhead : true - this.player.seekTo(n, true) // set to false if seeking manually - }, - - duration: function(){ - return this.player.getDuration() - }, - - mute: function(){ - this.player.mute() - this.muted = true - }, - - unmute: function(){ - this.player.unMute() - this.player.setVolume(80) - this.muted = false - }, - - setLoop: function(state){ - this.media.loop = state - }, - - finished: function(){ - console.log("youtube finished") - if (this.media.loop) { - this.seek(0) - this.play() - } - else if (this.bound) { - $(".playButton").removeClass('playing') - } - } - -}) - -window.onYouTubePlayerAPIReady = function(){ - // console.log("youtube api ready") -} diff --git a/site/public/assets/javascripts/vendor/fastclick.js b/site/public/assets/javascripts/vendor/fastclick.js deleted file mode 100644 index 9c746c2..0000000 --- a/site/public/assets/javascripts/vendor/fastclick.js +++ /dev/null @@ -1,790 +0,0 @@ -/** - * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs. - * - * @version 1.0.1 - * @codingstandard ftlabs-jsv2 - * @copyright The Financial Times Limited [All Rights Reserved] - * @license MIT License (see LICENSE.txt) - */ - -/*jslint browser:true, node:true*/ -/*global define, Event, Node*/ - - -/** - * Instantiate fast-clicking listeners on the specified layer. - * - * @constructor - * @param {Element} layer The layer to listen on - * @param {Object} options The options to override the defaults - */ -function FastClick(layer, options) { - 'use strict'; - var oldOnClick; - - options = options || {}; - - /** - * Whether a click is currently being tracked. - * - * @type boolean - */ - this.trackingClick = false; - - - /** - * Timestamp for when click tracking started. - * - * @type number - */ - this.trackingClickStart = 0; - - - /** - * The element being tracked for a click. - * - * @type EventTarget - */ - this.targetElement = null; - - - /** - * X-coordinate of touch start event. - * - * @type number - */ - this.touchStartX = 0; - - - /** - * Y-coordinate of touch start event. - * - * @type number - */ - this.touchStartY = 0; - - - /** - * ID of the last touch, retrieved from Touch.identifier. - * - * @type number - */ - this.lastTouchIdentifier = 0; - - - /** - * Touchmove boundary, beyond which a click will be cancelled. - * - * @type number - */ - this.touchBoundary = options.touchBoundary || 10; - - - /** - * The FastClick layer. - * - * @type Element - */ - this.layer = layer; - - /** - * The minimum time between tap(touchstart and touchend) events - * - * @type number - */ - this.tapDelay = options.tapDelay || 200; - - if (FastClick.notNeeded(layer)) { - return; - } - - // Some old versions of Android don't have Function.prototype.bind - function bind(method, context) { - return function() { return method.apply(context, arguments); }; - } - - - var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel']; - var context = this; - for (var i = 0, l = methods.length; i < l; i++) { - context[methods[i]] = bind(context[methods[i]], context); - } - - // Set up event handlers as required - if (deviceIsAndroid) { - layer.addEventListener('mouseover', this.onMouse, true); - layer.addEventListener('mousedown', this.onMouse, true); - layer.addEventListener('mouseup', this.onMouse, true); - } - - layer.addEventListener('click', this.onClick, true); - layer.addEventListener('touchstart', this.onTouchStart, false); - layer.addEventListener('touchmove', this.onTouchMove, false); - layer.addEventListener('touchend', this.onTouchEnd, false); - layer.addEventListener('touchcancel', this.onTouchCancel, false); - - // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) - // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick - // layer when they are cancelled. - if (!Event.prototype.stopImmediatePropagation) { - layer.removeEventListener = function(type, callback, capture) { - var rmv = Node.prototype.removeEventListener; - if (type === 'click') { - rmv.call(layer, type, callback.hijacked || callback, capture); - } else { - rmv.call(layer, type, callback, capture); - } - }; - - layer.addEventListener = function(type, callback, capture) { - var adv = Node.prototype.addEventListener; - if (type === 'click') { - adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) { - if (!event.propagationStopped) { - callback(event); - } - }), capture); - } else { - adv.call(layer, type, callback, capture); - } - }; - } - - // If a handler is already declared in the element's onclick attribute, it will be fired before - // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and - // adding it as listener. - if (typeof layer.onclick === 'function') { - - // Android browser on at least 3.2 requires a new reference to the function in layer.onclick - // - the old one won't work if passed to addEventListener directly. - oldOnClick = layer.onclick; - layer.addEventListener('click', function(event) { - oldOnClick(event); - }, false); - layer.onclick = null; - } -} - - -/** - * Android requires exceptions. - * - * @type boolean - */ -var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0; - - -/** - * iOS requires exceptions. - * - * @type boolean - */ -var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent); - - -/** - * iOS 4 requires an exception for select elements. - * - * @type boolean - */ -var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent); - - -/** - * iOS 6.0(+?) requires the target element to be manually derived - * - * @type boolean - */ -var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent); - - -/** - * Determine whether a given element requires a native click. - * - * @param {EventTarget|Element} target Target DOM element - * @returns {boolean} Returns true if the element needs a native click - */ -FastClick.prototype.needsClick = function(target) { - 'use strict'; - switch (target.nodeName.toLowerCase()) { - - // Don't send a synthetic click to disabled inputs (issue #62) - case 'button': - case 'select': - case 'textarea': - if (target.disabled) { - return true; - } - - break; - case 'input': - - // File inputs need real clicks on iOS 6 due to a browser bug (issue #68) - if ((deviceIsIOS && target.type === 'file') || target.disabled) { - return true; - } - - break; - case 'label': - case 'video': - return true; - } - - return (/\bneedsclick\b/).test(target.className); -}; - - -/** - * Determine whether a given element requires a call to focus to simulate click into element. - * - * @param {EventTarget|Element} target Target DOM element - * @returns {boolean} Returns true if the element requires a call to focus to simulate native click. - */ -FastClick.prototype.needsFocus = function(target) { - 'use strict'; - switch (target.nodeName.toLowerCase()) { - case 'textarea': - return true; - case 'select': - return !deviceIsAndroid; - case 'input': - switch (target.type) { - case 'button': - case 'checkbox': - case 'file': - case 'image': - case 'radio': - case 'submit': - return false; - } - - // No point in attempting to focus disabled inputs - return !target.disabled && !target.readOnly; - default: - return (/\bneedsfocus\b/).test(target.className); - } -}; - - -/** - * Send a click event to the specified element. - * - * @param {EventTarget|Element} targetElement - * @param {Event} event - */ -FastClick.prototype.sendClick = function(targetElement, event) { - 'use strict'; - var clickEvent, touch; - - // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24) - if (document.activeElement && document.activeElement !== targetElement) { - document.activeElement.blur(); - } - - touch = event.changedTouches[0]; - - // Synthesise a click event, with an extra attribute so it can be tracked - clickEvent = document.createEvent('MouseEvents'); - clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); - clickEvent.forwardedTouchEvent = true; - targetElement.dispatchEvent(clickEvent); -}; - -FastClick.prototype.determineEventType = function(targetElement) { - 'use strict'; - - //Issue #159: Android Chrome Select Box does not open with a synthetic click event - if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') { - return 'mousedown'; - } - - return 'click'; -}; - - -/** - * @param {EventTarget|Element} targetElement - */ -FastClick.prototype.focus = function(targetElement) { - 'use strict'; - var length; - - // Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724. - if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') { - length = targetElement.value.length; - targetElement.setSelectionRange(length, length); - } else { - targetElement.focus(); - } -}; - - -/** - * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it. - * - * @param {EventTarget|Element} targetElement - */ -FastClick.prototype.updateScrollParent = function(targetElement) { - 'use strict'; - var scrollParent, parentElement; - - scrollParent = targetElement.fastClickScrollParent; - - // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the - // target element was moved to another parent. - if (!scrollParent || !scrollParent.contains(targetElement)) { - parentElement = targetElement; - do { - if (parentElement.scrollHeight > parentElement.offsetHeight) { - scrollParent = parentElement; - targetElement.fastClickScrollParent = parentElement; - break; - } - - parentElement = parentElement.parentElement; - } while (parentElement); - } - - // Always update the scroll top tracker if possible. - if (scrollParent) { - scrollParent.fastClickLastScrollTop = scrollParent.scrollTop; - } -}; - - -/** - * @param {EventTarget} targetElement - * @returns {Element|EventTarget} - */ -FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) { - 'use strict'; - - // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node. - if (eventTarget.nodeType === Node.TEXT_NODE) { - return eventTarget.parentNode; - } - - return eventTarget; -}; - - -/** - * On touch start, record the position and scroll offset. - * - * @param {Event} event - * @returns {boolean} - */ -FastClick.prototype.onTouchStart = function(event) { - 'use strict'; - var targetElement, touch, selection; - - // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111). - if (event.targetTouches.length > 1) { - return true; - } - - targetElement = this.getTargetElementFromEventTarget(event.target); - touch = event.targetTouches[0]; - - if (deviceIsIOS) { - - // Only trusted events will deselect text on iOS (issue #49) - selection = window.getSelection(); - if (selection.rangeCount && !selection.isCollapsed) { - return true; - } - - if (!deviceIsIOS4) { - - // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23): - // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched - // with the same identifier as the touch event that previously triggered the click that triggered the alert. - // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an - // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform. - if (touch.identifier === this.lastTouchIdentifier) { - event.preventDefault(); - return false; - } - - this.lastTouchIdentifier = touch.identifier; - - // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and: - // 1) the user does a fling scroll on the scrollable layer - // 2) the user stops the fling scroll with another tap - // then the event.target of the last 'touchend' event will be the element that was under the user's finger - // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check - // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42). - this.updateScrollParent(targetElement); - } - } - - this.trackingClick = true; - this.trackingClickStart = event.timeStamp; - this.targetElement = targetElement; - - this.touchStartX = touch.pageX; - this.touchStartY = touch.pageY; - - // Prevent phantom clicks on fast double-tap (issue #36) - if ((event.timeStamp - this.lastClickTime) < this.tapDelay) { - event.preventDefault(); - } - - return true; -}; - - -/** - * Based on a touchmove event object, check whether the touch has moved past a boundary since it started. - * - * @param {Event} event - * @returns {boolean} - */ -FastClick.prototype.touchHasMoved = function(event) { - 'use strict'; - var touch = event.changedTouches[0], boundary = this.touchBoundary; - - if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) { - return true; - } - - return false; -}; - - -/** - * Update the last position. - * - * @param {Event} event - * @returns {boolean} - */ -FastClick.prototype.onTouchMove = function(event) { - 'use strict'; - if (!this.trackingClick) { - return true; - } - - // If the touch has moved, cancel the click tracking - if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) { - this.trackingClick = false; - this.targetElement = null; - } - - return true; -}; - - -/** - * Attempt to find the labelled control for the given label element. - * - * @param {EventTarget|HTMLLabelElement} labelElement - * @returns {Element|null} - */ -FastClick.prototype.findControl = function(labelElement) { - 'use strict'; - - // Fast path for newer browsers supporting the HTML5 control attribute - if (labelElement.control !== undefined) { - return labelElement.control; - } - - // All browsers under test that support touch events also support the HTML5 htmlFor attribute - if (labelElement.htmlFor) { - return document.getElementById(labelElement.htmlFor); - } - - // If no for attribute exists, attempt to retrieve the first labellable descendant element - // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label - return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea'); -}; - - -/** - * On touch end, determine whether to send a click event at once. - * - * @param {Event} event - * @returns {boolean} - */ -FastClick.prototype.onTouchEnd = function(event) { - 'use strict'; - var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement; - - if (!this.trackingClick) { - return true; - } - - // Prevent phantom clicks on fast double-tap (issue #36) - if ((event.timeStamp - this.lastClickTime) < this.tapDelay) { - this.cancelNextClick = true; - return true; - } - - // Reset to prevent wrong click cancel on input (issue #156). - this.cancelNextClick = false; - - this.lastClickTime = event.timeStamp; - - trackingClickStart = this.trackingClickStart; - this.trackingClick = false; - this.trackingClickStart = 0; - - // On some iOS devices, the targetElement supplied with the event is invalid if the layer - // is performing a transition or scroll, and has to be re-detected manually. Note that - // for this to function correctly, it must be called *after* the event target is checked! - // See issue #57; also filed as rdar://13048589 . - if (deviceIsIOSWithBadTarget) { - touch = event.changedTouches[0]; - - // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null - targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement; - targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent; - } - - targetTagName = targetElement.tagName.toLowerCase(); - if (targetTagName === 'label') { - forElement = this.findControl(targetElement); - if (forElement) { - this.focus(targetElement); - if (deviceIsAndroid) { - return false; - } - - targetElement = forElement; - } - } else if (this.needsFocus(targetElement)) { - - // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through. - // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37). - if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) { - this.targetElement = null; - return false; - } - - this.focus(targetElement); - this.sendClick(targetElement, event); - - // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open. - // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others) - if (!deviceIsIOS || targetTagName !== 'select') { - this.targetElement = null; - event.preventDefault(); - } - - return false; - } - - if (deviceIsIOS && !deviceIsIOS4) { - - // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled - // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42). - scrollParent = targetElement.fastClickScrollParent; - if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) { - return true; - } - } - - // Prevent the actual click from going though - unless the target node is marked as requiring - // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted. - if (!this.needsClick(targetElement)) { - event.preventDefault(); - this.sendClick(targetElement, event); - } - - return false; -}; - - -/** - * On touch cancel, stop tracking the click. - * - * @returns {void} - */ -FastClick.prototype.onTouchCancel = function() { - 'use strict'; - this.trackingClick = false; - this.targetElement = null; -}; - - -/** - * Determine mouse events which should be permitted. - * - * @param {Event} event - * @returns {boolean} - */ -FastClick.prototype.onMouse = function(event) { - 'use strict'; - - // If a target element was never set (because a touch event was never fired) allow the event - if (!this.targetElement) { - return true; - } - - if (event.forwardedTouchEvent) { - return true; - } - - // Programmatically generated events targeting a specific element should be permitted - if (!event.cancelable) { - return true; - } - - // Derive and check the target element to see whether the mouse event needs to be permitted; - // unless explicitly enabled, prevent non-touch click events from triggering actions, - // to prevent ghost/doubleclicks. - if (!this.needsClick(this.targetElement) || this.cancelNextClick) { - - // Prevent any user-added listeners declared on FastClick element from being fired. - if (event.stopImmediatePropagation) { - event.stopImmediatePropagation(); - } else { - - // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) - event.propagationStopped = true; - } - - // Cancel the event - event.stopPropagation(); - event.preventDefault(); - - return false; - } - - // If the mouse event is permitted, return true for the action to go through. - return true; -}; - - -/** - * On actual clicks, determine whether this is a touch-generated click, a click action occurring - * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or - * an actual click which should be permitted. - * - * @param {Event} event - * @returns {boolean} - */ -FastClick.prototype.onClick = function(event) { - 'use strict'; - var permitted; - - // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early. - if (this.trackingClick) { - this.targetElement = null; - this.trackingClick = false; - return true; - } - - // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target. - if (event.target.type === 'submit' && event.detail === 0) { - return true; - } - - permitted = this.onMouse(event); - - // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through. - if (!permitted) { - this.targetElement = null; - } - - // If clicks are permitted, return true for the action to go through. - return permitted; -}; - - -/** - * Remove all FastClick's event listeners. - * - * @returns {void} - */ -FastClick.prototype.destroy = function() { - 'use strict'; - var layer = this.layer; - - if (deviceIsAndroid) { - layer.removeEventListener('mouseover', this.onMouse, true); - layer.removeEventListener('mousedown', this.onMouse, true); - layer.removeEventListener('mouseup', this.onMouse, true); - } - - layer.removeEventListener('click', this.onClick, true); - layer.removeEventListener('touchstart', this.onTouchStart, false); - layer.removeEventListener('touchmove', this.onTouchMove, false); - layer.removeEventListener('touchend', this.onTouchEnd, false); - layer.removeEventListener('touchcancel', this.onTouchCancel, false); -}; - - -/** - * Check whether FastClick is needed. - * - * @param {Element} layer The layer to listen on - */ -FastClick.notNeeded = function(layer) { - 'use strict'; - var metaViewport; - var chromeVersion; - - // Devices that don't support touch don't need FastClick - if (typeof window.ontouchstart === 'undefined') { - return true; - } - - // Chrome version - zero for other browsers - chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1]; - - if (chromeVersion) { - - if (deviceIsAndroid) { - metaViewport = document.querySelector('meta[name=viewport]'); - - if (metaViewport) { - // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89) - if (metaViewport.content.indexOf('user-scalable=no') !== -1) { - return true; - } - // Chrome 32 and above with width=device-width or less don't need FastClick - if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) { - return true; - } - } - - // Chrome desktop doesn't need FastClick (issue #15) - } else { - return true; - } - } - - // IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97) - if (layer.style.msTouchAction === 'none') { - return true; - } - - return false; -}; - - -/** - * Factory method for creating a FastClick object - * - * @param {Element} layer The layer to listen on - * @param {Object} options The options to override the defaults - */ -FastClick.attach = function(layer, options) { - 'use strict'; - return new FastClick(layer, options); -}; - - -if (typeof define !== 'undefined' && define.amd) { - - // AMD. Register as an anonymous module. - define(function() { - 'use strict'; - return FastClick; - }); -} else if (typeof module !== 'undefined' && module.exports) { - module.exports = FastClick.attach; - module.exports.FastClick = FastClick; -} else { - window.FastClick = FastClick; -} diff --git a/site/public/assets/javascripts/vendor/flickity.pkgd.js b/site/public/assets/javascripts/vendor/flickity.pkgd.js deleted file mode 100644 index 0471fa5..0000000 --- a/site/public/assets/javascripts/vendor/flickity.pkgd.js +++ /dev/null @@ -1,5090 +0,0 @@ -/*! - * Flickity PACKAGED v1.0.1 - * Touch, responsive, flickable galleries - * - * Licensed GPLv3 for open source use - * or Flickity Commercial License for commercial use - * - * http://flickity.metafizzy.co - * Copyright 2015 Metafizzy - */ - -/** - * Bridget makes jQuery widgets - * v1.1.0 - * MIT license - */ - -( function( window ) { - - - -// -------------------------- utils -------------------------- // - -var slice = Array.prototype.slice; - -function noop() {} - -// -------------------------- definition -------------------------- // - -function defineBridget( $ ) { - -// bail if no jQuery -if ( !$ ) { - return; -} - -// -------------------------- addOptionMethod -------------------------- // - -/** - * adds option method -> $().plugin('option', {...}) - * @param {Function} PluginClass - constructor class - */ -function addOptionMethod( PluginClass ) { - // don't overwrite original option method - if ( PluginClass.prototype.option ) { - return; - } - - // option setter - PluginClass.prototype.option = function( opts ) { - // bail out if not an object - if ( !$.isPlainObject( opts ) ){ - return; - } - this.options = $.extend( true, this.options, opts ); - }; -} - -// -------------------------- plugin bridge -------------------------- // - -// helper function for logging errors -// $.error breaks jQuery chaining -var logError = typeof console === 'undefined' ? noop : - function( message ) { - console.error( message ); - }; - -/** - * jQuery plugin bridge, access methods like $elem.plugin('method') - * @param {String} namespace - plugin name - * @param {Function} PluginClass - constructor class - */ -function bridge( namespace, PluginClass ) { - // add to jQuery fn namespace - $.fn[ namespace ] = function( options ) { - if ( typeof options === 'string' ) { - // call plugin method when first argument is a string - // get arguments for method - var args = slice.call( arguments, 1 ); - - for ( var i=0, len = this.length; i < len; i++ ) { - var elem = this[i]; - var instance = $.data( elem, namespace ); - if ( !instance ) { - logError( "cannot call methods on " + namespace + " prior to initialization; " + - "attempted to call '" + options + "'" ); - continue; - } - if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) { - logError( "no such method '" + options + "' for " + namespace + " instance" ); - continue; - } - - // trigger method with arguments - var returnValue = instance[ options ].apply( instance, args ); - - // break look and return first value if provided - if ( returnValue !== undefined ) { - return returnValue; - } - } - // return this if no return value - return this; - } else { - return this.each( function() { - var instance = $.data( this, namespace ); - if ( instance ) { - // apply options & init - instance.option( options ); - instance._init(); - } else { - // initialize new instance - instance = new PluginClass( this, options ); - $.data( this, namespace, instance ); - } - }); - } - }; - -} - -// -------------------------- bridget -------------------------- // - -/** - * converts a Prototypical class into a proper jQuery plugin - * the class must have a ._init method - * @param {String} namespace - plugin name, used in $().pluginName - * @param {Function} PluginClass - constructor class - */ -$.bridget = function( namespace, PluginClass ) { - addOptionMethod( PluginClass ); - bridge( namespace, PluginClass ); -}; - -return $.bridget; - -} - -// transport -if ( typeof define === 'function' && define.amd ) { - // AMD - define( 'jquery-bridget/jquery.bridget',[ 'jquery' ], defineBridget ); -} else if ( typeof exports === 'object' ) { - defineBridget( require('jquery') ); -} else { - // get jquery from browser global - defineBridget( window.jQuery ); -} - -})( window ); - -/*! - * classie v1.0.1 - * class helper functions - * from bonzo https://github.com/ded/bonzo - * MIT license - * - * classie.has( elem, 'my-class' ) -> true/false - * classie.add( elem, 'my-new-class' ) - * classie.remove( elem, 'my-unwanted-class' ) - * classie.toggle( elem, 'my-class' ) - */ - -/*jshint browser: true, strict: true, undef: true, unused: true */ -/*global define: false, module: false */ - -( function( window ) { - - - -// class helper functions from bonzo https://github.com/ded/bonzo - -function classReg( className ) { - return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); -} - -// classList support for class management -// altho to be fair, the api sucks because it won't accept multiple classes at once -var hasClass, addClass, removeClass; - -if ( 'classList' in document.documentElement ) { - hasClass = function( elem, c ) { - return elem.classList.contains( c ); - }; - addClass = function( elem, c ) { - elem.classList.add( c ); - }; - removeClass = function( elem, c ) { - elem.classList.remove( c ); - }; -} -else { - hasClass = function( elem, c ) { - return classReg( c ).test( elem.className ); - }; - addClass = function( elem, c ) { - if ( !hasClass( elem, c ) ) { - elem.className = elem.className + ' ' + c; - } - }; - removeClass = function( elem, c ) { - elem.className = elem.className.replace( classReg( c ), ' ' ); - }; -} - -function toggleClass( elem, c ) { - var fn = hasClass( elem, c ) ? removeClass : addClass; - fn( elem, c ); -} - -var classie = { - // full names - hasClass: hasClass, - addClass: addClass, - removeClass: removeClass, - toggleClass: toggleClass, - // short names - has: hasClass, - add: addClass, - remove: removeClass, - toggle: toggleClass -}; - -// transport -if ( typeof define === 'function' && define.amd ) { - // AMD - define( 'classie/classie',classie ); -} else if ( typeof exports === 'object' ) { - // CommonJS - module.exports = classie; -} else { - // browser global - window.classie = classie; -} - -})( window ); - -/*! - * EventEmitter v4.2.11 - git.io/ee - * Unlicense - http://unlicense.org/ - * Oliver Caldwell - http://oli.me.uk/ - * @preserve - */ - -;(function () { - - - /** - * Class for managing events. - * Can be extended to provide event functionality in other classes. - * - * @class EventEmitter Manages event registering and emitting. - */ - function EventEmitter() {} - - // Shortcuts to improve speed and size - var proto = EventEmitter.prototype; - var exports = this; - var originalGlobalValue = exports.EventEmitter; - - /** - * Finds the index of the listener for the event in its storage array. - * - * @param {Function[]} listeners Array of listeners to search through. - * @param {Function} listener Method to look for. - * @return {Number} Index of the specified listener, -1 if not found - * @api private - */ - function indexOfListener(listeners, listener) { - var i = listeners.length; - while (i--) { - if (listeners[i].listener === listener) { - return i; - } - } - - return -1; - } - - /** - * Alias a method while keeping the context correct, to allow for overwriting of target method. - * - * @param {String} name The name of the target method. - * @return {Function} The aliased method - * @api private - */ - function alias(name) { - return function aliasClosure() { - return this[name].apply(this, arguments); - }; - } - - /** - * Returns the listener array for the specified event. - * Will initialise the event object and listener arrays if required. - * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them. - * Each property in the object response is an array of listener functions. - * - * @param {String|RegExp} evt Name of the event to return the listeners from. - * @return {Function[]|Object} All listener functions for the event. - */ - proto.getListeners = function getListeners(evt) { - var events = this._getEvents(); - var response; - var key; - - // Return a concatenated array of all matching events if - // the selector is a regular expression. - if (evt instanceof RegExp) { - response = {}; - for (key in events) { - if (events.hasOwnProperty(key) && evt.test(key)) { - response[key] = events[key]; - } - } - } - else { - response = events[evt] || (events[evt] = []); - } - - return response; - }; - - /** - * Takes a list of listener objects and flattens it into a list of listener functions. - * - * @param {Object[]} listeners Raw listener objects. - * @return {Function[]} Just the listener functions. - */ - proto.flattenListeners = function flattenListeners(listeners) { - var flatListeners = []; - var i; - - for (i = 0; i < listeners.length; i += 1) { - flatListeners.push(listeners[i].listener); - } - - return flatListeners; - }; - - /** - * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful. - * - * @param {String|RegExp} evt Name of the event to return the listeners from. - * @return {Object} All listener functions for an event in an object. - */ - proto.getListenersAsObject = function getListenersAsObject(evt) { - var listeners = this.getListeners(evt); - var response; - - if (listeners instanceof Array) { - response = {}; - response[evt] = listeners; - } - - return response || listeners; - }; - - /** - * Adds a listener function to the specified event. - * The listener will not be added if it is a duplicate. - * If the listener returns true then it will be removed after it is called. - * If you pass a regular expression as the event name then the listener will be added to all events that match it. - * - * @param {String|RegExp} evt Name of the event to attach the listener to. - * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.addListener = function addListener(evt, listener) { - var listeners = this.getListenersAsObject(evt); - var listenerIsWrapped = typeof listener === 'object'; - var key; - - for (key in listeners) { - if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) { - listeners[key].push(listenerIsWrapped ? listener : { - listener: listener, - once: false - }); - } - } - - return this; - }; - - /** - * Alias of addListener - */ - proto.on = alias('addListener'); - - /** - * Semi-alias of addListener. It will add a listener that will be - * automatically removed after its first execution. - * - * @param {String|RegExp} evt Name of the event to attach the listener to. - * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.addOnceListener = function addOnceListener(evt, listener) { - return this.addListener(evt, { - listener: listener, - once: true - }); - }; - - /** - * Alias of addOnceListener. - */ - proto.once = alias('addOnceListener'); - - /** - * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad. - * You need to tell it what event names should be matched by a regex. - * - * @param {String} evt Name of the event to create. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.defineEvent = function defineEvent(evt) { - this.getListeners(evt); - return this; - }; - - /** - * Uses defineEvent to define multiple events. - * - * @param {String[]} evts An array of event names to define. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.defineEvents = function defineEvents(evts) { - for (var i = 0; i < evts.length; i += 1) { - this.defineEvent(evts[i]); - } - return this; - }; - - /** - * Removes a listener function from the specified event. - * When passed a regular expression as the event name, it will remove the listener from all events that match it. - * - * @param {String|RegExp} evt Name of the event to remove the listener from. - * @param {Function} listener Method to remove from the event. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.removeListener = function removeListener(evt, listener) { - var listeners = this.getListenersAsObject(evt); - var index; - var key; - - for (key in listeners) { - if (listeners.hasOwnProperty(key)) { - index = indexOfListener(listeners[key], listener); - - if (index !== -1) { - listeners[key].splice(index, 1); - } - } - } - - return this; - }; - - /** - * Alias of removeListener - */ - proto.off = alias('removeListener'); - - /** - * Adds listeners in bulk using the manipulateListeners method. - * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added. - * You can also pass it a regular expression to add the array of listeners to all events that match it. - * Yeah, this function does quite a bit. That's probably a bad thing. - * - * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once. - * @param {Function[]} [listeners] An optional array of listener functions to add. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.addListeners = function addListeners(evt, listeners) { - // Pass through to manipulateListeners - return this.manipulateListeners(false, evt, listeners); - }; - - /** - * Removes listeners in bulk using the manipulateListeners method. - * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. - * You can also pass it an event name and an array of listeners to be removed. - * You can also pass it a regular expression to remove the listeners from all events that match it. - * - * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once. - * @param {Function[]} [listeners] An optional array of listener functions to remove. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.removeListeners = function removeListeners(evt, listeners) { - // Pass through to manipulateListeners - return this.manipulateListeners(true, evt, listeners); - }; - - /** - * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level. - * The first argument will determine if the listeners are removed (true) or added (false). - * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. - * You can also pass it an event name and an array of listeners to be added/removed. - * You can also pass it a regular expression to manipulate the listeners of all events that match it. - * - * @param {Boolean} remove True if you want to remove listeners, false if you want to add. - * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once. - * @param {Function[]} [listeners] An optional array of listener functions to add/remove. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) { - var i; - var value; - var single = remove ? this.removeListener : this.addListener; - var multiple = remove ? this.removeListeners : this.addListeners; - - // If evt is an object then pass each of its properties to this method - if (typeof evt === 'object' && !(evt instanceof RegExp)) { - for (i in evt) { - if (evt.hasOwnProperty(i) && (value = evt[i])) { - // Pass the single listener straight through to the singular method - if (typeof value === 'function') { - single.call(this, i, value); - } - else { - // Otherwise pass back to the multiple function - multiple.call(this, i, value); - } - } - } - } - else { - // So evt must be a string - // And listeners must be an array of listeners - // Loop over it and pass each one to the multiple method - i = listeners.length; - while (i--) { - single.call(this, evt, listeners[i]); - } - } - - return this; - }; - - /** - * Removes all listeners from a specified event. - * If you do not specify an event then all listeners will be removed. - * That means every event will be emptied. - * You can also pass a regex to remove all events that match it. - * - * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.removeEvent = function removeEvent(evt) { - var type = typeof evt; - var events = this._getEvents(); - var key; - - // Remove different things depending on the state of evt - if (type === 'string') { - // Remove all listeners for the specified event - delete events[evt]; - } - else if (evt instanceof RegExp) { - // Remove all events matching the regex. - for (key in events) { - if (events.hasOwnProperty(key) && evt.test(key)) { - delete events[key]; - } - } - } - else { - // Remove all listeners in all events - delete this._events; - } - - return this; - }; - - /** - * Alias of removeEvent. - * - * Added to mirror the node API. - */ - proto.removeAllListeners = alias('removeEvent'); - - /** - * Emits an event of your choice. - * When emitted, every listener attached to that event will be executed. - * If you pass the optional argument array then those arguments will be passed to every listener upon execution. - * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately. - * So they will not arrive within the array on the other side, they will be separate. - * You can also pass a regular expression to emit to all events that match it. - * - * @param {String|RegExp} evt Name of the event to emit and execute listeners for. - * @param {Array} [args] Optional array of arguments to be passed to each listener. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.emitEvent = function emitEvent(evt, args) { - var listeners = this.getListenersAsObject(evt); - var listener; - var i; - var key; - var response; - - for (key in listeners) { - if (listeners.hasOwnProperty(key)) { - i = listeners[key].length; - - while (i--) { - // If the listener returns true then it shall be removed from the event - // The function is executed either with a basic call or an apply if there is an args array - listener = listeners[key][i]; - - if (listener.once === true) { - this.removeListener(evt, listener.listener); - } - - response = listener.listener.apply(this, args || []); - - if (response === this._getOnceReturnValue()) { - this.removeListener(evt, listener.listener); - } - } - } - } - - return this; - }; - - /** - * Alias of emitEvent - */ - proto.trigger = alias('emitEvent'); - - /** - * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on. - * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it. - * - * @param {String|RegExp} evt Name of the event to emit and execute listeners for. - * @param {...*} Optional additional arguments to be passed to each listener. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.emit = function emit(evt) { - var args = Array.prototype.slice.call(arguments, 1); - return this.emitEvent(evt, args); - }; - - /** - * Sets the current value to check against when executing listeners. If a - * listeners return value matches the one set here then it will be removed - * after execution. This value defaults to true. - * - * @param {*} value The new value to check for when executing listeners. - * @return {Object} Current instance of EventEmitter for chaining. - */ - proto.setOnceReturnValue = function setOnceReturnValue(value) { - this._onceReturnValue = value; - return this; - }; - - /** - * Fetches the current value to check against when executing listeners. If - * the listeners return value matches this one then it should be removed - * automatically. It will return true by default. - * - * @return {*|Boolean} The current value to check for or the default, true. - * @api private - */ - proto._getOnceReturnValue = function _getOnceReturnValue() { - if (this.hasOwnProperty('_onceReturnValue')) { - return this._onceReturnValue; - } - else { - return true; - } - }; - - /** - * Fetches the events object and creates one if required. - * - * @return {Object} The events storage object. - * @api private - */ - proto._getEvents = function _getEvents() { - return this._events || (this._events = {}); - }; - - /** - * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version. - * - * @return {Function} Non conflicting EventEmitter class. - */ - EventEmitter.noConflict = function noConflict() { - exports.EventEmitter = originalGlobalValue; - return EventEmitter; - }; - - // Expose the class either via AMD, CommonJS or the global object - if (typeof define === 'function' && define.amd) { - define('eventEmitter/EventEmitter',[],function () { - return EventEmitter; - }); - } - else if (typeof module === 'object' && module.exports){ - module.exports = EventEmitter; - } - else { - exports.EventEmitter = EventEmitter; - } -}.call(this)); - -/*! - * eventie v1.0.6 - * event binding helper - * eventie.bind( elem, 'click', myFn ) - * eventie.unbind( elem, 'click', myFn ) - * MIT license - */ - -/*jshint browser: true, undef: true, unused: true */ -/*global define: false, module: false */ - -( function( window ) { - - - -var docElem = document.documentElement; - -var bind = function() {}; - -function getIEEvent( obj ) { - var event = window.event; - // add event.target - event.target = event.target || event.srcElement || obj; - return event; -} - -if ( docElem.addEventListener ) { - bind = function( obj, type, fn ) { - obj.addEventListener( type, fn, false ); - }; -} else if ( docElem.attachEvent ) { - bind = function( obj, type, fn ) { - obj[ type + fn ] = fn.handleEvent ? - function() { - var event = getIEEvent( obj ); - fn.handleEvent.call( fn, event ); - } : - function() { - var event = getIEEvent( obj ); - fn.call( obj, event ); - }; - obj.attachEvent( "on" + type, obj[ type + fn ] ); - }; -} - -var unbind = function() {}; - -if ( docElem.removeEventListener ) { - unbind = function( obj, type, fn ) { - obj.removeEventListener( type, fn, false ); - }; -} else if ( docElem.detachEvent ) { - unbind = function( obj, type, fn ) { - obj.detachEvent( "on" + type, obj[ type + fn ] ); - try { - delete obj[ type + fn ]; - } catch ( err ) { - // can't delete window object properties - obj[ type + fn ] = undefined; - } - }; -} - -var eventie = { - bind: bind, - unbind: unbind -}; - -// ----- module definition ----- // - -if ( typeof define === 'function' && define.amd ) { - // AMD - define( 'eventie/eventie',eventie ); -} else if ( typeof exports === 'object' ) { - // CommonJS - module.exports = eventie; -} else { - // browser global - window.eventie = eventie; -} - -})( window ); - -/*! - * getStyleProperty v1.0.4 - * original by kangax - * http://perfectionkills.com/feature-testing-css-properties/ - * MIT license - */ - -/*jshint browser: true, strict: true, undef: true */ -/*global define: false, exports: false, module: false */ - -( function( window ) { - - - -var prefixes = 'Webkit Moz ms Ms O'.split(' '); -var docElemStyle = document.documentElement.style; - -function getStyleProperty( propName ) { - if ( !propName ) { - return; - } - - // test standard property first - if ( typeof docElemStyle[ propName ] === 'string' ) { - return propName; - } - - // capitalize - propName = propName.charAt(0).toUpperCase() + propName.slice(1); - - // test vendor specific properties - var prefixed; - for ( var i=0, len = prefixes.length; i < len; i++ ) { - prefixed = prefixes[i] + propName; - if ( typeof docElemStyle[ prefixed ] === 'string' ) { - return prefixed; - } - } -} - -// transport -if ( typeof define === 'function' && define.amd ) { - // AMD - define( 'get-style-property/get-style-property',[],function() { - return getStyleProperty; - }); -} else if ( typeof exports === 'object' ) { - // CommonJS for Component - module.exports = getStyleProperty; -} else { - // browser global - window.getStyleProperty = getStyleProperty; -} - -})( window ); - -/*! - * getSize v1.2.2 - * measure size of elements - * MIT license - */ - -/*jshint browser: true, strict: true, undef: true, unused: true */ -/*global define: false, exports: false, require: false, module: false, console: false */ - -( function( window, undefined ) { - - - -// -------------------------- helpers -------------------------- // - -// get a number from a string, not a percentage -function getStyleSize( value ) { - var num = parseFloat( value ); - // not a percent like '100%', and a number - var isValid = value.indexOf('%') === -1 && !isNaN( num ); - return isValid && num; -} - -function noop() {} - -var logError = typeof console === 'undefined' ? noop : - function( message ) { - console.error( message ); - }; - -// -------------------------- measurements -------------------------- // - -var measurements = [ - 'paddingLeft', - 'paddingRight', - 'paddingTop', - 'paddingBottom', - 'marginLeft', - 'marginRight', - 'marginTop', - 'marginBottom', - 'borderLeftWidth', - 'borderRightWidth', - 'borderTopWidth', - 'borderBottomWidth' -]; - -function getZeroSize() { - var size = { - width: 0, - height: 0, - innerWidth: 0, - innerHeight: 0, - outerWidth: 0, - outerHeight: 0 - }; - for ( var i=0, len = measurements.length; i < len; i++ ) { - var measurement = measurements[i]; - size[ measurement ] = 0; - } - return size; -} - - - -function defineGetSize( getStyleProperty ) { - -// -------------------------- setup -------------------------- // - -var isSetup = false; - -var getStyle, boxSizingProp, isBoxSizeOuter; - -/** - * setup vars and functions - * do it on initial getSize(), rather than on script load - * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397 - */ -function setup() { - // setup once - if ( isSetup ) { - return; - } - isSetup = true; - - var getComputedStyle = window.getComputedStyle; - getStyle = ( function() { - var getStyleFn = getComputedStyle ? - function( elem ) { - return getComputedStyle( elem, null ); - } : - function( elem ) { - return elem.currentStyle; - }; - - return function getStyle( elem ) { - var style = getStyleFn( elem ); - if ( !style ) { - logError( 'Style returned ' + style + - '. Are you running this code in a hidden iframe on Firefox? ' + - 'See http://bit.ly/getsizebug1' ); - } - return style; - }; - })(); - - // -------------------------- box sizing -------------------------- // - - boxSizingProp = getStyleProperty('boxSizing'); - - /** - * WebKit measures the outer-width on style.width on border-box elems - * IE & Firefox measures the inner-width - */ - if ( boxSizingProp ) { - var div = document.createElement('div'); - div.style.width = '200px'; - div.style.padding = '1px 2px 3px 4px'; - div.style.borderStyle = 'solid'; - div.style.borderWidth = '1px 2px 3px 4px'; - div.style[ boxSizingProp ] = 'border-box'; - - var body = document.body || document.documentElement; - body.appendChild( div ); - var style = getStyle( div ); - - isBoxSizeOuter = getStyleSize( style.width ) === 200; - body.removeChild( div ); - } - -} - -// -------------------------- getSize -------------------------- // - -function getSize( elem ) { - setup(); - - // use querySeletor if elem is string - if ( typeof elem === 'string' ) { - elem = document.querySelector( elem ); - } - - // do not proceed on non-objects - if ( !elem || typeof elem !== 'object' || !elem.nodeType ) { - return; - } - - var style = getStyle( elem ); - - // if hidden, everything is 0 - if ( style.display === 'none' ) { - return getZeroSize(); - } - - var size = {}; - size.width = elem.offsetWidth; - size.height = elem.offsetHeight; - - var isBorderBox = size.isBorderBox = !!( boxSizingProp && - style[ boxSizingProp ] && style[ boxSizingProp ] === 'border-box' ); - - // get all measurements - for ( var i=0, len = measurements.length; i < len; i++ ) { - var measurement = measurements[i]; - var value = style[ measurement ]; - value = mungeNonPixel( elem, value ); - var num = parseFloat( value ); - // any 'auto', 'medium' value will be 0 - size[ measurement ] = !isNaN( num ) ? num : 0; - } - - var paddingWidth = size.paddingLeft + size.paddingRight; - var paddingHeight = size.paddingTop + size.paddingBottom; - var marginWidth = size.marginLeft + size.marginRight; - var marginHeight = size.marginTop + size.marginBottom; - var borderWidth = size.borderLeftWidth + size.borderRightWidth; - var borderHeight = size.borderTopWidth + size.borderBottomWidth; - - var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter; - - // overwrite width and height if we can get it from style - var styleWidth = getStyleSize( style.width ); - if ( styleWidth !== false ) { - size.width = styleWidth + - // add padding and border unless it's already including it - ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth ); - } - - var styleHeight = getStyleSize( style.height ); - if ( styleHeight !== false ) { - size.height = styleHeight + - // add padding and border unless it's already including it - ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight ); - } - - size.innerWidth = size.width - ( paddingWidth + borderWidth ); - size.innerHeight = size.height - ( paddingHeight + borderHeight ); - - size.outerWidth = size.width + marginWidth; - size.outerHeight = size.height + marginHeight; - - return size; -} - -// IE8 returns percent values, not pixels -// taken from jQuery's curCSS -function mungeNonPixel( elem, value ) { - // IE8 and has percent value - if ( window.getComputedStyle || value.indexOf('%') === -1 ) { - return value; - } - var style = elem.style; - // Remember the original values - var left = style.left; - var rs = elem.runtimeStyle; - var rsLeft = rs && rs.left; - - // Put in the new values to get a computed value out - if ( rsLeft ) { - rs.left = elem.currentStyle.left; - } - style.left = value; - value = style.pixelLeft; - - // Revert the changed values - style.left = left; - if ( rsLeft ) { - rs.left = rsLeft; - } - - return value; -} - -return getSize; - -} - -// transport -if ( typeof define === 'function' && define.amd ) { - // AMD for RequireJS - define( 'get-size/get-size',[ 'get-style-property/get-style-property' ], defineGetSize ); -} else if ( typeof exports === 'object' ) { - // CommonJS for Component - module.exports = defineGetSize( require('desandro-get-style-property') ); -} else { - // browser global - window.getSize = defineGetSize( window.getStyleProperty ); -} - -})( window ); - -/*! - * docReady v1.0.4 - * Cross browser DOMContentLoaded event emitter - * MIT license - */ - -/*jshint browser: true, strict: true, undef: true, unused: true*/ -/*global define: false, require: false, module: false */ - -( function( window ) { - - - -var document = window.document; -// collection of functions to be triggered on ready -var queue = []; - -function docReady( fn ) { - // throw out non-functions - if ( typeof fn !== 'function' ) { - return; - } - - if ( docReady.isReady ) { - // ready now, hit it - fn(); - } else { - // queue function when ready - queue.push( fn ); - } -} - -docReady.isReady = false; - -// triggered on various doc ready events -function onReady( event ) { - // bail if already triggered or IE8 document is not ready just yet - var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete'; - if ( docReady.isReady || isIE8NotReady ) { - return; - } - - trigger(); -} - -function trigger() { - docReady.isReady = true; - // process queue - for ( var i=0, len = queue.length; i < len; i++ ) { - var fn = queue[i]; - fn(); - } -} - -function defineDocReady( eventie ) { - // trigger ready if page is ready - if ( document.readyState === 'complete' ) { - trigger(); - } else { - // listen for events - eventie.bind( document, 'DOMContentLoaded', onReady ); - eventie.bind( document, 'readystatechange', onReady ); - eventie.bind( window, 'load', onReady ); - } - - return docReady; -} - -// transport -if ( typeof define === 'function' && define.amd ) { - // AMD - define( 'doc-ready/doc-ready',[ 'eventie/eventie' ], defineDocReady ); -} else if ( typeof exports === 'object' ) { - module.exports = defineDocReady( require('eventie') ); -} else { - // browser global - window.docReady = defineDocReady( window.eventie ); -} - -})( window ); - -/** - * matchesSelector v1.0.3 - * matchesSelector( element, '.selector' ) - * MIT license - */ - -/*jshint browser: true, strict: true, undef: true, unused: true */ -/*global define: false, module: false */ - -( function( ElemProto ) { - - - - var matchesMethod = ( function() { - // check for the standard method name first - if ( ElemProto.matches ) { - return 'matches'; - } - // check un-prefixed - if ( ElemProto.matchesSelector ) { - return 'matchesSelector'; - } - // check vendor prefixes - var prefixes = [ 'webkit', 'moz', 'ms', 'o' ]; - - for ( var i=0, len = prefixes.length; i < len; i++ ) { - var prefix = prefixes[i]; - var method = prefix + 'MatchesSelector'; - if ( ElemProto[ method ] ) { - return method; - } - } - })(); - - // ----- match ----- // - - function match( elem, selector ) { - return elem[ matchesMethod ]( selector ); - } - - // ----- appendToFragment ----- // - - function checkParent( elem ) { - // not needed if already has parent - if ( elem.parentNode ) { - return; - } - var fragment = document.createDocumentFragment(); - fragment.appendChild( elem ); - } - - // ----- query ----- // - - // fall back to using QSA - // thx @jonathantneal https://gist.github.com/3062955 - function query( elem, selector ) { - // append to fragment if no parent - checkParent( elem ); - - // match elem with all selected elems of parent - var elems = elem.parentNode.querySelectorAll( selector ); - for ( var i=0, len = elems.length; i < len; i++ ) { - // return true if match - if ( elems[i] === elem ) { - return true; - } - } - // otherwise return false - return false; - } - - // ----- matchChild ----- // - - function matchChild( elem, selector ) { - checkParent( elem ); - return match( elem, selector ); - } - - // ----- matchesSelector ----- // - - var matchesSelector; - - if ( matchesMethod ) { - // IE9 supports matchesSelector, but doesn't work on orphaned elems - // check for that - var div = document.createElement('div'); - var supportsOrphans = match( div, 'div' ); - matchesSelector = supportsOrphans ? match : matchChild; - } else { - matchesSelector = query; - } - - // transport - if ( typeof define === 'function' && define.amd ) { - // AMD - define( 'matches-selector/matches-selector',[],function() { - return matchesSelector; - }); - } else if ( typeof exports === 'object' ) { - module.exports = matchesSelector; - } - else { - // browser global - window.matchesSelector = matchesSelector; - } - -})( Element.prototype ); - -/** - * Fizzy UI utils v1.0.1 - * MIT license - */ - -/*jshint browser: true, undef: true, unused: true, strict: true */ - -( function( window, factory ) { - /*global define: false, module: false, require: false */ - - // universal module definition - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'fizzy-ui-utils/utils',[ - 'doc-ready/doc-ready', - 'matches-selector/matches-selector' - ], function( docReady, matchesSelector ) { - return factory( window, docReady, matchesSelector ); - }); - } else if ( typeof exports == 'object' ) { - // CommonJS - module.exports = factory( - window, - require('doc-ready'), - require('desandro-matches-selector') - ); - } else { - // browser global - window.fizzyUIUtils = factory( - window, - window.docReady, - window.matchesSelector - ); - } - -}( window, function factory( window, docReady, matchesSelector ) { - - - -var utils = {}; - -// ----- extend ----- // - -// extends objects -utils.extend = function( a, b ) { - for ( var prop in b ) { - a[ prop ] = b[ prop ]; - } - return a; -}; - -// ----- modulo ----- // - -utils.modulo = function( num, div ) { - return ( ( num % div ) + div ) % div; -}; - -// ----- isArray ----- // - -var objToString = Object.prototype.toString; -utils.isArray = function( obj ) { - return objToString.call( obj ) == '[object Array]'; -}; - -// ----- makeArray ----- // - -// turn element or nodeList into an array -utils.makeArray = function( obj ) { - var ary = []; - if ( utils.isArray( obj ) ) { - // use object if already an array - ary = obj; - } else if ( obj && typeof obj.length == 'number' ) { - // convert nodeList to array - for ( var i=0, len = obj.length; i < len; i++ ) { - ary.push( obj[i] ); - } - } else { - // array of single index - ary.push( obj ); - } - return ary; -}; - -// ----- indexOf ----- // - -// index of helper cause IE8 -utils.indexOf = Array.prototype.indexOf ? function( ary, obj ) { - return ary.indexOf( obj ); - } : function( ary, obj ) { - for ( var i=0, len = ary.length; i < len; i++ ) { - if ( ary[i] === obj ) { - return i; - } - } - return -1; - }; - -// ----- removeFrom ----- // - -utils.removeFrom = function( ary, obj ) { - var index = utils.indexOf( ary, obj ); - if ( index != -1 ) { - ary.splice( index, 1 ); - } -}; - -// ----- isElement ----- // - -// http://stackoverflow.com/a/384380/182183 -utils.isElement = ( typeof HTMLElement == 'function' || typeof HTMLElement == 'object' ) ? - function isElementDOM2( obj ) { - return obj instanceof HTMLElement; - } : - function isElementQuirky( obj ) { - return obj && typeof obj == 'object' && - obj.nodeType == 1 && typeof obj.nodeName == 'string'; - }; - -// ----- setText ----- // - -utils.setText = ( function() { - var setTextProperty; - function setText( elem, text ) { - // only check setTextProperty once - setTextProperty = setTextProperty || ( document.documentElement.textContent !== undefined ? 'textContent' : 'innerText' ); - elem[ setTextProperty ] = text; - } - return setText; -})(); - -// ----- getParent ----- // - -utils.getParent = function( elem, selector ) { - while ( elem != document.body ) { - elem = elem.parentNode; - if ( matchesSelector( elem, selector ) ) { - return elem; - } - } -}; - -// ----- getQueryElement ----- // - -// use element as selector string -utils.getQueryElement = function( elem ) { - if ( typeof elem == 'string' ) { - return document.querySelector( elem ); - } - return elem; -}; - -// ----- handleEvent ----- // - -// enable .ontype to trigger from .addEventListener( elem, 'type' ) -utils.handleEvent = function( event ) { - var method = 'on' + event.type; - if ( this[ method ] ) { - this[ method ]( event ); - } -}; - -// ----- filterFindElements ----- // - -utils.filterFindElements = function( elems, selector ) { - // make array of elems - elems = utils.makeArray( elems ); - var ffElems = []; - - for ( var i=0, len = elems.length; i < len; i++ ) { - var elem = elems[i]; - // check that elem is an actual element - if ( !utils.isElement( elem ) ) { - continue; - } - // filter & find items if we have a selector - if ( selector ) { - // filter siblings - if ( matchesSelector( elem, selector ) ) { - ffElems.push( elem ); - } - // find children - var childElems = elem.querySelectorAll( selector ); - // concat childElems to filterFound array - for ( var j=0, jLen = childElems.length; j < jLen; j++ ) { - ffElems.push( childElems[j] ); - } - } else { - ffElems.push( elem ); - } - } - - return ffElems; -}; - -// ----- debounceMethod ----- // - -utils.debounceMethod = function( _class, methodName, threshold ) { - // original method - var method = _class.prototype[ methodName ]; - var timeoutName = methodName + 'Timeout'; - - _class.prototype[ methodName ] = function() { - var timeout = this[ timeoutName ]; - if ( timeout ) { - clearTimeout( timeout ); - } - var args = arguments; - - var _this = this; - this[ timeoutName ] = setTimeout( function() { - method.apply( _this, args ); - delete _this[ timeoutName ]; - }, threshold || 100 ); - }; -}; - -// ----- htmlInit ----- // - -// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/ -utils.toDashed = function( str ) { - return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) { - return $1 + '-' + $2; - }).toLowerCase(); -}; - -var console = window.console; -/** - * allow user to initialize classes via .js-namespace class - * htmlInit( Widget, 'widgetName' ) - * options are parsed from data-namespace-option attribute - */ -utils.htmlInit = function( WidgetClass, namespace ) { - docReady( function() { - var dashedNamespace = utils.toDashed( namespace ); - var elems = document.querySelectorAll( '.js-' + dashedNamespace ); - var dataAttr = 'data-' + dashedNamespace + '-options'; - - for ( var i=0, len = elems.length; i < len; i++ ) { - var elem = elems[i]; - var attr = elem.getAttribute( dataAttr ); - var options; - try { - options = attr && JSON.parse( attr ); - } catch ( error ) { - // log error, do not initialize - if ( console ) { - console.error( 'Error parsing ' + dataAttr + ' on ' + - elem.nodeName.toLowerCase() + ( elem.id ? '#' + elem.id : '' ) + ': ' + - error ); - } - continue; - } - // initialize - var instance = new WidgetClass( elem, options ); - // make available via $().data('layoutname') - var jQuery = window.jQuery; - if ( jQuery ) { - jQuery.data( elem, namespace, instance ); - } - } - }); -}; - -// ----- ----- // - -return utils; - -})); - -( function( window, factory ) { - - // universal module definition - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'flickity/js/cell',[ - 'get-size/get-size' - ], function( getSize ) { - return factory( window, getSize ); - }); - } else if ( typeof exports == 'object' ) { - // CommonJS - module.exports = factory( - window, - require('get-size') - ); - } else { - // browser global - window.Flickity = window.Flickity || {}; - window.Flickity.Cell = factory( - window, - window.getSize - ); - } - -}( window, function factory( window, getSize ) { - - - -function Cell( elem, parent ) { - this.element = elem; - this.parent = parent; - - this.create(); -} - -var isIE8 = 'attachEvent' in window; - -Cell.prototype.create = function() { - this.element.style.position = 'absolute'; - // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183 - if ( isIE8 ) { - this.element.setAttribute( 'unselectable', 'on' ); - } - this.x = 0; - this.shift = 0; -}; - -Cell.prototype.destroy = function() { - // reset style - this.element.style.position = ''; - var side = this.parent.originSide; - this.element.style[ side ] = ''; -}; - -Cell.prototype.getSize = function() { - this.size = getSize( this.element ); -}; - -Cell.prototype.setPosition = function( x ) { - this.x = x; - this.setDefaultTarget(); - this.renderPosition( x ); -}; - -Cell.prototype.setDefaultTarget = function() { - var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight'; - this.target = this.x + this.size[ marginProperty ] + - this.size.width * this.parent.cellAlign; -}; - -Cell.prototype.renderPosition = function( x ) { - // render position of cell with in slider - var side = this.parent.originSide; - this.element.style[ side ] = this.parent.getPositionValue( x ); -}; - -/** - * @param {Integer} factor - 0, 1, or -1 -**/ -Cell.prototype.wrapShift = function( shift ) { - this.shift = shift; - this.renderPosition( this.x + this.parent.slideableWidth * shift ); -}; - -Cell.prototype.remove = function() { - this.element.parentNode.removeChild( this.element ); -}; - -return Cell; - -})); - -( function( window, factory ) { - - // universal module definition - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'flickity/js/animate',[ - 'get-style-property/get-style-property', - 'fizzy-ui-utils/utils' - ], function( getStyleProperty, utils ) { - return factory( window, getStyleProperty, utils ); - }); - } else if ( typeof exports == 'object' ) { - // CommonJS - module.exports = factory( - window, - require('desandro-get-style-property'), - require('fizzy-ui-utils') - ); - } else { - // browser global - window.Flickity = window.Flickity || {}; - window.Flickity.animatePrototype = factory( - window, - window.getStyleProperty, - window.fizzyUIUtils - ); - } - -}( window, function factory( window, getStyleProperty, utils ) { - - - -// -------------------------- requestAnimationFrame -------------------------- // - -// https://gist.github.com/1866474 - -var lastTime = 0; -var prefixes = 'webkit moz ms o'.split(' '); -// get unprefixed rAF and cAF, if present -var requestAnimationFrame = window.requestAnimationFrame; -var cancelAnimationFrame = window.cancelAnimationFrame; -// loop through vendor prefixes and get prefixed rAF and cAF -var prefix; -for( var i = 0; i < prefixes.length; i++ ) { - if ( requestAnimationFrame && cancelAnimationFrame ) { - break; - } - prefix = prefixes[i]; - requestAnimationFrame = requestAnimationFrame || window[ prefix + 'RequestAnimationFrame' ]; - cancelAnimationFrame = cancelAnimationFrame || window[ prefix + 'CancelAnimationFrame' ] || - window[ prefix + 'CancelRequestAnimationFrame' ]; -} - -// fallback to setTimeout and clearTimeout if either request/cancel is not supported -if ( !requestAnimationFrame || !cancelAnimationFrame ) { - requestAnimationFrame = function( callback ) { - var currTime = new Date().getTime(); - var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) ); - var id = window.setTimeout( function() { - callback( currTime + timeToCall ); - }, timeToCall ); - lastTime = currTime + timeToCall; - return id; - }; - - cancelAnimationFrame = function( id ) { - window.clearTimeout( id ); - }; -} - -// -------------------------- animate -------------------------- // - -var proto = {}; - -proto.startAnimation = function() { - if ( this.isAnimating ) { - return; - } - - this.isAnimating = true; - this.restingFrames = 0; - this.animate(); -}; - -proto.animate = function() { - this.applySelectedAttraction(); - - var previousX = this.x; - - this.integratePhysics(); - this.positionSlider(); - this.settle( previousX ); - // animate next frame - if ( this.isAnimating ) { - var _this = this; - requestAnimationFrame( function animateFrame() { - _this.animate(); - }); - } - - /** / - // log animation frame rate - var now = new Date(); - if ( this.then ) { - console.log( ~~( 1000 / (now-this.then)) + 'fps' ) - } - this.then = now; - /**/ -}; - - -var transformProperty = getStyleProperty('transform'); -var is3d = !!getStyleProperty('perspective'); - -proto.positionSlider = function() { - var x = this.x; - // wrap position around - if ( this.options.wrapAround && this.cells.length > 1 ) { - x = utils.modulo( x, this.slideableWidth ); - x = x - this.slideableWidth; - this.shiftWrapCells( x ); - } - - x = x + this.cursorPosition; - - // reverse if right-to-left and using transform - x = this.options.rightToLeft && transformProperty ? -x : x; - - var value = this.getPositionValue( x ); - - if ( transformProperty ) { - // use 3D tranforms for hardware acceleration on iOS - // but use 2D when settled, for better font-rendering - this.slider.style[ transformProperty ] = is3d && this.isAnimating ? - 'translate3d(' + value + ',0,0)' : 'translateX(' + value + ')'; - } else { - this.slider.style[ this.originSide ] = value; - } -}; - -proto.positionSliderAtSelected = function() { - if ( !this.cells.length ) { - return; - } - var selectedCell = this.cells[ this.selectedIndex ]; - this.x = -selectedCell.target; - this.positionSlider(); -}; - -proto.getPositionValue = function( position ) { - if ( this.options.percentPosition ) { - // percent position, round to 2 digits, like 12.34% - return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 )+ '%'; - } else { - // pixel positioning - return Math.round( position ) + 'px'; - } -}; - -proto.settle = function( previousX ) { - // keep track of frames where x hasn't moved - if ( !this.isPointerDown && Math.round( this.x * 100 ) == Math.round( previousX * 100 ) ) { - this.restingFrames++; - } - // stop animating if resting for 3 or more frames - if ( this.restingFrames > 2 ) { - this.isAnimating = false; - delete this.isFreeScrolling; - // render position with translateX when settled - if ( is3d ) { - this.positionSlider(); - } - this.dispatchEvent('settle'); - } -}; - -proto.shiftWrapCells = function( x ) { - // shift before cells - var beforeGap = this.cursorPosition + x; - this._shiftCells( this.beforeShiftCells, beforeGap, -1 ); - // shift after cells - var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition ); - this._shiftCells( this.afterShiftCells, afterGap, 1 ); -}; - -proto._shiftCells = function( cells, gap, shift ) { - for ( var i=0, len = cells.length; i < len; i++ ) { - var cell = cells[i]; - var cellShift = gap > 0 ? shift : 0; - cell.wrapShift( cellShift ); - gap -= cell.size.outerWidth; - } -}; - -proto._unshiftCells = function( cells ) { - if ( !cells || !cells.length ) { - return; - } - for ( var i=0, len = cells.length; i < len; i++ ) { - cells[i].wrapShift( 0 ); - } -}; - -// -------------------------- physics -------------------------- // - -proto.integratePhysics = function() { - this.velocity += this.accel; - this.x += this.velocity; - this.velocity *= this.getFrictionFactor(); - // reset acceleration - this.accel = 0; -}; - -proto.applyForce = function( force ) { - this.accel += force; -}; - -proto.getFrictionFactor = function() { - return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ]; -}; - - -proto.getRestingPosition = function() { - // my thanks to Steven Wittens, who simplified this math greatly - return this.x + this.velocity / ( 1 - this.getFrictionFactor() ); -}; - - -proto.applySelectedAttraction = function() { - // do not attract if pointer down or no cells - var len = this.cells.length; - if ( this.isPointerDown || this.isFreeScrolling || !len ) { - return; - } - var cell = this.cells[ this.selectedIndex ]; - var wrap = this.options.wrapAround && len > 1 ? - this.slideableWidth * Math.floor( this.selectedIndex / len ) : 0; - var distance = ( cell.target + wrap ) * -1 - this.x; - var force = distance * this.options.selectedAttraction; - this.applyForce( force ); -}; - -return proto; - -})); - -/*! - * Flickity v1.0.1 - * Touch, responsive, flickable galleries - * - * Licensed GPLv3 for open source use - * or Flickity Commercial License for commercial use - * - * http://flickity.metafizzy.co - * Copyright 2015 Metafizzy - */ - -( function( window, factory ) { - - // universal module definition - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'flickity/js/flickity',[ - 'classie/classie', - 'eventEmitter/EventEmitter', - 'eventie/eventie', - 'get-size/get-size', - 'fizzy-ui-utils/utils', - './cell', - './animate' - ], function( classie, EventEmitter, eventie, getSize, utils, Cell, animatePrototype ) { - return factory( window, classie, EventEmitter, eventie, getSize, utils, Cell, animatePrototype ); - }); - } else if ( typeof exports == 'object' ) { - // CommonJS - module.exports = factory( - window, - require('desandro-classie'), - require('wolfy87-eventemitter'), - require('eventie'), - require('get-size'), - require('fizzy-ui-utils'), - require('./cell'), - require('./animate') - ); - } else { - // browser global - var _Flickity = window.Flickity; - - window.Flickity = factory( - window, - window.classie, - window.EventEmitter, - window.eventie, - window.getSize, - window.fizzyUIUtils, - _Flickity.Cell, - _Flickity.animatePrototype - ); - } - -}( window, function factory( window, classie, EventEmitter, eventie, getSize, - utils, Cell, animatePrototype ) { - - - -// vars -var jQuery = window.jQuery; -var getComputedStyle = window.getComputedStyle; -var console = window.console; - -function moveElements( elems, toElem ) { - elems = utils.makeArray( elems ); - while ( elems.length ) { - toElem.appendChild( elems.shift() ); - } -} - -// -------------------------- Flickity -------------------------- // - -// globally unique identifiers -var GUID = 0; -// internal store of all Flickity intances -var instances = {}; - -function Flickity( element, options ) { - var queryElement = utils.getQueryElement( element ); - if ( !queryElement ) { - if ( console ) { - console.error( 'Bad element for Flickity: ' + ( queryElement || element ) ); - } - return; - } - this.element = queryElement; - // add jQuery - if ( jQuery ) { - this.$element = jQuery( this.element ); - } - // options - this.options = utils.extend( {}, this.constructor.defaults ); - this.option( options ); - - // kick things off - this._create(); -} - -Flickity.defaults = { - accessibility: true, - cellAlign: 'center', - // cellSelector: undefined, - // contain: false, - freeScrollFriction: 0.075, // friction when free-scrolling - friction: 0.28, // friction when selecting - // initialIndex: 0, - percentPosition: true, - resize: true, - selectedAttraction: 0.025, - setGallerySize: true - // watchCSS: false, - // wrapAround: false -}; - -// hash of methods triggered on _create() -Flickity.createMethods = []; - -// inherit EventEmitter -utils.extend( Flickity.prototype, EventEmitter.prototype ); - -Flickity.prototype._create = function() { - // add id for Flickity.data - var id = this.guid = ++GUID; - this.element.flickityGUID = id; // expando - instances[ id ] = this; // associate via id - // initial properties - this.selectedIndex = this.options.initialIndex || 0; - // how many frames slider has been in same position - this.restingFrames = 0; - // initial physics properties - this.x = 0; - this.velocity = 0; - this.accel = 0; - this.originSide = this.options.rightToLeft ? 'right' : 'left'; - // create viewport & slider - this.viewport = document.createElement('div'); - this.viewport.className = 'flickity-viewport'; - Flickity.setUnselectable( this.viewport ); - this._createSlider(); - - if ( this.options.resize || this.options.watchCSS ) { - eventie.bind( window, 'resize', this ); - this.isResizeBound = true; - } - - for ( var i=0, len = Flickity.createMethods.length; i < len; i++ ) { - var method = Flickity.createMethods[i]; - this[ method ](); - } - - if ( this.options.watchCSS ) { - this.watchCSS(); - } else { - this.activate(); - } - -}; - -/** - * set options - * @param {Object} opts - */ -Flickity.prototype.option = function( opts ) { - utils.extend( this.options, opts ); -}; - -Flickity.prototype.activate = function() { - if ( this.isActive ) { - return; - } - this.isActive = true; - classie.add( this.element, 'flickity-enabled' ); - if ( this.options.rightToLeft ) { - classie.add( this.element, 'flickity-rtl' ); - } - - // move initial cell elements so they can be loaded as cells - var cellElems = this._filterFindCellElements( this.element.children ); - moveElements( cellElems, this.slider ); - this.viewport.appendChild( this.slider ); - this.element.appendChild( this.viewport ); - - this.getSize(); - // get cells from children - this.reloadCells(); - - if ( this.options.accessibility ) { - // allow element to focusable - this.element.tabIndex = 0; - // listen for key presses - eventie.bind( this.element, 'keydown', this ); - } - - this.emit('activate'); - - this.positionSliderAtSelected(); - this.select( this.selectedIndex ); -}; - -// slider positions the cells -Flickity.prototype._createSlider = function() { - // slider element does all the positioning - var slider = document.createElement('div'); - slider.className = 'flickity-slider'; - slider.style[ this.originSide ] = 0; - this.slider = slider; -}; - -Flickity.prototype._filterFindCellElements = function( elems ) { - return utils.filterFindElements( elems, this.options.cellSelector ); -}; - -// goes through all children -Flickity.prototype.reloadCells = function() { - // collection of item elements - this.cells = this._makeCells( this.slider.children ); - this.positionCells(); - this._getWrapShiftCells(); - this.setGallerySize(); -}; - -/** - * turn elements into Flickity.Cells - * @param {Array or NodeList or HTMLElement} elems - * @returns {Array} items - collection of new Flickity Cells - */ -Flickity.prototype._makeCells = function( elems ) { - var cellElems = this._filterFindCellElements( elems ); - - // create new Flickity for collection - var cells = []; - for ( var i=0, len = cellElems.length; i < len; i++ ) { - var elem = cellElems[i]; - var cell = new Cell( elem, this ); - cells.push( cell ); - } - - return cells; -}; - -Flickity.prototype.getLastCell = function() { - return this.cells[ this.cells.length - 1 ]; -}; - -// positions all cells -Flickity.prototype.positionCells = function() { - // size all cells - this._sizeCells( this.cells ); - // position all cells - this._positionCells( 0 ); -}; - -/** - * position certain cells - * @param {Integer} index - which cell to start with - */ -Flickity.prototype._positionCells = function( index ) { - // also measure maxCellHeight - // start 0 if positioning all cells - this.maxCellHeight = index ? this.maxCellHeight || 0 : 0; - var cellX = 0; - // get cellX - if ( index > 0 ) { - var startCell = this.cells[ index - 1 ]; - cellX = startCell.x + startCell.size.outerWidth; - } - var cell; - for ( var len = this.cells.length, i=index; i < len; i++ ) { - cell = this.cells[i]; - cell.setPosition( cellX ); - cellX += cell.size.outerWidth; - this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight ); - } - // keep track of cellX for wrap-around - this.slideableWidth = cellX; - // contain cell target - this._containCells(); -}; - -/** - * cell.getSize() on multiple cells - * @param {Array} cells - */ -Flickity.prototype._sizeCells = function( cells ) { - for ( var i=0, len = cells.length; i < len; i++ ) { - var cell = cells[i]; - cell.getSize(); - } -}; - -// alias _init for jQuery plugin .flickity() -Flickity.prototype._init = -Flickity.prototype.reposition = function() { - this.positionCells(); - this.positionSliderAtSelected(); -}; - -Flickity.prototype.getSize = function() { - this.size = getSize( this.element ); - this.setCellAlign(); - this.cursorPosition = this.size.innerWidth * this.cellAlign; -}; - -var cellAlignShorthands = { - // cell align, then based on origin side - center: { - left: 0.5, - right: 0.5 - }, - left: { - left: 0, - right: 1 - }, - right: { - right: 0, - left: 1 - } -}; - -Flickity.prototype.setCellAlign = function() { - var shorthand = cellAlignShorthands[ this.options.cellAlign ]; - this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign; -}; - -Flickity.prototype.setGallerySize = function() { - if ( this.options.setGallerySize ) { - this.viewport.style.height = this.maxCellHeight + 'px'; - } -}; - -Flickity.prototype._getWrapShiftCells = function() { - // only for wrap-around - if ( !this.options.wrapAround ) { - return; - } - // unshift previous cells - this._unshiftCells( this.beforeShiftCells ); - this._unshiftCells( this.afterShiftCells ); - // get before cells - // initial gap - var gapX = this.cursorPosition; - var cellIndex = this.cells.length - 1; - this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 ); - // get after cells - // ending gap between last cell and end of gallery viewport - gapX = this.size.innerWidth - this.cursorPosition; - // start cloning at first cell, working forwards - this.afterShiftCells = this._getGapCells( gapX, 0, 1 ); -}; - -Flickity.prototype._getGapCells = function( gapX, cellIndex, increment ) { - // keep adding cells until the cover the initial gap - var cells = []; - while ( gapX > 0 ) { - var cell = this.cells[ cellIndex ]; - if ( !cell ) { - break; - } - cells.push( cell ); - cellIndex += increment; - gapX -= cell.size.outerWidth; - } - return cells; -}; - -// ----- contain ----- // - -// contain cell targets so no excess sliding -Flickity.prototype._containCells = function() { - if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) { - return; - } - var startMargin = this.options.rightToLeft ? 'marginRight' : 'marginLeft'; - var endMargin = this.options.rightToLeft ? 'marginLeft' : 'marginRight'; - var firstCellStartMargin = this.cells[0].size[ startMargin ]; - var lastCell = this.getLastCell(); - var contentWidth = this.slideableWidth - lastCell.size[ endMargin ]; - var endLimit = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign ); - // content is less than gallery size - var isContentSmaller = contentWidth < this.size.innerWidth; - // contain each cell target - for ( var i=0, len = this.cells.length; i < len; i++ ) { - var cell = this.cells[i]; - // reset default target - cell.setDefaultTarget(); - if ( isContentSmaller ) { - // all cells fit inside gallery - cell.target = contentWidth * this.cellAlign; - } else { - // contain to bounds - cell.target = Math.max( cell.target, this.cursorPosition + firstCellStartMargin ); - cell.target = Math.min( cell.target, endLimit ); - } - } -}; - -// ----- ----- // - -/** - * emits events via eventEmitter and jQuery events - * @param {String} type - name of event - * @param {Event} event - original event - * @param {Array} args - extra arguments - */ -Flickity.prototype.dispatchEvent = function( type, event, args ) { - var emitArgs = [ event ].concat( args ); - this.emitEvent( type, emitArgs ); - - if ( jQuery && this.$element ) { - if ( event ) { - // create jQuery event - var $event = jQuery.Event( event ); - $event.type = type; - this.$element.trigger( $event, args ); - } else { - // just trigger with type if no event available - this.$element.trigger( type, args ); - } - } -}; - -// -------------------------- select -------------------------- // - -/** - * @param {Integer} index - index of the cell - * @param {Boolean} isWrap - will wrap-around to last/first if at the end - */ -Flickity.prototype.select = function( index, isWrap ) { - if ( !this.isActive ) { - return; - } - // wrap position so slider is within normal area - var len = this.cells.length; - if ( this.options.wrapAround && len > 1 ) { - if ( index < 0 ) { - this.x -= this.slideableWidth; - } else if ( index >= len ) { - this.x += this.slideableWidth; - } - } - - if ( this.options.wrapAround || isWrap ) { - index = utils.modulo( index, len ); - } - - if ( this.cells[ index ] ) { - this.selectedIndex = index; - this.setSelectedCell(); - this.startAnimation(); - this.dispatchEvent('cellSelect'); - } -}; - -Flickity.prototype.previous = function( isWrap ) { - this.select( this.selectedIndex - 1, isWrap ); -}; - -Flickity.prototype.next = function( isWrap ) { - this.select( this.selectedIndex + 1, isWrap ); -}; - -Flickity.prototype.setSelectedCell = function() { - this._removeSelectedCellClass(); - this.selectedCell = this.cells[ this.selectedIndex ]; - this.selectedElement = this.selectedCell.element; - classie.add( this.selectedElement, 'is-selected' ); -}; - -Flickity.prototype._removeSelectedCellClass = function() { - if ( this.selectedCell ) { - classie.remove( this.selectedCell.element, 'is-selected' ); - } -}; - -// -------------------------- get cells -------------------------- // - -/** - * get Flickity.Cell, given an Element - * @param {Element} elem - * @returns {Flickity.Cell} item - */ -Flickity.prototype.getCell = function( elem ) { - // loop through cells to get the one that matches - for ( var i=0, len = this.cells.length; i < len; i++ ) { - var cell = this.cells[i]; - if ( cell.element == elem ) { - return cell; - } - } -}; - -/** - * get collection of Flickity.Cells, given Elements - * @param {Element, Array, NodeList} elems - * @returns {Array} cells - Flickity.Cells - */ -Flickity.prototype.getCells = function( elems ) { - elems = utils.makeArray( elems ); - var cells = []; - for ( var i=0, len = elems.length; i < len; i++ ) { - var elem = elems[i]; - var cell = this.getCell( elem ); - if ( cell ) { - cells.push( cell ); - } - } - return cells; -}; - -/** - * get cell elements - * @returns {Array} cellElems - */ -Flickity.prototype.getCellElements = function() { - var cellElems = []; - for ( var i=0, len = this.cells.length; i < len; i++ ) { - cellElems.push( this.cells[i].element ); - } - return cellElems; -}; - -/** - * get parent cell from an element - * @param {Element} elem - * @returns {Flickit.Cell} cell - */ -Flickity.prototype.getParentCell = function( elem ) { - // first check if elem is cell - var cell = this.getCell( elem ); - if ( cell ) { - return cell; - } - // try to get parent cell elem - elem = utils.getParent( elem, '.flickity-slider > *' ); - return this.getCell( elem ); -}; - -// -------------------------- events -------------------------- // - -Flickity.prototype.uiChange = function() { - this.emit('uiChange'); -}; - -Flickity.prototype.childUIPointerDown = function( event ) { - this.emitEvent( 'childUIPointerDown', [ event ] ); -}; - -// ----- resize ----- // - -Flickity.prototype.onresize = function() { - this.watchCSS(); - this.resize(); -}; - -utils.debounceMethod( Flickity, 'onresize', 150 ); - -Flickity.prototype.resize = function() { - if ( !this.isActive ) { - return; - } - this.getSize(); - // wrap values - if ( this.options.wrapAround ) { - this.x = utils.modulo( this.x, this.slideableWidth ); - } - this.positionCells(); - this._getWrapShiftCells(); - this.setGallerySize(); - this.positionSliderAtSelected(); -}; - -var supportsConditionalCSS = Flickity.supportsConditionalCSS = ( function() { - var supports; - return function checkSupport() { - if ( supports !== undefined ) { - return supports; - } - if ( !getComputedStyle ) { - supports = false; - return; - } - // style body's :after and check that - var style = document.createElement('style'); - var cssText = document.createTextNode('body:after { content: "foo"; display: none; }'); - style.appendChild( cssText ); - document.head.appendChild( style ); - var afterContent = getComputedStyle( document.body, ':after' ).content; - // check if able to get :after content - supports = afterContent.indexOf('foo') != -1; - document.head.removeChild( style ); - return supports; - }; -})(); - -// watches the :after property, activates/deactivates -Flickity.prototype.watchCSS = function() { - var watchOption = this.options.watchCSS; - if ( !watchOption ) { - return; - } - var supports = supportsConditionalCSS(); - if ( !supports ) { - // activate if watch option is fallbackOn - var method = watchOption == 'fallbackOn' ? 'activate' : 'deactivate'; - this[ method ](); - return; - } - - var afterContent = getComputedStyle( this.element, ':after' ).content; - // activate if :after { content: 'flickity' } - if ( afterContent.indexOf('flickity') != -1 ) { - this.activate(); - } else { - this.deactivate(); - } -}; - -// ----- keydown ----- // - -// go previous/next if left/right keys pressed -Flickity.prototype.onkeydown = function( event ) { - // only work if element is in focus - if ( !this.options.accessibility || - ( document.activeElement && document.activeElement != this.element ) ) { - return; - } - - if ( event.keyCode == 37 ) { - // go left - var leftMethod = this.options.rightToLeft ? 'next' : 'previous'; - this.uiChange(); - this[ leftMethod ](); - } else if ( event.keyCode == 39 ) { - // go right - var rightMethod = this.options.rightToLeft ? 'previous' : 'next'; - this.uiChange(); - this[ rightMethod ](); - } -}; - -// -------------------------- destroy -------------------------- // - -// deactivate all Flickity functionality, but keep stuff available -Flickity.prototype.deactivate = function() { - if ( !this.isActive ) { - return; - } - classie.remove( this.element, 'flickity-enabled' ); - classie.remove( this.element, 'flickity-rtl' ); - // destroy cells - for ( var i=0, len = this.cells.length; i < len; i++ ) { - var cell = this.cells[i]; - cell.destroy(); - } - this._removeSelectedCellClass(); - this.element.removeChild( this.viewport ); - // move child elements back into element - moveElements( this.slider.children, this.element ); - if ( this.options.accessibility ) { - this.element.removeAttribute('tabIndex'); - eventie.unbind( this.element, 'keydown', this ); - } - // set flags - this.isActive = false; - this.emit('deactivate'); -}; - -Flickity.prototype.destroy = function() { - this.deactivate(); - if ( this.isResizeBound ) { - eventie.unbind( window, 'resize', this ); - } - this.emit('destroy'); - if ( jQuery && this.$element ) { - jQuery.removeData( this.element, 'flickity' ); - } - delete this.element.flickityGUID; - delete instances[ this.guid ]; -}; - -// -------------------------- prototype -------------------------- // - -utils.extend( Flickity.prototype, animatePrototype ); - -// -------------------------- extras -------------------------- // - -// quick check for IE8 -var isIE8 = 'attachEvent' in window; - -Flickity.setUnselectable = function( elem ) { - if ( !isIE8 ) { - return; - } - // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183 - elem.setAttribute( 'unselectable', 'on' ); -}; - -/** - * get Flickity instance from element - * @param {Element} elem - * @returns {Flickity} - */ -Flickity.data = function( elem ) { - elem = utils.getQueryElement( elem ); - var id = elem && elem.flickityGUID; - return id && instances[ id ]; -}; - -utils.htmlInit( Flickity, 'flickity' ); - -if ( jQuery && jQuery.bridget ) { - jQuery.bridget( 'flickity', Flickity ); -} - -Flickity.Cell = Cell; - -return Flickity; - -})); - -/*! - * Unipointer v1.1.0 - * base class for doing one thing with pointer event - * MIT license - */ - -/*jshint browser: true, undef: true, unused: true, strict: true */ -/*global define: false, module: false, require: false */ - -( function( window, factory ) { - - // universal module definition - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'unipointer/unipointer',[ - 'eventEmitter/EventEmitter', - 'eventie/eventie' - ], function( EventEmitter, eventie ) { - return factory( window, EventEmitter, eventie ); - }); - } else if ( typeof exports == 'object' ) { - // CommonJS - module.exports = factory( - window, - require('wolfy87-eventemitter'), - require('eventie') - ); - } else { - // browser global - window.Unipointer = factory( - window, - window.EventEmitter, - window.eventie - ); - } - -}( window, function factory( window, EventEmitter, eventie ) { - - - -function noop() {} - -function Unipointer() {} - -// inherit EventEmitter -Unipointer.prototype = new EventEmitter(); - -Unipointer.prototype.bindStartEvent = function( elem ) { - this._bindStartEvent( elem, true ); -}; - -Unipointer.prototype.unbindStartEvent = function( elem ) { - this._bindStartEvent( elem, false ); -}; - -/** - * works as unbinder, as you can ._bindStart( false ) to unbind - * @param {Boolean} isBind - will unbind if falsey - */ -Unipointer.prototype._bindStartEvent = function( elem, isBind ) { - // munge isBind, default to true - isBind = isBind === undefined ? true : !!isBind; - var bindMethod = isBind ? 'bind' : 'unbind'; - - if ( window.navigator.pointerEnabled ) { - // W3C Pointer Events, IE11. See https://coderwall.com/p/mfreca - eventie[ bindMethod ]( elem, 'pointerdown', this ); - } else if ( window.navigator.msPointerEnabled ) { - // IE10 Pointer Events - eventie[ bindMethod ]( elem, 'MSPointerDown', this ); - } else { - // listen for both, for devices like Chrome Pixel - eventie[ bindMethod ]( elem, 'mousedown', this ); - eventie[ bindMethod ]( elem, 'touchstart', this ); - } -}; - -// trigger handler methods for events -Unipointer.prototype.handleEvent = function( event ) { - var method = 'on' + event.type; - if ( this[ method ] ) { - this[ method ]( event ); - } -}; - -// returns the touch that we're keeping track of -Unipointer.prototype.getTouch = function( touches ) { - for ( var i=0, len = touches.length; i < len; i++ ) { - var touch = touches[i]; - if ( touch.identifier == this.pointerIdentifier ) { - return touch; - } - } -}; - -// ----- start event ----- // - -Unipointer.prototype.onmousedown = function( event ) { - // dismiss clicks from right or middle buttons - var button = event.button; - if ( button && ( button !== 0 && button !== 1 ) ) { - return; - } - this._pointerDown( event, event ); -}; - -Unipointer.prototype.ontouchstart = function( event ) { - this._pointerDown( event, event.changedTouches[0] ); -}; - -Unipointer.prototype.onMSPointerDown = -Unipointer.prototype.onpointerdown = function( event ) { - this._pointerDown( event, event ); -}; - -/** - * pointer start - * @param {Event} event - * @param {Event or Touch} pointer - */ -Unipointer.prototype._pointerDown = function( event, pointer ) { - // dismiss other pointers - if ( this.isPointerDown ) { - return; - } - - this.isPointerDown = true; - // save pointer identifier to match up touch events - this.pointerIdentifier = pointer.pointerId !== undefined ? - // pointerId for pointer events, touch.indentifier for touch events - pointer.pointerId : pointer.identifier; - - this.pointerDown( event, pointer ); -}; - -Unipointer.prototype.pointerDown = function( event, pointer ) { - this._bindPostStartEvents( event ); - this.emitEvent( 'pointerDown', [ event, pointer ] ); -}; - -// hash of events to be bound after start event -var postStartEvents = { - mousedown: [ 'mousemove', 'mouseup' ], - touchstart: [ 'touchmove', 'touchend', 'touchcancel' ], - pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ], - MSPointerDown: [ 'MSPointerMove', 'MSPointerUp', 'MSPointerCancel' ] -}; - -Unipointer.prototype._bindPostStartEvents = function( event ) { - if ( !event ) { - return; - } - // get proper events to match start event - var events = postStartEvents[ event.type ]; - // IE8 needs to be bound to document - var node = event.preventDefault ? window : document; - // bind events to node - for ( var i=0, len = events.length; i < len; i++ ) { - var evnt = events[i]; - eventie.bind( node, evnt, this ); - } - // save these arguments - this._boundPointerEvents = { - events: events, - node: node - }; -}; - -Unipointer.prototype._unbindPostStartEvents = function() { - var args = this._boundPointerEvents; - // IE8 can trigger dragEnd twice, check for _boundEvents - if ( !args || !args.events ) { - return; - } - - for ( var i=0, len = args.events.length; i < len; i++ ) { - var event = args.events[i]; - eventie.unbind( args.node, event, this ); - } - delete this._boundPointerEvents; -}; - -// ----- move event ----- // - -Unipointer.prototype.onmousemove = function( event ) { - this._pointerMove( event, event ); -}; - -Unipointer.prototype.onMSPointerMove = -Unipointer.prototype.onpointermove = function( event ) { - if ( event.pointerId == this.pointerIdentifier ) { - this._pointerMove( event, event ); - } -}; - -Unipointer.prototype.ontouchmove = function( event ) { - var touch = this.getTouch( event.changedTouches ); - if ( touch ) { - this._pointerMove( event, touch ); - } -}; - -/** - * pointer move - * @param {Event} event - * @param {Event or Touch} pointer - * @private - */ -Unipointer.prototype._pointerMove = function( event, pointer ) { - this.pointerMove( event, pointer ); -}; - -// public -Unipointer.prototype.pointerMove = function( event, pointer ) { - this.emitEvent( 'pointerMove', [ event, pointer ] ); -}; - -// ----- end event ----- // - - -Unipointer.prototype.onmouseup = function( event ) { - this._pointerUp( event, event ); -}; - -Unipointer.prototype.onMSPointerUp = -Unipointer.prototype.onpointerup = function( event ) { - if ( event.pointerId == this.pointerIdentifier ) { - this._pointerUp( event, event ); - } -}; - -Unipointer.prototype.ontouchend = function( event ) { - var touch = this.getTouch( event.changedTouches ); - if ( touch ) { - this._pointerUp( event, touch ); - } -}; - -/** - * pointer up - * @param {Event} event - * @param {Event or Touch} pointer - * @private - */ -Unipointer.prototype._pointerUp = function( event, pointer ) { - this._pointerDone(); - this.pointerUp( event, pointer ); -}; - -// public -Unipointer.prototype.pointerUp = function( event, pointer ) { - this.emitEvent( 'pointerUp', [ event, pointer ] ); -}; - -// ----- pointer done ----- // - -// triggered on pointer up & pointer cancel -Unipointer.prototype._pointerDone = function() { - // reset properties - this.isPointerDown = false; - delete this.pointerIdentifier; - // remove events - this._unbindPostStartEvents(); - this.pointerDone(); -}; - -Unipointer.prototype.pointerDone = noop; - -// ----- pointer cancel ----- // - -Unipointer.prototype.onMSPointerCancel = -Unipointer.prototype.onpointercancel = function( event ) { - if ( event.pointerId == this.pointerIdentifier ) { - this._pointerCancel( event, event ); - } -}; - -Unipointer.prototype.ontouchcancel = function( event ) { - var touch = this.getTouch( event.changedTouches ); - if ( touch ) { - this._pointerCancel( event, touch ); - } -}; - -/** - * pointer cancel - * @param {Event} event - * @param {Event or Touch} pointer - * @private - */ -Unipointer.prototype._pointerCancel = function( event, pointer ) { - this._pointerDone(); - this.pointerCancel( event, pointer ); -}; - -// public -Unipointer.prototype.pointerCancel = function( event, pointer ) { - this.emitEvent( 'pointerCancel', [ event, pointer ] ); -}; - -// ----- ----- // - -// utility function for getting x/y cooridinates from event, because IE8 -Unipointer.getPointerPoint = function( pointer ) { - return { - x: pointer.pageX !== undefined ? pointer.pageX : pointer.clientX, - y: pointer.pageY !== undefined ? pointer.pageY : pointer.clientY - }; -}; - -// ----- ----- // - -return Unipointer; - -})); - -/*! - * Unidragger v1.1.3 - * Draggable base class - * MIT license - */ - -/*jshint browser: true, unused: true, undef: true, strict: true */ - -( function( window, factory ) { - /*global define: false, module: false, require: false */ - - // universal module definition - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'unidragger/unidragger',[ - 'eventie/eventie', - 'unipointer/unipointer' - ], function( eventie, Unipointer ) { - return factory( window, eventie, Unipointer ); - }); - } else if ( typeof exports == 'object' ) { - // CommonJS - module.exports = factory( - window, - require('eventie'), - require('unipointer') - ); - } else { - // browser global - window.Unidragger = factory( - window, - window.eventie, - window.Unipointer - ); - } - -}( window, function factory( window, eventie, Unipointer ) { - - - -// ----- ----- // - -function noop() {} - -// handle IE8 prevent default -function preventDefaultEvent( event ) { - if ( event.preventDefault ) { - event.preventDefault(); - } else { - event.returnValue = false; - } -} - -// -------------------------- Unidragger -------------------------- // - -function Unidragger() {} - -// inherit Unipointer & EventEmitter -Unidragger.prototype = new Unipointer(); - -// ----- bind start ----- // - -Unidragger.prototype.bindHandles = function() { - this._bindHandles( true ); -}; - -Unidragger.prototype.unbindHandles = function() { - this._bindHandles( false ); -}; - -var navigator = window.navigator; -/** - * works as unbinder, as you can .bindHandles( false ) to unbind - * @param {Boolean} isBind - will unbind if falsey - */ -Unidragger.prototype._bindHandles = function( isBind ) { - // munge isBind, default to true - isBind = isBind === undefined ? true : !!isBind; - // extra bind logic - var binderExtra; - if ( navigator.pointerEnabled ) { - binderExtra = function( handle ) { - // disable scrolling on the element - handle.style.touchAction = isBind ? 'none' : ''; - }; - } else if ( navigator.msPointerEnabled ) { - binderExtra = function( handle ) { - // disable scrolling on the element - handle.style.msTouchAction = isBind ? 'none' : ''; - }; - } else { - binderExtra = function() { - // TODO re-enable img.ondragstart when unbinding - if ( isBind ) { - disableImgOndragstart( handle ); - } - }; - } - // bind each handle - var bindMethod = isBind ? 'bind' : 'unbind'; - for ( var i=0, len = this.handles.length; i < len; i++ ) { - var handle = this.handles[i]; - this._bindStartEvent( handle, isBind ); - binderExtra( handle ); - eventie[ bindMethod ]( handle, 'click', this ); - } -}; - -// remove default dragging interaction on all images in IE8 -// IE8 does its own drag thing on images, which messes stuff up - -function noDragStart() { - return false; -} - -// TODO replace this with a IE8 test -var isIE8 = 'attachEvent' in document.documentElement; - -// IE8 only -var disableImgOndragstart = !isIE8 ? noop : function( handle ) { - - if ( handle.nodeName == 'IMG' ) { - handle.ondragstart = noDragStart; - } - - var images = handle.querySelectorAll('img'); - for ( var i=0, len = images.length; i < len; i++ ) { - var img = images[i]; - img.ondragstart = noDragStart; - } -}; - -// ----- start event ----- // - -/** - * pointer start - * @param {Event} event - * @param {Event or Touch} pointer - */ -Unidragger.prototype.pointerDown = function( event, pointer ) { - this._dragPointerDown( event, pointer ); - // kludge to blur focused inputs in dragger - var focused = document.activeElement; - if ( focused && focused.blur ) { - focused.blur(); - } - // bind move and end events - this._bindPostStartEvents( event ); - this.emitEvent( 'pointerDown', [ event, pointer ] ); -}; - -// base pointer down logic -Unidragger.prototype._dragPointerDown = function( event, pointer ) { - // track to see when dragging starts - this.pointerDownPoint = Unipointer.getPointerPoint( pointer ); - - // prevent default, unless touchstart or s and ",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,a.appendChild(b),b.innerHTML="",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){l.noCloneEvent=!1}),b.cloneNode(!0).click()),null==l.deleteExpando){l.deleteExpando=!0;try{delete b.test}catch(d){l.deleteExpando=!1}}a=b=c=null}(),function(){var b,c,d=z.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),l[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var Y=/^(?:input|select|textarea)$/i,Z=/^key/,$=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,ab=/^([^.]*)(?:\.(.+)|)$/;function bb(){return!0}function cb(){return!1}function db(){try{return z.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof n===L||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(F)||[""],h=b.length;while(h--)f=ab.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},i),(m=g[o])||(m=g[o]=[],m.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,l):m.push(l),n.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n.hasData(a)&&n._data(a);if(r&&(k=r.events)){b=(b||"").match(F)||[""],j=b.length;while(j--)if(h=ab.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;while(f--)g=m[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(k)&&(delete r.handle,n._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,m,o=[d||z],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||z,3!==d.nodeType&&8!==d.nodeType&&!_.test(p+n.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[n.expando]?b:new n.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),k=n.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!n.isWindow(d)){for(i=k.delegateType||p,_.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||z)&&o.push(l.defaultView||l.parentWindow||a)}m=0;while((h=o[m++])&&!b.isPropagationStopped())b.type=m>1?i:k.bindType||p,f=(n._data(h,"events")||{})[b.type]&&n._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&n.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&n.acceptData(d)&&g&&d[p]&&!n.isWindow(d)){l=d[g],l&&(d[g]=null),n.event.triggered=p;try{d[p]()}catch(r){}n.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(n._data(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((n.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?n(c,this).index(i)>=0:n.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),ib=/^\s+/,jb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,kb=/<([\w:]+)/,lb=/\s*$/g,sb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:l.htmlSerialize?[0,"",""]:[1,"X
","
"]},tb=eb(z),ub=tb.appendChild(z.createElement("div"));sb.optgroup=sb.option,sb.tbody=sb.tfoot=sb.colgroup=sb.caption=sb.thead,sb.th=sb.td;function vb(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==L?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==L?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||n.nodeName(d,b)?f.push(d):n.merge(f,vb(d,b));return void 0===b||b&&n.nodeName(a,b)?n.merge([a],f):f}function wb(a){X.test(a.type)&&(a.defaultChecked=a.checked)}function xb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function yb(a){return a.type=(null!==n.find.attr(a,"type"))+"/"+a.type,a}function zb(a){var b=qb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ab(a,b){for(var c,d=0;null!=(c=a[d]);d++)n._data(c,"globalEval",!b||n._data(b[d],"globalEval"))}function Bb(a,b){if(1===b.nodeType&&n.hasData(a)){var c,d,e,f=n._data(a),g=n._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)n.event.add(b,c,h[c][d])}g.data&&(g.data=n.extend({},g.data))}}function Cb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!l.noCloneEvent&&b[n.expando]){e=n._data(b);for(d in e.events)n.removeEvent(b,d,e.handle);b.removeAttribute(n.expando)}"script"===c&&b.text!==a.text?(yb(b).text=a.text,zb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),l.html5Clone&&a.innerHTML&&!n.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&X.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}n.extend({clone:function(a,b,c){var d,e,f,g,h,i=n.contains(a.ownerDocument,a);if(l.html5Clone||n.isXMLDoc(a)||!hb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(ub.innerHTML=a.outerHTML,ub.removeChild(f=ub.firstChild)),!(l.noCloneEvent&&l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(d=vb(f),h=vb(a),g=0;null!=(e=h[g]);++g)d[g]&&Cb(e,d[g]);if(b)if(c)for(h=h||vb(a),d=d||vb(f),g=0;null!=(e=h[g]);g++)Bb(e,d[g]);else Bb(a,f);return d=vb(f,"script"),d.length>0&&Ab(d,!i&&vb(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,m=a.length,o=eb(b),p=[],q=0;m>q;q++)if(f=a[q],f||0===f)if("object"===n.type(f))n.merge(p,f.nodeType?[f]:f);else if(mb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(kb.exec(f)||["",""])[1].toLowerCase(),k=sb[i]||sb._default,h.innerHTML=k[1]+f.replace(jb,"<$1>")+k[2],e=k[0];while(e--)h=h.lastChild;if(!l.leadingWhitespace&&ib.test(f)&&p.push(b.createTextNode(ib.exec(f)[0])),!l.tbody){f="table"!==i||lb.test(f)?""!==k[1]||lb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)n.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}n.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),l.appendChecked||n.grep(vb(p,"input"),wb),q=0;while(f=p[q++])if((!d||-1===n.inArray(f,d))&&(g=n.contains(f.ownerDocument,f),h=vb(o.appendChild(f),"script"),g&&Ab(h),c)){e=0;while(f=h[e++])pb.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=n.expando,j=n.cache,k=l.deleteExpando,m=n.event.special;null!=(d=a[h]);h++)if((b||n.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)m[e]?n.event.remove(d,e):n.removeEvent(d,e,g.handle);j[f]&&(delete j[f],k?delete d[i]:typeof d.removeAttribute!==L?d.removeAttribute(i):d[i]=null,c.push(f))}}}),n.fn.extend({text:function(a){return W(this,function(a){return void 0===a?n.text(this):this.empty().append((this[0]&&this[0].ownerDocument||z).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=xb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(vb(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&Ab(vb(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&n.cleanData(vb(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&n.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return W(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(gb,""):void 0;if(!("string"!=typeof a||nb.test(a)||!l.htmlSerialize&&hb.test(a)||!l.leadingWhitespace&&ib.test(a)||sb[(kb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(jb,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(vb(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(vb(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,o=k-1,p=a[0],q=n.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&ob.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(i=n.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=n.map(vb(i,"script"),yb),f=g.length;k>j;j++)d=i,j!==o&&(d=n.clone(d,!0,!0),f&&n.merge(g,vb(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,n.map(g,zb),j=0;f>j;j++)d=g[j],pb.test(d.type||"")&&!n._data(d,"globalEval")&&n.contains(h,d)&&(d.src?n._evalUrl&&n._evalUrl(d.src):n.globalEval((d.text||d.textContent||d.innerHTML||"").replace(rb,"")));i=c=null}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=0,e=[],g=n(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),n(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Db,Eb={};function Fb(b,c){var d=n(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:n.css(d[0],"display");return d.detach(),e}function Gb(a){var b=z,c=Eb[a];return c||(c=Fb(a,b),"none"!==c&&c||(Db=(Db||n("