/* * southampton.js * FixMyStreet JavaScript for Southampton */ $(function(){ $('[placeholder]').focus(function(){ var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); input.css({ 'color': '#000000' }); } }).blur(function(){ var input = $(this); if (input.val() === '' || input.val() == input.attr('placeholder')) { input.css({ 'color': '#999999' }); input.val(input.attr('placeholder')); } }).blur(); // use on() here because the #form_category may be replaced // during the page's lifetime $("#problem_form").on("change.southampton", "select#form_category", function() { var category = $(this).val(); if ('Potholes' == category) { if (!$('#potholes_extra').length) { var qns = ''; $('#form_title').closest('div.form-field').after(qns); } $('#potholes_extra').show('fast'); } else { $('#potholes_extra').hide('fast'); } } ).change(); // change called to trigger (in case we've come in with potholes selected) });