You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2006/11/10 10:15:40 UTC
svn commit: r473277 [21/45] - 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/common.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/common.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/common.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/common.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,513 @@
+/*
+ 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.io.common");
+dojo.require("dojo.string");
+dojo.require("dojo.lang.extras");
+
+/******************************************************************************
+ * Notes about dojo.io design:
+ *
+ * The dojo.io.* package has the unenviable task of making a lot of different
+ * types of I/O feel natural, despite a universal lack of good (or even
+ * reasonable!) I/O capability in the host environment. So lets pin this down
+ * a little bit further.
+ *
+ * Rhino:
+ * perhaps the best situation anywhere. Access to Java classes allows you
+ * to do anything one might want in terms of I/O, both synchronously and
+ * async. Can open TCP sockets and perform low-latency client/server
+ * interactions. HTTP transport is available through Java HTTP client and
+ * server classes. Wish it were always this easy.
+ *
+ * xpcshell:
+ * XPCOM for I/O.
+ *
+ * spidermonkey:
+ * S.O.L.
+ *
+ * Browsers:
+ * Browsers generally do not provide any useable filesystem access. We are
+ * therefore limited to HTTP for moving information to and from Dojo
+ * instances living in a browser.
+ *
+ * XMLHTTP:
+ * Sync or async, allows reading of arbitrary text files (including
+ * JS, which can then be eval()'d), writing requires server
+ * cooperation and is limited to HTTP mechanisms (POST and GET).
+ *
+ * <iframe> hacks:
+ * iframe document hacks allow browsers to communicate asynchronously
+ * with a server via HTTP POST and GET operations. With significant
+ * effort and server cooperation, low-latency data transit between
+ * client and server can be acheived via iframe mechanisms (repubsub).
+ *
+ * SVG:
+ * Adobe's SVG viewer implements helpful primitives for XML-based
+ * requests, but receipt of arbitrary text data seems unlikely w/o
+ * <![CDATA[]]> sections.
+ *
+ *
+ * A discussion between Dylan, Mark, Tom, and Alex helped to lay down a lot
+ * the IO API interface. A transcript of it can be found at:
+ * http://dojotoolkit.org/viewcvs/viewcvs.py/documents/irc/irc_io_api_log.txt?rev=307&view=auto
+ *
+ * Also referenced in the design of the API was the DOM 3 L&S spec:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html
+ ******************************************************************************/
+
+// a map of the available transport options. Transports should add themselves
+// by calling add(name)
+dojo.io.transports = [];
+dojo.io.hdlrFuncNames = [ "load", "error", "timeout" ]; // we're omitting a progress() event for now
+
+dojo.io.Request = function(/*String*/ url, /*String*/ mimetype, /*String*/ transport, /*String or Boolean*/ changeUrl){
+// summary:
+// Constructs a Request object that is used by dojo.io.bind(). dojo.io.bind() will create one of these for you if
+// you call dojo.io.bind() with an plain object containing the bind parameters.
+// This method can either take the arguments specified, or an Object containing all of the parameters that you
+// want to use to create the dojo.io.Request (similar to how dojo.io.bind() is called.
+// The named parameters to this constructor represent the minimum set of parameters need
+ if((arguments.length == 1)&&(arguments[0].constructor == Object)){
+ this.fromKwArgs(arguments[0]);
+ }else{
+ this.url = url;
+ if(mimetype){ this.mimetype = mimetype; }
+ if(transport){ this.transport = transport; }
+ if(arguments.length >= 4){ this.changeUrl = changeUrl; }
+ }
+}
+
+dojo.lang.extend(dojo.io.Request, {
+
+ /** The URL to hit */
+ url: "",
+
+ /** The mime type used to interrpret the response body */
+ mimetype: "text/plain",
+
+ /** The HTTP method to use */
+ method: "GET",
+
+ /** An Object containing key-value pairs to be included with the request */
+ content: undefined, // Object
+
+ /** The transport medium to use */
+ transport: undefined, // String
+
+ /** If defined the URL of the page is physically changed */
+ changeUrl: undefined, // String
+
+ /** A form node to use in the request */
+ formNode: undefined, // HTMLFormElement
+
+ /** Whether the request should be made synchronously */
+ sync: false,
+
+ bindSuccess: false,
+
+ /** Cache/look for the request in the cache before attempting to request?
+ * NOTE: this isn't a browser cache, this is internal and would only cache in-page
+ */
+ useCache: false,
+
+ /** Prevent the browser from caching this by adding a query string argument to the URL */
+ preventCache: false,
+
+ // events stuff
+ load: function(/*String*/ type, /*Object*/ data, /*Object*/ transportImplementation, /*Object*/ kwArgs){
+ // summary:
+ // Called on successful completion of a bind.
+ // type:
+ // A string with value "load"
+ // data:
+ // The object representing the result of the bind. The actual structure
+ // of the data object will depend on the mimetype that was given to bind
+ // in the bind arguments.
+ // transportImplementation:
+ // The object that implements a particular transport. Structure is depedent
+ // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the
+ // XMLHttpRequest object from the browser.
+ // kwArgs:
+ // Object that contains the request parameters that were given to the
+ // bind call. Useful for storing and retrieving state from when bind
+ // was called.
+ },
+ error: function(/*String*/ type, /*Object*/ error, /*Object*/ transportImplementation, /*Object*/ kwArgs){
+ // summary:
+ // Called when there is an error with a bind.
+ // type:
+ // A string with value "error"
+ // error:
+ // The error object. Should be a dojo.io.Error object, but not guaranteed.
+ // transportImplementation:
+ // The object that implements a particular transport. Structure is depedent
+ // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the
+ // XMLHttpRequest object from the browser.
+ // kwArgs:
+ // Object that contains the request parameters that were given to the
+ // bind call. Useful for storing and retrieving state from when bind
+ // was called.
+ },
+ timeout: function(/*String*/ type, /*Object*/ empty, /*Object*/ transportImplementation, /*Object*/ kwArgs){
+ // summary:
+ // Called when there is an error with a bind. Only implemented in certain transports at this time.
+ // type:
+ // A string with value "timeout"
+ // empty:
+ // Should be null. Just a spacer argument so that load, error, timeout and handle have the
+ // same signatures.
+ // transportImplementation:
+ // The object that implements a particular transport. Structure is depedent
+ // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the
+ // XMLHttpRequest object from the browser. May be null for the timeout case for
+ // some transports.
+ // kwArgs:
+ // Object that contains the request parameters that were given to the
+ // bind call. Useful for storing and retrieving state from when bind
+ // was called.
+ },
+ handle: function(/*String*/ type, /*Object*/ data, /*Object*/ transportImplementation, /*Object*/ kwArgs){
+ // summary:
+ // The handle method can be defined instead of defining separate load, error and timeout
+ // callbacks.
+ // type:
+ // A string with the type of callback: "load", "error", or "timeout".
+ // data:
+ // See the above callbacks for what this parameter could be.
+ // transportImplementation:
+ // The object that implements a particular transport. Structure is depedent
+ // on the transport. For XMLHTTPTransport (dojo.io.BrowserIO), it will be the
+ // XMLHttpRequest object from the browser.
+ // kwArgs:
+ // Object that contains the request parameters that were given to the
+ // bind call. Useful for storing and retrieving state from when bind
+ // was called.
+ },
+
+ //FIXME: change IframeIO.js to use timeouts?
+ // The number of seconds to wait until firing a timeout callback.
+ // If it is zero, that means, don't do a timeout check.
+ timeoutSeconds: 0,
+
+ // the abort method needs to be filled in by the transport that accepts the
+ // bind() request
+ abort: function(){ },
+
+ // backButton: function(){ },
+ // forwardButton: function(){ },
+
+ fromKwArgs: function(/*Object*/ kwArgs){
+ // summary:
+ // Creates a dojo.io.Request from a simple object (kwArgs object).
+
+ // normalize args
+ if(kwArgs["url"]){ kwArgs.url = kwArgs.url.toString(); }
+ if(kwArgs["formNode"]) { kwArgs.formNode = dojo.byId(kwArgs.formNode); }
+ if(!kwArgs["method"] && kwArgs["formNode"] && kwArgs["formNode"].method) {
+ kwArgs.method = kwArgs["formNode"].method;
+ }
+
+ // backwards compatibility
+ if(!kwArgs["handle"] && kwArgs["handler"]){ kwArgs.handle = kwArgs.handler; }
+ if(!kwArgs["load"] && kwArgs["loaded"]){ kwArgs.load = kwArgs.loaded; }
+ if(!kwArgs["changeUrl"] && kwArgs["changeURL"]) { kwArgs.changeUrl = kwArgs.changeURL; }
+
+ // encoding fun!
+ kwArgs.encoding = dojo.lang.firstValued(kwArgs["encoding"], djConfig["bindEncoding"], "");
+
+ kwArgs.sendTransport = dojo.lang.firstValued(kwArgs["sendTransport"], djConfig["ioSendTransport"], false);
+
+ var isFunction = dojo.lang.isFunction;
+ for(var x=0; x<dojo.io.hdlrFuncNames.length; x++){
+ var fn = dojo.io.hdlrFuncNames[x];
+ if(kwArgs[fn] && isFunction(kwArgs[fn])){ continue; }
+ if(kwArgs["handle"] && isFunction(kwArgs["handle"])){
+ kwArgs[fn] = kwArgs.handle;
+ }
+ // handler is aliased above, shouldn't need this check
+ /* else if(dojo.lang.isObject(kwArgs.handler)){
+ if(isFunction(kwArgs.handler[fn])){
+ kwArgs[fn] = kwArgs.handler[fn]||kwArgs.handler["handle"]||function(){};
+ }
+ }*/
+ }
+ dojo.lang.mixin(this, kwArgs);
+ }
+
+});
+
+dojo.io.Error = function(/*String*/ msg, /*String*/ type, /*Number*/num){
+ // summary:
+ // Constructs an object representing a bind error.
+ this.message = msg;
+ this.type = type || "unknown"; // must be one of "io", "parse", "unknown"
+ this.number = num || 0; // per-substrate error number, not normalized
+}
+
+dojo.io.transports.addTransport = function(name){
+ // summary:
+ // Used to register transports that can support bind calls.
+ this.push(name);
+ // FIXME: do we need to handle things that aren't direct children of the
+ // dojo.io module? (say, dojo.io.foo.fooTransport?)
+ this[name] = dojo.io[name];
+}
+
+// binding interface, the various implementations register their capabilities
+// and the bind() method dispatches
+dojo.io.bind = function(/*Object*/ request){
+ // summary:
+ // Binding interface for IO. Loading different IO transports, like
+ // dojo.io.BrowserIO or dojo.io.IframeIO will register with bind
+ // to handle particular types of bind calls.
+ // request:
+ // Object containing bind arguments. This object is converted to
+ // a dojo.io.Request object, and that request object is the return
+ // value for this method.
+ if(!(request instanceof dojo.io.Request)){
+ try{
+ request = new dojo.io.Request(request);
+ }catch(e){ dojo.debug(e); }
+ }
+
+ // if the request asks for a particular implementation, use it
+ var tsName = "";
+ if(request["transport"]){
+ tsName = request["transport"];
+ if(!this[tsName]){
+ dojo.io.sendBindError(request, "No dojo.io.bind() transport with name '"
+ + request["transport"] + "'.");
+ return request; //dojo.io.Request
+ }
+ if(!this[tsName].canHandle(request)){
+ dojo.io.sendBindError(request, "dojo.io.bind() transport with name '"
+ + request["transport"] + "' cannot handle this type of request.");
+ return request; //dojo.io.Request
+ }
+ }else{
+ // otherwise we do our best to auto-detect what available transports
+ // will handle
+ for(var x=0; x<dojo.io.transports.length; x++){
+ var tmp = dojo.io.transports[x];
+ if((this[tmp])&&(this[tmp].canHandle(request))){
+ tsName = tmp;
+ break;
+ }
+ }
+ if(tsName == ""){
+ dojo.io.sendBindError(request, "None of the loaded transports for dojo.io.bind()"
+ + " can handle the request.");
+ return request; //dojo.io.Request
+ }
+ }
+ this[tsName].bind(request);
+ request.bindSuccess = true;
+ return request; //dojo.io.Request
+}
+
+dojo.io.sendBindError = function(request /* Object */, message /* String */){
+ // summary:
+ // Used internally by dojo.io.bind() to return/raise a bind error.
+
+ //Need to be careful since not all hostenvs support setTimeout.
+ if((typeof request.error == "function" || typeof request.handle == "function")
+ && (typeof setTimeout == "function" || typeof setTimeout == "object")){
+ var errorObject = new dojo.io.Error(message);
+ setTimeout(function(){
+ request[(typeof request.error == "function") ? "error" : "handle"]("error", errorObject, null, request);
+ }, 50);
+ }else{
+ dojo.raise(message);
+ }
+}
+
+dojo.io.queueBind = function(/* Object */ request){
+ // summary:
+ // queueBind will use dojo.io.bind() but guarantee that only one bind
+ // call is handled at a time. If queueBind is called while a bind call
+ // is in process, it will queue up the other calls to bind and call them
+ // in order as bind calls complete.
+ // request:
+ // Same sort of request object as used for dojo.io.bind().
+ if(!(request instanceof dojo.io.Request)){
+ try{
+ request = new dojo.io.Request(request);
+ }catch(e){ dojo.debug(e); }
+ }
+
+ // make sure we get called if/when we get a response
+ var oldLoad = request.load;
+ request.load = function(){
+ dojo.io._queueBindInFlight = false;
+ var ret = oldLoad.apply(this, arguments);
+ dojo.io._dispatchNextQueueBind();
+ return ret;
+ }
+
+ var oldErr = request.error;
+ request.error = function(){
+ dojo.io._queueBindInFlight = false;
+ var ret = oldErr.apply(this, arguments);
+ dojo.io._dispatchNextQueueBind();
+ return ret;
+ }
+
+ dojo.io._bindQueue.push(request);
+ dojo.io._dispatchNextQueueBind();
+ return request; //dojo.io.Request
+}
+
+dojo.io._dispatchNextQueueBind = function(){
+ // summary:
+ // Private method used by dojo.io.queueBind().
+ if(!dojo.io._queueBindInFlight){
+ dojo.io._queueBindInFlight = true;
+ if(dojo.io._bindQueue.length > 0){
+ dojo.io.bind(dojo.io._bindQueue.shift());
+ }else{
+ dojo.io._queueBindInFlight = false;
+ }
+ }
+}
+dojo.io._bindQueue = [];
+dojo.io._queueBindInFlight = false;
+
+dojo.io.argsFromMap = function(/*Object*/ map, /*String*/ encoding, /*String*/ last){
+ // summary:
+ // Converts name/values pairs in the map object to an URL-encoded string
+ // with format of name1=value1&name2=value2...
+ // map:
+ // Object that has the contains the names and values.
+ // encoding:
+ // String to specify how to encode the name and value. If the encoding string
+ // contains "utf" (case-insensitive), then encodeURIComponent is used. Otherwise
+ // dojo.string.encodeAscii is used.
+ // last:
+ // The last parameter in the list. Helps with final string formatting?
+ var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;
+ var mapped = [];
+ var control = new Object();
+ for(var name in map){
+ var domap = function(elt){
+ var val = enc(name)+"="+enc(elt);
+ mapped[(last == name) ? "push" : "unshift"](val);
+ }
+ if(!control[name]){
+ var value = map[name];
+ // FIXME: should be isArrayLike?
+ if (dojo.lang.isArray(value)){
+ dojo.lang.forEach(value, domap);
+ }else{
+ domap(value);
+ }
+ }
+ }
+ return mapped.join("&"); //String
+}
+
+dojo.io.setIFrameSrc = function(/*DOMNode*/ iframe, /*String*/ src, /*Boolean*/ replace){
+ //summary:
+ // Sets the URL that is loaded in an IFrame. The replace parameter indicates whether
+ // location.replace() should be used when changing the location of the iframe.
+ try{
+ var r = dojo.render.html;
+ // dojo.debug(iframe);
+ if(!replace){
+ if(r.safari){
+ iframe.location = src;
+ }else{
+ frames[iframe.name].location = src;
+ }
+ }else{
+ // Fun with DOM 0 incompatibilities!
+ var idoc;
+ if(r.ie){
+ idoc = iframe.contentWindow.document;
+ }else if(r.safari){
+ idoc = iframe.document;
+ }else{ // if(r.moz){
+ idoc = iframe.contentWindow;
+ }
+
+ //For Safari (at least 2.0.3) and Opera, if the iframe
+ //has just been created but it doesn't have content
+ //yet, then iframe.document may be null. In that case,
+ //use iframe.location and return.
+ if(!idoc){
+ iframe.location = src;
+ return;
+ }else{
+ idoc.location.replace(src);
+ }
+ }
+ }catch(e){
+ dojo.debug(e);
+ dojo.debug("setIFrameSrc: "+e);
+ }
+}
+
+/*
+dojo.io.sampleTranport = new function(){
+ this.canHandle = function(kwArgs){
+ // canHandle just tells dojo.io.bind() if this is a good transport to
+ // use for the particular type of request.
+ if(
+ (
+ (kwArgs["mimetype"] == "text/plain") ||
+ (kwArgs["mimetype"] == "text/html") ||
+ (kwArgs["mimetype"] == "text/javascript")
+ )&&(
+ (kwArgs["method"] == "get") ||
+ ( (kwArgs["method"] == "post") && (!kwArgs["formNode"]) )
+ )
+ ){
+ return true;
+ }
+
+ return false;
+ }
+
+ this.bind = function(kwArgs){
+ var hdlrObj = {};
+
+ // set up a handler object
+ for(var x=0; x<dojo.io.hdlrFuncNames.length; x++){
+ var fn = dojo.io.hdlrFuncNames[x];
+ if(typeof kwArgs.handler == "object"){
+ if(typeof kwArgs.handler[fn] == "function"){
+ hdlrObj[fn] = kwArgs.handler[fn]||kwArgs.handler["handle"];
+ }
+ }else if(typeof kwArgs[fn] == "function"){
+ hdlrObj[fn] = kwArgs[fn];
+ }else{
+ hdlrObj[fn] = kwArgs["handle"]||function(){};
+ }
+ }
+
+ // build a handler function that calls back to the handler obj
+ var hdlrFunc = function(evt){
+ if(evt.type == "onload"){
+ hdlrObj.load("load", evt.data, evt);
+ }else if(evt.type == "onerr"){
+ var errObj = new dojo.io.Error("sampleTransport Error: "+evt.msg);
+ hdlrObj.error("error", errObj);
+ }
+ }
+
+ // the sample transport would attach the hdlrFunc() when sending the
+ // request down the pipe at this point
+ var tgtURL = kwArgs.url+"?"+dojo.io.argsFromMap(kwArgs.content);
+ // sampleTransport.sendRequest(tgtURL, hdlrFunc);
+ }
+
+ dojo.io.transports.addTransport("sampleTranport");
+}
+*/
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/common.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/common.js
------------------------------------------------------------------------------
svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/common.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_client.html
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_client.html?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_client.html (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/xip_client.html Fri Nov 10 01:15:01 2006
@@ -0,0 +1,200 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
+ <script type="text/javascript">
+ // <!--
+ /*
+ This file is really focused on just sending one message to the server, and
+ receiving one response. The code does not expect to be re-used for multiple messages.
+ This might be reworked later if performance indicates a need for it.
+
+ xip fragment identifier/hash values have the form:
+ #id:cmd:realUrlEncodedMessage
+
+ id: some ID that should be unique among messages. No inherent meaning,
+ just something to make sure the hash value is unique so the message
+ receiver knows a new message is available.
+
+ cmd: command to the receiver. Valid values are:
+ - loaded: the remote frame is loaded. Only sent from server to client.
+ - ok: the message that this page sent was received OK. The next message may
+ now be sent.
+ - start: the start message of a block of messages (a complete message may
+ need to be segmented into many messages to get around the limitiations
+ of the size of an URL that a browser accepts.
+ - part: indicates this is a part of a message.
+ - end: the end message of a block of messages. The message can now be acted upon.
+ If the message is small enough that it doesn't need to be segmented, then
+ just one hash value message can be sent with "end" as the command.
+
+ To reassemble a segmented message, the realUrlEncodedMessage parts just have to be concatenated
+ together.
+ */
+
+ //Choosing 1024 as an arbitrary limit for the URL sizes.
+ //Anecdotal info seems to indicate this is safe to use in all
+ //modern browsers.
+ xipUrlLimit = 1024;
+ xipIdCounter = 1;
+
+ function xipInit(){
+ xipIsSending = false;
+ xipServerUrl = null;
+ xipStateId = null;
+ xipRequestData = null;
+ xipCurrentHash = "";
+ xipResponseMessage = "";
+ xipRequestParts = [];
+ xipPartIndex = 0;
+ xipServerWindow = null;
+ }
+ xipInit();
+
+ function send(stateId, ifpServerUrl, urlEncodedData){
+ if(!xipIsSending){
+ xipIsSending = true;
+
+ xipStateId = stateId;
+ xipRequestData = urlEncodedData || "";
+
+ //Modify the server URL if it is a local path and
+ //This is done for local/same domain testing.
+ xipServerUrl = ifpServerUrl;
+ if(ifpServerUrl.indexOf("..") == 0){
+ var parts = ifpServerUrl.split("/");
+ xipServerUrl = parts[parts.length - 1];
+ }
+
+ //Fix server URL to tell it about this page's URL. So that it can call us
+ //back correctly. Use the fragment identifier to allow for caching of the server
+ //page, and hey, we're using the fragment identifier for everything else.
+ ifpServerUrl += "#" + encodeURIComponent(window.location);
+
+ //Start counter to inspect hash value.
+ setInterval(pollHash, 10);
+
+ //Loader server iframe, then wait for the server page to call us back.
+ xipServerWindow = frames["xipServerFrame"];
+ if (!xipServerWindow){
+ xipServerWindow = document.getElementById("xipServerFrame").contentWindow;
+ }
+
+ xipServerWindow.location.replace(ifpServerUrl);
+ }
+ }
+
+ 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(urlEncodedMessage){
+ //Split off xip header.
+ var parts = urlEncodedMessage.split(":");
+ var command = parts[1];
+ urlEncodedMessage = parts[2] || "";
+
+ switch(command){
+ case "loaded":
+ sendRequestStart();
+ break;
+ case "ok":
+ sendRequestPart();
+ break;
+ case "start":
+ xipResponseMessage = "";
+ xipResponseMessage += urlEncodedMessage;
+ setServerUrl("ok");
+ break;
+ case "part":
+ xipResponseMessage += urlEncodedMessage;
+ setServerUrl("ok");
+ break;
+ case "end":
+ setServerUrl("ok");
+ xipResponseMessage += urlEncodedMessage;
+ parent.dojo.io.XhrIframeProxy.receive(xipStateId, xipResponseMessage);
+ break;
+ }
+ }
+
+ function sendRequestStart(){
+ //Break the message into parts, if necessary.
+ xipRequestParts = [];
+ var reqData = xipRequestData;
+ var urlLength = xipServerUrl.length;
+ var partLength = xipUrlLimit - urlLength;
+ var reqIndex = 0;
+
+ while((reqData.length - reqIndex) + urlLength > xipUrlLimit){
+ xipRequestParts.push(reqData.substring(reqIndex, reqIndex + partLength));
+ reqIndex += partLength;
+ }
+ xipRequestParts.push(reqData.substring(reqIndex, reqData.length));
+
+ xipPartIndex = 0;
+ sendRequestPart();
+
+ }
+
+ function sendRequestPart(){
+ if(xipPartIndex < xipRequestParts.length){
+ //Get the message part.
+ var partData = xipRequestParts[xipPartIndex];
+
+ //Get the command.
+ var cmd = "part";
+ if(xipPartIndex + 1 == xipRequestParts.length){
+ cmd = "end";
+ }else if (xipPartIndex == 0){
+ cmd = "start";
+ }
+
+ setServerUrl(cmd, partData);
+ xipPartIndex++;
+ }
+ }
+
+ function setServerUrl(cmd, message){
+ var serverUrl = xipServerUrl + "#" + (xipIdCounter++) + ":" + cmd;
+ if(message){
+ serverUrl += ":" + message;
+ }
+
+ //Safari won't let us replace across domains.
+ if(navigator.userAgent.indexOf("Safari") == -1){
+ xipServerWindow.location.replace(serverUrl);
+ }else{
+ xipServerWindow.location = serverUrl;
+ }
+
+ }
+ // -->
+ </script>
+</head>
+<body>
+ <h4>The Dojo Toolkit -- xip_client.html</h4>
+
+ <p>This file is used for Dojo's XMLHttpRequest Iframe Proxy. This is the "client" file used
+ internally by dojo.io.XhrIframeProxy.</p>
+
+ <iframe id="xipServerFrame"></iframe>
+</body>
+</html>
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=473277
==============================================================================
--- 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 Fri Nov 10 01:15:01 2006
@@ -0,0 +1,337 @@
+<!--
+ /*
+ 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.
+ -->
+ <script type="text/javascript">
+ // <!--
+ /*
+ See xip_client.html for more info on the xip fragment identifier protocol.
+
+ This page uses Dojo to do the actual XMLHttpRequest (XHR) to the server, but you could
+ replace the Dojo references with your own XHR code if you like. But keep the other xip
+ code to communicate back to the xip client frame.
+ */
+ djConfig = {
+ parseWidgets: false,
+ baseScriptUri: "./"
+ }
+ // -->
+ </script>
+ <script type="text/javascript">
+ 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);
+ }
+ }
+ }
+
+ //Choosing 1024 as an arbitrary limit for the URL sizes.
+ //Anecdotal info seems to indicate this is safe to use in all
+ //modern browsers.
+ xipUrlLimit = 1024;
+ xipIdCounter = 1;
+
+ function xipServerInit(){
+ xipCurrentHash = "";
+ xipRequestMessage = "";
+ xipResponseParts = [];
+ xipPartIndex = 0;
+ }
+
+ function xipServerLoaded(){
+ xipServerInit();
+ xipClientUrl = decodeURIComponent(window.location.hash.substring(1, window.location.hash.length));
+
+ setInterval(pollHash, 10);
+ setClientUrl("loaded");
+ }
+
+ 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(urlEncodedMessage){
+ //Split off xip header.
+ var parts = urlEncodedMessage.split(":");
+ var command = parts[1];
+ urlEncodedMessage = parts[2] || "";
+
+ switch(command){
+ case "ok":
+ sendResponsePart();
+ break;
+ case "start":
+ xipRequestMessage = "";
+ xipRequestMessage += urlEncodedMessage;
+ setClientUrl("ok");
+ break;
+ case "part":
+ xipRequestMessage += urlEncodedMessage;
+ setClientUrl("ok");
+ break;
+ case "end":
+ setClientUrl("ok");
+ xipRequestMessage += urlEncodedMessage;
+ sendXhr();
+ break;
+ }
+ }
+
+ function sendResponse(urlEncodedData){
+ //Break the message into parts, if necessary.
+ xipResponseParts = [];
+ var resData = urlEncodedData;
+ 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 = xipClientUrl + "#" + (xipIdCounter++) + ":" + cmd;
+ if(message){
+ clientUrl += ":" + message;
+ }
+
+ //Safari won't let us replace across domains.
+ if(navigator.userAgent.indexOf("Safari") == -1){
+ parent.location.replace(clientUrl);
+ }else{
+ parent.location = 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});
+ }
+ }
+ }
+ }
+
+ window.onload = xipServerLoaded;
+ // -->
+ </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>
+</body>
+</html>
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/json.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/json.js Fri Nov 10 01:15:01 2006
@@ -14,33 +14,52 @@
dojo.require("dojo.AdapterRegistry");
dojo.json = {
+ // jsonRegistry: AdapterRegistry a registry of type-based serializers
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.
- ***/
+ 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(/* jsonString */ json){
+ 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 + ")");
@@ -50,16 +69,18 @@
}
},
- evalJSON: function (json) {
- dojo.deprecated("dojo.json.evalJSON", "use dojo.json.evalJson", "0.4");
- return this.evalJson(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!
- ***/
+ 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"){
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang.js Fri Nov 10 01:15:01 2006
@@ -9,6 +9,6 @@
*/
dojo.provide("dojo.lang");
-dojo.provide("dojo.lang.Lang");
-
dojo.require("dojo.lang.common");
+
+dojo.deprecated("dojo.lang", "replaced by dojo.lang.common", "0.5");
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/__package__.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/__package__.js Fri Nov 10 01:15:01 2006
@@ -10,7 +10,6 @@
dojo.kwCompoundRequire({
common: [
- "dojo.lang",
"dojo.lang.common",
"dojo.lang.assert",
"dojo.lang.array",
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/array.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/array.js Fri Nov 10 01:15:01 2006
@@ -14,14 +14,14 @@
// 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){
+dojo.lang.has = function(/*Object*/obj, /*String*/name){
try{
- return (typeof obj[name] != "undefined");
+ return typeof obj[name] != "undefined";
}catch(e){ return false; }
}
-dojo.lang.isEmpty = function(obj) {
- if(dojo.lang.isObject(obj)) {
+dojo.lang.isEmpty = function(/*Object*/obj){
+ if(dojo.lang.isObject(obj)){
var tmp = {};
var count = 0;
for(var x in obj){
@@ -30,15 +30,16 @@
break;
}
}
- return (count == 0);
- } else if(dojo.lang.isArrayLike(obj) || dojo.lang.isString(obj)) {
+ 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){
+dojo.lang.map = function(/*Array*/arr, /*Object|Function*/obj, /*Function?*/unary_func){
var isString = dojo.lang.isString(arr);
if(isString){
+ // arr: String
arr = arr.split("");
}
if(dojo.lang.isFunction(obj)&&(!unary_func)){
@@ -59,15 +60,27 @@
}
}
if(isString) {
- return outArr.join("");
+ return outArr.join(""); // String
} else {
- return outArr;
+ return outArr; // Array
}
}
+dojo.lang.reduce = function(/*Array*/arr, initialValue, /*Object|null*/obj, /*Function*/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)){
+dojo.lang.forEach = function(/*Array*/anArray, /*Function*/callback, /*Object?*/thisObject){
+ if(dojo.lang.isString(anArray)){
+ // anArray: String
anArray = anArray.split("");
}
if(Array.forEach){
@@ -83,90 +96,91 @@
}
}
-dojo.lang._everyOrSome = function(every, arr, callback, thisObject){
+dojo.lang._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);
+ 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;
+ if(every && !result){
+ return false; // Boolean
}else if((!every)&&(result)){
- return true;
+ return true; // Boolean
}
}
- return (every) ? true : false;
+ return Boolean(every); // Boolean
}
}
-dojo.lang.every = function(arr, callback, thisObject){
- return this._everyOrSome(true, arr, callback, thisObject);
+dojo.lang.every = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
+ return this._everyOrSome(true, arr, callback, thisObject); // Boolean
}
-dojo.lang.some = function(arr, callback, thisObject){
- return this._everyOrSome(false, arr, callback, thisObject);
+dojo.lang.some = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
+ return this._everyOrSome(false, arr, callback, thisObject); // Boolean
}
-dojo.lang.filter = function(arr, callback, thisObject) {
+dojo.lang.filter = function(/*Array*/arr, /*Function*/callback, /*Object?*/thisObject){
var isString = dojo.lang.isString(arr);
- if(isString) { arr = arr.split(""); }
- if(Array.filter) {
- var outArr = Array.filter(arr, callback, thisObject);
+ 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!"); }
+ 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 = [];
+ 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("");
+ if(isString){
+ return outArr.join(""); // String
} else {
- return outArr;
+ return outArr; // Array
}
}
-/**
- * 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(/* ... */) {
+dojo.lang.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])) {
+ 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 {
+ }else{
out.push(arguments[i]);
}
}
- return out;
+ return out; // Array
}
-/**
- * Converts an array-like object (i.e. arguments, DOMCollection)
- * to an array
-**/
-dojo.lang.toArray = function(arrayLike, startOffset) {
+dojo.lang.toArray = function(/*Object*/arrayLike, /*Number*/startOffset){
+ // summary:
+ // Converts an array-like object (i.e. arguments, DOMCollection)
+ // to an array
var array = [];
- for(var i = startOffset||0; i < arrayLike.length; i++) {
+ for(var i = startOffset||0; i < arrayLike.length; i++){
array.push(arrayLike[i]);
}
- return array;
+ return array; // Array
}
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/assert.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/assert.js Fri Nov 10 01:15:01 2006
@@ -14,22 +14,18 @@
dojo.require("dojo.lang.array");
dojo.require("dojo.lang.type");
-// -------------------------------------------------------------------
-// Assertion methods
-// -------------------------------------------------------------------
+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 an exception if the assertion fails.
- *
- * If the asserted condition is true, this method does nothing. If the
- * condition is false, we throw an error with a error message.
- *
- * @param booleanValue A boolean value, which needs to be true for the assertion to succeed.
- * @param message Optional. A string describing the assertion.
- * @throws Throws an Error if 'booleanValue' is false.
- */
-dojo.lang.assert = function(booleanValue, message){
- if(!booleanValue){
+ // 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){
@@ -41,63 +37,62 @@
}
}
-/**
- * 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.
- *
- * Examples:
- * <pre>
- * 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);
- * </pre>
- *
- * @scope public function
- * @param value Any literal value or object instance.
- * @param type A class of object, or a literal type, or the string name of a type, or an array with a list of types.
- * @param message Optional. A string describing the assertion.
- * @throws Throws an Error if 'value' is not of type 'type'.
- */
-dojo.lang.assertType = function(value, type, message){
- if(!dojo.lang.isOfType(value, type)){
- if(!message){
- if(!dojo.lang.assertType._errorMessage){
- dojo.lang.assertType._errorMessage = "Type mismatch: dojo.lang.assertType() failed.";
- }
- message = dojo.lang.assertType._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, message);
+ dojo.lang.assert(false, dojo.lang.assertType._errorMessage);
}
}
-/**
- * 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.
- *
- * Examples:
- * <pre>
- * 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});
- * </pre>
- *
- * @scope public function
- * @param object An anonymous object.
- * @param expectedProperties An array of strings (or an object with all the expected properties).
- * @param message Optional. A string describing the assertion.
- * @throws Throws an Error if 'value' is not of type 'type'.
- */
-dojo.lang.assertValidKeywords = function(object, expectedProperties, message){
+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){
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/common.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/common.js Fri Nov 10 01:15:01 2006
@@ -9,100 +9,124 @@
*/
dojo.provide("dojo.lang.common");
-dojo.require("dojo.lang");
-/*
- * Adds the given properties/methods to the specified object
- */
-dojo.lang._mixin = function(obj, props){
+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;
+ // 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.
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]) {
+ 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 && dojo.lang.isFunction(props["toString"]) && props["toString"] != obj["toString"]) {
+ if(dojo.render.html.ie
+ && (typeof(props["toString"]) == "function")
+ && (props["toString"] != obj["toString"])
+ && (props["toString"] != tobj["toString"]))
+ {
obj.toString = props.toString;
}
- return obj;
+ return obj; // Object
}
-/*
- * Adds the properties/methods of argument Objects to obj
- */
-dojo.lang.mixin = function(obj, props /*, props, ..., props */){
+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;
+ return obj; // Object
}
-/*
- * Adds the properties/methods of argument Objects to ctor's prototype
- */
-dojo.lang.extend = function(ctor /*function*/, props /*, props, ..., props */){
+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(ctor.prototype, arguments[i]);
+ dojo.lang._mixin(constructor.prototype, arguments[i]);
}
- return ctor;
+ return constructor; // Object
}
-/**
- * See if val is in arr. Call signatures:
- * find(array, value, identity) // recommended
- * find(value, array, identity)
-**/
-dojo.lang.find = function( /*Array*/ arr,
- /*Object*/ val,
- /*boolean*/ identity,
- /*boolean*/ findLast){
- // support both (arr, val) and (val, arr)
- if(!dojo.lang.isArrayLike(arr) && dojo.lang.isArrayLike(val)) {
- var a = arr;
- arr = val;
- val = a;
+// 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.
+ // 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(arr);
- if(isString) { arr = arr.split(""); }
+ var isString = dojo.lang.isString(array);
+ if(isString) { array = array.split(""); }
if(findLast) {
var step = -1;
- var i = arr.length - 1;
+ var i = array.length - 1;
var end = -1;
} else {
var step = 1;
var i = 0;
- var end = arr.length;
+ var end = array.length;
}
if(identity){
while(i != end) {
- if(arr[i] === val){ return i; }
+ if(array[i] === value){ return i; }
i += step;
}
}else{
while(i != end) {
- if(arr[i] == val){ return i; }
+ if(array[i] == value){ return i; }
i += step;
}
}
- return -1;
+ return -1; // number
}
dojo.lang.indexOf = dojo.lang.find;
-dojo.lang.findLast = function(/*Array*/ arr, /*Object*/ val, /*boolean*/ identity){
- return dojo.lang.find(arr, val, identity, true);
+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.
+ // 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(arr /*Array*/, val /*Object*/){
- return dojo.lang.find(arr, val) > -1; // return: boolean
+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
}
/**
@@ -115,40 +139,51 @@
* The following is* functions are fairly "safe"
*/
-dojo.lang.isObject = function(wh){
- if(typeof wh == "undefined"){ return false; }
- return (typeof wh == "object" || wh === null || dojo.lang.isArray(wh) || dojo.lang.isFunction(wh));
+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(wh){
- return (wh instanceof Array || typeof wh == "array");
+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(wh){
- if(dojo.lang.isString(wh)){ return false; }
- if(dojo.lang.isFunction(wh)){ return false; } // keeps out built-in ctors (Number, String, ...) which have length properties
- if(dojo.lang.isArray(wh)){ return true; }
- if(typeof wh != "undefined" && wh
- && dojo.lang.isNumber(wh.length) && isFinite(wh.length)){ return true; }
- return false;
+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(wh){
- if(!wh){ return false; }
- return (wh instanceof Function || typeof wh == "function");
+dojo.lang.isFunction = function(/*anything*/ 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"); // Boolean
}
-dojo.lang.isString = function(wh){
- return (wh instanceof String || typeof wh == "string");
+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(wh){
- if(!wh){ return false; }
- return !dojo.lang.isFunction() && /\{\s*\[native code\]\s*\}/.test(String(wh));
+dojo.lang.isAlien = function(/*anything*/ 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)); // Boolean
}
-dojo.lang.isBoolean = function(wh){
- return (wh instanceof Boolean || typeof wh == "boolean");
+dojo.lang.isBoolean = function(/*anything*/ it){
+ // summary: Return true if it is a Boolean.
+ return (it instanceof Boolean || typeof it == "boolean"); // Boolean
}
/**
@@ -156,35 +191,40 @@
* there are workarounds the the language provides and are mentioned
* in the WARNING messages.
*
- * WARNING: In most cases, isNaN(wh) 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 (arr["1"] is the same as
- * arr[1]) and isNaN will return false for both values ("1" and 1). Should you
- * use isNumber("1"), that 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(wh) when possible
*/
-dojo.lang.isNumber = function(wh){
- return (wh instanceof Number || typeof wh == "number");
+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
}
-/**
- * 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
- *
+/*
* FIXME: Should isUndefined go away since it is error prone?
*/
-dojo.lang.isUndefined = function(wh){
- return ((wh == undefined)&&(typeof wh == "undefined"));
+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
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/declare.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/declare.js Fri Nov 10 01:15:01 2006
@@ -13,10 +13,22 @@
dojo.require("dojo.lang.common");
dojo.require("dojo.lang.extras");
+dojo.lang.declare = function(/*String*/ className, /*Function|Array*/ superclass, /*Function?*/ init, /*Object|Array*/ props){
/*
- * Creates a constructor: inherit and extend
+ * summary: Create a feature-rich constructor with a compact notation
*
- * - inherits from "superclass(es)"
+ * 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.
@@ -32,52 +44,46 @@
* properties are copied to the subclass, and any
* inializater/constructor is invoked.
*
- * - "props" are copied to the constructor prototype
+ * 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
+ * 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>]);
+ * Initializer functions are called when an object
+ * is instantiated from this constructor.
*
- * - 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() {
+ * dojo.declare("my.classes.bar", my.classes.foo,
+ * function() {
+ * // initialization function
* this.myComplicatedObject = new ReallyComplicatedObject();
- * },
+ * },{
* someValue: 2,
- * aMethod: function() { doStuff(); }
+ * someMethod: 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)))){
+ 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)) {
+ 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 };
+ if((init)&&(!dojo.lang.isFunction(init))){ init = null };
}
var ctor = dojo.lang.declare._makeConstructor();
var scp = (superclass ? superclass.prototype : null);
@@ -98,10 +104,11 @@
}else{
dojo.lang.extend(ctor, (props)||{});
}
- dojo.lang.extend(ctor, dojo.lang.declare.base);
+ dojo.lang.extend(ctor, dojo.lang.declare._common);
ctor.prototype.constructor = ctor;
- ctor.prototype.initializer=(ctor.prototype.initializer)||(init)||(function(){});
+ ctor.prototype.initializer = (ctor.prototype.initializer)||(init)||(function(){});
dojo.lang.setObjPathValue(className, ctor, null, true);
+ return ctor; // Function
}
dojo.lang.declare._makeConstructor = function() {
@@ -112,14 +119,14 @@
if((s)&&(s.constructor)){
if(s.constructor==arguments.callee){
// if this constructor is invoked directly (my.ancestor.call(this))
- this.inherited("constructor", arguments);
+ this._inherited("constructor", arguments);
}else{
- this._inherited(s, "constructor", arguments);
+ this._contextMethod(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);
+ 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);
@@ -127,29 +134,27 @@
}
}
-dojo.lang.declare.base = {
+dojo.lang.declare._common = {
_getPropContext: function() { return (this.___proto||this); },
// caches ptype context and calls method on it
- _inherited: function(ptype, method, args){
- var stack = this.___proto;
+ _contextMethod: function(ptype, method, args){
+ var result, stack = this.___proto;
this.___proto = ptype;
- var result = ptype[method].apply(this,(args||[]));
- this.___proto = stack;
+ try { result = ptype[method].apply(this,(args||[])); }
+ catch(e) { throw e; }
+ finally { this.___proto = stack; }
return result;
},
- // invokes ctor.prototype.method, 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){
+ _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._inherited(p, prop, args) : p[prop]);
+ return (dojo.lang.isFunction(p[prop]) ? this._contextMethod(p, prop, args) : p[prop]);
}
}
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/extras.js Fri Nov 10 01:15:01 2006
@@ -12,14 +12,15 @@
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){
+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:
+ // setTimeout (Object context, function func, number delay[, arg1[, ...]]);
+ // setTimeout (function func, number delay[, arg1[, ...]]);
+
var context = window, argsStart = 2;
if(!dojo.lang.isFunction(func)){
context = func;
@@ -33,70 +34,91 @@
}
var args = [];
- for (var i = argsStart; i < arguments.length; i++) {
+ for (var i = argsStart; i < arguments.length; i++){
args.push(arguments[i]);
}
- return setTimeout(function () { func.apply(context, args); }, delay);
+ 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
+ dojo.global().clearTimeout(timer);
}
-dojo.lang.getNameInObj = function(ns, item){
+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 match
if(!ns){ ns = dj_global; }
for(var x in ns){
if(ns[x] === item){
- return new String(x);
+ return new String(x); // String
}
}
- return null;
+ return null; // null
}
-dojo.lang.shallowCopy = function(obj) {
- var ret = {}, key;
- for(key in obj) {
- if(dojo.lang.isUndefined(ret[key])) {
- ret[key] = obj[key];
+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: unknown
+ ret = obj;
}
- return ret;
+
+ return ret; // unknown
}
-/**
- * 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];
+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]; // unknown
}
}
- return undefined;
+ return undefined; // 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){
+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);
+ return dojo.evalProp(prop, obj, create); // unknown
}
}
-/**
- * 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){
+dojo.lang.setObjPathValue = function(/*String*/objpath, /*unknown*/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.
+ //
+ // context: if not specified, dj_global is used
+ // create: if true, undefined objects in the path are created.
+
if(arguments.length < 4){
create = true;
}
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/func.js Fri Nov 10 01:15:01 2006
@@ -19,16 +19,12 @@
* hitch(foo, "bar"); // runs foo.bar() in the scope of foo
* hitch(foo, myFunction); // runs myFunction in the scope of foo
*/
-dojo.lang.hitch = function(thisObject, method) {
- if(dojo.lang.isString(method)) {
- var fcn = thisObject[method];
- } else {
- var fcn = method;
- }
+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;
@@ -38,9 +34,11 @@
if( (searchForNames) ||
((dj_global["djConfig"])&&(djConfig["slowAnonFuncLookups"] == true)) ){
for(var x in nso){
- if(nso[x] === anonFuncPtr){
- return x;
- }
+ 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++;
@@ -93,7 +91,7 @@
// with enough args
totalArgs, // a copy
expected); // how many more do we need to run?;
- }
+ };
}
}
return gather([], outerArgs, ecount);
Modified: 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=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lang/repr.js Fri Nov 10 01:15:01 2006
@@ -15,26 +15,28 @@
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
- ***/
+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"){
- return "undefined";
+ // obj: undefined
+ return "undefined"; // String
}else if(obj === null){
- return "null";
+ // obj: null
+ return "null"; // String
}
try{
@@ -49,35 +51,28 @@
obj.toString == Function.prototype.toString ||
obj.toString == Object.prototype.toString
)){
- return o.NAME;
+ 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 + "";
+ return obj + ""; // String
}
-dojo.lang.reprArrayLike = function(arr){
+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(", ") + "]";
+ return "[" + na.join(", ") + "]"; // String
}catch(e){ }
-};
-
-dojo.lang.reprString = function(str){
- dojo.deprecated("dojo.lang.reprNumber", "use `String(num)` instead", "0.4");
- return dojo.string.escapeString(str);
-};
-
-dojo.lang.reprNumber = function(num){
- dojo.deprecated("dojo.lang.reprNumber", "use `String(num)` instead", "0.4");
- return num + "";
};
(function(){