rem: dojo.widget.PopupManager = new function(){ this.currentMenu = null; this.currentButton = null; this.currentFocusMenu = null; this.focusNode = null; this.registeredWindows = [];  this.registerWin = function(/*Window*/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.registerAllWindows = function(/*Window*/targetWindow){          if(!targetWindow) { targetWindow = dojo.html.getDocumentWindow(window.top && window.top.document || window.document); }  this.registerWin(targetWindow);  for (var i = 0; i < targetWindow.frames.length; i++){ try{  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(/*Window*/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(/*Widget*/menu){  if (this.currentMenu == menu){ this.currentMenu = null; this.currentButton = null; this.currentFocusMenu = null; } };  this.opened = function(/*Widget*/menu, /*DomNode*/button){  if (menu == this.currentMenu){ return; }  if (this.currentMenu){ this.currentMenu.close(); }  this.currentMenu = menu; this.currentFocusMenu = menu; this.currentButton = button; };  this.setFocusedMenu = function(/*Widget*/menu){   this.currentFocusMenu = menu; };  this.onKey = function(/*Event*/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(/*Event*/e){ if (!this.currentMenu){ return; }  var scrolloffset = dojo.html.getScroll().offset;     var m = this.currentMenu;  while (m){ if(dojo.html.overElement(m.domNode, e) || dojo.html.isDescendantOf(e.target, m.domNode)){ return; } m = m.currentSubpopup; }     if (this.currentButton && dojo.html.overElement(this.currentButton, e)){ return; }     this.currentMenu.close(); }; } 
add: function(){ try{ if(this.parent['focus']){ this.parent.focus(); }else{ this.parent.domNode.focus(); } }catch(e){dojo.debug("No idea how to focus to parent", e);} } 
context: 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(/*Window*/win){		// summary: register a window so that when clicks/scroll in it, the popup can be closed automatically		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.registerAllWindows = function(/*Window*/targetWindow){		// summary:		//		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		//starting from window.top, clicking everywhere in this page		//should close popup menus		if(!targetWindow) { //see comment below			targetWindow = dojo.html.getDocumentWindow(window.top && window.top.document || window.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(/*Window*/win){		// summary: remove listeners on the registered window		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(){		// summary: remove listeners on all the registered windows		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(/*Widget*/menu){		// summary: notify the manager that menu is closed		if (this.currentMenu == menu){			this.currentMenu = null;			this.currentButton = null;			this.currentFocusMenu = null;		}	};	this.opened = function(/*Widget*/menu, /*DomNode*/button){		// summary: sets the current opened popup		if (menu == this.currentMenu){ return; }		if (this.currentMenu){			this.currentMenu.close();		}		this.currentMenu = menu;		this.currentFocusMenu = menu;		this.currentButton = button;	};	this.setFocusedMenu = function(/*Widget*/menu){		// summary:		// 		Set the current focused popup, This is used by popups which supports keyboard navigation		this.currentFocusMenu = menu;	};	this.onKey = function(/*Event*/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(/*Event*/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();	};}
meta: 4707	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/4707/50c3492c4c3c825dbd3401e134a19ed46799c456/PopupContainer.js/buggy/www/resources/dojo-ajax/src/widget/PopupContainer.js