0ca151c8350d33be383ee82a941fb1ae4599b583
[ReadingsJQM.git] / js / app / app.coffee
1
2 window.Readings = {}
3
4 # Readings jquery plugin dispatcher.
5 $.fn.Readings =  ->
6   meth = arguments[0]
7   args = []
8   for a in arguments
9     args.push a
10   args.shift()
11   $.fn.Readings[meth].apply(this, args)
12
13
14 Readings.init = ->
15   if Readings.initialized?
16     return
17   Readings.config = new Readings.Config
18     wlurl: 'http://readings.local'
19     categories:
20       'authors': 'autor',
21       'epochs': 'epoka',
22       'genres': 'gatunek',
23       'kinds': 'rodzaj',
24       'themes': 'motyw'
25   Readings.initialized = true
26
27 $(document).on 'pageinit', '#page-categories' , (ev) ->
28   Readings.init()
29   $('#list-categories').Readings 'CategoryList'
30
31 rcategory = /category=(\w+)/
32 $(document).on 'pageshow', "#page-tags", (ev, ui) ->
33   category = rcategory.exec($(this).attr('data-url'))
34   if category? and category[1]?
35     $(this).Readings 'TagList', category[1]