From f18172258e4d0f8ec0ace5a4004163baf0054c9b Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 16 Jun 2014 16:22:45 +0100 Subject: [PATCH] focus on first element in form when showing --- services/web/app/views/project/list.jade | 2 +- services/web/public/coffee/UserDetailsUpdater.coffee | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/services/web/app/views/project/list.jade b/services/web/app/views/project/list.jade index 11bbe3f714..a4a1909211 100644 --- a/services/web/app/views/project/list.jade +++ b/services/web/app/views/project/list.jade @@ -120,7 +120,7 @@ block content div(ng-show="formVisable") form(enctype='multipart/form-data', method='post') .input - input(type='text', name='first_name', ng-model="userInfoForm.first_name", ng-blur="sendUpdate()", placeholder="First Name") + input(type='text', name='first_name', ng-model="userInfoForm.first_name", ng-blur="sendUpdate()", placeholder="First Name", focus-input="formVisable") .input input(type='text', name='last_name', ng-model="userInfoForm.last_name", ng-blur="sendUpdate()", placeholder='Last Name') .input#institution_auto_complete diff --git a/services/web/public/coffee/UserDetailsUpdater.coffee b/services/web/public/coffee/UserDetailsUpdater.coffee index e6d204bf09..0370638f51 100644 --- a/services/web/public/coffee/UserDetailsUpdater.coffee +++ b/services/web/public/coffee/UserDetailsUpdater.coffee @@ -5,6 +5,13 @@ define ["libs/algolia", "libs/angular", "libs/angular-autocomplete/angular-autoc app.factory "Institutions", -> new AlgoliaSearch("SK53GL4JLY", "75dc5e65794cd47eb7f725e6bb5075be").initIndex("institutions") + app.directive "focusInput", ($timeout) -> + return (scope, element, attr) -> + scope.$watch attr.focusInput, (value) -> + if value + $timeout -> + element.select() + app.controller "UpdateForm", ($scope, $http, Institutions)-> $scope.institutions = [] $scope.formVisable = false