Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1421)

Unified Diff: samples/third_party/todomvc_performance/js_todomvc/elements/td-model.html

Issue 204733004: Added TodoMVC startup benchmarks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/third_party/todomvc_performance/js_todomvc/elements/td-model.html
diff --git a/samples/third_party/todomvc_performance/js_todomvc/elements/td-model.html b/samples/third_party/todomvc_performance/js_todomvc/elements/td-model.html
new file mode 100755
index 0000000000000000000000000000000000000000..19f3d2204332eca9d0136ae222d137f1fa87567a
--- /dev/null
+++ b/samples/third_party/todomvc_performance/js_todomvc/elements/td-model.html
@@ -0,0 +1,74 @@
+<link rel="import" href="../components/polymer/polymer.html">
+
+<polymer-element name="td-model" attributes="filter items storageId">
+ <script>
+ Polymer('td-model', {
+ filtered: null,
+ completedCount: 0,
+ activeCount: 0,
+ allCompleted: false,
+ ready: function() {
+ this.asyncMethod(function() {
+ this.items = this.items || [];
+ });
+ },
+ filterChanged: function() {
+ this.filterItems();
+ },
+ itemsChanged: function() {
+ this.completedCount =
+ this.items.filter(this.filters.completed).length;
+ this.activeCount = this.items.length - this.completedCount;
+ this.allCompleted = this.completedCount && !this.activeCount;
+ this.filterItems();
+ if (this.storage) {
+ this.storage.value = this.items;
+ this.storage.save();
+ }
+ },
+ storageIdChanged: function() {
+ this.storage = document.querySelector('#' + this.storageId);
+ this.storage && (this.items = this.storage.value);
+ },
+ filterItems: function() {
+ var fn = this.filters[this.filter];
+ this.filtered = fn ? this.items.filter(fn) : this.items;
+ },
+ newItem: function(title) {
+ title = String(title).trim();
+ if (title) {
+ var item = {
+ title: title,
+ completed: false
+ };
+ this.items.push(item);
+ this.itemsChanged();
+ }
+ },
+ destroyItem: function(item) {
+ var i = this.items.indexOf(item);
+ if (i >= 0) {
+ this.items.splice(i, 1);
+ }
+ this.itemsChanged();
+ },
+ clearItems: function(){
+ this.items = this.items.filter(this.filters.active);
+ },
+ setItemsCompleted: function(completed) {
+ this.items.forEach(function(item) {
+ item.completed = completed;
+ });
+ this.itemsChanged();
+ },
+ filters: {
+ active: function(item) {
+ return !item.completed;
+ },
+ completed: function(item) {
+ return item.completed;
+ }
+ }
+ });
+ </script>
+</polymer-element>

Powered by Google App Engine
This is Rietveld 408576698