summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/activities.js.coffee
blob: 3b6b453ac51b4206457aaacb417d02dde194c2be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class @Activities
  constructor: ->
    Pager.init 20, true
    $(".event-filter a").bind "click", (event) =>
      event.preventDefault()
      @toggleFilter($(event.currentTarget))
      @reloadActivities()

  reloadActivities: ->
    $(".content_list").html ''
    Pager.init 20, true


  toggleFilter: (sender) ->
    sender.closest('li').toggleClass "active"
    event_filters = $.cookie("event_filter")
    filter = sender.attr("id").split("_")[0]
    if event_filters
      event_filters = event_filters.split(",")
    else
      event_filters = new Array()

    index = event_filters.indexOf(filter)
    if index is -1
      event_filters.push filter
    else
      event_filters.splice index, 1

    $.cookie "event_filter", event_filters.join(","), { path: '/' }