language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | emberjs | ember.js | 7f2fa488945b3dfb8ebc91560ca6137cee22def0.json | fix nested yield | packages/ember-views/lib/views/component.js | @@ -112,6 +112,7 @@ Ember.Component = Ember.View.extend(Ember.TargetActionSupport, {
view.appendChild(Ember.View, {
isVirtual: true,
tagName: '',
+ _contextView: parentView,
template: get(this, 'template'),
context: get(parentView, 'context'),
controller: get(parentView, 'controller'), | true |
Other | emberjs | ember.js | 7f2fa488945b3dfb8ebc91560ca6137cee22def0.json | fix nested yield | packages/ember-views/tests/views/component_test.js | @@ -101,4 +101,4 @@ test("Calling sendAction on a component with a context", function() {
component.sendAction('playing', testContext);
strictEqual(actionContext, testContext, "context was sent with the action");
-});
\ No newline at end of file
+}); | true |
Other | emberjs | ember.js | 7c1054cd099831c5806f2e330441664a8f403def.json | Remove stupid suggestion in TODO.
Removing items during willChange prevents run-time coalescing. | packages/ember-runtime/lib/computed/reduce_computed.js | @@ -278,8 +278,6 @@ DependentArraysObserver.prototype = {
Ember.run.once(this, 'flushChanges');
},
- // TODO: it probably makes more sense to remove the item during `willChange`
- // and add it back (with the new value) during `didChange`
flushChanges: function() {
var changedItems = this.changedItems, key, c, changeMeta;
for (key in changedItems) { | false |
Other | emberjs | ember.js | 9cebfdb39d54963a985b0b42d7ee1c8d794daee8.json | Add route name in Route#model hook assertion | packages/ember-routing/lib/system/route.js | @@ -558,7 +558,7 @@ Ember.Route = Ember.Object.extend(Ember.ActionHandler, {
var modelClass = this.container.lookupFactory('model:' + name);
var namespace = get(this, 'router.namespace');
- Ember.assert("You used the dynamic segment " + name + "_id in your route, but " + namespace + "." + classify(name) + " did not exist and you did not override your route's `model` hook.", modelClass);
+ Ember.assert("You used the dynamic segment " + name + "_id in your route "+ this.routeName + ", but " + namespace + "." + classify(name) + " did not exist and you did not override your route's `model` hook.", modelClass);
return modelClass.find(value);
},
| false |
Other | emberjs | ember.js | a91ecaa646bffa9390f17a9687e9e12a7b27b5c5.json | Add examples for an Ember.Route action handler
- add example for `this` inside action handler
- add example for _super inside action handler
- add example for bubbling action handling via returning true | packages/ember-routing/lib/system/route.js | @@ -76,18 +76,81 @@ Ember.Route = Ember.Object.extend(Ember.ActionHandler, {
this.send('playMusic');
```
+ Within a route's action handler, the value of the `this` context
+ is the Route object:
+
+ ```js
+ App.SongRoute = Ember.Route.extend({
+ actions: {
+ myAction: function() {
+ this.controllerFor("song");
+ this.transitionTo("other.route");
+ ...
+ }
+ }
+ });
+ ```
+
It is also possible to call `this._super()` from within an
- action handler if it overrides a handle defined on a parent
- class or mixin.
+ action handler if it overrides a handler defined on a parent
+ class or mixin:
- Within a route's action handler, the value of the `this` context
- is the Route object.
+ Take for example the following routes:
+
+ ```js
+ App.DebugRoute = Ember.Mixin.create({
+ actions: {
+ debugRouteInformation: function() {
+ console.debug("trololo");
+ }
+ }
+ });
+
+ App.AnnoyingDebugRoute = Ember.Route.extend(App.DebugRoute, {
+ actions: {
+ debugRouteInformation: function() {
+ // also call the debugRouteInformation of mixed in App.DebugRoute
+ this._super();
+
+ // show additional annoyance
+ window.alert(...);
+ }
+ }
+ });
+ ```
## Bubbling
By default, an action will stop bubbling once a handler defined
on the `actions` hash handles it. To continue bubbling the action,
- you must return `true` from the handler.
+ you must return `true` from the handler:
+
+ ```js
+ App.Router.map(function() {
+ this.resource("album", function() {
+ this.route("song");
+ });
+ });
+
+ App.AlbumRoute = Ember.Route.extend({
+ actions: {
+ startPlaying: function() {
+ }
+ }
+ });
+
+ App.AlbumSongRoute = Ember.Route.extend({
+ actions: {
+ startPlaying: function() {
+ // ...
+
+ if (actionShouldAlsoBeTriggeredOnParentRoute) {
+ return true;
+ }
+ }
+ }
+ });
+ ```
## Built-in actions
| false |
Other | emberjs | ember.js | ecc80519ed8f7e758d0e91ba8804c08060858e35.json | Update Gemfile.lock for latest ember-dev | Gemfile.lock | @@ -1,6 +1,6 @@
GIT
remote: https://github.com/emberjs/ember-dev.git
- revision: 8ba4efd40d6524d3bd99b662043ac298b27178ea
+ revision: e847d56ee6aa86076471bce65b3505f72682013c
branch: master
specs:
ember-dev (0.1) | false |
Other | emberjs | ember.js | 64cf3a5f18788805c5329e1241bc2648de99cecc.json | Update Gemfile.lock for latest ember-dev | Gemfile.lock | @@ -1,6 +1,6 @@
GIT
remote: https://github.com/emberjs/ember-dev.git
- revision: 8ba4efd40d6524d3bd99b662043ac298b27178ea
+ revision: e847d56ee6aa86076471bce65b3505f72682013c
branch: master
specs:
ember-dev (0.1) | false |
Other | emberjs | ember.js | ba554752ffb83fc21bc8ecb66ac593fcdf6f7a43.json | remove deprecated function (prepare 1.0) | packages/ember-runtime/lib/mixins/evented.js | @@ -116,11 +116,6 @@ Ember.Evented = Ember.Mixin.create({
Ember.sendEvent(this, name, args);
},
- fire: function(name) {
- Ember.deprecate("Ember.Evented#fire() has been deprecated in favor of trigger() for compatibility with jQuery. It will be removed in 1.0. Please update your code to call trigger() instead.");
- this.trigger.apply(this, arguments);
- },
-
/**
Cancels subscription for given name, target, and method.
| false |
Other | emberjs | ember.js | f0c90f83c5f1da1541e0516331a64ae0b96f76d5.json | Run dist before publishing builds | Rakefile | @@ -156,7 +156,7 @@ namespace :release do
task :deploy => ['ember:release:deploy', 'starter_kit:deploy', 'website:deploy']
end
-task :publish_build do
+task :publish_build => :dist do
root = File.dirname(__FILE__) + '/dist/'
EmberDev::Publish.to_s3({
:access_key_id => ENV['S3_ACCESS_KEY_ID'], | false |
Other | emberjs | ember.js | e1d9534a6440310b3c18d824573e2a2a894b388d.json | Update api docs for {{textarea}}
- make them similar to {{input}}
- provide extended example to show how easy implementing a one way and
two way binding on a textarea can be | packages/ember-handlebars/lib/controls.js | @@ -28,7 +28,7 @@ function normalizeHash(hash, hashTypes) {
## Use as text field
An `{{input}}` with no `type` or a `type` of `text` will render an HTML text input.
The following HTML attributes can be set via the helper:
-
+
* `value`
* `size`
* `name`
@@ -41,7 +41,7 @@ function normalizeHash(hash, hashTypes) {
When set to a quoted string, these values will be directly applied to the HTML
element. When left unquoted, these values will be bound to a property on the
template's current rendering context (most typically a controller instance).
-
+
Unbound:
```handlebars
@@ -60,15 +60,15 @@ function normalizeHash(hash, hashTypes) {
entryNotAllowed: true
});
```
-
+
```handlebars
{{input type="text" value=firstName disabled=entryNotAllowed size="50"}}
```
```html
<input type="text" value="Stanley" disabled="disabled" size="50"/>
```
-
+
### Extension
Internally, `{{input type="text"}}` creates an instance of `Ember.TextField`, passing
arguments from the helper to `Ember.TextField`'s `create` method. You can extend the
@@ -80,11 +80,12 @@ function normalizeHash(hash, hashTypes) {
Ember.TextField.reopen({
attributeBindings: ['required']
});
+ ```
## Use as checkbox
An `{{input}}` with a `type` of `checkbox` will render an HTML checkbox input.
The following HTML attributes can be set via the helper:
-
+
* `checked`
* `disabled`
* `tabindex`
@@ -131,7 +132,7 @@ function normalizeHash(hash, hashTypes) {
Ember.Checkbox.reopen({
classNames: ['my-app-checkbox']
});
-
+ ```
@method input
@for Ember.Handlebars.helpers
@@ -160,22 +161,140 @@ Ember.Handlebars.registerHelper('input', function(options) {
});
/**
- `{{textarea}}` inserts a new instance of `Ember.TextArea` into the template.
-
+ `{{textarea}}` inserts a new instance of `<textarea>` tag into the template.
+ The attributes of `{{textarea}}` match those of the native HTML tags as
+ closely as possible.
+
+ The following HTML attributes can be set:
+
+ * `value`
+ * `name`
+ * `rows`
+ * `cols`
+ * `placeholder`
+ * `disabled`
+ * `maxlength`
+ * `tabindex`
+
+ When set to a quoted string, these value will be directly applied to the HTML
+ element. When left unquoted, these values will be bound to a property on the
+ template's current rendering context (most typically a controller instance).
+
+ Unbound:
+
+ ```handlebars
+ {{textarea value="Lots of static text that ISN'T bound"}}
+ ```
+
+ Would result in the following HTML:
+
+ ```html
+ <textarea class="ember-text-area">
+ Lots of static text that ISN'T bound
+ </textarea>
+ ```
+
+ Bound:
+
+ In the following example, the `writtenWords` property on `App.ApplicationController`
+ will be updated live as the user types 'Lots of text that IS bound' into
+ the text area of their browser's window.
+
+ ```javascript
+ App.ApplicationController = Ember.Controller.extend({
+ writtenWords: "Lots of text that IS bound"
+ });
+ ```
+
+ ```handlebars
+ {{textarea value=writtenWords}}
+ ```
+
+ Would result in the following HTML:
+
+ ```html
+ <textarea class="ember-text-area">
+ Lots of text that IS bound
+ </textarea>
+ ```
+
+ If you wanted a one way binding between the text area and a div tag
+ somewhere else on your screen, you could use `Ember.computed.oneWay`:
+
+ ```javascript
+ App.ApplicationController = Ember.Controller.extend({
+ writtenWords: "Lots of text that IS bound",
+ outputWrittenWords: Ember.computed.oneWay("writtenWords")
+ });
+ ```
+
+ ```handlebars
+ {{textarea value=writtenWords}}
+
+ <div>
+ {{outputWrittenWords}}
+ </div>
+ ```
+
+ Would result in the following HTML:
+
+ ```html
+ <textarea class="ember-text-area">
+ Lots of text that IS bound
+ </textarea>
+
+ <-- the following div will be updated in real time as you type -->
+
+ <div>
+ Lots of text that IS bound
+ </div>
+ ```
+
+ Finally, this example really shows the power and ease of Ember when two
+ properties are bound to eachother via `Ember.computed.alias`. Type into
+ either text area box and they'll both stay in sync. Note that
+ `Ember.computed.alias` costs more in terms of performance, so only use it when
+ your really binding in both directions:
+
```javascript
App.ApplicationController = Ember.Controller.extend({
- writtenWords: "lorem ipsum dolor sit amet"
+ writtenWords: "Lots of text that IS bound",
+ twoWayWrittenWords: Ember.computed.alias("writtenWords")
});
```
```handlebars
- {{textarea value="writtenWords"}}
+ {{textarea value=writtenWords}}
+ {{textarea value=twoWayWrittenWords}}
```
-
+
```html
- <textarea class="ember-text-area">
- written words
+ <textarea id="ember1" class="ember-text-area">
+ Lots of text that IS bound
</textarea>
+
+ <-- both updated in real time -->
+
+ <textarea id="ember2" class="ember-text-area">
+ Lots of text that IS bound
+ </textarea>
+ ```
+
+ ### Extension
+
+ Internally, `{{textarea}}` creates an instance of `Ember.TextArea`, passing
+ arguments from the helper to `Ember.TextArea`'s `create` method. You can
+ extend the capabilities of text areas in your application by reopening this
+ class. For example, if you are deploying to browsers where the `required`
+ attribute is used, you can globally add support for the `required` attribute
+ on all {{textarea}}'s' in your app by reopening `Ember.TextArea` or
+ `Ember.TextSupport` and adding it to the `attributeBindings` concatenated
+ property:
+
+ ```javascript
+ Ember.TextArea.reopen({
+ attributeBindings: ['required']
+ });
```
@method textarea | true |
Other | emberjs | ember.js | e1d9534a6440310b3c18d824573e2a2a894b388d.json | Update api docs for {{textarea}}
- make them similar to {{input}}
- provide extended example to show how easy implementing a one way and
two way binding on a textarea can be | packages/ember-handlebars/lib/controls/text_area.js | @@ -10,51 +10,17 @@ require("ember-handlebars/controls/text_support");
var get = Ember.get, set = Ember.set;
/**
- The `Ember.TextArea` view class renders a
- [textarea](https://developer.mozilla.org/en/HTML/Element/textarea) element.
- It allows for binding Ember properties to the text area contents (`value`),
- live-updating as the user inputs text:
+ The internal class used to create textarea element when the `{{textarea}}`
+ helper is used.
- ```javascript
- App.ApplicationController = Ember.Controller.extend({
- writtenWords: 'hello'
- });
- ```
+ See handlebars.helpers.textarea for usage details.
- ```handlebars
- {{view Ember.TextArea valueBinding="writtenWords"}}
- ```
-
- Would result in the following HTML:
-
- ```html
- <textarea class="ember-text-area">
- written words
- </textarea>
- ```
-
## Layout and LayoutName properties
Because HTML `textarea` elements do not contain inner HTML the `layout` and
`layoutName` properties will not be applied. See [Ember.View](/api/classes/Ember.View.html)'s
layout section for more information.
- ## HTML Attributes
-
- By default `Ember.TextArea` provides support for `rows`, `cols`,
- `placeholder`, `disabled`, `maxlength` and `tabindex` attributes on a
- textarea. If you need to support more attributes have a look at the
- `attributeBindings` property in `Ember.View`'s HTML Attributes section.
-
- To globally add support for additional attributes you can reopen
- `Ember.TextArea` or `Ember.TextSupport`.
-
- ```javascript
- Ember.TextSupport.reopen({
- attributeBindings: ["required"]
- })
- ```
-
@class TextArea
@namespace Ember
@extends Ember.View | true |
Other | emberjs | ember.js | ba1c747b668e23c2fca0e19970f3a042a375a399.json | Use factory superclass in Route#model hook | packages/ember-routing/lib/system/route.js | @@ -547,7 +547,7 @@ Ember.Route = Ember.Object.extend({
if (!name && sawParams) { return params; }
else if (!name) { return; }
- var modelClass = this.container.lookupFactory('model:' + name);
+ var modelClass = this.container.lookupFactory('model:' + name).superclass;
var namespace = get(this, 'router.namespace');
Ember.assert("You used the dynamic segment " + name + "_id in your router, but " + namespace + "." + classify(name) + " did not exist and you did not override your route's `model` hook.", modelClass); | true |
Other | emberjs | ember.js | ba1c747b668e23c2fca0e19970f3a042a375a399.json | Use factory superclass in Route#model hook | packages/ember-routing/tests/system/route_test.js | @@ -17,11 +17,12 @@ test("default model utilizes the container to acquire the model factory", functi
post = {};
- Post = {
+ Post = Ember.Object.extend();
+ Post.reopenClass({
find: function(id) {
return post;
}
- };
+ });
container = {
lookupFactory: lookupFactory
@@ -34,7 +35,7 @@ test("default model utilizes the container to acquire the model factory", functi
function lookupFactory(fullName) {
equal(fullName, "model:post", "correct factory was looked up");
- return Post;
+ return Post.extend();
}
});
@@ -71,4 +72,4 @@ test("controllerFor uses route's controllerName if specified", function() {
routeOne.controllerName = 'test';
equal(routeTwo.controllerFor('one'), testController);
-});
\ No newline at end of file
+}); | true |
Other | emberjs | ember.js | ba1c747b668e23c2fca0e19970f3a042a375a399.json | Use factory superclass in Route#model hook | packages/ember/tests/routing/basic_test.js | @@ -2293,3 +2293,23 @@ test("currentRouteName is a property installed on ApplicationController that can
transitionAndCheck('each.other', 'be.excellent.to.each.other', 'each.other');
});
+test("Route model hook finds the same model as a manual find", function() {
+ var Post;
+ App.Post = Ember.Object.extend();
+ App.Post.reopenClass({
+ find: function() {
+ Post = this;
+ return {};
+ }
+ });
+
+ Router.map(function() {
+ this.route('post', { path: '/post/:post_id' });
+ });
+
+ bootApplication();
+
+ handleURL('/post/1');
+
+ equal(App.Post, Post);
+}); | true |
Other | emberjs | ember.js | 447b29466ef7bd0692627340b52ffbb565813040.json | add regression coverage for #3221 [closes #3223] | packages/ember-handlebars/tests/loader_test.js | @@ -1,4 +1,4 @@
-var originalLookup = Ember.lookup, lookup, Tobias;
+var originalLookup = Ember.lookup, lookup, Tobias, App, view;
module("test Ember.Handlebars.bootstrap", {
setup: function() {
@@ -7,6 +7,8 @@ module("test Ember.Handlebars.bootstrap", {
teardown: function() {
Ember.TEMPLATES = {};
Ember.lookup = originalLookup;
+ if(App) { Ember.run(App, 'destroy'); }
+ if (view) { Ember.run(view, 'destroy'); }
}
});
@@ -113,3 +115,20 @@ test('duplicated template data-template-name should throw exception', function()
/Template named "[^"]+" already exists\./,
"duplicate templates should not be allowed");
});
+
+test('registerComponents initializer', function(){
+ Ember.TEMPLATES['components/x-apple'] = 'asdf';
+
+ App = Ember.run(Ember.Application, 'create');
+
+ ok(Ember.Handlebars.helpers['x-apple'], 'x-apple helper is present');
+ ok(App.__container__.has('component:x-apple'), 'the container is aware of x-apple');
+});
+
+test('registerComponents and ad-hoc components', function(){
+ Ember.TEMPLATES['components/x-apple'] = 'asdf';
+
+ App = Ember.run(Ember.Application, 'create');
+ view = App.__container__.lookup('component:x-apple');
+ equal(view.get('layoutName'), 'components/x-apple', 'has correct layout name');
+}); | false |
Other | emberjs | ember.js | ef955e7a9c9c7dee6de37029aac83901e69e0888.json | Remove some commented test code. | packages/ember-handlebars/tests/controls/text_area_test.js | @@ -252,47 +252,3 @@ test("should call the cancel method when escape key is pressed", function() {
textArea.trigger('keyUp', event);
ok(wasCalled, "invokes cancel method");
});
-
-// test("listens for focus and blur events", function() {
-// var focusCalled = 0;
-// var blurCalled = 0;
-
-// textArea.focus = function() {
-// focusCalled++;
-// };
-// textArea.blur = function() {
-// blurCalled++;
-// };
-
-// equal(focusCalled+blurCalled, 0, "precond - no callbacks called yet");
-
-// textArea.$().focus();
-// equal(focusCalled, 1, "focus called after field receives focus");
-
-// textArea.$().blur();
-// equal(blurCalled, 1, "blur alled after field blurs");
-// });
-
-// test("calls correct method for key events", function() {
-// var insertNewlineCalled = 0;
-// var cancelCalled = 0;
-
-// textArea.insertNewline = function() {
-// insertNewlineCalled++;
-// return true;
-// };
-// textArea.cancel = function() {
-// cancelCalled++;
-// return true;
-// };
-
-// textArea.$().focus();
-// equal(insertNewlineCalled+cancelCalled, 0, "precond - no callbacks called yet");
-
-// Ember.RootResponder.responder.keyup(new Ember.Event({ type: 'keyup', keyCode: 13 }));
-// equal(insertNewlineCalled, 1, "calls insertNewline after hitting return");
-
-// Ember.RootResponder.responder.keyup(new Ember.Event({ type: 'keyup', keyCode: 27 }));
-// equal(cancelCalled, 1, "calls cancel after pressing escape key");
-// });
- | true |
Other | emberjs | ember.js | ef955e7a9c9c7dee6de37029aac83901e69e0888.json | Remove some commented test code. | packages/ember-handlebars/tests/controls/text_field_test.js | @@ -450,47 +450,3 @@ test("bubbling of handled actions can be enabled via bubbles property", function
textField.trigger('keyUp', event);
equal(stopPropagationCount, 1, "propagation was prevented if bubbles is false");
});
-
-// test("listens for focus and blur events", function() {
-// var focusCalled = 0;
-// var blurCalled = 0;
-
-// textField.focus = function() {
-// focusCalled++;
-// };
-// textField.blur = function() {
-// blurCalled++;
-// };
-
-// equal(focusCalled+blurCalled, 0, "precond - no callbacks called yet");
-
-// textField.$().focus();
-// equal(focusCalled, 1, "focus called after field receives focus");
-
-// textField.$().blur();
-// equal(blurCalled, 1, "blur alled after field blurs");
-// });
-
-// test("calls correct method for key events", function() {
-// var insertNewlineCalled = 0;
-// var cancelCalled = 0;
-
-// textField.insertNewline = function() {
-// insertNewlineCalled++;
-// return true;
-// };
-// textField.cancel = function() {
-// cancelCalled++;
-// return true;
-// };
-
-// textField.$().focus();
-// equal(insertNewlineCalled+cancelCalled, 0, "precond - no callbacks called yet");
-
-// Ember.RootResponder.responder.keyup(new Ember.Event({ type: 'keyup', keyCode: 13 }));
-// equal(insertNewlineCalled, 1, "calls insertNewline after hitting return");
-
-// Ember.RootResponder.responder.keyup(new Ember.Event({ type: 'keyup', keyCode: 27 }));
-// equal(cancelCalled, 1, "calls cancel after pressing escape key");
-// });
- | true |
Other | emberjs | ember.js | ef955e7a9c9c7dee6de37029aac83901e69e0888.json | Remove some commented test code. | packages/ember-handlebars/tests/handlebars_test.js | @@ -529,41 +529,40 @@ test("Template updates correctly if a path is passed to the bind helper", functi
equal(view.$('h1').text(), "$6", "updates when parent property changes");
});
-// test("Template updates correctly if a path is passed to the bind helper and the context object is an Ember.ObjectController", function() {
-// var templates;
+test("Template updates correctly if a path is passed to the bind helper and the context object is an Ember.ObjectController", function() {
+ container.register('template:menu', Ember.Handlebars.compile('<h1>{{bind "view.coffee.price"}}</h1>'));
-// templates = Ember.Object.create({
-// menu: Ember.Handlebars.compile('<h1>{{bind "coffee.price"}}</h1>')
-// });
+ var controller = Ember.ObjectController.create();
-// var controller = Ember.ObjectController.create();
-// var realObject = Ember.Object.create({
-// price: "$4"
-// });
+ var realObject = Ember.Object.create({
+ price: "$4"
+ });
-// set(controller, 'content', realObject);
+ set(controller, 'content', realObject);
-// var view = Ember.View.create({
-// templateName: 'menu',
-// templates: templates,
+ view = Ember.View.create({
+ container: container,
+ templateName: 'menu',
-// coffee: controller
-// });
+ coffee: controller
+ });
-// view.createElement();
+ appendView();
-// equal(view.$('h1').text(), "$4", "precond - renders price");
+ equal(view.$('h1').text(), "$4", "precond - renders price");
-// set(realObject, 'price', "$5");
+ Ember.run(function() {
+ set(realObject, 'price', "$5");
+ });
-// equal(view.$('h1').text(), "$5", "updates when property is set on real object");
+ equal(view.$('h1').text(), "$5", "updates when property is set on real object");
-// Ember.run(function() {
-// set(controller, 'price', "$6" );
-// });
+ Ember.run(function() {
+ set(controller, 'price', "$6" );
+ });
-// equal(view.$('h1').text(), "$6", "updates when property is set on object controller");
-// });
+ equal(view.$('h1').text(), "$6", "updates when property is set on object controller");
+});
test("should update the block when object passed to #if helper changes", function() {
container.register('template:menu', Ember.Handlebars.compile('<h1>{{#if view.inception}}{{view.INCEPTION}}{{/if}}</h1>'));
@@ -690,26 +689,6 @@ test("edge case: child conditional should not render children if parent conditio
ok(!childCreated, 'child should not be created');
});
-// test("Should insert a localized string if the {{loc}} helper is used", function() {
-// Ember.stringsFor('en', {
-// 'Brazil': 'Brasilia'
-// });
-
-// templates = Ember.Object.create({
-// 'loc': Ember.Handlebars.compile('<h1>Country: {{loc "Brazil"}}')
-// });
-
-// var view = Ember.View.create({
-// templateName: 'loc',
-// templates: templates,
-
-// country: 'Brazil'
-// });
-
-// view.createElement();
-// equal(view.$('h1').text(), 'Country: Brasilia', "returns localized value");
-// });
-
test("Template views return throw if their template cannot be found", function() {
view = Ember.View.create({
templateName: 'cantBeFound',
@@ -2194,8 +2173,6 @@ test("bindings can be 'this', in which case they *are* the current context", fun
// https://github.com/emberjs/ember.js/issues/120
test("should not enter an infinite loop when binding an attribute in Handlebars", function() {
- expect(0);
-
var App;
Ember.run(function() {
@@ -2221,9 +2198,8 @@ test("should not enter an infinite loop when binding an attribute in Handlebars"
Ember.run(function() {
parentView.appendTo('#qunit-fixture');
- // App.Link.create().appendTo('#qunit-fixture');
});
- // equal(view.$().attr('href'), 'test');
+ equal(parentView.$('a').attr('href'), 'test');
Ember.run(function() {
parentView.destroy(); | true |
Other | emberjs | ember.js | ef955e7a9c9c7dee6de37029aac83901e69e0888.json | Remove some commented test code. | packages/ember-runtime/tests/legacy_1x/mixins/observable/observable_test.js | @@ -273,10 +273,6 @@ test("should change normal properties and return this", function() {
test("should call computed properties passing value and return this", function() {
var ret = object.set("computed", "changed") ;
equal(object._computed, "changed") ;
-
- // DISABLED: this is no longer true with accessors
- //equal(Ember.typeOf(object.computed), 'function') ;
-
equal(ret, object) ;
});
| true |
Other | emberjs | ember.js | ef955e7a9c9c7dee6de37029aac83901e69e0888.json | Remove some commented test code. | packages/ember/tests/routing/basic_test.js | @@ -946,9 +946,6 @@ asyncTest("Events are triggered on the current state", function() {
container.register('controller:home', Ember.Controller.extend());
- //var controller = router._container.controller.home = Ember.Controller.create();
- //controller.target = router;
-
handleURL('/');
var actionId = Ember.$("#qunit-fixture a").data("ember-action"); | true |
Other | emberjs | ember.js | 30a6eae2518f7e0181d2705d44a02deaa5bad281.json | Change docs to mention `setUnknownProperty`
The docs incorrectly said that `unknownProperty` would be called when setting an unknown property. | packages/ember-metal/lib/property_set.js | @@ -10,7 +10,7 @@ var META_KEY = Ember.META_KEY,
/**
Sets the value of a property on an object, respecting computed properties
and notifying observers and other listeners of the change. If the
- property is not defined but the object implements the `unknownProperty`
+ property is not defined but the object implements the `setUnknownProperty`
method then that will be invoked as well.
If you plan to run on IE8 and older browsers then you should use this
@@ -20,7 +20,7 @@ var META_KEY = Ember.META_KEY,
On all newer browsers, you only need to use this method to set
properties if the property might not be defined on the object and you want
- to respect the `unknownProperty` handler. Otherwise you can ignore this
+ to respect the `setUnknownProperty` handler. Otherwise you can ignore this
method.
@method set | true |
Other | emberjs | ember.js | 30a6eae2518f7e0181d2705d44a02deaa5bad281.json | Change docs to mention `setUnknownProperty`
The docs incorrectly said that `unknownProperty` would be called when setting an unknown property. | packages/ember-metal/tests/accessors/set_test.js | @@ -25,7 +25,7 @@ test('should call setUnknownProperty if defined and value is undefined', functio
count: 0,
unknownProperty: function(key, value) {
- ok(false, 'should not invoke unknownProperty is setUnknownProperty is defined');
+ ok(false, 'should not invoke unknownProperty if setUnknownProperty is defined');
},
setUnknownProperty: function(key, value) { | true |
Other | emberjs | ember.js | 30a6eae2518f7e0181d2705d44a02deaa5bad281.json | Change docs to mention `setUnknownProperty`
The docs incorrectly said that `unknownProperty` would be called when setting an unknown property. | packages/ember-runtime/lib/mixins/observable.js | @@ -149,7 +149,7 @@ Ember.Observable = Ember.Mixin.create({
This method is generally very similar to calling `object[key] = value` or
`object.key = value`, except that it provides support for computed
- properties, the `unknownProperty()` method and property observers.
+ properties, the `setUnknownProperty()` method and property observers.
### Computed Properties
@@ -163,9 +163,9 @@ Ember.Observable = Ember.Mixin.create({
### Unknown Properties
If you try to set a value on a key that is undefined in the target
- object, then the `unknownProperty()` handler will be called instead. This
+ object, then the `setUnknownProperty()` handler will be called instead. This
gives you an opportunity to implement complex "virtual" properties that
- are not predefined on the object. If `unknownProperty()` returns
+ are not predefined on the object. If `setUnknownProperty()` returns
undefined, then `set()` will simply set the value on the object.
### Property Observers | true |
Other | emberjs | ember.js | 7fb13eb533bec382278b4a3e665dfe6af6bc386e.json | Remove Ember.Button from YUIDoc output. | packages/ember-handlebars/lib/controls/button.js | @@ -1,13 +1,13 @@
require('ember-runtime/mixins/target_action_support');
-/**
+/*
@module ember
@submodule ember-handlebars
*/
var get = Ember.get, set = Ember.set;
-/**
+/*
@class Button
@namespace Ember
@extends Ember.View
@@ -24,7 +24,7 @@ Ember.Button = Ember.View.extend(Ember.TargetActionSupport, {
attributeBindings: ['type', 'disabled', 'href', 'tabindex'],
- /**
+ /*
@private
Overrides `TargetActionSupport`'s `targetObject` computed | false |
Other | emberjs | ember.js | faed7a64417f5712ad356289a3c0b2068c50bf4e.json | simplify emptyView and itemViewClass lookups. | packages/ember-views/lib/views/collection_view.js | @@ -301,16 +301,13 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie
addedViews = [], view, item, idx, len;
if ('string' === typeof itemViewClass) {
- var newItemViewClass = get(itemViewClass);
- if (!newItemViewClass) {
- newItemViewClass = this.container.lookupFactory('view:' + itemViewClass);
- }
- itemViewClass = newItemViewClass;
+ itemViewClass = get(itemViewClass) || this.container.lookupFactory('view:' + itemViewClass);
}
Ember.assert(fmt("itemViewClass must be a subclass of Ember.View, not %@", [itemViewClass]), Ember.View.detect(itemViewClass));
len = content ? get(content, 'length') : 0;
+
if (len) {
for (idx = start; idx < start+added; idx++) {
item = content.objectAt(idx);
@@ -327,11 +324,7 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie
if (!emptyView) { return; }
if ('string' === typeof emptyView) {
- var newEmptyView = get(emptyView);
- if (!newEmptyView) {
- newEmptyView = this.container.lookupFactory('view:' + emptyView);
- }
- emptyView = newEmptyView;
+ emptyView = get(emptyView) || this.container.lookupFactory('view:' + emptyView);
}
var isClass = Ember.CoreView.detect(emptyView); | false |
Other | emberjs | ember.js | 4ce4b1fc613db57740bcf0e3c8fbde358f784757.json | Sync router.js - Closes #3153 | packages/ember-routing/lib/vendor/router.js | @@ -937,8 +937,8 @@ define("router",
.then(handleAbort)
.then(afterModel)
.then(handleAbort)
- .then(proceed)
- .then(null, handleError);
+ .then(null, handleError)
+ .then(proceed);
function handleAbort(result) {
if (transition.isAborted) {
@@ -965,10 +965,6 @@ define("router",
// `error` event from this handler info up to root.
trigger(handlerInfos.slice(0, index + 1), true, ['error', reason, transition]);
- if (handler.error) {
- handler.error(reason, transition);
- }
-
// Propagate the original error.
return RSVP.reject(reason);
} | false |
Other | emberjs | ember.js | 58adbb5c504f8abe8ae5a7fe293cd97ee749cda6.json | Add currentRouteName to ApplicationController
`currentRouteName`, unlike `currentPath`, can always be used as a target route
name within `linkTo` and `transitionTo` even for nested routes.
Closes #2812 | packages/ember-routing/lib/system/router.js | @@ -56,10 +56,12 @@ Ember.Router = Ember.Object.extend({
var appController = this.container.lookup('controller:application'),
path = Ember.Router._routePath(infos);
- if (!('currentPath' in appController)) {
- defineProperty(appController, 'currentPath');
- }
+ if (!('currentPath' in appController)) { defineProperty(appController, 'currentPath'); }
set(appController, 'currentPath', path);
+
+ if (!('currentRouteName' in appController)) { defineProperty(appController, 'currentRouteName'); }
+ set(appController, 'currentRouteName', infos[infos.length - 1].name);
+
this.notifyPropertyChange('url');
if (get(this, 'namespace').LOG_TRANSITIONS) { | true |
Other | emberjs | ember.js | 58adbb5c504f8abe8ae5a7fe293cd97ee749cda6.json | Add currentRouteName to ApplicationController
`currentRouteName`, unlike `currentPath`, can always be used as a target route
name within `linkTo` and `transitionTo` even for nested routes.
Closes #2812 | packages/ember/tests/routing/basic_test.js | @@ -2252,3 +2252,44 @@ test("Events can be handled by inherited event handlers", function() {
router.send("baz");
});
+test("currentRouteName is a property installed on ApplicationController that can be used in transitionTo", function() {
+
+ expect(24);
+
+ Router.map(function() {
+ this.resource("be", function() {
+ this.resource("excellent", function() {
+ this.resource("to", function() {
+ this.resource("each", function() {
+ this.route("other");
+ });
+ });
+ });
+ });
+ });
+
+ bootApplication();
+
+ var appController = router.container.lookup('controller:application');
+
+ function transitionAndCheck(path, expectedPath, expectedRouteName) {
+ if (path) { Ember.run(router, 'transitionTo', path); }
+ equal(appController.get('currentPath'), expectedPath);
+ equal(appController.get('currentRouteName'), expectedRouteName);
+ }
+
+ transitionAndCheck(null, 'index', 'index');
+ transitionAndCheck('/be', 'be.index', 'be.index');
+ transitionAndCheck('/be/excellent', 'be.excellent.index', 'excellent.index');
+ transitionAndCheck('/be/excellent/to', 'be.excellent.to.index', 'to.index');
+ transitionAndCheck('/be/excellent/to/each', 'be.excellent.to.each.index', 'each.index');
+ transitionAndCheck('/be/excellent/to/each/other', 'be.excellent.to.each.other', 'each.other');
+
+ transitionAndCheck('index', 'index', 'index');
+ transitionAndCheck('be', 'be.index', 'be.index');
+ transitionAndCheck('excellent', 'be.excellent.index', 'excellent.index');
+ transitionAndCheck('to.index', 'be.excellent.to.index', 'to.index');
+ transitionAndCheck('each', 'be.excellent.to.each.index', 'each.index');
+ transitionAndCheck('each.other', 'be.excellent.to.each.other', 'each.other');
+});
+ | true |
Other | emberjs | ember.js | 366e995e930713d96f6df508affc35f6db277d2d.json | Fix typos in Ember.Enumerable deprecations | packages/ember-runtime/lib/mixins/enumerable.js | @@ -308,7 +308,7 @@ Ember.Enumerable = Ember.Mixin.create({
@method mapProperty
@param {String} key name of the property
@return {Array} The mapped array.
- @deprecated User `filterBy` instead Use `mapBy` instead
+ @deprecated Use `mapBy` instead
*/
mapProperty: Ember.aliasMethod('mapBy'),
@@ -402,7 +402,7 @@ Ember.Enumerable = Ember.Mixin.create({
@param {String} key the property to test
@param {String} [value] optional value to test against.
@return {Array} filtered array
- @deprecated User `filterBy` instead
+ @deprecated Use `filterBy` instead
*/
filterProperty: Ember.aliasMethod('filterBy'),
@@ -433,7 +433,7 @@ Ember.Enumerable = Ember.Mixin.create({
@param {String} key the property to test
@param {String} [value] optional value to test against.
@return {Array} rejected array
- @deprecated User `rejectBy` instead
+ @deprecated Use `rejectBy` instead
*/
rejectProperty: Ember.aliasMethod('rejectBy'),
@@ -508,7 +508,7 @@ Ember.Enumerable = Ember.Mixin.create({
@param {String} key the property to test
@param {String} [value] optional value to test against.
@return {Object} found item or `undefined`
- @deprecated User `findBy` instead
+ @deprecated Use `findBy` instead
*/
findProperty: Ember.aliasMethod('findBy'),
| false |
Other | emberjs | ember.js | 39d6bd88ae6ad0d465aec6dd6636ffd07d32a3c2.json | Change didInit event to just init | packages/ember-runtime/lib/system/core_object.js | @@ -123,7 +123,7 @@ function makeCtor() {
m.proto = proto;
finishChains(this);
this.init.apply(this, arguments);
- sendEvent(this, "didInit");
+ sendEvent(this, "init");
};
Class.toString = Mixin.prototype.toString; | true |
Other | emberjs | ember.js | 39d6bd88ae6ad0d465aec6dd6636ffd07d32a3c2.json | Change didInit event to just init | packages/ember-runtime/tests/system/object/create_test.js | @@ -167,15 +167,15 @@ test("Calls all mixin inits if defined", function() {
equal(completed, 2, 'should have called init for both mixins.');
});
-test("Triggers didInit", function() {
+test("Triggers init", function() {
var completed = false;
var obj = Ember.Object.createWithMixins({
- markAsCompleted: Ember.on("didInit", function(){
+ markAsCompleted: Ember.on("init", function(){
completed = true;
})
});
- ok(completed, 'should have triggered didInit which should have run markAsCompleted');
+ ok(completed, 'should have triggered init which should have run markAsCompleted');
});
test('creating an object with required properties', function() { | true |
Other | emberjs | ember.js | d47b71885effb93a4a78a4024cea22de40875b72.json | Use a single array for actions.
Eliminate array creation for each listener added. | packages/ember-metal/lib/events.js | @@ -24,7 +24,7 @@ var o_create = Ember.create,
{
listeners: { // variable name: `listenerSet`
"foo:changed": [ // variable name: `actions`
- [target, method, flags]
+ target, method, flags
]
}
}
@@ -33,8 +33,8 @@ var o_create = Ember.create,
function indexOf(array, target, method) {
var index = -1;
- for (var i = 0, l = array.length; i < l; i++) {
- if (target === array[i][0] && method === array[i][1]) { index = i; break; }
+ for (var i = 0, l = array.length; i < l; i += 3) {
+ if (target === array[i] && method === array[i+1]) { index = i; break; }
}
return index;
}
@@ -67,14 +67,14 @@ function actionsUnion(obj, eventName, otherActions) {
actions = meta && meta.listeners && meta.listeners[eventName];
if (!actions) { return; }
- for (var i = actions.length - 1; i >= 0; i--) {
- var target = actions[i][0],
- method = actions[i][1],
- flags = actions[i][2],
+ for (var i = actions.length - 3; i >= 0; i -= 3) {
+ var target = actions[i],
+ method = actions[i+1],
+ flags = actions[i+2],
actionIndex = indexOf(otherActions, target, method);
if (actionIndex === -1) {
- otherActions.push([target, method, flags]);
+ otherActions.push(target, method, flags);
}
}
}
@@ -85,16 +85,16 @@ function actionsDiff(obj, eventName, otherActions) {
diffActions = [];
if (!actions) { return; }
- for (var i = actions.length - 1; i >= 0; i--) {
- var target = actions[i][0],
- method = actions[i][1],
- flags = actions[i][2],
+ for (var i = actions.length - 3; i >= 0; i -= 3) {
+ var target = actions[i],
+ method = actions[i+1],
+ flags = actions[i+2],
actionIndex = indexOf(otherActions, target, method);
if (actionIndex !== -1) { continue; }
- otherActions.push([target, method, flags]);
- diffActions.push([target, method, flags]);
+ otherActions.push(target, method, flags);
+ diffActions.push(target, method, flags);
}
return diffActions;
@@ -127,7 +127,7 @@ function addListener(obj, eventName, target, method, once) {
if (actionIndex !== -1) { return; }
- actions.push([target, method, flags]);
+ actions.push(target, method, flags);
if ('function' === typeof obj.didAddListener) {
obj.didAddListener(eventName, target, method);
@@ -161,7 +161,7 @@ function removeListener(obj, eventName, target, method) {
// action doesn't exist, give up silently
if (actionIndex === -1) { return; }
- actions.splice(actionIndex, 1);
+ actions.splice(actionIndex, 3);
if ('function' === typeof obj.didRemoveListener) {
obj.didRemoveListener(eventName, target, method);
@@ -175,8 +175,8 @@ function removeListener(obj, eventName, target, method) {
actions = meta && meta.listeners && meta.listeners[eventName];
if (!actions) { return; }
- for (var i = actions.length - 1; i >= 0; i--) {
- _removeListener(actions[i][0], actions[i][1]);
+ for (var i = actions.length - 3; i >= 0; i -= 3) {
+ _removeListener(actions[i], actions[i+1]);
}
}
}
@@ -206,17 +206,14 @@ function suspendListener(obj, eventName, target, method, callback) {
}
var actions = actionsFor(obj, eventName),
- actionIndex = indexOf(actions, target, method),
- action;
+ actionIndex = indexOf(actions, target, method);
if (actionIndex !== -1) {
- action = actions[actionIndex].slice(); // copy it, otherwise we're modifying a shared object
- action[2] |= SUSPENDED; // mark the action as suspended
- actions[actionIndex] = action; // replace the shared object with our copy
+ actions[actionIndex+2] |= SUSPENDED; // mark the action as suspended
}
function tryable() { return callback.call(target); }
- function finalizer() { if (action) { action[2] &= ~SUSPENDED; } }
+ function finalizer() { if (actionIndex !== -1) { actions[actionIndex+2] &= ~SUSPENDED; } }
return Ember.tryFinally(tryable, finalizer);
}
@@ -241,28 +238,22 @@ function suspendListeners(obj, eventNames, target, method, callback) {
target = null;
}
- var suspendedActions = [],
- eventName, actions, action, i, l;
+ var eventName, actions, i, l;
for (i=0, l=eventNames.length; i<l; i++) {
eventName = eventNames[i];
actions = actionsFor(obj, eventName);
var actionIndex = indexOf(actions, target, method);
if (actionIndex !== -1) {
- action = actions[actionIndex].slice();
- action[2] |= SUSPENDED;
- actions[actionIndex] = action;
- suspendedActions.push(action);
+ actions[actionIndex+2] |= SUSPENDED;
}
}
function tryable() { return callback.call(target); }
function finalizer() {
- for (i = 0, l = suspendedActions.length; i < l; i++) {
- suspendedActions[i][2] &= ~SUSPENDED;
- }
+ actions[actionIndex+2] &= ~SUSPENDED;
}
return Ember.tryFinally(tryable, finalizer);
@@ -315,10 +306,9 @@ function sendEvent(obj, eventName, params, actions) {
if (!actions) { return; }
- for (var i = actions.length - 1; i >= 0; i--) { // looping in reverse for once listeners
- var action = actions[i];
- if (!action) { continue; }
- var target = action[0], method = action[1], flags = action[2];
+ for (var i = actions.length - 3; i >= 0; i -= 3) { // looping in reverse for once listeners
+ var target = actions[i], method = actions[i+1], flags = actions[i+2];
+ if (!method) { continue; }
if (flags & SUSPENDED) { continue; }
if (flags & ONCE) { removeListener(obj, eventName, target, method); }
if (!target) { target = obj; }
@@ -360,9 +350,9 @@ function listenersFor(obj, eventName) {
if (!actions) { return ret; }
- for (var i = 0, l = actions.length; i < l; i++) {
- var target = actions[i][0],
- method = actions[i][1];
+ for (var i = 0, l = actions.length; i < l; i += 3) {
+ var target = actions[i],
+ method = actions[i+1];
ret.push([target, method]);
}
| true |
Other | emberjs | ember.js | d47b71885effb93a4a78a4024cea22de40875b72.json | Use a single array for actions.
Eliminate array creation for each listener added. | packages/ember-metal/tests/events_test.js | @@ -200,7 +200,7 @@ test('while suspended, it should not be possible to add a duplicate listener', f
Ember._suspendListener(obj, 'event!', target, target.method, callback);
equal(target.count, 1, 'should invoke');
- equal(Ember.meta(obj).listeners['event!'].length, 1, "a duplicate listener wasn't added");
+ equal(Ember.meta(obj).listeners['event!'].length, 3, "a duplicate listener wasn't added");
// now test _suspendListeners...
@@ -209,7 +209,7 @@ test('while suspended, it should not be possible to add a duplicate listener', f
Ember._suspendListeners(obj, ['event!'], target, target.method, callback);
equal(target.count, 2, 'should have invoked again');
- equal(Ember.meta(obj).listeners['event!'].length, 1, "a duplicate listener wasn't added");
+ equal(Ember.meta(obj).listeners['event!'].length, 3, "a duplicate listener wasn't added");
});
test('a listener can be added as part of a mixin', function() { | true |
Other | emberjs | ember.js | 0d62733f3089fe35ecbfb497320116d2372e9ef6.json | Fix crazy grammar. | packages/ember-application/lib/system/resolver.js | @@ -243,9 +243,10 @@ Ember.DefaultResolver = Ember.Object.extend({
factory = get(parsedName.root, className);
if (factory) { return factory; }
},
+
/**
Returns a human-readable description for a fullName. Used by the
- Application namespace in assertions to assertions to describe the
+ Application namespace in assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys.
| false |
Other | emberjs | ember.js | 9b442d5205913ef3e58d4c653950bbdf03e60453.json | Add examples to the Ember.NativeArray docs | packages/ember-runtime/lib/system/native_array.js | @@ -123,7 +123,26 @@ Ember.NativeArray = NativeArray;
/**
Creates an `Ember.NativeArray` from an Array like object.
- Does not modify the original object.
+ Does not modify the original object. Ember.A is not needed if
+ `Ember.EXTEND_PROTOTYPES` is `true` (the default value). However,
+ it is recommended that you use Ember.A when creating addons for
+ ember or when you can not garentee that `Ember.EXTEND_PROTOTYPES`
+ will be `true`.
+
+ Example
+
+ ```js
+ var Pagination = Ember.CollectionView.extend({
+ tagName: 'ul',
+ classNames: ['pagination'],
+ init: function() {
+ this._super();
+ if (!this.get('content')) {
+ this.set('content', Ember.A([]));
+ }
+ }
+ });
+ ```
@method A
@for Ember
@@ -136,7 +155,17 @@ Ember.A = function(arr) {
/**
Activates the mixin on the Array.prototype if not already applied. Calling
- this method more than once is safe.
+ this method more than once is safe. This will be called when ember is loaded
+ unless you have `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Array`
+ set to `false`.
+
+ Example
+
+ ```js
+ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Array) {
+ Ember.NativeArray.activate();
+ }
+ ```
@method activate
@for Ember.NativeArray | false |
Other | emberjs | ember.js | 8008c82cae5910586f2c5747ae79ea6152dcd05e.json | Add example to the View#disconnectOutlet docs | packages/ember-routing/lib/ext/view.js | @@ -21,10 +21,24 @@ Ember.View.reopen({
Allows you to connect a unique view as the parent
view's `{{outlet}}`.
+ Example
+
```javascript
+ var MyView = Ember.View.extend({
+ template: Ember.Handlebars.compile('Child view: {{outlet "main"}} ')
+ });
+ var myView = MyView.create();
+ myView.appendTo('body');
+ // The html for myView now looks like:
+ // <div id="ember228" class="ember-view">Child view: </div>
+
myView.connectOutlet('main', Ember.View.extend({
template: Ember.Handlebars.compile('<h1>Foo</h1> ')
}));
+ // The html for myView now looks like:
+ // <div id="ember228" class="ember-view">Child view:
+ // <div id="ember234" class="ember-view"><h1>Foo</h1> </div>
+ // </div>
```
@method connectOutlet
@param {String} outletName A unique name for the outlet
@@ -75,6 +89,30 @@ Ember.View.reopen({
/**
Removes an outlet from the current view.
+ Example
+
+ ```javascript
+ var MyView = Ember.View.extend({
+ template: Ember.Handlebars.compile('Child view: {{outlet "main"}} ')
+ });
+ var myView = MyView.create();
+ myView.appendTo('body');
+ // myView's html:
+ // <div id="ember228" class="ember-view">Child view: </div>
+
+ myView.connectOutlet('main', Ember.View.extend({
+ template: Ember.Handlebars.compile('<h1>Foo</h1> ')
+ }));
+ // myView's html:
+ // <div id="ember228" class="ember-view">Child view:
+ // <div id="ember234" class="ember-view"><h1>Foo</h1> </div>
+ // </div>
+
+ myView.disconnectOutlet('main');
+ // myView's html:
+ // <div id="ember228" class="ember-view">Child view: </div>
+ ```
+
@method disconnectOutlet
@param {String} outletName The name of the outlet to be removed
*/ | false |
Other | emberjs | ember.js | b0c6394ac68035298dd437a8d97387e034776d5d.json | Add examples to the Ember.computed docs | packages/ember-metal/lib/computed.js | @@ -467,6 +467,25 @@ function registerComputedWithProperties(name, macro) {
}
/**
+ A computed property that returns true of the value of the dependent
+ property is null, an empty string, empty array, or empty function.
+
+ Note: When using `Ember.computed.empty` to watch an array make sure to
+ use the `array.length` or `array.@each` syntax so the computed can
+ subscribe to transitions from empty to non-empty states.
+
+ Example
+
+```javascript
+ var ToDoList = Ember.Object.extend({
+ done: Ember.computed.empty('todos.length')
+ });
+ var todoList = ToDoList.create({todoList: ['Unit Test', 'Documentation', 'Release']});
+ todoList.get('done'); // false
+ todoList.get('todoList').clear(); // []
+ todoList.get('done'); // true
+ ```
+
@method computed.empty
@for Ember
@param {String} dependentKey
@@ -478,6 +497,21 @@ registerComputed('empty', function(dependentKey) {
});
/**
+ A computed property that returns true of the value of the dependent
+ property is NOT null, an empty string, empty array, or empty function.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ hasStuff: Ember.computed.notEmpty('backpack')
+ });
+ var hampster = Hampster.create({backpack: ['Food', 'Sleeping Bag', 'Tent']});
+ hampster.get('hasStuff'); // true
+ hampster.get('backpack').clear(); // []
+ hampster.get('hasStuff'); // false
+ ```
+
@method computed.notEmpty
@for Ember
@param {String} dependentKey
@@ -489,6 +523,24 @@ registerComputed('notEmpty', function(dependentKey) {
});
/**
+ A computed property that returns true of the value of the dependent
+ property is null or undefined. This avoids errors from JSLint complaining
+ about use of ==, which can be technically confusing.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ isHungry: Ember.computed.none('food')
+ });
+ var hampster = Hampster.create();
+ hampster.get('isHungry'); // true
+ hampster.set('food', 'Banana');
+ hampster.get('isHungry'); // false
+ hampster.set('food', null);
+ hampster.get('isHungry'); // true
+ ```
+
@method computed.none
@for Ember
@param {String} dependentKey
@@ -500,6 +552,21 @@ registerComputed('none', function(dependentKey) {
});
/**
+ A computed property that returns the inverse of the original value
+ for the dependent property.
+
+ Example
+
+ ```javascript
+ var User = Ember.Object.extend({
+ isAnonymous: Ember.computed.not('loggedIn')
+ });
+ var user = User.create({loggedIn: false});
+ user.get('isAnonymous'); // false
+ user.set('loggedIn', true);
+ user.get('isAnonymous'); // true
+ ```
+
@method computed.not
@for Ember
@param {String} dependentKey
@@ -511,6 +578,22 @@ registerComputed('not', function(dependentKey) {
});
/**
+ A computed property that which convert the dependent propery to a boolean.
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ hasBananas: Ember.computed.bool('numBananas')
+ });
+ var hampster = Hampster.create();
+ hampster.get('hasBananas'); // false
+ hampster.set('numBananas', 0);
+ hampster.get('hasBananas'); // false
+ hampster.set('numBananas', 1);
+ hampster.get('hasBananas'); // true
+ hampster.set('numBananas', null);
+ hampster.get('hasBananas'); // false
+ ```
+
@method computed.bool
@for Ember
@param {String} dependentKey
@@ -522,6 +605,23 @@ registerComputed('bool', function(dependentKey) {
});
/**
+ A computed property which matchs the original value for dependent property
+ against a given RegExp.
+
+ Example
+
+ ```javascript
+ var User = Ember.Object.extend({
+ hasValidEmail: Ember.computed.match('email', /^.+@.+\..+$/)
+ });
+ var user = User.create({loggedIn: false});
+ user.get('hasValidEmail'); // false
+ user.set('email', '');
+ user.get('hasValidEmail'); // false
+ user.set('email', 'ember_hampster@example.com');
+ user.get('hasValidEmail'); // true
+ ```
+
@method computed.match
@for Ember
@param {String} dependentKey
@@ -535,6 +635,23 @@ registerComputed('match', function(dependentKey, regexp) {
});
/**
+ A computed property that which returns true if dependent property is
+ equal to the given value.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ napTime: Ember.computed.equal('state', 'sleepy')
+ });
+ var hampster = Hampster.create();
+ hampster.get('napTime'); // false
+ hampster.set('state', 'sleepy');
+ hampster.get('napTime'); // false
+ hampster.set('state', 'hungry');
+ hampster.get('napTime'); // false
+ ```
+
@method computed.equal
@for Ember
@param {String} dependentKey
@@ -547,6 +664,23 @@ registerComputed('equal', function(dependentKey, value) {
});
/**
+ A computed property that which returns true if dependent property is
+ greater than the given value.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ hasTooManyBananas: Ember.computed.gt('numBananas', 10)
+ });
+ var hampster = Hampster.create();
+ hampster.get('hasTooManyBananas'); // false
+ hampster.set('numBananas', 3);
+ hampster.get('hasTooManyBananas'); // false
+ hampster.set('numBananas', 11);
+ hampster.get('hasTooManyBananas'); // true
+ ```
+
@method computed.gt
@for Ember
@param {String} dependentKey
@@ -559,6 +693,23 @@ registerComputed('gt', function(dependentKey, value) {
});
/**
+ A computed property that which returns true if dependent property is
+ greater than or equal to the given value.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ hasTooManyBananas: Ember.computed.gte('numBananas', 10)
+ });
+ var hampster = Hampster.create();
+ hampster.get('hasTooManyBananas'); // false
+ hampster.set('numBananas', 3);
+ hampster.get('hasTooManyBananas'); // false
+ hampster.set('numBananas', 10);
+ hampster.get('hasTooManyBananas'); // true
+ ```
+
@method computed.gte
@for Ember
@param {String} dependentKey
@@ -571,6 +722,23 @@ registerComputed('gte', function(dependentKey, value) {
});
/**
+ A computed property that which returns true if dependent property is
+ less than the given value.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ needsMoreBananas: Ember.computed.lt('numBananas', 3)
+ });
+ var hampster = Hampster.create();
+ hampster.get('needsMoreBananas'); // true
+ hampster.set('numBananas', 3);
+ hampster.get('needsMoreBananas'); // false
+ hampster.set('numBananas', 2);
+ hampster.get('needsMoreBananas'); // true
+ ```
+
@method computed.lt
@for Ember
@param {String} dependentKey
@@ -583,6 +751,23 @@ registerComputed('lt', function(dependentKey, value) {
});
/**
+ A computed property that which returns true if dependent property is
+ less than or equal to the given value.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ needsMoreBananas: Ember.computed.lte('numBananas', 3)
+ });
+ var hampster = Hampster.create();
+ hampster.get('needsMoreBananas'); // true
+ hampster.set('numBananas', 5);
+ hampster.get('needsMoreBananas'); // false
+ hampster.set('numBananas', 3);
+ hampster.get('needsMoreBananas'); // true
+ ```
+
@method computed.lte
@for Ember
@param {String} dependentKey
@@ -595,10 +780,27 @@ registerComputed('lte', function(dependentKey, value) {
});
/**
+ A computed property that which performs a logical `and` on the
+ values of all the original values for dependent properties.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ readyForCamp: Ember.computed.and('hasTent', 'hasBackpack')
+ });
+ var hampster = Hampster.create();
+ hampster.get('readyForCamp'); // false
+ hampster.set('hasTent', true);
+ hampster.get('readyForCamp'); // false
+ hampster.set('hasBackpack', true);
+ hampster.get('readyForCamp'); // true
+ ```
+
@method computed.and
@for Ember
@param {String} dependentKey, [dependentKey...]
- @return {Ember.ComputedProperty} computed property which peforms
+ @return {Ember.ComputedProperty} computed property which performs
a logical `and` on the values of all the original values for properties.
*/
registerComputedWithProperties('and', function(properties) {
@@ -611,10 +813,25 @@ registerComputedWithProperties('and', function(properties) {
});
/**
+ A computed property that which performs a logical `or` on the
+ values of all the original values for dependent properties.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella')
+ });
+ var hampster = Hampster.create();
+ hampster.get('readyForRain'); // false
+ hampster.set('hasJacket', true);
+ hampster.get('readyForRain'); // true
+ ```
+
@method computed.or
@for Ember
@param {String} dependentKey, [dependentKey...]
- @return {Ember.ComputedProperty} computed property which peforms
+ @return {Ember.ComputedProperty} computed property which performs
a logical `or` on the values of all the original values for properties.
*/
registerComputedWithProperties('or', function(properties) {
@@ -627,6 +844,21 @@ registerComputedWithProperties('or', function(properties) {
});
/**
+ A computed property that which returns the first truthy value
+ of a given list of dependent properties.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ hasClothes: Ember.computed.any('hat', 'shirt')
+ });
+ var hampster = Hampster.create();
+ hampster.get('hasClothes'); // null
+ hampster.set('shirt', 'Hawaiian Shirt');
+ hampster.get('hasClothes'); // 'Hawaiian Shirt'
+ ```
+
@method computed.any
@for Ember
@param {String} dependentKey, [dependentKey...]
@@ -643,6 +875,22 @@ registerComputedWithProperties('any', function(properties) {
});
/**
+ A computed property that which returns the first truthy value
+ of a given list of dependent properties.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ clothes: Ember.computed.map('hat', 'shirt')
+ });
+ var hampster = Hampster.create();
+ hampster.get('clothes'); // [null, null]
+ hampster.set('hat', 'Camp Hat');
+ hampster.set('shirt', 'Camp Shirt');
+ hampster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
+ ```
+
@method computed.map
@for Ember
@param {String} dependentKey, [dependentKey...]
@@ -699,18 +947,14 @@ Ember.computed.alias = function(dependentKey) {
};
/**
- @method computed.oneWay
- @for Ember
- @param {String} dependentKey
- @return {Ember.ComputedProperty} computed property which creates an
- one way computed property to the original value for property.
-
- Where `computed.alias` aliases `get` and `set`, and allows for bidirectional
+ Where `computed.alias` aliases `get` and `set`, and allows for bidirectional
data flow, `computed.oneWay` only provides an aliased `get`. The `set` will
not mutate the upstream property, rather causes the current property to
become the value set. This causes the downstream property to permentantly
diverge from the upstream property.
+ Example
+
```javascript
User = Ember.Object.extend({
firstName: null,
@@ -732,6 +976,12 @@ Ember.computed.alias = function(dependentKey) {
user.get('firstName');
# 'Teddy'
```
+
+ @method computed.oneWay
+ @for Ember
+ @param {String} dependentKey
+ @return {Ember.ComputedProperty} computed property which creates an
+ one way computed property to the original value for property.
*/
Ember.computed.oneWay = function(dependentKey) {
return Ember.computed(dependentKey, function() {
@@ -741,6 +991,22 @@ Ember.computed.oneWay = function(dependentKey) {
/**
+ A computed property that which acts like a standard getter
+ and setter, but defaults to the value from `defaultPath`.
+
+ Example
+
+ ```javascript
+ var Hampster = Ember.Object.extend({
+ wishList: Ember.computed.defaultTo('favoriteFood')
+ });
+ var hampster = Hampster.create({favoriteFood: 'Banana'});
+ hampster.get('wishList'); // 'Banana'
+ hampster.set('wishList', 'More Unit Tests');
+ hampster.get('wishList'); // 'More Unit Tests'
+ hampster.get('favoriteFood'); // 'Banana'
+ ```
+
@method computed.defaultTo
@for Ember
@param {String} defaultPath | false |
Other | emberjs | ember.js | 9ebb56e43184eed021a2059be08b58d9f8431e0e.json | Add examples to the Ember.Route docs | packages/ember-routing/lib/system/route.js | @@ -212,9 +212,30 @@ Ember.Route = Ember.Object.extend({
route in question. The model will be serialized into the URL
using the `serialize` hook.
+ Example
+
+ ```javascript
+ App.Router.map(function() {
+ this.route("index");
+ this.route("secret");
+ this.route("fourOhFour", { path: "*:"});
+ });
+
+ App.IndexRoute = Ember.Route.extend({
+ events: {
+ moveToSecret: function(context){
+ if (authorized()){
+ this.transitionTo('secret', context);
+ }
+ this.transitionTo('fourOhFour');
+ }
+ }
+ });
+ ```
+
@method transitionTo
@param {String} name the name of the route
- @param {...Object} models the
+ @param {...Object} models
*/
transitionTo: function(name, context) {
var router = this.router;
@@ -228,15 +249,65 @@ Ember.Route = Ember.Object.extend({
Of the bundled location types, only `history` currently supports
this behavior.
+ Example
+
+ ```javascript
+ App.Router.map(function() {
+ this.route("index");
+ this.route("secret");
+ });
+
+ App.SecretRoute = Ember.Route.extend({
+ afterModel: function() {
+ if (!authorized()){
+ this.replaceWith('index');
+ }
+ }
+ });
+ ```
+
@method replaceWith
@param {String} name the name of the route
- @param {...Object} models the
+ @param {...Object} models
*/
replaceWith: function() {
var router = this.router;
return this.router.replaceWith.apply(this.router, arguments);
},
+ /**
+ Triggers and event on a parent route.
+
+ Example
+
+ ```javascript
+ App.Router.map(function() {
+ this.route("index");
+ });
+
+ App.ApplicationRoute = Ember.Route.extend({
+ events: {
+ track: function(arg) {
+ console.log(arg, 'was clicked');
+ }
+ }
+ });
+
+ App.IndexRoute = Ember.Route.extend({
+ events: {
+ trackIfDebug: function(arg) {
+ if (debug) {
+ this.send('track', arg);
+ }
+ }
+ }
+ });
+ ```
+
+ @method send
+ @param {String} name the name of the event to trigger
+ @param {...*} args
+ */
send: function() {
return this.router.send.apply(this.router, arguments);
},
@@ -446,6 +517,16 @@ Ember.Route = Ember.Object.extend({
if a promise returned from `model` fails, the error will be
handled by the `error` hook on `Ember.Route`.
+ Example
+
+ ```js
+ App.PostRoute = Ember.Route.extend({
+ model: function(params) {
+ return App.Post.find(params.post_id);
+ }
+ });
+ ```
+
@method model
@param {Object} params the parameters extracted from the URL
@param {Transition} transition
@@ -557,7 +638,18 @@ Ember.Route = Ember.Object.extend({
be used if it is defined. If it is not defined, an `Ember.ObjectController`
instance would be used.
+ Example
+ ```js
+ App.PostRoute = Ember.Route.extend({
+ setupController: function(controller, model) {
+ controller.set('model', model);
+ }
+ });
+ ```
+
@method setupController
+ @param {Controller} controller instance
+ @param {Object} model
*/
setupController: function(controller, context) {
if (controller && (context !== undefined)) {
@@ -609,6 +701,17 @@ Ember.Route = Ember.Object.extend({
If the optional model is passed then the controller type is determined automatically,
e.g., an ArrayController for arrays.
+ Example
+
+ ```js
+ App.PostRoute = Ember.Route.extend({
+ setupController: function(controller, post) {
+ this._super(controller, post);
+ this.generateController('posts', post);
+ }
+ });
+ ```
+
@method generateController
@param {String} name the name of the controller
@param {Object} model the model to infer the type of the controller (optional)
@@ -627,6 +730,22 @@ Ember.Route = Ember.Object.extend({
This is the object returned by the `model` hook of the route
in question.
+ Example
+
+ ```js
+ App.Router.map(function() {
+ this.resource('post', { path: '/post/:post_id' }, function() {
+ this.resource('comments');
+ });
+ });
+
+ App.CommentsRoute = Ember.Route.extend({
+ afterModel: function() {
+ this.set('post', this.modelFor('post'));
+ }
+ });
+ ```
+
@method modelFor
@param {String} name the name of the route
@return {Object} the model object
@@ -658,6 +777,22 @@ Ember.Route = Ember.Object.extend({
This method can be overridden to set up and render additional or
alternative templates.
+ ```js
+ App.PostsRoute = Ember.Route.extend({
+ renderTemplate: function(controller, model) {
+ var favController = this.controllerFor('favoritePost');
+
+ // Render the `favoritePost` template into
+ // the outlet `posts`, and display the `favoritePost`
+ // controller.
+ this.render('favoritePost', {
+ outlet: 'posts',
+ controller: favController
+ });
+ }
+ });
+ ```
+
@method renderTemplate
@param {Object} controller the route's controller
@param {Object} model the route's model
@@ -795,6 +930,11 @@ Ember.Route = Ember.Object.extend({
this.teardownViews();
},
+ /**
+ @private
+
+ @method teardownViews
+ */
teardownViews: function() {
// Tear down the top level view
if (this.teardownTopLevelView) { this.teardownTopLevelView(); } | false |
Other | emberjs | ember.js | a1080d93578b6cae80819fd96f3429536c542e18.json | Fix YUIDoc warning: ignore private function. | packages/ember-testing/lib/support.js | @@ -23,7 +23,7 @@ function testCheckboxClick(handler) {
}
$(function() {
- /**
+ /*
Determine whether a checkbox checked using jQuery's "click" method will have
the correct value for its checked property.
| false |
Other | emberjs | ember.js | e05c26b6f889bcee5c20115ad31dcaad163f1027.json | Add additional packages to doc generation. | docs/yuidoc.json | @@ -13,7 +13,9 @@
"../packages/ember-views/lib",
"../packages/ember-handlebars/lib",
"../packages/ember-routing/lib",
- "../packages/ember-application/lib"
+ "../packages/ember-application/lib",
+ "../packages/ember-testing/lib",
+ "../packages/ember-handlebars-compiler/lib"
],
"exclude": "vendor",
"outdir": "./build" | false |
Other | emberjs | ember.js | 1745e57010f3807c2aec8cab43c280fe28723237.json | Add example for setProperties | packages/ember-metal/lib/set_properties.js | @@ -9,6 +9,14 @@ var changeProperties = Ember.changeProperties,
a single `beginPropertyChanges` and `endPropertyChanges` batch, so
observers will be buffered.
+ ```javascript
+ anObject.setProperties({
+ firstName: "Stanley",
+ lastName: "Stuart",
+ age: "21"
+ })
+ ```
+
@method setProperties
@param self
@param {Object} hash | false |
Other | emberjs | ember.js | 3ef443b42171ddad81829032caa9bd733729f3ae.json | Improve example for {{loc}} | packages/ember-handlebars/lib/helpers/loc.js | @@ -8,15 +8,24 @@ require('ember-handlebars/ext');
/**
`loc` looks up the string in the localized strings hash.
This is a convenient way to localize text. For example:
+
+ ```javascript
+ App.ApplicationController = Ember.Controller.extend({
+ welcomeMessage: '_Hello World'
+ });
- ```html
- <script type="text/x-handlebars" data-template-name="home">
- {{loc welcome}}
- </script>
+ Ember.STRINGS = {
+ '_Hello World': 'Bonjour le monde',
+ };
```
- Take note that `welcome` is a string and not an object
- reference.
+ ```handlebars
+ <span>{{loc welcomeMessage}}<span>
+ ```
+
+ ```html
+ <span>Bonjour le monde</span>
+ ```
@method loc
@for Ember.Handlebars.helpers | false |
Other | emberjs | ember.js | a13e9894a027b28b9ad05bde62d103acb881532f.json | Remove globals from Ember.Select documentation | packages/ember-handlebars/lib/controls/select.js | @@ -94,11 +94,13 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
Example:
```javascript
- App.names = ["Yehuda", "Tom"];
+ App.ApplicationController = Ember.Controller.extend({
+ names: ["Yehuda", "Tom"]
+ });
```
```handlebars
- {{view Ember.Select contentBinding="App.names"}}
+ {{view Ember.Select contentBinding="names"}}
```
Would result in the following HTML:
@@ -114,16 +116,16 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
`value` property directly or as a binding:
```javascript
- App.names = Ember.Object.create({
- selected: 'Tom',
- content: ["Yehuda", "Tom"]
+ App.ApplicationController = Ember.Controller.extend({
+ selectedName: 'Tom',
+ names: ["Yehuda", "Tom"]
});
```
```handlebars
{{view Ember.Select
- contentBinding="App.names.content"
- valueBinding="App.names.selected"
+ contentBinding="names"
+ valueBinding="selectedName"
}}
```
@@ -137,7 +139,7 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
```
A user interacting with the rendered `<select>` to choose "Yehuda" would
- update the value of `App.names.selected` to "Yehuda".
+ update the value of `selectedName` to "Yehuda".
### `content` as an Array of Objects
@@ -154,15 +156,17 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
element's text. Both paths must reference each object itself as `content`:
```javascript
- App.programmers = [
- Ember.Object.create({firstName: "Yehuda", id: 1}),
- Ember.Object.create({firstName: "Tom", id: 2})
- ];
+ App.ApplicationController = Ember.Controller.extend({
+ programmers: [
+ {firstName: "Yehuda", id: 1},
+ {firstName: "Tom", id: 2}
+ ]
+ });
```
```handlebars
{{view Ember.Select
- contentBinding="App.programmers"
+ contentBinding="programmers"
optionValuePath="content.id"
optionLabelPath="content.firstName"}}
```
@@ -181,22 +185,23 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
`valueBinding` option:
```javascript
- App.programmers = [
- Ember.Object.create({firstName: "Yehuda", id: 1}),
- Ember.Object.create({firstName: "Tom", id: 2})
- ];
-
- App.currentProgrammer = Ember.Object.create({
- id: 2
+ App.ApplicationController = Ember.Controller.extend({
+ programmers: [
+ {firstName: "Yehuda", id: 1},
+ {firstName: "Tom", id: 2}
+ ],
+ currentProgrammer: {
+ id: 2
+ }
});
```
```handlebars
{{view Ember.Select
- contentBinding="App.programmers"
+ contentBinding="programmers"
optionValuePath="content.id"
optionLabelPath="content.firstName"
- valueBinding="App.currentProgrammer.id"}}
+ valueBinding="currentProgrammer.id"}}
```
Would result in the following HTML with a selected option:
@@ -209,7 +214,7 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
```
Interacting with the rendered element by selecting the first option
- ('Yehuda') will update the `id` value of `App.currentProgrammer`
+ ('Yehuda') will update the `id` of `currentProgrammer`
to match the `value` property of the newly selected `<option>`.
Alternatively, you can control selection through the underlying objects
@@ -219,21 +224,21 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
element:
```javascript
- App.controller = Ember.Object.create({
+ App.ApplicationController = Ember.Controller.extend({
selectedPerson: null,
- content: [
- Ember.Object.create({firstName: "Yehuda", id: 1}),
- Ember.Object.create({firstName: "Tom", id: 2})
+ programmers: [
+ {firstName: "Yehuda", id: 1},
+ {firstName: "Tom", id: 2}
]
});
```
```handlebars
{{view Ember.Select
- contentBinding="App.controller.content"
+ contentBinding="programmers"
optionValuePath="content.id"
optionLabelPath="content.firstName"
- selectionBinding="App.controller.selectedPerson"}}
+ selectionBinding="selectedPerson"}}
```
Would result in the following HTML with a selected option:
@@ -246,19 +251,19 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
```
Interacting with the rendered element by selecting the first option
- ('Yehuda') will update the `selectedPerson` value of `App.controller`
- to match the content object of the newly selected `<option>`. In this
- case it is the first object in the `App.controller.content`
+ ('Yehuda') will update the `selectedPerson` to match the object of
+ the newly selected `<option>`. In this case it is the first object
+ in the `programmers`
### Supplying a Prompt
A `null` value for the `Ember.Select`'s `value` or `selection` property
results in there being no `<option>` with a `selected` attribute:
```javascript
- App.controller = Ember.Object.create({
- selected: null,
- content: [
+ App.ApplicationController = Ember.Controller.extend({
+ selectedProgrammer: null,
+ programmers: [
"Yehuda",
"Tom"
]
@@ -267,8 +272,8 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
``` handlebars
{{view Ember.Select
- contentBinding="App.controller.content"
- valueBinding="App.controller.selected"
+ contentBinding="programmers"
+ valueBinding="selectedProgrammer"
}}
```
@@ -281,16 +286,16 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
</select>
```
- Although `App.controller.selected` is `null` and no `<option>`
+ Although `selectedProgrammer` is `null` and no `<option>`
has a `selected` attribute the rendered HTML will display the
first item as though it were selected. You can supply a string
value for the `Ember.Select` to display when there is no selection
with the `prompt` option:
```javascript
- App.controller = Ember.Object.create({
- selected: null,
- content: [
+ App.ApplicationController = Ember.Controller.extend({
+ selectedProgrammer: null,
+ programmers: [
"Yehuda",
"Tom"
]
@@ -299,8 +304,8 @@ Ember.SelectOptgroup = Ember.CollectionView.extend({
```handlebars
{{view Ember.Select
- contentBinding="App.controller.content"
- valueBinding="App.controller.selected"
+ contentBinding="programmers"
+ valueBinding="selectedProgrammer"
prompt="Please select a name"
}}
```
@@ -337,6 +342,14 @@ Ember.Select = Ember.View.extend(
*/
multiple: false,
+ /**
+ The `disabled` attribute of the select element. Indicates whether
+ the element is disabled from interactions.
+
+ @property multiple
+ @type Boolean
+ @default false
+ */
disabled: false,
/** | false |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-metal/lib/events.js | @@ -9,6 +9,7 @@ require('ember-metal/utils');
var o_create = Ember.create,
metaFor = Ember.meta,
META_KEY = Ember.META_KEY,
+ a_slice = [].slice,
/* listener flags */
ONCE = 1, SUSPENDED = 2;
@@ -368,6 +369,31 @@ function listenersFor(obj, eventName) {
return ret;
}
+/**
+ Define a property as a function that should be executed when
+ a specified event or events are triggered.
+
+ var Job = Ember.Object.extend({
+ logCompleted: Ember.on('completed', function(){
+ console.log('Job completed!');
+ })
+ });
+ var job = Job.create();
+ Ember.sendEvent(job, 'completed'); // Logs "Job completed!"
+
+ @method on
+ @for Ember
+ @param {String} eventNames*
+ @param {Function} func
+ @return func
+*/
+Ember.on = function(){
+ var func = a_slice.call(arguments, -1)[0],
+ events = a_slice.call(arguments, 0, -1);
+ func.__ember_listens__ = events;
+ return func;
+};
+
Ember.addListener = addListener;
Ember.removeListener = removeListener;
Ember._suspendListener = suspendListener; | true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-metal/lib/mixin.js | @@ -178,7 +178,7 @@ function addNormalizedProperty(base, key, value, meta, descs, values, concats, m
// impl super if needed...
if (isMethod(value)) {
value = giveMethodSuper(base, key, value, values, descs);
- } else if ((concats && a_indexOf.call(concats, key) >= 0) ||
+ } else if ((concats && a_indexOf.call(concats, key) >= 0) ||
key === 'concatenatedProperties' ||
key === 'mergedProperties') {
value = applyConcatenatedProperties(base, key, value, values);
@@ -284,26 +284,30 @@ function followAlias(obj, desc, m, descs, values) {
return { desc: desc, value: value };
}
-function updateObservers(obj, key, observer, observerKey, method) {
- if ('function' !== typeof observer) { return; }
-
- var paths = observer[observerKey];
+function updateObserversAndListeners(obj, key, observerOrListener, pathsKey, updateMethod) {
+ var paths = observerOrListener[pathsKey];
if (paths) {
for (var i=0, l=paths.length; i<l; i++) {
- Ember[method](obj, paths[i], null, key);
+ Ember[updateMethod](obj, paths[i], null, key);
}
}
}
-function replaceObservers(obj, key, observer) {
- var prevObserver = obj[key];
+function replaceObserversAndListeners(obj, key, observerOrListener) {
+ var prev = obj[key];
- updateObservers(obj, key, prevObserver, '__ember_observesBefore__', 'removeBeforeObserver');
- updateObservers(obj, key, prevObserver, '__ember_observes__', 'removeObserver');
+ if ('function' === typeof prev) {
+ updateObserversAndListeners(obj, key, prev, '__ember_observesBefore__', 'removeBeforeObserver');
+ updateObserversAndListeners(obj, key, prev, '__ember_observes__', 'removeObserver');
+ updateObserversAndListeners(obj, key, prev, '__ember_listens__', 'removeListener');
+ }
- updateObservers(obj, key, observer, '__ember_observesBefore__', 'addBeforeObserver');
- updateObservers(obj, key, observer, '__ember_observes__', 'addObserver');
+ if ('function' === typeof observerOrListener) {
+ updateObserversAndListeners(obj, key, observerOrListener, '__ember_observesBefore__', 'addBeforeObserver');
+ updateObserversAndListeners(obj, key, observerOrListener, '__ember_observes__', 'addObserver');
+ updateObserversAndListeners(obj, key, observerOrListener, '__ember_listens__', 'addListener');
+ }
}
function applyMixin(obj, mixins, partial) {
@@ -336,7 +340,7 @@ function applyMixin(obj, mixins, partial) {
if (desc === undefined && value === undefined) { continue; }
- replaceObservers(obj, key, value);
+ replaceObserversAndListeners(obj, key, value);
detectBinding(obj, key, value, m);
defineProperty(obj, key, desc, value, m);
} | true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-metal/lib/utils.js | @@ -321,6 +321,7 @@ Ember.wrap = function(func, superFunc) {
superWrapper.wrappedFunction = func;
superWrapper.__ember_observes__ = func.__ember_observes__;
superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__;
+ superWrapper.__ember_listens__ = func.__ember_listens__;
return superWrapper;
}; | true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-metal/tests/events_test.js | @@ -211,3 +211,47 @@ test('while suspended, it should not be possible to add a duplicate listener', f
equal(target.count, 2, 'should have invoked again');
equal(Ember.meta(obj).listeners['event!'].length, 1, "a duplicate listener wasn't added");
});
+
+test('a listener can be added as part of a mixin', function() {
+ var triggered = 0;
+ var MyMixin = Ember.Mixin.create({
+ foo1: Ember.on('bar', function() {
+ triggered++;
+ }),
+
+ foo2: Ember.on('bar', function() {
+ triggered++;
+ })
+ });
+
+ var obj = {};
+ MyMixin.apply(obj);
+
+ Ember.sendEvent(obj, 'bar');
+ equal(triggered, 2, 'should invoke listeners');
+});
+
+test('a listener added as part of a mixin may be overridden', function() {
+
+ var triggered = 0;
+ var FirstMixin = Ember.Mixin.create({
+ foo: Ember.on('bar', function() {
+ triggered++;
+ })
+ });
+ var SecondMixin = Ember.Mixin.create({
+ foo: Ember.on('baz', function() {
+ triggered++;
+ })
+ });
+
+ var obj = {};
+ FirstMixin.apply(obj);
+ SecondMixin.apply(obj);
+
+ Ember.sendEvent(obj, 'bar');
+ equal(triggered, 0, 'should not invoke from overriden property');
+
+ Ember.sendEvent(obj, 'baz');
+ equal(triggered, 1, 'should invoke from subclass property');
+}); | true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-runtime/lib/ext/function.js | @@ -86,7 +86,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
});
```
- See `Ember.Observable.observes`.
+ See `Ember.observes`.
@method observes
@for Function
@@ -113,7 +113,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
});
```
- See `Ember.Observable.observesBefore`.
+ See `Ember.observesBefore`.
@method observesBefore
@for Function
@@ -123,5 +123,31 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) {
return this;
};
+ /**
+ The `on` extension of Javascript's Function prototype is available
+ when `Ember.EXTEND_PROTOTYPES` or `Ember.EXTEND_PROTOTYPES.Function` is
+ true, which is the default.
+
+ You can listen for events simply by adding the `on` call to the end of
+ your method declarations in classes or mixins that you write. For example:
+
+ ```javascript
+ Ember.Mixin.create({
+ doSomethingWithElement: function() {
+ // Executes whenever the "didInsertElement" event fires
+ }.on('didInsertElement')
+ });
+ ```
+
+ See `Ember.on`.
+
+ @method on
+ @for Function
+ */
+ Function.prototype.on = function() {
+ var events = a_slice.call(arguments);
+ this.__ember_listens__ = events;
+ return this;
+ };
}
| true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-runtime/lib/system/core_object.js | @@ -19,6 +19,7 @@ var set = Ember.set, get = Ember.get,
meta = Ember.meta,
rewatch = Ember.rewatch,
finishChains = Ember.finishChains,
+ sendEvent = Ember.sendEvent,
destroy = Ember.destroy,
schedule = Ember.run.schedule,
Mixin = Ember.Mixin,
@@ -122,6 +123,7 @@ function makeCtor() {
delete m.proto;
finishChains(this);
this.init.apply(this, arguments);
+ sendEvent(this, "didInit");
};
Class.toString = Mixin.prototype.toString; | true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-runtime/tests/ext/function_test.js | @@ -29,3 +29,53 @@ testBoth('global observer helper takes multiple params', function(get, set) {
equal(get(obj, 'count'), 2, 'should invoke observer after change');
});
+module('Function.prototype.on() helper');
+
+testBoth('sets up an event listener, and can trigger the function on multiple events', function(get, set) {
+
+ if (Ember.EXTEND_PROTOTYPES === false) {
+ ok('Function.prototype helper disabled');
+ return ;
+ }
+
+ var MyMixin = Ember.Mixin.create({
+
+ count: 0,
+
+ foo: function() {
+ set(this, 'count', get(this, 'count')+1);
+ }.on('bar', 'baz')
+
+ });
+
+ var obj = Ember.mixin({}, Ember.Evented, MyMixin);
+ equal(get(obj, 'count'), 0, 'should not invoke listener immediately');
+
+ obj.trigger('bar');
+ obj.trigger('baz');
+ equal(get(obj, 'count'), 2, 'should invoke listeners when events trigger');
+});
+
+testBoth('can be chained with observes', function(get, set) {
+
+ if (Ember.EXTEND_PROTOTYPES === false) {
+ ok('Function.prototype helper disabled');
+ return ;
+ }
+
+ var MyMixin = Ember.Mixin.create({
+
+ count: 0,
+ bay: 'bay',
+ foo: function() {
+ set(this, 'count', get(this, 'count')+1);
+ }.observes('bay').on('bar')
+ });
+
+ var obj = Ember.mixin({}, Ember.Evented, MyMixin);
+ equal(get(obj, 'count'), 0, 'should not invoke listener immediately');
+
+ set(obj, 'bay', 'BAY');
+ obj.trigger('bar');
+ equal(get(obj, 'count'), 2, 'should invoke observer and listener');
+}); | true |
Other | emberjs | ember.js | ca04bee6c8c43140d5cad2307ce6fbafeb5d9488.json | Add Ember.on, Function.prototype.on, didInit event
This commit adds `Ember.on(eventName, func)` and `Function.prototype.on`
as cousins to `Ember.observes` and `Function.prototype.observes`. This
provides a declarative form of marking methods to execute when an event
fires.
This is useful for mixins which need to do things on `didInsertElement` and `willDestroyElement`, but don't want to force a call to `super` from the classes that include it:
Ember.Mixin.create({
doSomethingWithElement: function() {
// Executes whenever the "didInsertElement" event fires, regardless of the presence of a method named `didInsertElement`
}.on('didInsertElement')
});
In addition, this commit also makes Ember.Object send a `didInit` event after initializing. This provides for an elegant solution to a common need: marking a function as an observer and also executing it at creation time. e.g.
Ember.Object.extend({
upateOptions: function(){
var opts = this.get('controller.foo').importantTransform();
this.set('options', opts);
}.observes('controller.foo').on('didInit')
}); | packages/ember-runtime/tests/system/object/create_test.js | @@ -167,6 +167,17 @@ test("Calls all mixin inits if defined", function() {
equal(completed, 2, 'should have called init for both mixins.');
});
+test("Triggers didInit", function() {
+ var completed = false;
+ var obj = Ember.Object.createWithMixins({
+ markAsCompleted: Ember.on("didInit", function(){
+ completed = true;
+ })
+ });
+
+ ok(completed, 'should have triggered didInit which should have run markAsCompleted');
+});
+
test('creating an object with required properties', function() {
var ClassA = Ember.Object.extend({
foo: Ember.required() | true |
Other | emberjs | ember.js | a5ee696e1f8ba277483c2e0ada3799ec880051ed.json | Explain groupedRows option in #each helper | packages/ember-handlebars/lib/helpers/each.js | @@ -308,13 +308,57 @@ GroupedEach.prototype = {
Each itemController will receive a reference to the current controller as
a `parentController` property.
+ ### (Experimental) Grouped Each
+
+ When used in conjunction with the experimental [group helper](https://github.com/emberjs/group-helper),
+ you can inform Handlebars to re-render an entire group of items instead of
+ re-rendering them one at a time (in the event that they are changed en masse
+ or an item is added/removed).
+
+ ```handlebars
+ {{#group}}
+ {{#each people}}
+ {{firstName}} {{lastName}}
+ {{/each}}
+ {{/group}}
+ ```
+
+ This can be faster than the normal way that Handlebars re-renders items
+ in some cases.
+
+ If for some reason you have a group with more than one `#each`, you can make
+ one of the collections be updated in normal (non-grouped) fashion by setting
+ the option `groupedRows=true` (counter-intuitive, I know).
+
+ For example,
+
+ ```handlebars
+ {{dealershipName}}
+
+ {{#group}}
+ {{#each dealers}}
+ {{firstName}} {{lastName}}
+ {{/each}}
+
+ {{#each car in cars groupedRows=true}}
+ {{car.make}} {{car.model}} {{car.color}}
+ {{/each}}
+ {{/group}}
+ ```
+ Any change to `dealershipName` or the `dealers` collection will cause the
+ entire group to be re-rendered. However, changes to the `cars` collection
+ will be re-rendered individually (as normal).
+
+ Note that `group` behavior is also disabled by specifying an `itemViewClass`.
+
@method each
@for Ember.Handlebars.helpers
@param [name] {String} name for item (used with `in`)
@param [path] {String} path
@param [options] {Object} Handlebars key/value pairs of options
@param [options.itemViewClass] {String} a path to a view class used for each item
@param [options.itemController] {String} name of a controller to be created for each item
+ @param [options.groupedRows] {boolean} enable normal item-by-item rendering when inside a `#group` helper
*/
Ember.Handlebars.registerHelper('each', function(path, options) {
if (arguments.length === 4) { | false |
Other | emberjs | ember.js | 988b7aed307399358d762468b13ea3ce07ccf53b.json | remove unnecessary code in loader.js | packages/loader/lib/main.js | @@ -22,7 +22,6 @@ var define, requireModule;
deps = mod.deps;
callback = mod.callback;
reified = [];
- exports;
for (var i=0, l=deps.length; i<l; i++) {
if (deps[i] === 'exports') { | false |
Other | emberjs | ember.js | 268705d6f0769e8b578e0e9f5052f78a6623d07d.json | Remove dead method `Route#deserialize`
`Ember.Route#deserialize` is not called anywhere. | packages/ember/tests/helpers/link_to_test.js | @@ -375,10 +375,6 @@ test("The {{linkTo}} helper moves into the named route with context", function()
App.ItemRoute = Ember.Route.extend({
serialize: function(object) {
return { id: object.id };
- },
-
- deserialize: function(params) {
- return { id: params.id, name: people[params.id] };
}
});
| false |
Other | emberjs | ember.js | 9c1a911eac841296fc483f8a26114c19f0151ae5.json | Fix RC7 version number. | packages/ember-metal/lib/core.js | @@ -49,10 +49,10 @@ Ember.toString = function() { return "Ember"; };
/**
@property VERSION
@type String
- @default '1.0.0-rc.7.1'
+ @default '1.0.0-rc.7'
@final
*/
-Ember.VERSION = '1.0.0-rc.7.1';
+Ember.VERSION = '1.0.0-rc.7';
/**
Standard environmental variables. You can define these in a global `ENV` | false |
Other | emberjs | ember.js | a6d5f9574d32f3920f4dd738b8b90ca1667d9d58.json | Add rel attribute binding to linkTo helper | packages/ember-routing/lib/helpers/link_to.js | @@ -62,6 +62,14 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
**/
title: null,
+ /**
+ Sets the `rel` attribute of the `LinkView`'s HTML element.
+
+ @property rel
+ @default null
+ **/
+ rel: null,
+
/**
The CSS class to apply to `LinkView`'s element when its `active`
property is `true`.
@@ -102,7 +110,7 @@ Ember.onLoad('Ember.Handlebars', function(Handlebars) {
@default false
**/
replace: false,
- attributeBindings: ['href', 'title'],
+ attributeBindings: ['href', 'title', 'rel'],
classNameBindings: ['active', 'loading', 'disabled'],
/** | true |
Other | emberjs | ember.js | a6d5f9574d32f3920f4dd738b8b90ca1667d9d58.json | Add rel attribute binding to linkTo helper | packages/ember/tests/helpers/link_to_test.js | @@ -414,14 +414,16 @@ test("The {{linkTo}} helper moves into the named route with context", function()
});
test("The {{linkTo}} helper binds some anchor html tag common attributes", function() {
- Ember.TEMPLATES.index = Ember.Handlebars.compile("<h3>Home</h3>{{#linkTo 'index' id='self-link' title='title-attr'}}Self{{/linkTo}}");
+ Ember.TEMPLATES.index = Ember.Handlebars.compile("<h3>Home</h3>{{#linkTo 'index' id='self-link' title='title-attr' rel='rel-attr'}}Self{{/linkTo}}");
bootApplication();
Ember.run(function() {
router.handleURL("/");
});
-
- equal(Ember.$('#self-link', '#qunit-fixture').attr('title'), 'title-attr', "The self-link contains title attribute");
+
+ var link = Ember.$('#self-link', '#qunit-fixture');
+ equal(link.attr('title'), 'title-attr', "The self-link contains title attribute");
+ equal(link.attr('rel'), 'rel-attr', "The self-link contains rel attribute");
});
test("The {{linkTo}} helper accepts string/numeric arguments", function() { | true |
Other | emberjs | ember.js | 11cfa1f8f664197531758d1849557b4522dd0771.json | Add Ember.DataAdapter in ember-extension-support | Assetfile | @@ -4,7 +4,7 @@ distros = {
"runtime" => %w(ember-metal rsvp container ember-runtime),
"template-compiler" => %w(ember-handlebars-compiler),
"data-deps" => %w(ember-metal rsvp container ember-runtime ember-states),
- "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph handlebars ember-handlebars-compiler ember-handlebars ember-routing ember-application ember-states)
+ "full" => %w(ember-metal rsvp container ember-runtime ember-views metamorph handlebars ember-handlebars-compiler ember-handlebars ember-routing ember-application ember-states ember-extension-support)
}
class AddMicroLoader < Rake::Pipeline::Filter | true |
Other | emberjs | ember.js | 11cfa1f8f664197531758d1849557b4522dd0771.json | Add Ember.DataAdapter in ember-extension-support | ember-dev.yml | @@ -34,6 +34,7 @@ testing_packages:
- ember-routing
- ember-application
- ember
+ - ember-extension-support
- ember-testing
testing_additional_requires:
- ember-debug | true |
Other | emberjs | ember.js | 11cfa1f8f664197531758d1849557b4522dd0771.json | Add Ember.DataAdapter in ember-extension-support | packages/ember-extension-support/lib/data_adapter.js | @@ -0,0 +1,424 @@
+/**
+@module ember
+@submodule ember-extension-support
+*/
+
+require('ember-application');
+
+/**
+ The `DataAdapter` helps a data persistence library
+ interface with tools that debug Ember such
+ as the Chrome Ember Extension.
+
+ This class will be extended by a persistence library
+ which will override some of the methods with
+ library-specific code.
+
+ The methods likely to be overriden are
+ `getFilters`, `detect`, `columnsForType`,
+ `getRecords`, `getRecordColumnValues`,
+ `getRecordKeywords`, `getRecordFilterValues`,
+ `getRecordColor`, `observeRecord`
+
+ The adapter will need to be registered
+ in the application's container as `dataAdapter:main`
+
+ Example:
+ ```javascript
+ Application.initializer({
+ name: "dataAdapter",
+
+ initialize: function(container, application) {
+ application.register('dataAdapter:main', DS.DataAdapter);
+ }
+ });
+ ```
+
+ @class DataAdapter
+ @namespace Ember
+ @extends Ember.Object
+*/
+Ember.DataAdapter = Ember.Object.extend({
+ init: function() {
+ this._super();
+ this.releaseMethods = Ember.A();
+ },
+
+ /**
+ The container of the application being debugged.
+ This property will be injected
+ on creation.
+ */
+ container: null,
+
+ /**
+ @private
+
+ Number of attributes to send
+ as columns. (Enough to make the record
+ identifiable).
+ */
+ attributeLimit: 3,
+
+ /**
+ @private
+
+ Stores all methods that clear observers.
+ These methods will be called on destruction.
+ */
+ releaseMethods: Ember.A(),
+
+ /**
+ @public
+
+ Specifies how records can be filtered.
+ Records returned will need to have a `filterValues`
+ property with a key for every name in the returned array.
+
+ @method getFilters
+ @return {Array} List of objects defining filters.
+ The object should have a `name` and `desc` property.
+ */
+ getFilters: function() {
+ return Ember.A();
+ },
+
+ /**
+ @public
+
+ Fetch the model types and observe them for changes.
+
+ @method watchModelTypes
+
+ @param {Function} typesAdded Callback to call to add types.
+ Takes an array of objects containing wrapped types (returned from `wrapModelType`).
+
+ @param {Function} typesUpdated Callback to call when a type has changed.
+ Takes an array of objects containing wrapped types.
+
+ @return {Function} Method to call to remove all observers
+ */
+ watchModelTypes: function(typesAdded, typesUpdated) {
+ var modelTypes = this.getModelTypes(),
+ self = this, typesToSend, releaseMethods = Ember.A();
+
+ typesToSend = modelTypes.map(function(type) {
+ var wrapped = self.wrapModelType(type);
+ releaseMethods.push(self.observeModelType(type, typesUpdated));
+ return wrapped;
+ });
+
+ typesAdded(typesToSend);
+
+ var release = function() {
+ releaseMethods.forEach(function(fn) { fn(); });
+ self.releaseMethods.removeObject(release);
+ };
+ this.releaseMethods.pushObject(release);
+ return release;
+ },
+
+ /**
+ @public
+
+ Fetch the records of a given type and observe them for changes.
+
+ @method watchRecords
+
+ @param {Function} recordsAdded Callback to call to add records.
+ Takes an array of objects containing wrapped records.
+ The object should have the following properties:
+ columnValues: {Object} key and value of a table cell
+ object: {Object} the actual record object
+
+ @param {Function} recordsUpdated Callback to call when a record has changed.
+ Takes an array of objects containing wrapped records.
+
+ @param {Function} recordsRemoved Callback to call when a record has removed.
+ Takes the following parameters:
+ index: the array index where the records were removed
+ count: the number of records removed
+
+ @return {Function} Method to call to remove all observers
+ */
+ watchRecords: function(type, recordsAdded, recordsUpdated, recordsRemoved) {
+ var self = this, releaseMethods = Ember.A(), records = this.getRecords(type), release;
+
+ var recordUpdated = function(updatedRecord) {
+ recordsUpdated([updatedRecord]);
+ };
+
+ var recordsToSend = records.map(function(record) {
+ releaseMethods.push(self.observeRecord(record, recordUpdated));
+ return self.wrapRecord(record);
+ });
+
+
+ var contentDidChange = function(array, idx, removedCount, addedCount) {
+ for (var i = idx; i < idx + addedCount; i++) {
+ var record = array.objectAt(i);
+ var wrapped = self.wrapRecord(record);
+ releaseMethods.push(self.observeRecord(record, recordUpdated));
+ recordsAdded([wrapped]);
+ }
+
+ if (removedCount) {
+ recordsRemoved(idx, removedCount);
+ }
+ };
+
+ var observer = { didChange: contentDidChange, willChange: Ember.K };
+ records.addArrayObserver(self, observer);
+
+ release = function() {
+ releaseMethods.forEach(function(fn) { fn(); });
+ records.removeArrayObserver(self, observer);
+ self.releaseMethods.removeObject(release);
+ };
+
+ recordsAdded(recordsToSend);
+
+ this.releaseMethods.pushObject(release);
+ return release;
+ },
+
+ /**
+ @private
+
+ Clear all observers before destruction
+ */
+ willDestroy: function() {
+ this._super();
+ this.releaseMethods.forEach(function(fn) {
+ fn();
+ });
+ },
+
+ /**
+ @private
+
+ Detect whether a class is a model.
+
+ Test that against the model class
+ of your persistence library
+
+ @method detect
+ @param {Class} klass The class to test
+ @return boolean Whether the class is a model class or not
+ */
+ detect: function(klass) {
+ return false;
+ },
+
+ /**
+ @private
+
+ Get the columns for a given model type.
+
+ @method columnsForType
+ @param {Class} type The model type
+ @return {Array} An array of columns of the following format:
+ name: {String} name of the column
+ desc: {String} Humanized description (what would show in a table column name)
+ */
+ columnsForType: function(type) {
+ return Ember.A();
+ },
+
+ /**
+ @private
+
+ Adds observers to a model type class.
+
+ @method observeModelType
+ @param {Class} type The model type class
+ @param {Function} typesUpdated Called when a type is modified.
+ @return {Function} The function to call to remove observers
+ */
+
+ observeModelType: function(type, typesUpdated) {
+ var self = this, records = this.getRecords(type);
+
+ var onChange = function() {
+ typesUpdated([self.wrapModelType(type)]);
+ };
+ var observer = {
+ didChange: function() {
+ Ember.run.scheduleOnce('actions', this, onChange);
+ },
+ willChange: Ember.K
+ };
+
+ records.addArrayObserver(this, observer);
+
+ var release = function() {
+ records.removeArrayObserver(self, observer);
+ };
+
+ return release;
+ },
+
+
+ /**
+ @private
+
+ Wraps a given model type and observes changes to it.
+
+ @method wrapModelType
+ @param {Class} type A model class
+ @param {Function} typesUpdated callback to call when the type changes
+ @return {Object} contains the wrapped type and the function to remove observers
+ Format:
+ type: {Object} the wrapped type
+ The wrapped type has the following format:
+ name: {String} name of the type
+ count: {Integer} number of records available
+ columns: {Columns} array of columns to describe the record
+ object: {Class} the actual Model type class
+ release: {Function} The function to remove observers
+ */
+ wrapModelType: function(type, typesUpdated) {
+ var release, records = this.getRecords(type),
+ typeToSend, self = this;
+
+ typeToSend = {
+ name: type.toString(),
+ count: Ember.get(records, 'length'),
+ columns: this.columnsForType(type),
+ object: type
+ };
+
+
+ return typeToSend;
+ },
+
+
+ /**
+ @private
+
+ Fetches all models defined in the application.
+ TODO: Use the resolver instead of looping over namespaces.
+
+ @method getModelTypes
+ @return {Array} Array of model types
+ */
+ getModelTypes: function() {
+ var namespaces = Ember.A(Ember.Namespace.NAMESPACES), types = Ember.A(), self = this;
+
+ namespaces.forEach(function(namespace) {
+ for (var key in namespace) {
+ if (!namespace.hasOwnProperty(key)) { continue; }
+ var klass = namespace[key];
+ if (self.detect(klass)) {
+ types.push(klass);
+ }
+ }
+ });
+ return types;
+ },
+
+ /**
+ @private
+
+ Fetches all loaded records for a given type.
+
+ @method getRecords
+ @return {Array} array of records.
+ This array will be observed for changes,
+ so it should update when new records are added/removed.
+ */
+ getRecords: function(type) {
+ return Ember.A();
+ },
+
+ /**
+ @private
+
+ Wraps a record and observers changes to it
+
+ @method wrapRecord
+ @param {Object} record The record instance
+ @return {Object} the wrapped record. Format:
+ columnValues: {Array}
+ searchKeywords: {Array}
+ */
+ wrapRecord: function(record) {
+ var recordToSend = { object: record }, columnValues = {}, self = this;
+
+ recordToSend.columnValues = this.getRecordColumnValues(record);
+ recordToSend.searchKeywords = this.getRecordKeywords(record);
+ recordToSend.filterValues = this.getRecordFilterValues(record);
+ recordToSend.color = this.getRecordColor(record);
+
+ return recordToSend;
+ },
+
+ /**
+ @private
+
+ Gets the values for each column.
+
+ @method getRecordColumnValues
+ @return {Object} Keys should match column names defined
+ by the model type.
+ */
+ getRecordColumnValues: function(record) {
+ return {};
+ },
+
+ /**
+ @private
+
+ Returns keywords to match when searching records.
+
+ @method getRecordKeywords
+ @return {Array} Relevant keywords for search.
+ */
+ getRecordKeywords: function(record) {
+ return Ember.A();
+ },
+
+ /**
+ @private
+
+ Returns the values of filters defined by `getFilters`.
+
+ @method getRecordFilterValues
+ @param {Object} record The record instance
+ @return {Object} The filter values
+ */
+ getRecordFilterValues: function(record) {
+ return {};
+ },
+
+ /**
+ @private
+
+ Each record can have a color that represents its state.
+
+ @method getRecordColor
+ @param {Object} record The record instance
+ @return {String} The record's color
+ Possible options: black, red, blue, green
+ */
+ getRecordColor: function(record) {
+ return null;
+ },
+
+ /**
+ @private
+
+ Observes all relevant properties and re-sends the wrapped record
+ when a change occurs.
+
+ @method observerRecord
+ @param {Object} record The record instance
+ @param {Function} recordUpdated The callback to call when a record is updated.
+ @return {Function} The function to call to remove all observers.
+ */
+ observeRecord: function(record, recordUpdated) {
+ return function(){};
+ }
+
+});
+ | true |
Other | emberjs | ember.js | 11cfa1f8f664197531758d1849557b4522dd0771.json | Add Ember.DataAdapter in ember-extension-support | packages/ember-extension-support/lib/main.js | @@ -0,0 +1,9 @@
+/**
+Ember Extension Support
+
+@module ember
+@submodule ember-extension-support
+@requires ember-application
+*/
+
+require('ember-extension-support/data_adapter'); | true |
Other | emberjs | ember.js | 11cfa1f8f664197531758d1849557b4522dd0771.json | Add Ember.DataAdapter in ember-extension-support | packages/ember-extension-support/package.json | @@ -0,0 +1,28 @@
+{
+ "name": "ember-extension-support",
+ "summary": "Ember Extension Support",
+ "description": "API for external tools such as the Chrome Ember Extension",
+ "homepage": "http://emberjs.com",
+ "authors": ["Teddy Zeenny"],
+ "version": "1.0.0-rc.6",
+ "dependencies": {
+ "ember-application": "1.0.0-rc.6"
+ },
+
+ "directories": {
+ "lib": "lib"
+ },
+
+ "dependencies:development": {
+ "spade-qunit": "~> 1.0.0"
+ },
+
+ "bpm:build": {
+
+ "bpm_libs.js": {
+ "files": ["lib"],
+ "modes": "*"
+ }
+ }
+
+} | true |
Other | emberjs | ember.js | 11cfa1f8f664197531758d1849557b4522dd0771.json | Add Ember.DataAdapter in ember-extension-support | packages/ember-extension-support/tests/data_adapter_test.js | @@ -0,0 +1,161 @@
+var adapter, App, get = Ember.get,
+ set = Ember.set, Model = Ember.Object.extend();
+
+var DataAdapter = Ember.DataAdapter.extend({
+ detect: function(klass) {
+ return klass !== Model && Model.detect(klass);
+ }
+});
+
+module("Data Adapter", {
+ setup:function() {
+ Ember.run(function() {
+ App = Ember.Application.create();
+ App.toString = function() { return 'App'; };
+ App.deferReadiness();
+ App.__container__.register('dataAdapter:main', DataAdapter);
+ adapter = App.__container__.lookup('dataAdapter:main');
+ });
+ },
+ teardown: function() {
+ Ember.run(function() {
+ adapter.destroy();
+ App.destroy();
+ });
+ }
+});
+
+test("Model Types Added", function() {
+ App.Post = Model.extend();
+
+ adapter.reopen({
+ getRecords: function() {
+ return Ember.A([1,2,3]);
+ },
+ columnsForType: function() {
+ return [ { name: 'title', desc: 'Title'} ];
+ }
+ });
+
+ Ember.run(App, 'advanceReadiness');
+
+ var modelTypesAdded = function(types) {
+
+ equal(types.length, 1);
+ var postType = types[0];
+ equal(postType.name, 'App.Post', 'Correctly sets the name');
+ equal(postType.count, 3, 'Correctly sets the record count');
+ strictEqual(postType.object, App.Post, 'Correctly sets the object');
+ deepEqual(postType.columns, [ {name: 'title', desc: 'Title'} ], 'Correctly sets the columns');
+ };
+
+ adapter.watchModelTypes(modelTypesAdded);
+
+});
+
+test("Model Types Updated", function() {
+ App.Post = Model.extend();
+
+ var records = Ember.A([1,2,3]);
+ adapter.reopen({
+ getRecords: function() {
+ return records;
+ }
+ });
+
+ Ember.run(App, 'advanceReadiness');
+
+ var modelTypesAdded = function() {
+ Ember.run(function() {
+ records.pushObject(4);
+ });
+ };
+
+ var modelTypesUpdated = function(types) {
+
+ var postType = types[0];
+ equal(postType.count, 4, 'Correctly updates the count');
+ };
+
+ adapter.watchModelTypes(modelTypesAdded, modelTypesUpdated);
+
+});
+
+test("Records Added", function() {
+ expect(8);
+ var countAdded = 1;
+
+ App.Post = Model.extend();
+
+ var post = App.Post.create();
+ var recordList = Ember.A([post]);
+
+ adapter.reopen({
+ getRecords: function() {
+ return recordList;
+ },
+ getRecordColor: function() {
+ return 'blue';
+ },
+ getRecordColumnValues: function() {
+ return { title: 'Post ' + countAdded };
+ },
+ getRecordKeywords: function() {
+ return ['Post ' + countAdded];
+ }
+ });
+
+ var recordsAdded = function(records) {
+ var record = records[0];
+ equal(record.color, 'blue', 'Sets the color correctly');
+ deepEqual(record.columnValues, { title: 'Post ' + countAdded }, 'Sets the column values correctly');
+ deepEqual(record.searchKeywords, ['Post ' + countAdded], 'Sets search keywords correctly');
+ strictEqual(record.object, post, 'Sets the object to the record instance');
+ };
+
+ adapter.watchRecords(App.Post, recordsAdded);
+ countAdded++;
+ post = App.Post.create();
+ recordList.pushObject(post);
+});
+
+test("Observes and releases a record correctly", function() {
+ var updatesCalled = 0;
+ App.Post = Model.extend();
+
+ var post = App.Post.create({ title: 'Post' });
+ var recordList = Ember.A([post]);
+
+ adapter.reopen({
+ getRecords: function() {
+ return recordList;
+ },
+ observeRecord: function(record, recordUpdated) {
+ var self = this;
+ var callback = function() {
+ recordUpdated(self.wrapRecord(record));
+ };
+ Ember.addObserver(record, 'title', callback);
+ return function() {
+ Ember.removeObserver(record, 'title', callback);
+ };
+ },
+ getRecordColumnValues: function(record) {
+ return { title: get(record, 'title') };
+ }
+ });
+
+ var recordsAdded = function() {
+ set(post, 'title', 'Post Modified');
+ };
+
+ var recordsUpdated = function(records) {
+ updatesCalled++;
+ equal(records[0].columnValues.title, 'Post Modified');
+ };
+
+ var release = adapter.watchRecords(App.Post, recordsAdded, recordsUpdated);
+ release();
+ set(post, 'title', 'New Title');
+ equal(updatesCalled, 1, 'Release function removes observers');
+}); | true |
Other | emberjs | ember.js | 2cb3f3fed24ba32e906a54568ecd7f9bedafadf5.json | Remove unused property
`Ember.CoreObject#isInstance` is referenced from only test code. | packages/ember-runtime/lib/system/core_object.js | @@ -165,8 +165,6 @@ CoreObject.PrototypeMixin = Mixin.create({
return this;
},
- isInstance: true,
-
/**
An overridable method called when objects are instantiated. By default,
does nothing unless it is overridden during class definition. | true |
Other | emberjs | ember.js | 2cb3f3fed24ba32e906a54568ecd7f9bedafadf5.json | Remove unused property
`Ember.CoreObject#isInstance` is referenced from only test code. | packages/ember-runtime/tests/system/object/extend_test.js | @@ -5,7 +5,6 @@ test('Basic extend', function() {
ok(SomeClass.isClass, "A class has isClass of true");
var obj = new SomeClass();
equal(obj.foo, 'BAR');
- ok(obj.isInstance, "An instance of a class has isInstance of true");
});
test('Sub-subclass', function() { | true |
Other | emberjs | ember.js | 5f014971b1c92894b67a0456828f688861ac430c.json | Fix some docs | packages/ember-runtime/lib/system/core_object.js | @@ -309,6 +309,8 @@ CoreObject.PrototypeMixin = Mixin.create({
/**
Override to implement teardown.
+
+ @method willDestroy
*/
willDestroy: Ember.K,
| true |
Other | emberjs | ember.js | 5f014971b1c92894b67a0456828f688861ac430c.json | Fix some docs | packages/ember-views/lib/views/component.js | @@ -99,32 +99,33 @@ Ember.Component = Ember.View.extend(Ember.TargetActionSupport, {
}).property('_parentView'),
/**
- Sends an action to component's controller. A component inherits its
- controller from the context in which it is used.
+ Sends an action to component's controller. A component inherits its
+ controller from the context in which it is used.
- By default, calling `sendAction()` will send an action with the name
- of the component's `action` property.
+ By default, calling `sendAction()` will send an action with the name
+ of the component's `action` property.
- For example, if the component had a property `action` with the value
- `"addItem"`, calling `sendAction()` would send the `addItem` action
- to the component's controller.
+ For example, if the component had a property `action` with the value
+ `"addItem"`, calling `sendAction()` would send the `addItem` action
+ to the component's controller.
- If you provide an argument to `sendAction()`, that key will be used to look
- up the action name.
+ If you provide an argument to `sendAction()`, that key will be used to look
+ up the action name.
- For example, if the component had a property `playing` with the value
- `didStartPlaying`, calling `sendAction('playing')` would send the
- `didStartPlaying` action to the component's controller.
+ For example, if the component had a property `playing` with the value
+ `didStartPlaying`, calling `sendAction('playing')` would send the
+ `didStartPlaying` action to the component's controller.
- Whether or not you are using the default action or a named action, if
- the action name is not defined on the component, calling `sendAction()`
- does not have any effect.
+ Whether or not you are using the default action or a named action, if
+ the action name is not defined on the component, calling `sendAction()`
+ does not have any effect.
- For example, if you call `sendAction()` on a component that does not have
- an `action` property defined, no action will be sent to the controller,
- nor will an exception be raised.
+ For example, if you call `sendAction()` on a component that does not have
+ an `action` property defined, no action will be sent to the controller,
+ nor will an exception be raised.
- @param [action] {String} the action to trigger
+ @method sendAction
+ @param [action] {String} the action to trigger
*/
sendAction: function(action) {
var actionName; | true |
Other | emberjs | ember.js | 5f014971b1c92894b67a0456828f688861ac430c.json | Fix some docs | packages/ember-views/lib/views/view.js | @@ -961,6 +961,9 @@ Ember.View = Ember.CoreView.extend(
/**
The parent context for this template.
+
+ @method parentContext
+ @return {Ember.View}
*/
parentContext: function() {
var parentView = get(this, '_parentView'); | true |
Other | emberjs | ember.js | 9d051c2a1b751494575fa06b9ebc73af8ed59ac3.json | Add sendAction() to Ember.Component | packages/ember-views/lib/views/component.js | @@ -1,6 +1,6 @@
require("ember-views/views/view");
-var set = Ember.set;
+var get = Ember.get, set = Ember.set, isNone = Ember.isNone;
/**
@module ember
@@ -85,11 +85,65 @@ var set = Ember.set;
@namespace Ember
@extends Ember.View
*/
-Ember.Component = Ember.View.extend({
+Ember.Component = Ember.View.extend(Ember.TargetActionSupport, {
init: function() {
this._super();
set(this, 'context', this);
set(this, 'controller', this);
set(this, 'templateData', {keywords: {}});
+ },
+
+ targetObject: Ember.computed(function(key) {
+ var parentView = get(this, '_parentView');
+ return parentView ? get(parentView, 'controller') : null;
+ }).property('_parentView'),
+
+ /**
+ Sends an action to component's controller. A component inherits its
+ controller from the context in which it is used.
+
+ By default, calling `sendAction()` will send an action with the name
+ of the component's `action` property.
+
+ For example, if the component had a property `action` with the value
+ `"addItem"`, calling `sendAction()` would send the `addItem` action
+ to the component's controller.
+
+ If you provide an argument to `sendAction()`, that key will be used to look
+ up the action name.
+
+ For example, if the component had a property `playing` with the value
+ `didStartPlaying`, calling `sendAction('playing')` would send the
+ `didStartPlaying` action to the component's controller.
+
+ Whether or not you are using the default action or a named action, if
+ the action name is not defined on the component, calling `sendAction()`
+ does not have any effect.
+
+ For example, if you call `sendAction()` on a component that does not have
+ an `action` property defined, no action will be sent to the controller,
+ nor will an exception be raised.
+
+ @param [action] {String} the action to trigger
+ */
+ sendAction: function(action) {
+ var actionName;
+
+ // Send the default action
+ if (action === undefined) {
+ actionName = get(this, 'action');
+ Ember.assert("The default action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone(actionName) || typeof actionName === 'string');
+ } else {
+ actionName = get(this, action);
+ Ember.assert("The " + action + " action was triggered on the component " + this.toString() + ", but the action name (" + actionName + ") was not a string.", isNone(actionName) || typeof actionName === 'string');
+ }
+
+
+ // If no action name for that action could be found, just abort.
+ if (actionName === undefined) { return; }
+
+ this.triggerAction({
+ action: actionName
+ });
}
}); | true |
Other | emberjs | ember.js | 9d051c2a1b751494575fa06b9ebc73af8ed59ac3.json | Add sendAction() to Ember.Component | packages/ember-views/tests/views/component_test.js | @@ -1,3 +1,5 @@
+var get = Ember.get, set = Ember.set;
+
module("Ember.Component");
var Component = Ember.Component.extend();
@@ -11,3 +13,80 @@ test("The controller (target of `action`) of an Ember.Component is itself", func
var control = Component.create();
strictEqual(control, control.get('controller'), "A control's controller is itself");
});
+
+var component, controller, actionCounts, sendCount;
+
+module("Ember.Component - Actions", {
+ setup: function() {
+ actionCounts = {};
+ sendCount = 0;
+
+ controller = Ember.Object.create({
+ send: function(actionName) {
+ sendCount++;
+ actionCounts[actionName] = actionCounts[actionName] || 0;
+ actionCounts[actionName]++;
+ }
+ });
+
+ component = Ember.Component.create({
+ _parentView: Ember.View.create({
+ controller: controller
+ })
+ });
+ },
+
+ teardown: function() {
+ Ember.run(function() {
+ component.destroy();
+ controller.destroy();
+ });
+ }
+});
+
+test("Calling sendAction on a component without an action defined does nothing", function() {
+ component.sendAction();
+ equal(sendCount, 0, "addItem action was not invoked");
+});
+
+test("Calling sendAction on a component with an action defined calls send on the controller", function() {
+ set(component, 'action', "addItem");
+
+ component.sendAction();
+
+ equal(sendCount, 1, "send was called once");
+ equal(actionCounts['addItem'], 1, "addItem event was sent once");
+});
+
+test("Calling sendAction with a named action uses the component's property as the action name", function() {
+ set(component, 'playing', "didStartPlaying");
+ set(component, 'action', "didDoSomeBusiness");
+
+ component.sendAction('playing');
+
+ equal(sendCount, 1, "send was called once");
+ equal(actionCounts['didStartPlaying'], 1, "named action was sent");
+
+ component.sendAction('playing');
+
+ equal(sendCount, 2, "send was called twice");
+ equal(actionCounts['didStartPlaying'], 2, "named action was sent");
+
+ component.sendAction();
+
+ equal(sendCount, 3, "send was called three times");
+ equal(actionCounts['didDoSomeBusiness'], 1, "default action was sent");
+});
+
+test("Calling sendAction when the action name is not a string raises an exception", function() {
+ set(component, 'action', {});
+ set(component, 'playing', {});
+
+ expectAssertion(function() {
+ component.sendAction();
+ });
+
+ expectAssertion(function() {
+ component.sendAction('playing');
+ });
+}); | true |
Other | emberjs | ember.js | 56583406394d44c8f9e0c1ac2c9a8a227852c26c.json | fix missed VERSION bump | packages/ember-metal/lib/core.js | @@ -49,10 +49,10 @@ Ember.toString = function() { return "Ember"; };
/**
@property VERSION
@type String
- @default '1.0.0-rc.6'
+ @default '1.0.0-rc.6.1'
@final
*/
-Ember.VERSION = '1.0.0-rc.6';
+Ember.VERSION = '1.0.0-rc.6.1';
/**
Standard environmental variables. You can define these in a global `ENV` | false |
Other | emberjs | ember.js | 2c9d53c1678ca0a024731265cba34a27ca1ad29b.json | improve readability of some exceptions caught b | packages/ember-testing/lib/adapters.js | @@ -72,6 +72,6 @@ Test.QUnitAdapter = Test.Adapter.extend({
start();
},
exception: function(error) {
- ok(false, error);
+ ok(false, Ember.inspect(error));
}
}); | false |
Other | emberjs | ember.js | 6b6f739ed9df057a62401429167dd14691cdfee5.json | Remove unnecessary assertion for `Ember.inspect`
The assertion for `Ember.inspect` with error object depends on
`Error#toString`.
It returns the value that provided by each environments. | packages/ember-runtime/tests/core/inspect_test.js | @@ -46,7 +46,3 @@ test("date", function() {
ok(inspected.match(/2011/), "The inspected date has its year");
ok(inspected.match(/13:24:11/), "The inspected date has its time");
});
-
-test("error", function() {
- equal(inspect(new Error("Oops")), "Error: Oops");
-}); | false |
Other | emberjs | ember.js | 1af8166a2e53287426aeb06a1cc922a30a58f2f1.json | Improve error message for missing itemView
This commit adds infrastructure for a container to return a
human-readable description for a fullName.
For example, Ember's default container will return App.FooController for
the fullName "controller:foo" (where App is the name of the namespaces).
This paves the way for improving other assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys (which don't match the mental model of an Ember user).
Alternate resolvers should implement lookupDescription(fullName), and
Ember.Application will automatically wire that method up to the
container's `describe` method. | packages/container/lib/main.js | @@ -318,6 +318,20 @@ define("container",
return this.resolver(fullName) || this.registry.get(fullName);
},
+ /**
+ A hook that can be used to describe how the resolver will
+ attempt to find the factory.
+
+ For example, the default Ember `.describe` returns the full
+ class name (including namespace) where Ember's resolver expects
+ to find the `fullName`.
+
+ @method describe
+ */
+ describe: function(fullName) {
+ return fullName;
+ },
+
/**
A hook to enable custom fullName normalization behaviour
| true |
Other | emberjs | ember.js | 1af8166a2e53287426aeb06a1cc922a30a58f2f1.json | Improve error message for missing itemView
This commit adds infrastructure for a container to return a
human-readable description for a fullName.
For example, Ember's default container will return App.FooController for
the fullName "controller:foo" (where App is the name of the namespaces).
This paves the way for improving other assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys (which don't match the mental model of an Ember user).
Alternate resolvers should implement lookupDescription(fullName), and
Ember.Application will automatically wire that method up to the
container's `describe` method. | packages/ember-application/lib/system/application.js | @@ -696,6 +696,7 @@ Ember.Application.reopenClass({
container.set = Ember.set;
container.normalize = normalize;
container.resolver = resolverFor(namespace);
+ container.describe = container.resolver.describe;
container.optionsForType('view', { singleton: false });
container.optionsForType('template', { instantiate: false });
container.register('application:main', namespace, { instantiate: false });
@@ -739,9 +740,16 @@ function resolverFor(namespace) {
var resolver = resolverClass.create({
namespace: namespace
});
- return function(fullName) {
+
+ function resolve(fullName) {
return resolver.resolve(fullName);
+ }
+
+ resolve.describe = function(fullName) {
+ return resolver.lookupDescription(fullName);
};
+
+ return resolve;
}
function normalize(fullName) { | true |
Other | emberjs | ember.js | 1af8166a2e53287426aeb06a1cc922a30a58f2f1.json | Improve error message for missing itemView
This commit adds infrastructure for a container to return a
human-readable description for a fullName.
For example, Ember's default container will return App.FooController for
the fullName "controller:foo" (where App is the name of the namespaces).
This paves the way for improving other assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys (which don't match the mental model of an Ember user).
Alternate resolvers should implement lookupDescription(fullName), and
Ember.Application will automatically wire that method up to the
container's `describe` method. | packages/ember-application/lib/system/resolver.js | @@ -219,5 +219,18 @@ Ember.DefaultResolver = Ember.Object.extend({
var className = classify(parsedName.name) + classify(parsedName.type),
factory = get(parsedName.root, className);
if (factory) { return factory; }
+ },
+
+ lookupDescription: function(name) {
+ var parsedName = this.parseName(name);
+
+ if (parsedName.type === 'template') {
+ return "template at " + parsedName.fullNameWithoutType.replace(/\./g, '/');
+ }
+
+ var description = parsedName.root + "." + classify(parsedName.name);
+ if (parsedName.type !== 'model') { description += classify(parsedName.type); }
+
+ return description;
}
}); | true |
Other | emberjs | ember.js | 1af8166a2e53287426aeb06a1cc922a30a58f2f1.json | Improve error message for missing itemView
This commit adds infrastructure for a container to return a
human-readable description for a fullName.
For example, Ember's default container will return App.FooController for
the fullName "controller:foo" (where App is the name of the namespaces).
This paves the way for improving other assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys (which don't match the mental model of an Ember user).
Alternate resolvers should implement lookupDescription(fullName), and
Ember.Application will automatically wire that method up to the
container's `describe` method. | packages/ember-handlebars-compiler/lib/main.js | @@ -115,7 +115,7 @@ Ember.Handlebars.helper = function(name, value) {
if (Ember.View.detect(value)) {
Ember.Handlebars.registerHelper(name, function(options) {
- Ember.assert("You can only pass attributes as parameters (not values) to a application-defined helper", arguments.length < 2);
+ Ember.assert("You can only pass attributes (such as name=value) not bare values to a helper for a View", arguments.length < 2);
makeBindings(options);
return Ember.Handlebars.helpers.view.call(this, value, options);
}); | true |
Other | emberjs | ember.js | 1af8166a2e53287426aeb06a1cc922a30a58f2f1.json | Improve error message for missing itemView
This commit adds infrastructure for a container to return a
human-readable description for a fullName.
For example, Ember's default container will return App.FooController for
the fullName "controller:foo" (where App is the name of the namespaces).
This paves the way for improving other assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys (which don't match the mental model of an Ember user).
Alternate resolvers should implement lookupDescription(fullName), and
Ember.Application will automatically wire that method up to the
container's `describe` method. | packages/ember-handlebars/lib/helpers/binding.js | @@ -466,7 +466,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
var path = attrs[attr],
normalized;
- Ember.assert(fmt("You must provide a String for a bound attribute, not %@", [path]), typeof path === 'string');
+ Ember.assert(fmt("You must provide an expression as the value of bound attribute. You specified: %@=%@", [attr, path]), typeof path === 'string');
normalized = normalizePath(ctx, path, options.data);
| true |
Other | emberjs | ember.js | 1af8166a2e53287426aeb06a1cc922a30a58f2f1.json | Improve error message for missing itemView
This commit adds infrastructure for a container to return a
human-readable description for a fullName.
For example, Ember's default container will return App.FooController for
the fullName "controller:foo" (where App is the name of the namespaces).
This paves the way for improving other assertions to describe the
precise name of the class that Ember is looking for, rather than
container keys (which don't match the mental model of an Ember user).
Alternate resolvers should implement lookupDescription(fullName), and
Ember.Application will automatically wire that method up to the
container's `describe` method. | packages/ember-handlebars/lib/helpers/collection.js | @@ -164,10 +164,10 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
if (hash.itemView) {
var controller = data.keywords.controller;
- Ember.assert('itemView given, but no container is available', controller && controller.container);
+ Ember.assert('You specified an itemView, but the current context has no container to look the itemView up in. This probably means that you created a view manually, instead of through the container. Instead, use container.lookup("view:viewName"), which will properly instantiate your view.', controller && controller.container);
var container = controller.container;
itemViewClass = container.resolve('view:' + Ember.String.camelize(hash.itemView));
- Ember.assert('itemView not found in container', !!itemViewClass);
+ Ember.assert('You specified the itemView ' + hash.itemView + ", but it was not found at " + container.describe("view:" + hash.itemView) + " (and it was not registered in the container)", !!itemViewClass);
} else if (hash.itemViewClass) {
itemViewClass = handlebarsGet(collectionPrototype, hash.itemViewClass, options);
} else { | true |
Other | emberjs | ember.js | bfdbf858e25af9bcda3cdc888798532af336eeac.json | Improve assertion for non-Array passed to #each | packages/ember-handlebars/lib/helpers/each.js | @@ -39,6 +39,11 @@ Ember.Handlebars.EachView = Ember.CollectionView.extend(Ember._Metamorph, {
return this._super();
},
+ _assertArrayLike: function(content) {
+ Ember.assert("The value that #each loops over must be an Array. You passed " + content.constructor + ", but it should have been an ArrayController", !Ember.ControllerMixin.detect(content) || (content && content.isGenerated) || content instanceof Ember.ArrayController);
+ Ember.assert("The value that #each loops over must be an Array. You passed " + ((Ember.ControllerMixin.detect(content) && content.get('model') !== undefined) ? ("" + content.get('model') + " (wrapped in " + content + ")") : ("" + content)), Ember.Array.detect(content));
+ },
+
disableContentObservers: function(callback) {
Ember.removeBeforeObserver(this, 'content', null, '_contentWillChange');
Ember.removeObserver(this, 'content', null, '_contentDidChange'); | true |
Other | emberjs | ember.js | bfdbf858e25af9bcda3cdc888798532af336eeac.json | Improve assertion for non-Array passed to #each | packages/ember-routing/lib/system/controller_for.js | @@ -21,22 +21,28 @@ Ember.generateController = function(container, controllerName, context) {
if (context && Ember.isArray(context)) {
DefaultController = container.resolve('controller:array');
controller = DefaultController.extend({
+ isGenerated: true,
content: context
});
} else if (context) {
DefaultController = container.resolve('controller:object');
controller = DefaultController.extend({
+ isGenerated: true,
content: context
});
} else {
DefaultController = container.resolve('controller:basic');
- controller = DefaultController.extend();
+ controller = DefaultController.extend({
+ isGenerated: true
+ });
}
controller.toString = function() {
return "(generated " + controllerName + " controller)";
};
+ controller.isGenerated = true;
+
fullName = 'controller:' + controllerName;
container.register(fullName, controller);
| true |
Other | emberjs | ember.js | bfdbf858e25af9bcda3cdc888798532af336eeac.json | Improve assertion for non-Array passed to #each | packages/ember-views/lib/views/collection_view.js | @@ -227,14 +227,18 @@ Ember.CollectionView = Ember.ContainerView.extend(/** @scope Ember.CollectionVie
var content = get(this, 'content');
if (content) {
- Ember.assert(fmt("an Ember.CollectionView's content must implement Ember.Array. You passed %@", [content]), Ember.Array.detect(content));
+ this._assertArrayLike(content);
content.addArrayObserver(this);
}
var len = content ? get(content, 'length') : 0;
this.arrayDidChange(content, 0, null, len);
}, 'content'),
+ _assertArrayLike: function(content) {
+ Ember.assert(fmt("an Ember.CollectionView's content must implement Ember.Array. You passed %@", [content]), Ember.Array.detect(content));
+ },
+
destroy: function() {
if (!this._super()) { return; }
| true |
Other | emberjs | ember.js | 4e380be3ec3b9645b2cafb6152d420dceddf41d2.json | Fix code comment
`Ember.OUT_OF_RANGE_EXCEPTION` is not defined.
It is exist as a private property `OUT_OF_RANGE_EXCEPTION`. | packages/ember-runtime/lib/mixins/mutable_array.js | @@ -100,7 +100,7 @@ Ember.MutableArray = Ember.Mixin.create(Ember.Array, Ember.MutableEnumerable,/**
method. You can pass either a single index, or a start and a length.
If you pass a start and length that is beyond the
- length this method will throw an `Ember.OUT_OF_RANGE_EXCEPTION`
+ length this method will throw an `OUT_OF_RANGE_EXCEPTION`
```javascript
var colors = ["red", "green", "blue", "yellow", "orange"]; | false |
Other | emberjs | ember.js | b5053d509da397588807c82c5abceeb3629ac19f.json | Remove unused argument for `Ember.Array#objectAt`
`Ember.Array#objectAt` accepts single argument. | packages/ember-runtime/lib/mixins/array.js | @@ -196,7 +196,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
if (startAt < 0) startAt += len;
for(idx=startAt;idx<len;idx++) {
- if (this.objectAt(idx, true) === object) return idx ;
+ if (this.objectAt(idx) === object) return idx ;
}
return -1;
}, | false |
Other | emberjs | ember.js | 9bdd766f9ebbe0c20b4fa7a41dc930f1d821a2b3.json | Add jQuery 1.9 to testing rake task | Gemfile.lock | @@ -1,6 +1,6 @@
GIT
remote: https://github.com/emberjs/ember-dev.git
- revision: b385cc1f6ef56ff5a120b5768a0e3a1259a94cf1
+ revision: 6ed6c8ed4c1d77f053b0e751c9e0259d65465e14
branch: master
specs:
ember-dev (0.1)
@@ -32,7 +32,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- aws-sdk (1.11.3)
+ aws-sdk (1.13.0)
json (~> 1.4)
nokogiri (< 1.6.0)
uuidtools (~> 2.1)
@@ -68,7 +68,7 @@ GEM
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
thor (0.18.1)
- uglifier (2.1.1)
+ uglifier (2.1.2)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
uuidtools (2.1.4) | true |
Other | emberjs | ember.js | 9bdd766f9ebbe0c20b4fa7a41dc930f1d821a2b3.json | Add jQuery 1.9 to testing rake task | ember-dev.yml | @@ -17,6 +17,7 @@ testing_suites:
- "EACH_PACKAGE"
- "package=all&jquery=1.7.2&nojshint=true"
- "package=all&jquery=1.8.3&nojshint=true"
+ - "package=all&jquery=1.9.1&nojshint=true"
- "package=all&jquery=git&nojshint=true"
- "package=all&jquery=git2&nojshint=true"
- "package=all&extendprototypes=true&nojshint=true" | true |
Other | emberjs | ember.js | 78f93856c9513edcc9d40e801c1f863d8e536a0c.json | Expose `options` arg in `debugger` HB helper
Without this, you can't look up template data and other important pieces of data. (`arguments` is optimized away in Chrome since the function makes no other reference to it) | packages/ember-handlebars/lib/helpers/debug.js | @@ -41,6 +41,6 @@ Ember.Handlebars.registerHelper('log', function(property, options) {
@for Ember.Handlebars.helpers
@param {String} property
*/
-Ember.Handlebars.registerHelper('debugger', function() {
+Ember.Handlebars.registerHelper('debugger', function(options) {
debugger;
}); | false |
Other | emberjs | ember.js | 4584fafdaf2747c8fb1b92fe2f936cba1051e2c9.json | use Ember.K for consistency
Unless there's a reason behind using just `function() {}`, it seems more reasonable to use Ember.K for consistency | packages/ember-views/lib/views/view.js | @@ -1712,7 +1712,7 @@ Ember.View = Ember.CoreView.extend(
@event willDestroyElement
*/
- willDestroyElement: function() {},
+ willDestroyElement: Ember.K,
/**
@private | false |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/container/lib/main.js | @@ -244,7 +244,7 @@ define("container",
register: function(type, name, factory, options) {
var fullName;
- if (type.indexOf(':') !== -1){
+ if (type.indexOf(':') !== -1) {
options = factory;
factory = name;
fullName = type; | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/container/tests/container_test.js | @@ -89,7 +89,7 @@ test("A registered factory returns true for `has` if an item is registered", fun
equal(container.has('controller:posts'), false, "The `has` method returned false for unregistered factories");
});
-test("A Registered factory can be unregistered, and all cached instances are removed", function(){
+test("A Registered factory can be unregistered, and all cached instances are removed", function() {
var container = new Container();
var PostController = factory();
@@ -206,15 +206,15 @@ test("A failed lookup returns undefined", function() {
equal(container.lookup("doesnot:exist"), undefined);
});
-test("Injecting a failed lookup raises an error", function(){
+test("Injecting a failed lookup raises an error", function() {
var container = new Container();
- var Foo = { create: function(){ }};
+ var Foo = { create: function() { }};
container.register('model:foo', Foo);
container.injection('model:foo', 'store', 'store:main');
- throws(function(){
+ throws(function() {
container.lookup('model:foo');
});
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/lib/ext/controller.js | @@ -77,7 +77,7 @@ Ember.ControllerMixin.reopen({
this._super.apply(this, arguments);
// Structure asserts to still do verification but not string concat in production
- if(!verifyDependencies(this)) {
+ if (!verifyDependencies(this)) {
Ember.assert("Missing dependencies", false);
}
}, | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/lib/system/application.js | @@ -239,7 +239,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
this.scheduleInitialize();
- if ( Ember.LOG_VERSION ) {
+ if (Ember.LOG_VERSION) {
Ember.LOG_VERSION = false; // we only need to see this once per Application#init
Ember.debug('-------------------------------');
Ember.debug('Ember.VERSION : ' + Ember.VERSION);
@@ -318,7 +318,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
if (!this.$ || this.$.isReady) {
Ember.run.schedule('actions', self, '_initialize');
} else {
- this.$().ready(function(){
+ this.$().ready(function() {
Ember.run(self, '_initialize');
});
}
@@ -407,7 +407,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
@param property {String}
@param injectionName {String}
**/
- inject: function(){
+ inject: function() {
var container = this.__container__;
container.injection.apply(container, arguments);
},
@@ -423,7 +423,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
@method initialize
**/
- initialize: function(){
+ initialize: function() {
Ember.deprecate('Calling initialize manually is not supported. Please see Ember.Application#advanceReadiness and Ember.Application#deferReadiness');
},
/**
@@ -469,7 +469,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
var App;
- Ember.run(function(){
+ Ember.run(function() {
App = Ember.Application.create();
});
@@ -479,11 +479,11 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
}
});
- test("first test", function(){
+ test("first test", function() {
// App is freshly reset
});
- test("first test", function(){
+ test("first test", function() {
// App is again freshly reset
});
```
@@ -498,7 +498,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
var App;
- Ember.run(function(){
+ Ember.run(function() {
App = Ember.Application.create();
});
@@ -511,10 +511,10 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
}
});
- test("first test", function(){
+ test("first test", function() {
ok(true, 'something before app is initialized');
- Ember.run(function(){
+ Ember.run(function() {
App.advanceReadiness();
});
ok(true, 'something after app is initialized');
@@ -534,7 +534,7 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
this.buildContainer();
- Ember.run.schedule('actions', this, function(){
+ Ember.run.schedule('actions', this, function() {
this._initialize();
});
} | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/lib/system/resolver.js | @@ -202,7 +202,7 @@ Ember.DefaultResolver = Ember.Object.extend({
@protected
@method resolveModel
*/
- resolveModel: function(parsedName){
+ resolveModel: function(parsedName) {
var className = classify(parsedName.name),
factory = get(parsedName.root, className);
| true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/tests/system/dependency_injection/custom_resolver_test.js | @@ -1,8 +1,8 @@
var application;
module("Ember.Application Depedency Injection – customResolver",{
- setup: function(){
- function fallbackTemplate(){ return "<h1>Fallback</h1>"; }
+ setup: function() {
+ function fallbackTemplate() { return "<h1>Fallback</h1>"; }
var resolver = Ember.DefaultResolver.extend({
resolveTemplate: function(parsedName) { | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/tests/system/dependency_injection/default_resolver_test.js | @@ -1,14 +1,14 @@
var locator, application, lookup, originalLookup;
module("Ember.Application Depedency Injection", {
- setup: function(){
+ setup: function() {
originalLookup = Ember.lookup;
application = Ember.run(Ember.Application, 'create');
locator = application.__container__;
},
- teardown: function(){
+ teardown: function() {
Ember.lookup = originalLookup;
Ember.run(application, 'destroy');
}
@@ -51,10 +51,10 @@ test("the default resolver resolves models on the namespace", function() {
equal(locator.lookupFactory('model:post'), application.Post, "looks up Post model on application");
});
-test("the default resolver throws an error if the fullName to resolve is invalid", function(){
- raises(function(){ locator.resolve(''); }, TypeError, /Invalid fullName/ );
- raises(function(){ locator.resolve(':'); }, TypeError, /Invalid fullName/ );
- raises(function(){ locator.resolve('model'); }, TypeError, /Invalid fullName/ );
- raises(function(){ locator.resolve('model:'); }, TypeError, /Invalid fullName/ );
- raises(function(){ locator.resolve(':type'); }, TypeError, /Invalid fullName/ );
+test("the default resolver throws an error if the fullName to resolve is invalid", function() {
+ raises(function() { locator.resolve(''); }, TypeError, /Invalid fullName/ );
+ raises(function() { locator.resolve(':'); }, TypeError, /Invalid fullName/ );
+ raises(function() { locator.resolve('model'); }, TypeError, /Invalid fullName/ );
+ raises(function() { locator.resolve('model:'); }, TypeError, /Invalid fullName/ );
+ raises(function() { locator.resolve(':type'); }, TypeError, /Invalid fullName/ );
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/tests/system/dependency_injection_test.js | @@ -3,7 +3,7 @@ var locator, originalLookup = Ember.lookup, lookup,
forEach = Ember.ArrayPolyfills.forEach;
module("Ember.Application Depedency Injection", {
- setup: function(){
+ setup: function() {
application = Ember.run(Ember.Application, 'create');
application.Person = Ember.Object.extend({});
@@ -51,7 +51,7 @@ test('Ember.Container.defaultContainer is the same as the Apps container, but em
}
});
-test('registered entities can be looked up later', function(){
+test('registered entities can be looked up later', function() {
equal(locator.resolve('model:person'), application.Person);
equal(locator.resolve('model:user'), application.User);
equal(locator.resolve('fruit:favorite'), application.Orange); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/tests/system/logging_test.js | @@ -1,19 +1,19 @@
var App, logs, originalLogger;
module("Ember.Application – logging of generated classes", {
- setup: function(){
+ setup: function() {
logs = {};
originalLogger = Ember.Logger.info;
- Ember.Logger.info = function(){
+ Ember.Logger.info = function() {
var fullName = arguments[1].fullName;
logs[fullName] = logs[fullName] || 0;
logs[fullName]++;
};
- Ember.run(function(){
+ Ember.run(function() {
App = Ember.Application.create({
LOG_ACTIVE_GENERATION: true
});
@@ -30,7 +30,7 @@ module("Ember.Application – logging of generated classes", {
});
},
- teardown: function(){
+ teardown: function() {
Ember.Logger.info = originalLogger;
Ember.run(App, 'destroy');
@@ -42,11 +42,11 @@ module("Ember.Application – logging of generated classes", {
function visit(path) {
stop();
- var promise = Ember.run(function(){
- return new Ember.RSVP.Promise(function(resolve, reject){
+ var promise = Ember.run(function() {
+ return new Ember.RSVP.Promise(function(resolve, reject) {
var router = App.__container__.lookup('router:main');
- resolve(router.handleURL(path).then(function(value){
+ resolve(router.handleURL(path).then(function(value) {
start();
ok(true, 'visited: `' + path + '`');
return value;
@@ -59,7 +59,7 @@ function visit(path) {
});
return {
- then: function(resolve, reject){
+ then: function(resolve, reject) {
Ember.run(promise, 'then', resolve, reject);
}
};
@@ -68,7 +68,7 @@ function visit(path) {
test("log class generation if logging enabled", function() {
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(Ember.keys(logs).length, 6, 'expected logs');
});
});
@@ -80,15 +80,15 @@ test("do NOT log class generation if logging disabled", function() {
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(Ember.keys(logs).length, 0, 'expected no logs');
});
});
test("actively generated classes get logged", function() {
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(logs['controller:application'], 1, 'expected: ApplicationController was generated');
equal(logs['controller:posts'], 1, 'expected: PostsController was generated');
@@ -106,7 +106,7 @@ test("predefined classes do not get logged", function() {
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
ok(!logs['controller:application'], 'did not expect: ApplicationController was generated');
ok(!logs['controller:posts'], 'did not expect: PostsController was generated');
@@ -116,19 +116,19 @@ test("predefined classes do not get logged", function() {
});
module("Ember.Application – logging of view lookups", {
- setup: function(){
+ setup: function() {
logs = {};
originalLogger = Ember.Logger.info;
- Ember.Logger.info = function(){
+ Ember.Logger.info = function() {
var fullName = arguments[1].fullName;
logs[fullName] = logs[fullName] || 0;
logs[fullName]++;
};
- Ember.run(function(){
+ Ember.run(function() {
App = Ember.Application.create({
LOG_VIEW_LOOKUPS: true
});
@@ -145,7 +145,7 @@ module("Ember.Application – logging of view lookups", {
});
},
- teardown: function(){
+ teardown: function() {
Ember.Logger.info = originalLogger;
Ember.run(App, 'destroy');
@@ -155,10 +155,10 @@ module("Ember.Application – logging of view lookups", {
});
test("log when template and view are missing when flag is active", function() {
- App.register('template:application', function(){ return ''; });
+ App.register('template:application', function() { return ''; });
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(logs['template:application'], undefined, 'expected: Should not log template:application since it exists.');
equal(logs['template:index'], 1, 'expected: Could not find "index" template or view.');
equal(logs['template:posts'], 1, 'expected: Could not find "posts" template or view.');
@@ -172,18 +172,18 @@ test("do not log when template and view are missing when flag is not true", func
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(Ember.keys(logs).length, 0, 'expected no logs');
});
});
test("log which view is used with a template", function() {
- App.register('template:application', function(){ return 'Template with default view'; });
- App.register('template:foo', function(){ return 'Template with custom view'; });
+ App.register('template:application', function() { return 'Template with default view'; });
+ App.register('template:foo', function() { return 'Template with custom view'; });
App.register('view:posts', Ember.View.extend({templateName: 'foo'}));
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(logs['view:application'], 1, 'expected: Should log use of default view');
equal(logs['view:index'], undefined, 'expected: Should not log when index is not present.');
equal(logs['view:posts'], 1, 'expected: Rendering posts with PostsView.');
@@ -197,7 +197,7 @@ test("do not log which views are used with templates when flag is not true", fun
Ember.run(App, 'advanceReadiness');
- visit('/posts').then(function(){
+ visit('/posts').then(function() {
equal(Ember.keys(logs).length, 0, 'expected no logs');
});
}); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/tests/system/readiness_test.js | @@ -61,7 +61,7 @@ test("Ember.Application's ready event is called right away if jQuery is already
Ember.run(function() {
application = Application.create({ router: false });
- application.then(function(){
+ application.then(function() {
wasResolved++;
});
@@ -82,7 +82,7 @@ test("Ember.Application's ready event is called after the document becomes ready
var wasResolved = 0;
Ember.run(function() {
application = Application.create({ router: false });
- application.then(function(){
+ application.then(function() {
wasResolved++;
});
equal(wasResolved, 0);
@@ -102,7 +102,7 @@ test("Ember.Application's ready event can be deferred by other components", func
Ember.run(function() {
application = Application.create({ router: false });
- application.then(function(){
+ application.then(function() {
wasResolved++;
});
application.deferReadiness();
@@ -133,7 +133,7 @@ test("Ember.Application's ready event can be deferred by other components", func
Ember.run(function() {
application = Application.create({ router: false });
application.deferReadiness();
- application.then(function(){
+ application.then(function() {
wasResolved++;
});
equal(wasResolved, 0); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-application/tests/system/reset_test.js | @@ -23,7 +23,7 @@ test("Brings it's own run-loop if not provided", function() {
application.reset();
- Ember.run(application,'then', function(){
+ Ember.run(application,'then', function() {
ok(true, 'app booted');
});
});
@@ -35,9 +35,9 @@ test("does not bring it's own run loop if one is already provided", function() {
application = Ember.run(Application, 'create');
- Ember.run(function(){
+ Ember.run(function() {
- application.ready = function(){
+ application.ready = function() {
didBecomeReady = true;
};
@@ -82,10 +82,10 @@ test("When an application is reset, the eventDispatcher is destroyed and recreat
var originalDispatcher = Ember.EventDispatcher;
stubEventDispatcher = {
- setup: function(){
+ setup: function() {
eventDispatcherWasSetup++;
},
- destroy: function(){
+ destroy: function() {
eventDispatcherWasDestroyed++;
}
};
@@ -185,7 +185,7 @@ test("When an application with advance/deferReadiness is reset, the app does cor
Ember.run(function() {
application = Application.create({
- ready: function(){
+ ready: function() {
readyCallCount++;
}
});
@@ -194,7 +194,7 @@ test("When an application with advance/deferReadiness is reset, the app does cor
equal(readyCallCount, 0, 'ready has not yet been called');
});
- Ember.run(function(){
+ Ember.run(function() {
application.advanceReadiness();
});
@@ -212,7 +212,7 @@ test("With ember-data like initializer and constant", function() {
var DS = {
Store: Ember.Object.extend({
- init: function(){
+ init: function() {
if (!get(DS, 'defaultStore')) {
set(DS, 'defaultStore', this);
}
@@ -229,7 +229,7 @@ test("With ember-data like initializer and constant", function() {
Application.initializer({
name: "store",
- initialize: function(container, application){
+ initialize: function(container, application) {
application.register('store:main', application.Store);
container.lookup('store:main'); | true |
Other | emberjs | ember.js | 239f120583ddc5c30ee96ccb38f6ba7e74f5f9d8.json | fix code styling for consistency | packages/ember-handlebars-compiler/lib/main.js | @@ -11,7 +11,7 @@ var objectCreate = Object.create || function(parent) {
};
var Handlebars = this.Handlebars || (Ember.imports && Ember.imports.Handlebars);
-if(!Handlebars && typeof require === 'function') {
+if (!Handlebars && typeof require === 'function') {
Handlebars = require('handlebars');
}
@@ -208,7 +208,7 @@ Ember.Handlebars.Compiler.prototype.mustache = function(mustache) {
// Update the mustache node to include a hash value indicating whether the original node
// was escaped. This will allow us to properly escape values when the underlying value
// changes and we need to re-render the value.
- if(!mustache.escaped) {
+ if (!mustache.escaped) {
mustache.hash = mustache.hash || new Handlebars.AST.HashNode([]);
mustache.hash.pairs.push(["unescaped", new Handlebars.AST.StringNode("true")]);
} | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.