Download:
child 19:bce86fd15801
parent 17:e6decc6d69a7
18:fa1c928c7a44
Anton Shestakov <av6@dwimlabs.net>, Wed, 22 Jun 2016 13:19:44 +0800
demo: remove trailing spaces

1 файлов изменено, 12 вставок(+), 12 удалений(-) [+]
demo.html file | annotate | diff | comparison | revisions
--- a/demo.html Wed Jun 22 13:16:13 2016 +0800
+++ b/demo.html Wed Jun 22 13:19:44 2016 +0800
@@ -3,11 +3,11 @@
<head>
<title>Shard Demo</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/css/bootstrap.min.css" integrity="sha384-MY3lqAyZWEjvYefTFTBYUN85pnmwAxdSjsX+8IqCP1N5VBzOIX6GNo1rUt9gz74C" crossorigin="anonymous">
-
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js" integrity="sha384-rY/jv8mMhqDabXSo+UCggqKtdmBfd3qC2/KvyTDNQ6PcUJXaxK1tMepoQda4g5vB" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js" integrity="sha384-FZY+KSLVXVyc1qAlqH9oCx1JEOlQh6iXfw3o2n3Iy32qGjXmUPWT9I0Z9e9wxYe3" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js" integrity="sha384-NNt9ocJfZhIg2c5PbM5G2a3tTaeXhEfqCHWHNB7htzaWKn8MwFkzVyGdzLA8QMX7" crossorigin="anonymous"></script>
-
+
<script src="backbone.shard.js"></script>
</head>
<body>
@@ -17,7 +17,7 @@
<div id="collection"></div>
</div>
</div>
-
+
<div class="row-fluid">
<div class="span3 offset3">
<h3>Read</h3>
@@ -28,7 +28,7 @@
<div id="subset-unread" class="centered"></div>
</div>
</div>
-
+
<script>
var Book = Backbone.Model;
var col = new Backbone.Collection([
@@ -37,42 +37,42 @@
new Book({title: 'Moby Dick', read: false}),
new Book({title: 'The Catcher in the Rye', read: false})
]);
-
+
var CollectionView = Backbone.View.extend({
initialize: function(options) {
this.collection.on('add change remove reset', this.render, this);
this.render();
},
-
+
render: function() {
this.$el.empty();
this.collection.each(this.appendItem, this);
},
-
+
appendItem: function(item) {
var $cb = $('<input>').attr('type', 'checkbox').prop('checked', item.get('read'));
var $label = $('<label>').addClass('checkbox').text(item.get('title')).prepend($cb);
this.$el.append($label);
-
+
$cb.change(function() {
item.set('read', this.checked);
});
}
});
-
+
var shardRead = new Backbone.Shard({collection: col, filter: function(book) { return book.get('read'); } });
var shardUnread = new Backbone.Shard({collection: col, filter: function(book) { return !book.get('read'); } });
-
+
new CollectionView({
el: $('#collection'),
collection: col
});
-
+
new CollectionView({
el: $('#subset-unread'),
collection: shardUnread
});
-
+
new CollectionView({
el: $('#subset-read'),
collection: shardRead