app-base-debug.js revision 042de896986219bc3b2b86b6c356c0ec7d662d32
0N/AProvides a top-level application component which manages navigation and views. 0N/AProvides a top-level application component which manages navigation and views. 0N/A * TODO: Add more description. 0N/A * TODO: Should this extend `Y.Base` and mix in `Y.Router` along with 0N/A `Y.PjaxBase` and `Y.View`? Also need to make sure the `Y.Base`-based 1054N/A extensions are doing the proper thing w.r.t. multiple inheritance. 1016N/A // -- Public Properties ---------------------------------------------------- 261N/A Hash of view-name to meta data used to declaratively describe an 583N/A application's views and their relationship with the app and other views. 1062N/A The view info in `views` is an Object keyed to a view name and can have any 312N/A or all of the following properties: 428N/A * `type`: Function or a string representing the view constructor to use to 126N/A create view instances. If a string is used, the constructor function is 1088N/A assumed to be on the `Y` object; e.g. `"SomeView"` -> `Y.SomeView`. 394N/A * `preserve`: Boolean for whether the view instance should be retained. By 8N/A default, the view instance will be destroyed when it is no longer the 77N/A active view. If `true` the view instance will simply be `removed()` from 0N/A the DOM when it is no longer active. This is useful when the view is 0N/A frequently used and may be expensive to re-create. 0N/A * `parent`: String to another named view in this hash that represents 0N/A parent view within the application's view hierarchy; e.g. a `"photo"` 491N/A relationship is used a queue for which transition to use. 491N/A * `instance`: Used internally to manage the current instance of this named 465N/A view. This can be used if your view instance is created up-front, or if 465N/A you would rather manage the View lifecyle, but you probably should just 491N/A let this be handled for you. 491N/A * TODO: Should `transitions` be supported on the registered views? 886N/A If `views` are passed at instantiation time, they will override any views 65N/A Transitions to use when the `activeView` changes. 65N/A Transition configurations contain a two properties: `viewIn` and `viewOut`; 464N/A there exists three configurations that represent the different scenarios of 0N/A the `activeView` changing: 312N/A * `navigate`: The default set of transitions to use when changing the 312N/A `activeView` of the application. 491N/A * `toChild`: The set of transitions to use when the `activeView` changes 428N/A to a named view who's `parent` property references the meta data of the 376N/A previously active view. 0N/A * `toParent`: The set of transitions to use when the `activeView` changes 11N/A to a named view who's meta data is referenced by the previously active 0N/A view's `parent` property. 1016N/A With the current state of `Y.Transition`, it is best to used named 58N/A transitions that registered on `Y.Transition.fx`. If `transitions` are 58N/A passed at instantiation time, they will override any transitions set on 77N/A @property transitions 77N/A viewIn : 'app:slideLeft', 260N/A viewOut: 'app:slideLeft' 491N/A viewIn : 'app:slideRight', 77N/A // -- Protected Properties ------------------------------------------------- 491N/A Map of view instance id (via `Y.stamp()`) to view-info object in `views`. 77N/A This mapping is used to tie a specific view instance back to its meta data 491N/A by adding a reference to the the related view info on the `views` object. 491N/A // -- Lifecycle Methods ---------------------------------------------------- 491N/A // -- Public Methods ------------------------------------------------------- 491N/A Creates and returns this app's `container` node from the specified HTML 491N/A string, DOM element, or existing `Y.Node` instance. This method is called 491N/A internally when the view is initialized. 491N/A This node is also stamped with the CSS class specified by `Y.App.CSS_CLASS`. 491N/A By default, the created node is _not_ added to the DOM automatically. 491N/A @param {HTMLElement|Node|String} container HTML string, DOM element, or 491N/A `Y.Node` instance to use as the container node. 1016N/A @return {Node} Node instance of the created container node. 491N/A Renders this application by appending the `viewContainer` node to the 491N/A `container` node, and showing the `activeView`. 491N/A You should call this method at least once, usually after the initialization 799N/A of your `Y.App` instance. 886N/A Returns the meta data associated with a view instance or view name defined 1088N/A @param {View|String} view View instance, or name of a view defined on the 1088N/A @return {Object} The meta data for the view. 491N/A Creates and returns a new view instance using the provided `name` to look up 1088N/A the view info meta data defined in the `views` object. The passed-in 491N/A `config` object is passed to the view constructor function. 491N/A This function also maps a view instance back to its view info meta data. 491N/A @param {String} name The name of a view defined on the `views` object. 491N/A @param {Object} [config] The configuration object passed to the view 1088N/A constructor function when creating the new view instance. 491N/A @return {View} The new view instance. 491N/A // TODO: Should `type` default to Y.View? 491N/A // TODO: Default to `Y.View` or throw error if `ViewConstructor` is not 1088N/A This will set the application's `activeView` attribute to the view instance 490N/A passed-in, or when a view name is provided, the `activeView` attribute will 490N/A be set to either the preserved instance, or a new view instance will be 490N/A created using the passed in `config`. 490N/A TODO: Document transition info and config. 1088N/A @param {String|View} view The name of a view defined in the `views` object, 1026N/A @param {Object} [config] Optional configuration to use when creating a new 1026N/A @param {Function|Object} [options] Optional callback Function, or object 491N/A containing any of the following properties: 491N/A @param {Object} [options.transitions] An object that contains transition 491N/A configuration overrides for the following properties: 491N/A @param {Object} [options.transitions.viewIn] Transition overrides for 491N/A the view being transitioned-in. 1088N/A @param {Object} [options.transitions.viewOut] Transition overrides for 491N/A the view being transitioned-out. 1088N/A @param {Function} [options.callback] Function to callback after setting 491N/A // -- Protected Methods ---------------------------------------------------- 491N/A Determines if the `view` passed in is configured as a child of the `parent` 1088N/A view passed in. This requires both views to be either named-views, or view 491N/A instanced created using configuration data that exists in the `views` 126N/A @param {View|String} view The name of a view defined in the `views` object, 126N/A @param {View|String} parent The name of a view defined in the `views` 491N/A object, or a view instance. 491N/A @return {Boolean} Whether the view is configured as a child of the parent. 491N/A Determines if the `view` passed in is configured as a parent of the `child` 491N/A view passed in. This requires both views to be either named-views, or view 491N/A instanced created using configuration data that exists in the `views` 491N/A @param {View|String} view The name of a view defined in the `views` object, 491N/A @param {View|String} parent The name of a view defined in the `views` 491N/A object, or a view instance. 491N/A @return {Boolean} Whether the view is configured as a parent of the child. 994N/A Transitions the `oldView` out and the `newView` using the provided `fx` and 994N/A `fxConfigs` transition overrides. 994N/A @method _transitionViews 994N/A @param {View} newView The view instance to transition-in (if any). 994N/A @param {View} oldView The view instance to transition-out (if any). 994N/A @param {Object} fx The set of named transition effects to use which have 994N/A been registered on `Y.Transition.fx`. This object should contain two 491N/A @param {String} fx.viewIn The named transition for the new active view. 1088N/A @param {String} fx.viewOut The named transition for the old active view. 491N/A @param {Object} [fxConfigs] Optional set of transition overrides, this 1088N/A object can contain the following properties: 491N/A @param {Object} [fxConfigs.viewIn] Optional transition overrides for the 491N/A @param {Object} [fxConfigs.viewOut] Optional transition overrides for the 491N/A @param {Function} [callback] Optional function to call once the transition 491N/A // TODO: A better way to handle the completion of the transitions? 491N/A // This currently assumes at least one view was passed in and that the 491N/A // transitions have the same duration. 1088N/A Helper method to attach the view instance to the application by making the 1062N/A application a bubble target of the view, and assigning the view instance to 1064N/A the `instance` property of the associated view info meta data. 1062N/A // TODO: Should attachment handle the actual insertion into the DOM? 1088N/A // This might help for extracting the transitions into an app extension. 886N/A // `_detachView` does the removal of the view from the DOM. 886N/A @param {View} view View to attach. 886N/A // TODO: Should this happen eagerly, before the transition? 886N/A Helper method to detach the view instance from the application by removing 886N/A the application as a bubble target of the view, and either just removing the 1088N/A view if it is intended to be preserved, or destroying the instance 1088N/A @param {View} view View to detach. 1088N/A // Remove from view to view-info map. 1088N/A // Remove from view-info instance property. 491N/A // -- Protected Event Handlers --------------------------------------------- 491N/A Handles the application's `activeViewChange` event (which is fired when the 491N/A `activeView` attribute changes) by detaching the old view, attaching the new 491N/A view and transitioning between them. 491N/A The `activeView` attribute is read-only, so the public API to change its 491N/A value is through the `showView()` method. 312N/A @method _afterActiveViewChange 491N/A // Prevent detaching (thus removing) the view we want to show. 491N/A // Also hard to animate out and in, the same view. 491N/A // Determine transitions to use. 491N/A // TODO: Should the insertion move into the `_attachView()` method? 1054N/A // slide transition implementation? 491N/A // TODO: Consider refactor based on a `app-transitions` extension which 491N/A // would either override or API `_attachView()` and `_detachView()`. 491N/A Container node which represents the application's bounding-box. 491N/A @type HTMLElement|Node|String 491N/A Container node into which all application views will be rendered. 491N/A @attribute viewContainer 491N/A @type HTMLElement|Node|String 77N/A @default Y.Node.create('<div/>') 1054N/A This attribute is provided by `PjaxBase`, but the default value is 491N/A overridden to match all links on the page. 491N/A @attribute linkSelector 491N/A This attribute is read-only, to set the `activeView`, use the 491N/A// -- Transitions -------------------------------------------------------------- 491N/A // TODO: Cross-fade transition that doesn't require a change in 491N/A // var position = this.getStyle('position'); 1054N/A // if (position !== 'absolute') { 491N/A // this._transitionPosition = position; 491N/A // this.setStyle('position', 'absolute'); 491N/A // if (this._transitionPosition) { 491N/A // this.setStyle('position', this._transitionPosition); 491N/A // delete this._transitionPosition; 58N/A // TODO: Cross-fade transition that doesn't require a change in 491N/A // var position = this.getStyle('position'); 491N/A // if (position !== 'absolute') { 207N/A // this._transitionPosition = position; 1054N/A // this.setStyle('position', 'absolute'); 491N/A // if (this._transitionPosition) { 491N/A // this.setStyle('position', this._transitionPosition); 297N/A // delete this._transitionPosition; 979N/A},
'@VERSION@' ,{
requires:[
'controller',
'pjax-base',
'view',
'transition']});