Bläddra i källkod

changed html autofocus to an angular directive

autofocus is html5y and worked on chrome but not firefox for me.
Henry Oswald 12 år sedan
förälder
incheckning
726719ce3f

+ 1 - 1
services/web/app/views/user/login.jade

@@ -20,7 +20,7 @@ block content
 									placeholder='email@example.com',
 									ng-model="email",
 									ng-model-options="{ updateOn: 'blur' }",
-									autofocus
+									focus="true"
 								)
 								span.small.text-primary(ng-show="loginForm.email.$invalid && loginForm.email.$dirty")
 									| Must be an email address

+ 1 - 1
services/web/app/views/user/register.jade

@@ -32,7 +32,7 @@ block content
 									ng-model="email",
 									ng-init="email = #{JSON.stringify(new_email)}",
 									ng-model-options="{ updateOn: 'blur' }",
-									autofocus
+									focus="true"
 								)
 								span.small.text-primary(ng-show="registerForm.email.$invalid && registerForm.email.$dirty")
 									| Must be an email address

+ 11 - 0
services/web/public/coffee/directives/focus.coffee

@@ -55,6 +55,17 @@ define [
 					selectName(element)
 		}
 
+
+	App.directive "focus", ($timeout) ->
+		scope:
+			trigger: "@focus"
+
+		link: (scope, element) ->
+			scope.$watch "trigger", (value) ->
+				if value is "true"
+					$timeout ->
+						element[0].focus()
+
 	selectName = (element) ->
 		# Select up to last '.'. I.e. everything
 		# except the file extension