Added a directive to focus the first input fields

This commit is contained in:
Matias Pando 2014-11-19 17:49:45 -03:00
parent b554c4c7ea
commit 527c3beab1
6 changed files with 27 additions and 18 deletions

View File

@ -112,20 +112,19 @@ angular.module('copayApp.directives')
}
])
.directive('walletSecret', function() {
return {
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
var validator = function(value) {
var a = new Address(value);
ctrl.$setValidity('walletSecret', !a.isValid() && Boolean(copay.Wallet.decodeSecret(value)));
return value;
};
return {
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
var validator = function(value) {
var a = new Address(value);
ctrl.$setValidity('walletSecret', !a.isValid() && Boolean(copay.Wallet.decodeSecret(value)));
return value;
};
ctrl.$parsers.unshift(validator);
}
};
}
)
ctrl.$parsers.unshift(validator);
}
};
})
.directive('loading', function() {
return {
restrict: 'A',
@ -270,6 +269,16 @@ angular.module('copayApp.directives')
}
}
])
.directive('autoFocus', function($timeout) {
return {
restrict: 'AC',
link: function(_scope, _element) {
$timeout(function() {
_element[0].focus();
}, 0);
}
};
})
.directive('match', function() {
return {
require: 'ngModel',

View File

@ -10,7 +10,7 @@
<div class="large-12 columns">
<div class="panel">
<label><span translate>Wallet name</span>
<input type="text" placeholder="{{'Family vacation funds'|translate}}" class="form-control" ng-model="walletName">
<input type="text" placeholder="{{'Family vacation funds'|translate}}" class="form-control" ng-model="walletName" auto-focus>
</label>
<div class="row">
<div class="large-6 medium-6 columns">

View File

@ -31,7 +31,7 @@
<span class="icon-input right" ng-show="!profileForm.email.$invalid &&
!profileForm.email.$pristine || error"><i class="fi-check"></i></span>
<input type="email" ng-model="email" class="form-control fi-email"
name="email" placeholder="Email" required>
name="email" placeholder="Email" required auto-focus>
</div>
</div>

View File

@ -48,7 +48,7 @@
</p>
<input type="email" ng-model="email" class="form-control"
name="email" placeholder="Email" required>
name="email" placeholder="Email" required auto-focus>
<input type="password" ng-model="password" class="form-control"
name="password" placeholder="Password" required>

View File

@ -25,7 +25,7 @@
<div class="pr">
<input id="connectionId" type="text" class="columns" placeholder="{{'Paste wallet secret here'|translate}}" name="connectionId" ng-model="connectionId" wallet-secret required>
<input id="connectionId" type="text" class="columns" placeholder="{{'Paste wallet secret here'|translate}}" name="connectionId" ng-model="connectionId" wallet-secret required auto-focus>
<div ng-hide="showScanner || disableScanner">
<a class="postfix button black" ng-click="openScanner()"><i class="fi-camera">&nbsp;</i></a>
</div>

View File

@ -41,7 +41,7 @@
<div class="pr">
<input class="columns" type="text" id="address" name="address" ng-disabled="loading || !!$root.merchant"
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" ng-change="onChanged()" valid-address required>
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" ng-change="onChanged()" valid-address required auto-focus>
<div ng-hide="showScanner || disableScanner">
<button class="postfix button black" ng-click="openScanner()"><i class="fi-camera size-24"></i></button>
</div>