Skip to content

Commit 8ac9c89

Browse files
committed
ember computed properties
1 parent 042b1ee commit 8ac9c89

39 files changed

+587
-0
lines changed

ember-computed-properties/.bowerrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"directory": "bower_components",
3+
"analytics": false
4+
}
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
indent_style = space
14+
indent_size = 2
15+
16+
[*.js]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[*.hbs]
21+
insert_final_newline = false
22+
indent_style = space
23+
indent_size = 2
24+
25+
[*.css]
26+
indent_style = space
27+
indent_size = 2
28+
29+
[*.html]
30+
indent_style = space
31+
indent_size = 2
32+
33+
[*.{diff,md}]
34+
trim_trailing_whitespace = false

ember-computed-properties/.ember-cli

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
/**
3+
Ember CLI sends analytics information by default. The data is completely
4+
anonymous, but there are times when you might want to disable this behavior.
5+
6+
Setting `disableAnalytics` to true will prevent any data from being sent.
7+
*/
8+
"disableAnalytics": false
9+
}

ember-computed-properties/.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
7+
# dependencies
8+
/node_modules
9+
/bower_components
10+
11+
# misc
12+
/.sass-cache
13+
/connect.lock
14+
/coverage/*
15+
/libpeerconnection.log
16+
npm-debug.log
17+
testem.log

ember-computed-properties/.jshintrc

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"predef": [
3+
"document",
4+
"window",
5+
"-Promise"
6+
],
7+
"browser": true,
8+
"boss": true,
9+
"curly": true,
10+
"debug": false,
11+
"devel": true,
12+
"eqeqeq": true,
13+
"evil": true,
14+
"forin": false,
15+
"immed": false,
16+
"laxbreak": false,
17+
"newcap": true,
18+
"noarg": true,
19+
"noempty": false,
20+
"nonew": false,
21+
"nomen": false,
22+
"onevar": false,
23+
"plusplus": false,
24+
"regexp": false,
25+
"undef": true,
26+
"sub": true,
27+
"strict": false,
28+
"white": false,
29+
"eqnull": true,
30+
"esnext": true,
31+
"unused": true
32+
}

ember-computed-properties/.travis.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
language: node_js
3+
node_js:
4+
- "0.12"
5+
6+
sudo: false
7+
8+
cache:
9+
directories:
10+
- node_modules
11+
12+
before_install:
13+
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
14+
- "npm config set spin false"
15+
- "npm install -g npm@^2"
16+
17+
install:
18+
- npm install -g bower
19+
- npm install
20+
- bower install
21+
22+
script:
23+
- npm test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignore_dirs": ["tmp"]
3+
}

ember-computed-properties/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Ember.js Computed Properties
2+
3+
> [https://youtu.be/sT_QZT9znGI](https://youtu.be/sT_QZT9znGI)
4+
5+
Install [Node.js](https://nodejs.org/).
6+
7+
Within this folder run the terminal command `npm install` to install the
8+
`dependencies` and `devDependencies`.
9+
10+
Then run `npm start` to run the app and `http://localhost:4200` to view.
11+
12+
## Further Reading / Useful Links
13+
14+
* [ember.js](http://emberjs.com/)
15+
* [ember-cli](http://www.ember-cli.com/)
16+
* Development Browser Extensions
17+
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
18+
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)

ember-computed-properties/app/app.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Ember from 'ember';
2+
import Resolver from 'ember/resolver';
3+
import loadInitializers from 'ember/load-initializers';
4+
import config from './config/environment';
5+
6+
var App;
7+
8+
Ember.MODEL_FACTORY_INJECTIONS = true;
9+
10+
App = Ember.Application.extend({
11+
modulePrefix: config.modulePrefix,
12+
podModulePrefix: config.podModulePrefix,
13+
Resolver: Resolver
14+
});
15+
16+
loadInitializers(App, config.modulePrefix);
17+
18+
export default App;

ember-computed-properties/app/components/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Component.extend({
4+
model: Ember.computed({
5+
set: function (key, bears) {
6+
return bears.map(function (bear) {
7+
bear.favorited = false;
8+
return Ember.Object.create(bear);
9+
});
10+
}
11+
}),
12+
totalBears: Ember.computed('model.[]', function () {
13+
return this.get('model.length');
14+
}),
15+
bears: Ember.computed('model.[]', 'page', function () {
16+
var page = this.get('page');
17+
return this.get('model').slice(page, page + 5);
18+
}),
19+
page: 0,
20+
favoritedBears: Ember.computed('[email protected]', {
21+
get: function () {
22+
return this.get('model').filterBy('favorited', true).length;
23+
}
24+
}),
25+
actions: {
26+
showMore: function () {
27+
this.incrementProperty('page', 5);
28+
},
29+
favorite: function (bear) {
30+
bear.toggleProperty('favorited');
31+
}
32+
}
33+
});

ember-computed-properties/app/controllers/.gitkeep

Whitespace-only changes.

ember-computed-properties/app/helpers/.gitkeep

Whitespace-only changes.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>EmberComputedProperties</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
10+
{{content-for 'head'}}
11+
12+
<link rel="stylesheet" href="assets/vendor.css">
13+
<link rel="stylesheet" href="assets/ember-computed-properties.css">
14+
15+
{{content-for 'head-footer'}}
16+
</head>
17+
<body>
18+
{{content-for 'body'}}
19+
20+
<script src="assets/vendor.js"></script>
21+
<script src="assets/ember-computed-properties.js"></script>
22+
23+
{{content-for 'body-footer'}}
24+
</body>
25+
</html>

ember-computed-properties/app/models/.gitkeep

Whitespace-only changes.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Ember from 'ember';
2+
import config from './config/environment';
3+
4+
var Router = Ember.Router.extend({
5+
location: config.locationType
6+
});
7+
8+
Router.map(function() {
9+
});
10+
11+
export default Router;

ember-computed-properties/app/routes/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Route.extend({
4+
model: function () {
5+
return $.get('/bears.json');
6+
}
7+
});

ember-computed-properties/app/styles/app.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{bear-list model=model}}

ember-computed-properties/app/templates/components/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<h3>Bears ({{totalBears}})</h3>
2+
<ul>
3+
{{#each bears as |bear|}}
4+
<li {{action "favorite" bear}}>
5+
{{#if bear.favorited}}
6+
⭐️
7+
{{/if}}
8+
{{bear.name}}
9+
</li>
10+
{{/each}}
11+
</ul>
12+
<button {{action "showMore"}}>Show More</button>
13+
14+
<br/>
15+
<br/>
16+
You have favorited {{favoritedBears}} bears

ember-computed-properties/bower.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "ember-computed-properties",
3+
"dependencies": {
4+
"ember": "1.13.7",
5+
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
6+
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
7+
"ember-data": "1.13.8",
8+
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5",
9+
"ember-qunit": "0.4.9",
10+
"ember-qunit-notifications": "0.0.7",
11+
"ember-resolver": "~0.1.18",
12+
"jquery": "^1.11.3",
13+
"loader.js": "ember-cli/loader.js#3.2.1",
14+
"qunit": "~1.18.0"
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* jshint node: true */
2+
3+
module.exports = function(environment) {
4+
var ENV = {
5+
modulePrefix: 'ember-computed-properties',
6+
environment: environment,
7+
baseURL: '/',
8+
locationType: 'auto',
9+
EmberENV: {
10+
FEATURES: {
11+
// Here you can enable experimental features on an ember canary build
12+
// e.g. 'with-controller': true
13+
}
14+
},
15+
16+
APP: {
17+
// Here you can pass flags/options to your application instance
18+
// when it is created
19+
}
20+
};
21+
22+
if (environment === 'development') {
23+
// ENV.APP.LOG_RESOLVER = true;
24+
// ENV.APP.LOG_ACTIVE_GENERATION = true;
25+
// ENV.APP.LOG_TRANSITIONS = true;
26+
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
27+
// ENV.APP.LOG_VIEW_LOOKUPS = true;
28+
}
29+
30+
if (environment === 'test') {
31+
// Testem prefers this...
32+
ENV.baseURL = '/';
33+
ENV.locationType = 'none';
34+
35+
// keep test console output quieter
36+
ENV.APP.LOG_ACTIVE_GENERATION = false;
37+
ENV.APP.LOG_VIEW_LOOKUPS = false;
38+
39+
ENV.APP.rootElement = '#ember-testing';
40+
}
41+
42+
if (environment === 'production') {
43+
44+
}
45+
46+
return ENV;
47+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* global require, module */
2+
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
3+
4+
module.exports = function(defaults) {
5+
var app = new EmberApp(defaults, {
6+
// Add options here
7+
});
8+
9+
// Use `app.import` to add additional libraries to the generated
10+
// output files.
11+
//
12+
// If you need to use different assets in different
13+
// environments, specify an object as the first parameter. That
14+
// object's keys should be the environment name and the values
15+
// should be the asset to use in that environment.
16+
//
17+
// If the library that you are including contains AMD or ES6
18+
// modules that you would like to import into your application
19+
// please specify an object with the list of modules as keys
20+
// along with the exports of each module as its value.
21+
22+
return app.toTree();
23+
};
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "ember-computed-properties",
3+
"version": "0.0.0",
4+
"description": "Small description for ember-computed-properties goes here",
5+
"private": true,
6+
"directories": {
7+
"doc": "doc",
8+
"test": "tests"
9+
},
10+
"scripts": {
11+
"build": "ember build",
12+
"start": "ember server",
13+
"test": "ember test"
14+
},
15+
"repository": "",
16+
"engines": {
17+
"node": ">= 0.10.0"
18+
},
19+
"author": "",
20+
"license": "MIT",
21+
"devDependencies": {
22+
"broccoli-asset-rev": "^2.1.2",
23+
"ember-cli": "1.13.8",
24+
"ember-cli-app-version": "0.5.0",
25+
"ember-cli-babel": "^5.1.3",
26+
"ember-cli-content-security-policy": "0.4.0",
27+
"ember-cli-dependency-checker": "^1.0.1",
28+
"ember-cli-htmlbars": "0.7.9",
29+
"ember-cli-htmlbars-inline-precompile": "^0.2.0",
30+
"ember-cli-ic-ajax": "0.2.1",
31+
"ember-cli-inject-live-reload": "^1.3.1",
32+
"ember-cli-qunit": "^1.0.0",
33+
"ember-cli-release": "0.2.3",
34+
"ember-cli-sri": "^1.0.3",
35+
"ember-cli-uglify": "^1.2.0",
36+
"ember-data": "1.13.8",
37+
"ember-disable-proxy-controllers": "^1.0.0",
38+
"ember-export-application-global": "^1.0.3"
39+
}
40+
}

0 commit comments

Comments
 (0)