endlich!!!
[ReadingsJQM.git] / js / app / reader.js
1 // Generated by CoffeeScript 1.3.3
2 (function() {
3
4   $.fn.extend({
5     load_book: function(slug) {
6       return this.each(function() {
7         var _this = this;
8         return $.ajax({
9           type: 'GET',
10           contentType: 'html',
11           url: '/fixtures/katalog_lektura_lord-jim.html',
12           error: function(e) {
13             return console.log("Error " + e);
14           },
15           success: function(page) {
16             var $page, $text, $toc;
17             $page = $(page);
18             $text = $page.find('#book-text');
19             $toc = $text.find('#toc');
20             _this.toc = $toc.find('a').map(function(_i, link) {
21               return {
22                 anchor: link.href,
23                 label: $(link).text()
24               };
25             });
26             $toc.remove();
27             _this.text = $text;
28             return $('[data-role=header] h1', _this).text(_this.text.find('h1 .title').text());
29           }
30         });
31       });
32     }
33   });
34
35 }).call(this);