📄 application.js
字号:
* @type Echo.LayoutDirection * @final */Echo.LayoutDirection.RTL = new Echo.LayoutDirection(false);/** * An application style sheet. */Echo.StyleSheet = Core.extend({ /** Map between style names and type-name to style maps. */ _nameToStyleMap: null, /** * Style cache mapping style names and type-name to style maps. Behaves identically to _nameToStyleMap except styles are * stored explicitly for every component type. This provides quick access to style information for the renderer. */ _renderCache: null, /** * Creates a new style sheet. * * @param initialValues an optional mapping between style names * and maps between component types and styles */ $construct: function(initialValues) { this._renderCache = { }; this._nameToStyleMap = { }; if (initialValues) { for (var styleName in initialValues) { for (var componentType in initialValues[styleName]) { this.setStyle(styleName, componentType, initialValues[styleName][componentType]); } } } }, /** * Returns the style that should be used for a component. * * @param {String} name the component's style name * @param {String} componentType the type of the component * @return the style */ getRenderStyle: function(name, componentType) { // Retrieve style from cache. var typeToStyleMap = this._renderCache[name]; if (!typeToStyleMap) { return null; } var style = typeToStyleMap[componentType]; if (style !== undefined) { // If style found in cache, return immediately. return style; } else { return this._loadRenderStyle(name, componentType); } }, /** * Creates a rendered style object for a specific style name and componentType and stores it in * the cache. This method is invoked by <code>getRenderStyle()</code> when a cached style cannot be found. * * @param {String} name the style name * @param {String} componentType the type of the component * @return the style */ _loadRenderStyle: function(name, componentType) { // Retrieve value (type-to-style-map) from name-to-style-map with specified name key. var typeToStyleMap = this._nameToStyleMap[name]; if (typeToStyleMap == null) { // No styles available for specified name, mark cache entry as null and return null. this._renderCache[name][componentType] = null; return null; } // Retrieve style for specific componentType. var style = typeToStyleMap[componentType]; if (style == null) { var testType = componentType; while (style == null) { // Search super types of testType to find style until found. testType = Echo.ComponentFactory.getSuperType(testType); if (testType == null) { // No style available for component type, mark cache entry as null and return null. this._renderCache[name][testType] = null; return null; } style = typeToStyleMap[testType]; } } this._renderCache[name][componentType] = style; return style; }, /** * Retrieves a specific style from the style sheet. * * @param {String} name the style name * @param {String} componentType the component type * @return the style */ getStyle: function(name, componentType) { var typeToStyleMap = this._nameToStyleMap[name]; if (typeToStyleMap == null) { return null; } return typeToStyleMap[componentType]; }, /** * Stores a style in the style sheet. * * @param {String} name the style name * @param {String} componentType the component type * @param the style */ setStyle: function(name, componentType, style) { // Create or clear cache entry for name. this._renderCache[name] = {}; var typeToStyleMap = this._nameToStyleMap[name]; if (typeToStyleMap == null) { typeToStyleMap = {}; this._nameToStyleMap[name] = typeToStyleMap; } typeToStyleMap[componentType] = style; }});// Update Management/** * Namespace for update management. * Provides capabilities for storing property changes made to applications and components * such that display redraws may be performed efficiently. * @namespace */Echo.Update = { };/** * Representation of an update to a single existing component which is currently rendered on the screen. */Echo.Update.ComponentUpdate = Core.extend({ $static: { /** * Data object representing the old and new states of a changed property. * * @param oldValue the old value of the property * @param newValue the new value of the property */ PropertyUpdate: function(oldValue, newValue) { this.oldValue = oldValue; this.newValue = newValue; } }, /** * The <code>Manager</code> to which this update belongs. * @type Array */ _manager: null, /** * The parent component represented in this <code>ServerComponentUpdate</code>. * @type Echo.Component */ parent: null, /** * Storage for contextual information used by application container to render this update. * Object type and content are specified by the application container, this variable is not * used by the application module in any capacity. */ renderContext: null, /** * The set of child Component ids added to the <code>parent</code>. * @type Array */ _addedChildIds: null, /** * A mapping between property names of the parent component and * <code>PropertyUpdate</code>s. */ _propertyUpdates: null, /** * The set of child Component ids removed from the <code>parent</code>. * @type Array */ _removedChildIds: null, /** * The set of descendant Component ids which are implicitly removed * as they were children of removed children. * @type Array */ _removedDescendantIds: null, /** * The set of child Component ids whose <code>LayoutData</code> * was updated. * @type Array */ _updatedLayoutDataChildIds: null, /** * The set of listener types which have been added to/removed from the component. * Associative mapping between listener type names and boolean values, true representing * the notion that listeners of a type have been added or removed. */ _listenerUpdates: null, /** * Creates a new ComponentUpdate. * * @param {Echo.Component} parent the updated component */ $construct: function(manager, parent) { /** * The <code>Manager</code> to which this update belongs. * @type Array */ this._manager = manager; /** * The parent component represented in this <code>ServerComponentUpdate</code>. * @type Echo.Component */ this.parent = parent; }, /** * Records the addition of a child to the parent component. * * @param {Echo.Component} child the added child */ _addChild: function(child) { if (!this._addedChildIds) { this._addedChildIds = []; } this._addedChildIds.push(child.renderId); this._manager._idMap[child.renderId] = child; }, /** * Appends removed children and descendants from another update to this * update as removed descendants. * This method is invoked when a component is removed that is an ancestor * of a component that has an update in the update manager. * * @param {Echo.Update.CompoentUpdate} update the update from which to pull * removed components/descendants */ _appendRemovedDescendants: function(update) { var i; // Append removed descendants. if (update._removedDescendantIds != null) { if (this._removedDescendantIds == null) { this._removedDescendantIds = []; } for (i = 0; i < update._removedDescendantIds.length; ++i) { this._removedDescendantIds.push(update._removedDescendantIds[i]); } } // Append removed children. if (update._removedChildIds != null) { if (this._removedDescendantIds == null) { this._removedDescendantIds = []; } for (i = 0; i < update._removedChildIds.length; ++i) { this._removedDescendantIds.push(update._removedChildIds[i]); } } if (this._removedDescendantIds != null) { Core.Arrays.removeDuplicates(this._removedDescendantIds); } }, /** * Returns an array containing the children added in this update, * or null if none were added. * * @return the added children * @type Array */ getAddedChildren: function() { if (!this._addedChildIds) { return null; } var components = []; for (var i = 0; i < this._addedChildIds.length; ++i) { components[i] = this._manager._idMap[this._addedChildIds[i]]; } return components; }, /** * Returns an array containing the children removed in this update, * or null if none were removed. * * @return the removed children * @type Array */ getRemovedChildren: function() { if (!this._removedChildIds) { return null; } var components = []; for (var i = 0; i < this._removedChildIds.length; ++i) { components[i] = this._manager._removedIdMap[this._removedChildIds[i]]; } return components; }, /** * Returns an array containing the descendants of any children removed in * this update, or null if none were removed. The removed children * themselves are not returned by this method. * * @return the removed descendants * @type Array */ getRemovedDescendants: function() { if (!this._removedDescendantIds) { return null; } var components = []; for (var i = 0; i < this._removedDescendantIds.length; ++i) { components[i] = this._manager._removedIdMap[this._removedDescendantIds[i]]; } return components; }, /** * Returns an array containing the children of this component whose * LayoutDatas have changed in this update, or null if no such * changes were made. * * @return the updated layout data children * @type Array */ getUpdatedLayoutDataChildren: function() { if (!this._updatedLayoutDataChildIds) { return null; } var components = []; for (var i = 0; i < this._updatedLayoutDataChildIds.length; ++i) { components[i] = this._manager._idMap[this._updatedLayoutDataChildIds[i]]; } return components; }, /** * Determines if any children were added during this update. * * @return true if any children were added * @type Boolean */ hasAddedChildren: function() { return this._addedChildIds != null; }, /** * Determines if any children were removed during this update. * * @return true if any children were removed * @type Boolean */ hasRemovedChildren: function() { return this._removedChildIds != null; }, /** * Determines if any children had their LayoutData changed during this update. * * @return true if any children had their LayoutData changed * @type Boolean */ hasUpdatedLayoutDataChildren: function() { return this._updatedLayoutData
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -