Commit ad6a96b2 authored by Adam Peller's avatar Adam Peller

Using r11542 to create a tag for the 1.0.0rc1 release.

git-svn-id: http://svn.dojotoolkit.org/src/tags/release-1.0.0rc1/dojo@11543 560b804f-0ae3-0310-86f3-f6aa0a117693
parent 1215b7fa
dojo.provide("dojo.AdapterRegistry");
dojo.AdapterRegistry = function(/*Boolean?*/ returnWrappers){
// summary:
// A registry to make contextual calling/searching easier.
// description:
// Objects of this class keep list of arrays in the form [name, check,
// wrap, directReturn] that are used to determine what the contextual
// result of a set of checked arguments is. All check/wrap functions
// in this registry should be of the same arity.
// example:
// | // create a new registry
// | var reg = new dojo.AdapterRegistry();
// | reg.register("handleString",
// | dojo.isString,
// | function(str){
// | // do something with the string here
// | }
// | );
// | reg.register("handleArr",
// | dojo.isArray,
// | function(arr){
// | // do something with the array here
// | }
// | );
// |
// | // now we can pass reg.match() *either* an array or a string and
// | // the value we pass will get handled by the right function
// | reg.match("someValue"); // will call the first function
// | reg.match(["someValue"]); // will call the second
this.pairs = [];
this.returnWrappers = returnWrappers || false; // Boolean
}
dojo.extend(dojo.AdapterRegistry, {
register: function(/*String*/ name, /*Function*/ check, /*Function*/ wrap, /*Boolean?*/ directReturn, /*Boolean?*/ override){
// summary:
// register a check function to determine if the wrap function or
// object gets selected
// name:
// a way to identify this matcher.
// check:
// a function that arguments are passed to from the adapter's
// match() function. The check function should return true if the
// given arguments are appropriate for the wrap function.
// directReturn:
// If directReturn is true, the value passed in for wrap will be
// returned instead of being called. Alternately, the
// AdapterRegistry can be set globally to "return not call" using
// the returnWrappers property. Either way, this behavior allows
// the registry to act as a "search" function instead of a
// function interception library.
// override:
// If override is given and true, the check function will be given
// highest priority. Otherwise, it will be the lowest priority
// adapter.
this.pairs[((override) ? "unshift" : "push")]([name, check, wrap, directReturn]);
},
match: function(/* ... */){
// summary:
// Find an adapter for the given arguments. If no suitable adapter
// is found, throws an exception. match() accepts any number of
// arguments, all of which are passed to all matching functions
// from the registered pairs.
for(var i = 0; i < this.pairs.length; i++){
var pair = this.pairs[i];
if(pair[1].apply(this, arguments)){
if((pair[3])||(this.returnWrappers)){
return pair[2];
}else{
return pair[2].apply(this, arguments);
}
}
}
throw new Error("No match found");
},
unregister: function(name){
// summary: Remove a named adapter from the registry
// FIXME: this is kind of a dumb way to handle this. On a large
// registry this will be slow-ish and we can use the name as a lookup
// should we choose to trade memory for speed.
for(var i = 0; i < this.pairs.length; i++){
var pair = this.pairs[i];
if(pair[0] == name){
this.pairs.splice(i, 1);
return true;
}
}
return false;
}
});
dojo.provide("dojo.DeferredList");
dojo.declare("dojo.DeferredList", dojo.Deferred, {
constructor: function(/*Array*/ list, /*Boolean?*/ fireOnOneCallback, /*Boolean?*/ fireOnOneErrback, /*Boolean?*/ consumeErrors, /*Function?*/ canceller){
// summary:
// Provides event handling for a group of Deferred objects.
// description:
// DeferredList takes an array of existing deferreds and returns a new deferred of its own
// this new deferred will typically have its callback fired when all of the deferreds in
// the given list have fired their own deferreds. The parameters `fireOnOneCallback` and
// fireOnOneErrback, will fire before all the deferreds as appropriate
//
// list:
// The list of deferreds to be synchronizied with this DeferredList
// fireOnOneCallback:
// Will cause the DeferredLists callback to be fired as soon as any
// of the deferreds in its list have been fired instead of waiting until
// the entire list has finished
// fireonOneErrback:
// Will cause the errback to fire upon any of the deferreds errback
// canceller:
// A deferred canceller function, see dojo.Deferred
this.list = list;
this.resultList = new Array(this.list.length);
// Deferred init
this.chain = [];
this.id = this._nextId();
this.fired = -1;
this.paused = 0;
this.results = [null, null];
this.canceller = canceller;
this.silentlyCancelled = false;
if (this.list.length === 0 && !fireOnOneCallback) {
this.callback(this.resultList);
}
this.finishedCount = 0;
this.fireOnOneCallback = fireOnOneCallback;
this.fireOnOneErrback = fireOnOneErrback;
this.consumeErrors = consumeErrors;
var index = 0;
dojo.forEach(this.list, function(d, index) {
d.addCallback(this, function(r) { this._cbDeferred(index, true, r); return r; });
d.addErrback(this, function(r) { this._cbDeferred(index, false, r); return r; });
index++;
},this);
},
_cbDeferred: function (index, succeeded, result) {
// summary:
// The DeferredLists' callback handler
this.resultList[index] = [succeeded, result]; this.finishedCount += 1;
if (this.fired !== 0) {
if (succeeded && this.fireOnOneCallback) {
this.callback([index, result]);
} else if (!succeeded && this.fireOnOneErrback) {
this.errback(result);
} else if (this.finishedCount == this.list.length) {
this.callback(this.resultList);
}
}
if (!succeeded && this.consumeErrors) {
result = null;
}
return result;
},
gatherResults: function (deferredList) {
// summary:
// Gathers the results of the deferreds for packaging
// as the parameters to the Deferred Lists' callback
var d = new dojo.DeferedList(deferredList, false, true, false);
d.addCallback(function (results) {
var ret = [];
for (var i = 0; i < results.length; i++) {
ret.push(results[i][1]);
}
return ret;
});
return d;
}
});
This diff is collapsed.
dojo.provide("dojo.NodeList-fx");
dojo.require("dojo.fx");
dojo.extend(dojo.NodeList, {
_anim: function(obj, method, args){
var anims = [];
args = args||{};
this.forEach(function(item){
var tmpArgs = { node: item };
dojo.mixin(tmpArgs, args);
anims.push(obj[method](tmpArgs));
});
return dojo.fx.combine(anims); // dojo._Animation
},
wipeIn: function(args){
// summary:
// wipe in all elements of this NodeList. Returns an instance of dojo._Animation
// example:
// Fade in all tables with class "blah":
// | dojo.query("table.blah").wipeIn().play();
return this._anim(dojo.fx, "wipeIn", args); // dojo._Animation
},
wipeOut: function(args){
// summary:
// wipe out all elements of this NodeList. Returns an instance of dojo._Animation
// example:
// Wipe out all tables with class "blah":
// | dojo.query("table.blah").wipeOut().play();
return this._anim(dojo.fx, "wipeOut", args); // dojo._Animation
},
slideTo: function(args){
// summary:
// slide all elements of the node list to the specified place.
// Returns an instance of dojo._Animation
// example:
// | Move all tables with class "blah" to 300/300:
// | dojo.query("table.blah").slideTo({
// | left: 40,
// | top: 50
// | }).play();
return this._anim(dojo.fx, "slideTo", args); // dojo._Animation
},
fadeIn: function(args){
// summary:
// fade in all elements of this NodeList. Returns an instance of dojo._Animation
// example:
// Fade in all tables with class "blah":
// | dojo.query("table.blah").fadeIn().play();
return this._anim(dojo, "fadeIn", args); // dojo._Animation
},
fadeOut: function(args){
// summary:
// fade out all elements of this NodeList. Returns an instance of dojo._Animation
// example:
// Fade out all elements with class "zork":
// | dojo.query(".zork").fadeOut().play();
// example:
// Fade them on a delay and do something at the end:
// | var fo = dojo.query(".zork").fadeOut();
// | dojo.connect(fo, "onEnd", function(){ /*...*/ });
// | fo.play();
return this._anim(dojo, "fadeOut", args); // dojo._Animation
},
animateProperty: function(args){
// summary:
// see dojo.animateProperty(). Animate all elements of this
// NodeList across the properties specified.
// example:
// | dojo.query(".zork").animateProperty({
// | duration: 500,
// | properties: {
// | color: { start: "black", end: "white" },
// | left: { end: 300 }
// | }
// | }).play();
return this._anim(dojo, "animateProperty", args); // dojo._Animation
}
});
/*******************************************************************************
* OpenAjax.js
*
* Reference implementation of the OpenAjax Hub, as specified by OpenAjax Alliance.
* Specification is under development at:
*
* http://www.openajax.org/member/wiki/OpenAjax_Hub_Specification
*
* Copyright 2006-2007 OpenAjax Alliance
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless
* required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
******************************************************************************/
// prevent re-definition of the OpenAjax object
if(!window["OpenAjax"]){
OpenAjax = new function(){
var t = true;
var f = false;
var g = window;
var libs;
var ooh = "org.openajax.hub.";
var h = {};
this.hub = h;
h.implementer = "http://openajax.org";
h.implVersion = "0.6";
h.specVersion = "0.6";
h.implExtraData = {};
var libs = {};
h.libraries = libs;
h.registerLibrary = function(prefix, nsURL, version, extra){
libs[prefix] = {
prefix: prefix,
namespaceURI: nsURL,
version: version,
extraData: extra
};
this.publish(ooh+"registerLibrary", libs[prefix]);
}
h.unregisterLibrary = function(prefix){
this.publish(ooh+"unregisterLibrary", libs[prefix]);
delete libs[prefix];
}
h._subscriptions = { c:{}, s:[] };
h._cleanup = [];
h._subIndex = 0;
h._pubDepth = 0;
h.subscribe = function(name, callback, scope, subscriberData, filter){
if(!scope){
scope = window;
}
var handle = name + "." + this._subIndex;
var sub = { scope: scope, cb: callback, fcb: filter, data: subscriberData, sid: this._subIndex++, hdl: handle };
var path = name.split(".");
this._subscribe(this._subscriptions, path, 0, sub);
return handle;
}
h.publish = function(name, message){
var path = name.split(".");
this._pubDepth++;
this._publish(this._subscriptions, path, 0, name, message);
this._pubDepth--;
if((this._cleanup.length > 0) && (this._pubDepth == 0)){
for(var i = 0; i < this._cleanup.length; i++){
this.unsubscribe(this._cleanup[i].hdl);
}
delete(this._cleanup);
this._cleanup = [];
}
}
h.unsubscribe = function(sub){
var path = sub.split(".");
var sid = path.pop();
this._unsubscribe(this._subscriptions, path, 0, sid);
}
h._subscribe = function(tree, path, index, sub){
var token = path[index];
if(index == path.length){
tree.s.push(sub);
}else{
if(typeof tree.c == "undefined"){
tree.c = {};
}
if(typeof tree.c[token] == "undefined"){
tree.c[token] = { c: {}, s: [] };
this._subscribe(tree.c[token], path, index + 1, sub);
}else{
this._subscribe( tree.c[token], path, index + 1, sub);
}
}
}
h._publish = function(tree, path, index, name, msg){
if(typeof tree != "undefined"){
var node;
if(index == path.length) {
node = tree;
}else{
this._publish(tree.c[path[index]], path, index + 1, name, msg);
this._publish(tree.c["*"], path, index + 1, name, msg);
node = tree.c["**"];
}
if(typeof node != "undefined"){
var callbacks = node.s;
var max = callbacks.length;
for(var i = 0; i < max; i++){
if(callbacks[i].cb){
var sc = callbacks[i].scope;
var cb = callbacks[i].cb;
var fcb = callbacks[i].fcb;
var d = callbacks[i].data;
if(typeof cb == "string"){
// get a function object
cb = sc[cb];
}
if(typeof fcb == "string"){
// get a function object
fcb = sc[fcb];
}
if((!fcb) ||
(fcb.call(sc, name, msg, d))) {
cb.call(sc, name, msg, d);
}
}
}
}
}
}
h._unsubscribe = function(tree, path, index, sid) {
if(typeof tree != "undefined") {
if(index < path.length) {
var childNode = tree.c[path[index]];
this._unsubscribe(childNode, path, index + 1, sid);
if(childNode.s.length == 0) {
for(var x in childNode.c)
return;
delete tree.c[path[index]];
}
return;
}
else {
var callbacks = tree.s;
var max = callbacks.length;
for(var i = 0; i < max; i++)
if(sid == callbacks[i].sid) {
if(this._pubDepth > 0) {
callbacks[i].cb = null;
this._cleanup.push(callbacks[i]);
}
else
callbacks.splice(i, 1);
return;
}
}
}
}
// The following function is provided for automatic testing purposes.
// It is not expected to be deployed in run-time OpenAjax Hub implementations.
h.reinit = function()
{
for (var lib in OpenAjax.hub.libraries) {
delete OpenAjax.hub.libraries[lib];
}
OpenAjax.hub.registerLibrary("OpenAjax", "http://openajax.org/hub", "0.6", {});
delete OpenAjax._subscriptions;
OpenAjax._subscriptions = {c:{},s:[]};
delete OpenAjax._cleanup;
OpenAjax._cleanup = [];
OpenAjax._subIndex = 0;
OpenAjax._pubDepth = 0;
}
};
// Register the OpenAjax Hub itself as a library.
OpenAjax.hub.registerLibrary("OpenAjax", "http://openajax.org/hub", "0.6", {});
}
dojo.provide("dojo._base");
dojo.require("dojo._base.lang");
dojo.require("dojo._base.declare");
dojo.require("dojo._base.connect");
dojo.require("dojo._base.Deferred");
dojo.require("dojo._base.json");
dojo.require("dojo._base.array");
dojo.require("dojo._base.Color");
dojo.requireIf(dojo.isBrowser, "dojo._base.window");
dojo.requireIf(dojo.isBrowser, "dojo._base.event");
dojo.requireIf(dojo.isBrowser, "dojo._base.html");
dojo.requireIf(dojo.isBrowser, "dojo._base.NodeList");
dojo.requireIf(dojo.isBrowser, "dojo._base.query");
dojo.requireIf(dojo.isBrowser, "dojo._base.xhr");
dojo.requireIf(dojo.isBrowser, "dojo._base.fx");
(function(){
if(djConfig.require){
for(var x=0; x<djConfig.require.length; x++){
dojo["require"](djConfig.require[x]);
}
}
})();
dojo.provide("dojo._base.Color");
dojo.require("dojo._base.array");
dojo.require("dojo._base.lang");
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
if(color){ this.setColor(color); }
};
// FIXME: 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],
maroon: [128,0,0],
red: [255,0,0],
purple: [128,0,128],
fuchsia: [255,0,255],
green: [0,128,0],
lime: [0,255,0],
olive: [128,128,0],
yellow: [255,255,0],
navy: [0,0,128],
blue: [0,0,255],
teal: [0,128,128],
aqua: [0,255,255]
};
dojo.extend(dojo.Color, {
r: 255, g: 255, b: 255, a: 1,
_set: function(r, g, b, a){
var t = this; t.r = r; t.g = g; t.b = b; t.a = a;
},
setColor: 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
var d = dojo;
if(d.isString(color)){
d.colorFromString(color, this);
}else if(d.isArray(color)){
d.colorFromArray(color, this);
}else{
this._set(color.r, color.g, color.b, color.a);
if(!(color instanceof d.Color)){ this.sanitize(); }
}
return this; // dojo.Color
},
sanitize: function(){
// summary:
// makes sure that the object has correct attributes
// description:
// the default implementation does nothing, include dojo.colors to
// augment it to real checks
return this; // dojo.Color
},
toRgb: function(){
// summary: returns 3 component array of rgb values
var t = this;
return [t.r, t.g, t.b]; // Array
},
toRgba: function(){
// summary: returns a 4 component array of rgba values
var t = this;
return [t.r, t.g, t.b, t.a]; // Array
},
toHex: function(){
// summary: returns a css color string in hexadecimal representation
var arr = dojo.map(["r", "g", "b"], function(x){
var s = this[x].toString(16);
return s.length < 2 ? "0" + s : s;
}, this);
return "#" + arr.join(""); // String
},
toCss: function(/*Boolean?*/ includeAlpha){
// summary: returns a css color string in rgb(a) representation
var t = this, rgb = t.r + ", " + t.g + ", " + t.b;
return (includeAlpha ? "rgba(" + rgb + ", " + t.a : "rgb(" + rgb) + ")"; // String
},
toString: function(){
// summary: returns a visual representation of the color
return this.toCss(true); // String
}
});
dojo.blendColors = function(
/*dojo.Color*/ start,
/*dojo.Color*/ end,
/*Number*/ weight,
/*dojo.Color?*/ obj
){
// 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 d = dojo, t = obj || new dojo.Color();
d.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]); }
});
return t.sanitize(); // dojo.Color
};
dojo.colorFromRgb = function(/*String*/ color, /*dojo.Color?*/ obj){
// summary: get rgb(a) array from css-style color declarations
var m = color.toLowerCase().match(/^rgba?\(([\s\.,0-9]+)\)/);
return m && dojo.colorFromArray(m[1].split(/\s*,\s*/), obj); // dojo.Color
};