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

📄 window.js

📁 《SVG开发实践》源代码
💻 JS
📖 第 1 页 / 共 3 页
字号:
    		this.windowTitlebarGroup.setAttributeNS(null,"display","inherit");    		if (this.minimized) {    			this.shadowTitleRect.setAttributeNS(null,"display","none");    		}    		else {    			this.shadowRect.setAttributeNS(null,"display","none");    			this.windowMainGroup.setAttributeNS(null,"display","inherit");    		}    	}    	else {    		if (this.titleBarVisible) {				this.titlebar.setAttributeNS(null,"cursor","pointer");			}    		if (this.decorationGroup) {				this.decorationGroup.setAttributeNS(null,"cursor","pointer");			}    	}		this.timer.setTimeout("fireFunction",this.timerMs,"moveEnd");    	this.panStatus = 0;}//minimize a windowWindow.prototype.minimize = function(fireFunction) {	this.windowMainGroup.setAttributeNS(null,"display","none");	if (this.decorationGroupMinimized) {		this.decorationGroupMinimized.setAttributeNS(null,"display","none");	}	this.minimized = true;	if (fireFunction) {		this.timer.setTimeout("fireFunction",this.timerMs,"minimized");	}}//maximize a windowWindow.prototype.maximize = function(fireFunction) {	this.windowMainGroup.setAttributeNS(null,"display","inherit");	if (this.decorationGroupMinimized) {		this.decorationGroupMinimized.setAttributeNS(null,"display","inherit");	}	if ((this.transY + this.height) > (this.constrYmax)) {		this.transY = this.constrYmax - this.height;		this.windowGroup.setAttributeNS(null,"transform","translate("+this.transX+","+this.transY+")");	}	this.minimized = false;	if (fireFunction) {		this.timer.setTimeout("fireFunction",this.timerMs,"maximized");	}}//open a closed windowWindow.prototype.close = function(fireFunction) {	this.windowGroup.setAttributeNS(null,"display","none");	this.closed = true;	if (fireFunction) {		this.timer.setTimeout("fireFunction",this.timerMs,"closed");	}}//close window, after closing the window is still in its previous state and can be re-openedWindow.prototype.open = function(fireFunction) {	if (!this.removed) {		this.windowGroup.setAttributeNS(null,"display","inherit");		this.closed = false;		if (fireFunction) {			this.timer.setTimeout("fireFunction",this.timerMs,"opened");		}	}	else {		alert("window " + this.id + " is already removed");	}}//resize window and reposition it into constrained coordsWindow.prototype.resize = function(width,height,fireFunction) {	this.width = width;	this.height = height;	//adopt shadow rect	this.shadowRect.setAttributeNS(null,"width",this.width);	this.shadowRect.setAttributeNS(null,"height",this.height);	this.shadowTitleRect.setAttributeNS(null,"width",this.width);	//adopt background rect	this.backgroundRect.setAttributeNS(null,"width",this.width);	this.backgroundRect.setAttributeNS(null,"height",this.height);	//adopt titlebar	if (this.titleBarVisible) {		this.titlebar.setAttributeNS(null,"width",this.width);	}	var buttonPosition = this.width - this.margin - this.titlebarHeight * 0.5;	if (this.closeButton) {		this.closeButtonInstance.setAttributeNS(null,"x",buttonPosition);		buttonPosition -=  this.titlebarHeight;	}	if (this.maximizeButton) {		this.maximizeButtonInstance.setAttributeNS(null,"x",buttonPosition);		buttonPosition -=  this.titlebarHeight;	}	if (this.minimizeButton) {		this.minimizeButtonInstance.setAttributeNS(null,"x",buttonPosition);	}	if (this.statusBarVisible) {		this.statusbar.setAttributeNS(null,"y",(this.height - this.statusbarHeight));		this.statusbar.setAttributeNS(null,"width",this.width);			this.statusTextElement.setAttributeNS(null,"y",this.height - (this.statusbarHeight - this.statustextStyles["font-size"]));	}	//check constraints	if (this.transX < this.constrXmin) {		this.transX = this.constrXmin;	}	if (this.transY < this.constrYmin) {		this.transY = this.constrYmin;	}	if ((this.transX + this.width) > (this.constrXmax)) {		this.transX = this.constrXmax - this.width;	}	if (this.minimized) {		if ((this.transY + this.titlebarHeight) > (this.constrYmax)) {			this.transY = this.constrYmax - this.titlebarHeight;		}	}	else {		if ((this.transY + this.height) > (this.constrYmax)) {			this.transY = this.constrYmax - this.height;		}	}	this.windowGroup.setAttributeNS(null,"transform","translate("+this.transX+","+this.transY+")");	if (fireFunction) {		this.fireFunction("resized");	}}//remove windowWindow.prototype.remove = function(fireFunction) {	if (!this.removed) {		this.parentGroup.removeChild(this.windowGroup);		this.removed = true;		if (fireFunction) {			this.timer.setTimeout("fireFunction",this.timerMs,"removed");		}	}}//change content of statusBarWindow.prototype.setStatusText = function(statusText) {	if (this.statusBarVisible) {        this.statusText = statusText;        if (this.statusText.length > 0) {            this.statusTextNode.nodeValue = this.statusText;        }        else {            this.statusTextNode.nodeValue = " ";        }	}	else {		alert("there is no statusbar available");	}}//change content of statusBarWindow.prototype.setTitleText = function(titleText) {	this.titleText = titleText;	if (titleText.length > 0) {		this.titleTextNode.nodeValue = titleText;	}	else {		this.titleTextNode.nodeValue = " ";	}}//move a window to a certain position (upper left corner)Window.prototype.moveTo = function(coordx,coordy,fireFunction) {	this.transX = coordx;	this.transY = coordy;	//check constraints	if (this.transX < this.constrXmin) {		this.transX = this.constrXmin;	}	if (this.transY < this.constrYmin) {		this.transY = this.constrYmin;	}	if ((this.transX + this.width) > (this.constrXmax)) {		this.transX = this.constrXmax - this.width;	}	if (this.minimized) {		if ((this.transY + this.titlebarHeight) > (this.constrYmax)) {			this.transY = this.constrYmax - this.titlebarHeight;		}	}	else {		if ((this.transY + this.height) > (this.constrYmax)) {			this.transY = this.constrYmax - this.height;		}	}	this.windowGroup.setAttributeNS(null,"transform","translate("+this.transX+","+this.transY+")");	if (fireFunction) {		this.timer.setTimeout("fireFunction",this.timerMs,"movedTo");	}}//append new content to the window main groupWindow.prototype.appendContent = function(node,inheritDisplay) {	if (typeof(node) == "string") {		node = document.getElementById(node);	}	if (inheritDisplay) {		node.setAttributeNS(null,"display","inherit");	}	this.windowContentGroup.appendChild(node);}//remove new content from the window main groupWindow.prototype.removeContent = function(node) {	if (typeof(node) == "string") {		node = document.getElementById(node);	}	this.windowContentGroup.removeChild(node);}//remove new content from the window main groupWindow.prototype.insertContentBefore = function(node,referenceNode,inheritDisplay) {	if (typeof(node) == "string") {		node = document.getElementById(node);	}	if (typeof(referenceNode) == "string") {		referenceNode = document.getElementById(referenceNode);	}	if (inheritDisplay) {		node.setAttributeNS(null,"display","inherit");	}	this.windowContentGroup.insertBefore(node,referenceNode);}//hide content of WindowWindow.prototype.hideContents = function() {	this.windowContentGroup.setAttributeNS(null,"display","none");}//show content of WindowWindow.prototype.showContents = function() {	this.windowContentGroup.setAttributeNS(null,"display","inherit");}//add window decorationWindow.prototype.addWindowDecoration = function(node,mayTriggerMoving,topOrBottom) {	if (typeof(node) == "string") {		node = document.getElementById(node);	}	if (this.decorationGroup) {		var parent = this.decorationGroup.parentNode;		parent.removeChild(this.decorationGroup);	}	if (topOrBottom == "bottom") {		this.decorationGroup = this.windowGroup.insertBefore(node,this.windowGroup.firstChild);	}		else if (topOrBottom == "top") {		this.decorationGroup = this.windowTitlebarGroup.insertBefore(node,this.windowTitlebarGroup.firstChild);	}	else {		alert("Error in window with id '"+this.id+"': you have to specify 'top' or 'bottom' for the variable 'topOrBottom'.");	}	if (mayTriggerMoving) {		this.decorationGroup.setAttributeNS(null,"id","decoGroup"+this.id);		this.decorationGroup.setAttributeNS(null,"cursor","pointer");		this.decorationGroup.addEventListener("click",this,false);		this.decorationGroup.addEventListener("mousedown",this,false);	}	//see if there is a sub group/element that should be hidden when minimized	try {		this.decorationGroupMinimized = document.getElementById("decoGroupMinimized"+this.id);		if (this.minimized) {			this.decorationGroupMinimized.setAttributeNS(null,"display","none");		}	}	catch(er) {		this.decorationGroupMinimized = null;	}}

⌨️ 快捷键说明

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