You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/08/19 00:33:00 UTC
svn commit: r432754 [13/28] - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/animation/ src/collections/ src/compat/ src/crypto/ src/data/
src/data/format/ src/data/provider/ src/debug/ s...
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,108 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lang.extras");
+
+dojo.require("dojo.lang.common");
+
+/**
+ * Sets a timeout in milliseconds to execute a function in a given context
+ * with optional arguments.
+ *
+ * setTimeout (Object context, function func, number delay[, arg1[, ...]]);
+ * setTimeout (function func, number delay[, arg1[, ...]]);
+ */
+dojo.lang.setTimeout = function(func, delay){
+ var context = window, argsStart = 2;
+ if(!dojo.lang.isFunction(func)){
+ context = func;
+ func = delay;
+ delay = arguments[2];
+ argsStart++;
+ }
+
+ if(dojo.lang.isString(func)){
+ func = context[func];
+ }
+
+ var args = [];
+ for (var i = argsStart; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ }
+ return setTimeout(function () { func.apply(context, args); }, delay);
+}
+
+dojo.lang.getNameInObj = function(ns, item){
+ if(!ns){ ns = dj_global; }
+
+ for(var x in ns){
+ if(ns[x] === item){
+ return new String(x);
+ }
+ }
+ return null;
+}
+
+dojo.lang.shallowCopy = function(obj) {
+ var ret = {}, key;
+ for(key in obj) {
+ if(dojo.lang.isUndefined(ret[key])) {
+ ret[key] = obj[key];
+ }
+ }
+ return ret;
+}
+
+/**
+ * Return the first argument that isn't undefined
+ */
+dojo.lang.firstValued = function(/* ... */) {
+ for(var i = 0; i < arguments.length; i++) {
+ if(typeof arguments[i] != "undefined") {
+ return arguments[i];
+ }
+ }
+ return undefined;
+}
+
+/**
+ * Get a value from a reference specified as a string descriptor,
+ * (e.g. "A.B") in the given context.
+ *
+ * getObjPathValue(String objpath [, Object context, Boolean create])
+ *
+ * If context is not specified, dj_global is used
+ * If create is true, undefined objects in the path are created.
+ */
+dojo.lang.getObjPathValue = function(objpath, context, create){
+ with(dojo.parseObjPath(objpath, context, create)){
+ return dojo.evalProp(prop, obj, create);
+ }
+}
+
+/**
+ * Set a value on a reference specified as a string descriptor.
+ * (e.g. "A.B") in the given context.
+ *
+ * setObjPathValue(String objpath, value [, Object context, Boolean create])
+ *
+ * If context is not specified, dj_global is used
+ * If create is true, undefined objects in the path are created.
+ */
+dojo.lang.setObjPathValue = function(objpath, value, context, create){
+ if(arguments.length < 4){
+ create = true;
+ }
+ with(dojo.parseObjPath(objpath, context, create)){
+ if(obj && (create || (prop in obj))){
+ obj[prop] = value;
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,150 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lang.func");
+
+dojo.require("dojo.lang.common");
+
+/**
+ * Runs a function in a given scope (thisObject), can
+ * also be used to preserve scope.
+ *
+ * hitch(foo, "bar"); // runs foo.bar() in the scope of foo
+ * hitch(foo, myFunction); // runs myFunction in the scope of foo
+ */
+dojo.lang.hitch = function(thisObject, method) {
+ if(dojo.lang.isString(method)) {
+ var fcn = thisObject[method];
+ } else {
+ var fcn = method;
+ }
+
+ return function() {
+ return fcn.apply(thisObject, arguments);
+ }
+}
+
+dojo.lang.anonCtr = 0;
+dojo.lang.anon = {};
+dojo.lang.nameAnonFunc = function(anonFuncPtr, namespaceObj, searchForNames){
+ var nso = (namespaceObj || dojo.lang.anon);
+ if( (searchForNames) ||
+ ((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)) ){
+ for(var x in nso){
+ if(nso[x] === anonFuncPtr){
+ return x;
+ }
+ }
+ }
+ var ret = "__"+dojo.lang.anonCtr++;
+ while(typeof nso[ret] != "undefined"){
+ ret = "__"+dojo.lang.anonCtr++;
+ }
+ nso[ret] = anonFuncPtr;
+ return ret;
+}
+
+dojo.lang.forward = function(funcName){
+ // Returns a function that forwards a method call to this.func(...)
+ return function(){
+ return this[funcName].apply(this, arguments);
+ };
+}
+
+dojo.lang.curry = function(ns, func /* args ... */){
+ var outerArgs = [];
+ ns = ns||dj_global;
+ if(dojo.lang.isString(func)){
+ func = ns[func];
+ }
+ for(var x=2; x<arguments.length; x++){
+ outerArgs.push(arguments[x]);
+ }
+ // since the event system replaces the original function with a new
+ // join-point runner with an arity of 0, we check to see if it's left us
+ // any clues about the original arity in lieu of the function's actual
+ // length property
+ var ecount = (func["__preJoinArity"]||func.length) - outerArgs.length;
+ // borrowed from svend tofte
+ function gather(nextArgs, innerArgs, expected){
+ var texpected = expected;
+ var totalArgs = innerArgs.slice(0); // copy
+ for(var x=0; x<nextArgs.length; x++){
+ totalArgs.push(nextArgs[x]);
+ }
+ // check the list of provided nextArgs to see if it, plus the
+ // number of innerArgs already supplied, meets the total
+ // expected.
+ expected = expected-nextArgs.length;
+ if(expected<=0){
+ var res = func.apply(ns, totalArgs);
+ expected = texpected;
+ return res;
+ }else{
+ return function(){
+ return gather(arguments,// check to see if we've been run
+ // with enough args
+ totalArgs, // a copy
+ expected); // how many more do we need to run?;
+ }
+ }
+ }
+ return gather([], outerArgs, ecount);
+}
+
+dojo.lang.curryArguments = function(ns, func, args, offset){
+ var targs = [];
+ var x = offset||0;
+ for(x=offset; x<args.length; x++){
+ targs.push(args[x]); // ensure that it's an arr
+ }
+ return dojo.lang.curry.apply(dojo.lang, [ns, func].concat(targs));
+}
+
+dojo.lang.tryThese = function(){
+ for(var x=0; x<arguments.length; x++){
+ try{
+ if(typeof arguments[x] == "function"){
+ var ret = (arguments[x]());
+ if(ret){
+ return ret;
+ }
+ }
+ }catch(e){
+ dojo.debug(e);
+ }
+ }
+}
+
+dojo.lang.delayThese = function(farr, cb, delay, onend){
+ /**
+ * alternate: (array funcArray, function callback, function onend)
+ * alternate: (array funcArray, function callback)
+ * alternate: (array funcArray)
+ */
+ if(!farr.length){
+ if(typeof onend == "function"){
+ onend();
+ }
+ return;
+ }
+ if((typeof delay == "undefined")&&(typeof cb == "number")){
+ delay = cb;
+ cb = function(){};
+ }else if(!cb){
+ cb = function(){};
+ if(!delay){ delay = 0; }
+ }
+ setTimeout(function(){
+ (farr.shift())();
+ cb();
+ dojo.lang.delayThese(farr, cb, delay, onend);
+ }, delay);
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,90 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lang.repr");
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.AdapterRegistry");
+dojo.require("dojo.string.extras");
+
+dojo.lang.reprRegistry = new dojo.AdapterRegistry();
+dojo.lang.registerRepr = function(name, check, wrap, /*optional*/ override){
+ /***
+ Register a repr function. repr functions should take
+ one argument and return a string representation of it
+ suitable for developers, primarily used when debugging.
+
+ If override is given, it is used as the highest priority
+ repr, otherwise it will be used as the lowest.
+ ***/
+ dojo.lang.reprRegistry.register(name, check, wrap, override);
+ };
+
+dojo.lang.repr = function(obj){
+ /***
+ Return a "programmer representation" for an object
+ ***/
+ if(typeof(obj) == "undefined"){
+ return "undefined";
+ }else if(obj === null){
+ return "null";
+ }
+
+ try{
+ if(typeof(obj["__repr__"]) == 'function'){
+ return obj["__repr__"]();
+ }else if((typeof(obj["repr"]) == 'function')&&(obj.repr != arguments.callee)){
+ return obj["repr"]();
+ }
+ return dojo.lang.reprRegistry.match(obj);
+ }catch(e){
+ if(typeof(obj.NAME) == 'string' && (
+ obj.toString == Function.prototype.toString ||
+ obj.toString == Object.prototype.toString
+ )){
+ return o.NAME;
+ }
+ }
+
+ if(typeof(obj) == "function"){
+ obj = (obj + "").replace(/^\s+/, "");
+ var idx = obj.indexOf("{");
+ if(idx != -1){
+ obj = obj.substr(0, idx) + "{...}";
+ }
+ }
+ return obj + "";
+}
+
+dojo.lang.reprArrayLike = function(arr){
+ try{
+ var na = dojo.lang.map(arr, dojo.lang.repr);
+ return "[" + na.join(", ") + "]";
+ }catch(e){ }
+};
+
+dojo.lang.reprString = function(str){
+ dojo.deprecated("dojo.lang.reprNumber", "use `String(num)` instead", "0.4");
+ return dojo.string.escapeString(str);
+};
+
+dojo.lang.reprNumber = function(num){
+ dojo.deprecated("dojo.lang.reprNumber", "use `String(num)` instead", "0.4");
+ return num + "";
+};
+
+(function(){
+ var m = dojo.lang;
+ m.registerRepr("arrayLike", m.isArrayLike, m.reprArrayLike);
+ m.registerRepr("string", m.isString, m.reprString);
+ m.registerRepr("numbers", m.isNumber, m.reprNumber);
+ m.registerRepr("boolean", m.isBoolean, m.reprNumber);
+ // m.registerRepr("numbers", m.typeMatcher("number", "boolean"), m.reprNumber);
+})();
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,226 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lang.type");
+
+dojo.require("dojo.lang.common");
+
+dojo.lang.whatAmI = function(wh) {
+ try {
+ if(dojo.lang.isArray(wh)) { return "array"; }
+ if(dojo.lang.isFunction(wh)) { return "function"; }
+ if(dojo.lang.isString(wh)) { return "string"; }
+ if(dojo.lang.isNumber(wh)) { return "number"; }
+ if(dojo.lang.isBoolean(wh)) { return "boolean"; }
+ if(dojo.lang.isAlien(wh)) { return "alien"; }
+ if(dojo.lang.isUndefined(wh)) { return "undefined"; }
+ // FIXME: should this go first?
+ for(var name in dojo.lang.whatAmI.custom) {
+ if(dojo.lang.whatAmI.custom[name](wh)) {
+ return name;
+ }
+ }
+ if(dojo.lang.isObject(wh)) { return "object"; }
+ } catch(E) {}
+ return "unknown";
+}
+/*
+ * dojo.lang.whatAmI.custom[typeName] = someFunction
+ * will return typeName is someFunction(wh) returns true
+ */
+dojo.lang.whatAmI.custom = {};
+
+/**
+ * Returns true for values that commonly represent numbers.
+ *
+ * Examples:
+ * <pre>
+ * dojo.lang.isNumeric(3); // returns true
+ * dojo.lang.isNumeric("3"); // returns true
+ * dojo.lang.isNumeric(new Number(3)); // returns true
+ * dojo.lang.isNumeric(new String("3")); // returns true
+ *
+ * dojo.lang.isNumeric(3/0); // returns false
+ * dojo.lang.isNumeric("foo"); // returns false
+ * dojo.lang.isNumeric(new Number("foo")); // returns false
+ * dojo.lang.isNumeric(false); // returns false
+ * dojo.lang.isNumeric(true); // returns false
+ * </pre>
+ */
+dojo.lang.isNumeric = function(wh){
+ return (!isNaN(wh) && isFinite(wh) && (wh != null) &&
+ !dojo.lang.isBoolean(wh) && !dojo.lang.isArray(wh));
+}
+
+/**
+ * Returns true for any literal, and for any object that is an
+ * instance of a built-in type like String, Number, Boolean,
+ * Array, Function, or Error.
+ */
+dojo.lang.isBuiltIn = function(wh){
+ return (dojo.lang.isArray(wh) ||
+ dojo.lang.isFunction(wh) ||
+ dojo.lang.isString(wh) ||
+ dojo.lang.isNumber(wh) ||
+ dojo.lang.isBoolean(wh) ||
+ (wh == null) ||
+ (wh instanceof Error) ||
+ (typeof wh == "error") );
+}
+
+/**
+ * Returns true for any object where the value of the
+ * property 'constructor' is 'Object'.
+ *
+ * Examples:
+ * <pre>
+ * dojo.lang.isPureObject(new Object()); // returns true
+ * dojo.lang.isPureObject({a: 1, b: 2}); // returns true
+ *
+ * dojo.lang.isPureObject(new Date()); // returns false
+ * dojo.lang.isPureObject([11, 2, 3]); // returns false
+ * </pre>
+ */
+dojo.lang.isPureObject = function(wh){
+ return ((wh != null) && dojo.lang.isObject(wh) && wh.constructor == Object);
+}
+
+/**
+ * Given a value and a datatype, this method returns true if the
+ * type of the value matches the datatype. The datatype parameter
+ * can be an array of datatypes, in which case the method returns
+ * true if the type of the value matches any of the datatypes.
+ *
+ * Examples:
+ * <pre>
+ * dojo.lang.isOfType("foo", String); // returns true
+ * dojo.lang.isOfType(12345, Number); // returns true
+ * dojo.lang.isOfType(false, Boolean); // returns true
+ * dojo.lang.isOfType([6, 8], Array); // returns true
+ * dojo.lang.isOfType(dojo.lang.isOfType, Function); // returns true
+ * dojo.lang.isOfType({foo: "bar"}, Object); // returns true
+ * dojo.lang.isOfType(new Date(), Date); // returns true
+ * dojo.lang.isOfType(xxxxx, Date); // returns true
+ *
+ * dojo.lang.isOfType("foo", "string"); // returns true
+ * dojo.lang.isOfType(12345, "number"); // returns true
+ * dojo.lang.isOfType(false, "boolean"); // returns true
+ * dojo.lang.isOfType([6, 8], "array"); // returns true
+ * dojo.lang.isOfType(dojo.lang.isOfType, "function"); // returns true
+ * dojo.lang.isOfType({foo: "bar"}, "object"); // returns true
+ * dojo.lang.isOfType(xxxxx, "undefined"); // returns true
+ * dojo.lang.isOfType(null, "null"); // returns true
+
+ * dojo.lang.isOfType("foo", [Number, String, Boolean]); // returns true
+ * dojo.lang.isOfType(12345, [Number, String, Boolean]); // returns true
+ * dojo.lang.isOfType(false, [Number, String, Boolean]); // returns true
+ * dojo.lang.isOfType(xxxxx, "undefined"); // returns true
+ * </pre>
+ *
+ * @param value Any literal value or object instance.
+ * @param type A class of object, or a literal type, or the string name of a type, or an array with a list of types.
+ * @return Returns a boolean
+ */
+dojo.lang.isOfType = function(value, type) {
+ if(dojo.lang.isArray(type)){
+ var arrayOfTypes = type;
+ for(var i in arrayOfTypes){
+ var aType = arrayOfTypes[i];
+ if(dojo.lang.isOfType(value, aType)) {
+ return true;
+ }
+ }
+ return false;
+ }else{
+ if(dojo.lang.isString(type)){
+ type = type.toLowerCase();
+ }
+ switch (type) {
+ case Array:
+ case "array":
+ return dojo.lang.isArray(value);
+ break;
+ case Function:
+ case "function":
+ return dojo.lang.isFunction(value);
+ break;
+ case String:
+ case "string":
+ return dojo.lang.isString(value);
+ break;
+ case Number:
+ case "number":
+ return dojo.lang.isNumber(value);
+ break;
+ case "numeric":
+ return dojo.lang.isNumeric(value);
+ break;
+ case Boolean:
+ case "boolean":
+ return dojo.lang.isBoolean(value);
+ break;
+ case Object:
+ case "object":
+ return dojo.lang.isObject(value);
+ break;
+ case "pureobject":
+ return dojo.lang.isPureObject(value);
+ break;
+ case "builtin":
+ return dojo.lang.isBuiltIn(value);
+ break;
+ case "alien":
+ return dojo.lang.isAlien(value);
+ break;
+ case "undefined":
+ return dojo.lang.isUndefined(value);
+ break;
+ case null:
+ case "null":
+ return (value === null);
+ break;
+ case "optional":
+ return ((value === null) || dojo.lang.isUndefined(value));
+ break;
+ default:
+ if (dojo.lang.isFunction(type)) {
+ return (value instanceof type);
+ } else {
+ dojo.raise("dojo.lang.isOfType() was passed an invalid type");
+ }
+ break;
+ }
+ }
+ dojo.raise("If we get here, it means a bug was introduced above.");
+}
+
+/*
+ * From reflection code, part of merge.
+ * TRT 2006-02-01
+ */
+dojo.lang.getObject=function(/* String */ str){
+ // summary
+ // Will return an object, if it exists, based on the name in the passed string.
+ var parts=str.split("."), i=0, obj=dj_global;
+ do{
+ obj=obj[parts[i++]];
+ }while(i<parts.length&&obj);
+ return (obj!=dj_global)?obj:null; // Object
+}
+
+dojo.lang.doesObjectExist=function(/* String */ str){
+ // summary
+ // Check to see if object [str] exists, based on the passed string.
+ var parts=str.split("."), i=0, obj=dj_global;
+ do{
+ obj=obj[parts[i++]];
+ }while(i<parts.length&&obj);
+ return (obj&&obj!=dj_global); // boolean
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/Animation.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/Animation.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/Animation.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/Animation.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,476 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.Animation");
+dojo.provide("dojo.lfx.Line");
+
+dojo.require("dojo.lang.func");
+
+/*
+ Animation package based on Dan Pupius' work: http://pupius.co.uk/js/Toolkit.Drawing.js
+*/
+dojo.lfx.Line = function(start, end){
+ this.start = start;
+ this.end = end;
+ if(dojo.lang.isArray(start)){
+ var diff = [];
+ dojo.lang.forEach(this.start, function(s,i){
+ diff[i] = this.end[i] - s;
+ }, this);
+
+ this.getValue = function(/*float*/ n){
+ var res = [];
+ dojo.lang.forEach(this.start, function(s, i){
+ res[i] = (diff[i] * n) + s;
+ }, this);
+ return res;
+ }
+ }else{
+ var diff = end - start;
+
+ this.getValue = function(/*float*/ n){
+ // summary: returns the point on the line
+ // n: a floating point number greater than 0 and less than 1
+ return (diff * n) + this.start;
+ }
+ }
+}
+
+dojo.lfx.easeIn = function(n){
+ // summary: returns the point on an easing curve
+ // n: a floating point number greater than 0 and less than 1
+ return Math.pow(n, 3);
+}
+
+dojo.lfx.easeOut = function(n){
+ // summary: returns the point on the line
+ // n: a floating point number greater than 0 and less than 1
+ return ( 1 - Math.pow(1 - n, 3) );
+}
+
+dojo.lfx.easeInOut = function(n){
+ // summary: returns the point on the line
+ // n: a floating point number greater than 0 and less than 1
+ return ( (3 * Math.pow(n, 2)) - (2 * Math.pow(n, 3)) );
+}
+
+dojo.lfx.IAnimation = function(){}
+dojo.lang.extend(dojo.lfx.IAnimation, {
+ // public properties
+ curve: null,
+ duration: 1000,
+ easing: null,
+ repeatCount: 0,
+ rate: 25,
+
+ // events
+ handler: null,
+ beforeBegin: null,
+ onBegin: null,
+ onAnimate: null,
+ onEnd: null,
+ onPlay: null,
+ onPause: null,
+ onStop: null,
+
+ // public methods
+ play: null,
+ pause: null,
+ stop: null,
+
+ fire: function(evt, args){
+ if(this[evt]){
+ this[evt].apply(this, (args||[]));
+ }
+ },
+
+ // private properties
+ _active: false,
+ _paused: false
+});
+
+dojo.lfx.Animation = function(/*Object*/ handlers, /*int*/ duration, /*Array*/ curve, /*function*/ easing, /*int*/ repeatCount, /*int*/ rate){
+ // summary
+ // a generic animation object that fires callbacks into it's handlers
+ // object at various states
+ // handlers
+ // object {
+ // handler: function(){},
+ // onstart: function(){},
+ // onstop: function(){},
+ // onanimate: function(){}
+ // }
+ dojo.lfx.IAnimation.call(this);
+ if(dojo.lang.isNumber(handlers)||(!handlers && duration.getValue)){
+ // no handlers argument:
+ rate = repeatCount;
+ repeatCount = easing;
+ easing = curve;
+ curve = duration;
+ duration = handlers;
+ handlers = null;
+ }else if(handlers.getValue||dojo.lang.isArray(handlers)){
+ // no handlers or duration:
+ rate = easing;
+ repeatCount = curve;
+ easing = duration;
+ curve = handlers;
+ duration = null;
+ handlers = null;
+ }
+ if(dojo.lang.isArray(curve)){
+ this.curve = new dojo.lfx.Line(curve[0], curve[1]);
+ }else{
+ this.curve = curve;
+ }
+ if(duration != null && duration > 0){ this.duration = duration; }
+ if(repeatCount){ this.repeatCount = repeatCount; }
+ if(rate){ this.rate = rate; }
+ if(handlers){
+ this.handler = handlers.handler;
+ this.beforeBegin = handlers.beforeBegin;
+ this.onBegin = handlers.onBegin;
+ this.onEnd = handlers.onEnd;
+ this.onPlay = handlers.onPlay;
+ this.onPause = handlers.onPause;
+ this.onStop = handlers.onStop;
+ this.onAnimate = handlers.onAnimate;
+ }
+ if(easing && dojo.lang.isFunction(easing)){
+ this.easing=easing;
+ }
+}
+dojo.inherits(dojo.lfx.Animation, dojo.lfx.IAnimation);
+dojo.lang.extend(dojo.lfx.Animation, {
+ // "private" properties
+ _startTime: null,
+ _endTime: null,
+ _timer: null,
+ _percent: 0,
+ _startRepeatCount: 0,
+
+ // public methods
+ play: function(delay, gotoStart){
+ if(gotoStart){
+ clearTimeout(this._timer);
+ this._active = false;
+ this._paused = false;
+ this._percent = 0;
+ }else if(this._active && !this._paused){
+ return this;
+ }
+
+ this.fire("handler", ["beforeBegin"]);
+ this.fire("beforeBegin");
+
+ if(delay > 0){
+ setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
+ return this;
+ }
+
+ this._startTime = new Date().valueOf();
+ if(this._paused){
+ this._startTime -= (this.duration * this._percent / 100);
+ }
+ this._endTime = this._startTime + this.duration;
+
+ this._active = true;
+ this._paused = false;
+
+ var step = this._percent / 100;
+ var value = this.curve.getValue(step);
+ if( this._percent == 0 ) {
+ if(!this._startRepeatCount) {
+ this._startRepeatCount = this.repeatCount;
+ }
+ this.fire("handler", ["begin", value]);
+ this.fire("onBegin", [value]);
+ }
+
+ this.fire("handler", ["play", value]);
+ this.fire("onPlay", [value]);
+
+ this._cycle();
+ return this;
+ },
+
+ pause: function() {
+ clearTimeout(this._timer);
+ if(!this._active){ return this; }
+ this._paused = true;
+ var value = this.curve.getValue(this._percent / 100);
+ this.fire("handler", ["pause", value]);
+ this.fire("onPause", [value]);
+ return this;
+ },
+
+ gotoPercent: function(pct, andPlay) {
+ clearTimeout(this._timer);
+ this._active = true;
+ this._paused = true;
+ this._percent = pct;
+ if( andPlay ) { this.play(); }
+ },
+
+ stop: function(gotoEnd) {
+ clearTimeout(this._timer);
+ var step = this._percent / 100;
+ if( gotoEnd ) {
+ step = 1;
+ }
+ var value = this.curve.getValue(step);
+ this.fire("handler", ["stop", value]);
+ this.fire("onStop", [value]);
+ this._active = false;
+ this._paused = false;
+ return this;
+ },
+
+ status: function() {
+ if( this._active ) {
+ return this._paused ? "paused" : "playing";
+ } else {
+ return "stopped";
+ }
+ },
+
+ // "private" methods
+ _cycle: function() {
+ clearTimeout(this._timer);
+ if(this._active){
+ var curr = new Date().valueOf();
+ var step = (curr - this._startTime) / (this._endTime - this._startTime);
+
+ if(step >= 1){
+ step = 1;
+ this._percent = 100;
+ }else{
+ this._percent = step * 100;
+ }
+
+ // Perform easing
+ if((this.easing)&&(dojo.lang.isFunction(this.easing))){
+ step = this.easing(step);
+ }
+
+ var value = this.curve.getValue(step);
+ this.fire("handler", ["animate", value]);
+ this.fire("onAnimate", [value]);
+
+ if( step < 1 ) {
+ this._timer = setTimeout(dojo.lang.hitch(this, "_cycle"), this.rate);
+ } else {
+ this._active = false;
+ this.fire("handler", ["end"]);
+ this.fire("onEnd");
+
+ if( this.repeatCount > 0 ) {
+ this.repeatCount--;
+ this.play(null, true);
+ } else if( this.repeatCount == -1 ) {
+ this.play(null, true);
+ } else {
+ if(this._startRepeatCount) {
+ this.repeatCount = this._startRepeatCount;
+ this._startRepeatCount = 0;
+ }
+ }
+ }
+ }
+ return this;
+ }
+});
+
+dojo.lfx.Combine = function(){
+ dojo.lfx.IAnimation.call(this);
+ this._anims = [];
+ this._animsEnded = 0;
+
+ var anims = arguments;
+ if(anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))){
+ anims = anims[0];
+ }
+
+ var _this = this;
+ dojo.lang.forEach(anims, function(anim){
+ _this._anims.push(anim);
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); _this._onAnimsEnded(); };
+ });
+}
+dojo.inherits(dojo.lfx.Combine, dojo.lfx.IAnimation);
+dojo.lang.extend(dojo.lfx.Combine, {
+ // private members
+ _animsEnded: 0,
+
+ // public methods
+ play: function(delay, gotoStart){
+ if( !this._anims.length ){ return this; }
+
+ this.fire("beforeBegin");
+
+ if(delay > 0){
+ setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
+ return this;
+ }
+
+ if(gotoStart || this._anims[0].percent == 0){
+ this.fire("onBegin");
+ }
+ this.fire("onPlay");
+ this._animsCall("play", null, gotoStart);
+ return this;
+ },
+
+ pause: function(){
+ this.fire("onPause");
+ this._animsCall("pause");
+ return this;
+ },
+
+ stop: function(gotoEnd){
+ this.fire("onStop");
+ this._animsCall("stop", gotoEnd);
+ return this;
+ },
+
+ // private methods
+ _onAnimsEnded: function(){
+ this._animsEnded++;
+ if(this._animsEnded >= this._anims.length){
+ this.fire("onEnd");
+ }
+ return this;
+ },
+
+ _animsCall: function(funcName){
+ var args = [];
+ if(arguments.length > 1){
+ for(var i = 1 ; i < arguments.length ; i++){
+ args.push(arguments[i]);
+ }
+ }
+ var _this = this;
+ dojo.lang.forEach(this._anims, function(anim){
+ anim[funcName](args);
+ }, _this);
+ return this;
+ }
+});
+
+dojo.lfx.Chain = function() {
+ dojo.lfx.IAnimation.call(this);
+ this._anims = [];
+ this._currAnim = -1;
+
+ var anims = arguments;
+ if(anims.length == 1 && (dojo.lang.isArray(anims[0]) || dojo.lang.isArrayLike(anims[0]))){
+ anims = anims[0];
+ }
+
+ var _this = this;
+ dojo.lang.forEach(anims, function(anim, i, anims_arr){
+ _this._anims.push(anim);
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ if(i < anims_arr.length - 1){
+ anim.onEnd = function(){ oldOnEnd(); _this._playNext(); };
+ }else{
+ anim.onEnd = function(){ oldOnEnd(); _this.fire("onEnd"); };
+ }
+ }, _this);
+}
+dojo.inherits(dojo.lfx.Chain, dojo.lfx.IAnimation);
+dojo.lang.extend(dojo.lfx.Chain, {
+ // private members
+ _currAnim: -1,
+
+ // public methods
+ play: function(delay, gotoStart){
+ if( !this._anims.length ) { return this; }
+ if( gotoStart || !this._anims[this._currAnim] ) {
+ this._currAnim = 0;
+ }
+
+ var currentAnimation = this._anims[this._currAnim];
+
+ this.fire("beforeBegin");
+ if(delay > 0){
+ setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
+ return this;
+ }
+
+ if(currentAnimation){
+ if(this._currAnim == 0){
+ this.fire("handler", ["begin", this._currAnim]);
+ this.fire("onBegin", [this._currAnim]);
+ }
+ this.fire("onPlay", [this._currAnim]);
+ currentAnimation.play(null, gotoStart);
+ }
+ return this;
+ },
+
+ pause: function(){
+ if( this._anims[this._currAnim] ) {
+ this._anims[this._currAnim].pause();
+ this.fire("onPause", [this._currAnim]);
+ }
+ return this;
+ },
+
+ playPause: function(){
+ if(this._anims.length == 0){ return this; }
+ if(this._currAnim == -1){ this._currAnim = 0; }
+ var currAnim = this._anims[this._currAnim];
+ if( currAnim ) {
+ if( !currAnim._active || currAnim._paused ) {
+ this.play();
+ } else {
+ this.pause();
+ }
+ }
+ return this;
+ },
+
+ stop: function(){
+ var currAnim = this._anims[this._currAnim];
+ if(currAnim){
+ currAnim.stop();
+ this.fire("onStop", [this._currAnim]);
+ }
+ return currAnim;
+ },
+
+ // private methods
+ _playNext: function(){
+ if( this._currAnim == -1 || this._anims.length == 0 ) { return this; }
+ this._currAnim++;
+ if( this._anims[this._currAnim] ){
+ this._anims[this._currAnim].play(null, true);
+ }
+ return this;
+ }
+});
+
+dojo.lfx.combine = function(){
+ var anims = arguments;
+ if(dojo.lang.isArray(arguments[0])){
+ anims = arguments[0];
+ }
+ return new dojo.lfx.Combine(anims);
+}
+
+dojo.lfx.chain = function(){
+ var anims = arguments;
+ if(dojo.lang.isArray(arguments[0])){
+ anims = arguments[0];
+ }
+ return new dojo.lfx.Chain(anims);
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/__package__.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/__package__.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/__package__.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,15 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ browser: ["dojo.lfx.html"],
+ dashboard: ["dojo.lfx.html"]
+});
+dojo.provide("dojo.lfx.*");
\ No newline at end of file
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/extras.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/extras.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/extras.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/extras.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,119 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.extras");
+
+dojo.require("dojo.lfx.html");
+dojo.require("dojo.lfx.Animation");
+
+dojo.lfx.html.fadeWipeIn = function(nodes, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anim = dojo.lfx.combine(
+ dojo.lfx.wipeIn(nodes, duration, easing),
+ dojo.lfx.fadeIn(nodes, duration, easing));
+
+ if(callback){
+ dojo.event.connect(anim, "onEnd", function(){
+ callback(nodes, anim);
+ });
+ }
+
+ return anim;
+}
+
+dojo.lfx.html.fadeWipeOut = function(nodes, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anim = dojo.lfx.combine(
+ dojo.lfx.wipeOut(nodes, duration, easing),
+ dojo.lfx.fadeOut(nodes, duration, easing));
+
+ if(callback){
+ dojo.event.connect(anim, "onEnd", function(){
+ callback(nodes, anim);
+ });
+ }
+
+ return anim;
+}
+
+dojo.lfx.html.scale = function(nodes, percentage, scaleContent, fromCenter, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var origWidth = dojo.style.getOuterWidth(node);
+ var origHeight = dojo.style.getOuterHeight(node);
+
+ var actualPct = percentage/100.0;
+ var props = [
+ { property: "width",
+ start: origWidth,
+ end: origWidth * actualPct
+ },
+ { property: "height",
+ start: origHeight,
+ end: origHeight * actualPct
+ }];
+
+ if(scaleContent){
+ var fontSize = dojo.style.getStyle(node, 'font-size');
+ var fontSizeType = null;
+ if(!fontSize){
+ fontSize = parseFloat('100%');
+ fontSizeType = '%';
+ }else{
+ dojo.lang.some(['em','px','%'], function(item, index, arr){
+ if(fontSize.indexOf(item)>0){
+ fontSize = parseFloat(fontSize);
+ fontSizeType = item;
+ return true;
+ }
+ });
+ }
+ props.push({
+ property: "font-size",
+ start: fontSize,
+ end: fontSize * actualPct,
+ units: fontSizeType });
+ }
+
+ if(fromCenter){
+ var positioning = dojo.style.getStyle(node, "position");
+ var originalTop = node.offsetTop;
+ var originalLeft = node.offsetLeft;
+ var endTop = ((origHeight * actualPct) - origHeight)/2;
+ var endLeft = ((origWidth * actualPct) - origWidth)/2;
+ props.push({
+ property: "top",
+ start: originalTop,
+ end: (positioning == "absolute" ? originalTop - endTop : (-1*endTop))
+ });
+ props.push({
+ property: "left",
+ start: originalLeft,
+ end: (positioning == "absolute" ? originalLeft - endLeft : (-1*endLeft))
+ });
+ }
+
+ var anim = dojo.lfx.propertyAnimation(node, props, duration, easing);
+ if(callback){
+ dojo.event.connect(anim, "onEnd", function(){
+ callback(node, anim);
+ });
+ }
+
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else{ return anims[0]; }
+}
+
+dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/html.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/html.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/html.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/html.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,535 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.html");
+dojo.require("dojo.lfx.Animation");
+
+dojo.require("dojo.html");
+
+dojo.lfx.html._byId = function(nodes){
+ if(!nodes){ return []; }
+ if(dojo.lang.isArray(nodes)){
+ if(!nodes.alreadyChecked){
+ var n = [];
+ dojo.lang.forEach(nodes, function(node){
+ n.push(dojo.byId(node));
+ });
+ n.alreadyChecked = true;
+ return n;
+ }else{
+ return nodes;
+ }
+ }else{
+ var n = [];
+ n.push(dojo.byId(nodes));
+ n.alreadyChecked = true;
+ return n;
+ }
+}
+
+dojo.lfx.html.propertyAnimation = function( /*DOMNode*/ nodes,
+ /*Array*/ propertyMap,
+ /*int*/ duration,
+ /*function*/ easing){
+ nodes = dojo.lfx.html._byId(nodes);
+
+ if(nodes.length==1){
+ // FIXME: we're only supporting start-value filling when one node is
+ // passed
+
+ dojo.lang.forEach(propertyMap, function(prop){
+ if(typeof prop["start"] == "undefined"){
+ if(prop.property != "opacity"){
+ prop.start = parseInt(dojo.style.getComputedStyle(nodes[0], prop.property));
+ }else{
+ prop.start = dojo.style.getOpacity(nodes[0]);
+ }
+ }
+ });
+ }
+
+ var coordsAsInts = function(coords){
+ var cints = new Array(coords.length);
+ for(var i = 0; i < coords.length; i++){
+ cints[i] = Math.round(coords[i]);
+ }
+ return cints;
+ }
+ var setStyle = function(n, style){
+ n = dojo.byId(n);
+ if(!n || !n.style){ return; }
+ for(var s in style){
+ if(s == "opacity"){
+ dojo.style.setOpacity(n, style[s]);
+ }else{
+ n.style[s] = style[s];
+ }
+ }
+ }
+ var propLine = function(properties){
+ this._properties = properties;
+ this.diffs = new Array(properties.length);
+ dojo.lang.forEach(properties, function(prop, i){
+ // calculate the end - start to optimize a bit
+ if(dojo.lang.isArray(prop.start)){
+ // don't loop through the arrays
+ this.diffs[i] = null;
+ }else if(prop.start instanceof dojo.graphics.color.Color){
+ // save these so we don't have to call toRgb() every getValue() call
+ prop.startRgb = prop.start.toRgb();
+ prop.endRgb = prop.end.toRgb();
+ }else{
+ this.diffs[i] = prop.end - prop.start;
+ }
+ }, this);
+ this.getValue = function(n){
+ var ret = {};
+ dojo.lang.forEach(this._properties, function(prop, i){
+ var value = null;
+ if(dojo.lang.isArray(prop.start)){
+ // FIXME: what to do here?
+ }else if(prop.start instanceof dojo.graphics.color.Color){
+ value = (prop.units||"rgb") + "(";
+ for(var j = 0 ; j < prop.startRgb.length ; j++){
+ value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : "");
+ }
+ value += ")";
+ }else{
+ value = ((this.diffs[i]) * n) + prop.start + (prop.property != "opacity" ? prop.units||"px" : "");
+ }
+ ret[dojo.style.toCamelCase(prop.property)] = value;
+ }, this);
+ return ret;
+ }
+ }
+
+ var anim = new dojo.lfx.Animation({
+ onAnimate: function(propValues){
+ dojo.lang.forEach(nodes, function(node){
+ setStyle(node, propValues);
+ });
+ } }, duration, new propLine(propertyMap), easing);
+
+ return anim;
+}
+
+dojo.lfx.html._makeFadeable = function(nodes){
+ var makeFade = function(node){
+ if(dojo.render.html.ie){
+ // only set the zoom if the "tickle" value would be the same as the
+ // default
+ if( (node.style.zoom.length == 0) &&
+ (dojo.style.getStyle(node, "zoom") == "normal") ){
+ // make sure the node "hasLayout"
+ // NOTE: this has been tested with larger and smaller user-set text
+ // sizes and works fine
+ node.style.zoom = "1";
+ // node.style.zoom = "normal";
+ }
+ // don't set the width to auto if it didn't already cascade that way.
+ // We don't want to f anyones designs
+ if( (node.style.width.length == 0) &&
+ (dojo.style.getStyle(node, "width") == "auto") ){
+ node.style.width = "auto";
+ }
+ }
+ }
+ if(dojo.lang.isArrayLike(nodes)){
+ dojo.lang.forEach(nodes, makeFade);
+ }else{
+ makeFade(nodes);
+ }
+}
+
+dojo.lfx.html.fadeIn = function(nodes, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ dojo.lfx.html._makeFadeable(nodes);
+ var anim = dojo.lfx.propertyAnimation(nodes, [
+ { property: "opacity",
+ start: dojo.style.getOpacity(nodes[0]),
+ end: 1 } ], duration, easing);
+ if(callback){
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); callback(nodes, anim); };
+ }
+
+ return anim;
+}
+
+dojo.lfx.html.fadeOut = function(nodes, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ dojo.lfx.html._makeFadeable(nodes);
+ var anim = dojo.lfx.propertyAnimation(nodes, [
+ { property: "opacity",
+ start: dojo.style.getOpacity(nodes[0]),
+ end: 0 } ], duration, easing);
+ if(callback){
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); callback(nodes, anim); };
+ }
+
+ return anim;
+}
+
+dojo.lfx.html.fadeShow = function(nodes, duration, easing, callback){
+ var anim = dojo.lfx.html.fadeIn(nodes, duration, easing, callback);
+ var oldBb = (anim["beforeBegin"]) ? dojo.lang.hitch(anim, "beforeBegin") : function(){};
+ anim.beforeBegin = function(){
+ oldBb();
+ if(dojo.lang.isArrayLike(nodes)){
+ dojo.lang.forEach(nodes, dojo.style.show);
+ }else{
+ dojo.style.show(nodes);
+ }
+ };
+
+ return anim;
+}
+
+dojo.lfx.html.fadeHide = function(nodes, duration, easing, callback){
+ var anim = dojo.lfx.html.fadeOut(nodes, duration, easing, function(){
+ if(dojo.lang.isArrayLike(nodes)){
+ dojo.lang.forEach(nodes, dojo.style.hide);
+ }else{
+ dojo.style.hide(nodes);
+ }
+ if(callback){ callback(nodes, anim); }
+ });
+
+ return anim;
+}
+
+dojo.lfx.html.wipeIn = function(nodes, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var overflow = dojo.style.getStyle(node, "overflow");
+ if(overflow == "visible") {
+ node.style.overflow = "hidden";
+ }
+ node.style.height = "0px";
+ dojo.style.show(node);
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ [{ property: "height",
+ start: 0,
+ end: node.scrollHeight }], duration, easing);
+
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){
+ oldOnEnd();
+ node.style.overflow = overflow;
+ node.style.height = "auto";
+ if(callback){ callback(node, anim); }
+ };
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else{ return anims[0]; }
+}
+
+dojo.lfx.html.wipeOut = function(nodes, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var overflow = dojo.style.getStyle(node, "overflow");
+ if(overflow == "visible") {
+ node.style.overflow = "hidden";
+ }
+ dojo.style.show(node);
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ [{ property: "height",
+ start: dojo.style.getContentBoxHeight(node),
+ end: 0 } ], duration, easing);
+
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){
+ oldOnEnd();
+ dojo.style.hide(node);
+ node.style.overflow = overflow;
+ if(callback){ callback(node, anim); }
+ };
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else { return anims[0]; }
+}
+
+dojo.lfx.html.slideTo = function(nodes, coords, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var top = null;
+ var left = null;
+
+ var init = (function(){
+ var innerNode = node;
+ return function(){
+ top = innerNode.offsetTop;
+ left = innerNode.offsetLeft;
+
+ if (!dojo.style.isPositionAbsolute(innerNode)) {
+ var ret = dojo.style.abs(innerNode, true);
+ dojo.style.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;");
+ top = ret.y;
+ left = ret.x;
+ }
+ }
+ })();
+ init();
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ [{ property: "top",
+ start: top,
+ end: coords[0] },
+ { property: "left",
+ start: left,
+ end: coords[1] }], duration, easing);
+
+ var oldBb = (anim["beforeBegin"]) ? dojo.lang.hitch(anim, "beforeBegin") : function(){};
+ anim.beforeBegin = function(){ oldBb(); init(); };
+
+ if(callback){
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); callback(nodes, anim); };
+ }
+
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else{ return anims[0]; }
+}
+
+dojo.lfx.html.slideBy = function(nodes, coords, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var top = null;
+ var left = null;
+
+ var init = (function(){
+ var innerNode = node;
+ return function(){
+ top = node.offsetTop;
+ left = node.offsetLeft;
+
+ if (!dojo.style.isPositionAbsolute(innerNode)) {
+ var ret = dojo.style.abs(innerNode);
+ dojo.style.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;");
+ top = ret.y;
+ left = ret.x;
+ }
+ }
+ })();
+ init();
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ [{ property: "top",
+ start: top,
+ end: top+coords[0] },
+ { property: "left",
+ start: left,
+ end: left+coords[1] }], duration, easing);
+
+ var oldBb = (anim["beforeBegin"]) ? dojo.lang.hitch(anim, "beforeBegin") : function(){};
+ anim.beforeBegin = function(){ oldBb(); init(); };
+
+ if(callback){
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); callback(nodes, anim); };
+ }
+
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else{ return anims[0]; }
+}
+
+dojo.lfx.html.explode = function(start, endNode, duration, easing, callback){
+ start = dojo.byId(start);
+ endNode = dojo.byId(endNode);
+ var startCoords = dojo.style.toCoordinateArray(start, true);
+ var outline = document.createElement("div");
+ dojo.html.copyStyle(outline, endNode);
+ with(outline.style){
+ position = "absolute";
+ display = "none";
+ }
+ document.body.appendChild(outline);
+
+ with(endNode.style){
+ visibility = "hidden";
+ display = "block";
+ }
+ var endCoords = dojo.style.toCoordinateArray(endNode, true);
+ with(endNode.style){
+ display = "none";
+ visibility = "visible";
+ }
+
+ var anim = new dojo.lfx.propertyAnimation(outline, [
+ { property: "height", start: startCoords[3], end: endCoords[3] },
+ { property: "width", start: startCoords[2], end: endCoords[2] },
+ { property: "top", start: startCoords[1], end: endCoords[1] },
+ { property: "left", start: startCoords[0], end: endCoords[0] },
+ { property: "opacity", start: 0.3, end: 1.0 }
+ ], duration, easing);
+
+ anim.beforeBegin = function(){
+ dojo.style.setDisplay(outline, "block");
+ };
+ anim.onEnd = function(){
+ dojo.style.setDisplay(endNode, "block");
+ outline.parentNode.removeChild(outline);
+ };
+ if(callback){
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); callback(endNode, anim); };
+ }
+ return anim;
+}
+
+dojo.lfx.html.implode = function(startNode, end, duration, easing, callback){
+ startNode = dojo.byId(startNode);
+ end = dojo.byId(end);
+ var startCoords = dojo.style.toCoordinateArray(startNode, true);
+ var endCoords = dojo.style.toCoordinateArray(end, true);
+
+ var outline = document.createElement("div");
+ dojo.html.copyStyle(outline, startNode);
+ dojo.style.setOpacity(outline, 0.3);
+ with(outline.style){
+ position = "absolute";
+ display = "none";
+ }
+ document.body.appendChild(outline);
+
+ var anim = new dojo.lfx.propertyAnimation(outline, [
+ { property: "height", start: startCoords[3], end: endCoords[3] },
+ { property: "width", start: startCoords[2], end: endCoords[2] },
+ { property: "top", start: startCoords[1], end: endCoords[1] },
+ { property: "left", start: startCoords[0], end: endCoords[0] },
+ { property: "opacity", start: 1.0, end: 0.3 }
+ ], duration, easing);
+
+ anim.beforeBegin = function(){
+ dojo.style.hide(startNode);
+ dojo.style.show(outline);
+ };
+ anim.onEnd = function(){
+ outline.parentNode.removeChild(outline);
+ };
+ if(callback){
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){ oldOnEnd(); callback(startNode, anim); };
+ }
+ return anim;
+}
+
+dojo.lfx.html.highlight = function(nodes, startColor, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var color = dojo.style.getBackgroundColor(node);
+ var bg = dojo.style.getStyle(node, "background-color").toLowerCase();
+ var bgImage = dojo.style.getStyle(node, "background-image");
+ var wasTransparent = (bg == "transparent" || bg == "rgba(0, 0, 0, 0)");
+ while(color.length > 3) { color.pop(); }
+
+ var rgb = new dojo.graphics.color.Color(startColor);
+ var endRgb = new dojo.graphics.color.Color(color);
+
+ var anim = dojo.lfx.propertyAnimation(node, [{
+ property: "background-color",
+ start: rgb,
+ end: endRgb
+ }], duration, easing);
+
+ var oldbb = (anim["beforeBegin"]) ? dojo.lang.hitch(anim, "beforeBegin") : function(){};
+ anim.beforeBegin = function(){
+ oldbb();
+ if(bgImage){
+ node.style.backgroundImage = "none";
+ }
+ node.style.backgroundColor = "rgb(" + rgb.toRgb().join(",") + ")";
+ };
+
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){
+ oldOnEnd();
+ if(bgImage){
+ node.style.backgroundImage = bgImage;
+ }
+ if(wasTransparent){
+ node.style.backgroundColor = "transparent";
+ }
+ if(callback){
+ callback(node, anim);
+ }
+ };
+
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else{ return anims[0]; }
+}
+
+dojo.lfx.html.unhighlight = function(nodes, endColor, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var color = new dojo.graphics.color.Color(dojo.style.getBackgroundColor(node));
+ var rgb = new dojo.graphics.color.Color(endColor);
+
+ var bgImage = dojo.style.getStyle(node, "background-image");
+
+ var anim = dojo.lfx.propertyAnimation(node, [{
+ property: "background-color",
+ start: color,
+ end: rgb
+ }], duration, easing);
+
+ var oldbb = (anim["beforeBegin"]) ? dojo.lang.hitch(anim, "beforeBegin") : function(){};
+ anim.beforeBegin = function(){
+ oldbb();
+ if(bgImage){
+ node.style.backgroundImage = "none";
+ }
+ node.style.backgroundColor = "rgb(" + color.toRgb().join(",") + ")";
+ };
+
+ var oldOnEnd = (anim["onEnd"]) ? dojo.lang.hitch(anim, "onEnd") : function(){};
+ anim.onEnd = function(){
+ oldOnEnd();
+ if(callback){
+ callback(node, anim);
+ }
+ };
+
+ anims.push(anim);
+ });
+
+ if(nodes.length > 1){ return dojo.lfx.combine(anims); }
+ else{ return anims[0]; }
+}
+
+dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,54 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.toggle");
+dojo.require("dojo.lfx.*");
+
+dojo.lfx.toggle.plain = {
+ show: function(node, duration, easing, callback){
+ dojo.style.show(node);
+ if(dojo.lang.isFunction(callback)){ callback(); }
+ },
+
+ hide: function(node, duration, easing, callback){
+ dojo.style.hide(node);
+ if(dojo.lang.isFunction(callback)){ callback(); }
+ }
+}
+
+dojo.lfx.toggle.fade = {
+ show: function(node, duration, easing, callback){
+ dojo.lfx.fadeShow(node, duration, easing, callback).play();
+ },
+
+ hide: function(node, duration, easing, callback){
+ dojo.lfx.fadeHide(node, duration, easing, callback).play();
+ }
+}
+
+dojo.lfx.toggle.wipe = {
+ show: function(node, duration, easing, callback){
+ dojo.lfx.wipeIn(node, duration, easing, callback).play();
+ },
+
+ hide: function(node, duration, easing, callback){
+ dojo.lfx.wipeOut(node, duration, easing, callback).play();
+ }
+}
+
+dojo.lfx.toggle.explode = {
+ show: function(node, duration, easing, callback, explodeSrc){
+ dojo.lfx.explode(explodeSrc||[0,0,0,0], node, duration, easing, callback).play();
+ },
+
+ hide: function(node, duration, easing, callback, explodeSrc){
+ dojo.lfx.implode(node, explodeSrc||[0,0,0,0], duration, easing, callback).play();
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,450 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/*
+ * loader.js - runs before the hostenv_*.js file. Contains all of the package loading methods.
+ */
+
+//A semi-colon is at the start of the line because after doing a build, this function definition
+//get compressed onto the same line as the last line in bootstrap1.js. That list line is just a
+//curly bracket, and the browser complains about that syntax. The semicolon fixes it. Putting it
+//here instead of at the end of bootstrap1.js, since it is more of an issue for this file, (using
+//the closure), and bootstrap1.js could change in the future.
+;(function(){
+ //Additional properties for dojo.hostenv
+ var _addHostEnv = {
+ pkgFileName: "__package__",
+
+ // for recursion protection
+ loading_modules_: {},
+ loaded_modules_: {},
+ addedToLoadingCount: [],
+ removedFromLoadingCount: [],
+
+ inFlightCount: 0,
+
+ // FIXME: it should be possible to pull module prefixes in from djConfig
+ modulePrefixes_: {
+ dojo: {name: "dojo", value: "src"}
+ },
+
+
+ setModulePrefix: function(module, prefix){
+ this.modulePrefixes_[module] = {name: module, value: prefix};
+ },
+
+ getModulePrefix: function(module){
+ var mp = this.modulePrefixes_;
+ if((mp[module])&&(mp[module]["name"])){
+ return mp[module].value;
+ }
+ return module;
+ },
+
+ getTextStack: [],
+ loadUriStack: [],
+ loadedUris: [],
+
+ //WARNING: This variable is referenced by packages outside of bootstrap: FloatingPane.js and undo/browser.js
+ post_load_: false,
+
+ //Egad! Lots of test files push on this directly instead of using dojo.addOnLoad.
+ modulesLoadedListeners: [],
+ unloadListeners: [],
+ loadNotifying: false
+ };
+
+ //Add all of these properties to dojo.hostenv
+ for(var param in _addHostEnv){
+ dojo.hostenv[param] = _addHostEnv[param];
+ }
+})();
+
+/**
+ * Loads and interprets the script located at relpath, which is relative to the
+ * script root directory. If the script is found but its interpretation causes
+ * a runtime exception, that exception is not caught by us, so the caller will
+ * see it. We return a true value if and only if the script is found.
+ *
+ * For now, we do not have an implementation of a true search path. We
+ * consider only the single base script uri, as returned by getBaseScriptUri().
+ *
+ * @param relpath A relative path to a script (no leading '/', and typically
+ * ending in '.js').
+ * @param module A module whose existance to check for after loading a path.
+ * Can be used to determine success or failure of the load.
+ * @param cb a function to pass the result of evaluating the script (optional)
+ */
+dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
+ var uri;
+ if((relpath.charAt(0) == '/')||(relpath.match(/^\w+:/))){
+ // dojo.raise("relpath '" + relpath + "'; must be relative");
+ uri = relpath;
+ }else{
+ uri = this.getBaseScriptUri() + relpath;
+ }
+ if(djConfig.cacheBust && dojo.render.html.capable){
+ uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,"");
+ }
+ try{
+ return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
+ }catch(e){
+ dojo.debug(e);
+ return false;
+ }
+}
+
+/**
+ * Reads the contents of the URI, and evaluates the contents.
+ * Returns true if it succeeded. Returns false if the URI reading failed.
+ * Throws if the evaluation throws.
+ * The result of the eval is not available to the caller TODO: now it is; was this a deliberate restriction?
+ *
+ * @param uri a uri which points at the script to be loaded
+ * @param cb a function to process the result of evaluating the script as an expression (optional)
+ */
+dojo.hostenv.loadUri = function(uri, cb /*optional*/){
+ if(this.loadedUris[uri]){
+ return 1;
+ }
+ var contents = this.getText(uri, null, true);
+ if(contents == null){ return 0; }
+ this.loadedUris[uri] = true;
+ if(cb){ contents = '('+contents+')'; }
+ var value = dj_eval(contents);
+ if(cb){
+ cb(value);
+ }
+ return 1;
+}
+
+// FIXME: probably need to add logging to this method
+dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
+ var ok = true;
+ try{
+ ok = this.loadUri(uri, cb);
+ }catch(e){
+ dojo.debug("failed loading ", uri, " with error: ", e);
+ }
+ return ((ok)&&(this.findModule(module, false))) ? true : false;
+}
+
+dojo.loaded = function(){ }
+dojo.unloaded = function(){ }
+
+dojo.hostenv.loaded = function(){
+ this.loadNotifying = true;
+ this.post_load_ = true;
+ var mll = this.modulesLoadedListeners;
+ for(var x=0; x<mll.length; x++){
+ mll[x]();
+ }
+
+ //Clear listeners so new ones can be added
+ //For other xdomain package loads after the initial load.
+ this.modulesLoadedListeners = [];
+ this.loadNotifying = false;
+
+ dojo.loaded();
+}
+
+dojo.hostenv.unloaded = function(){
+ var mll = this.unloadListeners;
+ while(mll.length){
+ (mll.pop())();
+ }
+ dojo.unloaded();
+}
+
+/*
+Call styles:
+ dojo.addOnLoad(functionPointer)
+ dojo.addOnLoad(object, "functionName")
+*/
+dojo.addOnLoad = function(obj, fcnName) {
+ var dh = dojo.hostenv;
+ if(arguments.length == 1) {
+ dh.modulesLoadedListeners.push(obj);
+ } else if(arguments.length > 1) {
+ dh.modulesLoadedListeners.push(function() {
+ obj[fcnName]();
+ });
+ }
+
+ //Added for xdomain loading. dojo.addOnLoad is used to
+ //indicate callbacks after doing some dojo.require() statements.
+ //In the xdomain case, if all the requires are loaded (after initial
+ //page load), then immediately call any listeners.
+ if(dh.post_load_ && dh.inFlightCount == 0 && !dh.loadNotifying){
+ dh.callLoaded();
+ }
+}
+
+dojo.addOnUnload = function(obj, fcnName){
+ var dh = dojo.hostenv;
+ if(arguments.length == 1){
+ dh.unloadListeners.push(obj);
+ } else if(arguments.length > 1) {
+ dh.unloadListeners.push(function() {
+ obj[fcnName]();
+ });
+ }
+}
+
+dojo.hostenv.modulesLoaded = function(){
+ if(this.post_load_){ return; }
+ if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
+ if(this.inFlightCount > 0){
+ dojo.debug("files still in flight!");
+ return;
+ }
+ dojo.hostenv.callLoaded();
+ }
+}
+
+dojo.hostenv.callLoaded = function(){
+ if(typeof setTimeout == "object"){
+ setTimeout("dojo.hostenv.loaded();", 0);
+ }else{
+ dojo.hostenv.loaded();
+ }
+}
+
+dojo.hostenv.getModuleSymbols = function(modulename) {
+ var syms = modulename.split(".");
+ for(var i = syms.length - 1; i > 0; i--){
+ var parentModule = syms.slice(0, i).join(".");
+ var parentModulePath = this.getModulePrefix(parentModule);
+ if(parentModulePath != parentModule){
+ syms.splice(0, i, parentModulePath);
+ break;
+ }
+ }
+ return syms;
+}
+
+/**
+* loadModule("A.B") first checks to see if symbol A.B is defined.
+* If it is, it is simply returned (nothing to do).
+*
+* If it is not defined, it will look for "A/B.js" in the script root directory,
+* followed by "A.js".
+*
+* It throws if it cannot find a file to load, or if the symbol A.B is not
+* defined after loading.
+*
+* It returns the object A.B.
+*
+* This does nothing about importing symbols into the current package.
+* It is presumed that the caller will take care of that. For example, to import
+* all symbols:
+*
+* with (dojo.hostenv.loadModule("A.B")) {
+* ...
+* }
+*
+* And to import just the leaf symbol:
+*
+* var B = dojo.hostenv.loadModule("A.B");
+* ...
+*
+* dj_load is an alias for dojo.hostenv.loadModule
+*/
+dojo.hostenv._global_omit_module_check = false;
+dojo.hostenv.loadModule = function(modulename, exact_only, omit_module_check){
+ if(!modulename){ return; }
+ omit_module_check = this._global_omit_module_check || omit_module_check;
+ var module = this.findModule(modulename, false);
+ if(module){
+ return module;
+ }
+
+ // protect against infinite recursion from mutual dependencies
+ if(dj_undef(modulename, this.loading_modules_)){
+ this.addedToLoadingCount.push(modulename);
+ }
+ this.loading_modules_[modulename] = 1;
+
+ // convert periods to slashes
+ var relpath = modulename.replace(/\./g, '/') + '.js';
+
+ var syms = this.getModuleSymbols(modulename);
+ var startedRelative = ((syms[0].charAt(0) != '/')&&(!syms[0].match(/^\w+:/)));
+ var last = syms[syms.length - 1];
+ // figure out if we're looking for a full package, if so, we want to do
+ // things slightly diffrently
+ var nsyms = modulename.split(".");
+ if(last=="*"){
+ modulename = (nsyms.slice(0, -1)).join('.');
+
+ while(syms.length){
+ syms.pop();
+ syms.push(this.pkgFileName);
+ relpath = syms.join("/") + '.js';
+ if(startedRelative && (relpath.charAt(0)=="/")){
+ relpath = relpath.slice(1);
+ }
+ ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ if(ok){ break; }
+ syms.pop();
+ }
+ }else{
+ relpath = syms.join("/") + '.js';
+ modulename = nsyms.join('.');
+ var ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ if((!ok)&&(!exact_only)){
+ syms.pop();
+ while(syms.length){
+ relpath = syms.join('/') + '.js';
+ ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ if(ok){ break; }
+ syms.pop();
+ relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
+ if(startedRelative && (relpath.charAt(0)=="/")){
+ relpath = relpath.slice(1);
+ }
+ ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ if(ok){ break; }
+ }
+ }
+
+ if((!ok)&&(!omit_module_check)){
+ dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
+ }
+ }
+
+ // check that the symbol was defined
+ //Don't bother if we're doing xdomain (asynchronous) loading.
+ if(!omit_module_check && !this["isXDomain"]){
+ // pass in false so we can give better error
+ module = this.findModule(modulename, false);
+ if(!module){
+ dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
+ }
+ }
+
+ return module;
+}
+
+/**
+* startPackage("A.B") follows the path, and at each level creates a new empty
+* object or uses what already exists. It returns the result.
+*/
+dojo.hostenv.startPackage = function(packname){
+ var modref = dojo.evalObjPath((packname.split(".").slice(0, -1)).join('.'));
+ this.loaded_modules_[(new String(packname)).toLowerCase()] = modref;
+
+ var syms = packname.split(/\./);
+ if(syms[syms.length-1]=="*"){
+ syms.pop();
+ }
+ return dojo.evalObjPath(syms.join("."), true);
+}
+
+/**
+ * findModule("A.B") returns the object A.B if it exists, otherwise null.
+ * @param modulename A string like 'A.B'.
+ * @param must_exist Optional, defualt false. throw instead of returning null
+ * if the module does not currently exist.
+ */
+dojo.hostenv.findModule = function(modulename, must_exist){
+ // check cache
+ /*
+ if(!dj_undef(modulename, this.modules_)){
+ return this.modules_[modulename];
+ }
+ */
+
+ var lmn = (new String(modulename)).toLowerCase();
+
+ if(this.loaded_modules_[lmn]){
+ return this.loaded_modules_[lmn];
+ }
+
+ // see if symbol is defined anyway
+ var module = dojo.evalObjPath(modulename);
+ if((modulename)&&(typeof module != 'undefined')&&(module)){
+ this.loaded_modules_[lmn] = module;
+ return module;
+ }
+
+ if(must_exist){
+ dojo.raise("no loaded module named '" + modulename + "'");
+ }
+ return null;
+}
+
+//Start of old bootstrap2:
+
+/*
+ * This method taks a "map" of arrays which one can use to optionally load dojo
+ * modules. The map is indexed by the possible dojo.hostenv.name_ values, with
+ * two additional values: "default" and "common". The items in the "default"
+ * array will be loaded if none of the other items have been choosen based on
+ * the hostenv.name_ item. The items in the "common" array will _always_ be
+ * loaded, regardless of which list is chosen. Here's how it's normally
+ * called:
+ *
+ * dojo.kwCompoundRequire({
+ * browser: [
+ * ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule()
+ * "foo.sample.*",
+ * "foo.test,
+ * ],
+ * default: [ "foo.sample.*" ],
+ * common: [ "really.important.module.*" ]
+ * });
+ */
+dojo.kwCompoundRequire = function(modMap){
+ var common = modMap["common"]||[];
+ var result = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
+
+ for(var x=0; x<result.length; x++){
+ var curr = result[x];
+ if(curr.constructor == Array){
+ dojo.hostenv.loadModule.apply(dojo.hostenv, curr);
+ }else{
+ dojo.hostenv.loadModule(curr);
+ }
+ }
+}
+
+dojo.require = function(){
+ dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
+}
+
+dojo.requireIf = function(){
+ if((arguments[0] === true)||(arguments[0]=="common")||(arguments[0] && dojo.render[arguments[0]].capable)){
+ var args = [];
+ for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
+ dojo.require.apply(dojo, args);
+ }
+}
+
+dojo.requireAfterIf = dojo.requireIf;
+
+dojo.provide = function(){
+ return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
+}
+
+dojo.setModulePrefix = function(module, prefix){
+ return dojo.hostenv.setModulePrefix(module, prefix);
+}
+
+// determine if an object supports a given method
+// useful for longer api chains where you have to test each object in the chain
+dojo.exists = function(obj, name){
+ var p = name.split(".");
+ for(var i = 0; i < p.length; i++){
+ if(!(obj[p[i]])) return false;
+ obj = obj[p[i]];
+ }
+ return true;
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js?rev=432754&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js Fri Aug 18 15:32:37 2006
@@ -0,0 +1,414 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+//Cross-domain package loader.
+
+//FIXME: How will xd loading work with debugAtAllCosts? Any bad interactions?
+//FIXME: widgets won't work fully (HTML/CSS) and also because of the requireIf() thing.
+
+dojo.hostenv.resetXd = function(){
+ //This flag indicates where or not we have crossed into xdomain territory. Once any package says
+ //it is cross domain, then the rest of the packages have to be treated as xdomain because we need
+ //to evaluate packages in order. If there is a xdomain package followed by a xhr package, we can't load
+ //the xhr package until the one before it finishes loading. The text of the xhr package will be converted
+ //to match the format for a xd package and put in the xd load queue.
+ //You can force all packages to be treated as xd by setting the djConfig.forceXDomain.
+ this.isXDomain = djConfig.forceXDomain || false;
+
+ this.xdTimer = 0;
+ this.xdInFlight = {};
+ this.xdOrderedReqs = [];
+ this.xdDepMap = {};
+ this.xdContents = [];
+}
+
+//Call reset immediately to set the state.
+dojo.hostenv.resetXd();
+
+dojo.hostenv.createXdPackage = function(contents){
+ //Find dependencies.
+ var deps = [];
+ var depRegExp = /dojo.(require|requireIf|requireAll|provide|requireAfterIf|requireAfter|kwCompoundRequire|conditionalRequire|hostenv\.conditionalLoadModule|.hostenv\.loadModule|hostenv\.moduleLoaded)\(([\w\W]*?)\)/mg;
+ var match;
+ while((match = depRegExp.exec(contents)) != null){
+ deps.push("\"" + match[1] + "\", " + match[2]);
+ }
+
+ //Create package object and the call to packageLoaded.
+ var output = [];
+ output.push("dojo.hostenv.packageLoaded({\n");
+
+ //Add dependencies
+ if(deps.length > 0){
+ output.push("depends: [");
+ for(var i = 0; i < deps.length; i++){
+ if(i > 0){
+ output.push(",\n");
+ }
+ output.push("[" + deps[i] + "]");
+ }
+ output.push("],");
+ }
+
+ //Add the contents of the file inside a function.
+ //Pass in dojo as an argument to the function to help with
+ //allowing multiple versions of dojo in a page.
+ output.push("\ndefinePackage: function(dojo){");
+ output.push(contents);
+ output.push("\n}});");
+
+ return output.join("");
+}
+
+dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
+ //Only do getBaseScriptUri if path does not start with a URL with a protocol.
+ //If there is a colon before the first / then, we have a URL with a protocol.
+ var colonIndex = relpath.indexOf(":");
+ var slashIndex = relpath.indexOf("/");
+ var uri;
+ var currentIsXDomain = false;
+ if(colonIndex > 0 && colonIndex < slashIndex){
+ uri = relpath;
+ this.isXDomain = currentIsXDomain = true;
+ }else{
+ uri = this.getBaseScriptUri() + relpath;
+
+ //Is ithe base script URI-based URL a cross domain URL?
+ colonIndex = uri.indexOf(":");
+ slashIndex = uri.indexOf("/");
+ if(colonIndex > 0 && colonIndex < slashIndex && (!location.host || uri.indexOf("http://" + location.host) != 0)){
+ this.isXDomain = currentIsXDomain = true;
+ }
+ }
+
+ if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); }
+ try{
+ return ((!module || this.isXDomain) ? this.loadUri(uri, cb, currentIsXDomain, module) : this.loadUriAndCheck(uri, module, cb));
+ }catch(e){
+ dojo.debug(e);
+ return false;
+ }
+}
+
+//Overriding loadUri for now. Wanted to override getText(), but it is used by
+//the widget code in too many, synchronous ways right now. This means the xd stuff
+//is not suitable for widgets yet.
+dojo.hostenv.loadUri = function(uri, cb, currentIsXDomain, module){
+ if(this.loadedUris[uri]){
+ return 1;
+ }
+
+ //Add the module (package) to the list of modules.
+ if(this.isXDomain){
+ //Curious: is this array going to get whacked with multiple access since scripts
+ //load asynchronously and may be accessing the array at the same time?
+ //JS is single-threaded supposedly, so it should be ok. And we don't need
+ //a precise ordering.
+ this.xdOrderedReqs.push(module);
+
+ //Add to waiting packages.
+ //If this is a __package__.js file, then this must be
+ //a package.* request (since xdomain can only work with the first
+ //path in a package search list. However, .* module names are not
+ //passed to this function, so do an adjustment here.
+ if(uri.indexOf("__package__") != -1){
+ module += ".*";
+ }
+
+ this.xdInFlight[module] = true;
+
+ //Increment inFlightCount
+ //This will stop the modulesLoaded from firing all the way.
+ this.inFlightCount++;
+
+ //Start timer
+ if(!this.xdTimer){
+ this.xdTimer = setInterval("dojo.hostenv.watchInFlightXDomain();", 100);
+ }
+ this.xdStartTime = (new Date()).getTime();
+ }
+
+ if (currentIsXDomain){
+ //Fix name to be a .xd.fileextension name.
+ var lastIndex = uri.lastIndexOf('.');
+ if(lastIndex <= 0){
+ lastIndex = uri.length - 1;
+ }
+
+ var xdUri = uri.substring(0, lastIndex) + ".xd";
+ if(lastIndex != uri.length - 1){
+ xdUri += uri.substring(lastIndex, uri.length);
+ }
+
+ //Add to script src
+ var element = document.createElement("script");
+ element.type = "text/javascript";
+ element.src = xdUri;
+ if(!this.headElement){
+ this.headElement = document.getElementsByTagName("head")[0];
+ }
+ this.headElement.appendChild(element);
+ }else{
+ var contents = this.getText(uri, null, true);
+ if(contents == null){ return 0; }
+
+ if(this.isXDomain){
+ var pkg = this.createXdPackage(contents);
+ dj_eval(pkg);
+ }else{
+ if(cb){ contents = '('+contents+')'; }
+ var value = dj_eval(contents);
+ if(cb){
+ cb(value);
+ }
+ }
+ }
+
+ //These steps are done in the non-xd loader version of this function.
+ //Maintain these steps to fit in with the existing system.
+ this.loadedUris[uri] = true;
+ return 1;
+}
+
+dojo.hostenv.packageLoaded = function(pkg){
+ var deps = pkg.depends;
+ var requireList = null;
+ var requireAfterList = null;
+ var provideList = [];
+ if(deps && deps.length > 0){
+ var dep = null;
+ var insertHint = 0;
+ var attachedPackage = false;
+ for(var i = 0; i < deps.length; i++){
+ dep = deps[i];
+
+ //Look for specific dependency indicators.
+ if (dep[0] == "provide" || dep[0] == "hostenv.moduleLoaded"){
+ provideList.push(dep[1]);
+ }else{
+ if(!requireList){
+ requireList = [];
+ }
+ if(!requireAfterList){
+ requireAfterList = [];
+ }
+
+ var unpackedDeps = this.unpackXdDependency(dep);
+ if(unpackedDeps.requires){
+ requireList = requireList.concat(unpackedDeps.requires);
+ }
+ if(unpackedDeps.requiresAfter){
+ requireAfterList = requireAfterList.concat(unpackedDeps.requiresAfter);
+ }
+ }
+
+ //Call the dependency indicator to allow for the normal dojo setup.
+ //Only allow for one dot reference, for the hostenv.* type calls.
+ var depType = dep[0];
+ var objPath = depType.split(".");
+ if(objPath.length == 2){
+ dojo[objPath[0]][objPath[1]].apply(dojo[objPath[0]], dep.slice(1));
+ }else{
+ dojo[depType].apply(dojo, dep.slice(1));
+ }
+ }
+
+ //Save off the package contents for definition later.
+ var contentIndex = this.xdContents.push({content: pkg.definePackage, isDefined: false}) - 1;
+
+ //Add provide/requires to dependency map.
+ for(var i = 0; i < provideList.length; i++){
+ this.xdDepMap[provideList[i]] = { requires: requireList, requiresAfter: requireAfterList, contentIndex: contentIndex };
+ }
+
+ //Now update the inflight status for any provided packages in this loaded package.
+ //Do this at the very end (in a *separate* for loop) to avoid shutting down the
+ //inflight timer check too soon.
+ for(var i = 0; i < provideList.length; i++){
+ this.xdInFlight[provideList[i]] = false;
+ }
+ }
+}
+
+//This is a bit brittle: it has to know about the dojo methods that deal with dependencies
+//It would be ideal to intercept the actual methods and do something fancy at that point,
+//but I have concern about knowing which provide to match to the dependency in that case,
+//since scripts can load whenever they want, and trigger new calls to dojo.hostenv.packageLoaded().
+dojo.hostenv.unpackXdDependency = function(dep){
+ //Extract the dependency(ies).
+ var newDeps = null;
+ var newAfterDeps = null;
+ switch(dep[0]){
+ case "requireIf":
+ case "requireAfterIf":
+ case "conditionalRequire":
+ //First arg (dep[1]) is the test. Depedency is dep[2].
+ if((dep[1] === true)||(dep[1]=="common")||(dep[1] && dojo.render[dep[1]].capable)){
+ newDeps = [{name: dep[2], content: null}];
+ }
+ break;
+ case "requireAll":
+ //the arguments are an array, each element a call to require.
+ //Get rid of first item, which is "requireAll".
+ dep.shift();
+ newDeps = dep;
+ dojo.hostenv.flattenRequireArray(newDeps);
+ break;
+ case "kwCompoundRequire":
+ case "hostenv.conditionalLoadModule":
+ var modMap = dep[1];
+ var common = modMap["common"]||[];
+ var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
+ dojo.hostenv.flattenRequireArray(newDeps);
+ break;
+ case "require":
+ case "requireAfter":
+ case "hostenv.loadModule":
+ //Just worry about dep[1]
+ newDeps = [{name: dep[1], content: null}];
+ break;
+ }
+
+ //The requireAfterIf or requireAfter needs to be evaluated after the current package is evaluated.
+ if(dep[0] == "requireAfterIf"){
+ newAfterDeps = newDeps;
+ newDeps = null;
+ }
+ return {requires: newDeps, requiresAfter: newAfterDeps};
+}
+
+//Walks the requires and evaluates package contents in
+//the right order.
+dojo.hostenv.xdWalkReqs = function(){
+ var reqChain = null;
+ var req;
+ for(var i = 0; i < this.xdOrderedReqs.length; i++){
+ req = this.xdOrderedReqs[i];
+ if(this.xdDepMap[req]){
+ reqChain = [req];
+ reqChain[req] = true; //Allow for fast lookup of the req in the array
+ this.xdEvalReqs(reqChain);
+ }
+ }
+}
+
+//Trace down any requires.
+dojo.hostenv.xdTraceReqs = function(reqs, reqChain){
+ if(reqs && reqs.length > 0){
+ var nextReq;
+ for(var i = 0; i < reqs.length; i++){
+ nextReq = reqs[i].name;
+ if(nextReq && !reqChain[nextReq]){
+ //New req depedency. Follow it down.
+ reqChain.push(nextReq);
+ reqChain[nextReq] = true;
+ this.xdEvalReqs(reqChain);
+ }
+ }
+ }
+}
+
+//Do a depth first, breadth second search and eval or reqs.
+dojo.hostenv.xdEvalReqs = function(reqChain){
+ if(reqChain.length > 0){
+ var req = reqChain[reqChain.length - 1];
+ var pkg = this.xdDepMap[req];
+ if(pkg){
+ //Trace down any requires for this package.
+ this.xdTraceReqs(pkg.requires, reqChain);
+
+ //Evaluate the package.
+ var contents = this.xdContents[pkg.contentIndex];
+ if(!contents.isDefined){
+ //Evaluate the package to bring it into being.
+ //Pass dojo in so that later, to support multiple versions of dojo
+ //in a page, we can pass which version of dojo to use.
+ contents.content(dojo);
+ contents.isDefined = true;
+ }
+ this.xdDepMap[req] = null;
+
+ //Trace down any requireAfters for this package..
+ this.xdTraceReqs(pkg.requiresAfter, reqChain);
+ }
+
+ //Done with that require. Remove it and go to the next one.
+ reqChain.pop();
+ this.xdEvalReqs(reqChain);
+ }
+}
+
+dojo.hostenv.clearXdInterval = function(){
+ clearInterval(this.xdTimer);
+ this.xdTimer = 0;
+}
+
+dojo.hostenv.watchInFlightXDomain = function(){
+ //Make sure we haven't waited timed out.
+ var waitInterval = (djConfig.xdWaitSeconds || 30) * 1000;
+
+ if(this.xdStartTime + waitInterval < (new Date()).getTime()){
+ this.clearXdInterval();
+ var noLoads = "";
+ for(var param in this.xdInFlight){
+ if(this.xdInFlight[param]){
+ noLoads += param + " ";
+ }
+ }
+ dojo.raise("Could not load cross-domain packages: " + noLoads);
+ }
+
+ //If any are true, then still waiting.
+ //Come back later.
+ for(var param in this.xdInFlight){
+ if(this.xdInFlight[param]){
+ return;
+ }
+ }
+
+ //All done loading. Clean up and notify that we are loaded.
+ this.clearXdInterval();
+
+ this.xdWalkReqs();
+
+ //Evaluate any packages that were not evaled before.
+ //This normally shouldn't happen with proper dojo.provide and dojo.require
+ //usage, but providing it just in case. Note that these may not be executed
+ //in the original order that the developer intended.
+ //Pass dojo in so that later, to support multiple versions of dojo
+ //in a page, we can pass which version of dojo to use.
+ for(var i = 0; i < this.xdContents.length; i++){
+ var current = this.xdContents[i];
+ if(current.content && !current.isDefined){
+ current.content(dojo);
+ }
+ }
+
+ //Clean up for the next round of xd loading.
+ this.resetXd();
+
+ //Clear inflight count so we will finally do finish work.
+ this.inFlightCount = 0;
+ this.callLoaded();
+}
+
+dojo.hostenv.flattenRequireArray = function(target){
+ //Each result could be an array of 3 elements (the 3 arguments to dojo.require).
+ //We only need the first one.
+ if(target){
+ for(var i = 0; i < target.length; i++){
+ if(target[i] instanceof Array){
+ target[i] = {name: target[i][0], content: null};
+ }else{
+ target[i] = {name: target[i], content: null};
+ }
+ }
+ }
+}