add stuff from webui.profile.js to missing-sources.

This commit is contained in:
Timo Aaltonen
2016-09-01 11:28:34 +03:00
parent 1a03d4cf9a
commit e1402d7d81
25 changed files with 4465 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
freeipa
Upstream does not ship unminified copies of various javascript files, so we must ship them
in debian/missing-sources. Minified build.js and dojo.js are built with a certain set of
modules, so those bits are under missing-sources/{build,dojo}. The list of modules are listed on
install/ui/src/build.profile.js and install/ui/src/dojo.profile.js.
in debian/missing-sources. Minified build.js, dojo.js and freeipa/{app,core}.js
are built with a certain set of modules, so those bits are under missing-sources/{build,dojo}.
The list of modules needed for the build are taken from install/ui/src/build.profile.js,
install/ui/src/dojo.profile.js and install/ui/src/webui.profile.js.

320
debian/missing-sources/dojo/Deferred.js vendored Normal file
View File

@@ -0,0 +1,320 @@
define([
"./has",
"./_base/lang",
"./errors/CancelError",
"./promise/Promise",
"./has!config-deferredInstrumentation?./promise/instrumentation"
], function(has, lang, CancelError, Promise, instrumentation){
"use strict";
// module:
// dojo/Deferred
var PROGRESS = 0,
RESOLVED = 1,
REJECTED = 2;
var FULFILLED_ERROR_MESSAGE = "This deferred has already been fulfilled.";
var freezeObject = Object.freeze || function(){};
var signalWaiting = function(waiting, type, result, rejection, deferred){
if(has("config-deferredInstrumentation")){
if(type === REJECTED && Deferred.instrumentRejected && waiting.length === 0){
Deferred.instrumentRejected(result, false, rejection, deferred);
}
}
for(var i = 0; i < waiting.length; i++){
signalListener(waiting[i], type, result, rejection);
}
};
var signalListener = function(listener, type, result, rejection){
var func = listener[type];
var deferred = listener.deferred;
if(func){
try{
var newResult = func(result);
if(type === PROGRESS){
if(typeof newResult !== "undefined"){
signalDeferred(deferred, type, newResult);
}
}else{
if(newResult && typeof newResult.then === "function"){
listener.cancel = newResult.cancel;
newResult.then(
// Only make resolvers if they're actually going to be used
makeDeferredSignaler(deferred, RESOLVED),
makeDeferredSignaler(deferred, REJECTED),
makeDeferredSignaler(deferred, PROGRESS));
return;
}
signalDeferred(deferred, RESOLVED, newResult);
}
}catch(error){
signalDeferred(deferred, REJECTED, error);
}
}else{
signalDeferred(deferred, type, result);
}
if(has("config-deferredInstrumentation")){
if(type === REJECTED && Deferred.instrumentRejected){
Deferred.instrumentRejected(result, !!func, rejection, deferred.promise);
}
}
};
var makeDeferredSignaler = function(deferred, type){
return function(value){
signalDeferred(deferred, type, value);
};
};
var signalDeferred = function(deferred, type, result){
if(!deferred.isCanceled()){
switch(type){
case PROGRESS:
deferred.progress(result);
break;
case RESOLVED:
deferred.resolve(result);
break;
case REJECTED:
deferred.reject(result);
break;
}
}
};
var Deferred = function(canceler){
// summary:
// Creates a new deferred. This API is preferred over
// `dojo/_base/Deferred`.
// description:
// Creates a new deferred, as an abstraction over (primarily)
// asynchronous operations. The deferred is the private interface
// that should not be returned to calling code. That's what the
// `promise` is for. See `dojo/promise/Promise`.
// canceler: Function?
// Will be invoked if the deferred is canceled. The canceler
// receives the reason the deferred was canceled as its argument.
// The deferred is rejected with its return value, or a new
// `dojo/errors/CancelError` instance.
// promise: dojo/promise/Promise
// The public promise object that clients can add callbacks to.
var promise = this.promise = new Promise();
var deferred = this;
var fulfilled, result, rejection;
var canceled = false;
var waiting = [];
if(has("config-deferredInstrumentation") && Error.captureStackTrace){
Error.captureStackTrace(deferred, Deferred);
Error.captureStackTrace(promise, Deferred);
}
this.isResolved = promise.isResolved = function(){
// summary:
// Checks whether the deferred has been resolved.
// returns: Boolean
return fulfilled === RESOLVED;
};
this.isRejected = promise.isRejected = function(){
// summary:
// Checks whether the deferred has been rejected.
// returns: Boolean
return fulfilled === REJECTED;
};
this.isFulfilled = promise.isFulfilled = function(){
// summary:
// Checks whether the deferred has been resolved or rejected.
// returns: Boolean
return !!fulfilled;
};
this.isCanceled = promise.isCanceled = function(){
// summary:
// Checks whether the deferred has been canceled.
// returns: Boolean
return canceled;
};
this.progress = function(update, strict){
// summary:
// Emit a progress update on the deferred.
// description:
// Emit a progress update on the deferred. Progress updates
// can be used to communicate updates about the asynchronous
// operation before it has finished.
// update: any
// The progress update. Passed to progbacks.
// strict: Boolean?
// If strict, will throw an error if the deferred has already
// been fulfilled and consequently no progress can be emitted.
// returns: dojo/promise/Promise
// Returns the original promise for the deferred.
if(!fulfilled){
signalWaiting(waiting, PROGRESS, update, null, deferred);
return promise;
}else if(strict === true){
throw new Error(FULFILLED_ERROR_MESSAGE);
}else{
return promise;
}
};
this.resolve = function(value, strict){
// summary:
// Resolve the deferred.
// description:
// Resolve the deferred, putting it in a success state.
// value: any
// The result of the deferred. Passed to callbacks.
// strict: Boolean?
// If strict, will throw an error if the deferred has already
// been fulfilled and consequently cannot be resolved.
// returns: dojo/promise/Promise
// Returns the original promise for the deferred.
if(!fulfilled){
// Set fulfilled, store value. After signaling waiting listeners unset
// waiting.
signalWaiting(waiting, fulfilled = RESOLVED, result = value, null, deferred);
waiting = null;
return promise;
}else if(strict === true){
throw new Error(FULFILLED_ERROR_MESSAGE);
}else{
return promise;
}
};
var reject = this.reject = function(error, strict){
// summary:
// Reject the deferred.
// description:
// Reject the deferred, putting it in an error state.
// error: any
// The error result of the deferred. Passed to errbacks.
// strict: Boolean?
// If strict, will throw an error if the deferred has already
// been fulfilled and consequently cannot be rejected.
// returns: dojo/promise/Promise
// Returns the original promise for the deferred.
if(!fulfilled){
if(has("config-deferredInstrumentation") && Error.captureStackTrace){
Error.captureStackTrace(rejection = {}, reject);
}
signalWaiting(waiting, fulfilled = REJECTED, result = error, rejection, deferred);
waiting = null;
return promise;
}else if(strict === true){
throw new Error(FULFILLED_ERROR_MESSAGE);
}else{
return promise;
}
};
this.then = promise.then = function(callback, errback, progback){
// summary:
// Add new callbacks to the deferred.
// description:
// Add new callbacks to the deferred. Callbacks can be added
// before or after the deferred is fulfilled.
// callback: Function?
// Callback to be invoked when the promise is resolved.
// Receives the resolution value.
// errback: Function?
// Callback to be invoked when the promise is rejected.
// Receives the rejection error.
// progback: Function?
// Callback to be invoked when the promise emits a progress
// update. Receives the progress update.
// returns: dojo/promise/Promise
// Returns a new promise for the result of the callback(s).
// This can be used for chaining many asynchronous operations.
var listener = [progback, callback, errback];
// Ensure we cancel the promise we're waiting for, or if callback/errback
// have returned a promise, cancel that one.
listener.cancel = promise.cancel;
listener.deferred = new Deferred(function(reason){
// Check whether cancel is really available, returned promises are not
// required to expose `cancel`
return listener.cancel && listener.cancel(reason);
});
if(fulfilled && !waiting){
signalListener(listener, fulfilled, result, rejection);
}else{
waiting.push(listener);
}
return listener.deferred.promise;
};
this.cancel = promise.cancel = function(reason, strict){
// summary:
// Inform the deferred it may cancel its asynchronous operation.
// description:
// Inform the deferred it may cancel its asynchronous operation.
// The deferred's (optional) canceler is invoked and the
// deferred will be left in a rejected state. Can affect other
// promises that originate with the same deferred.
// reason: any
// A message that may be sent to the deferred's canceler,
// explaining why it's being canceled.
// strict: Boolean?
// If strict, will throw an error if the deferred has already
// been fulfilled and consequently cannot be canceled.
// returns: any
// Returns the rejection reason if the deferred was canceled
// normally.
if(!fulfilled){
// Cancel can be called even after the deferred is fulfilled
if(canceler){
var returnedReason = canceler(reason);
reason = typeof returnedReason === "undefined" ? reason : returnedReason;
}
canceled = true;
if(!fulfilled){
// Allow canceler to provide its own reason, but fall back to a CancelError
if(typeof reason === "undefined"){
reason = new CancelError();
}
reject(reason);
return reason;
}else if(fulfilled === REJECTED && result === reason){
return reason;
}
}else if(strict === true){
throw new Error(FULFILLED_ERROR_MESSAGE);
}
};
freezeObject(promise);
};
Deferred.prototype.toString = function(){
// returns: String
// Returns `[object Deferred]`.
return "[object Deferred]";
};
if(instrumentation){
instrumentation(Deferred);
}
return Deferred;
});

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,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;
});

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,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;
});

223
debian/missing-sources/dojo/aspect.js vendored Normal file
View File

@@ -0,0 +1,223 @@
define([], function(){
// module:
// dojo/aspect
"use strict";
var undefined, nextId = 0;
function advise(dispatcher, type, advice, receiveArguments){
var previous = dispatcher[type];
var around = type == "around";
var signal;
if(around){
var advised = advice(function(){
return previous.advice(this, arguments);
});
signal = {
remove: function(){
if(advised){
advised = dispatcher = advice = null;
}
},
advice: function(target, args){
return advised ?
advised.apply(target, args) : // called the advised function
previous.advice(target, args); // cancelled, skip to next one
}
};
}else{
// create the remove handler
signal = {
remove: function(){
if(signal.advice){
var previous = signal.previous;
var next = signal.next;
if(!next && !previous){
delete dispatcher[type];
}else{
if(previous){
previous.next = next;
}else{
dispatcher[type] = next;
}
if(next){
next.previous = previous;
}
}
// remove the advice to signal that this signal has been removed
dispatcher = advice = signal.advice = null;
}
},
id: nextId++,
advice: advice,
receiveArguments: receiveArguments
};
}
if(previous && !around){
if(type == "after"){
// add the listener to the end of the list
// note that we had to change this loop a little bit to workaround a bizarre IE10 JIT bug
while(previous.next && (previous = previous.next)){}
previous.next = signal;
signal.previous = previous;
}else if(type == "before"){
// add to beginning
dispatcher[type] = signal;
signal.next = previous;
previous.previous = signal;
}
}else{
// around or first one just replaces
dispatcher[type] = signal;
}
return signal;
}
function aspect(type){
return function(target, methodName, advice, receiveArguments){
var existing = target[methodName], dispatcher;
if(!existing || existing.target != target){
// no dispatcher in place
target[methodName] = dispatcher = function(){
var executionId = nextId;
// before advice
var args = arguments;
var before = dispatcher.before;
while(before){
args = before.advice.apply(this, args) || args;
before = before.next;
}
// around advice
if(dispatcher.around){
var results = dispatcher.around.advice(this, args);
}
// after advice
var after = dispatcher.after;
while(after && after.id < executionId){
if(after.receiveArguments){
var newResults = after.advice.apply(this, args);
// change the return value only if a new value was returned
results = newResults === undefined ? results : newResults;
}else{
results = after.advice.call(this, results, args);
}
after = after.next;
}
return results;
};
if(existing){
dispatcher.around = {advice: function(target, args){
return existing.apply(target, args);
}};
}
dispatcher.target = target;
}
var results = advise((dispatcher || existing), type, advice, receiveArguments);
advice = null;
return results;
};
}
// TODOC: after/before/around return object
var after = aspect("after");
/*=====
after = function(target, methodName, advice, receiveArguments){
// summary:
// The "after" export of the aspect module is a function that can be used to attach
// "after" advice to a method. This function will be executed after the original method
// is executed. By default the function will be called with a single argument, the return
// value of the original method, or the the return value of the last executed advice (if a previous one exists).
// The fourth (optional) argument can be set to true to so the function receives the original
// arguments (from when the original method was called) rather than the return value.
// If there are multiple "after" advisors, they are executed in the order they were registered.
// target: Object
// This is the target object
// methodName: String
// This is the name of the method to attach to.
// advice: Function
// This is function to be called after the original method
// receiveArguments: Boolean?
// If this is set to true, the advice function receives the original arguments (from when the original mehtod
// was called) rather than the return value of the original/previous method.
// returns:
// A signal object that can be used to cancel the advice. If remove() is called on this signal object, it will
// stop the advice function from being executed.
};
=====*/
var before = aspect("before");
/*=====
before = function(target, methodName, advice){
// summary:
// The "before" export of the aspect module is a function that can be used to attach
// "before" advice to a method. This function will be executed before the original method
// is executed. This function will be called with the arguments used to call the method.
// This function may optionally return an array as the new arguments to use to call
// the original method (or the previous, next-to-execute before advice, if one exists).
// If the before method doesn't return anything (returns undefined) the original arguments
// will be preserved.
// If there are multiple "before" advisors, they are executed in the reverse order they were registered.
// target: Object
// This is the target object
// methodName: String
// This is the name of the method to attach to.
// advice: Function
// This is function to be called before the original method
};
=====*/
var around = aspect("around");
/*=====
around = function(target, methodName, advice){
// summary:
// The "around" export of the aspect module is a function that can be used to attach
// "around" advice to a method. The advisor function is immediately executed when
// the around() is called, is passed a single argument that is a function that can be
// called to continue execution of the original method (or the next around advisor).
// The advisor function should return a function, and this function will be called whenever
// the method is called. It will be called with the arguments used to call the method.
// Whatever this function returns will be returned as the result of the method call (unless after advise changes it).
// example:
// If there are multiple "around" advisors, the most recent one is executed first,
// which can then delegate to the next one and so on. For example:
// | around(obj, "foo", function(originalFoo){
// | return function(){
// | var start = new Date().getTime();
// | var results = originalFoo.apply(this, arguments); // call the original
// | var end = new Date().getTime();
// | console.log("foo execution took " + (end - start) + " ms");
// | return results;
// | };
// | });
// target: Object
// This is the target object
// methodName: String
// This is the name of the method to attach to.
// advice: Function
// This is function to be called around the original method
};
=====*/
return {
// summary:
// provides aspect oriented programming functionality, allowing for
// one to add before, around, or after advice on existing methods.
// example:
// | define(["dojo/aspect"], function(aspect){
// | var signal = aspect.after(targetObject, "methodName", function(someArgument){
// | this will be called when targetObject.methodName() is called, after the original function is called
// | });
//
// example:
// The returned signal object can be used to cancel the advice.
// | signal.remove(); // this will stop the advice from being executed anymore
// | aspect.before(targetObject, "methodName", function(someArgument){
// | // this will be called when targetObject.methodName() is called, before the original function is called
// | });
before: before,
around: around,
after: after
};
});

220
debian/missing-sources/dojo/dom-attr.js vendored Normal file
View File

@@ -0,0 +1,220 @@
define(["exports", "./sniff", "./_base/lang", "./dom", "./dom-style", "./dom-prop"],
function(exports, has, lang, dom, style, prop){
// module:
// dojo/dom-attr
// summary:
// This module defines the core dojo DOM attributes API.
// TODOC: summary not showing up in output see https://github.com/csnover/js-doc-parse/issues/42
// =============================
// Element attribute Functions
// =============================
// This module will be obsolete soon. Use dojo/prop instead.
// dojo.attr() should conform to http://www.w3.org/TR/DOM-Level-2-Core/
// attribute-related functions (to be obsolete soon)
var forcePropNames = {
innerHTML: 1,
className: 1,
htmlFor: has("ie"),
value: 1
},
attrNames = {
// original attribute names
classname: "class",
htmlfor: "for",
// for IE
tabindex: "tabIndex",
readonly: "readOnly"
};
function _hasAttr(node, name){
var attr = node.getAttributeNode && node.getAttributeNode(name);
return attr && attr.specified; // Boolean
}
// There is a difference in the presence of certain properties and their default values
// between browsers. For example, on IE "disabled" is present on all elements,
// but it is value is "false"; "tabIndex" of <div> returns 0 by default on IE, yet other browsers
// can return -1.
exports.has = function hasAttr(/*DOMNode|String*/ node, /*String*/ name){
// summary:
// Returns true if the requested attribute is specified on the
// given element, and false otherwise.
// node: DOMNode|String
// id or reference to the element to check
// name: String
// the name of the attribute
// returns: Boolean
// true if the requested attribute is specified on the
// given element, and false otherwise
var lc = name.toLowerCase();
return forcePropNames[prop.names[lc] || name] || _hasAttr(dom.byId(node), attrNames[lc] || name); // Boolean
};
exports.get = function getAttr(/*DOMNode|String*/ node, /*String*/ name){
// summary:
// Gets an attribute on an HTML element.
// description:
// Handles normalized getting of attributes on DOM Nodes.
// node: DOMNode|String
// id or reference to the element to get the attribute on
// name: String
// the name of the attribute to get.
// returns:
// the value of the requested attribute or null if that attribute does not have a specified or
// default value;
//
// example:
// | // get the current value of the "foo" attribute on a node
// | dojo.getAttr(dojo.byId("nodeId"), "foo");
// | // or we can just pass the id:
// | dojo.getAttr("nodeId", "foo");
node = dom.byId(node);
var lc = name.toLowerCase(),
propName = prop.names[lc] || name,
forceProp = forcePropNames[propName],
value = node[propName]; // should we access this attribute via a property or via getAttribute()?
if(forceProp && typeof value != "undefined"){
// node's property
return value; // Anything
}
if(propName != "href" && (typeof value == "boolean" || lang.isFunction(value))){
// node's property
return value; // Anything
}
// node's attribute
// we need _hasAttr() here to guard against IE returning a default value
var attrName = attrNames[lc] || name;
return _hasAttr(node, attrName) ? node.getAttribute(attrName) : null; // Anything
};
exports.set = function setAttr(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){
// summary:
// Sets an attribute on an HTML element.
// description:
// Handles normalized setting of attributes on DOM Nodes.
//
// When passing functions as values, note that they will not be
// directly assigned to slots on the node, but rather the default
// behavior will be removed and the new behavior will be added
// using `dojo.connect()`, meaning that event handler properties
// will be normalized and that some caveats with regards to
// non-standard behaviors for onsubmit apply. Namely that you
// should cancel form submission using `dojo.stopEvent()` on the
// passed event object instead of returning a boolean value from
// the handler itself.
// node: DOMNode|String
// id or reference to the element to set the attribute on
// name: String|Object
// the name of the attribute to set, or a hash of key-value pairs to set.
// value: String?
// the value to set for the attribute, if the name is a string.
// returns:
// the DOM node
//
// example:
// | // use attr() to set the tab index
// | dojo.setAttr("nodeId", "tabIndex", 3);
//
// example:
// Set multiple values at once, including event handlers:
// | dojo.setAttr("formId", {
// | "foo": "bar",
// | "tabIndex": -1,
// | "method": "POST",
// | "onsubmit": function(e){
// | // stop submitting the form. Note that the IE behavior
// | // of returning true or false will have no effect here
// | // since our handler is connect()ed to the built-in
// | // onsubmit behavior and so we need to use
// | // dojo.stopEvent() to ensure that the submission
// | // doesn't proceed.
// | dojo.stopEvent(e);
// |
// | // submit the form with Ajax
// | dojo.xhrPost({ form: "formId" });
// | }
// | });
//
// example:
// Style is s special case: Only set with an object hash of styles
// | dojo.setAttr("someNode",{
// | id:"bar",
// | style:{
// | width:"200px", height:"100px", color:"#000"
// | }
// | });
//
// example:
// Again, only set style as an object hash of styles:
// | var obj = { color:"#fff", backgroundColor:"#000" };
// | dojo.setAttr("someNode", "style", obj);
// |
// | // though shorter to use `dojo.style()` in this case:
// | dojo.setStyle("someNode", obj);
node = dom.byId(node);
if(arguments.length == 2){ // inline'd type check
// the object form of setter: the 2nd argument is a dictionary
for(var x in name){
exports.set(node, x, name[x]);
}
return node; // DomNode
}
var lc = name.toLowerCase(),
propName = prop.names[lc] || name,
forceProp = forcePropNames[propName];
if(propName == "style" && typeof value != "string"){ // inline'd type check
// special case: setting a style
style.set(node, value);
return node; // DomNode
}
if(forceProp || typeof value == "boolean" || lang.isFunction(value)){
return prop.set(node, name, value);
}
// node's attribute
node.setAttribute(attrNames[lc] || name, value);
return node; // DomNode
};
exports.remove = function removeAttr(/*DOMNode|String*/ node, /*String*/ name){
// summary:
// Removes an attribute from an HTML element.
// node: DOMNode|String
// id or reference to the element to remove the attribute from
// name: String
// the name of the attribute to remove
dom.byId(node).removeAttribute(attrNames[name.toLowerCase()] || name);
};
exports.getNodeProp = function getNodeProp(/*DomNode|String*/ node, /*String*/ name){
// summary:
// Returns an effective value of a property or an attribute.
// node: DOMNode|String
// id or reference to the element to remove the attribute from
// name: String
// the name of the attribute
// returns:
// the value of the attribute
node = dom.byId(node);
var lc = name.toLowerCase(), propName = prop.names[lc] || name;
if((propName in node) && propName != "href"){
// node's property
return node[propName]; // Anything
}
// node's attribute
var attrName = attrNames[lc] || name;
return _hasAttr(node, attrName) ? node.getAttribute(attrName) : null; // Anything
};
});

View File

@@ -0,0 +1,605 @@
define(["./sniff", "./_base/window","./dom", "./dom-style"],
function(has, win, dom, style){
// module:
// dojo/dom-geometry
// the result object
var geom = {
// summary:
// This module defines the core dojo DOM geometry API.
};
// Box functions will assume this model.
// On IE/Opera, BORDER_BOX will be set if the primary document is in quirks mode.
// Can be set to change behavior of box setters.
// can be either:
// "border-box"
// "content-box" (default)
geom.boxModel = "content-box";
// We punt per-node box mode testing completely.
// If anybody cares, we can provide an additional (optional) unit
// that overrides existing code to include per-node box sensitivity.
// Opera documentation claims that Opera 9 uses border-box in BackCompat mode.
// but experiments (Opera 9.10.8679 on Windows Vista) indicate that it actually continues to use content-box.
// IIRC, earlier versions of Opera did in fact use border-box.
// Opera guys, this is really confusing. Opera being broken in quirks mode is not our fault.
if(has("ie") /*|| has("opera")*/){
// client code may have to adjust if compatMode varies across iframes
geom.boxModel = document.compatMode == "BackCompat" ? "border-box" : "content-box";
}
geom.getPadExtents = function getPadExtents(/*DomNode*/ node, /*Object*/ computedStyle){
// summary:
// Returns object with special values specifically useful for node
// fitting.
// description:
// Returns an object with `w`, `h`, `l`, `t` properties:
// | l/t/r/b = left/top/right/bottom padding (respectively)
// | w = the total of the left and right padding
// | h = the total of the top and bottom padding
// If 'node' has position, l/t forms the origin for child nodes.
// The w/h are used for calculating boxes.
// Normally application code will not need to invoke this
// directly, and will use the ...box... functions instead.
// node: DOMNode
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var s = computedStyle || style.getComputedStyle(node), px = style.toPixelValue,
l = px(node, s.paddingLeft), t = px(node, s.paddingTop), r = px(node, s.paddingRight), b = px(node, s.paddingBottom);
return {l: l, t: t, r: r, b: b, w: l + r, h: t + b};
};
var none = "none";
geom.getBorderExtents = function getBorderExtents(/*DomNode*/ node, /*Object*/ computedStyle){
// summary:
// returns an object with properties useful for noting the border
// dimensions.
// description:
// - l/t/r/b = the sum of left/top/right/bottom border (respectively)
// - w = the sum of the left and right border
// - h = the sum of the top and bottom border
//
// The w/h are used for calculating boxes.
// Normally application code will not need to invoke this
// directly, and will use the ...box... functions instead.
// node: DOMNode
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var px = style.toPixelValue, s = computedStyle || style.getComputedStyle(node),
l = s.borderLeftStyle != none ? px(node, s.borderLeftWidth) : 0,
t = s.borderTopStyle != none ? px(node, s.borderTopWidth) : 0,
r = s.borderRightStyle != none ? px(node, s.borderRightWidth) : 0,
b = s.borderBottomStyle != none ? px(node, s.borderBottomWidth) : 0;
return {l: l, t: t, r: r, b: b, w: l + r, h: t + b};
};
geom.getPadBorderExtents = function getPadBorderExtents(/*DomNode*/ node, /*Object*/ computedStyle){
// summary:
// Returns object with properties useful for box fitting with
// regards to padding.
// description:
// - l/t/r/b = the sum of left/top/right/bottom padding and left/top/right/bottom border (respectively)
// - w = the sum of the left and right padding and border
// - h = the sum of the top and bottom padding and border
//
// The w/h are used for calculating boxes.
// Normally application code will not need to invoke this
// directly, and will use the ...box... functions instead.
// node: DOMNode
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var s = computedStyle || style.getComputedStyle(node),
p = geom.getPadExtents(node, s),
b = geom.getBorderExtents(node, s);
return {
l: p.l + b.l,
t: p.t + b.t,
r: p.r + b.r,
b: p.b + b.b,
w: p.w + b.w,
h: p.h + b.h
};
};
geom.getMarginExtents = function getMarginExtents(node, computedStyle){
// summary:
// returns object with properties useful for box fitting with
// regards to box margins (i.e., the outer-box).
//
// - l/t = marginLeft, marginTop, respectively
// - w = total width, margin inclusive
// - h = total height, margin inclusive
//
// The w/h are used for calculating boxes.
// Normally application code will not need to invoke this
// directly, and will use the ...box... functions instead.
// node: DOMNode
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var s = computedStyle || style.getComputedStyle(node), px = style.toPixelValue,
l = px(node, s.marginLeft), t = px(node, s.marginTop), r = px(node, s.marginRight), b = px(node, s.marginBottom);
return {l: l, t: t, r: r, b: b, w: l + r, h: t + b};
};
// Box getters work in any box context because offsetWidth/clientWidth
// are invariant wrt box context
//
// They do *not* work for display: inline objects that have padding styles
// because the user agent ignores padding (it's bogus styling in any case)
//
// Be careful with IMGs because they are inline or block depending on
// browser and browser mode.
// Although it would be easier to read, there are not separate versions of
// _getMarginBox for each browser because:
// 1. the branching is not expensive
// 2. factoring the shared code wastes cycles (function call overhead)
// 3. duplicating the shared code wastes bytes
geom.getMarginBox = function getMarginBox(/*DomNode*/ node, /*Object*/ computedStyle){
// summary:
// returns an object that encodes the width, height, left and top
// positions of the node's margin box.
// node: DOMNode
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var s = computedStyle || style.getComputedStyle(node), me = geom.getMarginExtents(node, s),
l = node.offsetLeft - me.l, t = node.offsetTop - me.t, p = node.parentNode, px = style.toPixelValue, pcs;
if(has("mozilla")){
// Mozilla:
// If offsetParent has a computed overflow != visible, the offsetLeft is decreased
// by the parent's border.
// We don't want to compute the parent's style, so instead we examine node's
// computed left/top which is more stable.
var sl = parseFloat(s.left), st = parseFloat(s.top);
if(!isNaN(sl) && !isNaN(st)){
l = sl;
t = st;
}else{
// If child's computed left/top are not parseable as a number (e.g. "auto"), we
// have no choice but to examine the parent's computed style.
if(p && p.style){
pcs = style.getComputedStyle(p);
if(pcs.overflow != "visible"){
l += pcs.borderLeftStyle != none ? px(node, pcs.borderLeftWidth) : 0;
t += pcs.borderTopStyle != none ? px(node, pcs.borderTopWidth) : 0;
}
}
}
}else if(has("opera") || (has("ie") == 8 && !has("quirks"))){
// On Opera and IE 8, offsetLeft/Top includes the parent's border
if(p){
pcs = style.getComputedStyle(p);
l -= pcs.borderLeftStyle != none ? px(node, pcs.borderLeftWidth) : 0;
t -= pcs.borderTopStyle != none ? px(node, pcs.borderTopWidth) : 0;
}
}
return {l: l, t: t, w: node.offsetWidth + me.w, h: node.offsetHeight + me.h};
};
geom.getContentBox = function getContentBox(node, computedStyle){
// summary:
// Returns an object that encodes the width, height, left and top
// positions of the node's content box, irrespective of the
// current box model.
// node: DOMNode
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
// clientWidth/Height are important since the automatically account for scrollbars
// fallback to offsetWidth/Height for special cases (see #3378)
node = dom.byId(node);
var s = computedStyle || style.getComputedStyle(node), w = node.clientWidth, h,
pe = geom.getPadExtents(node, s), be = geom.getBorderExtents(node, s);
if(!w){
w = node.offsetWidth;
h = node.offsetHeight;
}else{
h = node.clientHeight;
be.w = be.h = 0;
}
// On Opera, offsetLeft includes the parent's border
if(has("opera")){
pe.l += be.l;
pe.t += be.t;
}
return {l: pe.l, t: pe.t, w: w - pe.w - be.w, h: h - pe.h - be.h};
};
// Box setters depend on box context because interpretation of width/height styles
// vary wrt box context.
//
// The value of boxModel is used to determine box context.
// boxModel can be set directly to change behavior.
//
// Beware of display: inline objects that have padding styles
// because the user agent ignores padding (it's a bogus setup anyway)
//
// Be careful with IMGs because they are inline or block depending on
// browser and browser mode.
//
// Elements other than DIV may have special quirks, like built-in
// margins or padding, or values not detectable via computedStyle.
// In particular, margins on TABLE do not seems to appear
// at all in computedStyle on Mozilla.
function setBox(/*DomNode*/ node, /*Number?*/ l, /*Number?*/ t, /*Number?*/ w, /*Number?*/ h, /*String?*/ u){
// summary:
// sets width/height/left/top in the current (native) box-model
// dimensions. Uses the unit passed in u.
// node:
// DOM Node reference. Id string not supported for performance
// reasons.
// l:
// left offset from parent.
// t:
// top offset from parent.
// w:
// width in current box model.
// h:
// width in current box model.
// u:
// unit measure to use for other measures. Defaults to "px".
u = u || "px";
var s = node.style;
if(!isNaN(l)){
s.left = l + u;
}
if(!isNaN(t)){
s.top = t + u;
}
if(w >= 0){
s.width = w + u;
}
if(h >= 0){
s.height = h + u;
}
}
function isButtonTag(/*DomNode*/ node){
// summary:
// True if the node is BUTTON or INPUT.type="button".
return node.tagName.toLowerCase() == "button" ||
node.tagName.toLowerCase() == "input" && (node.getAttribute("type") || "").toLowerCase() == "button"; // boolean
}
function usesBorderBox(/*DomNode*/ node){
// summary:
// True if the node uses border-box layout.
// We could test the computed style of node to see if a particular box
// has been specified, but there are details and we choose not to bother.
// TABLE and BUTTON (and INPUT type=button) are always border-box by default.
// If you have assigned a different box to either one via CSS then
// box functions will break.
return geom.boxModel == "border-box" || node.tagName.toLowerCase() == "table" || isButtonTag(node); // boolean
}
geom.setContentSize = function setContentSize(/*DomNode*/ node, /*Object*/ box, /*Object*/ computedStyle){
// summary:
// Sets the size of the node's contents, irrespective of margins,
// padding, or borders.
// node: DOMNode
// box: Object
// hash with optional "w", and "h" properties for "width", and "height"
// respectively. All specified properties should have numeric values in whole pixels.
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var w = box.w, h = box.h;
if(usesBorderBox(node)){
var pb = geom.getPadBorderExtents(node, computedStyle);
if(w >= 0){
w += pb.w;
}
if(h >= 0){
h += pb.h;
}
}
setBox(node, NaN, NaN, w, h);
};
var nilExtents = {l: 0, t: 0, w: 0, h: 0};
geom.setMarginBox = function setMarginBox(/*DomNode*/ node, /*Object*/ box, /*Object*/ computedStyle){
// summary:
// sets the size of the node's margin box and placement
// (left/top), irrespective of box model. Think of it as a
// passthrough to setBox that handles box-model vagaries for
// you.
// node: DOMNode
// box: Object
// hash with optional "l", "t", "w", and "h" properties for "left", "right", "width", and "height"
// respectively. All specified properties should have numeric values in whole pixels.
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var s = computedStyle || style.getComputedStyle(node), w = box.w, h = box.h,
// Some elements have special padding, margin, and box-model settings.
// To use box functions you may need to set padding, margin explicitly.
// Controlling box-model is harder, in a pinch you might set dojo/dom-geometry.boxModel.
pb = usesBorderBox(node) ? nilExtents : geom.getPadBorderExtents(node, s),
mb = geom.getMarginExtents(node, s);
if(has("webkit")){
// on Safari (3.1.2), button nodes with no explicit size have a default margin
// setting an explicit size eliminates the margin.
// We have to swizzle the width to get correct margin reading.
if(isButtonTag(node)){
var ns = node.style;
if(w >= 0 && !ns.width){
ns.width = "4px";
}
if(h >= 0 && !ns.height){
ns.height = "4px";
}
}
}
if(w >= 0){
w = Math.max(w - pb.w - mb.w, 0);
}
if(h >= 0){
h = Math.max(h - pb.h - mb.h, 0);
}
setBox(node, box.l, box.t, w, h);
};
// =============================
// Positioning
// =============================
geom.isBodyLtr = function isBodyLtr(/*Document?*/ doc){
// summary:
// Returns true if the current language is left-to-right, and false otherwise.
// doc: Document?
// Optional document to query. If unspecified, use win.doc.
// returns: Boolean
doc = doc || win.doc;
return (win.body(doc).dir || doc.documentElement.dir || "ltr").toLowerCase() == "ltr"; // Boolean
};
geom.docScroll = function docScroll(/*Document?*/ doc){
// summary:
// Returns an object with {node, x, y} with corresponding offsets.
// doc: Document?
// Optional document to query. If unspecified, use win.doc.
// returns: Object
doc = doc || win.doc;
var node = win.doc.parentWindow || win.doc.defaultView; // use UI window, not dojo.global window. TODO: use dojo/window::get() except for circular dependency problem
return "pageXOffset" in node ? {x: node.pageXOffset, y: node.pageYOffset } :
(node = has("quirks") ? win.body(doc) : doc.documentElement) &&
{x: geom.fixIeBiDiScrollLeft(node.scrollLeft || 0, doc), y: node.scrollTop || 0 };
};
if(has("ie")){
geom.getIeDocumentElementOffset = function getIeDocumentElementOffset(/*Document?*/ doc){
// summary:
// returns the offset in x and y from the document body to the
// visual edge of the page for IE
// doc: Document?
// Optional document to query. If unspecified, use win.doc.
// description:
// The following values in IE contain an offset:
// | event.clientX
// | event.clientY
// | node.getBoundingClientRect().left
// | node.getBoundingClientRect().top
// But other position related values do not contain this offset,
// such as node.offsetLeft, node.offsetTop, node.style.left and
// node.style.top. The offset is always (2, 2) in LTR direction.
// When the body is in RTL direction, the offset counts the width
// of left scroll bar's width. This function computes the actual
// offset.
//NOTE: assumes we're being called in an IE browser
doc = doc || win.doc;
var de = doc.documentElement; // only deal with HTML element here, position() handles body/quirks
if(has("ie") < 8){
var r = de.getBoundingClientRect(), // works well for IE6+
l = r.left, t = r.top;
if(has("ie") < 7){
l += de.clientLeft; // scrollbar size in strict/RTL, or,
t += de.clientTop; // HTML border size in strict
}
return {
x: l < 0 ? 0 : l, // FRAME element border size can lead to inaccurate negative values
y: t < 0 ? 0 : t
};
}else{
return {
x: 0,
y: 0
};
}
};
}
geom.fixIeBiDiScrollLeft = function fixIeBiDiScrollLeft(/*Integer*/ scrollLeft, /*Document?*/ doc){
// summary:
// In RTL direction, scrollLeft should be a negative value, but IE
// returns a positive one. All codes using documentElement.scrollLeft
// must call this function to fix this error, otherwise the position
// will offset to right when there is a horizontal scrollbar.
// scrollLeft: Number
// doc: Document?
// Optional document to query. If unspecified, use win.doc.
// returns: Number
// In RTL direction, scrollLeft should be a negative value, but IE
// returns a positive one. All codes using documentElement.scrollLeft
// must call this function to fix this error, otherwise the position
// will offset to right when there is a horizontal scrollbar.
doc = doc || win.doc;
var ie = has("ie");
if(ie && !geom.isBodyLtr(doc)){
var qk = has("quirks"),
de = qk ? win.body(doc) : doc.documentElement,
pwin = win.global; // TODO: use winUtils.get(doc) after resolving circular dependency b/w dom-geometry.js and dojo/window.js
if(ie == 6 && !qk && pwin.frameElement && de.scrollHeight > de.clientHeight){
scrollLeft += de.clientLeft; // workaround ie6+strict+rtl+iframe+vertical-scrollbar bug where clientWidth is too small by clientLeft pixels
}
return (ie < 8 || qk) ? (scrollLeft + de.clientWidth - de.scrollWidth) : -scrollLeft; // Integer
}
return scrollLeft; // Integer
};
geom.position = function(/*DomNode*/ node, /*Boolean?*/ includeScroll){
// summary:
// Gets the position and size of the passed element relative to
// the viewport (if includeScroll==false), or relative to the
// document root (if includeScroll==true).
//
// description:
// Returns an object of the form:
// `{ x: 100, y: 300, w: 20, h: 15 }`.
// If includeScroll==true, the x and y values will include any
// document offsets that may affect the position relative to the
// viewport.
// Uses the border-box model (inclusive of border and padding but
// not margin). Does not act as a setter.
// node: DOMNode|String
// includeScroll: Boolean?
// returns: Object
node = dom.byId(node);
var db = win.body(node.ownerDocument),
ret = node.getBoundingClientRect();
ret = {x: ret.left, y: ret.top, w: ret.right - ret.left, h: ret.bottom - ret.top};
if(has("ie") < 9){
// On IE<9 there's a 2px offset that we need to adjust for, see dojo.getIeDocumentElementOffset()
var offset = geom.getIeDocumentElementOffset(node.ownerDocument);
// fixes the position in IE, quirks mode
ret.x -= offset.x + (has("quirks") ? db.clientLeft + db.offsetLeft : 0);
ret.y -= offset.y + (has("quirks") ? db.clientTop + db.offsetTop : 0);
}
// account for document scrolling
// if offsetParent is used, ret value already includes scroll position
// so we may have to actually remove that value if !includeScroll
if(includeScroll){
var scroll = geom.docScroll(node.ownerDocument);
ret.x += scroll.x;
ret.y += scroll.y;
}
return ret; // Object
};
// random "private" functions wildly used throughout the toolkit
geom.getMarginSize = function getMarginSize(/*DomNode*/ node, /*Object*/ computedStyle){
// summary:
// returns an object that encodes the width and height of
// the node's margin box
// node: DOMNode|String
// computedStyle: Object?
// This parameter accepts computed styles object.
// If this parameter is omitted, the functions will call
// dojo.getComputedStyle to get one. It is a better way, calling
// dojo.computedStyle once, and then pass the reference to this
// computedStyle parameter. Wherever possible, reuse the returned
// object of dojo/dom-style.getComputedStyle().
node = dom.byId(node);
var me = geom.getMarginExtents(node, computedStyle || style.getComputedStyle(node));
var size = node.getBoundingClientRect();
return {
w: (size.right - size.left) + me.w,
h: (size.bottom - size.top) + me.h
};
};
geom.normalizeEvent = function(event){
// summary:
// Normalizes the geometry of a DOM event, normalizing the pageX, pageY,
// offsetX, offsetY, layerX, and layerX properties
// event: Object
if(!("layerX" in event)){
event.layerX = event.offsetX;
event.layerY = event.offsetY;
}
if(!has("dom-addeventlistener")){
// old IE version
// FIXME: scroll position query is duped from dojo.html to
// avoid dependency on that entire module. Now that HTML is in
// Base, we should convert back to something similar there.
var se = event.target;
var doc = (se && se.ownerDocument) || document;
// DO NOT replace the following to use dojo.body(), in IE, document.documentElement should be used
// here rather than document.body
var docBody = has("quirks") ? doc.body : doc.documentElement;
var offset = geom.getIeDocumentElementOffset(doc);
event.pageX = event.clientX + geom.fixIeBiDiScrollLeft(docBody.scrollLeft || 0, doc) - offset.x;
event.pageY = event.clientY + (docBody.scrollTop || 0) - offset.y;
}
};
// TODO: evaluate separate getters/setters for position and sizes?
return geom;
});

View File

@@ -0,0 +1,13 @@
define(["./create"], function(create){
// module:
// dojo/errors/CancelError
/*=====
return function(){
// summary:
// Default error if a promise is canceled without a reason.
};
=====*/
return create("CancelError", null, null, { dojoType: "cancel" });
});

View File

@@ -0,0 +1,41 @@
define(["../_base/lang"], function(lang){
return function(name, ctor, base, props){
base = base || Error;
var ErrorCtor = function(message){
if(base === Error){
if(Error.captureStackTrace){
Error.captureStackTrace(this, ErrorCtor);
}
// Error.call() operates on the returned error
// object rather than operating on |this|
var err = Error.call(this, message),
prop;
// Copy own properties from err to |this|
for(prop in err){
if(err.hasOwnProperty(prop)){
this[prop] = err[prop];
}
}
// messsage is non-enumerable in ES5
this.message = message;
// stack is non-enumerable in at least Firefox
this.stack = err.stack;
}else{
base.apply(this, arguments);
}
if(ctor){
ctor.apply(this, arguments);
}
};
ErrorCtor.prototype = lang.delegate(base.prototype, props);
ErrorCtor.prototype.name = name;
ErrorCtor.prototype.constructor = ErrorCtor;
return ErrorCtor;
};
});

173
debian/missing-sources/dojo/has.js vendored Normal file
View File

@@ -0,0 +1,173 @@
define(["require", "module"], function(require, module){
// module:
// dojo/has
// summary:
// Defines the has.js API and several feature tests used by dojo.
// description:
// This module defines the has API as described by the project has.js with the following additional features:
//
// - the has test cache is exposed at has.cache.
// - the method has.add includes a forth parameter that controls whether or not existing tests are replaced
// - the loader's has cache may be optionally copied into this module's has cahce.
//
// This module adopted from https://github.com/phiggins42/has.js; thanks has.js team!
// try to pull the has implementation from the loader; both the dojo loader and bdLoad provide one
// if using a foreign loader, then the has cache may be initialized via the config object for this module
// WARNING: if a foreign loader defines require.has to be something other than the has.js API, then this implementation fail
var has = require.has || function(){};
if(!has("dojo-has-api")){
var
isBrowser =
// the most fundamental decision: are we in the browser?
typeof window != "undefined" &&
typeof location != "undefined" &&
typeof document != "undefined" &&
window.location == location && window.document == document,
// has API variables
global = this,
doc = isBrowser && document,
element = doc && doc.createElement("DiV"),
cache = (module.config && module.config()) || {};
has = function(name){
// summary:
// Return the current value of the named feature.
//
// name: String|Integer
// The name (if a string) or identifier (if an integer) of the feature to test.
//
// description:
// Returns the value of the feature named by name. The feature must have been
// previously added to the cache by has.add.
return typeof cache[name] == "function" ? (cache[name] = cache[name](global, doc, element)) : cache[name]; // Boolean
};
has.cache = cache;
has.add = function(name, test, now, force){
// summary:
// Register a new feature test for some named feature.
// name: String|Integer
// The name (if a string) or identifier (if an integer) of the feature to test.
// test: Function
// A test function to register. If a function, queued for testing until actually
// needed. The test function should return a boolean indicating
// the presence of a feature or bug.
// now: Boolean?
// Optional. Omit if `test` is not a function. Provides a way to immediately
// run the test and cache the result.
// force: Boolean?
// Optional. If the test already exists and force is truthy, then the existing
// test will be replaced; otherwise, add does not replace an existing test (that
// is, by default, the first test advice wins).
// example:
// A redundant test, testFn with immediate execution:
// | has.add("javascript", function(){ return true; }, true);
//
// example:
// Again with the redundantness. You can do this in your tests, but we should
// not be doing this in any internal has.js tests
// | has.add("javascript", true);
//
// example:
// Three things are passed to the testFunction. `global`, `document`, and a generic element
// from which to work your test should the need arise.
// | has.add("bug-byid", function(g, d, el){
// | // g == global, typically window, yadda yadda
// | // d == document object
// | // el == the generic element. a `has` element.
// | return false; // fake test, byid-when-form-has-name-matching-an-id is slightly longer
// | });
(typeof cache[name]=="undefined" || force) && (cache[name]= test);
return now && has(name);
};
// since we're operating under a loader that doesn't provide a has API, we must explicitly initialize
// has as it would have otherwise been initialized by the dojo loader; use has.add to the builder
// can optimize these away iff desired
has.add("host-browser", isBrowser);
has.add("dom", isBrowser);
has.add("dojo-dom-ready-api", 1);
has.add("dojo-sniff", 1);
}
if(has("host-browser")){
// Common application level tests
has.add("dom-addeventlistener", !!document.addEventListener);
has.add("touch", "ontouchstart" in document || window.navigator.msMaxTouchPoints > 0);
// I don't know if any of these tests are really correct, just a rough guess
has.add("device-width", screen.availWidth || innerWidth);
// Tests for DOMNode.attributes[] behavior:
// - dom-attributes-explicit - attributes[] only lists explicitly user specified attributes
// - dom-attributes-specified-flag (IE8) - need to check attr.specified flag to skip attributes user didn't specify
// - Otherwise, in IE6-7. attributes[] will list hundreds of values, so need to do outerHTML to get attrs instead.
var form = document.createElement("form");
has.add("dom-attributes-explicit", form.attributes.length == 0); // W3C
has.add("dom-attributes-specified-flag", form.attributes.length > 0 && form.attributes.length < 40); // IE8
}
has.clearElement = function(element){
// summary:
// Deletes the contents of the element passed to test functions.
element.innerHTML= "";
return element;
};
has.normalize = function(id, toAbsMid){
// summary:
// Resolves id into a module id based on possibly-nested tenary expression that branches on has feature test value(s).
//
// toAbsMid: Function
// Resolves a relative module id into an absolute module id
var
tokens = id.match(/[\?:]|[^:\?]*/g), i = 0,
get = function(skip){
var term = tokens[i++];
if(term == ":"){
// empty string module name, resolves to 0
return 0;
}else{
// postfixed with a ? means it is a feature to branch on, the term is the name of the feature
if(tokens[i++] == "?"){
if(!skip && has(term)){
// matched the feature, get the first value from the options
return get();
}else{
// did not match, get the second value, passing over the first
get(true);
return get(skip);
}
}
// a module
return term || 0;
}
};
id = get();
return id && toAbsMid(id);
};
has.load = function(id, parentRequire, loaded){
// summary:
// Conditional loading of AMD modules based on a has feature test value.
// id: String
// Gives the resolved module id to load.
// parentRequire: Function
// The loader require function with respect to the module that contained the plugin resource in it's
// dependency list.
// loaded: Function
// Callback to loader that consumes result of plugin demand.
if(id){
parentRequire([id], loaded);
}else{
loaded();
}
};
return has;
});

171
debian/missing-sources/dojo/mouse.js vendored Normal file
View File

@@ -0,0 +1,171 @@
define(["./_base/kernel", "./on", "./has", "./dom", "./_base/window"], function(dojo, on, has, dom, win){
// module:
// dojo/mouse
has.add("dom-quirks", win.doc && win.doc.compatMode == "BackCompat");
has.add("events-mouseenter", win.doc && "onmouseenter" in win.doc.createElement("div"));
has.add("events-mousewheel", win.doc && 'onmousewheel' in win.doc);
var mouseButtons;
if((has("dom-quirks") && has("ie")) || !has("dom-addeventlistener")){
mouseButtons = {
LEFT: 1,
MIDDLE: 4,
RIGHT: 2,
// helper functions
isButton: function(e, button){ return e.button & button; },
isLeft: function(e){ return e.button & 1; },
isMiddle: function(e){ return e.button & 4; },
isRight: function(e){ return e.button & 2; }
};
}else{
mouseButtons = {
LEFT: 0,
MIDDLE: 1,
RIGHT: 2,
// helper functions
isButton: function(e, button){ return e.button == button; },
isLeft: function(e){ return e.button == 0; },
isMiddle: function(e){ return e.button == 1; },
isRight: function(e){ return e.button == 2; }
};
}
dojo.mouseButtons = mouseButtons;
/*=====
dojo.mouseButtons = {
// LEFT: Number
// Numeric value of the left mouse button for the platform.
LEFT: 0,
// MIDDLE: Number
// Numeric value of the middle mouse button for the platform.
MIDDLE: 1,
// RIGHT: Number
// Numeric value of the right mouse button for the platform.
RIGHT: 2,
isButton: function(e, button){
// summary:
// Checks an event object for a pressed button
// e: Event
// Event object to examine
// button: Number
// The button value (example: dojo.mouseButton.LEFT)
return e.button == button; // Boolean
},
isLeft: function(e){
// summary:
// Checks an event object for the pressed left button
// e: Event
// Event object to examine
return e.button == 0; // Boolean
},
isMiddle: function(e){
// summary:
// Checks an event object for the pressed middle button
// e: Event
// Event object to examine
return e.button == 1; // Boolean
},
isRight: function(e){
// summary:
// Checks an event object for the pressed right button
// e: Event
// Event object to examine
return e.button == 2; // Boolean
}
};
=====*/
function eventHandler(type, selectHandler){
// emulation of mouseenter/leave with mouseover/out using descendant checking
var handler = function(node, listener){
return on(node, type, function(evt){
if(selectHandler){
return selectHandler(evt, listener);
}
if(!dom.isDescendant(evt.relatedTarget, node)){
return listener.call(this, evt);
}
});
};
handler.bubble = function(select){
return eventHandler(type, function(evt, listener){
// using a selector, use the select function to determine if the mouse moved inside the selector and was previously outside the selector
var target = select(evt.target);
var relatedTarget = evt.relatedTarget;
if(target && (target != (relatedTarget && relatedTarget.nodeType == 1 && select(relatedTarget)))){
return listener.call(target, evt);
}
});
};
return handler;
}
var wheel;
if(has("events-mousewheel")){
wheel = 'mousewheel';
}else{ //firefox
wheel = function(node, listener){
return on(node, 'DOMMouseScroll', function(evt){
evt.wheelDelta = -evt.detail;
listener.call(this, evt);
});
};
}
return {
// summary:
// This module provide mouse event handling utility functions and exports
// mouseenter and mouseleave event emulation.
// example:
// To use these events, you register a mouseenter like this:
// | define(["dojo/on", dojo/mouse"], function(on, mouse){
// | on(targetNode, mouse.enter, function(event){
// | dojo.addClass(targetNode, "highlighted");
// | });
// | on(targetNode, mouse.leave, function(event){
// | dojo.removeClass(targetNode, "highlighted");
// | });
_eventHandler: eventHandler, // for dojo/touch
// enter: Synthetic Event
// This is an extension event for the mouseenter that IE provides, emulating the
// behavior on other browsers.
enter: eventHandler("mouseover"),
// leave: Synthetic Event
// This is an extension event for the mouseleave that IE provides, emulating the
// behavior on other browsers.
leave: eventHandler("mouseout"),
// wheel: Normalized Mouse Wheel Event
// This is an extension event for the mousewheel that non-Mozilla browsers provide,
// emulating the behavior on Mozilla based browsers.
wheel: wheel,
isLeft: mouseButtons.isLeft,
/*=====
isLeft: function(){
// summary:
// Test an event object (from a mousedown event) to see if the left button was pressed.
},
=====*/
isMiddle: mouseButtons.isMiddle,
/*=====
isMiddle: function(){
// summary:
// Test an event object (from a mousedown event) to see if the middle button was pressed.
},
=====*/
isRight: mouseButtons.isRight
/*=====
, isRight: function(){
// summary:
// Test an event object (from a mousedown event) to see if the right button was pressed.
}
=====*/
};
});

View File

@@ -0,0 +1,133 @@
define([
"../_base/lang"
], function(lang){
"use strict";
// module:
// dojo/promise/Promise
function throwAbstract(){
throw new TypeError("abstract");
}
return lang.extend(function Promise(){
// summary:
// The public interface to a deferred.
// description:
// The public interface to a deferred. All promises in Dojo are
// instances of this class.
}, {
then: function(callback, errback, progback){
// summary:
// Add new callbacks to the promise.
// description:
// Add new callbacks to the deferred. Callbacks can be added
// before or after the deferred is fulfilled.
// callback: Function?
// Callback to be invoked when the promise is resolved.
// Receives the resolution value.
// errback: Function?
// Callback to be invoked when the promise is rejected.
// Receives the rejection error.
// progback: Function?
// Callback to be invoked when the promise emits a progress
// update. Receives the progress update.
// returns: dojo/promise/Promise
// Returns a new promise for the result of the callback(s).
// This can be used for chaining many asynchronous operations.
throwAbstract();
},
cancel: function(reason, strict){
// summary:
// Inform the deferred it may cancel its asynchronous operation.
// description:
// Inform the deferred it may cancel its asynchronous operation.
// The deferred's (optional) canceler is invoked and the
// deferred will be left in a rejected state. Can affect other
// promises that originate with the same deferred.
// reason: any
// A message that may be sent to the deferred's canceler,
// explaining why it's being canceled.
// strict: Boolean?
// If strict, will throw an error if the deferred has already
// been fulfilled and consequently cannot be canceled.
// returns: any
// Returns the rejection reason if the deferred was canceled
// normally.
throwAbstract();
},
isResolved: function(){
// summary:
// Checks whether the promise has been resolved.
// returns: Boolean
throwAbstract();
},
isRejected: function(){
// summary:
// Checks whether the promise has been rejected.
// returns: Boolean
throwAbstract();
},
isFulfilled: function(){
// summary:
// Checks whether the promise has been resolved or rejected.
// returns: Boolean
throwAbstract();
},
isCanceled: function(){
// summary:
// Checks whether the promise has been canceled.
// returns: Boolean
throwAbstract();
},
always: function(callbackOrErrback){
// summary:
// Add a callback to be invoked when the promise is resolved
// or rejected.
// callbackOrErrback: Function?
// A function that is used both as a callback and errback.
// returns: dojo/promise/Promise
// Returns a new promise for the result of the callback/errback.
return this.then(callbackOrErrback, callbackOrErrback);
},
otherwise: function(errback){
// summary:
// Add new errbacks to the promise.
// errback: Function?
// Callback to be invoked when the promise is rejected.
// returns: dojo/promise/Promise
// Returns a new promise for the result of the errback.
return this.then(null, errback);
},
trace: function(){
return this;
},
traceRejected: function(){
return this;
},
toString: function(){
// returns: string
// Returns `[object Promise]`.
return "[object Promise]";
}
});
});

View File

@@ -0,0 +1,105 @@
define([
"./tracer",
"../has",
"../_base/lang",
"../_base/array"
], function(tracer, has, lang, arrayUtil){
function logError(error, rejection, deferred){
var stack = "";
if(error && error.stack){
stack += error.stack;
}
if(rejection && rejection.stack){
stack += "\n ----------------------------------------\n rejected" + rejection.stack.split("\n").slice(1).join("\n").replace(/^\s+/, " ");
}
if(deferred && deferred.stack){
stack += "\n ----------------------------------------\n" + deferred.stack;
}
console.error(error, stack);
}
function reportRejections(error, handled, rejection, deferred){
if(!handled){
logError(error, rejection, deferred);
}
}
var errors = [];
var activeTimeout = false;
var unhandledWait = 1000;
function trackUnhandledRejections(error, handled, rejection, deferred){
if(handled){
arrayUtil.some(errors, function(obj, ix){
if(obj.error === error){
errors.splice(ix, 1);
return true;
}
});
}else if(!arrayUtil.some(errors, function(obj){ return obj.error === error; })){
errors.push({
error: error,
rejection: rejection,
deferred: deferred,
timestamp: new Date().getTime()
});
}
if(!activeTimeout){
activeTimeout = setTimeout(logRejected, unhandledWait);
}
}
function logRejected(){
var now = new Date().getTime();
var reportBefore = now - unhandledWait;
errors = arrayUtil.filter(errors, function(obj){
if(obj.timestamp < reportBefore){
logError(obj.error, obj.rejection, obj.deferred);
return false;
}
return true;
});
if(errors.length){
activeTimeout = setTimeout(logRejected, errors[0].timestamp + unhandledWait - now);
}else{
activeTimeout = false;
}
}
return function(Deferred){
// summary:
// Initialize instrumentation for the Deferred class.
// description:
// Initialize instrumentation for the Deferred class.
// Done automatically by `dojo/Deferred` if the
// `deferredInstrumentation` and `useDeferredInstrumentation`
// config options are set.
//
// Sets up `dojo/promise/tracer` to log to the console.
//
// Sets up instrumentation of rejected deferreds so unhandled
// errors are logged to the console.
var usage = has("config-useDeferredInstrumentation");
if(usage){
tracer.on("resolved", lang.hitch(console, "log", "resolved"));
tracer.on("rejected", lang.hitch(console, "log", "rejected"));
tracer.on("progress", lang.hitch(console, "log", "progress"));
var args = [];
if(typeof usage === "string"){
args = usage.split(",");
usage = args.shift();
}
if(usage === "report-rejections"){
Deferred.instrumentRejected = reportRejections;
}else if(usage === "report-unhandled-rejections" || usage === true || usage === 1){
Deferred.instrumentRejected = trackUnhandledRejections;
unhandledWait = parseInt(args[0], 10) || unhandledWait;
}else{
throw new Error("Unsupported instrumentation usage <" + usage + ">");
}
}
};
});

View File

@@ -0,0 +1,85 @@
define([
"../_base/lang",
"./Promise",
"../Evented"
], function(lang, Promise, Evented){
"use strict";
// module:
// dojo/promise/tracer
/*=====
return {
// summary:
// Trace promise fulfillment.
// description:
// Trace promise fulfillment. Calling `.trace()` or `.traceError()` on a
// promise enables tracing. Will emit `resolved`, `rejected` or `progress`
// events.
on: function(type, listener){
// summary:
// Subscribe to traces.
// description:
// See `dojo/Evented#on()`.
// type: String
// `resolved`, `rejected`, or `progress`
// listener: Function
// The listener is passed the traced value and any arguments
// that were used with the `.trace()` call.
}
};
=====*/
var evented = new Evented;
var emit = evented.emit;
evented.emit = null;
// Emit events asynchronously since they should not change the promise state.
function emitAsync(args){
setTimeout(function(){
emit.apply(evented, args);
}, 0);
}
Promise.prototype.trace = function(){
// summary:
// Trace the promise.
// description:
// Tracing allows you to transparently log progress,
// resolution and rejection of promises, without affecting the
// promise itself. Any arguments passed to `trace()` are
// emitted in trace events. See `dojo/promise/tracer` on how
// to handle traces.
// returns: dojo/promise/Promise
// The promise instance `trace()` is called on.
var args = lang._toArray(arguments);
this.then(
function(value){ emitAsync(["resolved", value].concat(args)); },
function(error){ emitAsync(["rejected", error].concat(args)); },
function(update){ emitAsync(["progress", update].concat(args)); }
);
return this;
};
Promise.prototype.traceRejected = function(){
// summary:
// Trace rejection of the promise.
// description:
// Tracing allows you to transparently log progress,
// resolution and rejection of promises, without affecting the
// promise itself. Any arguments passed to `trace()` are
// emitted in trace events. See `dojo/promise/tracer` on how
// to handle traces.
// returns: dojo/promise/Promise
// The promise instance `traceRejected()` is called on.
var args = lang._toArray(arguments);
this.otherwise(function(error){
emitAsync(["rejected", error].concat(args));
});
return this;
};
return evented;
});

153
debian/missing-sources/dojo/ready.js vendored Normal file
View File

@@ -0,0 +1,153 @@
define(["./_base/kernel", "./has", "require", "./has!host-browser?./domReady", "./_base/lang"], function(dojo, has, require, domReady, lang){
// module:
// dojo/ready
// note:
// This module should be unnecessary in dojo 2.0
var
// truthy if DOMContentLoaded or better (e.g., window.onload fired) has been achieved
isDomReady = 0,
// The queue of functions waiting to execute as soon as dojo.ready conditions satisfied
loadQ = [],
// prevent recursion in onLoad
onLoadRecursiveGuard = 0,
handleDomReady = function(){
isDomReady = 1;
dojo._postLoad = dojo.config.afterOnLoad = true;
onEvent();
},
onEvent = function(){
// Called when some state changes:
// - dom ready
// - dojo/domReady has finished processing everything in its queue
// - task added to loadQ
// - require() has finished loading all currently requested modules
//
// Run the functions queued with dojo.ready if appropriate.
//guard against recursions into this function
if(onLoadRecursiveGuard){
return;
}
onLoadRecursiveGuard = 1;
// Run tasks in queue if require() is finished loading modules, the dom is ready, and there are no
// pending tasks registered via domReady().
// The last step is necessary so that a user defined dojo.ready() callback is delayed until after the
// domReady() calls inside of dojo. Failure can be seen on dijit/tests/robot/Dialog_ally.html on IE8
// because the dijit/focus.js domReady() callback doesn't execute until after the test starts running.
while(isDomReady && (!domReady || domReady._Q.length == 0) && (require.idle ? require.idle() : true) && loadQ.length){
var f = loadQ.shift();
try{
f();
}catch(e){
// force the dojo.js on("error") handler do display the message
e.info = e.message;
if(require.signal){
require.signal("error", e);
}else{
throw e;
}
}
}
onLoadRecursiveGuard = 0;
};
// Check if we should run the next queue operation whenever require() finishes loading modules or domReady
// finishes processing it's queue.
require.on && require.on("idle", onEvent);
if(domReady){
domReady._onQEmpty = onEvent;
}
var ready = dojo.ready = dojo.addOnLoad = function(priority, context, callback){
// summary:
// Add a function to execute on DOM content loaded and all requested modules have arrived and been evaluated.
// In most cases, the `domReady` plug-in should suffice and this method should not be needed.
//
// When called in a non-browser environment, just checks that all requested modules have arrived and been
// evaluated.
// priority: Integer?
// The order in which to exec this callback relative to other callbacks, defaults to 1000
// context: Object?|Function
// The context in which to run execute callback, or a callback if not using context
// callback: Function?
// The function to execute.
//
// example:
// Simple DOM and Modules ready syntax
// | require(["dojo/ready"], function(ready){
// | ready(function(){ alert("Dom ready!"); });
// | });
//
// example:
// Using a priority
// | require(["dojo/ready"], function(ready){
// | ready(2, function(){ alert("low priority ready!"); })
// | });
//
// example:
// Using context
// | require(["dojo/ready"], function(ready){
// | ready(foo, function(){
// | // in here, this == foo
// | });
// | });
//
// example:
// Using dojo/hitch style args:
// | require(["dojo/ready"], function(ready){
// | var foo = { dojoReady: function(){ console.warn(this, "dojo dom and modules ready."); } };
// | ready(foo, "dojoReady");
// | });
var hitchArgs = lang._toArray(arguments);
if(typeof priority != "number"){
callback = context;
context = priority;
priority = 1000;
}else{
hitchArgs.shift();
}
callback = callback ?
lang.hitch.apply(dojo, hitchArgs) :
function(){
context();
};
callback.priority = priority;
for(var i = 0; i < loadQ.length && priority >= loadQ[i].priority; i++){}
loadQ.splice(i, 0, callback);
onEvent();
};
has.add("dojo-config-addOnLoad", 1);
if(has("dojo-config-addOnLoad")){
var dca = dojo.config.addOnLoad;
if(dca){
ready[(lang.isArray(dca) ? "apply" : "call")](dojo, dca);
}
}
if(has("dojo-sync-loader") && dojo.config.parseOnLoad && !dojo.isAsync){
ready(99, function(){
if(!dojo.parser){
dojo.deprecated("Add explicit require(['dojo/parser']);", "", "2.0");
require(["dojo/parser"]);
}
});
}
if(domReady){
domReady(handleDomReady);
}else{
handleDomReady();
}
return ready;
});

View File

@@ -0,0 +1,376 @@
define([
"dojo/_base/declare",
"dojo/hash",
"dojo/topic"
], function(declare, hash, topic){
// module:
// dojo/router/RouterBase
// Creating a basic trim to avoid needing the full dojo/string module
// similarly to dojo/_base/lang's trim
var trim;
if(String.prototype.trim){
trim = function(str){ return str.trim(); };
}else{
trim = function(str){ return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); };
}
// Firing of routes on the route object is always the same,
// no clean way to expose this on the prototype since it's for the
// internal router objects.
function fireRoute(params, currentPath, newPath){
var queue, isStopped, isPrevented, eventObj, callbackArgs, i, l;
queue = this.callbackQueue;
isStopped = false;
isPrevented = false;
eventObj = {
stopImmediatePropagation: function(){ isStopped = true; },
preventDefault: function(){ isPrevented = true; },
oldPath: currentPath,
newPath: newPath,
params: params
};
callbackArgs = [eventObj];
if(params instanceof Array){
callbackArgs = callbackArgs.concat(params);
}else{
for(var key in params){
callbackArgs.push(params[key]);
}
}
for(i=0, l=queue.length; i<l; ++i){
if(!isStopped){
queue[i].apply(null, callbackArgs);
}
}
return !isPrevented;
}
// Our actual class-like object
var RouterBase = declare(null, {
// summary:
// A module that allows one to easily map hash-based structures into
// callbacks. The router module is a singleton, offering one central
// point for all registrations of this type.
// example:
// | var router = new RouterBase({});
// | router.register("/widgets/:id", function(evt){
// | // If "/widgets/3" was matched,
// | // evt.params.id === "3"
// | xhr.get({
// | url: "/some/path/" + evt.params.id,
// | load: function(data){
// | // ...
// | }
// | });
// | });
_routes: null,
_routeIndex: null,
_started: false,
_currentPath: "",
idMatch: /:(\w[\w\d]*)/g,
idReplacement: "([^\\/]+)",
globMatch: /\*(\w[\w\d]*)/,
globReplacement: "(.+)",
constructor: function(kwArgs){
// A couple of safety initializations
this._routes = [];
this._routeIndex = {};
// Simple constructor-style "Decorate myself all over" for now
for(var i in kwArgs){
if(kwArgs.hasOwnProperty(i)){
this[i] = kwArgs[i];
}
}
},
register: function(/*String|RegExp*/ route, /*Function*/ callback){
// summary:
// Registers a route to a handling callback
// description:
// Given either a string or a regular expression, the router
// will monitor the page's hash and respond to changes that
// match the string or regex as provided.
//
// When provided a regex for the route:
//
// - Matching is performed, and the resulting capture groups
// are passed through to the callback as an array.
//
// When provided a string for the route:
//
// - The string is parsed as a URL-like structure, like
// "/foo/bar"
// - If any portions of that URL are prefixed with a colon
// (:), they will be parsed out and provided to the callback
// as properties of an object.
// - If the last piece of the URL-like structure is prefixed
// with a star (*) instead of a colon, it will be replaced in
// the resulting regex with a greedy (.+) match and
// anything remaining on the hash will be provided as a
// property on the object passed into the callback. Think of
// it like a basic means of globbing the end of a route.
// example:
// | router.register("/foo/:bar/*baz", function(object){
// | // If the hash was "/foo/abc/def/ghi",
// | // object.bar === "abc"
// | // object.baz === "def/ghi"
// | });
// returns: Object
// A plain JavaScript object to be used as a handle for
// either removing this specific callback's registration, as
// well as to add new callbacks with the same route initially
// used.
// route: String|RegExp
// A string or regular expression which will be used when
// monitoring hash changes.
// callback: Function
// When the hash matches a pattern as described in the route,
// this callback will be executed. It will receive an event
// object that will have several properties:
//
// - params: Either an array or object of properties pulled
// from the new hash
// - oldPath: The hash in its state before the change
// - newPath: The new hash being shifted to
// - preventDefault: A method that will stop hash changes
// from being actually applied to the active hash. This only
// works if the hash change was initiated using `router.go`,
// as changes initiated more directly to the location.hash
// property will already be in place
// - stopImmediatePropagation: When called, will stop any
// further bound callbacks on this particular route from
// being executed. If two distinct routes are bound that are
// different, but both happen to match the current hash in
// some way, this will *not* keep other routes from receiving
// notice of the change.
return this._registerRoute(route, callback);
},
registerBefore: function(/*String|RegExp*/ route, /*Function*/ callback){
// summary:
// Registers a route to a handling callback, except before
// any previously registered callbacks
// description:
// Much like the `register` method, `registerBefore` allows
// us to register route callbacks to happen before any
// previously registered callbacks. See the documentation for
// `register` for more details and examples.
return this._registerRoute(route, callback, true);
},
go: function(path, replace){
// summary:
// A simple pass-through to make changing the hash easy,
// without having to require dojo/hash directly. It also
// synchronously fires off any routes that match.
// example:
// | router.go("/foo/bar");
var applyChange;
if(typeof path !== "string"){return false;}
path = trim(path);
applyChange = this._handlePathChange(path);
if(applyChange){
hash(path, replace);
}
return applyChange;
},
startup: function(defaultPath){
// summary:
// This method must be called to activate the router. Until
// startup is called, no hash changes will trigger route
// callbacks.
if(this._started){ return; }
var self = this,
startingPath = hash();
this._started = true;
this._hashchangeHandle = topic.subscribe("/dojo/hashchange", function(){
self._handlePathChange.apply(self, arguments);
});
if(!startingPath){
// If there is no initial starting point, push our defaultPath into our
// history as the starting point
this.go(defaultPath, true);
}else{
// Handle the starting path
this._handlePathChange(startingPath);
}
},
destroy: function(){
this._hashchangeHandle.remove();
this._routes = null;
this._routeIndex = null;
},
_handlePathChange: function(newPath){
var i, j, li, lj, routeObj, result,
allowChange, parameterNames, params,
routes = this._routes,
currentPath = this._currentPath;
if(!this._started || newPath === currentPath){ return allowChange; }
allowChange = true;
for(i=0, li=routes.length; i<li; ++i){
routeObj = routes[i];
result = routeObj.route.exec(newPath);
if(result){
if(routeObj.parameterNames){
parameterNames = routeObj.parameterNames;
params = {};
for(j=0, lj=parameterNames.length; j<lj; ++j){
params[parameterNames[j]] = result[j+1];
}
}else{
params = result.slice(1);
}
allowChange = routeObj.fire(params, currentPath, newPath);
}
}
if(allowChange){
this._currentPath = newPath;
}
return allowChange;
},
_convertRouteToRegExp: function(route){
// Sub in based on IDs and globs
route = route.replace(this.idMatch, this.idReplacement);
route = route.replace(this.globMatch, this.globReplacement);
// Make sure it's an exact match
route = "^" + route + "$";
return new RegExp(route);
},
_getParameterNames: function(route){
var idMatch = this.idMatch,
globMatch = this.globMatch,
parameterNames = [], match;
idMatch.lastIndex = 0;
while((match = idMatch.exec(route)) !== null){
parameterNames.push(match[1]);
}
if((match = globMatch.exec(route)) !== null){
parameterNames.push(match[1]);
}
return parameterNames.length > 0 ? parameterNames : null;
},
_indexRoutes: function(){
var i, l, route, routeIndex, routes = this._routes;
// Start a new route index
routeIndex = this._routeIndex = {};
// Set it up again
for(i=0, l=routes.length; i<l; ++i){
route = routes[i];
routeIndex[route.route] = i;
}
},
_registerRoute: function(/*String|RegExp*/route, /*Function*/callback, /*Boolean?*/isBefore){
var index, exists, routeObj, callbackQueue, removed,
self = this, routes = this._routes,
routeIndex = this._routeIndex;
// Try to fetch the route if it already exists.
// This works thanks to stringifying of regex
index = this._routeIndex[route];
exists = typeof index !== "undefined";
if(exists){
routeObj = routes[index];
}
// If we didn't get one, make a default start point
if(!routeObj){
routeObj = {
route: route,
callbackQueue: [],
fire: fireRoute
};
}
callbackQueue = routeObj.callbackQueue;
if(typeof route == "string"){
routeObj.parameterNames = this._getParameterNames(route);
routeObj.route = this._convertRouteToRegExp(route);
}
if(isBefore){
callbackQueue.unshift(callback);
}else{
callbackQueue.push(callback);
}
if(!exists){
index = routes.length;
routeIndex[route] = index;
routes.push(routeObj);
}
// Useful in a moment to keep from re-removing routes
removed = false;
return { // Object
remove: function(){
var i, l;
if(removed){ return; }
for(i=0, l=callbackQueue.length; i<l; ++i){
if(callbackQueue[i] === callback){
callbackQueue.splice(i, 1);
}
}
if(callbackQueue.length === 0){
routes.splice(index, 1);
self._indexRoutes();
}
removed = true;
},
register: function(callback, isBefore){
return self.register(route, callback, isBefore);
}
};
}
});
return RouterBase;
});

80
debian/missing-sources/dojo/sniff.js vendored Normal file
View File

@@ -0,0 +1,80 @@
define(["./has"], function(has){
// module:
// dojo/sniff
/*=====
return function(){
// summary:
// This module sets has() flags based on the current browser.
// It returns the has() function.
};
=====*/
if(has("host-browser")){
var n = navigator,
dua = n.userAgent,
dav = n.appVersion,
tv = parseFloat(dav);
has.add("air", dua.indexOf("AdobeAIR") >= 0);
has.add("msapp", parseFloat(dua.split("MSAppHost/")[1]) || undefined);
has.add("khtml", dav.indexOf("Konqueror") >= 0 ? tv : undefined);
has.add("webkit", parseFloat(dua.split("WebKit/")[1]) || undefined);
has.add("chrome", parseFloat(dua.split("Chrome/")[1]) || undefined);
has.add("safari", dav.indexOf("Safari")>=0 && !has("chrome") ? parseFloat(dav.split("Version/")[1]) : undefined);
has.add("mac", dav.indexOf("Macintosh") >= 0);
has.add("quirks", document.compatMode == "BackCompat");
if(dua.match(/(iPhone|iPod|iPad)/)){
var p = RegExp.$1.replace(/P/, "p");
var v = dua.match(/OS ([\d_]+)/) ? RegExp.$1 : "1";
var os = parseFloat(v.replace(/_/, ".").replace(/_/g, ""));
has.add(p, os); // "iphone", "ipad" or "ipod"
has.add("ios", os);
}
has.add("android", parseFloat(dua.split("Android ")[1]) || undefined);
has.add("bb", (dua.indexOf("BlackBerry") >= 0 || dua.indexOf("BB10") >= 0) && parseFloat(dua.split("Version/")[1]) || undefined);
has.add("svg", typeof SVGAngle !== "undefined");
if(!has("webkit")){
// Opera
if(dua.indexOf("Opera") >= 0){
// see http://dev.opera.com/articles/view/opera-ua-string-changes and http://www.useragentstring.com/pages/Opera/
// 9.8 has both styles; <9.8, 9.9 only old style
has.add("opera", tv >= 9.8 ? parseFloat(dua.split("Version/")[1]) || tv : tv);
}
// Mozilla and firefox
if(dua.indexOf("Gecko") >= 0 && !has("khtml") && !has("webkit")){
has.add("mozilla", tv);
}
if(has("mozilla")){
//We really need to get away from this. Consider a sane isGecko approach for the future.
has.add("ff", parseFloat(dua.split("Firefox/")[1] || dua.split("Minefield/")[1]) || undefined);
}
// IE
if(document.all && !has("opera")){
var 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(isIE) != mode){
isIE = mode;
}
has.add("ie", isIE);
}
// Wii
has.add("wii", typeof opera != "undefined" && opera.wiiremote);
}
}
return has;
});

View File

@@ -0,0 +1,63 @@
define(["../../_base/array", "../../_base/lang", "../../when"
], function(array, lang, when){
// module:
// dojo/store/util/QueryResults
var QueryResults = function(results){
// summary:
// A function that wraps the results of a store query with additional
// methods.
// description:
// QueryResults is a basic wrapper that allows for array-like iteration
// over any kind of returned data from a query. While the simplest store
// will return a plain array of data, other stores may return deferreds or
// promises; this wrapper makes sure that *all* results can be treated
// the same.
//
// Additional methods include `forEach`, `filter` and `map`.
// results: Array|dojo/promise/Promise
// The result set as an array, or a promise for an array.
// returns:
// An array-like object that can be used for iterating over.
// example:
// Query a store and iterate over the results.
//
// | store.query({ prime: true }).forEach(function(item){
// | // do something
// | });
if(!results){
return results;
}
// if it is a promise it may be frozen
if(results.then){
results = lang.delegate(results);
}
function addIterativeMethod(method){
if(!results[method]){
results[method] = function(){
var args = arguments;
return when(results, function(results){
Array.prototype.unshift.call(args, results);
return QueryResults(array[method].apply(array, args));
});
};
}
}
addIterativeMethod("forEach");
addIterativeMethod("filter");
addIterativeMethod("map");
if(!results.total){
results.total = when(results, function(results){
return results.length;
});
}
return results; // Object
};
lang.setObject("dojo.store.util.QueryResults", QueryResults);
return QueryResults;
});

View File

@@ -0,0 +1,110 @@
define(["../../_base/array" /*=====, "../api/Store" =====*/], function(arrayUtil /*=====, Store =====*/){
// module:
// dojo/store/util/SimpleQueryEngine
return function(query, options){
// summary:
// Simple query engine that matches using filter functions, named filter
// functions or objects by name-value on a query object hash
//
// description:
// The SimpleQueryEngine provides a way of getting a QueryResults through
// the use of a simple object hash as a filter. The hash will be used to
// match properties on data objects with the corresponding value given. In
// other words, only exact matches will be returned.
//
// This function can be used as a template for more complex query engines;
// for example, an engine can be created that accepts an object hash that
// contains filtering functions, or a string that gets evaluated, etc.
//
// When creating a new dojo.store, simply set the store's queryEngine
// field as a reference to this function.
//
// query: Object
// An object hash with fields that may match fields of items in the store.
// Values in the hash will be compared by normal == operator, but regular expressions
// or any object that provides a test() method are also supported and can be
// used to match strings by more complex expressions
// (and then the regex's or object's test() method will be used to match values).
//
// options: dojo/store/api/Store.QueryOptions?
// An object that contains optional information such as sort, start, and count.
//
// returns: Function
// A function that caches the passed query under the field "matches". See any
// of the "query" methods on dojo.stores.
//
// example:
// Define a store with a reference to this engine, and set up a query method.
//
// | var myStore = function(options){
// | // ...more properties here
// | this.queryEngine = SimpleQueryEngine;
// | // define our query method
// | this.query = function(query, options){
// | return QueryResults(this.queryEngine(query, options)(this.data));
// | };
// | };
// create our matching query function
switch(typeof query){
default:
throw new Error("Can not query with a " + typeof query);
case "object": case "undefined":
var queryObject = query;
query = function(object){
for(var key in queryObject){
var required = queryObject[key];
if(required && required.test){
// an object can provide a test method, which makes it work with regex
if(!required.test(object[key], object)){
return false;
}
}else if(required != object[key]){
return false;
}
}
return true;
};
break;
case "string":
// named query
if(!this[query]){
throw new Error("No filter function " + query + " was found in store");
}
query = this[query];
// fall through
case "function":
// fall through
}
function execute(array){
// execute the whole query, first we filter
var results = arrayUtil.filter(array, query);
// next we sort
var sortSet = options && options.sort;
if(sortSet){
results.sort(typeof sortSet == "function" ? sortSet : function(a, b){
for(var sort, i=0; sort = sortSet[i]; i++){
var aValue = a[sort.attribute];
var bValue = b[sort.attribute];
if (aValue != bValue){
return !!sort.descending == (aValue == null || aValue > bValue) ? -1 : 1;
}
}
return 0;
});
}
// now we paginate
if(options && (options.start || options.count)){
var total = results.length;
results = results.slice(options.start || 0, (options.start || 0) + (options.count || Infinity));
results.total = total;
}
return results;
}
execute.matches = query;
return execute;
};
});

55
debian/missing-sources/dojo/when.js vendored Normal file
View File

@@ -0,0 +1,55 @@
define([
"./Deferred",
"./promise/Promise"
], function(Deferred, Promise){
"use strict";
// module:
// dojo/when
return function when(valueOrPromise, callback, errback, progback){
// summary:
// Transparently applies callbacks to values and/or promises.
// description:
// Accepts promises but also transparently handles non-promises. If no
// callbacks are provided returns a promise, regardless of the initial
// value. Foreign promises are converted.
//
// If callbacks are provided and the initial value is not a promise,
// the callback is executed immediately with no error handling. Returns
// a promise if the initial value is a promise, or the result of the
// callback otherwise.
// valueOrPromise:
// Either a regular value or an object with a `then()` method that
// follows the Promises/A specification.
// callback: Function?
// Callback to be invoked when the promise is resolved, or a non-promise
// is received.
// errback: Function?
// Callback to be invoked when the promise is rejected.
// progback: Function?
// Callback to be invoked when the promise emits a progress update.
// returns: dojo/promise/Promise
// Promise, or if a callback is provided, the result of the callback.
var receivedPromise = valueOrPromise && typeof valueOrPromise.then === "function";
var nativePromise = receivedPromise && valueOrPromise instanceof Promise;
if(!receivedPromise){
if(arguments.length > 1){
return callback ? callback(valueOrPromise) : valueOrPromise;
}else{
return new Deferred().resolve(valueOrPromise);
}
}else if(!nativePromise){
var deferred = new Deferred(valueOrPromise.cancel);
valueOrPromise.then(deferred.resolve, deferred.reject, deferred.progress);
valueOrPromise = deferred.promise;
}
if(callback || errback || progback){
return valueOrPromise.then(callback, errback, progback);
}
return valueOrPromise;
};
});