summaryrefslogtreecommitdiff
path: root/addons/payment/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/payment/static/src/js')
-rw-r--r--addons/payment/static/src/js/payment_form.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js
index 8ccb48ec0de..97f49ddf2f2 100644
--- a/addons/payment/static/src/js/payment_form.js
+++ b/addons/payment/static/src/js/payment_form.js
@@ -36,6 +36,18 @@ odoo.define('payment.payment_form', function (require) {
$('[data-toggle="tooltip"]').tooltip();
},
+ disableButton: function (button) {
+ $(button).attr('disabled', true);
+ $(button).children('.fa-lock').removeClass('fa-lock');
+ $(button).prepend('<span class="o_loader"><i class="fa fa-refresh fa-spin"></i>&nbsp;</span>');
+ },
+
+ enableButton: function (button) {
+ $(button).attr('disabled', false);
+ $(button).children('.fa').addClass('fa-lock');
+ $(button).find('span.o_loader').remove();
+ },
+
payEvent: function (ev) {
ev.preventDefault();
var form = this.el;
@@ -90,10 +102,7 @@ odoo.define('payment.payment_form', function (require) {
return;
}
- $(button).attr('disabled', true);
- $(button).children('.fa-plus-circle').removeClass('fa-plus-circle')
- $(button).prepend('<span class="o_loader"><i class="fa fa-refresh fa-spin"></i>&nbsp;</span>');
-
+ this.disableButton(button);
var verify_validity = this.$el.find('input[name="verify_validity"]');
if (verify_validity.length>0) {
@@ -128,14 +137,10 @@ odoo.define('payment.payment_form', function (require) {
}
}
// here we remove the 'processing' icon from the 'add a new payment' button
- $(button).attr('disabled', false);
- $(button).children('.fa').addClass('fa-plus-circle')
- $(button).find('span.o_loader').remove();
+ self.enableButton(button);
}).fail(function (error, event) {
// if the rpc fails, pretty obvious
- $(button).attr('disabled', false);
- $(button).children('.fa').addClass('fa-plus-circle')
- $(button).find('span.o_loader').remove();
+ self.enableButton(button);
self.displayError(
_t('Server Error'),
@@ -200,6 +205,7 @@ odoo.define('payment.payment_form', function (require) {
}
}
else { // if the user is using an old payment then we just submit the form
+ this.disableButton(button);
form.submit();
return $.Deferred();
}