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

📄 dock.js.svn-base

📁 嵌入式无线路由系统openwrt的web配置工具
💻 SVN-BASE
字号:
/*

Script: Dock.js
	Implements the dock/taskbar. Enables window minimize.

Copyright:
	Copyright (c) 2007-2008 Greg Houston, <http://greghoustondesign.com/>.

License:
	MIT-style license.

Requires:
	Core.js, Window.js, Desktop.js

Todo:
	- Make it so the dock requires no initial html markup.

*/

MochaUI.options.extend({
  // Naming options:
  // If you change the IDs of the Mocha Desktop containers in your HTML, you need to change them here as well.
  dockWrapper: 'dockWrapper',
  dock:        'dock'
});

MochaUI.dockVisible = true;

MochaUI.extend({
	/*

	Function: minimizeAll
		Minimize all windows.

	*/
	minimizeAll: function() {
		$$('div.mocha').each(function(windowEl){
		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);
			if (!currentInstance.isMinimized){
				MochaUI.Dock.minimizeWindow(windowEl);
			}
		}.bind(this));
	}
});

MochaUI.Dock = new Class({
	Extends: MochaUI.Window,
	Implements: [Events, Options],

	options: {
		useCanvasTabs:        true,           // Toggle use of canvas tab graphics. NOT YET IMPLEMENTED
		dockTabColor:         [255, 255, 255] // Style options
	},
	initialize: function(options){
		// Stops if MochaUI.Desktop is not implemented
		if (!MochaUI.Desktop) return;
		this.setOptions(options);

		this.dockWrapper = $(MochaUI.options.dockWrapper);
		this.dock        = $(MochaUI.options.dock);

		this.dockWrapper.setStyles({
			'display':  'block',
			'position': 'absolute',
			'top':      null,
			'bottom':   0,
			'left':     0
		});

		this.dockSortables = new Sortables('#dockSort', {
      constrain: true,
      clone: false,
      revert: false
		});

		MochaUI.Desktop.setDesktopSize();
	},
	minimizeWindow: function(windowEl) {
		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);
		if (!currentInstance) return;
		currentInstance.isMinimized = true;

		// 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 titleText = currentInstance.titleEl.innerHTML;

		// Hide window and add to dock
		currentInstance.contentBorderEl.setStyle('visibility', 'hidden');
		currentInstance.footerEl.setStyle('visibility', 'hidden');
		if(currentInstance.toolbarWrapperEl){
			currentInstance.toolbarWrapperEl.setStyle('visibility', 'hidden');
		}
		windowEl.setStyle('visibility', 'hidden');

		 // Fixes a scrollbar issue in Mac FF2
		if (Browser.Platform.mac && Browser.Engine.gecko){
			currentInstance.contentWrapperEl.setStyle('overflow', 'hidden');
		}

		var dockTab = new Element('div', {
			'id': currentInstance.options.id + '_dockTab',
			'class': 'dockTab',
			'title': titleText
		}).inject($('dockClear'), 'before');

		dockTab.addEvent('mousedown', function(e){
			this.timeDown = $time();
		});

		dockTab.addEvent('mouseup', function(e){
			this.timeUp = $time();
			if ((this.timeUp - this.timeDown) < 275){
				MochaUI.Dock.restoreMinimized.delay(25, MochaUI.Dock, windowEl);
			}
		});

		this.dockSortables.addItems(dockTab);

		//Insert canvas
		if (this.options.useCanvasTabs){
			var dockTabCanvas = new Element('canvas', {
				'id': currentInstance.options.id + '_dockTabCanvas',
				'class': 'dockCanvas',
				'width': 120,
				'height': 20
			}).inject(dockTab);

			// Dynamically initialize canvas using excanvas. This is only required by IE
			if (Browser.Engine.trident && MochaUI.ieSupport == 'excanvas') {
				G_vmlCanvasManager.initElement(dockTabCanvas);
			}

			var ctx = $(currentInstance.options.id + '_dockTabCanvas').getContext('2d');
			MochaUI.roundedRect(ctx, 0, 0, 120, 20, 5, this.options.dockTabColor, 1);
		}

		var dockTabText = new Element('div', {
			'id': currentInstance.options.id + '_dockTabText',
			'class': 'dockText'
		}).set('html', titleText.substring(0,18) + (titleText.length > 18 ? '...' : '')).inject($(dockTab));

		MochaUI.Desktop.setDesktopSize();

		// Fixes a scrollbar issue in Mac FF2.
		// Have to use timeout because window gets focused when you click on the minimize button
		setTimeout(windowEl.setStyle.bind(windowEl, ['zIndex', 1]), 100);
		currentInstance.isFocused = false;
		currentInstance.fireEvent('onMinimize', windowEl);
	},
	restoreMinimized: function(windowEl) {

		if (MochaUI.Windows.windowsVisible == false){
			MochaUI.toggleWindowVisibility();
		}

		var currentInstance = MochaUI.Windows.instances.get(windowEl.id);
		currentButton = $(currentInstance.options.id + '_dockTab');

		this.dockSortables.removeItems(currentButton).destroy();
		MochaUI.Desktop.setDesktopSize();

		 // Part of Mac FF2 scrollbar fix
		if (currentInstance.options.scrollbars == true && currentInstance.iframe == false){
			currentInstance.contentWrapperEl.setStyle('overflow', 'auto');
		}

		if (currentInstance.isCollapsed) {
			MochaUI.collapseToggle(windowEl);
		}

		windowEl.setStyle('visibility', 'visible');
		currentInstance.contentBorderEl.setStyle('visibility', 'visible');
		currentInstance.footerEl.setStyle('visibility', 'visible');
		if(currentInstance.toolbarWrapperEl){
			currentInstance.toolbarWrapperEl.setStyle('visibility', 'visible');
		}

		// Show iframe
		if ( currentInstance.iframe ) {
			currentInstance.iframeEl.setStyle('visibility', 'visible');
		}
		currentInstance.isMinimized = false;
		MochaUI.focusWindow(windowEl);
		currentInstance.fireEvent('onRestore', windowEl);
	}
});

⌨️ 快捷键说明

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