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
fbe1a9f9
Unverified
Commit
fbe1a9f9
authored
Oct 11, 2019
by
Kyle Keating
Committed by
GitHub
Oct 11, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1382 from hypothesis/aria-sidebar-state
Improve accessability for toggle buttons
parents
b00d4670
ab3d902f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
toolbar.coffee
src/annotator/plugin/toolbar.coffee
+18
-4
annotator.scss
src/styles/annotator/annotator.scss
+1
-2
No files found.
src/annotator/plugin/toolbar.coffee
View file @
fbe1a9f9
...
@@ -6,6 +6,7 @@ makeButton = (item) ->
...
@@ -6,6 +6,7 @@ makeButton = (item) ->
.
attr
(
'href'
,
''
)
.
attr
(
'href'
,
''
)
.
attr
(
'title'
,
item
.
title
)
.
attr
(
'title'
,
item
.
title
)
.
attr
(
'name'
,
item
.
name
)
.
attr
(
'name'
,
item
.
name
)
.
attr
(
'aria-pressed'
,
item
.
ariaPressed
)
.
on
(
item
.
on
)
.
on
(
item
.
on
)
.
addClass
(
'annotator-frame-button'
)
.
addClass
(
'annotator-frame-button'
)
.
addClass
(
item
.
class
)
.
addClass
(
item
.
class
)
...
@@ -26,6 +27,15 @@ module.exports = class Toolbar extends Plugin
...
@@ -26,6 +27,15 @@ module.exports = class Toolbar extends Plugin
$
(
@
options
.
container
).
append
@
toolbar
$
(
@
options
.
container
).
append
@
toolbar
else
else
$
(
@
element
).
append
@
toolbar
$
(
@
element
).
append
@
toolbar
# https://h.readthedocs.io/projects/client/en/latest/publishers/config/?highlight=onLoginRequest#cmdoption-arg-showhighlights
highlightsAreVisible
=
true
;
# default to on
showHighlightsConfig
=
window
.
hypothesisConfig
().
showHighlights
;
if
showHighlightsConfig
==
'always'
||
showHighlightsConfig
==
true
highlightsAreVisible
=
true
else
if
showHighlightsConfig
==
false
||
showHighlightsConfig
==
'never'
highlightsAreVisible
=
false
items
=
[
items
=
[
"title"
:
"Close Sidebar"
"title"
:
"Close Sidebar"
...
@@ -39,6 +49,7 @@ module.exports = class Toolbar extends Plugin
...
@@ -39,6 +49,7 @@ module.exports = class Toolbar extends Plugin
@
toolbar
.
find
(
'[name=sidebar-close]'
).
hide
();
@
toolbar
.
find
(
'[name=sidebar-close]'
).
hide
();
,
,
"title"
:
"Toggle or Resize Sidebar"
"title"
:
"Toggle or Resize Sidebar"
"ariaPressed"
:
!!
window
.
hypothesisConfig
().
openSidebar
"class"
:
"annotator-frame-button--sidebar_toggle h-icon-chevron-left"
"class"
:
"annotator-frame-button--sidebar_toggle h-icon-chevron-left"
"name"
:
"sidebar-toggle"
"name"
:
"sidebar-toggle"
"on"
:
"on"
:
...
@@ -48,12 +59,15 @@ module.exports = class Toolbar extends Plugin
...
@@ -48,12 +59,15 @@ module.exports = class Toolbar extends Plugin
collapsed
=
@
annotator
.
frame
.
hasClass
(
'annotator-collapsed'
)
collapsed
=
@
annotator
.
frame
.
hasClass
(
'annotator-collapsed'
)
if
collapsed
if
collapsed
@
annotator
.
show
()
@
annotator
.
show
()
event
.
target
.
setAttribute
(
'aria-pressed'
,
true
);
else
else
@
annotator
.
hide
()
@
annotator
.
hide
()
event
.
target
.
setAttribute
(
'aria-pressed'
,
false
);
,
,
"title"
:
"
Hide Highlights
"
"title"
:
"
Toggle Highlights Visibility
"
"class"
:
"h-icon-visibility"
"class"
:
if
highlightsAreVisible
then
'h-icon-visibility'
else
'h-icon-visibility-off'
"name"
:
"highlight-visibility"
"name"
:
"highlight-visibility"
"ariaPressed"
:
highlightsAreVisible
"on"
:
"on"
:
"click"
:
(
event
)
=>
"click"
:
(
event
)
=>
event
.
preventDefault
()
event
.
preventDefault
()
...
@@ -87,12 +101,12 @@ module.exports = class Toolbar extends Plugin
...
@@ -87,12 +101,12 @@ module.exports = class Toolbar extends Plugin
$
(
'[name=highlight-visibility]'
)
$
(
'[name=highlight-visibility]'
)
.
removeClass
(
'h-icon-visibility-off'
)
.
removeClass
(
'h-icon-visibility-off'
)
.
addClass
(
'h-icon-visibility'
)
.
addClass
(
'h-icon-visibility'
)
.
prop
(
'title'
,
'Hide Highlights'
);
.
attr
(
'aria-pressed'
,
'true'
)
else
else
$
(
'[name=highlight-visibility]'
)
$
(
'[name=highlight-visibility]'
)
.
removeClass
(
'h-icon-visibility'
)
.
removeClass
(
'h-icon-visibility'
)
.
addClass
(
'h-icon-visibility-off'
)
.
addClass
(
'h-icon-visibility-off'
)
.
prop
(
'title'
,
'Show Highlights'
);
.
attr
(
'aria-pressed'
,
'false'
)
disableMinimizeBtn
:
()
->
disableMinimizeBtn
:
()
->
$
(
'[name=sidebar-toggle]'
).
remove
();
$
(
'[name=sidebar-toggle]'
).
remove
();
...
...
src/styles/annotator/annotator.scss
View file @
fbe1a9f9
...
@@ -107,7 +107,7 @@ $base-font-size: 14px;
...
@@ -107,7 +107,7 @@ $base-font-size: 14px;
}
}
.annotator-frame-button
{
.annotator-frame-button
{
transition
:
background-color
0
.25s
0
.25s
;
transition
:
background-color
0
.25s
;
@include
smallshadow
;
@include
smallshadow
;
background
:
$white
;
background
:
$white
;
border
:
solid
1px
$gray-lighter
;
border
:
solid
1px
$gray-lighter
;
...
@@ -121,7 +121,6 @@ $base-font-size: 14px;
...
@@ -121,7 +121,6 @@ $base-font-size: 14px;
margin-bottom
:
5px
;
margin-bottom
:
5px
;
&
:active
{
&
:active
{
transition
:
background-color
0
.25s
;
background-color
:
$gray-light
;
background-color
:
$gray-light
;
}
}
...
...
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