aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/fixmystreet.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js/fixmystreet.js')
-rw-r--r--web/js/fixmystreet.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index b86d5f49c..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();
@@ -43,18 +47,19 @@ $(function(){
// FIXME - needs to use translated string
jQuery.validator.addMethod('validCategory', function(value, element) {
- return this.optional(element) || value != '-- Pick a category --'; }, validation_strings.category );
+ return this.optional(element) || value != '-- Pick a category --'; }, translation_strings.category );
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 ); }, validation_strings.category );
+ return this.optional(element) || value.length > 5 && value.match( /\S/ ) && value.match( /\s/ ) && !value.match( validNamePat ); }, translation_strings.category );
var form_submitted = 0;
var submitted = false;
- $("form.validate").validate({
+ $("form.validate").each(function(){
+ $(this).validate({
rules: validation_rules,
- messages: validation_strings,
+ messages: translation_strings,
onkeyup: false,
onfocusout: false,
errorElement: 'div',
@@ -85,6 +90,7 @@ $(function(){
submitted = false;
},
invalidHandler: function(form, validator) { submitted = true; }
+ });
});
$('input[type=submit]').click( function(e) { form_submitted = 1; } );
@@ -128,7 +134,7 @@ $(function(){
// Geolocation
if (geo_position_js.init()) {
- var link = '<a href="#LINK" id="geolocate_link">&hellip; or locate me automatically</a>';
+ var link = '<a href="#LINK" id="geolocate_link">&hellip; ' + translation_strings.geolocate + '</a>';
$('form[action="/alert/list"]').append(link.replace('LINK','alert/list'));
if ($('body.frontpage').length) {
$('#postcodeForm').after(link.replace('LINK','around'));
@@ -142,7 +148,8 @@ $(function(){
if($('.mobile').length){
$link.append(' <img src="/cobrands/fixmystreet/images/spinner-black.gif" alt="" align="bottom">');
}else{
- $link.append(' <img src="/cobrands/fixmystreet/images/spinner-yellow.gif" alt="" align="bottom">');
+ var spincolor = $('<span>').css("color","white").css("color") === $('#front-main').css("background-color")? 'white' : 'yellow';
+ $link.append(' <img src="/cobrands/fixmystreet/images/spinner-' + spincolor + '.gif" alt="" align="bottom">');
}
geo_position_js.getCurrentPosition(function(pos) {
$link.find('img').remove();
@@ -153,13 +160,13 @@ $(function(){
}, function(err) {
$link.find('img').remove();
if (err.code == 1) { // User said no
- $link.html("You declined; please fill in the box above");
+ $link.html(translation_strings.geolocation_declined);
} else if (err.code == 2) { // No position
- $link.html("Could not look up location");
+ $link.html(translation_strings.geolocation_no_position);
} else if (err.code == 3) { // Too long
- $link.html("No result returned");
+ $link.html(translation_strings.geolocation_no_result);
} else { // Unknown
- $link.html("Unknown error");
+ $link.html(translation_strings.geolocation_unknown);
}
}, {
enableHighAccuracy: true,