Autofocus input fields on calendar edit and creation

This commit is contained in:
Raimund Schlüßler 2016-08-11 00:09:08 +02:00
parent 7eb3fd2260
commit 1097aa14f1
2 changed files with 24 additions and 10 deletions

View file

@ -21,14 +21,14 @@
angular.module('Tasks').controller('ListController', [
'$scope', '$rootScope', '$window', '$routeParams', 'ListsModel', 'TasksBusinessLayer', 'CollectionsModel', 'ListsBusinessLayer', '$location',
'SearchBusinessLayer', 'CalendarService', 'TasksModel',
'SearchBusinessLayer', 'CalendarService', 'TasksModel', '$timeout',
function($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel) {
SearchBusinessLayer, CalendarService, TasksModel, $timeout) {
'use strict';
var ListController;
ListController = (function() {
function ListController(_$scope, $rootScope, _$window, _$routeParams, _$listsmodel, _$tasksbusinesslayer, _$collectionsmodel, _$listsbusinesslayer, $location,
_$searchbusinesslayer, _$calendarservice, _$tasksmodel) {
_$searchbusinesslayer, _$calendarservice, _$tasksmodel, _$timeout) {
this._$scope = _$scope;
this._$window = _$window;
@ -39,6 +39,7 @@ angular.module('Tasks').controller('ListController', [
this._$collectionsmodel = _$collectionsmodel;
this._$listsbusinesslayer = _$listsbusinesslayer;
this.$location = $location;
this._$timeout = _$timeout;
this._$searchbusinesslayer = _$searchbusinesslayer;
this._$calendarservice = _$calendarservice;
this._$scope.collections = this._$collectionsmodel.getAll();
@ -62,6 +63,9 @@ angular.module('Tasks').controller('ListController', [
_$scope.status.addingList = true;
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
_$timeout(function() {
$('#newList').focus();
}, 50);
};
this._$scope.create = function() {
@ -89,7 +93,10 @@ angular.module('Tasks').controller('ListController', [
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
calendar.prepareUpdate();
return $location.path('/calendars/' + _$scope.route.calendarID + '/edit/name');
$location.path('/calendars/' + _$scope.route.calendarID + '/edit/name');
_$timeout(function() {
$('#list_' + calendar.uri + ' input.edit').focus();
}, 50);
};
this._$scope.checkNew = function(event,name) {
@ -235,6 +242,6 @@ angular.module('Tasks').controller('ListController', [
})();
return new ListController($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel);
SearchBusinessLayer, CalendarService, TasksModel, $timeout);
}
]);

View file

@ -579,14 +579,14 @@ angular.module('Tasks').controller('DetailsController', [
angular.module('Tasks').controller('ListController', [
'$scope', '$rootScope', '$window', '$routeParams', 'ListsModel', 'TasksBusinessLayer', 'CollectionsModel', 'ListsBusinessLayer', '$location',
'SearchBusinessLayer', 'CalendarService', 'TasksModel',
'SearchBusinessLayer', 'CalendarService', 'TasksModel', '$timeout',
function($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel) {
SearchBusinessLayer, CalendarService, TasksModel, $timeout) {
'use strict';
var ListController;
ListController = (function() {
function ListController(_$scope, $rootScope, _$window, _$routeParams, _$listsmodel, _$tasksbusinesslayer, _$collectionsmodel, _$listsbusinesslayer, $location,
_$searchbusinesslayer, _$calendarservice, _$tasksmodel) {
_$searchbusinesslayer, _$calendarservice, _$tasksmodel, _$timeout) {
this._$scope = _$scope;
this._$window = _$window;
@ -597,6 +597,7 @@ angular.module('Tasks').controller('ListController', [
this._$collectionsmodel = _$collectionsmodel;
this._$listsbusinesslayer = _$listsbusinesslayer;
this.$location = $location;
this._$timeout = _$timeout;
this._$searchbusinesslayer = _$searchbusinesslayer;
this._$calendarservice = _$calendarservice;
this._$scope.collections = this._$collectionsmodel.getAll();
@ -620,6 +621,9 @@ angular.module('Tasks').controller('ListController', [
_$scope.status.addingList = true;
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
_$timeout(function() {
$('#newList').focus();
}, 50);
};
this._$scope.create = function() {
@ -647,7 +651,10 @@ angular.module('Tasks').controller('ListController', [
_$scope.nameError = false;
$('.hasTooltip').tooltip('hide');
calendar.prepareUpdate();
return $location.path('/calendars/' + _$scope.route.calendarID + '/edit/name');
$location.path('/calendars/' + _$scope.route.calendarID + '/edit/name');
_$timeout(function() {
$('#list_' + calendar.uri + ' input.edit').focus();
}, 50);
};
this._$scope.checkNew = function(event,name) {
@ -793,7 +800,7 @@ angular.module('Tasks').controller('ListController', [
})();
return new ListController($scope, $rootScope, $window, $routeParams, ListsModel, TasksBusinessLayer, CollectionsModel, ListsBusinessLayer, $location,
SearchBusinessLayer, CalendarService, TasksModel);
SearchBusinessLayer, CalendarService, TasksModel, $timeout);
}
]);