فهرست منبع

focus on first element in form when showing

Henry Oswald 12 سال پیش
والد
کامیت
f18172258e
2فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 1 1
      services/web/app/views/project/list.jade
  2. 7 0
      services/web/public/coffee/UserDetailsUpdater.coffee

+ 1 - 1
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

+ 7 - 0
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