You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2006/11/10 10:15:40 UTC
svn commit: r473277 [23/45] - in
/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource:
./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/
src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/...
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/rounded.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/rounded.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/rounded.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/rounded.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,512 @@
+/*
+ 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 /* ... */){
+ // summary
+ // Creates a set of rounded corners based on settings.
+ 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){
+ // summary
+ // Rounds corners based on options to passed 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;
+ }
+};
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/rounded.js
------------------------------------------------------------------------------
svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/rounded.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,86 @@
+/*
+ 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(/* HTMLElement */node) {
+ // summary
+ // creates a shadow underneath 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(/* HTMLElement */node){
+ // summary
+ // Initializes the shadow.
+ 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(/* int */width, /* int */height){
+ // summary
+ // Resizes the shadow based on width and 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: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js
------------------------------------------------------------------------------
svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/shadow.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/lfx/toggle.js Fri Nov 10 01:15:01 2006
@@ -13,12 +13,12 @@
dojo.lfx.toggle.plain = {
show: function(node, duration, easing, callback){
- dojo.style.show(node);
+ dojo.html.show(node);
if(dojo.lang.isFunction(callback)){ callback(); }
},
hide: function(node, duration, easing, callback){
- dojo.style.hide(node);
+ dojo.html.hide(node);
if(dojo.lang.isFunction(callback)){ callback(); }
}
}
@@ -45,10 +45,10 @@
dojo.lfx.toggle.explode = {
show: function(node, duration, easing, callback, explodeSrc){
- dojo.lfx.explode(explodeSrc||[0,0,0,0], node, duration, easing, callback).play();
+ 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||[0,0,0,0], duration, easing, callback).play();
+ dojo.lfx.implode(node, explodeSrc||{x:0,y:0,width:0,height:0}, duration, easing, callback).play();
}
}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader.js Fri Nov 10 01:15:01 2006
@@ -9,7 +9,7 @@
*/
/*
- * loader.js - runs before the hostenv_*.js file. Contains all of the package loading methods.
+ * 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
@@ -34,18 +34,24 @@
modulePrefixes_: {
dojo: {name: "dojo", value: "src"}
},
-
-
- setModulePrefix: function(module, prefix){
+
+ setModulePrefix: function(/*String*/module, /*String*/prefix){
+ // summary: establishes module/prefix pair
this.modulePrefixes_[module] = {name: module, value: prefix};
},
-
- getModulePrefix: function(module){
+
+ moduleHasPrefix: function(/*String*/module){
+ // summary: checks to see if module has been established
var mp = this.modulePrefixes_;
- if((mp[module])&&(mp[module]["name"])){
- return mp[module].value;
+ return Boolean(mp[module] && mp[module].value); // Boolean
+ },
+
+ getModulePrefix: function(/*String*/module){
+ // summary: gets the prefix associated with module
+ if(this.moduleHasPrefix(module)){
+ return this.modulePrefixes_[module].value; // String
}
- return module;
+ return module; // String
},
getTextStack: [],
@@ -67,24 +73,27 @@
}
})();
-/**
- * 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().
- *
- * @param relpath A relative path to a script (no leading '/', and typically
- * ending in '.js').
- * @param module A module whose existance to check for after loading a path.
- * Can be used to determine success or failure of the load.
- * @param cb a function to pass the result of evaluating the script (optional)
- */
-dojo.hostenv.loadPath = function(relpath, module /*optional*/, cb /*optional*/){
+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+:/))){
+ if(relpath.charAt(0) == '/' || relpath.match(/^\w+:/)){
// dojo.raise("relpath '" + relpath + "'; must be relative");
uri = relpath;
}else{
@@ -94,46 +103,48 @@
uri += "?" + String(djConfig.cacheBust).replace(/\W+/g,"");
}
try{
- return ((!module) ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb));
+ return !module ? this.loadUri(uri, cb) : this.loadUriAndCheck(uri, module, cb); // Boolean
}catch(e){
dojo.debug(e);
- return false;
+ return false; // Boolean
}
}
-/**
- * Reads the contents of the URI, and evaluates the contents.
- * Returns true if it succeeded. Returns false if the URI reading failed.
- * Throws if the evaluation throws.
- * The result of the eval is not available to the caller TODO: now it is; was this a deliberate restriction?
- *
- * @param uri a uri which points at the script to be loaded
- * @param cb a function to process the result of evaluating the script as an expression (optional)
- */
-dojo.hostenv.loadUri = function(uri, cb /*optional*/){
+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 1;
+ return true; // Boolean
}
var contents = this.getText(uri, null, true);
- if(contents == null){ return 0; }
+ if(!contents){ return false; } // Boolean
this.loadedUris[uri] = true;
if(cb){ contents = '('+contents+')'; }
var value = dj_eval(contents);
- if(cb){
- cb(value);
- }
- return 1;
+ if(cb){ cb(value); }
+ return true; // Boolean
}
// FIXME: probably need to add logging to this method
-dojo.hostenv.loadUriAndCheck = function(uri, module, cb){
+dojo.hostenv.loadUriAndCheck = function(/*String (URL)*/uri, /*String*/moduleName, /*Function?*/cb){
+ // summary: calls loadUri then findModule and returns true if both succeed
var ok = true;
try{
ok = this.loadUri(uri, cb);
}catch(e){
dojo.debug("failed loading ", uri, " with error: ", e);
}
- return ((ok)&&(this.findModule(module, false))) ? true : false;
+ return Boolean(ok && this.findModule(moduleName, false)); // Boolean
}
dojo.loaded = function(){ }
@@ -163,18 +174,24 @@
dojo.unloaded();
}
-/*
-Call styles:
- dojo.addOnLoad(functionPointer)
- dojo.addOnLoad(object, "functionName")
-*/
-dojo.addOnLoad = function(obj, fcnName) {
+dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName) {
+// summary:
+// Registers a function to be triggered after the DOM has finished loading
+// and widgets declared in markup have been instantiated. Images and CSS files
+// may or may not have finished downloading when the specified function is called.
+// (Note that widgets' CSS and HTML code is guaranteed to be downloaded before said
+// widgets are instantiated.)
+//
+// usage:
+// dojo.addOnLoad(functionPointer)
+// dojo.addOnLoad(object, "functionName")
+
var dh = dojo.hostenv;
if(arguments.length == 1) {
dh.modulesLoadedListeners.push(obj);
} else if(arguments.length > 1) {
dh.modulesLoadedListeners.push(function() {
- obj[fcnName]();
+ obj[functionName]();
});
}
@@ -187,20 +204,25 @@
}
}
-dojo.addOnUnload = function(obj, fcnName){
+dojo.addOnUnload = function(/*Object?*/obj, /*String|Function?*/functionName){
+// summary: registers a function to be triggered when the page unloads
+//
+// usage:
+// dojo.addOnLoad(functionPointer)
+// dojo.addOnLoad(object, "functionName")
var dh = dojo.hostenv;
if(arguments.length == 1){
dh.unloadListeners.push(obj);
} else if(arguments.length > 1) {
dh.unloadListeners.push(function() {
- obj[fcnName]();
+ obj[functionName]();
});
}
}
dojo.hostenv.modulesLoaded = function(){
if(this.post_load_){ return; }
- if((this.loadUriStack.length==0)&&(this.getTextStack.length==0)){
+ if(this.loadUriStack.length==0 && this.getTextStack.length==0){
if(this.inFlightCount > 0){
dojo.debug("files still in flight!");
return;
@@ -217,194 +239,214 @@
}
}
-dojo.hostenv.getModuleSymbols = function(modulename) {
+dojo.hostenv.getModuleSymbols = function(/*String*/modulename){
+// summary:
+// Converts a module name in dotted JS notation to an array representing the path in the source tree
+
var syms = modulename.split(".");
- for(var i = syms.length - 1; i > 0; i--){
+ for(var i = syms.length; i>0; i--){
var parentModule = syms.slice(0, i).join(".");
- var parentModulePath = this.getModulePrefix(parentModule);
- if(parentModulePath != parentModule){
- syms.splice(0, i, parentModulePath);
- break;
- }
- }
- return syms;
-}
-
-/**
-* 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 ((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(modulename, exact_only, omit_module_check){
- if(!modulename){ return; }
- omit_module_check = this._global_omit_module_check || omit_module_check;
- var module = this.findModule(modulename, 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);
+ if(dj_undef(moduleName, this.loading_modules_)){
+ this.addedToLoadingCount.push(moduleName);
}
- this.loading_modules_[modulename] = 1;
+ this.loading_modules_[moduleName] = 1;
// convert periods to slashes
- var relpath = modulename.replace(/\./g, '/') + '.js';
+ 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 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
- var nsyms = modulename.split(".");
if(last=="*"){
- modulename = (nsyms.slice(0, -1)).join('.');
-
+ moduleName = nsyms.slice(0, -1).join('.');
while(syms.length){
syms.pop();
syms.push(this.pkgFileName);
relpath = syms.join("/") + '.js';
- if(startedRelative && (relpath.charAt(0)=="/")){
+ if(startedRelative && relpath.charAt(0)=="/"){
relpath = relpath.slice(1);
}
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ ok = this.loadPath(relpath, !omitModuleCheck ? moduleName : null);
if(ok){ break; }
syms.pop();
}
}else{
relpath = syms.join("/") + '.js';
- modulename = nsyms.join('.');
- var ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
- if((!ok)&&(!exact_only)){
+ 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, ((!omit_module_check) ? modulename : null));
+ ok = this.loadPath(relpath, modArg);
if(ok){ break; }
syms.pop();
relpath = syms.join('/') + '/'+this.pkgFileName+'.js';
- if(startedRelative && (relpath.charAt(0)=="/")){
+ if(startedRelative && relpath.charAt(0)=="/"){
relpath = relpath.slice(1);
}
- ok = this.loadPath(relpath, ((!omit_module_check) ? modulename : null));
+ ok = this.loadPath(relpath, modArg);
if(ok){ break; }
}
}
- if((!ok)&&(!omit_module_check)){
- dojo.raise("Could not load '" + modulename + "'; last tried '" + relpath + "'");
+ 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(!omit_module_check && !this["isXDomain"]){
+ if(!omitModuleCheck && !this["isXDomain"]){
// pass in false so we can give better error
- module = this.findModule(modulename, false);
+ module = this.findModule(moduleName, false);
if(!module){
- dojo.raise("symbol '" + modulename + "' is not defined after loading '" + relpath + "'");
+ dojo.raise("symbol '" + moduleName + "' is not defined after loading '" + relpath + "'");
}
}
return module;
}
-/**
-* startPackage("A.B") follows the path, and at each level creates a new empty
-* object or uses what already exists. It returns the result.
-*/
-dojo.hostenv.startPackage = function(packname){
- var modref = dojo.evalObjPath((packname.split(".").slice(0, -1)).join('.'));
- this.loaded_modules_[(new String(packname)).toLowerCase()] = modref;
+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 = packname.split(/\./);
+ var syms = packageName.split(/\./);
if(syms[syms.length-1]=="*"){
syms.pop();
+ strippedPkgName = syms.join(".");
}
- return dojo.evalObjPath(syms.join("."), true);
+ var evaledPkg = dojo.evalObjPath(strippedPkgName, true);
+ this.loaded_modules_[fullPkgName] = evaledPkg;
+ this.loaded_modules_[strippedPkgName] = evaledPkg;
+
+ return evaledPkg; // Object
}
-/**
- * findModule("A.B") returns the object A.B if it exists, otherwise null.
- * @param modulename A string like 'A.B'.
- * @param must_exist Optional, defualt false. throw instead of returning null
- * if the module does not currently exist.
- */
-dojo.hostenv.findModule = function(modulename, must_exist){
- // check cache
- /*
- if(!dj_undef(modulename, this.modules_)){
- return this.modules_[modulename];
- }
- */
+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 = (new String(modulename)).toLowerCase();
+ var lmn = String(moduleName);
if(this.loaded_modules_[lmn]){
- return this.loaded_modules_[lmn];
- }
-
- // see if symbol is defined anyway
- var module = dojo.evalObjPath(modulename);
- if((modulename)&&(typeof module != 'undefined')&&(module)){
- this.loaded_modules_[lmn] = module;
- return module;
+ return this.loaded_modules_[lmn]; // Object
}
- if(must_exist){
- dojo.raise("no loaded module named '" + modulename + "'");
+ if(mustExist){
+ dojo.raise("no loaded module named '" + moduleName + "'");
}
- return null;
+ return null; // null
}
//Start of old bootstrap2:
-/*
- * 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.*" ]
- * });
- */
-dojo.kwCompoundRequire = function(modMap){
+dojo.kwCompoundRequire = function(/*Object containing Arrays*/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"]||[]);
+ 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];
@@ -416,12 +458,27 @@
}
}
-dojo.require = function(){
+dojo.require = function(/*String*/ resourceName){
+ // summary
+ // Ensure that the given resource (ie, javascript
+ // source file) has been loaded.
+ // description
+ // dojo.require() is similar to C's #include command or java's "import" command.
+ // You call dojo.require() to pull in the resources (ie, javascript source files)
+ // that define the functions you are using.
+ //
+ // Note that in the case of a build, many resources have already been included
+ // into dojo.js (ie, many of the javascript source files have been compressed and
+ // concatened into dojo.js), so many dojo.require() calls will simply return
+ // without downloading anything.
dojo.hostenv.loadModule.apply(dojo.hostenv, arguments);
}
-dojo.requireIf = function(){
- if((arguments[0] === true)||(arguments[0]=="common")||(arguments[0] && dojo.render[arguments[0]].capable)){
+dojo.requireIf = function(/*Boolean*/ condition, /*String*/ resourceName){
+ // summary
+ // If the condition is true then call dojo.require() for the specified resource
+ 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);
@@ -430,21 +487,241 @@
dojo.requireAfterIf = dojo.requireIf;
-dojo.provide = function(){
+dojo.provide = function(/*String*/ resourceName){
+ // summary
+ // Each javascript source file must have (exactly) one dojo.provide()
+ // call at the top of the file, corresponding to the file name.
+ // For example, dojo/src/foo.js must have dojo.provide("dojo.foo"); at the top of the file.
+ //
+ // description
+ // Each javascript source file is called a resource. When a resource
+ // is loaded by the browser, dojo.provide() registers that it has
+ // been loaded.
+ //
+ // For backwards compatibility reasons, in addition to registering the resource,
+ // dojo.provide() also ensures that the javascript object for the module exists. For
+ // example, dojo.provide("dojo.html.common"), in addition to registering that common.js
+ // is a resource for the dojo.html module, will ensure that the dojo.html javascript object
+ // exists, so that calls like dojo.html.foo = function(){ ... } don't fail.
+ //
+ // In the case of a build (or in the future, a rollup), where multiple javascript source
+ // files are combined into one bigger file (similar to a .lib or .jar file), that file
+ // will contain multiple dojo.provide() calls, to note that it includes
+ // multiple resources.
return dojo.hostenv.startPackage.apply(dojo.hostenv, arguments);
}
-dojo.setModulePrefix = function(module, prefix){
+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);
}
-// determine if an object supports a given method
-// useful for longer api chains where you have to test each object in the chain
-dojo.exists = function(obj, name){
+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;
+ if(!obj[p[i]]){ return false; } // Boolean
obj = obj[p[i]];
}
- return true;
+ 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; }
+ }
+}
+
+//These two functions are placed outside of preloadLocalizations
+//So that the xd loading can use/override them.
+dojo.hostenv.localesGenerated /***BUILD:localesGenerated***/; // value will be inserted here at build time, if necessary
+
+dojo.hostenv.registerNlsPrefix = function(){
+// summary:
+// Register module "nls" to point where Dojo can find pre-built localization files
+ dojo.registerModulePath("nls","nls");
+}
+
+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.
+
+ if(dojo.hostenv.localesGenerated){
+ dojo.hostenv.registerNlsPrefix();
+
+ function preload(locale){
+ locale = dojo.hostenv.normalizeLocale(locale);
+ dojo.hostenv.searchLocalePath(locale, true, function(loc){
+ for(var i=0; i<dojo.hostenv.localesGenerated.length;i++){
+ if(dojo.hostenv.localesGenerated[i] == loc){
+ dojo["require"]("nls.dojo_"+loc);
+ return true; // Boolean
+ }
+ }
+ return false; // Boolean
+ });
+ }
+ 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]);
+ }
+ };
+ }
+})();
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/loader_xd.js Fri Nov 10 01:15:01 2006
@@ -412,3 +412,26 @@
}
}
}
+
+//Need to preload any flattened i18n bundles before we start
+//executing code, since we cannot do it synchronously, as the
+//i18n code normally expects.
+dojo.hostenv.xdHasCalledPreload = false;
+dojo.hostenv.xdRealCallLoaded = dojo.hostenv.callLoaded;
+dojo.hostenv.callLoaded = function(){
+ //If getModulePrefix for dojo returns anything other than "src", that means
+ //there is a path registered for dojo, with implies that dojo was xdomain loaded.
+ if(this.xdHasCalledPreload || dojo.hostenv.getModulePrefix("dojo") == "src"){
+ this.xdRealCallLoaded();
+ this.xdHasCalledPreload = true;
+ }else{
+ if(this.localesGenerated){
+ this.registerNlsPrefix = function(){
+ //Need to set the nls prefix to be the xd location.
+ dojo.registerModulePath("nls", dojo.hostenv.getModulePrefix("dojo") + "/../nls");
+ };
+ this.preloadLocalizations();
+ }
+ this.xdHasCalledPreload = true;
+ }
+}
Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,108 @@
+/*
+ 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.logging.ConsoleLogger");
+dojo.require("dojo.logging.Logger");
+
+dojo.lang.extend(dojo.logging.MemoryLogHandler,{
+
+ debug:function(){
+ dojo.hostenv.println.apply(this,arguments);
+ },
+ info:function(){
+ dojo.hostenv.println.apply(this,arguments);
+ },
+ warn:function(){
+ dojo.hostenv.println.apply(this,arguments);
+ },
+ error:function(){
+ dojo.hostenv.println.apply(this,arguments);
+ },
+ critical:function(){
+ dojo.hostenv.println.apply(this,arguments);
+ },
+
+ emit:function(record){
+ if (!djConfig.isDebug) { return; }
+
+ var funcName=null;
+ switch(record.level){
+ case 1:
+ funcName="debug";
+ break;
+ case 2:
+ funcName="info";
+ break;
+ case 3:
+ funcName="warn";
+ break;
+ case 4:
+ funcName="error";
+ break;
+ case 5:
+ funcName="critical";
+ break;
+ default:
+ funcName="debug";
+ }
+
+ var logStr = String(dojo.log.getLevelName(record.level)+": "
+ +record.time.toLocaleTimeString())+": "+record.message;
+ if(record.msgArgs && record.msgArgs.length > 0){
+ this[funcName].call(this, logStr, record.msgArgs);
+ } else {
+ this[funcName].call(this, logStr);
+ }
+
+ this.data.push(record);
+ if(this.numRecords != -1){
+ while(this.data.length>this.numRecords){
+ this.data.shift();
+ }
+ }
+ }
+});
+
+if(!dj_undef("console") && !dj_undef("info", console)){
+dojo.lang.extend(dojo.logging.MemoryLogHandler,{
+ debug:function(){
+ console.debug.apply(this, arguments);
+ },
+ info:function(){
+ console.info.apply(this, arguments);
+ },
+ warn:function(){
+ console.warn.apply(this, arguments);
+ },
+ error:function(){
+ console.error.apply(this, arguments);
+ },
+ critical:function(){
+ console.error.apply(this, arguments);
+ }
+});
+
+dojo.lang.extend(dojo.logging.Logger,{
+ exception: function(msg, e, squelch){
+ var args=[msg];
+
+ if(e){
+ msg+=" : "+ e.name + " " + (e.description||e.message);
+ args.push(e);
+ }
+
+ this.logType("ERROR", args);
+ if(!squelch){
+ throw e;
+ }
+ }
+});
+
+}
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js
------------------------------------------------------------------------------
svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"
Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/ConsoleLogger.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/Logger.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/Logger.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/Logger.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/Logger.js Fri Nov 10 01:15:01 2006
@@ -52,8 +52,7 @@
// Dependencies: none
dojo.provide("dojo.logging.Logger");
-dojo.provide("dojo.log");
-dojo.require("dojo.lang");
+dojo.require("dojo.lang.common");
/*
A simple data structure class that stores information for and about
@@ -64,8 +63,18 @@
dojo.logging.Record = function(lvl, msg){
this.level = lvl;
- this.message = msg;
+ this.message = "";
+ this.msgArgs = [];
this.time = new Date();
+
+ if(dojo.lang.isArray(msg)){
+ if(msg.length > 0 && dojo.lang.isString(msg[0])){
+ this.message=msg.shift();
+ }
+ this.msgArgs=msg;
+ }else{
+ this.message=msg;
+ }
// FIXME: what other information can we receive/discover here?
}
@@ -89,7 +98,7 @@
this.handlers = [];
}
-dojo.lang.extend(dojo.logging.Logger, {
+dojo.extend(dojo.logging.Logger,{
argsToArr: function(args){
// utility function, reproduced from __util__ here to remove dependency
var ret = [];
@@ -235,31 +244,21 @@
},
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);
+ return this.log.apply(this, [dojo.logging.log.getLevel(type),
+ args]);
+ },
+
+ warn:function(){
+ this.warning.apply(this,arguments);
+ },
+ err:function(){
+ this.error.apply(this,arguments);
+ },
+ crit:function(){
+ this.critical.apply(this,arguments);
}
});
-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;
@@ -267,35 +266,26 @@
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.lang.extend(dojo.logging.LogHandler,{
+
+ setFormatter:function(formatter){
+ dojo.unimplemented("setFormatter");
+ },
+
+ flush:function(){},
+ close:function(){},
+ handleError:function(){},
+
+ handle:function(record){
+ if((this.filter(record))&&(record.level>=this.cutOffLevel)){
+ this.emit(record);
+ }
+ },
+
+ emit:function(record){
+ dojo.unimplemented("emit");
}
-}
-
-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
@@ -368,41 +358,30 @@
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.lang.inherits(dojo.logging.MemoryLogHandler, dojo.logging.LogHandler);
+dojo.lang.extend(dojo.logging.MemoryLogHandler,{
+
+ emit:function(record){
+ if (!djConfig.isDebug) { return; }
+
+ 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.logQueueHandler = new dojo.logging.MemoryLogHandler(0,50,0,10000);
-// actual logging event handler
-dojo.logging.logQueueHandler.emit = function(record){
- // we should probably abstract this in the future
- var logStr = String(dojo.log.getLevelName(record.level)+": "+record.time.toLocaleTimeString())+": "+record.message;
- if(!dj_undef("debug", dj_global)){
- dojo.debug(logStr);
- }else if((typeof dj_global["print"] == "function")&&(!dojo.render.html.capable)){
- print(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;
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/__package__.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/__package__.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/__package__.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/logging/__package__.js Fri Nov 10 01:15:01 2006
@@ -9,7 +9,7 @@
*/
dojo.kwCompoundRequire({
- common: ["dojo.logging.Logger", false, false],
+ common: [["dojo.logging.Logger", false, false]],
rhino: ["dojo.logging.RhinoLogger"]
});
dojo.provide("dojo.logging.*");
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math.js Fri Nov 10 01:15:01 2006
@@ -10,39 +10,49 @@
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.degToRad = function(/* float */x) {
+ // summary
+ // Converts degrees to radians.
+ return (x*Math.PI) / 180; // float
+}
+dojo.math.radToDeg = function(/* float */x) {
+ // summary
+ // Converts radians to degrees.
+ return (x*180) / Math.PI; // float
+}
-dojo.math.factorial = function (n) {
+dojo.math.factorial = function(/* integer */n){
+ // summary
+ // Returns n!
if(n<1){ return 0; }
var retVal = 1;
for(var i=1;i<=n;i++){ retVal *= i; }
- return retVal;
+ return retVal; // integer
}
-//The number of ways of obtaining an ordered subset of k elements from a set of n elements
-dojo.math.permutations = function (n,k) {
+dojo.math.permutations = function(/* integer */n, /* integer */k) {
+ // summary
+ // The number of ways of obtaining an ordered subset of k elements from a set of n elements
if(n==0 || k==0) return 1;
- return (dojo.math.factorial(n) / dojo.math.factorial(n-k));
+ return (dojo.math.factorial(n) / dojo.math.factorial(n-k)); // float
}
-//The number of ways of picking n unordered outcomes from r possibilities
-dojo.math.combinations = function (n,r) {
+dojo.math.combinations = function (/* integer */n, /* integer */r) {
+ // summary
+ // The number of ways of picking n unordered outcomes from r possibilities
if(n==0 || r==0) return 1;
- return (dojo.math.factorial(n) / (dojo.math.factorial(n-r) * dojo.math.factorial(r)));
+ return (dojo.math.factorial(n) / (dojo.math.factorial(n-r) * dojo.math.factorial(r))); // float
}
-dojo.math.bernstein = function (t,n,i) {
- return (dojo.math.combinations(n,i) * Math.pow(t,i) * Math.pow(1-t,n-i));
+dojo.math.bernstein = function(/* float */t, /* float */n, /* float */i) {
+ // summary
+ // Calculates a weighted average based on the Bernstein theorem.
+ return (dojo.math.combinations(n,i) * Math.pow(t,i) * Math.pow(1-t,n-i)); // float
}
-/**
- * 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 () {
+dojo.math.gaussianRandom = function(){
+ // summary
+ // Returns random numbers with a Gaussian distribution, with the mean set at 0 and the variance set at 1.
var k = 2;
do {
var i = 2 * Math.random() - 1;
@@ -50,66 +60,49 @@
k = i * i + j * j;
} while (k >= 1);
k = Math.sqrt((-2 * Math.log(k)) / k);
- return i * k;
+ return i * k; // float
}
-/**
- * Calculates the mean of an Array of numbers.
- *
- * @return The mean of the numbers in the Array
- */
-dojo.math.mean = function () {
+dojo.math.mean = function() {
+ // summary
+ // Calculates the mean of an Array of numbers.
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;
+ return mean / array.length; // float
}
-/**
- * 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) {
+dojo.math.round = function(/* float */number, /* integer */places) {
+ // summary
+ // Extends Math.round by adding a second argument specifying the number of decimal places to round to.
+ // TODO: add support for significant figures
if (!places) { var shift = 1; }
else { var shift = Math.pow(10, places); }
- return Math.round(number * shift) / shift;
+ return Math.round(number * shift) / shift; // float
}
-/**
- * Calculates the standard deviation of an Array of numbers
- *
- * @return The standard deviation of the numbers
- */
-dojo.math.sd = function () {
+dojo.math.sd = dojo.math.standardDeviation = function(/* array */){
+ // summary
+ // Calculates the standard deviation of an Array of numbers
var array = dojo.lang.isArray(arguments[0]) ? arguments[0] : arguments;
- return Math.sqrt(dojo.math.variance(array));
+ return Math.sqrt(dojo.math.variance(array)); // float
}
-/**
- * Calculates the variance of an Array of numbers
- *
- * @return The variance of the numbers
- */
-dojo.math.variance = function () {
+dojo.math.variance = function(/* array */) {
+ // summary
+ // Calculates the variance of an Array of numbers
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);
+ return (squares / array.length) - Math.pow(mean / array.length, 2); // float
}
-/**
- * Like range() in python
-**/
-dojo.math.range = function(a, b, step) {
+dojo.math.range = function(/* integer */a, /* integer */b, /* integer */step) {
+ // summary
+ // implementation of Python's range()
if(arguments.length < 2) {
b = a;
a = 0;
@@ -130,5 +123,5 @@
} else {
throw new Error("dojo.math.range: step must be non-zero");
}
- return range;
+ return range; // array
}
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math/curves.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math/curves.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math/curves.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/math/curves.js Fri Nov 10 01:15:01 2006
@@ -9,7 +9,6 @@
*/
dojo.provide("dojo.math.curves");
-
dojo.require("dojo.math");
/* Curves from Dan's 13th lib stuff.
@@ -18,8 +17,9 @@
*/
dojo.math.curves = {
- //Creates a straight line object
- Line: function(start, end) {
+ Line: function(/* array */start, /* array */end) {
+ // summary
+ // Creates a straight line object
this.start = start;
this.end = end;
this.dimensions = start.length;
@@ -33,21 +33,25 @@
}
//simple function to find point on an n-dimensional, straight line
- this.getValue = function(n) {
+ this.getValue = function(/* float */n){
+ // summary
+ // Returns the point at point N (in terms of percentage) on this line.
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 retVal; // array
}
-
- return this;
+ return this; // dojo.math.curves.Line
},
-
- //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) {
+ Bezier: function(/* array */pnts) {
+ // summary
+ // Creates a bezier curve
+ // 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.
+ this.getValue = function(/* float */step) {
+ // summary
+ // Returns the point at point N (in terms of percentage) on this curve.
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);
@@ -63,16 +67,18 @@
}
retVal[j] = C/D;
}
- return retVal;
+ return retVal; // array
}
this.p = pnts;
- return this;
+ return this; // dojo.math.curves.Bezier
},
-
- //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) {
+ CatmullRom : function(/* array */pnts, /* float */c) {
+ // summary
+ // Creates a catmull-rom spline curve with c tension.
+ this.getValue = function(/* float */step) {
+ // summary
+ // Returns the point at point N (in terms of percentage) on this curve.
var percent = step * (this.p.length-1);
var node = Math.floor(percent);
var progress = percent - node;
@@ -95,21 +101,21 @@
retVal[k] = x1*u3 + x2*u2 + x3*u + x4;
}
- return retVal;
-
+ return retVal; // array
}
-
if(!c) this.c = 0.7;
else this.c = c;
this.p = pnts;
- return this;
+ return this; // dojo.math.curves.CatmullRom
},
// 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) {
+ Arc : function(/* array */start, /* array */end, /* boolean? */ccw) {
+ // summary
+ // Creates an arc with a counter clockwise switch
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));
@@ -122,43 +128,51 @@
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) {
+ CenteredArc : function(/* array */center, /* float */radius, /* array */start, /* array */end) {
+ // summary
+ // 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
this.center = center;
this.radius = radius;
this.start = start || 0;
this.end = end;
- this.getValue = function(n) {
+ this.getValue = function(/* float */n) {
+ // summary
+ // Returns the point at point N (in terms of percentage) on this curve.
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 retVal; // array
}
- return this;
+ return this; // dojo.math.curves.CenteredArc
},
- // Special case of Arc (start = 0, end = 360)
- Circle : function(center, radius) {
+ Circle : function(/* array */center, /* float */radius) {
+ // summary
+ // Special case of Arc (start = 0, end = 360)
dojo.math.curves.CenteredArc.call(this, center, radius, 0, 360);
- return this;
+ return this; // dojo.math.curves.Circle
},
Path : function() {
+ // summary
+ // Generic path shape, created from curve segments
var curves = [];
var weights = [];
var ranges = [];
var totalWeight = 0;
- this.add = function(curve, weight) {
+ this.add = function(/* dojo.math.curves.* */curve, /* float */weight) {
+ // summary
+ // Add a curve segment to this path
if( weight < 0 ) { dojo.raise("dojo.math.curves.Path.add: weight cannot be less than 0"); }
curves.push(curve);
weights.push(weight);
@@ -166,7 +180,9 @@
computeRanges();
}
- this.remove = function(curve) {
+ this.remove = function(/* dojo.math.curves.* */curve) {
+ // summary
+ // Remove a curve segment from this path
for(var i = 0; i < curves.length; i++) {
if( curves[i] == curve ) {
curves.splice(i, 1);
@@ -178,12 +194,16 @@
}
this.removeAll = function() {
+ // summary
+ // Remove all curve segments
curves = [];
weights = [];
totalWeight = 0;
}
- this.getValue = function(n) {
+ this.getValue = function(/* float */n) {
+ // summary
+ // Returns the point at point N (in terms of percentage) on this curve.
var found = false, value = 0;
for(var i = 0; i < ranges.length; i++) {
var r = ranges[i];
@@ -204,7 +224,7 @@
for(var j = 0; j < i; j++) {
value = dojo.math.points.translate(value, curves[j].getValue(1));
}
- return value;
+ return value; // array
}
function computeRanges() {
@@ -217,6 +237,6 @@
}
}
- return this;
+ return this; // dojo.math.curves.Path
}
};