X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/b2dcc4cec0edb145ed13c26537c94b593691954f..bdd9d26375a6489d7ff8eac944e29b0789f04a20:/js/app/app.js diff --git a/js/app/app.js b/js/app/app.js index 79aa20c..b5e2ba2 100644 --- a/js/app/app.js +++ b/js/app/app.js @@ -1,10 +1,25 @@ +// Generated by CoffeeScript 1.3.3 (function() { + var rcategory; window.Readings = {}; - $.fn.Readings = {}; + $.fn.Readings = function() { + var a, args, meth, _i, _len; + meth = arguments[0]; + args = []; + for (_i = 0, _len = arguments.length; _i < _len; _i++) { + a = arguments[_i]; + args.push(a); + } + args.shift(); + return $.fn.Readings[meth].apply(this, args); + }; - $(document).on('pageinit', function(ev) { + Readings.init = function() { + if (Readings.initialized != null) { + return; + } Readings.config = new Readings.Config({ wlurl: 'http://readings.local', categories: { @@ -13,9 +28,36 @@ 'genres': 'gatunek', 'kinds': 'rodzaj', 'themes': 'motyw' - } + }, + show_filter: ['authors', 'themes'], + show_dividers: ['authors', 'themes'] }); - return Readings.category_list($('#list-categories')); + return Readings.initialized = true; + }; + + $(document).on('pageinit', '#page-categories', function(ev) { + Readings.init(); + return $('#list-categories').Readings('CategoryList'); + }); + + rcategory = /category=(\w+)/; + + $(document).on('pageinit', "#page-tags", function(ev, ui) { + var category; + category = rcategory.exec($(this).attr('data-url')); + if ((category != null) && (category[1] != null)) { + return $(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: function(rec) { + return new Readings.Tag(rec, category[1]); + }, + dividers: Readings.config.get('show_dividers').indexOf(category[1]) >= 0 + }); + } else { + return alert('no category in query string'); + } }); }).call(this);