Skip to content

Commit

Permalink
Merge pull request #4 from 720kb/focus_fix
Browse files Browse the repository at this point in the history
Fix Focus after NFC Send
  • Loading branch information
makevoid committed Nov 5, 2015
2 parents e617c06 + c5d5e28 commit 186a632
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions www/js/controllers/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
'use strict';

angular.module('Send.controller', [])
.controller('SendCtrl', ['$rootScope', '$scope', '$window', '$log', '$stateParams', '$filter', 'BitCoin', 'CordovaClipboard',
function SendCtrlController($rootScope, $scope, $window, $log, $stateParams, $filter, BitCoin, CordovaClipboard) {
.controller('SendCtrl', ['$rootScope', '$scope', '$window', '$log', '$stateParams', '$filter', 'BitCoin', 'CordovaClipboard', '$timeout',
function SendCtrlController($rootScope, $scope, $window, $log, $stateParams, $filter, BitCoin, CordovaClipboard, $timeout) {

var onNFCTag
, inputToAddressElement = $window.document.getElementById('toAddress');
Expand Down Expand Up @@ -113,5 +113,11 @@

onNFCTag();
});

$scope.$on('focus', function setFocus() {
$timeout(function(){
document.querySelector("input[type=number]").focus();
}, 1);
});
}]);
}(angular));
5 changes: 3 additions & 2 deletions www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@

$state.go('app.send', {
'nfcAddress': $rootScope.tagAddress
}).then(function(){
$rootScope.$broadcast('focus');
});
// TODO: focus on amount field - http://stackoverflow.com/a/22751353/160699 ?
}
}
]
});
}
// }
});

$rootScope.$on('nfc:status-message', function onMessageTag(eventsInformations, payload) {
Expand Down
2 changes: 1 addition & 1 deletion www/views/send/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h5>To</h5>
<h5>Amount</h5>
<div class="separator5"></div>
<label class="item item-input">
<input type="number" placeholder="0.0 mBTC" ng-model="sendForm.outputAmount">
<input type="number" placeholder="0.0 mBTC" ng-focus="sendFocus" ng-model="sendForm.outputAmount">
</label>
<!--all the errors and success messages-->
<div ng-if="errorText || successText">
Expand Down

0 comments on commit 186a632

Please sign in to comment.