X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/b2dcc4cec0edb145ed13c26537c94b593691954f..bdd9d26375a6489d7ff8eac944e29b0789f04a20:/js/app/app.coffee diff --git a/js/app/app.coffee b/js/app/app.coffee index 390729a..c6e4cb4 100644 --- a/js/app/app.coffee +++ b/js/app/app.coffee @@ -1,9 +1,19 @@ window.Readings = {} -$.fn.Readings = {} +# Readings jquery plugin dispatcher. +$.fn.Readings = -> + meth = arguments[0] + args = [] + for a in arguments + args.push a + args.shift() + $.fn.Readings[meth].apply(this, args) -$(document).on 'pageinit', (ev) -> + +Readings.init = -> + if Readings.initialized? + return Readings.config = new Readings.Config wlurl: 'http://readings.local' categories: @@ -12,5 +22,23 @@ $(document).on 'pageinit', (ev) -> 'genres': 'gatunek', 'kinds': 'rodzaj', 'themes': 'motyw' + show_filter: [ 'authors', 'themes' ] + show_dividers: [ 'authors', 'themes'] + Readings.initialized = true + +$(document).on 'pageinit', '#page-categories' , (ev) -> + Readings.init() + $('#list-categories').Readings 'CategoryList' - Readings.category_list $('#list-categories') \ No newline at end of file +rcategory = /category=(\w+)/ +$(document).on 'pageinit', "#page-tags", (ev, ui) -> + category = rcategory.exec($(this).attr('data-url')) + if category? and category[1]? + $(this).Readings 'list', + category: category[1] + url: Readings.config.get('wlurl') + "/api/#{category[1]}" + filter: (Readings.config.get('show_filter').indexOf(category[1]) >= 0) + mapper: (rec) -> new Readings.Tag(rec, category[1]) + dividers: (Readings.config.get('show_dividers').indexOf(category[1]) >= 0) + else + alert 'no category in query string' \ No newline at end of file