📄 client.js
字号:
div.appendChild(msgDiv); var xDiv = document.createElement("div"); xDiv.style.cssText = "color:red;line-height:90%;font-size:" + (new Core.Web.Measure.Bounds(this.domainElement).height || 100) + "px;text-align:center;overflow:hidden;"; xDiv.appendChild(document.createTextNode("X")); div.appendChild(xDiv); // Attempt to dispose. this.dispose(); }, /** * Forces IE browser to re-render entire document if the height of the application's domain element measures zero. * This is a workaround for an Internet Explorer bug where the browser's rendering engine fundamentally fails and simply * displays a blank screen (commonly referred to on bug-tracker/forum as the "blank screen of death"/BSOD). * This bug appears to be most prevalent in IE7. */ _forceIERedraw: function() { if (Core.Web.Env.BROWSER_INTERNET_EXPLORER && this.domainElement.offsetHeight === 0) { var displayState = document.documentElement.style.display; if (!displayState) { displayState = ""; } document.documentElement.style.display = "none"; document.documentElement.style.display = displayState; } }, /** * Listener for application change of component focus: * invokes focus() method on focused component's peer. * * @param e the event */ _processApplicationFocus: function(e) { var focusedComponent = this.application.getFocusedComponent(); if (focusedComponent && focusedComponent.peer && focusedComponent.peer.renderFocus) { focusedComponent.peer.renderFocus(); } }, /** * Root KeyDown event handler. * Specifically processes tab key events for focus management. * * @param e the event */ _processKeyPress: function(e) { if (e.keyCode == 9) { // Tab this.application.focusNext(e.shiftKey); Core.Web.DOM.preventEventDefault(e); return false; // Stop propagation. } return true; // Allow propagation. }, /** * Processes updates to the component hierarchy. * Invokes <code>Echo.Render.processUpdates()</code>. */ processUpdates: function() { var ir = null; try { ir = this.createInputRestriction(); Echo.Render.processUpdates(this); } finally { this.removeInputRestriction(ir); this._forceIERedraw(); } }, /** * Registers a listener to be notified when all input restrictions have been removed. * * @param {Echo.Component} component the component for which the restriction listener is being registered * @param {Function} l the method to notify when all input restrictions have been cleared */ registerRestrictionListener: function(component, l) { if (!this._inputRestrictionListeners) { this._inputRestrictionListeners = { }; } this._inputRestrictionListeners[component.renderId] = l; }, /** * Removes an input restriction. * * @param {String} id the id (handle) of the input restriction to remove */ removeInputRestriction: function(id) { if (this._inputRestrictionMap[id] === undefined) { return; } delete this._inputRestrictionMap[id]; --this._inputRestrictionCount; if (this._inputRestrictionCount === 0) { // Last input restriction removed. // Remove wait indicator from scheduling (if wait indicator has not been presented yet, it will not be). Core.Web.Scheduler.remove(this._waitIndicatorRunnable); // Disable wait indicator. if (this._waitIndicatorActive) { this._waitIndicatorActive = false; this._waitIndicator.deactivate(); } if (this._inputRestrictionListeners) { // Notify input restriction listeners. for (var x in this._inputRestrictionListeners) { this._inputRestrictionListeners[x](); } // Clear input restriction listeners. this._inputRestrictionListeners = null; } } }, /** * Sets the wait indicator that will be displayed when a client-server action takes longer than * a specified period of time. * * @param {Echo.Client.WaitIndicator} waitIndicator the new wait indicator */ setWaitIndicator: function(waitIndicator) { if (this._waitIndicator) { this._waitIndicator.deactivate(); } this._waitIndicator = waitIndicator; }, /** * Activates the wait indicator. */ _waitIndicatorActivate: function() { this._waitIndicatorActive = true; this._waitIndicator.activate(); }, /** * Instance listener to respond to resizing of browser window. * * @param e the DOM resize event */ _windowResizeListener: function(e) { Echo.Render.notifyResize(this.application.rootComponent); }});/** * Provides a debugging tool for measuring performance of the Echo3 client engine. * This is generally best used to measure performance before/after modifications. */Echo.Client.Timer = Core.extend({ /** Array of times. */ _times: null, /** Array of labels. */ _labels: null, /** * Creates a new debug timer. * * @constructor */ $construct: function() { this._times = [new Date().getTime()]; this._labels = ["Start"]; }, /** * Marks the time required to complete a task. This method should be invoked * when a task is completed with the 'label' specifying a description of the task. * * @param {String} label a description of the completed task. */ mark: function(label) { this._times.push(new Date().getTime()); this._labels.push(label); }, /** * Returns a String representation of the timer results, showing how long * each task required to complete (and included a total time). * * @return the timer results * @type String */ toString: function() { var out = ""; for (var i = 1; i < this._times.length; ++i) { var time = this._times[i] - this._times[i - 1]; out += this._labels[i] + ":" + time + " "; } out += "TOT:" + (this._times[this._times.length - 1] - this._times[0]) + "ms"; return out; }});/** * Abstract base class for "Wait Indicators" which are displayed when the * application is not available (e.g., due to in-progress client/server * activity. A single wait indicator will be used by the application. */Echo.Client.WaitIndicator = Core.extend({ $abstract: { /** * Wait indicator activation method. Invoked when the wait indicator * should be activated. The implementation should add the wait indicator * to the DOM and begin any animation (if applicable). */ activate: function() { }, /** * Wait indicator deactivation method. Invoked when the wait indicator * should be deactivated. The implementation should remove the wait * indicator from the DOM, cancel any animations, and dispose of any * resources. */ deactivate: function() { } }});/** * Default wait indicator implementation. */Echo.Client.DefaultWaitIndicator = Core.extend(Echo.Client.WaitIndicator, { /** Creates a new DefaultWaitIndicator. */ $construct: function() { this._divElement = document.createElement("div"); this._divElement.style.cssText = "display: none;z-index:32767;position:absolute;top:30px;right:30px;" + "width:200px;padding:20px;border:1px outset #abcdef;background-color:#abcdef;color:#000000;text-align:center;"; this._divElement.appendChild(document.createTextNode("Please wait...")); this._fadeRunnable = new Core.Web.Scheduler.MethodRunnable(Core.method(this, this._tick), 50, true); document.body.appendChild(this._divElement); }, /** @see Echo.Client.WaitIndicator#activate */ activate: function() { this._divElement.style.display = "block"; Core.Web.Scheduler.add(this._fadeRunnable); this._opacity = 0; }, /** @see Echo.Client.WaitIndicator#deactivate */ deactivate: function() { this._divElement.style.display = "none"; Core.Web.Scheduler.remove(this._fadeRunnable); }, /** * Runnable-invoked method to animate (fade in/out) wait indicator. */ _tick: function() { ++this._opacity; // Formula explained: // this._opacity starts at 0 and is incremented forever. // First operation is to modulo by 40 then subtract 20, result ranges from -20 to 20. // Next take the absolute value, result ranges from 20 to 0 to 20. // Divide this value by 30, so the range goes from 2/3 to 0 to 2/3. // Subtract that value from 1, so the range goes from 1/3 to 1 and back. var opacityValue = 1 - (Math.abs((this._opacity % 40) - 20) / 30); if (!Core.Web.Env.PROPRIETARY_IE_OPACITY_FILTER_REQUIRED) { this._divElement.style.opacity = opacityValue; } }});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -