app-base.js revision 33583dee8962d0d7b705003e6760ed1dc9ee78ba
563b922249eadd0562ddea89c52ed308c2d31c0aJaco JoosteProvides a top-level application component which manages navigation and views.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste@submodule app-base
563b922249eadd0562ddea89c52ed308c2d31c0aJaco JoosteProvides a top-level application component which manages navigation and views.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * TODO: Add more description.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * TODO: Should this extend `Y.Base` and mix in `Y.Router` along with
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste `Y.PjaxBase` and `Y.View`? Also need to make sure the `Y.Base`-based
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste extensions are doing the proper thing w.r.t. multiple inheritance.
deab5d0e23a609e0eb9c5915e6cd0f4e26aac38fJaco Jooste@extends Base
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste@uses PjaxBase
563b922249eadd0562ddea89c52ed308c2d31c0aJaco JoosteApp = Y.App = Y.Base.create('app', Y.Base, [Y.View, Y.Router, Y.PjaxBase], {
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste // -- Public Properties ----------------------------------------------------
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste Hash of view-name to metadata used to declaratively describe an
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste application's views and their relationship with the app and other views.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste The view info in `views` is an Object keyed to a view name and can have any
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste or all of the following properties:
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `type`: Function or a string representing the view constructor to use to
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste create view instances. If a string is used, the constructor function is
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste assumed to be on the `Y` object; e.g. `"SomeView"` -> `Y.SomeView`.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `preserve`: Boolean for whether the view instance should be retained. By
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste default, the view instance will be destroyed when it is no longer the
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste active view. If `true` the view instance will simply be `removed()` from
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste the DOM when it is no longer active. This is useful when the view is
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste frequently used and may be expensive to re-create.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `parent`: String to another named view in this hash that represents
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste parent view within the application's view hierarchy; e.g. a `"photo"`
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste view could have `"album"` has its `parent` view. This parent/child
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste relationship is used a queue for which transition to use.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `instance`: Used internally to manage the current instance of this named
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste view. This can be used if your view instance is created up-front, or if
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste you would rather manage the View lifecyle, but you probably should just
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste let this be handled for you.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * TODO: Should `transitions` be supported on the registered views?
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste If `views` are passed at instantiation time, they will override any views
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste set on the prototype.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste @property views
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste @type Object
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste Transitions to use when the `activeView` changes.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste Transition configurations contain a two properties: `viewIn` and `viewOut`;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste there exists three configurations that represent the different scenarios of
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste the `activeView` changing:
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `navigate`: The default set of transitions to use when changing the
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste `activeView` of the application.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `toChild`: The set of transitions to use when the `activeView` changes
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste to a named view who's `parent` property references the metadata of the
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste previously active view.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * `toParent`: The set of transitions to use when the `activeView` changes
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste to a named view who's metadata is referenced by the previously active
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste view's `parent` property.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste With the current state of `Y.Transition`, it is best to used named
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste transitions that registered on `Y.Transition.fx`. If `transitions` are
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste passed at instantiation time, they will override any transitions set on
dfa51161ad226f5998270e3becb25817774aa168Tony Bamford the prototype.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste @property transitions
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste @type Object
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste viewIn : 'app:fadeIn',
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste viewOut: 'app:fadeOut'
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste viewIn : 'app:slideLeft',
a805ad8fd997c440021b625583752605188e4de3Brian Bailey viewOut: 'app:slideLeft'
deab5d0e23a609e0eb9c5915e6cd0f4e26aac38fJaco Jooste viewIn : 'app:slideRight',
deab5d0e23a609e0eb9c5915e6cd0f4e26aac38fJaco Jooste viewOut: 'app:slideRight'
toParent: {
this._viewInfoMap = {};
create: function () {
render: function () {
view;
return view;
var viewInfo;
if (callback) {
var self = this,
called = false;
function done () {
if (!called) {
called = true;
var viewInfo;
if (view) {
if (!view) {
_afterActiveViewChange: function (e) {
if (isChild) {
} else if (isParent) {
} else if (newView) {
ATTRS: {
container: {
valueFn: function () {
linkSelector: {
activeView: {
readOnly: true
on: {
start: function () {
end: function () {
on: {
start: function () {
end: function () {
on: {
end: function () {
on: {
start: function () {
end: function () {