aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2014-03-17 17:34:13 +0000
committerStruan Donald <struan@exo.org.uk>2014-03-25 13:13:30 +0000
commit87f54caa2618bbf873ac87b5b7bca04f7969d603 (patch)
treebebb27506a99e63529d213ad683672b8623c224d
parent4db84e2b69378d6e26daa6ba460437d2e2c0d498 (diff)
Allow cobrands to set their own path to pin files
New cobrand function of pin_path that sets the path to where the image files for pins are located. Defaults to /i This still means they need to use the same file names but they can at least put those in a cobrand directory rather than having to overwrite the files in /i or fudge it with pin_colour
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm14
-rw-r--r--templates/web/default/maps/openlayers.html3
-rw-r--r--web/js/fixmystreet.js6
-rw-r--r--web/js/map-OpenLayers.js8
5 files changed, 25 insertions, 8 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 24dececac..081256fe2 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -199,7 +199,7 @@ sub generate_map_tags : Private {
? [ {
latitude => $problem->latitude,
longitude => $problem->longitude,
- colour => $c->cobrand->moniker eq 'zurich'? $c->cobrand->pin_colour($problem) : 'yellow',
+ colour => $c->cobrand->pin_colour($problem, 'report'),
type => 'big',
} ]
: [],
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 832a6bb5c..2de3eae5f 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -731,10 +731,22 @@ Returns the colour of pin to be used for a particular report
sub pin_colour {
my ( $self, $p, $context ) = @_;
#return 'green' if time() - $p->confirmed->epoch < 7 * 24 * 60 * 60;
- return 'yellow' if $context eq 'around' || $context eq 'reports';
+ return 'yellow' if $context eq 'around' || $context eq 'reports' || $context eq 'report';
return $p->is_fixed ? 'green' : 'red';
}
+=head2 path_to_pin_icons
+
+Used to override the path for the pin icons if you want to add custom pin icons
+for your cobrand.
+
+=cut
+
+sub path_to_pin_icons {
+ return '/i/';
+}
+
+
=head2 tweak_all_reports_map
Used to tweak the display settings of the map on the all reports pages.
diff --git a/templates/web/default/maps/openlayers.html b/templates/web/default/maps/openlayers.html
index 1ac32a717..7967d4480 100644
--- a/templates/web/default/maps/openlayers.html
+++ b/templates/web/default/maps/openlayers.html
@@ -18,6 +18,7 @@ var fixmystreet = {
[% IF map.zoom -%]
'zoom': [% map.zoom %],
[%- END %]
+ 'pin_prefix': '[% c.cobrand.path_to_pin_icons %]',
'numZoomLevels': [% map.numZoomLevels %],
'zoomOffset': [% map.zoomOffset %],
'map_type': [% map.map_type %],
@@ -81,7 +82,7 @@ var fixmystreet = {
[% IF pin.id %]
<a title="[% pin.title | html %]" href="[% c.uri_for('/report/' _ pin.id) %]">
[%- END -%]
-<img border="0" class="pin" src="[% c.uri_for('/i/pin-' _ pin.colour _ '.png') %]"
+<img border="0" class="pin" src="[% c.uri_for( c.cobrand.path_to_pin_icons _ 'pin-' _ pin.colour _ '.png') %]"
alt="[% loc('Problem') %]" style="top:[% pin.py - 64 %]px; left:[% pin.px - 24 %]px; position: absolute;">
[%- IF pin.id -%]
</a>
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index 838351e8b..7d75c8b65 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -17,7 +17,11 @@ $(function(){
$html.removeClass('no-js').addClass('js');
// Preload the new report pin
- document.createElement('img').src = '/i/pin-green.png';
+ if ( typeof fixmystreet !== 'undefined' && typeof fixmystreet.pin_prefix !== 'undefined' ) {
+ document.createElement('img').src = fixmystreet.pin_prefix + 'pin-green.png';
+ } else {
+ document.createElement('img').src = '/i/pin-green.png';
+ }
// Focus on postcode box on front page
$('#pc').focus();
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index f7a46ee68..49f4257eb 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -122,24 +122,24 @@ function fixmystreet_onload() {
});
pin_layer_style_map.addUniqueValueRules('default', 'size', {
'normal': {
- externalGraphic: "/i/pin-${colour}.png",
+ externalGraphic: fixmystreet.pin_prefix + "pin-${colour}.png",
graphicWidth: 48,
graphicHeight: 64,
graphicXOffset: -24,
graphicYOffset: -64,
- backgroundGraphic: "/i/pin-shadow.png",
+ backgroundGraphic: fixmystreet.pin_prefix + "pin-shadow.png",
backgroundWidth: 60,
backgroundHeight: 30,
backgroundXOffset: -7,
backgroundYOffset: -30
},
'big': {
- externalGraphic: "/i/pin-${colour}-big.png",
+ externalGraphic: fixmystreet.pin_prefix + "pin-${colour}-big.png",
graphicWidth: 78,
graphicHeight: 105,
graphicXOffset: -39,
graphicYOffset: -105,
- backgroundGraphic: "/i/pin-shadow-big.png",
+ backgroundGraphic: fixmystreet.pin_prefix + "pin-shadow-big.png",
backgroundWidth: 88,
backgroundHeight: 40,
backgroundXOffset: -10,