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

📄 core.js

📁 嵌入式无线路由系统openwrt的web配置工具
💻 JS
字号:
/*Script: Core.js	MochaUI - A Web Applications User Interface Framework.Copyright:	Copyright (c) 2007-2008 Greg Houston, <http://greghoustondesign.com/>.License:	MIT-style license.Contributors:	- Scott F. Frederick	- Joel Lindau	- OpenRB.comNote:	This documentation is taken directly from the javascript source files. It is built using Natural Docs.*/var MochaUI = new Hash({  options: new Hash(),	Windows: {		instances:      new Hash(),		indexLevel:     1,            // Used for z-Index		windowIDCount:  0,	          // Used for windows without an ID defined by the user		windowsVisible: true          // Ctrl-Alt-Q to toggle window visibility	},	ieSupport:  'excanvas',   // Makes it easier to switch between Excanvas and Moocanvas for testing	collapseToggle: function(windowEl){		var instances = MochaUI.Windows.instances;		var currentInstance = instances.get(windowEl.id);		var handles = currentInstance.windowEl.getElements('.handle');		if (currentInstance.isCollapsed == false) {			currentInstance.isCollapsed = true;			handles.setStyle('display', 'none');			if ( currentInstance.iframe ) {				currentInstance.iframeEl.setStyle('visibility', 'hidden');			}			var styles = {        visibility: 'hidden',				position: 'absolute',				top: -10000,				left: -10000      }			currentInstance.contentBorderEl.setStyles(styles);      currentInstance.footerEl.setStyles(styles);			if(currentInstance.toolbarWrapperEl){				currentInstance.toolbarWrapperEl.setStyles(styles);			}			currentInstance.drawWindowCollapsed(windowEl);		}		else {			currentInstance.isCollapsed = false;			currentInstance.drawWindow(windowEl);			var styles = {				visibility: 'visible',				position: null,				top: null,				left: null      }			currentInstance.contentBorderEl.setStyles(styles);			currentInstance.footerEl.setStyles(styles);			if(currentInstance.toolbarWrapperEl){				currentInstance.toolbarWrapperEl.setStyles(styles);			}			if ( currentInstance.iframe ) {				currentInstance.iframeEl.setStyle('visibility', 'visible');			}			handles.setStyle('display', 'block');		}	},	/*	Function: closeWindow		Closes a window.	Syntax:	(start code)		MochaUI.closeWindow();	(end)	Arguments:		windowEl - the ID of the window to be closed	Returns:		true - the window was closed		false - the window was not closed	*/	closeWindow: function(windowEl){		// Does window exist and is not already in process of closing ?		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);		if (windowEl != $(windowEl) || currentInstance.isClosing) return;		currentInstance.isClosing = true;		currentInstance.fireEvent('onClose', windowEl);		if (currentInstance.options.type == 'modal'){			MochaUI.Modal.hide();		}		windowEl.destroy();		currentInstance.fireEvent('onCloseComplete', currentInstance.options.id);		MochaUI.Windows.instances.erase(currentInstance.options.id); // see how this effects on close complete		delete currentInstance;				if (this.loadingWorkspace == true){			this.windowUnload();		}		if (currentInstance.check) currentInstance.check.destroy();		return true;	},	focusWindow: function(windowEl, fireEvent){		var instances =  MochaUI.Windows.instances;		var currentInstance = instances.get(windowEl.id);		// Only focus when needed		if ( windowEl.getStyle('zIndex') == MochaUI.Windows.indexLevel || !currentInstance || currentInstance.isFocused == true)			return;		MochaUI.Windows.indexLevel++;		windowEl.setStyle('zIndex', MochaUI.Windows.indexLevel);		// Fire onBlur for the window that lost focus.		instances.each(function(instance){			if (instance.isFocused == true){				instance.fireEvent('onBlur', instance.windowEl);			}			instance.isFocused = false;		});		currentInstance.isFocused = true;		if (fireEvent != false){			currentInstance.fireEvent('onFocus', windowEl);		}	},	roundedRect: function(ctx, x, y, width, height, radius, rgb, a){		ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + a + ')';		ctx.beginPath();		ctx.moveTo(x, y + radius);		ctx.lineTo(x, y + height - radius);		ctx.quadraticCurveTo(x, y + height, x + radius, y + height);		ctx.lineTo(x + width - radius, y + height);		ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);		ctx.lineTo(x + width, y + radius);		ctx.quadraticCurveTo(x + width, y, x + width - radius, y);		ctx.lineTo(x + radius, y);		ctx.quadraticCurveTo(x, y, x, y + radius);		ctx.fill();	},	triangle: function(ctx, x, y, width, height, rgb, a){		ctx.beginPath();		ctx.moveTo(x + width, y);		ctx.lineTo(x, y + height);		ctx.lineTo(x + width, y + height);		ctx.closePath();		ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + a + ')';		ctx.fill();	},	circle: function(ctx, x, y, diameter, rgb, a){		ctx.beginPath();		ctx.moveTo(x, y);		ctx.arc(x, y, diameter, 0, Math.PI*2, true);		ctx.fillStyle = 'rgba(' + rgb.join(',') + ',' + a + ')';		ctx.fill();	},	/*	Function: centerWindow		Center a window in it's container. If windowEl is undefined it will center the window that has focus.	*/	centerWindow: function(windowEl){		if (!windowEl){			MochaUI.Windows.instances.each(function(instance){				if (instance.isModal == true) {					windowEl = instance.windowEl;				}			});			// found no focused windows			if (!windowEl) {        return;      }		}		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);		var options = currentInstance.options;		var dimensions = options.container.getCoordinates();		var windowPosTop = (dimensions.height * .5) - ((options.height + currentInstance.headerFooterShadow) * .5);		var windowPosLeft =	(dimensions.width * .5) - (options.width * .5);		windowEl.setStyles({			'top': windowPosTop,			'left': windowPosLeft		});	},	/*	Function: dynamicResize		Use with a timer to resize a window as the window's content size changes, such as with an accordian.	*/	dynamicResize: function(windowEl){		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);		var contentWrapperEl = currentInstance.contentWrapperEl;		var contentEl = currentInstance.contentEl;		contentWrapperEl.setStyle('height', contentEl.offsetHeight);		contentWrapperEl.setStyle('width', contentEl.offsetWidth);		currentInstance.drawWindow(windowEl);	},		eventStop: function(e) {    new Event(e).stop();  },	/*	Function: garbageCleanUp		Empties all windows of their children, and removes and garbages the windows. It is does not trigger onClose() or onCloseComplete(). This is useful to clear memory before the pageUnload.	Syntax:	(start code)		MochaUI.garbageCleanUp();	(end)	*/	garbageCleanUp: function(){		$$('div.mocha').each(function(el){			el.destroy();		}.bind(this));	}});

⌨️ 快捷键说明

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