1 // Generated by CoffeeScript 1.3.3
5 slug_in_url = /([a-z0-9-]+)[/]?$/;
7 Readings.Book = (function() {
9 function Book(record) {
10 this.url = record.url;
11 this.href = record.href;
12 this.cover = record.cover;
13 this.author = record.author;
14 this.title = record.title;
15 this.slug = slug_in_url.exec(this.href)[1];
18 Book.prototype.render = function() {
19 return "<li><a href=\"reader.html?slug=" + this.slug + "\">" + this.title + "</a></li>";
22 Book.prototype.group = function() {
30 $.fn.Readings.BookList = function(category, tag) {
31 return this.each(function() {
33 $('[data-role=header] h1').text(tag.name);
34 list = $('[data-role=listview]', this);
36 url: "" + tag.href + "books/",
38 success: function(data) {
39 var b, books, last_separator, separator, show_separator, _i, _len, _results;
41 books = $.map(data, function(rec) {
42 return new Readings.Book(rec);
45 last_separator = null;
46 show_separator = !(category === 'authors');
48 for (_i = 0, _len = books.length; _i < _len; _i++) {
51 separator = t.group();
52 if (last_separator !== separator) {
53 list.append("<li data-role=\"list-divider\">" + separator + "</li>");
54 last_separator = separator;
57 list.append(b.render());
58 _results.push(list.listview('refresh'));