aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-10-21 11:01:20 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-10-21 11:01:20 +0100
commit32690f423f65ab281cb9ec8122b3977140b40984 (patch)
treed09586bc004d051be660c1709c497a8f025efd53 /web/js
parentc51d8e6b5ed134521dbdd376271481029b605aaf (diff)
parent3a2b49ebcb8c65d73108930f421142f2536cb893 (diff)
Merge branch '1543-reports-page-fixes'
Diffstat (limited to 'web/js')
-rw-r--r--web/js/map-OpenLayers.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 7d264860f..43a0aadbb 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -272,6 +272,9 @@ var fixmystreet = fixmystreet || {};
function parse_query_string() {
var qs = {};
+ if (!location.search) {
+ return qs;
+ }
location.search.substring(1).split('&').forEach(function(i) {
var s = i.split('='),
k = s[0],
@@ -294,7 +297,15 @@ var fixmystreet = fixmystreet || {};
var qs = parse_query_string();
var filter_categories = replace_query_parameter(qs, 'filter_categories', 'filter_category');
var filter_statuses = replace_query_parameter(qs, 'statuses', 'status');
- var new_url = location.href.replace(location.search, '?' + $.param(qs));
+ delete qs['p'];
+ var new_url;
+ if ($.isEmptyObject(qs)) {
+ new_url = location.href.replace(location.search, "");
+ } else if (location.search) {
+ new_url = location.href.replace(location.search, '?' + $.param(qs));
+ } else {
+ new_url = location.href + '?' + $.param(qs);
+ }
history.pushState({
filter_change: { 'filter_categories': filter_categories, 'statuses': filter_statuses }
}, null, new_url);
@@ -421,6 +432,13 @@ var fixmystreet = fixmystreet || {};
format: new OpenLayers.Format.FixMyStreet()
});
}
+ if (fixmystreet.page == 'reports' || fixmystreet.page == 'my') {
+ pin_layer_options.strategies = [ new OpenLayers.Strategy.FixMyStreetFixed() ];
+ pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({
+ url: '?ajax=1',
+ format: new OpenLayers.Format.FixMyStreet()
+ });
+ }
fixmystreet.markers = new OpenLayers.Layer.Vector("Pins", pin_layer_options);
fixmystreet.markers.events.register( 'loadend', fixmystreet.markers, function(evt) {
if (fixmystreet.map.popups.length) {
@@ -714,6 +732,20 @@ OpenLayers.Strategy.FixMyStreet = OpenLayers.Class(OpenLayers.Strategy.BBOX, {
}
});
+/* Copy of Strategy.Fixed, but with no initial load */
+OpenLayers.Strategy.FixMyStreetFixed = OpenLayers.Class(OpenLayers.Strategy.Fixed, {
+ activate: function() {
+ var activated = OpenLayers.Strategy.prototype.activate.apply(this, arguments);
+ if (activated) {
+ this.layer.events.on({
+ "refresh": this.load,
+ scope: this
+ });
+ }
+ return activated;
+ }
+});
+
/* Pan data request handler */
// This class is used to get a JSON object from /ajax that contains
// pins for the map and HTML for the sidebar. It does a fetch whenever the map
@@ -761,6 +793,13 @@ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, {
if (typeof(obj.current) != 'undefined' && (current = document.getElementById('current'))) {
current.innerHTML = obj.current;
}
+ var reports_list;
+ if (typeof(obj.reports_list) != 'undefined' && (reports_list = document.getElementById('js-reports-list'))) {
+ reports_list.innerHTML = obj.reports_list;
+ }
+ if (typeof(obj.pagination) != 'undefined') {
+ $('.js-pagination').html(obj.pagination);
+ }
return fixmystreet.maps.markers_list( obj.pins, false );
},
CLASS_NAME: "OpenLayers.Format.FixMyStreet"