/** * PreloadJS * Visit http://createjs.com/ for documentation, updates and examples. * * Copyright (c) 2011 gskinner.com, inc. * * Distributed under the terms of the MIT license. * http://www.opensource.org/licenses/mit-license.html * * This notice shall be included in all copies or substantial portions of the Software. **/(function(g){var c=function(){this.init()};c.prototype={};var a=c.prototype;a.loaded=false;a.progress=0;a._item=null;a.onProgress=null;a.onLoadStart=null;a.onFileLoad=null;a.onFileProgress=null;a.onComplete=null;a.onError=null;a.getItem=function(){return this._item};a.init=function(){};a.load=function(){};a.cancel=function(){};a._sendLoadStart=function(){if(this.onLoadStart)this.onLoadStart({target:this})};a._sendProgress=function(a){var f;if(a instanceof Number)this.progress=a,f={loaded:this.progress, total:1};else if(f=a,this.progress=a.loaded/a.total,isNaN(this.progress)||this.progress==Infinity)this.progress=0;f.target=this;if(this.onProgress)this.onProgress(f)};a._sendFileProgress=function(a){if(this.onFileProgress)a.target=this,this.onFileProgress(a)};a._sendComplete=function(){if(this.onComplete)this.onComplete({target:this})};a._sendFileComplete=function(a){if(this.onFileLoad)a.target=this,this.onFileLoad(a)};a._sendError=function(a){if(this.onError)a==null&&(a={}),a.target=this,this.onError(a)}; a.toString=function(){return"[PreloadJS AbstractLoader]"};g.AbstractLoader=c})(window);(function(g){function c(){}var a=function(a){this.initialize(a)},b=a.prototype=new AbstractLoader;a.IMAGE="image";a.SOUND="sound";a.JSON="json";a.JAVASCRIPT="javascript";a.CSS="css";a.XML="xml";a.TEXT="text";a.TIMEOUT_TIME=8E3;b.useXHR=true;b.stopOnError=false;b.maintainScriptOrder=true;b.next=null;b.typeHandlers=null;b.extensionHandlers=null;b._maxConnections=1;b._currentLoads=null;b._loadQueue=null;b._loadedItemsById=null;b._loadedItemsBySrc=null;b._targetProgress=0;b._numItems=0;b._numItemsLoaded= null;b._scriptOrder=null;b._loadedScripts=null;b.TAG_LOAD_OGGS=true;b.initialize=function(a){this._targetProgress=this._numItemsLoaded=this._numItems=0;this._paused=false;this._currentLoads=[];this._loadQueue=[];this._scriptOrder=[];this._loadedScripts=[];this._loadedItemsById={};this._loadedItemsBySrc={};this.typeHandlers={};this.extensionHandlers={};this.useXHR=a!=false&&g.XMLHttpRequest!=null;this.determineCapabilities()};b.determineCapabilities=function(){var f=a.lib.BrowserDetect;if(f!=null)a.TAG_LOAD_OGGS= f.isFirefox||f.isOpera};a.isBinary=function(f){switch(f){case a.IMAGE:case a.SOUND:return true;default:return false}};b.installPlugin=function(a){if(!(a==null||a.getPreloadHandlers==null)){a=a.getPreloadHandlers();if(a.types!=null)for(var b=0,d=a.types.length;b0){for(var d=0,c=0,g=this._currentLoads.length;c -1;c.isOpera=g.opera!=null;c.isIOS=a.indexOf("iPod")>-1||a.indexOf("iPhone")>-1||a.indexOf("iPad")>-1};c.init();a.lib.BrowserDetect=c})(window);(function(){var g=function(a,b,c){this.init(a,b,c)},c=g.prototype=new AbstractLoader;c._srcAttr=null;c._loadTimeOutTimeout=null;c.tagCompleteProxy=null;c.init=function(a,b,c){this._item=a;this._srcAttr=b||"src";this._useXHR=c==true;this.isAudio=a.tag instanceof HTMLAudioElement;this.tagCompleteProxy=PreloadJS.proxy(this._handleTagLoad,this)};c.cancel=function(){this._clean();var a=this.getItem();if(a!=null)a.src=null};c.load=function(){this._useXHR?this.loadXHR():this.loadTag()};c.loadXHR=function(){var a= this.getItem(),a=new PreloadJS.lib.XHRLoader(a);a.onProgress=PreloadJS.proxy(this._handleProgress,this);a.onFileLoad=PreloadJS.proxy(this._handleXHRComplete,this);a.onFileError=PreloadJS.proxy(this._handleLoadError,this);a.load()};c._handleXHRComplete=function(a){this._clean();var b=a.getItem();a.getResult();b.type==PreloadJS.IMAGE?(b.tag.onload=PreloadJS.proxy(this._sendComplete,this),b.tag.src=b.src):(b.tag[this._srcAttr]=b.src,this._sendComplete())};c._handleLoadError=function(a){this._clean(); this._sendError(a)};c.loadTag=function(){var a=this.getItem(),b=a.tag;clearTimeout(this._loadTimeOutTimeout);this._loadTimeOutTimeout=setTimeout(PreloadJS.proxy(this._handleLoadTimeOut,this),PreloadJS.TIMEOUT_TIME);if(this.isAudio)b.src=null,b.preload="auto",b.setAttribute("data-temp","true");b.onerror=PreloadJS.proxy(this._handleLoadError,this);b.onprogress=PreloadJS.proxy(this._handleProgress,this);this.isAudio?(b.onstalled=PreloadJS.proxy(this._handleStalled,this),b.addEventListener("canplaythrough", this.tagCompleteProxy)):b.onload=PreloadJS.proxy(this._handleTagLoad,this);b[this._srcAttr]=a.src;a=a.type==PreloadJS.SOUND&&a.ext=="ogg"&&PreloadJS.lib.BrowserDetect.isFirefox;b.load!=null&&!a&&b.load()};c._handleLoadTimeOut=function(){this._clean();this._sendError()};c._handleStalled=function(){};c._handleLoadError=function(){this._clean();this._sendError()};c._handleTagLoad=function(){var a=this.getItem().tag;clearTimeout(this._loadTimeOutTimeout);if(!(this.isAudio&&a.readyState!==4)&&!this.loaded)this.loaded= true,this._clean(),this._sendComplete()};c._clean=function(){clearTimeout(this._loadTimeOutTimeout);var a=this.getItem().tag;a.onload=null;a.removeEventListener("canplaythrough",this.tagCompleteProxy);a.onstalled=null;a.onprogress=null;a.onerror=null};c._handleProgress=function(a){clearTimeout(this._loadTimeOutTimeout);if(this.isAudio){a=this.getItem();if(a.buffered==null)return;a={loaded:a.buffered.length>0?a.buffered.end(0):0,total:a.duration}}this._sendProgress(a)};c.toString=function(){return"[PreloadJS TagLoader]"}; PreloadJS.lib.TagLoader=g})(window);(function(g){var c=function(a){this.init(a)},a=c.prototype=new AbstractLoader;a._wasLoaded=false;a._request=null;a._loadTimeOutTimeout=null;a._xhrLevel=null;a.init=function(a){this._item=a;this._createXHR(a)};a.getResult=function(){try{return this._request.responseText}catch(a){}return this._request.response};a.cancel=function(){this._clean();this._request.abort()};a.load=function(){if(this._request==null)this.handleError();else{if(this._xhrLevel==1)this._loadTimeOutTimeout=setTimeout(PreloadJS.proxy(this.handleTimeout, this),PreloadJS.TIMEOUT_TIME);this._request.onloadstart=PreloadJS.proxy(this.handleLoadStart,this);this._request.onprogress=PreloadJS.proxy(this.handleProgress,this);this._request.onabort=PreloadJS.proxy(this.handleAbort,this);this._request.onerror=PreloadJS.proxy(this.handleError,this);this._request.ontimeout=PreloadJS.proxy(this.handleTimeout,this);this._request.onload=PreloadJS.proxy(this.handleLoad,this);this._request.onreadystatechange=PreloadJS.proxy(this.handleReadyStateChange,this);try{this._request.send()}catch(a){}}}; a.handleProgress=function(a){a.loaded>0&&a.total==0||this._sendProgress({loaded:a.loaded,total:a.total})};a.handleLoadStart=function(){clearTimeout(this._loadTimeOutTimeout);this._sendLoadStart()};a.handleAbort=function(){this._clean();this._sendError()};a.handleError=function(){this._clean();this._sendError()};a.handleReadyStateChange=function(){this._request.readyState==4&&this.handleLoad()};a._checkError=function(){switch(parseInt(this._request.status)){case 404:case 0:return false}if(this._request.response== null){try{if(this._request.responseXML!=null)return true}catch(a){}return false}return true};a.handleLoad=function(){if(!this.loaded)this.loaded=true,this._checkError()?(this._clean(),this._sendComplete()):this.handleError()};a.handleTimeout=function(){this._clean();this._sendError()};a.handleLoadEnd=function(){this._clean()};a._createXHR=function(a){this._xhrLevel=1;if(g.ArrayBuffer)this._xhrLevel=2;if(g.XMLHttpRequest)this._request=new XMLHttpRequest;else try{this._request=new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(c){return null}a.type== PreloadJS.TEXT&&this._request.overrideMimeType("text/plain; charset=x-user-defined");this._request.open("GET",a.src,true);if(PreloadJS.isBinary(a.type))this._request.responseType="arraybuffer";return true};a._clean=function(){clearTimeout(this._loadTimeOutTimeout);var a=this._request;a.onloadstart=null;a.onprogress=null;a.onabort=null;a.onerror=null;a.onload=null;a.ontimeout=null;a.onloadend=null;a.onreadystatechange=null;clearInterval(this._checkLoadInterval)};a.toString=function(){return"[PreloadJS XHRLoader]"}; PreloadJS.lib.XHRLoader=c})(window);