Commit 5133fe8efb0f58f3a8fe0fe8e5474fa7db98cac1
1 parent
3cc04583
Exists in
master
and in
4 other branches
dashboard js -> coffee
Showing
2 changed files
with
29 additions
and
40 deletions
Show diff stats
app/assets/javascripts/dashboard.js
| ... | ... | @@ -1,40 +0,0 @@ |
| 1 | -/** | |
| 2 | - * Init dashboard page | |
| 3 | - * | |
| 4 | - */ | |
| 5 | - | |
| 6 | -$(function(){ | |
| 7 | - Pager.init(20, true); | |
| 8 | - dashboardPage(); | |
| 9 | -}); | |
| 10 | - | |
| 11 | -function dashboardPage(){ | |
| 12 | - $(".event_filter_link").bind('click',(function(){ | |
| 13 | - toggleFilter($(this)); | |
| 14 | - reloadActivities(); | |
| 15 | - })); | |
| 16 | -} | |
| 17 | - | |
| 18 | -function reloadActivities(){ | |
| 19 | - $('.content_list').html(''); | |
| 20 | - Pager.init(20, true); | |
| 21 | -} | |
| 22 | - | |
| 23 | -function toggleFilter(sender){ | |
| 24 | - sender.parent().toggleClass('inactive'); | |
| 25 | - var event_filters = $.cookie('event_filter'); | |
| 26 | - var filter = sender.attr('id').split('_')[0]; | |
| 27 | - if (!event_filters) { | |
| 28 | - event_filters = new Array(); | |
| 29 | - } else { | |
| 30 | - event_filters = event_filters.split(','); | |
| 31 | - } | |
| 32 | - var index = event_filters.indexOf(filter); | |
| 33 | - if (index == -1) { | |
| 34 | - event_filters.push(filter); | |
| 35 | - } else { | |
| 36 | - event_filters.splice(index, 1); | |
| 37 | - } | |
| 38 | - $.cookie('event_filter', event_filters.join(',')); | |
| 39 | -}; | |
| 40 | - |
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +$ -> | |
| 2 | + dashboardPage() | |
| 3 | + | |
| 4 | +dashboardPage = -> | |
| 5 | + Pager.init 20, true | |
| 6 | + $(".event_filter_link").bind "click", -> | |
| 7 | + toggleFilter $(this) | |
| 8 | + reloadActivities() | |
| 9 | + | |
| 10 | +reloadActivities = -> | |
| 11 | + $(".content_list").html '' | |
| 12 | + Pager.init 20, true | |
| 13 | + | |
| 14 | +toggleFilter = (sender) -> | |
| 15 | + sender.parent().toggleClass "inactive" | |
| 16 | + event_filters = $.cookie("event_filter") | |
| 17 | + filter = sender.attr("id").split("_")[0] | |
| 18 | + if event_filters | |
| 19 | + event_filters = event_filters.split(",") | |
| 20 | + else | |
| 21 | + event_filters = new Array() | |
| 22 | + | |
| 23 | + index = event_filters.indexOf(filter) | |
| 24 | + if index is -1 | |
| 25 | + event_filters.push filter | |
| 26 | + else | |
| 27 | + event_filters.splice index, 1 | |
| 28 | + | |
| 29 | + $.cookie "event_filter", event_filters.join(",") | ... | ... |