Merge branch 'master' into markercluster
Conflicts: src/view.map.js
This commit is contained in:
9
dist/recline.dataset.js
vendored
9
dist/recline.dataset.js
vendored
@@ -727,20 +727,23 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
this._applyFreeTextQuery = function(results, queryObj) {
|
this._applyFreeTextQuery = function(results, queryObj) {
|
||||||
if (queryObj.q) {
|
if (queryObj.q) {
|
||||||
var terms = queryObj.q.split(' ');
|
var terms = queryObj.q.split(' ');
|
||||||
|
var patterns=_.map(terms, function(term) {
|
||||||
|
return new RegExp(term.toLowerCase());;
|
||||||
|
});
|
||||||
results = _.filter(results, function(rawdoc) {
|
results = _.filter(results, function(rawdoc) {
|
||||||
var matches = true;
|
var matches = true;
|
||||||
_.each(terms, function(term) {
|
_.each(patterns, function(pattern) {
|
||||||
var foundmatch = false;
|
var foundmatch = false;
|
||||||
_.each(self.fields, function(field) {
|
_.each(self.fields, function(field) {
|
||||||
var value = rawdoc[field.id];
|
var value = rawdoc[field.id];
|
||||||
if (value !== null) {
|
if ((value !== null) && (value !== undefined)) {
|
||||||
value = value.toString();
|
value = value.toString();
|
||||||
} else {
|
} else {
|
||||||
// value can be null (apparently in some cases)
|
// value can be null (apparently in some cases)
|
||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
// TODO regexes?
|
// TODO regexes?
|
||||||
foundmatch = foundmatch || (value.toLowerCase() === term.toLowerCase());
|
foundmatch = foundmatch || (pattern.test(value.toLowerCase()));
|
||||||
// TODO: early out (once we are true should break to spare unnecessary testing)
|
// TODO: early out (once we are true should break to spare unnecessary testing)
|
||||||
// if (foundmatch) return true;
|
// if (foundmatch) return true;
|
||||||
});
|
});
|
||||||
|
|||||||
18
dist/recline.js
vendored
18
dist/recline.js
vendored
@@ -1032,20 +1032,23 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
this._applyFreeTextQuery = function(results, queryObj) {
|
this._applyFreeTextQuery = function(results, queryObj) {
|
||||||
if (queryObj.q) {
|
if (queryObj.q) {
|
||||||
var terms = queryObj.q.split(' ');
|
var terms = queryObj.q.split(' ');
|
||||||
|
var patterns=_.map(terms, function(term) {
|
||||||
|
return new RegExp(term.toLowerCase());;
|
||||||
|
});
|
||||||
results = _.filter(results, function(rawdoc) {
|
results = _.filter(results, function(rawdoc) {
|
||||||
var matches = true;
|
var matches = true;
|
||||||
_.each(terms, function(term) {
|
_.each(patterns, function(pattern) {
|
||||||
var foundmatch = false;
|
var foundmatch = false;
|
||||||
_.each(self.fields, function(field) {
|
_.each(self.fields, function(field) {
|
||||||
var value = rawdoc[field.id];
|
var value = rawdoc[field.id];
|
||||||
if (value !== null) {
|
if ((value !== null) && (value !== undefined)) {
|
||||||
value = value.toString();
|
value = value.toString();
|
||||||
} else {
|
} else {
|
||||||
// value can be null (apparently in some cases)
|
// value can be null (apparently in some cases)
|
||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
// TODO regexes?
|
// TODO regexes?
|
||||||
foundmatch = foundmatch || (value.toLowerCase() === term.toLowerCase());
|
foundmatch = foundmatch || (pattern.test(value.toLowerCase()));
|
||||||
// TODO: early out (once we are true should break to spare unnecessary testing)
|
// TODO: early out (once we are true should break to spare unnecessary testing)
|
||||||
// if (foundmatch) return true;
|
// if (foundmatch) return true;
|
||||||
});
|
});
|
||||||
@@ -2696,9 +2699,6 @@ my.Map = Backbone.View.extend({
|
|||||||
try {
|
try {
|
||||||
self.features.addData(feature);
|
self.features.addData(feature);
|
||||||
|
|
||||||
if (feature.properties && feature.properties.popupContent) {
|
|
||||||
self.features.bindPopup(feature.properties.popupContent);
|
|
||||||
}
|
|
||||||
} catch (except) {
|
} catch (except) {
|
||||||
wrongSoFar += 1;
|
wrongSoFar += 1;
|
||||||
var msg = 'Wrong geometry value';
|
var msg = 'Wrong geometry value';
|
||||||
@@ -2846,7 +2846,11 @@ my.Map = Backbone.View.extend({
|
|||||||
var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution ,subdomains: '1234'});
|
var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution ,subdomains: '1234'});
|
||||||
this.map.addLayer(bg);
|
this.map.addLayer(bg);
|
||||||
|
|
||||||
this.features = new L.GeoJSON();
|
this.features = new L.GeoJSON(null,
|
||||||
|
{onEachFeature: function(feature,layer) {
|
||||||
|
layer.bindPopup(feature.properties.popupContent);
|
||||||
|
}
|
||||||
|
});
|
||||||
this.map.addLayer(this.features);
|
this.map.addLayer(this.features);
|
||||||
|
|
||||||
this.map.setView([0, 0], 2);
|
this.map.setView([0, 0], 2);
|
||||||
|
|||||||
@@ -142,20 +142,23 @@ this.recline.Backend.Memory = this.recline.Backend.Memory || {};
|
|||||||
this._applyFreeTextQuery = function(results, queryObj) {
|
this._applyFreeTextQuery = function(results, queryObj) {
|
||||||
if (queryObj.q) {
|
if (queryObj.q) {
|
||||||
var terms = queryObj.q.split(' ');
|
var terms = queryObj.q.split(' ');
|
||||||
|
var patterns=_.map(terms, function(term) {
|
||||||
|
return new RegExp(term.toLowerCase());;
|
||||||
|
});
|
||||||
results = _.filter(results, function(rawdoc) {
|
results = _.filter(results, function(rawdoc) {
|
||||||
var matches = true;
|
var matches = true;
|
||||||
_.each(terms, function(term) {
|
_.each(patterns, function(pattern) {
|
||||||
var foundmatch = false;
|
var foundmatch = false;
|
||||||
_.each(self.fields, function(field) {
|
_.each(self.fields, function(field) {
|
||||||
var value = rawdoc[field.id];
|
var value = rawdoc[field.id];
|
||||||
if (value !== null) {
|
if ((value !== null) && (value !== undefined)) {
|
||||||
value = value.toString();
|
value = value.toString();
|
||||||
} else {
|
} else {
|
||||||
// value can be null (apparently in some cases)
|
// value can be null (apparently in some cases)
|
||||||
value = '';
|
value = '';
|
||||||
}
|
}
|
||||||
// TODO regexes?
|
// TODO regexes?
|
||||||
foundmatch = foundmatch || (value.toLowerCase() === term.toLowerCase());
|
foundmatch = foundmatch || (pattern.test(value.toLowerCase()));
|
||||||
// TODO: early out (once we are true should break to spare unnecessary testing)
|
// TODO: early out (once we are true should break to spare unnecessary testing)
|
||||||
// if (foundmatch) return true;
|
// if (foundmatch) return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -403,7 +403,8 @@ my.Map = Backbone.View.extend({
|
|||||||
|
|
||||||
var mapUrl = "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png";
|
var mapUrl = "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png";
|
||||||
var osmAttribution = 'Map data © 2011 OpenStreetMap contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">';
|
var osmAttribution = 'Map data © 2011 OpenStreetMap contributors, Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">';
|
||||||
var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution ,subdomains: '1234'}).addTo(this.map);
|
var bg = new L.TileLayer(mapUrl, {maxZoom: 18, attribution: osmAttribution ,subdomains: '1234'});
|
||||||
|
this.map.addLayer(bg);
|
||||||
|
|
||||||
this.markers = new L.MarkerClusterGroup(this._clusterOptions);
|
this.markers = new L.MarkerClusterGroup(this._clusterOptions);
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ test('query string', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
data.query({q: 'UK 6'}).then(function(out) {
|
data.query({q: 'UK 6'}).then(function(out) {
|
||||||
equal(out.total, 1);
|
equal(out.total, 2); // the new regex support will find 2 hits
|
||||||
deepEqual(out.hits[0].id, 1);
|
deepEqual(out.hits[0].id, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -234,7 +234,7 @@ test('query string', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
dataset.query({q: 'UK 6'}).then(function() {
|
dataset.query({q: 'UK 6'}).then(function() {
|
||||||
equal(dataset.records.length, 1);
|
equal(dataset.records.length, 2);
|
||||||
deepEqual(dataset.records.models[0].id, 1);
|
deepEqual(dataset.records.models[0].id, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ test('Popup - Custom', function () {
|
|||||||
assertPresent(popup);
|
assertPresent(popup);
|
||||||
|
|
||||||
var text = popup.html();
|
var text = popup.html();
|
||||||
ok((text.indexOf('<h3>3</h3>y: 6') != -1))
|
ok((text.indexOf('<h3>1</h3>y: 2') != -1))
|
||||||
|
|
||||||
view.remove();
|
view.remove();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user