From 1097aa14f180e3997f2ce603ca40a3c6fb11f431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Thu, 11 Aug 2016 00:09:08 +0200 Subject: [PATCH] Autofocus input fields on calendar edit and creation --- js/app/controllers/listcontroller.js | 17 ++++++++++++----- js/public/app.js | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/js/app/controllers/listcontroller.js b/js/app/controllers/listcontroller.js index 03cfa210..ed0a7ba2 100644 --- a/js/app/controllers/listcontroller.js +++ b/js/app/controllers/listcontroller.js @@ -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); } ]); diff --git a/js/public/app.js b/js/public/app.js index 1116861f..df7893e1 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -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); } ]);