You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2006/06/10 15:59:38 UTC
svn commit: r413300 [8/16] - in /tapestry/tapestry4/trunk/framework/src/js:
dojo/ dojo/src/ dojo/src/animation/ dojo/src/collections/ dojo/src/compat/
dojo/src/crypto/ dojo/src/data/ dojo/src/data/format/
dojo/src/data/provider/ dojo/src/debug/ dojo/sr...
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/Logger.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/Logger.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/Logger.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/Logger.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,408 @@
+/*
+ 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
+*/
+
+/* This is the dojo logging facility, which is imported from nWidgets
+ (written by Alex Russell, CLA on file), which is patterned on the
+ Python logging module, which in turn has been heavily influenced by
+ log4j (execpt with some more pythonic choices, which we adopt as well).
+
+ While the dojo logging facilities do provide a set of familiar
+ interfaces, many of the details are changed to reflect the constraints
+ of the browser environment. Mainly, file and syslog-style logging
+ facilites are not provided, with HTTP POST and GET requests being the
+ only ways of getting data from the browser back to a server. Minimal
+ support for this (and XML serialization of logs) is provided, but may
+ not be of practical use in a deployment environment.
+
+ The Dojo logging classes are agnostic of any environment, and while
+ default loggers are provided for browser-based interpreter
+ environments, this file and the classes it define are explicitly
+ designed to be portable to command-line interpreters and other
+ ECMA-262v3 envrionments.
+
+ the logger needs to accomidate:
+ log "levels"
+ type identifiers
+ file?
+ message
+ tic/toc?
+
+ The logger should ALWAYS record:
+ time/date logged
+ message
+ type
+ level
+*/
+// TODO: conver documentation to javadoc style once we confirm that is our choice
+// TODO: define DTD for XML-formatted log messages
+// TODO: write XML Formatter class
+// TODO: write HTTP Handler which uses POST to send log lines/sections
+
+// Filename: LogCore.js
+// Purpose: a common logging infrastructure for dojo
+// Classes: dojo.logging, dojo.logging.Logger, dojo.logging.Record, dojo.logging.LogFilter
+// Global Objects: dojo.logging
+// Dependencies: none
+
+dojo.provide("dojo.logging.Logger");
+dojo.provide("dojo.log");
+dojo.require("dojo.lang");
+
+/*
+ A simple data structure class that stores information for and about
+ a logged event. Objects of this type are created automatically when
+ an event is logged and are the internal format in which information
+ about log events is kept.
+*/
+
+dojo.logging.Record = function(lvl, msg){
+ this.level = lvl;
+ this.message = msg;
+ this.time = new Date();
+ // FIXME: what other information can we receive/discover here?
+}
+
+// an empty parent (abstract) class which concrete filters should inherit from.
+dojo.logging.LogFilter = function(loggerChain){
+ this.passChain = loggerChain || "";
+ this.filter = function(record){
+ // FIXME: need to figure out a way to enforce the loggerChain
+ // restriction
+ return true; // pass all records
+ }
+}
+
+dojo.logging.Logger = function(){
+ this.cutOffLevel = 0;
+ this.propagate = true;
+ this.parent = null;
+ // storage for dojo.logging.Record objects seen and accepted by this logger
+ this.data = [];
+ this.filters = [];
+ this.handlers = [];
+}
+
+dojo.lang.extend(dojo.logging.Logger, {
+ argsToArr: function(args){
+ // utility function, reproduced from __util__ here to remove dependency
+ var ret = [];
+ for(var x=0; x<args.length; x++){
+ ret.push(args[x]);
+ }
+ return ret;
+ },
+
+ setLevel: function(lvl){
+ this.cutOffLevel = parseInt(lvl);
+ },
+
+ isEnabledFor: function(lvl){
+ return parseInt(lvl) >= this.cutOffLevel;
+ },
+
+ getEffectiveLevel: function(){
+ if((this.cutOffLevel==0)&&(this.parent)){
+ return this.parent.getEffectiveLevel();
+ }
+ return this.cutOffLevel;
+ },
+
+ addFilter: function(flt){
+ this.filters.push(flt);
+ return this.filters.length-1;
+ },
+
+ removeFilterByIndex: function(fltIndex){
+ if(this.filters[fltIndex]){
+ delete this.filters[fltIndex];
+ return true;
+ }
+ return false;
+ },
+
+ removeFilter: function(fltRef){
+ for(var x=0; x<this.filters.length; x++){
+ if(this.filters[x]===fltRef){
+ delete this.filters[x];
+ return true;
+ }
+ }
+ return false;
+ },
+
+ removeAllFilters: function(){
+ this.filters = []; // clobber all of them
+ },
+
+ filter: function(rec){
+ for(var x=0; x<this.filters.length; x++){
+ if((this.filters[x]["filter"])&&
+ (!this.filters[x].filter(rec))||
+ (rec.level<this.cutOffLevel)){
+ return false;
+ }
+ }
+ return true;
+ },
+
+ addHandler: function(hdlr){
+ this.handlers.push(hdlr);
+ return this.handlers.length-1;
+ },
+
+ handle: function(rec){
+ if((!this.filter(rec))||(rec.level<this.cutOffLevel)){ return false; }
+ for(var x=0; x<this.handlers.length; x++){
+ if(this.handlers[x]["handle"]){
+ this.handlers[x].handle(rec);
+ }
+ }
+ // FIXME: not sure what to do about records to be propagated that may have
+ // been modified by the handlers or the filters at this logger. Should
+ // parents always have pristine copies? or is passing the modified record
+ // OK?
+ // if((this.propagate)&&(this.parent)){ this.parent.handle(rec); }
+ return true;
+ },
+
+ // the heart and soul of the logging system
+ log: function(lvl, msg){
+ if( (this.propagate)&&(this.parent)&&
+ (this.parent.rec.level>=this.cutOffLevel)){
+ this.parent.log(lvl, msg);
+ return false;
+ }
+ // FIXME: need to call logging providers here!
+ this.handle(new dojo.logging.Record(lvl, msg));
+ return true;
+ },
+
+ // logger helpers
+ debug:function(msg){
+ return this.logType("DEBUG", this.argsToArr(arguments));
+ },
+
+ info: function(msg){
+ return this.logType("INFO", this.argsToArr(arguments));
+ },
+
+ warning: function(msg){
+ return this.logType("WARNING", this.argsToArr(arguments));
+ },
+
+ error: function(msg){
+ return this.logType("ERROR", this.argsToArr(arguments));
+ },
+
+ critical: function(msg){
+ return this.logType("CRITICAL", this.argsToArr(arguments));
+ },
+
+ exception: function(msg, e, squelch){
+ // FIXME: this needs to be modified to put the exception in the msg
+ // if we're on Moz, we can get the following from the exception object:
+ // lineNumber
+ // message
+ // fileName
+ // stack
+ // name
+ // on IE, we get:
+ // name
+ // message (from MDA?)
+ // number
+ // description (same as message!)
+ if(e){
+ var eparts = [e.name, (e.description||e.message)];
+ if(e.fileName){
+ eparts.push(e.fileName);
+ eparts.push("line "+e.lineNumber);
+ // eparts.push(e.stack);
+ }
+ msg += " "+eparts.join(" : ");
+ }
+
+ this.logType("ERROR", msg);
+ if(!squelch){
+ throw e;
+ }
+ },
+
+ logType: function(type, args){
+ var na = [dojo.logging.log.getLevel(type)];
+ if(typeof args == "array"){
+ na = na.concat(args);
+ }else if((typeof args == "object")&&(args["length"])){
+ na = na.concat(this.argsToArr(args));
+ /* for(var x=0; x<args.length; x++){
+ na.push(args[x]);
+ } */
+ }else{
+ na = na.concat(this.argsToArr(arguments).slice(1));
+ /* for(var x=1; x<arguments.length; x++){
+ na.push(arguments[x]);
+ } */
+ }
+ return this.log.apply(this, na);
+ }
+});
+
+void(function(){
+ var ptype = dojo.logging.Logger.prototype;
+ ptype.warn = ptype.warning;
+ ptype.err = ptype.error;
+ ptype.crit = ptype.critical;
+})();
+
+// the Handler class
+dojo.logging.LogHandler = function(level){
+ this.cutOffLevel = (level) ? level : 0;
+ this.formatter = null; // FIXME: default formatter?
+ this.data = [];
+ this.filters = [];
+}
+
+dojo.logging.LogHandler.prototype.setFormatter = function(fmtr){
+ // FIXME: need to vet that it is indeed a formatter object
+ dojo.unimplemented("setFormatter");
+}
+
+dojo.logging.LogHandler.prototype.flush = function(){
+ dojo.unimplemented("flush");
+}
+
+dojo.logging.LogHandler.prototype.close = function(){
+ dojo.unimplemented("close");
+}
+
+dojo.logging.LogHandler.prototype.handleError = function(){
+ dojo.unimplemented("handleError");
+}
+
+dojo.logging.LogHandler.prototype.handle = function(record){
+ // emits the passed record if it passes this object's filters
+ if((this.filter(record))&&(record.level>=this.cutOffLevel)){
+ this.emit(record);
+ }
+}
+
+dojo.logging.LogHandler.prototype.emit = function(record){
+ // do whatever is necessaray to actually log the record
+ dojo.unimplemented("emit");
+}
+
+// set aliases since we don't want to inherit from dojo.logging.Logger
+void(function(){ // begin globals protection closure
+ var names = [
+ "setLevel", "addFilter", "removeFilterByIndex", "removeFilter",
+ "removeAllFilters", "filter"
+ ];
+ var tgt = dojo.logging.LogHandler.prototype;
+ var src = dojo.logging.Logger.prototype;
+ for(var x=0; x<names.length; x++){
+ tgt[names[x]] = src[names[x]];
+ }
+})(); // end globals protection closure
+
+dojo.logging.log = new dojo.logging.Logger();
+
+// an associative array of logger objects. This object inherits from
+// a list of level names with their associated numeric levels
+dojo.logging.log.levels = [ {"name": "DEBUG", "level": 1},
+ {"name": "INFO", "level": 2},
+ {"name": "WARNING", "level": 3},
+ {"name": "ERROR", "level": 4},
+ {"name": "CRITICAL", "level": 5} ];
+
+dojo.logging.log.loggers = {};
+
+dojo.logging.log.getLogger = function(name){
+ if(!this.loggers[name]){
+ this.loggers[name] = new dojo.logging.Logger();
+ this.loggers[name].parent = this;
+ }
+ return this.loggers[name];
+}
+
+dojo.logging.log.getLevelName = function(lvl){
+ for(var x=0; x<this.levels.length; x++){
+ if(this.levels[x].level == lvl){
+ return this.levels[x].name;
+ }
+ }
+ return null;
+}
+
+dojo.logging.log.addLevelName = function(name, lvl){
+ if(this.getLevelName(name)){
+ this.err("could not add log level "+name+" because a level with that name already exists");
+ return false;
+ }
+ this.levels.append({"name": name, "level": parseInt(lvl)});
+ return true;
+}
+
+dojo.logging.log.getLevel = function(name){
+ for(var x=0; x<this.levels.length; x++){
+ if(this.levels[x].name.toUpperCase() == name.toUpperCase()){
+ return this.levels[x].level;
+ }
+ }
+ return null;
+}
+
+// a default handler class, it simply saves all of the handle()'d records in
+// memory. Useful for attaching to with dojo.event.connect()
+dojo.logging.MemoryLogHandler = function(level, recordsToKeep, postType, postInterval){
+ // mixin style inheritance
+ dojo.logging.LogHandler.call(this, level);
+ // default is unlimited
+ this.numRecords = (typeof djConfig['loggingNumRecords'] != 'undefined') ? djConfig['loggingNumRecords'] : ((recordsToKeep) ? recordsToKeep : -1);
+ // 0=count, 1=time, -1=don't post TODO: move this to a better location for prefs
+ this.postType = (typeof djConfig['loggingPostType'] != 'undefined') ? djConfig['loggingPostType'] : ( postType || -1);
+ // milliseconds for time, interger for number of records, -1 for non-posting,
+ this.postInterval = (typeof djConfig['loggingPostInterval'] != 'undefined') ? djConfig['loggingPostInterval'] : ( postType || -1);
+
+}
+// prototype inheritance
+dojo.logging.MemoryLogHandler.prototype = new dojo.logging.LogHandler();
+
+// FIXME
+// dojo.inherits(dojo.logging.MemoryLogHandler,
+
+// over-ride base-class
+dojo.logging.MemoryLogHandler.prototype.emit = function(record){
+ this.data.push(record);
+ if(this.numRecords != -1){
+ while(this.data.length>this.numRecords){
+ this.data.shift();
+ }
+ }
+}
+
+dojo.logging.logQueueHandler = new dojo.logging.MemoryLogHandler(0,50,0,10000);
+// actual logging event handler
+dojo.logging.logQueueHandler.emit = function(record){
+ if (!djConfig.isDebug) { return; }
+ // we should probably abstract this in the future
+ var logStr = String(dojo.log.getLevelName(record.level)+": "+record.time.toLocaleTimeString())+": "+record.message;
+ if(!dj_undef("println", dojo.hostenv)){
+ dojo.hostenv.println(logStr);
+ }
+
+ this.data.push(record);
+ if(this.numRecords != -1){
+ while(this.data.length>this.numRecords){
+ this.data.shift();
+ }
+ }
+}
+
+dojo.logging.log.addHandler(dojo.logging.logQueueHandler);
+dojo.log = dojo.logging.log;
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/Logger.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,15 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ common: ["dojo.logging.Logger", false, false],
+ rhino: ["dojo.logging.RhinoLogger"]
+});
+dojo.provide("dojo.logging.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/logging/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/math.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/math.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/math.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,134 @@
+/*
+ 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.math");
+
+dojo.math.degToRad = function (x) { return (x*Math.PI) / 180; }
+dojo.math.radToDeg = function (x) { return (x*180) / Math.PI; }
+
+dojo.math.factorial = function (n) {
+ if(n<1){ return 0; }
+ var retVal = 1;
+ for(var i=1;i<=n;i++){ retVal *= i; }
+ return retVal;
+}
+
+//The number of ways of obtaining an ordered subset of k elements from a set of n elements
+dojo.math.permutations = function (n,k) {
+ if(n==0 || k==0) return 1;
+ return (dojo.math.factorial(n) / dojo.math.factorial(n-k));
+}
+
+//The number of ways of picking n unordered outcomes from r possibilities
+dojo.math.combinations = function (n,r) {
+ if(n==0 || r==0) return 1;
+ return (dojo.math.factorial(n) / (dojo.math.factorial(n-r) * dojo.math.factorial(r)));
+}
+
+dojo.math.bernstein = function (t,n,i) {
+ return (dojo.math.combinations(n,i) * Math.pow(t,i) * Math.pow(1-t,n-i));
+}
+
+/**
+ * Returns random numbers with a Gaussian distribution, with the mean set at
+ * 0 and the variance set at 1.
+ *
+ * @return A random number from a Gaussian distribution
+ */
+dojo.math.gaussianRandom = function () {
+ var k = 2;
+ do {
+ var i = 2 * Math.random() - 1;
+ var j = 2 * Math.random() - 1;
+ k = i * i + j * j;
+ } while (k >= 1);
+ k = Math.sqrt((-2 * Math.log(k)) / k);
+ return i * k;
+}
+
+/**
+ * Calculates the mean of an Array of numbers.
+ *
+ * @return The mean of the numbers in the Array
+ */
+dojo.math.mean = function () {
+ var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments;
+ var mean = 0;
+ for (var i = 0; i < array.length; i++) { mean += array[i]; }
+ return mean / array.length;
+}
+
+/**
+ * Extends Math.round by adding a second argument specifying the number of
+ * decimal places to round to.
+ *
+ * @param number The number to round
+ * @param places The number of decimal places to round to
+ * @return The rounded number
+ */
+// TODO: add support for significant figures
+dojo.math.round = function (number, places) {
+ if (!places) { var shift = 1; }
+ else { var shift = Math.pow(10, places); }
+ return Math.round(number * shift) / shift;
+}
+
+/**
+ * Calculates the standard deviation of an Array of numbers
+ *
+ * @return The standard deviation of the numbers
+ */
+dojo.math.sd = function () {
+ var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments;
+ return Math.sqrt(dojo.math.variance(array));
+}
+
+/**
+ * Calculates the variance of an Array of numbers
+ *
+ * @return The variance of the numbers
+ */
+dojo.math.variance = function () {
+ var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments;
+ var mean = 0, squares = 0;
+ for (var i = 0; i < array.length; i++) {
+ mean += array[i];
+ squares += Math.pow(array[i], 2);
+ }
+ return (squares / array.length)
+ - Math.pow(mean / array.length, 2);
+}
+
+/**
+ * Like range() in python
+**/
+dojo.math.range = function(a, b, step) {
+ if(arguments.length < 2) {
+ b = a;
+ a = 0;
+ }
+ if(arguments.length < 3) {
+ step = 1;
+ }
+
+ var range = [];
+ if(step > 0) {
+ for(var i = a; i < b; i += step) {
+ range.push(i);
+ }
+ } else if(step < 0) {
+ for(var i = a; i > b; i += step) {
+ range.push(i);
+ }
+ } else {
+ throw new Error("dojo.math.range: step must be non-zero");
+ }
+ return range;
+}
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/Math.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/Math.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/Math.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/Math.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,12 @@
+/*
+ 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.deprecated("dojo.math.Math", "include dojo.math instead", "0.4");
+dojo.require("dojo.math");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/Math.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,18 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ common: [
+ ["dojo.math", false, false],
+ ["dojo.math.curves", false, false],
+ ["dojo.math.points", false, false]
+ ]
+});
+dojo.provide("dojo.math.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/curves.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/curves.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/curves.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/curves.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,222 @@
+/*
+ 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.math.curves");
+
+dojo.require("dojo.math");
+
+/* Curves from Dan's 13th lib stuff.
+ * See: http://pupius.co.uk/js/Toolkit.Drawing.js
+ * http://pupius.co.uk/dump/dojo/Dojo.Math.js
+ */
+
+dojo.math.curves = {
+ //Creates a straight line object
+ Line: function(start, end) {
+ this.start = start;
+ this.end = end;
+ this.dimensions = start.length;
+
+ for(var i = 0; i < start.length; i++) {
+ start[i] = Number(start[i]);
+ }
+
+ for(var i = 0; i < end.length; i++) {
+ end[i] = Number(end[i]);
+ }
+
+ //simple function to find point on an n-dimensional, straight line
+ this.getValue = function(n) {
+ var retVal = new Array(this.dimensions);
+ for(var i=0;i<this.dimensions;i++)
+ retVal[i] = ((this.end[i] - this.start[i]) * n) + this.start[i];
+ return retVal;
+ }
+
+ return this;
+ },
+
+
+ //Takes an array of points, the first is the start point, the last is end point and the ones in
+ //between are the Bezier control points.
+ Bezier: function(pnts) {
+ this.getValue = function(step) {
+ if(step >= 1) return this.p[this.p.length-1]; // if step>=1 we must be at the end of the curve
+ if(step <= 0) return this.p[0]; // if step<=0 we must be at the start of the curve
+ var retVal = new Array(this.p[0].length);
+ for(var k=0;j<this.p[0].length;k++) { retVal[k]=0; }
+ for(var j=0;j<this.p[0].length;j++) {
+ var C=0; var D=0;
+ for(var i=0;i<this.p.length;i++) {
+ C += this.p[i][j] * this.p[this.p.length-1][0]
+ * dojo.math.bernstein(step,this.p.length,i);
+ }
+ for(var l=0;l<this.p.length;l++) {
+ D += this.p[this.p.length-1][0] * dojo.math.bernstein(step,this.p.length,l);
+ }
+ retVal[j] = C/D;
+ }
+ return retVal;
+ }
+ this.p = pnts;
+ return this;
+ },
+
+
+ //Catmull-Rom Spline - allows you to interpolate a smooth curve through a set of points in n-dimensional space
+ CatmullRom : function(pnts,c) {
+ this.getValue = function(step) {
+ var percent = step * (this.p.length-1);
+ var node = Math.floor(percent);
+ var progress = percent - node;
+
+ var i0 = node-1; if(i0 < 0) i0 = 0;
+ var i = node;
+ var i1 = node+1; if(i1 >= this.p.length) i1 = this.p.length-1;
+ var i2 = node+2; if(i2 >= this.p.length) i2 = this.p.length-1;
+
+ var u = progress;
+ var u2 = progress*progress;
+ var u3 = progress*progress*progress;
+
+ var retVal = new Array(this.p[0].length);
+ for(var k=0;k<this.p[0].length;k++) {
+ var x1 = ( -this.c * this.p[i0][k] ) + ( (2 - this.c) * this.p[i][k] ) + ( (this.c-2) * this.p[i1][k] ) + ( this.c * this.p[i2][k] );
+ var x2 = ( 2 * this.c * this.p[i0][k] ) + ( (this.c-3) * this.p[i][k] ) + ( (3 - 2 * this.c) * this.p[i1][k] ) + ( -this.c * this.p[i2][k] );
+ var x3 = ( -this.c * this.p[i0][k] ) + ( this.c * this.p[i1][k] );
+ var x4 = this.p[i][k];
+
+ retVal[k] = x1*u3 + x2*u2 + x3*u + x4;
+ }
+ return retVal;
+
+ }
+
+
+ if(!c) this.c = 0.7;
+ else this.c = c;
+ this.p = pnts;
+
+ return this;
+ },
+
+ // FIXME: This is the bad way to do a partial-arc with 2 points. We need to have the user
+ // supply the radius, otherwise we always get a half-circle between the two points.
+ Arc : function(start, end, ccw) {
+ var center = dojo.math.points.midpoint(start, end);
+ var sides = dojo.math.points.translate(dojo.math.points.invert(center), start);
+ var rad = Math.sqrt(Math.pow(sides[0], 2) + Math.pow(sides[1], 2));
+ var theta = dojo.math.radToDeg(Math.atan(sides[1]/sides[0]));
+ if( sides[0] < 0 ) {
+ theta -= 90;
+ } else {
+ theta += 90;
+ }
+ dojo.math.curves.CenteredArc.call(this, center, rad, theta, theta+(ccw?-180:180));
+ },
+
+ // Creates an arc object, with center and radius (Top of arc = 0 degrees, increments clockwise)
+ // center => 2D point for center of arc
+ // radius => scalar quantity for radius of arc
+ // start => to define an arc specify start angle (default: 0)
+ // end => to define an arc specify start angle
+ CenteredArc : function(center, radius, start, end) {
+ this.center = center;
+ this.radius = radius;
+ this.start = start || 0;
+ this.end = end;
+
+ this.getValue = function(n) {
+ var retVal = new Array(2);
+ var theta = dojo.math.degToRad(this.start+((this.end-this.start)*n));
+
+ retVal[0] = this.center[0] + this.radius*Math.sin(theta);
+ retVal[1] = this.center[1] - this.radius*Math.cos(theta);
+
+ return retVal;
+ }
+
+ return this;
+ },
+
+ // Special case of Arc (start = 0, end = 360)
+ Circle : function(center, radius) {
+ dojo.math.curves.CenteredArc.call(this, center, radius, 0, 360);
+ return this;
+ },
+
+ Path : function() {
+ var curves = [];
+ var weights = [];
+ var ranges = [];
+ var totalWeight = 0;
+
+ this.add = function(curve, weight) {
+ if( weight < 0 ) { dojo.raise("dojo.math.curves.Path.add: weight cannot be less than 0"); }
+ curves.push(curve);
+ weights.push(weight);
+ totalWeight += weight;
+ computeRanges();
+ }
+
+ this.remove = function(curve) {
+ for(var i = 0; i < curves.length; i++) {
+ if( curves[i] == curve ) {
+ curves.splice(i, 1);
+ totalWeight -= weights.splice(i, 1)[0];
+ break;
+ }
+ }
+ computeRanges();
+ }
+
+ this.removeAll = function() {
+ curves = [];
+ weights = [];
+ totalWeight = 0;
+ }
+
+ this.getValue = function(n) {
+ var found = false, value = 0;
+ for(var i = 0; i < ranges.length; i++) {
+ var r = ranges[i];
+ //w(r.join(" ... "));
+ if( n >= r[0] && n < r[1] ) {
+ var subN = (n - r[0]) / r[2];
+ value = curves[i].getValue(subN);
+ found = true;
+ break;
+ }
+ }
+
+ // FIXME: Do we want to assume we're at the end?
+ if( !found ) {
+ value = curves[curves.length-1].getValue(1);
+ }
+
+ for(var j = 0; j < i; j++) {
+ value = dojo.math.points.translate(value, curves[j].getValue(1));
+ }
+ return value;
+ }
+
+ function computeRanges() {
+ var start = 0;
+ for(var i = 0; i < weights.length; i++) {
+ var end = start + weights[i] / totalWeight;
+ var len = end - start;
+ ranges[i] = [start, end, len];
+ start = end;
+ }
+ }
+
+ return this;
+ }
+};
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/curves.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/points.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/points.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/points.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/points.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,47 @@
+/*
+ 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.math.points");
+dojo.require("dojo.math");
+
+// TODO: add a Point class?
+dojo.math.points = {
+ translate: function(a, b) {
+ if( a.length != b.length ) {
+ dojo.raise("dojo.math.translate: points not same size (a:[" + a + "], b:[" + b + "])");
+ }
+ var c = new Array(a.length);
+ for(var i = 0; i < a.length; i++) {
+ c[i] = a[i] + b[i];
+ }
+ return c;
+ },
+
+ midpoint: function(a, b) {
+ if( a.length != b.length ) {
+ dojo.raise("dojo.math.midpoint: points not same size (a:[" + a + "], b:[" + b + "])");
+ }
+ var c = new Array(a.length);
+ for(var i = 0; i < a.length; i++) {
+ c[i] = (a[i] + b[i]) / 2;
+ }
+ return c;
+ },
+
+ invert: function(a) {
+ var b = new Array(a.length);
+ for(var i = 0; i < a.length; i++) { b[i] = -a[i]; }
+ return b;
+ },
+
+ distance: function(a, b) {
+ return Math.sqrt(Math.pow(b[0]-a[0], 2) + Math.pow(b[1]-a[1], 2));
+ }
+};
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/math/points.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,15 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.deprecated("dojo.reflect", "merged into dojo.lang (dojo.lang[type]).", "0.4");
+dojo.kwCompoundRequire({
+ common: ["dojo.reflect.reflection"]
+});
+dojo.provide("dojo.reflect.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/reflection.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/reflection.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/reflection.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/reflection.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,198 @@
+/*
+ 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.deprecated("dojo.reflect", "merged into dojo.lang (dojo.lang[type])", "0.4");
+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");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/reflect/reflection.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/JsonService.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/JsonService.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/JsonService.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/JsonService.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,103 @@
+/*
+ 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.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(typeof args["strictArgChecks"] != "undefined"){
+ this.strictArgChecks = args.strictArgChecks;
+ }
+ }
+ }
+}
+
+dojo.inherits(dojo.rpc.JsonService, dojo.rpc.RpcService);
+
+dojo.lang.extend(dojo.rpc.JsonService, {
+
+ bustCache: false,
+
+ contentType: "application/json-rpc",
+
+ lastSubmissionId: 0,
+
+ callRemote: function(method, params){
+ var deferred = new dojo.rpc.Deferred();
+ this.bind(method, params, deferred);
+ return deferred;
+ },
+
+ bind: function(method, parameters, deferredRequestHandler, url){
+ dojo.io.bind({
+ url: url||this.serviceUrl,
+ postContent: this.createRequest(method, parameters),
+ method: "POST",
+ contentType: this.contentType,
+ 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){ return; }
+ if(obj["Result"]||obj["result"]){
+ return obj["result"]||obj["Result"];
+ }else if(obj["ResultSet"]){
+ return obj["ResultSet"];
+ }else{
+ return obj;
+ }
+ }
+});
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/JsonService.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/RpcService.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/RpcService.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/RpcService.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/RpcService.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,116 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.rpc.RpcService");
+dojo.require("dojo.io.*");
+dojo.require("dojo.json");
+dojo.require("dojo.lang.func");
+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||e);
+ deferredRequestHandler.callback(results);
+ }
+ );
+ return tf;
+ },
+
+
+ generateMethod: function(/*string*/ method, /*array*/ parameters, /*string*/ url){
+ // summary
+ // generate the local bind methods for the remote object
+ return dojo.lang.hitch(this, 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)
+ ){
+ // put error stuff here, no enough params
+ dojo.raise("Invalid number of parameters for remote method.");
+ } else {
+ this.bind(method, arguments, deferredRequestHandler, url);
+ }
+
+ 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.");
+ if(object.methods){
+ dojo.lang.forEach(object.methods, function(m){
+ if(m && m["name"]){
+ dojo.debug("RpcService: Creating Method: this.", m.name, "()");
+ this[m.name] = this.generateMethod( m.name,
+ m.parameters,
+ m["url"]||m["serviceUrl"]||m["serviceURL"]);
+ if(dojo.lang.isFunction(this[m.name])){
+ dojo.debug("RpcService: Successfully created", m.name, "()");
+ }else{
+ dojo.debug("RpcService: Failed to create", m.name, "()");
+ }
+ }
+ }, this);
+ }
+
+ 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
+ });
+ }
+});
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/RpcService.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/YahooService.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/YahooService.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/YahooService.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/YahooService.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,55 @@
+/*
+ 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.rpc.YahooService");
+dojo.require("dojo.rpc.RpcService");
+dojo.require("dojo.rpc.JsonService");
+dojo.require("dojo.json");
+dojo.require("dojo.uri.*");
+dojo.require("dojo.io.ScriptSrcIO");
+
+dojo.rpc.YahooService = function(appId){
+ this.appId = appId;
+ if(!appId){
+ this.appId = "dojotoolkit";
+ dojo.debug( "please initializae the YahooService class with your own",
+ "application ID. Using the default may cause problems during",
+ "deployment of your application");
+ }
+ this.connect(dojo.uri.dojoUri("src/rpc/yahoo.smd"));
+ this.scrictArgChecks = false;
+}
+
+dojo.inherits(dojo.rpc.YahooService, dojo.rpc.JsonService);
+
+dojo.lang.extend(dojo.rpc.YahooService, {
+ strictArgChecks: false,
+
+ bind: function(method, parameters, deferredRequestHandler, url){
+ var params = parameters;
+ if( (dojo.lang.isArrayLike(parameters))&&
+ (parameters.length == 1)){
+ params = parameters[0];
+ }
+ params.output = "json";
+ params.appid= this.appId;
+ dojo.io.bind({
+ url: url||this.serviceUrl,
+ transport: "ScriptSrcTransport",
+ // FIXME: need to get content interpolation fixed
+ content: params,
+ jsonParamName: "callback",
+ mimetype: "text/json",
+ load: this.resultCallback(deferredRequestHandler),
+ error: this.errorCallback(deferredRequestHandler),
+ preventCache: true
+ });
+ }
+});
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/rpc/YahooService.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/selection/Selection.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/selection/Selection.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/selection/Selection.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/selection/Selection.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,425 @@
+/*
+ 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.selection.Selection");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.func");
+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 for growable selections
+
+ 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
+
+ // if true, the selection is treated as an in-order and can grow by ranges, not just by single item
+ isGrowable: true,
+
+ _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(idx, 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
+ idx = this._find(item, true);
+ if(idx > -1) {
+ this.selection.splice(idx, 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(this.isGrowable && 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(!this.isGrowable) { return; }
+
+ 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) {
+ //dojo.debug("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() {
+ if(!this.isGrowable) { return; }
+
+ 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() {
+ if(!this.isGrowable) { return; }
+
+ 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;
+ },
+
+ // select first selectable item
+ selectFirst: function() {
+ this.deselectAll();
+ var idx = 0;
+ while(this.items[idx] && !this.select(this.items[idx])) {
+ idx++;
+ }
+ return this.items[idx] ? true : false;
+ },
+
+ // select last selectable item
+ selectLast: function() {
+ this.deselectAll();
+ var idx = this.items.length-1;
+ while(this.items[idx] && !this.select(this.items[idx])) {
+ idx--;
+ }
+ return this.items[idx] ? true : false;
+ },
+
+ _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);
+ }
+ }
+ },
+
+ 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]);
+ }
+ }
+
+ this.length = this.selection.length;
+ }
+});
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/selection/Selection.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/string.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/string.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/string.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,12 @@
+/*
+ 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.string");
+dojo.require("dojo.string.common");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/Builder.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/Builder.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/Builder.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/Builder.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,105 @@
+/*
+ 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.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;
+ };
+};
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/Builder.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,19 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ common: [
+ "dojo.string",
+ "dojo.string.common",
+ "dojo.string.extras",
+ "dojo.string.Builder"
+ ]
+});
+dojo.provide("dojo.string.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/common.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/common.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/common.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/common.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,87 @@
+/*
+ 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.string.common");
+
+dojo.require("dojo.string");
+
+/**
+ * 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(!str.replace){ return str; }
+ if(!str.length){ return str; }
+ var re = (wh > 0) ? (/^\s+/) : (wh < 0) ? (/\s+$/) : (/^\s+|\s+$/g);
+ return str.replace(re, "");
+}
+
+/**
+ * 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);
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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);
+}
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/string/common.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/text/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/text/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/text/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/text/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,17 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ common: [
+ "dojo.text.String",
+ "dojo.text.Builder"
+ ]
+});
+dojo.provide("dojo.text.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/text/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/undo/Manager.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/undo/Manager.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/undo/Manager.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/undo/Manager.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,198 @@
+/*
+ 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.undo.Manager");
+dojo.require("dojo.lang");
+
+dojo.undo.Manager = function(parent) {
+ this.clear();
+ this._parent = parent;
+};
+dojo.lang.extend(dojo.undo.Manager, {
+ _parent: null,
+ _undoStack: null,
+ _redoStack: null,
+ _currentManager: null,
+
+ canUndo: false,
+ canRedo: false,
+
+ isUndoing: false,
+ isRedoing: false,
+
+ // these events allow you to hook in and update your code (UI?) as necessary
+ onUndo: function(manager, item) {},
+ onRedo: function(manager, item) {},
+
+ // fired when you do *any* undo action, which means you'll have one for every item
+ // in a transaction. this is usually only useful for debugging
+ onUndoAny: function(manager, item) {},
+ onRedoAny: function(manager, item) {},
+
+ _updateStatus: function() {
+ this.canUndo = this._undoStack.length > 0;
+ this.canRedo = this._redoStack.length > 0;
+ },
+
+ clear: function() {
+ this._undoStack = [];
+ this._redoStack = [];
+ this._currentManager = this;
+
+ this.isUndoing = false;
+ this.isRedoing = false;
+
+ this._updateStatus();
+ },
+
+ undo: function() {
+ if(!this.canUndo) { return false; }
+
+ this.endAllTransactions();
+
+ this.isUndoing = true;
+ var top = this._undoStack.pop();
+ if(top instanceof this.constructor) {
+ top.undoAll();
+ } else {
+ top.undo();
+ }
+ if(top.redo) {
+ this._redoStack.push(top);
+ }
+ this.isUndoing = false;
+
+ this._updateStatus();
+ this.onUndo(this, top);
+ if(!(top instanceof this.constructor)) {
+ this.getTop().onUndoAny(this, top);
+ }
+ return true;
+ },
+
+ redo: function() {
+ if(!this.canRedo) { return false; }
+
+ this.isRedoing = true;
+ var top = this._redoStack.pop();
+ if(top instanceof this.constructor) {
+ top.redoAll();
+ } else {
+ top.redo();
+ }
+ this._undoStack.push(top);
+ this.isRedoing = false;
+
+ this._updateStatus();
+ this.onRedo(this, top);
+ if(!(top instanceof this.constructor)) {
+ this.getTop().onRedoAny(this, top);
+ }
+ return true;
+ },
+
+ undoAll: function() {
+ while(this._undoStack.length > 0) {
+ this.undo();
+ }
+ },
+
+ redoAll: function() {
+ while(this._redoStack.length > 0) {
+ this.redo();
+ }
+ },
+
+ push: function(undo, redo /* optional */, description /* optional */) {
+ if(!undo) { return; }
+
+ if(this._currentManager == this) {
+ this._undoStack.push({
+ undo: undo,
+ redo: redo,
+ description: description
+ });
+ } else {
+ this._currentManager.push.apply(this._currentManager, arguments);
+ }
+ // adding a new undo-able item clears out the redo stack
+ this._redoStack = [];
+ this._updateStatus();
+ },
+
+ concat: function(manager) {
+ if ( !manager ) { return; }
+
+ if (this._currentManager == this ) {
+ for(var x=0; x < manager._undoStack.length; x++) {
+ this._undoStack.push(manager._undoStack[x]);
+ }
+ // adding a new undo-able item clears out the redo stack
+ this._redoStack = [];
+ this._updateStatus();
+ } else {
+ this._currentManager.concat.apply(this._currentManager, arguments);
+ }
+ },
+
+ beginTransaction: function(description /* optional */) {
+ if(this._currentManager == this) {
+ var mgr = new dojo.undo.Manager(this);
+ mgr.description = description ? description : "";
+ this._undoStack.push(mgr);
+ this._currentManager = mgr;
+ return mgr;
+ } else {
+ //for nested transactions need to make sure the top level _currentManager is set
+ this._currentManager = this._currentManager.beginTransaction.apply(this._currentManager, arguments);
+ }
+ },
+
+ endTransaction: function(flatten /* optional */) {
+ if(this._currentManager == this) {
+ if(this._parent) {
+ this._parent._currentManager = this._parent;
+ // don't leave empty transactions hangin' around
+ if(this._undoStack.length == 0 || flatten) {
+ var idx = dojo.lang.find(this._parent._undoStack, this);
+ if (idx >= 0) {
+ this._parent._undoStack.splice(idx, 1);
+ //add the current transaction to parents undo stack
+ if (flatten) {
+ for(var x=0; x < this._undoStack.length; x++){
+ this._parent._undoStack.splice(idx++, 0, this._undoStack[x]);
+ }
+ this._updateStatus();
+ }
+ }
+ }
+ return this._parent;
+ }
+ } else {
+ //for nested transactions need to make sure the top level _currentManager is set
+ this._currentManager = this._currentManager.endTransaction.apply(this._currentManager, arguments);
+ }
+ },
+
+ endAllTransactions: function() {
+ while(this._currentManager != this) {
+ this.endTransaction();
+ }
+ },
+
+ // find the top parent of an undo manager
+ getTop: function() {
+ if(this._parent) {
+ return this._parent.getTop();
+ } else {
+ return this;
+ }
+ }
+});
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/undo/Manager.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/uri/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/uri/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/uri/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/uri/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,14 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.kwCompoundRequire({
+ common: ["dojo.uri.Uri", false, false]
+});
+dojo.provide("dojo.uri.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/uri/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,12 @@
+/*
+ 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.validate");
+dojo.require("dojo.validate.common");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/__package__.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/__package__.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/__package__.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/__package__.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,21 @@
+/*
+ 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.require("dojo.validate");
+dojo.kwCompoundRequire({
+ common: ["dojo.validate.check",
+ "dojo.validate.datetime",
+ "dojo.validate.de",
+ "dojo.validate.jp",
+ "dojo.validate.us",
+ "dojo.validate.web"
+ ],
+});
+dojo.provide("dojo.validate.*");
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/check.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/check.js?rev=413300&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/check.js (added)
+++ tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/check.js Sat Jun 10 06:59:28 2006
@@ -0,0 +1,211 @@
+/*
+ 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.validate.check");
+dojo.require("dojo.validate.common");
+
+/**
+ Validates user input of an HTML form based on input profile.
+
+ @param form The form object to be validated.
+ @param profile The input profile that specifies how the form fields are to be validated.
+ @return results An object that contains several methods summarizing the results of the validation.
+*/
+dojo.validate.check = function(form, profile) {
+ // Essentially private properties of results object
+ var missing = [];
+ var invalid = [];
+
+ // results object summarizes the validation
+ var results = {
+ isSuccessful: function() {return ( !this.hasInvalid() && !this.hasMissing() );},
+ hasMissing: function() {return ( missing.length > 0 );},
+ getMissing: function() {return missing;},
+ isMissing: function(elemname) {
+ for (var i = 0; i < missing.length; i++) {
+ if ( elemname == missing[i] ) { return true; }
+ }
+ return false;
+ },
+ hasInvalid: function() {return ( invalid.length > 0 );},
+ getInvalid: function() {return invalid;},
+ isInvalid: function(elemname) {
+ for (var i = 0; i < invalid.length; i++) {
+ if ( elemname == invalid[i] ) { return true; }
+ }
+ return false;
+ }
+ };
+
+ // Filters are applied before fields are validated.
+ // Trim removes white space at the front and end of the fields.
+ if ( profile.trim instanceof Array ) {
+ for (var i = 0; i < profile.trim.length; i++) {
+ var elem = form[profile.trim[i]];
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; }
+ elem.value = elem.value.replace(/(^\s*|\s*$)/g, "");
+ }
+ }
+ // Convert to uppercase
+ if ( profile.uppercase instanceof Array ) {
+ for (var i = 0; i < profile.uppercase.length; i++) {
+ var elem = form[profile.uppercase[i]];
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; }
+ elem.value = elem.value.toUpperCase();
+ }
+ }
+ // Convert to lowercase
+ if ( profile.lowercase instanceof Array ) {
+ for (var i = 0; i < profile.lowercase.length; i++) {
+ var elem = form[profile.lowercase[i]];
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; }
+ elem.value = elem.value.toLowerCase();
+ }
+ }
+ // Uppercase first letter
+ if ( profile.ucfirst instanceof Array ) {
+ for (var i = 0; i < profile.ucfirst.length; i++) {
+ var elem = form[profile.ucfirst[i]];
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; }
+ elem.value = elem.value.replace(/\b\w+\b/g, function(word) { return word.substring(0,1).toUpperCase() + word.substring(1).toLowerCase(); });
+ }
+ }
+ // Remove non digits characters from the input.
+ if ( profile.digit instanceof Array ) {
+ for (var i = 0; i < profile.digit.length; i++) {
+ var elem = form[profile.digit[i]];
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; }
+ elem.value = elem.value.replace(/\D/g, "");
+ }
+ }
+
+ // See if required input fields have values missing.
+ if ( profile.required instanceof Array ) {
+ for (var i = 0; i < profile.required.length; i++) {
+ if ( typeof profile.required[i] != "string" ) { continue; }
+ var elem = form[profile.required[i]];
+ // Are textbox, textarea, or password fields blank.
+ if ( (elem.type == "text" || elem.type == "textarea" || elem.type == "password") && /^\s*$/.test(elem.value) ) {
+ missing[missing.length] = elem.name;
+ }
+ // Does drop-down box have option selected.
+ else if ( (elem.type == "select-one" || elem.type == "select-multiple") && elem.selectedIndex == -1 ) {
+ missing[missing.length] = elem.name;
+ }
+ // Does radio button group (or check box group) have option checked.
+ else if ( elem instanceof Array ) {
+ var checked = false;
+ for (var j = 0; j < elem.length; j++) {
+ if (elem[j].checked) { checked = true; }
+ }
+ if ( !checked ) {
+ missing[missing.length] = elem[0].name;
+ }
+ }
+ }
+ }
+
+ // See if checkbox groups and select boxes have x number of required values.
+ if ( profile.required instanceof Array ) {
+ for (var i = 0; i < profile.required.length; i++) {
+ if ( typeof profile.required[i] != "object" ) { continue; }
+ var elem, numRequired;
+ for (var name in profile.required[i]) {
+ elem = form[name];
+ numRequired = profile.required[i][name];
+ }
+ // case 1: elem is a check box group
+ if ( elem instanceof Array ) {
+ var checked = 0;
+ for (var j = 0; j < elem.length; j++) {
+ if (elem[j].checked) { checked++; }
+ }
+ if ( checked < numRequired ) {
+ missing[missing.length] = elem[0].name;
+ }
+ }
+ // case 2: elem is a select box
+ else if ( elem.type == "select-multiple" ) {
+ var selected = 0;
+ for (var j = 0; j < elem.options.length; j++) {
+ if (elem.options[j].selected) { selected++; }
+ }
+ if ( selected < numRequired ) {
+ missing[missing.length] = elem.name;
+ }
+ }
+ }
+ }
+
+ // Dependant fields are required when the target field is present (not blank).
+ // Todo: Support dependant and target fields that are radio button groups, or select drop-down lists.
+ // Todo: Make the dependancy based on a specific value of the target field.
+ // Todo: allow dependant fields to have several required values, like {checkboxgroup: 3}.
+ if ( typeof profile.dependancies == "object" ) {
+ // properties of dependancies object are the names of dependant fields to be checked
+ for (name in profile.dependancies) {
+ var elem = form[name]; // the dependant element
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; } // limited support
+ if ( /\S+/.test(elem.value) ) { continue; } // has a value already
+ if ( results.isMissing(elem.name) ) { continue; } // already listed as missing
+ var target = form[profile.dependancies[name]];
+ if ( target.type != "text" && target.type != "textarea" && target.type != "password" ) { continue; } // limited support
+ if ( /^\s*$/.test(target.value) ) { continue; } // skip if blank
+ missing[missing.length] = elem.name; // ok the dependant field is missing
+ }
+ }
+
+ // Find invalid input fields.
+ if ( typeof profile.constraints == "object" ) {
+ // constraint properties are the names of fields to be validated
+ for (name in profile.constraints) {
+ var elem = form[name];
+ if ( elem.type != "text" && elem.type != "textarea" && elem.type != "password" ) { continue; }
+ // skip if blank - its optional unless required, in which case it is already listed as missing.
+ if ( /^\s*$/.test(elem.value) ) { continue; }
+
+ var isValid = true;
+ // case 1: constraint value is validation function
+ if ( typeof profile.constraints[name] == "function" ) {
+ isValid = profile.constraints[name](elem.value);
+ }
+ // case 2: constraint value is array, first elem is function, tail is parameters
+ else if ( profile.constraints[name] instanceof Array ) {
+ var isValidSomething = profile.constraints[name][0];
+ var params = profile.constraints[name].slice(1);
+ params.unshift(elem.value);
+ isValid = isValidSomething.apply(null, params);
+ }
+
+ if ( !isValid ) {
+ invalid[invalid.length] = elem.name;
+ }
+ }
+ }
+
+ // Find unequal confirm fields and report them as Invalid.
+ if ( typeof profile.confirm == "object" ) {
+ for (name in profile.confirm) {
+ var elem = form[name]; // the confirm element
+ var target = form[profile.confirm[name]];
+ if ( (elem.type != "text" && elem.type != "textarea" && elem.type != "password")
+ || target.type != elem.type
+ || target.value == elem.value // it's valid
+ || results.isInvalid(elem.name) // already listed as invalid
+ || /^\s*$/.test(target.value) ) // skip if blank - only confirm if target has a value
+ {
+ continue;
+ }
+ invalid[invalid.length] = elem.name;
+ }
+ }
+
+ return results;
+}
Propchange: tapestry/tapestry4/trunk/framework/src/js/dojo/src/validate/check.js
------------------------------------------------------------------------------
svn:eol-style = native