support auto focus "download links" text box when entering "new task" page
This commit is contained in:
parent
c085dc7a88
commit
7e1b64a83b
|
@ -305,6 +305,7 @@
|
||||||
<script src="scripts/controllers/settings-ariang.js"></script>
|
<script src="scripts/controllers/settings-ariang.js"></script>
|
||||||
<script src="scripts/controllers/settings-aria2.js"></script>
|
<script src="scripts/controllers/settings-aria2.js"></script>
|
||||||
<script src="scripts/controllers/status.js"></script>
|
<script src="scripts/controllers/status.js"></script>
|
||||||
|
<script src="scripts/directives/autoFocus.js"></script>
|
||||||
<script src="scripts/directives/pieceBar.js"></script>
|
<script src="scripts/directives/pieceBar.js"></script>
|
||||||
<script src="scripts/directives/pieceMap.js"></script>
|
<script src="scripts/directives/pieceMap.js"></script>
|
||||||
<script src="scripts/directives/chart.js"></script>
|
<script src="scripts/directives/chart.js"></script>
|
||||||
|
|
14
src/scripts/directives/autoFocus.js
Normal file
14
src/scripts/directives/autoFocus.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('ariaNg').directive('ngAutoFocus', ['$timeout', function ($timeout) {
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
link: function (scope, element) {
|
||||||
|
$timeout(function () {
|
||||||
|
element[0].focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
})();
|
|
@ -43,7 +43,7 @@
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<p translate>Download Links:</p>
|
<p translate>Download Links:</p>
|
||||||
<div class="form-group has-feedback no-margin" ng-class="{ 'has-error' : newTaskForm.urls.$invalid && newTaskForm.urls.$dirty, 'has-success' : newTaskForm.urls.$valid && newTaskForm.urls.$dirty }">
|
<div class="form-group has-feedback no-margin" ng-class="{ 'has-error' : newTaskForm.urls.$invalid && newTaskForm.urls.$dirty, 'has-success' : newTaskForm.urls.$valid && newTaskForm.urls.$dirty }">
|
||||||
<textarea name="urls" class="form-control" rows="10"
|
<textarea name="urls" class="form-control" rows="10" autofocus="autofocus" ng-auto-focus
|
||||||
ng-model="context.urls" ng-required="true" ng-keydown="urlTextboxKeyDown($event)"
|
ng-model="context.urls" ng-required="true" ng-keydown="urlTextboxKeyDown($event)"
|
||||||
ng-placeholder="'Support multiple URLs, one URL per line.' | translate"
|
ng-placeholder="'Support multiple URLs, one URL per line.' | translate"
|
||||||
ng-pattern="/^(\n?(((http|https|ftp|ssh):\/\/.+)|(magnet:\?.+)))*$/i"></textarea>
|
ng-pattern="/^(\n?(((http|https|ftp|ssh):\/\/.+)|(magnet:\?.+)))*$/i"></textarea>
|
||||||
|
|
Reference in a new issue