You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/01/11 23:36:18 UTC
svn commit: r495409 [22/47] - in
/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/...
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_server.html
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_server.html?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_server.html (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_server.html Thu Jan 11 14:35:53 2007
@@ -0,0 +1,371 @@
+<!--
+ /*
+ 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
+ */
+ Pieces taken from Dojo source to make this file stand-alone
+-->
+<html>
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
+ <script type="text/javascript" src="isAllowed.js"></script>
+ <!--
+ BY DEFAULT THIS FILE DOES NOT WORK SO THAT YOU DON'T ACCIDENTALLY EXPOSE
+ ALL OF YOUR XHR-ENABLED SERVICES ON YOUR SITE.
+
+ In order for this file to work, you should define a function with the following signature:
+
+ function isAllowedRequest(request){
+ return false;
+ }
+
+ Return true out of the function if you want to allow the cross-domain request.
+
+ DON'T DEFINE THIS FUNCTION IN THIS FILE! Define it in a separate file called isAllowed.js
+ and include it in this page with a script tag that has a src attribute pointing to the file.
+ See the very first script tag in this file for an example. You do not have to place the
+ script file in the same directory as this file, just update the path above if you move it
+ somewhere else.
+
+ Customize the isAllowedRequest function to restrict what types of requests are allowed
+ for this server. The request object has the following properties:
+ - requestHeaders: an object with the request headers that are to be added to
+ the XHR request.
+ - method: the HTTP method (GET, POST, etc...)
+ - uri: The URI for the request.
+ - data: The URL-encoded data for the request. For a GET request, this would
+ be the querystring parameters. For a POST request, it wll be the
+ body data.
+
+ See xip_client.html for more info on the xip fragment identifier protocol.
+ -->
+ <script type="text/javascript">
+ // <!--
+ djConfig = {
+ parseWidgets: false,
+ baseScriptUri: "./"
+ }
+ // -->
+ </script>
+ <script type="text/javascript">
+ // <!--
+ //Core XHR handling taken from Dojo IO code.
+ dojo = {};
+ dojo.hostenv = {};
+ // These are in order of decreasing likelihood; this will change in time.
+ dojo.hostenv._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
+
+ dojo.hostenv.getXmlhttpObject = function(){
+ var http = null;
+ var last_e = null;
+ try{ http = new XMLHttpRequest(); }catch(e){}
+ if(!http){
+ for(var i=0; i<3; ++i){
+ var progid = dojo.hostenv._XMLHTTP_PROGIDS[i];
+ try{
+ http = new ActiveXObject(progid);
+ }catch(e){
+ last_e = e;
+ }
+
+ if(http){
+ dojo.hostenv._XMLHTTP_PROGIDS = [progid]; // so faster next time
+ break;
+ }
+ }
+
+ /*if(http && !http.toString) {
+ http.toString = function() { "[object XMLHttpRequest]"; }
+ }*/
+ }
+
+ if(!http){
+ throw "xip_server.html: XMLHTTP not available: " + last_e;
+ }
+
+ return http;
+ }
+
+ dojo.setHeaders = function(http, headers){
+ if(headers) {
+ for(var header in headers) {
+ var headerValue = headers[header];
+ http.setRequestHeader(header, headerValue);
+ }
+ }
+ }
+
+ //MSIE has the lowest limit for URLs with fragment identifiers,
+ //at around 4K. Choosing a slightly smaller number for good measure.
+ xipUrlLimit = 4000;
+ xipIdCounter = 1;
+
+ function xipServerInit(){
+ xipStateId = "";
+ xipCurrentHash = "";
+ xipRequestMessage = "";
+ xipResponseParts = [];
+ xipPartIndex = 0;
+ }
+
+ function pollHash(){
+ //Can't use location.hash because at least Firefox does a decodeURIComponent on it.
+ var urlParts = window.location.href.split("#");
+ if(urlParts.length == 2){
+ var newHash = urlParts[1];
+ if(newHash != xipCurrentHash){
+ try{
+ messageReceived(newHash);
+ }catch(e){
+ //Make sure to not keep processing the error hash value.
+ xipCurrentHash = newHash;
+ throw e;
+ }
+ xipCurrentHash = newHash;
+ }
+ }
+ }
+
+ function messageReceived(encodedData){
+ var msg = unpackMessage(encodedData);
+
+ switch(msg.command){
+ case "ok":
+ sendResponsePart();
+ break;
+ case "start":
+ xipRequestMessage = "";
+ xipRequestMessage += msg.message;
+ setClientUrl("ok");
+ break;
+ case "part":
+ xipRequestMessage += msg.message;
+ setClientUrl("ok");
+ break;
+ case "end":
+ setClientUrl("ok");
+ xipRequestMessage += msg.message;
+ sendXhr();
+ break;
+ }
+ }
+
+ function sendResponse(encodedData){
+ //Break the message into parts, if necessary.
+ xipResponseParts = [];
+ var resData = encodedData;
+ var urlLength = xipClientUrl.length;
+ var partLength = xipUrlLimit - urlLength;
+ var resIndex = 0;
+
+ while((resData.length - resIndex) + urlLength > xipUrlLimit){
+ xipResponseParts.push(resData.substring(resIndex, resIndex + partLength));
+ resIndex += partLength;
+ }
+ xipResponseParts.push(resData.substring(resIndex, resData.length));
+
+ xipPartIndex = 0;
+ sendResponsePart();
+ }
+
+ function sendResponsePart(){
+ if(xipPartIndex < xipResponseParts.length){
+ //Get the message part.
+ var partData = xipResponseParts[xipPartIndex];
+
+ //Get the command.
+ var cmd = "part";
+ if(xipPartIndex + 1 == xipResponseParts.length){
+ cmd = "end";
+ }else if (xipPartIndex == 0){
+ cmd = "start";
+ }
+
+ setClientUrl(cmd, partData);
+ xipPartIndex++;
+ }else{
+ xipServerInit();
+ }
+ }
+
+ function setClientUrl(cmd, message){
+ var clientUrl = makeClientUrl(cmd, message);
+ //Safari won't let us replace across domains.
+ if(navigator.userAgent.indexOf("Safari") == -1){
+ parent.location.replace(clientUrl);
+ }else{
+ parent.location = clientUrl;
+ }
+ }
+
+ function makeClientUrl(cmd, message){
+ var clientUrl = xipClientUrl + "#" + (xipIdCounter++) + ":" + cmd;
+ if(message){
+ clientUrl += ":" + message;
+ }
+ return clientUrl
+ }
+
+ function xhrDone(xhr){
+ /* Need to pull off and return the following data:
+ - responseHeaders
+ - status
+ - statusText
+ - responseText
+ */
+ var response = {};
+
+ if(typeof(xhr.getAllResponseHeaders) != "undefined"){
+ var allHeaders = xhr.getAllResponseHeaders();
+ if(allHeaders){
+ response.responseHeaders = allHeaders;
+ }
+ }
+
+ if(xhr.status == 0 || xhr.status){
+ response.status = xhr.status;
+ }
+
+ if(xhr.statusText){
+ response.statusText = xhr.statusText;
+ }
+
+ if(xhr.responseText){
+ response.responseText = xhr.responseText;
+ }
+
+ //Build a string of the response object.
+ var result = "";
+ var isFirst = true;
+ for (var param in response){
+ if(isFirst){
+ isFirst = false;
+ }else{
+ result += "&";
+ }
+ result += param + "=" + encodeURIComponent(response[param]);
+ }
+ sendResponse(result);
+ }
+
+ function sendXhr(){
+ var request = {};
+ var nvPairs = xipRequestMessage.split("&");
+ var i = 0;
+ var nameValue = null;
+ for(i = 0; i < nvPairs.length; i++){
+ if(nvPairs[i]){
+ var nameValue = nvPairs[i].split("=");
+ request[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
+ }
+ }
+
+ //Split up the request headers, if any.
+ var headers = {};
+ if(request.requestHeaders){
+ nvPairs = request.requestHeaders.split("\r\n");
+ for(i = 0; i < nvPairs.length; i++){
+ if(nvPairs[i]){
+ nameValue = nvPairs[i].split(": ");
+ headers[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
+ }
+ }
+
+ request.requestHeaders = headers;
+ }
+
+ if(isAllowedRequest(request)){
+
+ //The request is allowed, so set up the XHR object.
+ var xhr = dojo.hostenv.getXmlhttpObject();
+
+ //Start timer to look for readyState.
+ var xhrIntervalId = setInterval(function(){
+
+ if(xhr.readyState == 4){
+ clearInterval(xhrIntervalId);
+ xhrDone(xhr);
+ }
+ }, 10);
+
+ //Actually start up the XHR request.
+ xhr.open(request.method, request.uri, true);
+ dojo.setHeaders(xhr, request.requestHeaders);
+
+ var content = "";
+ if(request.data){
+ content = request.data;
+ }
+
+ try{
+ xhr.send(content);
+ }catch(e){
+ if(typeof xhr.abort == "function"){
+ xhr.abort();
+ xhrDone({status: 404, statusText: "xip_server.html error: " + e});
+ }
+ }
+ }
+ }
+
+ function unpackMessage(encodedMessage){
+ var parts = encodedMessage.split(":");
+ var command = parts[1];
+ encodedMessage = parts[2] || "";
+
+ var config = null;
+ if(command == "init"){
+ var configParts = encodedMessage.split("&");
+ config = {};
+ for(var i = 0; i < configParts.length; i++){
+ var nameValue = configParts[i].split("=");
+ config[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
+ }
+ }
+ return {command: command, message: encodedMessage, config: config};
+ }
+
+ function onServerLoad(){
+ xipServerInit();
+
+ //Decode the init params
+ var config = unpackMessage(window.location.href.split("#")[1]).config;
+
+ xipStateId = config.id;
+ xipClientUrl = config.client;
+ xipUseFrameRecursion = config["fr"];
+
+ setInterval(pollHash, 10);
+
+ if(xipUseFrameRecursion == "true"){
+ var serverUrl = window.location.href.split("#")[0];
+ document.getElementById("iframeHolder").innerHTML = '<iframe src="'
+ + makeClientUrl("init", 'id=' + xipStateId + '&server=' + encodeURIComponent(serverUrl)
+ + '&fr=endpoint') + '" name="' + xipStateId + '_clientEndPoint"></iframe>';
+ }else{
+ setClientUrl("loaded");
+ }
+ }
+
+ if(typeof(window.addEventListener) == "undefined"){
+ window.attachEvent("onload", onServerLoad);
+ }else{
+ window.addEventListener('load', onServerLoad, false);
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <h4>The Dojo Toolkit -- xip_server.html</h4>
+
+ <p>This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the the file
+ that should go on the server that will actually be doing the XHR request.</p>
+ <div id="iframeHolder"></div>
+</body>
+</html>
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/json.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/json.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/json.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/json.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,156 @@
+/*
+ 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: AdapterRegistry a registry of type-based serializers
+ jsonRegistry: new dojo.AdapterRegistry(),
+
+ register: function( /*String*/ name,
+ /*function*/ check,
+ /*function*/ wrap,
+ /*optional, boolean*/ override){
+ // summary:
+ // 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.
+ // name:
+ // a descriptive type for this serializer
+ // check:
+ // a unary function that will be passed an object to determine
+ // whether or not wrap will be used to serialize the object
+ // wrap:
+ // the serialization function
+ // override:
+ // optional, determines if the this serialization function will be
+ // given priority in the test order
+
+ dojo.json.jsonRegistry.register(name, check, wrap, override);
+ },
+
+ evalJson: function(/*String*/ json){
+ // summary:
+ // evaluates the passed string-form of a JSON object
+ // json:
+ // a string literal of a JSON item, for instance:
+ // '{ "foo": [ "bar", 1, { "baz": "thud" } ] }'
+ // return:
+ // the result of the evaluation
+
+ // FIXME: should this accept mozilla's optional second arg?
+ try {
+ return eval("(" + json + ")");
+ }catch(e){
+ dojo.debug(e);
+ return json;
+ }
+ },
+
+ serialize: function(/*Object*/ o){
+ // summary:
+ // Create a JSON serialization of an object, note that this
+ // doesn't check for infinite recursion, so don't do that!
+ // o:
+ // an object to be serialized. Objects may define their own
+ // serialization via a special "__json__" or "json" function
+ // property. If a specialized serializer has been defined, it will
+ // be used as a fallback.
+ // return:
+ // a String representing the serialized version of the passed
+ // object
+
+ 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(",") + "}";
+ }
+};
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang.js Thu Jan 11 14:35:53 2007
@@ -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");
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/__package__.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/__package__.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/__package__.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/__package__.js Thu Jan 11 14:35:53 2007
@@ -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.*");
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/array.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/array.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/array.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/array.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,284 @@
+/*
+ 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.mixin(dojo.lang, {
+ has: function(/*Object*/obj, /*String*/name){
+ // summary: is there a property with the passed name in obj?
+ try{
+ return typeof obj[name] != "undefined"; // Boolean
+ }catch(e){ return false; } // Boolean
+ },
+
+ isEmpty: function(/*Object*/obj){
+ // summary:
+ // can be used to determine if the passed object is "empty". In
+ // the case of array-like objects, the length, property is
+ // examined, but for other types of objects iteration is used to
+ // examine the iterable "surface area" to determine if any
+ // non-prototypal properties have been assigned. This iteration is
+ // prototype-extension safe.
+ 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; // boolean
+ }else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)){
+ return obj.length == 0; // boolean
+ }
+ },
+
+ map: function(/*Array*/arr, /*Object|Function*/obj, /*Function?*/unary_func){
+ // summary:
+ // returns a new array constituded from the return values of
+ // passing each element of arr into unary_func. The obj parameter
+ // may be passed to enable the passed function to be called in
+ // that scope. In environments that support JavaScript 1.6, this
+ // function is a passthrough to the built-in map() function
+ // provided by Array instances. For details on this, see:
+ // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:map
+ // examples:
+ // dojo.lang.map([1, 2, 3, 4], function(item){ return item+1 });
+ // // returns [2, 3, 4, 5]
+ var isString = dojo.lang.isString(arr);
+ if(isString){
+ // arr: String
+ 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(""); // String
+ } else {
+ return outArr; // Array
+ }
+ },
+
+ reduce: function(/*Array*/arr, initialValue, /*Object|Function*/obj, /*Function*/binary_func){
+ // summary:
+ // similar to Python's builtin reduce() function. The result of
+ // the previous computation is passed as the first argument to
+ // binary_func along with the next value from arr. The result of
+ // this call is used along with the subsequent value from arr, and
+ // this continues until arr is exhausted. The return value is the
+ // last result. The "obj" and "initialValue" parameters may be
+ // safely omitted and the order of obj and binary_func may be
+ // reversed. The default order of the obj and binary_func argument
+ // will probably be reversed in a future release, and this call
+ // order is supported today.
+ // examples:
+ // dojo.lang.reduce([1, 2, 3, 4], function(last, next){ return last+next});
+ // returns 10
+ var reducedValue = initialValue;
+ if(arguments.length == 1){
+ dojo.debug("dojo.lang.reduce called with too few arguments!");
+ return false;
+ }else if(arguments.length == 2){
+ binary_func = initialValue;
+ reducedValue = arr.shift();
+ }else if(arguments.lenght == 3){
+ if(dojo.lang.isFunction(obj)){
+ binary_func = obj;
+ obj = null;
+ }
+ }else{
+ // un-fsck the default order
+ // FIXME:
+ // could be wrong for some strange function object cases. Not
+ // sure how to test for them.
+ if(dojo.lang.isFunction(obj)){
+ var tmp = binary_func;
+ binary_func = obj;
+ obj = tmp;
+ }
+ }
+
+ var ob = obj ? obj : dj_global;
+ dojo.lang.map(arr,
+ function(val){
+ reducedValue = binary_func.call(ob, reducedValue, val);
+ }
+ );
+ return reducedValue;
+ },
+
+ forEach: function(/*Array*/anArray, /*Function*/callback, /*Object?*/thisObject){
+ // summary:
+ // for every item in anArray, call callback with that item as its
+ // only parameter. Return values are ignored. This funciton
+ // corresponds (and wraps) the JavaScript 1.6 forEach method. For
+ // more details, see:
+ // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:forEach
+ if(dojo.lang.isString(anArray)){
+ // anArray: String
+ 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);
+ }
+ }
+ },
+
+ _everyOrSome: function(/*Boolean*/every, /*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
+ if(dojo.lang.isString(arr)){
+ //arr: String
+ 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; // Boolean
+ }else if((!every)&&(result)){
+ return true; // Boolean
+ }
+ }
+ return Boolean(every); // Boolean
+ }
+ },
+
+ every: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
+ // summary:
+ // determines whether or not every item in the array satisfies the
+ // condition implemented by callback. thisObject may be used to
+ // scope the call to callback. The function signature is derived
+ // from the JavaScript 1.6 Array.every() function. More
+ // information on this can be found here:
+ // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:every
+ // examples:
+ // dojo.lang.every([1, 2, 3, 4], function(item){ return item>1; });
+ // // returns false
+ // dojo.lang.every([1, 2, 3, 4], function(item){ return item>0; });
+ // // returns true
+ return this._everyOrSome(true, arr, callback, thisObject); // Boolean
+ },
+
+ some: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
+ // summary:
+ // determines whether or not any item in the array satisfies the
+ // condition implemented by callback. thisObject may be used to
+ // scope the call to callback. The function signature is derived
+ // from the JavaScript 1.6 Array.some() function. More
+ // information on this can be found here:
+ // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:some
+ // examples:
+ // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; });
+ // // returns true
+ // dojo.lang.some([1, 2, 3, 4], function(item){ return item<1; });
+ // // returns false
+ return this._everyOrSome(false, arr, callback, thisObject); // Boolean
+ },
+
+ filter: function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
+ // summary:
+ // returns a new Array with those items from arr that match the
+ // condition implemented by callback.thisObject may be used to
+ // scope the call to callback. The function signature is derived
+ // from the JavaScript 1.6 Array.filter() function, although
+ // special accomidation is made in our implementation for strings.
+ // More information on the JS 1.6 API can be found here:
+ // http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:filter
+ // examples:
+ // dojo.lang.some([1, 2, 3, 4], function(item){ return item>1; });
+ // // returns [2, 3, 4]
+ var isString = dojo.lang.isString(arr);
+ if(isString){ /*arr: String*/arr = arr.split(""); }
+ var outArr;
+ if(Array.filter){
+ outArr = Array.filter(arr, callback, thisObject);
+ }else{
+ if(!thisObject){
+ if(arguments.length >= 3){ dojo.raise("thisObject doesn't exist!"); }
+ thisObject = dj_global;
+ }
+
+ 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(""); // String
+ } else {
+ return outArr; // Array
+ }
+ },
+
+ unnest: function(/* ... */){
+ // summary:
+ // Creates a 1-D array out of all the arguments passed,
+ // unravelling any array-like objects in the process
+ // usage:
+ // unnest(1, 2, 3) ==> [1, 2, 3]
+ // unnest(1, [2, [3], [[[4]]]]) ==> [1, 2, 3, 4]
+
+ 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; // Array
+ },
+
+ toArray: function(/*Object*/arrayLike, /*Number*/startOffset){
+ // summary:
+ // Converts an array-like object (i.e. arguments, DOMCollection)
+ // to an array. Returns a new Array object.
+ var array = [];
+ for(var i = startOffset||0; i < arrayLike.length; i++){
+ array.push(arrayLike[i]);
+ }
+ return array; // Array
+ }
+});
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/assert.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/assert.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/assert.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/assert.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,116 @@
+/*
+ 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.
+ * description:
+ * If the asserted condition is true, this method does nothing. If the
+ * condition is false, we throw an error with a error message.
+ * booleanValue: Must be true for the assertion to succeed.
+ * message: A string describing the assertion.
+ */
+
+ // throws: Throws an Error if 'booleanValue' is false.
+ 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'
+ * 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.
+ * value: Any literal value or object instance.
+ * type: A class of object, or a literal type, or the string name of a type, or an array with a list of types.
+ * keywordParameters: {optional: boolean}
+ */
+
+ /* 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});
+ * throws: Throws an Error if 'value' is not of type 'type'.
+ */
+ 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'.
+ * 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.
+ * object: An anonymous object.
+ * expectedProperties: An array of strings (or an object with all the expected properties).
+ * message: A message describing the assertion.
+ */
+
+ /* 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});
+ * throws: Throws an Error if 'object' has unexpected properties.
+ */
+ 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);
+ }
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/common.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/common.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/common.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/common.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,253 @@
+/*
+ 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(!dojo.lang.isFunction(superclass)){
+ 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;
+ // DEPRECATED: 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. This addition is
+ // "prototype extension safe", so that instances of objects will not
+ // pass along prototype defaults.
+ 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; // Object
+}
+
+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; // Object
+}
+
+// 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.
+ // array: just what you think
+ // value: the value to locate
+ // identity:
+ // If true, matches with identity comparison (===). If false, uses
+ // normal comparison (==).
+ // findLast:
+ // If true, returns index of last instance of value.
+ // examples:
+ // find(array, value[, identity [findLast]]) // recommended
+ // 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. This is a shortcut for dojo.lang.find() with a true
+ // value for its "findLast" parameter.
+ // identity:
+ // If true, matches with identity comparison (===). If false, uses
+ // normal comparison (==).
+ return dojo.lang.find(array, value, identity, true); // number
+}
+
+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; // 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(/*anything*/ 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)); // Boolean
+}
+
+dojo.lang.isArray = function(/*anything*/ it){
+ // summary: Return true if it is an Array.
+ return (it && it instanceof Array || typeof it == "array"); // Boolean
+}
+
+dojo.lang.isArrayLike = function(/*anything*/ 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; // Boolean
+}
+
+dojo.lang.isFunction = function(/*anything*/ it){
+ // summary: Return true if it is a Function.
+ return (it instanceof Function || typeof it == "function"); // Boolean
+};
+
+(function(){
+ // webkit treats NodeList as a function, which is bad
+ if((dojo.render.html.capable)&&(dojo.render.html["safari"])){
+ dojo.lang.isFunction = function(/*anything*/ it){
+ if((typeof(it) == "function") && (it == "[object NodeList]")) { return false; }
+ return (it instanceof Function || typeof it == "function"); // Boolean
+ }
+ }
+})();
+
+dojo.lang.isString = function(/*anything*/ it){
+ // summary: Return true if it is a String.
+ return (typeof it == "string" || it instanceof String);
+}
+
+dojo.lang.isAlien = function(/*anything*/ it){
+ // summary: Return true if it is not a built-in function. False if not.
+ if(!it){ return false; }
+ return !dojo.lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean
+}
+
+dojo.lang.isBoolean = function(/*anything*/ it){
+ // summary: Return true if it is a Boolean.
+ return (it instanceof Boolean || typeof it == "boolean"); // 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(/*anything*/ it){
+ // summary: Return true if it is a number.
+ // description:
+ // 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"); // Boolean
+}
+
+/*
+ * FIXME: Should isUndefined go away since it is error prone?
+ */
+dojo.lang.isUndefined = function(/*anything*/ it){
+ // summary: Return true if it is not defined.
+ // description:
+ // 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)); // Boolean
+}
+
+// end Crockford functions
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/declare.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/declare.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/declare.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/declare.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,168 @@
+/*
+ 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");
+
+dojo.lang.declare = function( /*String*/ className,
+ /*Function|Array*/ superclass,
+ /*Function?*/ init,
+ /*Object|Array*/ props){
+ /*
+ * summary: Create a feature-rich constructor with a compact notation
+ * className: the name of the constructor (loosely, a "class")
+ * superclass:
+ * 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.
+ * init: an initializer function
+ * props:
+ * an object (or array of objects) whose properties are copied to the
+ * created prototype
+ * description:
+ * Create a constructor using a compact notation for inheritance and
+ * prototype extension. "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.
+ *
+ * Properties of object "props" are copied to the constructor
+ * prototype. If "props" is an array, properties of each object in the
+ * array are copied to the constructor prototype.
+ *
+ * name of the class ("className" argument) is stored in
+ * "declaredClass" property
+ *
+ * Initializer functions are called when an object is instantiated
+ * from this constructor.
+ *
+ * Aliased as "dojo.declare"
+ *
+ * Usage:
+ *
+ * dojo.declare("my.classes.bar", my.classes.foo,
+ * function(){
+ * // initialization function
+ * this.myComplicatedObject = new ReallyComplicatedObject();
+ * },
+ * { // properties to be added to the class prototype
+ * someValue: 2,
+ * someMethod: function(){
+ * doStuff();
+ * }
+ * }
+ * );
+ *
+ */
+ if((dojo.lang.isFunction(props))||((!props)&&(!dojo.lang.isFunction(init)))){
+ // parameter juggling to support omitting init param (also allows
+ // reordering init and props arguments)
+ 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._common);
+ ctor.prototype.constructor = ctor;
+ ctor.prototype.initializer = (ctor.prototype.initializer)||(init)||(function(){});
+ var created = dojo.parseObjPath(className, null, true);
+ created.obj[created.prop] = ctor;
+ return ctor; // Function
+}
+
+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._contextMethod(s, "constructor", arguments);
+ }
+ }
+ var ms = (self.constructor.mixins)||([]);
+ for(var i=0, m; (m=ms[i]); i++) {
+ (((m.prototype)&&(m.prototype.initializer))||(m)).apply(this, arguments);
+ }
+ if((!this.prototyping)&&(self.initializer)){
+ self.initializer.apply(this, arguments);
+ }
+ }
+}
+
+dojo.lang.declare._common = {
+ _getPropContext: function(){ return (this.___proto||this); },
+ // caches ptype context and calls method on it
+ _contextMethod: 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;
+ },
+ _inherited: function(prop, args){
+ // summary:
+ // Searches backward thru prototype chain to find nearest
+ // ancestral instance of prop. Internal use only.
+ 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._contextMethod(p, prop, args) : p[prop]);
+ },
+ inherited: function(prop, args){
+ dojo.deprecated("'inherited' method is dangerous, do not up-call! 'inherited' is slated for removal in 0.5; name your super class (or use superclass property) instead.", "0.5");
+ this._inherited(prop, args);
+ }
+}
+
+dojo.declare = dojo.lang.declare;
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,143 @@
+/*
+ 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");
+
+dojo.lang.setTimeout = function(/*Function*/func, /*int*/delay /*, ...*/){
+ // summary:
+ // Sets a timeout in milliseconds to execute a function in a given
+ // context with optional arguments.
+ // usage:
+ // dojo.lang.setTimeout(Object context, function func, number delay[, arg1[, ...]]);
+ // dojo.lang.setTimeout(function func, number delay[, arg1[, ...]]);
+
+ 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); // int
+}
+
+dojo.lang.clearTimeout = function(/*int*/timer){
+ // summary: clears timer by number from the execution queue
+
+ // FIXME:
+ // why do we have this function? It's not portable outside of browser
+ // environments and it's a stupid wrapper on something that browsers
+ // provide anyway.
+ dojo.global().clearTimeout(timer);
+}
+
+dojo.lang.getNameInObj = function(/*Object*/ns, /*unknown*/item){
+ // summary:
+ // looks for a value in the object ns with a value matching item and
+ // returns the property name
+ // ns: if null, dj_global is used
+ // item: value to return a name for
+ if(!ns){ ns = dj_global; }
+
+ for(var x in ns){
+ if(ns[x] === item){
+ return new String(x); // String
+ }
+ }
+ return null; // null
+}
+
+dojo.lang.shallowCopy = function(/*Object*/obj, /*Boolean?*/deep){
+ // summary:
+ // copies object obj one level deep, or full depth if deep is true
+ var i, ret;
+
+ if(obj === null){ /*obj: null*/ return null; } // null
+
+ if(dojo.lang.isObject(obj)){
+ // obj: Object
+ 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)){
+ // obj: Array
+ ret = [];
+ for(i=0; i<obj.length; i++){
+ ret[i] = deep ? dojo.lang.shallowCopy(obj[i], deep) : obj[i];
+ }
+ }else{
+ // obj: Object
+ ret = obj;
+ }
+
+ return ret; // Object
+}
+
+dojo.lang.firstValued = function(/* ... */){
+ // summary: Return the first argument that isn't undefined
+
+ for(var i = 0; i < arguments.length; i++){
+ if(typeof arguments[i] != "undefined"){
+ return arguments[i]; // Object
+ }
+ }
+ return undefined; // undefined
+}
+
+dojo.lang.getObjPathValue = function(/*String*/objpath, /*Object?*/context, /*Boolean?*/create){
+ // summary:
+ // Gets a value from a reference specified as a string descriptor,
+ // (e.g. "A.B") in the given context.
+ // context: if not specified, dj_global is used
+ // create: if true, undefined objects in the path are created.
+ with(dojo.parseObjPath(objpath, context, create)){
+ return dojo.evalProp(prop, obj, create); // Object
+ }
+}
+
+dojo.lang.setObjPathValue = function(/*String*/objpath, /*anything*/value, /*Object?*/context, /*Boolean?*/create){
+ // summary:
+ // Sets a value on a reference specified as a string descriptor.
+ // (e.g. "A.B") in the given context. This is similar to straight
+ // assignment, except that the object structure in question can
+ // optionally be created if it does not exist.
+ // context: if not specified, dj_global is used
+ // create: if true, undefined objects in the path are created.
+
+ // FIXME: why is this function valuable? It should be scheduled for
+ // removal on the grounds that dojo.parseObjPath does most of it's work and
+ // is more straightforward and has fewer dependencies. Also, the order of
+ // arguments is bone-headed. "context" should clearly come after "create".
+ // *sigh*
+ dojo.deprecated("dojo.lang.setObjPathValue", "use dojo.parseObjPath and the '=' operator", "0.6");
+
+ 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/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,231 @@
+/*
+ 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");
+
+dojo.lang.hitch = function(/*Object*/thisObject, /*Function|String*/method){
+ // summary:
+ // Returns a function that will only ever execute in the a given scope
+ // (thisObject). This allows for easy use of object member functions
+ // in callbacks and other places in which the "this" keyword may
+ // otherwise not reference the expected scope. Note that the order of
+ // arguments may be reversed in a future version.
+ // thisObject: the scope to run the method in
+ // method:
+ // a function to be "bound" to thisObject or the name of the method in
+ // thisObject to be used as the basis for the binding
+ // usage:
+ // dojo.lang.hitch(foo, "bar")(); // runs foo.bar() in the scope of foo
+ // dojo.lang.hitch(foo, myFunction); // returns a function that runs myFunction in the scope of foo
+
+ // FIXME:
+ // should this be extended to "fixate" arguments in a manner similar
+ // to dojo.lang.curry, but without the default execution of curry()?
+ var fcn = (dojo.lang.isString(method) ? thisObject[method] : method) || function(){};
+ return function(){
+ return fcn.apply(thisObject, arguments); // Function
+ };
+}
+
+dojo.lang.anonCtr = 0;
+dojo.lang.anon = {};
+
+dojo.lang.nameAnonFunc = function(/*Function*/anonFuncPtr, /*Object*/thisObj, /*Boolean*/searchForNames){
+ // summary:
+ // Creates a reference to anonFuncPtr in thisObj with a completely
+ // unique name. The new name is returned as a String. If
+ // searchForNames is true, an effort will be made to locate an
+ // existing reference to anonFuncPtr in thisObj, and if one is found,
+ // the existing name will be returned instead. The default is for
+ // searchForNames to be false.
+ var nso = (thisObj|| 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; // String
+}
+
+dojo.lang.forward = function(funcName){
+ // summary:
+ // Returns a function that forwards a method call to
+ // this.funcName(...). Unlike dojo.lang.hitch(), the "this" scope is
+ // not fixed on a single object. Ported from MochiKit.
+ return function(){
+ return this[funcName].apply(this, arguments);
+ }; // Function
+}
+
+dojo.lang.curry = function(thisObj, func /* args ... */){
+ // summary:
+ // similar to the curry() method found in many functional programming
+ // environments, this function returns an "argument accumulator"
+ // function, bound to a particular scope, and "primed" with a variable
+ // number of arguments. The curry method is unique in that it returns
+ // a function that may return other "partial" function which can be
+ // called repeatedly. New functions are returned until the arity of
+ // the original function is reached, at which point the underlying
+ // function (func) is called in the scope thisObj with all of the
+ // accumulated arguments (plus any extras) in positional order.
+ // examples:
+ // assuming a function defined like this:
+ // var foo = {
+ // bar: function(arg1, arg2, arg3){
+ // dojo.debug.apply(dojo, arguments);
+ // }
+ // };
+ //
+ // dojo.lang.curry() can be used most simply in this way:
+ //
+ // tmp = dojo.lang.curry(foo, foo.bar, "arg one", "thinger");
+ // tmp("blah", "this is superfluous");
+ // // debugs: "arg one thinger blah this is superfluous"
+ // tmp("blah");
+ // // debugs: "arg one thinger blah"
+ // tmp();
+ // // returns a function exactly like tmp that expects one argument
+ //
+ // other intermittent functions could be created until the 3
+ // positional arguments are filled:
+ //
+ // tmp = dojo.lang.curry(foo, foo.bar, "arg one");
+ // tmp2 = tmp("arg two");
+ // tmp2("blah blah");
+ // // debugs: "arg one arg two blah blah"
+ // tmp2("oy");
+ // // debugs: "arg one arg two oy"
+ //
+ // curry() can also be used to call the function if enough arguments
+ // are passed in the initial invocation:
+ //
+ // dojo.lang.curry(foo, foo.bar, "one", "two", "three", "four");
+ // // debugs: "one two three four"
+ // dojo.lang.curry(foo, foo.bar, "one", "two", "three");
+ // // debugs: "one two three"
+
+
+ // FIXME: the order of func and thisObj should be changed!!!
+ var outerArgs = [];
+ thisObj = thisObj||dj_global;
+ if(dojo.lang.isString(func)){
+ func = thisObj[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(thisObj, 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(/*Object*/thisObj, /*Function*/func, /*Array*/args, /*Integer, optional*/offset){
+ // summary:
+ // similar to dojo.lang.curry(), except that a list of arguments to
+ // start the curry with may be provided as an array instead of as
+ // positional arguments. An offset may be specified from the 0 index
+ // to skip some elements in args.
+ 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, [thisObj, func].concat(targs));
+}
+
+dojo.lang.tryThese = function(/*...*/){
+ // summary:
+ // executes each function argument in turn, returning the return value
+ // from the first one which does not throw an exception in execution.
+ // Any number of functions may be passed.
+ 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(/*Array*/farr, /*Function, optional*/cb, /*Integer*/delay, /*Function, optional*/onend){
+ // summary:
+ // executes a series of functions contained in farr, but spaces out
+ // calls to each function by the millisecond delay provided. If cb is
+ // provided, it will be called directly after each item in farr is
+ // called and if onend is passed, it will be called when all items
+ // have completed executing.
+
+ /**
+ * 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/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,85 @@
+/*
+ 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(/*String*/name, /*Function*/check, /*Function*/wrap, /*Boolean?*/override){
+ // summary:
+ // 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(/*Object*/obj){
+ // summary: Return a "programmer representation" for an object
+ // description: returns a string representation of an object suitable for developers, primarily used when debugging
+
+ if(typeof(obj) == "undefined"){
+ // obj: undefined
+ return "undefined"; // String
+ }else if(obj === null){
+ // obj: null
+ return "null"; // String
+ }
+
+ 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; // String
+ }
+ }
+
+ if(typeof(obj) == "function"){
+ // obj: Function
+ obj = (obj + "").replace(/^\s+/, "");
+ var idx = obj.indexOf("{");
+ if(idx != -1){
+ obj = obj.substr(0, idx) + "{...}";
+ }
+ }
+ return obj + ""; // String
+}
+
+dojo.lang.reprArrayLike = function(/*Array*/arr){
+ // summary: Maps each element of arr to dojo.lang.repr and provides output in an array-like format
+ // description: returns an array-like string representation of the provided array suitable for developers, primarily used when debugging
+ try{
+ var na = dojo.lang.map(arr, dojo.lang.repr);
+ return "[" + na.join(", ") + "]"; // String
+ }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);
+})();
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Streamer.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Streamer.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Streamer.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Streamer.js Thu Jan 11 14:35:53 2007
@@ -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);
+ }
+};
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Timer.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Timer.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Timer.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/Timer.js Thu Jan 11 14:35:53 2007
@@ -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);
+ }
+});
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/__package__.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/__package__.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/__package__.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/timing/__package__.js Thu Jan 11 14:35:53 2007
@@ -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.*");
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js?view=auto&rev=495409
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/type.js Thu Jan 11 14:35:53 2007
@@ -0,0 +1,245 @@
+/*
+ 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: 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: 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
+ // 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.
+ // value: Any literal value or object instance.
+
+ 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
+ // 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.
+ // value:
+ // Any literal value or object instance.
+ // 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: Any literal value or object instance.
+ * type: A class of object, or a literal type, or the string name of a type, or an array with a list of types.
+ * keywordParameters: {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
+ case Function:
+ case "function":
+ return dojo.lang.isFunction(value); // boolean
+ case String:
+ case "string":
+ return dojo.lang.isString(value); // boolean
+ case Number:
+ case "number":
+ return dojo.lang.isNumber(value); // boolean
+ case "numeric":
+ return dojo.lang.isNumeric(value); // boolean
+ case Boolean:
+ case "boolean":
+ return dojo.lang.isBoolean(value); // boolean
+ case Object:
+ case "object":
+ return dojo.lang.isObject(value); // boolean
+ case "pureobject":
+ return dojo.lang.isPureObject(value); // boolean
+ case "builtin":
+ return dojo.lang.isBuiltIn(value); // boolean
+ case "alien":
+ return dojo.lang.isAlien(value); // boolean
+ case "undefined":
+ return dojo.lang.isUndefined(value); // boolean
+ case null:
+ case "null":
+ return (value === null); // boolean
+ 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
+ default:
+ if(dojo.lang.isFunction(type)){
+ return (value instanceof type); // boolean
+ }else{
+ dojo.raise("dojo.lang.isOfType() was passed an invalid type");
+ }
+ }
+ }
+ 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
+}