X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/bdd9d26375a6489d7ff8eac944e29b0789f04a20..45f8b33043d9aad64b1f89906323bc477efda0f3:/js/app/BooksList.coffee diff --git a/js/app/BooksList.coffee b/js/app/BooksList.coffee deleted file mode 100644 index 21b6d19..0000000 --- a/js/app/BooksList.coffee +++ /dev/null @@ -1,44 +0,0 @@ - -slug_in_url = /([a-z0-9-]+)[/]?$/ - -class Readings.Book - constructor: (record) -> - @url = record.url - @href = record.href - @cover = record.cover - @author = record.author - @title = record.title - @slug = slug_in_url.exec(@href)[1] - - render: -> - "
  • #{@title}
  • " - - group: -> - @author - - -$.fn.Readings.BookList = (category, tag) -> - this.each -> - $('[data-role=header] h1').text tag.name - list = $('[data-role=listview]', this) - $.ajax - url: "#{tag.href}books/" - #url: Readings.config.get('wlurl') + "/api/#{category}" - contentType: "json" - success: (data) -> - console.log(data) - books = $.map data, (rec) -> new Readings.Book(rec) - list.empty() - last_separator = null - show_separator = !(category == 'authors') - - for b in books - # throw a separator in for some categories - if show_separator - separator = t.group() - if last_separator != separator - list.append "
  • #{separator}
  • " - last_separator = separator - - list.append b.render() - list.listview 'refresh'