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

📄 bordercontainer.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
			var containerHeight = thisBorderBox.h;			var middleHeight = containerHeight;			if(this._top){ middleHeight -= topHeight; }			if(this._bottom){ middleHeight -= bottomHeight; }			if(topSplitter){ middleHeight -= topSplitterThickness; }			if(bottomSplitter){ middleHeight -= bottomSplitterThickness; }			var centerDim = { h: middleHeight };			var sidebarHeight = sidebarLayout ? containerHeight : middleHeight;			if(leftSplitter){ leftSplitter.style.height = sidebarHeight; }			if(rightSplitter){ rightSplitter.style.height = sidebarHeight; }			resizeWidget(this._leftWidget, {h: sidebarHeight});			resizeWidget(this._rightWidget, {h: sidebarHeight});			var containerWidth = thisBorderBox.w;			var middleWidth = containerWidth;			if(this._left){ middleWidth -= leftWidth; }			if(this._right){ middleWidth -= rightWidth; }			if(leftSplitter){ middleWidth -= leftSplitterThickness; }			if(rightSplitter){ middleWidth -= rightSplitterThickness; }			centerDim.w = middleWidth;			var sidebarWidth = sidebarLayout ? middleWidth : containerWidth;			if(topSplitter){ topSplitter.style.width = sidebarWidth; }			if(bottomSplitter){ bottomSplitter.style.width = sidebarWidth; }			resizeWidget(this._topWidget, {w: sidebarWidth});			resizeWidget(this._bottomWidget, {w: sidebarWidth});			resizeWidget(this._centerWidget, centerDim);		}else{			// We've already sized the children by setting style.top/bottom/left/right...			// Now just need to call resize() on those children so they can re-layout themselves			// TODO: calling child.resize() without an argument is bad, because it forces			// the child to query it's own size (even though this function already knows			// the size), plus which querying the size of a node right after setting it			// is known to cause problems (incorrect answer or an exception).			// This is a setback from older layout widgets, which			// don't do that.  See #3399, #2678, #3624 and #2955, #1988			var resizeList = {};			if(changedRegion){				resizeList[changedRegion] = resizeList.center = true;				if(/top|bottom/.test(changedRegion) && this.design != "sidebar"){					resizeList.left = resizeList.right = true;				}else if(/left|right/.test(changedRegion) && this.design == "sidebar"){					resizeList.top = resizeList.bottom = true;				}			}			dojo.forEach(this.getChildren(), function(child){				if(child.resize && (!changedRegion || child.region in resizeList)){	//				console.log(this.id, ": resizing child id=" + child.id + " (region=" + child.region + "), style before resize is " +	//									 "{ t: " + child.domNode.style.top +	//									", b: " + child.domNode.style.bottom +	//									", l: " + child.domNode.style.left +	//									 ", r: " + child.domNode.style.right +	//									 ", w: " + child.domNode.style.width +	//									 ", h: " + child.domNode.style.height +	//									"}"	//						);					child.resize();	//				console.log(this.id, ": after resize of child id=" + child.id + " (region=" + child.region + ") " +	//									 "{ t: " + child.domNode.style.top +	//									", b: " + child.domNode.style.bottom +	//									", l: " + child.domNode.style.left +	//									 ", r: " + child.domNode.style.right +	//									 ", w: " + child.domNode.style.width +	//									 ", h: " + child.domNode.style.height +	//									"}"	//						);				}			}, this);		}	}});// This argument can be specified for the children of a BorderContainer.// Since any widget can be specified as a LayoutContainer child, mix it// into the base widget class.  (This is a hack, but it's effective.)dojo.extend(dijit._Widget, {	// region: String	//		"top", "bottom", "leading", "trailing", "left", "right", "center".	//		See the BorderContainer description for details on this parameter.	region: '',	// splitter: Boolean	splitter: false,	// minSize: Number	minSize: 0,	// maxSize: Number	maxSize: Infinity});dojo.require("dijit._Templated");dojo.declare("dijit.layout._Splitter", [ dijit._Widget, dijit._Templated ],{/*=====	container: null,	child: null,	region: null,=====*/	// live: Boolean	//		If true, the child's size changes and the child widget is redrawn as you drag the splitter;	//		otherwise, the size doesn't change until you drop the splitter (by mouse-up)	live: true,	// summary: A draggable spacer between two items in a BorderContainer	templateString: '<div class="dijitSplitter" dojoAttachEvent="onkeypress:_onKeyPress,onmousedown:_startDrag" tabIndex="0" waiRole="separator"><div class="dijitSplitterThumb"></div></div>',	postCreate: function(){		this.inherited(arguments);		this.horizontal = /top|bottom/.test(this.region);		dojo.addClass(this.domNode, "dijitSplitter" + (this.horizontal ? "H" : "V"));//		dojo.addClass(this.child.domNode, "dijitSplitterPane");//		dojo.setSelectable(this.domNode, false); //TODO is this necessary?		this._factor = /top|left/.test(this.region) ? 1 : -1;		this._minSize = this.child.minSize;		this._computeMaxSize();		//TODO: might be more accurate to recompute constraints on resize?		this.connect(this.container, "layout", dojo.hitch(this, this._computeMaxSize));		this._cookieName = this.container.id + "_" + this.region;		if(this.container.persist){			// restore old size			var persistSize = dojo.cookie(this._cookieName);			if(persistSize){				this.child.domNode.style[this.horizontal ? "height" : "width"] = persistSize;			}		}	},	_computeMaxSize: function(){		var dim = this.horizontal ? 'h' : 'w';		var available = dojo.contentBox(this.container.domNode)[dim] - (this.oppNode ? dojo.marginBox(this.oppNode)[dim] : 0);		this._maxSize = Math.min(this.child.maxSize, available);	},	_startDrag: function(e){		if(!this.cover){			this.cover = dojo.doc.createElement('div');			dojo.addClass(this.cover, "dijitSplitterCover");			dojo.place(this.cover, this.child.domNode, "after");		}else{			this.cover.style.zIndex = 1;		}		// Safeguard in case the stop event was missed.  Shouldn't be necessary if we always get the mouse up. 		if(this.fake){ dojo._destroyElement(this.fake); }		if(!(this._resize = this.live)){ //TODO: disable live for IE6?			// create fake splitter to display at old position while we drag			(this.fake = this.domNode.cloneNode(true)).removeAttribute("id");			dojo.addClass(this.domNode, "dijitSplitterShadow");			dojo.place(this.fake, this.domNode, "after");		}		dojo.addClass(this.domNode, "dijitSplitterActive");		//Performance: load data info local vars for onmousevent function closure		var factor = this._factor,			max = this._maxSize,			min = this._minSize || 10;		var axis = this.horizontal ? "pageY" : "pageX";		var pageStart = e[axis];		var splitterStyle = this.domNode.style;		var dim = this.horizontal ? 'h' : 'w';		var childStart = dojo.marginBox(this.child.domNode)[dim];		var splitterStart = parseInt(this.domNode.style[this.region]);		var resize = this._resize;		var region = this.region;		var mb = {};		var childNode = this.child.domNode;		var layoutFunc = dojo.hitch(this.container, this.container._layoutChildren);		var de = dojo.doc.body;		this._handlers = (this._handlers || []).concat([			dojo.connect(de, "onmousemove", this._drag = function(e, forceResize){				var delta = e[axis] - pageStart,					childSize = factor * delta + childStart,					boundChildSize = Math.max(Math.min(childSize, max), min);				if(resize || forceResize){					mb[dim] = boundChildSize;					// TODO: inefficient; we set the marginBox here and then immediately layoutFunc() needs to query it					dojo.marginBox(childNode, mb);					layoutFunc(region);				}				splitterStyle[region] = factor * delta + splitterStart + (boundChildSize - childSize) + "px";			}),			dojo.connect(de, "onmouseup", this, "_stopDrag")		]);		dojo.stopEvent(e);	},	_stopDrag: function(e){		try{			if(this.cover){ this.cover.style.zIndex = -1; }			if(this.fake){ dojo._destroyElement(this.fake); }			dojo.removeClass(this.domNode, "dijitSplitterActive");			dojo.removeClass(this.domNode, "dijitSplitterShadow");			this._drag(e); //TODO: redundant with onmousemove?			this._drag(e, true);		}finally{			this._cleanupHandlers();			delete this._drag;		}		if(this.container.persist){			dojo.cookie(this._cookieName, this.child.domNode.style[this.horizontal ? "height" : "width"]);		}	},	_cleanupHandlers: function(){		dojo.forEach(this._handlers, dojo.disconnect);		delete this._handlers;	},	_onKeyPress: function(/*Event*/ e){		// should we apply typematic to this?		this._resize = true;		var horizontal = this.horizontal;		var tick = 1;		var dk = dojo.keys;		switch(e.keyCode){			case horizontal ? dk.UP_ARROW : dk.LEFT_ARROW:				tick *= -1;				break;			case horizontal ? dk.DOWN_ARROW : dk.RIGHT_ARROW:				break;			default://				this.inherited(arguments);				return;		}		var childSize = dojo.marginBox(this.child.domNode)[ horizontal ? 'h' : 'w' ] + this._factor * tick;		var mb = {};		mb[ this.horizontal ? "h" : "w"] = Math.max(Math.min(childSize, this._maxSize), this._minSize);		dojo.marginBox(this.child.domNode, mb);		this.container._layoutChildren(this.region);		dojo.stopEvent(e);	},	destroy: function(){		this._cleanupHandlers();		delete this.child;		delete this.container;		delete this.fake;		this.inherited(arguments);	}});}

⌨️ 快捷键说明

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