📄 application.js
字号:
/** * Returns an arbitrary property value. * * @param {String} name the name of the property * @return the property value */ get: function(name) { return this._localStyle[name]; }, /** * Retrieves the child component at the specified index. * * @param {Number} index the (integer) index * @return the child component * @type Echo.Component */ getComponent: function(index) { return this.children[index]; }, /** * Returns the number of child components. * * @return the number of child components * @type Number */ getComponentCount: function() { return this.children.length; }, /** * Returns an arbitrary indexed property value. * * @param {String} name the name of the property * @param {Number} index the index to return * @return the property value */ getIndex: function(name, index) { var valueArray = this._localStyle[name]; return valueArray ? valueArray[index] : null; }, /** * Returns the component layout direction. * Note that in most cases it is preferable to set the layout direction of the Application, rather than individual components. * * @return the component layout direction * @type Echo.LayoutDirection */ getLayoutDirection: function() { return this._layoutDirection; }, /** * Returns the component locale. * Note that in most cases it is preferable to set the locale of the Application, rather than individual components. * * @return the component locale * @type String */ getLocale: function() { return this._locale; }, /** * Retrieves local style property map associations. This method should only be used by a de-serialized for * the purpose of rapidly loading properties into a new component. * * @return the internal style property map associations */ getLocalStyleData: function() { return this._localStyle; }, /** * Returns the layout direction with which the component should be rendered, based on analyzing the component's layout * direction, its parent's, and/or the application's. * * @return the rendering layout direction * @type Echo.LayoutDirection */ getRenderLayoutDirection: function() { var component = this; while (component) { if (component._layoutDirection) { return component._layoutDirection; } component = component.parent; } if (this.application) { return this.application.getLayoutDirection(); } return null; }, /** * Returns the locale with which the component should be rendered, based on analyzing the component's locale, * its parent's, and/or the application's. * * @return the rendering locale * @type String */ getRenderLocale: function() { var component = this; while (component) { if (component._locale) { return component._locale; } component = component.parent; } if (this.application) { return this.application.getLocale(); } return null; }, /** * Returns the style assigned to this component, if any. * * @return the assigned style */ getStyle: function() { return this._style; }, /** * Returns the name of the style (from the application's style sheet) * assigned to this component. * * @return the style name * @type String */ getStyleName: function() { return this._styleName; }, /** * Returns the index of a child component, or -1 if the component * is not a child. * * @param {Echo.Component} component the component * @return the index * @type Number */ indexOf: function(component) { for (var i = 0; i < this.children.length; ++i) { if (this.children[i] == component) { return i; } } return -1; }, /** * Determines if the component is active, that is, within the current modal context * and ready to receive input. * * @return the active state * @type Boolean */ isActive: function() { // Verify the component and its ancestors are all enabled. if (!this.isRenderEnabled()) { return false; } // Verify component is registered to an application, and that the application is active. if (!this.application || !this.application.isActive()) { return false; } // Verify component is in modal context. var modalContextRoot = this.application.getModalContextRoot(); if (modalContextRoot != null && !modalContextRoot.isAncestorOf(this)) { return false; } return true; }, /** * Determines if this component is or is an ancestor of another component. * * @param {Echo.Component} c the component to test * @return true if an ancestor relationship exists * @type Boolean */ isAncestorOf: function(c) { while (c != null && c != this) { c = c.parent; } return c == this; }, /** * Determines the enabled state of this component. * Use isRenderEnabled() to determine whether a component should be rendered as enabled. * * @return the enabled state of this specific component */ isEnabled: function() { return this._enabled; }, /** * Determines whether this <code>Component</code> should be rendered with * an enabled state. * Disabled <code>Component</code>s are not eligible to receive user input. * * @return true if the component should be rendered enabled * @type Boolean */ isRenderEnabled: function() { var component = this; while (component != null) { if (!component._enabled) { return false; } component = component.parent; } return true; }, /** * Registers / unregisters a component that has been added/removed to/from a registered hierarchy * (a hierarchy that is registered to an application). * * @param {Echo.Application} application the application (null to unregister the component) */ register: function(application) { // Sanity check. if (application && this.application) { throw new Error("Attempt to re-register or change registered application of component."); } var i; if (!application) { // unregistering // Recursively unregister children. if (this.children != null) { for (i = 0; i < this.children.length; ++i) { this.children[i].register(false); // Recursively unregister children. } } // Notify application. this.application._unregisterComponent(this); // Change application focus in the event the focused component is being removed. // Note that this is performed after de-registration to ensure any removed modal context is cleared. if (this.application._focusedComponent == this) { this.application.setFocusedComponent(this.parent); } // Notify dispose listeners. if (this._listenerList != null && this._listenerList.hasListeners("dispose")) { this._listenerList.fireEvent({ type: "dispose", source: this }); } } // Link/unlink with application. this.application = application; if (application) { // registering // Assign render id if required. if (this.renderId == null) { this.renderId = "CL." + (++Echo.Component._nextRenderId); } // Notify application. this.application._registerComponent(this); // Notify init listeners. if (this._listenerList != null && this._listenerList.hasListeners("init")) { this._listenerList.fireEvent({ type: "init", source: this }); } // Recursively register children. if (this.children != null) { for (i = 0; i < this.children.length; ++i) { this.children[i].register(application); // Recursively unregister children. } } } }, /** * Returns the value of a property that should be rendered, * based on the value set on this component, in the component's * specified style, and/or in the application's stylesheet. * * @param {String} name the name of the property * @param defaultValue the default value to return if no value is * specified in an internal property, style, or stylesheet * @return the property value */ render: function(name, defaultValue) { var value = this._localStyle[name]; if (value == null) { if (this._style != null) { value = this._style[name]; } if (value == null && this.application && this.application._styleSheet) { var style = this.application._styleSheet.getRenderStyle( this._styleName != null ? this._styleName : "", this.componentType); if (style) { value = style[name]; } } } return value == null ? defaultValue : value; }, /** * Returns the value of an indexed property that should be rendered, * based on the value set on this component, in the component's * specified style, and/or in the application's stylesheet. * * @param {String} name the name of the property * @param {Number} index the (integer) index of the property * @param defaultValue the default value to return if no value is * specified in an internal property, style, or stylesheet * @return the property value */ renderIndex: function(name, index, defaultValue) { var valueArray = this._localStyle[name]; var value = valueArray ? valueArray[index] : null; if (value == null) { if (this._style != null) { valueArray = this._style[name]; value = valueArray ? valueArray[index] : null; } if (value == null && this._styleName && this.application && this.application._styleSheet) { var style = this.application._styleSheet.getRenderStyle( this._styleName != null ? this._styleName : "", this.componentType); if (style) { valueArray = style[name]; value = valueArray ? valueArray[index] : null; } } } return value == null ? defaultValue : value; }, /** * Removes a child component. * * @param componentOrIndex the index of the component to remove, or the component to remove * (values may be of type Echo.Component or Number) */ remove: function(componentOrIndex) { var component; var index; if (typeof componentOrIndex == "number") { index = componentOrIndex; component = this.children[index]; if (!component) { throw new Error("Component.remove(): index out of bounds: " + index + ", parent: " + this); } } else { component = componentOrIndex; index = this.indexOf(component); if (index == -1) { // Component is not a child: do nothing. return; } } if (this.application) { component.register(null); } this.children.splice(index, 1); component.parent = null; if (this.application) { this.application.notifyComponentUpdate(this, "children", component, null); } if (component._listenerList && component._listenerList.hasListeners("parent")) { component._listenerList.fireEvent({type: "parent", source: component, oldValue: this, newValue: null}); } if (this._listenerList && this._listenerList.hasListeners("children")) { this._listenerList.fireEvent({type: "children", source: this, remove: component, index: index}); } }, /** * Removes all child components. */ removeAll: function() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -