⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stackcontainer.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
		// buttonWidget: String		//	the name of the button widget to create to correspond to each page		buttonWidget: "dijit.layout._StackButton",		postCreate: function(){			dijit.setWaiRole(this.domNode, "tablist");			// TODO: change key from object to id, to get more separation from StackContainer			this.pane2button = {};		// mapping from panes to buttons			this.pane2menu = {};		// mapping from panes to close menu			this._subscriptions=[				dojo.subscribe(this.containerId+"-startup", this, "onStartup"),				dojo.subscribe(this.containerId+"-addChild", this, "onAddChild"),				dojo.subscribe(this.containerId+"-removeChild", this, "onRemoveChild"),				dojo.subscribe(this.containerId+"-selectChild", this, "onSelectChild"),				dojo.subscribe(this.containerId+"-containerKeyPress", this, "onContainerKeyPress")			];		},		onStartup: function(/*Object*/ info){			// summary: called after StackContainer has finished initializing			dojo.forEach(info.children, this.onAddChild, this);			this.onSelectChild(info.selected);		},		destroy: function(){			for(var pane in this.pane2button){				this.onRemoveChild(pane);			}			dojo.forEach(this._subscriptions, dojo.unsubscribe);			this.inherited(arguments);		},		onAddChild: function(/*Widget*/ page, /*Integer?*/ insertIndex){			// summary:			//   Called whenever a page is added to the container.			//   Create button corresponding to the page.			// add a node that will be promoted to the button widget			var refNode = dojo.doc.createElement("span");			this.domNode.appendChild(refNode);			// create an instance of the button widget			var cls = dojo.getObject(this.buttonWidget);			var button = new cls({label: page.title, closeButton: page.closable}, refNode);			this.addChild(button, insertIndex);			this.pane2button[page] = button;			page.controlButton = button;	// this value might be overwritten if two tabs point to same container						dojo.connect(button, "onClick", dojo.hitch(this,"onButtonClick",page));			if(page.closable){				dojo.connect(button, "onClickCloseButton", dojo.hitch(this,"onCloseButtonClick",page));				// add context menu onto title button				var _nlsResources = dojo.i18n.getLocalization("dijit", "common");				var closeMenu = new dijit.Menu({targetNodeIds:[button.id], id:button.id+"_Menu"});				var mItem = new dijit.MenuItem({label:_nlsResources.itemClose});            	dojo.connect(mItem, "onClick", dojo.hitch(this, "onCloseButtonClick", page));           		closeMenu.addChild(mItem);           		this.pane2menu[page] = closeMenu;			}			if(!this._currentChild){ // put the first child into the tab order				button.focusNode.setAttribute("tabIndex", "0");				this._currentChild = page;			}			//make sure all tabs have the same length			if(!this.isLeftToRight() && dojo.isIE && this._rectifyRtlTabList){				this._rectifyRtlTabList();			}		},		onRemoveChild: function(/*Widget*/ page){			// summary:			//   Called whenever a page is removed from the container.			//   Remove the button corresponding to the page.			if(this._currentChild === page){ this._currentChild = null; }			var button = this.pane2button[page];			var menu = this.pane2menu[page];			if (menu){				menu.destroy();			}			if(button){				// TODO? if current child { reassign }				button.destroy();			}			this.pane2button[page] = null;		},		onSelectChild: function(/*Widget*/ page){			// summary:			//	Called when a page has been selected in the StackContainer, either by me or by another StackController			if(!page){ return; }			if(this._currentChild){				var oldButton=this.pane2button[this._currentChild];				oldButton.setAttribute('checked', false);				oldButton.focusNode.setAttribute("tabIndex", "-1");			}			var newButton=this.pane2button[page];			newButton.setAttribute('checked', true);			this._currentChild = page;			newButton.focusNode.setAttribute("tabIndex", "0");			var container = dijit.byId(this.containerId);			dijit.setWaiState(container.containerNode || container.domNode, "labelledby", newButton.id);		},		onButtonClick: function(/*Widget*/ page){			// summary:			//   Called whenever one of my child buttons is pressed in an attempt to select a page			var container = dijit.byId(this.containerId);	// TODO: do this via topics?			container.selectChild(page); 		},		onCloseButtonClick: function(/*Widget*/ page){			// summary:			//   Called whenever one of my child buttons [X] is pressed in an attempt to close a page			var container = dijit.byId(this.containerId);			container.closeChild(page);			var b = this.pane2button[this._currentChild];			if(b){				dijit.focus(b.focusNode || b.domNode);			}		},				// TODO: this is a bit redundant with forward, back api in StackContainer		adjacent: function(/*Boolean*/ forward){			if(!this.isLeftToRight() && (!this.tabPosition || /top|bottom/.test(this.tabPosition))){ forward = !forward; }			// find currently focused button in children array			var children = this.getChildren();			var current = dojo.indexOf(children, this.pane2button[this._currentChild]);			// pick next button to focus on			var offset = forward ? 1 : children.length - 1;			return children[ (current + offset) % children.length ]; // dijit._Widget		},		onkeypress: function(/*Event*/ e){			// summary:			//   Handle keystrokes on the page list, for advancing to next/previous button			//   and closing the current page if the page is closable.			if(this.disabled || e.altKey ){ return; }			var forward = null;			if(e.ctrlKey || !e._djpage){				var k = dojo.keys;				switch(e.keyCode){					case k.LEFT_ARROW:					case k.UP_ARROW:						if(!e._djpage){ forward = false; }						break;					case k.PAGE_UP:						if(e.ctrlKey){ forward = false; }						break;					case k.RIGHT_ARROW:					case k.DOWN_ARROW:						if(!e._djpage){ forward = true; }						break;					case k.PAGE_DOWN:						if(e.ctrlKey){ forward = true; }						break;					case k.DELETE:						if(this._currentChild.closable){							this.onCloseButtonClick(this._currentChild);						}						dojo.stopEvent(e);						break;					default:						if(e.ctrlKey){							if(e.keyCode == k.TAB){								this.adjacent(!e.shiftKey).onClick();								dojo.stopEvent(e);							}else if(e.keyChar == "w"){								if(this._currentChild.closable){									this.onCloseButtonClick(this._currentChild);								}								dojo.stopEvent(e); // avoid browser tab closing.							}						}				}				// handle page navigation				if(forward !== null){					this.adjacent(forward).onClick();					dojo.stopEvent(e);				}			}		},		onContainerKeyPress: function(/*Object*/ info){			info.e._djpage = info.page;			this.onkeypress(info.e);		}});dojo.declare("dijit.layout._StackButton",	dijit.form.ToggleButton,	{	// summary	//	Internal widget used by StackContainer.	//	The button-like or tab-like object you click to select or delete a page		tabIndex: "-1", // StackContainer buttons are not in the tab order by default		postCreate: function(/*Event*/ evt){		dijit.setWaiRole((this.focusNode || this.domNode), "tab");		this.inherited(arguments);	},		onClick: function(/*Event*/ evt){		// summary: This is for TabContainer where the tabs are <span> rather than button,		// 	so need to set focus explicitly (on some browsers)		dijit.focus(this.focusNode);		// ... now let StackController catch the event and tell me what to do	},	onClickCloseButton: function(/*Event*/ evt){		// summary		//	StackContainer connects to this function; if your widget contains a close button		//	then clicking it should call this function.		evt.stopPropagation();	}});// These arguments can be specified for the children of a StackContainer.// Since any widget can be specified as a StackContainer child, mix them// into the base widget class.  (This is a hack, but it's effective.)dojo.extend(dijit._Widget, {	// title: String	//		Title of this widget.  Used by TabContainer to the name the tab, etc.	title: "",	// selected: Boolean	//		Is this child currently selected?	selected: false,	// closable: Boolean	//		True if user can close (destroy) this child, such as (for example) clicking the X on the tab.	closable: false,	// true if user can close this tab pane	onClose: function(){		// summary: Callback if someone tries to close the child, child will be closed if func returns true		return true;	}});}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -