Browse Source

Merge branch 'feature/home-click' into develop

* feature/home-click:
  Handle clicks on zones and pois in the home search
tags/0.3.6^2
Bèr Kessels 1 month ago
parent
commit
9747aef27e
2 changed files with 13 additions and 0 deletions
  1. 12
    0
      app/assets/javascripts/application.js
  2. 1
    0
      app/views/home.erb

+ 12
- 0
app/assets/javascripts/application.js View File

@@ -14,6 +14,18 @@ var bragi = function(q, callback, base_url) {
r.send(q);
};

var handleHorseyInsert = function(info) {
var clickedItem = info.selection;
if (clickedItem.type == "poi") {
window.location.href = '/places/' + clickedItem.id;
} else if (clickedItem.type == "zone") {
var cityName = clickedItem.label.split(',')[0];
if (cityName) {
window.location.href = '/in/' + cityName.toLowerCase();
}
}
};

var sourceEntry = function(feature) {
var attrs = (feature.properties.geocoding || {});


+ 1
- 0
app/views/home.erb View File

@@ -3,6 +3,7 @@ js = "horsey(document.getElementById('search-input'), {
source (data, done) { bragi(data.input, done, '#{bragi_url}'); },
getText: 'label',
getValue: 'id',
predictNextSearch(info) { handleHorseyInsert(info) },
renderItem: function(li, suggestion) {
var image = `<img class=\"inline-icon\" src=\"/images/${suggestion.type}.svg\" alt=\"${suggestion.type} icon\">`;
var type = `<small>${suggestion.poi_types.join(',')}</small>`;

Loading…
Cancel
Save