You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2006/09/29 05:43:06 UTC

svn commit: r451106 [28/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/widget/Menu2.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,700 @@
+/*
+	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.widget.Menu2");
+
+dojo.require("dojo.widget.PopupContainer");
+
+dojo.widget.defineWidget(
+	"dojo.widget.PopupMenu2",
+	dojo.widget.PopupContainer,
+	function(){
+		this.targetNodeIds = []; // fill this with nodeIds upon widget creation and it becomes context menu for those nodes
+	
+		this.eventNames =  {
+			open: ""
+		};
+	},
+{
+	templateCssString: "",
+	currentSubmenuTrigger: null,
+	snarfChildDomOutput: true,
+
+	eventNaming: "default",
+
+	templateString: '<table class="dojoPopupMenu2" border=0 cellspacing=0 cellpadding=0 style="display: none;"><tbody dojoAttachPoint="containerNode"></tbody></table>',
+	templateCssPath: dojo.uri.dojoUri("src/widget/templates/Menu2.css"),
+
+	submenuDelay: 500,
+	submenuOverlap: 5,
+	contextMenuForWindow: false,
+	openEvent: null,
+
+	_highlighted_option: null,
+
+	initialize: function(args, frag) {
+		if (this.eventNaming == "default") {
+			for (var eventName in this.eventNames) {
+				this.eventNames[eventName] = this.widgetId+"/"+eventName;
+			}
+		}
+	},
+
+	postCreate: function(){
+		if (this.contextMenuForWindow){
+			var doc = dojo.body();
+			this.bindDomNode(doc);
+		} else if ( this.targetNodeIds.length > 0 ){
+			dojo.lang.forEach(this.targetNodeIds, this.bindDomNode, this);
+		}
+
+		this.subscribeSubitemsOnOpen();
+	},
+
+	subscribeSubitemsOnOpen: function() {
+		var subItems = this.getChildrenOfType(dojo.widget.MenuItem2);
+
+		for(var i=0; i<subItems.length; i++) {
+			dojo.event.topic.subscribe(this.eventNames.open, subItems[i], "menuOpen")
+		}
+	},
+
+	// get open event for current menu
+	getTopOpenEvent: function() {
+		var menu = this;
+		while (menu.parentPopup){ menu = menu.parentPopup; }
+		return menu.openEvent;
+	},
+
+	// attach menu to given node
+	bindDomNode: function(node){
+		node = dojo.byId(node);
+
+		var win = dojo.html.getElementWindow(node);
+		if(dojo.html.isTag(node,'iframe') == 'iframe'){
+			win = dojo.html.iframeContentWindow(node);
+			node = dojo.withGlobal(win, dojo.body);
+		}
+		// fixes node so that it supports oncontextmenu if not natively supported, Konqueror, Opera more?
+		dojo.widget.Menu2.OperaAndKonqFixer.fixNode(node);
+
+		dojo.event.kwConnect({
+			srcObj:     node,
+			srcFunc:    "oncontextmenu",
+			targetObj:  this,
+			targetFunc: "onOpen",
+			once:       true
+		});
+
+		//normal connect does not work if document.designMode is on in FF, use addListener instead
+		if(dojo.render.html.moz && win.document.designMode.toLowerCase() == 'on'){
+			dojo.event.browser.addListener(node, "contextmenu", dojo.lang.hitch(this, "onOpen"));
+		}
+		dojo.widget.PopupManager.registerWin(win);
+	},
+
+	// detach menu from given node
+	unBindDomNode: function(nodeName){
+		var node = dojo.byId(nodeName);
+		dojo.event.kwDisconnect({
+			srcObj:     node,
+			srcFunc:    "oncontextmenu",
+			targetObj:  this,
+			targetFunc: "onOpen",
+			once:       true
+		});
+
+		// cleans a fixed node, konqueror and opera
+		dojo.widget.Menu2.OperaAndKonqFixer.cleanNode(node);
+	},
+
+	moveToNext: function(evt){
+		this.highlightOption(1);
+		return true; //do not pass to parent menu
+	},
+
+	moveToPrevious: function(evt){
+		this.highlightOption(-1);
+		return true; //do not pass to parent menu
+	},
+
+	moveToParentMenu: function(evt){
+		if(this._highlighted_option && this.parentPopup){
+			//only process event in the focused menu
+			//and its immediate parentPopup to support
+			//MenuBar2
+			if(evt._menu2UpKeyProcessed){
+				return true; //do not pass to parent menu
+			}else{
+				this._highlighted_option.onUnhover();
+				this.closeSubpopup();
+				evt._menu2UpKeyProcessed = true;
+			}
+		}
+		return false;
+	},
+
+	moveToChildMenu: function(evt){
+		if(this._highlighted_option && this._highlighted_option.submenuId){
+			this._highlighted_option._onClick(true);
+			return true; //do not pass to parent menu
+		}
+		return false;
+	},
+
+	selectCurrentItem: function(evt){
+		if(this._highlighted_option){
+			this._highlighted_option._onClick();
+			return true;
+		}
+		return false;
+	},
+
+	//return true to stop the event being processed by the
+	//parent popupmenu
+	processKey: function(evt){
+		if(evt.ctrlKey || evt.altKey || !evt.key){ return false; }
+
+		var rval = false;
+		switch(evt.key){
+ 			case evt.KEY_DOWN_ARROW:
+				rval = this.moveToNext(evt);
+				break;
+			case evt.KEY_UP_ARROW:
+				rval = this.moveToPrevious(evt);
+				break;
+			case evt.KEY_RIGHT_ARROW:
+				rval = this.moveToChildMenu(evt);
+				break;
+			case evt.KEY_LEFT_ARROW:
+				rval = this.moveToParentMenu(evt);
+				break;
+			case " ": //fall through
+			case evt.KEY_ENTER: 
+				if(rval = this.selectCurrentItem(evt)){
+					break;
+				}
+				//fall through
+			case evt.KEY_ESCAPE:
+				dojo.widget.PopupManager.currentMenu.close();
+				rval = true;
+				break;
+		}
+
+		return rval;
+	},
+
+	findValidItem: function(dir, curItem){
+		if(curItem){
+			curItem = dir>0 ? curItem.getNextSibling() : curItem.getPreviousSibling();
+		}
+
+		for(var i=0; i < this.children.length; ++i){
+			if(!curItem){
+				curItem = dir>0 ? this.children[0] : this.children[this.children.length-1];
+			}
+			//find next/previous visible menu item, not including separators
+			if(curItem.onHover && curItem.isShowing()){
+				return curItem;
+			}
+			curItem = dir>0 ? curItem.getNextSibling() : curItem.getPreviousSibling();
+		}
+	},
+	
+	highlightOption: function(dir){
+		var item;
+		// || !this._highlighted_option.parentNode
+		if((!this._highlighted_option)){
+			item = this.findValidItem(dir);
+		}else{
+			item = this.findValidItem(dir, this._highlighted_option);
+		}
+		if(item){
+			if(this._highlighted_option) {
+				this._highlighted_option.onUnhover();
+			}
+			item.onHover();
+			dojo.html.scrollIntoView(item.domNode);
+			// navigate into the item table and select the first caption tag
+			try {
+				var node = dojo.html.getElementsByClass("dojoMenuItem2Label", item.domNode)[0];
+				node.focus();
+			} catch(e) { }
+		}
+	},
+
+	// User defined function to handle clicks on an item
+	onItemClick: function(item) {},
+
+	close: function(force){
+		if(this.animationInProgress){
+			dojo.widget.PopupMenu2.superclass.close.apply(this, arguments);
+			return;
+		}
+
+		if(this._highlighted_option){
+			this._highlighted_option.onUnhover();
+		}
+
+		dojo.widget.PopupMenu2.superclass.close.apply(this, arguments);
+	},
+
+	//overwrite the default one
+	closeSubpopup: function(force){
+		if (this.currentSubpopup == null){ return; }
+
+		this.currentSubpopup.close(force);
+		this.currentSubpopup = null;
+
+		this.currentSubmenuTrigger.is_open = false;
+		this.currentSubmenuTrigger.closedSubmenu(force);
+		this.currentSubmenuTrigger = null;
+	},
+
+	// open the menu to the right of the current menu item
+	openSubmenu: function(submenu, from_item){
+		var fromPos = dojo.html.getAbsolutePosition(from_item.domNode, true);
+		var our_w = dojo.html.getMarginBox(this.domNode).width;
+		var x = fromPos.x + our_w - this.submenuOverlap;
+		var y = fromPos.y;
+
+		//the following is set in open, so we do not need it
+		//this.currentSubpopup = submenu;
+		submenu.open(x, y, this, from_item.domNode);
+
+		this.currentSubmenuTrigger = from_item;
+		this.currentSubmenuTrigger.is_open = true;
+	},
+
+	onOpen: function(e){
+		this.openEvent = e;
+		if(e["target"]){
+			this.openedForWindow = dojo.html.getElementWindow(e.target);
+		}else{
+			this.openedForWindow = null;
+		}
+		var x = e.pageX, y = e.pageY;
+
+		var win = dojo.html.getElementWindow(e.target);
+		var iframe = win._frameElement || win.frameElement;
+		if(iframe){
+			var cood = dojo.html.abs(iframe, true);
+			x += cood.x - dojo.withGlobal(win, dojo.html.getScroll).left;
+			y += cood.y - dojo.withGlobal(win, dojo.html.getScroll).top;
+		}
+		this.open(x, y, null, [x, y]);
+
+		e.preventDefault();
+		e.stopPropagation();
+	}
+});
+
+dojo.widget.defineWidget(
+	"dojo.widget.MenuItem2",
+	dojo.widget.HtmlWidget,
+	function(){
+		this.eventNames = {
+			engage: ""
+		};
+	},
+{
+	// Make 4 columns
+	//   icon, label, accelerator-key, and right-arrow indicating sub-menu
+	templateString:
+		 '<tr class="dojoMenuItem2" dojoAttachEvent="onMouseOver: onHover; onMouseOut: onUnhover; onClick: _onClick; onKey:onKey;">'
+		+'<td><div class="${this.iconClass}" style="${this.iconStyle}"></div></td>'
+		+'<td tabIndex="-1" class="dojoMenuItem2Label">${this.caption}</td>'
+		+'<td class="dojoMenuItem2Accel">${this.accelKey}</td>'
+		+'<td><div class="dojoMenuItem2Submenu" style="display:${this.arrowDisplay};"></div></td>'
+		+'</tr>',
+
+	//
+	// internal settings
+	//
+
+	is_hovering: false,
+	hover_timer: null,
+	is_open: false,
+	topPosition: 0,
+
+	//
+	// options
+	//
+
+	caption: 'Untitled',
+	accelKey: '',
+	iconSrc: '',
+	iconClass: 'dojoMenuItem2Icon',
+	submenuId: '',
+	disabled: false,
+	eventNaming: "default",
+	highlightClass: 'dojoMenuItem2Hover',
+
+	postMixInProperties: function(){
+		this.iconStyle="";
+		if (this.iconSrc){
+			if ((this.iconSrc.toLowerCase().substring(this.iconSrc.length-4) == ".png") && (dojo.render.html.ie55 || dojo.render.html.ie60)){
+				this.iconStyle="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.iconSrc+"', sizingMethod='image')";
+			}else{
+				this.iconStyle="background-image: url("+this.iconSrc+")";
+			}
+		}
+		this.arrowDisplay = this.submenuId ? 'block' : 'none';
+		dojo.widget.MenuItem2.superclass.postMixInProperties.apply(this, arguments);
+	},
+
+	fillInTemplate: function(){
+		dojo.html.disableSelection(this.domNode);
+
+		if (this.disabled){
+			this.setDisabled(true);
+		}
+
+		if (this.eventNaming == "default") {
+			for (var eventName in this.eventNames) {
+				this.eventNames[eventName] = this.widgetId+"/"+eventName;
+			}
+		}
+	},
+
+	onHover: function(){
+		//this is to prevent some annoying behavior when both mouse and keyboard are used
+		this.onUnhover();
+
+		if (this.is_hovering){ return; }
+		if (this.is_open){ return; }
+
+		if(this.parent._highlighted_option){
+			this.parent._highlighted_option.onUnhover();
+		}
+		this.parent.closeSubpopup();
+		this.parent._highlighted_option = this;
+		dojo.widget.PopupManager.setFocusedMenu(this.parent);
+
+		this.highlightItem();
+
+		if (this.is_hovering){ this.stopSubmenuTimer(); }
+		this.is_hovering = true;
+		this.startSubmenuTimer();
+	},
+
+	onUnhover: function(){
+		if(!this.is_open){ this.unhighlightItem(); }
+
+		this.is_hovering = false;
+
+		this.parent._highlighted_option = null;
+
+		if(this.parent.parentPopup){
+			dojo.widget.PopupManager.setFocusedMenu(this.parent.parentPopup);
+		}
+
+		this.stopSubmenuTimer();
+	},
+
+	// Internal function for clicks
+	_onClick: function(focus){
+		var displayingSubMenu = false;
+		if (this.disabled){ return false; }
+
+		if (this.submenuId){
+			if (!this.is_open){
+				this.stopSubmenuTimer();
+				this.openSubmenu();
+			}
+			displayingSubMenu = true;
+		}else{
+			// for some browsers the onMouseOut doesn't get called (?), so call it manually
+			this.onUnhover(); //only onUnhover when no submenu is available
+			this.parent.closeAll(true);
+		}
+
+		// user defined handler for click
+		this.onClick();
+
+		dojo.event.topic.publish(this.eventNames.engage, this);
+
+		if(displayingSubMenu && focus){
+			dojo.widget.getWidgetById(this.submenuId).highlightOption(1);
+		}
+		return;
+	},
+
+	// User defined function to handle clicks
+	// this default function call the parent
+	// menu's onItemClick
+	onClick: function() {
+		this.parent.onItemClick(this);
+	},
+
+	highlightItem: function(){
+		dojo.html.addClass(this.domNode, this.highlightClass);
+	},
+
+	unhighlightItem: function(){
+		dojo.html.removeClass(this.domNode, this.highlightClass);
+	},
+
+	startSubmenuTimer: function(){
+		this.stopSubmenuTimer();
+
+		if (this.disabled){ return; }
+
+		var self = this;
+		var closure = function(){ return function(){ self.openSubmenu(); } }();
+
+		this.hover_timer = dojo.lang.setTimeout(closure, this.parent.submenuDelay);
+	},
+
+	stopSubmenuTimer: function(){
+		if (this.hover_timer){
+			dojo.lang.clearTimeout(this.hover_timer);
+			this.hover_timer = null;
+		}
+	},
+
+	openSubmenu: function(){
+		// first close any other open submenu
+		this.parent.closeSubpopup();
+
+		var submenu = dojo.widget.getWidgetById(this.submenuId);
+		if (submenu){
+			this.parent.openSubmenu(submenu, this);
+		}
+	},
+
+	closedSubmenu: function(){
+		this.onUnhover();
+	},
+
+	setDisabled: function(value){
+		this.disabled = value;
+
+		if (this.disabled){
+			dojo.html.addClass(this.domNode, 'dojoMenuItem2Disabled');
+		}else{
+			dojo.html.removeClass(this.domNode, 'dojoMenuItem2Disabled');
+		}
+	},
+
+	enable: function(){
+		this.setDisabled(false);
+	},
+
+	disable: function(){
+		this.setDisabled(true);
+	},
+
+	menuOpen: function(message) {
+	}
+
+});
+
+dojo.widget.defineWidget(
+	"dojo.widget.MenuSeparator2",
+	dojo.widget.HtmlWidget,
+{
+	templateString: '<tr class="dojoMenuSeparator2"><td colspan=4>'
+			+'<div class="dojoMenuSeparator2Top"></div>'
+			+'<div class="dojoMenuSeparator2Bottom"></div>'
+			+'</td></tr>',
+
+	postCreate: function(){
+		dojo.html.disableSelection(this.domNode);
+	}
+});
+
+dojo.widget.defineWidget(
+	"dojo.widget.MenuBar2",
+	dojo.widget.PopupMenu2,
+{
+	menuOverlap: 2,
+
+	templateString: '<div class="dojoMenuBar2" tabIndex="0"><table class="dojoMenuBar2Client"><tr dojoAttachPoint="containerNode"></tr></table></div>',
+
+	close: function(force){
+		if(this._highlighted_option){
+			this._highlighted_option.onUnhover();
+		}
+
+		this.closeSubpopup(force);
+	},
+
+	processKey: function(evt){
+		if(evt.ctrlKey || evt.altKey){ return false; }
+
+		if (!dojo.html.hasClass(evt.target,"dojoMenuBar2")) { return false; }
+		var rval = false;
+
+		switch(evt.key){
+ 			case evt.KEY_DOWN_ARROW:
+				rval = this.moveToChildMenu(evt);
+				break;
+			case evt.KEY_UP_ARROW:
+				rval = this.moveToParentMenu(evt);
+				break;
+			case evt.KEY_RIGHT_ARROW:
+				rval = this.moveToNext(evt);
+				break;
+			case evt.KEY_LEFT_ARROW:
+				rval = this.moveToPrevious(evt);
+				break;
+			default:
+				rval = this.inherited("processKey", [evt]);
+				break;
+		}
+
+		return rval;
+	},
+
+	postCreate: function(){
+		this.inherited("postCreate");
+		dojo.widget.PopupManager.opened(this);
+		this.isShowingNow = true;
+	},
+
+	/*
+	 * override PopupMenu2 to open the submenu below us rather than to our right
+	 */
+	openSubmenu: function(submenu, from_item){
+		var fromPos = dojo.html.getAbsolutePosition(from_item.domNode, true);
+		var ourPos = dojo.html.getAbsolutePosition(this.domNode, true);
+		var our_h = dojo.html.getBorderBox(this.domNode).height;
+		var x = fromPos.x;
+		var y = ourPos.y + our_h - this.menuOverlap;
+
+		submenu.open(x, y, this, from_item.domNode);
+
+		this.currentSubmenuTrigger = from_item;
+		this.currentSubmenuTrigger.is_open = true;
+	}
+});
+
+dojo.widget.defineWidget(
+	"dojo.widget.MenuBarItem2",
+	dojo.widget.MenuItem2,
+{
+	templateString:
+		 '<td class="dojoMenuBarItem2" dojoAttachEvent="onMouseOver: onHover; onMouseOut: onUnhover; onClick: _onClick;">'
+		+'<span><span>${this.caption}</span>${this.caption}</span>'
+		+'</td>',
+
+	highlightClass: 'dojoMenuBarItem2Hover',
+
+	setDisabled: function(value){
+		this.disabled = value;
+		if (this.disabled){
+			dojo.html.addClass(this.domNode, 'dojoMenuBarItem2Disabled');
+		}else{
+			dojo.html.removeClass(this.domNode, 'dojoMenuBarItem2Disabled');
+		}
+	}
+});
+
+
+// ************************** make contextmenu work in konqueror and opera *********************
+dojo.widget.Menu2.OperaAndKonqFixer = new function(){
+ 	var implement = true;
+ 	var delfunc = false;
+
+ 	/** 	dom event check
+ 	*
+ 	*	make a event and dispatch it and se if it calls function below,
+ 	*	if it indeed is supported and we dont need to implement our own
+ 	*/
+
+ 	// gets called if we have support for oncontextmenu
+ 	if (!dojo.lang.isFunction(dojo.doc().oncontextmenu)){
+ 		dojo.doc().oncontextmenu = function(){
+ 			implement = false;
+ 			delfunc = true;
+ 		}
+ 	}
+
+ 	if (dojo.doc().createEvent){ // moz, safari has contextmenu event, need to do livecheck on this env.
+ 		try {
+ 			var e = dojo.doc().createEvent("MouseEvents");
+ 			e.initMouseEvent("contextmenu", 1, 1, dojo.global(), 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
+ 			dojo.doc().dispatchEvent(e);
+ 		} catch (e) {/* assume not supported */}
+ 	} else {
+ 		// IE no need to implement custom contextmenu
+ 		implement = false;
+ 	}
+
+ 	// clear this one if it wasn't there before
+ 	if (delfunc){
+ 		delete dojo.doc().oncontextmenu;
+ 	}
+ 	/***** end dom event check *****/
+
+
+ 	/**
+ 	*	this fixes a dom node by attaching a custom oncontextmenu function that gets called when apropriate
+ 	*	@param	node	a dom node
+ 	*
+ 	*	no returns
+ 	*/
+ 	this.fixNode = function(node){
+ 		if (implement){
+ 			// attach stub oncontextmenu function
+ 			if (!dojo.lang.isFunction(node.oncontextmenu)){
+ 				node.oncontextmenu = function(e){/*stub*/}
+ 			}
+
+ 			// attach control function for oncontextmenu
+ 			if (dojo.render.html.opera){
+ 				// opera
+ 				// listen to ctrl-click events
+ 				node._menufixer_opera = function(e){
+ 					if (e.ctrlKey){
+ 						this.oncontextmenu(e);
+ 					}
+ 				};
+
+ 				dojo.event.connect(node, "onclick", node, "_menufixer_opera");
+
+ 			} else {
+ 				// konqueror
+ 				// rightclick, listen to mousedown events
+ 				node._menufixer_konq = function(e){
+ 					if (e.button==2 ){
+ 						e.preventDefault(); // need to prevent browsers menu
+ 						this.oncontextmenu(e);
+ 					}
+ 				};
+
+ 				dojo.event.connect(node, "onmousedown", node, "_menufixer_konq");
+ 			}
+ 		}
+ 	}
+
+ 	/**
+ 	*	this cleans up a fixed node, prevent memoryleak?
+ 	*	@param node	node to clean
+ 	*
+ 	*	no returns
+ 	*/
+ 	this.cleanNode = function(node){
+ 		if (implement){
+ 			// checks needed if we gets a non fixed node
+ 			if (node._menufixer_opera){
+ 				dojo.event.disconnect(node, "onclick", node, "_menufixer_opera");
+ 				delete node._menufixer_opera;
+ 			} else if(node._menufixer_konq){
+ 				dojo.event.disconnect(node, "onmousedown", node, "_menufixer_konq");
+ 				delete node._menufixer_konq;
+ 			}
+ 			if (node.oncontextmenu){
+ 				delete node.oncontextmenu;
+ 			}
+ 		}
+ 	}
+};
\ No newline at end of file

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Menu2.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/MonthlyCalendar.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/MonthlyCalendar.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/MonthlyCalendar.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/MonthlyCalendar.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,181 @@
+/*
+	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.widget.MonthlyCalendar");
+dojo.require("dojo.date.common");
+dojo.require("dojo.date.format");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.DatePicker");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.*");
+
+dojo.widget.defineWidget(
+	"dojo.widget.MonthlyCalendar",
+	dojo.widget.DatePicker,
+	function(){
+		this.iCalendars = [];
+	},
+{
+	dayWidth: 'wide',
+
+	templatePath: dojo.uri.dojoUri("src/widget/templates/MonthlyCalendar.html"),
+	templateCssPath: dojo.uri.dojoUri("src/widget/templates/MonthlyCalendar.css"),
+
+	cache: function() {
+	},
+
+	addCalendar: function(/* dojo.iCalendar */ cal) {
+		dojo.debug("Adding Calendar");
+		this.iCalendars.push(cal);
+		dojo.debug("Starting init");
+		this.initUI();
+		dojo.debug("done init");
+	},
+
+	createDayContents: function(node,mydate) {
+		dojo.html.removeChildren(node);
+		node.appendChild(document.createTextNode(mydate.getDate()));	
+			for(var x=0; x<this.iCalendars.length; x++) {
+				var evts = this.iCalendars[x].getEvents(mydate);
+				if ((dojo.lang.isArray(evts)) && (evts.length>0)) {
+				for(var y=0;y<evts.length;y++) {
+					var el = document.createElement("div");
+					dojo.html.addClass(el, "dojoMonthlyCalendarEvent");          
+					el.appendChild(document.createTextNode(evts[y].summary.value));
+					el.width = dojo.html.getContentBox(node).width;
+					node.appendChild(el);
+				}
+			}
+		}
+	},
+
+	initUI: function() {
+		var dayLabels = dojo.date.getNames('days', this.dayWidth, 'standAlone', this.lang);
+		var dayLabelNodes = this.dayLabelsRow.getElementsByTagName("td");
+		for(var i=0; i<7; i++) {
+			dayLabelNodes.item(i).innerHTML = dayLabels[i];
+		}
+
+		this.selectedIsUsed = false;
+		this.currentIsUsed = false;
+		var currentClassName = "";
+		var previousDate = new Date();
+		var calendarNodes = this.calendarDatesContainerNode.getElementsByTagName("td");
+		var currentCalendarNode;
+		// set hours of date such that there is no chance of rounding error due to 
+		// time change in local time zones
+		previousDate.setHours(8);
+		var nextDate = new Date(this.firstSaturday.year, this.firstSaturday.month, this.firstSaturday.date, 8);
+		var lastDay = new Date(this.firstSaturday.year, this.firstSaturday.month, this.firstSaturday.date + 42, 8);
+		
+		if (this.iCalendars.length > 0) {
+			for (var x=0; x<this.iCalendars.length;x++) {
+				this.iCalendars[x].preComputeRecurringEvents(lastDay);
+			}
+		}
+
+		if(this.firstSaturday.date < 7) {
+			// this means there are days to show from the previous month
+			var dayInWeek = 6;
+			for (var i=this.firstSaturday.date; i>0; i--) {
+				currentCalendarNode = calendarNodes.item(dayInWeek);
+				this.createDayContents(currentCalendarNode, nextDate);
+				
+				dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+				dayInWeek--;
+				previousDate = nextDate;
+				nextDate = this.incrementDate(nextDate, false);
+			}
+			for(var i=dayInWeek; i>-1; i--) {
+				currentCalendarNode = calendarNodes.item(i);
+
+				this.createDayContents(currentCalendarNode, nextDate);
+
+				dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "previous"));
+				previousDate = nextDate;
+				nextDate = this.incrementDate(nextDate, false);				
+			}
+		} else {
+			nextDate.setDate(1);
+			for(var i=0; i<7; i++) {
+				currentCalendarNode = calendarNodes.item(i);
+				this.createDayContents(currentCalendarNode, nextDate);
+				dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+				previousDate = nextDate;
+				nextDate = this.incrementDate(nextDate, true);				
+			}
+		}
+		previousDate.setDate(this.firstSaturday.date);
+		previousDate.setMonth(this.firstSaturday.month);
+		previousDate.setFullYear(this.firstSaturday.year);
+		nextDate = this.incrementDate(previousDate, true);
+		var count = 7;
+		currentCalendarNode = calendarNodes.item(count);
+		while((nextDate.getMonth() == previousDate.getMonth()) && (count<42)) {
+			this.createDayContents(currentCalendarNode, nextDate);
+			dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+			currentCalendarNode = calendarNodes.item(++count);
+			previousDate = nextDate;
+			nextDate = this.incrementDate(nextDate, true);
+		}
+		
+		while(count < 42) {
+			this.createDayContents(currentCalendarNode, nextDate);
+			dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "next"));
+			currentCalendarNode = calendarNodes.item(++count);
+			previousDate = nextDate;
+			nextDate = this.incrementDate(nextDate, true);
+		}
+		this.setMonthLabel(this.firstSaturday.month);
+		this.setYearLabels(this.firstSaturday.year);
+	}	
+});
+
+dojo.widget.MonthlyCalendar.util= new function() {
+
+	this.toRfcDate = function(jsDate) {
+		if(!jsDate) {
+			jsDate = this.today;
+		}
+		var year = jsDate.getFullYear();
+		var month = jsDate.getMonth() + 1;
+		if (month < 10) {
+			month = "0" + month.toString();
+		}
+		var date = jsDate.getDate();
+		if (date < 10) {
+			date = "0" + date.toString();
+		}
+		// because this is a date picker and not a time picker, we treat time 
+		// as zero
+		return year + "-" + month + "-" + date + "T00:00:00+00:00";
+	}
+	
+	this.fromRfcDate = function(rfcDate) {
+		var tempDate = rfcDate.split("-");
+		if(tempDate.length < 3) {
+			return new Date();
+		}
+		// fullYear, month, date
+		return new Date(parseInt(tempDate[0]), (parseInt(tempDate[1], 10) - 1), parseInt(tempDate[2].substr(0,2), 10));
+	}
+
+//Note: redundant with dojo.widget.DatePicker.util	
+	this.initFirstSaturday = function(month, year) {
+		if(!month) {
+			month = this.date.getMonth();
+		}
+		if(!year) {
+			year = this.date.getFullYear();
+		}
+		var firstOfMonth = new Date(year, month, 1);
+		return {year: year, month: month, date: 7 - firstOfMonth.getDay()};
+	}
+}

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/MonthlyCalendar.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,393 @@
+/*
+	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.widget.PageContainer");
+
+dojo.require("dojo.lang.func");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.selection");
+
+// A PageContainer is a container that has multiple panes, but shows only
+// one pane at a time.
+//
+// Publishes topics <widgetId>-addPane, <widgetId>-removePane, and <widgetId>-selectPane
+//
+// Can be base class for container, Wizard, Show, etc.
+dojo.widget.defineWidget("dojo.widget.PageContainer", dojo.widget.HtmlWidget, {
+	isContainer: true,
+
+	// Boolean
+	//  if true, change the size of my currently displayed child to match my size
+	doLayout: true,
+
+	templateString: "<div dojoAttachPoint='containerNode'></div>",
+
+	// String
+	//   id of the initially shown page
+	selectedPage: "",
+
+	fillInTemplate: function(args, frag) {
+		// Copy style info from input node to output node
+		var source = this.getFragNodeRef(frag);
+		dojo.html.copyStyle(this.domNode, source);
+		dojo.widget.PageContainer.superclass.fillInTemplate.apply(this, arguments);
+	},
+
+	postCreate: function(args, frag) {
+		// Setup each page panel
+		dojo.lang.forEach(this.children, this._setupPage, this);
+
+		// Display the selected page
+		if(this.selectedPageWidget){
+			this.selectPage(this.selectedPageWidget, true);
+		}
+	},
+
+	addChild: function(child){
+		this._setupPage(child);
+		dojo.widget.PageContainer.superclass.addChild.apply(this, arguments);
+
+		// in case the page labels have overflowed from one line to two lines
+		this.onResized();
+	},
+
+	_setupPage: function(page){
+		// Summary: Add the given pane to this page container
+		page.domNode.style.display="none";
+
+		if(!this.selectedPageWidget || this.selectedPage==page.widgetId || page.selected || (this.children.length==0)){
+			// Deselect old page and select new one
+			// We do this instead of calling selectPage in this case, because other wise other widgets
+			// listening for addChild and selectPage can run into a race condition
+			if(this.selectedPageWidget){
+				this._hidePage(this.selectedPageWidget);
+			}
+			this.selectedPageWidget = page;
+			this._showPage(page);
+
+		} else {
+			this._hidePage(page);
+		}
+
+		dojo.html.addClass(page.domNode, "selected");
+
+		// publish the addPane event for panes added via addChild(), and the original panes too
+		dojo.event.topic.publish(this.widgetId+"-addPane", page);
+	},
+
+	removeChild: function(/* Widget */page){
+		dojo.widget.PageContainer.superclass.removeChild.apply(this, arguments);
+
+		// If we are being destroyed than don't the code below (to select another pane), because we are deleting
+		// every pane one by one
+		if(this._beingDestroyed){ return; }
+
+		// this will notify any tablists to remove a button; do this first because it may affect sizing
+		dojo.event.topic.publish(this.widgetId+"-removePane", page);
+
+		if (this.selectedPageWidget === page) {
+			this.selectedPageWidget = undefined;
+			if (this.children.length > 0) {
+				this.selectPage(this.children[0], true);
+			}
+		}
+	},
+
+	selectPage: function(/* Widget */ page, /* Boolean */ _noRefresh, /* Widget */ callingWidget){
+		// summary
+		//	Show the given widget (which must be one of my children)
+		page = dojo.widget.byId(page);
+		this.correspondingPageButton = callingWidget;
+
+		// Deselect old page and select new one
+		if(this.selectedPageWidget){
+			this._hidePage(this.selectedPageWidget);
+		}
+		this.selectedPageWidget = page;
+		this._showPage(page, _noRefresh);
+		page.isFirstPage = (page == this.children[0]);
+		page.isLastPage = (page == this.children[this.children.length-1]);
+		dojo.event.topic.publish(this.widgetId+"-selectPane", page);
+	},
+
+	nextPage: function(){
+		// Summary: advance to next page
+		var index = dojo.lang.find(this.children, this.selectedPageWidget);
+		this.selectPage(this.children[index+1]);
+	},
+
+	previousPage: function(){
+		// Summary: go back to previous page
+		var index = dojo.lang.find(this.children, this.selectedPageWidget);
+		this.selectPage(this.children[index-1]);
+	},
+
+	onResized: function(){
+		// Summary: called when any page is shown, to make it fit the container correctly
+		if(this.doLayout && this.selectedPageWidget){
+			with(this.selectedPageWidget.domNode.style){
+				top = dojo.html.getPixelValue(this.containerNode, "padding-top", true);
+				left = dojo.html.getPixelValue(this.containerNode, "padding-left", true);
+			}
+			var content = dojo.html.getContentBox(this.containerNode);
+			this.selectedPageWidget.resizeTo(content.width, content.height);
+		}
+	},
+
+	_showPage: function(page, _noRefresh) {
+		page.selected=true;
+
+		// size the current page (in case this is the first time it's being shown, or I have been resized)
+		if(this.doLayout){
+			var content = dojo.html.getContentBox(this.containerNode);
+			page.resizeTo(content.width, content.height);
+		}
+
+		// make sure we dont refresh onClose and on postCreate
+		// speeds up things a bit when using refreshOnShow and fixes #646
+		if(_noRefresh && page.refreshOnShow){
+			var tmp = page.refreshOnShow;
+			page.refreshOnShow = false;
+			page.show();
+			page.refreshOnShow = tmp;
+		}else{
+			page.show();
+		}
+	},
+
+	_hidePage: function(page) {
+		page.selected=false;
+		page.hide();
+	},
+
+	closePage: function(page) {
+		// summary
+		//	callback when user clicks the [X] to remove a page
+		//	if onClose() returns true then remove and destroy the childd
+		var remove = page.onClose(this, page);
+		if(remove) {
+			this.removeChild(page);
+			// makes sure we can clean up executeScripts in ContentPane onUnLoad
+			page.destroy();
+		}
+	},
+
+	destroy: function(){
+		this._beingDestroyed = true;
+		dojo.event.topic.destroy(this.widgetId+"-addPane");
+		dojo.event.topic.destroy(this.widgetId+"-removePane");
+		dojo.event.topic.destroy(this.widgetId+"-selectPane");
+		dojo.widget.PageContainer.superclass.destroy.apply(this, arguments);
+	}
+});
+
+
+// PageController - set of buttons to select the page in a page list
+// When intialized, the PageController monitors the container, and whenever a pane is
+// added or deleted updates itself accordingly.
+dojo.widget.defineWidget(
+    "dojo.widget.PageController",
+    dojo.widget.HtmlWidget,
+	{
+		templateString: "<span wairole='tablist' dojoAttachEvent='onKey'></span>",
+		isContainer: true,
+
+		// String
+		//	the id of the page container that I point to
+		containerId: "",
+
+		// String
+		//	the name of the button widget to create to correspond to each page
+		buttonWidget: "PageButton",
+
+		// String
+		//	Class name to apply to the top dom node
+		"class": "dojoPageController",
+
+		fillInTemplate: function() {
+			dojo.html.addClass(this.domNode, this["class"]);  // "class" is a reserved word in JS
+			dojo.widget.wai.setAttr(this.domNode, "waiRole", "role", "tablist");
+		},
+
+		postCreate: function(){
+			this.pane2button = {};		// mapping from panes to buttons
+
+			// If children have already been added to the page container then create buttons for them
+			var container = dojo.widget.byId(this.containerId);
+			if(container){
+				dojo.lang.forEach(container.children, this.onAddPage, this);
+			}
+
+			dojo.event.topic.subscribe(this.containerId+"-addPane", this, "onAddPage");
+			dojo.event.topic.subscribe(this.containerId+"-removePane", this, "onRemovePage");
+			dojo.event.topic.subscribe(this.containerId+"-selectPane", this, "onSelectPage");
+		},
+
+		destroy: function(){
+			dojo.event.topic.unsubscribe(this.containerId+"-addPane", this, "onAddPage");
+			dojo.event.topic.unsubscribe(this.containerId+"-removePane", this, "onRemovePage");
+			dojo.event.topic.unsubscribe(this.containerId+"-selectPane", this, "onSelectPage");
+			dojo.widget.PageController.superclass.destroy.apply(this, arguments);
+		},
+
+		onAddPage: function(/* Widget */ pane){
+			// summary
+			//   Called whenever a pane is added to the container.
+			//   Create button corresponding to the pane.
+			var button = dojo.widget.createWidget(this.buttonWidget,
+				{
+					label: pane.label,
+					closable: pane.tabCloseButton
+				});
+			this.addChild(button);
+			this.domNode.appendChild(button.domNode);
+			this.pane2button[pane]=button;
+			pane.tabButton = button;	// this value might be overwritten if two tabs point to same container
+
+			var _this = this;
+			dojo.event.connect(button, "onClick", function(){ _this.onButtonClick(pane); });
+			dojo.event.connect(button, "onCloseButtonClick", function(){ _this.onCloseButtonClick(pane); });
+		},
+
+		onRemovePage: function(/* Widget */ pane){
+			// summary
+			//   Called whenever a pane is removed from the container.
+			//   Remove the button corresponding to the pane.
+			if(this.currentPane == pane){ this.currentPane = null; }
+			var button = this.pane2button[pane];
+			button.destroy();
+			this.pane2button[pane] = null;
+		},
+
+		onSelectPage: function(/*Widget*/ page){
+			// Summary
+			//	Called when a page has been selected in the PageContainer, either by me or by someone another PageController
+			if(this.currentPane){
+				var oldButton=this.pane2button[this.currentPane];
+				oldButton.clearSelected();
+			}
+			var newButton=this.pane2button[page];
+			newButton.setSelected();
+			this.currentPane=page;
+		},
+
+		onButtonClick: function(/*Widget*/ page){
+			// summary
+			//   Called whenever one of my child buttons is pressed in an attempt to select a pane
+			var container = dojo.widget.byId(this.containerId);	// TODO: do this via topics?
+			container.selectPage(page, false, this);
+		},
+
+		onCloseButtonClick: function(/*Widget*/ page){
+			// summary
+			//   Called whenever one of my child buttons [X] is pressed in an attempt to close a pane
+			var container = dojo.widget.byId(this.containerId);
+			container.closePage(page);
+		},
+
+		onKey: function(evt){
+			// summary:
+			//   Handle keystrokes on the page list, for advancing to next/previous button
+
+			if( (evt.keyCode == evt.KEY_RIGHT_ARROW)||
+				(evt.keyCode == evt.KEY_LEFT_ARROW) ){
+				var current = 0;
+				var next = null;	// the next button to focus on
+				
+				// find currently focused button in children array
+				var current = dojo.lang.find(this.children, this._currentPage);
+				
+				// pick next button to focus on
+				if(evt.keyCode == evt.KEY_RIGHT_ARROW){
+					next = this.children[ (current+1) % this.children.length ]; 
+				}else{ // is LEFT_ARROW
+					next = this.children[ (current+ (this.children.length-1)) % this.children.length ];
+				}
+				
+				dojo.event.browser.stopEvent(evt);
+				next.onClick();
+			}
+		}
+	}
+);
+
+// PageButton (the thing you click to select or delete a page)
+dojo.widget.defineWidget("dojo.widget.PageButton", dojo.widget.HtmlWidget,
+{
+	templateString: "<span class='item'>" +
+						"<span dojoAttachEvent='onClick' dojoAttachPoint='titleNode' class='selectButton'>${this.label}</span>" +
+						"<span dojoAttachEvent='onClick:onCloseButtonClick' class='closeButton'>[X]</span>" +
+					"</span>",
+
+	// String
+	//  Name to print on the button
+	label: "foo",
+	
+	// Boolean
+	//	true iff we should also print a close icon to destroy corresponding pane
+	closable: false,
+
+	onClick: function(){
+		// summary
+		//  Basically this is the attach point PageController listens to, to select the page
+		this.focus();
+	},
+
+	onCloseButtonMouseOver: function(){
+		// summary
+		//	The close button changes color a bit when you mouse over	
+		dojo.html.addClass(this.closeButtonNode, "closeHover");
+	},
+
+	onCloseButtonMouseOut: function(){
+		// summary
+		// 	Revert close button to normal color on mouse out
+		dojo.html.removeClass(this.closeButtonNode, "closeHover");
+	},
+
+	onCloseButtonClick: function(evt){
+		// summary
+		//	Handle clicking the close button for this tab
+	},
+	
+	setSelected: function(){
+		// summary
+		//	This is run whenever the pane corresponding to this button has been selected
+		dojo.html.addClass(this.domNode, "current");
+		this.titleNode.setAttribute("tabIndex","0");
+	},
+	
+	clearSelected: function(){
+		// summary
+		//	This function is run whenever the pane corresponding to this button has been deselected (and another pane has been shown)
+		dojo.html.removeClass(this.domNode, "current");
+		this.titleNode.setAttribute("tabIndex","-1");
+	},
+
+	focus: function(){
+		// summary
+		//	This will focus on the this button (for accessibility you need to do this when the button is selected)
+		if(this.titleNode.focus){	// mozilla 1.7 doesn't have focus() func
+			this.titleNode.focus();
+		}
+		this.parent._currentPage = this;
+	}
+});
+
+// These arguments can be specified for the children of a PageContainer.
+// Since any widget can be specified as a PageContainer child, mix them
+// into the base widget class.  (This is a hack, but it's effective.)
+dojo.lang.extend(dojo.widget.Widget, {
+	label: "",
+	selected: false,	// is this tab currently selected?
+	closeButton: false,
+	onClose: function(){ return true; }	// callback if someone tries to close the child, child will be closed if func returns true
+});

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PageContainer.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,334 @@
+/*
+	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.widget.Parse");
+
+dojo.require("dojo.widget.Manager");
+dojo.require("dojo.dom");
+dojo.require("dojo.namespace");
+
+//
+// dojoML parser should be moved out of 'widget', codifying the difference between a 'component'
+// and a 'widget'. A 'component' being anything that can be generated from a tag.
+//
+// a particular dojoML tag would be handled by a registered tagHandler with a hook for a default handler
+// if the widget system is loaded, a widget builder would be attach itself as the default handler
+// 
+// widget tags are no longer registered themselves:
+// they are now arbitrarily namespaced, so we cannot register them all, and the non-prefixed portions 
+// are no longer guaranteed unique 
+// 
+// therefore dojo.widget.tags should go with this parser code out of the widget module
+//
+
+dojo.widget.Parse = function(fragment){
+	this.propertySetsList = [];
+	this.fragment = fragment;
+	
+	this.createComponents = function(frag, parentComp){
+		var comps = [];
+		var built = false;
+		// if we have items to parse/create at this level, do it!
+		try{
+			if((frag)&&(frag["tagName"])&&(frag!=frag["nodeRef"])){
+				
+				// these are in fact, not ever for widgets per-se anymore, 
+				// but for other markup elements (aka components)
+				var djTags = dojo.widget.tags;
+				
+				// we split so that you can declare multiple 
+				// non-destructive components from the same ctor node
+				var tna = String(frag["tagName"]).split(";");
+				for(var x=0; x<tna.length; x++){
+					var ltn = (tna[x].replace(/^\s+|\s+$/g, "")).toLowerCase();
+					// FIXME: unsure what this does
+					frag.tagName = ltn;
+					if(djTags[ltn]){
+						built = true;
+						var ret = djTags[ltn](frag, this, parentComp, frag["index"]);
+						comps.push(ret);
+					} else {
+						// we require a namespace prefix, default to dojo:
+						if (ltn.indexOf(":") == -1){
+							ltn = "dojo:"+ltn;
+						}
+						// FIXME: handling failure condition correctly?
+						//var ret = djTags[ltn](frag, this, parentComp, frag["index"]);
+						var ret = dojo.widget.buildWidgetFromParseTree(ltn, frag, this, parentComp, frag["index"]);
+						if (ret) {
+							built = true;
+							comps.push(ret);
+						}
+					}
+				}
+			}
+		}catch(e){
+			dojo.debug("dojo.widget.Parse: error:" + e);
+			// note, commenting out the next line is breaking several widgets for me
+			// throw e;
+			// IE is such a bitch sometimes
+		}
+		// if there's a sub-frag, build widgets from that too
+		if(!built){
+			comps = comps.concat(this.createSubComponents(frag, parentComp));
+		}
+		return comps;
+	}
+
+	/*	createSubComponents recurses over a raw JavaScript object structure,
+			and calls the corresponding handler for its normalized tagName if it exists
+	*/
+	this.createSubComponents = function(fragment, parentComp){
+		var frag, comps = [];
+		for(var item in fragment){
+			frag = fragment[item];
+			if ((frag)&&(typeof frag == "object")&&(frag!=fragment.nodeRef)&&(frag!=fragment["tagName"])){
+				comps = comps.concat(this.createComponents(frag, parentComp));
+			}
+		}
+		return comps;
+	}
+
+	/*  parsePropertySets checks the top level of a raw JavaScript object
+			structure for any propertySets.  It stores an array of references to 
+			propertySets that it finds.
+	*/
+	this.parsePropertySets = function(fragment){
+		return [];
+		/*
+		var propertySets = [];
+		for(var item in fragment){
+			if((fragment[item]["tagName"] == "dojo:propertyset")){
+				propertySets.push(fragment[item]);
+			}
+		}
+		// FIXME: should we store these propertySets somewhere for later retrieval
+		this.propertySetsList.push(propertySets);
+		return propertySets;
+		*/
+	}
+	
+	/*  parseProperties checks a raw JavaScript object structure for
+			properties, and returns an array of properties that it finds.
+	*/
+	this.parseProperties = function(fragment){
+		var properties = {};
+		for(var item in fragment){
+			// FIXME: need to check for undefined?
+			// case: its a tagName or nodeRef
+			if((fragment[item] == fragment["tagName"])||(fragment[item] == fragment.nodeRef)){
+				// do nothing
+			}else{
+				if((fragment[item]["tagName"])&&
+					(dojo.widget.tags[fragment[item].tagName.toLowerCase()])){
+					// TODO: it isn't a property or property set, it's a fragment, 
+					// so do something else
+					// FIXME: needs to be a better/stricter check
+					// TODO: handle xlink:href for external property sets
+				}else if((fragment[item][0])&&(fragment[item][0].value!="")&&(fragment[item][0].value!=null)){
+					try{
+						// FIXME: need to allow more than one provider
+						if(item.toLowerCase() == "dataprovider") {
+							var _this = this;
+							this.getDataProvider(_this, fragment[item][0].value);
+							properties.dataProvider = this.dataProvider;
+						}
+						properties[item] = fragment[item][0].value;
+						var nestedProperties = this.parseProperties(fragment[item]);
+						// FIXME: this kind of copying is expensive and inefficient!
+						for(var property in nestedProperties){
+							properties[property] = nestedProperties[property];
+						}
+					}catch(e){ dojo.debug(e); }
+				}
+			}
+		}
+		return properties;
+	}
+
+	/* getPropertySetById returns the propertySet that matches the provided id
+	*/
+	
+	this.getDataProvider = function(objRef, dataUrl){
+		// FIXME: this is currently sync.  To make this async, we made need to move 
+		//this step into the widget ctor, so that it is loaded when it is needed 
+		// to populate the widget
+		dojo.io.bind({
+			url: dataUrl,
+			load: function(type, evaldObj){
+				if(type=="load"){
+					objRef.dataProvider = evaldObj;
+				}
+			},
+			mimetype: "text/javascript",
+			sync: true
+		});
+	}
+
+	
+	this.getPropertySetById = function(propertySetId){
+		for(var x = 0; x < this.propertySetsList.length; x++){
+			if(propertySetId == this.propertySetsList[x]["id"][0].value){
+				return this.propertySetsList[x];
+			}
+		}
+		return "";
+	}
+	
+	/* getPropertySetsByType returns the propertySet(s) that match(es) the
+	 * provided componentClass
+	 */
+	this.getPropertySetsByType = function(componentType){
+		var propertySets = [];
+		for(var x=0; x < this.propertySetsList.length; x++){
+			var cpl = this.propertySetsList[x];
+			var cpcc = cpl["componentClass"]||cpl["componentType"]||null;
+			var propertySetId = this.propertySetsList[x]["id"][0].value;
+			if((cpcc)&&(propertySetId == cpcc[0].value)){
+				propertySets.push(cpl);
+			}
+		}
+		return propertySets;
+	}
+	
+	/* getPropertySets returns the propertySet for a given component fragment
+	*/
+	this.getPropertySets = function(fragment){
+		var ppl = "dojo:propertyproviderlist";
+		var propertySets = [];
+		var tagname = fragment["tagName"];
+		if(fragment[ppl]){ 
+			var propertyProviderIds = fragment[ppl].value.split(" ");
+			// FIXME: should the propertyProviderList attribute contain #
+			// 		  syntax for reference to ids or not?
+			// FIXME: need a better test to see if this is local or external
+			// FIXME: doesn't handle nested propertySets, or propertySets that
+			// 		  just contain information about css documents, etc.
+			for(var propertySetId in propertyProviderIds){
+				if((propertySetId.indexOf("..")==-1)&&(propertySetId.indexOf("://")==-1)){
+					// get a reference to a propertySet within the current parsed structure
+					var propertySet = this.getPropertySetById(propertySetId);
+					if(propertySet != ""){
+						propertySets.push(propertySet);
+					}
+				}else{
+					// FIXME: add code to parse and return a propertySet from
+					// another document
+					// alex: is this even necessaray? Do we care? If so, why?
+				}
+			}
+		}
+		// we put the typed ones first so that the parsed ones override when
+		// iteration happens.
+		return (this.getPropertySetsByType(tagname)).concat(propertySets);
+	}
+	
+	/* 
+		nodeRef is the node to be replaced... in the future, we might want to add 
+		an alternative way to specify an insertion point
+
+		componentName is the expected dojo widget name, i.e. Button of ContextMenu
+
+		properties is an object of name value pairs
+		namespace is the namespace of the widget.  Defaults to "dojo"
+	*/
+	this.createComponentFromScript = function(nodeRef, componentName, properties, ns){
+		properties.fastMixIn = true;			
+		// FIXME: we pulled it apart and now we put it back together ... 
+		var ltn = (ns || "dojo") + ":" + componentName.toLowerCase();
+		if(dojo.widget.tags[ltn]){
+			return [dojo.widget.tags[ltn](properties, this, null, null, properties)];
+		}
+		return [dojo.widget.buildWidgetFromParseTree(ltn, properties, this, null, null, properties)];
+	}
+}
+
+dojo.widget._parser_collection = {"dojo": new dojo.widget.Parse() };
+dojo.widget.getParser = function(name){
+	if(!name){ name = "dojo"; }
+	if(!this._parser_collection[name]){
+		this._parser_collection[name] = new dojo.widget.Parse();
+	}
+	return this._parser_collection[name];
+}
+
+/**
+ * Creates widget.
+ *
+ * @param name     The name of the widget to create with optional namespace prefix,
+ *                 e.g."ns:widget", namespace defaults to "dojo".
+ * @param props    Key-Value pairs of properties of the widget
+ * @param refNode  If the position argument is specified, this node is used as
+ *                 a reference for inserting this node into a DOM tree; else
+ *                 the widget becomes the domNode
+ * @param position The position to insert this widget's node relative to the
+ *                 refNode argument
+ * @return The new Widget object
+ */
+
+dojo.widget.createWidget = function(name, props, refNode, position){
+	var isNode = false;
+	var isNameStr = (typeof name == "string");
+	if(isNameStr){
+		var pos = name.indexOf(":");
+		var ns = (pos > -1) ? name.substring(0,pos) : "dojo";
+		if(pos > -1){ name = name.substring(pos+1); }
+		var lowerCaseName = name.toLowerCase();
+		var namespacedName = ns + ":" + lowerCaseName;
+		isNode = (dojo.byId(name) && (!dojo.widget.tags[namespacedName])); 
+	}
+
+	if((arguments.length == 1) && ((isNode)||(!isNameStr))){
+		// we got a DOM node 
+		var xp = new dojo.xml.Parse(); 
+		// FIXME: we should try to find the parent! 
+		var tn = (isNode) ? dojo.byId(name) : name; 
+		return dojo.widget.getParser().createComponents(xp.parseElement(tn, null, true))[0]; 
+	}
+	
+	function fromScript(placeKeeperNode, name, props, ns){
+		props[namespacedName] = { 
+			dojotype: [{value: lowerCaseName}],
+			nodeRef: placeKeeperNode,
+			fastMixIn: true
+		};
+		props["namespace"] = ns;
+		return dojo.widget.getParser().createComponentFromScript(placeKeeperNode, name, props, ns);
+	}
+
+	props = props||{};
+	var notRef = false;
+	var tn = null;
+	var h = dojo.render.html.capable;
+	if(h){
+		tn = document.createElement("span");
+	}
+	if(!refNode){
+		notRef = true;
+		refNode = tn;
+		if(h){
+			dojo.body().appendChild(refNode);
+		}
+	}else if(position){
+		dojo.dom.insertAtPosition(tn, refNode, position);
+	}else{ // otherwise don't replace, but build in-place
+		tn = refNode;
+	}
+	var widgetArray = fromScript(tn, name.toLowerCase(), props, ns);
+	if (!widgetArray || !widgetArray[0] || typeof widgetArray[0].widgetType == "undefined") {
+		throw new Error("createWidget: Creation of \"" + name + "\" widget failed.");
+	}
+	if (notRef) {
+		if (widgetArray[0].domNode.parentNode) {
+			widgetArray[0].domNode.parentNode.removeChild(widgetArray[0].domNode);
+		}
+	}
+	return widgetArray[0]; // just return the widget
+}

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/Parse.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PopupContainer.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PopupContainer.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PopupContainer.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PopupContainer.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,428 @@
+/*
+	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.widget.PopupContainer");
+
+dojo.require("dojo.html.style");
+dojo.require("dojo.html.layout");
+dojo.require("dojo.html.selection");
+dojo.require("dojo.html.iframe");
+dojo.require("dojo.event.*");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+
+
+//PopupContainerBase is the mixin class which provide popup behaviors:
+//it can open in a given position x,y or around a given node.
+//In addition, it handles animation and IE bleed through workaround.
+//This class can not be used standalone: it should be mixed-in to a
+//dojo.widget.HtmlWidget. Use PopupContainer instead if you want a 
+//a standalone popup widget
+dojo.declare(
+	"dojo.widget.PopupContainerBase",
+	null,
+	function(){
+		this.queueOnAnimationFinish = [];
+	},
+{
+	isContainer: true,
+	templateString: '<div dojoAttachPoint="containerNode" style="display:none;position:absolute;" class="dojoPopupContainer" ></div>',
+
+	isShowingNow: false,
+
+	currentSubpopup: null,
+
+	beginZIndex: 1000,
+
+	parentPopup: null,
+	parent: null, // parent Widget
+	popupIndex: 0,
+
+	aroundBox: dojo.html.boxSizing.BORDER_BOX, //by default, popup around the BORDER box of the aroundNode in open()
+
+	openedForWindow: null, //in which window, the open() is triggered
+
+	processKey: function(evt){
+		return false;
+	},
+
+	//this function should be called in sub class where a custom
+	//templateString/templateStringPath is used (see Tooltip widget)
+	applyPopupBasicStyle: function(){
+		with(this.domNode.style){
+			display = 'none';
+			position = 'absolute';
+		}
+	},
+
+	//connect to this stub to modify the content of the popup
+	aboutToShow: function() {},
+
+	/**
+	 * Open the popup at position (x,y), relative to dojo.body()
+	 * Or open(node, parent, explodeSrc, aroundOrient) to open
+	 * around node
+	 */
+	open: function(x, y, parent, explodeSrc, orient, padding){
+		if (this.isShowingNow){ return; }
+
+		this.aboutToShow();
+
+		// if I click right button and menu is opened, then it gets 2 commands: close -> open
+		// so close enables animation and next "open" is put to queue to occur at new location
+		if(this.animationInProgress){
+			this.queueOnAnimationFinish.push(this.open, arguments);
+			return;
+		}
+
+		// save this so that the focus can be returned
+		this.parent = parent;
+
+		var around = false, node, aroundOrient;
+		if(typeof x == 'object'){
+			node = x;
+			aroundOrient = explodeSrc;
+			explodeSrc = parent;
+			parent = y;
+			around = true;
+		}
+
+		// for unknown reasons even if the domNode is attached to the body in postCreate(),
+		// it's not attached here, so have to attach it here.
+		dojo.body().appendChild(this.domNode);
+
+		// if explodeSrc isn't specified then explode from my parent widget
+		explodeSrc = explodeSrc || parent["domNode"] || [];
+
+		//keep track of parent popup to decided whether this is a top level popup
+		var parentPopup = null;
+		this.isTopLevel = true;
+		while(parent){
+			if(parent !== this && (parent.setOpenedSubpopup != undefined && parent.applyPopupBasicStyle != undefined)){
+				parentPopup = parent;
+				this.isTopLevel = false;
+				parentPopup.setOpenedSubpopup(this);
+				break;
+			}
+			parent = parent.parent;
+		}
+
+		this.parentPopup = parentPopup;
+		this.popupIndex = parentPopup ? parentPopup.popupIndex + 1 : 1;
+
+		if(this.isTopLevel){
+			var button = explodeSrc instanceof Array ? null : explodeSrc;
+			dojo.widget.PopupManager.opened(this, button);
+		}
+
+		//Store the current selection and restore it before the action for a menu item
+		//is executed. This is required as clicking on an menu item deselects current selection
+		if(this.isTopLevel && !dojo.withGlobal(this.openedForWindow||dojo.global(), dojo.html.selection.isCollapsed)){
+			this._bookmark = dojo.withGlobal(this.openedForWindow||dojo.global(), dojo.html.selection.getBookmark);
+		}else{
+			this._bookmark = null;
+		}
+
+		//convert explodeSrc from format [x, y] to 
+		//{left: x, top: y, width: 0, height: 0} which is the new
+		//format required by dojo.html.toCoordinateObject
+		if(explodeSrc instanceof Array){
+			explodeSrc = {left: explodeSrc[0], top: explodeSrc[1], width: 0, height: 0};
+		}
+
+		// display temporarily, and move into position, then hide again
+		with(this.domNode.style){
+			display="";
+			zIndex = this.beginZIndex + this.popupIndex;
+		}
+
+		if(around){
+			this.move(node, padding, aroundOrient);
+		}else{
+			this.move(x, y, padding, orient);
+		}
+		this.domNode.style.display="none";
+
+		this.explodeSrc = explodeSrc;
+
+		// then use the user defined method to display it
+		this.show();
+
+		this.isShowingNow = true;
+	},
+
+	/* Summery: calculate where to place the popup
+		move(node, padding, aroundOrient) */
+	move: function(x, y, padding, orient){
+		var around = (typeof x == "object");
+		if(around){
+			var aroundOrient=padding;
+			var node=x;
+			padding=y;
+			if(!aroundOrient){ //By default, attempt to open above the aroundNode, or below
+				aroundOrient = {'BL': 'TL', 'TL': 'BL'};
+			}
+			dojo.html.placeOnScreenAroundElement(this.domNode, node, padding, this.aroundBox, aroundOrient);
+		}else{
+			if(!orient){ orient = 'TL,TR,BL,BR';}
+			dojo.html.placeOnScreen(this.domNode, x, y, padding, true, orient);
+		}
+	},
+
+	close: function(force){
+		if(force){
+			this.domNode.style.display="none";
+		}
+
+		// If we are in the process of opening the menu and we are asked to close it
+		if(this.animationInProgress){
+			this.queueOnAnimationFinish.push(this.close, []);
+			return;
+		}
+
+		this.closeSubpopup(force);
+		this.hide();
+		if(this.bgIframe){
+			this.bgIframe.hide();
+			this.bgIframe.size({left: 0, top: 0, width: 0, height: 0});
+		}
+		if(this.isTopLevel){
+			dojo.widget.PopupManager.closed(this);
+		}
+		this.isShowingNow = false;
+		// return focus to the widget that opened the menu
+		try {
+			this.parent.domNode.focus();
+		} catch(e) {}
+
+		//do not need to restore if current selection is not empty
+		//(use keyboard to select a menu item)
+		if(this._bookmark && dojo.withGlobal(this.openedForWindow||dojo.global(), dojo.html.selection.isCollapsed)){
+			if(this.openedForWindow){
+				this.openedForWindow.focus()
+			}
+			dojo.withGlobal(this.openedForWindow||dojo.global(), "moveToBookmark", dojo.html.selection, [this._bookmark]);
+		}
+		this._bookmark = null;
+	},
+
+	closeAll: function(force){
+		if (this.parentPopup){
+			this.parentPopup.closeAll(force);
+		}else{
+			this.close(force);
+		}
+	},
+
+	//call this when a embedded popup is shown
+	setOpenedSubpopup: function(popup) {
+		this.currentSubpopup = popup;
+	},
+
+	closeSubpopup: function(force) {
+		if(this.currentSubpopup == null){ return; }
+		
+		this.currentSubpopup.close(force);
+		this.currentSubpopup = null;
+	},
+
+	onShow: function() {
+		this.inherited('onShow');
+		// With some animation (wipe), after close, the size of the domnode is 0
+		// and next time when shown, the open() function can not determine
+		// the correct place to popup, so we store the opened size here and 
+		// set it after close (in function onHide())
+		this.openedSize={w: this.domNode.style.width, h: this.domNode.style.height};
+		// prevent IE bleed through
+		if(dojo.render.html.ie){
+			if(!this.bgIframe){
+				this.bgIframe = new dojo.html.BackgroundIframe();
+				this.bgIframe.setZIndex(this.domNode);
+			}
+
+			this.bgIframe.size(this.domNode);
+			this.bgIframe.show();
+		}
+		this.processQueue();
+	},
+
+	// do events from queue
+	processQueue: function() {
+		if (!this.queueOnAnimationFinish.length) return;
+
+		var func = this.queueOnAnimationFinish.shift();
+		var args = this.queueOnAnimationFinish.shift();
+
+		func.apply(this, args);
+	},
+
+	onHide: function() {
+		dojo.widget.HtmlWidget.prototype.onHide.call(this);
+		
+		//restore size of the domnode, see comment in
+		//function onShow()
+		if(this.openedSize){
+			with(this.domNode.style){
+				width=this.openedSize.w;
+				height=this.openedSize.h;
+			}
+		}
+		
+		this.processQueue();
+	}
+});
+
+dojo.widget.defineWidget(
+	"dojo.widget.PopupContainer",
+	[dojo.widget.HtmlWidget, dojo.widget.PopupContainerBase], {});
+
+
+//
+// the popup manager makes sure we don't have several popups
+// open at once. the root popup in an opening sequence calls
+// opened(). when a root menu closes it calls closed(). then
+// everything works. lovely.
+//
+
+dojo.widget.PopupManager = new function(){
+
+	this.currentMenu = null;
+	this.currentButton = null;		// button that opened current menu (if any)
+	this.currentFocusMenu = null;	// the (sub)menu which receives key events
+	this.focusNode = null;
+	this.registeredWindows = [];
+
+	this.registerWin = function(win){
+		if(!win.__PopupManagerRegistered)
+		{
+			dojo.event.connect(win.document, 'onmousedown', this, 'onClick');
+			dojo.event.connect(win, "onscroll", this, "onClick");
+			dojo.event.connect(win.document, "onkey", this, 'onKey');
+			win.__PopupManagerRegistered = true;
+			this.registeredWindows.push(win);
+		}
+	};
+
+	/*
+		This function register all the iframes and the top window,
+		so that whereever the user clicks in the page, the popup 
+		menu will be closed
+		In case you add an iframe after onload event, please call
+		dojo.widget.PopupManager.registerWin manually
+	*/
+	this.registerAllWindows = function(targetWindow){
+		//starting from window.top, clicking everywhere in this page 
+		//should close popup menus
+		if(!targetWindow) { //see comment below
+			targetWindow = dojo.html.getDocumentWindow(window.top.document);
+		}
+
+		this.registerWin(targetWindow);
+
+		for (var i = 0; i < targetWindow.frames.length; i++){
+			try{
+				//do not remove  dojo.html.getDocumentWindow, see comment in it
+				var win = dojo.html.getDocumentWindow(targetWindow.frames[i].document);
+				if(win){
+					this.registerAllWindows(win);
+				}
+			}catch(e){ /* squelch error for cross domain iframes */ }
+		}
+	};
+
+	this.unRegisterWin = function(win){
+		if(win.__PopupManagerRegistered)
+		{
+			dojo.event.disconnect(win.document, 'onmousedown', this, 'onClick');
+			dojo.event.disconnect(win, "onscroll", this, "onClick");
+			dojo.event.disconnect(win.document, "onkey", this, 'onKey');
+			win.__PopupManagerRegistered = false;
+		}
+	};
+
+	this.unRegisterAllWindows = function(){
+		for(var i=0;i<this.registeredWindows.length;++i){
+			this.unRegisterWin(this.registeredWindows[i]);
+		}
+		this.registeredWindows = [];
+	};
+
+	dojo.addOnLoad(this, "registerAllWindows");
+	dojo.addOnUnload(this, "unRegisterAllWindows");
+
+	this.closed = function(menu){
+		if (this.currentMenu == menu){
+			this.currentMenu = null;
+			this.currentButton = null;
+			this.currentFocusMenu = null;
+		}
+	};
+
+	this.opened = function(menu, button){
+		if (menu == this.currentMenu){ return; }
+
+		if (this.currentMenu){
+			this.currentMenu.close();
+		}
+
+		this.currentMenu = menu;
+		this.currentFocusMenu = menu;
+		this.currentButton = button;
+	};
+
+	this.setFocusedMenu = function(menu){
+		this.currentFocusMenu = menu;
+	};
+
+	this.onKey = function(e){
+		if (!e.key) { return; }
+		if(!this.currentMenu || !this.currentMenu.isShowingNow){ return; }
+
+		var m = this.currentFocusMenu;
+		while (m){
+			if(m.processKey(e)){
+				e.preventDefault();
+				e.stopPropagation();
+				break;
+			}
+			m = m.parentPopup;
+		}
+	},
+
+	this.onClick = function(e){
+		if (!this.currentMenu){ return; }
+
+		var scrolloffset = dojo.html.getScroll().offset;
+
+		// starting from the base menu, perform a hit test
+		// and exit when one succeeds
+
+		var m = this.currentMenu;
+
+		while (m){
+			if(dojo.html.overElement(m.domNode, e) || dojo.html.isDescendantOf(e.target, m.domNode)){
+				return;
+			}
+			m = m.currentSubpopup;
+		}
+
+		// Also, if user clicked the button that opened this menu, then
+		// that button will send the menu a close() command, so this code
+		// shouldn't try to close the menu.  Closing twice messes up animation.
+		if (this.currentButton && dojo.html.overElement(this.currentButton, e)){
+			return;
+		}
+
+		// the click didn't fall within the open menu tree
+		// so close it
+
+		this.currentMenu.close();
+	};
+}
\ No newline at end of file

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/PopupContainer.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/ProgressBar.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/ProgressBar.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/ProgressBar.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/ProgressBar.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,287 @@
+/*
+	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.widget.ProgressBar");
+
+// requires here
+dojo.require("dojo.widget.*"); // necessary
+dojo.require("dojo.event");
+dojo.require("dojo.dom.*");
+dojo.require("dojo.html.style");
+dojo.require("dojo.string.*");
+dojo.require("dojo.lfx.*");
+
+dojo.widget.defineWidget(
+	"dojo.widget.ProgressBar",
+	dojo.widget.HtmlWidget,
+	{
+		// Constructor arguments
+		progressValue: "0",
+		maxProgressValue: 100,
+		width: 300,
+		height: 30,
+		frontPercentClass: "frontPercent",
+		backPercentClass: "backPercent",
+		frontBarClass: "frontBar",
+		backBarClass: "backBar",
+		hasText: "false",
+		isVertical:"false",
+		showOnlyIntegers: "false",
+		dataSource: "",
+		pollInterval: "3000",
+		duration: "1000",
+//		leftImage: null,
+//		centerImage: null,
+//		rightImage: null,
+		templatePath: dojo.uri.dojoUri("src/widget/templates/ProgressBar.html"),
+		templateCssPath: dojo.uri.dojoUri("src/widget/templates/ProgressBar.css"),
+		
+	
+		// attach points
+		containerNode: null,
+		internalProgress: null,
+	
+		// private members
+		_pixelUnitRatio: 0.0,
+		// _pixelRatio := width/100
+		_pixelPercentRatio: 0.0,
+		_unitPercentRatio: 0.0,
+		_unitPixelRatio: 0.0,
+		_floatDimension: 0.0,
+		_intDimension: 0,
+		_progressPercentValue: "0%",
+		_floatMaxProgressValue: 0.0,
+		_dimension: "width",
+		_pixelValue: 0,
+		_oInterval: null,
+		_animation: null,
+		_animationStopped: true,
+		_progressValueBak: false,
+		_hasTextBak: false,
+		// public functions
+		fillInTemplate: function(args, frag){
+			this.internalProgress.className = this.frontBarClass;
+			this.containerNode.className = this.backBarClass;
+			if (this.isVertical == "true"){
+				this.internalProgress.style.bottom="0px";
+				this.internalProgress.style.left="0px";
+				this._dimension = "height";
+			} else {
+				this.internalProgress.style.top="0px";
+				this.internalProgress.style.left="0px";
+				this._dimension = "width";
+			}
+			this.frontPercentLabel.className = this.frontPercentClass;
+			this.backPercentLabel.className = this.backPercentClass;
+			this.progressValue = "" + this.progressValue; 
+			this.domNode.style.height = this.height; 
+			this.domNode.style.width = this.width;
+			this._intDimension = parseInt("0" + eval("this." + this._dimension));
+			this._floatDimension = parseFloat("0" + eval("this."+this._dimension));
+			this._pixelPercentRatio = this._floatDimension/100;
+			this.setMaxProgressValue(this.maxProgressValue, true);
+			this.setProgressValue(dojo.string.trim(this.progressValue), true);
+			dojo.debug("float dimension: " + this._floatDimension);
+			dojo.debug("this._unitPixelRatio: " + this._unitPixelRatio);
+			this.showText(this.hasText);
+		},
+		showText: function(visible){
+			if (visible == "true"){
+				this.backPercentLabel.style.display="block";
+				this.frontPercentLabel.style.display="block";
+			} else {
+				this.backPercentLabel.style.display="none";
+				this.frontPercentLabel.style.display="none";
+			}
+			this.hasText = visible;
+		},
+		postCreate: function(args, frag){
+			// labels position
+			this.render();
+		},
+		_backupValues: function(){
+			this._progressValueBak = this.progressValue;
+			this._hasTextBak = this.hasText;
+		},
+		_restoreValues: function(){
+				this.setProgressValue(this._progressValueBak);
+				this.showText(this._hasTextBak);
+		},
+		_setupAnimation: function(){
+			var _self = this;
+			dojo.debug("internalProgress width: " + this.internalProgress.style.width);
+			this._animation = dojo.lfx.html.slideTo(this.internalProgress, 
+				{top: 0, left: this.width-parseInt(this.internalProgress.style.width)}, parseInt(this.duration), null, 
+					function(){
+						var _backAnim = dojo.lfx.html.slideTo(_self.internalProgress, 
+						{ top: 0, left: 0 }, parseInt(_self.duration));
+						dojo.event.connect(_backAnim, "onEnd", function(){
+							if (!_self._animationStopped){
+								_self._animation.play();
+							}
+							});
+						if (!_self._animationStopped){
+							_backAnim.play();
+						}
+						_backAnim = null; // <-- to avoid memory leaks in IE
+					}
+				);
+		},
+		getMaxProgressValue: function(){
+			return this.maxProgressValue;
+		},
+		setMaxProgressValue: function(maxValue, noRender){
+			if (!this._animationStopped){
+				return;
+			}
+			this.maxProgressValue = maxValue;
+			this._floatMaxProgressValue = parseFloat("0" + this.maxProgressValue);
+			this._pixelUnitRatio = this._floatDimension/this.maxProgressValue;
+			this._unitPercentRatio = this._floatMaxProgressValue/100;
+			this._unitPixelRatio = this._floatMaxProgressValue/this._floatDimension;
+			this.setProgressValue(this.progressValue, true);
+			if (!noRender){
+				this.render();
+			}
+		},
+		setProgressValue: function(value, noRender){
+			if (!this._animationStopped){
+				return;
+			}
+			// transformations here
+			this._progressPercentValue = "0%";
+			var _value=dojo.string.trim("" + value);
+			var _floatValue = parseFloat("0" + _value);
+			var _intValue = parseInt("0" + _value);
+			var _pixelValue = 0;
+			if (dojo.string.endsWith(_value, "%", false)){
+				this._progressPercentValue = Math.min(_floatValue.toFixed(1), 100) + "%";
+				_value = Math.min((_floatValue)*this._unitPercentRatio, this.maxProgressValue);
+				_pixelValue = Math.min((_floatValue)*this._pixelPercentRatio, eval("this."+this._dimension));
+			} else {
+				this.progressValue = Math.min(_floatValue, this.maxProgressValue);
+				this._progressPercentValue = Math.min((_floatValue/this._unitPercentRatio).toFixed(1), 100) + "%";
+				_pixelValue = Math.min(_floatValue/this._unitPixelRatio, eval("this."+this._dimension));
+			}
+			this.progressValue = dojo.string.trim(_value);
+			this._pixelValue = _pixelValue;
+			if (!noRender){
+				this.render();
+			}
+		},
+		setCurrentPercentProgress: function(percentProgress){
+			this._setCurrentPixelProgress(percentProgress);
+		},
+		getProgressValue: function(){
+			return this.progressValue;
+		},
+		getProgressPercentValue: function(){
+			return this._progressPercentValue;
+		},
+		setDataSource: function(dataSource){
+			this.dataSource = dataSource;
+		},
+		setPollInterval: function(pollInterval){
+			this.pollInterval = pollInterval;
+		},
+		start: function(){
+			var _showFunction = dojo.lang.hitch(this, this._showRemoteProgress);
+			this._oInterval = setInterval(_showFunction, this.pollInterval);
+		},
+		startAnimation: function(){
+			if (this._animationStopped) {
+				this._backupValues();
+				this.setProgressValue("10%");
+				this._animationStopped = false;
+				this._setupAnimation();
+				this.showText(false);
+				this._animation.play();
+			}
+		},
+		stopAnimation: function(){
+			if (this._animation) {
+				this._animationStopped = true;
+				this._animation.stop();
+				this.internalProgress.style.left = "0px";
+				this._restoreValues();
+				this._setLabelPosition();
+			}
+		},
+		_showRemoteProgress: function(){
+			var _self = this;
+//			dojo.debug("getMax: "+this.getMaxProgressValue()+" getprval: "+this.getProgressValue());
+			if ( (this.getMaxProgressValue() == this.getProgressValue()) &&
+				this._oInterval){
+				clearInterval(this._oInterval);
+				this._oInterval = null;
+				this.setProgressValue("100%");
+				return;	
+			}
+			var bArgs = {
+				url: _self.dataSource,
+				method: "POST",
+				mimetype: "text/json",
+				error: function(type, errorObj){
+					dojo.debug("[ProgressBar] showRemoteProgress error");
+				},
+				load: function(type, data, evt){
+					//dojo.debug(data["progress"]);
+					_self.setProgressValue(
+						(_self._oInterval ? data["progress"] : "100%")
+					);
+//				dojo.debug("_oInterval: "+_self._oInterval);
+				}
+			};
+			dojo.io.bind(bArgs);
+		},
+		render: function(){
+			this._setPercentLabel(dojo.string.trim(this._progressPercentValue));
+			this._setPixelValue(this._pixelValue);
+			this._setLabelPosition();
+		},
+		// private functions
+		_setLabelPosition: function(){
+			var _widthFront = 
+				dojo.html.getContentBox(this.frontPercentLabel).width;
+			var _heightFront = 
+				dojo.html.getContentBox(this.frontPercentLabel).height;
+			var _widthBack = 
+				dojo.html.getContentBox(this.backPercentLabel).width;
+			var _heightBack = 
+				dojo.html.getContentBox(this.backPercentLabel).height;
+			var _leftFront = (this.width - _widthFront)/2 + "px";
+			var _bottomFront = (parseInt(this.height) - parseInt(_heightFront))/2 + "px";
+			var _leftBack = (this.width - _widthBack)/2 + "px";
+			var _bottomBack = (parseInt(this.height) - parseInt(_heightBack))/2 + "px";
+			this.frontPercentLabel.style.left = _leftFront;
+			this.backPercentLabel.style.left = _leftBack; 
+			this.frontPercentLabel.style.bottom = _bottomFront;
+			this.backPercentLabel.style.bottom = _bottomBack; 
+//			dojo.debug("bottom: "+this.backPercentLabel.style.bottom);
+//			dojo.debug("BOTTOM: "+_bottom);
+		},
+		_setPercentLabel: function(percentValue){
+			dojo.dom.removeChildren(this.frontPercentLabel);
+			dojo.dom.removeChildren(this.backPercentLabel);
+			var _percentValue = this.showOnlyIntegers == "false" ? 
+				percentValue : parseInt(percentValue) + "%";
+			this.frontPercentLabel.
+				appendChild(document.createTextNode(_percentValue));
+			this.backPercentLabel.
+				appendChild(document.createTextNode(_percentValue));
+		},
+		_setPixelValue: function(value){
+			eval("this.internalProgress.style." + this._dimension + " = " + value + " + 'px'");
+			this.onChange();
+		},
+		onChange: function(){
+		}
+	});
+	

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/ProgressBar.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RadioGroup.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RadioGroup.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RadioGroup.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RadioGroup.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,194 @@
+/*
+	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.widget.RadioGroup");
+
+dojo.require("dojo.lang.common");
+dojo.require("dojo.event.browser");
+dojo.require("dojo.html.selection");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+
+// Widget that provides useful/common functionality that may be desirable
+// when interacting with ul/ol html lists.
+//
+// This widget was mostly developed under supervision/guidance from Tom Trenka.
+dojo.widget.defineWidget(
+	"dojo.widget.RadioGroup", 
+	dojo.widget.HtmlWidget,
+	function(){
+		this.selectedItem=null; //currently selected li, if any
+		this.listNode=null; //the containing ul or ol
+		this.items=[]; //the individual li's
+		this.selected=[];
+		
+		//	CSS classes as attributes.
+		this.groupCssClass="radioGroup";
+		this.selectedCssClass="selected";
+		this.itemContentCssClass="itemContent";
+	},
+	{
+		isContainer:false,
+		templatePath: null,
+		templateCssPath: null,
+		
+		//	overridden from HtmlWidget
+		postCreate:function(){
+			this.parseStructure();
+			dojo.html.addClass(this.listNode, this.groupCssClass);
+			this.setupChildren();
+			dojo.event.browser.addListener(this.listNode, "onclick", dojo.lang.hitch(this, "onSelect"));
+			if (this.selectedItem){
+				this.selectItem(this.selectedItem);
+			}
+		},
+		
+		/* 
+		 * Sets local radioGroup and items properties, also validates
+		 * that domNode contains an expected list.
+		 *
+		 * exception: If a ul or ol node can't be found in this widgets domNode
+		 */
+		parseStructure:function() {
+			var listNode = dojo.dom.firstElement(this.domNode, "ul");
+			if (!listNode) { listNode = dojo.dom.firstElement(this.domNode, "ol");}
+			
+			if (listNode) {
+				this.listNode = listNode;
+				this.items=[];	//	reset the items.
+				var nl=listNode.getElementsByTagName("li");
+				for (var i=0; i<nl.length; i++){
+					if(nl[i].parentNode==listNode){
+						this.items.push(nl[i]);
+					}
+				}
+				return;
+			}
+			dojo.raise("RadioGroup: Expected ul or ol content.");
+		},
+		
+		/*
+		 * Allows the app to add a node on the fly, finishing up
+		 * the setup so that we don't need to deal with it on a
+		 * widget-wide basis.
+		 */
+		add:function(node){
+			if(node.parentNode!=this.listNode){
+				this.listNode.appendChild(node);
+			}
+			this.items.push(node);
+			this.setup(node);
+		},
+		
+		// removes the specified node from this group, if it exists
+		remove:function(node){
+			var idx=-1;
+			for(var i=0; i<this.items.length; i++){
+				if(this.items[i]==node){
+					idx=i;
+					break;
+				}
+			}
+			if(idx<0) {return;}
+			this.items.splice(idx,1);
+			node.parentNode.removeChild(node);
+		},
+		
+		// removes all items in this list
+		clear:function(){
+			for(var i=0; i<this.items.length; i++){
+				this.listNode.removeChild(this.items[i]);
+			}
+			this.items=[];
+		},
+		
+		// clears any selected items from being selected
+		clearSelections:function(){
+			for(var i=0; i<this.items.length; i++){
+				dojo.html.removeClass(this.items[i], this.selectedCssClass);
+			}
+			this.selectedItem=null;
+		},
+		
+		setup:function(node){
+			var span = document.createElement("span");
+			dojo.html.disableSelection(span);
+			dojo.html.addClass(span, this.itemContentCssClass);
+			dojo.dom.moveChildren(node, span);
+			node.appendChild(span);
+			
+			if (this.selected.length > 0) {
+				var uid = dojo.html.getAttribute(node, "id");
+				if (uid && uid == this.selected){
+					this.selectedItem = node;
+				}
+			}
+			dojo.event.browser.addListener(node, "onclick", dojo.lang.hitch(this, "onItemSelect"));
+			if (dojo.html.hasAttribute(node, "onitemselect")) {
+				var tn = dojo.lang.nameAnonFunc(new Function(dojo.html.getAttribute(node, "onitemselect")), 
+												this);
+				dojo.event.browser.addListener(node, "onclick", dojo.lang.hitch(this, tn));
+			}
+		},
+		
+		/*
+		 * Iterates over the items li nodes and manipulates their
+		 * dom structures to handle things like span tag insertion
+		 * and selecting a default item.
+		 */
+		setupChildren:function(){
+			for (var i=0; i<this.items.length; i++){
+				this.setup(this.items[i]);
+			}
+		},
+		
+		// Sets the selectedItem to passed in node, applies
+		// css selection class on new item
+		selectItem:function(node, event, nofire){
+			if(this.selectedItem){
+				dojo.html.removeClass(this.selectedItem, this.selectedCssClass);
+			}
+			
+			this.selectedItem = node;
+			dojo.html.addClass(this.selectedItem, this.selectedCssClass);
+			
+			// if this is the result of an event, stop here.
+			if (!dj_undef("currentTarget", event)){
+				return;
+			}
+			
+			//	if there's no nofire flag, passed when this is nailed internally.
+			if(!nofire){
+				if(dojo.render.html.ie){
+					this.selectedItem.fireEvent("onclick");
+				}else{
+					var e = document.createEvent("MouseEvents");
+					e.initEvent("click", true, false);
+					this.selectedItem.dispatchEvent(e);
+				}
+			}
+		},
+		
+		// gets the currently selected item
+		getValue:function() {
+			return this.selectedItem;
+		},
+		
+		// when the ul or ol contained by this widget is selected
+		onSelect:function(e) { },
+		
+		// when an individual li is selected
+		onItemSelect:function(e) {
+			if (!dj_undef("currentTarget", e)){
+				this.selectItem(e.currentTarget, e);
+			}
+		}
+	}
+);

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RadioGroup.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RemoteTabController.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RemoteTabController.js?view=auto&rev=451106
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RemoteTabController.js (added)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RemoteTabController.js Thu Sep 28 20:42:39 2006
@@ -0,0 +1,50 @@
+/*
+	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.widget.RemoteTabController");
+
+//Summary
+//Remote Tab Controller widget.  Can be located independently of a tab
+//container and control the selection of its tabs
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.TabContainer");
+dojo.require("dojo.event.*");
+
+dojo.deprecated("dojo.widget.RemoteTabController is slated for removal in 0.5; use PageController or TabController instead.", "0.5");
+
+dojo.widget.defineWidget(
+    "dojo.widget.RemoteTabController",
+    dojo.widget.TabController,
+	{
+        templateCssPath: dojo.uri.dojoUri("src/widget/templates/RemoteTabControl.css"),
+		templateString: '<div dojoAttachPoint="domNode" wairole="tablist"></div>',
+
+		"class": "dojoRemoteTabController",
+
+		// String
+		//	ID of page container that I connect to
+		tabContainer: "",
+	
+		postMixInProperties: function(){
+			this.containerId = this.tabContainer;
+			dojo.widget.RemoteTabController.superclass.postMixInProperties.apply(this, arguments);
+		},
+			
+		fillInTemplate: function() {
+			dojo.html.addClass(this.domNode, this["class"]);  // "class" is a reserved word in JS
+
+			if (this.tabContainer) {
+				dojo.addOnLoad(dojo.lang.hitch(this, "setupTabs"));
+			}
+
+			dojo.widget.RemoteTabController.superclass.fillInTemplate.apply(this, arguments);
+		}
+	}
+);

Propchange: tapestry/tapestry4/trunk/tapestry-framework/src/js/dojo/src/widget/RemoteTabController.js
------------------------------------------------------------------------------
    svn:eol-style = native