diff options
Diffstat (limited to 'web/js/fixmystreet.js')
-rw-r--r-- | web/js/fixmystreet.js | 88 |
1 files changed, 35 insertions, 53 deletions
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index 50ccb2ac3..4b19dc53e 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -3,76 +3,58 @@ * FixMyStreet JavaScript */ +$(function(){ -YAHOO.util.Event.onContentReady('pc', function() { - if (this.id && this.value == this.defaultValue) { - this.focus(); - } -}); + $('#pc').focus(); -YAHOO.util.Event.onContentReady('mapForm', function() { - this.onsubmit = function() { + $('input[type=submit]').removeAttr('disabled'); + $('#mapForm').submit(function() { if (this.submit_problem) { - this.onsubmit = function() { return false; }; + $('input[type=submit]', this).prop("disabled", true); } - - /* XXX Should be in Tilma code only */ - if (this.x) { - this.x.value = fixmystreet.x + 3; - this.y.value = fixmystreet.y + 3; - } - return true; - } -}); + }); -YAHOO.util.Event.onContentReady('another_qn', function() { - if (!document.getElementById('been_fixed_no').checked && !document.getElementById('been_fixed_unknown').checked) { - YAHOO.util.Dom.setStyle(this, 'display', 'none'); + if (!$('#been_fixed_no').prop('checked') && !$('#been_fixed_unknown').prop('checked')) { + $('#another_qn').hide(); } - YAHOO.util.Event.addListener('been_fixed_no', 'click', function(e) { - YAHOO.util.Dom.setStyle('another_qn', 'display', 'block'); + $('#been_fixed_no').click(function() { + $('#another_qn').show('fast'); }); - YAHOO.util.Event.addListener('been_fixed_unknown', 'click', function(e) { - YAHOO.util.Dom.setStyle('another_qn', 'display', 'block'); + $('#been_fixed_unknown').click(function() { + $('#another_qn').show('fast'); }); - YAHOO.util.Event.addListener('been_fixed_yes', 'click', function(e) { - YAHOO.util.Dom.setStyle('another_qn', 'display', 'none'); + $('#been_fixed_yes').click(function() { + $('#another_qn').hide('fast'); }); -}); -var timer; -function email_alert_close() { - YAHOO.util.Dom.setStyle('email_alert_box', 'display', 'none'); -} -YAHOO.util.Event.onContentReady('email_alert', function() { - YAHOO.util.Event.addListener(this, 'click', function(e) { - if (!document.getElementById('email_alert_box')) + var timer; + function email_alert_close() { + $('#email_alert_box').hide('fast'); + } + + $('#email_alert').click(function(e) { + if (!$('#email_alert_box').length) return true; - YAHOO.util.Event.preventDefault(e); - if (YAHOO.util.Dom.getStyle('email_alert_box', 'display') == 'block') { + e.preventDefault(); + if ($('#email_alert_box').is(':visible')) { email_alert_close(); } else { - var pos = YAHOO.util.Dom.getXY(this); - pos[0] -= 20; pos[1] += 20; - YAHOO.util.Dom.setStyle('email_alert_box', 'display', 'block'); - YAHOO.util.Dom.setXY('email_alert_box', pos); - document.getElementById('alert_rznvy').focus(); + var pos = $(this).position(); + $('#email_alert_box').css( { 'left': ( pos.left - 20 ) + 'px', 'top': ( pos.top + 20 ) + 'px' } ); + $('#email_alert_box').show('fast'); + $('#alert_rznvy').focus(); } - }); - YAHOO.util.Event.addListener(this, 'mouseout', function(e) { - timer = window.setTimeout(email_alert_close, 2000); - }); - YAHOO.util.Event.addListener(this, 'mouseover', function(e) { + }).hover(function() { window.clearTimeout(timer); + }, function() { + timer = window.setTimeout(email_alert_close, 2000); }); -}); -YAHOO.util.Event.onContentReady('email_alert_box', function() { - YAHOO.util.Event.addListener(this, 'mouseout', function(e) { - timer = window.setTimeout(email_alert_close, 2000); - }); - YAHOO.util.Event.addListener(this, 'mouseover', function(e) { + + $('#email_alert_box').hover(function() { window.clearTimeout(timer); + }, function() { + timer = window.setTimeout(email_alert_close, 2000); }); -}); +}); |