1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-23 03:01:28 +00:00

build custom layer of Dojo to speed up loading of tt-rss (refs #293)

This commit is contained in:
Andrew Dolgov
2011-03-04 19:02:28 +03:00
parent cfad9259a6
commit a089699c89
144 changed files with 55627 additions and 13766 deletions

View File

@@ -5,116 +5,500 @@
*/
/*=====
// note:
// 'djConfig' does not exist under 'dojo.*' so that it can be set before the
// 'dojo' variable exists.
// note:
// Setting any of these variables *after* the library has loaded does
// nothing at all.
djConfig = {
// summary:
// Application code can set the global 'djConfig' prior to loading
// the library to override certain global settings for how dojo works.
//
// isDebug: Boolean
// Defaults to `false`. If set to `true`, ensures that Dojo provides
// extended debugging feedback via Firebug. If Firebug is not available
// on your platform, setting `isDebug` to `true` will force Dojo to
// pull in (and display) the version of Firebug Lite which is
// integrated into the Dojo distribution, thereby always providing a
// debugging/logging console when `isDebug` is enabled. Note that
// Firebug's `console.*` methods are ALWAYS defined by Dojo. If
// `isDebug` is false and you are on a platform without Firebug, these
// methods will be defined as no-ops.
isDebug: false,
// debugAtAllCosts: Boolean
// Defaults to `false`. If set to `true`, this triggers an alternate
// mode of the package system in which dependencies are detected and
// only then are resources evaluated in dependency order via
// `<script>` 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 `<base>` 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
}
=====*/
(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<l;i++){
d._mixin(_a,arguments[i]);
}
return _a;
};
dojo._getProp=function(_c,_d,_e){
var _f=_e||d.global;
for(var i=0,p;_f&&(p=_c[i]);i++){
if(i==0&&d._scopeMap[p]){
p=d._scopeMap[p];
}
_f=(p in _f?_f[p]:(_d?_f[p]={}:undefined));
}
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(){
};
// 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).
}
=====*/
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<l; i++){
d._mixin(obj, arguments[i]);
}
return obj; // Object
}
dojo._getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
var obj=context || d.global;
for(var i=0, p; obj && (p=parts[i]); i++){
if(i == 0 && d._scopeMap[p]){
p = d._scopeMap[p];
}
obj = (p in obj ? obj[p] : (create ? obj[p]={} : undefined));
}
return obj; // mixed
}
dojo.setObject = function(/*String*/name, /*Object*/value, /*Object?*/context){
// summary:
// Set a property from a dot-separated string, such as "A.B.C"
// description:
// Useful for longer api chains where you have to test each object in
// the chain, or when you have an object reference in string format.
// Objects are created as needed along `path`. Returns the passed
// value if setting is successful or `undefined` if not.
// name:
// Path to a property, in the form "A.B.C".
// context:
// Optional. Object to use as root of path. Defaults to
// `dojo.global`.
// example:
// set the value of `foo.bar.baz`, regardless of whether
// intermediate objects already exist:
// | dojo.setObject("foo.bar.baz", value);
// example:
// without `dojo.setObject`, we often see code like this:
// | // ensure that intermediate objects are available
// | if(!obj["parent"]){ obj.parent = {}; }
// | if(!obj.parent["child"]){ obj.parent.child= {}; }
// | // now we can safely set the property
// | obj.parent.child.prop = "some value";
// wheras with `dojo.setObject`, we can shorten that to:
// | dojo.setObject("parent.child.prop", "some value", obj);
var parts=name.split("."), p=parts.pop(), obj=d._getProp(parts, true, context);
return obj && p ? (obj[p]=value) : undefined; // Object
}
dojo.getObject = function(/*String*/name, /*Boolean?*/create, /*Object?*/context){
// summary:
// Get a property from a dot-separated string, such as "A.B.C"
// description:
// Useful for longer api chains where you have to test each object in
// the chain, or when you have an object reference in string format.
// name:
// Path to an property, in the form "A.B.C".
// create:
// Optional. Defaults to `false`. If `true`, Objects will be
// created at any point along the 'path' that is undefined.
// context:
// Optional. Object to use as root of path. Defaults to
// 'dojo.global'. Null may be passed.
return d._getProp(name.split("."), create, context); // Object
}
dojo.exists = function(/*String*/name, /*Object?*/obj){
// summary:
// determine if an object supports a given method
// description:
// useful for longer api chains where you have to test each object in
// the chain. Useful only for object and method detection.
// Not useful for testing generic properties on an object.
// In particular, dojo.exists("foo.bar") when foo.bar = ""
// will return false. Use ("bar" in foo) to test for those cases.
// name:
// Path to an object, in the form "A.B.C".
// obj:
// Object to use as root of path. Defaults to
// 'dojo.global'. Null may be passed.
// example:
// | // define an object
// | var foo = {
// | bar: { }
// | };
// |
// | // search the global scope
// | dojo.exists("foo.bar"); // true
// | dojo.exists("foo.bar.baz"); // false
// |
// | // search from a particular scope
// | dojo.exists("bar", foo); // true
// | dojo.exists("bar.baz", foo); // false
return !!d.getObject(name, false, obj); // Boolean
}
dojo["eval"] = function(/*String*/ scriptFragment){
// summary:
// A legacy method created for use exclusively by internal Dojo methods. Do not use
// this method directly, the behavior of this eval will differ from the normal
// browser eval.
// description:
// Placed in a separate function to minimize size of trapped
// exceptions. Calling eval() directly from some other scope may
// complicate tracebacks on some platforms.
// returns:
// The result of the evaluation. Often `undefined`
return d.global.eval ? d.global.eval(scriptFragment) : eval(scriptFragment); // Object
}
/*=====
dojo.deprecated = function(behaviour, extra, removal){
// summary:
// Log a debug message to indicate that a behavior has been
// deprecated.
// behaviour: String
// The API or behavior being deprecated. Usually in the form
// of "myApp.someFunction()".
// extra: String?
// Text to append to the message. Often provides advice on a
// new function or facility to achieve the same goal during
// the deprecation period.
// removal: String?
// Text to indicate when in the future the behavior will be
// removed. Usually a version number.
// example:
// | dojo.deprecated("myApp.getTemp()", "use myApp.getLocaleTemp() instead", "1.0");
}
dojo.experimental = function(moduleName, extra){
// summary: Marks code as experimental.
// description:
// This can be used to mark a function, file, or module as
// experimental. Experimental code is not ready to be used, and the
// APIs are subject to change without notice. Experimental code may be
// completed deleted without going through the normal deprecation
// process.
// moduleName: String
// The name of a module, or the name of a module file or a specific
// function
// extra: String?
// some additional message for the user
// example:
// | dojo.experimental("dojo.data.Result");
// example:
// | dojo.experimental("dojo.weather.toKelvin()", "PENDING approval from NOAA");
}
=====*/
//Real functions declared in dojo._firebug.firebug.
d.deprecated = d.experimental = function(){};
})();
// vim:ai:ts=4:noet

View File

@@ -5,240 +5,470 @@
*/
if(typeof window!="undefined"){
dojo.isBrowser=true;
dojo._name="browser";
/*=====
dojo.isBrowser = {
// example:
// | if(dojo.isBrowser){ ... }
};
dojo.isFF = {
// example:
// | if(dojo.isFF > 1){ ... }
};
dojo.isIE = {
// example:
// | if(dojo.isIE > 6){
// | // we are IE7
// | }
};
dojo.isSafari = {
// example:
// | if(dojo.isSafari){ ... }
// example:
// Detect iPhone:
// | if(dojo.isSafari && navigator.userAgent.indexOf("iPhone") != -1){
// | // we are iPhone. Note, iPod touch reports "iPod" above and fails this test.
// | }
};
dojo = {
// isBrowser: Boolean
// True if the client is a web-browser
isBrowser: true,
// isFF: Number | undefined
// Version as a Number if client is FireFox. undefined otherwise. Corresponds to
// major detected FireFox version (1.5, 2, 3, etc.)
isFF: 2,
// isIE: Number | undefined
// Version as a Number if client is MSIE(PC). undefined otherwise. Corresponds to
// major detected IE version (6, 7, 8, etc.)
isIE: 6,
// isKhtml: Number | undefined
// Version as a Number if client is a KHTML browser. undefined otherwise. Corresponds to major
// detected version.
isKhtml: 0,
// isWebKit: Number | undefined
// Version as a Number if client is a WebKit-derived browser (Konqueror,
// Safari, Chrome, etc.). undefined otherwise.
isWebKit: 0,
// isMozilla: Number | undefined
// Version as a Number if client is a Mozilla-based browser (Firefox,
// SeaMonkey). undefined otherwise. Corresponds to major detected version.
isMozilla: 0,
// isOpera: Number | undefined
// Version as a Number if client is Opera. undefined otherwise. Corresponds to
// major detected version.
isOpera: 0,
// isSafari: Number | undefined
// Version as a Number if client is Safari or iPhone. undefined otherwise.
isSafari: 0,
// isChrome: Number | undefined
// Version as a Number if client is Chrome browser. undefined otherwise.
isChrome: 0
// isMac: Boolean
// True if the client runs on Mac
}
=====*/
if(typeof window != 'undefined'){
dojo.isBrowser = true;
dojo._name = "browser";
// attempt to figure out the path to dojo if it isn't set in the config
(function(){
var d = dojo;
// this is a scope protection closure. We set browser versions and grab
// the URL we were loaded from here.
// grab the node we were loaded from
if(document && document.getElementsByTagName){
var scripts = document.getElementsByTagName("script");
var rePkg = /dojo(\.xd)?\.js(\W|$)/i;
for(var i = 0; i < scripts.length; i++){
var src = scripts[i].getAttribute("src");
if(!src){ continue; }
var m = src.match(rePkg);
if(m){
// find out where we came from
if(!d.config.baseUrl){
d.config.baseUrl = src.substring(0, m.index);
}
// and find out if we need to modify our behavior
var cfg = scripts[i].getAttribute("djConfig");
if(cfg){
var cfgo = eval("({ "+cfg+" })");
for(var x in cfgo){
dojo.config[x] = cfgo[x];
}
}
break; // "first Dojo wins"
}
}
}
d.baseUrl = d.config.baseUrl;
// fill in the rendering support information in dojo.render.*
var n = navigator;
var dua = n.userAgent,
dav = n.appVersion,
tv = parseFloat(dav);
if(dua.indexOf("Opera") >= 0){ d.isOpera = tv; }
if(dua.indexOf("AdobeAIR") >= 0){ d.isAIR = 1; }
d.isKhtml = (dav.indexOf("Konqueror") >= 0) ? tv : 0;
d.isWebKit = parseFloat(dua.split("WebKit/")[1]) || undefined;
d.isChrome = parseFloat(dua.split("Chrome/")[1]) || undefined;
d.isMac = dav.indexOf("Macintosh") >= 0;
// safari detection derived from:
// http://developer.apple.com/internet/safari/faq.html#anchor2
// http://developer.apple.com/internet/safari/uamatrix.html
var index = Math.max(dav.indexOf("WebKit"), dav.indexOf("Safari"), 0);
if(index && !dojo.isChrome){
// try to grab the explicit Safari version first. If we don't get
// one, look for less than 419.3 as the indication that we're on something
// "Safari 2-ish".
d.isSafari = parseFloat(dav.split("Version/")[1]);
if(!d.isSafari || parseFloat(dav.substr(index + 7)) <= 419.3){
d.isSafari = 2;
}
}
if(dua.indexOf("Gecko") >= 0 && !d.isKhtml && !d.isWebKit){ d.isMozilla = d.isMoz = tv; }
if(d.isMoz){
//We really need to get away from this. Consider a sane isGecko approach for the future.
d.isFF = parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1]) || undefined;
}
if(document.all && !d.isOpera){
d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
//In cases where the page has an HTTP header or META tag with
//X-UA-Compatible, then it is in emulation mode.
//Make sure isIE reflects the desired version.
//document.documentMode of 5 means quirks mode.
//Only switch the value if documentMode's major version
//is different from isIE's major version.
var mode = document.documentMode;
if(mode && mode != 5 && Math.floor(d.isIE) != mode){
d.isIE = mode;
}
}
//Workaround to get local file loads of dojo to work on IE 7
//by forcing to not use native xhr.
if(dojo.isIE && window.location.protocol === "file:"){
dojo.config.ieForceActiveXXhr=true;
}
d.isQuirks = document.compatMode == "BackCompat";
// TODO: is the HTML LANG attribute relevant?
d.locale = dojo.config.locale || (d.isIE ? n.userLanguage : n.language).toLowerCase();
// These are in order of decreasing likelihood; this will change in time.
d._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
d._xhrObj = function(){
// summary:
// does the work of portably generating a new XMLHTTPRequest object.
var http, last_e;
if(!dojo.isIE || !dojo.config.ieForceActiveXXhr){
try{ http = new XMLHttpRequest(); }catch(e){}
}
if(!http){
for(var i=0; i<3; ++i){
var progid = d._XMLHTTP_PROGIDS[i];
try{
http = new ActiveXObject(progid);
}catch(e){
last_e = e;
}
if(http){
d._XMLHTTP_PROGIDS = [progid]; // so faster next time
break;
}
}
}
if(!http){
throw new Error("XMLHTTP not available: "+last_e);
}
return http; // XMLHTTPRequest instance
}
d._isDocumentOk = function(http){
var stat = http.status || 0,
lp = location.protocol;
return (stat >= 200 && stat < 300) || // Boolean
stat == 304 || // allow any 2XX response code
stat == 1223 || // get it out of the cache
// Internet Explorer mangled the status code OR we're Titanium/browser chrome/chrome extension requesting a local file
(!stat && (lp == "file:" || lp == "chrome:" || lp == "chrome-extension:" || lp == "app:") );
}
//See if base tag is in use.
//This is to fix http://trac.dojotoolkit.org/ticket/3973,
//but really, we need to find out how to get rid of the dojo._Url reference
//below and still have DOH work with the dojo.i18n test following some other
//test that uses the test frame to load a document (trac #2757).
//Opera still has problems, but perhaps a larger issue of base tag support
//with XHR requests (hasBase is true, but the request is still made to document
//path, not base path).
var owloc = window.location+"";
var base = document.getElementsByTagName("base");
var hasBase = (base && base.length > 0);
d._getText = function(/*URI*/ uri, /*Boolean*/ fail_ok){
// summary: Read the contents of the specified uri and return those contents.
// uri:
// A relative or absolute uri. If absolute, it still must be in
// the same "domain" as we are.
// fail_ok:
// Default false. If fail_ok and loading fails, return null
// instead of throwing.
// returns: The response text. null is returned when there is a
// failure and failure is okay (an exception otherwise)
// NOTE: must be declared before scope switches ie. this._xhrObj()
var http = d._xhrObj();
if(!hasBase && dojo._Url){
uri = (new dojo._Url(owloc, uri)).toString();
}
if(d.config.cacheBust){
//Make sure we have a string before string methods are used on uri
uri += "";
uri += (uri.indexOf("?") == -1 ? "?" : "&") + String(d.config.cacheBust).replace(/\W+/g,"");
}
http.open('GET', uri, false);
try{
http.send(null);
if(!d._isDocumentOk(http)){
var err = Error("Unable to load "+uri+" status:"+ http.status);
err.status = http.status;
err.responseText = http.responseText;
throw err;
}
}catch(e){
if(fail_ok){ return null; } // null
// rethrow the exception
throw e;
}
return http.responseText; // String
}
var _w = window;
var _handleNodeEvent = function(/*String*/evtName, /*Function*/fp){
// summary:
// non-destructively adds the specified function to the node's
// evtName handler.
// evtName: should be in the form "onclick" for "onclick" handlers.
// Make sure you pass in the "on" part.
var _a = _w.attachEvent || _w.addEventListener;
evtName = _w.attachEvent ? evtName : evtName.substring(2);
_a(evtName, function(){
fp.apply(_w, arguments);
}, false);
};
d._windowUnloaders = [];
d.windowUnloaded = function(){
// summary:
// signal fired by impending window destruction. You may use
// dojo.addOnWindowUnload() to register a listener for this
// event. NOTE: if you wish to dojo.connect() to this method
// to perform page/application cleanup, be aware that this
// event WILL NOT fire if no handler has been registered with
// dojo.addOnWindowUnload. This behavior started in Dojo 1.3.
// Previous versions always triggered dojo.windowUnloaded. See
// dojo.addOnWindowUnload for more info.
var mll = d._windowUnloaders;
while(mll.length){
(mll.pop())();
}
d = null;
};
var _onWindowUnloadAttached = 0;
d.addOnWindowUnload = function(/*Object?|Function?*/obj, /*String|Function?*/functionName){
// summary:
// registers a function to be triggered when window.onunload
// fires.
// description:
// The first time that addOnWindowUnload is called Dojo
// will register a page listener to trigger your unload
// handler with. Note that registering these handlers may
// destory "fastback" page caching in browsers that support
// it. Be careful trying to modify the DOM or access
// JavaScript properties during this phase of page unloading:
// they may not always be available. Consider
// dojo.addOnUnload() if you need to modify the DOM or do
// heavy JavaScript work since it fires at the eqivalent of
// the page's "onbeforeunload" event.
// example:
// | dojo.addOnWindowUnload(functionPointer)
// | dojo.addOnWindowUnload(object, "functionName");
// | dojo.addOnWindowUnload(object, function(){ /* ... */});
d._onto(d._windowUnloaders, obj, functionName);
if(!_onWindowUnloadAttached){
_onWindowUnloadAttached = 1;
_handleNodeEvent("onunload", d.windowUnloaded);
}
};
var _onUnloadAttached = 0;
d.addOnUnload = function(/*Object?|Function?*/obj, /*String|Function?*/functionName){
// summary:
// registers a function to be triggered when the page unloads.
// description:
// The first time that addOnUnload is called Dojo will
// register a page listener to trigger your unload handler
// with.
//
// In a browser enviroment, the functions will be triggered
// during the window.onbeforeunload event. Be careful of doing
// too much work in an unload handler. onbeforeunload can be
// triggered if a link to download a file is clicked, or if
// the link is a javascript: link. In these cases, the
// onbeforeunload event fires, but the document is not
// actually destroyed. So be careful about doing destructive
// operations in a dojo.addOnUnload callback.
//
// Further note that calling dojo.addOnUnload will prevent
// browsers from using a "fast back" cache to make page
// loading via back button instantaneous.
// example:
// | dojo.addOnUnload(functionPointer)
// | dojo.addOnUnload(object, "functionName")
// | dojo.addOnUnload(object, function(){ /* ... */});
d._onto(d._unloaders, obj, functionName);
if(!_onUnloadAttached){
_onUnloadAttached = 1;
_handleNodeEvent("onbeforeunload", dojo.unloaded);
}
};
})();
//START DOMContentLoaded
dojo._initFired = false;
dojo._loadInit = function(e){
if(dojo._scrollIntervalId){
clearInterval(dojo._scrollIntervalId);
dojo._scrollIntervalId = 0;
}
if(!dojo._initFired){
dojo._initFired = true;
//Help out IE to avoid memory leak.
if(!dojo.config.afterOnLoad && window.detachEvent){
window.detachEvent("onload", dojo._loadInit);
}
if(dojo._inFlightCount == 0){
dojo._modulesLoaded();
}
}
}
if(!dojo.config.afterOnLoad){
if(document.addEventListener){
//Standards. Hooray! Assumption here that if standards based,
//it knows about DOMContentLoaded. It is OK if it does not, the fall through
//to window onload should be good enough.
document.addEventListener("DOMContentLoaded", dojo._loadInit, false);
window.addEventListener("load", dojo._loadInit, false);
}else if(window.attachEvent){
window.attachEvent("onload", dojo._loadInit);
//DOMContentLoaded approximation. Diego Perini found this MSDN article
//that indicates doScroll is available after DOM ready, so do a setTimeout
//to check when it is available.
//http://msdn.microsoft.com/en-us/library/ms531426.aspx
if(!dojo.config.skipIeDomLoaded && self === self.top){
dojo._scrollIntervalId = setInterval(function (){
try{
//When dojo is loaded into an iframe in an IE HTML Application
//(HTA), such as in a selenium test, javascript in the iframe
//can't see anything outside of it, so self===self.top is true,
//but the iframe is not the top window and doScroll will be
//available before document.body is set. Test document.body
//before trying the doScroll trick
if(document.body){
document.documentElement.doScroll("left");
dojo._loadInit();
}
}catch (e){}
}, 30);
}
}
}
if(dojo.isIE){
try{
(function(){
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
var vmlElems = ["*", "group", "roundrect", "oval", "shape", "rect", "imagedata", "path", "textpath", "text"],
i = 0, l = 1, s = document.createStyleSheet();
if(dojo.isIE >= 8){
i = 1;
l = vmlElems.length;
}
for(; i < l; ++i){
s.addRule("v\\:" + vmlElems[i], "behavior:url(#default#VML); display:inline-block");
}
})();
}catch(e){}
}
//END DOMContentLoaded
/*
OpenAjax.subscribe("OpenAjax", "onload", function(){
if(dojo._inFlightCount == 0){
dojo._modulesLoaded();
}
});
OpenAjax.subscribe("OpenAjax", "onunload", function(){
dojo.unloaded();
});
*/
} //if (typeof window != 'undefined')
//Register any module paths set up in djConfig. Need to do this
//in the hostenvs since hostenv_browser can read djConfig from a
//script tag's attribute.
(function(){
var d=dojo;
if(document&&document.getElementsByTagName){
var _1=document.getElementsByTagName("script");
var _2=/dojo(\.xd)?\.js(\W|$)/i;
for(var i=0;i<_1.length;i++){
var _3=_1[i].getAttribute("src");
if(!_3){
continue;
}
var m=_3.match(_2);
if(m){
if(!d.config.baseUrl){
d.config.baseUrl=_3.substring(0,m.index);
}
var _4=_1[i].getAttribute("djConfig");
if(_4){
var _5=eval("({ "+_4+" })");
for(var x in _5){
dojo.config[x]=_5[x];
}
}
break;
}
}
}
d.baseUrl=d.config.baseUrl;
var n=navigator;
var _6=n.userAgent,_7=n.appVersion,tv=parseFloat(_7);
if(_6.indexOf("Opera")>=0){
d.isOpera=tv;
}
if(_6.indexOf("AdobeAIR")>=0){
d.isAIR=1;
}
d.isKhtml=(_7.indexOf("Konqueror")>=0)?tv:0;
d.isWebKit=parseFloat(_6.split("WebKit/")[1])||undefined;
d.isChrome=parseFloat(_6.split("Chrome/")[1])||undefined;
d.isMac=_7.indexOf("Macintosh")>=0;
var _8=Math.max(_7.indexOf("WebKit"),_7.indexOf("Safari"),0);
if(_8&&!dojo.isChrome){
d.isSafari=parseFloat(_7.split("Version/")[1]);
if(!d.isSafari||parseFloat(_7.substr(_8+7))<=419.3){
d.isSafari=2;
}
}
if(_6.indexOf("Gecko")>=0&&!d.isKhtml&&!d.isWebKit){
d.isMozilla=d.isMoz=tv;
}
if(d.isMoz){
d.isFF=parseFloat(_6.split("Firefox/")[1]||_6.split("Minefield/")[1])||undefined;
}
if(document.all&&!d.isOpera){
d.isIE=parseFloat(_7.split("MSIE ")[1])||undefined;
var _9=document.documentMode;
if(_9&&_9!=5&&Math.floor(d.isIE)!=_9){
d.isIE=_9;
}
}
if(dojo.isIE&&window.location.protocol==="file:"){
dojo.config.ieForceActiveXXhr=true;
}
d.isQuirks=document.compatMode=="BackCompat";
d.locale=dojo.config.locale||(d.isIE?n.userLanguage:n.language).toLowerCase();
d._XMLHTTP_PROGIDS=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"];
d._xhrObj=function(){
var _a,_b;
if(!dojo.isIE||!dojo.config.ieForceActiveXXhr){
try{
_a=new XMLHttpRequest();
}
catch(e){
}
}
if(!_a){
for(var i=0;i<3;++i){
var _c=d._XMLHTTP_PROGIDS[i];
try{
_a=new ActiveXObject(_c);
}
catch(e){
_b=e;
}
if(_a){
d._XMLHTTP_PROGIDS=[_c];
break;
}
}
}
if(!_a){
throw new Error("XMLHTTP not available: "+_b);
}
return _a;
};
d._isDocumentOk=function(_d){
var _e=_d.status||0,lp=location.protocol;
return (_e>=200&&_e<300)||_e==304||_e==1223||(!_e&&(lp=="file:"||lp=="chrome:"||lp=="chrome-extension:"||lp=="app:"));
};
var _f=window.location+"";
var _10=document.getElementsByTagName("base");
var _11=(_10&&_10.length>0);
d._getText=function(uri,_12){
var _13=d._xhrObj();
if(!_11&&dojo._Url){
uri=(new dojo._Url(_f,uri)).toString();
}
if(d.config.cacheBust){
uri+="";
uri+=(uri.indexOf("?")==-1?"?":"&")+String(d.config.cacheBust).replace(/\W+/g,"");
}
_13.open("GET",uri,false);
try{
_13.send(null);
if(!d._isDocumentOk(_13)){
var err=Error("Unable to load "+uri+" status:"+_13.status);
err.status=_13.status;
err.responseText=_13.responseText;
throw err;
}
}
catch(e){
if(_12){
return null;
}
throw e;
}
return _13.responseText;
};
var _14=window;
var _15=function(_16,fp){
var _17=_14.attachEvent||_14.addEventListener;
_16=_14.attachEvent?_16:_16.substring(2);
_17(_16,function(){
fp.apply(_14,arguments);
},false);
};
d._windowUnloaders=[];
d.windowUnloaded=function(){
var mll=d._windowUnloaders;
while(mll.length){
(mll.pop())();
}
d=null;
};
var _18=0;
d.addOnWindowUnload=function(obj,_19){
d._onto(d._windowUnloaders,obj,_19);
if(!_18){
_18=1;
_15("onunload",d.windowUnloaded);
}
};
var _1a=0;
d.addOnUnload=function(obj,_1b){
d._onto(d._unloaders,obj,_1b);
if(!_1a){
_1a=1;
_15("onbeforeunload",dojo.unloaded);
}
};
})();
dojo._initFired=false;
dojo._loadInit=function(e){
if(dojo._scrollIntervalId){
clearInterval(dojo._scrollIntervalId);
dojo._scrollIntervalId=0;
}
if(!dojo._initFired){
dojo._initFired=true;
if(!dojo.config.afterOnLoad&&window.detachEvent){
window.detachEvent("onload",dojo._loadInit);
}
if(dojo._inFlightCount==0){
dojo._modulesLoaded();
}
}
};
if(!dojo.config.afterOnLoad){
if(document.addEventListener){
document.addEventListener("DOMContentLoaded",dojo._loadInit,false);
window.addEventListener("load",dojo._loadInit,false);
}else{
if(window.attachEvent){
window.attachEvent("onload",dojo._loadInit);
if(!dojo.config.skipIeDomLoaded&&self===self.top){
dojo._scrollIntervalId=setInterval(function(){
try{
if(document.body){
document.documentElement.doScroll("left");
dojo._loadInit();
}
}
catch(e){
}
},30);
}
}
}
}
if(dojo.isIE){
try{
(function(){
document.namespaces.add("v","urn:schemas-microsoft-com:vml");
var _1c=["*","group","roundrect","oval","shape","rect","imagedata","path","textpath","text"],i=0,l=1,s=document.createStyleSheet();
if(dojo.isIE>=8){
i=1;
l=_1c.length;
}
for(;i<l;++i){
s.addRule("v\\:"+_1c[i],"behavior:url(#default#VML); display:inline-block");
}
})();
}
catch(e){
}
}
}
(function(){
var mp=dojo.config["modulePaths"];
if(mp){
for(var _1d in mp){
dojo.registerModulePath(_1d,mp[_1d]);
}
}
var mp = dojo.config["modulePaths"];
if(mp){
for(var param in mp){
dojo.registerModulePath(param, mp[param]);
}
}
})();
//Load debug code if necessary.
if(dojo.config.isDebug){
dojo.require("dojo._firebug.firebug");
dojo.require("dojo._firebug.firebug");
}
if(dojo.config.debugAtAllCosts){
dojo.config.useXDomain=true;
dojo.require("dojo._base._loader.loader_xd");
dojo.require("dojo._base._loader.loader_debug");
dojo.require("dojo.i18n");
dojo.config.useXDomain = true;
dojo.require("dojo._base._loader.loader_xd");
dojo.require("dojo._base._loader.loader_debug");
dojo.require("dojo.i18n");
}

View File

@@ -5,171 +5,334 @@
*/
if(typeof window!="undefined"){
dojo.isBrowser=true;
dojo._name="browser";
// a host environment specifically built for Mozilla extensions, but derived
// from the browser host environment
if(typeof window != 'undefined'){
dojo.isBrowser = true;
dojo._name = "browser";
// FIXME: PORTME
// http://developer.mozilla.org/en/mozIJSSubScriptLoader
// attempt to figure out the path to dojo if it isn't set in the config
(function(){
var d = dojo;
// this is a scope protection closure. We set browser versions and grab
// the URL we were loaded from here.
// FIXME: need to probably use a different reference to "document" to get the hosting XUL environment
d.baseUrl = d.config.baseUrl;
// fill in the rendering support information in dojo.render.*
var n = navigator;
var dua = n.userAgent;
var dav = n.appVersion;
var tv = parseFloat(dav);
d.isMozilla = d.isMoz = tv;
if(d.isMoz){
d.isFF = parseFloat(dua.split("Firefox/")[1]) || undefined;
}
// FIXME
d.isQuirks = document.compatMode == "BackCompat";
// FIXME
// TODO: is the HTML LANG attribute relevant?
d.locale = dojo.config.locale || n.language.toLowerCase();
d._xhrObj = function(){
return new XMLHttpRequest();
}
// monkey-patch _loadUri to handle file://, chrome://, and resource:// url's
var oldLoadUri = d._loadUri;
d._loadUri = function(uri, cb){
var handleLocal = ["file:", "chrome:", "resource:"].some(function(prefix){
return String(uri).indexOf(prefix) == 0;
});
if(handleLocal){
// see:
// http://developer.mozilla.org/en/mozIJSSubScriptLoader
var l = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
var value = l.loadSubScript(uri, d.global)
if(cb){ cb(value); }
return true;
}else{
// otherwise, call the pre-existing version
return oldLoadUri.apply(d, arguments);
}
}
// FIXME: PORTME
d._isDocumentOk = function(http){
var stat = http.status || 0;
return (stat >= 200 && stat < 300) || // Boolean
stat == 304 || // allow any 2XX response code
stat == 1223 || // get it out of the cache
(!stat && (location.protocol=="file:" || location.protocol=="chrome:") );
}
// FIXME: PORTME
// var owloc = window.location+"";
// var base = document.getElementsByTagName("base");
// var hasBase = (base && base.length > 0);
var hasBase = false;
d._getText = function(/*URI*/ uri, /*Boolean*/ fail_ok){
// summary: Read the contents of the specified uri and return those contents.
// uri:
// A relative or absolute uri. If absolute, it still must be in
// the same "domain" as we are.
// fail_ok:
// Default false. If fail_ok and loading fails, return null
// instead of throwing.
// returns: The response text. null is returned when there is a
// failure and failure is okay (an exception otherwise)
// alert("_getText: " + uri);
// NOTE: must be declared before scope switches ie. this._xhrObj()
var http = d._xhrObj();
if(!hasBase && dojo._Url){
uri = (new dojo._Url(uri)).toString();
}
if(d.config.cacheBust){
//Make sure we have a string before string methods are used on uri
uri += "";
uri += (uri.indexOf("?") == -1 ? "?" : "&") + String(d.config.cacheBust).replace(/\W+/g,"");
}
var handleLocal = ["file:", "chrome:", "resource:"].some(function(prefix){
return String(uri).indexOf(prefix) == 0;
});
if(handleLocal){
// see:
// http://forums.mozillazine.org/viewtopic.php?p=921150#921150
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var scriptableStream=Components
.classes["@mozilla.org/scriptableinputstream;1"]
.getService(Components.interfaces.nsIScriptableInputStream);
var channel = ioService.newChannel(uri, null, null);
var input = channel.open();
scriptableStream.init(input);
var str = scriptableStream.read(input.available());
scriptableStream.close();
input.close();
return str;
}else{
http.open('GET', uri, false);
try{
http.send(null);
// alert(http);
if(!d._isDocumentOk(http)){
var err = Error("Unable to load "+uri+" status:"+ http.status);
err.status = http.status;
err.responseText = http.responseText;
throw err;
}
}catch(e){
if(fail_ok){ return null; } // null
// rethrow the exception
throw e;
}
return http.responseText; // String
}
}
d._windowUnloaders = [];
// FIXME: PORTME
d.windowUnloaded = function(){
// summary:
// signal fired by impending window destruction. You may use
// dojo.addOnWIndowUnload() or dojo.connect() to this method to perform
// page/application cleanup methods. See dojo.addOnWindowUnload for more info.
var mll = d._windowUnloaders;
while(mll.length){
(mll.pop())();
}
}
// FIXME: PORTME
d.addOnWindowUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
// summary:
// registers a function to be triggered when window.onunload fires.
// Be careful trying to modify the DOM or access JavaScript properties
// during this phase of page unloading: they may not always be available.
// Consider dojo.addOnUnload() if you need to modify the DOM or do heavy
// JavaScript work.
// example:
// | dojo.addOnWindowUnload(functionPointer)
// | dojo.addOnWindowUnload(object, "functionName")
// | dojo.addOnWindowUnload(object, function(){ /* ... */});
d._onto(d._windowUnloaders, obj, functionName);
}
// XUL specific APIs
var contexts = [];
var current = null;
dojo._defaultContext = [ window, document ];
dojo.pushContext = function(/*Object|String?*/g, /*MDocumentElement?*/d){
// summary:
// causes subsequent calls to Dojo methods to assume the
// passed object and, optionally, document as the default
// scopes to use. A 2-element array of the previous global and
// document are returned.
// description:
// dojo.pushContext treats contexts as a stack. The
// auto-detected contexts which are initially provided using
// dojo.setContext() require authors to keep state in order to
// "return" to a previous context, whereas the
// dojo.pushContext and dojo.popContext methods provide a more
// natural way to augment blocks of code to ensure that they
// execute in a different window or frame without issue. If
// called without any arguments, the default context (the
// context when Dojo is first loaded) is instead pushed into
// the stack. If only a single string is passed, a node in the
// intitial context's document is looked up and its
// contextWindow and contextDocument properties are used as
// the context to push. This means that iframes can be given
// an ID and code can be executed in the scope of the iframe's
// document in subsequent calls easily.
// g:
// The global context. If a string, the id of the frame to
// search for a context and document.
// d:
// The document element to execute subsequent code with.
var old = [dojo.global, dojo.doc];
contexts.push(old);
var n;
if(!g && !d){
n = dojo._defaultContext;
}else{
n = [ g, d ];
if(!d && dojo.isString(g)){
var t = document.getElementById(g);
if(t.contentDocument){
n = [t.contentWindow, t.contentDocument];
}
}
}
current = n;
dojo.setContext.apply(dojo, n);
return old; // Array
};
dojo.popContext = function(){
// summary:
// If the context stack contains elements, ensure that
// subsequent code executes in the *previous* context to the
// current context. The current context set ([global,
// document]) is returned.
var oc = current;
if(!contexts.length){
return oc;
}
dojo.setContext.apply(dojo, contexts.pop());
return oc;
};
// FIXME:
// don't really like the current arguments and order to
// _inContext, so don't make it public until it's right!
dojo._inContext = function(g, d, f){
var a = dojo._toArray(arguments);
f = a.pop();
if(a.length == 1){
d = null;
}
dojo.pushContext(g, d);
var r = f();
dojo.popContext();
return r;
};
})();
dojo._initFired = false;
// BEGIN DOMContentLoaded, from Dean Edwards (http://dean.edwards.name/weblog/2006/06/again/)
dojo._loadInit = function(e){
dojo._initFired = true;
// allow multiple calls, only first one will take effect
// A bug in khtml calls events callbacks for document for event which isnt supported
// for example a created contextmenu event calls DOMContentLoaded, workaround
var type = (e && e.type) ? e.type.toLowerCase() : "load";
if(arguments.callee.initialized || (type != "domcontentloaded" && type != "load")){ return; }
arguments.callee.initialized = true;
if(dojo._inFlightCount == 0){
dojo._modulesLoaded();
}
}
/*
(function(){
var _w = window;
var _handleNodeEvent = function(evtName, fp){
// summary:
// non-destructively adds the specified function to the node's
// evtName handler.
// evtName: should be in the form "onclick" for "onclick" handlers.
// Make sure you pass in the "on" part.
var oldHandler = _w[evtName] || function(){};
_w[evtName] = function(){
fp.apply(_w, arguments);
oldHandler.apply(_w, arguments);
};
};
// FIXME: PORT
// FIXME: dojo.unloaded requires dojo scope, so using anon function wrapper.
_handleNodeEvent("onbeforeunload", function() { dojo.unloaded(); });
_handleNodeEvent("onunload", function() { dojo.windowUnloaded(); });
})();
*/
// FIXME: PORTME
// this event fires a lot, namely for all plugin XUL overlays and for
// all iframes (in addition to window navigations). We only want
// Dojo's to fire once..but we might care if pages navigate. We'll
// probably need an extension-specific API
if(!dojo.config.afterOnLoad){
window.addEventListener("DOMContentLoaded",function(e){
dojo._loadInit(e);
// console.log("DOM content loaded", e);
}, false);
}
} //if (typeof window != 'undefined')
//Register any module paths set up in djConfig. Need to do this
//in the hostenvs since hostenv_browser can read djConfig from a
//script tag's attribute.
(function(){
var d=dojo;
d.baseUrl=d.config.baseUrl;
var n=navigator;
var _1=n.userAgent;
var _2=n.appVersion;
var tv=parseFloat(_2);
d.isMozilla=d.isMoz=tv;
if(d.isMoz){
d.isFF=parseFloat(_1.split("Firefox/")[1])||undefined;
}
d.isQuirks=document.compatMode=="BackCompat";
d.locale=dojo.config.locale||n.language.toLowerCase();
d._xhrObj=function(){
return new XMLHttpRequest();
};
var _3=d._loadUri;
d._loadUri=function(_4,cb){
var _5=["file:","chrome:","resource:"].some(function(_6){
return String(_4).indexOf(_6)==0;
});
if(_5){
var l=Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
var _7=l.loadSubScript(_4,d.global);
if(cb){
cb(_7);
}
return true;
}else{
return _3.apply(d,arguments);
}
};
d._isDocumentOk=function(_8){
var _9=_8.status||0;
return (_9>=200&&_9<300)||_9==304||_9==1223||(!_9&&(location.protocol=="file:"||location.protocol=="chrome:"));
};
var _a=false;
d._getText=function(_b,_c){
var _d=d._xhrObj();
if(!_a&&dojo._Url){
_b=(new dojo._Url(_b)).toString();
}
if(d.config.cacheBust){
_b+="";
_b+=(_b.indexOf("?")==-1?"?":"&")+String(d.config.cacheBust).replace(/\W+/g,"");
}
var _e=["file:","chrome:","resource:"].some(function(_f){
return String(_b).indexOf(_f)==0;
});
if(_e){
var _10=Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var _11=Components.classes["@mozilla.org/scriptableinputstream;1"].getService(Components.interfaces.nsIScriptableInputStream);
var _12=_10.newChannel(_b,null,null);
var _13=_12.open();
_11.init(_13);
var str=_11.read(_13.available());
_11.close();
_13.close();
return str;
}else{
_d.open("GET",_b,false);
try{
_d.send(null);
if(!d._isDocumentOk(_d)){
var err=Error("Unable to load "+_b+" status:"+_d.status);
err.status=_d.status;
err.responseText=_d.responseText;
throw err;
}
}
catch(e){
if(_c){
return null;
}
throw e;
}
return _d.responseText;
}
};
d._windowUnloaders=[];
d.windowUnloaded=function(){
var mll=d._windowUnloaders;
while(mll.length){
(mll.pop())();
}
};
d.addOnWindowUnload=function(obj,_14){
d._onto(d._windowUnloaders,obj,_14);
};
var _15=[];
var _16=null;
dojo._defaultContext=[window,document];
dojo.pushContext=function(g,d){
var old=[dojo.global,dojo.doc];
_15.push(old);
var n;
if(!g&&!d){
n=dojo._defaultContext;
}else{
n=[g,d];
if(!d&&dojo.isString(g)){
var t=document.getElementById(g);
if(t.contentDocument){
n=[t.contentWindow,t.contentDocument];
}
}
}
_16=n;
dojo.setContext.apply(dojo,n);
return old;
};
dojo.popContext=function(){
var oc=_16;
if(!_15.length){
return oc;
}
dojo.setContext.apply(dojo,_15.pop());
return oc;
};
dojo._inContext=function(g,d,f){
var a=dojo._toArray(arguments);
f=a.pop();
if(a.length==1){
d=null;
}
dojo.pushContext(g,d);
var r=f();
dojo.popContext();
return r;
};
})();
dojo._initFired=false;
dojo._loadInit=function(e){
dojo._initFired=true;
var _17=(e&&e.type)?e.type.toLowerCase():"load";
if(arguments.callee.initialized||(_17!="domcontentloaded"&&_17!="load")){
return;
}
arguments.callee.initialized=true;
if(dojo._inFlightCount==0){
dojo._modulesLoaded();
}
};
if(!dojo.config.afterOnLoad){
window.addEventListener("DOMContentLoaded",function(e){
dojo._loadInit(e);
},false);
}
}
(function(){
var mp=dojo.config["modulePaths"];
if(mp){
for(var _18 in mp){
dojo.registerModulePath(_18,mp[_18]);
}
}
var mp = dojo.config["modulePaths"];
if(mp){
for(var param in mp){
dojo.registerModulePath(param, mp[param]);
}
}
})();
//Load debug code if necessary.
if(dojo.config.isDebug){
console.log=function(m){
var s=Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
s.logStringMessage(m);
};
console.debug=function(){
};
// logging stub for extension logging
console.log = function(m){
var s = Components.classes["@mozilla.org/consoleservice;1"].getService(
Components.interfaces.nsIConsoleService
);
s.logStringMessage(m);
}
console.debug = function(){
console.log(dojo._toArray(arguments).join(" "));
}
// FIXME: what about the rest of the console.* methods? And is there any way to reach into firebug and log into it directly?
}

View File

@@ -5,149 +5,204 @@
*/
/*
* Rhino host environment
*/
if(dojo.config["baseUrl"]){
dojo.baseUrl=dojo.config["baseUrl"];
dojo.baseUrl = dojo.config["baseUrl"];
}else{
dojo.baseUrl="./";
dojo.baseUrl = "./";
}
dojo.locale=dojo.locale||String(java.util.Locale.getDefault().toString().replace("_","-").toLowerCase());
dojo._name="rhino";
dojo.isRhino=true;
if(typeof print=="function"){
console.debug=print;
dojo.locale = dojo.locale || String(java.util.Locale.getDefault().toString().replace('_','-').toLowerCase());
dojo._name = 'rhino';
dojo.isRhino = true;
if(typeof print == "function"){
console.debug = print;
}
if(!("byId" in dojo)){
dojo.byId=function(id,_1){
if(id&&(typeof id=="string"||id instanceof String)){
if(!_1){
_1=document;
dojo.byId = function(id, doc){
if(id && (typeof id == "string" || id instanceof String)){
if(!doc){ doc = document; }
return doc.getElementById(id);
}
return id; // assume it's a node
}
}
return _1.getElementById(id);
dojo._isLocalUrl = function(/*String*/ uri) {
// summary:
// determines if URI is local or not.
var local = (new java.io.File(uri)).exists();
if(!local){
var stream;
//Try remote URL. Allow this method to throw,
//but still do cleanup.
try{
// try it as a file first, URL second
stream = (new java.net.URL(uri)).openStream();
// close the stream so we don't leak resources
stream.close();
}finally{
if(stream && stream.close){
stream.close();
}
}
}
return local;
}
return id;
};
// see comments in spidermonkey loadUri
dojo._loadUri = function(uri, cb){
try{
var local;
try{
local = dojo._isLocalUrl(uri);
}catch(e){
// no debug output; this failure just means the uri was not found.
return false;
}
//FIXME: Use Rhino 1.6 native readFile/readUrl if available?
if(cb){
var contents = (local ? readText : readUri)(uri, "UTF-8");
// patch up the input to eval until https://bugzilla.mozilla.org/show_bug.cgi?id=471005 is fixed.
if(!eval("'\u200f'").length){
contents = String(contents).replace(/[\u200E\u200F\u202A-\u202E]/g, function(match){
return "\\u" + match.charCodeAt(0).toString(16);
})
}
cb(eval('('+contents+')'));
}else{
load(uri);
}
return true;
}catch(e){
console.debug("rhino load('" + uri + "') failed. Exception: " + e);
return false;
}
}
dojo._isLocalUrl=function(_2){
var _3=(new java.io.File(_2)).exists();
if(!_3){
var _4;
try{
_4=(new java.net.URL(_2)).openStream();
_4.close();
dojo.exit = function(exitcode){
quit(exitcode);
}
finally{
if(_4&&_4.close){
_4.close();
// reading a file from disk in Java is a humiliating experience by any measure.
// Lets avoid that and just get the freaking text
function readText(path, encoding){
encoding = encoding || "utf-8";
// NOTE: we intentionally avoid handling exceptions, since the caller will
// want to know
var jf = new java.io.File(path);
var is = new java.io.FileInputStream(jf);
return dj_readInputStream(is, encoding);
}
function readUri(uri, encoding){
var conn = (new java.net.URL(uri)).openConnection();
encoding = encoding || conn.getContentEncoding() || "utf-8";
var is = conn.getInputStream();
return dj_readInputStream(is, encoding);
}
function dj_readInputStream(is, encoding){
var input = new java.io.BufferedReader(new java.io.InputStreamReader(is, encoding));
try {
var sb = new java.lang.StringBuffer();
var line = "";
while((line = input.readLine()) !== null){
sb.append(line);
sb.append(java.lang.System.getProperty("line.separator"));
}
return sb.toString();
} finally {
input.close();
}
}
return _3;
};
dojo._loadUri=function(_5,cb){
try{
var _6;
try{
_6=dojo._isLocalUrl(_5);
dojo._getText = function(/*URI*/ uri, /*Boolean*/ fail_ok){
// summary: Read the contents of the specified uri and return those contents.
// uri:
// A relative or absolute uri.
// fail_ok:
// Default false. If fail_ok and loading fails, return null
// instead of throwing.
// returns: The response text. null is returned when there is a
// failure and failure is okay (an exception otherwise)
try{
var local = dojo._isLocalUrl(uri);
var text = (local ? readText : readUri)(uri, "UTF-8");
if(text !== null){
//Force JavaScript string.
text += "";
}
return text;
}catch(e){
if(fail_ok){
return null;
}else{
throw e;
}
}
}
catch(e){
return false;
// summary:
// return the document object associated with the dojo.global
dojo.doc = typeof document != "undefined" ? document : null;
dojo.body = function(){
return document.body;
}
if(cb){
var _7=(_6?readText:readUri)(_5,"UTF-8");
if(!eval("''").length){
_7=String(_7).replace(/[\u200E\u200F\u202A-\u202E]/g,function(_8){
return "\\u"+_8.charCodeAt(0).toString(16);
});
}
cb(eval("("+_7+")"));
}else{
load(_5);
}
return true;
}
catch(e){
return false;
}
};
dojo.exit=function(_9){
quit(_9);
};
function readText(_a,_b){
_b=_b||"utf-8";
var jf=new java.io.File(_a);
var is=new java.io.FileInputStream(jf);
return dj_readInputStream(is,_b);
};
function readUri(_c,_d){
var _e=(new java.net.URL(_c)).openConnection();
_d=_d||_e.getContentEncoding()||"utf-8";
var is=_e.getInputStream();
return dj_readInputStream(is,_d);
};
function dj_readInputStream(is,_f){
var _10=new java.io.BufferedReader(new java.io.InputStreamReader(is,_f));
try{
var sb=new java.lang.StringBuffer();
var _11="";
while((_11=_10.readLine())!==null){
sb.append(_11);
sb.append(java.lang.System.getProperty("line.separator"));
}
return sb.toString();
}
finally{
_10.close();
}
};
dojo._getText=function(uri,_12){
try{
var _13=dojo._isLocalUrl(uri);
var _14=(_13?readText:readUri)(uri,"UTF-8");
if(_14!==null){
_14+="";
}
return _14;
}
catch(e){
if(_12){
return null;
}else{
throw e;
}
}
};
dojo.doc=typeof document!="undefined"?document:null;
dojo.body=function(){
return document.body;
};
if(typeof setTimeout=="undefined"||typeof clearTimeout=="undefined"){
dojo._timeouts=[];
clearTimeout=function(idx){
if(!dojo._timeouts[idx]){
return;
}
dojo._timeouts[idx].stop();
};
setTimeout=function(_15,_16){
var def={sleepTime:_16,hasSlept:false,run:function(){
if(!this.hasSlept){
this.hasSlept=true;
java.lang.Thread.currentThread().sleep(this.sleepTime);
}
try{
_15();
}
catch(e){
}
}};
var _17=new java.lang.Runnable(def);
var _18=new java.lang.Thread(_17);
_18.start();
return dojo._timeouts.push(_18)-1;
};
// Supply setTimeout/clearTimeout implementations if they aren't already there
// Note: this assumes that we define both if one is not provided... there might
// be a better way to do this if there is a use case where one is defined but
// not the other
if(typeof setTimeout == "undefined" || typeof clearTimeout == "undefined"){
dojo._timeouts = [];
clearTimeout = function(idx){
if(!dojo._timeouts[idx]){ return; }
dojo._timeouts[idx].stop();
}
setTimeout = function(func, delay){
// summary: provides timed callbacks using Java threads
var def={
sleepTime:delay,
hasSlept:false,
run:function(){
if(!this.hasSlept){
this.hasSlept=true;
java.lang.Thread.currentThread().sleep(this.sleepTime);
}
try{
func();
}catch(e){
console.debug("Error running setTimeout thread:" + e);
}
}
};
var runnable = new java.lang.Runnable(def);
var thread = new java.lang.Thread(runnable);
thread.start();
return dojo._timeouts.push(thread)-1;
}
}
//Register any module paths set up in djConfig. Need to do this
//in the hostenvs since hostenv_browser can read djConfig from a
//script tag's attribute.
if(dojo.config["modulePaths"]){
for(var param in dojo.config["modulePaths"]){
dojo.registerModulePath(param,dojo.config["modulePaths"][param]);
}
for(var param in dojo.config["modulePaths"]){
dojo.registerModulePath(param, dojo.config["modulePaths"][param]);
}
}

View File

@@ -5,46 +5,83 @@
*/
/*
* SpiderMonkey host environment
*/
if(dojo.config["baseUrl"]){
dojo.baseUrl=dojo.config["baseUrl"];
dojo.baseUrl = dojo.config["baseUrl"];
}else{
dojo.baseUrl="./";
dojo.baseUrl = "./";
}
dojo._name="spidermonkey";
dojo.isSpidermonkey=true;
dojo.exit=function(_1){
quit(_1);
dojo._name = 'spidermonkey';
/*=====
dojo.isSpidermonkey = {
// summary: Detect spidermonkey
};
if(typeof print=="function"){
console.debug=print;
=====*/
dojo.isSpidermonkey = true;
dojo.exit = function(exitcode){
quit(exitcode);
}
if(typeof line2pc=="undefined"){
throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global");
if(typeof print == "function"){
console.debug = print;
}
dojo._spidermonkeyCurrentFile=function(_2){
var s="";
try{
throw Error("whatever");
if(typeof line2pc == 'undefined'){
throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global");
}
catch(e){
s=e.stack;
dojo._spidermonkeyCurrentFile = function(depth){
//
// This is a hack that determines the current script file by parsing a
// generated stack trace (relying on the non-standard "stack" member variable
// of the SpiderMonkey Error object).
//
// If param depth is passed in, it'll return the script file which is that far down
// the stack, but that does require that you know how deep your stack is when you are
// calling.
//
var s = '';
try{
throw Error("whatever");
}catch(e){
s = e.stack;
}
// lines are like: bu_getCurrentScriptURI_spidermonkey("ScriptLoader.js")@burst/Runtime.js:101
var matches = s.match(/[^@]*\.js/gi);
if(!matches){
throw Error("could not parse stack string: '" + s + "'");
}
var fname = (typeof depth != 'undefined' && depth) ? matches[depth + 1] : matches[matches.length - 1];
if(!fname){
throw Error("could not find file name in stack string '" + s + "'");
}
//print("SpiderMonkeyRuntime got fname '" + fname + "' from stack string '" + s + "'");
return fname;
}
var _3=s.match(/[^@]*\.js/gi);
if(!_3){
throw Error("could not parse stack string: '"+s+"'");
// print(dojo._spidermonkeyCurrentFile(0));
dojo._loadUri = function(uri){
// spidermonkey load() evaluates the contents into the global scope (which
// is what we want).
// TODO: sigh, load() does not return a useful value.
// Perhaps it is returning the value of the last thing evaluated?
var ok = load(uri);
// console.log("spidermonkey load(", uri, ") returned ", ok);
return 1;
}
var _4=(typeof _2!="undefined"&&_2)?_3[_2+1]:_3[_3.length-1];
if(!_4){
throw Error("could not find file name in stack string '"+s+"'");
}
return _4;
};
dojo._loadUri=function(_5){
var ok=load(_5);
return 1;
};
//Register any module paths set up in djConfig. Need to do this
//in the hostenvs since hostenv_browser can read djConfig from a
//script tag's attribute.
if(dojo.config["modulePaths"]){
for(var param in dojo.config["modulePaths"]){
dojo.registerModulePath(param,dojo.config["modulePaths"][param]);
}
for(var param in dojo.config["modulePaths"]){
dojo.registerModulePath(param, dojo.config["modulePaths"][param]);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,55 +5,82 @@
*/
if(!dojo._hasResource["dojo._base._loader.loader_debug"]){
dojo._hasResource["dojo._base._loader.loader_debug"]=true;
if(!dojo._hasResource["dojo._base._loader.loader_debug"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojo._base._loader.loader_debug"] = true;
dojo.provide("dojo._base._loader.loader_debug");
dojo.nonDebugProvide=dojo.provide;
dojo.provide=function(_1){
var _2=dojo["_xdDebugQueue"];
if(_2&&_2.length>0&&_1==_2["currentResourceName"]){
if(dojo.isAIR){
window.setTimeout(function(){
dojo._xdDebugFileLoaded(_1);
},1);
}else{
window.setTimeout(dojo._scopeName+"._xdDebugFileLoaded('"+_1+"')",1);
//Override dojo.provide, so we can trigger the next
//script tag for the next local module. We can only add one
//at a time because there are browsers that execute script tags
//in the order that the code is received, and not in the DOM order.
dojo.nonDebugProvide = dojo.provide;
dojo.provide = function(resourceName){
var dbgQueue = dojo["_xdDebugQueue"];
if(dbgQueue && dbgQueue.length > 0 && resourceName == dbgQueue["currentResourceName"]){
//Set a timeout so the module can be executed into existence. Normally the
//dojo.provide call in a module is the first line. Don't want to risk attaching
//another script tag until the current one finishes executing.
if(dojo.isAIR){
window.setTimeout(function(){dojo._xdDebugFileLoaded(resourceName);}, 1);
}else{
window.setTimeout(dojo._scopeName + "._xdDebugFileLoaded('" + resourceName + "')", 1);
}
}
return dojo.nonDebugProvide.apply(dojo, arguments);
}
dojo._xdDebugFileLoaded = function(resourceName){
if(!dojo._xdDebugScopeChecked){
//If using a scoped dojo, we need to expose dojo as a real global
//for the debugAtAllCosts stuff to work.
if(dojo._scopeName != "dojo"){
window.dojo = window[dojo.config.scopeMap[0][1]];
window.dijit = window[dojo.config.scopeMap[1][1]];
window.dojox = window[dojo.config.scopeMap[2][1]];
}
dojo._xdDebugScopeChecked = true;
}
var dbgQueue = dojo._xdDebugQueue;
if(resourceName && resourceName == dbgQueue.currentResourceName){
dbgQueue.shift();
}
if(dbgQueue.length == 0){
//Check for more modules that need debug loading.
//dojo._xdWatchInFlight will add more things to the debug
//queue if they just recently loaded but it was not detected
//between the dojo._xdWatchInFlight intervals.
dojo._xdWatchInFlight();
}
if(dbgQueue.length == 0){
dbgQueue.currentResourceName = null;
//Make sure nothing else is in flight.
//If something is still in flight, then it still
//needs to be added to debug queue after it loads.
for(var param in dojo._xdInFlight){
if(dojo._xdInFlight[param] === true){
return;
}
}
dojo._xdNotifyLoaded();
}else{
if(resourceName == dbgQueue.currentResourceName){
dbgQueue.currentResourceName = dbgQueue[0].resourceName;
var element = document.createElement("script");
element.type = "text/javascript";
element.src = dbgQueue[0].resourcePath;
document.getElementsByTagName("head")[0].appendChild(element);
}
}
}
return dojo.nonDebugProvide.apply(dojo,arguments);
};
dojo._xdDebugFileLoaded=function(_3){
if(!dojo._xdDebugScopeChecked){
if(dojo._scopeName!="dojo"){
window.dojo=window[dojo.config.scopeMap[0][1]];
window.dijit=window[dojo.config.scopeMap[1][1]];
window.dojox=window[dojo.config.scopeMap[2][1]];
}
dojo._xdDebugScopeChecked=true;
}
var _4=dojo._xdDebugQueue;
if(_3&&_3==_4.currentResourceName){
_4.shift();
}
if(_4.length==0){
dojo._xdWatchInFlight();
}
if(_4.length==0){
_4.currentResourceName=null;
for(var _5 in dojo._xdInFlight){
if(dojo._xdInFlight[_5]===true){
return;
}
}
dojo._xdNotifyLoaded();
}else{
if(_3==_4.currentResourceName){
_4.currentResourceName=_4[0].resourceName;
var _6=document.createElement("script");
_6.type="text/javascript";
_6.src=_4[0].resourcePath;
document.getElementsByTagName("head")[0].appendChild(_6);
}
}
};
}

File diff suppressed because it is too large Load Diff