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/09/29 05:43:06 UTC
svn commit: r451106 [19/40] - in /tapestry/tapestry4/trunk: ./
tapestry-framework/src/java/org/apache/tapestry/asset/
tapestry-framework/src/js/dojo/ tapestry-framework/src/js/dojo/src/
tapestry-framework/src/js/dojo/src/animation/ tapestry-framework/s...
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/html.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/html.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/html.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/html.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,631 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.html");
+
+dojo.require("dojo.gfx.color");
+dojo.require("dojo.lfx.Animation");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.html.display");
+dojo.require("dojo.html.color");
+dojo.require("dojo.html.layout");
+
+dojo.lfx.html._byId = function(nodes){
+ if(!nodes){ return []; }
+ if(dojo.lang.isArrayLike(nodes)){
+ if(!nodes.alreadyChecked){
+ var n = [];
+ dojo.lang.forEach(nodes, function(node){
+ n.push(dojo.byId(node));
+ });
+ n.alreadyChecked = true;
+ return n;
+ }else{
+ return nodes;
+ }
+ }else{
+ var n = [];
+ n.push(dojo.byId(nodes));
+ n.alreadyChecked = true;
+ return n;
+ }
+}
+
+dojo.lfx.html.propertyAnimation = function( /*DOMNode*/ nodes,
+ /*Array*/ propertyMap,
+ /*int*/ duration,
+ /*function*/ easing,
+ /*Object*/ handlers){
+ nodes = dojo.lfx.html._byId(nodes);
+
+ var targs = {
+ "propertyMap": propertyMap,
+ "nodes": nodes,
+ "duration": duration,
+ "easing": easing||dojo.lfx.easeDefault
+ };
+
+ var setEmUp = function(args){
+ if(args.nodes.length==1){
+ // FIXME: we're only supporting start-value filling when one node is
+ // passed
+
+ var pm = args.propertyMap;
+ if(!dojo.lang.isArray(args.propertyMap)){
+ // it's stupid to have to pack an array with a set of objects
+ // when you can just pass in an object list
+ var parr = [];
+ for(var pname in pm){
+ pm[pname].property = pname;
+ parr.push(pm[pname]);
+ }
+ pm = args.propertyMap = parr;
+ }
+ dojo.lang.forEach(pm, function(prop){
+ if(dj_undef("start", prop)){
+ if(prop.property != "opacity"){
+ prop.start = parseInt(dojo.html.getComputedStyle(args.nodes[0], prop.property));
+ }else{
+ prop.start = dojo.html.getOpacity(args.nodes[0]);
+ }
+ }
+ });
+ }
+ }
+
+ var coordsAsInts = function(coords){
+ var cints = [];
+ dojo.lang.forEach(coords, function(c){
+ cints.push(Math.round(c));
+ });
+ return cints;
+ }
+
+ var setStyle = function(n, style){
+ n = dojo.byId(n);
+ if(!n || !n.style){ return; }
+ for(var s in style){
+ if(s == "opacity"){
+ dojo.html.setOpacity(n, style[s]);
+ }else{
+ n.style[s] = style[s];
+ }
+ }
+ }
+
+ var propLine = function(properties){
+ this._properties = properties;
+ this.diffs = new Array(properties.length);
+ dojo.lang.forEach(properties, function(prop, i){
+ // calculate the end - start to optimize a bit
+ if(dojo.lang.isFunction(prop.start)){
+ prop.start = prop.start(prop, i);
+ }
+ if(dojo.lang.isFunction(prop.end)){
+ prop.end = prop.end(prop, i);
+ }
+ if(dojo.lang.isArray(prop.start)){
+ // don't loop through the arrays
+ this.diffs[i] = null;
+ }else if(prop.start instanceof dojo.gfx.color.Color){
+ // save these so we don't have to call toRgb() every getValue() call
+ prop.startRgb = prop.start.toRgb();
+ prop.endRgb = prop.end.toRgb();
+ }else{
+ this.diffs[i] = prop.end - prop.start;
+ }
+ }, this);
+
+ this.getValue = function(n){
+ var ret = {};
+ dojo.lang.forEach(this._properties, function(prop, i){
+ var value = null;
+ if(dojo.lang.isArray(prop.start)){
+ // FIXME: what to do here?
+ }else if(prop.start instanceof dojo.gfx.color.Color){
+ value = (prop.units||"rgb") + "(";
+ for(var j = 0 ; j < prop.startRgb.length ; j++){
+ value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : "");
+ }
+ value += ")";
+ }else{
+ value = ((this.diffs[i]) * n) + prop.start + (prop.property != "opacity" ? prop.units||"px" : "");
+ }
+ ret[dojo.html.toCamelCase(prop.property)] = value;
+ }, this);
+ return ret;
+ }
+ }
+
+ var anim = new dojo.lfx.Animation({
+ beforeBegin: function(){
+ setEmUp(targs);
+ anim.curve = new propLine(targs.propertyMap);
+ },
+ onAnimate: function(propValues){
+ dojo.lang.forEach(targs.nodes, function(node){
+ setStyle(node, propValues);
+ });
+ }
+ },
+ targs.duration,
+ null,
+ targs.easing
+ );
+ if(handlers){
+ for(var x in handlers){
+ if(dojo.lang.isFunction(handlers[x])){
+ anim.connect(x, anim, handlers[x]);
+ }
+ }
+ }
+
+ return anim; // dojo.lfx.Animation
+}
+
+dojo.lfx.html._makeFadeable = function(nodes){
+ var makeFade = function(node){
+ if(dojo.render.html.ie){
+ // only set the zoom if the "tickle" value would be the same as the
+ // default
+ if( (node.style.zoom.length == 0) &&
+ (dojo.html.getStyle(node, "zoom") == "normal") ){
+ // make sure the node "hasLayout"
+ // NOTE: this has been tested with larger and smaller user-set text
+ // sizes and works fine
+ node.style.zoom = "1";
+ // node.style.zoom = "normal";
+ }
+ // don't set the width to auto if it didn't already cascade that way.
+ // We don't want to f anyones designs
+ if( (node.style.width.length == 0) &&
+ (dojo.html.getStyle(node, "width") == "auto") ){
+ node.style.width = "auto";
+ }
+ }
+ }
+ if(dojo.lang.isArrayLike(nodes)){
+ dojo.lang.forEach(nodes, makeFade);
+ }else{
+ makeFade(nodes);
+ }
+}
+
+dojo.lfx.html.fade = function(/*Array*/ nodes, /*Object*/values, /*Decimal?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
+ // values: object { start: Decimal?, end: Decimal? }
+ nodes = dojo.lfx.html._byId(nodes);
+ var props = { property: "opacity" };
+ if(!dj_undef("start", values)){
+ props.start = values.start;
+ }else{
+ props.start = function(){ return dojo.html.getOpacity(nodes[0]); };
+ }
+
+ if(!dj_undef("end", values)){
+ props.end = values.end;
+ }else{
+ dojo.raise("dojo.lfx.html.fade needs an end value");
+ }
+
+ var anim = dojo.lfx.propertyAnimation(nodes, [ props ], duration, easing);
+ anim.connect("beforeBegin", function(){
+ dojo.lfx.html._makeFadeable(nodes);
+ });
+ if(callback){
+ anim.connect("onEnd", function(){ callback(nodes, anim); });
+ }
+
+ return anim; // dojo.lfx.Animation
+}
+
+dojo.lfx.html.fadeIn = function(nodes, duration, easing, callback){
+ return dojo.lfx.html.fade(nodes, { end: 1 }, duration, easing, callback);
+}
+
+dojo.lfx.html.fadeOut = function(nodes, duration, easing, callback){
+ return dojo.lfx.html.fade(nodes, { end: 0 }, duration, easing, callback);
+}
+
+dojo.lfx.html.fadeShow = function(nodes, duration, easing, callback){
+ nodes=dojo.lfx.html._byId(nodes);
+ dojo.lang.forEach(nodes, function(node){
+ dojo.html.setOpacity(node, 0.0);
+ });
+
+ var anim = dojo.lfx.html.fadeIn(nodes, duration, easing, callback);
+ anim.connect("beforeBegin", function(){
+ if(dojo.lang.isArrayLike(nodes)){
+ dojo.lang.forEach(nodes, dojo.html.show);
+ }else{
+ dojo.html.show(nodes);
+ }
+ });
+
+ return anim;
+}
+
+dojo.lfx.html.fadeHide = function(nodes, duration, easing, callback){
+ var anim = dojo.lfx.html.fadeOut(nodes, duration, easing, function(){
+ if(dojo.lang.isArrayLike(nodes)){
+ dojo.lang.forEach(nodes, dojo.html.hide);
+ }else{
+ dojo.html.hide(nodes);
+ }
+ if(callback){ callback(nodes, anim); }
+ });
+
+ return anim;
+}
+
+dojo.lfx.html.wipeIn = function(/*Array*/ nodes, /*Decimal?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var oprop = { overflow: null };
+
+ // for FF, the node has to be rendered before node.scrollHeight has a value
+ node.style.visibility = "hidden";
+ node.style.display = "block";
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ { "height": {
+ start: 1, // 0 causes IE to display the whole panel
+ end: function(){ return node.scrollHeight; }
+ }
+ },
+ duration,
+ easing);
+
+ anim.connect("beforeBegin", function(){
+ oprop.overflow = dojo.html.getStyle(node, "overflow");
+ with(node.style){
+ if(oprop.overflow == "visible") {
+ overflow = "hidden";
+ }
+ visibility = "visible";
+ height = "1px"; // 0 causes IE to display the whole panel
+ }
+ dojo.html.show(node);
+ });
+
+ anim.connect("onEnd", function(){
+ with(node.style){
+ overflow = oprop.overflow;
+ // height = "auto";
+ height = "";
+ visibility = "visible";
+ }
+ if(callback){ callback(node, anim); }
+ });
+ anims.push(anim);
+ });
+
+ return dojo.lfx.combine(anims); // dojo.lfx.Combine
+}
+
+dojo.lfx.html.wipeOut = function(/*Array*/ nodes, /*Decimal?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var oprop = { overflow: null };
+ var anim = dojo.lfx.propertyAnimation(node,
+ { "height": {
+ start: function(){ return dojo.html.getContentBox(node).height; },
+ end: 1 // 0 causes IE to display the whole panel
+ }
+ },
+ duration,
+ easing,
+ {
+ "beforeBegin": function(){
+ oprop.overflow = dojo.html.getStyle(node, "overflow");
+ if(oprop.overflow == "visible") {
+ node.style.overflow = "hidden";
+ }
+ node.style.visibility = "visible";
+ dojo.html.show(node);
+ },
+
+ "onEnd": function(){
+ // dojo.html.hide(node);
+ with(node.style){
+ overflow = oprop.overflow;
+ visibility = "hidden";
+ height = "";
+ }
+ if(callback){ callback(node, anim); }
+ }
+ }
+ );
+ anims.push(anim);
+ });
+
+ return dojo.lfx.combine(anims); // dojo.lfx.Combine
+}
+
+dojo.lfx.html.slideTo = function(/*Array*/ nodes, /*Object*/ coords, /*Decimal?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
+ // coords: object { top: Decimal?, left: Decimal? }
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+ var compute = dojo.html.getComputedStyle;
+
+ if(dojo.lang.isArray(coords)){
+ /* coords: Array
+ pId: a */
+ dojo.deprecated('dojo.lfx.html.slideTo(node, array)', 'use dojo.lfx.html.slideTo(node, {top: value, left: value});', '0.5');
+ coords = { top: coords[0], left: coords[1] };
+ }
+ dojo.lang.forEach(nodes, function(node){
+ var top = null;
+ var left = null;
+
+ var init = (function(){
+ var innerNode = node;
+ return function(){
+ var pos = compute(innerNode, 'position');
+ top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0);
+ left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0);
+
+ if (!dojo.lang.inArray(['absolute', 'relative'], pos)) {
+ var ret = dojo.html.abs(innerNode, true);
+ dojo.html.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;");
+ top = ret.y;
+ left = ret.x;
+ }
+ }
+ })();
+ init();
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ { "top": { start: top, end: (coords.top||0) },
+ "left": { start: left, end: (coords.left||0) }
+ },
+ duration,
+ easing,
+ { "beforeBegin": init }
+ );
+
+ if(callback){
+ anim.connect("onEnd", function(){ callback(nodes, anim); });
+ }
+
+ anims.push(anim);
+ });
+
+ return dojo.lfx.combine(anims); // dojo.lfx.Combine
+}
+
+dojo.lfx.html.slideBy = function(/*Array*/ nodes, /*Object*/ coords, /*Decimal?*/ duration, /*Function?*/ easing, /*Function?*/ callback){
+ // coords: object { top: Decimal?, left: Decimal? }
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+ var compute = dojo.html.getComputedStyle;
+
+ if(dojo.lang.isArray(coords)){
+ /* coords: Array
+ pId: a */
+ dojo.deprecated('dojo.lfx.html.slideBy(node, array)', 'use dojo.lfx.html.slideBy(node, {top: value, left: value});', '0.5');
+ coords = { top: coords[0], left: coords[1] };
+ }
+
+ dojo.lang.forEach(nodes, function(node){
+ var top = null;
+ var left = null;
+
+ var init = (function(){
+ var innerNode = node;
+ return function(){
+ var pos = compute(innerNode, 'position');
+ top = (pos == 'absolute' ? node.offsetTop : parseInt(compute(node, 'top')) || 0);
+ left = (pos == 'absolute' ? node.offsetLeft : parseInt(compute(node, 'left')) || 0);
+
+ if (!dojo.lang.inArray(['absolute', 'relative'], pos)) {
+ var ret = dojo.html.abs(innerNode, true);
+ dojo.html.setStyleAttributes(innerNode, "position:absolute;top:"+ret.y+"px;left:"+ret.x+"px;");
+ top = ret.y;
+ left = ret.x;
+ }
+ }
+ })();
+ init();
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ {
+ "top": { start: top, end: top+(coords.top||0) },
+ "left": { start: left, end: left+(coords.left||0) }
+ },
+ duration,
+ easing).connect("beforeBegin", init);
+
+ if(callback){
+ anim.connect("onEnd", function(){ callback(nodes, anim); });
+ }
+
+ anims.push(anim);
+ });
+
+ return dojo.lfx.combine(anims); // dojo.lfx.Combine
+}
+
+dojo.lfx.html.explode = function(start, endNode, duration, easing, callback){
+ var h = dojo.html;
+ start = dojo.byId(start);
+ endNode = dojo.byId(endNode);
+ var startCoords = h.toCoordinateObject(start, true);
+ var outline = document.createElement("div");
+ h.copyStyle(outline, endNode);
+ if (endNode.explodeClassName) { outline.className = endNode.explodeClassName; }
+ with(outline.style){
+ position = "absolute";
+ display = "none";
+ // border = "1px solid black";
+ }
+ dojo.body().appendChild(outline);
+
+ with(endNode.style){
+ visibility = "hidden";
+ display = "block";
+ }
+ var endCoords = h.toCoordinateObject(endNode, true);
+ with(endNode.style){
+ display = "none";
+ visibility = "visible";
+ }
+
+ var props = { opacity: { start: 0.5, end: 1.0 } };
+ dojo.lang.forEach(["height", "width", "top", "left"], function(type){
+ props[type] = { start: startCoords[type], end: endCoords[type] }
+ });
+
+ var anim = new dojo.lfx.propertyAnimation(outline,
+ props,
+ duration,
+ easing,
+ {
+ "beforeBegin": function(){
+ h.setDisplay(outline, "block");
+ },
+ "onEnd": function(){
+ h.setDisplay(endNode, "block");
+ outline.parentNode.removeChild(outline);
+ }
+ }
+ );
+
+ if(callback){
+ anim.connect("onEnd", function(){ callback(endNode, anim); });
+ }
+ return anim;
+}
+
+dojo.lfx.html.implode = function(startNode, end, duration, easing, callback){
+ var h = dojo.html;
+ startNode = dojo.byId(startNode);
+ end = dojo.byId(end);
+ var startCoords = dojo.html.toCoordinateObject(startNode, true);
+ var endCoords = dojo.html.toCoordinateObject(end, true);
+
+ var outline = document.createElement("div");
+ dojo.html.copyStyle(outline, startNode);
+ if (startNode.explodeClassName) { outline.className = startNode.explodeClassName; }
+ dojo.html.setOpacity(outline, 0.3);
+ with(outline.style){
+ position = "absolute";
+ display = "none";
+ backgroundColor = h.getStyle(startNode, "background-color").toLowerCase();
+ }
+ dojo.body().appendChild(outline);
+
+ var props = { opacity: { start: 1.0, end: 0.5 } };
+ dojo.lang.forEach(["height", "width", "top", "left"], function(type){
+ props[type] = { start: startCoords[type], end: endCoords[type] }
+ });
+
+ var anim = new dojo.lfx.propertyAnimation(outline,
+ props,
+ duration,
+ easing,
+ {
+ "beforeBegin": function(){
+ dojo.html.hide(startNode);
+ dojo.html.show(outline);
+ },
+ "onEnd": function(){
+ outline.parentNode.removeChild(outline);
+ }
+ }
+ );
+
+ if(callback){
+ anim.connect("onEnd", function(){ callback(startNode, anim); });
+ }
+ return anim;
+}
+
+dojo.lfx.html.highlight = function(nodes, startColor, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var color = dojo.html.getBackgroundColor(node);
+ var bg = dojo.html.getStyle(node, "background-color").toLowerCase();
+ var bgImage = dojo.html.getStyle(node, "background-image");
+ var wasTransparent = (bg == "transparent" || bg == "rgba(0, 0, 0, 0)");
+ while(color.length > 3) { color.pop(); }
+
+ var rgb = new dojo.gfx.color.Color(startColor);
+ var endRgb = new dojo.gfx.color.Color(color);
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ { "background-color": { start: rgb, end: endRgb } },
+ duration,
+ easing,
+ {
+ "beforeBegin": function(){
+ if(bgImage){
+ node.style.backgroundImage = "none";
+ }
+ node.style.backgroundColor = "rgb(" + rgb.toRgb().join(",") + ")";
+ },
+ "onEnd": function(){
+ if(bgImage){
+ node.style.backgroundImage = bgImage;
+ }
+ if(wasTransparent){
+ node.style.backgroundColor = "transparent";
+ }
+ if(callback){
+ callback(node, anim);
+ }
+ }
+ }
+ );
+
+ anims.push(anim);
+ });
+ return dojo.lfx.combine(anims);
+}
+
+dojo.lfx.html.unhighlight = function(nodes, endColor, duration, easing, callback){
+ nodes = dojo.lfx.html._byId(nodes);
+ var anims = [];
+
+ dojo.lang.forEach(nodes, function(node){
+ var color = new dojo.gfx.color.Color(dojo.html.getBackgroundColor(node));
+ var rgb = new dojo.gfx.color.Color(endColor);
+
+ var bgImage = dojo.html.getStyle(node, "background-image");
+
+ var anim = dojo.lfx.propertyAnimation(node,
+ { "background-color": { start: color, end: rgb } },
+ duration,
+ easing,
+ {
+ "beforeBegin": function(){
+ if(bgImage){
+ node.style.backgroundImage = "none";
+ }
+ node.style.backgroundColor = "rgb(" + color.toRgb().join(",") + ")";
+ },
+ "onEnd": function(){
+ if(callback){
+ callback(node, anim);
+ }
+ }
+ }
+ );
+ anims.push(anim);
+ });
+ return dojo.lfx.combine(anims);
+}
+
+dojo.lang.mixin(dojo.lfx, dojo.lfx.html);
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/html.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/rounded.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/rounded.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/rounded.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/rounded.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,509 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.rounded");
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.html.common");
+dojo.require("dojo.html.style");
+dojo.require("dojo.html.display");
+dojo.require("dojo.html.layout");
+
+/* Port of curvyCorners, by Cameron Cooke and Tim Hutchison.
+ * Original port done by Brian Lucas.
+ * Refactor and function by trt.
+ */
+dojo.lfx.rounded = function(/* object */settings){
+ // setup
+ var options={
+ validTags:settings.validTags || ["div"], // tags we can apply this to
+ autoPad:settings.autoPad!=null ? settings.autoPad : true, // automatically pad
+ antiAlias:settings.antiAlias!=null ? settings.antiAlias : true, // anti-alias corners
+ radii:{ // corner radii
+ tl:(settings.tl && settings.tl.radius!=null) ? settings.tl.radius:5,
+ tr:(settings.tr && settings.tr.radius!=null) ? settings.tr.radius:5,
+ bl:(settings.bl && settings.bl.radius!=null) ? settings.bl.radius:5,
+ br:(settings.br && settings.br.radius!=null) ? settings.br.radius:5
+ }
+ };
+
+ // get the node list to operate on.
+ var nodes;
+ if(typeof(arguments[1]) == "string"){
+ // a CSS classname was passed, grab a node list.
+ nodes=dojo.html.getElementsByClass(arguments[1]);
+ } else if(dojo.lang.isArrayLike(arguments[1])){
+ // we assume that the second argument is an array of nodes to apply this to.
+ nodes=arguments[1];
+ for(var i=0; i<nodes.length; i++){ nodes[i]=dojo.byId(nodes[i]); }
+ }
+ if(nodes.length == 0) return; // don't bother.
+
+ ////////////////////////////////////////////////////////////////////
+ for(var i=0; i<nodes.length; i++){
+ dojo.lfx.rounded.applyCorners(options, nodes[i]);
+ }
+};
+
+// can call this directly if one wants.
+dojo.lfx.rounded.applyCorners = function(/* object */options, /* HTMLElement */node){
+ var top = null;
+ var bottom = null;
+ var contentNode = null;
+ var fns=dojo.lfx.rounded._fns;
+
+ // node details
+ var width = node.offsetWidth;
+ var height = node.offsetHeight;
+ var borderWidth = parseInt(dojo.html.getComputedStyle(node, "border-top-width"));
+ var borderColor = dojo.html.getComputedStyle(node, "border-top-color");
+ var color = dojo.html.getComputedStyle(node, "background-color");
+ var bgImage = dojo.html.getComputedStyle(node, "background-image");
+ var position = dojo.html.getComputedStyle(node, "position");
+ var padding = parseInt(dojo.html.getComputedStyle(node, "padding-top"));
+
+ // formatting details
+ // TODO: use Dojo equivilents for these if exists.
+ var format={
+ height : height,
+ width : width,
+ borderWidth : borderWidth,
+ color : fns.getRGB(color),
+ padding : padding,
+ borderColor : fns.getRGB(borderColor),
+ borderString : borderWidth + "px" + " solid " + fns.getRGB(borderColor),
+ bgImage : ((bgImage != "none")? bgImage : ""),
+ content : node.innerHTML
+ };
+
+ if(!dojo.html.isPositionAbsolute(node)){ node.style.position="relative"; }
+ node.style.padding="0px";
+ if(dojo.render.html.ie && width=="auto" && height=="auto"){ node.style.width="100%"; }
+ if(options.autoPad && format.padding>0){
+ node.innerHTML="";
+ }
+
+ var topHeight=Math.max(options.radii.tl, options.radii.tr);
+ var bottomHeight=Math.max(options.radii.bl, options.radii.br);
+
+ // build the containers.
+ if(options.radii.tl || options.radii.tr){
+ top = document.createElement("div");
+ top.style.width="100%";
+ top.style.fontSize="1px";
+ top.style.overflow="hidden";
+ top.style.position="absolute";
+ top.style.paddingLeft=format.borderWidth+"px";
+ top.style.paddingRight=format.borderWidth+"px";
+ top.style.height=topHeight+"px";
+ top.style.top=(0-topHeight)+"px";
+ top.style.left=(0-format.borderWidth)+"px";
+ node.appendChild(top);
+ }
+ if(options.radii.bl || options.radii.br){ // bottom
+ bottom = document.createElement("div");
+ bottom.style.width="100%";
+ bottom.style.fontSize="1px";
+ bottom.style.overflow="hidden";
+ bottom.style.position="absolute";
+ bottom.style.paddingLeft=format.borderWidth+"px";
+ bottom.style.paddingRight=format.borderWidth+"px";
+ bottom.style.height=bottomHeight+"px";
+ bottom.style.bottom=(0-bottomHeight)+"px";
+ bottom.style.left=(0-format.borderWidth)+"px";
+ node.appendChild(bottom);
+ }
+
+ // turn off the borders
+ if(top){ node.style.borderTopWidth = "0px"; }
+ if(bottom){ node.style.borderBottomWidth = "0px"; }
+
+ // do the corners
+ var corners = ["tr", "tl", "br", "bl"];
+ for(var i=0; i<corners.length; i++){
+ var cc=corners[i];
+ if(options.radii[cc]==0){
+ // fill up the space with a div.
+ if((cc.charAt(0)=="t"&&top) || (cc.charAt(0)=="b"&&bottom)){
+ var corner=document.createElement("div");
+ corner.style.position="relative";
+ corner.style.fontSize="1px;";
+ corner.style.overflow="hidden";
+ if(format.bgImage==""){
+ corner.style.backgroundColor=format.color;
+ } else {
+ corner.style.backgroundImage=format.bgImage;
+ }
+ switch(cc){
+ case "tl":{
+ corner.style.height=topHeight-format.borderWidth+"px";
+ corner.style.marginRight=options.radii[cc]-(format.borderWidth*2)+"px";
+ corner.style.borderLeft=format.borderString;
+ corner.style.borderTop=format.borderString;
+ corner.style.left=-format.borderWidth+"px";
+ break;
+ }
+ case "tr":{
+ corner.style.height=topHeight-format.borderWidth+"px";
+ corner.style.marginLeft=options.radii[cc]-(format.borderWidth*2)+"px";
+ corner.style.borderRight=format.borderString;
+ corner.style.borderTop=format.borderString;
+ corner.style.backgroundPosition="-"+(topHeight-format.borderWidth)+"px 0px";
+ corner.style.left=format.borderWidth+"px";
+ break;
+ }
+ case "bl":{
+ corner.style.height=bottomHeight-format.borderWidth+"px";
+ corner.style.marginRight=options.radii[cc]-(format.borderWidth*2)+"px";
+ corner.style.borderLeft=format.borderString;
+ corner.style.borderBottom=format.borderString;
+ corner.style.left=format.borderWidth+"px";
+ corner.style.backgroundPosition="-"+format.borderWidth+"px -"+(format.height+(bottomHeight+format.borderWidth))+"px";
+ break;
+ }
+ case "br":{
+ corner.style.height=bottomHeight-format.borderWidth+"px";
+ corner.style.marginLeft=options.radii[cc]-(format.borderWidth*2)+"px";
+ corner.style.borderRight=format.borderString;
+ corner.style.borderBottom=format.borderString;
+ corner.style.left=format.borderWidth+"px";
+ corner.style.backgroundPosition="-"+(bottomHeight+format.borderWidth)+"px -"+(format.height+(bottomHeight+format.borderWidth))+"px";
+ break;
+ }
+ }
+ }
+ } else {
+ // NB: this version will not do the caching they built into the
+ // current version of curvyCorners.
+ var corner=document.createElement("div");
+ corner.style.height=options.radii[cc]+"px";
+ corner.style.width=options.radii[cc]+"px";
+ corner.style.position="absolute";
+ corner.style.fontSize="1px";
+ corner.style.overflow="hidden";
+
+ var borderRadius=Math.floor(options.radii[cc] - format.borderWidth);
+ for(var x=0, j=options.radii[cc]; x<j; x++){
+ // figure out y coords
+ var y1=Math.floor(Math.sqrt(Math.pow(borderRadius,2)-Math.pow((x+1),2)))-1;
+ if((x+1) >= borderRadius){ var y1=-1; }
+ var y2=Math.ceil(Math.sqrt(Math.pow(borderRadius,2)-Math.pow(x,2)));
+ if(x >= borderRadius){ y2=-1; }
+ var y3=Math.floor(Math.sqrt(Math.pow(j,2)-Math.pow((x+1),2)))-1;
+ if((x+1) >= j){ y3=-1; }
+ var y4=Math.ceil(Math.sqrt(Math.pow(j, 2)-Math.pow(x, 2)));
+ if(x >= j){ y4=-1; }
+
+ // start drawing
+ if(y1 > -1){
+ fns.draw(x, 0, format.color, 100, (y1+1), corner, -1, j, topHeight, format);
+ }
+
+ // cycle the y-axis
+ for(var y=(y1+1); y<y2; y++){
+ if(options.antiAlias){
+ if(format.bgImage != ""){
+ var fract=fns.fraction(x, y, borderRadius)*100;
+ if(fract < 30){
+ fns.draw(x, y, format.borderColor, 100, 1, corner, 0, options.radii[cc], topHeight, format);
+ } else {
+ fns.draw(x, y, format.borderColor, 100, 1, corner, -1, options.radii[cc], topHeight, format);
+ }
+ } else {
+ var clr=fns.blend(format.color, format.borderColor, fns.fraction(x, y, borderRadius));
+ fns.draw(x, y, clr, 100, 1, corner, 0, options.radii[cc], topHeight, format);
+ }
+ }
+ }
+
+ // bar for the border
+ if(options.antiAlias){
+ if(y3 >= y2){
+ if(y2 == -1){ y2 = 0; }
+ fns.draw(x, y2, format.borderColor, 100, (y3-y2+1), corner, 0, 0, topHeight, format)
+ } else {
+ if(y3 >= y1){
+ fns.draw(x, (y1+1), format.borderColor, 100, (y3-y1), corner, 0, 0, topHeight, format);
+ }
+ }
+ for(var y=(y3+1); y<y4; y++){
+ fns.draw(x, y, format.borderColor, (fns.fraction(x, y, j)*100), 1, corner, (format.borderWidth>0 ? 0:-1), options.radii[cc], topHeight, format);
+ }
+ } else {
+ y3=y1;
+ }
+ }
+
+ // reposition pixels if not the bottom right.
+ if(cc != "br"){
+ for(var t=0, k=corner.childNodes.length; t<k; t++){
+ var bar=corner.childNodes[t];
+ var barTop = parseInt(dojo.html.getComputedStyle(bar, "top"));
+ var barLeft = parseInt(dojo.html.getComputedStyle(bar, "left"));
+ var barHeight = parseInt(dojo.html.getComputedStyle(bar, "height"));
+
+ // reposition.
+ if(cc.charAt(1)=="l"){
+ bar.style.left = (options.radii[cc]-barLeft-1)+"px";
+ }
+ if(cc=="tr"){
+ bar.style.top = (options.radii[cc]-barHeight-barTop)+"px";
+ bar.style.backgroundPosition="-"+Math.abs((format.width-options.radii[cc]+format.borderWidth)+barLeft)
+ +"px -"+Math.abs(options.radii[cc]-barHeight-barTop-format.borderWidth)+"px";
+ } else if (cc=="tl"){
+ bar.style.top = (options.radii[cc]-barHeight-barTop)+"px";
+ bar.style.backgroundPosition="-"+Math.abs((options.radii[cc]-barLeft-1)-format.borderWidth)
+ +"px -"+Math.abs(options.radii[cc]-barHeight-barTop-format.borderWidth)+"px";
+ } else {
+ bar.style.backgroundPosition="-"+Math.abs((options.radii[cc]+barLeft)+format.borderWidth)
+ +"px -"+Math.abs((format.height+options.radii[cc]+barTop)-format.borderWidth)+"px";
+ }
+ }
+ }
+ }
+
+ if(corner){
+ // position the container.
+ var psn=[];
+ if(cc.charAt(0)=="t"){ psn.push("top"); }
+ else { psn.push("bottom"); }
+ if(cc.charAt(1)=="l"){ psn.push("left"); }
+ else { psn.push("right"); }
+
+ if(corner.style.position=="absolute"){
+ for(var z=0; z<psn.length; z++){ corner.style[psn[z]]="0px"; }
+ }
+
+ if(psn[0]=="top"){
+ if(top){ top.appendChild(corner); }
+ } else {
+ if(bottom){ bottom.appendChild(corner); }
+ }
+ }
+ }
+
+ // draw fillers.
+ var diff={
+ t: Math.abs(options.radii.tl - options.radii.tr),
+ b: Math.abs(options.radii.bl - options.radii.br)
+ };
+ for(var z in diff){
+ var smaller=(options.radii[z+"l"]<options.radii[z+"r"] ? z+"l":z+"r");
+ var filler=document.createElement("div");
+ filler.style.height=diff[z]+"px";
+ filler.style.width=options.radii[smaller]+"px";
+ filler.style.position="absolute";
+ filler.style.fontSize="1px";
+ filler.style.overflow="hidden";
+ filler.style.backgroundColor=format.color;
+ switch(smaller){
+ case "tl":{
+ filler.style.bottom="0px";
+ filler.style.left="0px";
+ filler.style.borderLeft=format.borderString;
+ top.appendChild(filler);
+ break;
+ }
+ case "tr":{
+ filler.style.bottom="0px";
+ filler.style.right="0px";
+ filler.style.borderRight=format.borderString;
+ top.appendChild(filler);
+ break;
+ }
+ case "bl":{
+ filler.style.top="0px";
+ filler.style.left="0px";
+ filler.style.borderLeft=format.borderString;
+ bottom.appendChild(filler);
+ break;
+ }
+ case "br":{
+ filler.style.top="0px";
+ filler.style.right="0px";
+ filler.style.borderRight=format.borderString;
+ bottom.appendChild(filler);
+ break;
+ }
+ }
+
+ var fillBar=document.createElement("div");
+ fillBar.style.position="relative";
+ fillBar.style.fontSize="1px";
+ fillBar.style.overflow="hidden";
+ fillBar.style.backgroundColor=format.color;
+ fillBar.style.backgroundImage=format.bgImage;
+ if(z=="t"){
+ if(top){
+ if(options.radii.tl && options.radii.tr){
+ fillBar.style.height=(topHeight-format.borderWidth) + "px";
+ fillBar.style.marginLeft=(options.radii.tl-format.borderWidth)+"px";
+ fillBar.style.marginRight=(options.radii.tr-format.borderWidth)+"px";
+ fillBar.style.borderTop=format.borderString;
+ if(format.bgImage!=""){
+ fillBar.style.backgroundPosition="-"+(topHeight+format.borderWidth)+"px 0px";
+ }
+ }
+ top.appendChild(fillBar);
+ }
+ } else {
+ if(bottom){
+ if(options.radii.bl && options.radii.br){
+ fillBar.style.height=(bottomHeight-format.borderWidth) + "px";
+ fillBar.style.marginLeft=(options.radii.bl-format.borderWidth)+"px";
+ fillBar.style.marginRight=(options.radii.br-format.borderWidth)+"px";
+ fillBar.style.borderBottom=format.borderString;
+ if(format.bgImage!=""){
+ fillBar.style.backgroundPosition="-"+(bottomHeight+format.borderWidth)+"px -"
+ + (format.height + (topHeight+format.borderWidth))+"px";
+ }
+ }
+ bottom.appendChild(fillBar);
+ }
+ }
+ }
+
+ // finally, set up the padding.
+ if(options.autoPad && format.padding>0){
+ var content=document.createElement("div");
+ content.style.position="relative";
+ content.innerHTML=format.content;
+ content.className="autoPadDiv";
+ if(topHeight < format.padding){
+ content.style.paddingTop = Math.abs(topHeight-format.padding)+"px";
+ }
+ if(bottomHeight < format.padding){
+ content.style.paddingBottom = Math.abs(bottomHeight-format.padding)+"px";
+ }
+ content.style.paddingLeft=format.padding+"px";
+ content.style.paddingRight=format.padding+"px";
+ node.appendChild(content);
+ }
+};
+
+var count=0;
+
+// helper methods.
+dojo.lfx.rounded._fns={
+ blend:function(clr1, clr2, frac){
+ var c1={
+ r:parseInt(clr1.substr(1,2),16),
+ g:parseInt(clr1.substr(3,2),16),
+ b:parseInt(clr1.substr(5,2),16)
+ };
+ var c2={
+ r:parseInt(clr2.substr(1,2),16),
+ g:parseInt(clr2.substr(3,2),16),
+ b:parseInt(clr2.substr(5,2),16)
+ };
+ if(frac>1||frac<0){ frac=1; }
+ var ret=[
+ Math.min(Math.max(Math.round((c1.r*frac)+(c2.r*(1-frac))),0),255),
+ Math.min(Math.max(Math.round((c1.g*frac)+(c2.g*(1-frac))),0),255),
+ Math.min(Math.max(Math.round((c1.b*frac)+(c2.b*(1-frac))),0),255)
+ ];
+ for(var i=0; i<ret.length; i++){
+ var n=ret[i].toString(16);
+ if(n.length<2){ n="0"+n; }
+ ret[i]=n;
+ }
+ return "#"+ret.join("");
+ },
+ fraction:function(x, y, r){
+ var frac=0;
+ var xval=[];
+ var yval=[];
+ var point=0;
+ var whatsides="";
+
+ var intersect=Math.sqrt((Math.pow(r,2)-Math.pow(x,2)));
+ if(intersect >=y && intersect < (y+1)){
+ whatsides="Left";
+ xval[point]=0;
+ yval[point++]=intersect-y;
+ }
+
+ intersect=Math.sqrt((Math.pow(r,2)-Math.pow(y+1,2)));
+ if(intersect >=x && intersect < (x+1)){
+ whatsides += "Top";
+ xval[point]=intersect-x;
+ yval[point++]=1;
+ }
+
+ intersect=Math.sqrt((Math.pow(r,2)-Math.pow(x+1,2)));
+ if(intersect >= y && intersect < (y+1)){
+ whatsides += "Right";
+ xval[point]=1;
+ yval[point++] = intersect-y;
+ }
+
+ intersect=Math.sqrt((Math.pow(r,2)-Math.pow(y,2)));
+ if(intersect >=x && intersect < (x+1)){
+ whatsides += "Bottom";
+ xval[point]=intersect-x;
+ yval[point]=1;
+ }
+
+ switch(whatsides){
+ case "LeftRight":
+ return Math.min(yval[0],yval[1]) + ((Math.max(yval[0],yval[1])-Math.min(yval[0],yval[1]))/2);
+ case "TopRight":
+ return 1-(((1-xval[0])*(1-yval[1]))/2);
+ case "TopBottom":
+ return Math.min(xval[0],xval[1]) + ((Math.max(xval[0],xval[1])-Math.min(xval[0],xval[1]))/2);
+ case "LeftBottom":
+ return (yval[0]*xval[1])/2;
+ default: return 1;
+ }
+ },
+ draw:function(x, y, color, opac, height, corner, image, radius, top, format){
+ var px=document.createElement("div");
+ px.style.height=height+"px"
+ px.style.width="1px";
+ px.style.position="absolute";
+ px.style.fontSize="1px";
+ px.style.overflow="hidden";
+ if(image==-1 && format.bgImage!=""){
+ px.style.backgroundImage=format.bgImage;
+ px.style.backgroundPosition="-"+(format.width-(radius-x)+format.borderWidth)
+ +"px -"+((format.height+top+y)-format.borderWidth)+"px";
+ } else {
+ px.style.backgroundColor=color;
+ }
+ if(opac!=100){ dojo.html.setOpacity(px, (opac/100)); }
+ px.style.top=y+"px";
+ px.style.left=x+"px";
+ corner.appendChild(px);
+ },
+ getRGB:function(clr){
+ var ret="#ffffff";
+ if(clr!="" && clr!="transparent"){
+ if(clr.substr(0,3)=="rgb"){
+ var t=clr.substring(4, clr.indexOf(")"));
+ t=t.split(",");
+ for(var i=0; i<t.length; i++){
+ var n=parseInt(t[i]).toString(16);
+ if(n.length<2){ n = "0"+n; }
+ t[i]=n;
+ }
+ ret = "#"+t.join("");
+ }
+ else if(clr.length==4){
+ ret = "#"+clr.substring(1,2)+clr.substring(1,2)
+ + clr.substring(2,3)+clr.substring(2,3)
+ + clr.substring(3,4)+clr.substring(3,4);
+ }
+ else {
+ ret = clr;
+ }
+ }
+ return ret;
+ }
+};
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/shadow.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/shadow.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/shadow.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/shadow.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,79 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.shadow");
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.uri.Uri");
+
+dojo.lfx.shadow = function(node) {
+ this.shadowPng = dojo.uri.dojoUri("src/html/images/shadow");
+ this.shadowThickness = 8;
+ this.shadowOffset = 15;
+ this.init(node);
+}
+
+dojo.extend(dojo.lfx.shadow, {
+ init: function(node){
+ this.node=node;
+
+ // make all the pieces of the shadow, and position/size them as much
+ // as possible (but a lot of the coordinates are set in sizeShadow
+ this.pieces={};
+ var x1 = -1 * this.shadowThickness;
+ var y0 = this.shadowOffset;
+ var y1 = this.shadowOffset + this.shadowThickness;
+ this._makePiece("tl", "top", y0, "left", x1);
+ this._makePiece("l", "top", y1, "left", x1, "scale");
+ this._makePiece("tr", "top", y0, "left", 0);
+ this._makePiece("r", "top", y1, "left", 0, "scale");
+ this._makePiece("bl", "top", 0, "left", x1);
+ this._makePiece("b", "top", 0, "left", 0, "crop");
+ this._makePiece("br", "top", 0, "left", 0);
+ },
+
+ _makePiece: function(name, vertAttach, vertCoord, horzAttach, horzCoord, sizing){
+ var img;
+ var url = this.shadowPng + name.toUpperCase() + ".png";
+ if(dojo.render.html.ie55 || dojo.render.html.ie60){
+ img=dojo.doc().createElement("div");
+ img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+url+"'"+
+ (sizing?", sizingMethod='"+sizing+"'":"") + ")";
+ }else{
+ img=dojo.doc().createElement("img");
+ img.src=url;
+ }
+ img.style.position="absolute";
+ img.style[vertAttach]=vertCoord+"px";
+ img.style[horzAttach]=horzCoord+"px";
+ img.style.width=this.shadowThickness+"px";
+ img.style.height=this.shadowThickness+"px";
+ this.pieces[name]=img;
+ this.node.appendChild(img);
+ },
+
+ size: function(width, height){
+ var sideHeight = height - (this.shadowOffset+this.shadowThickness+1);
+ if (sideHeight < 0) { sideHeight = 0; }
+ if (height < 1) { height = 1; }
+ if (width < 1) { width = 1; }
+ with(this.pieces){
+ l.style.height = sideHeight+"px";
+ r.style.height = sideHeight+"px";
+ b.style.width = (width-1)+"px";
+ bl.style.top = (height-1)+"px";
+ b.style.top = (height-1)+"px";
+ br.style.top = (height-1)+"px";
+ tr.style.left = (width-1)+"px";
+ r.style.left = (width-1)+"px";
+ br.style.left = (width-1)+"px";
+ }
+ }
+});
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/shadow.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/toggle.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/toggle.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/toggle.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/toggle.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,54 @@
+/*
+ Copyright (c) 2004-2006, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.lfx.toggle");
+dojo.require("dojo.lfx.*");
+
+dojo.lfx.toggle.plain = {
+ show: function(node, duration, easing, callback){
+ dojo.html.show(node);
+ if(dojo.lang.isFunction(callback)){ callback(); }
+ },
+
+ hide: function(node, duration, easing, callback){
+ dojo.html.hide(node);
+ if(dojo.lang.isFunction(callback)){ callback(); }
+ }
+}
+
+dojo.lfx.toggle.fade = {
+ show: function(node, duration, easing, callback){
+ dojo.lfx.fadeShow(node, duration, easing, callback).play();
+ },
+
+ hide: function(node, duration, easing, callback){
+ dojo.lfx.fadeHide(node, duration, easing, callback).play();
+ }
+}
+
+dojo.lfx.toggle.wipe = {
+ show: function(node, duration, easing, callback){
+ dojo.lfx.wipeIn(node, duration, easing, callback).play();
+ },
+
+ hide: function(node, duration, easing, callback){
+ dojo.lfx.wipeOut(node, duration, easing, callback).play();
+ }
+}
+
+dojo.lfx.toggle.explode = {
+ show: function(node, duration, easing, callback, explodeSrc){
+ dojo.lfx.explode(explodeSrc||{x:0,y:0,width:0,height:0}, node, duration, easing, callback).play();
+ },
+
+ hide: function(node, duration, easing, callback, explodeSrc){
+ dojo.lfx.implode(node, explodeSrc||{x:0,y:0,width:0,height:0}, duration, easing, callback).play();
+ }
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/lfx/toggle.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,667 @@
+/*
+ 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
+*/
+
+/*
+ * loader.js - A bootstrap module. Runs before the hostenv_*.js file. Contains all of the package loading methods.
+ */
+
+//A semi-colon is at the start of the line because after doing a build, this function definition
+//get compressed onto the same line as the last line in bootstrap1.js. That list line is just a
+//curly bracket, and the browser complains about that syntax. The semicolon fixes it. Putting it
+//here instead of at the end of bootstrap1.js, since it is more of an issue for this file, (using
+//the closure), and bootstrap1.js could change in the future.
+;(function(){
+ //Additional properties for dojo.hostenv
+ var _addHostEnv = {
+ pkgFileName: "__package__",
+
+ // for recursion protection
+ loading_modules_: {},
+ loaded_modules_: {},
+ addedToLoadingCount: [],
+ removedFromLoadingCount: [],
+
+ inFlightCount: 0,
+
+ // FIXME: it should be possible to pull module prefixes in from djConfig
+ modulePrefixes_: {
+ dojo: {name: "dojo", value: "src"}
+ },
+
+ setModulePrefix: function(module, prefix){
+ this.modulePrefixes_[module] = {name: module, value: prefix};
+ },
+
+ moduleHasPrefix: function(module){
+ var mp = this.modulePrefixes_;
+ return Boolean(mp[module] && mp[module].value);
+ },
+
+ getModulePrefix: function(module){
+ if(this.moduleHasPrefix(module)){
+ return this.modulePrefixes_[module].value;
+ }
+ return module;
+ },
+
+ getTextStack: [],
+ loadUriStack: [],
+ loadedUris: [],
+
+ //WARNING: This variable is referenced by packages outside of bootstrap: FloatingPane.js and undo/browser.js
+ post_load_: false,
+
+ //Egad! Lots of test files push on this directly instead of using dojo.addOnLoad.
+ modulesLoadedListeners: [],
+ unloadListeners: [],
+ loadNotifying: false
+ };
+
+ //Add all of these properties to dojo.hostenv
+ for(var param in _addHostEnv){
+ dojo.hostenv[param] = _addHostEnv[param];
+ }
+})();
+
+dojo.hostenv.loadPath = function(/*String*/relpath, /*String?*/module, /*Function?*/cb){
+// summary:
+// Load a Javascript module given a relative path
+//
+// description:
+// Loads and interprets the script located at relpath, which is relative to the
+// script root directory. If the script is found but its interpretation causes
+// a runtime exception, that exception is not caught by us, so the caller will
+// see it. We return a true value if and only if the script is found.
+//
+// For now, we do not have an implementation of a true search path. We
+// consider only the single base script uri, as returned by getBaseScriptUri().
+//
+// relpath: A relative path to a script (no leading '/', and typically
+// ending in '.js').
+// module: A module whose existance to check for after loading a path.
+// Can be used to determine success or failure of the load.
+// cb: a callback function to pass the result of evaluating the script
+
+ var uri;
+ if(relpath.charAt(0) == '/' || relpath.match(/^\w+:/)){
+ // dojo.raise("relpath '" + relpath + "'; must be relative");
+ uri = relpath;
+ }else{
+ uri = this.getBaseScriptUri() + relpath;
+ }
+ if(djConfig.cacheBust && dojo.render.html.capable){
+ uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,"");
+ }
+ try{
+ return !module ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb); // Boolean
+ }catch(e){
+ dojo.debug(e);
+ return false; // Boolean
+ }
+}
+
+dojo.hostenv.loadUri = function(/*String (URL)*/uri, /*Function?*/cb){
+// summary:
+// Loads JavaScript from a URI
+//
+// description:
+// Reads the contents of the URI, and evaluates the contents. This is used to load modules as well
+// as resource bundles. Returns true if it succeeded. Returns false if the URI reading failed.
+// Throws if the evaluation throws.
+//
+// uri: a uri which points at the script to be loaded
+// cb: a callback function to process the result of evaluating the script as an expression, typically
+// used by the resource bundle loader to load JSON-style resources
+
+ if(this.loadedUris[uri]){
+ return true; // Boolean
+ }
+ var contents = this.getText(uri, null, true);
+ if(!contents){ return false; } // Boolean
+ this.loadedUris[uri] = true;
+ if(cb){ contents = '('+contents+')'; }
+ var value = dj_eval(contents);
+ if(cb){ cb(value); }
+ return true; // Boolean
+}
+
+// FIXME: probably need to add logging to this method
+dojo.hostenv.loadUriAndCheck = function(uri, module, /*Function?*/cb){
+ var ok = true;
+ try{
+ ok = this.loadUri(uri, cb);
+ }catch(e){
+ dojo.debug("failed loading ", uri, " with error: ", e);
+ }
+ return Boolean(ok && this.findModule(module, false)); // Boolean
+}
+
+dojo.loaded = function(){ }
+dojo.unloaded = function(){ }
+
+dojo.hostenv.loaded = function(){
+ this.loadNotifying = true;
+ this.post_load_ = true;
+ var mll = this.modulesLoadedListeners;
+ for(var x=0; x<mll.length; x++){
+ mll[x]();
+ }
+
+ //Clear listeners so new ones can be added
+ //For other xdomain package loads after the initial load.
+ this.modulesLoadedListeners = [];
+ this.loadNotifying = false;
+
+ dojo.loaded();
+}
+
+dojo.hostenv.unloaded = function(){
+ var mll = this.unloadListeners;
+ while(mll.length){
+ (mll.pop())();
+ }
+ dojo.unloaded();
+}
+
+/*
+Call styles:
+ dojo.addOnLoad(functionPointer)
+ dojo.addOnLoad(object, "functionName")
+*/
+dojo.addOnLoad = function(obj, fcnName) {
+ var dh = dojo.hostenv;
+ if(arguments.length == 1) {
+ dh.modulesLoadedListeners.push(obj);
+ } else if(arguments.length > 1) {
+ dh.modulesLoadedListeners.push(function() {
+ obj[fcnName]();
+ });
+ }
+
+ //Added for xdomain loading. dojo.addOnLoad is used to
+ //indicate callbacks after doing some dojo.require() statements.
+ //In the xdomain case, if all the requires are loaded (after initial
+ //page load), then immediately call any listeners.
+ if(dh.post_load_ && dh.inFlightCount == 0 && !dh.loadNotifying){
+ dh.callLoaded();
+ }
+}
+
+dojo.addOnUnload = function(obj, fcnName){
+ var dh = dojo.hostenv;
+ if(arguments.length == 1){
+ dh.unloadListeners.push(obj);
+ } else if(arguments.length > 1) {
+ dh.unloadListeners.push(function() {
+ obj[fcnName]();
+ });
+ }
+}
+
+dojo.hostenv.modulesLoaded = function(){
+ if(this.post_load_){ return; }
+ if(this.loadUriStack.length==0 && this.getTextStack.length==0){
+ if(this.inFlightCount > 0){
+ dojo.debug("files still in flight!");
+ return;
+ }
+ dojo.hostenv.callLoaded();
+ }
+}
+
+dojo.hostenv.callLoaded = function(){
+ if(typeof setTimeout == "object"){
+ setTimeout("dojo.hostenv.loaded();", 0);
+ }else{
+ dojo.hostenv.loaded();
+ }
+}
+
+dojo.hostenv.getModuleSymbols = function(/*String*/modulename){
+ var syms = modulename.split(".");
+ for(var i = syms.length; i>0; i--){
+ var parentModule = syms.slice(0, i).join(".");
+ if ((i==1) && !this.moduleHasPrefix(parentModule)){
+ //Support default module directory (sibling of dojo)
+ syms[0] = "../" + syms[0];
+ }else{
+ var parentModulePath = this.getModulePrefix(parentModule);
+ if(parentModulePath != parentModule){
+ syms.splice(0, i, parentModulePath);
+ break;
+ }
+ }
+ }
+ return syms; // Array
+}
+
+dojo.hostenv._global_omit_module_check = false;
+dojo.hostenv.loadModule = function(/*String*/modulename, /*Boolean?*/exactOnly, /*Boolean?*/omitModuleCheck){
+// summary:
+// loads a Javascript module from the appropriate URI
+//
+// description:
+// loadModule("A.B") first checks to see if symbol A.B is defined.
+// If it is, it is simply returned (nothing to do).
+//
+// If it is not defined, it will look for "A/B.js" in the script root directory,
+// followed by "A.js".
+//
+// It throws if it cannot find a file to load, or if the symbol A.B is not
+// defined after loading.
+//
+// It returns the object A.B.
+//
+// This does nothing about importing symbols into the current package.
+// It is presumed that the caller will take care of that. For example, to import
+// all symbols:
+//
+// with (dojo.hostenv.loadModule("A.B")) {
+// ...
+// }
+//
+// And to import just the leaf symbol:
+//
+// var B = dojo.hostenv.loadModule("A.B");
+// ...
+//
+// dj_load is an alias for dojo.hostenv.loadModule
+
+ if(!modulename){ return; }
+ omitModuleCheck = this._global_omit_module_check || omitModuleCheck;
+ var module = this.findModule(modulename, false);
+ if(module){
+ return module;
+ }
+
+ // protect against infinite recursion from mutual dependencies
+ if(dj_undef(modulename, this.loading_modules_)){
+ this.addedToLoadingCount.push(modulename);
+ }
+ this.loading_modules_[modulename] = 1;
+
+ // convert periods to slashes
+ var relpath = modulename.replace(/\./g, '/') + '.js';
+
+ var nsyms = modulename.split(".");
+
+ // this line allowed loading of a module manifest as if it were a namespace
+ // it's an interesting idea, but shouldn't be combined with 'namespaces' proper
+ // and leads to unwanted dependencies
+ // the effect can be achieved in other (albeit less-flexible) ways now, so I am
+ // removing this pending further design work
+ // perhaps we can explicitly define this idea of a 'module manifest', and subclass
+ // 'namespace manifest' from that
+ //dojo.getNamespace(nsyms[0]);
+
+ var syms = this.getModuleSymbols(modulename);
+ var startedRelative = ((syms[0].charAt(0) != '/') && !syms[0].match(/^\w+:/));
+ var last = syms[syms.length - 1];
+ var ok;
+ // figure out if we're looking for a full package, if so, we want to do
+ // things slightly diffrently
+ if(last=="*"){
+ modulename = nsyms.slice(0, -1).join('.');
+ while(syms.length){
+ syms.pop();
+ syms.push(this.pkgFileName);
+ relpath = syms.join("/") + '.js';
+ if(startedRelative && relpath.charAt(0)=="/"){
+ relpath = relpath.slice(1);
+ }
+ ok = this.loadPath(relpath, !omitModuleCheck ? modulename : null);
+ if(ok){ break; }
+ syms.pop();
+ }
+ }else{
+ relpath = syms.join("/") + '.js';
+ modulename = nsyms.join('.');
+ var modArg = !omitModuleCheck ? modulename : null;
+ ok = this.loadPath(relpath, modArg);
+ if(!ok && !exactOnly){
+ syms.pop();
+ while(syms.length){
+ relpath = syms.join('/') + '.js';
+ ok = this.loadPath(relpath, modArg);
+ if(ok){ break; }
+ syms.pop();
+ relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
+ if(startedRelative && relpath.charAt(0)=="/"){
+ relpath = relpath.slice(1);
+ }
+ ok = this.loadPath(relpath, modArg);
+ if(ok){ break; }
+ }
+ }
+
+ if(!ok && !omitModuleCheck){
+ dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
+ }
+ }
+
+ // check that the symbol was defined
+ //Don't bother if we're doing xdomain (asynchronous) loading.
+ if(!omitModuleCheck && !this["isXDomain"]){
+ // pass in false so we can give better error
+ module = this.findModule(modulename, false);
+ if(!module){
+ dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
+ }
+ }
+
+ return module;
+}
+
+dojo.hostenv.startPackage = function(/*String*/packageName){
+// summary:
+// Creates a JavaScript package
+//
+// description:
+// startPackage("A.B") follows the path, and at each level creates a new empty
+// object or uses what already exists. It returns the result.
+//
+// packageName: the package to be created as a String in dot notation
+
+ //Make sure we have a string.
+ var fullPkgName = String(packageName);
+ var strippedPkgName = fullPkgName;
+
+ var syms = packageName.split(/\./);
+ if(syms[syms.length-1]=="*"){
+ syms.pop();
+ strippedPkgName = syms.join(".");
+ }
+ var evaledPkg = dojo.evalObjPath(strippedPkgName, true);
+ this.loaded_modules_[fullPkgName] = evaledPkg;
+ this.loaded_modules_[strippedPkgName] = evaledPkg;
+
+ return evaledPkg; // Object
+}
+
+dojo.hostenv.findModule = function(/*String*/moduleName, /*Boolean?*/mustExist){
+// summary:
+// Returns the Object representing the module, if it exists, otherwise null.
+//
+// moduleName A fully qualified module including package name, like 'A.B'.
+// mustExist Optional, default false. throw instead of returning null
+// if the module does not currently exist.
+
+ var lmn = String(moduleName);
+
+ if(this.loaded_modules_[lmn]){
+ return this.loaded_modules_[lmn]; // Object
+ }
+
+ if(mustExist){
+ dojo.raise("no loaded module named '" + moduleName + "'");
+ }
+ return null; // null
+}
+
+//Start of old bootstrap2:
+
+dojo.kwCompoundRequire = function(modMap){
+// description:
+// This method taks a "map" of arrays which one can use to optionally load dojo
+// modules. The map is indexed by the possible dojo.hostenv.name_ values, with
+// two additional values: "default" and "common". The items in the "default"
+// array will be loaded if none of the other items have been choosen based on
+// the hostenv.name_ item. The items in the "common" array will _always_ be
+// loaded, regardless of which list is chosen. Here's how it's normally
+// called:
+//
+// dojo.kwCompoundRequire({
+// browser: [
+// ["foo.bar.baz", true, true], // an example that passes multiple args to loadModule()
+// "foo.sample.*",
+// "foo.test,
+// ],
+// default: [ "foo.sample.*" ],
+// common: [ "really.important.module.*" ]
+// });
+
+ var common = modMap["common"]||[];
+ var result = modMap[dojo.hostenv.name_] ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
+
+ for(var x=0; x<result.length; x++){
+ var curr = result[x];
+ if(curr.constructor == Array){
+ dojo.hostenv.loadModule.apply(dojo.hostenv, curr);
+ }else{
+ dojo.hostenv.loadModule(curr);
+ }
+ }
+}
+
+dojo.require = function(){
+ dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
+}
+
+dojo.requireIf = function(){
+ var arg0 = arguments[0];
+ if((arg0 === true)||(arg0=="common")||(arg0 && dojo.render[arg0].capable)){
+ var args = [];
+ for (var i = 1; i < arguments.length; i++) { args.push(arguments[i]); }
+ dojo.require.apply(dojo, args);
+ }
+}
+
+dojo.requireAfterIf = dojo.requireIf;
+
+dojo.provide = function(){
+ return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
+}
+
+dojo.registerModulePath = function(/*String*/module, /*String*/prefix){
+ // summary: maps a module name to a path
+ // description: An unregistered module is given the default path of ../<module>,
+ // relative to Dojo root. For example, module acme is mapped to ../acme.
+ // If you want to use a different module name, use dojo.registerModulePath.
+ return dojo.hostenv.setModulePrefix(module, prefix);
+}
+
+dojo.setModulePrefix = function(/*String*/module, /*String*/prefix){
+ // summary: maps a module name to a path
+ dojo.deprecated('dojo.setModulePrefix("' + module + '", "' + prefix + '")', "replaced by dojo.registerModulePath", "0.5");
+ return dojo.registerModulePath(module, prefix);
+}
+
+dojo.exists = function(/*Object*/obj, /*String*/name){
+ // summary: determine if an object supports a given method
+ // description: useful for longer api chains where you have to test each object in the chain
+ var p = name.split(".");
+ for(var i = 0; i < p.length; i++){
+ if(!obj[p[i]]){ return false; }
+ obj = obj[p[i]];
+ }
+ return true; // Boolean
+}
+
+// Localization routines
+
+dojo.hostenv.normalizeLocale = function(/*String?*/locale){
+// summary:
+// Returns canonical form of locale, as used by Dojo. All variants are case-insensitive and are separated by '-'
+// as specified in RFC 3066. If no locale is specified, the user agent's default is returned.
+
+ return locale ? locale.toLowerCase() : dojo.locale; // String
+};
+
+dojo.hostenv.searchLocalePath = function(/*String*/locale, /*Boolean*/down, /*Function*/searchFunc){
+// summary:
+// A helper method to assist in searching for locale-based resources. Will iterate through
+// the variants of a particular locale, either up or down, executing a callback function.
+// For example, "en-us" and true will try "en-us" followed by "en" and finally "ROOT".
+
+ locale = dojo.hostenv.normalizeLocale(locale);
+
+ var elements = locale.split('-');
+ var searchlist = [];
+ for(var i = elements.length; i > 0; i--){
+ searchlist.push(elements.slice(0, i).join('-'));
+ }
+ searchlist.push(false);
+ if(down){searchlist.reverse();}
+
+ for(var j = searchlist.length - 1; j >= 0; j--){
+ var loc = searchlist[j] || "ROOT";
+ var stop = searchFunc(loc);
+ if(stop){ break; }
+ }
+}
+
+dojo.hostenv.preloadLocalizations = function(){
+// summary:
+// Load built, flattened resource bundles, if available for all locales used in the page.
+// Execute only once. Note that this is a no-op unless there is a build.
+
+ var localesGenerated /***BUILD:localesGenerated***/; // value will be inserted at build time, if necessary
+
+ if(localesGenerated){
+ dojo.registerModulePath("nls","nls");
+
+ function preload(locale){
+ locale = dojo.hostenv.normalizeLocale(locale);
+ dojo.hostenv.searchLocalePath(locale, true, function(loc){
+ for(var i=0; i<localesGenerated.length;i++){
+ if(localesGenerated[i] == loc){
+ dojo["require"]("nls.dojo_"+loc);
+ return true;
+ }
+ }
+ return false;
+ });
+ }
+ preload();
+ var extra = djConfig.extraLocale||[];
+ for(var i=0; i<extra.length; i++){
+ preload(extra[i]);
+ }
+ }
+ dojo.hostenv.preloadLocalizations = function(){};
+}
+
+dojo.requireLocalization = function(/*String*/moduleName, /*String*/bundleName, /*String?*/locale){
+// summary:
+// Declares translated resources and loads them if necessary, in the same style as dojo.require.
+// Contents of the resource bundle are typically strings, but may be any name/value pair,
+// represented in JSON format. See also dojo.i18n.getLocalization.
+//
+// moduleName: name of the package containing the "nls" directory in which the bundle is found
+// bundleName: bundle name, i.e. the filename without the '.js' suffix
+// locale: the locale to load (optional) By default, the browser's user locale as defined by dojo.locale
+//
+// description:
+// Load translated resource bundles provided underneath the "nls" directory within a package.
+// Translated resources may be located in different packages throughout the source tree. For example,
+// a particular widget may define one or more resource bundles, structured in a program as follows,
+// where moduleName is mycode.mywidget and bundleNames available include bundleone and bundletwo:
+// ...
+// mycode/
+// mywidget/
+// nls/
+// bundleone.js (the fallback translation, English in this example)
+// bundletwo.js (also a fallback translation)
+// de/
+// bundleone.js
+// bundletwo.js
+// de-at/
+// bundleone.js
+// en/
+// (empty; use the fallback translation)
+// en-us/
+// bundleone.js
+// en-gb/
+// bundleone.js
+// es/
+// bundleone.js
+// bundletwo.js
+// ...etc
+// ...
+// Each directory is named for a locale as specified by RFC 3066, (http://www.ietf.org/rfc/rfc3066.txt),
+// normalized in lowercase. Note that the two bundles in the example do not define all the same variants.
+// For a given locale, bundles will be loaded for that locale and all more general locales above it, including
+// a fallback at the root directory. For example, a declaration for the "de-at" locale will first
+// load nls/de-at/bundleone.js, then nls/de/bundleone.js and finally nls/bundleone.js. The data will
+// be flattened into a single Object so that lookups will follow this cascading pattern. An optional build
+// step can preload the bundles to avoid data redundancy and the multiple network hits normally required to
+// load these resources.
+
+ dojo.hostenv.preloadLocalizations();
+ var bundlePackage = [moduleName, "nls", bundleName].join(".");
+//NOTE: When loading these resources, the packaging does not match what is on disk. This is an
+// implementation detail, as this is just a private data structure to hold the loaded resources.
+// e.g. tests/hello/nls/en-us/salutations.js is loaded as the object tests.hello.nls.salutations.en_us={...}
+// The structure on disk is intended to be most convenient for developers and translators, but in memory
+// it is more logical and efficient to store in a different order. Locales cannot use dashes, since the
+// resulting path will not evaluate as valid JS, so we translate them to underscores.
+
+ var bundle = dojo.hostenv.findModule(bundlePackage);
+ if(bundle){
+ if(djConfig.localizationComplete && bundle._built){return;}
+ var jsLoc = dojo.hostenv.normalizeLocale(locale).replace('-', '_');
+ var translationPackage = bundlePackage+"."+jsLoc;
+ if(dojo.hostenv.findModule(translationPackage)){return;}
+ }
+
+ bundle = dojo.hostenv.startPackage(bundlePackage);
+ var syms = dojo.hostenv.getModuleSymbols(moduleName);
+ var modpath = syms.concat("nls").join("/");
+ var parent;
+ dojo.hostenv.searchLocalePath(locale, false, function(loc){
+ var jsLoc = loc.replace('-', '_');
+ var translationPackage = bundlePackage + "." + jsLoc;
+ var loaded = false;
+ if(!dojo.hostenv.findModule(translationPackage)){
+ // Mark loaded whether it's found or not, so that further load attempts will not be made
+ dojo.hostenv.startPackage(translationPackage);
+ var module = [modpath];
+ if(loc != "ROOT"){module.push(loc);}
+ module.push(bundleName);
+ var filespec = module.join("/") + '.js';
+ loaded = dojo.hostenv.loadPath(filespec, null, function(hash){
+ // Use singleton with prototype to point to parent bundle, then mix-in result from loadPath
+ var clazz = function(){};
+ clazz.prototype = parent;
+ bundle[jsLoc] = new clazz();
+ for(var j in hash){ bundle[jsLoc][j] = hash[j]; }
+ });
+ }else{
+ loaded = true;
+ }
+ if(loaded && bundle[jsLoc]){
+ parent = bundle[jsLoc];
+ }else{
+ bundle[jsLoc] = parent;
+ }
+ });
+};
+
+(function(){
+ // If other locales are used, dojo.requireLocalization should load them as well, by default.
+ // Override dojo.requireLocalization to do load the default bundle, then iterate through the
+ // extraLocale list and load those translations as well, unless a particular locale was requested.
+
+ var extra = djConfig.extraLocale;
+ if(extra){
+ if(!extra instanceof Array){
+ extra = [extra];
+ }
+
+ var req = dojo.requireLocalization;
+ dojo.requireLocalization = function(m, b, locale){
+ req(m,b,locale);
+ if(locale){return;}
+ for(var i=0; i<extra.length; i++){
+ req(m,b,extra[i]);
+ }
+ };
+ }
+})();
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader_xd.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader_xd.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader_xd.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader_xd.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,414 @@
+/*
+ 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
+*/
+
+//Cross-domain package loader.
+
+//FIXME: How will xd loading work with debugAtAllCosts? Any bad interactions?
+//FIXME: widgets won't work fully (HTML/CSS) and also because of the requireIf() thing.
+
+dojo.hostenv.resetXd = function(){
+ //This flag indicates where or not we have crossed into xdomain territory. Once any package says
+ //it is cross domain, then the rest of the packages have to be treated as xdomain because we need
+ //to evaluate packages in order. If there is a xdomain package followed by a xhr package, we can't load
+ //the xhr package until the one before it finishes loading. The text of the xhr package will be converted
+ //to match the format for a xd package and put in the xd load queue.
+ //You can force all packages to be treated as xd by setting the djConfig.forceXDomain.
+ this.isXDomain = djConfig.forceXDomain || false;
+
+ this.xdTimer = 0;
+ this.xdInFlight = {};
+ this.xdOrderedReqs = [];
+ this.xdDepMap = {};
+ this.xdContents = [];
+}
+
+//Call reset immediately to set the state.
+dojo.hostenv.resetXd();
+
+dojo.hostenv.createXdPackage = function(contents){
+ //Find dependencies.
+ var deps = [];
+ var depRegExp = /dojo.(require|requireIf|requireAll|provide|requireAfterIf|requireAfter|kwCompoundRequire|conditionalRequire|hostenv\.conditionalLoadModule|.hostenv\.loadModule|hostenv\.moduleLoaded)\(([\w\W]*?)\)/mg;
+ var match;
+ while((match = depRegExp.exec(contents)) != null){
+ deps.push("\"" + match[1] + "\", " + match[2]);
+ }
+
+ //Create package object and the call to packageLoaded.
+ var output = [];
+ output.push("dojo.hostenv.packageLoaded({\n");
+
+ //Add dependencies
+ if(deps.length > 0){
+ output.push("depends: [");
+ for(var i = 0; i < deps.length; i++){
+ if(i > 0){
+ output.push(",\n");
+ }
+ output.push("[" + deps[i] + "]");
+ }
+ output.push("],");
+ }
+
+ //Add the contents of the file inside a function.
+ //Pass in dojo as an argument to the function to help with
+ //allowing multiple versions of dojo in a page.
+ output.push("\ndefinePackage: function(dojo){");
+ output.push(contents);
+ output.push("\n}});");
+
+ return output.join("");
+}
+
+dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
+ //Only do getBaseScriptUri if path does not start with a URL with a protocol.
+ //If there is a colon before the first / then, we have a URL with a protocol.
+ var colonIndex = relpath.indexOf(":");
+ var slashIndex = relpath.indexOf("/");
+ var uri;
+ var currentIsXDomain = false;
+ if(colonIndex > 0 && colonIndex < slashIndex){
+ uri = relpath;
+ this.isXDomain = currentIsXDomain = true;
+ }else{
+ uri = this.getBaseScriptUri() + relpath;
+
+ //Is ithe base script URI-based URL a cross domain URL?
+ colonIndex = uri.indexOf(":");
+ slashIndex = uri.indexOf("/");
+ if(colonIndex > 0 && colonIndex < slashIndex && (!location.host || uri.indexOf("http://" + location.host) != 0)){
+ this.isXDomain = currentIsXDomain = true;
+ }
+ }
+
+ if(djConfig.cacheBust && dojo.render.html.capable) { uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,""); }
+ try{
+ return ((!module || this.isXDomain) ? this.loadUri(uri, cb, currentIsXDomain, module) : this.loadUriAndCheck(uri, module, cb));
+ }catch(e){
+ dojo.debug(e);
+ return false;
+ }
+}
+
+//Overriding loadUri for now. Wanted to override getText(), but it is used by
+//the widget code in too many, synchronous ways right now. This means the xd stuff
+//is not suitable for widgets yet.
+dojo.hostenv.loadUri = function(uri, cb, currentIsXDomain, module){
+ if(this.loadedUris[uri]){
+ return 1;
+ }
+
+ //Add the module (package) to the list of modules.
+ if(this.isXDomain){
+ //Curious: is this array going to get whacked with multiple access since scripts
+ //load asynchronously and may be accessing the array at the same time?
+ //JS is single-threaded supposedly, so it should be ok. And we don't need
+ //a precise ordering.
+ this.xdOrderedReqs.push(module);
+
+ //Add to waiting packages.
+ //If this is a __package__.js file, then this must be
+ //a package.* request (since xdomain can only work with the first
+ //path in a package search list. However, .* module names are not
+ //passed to this function, so do an adjustment here.
+ if(uri.indexOf("__package__") != -1){
+ module += ".*";
+ }
+
+ this.xdInFlight[module] = true;
+
+ //Increment inFlightCount
+ //This will stop the modulesLoaded from firing all the way.
+ this.inFlightCount++;
+
+ //Start timer
+ if(!this.xdTimer){
+ this.xdTimer = setInterval("dojo.hostenv.watchInFlightXDomain();", 100);
+ }
+ this.xdStartTime = (new Date()).getTime();
+ }
+
+ if (currentIsXDomain){
+ //Fix name to be a .xd.fileextension name.
+ var lastIndex = uri.lastIndexOf('.');
+ if(lastIndex <= 0){
+ lastIndex = uri.length - 1;
+ }
+
+ var xdUri = uri.substring(0, lastIndex) + ".xd";
+ if(lastIndex != uri.length - 1){
+ xdUri += uri.substring(lastIndex, uri.length);
+ }
+
+ //Add to script src
+ var element = document.createElement("script");
+ element.type = "text/javascript";
+ element.src = xdUri;
+ if(!this.headElement){
+ this.headElement = document.getElementsByTagName("head")[0];
+ }
+ this.headElement.appendChild(element);
+ }else{
+ var contents = this.getText(uri, null, true);
+ if(contents == null){ return 0; }
+
+ if(this.isXDomain){
+ var pkg = this.createXdPackage(contents);
+ dj_eval(pkg);
+ }else{
+ if(cb){ contents = '('+contents+')'; }
+ var value = dj_eval(contents);
+ if(cb){
+ cb(value);
+ }
+ }
+ }
+
+ //These steps are done in the non-xd loader version of this function.
+ //Maintain these steps to fit in with the existing system.
+ this.loadedUris[uri] = true;
+ return 1;
+}
+
+dojo.hostenv.packageLoaded = function(pkg){
+ var deps = pkg.depends;
+ var requireList = null;
+ var requireAfterList = null;
+ var provideList = [];
+ if(deps && deps.length > 0){
+ var dep = null;
+ var insertHint = 0;
+ var attachedPackage = false;
+ for(var i = 0; i < deps.length; i++){
+ dep = deps[i];
+
+ //Look for specific dependency indicators.
+ if (dep[0] == "provide" || dep[0] == "hostenv.moduleLoaded"){
+ provideList.push(dep[1]);
+ }else{
+ if(!requireList){
+ requireList = [];
+ }
+ if(!requireAfterList){
+ requireAfterList = [];
+ }
+
+ var unpackedDeps = this.unpackXdDependency(dep);
+ if(unpackedDeps.requires){
+ requireList = requireList.concat(unpackedDeps.requires);
+ }
+ if(unpackedDeps.requiresAfter){
+ requireAfterList = requireAfterList.concat(unpackedDeps.requiresAfter);
+ }
+ }
+
+ //Call the dependency indicator to allow for the normal dojo setup.
+ //Only allow for one dot reference, for the hostenv.* type calls.
+ var depType = dep[0];
+ var objPath = depType.split(".");
+ if(objPath.length == 2){
+ dojo[objPath[0]][objPath[1]].apply(dojo[objPath[0]], dep.slice(1));
+ }else{
+ dojo[depType].apply(dojo, dep.slice(1));
+ }
+ }
+
+ //Save off the package contents for definition later.
+ var contentIndex = this.xdContents.push({content: pkg.definePackage, isDefined: false}) - 1;
+
+ //Add provide/requires to dependency map.
+ for(var i = 0; i < provideList.length; i++){
+ this.xdDepMap[provideList[i]] = { requires: requireList, requiresAfter: requireAfterList, contentIndex: contentIndex };
+ }
+
+ //Now update the inflight status for any provided packages in this loaded package.
+ //Do this at the very end (in a *separate* for loop) to avoid shutting down the
+ //inflight timer check too soon.
+ for(var i = 0; i < provideList.length; i++){
+ this.xdInFlight[provideList[i]] = false;
+ }
+ }
+}
+
+//This is a bit brittle: it has to know about the dojo methods that deal with dependencies
+//It would be ideal to intercept the actual methods and do something fancy at that point,
+//but I have concern about knowing which provide to match to the dependency in that case,
+//since scripts can load whenever they want, and trigger new calls to dojo.hostenv.packageLoaded().
+dojo.hostenv.unpackXdDependency = function(dep){
+ //Extract the dependency(ies).
+ var newDeps = null;
+ var newAfterDeps = null;
+ switch(dep[0]){
+ case "requireIf":
+ case "requireAfterIf":
+ case "conditionalRequire":
+ //First arg (dep[1]) is the test. Depedency is dep[2].
+ if((dep[1] === true)||(dep[1]=="common")||(dep[1] && dojo.render[dep[1]].capable)){
+ newDeps = [{name: dep[2], content: null}];
+ }
+ break;
+ case "requireAll":
+ //the arguments are an array, each element a call to require.
+ //Get rid of first item, which is "requireAll".
+ dep.shift();
+ newDeps = dep;
+ dojo.hostenv.flattenRequireArray(newDeps);
+ break;
+ case "kwCompoundRequire":
+ case "hostenv.conditionalLoadModule":
+ var modMap = dep[1];
+ var common = modMap["common"]||[];
+ var newDeps = (modMap[dojo.hostenv.name_]) ? common.concat(modMap[dojo.hostenv.name_]||[]) : common.concat(modMap["default"]||[]);
+ dojo.hostenv.flattenRequireArray(newDeps);
+ break;
+ case "require":
+ case "requireAfter":
+ case "hostenv.loadModule":
+ //Just worry about dep[1]
+ newDeps = [{name: dep[1], content: null}];
+ break;
+ }
+
+ //The requireAfterIf or requireAfter needs to be evaluated after the current package is evaluated.
+ if(dep[0] == "requireAfterIf"){
+ newAfterDeps = newDeps;
+ newDeps = null;
+ }
+ return {requires: newDeps, requiresAfter: newAfterDeps};
+}
+
+//Walks the requires and evaluates package contents in
+//the right order.
+dojo.hostenv.xdWalkReqs = function(){
+ var reqChain = null;
+ var req;
+ for(var i = 0; i < this.xdOrderedReqs.length; i++){
+ req = this.xdOrderedReqs[i];
+ if(this.xdDepMap[req]){
+ reqChain = [req];
+ reqChain[req] = true; //Allow for fast lookup of the req in the array
+ this.xdEvalReqs(reqChain);
+ }
+ }
+}
+
+//Trace down any requires.
+dojo.hostenv.xdTraceReqs = function(reqs, reqChain){
+ if(reqs && reqs.length > 0){
+ var nextReq;
+ for(var i = 0; i < reqs.length; i++){
+ nextReq = reqs[i].name;
+ if(nextReq && !reqChain[nextReq]){
+ //New req depedency. Follow it down.
+ reqChain.push(nextReq);
+ reqChain[nextReq] = true;
+ this.xdEvalReqs(reqChain);
+ }
+ }
+ }
+}
+
+//Do a depth first, breadth second search and eval or reqs.
+dojo.hostenv.xdEvalReqs = function(reqChain){
+ if(reqChain.length > 0){
+ var req = reqChain[reqChain.length - 1];
+ var pkg = this.xdDepMap[req];
+ if(pkg){
+ //Trace down any requires for this package.
+ this.xdTraceReqs(pkg.requires, reqChain);
+
+ //Evaluate the package.
+ var contents = this.xdContents[pkg.contentIndex];
+ if(!contents.isDefined){
+ //Evaluate the package to bring it into being.
+ //Pass dojo in so that later, to support multiple versions of dojo
+ //in a page, we can pass which version of dojo to use.
+ contents.content(dojo);
+ contents.isDefined = true;
+ }
+ this.xdDepMap[req] = null;
+
+ //Trace down any requireAfters for this package..
+ this.xdTraceReqs(pkg.requiresAfter, reqChain);
+ }
+
+ //Done with that require. Remove it and go to the next one.
+ reqChain.pop();
+ this.xdEvalReqs(reqChain);
+ }
+}
+
+dojo.hostenv.clearXdInterval = function(){
+ clearInterval(this.xdTimer);
+ this.xdTimer = 0;
+}
+
+dojo.hostenv.watchInFlightXDomain = function(){
+ //Make sure we haven't waited timed out.
+ var waitInterval = (djConfig.xdWaitSeconds || 30) * 1000;
+
+ if(this.xdStartTime + waitInterval < (new Date()).getTime()){
+ this.clearXdInterval();
+ var noLoads = "";
+ for(var param in this.xdInFlight){
+ if(this.xdInFlight[param]){
+ noLoads += param + " ";
+ }
+ }
+ dojo.raise("Could not load cross-domain packages: " + noLoads);
+ }
+
+ //If any are true, then still waiting.
+ //Come back later.
+ for(var param in this.xdInFlight){
+ if(this.xdInFlight[param]){
+ return;
+ }
+ }
+
+ //All done loading. Clean up and notify that we are loaded.
+ this.clearXdInterval();
+
+ this.xdWalkReqs();
+
+ //Evaluate any packages that were not evaled before.
+ //This normally shouldn't happen with proper dojo.provide and dojo.require
+ //usage, but providing it just in case. Note that these may not be executed
+ //in the original order that the developer intended.
+ //Pass dojo in so that later, to support multiple versions of dojo
+ //in a page, we can pass which version of dojo to use.
+ for(var i = 0; i < this.xdContents.length; i++){
+ var current = this.xdContents[i];
+ if(current.content && !current.isDefined){
+ current.content(dojo);
+ }
+ }
+
+ //Clean up for the next round of xd loading.
+ this.resetXd();
+
+ //Clear inflight count so we will finally do finish work.
+ this.inFlightCount = 0;
+ this.callLoaded();
+}
+
+dojo.hostenv.flattenRequireArray = function(target){
+ //Each result could be an array of 3 elements (the 3 arguments to dojo.require).
+ //We only need the first one.
+ if(target){
+ for(var i = 0; i < target.length; i++){
+ if(target[i] instanceof Array){
+ target[i] = {name: target[i][0], content: null};
+ }else{
+ target[i] = {name: target[i], content: null};
+ }
+ }
+ }
+}
Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/loader_xd.js
------------------------------------------------------------------------------
svn:eol-style = native