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
35bf9608
Commit
35bf9608
authored
Sep 26, 2016
by
Sean Roberts
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove use of .bind for click handler #137
parent
212ddc11
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
adder.js
h/static/scripts/annotator/adder.js
+16
-5
No files found.
h/static/scripts/annotator/adder.js
View file @
35bf9608
...
...
@@ -95,6 +95,7 @@ function createAdderDOM(container) {
*/
function
Adder
(
container
,
options
)
{
var
self
=
this
;
var
element
=
createAdderDOM
(
container
);
Object
.
assign
(
container
.
style
,
{
...
...
@@ -119,21 +120,23 @@ function Adder(container, options) {
var
enterTimeout
;
element
.
querySelector
(
'.js-annotate-btn'
)
.
addEventListener
(
'click'
,
handleCommand
.
bind
(
this
,
'annotate'
)
);
.
addEventListener
(
'click'
,
handleCommand
);
element
.
querySelector
(
'.js-highlight-btn'
)
.
addEventListener
(
'click'
,
handleCommand
.
bind
(
this
,
'highlight'
)
);
.
addEventListener
(
'click'
,
handleCommand
);
function
handleCommand
(
command
,
event
)
{
function
handleCommand
(
event
)
{
event
.
preventDefault
();
event
.
stopPropagation
();
if
(
command
===
'annotate'
)
{
var
isAnnotateCommand
=
this
.
classList
.
contains
(
'js-annotate-btn'
);
if
(
isAnnotateCommand
)
{
options
.
onAnnotate
();
}
else
{
options
.
onHighlight
();
}
this
.
hide
();
self
.
hide
();
}
function
width
()
{
...
...
@@ -221,6 +224,14 @@ function Adder(container, options) {
'annotator-adder--arrow-up'
:
arrowDirection
===
ARROW_POINTING_UP
,
});
// Some sites make big assumptions about interactive
// elements on the page. Some want to hide interactive elements
// after use. So we need to make sure the button stays displayed
// the way it was originally displayed - withouth the inline styles
// See: https://github.com/hypothesis/client/issues/137
this
.
element
.
querySelector
(
ANNOTATE_BTN_SELECTOR
).
style
.
display
=
''
;
this
.
element
.
querySelector
(
HIGHLIGHT_BTN_SELECTOR
).
style
.
display
=
''
;
Object
.
assign
(
container
.
style
,
{
top
:
toPx
(
top
),
left
:
toPx
(
left
),
...
...
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