Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
e44d5770
Commit
e44d5770
authored
Nov 27, 2015
by
Robert Knight
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2747 from hypothesis/179-focus-in-username-field-when-sign-in-is-clicked
Keyboard focus the login form when shown
parents
3b2bd157
3bf49a2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
app.coffee
h/static/scripts/app.coffee
+1
-0
h-autofocus.js
h/static/scripts/directive/h-autofocus.js
+23
-0
auth.html
h/templates/client/auth.html
+1
-1
No files found.
h/static/scripts/app.coffee
View file @
e44d5770
...
...
@@ -109,6 +109,7 @@ module.exports = angular.module('h', [
.
directive
(
'formInput'
,
require
(
'./directive/form-input'
))
.
directive
(
'formValidate'
,
require
(
'./directive/form-validate'
))
.
directive
(
'groupList'
,
require
(
'./directive/group-list'
).
directive
)
.
directive
(
'hAutofocus'
,
require
(
'./directive/h-autofocus'
))
.
directive
(
'markdown'
,
require
(
'./directive/markdown'
))
.
directive
(
'simpleSearch'
,
require
(
'./directive/simple-search'
))
.
directive
(
'statusButton'
,
require
(
'./directive/status-button'
))
...
...
h/static/scripts/directive/h-autofocus.js
0 → 100644
View file @
e44d5770
'use strict'
;
/** An attribute directive that focuses an <input> when it's linked by Angular.
*
* The HTML5 autofocus attribute automatically puts the keyboard focus in an
* <input> on page load. But this doesn't work for <input>s that are
* rendered by JavaScript/Angular after page load, for example an <input> that
* is shown/hidden by JavaScript when an ng-if condition becomes true.
*
* To automatically put the keyboard focus on such an input when it's linked by
* Angular, attach this directive to it as an attribute:
*
* <input ng-if="..." h-autofocus>
*
*/
module
.
exports
=
function
()
{
return
{
restrict
:
'A'
,
link
:
function
(
$scope
,
$element
,
$attrs
)
{
$element
.
focus
();
}
};
};
h/templates/client/auth.html
View file @
e44d5770
...
...
@@ -23,7 +23,7 @@
<input
class=
"form-input"
type=
"text"
id=
"field-login-username"
name=
"username"
value=
""
ng-model=
"model.username"
required
autocapitalize=
"false"
/>
required
autocapitalize=
"false"
h-autofocus
/>
<ul
class=
"form-error-list"
>
<li
class=
"form-error"
ng-show=
"login.username.$error.required"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment