app/assets/javascripts/swim.js.coffee in speedo-0.3.4 vs app/assets/javascripts/swim.js.coffee in speedo-0.4.0

- old
+ new

@@ -1,11 +1,6 @@ $ -> - # For Web-app mode, uncomment this (and the CSS in speedo/layout.css.scss) to make the cols fill the browser - # $('.col1, .col2, .col3').css('height',$(window).height() - $('.main_nav').outerHeight() - $('.branding').outerHeight() - 60 + 'px') - # $(window).resize -> - # $('.col1, .col2, .col3').css('height',$(window).height() - $('.main_nav').outerHeight() - $('.branding').outerHeight() - 60 + 'px') - $('.tip').livequery -> $(@).tooltip() $('time.ago').livequery -> $(@).timeago() @@ -15,15 +10,18 @@ $('select.chzn').livequery -> $(@).chosen() $('input, textarea').livequery -> - $(@).placeholder() + $(@).not('input[type=password]').placeholder() $("select, input:checkbox, input:radio, input:file").livequery -> $(@).not('.hidden').not('.chzn').not('.bare').uniform() + $("form").livequery -> + $(@).preventDoubleSubmission() + $('input[type=date]').livequery -> $(@).not('.bare').datepicker numberOfMonths: 2 dateFormat: 'yy-mm-dd' showOn: 'focus' @@ -49,5 +47,18 @@ "aaSorting": [] # No initial sorting "aoColumnDefs": [ # Use this to make the final column un-sortable { "bSortable": false, "aTargets": [ -1 ] } ] # "bJQueryUI": true # Use jQueryUI styling + + +jQuery.fn.preventDoubleSubmission = -> + $form = $(this) + $form.bind "submit", (e) -> + if $form.data("submitted") is true + e.preventDefault() + else + $form.data "submitted", true + $form.find('input[type=submit], button').attr('disabled', 'disabled') + $form.ajaxComplete -> + $form.data "submitted", false + $form.find('input[type=submit], button').removeAttr('disabled')