dashboard js -> coffee
This commit is contained in:
parent
3cc0458312
commit
5133fe8efb
2 changed files with 29 additions and 40 deletions
|
@ -1,40 +0,0 @@
|
||||||
/**
|
|
||||||
* Init dashboard page
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
$(function(){
|
|
||||||
Pager.init(20, true);
|
|
||||||
dashboardPage();
|
|
||||||
});
|
|
||||||
|
|
||||||
function dashboardPage(){
|
|
||||||
$(".event_filter_link").bind('click',(function(){
|
|
||||||
toggleFilter($(this));
|
|
||||||
reloadActivities();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
function reloadActivities(){
|
|
||||||
$('.content_list').html('');
|
|
||||||
Pager.init(20, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleFilter(sender){
|
|
||||||
sender.parent().toggleClass('inactive');
|
|
||||||
var event_filters = $.cookie('event_filter');
|
|
||||||
var filter = sender.attr('id').split('_')[0];
|
|
||||||
if (!event_filters) {
|
|
||||||
event_filters = new Array();
|
|
||||||
} else {
|
|
||||||
event_filters = event_filters.split(',');
|
|
||||||
}
|
|
||||||
var index = event_filters.indexOf(filter);
|
|
||||||
if (index == -1) {
|
|
||||||
event_filters.push(filter);
|
|
||||||
} else {
|
|
||||||
event_filters.splice(index, 1);
|
|
||||||
}
|
|
||||||
$.cookie('event_filter', event_filters.join(','));
|
|
||||||
};
|
|
||||||
|
|
29
app/assets/javascripts/dashboard.js.coffee
Normal file
29
app/assets/javascripts/dashboard.js.coffee
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
$ ->
|
||||||
|
dashboardPage()
|
||||||
|
|
||||||
|
dashboardPage = ->
|
||||||
|
Pager.init 20, true
|
||||||
|
$(".event_filter_link").bind "click", ->
|
||||||
|
toggleFilter $(this)
|
||||||
|
reloadActivities()
|
||||||
|
|
||||||
|
reloadActivities = ->
|
||||||
|
$(".content_list").html ''
|
||||||
|
Pager.init 20, true
|
||||||
|
|
||||||
|
toggleFilter = (sender) ->
|
||||||
|
sender.parent().toggleClass "inactive"
|
||||||
|
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(",")
|
Loading…
Reference in a new issue