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

📄 desktop.js

📁 嵌入式无线路由系统openwrt的web配置工具
💻 JS
字号:
/*Script: Desktop.js	Creates a desktop. Enables window maximize.Copyright:	Copyright (c) 2007-2008 Greg Houston, <http://greghoustondesign.com/>.License:	MIT-style license.Requires:	Core.js, Window.js*/MochaUI.Desktop = new Class({	Extends: MochaUI.Window,	Implements: [Events, Options],	options: {		// Naming options:		// If you change the IDs of the Mocha Desktop containers in your HTML, you need to change them here as well.		desktop:                'desktop',		desktopHeader:          'desktopHeader',		desktopNavBar:          'desktopNavbar',		pageWrapper:            'pageWrapper',		page:                   'page'  },	initialize: function(options){		this.setOptions(options);		this.desktop                = $(this.options.desktop);		this.desktopHeader          = $(this.options.desktopHeader);		this.desktopNavBar          = $(this.options.desktopNavBar);		this.pageWrapper            = $(this.options.pageWrapper);		this.page                   = $(this.options.page);		this.setDesktopSize();    if (Browser.Engine.trident4 && this.desktopNavBar){			this.desktopNavBar.getElements('li').each(function(element) {				element.addEvent('mouseenter', function(){					this.addClass('ieHover');				});				element.addEvent('mouseleave', function(){					this.removeClass('ieHover');				});			});		};		// Resize desktop, page wrapper, modal overlay, and maximized windows when browser window is resized		window.addEvent('resize', this.onBrowserResize.bind(this));	},	onBrowserResize: function(){		this.setDesktopSize();		// Resize maximized windows to fit new browser window size		setTimeout( function(){			MochaUI.Windows.instances.each(function(instance){				if (instance.isMaximized) {					// Hide iframe while resize for better performance					if ( instance.iframeEl ) {						instance.iframeEl.setStyle('visibility', 'hidden');					}					var coordinates = document.getCoordinates();					var borderHeight = instance.contentBorderEl.getStyle('border-top').toInt() + instance.contentBorderEl.getStyle('border-bottom').toInt();					var toolbarHeight = instance.toolbarWrapperEl ? instance.toolbarWrapperEl.getStyle('height').toInt() + instance.toolbarWrapperEl.getStyle('border-top').toInt() : 0;					instance.contentWrapperEl.setStyles({						'height': coordinates.height - instance.options.headerHeight - instance.options.footerHeight - borderHeight - toolbarHeight,						'width': coordinates.width					});					instance.drawWindow($(instance.options.id));					if ( instance.iframeEl ) {						instance.iframeEl.setStyles({							'height': instance.contentWrapperEl.getStyle('height')						});						instance.iframeEl.setStyle('visibility', 'visible');					}				}			}.bind(this));		}.bind(this), 100);	},	setDesktopSize: function(){		var windowDimensions = window.getCoordinates();		// var dock = $(MochaUI.options.dock);		var dockWrapper = $(MochaUI.options.dockWrapper);		// Setting the desktop height may only be needed by IE7		if (this.desktop){			this.desktop.setStyle('height', windowDimensions.height);		}		// Set pageWrapper height so the dock doesn't cover the pageWrapper scrollbars.		if (this.pageWrapper && this.desktopHeader) {			var dockOffset = MochaUI.dockVisible ? dockWrapper.offsetHeight : 0;			var pageWrapperHeight = windowDimensions.height - this.desktopHeader.offsetHeight - dockOffset;			if ( pageWrapperHeight < 0 ) {				pageWrapperHeight = 0;			}			this.pageWrapper.setStyle('height', pageWrapperHeight);		}	},	/*	Function: maximizeWindow		Maximize a window.	Syntax:		(start code)		MochaUI.Desktop.maximizeWindow(windowEl);		(end)	*/	maximizeWindow: function(windowEl) {		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);		var windowDrag = currentInstance.windowDrag;		// If window no longer exists or is maximized, stop		if (windowEl != $(windowEl) || currentInstance.isMaximized ) return;		if (currentInstance.isCollapsed){			MochaUI.collapseToggle(windowEl);		}		currentInstance.isMaximized = true;		// If window is restricted to a container, it should not be draggable when maximized.		if (currentInstance.options.restrict){			windowDrag.detach();			currentInstance.titleBarEl.setStyle('cursor', 'default');		}		// If the window has a container that is not the desktop		// temporarily move the window to the desktop while it is minimized.		if (currentInstance.options.container != this.desktop){			this.desktop.grab(windowEl);			if (this.options.restrict){			windowDrag.container = this.desktop;			}		}		// Save original position		currentInstance.oldTop = windowEl.getStyle('top');		currentInstance.oldLeft = windowEl.getStyle('left');		var contentWrapperEl = currentInstance.contentWrapperEl;		// Save original dimensions		contentWrapperEl.oldWidth = contentWrapperEl.getStyle('width');		contentWrapperEl.oldHeight = contentWrapperEl.getStyle('height');		// Hide iframe		// Iframe should be hidden when minimizing, maximizing, and moving for performance and Flash issues		if ( currentInstance.iframe ) {			currentInstance.iframeEl.setStyle('visibility', 'hidden');		}		var windowDimensions = document.getCoordinates();		var options = currentInstance.options;		var shadowBlur = options.shadowBlur;		var shadowOffset = options.shadowOffset;		windowEl.setStyles({			'top': shadowOffset.y - shadowBlur,			'left': shadowOffset.x - shadowBlur		});		currentInstance.contentWrapperEl.setStyles({			'height': windowDimensions.height - options.headerHeight - options.footerHeight,			'width':  windowDimensions.width		});		currentInstance.drawWindow(windowEl);		// Show iframe		if ( currentInstance.iframe ) {			currentInstance.iframeEl.setStyle('visibility', 'visible');		}		currentInstance.fireEvent('onMaximize', windowEl);		currentInstance.maximizeButtonEl.setProperty('title', 'Restore');		MochaUI.focusWindow(windowEl);	},	/*	Function: restoreWindow		Restore a maximized window.	Syntax:		(start code)		MochaUI.Desktop.restoreWindow(windowEl);		(end)	*/	restoreWindow: function(windowEl) {		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);		// Window exists and is maximized ?		if (windowEl != $(windowEl) || !currentInstance.isMaximized) return;		var options = currentInstance.options;		currentInstance.isMaximized = false;		if (options.restrict){			currentInstance.windowDrag.attach();			currentInstance.titleBarEl.setStyle('cursor', 'move');		}		// Hide iframe		// Iframe should be hidden when minimizing, maximizing, and moving for performance and Flash issues		if ( currentInstance.iframe ) {			currentInstance.iframeEl.setStyle('visibility', 'hidden');		}		var contentWrapperEl = currentInstance.contentWrapperEl;		contentWrapperEl.setStyles({			'width':  contentWrapperEl.oldWidth,			'height': contentWrapperEl.oldHeight		});		currentInstance.drawWindow(windowEl);		windowEl.setStyles({			'top': currentInstance.oldTop,			'left': currentInstance.oldLeft		});		if (currentInstance.container != this.desktop){			$(options.container).grab(windowEl);			if (options.restrict){				currentInstance.windowDrag.container = $(options.container);			}		}		currentInstance.fireEvent('onRestore', windowEl);		currentInstance.maximizeButtonEl.setProperty('title', 'Maximize');	}});

⌨️ 快捷键说明

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