From 00663dc1bed13a586ed4555086463f51be38ed4e Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 23 Mar 2012 13:43:06 +0000 Subject: initial code to display user title if council is Bromley --- web/js/map-OpenLayers.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 272fd6c12..79740de78 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -440,6 +440,10 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { } $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); + if ( data.extra_name_info ) { + var lb = $('#form_name').prev(); + lb.before(data.extra_name_info); + } }); $('#side-form, #site-logo').show(); -- cgit v1.2.3 From ffd6301db1e3709fdb3072b6ee76355971ead603 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 26 Mar 2012 18:59:08 +0100 Subject: Adjust figures for when map might not be top left of page. --- web/js/map-OpenLayers.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 272fd6c12..aa2b2b2eb 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -236,7 +236,7 @@ $(function(){ if (fixmystreet.state_map && fixmystreet.state_map == 'full') { // TODO Work better with window resizing, this is pretty 'set up' only at present - var q = $(window).width() / 4; + var q = $('#map_box').width() / 4; // Need to try and fake the 'centre' being 75% from the left fixmystreet.map.pan(-q, -25, { animate: false }); fixmystreet.map.events.register("movestart", null, function(e){ @@ -459,7 +459,12 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { // If we clicked the map somewhere inconvenient var sidebar = $('#report-a-problem-sidebar'); if (sidebar.css('position') == 'absolute') { - var w = sidebar.width(), h = sidebar.height(), o = sidebar.offset(); + var w = sidebar.width(), h = sidebar.height(), + o = sidebar.offset(), + $map_box = $('#map_box'), bo = $map_box.offset(); + // e.xy is relative to top left of map, which might not be top left of page + e.xy.x += bo.left; + e.xy.y += bo.top; if (e.xy.y <= o.top || (e.xy.x >= o.left && e.xy.x <= o.left + w + 24 && e.xy.y >= o.top && e.xy.y <= o.top + h + 64)) { // top of the page, pin hidden by header; // or underneath where the new sidebar will appear @@ -468,7 +473,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); - p.x -= $(window).width() / 3; + p.x -= $map_box.width() / 3; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } -- cgit v1.2.3 From e79d5800688c548ad462208dcc38396f1827f3d9 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 29 Mar 2012 12:40:10 +0100 Subject: On map page, move overlay to left hand side of map (and adjust pans appropriately). --- web/js/map-OpenLayers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 5f60a4437..faa3d223e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -236,7 +236,8 @@ $(function(){ if (fixmystreet.state_map && fixmystreet.state_map == 'full') { // TODO Work better with window resizing, this is pretty 'set up' only at present - var q = $('#map_box').width() / 4; + var $content = $('.content'), + q = ( $content.offset().left + $content.width() ) / 2; // Need to try and fake the 'centre' being 75% from the left fixmystreet.map.pan(-q, -25, { animate: false }); fixmystreet.map.events.register("movestart", null, function(e){ @@ -477,7 +478,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); - p.x -= $map_box.width() / 3; + p.x -= ( o.left + w ) / 2; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } -- cgit v1.2.3 From f6729a1c1e78e0542e4eed2b73c401cec5210768 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 29 Mar 2012 12:53:39 +0100 Subject: Work better if map left isn't left of window. --- web/js/map-OpenLayers.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index faa3d223e..e4859b590 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -236,8 +236,9 @@ $(function(){ if (fixmystreet.state_map && fixmystreet.state_map == 'full') { // TODO Work better with window resizing, this is pretty 'set up' only at present - var $content = $('.content'), - q = ( $content.offset().left + $content.width() ) / 2; + var $content = $('.content'), mb = $('#map_box'), + q = ( $content.offset().left - mb.offset().left + $content.width() ) / 2; + if (q < 0) { q = 0; } // Need to try and fake the 'centre' being 75% from the left fixmystreet.map.pan(-q, -25, { animate: false }); fixmystreet.map.events.register("movestart", null, function(e){ @@ -478,7 +479,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); - p.x -= ( o.left + w ) / 2; + p.x -= ( o.left - bo.left + w ) / 2; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } -- cgit v1.2.3 From 32a74ddaf0f203ef9c9a28dc08c650c643e09de1 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 30 Mar 2012 12:44:59 +0100 Subject: add first name and last name boxes for bromley --- web/js/map-OpenLayers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index e4859b590..8ea54cac3 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -443,7 +443,8 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); if ( data.extra_name_info ) { - var lb = $('#form_name').prev(); + // there might be a first name field on some cobrands + var lb = $('#form_first_name').prev() || $('#form_name').prev(); lb.before(data.extra_name_info); } }); -- cgit v1.2.3 From c027d62d5d936c81a09d0585a614c21780c532fb Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Thu, 5 Apr 2012 12:05:48 +0100 Subject: remove merge code :( --- web/js/map-OpenLayers.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 9d8974fb6..8ea54cac3 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -480,11 +480,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); -<<<<<<< HEAD p.x -= ( o.left - bo.left + w ) / 2; -======= - p.x -= ( o.left + w ) / 2; ->>>>>>> send-report-rewrite lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } -- cgit v1.2.3 From 3d4bc5beebc8d9db495d41b93f9c858b4c92a7bd Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 17 Apr 2012 14:25:25 +0100 Subject: Work much better if reporting pin is clicked/dragged in/out of council boundary (CM17). --- web/js/map-OpenLayers.js | 51 ++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 8ea54cac3..a92d02c84 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -7,6 +7,32 @@ function fixmystreet_update_pin(lonlat) { ); document.getElementById('fixmystreet.latitude').value = lonlat.lat || lonlat.y; document.getElementById('fixmystreet.longitude').value = lonlat.lon || lonlat.x; + + $.getJSON('/report/new/ajax', { + latitude: $('#fixmystreet\\.latitude').val(), + longitude: $('#fixmystreet\\.longitude').val() + }, function(data) { + if (data.error) { + if (!$('#side-form-error').length) { + $('
').insertAfter($('#side-form')); + } + $('#side-form-error').html('

Reporting a problem

' + data.error + '

').show(); + $('#side-form').hide(); + return; + } + $('#side-form, #site-logo').show(); + $('#councils_text').html(data.councils_text); + $('#form_category_row').html(data.category); + if ( data.extra_name_info ) { + // there might be a first name field on some cobrands + var lb = $('#form_first_name').prev() || $('#form_name').prev(); + lb.before(data.extra_name_info); + } + }); + + if (!$('#side-form-error').is(':visible')) { + $('#side-form, #site-logo').show(); + } } function fixmystreet_activate_drag() { @@ -420,7 +446,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.markers.addFeatures( markers ); fixmystreet_activate_drag(); } - fixmystreet_update_pin(lonlat); + // check to see if markers are visible. We click the // link so that it updates the text in case they go // back @@ -428,28 +454,15 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.state_pins_were_hidden = true; $('#hide_pins_link').click(); } + + // Store pin location in form fields, and check coverage of point + fixmystreet_update_pin(lonlat); + + // Already did this first time map was clicked, so no need to do it again. if (fixmystreet.page == 'new') { return; } - $.getJSON('/report/new/ajax', { - latitude: $('#fixmystreet\\.latitude').val(), - longitude: $('#fixmystreet\\.longitude').val() - }, function(data) { - if (data.error) { - // XXX If they then click back and click somewhere in the area, this error will still show. - $('#side-form').html('

Reporting a problem

' + data.error + '

'); - return; - } - $('#councils_text').html(data.councils_text); - $('#form_category_row').html(data.category); - if ( data.extra_name_info ) { - // there might be a first name field on some cobrands - var lb = $('#form_first_name').prev() || $('#form_name').prev(); - lb.before(data.extra_name_info); - } - }); - $('#side-form, #site-logo').show(); fixmystreet.map.updateSize(); // might have done, and otherwise Firefox gets confused. /* For some reason on IOS5 if you use the jQuery show method it * doesn't display the JS validation error messages unless you do this -- cgit v1.2.3 From 339ed277ad480116c0a64300b2a55b28bc326310 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 24 Apr 2012 10:04:05 +0100 Subject: Text changes from Bromley, fix bug where multiple Title fields would appear if pin moved. --- web/js/map-OpenLayers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index a92d02c84..ac8a7819e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -23,7 +23,7 @@ function fixmystreet_update_pin(lonlat) { $('#side-form, #site-logo').show(); $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); - if ( data.extra_name_info ) { + if ( data.extra_name_info && !$('#form_fms_extra_title').length ) { // there might be a first name field on some cobrands var lb = $('#form_first_name').prev() || $('#form_name').prev(); lb.before(data.extra_name_info); -- cgit v1.2.3 From f16a8d2fd144c049e0435fd6e943ee53ed05ad22 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 1 May 2012 19:36:46 +0100 Subject: display title dropdown for bromley users on main site problem page --- web/js/map-OpenLayers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index ac8a7819e..f11ae3ed9 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -25,7 +25,8 @@ function fixmystreet_update_pin(lonlat) { $('#form_category_row').html(data.category); if ( data.extra_name_info && !$('#form_fms_extra_title').length ) { // there might be a first name field on some cobrands - var lb = $('#form_first_name').prev() || $('#form_name').prev(); + var lb = $('#form_first_name').prev(); + if ( lb.length == 0 ) { lb = $('#form_name').prev(); } lb.before(data.extra_name_info); } }); -- cgit v1.2.3 From 88efd2d6415d9d95c0f428ee29da1a637e92bbd1 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 14 May 2012 17:08:35 +0100 Subject: Have a minimum zoom on mobile version. --- web/js/map-OpenLayers.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index f11ae3ed9..7ffdc7f34 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -83,7 +83,10 @@ function fixmystreet_onload() { var bounds = area.getDataExtent(); if (bounds) { var center = bounds.getCenterLonLat(); - fixmystreet.map.setCenter(center, fixmystreet.map.getZoomForExtent(bounds), false, true); + var z = fixmystreet.map.getZoomForExtent(bounds); + if ( z >= 13 || !$('html').hasClass('mobile') ) { + fixmystreet.map.setCenter(center, z, false, true); + } } }); } @@ -178,7 +181,12 @@ function fixmystreet_onload() { if ( fixmystreet.zoomToBounds ) { var bounds = fixmystreet.markers.getDataExtent(); - if (bounds) { fixmystreet.map.zoomToExtent( bounds ); } + if (bounds) { + var z = fixmystreet.map.getZoomForExtent(bounds); + if ( z >= 13 || !$('html').hasClass('mobile') ) { + fixmystreet.map.zoomToExtent( bounds ); + } + } } $('#hide_pins_link').click(function(e) { -- cgit v1.2.3 From 2087ef326b3d031a5b54f61a400919bda41f28bb Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 14 May 2012 17:20:29 +0100 Subject: Actually, just initially make sure zoom is at least 13. --- web/js/map-OpenLayers.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 7ffdc7f34..054a67767 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -84,9 +84,10 @@ function fixmystreet_onload() { if (bounds) { var center = bounds.getCenterLonLat(); var z = fixmystreet.map.getZoomForExtent(bounds); - if ( z >= 13 || !$('html').hasClass('mobile') ) { - fixmystreet.map.setCenter(center, z, false, true); + if ( z < 13 && $('html').hasClass('mobile') ) { + z = 13; } + fixmystreet.map.setCenter(center, z, false, true); } }); } @@ -182,10 +183,12 @@ function fixmystreet_onload() { if ( fixmystreet.zoomToBounds ) { var bounds = fixmystreet.markers.getDataExtent(); if (bounds) { + var center = bounds.getCenterLonLat(); var z = fixmystreet.map.getZoomForExtent(bounds); - if ( z >= 13 || !$('html').hasClass('mobile') ) { - fixmystreet.map.zoomToExtent( bounds ); + if ( z < 13 && $('html').hasClass('mobile') ) { + z = 13; } + fixmystreet.map.setCenter(center, z); } } -- cgit v1.2.3 From 3b0e39a4c89e4c184f30c6131936dc63845d6a1f Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 23 May 2012 12:49:59 +0100 Subject: Don't want this to happen if zoom is actually 0. --- web/js/map-OpenLayers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 7ddaae299..d73e2bfc8 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -246,7 +246,7 @@ $(function(){ fixmystreet.map.moveStart = { zoom: this.getZoom(), center: this.getCenter() }; }); fixmystreet.map.events.register("zoomend", null, function(e){ - if ( fixmystreet.map.moveStart && !fixmystreet.map.moveStart.zoom ) { + if ( fixmystreet.map.moveStart && !fixmystreet.map.moveStart.zoom && fixmystreet.map.moveStart.zoom !== 0 ) { return true; // getZoom() on Firefox appears to return null at first? } if ( !fixmystreet.map.moveStart || !this.getCenter().equals(fixmystreet.map.moveStart.center) ) { -- cgit v1.2.3