mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Fix filter logic
This commit is contained in:
parent
c6e9f5231c
commit
06b2dd9e47
1 changed files with 18 additions and 5 deletions
|
|
@ -66,8 +66,7 @@ class Visualization {
|
||||||
this._$categoryList.on('click', 'a', e => {
|
this._$categoryList.on('click', 'a', e => {
|
||||||
$(e.target).parent().toggleClass('active')
|
$(e.target).parent().toggleClass('active')
|
||||||
|
|
||||||
var categories = this.getActiveCategories()
|
var incidents = this.filterAll()
|
||||||
var incidents = filter.byCategories(this.data, categories)
|
|
||||||
this.displayMarkers(incidents)
|
this.displayMarkers(incidents)
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
@ -78,6 +77,14 @@ class Visualization {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get currently active year
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
getCurrentYear () {
|
||||||
|
return this._$yearList.children('.active').find('a').data().showYear
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the year list which optionally already holds a button for "all"
|
* Creates the year list which optionally already holds a button for "all"
|
||||||
* @param {jQuery.Selector} selector The container holding
|
* @param {jQuery.Selector} selector The container holding
|
||||||
|
|
@ -110,9 +117,7 @@ class Visualization {
|
||||||
$target.parent().siblings().removeClass('active')
|
$target.parent().siblings().removeClass('active')
|
||||||
$target.parent().addClass('active')
|
$target.parent().addClass('active')
|
||||||
|
|
||||||
var year = $target.data().showYear
|
var incidents = this.filterAll()
|
||||||
var incidents = (year) ? filter.byYear(this.data, year) : this.data
|
|
||||||
|
|
||||||
this.displayMarkers(incidents)
|
this.displayMarkers(incidents)
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
@ -123,6 +128,14 @@ class Visualization {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterAll () {
|
||||||
|
var year = this.getCurrentYear()
|
||||||
|
var categories = this.getActiveCategories()
|
||||||
|
|
||||||
|
var byYear = (year) ? filter.byYear(this.data, year) : this.data
|
||||||
|
return filter.byCategories(byYear, categories)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up all markers for the first time so afterwards they only need to be
|
* Sets up all markers for the first time so afterwards they only need to be
|
||||||
* faded in and out
|
* faded in and out
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue