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

📄 paneset-controlling.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 2 页
字号:
// $Id: paneset-controlling.js 6651 2007-03-19 10:15:22Z slip $/** * Sets the width of the PaneSet container. * @param width [number] - width to set. */Zapatec.PaneSet.prototype.setContainerWidth = function(width) {	if (!this.fireOnState("ready", function() {this.setContainerWidth(width);})) {		return;	}	Zapatec.Utils.setWidth(this.getContainer(), width);};/** * Sets the height of the PaneSet container. * @param height [number] - height to set. */Zapatec.PaneSet.prototype.setContainerHeight = function(height) {	if (!this.fireOnState("ready", function() {this.setContainerHeight(height);})) {		return;	}	Zapatec.Utils.setHeight(this.getContainer(), height);};/** * Sets the breadth of the divider. This depends on PaneSet orientation. * For "vertical" it's width, for "horizontal" it's height. * @param divider [HTML element] - the element representing divider. * @param breadth [number] - the breadth of the divider, depends on orientation */Zapatec.PaneSet.prototype.setDividerBreadth = function(divider, breadth) {	if (!this.fireOnState("ready", function() {this.setDividerBreadth(divider, breadth);})) {		return;	}	if (!this.isChildDivider(divider)) {		return;	}	if (this.config.orientation == "vertical") {		Zapatec.Utils.setWidth(divider, breadth);	} else {		Zapatec.Utils.setHeight(divider, breadth);	}};/** * Sets the dimensions of container * @param length [number] - length of the container. * @param breadth [number] - breadth of the container. */Zapatec.PaneSet.prototype.setContainerSizes = function(length, breadth) {	this.config.breadth = parseInt(breadth, 10) || this.config.breadth;	this.config.length = parseInt(length, 10) || this.config.length;	if (this.config.orientation == "vertical") {		this.setContainerWidth(this.config.breadth);		this.setContainerHeight(this.config.length);	} else {		this.setContainerWidth(this.config.length);		this.setContainerHeight(this.config.breadth);	}};/** * Moves the Pane/PaneSet to the specified point. * @param pane [object] - Pane/PaneSet object to move. * @param x [number] - X coordinate. * @param y [number] - Y coordinate. */Zapatec.PaneSet.prototype.movePane = function(pane, x, y) {	var self = this, paneCont = null;	if (!this.fireOnState("ready", function() {this.movePane(pane, x, y);}) ||	    (pane.widgetType == "paneset" && !pane.fireOnState("ready", function() {self.movePane(pane, x, y);}))) {		return;	}	if (typeof this.isChildPane(pane) == "number") {		paneCont = pane.getContainer();		Zapatec.Utils.makeSafelyMovable(paneCont, this.getContainer(), null);		Zapatec.Utils.moveTo(paneCont, x, y);	}};/** * Moves the divider to the specified point. * @param divider [HTML element] - diveder to work with. * @param x [number] - X coordinate. * @param y [number] - Y coordinate. */Zapatec.PaneSet.prototype.moveDivider = function(divider, x, y) {	if (!this.fireOnState("ready", function() {this.moveDivider(divider, x, y);})) {		return;	}	if (this.isChildDivider(divider)) {		Zapatec.Utils.makeSafelyMovable(divider, this.getContainer(), null);		Zapatec.Utils.moveTo(divider, x, y);	}};/** * Sets the breadth of child Pane/PaneSet. I'm using * word breadth here because dimensions of child panes * are opposite to the PaneSet dimensions. From this * reasons we call method setPaneLength. If the Pane/PaneSet is not * present in this.panes array, we try to seek it in * child PaneSets. * @param pane [string or number or object] - ID of the Pane/PaneSet, * its number counting from 1 in this PaneSet or Pane object itself. * @param length [number] - new breadth. */Zapatec.PaneSet.prototype.setPaneLength = function(pane, length) {	var self = this, diff, position, nextPane, divider, availSpace, dividerPos, nextPos;	length = parseInt(length, 10);	if (!this.fireOnState("ready", function() {this.setPaneLength(pane, length);})) {		return;	}		//searching the Pane by ID, number or taking it if it's object	if (typeof pane == "string") {		pane = this.getPaneById(pane);	} else if (typeof pane == "number") {		pane = this.panes[pane - 1];	} else if (!pane || !pane.widgetType) {		Zapatec.Log({description: "No Pane/PaneSet found when calling setPaneLength!"});		return;	}	//is this child Pane/PaneSet	position = this.isChildPane(pane);	//if not than this must be an error	if (!position && position !== 0) {		Zapatec.Log({description: "Not a child Pane or PaneSet object passed when calling setPaneLength!"});		return;	}	if (pane.disabled) {		return;	}	//checking if position is PaneSet object or number pointing	//to the object in panes array.	if (typeof position == "number") {		//next Pane/PaneSet and our divider		nextPane = this.panes[position + 1];		divider = this.dividers[position];		//if this is PaneSet need to be safe with its state		if (nextPane && nextPane.widgetType == "paneset" && !nextPane.fireOnState("ready", function() {self.setPaneLength(pane, length);})) {			return;		}		if (pane.widgetType == "paneset" && !pane.fireOnState("ready", function() {self.setPaneLength(pane, length);})) {			return;		}		//determining the direction of change		diff = length - pane.config.breadth;		//if difference bigger than 0 we should check if this is not last pane/PaneSet		//and try to get available for sizing space. If diff < 0 getting available space		//for sizing. otherwise we don't breadth Pane/PaneSet		if (diff > 0 && divider) {			//getting available space from nextPane			if (nextPane.widgetType == "paneset") {				availSpace = nextPane.getAvailableBreadth(false);			} else {				availSpace = nextPane.config.breadth - 1;			}			//correcting new length due to available breadth			length -= diff;			if (availSpace < diff) {				diff = availSpace;			}			length += diff;		} else if (diff < 0 && divider) {			//getting available space from this pane			if (pane.widgetType == "paneset") {				availSpace = pane.getAvailableBreadth(true);			} else {				availSpace = pane.config.breadth - 1;			}			//correcting new length due to available breadth			length -= diff;			if (availSpace < Math.abs(diff)) {				diff = -availSpace;			}			length += diff;		} else {			//leaving breadth the same			length = pane.config.breadth;		}		//FIXME: if it is the last Pane and diff < 0 we should restore disabled panes		this.sizePane(pane, null, length, true);		//saving new breadth to config		this.config.panes[position].breadth = length;		if (nextPane && divider) {			//getting divider position			dividerPos = Zapatec.Utils.getPos(divider);			//getting next Pane position			nextPos = Zapatec.Utils.getPos(nextPane.getContainer());			//increasing coordinates			this.incCoords(dividerPos, diff);			this.incCoords(nextPos, diff);			//saving new breadth to config			this.config.panes[position + 1].breadth = nextPane.config.breadth - diff;			//moving divider			this.moveDivider(divider, dividerPos.x, dividerPos.y);			//moving Pane/PaneSet			this.movePane(nextPane, nextPos.x, nextPos.y);			//sizing next Pane/PaneSet			this.sizePane(nextPane, null, nextPane.config.breadth - diff, false);		}		this.bubleEvent("paneLengthChanged", pane, nextPane);	} else if (position && position.widgetType == "paneset") {		//if this is not the direct child, let its real parent work with it		position.setPaneLength(pane, length);		return;	} else {		Zapatec.Log({description: "Can't find position of a child Pane or PaneSet object\n passed when calling setPaneLength!"});		return;	}};/** * Sets the dimensions of specified Pane/PaneSet. Internal use only. * @param pane [string or number or object] - Pane object. * @param breadth [number] - new length. * @param length [number] - new breadth. * @param end [boolean] - determines if we change space from * the pane end or beginning. */Zapatec.PaneSet.prototype.sizePane = function(pane, breadth, length, end) {	breadth = parseInt(breadth, 10);	length = parseInt(length, 10);	if (!this.fireOnState("ready", function() {this.sizePane(pane, breadth, length, end);})) {		return;	}	//setting dimensions if passed	if (this.config.orientation == "vertical") {		if (breadth) {			pane.setWidth(breadth, end);			pane.config.length = breadth;		}		if (length) {			pane.setHeight(length, end);			pane.config.breadth = length;		}	} else {		if (breadth) {			pane.setHeight(breadth, end);			pane.config.length = breadth;		}		if (length) {			pane.setWidth(length, end);			pane.config.breadth = length;		}	}};/** * Sets the width of the whole PaneSet. * @param width [number] - width of the PaneSet * @param end [boolean] - determines if we change space from * the pane end or beginning. */

⌨️ 快捷键说明

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