📄 window.js
字号:
//<addItems : function (items, position) { if (!isc.isAn.Array(items)) items = [items]; if (!this.items) this.items = []; for (var i =0; i < items.length; i++) { // Skip any items we already have if (this.items.contains(items[i])) continue; // add each item to this.items if (position != null) this.items.addAt(items[i], position+i); else this.items.add(items[i]); // if the body hasn't been created yet, ensure any drawn items are clear()'d, and return if (!this._isInitialized) { if (isc.isA.Canvas(items[i]) && items[i].isDrawn()) items[i].clear(); // If the body has been drawn - add the items to it as members/children } else { // Depending on the contentLayout property the body may be a layout or a straight // canvas. Use addMember if it's there, otherwise just addChild. if (this.body.addMember) { this.body.addMember(items[i], position); } else { this.body.addChild(items[i]); } } } return items; },//> @method Window.removeItems([A]) // Removes an array of widgets from the window.// @visibility external// @group windowItems// @param items (array of canvases) an array of widgets to be removed// @return (array) the array of widgets removed//<removeItems : function (items) { if (!isc.isAn.Array(items)) items = [items]; if (this._isInitialized) { if (this.body.removeMembers) this.body.removeMembers(items); else { for (var i=0; i<items.length; i++) { if (items[i].parentElement == this.body) items[i].deparent(); } } } // Remove from this.items this.items.removeList(items); return items;},// Resizing / Layout// ---------------------------------------------------------------------------------------// override to handle autoSize:true: make the Window match the body's sizelayoutChildren : function (a,b,c,d) { if (this.body == null) return; if (this._disableAutoSize) { this._disableAutoSize = null; this.disableAutoSize(); } if (this.autoSize) this._matchBodyWidth(); this.invokeSuper(isc.Window, "layoutChildren", a,b,c,d); var edge = this.edgesAsChild ? this._edgedCanvas : null; if (edge) edge.setHeight(this.getVisibleHeight(true));},_matchBodyWidth : function () { if (this.minimized) return; if (this._matchingWidth) return; this._matchingWidth = true; var edge = this.edgesAsChild ? this._edgedCanvas : null; if (!this.body.isDrawn()) this.body.draw(); // if autoSizing, once the body has received an initial width from the Window, don't have // the Window's layout code manage the width of the body. Otherwise, the first time we // autoSize to an overflowed body, we'll size the body to it's overflow'd size, // establishing the overflowed size as a minimum from then on. this.body.inherentWidth = true; // the window should be larger than the body by styling width (margin/border/padding) on // Window as a whole, plus the layoutMargin, which is interior to styling. var edgeWidth = (this.getWidth() - this.getInnerWidth()) + this._leftMargin + this._rightMargin; // plus the width of rounded edges, if edges are done as a child (otherwise these are // already factored in as native margins) if (edge) edgeWidth += edge._leftMargin + edge._rightMargin; var windowWidth = this.body.getVisibleWidth() + edgeWidth; this.logInfo("edgeWidth is: " + edgeWidth + ", setting window width to: " + windowWidth, "layout"); // setting the Window's width to match the body means all other children (eg the header) // will be sized to match the Window's width if (this.getWidth() != windowWidth) this.setWidth(windowWidth); this._matchingWidth = null;},disableAutoSize : function () { this.setAutoSize(false);},//> @method window.setAutoSize()// Setter for +link{window.autoSize}// @param autoSize (boolean) true if the window should auto-size to its content// @visibility external//<setAutoSize : function (autoSize) { this.autoSize = autoSize; if (autoSize) { if (this.body) { // set the body to apply a "fill" policy if its a Layout (in autoSize mode we just // stack the body items by default) if (isc.isA.Layout(this.body)) this.body.vPolicy = this.body.hPolicy = "none"; // set the body to start scrolling this.body.setOverflow("visible"); } // change the policy of the Window as a whole to start setting the size of the body // based on the Window size instead of vice versa this.vPolicy = "none"; this.setOverflow("visible"); } else { if (this.body) { // set the body to apply a "fill" policy if its a Layout (in autoSize mode we just // stack the body items by default) if (isc.isA.Layout(this.body)) this.body.vPolicy = this.body.hPolicy = "fill"; // set the body to start scrolling this.body.setOverflow("auto"); this.body.inherentWidth = false; } // change the policy of the Window as a whole to start setting the size of the body // based on the Window size instead of vice versa this.vPolicy = "fill"; this.setOverflow("hidden"); }},// if we are dragResized, disable autoSizingdragResizeStart : function () { if (this.Super("dragResizeStart", arguments) == false) return; // set a flag to disable autoSizing the next time we do layout. // NOTE: technically, we should only do this on a successful drag, and for the special case // of dragAppearance target, be able to disable autoSizing but re-enable it on drag // cancellation. if (this.autoSize) { this.autoSize = false; this._disableAutoSize = true; }},// ---------------------------------------------------------------------------------------//> @method Window.returnValue()// @group data// return a value to the callback function// and hide the Window//// @param value (any) return value for the Window//<returnValue : function (value) { if (this.isVisible()) this.hide(); if (this.callback) this.fireCallback(this.callback, "value", [value]); return value;},// event handling// -------------------------------------------------------------------------------------------------////> @method Window.show()// Show the Window.// <P>// When a modal window is shown, it will begin blocking input to any components on the screen other// than the modal window.// @group appearance//<show : function (a,b,c,d) { if (isc._traceMarkers) arguments.__this = this; if (this.isModal) { // Explicitly catch the case of a developer specifying isModal on a non top-level window // this will be clearer than a log message about clickMasks. if (this.topElement != null) { this.logWarn("Window specified with 'isModal' set to true, but this window has a " + "parentElement. Only top level Windows can be shown modally."); this.isModal = false; } else { this.showClickMask( this.getID() + (this.dismissOnOutsideClick ? ".closeClick()" : ".flash()"), false, // Don't mask ourselves [this]); this.makeModalMask(); } } if (this.shouldDismissOnEscape()) this._setDismissOnEscapeEvent(); // If we're going to be auto-centered, draw offscreen before centering if (this.autoCenter && !this.parentElement) { this._centering = true; this.moveTo(-1000, -1000); this._centering = false; } this.invokeSuper(isc.Window, "show", a,b,c,d); if (this.autoCenter) { // if we're supposed to autoCenter, center in the page this.centerInPage(); // set up an event to keep autoCentering on page resize if (!this.parentElement) { isc.Page.setEvent(this._$resize, this, null, "parentResized"); } } this.bringToFront();},makeModalMask : function () { if (!this.showModalMask) return; if (!this.modalMask) this.modalMask = this.createAutoChild( "modalMask", { styleName: this.modalMaskStyle, opacity: this.modalMaskOpacity } ); this.modalMask.show();},hideModalMask : function () { if (this.modalMask) this.modalMask.hide();},destroyModalMask : function () { if (this.modalMask) { this.modalMask.destroy(); this.modalMask = null; } }//> @method window.shouldDismissOnEscape()// Should this window be dismissed (same effect as pressing the "Cancel" button) when the // user presses the "Escape" key?<br>// Default behavior: if +link{window.dismissOnEscape} is set, just return it. Otherwise return// true if this window is showing a "close" control in the header // (see +link{window.headerControls}).// @return (boolean) true if the window should be dismissed when the user hits escape// @visibility external//<shouldDismissOnEscape : function () { if (this.dismissOnEscape != null) return this.dismissOnEscape; // If we're showing a close button in our header, return true return this.showHeader && this.headerControls && this.showCloseButton && this.headerControls.contains("closeButton"); },_setDismissOnEscapeEvent : function () { this._escapeRegistered = true; isc.Page.registerKey("Escape", this.getID() + ".handleEscape()", this);},_clearDismissOnEscapeEvent : function () { isc.Page.unregisterKey("Escape", this); this._escapeRegistered = false;},// handleEscape() - fired when the user hits escape if 'dismissOnEscape' is true.// Fires closeClick() to dismiss the window. Can potentially be overridden for other// behavior.handleEscape : function () { // If we're under a clickMask, don't dismiss. // This handles the case where we're showing 2 windows, the top one of which is modal // In this case we want the user to have to interact with the top window before // dismissing the window underneath it. if (this.isMasked()) return; this.closeClick();},resized : function (a,b,c,d) { this.invokeSuper(isc.Window, "resized", a,b,c,d); if (this.autoCenter) this.centerInPage();},//> @method Window.hide()// Hide the Window. Hides the clickMask for modal Windows.// @group appearance//<hide : function (a,b,c,d) { //>Animation if (this._animatingMinimize) isc.Animation.finishAnimation(this._animatingMinimize); //<Animation this.invokeSuper(isc.Window, "hide", a,b,c,d); if (this.isDrawn() && this.isModal) { this.hideClickMask(); this.hideModalMask(); } if (this._escapeRegistered) this._clearDismissOnEscapeEvent(); },// If a parent is hidden or shown, and dismissOnEscape is true, set up / clear the// escape keypress eventparentVisibilityChanged : function () { if (this.shouldDismissOnEscape()) { if (this.isVisible()) this._setDismissOnEscapeEvent(); } else if (this._escapeRegistered) { this._clearDismissOnEscapeEvent(); }},//> @method Window.clear()// When clearing a modal window, also clear the clickMask// @group appearance//<clear : function (a,b,c,d) { //>Animation if (this._animatingMinimize) isc.Animation.finishAnimation(this._animatingMinimize); //<Animation this.invokeSuper(isc.Window, "clear", a,b,c,d); if (this.isVisible() && this.isModal) { this.hideClickMask(); this.hideModalMask(); } if (this.isVisible() && this._escapeRegistered) this._clearDismissOnEscapeEvent();},// AutoCenter// ---------------------------------------------------------------------------------------// if our parent (or the Page) resizes, autoCenter if configured to do soparentResized : function () { this.Super("parentResized", arguments); // auto center, only if we're still set to if (th
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -