From e945ebe3257bc43065a1d17f82c0683f8d8fd460 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 16 Aug 2017 19:10:39 -0500 Subject: [PATCH] Fix auto-disable button on form submit, per Chrome issues dang it chrome, why you gotta be like that --- tailbone/static/js/tailbone.js | 10 ++++++++-- tailbone/templates/base.mako | 2 +- tailbone/templates/master/clone.mako | 4 ++-- tailbone/templates/upgrades/view.mako | 4 ++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tailbone/static/js/tailbone.js b/tailbone/static/js/tailbone.js index d9022dbf..91b3c229 100644 --- a/tailbone/static/js/tailbone.js +++ b/tailbone/static/js/tailbone.js @@ -177,8 +177,14 @@ $(function() { $('a.button.autodisable').click(function() { disable_button(this); }); - $('input[type="submit"].autodisable').click(function() { - disable_button(this); + // for some reason chrome requires us to do things this way... + // https://stackoverflow.com/questions/16867080/onclick-javascript-stops-form-submit-in-chrome + // https://stackoverflow.com/questions/5691054/disable-submit-button-on-form-submit + $('form.autodisable').submit(function() { + var submit = $(this).find('input[type="submit"]'); + if (submit.length) { + disable_button(submit); + } }); /* diff --git a/tailbone/templates/base.mako b/tailbone/templates/base.mako index 22fedede..d11dc90a 100644 --- a/tailbone/templates/base.mako +++ b/tailbone/templates/base.mako @@ -138,7 +138,7 @@ var logout_url = '${request.route_url('logout')}'; var noop_url = '${request.route_url('noop')}'; - ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.js'))} + ${h.javascript_link(request.static_url('tailbone:static/js/tailbone.js') + '?ver={}'.format(tailbone.__version__))} <%def name="extra_javascript()"> diff --git a/tailbone/templates/master/clone.mako b/tailbone/templates/master/clone.mako index c4ed4380..438421dc 100644 --- a/tailbone/templates/master/clone.mako +++ b/tailbone/templates/master/clone.mako @@ -14,11 +14,11 @@

Are you sure about this?


-${h.form(request.current_route_url())} +${h.form(request.current_route_url(), class_='autodisable')} ${h.csrf_token(request)} ${h.hidden('clone', value='clone')}
${h.link_to("Whoops, nevermind...", form.cancel_url, class_='button autodisable')} - ${h.submit('submit', "Yes, please clone away", class_='autodisable')} + ${h.submit('submit', "Yes, please clone away")}
${h.end_form()} diff --git a/tailbone/templates/upgrades/view.mako b/tailbone/templates/upgrades/view.mako index e6d2a86e..1c9b3ec5 100644 --- a/tailbone/templates/upgrades/view.mako +++ b/tailbone/templates/upgrades/view.mako @@ -41,9 +41,9 @@ ${parent.body()} % if not instance.executed and request.has_perm('{}.execute'.format(permission_prefix)):
% if instance.enabled and not instance.executing: - ${h.form(url('{}.execute'.format(route_prefix), uuid=instance.uuid))} + ${h.form(url('{}.execute'.format(route_prefix), uuid=instance.uuid), class_='autodisable')} ${h.csrf_token(request)} - ${h.submit('execute', "Execute this upgrade", class_='autodisable')} + ${h.submit('execute', "Execute this upgrade")} ${h.end_form()} % elif instance.enabled: