X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/1be34458067b077d6403eb0bec498759be8fd4ca..refs/heads/readings:/js/app/reader.js diff --git a/js/app/reader.js b/js/app/reader.js index a978e54..35a791f 100644 --- a/js/app/reader.js +++ b/js/app/reader.js @@ -1,35 +1,42 @@ -// Generated by CoffeeScript 1.3.3 (function() { - $.fn.extend({ - load_book: function(slug) { - return this.each(function() { - var _this = this; - return $.ajax({ - type: 'GET', - contentType: 'html', - url: '/fixtures/katalog_lektura_lord-jim.html', - error: function(e) { - return console.log("Error " + e); - }, - success: function(page) { - var $page, $text, $toc; - $page = $(page); - $text = $page.find('#book-text'); - $toc = $text.find('#toc'); - _this.toc = $toc.find('a').map(function(_i, link) { - return { - anchor: link.href, - label: $(link).text() - }; - }); - $toc.remove(); - _this.text = $text; - return $('[data-role=header] h1', _this).text(_this.text.find('h1 .title').text()); - } - }); + $.fn.Readings.reader = function(opts) { + this.each(function() { + var _this = this; + return Readings.catalogue.fetchBook(opts.book_id, true, function(book) { + return $(_this).find("#content-reader").empty().append(book.getText()); }); - } - }); + }); + return { + load_book: function(slug) { + return this.each(function() { + var _this = this; + return $.ajax({ + type: 'GET', + contentType: 'html', + url: '/fixtures/katalog_lektura_lord-jim.html', + error: function(e) { + return console.log("Error " + e); + }, + success: function(page) { + var $page, $text, $toc; + $page = $(page); + $text = $page.find('#book-text'); + $toc = $text.find('#toc'); + _this.toc = $toc.find('a').map(function(_i, link) { + return { + anchor: link.href, + label: $(link).text() + }; + }); + $toc.remove(); + _this.text = $text; + return $('[data-role=header] h1', _this).text(_this.text.find('h1 .title').text()); + } + }); + }); + } + }; + }; }).call(this);