📄 lite-window.js
字号:
this.titleText.innerHTML = text; } return true;}/** * Updates the window "WCH" (windowed controls hider). A WCH is an * "invention" (read: "miserable hack") that works around one of the most * common and old bug in Internet Explorer: the SELECT boxes or IFRAMES show on * top of any other HTML element. This function makes sure that the WCH covers * correctly the window element and another element if passed. */Zapatec.Window.prototype.updateWCH = function() { if (this.WCH && this.WCH.style.bottom != "") { this.WCH.style.bottom = ""; } Zapatec.Utils.setupWCH(this.WCH, this.config.left, this.config.top, this.config.width, this.config.height + this.config.heightDiff - 2); return true;}/** * Sets the X coordinate of the window. Needed to synchronize some variables in * one place. Also updates the WCH for IE. * * @param left [integer] - X coordinate. */Zapatec.Window.prototype.setLeft = function(left) { if (!this.winDiv) { return false; } (left < 0) && (left = 0); this.winDiv.style.left = (this.config.left = left) + "px"; this.updateWCH(); return true;}/** * Sets the Y coordinate of the window. Needed to synchronize some variables in * one place. Also updates the WCH for IE. * * @param top [integer] - Y coordinate. */Zapatec.Window.prototype.setTop = function(top) { if (!this.winDiv) { return false; } (top < 0) && (top = 0); this.winDiv.style.top = (this.config.top = top) + "px"; this.updateWCH(); return true;}/** * Sets the width of the window. Needed to synchronize some variables in * one place. Also updates the WCH for IE. * * @param width [integer] - width of the window. */Zapatec.Window.prototype.setWidth = function(width) { if (!this.winDiv) { return false; } var diff = this.config.width - width; if (Zapatec.is_gecko) { } this.winDiv.style.width = (this.config.width = width) + "px"; if (this.titleText) this.titleText.style.width = (this.config.titleWidth -= diff) + "px"; if (this.contentArea) this.contentArea.style.width = (this.config.contentWidth -= diff) + "px"; this.updateWCH(); return true;}/** * Sets the height of the window. Needed to synchronize some variables in * one place. Also updates the WCH for IE. * * @param height [integer] - height of the window. */Zapatec.Window.prototype.setHeight = function(height) { if (!this.winDiv) { return false; } this.contentArea.style.height = (this.config.height = height) + "px"; this.updateWCH(); return true;}/** * Sets the position of the window. * * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. */Zapatec.Window.prototype.setPos = function(left, top) { if (!this.winDiv) { return false; } this.setLeft(left); this.setTop(top); return true;}/** * Sets the sizes of the window. * * @param width [integer] - width of the window. * @param height [integer] - height of the window. */Zapatec.Window.prototype.setSize = function(width, height) { if (!this.winDiv) { return false; } this.setWidth(width); this.setHeight(height); return true;}/** * Sets the sizes and position of the window. * * @param left [integer] - X coordinate. * @param top [integer] - Y coordinate. * @param width [integer] - width of the window. * @param height [integer] - height of the window. */Zapatec.Window.prototype.setPosAndSize = function(left, top, width, height) { if (!this.winDiv) { return false; } this.setPos(left, top); this.setSize(width, height); return true;}/** * Raise this window so that it's above all other. * Bring it to the front. */ Zapatec.Window.prototype.raise = function() { if (!this.winDiv) { return false; } Zapatec.Window.maxNumber++; //increment so it's more than all the others this.winDiv.style.zIndex = Zapatec.Window.maxNumber; this.setCurrent(this); if (this.config.onRaise) { this.config.onRaise(this); } return true;}/** * Shows the window. */ Zapatec.Window.prototype.show = function() { if (!this.winDiv) { return false; } this.winDiv.style.display = "block"; if (this.config.modal == true && this.modalLayer) { this.modalLayer.style.display = "block"; } this.updateWCH(); this.config.visible = true; if (this.config.onHide) { this.config.onHide(this); } return true;}/** * Hides the window. */ Zapatec.Window.prototype.hide = function() { if (!this.winDiv) { return false; } this.winDiv.style.display = "none"; if (this.config.modal == true && this.modalLayer) { this.modalLayer.style.display = "none"; } Zapatec.Utils.hideWCH(this.WCH); this.config.visible = false; if (this.config.onHide) { this.config.onHide(this); } return true;}/** * Closes the window. Currently does not destroys the window object, just the HTML part of it */ Zapatec.Window.prototype.close = function() { if (!this.winDiv) { return false; } // Return content back to the place it was taken from if (this.config.divContent && this.contentArea) { var objContent = null; if (typeof this.config.divContent == 'string') { objContent = document.getElementById(this.config.divContent); } else if (typeof this.config.divContent == 'object') { objContent = this.config.divContent; } if (objContent) { var objChild = this.contentArea.firstChild; while (objChild) { objContent.appendChild(objChild); objChild = this.contentArea.firstChild; } } } // Destroy window Zapatec.Utils.destroy(this.winDiv); Zapatec.Utils.destroy(this.WCH); if (this.config.modal == true && this.modalLayer) { Zapatec.Utils.destroy(this.modalLayer); } delete this.winDiv; for (i in Zapatec.Window.winArray) { if (Zapatec.Window.winArray[i] == this) { Zapatec.Window.winArray[i] = null; } } if (Zapatec.Window.lastActive) { Zapatec.Window.lastActive.setCurrent(); } if (this.config.onClose) { this.config.onClose(this); } return true;}/** * Destroy the window. */ Zapatec.Window.prototype.destroy = function() { this.close();}/** * This function displays the calendar near a given "anchor" element, according * to some rules passed in \em opts. The \em opts argument is a string * containing one or 2 letters. The first letter decides the vertical * alignment, and the second letter decides the horizontal alignment relative * to the anchor element. Following we will describe these options; in parens * we will use simple descriptions like "top to bottom" which means that the * top margin of the calendar is aligned with the bottom margin of the object. * * \b Vertical align: * * - T -- the calendar is completely above the element (bottom to top) * - t -- the calendar is above the element but might overlap it (bottom to bottom) * - C -- the calendar is vertically centered to the element * - b -- the calendar is below the element but might overlap it (top to top) * - B -- the calendar is completely below the element (top to bottom) * * \b Horizontal align (defaults to 'l' if no letter passed): * * - L -- the calendar is completely to the left of the element (right to left) * - l -- the calendar is to the left of the element but might overlap it (right to right) * - C -- the calendar is horizontally centered to the element * - r -- the calendar is to the right of the element but might overlap it (left to left) * - R -- the calendar is completely to the right of the element (left to right) * * @param el [HTMLElement] the anchor element * @param opts [string, optional] the align options, as described above. Defaults to "Bl" if nothing passed. */Zapatec.Window.prototype.showAtElement = function (el, opts) { if (!this.winDiv) { return false; } var self = this; var p = Zapatec.Utils.getAbsolutePos(el); if (!opts || typeof opts != "string") { this.showAt(p.x, p.y + el.offsetHeight); return true; } this.winDiv.style.display = "block"; var w = self.winDiv.offsetWidth; var h = self.winDiv.offsetHeight; self.winDiv.style.display = "none"; var valign = opts.substr(0, 1); var halign = "l"; if (opts.length > 1) { halign = opts.substr(1, 1); } // vertical alignment switch (valign) { case "T": p.y -= h; break; case "B": p.y += el.offsetHeight; break; case "C": p.y += (el.offsetHeight - h) / 2; break; case "t": p.y += el.offsetHeight - h; break; case "b": break; // already there } // horizontal alignment switch (halign) { case "L": p.x -= w; break; case "R": p.x += el.offsetWidth; break; case "C": p.x += (el.offsetWidth - w) / 2; break; case "l": p.x += el.offsetWidth - w; break; case "r": break; // already there } p.width = w; p.height = h; Zapatec.Utils.fixBoxPosition(p); self.showAt(p.x, p.y); return true;}/** * Shows the calendar at a given absolute position (beware that, depending on * the calendar element style -- position property -- this might be relative to * the parent's containing rectangle). * * @param x [int] the X position * @param y [int] the Y position */Zapatec.Window.prototype.showAt = function (x, y) { if (!this.winDiv) { return false; } this.setPos(x, y); this.show(); return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -