Skip to content

Commit

Permalink
Keep it up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
towerhe committed Sep 24, 2013
1 parent b22d267 commit a406fd1
Show file tree
Hide file tree
Showing 89 changed files with 2,153 additions and 835 deletions.
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def ember_path
File.expand_path(ENV['EMBER_PATH'] || File.expand_path("../../ember.js", __FILE__))
end

def ember_data_path
File.expand_path(ENV['EMBER_DATA_PATH'] || File.expand_path("../../ember-data", __FILE__))
end

def generate_docs
print "Generating docs data from #{ember_path}... "

Expand Down
49 changes: 21 additions & 28 deletions data/guides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,34 +152,26 @@
模型:
- title: "介绍"
url: "models"
warning: "ember-data"
- title: "创建一个存储器"
url: "models/defining-a-store"
warning: "ember-data"
- title: "Using the Store"
url: "models/using-the-store"
- title: "定义模型"
url: "models/defining-models"
warning: "ember-data"
- title: "查找模型"
url: "models/finding-models"
warning: "ember-data"
- title: "修改属性"
url: "models/modifying-attributes"
warning: "ember-data"
#- title: "Modifying Relationships"
#url: "models/modifying-relationships"
#warning: "ember-data"
- title: "模型生命周期"
url: "models/model-lifecycle"
warning: "ember-data"
- title: "The Fixture Adapter"
url: "models/the-fixture-adapter"
warning: "ember-data"
- title: "REST适配器"
url: "models/the-rest-adapter"
warning: "ember-data"
#- title: "The Basic Adapter"
#url: "modells/the-basic-adapter"
#warning: "ember-data"
- title: "Finding a Record"
url: "models/finding-a-record"
- title: "Finding All Records of a Type"
url: "models/finding-all-records-of-a-type"
- title: "Pushing Records into the Store"
url: "models/pushing-records-into-the-store"
- title: "Querying the Server for Records"
url: "models/querying-the-server-for-records"
# - title: "Filtering Records"
# url: "models/filtering-records"
- title: "Working with Records"
url: "models/working-with-records"
- title: "Connecting to an HTTP Server"
url: "models/connecting-to-an-http-server"
- title: "Frequently Asked Questions"
url: "models/frequently-asked-questions"

视图:
- title: "介绍"
Expand Down Expand Up @@ -228,7 +220,6 @@ Testing:
url: "configuring-ember/disabling-prototype-extensions"
- title: "嵌入式应用"
url: "configuring-ember/embedding-applications"

Cookbook:
- title: "Introduction"
url: "cookbook"
Expand Down Expand Up @@ -347,7 +338,9 @@ Cookbook:
url: "understanding-ember/keeping-templates-up-to-date"
- title: "调试"
url: "understanding-ember/debugging"

Contributing to Ember.js:
- title: "Adding New Features"
url: "contributing/adding-new-features"
#Understanding Ember Data:
#- title: "Record Lifecycle"
#url: "understanding-ember-data/record-lifecycle"
4 changes: 2 additions & 2 deletions lib/toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ def warning
WARNINGS = {
"ember-data"=> %Q{
<div class="under_construction_warning">
<h1>
<h3>
<div class="msg">
警告: ember-data处在快速成长的开发阶段。
<br/>
<span class="more_caution">使用的时候请自己关注ember-data的最新动态!!!</span>
</div>
</h1>
</h3>
</div>
}
}
Expand Down
14 changes: 11 additions & 3 deletions source/bilingual_guides/components/defining-a-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
中英对照:[http://emberjs.cn/bilingual_guides/components/defining-a-component/](http://emberjs.cn/bilingual_guides/components/defining-a-component/)

To define a component, create a template whose name starts with
`components/`. To define a new component `{{blog-post}}`, for example,
`components/`. To define a new component, `{{blog-post}}` for example,
create a `components/blog-post` template.

为了定义一个组件,需要先创建一个名字以`components/`开始的模板。例如:如果需要定义一个新组建`{{blog-post}}`,需要创建`components/blog-post`模板。

<aside>
**Note:** Components must have a dash in their name. So `blog-post` is an acceptable name,
but `post` is not. This prevents clashes with current or future HTML element names, and
ensures Ember picks up the components automatically.

**注意:** 组件名必须包含'-'。因此`blog-post`是一个合法的命名,而`post`则不是。这样避免了与当前或者今后的HTML元素的冲突,并确保Ember能自动加载组件。
</aside>

If you are including your Handlebars templates inside an HTML file via
`<script>` tags, it would look like this:

Expand Down Expand Up @@ -40,7 +48,7 @@ component of the same name. Given the above template, you can now use the

<a class="jsbin-embed" href="http://jsbin.com/ifuxey/1/embed?live,html">JS Bin</a><script src="http://static.jsbin.com/js/embed.js"></script>

Each component, under the hood, is backed by an element. By default,
Each component, under the hood, is backed by an element. By default
Ember will use a `<div>` element to contain your component's template.
To learn how to change the element Ember uses for your component, see
[Customizing a Component's Element](/guides/components/customizing-a-components-element).
Expand All @@ -59,7 +67,7 @@ created.

通常情况下,组件只封装一些会被不停的重复使用的Handlebars模板片段。在这些情况下,不需要编写任何Javascript代码,只需要像之前所述,定义好Handlebars模板,就能使用组件了。

If you need to customize the behavior of the component, however, you'll
If you need to customize the behavior of the component you'll
need to define a subclass of `Ember.Component`. For example, you would
need a custom subclass if you wanted to change a component's element,
respond to actions from the component's template, or manually make
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

中英对照:[http://emberjs.cn/bilingual_guides/components/passing-properties-to-a-component/](http://emberjs.cn/bilingual_guides/components/passing-properties-to-a-component/)

By default, a component does not have access to properties in the
By default a component does not have access to properties in the
template scope in which it is used.

默认情况下,组件不能访问模板作用域下的属性。
Expand Down
4 changes: 2 additions & 2 deletions source/bilingual_guides/concepts/naming-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Here's an example:
App.FavoritesRoute = Ember.Route.extend({
model: function() {
// the model is an Array of all of the posts
return App.Post.find();
return this.get('store').find('post');
}
});
```
Expand Down Expand Up @@ -211,7 +211,7 @@ generating a link for a model object).
```javascript
App.PostRoute = Ember.Route.extend({
model: function(params) {
return App.Post.find(params.post_id);
return this.get('store').find('post', params.post_id);
},

serialize: function(post) {
Expand Down
4 changes: 2 additions & 2 deletions source/bilingual_guides/getting-started/accepting-edits.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In the previous step we updated TodoMVC to allow a user to toggle the display of

在上一步中我们修改了TodoMVC使其可以支持用户能够切换到一个文本输入框`<input>`来编辑一个待办事项的标题。接下来,我们将实现在`<input>`显示时立即当前焦点移至其上,开始接收用户的输入,并在用户按下`<enter>`键时或把焦点从编辑的`<input>`元素中移出时,将用户的修改持久化,并显示待办事项修改后的标题。

To accomplish this, we'll create a new custom component and register it with Handelbars to make it available to our templates.
To accomplish this, we'll create a new custom component and register it with Handlebars to make it available to our templates.

为了实现这一步,可以创建一个自定义的组件并且通过Handlebars来注册它,使得其在模板中可用。

Expand Down Expand Up @@ -59,7 +59,7 @@ In `index.html` replace the static `<input>` element with our custom `{{edit-tod
<!--- ... 为保持代码简洁,在此省略了其他代码 ... -->
```

Pressing the `<enter>` key will trigger the `acceptChanges` event on the instance of `TodoController`. Moving focus away from from the `<input>` will trigger the `focus-out` event, calling a method `acceptChanges` on this view's instance of `TodoController`.
Pressing the `<enter>` key will trigger the `acceptChanges` event on the instance of `TodoController`. Moving focus away from the `<input>` will trigger the `focus-out` event, calling a method `acceptChanges` on this view's instance of `TodoController`.

点击`<enter>`键会触发`TodoController`实例的`acceptChanges`事件。焦点离开`<input>`时会出发`focus-out`事件,并调用视图的`TodoController`实例的`acceptChanges`方法。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ In `index.html` include `js/controllers/todos_controller.js` as a dependency:
```html
<!--- ... additional lines truncated for brevity ... -->
<!--- ... 为保持代码简洁,在此省略了其他代码 ... -->
<script src="js/models/store.js"></script>
<script src="js/models/todo.js"></script>
<script src="js/controllers/todos_controller.js"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Implement these properties as part of this template's controller, the `Todos.Tod
在模板的控制器`Todos.TodosController`中实现以上的属性:

```javascript
// Hint: these lines MUST NOT go into the 'actions' object.
// 提示:下面的代码不能放入'actions'
// ... additional lines truncated for brevity ...
// ... 为保持代码简洁,在此省略了其他代码 ...
remaining: function () {
Expand Down
2 changes: 1 addition & 1 deletion source/bilingual_guides/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Welcome to Ember.js! This guide will take you through creating a simple applicat

In this guide we will walk through the steps of building the popular [TodoMVC demo application](http://addyosmani.github.com/todomvc/).

本入门指南采用非常流行的[TodoMVC示例](http://addyosmani.github.com/todomvc/) 应用作为例子,介绍如何使用Ember.js来开发TodoMVC。
本入门指南采用非常流行的[TodoMVC示例](http://todomvc.com) 应用作为例子,介绍如何使用Ember.js来开发TodoMVC。
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ Todos.TodoController = Ember.ObjectController.extend({
var model = this.get('model');

if (value === undefined) {
// property being used as getter
// property being used as a getter
return model.get('isCompleted');
} else {
// property being used as setter
// property being used as a setter
model.set('isCompleted', value);
model.save();
return value;
Expand All @@ -55,10 +55,14 @@ Todos.TodoController = Ember.ObjectController.extend({
});
```

When called from the template to display the current `isCompleted` state of the todo, this property will proxy that question to its underlying `model`. When called with a value because a user has toggled the checkbox in the template, this property will set the `isCompleted` property of its `model` to the passed value (`true` or `false`), persist the model update, and return the passed value so the checkbox will display correctly.
When called from the template to display the current `isCompleted` state of the todo, this property will proxy that question to its underlying `model`. When called with a value because a user has toggled the checkbox in the template, this property will set the `isCompleted` property of its `model` to the passed value (`true` or `false`), persist the model update, and return the passed value so the checkbox will display correctly.

The `isCompleted` function is marked a [computed property](/guides/object-model/computed-properties/) whose value is dependent on the value of `model.isCompleted`.

当模板中需要显示待办事项的当前`isCompleted`状态,这个属性将这个问题委派给其底层的`model`。当被调用时因为用户触发了模板中的复选框而带有一个参数,那么这个属性将设置`model``isCompleted`属性为传入的参数值(`true`或者`false`),并将模型的变更持久化,返回传入的值以便复选框显示正确。

`isCompleted`函数被声明为一个[计算属性](/guides/object-model/computed-properties/),其值依赖于`model.isCompleted`

In `index.html` include `js/controllers/todo_controller.js` as a dependency:

`index.html`中包含`js/controllers/todo_controller.js`依赖:
Expand Down
4 changes: 2 additions & 2 deletions source/bilingual_guides/getting-started/modeling-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ Reload your web browser to ensure that all files have been referenced correctly
### Additional Resources

* [Changes in this step in `diff` format](https://github.com/emberjs/quickstart-code-sample/commit/a1ccdb43df29d316a7729321764c00b8d850fcd1)
* [Defining A Store Guide](/guides/models/defining-a-store)
* [Using the Store Guide](/guides/models/using-the-store)
* [Defining Models Guide](/guides/models/defining-models)

### 附加资源

* [采用`diff`格式显示这步骤所作的修改](https://github.com/emberjs/quickstart-code-sample/commit/a1ccdb43df29d316a7729321764c00b8d850fcd1)
* [创建一个存储器指南](/guides/models/defining-a-store)
* [Store使用指南](/guides/models/using-the-store)
* [定义模型指南](/guides/models/defining-models)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 获取EMBER.JS和相应依赖

TodoMVC has a few dependecnies:
TodoMVC has a few dependencies:

TodoMVC的依赖:

Expand All @@ -19,9 +19,9 @@ For this example, all of these resources should be stored in the folder `js/libs

```html
<!-- ... additional lines truncated for brevity ... -->
<!-- ... 为确保简洁,略去头尾代码 ... -->
<script src="js/libs/jquery.min.js"></script>
<script src="js/libs/handlebars.js"></script>
<!-- ... 为确保简洁,略去头尾代码 ... -->
<script src="js/libs/jquery-1.10.2.min.js"></script>
<script src="js/libs/handlebars-1.0.0.js"></script>
<script src="js/libs/ember.js"></script>
<script src="js/libs/ember-data.js"></script>
</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Toggling All Todos Between Complete and Incomplete

TodoMVC allows user to toggle all existing todos into either a complete or incomplete state. It uses the same checkbox that becomes checked when all todos are completed and unchecked when one or more todos remain incomplete.
TodoMVC allows users to toggle all existing todos into either a complete or incomplete state. It uses the same checkbox that becomes checked when all todos are completed and unchecked when one or more todos remain incomplete.

To implement this behavior update the `allAreDone` property in `js/controllers/todos_controller.js` to handle both getting and setting behavior:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In `index.html` include `js/libs/local_storage_adapter.js` as a dependency:
```html
<!--- ... additional lines truncated for brevity ... -->
<script src="js/libs/ember-data.js"></script>
<script src="js/libs/local_storage_adapter.js"></script>
<script src="js/libs/localstorage_adapter.js"></script>
<script src="js/application.js"></script>
<!--- ... additional lines truncated for brevity ... -->
```
Expand Down
Empty file.
46 changes: 0 additions & 46 deletions source/bilingual_guides/models/defining-a-store.md

This file was deleted.

Loading

0 comments on commit a406fd1

Please sign in to comment.