4 # Readings jquery plugin dispatcher.
11 $.fn.Readings[meth].apply(this, args)
15 if Readings.initialized?
17 Readings.config = new Readings.Config
18 wlurl: 'http://dev.wolnelektury.pl'
19 initdburl: 'http://dev.wolnelektury.pl/media/api/mobile/initial/initial.sql'
26 show_filter: [ 'authors', 'themes' ]
27 show_dividers: [ 'authors', 'themes']
29 Readings.catalogue = new Readings.Catalogue().open()
30 Readings.initialized = true
32 $(document).on 'pageinit', '#page-categories' , (ev) ->
34 $('#list-categories').Readings 'CategoryList'
36 rcategory = /category=(\w+)/
37 rtag = /tag=([a-z0-9-]+)/
38 rtagid = /tag_id=([0-9]+)/
40 $(document).on 'pageinit', "#page-tags", (ev, ui) ->
41 category = rcategory.exec($(this).attr('data-url'))
43 category = category[1]
45 return $(this).Readings 'list',
47 # url: Readings.config.get('wlurl') + "/api/#{category}"
48 sql: "SELECT * FROM tag WHERE category=? ORDER BY sort_key"
50 filter: (Readings.config.get('show_filter').indexOf(category) >= 0)
51 mapper: (rec) -> new Readings.Tag(rec, category)
52 dividers: (Readings.config.get('show_dividers').indexOf(category) >= 0)
53 alert 'no category in query string'
55 $(document).on 'pageinit', '#page-books', (ev, ui) ->
56 tag_id_m = rtagid.exec($(this).attr('data-url'))
57 tag_id = tag_id_m[1] if tag_id_m?
59 tag = Readings.catalogue.withTag tag_id, (tag) =>
60 $(this).Readings 'list',
61 fetch: (cb) -> Readings.catalogue.withBooks(tag, cb)
63 dividers: (tag.category != 'author')