Commit 24680e58 authored by Eric Bidelman's avatar Eric Bidelman

Feedback

parent 175cff47
...@@ -2,34 +2,33 @@ ...@@ -2,34 +2,33 @@
> Polymer is a new type of library for the web, built on top of Web Components, and designed to leverage the evolving web platform on modern browsers. > Polymer is a new type of library for the web, built on top of Web Components, and designed to leverage the evolving web platform on modern browsers.
> _[Polymer - www.polymer-project.org](http://www.polymer-project.org/)_ > _[Polymer - www.polymer-project.org](https://www.polymer-project.org/)_
## Learning Polymer ## Learning Polymer
The [Polymer website](http://www.polymer-project.org) is a great resource for getting started. The [Polymer website](https://www.polymer-project.org) is a great resource for getting started.
Here are some links you may find helpful: Here are some links you may find helpful:
* [Getting Started](http://www.polymer-project.org/docs/start/everything.html) * [Getting Started](https://www.polymer-project.org/1.0/docs/start/getting-the-code.html)
* [FAQ](http://www.polymer-project.org/resources/faq.html) * [FAQ](https://www.polymer-project.org/0.5/resources/faq.html) (old)
* [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html) * [Browser Compatibility](https://www.polymer-project.org/1.0/resources/compatibility.html)
Get help from Polymer devs and users: Get help from Polymer devs and users:
* Find us on IRC on __#polymer__ at freenode. * Find us Slack - polymer.slack.com
* Join the high-traffic [polymer-dev](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev) Google group or the announcement-only [polymer-announce](https://groups.google.com/forum/?fromgroups=#!forum/polymer-announce) Google group. * Join the high-traffic [polymer-dev](https://groups.google.com/forum/?fromgroups=#!forum/polymer-dev) Google group or the announcement-only [polymer-announce](https://groups.google.com/forum/?fromgroups=#!forum/polymer-announce) Google group.
## Implementation ## Implementation
The Polymer implementation of TodoMVC has a few key differences with other implementations: The Polymer implementation of TodoMVC has a few key differences with other implementations:
* Since [Web Components](http://w3c.github.io/webcomponents/explainer/) allow you to create new types of DOM elements, the DOM tree is very different from other implementations. * [Web Components](http://w3c.github.io/webcomponents/explainer/) allow you to create new HTML elements that are reusable, composable, and encapsulated.
* The template, styling, and behavior are fully encapsulated in each custom element. Instead of having an overall stylesheet (`base.css` or `app.css`), each element that needs styling has its own stylesheet. * Non-visual elements such as the router and the model are also implemented as custom elements and appear in the DOM. Implementing them as custom elements instead of plain objects allows you to take advantage of Polymer's data binding and event handling throughout the app.
* Non-visual elements such as the router and the model are also implemented as custom elements and appear in the DOM. Implementing them as custom elements instead of plain objects allows you to take advantage of Polymer data binding and event handling throughout the app.
## Compatibility ## Compatibility
Polymer and its polyfills are intended to work in the latest version of [evergreen browsers](http://tomdale.net/2013/05/evergreen-browsers/). IE9 is not supported. Please refer to [Browser Compatibility](http://www.polymer-project.org/resources/compatibility.html) for more details. Polymer and the web component polyfills are intended to work in the latest version of [evergreen browsers](http://tomdale.net/2013/05/evergreen-browsers/). IE9 is not supported. Please refer to [Browser Compatibility](https://www.polymer-project.org/1.0/resources/compatibility.html) for more details.
## Running this sample ## Running this sample
...@@ -42,3 +41,11 @@ Polymer and its polyfills are intended to work in the latest version of [evergre ...@@ -42,3 +41,11 @@ Polymer and its polyfills are intended to work in the latest version of [evergre
`python -m SimpleHTTPServer` `python -m SimpleHTTPServer`
1. Browse to the server root 1. Browse to the server root
## Making updates
If you want to make a change to any of the elements in elements/elements.html, you'll need to install `polybuild` (Polymer's build tool) and re-vulcanize elements.build.html.
1. Run `npm install`
1. Make a change
2. Run `npm run build`
...@@ -36,7 +36,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN ...@@ -36,7 +36,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</dom-module> </dom-module>
<dom-module id="td-todos" assetpath="/"> <dom-module id="td-todos" assetpath="/">
<template> <template>
<style> :host { display: block; } </style> <style> :host { display: block; } </style>
<flatiron-director route="{{route}}" hidden=""></flatiron-director> <flatiron-director route="{{route}}" hidden=""></flatiron-director>
<section id="todoapp"> <section id="todoapp">
<header id="header"> <header id="header">
...@@ -56,8 +56,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN ...@@ -56,8 +56,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<footer id="footer"> <footer id="footer">
<span id="todo-count"> <span id="todo-count">
<strong>{{activeCount}}</strong> <strong>{{activeCount}}</strong>
<span>{{_computeItemsLeft(activeCount)}}</span> left <span>{{_computeItemsLeft(activeCount)}}</span> left
</span> </span>
<iron-selector id="filters" selected="{{route}}" attr-for-selected="route"> <iron-selector id="filters" selected="{{route}}" attr-for-selected="route">
......
<link rel="import" href="../bower_components/polymer/polymer.html"> <link rel="import" href="../bower_components/polymer/polymer.html">
<script> <script>
(function() { (function () {
'use strict'; 'use strict';
var ENTER_KEY = 13; var ENTER_KEY = 13;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</template> </template>
</template> </template>
<script> <script>
(function() { (function () {
'use strict'; 'use strict';
Polymer({ Polymer({
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
}, },
item: { item: {
type: Object, type: Object,
value: function() { return {}; } value: function () { return {}; }
}, },
}, },
...@@ -48,21 +48,21 @@ ...@@ -48,21 +48,21 @@
this.toggleClass('editing', editing); this.toggleClass('editing', editing);
}, },
_onBlur: function() { _onBlur: function () {
this._commitAction(); this._commitAction();
this.editing = false; this.editing = false;
}, },
_editAction: function() { _editAction: function () {
this.editing = true; this.editing = true;
this._editingValue = this.item.title; this._editingValue = this.item.title;
// Wait one tick template to stamp. // Wait one tick template to stamp.
this.async(function() { this.async(function () {
this.querySelector('#edit').focus(); this.querySelector('#edit').focus();
}); });
}, },
_commitAction: function() { _commitAction: function () {
if (this.editing) { if (this.editing) {
this.editing = false; this.editing = false;
this.set('item.title', this._editingValue.trim()); this.set('item.title', this._editingValue.trim());
...@@ -72,11 +72,11 @@ ...@@ -72,11 +72,11 @@
} }
}, },
_cancelAction: function() { _cancelAction: function () {
this.editing = false; this.editing = false;
}, },
_destroyAction: function() { _destroyAction: function () {
this.fire('td-destroy-item', this.item); this.fire('td-destroy-item', this.item);
} }
}); });
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
on-iron-localstorage-load-empty="_initializeDefaultTodos"></iron-localstorage> on-iron-localstorage-load-empty="_initializeDefaultTodos"></iron-localstorage>
</template> </template>
<script> <script>
(function() { (function () {
'use strict'; 'use strict';
Polymer({ Polymer({
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
} }
}, },
_initializeDefaultTodos: function() { _initializeDefaultTodos: function () {
this.items = []; this.items = [];
}, },
...@@ -41,11 +41,11 @@ ...@@ -41,11 +41,11 @@
this.push('items', {title: title, completed: false}); this.push('items', {title: title, completed: false});
}, },
getCompletedCount: function() { getCompletedCount: function () {
return this.items ? this.items.filter(this.filters.completed).length : 0; return this.items ? this.items.filter(this.filters.completed).length : 0;
}, },
getActiveCount: function() { getActiveCount: function () {
return this.items.length - this.getCompletedCount(this.items); return this.items.length - this.getCompletedCount(this.items);
}, },
...@@ -61,12 +61,12 @@ ...@@ -61,12 +61,12 @@
} }
}, },
clearCompletedItems: function() { clearCompletedItems: function () {
this.items = this.items.filter(this.filters.active); this.items = this.items.filter(this.filters.active);
}, },
setItemsCompleted: function(completed) { setItemsCompleted: function(completed) {
for (var i = 0; i < this.items.length; ++i) { for (var i = 0; i < this.items.length; ++i) {
this.set(['items', i, 'completed'], completed); this.set(['items', i, 'completed'], completed);
} }
}, },
......
...@@ -6,28 +6,28 @@ ...@@ -6,28 +6,28 @@
<dom-module id="td-todos"> <dom-module id="td-todos">
<template> <template>
<style> <style>
:host { :host {
display: block; display: block;
} }
</style> </style>
<flatiron-director route="{{route}}" hidden></flatiron-director> <flatiron-director route="{{route}}" hidden></flatiron-director>
<section id="todoapp"> <section id="todoapp">
<header id="header"> <header id="header">
<input is="td-input" id="new-todo" <input is="td-input" id="new-todo"
placeholder="What needs to be done?" autofocus placeholder="What needs to be done?" autofocus
on-td-input-commit="addTodoAction" on-td-input-commit="addTodoAction"
on-td-input-cancel="cancelAddTodoAction"> on-td-input-cancel="cancelAddTodoAction">
</header> </header>
<template is="dom-if" if="{{items.length}}"> <template is="dom-if" if="{{items.length}}">
<section id="main"> <section id="main">
<input id="toggle-all" type="checkbox" checked="[[allCompleted]]" <input id="toggle-all" type="checkbox" checked="[[allCompleted]]"
on-change="toggleAllCompletedAction"> on-change="toggleAllCompletedAction">
<label for="toggle-all">Mark all as complete</label> <label for="toggle-all">Mark all as complete</label>
<ul id="todo-list" on-td-destroy-item="destroyItemAction"> <ul id="todo-list" on-td-destroy-item="destroyItemAction">
<template id="todo-list-repeater" is="dom-repeat" items="{{items}}" <template id="todo-list-repeater" is="dom-repeat" items="{{items}}"
filter="{{matchesFilter(route)}}" observe="completed"> filter="{{matchesFilter(route)}}" observe="completed">
<li is="td-item" item="{{item}}"></li> <li is="td-item" item="{{item}}"></li>
</template> </template>
</ul> </ul>
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
<footer id="footer"> <footer id="footer">
<span id="todo-count"> <span id="todo-count">
<strong>{{activeCount}}</strong> <strong>{{activeCount}}</strong>
<span>{{_computeItemsLeft(activeCount)}}</span> left <span>{{_computeItemsLeft(activeCount)}}</span> left
</span> </span>
<iron-selector id="filters" selected="{{route}}" attr-for-selected="route"> <iron-selector id="filters" selected="{{route}}" attr-for-selected="route">
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
</section> </section>
</template> </template>
<script> <script>
(function() { (function () {
'use strict'; 'use strict';
Polymer({ Polymer({
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
} }
}, },
attached: function() { attached: function () {
this.model = document.querySelector('#' + this.modelId); this.model = document.querySelector('#' + this.modelId);
}, },
...@@ -122,15 +122,15 @@ ...@@ -122,15 +122,15 @@
matchesFilter: function(route) { matchesFilter: function(route) {
return function(item, index, array) { return function(item, index, array) {
return this.model ? this.model.matchesFilter(item, route) : false; return this.model ? this.model.matchesFilter(item, route) : false;
}.bind(this); }.bind(this);
}, },
addTodoAction: function() { addTodoAction: function () {
this.model.newItem(this.$['new-todo'].value); this.model.newItem(this.$['new-todo'].value);
this.$['new-todo'].value = ''; this.$['new-todo'].value = '';
}, },
cancelAddTodoAction: function() { cancelAddTodoAction: function () {
this.$['new-todo'].value = ''; this.$['new-todo'].value = '';
}, },
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
this.model.setItemsCompleted(e.target.checked); this.model.setItemsCompleted(e.target.checked);
}, },
clearCompletedAction: function() { clearCompletedAction: function () {
this.model.clearCompletedItems(); this.model.clearCompletedItems();
} }
}); });
......
...@@ -27,15 +27,15 @@ ...@@ -27,15 +27,15 @@
<script> <script>
(function() { (function() {
// Feature detect and conditionally load the polyfills. // Feature detect and conditionally load the polyfills.
var webComponentsSupported = ('registerElement' in document var webComponentsSupported = ('registerElement' in document
&& 'import' in document.createElement('link') && 'import' in document.createElement('link')
&& 'content' in document.createElement('template')); && 'content' in document.createElement('template'));
if (!webComponentsSupported) { if (!webComponentsSupported) {
var script = document.createElement('script'); var script = document.createElement('script');
script.async = true; script.async = true;
script.src = 'bower_components/webcomponentsjs/webcomponents-lite.min.js'; script.src = 'bower_components/webcomponentsjs/webcomponents-lite.min.js';
document.head.appendChild(script); document.head.appendChild(script);
} }
})(); })();
</script> </script>
......
{ {
"name": "polymer-todomvc", "private": true,
"version": "1.0.0",
"description": "Polymer TodoMVC demo",
"main": "index.html",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "postinstall": "npm run build",
"build": "polybuild --maximum-crush elements/elements.html"
}, },
"repository": {
"type": "git",
"url": "https://github.com/tastejs/todomvc"
},
"keywords": [
"polymer",
"todomvc"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/tastejs/todomvc/issues"
},
"homepage": "https://github.com/tastejs/todomvc",
"devDependencies": { "devDependencies": {
"polybuild": "^1.0.5" "polybuild": "^1.0.5"
} }
......
#!/bin/sh
# vulcanize elements.html \
# --inline-script --inline-css --strip-comments | \
# crisper -h elements.build.html -j elements.build.js
polybuild --maximum-crush elements/elements.html
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment