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

📄 window-controlling.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 2 页
字号:
// $Id: window-controlling.js 6767 2007-03-27 08:21:54Z slip $/** * * Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. *//** * Gets the window container. */Zapatec.Window.prototype.getContainer = function() {	return this.container;};/** * Sets default state values of the widget. */Zapatec.Window.prototype.setDefaultState = function() {	//stores the properties which describe the state of the widget	this.state = {};	//is window minimized, maximized or simple	this.state.state = "simple";	//X coordinate	this.state.left = 0;	//Y coordinate	this.state.top = 0;	//the width of the window	this.state.width = 0;	//the height of the window	this.state.height = 0;	//the content type of the window	this.state.contentType = "";	//the content of the window	this.state.content = "";};/** * Updates the state object. */Zapatec.Window.prototype._updateState = function() {	//getting position	var pos = null;	if (!this.getConfiguration().fixed) {		pos = this.getPosition();	} else {		pos = this.getScreenPosition();	}	//saving coordinates	this.state.left = pos.x;	this.state.top = pos.y;	//saving sizes	if (this.state.state != "min") {		this.state.width = this.getWidth();		this.state.height = this.getHeight();	}};/**  * Gets the state of the window. * @return object with the following properties: * \code *    prop. name     | description *  ------------------------------------------------------------------------------------------------- *   x       | left coordinate. *   y       | top coordinate. *   width   | width of container. *   height  | height of container. *   url     | if content is set from URL, than it contains that URL, otherwise null *   div     | if content is set from DIV element, than it contains it id, if it has no id its null. *   text    | if content is set as text string, than it contains that text, otherwise null * \endcode */Zapatec.Window.prototype.getState = function() {	var state = {};	//getting coordinates	state.x = this.state.left;	state.y = this.state.top;	//getting sizes	state.width = this.state.width;	state.height = this.state.height;	//getting zIndex	state.zIndex = this.getContainer().style.zIndex;	//getting content	switch(this.state.contentType) {		case "html/text" : state.text = this.state.content; break;		case "html" : state.div = this.state.content; break;		case "html/url" : state.url = this.state.content; break;	}		return state;};/**  * Sets the state of the window. * @param state [object] with the following properties: * \code *    prop. name     | description *  ------------------------------------------------------------------------------------------------- *   x       | left coordinate. *   y       | top coordinate. *   width   | width of container. *   height  | height of container. *   url     | URL content. *   div     | content is set from DIV element. *   text    | content is set as text string. * \endcode */Zapatec.Window.prototype.setState = function(state) {	if (!this.fireOnState("ready", function() {this.setState(state);})) {return;}	//setting size and coordinates	if (state.x || state.y || state.width || state.height) {		this.setPosAndSize(state.x, state.y, state.width, state.height);	}	//setting z-index	if (state.zIndex) {		//for container		this.container.style.zIndex = state.zIndex;		//updating global variable		if(state.zIndex > Zapatec.Window.maxNumber){			Zapatec.Window.maxNumber = state.zIndex + 1;		}		//updating WCH		if (this.WCH) {			this.WCH.style.zIndex = state.zIndex - 1;		}		//updating modal		if(this.config.modal){			this.modal.container.style.zIndex = state.zIndex - 2;		}	}	//setting content	if(state.url || state.div || state.text){		this.setContent("");		if (state.url) {			//URL content			this.setContentUrl(state.url);		} else if (state.div) {			//DIV content			this.setDivContent(state.div);		} else if (state.text) {			//text content			this.setContent(state.text);		}	}	return true;};/** * Depricated. Only for backward compability. * * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. */Zapatec.Window.prototype.setPos = function(left, top) {	this.setScreenPosition(left, top);};/** * We overwrite implemented method to make it more  * friendly to states. So actually this method sets * the coordinates of Window. * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. */Zapatec.Window.prototype.setPosition = function(left, top) {	if (!this.fireOnState("shown", function() {this.setPosition(left, top);})) {return;}	//calling interface method in scope of this object	Zapatec.Movable.setPosition.call(this, left, top);	//updating state object	this._updateState();};/** * We overwrite implemented method to make it more  * friendly to states. This method sets the coordinates * of Window on the screen. * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. */Zapatec.Window.prototype.setScreenPosition = function(left, top) {	if (!this.fireOnState("shown", function() {this.setScreenPosition(left, top);})) {return;}	//calling interface method in scope of this object	Zapatec.Movable.setScreenPosition.call(this, left, top);};/** * We overwrite implemented method to make it more  * friendly to states. This method sets the coordinates * of Window on the whole page (document.body). * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. */Zapatec.Window.prototype.setPagePosition = function(left, top) {	if (!this.fireOnState("shown", function() {this.setPagePosition(left, top);})) {return;}	//calling interface method in scope of this object	Zapatec.Movable.setPagePosition.call(this, left, top);};/** * Sets the width of the window.  * We overwrite interface method to make * it friendly for states. * * @param width [integer] - width of the window. */Zapatec.Window.prototype.setWidth = function(width) {	if (!this.fireOnState("shown", function() {this.setWidth(width);})) {return;}	//we can only call this in case if Window is not minimized or maximized	if (this.state.state != "simple") {return false;}	//calling interface method in scope of this object	Zapatec.Sizable.setWidth.call(this, width);	//updating state object	this._updateState();};/** * Sets the height of the window. * We overwrite interface method to make * it friendly for states. * * @param height [integer] - height of the window. */Zapatec.Window.prototype.setHeight = function(height) {	if (!this.fireOnState("shown", function() {this.setHeight(height);})) {return;}	//we can only call this in case if Window is not minimized or maximized	if (this.state.state != "simple") {return false;}	//calling interface method in scope of this object	Zapatec.Sizable.setHeight.call(this, height);	//updating state object	this._updateState();};/** * Sets the sizes of the window.  * * @param width [integer] - width of the window. * @param height [integer] - height of the window. */Zapatec.Window.prototype.setSize = function(width, height) {	this.setWidth(width);	this.setHeight(height);};/** * Sets the sizes and position of the window.  * * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. * @param width [integer] - width of the window. * @param height [integer] - height of the window. */Zapatec.Window.prototype.setPosAndSize = function(left, top, width, height) {	this.setSize(width, height);	this.setPos(left, top);};/* * Set the title of the window * @param type [string] the title to set to */ Zapatec.Window.prototype.setTitle = function(text) {	if (!this.fireOnState("ready", function() {this.setTitle(text);})) {return;}	//putting text into title element	if (text !== '') {		this.titleText.innerHTML = text;	}	//returning success	return true;};/** * Sets the status text of the window.  * * @param mesage [string] - text to be shown. * @param mode [string] - currently mode forces to do some additional action when seting the text. *                        For example, "temp" means to store the previous value. */Zapatec.Window.prototype.setStatus = function(message, mode) {	if (!this.fireOnState("ready", function() {this.setStatus(message, mode);})) {return;}	//to be able to use different mods of setting status text we use mode var	if (this.config.showStatus && Zapatec.isHtmlElement(this.statusText)) {		switch (mode) {			//if mode "temp" current value is saved and overwritten by new one			case "temp" : {				this.prevStText = this.statusText.innerHTML;				break;			}						//in case of "restore" we just restore old value saved before			case "restore" : {				message = this.prevStText || message;				delete this.prevStText;				break;			}					}		//putting message into the status element		this.statusText.innerHTML = message;	}	//returning success	return true;}/*  * Set the content of a window. * @param type [string] the HTML data to set the content to. */Zapatec.Window.prototype.setContent = function(text) {	if (!this.fireOnState("shown", function() {this.setContent(text);})) return;	//setting content	this.content.setPaneContent(text, "html/text");	//updating state object	this.state.contentType = "html/text";	this.state.content = text;}/*  * Set the content of a window from HTML element(DIV). * @param div [string]or [object] the HTML data to set the content to. */Zapatec.Window.prototype.setDivContent = function(div) {	if (!this.fireOnState("shown", function() {this.setDivContent(div);})) return;	//setting content	this.content.setPaneContent(div, "html");	//updating state object	this.state.contentType = "html";	if (typeof div == "string") {		this.state.content = div;	} else {		this.state.content = null;	}}/*  * Set the content of a window from url. * @param div [string]or [object] the HTML data to set the content to. */Zapatec.Window.prototype.setContentUrl = function(url) {	if (!this.fireOnState("shown", function() {this.setContentUrl(url);})) return;	//setting content	this.content.setPaneContent(url, "html/url");	//updating state object	this.state.contentType = "html/url";	this.state.content = url;}/** * Activates the window. */Zapatec.Window.prototype.activate = function() {	if (!this.fireOnState("shown", function() {this.activate();})) {return;}	//if it is already active then do nothing	if (this.face.className.indexOf("zpWinFront") != -1) {		return true;	}	Zapatec.Window.activating = this;	//set the current window	if (Zapatec.Window.currentWindow) {		Zapatec.Window.currentWindow.deactivate();	}	Zapatec.Window.currentWindow = this;	Zapatec.Utils.removeClass(this.face, 'zpWinBack');	Zapatec.Utils.addClass(this.face, 'zpWinFront');	if (this.WCH) this.WCH.style.zIndex = Zapatec.Window.maxNumber++;	if (this.modal) this.modal.container.style.zIndex = Zapatec.Window.maxNumber++;	this.getContainer().style.zIndex = Zapatec.Window.maxNumber++;	//if it is not the first one and it is not the same one as before		this.fireEvent("onRaise", this);	Zapatec.Window.activating = null;};/** * Deactivates the window. */Zapatec.Window.prototype.deactivate = function() {	if (!this.fireOnState("shown", function() {this.deactivate();})) {return;}	//if window is already unactive - do nothing	if (this.face.className.indexOf("zpWinBack") != -1) {		return true;	}	var prevWin = Zapatec.Window.currentWindow;	Zapatec.Utils.removeClass(this.face, 'zpWinFront');	Zapatec.Utils.addClass(this.face, 'zpWinBack');	Zapatec.Window.activateFreeWindow(this);	Zapatec.Window.lastActive = this;};/** * If this window can be activated. * @return {boolean or string} true if can be, * false if can not, "min" if minimized. */Zapatec.Window.prototype.canActivate = function() {	if (!this.stateReached("ready")) {		return false;	}	if (this.state.state == "min") {		return "min";	}	return true;};

⌨️ 快捷键说明

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