From 18ca40b01ee6f0b76354699b9ffca9ae6e30d698 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 1 Aug 2014 16:30:26 -0700 Subject: [PATCH] paypro: reset form if user removes payment uri. --- js/directives.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/js/directives.js b/js/directives.js index 899ee977e..d52143949 100644 --- a/js/directives.js +++ b/js/directives.js @@ -44,6 +44,9 @@ angular.module('copayApp.directives') // XXX There needs to be a better way to do this: total = +total / config.unitToSatoshi; + var address = angular.element( + document.querySelector('input#address')); + var amount = angular.element( document.querySelector('input#amount')); amount.val(total); @@ -72,6 +75,23 @@ angular.module('copayApp.directives') document.querySelector('[title="Send all funds"]')); sendall.attr('class', sendall.attr('class') + ' hidden'); + address.on('change', function(ev) { + var val = address.val(); + var uri = copay.HDPath.parseBitcoinURI(val || ''); + if (!uri || !uri.merchant) { + if (amount.attr('disabled') === true) { + amount.attr('disabled', false); + } + if (amount.attr('disabled') === false) { + submit.attr('disabled', true); + } + if (/ hidden$/.test(sendall.attr('class'))) { + sendall.attr('class', + sendall.attr('class').replace(' hidden', '')); + } + } + }); + ctrl.$setValidity('validAddress', true); });