Skip to content

Commit

Permalink
added AMD loader, refs #12672 \!strict
Browse files Browse the repository at this point in the history
  • Loading branch information
rcgill committed Apr 14, 2011
1 parent e90518a commit 5306646
Show file tree
Hide file tree
Showing 175 changed files with 8,223 additions and 5,361 deletions.
7 changes: 6 additions & 1 deletion AdapterRegistry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/AdapterRegistry", ["dojo"], function(dojo) {
define(["."], function(dojo) {
// module:
// dojo/AdapterRegistry
// summary:
// TODOC:This module defines


dojo.AdapterRegistry = function(/*Boolean?*/ returnWrappers){
// summary:
Expand Down
7 changes: 6 additions & 1 deletion DeferredList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/DeferredList", ["dojo"], function(dojo) {
define(["."], function(dojo) {
// module:
// dojo/DeferredList
// summary:
// TODOC:This module defines


dojo.DeferredList = function(/*Array*/ list, /*Boolean?*/ fireOnOneCallback, /*Boolean?*/ fireOnOneErrback, /*Boolean?*/ consumeErrors, /*Function?*/ canceller){
// summary:
Expand Down
7 changes: 6 additions & 1 deletion NodeList-data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/NodeList-data", ["dojo"], function(dojo) {
define(["."], function(dojo) {
// module:
// dojo/NodeList-data
// summary:
// TODOC:This module defines

(function(d){

/*=====
Expand Down
7 changes: 6 additions & 1 deletion NodeList-fx.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/NodeList-fx", ["dojo", "dojo/fx"], function(dojo) {
define([".", "./fx"], function(dojo) {
// module:
// dojo/NodeList-fx
// summary:
// TODOC:This module defines


/*=====
dojo["NodeList-fx"] = {
Expand Down
7 changes: 6 additions & 1 deletion NodeList-html.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/NodeList-html", ["dojo", "dojo/html"], function(dojo) {
define([".", "./html"], function(dojo) {
// module:
// dojo/NodeList-html
// summary:
// TODOC:This module defines


/*=====
dojo["NodeList-html"] = {
Expand Down
7 changes: 6 additions & 1 deletion NodeList-manipulate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/NodeList-manipulate", ["dojo"], function(dojo) {
define(["."], function(dojo) {
// module:
// dojo/NodeList-manipulate
// summary:
// TODOC:This module defines


/*=====
dojo["NodeList-manipulate"] = {
Expand Down
7 changes: 6 additions & 1 deletion NodeList-traverse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/NodeList-traverse", ["dojo"], function(dojo) {
define(["."], function(dojo) {
// module:
// dojo/NodeList-traverse
// summary:
// TODOC:This module defines


/*=====
dojo["NodeList-traverse"] = {
Expand Down
7 changes: 6 additions & 1 deletion Stateful.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
define("dojo/Stateful", ["dojo"], function(dojo) {
define(["."], function(dojo) {
// module:
// dojo/Stateful
// summary:
// TODOC:This module defines


dojo.declare("dojo.Stateful", null, {
// summary:
Expand Down
69 changes: 32 additions & 37 deletions _base/Color.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/lang"], function(dojo){

(function(){

var d = dojo;
define(["./kernel", "./array", "./lang"], function(dojo){

dojo.Color = function(/*Array|String|Object*/ color){
// summary:
// Takes a named string, hex string, array of rgb or rgba values,
// an object with r, g, b, and a properties, or another `dojo.Color` object
// and creates a new Color instance to work from.
// Takes a named string, hex string, array of rgb or rgba values,
// an object with r, g, b, and a properties, or another `dojo.Color` object
// and creates a new Color instance to work from.
//
// example:
// Work with a Color instance:
Expand All @@ -27,26 +23,26 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
};

// FIXME:
// there's got to be a more space-efficient way to encode or discover
// these!! Use hex?
// there's got to be a more space-efficient way to encode or discover
// these!! Use hex?
dojo.Color.named = {
black: [0,0,0],
silver: [192,192,192],
gray: [128,128,128],
white: [255,255,255],
black: [0,0,0],
silver: [192,192,192],
gray: [128,128,128],
white: [255,255,255],
maroon: [128,0,0],
red: [255,0,0],
red: [255,0,0],
purple: [128,0,128],
fuchsia: [255,0,255],
green: [0,128,0],
lime: [0,255,0],
green: [0,128,0],
lime: [0,255,0],
olive: [128,128,0],
yellow: [255,255,0],
navy: [0,0,128],
blue: [0,0,255],
navy: [0,0,128],
blue: [0,0,255],
teal: [0,128,128],
aqua: [0,255,255],
transparent: d.config.transparentColor || [255,255,255]
transparent: dojo.config.transparentColor || [255,255,255]
};

dojo.extend(dojo.Color, {
Expand All @@ -63,13 +59,13 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// example:
// | var c = new dojo.Color(); // no color
// | c.setColor("#ededed"); // greyish
if(d.isString(color)){
d.colorFromString(color, this);
}else if(d.isArray(color)){
d.colorFromArray(color, this);
if(dojo.isString(color)){
dojo.colorFromString(color, this);
}else if(dojo.isArray(color)){
dojo.colorFromArray(color, this);
}else{
this._set(color.r, color.g, color.b, color.a);
if(!(color instanceof d.Color)){ this.sanitize(); }
if(!(color instanceof dojo.Color)){ this.sanitize(); }
}
return this; // dojo.Color
},
Expand All @@ -86,7 +82,7 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// Returns 3 component array of rgb values
// example:
// | var c = new dojo.Color("#000000");
// | console.log(c.toRgb()); // [0,0,0]
// | console.log(c.toRgb()); // [0,0,0]
var t = this;
return [t.r, t.g, t.b]; // Array
},
Expand All @@ -101,8 +97,8 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// summary:
// Returns a CSS color string in hexadecimal representation
// example:
// | console.log(new dojo.Color([0,0,0]).toHex()); // #000000
var arr = d.map(["r", "g", "b"], function(x){
// | console.log(new dojo.Color([0,0,0]).toHex()); // #000000
var arr = dojo.map(["r", "g", "b"], function(x){
var s = this[x].toString(16);
return s.length < 2 ? "0" + s : s;
}, this);
Expand Down Expand Up @@ -133,8 +129,8 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// summary:
// Blend colors end and start with weight from 0 to 1, 0.5 being a 50/50 blend,
// can reuse a previously allocated dojo.Color object for the result
var t = obj || new d.Color();
d.forEach(["r", "g", "b", "a"], function(x){
var t = obj || new dojo.Color();
dojo.forEach(["r", "g", "b", "a"], function(x){
t[x] = start[x] + (end[x] - start[x]) * weight;
if(x != "a"){ t[x] = Math.round(t[x]); }
});
Expand Down Expand Up @@ -167,14 +163,14 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
//
// example:
// | var thing = dojo.colorFromHex("#000"); // black, shorthand
var t = obj || new d.Color(),
var t = obj || new dojo.Color(),
bits = (color.length == 4) ? 4 : 8,
mask = (1 << bits) - 1;
color = Number("0x" + color.substr(1));
if(isNaN(color)){
return null; // dojo.Color
}
d.forEach(["b", "g", "r"], function(x){
dojo.forEach(["b", "g", "r"], function(x){
var c = color & mask;
color >>= bits;
t[x] = bits == 4 ? 17 * c : c;
Expand All @@ -191,7 +187,7 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// | var myColor = dojo.colorFromArray([237,237,237,0.5]); // grey, 50% alpha
// returns:
// A dojo.Color object. If obj is passed, it will be the return value.
var t = obj || new d.Color();
var t = obj || new dojo.Color();
t._set(Number(a[0]), Number(a[1]), Number(a[2]), Number(a[3]));
if(isNaN(t.a)){ t.a = 1; }
return t.sanitize(); // dojo.Color
Expand All @@ -208,10 +204,9 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// 10, 50)"
// returns:
// A dojo.Color object. If obj is passed, it will be the return value.
var a = d.Color.named[str];
return a && d.colorFromArray(a, obj) || d.colorFromRgb(str, obj) || d.colorFromHex(str, obj);
var a = dojo.Color.named[str];
return a && dojo.colorFromArray(a, obj) || dojo.colorFromRgb(str, obj) || dojo.colorFromHex(str, obj);
};
})();

return dojo.Color;
return dojo.Color;
});
113 changes: 58 additions & 55 deletions _base/Deferred.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo){
define(["./kernel", "./lang"], function(dojo){
// module:
// dojo/_base/Deferred
// summary:
// This module defines dojo.Deferred.

(function(){
var mutator = function(){};
var freeze = Object.freeze || function(){};
// A deferred provides an API for creating and resolving a promise.
dojo.Deferred = function(/*Function?*/canceller){
// summary:
// Deferreds provide a generic means for encapsulating an asynchronous
// operation and notifying users of the completion and result of the operation.
// operation and notifying users of the completion and result of the operation.
// description:
// The dojo.Deferred API is based on the concept of promises that provide a
// generic interface into the eventual completion of an asynchronous action.
Expand All @@ -23,20 +26,20 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// separated from the concerns of asynchronous interaction (which are
// handled by the promise).
//
// The dojo.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:
// The dojo.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){
// | 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.
// execution of the callback. The callbacks will never affect the original promises value.
//
// The dojo.Deferred instances also provide the following functions for backwards compatibility:
//
Expand All @@ -48,7 +51,7 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// 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
// 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
Expand Down Expand Up @@ -231,26 +234,26 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// provide the implementation of the promise
this.then = promise.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.
// 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.
// 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.
//
// example:
// An example of using a CommonJS compliant promise:
// | asyncComputeTheAnswerToEverything().
// An example of using a CommonJS compliant promise:
// | asyncComputeTheAnswerToEverything().
// | then(addTwo).
// | then(printResult, onError);
// | >44
// | >44
//
var returnDeferred = progressCallback == mutator ? this : new dojo.Deferred(promise.cancel);
var listener = {
Expand Down Expand Up @@ -302,35 +305,35 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
},
fired: -1
});
})();
dojo.when = function(promiseOrValue, /*Function?*/callback, /*Function?*/errback, /*Function?*/progressHandler){
// summary:
// This provides normalization between normal synchronous values and
// asynchronous promises, so you can interact with them in a common way
// example:
// | function printFirstAndList(items){
// | dojo.when(findFirst(items), console.log);
// | dojo.when(findLast(items), console.log);
// | }
// | function findFirst(items){
// | return dojo.when(items, function(items){
// | return items[0];
// | });
// | }
// | function findLast(items){
// | return dojo.when(items, function(items){
// | return items[items.length];
// | });
// | }
// And now all three of his functions can be used sync or async.
// | printFirstAndLast([1,2,3,4]) will work just as well as
// | printFirstAndLast(dojo.xhrGet(...));

if(promiseOrValue && typeof promiseOrValue.then === "function"){
return promiseOrValue.then(callback, errback, progressHandler);
}
return callback(promiseOrValue);
};

return dojo.Deferred;
dojo.when = function(promiseOrValue, /*Function?*/callback, /*Function?*/errback, /*Function?*/progressHandler){
// summary:
// This provides normalization between normal synchronous values and
// asynchronous promises, so you can interact with them in a common way
// example:
// | function printFirstAndList(items){
// | dojo.when(findFirst(items), console.log);
// | dojo.when(findLast(items), console.log);
// | }
// | function findFirst(items){
// | return dojo.when(items, function(items){
// | return items[0];
// | });
// | }
// | function findLast(items){
// | return dojo.when(items, function(items){
// | return items[items.length];
// | });
// | }
// And now all three of his functions can be used sync or async.
// | printFirstAndLast([1,2,3,4]) will work just as well as
// | printFirstAndLast(dojo.xhrGet(...));

if(promiseOrValue && typeof promiseOrValue.then === "function"){
return promiseOrValue.then(callback, errback, progressHandler);
}
return callback(promiseOrValue);
};

return dojo.Deferred;
});
Loading

0 comments on commit 5306646

Please sign in to comment.