From 9dc36815cdf21287a597842d6653b3f652f5d85c Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 18 Nov 2016 16:33:07 -0500 Subject: Experimental and initial version - still has work to go - #379 --- www/external/gifshot.min.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 www/external/gifshot.min.js (limited to 'www/external') diff --git a/www/external/gifshot.min.js b/www/external/gifshot.min.js new file mode 100644 index 00000000..d20775fc --- /dev/null +++ b/www/external/gifshot.min.js @@ -0,0 +1,8 @@ +/*Copyrights for code authored by Yahoo Inc. is licensed under the following terms: +MIT License +Copyright 2015 Yahoo Inc. +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. +*/ +!function(e,t,r,i){var n,o,a,s,d,c,l,u,m,f,g,h,p,v,b,w,y,C,S,k,F,x;n=function(){var i={URL:e.URL||e.webkitURL||e.mozURL||e.msURL,getUserMedia:function(){var e=r.getUserMedia||r.webkitGetUserMedia||r.mozGetUserMedia||r.msGetUserMedia;return e?e.bind(r):e}(),requestAnimFrame:e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame,requestTimeout:function(e,t){function r(){var i=(new Date).getTime(),s=i-n;s>=t?e.call():o.value=a(r)}if(e=e||i.noop,t=t||0,!i.requestAnimFrame)return setTimeout(e,t);var n=(new Date).getTime(),o=new Object,a=i.requestAnimFrame;return o.value=a(r),o},Blob:e.Blob||e.BlobBuilder||e.WebKitBlobBuilder||e.MozBlobBuilder||e.MSBlobBuilder,btoa:function(){var t=e.btoa||function(e){for(var t,r,i,n,o,a,s,d="",c=0,l=e.length,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";l>c;)t=e.charCodeAt(c++),r=e.charCodeAt(c++),i=e.charCodeAt(c++),n=t>>2,o=(3&t)<<4|r>>4,a=(15&r)<<2|i>>6,s=63&i,isNaN(r)?a=s=64:isNaN(i)&&(s=64),d=d+u.charAt(n)+u.charAt(o)+u.charAt(a)+u.charAt(s);return d};return t?t.bind(e):function(){}}(),isObject:function(e){return e&&"[object Object]"===Object.prototype.toString.call(e)},isEmptyObject:function(e){return i.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&"function"==typeof e},isElement:function(e){return e&&1===e.nodeType},isString:function(e){return"string"==typeof e||"[object String]"===Object.prototype.toString.call(e)},isSupported:{canvas:function(){var e=t.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return e.Worker},blob:function(){return i.Blob},Uint8Array:function(){return e.Uint8Array},Uint32Array:function(){return e.Uint32Array},videoCodecs:function(){var e=t.createElement("video"),r={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{e&&e.canPlayType&&(r.mp4=""!==e.canPlayType('video/mp4; codecs="mp4v.20.8"'),r.h264=""!==(e.canPlayType('video/mp4; codecs="avc1.42E01E"')||e.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')),r.ogv=""!==e.canPlayType('video/ogg; codecs="theora"'),r.ogg=""!==e.canPlayType('video/ogg; codecs="theora"'),r.webm=-1!==e.canPlayType('video/webm; codecs="vp8, vorbis"'))}catch(i){}return r}()},noop:function(){},each:function(e,t){var r,n;if(i.isArray(e))for(r=-1,n=e.length;++ri&&n>=o;)s.style.fontSize=--n+"px";return t.body.removeChild(s),n+"px"},webWorkerError:!1};return i}(),o=function(e){var t={validate:function(r){r=e.isObject(r)?r:{};var i={};return e.each(t.validators,function(e,t){var n=t.errorCode;return r[n]||t.condition?void 0:(i=t,i.error=!0,!1)}),delete i.condition,i},isValid:function(e){var r=t.validate(e),i=r.error!==!0?!0:!1;return i},validators:[{condition:e.isFunction(e.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:e.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:e.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:e.isFunction(e.URL),errorCode:"window.URL",errorMsg:"The window.URL API is not supported in your browser"},{condition:e.isSupported.blob(),errorCode:"window.Blob",errorMsg:"The window.Blob File API is not supported in your browser"},{condition:e.isSupported.Uint8Array(),errorCode:"window.Uint8Array",errorMsg:"The window.Uint8Array function constructor is not supported in your browser"},{condition:e.isSupported.Uint32Array(),errorCode:"window.Uint32Array",errorMsg:"The window.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}};return t}(n),a={sampleInterval:10,numWorkers:2,gifWidth:200,gifHeight:200,interval:.1,numFrames:10,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:function(){},completeCallback:function(){},saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},s=function(){return o.isValid()},d=function(){return o.isValid()},c=function(){var e={getUserMedia:!0};return o.isValid(e)},l=function(e){var t=!1;if(n.isArray(e)&&e.length){if(n.each(e,function(e,r){n.isSupported.videoCodecs[r]&&(t=!0)}),!t)return!1}else if(n.isString(e)&&e.length&&!n.isSupported.videoCodecs[e])return!1;return o.isValid({getUserMedia:!0})},u=function(){function e(){function e(e,t,r){var i,n;for(u=e,m=t,f=r,g=new Array(h),i=0;h>i;i++)g[i]=new Array(4),n=g[i],n[0]=n[1]=n[2]=(i<r;r++)t[g[r][3]]=r;for(var i=0,n=0;h>n;n++){var o=t[n];e[i++]=g[o][0],e[i++]=g[o][1],e[i++]=g[o][2]}return e}function r(){var e,t,r,i,n,o,a,s;for(a=0,s=0,e=0;h>e;e++){for(n=g[e],r=e,i=n[1],t=e+1;h>t;t++)o=g[t],o[1]>1,t=a+1;i>t;t++)B[t]=e;a=i,s=e}}for(B[a]=s+C>>1,t=a+1;256>t;t++)B[t]=C}function i(){var e,t,r,i,n,o,a,g,h,C,F,x,E,W;for(y>m&&(f=1),l=30+(f-1)/3,x=u,E=0,W=m,F=m/(3*f),C=F/k|0,g=j,o=I,a=o>>R,1>=a&&(a=0),e=0;a>e;e++)q[e]=g*((a*a-e*e)*z/(a*a));for(h=y>m?3:m%p!==0?3*p:m%v!==0?3*v:m%b!==0?3*b:3*w,e=0;F>e;)if(r=(255&x[E+0])<=W&&(E-=m),e++,0===C&&(C=1),e%C===0)for(g-=g/l,o-=o/T,a=o>>R,1>=a&&(a=0),t=0;a>t;t++)q[t]=g*((a*a-t*t)*z/(a*a))}function n(e,t,r){var i,n,o,a,s,d,c;for(s=1e3,c=-1,i=B[t],n=i-1;h>i||n>=0;)h>i&&(d=g[i],o=d[1]-t,o>=s?i=h:(i++,0>o&&(o=-o),a=d[0]-e,0>a&&(a=-a),o+=a,s>o&&(a=d[2]-r,0>a&&(a=-a),o+=a,s>o&&(s=o,c=d[3])))),n>=0&&(d=g[n],o=t-d[1],o>=s?n=-1:(n--,0>o&&(o=-o),a=d[0]-e,0>a&&(a=-a),o+=a,s>o&&(a=d[2]-r,0>a&&(a=-a),o+=a,s>o&&(s=o,c=d[3]))));return c}function o(){return i(),a(),r(),t()}function a(){var e;for(e=0;h>e;e++)g[e][0]>>=S,g[e][1]>>=S,g[e][2]>>=S,g[e][3]=e}function s(e,t,r,i,n){var o,a,s,d,c,l,u;for(s=t-e,-1>s&&(s=-1),d=t+e,d>h&&(d=h),o=t+1,a=t-1,l=1;d>o||a>s;){if(c=q[l++],d>o){u=g[o++];try{u[0]-=c*(u[0]-r)/P|0,u[1]-=c*(u[1]-i)/P|0,u[2]-=c*(u[2]-n)/P|0}catch(m){}}if(a>s){u=g[a--];try{u[0]-=c*(u[0]-r)/P|0,u[1]-=c*(u[1]-i)/P|0,u[2]-=c*(u[2]-n)/P|0}catch(m){}}}}function d(e,t,r,i,n){var o=g[t],a=e/j;o[0]-=a*(o[0]-r)|0,o[1]-=a*(o[1]-i)|0,o[2]-=a*(o[2]-n)|0}function c(e,t,r){var i,n,o,a,s,d,c,l,u,m;for(l=~(1<<31),u=l,d=-1,c=d,i=0;h>i;i++)m=g[i],n=m[0]-e,0>n&&(n=-n),o=m[1]-t,0>o&&(o=-o),n+=o,o=m[2]-r,0>o&&(o=-o),n+=o,l>n&&(l=n,d=i),a=n-(G[i]>>F-S),u>a&&(u=a,c=i),s=D[i]>>W,D[i]-=s,G[i]+=s<>W,A=x<>3,R=6,M=1<i;)o.push(e[i++]),o.push(e[i++]),o.push(e[i++]),i++;return o},componentizedPaletteToArray:function(e){var t,r,i,n,o=[];for(t=0;to;o++)a=c[h++],s=c[h++],d=c[h++],g[o]=l.map(a,s,d);return{pixels:g,palette:m}},run:function(e){var t=e.width,r=e.height,i=e.data,n=(e.palette,e.sampleInterval);return this.processFrameWithQuantizer(i,t,r,n)}};return r};return t}(u),f=function(e,t,r,n){function o(e){var t=e.length;if(2>t||t>256||t&t-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return t}function a(e,t,r,n){function o(r){for(;f>=r;)e[t++]=255&g,g>>=8,f-=8,t===s+256&&(e[s]=255,s=t++)}function a(e){g|=e<v;++v){var w=n[v]&c,y=h<<8|w,C=p[y];if(C===i){for(g|=h<=8;)e[t++]=255&g,g>>=8,f-=8,t===s+256&&(e[s]=255,s=t++);4096===u?(a(d),u=l+1,m=r+1,p={}):(u>=1<=t||0>=r||t>65535||r>65535)throw"Width/Height invalid.";e[s++]=71,e[s++]=73,e[s++]=70,e[s++]=56,e[s++]=57,e[s++]=97;var l=0,u=0;if(e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=(null!==c?128:0)|l,e[s++]=u,e[s++]=0,null!==d){if(0>d||d>65535)throw"Loop count invalid.";e[s++]=33,e[s++]=255,e[s++]=11,e[s++]=78,e[s++]=69,e[s++]=84,e[s++]=83,e[s++]=67,e[s++]=65,e[s++]=80,e[s++]=69,e[s++]=50,e[s++]=46,e[s++]=48,e[s++]=3,e[s++]=1,e[s++]=255&d,e[s++]=d>>8&255,e[s++]=0}var m=!1;this.addFrame=function(t,r,n,d,l,u){if(m===!0&&(--s,m=!1),u=u===i?{}:u,0>t||0>r||t>65535||r>65535)throw"x/y invalid.";if(0>=n||0>=d||n>65535||d>65535)throw"Width/Height invalid.";if(l.length>=1;)++p;h=1<b||b>3)throw"Disposal out of range.";var w=!1,y=0;if(u.transparent!==i&&null!==u.transparent&&(w=!0,y=u.transparent,0>y||y>=h))throw"Transparent color index.";if((0!==b||w||0!==v)&&(e[s++]=33,e[s++]=249,e[s++]=4,e[s++]=b<<2|(w===!0?1:0),e[s++]=255&v,e[s++]=v>>8&255,e[s++]=y,e[s++]=0),e[s++]=44,e[s++]=255&t,e[s++]=t>>8&255,e[s++]=255&r,e[s++]=r>>8&255,e[s++]=255&n,e[s++]=n>>8&255,e[s++]=255&d,e[s++]=d>>8&255,e[s++]=f===!0?128|p-1:0,f===!0)for(var C=0,S=g.length;S>C;++C){var k=g[C];e[s++]=k>>16&255,e[s++]=k>>8&255,e[s++]=255&k}s=a(e,s,2>p?2:p,l)},this.end=function(){return m===!1&&(e[s++]=59,m=!0),s}},g=function(e,r,i,n){var o=function(t){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=e.noop,this.onRenderProgressCallback=e.noop,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=t,this.initializeWebWorkers(t)};return o.prototype={workerMethods:r(),initializeWebWorkers:function(n){var o,a,s,d,c=i.toString()+"("+r.toString()+"());",l=-1,u="";for(d=n.numWorkers;++lt;t++)e[t]=String.fromCharCode(t);return e}(),bufferToString:function(e){for(var t=e.length,r="",i=-1;++i=0&&this.processFrame(e)},generateGIF:function(t,r){var i,o,a=[],s={loop:this.repeat},d=this.options,c=d.interval,l=d.images,u=!!l.length,m=d.gifHeight,f=d.gifWidth,g=new n(a,f,m,s),h=this.onRenderProgressCallback,p=u?100*c:0;this.generatingGIF=!0,e.each(t,function(e,r){var i=r.palette;h(.75+.25*r.position*1/t.length),g.addFrame(0,0,f,m,r.pixels,{palette:i,delay:p})}),g.end(),h(1),this.frames=[],this.generatingGIF=!1,e.isFunction(r)&&(i=this.bufferToString(a),o="data:image/gif;base64,"+e.btoa(i),r(o))},setRepeat:function(e){this.repeat=e},addFrame:function(t,r){r=e.isObject(r)?r:{};var i,n=this,o=n.ctx,a=n.options,s=a.gifWidth,d=a.gifHeight,c=(r.gifHeight,r.gifWidth,r.text),l=r.fontWeight,u=e.getFontSize(r),m=r.fontFamily,f=r.fontColor,g=r.textAlign,h=r.textBaseline,p=r.textXCoordinate?r.textXCoordinate:"left"===g?1:"right"===g?s:s/2,v=r.textYCoordinate?r.textYCoordinate:"top"===h?1:"center"===h?d/2:d,b=l+" "+u+" "+m;try{o.drawImage(t,0,0,s,d),c&&(o.font=b,o.fillStyle=f,o.textAlign=g,o.textBaseline=h,o.fillText(c,p,v)),i=o.getImageData(0,0,s,d),n.addFrameImageData(i)}catch(w){return""+w}},addFrameImageData:function(e){var t=this.frames,r=e.data;this.frames.push({data:r,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:t.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(t){var r=this,i=function(i){r.destroyWorkers(),e.requestTimeout(function(){t(i)},0)};r.startRendering(i)},destroyWorkers:function(){if(!this.workerError){var t=this.workers;e.each(t,function(t,r){var i=r.worker,n=r.objectUrl;i.terminate(),e.URL.revokeObjectURL(n)})}}},o}(n,m,u,f),h=function(e,t){e.getBase64GIF(function(e){t({error:!1,errorCode:"",errorMsg:"",image:e})})},p=function(e){function r(){n.each(p,function(e,t){t&&s.addFrame(t,u)}),h(s,l)}var a,s,d=e.images,c=e.imagesLength,l=e.callback,u=e.options,m={getUserMedia:!0,"window.URL":!0},f=o.validate(m),p=[],v=0;return f.error?l(f):(s=new g(u),n.each(d,function(e,o){n.isElement(o)?(u.crossOrigin&&(o.crossOrigin=u.crossOrigin),p[e]=o,v+=1,v===c&&r()):n.isString(o)&&(a=t.createElement("img"),u.crossOrigin&&(a.crossOrigin=u.crossOrigin),a.onerror=function(){p.length>e&&(p[e]=i)}(function(t){t.onload=function(){p[e]=t,v+=1,v===c&&r(),n.removeElement(t)}}(a)),a.src=o,n.setCSSAttr(a,{position:"fixed",opacity:"0"}),t.body.appendChild(a))}),void 0)},v={getGIF:function(e,r){r=n.isFunction(r)?r:n.noop;var i,o=t.createElement("canvas"),a=e.images,s=!!a.length,d=e.videoElement,c=e.keepCameraOn,l=e.webcamVideoElement,u=e.cameraStream,m=+e.gifWidth,f=+e.gifHeight,h=e.videoWidth,p=e.videoHeight,v=(+e.sampleInterval,+e.numWorkers,e.crop),b=+e.interval,w=s?0:1e3*b,y=e.progressCallback,C=e.savedRenderingContexts,S=e.saveRenderingContexts,k=[],F=C.length?C.length:e.numFrames,x=F,E=new g(e),W=e.text,O=e.fontWeight,A=n.getFontSize(e),U=e.fontFamily,R=e.fontColor,M=e.textAlign,I=e.textBaseline,T=e.textXCoordinate?e.textXCoordinate:"left"===M?1:"right"===M?m:m/2,V=e.textYCoordinate?e.textYCoordinate:"top"===I?1:"center"===I?f/2:f,j=O+" "+A+" "+U,H=v?Math.floor(v.scaledWidth/2):0,z=v?h-v.scaledWidth:0,L=v?Math.floor(v.scaledHeight/2):0,P=v?p-v.scaledHeight:0,B=function G(){function e(){try{z>h&&(z=h),P>p&&(P=p),0>H&&(H=0),0>L&&(L=0),i.drawImage(d,H,L,z,P,0,0,m,f),t()}catch(r){if("NS_ERROR_NOT_AVAILABLE"!==r.name)throw r;n.requestTimeout(e,100)}}function t(){x=o;var t,a,s,g,h=F-x;S&&k.push(i.getImageData(0,0,m,f)),W&&(i.font=j,i.fillStyle=R,i.textAlign=M,i.textBaseline=I,i.fillText(W,T,V)),t=i.getImageData(0,0,m,f),a=t.data,s=a[0]+a[1]+a[2]+a[3],g=0===s,g?1===h&&1===F&&e():E.addFrameImageData(t),y(h/F),o>0&&n.requestTimeout(G,w),x||E.getBase64GIF(function(e){r({error:!1,errorCode:"",errorMsg:"",image:e,cameraStream:u,videoElement:d,webcamVideoElement:l,savedRenderingContexts:k,keepCameraOn:c})})}var o=x-1;C.length?(i.putImageData(C[F-x],0,0),t()):e()};F=null!=F?F:10,b=null!=b?b:.1,o.width=m,o.height=f,i=o.getContext("2d"),function D(){return C.length||0!==d.currentTime?(B(),void 0):(n.requestTimeout(D,100),void 0)}()},getCropDimensions:function(e){var t=e.videoWidth,r=e.videoHeight,i=e.gifWidth,n=e.gifHeight,o={width:0,height:0,scaledWidth:0,scaledHeight:0};return t>r?(o.width=Math.round(t*(n/r))-i,o.scaledWidth=Math.round(o.width*(r/n))):(o.height=Math.round(r*(i/t))-n,o.scaledHeight=Math.round(o.height*(t/i))),o}},b={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function E(e){E.attempts=E.attempts||0;var t=this,r=e.videoElement,i=e.cameraStream,o=e.completedCallback;r&&(r.videoWidth>0&&r.videoHeight>0?(r.removeEventListener("loadeddata",t.findVideoSize),o({videoElement:r,cameraStream:i,videoWidth:r.videoWidth,videoHeight:r.videoHeight})):E.attempts<10?(E.attempts+=1,n.requestTimeout(function(){t.findVideoSize(e)},200)):o({videoElement:r,cameraStream:i,videoWidth:t.defaultVideoDimensions.width,videoHeight:t.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){n.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){var t=this,r=n.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,i=e.videoElement,o=e.cameraStream,a=e.streamedCallback,s=e.completedCallback;n.isFunction(a)&&a(),r?n.isString(r)&&(i.src=r,i.innerHTML=''):i.mozSrcObject?i.mozSrcObject=o:n.URL&&(i.src=n.URL.createObjectURL(o)),i.play(),n.requestTimeout(function d(){d.count=d.count||0,t.loadedData===!0?(t.findVideoSize({videoElement:i,cameraStream:o,completedCallback:s}),t.loadedData=!1):(d.count+=1,d.count>10?t.findVideoSize({videoElement:i,cameraStream:o,completedCallback:s}):d())},100)},startStreaming:function(e){var r=this,i=n.isFunction(e.error)?e.error:n.noop,o=n.isFunction(e.streamed)?e.streamed:n.noop,a=n.isFunction(e.completed)?e.completed:n.noop,s=e.existingVideo,d=e.webcamVideoElement,c=n.isElement(s)?s:d?d:t.createElement("video"),l=e.lastCameraStream,u=e.crossOrigin,m=e.options;u&&(c.crossOrigin=m.crossOrigin),c.autoplay=!0,c.loop=!0,c.muted=!0,c.addEventListener("loadeddata",function(){r.loadedData=!0}),s?r.stream({videoElement:c,existingVideo:s,completedCallback:a}):l?r.stream({videoElement:c,cameraStream:l,streamedCallback:o,completedCallback:a}):n.getUserMedia({video:!0},function(e){r.stream({videoElement:c,cameraStream:e,streamedCallback:o,completedCallback:a})},i)},startVideoStreaming:function(e,t){t=t||{};var r,o=this,a=t.timeout!==i?t.timeout:0,s=t.callback,d=t.webcamVideoElement;a>0&&(r=n.requestTimeout(function(){o.onStreamingTimeout(s)},1e4)),this.startStreaming({error:function(){s({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(r)},completed:function(t){var r=t.cameraStream,i=t.videoElement,n=t.videoWidth,o=t.videoHeight;e({cameraStream:r,videoElement:i,videoWidth:n,videoHeight:o})},lastCameraStream:t.lastCameraStream,webcamVideoElement:d,crossOrigin:t.crossOrigin,options:t})},stopVideoStreaming:function(e){e=n.isObject(e)?e:{};var t=e.cameraStream,r=e.videoElement,i=e.keepCameraOn,o=e.webcamVideoElement;!i&&t&&n.isFunction(t.stop)&&t.stop(),n.isElement(r)&&!o&&(r.pause(),n.isFunction(n.URL.revokeObjectURL)&&!n.webWorkerError&&r.src&&n.URL.revokeObjectURL(r.src),n.removeElement(r))}},w=function(e){e=n.isObject(e)?e:{};var t=(n.isObject(e.options)?e.options:{},e.cameraStream),r=e.videoElement,i=e.webcamVideoElement,o=e.keepCameraOn;b.stopVideoStreaming({cameraStream:t,videoElement:r,keepCameraOn:o,webcamVideoElement:i})},y=function(e,r){var i=e.options||{},o=i.images,a=i.video,s=(+i.numFrames,e.cameraStream),d=e.videoElement,c=e.videoWidth,l=e.videoHeight,u=+i.gifWidth,m=+i.gifHeight,f=v.getCropDimensions({videoWidth:c,videoHeight:l,gifHeight:m,gifWidth:u}),g=r;i.crop=f,i.videoElement=d,i.videoWidth=c,i.videoHeight=l,i.cameraStream=s,n.isElement(d)&&(d.width=u+f.width,d.height=m+f.height,i.webcamVideoElement||(n.setCSSAttr(d,{position:"fixed",opacity:"0"}),t.body.appendChild(d)),d.play(),v.getGIF(i,function(e){o&&o.length||a&&a.length||w(e),g(e)}))},C=function(e){var t,r,i=e.existingVideo,a=e.callback,s=e.options,d={getUserMedia:!0,"window.URL":!0},c=o.validate(d);if(c.error)return a(c);if(n.isElement(i)&&i.src){if(r=i.src,t=n.getExtension(r),!n.isSupported.videoCodecs[t])return a(o.messages.videoCodecs)}else n.isArray(i)&&n.each(i,function(e,r){return t=r.substr(r.lastIndexOf(".")+1,r.length),n.isSupported.videoCodecs[t]?(i=r,!1):void 0});b.startStreaming({completed:function(e){e.options=s||{},y(e,a)},existingVideo:i,crossOrigin:s.crossOrigin,options:s})},S=function(e){var t=e.lastCameraStream,r=e.callback,i=e.webcamVideoElement,n=e.options;return d()?n.savedRenderingContexts.length?(v.getWebcamGIF(n,function(e){r(e)}),void 0):(b.startVideoStreaming(function(e){e.options=n||{},y(e,r)},{lastCameraStream:t,callback:r,webcamVideoElement:i,crossOrigin:n.crossOrigin}),void 0):r(o.validate())},k=function(e,t){if(t=n.isFunction(e)?e:t,e=n.isObject(e)?e:{},n.isFunction(t)){var r=n.mergeOptions(a,e)||{},i=e.cameraStream,o=r.images,s=o?o.length:0,d=r.video,c=r.webcamVideoElement;r=n.mergeOptions(r,{gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)}),s?p({images:o,imagesLength:s,callback:t,options:r}):d?C({existingVideo:d,callback:t,options:r}):S({lastCameraStream:i,callback:t,webcamVideoElement:c,options:r})}},F=function(e,t){if(t=n.isFunction(e)?e:t,e=n.isObject(e)?e:{},n.isFunction(t)){var r=n.mergeOptions(a,e),i=n.mergeOptions(r,{interval:.1,numFrames:1,gifWidth:Math.floor(r.gifWidth),gifHeight:Math.floor(r.gifHeight)});k(i,t)}},x=function(e,t,r,i,n,o,a,s,d,c){var l={utils:e,error:t,defaultOptions:r,createGIF:s,takeSnapShot:d,stopVideoStreaming:c,isSupported:i,isWebCamGIFSupported:n,isExistingVideoGIFSupported:a,isExistingImagesGIFSupported:o,VERSION:"0.3.2"};return l}(n,o,a,s,d,c,l,k,F,w),function(t){"function"==typeof define&&define.amd?define([],function(){return t}):"undefined"!=typeof exports?module.exports=t:e.gifshot=t}(x)}("undefined"!=typeof window?window:{},"undefined"!=typeof document?document:{createElement:function(){}},"undefined"!=typeof window?window.navigator:{}); \ No newline at end of file -- cgit v1.2.3 From eb4dcce4167444cc856ed904c23d4417365dd0e8 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 30 Nov 2016 15:40:32 -0500 Subject: major rewrite of GIF creation - memory handling much better #398 - moved to Stream based support --- www/external/NeuQuant.min.js | 55 +++++++++++++++ www/external/gifwriter.min.js | 64 ++++++++++++++++++ www/external/polyfill.min.js | 4 ++ www/external/screwdriver.js | 151 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 274 insertions(+) create mode 100644 www/external/NeuQuant.min.js create mode 100644 www/external/gifwriter.min.js create mode 100644 www/external/polyfill.min.js create mode 100644 www/external/screwdriver.js (limited to 'www/external') diff --git a/www/external/NeuQuant.min.js b/www/external/NeuQuant.min.js new file mode 100644 index 00000000..12d6bb8d --- /dev/null +++ b/www/external/NeuQuant.min.js @@ -0,0 +1,55 @@ +// NeuQuant.js +// =========== + +/* + * NeuQuant Neural-Net Quantization Algorithm + * ------------------------------------------ + * + * Copyright (c) 1994 Anthony Dekker + * + * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See + * "Kohonen neural networks for optimal colour quantization" in "Network: + * Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of + * the algorithm. + * + * Any party obtaining a copy of these files from the author, directly or + * indirectly, is granted, free of charge, a full and unrestricted irrevocable, + * world-wide, paid up, royalty-free, nonexclusive right and license to deal in + * this software and documentation files (the "Software"), including without + * limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons who + * receive copies from any such party to do so, with the only requirement being + * that this copyright notice remain intact. + */ + +/* + * This class handles Neural-Net quantization algorithm + * @author Kevin Weiner (original Java version - kweiner@fmsware.com) + * @author Thibault Imbert (AS3 version - bytearray.org) + * @version 0.1 AS3 implementation + * @version 0.2 JS->AS3 "translation" by antimatter15 + * @version 0.3 JS clean up + using modern JS idioms by sole - http://soledadpenades.com + * Also implement fix in color conversion described at http://stackoverflow.com/questions/16371712/neuquant-js-javascript-color-quantization-hidden-bug-in-js-conversion + */ + +NeuQuant=function(){function r(){function r(r,n,f){var o,t +for(y=r,p=n,h=f,s=new Array(w),o=0;o>1,n=u+1;n>1,n=u+1;n<256;n++)O[n]=b}function o(){var r,n,f,o,t,a,u,s,w,b,j,k,q,x +for(p>D,u<=1&&(u=0),r=0;r=x&&(q-=p),r++,0===b&&(b=1),r%b===0)for(s-=s/e,a-=a/G,u=a>>D,u<=1&&(u=0),n=0;n=0;)o=c?o=w:(o++,a<0&&(a=-a),u=i[0]-r,u<0&&(u=-u),a+=u,a=0&&(i=s[t],a=n-i[1],a>=c?t=-1:(t--,a<0&&(a=-a),u=i[0]-r,u<0&&(u=-u),a+=u,a>=d,s[r][1]>>=d,s[r][2]>>=d,s[r][3]=r}function c(r,n,f,o,t){var a,u,c,i,v,e,y +for(c=n-r,c<-1&&(c=-1),i=n+r,i>w&&(i=w),a=n+1,u=n-1,e=1;ac;){if(v=S[e++],ac){y=s[u--] +try{y[0]-=v*(y[0]-f)/M|0,y[1]-=v*(y[1]-o)/M|0,y[2]-=v*(y[2]-t)/M|0}catch(r){}}}}function i(r,n,f,o,t){var a=s[n],u=r/I +a[0]-=u*(a[0]-f)|0,a[1]-=u*(a[1]-o)|0,a[2]-=u*(a[2]-t)|0}function v(r,n,f){var o,t,a,u,c,i,v,e,y,p +for(e=~(1<<31),y=e,i=-1,v=i,o=0;o>j-d),u>x,R[o]-=c,P[o]+=c<>x,B=k<>3,D=6,E=1<, 2013. +// // +// // https://github.com/deanm/omggif +// // +// // 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. +// // +// // omggif is a JavaScript implementation of a GIF 89a encoder and decoder, +// // including animation and compression. It does not rely on any specific +// // underlying system, so should run in the browser, Node, or Plask. +// Main compression routine, palette indexes -> LZW code stream. +// |index_stream| must have at least one entry. +"use strict" +function _classCallCheck(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function check_palette_and_num_colors(r){var e=r.length +if(e<2||e>256||e&e-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.") +return e}function GifWriterOutputLZWCodeStream(r,e,t,a){function n(t){for(;s>=t;)r[e++]=255&v,v>>=8,s-=8,e===i+256&&(r[i]=255,i=e++)}function o(r){v|=r<=8;)r[e++]=255&v,v>>=8,s-=8,e===i+256&&(r[i]=255,i=e++) +4096===d?(o(l),d=f+1,c=t+1,p={}):(d>=1<3&&void 0!==arguments[3]?arguments[3]:{} +_classCallCheck(this,r) +var o=n.loop,i=n.palette,l=0,u=[],f=i +if(t<=0||a<=0||t>65535||a>65535)throw new Error("Width/Height invalid.") +u[l++]=71,u[l++]=73,u[l++]=70,u[l++]=56,u[l++]=57,u[l++]=97 +var d=0,c=0 +if(f){for(var s=check_palette_and_num_colors(f);s>>=1;)++d +if(s=1<=s)throw new Error("Background index out of range.") +if(0===c)throw new Error("Background index explicitly passed as 0.")}}if(u[l++]=255&t,u[l++]=t>>8&255,u[l++]=255&a,u[l++]=a>>8&255,u[l++]=(f?128:0)|d,u[l++]=c,u[l++]=0,f)for(var v=f,h=Array.isArray(v),p=0,v=h?v:v[Symbol.iterator]();;){var w +if(h){if(p>=v.length)break +w=v[p++]}else{if(p=v.next(),p.done)break +w=p.value}var g=w +u[l++]=g>>16&255,u[l++]=g>>8&255,u[l++]=255&g}if(Number.isInteger(o)){if(o<0||o>65535)throw"Loop count invalid." +u[l++]=33,u[l++]=255,u[l++]=11,u[l++]=78,u[l++]=69,u[l++]=84,u[l++]=83,u[l++]=67,u[l++]=65,u[l++]=80,u[l++]=69,u[l++]=50,u[l++]=46,u[l++]=48,u[l++]=3,u[l++]=1,u[l++]=255&o,u[l++]=o>>8&255,u[l++]=0}var _=this,y=e.getReader() +return new ReadableStream({start:function(r){r.enqueue(new Uint8Array(u))},pull:function(r){return y.read().then(function(e){var t=e.done,a=e.value +return t?(r.enqueue(new Uint8Array([59])),void r.close()):void _.addFrame.apply(_,[r].concat(a))})}})}return r.prototype.addFrame=function(r,e,t,a,n,o){var i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{},l=0,u=[] +if(e<0||t<0||e>65535||t>65535)throw new Error("x/y invalid.") +if(a<=0||n<=0||a>65535||n>65535)throw"Width/Height invalid." +if(o.length>=1;)++s +c=1<3)throw"Disposal out of range." +var p=!1,w=0 +if(void 0!==i.transparent&&null!==i.transparent&&(p=!0,w=i.transparent,w<0||w>=c))throw"Transparent color index." +if((0!==h||p||0!==v)&&(u[l++]=33,u[l++]=249,u[l++]=4,u[l++]=h<<2|(p===!0?1:0),u[l++]=255&v,u[l++]=v>>8&255,u[l++]=w,u[l++]=0),u[l++]=44,u[l++]=255&e,u[l++]=e>>8&255,u[l++]=255&t,u[l++]=t>>8&255,u[l++]=255&a,u[l++]=a>>8&255,u[l++]=255&n,u[l++]=n>>8&255,u[l++]=f===!0?128|s-1:0,f===!0)for(var g=0,_=d.length;g<_;++g){var y=d[g] +u[l++]=y>>16&255,u[l++]=y>>8&255,u[l++]=255&y}GifWriterOutputLZWCodeStream(u,l,s<2?2:s,o),r.enqueue(new Uint8Array(u))},r}() diff --git a/www/external/polyfill.min.js b/www/external/polyfill.min.js new file mode 100644 index 00000000..dd753762 --- /dev/null +++ b/www/external/polyfill.min.js @@ -0,0 +1,4 @@ +!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g["default"]=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o=0;i--)if(ka[i]!=kb[i])return!1;for(i=ka.length-1;i>=0;i--)if(key=ka[i],!_deepEqual(a[key],b[key]))return!1;return!0}function expectedException(actual,expected){return actual&&expected?"[object RegExp]"==Object.prototype.toString.call(expected)?expected.test(actual):actual instanceof expected?!0:expected.call({},actual)===!0:!1}function _throws(shouldThrow,block,expected,message){var actual;util.isString(expected)&&(message=expected,expected=null);try{block()}catch(e){actual=e}if(message=(expected&&expected.name?" ("+expected.name+").":".")+(message?" "+message:"."),shouldThrow&&!actual&&fail(actual,expected,"Missing expected exception"+message),!shouldThrow&&expectedException(actual,expected)&&fail(actual,expected,"Got unwanted exception"+message),shouldThrow&&actual&&expected&&!expectedException(actual,expected)||!shouldThrow&&actual)throw actual}var util=require("util/"),pSlice=Array.prototype.slice,hasOwn=Object.prototype.hasOwnProperty,assert=module.exports=ok;assert.AssertionError=function(options){this.name="AssertionError",this.actual=options.actual,this.expected=options.expected,this.operator=options.operator,options.message?(this.message=options.message,this.generatedMessage=!1):(this.message=getMessage(this),this.generatedMessage=!0);var stackStartFunction=options.stackStartFunction||fail;if(Error.captureStackTrace)Error.captureStackTrace(this,stackStartFunction);else{var err=new Error;if(err.stack){var out=err.stack,fn_name=stackStartFunction.name,idx=out.indexOf("\n"+fn_name);if(idx>=0){var next_line=out.indexOf("\n",idx+1);out=out.substring(next_line+1)}this.stack=out}}},util.inherits(assert.AssertionError,Error),assert.fail=fail,assert.ok=ok,assert.equal=function(actual,expected,message){actual!=expected&&fail(actual,expected,message,"==",assert.equal)},assert.notEqual=function(actual,expected,message){actual==expected&&fail(actual,expected,message,"!=",assert.notEqual)},assert.deepEqual=function(actual,expected,message){_deepEqual(actual,expected)||fail(actual,expected,message,"deepEqual",assert.deepEqual)},assert.notDeepEqual=function(actual,expected,message){_deepEqual(actual,expected)&&fail(actual,expected,message,"notDeepEqual",assert.notDeepEqual)},assert.strictEqual=function(actual,expected,message){actual!==expected&&fail(actual,expected,message,"===",assert.strictEqual)},assert.notStrictEqual=function(actual,expected,message){actual===expected&&fail(actual,expected,message,"!==",assert.notStrictEqual)},assert["throws"]=function(block,error,message){_throws.apply(this,[!0].concat(pSlice.call(arguments)))},assert.doesNotThrow=function(block,message){_throws.apply(this,[!1].concat(pSlice.call(arguments)))},assert.ifError=function(err){if(err)throw err};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)hasOwn.call(obj,key)&&keys.push(key);return keys}},{"util/":6}],3:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],4:[function(require,module,exports){function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=cachedSetTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex1)for(var i=1;i=3&&(ctx.depth=arguments[2]),arguments.length>=4&&(ctx.colors=arguments[3]),isBoolean(opts)?ctx.showHidden=opts:opts&&exports._extend(ctx,opts),isUndefined(ctx.showHidden)&&(ctx.showHidden=!1),isUndefined(ctx.depth)&&(ctx.depth=2),isUndefined(ctx.colors)&&(ctx.colors=!1),isUndefined(ctx.customInspect)&&(ctx.customInspect=!0),ctx.colors&&(ctx.stylize=stylizeWithColor),formatValue(ctx,obj,ctx.depth)}function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];return style?"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m":str}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&(!value.constructor||value.constructor.prototype!==value)){var ret=value.inspect(recurseTimes,ctx);return isString(ret)||(ret=formatValue(ctx,ret,recurseTimes)),ret}var primitive=formatPrimitive(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=arrayToHash(keys);if(ctx.showHidden&&(keys=Object.getOwnPropertyNames(value)),isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0))return formatError(value);if(0===keys.length){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),"regexp");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),"date");if(isError(value))return formatError(value)}var base="",array=!1,braces=["{","}"];if(isArray(value)&&(array=!0,braces=["[","]"]),isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)&&(base=" "+RegExp.prototype.toString.call(value)),isDate(value)&&(base=" "+Date.prototype.toUTCString.call(value)),isError(value)&&(base=" "+formatError(value)),0===keys.length&&(!array||0==value.length))return braces[0]+base+braces[1];if(0>recurseTimes)return isRegExp(value)?ctx.stylize(RegExp.prototype.toString.call(value),"regexp"):ctx.stylize("[Object]","special");ctx.seen.push(value);var output;return output=array?formatArray(ctx,value,recurseTimes,visibleKeys,keys):keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)}),ctx.seen.pop(),reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}return isNumber(value)?ctx.stylize(""+value,"number"):isBoolean(value)?ctx.stylize(""+value,"boolean"):isNull(value)?ctx.stylize("null","null"):void 0}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){for(var output=[],i=0,l=value.length;l>i;++i)hasOwnProperty(value,String(i))?output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),!0)):output.push("");return keys.forEach(function(key){key.match(/^\d+$/)||output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,!0))}),output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;if(desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]},desc.get?str=desc.set?ctx.stylize("[Getter/Setter]","special"):ctx.stylize("[Getter]","special"):desc.set&&(str=ctx.stylize("[Setter]","special")),hasOwnProperty(visibleKeys,key)||(name="["+key+"]"),str||(ctx.seen.indexOf(desc.value)<0?(str=isNull(recurseTimes)?formatValue(ctx,desc.value,null):formatValue(ctx,desc.value,recurseTimes-1),str.indexOf("\n")>-1&&(str=array?str.split("\n").map(function(line){return" "+line}).join("\n").substr(2):"\n"+str.split("\n").map(function(line){return" "+line}).join("\n"))):str=ctx.stylize("[Circular]","special")),isUndefined(name)){if(array&&key.match(/^\d+$/))return str;name=JSON.stringify(""+key),name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(name=name.substr(1,name.length-2),name=ctx.stylize(name,"name")):(name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),name=ctx.stylize(name,"string"))}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0,length=output.reduce(function(prev,cur){return numLinesEst++,cur.indexOf("\n")>=0&&numLinesEst++,prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);return length>60?braces[0]+(""===base?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]:braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNullOrUndefined(arg){return null==arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isSymbol(arg){return"symbol"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return isObject(re)&&"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"==typeof arg&&null!==arg}function isDate(d){return isObject(d)&&"[object Date]"===objectToString(d)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(arg){return"function"==typeof arg}function isPrimitive(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"==typeof arg||"undefined"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return 10>n?"0"+n.toString(10):n.toString(10)}function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){for(var objects=[],i=0;i=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}}),x=args[i];len>i;x=args[++i])str+=isNull(x)||!isObject(x)?" "+x:" "+inspect(x);return str},exports.deprecate=function(fn,msg){function deprecated(){if(!warned){if(process.throwDeprecation)throw new Error(msg);process.traceDeprecation?console.trace(msg):console.error(msg),warned=!0}return fn.apply(this,arguments)}if(isUndefined(global.process))return function(){return exports.deprecate(fn,msg).apply(this,arguments)};if(process.noDeprecation===!0)return fn;var warned=!1;return deprecated};var debugEnviron,debugs={};exports.debuglog=function(set){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),set=set.toUpperCase(),!debugs[set])if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else debugs[set]=function(){};return debugs[set]},exports.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(origin,add){if(!add||!isObject(add))return origin;for(var keys=Object.keys(add),i=keys.length;i--;)origin[keys[i]]=add[keys[i]];return origin}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":5,_process:4,inherits:3}],7:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i1?_len-1:0),_key=1;_len>_key;_key++)args[_key-1]=arguments[_key];try{return Promise.resolve(func.apply(void 0,args))}catch(e){return Promise.reject(e)}},exports.typeIsObject=function(x){return"object"===("undefined"==typeof x?"undefined":_typeof(x))&&null!==x||"function"==typeof x},exports.toInteger=function(v){return v=Number(v),isNaN(v)?0:0>v?-1*Math.floor(Math.abs(v)):Math.floor(Math.abs(v))},exports.createDataProperty=function(o,p,v){assert(exports.typeIsObject(o)),Object.defineProperty(o,p,{value:v,writable:!0,enumerable:!0,configurable:!0})},exports.createArrayFromList=function(elements){return elements.slice()},exports.ArrayBufferCopy=function(dest,destOffset,src,srcOffset,n){new Uint8Array(dest).set(new Uint8Array(src,srcOffset,n),destOffset)},exports.CreateIterResultObject=function(value,done){assert("boolean"==typeof done);var obj={};return Object.defineProperty(obj,"value",{value:value,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(obj,"done",{value:done,enumerable:!0,writable:!0,configurable:!0}),obj},exports.IsFiniteNonNegativeNumber=function(v){return Number.isNaN(v)?!1:v===1/0?!1:!(0>v)},exports.InvokeOrNoop=function(O,P,args){var method=O[P];if(void 0!==method)return method.apply(O,args)},exports.PromiseInvokeOrNoop=function(O,P,args){var method=void 0;try{method=O[P]}catch(methodE){return Promise.reject(methodE)}if(void 0===method)return Promise.resolve(void 0);try{return Promise.resolve(method.apply(O,args))}catch(e){return Promise.reject(e)}},exports.PromiseInvokeOrFallbackOrNoop=function(O,P1,args1,P2,args2){var method=void 0;try{method=O[P1]}catch(methodE){return Promise.reject(methodE)}if(void 0===method)return exports.PromiseInvokeOrNoop(O,P2,args2);try{return Promise.resolve(method.apply(O,args1))}catch(e){return Promise.reject(e)}},exports.SameRealmTransfer=function(O){return O},exports.ValidateAndNormalizeHighWaterMark=function(highWaterMark){if(highWaterMark=Number(highWaterMark),Number.isNaN(highWaterMark)||0>highWaterMark)throw new RangeError("highWaterMark property of a queuing strategy must be nonnegative and non-NaN");return highWaterMark},exports.ValidateAndNormalizeQueuingStrategy=function(size,highWaterMark){if(void 0!==size&&"function"!=typeof size)throw new TypeError("size property of a queuing strategy must be a function");return highWaterMark=exports.ValidateAndNormalizeHighWaterMark(highWaterMark),{size:size,highWaterMark:highWaterMark}}},{assert:2}],10:[function(require,module,exports){"use strict";var assert=require("assert"),_require=require("./helpers.js"),IsFiniteNonNegativeNumber=_require.IsFiniteNonNegativeNumber;exports.DequeueValue=function(queue){assert(queue.length>0,"Spec-level failure: should never dequeue from an empty queue.");var pair=queue.shift();return queue._totalSize-=pair.size,pair.value},exports.EnqueueValueWithSize=function(queue,value,size){if(size=Number(size),!IsFiniteNonNegativeNumber(size))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");queue.push({value:value,size:size}),void 0===queue._totalSize&&(queue._totalSize=0),queue._totalSize+=size},exports.GetTotalQueueSize=function(queue){return void 0===queue._totalSize&&(queue._totalSize=0),queue._totalSize},exports.PeekQueueValue=function(queue){assert(queue.length>0,"Spec-level failure: should never peek at an empty queue.");var pair=queue[0];return pair.value}},{"./helpers.js":9,assert:2}],11:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function AcquireReadableStreamBYOBReader(stream){return new ReadableStreamBYOBReader(stream)}function AcquireReadableStreamDefaultReader(stream){return new ReadableStreamDefaultReader(stream)}function IsReadableStream(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_readableStreamController"):!1}function IsReadableStreamDisturbed(stream){return assert(IsReadableStream(stream)===!0,"IsReadableStreamDisturbed should only be used on known readable streams"),stream._disturbed}function IsReadableStreamLocked(stream){return assert(IsReadableStream(stream)===!0,"IsReadableStreamLocked should only be used on known readable streams"),void 0!==stream._reader}function ReadableStreamTee(stream,shouldClone){assert(IsReadableStream(stream)===!0),assert("boolean"==typeof shouldClone);var reader=AcquireReadableStreamDefaultReader(stream),teeState={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:void 0,reason2:void 0};teeState.promise=new Promise(function(resolve){teeState._resolve=resolve});var pull=create_ReadableStreamTeePullFunction();pull._reader=reader,pull._teeState=teeState,pull._shouldClone=shouldClone;var cancel1=create_ReadableStreamTeeBranch1CancelFunction();cancel1._stream=stream,cancel1._teeState=teeState;var cancel2=create_ReadableStreamTeeBranch2CancelFunction();cancel2._stream=stream,cancel2._teeState=teeState;var underlyingSource1=Object.create(Object.prototype);createDataProperty(underlyingSource1,"pull",pull),createDataProperty(underlyingSource1,"cancel",cancel1);var branch1Stream=new ReadableStream(underlyingSource1),underlyingSource2=Object.create(Object.prototype);createDataProperty(underlyingSource2,"pull",pull),createDataProperty(underlyingSource2,"cancel",cancel2);var branch2Stream=new ReadableStream(underlyingSource2);return pull._branch1=branch1Stream._readableStreamController,pull._branch2=branch2Stream._readableStreamController,reader._closedPromise["catch"](function(r){teeState.closedOrErrored!==!0&&(ReadableStreamDefaultControllerError(pull._branch1,r),ReadableStreamDefaultControllerError(pull._branch2,r),teeState.closedOrErrored=!0)}),[branch1Stream,branch2Stream]}function create_ReadableStreamTeePullFunction(){function f(){var reader=f._reader,branch1=f._branch1,branch2=f._branch2,teeState=f._teeState;return ReadableStreamDefaultReaderRead(reader).then(function(result){assert(typeIsObject(result));var value=result.value,done=result.done;if(assert("boolean"==typeof done),done===!0&&teeState.closedOrErrored===!1&&(teeState.canceled1===!1&&ReadableStreamDefaultControllerClose(branch1),teeState.canceled2===!1&&ReadableStreamDefaultControllerClose(branch2),teeState.closedOrErrored=!0),teeState.closedOrErrored!==!0){if(teeState.canceled1===!1){var value1=value;ReadableStreamDefaultControllerEnqueue(branch1,value1)}if(teeState.canceled2===!1){var value2=value;ReadableStreamDefaultControllerEnqueue(branch2,value2)}}})}return f}function create_ReadableStreamTeeBranch1CancelFunction(){function f(reason){var stream=f._stream,teeState=f._teeState;if(teeState.canceled1=!0,teeState.reason1=reason,teeState.canceled2===!0){var compositeReason=createArrayFromList([teeState.reason1,teeState.reason2]),cancelResult=ReadableStreamCancel(stream,compositeReason);teeState._resolve(cancelResult)}return teeState.promise}return f}function create_ReadableStreamTeeBranch2CancelFunction(){function f(reason){var stream=f._stream,teeState=f._teeState;if(teeState.canceled2=!0,teeState.reason2=reason,teeState.canceled1===!0){var compositeReason=createArrayFromList([teeState.reason1,teeState.reason2]),cancelResult=ReadableStreamCancel(stream,compositeReason);teeState._resolve(cancelResult)}return teeState.promise}return f}function ReadableStreamAddReadIntoRequest(stream){assert(IsReadableStreamBYOBReader(stream._reader)===!0),assert("readable"===stream._state||"closed"===stream._state);var promise=new Promise(function(resolve,reject){var readIntoRequest={_resolve:resolve,_reject:reject};stream._reader._readIntoRequests.push(readIntoRequest)});return promise}function ReadableStreamAddReadRequest(stream){assert(IsReadableStreamDefaultReader(stream._reader)===!0),assert("readable"===stream._state);var promise=new Promise(function(resolve,reject){var readRequest={_resolve:resolve,_reject:reject};stream._reader._readRequests.push(readRequest)});return promise}function ReadableStreamCancel(stream,reason){if(stream._disturbed=!0,"closed"===stream._state)return Promise.resolve(void 0);if("errored"===stream._state)return Promise.reject(stream._storedError);ReadableStreamClose(stream);var sourceCancelPromise=stream._readableStreamController[InternalCancel](reason);return sourceCancelPromise.then(function(){})}function ReadableStreamClose(stream){assert("readable"===stream._state),stream._state="closed";var reader=stream._reader;if(void 0!==reader){if(IsReadableStreamDefaultReader(reader)===!0){var _iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=reader._readRequests[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var _resolve=_step.value._resolve;_resolve(CreateIterResultObject(void 0,!0))}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator["return"]&&_iterator["return"]()}finally{if(_didIteratorError)throw _iteratorError}}reader._readRequests=[]}defaultReaderClosedPromiseResolve(reader)}}function ReadableStreamError(stream,e){assert(IsReadableStream(stream)===!0,"stream must be ReadableStream"),assert("readable"===stream._state,"state must be readable"),stream._state="errored",stream._storedError=e;var reader=stream._reader;if(void 0!==reader){if(IsReadableStreamDefaultReader(reader)===!0){var _iteratorNormalCompletion2=!0,_didIteratorError2=!1,_iteratorError2=void 0;try{for(var _step2,_iterator2=reader._readRequests[Symbol.iterator]();!(_iteratorNormalCompletion2=(_step2=_iterator2.next()).done);_iteratorNormalCompletion2=!0){var readRequest=_step2.value;readRequest._reject(e)}}catch(err){_didIteratorError2=!0,_iteratorError2=err}finally{try{!_iteratorNormalCompletion2&&_iterator2["return"]&&_iterator2["return"]()}finally{if(_didIteratorError2)throw _iteratorError2}}reader._readRequests=[]}else{assert(IsReadableStreamBYOBReader(reader),"reader must be ReadableStreamBYOBReader");var _iteratorNormalCompletion3=!0,_didIteratorError3=!1,_iteratorError3=void 0;try{for(var _step3,_iterator3=reader._readIntoRequests[Symbol.iterator]();!(_iteratorNormalCompletion3=(_step3=_iterator3.next()).done);_iteratorNormalCompletion3=!0){var readIntoRequest=_step3.value;readIntoRequest._reject(e)}}catch(err){_didIteratorError3=!0,_iteratorError3=err}finally{try{!_iteratorNormalCompletion3&&_iterator3["return"]&&_iterator3["return"]()}finally{if(_didIteratorError3)throw _iteratorError3}}reader._readIntoRequests=[]}defaultReaderClosedPromiseReject(reader,e)}}function ReadableStreamFulfillReadIntoRequest(stream,chunk,done){var reader=stream._reader;assert(reader._readIntoRequests.length>0);var readIntoRequest=reader._readIntoRequests.shift();readIntoRequest._resolve(CreateIterResultObject(chunk,done))}function ReadableStreamFulfillReadRequest(stream,chunk,done){var reader=stream._reader;assert(reader._readRequests.length>0);var readRequest=reader._readRequests.shift();readRequest._resolve(CreateIterResultObject(chunk,done))}function ReadableStreamGetNumReadIntoRequests(stream){return stream._reader._readIntoRequests.length}function ReadableStreamGetNumReadRequests(stream){ +return stream._reader._readRequests.length}function ReadableStreamHasBYOBReader(stream){var reader=stream._reader;return void 0===reader?!1:IsReadableStreamBYOBReader(reader)!==!1}function ReadableStreamHasDefaultReader(stream){var reader=stream._reader;return void 0===reader?!1:IsReadableStreamDefaultReader(reader)!==!1}function IsReadableStreamBYOBReader(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_readIntoRequests"):!1}function IsReadableStreamDefaultReader(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_readRequests"):!1}function ReadableStreamReaderGenericInitialize(reader,stream){reader._ownerReadableStream=stream,stream._reader=reader,"readable"===stream._state?defaultReaderClosedPromiseInitialize(reader):"closed"===stream._state?defaultReaderClosedPromiseInitializeAsResolved(reader):(assert("errored"===stream._state,"state must be errored"),defaultReaderClosedPromiseInitializeAsRejected(reader,stream._storedError))}function ReadableStreamReaderGenericCancel(reader,reason){var stream=reader._ownerReadableStream;return assert(void 0!==stream),ReadableStreamCancel(stream,reason)}function ReadableStreamReaderGenericRelease(reader){assert(void 0!==reader._ownerReadableStream),assert(reader._ownerReadableStream._reader===reader),"readable"===reader._ownerReadableStream._state?defaultReaderClosedPromiseReject(reader,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):defaultReaderClosedPromiseResetToRejected(reader,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),reader._ownerReadableStream._reader=void 0,reader._ownerReadableStream=void 0}function ReadableStreamBYOBReaderRead(reader,view){var stream=reader._ownerReadableStream;return assert(void 0!==stream),stream._disturbed=!0,"errored"===stream._state?Promise.reject(stream._storedError):ReadableByteStreamControllerPullInto(stream._readableStreamController,view)}function ReadableStreamDefaultReaderRead(reader){var stream=reader._ownerReadableStream;return assert(void 0!==stream),stream._disturbed=!0,"closed"===stream._state?Promise.resolve(CreateIterResultObject(void 0,!0)):"errored"===stream._state?Promise.reject(stream._storedError):(assert("readable"===stream._state),stream._readableStreamController[InternalPull]())}function IsReadableStreamDefaultController(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_underlyingSource"):!1}function ReadableStreamDefaultControllerCallPullIfNeeded(controller){var shouldPull=ReadableStreamDefaultControllerShouldCallPull(controller);if(shouldPull!==!1){if(controller._pulling===!0)return void(controller._pullAgain=!0);controller._pulling=!0;var pullPromise=PromiseInvokeOrNoop(controller._underlyingSource,"pull",[controller]);pullPromise.then(function(){return controller._pulling=!1,controller._pullAgain===!0?(controller._pullAgain=!1,ReadableStreamDefaultControllerCallPullIfNeeded(controller)):void 0},function(e){ReadableStreamDefaultControllerErrorIfNeeded(controller,e)})["catch"](rethrowAssertionErrorRejection)}}function ReadableStreamDefaultControllerShouldCallPull(controller){var stream=controller._controlledReadableStream;if("closed"===stream._state||"errored"===stream._state)return!1;if(controller._closeRequested===!0)return!1;if(controller._started===!1)return!1;if(IsReadableStreamLocked(stream)===!0&&ReadableStreamGetNumReadRequests(stream)>0)return!0;var desiredSize=ReadableStreamDefaultControllerGetDesiredSize(controller);return desiredSize>0}function ReadableStreamDefaultControllerClose(controller){var stream=controller._controlledReadableStream;assert(controller._closeRequested===!1),assert("readable"===stream._state),controller._closeRequested=!0,0===controller._queue.length&&ReadableStreamClose(stream)}function ReadableStreamDefaultControllerEnqueue(controller,chunk){var stream=controller._controlledReadableStream;if(assert(controller._closeRequested===!1),assert("readable"===stream._state),IsReadableStreamLocked(stream)===!0&&ReadableStreamGetNumReadRequests(stream)>0)ReadableStreamFulfillReadRequest(stream,chunk,!1);else{var chunkSize=1;if(void 0!==controller._strategySize)try{chunkSize=controller._strategySize(chunk)}catch(chunkSizeE){throw ReadableStreamDefaultControllerErrorIfNeeded(controller,chunkSizeE),chunkSizeE}try{EnqueueValueWithSize(controller._queue,chunk,chunkSize)}catch(enqueueE){throw ReadableStreamDefaultControllerErrorIfNeeded(controller,enqueueE),enqueueE}}ReadableStreamDefaultControllerCallPullIfNeeded(controller)}function ReadableStreamDefaultControllerError(controller,e){var stream=controller._controlledReadableStream;assert("readable"===stream._state),controller._queue=[],ReadableStreamError(stream,e)}function ReadableStreamDefaultControllerErrorIfNeeded(controller,e){"readable"===controller._controlledReadableStream._state&&ReadableStreamDefaultControllerError(controller,e)}function ReadableStreamDefaultControllerGetDesiredSize(controller){var queueSize=GetTotalQueueSize(controller._queue);return controller._strategyHWM-queueSize}function IsReadableByteStreamController(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_underlyingByteSource"):!1}function IsReadableStreamBYOBRequest(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_associatedReadableByteStreamController"):!1}function ReadableByteStreamControllerCallPullIfNeeded(controller){var shouldPull=ReadableByteStreamControllerShouldCallPull(controller);if(shouldPull!==!1){if(controller._pulling===!0)return void(controller._pullAgain=!0);controller._pullAgain=!1,controller._pulling=!0;var pullPromise=PromiseInvokeOrNoop(controller._underlyingByteSource,"pull",[controller]);pullPromise.then(function(){controller._pulling=!1,controller._pullAgain===!0&&(controller._pullAgain=!1,ReadableByteStreamControllerCallPullIfNeeded(controller))},function(e){"readable"===controller._controlledReadableStream._state&&ReadableByteStreamControllerError(controller,e)})["catch"](rethrowAssertionErrorRejection)}}function ReadableByteStreamControllerClearPendingPullIntos(controller){ReadableByteStreamControllerInvalidateBYOBRequest(controller),controller._pendingPullIntos=[]}function ReadableByteStreamControllerCommitPullIntoDescriptor(stream,pullIntoDescriptor){assert("errored"!==stream._state,"state must not be errored");var done=!1;"closed"===stream._state&&(assert(0===pullIntoDescriptor.bytesFilled),done=!0);var filledView=ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);"default"===pullIntoDescriptor.readerType?ReadableStreamFulfillReadRequest(stream,filledView,done):(assert("byob"===pullIntoDescriptor.readerType),ReadableStreamFulfillReadIntoRequest(stream,filledView,done))}function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor){var bytesFilled=pullIntoDescriptor.bytesFilled,elementSize=pullIntoDescriptor.elementSize;return assert(bytesFilled<=pullIntoDescriptor.byteLength),assert(bytesFilled%elementSize===0),new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer,pullIntoDescriptor.byteOffset,bytesFilled/elementSize)}function ReadableByteStreamControllerEnqueueChunkToQueue(controller,buffer,byteOffset,byteLength){controller._queue.push({buffer:buffer,byteOffset:byteOffset,byteLength:byteLength}),controller._totalQueuedBytes+=byteLength}function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller,pullIntoDescriptor){var elementSize=pullIntoDescriptor.elementSize,currentAlignedBytes=pullIntoDescriptor.bytesFilled-pullIntoDescriptor.bytesFilled%elementSize,maxBytesToCopy=Math.min(controller._totalQueuedBytes,pullIntoDescriptor.byteLength-pullIntoDescriptor.bytesFilled),maxBytesFilled=pullIntoDescriptor.bytesFilled+maxBytesToCopy,maxAlignedBytes=maxBytesFilled-maxBytesFilled%elementSize,totalBytesToCopyRemaining=maxBytesToCopy,ready=!1;maxAlignedBytes>currentAlignedBytes&&(totalBytesToCopyRemaining=maxAlignedBytes-pullIntoDescriptor.bytesFilled,ready=!0);for(var queue=controller._queue;totalBytesToCopyRemaining>0;){var headOfQueue=queue[0],bytesToCopy=Math.min(totalBytesToCopyRemaining,headOfQueue.byteLength),destStart=pullIntoDescriptor.byteOffset+pullIntoDescriptor.bytesFilled;ArrayBufferCopy(pullIntoDescriptor.buffer,destStart,headOfQueue.buffer,headOfQueue.byteOffset,bytesToCopy),headOfQueue.byteLength===bytesToCopy?queue.shift():(headOfQueue.byteOffset+=bytesToCopy,headOfQueue.byteLength-=bytesToCopy),controller._totalQueuedBytes-=bytesToCopy,ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller,bytesToCopy,pullIntoDescriptor),totalBytesToCopyRemaining-=bytesToCopy}return ready===!1&&(assert(0===controller._totalQueuedBytes,"queue must be empty"),assert(pullIntoDescriptor.bytesFilled>0),assert(pullIntoDescriptor.bytesFilled0;){if(0===controller._totalQueuedBytes)return;var pullIntoDescriptor=controller._pendingPullIntos[0];ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller,pullIntoDescriptor)===!0&&(ReadableByteStreamControllerShiftPendingPullInto(controller),ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream,pullIntoDescriptor))}}function ReadableByteStreamControllerPullInto(controller,view){var stream=controller._controlledReadableStream,elementSize=1;view.constructor!==DataView&&(elementSize=view.constructor.BYTES_PER_ELEMENT);var ctor=view.constructor,pullIntoDescriptor={buffer:view.buffer,byteOffset:view.byteOffset,byteLength:view.byteLength,bytesFilled:0,elementSize:elementSize,ctor:ctor,readerType:"byob"};if(controller._pendingPullIntos.length>0)return pullIntoDescriptor.buffer=SameRealmTransfer(pullIntoDescriptor.buffer),controller._pendingPullIntos.push(pullIntoDescriptor),ReadableStreamAddReadIntoRequest(stream);if("closed"===stream._state){var emptyView=new view.constructor(view.buffer,view.byteOffset,0);return Promise.resolve(CreateIterResultObject(emptyView,!0))}if(controller._totalQueuedBytes>0){if(ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller,pullIntoDescriptor)===!0){var filledView=ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);return ReadableByteStreamControllerHandleQueueDrain(controller),Promise.resolve(CreateIterResultObject(filledView,!1))}if(controller._closeRequested===!0){var e=new TypeError("Insufficient bytes to fill elements in the given buffer");return ReadableByteStreamControllerError(controller,e),Promise.reject(e)}}pullIntoDescriptor.buffer=SameRealmTransfer(pullIntoDescriptor.buffer),controller._pendingPullIntos.push(pullIntoDescriptor);var promise=ReadableStreamAddReadIntoRequest(stream);return ReadableByteStreamControllerCallPullIfNeeded(controller),promise}function ReadableByteStreamControllerRespondInClosedState(controller,firstDescriptor){firstDescriptor.buffer=SameRealmTransfer(firstDescriptor.buffer),assert(0===firstDescriptor.bytesFilled,"bytesFilled must be 0");for(var stream=controller._controlledReadableStream;ReadableStreamGetNumReadIntoRequests(stream)>0;){var pullIntoDescriptor=ReadableByteStreamControllerShiftPendingPullInto(controller);ReadableByteStreamControllerCommitPullIntoDescriptor(stream,pullIntoDescriptor)}}function ReadableByteStreamControllerRespondInReadableState(controller,bytesWritten,pullIntoDescriptor){if(pullIntoDescriptor.bytesFilled+bytesWritten>pullIntoDescriptor.byteLength)throw new RangeError("bytesWritten out of range");if(ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller,bytesWritten,pullIntoDescriptor),!(pullIntoDescriptor.bytesFilled0){var end=pullIntoDescriptor.byteOffset+pullIntoDescriptor.bytesFilled,remainder=pullIntoDescriptor.buffer.slice(end-remainderSize,end);ReadableByteStreamControllerEnqueueChunkToQueue(controller,remainder,0,remainder.byteLength)}pullIntoDescriptor.buffer=SameRealmTransfer(pullIntoDescriptor.buffer),pullIntoDescriptor.bytesFilled-=remainderSize,ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream,pullIntoDescriptor),ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller)}}function ReadableByteStreamControllerRespondInternal(controller,bytesWritten){var firstDescriptor=controller._pendingPullIntos[0],stream=controller._controlledReadableStream;if("closed"===stream._state){if(0!==bytesWritten)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");ReadableByteStreamControllerRespondInClosedState(controller,firstDescriptor)}else assert("readable"===stream._state),ReadableByteStreamControllerRespondInReadableState(controller,bytesWritten,firstDescriptor)}function ReadableByteStreamControllerShiftPendingPullInto(controller){var descriptor=controller._pendingPullIntos.shift();return ReadableByteStreamControllerInvalidateBYOBRequest(controller),descriptor}function ReadableByteStreamControllerShouldCallPull(controller){var stream=controller._controlledReadableStream;return"readable"!==stream._state?!1:controller._closeRequested===!0?!1:controller._started===!1?!1:ReadableStreamHasDefaultReader(stream)&&ReadableStreamGetNumReadRequests(stream)>0?!0:ReadableStreamHasBYOBReader(stream)&&ReadableStreamGetNumReadIntoRequests(stream)>0?!0:ReadableByteStreamControllerGetDesiredSize(controller)>0}function ReadableByteStreamControllerClose(controller){var stream=controller._controlledReadableStream;if(assert(controller._closeRequested===!1),assert("readable"===stream._state),controller._totalQueuedBytes>0)return void(controller._closeRequested=!0);if(controller._pendingPullIntos.length>0){var firstPendingPullInto=controller._pendingPullIntos[0];if(firstPendingPullInto.bytesFilled>0){var e=new TypeError("Insufficient bytes to fill elements in the given buffer");throw ReadableByteStreamControllerError(controller,e),e}}ReadableStreamClose(stream)}function ReadableByteStreamControllerEnqueue(controller,chunk){var stream=controller._controlledReadableStream;assert(controller._closeRequested===!1),assert("readable"===stream._state);var buffer=chunk.buffer,byteOffset=chunk.byteOffset,byteLength=chunk.byteLength,transferredBuffer=SameRealmTransfer(buffer);if(ReadableStreamHasDefaultReader(stream)===!0)if(0===ReadableStreamGetNumReadRequests(stream))ReadableByteStreamControllerEnqueueChunkToQueue(controller,transferredBuffer,byteOffset,byteLength);else{assert(0===controller._queue.length);var transferredView=new Uint8Array(transferredBuffer,byteOffset,byteLength);ReadableStreamFulfillReadRequest(stream,transferredView,!1)}else ReadableStreamHasBYOBReader(stream)===!0?(ReadableByteStreamControllerEnqueueChunkToQueue(controller,transferredBuffer,byteOffset,byteLength),ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller)):(assert(IsReadableStreamLocked(stream)===!1,"stream must not be locked"),ReadableByteStreamControllerEnqueueChunkToQueue(controller,transferredBuffer,byteOffset,byteLength))}function ReadableByteStreamControllerError(controller,e){var stream=controller._controlledReadableStream;assert("readable"===stream._state),ReadableByteStreamControllerClearPendingPullIntos(controller),controller._queue=[],ReadableStreamError(stream,e)}function ReadableByteStreamControllerGetDesiredSize(controller){return controller._strategyHWM-controller._totalQueuedBytes}function ReadableByteStreamControllerRespond(controller,bytesWritten){if(bytesWritten=Number(bytesWritten),IsFiniteNonNegativeNumber(bytesWritten)===!1)throw new RangeError("bytesWritten must be a finite");assert(controller._pendingPullIntos.length>0),ReadableByteStreamControllerRespondInternal(controller,bytesWritten)}function ReadableByteStreamControllerRespondWithNewView(controller,view){assert(controller._pendingPullIntos.length>0);var firstDescriptor=controller._pendingPullIntos[0];if(firstDescriptor.byteOffset+firstDescriptor.bytesFilled!==view.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(firstDescriptor.byteLength!==view.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");firstDescriptor.buffer=view.buffer,ReadableByteStreamControllerRespondInternal(controller,view.byteLength)}function streamBrandCheckException(name){return new TypeError("ReadableStream.prototype."+name+" can only be used on a ReadableStream")}function readerLockException(name){return new TypeError("Cannot "+name+" a stream using a released reader")}function defaultReaderBrandCheckException(name){return new TypeError("ReadableStreamDefaultReader.prototype."+name+" can only be used on a ReadableStreamDefaultReader")}function defaultReaderClosedPromiseInitialize(reader){reader._closedPromise=new Promise(function(resolve,reject){reader._closedPromise_resolve=resolve,reader._closedPromise_reject=reject})}function defaultReaderClosedPromiseInitializeAsRejected(reader,reason){reader._closedPromise=Promise.reject(reason),reader._closedPromise_resolve=void 0,reader._closedPromise_reject=void 0}function defaultReaderClosedPromiseInitializeAsResolved(reader){reader._closedPromise=Promise.resolve(void 0),reader._closedPromise_resolve=void 0,reader._closedPromise_reject=void 0}function defaultReaderClosedPromiseReject(reader,reason){assert(void 0!==reader._closedPromise_resolve),assert(void 0!==reader._closedPromise_reject),reader._closedPromise_reject(reason),reader._closedPromise_resolve=void 0,reader._closedPromise_reject=void 0}function defaultReaderClosedPromiseResetToRejected(reader,reason){assert(void 0===reader._closedPromise_resolve),assert(void 0===reader._closedPromise_reject),reader._closedPromise=Promise.reject(reason)}function defaultReaderClosedPromiseResolve(reader){assert(void 0!==reader._closedPromise_resolve),assert(void 0!==reader._closedPromise_reject),reader._closedPromise_resolve(void 0),reader._closedPromise_resolve=void 0,reader._closedPromise_reject=void 0}function byobReaderBrandCheckException(name){return new TypeError("ReadableStreamBYOBReader.prototype."+name+" can only be used on a ReadableStreamBYOBReader")}function defaultControllerBrandCheckException(name){return new TypeError("ReadableStreamDefaultController.prototype."+name+" can only be used on a ReadableStreamDefaultController")}function byobRequestBrandCheckException(name){return new TypeError("ReadableStreamBYOBRequest.prototype."+name+" can only be used on a ReadableStreamBYOBRequest")}function byteStreamControllerBrandCheckException(name){return new TypeError("ReadableByteStreamController.prototype."+name+" can only be used on a ReadableByteStreamController")}var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function defineProperties(target,props){for(var i=0;i0?(Promise.all(promises).then(function(){finishWithRejection(reason)}),void(_state="waitingForLastReadAndOrLastWrite")):void finishWithRejection(reason)}function handleWriteRejection(reason){"piping"===_state&&abortWriterCancelReader(reason,preventAbort,preventCancel)}function handleReadValue(value){_lastWrite=_writer.write(value),_lastWrite["catch"](handleWriteRejection),_allWrites=Promise.all([_allWrites,_lastWrite]),doPipe()}function handleReadDone(){return releaseReader(),preventClose===!1?(_writer.close().then(function(){return _allWrites},function(reason){releaseWriter(),finishWithRejection(reason)}).then(function(){releaseWriter(),finishWithFulfillment()}),void(_state="closingDest")):void 0===_lastWrite?(releaseWriter(),void finishWithFulfillment()):(_lastWrite.then(function(){releaseWriter(),finishWithFulfillment()},function(reason){releaseWriter(),finishWithRejection(reason)}),void(_state="waitingLastWriteOnReadableClosed"))}function doPipe(){_lastRead=_reader.read(),Promise.all([_lastRead,_writer.ready]).then(function(_ref5){var _ref6=_slicedToArray(_ref5,1),_ref6$=_ref6[0],value=_ref6$.value,done=_ref6$.done;"piping"===_state&&(Boolean(done)===!1?handleReadValue(value):handleReadDone())},function(){})["catch"](rethrowAssertionErrorRejection)}function handleReaderClosedRejection(reason){"piping"===_state&&(_lastRead=void 0,abortWriterCancelReader(reason,preventAbort,!0))}function handleUnexpectedWriterCloseAndError(reason){"piping"===_state&&(_lastWrite=void 0,abortWriterCancelReader(reason,!0,preventCancel))}function handleWriterClosedFulfillment(){handleUnexpectedWriterCloseAndError(new TypeError("dest closed unexpectedly"))}function handleWriterClosedRejection(reason){handleUnexpectedWriterCloseAndError(reason)}var _ref4=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],preventClose=_ref4.preventClose,preventAbort=_ref4.preventAbort,preventCancel=_ref4.preventCancel;preventClose=Boolean(preventClose),preventAbort=Boolean(preventAbort),preventCancel=Boolean(preventCancel);var source=this,_resolvePipeToPromise=void 0,_rejectPipeToPromise=void 0,_reader=void 0,_writer=void 0,_state="piping",_lastRead=void 0,_lastWrite=void 0,_allWrites=void 0;return new Promise(function(resolve,reject){_resolvePipeToPromise=resolve,_rejectPipeToPromise=reject,_reader=source.getReader(),_writer=dest.getWriter(),_reader.closed["catch"](handleReaderClosedRejection),_writer.closed.then(handleWriterClosedFulfillment,handleWriterClosedRejection),doPipe()})}},{key:"tee",value:function(){if(IsReadableStream(this)===!1)throw streamBrandCheckException("tee");var branches=ReadableStreamTee(this,!1);return createArrayFromList(branches)}},{key:"locked",get:function(){if(IsReadableStream(this)===!1)throw streamBrandCheckException("locked");return IsReadableStreamLocked(this)}}]),ReadableStream}();exports.ReadableStream=ReadableStream,exports.IsReadableStreamDisturbed=IsReadableStreamDisturbed;var ReadableStreamDefaultReader=function(){function ReadableStreamDefaultReader(stream){if(_classCallCheck(this,ReadableStreamDefaultReader),IsReadableStream(stream)===!1)throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(IsReadableStreamLocked(stream)===!0)throw new TypeError("This stream has already been locked for exclusive reading by another reader");ReadableStreamReaderGenericInitialize(this,stream),this._readRequests=[]}return _createClass(ReadableStreamDefaultReader,[{key:"cancel",value:function(reason){return IsReadableStreamDefaultReader(this)===!1?Promise.reject(defaultReaderBrandCheckException("cancel")):void 0===this._ownerReadableStream?Promise.reject(readerLockException("cancel")):ReadableStreamReaderGenericCancel(this,reason)}},{key:"read",value:function(){return IsReadableStreamDefaultReader(this)===!1?Promise.reject(defaultReaderBrandCheckException("read")):void 0===this._ownerReadableStream?Promise.reject(readerLockException("read from")):ReadableStreamDefaultReaderRead(this)}},{key:"releaseLock",value:function(){if(IsReadableStreamDefaultReader(this)===!1)throw defaultReaderBrandCheckException("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");ReadableStreamReaderGenericRelease(this)}}},{key:"closed",get:function(){return IsReadableStreamDefaultReader(this)===!1?Promise.reject(defaultReaderBrandCheckException("closed")):this._closedPromise}}]),ReadableStreamDefaultReader}(),ReadableStreamBYOBReader=function(){function ReadableStreamBYOBReader(stream){if(_classCallCheck(this,ReadableStreamBYOBReader),!IsReadableStream(stream))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(IsReadableStreamLocked(stream))throw new TypeError("This stream has already been locked for exclusive reading by another reader");ReadableStreamReaderGenericInitialize(this,stream),this._readIntoRequests=[]}return _createClass(ReadableStreamBYOBReader,[{key:"cancel",value:function(reason){return IsReadableStreamBYOBReader(this)?void 0===this._ownerReadableStream?Promise.reject(readerLockException("cancel")):ReadableStreamReaderGenericCancel(this,reason):Promise.reject(byobReaderBrandCheckException("cancel"))}},{key:"read",value:function(view){return IsReadableStreamBYOBReader(this)?void 0===this._ownerReadableStream?Promise.reject(readerLockException("read from")):ArrayBuffer.isView(view)?0===view.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):ReadableStreamBYOBReaderRead(this,view):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(byobReaderBrandCheckException("read"))}},{key:"releaseLock",value:function(){if(!IsReadableStreamBYOBReader(this))throw byobReaderBrandCheckException("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");ReadableStreamReaderGenericRelease(this)}}},{key:"closed",get:function(){return IsReadableStreamBYOBReader(this)?this._closedPromise:Promise.reject(byobReaderBrandCheckException("closed"))}}]),ReadableStreamBYOBReader}(),ReadableStreamDefaultController=function(){function ReadableStreamDefaultController(stream,underlyingSource,size,highWaterMark){if(_classCallCheck(this,ReadableStreamDefaultController),IsReadableStream(stream)===!1)throw new TypeError("ReadableStreamDefaultController can only be constructed with a ReadableStream instance");if(void 0!==stream._readableStreamController)throw new TypeError("ReadableStreamDefaultController instances can only be created by the ReadableStream constructor");this._controlledReadableStream=stream,this._underlyingSource=underlyingSource,this._queue=[],this._started=!1,this._closeRequested=!1,this._pullAgain=!1,this._pulling=!1;var normalizedStrategy=ValidateAndNormalizeQueuingStrategy(size,highWaterMark);this._strategySize=normalizedStrategy.size,this._strategyHWM=normalizedStrategy.highWaterMark;var controller=this,startResult=InvokeOrNoop(underlyingSource,"start",[this]);Promise.resolve(startResult).then(function(){controller._started=!0, +ReadableStreamDefaultControllerCallPullIfNeeded(controller)},function(r){ReadableStreamDefaultControllerErrorIfNeeded(controller,r)})["catch"](rethrowAssertionErrorRejection)}return _createClass(ReadableStreamDefaultController,[{key:"close",value:function(){if(IsReadableStreamDefaultController(this)===!1)throw defaultControllerBrandCheckException("close");if(this._closeRequested===!0)throw new TypeError("The stream has already been closed; do not close it again!");var state=this._controlledReadableStream._state;if("readable"!==state)throw new TypeError("The stream (in "+state+" state) is not in the readable state and cannot be closed");ReadableStreamDefaultControllerClose(this)}},{key:"enqueue",value:function(chunk){if(IsReadableStreamDefaultController(this)===!1)throw defaultControllerBrandCheckException("enqueue");if(this._closeRequested===!0)throw new TypeError("stream is closed or draining");var state=this._controlledReadableStream._state;if("readable"!==state)throw new TypeError("The stream (in "+state+" state) is not in the readable state and cannot be enqueued to");return ReadableStreamDefaultControllerEnqueue(this,chunk)}},{key:"error",value:function(e){if(IsReadableStreamDefaultController(this)===!1)throw defaultControllerBrandCheckException("error");var stream=this._controlledReadableStream;if("readable"!==stream._state)throw new TypeError("The stream is "+stream._state+" and so cannot be errored");ReadableStreamDefaultControllerError(this,e)}},{key:InternalCancel,value:function(reason){return this._queue=[],PromiseInvokeOrNoop(this._underlyingSource,"cancel",[reason])}},{key:InternalPull,value:function(){var stream=this._controlledReadableStream;if(this._queue.length>0){var chunk=DequeueValue(this._queue);return this._closeRequested===!0&&0===this._queue.length?ReadableStreamClose(stream):ReadableStreamDefaultControllerCallPullIfNeeded(this),Promise.resolve(CreateIterResultObject(chunk,!1))}var pendingPromise=ReadableStreamAddReadRequest(stream);return ReadableStreamDefaultControllerCallPullIfNeeded(this),pendingPromise}},{key:"desiredSize",get:function(){if(IsReadableStreamDefaultController(this)===!1)throw defaultControllerBrandCheckException("desiredSize");return ReadableStreamDefaultControllerGetDesiredSize(this)}}]),ReadableStreamDefaultController}(),ReadableStreamBYOBRequest=function(){function ReadableStreamBYOBRequest(controller,view){_classCallCheck(this,ReadableStreamBYOBRequest),this._associatedReadableByteStreamController=controller,this._view=view}return _createClass(ReadableStreamBYOBRequest,[{key:"respond",value:function(bytesWritten){if(IsReadableStreamBYOBRequest(this)===!1)throw byobRequestBrandCheckException("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController,bytesWritten)}},{key:"respondWithNewView",value:function(view){if(IsReadableStreamBYOBRequest(this)===!1)throw byobRequestBrandCheckException("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(view))throw new TypeError("You can only respond with array buffer views");ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController,view)}},{key:"view",get:function(){return this._view}}]),ReadableStreamBYOBRequest}(),ReadableByteStreamController=function(){function ReadableByteStreamController(stream,underlyingByteSource,highWaterMark){if(_classCallCheck(this,ReadableByteStreamController),IsReadableStream(stream)===!1)throw new TypeError("ReadableByteStreamController can only be constructed with a ReadableStream instance given a byte source");if(void 0!==stream._readableStreamController)throw new TypeError("ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte source");this._controlledReadableStream=stream,this._underlyingByteSource=underlyingByteSource,this._pullAgain=!1,this._pulling=!1,ReadableByteStreamControllerClearPendingPullIntos(this),this._queue=[],this._totalQueuedBytes=0,this._closeRequested=!1,this._started=!1,this._strategyHWM=ValidateAndNormalizeHighWaterMark(highWaterMark);var autoAllocateChunkSize=underlyingByteSource.autoAllocateChunkSize;if(void 0!==autoAllocateChunkSize&&(Number.isInteger(autoAllocateChunkSize)===!1||0>autoAllocateChunkSize))throw new RangeError("autoAllocateChunkSize must be a non negative integer");this._autoAllocateChunkSize=autoAllocateChunkSize,this._pendingPullIntos=[];var controller=this,startResult=InvokeOrNoop(underlyingByteSource,"start",[this]);Promise.resolve(startResult).then(function(){controller._started=!0,assert(controller._pulling===!1),assert(controller._pullAgain===!1),ReadableByteStreamControllerCallPullIfNeeded(controller)},function(r){"readable"===stream._state&&ReadableByteStreamControllerError(controller,r)})["catch"](rethrowAssertionErrorRejection)}return _createClass(ReadableByteStreamController,[{key:"close",value:function(){if(IsReadableByteStreamController(this)===!1)throw byteStreamControllerBrandCheckException("close");if(this._closeRequested===!0)throw new TypeError("The stream has already been closed; do not close it again!");var state=this._controlledReadableStream._state;if("readable"!==state)throw new TypeError("The stream (in "+state+" state) is not in the readable state and cannot be closed");ReadableByteStreamControllerClose(this)}},{key:"enqueue",value:function(chunk){if(IsReadableByteStreamController(this)===!1)throw byteStreamControllerBrandCheckException("enqueue");if(this._closeRequested===!0)throw new TypeError("stream is closed or draining");var state=this._controlledReadableStream._state;if("readable"!==state)throw new TypeError("The stream (in "+state+" state) is not in the readable state and cannot be enqueued to");if(!ArrayBuffer.isView(chunk))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");ReadableByteStreamControllerEnqueue(this,chunk)}},{key:"error",value:function(e){if(IsReadableByteStreamController(this)===!1)throw byteStreamControllerBrandCheckException("error");var stream=this._controlledReadableStream;if("readable"!==stream._state)throw new TypeError("The stream is "+stream._state+" and so cannot be errored");ReadableByteStreamControllerError(this,e)}},{key:InternalCancel,value:function(reason){if(this._pendingPullIntos.length>0){var firstDescriptor=this._pendingPullIntos[0];firstDescriptor.bytesFilled=0}return this._queue=[],this._totalQueuedBytes=0,PromiseInvokeOrNoop(this._underlyingByteSource,"cancel",[reason])}},{key:InternalPull,value:function(){var stream=this._controlledReadableStream;if(0===ReadableStreamGetNumReadRequests(stream)){if(this._totalQueuedBytes>0){var entry=this._queue.shift();this._totalQueuedBytes-=entry.byteLength,ReadableByteStreamControllerHandleQueueDrain(this);var view=void 0;try{view=new Uint8Array(entry.buffer,entry.byteOffset,entry.byteLength)}catch(viewE){return Promise.reject(viewE)}return Promise.resolve(CreateIterResultObject(view,!1))}var autoAllocateChunkSize=this._autoAllocateChunkSize;if(void 0!==autoAllocateChunkSize){var buffer=void 0;try{buffer=new ArrayBuffer(autoAllocateChunkSize)}catch(bufferE){return Promise.reject(bufferE)}var pullIntoDescriptor={buffer:buffer,byteOffset:0,byteLength:autoAllocateChunkSize,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(pullIntoDescriptor)}}else assert(void 0===this._autoAllocateChunkSize);var promise=ReadableStreamAddReadRequest(stream);return ReadableByteStreamControllerCallPullIfNeeded(this),promise}},{key:"byobRequest",get:function(){if(IsReadableByteStreamController(this)===!1)throw byteStreamControllerBrandCheckException("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){var firstDescriptor=this._pendingPullIntos[0],view=new Uint8Array(firstDescriptor.buffer,firstDescriptor.byteOffset+firstDescriptor.bytesFilled,firstDescriptor.byteLength-firstDescriptor.bytesFilled);this._byobRequest=new ReadableStreamBYOBRequest(this,view)}return this._byobRequest}},{key:"desiredSize",get:function(){if(IsReadableByteStreamController(this)===!1)throw byteStreamControllerBrandCheckException("desiredSize");return ReadableByteStreamControllerGetDesiredSize(this)}}]),ReadableByteStreamController}()},{"./helpers.js":9,"./queue-with-sizes.js":10,"./utils.js":13,assert:2}],12:[function(require,module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function TransformStreamCloseReadable(transformStream){if(transformStream._errored===!0)throw new TypeError("TransformStream is already errored");if(transformStream._readableClosed===!0)throw new TypeError("Readable side is already closed");try{transformStream._readableController.close()}catch(e){assert(!1)}transformStream._readableClosed=!0}function TransformStreamEnqueueToReadable(transformStream,chunk){if(transformStream._errroed===!0)throw new TypeError("TransformStream is already errored");if(transformStream._readableClosed===!0)throw new TypeError("Readable side is already closed");var controller=transformStream._readableController;transformStream._readableBackpressure=!0;try{controller.enqueue(chunk)}catch(e){if(transformStream._error===!1){var reason=new TypeError("Failed to enqueue to readable side");TransformStreamErrorInternal(transformStream,reason)}throw transformStream._error}var backpressure=void 0;try{backpressure=controller.desiredSize<=0}catch(e){if(transformStream._error===!1){var reason=new TypeError("Failed to calculate backpressure of readable side");TransformStreamError(transformStream,reason)}throw transformStream._error}backpressure&&(transformStream._readableBackpressure=!1)}function TransformStreamError(transformStream,e){if(transformStream._errored===!0)throw new TypeError("TransformStream is already errored");TransformStreamErrorInternal(transformStream,e)}function TransformStreamChunkDone(transformStream){if(transformStream._errroed===!0)throw new TypeError("TransformStream is already errored");if(transformStream._transforming===!1)throw new TypeError("No active transform is running");assert(void 0!==transformStream._resolveWrite),transformStream._transforming=!1,transformStream._resolveWrite(void 0),transformStream._resolveWrite=void 0,TransformStreamTransformIfNeeded(transformStream)}function TransformStreamErrorInternal(transformStream,e){transformStream._errored=!0,transformStream._writableDone===!1&&transformStream._writableController.error(e),transformStream._readableClosed===!1&&transformStream._readableController.error(e),transformStream._chunk=void 0,void 0!==transformStream._resolveWriter&&transformStream._resolveWriter(void 0)}function TransformStreamTransformIfNeeded(transformStream){if(transformStream._chunkPending!==!1&&(assert(void 0!==transformStream._resolveWrite),transformStream._transforming!==!0&&transformStream._readableBackpressure!==!0)){transformStream._transforming=!0;var chunk=transformStream._chunk;transformStream._chunkPending=!1,transformStream._chunk=void 0;try{void 0!==transformStream._transformer.transform&&transformStream._transformer.transform(chunk,TransformStreamChunkDone.bind(void 0,transformStream),transformStream._enqueueFunction,transformStream._closeFunction,transformStream._errorFunction)}catch(e){transformStream._errored===!1&&TransformStreamErrorInternal(transformStream,e)}}}function TransformStreamStart(transformStream){void 0!==transformStream._transformer.start&&transformStream._transformer.start(transformStream._enqueueFunction,transformStream._closeFunction,transformStream._errorFunction)}var _createClass=function(){function defineProperties(target,props){for(var i=0;i0);var writeRequest=stream._writeRequests.shift();writeRequest._resolve(void 0)}function WritableStreamUpdateBackpressure(stream,backpressure){assert("writable"===stream._state);var writer=stream._writer;void 0!==writer&&(backpressure===!0?defaultWriterReadyPromiseReset(writer):(assert(backpressure===!1),defaultWriterReadyPromiseResolve(writer)))}function IsWritableStreamDefaultWriter(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_ownerWritableStream"):!1}function WritableStreamDefaultWriterAbort(writer,reason){var stream=writer._ownerWritableStream;return assert(void 0!==stream),WritableStreamAbort(stream,reason)}function WritableStreamDefaultWriterClose(writer){var stream=writer._ownerWritableStream;assert(void 0!==stream);var state=stream._state;if("closed"===state||"errored"===state)return Promise.reject(new TypeError("The stream (in "+state+" state) is not in the writable state and cannot be closed"));assert("writable"===state);var promise=WritableStreamAddWriteRequest(stream);return WritableStreamDefaultControllerGetBackpressure(stream._writableStreamController)===!0&&defaultWriterReadyPromiseResolve(writer),stream._state="closing",WritableStreamDefaultControllerClose(stream._writableStreamController),promise}function WritableStreamDefaultWriterGetDesiredSize(writer){var stream=writer._ownerWritableStream,state=stream._state;return"errored"===state?null:"closed"===state?0:WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController)}function WritableStreamDefaultWriterWrite(writer,chunk){var stream=writer._ownerWritableStream;assert(void 0!==stream);var state=stream._state;if("closed"===state||"errored"===state)return Promise.reject(new TypeError("The stream (in "+state+" state) is not in the writable state and cannot be written to"));assert("writable"===state);var promise=WritableStreamAddWriteRequest(stream);return WritableStreamDefaultControllerWrite(stream._writableStreamController,chunk),promise}function WritableStreamDefaultControllerAbort(controller,reason){controller._queue=[];var sinkAbortPromise=PromiseInvokeOrFallbackOrNoop(controller._underlyingSink,"abort",[reason],"close",[]);return sinkAbortPromise.then(function(){})}function WritableStreamDefaultControllerClose(controller){EnqueueValueWithSize(controller._queue,"close",0),WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller)}function WritableStreamDefaultControllerGetDesiredSize(controller){var queueSize=GetTotalQueueSize(controller._queue);return controller._strategyHWM-queueSize}function WritableStreamDefaultControllerWrite(controller,chunk){var stream=controller._controlledWritableStream;assert("writable"===stream._state);var chunkSize=1;if(void 0!==controller._strategySize)try{chunkSize=controller._strategySize(chunk)}catch(chunkSizeE){return WritableStreamDefaultControllerErrorIfNeeded(controller,chunkSizeE),Promise.reject(chunkSizeE)}var writeRecord={chunk:chunk},lastBackpressure=WritableStreamDefaultControllerGetBackpressure(controller);try{EnqueueValueWithSize(controller._queue,writeRecord,chunkSize)}catch(enqueueE){return WritableStreamDefaultControllerErrorIfNeeded(controller,enqueueE),Promise.reject(enqueueE)}if("writable"===stream._state){var backpressure=WritableStreamDefaultControllerGetBackpressure(controller);lastBackpressure!==backpressure&&WritableStreamUpdateBackpressure(stream,backpressure)}WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller)}function IsWritableStreamDefaultController(x){return typeIsObject(x)?!!Object.prototype.hasOwnProperty.call(x,"_underlyingSink"):!1}function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller){if("closed"!==controller._controlledWritableStream._state&&"errored"!==controller._controlledWritableStream._state&&controller._started!==!1&&controller._writing!==!0&&0!==controller._queue.length){var writeRecord=PeekQueueValue(controller._queue);"close"===writeRecord?WritableStreamDefaultControllerProcessClose(controller):WritableStreamDefaultControllerProcessWrite(controller,writeRecord.chunk)}}function WritableStreamDefaultControllerErrorIfNeeded(controller,e){"writable"!==controller._controlledWritableStream._state&&"closing"!==controller._controlledWritableStream._state||WritableStreamDefaultControllerError(controller,e)}function WritableStreamDefaultControllerProcessClose(controller){var stream=controller._controlledWritableStream;assert("closing"===stream._state,"can't process final write record unless already closed"),DequeueValue(controller._queue),assert(0===controller._queue.length,"queue must be empty once the final write record is dequeued");var sinkClosePromise=PromiseInvokeOrNoop(controller._underlyingSink,"close");sinkClosePromise.then(function(){"closing"===stream._state&&(WritableStreamFulfillWriteRequest(stream),WritableStreamFinishClose(stream))},function(r){WritableStreamDefaultControllerErrorIfNeeded(controller,r)})["catch"](rethrowAssertionErrorRejection)}function WritableStreamDefaultControllerProcessWrite(controller,chunk){controller._writing=!0;var sinkWritePromise=PromiseInvokeOrNoop(controller._underlyingSink,"write",[chunk]);sinkWritePromise.then(function(){var stream=controller._controlledWritableStream,state=stream._state;if("errored"!==state&&"closed"!==state){controller._writing=!1,WritableStreamFulfillWriteRequest(stream);var lastBackpressure=WritableStreamDefaultControllerGetBackpressure(controller);if(DequeueValue(controller._queue),"closing"!==state){var backpressure=WritableStreamDefaultControllerGetBackpressure(controller);lastBackpressure!==backpressure&&WritableStreamUpdateBackpressure(controller._controlledWritableStream,backpressure)}WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller)}},function(r){WritableStreamDefaultControllerErrorIfNeeded(controller,r)})["catch"](rethrowAssertionErrorRejection)}function WritableStreamDefaultControllerGetBackpressure(controller){var desiredSize=WritableStreamDefaultControllerGetDesiredSize(controller);return 0>=desiredSize}function WritableStreamDefaultControllerError(controller,e){var stream=controller._controlledWritableStream;assert("writable"===stream._state||"closing"===stream._state),WritableStreamError(stream,e),controller._queue=[]}function streamBrandCheckException(name){return new TypeError("WritableStream.prototype."+name+" can only be used on a WritableStream")}function defaultWriterBrandCheckException(name){return new TypeError("WritableStreamDefaultWriter.prototype."+name+" can only be used on a WritableStreamDefaultWriter")}function defaultWriterLockException(name){return new TypeError("Cannot "+name+" a stream using a released writer")}function defaultWriterClosedPromiseInitialize(writer){writer._closedPromise=new Promise(function(resolve,reject){writer._closedPromise_resolve=resolve,writer._closedPromise_reject=reject})}function defaultWriterClosedPromiseInitializeAsRejected(writer,reason){writer._closedPromise=Promise.reject(reason),writer._closedPromise_resolve=void 0,writer._closedPromise_reject=void 0}function defaultWriterClosedPromiseInitializeAsResolved(writer){writer._closedPromise=Promise.resolve(void 0),writer._closedPromise_resolve=void 0,writer._closedPromise_reject=void 0}function defaultWriterClosedPromiseReject(writer,reason){assert(void 0!==writer._closedPromise_resolve),assert(void 0!==writer._closedPromise_reject),writer._closedPromise_reject(reason),writer._closedPromise_resolve=void 0,writer._closedPromise_reject=void 0}function defaultWriterClosedPromiseResetToRejected(writer,reason){assert(void 0===writer._closedPromise_resolve),assert(void 0===writer._closedPromise_reject),writer._closedPromise=Promise.reject(reason)}function defaultWriterClosedPromiseResolve(writer){assert(void 0!==writer._closedPromise_resolve),assert(void 0!==writer._closedPromise_reject),writer._closedPromise_resolve(void 0),writer._closedPromise_resolve=void 0,writer._closedPromise_reject=void 0}function defaultWriterReadyPromiseInitialize(writer){writer._readyPromise=new Promise(function(resolve,reject){writer._readyPromise_resolve=resolve,writer._readyPromise_reject=reject})}function defaultWriterReadyPromiseInitializeAsResolved(writer){writer._readyPromise=Promise.resolve(void 0),writer._readyPromise_resolve=void 0,writer._readyPromise_reject=void 0}function defaultWriterReadyPromiseReject(writer,reason){assert(void 0!==writer._readyPromise_resolve),assert(void 0!==writer._readyPromise_reject),writer._readyPromise_reject(reason),writer._readyPromise_resolve=void 0,writer._readyPromise_reject=void 0}function defaultWriterReadyPromiseReset(writer){assert(void 0===writer._readyPromise_resolve),assert(void 0===writer._readyPromise_reject),writer._readyPromise=new Promise(function(resolve,reject){writer._readyPromise_resolve=resolve,writer._readyPromise_reject=reject})}function defaultWriterReadyPromiseResetToRejected(writer,reason){assert(void 0===writer._readyPromise_resolve),assert(void 0===writer._readyPromise_reject),writer._readyPromise=Promise.reject(reason)}function defaultWriterReadyPromiseResolve(writer){assert(void 0!==writer._readyPromise_resolve),assert(void 0!==writer._readyPromise_reject),writer._readyPromise_resolve(void 0),writer._readyPromise_resolve=void 0,writer._readyPromise_reject=void 0}var _createClass=function(){function defineProperties(target,props){for(var i=0;i= blob.size) + controller.close() + }) + } + }) + }: + + // basic stream support + basicStreamSupport ? function stream(blob){ + var position = 0 + var blob = this + + return new ReadableStream({ + pull: function (controller) { + var chunk = blob.slice(position, position + 524288) + + return chunk.arrayBuffer().then(function (buffer) { + position += buffer.byteLength + let uint8array = new Uint8Array(buffer) + controller.enqueue(uint8array) + + if(position == blob.size) + controller.close() + }) + } + }) + }: + + // fetchTransform + fetchTransform ? function stream() { + return (new Response(this)).body + }: + + function stream() { + throw new Error('Include https://github.com/creatorrr/web-streams-polyfill') + } + } + +}()); -- cgit v1.2.3 From a83361982f3fa6117716efa3e7823c30b70c49f5 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Wed, 30 Nov 2016 15:41:13 -0500 Subject: minifaction of most external resources where possible --- www/external/GCMIntentService.java | 543 ---- www/external/angular-carousel.js | 2288 ------------- www/external/angular-carousel.min.js | 124 + www/external/angular-circular-navigation.js | 70 - www/external/angular-circular-navigation.min.js | 5 + www/external/canvas-toBlob.js | 124 - www/external/canvas-toBlob.min.js | 17 + www/external/draggabilly.pkgd.js | 1530 --------- www/external/draggabilly.pkgd.min.js | 96 + www/external/gifshot.min.js | 8 - www/external/imagesloaded.pkgd.js | 487 --- www/external/imagesloaded.pkgd.min.js | 42 + www/external/ion-pullup.js | 261 -- www/external/ion-pullup.min.js | 10 + www/external/ionRadio.js | 55 - www/external/ionRadio.min.js | 12 + www/external/ionic.content.banner.js | 190 -- www/external/ionic.content.banner.min.js | 12 + www/external/ionic.scroll.sista.js | 321 -- www/external/ionic.scroll.sista.min.js | 28 + www/external/ng-websocket.js | 381 --- www/external/ng-websocket.min.js | 31 + www/external/origjs/NeuQuant.js | 389 +++ www/external/origjs/README.TXT | 3 + www/external/origjs/angular-carousel.js | 2286 +++++++++++++ www/external/origjs/angular-circular-navigation.js | 70 + .../origjs/angular-ios9-uiwebview.patch.js | 73 + www/external/origjs/canvas-toBlob.js | 124 + www/external/origjs/draggabilly.pkgd.js | 1530 +++++++++ www/external/origjs/gifwriter.js | 406 +++ www/external/origjs/imagesloaded.pkgd.js | 487 +++ www/external/origjs/ion-pullup.js | 261 ++ www/external/origjs/ionRadio.js | 55 + www/external/origjs/ionic.content.banner.js | 190 ++ www/external/origjs/ionic.scroll.sista.js | 321 ++ www/external/origjs/ng-websocket.js | 381 +++ www/external/origjs/packery.pkgd.js | 3413 ++++++++++++++++++++ www/external/packery.pkgd.js | 3413 -------------------- www/external/packery.pkgd.min.js | 270 ++ 39 files changed, 10636 insertions(+), 9671 deletions(-) delete mode 100644 www/external/GCMIntentService.java delete mode 100644 www/external/angular-carousel.js create mode 100644 www/external/angular-carousel.min.js delete mode 100644 www/external/angular-circular-navigation.js create mode 100644 www/external/angular-circular-navigation.min.js delete mode 100644 www/external/canvas-toBlob.js create mode 100644 www/external/canvas-toBlob.min.js delete mode 100644 www/external/draggabilly.pkgd.js create mode 100644 www/external/draggabilly.pkgd.min.js delete mode 100644 www/external/gifshot.min.js delete mode 100644 www/external/imagesloaded.pkgd.js create mode 100644 www/external/imagesloaded.pkgd.min.js delete mode 100755 www/external/ion-pullup.js create mode 100644 www/external/ion-pullup.min.js delete mode 100644 www/external/ionRadio.js create mode 100644 www/external/ionRadio.min.js delete mode 100644 www/external/ionic.content.banner.js create mode 100644 www/external/ionic.content.banner.min.js delete mode 100644 www/external/ionic.scroll.sista.js create mode 100644 www/external/ionic.scroll.sista.min.js delete mode 100644 www/external/ng-websocket.js create mode 100644 www/external/ng-websocket.min.js create mode 100644 www/external/origjs/NeuQuant.js create mode 100644 www/external/origjs/README.TXT create mode 100644 www/external/origjs/angular-carousel.js create mode 100644 www/external/origjs/angular-circular-navigation.js create mode 100644 www/external/origjs/angular-ios9-uiwebview.patch.js create mode 100644 www/external/origjs/canvas-toBlob.js create mode 100644 www/external/origjs/draggabilly.pkgd.js create mode 100644 www/external/origjs/gifwriter.js create mode 100644 www/external/origjs/imagesloaded.pkgd.js create mode 100755 www/external/origjs/ion-pullup.js create mode 100644 www/external/origjs/ionRadio.js create mode 100644 www/external/origjs/ionic.content.banner.js create mode 100644 www/external/origjs/ionic.scroll.sista.js create mode 100644 www/external/origjs/ng-websocket.js create mode 100644 www/external/origjs/packery.pkgd.js delete mode 100644 www/external/packery.pkgd.js create mode 100644 www/external/packery.pkgd.min.js (limited to 'www/external') diff --git a/www/external/GCMIntentService.java b/www/external/GCMIntentService.java deleted file mode 100644 index 9ffe5836..00000000 --- a/www/external/GCMIntentService.java +++ /dev/null @@ -1,543 +0,0 @@ -package com.adobe.phonegap.push; - -import android.annotation.SuppressLint; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.res.AssetManager; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Color; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.NotificationCompat; -import android.text.Html; -import android.util.Log; - -import com.google.android.gcm.GCMBaseIntentService; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -@SuppressLint("NewApi") -public class GCMIntentService extends GCMBaseIntentService implements PushConstants { - - private static final String LOG_TAG = "PushPlugin_GCMIntentService"; - private static HashMap> messageMap = new HashMap>(); - - public void setNotification(int notId, String message){ - ArrayList messageList = messageMap.get(notId); - if(messageList == null) { - messageList = new ArrayList(); - messageMap.put(notId, messageList); - } - - if(message.isEmpty()){ - messageList.clear(); - }else{ - messageList.add(message); - } - } - - public GCMIntentService() { - super("GCMIntentService"); - } - - @Override - public void onRegistered(Context context, String regId) { - - Log.v(LOG_TAG, "onRegistered: " + regId); - - try { - JSONObject json = new JSONObject().put(REGISTRATION_ID, regId); - - Log.v(LOG_TAG, "onRegistered: " + json.toString()); - - PushPlugin.sendEvent( json ); - } - catch(JSONException e) { - // No message to the user is sent, JSON failed - Log.e(LOG_TAG, "onRegistered: JSON exception"); - } - } - - @Override - public void onUnregistered(Context context, String regId) { - Log.d(LOG_TAG, "onUnregistered - regId: " + regId); - } - - @Override - protected void onMessage(Context context, Intent intent) { - Log.d(LOG_TAG, "onMessage - context: " + context); - - // Extract the payload from the message - Bundle extras = intent.getExtras(); - if (extras != null) { - // if we are in the foreground, just surface the payload, else post it to the statusbar - if (PushPlugin.isInForeground()) { - extras.putBoolean(FOREGROUND, true); - PushPlugin.sendExtras(extras); - } - else { - extras.putBoolean(FOREGROUND, false); - - // Send a notification if there is a message - String message = this.getMessageText(extras); - String title = getString(extras, TITLE, ""); - if ((message != null && message.length() != 0) || - (title != null && title.length() != 0)) { - createNotification(context, extras); - } - } - } - } - - public void createNotification(Context context, Bundle extras) { - NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - String appName = getAppName(this); - String packageName = context.getPackageName(); - Resources resources = context.getResources(); - - int notId = parseInt(NOT_ID, extras); - Intent notificationIntent = new Intent(this, PushHandlerActivity.class); - notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); - notificationIntent.putExtra(PUSH_BUNDLE, extras); - notificationIntent.putExtra(NOT_ID, notId); - - int requestCode = new Random().nextInt(); - PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); - - NotificationCompat.Builder mBuilder = - new NotificationCompat.Builder(context) - .setWhen(System.currentTimeMillis()) - .setContentTitle(getString(extras, TITLE)) - .setTicker(getString(extras, TITLE)) - .setContentIntent(contentIntent) - .setAutoCancel(true); - - SharedPreferences prefs = context.getSharedPreferences(PushPlugin.COM_ADOBE_PHONEGAP_PUSH, Context.MODE_PRIVATE); - String localIcon = prefs.getString(ICON, null); - String localIconColor = prefs.getString(ICON_COLOR, null); - boolean soundOption = prefs.getBoolean(SOUND, true); - //PP - make vibrate false - //boolean vibrateOption = prefs.getBoolean(VIBRATE, true); - boolean vibrateOption = false; - Log.d(LOG_TAG, "stored icon=" + localIcon); - Log.d(LOG_TAG, "stored iconColor=" + localIconColor); - Log.d(LOG_TAG, "stored sound=" + soundOption); - Log.d(LOG_TAG, "stored vibrate=" + vibrateOption); - - /* - * Notification Vibration - */ - - setNotificationVibration(extras, vibrateOption, mBuilder); - - /* - * Notification Icon Color - * - * Sets the small-icon background color of the notification. - * To use, add the `iconColor` key to plugin android options - * - */ - setNotificationIconColor(getString(extras,"color"), mBuilder, localIconColor); - - /* - * Notification Icon - * - * Sets the small-icon of the notification. - * - * - checks the plugin options for `icon` key - * - if none, uses the application icon - * - * The icon value must be a string that maps to a drawable resource. - * If no resource is found, falls - * - */ - setNotificationSmallIcon(context, extras, packageName, resources, mBuilder, localIcon); - - /* - * Notification Large-Icon - * - * Sets the large-icon of the notification - * - * - checks the gcm data for the `image` key - * - checks to see if remote image, loads it. - * - checks to see if assets image, Loads It. - * - checks to see if resource image, LOADS IT! - * - if none, we don't set the large icon - * - */ - setNotificationLargeIcon(extras, packageName, resources, mBuilder); - - /* - * Notification Sound - */ - if (soundOption) { - /* PP Enable Sound option */ - setNotificationSound(context, extras, mBuilder); - } - - /* - * LED Notification - */ - setNotificationLedColor(extras, mBuilder); - - /* - * Priority Notification - */ - setNotificationPriority(extras, mBuilder); - - /* - * Notification message - */ - setNotificationMessage(notId, extras, mBuilder); - - /* - * Notification count - */ - setNotificationCount(extras, mBuilder); - - /* - * Notication add actions - */ - createActions(extras, mBuilder, resources, packageName); - - // PP add lights - mBuilder.setLights(0xFFFF0000, 500, 500); - - //PP - http://stackoverflow.com/questions/29343974/custom-sound-in-android-push-notifications-gcm - // mNotificationManager.notify(appName, notId, mBuilder.build()); - Notification notification = mBuilder.build(); - //notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "/"+ R.raw.blop); - //PP http://stackoverflow.com/questions/15449945/notification-sound-from-uri-parse-does-not-work - //notification.sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/blop"); - //notification.defaults |= Notification.DEFAULT_VIBRATE; - mNotificationManager.notify((String) appName, notId, notification); - } - - private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, Resources resources, String packageName) { - Log.d(LOG_TAG, "create actions"); - String actions = getString(extras, ACTIONS); - if (actions != null) { - try { - JSONArray actionsArray = new JSONArray(actions); - for (int i=0; i < actionsArray.length(); i++) { - Log.d(LOG_TAG, "adding action"); - JSONObject action = actionsArray.getJSONObject(i); - Log.d(LOG_TAG, "adding callback = " + action.getString(CALLBACK)); - Intent intent = new Intent(this, PushHandlerActivity.class); - intent.putExtra(CALLBACK, action.getString(CALLBACK)); - intent.putExtra(PUSH_BUNDLE, extras); - PendingIntent pIntent = PendingIntent.getActivity(this, i, intent, PendingIntent.FLAG_UPDATE_CURRENT); - - mBuilder.addAction(resources.getIdentifier(action.getString(ICON), DRAWABLE, packageName), - action.getString(TITLE), pIntent); - } - } catch(JSONException e) { - // nope - } - } - } - - private void setNotificationCount(Bundle extras, NotificationCompat.Builder mBuilder) { - String msgcnt = getString(extras, MSGCNT); - if (msgcnt == null) { - msgcnt = getString(extras, BADGE); - } - if (msgcnt != null) { - mBuilder.setNumber(Integer.parseInt(msgcnt)); - } - } - - private void setNotificationVibration(Bundle extras, Boolean vibrateOption, NotificationCompat.Builder mBuilder) { - String vibrationPattern = getString(extras, VIBRATION_PATTERN); - if (vibrationPattern != null) { - String[] items = vibrationPattern.replaceAll("\\[", "").replaceAll("\\]", "").split(","); - long[] results = new long[items.length]; - for (int i = 0; i < items.length; i++) { - try { - results[i] = Long.parseLong(items[i]); - } catch (NumberFormatException nfe) {} - } - mBuilder.setVibrate(results); - } else { - if (vibrateOption) { - mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); - } - } - } - - private void setNotificationMessage(int notId, Bundle extras, NotificationCompat.Builder mBuilder) { - String message = getMessageText(extras); - - String style = getString(extras, STYLE, STYLE_TEXT); - if(STYLE_INBOX.equals(style)) { - setNotification(notId, message); - - mBuilder.setContentText(message); - - ArrayList messageList = messageMap.get(notId); - Integer sizeList = messageList.size(); - if (sizeList > 1) { - String sizeListMessage = sizeList.toString(); - String stacking = sizeList + " more"; - if (getString(extras, SUMMARY_TEXT) != null) { - stacking = getString(extras, SUMMARY_TEXT); - stacking = stacking.replace("%n%", sizeListMessage); - } - NotificationCompat.InboxStyle notificationInbox = new NotificationCompat.InboxStyle() - .setBigContentTitle(getString(extras, TITLE)) - .setSummaryText(stacking); - - for (int i = messageList.size() - 1; i >= 0; i--) { - notificationInbox.addLine(Html.fromHtml(messageList.get(i))); - } - - mBuilder.setStyle(notificationInbox); - } else { - NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); - if (message != null) { - bigText.bigText(message); - bigText.setBigContentTitle(getString(extras, TITLE)); - mBuilder.setStyle(bigText); - } - } - } else if (STYLE_PICTURE.equals(style)) { - setNotification(notId, ""); - - NotificationCompat.BigPictureStyle bigPicture = new NotificationCompat.BigPictureStyle(); - bigPicture.bigPicture(getBitmapFromURL(getString(extras, PICTURE))); - bigPicture.setBigContentTitle(getString(extras, TITLE)); - bigPicture.setSummaryText(getString(extras, SUMMARY_TEXT)); - - mBuilder.setContentTitle(getString(extras, TITLE)); - mBuilder.setContentText(message); - - mBuilder.setStyle(bigPicture); - } else { - setNotification(notId, ""); - - NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); - - if (message != null) { - mBuilder.setContentText(Html.fromHtml(message)); - - bigText.bigText(message); - bigText.setBigContentTitle(getString(extras, TITLE)); - - String summaryText = getString(extras, SUMMARY_TEXT); - if (summaryText != null) { - bigText.setSummaryText(summaryText); - } - - mBuilder.setStyle(bigText); - } - /* - else { - mBuilder.setContentText(""); - } - */ - } - } - - private String getString(Bundle extras,String key) { - String message = extras.getString(key); - if (message == null) { - message = extras.getString(GCM_NOTIFICATION+"."+key); - } - return message; - } - - private String getString(Bundle extras,String key, String defaultString) { - String message = extras.getString(key); - if (message == null) { - message = extras.getString(GCM_NOTIFICATION+"."+key, defaultString); - } - return message; - } - - private String getMessageText(Bundle extras) { - String message = getString(extras, MESSAGE); - if (message == null) { - message = getString(extras, BODY); - } - return message; - } - - private void setNotificationSound(Context context, Bundle extras, NotificationCompat.Builder mBuilder) { - String soundname = getString(extras, SOUNDNAME); - if (soundname == null) { - soundname = getString(extras, SOUND); - } - if (soundname != null) { - Uri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE - + "://" + context.getPackageName() + "/raw/" + soundname); - Log.d(LOG_TAG, sound.toString()); - mBuilder.setSound(sound); - } else { - mBuilder.setSound(android.provider.Settings.System.DEFAULT_NOTIFICATION_URI); - } - } - - private void setNotificationLedColor(Bundle extras, NotificationCompat.Builder mBuilder) { - String ledColor = getString(extras, LED_COLOR); - if (ledColor != null) { - // Converts parse Int Array from ledColor - String[] items = ledColor.replaceAll("\\[", "").replaceAll("\\]", "").split(","); - int[] results = new int[items.length]; - for (int i = 0; i < items.length; i++) { - try { - results[i] = Integer.parseInt(items[i]); - } catch (NumberFormatException nfe) {} - } - if (results.length == 4) { - mBuilder.setLights(Color.argb(results[0], results[1], results[2], results[3]), 500, 500); - } else { - Log.e(LOG_TAG, "ledColor parameter must be an array of length == 4 (ARGB)"); - } - } - } - - private void setNotificationPriority(Bundle extras, NotificationCompat.Builder mBuilder) { - String priorityStr = getString(extras, PRIORITY); - if (priorityStr != null) { - try { - Integer priority = Integer.parseInt(priorityStr); - if (priority >= NotificationCompat.PRIORITY_MIN && priority <= NotificationCompat.PRIORITY_MAX) { - mBuilder.setPriority(priority); - } else { - Log.e(LOG_TAG, "Priority parameter must be between -2 and 2"); - } - } catch (NumberFormatException e) { - e.printStackTrace(); - } - } - } - - private void setNotificationLargeIcon(Bundle extras, String packageName, Resources resources, NotificationCompat.Builder mBuilder) { - String gcmLargeIcon = getString(extras, IMAGE); // from gcm - if (gcmLargeIcon != null) { - if (gcmLargeIcon.startsWith("http://") || gcmLargeIcon.startsWith("https://")) { - mBuilder.setLargeIcon(getBitmapFromURL(gcmLargeIcon)); - Log.d(LOG_TAG, "using remote large-icon from gcm"); - } else { - AssetManager assetManager = getAssets(); - InputStream istr; - try { - istr = assetManager.open(gcmLargeIcon); - Bitmap bitmap = BitmapFactory.decodeStream(istr); - mBuilder.setLargeIcon(bitmap); - Log.d(LOG_TAG, "using assets large-icon from gcm"); - } catch (IOException e) { - int largeIconId = 0; - largeIconId = resources.getIdentifier(gcmLargeIcon, DRAWABLE, packageName); - if (largeIconId != 0) { - Bitmap largeIconBitmap = BitmapFactory.decodeResource(resources, largeIconId); - mBuilder.setLargeIcon(largeIconBitmap); - Log.d(LOG_TAG, "using resources large-icon from gcm"); - } else { - Log.d(LOG_TAG, "Not setting large icon"); - } - } - } - } - } - - private void setNotificationSmallIcon(Context context, Bundle extras, String packageName, Resources resources, NotificationCompat.Builder mBuilder, String localIcon) { - int iconId = 0; - String icon = getString(extras, ICON); - if (icon != null) { - iconId = resources.getIdentifier(icon, DRAWABLE, packageName); - Log.d(LOG_TAG, "using icon from plugin options"); - } - else if (localIcon != null) { - iconId = resources.getIdentifier(localIcon, DRAWABLE, packageName); - Log.d(LOG_TAG, "using icon from plugin options"); - } - if (iconId == 0) { - Log.d(LOG_TAG, "no icon resource found - using application icon"); - iconId = context.getApplicationInfo().icon; - } - mBuilder.setSmallIcon(iconId); - } - - private void setNotificationIconColor(String color, NotificationCompat.Builder mBuilder, String localIconColor) { - int iconColor = 0; - if (color != null) { - try { - iconColor = Color.parseColor(color); - } catch (IllegalArgumentException e) { - Log.e(LOG_TAG, "couldn't parse color from android options"); - } - } - else if (localIconColor != null) { - try { - iconColor = Color.parseColor(localIconColor); - } catch (IllegalArgumentException e) { - Log.e(LOG_TAG, "couldn't parse color from android options"); - } - } - if (iconColor != 0) { - mBuilder.setColor(iconColor); - } - } - - public Bitmap getBitmapFromURL(String strURL) { - try { - URL url = new URL(strURL); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - connection.connect(); - InputStream input = connection.getInputStream(); - return BitmapFactory.decodeStream(input); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - private static String getAppName(Context context) { - CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); - return (String)appName; - } - - @Override - public void onError(Context context, String errorId) { - Log.e(LOG_TAG, "onError - errorId: " + errorId); - // if we are in the foreground, just send the error - if (PushPlugin.isInForeground()) { - PushPlugin.sendError(errorId); - } - } - - private int parseInt(String value, Bundle extras) { - int retval = 0; - - try { - retval = Integer.parseInt(getString(extras, value)); - } - catch(NumberFormatException e) { - Log.e(LOG_TAG, "Number format exception - Error parsing " + value + ": " + e.getMessage()); - } - catch(Exception e) { - Log.e(LOG_TAG, "Number format exception - Error parsing " + value + ": " + e.getMessage()); - } - - return retval; - } -} diff --git a/www/external/angular-carousel.js b/www/external/angular-carousel.js deleted file mode 100644 index 21cc6729..00000000 --- a/www/external/angular-carousel.js +++ /dev/null @@ -1,2288 +0,0 @@ -/* jshint ignore:start */ -/** - - * Angular Carousel - Mobile friendly touch carousel for AngularJS - * @version v0.3.12 - 2015-06-11 - * @link http://revolunet.github.com/angular-carousel - * @author Julien Bouquillon - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -/*global angular */ - -/* -Angular touch carousel with CSS GPU accel and slide buffering -http://github.com/revolunet/angular-carousel - -*/ - -// Modified by PP for mobile friendly touch, start without auto slide but enabled it if tapped -// and logic to wait for an image to load before it slides to the next one - -angular.module('angular-carousel', [ - 'ngTouch', - 'angular-carousel.shifty' -]); - -angular.module('angular-carousel') - -// PP modified carousel to work in conjunction with lazy loading -// so slide does not progress if image is not loaded or gets an error -// imageLoadingDataShare is the factory that has a value -// of 0 if no image is being loaded, -1 if there was an error and 1 if an image is currently being loaded -.directive('rnCarouselAutoSlide', ['$interval','$timeout', 'imageLoadingDataShare', 'carouselUtils', function($interval,$timeout, imageLoadingDataShare, carouselUtils ) { - return { - restrict: 'A', - link: function (scope, element, attrs) { - - - var stopAutoPlay = function() { - if (scope.autoSlider) { - //console.log ("Cancelling timer"); - //$interval.cancel(scope.autoSlider); - scope.autoSlider = null; - } - }; - var restartTimer = function() { - //console.log ("restart timer"); - if (carouselUtils.isStopped() == false) - { - //console.log ("Timer restart rnForceStop "+ carouselUtils.get()); - //console.log ("Calling autoslide because isStopped is false"); - scope.autoSlide(); - } - else { - //console.log ("Not sliding as stop=true"); - } - }; - //PP - don't auto play if user taps - var toggleAutoPlay = function() { - //scope.rnForceStop = !scope.rnForceStop; - carouselUtils.setStop(!carouselUtils.getStop()); - if (carouselUtils.isStopped()) - carouselUtils.setIndex (scope.carouselIndex); - //console.log ("Autoplay is " + carouselUtils.get()); - if (scope.autoSlider ) - { - // PP - If autoslide was on and we tapped, stop auto slide - //scope.rnForceStop = true; //PP - carouselUtils.setStop (true); - carouselUtils.setIndex (scope.carouselIndex); - //console.log ("***RN: Stopping Play rnForceStop is "+carouselUtils.getStop()); - stopAutoPlay(); - } - else - { - //scope.rnForceStop = false; //PP - carouselUtils.setStop (false); - //console.log ("***RN: Starting Play rnForceStop is "+carouselUtils.getStop()); - //scope.carouselIndex = carouselUtils.getIndex(); - restartTimer(); - } - }; - -// start with autoplay and require tap to stop - //console.log ("*** Setting rnForceStop to false and watching"); - //scope.rnForceStop = false; // PP - carouselUtils.setStop (false); - scope.$watch('carouselIndex', restartTimer); - - if (attrs.hasOwnProperty('rnCarouselPauseOnHover') && attrs.rnCarouselPauseOnHover !== 'false'){ - // PP - added touchend to make it react to touch devices - if (attrs.hasOwnProperty('rnPlatform') && attrs.rnPlatform == 'desktop') - { - //console.log ("ranPlatform is " + attrs.rnPlatform); - //console.log ("Desktop, de-registering any old click"); - element.off('click', toggleAutoPlay); // PP - remove mouse click for desktop - element.on('click', toggleAutoPlay); // PP for desktop - //console.log ("Desktop, registering click"); - } - else - { - //console.log ("ranPlatform is " + attrs.rnPlatform); - //console.log ("Device, de-registering any old touch"); - element.off('touchend', toggleAutoPlay); // PP - remove touchend too - element.on('touchend', toggleAutoPlay); - //console.log ("Device, registering touch"); - } - //element.on('mouseenter', stopAutoPlay); - //element.on('mouseleave', restartTimer); - } - - scope.$on('$destroy', function(){ - stopAutoPlay(); - //element.off('mouseenter', stopAutoPlay); - //element.off('mouseleave', restartTimer); - element.off('touchend', toggleAutoPlay); // PP - remove touchend too - element.off('click', toggleAutoPlay); // PP - remove mouse click for desktop - }); - } - }; -}]); - -angular.module('angular-carousel') - -.directive('rnCarouselIndicators', ['$parse', function($parse) { - return { - restrict: 'A', - scope: { - slides: '=', - index: '=rnCarouselIndex' - }, - templateUrl: 'carousel-indicators.html', - link: function(scope, iElement, iAttributes) { - var indexModel = $parse(iAttributes.rnCarouselIndex); - scope.goToSlide = function(index) { - indexModel.assign(scope.$parent.$parent, index); - }; - } - }; -}]); - -angular.module('angular-carousel').run(['$templateCache', function($templateCache) { - $templateCache.put('carousel-indicators.html', - '' - ); -}]); - -(function() { - "use strict"; - - angular.module('angular-carousel') - - .service('DeviceCapabilities', function() { - - // TODO: merge in a single function - - // detect supported CSS property - function detectTransformProperty() { - var transformProperty = 'transform', - safariPropertyHack = 'webkitTransform'; - if (typeof document.body.style[transformProperty] !== 'undefined') { - - ['webkit', 'moz', 'o', 'ms'].every(function (prefix) { - var e = '-' + prefix + '-transform'; - if (typeof document.body.style[e] !== 'undefined') { - transformProperty = e; - return false; - } - return true; - }); - } else if (typeof document.body.style[safariPropertyHack] !== 'undefined') { - transformProperty = '-webkit-transform'; - } else { - transformProperty = undefined; - } - return transformProperty; - } - - //Detect support of translate3d - function detect3dSupport() { - var el = document.createElement('p'), - has3d, - transforms = { - 'webkitTransform': '-webkit-transform', - 'msTransform': '-ms-transform', - 'transform': 'transform' - }; - // Add it to the body to get the computed style - document.body.insertBefore(el, null); - for (var t in transforms) { - if (el.style[t] !== undefined) { - el.style[t] = 'translate3d(1px,1px,1px)'; - has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); - } - } - document.body.removeChild(el); - return (has3d !== undefined && has3d.length > 0 && has3d !== "none"); - } - - return { - has3d: detect3dSupport(), - transformProperty: detectTransformProperty() - }; - - }) - - .service('computeCarouselSlideStyle', ["DeviceCapabilities", function(DeviceCapabilities) { - // compute transition transform properties for a given slide and global offset - return function(slideIndex, offset, transitionType) { - var style = { - display: 'inline-block' - }, - opacity, - absoluteLeft = (slideIndex * 100) + offset, - slideTransformValue = DeviceCapabilities.has3d ? 'translate3d(' + absoluteLeft + '%, 0, 0)' : 'translate3d(' + absoluteLeft + '%, 0)', - distance = ((100 - Math.abs(absoluteLeft)) / 100); - - if (!DeviceCapabilities.transformProperty) { - // fallback to default slide if transformProperty is not available - style['margin-left'] = absoluteLeft + '%'; - } else { - if (transitionType == 'fadeAndSlide') { - style[DeviceCapabilities.transformProperty] = slideTransformValue; - opacity = 0; - if (Math.abs(absoluteLeft) < 100) { - opacity = 0.3 + distance * 0.7; - } - style.opacity = opacity; - } else if (transitionType == 'hexagon') { - var transformFrom = 100, - degrees = 0, - maxDegrees = 60 * (distance - 1); - - transformFrom = offset < (slideIndex * -100) ? 100 : 0; - degrees = offset < (slideIndex * -100) ? maxDegrees : -maxDegrees; - style[DeviceCapabilities.transformProperty] = slideTransformValue + ' ' + 'rotateY(' + degrees + 'deg)'; - style[DeviceCapabilities.transformProperty + '-origin'] = transformFrom + '% 50%'; - } else if (transitionType == 'zoom') { - style[DeviceCapabilities.transformProperty] = slideTransformValue; - var scale = 1; - if (Math.abs(absoluteLeft) < 100) { - scale = 1 + ((1 - distance) * 2); - } - style[DeviceCapabilities.transformProperty] += ' scale(' + scale + ')'; - style[DeviceCapabilities.transformProperty + '-origin'] = '50% 50%'; - opacity = 0; - if (Math.abs(absoluteLeft) < 100) { - opacity = 0.3 + distance * 0.7; - } - style.opacity = opacity; - } else { - style[DeviceCapabilities.transformProperty] = slideTransformValue; - } - } - return style; - }; - }]) - - //PP - .factory ('carouselUtils', function() { - var isstopped = false; - var duration = 0; - var stoppedIndex = 0; - return { - - setDuration: function (val) - { - duration = val; - //console.log (">>>>>>>>>>>>>>>> DURATION SET TO (secs) " + duration); - }, - - getDuration: function () - { - return duration; - }, - - setStop: function(val) - { - isstopped = val; - if (isstopped) - { - console.log ("Paused at " + stoppedIndex); - } - }, - - setIndex: function(val) - { - stoppedIndex = val; - //console.log ("setting saved index to " + stoppedIndex); - }, - getIndex: function() - { - return stoppedIndex; - }, - getStop: function() - { - return isstopped; - }, - isStopped: function() - { - return isstopped; - }, - hello: function() - { - //console.log ("Hello from carouselUtils"); - } - - } - }) - - - .service('createStyleString', function() { - return function(object) { - var styles = []; - angular.forEach(object, function(value, key) { - styles.push(key + ':' + value); - }); - return styles.join(';'); - }; - }) - - .directive('rnCarousel', ['$swipe', '$window', '$document', '$parse', '$compile', '$timeout', '$interval', 'computeCarouselSlideStyle', 'createStyleString', 'Tweenable', 'imageLoadingDataShare', 'carouselUtils', - function($swipe, $window, $document, $parse, $compile, $timeout, $interval, computeCarouselSlideStyle, createStyleString, Tweenable, imageLoadingDataShare, carouselUtils) { - // internal ids to allow multiple instances - var carouselId = 0, - // in absolute pixels, at which distance the slide stick to the edge on release - rubberTreshold = 3; - - var requestAnimationFrame = $window.requestAnimationFrame || $window.webkitRequestAnimationFrame || $window.mozRequestAnimationFrame; - - function getItemIndex(collection, target, defaultIndex) { - var result = defaultIndex; - collection.every(function(item, index) { - if (angular.equals(item, target)) { - result = index; - return false; - } - return true; - }); - return result; - } - - return { - restrict: 'A', - scope: true, - - - compile: function(tElement, tAttributes) { - // use the compile phase to customize the DOM - var firstChild = tElement[0].querySelector('li'), - firstChildAttributes = (firstChild) ? firstChild.attributes : [], - isRepeatBased = false, - isBuffered = false, - repeatItem, - repeatCollection; - - // try to find an ngRepeat expression - // at this point, the attributes are not yet normalized so we need to try various syntax - ['ng-repeat', 'data-ng-repeat', 'ng:repeat', 'x-ng-repeat'].every(function(attr) { - var repeatAttribute = firstChildAttributes[attr]; - if (angular.isDefined(repeatAttribute)) { - // ngRepeat regexp extracted from angular 1.2.7 src - var exprMatch = repeatAttribute.value.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/), - trackProperty = exprMatch[3]; - - repeatItem = exprMatch[1]; - repeatCollection = exprMatch[2]; - - if (repeatItem) { - if (angular.isDefined(tAttributes['rnCarouselBuffered'])) { - // update the current ngRepeat expression and add a slice operator if buffered - isBuffered = true; - repeatAttribute.value = repeatItem + ' in ' + repeatCollection + '|carouselSlice:carouselBufferIndex:carouselBufferSize'; - if (trackProperty) { - repeatAttribute.value += ' track by ' + trackProperty; - } - } - isRepeatBased = true; - return false; - } - } - return true; - }); - - return function(scope, iElement, iAttributes, containerCtrl) { - - carouselId++; - - var defaultOptions = { - transitionType: iAttributes.rnCarouselTransition || 'slide', - transitionEasing: iAttributes.rnCarouselEasing || 'easeTo', - transitionDuration: parseFloat(iAttributes.rnCarouselDuration, 10) || 300, - isSequential: true, - autoSlideDuration: 3, - bufferSize: 9, - /* in container % how much we need to drag to trigger the slide change */ - moveTreshold: 0.1, - defaultIndex: 0 - }; - - // TODO - var options = angular.extend({}, defaultOptions); - - var pressed, - startX, - isIndexBound = false, - offset = 0, - destination, - swipeMoved = false, - //animOnIndexChange = true, - currentSlides = [], - elWidth = null, - elX = null, - animateTransitions = true, - intialState = true, - animating = false, - mouseUpBound = false, - locked = false; - - //rn-swipe-disabled =true will only disable swipe events - if(iAttributes.rnSwipeDisabled !== "true") { - $swipe.bind(iElement, { - start: swipeStart, - move: swipeMove, - end: swipeEnd, - cancel: function(event) { - swipeEnd({}, event); - } - }); - } - - function getSlidesDOM() { - return iElement[0].querySelectorAll('ul[rn-carousel] > li'); - } - - function documentMouseUpEvent(event) { - // in case we click outside the carousel, trigger a fake swipeEnd - swipeMoved = true; - swipeEnd({ - x: event.clientX, - y: event.clientY - }, event); - } - - function updateSlidesPosition(offset) { - // manually apply transformation to carousel childrens - // todo : optim : apply only to visible items - var x = scope.carouselBufferIndex * 100 + offset; - angular.forEach(getSlidesDOM(), function(child, index) { - child.style.cssText = createStyleString(computeCarouselSlideStyle(index, x, options.transitionType)); - }); - } - - scope.nextSlide = function(slideOptions) { - if (carouselUtils.isStopped()==true) - { - //console.log ("Just updated index, but we are stopped"); - return; - } - var index = scope.carouselIndex + 1; - if (index > currentSlides.length - 1) { -//PP - index--; - } - - //console.log ("inside next slide with index = " + index); - // PP - we keep moving the index but don't load so it looks nicer - // and we don't mess up the rate - if (imageLoadingDataShare.get() != 1) // PP- If the image is still being loaded, hold on, don't change - { - goToSlide(index, slideOptions); - // console.log ("loaded carousel is " + scope.carouselIndex); - - } - else - { - scope.autoSlide(); - // lets move the index along - PP - // so playback total time is not affected - - // scope.carouselIndex = index; - //console.log ("Image is still loading, not skipping slides, index at "+index); - // updateBufferIndex(); - //console.log ("NOT LOADED but advancing carousel to " + scope.carouselIndex); - -} - - }; - - scope.prevSlide = function(slideOptions) { - var index = scope.carouselIndex - 1; - if (index < 0) { - index = currentSlides.length - 1; - } - goToSlide(index, slideOptions); - }; - - function goToSlide(index, slideOptions) { - //console.log('goToSlide', arguments); - // move a to the given slide index - if (index === undefined) { - index = scope.carouselIndex; - } - - slideOptions = slideOptions || {}; - if (slideOptions.animate === false || options.transitionType === 'none') { - locked = false; - offset = index * -100; - scope.carouselIndex = index; - //console.log ("inside goToSlide: updating carousel index to " + scope.carouselIndex); - updateBufferIndex(); - return; - } - - locked = true; - var tweenable = new Tweenable(); - tweenable.tween({ - from: { - 'x': offset - }, - to: { - 'x': index * -100 - }, - duration: options.transitionDuration, - easing: options.transitionEasing, - step: function(state) { - updateSlidesPosition(state.x); - }, - finish: function() { - scope.$apply(function() { - scope.carouselIndex = index; - offset = index * -100; - updateBufferIndex(); - $timeout(function () { - locked = false; - }, 0, false); - }); - } - }); - } - - function getContainerWidth() { - var rect = iElement[0].getBoundingClientRect(); - return rect.width ? rect.width : rect.right - rect.left; - } - - function updateContainerWidth() { - elWidth = getContainerWidth(); - } - - function bindMouseUpEvent() { - if (!mouseUpBound) { - mouseUpBound = true; - $document.bind('mouseup', documentMouseUpEvent); - } - } - - function unbindMouseUpEvent() { - if (mouseUpBound) { - mouseUpBound = false; - $document.unbind('mouseup', documentMouseUpEvent); - } - } - - function swipeStart(coords, event) { - // console.log('swipeStart', coords, event); - if (locked || currentSlides.length <= 1) { - return; - } - updateContainerWidth(); - elX = iElement[0].querySelector('li').getBoundingClientRect().left; - pressed = true; - startX = coords.x; - return false; - } - - function swipeMove(coords, event) { - //console.log('swipeMove', coords, event); - var x, delta; - bindMouseUpEvent(); - if (pressed) { - x = coords.x; - delta = startX - x; - if (delta > 2 || delta < -2) { - swipeMoved = true; - var moveOffset = offset + (-delta * 100 / elWidth); - updateSlidesPosition(moveOffset); - } - } - return false; - } - - var init = true; - scope.carouselIndex = 0; - - if (!isRepeatBased) { - // fake array when no ng-repeat - currentSlides = []; - angular.forEach(getSlidesDOM(), function(node, index) { - currentSlides.push({id: index}); - }); - } - - if (iAttributes.rnCarouselControls!==undefined) { - // dont use a directive for this - var nextSlideIndexCompareValue = isRepeatBased ? repeatCollection.replace('::', '') + '.length - 1' : currentSlides.length - 1; - var tpl = ''; - iElement.parent().append($compile(angular.element(tpl))(scope)); - } - - if (iAttributes.rnCarouselAutoSlide!==undefined) { - // PP was parseInt, changed to parseFloat so I can specify fractions of seconds - var duration = parseFloat(iAttributes.rnCarouselAutoSlide, 10) || options.autoSlideDuration; - carouselUtils.setDuration(duration); - console.log ("Setting duration - should only happen once"); - scope.autoSlide = function() { - //console.log ("Inside autoslide"); - if (scope.autoSlider) { - //$interval.cancel(scope.autoSlider); - scope.autoSlider = null; - } - if (carouselUtils.isStopped() == false) //PP - don't move slide if this variable is set - { - var mydur = carouselUtils.getDuration(); - - // what happens if mydur needs to be less than a millisecond? - var mydurms = mydur * 1000.0; - - if (mydurms < 5) - { - console.log ("duration is too small at "+mydurms+" making it to 5"); - mydurms = 5; - - } - //console.log ("Setting next slide duration at " + mydur *1000); - scope.autoSlider = $timeout(function() { - //console.log ("setting time to " + mydurms); - //if (!locked && !pressed ) { - if (1 ) { - scope.nextSlide(); - } - }, mydurms); - } - else { console.log ("We are stopped, doing nothing"); } - }; - } - - if (iAttributes.rnCarouselDefaultIndex) { - var defaultIndexModel = $parse(iAttributes.rnCarouselDefaultIndex); - options.defaultIndex = defaultIndexModel(scope.$parent) || 0; - } - - - var shouldInitialySlideTo = null; - if (iAttributes.rnCarouselIndex) { - var updateParentIndex = function(value) { - if (value < 0) { - return; - } - //console.log ("Still indexing"); - indexModel.assign(scope.$parent, value); - }; - var indexModel = $parse(iAttributes.rnCarouselIndex); - if (angular.isFunction(indexModel.assign)) { - /* check if this property is assignable then watch it */ - scope.$watch('carouselIndex', function(newValue) { - //if (carouselUtils.isStopped() == false) - //console.log ("Carouselc chanhed 1"); - updateParentIndex(newValue); - }); - scope.$parent.$watch(function () { - return indexModel(scope.$parent); - }, function(newValue, oldValue) { - shouldInitialySlideTo = newValue; - - if (newValue !== undefined && newValue !== null) { - if (currentSlides && currentSlides.length > 0 && newValue >= currentSlides.length) { - newValue = currentSlides.length - 1; - updateParentIndex(newValue); - } else if (currentSlides && newValue < 0) { - newValue = 0; // PP - updateParentIndex(newValue); - } - if (!locked) { - goToSlide(newValue, { - animate: !init - }); - } - init = false; - } - }); - isIndexBound = true; - - if (options.defaultIndex) { - goToSlide(options.defaultIndex, { - animate: !init - }); - } - } else if (!isNaN(iAttributes.rnCarouselIndex)) { - /* if user just set an initial number, set it */ - goToSlide(parseInt(iAttributes.rnCarouselIndex, 10), { - animate: false - }); - } - } else { - goToSlide(options.defaultIndex, { - animate: !init - }); - init = false; - } - - if (iAttributes.rnCarouselLocked) { - scope.$watch(iAttributes.rnCarouselLocked, function(newValue, oldValue) { - // only bind swipe when it's not switched off - if(newValue === true) { - locked = true; - } else { - locked = false; - } - }); - } - - if (isRepeatBased) { - // use rn-carousel-deep-watch to fight the Angular $watchCollection weakness : https://github.com/angular/angular.js/issues/2621 - // optional because it have some performance impacts (deep watch) - var deepWatch = (iAttributes.rnCarouselDeepWatch!==undefined); - - scope[deepWatch?'$watch':'$watchCollection'](repeatCollection, function(newValue, oldValue) { - //console.log('repeatCollection', currentSlides); - currentSlides = newValue; -// This will force the required initial carouselIndex - // specified with `rn-carousel-index` on carousel initialization. - if (shouldInitialySlideTo) { - scope.carouselIndex = shouldInitialySlideTo; - shouldInitialySlideTo = null; - } - // if deepWatch ON ,manually compare objects to guess the new position - if (deepWatch && angular.isArray(newValue)) { - var activeElement = oldValue[scope.carouselIndex]; - var newIndex = getItemIndex(newValue, activeElement, scope.carouselIndex); - goToSlide(newIndex, {animate: false}); - } else { - goToSlide(scope.carouselIndex, {animate: false}); - } - }, true); - } - - function swipeEnd(coords, event, forceAnimation) { - // console.log('swipeEnd', 'scope.carouselIndex', scope.carouselIndex); - // Prevent clicks on buttons inside slider to trigger "swipeEnd" event on touchend/mouseup - // console.log(iAttributes.rnCarouselOnInfiniteScroll); - if (event && !swipeMoved) { - return; - } - unbindMouseUpEvent(); - pressed = false; - swipeMoved = false; - destination = startX - coords.x; - if (destination===0) { - return; - } - if (locked) { - return; - } - offset += (-destination * 100 / elWidth); - if (options.isSequential) { - var minMove = options.moveTreshold * elWidth, - absMove = -destination, - slidesMove = -Math[absMove >= 0 ? 'ceil' : 'floor'](absMove / elWidth), - shouldMove = Math.abs(absMove) > minMove; - - if (currentSlides && (slidesMove + scope.carouselIndex) >= currentSlides.length) { - slidesMove = currentSlides.length - 1 - scope.carouselIndex; - } - if ((slidesMove + scope.carouselIndex) < 0) { - slidesMove = -scope.carouselIndex; - } - var moveOffset = shouldMove ? slidesMove : 0; - - destination = (scope.carouselIndex + moveOffset); - - goToSlide(destination); - if(iAttributes.rnCarouselOnInfiniteScrollRight!==undefined && slidesMove === 0 && scope.carouselIndex !== 0) { - $parse(iAttributes.rnCarouselOnInfiniteScrollRight)(scope) - goToSlide(0); - } - if(iAttributes.rnCarouselOnInfiniteScrollLeft!==undefined && slidesMove === 0 && scope.carouselIndex === 0 && moveOffset === 0) { - $parse(iAttributes.rnCarouselOnInfiniteScrollLeft)(scope) - goToSlide(currentSlides.length); - } - - } else { - scope.$apply(function() { - scope.carouselIndex = parseInt(-offset / 100, 10); - updateBufferIndex(); - }); - - } - - } - - scope.$on('$destroy', function() { - unbindMouseUpEvent(); - }); - - scope.carouselBufferIndex = 0; - scope.carouselBufferSize = options.bufferSize; - - function updateBufferIndex() { - // update and cap te buffer index - var bufferIndex = 0; - var bufferEdgeSize = (scope.carouselBufferSize - 1) / 2; - if (isBuffered) { - if (scope.carouselIndex <= bufferEdgeSize) { - // first buffer part - bufferIndex = 0; - } else if (currentSlides && currentSlides.length < scope.carouselBufferSize) { - // smaller than buffer - bufferIndex = 0; - } else if (currentSlides && scope.carouselIndex > currentSlides.length - scope.carouselBufferSize) { - // last buffer part - bufferIndex = currentSlides.length - scope.carouselBufferSize; - } else { - // compute buffer start - bufferIndex = scope.carouselIndex - bufferEdgeSize; - } - - scope.carouselBufferIndex = bufferIndex; - $timeout(function() { - updateSlidesPosition(offset); - }, 0, false); - } else { - $timeout(function() { - updateSlidesPosition(offset); - }, 0, false); - } - } - - function onOrientationChange() { - updateContainerWidth(); - goToSlide(); - } - - // handle orientation change - var winEl = angular.element($window); - winEl.bind('orientationchange', onOrientationChange); - winEl.bind('resize', onOrientationChange); - - scope.$on('$destroy', function() { - unbindMouseUpEvent(); - winEl.unbind('orientationchange', onOrientationChange); - winEl.unbind('resize', onOrientationChange); - }); - }; - } - }; - } - ]); -})(); - - - -angular.module('angular-carousel.shifty', []) - -.factory('Tweenable', function() { - - /*! shifty - v1.3.4 - 2014-10-29 - http://jeremyckahn.github.io/shifty */ - ;(function (root) { - - /*! - * Shifty Core - * By Jeremy Kahn - jeremyckahn@gmail.com - */ - - var Tweenable = (function () { - - 'use strict'; - - // Aliases that get defined later in this function - var formula; - - // CONSTANTS - var DEFAULT_SCHEDULE_FUNCTION; - var DEFAULT_EASING = 'linear'; - var DEFAULT_DURATION = 500; - var UPDATE_TIME = 1000 / 60; - - var _now = Date.now - ? Date.now - : function () {return +new Date();}; - - var now = typeof SHIFTY_DEBUG_NOW !== 'undefined' ? SHIFTY_DEBUG_NOW : _now; - - if (typeof window !== 'undefined') { - // requestAnimationFrame() shim by Paul Irish (modified for Shifty) - // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - DEFAULT_SCHEDULE_FUNCTION = window.requestAnimationFrame - || window.webkitRequestAnimationFrame - || window.oRequestAnimationFrame - || window.msRequestAnimationFrame - || (window.mozCancelRequestAnimationFrame - && window.mozRequestAnimationFrame) - || setTimeout; - } else { - DEFAULT_SCHEDULE_FUNCTION = setTimeout; - } - - function noop () { - // NOOP! - } - - /*! - * Handy shortcut for doing a for-in loop. This is not a "normal" each - * function, it is optimized for Shifty. The iterator function only receives - * the property name, not the value. - * @param {Object} obj - * @param {Function(string)} fn - */ - function each (obj, fn) { - var key; - for (key in obj) { - if (Object.hasOwnProperty.call(obj, key)) { - fn(key); - } - } - } - - /*! - * Perform a shallow copy of Object properties. - * @param {Object} targetObject The object to copy into - * @param {Object} srcObject The object to copy from - * @return {Object} A reference to the augmented `targetObj` Object - */ - function shallowCopy (targetObj, srcObj) { - each(srcObj, function (prop) { - targetObj[prop] = srcObj[prop]; - }); - - return targetObj; - } - - /*! - * Copies each property from src onto target, but only if the property to - * copy to target is undefined. - * @param {Object} target Missing properties in this Object are filled in - * @param {Object} src - */ - function defaults (target, src) { - each(src, function (prop) { - if (typeof target[prop] === 'undefined') { - target[prop] = src[prop]; - } - }); - } - - /*! - * Calculates the interpolated tween values of an Object for a given - * timestamp. - * @param {Number} forPosition The position to compute the state for. - * @param {Object} currentState Current state properties. - * @param {Object} originalState: The original state properties the Object is - * tweening from. - * @param {Object} targetState: The destination state properties the Object - * is tweening to. - * @param {number} duration: The length of the tween in milliseconds. - * @param {number} timestamp: The UNIX epoch time at which the tween began. - * @param {Object} easing: This Object's keys must correspond to the keys in - * targetState. - */ - function tweenProps (forPosition, currentState, originalState, targetState, - duration, timestamp, easing) { - var normalizedPosition = (forPosition - timestamp) / duration; - - var prop; - for (prop in currentState) { - if (currentState.hasOwnProperty(prop)) { - currentState[prop] = tweenProp(originalState[prop], - targetState[prop], formula[easing[prop]], normalizedPosition); - } - } - - return currentState; - } - - /*! - * Tweens a single property. - * @param {number} start The value that the tween started from. - * @param {number} end The value that the tween should end at. - * @param {Function} easingFunc The easing curve to apply to the tween. - * @param {number} position The normalized position (between 0.0 and 1.0) to - * calculate the midpoint of 'start' and 'end' against. - * @return {number} The tweened value. - */ - function tweenProp (start, end, easingFunc, position) { - return start + (end - start) * easingFunc(position); - } - - /*! - * Applies a filter to Tweenable instance. - * @param {Tweenable} tweenable The `Tweenable` instance to call the filter - * upon. - * @param {String} filterName The name of the filter to apply. - */ - function applyFilter (tweenable, filterName) { - var filters = Tweenable.prototype.filter; - var args = tweenable._filterArgs; - - each(filters, function (name) { - if (typeof filters[name][filterName] !== 'undefined') { - filters[name][filterName].apply(tweenable, args); - } - }); - } - - var timeoutHandler_endTime; - var timeoutHandler_currentTime; - var timeoutHandler_isEnded; - var timeoutHandler_offset; - /*! - * Handles the update logic for one step of a tween. - * @param {Tweenable} tweenable - * @param {number} timestamp - * @param {number} duration - * @param {Object} currentState - * @param {Object} originalState - * @param {Object} targetState - * @param {Object} easing - * @param {Function(Object, *, number)} step - * @param {Function(Function,number)}} schedule - */ - function timeoutHandler (tweenable, timestamp, duration, currentState, - originalState, targetState, easing, step, schedule) { - timeoutHandler_endTime = timestamp + duration; - timeoutHandler_currentTime = Math.min(now(), timeoutHandler_endTime); - timeoutHandler_isEnded = - timeoutHandler_currentTime >= timeoutHandler_endTime; - - timeoutHandler_offset = duration - ( - timeoutHandler_endTime - timeoutHandler_currentTime); - - if (tweenable.isPlaying() && !timeoutHandler_isEnded) { - tweenable._scheduleId = schedule(tweenable._timeoutHandler, UPDATE_TIME); - - applyFilter(tweenable, 'beforeTween'); - tweenProps(timeoutHandler_currentTime, currentState, originalState, - targetState, duration, timestamp, easing); - applyFilter(tweenable, 'afterTween'); - - step(currentState, tweenable._attachment, timeoutHandler_offset); - } else if (timeoutHandler_isEnded) { - step(targetState, tweenable._attachment, timeoutHandler_offset); - tweenable.stop(true); - } - } - - - /*! - * Creates a usable easing Object from either a string or another easing - * Object. If `easing` is an Object, then this function clones it and fills - * in the missing properties with "linear". - * @param {Object} fromTweenParams - * @param {Object|string} easing - */ - function composeEasingObject (fromTweenParams, easing) { - var composedEasing = {}; - - if (typeof easing === 'string') { - each(fromTweenParams, function (prop) { - composedEasing[prop] = easing; - }); - } else { - each(fromTweenParams, function (prop) { - if (!composedEasing[prop]) { - composedEasing[prop] = easing[prop] || DEFAULT_EASING; - } - }); - } - - return composedEasing; - } - - /** - * Tweenable constructor. - * @param {Object=} opt_initialState The values that the initial tween should start at if a "from" object is not provided to Tweenable#tween. - * @param {Object=} opt_config See Tweenable.prototype.setConfig() - * @constructor - */ - function Tweenable (opt_initialState, opt_config) { - this._currentState = opt_initialState || {}; - this._configured = false; - this._scheduleFunction = DEFAULT_SCHEDULE_FUNCTION; - - // To prevent unnecessary calls to setConfig do not set default configuration here. - // Only set default configuration immediately before tweening if none has been set. - if (typeof opt_config !== 'undefined') { - this.setConfig(opt_config); - } - } - - /** - * Configure and start a tween. - * @param {Object=} opt_config See Tweenable.prototype.setConfig() - * @return {Tweenable} - */ - Tweenable.prototype.tween = function (opt_config) { - if (this._isTweening) { - return this; - } - - // Only set default config if no configuration has been set previously and none is provided now. - if (opt_config !== undefined || !this._configured) { - this.setConfig(opt_config); - } - - this._timestamp = now(); - this._start(this.get(), this._attachment); - return this.resume(); - }; - - /** - * Sets the tween configuration. `config` may have the following options: - * - * - __from__ (_Object=_): Starting position. If omitted, the current state is used. - * - __to__ (_Object=_): Ending position. - * - __duration__ (_number=_): How many milliseconds to animate for. - * - __start__ (_Function(Object)_): Function to execute when the tween begins. Receives the state of the tween as the first parameter. Attachment is the second parameter. - * - __step__ (_Function(Object, *, number)_): Function to execute on every tick. Receives the state of the tween as the first parameter. Attachment is the second parameter, and the time elapsed since the start of the tween is the third parameter. This function is not called on the final step of the animation, but `finish` is. - * - __finish__ (_Function(Object, *)_): Function to execute upon tween completion. Receives the state of the tween as the first parameter. Attachment is the second parameter. - * - __easing__ (_Object|string=_): Easing curve name(s) to use for the tween. - * - __attachment__ (_Object|string|any=_): Value that is attached to this instance and passed on to the step/start/finish methods. - * @param {Object} config - * @return {Tweenable} - */ - Tweenable.prototype.setConfig = function (config) { - config = config || {}; - this._configured = true; - - // Attach something to this Tweenable instance (e.g.: a DOM element, an object, a string, etc.); - this._attachment = config.attachment; - - // Init the internal state - this._pausedAtTime = null; - this._scheduleId = null; - this._start = config.start || noop; - this._step = config.step || noop; - this._finish = config.finish || noop; - this._duration = config.duration || DEFAULT_DURATION; - this._currentState = config.from || this.get(); - this._originalState = this.get(); - this._targetState = config.to || this.get(); - - // Aliases used below - var currentState = this._currentState; - var targetState = this._targetState; - - // Ensure that there is always something to tween to. - defaults(targetState, currentState); - - this._easing = composeEasingObject( - currentState, config.easing || DEFAULT_EASING); - - this._filterArgs = - [currentState, this._originalState, targetState, this._easing]; - - applyFilter(this, 'tweenCreated'); - return this; - }; - - /** - * Gets the current state. - * @return {Object} - */ - Tweenable.prototype.get = function () { - return shallowCopy({}, this._currentState); - }; - - /** - * Sets the current state. - * @param {Object} state - */ - Tweenable.prototype.set = function (state) { - this._currentState = state; - }; - - /** - * Pauses a tween. Paused tweens can be resumed from the point at which they were paused. This is different than [`stop()`](#stop), as that method causes a tween to start over when it is resumed. - * @return {Tweenable} - */ - Tweenable.prototype.pause = function () { - this._pausedAtTime = now(); - this._isPaused = true; - return this; - }; - - /** - * Resumes a paused tween. - * @return {Tweenable} - */ - Tweenable.prototype.resume = function () { - if (this._isPaused) { - this._timestamp += now() - this._pausedAtTime; - } - - this._isPaused = false; - this._isTweening = true; - - var self = this; - this._timeoutHandler = function () { - timeoutHandler(self, self._timestamp, self._duration, self._currentState, - self._originalState, self._targetState, self._easing, self._step, - self._scheduleFunction); - }; - - this._timeoutHandler(); - - return this; - }; - - /** - * Move the state of the animation to a specific point in the tween's timeline. - * If the animation is not running, this will cause the `step` handlers to be - * called. - * @param {millisecond} millisecond The millisecond of the animation to seek to. - * @return {Tweenable} - */ - Tweenable.prototype.seek = function (millisecond) { - this._timestamp = now() - millisecond; - - if (!this.isPlaying()) { - this._isTweening = true; - this._isPaused = false; - - // If the animation is not running, call timeoutHandler to make sure that - // any step handlers are run. - timeoutHandler(this, this._timestamp, this._duration, this._currentState, - this._originalState, this._targetState, this._easing, this._step, - this._scheduleFunction); - - this._timeoutHandler(); - this.pause(); - } - - return this; - }; - - /** - * Stops and cancels a tween. - * @param {boolean=} gotoEnd If false or omitted, the tween just stops at its current state, and the "finish" handler is not invoked. If true, the tweened object's values are instantly set to the target values, and "finish" is invoked. - * @return {Tweenable} - */ - Tweenable.prototype.stop = function (gotoEnd) { - this._isTweening = false; - this._isPaused = false; - this._timeoutHandler = noop; - - (root.cancelAnimationFrame || - root.webkitCancelAnimationFrame || - root.oCancelAnimationFrame || - root.msCancelAnimationFrame || - root.mozCancelRequestAnimationFrame || - root.clearTimeout)(this._scheduleId); - - if (gotoEnd) { - shallowCopy(this._currentState, this._targetState); - applyFilter(this, 'afterTweenEnd'); - this._finish.call(this, this._currentState, this._attachment); - } - - return this; - }; - - /** - * Returns whether or not a tween is running. - * @return {boolean} - */ - Tweenable.prototype.isPlaying = function () { - return this._isTweening && !this._isPaused; - }; - - /** - * Sets a custom schedule function. - * - * If a custom function is not set the default one is used [`requestAnimationFrame`](https://developer.mozilla.org/en-US/docs/Web/API/window.requestAnimationFrame) if available, otherwise [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/Window.setTimeout)). - * - * @param {Function(Function,number)} scheduleFunction The function to be called to schedule the next frame to be rendered - */ - Tweenable.prototype.setScheduleFunction = function (scheduleFunction) { - this._scheduleFunction = scheduleFunction; - }; - - /** - * `delete`s all "own" properties. Call this when the `Tweenable` instance is no longer needed to free memory. - */ - Tweenable.prototype.dispose = function () { - var prop; - for (prop in this) { - if (this.hasOwnProperty(prop)) { - delete this[prop]; - } - } - }; - - /*! - * Filters are used for transforming the properties of a tween at various - * points in a Tweenable's life cycle. See the README for more info on this. - */ - Tweenable.prototype.filter = {}; - - /*! - * This object contains all of the tweens available to Shifty. It is extendible - simply attach properties to the Tweenable.prototype.formula Object following the same format at linear. - * - * `pos` should be a normalized `number` (between 0 and 1). - */ - Tweenable.prototype.formula = { - linear: function (pos) { - return pos; - } - }; - - formula = Tweenable.prototype.formula; - - shallowCopy(Tweenable, { - 'now': now - ,'each': each - ,'tweenProps': tweenProps - ,'tweenProp': tweenProp - ,'applyFilter': applyFilter - ,'shallowCopy': shallowCopy - ,'defaults': defaults - ,'composeEasingObject': composeEasingObject - }); - - root.Tweenable = Tweenable; - return Tweenable; - - } ()); - - /*! - * All equations are adapted from Thomas Fuchs' [Scripty2](https://github.com/madrobby/scripty2/blob/master/src/effects/transitions/penner.js). - * - * Based on Easing Equations (c) 2003 [Robert Penner](http://www.robertpenner.com/), all rights reserved. This work is [subject to terms](http://www.robertpenner.com/easing_terms_of_use.html). - */ - - /*! - * TERMS OF USE - EASING EQUATIONS - * Open source under the BSD License. - * Easing Equations (c) 2003 Robert Penner, all rights reserved. - */ - - ;(function () { - - Tweenable.shallowCopy(Tweenable.prototype.formula, { - easeInQuad: function (pos) { - return Math.pow(pos, 2); - }, - - easeOutQuad: function (pos) { - return -(Math.pow((pos - 1), 2) - 1); - }, - - easeInOutQuad: function (pos) { - if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,2);} - return -0.5 * ((pos -= 2) * pos - 2); - }, - - easeInCubic: function (pos) { - return Math.pow(pos, 3); - }, - - easeOutCubic: function (pos) { - return (Math.pow((pos - 1), 3) + 1); - }, - - easeInOutCubic: function (pos) { - if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,3);} - return 0.5 * (Math.pow((pos - 2),3) + 2); - }, - - easeInQuart: function (pos) { - return Math.pow(pos, 4); - }, - - easeOutQuart: function (pos) { - return -(Math.pow((pos - 1), 4) - 1); - }, - - easeInOutQuart: function (pos) { - if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);} - return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2); - }, - - easeInQuint: function (pos) { - return Math.pow(pos, 5); - }, - - easeOutQuint: function (pos) { - return (Math.pow((pos - 1), 5) + 1); - }, - - easeInOutQuint: function (pos) { - if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,5);} - return 0.5 * (Math.pow((pos - 2),5) + 2); - }, - - easeInSine: function (pos) { - return -Math.cos(pos * (Math.PI / 2)) + 1; - }, - - easeOutSine: function (pos) { - return Math.sin(pos * (Math.PI / 2)); - }, - - easeInOutSine: function (pos) { - return (-0.5 * (Math.cos(Math.PI * pos) - 1)); - }, - - easeInExpo: function (pos) { - return (pos === 0) ? 0 : Math.pow(2, 10 * (pos - 1)); - }, - - easeOutExpo: function (pos) { - return (pos === 1) ? 1 : -Math.pow(2, -10 * pos) + 1; - }, - - easeInOutExpo: function (pos) { - if (pos === 0) {return 0;} - if (pos === 1) {return 1;} - if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(2,10 * (pos - 1));} - return 0.5 * (-Math.pow(2, -10 * --pos) + 2); - }, - - easeInCirc: function (pos) { - return -(Math.sqrt(1 - (pos * pos)) - 1); - }, - - easeOutCirc: function (pos) { - return Math.sqrt(1 - Math.pow((pos - 1), 2)); - }, - - easeInOutCirc: function (pos) { - if ((pos /= 0.5) < 1) {return -0.5 * (Math.sqrt(1 - pos * pos) - 1);} - return 0.5 * (Math.sqrt(1 - (pos -= 2) * pos) + 1); - }, - - easeOutBounce: function (pos) { - if ((pos) < (1 / 2.75)) { - return (7.5625 * pos * pos); - } else if (pos < (2 / 2.75)) { - return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75); - } else if (pos < (2.5 / 2.75)) { - return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375); - } else { - return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375); - } - }, - - easeInBack: function (pos) { - var s = 1.70158; - return (pos) * pos * ((s + 1) * pos - s); - }, - - easeOutBack: function (pos) { - var s = 1.70158; - return (pos = pos - 1) * pos * ((s + 1) * pos + s) + 1; - }, - - easeInOutBack: function (pos) { - var s = 1.70158; - if ((pos /= 0.5) < 1) {return 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s));} - return 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2); - }, - - elastic: function (pos) { - return -1 * Math.pow(4,-8 * pos) * Math.sin((pos * 6 - 1) * (2 * Math.PI) / 2) + 1; - }, - - swingFromTo: function (pos) { - var s = 1.70158; - return ((pos /= 0.5) < 1) ? 0.5 * (pos * pos * (((s *= (1.525)) + 1) * pos - s)) : - 0.5 * ((pos -= 2) * pos * (((s *= (1.525)) + 1) * pos + s) + 2); - }, - - swingFrom: function (pos) { - var s = 1.70158; - return pos * pos * ((s + 1) * pos - s); - }, - - swingTo: function (pos) { - var s = 1.70158; - return (pos -= 1) * pos * ((s + 1) * pos + s) + 1; - }, - - bounce: function (pos) { - if (pos < (1 / 2.75)) { - return (7.5625 * pos * pos); - } else if (pos < (2 / 2.75)) { - return (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75); - } else if (pos < (2.5 / 2.75)) { - return (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375); - } else { - return (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375); - } - }, - - bouncePast: function (pos) { - if (pos < (1 / 2.75)) { - return (7.5625 * pos * pos); - } else if (pos < (2 / 2.75)) { - return 2 - (7.5625 * (pos -= (1.5 / 2.75)) * pos + 0.75); - } else if (pos < (2.5 / 2.75)) { - return 2 - (7.5625 * (pos -= (2.25 / 2.75)) * pos + 0.9375); - } else { - return 2 - (7.5625 * (pos -= (2.625 / 2.75)) * pos + 0.984375); - } - }, - - easeFromTo: function (pos) { - if ((pos /= 0.5) < 1) {return 0.5 * Math.pow(pos,4);} - return -0.5 * ((pos -= 2) * Math.pow(pos,3) - 2); - }, - - easeFrom: function (pos) { - return Math.pow(pos,4); - }, - - easeTo: function (pos) { - return Math.pow(pos,0.25); - } - }); - - }()); - - /*! - * The Bezier magic in this file is adapted/copied almost wholesale from - * [Scripty2](https://github.com/madrobby/scripty2/blob/master/src/effects/transitions/cubic-bezier.js), - * which was adapted from Apple code (which probably came from - * [here](http://opensource.apple.com/source/WebCore/WebCore-955.66/platform/graphics/UnitBezier.h)). - * Special thanks to Apple and Thomas Fuchs for much of this code. - */ - - /*! - * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder(s) nor the names of any - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - ;(function () { - // port of webkit cubic bezier handling by http://www.netzgesta.de/dev/ - function cubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration) { - var ax = 0,bx = 0,cx = 0,ay = 0,by = 0,cy = 0; - function sampleCurveX(t) {return ((ax * t + bx) * t + cx) * t;} - function sampleCurveY(t) {return ((ay * t + by) * t + cy) * t;} - function sampleCurveDerivativeX(t) {return (3.0 * ax * t + 2.0 * bx) * t + cx;} - function solveEpsilon(duration) {return 1.0 / (200.0 * duration);} - function solve(x,epsilon) {return sampleCurveY(solveCurveX(x,epsilon));} - function fabs(n) {if (n >= 0) {return n;}else {return 0 - n;}} - function solveCurveX(x,epsilon) { - var t0,t1,t2,x2,d2,i; - for (t2 = x, i = 0; i < 8; i++) {x2 = sampleCurveX(t2) - x; if (fabs(x2) < epsilon) {return t2;} d2 = sampleCurveDerivativeX(t2); if (fabs(d2) < 1e-6) {break;} t2 = t2 - x2 / d2;} - t0 = 0.0; t1 = 1.0; t2 = x; if (t2 < t0) {return t0;} if (t2 > t1) {return t1;} - while (t0 < t1) {x2 = sampleCurveX(t2); if (fabs(x2 - x) < epsilon) {return t2;} if (x > x2) {t0 = t2;}else {t1 = t2;} t2 = (t1 - t0) * 0.5 + t0;} - return t2; // Failure. - } - cx = 3.0 * p1x; bx = 3.0 * (p2x - p1x) - cx; ax = 1.0 - cx - bx; cy = 3.0 * p1y; by = 3.0 * (p2y - p1y) - cy; ay = 1.0 - cy - by; - return solve(t, solveEpsilon(duration)); - } - /*! - * getCubicBezierTransition(x1, y1, x2, y2) -> Function - * - * Generates a transition easing function that is compatible - * with WebKit's CSS transitions `-webkit-transition-timing-function` - * CSS property. - * - * The W3C has more information about - * - * CSS3 transition timing functions. - * - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @return {function} - */ - function getCubicBezierTransition (x1, y1, x2, y2) { - return function (pos) { - return cubicBezierAtTime(pos,x1,y1,x2,y2,1); - }; - } - // End ported code - - /** - * Creates a Bezier easing function and attaches it to `Tweenable.prototype.formula`. This function gives you total control over the easing curve. Matthew Lein's [Ceaser](http://matthewlein.com/ceaser/) is a useful tool for visualizing the curves you can make with this function. - * - * @param {string} name The name of the easing curve. Overwrites the old easing function on Tweenable.prototype.formula if it exists. - * @param {number} x1 - * @param {number} y1 - * @param {number} x2 - * @param {number} y2 - * @return {function} The easing function that was attached to Tweenable.prototype.formula. - */ - Tweenable.setBezierFunction = function (name, x1, y1, x2, y2) { - var cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2); - cubicBezierTransition.x1 = x1; - cubicBezierTransition.y1 = y1; - cubicBezierTransition.x2 = x2; - cubicBezierTransition.y2 = y2; - - return Tweenable.prototype.formula[name] = cubicBezierTransition; - }; - - - /** - * `delete`s an easing function from `Tweenable.prototype.formula`. Be careful with this method, as it `delete`s whatever easing formula matches `name` (which means you can delete default Shifty easing functions). - * - * @param {string} name The name of the easing function to delete. - * @return {function} - */ - Tweenable.unsetBezierFunction = function (name) { - delete Tweenable.prototype.formula[name]; - }; - - })(); - - ;(function () { - - function getInterpolatedValues ( - from, current, targetState, position, easing) { - return Tweenable.tweenProps( - position, current, from, targetState, 1, 0, easing); - } - - // Fake a Tweenable and patch some internals. This approach allows us to - // skip uneccessary processing and object recreation, cutting down on garbage - // collection pauses. - var mockTweenable = new Tweenable(); - mockTweenable._filterArgs = []; - - /** - * Compute the midpoint of two Objects. This method effectively calculates a specific frame of animation that [Tweenable#tween](shifty.core.js.html#tween) does many times over the course of a tween. - * - * Example: - * - * var interpolatedValues = Tweenable.interpolate({ - * width: '100px', - * opacity: 0, - * color: '#fff' - * }, { - * width: '200px', - * opacity: 1, - * color: '#000' - * }, 0.5); - * - * console.log(interpolatedValues); - * // {opacity: 0.5, width: "150px", color: "rgb(127,127,127)"} - * - * @param {Object} from The starting values to tween from. - * @param {Object} targetState The ending values to tween to. - * @param {number} position The normalized position value (between 0.0 and 1.0) to interpolate the values between `from` and `to` for. `from` represents 0 and `to` represents `1`. - * @param {string|Object} easing The easing curve(s) to calculate the midpoint against. You can reference any easing function attached to `Tweenable.prototype.formula`. If omitted, this defaults to "linear". - * @return {Object} - */ - Tweenable.interpolate = function (from, targetState, position, easing) { - var current = Tweenable.shallowCopy({}, from); - var easingObject = Tweenable.composeEasingObject( - from, easing || 'linear'); - - mockTweenable.set({}); - - // Alias and reuse the _filterArgs array instead of recreating it. - var filterArgs = mockTweenable._filterArgs; - filterArgs.length = 0; - filterArgs[0] = current; - filterArgs[1] = from; - filterArgs[2] = targetState; - filterArgs[3] = easingObject; - - // Any defined value transformation must be applied - Tweenable.applyFilter(mockTweenable, 'tweenCreated'); - Tweenable.applyFilter(mockTweenable, 'beforeTween'); - - var interpolatedValues = getInterpolatedValues( - from, current, targetState, position, easingObject); - - // Transform values back into their original format - Tweenable.applyFilter(mockTweenable, 'afterTween'); - - return interpolatedValues; - }; - - }()); - - /** - * Adds string interpolation support to Shifty. - * - * The Token extension allows Shifty to tween numbers inside of strings. Among - * other things, this allows you to animate CSS properties. For example, you - * can do this: - * - * var tweenable = new Tweenable(); - * tweenable.tween({ - * from: { transform: 'translateX(45px)'}, - * to: { transform: 'translateX(90xp)'} - * }); - * - * ` ` - * `translateX(45)` will be tweened to `translateX(90)`. To demonstrate: - * - * var tweenable = new Tweenable(); - * tweenable.tween({ - * from: { transform: 'translateX(45px)'}, - * to: { transform: 'translateX(90px)'}, - * step: function (state) { - * console.log(state.transform); - * } - * }); - * - * ` ` - * The above snippet will log something like this in the console: - * - * translateX(60.3px) - * ... - * translateX(76.05px) - * ... - * translateX(90px) - * - * ` ` - * Another use for this is animating colors: - * - * var tweenable = new Tweenable(); - * tweenable.tween({ - * from: { color: 'rgb(0,255,0)'}, - * to: { color: 'rgb(255,0,255)'}, - * step: function (state) { - * console.log(state.color); - * } - * }); - * - * ` ` - * The above snippet will log something like this: - * - * rgb(84,170,84) - * ... - * rgb(170,84,170) - * ... - * rgb(255,0,255) - * - * ` ` - * This extension also supports hexadecimal colors, in both long (`#ff00ff`) - * and short (`#f0f`) forms. Be aware that hexadecimal input values will be - * converted into the equivalent RGB output values. This is done to optimize - * for performance. - * - * var tweenable = new Tweenable(); - * tweenable.tween({ - * from: { color: '#0f0'}, - * to: { color: '#f0f'}, - * step: function (state) { - * console.log(state.color); - * } - * }); - * - * ` ` - * This snippet will generate the same output as the one before it because - * equivalent values were supplied (just in hexadecimal form rather than RGB): - * - * rgb(84,170,84) - * ... - * rgb(170,84,170) - * ... - * rgb(255,0,255) - * - * ` ` - * ` ` - * ## Easing support - * - * Easing works somewhat differently in the Token extension. This is because - * some CSS properties have multiple values in them, and you might need to - * tween each value along its own easing curve. A basic example: - * - * var tweenable = new Tweenable(); - * tweenable.tween({ - * from: { transform: 'translateX(0px) translateY(0px)'}, - * to: { transform: 'translateX(100px) translateY(100px)'}, - * easing: { transform: 'easeInQuad' }, - * step: function (state) { - * console.log(state.transform); - * } - * }); - * - * ` ` - * The above snippet create values like this: - * - * translateX(11.560000000000002px) translateY(11.560000000000002px) - * ... - * translateX(46.24000000000001px) translateY(46.24000000000001px) - * ... - * translateX(100px) translateY(100px) - * - * ` ` - * In this case, the values for `translateX` and `translateY` are always the - * same for each step of the tween, because they have the same start and end - * points and both use the same easing curve. We can also tween `translateX` - * and `translateY` along independent curves: - * - * var tweenable = new Tweenable(); - * tweenable.tween({ - * from: { transform: 'translateX(0px) translateY(0px)'}, - * to: { transform: 'translateX(100px) translateY(100px)'}, - * easing: { transform: 'easeInQuad bounce' }, - * step: function (state) { - * console.log(state.transform); - * } - * }); - * - * ` ` - * The above snippet create values like this: - * - * translateX(10.89px) translateY(82.355625px) - * ... - * translateX(44.89000000000001px) translateY(86.73062500000002px) - * ... - * translateX(100px) translateY(100px) - * - * ` ` - * `translateX` and `translateY` are not in sync anymore, because `easeInQuad` - * was specified for `translateX` and `bounce` for `translateY`. Mixing and - * matching easing curves can make for some interesting motion in your - * animations. - * - * The order of the space-separated easing curves correspond the token values - * they apply to. If there are more token values than easing curves listed, - * the last easing curve listed is used. - */ - function token () { - // Functionality for this extension runs implicitly if it is loaded. - } /*!*/ - - // token function is defined above only so that dox-foundation sees it as - // documentation and renders it. It is never used, and is optimized away at - // build time. - - ;(function (Tweenable) { - - /*! - * @typedef {{ - * formatString: string - * chunkNames: Array. - * }} - */ - var formatManifest; - - // CONSTANTS - - var R_NUMBER_COMPONENT = /(\d|\-|\.)/; - var R_FORMAT_CHUNKS = /([^\-0-9\.]+)/g; - var R_UNFORMATTED_VALUES = /[0-9.\-]+/g; - var R_RGB = new RegExp( - 'rgb\\(' + R_UNFORMATTED_VALUES.source + - (/,\s*/.source) + R_UNFORMATTED_VALUES.source + - (/,\s*/.source) + R_UNFORMATTED_VALUES.source + '\\)', 'g'); - var R_RGB_PREFIX = /^.*\(/; - var R_HEX = /#([0-9]|[a-f]){3,6}/gi; - var VALUE_PLACEHOLDER = 'VAL'; - - // HELPERS - - var getFormatChunksFrom_accumulator = []; - /*! - * @param {Array.number} rawValues - * @param {string} prefix - * - * @return {Array.} - */ - function getFormatChunksFrom (rawValues, prefix) { - getFormatChunksFrom_accumulator.length = 0; - - var rawValuesLength = rawValues.length; - var i; - - for (i = 0; i < rawValuesLength; i++) { - getFormatChunksFrom_accumulator.push('_' + prefix + '_' + i); - } - - return getFormatChunksFrom_accumulator; - } - - /*! - * @param {string} formattedString - * - * @return {string} - */ - function getFormatStringFrom (formattedString) { - var chunks = formattedString.match(R_FORMAT_CHUNKS); - - if (!chunks) { - // chunks will be null if there were no tokens to parse in - // formattedString (for example, if formattedString is '2'). Coerce - // chunks to be useful here. - chunks = ['', '']; - - // If there is only one chunk, assume that the string is a number - // followed by a token... - // NOTE: This may be an unwise assumption. - } else if (chunks.length === 1 || - // ...or if the string starts with a number component (".", "-", or a - // digit)... - formattedString[0].match(R_NUMBER_COMPONENT)) { - // ...prepend an empty string here to make sure that the formatted number - // is properly replaced by VALUE_PLACEHOLDER - chunks.unshift(''); - } - - return chunks.join(VALUE_PLACEHOLDER); - } - - /*! - * Convert all hex color values within a string to an rgb string. - * - * @param {Object} stateObject - * - * @return {Object} The modified obj - */ - function sanitizeObjectForHexProps (stateObject) { - Tweenable.each(stateObject, function (prop) { - var currentProp = stateObject[prop]; - - if (typeof currentProp === 'string' && currentProp.match(R_HEX)) { - stateObject[prop] = sanitizeHexChunksToRGB(currentProp); - } - }); - } - - /*! - * @param {string} str - * - * @return {string} - */ - function sanitizeHexChunksToRGB (str) { - return filterStringChunks(R_HEX, str, convertHexToRGB); - } - - /*! - * @param {string} hexString - * - * @return {string} - */ - function convertHexToRGB (hexString) { - var rgbArr = hexToRGBArray(hexString); - return 'rgb(' + rgbArr[0] + ',' + rgbArr[1] + ',' + rgbArr[2] + ')'; - } - - var hexToRGBArray_returnArray = []; - /*! - * Convert a hexadecimal string to an array with three items, one each for - * the red, blue, and green decimal values. - * - * @param {string} hex A hexadecimal string. - * - * @returns {Array.} The converted Array of RGB values if `hex` is a - * valid string, or an Array of three 0's. - */ - function hexToRGBArray (hex) { - - hex = hex.replace(/#/, ''); - - // If the string is a shorthand three digit hex notation, normalize it to - // the standard six digit notation - if (hex.length === 3) { - hex = hex.split(''); - hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; - } - - hexToRGBArray_returnArray[0] = hexToDec(hex.substr(0, 2)); - hexToRGBArray_returnArray[1] = hexToDec(hex.substr(2, 2)); - hexToRGBArray_returnArray[2] = hexToDec(hex.substr(4, 2)); - - return hexToRGBArray_returnArray; - } - - /*! - * Convert a base-16 number to base-10. - * - * @param {Number|String} hex The value to convert - * - * @returns {Number} The base-10 equivalent of `hex`. - */ - function hexToDec (hex) { - return parseInt(hex, 16); - } - - /*! - * Runs a filter operation on all chunks of a string that match a RegExp - * - * @param {RegExp} pattern - * @param {string} unfilteredString - * @param {function(string)} filter - * - * @return {string} - */ - function filterStringChunks (pattern, unfilteredString, filter) { - var pattenMatches = unfilteredString.match(pattern); - var filteredString = unfilteredString.replace(pattern, VALUE_PLACEHOLDER); - - if (pattenMatches) { - var pattenMatchesLength = pattenMatches.length; - var currentChunk; - - for (var i = 0; i < pattenMatchesLength; i++) { - currentChunk = pattenMatches.shift(); - filteredString = filteredString.replace( - VALUE_PLACEHOLDER, filter(currentChunk)); - } - } - - return filteredString; - } - - /*! - * Check for floating point values within rgb strings and rounds them. - * - * @param {string} formattedString - * - * @return {string} - */ - function sanitizeRGBChunks (formattedString) { - return filterStringChunks(R_RGB, formattedString, sanitizeRGBChunk); - } - - /*! - * @param {string} rgbChunk - * - * @return {string} - */ - function sanitizeRGBChunk (rgbChunk) { - var numbers = rgbChunk.match(R_UNFORMATTED_VALUES); - var numbersLength = numbers.length; - var sanitizedString = rgbChunk.match(R_RGB_PREFIX)[0]; - - for (var i = 0; i < numbersLength; i++) { - sanitizedString += parseInt(numbers[i], 10) + ','; - } - - sanitizedString = sanitizedString.slice(0, -1) + ')'; - - return sanitizedString; - } - - /*! - * @param {Object} stateObject - * - * @return {Object} An Object of formatManifests that correspond to - * the string properties of stateObject - */ - function getFormatManifests (stateObject) { - var manifestAccumulator = {}; - - Tweenable.each(stateObject, function (prop) { - var currentProp = stateObject[prop]; - - if (typeof currentProp === 'string') { - var rawValues = getValuesFrom(currentProp); - - manifestAccumulator[prop] = { - 'formatString': getFormatStringFrom(currentProp) - ,'chunkNames': getFormatChunksFrom(rawValues, prop) - }; - } - }); - - return manifestAccumulator; - } - - /*! - * @param {Object} stateObject - * @param {Object} formatManifests - */ - function expandFormattedProperties (stateObject, formatManifests) { - Tweenable.each(formatManifests, function (prop) { - var currentProp = stateObject[prop]; - var rawValues = getValuesFrom(currentProp); - var rawValuesLength = rawValues.length; - - for (var i = 0; i < rawValuesLength; i++) { - stateObject[formatManifests[prop].chunkNames[i]] = +rawValues[i]; - } - - delete stateObject[prop]; - }); - } - - /*! - * @param {Object} stateObject - * @param {Object} formatManifests - */ - function collapseFormattedProperties (stateObject, formatManifests) { - Tweenable.each(formatManifests, function (prop) { - var currentProp = stateObject[prop]; - var formatChunks = extractPropertyChunks( - stateObject, formatManifests[prop].chunkNames); - var valuesList = getValuesList( - formatChunks, formatManifests[prop].chunkNames); - currentProp = getFormattedValues( - formatManifests[prop].formatString, valuesList); - stateObject[prop] = sanitizeRGBChunks(currentProp); - }); - } - - /*! - * @param {Object} stateObject - * @param {Array.} chunkNames - * - * @return {Object} The extracted value chunks. - */ - function extractPropertyChunks (stateObject, chunkNames) { - var extractedValues = {}; - var currentChunkName, chunkNamesLength = chunkNames.length; - - for (var i = 0; i < chunkNamesLength; i++) { - currentChunkName = chunkNames[i]; - extractedValues[currentChunkName] = stateObject[currentChunkName]; - delete stateObject[currentChunkName]; - } - - return extractedValues; - } - - var getValuesList_accumulator = []; - /*! - * @param {Object} stateObject - * @param {Array.} chunkNames - * - * @return {Array.} - */ - function getValuesList (stateObject, chunkNames) { - getValuesList_accumulator.length = 0; - var chunkNamesLength = chunkNames.length; - - for (var i = 0; i < chunkNamesLength; i++) { - getValuesList_accumulator.push(stateObject[chunkNames[i]]); - } - - return getValuesList_accumulator; - } - - /*! - * @param {string} formatString - * @param {Array.} rawValues - * - * @return {string} - */ - function getFormattedValues (formatString, rawValues) { - var formattedValueString = formatString; - var rawValuesLength = rawValues.length; - - for (var i = 0; i < rawValuesLength; i++) { - formattedValueString = formattedValueString.replace( - VALUE_PLACEHOLDER, +rawValues[i].toFixed(4)); - } - - return formattedValueString; - } - - /*! - * Note: It's the duty of the caller to convert the Array elements of the - * return value into numbers. This is a performance optimization. - * - * @param {string} formattedString - * - * @return {Array.|null} - */ - function getValuesFrom (formattedString) { - return formattedString.match(R_UNFORMATTED_VALUES); - } - - /*! - * @param {Object} easingObject - * @param {Object} tokenData - */ - function expandEasingObject (easingObject, tokenData) { - Tweenable.each(tokenData, function (prop) { - var currentProp = tokenData[prop]; - var chunkNames = currentProp.chunkNames; - var chunkLength = chunkNames.length; - var easingChunks = easingObject[prop].split(' '); - var lastEasingChunk = easingChunks[easingChunks.length - 1]; - - for (var i = 0; i < chunkLength; i++) { - easingObject[chunkNames[i]] = easingChunks[i] || lastEasingChunk; - } - - delete easingObject[prop]; - }); - } - - /*! - * @param {Object} easingObject - * @param {Object} tokenData - */ - function collapseEasingObject (easingObject, tokenData) { - Tweenable.each(tokenData, function (prop) { - var currentProp = tokenData[prop]; - var chunkNames = currentProp.chunkNames; - var chunkLength = chunkNames.length; - var composedEasingString = ''; - - for (var i = 0; i < chunkLength; i++) { - composedEasingString += ' ' + easingObject[chunkNames[i]]; - delete easingObject[chunkNames[i]]; - } - - easingObject[prop] = composedEasingString.substr(1); - }); - } - - Tweenable.prototype.filter.token = { - 'tweenCreated': function (currentState, fromState, toState, easingObject) { - sanitizeObjectForHexProps(currentState); - sanitizeObjectForHexProps(fromState); - sanitizeObjectForHexProps(toState); - this._tokenData = getFormatManifests(currentState); - }, - - 'beforeTween': function (currentState, fromState, toState, easingObject) { - expandEasingObject(easingObject, this._tokenData); - expandFormattedProperties(currentState, this._tokenData); - expandFormattedProperties(fromState, this._tokenData); - expandFormattedProperties(toState, this._tokenData); - }, - - 'afterTween': function (currentState, fromState, toState, easingObject) { - collapseFormattedProperties(currentState, this._tokenData); - collapseFormattedProperties(fromState, this._tokenData); - collapseFormattedProperties(toState, this._tokenData); - collapseEasingObject(easingObject, this._tokenData); - } - }; - - } (Tweenable)); - - }(window)); - - return window.Tweenable; -}); - -(function() { - "use strict"; - - angular.module('angular-carousel') - - .filter('carouselSlice', function() { - return function(collection, start, size) { - if (angular.isArray(collection)) { - return collection.slice(start, start + size); - } else if (angular.isObject(collection)) { - // dont try to slice collections :) - return collection; - } - }; - }); - -})(); -/* jshint ignore:end */ diff --git a/www/external/angular-carousel.min.js b/www/external/angular-carousel.min.js new file mode 100644 index 00000000..34327d30 --- /dev/null +++ b/www/external/angular-carousel.min.js @@ -0,0 +1,124 @@ +//Angular Carousel - Mobile friendly touch carousel for AngularJS +//@version v0.3.12 - 2015-06-11 +//@link http://revolunet.github.com/angular-carousel +//@author Julien Bouquillon +//@license MIT License, http://www.opensource.org/licenses/MIT +//Angular touch carousel with CSS GPU accel and slide buffering +//http://github.com/revolunet/angular-carousel + +// Modified by PP for mobile friendly touch, start without auto slide but enabled it if tapped +// and logic to wait for an image to load before it slides to the next one +// +/* jshint ignore:start */ +/*global angular */ + +angular.module("angular-carousel",["ngTouch","angular-carousel.shifty"]),angular.module("angular-carousel").directive("rnCarouselAutoSlide",["$interval","$timeout","imageLoadingDataShare","carouselUtils",function(t,e,n,r){return{restrict:"A",link:function(t,e,n){var i=function(){t.autoSlider&&(t.autoSlider=null)},o=function(){0==r.isStopped()&&t.autoSlide()},a=function(){r.setStop(!r.getStop()),r.isStopped()&&r.setIndex(t.carouselIndex),t.autoSlider?(r.setStop(!0),r.setIndex(t.carouselIndex),i()):(r.setStop(!1),o())} +r.setStop(!1),t.$watch("carouselIndex",o),n.hasOwnProperty("rnCarouselPauseOnHover")&&"false"!==n.rnCarouselPauseOnHover&&(n.hasOwnProperty("rnPlatform")&&"desktop"==n.rnPlatform?(e.off("click",a),e.on("click",a)):(e.off("touchend",a),e.on("touchend",a))),t.$on("$destroy",function(){i(),e.off("touchend",a),e.off("click",a)})}}}]),angular.module("angular-carousel").directive("rnCarouselIndicators",["$parse",function(t){return{restrict:"A",scope:{slides:"=",index:"=rnCarouselIndex"},templateUrl:"carousel-indicators.html",link:function(e,n,r){var i=t(r.rnCarouselIndex) +e.goToSlide=function(t){i.assign(e.$parent.$parent,t)}}}}]),angular.module("angular-carousel").run(["$templateCache",function(t){t.put("carousel-indicators.html",'')}]),function(){"use strict" +angular.module("angular-carousel").service("DeviceCapabilities",function(){function t(){var t="transform",e="webkitTransform" +return"undefined"!=typeof document.body.style[t]?["webkit","moz","o","ms"].every(function(e){var n="-"+e+"-transform" +return"undefined"==typeof document.body.style[n]||(t=n,!1)}):t="undefined"!=typeof document.body.style[e]?"-webkit-transform":void 0,t}function e(){var t,e=document.createElement("p"),n={webkitTransform:"-webkit-transform",msTransform:"-ms-transform",transform:"transform"} +document.body.insertBefore(e,null) +for(var r in n)void 0!==e.style[r]&&(e.style[r]="translate3d(1px,1px,1px)",t=window.getComputedStyle(e).getPropertyValue(n[r])) +return document.body.removeChild(e),void 0!==t&&t.length>0&&"none"!==t}return{has3d:e(),transformProperty:t()}}).service("computeCarouselSlideStyle",["DeviceCapabilities",function(t){return function(e,n,r){var i,o={display:"inline-block"},a=100*e+n,u=t.has3d?"translate3d("+a+"%, 0, 0)":"translate3d("+a+"%, 0)",s=(100-Math.abs(a))/100 +if(t.transformProperty)if("fadeAndSlide"==r)o[t.transformProperty]=u,i=0,Math.abs(a)<100&&(i=.3+.7*s),o.opacity=i +else if("hexagon"==r){var c=100,l=0,f=60*(s-1) +c=n li")}function _(t){N=!0,F({x:t.clientX,y:t.clientY},t)}function I(t){var e=100*a.carouselBufferIndex+t +angular.forEach(w(),function(t,n){t.style.cssText=s(u(n,e,z.transitionType))})}function x(t,e){if(void 0===t&&(t=a.carouselIndex),e=e||{},e.animate===!1||"none"===z.transitionType)return U=!1,R=t*-100,a.carouselIndex=t,void O() +U=!0 +var n=new c +n.tween({from:{x:R},to:{x:t*-100},duration:z.transitionDuration,easing:z.transitionEasing,step:function(t){I(t.x)},finish:function(){a.$apply(function(){a.carouselIndex=t,R=t*-100,O(),o(function(){U=!1},0,!1)})}})}function C(){var t=p[0].getBoundingClientRect() +return t.width?t.width:t.right-t.left}function b(){Q=C()}function k(){j||(j=!0,n.bind("mouseup",_))}function M(){j&&(j=!1,n.unbind("mouseup",_))}function T(t,e){if(!(U||H.length<=1))return b(),L=p[0].querySelector("li").getBoundingClientRect().left,D=!0,A=t.x,!1}function P(t,e){var n,r +if(k(),D&&(n=t.x,r=A-n,r>2||r<-2)){N=!0 +var i=R+100*-r/Q +I(i)}return!1}function F(t,e,n){if((!e||N)&&(M(),D=!1,N=!1,B=A-t.x,0!==B&&!U))if(R+=100*-B/Q,z.isSequential){var i=z.moveTreshold*Q,o=-B,u=-Math[o>=0?"ceil":"floor"](o/Q),s=Math.abs(o)>i +H&&u+a.carouselIndex>=H.length&&(u=H.length-1-a.carouselIndex),u+a.carouselIndex<0&&(u=-a.carouselIndex) +var c=s?u:0 +B=a.carouselIndex+c,x(B),void 0!==g.rnCarouselOnInfiniteScrollRight&&0===u&&0!==a.carouselIndex&&(r(g.rnCarouselOnInfiniteScrollRight)(a),x(0)),void 0!==g.rnCarouselOnInfiniteScrollLeft&&0===u&&0===a.carouselIndex&&0===c&&(r(g.rnCarouselOnInfiniteScrollLeft)(a),x(H.length))}else a.$apply(function(){a.carouselIndex=parseInt(-R/100,10),O()})}function O(){var t=0,e=(a.carouselBufferSize-1)/2 +S?(t=a.carouselIndex<=e?0:H&&H.lengthH.length-a.carouselBufferSize?H.length-a.carouselBufferSize:a.carouselIndex-e,a.carouselBufferIndex=t,o(function(){I(R)},0,!1)):o(function(){I(R)},0,!1)}function $(){b(),x()}h++ +var D,A,B,q={transitionType:g.rnCarouselTransition||"slide",transitionEasing:g.rnCarouselEasing||"easeTo",transitionDuration:parseFloat(g.rnCarouselDuration,10)||300,isSequential:!0,autoSlideDuration:3,bufferSize:9,moveTreshold:.1,defaultIndex:0},z=angular.extend({},q),E=!1,R=0,N=!1,H=[],Q=null,L=null,j=!1,U=!1 +"true"!==g.rnSwipeDisabled&&t.bind(p,{start:T,move:P,end:F,cancel:function(t){F({},t)}}),a.nextSlide=function(t){if(1!=f.isStopped()){var e=a.carouselIndex+1 +e>H.length-1&&e--,1!=l.get()?x(e,t):a.autoSlide()}},a.prevSlide=function(t){var e=a.carouselIndex-1 +e<0&&(e=H.length-1),x(e,t)} +var W=!0 +if(a.carouselIndex=0,y||(H=[],angular.forEach(w(),function(t,e){H.push({id:e})})),void 0!==g.rnCarouselControls){var Y=y?m.replace("::","")+".length - 1":H.length-1,G='' +p.parent().append(i(angular.element(G))(a))}if(void 0!==g.rnCarouselAutoSlide){var V=parseFloat(g.rnCarouselAutoSlide,10)||z.autoSlideDuration +f.setDuration(V),console.log("Setting duration - should only happen once"),a.autoSlide=function(){if(a.autoSlider&&(a.autoSlider=null),0==f.isStopped()){var t=f.getDuration(),e=1e3*t +e<5&&(console.log("duration is too small at "+e+" making it to 5"),e=5),a.autoSlider=o(function(){a.nextSlide()},e)}else console.log("We are stopped, doing nothing")}}if(g.rnCarouselDefaultIndex){var X=r(g.rnCarouselDefaultIndex) +z.defaultIndex=X(a.$parent)||0}var J=null +if(g.rnCarouselIndex){var K=function(t){t<0||Z.assign(a.$parent,t)},Z=r(g.rnCarouselIndex) +angular.isFunction(Z.assign)?(a.$watch("carouselIndex",function(t){K(t)}),a.$parent.$watch(function(){return Z(a.$parent)},function(t,e){J=t,void 0!==t&&null!==t&&(H&&H.length>0&&t>=H.length?(t=H.length-1,K(t)):H&&t<0&&(t=0,K(t)),U||x(t,{animate:!W}),W=!1)}),E=!0,z.defaultIndex&&x(z.defaultIndex,{animate:!W})):isNaN(g.rnCarouselIndex)||x(parseInt(g.rnCarouselIndex,10),{animate:!1})}else x(z.defaultIndex,{animate:!W}),W=!1 +if(g.rnCarouselLocked&&a.$watch(g.rnCarouselLocked,function(t,e){U=t===!0}),y){var tt=void 0!==g.rnCarouselDeepWatch +a[tt?"$watch":"$watchCollection"](m,function(t,e){if(H=t,J&&(a.carouselIndex=J,J=null),tt&&angular.isArray(t)){var n=e[a.carouselIndex],r=d(t,n,a.carouselIndex) +x(r,{animate:!1})}else x(a.carouselIndex,{animate:!1})},!0)}a.$on("$destroy",function(){M()}),a.carouselBufferIndex=0,a.carouselBufferSize=z.bufferSize +var et=angular.element(e) +et.bind("orientationchange",$),et.bind("resize",$),a.$on("$destroy",function(){M(),et.unbind("orientationchange",$),et.unbind("resize",$)})}}}}])}(),angular.module("angular-carousel.shifty",[]).factory("Tweenable",function(){return function(t){var e=function(){"use strict" +function e(){}function n(t,e){var n +for(n in t)Object.hasOwnProperty.call(t,n)&&e(n)}function r(t,e){return n(e,function(n){t[n]=e[n]}),t}function i(t,e){n(e,function(n){"undefined"==typeof t[n]&&(t[n]=e[n])})}function o(t,e,n,r,i,o,u){var s,c=(t-o)/i +for(s in e)e.hasOwnProperty(s)&&(e[s]=a(n[s],r[s],f[u[s]],c)) +return e}function a(t,e,n,r){return t+(e-t)*n(r)}function u(t,e){var r=l.prototype.filter,i=t._filterArgs +n(r,function(n){"undefined"!=typeof r[n][e]&&r[n][e].apply(t,i)})}function s(t,e,n,r,i,a,s,c,l){w=e+n,y=Math.min(v(),w),S=y>=w,_=n-(w-y),t.isPlaying()&&!S?(t._scheduleId=l(t._timeoutHandler,g),u(t,"beforeTween"),o(y,r,i,a,n,e,s),u(t,"afterTween"),c(r,t._attachment,_)):S&&(c(a,t._attachment,_),t.stop(!0))}function c(t,e){var r={} +return"string"==typeof e?n(t,function(t){r[t]=e}):n(t,function(t){r[t]||(r[t]=e[t]||h)}),r}function l(t,e){this._currentState=t||{},this._configured=!1,this._scheduleFunction=d,"undefined"!=typeof e&&this.setConfig(e)}var f,d,h="linear",p=500,g=1e3/60,m=Date.now?Date.now:function(){return+new Date},v="undefined"!=typeof SHIFTY_DEBUG_NOW?SHIFTY_DEBUG_NOW:m +d="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||window.mozCancelRequestAnimationFrame&&window.mozRequestAnimationFrame||setTimeout:setTimeout +var w,y,S,_ +return l.prototype.tween=function(t){return this._isTweening?this:(void 0===t&&this._configured||this.setConfig(t),this._timestamp=v(),this._start(this.get(),this._attachment),this.resume())},l.prototype.setConfig=function(t){t=t||{},this._configured=!0,this._attachment=t.attachment,this._pausedAtTime=null,this._scheduleId=null,this._start=t.start||e,this._step=t.step||e,this._finish=t.finish||e,this._duration=t.duration||p,this._currentState=t.from||this.get(),this._originalState=this.get(),this._targetState=t.to||this.get() +var n=this._currentState,r=this._targetState +return i(r,n),this._easing=c(n,t.easing||h),this._filterArgs=[n,this._originalState,r,this._easing],u(this,"tweenCreated"),this},l.prototype.get=function(){return r({},this._currentState)},l.prototype.set=function(t){this._currentState=t},l.prototype.pause=function(){return this._pausedAtTime=v(),this._isPaused=!0,this},l.prototype.resume=function(){this._isPaused&&(this._timestamp+=v()-this._pausedAtTime),this._isPaused=!1,this._isTweening=!0 +var t=this +return this._timeoutHandler=function(){s(t,t._timestamp,t._duration,t._currentState,t._originalState,t._targetState,t._easing,t._step,t._scheduleFunction)},this._timeoutHandler(),this},l.prototype.seek=function(t){return this._timestamp=v()-t,this.isPlaying()||(this._isTweening=!0,this._isPaused=!1,s(this,this._timestamp,this._duration,this._currentState,this._originalState,this._targetState,this._easing,this._step,this._scheduleFunction),this._timeoutHandler(),this.pause()),this},l.prototype.stop=function(n){return this._isTweening=!1,this._isPaused=!1,this._timeoutHandler=e,(t.cancelAnimationFrame||t.webkitCancelAnimationFrame||t.oCancelAnimationFrame||t.msCancelAnimationFrame||t.mozCancelRequestAnimationFrame||t.clearTimeout)(this._scheduleId),n&&(r(this._currentState,this._targetState),u(this,"afterTweenEnd"),this._finish.call(this,this._currentState,this._attachment)),this},l.prototype.isPlaying=function(){return this._isTweening&&!this._isPaused},l.prototype.setScheduleFunction=function(t){this._scheduleFunction=t},l.prototype.dispose=function(){var t +for(t in this)this.hasOwnProperty(t)&&delete this[t]},l.prototype.filter={},l.prototype.formula={linear:function(t){return t}},f=l.prototype.formula,r(l,{now:v,each:n,tweenProps:o,tweenProp:a,applyFilter:u,shallowCopy:r,defaults:i,composeEasingObject:c}),t.Tweenable=l,l}() +!function(){e.shallowCopy(e.prototype.formula,{easeInQuad:function(t){return Math.pow(t,2)},easeOutQuad:function(t){return-(Math.pow(t-1,2)-1)},easeInOutQuad:function(t){return(t/=.5)<1?.5*Math.pow(t,2):-.5*((t-=2)*t-2)},easeInCubic:function(t){return Math.pow(t,3)},easeOutCubic:function(t){return Math.pow(t-1,3)+1},easeInOutCubic:function(t){return(t/=.5)<1?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)},easeInQuart:function(t){return Math.pow(t,4)},easeOutQuart:function(t){return-(Math.pow(t-1,4)-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeInQuint:function(t){return Math.pow(t,5)},easeOutQuint:function(t){return Math.pow(t-1,5)+1},easeInOutQuint:function(t){return(t/=.5)<1?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)},easeInSine:function(t){return-Math.cos(t*(Math.PI/2))+1},easeOutSine:function(t){return Math.sin(t*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:-Math.pow(2,-10*t)+1},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-Math.pow(t-1,2))},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeOutBounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},easeInBack:function(t){var e=1.70158 +return t*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158 +return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack:function(t){var e=1.70158 +return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},elastic:function(t){return-1*Math.pow(4,-8*t)*Math.sin((6*t-1)*(2*Math.PI)/2)+1},swingFromTo:function(t){var e=1.70158 +return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},swingFrom:function(t){var e=1.70158 +return t*t*((e+1)*t-e)},swingTo:function(t){var e=1.70158 +return(t-=1)*t*((e+1)*t+e)+1},bounce:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},bouncePast:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?2-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?2-(7.5625*(t-=2.25/2.75)*t+.9375):2-(7.5625*(t-=2.625/2.75)*t+.984375)},easeFromTo:function(t){return(t/=.5)<1?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeFrom:function(t){return Math.pow(t,4)},easeTo:function(t){return Math.pow(t,.25)}})}(),function(){function t(t,e,n,r,i,o){function a(t){return((h*t+p)*t+g)*t}function u(t){return((m*t+v)*t+w)*t}function s(t){return(3*h*t+2*p)*t+g}function c(t){return 1/(200*t)}function l(t,e){return u(d(t,e))}function f(t){return t>=0?t:0-t}function d(t,e){var n,r,i,o,u,c +for(i=t,c=0;c<8;c++){if(o=a(i)-t,f(o)r)return r +for(;no?n=i:r=i,i=.5*(r-n)+n}return i}var h=0,p=0,g=0,m=0,v=0,w=0 +return g=3*e,p=3*(r-e)-g,h=1-g-p,w=3*n,v=3*(i-n)-w,m=1-w-v,l(t,c(o))}function n(e,n,r,i){return function(o){return t(o,e,n,r,i,1)}}e.setBezierFunction=function(t,r,i,o,a){var u=n(r,i,o,a) +return u.x1=r,u.y1=i,u.x2=o,u.y2=a,e.prototype.formula[t]=u},e.unsetBezierFunction=function(t){delete e.prototype.formula[t]}}(),function(){function t(t,n,r,i,o){return e.tweenProps(i,n,t,r,1,0,o)}var n=new e +n._filterArgs=[],e.interpolate=function(r,i,o,a){var u=e.shallowCopy({},r),s=e.composeEasingObject(r,a||"linear") +n.set({}) +var c=n._filterArgs +c.length=0,c[0]=u,c[1]=r,c[2]=i,c[3]=s,e.applyFilter(n,"tweenCreated"),e.applyFilter(n,"beforeTween") +var l=t(r,u,i,o,s) +return e.applyFilter(n,"afterTween"),l}}(),function(t){function e(t,e){M.length=0 +var n,r=t.length +for(n=0;n{{options.content}}' + - '', - controller: ['$scope', '$element', '$attrs', - function ($scope, $element, $attrs) { - - $scope.toggleMenu = function () { - //PP - if (typeof $scope.options.button.onclick === 'function') - { - // PP - console.log ("FUNCTION"); - //$scope.options.isOpen = !$scope.options.isOpen; - $scope.options.button.onclick(); - } - else - { - // console.log ("NO FUNCTION"); - $scope.options.isOpen = !$scope.options.isOpen; - } - }; - - $scope.perform = function (options, item) { - if (typeof item.onclick === 'function') { - item.onclick(options, item); - } - - if ($scope.options.toggleOnClick) { - $scope.toggleMenu(); - } - }; - - } - ] - }; - }]); - - /* istanbul ignore next */ - if (typeof define === 'function' && define.amd) { - define('circular', ['angular'], circular); - } else if ('undefined' !== typeof exports && 'undefined' !== typeof module) { - module.exports = circular; - } - -})(); diff --git a/www/external/angular-circular-navigation.min.js b/www/external/angular-circular-navigation.min.js new file mode 100644 index 00000000..3b466c2f --- /dev/null +++ b/www/external/angular-circular-navigation.min.js @@ -0,0 +1,5 @@ +// https://github.com/maxklenk/angular-circular-navigation/blob/master/LICENSE +// PP - Modified to show at right angles +!function(){"use strict" +var o=window.angular?window.angular:"undefined"!=typeof require?require("angular"):void 0,n=o.module("angularCircularNavigation",[]).directive("circular",["$compile",function(o){return{restrict:"EA",scope:{options:"="},template:'',controller:["$scope","$element","$attrs",function(o,n,t){o.toggleMenu=function(){"function"==typeof o.options.button.onclick?o.options.button.onclick():o.options.isOpen=!o.options.isOpen},o.perform=function(n,t){"function"==typeof t.onclick&&t.onclick(n,t),o.options.toggleOnClick&&o.toggleMenu()}}]}}]) +"function"==typeof define&&define.amd?define("circular",["angular"],n):"undefined"!=typeof exports&&"undefined"!=typeof module&&(module.exports=n)}() diff --git a/www/external/canvas-toBlob.js b/www/external/canvas-toBlob.js deleted file mode 100644 index 6d895a78..00000000 --- a/www/external/canvas-toBlob.js +++ /dev/null @@ -1,124 +0,0 @@ -/* canvas-toBlob.js - * A canvas.toBlob() implementation. - * 2013-12-27 - * - * By Eli Grey, http://eligrey.com and Devin Samarin, https://github.com/eboyjr - * License: MIT - * See https://github.com/eligrey/canvas-toBlob.js/blob/master/LICENSE.md - */ - -/*global self */ -/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true, - plusplus: true */ - -/*! @source http://purl.eligrey.com/github/canvas-toBlob.js/blob/master/canvas-toBlob.js */ - -(function(view) { -"use strict"; -var - Uint8Array = view.Uint8Array - , HTMLCanvasElement = view.HTMLCanvasElement - , canvas_proto = HTMLCanvasElement && HTMLCanvasElement.prototype - , is_base64_regex = /\s*;\s*base64\s*(?:;|$)/i - , to_data_url = "toDataURL" - , base64_ranks - , decode_base64 = function(base64) { - var - len = base64.length - , buffer = new Uint8Array(len / 4 * 3 | 0) - , i = 0 - , outptr = 0 - , last = [0, 0] - , state = 0 - , save = 0 - , rank - , code - , undef - ; - while (len--) { - code = base64.charCodeAt(i++); - rank = base64_ranks[code-43]; - if (rank !== 255 && rank !== undef) { - last[1] = last[0]; - last[0] = code; - save = (save << 6) | rank; - state++; - if (state === 4) { - buffer[outptr++] = save >>> 16; - if (last[1] !== 61 /* padding character */) { - buffer[outptr++] = save >>> 8; - } - if (last[0] !== 61 /* padding character */) { - buffer[outptr++] = save; - } - state = 0; - } - } - } - // 2/3 chance there's going to be some null bytes at the end, but that - // doesn't really matter with most image formats. - // If it somehow matters for you, truncate the buffer up outptr. - return buffer; - } -; -if (Uint8Array) { - base64_ranks = new Uint8Array([ - 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1 - , -1, -1, 0, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 - , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 - , -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 - , 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 - ]); -} -if (HTMLCanvasElement && !canvas_proto.toBlob) { - canvas_proto.toBlob = function(callback, type /*, ...args*/) { - if (!type) { - type = "image/png"; - } if (this.mozGetAsFile) { - callback(this.mozGetAsFile("canvas", type)); - return; - } if (this.msToBlob && /^\s*image\/png\s*(?:$|;)/i.test(type)) { - callback(this.msToBlob()); - return; - } - - var - args = Array.prototype.slice.call(arguments, 1) - , dataURI = this[to_data_url].apply(this, args) - , header_end = dataURI.indexOf(",") - , data = dataURI.substring(header_end + 1) - , is_base64 = is_base64_regex.test(dataURI.substring(0, header_end)) - , blob - ; - if (Blob.fake) { - // no reason to decode a data: URI that's just going to become a data URI again - blob = new Blob - if (is_base64) { - blob.encoding = "base64"; - } else { - blob.encoding = "URI"; - } - blob.data = data; - blob.size = data.length; - } else if (Uint8Array) { - if (is_base64) { - blob = new Blob([decode_base64(data)], {type: type}); - } else { - blob = new Blob([decodeURIComponent(data)], {type: type}); - } - } - callback(blob); - }; - - if (canvas_proto.toDataURLHD) { - canvas_proto.toBlobHD = function() { - to_data_url = "toDataURLHD"; - var blob = this.toBlob(); - to_data_url = "toDataURL"; - return blob; - } - } else { - canvas_proto.toBlobHD = canvas_proto.toBlob; - } -} -}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this)); diff --git a/www/external/canvas-toBlob.min.js b/www/external/canvas-toBlob.min.js new file mode 100644 index 00000000..6651861b --- /dev/null +++ b/www/external/canvas-toBlob.min.js @@ -0,0 +1,17 @@ +/* canvas-toBlob.js + * A canvas.toBlob() implementation. + * 2013-12-27 + * + * By Eli Grey, http://eligrey.com and Devin Samarin, https://github.com/eboyjr + * License: MIT + * See https://github.com/eligrey/canvas-toBlob.js/blob/master/LICENSE.md + */ +!function(t){"use strict" +var o,e=t.Uint8Array,n=t.HTMLCanvasElement,i=n&&n.prototype,s=/\s*;\s*base64\s*(?:;|$)/i,a="toDataURL",l=function(t){for(var n,i,s,a=t.length,l=new e(a/4*3|0),r=0,b=0,d=[0,0],f=0,c=0;a--;)i=t.charCodeAt(r++),n=o[i-43],255!==n&&n!==s&&(d[1]=d[0],d[0]=i,c=c<<6|n,f++,4===f&&(l[b++]=c>>>16,61!==d[1]&&(l[b++]=c>>>8),61!==d[0]&&(l[b++]=c),f=0)) +return l} +e&&(o=new e([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51])),n&&!i.toBlob&&(i.toBlob=function(t,o){if(o||(o="image/png"),this.mozGetAsFile)return void t(this.mozGetAsFile("canvas",o)) +if(this.msToBlob&&/^\s*image\/png\s*(?:$|;)/i.test(o))return void t(this.msToBlob()) +var n,i=Array.prototype.slice.call(arguments,1),r=this[a].apply(this,i),b=r.indexOf(","),d=r.substring(b+1),f=s.test(r.substring(0,b)) +Blob.fake?(n=new Blob,f?n.encoding="base64":n.encoding="URI",n.data=d,n.size=d.length):e&&(n=f?new Blob([l(d)],{type:o}):new Blob([decodeURIComponent(d)],{type:o})),t(n)},i.toDataURLHD?i.toBlobHD=function(){a="toDataURLHD" +var t=this.toBlob() +return a="toDataURL",t}:i.toBlobHD=i.toBlob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this) diff --git a/www/external/draggabilly.pkgd.js b/www/external/draggabilly.pkgd.js deleted file mode 100644 index bef3db35..00000000 --- a/www/external/draggabilly.pkgd.js +++ /dev/null @@ -1,1530 +0,0 @@ -/*! - * Draggabilly PACKAGED v2.1.0 - * Make that shiz draggable - * http://draggabilly.desandro.com - * MIT license - */ - -/** - * Bridget makes jQuery widgets - * v2.0.0 - * MIT license - */ - -/* jshint browser: true, strict: true, undef: true, unused: true */ - -( function( window, factory ) { - - /* globals define: false, module: false, require: false */ - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) { - factory( window, jQuery ); - }); - } else if ( typeof module == 'object' && module.exports ) { - // CommonJS - module.exports = factory( - window, - require('jquery') - ); - } else { - // browser global - window.jQueryBridget = factory( - window, - window.jQuery - ); - } - -}( window, function factory( window, jQuery ) { - - -// ----- utils ----- // - -var arraySlice = Array.prototype.slice; - -// helper function for logging errors -// $.error breaks jQuery chaining -var console = window.console; -var logError = typeof console == 'undefined' ? function() {} : - function( message ) { - console.error( message ); - }; - -// ----- jQueryBridget ----- // - -function jQueryBridget( namespace, PluginClass, $ ) { - $ = $ || jQuery || window.jQuery; - if ( !$ ) { - return; - } - - // add option method -> $().plugin('option', {...}) - if ( !PluginClass.prototype.option ) { - // option setter - PluginClass.prototype.option = function( opts ) { - // bail out if not an object - if ( !$.isPlainObject( opts ) ){ - return; - } - this.options = $.extend( true, this.options, opts ); - }; - } - - // make jQuery plugin - $.fn[ namespace ] = function( arg0 /*, arg1 */ ) { - if ( typeof arg0 == 'string' ) { - // method call $().plugin( 'methodName', { options } ) - // shift arguments by 1 - var args = arraySlice.call( arguments, 1 ); - return methodCall( this, arg0, args ); - } - // just $().plugin({ options }) - plainCall( this, arg0 ); - return this; - }; - - // $().plugin('methodName') - function methodCall( $elems, methodName, args ) { - var returnValue; - var pluginMethodStr = '$().' + namespace + '("' + methodName + '")'; - - $elems.each( function( i, elem ) { - // get instance - var instance = $.data( elem, namespace ); - if ( !instance ) { - logError( namespace + ' not initialized. Cannot call methods, i.e. ' + - pluginMethodStr ); - return; - } - - var method = instance[ methodName ]; - if ( !method || methodName.charAt(0) == '_' ) { - logError( pluginMethodStr + ' is not a valid method' ); - return; - } - - // apply method, get return value - var value = method.apply( instance, args ); - // set return value if value is returned, use only first value - returnValue = returnValue === undefined ? value : returnValue; - }); - - return returnValue !== undefined ? returnValue : $elems; - } - - function plainCall( $elems, options ) { - $elems.each( function( i, elem ) { - var instance = $.data( elem, namespace ); - if ( instance ) { - // set options & init - instance.option( options ); - instance._init(); - } else { - // initialize new instance - instance = new PluginClass( elem, options ); - $.data( elem, namespace, instance ); - } - }); - } - - updateJQuery( $ ); - -} - -// ----- updateJQuery ----- // - -// set $.bridget for v1 backwards compatibility -function updateJQuery( $ ) { - if ( !$ || ( $ && $.bridget ) ) { - return; - } - $.bridget = jQueryBridget; -} - -updateJQuery( jQuery || window.jQuery ); - -// ----- ----- // - -return jQueryBridget; - -})); - -/*! - * getSize v2.0.2 - * measure size of elements - * MIT license - */ - -/*jshint browser: true, strict: true, undef: true, unused: true */ -/*global define: false, module: false, console: false */ - -( function( window, factory ) { - - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'get-size/get-size',[],function() { - return factory(); - }); - } else if ( typeof module == 'object' && module.exports ) { - // CommonJS - module.exports = factory(); - } else { - // browser global - window.getSize = factory(); - } - -})( window, function factory() { - - -// -------------------------- 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' -]; - -var measurementsLength = measurements.length; - -function getZeroSize() { - var size = { - width: 0, - height: 0, - innerWidth: 0, - innerHeight: 0, - outerWidth: 0, - outerHeight: 0 - }; - for ( var i=0; i < measurementsLength; i++ ) { - var measurement = measurements[i]; - size[ measurement ] = 0; - } - return size; -} - -// -------------------------- getStyle -------------------------- // - -/** - * getStyle, get style of element, check for Firefox bug - * https://bugzilla.mozilla.org/show_bug.cgi?id=548397 - */ -function getStyle( elem ) { - var style = getComputedStyle( 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; -} - -// -------------------------- setup -------------------------- // - -var isSetup = false; - -var isBoxSizeOuter; - -/** - * setup - * check isBoxSizerOuter - * do on first getSize() rather than on page load for Firefox bug - */ -function setup() { - // setup once - if ( isSetup ) { - return; - } - isSetup = true; - - // -------------------------- box sizing -------------------------- // - - /** - * WebKit measures the outer-width on style.width on border-box elems - * IE & Firefox<29 measures the inner-width - */ - 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.boxSizing = 'border-box'; - - var body = document.body || document.documentElement; - body.appendChild( div ); - var style = getStyle( div ); - - getSize.isBoxSizeOuter = 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 = style.boxSizing == 'border-box'; - - // get all measurements - for ( var i=0; i < measurementsLength; i++ ) { - var measurement = measurements[i]; - var value = style[ measurement ]; - 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; -} - -return getSize; - -}); - -/** - * EvEmitter v1.0.1 - * Lil' event emitter - * MIT License - */ - -/* jshint unused: true, undef: true, strict: true */ - -( function( global, factory ) { - // universal module definition - /* jshint strict: false */ /* globals define, module */ - if ( typeof define == 'function' && define.amd ) { - // AMD - RequireJS - define( 'ev-emitter/ev-emitter',factory ); - } else if ( typeof module == 'object' && module.exports ) { - // CommonJS - Browserify, Webpack - module.exports = factory(); - } else { - // Browser globals - global.EvEmitter = factory(); - } - -}( this, function() { - - - -function EvEmitter() {} - -var proto = EvEmitter.prototype; - -proto.on = function( eventName, listener ) { - if ( !eventName || !listener ) { - return; - } - // set events hash - var events = this._events = this._events || {}; - // set listeners array - var listeners = events[ eventName ] = events[ eventName ] || []; - // only add once - if ( listeners.indexOf( listener ) == -1 ) { - listeners.push( listener ); - } - - return this; -}; - -proto.once = function( eventName, listener ) { - if ( !eventName || !listener ) { - return; - } - // add event - this.on( eventName, listener ); - // set once flag - // set onceEvents hash - var onceEvents = this._onceEvents = this._onceEvents || {}; - // set onceListeners array - var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || []; - // set flag - onceListeners[ listener ] = true; - - return this; -}; - -proto.off = function( eventName, listener ) { - var listeners = this._events && this._events[ eventName ]; - if ( !listeners || !listeners.length ) { - return; - } - var index = listeners.indexOf( listener ); - if ( index != -1 ) { - listeners.splice( index, 1 ); - } - - return this; -}; - -proto.emitEvent = function( eventName, args ) { - var listeners = this._events && this._events[ eventName ]; - if ( !listeners || !listeners.length ) { - return; - } - var i = 0; - var listener = listeners[i]; - args = args || []; - // once stuff - var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; - - while ( listener ) { - var isOnce = onceListeners && onceListeners[ listener ]; - if ( isOnce ) { - // remove listener - // remove before trigger to prevent recursion - this.off( eventName, listener ); - // unset once flag - delete onceListeners[ listener ]; - } - // trigger listener - listener.apply( this, args ); - // get next listener - i += isOnce ? 0 : 1; - listener = listeners[i]; - } - - return this; -}; - -return EvEmitter; - -})); - -/*! - * Unipointer v2.1.0 - * base class for doing one thing with pointer event - * MIT license - */ - -/*jshint browser: true, undef: true, unused: true, strict: true */ - -( function( window, factory ) { - // universal module definition - /* jshint strict: false */ /*global define, module, require */ - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'unipointer/unipointer',[ - 'ev-emitter/ev-emitter' - ], function( EvEmitter ) { - return factory( window, EvEmitter ); - }); - } else if ( typeof module == 'object' && module.exports ) { - // CommonJS - module.exports = factory( - window, - require('ev-emitter') - ); - } else { - // browser global - window.Unipointer = factory( - window, - window.EvEmitter - ); - } - -}( window, function factory( window, EvEmitter ) { - - - -function noop() {} - -function Unipointer() {} - -// inherit EvEmitter -var proto = Unipointer.prototype = Object.create( EvEmitter.prototype ); - -proto.bindStartEvent = function( elem ) { - this._bindStartEvent( elem, true ); -}; - -proto.unbindStartEvent = function( elem ) { - this._bindStartEvent( elem, false ); -}; - -/** - * works as unbinder, as you can ._bindStart( false ) to unbind - * @param {Boolean} isBind - will unbind if falsey - */ -proto._bindStartEvent = function( elem, isBind ) { - // munge isBind, default to true - isBind = isBind === undefined ? true : !!isBind; - var bindMethod = isBind ? 'addEventListener' : 'removeEventListener'; - - if ( window.navigator.pointerEnabled ) { - // W3C Pointer Events, IE11. See https://coderwall.com/p/mfreca - elem[ bindMethod ]( 'pointerdown', this ); - } else if ( window.navigator.msPointerEnabled ) { - // IE10 Pointer Events - elem[ bindMethod ]( 'MSPointerDown', this ); - } else { - // listen for both, for devices like Chrome Pixel - elem[ bindMethod ]( 'mousedown', this ); - elem[ bindMethod ]( 'touchstart', this ); - } -}; - -// trigger handler methods for events -proto.handleEvent = function( event ) { - var method = 'on' + event.type; - if ( this[ method ] ) { - this[ method ]( event ); - } -}; - -// returns the touch that we're keeping track of -proto.getTouch = function( touches ) { - for ( var i=0; i < touches.length; i++ ) { - var touch = touches[i]; - if ( touch.identifier == this.pointerIdentifier ) { - return touch; - } - } -}; - -// ----- start event ----- // - -proto.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 ); -}; - -proto.ontouchstart = function( event ) { - this._pointerDown( event, event.changedTouches[0] ); -}; - -proto.onMSPointerDown = -proto.onpointerdown = function( event ) { - this._pointerDown( event, event ); -}; - -/** - * pointer start - * @param {Event} event - * @param {Event or Touch} pointer - */ -proto._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 ); -}; - -proto.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' ] -}; - -proto._bindPostStartEvents = function( event ) { - if ( !event ) { - return; - } - // get proper events to match start event - var events = postStartEvents[ event.type ]; - // bind events to node - events.forEach( function( eventName ) { - window.addEventListener( eventName, this ); - }, this ); - // save these arguments - this._boundPointerEvents = events; -}; - -proto._unbindPostStartEvents = function() { - // check for _boundEvents, in case dragEnd triggered twice (old IE8 bug) - if ( !this._boundPointerEvents ) { - return; - } - this._boundPointerEvents.forEach( function( eventName ) { - window.removeEventListener( eventName, this ); - }, this ); - - delete this._boundPointerEvents; -}; - -// ----- move event ----- // - -proto.onmousemove = function( event ) { - this._pointerMove( event, event ); -}; - -proto.onMSPointerMove = -proto.onpointermove = function( event ) { - if ( event.pointerId == this.pointerIdentifier ) { - this._pointerMove( event, event ); - } -}; - -proto.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 - */ -proto._pointerMove = function( event, pointer ) { - this.pointerMove( event, pointer ); -}; - -// public -proto.pointerMove = function( event, pointer ) { - this.emitEvent( 'pointerMove', [ event, pointer ] ); -}; - -// ----- end event ----- // - - -proto.onmouseup = function( event ) { - this._pointerUp( event, event ); -}; - -proto.onMSPointerUp = -proto.onpointerup = function( event ) { - if ( event.pointerId == this.pointerIdentifier ) { - this._pointerUp( event, event ); - } -}; - -proto.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 - */ -proto._pointerUp = function( event, pointer ) { - this._pointerDone(); - this.pointerUp( event, pointer ); -}; - -// public -proto.pointerUp = function( event, pointer ) { - this.emitEvent( 'pointerUp', [ event, pointer ] ); -}; - -// ----- pointer done ----- // - -// triggered on pointer up & pointer cancel -proto._pointerDone = function() { - // reset properties - this.isPointerDown = false; - delete this.pointerIdentifier; - // remove events - this._unbindPostStartEvents(); - this.pointerDone(); -}; - -proto.pointerDone = noop; - -// ----- pointer cancel ----- // - -proto.onMSPointerCancel = -proto.onpointercancel = function( event ) { - if ( event.pointerId == this.pointerIdentifier ) { - this._pointerCancel( event, event ); - } -}; - -proto.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 - */ -proto._pointerCancel = function( event, pointer ) { - this._pointerDone(); - this.pointerCancel( event, pointer ); -}; - -// public -proto.pointerCancel = function( event, pointer ) { - this.emitEvent( 'pointerCancel', [ event, pointer ] ); -}; - -// ----- ----- // - -// utility function for getting x/y coords from event -Unipointer.getPointerPoint = function( pointer ) { - return { - x: pointer.pageX, - y: pointer.pageY - }; -}; - -// ----- ----- // - -return Unipointer; - -})); - -/*! - * Unidragger v2.1.0 - * Draggable base class - * MIT license - */ - -/*jshint browser: true, unused: true, undef: true, strict: true */ - -( function( window, factory ) { - // universal module definition - /*jshint strict: false */ /*globals define, module, require */ - - if ( typeof define == 'function' && define.amd ) { - // AMD - define( 'unidragger/unidragger',[ - 'unipointer/unipointer' - ], function( Unipointer ) { - return factory( window, Unipointer ); - }); - } else if ( typeof module == 'object' && module.exports ) { - // CommonJS - module.exports = factory( - window, - require('unipointer') - ); - } else { - // browser global - window.Unidragger = factory( - window, - window.Unipointer - ); - } - -}( window, function factory( window, Unipointer ) { - - - -// ----- ----- // - -function noop() {} - -// -------------------------- Unidragger -------------------------- // - -function Unidragger() {} - -// inherit Unipointer & EvEmitter -var proto = Unidragger.prototype = Object.create( Unipointer.prototype ); - -// ----- bind start ----- // - -proto.bindHandles = function() { - this._bindHandles( true ); -}; - -proto.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 - */ -proto._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 = noop; - } - // bind each handle - var bindMethod = isBind ? 'addEventListener' : 'removeEventListener'; - for ( var i=0; i < this.handles.length; i++ ) { - var handle = this.handles[i]; - this._bindStartEvent( handle, isBind ); - binderExtra( handle ); - handle[ bindMethod ]( 'click', this ); - } -}; - -// ----- start event ----- // - -/** - * pointer start - * @param {Event} event - * @param {Event or Touch} pointer - */ -proto.pointerDown = function( event, pointer ) { - // dismiss range sliders - if ( event.target.nodeName == 'INPUT' && event.target.type == 'range' ) { - // reset pointerDown logic - this.isPointerDown = false; - delete this.pointerIdentifier; - return; - } - - 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 -proto._dragPointerDown = function( event, pointer ) { - // track to see when dragging starts - this.pointerDownPoint = Unipointer.getPointerPoint( pointer ); - - var canPreventDefault = this.canPreventDefaultOnPointerDown( event, pointer ); - if ( canPreventDefault ) { - event.preventDefault(); - } -}; - -// overwriteable method so Flickity can prevent for scrolling -proto.canPreventDefaultOnPointerDown = function( event ) { - // prevent default, unless touchstart or s and