Imported Debian patch 4.6.2-4~numeezy

This commit is contained in:
Alexandre Ellert
2018-01-31 13:57:05 +02:00
committed by Mario Fetka
parent 8ff3be4216
commit c86f4cfde4
103 changed files with 38064 additions and 0 deletions

View File

@@ -0,0 +1,383 @@
define([
"./kernel",
"../Deferred",
"../promise/Promise",
"../errors/CancelError",
"../has",
"./lang",
"../when"
], function(dojo, NewDeferred, Promise, CancelError, has, lang, when){
// module:
// dojo/_base/Deferred
var mutator = function(){};
var freeze = Object.freeze || function(){};
// A deferred provides an API for creating and resolving a promise.
var Deferred = dojo.Deferred = function(/*Function?*/ canceller){
// summary:
// Deprecated. This module defines the legacy dojo/_base/Deferred API.
// New code should use dojo/Deferred instead.
// description:
// The Deferred API is based on the concept of promises that provide a
// generic interface into the eventual completion of an asynchronous action.
// The motivation for promises fundamentally is about creating a
// separation of concerns that allows one to achieve the same type of
// call patterns and logical data flow in asynchronous code as can be
// achieved in synchronous code. Promises allows one
// to be able to call a function purely with arguments needed for
// execution, without conflating the call with concerns of whether it is
// sync or async. One shouldn't need to alter a call's arguments if the
// implementation switches from sync to async (or vice versa). By having
// async functions return promises, the concerns of making the call are
// separated from the concerns of asynchronous interaction (which are
// handled by the promise).
//
// The Deferred is a type of promise that provides methods for fulfilling the
// promise with a successful result or an error. The most important method for
// working with Dojo's promises is the then() method, which follows the
// CommonJS proposed promise API. An example of using a Dojo promise:
//
// | var resultingPromise = someAsyncOperation.then(function(result){
// | ... handle result ...
// | },
// | function(error){
// | ... handle error ...
// | });
//
// The .then() call returns a new promise that represents the result of the
// execution of the callback. The callbacks will never affect the original promises value.
//
// The Deferred instances also provide the following functions for backwards compatibility:
//
// - addCallback(handler)
// - addErrback(handler)
// - callback(result)
// - errback(result)
//
// Callbacks are allowed to return promises themselves, so
// you can build complicated sequences of events with ease.
//
// The creator of the Deferred may specify a canceller. The canceller
// is a function that will be called if Deferred.cancel is called
// before the Deferred fires. You can use this to implement clean
// aborting of an XMLHttpRequest, etc. Note that cancel will fire the
// deferred with a CancelledError (unless your canceller returns
// another kind of error), so the errbacks should be prepared to
// handle that error for cancellable Deferreds.
// example:
// | var deferred = new Deferred();
// | setTimeout(function(){ deferred.callback({success: true}); }, 1000);
// | return deferred;
// example:
// Deferred objects are often used when making code asynchronous. It
// may be easiest to write functions in a synchronous manner and then
// split code using a deferred to trigger a response to a long-lived
// operation. For example, instead of register a callback function to
// denote when a rendering operation completes, the function can
// simply return a deferred:
//
// | // callback style:
// | function renderLotsOfData(data, callback){
// | var success = false
// | try{
// | for(var x in data){
// | renderDataitem(data[x]);
// | }
// | success = true;
// | }catch(e){ }
// | if(callback){
// | callback(success);
// | }
// | }
//
// | // using callback style
// | renderLotsOfData(someDataObj, function(success){
// | // handles success or failure
// | if(!success){
// | promptUserToRecover();
// | }
// | });
// | // NOTE: no way to add another callback here!!
// example:
// Using a Deferred doesn't simplify the sending code any, but it
// provides a standard interface for callers and senders alike,
// providing both with a simple way to service multiple callbacks for
// an operation and freeing both sides from worrying about details
// such as "did this get called already?". With Deferreds, new
// callbacks can be added at any time.
//
// | // Deferred style:
// | function renderLotsOfData(data){
// | var d = new Deferred();
// | try{
// | for(var x in data){
// | renderDataitem(data[x]);
// | }
// | d.callback(true);
// | }catch(e){
// | d.errback(new Error("rendering failed"));
// | }
// | return d;
// | }
//
// | // using Deferred style
// | renderLotsOfData(someDataObj).then(null, function(){
// | promptUserToRecover();
// | });
// | // NOTE: addErrback and addCallback both return the Deferred
// | // again, so we could chain adding callbacks or save the
// | // deferred for later should we need to be notified again.
// example:
// In this example, renderLotsOfData is synchronous and so both
// versions are pretty artificial. Putting the data display on a
// timeout helps show why Deferreds rock:
//
// | // Deferred style and async func
// | function renderLotsOfData(data){
// | var d = new Deferred();
// | setTimeout(function(){
// | try{
// | for(var x in data){
// | renderDataitem(data[x]);
// | }
// | d.callback(true);
// | }catch(e){
// | d.errback(new Error("rendering failed"));
// | }
// | }, 100);
// | return d;
// | }
//
// | // using Deferred style
// | renderLotsOfData(someDataObj).then(null, function(){
// | promptUserToRecover();
// | });
//
// Note that the caller doesn't have to change his code at all to
// handle the asynchronous case.
var result, finished, canceled, fired, isError, head, nextListener;
var promise = (this.promise = new Promise());
function complete(value){
if(finished){
throw new Error("This deferred has already been resolved");
}
result = value;
finished = true;
notify();
}
function notify(){
var mutated;
while(!mutated && nextListener){
var listener = nextListener;
nextListener = nextListener.next;
if((mutated = (listener.progress == mutator))){ // assignment and check
finished = false;
}
var func = (isError ? listener.error : listener.resolved);
if(has("config-useDeferredInstrumentation")){
if(isError && NewDeferred.instrumentRejected){
NewDeferred.instrumentRejected(result, !!func);
}
}
if(func){
try{
var newResult = func(result);
if (newResult && typeof newResult.then === "function"){
newResult.then(lang.hitch(listener.deferred, "resolve"), lang.hitch(listener.deferred, "reject"), lang.hitch(listener.deferred, "progress"));
continue;
}
var unchanged = mutated && newResult === undefined;
if(mutated && !unchanged){
isError = newResult instanceof Error;
}
listener.deferred[unchanged && isError ? "reject" : "resolve"](unchanged ? result : newResult);
}catch(e){
listener.deferred.reject(e);
}
}else{
if(isError){
listener.deferred.reject(result);
}else{
listener.deferred.resolve(result);
}
}
}
}
this.isResolved = promise.isResolved = function(){
// summary:
// Checks whether the deferred has been resolved.
// returns: Boolean
return fired == 0;
};
this.isRejected = promise.isRejected = function(){
// summary:
// Checks whether the deferred has been rejected.
// returns: Boolean
return fired == 1;
};
this.isFulfilled = promise.isFulfilled = function(){
// summary:
// Checks whether the deferred has been resolved or rejected.
// returns: Boolean
return fired >= 0;
};
this.isCanceled = promise.isCanceled = function(){
// summary:
// Checks whether the deferred has been canceled.
// returns: Boolean
return canceled;
};
// calling resolve will resolve the promise
this.resolve = this.callback = function(value){
// summary:
// Fulfills the Deferred instance successfully with the provide value
this.fired = fired = 0;
this.results = [value, null];
complete(value);
};
// calling error will indicate that the promise failed
this.reject = this.errback = function(error){
// summary:
// Fulfills the Deferred instance as an error with the provided error
isError = true;
this.fired = fired = 1;
if(has("config-useDeferredInstrumentation")){
if(NewDeferred.instrumentRejected){
NewDeferred.instrumentRejected(error, !!nextListener);
}
}
complete(error);
this.results = [null, error];
};
// call progress to provide updates on the progress on the completion of the promise
this.progress = function(update){
// summary:
// Send progress events to all listeners
var listener = nextListener;
while(listener){
var progress = listener.progress;
progress && progress(update);
listener = listener.next;
}
};
this.addCallbacks = function(callback, errback){
// summary:
// Adds callback and error callback for this deferred instance.
// callback: Function?
// The callback attached to this deferred object.
// errback: Function?
// The error callback attached to this deferred object.
// returns:
// Returns this deferred object.
this.then(callback, errback, mutator);
return this; // Deferred
};
// provide the implementation of the promise
promise.then = this.then = function(/*Function?*/resolvedCallback, /*Function?*/errorCallback, /*Function?*/progressCallback){
// summary:
// Adds a fulfilledHandler, errorHandler, and progressHandler to be called for
// completion of a promise. The fulfilledHandler is called when the promise
// is fulfilled. The errorHandler is called when a promise fails. The
// progressHandler is called for progress events. All arguments are optional
// and non-function values are ignored. The progressHandler is not only an
// optional argument, but progress events are purely optional. Promise
// providers are not required to ever create progress events.
//
// This function will return a new promise that is fulfilled when the given
// fulfilledHandler or errorHandler callback is finished. This allows promise
// operations to be chained together. The value returned from the callback
// handler is the fulfillment value for the returned promise. If the callback
// throws an error, the returned promise will be moved to failed state.
//
// returns:
// Returns a new promise that represents the result of the
// execution of the callback. The callbacks will never affect the original promises value.
// example:
// An example of using a CommonJS compliant promise:
// | asyncComputeTheAnswerToEverything().
// | then(addTwo).
// | then(printResult, onError);
// | >44
//
var returnDeferred = progressCallback == mutator ? this : new Deferred(promise.cancel);
var listener = {
resolved: resolvedCallback,
error: errorCallback,
progress: progressCallback,
deferred: returnDeferred
};
if(nextListener){
head = head.next = listener;
}
else{
nextListener = head = listener;
}
if(finished){
notify();
}
return returnDeferred.promise; // Promise
};
var deferred = this;
promise.cancel = this.cancel = function(){
// summary:
// Cancels the asynchronous operation
if(!finished){
var error = canceller && canceller(deferred);
if(!finished){
if (!(error instanceof Error)){
error = new CancelError(error);
}
error.log = false;
deferred.reject(error);
}
}
canceled = true;
};
freeze(promise);
};
lang.extend(Deferred, {
addCallback: function(/*Function*/ callback){
// summary:
// Adds successful callback for this deferred instance.
// returns:
// Returns this deferred object.
return this.addCallbacks(lang.hitch.apply(dojo, arguments)); // Deferred
},
addErrback: function(/*Function*/ errback){
// summary:
// Adds error callback for this deferred instance.
// returns:
// Returns this deferred object.
return this.addCallbacks(null, lang.hitch.apply(dojo, arguments)); // Deferred
},
addBoth: function(/*Function*/ callback){
// summary:
// Add handler as both successful callback and error callback for this deferred instance.
// returns:
// Returns this deferred object.
var enclosed = lang.hitch.apply(dojo, arguments);
return this.addCallbacks(enclosed, enclosed); // Deferred
},
fired: -1
});
Deferred.when = dojo.when = when;
return Deferred;
});

View File

@@ -0,0 +1,350 @@
define(["./kernel", "../has", "./lang"], function(dojo, has, lang){
// module:
// dojo/_base/array
// our old simple function builder stuff
var cache = {}, u;
function buildFn(fn){
return cache[fn] = new Function("item", "index", "array", fn); // Function
}
// magic snippet: if(typeof fn == "string") fn = cache[fn] || buildFn(fn);
// every & some
function everyOrSome(some){
var every = !some;
return function(a, fn, o){
var i = 0, l = a && a.length || 0, result;
if(l && typeof a == "string") a = a.split("");
if(typeof fn == "string") fn = cache[fn] || buildFn(fn);
if(o){
for(; i < l; ++i){
result = !fn.call(o, a[i], i, a);
if(some ^ result){
return !result;
}
}
}else{
for(; i < l; ++i){
result = !fn(a[i], i, a);
if(some ^ result){
return !result;
}
}
}
return every; // Boolean
};
}
// indexOf, lastIndexOf
function index(up){
var delta = 1, lOver = 0, uOver = 0;
if(!up){
delta = lOver = uOver = -1;
}
return function(a, x, from, last){
if(last && delta > 0){
// TODO: why do we use a non-standard signature? why do we need "last"?
return array.lastIndexOf(a, x, from);
}
var l = a && a.length || 0, end = up ? l + uOver : lOver, i;
if(from === u){
i = up ? lOver : l + uOver;
}else{
if(from < 0){
i = l + from;
if(i < 0){
i = lOver;
}
}else{
i = from >= l ? l + uOver : from;
}
}
if(l && typeof a == "string") a = a.split("");
for(; i != end; i += delta){
if(a[i] == x){
return i; // Number
}
}
return -1; // Number
};
}
var array = {
// summary:
// The Javascript v1.6 array extensions.
every: everyOrSome(false),
/*=====
every: function(arr, callback, thisObject){
// summary:
// Determines whether or not every item in arr satisfies the
// condition implemented by callback.
// arr: Array|String
// the array to iterate on. If a string, operates on individual characters.
// callback: Function|String
// a function is invoked with three arguments: item, index,
// and array and returns true if the condition is met.
// thisObject: Object?
// may be used to scope the call to callback
// returns: Boolean
// description:
// This function corresponds to the JavaScript 1.6 Array.every() method, with one difference: when
// run over sparse arrays, this implementation passes the "holes" in the sparse array to
// the callback function with a value of undefined. JavaScript 1.6's every skips the holes in the sparse array.
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/every
// example:
// | // returns false
// | array.every([1, 2, 3, 4], function(item){ return item>1; });
// example:
// | // returns true
// | array.every([1, 2, 3, 4], function(item){ return item>0; });
},
=====*/
some: everyOrSome(true),
/*=====
some: function(arr, callback, thisObject){
// summary:
// Determines whether or not any item in arr satisfies the
// condition implemented by callback.
// arr: Array|String
// the array to iterate over. If a string, operates on individual characters.
// callback: Function|String
// a function is invoked with three arguments: item, index,
// and array and returns true if the condition is met.
// thisObject: Object?
// may be used to scope the call to callback
// returns: Boolean
// description:
// This function corresponds to the JavaScript 1.6 Array.some() method, with one difference: when
// run over sparse arrays, this implementation passes the "holes" in the sparse array to
// the callback function with a value of undefined. JavaScript 1.6's some skips the holes in the sparse array.
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/some
// example:
// | // is true
// | array.some([1, 2, 3, 4], function(item){ return item>1; });
// example:
// | // is false
// | array.some([1, 2, 3, 4], function(item){ return item<1; });
},
=====*/
indexOf: index(true),
/*=====
indexOf: function(arr, value, fromIndex, findLast){
// summary:
// locates the first index of the provided value in the
// passed array. If the value is not found, -1 is returned.
// description:
// This method corresponds to the JavaScript 1.6 Array.indexOf method, with two differences:
//
// 1. when run over sparse arrays, the Dojo function invokes the callback for every index
// whereas JavaScript 1.6's indexOf skips the holes in the sparse array.
// 2. uses equality (==) rather than strict equality (===)
//
// For details on this method, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/indexOf
// arr: Array
// value: Object
// fromIndex: Integer?
// findLast: Boolean?
// Makes indexOf() work like lastIndexOf(). Used internally; not meant for external usage.
// returns: Number
},
=====*/
lastIndexOf: index(false),
/*=====
lastIndexOf: function(arr, value, fromIndex){
// summary:
// locates the last index of the provided value in the passed
// array. If the value is not found, -1 is returned.
// description:
// This method corresponds to the JavaScript 1.6 Array.lastIndexOf method, with two differences:
//
// 1. when run over sparse arrays, the Dojo function invokes the callback for every index
// whereas JavaScript 1.6's lasIndexOf skips the holes in the sparse array.
// 2. uses equality (==) rather than strict equality (===)
//
// For details on this method, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/lastIndexOf
// arr: Array,
// value: Object,
// fromIndex: Integer?
// returns: Number
},
=====*/
forEach: function(arr, callback, thisObject){
// summary:
// for every item in arr, callback is invoked. Return values are ignored.
// If you want to break out of the loop, consider using array.every() or array.some().
// forEach does not allow breaking out of the loop over the items in arr.
// arr:
// the array to iterate over. If a string, operates on individual characters.
// callback:
// a function is invoked with three arguments: item, index, and array
// thisObject:
// may be used to scope the call to callback
// description:
// This function corresponds to the JavaScript 1.6 Array.forEach() method, with one difference: when
// run over sparse arrays, this implementation passes the "holes" in the sparse array to
// the callback function with a value of undefined. JavaScript 1.6's forEach skips the holes in the sparse array.
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/forEach
// example:
// | // log out all members of the array:
// | array.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | function(item){
// | console.log(item);
// | }
// | );
// example:
// | // log out the members and their indexes
// | array.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | function(item, idx, arr){
// | console.log(item, "at index:", idx);
// | }
// | );
// example:
// | // use a scoped object member as the callback
// |
// | var obj = {
// | prefix: "logged via obj.callback:",
// | callback: function(item){
// | console.log(this.prefix, item);
// | }
// | };
// |
// | // specifying the scope function executes the callback in that scope
// | array.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | obj.callback,
// | obj
// | );
// |
// | // alternately, we can accomplish the same thing with lang.hitch()
// | array.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | lang.hitch(obj, "callback")
// | );
// arr: Array|String
// callback: Function|String
// thisObject: Object?
var i = 0, l = arr && arr.length || 0;
if(l && typeof arr == "string") arr = arr.split("");
if(typeof callback == "string") callback = cache[callback] || buildFn(callback);
if(thisObject){
for(; i < l; ++i){
callback.call(thisObject, arr[i], i, arr);
}
}else{
for(; i < l; ++i){
callback(arr[i], i, arr);
}
}
},
map: function(arr, callback, thisObject, Ctr){
// summary:
// applies callback to each element of arr and returns
// an Array with the results
// arr: Array|String
// the array to iterate on. If a string, operates on
// individual characters.
// callback: Function|String
// a function is invoked with three arguments, (item, index,
// array), and returns a value
// thisObject: Object?
// may be used to scope the call to callback
// returns: Array
// description:
// This function corresponds to the JavaScript 1.6 Array.map() method, with one difference: when
// run over sparse arrays, this implementation passes the "holes" in the sparse array to
// the callback function with a value of undefined. JavaScript 1.6's map skips the holes in the sparse array.
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
// example:
// | // returns [2, 3, 4, 5]
// | array.map([1, 2, 3, 4], function(item){ return item+1 });
// TODO: why do we have a non-standard signature here? do we need "Ctr"?
var i = 0, l = arr && arr.length || 0, out = new (Ctr || Array)(l);
if(l && typeof arr == "string") arr = arr.split("");
if(typeof callback == "string") callback = cache[callback] || buildFn(callback);
if(thisObject){
for(; i < l; ++i){
out[i] = callback.call(thisObject, arr[i], i, arr);
}
}else{
for(; i < l; ++i){
out[i] = callback(arr[i], i, arr);
}
}
return out; // Array
},
filter: function(arr, callback, thisObject){
// summary:
// Returns a new Array with those items from arr that match the
// condition implemented by callback.
// arr: Array
// the array to iterate over.
// callback: Function|String
// a function that is invoked with three arguments (item,
// index, array). The return of this function is expected to
// be a boolean which determines whether the passed-in item
// will be included in the returned array.
// thisObject: Object?
// may be used to scope the call to callback
// returns: Array
// description:
// This function corresponds to the JavaScript 1.6 Array.filter() method, with one difference: when
// run over sparse arrays, this implementation passes the "holes" in the sparse array to
// the callback function with a value of undefined. JavaScript 1.6's filter skips the holes in the sparse array.
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
// example:
// | // returns [2, 3, 4]
// | array.filter([1, 2, 3, 4], function(item){ return item>1; });
// TODO: do we need "Ctr" here like in map()?
var i = 0, l = arr && arr.length || 0, out = [], value;
if(l && typeof arr == "string") arr = arr.split("");
if(typeof callback == "string") callback = cache[callback] || buildFn(callback);
if(thisObject){
for(; i < l; ++i){
value = arr[i];
if(callback.call(thisObject, value, i, arr)){
out.push(value);
}
}
}else{
for(; i < l; ++i){
value = arr[i];
if(callback(value, i, arr)){
out.push(value);
}
}
}
return out; // Array
},
clearCache: function(){
cache = {};
}
};
has("extend-dojo") && lang.mixin(dojo, array);
return array;
});

View File

@@ -0,0 +1,193 @@
define(["../has", "require"], function(has, require){
// module:
// dojo/_base/config
/*=====
return {
// summary:
// This module defines the user configuration during bootstrap.
// description:
// By defining user configuration as a module value, an entire configuration can be specified in a build,
// thereby eliminating the need for sniffing and or explicitly setting in the global variable dojoConfig.
// Also, when multiple instances of dojo exist in a single application, each will necessarily be located
// at an unique absolute module identifier as given by the package configuration. Implementing configuration
// as a module allows for specifying unique, per-instance configurations.
// example:
// Create a second instance of dojo with a different, instance-unique configuration (assume the loader and
// dojo.js are already loaded).
// | // specify a configuration that creates a new instance of dojo at the absolute module identifier "myDojo"
// | require({
// | packages:[{
// | name:"myDojo",
// | location:".", //assume baseUrl points to dojo.js
// | }]
// | });
// |
// | // specify a configuration for the myDojo instance
// | define("myDojo/config", {
// | // normal configuration variables go here, e.g.,
// | locale:"fr-ca"
// | });
// |
// | // load and use the new instance of dojo
// | require(["myDojo"], function(dojo){
// | // dojo is the new instance of dojo
// | // use as required
// | });
// 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,
// 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: [deprecated] 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. Specifying
// `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent
// of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple
// modules may be configured via `djConfig.modulePaths`.
modulePaths: {},
// addOnLoad: Function|Array
// Adds a callback via dojo/ready. Useful when Dojo is added after
// the page loads and djConfig.afterOnLoad is true. Supports the same
// arguments as dojo/ready. 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,
// parseOnLoad: Boolean
// Run the parser after the page is loaded
parseOnLoad: false,
// require: String[]
// An array of module names to be loaded immediately after dojo.js has been included
// in a page.
require: [],
// defaultDuration: Number
// 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/topic.publish(). See dojo/main.__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,
// deps: Function|Array
// Defines dependencies to be used before the loader has been loaded.
// When provided, they cause the loader to execute require(deps, callback)
// once it has finished loading. Should be used with callback.
deps: undefined,
// callback: Function|Array
// Defines a callback to be used when dependencies are defined before
// the loader has been loaded. When provided, they cause the loader to
// execute require(deps, callback) once it has finished loading.
// Should be used with deps.
callback: undefined,
// deferredInstrumentation: Boolean
// Whether deferred instrumentation should be loaded or included
// in builds.
deferredInstrumentation: true,
// useDeferredInstrumentation: Boolean|String
// Whether the deferred instrumentation should be used.
//
// * `"report-rejections"`: report each rejection as it occurs.
// * `true` or `1` or `"report-unhandled-rejections"`: wait 1 second
// in an attempt to detect unhandled rejections.
useDeferredInstrumentation: "report-unhandled-rejections"
};
=====*/
var result = {};
if(has("dojo-config-api")){
// must be the dojo loader; take a shallow copy of require.rawConfig
var src = require.rawConfig, p;
for(p in src){
result[p] = src[p];
}
}else{
var adviseHas = function(featureSet, prefix, booting){
for(p in featureSet){
p!="has" && has.add(prefix + p, featureSet[p], 0, booting);
}
};
result = has("dojo-loader") ?
// must be a built version of the dojo loader; all config stuffed in require.rawConfig
require.rawConfig :
// a foreign loader
this.dojoConfig || this.djConfig || {};
adviseHas(result, "config", 1);
adviseHas(result.has, "", 1);
}
if(!result.locale && typeof navigator != "undefined"){
// Default locale for browsers.
result.locale = (navigator.language || navigator.userLanguage).toLowerCase();
}
return result;
});

View File

@@ -0,0 +1,374 @@
define(["./kernel", "../on", "../topic", "../aspect", "./event", "../mouse", "./sniff", "./lang", "../keys"], function(dojo, on, hub, aspect, eventModule, mouse, has, lang){
// module:
// dojo/_base/connect
has.add("events-keypress-typed", function(){ // keypresses should only occur a printable character is hit
var testKeyEvent = {charCode: 0};
try{
testKeyEvent = document.createEvent("KeyboardEvent");
(testKeyEvent.initKeyboardEvent || testKeyEvent.initKeyEvent).call(testKeyEvent, "keypress", true, true, null, false, false, false, false, 9, 3);
}catch(e){}
return testKeyEvent.charCode == 0 && !has("opera");
});
function connect_(obj, event, context, method, dontFix){
method = lang.hitch(context, method);
if(!obj || !(obj.addEventListener || obj.attachEvent)){
// it is a not a DOM node and we are using the dojo.connect style of treating a
// method like an event, must go right to aspect
return aspect.after(obj || dojo.global, event, method, true);
}
if(typeof event == "string" && event.substring(0, 2) == "on"){
event = event.substring(2);
}
if(!obj){
obj = dojo.global;
}
if(!dontFix){
switch(event){
// dojo.connect has special handling for these event types
case "keypress":
event = keypress;
break;
case "mouseenter":
event = mouse.enter;
break;
case "mouseleave":
event = mouse.leave;
break;
}
}
return on(obj, event, method, dontFix);
}
var _punctMap = {
106:42,
111:47,
186:59,
187:43,
188:44,
189:45,
190:46,
191:47,
192:96,
219:91,
220:92,
221:93,
222:39,
229:113
};
var evtCopyKey = has("mac") ? "metaKey" : "ctrlKey";
var _synthesizeEvent = function(evt, props){
var faux = lang.mixin({}, evt, props);
setKeyChar(faux);
// FIXME: would prefer to use lang.hitch: lang.hitch(evt, evt.preventDefault);
// but it throws an error when preventDefault is invoked on Safari
// does Event.preventDefault not support "apply" on Safari?
faux.preventDefault = function(){ evt.preventDefault(); };
faux.stopPropagation = function(){ evt.stopPropagation(); };
return faux;
};
function setKeyChar(evt){
evt.keyChar = evt.charCode ? String.fromCharCode(evt.charCode) : '';
evt.charOrCode = evt.keyChar || evt.keyCode;
}
var keypress;
if(has("events-keypress-typed")){
// this emulates Firefox's keypress behavior where every keydown can correspond to a keypress
var _trySetKeyCode = function(e, code){
try{
// squelch errors when keyCode is read-only
// (e.g. if keyCode is ctrl or shift)
return (e.keyCode = code);
}catch(e){
return 0;
}
};
keypress = function(object, listener){
var keydownSignal = on(object, "keydown", function(evt){
// munge key/charCode
var k=evt.keyCode;
// These are Windows Virtual Key Codes
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
var unprintable = (k!=13) && k!=32 && (k!=27||!has("ie")) && (k<48||k>90) && (k<96||k>111) && (k<186||k>192) && (k<219||k>222) && k!=229;
// synthesize keypress for most unprintables and CTRL-keys
if(unprintable||evt.ctrlKey){
var c = unprintable ? 0 : k;
if(evt.ctrlKey){
if(k==3 || k==13){
return listener.call(evt.currentTarget, evt); // IE will post CTRL-BREAK, CTRL-ENTER as keypress natively
}else if(c>95 && c<106){
c -= 48; // map CTRL-[numpad 0-9] to ASCII
}else if((!evt.shiftKey)&&(c>=65&&c<=90)){
c += 32; // map CTRL-[A-Z] to lowercase
}else{
c = _punctMap[c] || c; // map other problematic CTRL combinations to ASCII
}
}
// simulate a keypress event
var faux = _synthesizeEvent(evt, {type: 'keypress', faux: true, charCode: c});
listener.call(evt.currentTarget, faux);
if(has("ie")){
_trySetKeyCode(evt, faux.keyCode);
}
}
});
var keypressSignal = on(object, "keypress", function(evt){
var c = evt.charCode;
c = c>=32 ? c : 0;
evt = _synthesizeEvent(evt, {charCode: c, faux: true});
return listener.call(this, evt);
});
return {
remove: function(){
keydownSignal.remove();
keypressSignal.remove();
}
};
};
}else{
if(has("opera")){
keypress = function(object, listener){
return on(object, "keypress", function(evt){
var c = evt.which;
if(c==3){
c=99; // Mozilla maps CTRL-BREAK to CTRL-c
}
// can't trap some keys at all, like INSERT and DELETE
// there is no differentiating info between DELETE and ".", or INSERT and "-"
c = c<32 && !evt.shiftKey ? 0 : c;
if(evt.ctrlKey && !evt.shiftKey && c>=65 && c<=90){
// lowercase CTRL-[A-Z] keys
c += 32;
}
return listener.call(this, _synthesizeEvent(evt, { charCode: c }));
});
};
}else{
keypress = function(object, listener){
return on(object, "keypress", function(evt){
setKeyChar(evt);
return listener.call(this, evt);
});
};
}
}
var connect = {
// summary:
// This module defines the dojo.connect API.
// This modules also provides keyboard event handling helpers.
// This module exports an extension event for emulating Firefox's keypress handling.
// However, this extension event exists primarily for backwards compatibility and
// is not recommended. WebKit and IE uses an alternate keypress handling (only
// firing for printable characters, to distinguish from keydown events), and most
// consider the WebKit/IE behavior more desirable.
_keypress:keypress,
connect:function(obj, event, context, method, dontFix){
// summary:
// `dojo.connect` is a deprecated event handling and delegation method in
// Dojo. It allows one function to "listen in" on the execution of
// any other, triggering the second whenever the first is called. Many
// listeners may be attached to a function, and source functions may
// be either regular function calls or DOM events.
//
// description:
// Connects listeners to actions, so that after event fires, a
// listener is called with the same arguments passed to the original
// function.
//
// Since `dojo.connect` allows the source of events to be either a
// "regular" JavaScript function or a DOM event, it provides a uniform
// interface for listening to all the types of events that an
// application is likely to deal with though a single, unified
// interface. DOM programmers may want to think of it as
// "addEventListener for everything and anything".
//
// When setting up a connection, the `event` parameter must be a
// string that is the name of the method/event to be listened for. If
// `obj` is null, `kernel.global` is assumed, meaning that connections
// to global methods are supported but also that you may inadvertently
// connect to a global by passing an incorrect object name or invalid
// reference.
//
// `dojo.connect` generally is forgiving. If you pass the name of a
// function or method that does not yet exist on `obj`, connect will
// not fail, but will instead set up a stub method. Similarly, null
// arguments may simply be omitted such that fewer than 4 arguments
// may be required to set up a connection See the examples for details.
//
// The return value is a handle that is needed to
// remove this connection with `dojo.disconnect`.
//
// obj: Object?
// The source object for the event function.
// Defaults to `kernel.global` if null.
// If obj is a DOM node, the connection is delegated
// to the DOM event manager (unless dontFix is true).
//
// event: String
// String name of the event function in obj.
// I.e. identifies a property `obj[event]`.
//
// context: Object|null
// The object that method will receive as "this".
//
// If context is null and method is a function, then method
// inherits the context of event.
//
// If method is a string then context must be the source
// object object for method (context[method]). If context is null,
// kernel.global is used.
//
// method: String|Function
// A function reference, or name of a function in context.
// The function identified by method fires after event does.
// method receives the same arguments as the event.
// See context argument comments for information on method's scope.
//
// dontFix: Boolean?
// If obj is a DOM node, set dontFix to true to prevent delegation
// of this connection to the DOM event manager.
//
// example:
// When obj.onchange(), do ui.update():
// | dojo.connect(obj, "onchange", ui, "update");
// | dojo.connect(obj, "onchange", ui, ui.update); // same
//
// example:
// Using return value for disconnect:
// | var link = dojo.connect(obj, "onchange", ui, "update");
// | ...
// | dojo.disconnect(link);
//
// example:
// When onglobalevent executes, watcher.handler is invoked:
// | dojo.connect(null, "onglobalevent", watcher, "handler");
//
// example:
// When ob.onCustomEvent executes, customEventHandler is invoked:
// | dojo.connect(ob, "onCustomEvent", null, "customEventHandler");
// | dojo.connect(ob, "onCustomEvent", "customEventHandler"); // same
//
// example:
// When ob.onCustomEvent executes, customEventHandler is invoked
// with the same scope (this):
// | dojo.connect(ob, "onCustomEvent", null, customEventHandler);
// | dojo.connect(ob, "onCustomEvent", customEventHandler); // same
//
// example:
// When globalEvent executes, globalHandler is invoked
// with the same scope (this):
// | dojo.connect(null, "globalEvent", null, globalHandler);
// | dojo.connect("globalEvent", globalHandler); // same
// normalize arguments
var a=arguments, args=[], i=0;
// if a[0] is a String, obj was omitted
args.push(typeof a[0] == "string" ? null : a[i++], a[i++]);
// if the arg-after-next is a String or Function, context was NOT omitted
var a1 = a[i+1];
args.push(typeof a1 == "string" || typeof a1 == "function" ? a[i++] : null, a[i++]);
// absorb any additional arguments
for(var l=a.length; i<l; i++){ args.push(a[i]); }
return connect_.apply(this, args);
},
disconnect:function(handle){
// summary:
// Remove a link created by dojo.connect.
// description:
// Removes the connection between event and the method referenced by handle.
// handle: Handle
// the return value of the dojo.connect call that created the connection.
if(handle){
handle.remove();
}
},
subscribe:function(topic, context, method){
// summary:
// Attach a listener to a named topic. The listener function is invoked whenever the
// named topic is published (see: dojo.publish).
// Returns a handle which is needed to unsubscribe this listener.
// topic: String
// The topic to which to subscribe.
// context: Object?
// Scope in which method will be invoked, or null for default scope.
// method: String|Function
// The name of a function in context, or a function reference. This is the function that
// is invoked when topic is published.
// example:
// | dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); });
// | dojo.publish("alerts", [ "read this", "hello world" ]);
return hub.subscribe(topic, lang.hitch(context, method));
},
publish:function(topic, args){
// summary:
// Invoke all listener method subscribed to topic.
// topic: String
// The name of the topic to publish.
// args: Array?
// An array of arguments. The arguments will be applied
// to each topic subscriber (as first class parameters, via apply).
// example:
// | dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); };
// | dojo.publish("alerts", [ "read this", "hello world" ]);
return hub.publish.apply(hub, [topic].concat(args));
},
connectPublisher:function(topic, obj, event){
// summary:
// Ensure that every time obj.event() is called, a message is published
// on the topic. Returns a handle which can be passed to
// dojo.disconnect() to disable subsequent automatic publication on
// the topic.
// topic: String
// The name of the topic to publish.
// obj: Object?
// The source object for the event function. Defaults to kernel.global
// if null.
// event: String
// The name of the event function in obj.
// I.e. identifies a property obj[event].
// example:
// | dojo.connectPublisher("/ajax/start", dojo, "xhrGet");
var pf = function(){ connect.publish(topic, arguments); };
return event ? connect.connect(obj, event, pf) : connect.connect(obj, pf); //Handle
},
isCopyKey: function(e){
// summary:
// Checks an event for the copy key (meta on Mac, and ctrl anywhere else)
// e: Event
// Event object to examine
return e[evtCopyKey]; // Boolean
}
};
connect.unsubscribe = connect.disconnect;
/*=====
connect.unsubscribe = function(handle){
// summary:
// Remove a topic listener.
// handle: Handle
// The handle returned from a call to subscribe.
// example:
// | var alerter = dojo.subscribe("alerts", null, function(caption, message){ alert(caption + "\n" + message); };
// | ...
// | dojo.unsubscribe(alerter);
};
=====*/
has("extend-dojo") && lang.mixin(dojo, connect);
return connect;
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
define(["./kernel", "../on", "../has", "../dom-geometry"], function(dojo, on, has, dom){
// module:
// dojo/_base/event
if(on._fixEvent){
var fixEvent = on._fixEvent;
on._fixEvent = function(evt, se){
// add some additional normalization for back-compat, this isn't in on.js because it is somewhat more expensive
evt = fixEvent(evt, se);
if(evt){
dom.normalizeEvent(evt);
}
return evt;
};
}
var ret = {
// summary:
// This module defines dojo DOM event API. Usually you should use dojo/on, and evt.stopPropagation() +
// evt.preventDefault(), rather than this module.
fix: function(/*Event*/ evt, /*DOMNode*/ sender){
// summary:
// normalizes properties on the event object including event
// bubbling methods, keystroke normalization, and x/y positions
// evt: Event
// native event object
// sender: DOMNode
// node to treat as "currentTarget"
if(on._fixEvent){
return on._fixEvent(evt, sender);
}
return evt; // Event
},
stop: function(/*Event*/ evt){
// summary:
// prevents propagation and clobbers the default action of the
// passed event
// evt: Event
// The event object. If omitted, window.event is used on IE.
if(has("dom-addeventlistener") || (evt && evt.preventDefault)){
evt.preventDefault();
evt.stopPropagation();
}else{
evt = evt || window.event;
evt.cancelBubble = true;
on._preventDefault.call(evt);
}
}
};
if(has("extend-dojo")){
dojo.fixEvent = ret.fix;
dojo.stopEvent = ret.stop;
}
return ret;
});

View File

@@ -0,0 +1,299 @@
define(["../has", "./config", "require", "module"], function(has, config, require, module){
// module:
// dojo/_base/kernel
// This module is the foundational module of the dojo boot sequence; it defines the dojo object.
var
// loop variables for this module
i, p,
// create dojo, dijit, and dojox
// FIXME: in 2.0 remove dijit, dojox being created by dojo
dijit = {},
dojox = {},
dojo = {
// summary:
// This module is the foundational module of the dojo boot sequence; it defines the dojo object.
// notice dojo takes ownership of the value of the config module
config:config,
global:this,
dijit:dijit,
dojox:dojox
};
// Configure the scope map. For a 100% AMD application, the scope map is not needed other than to provide
// a _scopeName property for the dojo, dijit, and dojox root object so those packages can create
// unique names in the global space.
//
// Built, legacy modules use the scope map to allow those modules to be expressed as if dojo, dijit, and dojox,
// where global when in fact they are either global under different names or not global at all. In v1.6-, the
// config variable "scopeMap" was used to map names as used within a module to global names. This has been
// subsumed by the AMD map configuration variable which can relocate packages to different names. For backcompat,
// only the "*" mapping is supported. See http://livedocs.dojotoolkit.org/developer/design/loader#legacy-cross-domain-mode for details.
//
// The following computations contort the packageMap for this dojo instance into a scopeMap.
var scopeMap =
// a map from a name used in a legacy module to the (global variable name, object addressed by that name)
// always map dojo, dijit, and dojox
{
dojo:["dojo", dojo],
dijit:["dijit", dijit],
dojox:["dojox", dojox]
},
packageMap =
// the package map for this dojo instance; note, a foreign loader or no pacakgeMap results in the above default config
(require.map && require.map[module.id.match(/[^\/]+/)[0]]),
item;
// process all mapped top-level names for this instance of dojo
for(p in packageMap){
if(scopeMap[p]){
// mapped dojo, dijit, or dojox
scopeMap[p][0] = packageMap[p];
}else{
// some other top-level name
scopeMap[p] = [packageMap[p], {}];
}
}
// publish those names to _scopeName and, optionally, the global namespace
for(p in scopeMap){
item = scopeMap[p];
item[1]._scopeName = item[0];
if(!config.noGlobals){
this[item[0]] = item[1];
}
}
dojo.scopeMap = scopeMap;
/*===== dojo.__docParserConfigureScopeMap(scopeMap); =====*/
// FIXME: dojo.baseUrl and dojo.config.baseUrl should be deprecated
dojo.baseUrl = dojo.config.baseUrl = require.baseUrl;
dojo.isAsync = !has("dojo-loader") || require.async;
dojo.locale = config.locale;
var rev = "$Rev: 43d05c6 $".match(/\d+/);
dojo.version = {
// summary:
// Version number of the Dojo Toolkit
// description:
// Hash about the version, including
//
// - 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
major: 1, minor: 9, patch: 1, flag: "",
revision: rev ? +rev[0] : NaN,
toString: function(){
var v = dojo.version;
return v.major + "." + v.minor + "." + v.patch + v.flag + " (" + v.revision + ")"; // String
}
};
// If has("extend-dojo") is truthy, then as a dojo module is defined it should push it's definitions
// into the dojo object, and conversely. In 2.0, it will likely be unusual to augment another object
// as a result of defining a module. This has feature gives a way to force 2.0 behavior as the code
// is migrated. Absent specific advice otherwise, set extend-dojo to truthy.
has.add("extend-dojo", 1);
(Function("d", "d.eval = function(){return d.global.eval ? d.global.eval(arguments[0]) : eval(arguments[0]);}"))(dojo);
/*=====
dojo.eval = function(scriptText){
// summary:
// A legacy method created for use exclusively by internal Dojo methods. Do not use this method
// directly unless you understand its possibly-different implications on the platforms your are targeting.
// description:
// Makes an attempt to evaluate scriptText in the global scope. The function works correctly for browsers
// that support indirect eval.
//
// As usual, IE does not. On IE, the only way to implement global eval is to
// use execScript. Unfortunately, execScript does not return a value and breaks some current usages of dojo.eval.
// This implementation uses the technique of executing eval in the scope of a function that is a single scope
// frame below the global scope; thereby coming close to the global scope. Note carefully that
//
// dojo.eval("var pi = 3.14;");
//
// will define global pi in non-IE environments, but define pi only in a temporary local scope for IE. If you want
// to define a global variable using dojo.eval, write something like
//
// dojo.eval("window.pi = 3.14;")
// scriptText:
// The text to evaluation.
// returns:
// The result of the evaluation. Often `undefined`
};
=====*/
if(has("host-rhino")){
dojo.exit = function(exitcode){
quit(exitcode);
};
}else{
dojo.exit = function(){
};
}
has.add("dojo-guarantee-console",
// ensure that console.log, console.warn, etc. are defined
1
);
if(has("dojo-guarantee-console")){
typeof console != "undefined" || (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 tn;
i = 0;
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;
})();
}
}
}
has.add("dojo-debug-messages",
// include dojo.deprecated/dojo.experimental implementations
!!config.isDebug
);
dojo.deprecated = dojo.experimental = function(){};
if(has("dojo-debug-messages")){
dojo.deprecated = function(/*String*/ behaviour, /*String?*/ extra, /*String?*/ 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");
var message = "DEPRECATED: " + behaviour;
if(extra){ message += " " + extra; }
if(removal){ message += " -- will be removed in version: " + removal; }
console.warn(message);
};
dojo.experimental = function(/* String */ moduleName, /* String? */ 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");
var message = "EXPERIMENTAL: " + moduleName + " -- APIs subject to change without notice.";
if(extra){ message += " " + extra; }
console.warn(message);
};
}
has.add("dojo-modulePaths",
// consume dojo.modulePaths processing
1
);
if(has("dojo-modulePaths")){
// notice that modulePaths won't be applied to any require's before the dojo/_base/kernel factory is run;
// this is the v1.6- behavior.
if(config.modulePaths){
dojo.deprecated("dojo.modulePaths", "use paths configuration");
var paths = {};
for(p in config.modulePaths){
paths[p.replace(/\./g, "/")] = config.modulePaths[p];
}
require({paths:paths});
}
}
has.add("dojo-moduleUrl",
// include dojo.moduleUrl
1
);
if(has("dojo-moduleUrl")){
dojo.moduleUrl = function(/*String*/module, /*String?*/url){
// summary:
// Returns a URL relative to a module.
// example:
// | var pngPath = dojo.moduleUrl("acme","images/small.png");
// | console.dir(pngPath); // list the object properties
// | // create an image and set it's source to pngPath's value:
// | var img = document.createElement("img");
// | img.src = pngPath;
// | // add our image to the document
// | dojo.body().appendChild(img);
// example:
// you may de-reference as far as you like down the package
// hierarchy. This is sometimes handy to avoid lenghty relative
// urls or for building portable sub-packages. In this example,
// the `acme.widget` and `acme.util` directories may be located
// under different roots (see `dojo.registerModulePath`) but the
// the modules which reference them can be unaware of their
// relative locations on the filesystem:
// | // somewhere in a configuration block
// | dojo.registerModulePath("acme.widget", "../../acme/widget");
// | dojo.registerModulePath("acme.util", "../../util");
// |
// | // ...
// |
// | // code in a module using acme resources
// | var tmpltPath = dojo.moduleUrl("acme.widget","templates/template.html");
// | var dataPath = dojo.moduleUrl("acme.util","resources/data.json");
dojo.deprecated("dojo.moduleUrl()", "use require.toUrl", "2.0");
// require.toUrl requires a filetype; therefore, just append the suffix "/*.*" to guarantee a filetype, then
// remove the suffix from the result. This way clients can request a url w/out a filetype. This should be
// rare, but it maintains backcompat for the v1.x line (note: dojo.moduleUrl will be removed in v2.0).
// Notice * is an illegal filename so it won't conflict with any real path map that may exist the paths config.
var result = null;
if(module){
result = require.toUrl(module.replace(/\./g, "/") + (url ? ("/" + url) : "") + "/*.*").replace(/\/\*\.\*/, "") + (url ? "" : "/");
}
return result;
};
}
dojo._hasResource = {}; // for backward compatibility with layers built with 1.6 tooling
return dojo;
});

View File

@@ -0,0 +1,605 @@
define(["./kernel", "../has", "../sniff"], function(dojo, has){
// module:
// dojo/_base/lang
has.add("bug-for-in-skips-shadowed", function(){
// if true, the for-in iterator skips object properties that exist in Object's prototype (IE 6 - ?)
for(var i in {toString: 1}){
return 0;
}
return 1;
});
// Helper methods
var _extraNames =
has("bug-for-in-skips-shadowed") ?
"hasOwnProperty.valueOf.isPrototypeOf.propertyIsEnumerable.toLocaleString.toString.constructor".split(".") : [],
_extraLen = _extraNames.length,
getProp = function(/*Array*/parts, /*Boolean*/create, /*Object*/context){
var p, i = 0, dojoGlobal = dojo.global;
if(!context){
if(!parts.length){
return dojoGlobal;
}else{
p = parts[i++];
try{
context = dojo.scopeMap[p] && dojo.scopeMap[p][1];
}catch(e){}
context = context || (p in dojoGlobal ? dojoGlobal[p] : (create ? dojoGlobal[p] = {} : undefined));
}
}
while(context && (p = parts[i++])){
context = (p in context ? context[p] : (create ? context[p] = {} : undefined));
}
return context; // mixed
},
opts = Object.prototype.toString,
efficient = function(obj, offset, startWith){
return (startWith||[]).concat(Array.prototype.slice.call(obj, offset||0));
},
_pattern = /\{([^\}]+)\}/g;
// Module export
var lang = {
// summary:
// This module defines Javascript language extensions.
// _extraNames: String[]
// Lists property names that must be explicitly processed during for-in iteration
// in environments that have has("bug-for-in-skips-shadowed") true.
_extraNames:_extraNames,
_mixin: function(dest, source, copyFunc){
// summary:
// Copies/adds all properties of source to dest; returns dest.
// dest: Object
// The object to which to copy/add all properties contained in source.
// source: Object
// The object from which to draw all properties to copy into dest.
// copyFunc: Function?
// The process used to copy/add a property in source; defaults to the Javascript assignment operator.
// returns:
// dest, as modified
// description:
// All properties, including functions (sometimes termed "methods"), excluding any non-standard extensions
// found in Object.prototype, are copied/added to dest. Copying/adding each particular property is
// delegated to copyFunc (if any); copyFunc defaults to the Javascript assignment operator if not provided.
// Notice that by default, _mixin executes a so-called "shallow copy" and aggregate types are copied/added by reference.
var name, s, i, empty = {};
for(name in source){
// the (!(name in empty) || empty[name] !== s) condition avoids copying properties in "source"
// inherited from Object.prototype. For example, if dest 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 dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){
dest[name] = copyFunc ? copyFunc(s) : s;
}
}
if(has("bug-for-in-skips-shadowed")){
if(source){
for(i = 0; i < _extraLen; ++i){
name = _extraNames[i];
s = source[name];
if(!(name in dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){
dest[name] = copyFunc ? copyFunc(s) : s;
}
}
}
}
return dest; // Object
},
mixin: function(dest, sources){
// summary:
// Copies/adds all properties of one or more sources to dest; returns dest.
// dest: Object
// The object to which to copy/add all properties contained in source. If dest is falsy, then
// a new object is manufactured before copying/adding properties begins.
// sources: Object...
// One of more objects from which to draw all properties to copy into dest. sources are processed
// left-to-right and if more than one of these objects contain the same property name, the right-most
// value "wins".
// returns: Object
// dest, as modified
// description:
// All properties, including functions (sometimes termed "methods"), excluding any non-standard extensions
// found in Object.prototype, are copied/added from sources to dest. sources are processed left to right.
// The Javascript assignment operator is used to copy/add each property; therefore, by default, mixin
// executes a so-called "shallow copy" and aggregate types are copied/added by reference.
// example:
// make a shallow copy of an object
// | var copy = lang.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 `lang.mixin` on the `this` object:
// | declare("acme.Base", null, {
// | constructor: function(properties){
// | // property configuration:
// | lang.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 = lang.mixin(
// | {
// | name: "Frylock",
// | braces: true
// | },
// | {
// | name: "Carl Brutanananadilewski"
// | }
// | );
// |
// | // will print "Carl Brutanananadilewski"
// | console.log(flattened.name);
// | // will print "true"
// | console.log(flattened.braces);
if(!dest){ dest = {}; }
for(var i = 1, l = arguments.length; i < l; i++){
lang._mixin(dest, arguments[i]);
}
return dest; // Object
},
setObject: function(name, value, 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: String
// Path to a property, in the form "A.B.C".
// value: anything
// value or object to place at location given by name
// context: Object?
// 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:
// | lang.setObject("foo.bar.baz", value);
// example:
// without `lang.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";
// whereas with `lang.setObject`, we can shorten that to:
// | lang.setObject("parent.child.prop", "some value", obj);
var parts = name.split("."), p = parts.pop(), obj = getProp(parts, true, context);
return obj && p ? (obj[p] = value) : undefined; // Object
},
getObject: function(name, create, 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: String
// Path to an property, in the form "A.B.C".
// create: Boolean?
// Optional. Defaults to `false`. If `true`, Objects will be
// created at any point along the 'path' that is undefined.
// context: Object?
// Optional. Object to use as root of path. Defaults to
// 'dojo.global'. Null may be passed.
return getProp(name.split("."), create, context); // Object
},
exists: function(name, 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 for object and method detection.
// name: String
// Path to an object, in the form "A.B.C".
// obj: Object?
// 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
// | lang.exists("foo.bar"); // true
// | lang.exists("foo.bar.baz"); // false
// |
// | // search from a particular scope
// | lang.exists("bar", foo); // true
// | lang.exists("bar.baz", foo); // false
return lang.getObject(name, false, obj) !== undefined; // Boolean
},
// Crockford (ish) functions
isString: function(it){
// summary:
// Return true if it is a String
// it: anything
// Item to test.
return (typeof it == "string" || it instanceof String); // Boolean
},
isArray: function(it){
// summary:
// Return true if it is an Array.
// Does not work on Arrays created in other windows.
// it: anything
// Item to test.
return it && (it instanceof Array || typeof it == "array"); // Boolean
},
isFunction: function(it){
// summary:
// Return true if it is a Function
// it: anything
// Item to test.
return opts.call(it) === "[object Function]";
},
isObject: function(it){
// summary:
// Returns true if it is a JavaScript object (or an Array, a Function
// or null)
// it: anything
// Item to test.
return it !== undefined &&
(it === null || typeof it == "object" || lang.isArray(it) || lang.isFunction(it)); // Boolean
},
isArrayLike: function(it){
// summary:
// similar to isArray() but more permissive
// it: anything
// Item to test.
// returns:
// If it walks like a duck and quacks like a duck, return `true`
// description:
// Doesn't strongly test for "arrayness". Instead, settles for "isn't
// a string or number and has a length property". Arguments objects
// and DOM collections will return true when passed to
// isArrayLike(), but will return false when passed to
// isArray().
return it && it !== undefined && // Boolean
// keep out built-in constructors (Number, String, ...) which have length
// properties
!lang.isString(it) && !lang.isFunction(it) &&
!(it.tagName && it.tagName.toLowerCase() == 'form') &&
(lang.isArray(it) || isFinite(it.length));
},
isAlien: function(it){
// summary:
// Returns true if it is a built-in function or some other kind of
// oddball that *should* report as a function but doesn't
return it && !lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean
},
extend: function(ctor, props){
// summary:
// Adds all properties and methods of props to constructor's
// prototype, making them available to all instances created with
// constructor.
// ctor: Object
// Target constructor to extend.
// props: Object
// One or more objects to mix into ctor.prototype
for(var i=1, l=arguments.length; i<l; i++){
lang._mixin(ctor.prototype, arguments[i]);
}
return ctor; // Object
},
_hitchArgs: function(scope, method){
var pre = lang._toArray(arguments, 2);
var named = lang.isString(method);
return function(){
// arrayify arguments
var args = lang._toArray(arguments);
// locate our method
var f = named ? (scope||dojo.global)[method] : method;
// invoke with collected args
return f && f.apply(scope || this, pre.concat(args)); // mixed
}; // Function
},
hitch: function(scope, method){
// summary:
// Returns a function that will only ever execute in the a given scope.
// This allows for easy use of object member functions
// in callbacks and other places in which the "this" keyword may
// otherwise not reference the expected scope.
// Any number of default positional arguments may be passed as parameters
// beyond "method".
// Each of these values will be used to "placehold" (similar to curry)
// for the hitched function.
// scope: Object
// The scope to use when method executes. If method is a string,
// scope is also the object containing method.
// method: Function|String...
// A function to be hitched to scope, or the name of the method in
// scope to be hitched.
// example:
// | lang.hitch(foo, "bar")();
// runs foo.bar() in the scope of foo
// example:
// | lang.hitch(foo, myFunction);
// returns a function that runs myFunction in the scope of foo
// example:
// Expansion on the default positional arguments passed along from
// hitch. Passed args are mixed first, additional args after.
// | var foo = { bar: function(a, b, c){ console.log(a, b, c); } };
// | var fn = lang.hitch(foo, "bar", 1, 2);
// | fn(3); // logs "1, 2, 3"
// example:
// | var foo = { bar: 2 };
// | lang.hitch(foo, function(){ this.bar = 10; })();
// execute an anonymous function in scope of foo
if(arguments.length > 2){
return lang._hitchArgs.apply(dojo, arguments); // Function
}
if(!method){
method = scope;
scope = null;
}
if(lang.isString(method)){
scope = scope || dojo.global;
if(!scope[method]){ throw(['lang.hitch: scope["', method, '"] is null (scope="', scope, '")'].join('')); }
return function(){ return scope[method].apply(scope, arguments || []); }; // Function
}
return !scope ? method : function(){ return method.apply(scope, arguments || []); }; // Function
},
delegate: (function(){
// boodman/crockford delegation w/ cornford optimization
function TMP(){}
return function(obj, props){
TMP.prototype = obj;
var tmp = new TMP();
TMP.prototype = null;
if(props){
lang._mixin(tmp, props);
}
return tmp; // Object
};
})(),
/*=====
delegate: function(obj, props){
// summary:
// Returns a new object which "looks" to obj for properties which it
// does not have a value for. Optionally takes a bag of properties to
// seed the returned object with initially.
// description:
// This is a small implementation of the Boodman/Crockford delegation
// pattern in JavaScript. An intermediate object constructor mediates
// the prototype chain for the returned object, using it to delegate
// down to obj for property lookup when object-local lookup fails.
// This can be thought of similarly to ES4's "wrap", save that it does
// not act on types but rather on pure objects.
// obj: Object
// The object to delegate to for properties not found directly on the
// return object or in props.
// props: Object...
// an object containing properties to assign to the returned object
// returns:
// an Object of anonymous type
// example:
// | var foo = { bar: "baz" };
// | var thinger = lang.delegate(foo, { thud: "xyzzy"});
// | thinger.bar == "baz"; // delegated to foo
// | foo.thud == undefined; // by definition
// | thinger.thud == "xyzzy"; // mixed in from props
// | foo.bar = "thonk";
// | thinger.bar == "thonk"; // still delegated to foo's bar
},
=====*/
_toArray: has("ie") ?
(function(){
function slow(obj, offset, startWith){
var arr = startWith||[];
for(var x = offset || 0; x < obj.length; x++){
arr.push(obj[x]);
}
return arr;
}
return function(obj){
return ((obj.item) ? slow : efficient).apply(this, arguments);
};
})() : efficient,
/*=====
_toArray: function(obj, offset, startWith){
// summary:
// Converts an array-like object (i.e. arguments, DOMCollection) to an
// array. Returns a new Array with the elements of obj.
// obj: Object
// the object to "arrayify". We expect the object to have, at a
// minimum, a length property which corresponds to integer-indexed
// properties.
// offset: Number?
// the location in obj to start iterating from. Defaults to 0.
// Optional.
// startWith: Array?
// An array to pack with the properties of obj. If provided,
// properties in obj are appended at the end of startWith and
// startWith is the returned array.
},
=====*/
partial: function(/*Function|String*/ method /*, ...*/){
// summary:
// similar to hitch() except that the scope object is left to be
// whatever the execution context eventually becomes.
// description:
// Calling lang.partial is the functional equivalent of calling:
// | lang.hitch(null, funcName, ...);
// method:
// The function to "wrap"
var arr = [ null ];
return lang.hitch.apply(dojo, arr.concat(lang._toArray(arguments))); // Function
},
clone: function(/*anything*/ src){
// summary:
// Clones objects (including DOM nodes) and all children.
// Warning: do not clone cyclic structures.
// src:
// The object to clone
if(!src || typeof src != "object" || lang.isFunction(src)){
// null, undefined, any non-object, or function
return src; // anything
}
if(src.nodeType && "cloneNode" in src){
// DOM Node
return src.cloneNode(true); // Node
}
if(src instanceof Date){
// Date
return new Date(src.getTime()); // Date
}
if(src instanceof RegExp){
// RegExp
return new RegExp(src); // RegExp
}
var r, i, l;
if(lang.isArray(src)){
// array
r = [];
for(i = 0, l = src.length; i < l; ++i){
if(i in src){
r.push(lang.clone(src[i]));
}
}
// we don't clone functions for performance reasons
// }else if(d.isFunction(src)){
// // function
// r = function(){ return src.apply(this, arguments); };
}else{
// generic objects
r = src.constructor ? new src.constructor() : {};
}
return lang._mixin(r, src, lang.clone);
},
trim: String.prototype.trim ?
function(str){ return str.trim(); } :
function(str){ return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); },
/*=====
trim: function(str){
// summary:
// Trims whitespace from both sides of the string
// str: String
// String to be trimmed
// returns: String
// Returns the trimmed string
// description:
// This version of trim() was selected for inclusion into the base due
// to its compact size and relatively good performance
// (see [Steven Levithan's blog](http://blog.stevenlevithan.com/archives/faster-trim-javascript)
// Uses String.prototype.trim instead, if available.
// The fastest but longest version of this function is located at
// lang.string.trim()
},
=====*/
replace: function(tmpl, map, pattern){
// summary:
// Performs parameterized substitutions on a string. Throws an
// exception if any parameter is unmatched.
// tmpl: String
// String to be used as a template.
// map: Object|Function
// If an object, it is used as a dictionary to look up substitutions.
// If a function, it is called for every substitution with following parameters:
// a whole match, a name, an offset, and the whole template
// string (see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/replace
// for more details).
// pattern: RegEx?
// Optional regular expression objects that overrides the default pattern.
// Must be global and match one item. The default is: /\{([^\}]+)\}/g,
// which matches patterns like that: "{xxx}", where "xxx" is any sequence
// of characters, which doesn't include "}".
// returns: String
// Returns the substituted string.
// example:
// | // uses a dictionary for substitutions:
// | lang.replace("Hello, {name.first} {name.last} AKA {nick}!",
// | {
// | nick: "Bob",
// | name: {
// | first: "Robert",
// | middle: "X",
// | last: "Cringely"
// | }
// | });
// | // returns: Hello, Robert Cringely AKA Bob!
// example:
// | // uses an array for substitutions:
// | lang.replace("Hello, {0} {2}!",
// | ["Robert", "X", "Cringely"]);
// | // returns: Hello, Robert Cringely!
// example:
// | // uses a function for substitutions:
// | function sum(a){
// | var t = 0;
// | arrayforEach(a, function(x){ t += x; });
// | return t;
// | }
// | lang.replace(
// | "{count} payments averaging {avg} USD per payment.",
// | lang.hitch(
// | { payments: [11, 16, 12] },
// | function(_, key){
// | switch(key){
// | case "count": return this.payments.length;
// | case "min": return Math.min.apply(Math, this.payments);
// | case "max": return Math.max.apply(Math, this.payments);
// | case "sum": return sum(this.payments);
// | case "avg": return sum(this.payments) / this.payments.length;
// | }
// | }
// | )
// | );
// | // prints: 3 payments averaging 13 USD per payment.
// example:
// | // uses an alternative PHP-like pattern for substitutions:
// | lang.replace("Hello, ${0} ${2}!",
// | ["Robert", "X", "Cringely"], /\$\{([^\}]+)\}/g);
// | // returns: Hello, Robert Cringely!
return tmpl.replace(pattern || _pattern, lang.isFunction(map) ?
map : function(_, k){ return lang.getObject(k, false, map); });
}
};
has("extend-dojo") && lang.mixin(dojo, lang);
return lang;
});

View File

@@ -0,0 +1,93 @@
define(["./kernel", "./lang", "../sniff"], function(dojo, lang, has){
// module:
// dojo/_base/sniff
/*=====
return {
// summary:
// Deprecated. New code should use dojo/sniff.
// This module populates the dojo browser version sniffing properties like dojo.isIE.
};
=====*/
if(!has("host-browser")){
return has;
}
// no idea what this is for, or if it's used
dojo._name = "browser";
lang.mixin(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: has("ff"),
// 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: has("ie"),
// isKhtml: Number|undefined
// Version as a Number if client is a KHTML browser. undefined otherwise. Corresponds to major
// detected version.
isKhtml: has("khtml"),
// isWebKit: Number|undefined
// Version as a Number if client is a WebKit-derived browser (Konqueror,
// Safari, Chrome, etc.). undefined otherwise.
isWebKit: has("webkit"),
// isMozilla: Number|undefined
// Version as a Number if client is a Mozilla-based browser (Firefox,
// SeaMonkey). undefined otherwise. Corresponds to major detected version.
isMozilla: has("mozilla"),
// isMoz: Number|undefined
// Version as a Number if client is a Mozilla-based browser (Firefox,
// SeaMonkey). undefined otherwise. Corresponds to major detected version.
isMoz: has("mozilla"),
// isOpera: Number|undefined
// Version as a Number if client is Opera. undefined otherwise. Corresponds to
// major detected version.
isOpera: has("opera"),
// isSafari: Number|undefined
// Version as a Number if client is Safari or iPhone. undefined otherwise.
isSafari: has("safari"),
// isChrome: Number|undefined
// Version as a Number if client is Chrome browser. undefined otherwise.
isChrome: has("chrome"),
// isMac: Boolean
// True if the client runs on Mac
isMac: has("mac"),
// isIos: Number|undefined
// Version as a Number if client is iPhone, iPod, or iPad. undefined otherwise.
isIos: has("ios"),
// isAndroid: Number|undefined
// Version as a Number if client is android browser. undefined otherwise.
isAndroid: has("android"),
// isWii: Boolean
// True if client is Wii
isWii: has("wii"),
// isQuirks: Boolean
// Page is in quirks mode.
isQuirks: has("quirks"),
// isAir: Boolean
// True if client is Adobe Air
isAir: has("air")
});
return has;
});

View File

@@ -0,0 +1,134 @@
define(["./kernel", "./lang", "../sniff"], function(dojo, lang, has){
// module:
// dojo/_base/window
var ret = {
// summary:
// API to save/set/restore the global/document scope.
global: dojo.global,
/*=====
global: {
// summary:
// Alias for the current window. 'global' can be modified
// for temporary context shifting. See also withGlobal().
// description:
// Use this rather than referring to 'window' to ensure your code runs
// correctly in managed contexts.
},
=====*/
doc: this["document"] || null,
/*=====
doc: {
// summary:
// Alias for the current document. 'doc' can be modified
// for temporary context shifting. See also withDoc().
// description:
// Use this rather than referring to 'window.document' to ensure your code runs
// correctly in managed contexts.
// example:
// | n.appendChild(dojo.doc.createElement('div'));
},
=====*/
body: function(/*Document?*/ doc){
// summary:
// Return the body element of the specified document or of dojo/_base/window::doc.
// example:
// | win.body().appendChild(dojo.doc.createElement('div'));
// Note: document.body is not defined for a strict xhtml document
// Would like to memoize this, but dojo.doc can change vi dojo.withDoc().
doc = doc || dojo.doc;
return doc.body || doc.getElementsByTagName("body")[0]; // Node
},
setContext: function(/*Object*/ globalObject, /*DocumentElement*/ globalDocument){
// summary:
// changes the behavior of many core Dojo functions that deal with
// namespace and DOM lookup, changing them to work in a new global
// context (e.g., an iframe). The varibles dojo.global and dojo.doc
// are modified as a result of calling this function and the result of
// `dojo.body()` likewise differs.
dojo.global = ret.global = globalObject;
dojo.doc = ret.doc = globalDocument;
},
withGlobal: function( /*Object*/ globalObject,
/*Function*/ callback,
/*Object?*/ thisObject,
/*Array?*/ cbArguments){
// summary:
// Invoke callback with globalObject as dojo.global and
// globalObject.document as dojo.doc.
// description:
// Invoke callback with globalObject as dojo.global and
// globalObject.document as dojo.doc. If provided, globalObject
// will be executed in the context of object thisObject
// When callback() returns or throws an error, the dojo.global
// and dojo.doc will be restored to its previous state.
var oldGlob = dojo.global;
try{
dojo.global = ret.global = globalObject;
return ret.withDoc.call(null, globalObject.document, callback, thisObject, cbArguments);
}finally{
dojo.global = ret.global = oldGlob;
}
},
withDoc: function( /*DocumentElement*/ documentObject,
/*Function*/ callback,
/*Object?*/ thisObject,
/*Array?*/ cbArguments){
// summary:
// Invoke callback with documentObject as dojo/_base/window::doc.
// description:
// Invoke callback with documentObject as dojo/_base/window::doc. If provided,
// callback will be executed in the context of object thisObject
// When callback() returns or throws an error, the dojo/_base/window::doc will
// be restored to its previous state.
var oldDoc = ret.doc,
oldQ = has("quirks"),
oldIE = has("ie"), isIE, mode, pwin;
try{
dojo.doc = ret.doc = documentObject;
// update dojo.isQuirks and the value of the has feature "quirks".
// remove setting dojo.isQuirks and dojo.isIE for 2.0
dojo.isQuirks = has.add("quirks", dojo.doc.compatMode == "BackCompat", true, true); // no need to check for QuirksMode which was Opera 7 only
if(has("ie")){
if((pwin = documentObject.parentWindow) && pwin.navigator){
// re-run IE detection logic and update dojo.isIE / has("ie")
// (the only time parentWindow/navigator wouldn't exist is if we were not
// passed an actual legitimate document object)
isIE = parseFloat(pwin.navigator.appVersion.split("MSIE ")[1]) || undefined;
mode = documentObject.documentMode;
if(mode && mode != 5 && Math.floor(isIE) != mode){
isIE = mode;
}
dojo.isIE = has.add("ie", isIE, true, true);
}
}
if(thisObject && typeof callback == "string"){
callback = thisObject[callback];
}
return callback.apply(thisObject, cbArguments || []);
}finally{
dojo.doc = ret.doc = oldDoc;
dojo.isQuirks = has.add("quirks", oldQ, true, true);
dojo.isIE = has.add("ie", oldIE, true, true);
}
}
};
has("extend-dojo") && lang.mixin(dojo, ret);
return ret;
});