From a089699c8915636ba4f158d77dba9b012bc93208 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 4 Mar 2011 19:02:28 +0300 Subject: build custom layer of Dojo to speed up loading of tt-rss (refs #293) --- lib/dojo/_base/_loader/bootstrap.js | 604 +++++++++++++++++++++++++++++------- 1 file changed, 494 insertions(+), 110 deletions(-) (limited to 'lib/dojo/_base/_loader/bootstrap.js') diff --git a/lib/dojo/_base/_loader/bootstrap.js b/lib/dojo/_base/_loader/bootstrap.js index 7cc168e5d..3ef3012a2 100644 --- a/lib/dojo/_base/_loader/bootstrap.js +++ b/lib/dojo/_base/_loader/bootstrap.js @@ -5,116 +5,500 @@ */ -(function(){ -if(typeof this["loadFirebugConsole"]=="function"){ -this["loadFirebugConsole"](); -}else{ -this.console=this.console||{}; -var cn=["assert","count","debug","dir","dirxml","error","group","groupEnd","info","profile","profileEnd","time","timeEnd","trace","warn","log"]; -var i=0,tn; -while((tn=cn[i++])){ -if(!console[tn]){ -(function(){ -var _1=tn+""; -console[_1]=("log" in console)?function(){ -var a=Array.apply({},arguments); -a.unshift(_1+":"); -console["log"](a.join(" ")); -}:function(){ -}; -console[_1]._fake=true; -})(); -} -} -} -if(typeof dojo=="undefined"){ -dojo={_scopeName:"dojo",_scopePrefix:"",_scopePrefixArgs:"",_scopeSuffix:"",_scopeMap:{},_scopeMapRev:{}}; -} -var d=dojo; -if(typeof dijit=="undefined"){ -dijit={_scopeName:"dijit"}; -} -if(typeof dojox=="undefined"){ -dojox={_scopeName:"dojox"}; -} -if(!d._scopeArgs){ -d._scopeArgs=[dojo,dijit,dojox]; -} -d.global=this; -d.config={isDebug:false,debugAtAllCosts:false}; -if(typeof djConfig!="undefined"){ -for(var _2 in djConfig){ -d.config[_2]=djConfig[_2]; -} -} -dojo.locale=d.config.locale; -var _3="$Rev: 22487 $".match(/\d+/); -dojo.version={major:1,minor:5,patch:0,flag:"",revision:_3?+_3[0]:NaN,toString:function(){ -with(d.version){ -return major+"."+minor+"."+patch+flag+" ("+revision+")"; -} -}}; -if(typeof OpenAjax!="undefined"){ -OpenAjax.hub.registerLibrary(dojo._scopeName,"http://dojotoolkit.org",d.version.toString()); -} -var _4,_5,_6={}; -for(var i in {toString:1}){ -_4=[]; -break; -} -dojo._extraNames=_4=_4||["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"]; -_5=_4.length; -dojo._mixin=function(_7,_8){ -var _9,s,i; -for(_9 in _8){ -s=_8[_9]; -if(!(_9 in _7)||(_7[_9]!==s&&(!(_9 in _6)||_6[_9]!==s))){ -_7[_9]=s; -} -} -if(_5&&_8){ -for(i=0;i<_5;++i){ -_9=_4[i]; -s=_8[_9]; -if(!(_9 in _7)||(_7[_9]!==s&&(!(_9 in _6)||_6[_9]!==s))){ -_7[_9]=s; -} -} -} -return _7; -}; -dojo.mixin=function(_a,_b){ -if(!_a){ -_a={}; -} -for(var i=1,l=arguments.length;i` tag inclusion. This may double-request resources and + // cause problems with scripts which expect `dojo.require()` to + // preform synchronously. `debugAtAllCosts` can be an invaluable + // debugging aid, but when using it, ensure that all code which + // depends on Dojo modules is wrapped in `dojo.addOnLoad()` handlers. + // Due to the somewhat unpredictable side-effects of using + // `debugAtAllCosts`, it is strongly recommended that you enable this + // flag as a last resort. `debugAtAllCosts` has no effect when loading + // resources across domains. For usage information, see the + // [Dojo Book](http://dojotoolkit.org/book/book-dojo/part-4-meta-dojo-making-your-dojo-code-run-faster-and-better/debugging-facilities/deb) + debugAtAllCosts: false, + // locale: String + // The locale to assume for loading localized resources in this page, + // specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt). + // Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`. + // See the documentation for `dojo.i18n` and `dojo.requireLocalization` + // for details on loading localized resources. If no locale is specified, + // Dojo assumes the locale of the user agent, according to `navigator.userLanguage` + // or `navigator.language` properties. + locale: undefined, + // extraLocale: Array + // No default value. Specifies additional locales whose + // resources should also be loaded alongside the default locale when + // calls to `dojo.requireLocalization()` are processed. + extraLocale: undefined, + // baseUrl: String + // The directory in which `dojo.js` is located. Under normal + // conditions, Dojo auto-detects the correct location from which it + // was loaded. You may need to manually configure `baseUrl` in cases + // where you have renamed `dojo.js` or in which `` tags confuse + // some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned + // either the value of `djConfig.baseUrl` if one is provided or the + // auto-detected root if not. Other modules are located relative to + // this path. The path should end in a slash. + baseUrl: undefined, + // modulePaths: Object + // A map of module names to paths relative to `dojo.baseUrl`. The + // key/value pairs correspond directly to the arguments which + // `dojo.registerModulePath` accepts. Specifiying + // `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent + // of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple + // modules may be configured via `djConfig.modulePaths`. + modulePaths: {}, + // afterOnLoad: Boolean + // Indicates Dojo was added to the page after the page load. In this case + // Dojo will not wait for the page DOMContentLoad/load events and fire + // its dojo.addOnLoad callbacks after making sure all outstanding + // dojo.required modules have loaded. Only works with a built dojo.js, + // it does not work the dojo.js directly from source control. + afterOnLoad: false, + // addOnLoad: Function or Array + // Adds a callback via dojo.addOnLoad. Useful when Dojo is added after + // the page loads and djConfig.afterOnLoad is true. Supports the same + // arguments as dojo.addOnLoad. When using a function reference, use + // `djConfig.addOnLoad = function(){};`. For object with function name use + // `djConfig.addOnLoad = [myObject, "functionName"];` and for object with + // function reference use + // `djConfig.addOnLoad = [myObject, function(){}];` + addOnLoad: null, + // require: Array + // An array of module names to be loaded immediately after dojo.js has been included + // in a page. + require: [], + // defaultDuration: Array + // Default duration, in milliseconds, for wipe and fade animations within dijits. + // Assigned to dijit.defaultDuration. + defaultDuration: 200, + // dojoBlankHtmlUrl: String + // Used by some modules to configure an empty iframe. Used by dojo.io.iframe and + // dojo.back, and dijit popup support in IE where an iframe is needed to make sure native + // controls do not bleed through the popups. Normally this configuration variable + // does not need to be set, except when using cross-domain/CDN Dojo builds. + // Save dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl` + // to the path on your domain your copy of blank.html. + dojoBlankHtmlUrl: undefined, + // ioPublish: Boolean? + // Set this to true to enable publishing of topics for the different phases of + // IO operations. Publishing is done via dojo.publish. See dojo.__IoPublish for a list + // of topics that are published. + ioPublish: false, + // useCustomLogger: Anything? + // If set to a value that evaluates to true such as a string or array and + // isDebug is true and Firebug is not available or running, then it bypasses + // the creation of Firebug Lite allowing you to define your own console object. + useCustomLogger: undefined, + // transparentColor: Array + // Array containing the r, g, b components used as transparent color in dojo.Color; + // if undefined, [255,255,255] (white) will be used. + transparentColor: undefined, + // skipIeDomLoaded: Boolean + // For IE only, skip the DOMContentLoaded hack used. Sometimes it can cause an Operation + // Aborted error if the rest of the page triggers script defers before the DOM is ready. + // If this is config value is set to true, then dojo.addOnLoad callbacks will not be + // triggered until the page load event, which is after images and iframes load. If you + // want to trigger the callbacks sooner, you can put a script block in the bottom of + // your HTML that calls dojo._loadInit();. If you are using multiversion support, change + // "dojo." to the appropriate scope name for dojo. + skipIeDomLoaded: false } -_f=(p in _f?_f[p]:(_d?_f[p]={}:undefined)); +=====*/ + +(function(){ + // firebug stubs + + if(typeof this["loadFirebugConsole"] == "function"){ + // for Firebug 1.2 + this["loadFirebugConsole"](); + }else{ + this.console = this.console || {}; + + // Be careful to leave 'log' always at the end + var cn = [ + "assert", "count", "debug", "dir", "dirxml", "error", "group", + "groupEnd", "info", "profile", "profileEnd", "time", "timeEnd", + "trace", "warn", "log" + ]; + var i=0, tn; + while((tn=cn[i++])){ + if(!console[tn]){ + (function(){ + var tcn = tn+""; + console[tcn] = ('log' in console) ? function(){ + var a = Array.apply({}, arguments); + a.unshift(tcn+":"); + console["log"](a.join(" ")); + } : function(){} + console[tcn]._fake = true; + })(); + } + } + } + + //TODOC: HOW TO DOC THIS? + // dojo is the root variable of (almost all) our public symbols -- make sure it is defined. + if(typeof dojo == "undefined"){ + dojo = { + _scopeName: "dojo", + _scopePrefix: "", + _scopePrefixArgs: "", + _scopeSuffix: "", + _scopeMap: {}, + _scopeMapRev: {} + }; + } + + var d = dojo; + + //Need placeholders for dijit and dojox for scoping code. + if(typeof dijit == "undefined"){ + dijit = {_scopeName: "dijit"}; + } + if(typeof dojox == "undefined"){ + dojox = {_scopeName: "dojox"}; + } + + if(!d._scopeArgs){ + d._scopeArgs = [dojo, dijit, dojox]; + } + +/*===== +dojo.global = { + // summary: + // Alias for the global scope + // (e.g. the window object in a browser). + // description: + // Refer to 'dojo.global' rather than referring to window to ensure your + // code runs correctly in contexts other than web browsers (e.g. Rhino on a server). } -return _f; -}; -dojo.setObject=function(_10,_11,_12){ -var _13=_10.split("."),p=_13.pop(),obj=d._getProp(_13,true,_12); -return obj&&p?(obj[p]=_11):undefined; -}; -dojo.getObject=function(_14,_15,_16){ -return d._getProp(_14.split("."),_15,_16); -}; -dojo.exists=function(_17,obj){ -return !!d.getObject(_17,false,obj); -}; -dojo["eval"]=function(_18){ -return d.global.eval?d.global.eval(_18):eval(_18); -}; -d.deprecated=d.experimental=function(){ -}; +=====*/ + d.global = this; + + d.config =/*===== djConfig = =====*/{ + isDebug: false, + debugAtAllCosts: false + }; + + if(typeof djConfig != "undefined"){ + for(var opt in djConfig){ + d.config[opt] = djConfig[opt]; + } + } + +/*===== + // Override locale setting, if specified + dojo.locale = { + // summary: the locale as defined by Dojo (read-only) + }; +=====*/ + dojo.locale = d.config.locale; + + var rev = "$Rev: 22487 $".match(/\d+/); + +/*===== + dojo.version = function(){ + // summary: + // Version number of the Dojo Toolkit + // major: Integer + // Major version. If total version is "1.2.0beta1", will be 1 + // minor: Integer + // Minor version. If total version is "1.2.0beta1", will be 2 + // patch: Integer + // Patch version. If total version is "1.2.0beta1", will be 0 + // flag: String + // Descriptor flag. If total version is "1.2.0beta1", will be "beta1" + // revision: Number + // The SVN rev from which dojo was pulled + this.major = 0; + this.minor = 0; + this.patch = 0; + this.flag = ""; + this.revision = 0; + } +=====*/ + dojo.version = { + major: 1, minor: 5, patch: 0, flag: "", + revision: rev ? +rev[0] : NaN, + toString: function(){ + with(d.version){ + return major + "." + minor + "." + patch + flag + " (" + revision + ")"; // String + } + } + } + + // Register with the OpenAjax hub + if(typeof OpenAjax != "undefined"){ + OpenAjax.hub.registerLibrary(dojo._scopeName, "http://dojotoolkit.org", d.version.toString()); + } + + var extraNames, extraLen, empty = {}; + for(var i in {toString: 1}){ extraNames = []; break; } + dojo._extraNames = extraNames = extraNames || ["hasOwnProperty", "valueOf", "isPrototypeOf", + "propertyIsEnumerable", "toLocaleString", "toString", "constructor"]; + extraLen = extraNames.length; + + dojo._mixin = function(/*Object*/ target, /*Object*/ source){ + // summary: + // Adds all properties and methods of source to target. This addition + // is "prototype extension safe", so that instances of objects + // will not pass along prototype defaults. + var name, s, i; + for(name in source){ + // the "tobj" condition avoid copying properties in "source" + // inherited from Object.prototype. For example, if target has a custom + // toString() method, don't overwrite it with the toString() method + // that source inherited from Object.prototype + s = source[name]; + if(!(name in target) || (target[name] !== s && (!(name in empty) || empty[name] !== s))){ + target[name] = s; + } + } + // IE doesn't recognize some custom functions in for..in + if(extraLen && source){ + for(i = 0; i < extraLen; ++i){ + name = extraNames[i]; + s = source[name]; + if(!(name in target) || (target[name] !== s && (!(name in empty) || empty[name] !== s))){ + target[name] = s; + } + } + } + return target; // Object + } + + dojo.mixin = function(/*Object*/obj, /*Object...*/props){ + // summary: + // Adds all properties and methods of props to obj and returns the + // (now modified) obj. + // description: + // `dojo.mixin` can mix multiple source objects into a + // destination object which is then returned. Unlike regular + // `for...in` iteration, `dojo.mixin` is also smart about avoiding + // extensions which other toolkits may unwisely add to the root + // object prototype + // obj: + // The object to mix properties into. Also the return value. + // props: + // One or more objects whose values are successively copied into + // obj. If more than one of these objects contain the same value, + // the one specified last in the function call will "win". + // example: + // make a shallow copy of an object + // | var copy = dojo.mixin({}, source); + // example: + // many class constructors often take an object which specifies + // values to be configured on the object. In this case, it is + // often simplest to call `dojo.mixin` on the `this` object: + // | dojo.declare("acme.Base", null, { + // | constructor: function(properties){ + // | // property configuration: + // | dojo.mixin(this, properties); + // | + // | console.log(this.quip); + // | // ... + // | }, + // | quip: "I wasn't born yesterday, you know - I've seen movies.", + // | // ... + // | }); + // | + // | // create an instance of the class and configure it + // | var b = new acme.Base({quip: "That's what it does!" }); + // example: + // copy in properties from multiple objects + // | var flattened = dojo.mixin( + // | { + // | name: "Frylock", + // | braces: true + // | }, + // | { + // | name: "Carl Brutanananadilewski" + // | } + // | ); + // | + // | // will print "Carl Brutanananadilewski" + // | console.log(flattened.name); + // | // will print "true" + // | console.log(flattened.braces); + if(!obj){ obj = {}; } + for(var i=1, l=arguments.length; i