aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--templates/web/default/common_header_tags.html1
-rwxr-xr-xtemplates/web/default/faq/faq-en-gb.html3
-rw-r--r--web/cobrands/bromley/fixmystreet.js168
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js170
-rw-r--r--web/css/core.scss6
-rw-r--r--web/js/common.js190
-rw-r--r--web/js/fixmystreet.js156
8 files changed, 201 insertions, 494 deletions
diff --git a/.gitignore b/.gitignore
index 055e181dd..974d01d6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*.ttc
/cities_bin
/private_locale
+*~
._*
.DS_Store
.carton
diff --git a/templates/web/default/common_header_tags.html b/templates/web/default/common_header_tags.html
index e74ae7b70..251094c61 100644
--- a/templates/web/default/common_header_tags.html
+++ b/templates/web/default/common_header_tags.html
@@ -7,6 +7,7 @@
<script src="[% version('/js/jquery.validate.min.js') %]" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="[% version('/js/geo.min.js') %]"></script>
+<script type="text/javascript" src="[% version('/js/common.js') %]"></script>
<script type="text/javascript" src="[% version(js_override || '/js/fixmystreet.js') %]"></script>
[% map_js %]
diff --git a/templates/web/default/faq/faq-en-gb.html b/templates/web/default/faq/faq-en-gb.html
index ed9d53c24..cc9ba979a 100755
--- a/templates/web/default/faq/faq-en-gb.html
+++ b/templates/web/default/faq/faq-en-gb.html
@@ -93,7 +93,8 @@ href="https://secure.mysociety.org/donate/">please do</a>.</dd>
to find out where reports go at the moment. Also <a href="/contact">contact us</a>
to update the address or addresses we use.</dd>
<dt>I&rsquo;m from a council, can we have FixMyStreet on our website?</dt>
- <dd>Yes you can! We offer branded, hosted versions of FixMyStreet for local council websites. <a href="/for-councils">Full details</a>.</dd>
+ <dd>Yes you can! We offer branded, hosted versions of FixMyStreet for local council websites.
+ <a href="http://www.fixmystreet.com/for-councils">Full details</a>.</dd>
<dt>Do you remove silly or illegal content?</dt>
<dd>FixMyStreet is not responsible for the content and accuracy
of material submitted by its users. We reserve the right to edit or remove any
diff --git a/web/cobrands/bromley/fixmystreet.js b/web/cobrands/bromley/fixmystreet.js
index b00a653c1..bfe985d5f 100644
--- a/web/cobrands/bromley/fixmystreet.js
+++ b/web/cobrands/bromley/fixmystreet.js
@@ -3,33 +3,6 @@
* FixMyStreet JavaScript
*/
-function form_category_onchange() {
- var cat = $('#form_category');
- var args = {
- category: cat.val()
- };
-
- if ( typeof fixmystreet !== 'undefined' ) {
- args.latitude = fixmystreet.latitude;
- args.longitude = fixmystreet.longitude;
- } else {
- args.latitude = $('input[name="latitude"]').val();
- args.longitude = $('input[name="longitude"]').val();
- }
-
- $.getJSON('/report/new/category_extras', args, function(data) {
- if ( data.category_extra ) {
- if ( $('#category_meta').size() ) {
- $('#category_meta').html( data.category_extra);
- } else {
- $('#form_category_row').after( data.category_extra );
- }
- } else {
- $('#category_meta').empty();
- }
- });
-}
-
/*
* general height fixing function
*
@@ -80,11 +53,6 @@ function tabs(elem, indirect) {
$(function(){
var $html = $('html');
- $html.removeClass('no-js').addClass('js');
-
- // Preload the new report pin
- document.createElement('img').src = '/i/pin-green.png';
-
var last_type;
$(window).resize(function(){
var type = $('#site-header').css('borderTopWidth');
@@ -154,141 +122,7 @@ $(function(){
$('span.report-a-problem-btn').css({ cursor:'' }).off('.reportBtn');
}
last_type = type;
- });
-
- //add mobile class if small screen
- $(window).resize();
-
- $('#pc').focus();
-
- $('input[type=submit]').removeAttr('disabled');
- /*
- $('#mapForm').submit(function() {
- if (this.submit_problem) {
- $('input[type=submit]', this).prop("disabled", true);
- }
- return true;
- });
- */
-
- if (!$('#been_fixed_no').prop('checked') && !$('#been_fixed_unknown').prop('checked')) {
- $('#another_qn').hide();
- }
- $('#been_fixed_no').click(function() {
- $('#another_qn').show('fast');
- });
- $('#been_fixed_unknown').click(function() {
- $('#another_qn').show('fast');
- });
- $('#been_fixed_yes').click(function() {
- $('#another_qn').hide('fast');
- });
-
- // FIXME - needs to use translated string
- jQuery.validator.addMethod('validCategory', function(value, element) {
- return this.optional(element) || value != '-- Pick a category --'; }, validation_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( validNamePat ); }, validation_strings.category );
-
- var form_submitted = 0;
- var submitted = false;
-
- $("form.validate").validate({
- rules: {
- title: { required: true },
- detail: { required: true },
- email: { required: true },
- update: { required: true },
- rznvy: { required: true }
- },
- messages: validation_strings,
- onkeyup: false,
- onfocusout: false,
- errorElement: 'div',
- errorClass: 'form-error',
- // we do this to stop things jumping around on blur
- success: function (err) { if ( form_submitted ) { err.addClass('label-valid').removeClass('label-valid-hidden').html( '&nbsp;' ); } else { err.addClass('label-valid-hidden'); } },
- errorPlacement: function( error, element ) {
- element.before( error );
- },
- submitHandler: function(form) {
- if (form.submit_problem) {
- $('input[type=submit]', form).prop("disabled", true);
- }
-
- form.submit();
- },
- // make sure we can see the error message when we focus on invalid elements
- showErrors: function( errorMap, errorList ) {
- if ( submitted && errorList.length ) {
- $(window).scrollTop( $(errorList[0].element).offset().top - 120 );
- }
- this.defaultShowErrors();
- submitted = false;
- },
- invalidHandler: function(form, validator) { submitted = true; }
- });
-
- $('input[type=submit]').click( function(e) { form_submitted = 1; } );
-
- /* set correct required status depending on what we submit
- * NB: need to add things to form_category as the JS updating
- * of this we do after a map click removes them */
- $('#submit_sign_in').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').removeClass();
- } );
-
- $('#submit_register').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').addClass('required validName');
- } );
-
- $('#problem_submit > input[type="submit"]').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').addClass('required validName');
- } );
-
- $('#update_post').click( function(e) {
- $('#form_name').addClass('required').removeClass('valid');
- } );
-
- $('#form_category').change( form_category_onchange );
-
- // Geolocation
- if (geo_position_js.init()) {
- $('#postcodeForm').after('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
- $('#geolocate_link').click(function(e) {
- e.preventDefault();
- // Spinny thing!
- if($('.mobile').length){
- $(this).append(' <img src="/cobrands/fixmystreet/images/spinner-black.gif" alt="" align="bottom">');
- }else{
- $(this).append(' <img src="/cobrands/fixmystreet/images/spinner-yellow.gif" alt="" align="bottom">');
- }
- geo_position_js.getCurrentPosition(function(pos) {
- $('img', this).remove();
- var latitude = pos.coords.latitude;
- var longitude = pos.coords.longitude;
- location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
- }, function(err) {
- $('img', this).remove();
- if (err.code == 1) { // User said no
- } else if (err.code == 2) { // No position
- $(this).html("Could not look up location");
- } else if (err.code == 3) { // Too long
- $('this').html("No result returned");
- } else { // Unknown
- $('this').html("Unknown error");
- }
- }, {
- enableHighAccuracy: true,
- timeout: 10000
- });
- });
- }
+ }).resize();
/*
* Report a problem page
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 0db8334fb..27b2b345b 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -3,33 +3,6 @@
* FixMyStreet JavaScript
*/
-function form_category_onchange() {
- var cat = $('#form_category');
- var args = {
- category: cat.val()
- };
-
- if ( typeof fixmystreet !== 'undefined' ) {
- args.latitude = fixmystreet.latitude;
- args.longitude = fixmystreet.longitude;
- } else {
- args.latitude = $('input[name="latitude"]').val();
- args.longitude = $('input[name="longitude"]').val();
- }
-
- $.getJSON('/report/new/category_extras', args, function(data) {
- if ( data.category_extra ) {
- if ( $('#category_meta').size() ) {
- $('#category_meta').html( data.category_extra);
- } else {
- $('#form_category_row').after( data.category_extra );
- }
- } else {
- $('#category_meta').empty();
- }
- });
-}
-
/*
* general height fixing function
*
@@ -80,12 +53,7 @@ function tabs(elem, indirect) {
$(function(){
var $html = $('html');
- $html.removeClass('no-js').addClass('js');
-
-
- // Preload the new report pin
- document.createElement('img').src = '/i/pin-green.png';
-
+ // Deal with switching between mobile and desktop versions on resize
var last_type;
$(window).resize(function(){
var type = $('#site-header').css('borderTopWidth');
@@ -154,141 +122,7 @@ $(function(){
$('span.report-a-problem-btn').css({ cursor:'' }).off('.reportBtn');
}
last_type = type;
- });
-
- //add mobile class if small screen
- $(window).resize();
-
- $('#pc').focus();
-
- $('input[type=submit]').removeAttr('disabled');
- /*
- $('#mapForm').submit(function() {
- if (this.submit_problem) {
- $('input[type=submit]', this).prop("disabled", true);
- }
- return true;
- });
- */
-
- if (!$('#been_fixed_no').prop('checked') && !$('#been_fixed_unknown').prop('checked')) {
- $('#another_qn').hide();
- }
- $('#been_fixed_no').click(function() {
- $('#another_qn').show('fast');
- });
- $('#been_fixed_unknown').click(function() {
- $('#another_qn').show('fast');
- });
- $('#been_fixed_yes').click(function() {
- $('#another_qn').hide('fast');
- });
-
- // FIXME - needs to use translated string
- jQuery.validator.addMethod('validCategory', function(value, element) {
- return this.optional(element) || value != '-- Pick a category --'; }, validation_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( validNamePat ); }, validation_strings.category );
-
- var form_submitted = 0;
- var submitted = false;
-
- $("form.validate").validate({
- rules: {
- title: { required: true },
- detail: { required: true },
- email: { required: true },
- update: { required: true },
- rznvy: { required: true }
- },
- messages: validation_strings,
- onkeyup: false,
- onfocusout: false,
- errorElement: 'div',
- errorClass: 'form-error',
- // we do this to stop things jumping around on blur
- success: function (err) { if ( form_submitted ) { err.addClass('label-valid').removeClass('label-valid-hidden').html( '&nbsp;' ); } else { err.addClass('label-valid-hidden'); } },
- errorPlacement: function( error, element ) {
- element.before( error );
- },
- submitHandler: function(form) {
- if (form.submit_problem) {
- $('input[type=submit]', form).prop("disabled", true);
- }
-
- form.submit();
- },
- // make sure we can see the error message when we focus on invalid elements
- showErrors: function( errorMap, errorList ) {
- if ( submitted && errorList.length ) {
- $(window).scrollTop( $(errorList[0].element).offset().top - 120 );
- }
- this.defaultShowErrors();
- submitted = false;
- },
- invalidHandler: function(form, validator) { submitted = true; }
- });
-
- $('input[type=submit]').click( function(e) { form_submitted = 1; } );
-
- /* set correct required status depending on what we submit
- * NB: need to add things to form_category as the JS updating
- * of this we do after a map click removes them */
- $('#submit_sign_in').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').removeClass();
- } );
-
- $('#submit_register').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').addClass('required validName');
- } );
-
- $('#problem_submit > input[type="submit"]').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').addClass('required validName');
- } );
-
- $('#update_post').click( function(e) {
- $('#form_name').addClass('required').removeClass('valid');
- } );
-
- $('#form_category').change( form_category_onchange );
-
- // Geolocation
- if (geo_position_js.init()) {
- $('#postcodeForm').after('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
- $('#geolocate_link').click(function(e) {
- e.preventDefault();
- // Spinny thing!
- if($('.mobile').length){
- $(this).append(' <img src="/cobrands/fixmystreet/images/spinner-black.gif" alt="" align="bottom">');
- }else{
- $(this).append(' <img src="/cobrands/fixmystreet/images/spinner-yellow.gif" alt="" align="bottom">');
- }
- geo_position_js.getCurrentPosition(function(pos) {
- $('img', this).remove();
- var latitude = pos.coords.latitude;
- var longitude = pos.coords.longitude;
- location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
- }, function(err) {
- $('img', this).remove();
- if (err.code == 1) { // User said no
- } else if (err.code == 2) { // No position
- $(this).html("Could not look up location");
- } else if (err.code == 3) { // Too long
- $('this').html("No result returned");
- } else { // Unknown
- $('this').html("Unknown error");
- }
- }, {
- enableHighAccuracy: true,
- timeout: 10000
- });
- });
- }
+ }).resize();
/*
* Report a problem page
diff --git a/web/css/core.scss b/web/css/core.scss
index a38a188ce..72e483dfa 100644
--- a/web/css/core.scss
+++ b/web/css/core.scss
@@ -114,7 +114,9 @@ $map_width: 500px;
}
}
- #geolocate_para {
+ #geolocate_link {
+ display: block;
+ border: none;
font-size: 70%;
margin: 2px 0 0 0;
text-align: right;
@@ -609,7 +611,7 @@ $map_width: 500px;
}
}
- #geolocate_para {
+ #geolocate_link {
font-size: 100%;
}
diff --git a/web/js/common.js b/web/js/common.js
new file mode 100644
index 000000000..670791fc8
--- /dev/null
+++ b/web/js/common.js
@@ -0,0 +1,190 @@
+/*
+ * common.js
+ * FixMyStreet JavaScript used by all cobrands.
+ * With the JavaScript written more proper like.
+ */
+
+(function($){
+
+/*
+ Deal with changes to category by asking for details from the server.
+ */
+$(function(){
+
+ var $html = $('html');
+
+ // Add a class to the whole page saying JavaScript is enabled (for CSS and so on)
+ $html.removeClass('no-js').addClass('js');
+
+ // Preload the new report pin
+ document.createElement('img').src = '/i/pin-green.png';
+
+ // Focus on postcode box on front page
+ $('#pc').focus();
+
+ // In case we've come here by clicking back to a form that disabled a submit button
+ $('input[type=submit]').removeAttr('disabled');
+
+ // Questionnaire hide/showings
+ if (!$('#been_fixed_no').prop('checked') && !$('#been_fixed_unknown').prop('checked')) {
+ $('#another_qn').hide();
+ }
+ $('#been_fixed_no').click(function() {
+ $('#another_qn').show('fast');
+ });
+ $('#been_fixed_unknown').click(function() {
+ $('#another_qn').show('fast');
+ });
+ $('#been_fixed_yes').click(function() {
+ $('#another_qn').hide('fast');
+ });
+
+ // Form validation
+
+ // FIXME - needs to use translated string
+ jQuery.validator.addMethod('validCategory', function(value, element) {
+ return this.optional(element) || value != '-- Pick a category --'; }, validation_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( validNamePat ); }, validation_strings.category );
+
+ var form_submitted = 0;
+ var submitted = false;
+
+ $("form.validate").validate({
+ rules: {
+ title: { required: true },
+ detail: { required: true },
+ email: { required: true },
+ update: { required: true },
+ rznvy: { required: true }
+ },
+ messages: validation_strings,
+ onkeyup: false,
+ onfocusout: false,
+ errorElement: 'div',
+ errorClass: 'form-error',
+ // we do this to stop things jumping around on blur
+ success: function (err) { if ( form_submitted ) { err.addClass('label-valid').removeClass('label-valid-hidden').html( '&nbsp;' ); } else { err.addClass('label-valid-hidden'); } },
+ errorPlacement: function( error, element ) {
+ // Different for old/new style design
+ if ($('.form-field').length) {
+ element.parent('div.form-field').before( error );
+ } else {
+ element.before( error );
+ }
+ },
+ submitHandler: function(form) {
+ if (form.submit_problem) {
+ $('input[type=submit]', form).prop("disabled", true);
+ }
+
+ form.submit();
+ },
+ // make sure we can see the error message when we focus on invalid elements
+ showErrors: function( errorMap, errorList ) {
+ if ( submitted && errorList.length ) {
+ $(window).scrollTop( $(errorList[0].element).offset().top - 120 );
+ }
+ this.defaultShowErrors();
+ submitted = false;
+ },
+ invalidHandler: function(form, validator) { submitted = true; }
+ });
+
+ $('input[type=submit]').click( function(e) { form_submitted = 1; } );
+
+ /* set correct required status depending on what we submit
+ * NB: need to add things to form_category as the JS updating
+ * of this we do after a map click removes them */
+ $('#submit_sign_in').click( function(e) {
+ $('#form_category').addClass('required validCategory').removeClass('valid');
+ $('#form_name').removeClass();
+ } );
+
+ $('#submit_register').click( function(e) {
+ $('#form_category').addClass('required validCategory').removeClass('valid');
+ $('#form_name').addClass('required validName');
+ } );
+
+ $('#problem_submit > input[type="submit"]').click( function(e) {
+ $('#form_category').addClass('required validCategory').removeClass('valid');
+ $('#form_name').addClass('required validName');
+ } );
+
+ $('#update_post').click( function(e) {
+ $('#form_name').addClass('required').removeClass('valid');
+ } );
+
+ // Geolocation
+ if (geo_position_js.init()) {
+ if ($('body.frontpage').length) {
+ $('#postcodeForm').after('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
+ } else{
+ $('#postcodeForm').append('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
+ }
+ $('#geolocate_link').click(function(e) {
+ var $link = $(this);
+ e.preventDefault();
+ // Spinny thing!
+ 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">');
+ }
+ geo_position_js.getCurrentPosition(function(pos) {
+ $link.find('img').remove();
+ var latitude = pos.coords.latitude;
+ var longitude = pos.coords.longitude;
+ location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
+ }, function(err) {
+ $link.find('img').remove();
+ if (err.code == 1) { // User said no
+ $link.html("You declined; please fill in the box above");
+ } else if (err.code == 2) { // No position
+ $link.html("Could not look up location");
+ } else if (err.code == 3) { // Too long
+ $link.html("No result returned");
+ } else { // Unknown
+ $link.html("Unknown error");
+ }
+ }, {
+ enableHighAccuracy: true,
+ timeout: 10000
+ });
+ });
+ }
+
+ // Delegation is necessary because #form_category may be replaced during the lifetime of the page
+ $("#problem_form").on("change.category", "select#form_category", function(){
+ var args = {
+ category: $(this).val()
+ };
+
+ if ( typeof fixmystreet !== 'undefined' ) {
+ args.latitude = fixmystreet.latitude;
+ args.longitude = fixmystreet.longitude;
+ } else {
+ args.latitude = $('input[name="latitude"]').val();
+ args.longitude = $('input[name="longitude"]').val();
+ }
+
+ $.getJSON('/report/new/category_extras', args, function(data) {
+ var $category_meta = $('#category_meta');
+ if ( data.category_extra ) {
+ if ( $category_meta.length ) {
+ $category_meta.html( data.category_extra );
+ } else {
+ $('#form_category_row').after( data.category_extra );
+ }
+ } else {
+ $category_meta.empty();
+ }
+ });
+ });
+
+});
+
+})(jQuery);
+
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index 834aa4ed3..cf2bb0822 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -3,137 +3,13 @@
* FixMyStreet JavaScript
*/
-function form_category_onchange() {
- var cat = $('#form_category');
- var args = {
- category: cat.val()
- };
-
- if ( typeof fixmystreet !== 'undefined' ) {
- args.latitude = fixmystreet.latitude;
- args.longitude = fixmystreet.longitude;
- } else {
- args.latitude = $('input[name="latitude"]').val();
- args.longitude = $('input[name="longitude"]').val();
- }
-
- $.getJSON('/report/new/category_extras', args, function(data) {
- if ( data.category_extra ) {
- if ( $('#category_meta').size() ) {
- $('#category_meta').html( data.category_extra);
- } else {
- $('#form_category_row').after( data.category_extra );
- }
- } else {
- $('#category_meta').empty();
- }
- });
-}
-
$(function(){
- $('html').removeClass('no-js').addClass('js');
-
- $('#pc').focus();
-
- $('input[type=submit]').removeAttr('disabled');
- /*
- $('#mapForm').submit(function() {
- if (this.submit_problem) {
- $('input[type=submit]', this).prop("disabled", true);
- }
- return true;
- });
- */
-
- if (!$('#been_fixed_no').prop('checked') && !$('#been_fixed_unknown').prop('checked')) {
- $('#another_qn').hide();
- }
- $('#been_fixed_no').click(function() {
- $('#another_qn').show('fast');
- });
- $('#been_fixed_unknown').click(function() {
- $('#another_qn').show('fast');
- });
- $('#been_fixed_yes').click(function() {
- $('#another_qn').hide('fast');
- });
-
var timer;
function email_alert_close() {
$('#email_alert_box').hide('fast');
}
- // FIXME - needs to use translated string
- jQuery.validator.addMethod('validCategory', function(value, element) {
- return this.optional(element) || value != '-- Pick a category --'; }, validation_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( validNamePat ); }, validation_strings.category );
-
- var form_submitted = 0;
- var submitted = false;
-
- $("form.validate").validate({
- rules: {
- title: { required: true },
- detail: { required: true },
- email: { required: true },
- update: { required: true },
- rznvy: { required: true }
- },
- messages: validation_strings,
- onkeyup: false,
- errorElement: 'div',
- errorClass: 'form-error',
- // we do this to stop things jumping around on blur
- success: function (err) { if ( form_submitted ) { err.addClass('label-valid').removeClass('label-valid-hidden').html( '&nbsp;' ); } else { err.addClass('label-valid-hidden'); } },
- errorPlacement: function( error, element ) {
- element.parent('div').before( error );
- },
- submitHandler: function(form) {
- if (form.submit_problem) {
- $('input[type=submit]', form).prop("disabled", true);
- }
-
- form.submit();
- },
- // make sure we can see the error message when we focus on invalid elements
- showErrors: function( errorMap, errorList ) {
- if ( submitted && errorList.length ) {
- $(window).scrollTop( $(errorList[0].element).offset().top - 40 );
- }
- this.defaultShowErrors();
- submitted = false;
- },
- invalidHandler: function(form, validator) { submitted = true; }
- });
-
- $('input[type=submit]').click( function(e) { form_submitted = 1; } );
-
- /* set correct required status depending on what we submit
- * NB: need to add things to form_category as the JS updating
- * of this we do after a map click removes them */
- $('#submit_sign_in').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').removeClass();
- } );
-
- $('#submit_register').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').addClass('required validName');
- } );
-
- $('#problem_submit > input[type="submit"]').click( function(e) {
- $('#form_category').addClass('required validCategory').removeClass('valid');
- $('#form_name').addClass('required validName');
- } );
-
- $('#update_post').click( function(e) {
- $('#form_name').addClass('required').removeClass('valid');
- } );
-
$('#email_alert').click(function(e) {
if (!$('#email_alert_box').length) {
return true;
@@ -159,36 +35,4 @@ $(function(){
timer = window.setTimeout(email_alert_close, 2000);
});
- // Using delegate here because we *might* be running under a cobrand which isn't jQuery 1.7+
- // Delegation is necessary because #form_category may be replaced during the lifetime of the page
- $("#problem_form").delegate("select#form_category", "change", form_category_onchange );
-
- // Geolocation
- if (geo_position_js.init()) {
- $('#postcodeForm').append('<p id="geolocate_para">Or <a href="#" id="geolocate_link">locate me automatically</a>').css({ "padding-bottom": "0.5em" });
- $('#geolocate_link').click(function(e) {
- e.preventDefault();
- // Spinny thing!
- $('#geolocate_para').append(' <img src="/i/flower.gif" alt="" align="bottom">');
- geo_position_js.getCurrentPosition(function(pos) {
- $('#geolocate_para img').remove();
- var latitude = pos.coords.latitude;
- var longitude = pos.coords.longitude;
- location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
- }, function(err) {
- $('#geolocate_para img').remove();
- if (err.code == 1) { // User said no
- } else if (err.code == 2) { // No position
- $('#geolocate_para').html("Could not look up location");
- } else if (err.code == 3) { // Too long
- $('#geolocate_para').html("No result returned");
- } else { // Unknown
- $('#geolocate_para').html("Unknown error");
- }
- }, {
- timeout: 10000
- });
- });
- }
-
});