Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember - npm Package Compare versions

Comparing version 1.0.0-pre.m1 to 1.0.0-pre.m2

rsvp.js

534

application.js

@@ -11,36 +11,296 @@ //

(function() {
// ==========================================================================
// Project: Ember - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
// Portions ©2008-2011 Apple Inc. All rights reserved.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
function visit(vertex, fn, visited, path) {
var name = vertex.name,
vertices = vertex.incoming,
names = vertex.incomingNames,
len = names.length,
i;
if (!visited) {
visited = {};
}
if (!path) {
path = [];
}
if (visited.hasOwnProperty(name)) {
return;
}
path.push(name);
visited[name] = true;
for (i = 0; i < len; i++) {
visit(vertices[names[i]], fn, visited, path);
}
fn(vertex, path);
path.pop();
}
function DAG() {
this.names = [];
this.vertices = {};
}
DAG.prototype.add = function(name) {
if (!name) { return; }
if (this.vertices.hasOwnProperty(name)) {
return this.vertices[name];
}
var vertex = {
name: name, incoming: {}, incomingNames: [], hasOutgoing: false, value: null
};
this.vertices[name] = vertex;
this.names.push(name);
return vertex;
};
DAG.prototype.map = function(name, value) {
this.add(name).value = value;
};
DAG.prototype.addEdge = function(fromName, toName) {
if (!fromName || !toName || fromName === toName) {
return;
}
var from = this.add(fromName), to = this.add(toName);
if (to.incoming.hasOwnProperty(fromName)) {
return;
}
function checkCycle(vertex, path) {
if (vertex.name === toName) {
throw new Error("cycle detected: " + toName + " <- " + path.join(" <- "));
}
}
visit(from, checkCycle);
from.hasOutgoing = true;
to.incoming[fromName] = from;
to.incomingNames.push(fromName);
};
DAG.prototype.topsort = function(fn) {
var visited = {},
vertices = this.vertices,
names = this.names,
len = names.length,
i, vertex;
for (i = 0; i < len; i++) {
vertex = vertices[names[i]];
if (!vertex.hasOutgoing) {
visit(vertex, fn, visited);
}
}
};
DAG.prototype.addEdges = function(name, value, before, after) {
var i;
this.map(name, value);
if (before) {
if (typeof before === 'string') {
this.addEdge(name, before);
} else {
for (i = 0; i < before.length; i++) {
this.addEdge(name, before[i]);
}
}
}
if (after) {
if (typeof after === 'string') {
this.addEdge(after, name);
} else {
for (i = 0; i < after.length; i++) {
this.addEdge(after[i], name);
}
}
}
};
Ember.DAG = DAG;
})();
(function() {
/**
@module ember
@submodule ember-application
*/
var get = Ember.get, set = Ember.set;
/**
@class
An instance of `Ember.Application` is the starting point for every Ember.js
application. It helps to instantiate, initialize and coordinate the many
objects that make up your app.
An Ember.Application instance serves as the namespace in which you define your
application's classes. You can also override the configuration of your
Each Ember.js app has one and only one `Ember.Application` object. In fact, the very
first thing you should do in your application is create the instance:
```javascript
window.App = Ember.Application.create();
```
Typically, the application object is the only global variable. All other
classes in your app should be properties on the `Ember.Application` instance,
which highlights its first role: a global namespace.
For example, if you define a view class, it might look like this:
```javascript
App.MyView = Ember.View.extend();
```
After all of your classes are defined, call `App.initialize()` to start the
application.
By default, Ember.Application will begin listening for events on the document.
If your application is embedded inside a page, instead of controlling the
entire document, you can specify which DOM element to attach to by setting
the `rootElement` property to a CSS selector.
Because `Ember.Application` inherits from `Ember.Namespace`, any classes
you create will have useful string representations when calling `toString()`;
see the `Ember.Namespace` documentation for more information.
MyApp = Ember.Application.create({
rootElement: '#my-app'
});
While you can think of your `Ember.Application` as a container that holds the
other classes in your application, there are several other responsibilities
going on under-the-hood that you may want to understand.
The root of an Ember.Application must not be removed during the course of the
page's lifetime. If you have only a single conceptual application for the
entire page, and are not embedding any third-party Ember applications
in your page, use the default document root for your application.
### Event Delegation
You only need to specify the root if your page contains multiple instances
of Ember.Application.
Ember.js uses a technique called _event delegation_. This allows the framework
to set up a global, shared event listener instead of requiring each view to do
it manually. For example, instead of each view registering its own `mousedown`
listener on its associated element, Ember.js sets up a `mousedown` listener on
the `body`.
@extends Ember.Object
If a `mousedown` event occurs, Ember.js will look at the target of the event and
start walking up the DOM node tree, finding corresponding views and invoking their
`mouseDown` method as it goes.
`Ember.Application` has a number of default events that it listens for, as well
as a mapping from lowercase events to camel-cased view method names. For
example, the `keypress` event causes the `keyPress` method on the view to be
called, the `dblclick` event causes `doubleClick` to be called, and so on.
If there is a browser event that Ember.js does not listen for by default, you
can specify custom events and their corresponding view method names by setting
the application's `customEvents` property:
```javascript
App = Ember.Application.create({
customEvents: {
// add support for the loadedmetadata media
// player event
'loadedmetadata': "loadedMetadata"
}
});
```
By default, the application sets up these event listeners on the document body.
However, in cases where you are embedding an Ember.js application inside an
existing page, you may want it to set up the listeners on an element inside
the body.
For example, if only events inside a DOM element with the ID of `ember-app` should
be delegated, set your application's `rootElement` property:
```javascript
window.App = Ember.Application.create({
rootElement: '#ember-app'
});
```
The `rootElement` can be either a DOM element or a jQuery-compatible selector
string. Note that *views appended to the DOM outside the root element will not
receive events.* If you specify a custom root element, make sure you only append
views inside it!
To learn more about the advantages of event delegation and the Ember.js view layer,
and a list of the event listeners that are setup by default, visit the
[Ember.js View Layer guide](http://emberjs.com/guides/view_layer#toc_event-delegation).
### Dependency Injection
One thing you may have noticed while using Ember.js is that you define *classes*, not
*instances*. When your application loads, all of the instances are created for you.
Creating these instances is the responsibility of `Ember.Application`.
When the `Ember.Application` initializes, it will look for an `Ember.Router` class
defined on the applications's `Router` property, like this:
```javascript
App.Router = Ember.Router.extend({
// ...
});
```
If found, the router is instantiated and saved on the application's `router`
property (note the lowercase 'r'). While you should *not* reference this router
instance directly from your application code, having access to `App.router`
from the console can be useful during debugging.
After the router is created, the application loops through all of the
registered _injections_ and invokes them once for each property on the
`Ember.Application` object.
An injection is a function that is responsible for instantiating objects from
classes defined on the application. By default, the only injection registered
instantiates controllers and makes them available on the router.
For example, if you define a controller class:
```javascript
App.MyController = Ember.Controller.extend({
// ...
});
```
Your router will receive an instance of `App.MyController` saved on its
`myController` property.
Libraries on top of Ember.js can register additional injections. For example,
if your application is using Ember Data, it registers an injection that
instantiates `DS.Store`:
```javascript
Ember.Application.registerInjection({
name: 'store',
before: 'controllers',
injection: function(app, router, property) {
if (property === 'Store') {
set(router, 'store', app[property].create());
}
}
});
```
### Routing
In addition to creating your application's router, `Ember.Application` is also
responsible for telling the router when to start routing.
By default, the router will begin trying to translate the current URL into
application state once the browser emits the `DOMContentReady` event. If you
need to defer routing, you can call the application's `deferReadiness()` method.
Once routing can begin, call the `advanceReadiness()` method.
If there is any setup required before routing begins, you can implement a `ready()`
method on your app that will be invoked immediately before routing begins:
```javascript
window.App = Ember.Application.create({
ready: function() {
this.set('router.enableLogging', true);
}
});
To begin routing, you must have at a minimum a top-level controller and view.
You define these as `App.ApplicationController` and `App.ApplicationView`,
respectively. Your application will not work if you do not define these two
mandatory classes. For example:
```javascript
App.ApplicationView = Ember.View.extend({
templateName: 'application'
});
App.ApplicationController = Ember.Controller.extend();
```
@class Application
@namespace Ember
@extends Ember.Namespace
*/

@@ -51,6 +311,11 @@ Ember.Application = Ember.Namespace.extend(

/**
The root DOM element of the Application.
The root DOM element of the Application. This can be specified as an
element or a
[jQuery-compatible selector string](http://api.jquery.com/category/selectors/).
Can be specified as DOMElement or a selector string.
This is the element that will be passed to the Application's,
`eventDispatcher`, which sets up the listeners for event delegation. Every
view in your application should be a child of the element you specify here.
@property rootElement
@type DOMElement

@@ -62,2 +327,12 @@ @default 'body'

/**
The `Ember.EventDispatcher` responsible for delegating events to this
application's views.
The event dispatcher is created by the application at initialization time
and sets up event listeners on the DOM element described by the
application's `rootElement` property.
See the documentation for `Ember.EventDispatcher` for more information.
@property eventDispatcher
@type Ember.EventDispatcher

@@ -69,2 +344,23 @@ @default null

/**
The DOM events for which the event dispatcher should listen.
By default, the application's `Ember.EventDispatcher` listens
for a set of standard DOM events, such as `mousedown` and
`keyup`, and delegates them to your application's `Ember.View`
instances.
If you would like additional events to be delegated to your
views, set your `Ember.Application`'s `customEvents` property
to a hash containing the DOM event name as the key and the
corresponding view method name as the value. For example:
App = Ember.Application.create({
customEvents: {
// add support for the loadedmetadata media
// player event
'loadedmetadata': "loadedMetadata"
}
});
@property customEvents
@type Object

@@ -75,16 +371,13 @@ @default null

/** @private */
autoinit: !Ember.testing,
isInitialized: false,
init: function() {
if (!this.$) { this.$ = Ember.$; }
var eventDispatcher,
rootElement = get(this, 'rootElement');
this._super();
eventDispatcher = Ember.EventDispatcher.create({
rootElement: rootElement
});
this.createEventDispatcher();
set(this, 'eventDispatcher', eventDispatcher);
// Start off the number of deferrals at 1. This will be

@@ -95,4 +388,22 @@ // decremented by the Application's own `initialize` method.

this.waitForDOMContentLoaded();
if (this.autoinit) {
var self = this;
this.$().ready(function() {
if (self.isDestroyed || self.isInitialized) return;
self.initialize();
});
}
},
/** @private */
createEventDispatcher: function() {
var rootElement = get(this, 'rootElement'),
eventDispatcher = Ember.EventDispatcher.create({
rootElement: rootElement
});
set(this, 'eventDispatcher', eventDispatcher);
},
waitForDOMContentLoaded: function() {

@@ -138,11 +449,49 @@ this.deferReadiness();

router.get('postsController.router') // router
@method initialize
@param router {Ember.Router}
*/
initialize: function(router) {
var properties = Ember.A(Ember.keys(this)),
injections = get(this.constructor, 'injections'),
namespace = this, controller, name;
Ember.assert("Application initialize may only be call once", !this.isInitialized);
Ember.assert("Application not destroyed", !this.isDestroyed);
if (!router && Ember.Router.detect(namespace['Router'])) {
router = namespace['Router'].create();
router = this.setupRouter(router);
this.runInjections(router);
Ember.runLoadHooks('application', this);
this.isInitialized = true;
// At this point, any injections or load hooks that would have wanted
// to defer readiness have fired.
this.advanceReadiness();
return this;
},
/** @private */
runInjections: function(router) {
var injections = get(this.constructor, 'injections'),
graph = new Ember.DAG(),
namespace = this,
properties, i, injection;
for (i=0; i<injections.length; i++) {
injection = injections[i];
graph.addEdges(injection.name, injection.injection, injection.before, injection.after);
}
graph.topsort(function (vertex) {
var injection = vertex.value,
properties = Ember.A(Ember.keys(namespace));
properties.forEach(function(property) {
injection(namespace, router, property);
});
});
},
/** @private */
setupRouter: function(router) {
if (!router && Ember.Router.detect(this.Router)) {
router = this.Router.create();
this._createdRouter = router;

@@ -163,15 +512,3 @@ }

injections.forEach(function(injection) {
properties.forEach(function(property) {
injection[1](namespace, router, property);
});
});
Ember.runLoadHooks('application', this);
// At this point, any injections or load hooks that would have wanted
// to defer readiness have fired.
this.advanceReadiness();
return this;
return router;
},

@@ -189,4 +526,7 @@

router = get(this, 'router');
this.createApplicationView(router);
if (router && router instanceof Ember.Router) {

@@ -197,2 +537,38 @@ this.startRouting(router);

createApplicationView: function (router) {
var rootElement = get(this, 'rootElement'),
applicationViewOptions = {},
applicationViewClass = this.ApplicationView,
applicationTemplate = Ember.TEMPLATES.application,
applicationController, applicationView;
// don't do anything unless there is an ApplicationView or application template
if (!applicationViewClass && !applicationTemplate) return;
if (router) {
applicationController = get(router, 'applicationController');
if (applicationController) {
applicationViewOptions.controller = applicationController;
}
}
if (applicationTemplate) {
applicationViewOptions.template = applicationTemplate;
}
if (!applicationViewClass) {
applicationViewClass = Ember.View;
}
applicationView = applicationViewClass.create(applicationViewOptions);
this._createdApplicationView = applicationView;
if (router) {
set(router, 'applicationView', applicationView);
}
applicationView.appendTo(rootElement);
},
/**

@@ -203,17 +579,12 @@ @private

trigger a new call to `route` whenever the URL changes.
@method startRouting
@property router {Ember.Router}
*/
startRouting: function(router) {
var location = get(router, 'location'),
rootElement = get(this, 'rootElement'),
applicationController = get(router, 'applicationController');
var location = get(router, 'location');
Ember.assert("ApplicationView and ApplicationController must be defined on your application", (this.ApplicationView && applicationController) );
Ember.assert("You must have an application template or ApplicationView defined on your application", get(router, 'applicationView') );
Ember.assert("You must have an ApplicationController defined on your application", get(router, 'applicationController') );
var applicationView = this.ApplicationView.create({
controller: applicationController
});
this._createdApplicationView = applicationView;
applicationView.appendTo(rootElement);
router.route(location.getURL());

@@ -228,6 +599,7 @@ location.onUpdateURL(function(url) {

The call will be delayed until the DOM has become ready.
@event ready
*/
ready: Ember.K,
/** @private */
willDestroy: function() {

@@ -247,19 +619,10 @@ get(this, 'eventDispatcher').destroy();

injections: Ember.A(),
registerInjection: function(options) {
var injections = get(this, 'injections'),
before = options.before,
name = options.name,
injection = options.injection,
location;
registerInjection: function(injection) {
var injections = get(this, 'injections');
if (before) {
location = injections.find(function(item) {
if (item[0] === before) { return true; }
});
location = injections.indexOf(location);
} else {
location = get(injections, 'length');
}
Ember.assert("The injection '" + injection.name + "' has already been registered", !injections.findProperty('name', injection.name));
Ember.assert("An injection cannot be registered with both a before and an after", !(injection.before && injection.after));
Ember.assert("An injection cannot be registered without an injection function", Ember.canInvoke(injection, 'injection'));
injections.splice(location, 0, [name, injection]);
injections.push(injection);
}

@@ -271,7 +634,11 @@ });

injection: function(app, router, property) {
if (!router) { return; }
if (!/^[A-Z].*Controller$/.test(property)) { return; }
var name = property.charAt(0).toLowerCase() + property.substr(1),
controller = app[property].create();
controllerClass = app[property], controller;
if(!Ember.Object.detect(controllerClass)){ return; }
controller = app[property].create();
router.set(name, controller);

@@ -301,4 +668,11 @@

(function() {
/**
Ember Application
@module ember
@submodule ember-application
@requires ember-views, ember-states, ember-routing
*/
})();

56

debug.js

@@ -11,2 +11,13 @@ //

/**
Ember Debug
@module ember
@submodule ember-debug
*/
/**
@class Ember
*/
if ('undefined' === typeof Ember) {

@@ -36,11 +47,8 @@ Ember = {};

@static
@function
@param {String} desc
A description of the assertion. This will become the text of the Error
thrown if the assertion fails.
@method assert
@param {String} desc A description of the assertion. This will become
the text of the Error thrown if the assertion fails.
@param {Boolean} test
Must be truthy for the assertion to pass. If falsy, an exception will be
thrown.
@param {Boolean} test Must be truthy for the assertion to pass. If
falsy, an exception will be thrown.
*/

@@ -56,9 +64,6 @@ Ember.assert = function(desc, test) {

@static
@function
@param {String} message
A warning to display.
@param {Boolean} test
An optional boolean. If falsy, the warning will be displayed.
@method warn
@param {String} message A warning to display.
@param {Boolean} test An optional boolean. If falsy, the warning
will be displayed.
*/

@@ -77,9 +82,6 @@ Ember.warn = function(message, test) {

@static
@function
@param {String} message
A description of the deprecation.
@param {Boolean} test
An optional boolean. If falsy, the deprecation will be displayed.
@method deprecate
@param {String} message A description of the deprecation.
@param {Boolean} test An optional boolean. If falsy, the deprecation
will be displayed.
*/

@@ -129,9 +131,5 @@ Ember.deprecate = function(message, test) {

@static
@function
@param {String} message
A description of the deprecation.
@param {Function} func
The function to be deprecated.
@method deprecateFunc
@param {String} message A description of the deprecation.
@param {Function} func The function to be deprecated.
*/

@@ -138,0 +136,0 @@ Ember.deprecateFunc = function(message, func) {

@@ -14,9 +14,9 @@ //

(function() {
// ==========================================================================
// Project: Ember
// Copyright: ©2011 Strobe Inc. and contributors.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
/**
Ember
@module ember
*/
})();

@@ -6,3 +6,3 @@ {

"dependencies": {
"convoy": "~0.3",
"convoy": "latest",
"connect": "latest",

@@ -9,0 +9,0 @@ "ember": "latest",

@@ -7,3 +7,3 @@ {

"author": "Charles Jolley",
"version": "v1.0.0-pre.m1",
"version": "v1.0.0-pre.m2",
"dependencies": {

@@ -10,0 +10,0 @@ "handlebars": "~> 1.0.0-beta.6",

@@ -10,9 +10,5 @@

asset.body = [
"var templateSpec = " + Ember.Handlebars.precompile(data) + ";",
"var Utils = Ember.Handlebars.Utils",
"module.exports = function(context, options) { ",
" options = options || {};",
" return templateSpec.call(Utils, Ember.Handlebars, context,",
" options.helpers, options.partials, options.data);",
"};"].join("\n");
"var templateSpec = "+ Ember.Handlebars.precompile(data).toString() +";",
"module.exports = Ember.Handlebars.VM.template(templateSpec);"
].join("\n");
done();

@@ -19,0 +15,0 @@ });

@@ -61,2 +61,7 @@ //

(function() {
/**
@module ember
@submodule ember-routing
*/
var get = Ember.get;

@@ -91,3 +96,4 @@

/**
@class
@class Routable
@namespace Ember
@extends Ember.Mixin

@@ -98,3 +104,3 @@ */

var redirection;
this.on('connectOutlets', this, this.stashContext);
this.on('setup', this, this.stashContext);

@@ -120,2 +126,6 @@ if (redirection = get(this, 'redirectsTo')) {

setup: function() {
return this.connectOutlets.apply(this, arguments);
},
/**

@@ -127,4 +137,10 @@ @private

demand.
@method stashContext
@param manager {Ember.StateManager}
@param context
*/
stashContext: function(manager, context) {
this.router = manager;
var serialized = this.serialize(manager, context);

@@ -148,2 +164,6 @@ Ember.assert('serialize must return a hash', !serialized || typeof serialized === 'object');

In general, this will update the browser's URL.
@method updateRoute
@param manager {Ember.StateManager}
@param location {Ember.Location}
*/

@@ -165,2 +185,6 @@ updateRoute: function(manager, location) {

not the original context object.
@method absoluteRoute
@param manager {Ember.StateManager}
@param hash {Hash}
*/

@@ -199,6 +223,9 @@ absoluteRoute: function(manager, hash) {

property. This heuristic may change.
@property isRoutable
@type Boolean
*/
isRoutable: Ember.computed(function() {
return typeof get(this, 'route') === 'string';
}).cacheable(),
}),

@@ -209,2 +236,5 @@ /**

Determine if this is the last routeable state
@property isLeafRoute
@type Boolean
*/

@@ -214,3 +244,3 @@ isLeafRoute: Ember.computed(function() {

return !get(this, 'childStates').findProperty('isRoutable');
}).cacheable(),
}),

@@ -222,2 +252,5 @@ /**

string property.
@property routeMatcher
@type Ember._RouteMatcher
*/

@@ -229,3 +262,3 @@ routeMatcher: Ember.computed(function() {

}
}).cacheable(),
}),

@@ -237,2 +270,5 @@ /**

a context.
@property hasContext
@type Boolean
*/

@@ -244,3 +280,3 @@ hasContext: Ember.computed(function() {

}
}).cacheable(),
}),

@@ -253,2 +289,5 @@ /**

specified as a String.
@property modelClass
@type Ember.Object
*/

@@ -259,7 +298,7 @@ modelClass: Ember.computed(function() {

if (typeof modelType === 'string') {
return Ember.get(window, modelType);
return Ember.get(Ember.lookup, modelType);
} else {
return modelType;
}
}).cacheable(),
}),

@@ -279,2 +318,5 @@ /**

used here.
@method modelClassFor
@param namespace {Ember.Namespace}
*/

@@ -320,2 +362,6 @@ modelClassFor: function(namespace) {

fine with any class that has a `find` method.
@method deserialize
@param manager {Ember.StateManager}
@param params {Hash}
*/

@@ -342,2 +388,6 @@ deserialize: function(manager, params) {

{ blog_post_id: 12 }
@method serialize
@param manager {Ember.StateManager}
@param context
*/

@@ -361,2 +411,5 @@ serialize: function(manager, context) {

@private
@method resolvePath
@param manager {Ember.StateManager}
@param path {String}
*/

@@ -416,2 +469,6 @@ resolvePath: function(manager, path) {

on the state whose path is `/posts` with the path `/2/comments`.
@method routePath
@param manager {Ember.StateManager}
@param path {String}
*/

@@ -448,2 +505,6 @@ routePath: function(manager, path) {

state of the state it will eventually move into.
@method unroutePath
@param router {Ember.Router}
@param path {String}
*/

@@ -486,2 +547,49 @@ unroutePath: function(router, path) {

parentTemplate: Ember.computed(function() {
var state = this, parentState, template;
while (state = get(state, 'parentState')) {
if (template = get(state, 'template')) {
return template;
}
}
return 'application';
}),
_template: Ember.computed(function(key, value) {
if (arguments.length > 1) { return value; }
if (value = get(this, 'template')) {
return value;
}
// If no template was explicitly supplied convert
// the class name into a template name. For example,
// App.PostRoute will return `post`.
var className = this.constructor.toString(), baseName;
if (/^[^\[].*Route$/.test(className)) {
baseName = className.match(/([^\.]+\.)*([^\.]+)/)[2];
baseName = baseName.replace(/Route$/, '');
return baseName.charAt(0).toLowerCase() + baseName.substr(1);
}
}),
render: function(options) {
options = options || {};
var template = options.template || get(this, '_template'),
parentTemplate = options.into || get(this, 'parentTemplate'),
controller = get(this.router, parentTemplate + "Controller");
var viewName = Ember.String.classify(template) + "View",
viewClass = get(get(this.router, 'namespace'), viewName);
viewClass = (viewClass || Ember.View).extend({
templateName: template
});
controller.set('view', viewClass.create());
},
/**

@@ -491,2 +599,6 @@ The `connectOutlets` event will be triggered once a

route's context.
@event connectOutlets
@param router {Ember.Router}
@param [context*]
*/

@@ -498,2 +610,4 @@ connectOutlets: Ember.K,

URL changes due to the back/forward button
@event navigateAway
*/

@@ -509,5 +623,11 @@ navigateAway: Ember.K

/**
@class
@module ember
@submodule ember-routing
*/
/**
@class Route
@namespace Ember
@extends Ember.State
@extends Ember.Routable
@uses Ember.Routable
*/

@@ -525,2 +645,8 @@ Ember.Route = Ember.State.extend(Ember.Routable);

/**
@class _RouteMatcher
@namespace Ember
@private
@extends Ember.Object
*/
Ember._RouteMatcher = Ember.Object.extend({

@@ -584,5 +710,10 @@ state: null,

(function() {
/**
@module ember
@submodule ember-routing
*/
var get = Ember.get, set = Ember.set;
/**
/*
This file implements the `location` API used by Ember's router.

@@ -599,8 +730,6 @@

TODO: This, as well as the Ember.Location documentation below, should
perhaps be moved so that it's visible in the JsDoc output.
TODO: This should perhaps be moved so that it's visible in the doc output.
*/
/**
@class
Ember.Location returns an instance of the correct implementation of

@@ -611,2 +740,6 @@ the `location` API.

particular implementation.
@class Location
@namespace Ember
@static
*/

@@ -636,7 +769,10 @@ Ember.Location = {

(function() {
/**
@module ember
@submodule ember-routing
*/
var get = Ember.get, set = Ember.set;
/**
@class
Ember.NoneLocation does not interact with the browser. It is useful for

@@ -647,6 +783,7 @@ testing, or when you need to manage state with your Router, but temporarily

@class NoneLocation
@namespace Ember
@extends Ember.Object
*/
Ember.NoneLocation = Ember.Object.extend(
/** @scope Ember.NoneLocation.prototype */ {
Ember.NoneLocation = Ember.Object.extend({
path: '',

@@ -681,7 +818,10 @@

(function() {
/**
@module ember
@submodule ember-routing
*/
var get = Ember.get, set = Ember.set;
/**
@class
Ember.HashLocation implements the location API using the browser's

@@ -691,8 +831,8 @@ hash. At present, it relies on a hashchange event existing in the

@class HashLocation
@namespace Ember
@extends Ember.Object
*/
Ember.HashLocation = Ember.Object.extend(
/** @scope Ember.HashLocation.prototype */ {
Ember.HashLocation = Ember.Object.extend({
/** @private */
init: function() {

@@ -706,2 +846,4 @@ set(this, 'location', get(this, 'location') || window.location);

Returns the current `location.hash`, minus the '#' at the front.
@method getURL
*/

@@ -718,2 +860,5 @@ getURL: function() {

`HashLocation`.
@method setURL
@param path {String}
*/

@@ -731,2 +876,5 @@ setURL: function(path) {

button, but not after `setURL` is invoked.
@method onUpdateURL
@param callback {Function}
*/

@@ -755,2 +903,5 @@ onUpdateURL: function(callback) {

to generate a URL based on an event.
@method formatURL
@param url {String}
*/

@@ -761,3 +912,2 @@ formatURL: function(url) {

/** @private */
willDestroy: function() {

@@ -777,32 +927,44 @@ var guid = Ember.guidFor(this);

(function() {
/**
@module ember
@submodule ember-routing
*/
var get = Ember.get, set = Ember.set;
var popstateReady = false;
/**
@class
Ember.HistoryLocation implements the location API using the browser's
history.pushState API.
@class HistoryLocation
@namespace Ember
@extends Ember.Object
*/
Ember.HistoryLocation = Ember.Object.extend(
/** @scope Ember.HistoryLocation.prototype */ {
Ember.HistoryLocation = Ember.Object.extend({
/** @private */
init: function() {
set(this, 'location', get(this, 'location') || window.location);
set(this, '_initialURL', get(this, 'location').pathname);
this.initState();
},
/**
Will be pre-pended to path upon state change
*/
rootURL: '/',
@private
Used to set state on first call to setURL
@method initState
*/
initState: function() {
this.replaceState(get(this, 'location').pathname);
set(this, 'history', window.history);
},
/**
@private
Will be pre-pended to path upon state change
Used to give history a starting reference
*/
_initialURL: null,
@property rootURL
@default '/'
*/
rootURL: '/',

@@ -813,2 +975,4 @@ /**

Returns the current `location.pathname`.
@method getURL
*/

@@ -823,11 +987,12 @@ getURL: function() {

Uses `history.pushState` to update the url without a page reload.
@method setURL
@param path {String}
*/
setURL: function(path) {
var state = window.history.state,
initialURL = get(this, '_initialURL');
path = this.formatURL(path);
path = this.formatPath(path);
if ((initialURL !== path && !state) || (state && state.path !== path)) {
window.history.pushState({ path: path }, null, path);
if (this.getState().path !== path) {
popstateReady = true;
this.pushState(path);
}

@@ -837,2 +1002,37 @@ },

/**
@private
Get the current `history.state`
@method getState
*/
getState: function() {
return get(this, 'history').state;
},
/**
@private
Pushes a new state
@method pushState
@param path {String}
*/
pushState: function(path) {
window.history.pushState({ path: path }, null, path);
},
/**
@private
Replaces the current state
@method replaceState
@param path {String}
*/
replaceState: function(path) {
window.history.replaceState({ path: path }, null, path);
},
/**
@private

@@ -842,2 +1042,5 @@

history changes, including using forward and back buttons.
@method onUpdateURL
@param callback {Function}
*/

@@ -848,2 +1051,5 @@ onUpdateURL: function(callback) {

Ember.$(window).bind('popstate.ember-location-'+guid, function(e) {
if(!popstateReady) {
return;
}
callback(location.pathname);

@@ -856,25 +1062,17 @@ });

returns the given path appended to rootURL
*/
formatPath: function(path) {
Used when using `{{action}}` helper. The url is always appended to the rootURL.
@method formatURL
@param url {String}
*/
formatURL: function(url) {
var rootURL = get(this, 'rootURL');
if (path !== '') {
if (url !== '') {
rootURL = rootURL.replace(/\/$/, '');
}
return rootURL + path;
return rootURL + url;
},
/**
@private
Used when using {{action}} helper. Since no formatting
is required we just return the url given.
*/
formatURL: function(url) {
return url;
},
/** @private */
willDestroy: function() {

@@ -900,2 +1098,7 @@ var guid = Ember.guidFor(this);

(function() {
/**
@module ember
@submodule ember-routing
*/
var get = Ember.get, set = Ember.set;

@@ -913,4 +1116,2 @@

/**
@class
`Ember.Router` is the subclass of `Ember.StateManager` responsible for providing URL-based

@@ -1208,8 +1409,10 @@ application state detection. The `Ember.Router` instance of an application detects the browser URL

App = Ember.Application.create({
FooController: Ember.Object.create(Ember.ControllerMixin),
Router: Ember.Router.extend({ ... })
});
``` javascript
App = Ember.Application.create({
FooController: Ember.Object.create(Ember.ControllerMixin),
Router: Ember.Router.extend({ ... })
});
App.get('router.fooController'); // instance of App.FooController
App.get('router.fooController'); // instance of App.FooController
```

@@ -1227,27 +1430,31 @@ The controller singletons will have their `namespace` property set to the application and their `target`

App = Ember.Application.create({
Router: Ember.Router.extend({
root: Ember.Route.extend({
aRoute: Ember.Route.extend({
route: '/',
anActionOnTheRouter: function(router, context) {
router.transitionTo('anotherState', context);
}
})
anotherState: Ember.Route.extend({
route: '/differentUrl',
connectOutlets: function(router, context) {
``` javascript
App = Ember.Application.create({
Router: Ember.Router.extend({
root: Ember.Route.extend({
aRoute: Ember.Route.extend({
route: '/',
anActionOnTheRouter: function(router, context) {
router.transitionTo('anotherState', context);
}
})
anotherState: Ember.Route.extend({
route: '/differentUrl',
connectOutlets: function(router, context) {
}
})
})
}
})
});
App.initialize();
})
})
});
App.initialize();
```
The following template:
<script type="text/x-handlebars" data-template-name="aView">
<h1><a {{action anActionOnTheRouter}}>{{title}}</a></h1>
</script>
``` handlebars
<script type="text/x-handlebars" data-template-name="aView">
<h1><a {{action anActionOnTheRouter}}>{{title}}</a></h1>
</script>
```

@@ -1261,12 +1468,15 @@ Will delegate `click` events on the rendered `h1` to the application's router instance. In this case the

<script type="text/x-handlebars" data-template-name="photos">
{{#each photo in controller}}
<h1><a {{action showPhoto photo}}>{{title}}</a></h1>
{{/each}}
</script>
``` handlebars
<script type="text/x-handlebars" data-template-name="photos">
{{#each photo in controller}}
<h1><a {{action showPhoto photo}}>{{title}}</a></h1>
{{/each}}
</script>
```
See Handlebars.helpers.action for additional usage examples.
See `Handlebars.helpers.action` for additional usage examples.
## Changing View Hierarchy in Response To State Change
Changes in application state that change the URL should be accompanied by associated changes in view

@@ -1276,21 +1486,23 @@ hierarchy. This can be accomplished by calling 'connectOutlet' on the injected controller singletons from

App = Ember.Application.create({
OneController: Ember.ObjectController.extend(),
OneView: Ember.View.extend(),
``` javascript
App = Ember.Application.create({
OneController: Ember.ObjectController.extend(),
OneView: Ember.View.extend(),
AnotherController: Ember.ObjectController.extend(),
AnotherView: Ember.View.extend(),
AnotherController: Ember.ObjectController.extend(),
AnotherView: Ember.View.extend(),
Router: Ember.Router.extend({
root: Ember.Route.extend({
aRoute: Ember.Route.extend({
route: '/',
connectOutlets: function(router, context) {
router.get('oneController').connectOutlet('another');
},
})
})
Router: Ember.Router.extend({
root: Ember.Route.extend({
aRoute: Ember.Route.extend({
route: '/',
connectOutlets: function(router, context) {
router.get('oneController').connectOutlet('another');
},
})
});
App.initialize();
})
})
});
App.initialize();
```

@@ -1307,2 +1519,4 @@

@class Router
@namespace Ember
@extends Ember.StateManager

@@ -1314,3 +1528,4 @@ */

/**
@property {String}
@property initialState
@type String
@default 'root'

@@ -1325,5 +1540,8 @@ */

* 'hash': Uses URL fragment identifiers (like #/blog/1) for routing.
* 'history': Uses the browser's history.pushstate API for routing. Only works in
modern browsers with pushstate support.
* 'none': Does not read or set the browser URL, but still allows for
routing to happen. Useful for testing.
@property location
@type String

@@ -1338,2 +1556,3 @@ @default 'hash'

@property rootURL
@type String

@@ -1345,10 +1564,2 @@ @default '/'

/**
On router, transitionEvent should be called connectOutlets
@property {String}
@default 'connectOutlets'
*/
transitionEvent: 'connectOutlets',
transitionTo: function() {

@@ -1367,2 +1578,3 @@ this.abortRoutingPromises();

try {
path = path.replace(get(this, 'rootURL'), '');
path = path.replace(/^(?=[^\/])/, "/");

@@ -1399,4 +1611,4 @@

Ember.assert(Ember.String.fmt("Could not find route with path '%@'", [path]), !!state);
Ember.assert("To get a URL for a state, it must have a `route` property.", !!get(state, 'routeMatcher'));
Ember.assert(Ember.String.fmt("Could not find route with path '%@'", [path]), state);
Ember.assert(Ember.String.fmt("To get a URL for the state '%@', it must have a `route` property.", [path]), get(state, 'routeMatcher'));

@@ -1414,7 +1626,7 @@ var location = get(this, 'location'),

Ember.assert(Ember.String.fmt("You must specify a target state for event '%@' in order to link to it in the current state '%@'.", [eventName, get(currentState, 'path')]), !!targetStateName);
Ember.assert(Ember.String.fmt("You must specify a target state for event '%@' in order to link to it in the current state '%@'.", [eventName, get(currentState, 'path')]), targetStateName);
var targetState = this.findStateByPath(currentState, targetStateName);
Ember.assert("Your target state name " + targetStateName + " for event " + eventName + " did not resolve to a state", !!targetState);
Ember.assert("Your target state name " + targetStateName + " for event " + eventName + " did not resolve to a state", targetState);

@@ -1426,3 +1638,2 @@ var hash = this.serializeRecursively(targetState, contexts, {});

/** @private */
serializeRecursively: function(state, contexts, hash) {

@@ -1447,5 +1658,2 @@ var parentState,

/**
@private
*/
handleStatePromises: function(states, complete) {

@@ -1480,4 +1688,22 @@ this.abortRoutingPromises();

/** @private */
moveStatesIntoRoot: function() {
this.root = Ember.Route.extend();
for (var name in this) {
if (name === "constructor") { continue; }
var state = this[name];
if (state instanceof Ember.Route || Ember.Route.detect(state)) {
this.root[name] = state;
delete this[name];
}
}
},
init: function() {
if (!this.root) {
this.moveStatesIntoRoot();
}
this._super();

@@ -1494,5 +1720,19 @@

}
this.assignRouter(this, this);
},
/** @private */
assignRouter: function(state, router) {
state.router = router;
var childStates = state.states;
if (childStates) {
for (var stateName in childStates) {
if (!childStates.hasOwnProperty(stateName)) { continue; }
this.assignRouter(childStates[stateName], router);
}
}
},
willDestroy: function() {

@@ -1508,9 +1748,11 @@ get(this, 'location').destroy();

(function() {
// ==========================================================================
// Project: Ember Routing
// Copyright: ©2012 Tilde Inc. and contributors.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
/**
Ember Routing
@module ember
@submodule ember-routing
@requires ember-states
*/
})();

@@ -12,5 +12,11 @@ //

/**
@class
@module ember
@submodule ember-states
*/
/**
@class State
@namespace Ember
@extends Ember.Object
@uses Ember.Evented
*/

@@ -24,2 +30,3 @@ Ember.State = Ember.Object.extend(Ember.Evented,

@property parentState
@type Ember.State

@@ -33,2 +40,3 @@ */

@property name
@type String

@@ -41,4 +49,4 @@ */

@property path
@type String
@readOnly
*/

@@ -54,3 +62,3 @@ path: Ember.computed(function() {

return path;
}).property().cacheable(),
}).property(),

@@ -62,2 +70,5 @@ /**

also call methods with the given name.
@method trigger
@param name
*/

@@ -71,3 +82,2 @@ trigger: function(name) {

/** @private */
init: function() {

@@ -112,3 +122,2 @@ var states = get(this, 'states'), foundStates;

/** @private */
setupChild: function(states, name, value) {

@@ -129,2 +138,3 @@ if (!value) { return false; }

states[name] = value;
return value;
}

@@ -149,2 +159,3 @@ },

@property isLeaf
@type Boolean

@@ -154,3 +165,3 @@ */

return !get(this, 'childStates').length;
}).cacheable(),
}),

@@ -160,2 +171,5 @@ /**

By default we assume all states take contexts.
@property hasContext
@default true
*/

@@ -167,3 +181,3 @@ hasContext: true,

@event
@event setup
@param {Ember.StateManager} manager

@@ -178,3 +192,3 @@ @param context

@event
@event enter
@param {Ember.StateManager} manager

@@ -187,3 +201,3 @@ */

@event
@event exit
@param {Ember.StateManager} manager

@@ -194,52 +208,54 @@ */

var Event = Ember.$ && Ember.$.Event;
Ember.State.reopenClass({
Ember.State.reopenClass(
/** @scope Ember.State */{
/**
@static
Creates an action function for transitioning to the named state while preserving context.
Creates an action function for transitioning to the named state while preserving context.
The following example StateManagers are equivalent:
The following example StateManagers are equivalent:
aManager = Ember.StateManager.create({
stateOne: Ember.State.create({
changeToStateTwo: Ember.State.transitionTo('stateTwo')
}),
stateTwo: Ember.State.create({})
})
aManager = Ember.StateManager.create({
stateOne: Ember.State.create({
changeToStateTwo: Ember.State.transitionTo('stateTwo')
}),
stateTwo: Ember.State.create({})
})
bManager = Ember.StateManager.create({
stateOne: Ember.State.create({
changeToStateTwo: function(manager, context){
manager.transitionTo('stateTwo', context)
}
}),
stateTwo: Ember.State.create({})
})
bManager = Ember.StateManager.create({
stateOne: Ember.State.create({
changeToStateTwo: function(manager, context){
manager.transitionTo('stateTwo', context)
}
}),
stateTwo: Ember.State.create({})
})
@method transitionTo
@static
@param {String} target
*/
@param {String} target
*/
transitionTo: function(target) {
var event = function(stateManager, context) {
if (Event && context instanceof Event) {
if (context.hasOwnProperty('context')) {
context = context.context;
} else {
// If we received an event and it doesn't contain
// a context, don't pass along a superfluous
// context to the target of the event.
return stateManager.transitionTo(target);
var transitionFunction = function(stateManager, contextOrEvent) {
var contexts = [], transitionArgs,
Event = Ember.$ && Ember.$.Event;
if (contextOrEvent && (Event && contextOrEvent instanceof Event)) {
if (contextOrEvent.hasOwnProperty('contexts')) {
contexts = contextOrEvent.contexts.slice();
}
}
else {
contexts = [].slice.call(arguments, 1);
}
stateManager.transitionTo(target, context);
contexts.unshift(target);
stateManager.transitionTo.apply(stateManager, contexts);
};
event.transitionTarget = target;
transitionFunction.transitionTarget = target;
return event;
return transitionFunction;
}
});

@@ -252,7 +268,10 @@

(function() {
/**
@module ember
@submodule ember-states
*/
var get = Ember.get, set = Ember.set, fmt = Ember.String.fmt;
var arrayForEach = Ember.ArrayPolyfills.forEach;
/**
@private
A Transition takes the enter, exit and resolve states and normalizes

@@ -263,2 +282,5 @@ them:

* adds in `initialState`s
@class Transition
@private
*/

@@ -275,4 +297,2 @@ var Transition = function(raw) {

/**
@private
Normalize the passed in enter, exit and resolve states.

@@ -282,2 +302,3 @@

@method normalize
@param {Ember.StateManager} manager the state manager running the transition

@@ -294,4 +315,2 @@ @param {Array} contexts a list of contexts passed into `transitionTo`

/**
@private
Match each of the contexts passed to `transitionTo` to a state.

@@ -301,2 +320,3 @@ This process may also require adding additional enter and exit

@method matchContextsToStates
@param {Array} contexts a list of contexts passed into `transitionTo`

@@ -374,5 +394,5 @@ */

/**
@private
Add any `initialState`s to the list of enter states.
Add any `initialState`s to the list of enter states.
@method addInitialStates
*/

@@ -395,4 +415,2 @@ addInitialStates: function() {

/**
@private
Remove any states that were added because the number of contexts

@@ -402,2 +420,3 @@ exceeded the number of explicit enter states, but the context has

@method removeUnchangedContexts
@param {Ember.StateManager} manager passed in to look up the last

@@ -425,4 +444,2 @@ context for a states

/**
@class
StateManager is part of Ember's implementation of a finite state machine. A StateManager

@@ -791,10 +808,16 @@ instance manages a number of properties that are instances of `Ember.State`,

})
@class StateManager
@namespace Ember
@extends Ember.State
**/
Ember.StateManager = Ember.State.extend(
/** @scope Ember.StateManager.prototype */ {
Ember.StateManager = Ember.State.extend({
/**
@private
/**
When creating a new statemanager, look for a default state to transition
into. This state can either be named `start`, or can be specified using the
`initialState` property.
@method init
*/

@@ -842,4 +865,4 @@ init: function() {

@property currentState
@type Ember.State
@readOnly
*/

@@ -849,5 +872,17 @@ currentState: null,

/**
The path of the current state. Returns a string representation of the current
state.
@property currentPath
@type String
*/
currentPath: Ember.computed('currentState', function() {
return get(this, 'currentState.path');
}),
/**
The name of transitionEvent that this stateManager will dispatch
@property {String}
@property transitionEvent
@type String
@default 'setup'

@@ -862,2 +897,3 @@ */

@property errorOnUnhandledEvents
@type Boolean

@@ -868,11 +904,21 @@ @default true

send: function(event, context) {
send: function(event) {
var contexts, sendRecursiveArguments;
Ember.assert('Cannot send event "' + event + '" while currentState is ' + get(this, 'currentState'), get(this, 'currentState'));
return this.sendRecursively(event, get(this, 'currentState'), context);
contexts = [].slice.call(arguments, 1);
sendRecursiveArguments = contexts;
sendRecursiveArguments.unshift(event, get(this, 'currentState'));
return this.sendRecursively.apply(this, sendRecursiveArguments);
},
sendRecursively: function(event, currentState, context) {
sendRecursively: function(event, currentState) {
var log = this.enableLogging,
action = currentState[event];
action = currentState[event],
contexts, sendRecursiveArguments, actionArguments;
contexts = [].slice.call(arguments, 2);
// Test to see if the action is a method that

@@ -886,7 +932,15 @@ // can be invoked. Don't blindly check just for

if (log) { Ember.Logger.log(fmt("STATEMANAGER: Sending event '%@' to state %@.", [event, get(currentState, 'path')])); }
return action.call(currentState, this, context);
actionArguments = contexts;
actionArguments.unshift(this);
return action.apply(currentState, actionArguments);
} else {
var parentState = get(currentState, 'parentState');
if (parentState) {
return this.sendRecursively(event, parentState, context);
sendRecursiveArguments = contexts;
sendRecursiveArguments.unshift(event, parentState);
return this.sendRecursively.apply(this, sendRecursiveArguments);
} else if (get(this, 'errorOnUnhandledEvent')) {

@@ -913,5 +967,6 @@ throw new Ember.Error(this.toString() + " could not respond to event " + event + " in state " + get(this, 'currentState.path') + ".");

@method getStateByPath
@param {Ember.State} root the state to start searching from
@param {String} path the state path to follow
@returns {Ember.State} the state at the end of the path
@return {Ember.State} the state at the end of the path
*/

@@ -922,3 +977,3 @@ getStateByPath: function(root, path) {

for (var i=0, l=parts.length; i<l; i++) {
for (var i=0, len=parts.length; i<len; i++) {
state = get(get(state, 'states'), parts[i]);

@@ -943,28 +998,30 @@ if (!state) { break; }

/**
@private
A state stores its child states in its `states` hash.
This code takes a path like `posts.show` and looks
up `origin.states.posts.states.show`.
up `root.states.posts.states.show`.
It returns a list of all of the states from the
origin, which is the list of states to call `enter`
root, which is the list of states to call `enter`
on.
@method getStatesInPath
@param root
@param path
*/
findStatesByPath: function(origin, path) {
getStatesInPath: function(root, path) {
if (!path || path === "") { return undefined; }
var r = path.split('.'),
ret = [];
var parts = path.split('.'),
result = [],
states,
state;
for (var i=0, len = r.length; i < len; i++) {
var states = get(origin, 'states');
for (var i=0, len=parts.length; i<len; i++) {
states = get(root, 'states');
if (!states) { return undefined; }
var s = get(states, r[i]);
if (s) { origin = s; ret.push(s); }
state = get(states, parts[i]);
if (state) { root = state; result.push(state); }
else { return undefined; }
}
return ret;
return result;
},

@@ -1001,3 +1058,3 @@

var enterStates = this.findStatesByPath(currentState, path),
var enterStates = this.getStatesInPath(currentState, path),
exitStates = [],

@@ -1044,3 +1101,3 @@ resolveState = currentState;

if (!resolveState) {
enterStates = this.findStatesByPath(this, path);
enterStates = this.getStatesInPath(this, path);
if (!enterStates) {

@@ -1051,3 +1108,3 @@ Ember.assert('Could not find state for path: "'+path+'"');

}
enterStates = this.findStatesByPath(resolveState, path);
enterStates = this.getStatesInPath(resolveState, path);
}

@@ -1142,9 +1199,11 @@

(function() {
// ==========================================================================
// Project: Ember Statecharts
// Copyright: ©2011 Living Social Inc. and contributors.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
/**
Ember States
@module ember
@submodule ember-states
@requires ember-runtime
*/
})();

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc