You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/09/29 05:43:06 UTC
svn commit: r451106 [18/40] - in /tapestry/tapestry4/trunk: ./
tapestry-framework/src/java/org/apache/tapestry/asset/
tapestry-framework/src/js/dojo/ tapestry-framework/src/js/dojo/src/
tapestry-framework/src/js/dojo/src/animation/ tapestry-framework/s...
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/json.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/json.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/json.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/json.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,130 @@
+/*
+ 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.json");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.string.extras");
+dojo.require("dojo.AdapterRegistry");
+
+dojo.json = {
+ jsonRegistry: new dojo.AdapterRegistry(),
+
+ register: function(name, check, wrap, /*optional*/ override){
+ /***
+
+ Register a JSON serialization function. JSON serialization
+ functions should take one argument and return an object
+ suitable for JSON serialization:
+
+ - string
+ - number
+ - boolean
+ - undefined
+ - object
+ - null
+ - Array-like (length property that is a number)
+ - Objects with a "json" method will have this method called
+ - Any other object will be used as {key:value, ...} pairs
+
+ If override is given, it is used as the highest priority
+ JSON serialization, otherwise it will be used as the lowest.
+ ***/
+
+ dojo.json.jsonRegistry.register(name, check, wrap, override);
+ },
+
+ evalJson: function(/* jsonString */ json){
+ // FIXME: should this accept mozilla's optional second arg?
+ try {
+ return eval("(" + json + ")");
+ }catch(e){
+ dojo.debug(e);
+ return json;
+ }
+ },
+
+ serialize: function(o){
+ /***
+ Create a JSON serialization of an object, note that this doesn't
+ check for infinite recursion, so don't do that!
+ ***/
+
+ var objtype = typeof(o);
+ if(objtype == "undefined"){
+ return "undefined";
+ }else if((objtype == "number")||(objtype == "boolean")){
+ return o + "";
+ }else if(o === null){
+ return "null";
+ }
+ if (objtype == "string") { return dojo.string.escapeString(o); }
+ // recurse
+ var me = arguments.callee;
+ // short-circuit for objects that support "json" serialization
+ // if they return "self" then just pass-through...
+ var newObj;
+ if(typeof(o.__json__) == "function"){
+ newObj = o.__json__();
+ if(o !== newObj){
+ return me(newObj);
+ }
+ }
+ if(typeof(o.json) == "function"){
+ newObj = o.json();
+ if (o !== newObj) {
+ return me(newObj);
+ }
+ }
+ // array
+ if(objtype != "function" && typeof(o.length) == "number"){
+ var res = [];
+ for(var i = 0; i < o.length; i++){
+ var val = me(o[i]);
+ if(typeof(val) != "string"){
+ val = "undefined";
+ }
+ res.push(val);
+ }
+ return "[" + res.join(",") + "]";
+ }
+ // look in the registry
+ try {
+ window.o = o;
+ newObj = dojo.json.jsonRegistry.match(o);
+ return me(newObj);
+ }catch(e){
+ // dojo.debug(e);
+ }
+ // it's a function with no adapter, bad
+ if(objtype == "function"){
+ return null;
+ }
+ // generic object code path
+ res = [];
+ for (var k in o){
+ var useKey;
+ if (typeof(k) == "number"){
+ useKey = '"' + k + '"';
+ }else if (typeof(k) == "string"){
+ useKey = dojo.string.escapeString(k);
+ }else{
+ // skip non-string or number keys
+ continue;
+ }
+ val = me(o[k]);
+ if(typeof(val) != "string"){
+ // skip non-serializable values
+ continue;
+ }
+ res.push(useKey + ":" + val);
+ }
+ return "{" + res.join(",") + "}";
+ }
+};
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/json.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,14 @@
+/*
+ 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");
+dojo.require("dojo.lang.common");
+
+dojo.deprecated("dojo.lang", "replaced by dojo.lang.common", "0.5");
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/__package__.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/__package__.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/__package__.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,23 @@
+/*
+ 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({
+ common: [
+ "dojo.lang.common",
+ "dojo.lang.assert",
+ "dojo.lang.array",
+ "dojo.lang.type",
+ "dojo.lang.func",
+ "dojo.lang.extras",
+ "dojo.lang.repr",
+ "dojo.lang.declare"
+ ]
+});
+dojo.provide("dojo.lang.*");
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/array.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/array.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/array.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/array.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,183 @@
+/*
+ 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.array");
+
+dojo.require("dojo.lang.common");
+
+// FIXME: Is this worthless since you can do: if(name in obj)
+// is this the right place for this?
+dojo.lang.has = function(obj, name){
+ try{
+ return (typeof obj[name] != "undefined");
+ }catch(e){ return false; }
+}
+
+dojo.lang.isEmpty = function(obj) {
+ if(dojo.lang.isObject(obj)) {
+ var tmp = {};
+ var count = 0;
+ for(var x in obj){
+ if(obj[x] && (!tmp[x])){
+ count++;
+ break;
+ }
+ }
+ return (count == 0);
+ } else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)) {
+ return obj.length == 0;
+ }
+}
+
+dojo.lang.map = function(arr, obj, unary_func){
+ var isString = dojo.lang.isString(arr);
+ if(isString){
+ arr = arr.split("");
+ }
+ if(dojo.lang.isFunction(obj)&&(!unary_func)){
+ unary_func = obj;
+ obj = dj_global;
+ }else if(dojo.lang.isFunction(obj) && unary_func){
+ // ff 1.5 compat
+ var tmpObj = obj;
+ obj = unary_func;
+ unary_func = tmpObj;
+ }
+ if(Array.map){
+ var outArr = Array.map(arr, unary_func, obj);
+ }else{
+ var outArr = [];
+ for(var i=0;i<arr.length;++i){
+ outArr.push(unary_func.call(obj, arr[i]));
+ }
+ }
+ if(isString) {
+ return outArr.join("");
+ } else {
+ return outArr;
+ }
+}
+
+dojo.lang.reduce = function(arr, initialValue, obj, binary_func){
+ var reducedValue = initialValue;
+ var ob = obj ? obj : dj_global;
+ dojo.lang.map(arr,
+ function(val){
+ reducedValue = binary_func.call(ob, reducedValue, val);
+ }
+ );
+ return reducedValue;
+}
+
+// http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:forEach
+dojo.lang.forEach = function(anArray /* Array */, callback /* Function */, thisObject /* Object */){
+ if(dojo.lang.isString(anArray)){
+ anArray = anArray.split("");
+ }
+ if(Array.forEach){
+ Array.forEach(anArray, callback, thisObject);
+ }else{
+ // FIXME: there are several ways of handilng thisObject. Is dj_global always the default context?
+ if(!thisObject){
+ thisObject=dj_global;
+ }
+ for(var i=0,l=anArray.length; i<l; i++){
+ callback.call(thisObject, anArray[i], i, anArray);
+ }
+ }
+}
+
+dojo.lang._everyOrSome = function(every, arr, callback, thisObject){
+ if(dojo.lang.isString(arr)){
+ arr = arr.split("");
+ }
+ if(Array.every){
+ return Array[ (every) ? "every" : "some" ](arr, callback, thisObject);
+ }else{
+ if(!thisObject){
+ thisObject = dj_global;
+ }
+ for(var i=0,l=arr.length; i<l; i++){
+ var result = callback.call(thisObject, arr[i], i, arr);
+ if((every)&&(!result)){
+ return false;
+ }else if((!every)&&(result)){
+ return true;
+ }
+ }
+ return (every) ? true : false;
+ }
+}
+
+dojo.lang.every = function(arr, callback, thisObject){
+ return this._everyOrSome(true, arr, callback, thisObject);
+}
+
+dojo.lang.some = function(arr, callback, thisObject){
+ return this._everyOrSome(false, arr, callback, thisObject);
+}
+
+dojo.lang.filter = function(arr, callback, thisObject) {
+ var isString = dojo.lang.isString(arr);
+ if(isString) { arr = arr.split(""); }
+ if(Array.filter) {
+ var outArr = Array.filter(arr, callback, thisObject);
+ } else {
+ if(!thisObject) {
+ if(arguments.length >= 3) { dojo.raise("thisObject doesn't exist!"); }
+ thisObject = dj_global;
+ }
+
+ var outArr = [];
+ for(var i = 0; i < arr.length; i++) {
+ if(callback.call(thisObject, arr[i], i, arr)) {
+ outArr.push(arr[i]);
+ }
+ }
+ }
+ if(isString) {
+ return outArr.join("");
+ } else {
+ return outArr;
+ }
+}
+
+/**
+ * Creates a 1-D array out of all the arguments passed,
+ * unravelling any array-like objects in the process
+ *
+ * Ex:
+ * unnest(1, 2, 3) ==> [1, 2, 3]
+ * unnest(1, [2, [3], [[[4]]]]) ==> [1, 2, 3, 4]
+ */
+dojo.lang.unnest = function(/* ... */) {
+ var out = [];
+ for(var i = 0; i < arguments.length; i++) {
+ if(dojo.lang.isArrayLike(arguments[i])) {
+ var add = dojo.lang.unnest.apply(this, arguments[i]);
+ out = out.concat(add);
+ } else {
+ out.push(arguments[i]);
+ }
+ }
+ return out;
+}
+
+/**
+ * Converts an array-like object (i.e. arguments, DOMCollection)
+ * to an array
+**/
+dojo.lang.toArray = function(arrayLike, startOffset) {
+ var array = [];
+ for(var i = startOffset||0; i < arrayLike.length; i++) {
+ array.push(arrayLike[i]);
+ }
+ return array;
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/array.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/assert.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/assert.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/assert.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/assert.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,111 @@
+/*
+ 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.assert");
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.type");
+
+dojo.lang.assert = function(/* boolean */ booleanValue, /* string? */ message){
+ /* summary:
+ * Throws an exception if the assertion fails.
+ * booleanValue: boolean Must be true for the assertion to succeed.
+ * message: string? A string describing the assertion.
+ * throws: Throws an Error if 'booleanValue' is false.
+ * description:
+ * If the asserted condition is true, this method does nothing. If the
+ * condition is false, we throw an error with a error message.
+ */
+ if(!booleanValue){
+ var errorMessage = "An assert statement failed.\n" +
+ "The method dojo.lang.assert() was called with a 'false' value.\n";
+ if(message){
+ errorMessage += "Here's the assert message:\n" + message + "\n";
+ }
+ // Use throw instead of dojo.raise, until bug #264 is fixed:
+ // dojo.raise(errorMessage);
+ throw new Error(errorMessage);
+ }
+}
+
+dojo.lang.assertType = function(/* anything */ value, /* misc. */ type, /* object? */ keywordParameters){
+ /* summary:
+ * Throws an exception if 'value' is not of type 'type'
+ * value: anything Any literal value or object instance.
+ * type: misc. A class of object, or a literal type, or the string name of a type, or an array with a list of types.
+ * keywordParameters: object? {optional: boolean}
+ * throws: Throws an Error if 'value' is not of type 'type'.
+ * examples:
+ * dojo.lang.assertType("foo", String);
+ * dojo.lang.assertType(12345, Number);
+ * dojo.lang.assertType(false, Boolean);
+ * dojo.lang.assertType([6, 8], Array);
+ * dojo.lang.assertType(dojo.lang.assertType, Function);
+ * dojo.lang.assertType({foo: "bar"}, Object);
+ * dojo.lang.assertType(new Date(), Date);
+ * dojo.lang.assertType(null, Array, {optional: true});
+ * description:
+ * Given a value and a data type, this method checks the type of the value
+ * to make sure it matches the data type, and throws an exception if there
+ * is a mismatch.
+ */
+ if (dojo.lang.isString(keywordParameters)) {
+ dojo.deprecated('dojo.lang.assertType(value, type, "message")', 'use dojo.lang.assertType(value, type) instead', "0.5");
+ }
+ if(!dojo.lang.isOfType(value, type, keywordParameters)){
+ if(!dojo.lang.assertType._errorMessage){
+ dojo.lang.assertType._errorMessage = "Type mismatch: dojo.lang.assertType() failed.";
+ }
+ dojo.lang.assert(false, dojo.lang.assertType._errorMessage);
+ }
+}
+
+dojo.lang.assertValidKeywords = function(/* object */ object, /* array */ expectedProperties, /* string? */ message){
+ /* summary:
+ * Throws an exception 'object' has any properties other than the 'expectedProperties'.
+ * object: object An anonymous object.
+ * expectedProperties: array An array of strings (or an object with all the expected properties).
+ * message: string? A message describing the assertion.
+ * throws: Throws an Error if 'object' has unexpected properties.
+ * examples:
+ * dojo.lang.assertValidKeywords({a: 1, b: 2}, ["a", "b"]);
+ * dojo.lang.assertValidKeywords({a: 1, b: 2}, ["a", "b", "c"]);
+ * dojo.lang.assertValidKeywords({foo: "iggy"}, ["foo"]);
+ * dojo.lang.assertValidKeywords({foo: "iggy"}, ["foo", "bar"]);
+ * dojo.lang.assertValidKeywords({foo: "iggy"}, {foo: null, bar: null});
+ * description:
+ * Given an anonymous object and a list of expected property names, this
+ * method check to make sure the object does not have any properties
+ * that aren't on the list of expected properties, and throws an Error
+ * if there are unexpected properties. This is useful for doing error
+ * checking on keyword arguments, to make sure there aren't typos.
+ */
+ var key;
+ if(!message){
+ if(!dojo.lang.assertValidKeywords._errorMessage){
+ dojo.lang.assertValidKeywords._errorMessage = "In dojo.lang.assertValidKeywords(), found invalid keyword:";
+ }
+ message = dojo.lang.assertValidKeywords._errorMessage;
+ }
+ if(dojo.lang.isArray(expectedProperties)){
+ for(key in object){
+ if(!dojo.lang.inArray(expectedProperties, key)){
+ dojo.lang.assert(false, message + " " + key);
+ }
+ }
+ }else{
+ for(key in object){
+ if(!(key in expectedProperties)){
+ dojo.lang.assert(false, message + " " + key);
+ }
+ }
+ }
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/assert.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/common.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/common.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/common.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/common.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,234 @@
+/*
+ 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.common");
+
+dojo.lang.inherits = function(/*Function*/ subclass, /*Function*/ superclass){
+ // summary: Set up inheritance between two classes.
+ if(typeof superclass != 'function'){
+ dojo.raise("dojo.inherits: superclass argument ["+superclass+"] must be a function (subclass: ["+subclass+"']");
+ }
+ subclass.prototype = new superclass();
+ subclass.prototype.constructor = subclass;
+ subclass.superclass = superclass.prototype;
+ // DEPRICATED: super is a reserved word, use 'superclass'
+ subclass['super'] = superclass.prototype;
+}
+
+dojo.lang._mixin = function(/*Object*/ obj, /*Object*/ props){
+ // summary: Adds all properties and methods of props to obj.
+ var tobj = {};
+ for(var x in props){
+ // the "tobj" condition avoid copying properties in "props"
+ // inherited from Object.prototype. For example, if obj has a custom
+ // toString() method, don't overwrite it with the toString() method
+ // that props inherited from Object.protoype
+ if((typeof tobj[x] == "undefined") || (tobj[x] != props[x])){
+ obj[x] = props[x];
+ }
+ }
+ // IE doesn't recognize custom toStrings in for..in
+ if(dojo.render.html.ie
+ && (typeof(props["toString"]) == "function")
+ && (props["toString"] != obj["toString"])
+ && (props["toString"] != tobj["toString"]))
+ {
+ obj.toString = props.toString;
+ }
+ return obj;
+}
+
+dojo.lang.mixin = function(/*Object*/ obj, /*Object...*/props){
+ // summary: Adds all properties and methods of props to obj.
+ for(var i=1, l=arguments.length; i<l; i++){
+ dojo.lang._mixin(obj, arguments[i]);
+ }
+ return obj; // Object
+}
+
+dojo.lang.extend = function(/*Object*/ constructor, /*Object...*/ props){
+ // summary: Adds all properties and methods of props to constructor's prototype,
+ // making them available to all instances created with constructor.
+ for(var i=1, l=arguments.length; i<l; i++){
+ dojo.lang._mixin(constructor.prototype, arguments[i]);
+ }
+ return constructor;
+}
+
+// Promote to dojo module
+dojo.inherits = dojo.lang.inherits;
+//dojo.lang._mixin = dojo.lang._mixin;
+dojo.mixin = dojo.lang.mixin;
+dojo.extend = dojo.lang.extend;
+
+dojo.lang.find = function( /*Array*/ array,
+ /*Object*/ value,
+ /*Boolean?*/ identity,
+ /*Boolean?*/ findLast){
+ // summary: Return the index of value in array, returning -1 if not found.
+
+ // param: identity: If true, matches with identity comparison (===).
+ // If false, uses normal comparison (==).
+ // param: findLast: If true, returns index of last instance of value.
+ // usage:
+ // find(array, value[, identity [findLast]]) // recommended
+ // usage:
+ // find(value, array[, identity [findLast]]) // deprecated
+
+ // support both (array, value) and (value, array)
+ if(!dojo.lang.isArrayLike(array) && dojo.lang.isArrayLike(value)) {
+ dojo.deprecated('dojo.lang.find(value, array)', 'use dojo.lang.find(array, value) instead', "0.5");
+ var temp = array;
+ array = value;
+ value = temp;
+ }
+ var isString = dojo.lang.isString(array);
+ if(isString) { array = array.split(""); }
+
+ if(findLast) {
+ var step = -1;
+ var i = array.length - 1;
+ var end = -1;
+ } else {
+ var step = 1;
+ var i = 0;
+ var end = array.length;
+ }
+ if(identity){
+ while(i != end) {
+ if(array[i] === value){ return i; }
+ i += step;
+ }
+ }else{
+ while(i != end) {
+ if(array[i] == value){ return i; }
+ i += step;
+ }
+ }
+ return -1; // number
+}
+
+dojo.lang.indexOf = dojo.lang.find;
+
+dojo.lang.findLast = function(/*Array*/ array, /*Object*/ value, /*boolean?*/ identity){
+ // summary: Return index of last occurance of value in array, returning -1 if not found.
+
+ // param: identity: If true, matches with identity comparison (===).
+ // If false, uses normal comparison (==).
+ return dojo.lang.find(array, value, identity, true);
+}
+
+dojo.lang.lastIndexOf = dojo.lang.findLast;
+
+dojo.lang.inArray = function(array /*Array*/, value /*Object*/){
+ // summary: Return true if value is present in array.
+ return dojo.lang.find(array, value) > -1; // return: boolean
+}
+
+/**
+ * Partial implmentation of is* functions from
+ * http://www.crockford.com/javascript/recommend.html
+ * NOTE: some of these may not be the best thing to use in all situations
+ * as they aren't part of core JS and therefore can't work in every case.
+ * See WARNING messages inline for tips.
+ *
+ * The following is* functions are fairly "safe"
+ */
+
+dojo.lang.isObject = function(it){
+ // summary: Return true if it is an Object, Array or Function.
+ if(typeof it == "undefined"){ return false; }
+ return (typeof it == "object" || it === null || dojo.lang.isArray(it) || dojo.lang.isFunction(it));
+}
+
+dojo.lang.isArray = function(it){
+ // summary: Return true if it is an Array.
+ return (it && it instanceof Array || typeof it == "array");
+}
+
+dojo.lang.isArrayLike = function(it){
+ // summary: Return true if it can be used as an array (i.e. is an object with an integer length property).
+ if((!it)||(dojo.lang.isUndefined(it))){ return false; }
+ if(dojo.lang.isString(it)){ return false; }
+ if(dojo.lang.isFunction(it)){ return false; } // keeps out built-in constructors (Number, String, ...) which have length properties
+ if(dojo.lang.isArray(it)){ return true; }
+ // form node itself is ArrayLike, but not always iterable. Use form.elements instead.
+ if((it.tagName)&&(it.tagName.toLowerCase()=='form')){ return false; }
+ if(dojo.lang.isNumber(it.length) && isFinite(it.length)){ return true; }
+ return false;
+}
+
+dojo.lang.isFunction = function(it){
+ // summary: Return true if it is a Function.
+ if(!it){ return false; }
+ // webkit treats NodeList as a function, which is bad
+ if((typeof(it) == "function") && (it == "[object NodeList]")) { return false; }
+ return (it instanceof Function || typeof it == "function");
+}
+
+dojo.lang.isString = function(it){
+ // summary: Return true if it is a String.
+ return (typeof it == "string" || it instanceof String);
+}
+
+dojo.lang.isAlien = function(it){
+ // summary: Return true if it is not a built-in function.
+ if(!it){ return false; }
+ return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(it));
+}
+
+dojo.lang.isBoolean = function(it){
+ // summary: Return true if it is a Boolean.
+ return (it instanceof Boolean || typeof it == "boolean");
+}
+
+/**
+ * The following is***() functions are somewhat "unsafe". Fortunately,
+ * there are workarounds the the language provides and are mentioned
+ * in the WARNING messages.
+ *
+ */
+dojo.lang.isNumber = function(it){
+ // summary: Return true if it is a number.
+
+ // warning:
+ // In most cases, isNaN(it) is sufficient to determine whether or not
+ // something is a number or can be used as such. For example, a number or string
+ // can be used interchangably when accessing array items (array["1"] is the same as
+ // array[1]) and isNaN will return false for both values ("1" and 1). However,
+ // isNumber("1") will return false, which is generally not too useful.
+ // Also, isNumber(NaN) returns true, again, this isn't generally useful, but there
+ // are corner cases (like when you want to make sure that two things are really
+ // the same type of thing). That is really where isNumber "shines".
+ //
+ // recommendation: Use isNaN(it) when possible
+
+ return (it instanceof Number || typeof it == "number");
+}
+
+/*
+ * FIXME: Should isUndefined go away since it is error prone?
+ */
+dojo.lang.isUndefined = function(it){
+ // summary: Return true if it is not defined.
+
+ // warning: In some cases, isUndefined will not behave as you
+ // might expect. If you do isUndefined(foo) and there is no earlier
+ // reference to foo, an error will be thrown before isUndefined is
+ // called. It behaves correctly if you scope yor object first, i.e.
+ // isUndefined(foo.bar) where foo is an object and bar isn't a
+ // property of the object.
+ //
+ // recommendation: Use typeof foo == "undefined" when possible
+
+ return ((typeof(it) == "undefined")&&(it == undefined));
+}
+
+// end Crockford functions
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/common.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/declare.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/declare.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/declare.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/declare.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,158 @@
+/*
+ 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.declare");
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.extras");
+
+/*
+ * Creates a constructor: inherit and extend
+ *
+ * - inherits from "superclass(es)"
+ *
+ * "superclass" argument may be a Function, or an array of
+ * Functions.
+ *
+ * If "superclass" is an array, the first element is used
+ * as the prototypical ancestor and any following Functions
+ * become mixin ancestors.
+ *
+ * All "superclass(es)" must be Functions (not mere Objects).
+ *
+ * Using mixin ancestors provides a type of multiple
+ * inheritance. Mixin ancestors prototypical
+ * properties are copied to the subclass, and any
+ * inializater/constructor is invoked.
+ *
+ * - "props" are copied to the constructor prototype
+ *
+ * - name of the class ("className" argument) is stored in
+ * "declaredClass" property
+ *
+ * - An initializer function can be specified in the "init"
+ * argument, or by including a function called "initializer"
+ * in "props".
+ *
+ * - Superclass methods (inherited methods) can be invoked using "inherited" method:
+ *
+ * this.inherited(<method name>[, <argument array>]);
+ *
+ * - inherited will continue up the prototype chain until it finds an implementation of method
+ * - nested calls to inherited are supported (i.e. inherited method "A" can succesfully call inherited("A"), and so on)
+ *
+ * Aliased as "dojo.declare"
+ *
+ * Usage:
+ *
+ * dojo.declare("my.classes.bar", my.classes.foo, {
+ * initializer: function() {
+ * this.myComplicatedObject = new ReallyComplicatedObject();
+ * },
+ * someValue: 2,
+ * aMethod: function() { doStuff(); }
+ * });
+ *
+ */
+dojo.lang.declare = function(className /*string*/, superclass /*function || array*/, init /*function*/, props /*object*/){
+ // FIXME: parameter juggling for backward compat ... deprecate and remove after 0.3.*
+ // new sig: (className (string)[, superclass (function || array)[, init (function)][, props (object)]])
+ // old sig: (className (string)[, superclass (function || array), props (object), init (function)])
+ if ((dojo.lang.isFunction(props))||((!props)&&(!dojo.lang.isFunction(init)))){
+ var temp = props;
+ props = init;
+ init = temp;
+ }
+ var mixins = [ ];
+ if (dojo.lang.isArray(superclass)) {
+ mixins = superclass;
+ superclass = mixins.shift();
+ }
+ if(!init){
+ init = dojo.evalObjPath(className, false);
+ if ((init)&&(!dojo.lang.isFunction(init))){ init = null };
+ }
+ var ctor = dojo.lang.declare._makeConstructor();
+ var scp = (superclass ? superclass.prototype : null);
+ if(scp){
+ scp.prototyping = true;
+ ctor.prototype = new superclass();
+ scp.prototyping = false;
+ }
+ ctor.superclass = scp;
+ ctor.mixins = mixins;
+ for(var i=0,l=mixins.length; i<l; i++){
+ dojo.lang.extend(ctor, mixins[i].prototype);
+ }
+ ctor.prototype.initializer = null;
+ ctor.prototype.declaredClass = className;
+ if(dojo.lang.isArray(props)){
+ dojo.lang.extend.apply(dojo.lang, [ctor].concat(props));
+ }else{
+ dojo.lang.extend(ctor, (props)||{});
+ }
+ dojo.lang.extend(ctor, dojo.lang.declare.base);
+ ctor.prototype.constructor = ctor;
+ ctor.prototype.initializer=(ctor.prototype.initializer)||(init)||(function(){});
+ dojo.lang.setObjPathValue(className, ctor, null, true);
+ return ctor;
+}
+
+dojo.lang.declare._makeConstructor = function() {
+ return function(){
+ // get the generational context (which object [or prototype] should be constructed)
+ var self = this._getPropContext();
+ var s = self.constructor.superclass;
+ if((s)&&(s.constructor)){
+ if(s.constructor==arguments.callee){
+ // if this constructor is invoked directly (my.ancestor.call(this))
+ this.inherited("constructor", arguments);
+ }else{
+ this._inherited(s, "constructor", arguments);
+ }
+ }
+ var m = (self.constructor.mixins)||([]);
+ for(var i=0,l=m.length; i<l; i++) {
+ (((m[i].prototype)&&(m[i].prototype.initializer))||(m[i])).apply(this, arguments);
+ }
+ if((!this.prototyping)&&(self.initializer)){
+ self.initializer.apply(this, arguments);
+ }
+ }
+}
+
+dojo.lang.declare.base = {
+ _getPropContext: function() { return (this.___proto||this); },
+ // caches ptype context and calls method on it
+ _inherited: function(ptype, method, args){
+ var result, stack = this.___proto;
+ this.___proto = ptype;
+ try { result = ptype[method].apply(this,(args||[])); }
+ catch(e) { throw e; }
+ finally { this.___proto = stack; }
+ return result;
+ },
+ // get value from ctor.prototype.prop. If prop is a function, it is invoked, with args, in our context
+ inheritedFrom: function(ctor, prop, args){
+ var p = ((ctor)&&(ctor.prototype)&&(ctor.prototype[prop]));
+ return (dojo.lang.isFunction(p) ? p.apply(this, (args||[])) : p);
+ },
+ // searches backward thru prototype chain to find nearest ancestral instance of prop
+ inherited: function(prop, args){
+ var p = this._getPropContext();
+ do{
+ if((!p.constructor)||(!p.constructor.superclass)){return;}
+ p = p.constructor.superclass;
+ }while(!(prop in p));
+ return (dojo.lang.isFunction(p[prop]) ? this._inherited(p, prop, args) : p[prop]);
+ }
+}
+
+dojo.declare = dojo.lang.declare;
\ No newline at end of file
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/declare.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/extras.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/extras.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/extras.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/extras.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,126 @@
+/*
+ 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 dojo.global().setTimeout(function () { func.apply(context, args); }, delay);
+}
+
+dojo.lang.clearTimeout = function(timer){
+ dojo.global().clearTimeout(timer);
+}
+
+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, deep) {
+ var i, ret;
+
+ if (obj === null) return null;
+
+ if (dojo.lang.isObject(obj)) {
+ ret = new obj.constructor();
+ for (i in obj) {
+ if(dojo.lang.isUndefined(ret[i])) {
+ ret[i] = deep ? dojo.lang.shallowCopy(obj[i], deep) : obj[i];
+ }
+ }
+ } else if (dojo.lang.isArray(obj)) {
+ ret = [];
+ for(i=0; i<obj.length; i++) {
+ ret[i] = deep ? dojo.lang.shallowCopy(obj[i], deep) : obj[i];
+ }
+ } else {
+ ret = obj;
+ }
+
+ 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;
+ }
+ }
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/extras.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/func.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/func.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/func.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/func.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,148 @@
+/*
+ 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){
+ var fcn = (dojo.lang.isString(method) ? thisObject[method] : method) || function(){};
+
+ 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){
+ try{
+ if(nso[x] === anonFuncPtr){
+ return x;
+ }
+ }catch(e){} // window.external fails in IE embedded in Eclipse (Eclipse bug #151165)
+ }
+ }
+ 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);
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/func.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/repr.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/repr.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/repr.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/repr.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,80 @@
+/*
+ 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 obj.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){ }
+};
+
+(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);
+})();
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/repr.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Streamer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Streamer.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Streamer.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Streamer.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,99 @@
+/*
+ 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.timing.Streamer");
+dojo.require("dojo.lang.timing.Timer");
+
+dojo.lang.timing.Streamer = function(
+ /* function */input,
+ /* function */output,
+ /* int */interval,
+ /* int */minimum,
+ /* array */initialData
+){
+ // summary
+ // Streamer will take an input function that pushes N datapoints into a
+ // queue, and will pass the next point in that queue out to an
+ // output function at the passed interval; this way you can emulate
+ // a constant buffered stream of data.
+ // input: the function executed when the internal queue reaches minimumSize
+ // output: the function executed on internal tick
+ // interval: the interval in ms at which the output function is fired.
+ // minimum: the minimum number of elements in the internal queue.
+
+ var self = this;
+ var queue = [];
+
+ // public properties
+ this.interval = interval || 1000;
+ this.minimumSize = minimum || 10; // latency usually == interval * minimumSize
+ this.inputFunction = input || function(q){ };
+ this.outputFunction = output || function(point){ };
+
+ // more setup
+ var timer = new dojo.lang.timing.Timer(this.interval);
+ var tick = function(){
+ self.onTick(self);
+
+ if(queue.length < self.minimumSize){
+ self.inputFunction(queue);
+ }
+
+ var obj = queue.shift();
+ while(typeof(obj) == "undefined" && queue.length > 0){
+ obj = queue.shift();
+ }
+
+ // check to see if the input function needs to be fired
+ // stop before firing the output function
+ // TODO: relegate this to the output function?
+ if(typeof(obj) == "undefined"){
+ self.stop();
+ return;
+ }
+
+ // call the output function.
+ self.outputFunction(obj);
+ };
+
+ this.setInterval = function(/* int */ms){
+ // summary
+ // sets the interval in milliseconds of the internal timer
+ this.interval = ms;
+ timer.setInterval(ms);
+ };
+
+ this.onTick = function(/* dojo.lang.timing.Streamer */obj){ };
+ // wrap the timer functions so that we can connect to them if needed.
+ this.start = function(){
+ // summary
+ // starts the Streamer
+ if(typeof(this.inputFunction) == "function" && typeof(this.outputFunction) == "function"){
+ timer.start();
+ return;
+ }
+ dojo.raise("You cannot start a Streamer without an input and an output function.");
+ };
+ this.onStart = function(){ };
+ this.stop = function(){
+ // summary
+ // stops the Streamer
+ timer.stop();
+ };
+ this.onStop = function(){ };
+
+ // finish initialization
+ timer.onTick = this.tick;
+ timer.onStart = this.onStart;
+ timer.onStop = this.onStop;
+ if(initialData){
+ queue.concat(initialData);
+ }
+};
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Streamer.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Timer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Timer.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Timer.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Timer.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,64 @@
+/*
+ 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.timing.Timer");
+dojo.require("dojo.lang.func");
+
+dojo.lang.timing.Timer = function(/*int*/ interval){
+ // summary: Timer object executes an "onTick()" method repeatedly at a specified interval.
+ // repeatedly at a given interval.
+ // interval: Interval between function calls, in milliseconds.
+ this.timer = null;
+ this.isRunning = false;
+ this.interval = interval;
+
+ this.onStart = null;
+ this.onStop = null;
+};
+
+dojo.extend(dojo.lang.timing.Timer, {
+ onTick : function(){
+ // summary: Method called every time the interval passes. Override to do something useful.
+ },
+
+ setInterval : function(interval){
+ // summary: Reset the interval of a timer, whether running or not.
+ // interval: New interval, in milliseconds.
+ if (this.isRunning){
+ dj_global.clearInterval(this.timer);
+ }
+ this.interval = interval;
+ if (this.isRunning){
+ this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
+ }
+ },
+
+ start : function(){
+ // summary: Start the timer ticking.
+ // description: Calls the "onStart()" handler, if defined.
+ // Note that the onTick() function is not called right away,
+ // only after first interval passes.
+ if (typeof this.onStart == "function"){
+ this.onStart();
+ }
+ this.isRunning = true;
+ this.timer = dj_global.setInterval(dojo.lang.hitch(this, "onTick"), this.interval);
+ },
+
+ stop : function(){
+ // summary: Stop the timer.
+ // description: Calls the "onStop()" handler, if defined.
+ if (typeof this.onStop == "function"){
+ this.onStop();
+ }
+ this.isRunning = false;
+ dj_global.clearInterval(this.timer);
+ }
+});
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/Timer.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/__package__.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/__package__.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/__package__.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,11 @@
+/*
+ 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.timing.*");
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/timing/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/type.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/type.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/type.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/type.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,259 @@
+/*
+ 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(value) {
+ dojo.deprecated("dojo.lang.whatAmI", "use dojo.lang.getType instead", "0.5");
+ return dojo.lang.getType(value);
+}
+dojo.lang.whatAmI.custom = {};
+
+dojo.lang.getType = function(/* anything */ value){
+ /* summary:
+ * Attempts to determine what type value is.
+ * value: anything Any literal value or object instance.
+ */
+ try {
+ if(dojo.lang.isArray(value)) {
+ return "array"; // string
+ }
+ if(dojo.lang.isFunction(value)) {
+ return "function"; // string
+ }
+ if(dojo.lang.isString(value)) {
+ return "string"; // string
+ }
+ if(dojo.lang.isNumber(value)) {
+ return "number"; // string
+ }
+ if(dojo.lang.isBoolean(value)) {
+ return "boolean"; // string
+ }
+ if(dojo.lang.isAlien(value)) {
+ return "alien"; // string
+ }
+ if(dojo.lang.isUndefined(value)) {
+ return "undefined"; // string
+ }
+ // FIXME: should this go first?
+ for(var name in dojo.lang.whatAmI.custom) {
+ if(dojo.lang.whatAmI.custom[name](value)) {
+ return name; // string
+ }
+ }
+ if(dojo.lang.isObject(value)) {
+ return "object"; // string
+ }
+ } catch(E) {}
+ return "unknown"; // string
+}
+
+dojo.lang.isNumeric = function(/* anything */ value){
+ /* summary:
+ * Returns true if value can be interpreted as a number
+ * value: anything Any literal value or object instance.
+ * examples:
+ * 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
+ */
+ return (!isNaN(value)
+ && isFinite(value)
+ && (value != null)
+ && !dojo.lang.isBoolean(value)
+ && !dojo.lang.isArray(value)
+ && !/^\s*$/.test(value)
+ ); // boolean
+}
+
+dojo.lang.isBuiltIn = function(/* anything */ value){
+ /* summary:
+ * Returns true if value is of a type provided by core JavaScript
+ * value: anything Any literal value or object instance.
+ * description:
+ * 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.
+ */
+ return (dojo.lang.isArray(value)
+ || dojo.lang.isFunction(value)
+ || dojo.lang.isString(value)
+ || dojo.lang.isNumber(value)
+ || dojo.lang.isBoolean(value)
+ || (value == null)
+ || (value instanceof Error)
+ || (typeof value == "error")
+ ); // boolean
+}
+
+dojo.lang.isPureObject = function(/* anything */ value){
+ /* summary:
+ * Returns true for any value where the value of value.constructor == Object
+ * value: anything Any literal value or object instance.
+ * description:
+ * 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.
+ * examples:
+ * 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
+ */
+ return ((value != null)
+ && dojo.lang.isObject(value)
+ && value.constructor == Object
+ ); // boolean
+}
+
+dojo.lang.isOfType = function(/* anything */ value, /* function */ type, /* object? */ keywordParameters) {
+ /* summary:
+ * Returns true if 'value' is of type 'type'
+ * description:
+ * 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.
+ * value: anything Any literal value or object instance.
+ * type: misc. A class of object, or a literal type, or the string name of a type, or an array with a list of types.
+ * keywordParameters: object? {optional: boolean}
+ * examples:
+ * 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("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(null, Date, {optional: true} ); // returns true // description:
+ */
+ var optional = false;
+ if (keywordParameters) {
+ optional = keywordParameters["optional"];
+ }
+ if (optional && ((value === null) || dojo.lang.isUndefined(value))) {
+ return true; // boolean
+ }
+ 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; // boolean
+ }
+ }
+ return false; // boolean
+ }else{
+ if(dojo.lang.isString(type)){
+ type = type.toLowerCase();
+ }
+ switch (type) {
+ case Array:
+ case "array":
+ return dojo.lang.isArray(value); // boolean
+ break;
+ case Function:
+ case "function":
+ return dojo.lang.isFunction(value); // boolean
+ break;
+ case String:
+ case "string":
+ return dojo.lang.isString(value); // boolean
+ break;
+ case Number:
+ case "number":
+ return dojo.lang.isNumber(value); // boolean
+ break;
+ case "numeric":
+ return dojo.lang.isNumeric(value); // boolean
+ break;
+ case Boolean:
+ case "boolean":
+ return dojo.lang.isBoolean(value); // boolean
+ break;
+ case Object:
+ case "object":
+ return dojo.lang.isObject(value); // boolean
+ break;
+ case "pureobject":
+ return dojo.lang.isPureObject(value); // boolean
+ break;
+ case "builtin":
+ return dojo.lang.isBuiltIn(value); // boolean
+ break;
+ case "alien":
+ return dojo.lang.isAlien(value); // boolean
+ break;
+ case "undefined":
+ return dojo.lang.isUndefined(value); // boolean
+ break;
+ case null:
+ case "null":
+ return (value === null); // boolean
+ break;
+ case "optional":
+ dojo.deprecated('dojo.lang.isOfType(value, [type, "optional"])', 'use dojo.lang.isOfType(value, type, {optional: true} ) instead', "0.5");
+ return ((value === null) || dojo.lang.isUndefined(value)); // boolean
+ break;
+ default:
+ if (dojo.lang.isFunction(type)) {
+ return (value instanceof type); // boolean
+ } 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.");
+}
+
+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
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lang/type.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/Animation.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/Animation.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/Animation.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/Animation.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,524 @@
+/*
+ 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(/*int*/ start, /*int*/ end){
+ this.start = start;
+ this.end = end;
+ if(dojo.lang.isArray(start)){
+ /* start: Array
+ end: Array
+ pId: a */
+ 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; // Array
+ }
+ }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; // Decimal
+ }
+ }
+}
+
+dojo.lfx.easeDefault = function(n){
+ // sin wave easing. All the cool kids are doing it.
+ if(dojo.render.html.khtml){
+ // the cool kids are obviously not using konqueror...
+ // found a very wierd bug in floats constants, 1.5 evals as 1
+ // seems somebody mixed up ints and floats in 3.5.4 ??
+ // FIXME: investigate more and post a KDE bug (Fredrik)
+ return (parseFloat("0.5")+((Math.sin( (n+parseFloat("1.5")) * Math.PI))/2));
+ }else{
+ return (0.5+((Math.sin( (n+1.5) * Math.PI))/2));
+ }
+}
+
+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,
+
+ connect: function(/*Event*/ evt, /*Object*/ scope, /*Function*/ newFunc){
+ if(!newFunc){
+ /* scope: Function
+ newFunc: null
+ pId: f */
+ newFunc = scope;
+ scope = this;
+ }
+ newFunc = dojo.lang.hitch(scope, newFunc);
+ var oldFunc = this[evt]||function(){};
+ this[evt] = function(){
+ var ret = oldFunc.apply(this, arguments);
+ newFunc.apply(this, arguments);
+ return ret;
+ }
+ return this; // dojo.lfx.IAnimation
+ },
+
+ fire: function(/*Event*/ evt, /*Array*/ args){
+ if(this[evt]){
+ this[evt].apply(this, (args||[]));
+ }
+ return this; // dojo.lfx.IAnimation
+ },
+
+ repeat: function(/*int*/ count){
+ this.repeatCount = count;
+ return this; // dojo.lfx.IAnimation
+ },
+
+ // 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){
+ dojo.lang.forEach([
+ "handler", "beforeBegin", "onBegin",
+ "onEnd", "onPlay", "onStop", "onAnimate"
+ ], function(item){
+ if(handlers[item]){
+ this.connect(item, handlers[item]);
+ }
+ }, this);
+ }
+ 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(/*int?*/ delay, /*bool?*/ gotoStart){
+ if(gotoStart){
+ clearTimeout(this._timer);
+ this._active = false;
+ this._paused = false;
+ this._percent = 0;
+ }else if(this._active && !this._paused){
+ return this; // dojo.lfx.Animation
+ }
+
+ this.fire("handler", ["beforeBegin"]);
+ this.fire("beforeBegin");
+
+ if(delay > 0){
+ setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
+ return this; // dojo.lfx.Animation
+ }
+
+ 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; // dojo.lfx.Animation
+ },
+
+ pause: function(){
+ clearTimeout(this._timer);
+ if(!this._active){ return this; /*dojo.lfx.Animation*/}
+ this._paused = true;
+ var value = this.curve.getValue(this._percent / 100);
+ this.fire("handler", ["pause", value]);
+ this.fire("onPause", [value]);
+ return this; // dojo.lfx.Animation
+ },
+
+ gotoPercent: function(/*Decimal*/ pct, /*bool?*/ andPlay){
+ clearTimeout(this._timer);
+ this._active = true;
+ this._paused = true;
+ this._percent = pct;
+ if(andPlay){ this.play(); }
+ return this; // dojo.lfx.Animation
+ },
+
+ stop: function(/*bool?*/ 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; // dojo.lfx.Animation
+ },
+
+ status: function(){
+ if(this._active){
+ return this._paused ? "paused" : "playing"; // String
+ }else{
+ return "stopped"; // String
+ }
+ return this;
+ },
+
+ // "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.Animation
+ }
+});
+
+dojo.lfx.Combine = function(/*dojo.lfx.IAnimation...*/ animations){
+ 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]))){
+ /* animations: Array
+ pId: a */
+ anims = anims[0];
+ }
+
+ dojo.lang.forEach(anims, function(anim){
+ this._anims.push(anim);
+ anim.connect("onEnd", dojo.lang.hitch(this, "_onAnimsEnded"));
+ }, this);
+}
+dojo.inherits(dojo.lfx.Combine, dojo.lfx.IAnimation);
+dojo.lang.extend(dojo.lfx.Combine, {
+ // private members
+ _animsEnded: 0,
+
+ // public methods
+ play: function(/*int?*/ delay, /*bool?*/ gotoStart){
+ if( !this._anims.length ){ return this; /*dojo.lfx.Combine*/}
+
+ this.fire("beforeBegin");
+
+ if(delay > 0){
+ setTimeout(dojo.lang.hitch(this, function(){ this.play(null, gotoStart); }), delay);
+ return this; // dojo.lfx.Combine
+ }
+
+ if(gotoStart || this._anims[0].percent == 0){
+ this.fire("onBegin");
+ }
+ this.fire("onPlay");
+ this._animsCall("play", null, gotoStart);
+ return this; // dojo.lfx.Combine
+ },
+
+ pause: function(){
+ this.fire("onPause");
+ this._animsCall("pause");
+ return this; // dojo.lfx.Combine
+ },
+
+ stop: function(/*bool?*/ gotoEnd){
+ this.fire("onStop");
+ this._animsCall("stop", gotoEnd);
+ return this; // dojo.lfx.Combine
+ },
+
+ // private methods
+ _onAnimsEnded: function(){
+ this._animsEnded++;
+ if(this._animsEnded >= this._anims.length){
+ this.fire("onEnd");
+ }
+ return this; // dojo.lfx.Combine
+ },
+
+ _animsCall: function(/*String*/ 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.Combine
+ }
+});
+
+dojo.lfx.Chain = function(/*dojo.lfx.IAnimation...*/ animations) {
+ 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]))){
+ /* animations: Array
+ pId: a */
+ anims = anims[0];
+ }
+
+ var _this = this;
+ dojo.lang.forEach(anims, function(anim, i, anims_arr){
+ this._anims.push(anim);
+ if(i < anims_arr.length - 1){
+ anim.connect("onEnd", dojo.lang.hitch(this, "_playNext") );
+ }else{
+ anim.connect("onEnd", dojo.lang.hitch(this, function(){ 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(/*int?*/ delay, /*bool?*/ gotoStart){
+ if( !this._anims.length ) { return this; /*dojo.lfx.Chain*/}
+ 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; // dojo.lfx.Chain
+ }
+
+ 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; // dojo.lfx.Chain
+ },
+
+ pause: function(){
+ if( this._anims[this._currAnim] ) {
+ this._anims[this._currAnim].pause();
+ this.fire("onPause", [this._currAnim]);
+ }
+ return this; // dojo.lfx.Chain
+ },
+
+ 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; // dojo.lfx.Chain
+ },
+
+ stop: function(){
+ var currAnim = this._anims[this._currAnim];
+ if(currAnim){
+ currAnim.stop();
+ this.fire("onStop", [this._currAnim]);
+ }
+ return currAnim; // dojo.lfx.IAnimation
+ },
+
+ // 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.Chain
+ }
+});
+
+dojo.lfx.combine = function(/*dojo.lfx.IAnimation...*/ animations){
+ var anims = arguments;
+ if(dojo.lang.isArray(arguments[0])){
+ /* animations: Array
+ pId: a */
+ anims = arguments[0];
+ }
+ if(anims.length == 1){ return anims[0]; }
+ return new dojo.lfx.Combine(anims); // dojo.lfx.Combine
+}
+
+dojo.lfx.chain = function(/*dojo.lfx.IAnimation...*/ animations){
+ var anims = arguments;
+ if(dojo.lang.isArray(arguments[0])){
+ /* animations: Array
+ pId: a */
+ anims = arguments[0];
+ }
+ if(anims.length == 1){ return anims[0]; }
+ return new dojo.lfx.Chain(anims); // dojo.lfx.Combine
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/Animation.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/__package__.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/__package__.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/__package__.js Thu Sep 28 20:42:39 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
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/extras.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/extras.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/extras.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/extras.js Thu Sep 28 20:42:39 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.fadeIn(nodes, duration, easing),
+ dojo.lfx.wipeIn(nodes, duration, easing)
+ );
+
+ if(callback){
+ anim.connect("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.fadeOut(nodes, duration, easing),
+ dojo.lfx.wipeOut(nodes, duration, easing)
+ );
+
+ if(callback){
+ anim.connect("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 outer = dojo.html.getMarginBox(node);
+
+ var actualPct = percentage/100.0;
+ var props = [
+ { property: "width",
+ start: outer.width,
+ end: outer.width * actualPct
+ },
+ { property: "height",
+ start: outer.height,
+ end: outer.height * actualPct
+ }];
+
+ if(scaleContent){
+ var fontSize = dojo.html.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.html.getStyle(node, "position");
+ var originalTop = node.offsetTop;
+ var originalLeft = node.offsetLeft;
+ var endTop = ((outer.height * actualPct) - outer.height)/2;
+ var endLeft = ((outer.width * actualPct) - outer.width)/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){
+ anim.connect("onEnd", function(){
+ callback(node, anim);
+ });
+ }
+
+ anims.push(anim);
+ });
+
+ return dojo.lfx.combine(anims);
+}
+
+dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/extras.js
------------------------------------------------------------------------------
svn:eol-style = native