📄 window-core.js
字号:
// $Id: window-core.js 7641 2007-08-02 06:42:37Z ricardoe $/** * * Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. *//** * The Window object constructor. Call it, for example, like this: * * \code * var win = new Zapatec.Window({ * showResize : false * }); * \endcode * * The above creates a new Window object. The Window isn't displayed * instantly; using the "win" variable, the programmer can now set certain * configuration variables, hook his own event handlers and then display the * window using Zapatec.Window.create() and Zapatec.Window.show(). * * @param config [object] - all parameters are passed as the properties of this object. * * Constructor recognizes the following properties of the config object * \code * prop. name | description * ------------------------------------------------------------------------------------------------- * showMinButton | whether to show minimize button (default true). * showMaxButton | whether to show maximize button (default true). * showCloseButton | whether to show close button (default true). * showStatus | whether to show status bar text (default true). * showTitle | whether to show the title bar text (default true) * canResize | whether to show resize icon (default true). * raiseOnlyOnTitle| whether to raize when clicking on title or on the whole body of the created window (default false). * canDrag | whether you can drag the window (default true). * modal | if true modal window will be created (default false). * onClose | custom handler, will be called when window is closed. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onRestore | custom handler, will be called when restore button is clicked. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onMinimize | custom handler, will be called when min button is clicked. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onMaximize | custom handler, will be called when max button is clicked. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onShow | custom handler, will be called when show method is called. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onHide | custom handler, will be called when hide method is called. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onResize | custom handler, will be called when window is resized. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onRaise | custom handler, will be called when window is raized. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * onContentLoad | custom handler, will be called when content is loaded. Depricated use eventListeners * | option instead. See Zapatec.Widget documentation. * minWidth | minimal width of the window. Depricated use "limit" option instead. * minHeight | minimal height of the window. Depricated use "limit" option instead. * iframeContent | type of the content element. * hideOnClose | whether we destroy the window or just close * dragMin | is minimized draggable or not (default false) * bottomMinimize | is the window minimized to the bottom or just stay at its position * lang | set the localization for all the messages * * \endcode */Zapatec.Window = function (config) { //the reference to the root HTML element of the window this.container = null; //reference to the element which holds the title bar this.titleArea = null; //reference to the element which holds the title text this.titleText = null; //reference to the Zapatec.Button object representing minimize button this.minButton = null; //reference to the Zapatec.Button object representing maximize button this.maxButton = null; //reference to the Zapatec.Button object representing close button this.closeButton = null; //reference to the Zapatec.Pane object representing content of the window this.content = null; //reference to the element holding status area element this.statusText = null; //reference to the Modal object of this window this.modal = null; //flag which determines if the window is resizing this.resizing = false; //type of the widget - window in our case :) this.widgetType = "window"; //widget privillage modes this.widgetModes = {}; //high priority events this.highPriorityEvents = []; //delayed events this.delayedEvents = []; //this variable points the state of the widget in general. //The widget has a set of states 4 of them should go one after another ('created' -> 'inited' -> 'loaded' -> 'ready') //and point to the stage of creation of widget. Last one should be 'ready', //which means a fully ready for work widget. Each of the methods can require //the state to be not lower than it needs. So we will also define a method //to work with this variable - stateReached(state) - to get true if state reached or passed. this.widgetState = "created"; //array of priorities for states, in other words its the number which points the order // of states to be passed. this.priorities = { //the number of states supported count : 7, //states priorities destroyed : 0, created : 1, inited : 2, loaded : 3, ready : 4, hidden : 5, shown : 6 }; this.setDefaultState(); //for backward compability if (!config.eventListeners) { config.eventListeners = {}; } if (config.onClose) {config.eventListeners.onClose = config.onClose;} if (config.onRestore) {config.eventListeners.onRestore = config.onRestore;} if (config.onMaximize) {config.eventListeners.onMaximize = config.onMaximize;} if (config.onMinimize) {config.eventListeners.onMinimize = config.onMinimize;} if (config.onShow) {config.eventListeners.onShow = config.onShow;} if (config.onHide) {config.eventListeners.onHide = config.onHide;} if (config.onResize) {config.eventListeners.onResize = config.onResize;} if (config.onRaise) {config.eventListeners.onRaise = config.onRaise;} if (config.onContentLoad) {config.eventListeners.onContentLoad = config.onContentLoad;} config = Zapatec.Hash.remove(config, "onClose", "onRestore", "onMaximize", "onMinimize", "onShow", "onHide", "onResize", "onRaise", "onContentLoad" ); //calling super constructor Zapatec.Window.SUPERconstructor.call(this, config); //creating SRProp object for manipulating with our object this.restorer = new Zapatec.SRProp(this);};Zapatec.Window.id = "Zapatec.Window";//Inheriting Zapatec.Widget classZapatec.inherit(Zapatec.Window, Zapatec.Widget);//Implementing Zapatec.CommandEvent interfaceZapatec.implement(Zapatec.Window, "Zapatec.CommandEvent");//Implementing Zapatec.Movable interfaceZapatec.implement(Zapatec.Window, "Zapatec.Movable");//Implementing Zapatec.Draggable interfaceZapatec.implement(Zapatec.Window, "Zapatec.Draggable");//Implementing Zapatec.Sizable interfaceZapatec.implement(Zapatec.Window, "Zapatec.Sizable");//Implementing Zapatec.Resizable interfaceZapatec.implement(Zapatec.Window, "Zapatec.Resizable");/** * This function inits the config object and loads HTML structure * of the window, not to waste time :) * @param config [object] - object which holds the configuration, same as for constructor */Zapatec.Window.prototype.init = function(config) { // processing Widget functionality Zapatec.Window.SUPERclass.init.call(this, config); //action to be fired when privileged execution is on this.addEventListener("privileged_execution_on", function() { //array of high priority events this.highPriorityEvents = []; }); //action to be fired when privileged execution is off this.addEventListener("privileged_execution_off", function() { //putting high priority events into the begining of array for (var ii = this.highPriorityEvents.length - 1; ii >= 0; --ii) { //if there is listener and it was not executed moving it to events array if (this.highPriorityEvents[ii] && !this.highPriorityEvents[ii].executed) { this.addEventListener(this.highPriorityEvents[ii].state, this.highPriorityEvents[ii].listener, true); } } //clearing array this.highPriorityEvents = []; }); //action to be fired when delayed execution is on this.addEventListener("delayed_execution_on", function() { //array of delayed events this.delayedEvents = []; }); //action to be fired when delayed execution is off this.addEventListener("delayed_execution_off", function() { //trying to execute or schedule delayed events for (var ii = this.delayedEvents.length - 1; ii >= 0; --ii) { //trying to schedule delayed event if (!this.fireOnState(this.delayedEvents[ii].state, this.delayedEvents[ii].listener)) { continue; } //otherwise executing it this.delayedEvents[ii].listener(); } }); //listener to activate Window on drag start //also sets the status message for dragging this.addEventListener("beforeDragInit", function() { this.activate(); if (this.getConfiguration().method == "cut") { this.setStatus(this.getMessage('windowOnBeforeDragStatusMessage'), 'temp'); } }); //tries to remember dummy position var pos = null; this.addEventListener("beforeDragEnd", function() { if (this.getConfiguration().method != "cut") { pos = this.getPosition(); } }); //resets status on drag end this.addEventListener("onDragEnd", function() { if (this.getConfiguration().method == "cut") { this.setStatus('', 'restore'); } else { this.setPosition(pos.x, pos.y); } }); //listener to activate Window on resize start //also sets the status message for resizing this.addEventListener("onResizeInit", function() { this.activate(); this.setStatus(this.getMessage('windowOnResizeStatusMessage'), 'temp'); }); //resets status on resize end this.addEventListener("onResizeEnd", function() { this.setStatus('', 'restore'); }); //changing state to "inited" this.changeState("inited"); //loading template for Window this.loadData({object : this, action : "loadTemplate"});};/** * Sets the default configuration of the object and * inits it with user defined values. * @param config {object} configuration parameters. */Zapatec.Window.prototype.configure = function(config) { //wether title is visible this.defineConfigOption("showTitle", true); //wethter min button is visible this.defineConfigOption("showMinButton", true); //wethter max button is visible this.defineConfigOption("showMaxButton", true); //wethter close button is visible this.defineConfigOption("showCloseButton", true); //wethter status bar is visible this.defineConfigOption("showStatus", true);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -