You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/01/27 00:58:20 UTC
svn commit: r372668 [8/16] - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/alg/ src/animation/ src/collections/ src/crypto/ src/data/
src/dnd/ src/event/ src/flash/ src/flash/flash6/ src...
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,14 @@
+/*
+ Copyright (c) 2004-2005, 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.hostenv.conditionalLoadModule({
+ common: ["dojo.reflect.reflection"]
+});
+dojo.hostenv.moduleLoaded("dojo.reflect.*");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/reflection.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/reflection.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/reflection.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/reflect/reflection.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,197 @@
+/*
+ Copyright (c) 2004-2005, 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.reflect");
+
+/*****************************************************************
+ reflect.js
+ v.1.5.0
+ (c) 2003-2004 Thomas R. Trenka, Ph.D.
+
+ Derived from the reflection functions of f(m).
+ http://dojotoolkit.org
+ http://fm.dept-z.com
+
+ There is a dependency on the variable dJ_global, which
+ should always refer to the global object.
+******************************************************************/
+if(!dj_global){ var dj_global = this; }
+
+dojo.reflect = {} ;
+dojo.reflect.$unknownType = function(){ } ;
+dojo.reflect.ParameterInfo = function(name, type){
+ this.name = name ;
+ this.type = (type) ? type : dojo.reflect.$unknownType ;
+} ;
+dojo.reflect.PropertyInfo = function(name, type) {
+ this.name = name ;
+ this.type = (type) ? type : dojo.reflect.$unknownType ;
+} ;
+dojo.reflect.MethodInfo = function(name, fn){
+ var parse = function(f) {
+ var o = {} ;
+ var s = f.toString() ;
+ var param = ((s.substring(s.indexOf('(')+1, s.indexOf(')'))).replace(/\s+/g, "")).split(",") ;
+ o.parameters = [] ;
+ for (var i = 0; i < param.length; i++) {
+ o.parameters.push(new dojo.reflect.ParameterInfo(param[i])) ;
+ }
+ o.body = (s.substring(s.indexOf('{')+1, s.lastIndexOf('}'))).replace(/(^\s*)|(\s*$)/g, "") ;
+ return o ;
+ } ;
+
+ var tmp = parse(fn) ;
+ var p = tmp.parameters ;
+ var body = tmp.body ;
+
+ this.name = (name) ? name : "anonymous" ;
+ this.getParameters = function(){ return p ; } ;
+ this.getNullArgumentsObject = function() {
+ var a = [] ;
+ for (var i = 0; i < p.length; i++){
+ a.push(null);
+ }
+ return a ;
+ } ;
+ this.getBody = function() { return body ; } ;
+ this.type = Function ;
+ this.invoke = function(src, args){ return fn.apply(src, args) ; } ;
+} ;
+
+// Static object that can activate instances of the passed type.
+dojo.reflect.Activator = new (function(){
+ this.createInstance = function(type, args) {
+ switch (typeof(type)) {
+ case "function" : {
+ var o = {} ;
+ type.apply(o, args) ;
+ return o ;
+ } ;
+ case "string" : {
+ var o = {} ;
+ (dojo.reflect.Reflector.getTypeFromString(type)).apply(o, args) ;
+ return o ;
+ } ;
+ }
+ throw new Error("dojo.reflect.Activator.createInstance(): no such type exists.");
+ }
+})() ;
+
+dojo.reflect.Reflector = new (function(){
+ this.getTypeFromString = function(s) {
+ var parts = s.split("."), i = 0, obj = dj_global ;
+ do { obj = obj[parts[i++]] ; } while (i < parts.length && obj) ;
+ return (obj != dj_global) ? obj : null ;
+ };
+
+ this.typeExists = function(s) {
+ var parts = s.split("."), i = 0, obj = dj_global ;
+ do { obj = obj[parts[i++]] ; } while (i < parts.length && obj) ;
+ return (obj && obj != dj_global) ;
+ };
+
+ this.getFieldsFromType = function(s) {
+ var type = s ;
+ if (typeof(s) == "string") {
+ type = this.getTypeFromString(s) ;
+ }
+ var nullArgs = (new dojo.reflect.MethodInfo(type)).getNullArgumentsObject() ;
+ return this.getFields(dojo.reflect.Activator.createInstance(s, nullArgs)) ;
+ };
+
+ this.getPropertiesFromType = function(s) {
+ var type = s ;
+ if (typeof(s) == "string") {
+ type = this.getTypeFromString(s);
+ }
+ var nullArgs = (new dojo.reflect.MethodInfo(type)).getNullArgumentsObject() ;
+ return this.getProperties(dojo.reflect.Activator.createInstance(s, nullArgs)) ;
+ };
+
+ this.getMethodsFromType = function(s) {
+ var type = s ;
+ if (typeof(s) == "string") {
+ type = this.getTypeFromString(s) ;
+ }
+ var nullArgs = (new dojo.reflect.MethodInfo(type)).getNullArgumentsObject() ;
+ return this.getMethods(dojo.reflect.Activator.createInstance(s, nullArgs)) ;
+ };
+
+ this.getType = function(o) { return o.constructor ; } ;
+
+ this.getFields = function(obj) {
+ var arr = [] ;
+ for (var p in obj) {
+ if(this.getType(obj[p]) != Function){
+ arr.push(new dojo.reflect.PropertyInfo(p, this.getType(obj[p]))) ;
+ }else{
+ arr.push(new dojo.reflect.MethodInfo(p, obj[p]));
+ }
+ }
+ return arr ;
+ };
+
+ this.getProperties = function(obj) {
+ var arr = [] ;
+ var fi = this.getFields(obj) ;
+ for (var i = 0; i < fi.length; i++){
+ if (this.isInstanceOf(fi[i], dojo.reflect.PropertyInfo)){
+ arr.push(fi[i]) ;
+ }
+ }
+ return arr ;
+ };
+
+ this.getMethods = function(obj) {
+ var arr = [] ;
+ var fi = this.getFields(obj) ;
+ for (var i = 0; i < fi.length; i++){
+ if (this.isInstanceOf(fi[i], dojo.reflect.MethodInfo)){
+ arr.push(fi[i]) ;
+ }
+ }
+ return arr ;
+ };
+
+ /*
+ this.implements = function(o, type) {
+ if (this.isSubTypeOf(o, type)) return false ;
+ var f = this.getFieldsFromType(type) ;
+ for (var i = 0; i < f.length; i++) {
+ if (typeof(o[(f[i].name)]) == "undefined"){
+ return false;
+ }
+ }
+ return true ;
+ };
+ */
+
+ this.getBaseClass = function(o) {
+ if (o.getType().prototype.prototype.constructor){
+ return (o.getType()).prototype.prototype.constructor ;
+ }
+ return Object ;
+ } ;
+
+ this.isInstanceOf = function(o, type) {
+ return (this.getType(o) == type) ;
+ };
+
+ this.isSubTypeOf = function(o, type) {
+ return (o instanceof type) ;
+ };
+
+ this.isBaseTypeOf = function(o, type) {
+ return (type instanceof o);
+ };
+})();
+
+// back-compat
+dojo.provide("dojo.reflect.reflection");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/regexp.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/regexp.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/regexp.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/regexp.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,566 @@
+/*
+ Copyright (c) 2004-2005, 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.regexp");
+dojo.provide("dojo.regexp.us");
+
+// *** Regular Expression Generators ***
+
+/**
+ Builds a RE that matches a top-level domain.
+
+ @param flags An object.
+ flags.allowCC Include 2 letter country code domains. Default is true.
+ flags.allowGeneric Include the generic domains. Default is true.
+ flags.allowInfra Include infrastructure domains. Default is true.
+
+ @return A string for a regular expression for a top-level domain.
+*/
+dojo.regexp.tld = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.allowCC != "boolean") { flags.allowCC = true; }
+ if (typeof flags.allowInfra != "boolean") { flags.allowInfra = true; }
+ if (typeof flags.allowGeneric != "boolean") { flags.allowGeneric = true; }
+
+ // Infrastructure top-level domain - only one at present
+ var infraRE = "arpa";
+
+ // Generic top-level domains RE.
+ var genericRE =
+ "aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|xxx|jobs|mobi|post";
+
+ // Country Code top-level domains RE
+ var ccRE =
+ "ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|" +
+ "bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|" +
+ "ec|ee|eg|er|es|et|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|" +
+ "hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la|" +
+ "lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|" +
+ "mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|" +
+ "ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sk|sl|sm|sn|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|" +
+ "to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw";
+
+ // Build top-level domain RE
+ var a = [];
+ if (flags.allowInfra) { a.push(infraRE); }
+ if (flags.allowGeneric) { a.push(genericRE); }
+ if (flags.allowCC) { a.push(ccRE); }
+
+ var tldRE = "";
+ if (a.length > 0) {
+ tldRE = "(" + a.join("|") + ")";
+ }
+
+ return tldRE;
+}
+
+/**
+ Builds a RE that matches an IP Address.
+ Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal.
+ Supports 2 formats for Ipv6.
+
+ @param flags An object. All flags are boolean with default = true.
+ flags.allowDottedDecimal Example, 207.142.131.235. No zero padding.
+ flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed.
+ flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed.
+ flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295.
+ flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF.
+ Case insensitive. Zero padding allowed.
+ flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits.
+ flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits
+ followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d
+
+ @return A string for a regular expression for an IP address.
+*/
+dojo.regexp.ipAddress = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.allowDottedDecimal != "boolean") { flags.allowDottedDecimal = true; }
+ if (typeof flags.allowDottedHex != "boolean") { flags.allowDottedHex = true; }
+ if (typeof flags.allowDottedOctal != "boolean") { flags.allowDottedOctal = true; }
+ if (typeof flags.allowDecimal != "boolean") { flags.allowDecimal = true; }
+ if (typeof flags.allowHex != "boolean") { flags.allowHex = true; }
+ if (typeof flags.allowIPv6 != "boolean") { flags.allowIPv6 = true; }
+ if (typeof flags.allowHybrid != "boolean") { flags.allowHybrid = true; }
+
+ // decimal-dotted IP address RE.
+ var dottedDecimalRE =
+ // Each number is between 0-255. Zero padding is not allowed.
+ "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
+
+ // dotted hex IP address RE. Each number is between 0x0-0xff. Zero padding is allowed, e.g. 0x00.
+ var dottedHexRE = "(0[xX]0*[\\da-fA-F]?[\\da-fA-F]\\.){3}0[xX]0*[\\da-fA-F]?[\\da-fA-F]";
+
+ // dotted octal IP address RE. Each number is between 0000-0377.
+ // Zero padding is allowed, but each number must have at least 4 characters.
+ var dottedOctalRE = "(0+[0-3][0-7][0-7]\\.){3}0+[0-3][0-7][0-7]";
+
+ // decimal IP address RE. A decimal number between 0-4294967295.
+ var decimalRE = "(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|" +
+ "4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])";
+
+ // hexadecimal IP address RE.
+ // A hexadecimal number between 0x0-0xFFFFFFFF. Case insensitive. Zero padding is allowed.
+ var hexRE = "0[xX]0*[\\da-fA-F]{1,8}";
+
+ // IPv6 address RE.
+ // The format is written as eight groups of four hexadecimal digits, x:x:x:x:x:x:x:x,
+ // where x is between 0000-ffff. Zero padding is optional. Case insensitive.
+ var ipv6RE = "([\\da-fA-F]{1,4}\\:){7}[\\da-fA-F]{1,4}";
+
+ // IPv6/IPv4 Hybrid address RE.
+ // The format is written as six groups of four hexadecimal digits,
+ // followed by the 4 dotted decimal IPv4 format. x:x:x:x:x:x:d.d.d.d
+ var hybridRE = "([\\da-fA-F]{1,4}\\:){6}" +
+ "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
+
+ // Build IP Address RE
+ var a = [];
+ if (flags.allowDottedDecimal) { a.push(dottedDecimalRE); }
+ if (flags.allowDottedHex) { a.push(dottedHexRE); }
+ if (flags.allowDottedOctal) { a.push(dottedOctalRE); }
+ if (flags.allowDecimal) { a.push(decimalRE); }
+ if (flags.allowHex) { a.push(hexRE); }
+ if (flags.allowIPv6) { a.push(ipv6RE); }
+ if (flags.allowHybrid) { a.push(hybridRE); }
+
+ var ipAddressRE = "";
+ if (a.length > 0) {
+ ipAddressRE = "(" + a.join("|") + ")";
+ }
+
+ return ipAddressRE;
+}
+
+/**
+ Builds a RE that matches a host.
+ A host is a domain name or an IP address, possibly followed by a port number.
+
+ @param flags An object.
+ flags.allowIP Allow an IP address for hostname. Default is true.
+ flags.allowLocal Allow the host to be "localhost". Default is false.
+ flags.allowPort Allow a port number to be present. Default is true.
+ flags in regexp.ipAddress can be applied.
+ flags in regexp.tld can be applied.
+
+ @return A string for a regular expression for a host.
+*/
+dojo.regexp.host = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.allowIP != "boolean") { flags.allowIP = true; }
+ if (typeof flags.allowLocal != "boolean") { flags.allowLocal = false; }
+ if (typeof flags.allowPort != "boolean") { flags.allowPort = true; }
+
+ // Domain names can not end with a dash.
+ var domainNameRE = "([0-9a-zA-Z]([-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?\\.)+" + dojo.regexp.tld(flags);
+
+ // port number RE
+ portRE = ( flags.allowPort ) ? "(\\:" + dojo.regexp.integer({signed: false}) + ")?" : "";
+
+ // build host RE
+ var hostNameRE = domainNameRE;
+ if (flags.allowIP) { hostNameRE += "|" + dojo.regexp.ipAddress(flags); }
+ if (flags.allowLocal) { hostNameRE += "|localhost"; }
+
+ return "(" + hostNameRE + ")" + portRE;
+}
+
+/**
+ Builds a regular expression that matches a URL.
+
+ @param flags An object.
+ flags.scheme Can be true, false, or [true, false].
+ This means: required, not allowed, or match either one.
+ flags in regexp.host can be applied.
+ flags in regexp.ipAddress can be applied.
+ flags in regexp.tld can be applied.
+
+ @return A string for a regular expression for a URL.
+*/
+dojo.regexp.url = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.scheme == "undefined") { flags.scheme = [true, false]; }
+
+ // Scheme RE
+ var protocalRE = dojo.regexp.buildGroupRE(flags.scheme,
+ function(q) { if (q) { return "(https?|ftps?)\\://"; } return ""; }
+ );
+
+ // Path and query and anchor RE
+ var pathRE = "(/([^?#\\s/]+/)*)?([^?#\\s/]+(\\?[^?#\\s/]*)?(#[A-Za-z][\\w.:-]*)?)?";
+
+ return (protocalRE + dojo.regexp.host(flags) + pathRE);
+}
+
+/**
+ Builds a regular expression that matches an email address.
+
+ @param flags An object.
+ flags.allowCruft Allow address like <ma...@yahoo.com>. Default is false.
+ flags in regexp.host can be applied.
+ flags in regexp.ipAddress can be applied.
+ flags in regexp.tld can be applied.
+
+ @return A string for a regular expression for an email address.
+*/
+dojo.regexp.emailAddress = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.allowCruft != "boolean") { flags.allowCruft = false; }
+ flags.allowPort = false; // invalid in email addresses
+
+ // user name RE - apostrophes are valid if there's not 2 in a row
+ var usernameRE = "([\\da-z]+[-._+&'])*[\\da-z]+";
+
+ // build emailAddress RE
+ var emailAddressRE = usernameRE + "@" + dojo.regexp.host(flags);
+
+ // Allow email addresses with cruft
+ if ( flags.allowCruft ) {
+ emailAddressRE = "<?(mailto\\:)?" + emailAddressRE + ">?";
+ }
+
+ return emailAddressRE;
+}
+
+/**
+ Builds a regular expression that matches a list of email addresses.
+
+ @param flags An object.
+ flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ".
+ flags in regexp.emailAddress can be applied.
+ flags in regexp.host can be applied.
+ flags in regexp.ipAddress can be applied.
+ flags in regexp.tld can be applied.
+
+ @return A string for a regular expression for an email address list.
+*/
+dojo.regexp.emailAddressList = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.listSeparator != "string") { flags.listSeparator = "\\s;,"; }
+
+ // build a RE for an Email Address List
+ var emailAddressRE = dojo.regexp.emailAddress(flags);
+ var emailAddressListRE = "(" + emailAddressRE + "\\s*[" + flags.listSeparator + "]\\s*)*" +
+ emailAddressRE + "\\s*[" + flags.listSeparator + "]?\\s*";
+
+ return emailAddressListRE;
+}
+
+/**
+ Builds a regular expression that matches an integer.
+
+ @param flags An object.
+ flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false].
+ Default is [true, false], (i.e. will match if it is signed or unsigned).
+ flags.separator The character used as the thousands separator. Default is no separator.
+ For more than one symbol use an array, e.g. [",", ""], makes ',' optional.
+
+ @return A string for a regular expression for an integer.
+*/
+dojo.regexp.integer = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.signed == "undefined") { flags.signed = [true, false]; }
+ if (typeof flags.separator == "undefined") { flags.separator = ""; }
+
+ // build sign RE
+ var signRE = dojo.regexp.buildGroupRE(flags.signed,
+ function(q) { if (q) { return "[-+]"; } return ""; }
+ );
+
+ // number RE
+ var numberRE = dojo.regexp.buildGroupRE(flags.separator,
+ function(sep) {
+ if ( sep == "" ) {
+ return "(0|[1-9]\\d*)";
+ }
+ return "(0|[1-9]\\d{0,2}([" + sep + "]\\d{3})*)";
+ }
+ );
+ var numberRE;
+
+ // integer RE
+ return (signRE + numberRE);
+}
+
+/**
+ Builds a regular expression to match a real number in exponential notation.
+
+ @param flags An object.
+ flags.places The integer number of decimal places.
+ If not given, the decimal part is optional and the number of places is unlimited.
+ flags.decimal A string for the character used as the decimal point. Default is ".".
+ flags.exponent Express in exponential notation. Can be true, false, or [true, false].
+ Default is [true, false], (i.e. will match if the exponential part is present are not).
+ flags.eSigned The leading plus-or-minus sign on the exponent. Can be true, false,
+ or [true, false]. Default is [true, false], (i.e. will match if it is signed or unsigned).
+ flags in regexp.integer can be applied.
+
+ @return A string for a regular expression for a real number.
+*/
+dojo.regexp.realNumber = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.places != "number") { flags.places = Infinity; }
+ if (typeof flags.decimal != "string") { flags.decimal = "."; }
+ if (typeof flags.exponent == "undefined") { flags.exponent = [true, false]; }
+ if (typeof flags.eSigned == "undefined") { flags.eSigned = [true, false]; }
+
+ // integer RE
+ var integerRE = dojo.regexp.integer(flags);
+
+ // decimal RE
+ var decimalRE = "";
+ if ( flags.places == Infinity) {
+ decimalRE = "(\\" + flags.decimal + "\\d+)?";
+ }
+ else if ( flags.places > 0) {
+ decimalRE = "\\" + flags.decimal + "\\d{" + flags.places + "}";
+ }
+
+ // exponent RE
+ var exponentRE = dojo.regexp.buildGroupRE(flags.exponent,
+ function(q) {
+ if (q) { return "([eE]" + dojo.regexp.integer({signed: flags.eSigned}) + ")"; }
+ return "";
+ }
+ );
+
+ // real number RE
+ return (integerRE + decimalRE + exponentRE);
+}
+
+/**
+ Builds a regular expression to match a monetary value.
+
+ @param flags An object.
+ flags.signed The leading plus-or-minus sign. Can be true, false, or [true, false].
+ Default is [true, false], (i.e. will match if it is signed or unsigned).
+ flags.symbol A currency symbol such as Yen "�", Pound "�", or the Euro sign "�".
+ Default is "$". For more than one symbol use an array, e.g. ["$", ""], makes $ optional.
+ flags.placement The symbol can come "before" the number or "after". Default is "before".
+ flags.separator The character used as the thousands separator. The default is ",".
+ flags.cents The two decimal places for cents. Can be true, false, or [true, false].
+ Default is [true, false], (i.e. will match if cents are present are not).
+ flags.decimal A string for the character used as the decimal point. Default is ".".
+
+ @return A string for a regular expression for a monetary value.
+*/
+dojo.regexp.currency = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.signed == "undefined") { flags.signed = [true, false]; }
+ if (typeof flags.symbol == "undefined") { flags.symbol = "$"; }
+ if (typeof flags.placement != "string") { flags.placement = "before"; }
+ if (typeof flags.separator != "string") { flags.separator = ","; }
+ if (typeof flags.cents == "undefined") { flags.cents = [true, false]; }
+ if (typeof flags.decimal != "string") { flags.decimal = "."; }
+
+ // build sign RE
+ var signRE = dojo.regexp.buildGroupRE(flags.signed,
+ function(q) { if (q) { return "[-+]"; } return ""; }
+ );
+
+ // build symbol RE
+ var symbolRE = dojo.regexp.buildGroupRE(flags.symbol,
+ function(symbol) {
+ // escape all special characters
+ return "\\s?" + symbol.replace( /([.$?*!=:|\\\/^])/g, "\\$1") + "\\s?";
+ }
+ );
+
+ // number RE
+ var numberRE = dojo.regexp.integer( {signed: false, separator: flags.separator} );
+
+ // build cents RE
+ var centsRE = dojo.regexp.buildGroupRE(flags.cents,
+ function(q) { if (q) { return "(\\" + flags.decimal + "\\d\\d)"; } return ""; }
+ );
+
+ // build currency RE
+ var currencyRE;
+ if (flags.placement == "before") {
+ currencyRE = signRE + symbolRE + numberRE + centsRE;
+ }
+ else {
+ currencyRE = signRE + numberRE + centsRE + symbolRE;
+ }
+
+ return currencyRE;
+}
+
+/**
+ A regular expression to match US state and territory abbreviations.
+
+ @param flags An object.
+ flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true.
+ flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true.
+
+ @return A string for a regular expression for a US state.
+*/
+dojo.regexp.us.state = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.allowTerritories != "boolean") { flags.allowTerritories = true; }
+ if (typeof flags.allowMilitary != "boolean") { flags.allowMilitary = true; }
+
+ // state RE
+ var statesRE =
+ "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|" +
+ "NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY";
+
+ // territories RE
+ var territoriesRE = "AS|FM|GU|MH|MP|PW|PR|VI";
+
+ // military states RE
+ var militaryRE = "AA|AE|AP";
+
+ // Build states and territories RE
+ if (flags.allowTerritories) { statesRE += "|" + territoriesRE; }
+ if (flags.allowMilitary) { statesRE += "|" + militaryRE; }
+
+ return "(" + statesRE + ")";
+}
+
+/**
+ Builds a regular expression to match any International format for time.
+ The RE can match one format or one of multiple formats.
+
+ Format
+ h 12 hour, no zero padding.
+ hh 12 hour, has leading zero.
+ H 24 hour, no zero padding.
+ HH 24 hour, has leading zero.
+ m minutes, no zero padding.
+ mm minutes, has leading zero.
+ s seconds, no zero padding.
+ ss seconds, has leading zero.
+ t am or pm, case insensitive.
+ All other characters must appear literally in the expression.
+
+ Example
+ "h:m:s t" -> 2:5:33 PM
+ "HH:mm:ss" -> 14:05:33
+
+ @param flags An object.
+ flags.format A string or an array of strings. Default is "h:mm:ss t".
+ flags.amSymbol The symbol used for AM. Default is "AM".
+ flags.pmSymbol The symbol used for PM. Default is "PM".
+
+ @return A string for a regular expression for a time value.
+*/
+dojo.regexp.time = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.format == "undefined") { flags.format = "h:mm:ss t"; }
+ if (typeof flags.amSymbol != "string") { flags.amSymbol = "AM"; }
+ if (typeof flags.pmSymbol != "string") { flags.pmSymbol = "PM"; }
+
+ // Converts a time format to a RE
+ var timeRE = function(format) {
+ // escape all special characters
+ format = format.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+ var amRE = flags.amSymbol.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+ var pmRE = flags.pmSymbol.replace( /([.$?*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+
+ // replace tokens with Regular Expressions
+ format = format.replace("hh", "(0[1-9]|1[0-2])");
+ format = format.replace("h", "([1-9]|1[0-2])");
+ format = format.replace("HH", "([01][0-9]|2[0-3])");
+ format = format.replace("H", "([0-9]|1[0-9]|2[0-3])");
+ format = format.replace("mm", "([0-5][0-9])");
+ format = format.replace("m", "([1-5][0-9]|[0-9])");
+ format = format.replace("ss", "([0-5][0-9])");
+ format = format.replace("s", "([1-5][0-9]|[0-9])");
+ format = format.replace("t", "\\s?(" + amRE + "|" + pmRE + ")\\s?" );
+
+ return format;
+ };
+
+ // build RE for multiple time formats
+ return dojo.regexp.buildGroupRE(flags.format, timeRE);
+}
+
+/**
+ Builds a regular expression to match any sort of number based format.
+ Use it for phone numbers, social security numbers, zip-codes, etc.
+ The RE can match one format or one of multiple formats.
+
+ Format
+ # Stands for a digit, 0-9.
+ ? Stands for an optional digit, 0-9 or nothing.
+ All other characters must appear literally in the expression.
+
+ Example
+ "(###) ###-####" -> (510) 542-9742
+ "(###) ###-#### x#???" -> (510) 542-9742 x153
+ "###-##-####" -> 506-82-1089 i.e. social security number
+ "#####-####" -> 98225-1649 i.e. zip code
+
+ @param flags An object.
+ flags.format A string or an Array of strings for multiple formats.
+ @return A string for a regular expression for the number format(s).
+*/
+dojo.regexp.numberFormat = function(flags) {
+ // assign default values to missing paramters
+ flags = (typeof flags == "object") ? flags : {};
+ if (typeof flags.format == "undefined") { flags.format = "###-###-####"; }
+
+ // Converts a number format to RE.
+ var digitRE = function(format) {
+ // escape all special characters, except '?'
+ format = format.replace( /([.$*!=:|{}\(\)\[\]\\\/^])/g, "\\$1");
+
+ // Now replace '?' with Regular Expression
+ format = format.replace(/\?/g, "\\d?");
+
+ // replace # with Regular Expression
+ format = format.replace(/#/g, "\\d");
+
+ return format;
+ };
+
+ // build RE for multiple number formats
+ return dojo.regexp.buildGroupRE(flags.format, digitRE);
+}
+
+
+/**
+ This is basically a utility function used by some of the RE generators.
+ Builds a regular expression that groups subexpressions.
+ The subexpressions are constructed by the function, re, in the second parameter.
+ re builds one subexpression for each elem in the array a, in the first parameter.
+
+ @param a A single value or an array of values.
+ @param re A function. Takes one parameter and converts it to a regular expression.
+ @return A string for a regular expression that groups all the subexpressions.
+*/
+dojo.regexp.buildGroupRE = function(a, re) {
+
+ // case 1: a is a single value.
+ if ( !( a instanceof Array ) ) {
+ return re(a);
+ }
+
+ // case 2: a is an array
+ var b = [];
+ for (var i = 0; i < a.length; i++) {
+ // convert each elem to a RE
+ b.push(re(a[i]));
+ }
+
+ // join the REs as alternatives in a RE group.
+ return "(" + b.join("|") + ")";
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/Deferred.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/Deferred.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/Deferred.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/Deferred.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,372 @@
+/*
+ Copyright (c) 2004-2005, 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.rpc.Deferred");
+dojo.require("dojo.lang");
+
+dojo.rpc.Deferred = function(/* optional */ canceller){
+ /*
+ NOTE: this namespace and documentation are imported wholesale
+ from MochiKit
+
+ Encapsulates a sequence of callbacks in response to a value that
+ may not yet be available. This is modeled after the Deferred class
+ from Twisted <http://twistedmatrix.com>.
+
+ Why do we want this? JavaScript has no threads, and even if it did,
+ threads are hard. Deferreds are a way of abstracting non-blocking
+ events, such as the final response to an XMLHttpRequest.
+
+ The sequence of callbacks is internally represented as a list
+ of 2-tuples containing the callback/errback pair. For example,
+ the following call sequence::
+
+ var d = new Deferred();
+ d.addCallback(myCallback);
+ d.addErrback(myErrback);
+ d.addBoth(myBoth);
+ d.addCallbacks(myCallback, myErrback);
+
+ is translated into a Deferred with the following internal
+ representation::
+
+ [
+ [myCallback, null],
+ [null, myErrback],
+ [myBoth, myBoth],
+ [myCallback, myErrback]
+ ]
+
+ The Deferred also keeps track of its current status (fired).
+ Its status may be one of three things:
+
+ -1: no value yet (initial condition)
+ 0: success
+ 1: error
+
+ A Deferred will be in the error state if one of the following
+ three conditions are met:
+
+ 1. The result given to callback or errback is "instanceof" Error
+ 2. The previous callback or errback raised an exception while
+ executing
+ 3. The previous callback or errback returned a value "instanceof"
+ Error
+
+ Otherwise, the Deferred will be in the success state. The state of
+ the Deferred determines the next element in the callback sequence to
+ run.
+
+ When a callback or errback occurs with the example deferred chain,
+ something equivalent to the following will happen (imagine that
+ exceptions are caught and returned)::
+
+ // d.callback(result) or d.errback(result)
+ if(!(result instanceof Error)){
+ result = myCallback(result);
+ }
+ if(result instanceof Error){
+ result = myErrback(result);
+ }
+ result = myBoth(result);
+ if(result instanceof Error){
+ result = myErrback(result);
+ }else{
+ result = myCallback(result);
+ }
+
+ The result is then stored away in case another step is added to the
+ callback sequence. Since the Deferred already has a value available,
+ any new callbacks added will be called immediately.
+
+ There are two other "advanced" details about this implementation that
+ are useful:
+
+ Callbacks are allowed to return Deferred instances themselves, so you
+ can build complicated sequences of events with ease.
+
+ The creator of the Deferred may specify a canceller. The canceller
+ is a function that will be called if Deferred.cancel is called before
+ the Deferred fires. You can use this to implement clean aborting of
+ an XMLHttpRequest, etc. Note that cancel will fire the deferred with
+ a CancelledError (unless your canceller returns another kind of
+ error), so the errbacks should be prepared to handle that error for
+ cancellable Deferreds.
+
+ */
+
+ this.chain = [];
+ this.id = this._nextId();
+ this.fired = -1;
+ this.paused = 0;
+ this.results = [null, null];
+ this.canceller = canceller;
+ this.silentlyCancelled = false;
+};
+
+dojo.lang.extend(dojo.rpc.Deferred, {
+ getFunctionFromArgs: function(){
+ var a = arguments;
+ if((a[0])&&(!a[1])){
+ if(dojo.lang.isFunction(a[0])){
+ return a[0];
+ }else if(dojo.lang.isString(a[0])){
+ return dj_global[a[0]];
+ }
+ }else if((a[0])&&(a[1])){
+ return dojo.lang.hitch(a[0], a[1]);
+ }
+ return null;
+ },
+
+ repr: function(){
+ var state;
+ if(this.fired == -1){
+ state = 'unfired';
+ }else if(this.fired == 0){
+ state = 'success';
+ } else {
+ state = 'error';
+ }
+ return 'Deferred(' + this.id + ', ' + state + ')';
+ },
+
+ toString: dojo.lang.forward("repr"),
+
+ _nextId: (function(){
+ var n = 1;
+ return function(){ return n++; };
+ })(),
+
+ cancel: function(){
+ /***
+ Cancels a Deferred that has not yet received a value, or is
+ waiting on another Deferred as its value.
+
+ If a canceller is defined, the canceller is called. If the
+ canceller did not return an error, or there was no canceller,
+ then the errback chain is started with CancelledError.
+ ***/
+ if(this.fired == -1){
+ if (this.canceller){
+ this.canceller(this);
+ }else{
+ this.silentlyCancelled = true;
+ }
+ if(this.fired == -1){
+ this.errback(new Error(this.repr()));
+ }
+ }else if( (this.fired == 0)&&
+ (this.results[0] instanceof dojo.rpc.Deferred)){
+ this.results[0].cancel();
+ }
+ },
+
+
+ _pause: function(){
+ // Used internally to signal that it's waiting on another Deferred
+ this.paused++;
+ },
+
+ _unpause: function(){
+ // Used internally to signal that it's no longer waiting on
+ // another Deferred.
+ this.paused--;
+ if ((this.paused == 0) && (this.fired >= 0)) {
+ this._fire();
+ }
+ },
+
+ _continue: function(res){
+ // Used internally when a dependent deferred fires.
+ this._resback(res);
+ this._unpause();
+ },
+
+ _resback: function(res){
+ // The primitive that means either callback or errback
+ this.fired = ((res instanceof Error) ? 1 : 0);
+ this.results[this.fired] = res;
+ this._fire();
+ },
+
+ _check: function(){
+ if(this.fired != -1){
+ if(!this.silentlyCancelled){
+ dojo.raise("already called!");
+ }
+ this.silentlyCancelled = false;
+ return;
+ }
+ },
+
+ callback: function(res){
+ /*
+ Begin the callback sequence with a non-error value.
+
+ callback or errback should only be called once on a given
+ Deferred.
+ */
+ this._check();
+ this._resback(res);
+ },
+
+ errback: function(res){
+ // Begin the callback sequence with an error result.
+ this._check();
+ if(!(res instanceof Error)){
+ res = new Error(res);
+ }
+ this._resback(res);
+ },
+
+ addBoth: function(cb, cbfn){
+ /*
+ Add the same function as both a callback and an errback as the
+ next element on the callback sequence. This is useful for code
+ that you want to guarantee to run, e.g. a finalizer.
+ */
+ var enclosed = this.getFunctionFromArgs(cb, cbfn);
+ if(arguments.length > 2){
+ enclosed = dojo.lang.curryArguments(null, enclosed, arguments, 2);
+ }
+ return this.addCallbacks(enclosed, enclosed);
+ },
+
+ addCallback: function(cb, cbfn){
+ // Add a single callback to the end of the callback sequence.
+ var enclosed = this.getFunctionFromArgs(cb, cbfn);
+ if(arguments.length > 2){
+ enclosed = dojo.lang.curryArguments(null, enclosed, arguments, 2);
+ }
+ return this.addCallbacks(enclosed, null);
+ },
+
+ addErrback: function(cb, cbfn){
+ // Add a single callback to the end of the callback sequence.
+ var enclosed = this.getFunctionFromArgs(cb, cbfn);
+ if(arguments.length > 2){
+ enclosed = dojo.lang.curryArguments(null, enclosed, arguments, 2);
+ }
+ return this.addCallbacks(null, enclosed);
+ return this.addCallbacks(null, fn);
+ },
+
+ addCallbacks: function (cb, eb) {
+ // Add separate callback and errback to the end of the callback
+ // sequence.
+ this.chain.push([cb, eb])
+ if (this.fired >= 0) {
+ this._fire();
+ }
+ return this;
+ },
+
+ _fire: function(){
+ // Used internally to exhaust the callback sequence when a result
+ // is available.
+ var chain = this.chain;
+ var fired = this.fired;
+ var res = this.results[fired];
+ var self = this;
+ var cb = null;
+ while (chain.length > 0 && this.paused == 0) {
+ // Array
+ var pair = chain.shift();
+ var f = pair[fired];
+ if (f == null) {
+ continue;
+ }
+ try {
+ res = f(res);
+ fired = ((res instanceof Error) ? 1 : 0);
+ if(res instanceof dojo.rpc.Deferred) {
+ cb = function(res){
+ self._continue(res);
+ }
+ this._pause();
+ }
+ }catch(err){
+ fired = 1;
+ res = err;
+ }
+ }
+ this.fired = fired;
+ this.results[fired] = res;
+ if((cb)&&(this.paused)){
+ // this is for "tail recursion" in case the dependent
+ // deferred is already fired
+ res.addBoth(cb);
+ }
+ }
+});
+
+/*
+dojo.lang.extend(dojo.rpc.Deferred, {
+
+ getFunctionFromArgs: function(){
+ var a = arguments;
+ if((a[0])&&(!a[1])){
+ if(dojo.lang.isFunction(a[0])){
+ return a[0];
+ }else if(dojo.lang.isString(a[0])){
+ return dj_global[a[0]];
+ }
+ }else if((a[0])&&(a[1])){
+ return dojo.lang.hitch(a[0], a[1]);
+ }
+ return null;
+ },
+
+ addCallback: function(cb, cbfn){
+ var enclosed = this.getFunctionFromArgs(cb, cbfn)
+ if(enclosed){
+ this._callbacks.push(enclosed);
+ if(this.results){
+ enclosed(this.results);
+ }
+ }else{
+ dojo.raise("Deferred: object supplied to addCallback is not a function");
+ }
+ },
+
+ addErrback: function(eb, ebfn){
+ var enclosed = this.getFunctionFromArgs(eb, ebfn)
+ if(enclosed){
+ this._errbacks.push(enclosed);
+ if(this.error){
+ enclosed(this.error);
+ }
+ }else{
+ dojo.raise("Deferred: object supplied to addErrback is not a function");
+ }
+ },
+
+ addBoth: function(cb, eb){
+ this.addCallback(cb);
+ this.addErrback(eb);
+ },
+
+ callback: function(results){
+ this.results = results;
+ dojo.lang.forEach(this._callbacks, function(func){
+ func(results);
+ });
+ },
+
+ errback: function(error){
+ this.error = error;
+ dojo.lang.forEach(this._errbacks, function(func){
+ func(error);
+ });
+ }
+
+});
+*/
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JotService.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JotService.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JotService.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JotService.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2004-2005, 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.rpc.JotService");
+dojo.require("dojo.rpc.RpcService");
+dojo.require("dojo.rpc.JsonService");
+dojo.require("dojo.json");
+
+dojo.rpc.JotService = function(){
+ this.serviceUrl = "/_/jsonrpc";
+}
+
+dojo.inherits(dojo.rpc.JotService, dojo.rpc.JsonService);
+
+dojo.lang.extend(dojo.rpc.JotService, {
+ bind: function(method, parameters, deferredRequestHandler){
+ dojo.io.bind({
+ url: this.serviceUrl,
+ content: {
+ json: this.createRequest(method, parameters)
+ },
+ method: "POST",
+ mimetype: "text/json",
+ load: this.resultCallback(deferredRequestHandler),
+ preventCache: true
+ });
+ },
+
+ createRequest: function(method, params){
+ var req = { "params": params, "method": method, "id": this.lastSubmissionId++ };
+ return dojo.json.serialize(req);
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JsonService.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JsonService.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JsonService.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/JsonService.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,97 @@
+/*
+ Copyright (c) 2004-2005, 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.rpc.JsonService");
+dojo.require("dojo.rpc.RpcService");
+dojo.require("dojo.io.*");
+dojo.require("dojo.json");
+dojo.require("dojo.lang");
+
+dojo.rpc.JsonService = function(args){
+ // passing just the URL isn't terribly useful. It's expected that at
+ // various times folks will want to specify:
+ // - just the serviceUrl (for use w/ remoteCall())
+ // - the text of the SMD to evaluate
+ // - a raw SMD object
+ // - the SMD URL
+ if(args){
+ if(dojo.lang.isString(args)){
+ // we assume it's an SMD file to be processed, since this was the
+ // earlier function signature
+
+ // FIXME: also accept dojo.uri.Uri objects?
+ this.connect(args);
+ }else{
+ // otherwise we assume it's an arguments object with the following
+ // (optional) properties:
+ // - serviceUrl
+ // - strictArgChecks
+ // - smdUrl
+ // - smdStr
+ // - smdObj
+ if(args["smdUrl"]){
+ this.connect(args.smdUrl);
+ }
+ if(args["smdStr"]){
+ this.processSmd(dj_eval("("+args.smdStr+")"));
+ }
+ if(args["smdObj"]){
+ this.processSmd(args.smdObj);
+ }
+ if(args["serviceUrl"]){
+ this.serviceUrl = args.serviceUrl;
+ }
+ if(args["strictArgChecks"]){
+ this.strictArgChecks = args.strictArgChecks;
+ }
+ }
+ }
+}
+
+dojo.inherits(dojo.rpc.JsonService, dojo.rpc.RpcService);
+
+dojo.lang.extend(dojo.rpc.JsonService, {
+
+ bustCache: false,
+
+ lastSubmissionId: 0,
+
+ callRemote: function(method, params){
+ var deferred = new dojo.rpc.Deferred();
+ this.bind(method, params, deferred);
+ return deferred;
+ },
+
+ bind: function(method, parameters, deferredRequestHandler){
+ dojo.io.bind({
+ url: this.serviceUrl,
+ postContent: this.createRequest(method, parameters),
+ method: "POST",
+ mimetype: "text/json",
+ load: this.resultCallback(deferredRequestHandler),
+ preventCache:this.bustCache
+ });
+ },
+
+ createRequest: function(method, params){
+ var req = { "params": params, "method": method, "id": this.lastSubmissionId++ };
+ var data = dojo.json.serialize(req);
+ dojo.debug("JsonService: JSON-RPC Request: " + data);
+ return data;
+ },
+
+ parseResults: function(obj){
+ if(obj["result"]){
+ return obj["result"];
+ }else{
+ return obj;
+ }
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/RpcService.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/RpcService.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/RpcService.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/RpcService.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,114 @@
+/*
+ Copyright (c) 2004-2005, 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.rpc.RpcService");
+dojo.require("dojo.io.*");
+dojo.require("dojo.json");
+dojo.require("dojo.lang");
+dojo.require("dojo.rpc.Deferred");
+
+dojo.rpc.RpcService = function(url){
+ // summary
+ // constructor for rpc base class
+ if(url){
+ this.connect(url);
+ }
+}
+
+dojo.lang.extend(dojo.rpc.RpcService, {
+
+ strictArgChecks: true,
+ serviceUrl: "",
+
+ parseResults: function(obj){
+ // summary
+ // parse the results coming back from an rpc request.
+ // this base implementation, just returns the full object
+ // subclasses should parse and only return the actual results
+ return obj;
+ },
+
+ errorCallback: function(/* dojo.rpc.Deferred */ deferredRequestHandler){
+ // summary
+ // create callback that calls the Deferres errback method
+ return function(type, obj, e){
+ deferredRequestHandler.errback(e);
+ }
+ },
+
+ resultCallback: function(/* dojo.rpc.Deferred */ deferredRequestHandler){
+ // summary
+ // create callback that calls the Deferred's callback method
+ var tf = dojo.lang.hitch(this,
+ function(type, obj, e){
+ var results = this.parseResults(obj);
+ deferredRequestHandler.callback(results);
+ }
+ );
+ return tf;
+ },
+
+
+ generateMethod: function(/* string */ method, /* array */ parameters){
+ // summary
+ // generate the local bind methods for the remote object
+ var _this = this;
+ return function(){
+ var deferredRequestHandler = new dojo.rpc.Deferred();
+
+ // if params weren't specified, then we can assume it's varargs
+ if(
+ (!_this.strictArgChecks)||
+ (
+ (parameters != null)&&
+ (arguments.length != parameters.length)
+ )
+ ){
+ dojo.raise("Invalid number of parameters for remote method.");
+ // put error stuff here, no enough params
+ } else {
+ _this.bind(method, arguments, deferredRequestHandler);
+ }
+
+ return deferredRequestHandler;
+ };
+ },
+
+ processSmd: function(/*json */object){
+
+ // summary
+ // callback method for reciept of a smd object. Parse the smd and generate functions based on the description
+ dojo.debug("RpcService: Processing returned SMD.");
+ for(var n = 0; n < object.methods.length; n++){
+ dojo.debug("RpcService: Creating Method: this.", object.methods[n].name, "()");
+ this[object.methods[n].name] = this.generateMethod(object.methods[n].name,object.methods[n].parameters);
+ if (dojo.lang.isFunction(this[object.methods[n].name])) {
+ dojo.debug("RpcService: Successfully created", object.methods[n].name, "()");
+ } else {
+ dojo.debug("RpcService: Failed to create", object.methods[n].name, "()");
+ }
+ }
+
+ this.serviceUrl = object.serviceUrl||object.serviceURL;
+ dojo.debug("RpcService: Dojo RpcService is ready for use.");
+ },
+
+ connect: function(/* string */smdUrl){
+ // summary
+ // connect to a remote url and retrieve a smd object
+ dojo.debug("RpcService: Attempting to load SMD document from:", smdUrl);
+ dojo.io.bind({
+ url: smdUrl,
+ mimetype: "text/json",
+ load: dojo.lang.hitch(this, function(type, object, e){ return this.processSmd(object); }),
+ sync: true
+ });
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/rpc/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,14 @@
+/*
+ Copyright (c) 2004-2005, 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.hostenv.conditionalLoadModule({
+ common: ["dojo.rpc.JsonService", false, false]
+});
+dojo.hostenv.moduleLoaded("dojo.rpc.*");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/selection.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/selection.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/selection.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/selection.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,403 @@
+/*
+ Copyright (c) 2004-2005, 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.selection");
+dojo.require("dojo.lang");
+dojo.require("dojo.math");
+
+dojo.selection.Selection = function(items, isCollection) {
+ this.items = [];
+ this.selection = [];
+ this._pivotItems = [];
+ this.clearItems();
+
+ if(items) {
+ if(isCollection) {
+ this.setItemsCollection(items);
+ } else {
+ this.setItems(items);
+ }
+ }
+}
+dojo.lang.extend(dojo.selection.Selection, {
+ items: null, // items to select from, order matters
+
+ selection: null, // items selected, aren't stored in order (see sorted())
+ lastSelected: null, // last item selected
+
+ allowImplicit: true, // if true, grow selection will start from 0th item when nothing is selected
+ length: 0, // number of *selected* items
+
+ _pivotItems: null, // stack of pivot items
+ _pivotItem: null, // item we grow selections from, top of stack
+
+ // event handlers
+ onSelect: function(item) {},
+ onDeselect: function(item) {},
+ onSelectChange: function(item, selected) {},
+
+ _find: function(item, inSelection) {
+ if(inSelection) {
+ return dojo.lang.find(item, this.selection);
+ } else {
+ return dojo.lang.find(item, this.items);
+ }
+ },
+
+ isSelectable: function(item) {
+ // user-customizable, will filter items through this
+ return true;
+ },
+
+ setItems: function(/* ... */) {
+ this.clearItems();
+ this.addItems.call(this, arguments);
+ },
+
+ // this is in case you have an active collection array-like object
+ // (i.e. getElementsByTagName collection) that manages its own order
+ // and item list
+ setItemsCollection: function(collection) {
+ this.items = collection;
+ },
+
+ addItems: function(/* ... */) {
+ var args = dojo.lang.unnest(arguments);
+ for(var i = 0; i < args.length; i++) {
+ this.items.push(args[i]);
+ }
+ },
+
+ addItemsAt: function(item, before /* ... */) {
+ if(this.items.length == 0) { // work for empy case
+ return this.addItems(dojo.lang.toArray(arguments, 2));
+ }
+
+ if(!this.isItem(item)) {
+ item = this.items[item];
+ }
+ if(!item) { throw new Error("addItemsAt: item doesn't exist"); }
+ var idx = this._find(item);
+ if(idx > 0 && before) { idx--; }
+ for(var i = 2; i < arguments.length; i++) {
+ if(!this.isItem(arguments[i])) {
+ this.items.splice(idx++, 0, arguments[i]);
+ }
+ }
+ },
+
+ removeItem: function(item) {
+ // remove item
+ var idx = this._find(item);
+ if(idx > -1) {
+ this.items.splice(i, 1);
+ }
+ // remove from selection
+ // FIXME: do we call deselect? I don't think so because this isn't how
+ // you usually want to deselect an item. For example, if you deleted an
+ // item, you don't really want to deselect it -- you want it gone. -DS
+ id = this._find(item, true);
+ if(idx > -1) {
+ this.selection.splice(i, 1);
+ }
+ },
+
+ clearItems: function() {
+ this.items = [];
+ this.deselectAll();
+ },
+
+ isItem: function(item) {
+ return this._find(item) > -1;
+ },
+
+ isSelected: function(item) {
+ return this._find(item, true) > -1;
+ },
+
+ /**
+ * allows you to filter item in or out of the selection
+ * depending on the current selection and action to be taken
+ **/
+ selectFilter: function(item, selection, add, grow) {
+ return true;
+ },
+
+ /**
+ * update -- manages selections, most selecting should be done here
+ * item => item which may be added/grown to/only selected/deselected
+ * add => behaves like ctrl in windows selection world
+ * grow => behaves like shift
+ * noToggle => if true, don't toggle selection on item
+ **/
+ update: function(item, add, grow, noToggle) {
+ if(!this.isItem(item)) { return false; }
+
+ if(grow) {
+ if(!this.isSelected(item)
+ && this.selectFilter(item, this.selection, false, true)) {
+ this.grow(item);
+ this.lastSelected = item;
+ }
+ } else if(add) {
+ if(this.selectFilter(item, this.selection, true, false)) {
+ if(noToggle) {
+ if(this.select(item)) {
+ this.lastSelected = item;
+ }
+ } else if(this.toggleSelected(item)) {
+ this.lastSelected = item;
+ }
+ }
+ } else {
+ this.deselectAll();
+ this.select(item);
+ }
+
+ this.length = this.selection.length;
+ },
+
+ /**
+ * Grow a selection.
+ * toItem => which item to grow selection to
+ * fromItem => which item to start the growth from (it won't be selected)
+ *
+ * Any items in (fromItem, lastSelected] that aren't part of
+ * (fromItem, toItem] will be deselected
+ **/
+ grow: function(toItem, fromItem) {
+ if(arguments.length == 1) {
+ fromItem = this._pivotItem;
+ if(!fromItem && this.allowImplicit) {
+ fromItem = this.items[0];
+ }
+ }
+ if(!toItem || !fromItem) { return false; }
+
+ var fromIdx = this._find(fromItem);
+
+ // get items to deselect (fromItem, lastSelected]
+ var toDeselect = {};
+ var lastIdx = -1;
+ if(this.lastSelected) {
+ lastIdx = this._find(this.lastSelected);
+ var step = fromIdx < lastIdx ? -1 : 1;
+ var range = dojo.math.range(lastIdx, fromIdx, step);
+ for(var i = 0; i < range.length; i++) {
+ toDeselect[range[i]] = true;
+ }
+ }
+
+ // add selection (fromItem, toItem]
+ var toIdx = this._find(toItem);
+ var step = fromIdx < toIdx ? -1 : 1;
+ var shrink = lastIdx >= 0 && step == 1 ? lastIdx < toIdx : lastIdx > toIdx;
+ var range = dojo.math.range(toIdx, fromIdx, step);
+ if(range.length) {
+ for(var i = range.length-1; i >= 0; i--) {
+ var item = this.items[range[i]];
+ if(this.selectFilter(item, this.selection, false, true)) {
+ if(this.select(item, true) || shrink) {
+ this.lastSelected = item;
+ }
+ if(range[i] in toDeselect) {
+ delete toDeselect[range[i]];
+ }
+ }
+ }
+ } else {
+ this.lastSelected = fromItem;
+ }
+
+ // now deselect...
+ for(var i in toDeselect) {
+ if(this.items[i] == this.lastSelected) {
+ dbg("oops!");
+ }
+ this.deselect(this.items[i]);
+ }
+
+ // make sure everything is all kosher after selections+deselections
+ this._updatePivot();
+ },
+
+ /**
+ * Grow selection upwards one item from lastSelected
+ **/
+ growUp: function() {
+ var idx = this._find(this.lastSelected) - 1;
+ while(idx >= 0) {
+ if(this.selectFilter(this.items[idx], this.selection, false, true)) {
+ this.grow(this.items[idx]);
+ break;
+ }
+ idx--;
+ }
+ },
+
+ /**
+ * Grow selection downwards one item from lastSelected
+ **/
+ growDown: function() {
+ var idx = this._find(this.lastSelected);
+ if(idx < 0 && this.allowImplicit) {
+ this.select(this.items[0]);
+ idx = 0;
+ }
+ idx++;
+ while(idx > 0 && idx < this.items.length) {
+ if(this.selectFilter(this.items[idx], this.selection, false, true)) {
+ this.grow(this.items[idx]);
+ break;
+ }
+ idx++;
+ }
+ },
+
+ toggleSelected: function(item, noPivot) {
+ if(this.isItem(item)) {
+ if(this.select(item, noPivot)) { return 1; }
+ if(this.deselect(item)) { return -1; }
+ }
+ return 0;
+ },
+
+ select: function(item, noPivot) {
+ if(this.isItem(item) && !this.isSelected(item)
+ && this.isSelectable(item)) {
+ this.selection.push(item);
+ this.lastSelected = item;
+ this.onSelect(item);
+ this.onSelectChange(item, true);
+ if(!noPivot) {
+ this._addPivot(item);
+ }
+ return true;
+ }
+ return false;
+ },
+
+ deselect: function(item) {
+ var idx = this._find(item, true);
+ if(idx > -1) {
+ this.selection.splice(idx, 1);
+ this.onDeselect(item);
+ this.onSelectChange(item, false);
+ if(item == this.lastSelected) {
+ this.lastSelected = null;
+ }
+
+ this._removePivot(item);
+
+ return true;
+ }
+ return false;
+ },
+
+ selectAll: function() {
+ for(var i = 0; i < this.items.length; i++) {
+ this.select(this.items[i]);
+ }
+ },
+
+ deselectAll: function() {
+ while(this.selection && this.selection.length) {
+ this.deselect(this.selection[0]);
+ }
+ },
+
+ selectNext: function() {
+ var idx = this._find(this.lastSelected);
+ while(idx > -1 && ++idx < this.items.length) {
+ if(this.isSelectable(this.items[idx])) {
+ this.deselectAll();
+ this.select(this.items[idx]);
+ return true;
+ }
+ }
+ return false;
+ },
+
+ selectPrevious: function() {
+ //debugger;
+ var idx = this._find(this.lastSelected);
+ while(idx-- > 0) {
+ if(this.isSelectable(this.items[idx])) {
+ this.deselectAll();
+ this.select(this.items[idx]);
+ return true;
+ }
+ }
+ return false;
+ },
+
+ selectFirst: function() {
+ return this.select(this.items[0]);
+ },
+
+ selectLast: function() {
+ return this.select(this.items[this.items.length-1]);
+ },
+
+ _addPivot: function(item, andClear) {
+ this._pivotItem = item;
+ if(andClear) {
+ this._pivotItems = [item];
+ } else {
+ this._pivotItems.push(item);
+ }
+ },
+
+ _removePivot: function(item) {
+ var i = dojo.lang.find(item, this._pivotItems);
+ if(i > -1) {
+ this._pivotItems.splice(i, 1);
+ this._pivotItem = this._pivotItems[this._pivotItems.length-1];
+ }
+
+ this._updatePivot();
+ },
+
+ _updatePivot: function() {
+ if(this._pivotItems.length == 0) {
+ if(this.lastSelected) {
+ this._addPivot(this.lastSelected);
+ }
+ } else {
+ this._pivotItem = null;
+ }
+ },
+
+ sorted: function() {
+ return dojo.lang.toArray(this.selection).sort(
+ dojo.lang.hitch(this, function(a, b) {
+ var A = this._find(a), B = this._find(b);
+ if(A > B) {
+ return 1;
+ } else if(A < B) {
+ return -1;
+ } else {
+ return 0;
+ }
+ })
+ );
+ },
+
+ // remove any items from the selection that are no longer in this.items
+ updateSelected: function() {
+ for(var i = 0; i < this.selection.length; i++) {
+ if(this._find(this.selection[i]) < 0) {
+ var removed = this.selection.splice(i, 1);
+
+ this._removePivot(removed[0]);
+ }
+ }
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,72 @@
+/*
+ Copyright (c) 2004-2005, 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
+*/
+
+// FIXME: should we require JSON here?
+dojo.require("dojo.lang.*");
+dojo.provide("dojo.storage");
+dojo.provide("dojo.storage.StorageProvider");
+
+dojo.storage = new function(){
+ this.provider = null;
+
+ // similar API as with dojo.io.addTransport()
+ this.setProvider = function(obj){
+ this.provider = obj;
+ }
+
+ this.set = function(key, value, namespace){
+ // FIXME: not very expressive, doesn't have a way of indicating queuing
+ if(!this.provider){
+ return false;
+ }
+ return this.provider.set(key, value, namespace);
+ }
+
+ this.get = function(key, namespace){
+ if(!this.provider){
+ return false;
+ }
+ return this.provider.get(key, namespace);
+ }
+
+ this.remove = function(key, namespace){
+ return this.provider.remove(key, namespace);
+ }
+}
+
+dojo.storage.StorageProvider = function(){
+}
+
+dojo.lang.extend(dojo.storage.StorageProvider, {
+ namespace: "*",
+ initialized: false,
+
+ free: function(){
+ dojo.unimplemented("dojo.storage.StorageProvider.free");
+ return 0;
+ },
+
+ freeK: function(){
+ return dojo.math.round(this.free()/1024, 0);
+ },
+
+ set: function(key, value, namespace){
+ dojo.unimplemented("dojo.storage.StorageProvider.set");
+ },
+
+ get: function(key, namespace){
+ dojo.unimplemented("dojo.storage.StorageProvider.get");
+ },
+
+ remove: function(key, value, namespace){
+ dojo.unimplemented("dojo.storage.StorageProvider.set");
+ }
+
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.as
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.as?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.as (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.as Thu Jan 26 15:56:50 2006
@@ -0,0 +1,51 @@
+import flash.external.ExternalInterface;
+
+class Storage {
+ static var app : Storage;
+ var store: SharedObject;
+ static var started: Boolean = false;
+
+ public function Storage(){
+ ExternalInterface.addCallback("set", null, set);
+ ExternalInterface.addCallback("get", null, get);
+ ExternalInterface.addCallback("free", null, free);
+ }
+
+ public function set(key, value, namespace){
+ var primeForReHide = false;
+ store = SharedObject.getLocal(namespace);
+ store.onStatus = function(status){
+ // ExternalInterface.call("alert", status.code == "SharedObject.Flush.Failed");
+ // ExternalInterface.call("alert", status.code == "SharedObject.Flush.Success");
+ if(primeForReHide){
+ primeForReHide = false;
+ ExternalInterface.call("dojo.storage.provider.hideStore");
+ }
+ }
+ store.data[key] = value;
+ var ret = store.flush();
+ if(typeof ret == "string"){
+ ExternalInterface.call("dojo.storage.provider.unHideStore");
+ primeForReHide = true;
+ }
+ return store.getSize(namespace);
+ }
+
+ public function get(key, namespace){
+ store = SharedObject.getLocal(namespace);
+ return store.data[key];
+ }
+
+ public function free(namespace){
+ return SharedObject.getDiskUsage(namespace);
+ }
+
+ static function main(mc){
+ app = new Storage();
+ if(!started){
+ ExternalInterface.call("dojo.storage.provider.storageOnLoad");
+ started = true;
+ }
+ }
+}
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.swf
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.swf?rev=372668&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/Storage.swf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,16 @@
+/*
+ Copyright (c) 2004-2005, 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.hostenv.conditionalLoadModule({
+ common: ["dojo.storage"],
+ browser: ["dojo.storage.browser"]
+});
+dojo.hostenv.moduleLoaded("dojo.storage.*");
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/browser.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/browser.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/browser.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/browser.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,102 @@
+/*
+ Copyright (c) 2004-2005, 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.storage.browser");
+dojo.require("dojo.storage");
+dojo.require("dojo.uri.*");
+
+dojo.storage.browser.StorageProvider = function(){
+ this.initialized = false;
+ this.flash = null;
+ this.backlog = [];
+}
+
+dojo.inherits( dojo.storage.browser.StorageProvider,
+ dojo.storage.StorageProvider);
+
+dojo.lang.extend(dojo.storage.browser.StorageProvider, {
+ storageOnLoad: function(){
+ this.initialized = true;
+ this.hideStore();
+ while(this.backlog.length){
+ this.set.apply(this, this.backlog.shift());
+ }
+ },
+
+ unHideStore: function(){
+ var container = dojo.byId("dojo-storeContainer");
+ with(container.style){
+ position = "absolute";
+ overflow = "visible";
+ width = "215px";
+ height = "138px";
+ // FIXME: make these positions dependent on screen size/scrolling!
+ left = "30px";
+ top = "30px";
+ visiblity = "visible";
+ zIndex = "20";
+ border = "1px solid black";
+ }
+ },
+
+ hideStore: function(status){
+ var container = dojo.byId("dojo-storeContainer");
+ with(container.style){
+ left = "-300px";
+ top = "-300px";
+ }
+ },
+
+ set: function(key, value, ns){
+ if(!this.initialized){
+ this.backlog.push([key, value, ns]);
+ return "pending";
+ }
+ return this.flash.set(key, value, ns||this.namespace);
+ },
+
+ get: function(key, ns){
+ return this.flash.get(key, ns||this.namespace);
+ },
+
+ writeStorage: function(){
+ var swfloc = dojo.uri.dojoUri("src/storage/Storage.swf").toString();
+ // alert(swfloc);
+ var storeParts = [
+ '<div id="dojo-storeContainer"',
+ 'style="position: absolute; left: -300px; top: -300px;">'];
+ if(dojo.render.html.ie){
+ storeParts.push('<object');
+ storeParts.push(' style="border: 1px solid black;"');
+ storeParts.push(' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
+ storeParts.push(' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"');
+ storeParts.push(' width="215" height="138" id="dojoStorage">');
+ storeParts.push(' <param name="movie" value="'+swfloc+'">');
+ storeParts.push(' <param name="quality" value="high">');
+ storeParts.push('</object>');
+ }else{
+ storeParts.push('<embed src="'+swfloc+'" width="215" height="138" ');
+ storeParts.push(' quality="high" ');
+ storeParts.push(' pluginspage="http://www.macromedia.com/go/getflashplayer" ');
+ storeParts.push(' type="application/x-shockwave-flash" ');
+ storeParts.push(' name="dojoStorage">');
+ storeParts.push('</embed>');
+ }
+ storeParts.push('</div>');
+ document.write(storeParts.join(""));
+ }
+});
+
+dojo.storage.setProvider(new dojo.storage.browser.StorageProvider());
+dojo.storage.provider.writeStorage();
+
+dojo.addOnLoad(function(){
+ dojo.storage.provider.flash = (dojo.render.html.ie) ? window["dojoStorage"] : document["dojoStorage"];
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/storage.sh
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/storage.sh?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/storage.sh (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/storage/storage.sh Thu Jan 26 15:56:50 2006
@@ -0,0 +1,3 @@
+#! /bin/bash
+
+mtasc -version 8 -swf Storage.swf -main -header 215:138:10 Storage.as
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,318 @@
+/*
+ Copyright (c) 2004-2005, 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.string");
+dojo.require("dojo.lang");
+
+/**
+ * Trim whitespace from 'str'. If 'wh' > 0,
+ * only trim from start, if 'wh' < 0, only trim
+ * from end, otherwise trim both ends
+ */
+dojo.string.trim = function(str, wh){
+ if(!dojo.lang.isString(str)){ return str; }
+ if(!str.length){ return str; }
+ if(wh > 0) {
+ return str.replace(/^\s+/, "");
+ } else if(wh < 0) {
+ return str.replace(/\s+$/, "");
+ } else {
+ return str.replace(/^\s+|\s+$/g, "");
+ }
+}
+
+/**
+ * Trim whitespace at the beginning of 'str'
+ */
+dojo.string.trimStart = function(str) {
+ return dojo.string.trim(str, 1);
+}
+
+/**
+ * Trim whitespace at the end of 'str'
+ */
+dojo.string.trimEnd = function(str) {
+ return dojo.string.trim(str, -1);
+}
+
+/**
+ * Parameterized string function
+ * str - formatted string with %{values} to be replaces
+ * pairs - object of name: "value" value pairs
+ * killExtra - remove all remaining %{values} after pairs are inserted
+ */
+dojo.string.paramString = function(str, pairs, killExtra) {
+ for(var name in pairs) {
+ var re = new RegExp("\\%\\{" + name + "\\}", "g");
+ str = str.replace(re, pairs[name]);
+ }
+
+ if(killExtra) { str = str.replace(/%\{([^\}\s]+)\}/g, ""); }
+ return str;
+}
+
+/** Uppercases the first letter of each word */
+dojo.string.capitalize = function (str) {
+ if (!dojo.lang.isString(str)) { return ""; }
+ if (arguments.length == 0) { str = this; }
+ var words = str.split(' ');
+ var retval = "";
+ var len = words.length;
+ for (var i=0; i<len; i++) {
+ var word = words[i];
+ word = word.charAt(0).toUpperCase() + word.substring(1, word.length);
+ retval += word;
+ if (i < len-1)
+ retval += " ";
+ }
+
+ return new String(retval);
+}
+
+/**
+ * Return true if the entire string is whitespace characters
+ */
+dojo.string.isBlank = function (str) {
+ if(!dojo.lang.isString(str)) { return true; }
+ return (dojo.string.trim(str).length == 0);
+}
+
+dojo.string.encodeAscii = function(str) {
+ if(!dojo.lang.isString(str)) { return str; }
+ var ret = "";
+ var value = escape(str);
+ var match, re = /%u([0-9A-F]{4})/i;
+ while((match = value.match(re))) {
+ var num = Number("0x"+match[1]);
+ var newVal = escape("&#" + num + ";");
+ ret += value.substring(0, match.index) + newVal;
+ value = value.substring(match.index+match[0].length);
+ }
+ ret += value.replace(/\+/g, "%2B");
+ return ret;
+}
+
+// TODO: make an HTML version
+dojo.string.summary = function(str, len) {
+ if(!len || str.length <= len) {
+ return str;
+ } else {
+ return str.substring(0, len).replace(/\.+$/, "") + "...";
+ }
+}
+
+dojo.string.escape = function(type, str) {
+ var args = [];
+ for(var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
+ switch(type.toLowerCase()) {
+ case "xml":
+ case "html":
+ case "xhtml":
+ return dojo.string.escapeXml.apply(this, args);
+ case "sql":
+ return dojo.string.escapeSql.apply(this, args);
+ case "regexp":
+ case "regex":
+ return dojo.string.escapeRegExp.apply(this, args);
+ case "javascript":
+ case "jscript":
+ case "js":
+ return dojo.string.escapeJavaScript.apply(this, args);
+ case "ascii":
+ // so it's encode, but it seems useful
+ return dojo.string.encodeAscii.apply(this, args);
+ default:
+ return str;
+ }
+}
+
+dojo.string.escapeXml = function(str, noSingleQuotes) {
+ str = str.replace(/&/gm, "&").replace(/</gm, "<")
+ .replace(/>/gm, ">").replace(/"/gm, """);
+ if(!noSingleQuotes) { str = str.replace(/'/gm, "'"); }
+ return str;
+}
+
+dojo.string.escapeSql = function(str) {
+ return str.replace(/'/gm, "''");
+}
+
+dojo.string.escapeRegExp = function(str) {
+ return str.replace(/\\/gm, "\\\\").replace(/([\f\b\n\t\r])/gm, "\\$1");
+}
+
+dojo.string.escapeJavaScript = function(str) {
+ return str.replace(/(["'\f\b\n\t\r])/gm, "\\$1");
+}
+
+/**
+ * Return 'str' repeated 'count' times, optionally
+ * placing 'separator' between each rep
+ */
+dojo.string.repeat = function(str, count, separator) {
+ var out = "";
+ for(var i = 0; i < count; i++) {
+ out += str;
+ if(separator && i < count - 1) {
+ out += separator;
+ }
+ }
+ return out;
+}
+
+/**
+ * Returns true if 'str' ends with 'end'
+ */
+dojo.string.endsWith = function(str, end, ignoreCase) {
+ if(ignoreCase) {
+ str = str.toLowerCase();
+ end = end.toLowerCase();
+ }
+ return str.lastIndexOf(end) == str.length - end.length;
+}
+
+/**
+ * Returns true if 'str' ends with any of the arguments[2 -> n]
+ */
+dojo.string.endsWithAny = function(str /* , ... */) {
+ for(var i = 1; i < arguments.length; i++) {
+ if(dojo.string.endsWith(str, arguments[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Returns true if 'str' starts with 'start'
+ */
+dojo.string.startsWith = function(str, start, ignoreCase) {
+ if(ignoreCase) {
+ str = str.toLowerCase();
+ start = start.toLowerCase();
+ }
+ return str.indexOf(start) == 0;
+}
+
+/**
+ * Returns true if 'str' starts with any of the arguments[2 -> n]
+ */
+dojo.string.startsWithAny = function(str /* , ... */) {
+ for(var i = 1; i < arguments.length; i++) {
+ if(dojo.string.startsWith(str, arguments[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Returns true if 'str' starts with any of the arguments 2 -> n
+ */
+dojo.string.has = function(str /* , ... */) {
+ for(var i = 1; i < arguments.length; i++) {
+ if(str.indexOf(arguments[i] > -1)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Pad 'str' to guarantee that it is at least 'len' length
+ * with the character 'c' at either the start (dir=1) or
+ * end (dir=-1) of the string
+ */
+dojo.string.pad = function(str, len/*=2*/, c/*='0'*/, dir/*=1*/) {
+ var out = String(str);
+ if(!c) {
+ c = '0';
+ }
+ if(!dir) {
+ dir = 1;
+ }
+ while(out.length < len) {
+ if(dir > 0) {
+ out = c + out;
+ } else {
+ out += c;
+ }
+ }
+ return out;
+}
+
+/** same as dojo.string.pad(str, len, c, 1) */
+dojo.string.padLeft = function(str, len, c) {
+ return dojo.string.pad(str, len, c, 1);
+}
+
+/** same as dojo.string.pad(str, len, c, -1) */
+dojo.string.padRight = function(str, len, c) {
+ return dojo.string.pad(str, len, c, -1);
+}
+
+dojo.string.normalizeNewlines = function (text,newlineChar) {
+ if (newlineChar == "\n") {
+ text = text.replace(/\r\n/g, "\n");
+ text = text.replace(/\r/g, "\n");
+ } else if (newlineChar == "\r") {
+ text = text.replace(/\r\n/g, "\r");
+ text = text.replace(/\n/g, "\r");
+ } else {
+ text = text.replace(/([^\r])\n/g, "$1\r\n");
+ text = text.replace(/\r([^\n])/g, "\r\n$1");
+ }
+ return text;
+}
+
+dojo.string.splitEscaped = function (str,charac) {
+ var components = [];
+ for (var i = 0, prevcomma = 0; i < str.length; i++) {
+ if (str.charAt(i) == '\\') { i++; continue; }
+ if (str.charAt(i) == charac) {
+ components.push(str.substring(prevcomma, i));
+ prevcomma = i + 1;
+ }
+ }
+ components.push(str.substr(prevcomma));
+ return components;
+}
+
+
+// do we even want to offer this? is it worth it?
+dojo.string.addToPrototype = function() {
+ for(var method in dojo.string) {
+ if(dojo.lang.isFunction(dojo.string[method])) {
+ var func = (function() {
+ var meth = method;
+ switch(meth) {
+ case "addToPrototype":
+ return null;
+ break;
+ case "escape":
+ return function(type) {
+ return dojo.string.escape(type, this);
+ }
+ break;
+ default:
+ return function() {
+ var args = [this];
+ for(var i = 0; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ }
+ dojo.debug(args);
+ return dojo.string[meth].apply(dojo.string, args);
+ }
+ }
+ })();
+ if(func) { String.prototype[method] = func; }
+ }
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/Builder.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/Builder.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/Builder.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/Builder.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,105 @@
+/*
+ Copyright (c) 2004-2005, 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.string.Builder");
+dojo.require("dojo.string");
+
+// NOTE: testing shows that direct "+=" concatenation is *much* faster on
+// Spidermoneky and Rhino, while arr.push()/arr.join() style concatenation is
+// significantly quicker on IE (Jscript/wsh/etc.).
+
+dojo.string.Builder = function(str){
+ this.arrConcat = (dojo.render.html.capable && dojo.render.html["ie"]);
+
+ var a = [];
+ var b = str || "";
+ var length = this.length = b.length;
+
+ if(this.arrConcat){
+ if(b.length > 0){
+ a.push(b);
+ }
+ b = "";
+ }
+
+ this.toString = this.valueOf = function(){
+ return (this.arrConcat) ? a.join("") : b;
+ };
+
+ this.append = function(s){
+ if(this.arrConcat){
+ a.push(s);
+ }else{
+ b+=s;
+ }
+ length += s.length;
+ this.length = length;
+ return this;
+ };
+
+ this.clear = function(){
+ a = [];
+ b = "";
+ length = this.length = 0;
+ return this;
+ };
+
+ this.remove = function(f,l){
+ var s = "";
+ if(this.arrConcat){
+ b = a.join("");
+ }
+ a=[];
+ if(f>0){
+ s = b.substring(0, (f-1));
+ }
+ b = s + b.substring(f + l);
+ length = this.length = b.length;
+ if(this.arrConcat){
+ a.push(b);
+ b="";
+ }
+ return this;
+ };
+
+ this.replace = function(o,n){
+ if(this.arrConcat){
+ b = a.join("");
+ }
+ a = [];
+ b = b.replace(o,n);
+ length = this.length = b.length;
+ if(this.arrConcat){
+ a.push(b);
+ b="";
+ }
+ return this;
+ };
+
+ this.insert = function(idx,s){
+ if(this.arrConcat){
+ b = a.join("");
+ }
+ a=[];
+ if(idx == 0){
+ b = s + b;
+ }else{
+ var t = b.split("");
+ t.splice(idx,0,s);
+ b = t.join("")
+ }
+ length = this.length = b.length;
+ if(this.arrConcat){
+ a.push(b);
+ b="";
+ }
+ return this;
+ };
+};
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/__package__.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/__package__.js?rev=372668&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/__package__.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/string/__package__.js Thu Jan 26 15:56:50 2006
@@ -0,0 +1,17 @@
+/*
+ Copyright (c) 2004-2005, 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.hostenv.conditionalLoadModule({
+ common: [
+ "dojo.string",
+ "dojo.string.Builder"
+ ]
+});
+dojo.hostenv.moduleLoaded("dojo.string.*");