mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Chain chain
This commit is contained in:
parent
7bf461d097
commit
b606226d99
2 changed files with 15 additions and 4 deletions
|
|
@ -20,8 +20,7 @@ $.getJSON('/articles/')
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log('Got data successfully!')
|
console.log('Got data successfully!')
|
||||||
visualization = new Visualization(map, response, colors)
|
visualization = new Visualization(map, response, colors)
|
||||||
|
.setupCategoryFilter('.category-filter')
|
||||||
visualization.displayMarkers()
|
.setupYearFilter('.year-filter')
|
||||||
visualization.setupCategoryFilter('.category-filter')
|
.displayMarkers()
|
||||||
visualization.setupYearFilter('.year-filter')
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ class Visualization {
|
||||||
/**
|
/**
|
||||||
* Clear the map and render new markers
|
* Clear the map and render new markers
|
||||||
* @param {Array[Object]} incidents The incidents to be shown
|
* @param {Array[Object]} incidents The incidents to be shown
|
||||||
|
* @return {Visualization}
|
||||||
|
* @chainable
|
||||||
*/
|
*/
|
||||||
displayMarkers (incidents) {
|
displayMarkers (incidents) {
|
||||||
if (incidents == null)
|
if (incidents == null)
|
||||||
|
|
@ -36,6 +38,8 @@ class Visualization {
|
||||||
this._createMarker(incident).bindPopup(incident.description)
|
this._createMarker(incident).bindPopup(incident.description)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,6 +61,8 @@ class Visualization {
|
||||||
* Sets up the category filter
|
* Sets up the category filter
|
||||||
* @param {jQuery.Selector} selector The container holding the LIs
|
* @param {jQuery.Selector} selector The container holding the LIs
|
||||||
* representing the different categories
|
* representing the different categories
|
||||||
|
* @return {Visualization}
|
||||||
|
* @chainable
|
||||||
*/
|
*/
|
||||||
setupCategoryFilter (selector) {
|
setupCategoryFilter (selector) {
|
||||||
this._$categoryList = $(selector)
|
this._$categoryList = $(selector)
|
||||||
|
|
@ -72,11 +78,15 @@ class Visualization {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
* @return {Visualization}
|
||||||
|
* @chainable
|
||||||
*/
|
*/
|
||||||
setupYearFilter (selector) {
|
setupYearFilter (selector) {
|
||||||
var fragment = document.createDocumentFragment()
|
var fragment = document.createDocumentFragment()
|
||||||
|
|
@ -113,6 +123,8 @@ class Visualization {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue