diff --git a/index.html b/index.html index 9dea09c41..a6278c10a 100644 --- a/index.html +++ b/index.html @@ -84,13 +84,15 @@ -
- +
+

- {{$root.wallet.getName()}} + {{$root.wallet.getName()}}

diff --git a/js/controllers/create.js b/js/controllers/create.js index 54d99263a..3e65e7d34 100644 --- a/js/controllers/create.js +++ b/js/controllers/create.js @@ -72,7 +72,7 @@ angular.module('copayApp.controllers').controller('CreateController', }); }; - $scope.$on("$destroy", function () { - $rootScope.hideWalletNavigation = false; + $scope.$on("$destroy", function () { + $rootScope.hideWalletNavigation = false; }); }); diff --git a/js/controllers/import.js b/js/controllers/import.js index f317833ad..1e177ee09 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -100,8 +100,8 @@ angular.module('copayApp.controllers').controller('ImportController', }; - $scope.$on("$destroy", function () { - $rootScope.hideWalletNavigation = false; + $scope.$on("$destroy", function () { + $rootScope.hideWalletNavigation = false; }); }); diff --git a/js/controllers/join.js b/js/controllers/join.js index 8d323ae8f..e1029fac2 100644 --- a/js/controllers/join.js +++ b/js/controllers/join.js @@ -154,7 +154,7 @@ angular.module('copayApp.controllers').controller('JoinController', } - $scope.$on("$destroy", function () { - $rootScope.hideWalletNavigation = false; + $scope.$on("$destroy", function () { + $rootScope.hideWalletNavigation = false; }); }); diff --git a/js/controllers/send.js b/js/controllers/send.js index 00cd69ceb..53e742f1f 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -50,6 +50,17 @@ angular.module('copayApp.controllers').controller('SendController', }); }; + if (isCordova) { + var openScannerCordova = $rootScope.$on('dataScanned', function(event, data) { + $scope.sendForm.address.$setViewValue(data); + $scope.sendForm.address.$render(); + }); + + $scope.$on('$destroy', function() { + openScannerCordova(); + }); + } + $scope.formFocus = function(what) { if (!$scope.isWindowsPhoneApp) return @@ -183,17 +194,17 @@ angular.module('copayApp.controllers').controller('SendController', var comment = form.comment.$modelValue; var merchantData = $scope._merchantData; var address, amount; - if (!merchantData) { + if (!merchantData) { address = form.address.$modelValue; amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0)); } - w.spend({ + w.spend({ merchantData: merchantData, toAddress: address, amountSat: amount, - comment: comment, - }, function (err, txid, status) { + comment: comment, + }, function (err, txid, status) { $scope.loading = false; $scope.creatingTX = false; if ($scope.isWindowsPhoneApp) @@ -202,8 +213,8 @@ angular.module('copayApp.controllers').controller('SendController', if (err) return $scope.setError(err); txStatus.notify(status); - $scope.resetForm(); - }); + $scope.resetForm(); + }); }, 1); }; @@ -299,7 +310,6 @@ angular.module('copayApp.controllers').controller('SendController', }; $scope.openScanner = function() { - if (window.cordova) return $scope.scannerIntent(); $scope.showScanner = true; // Wait a moment until the canvas shows @@ -324,31 +334,6 @@ angular.module('copayApp.controllers').controller('SendController', }, 500); }; - $scope.scannerIntent = function() { - window.ignoreMobilePause = true; - cordova.plugins.barcodeScanner.scan( - function onSuccess(result) { - $timeout(function() { - window.ignoreMobilePause = false; - }, 100); - if (result.cancelled) return; - - $timeout(function() { - var data = result.text; - $scope.$apply(function() { - $scope.sendForm.address.$setViewValue(result.text); - $scope.sendForm.address.$render(); - }); - }, 1000); - }, - function onError(error) { - $timeout(function() { - window.ignoreMobilePause = false; - }, 100); - alert('Scanning error'); - }); - } - $scope.setTopAmount = function() { var w = $rootScope.wallet; var form = $scope.sendForm; diff --git a/js/controllers/sidebar.js b/js/controllers/sidebar.js index a262c472e..cf074753f 100644 --- a/js/controllers/sidebar.js +++ b/js/controllers/sidebar.js @@ -1,8 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService, isMobile, go) { +angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService, isMobile, isCordova, go) { - $scope.isMobile = isMobile.any() + $scope.isMobile = isMobile.any(); + $scope.isCordova = isCordova; $scope.menu = [{ 'title': 'Home', @@ -46,6 +47,32 @@ angular.module('copayApp.controllers').controller('SidebarController', function( $scope.setWallets(); }; + $scope.openScanner = function() { + window.ignoreMobilePause = true; + cordova.plugins.barcodeScanner.scan( + function onSuccess(result) { + $timeout(function() { + window.ignoreMobilePause = false; + }, 100); + if (result.cancelled) return; + + $timeout(function() { + var data = result.text; + $scope.$apply(function() { + $rootScope.$emit('dataScanned', data); + }); + }, 1000); + }, + function onError(error) { + $timeout(function() { + window.ignoreMobilePause = false; + }, 100); + alert('Scanning error'); + } + ); + go.send(); + }; + $scope.init = function() { // This should be called only once. diff --git a/views/homeWallet.html b/views/homeWallet.html index 227c4c742..8ad57b533 100644 --- a/views/homeWallet.html +++ b/views/homeWallet.html @@ -12,7 +12,10 @@
{{$root.wallet.getName() | limitTo: 1}}
-

{{$root.wallet.getName()}}

+

+ {{$root.wallet.getName()}} + +

diff --git a/views/send.html b/views/send.html index eafa74ec9..f00652b4f 100644 --- a/views/send.html +++ b/views/send.html @@ -1,19 +1,8 @@
-
-

{{$root.title}}

-
-
-
+
+

{{$root.title}}

-
-
- -
-
- -
-
@@ -31,24 +20,24 @@
-
-
-
-
-
- -
- - Creating Transaction... - -
-
+
+
+
+
+
+ +
+ + Creating Transaction... +
+
+
-
+