Interactive interface for browsing global, full-resolution satellite imagery
Load delay for all ajax calls, debug is now only loaded as needed, faster startup times by delaying add layers rendering
Mike McGannc88b870dda7c
diff --git a/Gruntfile.js b/Gruntfile.jsindex 106aaf9cc..a146025a1 100644--- a/Gruntfile.js+++ b/Gruntfile.js@@ -308,8 +308,12 @@ module.exports = function(grunt) {concat: {// Combine all the Worldview JavaScript files into one file.wv_js: {- src: wvJs,- dest: "build/<%=pkg%>-debug/web/js/wv.js"+ src: wvJs["wv.js"],+ dest: "build/<%=pkg%>-debug/web/js/wv.js",+ },+ wv_debug_js: {+ src: wvJs["wv.debug.js"],+ dest: "build/<%=pkg%>-debug/web/js/wv.debug.js"},// Combine all the Worldview CSS files into one file.wv_css: {@@ -327,6 +331,9 @@ module.exports = function(grunt) {files: {"build/<%=pkg%>/web/js/wv.js": ["build/<%=pkg%>-debug/web/js/wv.js"+ ],+ "build/<%=pkg%>/web/js/wv.debug.js": [+ "build/<%=pkg%>-debug/web/js/wv.debug.js"]}}@@ -416,6 +423,7 @@ module.exports = function(grunt) {"build/<%=pkg%>-debug/web/**/*.js","!build/<%=pkg%>-debug/web/css/wv.css","!build/<%=pkg%>-debug/web/js/wv.js",+ "!build/<%=pkg%>-debug/web/js/wv.debug.js","!build/<%=pkg%>-debug/web/css/bulkDownload.css","!build/<%=pkg%>-debug/web/js/map/wv.map.tileworker.js","!build/<%=pkg%>-debug/web/ext/**/*"diff --git a/etc/deploy/wv.js.json b/etc/deploy/wv.js.jsonindex a869b50ab..80e6e2abd 100644--- a/etc/deploy/wv.js.json+++ b/etc/deploy/wv.js.json@@ -1,57 +1,61 @@-[- "src/js/wv.brand.js",-- "src/js/util/wv.util.browser.js",- "src/js/util/wv.util.js",- "src/js/util/wv.util.events.js",-- "src/js/ui/wv.ui.js",- "src/js/ui/wv.ui.indicator.js",- "src/js/ui/wv.ui.info.js",-- "src/js/proj/wv.proj.js",- "src/js/proj/wv.proj.change.js",- "src/js/proj/wv.proj.model.js",- "src/js/proj/wv.proj.ui.js",-- "src/js/date/wv.date.js",- "src/js/date/wv.date.model.js",- "src/js/date/wv.date.sliders.js",- "src/js/date/wv.date.label.js",- "src/js/date/wv.date.timeline.js",-- "src/js/layers/wv.layers.js",- "src/js/layers/wv.layers.model.js",- "src/js/layers/wv.layers.sidebar.js",- "src/js/layers/wv.layers.active.js",- "src/js/layers/wv.layers.add.js",- "src/js/layers/wv.layers.options.js",-- "src/js/image/wv.image.rubberband.js",- "src/js/image/wv.image.panel.js",-- "src/js/palettes/wv.palettes.js",- "src/js/palettes/wv.palettes.legend.js",- "src/js/palettes/wv.palettes.model.js",-- "src/js/data/wv.data.js",- "src/js/data/wv.data.echo.js",- "src/js/data/wv.data.handler.js",- "src/js/data/wv.data.layers.js",- "src/js/data/wv.data.map.js",- "src/js/data/wv.data.model.js",- "src/js/data/wv.data.results.js",- "src/js/data/wv.data.ui.js",-- "src/js/map/wv.map.js",- "src/js/map/wv.map.model.js",- "src/js/map/wv.map.palette.js",- "src/js/map/wv.map.ui.js",-- "src/js/link/wv.link.model.js",- "src/js/link/wv.link.ui.js",-- "src/js/wv.debug.js",- "src/js/wv.tour.js",- "src/js/wv.main.js"-]+{+ "wv.js": [+ "src/js/wv.brand.js",++ "src/js/util/wv.util.browser.js",+ "src/js/util/wv.util.js",+ "src/js/util/wv.util.events.js",++ "src/js/ui/wv.ui.js",+ "src/js/ui/wv.ui.indicator.js",+ "src/js/ui/wv.ui.info.js",++ "src/js/proj/wv.proj.js",+ "src/js/proj/wv.proj.change.js",+ "src/js/proj/wv.proj.model.js",+ "src/js/proj/wv.proj.ui.js",++ "src/js/date/wv.date.js",+ "src/js/date/wv.date.model.js",+ "src/js/date/wv.date.sliders.js",+ "src/js/date/wv.date.label.js",+ "src/js/date/wv.date.timeline.js",++ "src/js/layers/wv.layers.js",+ "src/js/layers/wv.layers.model.js",+ "src/js/layers/wv.layers.sidebar.js",+ "src/js/layers/wv.layers.active.js",+ "src/js/layers/wv.layers.add.js",+ "src/js/layers/wv.layers.options.js",++ "src/js/image/wv.image.rubberband.js",+ "src/js/image/wv.image.panel.js",++ "src/js/palettes/wv.palettes.js",+ "src/js/palettes/wv.palettes.legend.js",+ "src/js/palettes/wv.palettes.model.js",++ "src/js/data/wv.data.js",+ "src/js/data/wv.data.echo.js",+ "src/js/data/wv.data.handler.js",+ "src/js/data/wv.data.layers.js",+ "src/js/data/wv.data.map.js",+ "src/js/data/wv.data.model.js",+ "src/js/data/wv.data.results.js",+ "src/js/data/wv.data.ui.js",++ "src/js/map/wv.map.js",+ "src/js/map/wv.map.model.js",+ "src/js/map/wv.map.palette.js",+ "src/js/map/wv.map.ui.js",++ "src/js/link/wv.link.model.js",+ "src/js/link/wv.link.ui.js",++ "src/js/wv.tour.js",+ "src/js/wv.main.js"+ ],+ "wv.debug.js": [+ "src/js/wv.debug.js"+ ]+}diff --git a/src/ext/main/yepnope-1.5.4/yepnope.js b/src/ext/main/yepnope-1.5.4/yepnope.jsnew file mode 100644index 000000000..fab179010--- /dev/null+++ b/src/ext/main/yepnope-1.5.4/yepnope.js@@ -0,0 +1,562 @@+// yepnope.js+// Version - 1.5.4pre+//+// by+// Alex Sexton - @SlexAxton - AlexSexton[at]gmail.com+// Ralph Holzmann - @ralphholzmann - ralphholzmann[at]gmail.com+//+// http://yepnopejs.com/+// https://github.com/SlexAxton/yepnope.js/+//+// Tri-license - WTFPL | MIT | BSD+//+// Please minify before use.+// Also available as Modernizr.load via the Modernizr Project+//+( function ( window, doc, undef ) {++var docElement = doc.documentElement,+ sTimeout = window.setTimeout,+ firstScript = doc.getElementsByTagName( "script" )[ 0 ],+ toString = {}.toString,+ execStack = [],+ started = 0,+ noop = function () {},+ // Before you get mad about browser sniffs, please read:+ // https://github.com/Modernizr/Modernizr/wiki/Undetectables+ // If you have a better solution, we are actively looking to solve the problem+ isGecko = ( "MozAppearance" in docElement.style ),+ isGeckoLTE18 = isGecko && !! doc.createRange().compareNode,+ insBeforeObj = isGeckoLTE18 ? docElement : firstScript.parentNode,+ // Thanks to @jdalton for showing us this opera detection (by way of @kangax) (and probably @miketaylr too, or whatever...)+ isOpera = window.opera && toString.call( window.opera ) == "[object Opera]",+ isIE = !! doc.attachEvent && !isOpera,+ strJsElem = isGecko ? "object" : isIE ? "script" : "img",+ strCssElem = isIE ? "script" : strJsElem,+ isArray = Array.isArray || function ( obj ) {+ return toString.call( obj ) == "[object Array]";+ },+ isObject = function ( obj ) {+ return Object(obj) === obj;+ },+ isString = function ( s ) {+ return typeof s == "string";+ },+ isFunction = function ( fn ) {+ return toString.call( fn ) == "[object Function]";+ },+ globalFilters = [],+ scriptCache = {},+ prefixes = {+ // key value pair timeout options+ timeout : function( resourceObj, prefix_parts ) {+ if ( prefix_parts.length ) {+ resourceObj['timeout'] = prefix_parts[ 0 ];+ }+ return resourceObj;+ }+ },+ handler,+ yepnope;++ /* Loader helper functions */+ function isFileReady ( readyState ) {+ // Check to see if any of the ways a file can be ready are available as properties on the file's element+ return ( ! readyState || readyState == "loaded" || readyState == "complete" || readyState == "uninitialized" );+ }+++ // Takes a preloaded js obj (changes in different browsers) and injects it into the head+ // in the appropriate order+ function injectJs ( src, cb, attrs, timeout, /* internal use */ err, internal ) {+ var script = doc.createElement( "script" ),+ done, i;++ timeout = timeout || yepnope['errorTimeout'];++ script.src = src;++ // Add our extra attributes to the script element+ for ( i in attrs ) {+ script.setAttribute( i, attrs[ i ] );+ }++ cb = internal ? executeStack : ( cb || noop );++ // Bind to load events+ script.onreadystatechange = script.onload = function () {++ if ( ! done && isFileReady( script.readyState ) ) {++ // Set done to prevent this function from being called twice.+ done = 1;+ cb();++ // Handle memory leak in IE+ script.onload = script.onreadystatechange = null;+ }+ };++ // 404 Fallback+ sTimeout(function () {+ if ( ! done ) {+ done = 1;+ // Might as well pass in an error-state if we fire the 404 fallback+ cb(1);+ }+ }, timeout );++ // Inject script into to document+ // or immediately callback if we know there+ // was previously a timeout error+ err ? script.onload() : firstScript.parentNode.insertBefore( script, firstScript );+ }++ // Takes a preloaded css obj (changes in different browsers) and injects it into the head+ function injectCss ( href, cb, attrs, timeout, /* Internal use */ err, internal ) {++ // Create stylesheet link+ var link = doc.createElement( "link" ),+ done, i;++ timeout = timeout || yepnope['errorTimeout'];++ cb = internal ? executeStack : ( cb || noop );++ // Add attributes+ link.href = href;+ link.rel = "stylesheet";+ link.type = "text/css";++ // Add our extra attributes to the link element+ for ( i in attrs ) {+ link.setAttribute( i, attrs[ i ] );+ }++ if ( ! err ) {+ firstScript.parentNode.insertBefore( link, firstScript );+ sTimeout(cb, 0);+ }+ }++ function executeStack ( ) {+ // shift an element off of the stack+ var i = execStack.shift();+ started = 1;++ // if a is truthy and the first item in the stack has an src+ if ( i ) {+ // if it's a script, inject it into the head with no type attribute+ if ( i['t'] ) {+ // Inject after a timeout so FF has time to be a jerk about it and+ // not double load (ignore the cache)+ sTimeout( function () {+ (i['t'] == "c" ? yepnope['injectCss'] : yepnope['injectJs'])( i['s'], 0, i['a'], i['x'], i['e'], 1 );+ }, 0 );+ }+ // Otherwise, just call the function and potentially run the stack+ else {+ i();+ executeStack();+ }+ }+ else {+ // just reset out of recursive mode+ started = 0;+ }+ }++ function preloadFile ( elem, url, type, splicePoint, dontExec, attrObj, timeout ) {++ timeout = timeout || yepnope['errorTimeout'];++ // Create appropriate element for browser and type+ var preloadElem = doc.createElement( elem ),+ done = 0,+ firstFlag = 0,+ stackObject = {+ "t": type, // type+ "s": url, // src+ //r: 0, // ready+ "e": dontExec,// set to true if we don't want to reinject+ "a": attrObj,+ "x": timeout+ };++ // The first time (common-case)+ if ( scriptCache[ url ] === 1 ) {+ firstFlag = 1;+ scriptCache[ url ] = [];+ }++ function onload ( first ) {+ // If the script/css file is loaded+ if ( ! done && isFileReady( preloadElem.readyState ) ) {++ // Set done to prevent this function from being called twice.+ stackObject['r'] = done = 1;++ ! started && executeStack();++ // Handle memory leak in IE+ preloadElem.onload = preloadElem.onreadystatechange = null;+ if ( first ) {+ if ( elem != "img" ) {+ sTimeout(function(){ insBeforeObj.removeChild( preloadElem ) }, 50);+ }++ for ( var i in scriptCache[ url ] ) {+ if ( scriptCache[ url ].hasOwnProperty( i ) ) {+ scriptCache[ url ][ i ].onload();+ }+ }+ }+ }+ }+++ // Setting url to data for objects or src for img/scripts+ if ( elem == "object" ) {+ preloadElem.data = url;+ } else {+ preloadElem.src = url;++ // Setting bogus script type to allow the script to be cached+ preloadElem.type = elem;+ }++ // Don't let it show up visually+ preloadElem.width = preloadElem.height = "0";++ // Attach handlers for all browsers+ preloadElem.onerror = preloadElem.onload = preloadElem.onreadystatechange = function(){+ onload.call(this, firstFlag);+ };+ // inject the element into the stack depending on if it's+ // in the middle of other scripts or not+ execStack.splice( splicePoint, 0, stackObject );++ // The only place these can't go is in the <head> element, since objects won't load in there+ // so we have two options - insert before the head element (which is hard to assume) - or+ // insertBefore technically takes null/undefined as a second param and it will insert the element into+ // the parent last. We try the head, and it automatically falls back to undefined.+ if ( elem != "img" ) {+ // If it's the first time, or we've already loaded it all the way through+ if ( firstFlag || scriptCache[ url ] === 2 ) {+ insBeforeObj.insertBefore( preloadElem, isGeckoLTE18 ? null : firstScript );++ // If something fails, and onerror doesn't fire,+ // continue after a timeout.+ sTimeout( onload, timeout );+ }+ else {+ // instead of injecting, just hold on to it+ scriptCache[ url ].push( preloadElem );+ }+ }+ }++ function load ( resource, type, dontExec, attrObj, timeout ) {+ // If this method gets hit multiple times, we should flag+ // that the execution of other threads should halt.+ started = 0;++ // We'll do 'j' for js and 'c' for css, yay for unreadable minification tactics+ type = type || "j";+ if ( isString( resource ) ) {+ // if the resource passed in here is a string, preload the file+ preloadFile( type == "c" ? strCssElem : strJsElem, resource, type, this['i']++, dontExec, attrObj, timeout );+ } else {+ // Otherwise it's a callback function and we can splice it into the stack to run+ execStack.splice( this['i']++, 0, resource );+ execStack.length == 1 && executeStack();+ }++ // OMG is this jQueries? For chaining...+ return this;+ }++ // return the yepnope object with a fresh loader attached+ function getYepnope () {+ var y = yepnope;+ y['loader'] = {+ "load": load,+ "i" : 0+ };+ return y;+ }++ /* End loader helper functions */+ // Yepnope Function+ yepnope = function ( needs ) {++ var i,+ need,+ // start the chain as a plain instance+ chain = this['yepnope']['loader'];++ function satisfyPrefixes ( url ) {+ // split all prefixes out+ var parts = url.split( "!" ),+ gLen = globalFilters.length,+ origUrl = parts.pop(),+ pLen = parts.length,+ res = {+ "url" : origUrl,+ // keep this one static for callback variable consistency+ "origUrl" : origUrl,+ "prefixes" : parts+ },+ mFunc,+ j,+ prefix_parts;++ // loop through prefixes+ // if there are none, this automatically gets skipped+ for ( j = 0; j < pLen; j++ ) {+ prefix_parts = parts[ j ].split( '=' );+ mFunc = prefixes[ prefix_parts.shift() ];+ if ( mFunc ) {+ res = mFunc( res, prefix_parts );+ }+ }++ // Go through our global filters+ for ( j = 0; j < gLen; j++ ) {+ res = globalFilters[ j ]( res );+ }++ // return the final url+ return res;+ }++ function getExtension ( url ) {+ return url.split(".").pop().split("?").shift();+ }++ function loadScriptOrStyle ( input, callback, chain, index, testResult ) {+ // run through our set of prefixes+ var resource = satisfyPrefixes( input ),+ autoCallback = resource['autoCallback'],+ extension = getExtension( resource['url'] );++ // if no object is returned or the url is empty/0 just exit the load+ if ( resource['bypass'] ) {+ return;+ }++ // Determine callback, if any+ if ( callback ) {+ callback = isFunction( callback ) ?+ callback :+ callback[ input ] ||+ callback[ index ] ||+ callback[ ( input.split( "/" ).pop().split( "?" )[ 0 ] ) ];+ }++ // if someone is overriding all normal functionality+ if ( resource['instead'] ) {+ return resource['instead']( input, callback, chain, index, testResult );+ }+ else {+ // Handle if we've already had this url and it's completed loaded already+ if ( scriptCache[ resource['url'] ] ) {+ // don't let this execute again+ resource['noexec'] = true;+ }+ else {+ scriptCache[ resource['url'] ] = 1;+ }++ // Throw this into the queue+ chain.load( resource['url'], ( ( resource['forceCSS'] || ( ! resource['forceJS'] && "css" == getExtension( resource['url'] ) ) ) ) ? "c" : undef, resource['noexec'], resource['attrs'], resource['timeout'] );++ // If we have a callback, we'll start the chain over+ if ( isFunction( callback ) || isFunction( autoCallback ) ) {+ // Call getJS with our current stack of things+ chain['load']( function () {+ // Hijack yepnope and restart index counter+ getYepnope();+ // Call our callbacks with this set of data+ callback && callback( resource['origUrl'], testResult, index );+ autoCallback && autoCallback( resource['origUrl'], testResult, index );++ // Override this to just a boolean positive+ scriptCache[ resource['url'] ] = 2;+ } );+ }+ }+ }++ function loadFromTestObject ( testObject, chain ) {+ var testResult = !! testObject['test'],+ group = testResult ? testObject['yep'] : testObject['nope'],+ always = testObject['load'] || testObject['both'],+ callback = testObject['callback'] || noop,+ cbRef = callback,+ complete = testObject['complete'] || noop,+ needGroupSize,+ callbackKey;++ // Reusable function for dealing with the different input types+ // NOTE:: relies on closures to keep 'chain' up to date, a bit confusing, but+ // much smaller than the functional equivalent in this case.+ function handleGroup ( needGroup, moreToCome ) {+ if ( ! needGroup ) {+ // Call the complete callback when there's nothing to load.+ ! moreToCome && complete();+ }+ // If it's a string+ else if ( isString( needGroup ) ) {+ // if it's a string, it's the last+ if ( !moreToCome ) {+ // Add in the complete callback to go at the end+ callback = function () {+ var args = [].slice.call( arguments );+ cbRef.apply( this, args );+ complete();+ };+ }+ // Just load the script of style+ loadScriptOrStyle( needGroup, callback, chain, 0, testResult );+ }+ // See if we have an object. Doesn't matter if it's an array or a key/val hash+ // Note:: order cannot be guaranteed on an key value object with multiple elements+ // since the for-in does not preserve order. Arrays _should_ go in order though.+ else if ( isObject( needGroup ) ) {+ // I hate this, but idk another way for objects.+ needGroupSize = (function(){+ var count = 0, i+ for (i in needGroup ) {+ if ( needGroup.hasOwnProperty( i ) ) {+ count++;+ }+ }+ return count;+ })();++ for ( callbackKey in needGroup ) {+ // Safari 2 does not have hasOwnProperty, but not worth the bytes for a shim+ // patch if needed. Kangax has a nice shim for it. Or just remove the check+ // and promise not to extend the object prototype.+ if ( needGroup.hasOwnProperty( callbackKey ) ) {+ // Find the last added resource, and append to it's callback.+ if ( ! moreToCome && ! ( --needGroupSize ) ) {+ // If this is an object full of callbacks+ if ( ! isFunction( callback ) ) {+ // Add in the complete callback to go at the end+ callback[ callbackKey ] = (function( innerCb ) {+ return function () {+ var args = [].slice.call( arguments );+ innerCb && innerCb.apply( this, args );+ complete();+ };+ })( cbRef[ callbackKey ] );+ }+ // If this is just a single callback+ else {+ callback = function () {+ var args = [].slice.call( arguments );+ cbRef.apply( this, args );+ complete();+ };+ }+ }+ loadScriptOrStyle( needGroup[ callbackKey ], callback, chain, callbackKey, testResult );+ }+ }+ }+ }++ // figure out what this group should do+ handleGroup( group, !!always );++ // Run our loader on the load/both group too+ // the always stuff always loads second.+ always && handleGroup( always );+ }++ // Someone just decides to load a single script or css file as a string+ if ( isString( needs ) ) {+ loadScriptOrStyle( needs, 0, chain, 0 );+ }+ // Normal case is likely an array of different types of loading options+ else if ( isArray( needs ) ) {+ // go through the list of needs+ for( i = 0; i < needs.length; i++ ) {+ need = needs[ i ];++ // if it's a string, just load it+ if ( isString( need ) ) {+ loadScriptOrStyle( need, 0, chain, 0 );+ }+ // if it's an array, call our function recursively+ else if ( isArray( need ) ) {+ yepnope( need );+ }+ // if it's an object, use our modernizr logic to win+ else if ( isObject( need ) ) {+ loadFromTestObject( need, chain );+ }+ }+ }+ // Allow a single object to be passed in+ else if ( isObject( needs ) ) {+ loadFromTestObject( needs, chain );+ }+ };++ // This publicly exposed function is for allowing+ // you to add functionality based on prefixes on the+ // string files you add. 'css!' is a builtin prefix+ //+ // The arguments are the prefix (not including the !) as a string+ // and+ // A callback function. This function is passed a resource object+ // that can be manipulated and then returned. (like middleware. har.)+ //+ // Examples of this can be seen in the officially supported ie prefix+ yepnope['addPrefix'] = function ( prefix, callback ) {+ prefixes[ prefix ] = callback;+ };++ // A filter is a global function that every resource+ // object that passes through yepnope will see. You can+ // of course conditionally choose to modify the resource objects+ // or just pass them along. The filter function takes the resource+ // object and is expected to return one.+ //+ // The best example of a filter is the 'autoprotocol' officially+ // supported filter+ yepnope['addFilter'] = function ( filter ) {+ globalFilters.push( filter );+ };++ // Default error timeout to 10sec - modify to alter+ yepnope['errorTimeout'] = 1e4;++ // Webreflection readystate hack+ // safe for jQuery 1.4+ ( i.e. don't use yepnope with jQuery 1.3.2 )+ // if the readyState is null and we have a listener+ if ( doc.readyState == null && doc.addEventListener ) {+ // set the ready state to loading+ doc.readyState = "loading";+ // call the listener+ doc.addEventListener( "DOMContentLoaded", handler = function () {+ // Remove the listener+ doc.removeEventListener( "DOMContentLoaded", handler, 0 );+ // Set it to ready+ doc.readyState = "complete";+ }, 0 );+ }++ // Attach loader &+ // Leak it+ window['yepnope'] = getYepnope();++ // Exposing executeStack to better facilitate plugins+ window['yepnope']['executeStack'] = executeStack;+ window['yepnope']['injectJs'] = injectJs;+ window['yepnope']['injectCss'] = injectCss;++})( this, document );diff --git a/src/ext/main/yepnope-1.5.4/yepnope.min.js b/src/ext/main/yepnope-1.5.4/yepnope.min.jsnew file mode 100644index 000000000..73655a5b2--- /dev/null+++ b/src/ext/main/yepnope-1.5.4/yepnope.min.js@@ -0,0 +1,2 @@+/*yepnope1.5.x|WTFPL*/+(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}})(this,document);\ No newline at end of filediff --git a/src/index.html b/src/index.htmlindex 5cedc2d8b..f0e788aea 100644--- a/src/index.html+++ b/src/index.html@@ -92,6 +92,9 @@<!-- External libraries =============================================== -->+ <!-- link.dev --> <script type="text/javascript" src="ext/main/yepnope-1.5.4/yepnope.js"></script>+ <!-- link.prod --> <!-- <script type="text/javascript" src="ext/main/yepnope-1.5.4/yepnope.min.js"></script> -->+<!-- link.dev --> <script type="text/javascript" src="ext/main/lodash-2.4.1/lodash.js"></script><!-- link.prod --> <!-- <script type="text/javascript" src="ext/main/lodash-2.4.1/lodash.min.js"></script> -->@@ -188,7 +191,6 @@<!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.model.js"></script><!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.ui.js"></script>- <!-- link.dev --> <script type="text/javascript" src="js/wv.debug.js"></script><!-- link.dev --> <script type="text/javascript" src="js/wv.tour.js"></script><!-- link.dev --> <script type="text/javascript" src="js/wv.main.js"></script></head>diff --git a/src/js/layers/wv.layers.add.js b/src/js/layers/wv.layers.add.jsindex f68c21092..d319b7d3e 100644--- a/src/js/layers/wv.layers.add.js+++ b/src/js/layers/wv.layers.add.js@@ -35,7 +35,6 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {visible[layer.id] = true;});- render();$(window).resize(resize);model.events@@ -47,8 +46,14 @@ wv.layers.add = wv.layers.add || function(models, ui, config) {resize();}});- filter();- resize();+ // Rendering all the layers can take a half second or so. Place+ // in a timeout to make startup look fast. This should all be+ // replaced in the next version.+ setTimeout(function() {+ render();+ filter();+ resize();+ }, 1);};var render = function() {diff --git a/src/js/wv.debug.js b/src/js/wv.debug.jsindex 3227606f0..bf52ac35a 100644--- a/src/js/wv.debug.js+++ b/src/js/wv.debug.js@@ -15,17 +15,53 @@var wv = wv || {};wv.debug = wv.debug || (function() {+ var parameters = wv.util.fromQueryString(location.search);var self = {};- self.loadDelay = function(configURI, parameters) {- var delay = parseInt(parameters.loadDelay);- promise = $.Deferred();- $.getJSON(configURI).done(function(data) {- setTimeout(function() {- promise.resolve(data);- }, delay);- });- return promise;+ var init = function() {+ if ( parameters.loadDelay ) {+ loadDelay();+ }+ };++ var loadDelay = function() {+ var delay;+ try {+ delay = parseInt(parameters.loadDelay);+ } catch ( error ) {+ console.warn("Invalid load delay: " + delay);+ return;+ }++ var ajax = $.ajax;+ $.ajax = function() {+ var ajaxArgs = arguments;+ console.log("delay", ajaxArgs);+ var jqXHR = ajax.apply($, arguments);+ var done = jqXHR.done;+ jqXHR.done = function(fn) {+ done(function() {+ var args = arguments;+ setTimeout(function() {+ fn.apply(jqXHR, args);+ }, delay);+ });+ return jqXHR;+ };+ jqXHR.done(function() { console.log("done", ajaxArgs); });+ var fail = jqXHR.fail;+ jqXHR.fail = function(fn) {+ fail(function() {+ var args = arguments;+ setTimeout(function() {+ fn.apply(jqXHR, args);+ }, delay);+ });+ return jqXHR;+ };+ jqXHR.fail(function() { console.log("fail", ajaxArgs); });+ return jqXHR;+ }};self.error = function(parameters) {@@ -34,6 +70,7 @@ wv.debug = wv.debug || (function() {}};+ init();return self;})();diff --git a/src/js/wv.main.js b/src/js/wv.main.jsindex c619fcf3e..712dda056 100644--- a/src/js/wv.main.js+++ b/src/js/wv.main.js@@ -15,18 +15,34 @@ $(function() {var state = wv.util.fromQueryString(location.search);var parameters = wv.util.fromQueryString(location.search);var errors = [];+ var startTime;var main = function() {+ if ( parameters.elapsed ) {+ startTime = new Date().getTime();+ } else {+ elapsed = function() {};+ }+ elapsed("start");+ yepnope({+ test: parameters.debug,+ yep: ['js/wv.debug.js'],+ complete: loadConfig+ });+ }++ var loadConfig = function() {+ elapsed("loading config");var configURI = wv.brand.url("config/wv.json");- var promise = ( parameters.loadDelay ) ?- wv.debug.loadDelay(configURI, parameters) :- $.getJSON(configURI);- promise.done(wv.util.wrap(onConfigLoaded))+ var promise = $.getJSON(configURI);+ promise+ .done(wv.util.wrap(onConfigLoaded)).fail(wv.util.error);- wv.ui.indicator.delayed(promise, 2000);+ wv.ui.indicator.delayed(promise, 1000);};var onConfigLoaded = function(data) {+ elapsed("config loaded");config = data;config.parameters = parameters;@@ -66,6 +82,7 @@ $(function() {};var init = function() {+ elapsed("init");// If at the beginning of the day, wait on the previous day until GIBS// catches up (about three hours)var initialDate = wv.util.now();@@ -114,6 +131,7 @@ $(function() {models.link.load(state);models.proj.change = wv.proj.change(models);+ elapsed("ui");// Create widgetsvar ui = {};@@ -182,14 +200,15 @@ $(function() {} else {console.warn("Development version");}- wv.debug.layers(ui, models, config);+ //wv.debug.layers(ui, models, config);errorReport();- wv.debug.error(parameters);+ //wv.debug.error(parameters);ui.info = wv.ui.info(ui);models.wv.events.trigger("startup");+ elapsed("done");};var errorReport = function() {@@ -213,6 +232,11 @@ $(function() {}};+ var elapsed = function(message) {+ var t = new Date().getTime() - startTime;+ console.log(t, message);+ };+/*var debuggingFeatures = function(config) {// Install a black palette which can be used to find "holes" in