[search] allow title and description to be HTML, DOM elements or jQuery objects

This commit is contained in:
fkloft 2015-02-14 14:48:14 +01:00
parent c450aa63f8
commit f9db2c3861

View File

@ -12,8 +12,8 @@ addHook('search', function(query) {});
- `addResult(result)` can be called to add a result to the query. - `addResult(result)` can be called to add a result to the query.
`result` may have the following members (`title` is required, as well as one of `position` and `bounds`): `result` may have the following members (`title` is required, as well as one of `position` and `bounds`):
- `title`: the label for this result - `title`: the label for this result. Will be interpreted as HTML, so make sure to escape properly.
- `description`: secondary information for this result - `description`: secondary information for this result. Will be interpreted as HTML, so make sure to escape properly.
- `position`: a L.LatLng object describing the position of this result - `position`: a L.LatLng object describing the position of this result
- `bounds`: a L.LatLngBounds object describing the bounds of this result - `bounds`: a L.LatLngBounds object describing the bounds of this result
- `layer`: a ILayer to be added to the map when the user selects this search result. Will be generated if not set. - `layer`: a ILayer to be added to the map when the user selects this search result. Will be generated if not set.
@ -95,7 +95,7 @@ window.search.Query.prototype.addResult = function(result) {
}); });
var link = $('<a>') var link = $('<a>')
.text(result.title) .append(result.title)
.appendTo(item); .appendTo(item);
if(result.icon) { if(result.icon) {
@ -107,7 +107,7 @@ window.search.Query.prototype.addResult = function(result) {
item item
.append($('<br>')) .append($('<br>'))
.append($('<em>') .append($('<em>')
.text(result.description)); .append(result.description));
} }
}; };
@ -253,6 +253,7 @@ addHook('search', function(query) {
}); });
// TODO: recognize 50°31'03.8"N 7°59'05.3"E and similar formats // TODO: recognize 50°31'03.8"N 7°59'05.3"E and similar formats
// TODO: if a portal with these exact coordinates is found, select it
addHook('search', function(query) { addHook('search', function(query) {
if(query.term.split(',').length == 2) { if(query.term.split(',').length == 2) {
var ll = query.term.split(','); var ll = query.term.split(',');