aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm16
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm4
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm8
-rw-r--r--templates/web/base/front/international_banner.html0
-rw-r--r--templates/web/fixmystreet.com/front/international_banner.html11
-rw-r--r--web/cobrands/fixmystreet.com/js.js26
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js19
7 files changed, 26 insertions, 58 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index 6def423ce..c457c8fce 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -134,22 +134,6 @@ sub check_location : Private {
return 1;
}
-=head2 country_message
-
-Displays the country_message template, used for displaying a message to
-people using the site from outside the host country.
-
-=cut
-
-sub country_message : Path('/country_message') : Args(0) {
- my ( $self, $c ) = @_;
-
- # we do not want to cache this as we always want to check if displaying this
- # is the right thing to do.
- $c->res->header( 'Cache_Control' => 'max-age=0' );
- $c->stash->{template} = 'front/international_banner.html';
-}
-
# Utility function for if someone (rarely) enters a grid reference
sub gridref_to_latlon {
my ( $a, $b, $num ) = @_;
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index b3b830f06..c76ee0f7d 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -936,10 +936,6 @@ sub updates_as_hashref {
return {};
}
-sub get_country_for_ip_address {
- return 0;
-}
-
sub jurisdiction_id_example {
my $self = shift;
return $self->moniker;
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 159f2f5db..99fe6da15 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -1,6 +1,5 @@
package FixMyStreet::Cobrand::FixMyStreet;
use base 'FixMyStreet::Cobrand::UK';
-use mySociety::Gaze;
use constant COUNCIL_ID_BROMLEY => 2482;
@@ -52,13 +51,6 @@ sub extra_contact_validation {
return %errors;
}
-sub get_country_for_ip_address {
- my $self = shift;
- my $ip = shift;
-
- return mySociety::Gaze::get_country_from_ip($ip);
-}
-
sub report_form_extras {
( { name => 'gender', required => 0 }, { name => 'variant', required => 0 } )
}
diff --git a/templates/web/base/front/international_banner.html b/templates/web/base/front/international_banner.html
deleted file mode 100644
index e69de29bb..000000000
--- a/templates/web/base/front/international_banner.html
+++ /dev/null
diff --git a/templates/web/fixmystreet.com/front/international_banner.html b/templates/web/fixmystreet.com/front/international_banner.html
deleted file mode 100644
index 303d52851..000000000
--- a/templates/web/fixmystreet.com/front/international_banner.html
+++ /dev/null
@@ -1,11 +0,0 @@
-[% country = c.cobrand.get_country_for_ip_address(c.req.address) -%]
-[%- IF country AND country != 'GB' -%]
-<div class="top_banner top_banner--country">
- <a href="#" class="top_banner__close">Close</a>
- <p>
- This site is for reporting <strong>problems in the UK</strong>. There are FixMyStreet sites
- <a href="http://www.fixmystreet.org/sites/">all over the world</a>, or you
- could set up your own using the <a href="http://www.fixmystreet.org/">FixMyStreet Platform</a>.
- </p>
-</div>
-[%- END -%]
diff --git a/web/cobrands/fixmystreet.com/js.js b/web/cobrands/fixmystreet.com/js.js
index 3abba8e33..9dbd11f2c 100644
--- a/web/cobrands/fixmystreet.com/js.js
+++ b/web/cobrands/fixmystreet.com/js.js
@@ -1,3 +1,29 @@
jQuery.validator.addMethod('validName', function(value, element) {
var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i;
return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); }, translation_strings.category );
+
+$(function(){
+
+ /* Front page banner for other countries */
+
+ $('.top_banner__close').live('click', function() {
+ $('.top_banner--country').hide();
+ $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'});
+ });
+
+ if ( $('body.frontpage').length ) {
+ if (!$.cookie('has_seen_country_message')) {
+ $.ajax({
+ url: 'https://gaze.mysociety.org/gaze-rest?f=get_country_from_ip',
+ success: function(data) {
+ if ( data && data != 'GB\n' ) {
+ var banner = '<div class="top_banner top_banner--country"><a href="#" class="top_banner__close">Close</a> <p>This site is for reporting <strong>problems in the UK</strong>. There are FixMyStreet sites <a href="http://www.fixmystreet.org/sites/">all over the world</a>, or you could set up your own using the <a href="http://www.fixmystreet.org/">FixMyStreet Platform</a>.</p></div>';
+ $('body').prepend(banner);
+ $('.top_banner--country').slideDown('slow');
+ }
+ }
+ });
+ }
+ }
+
+});
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index f01c5142d..4de18be9a 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -532,25 +532,6 @@ $.fn.drawer = function(id, ajax) {
}).fadeOut(500);
});
- $('.top_banner__close').live('click', function() {
- $('.top_banner--country').hide();
- $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'});
- });
-
- if ( cobrand == 'fixmystreet' && $('body.frontpage').length ) {
- if (!$.cookie('has_seen_country_message')) {
- $.ajax({
- url: '/country_message',
- success: function(data) {
- if ( data ) {
- $('body').prepend(data);
- $('.top_banner--country').slideDown('slow');
- }
- }
- });
- }
- }
-
/*
* Fancybox fullscreen images
*/