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
4dfbfa2c
Commit
4dfbfa2c
authored
Sep 29, 2016
by
Robert Knight
Committed by
GitHub
Sep 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #141 from hypothesis/fix-prevent-default-override
Fix prevent default override
parents
212ddc11
ffca6a90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
adder.js
h/static/scripts/annotator/adder.js
+23
-7
No files found.
h/static/scripts/annotator/adder.js
View file @
4dfbfa2c
...
...
@@ -4,6 +4,11 @@ var classnames = require('classnames');
var
template
=
require
(
'./adder.html'
);
var
ANNOTATE_BTN_CLASS
=
'js-annotate-btn'
;
var
ANNOTATE_BTN_SELECTOR
=
'.js-annotate-btn'
;
var
HIGHLIGHT_BTN_SELECTOR
=
'.js-highlight-btn'
;
/**
* Show the adder above the selection with an arrow pointing down at the
* selected text.
...
...
@@ -95,6 +100,7 @@ function createAdderDOM(container) {
*/
function
Adder
(
container
,
options
)
{
var
self
=
this
;
var
element
=
createAdderDOM
(
container
);
Object
.
assign
(
container
.
style
,
{
...
...
@@ -118,22 +124,24 @@ function Adder(container, options) {
var
view
=
element
.
ownerDocument
.
defaultView
;
var
enterTimeout
;
element
.
querySelector
(
'.js-annotate-btn'
)
.
addEventListener
(
'click'
,
handleCommand
.
bind
(
this
,
'annotate'
)
);
element
.
querySelector
(
'.js-highlight-btn'
)
.
addEventListener
(
'click'
,
handleCommand
.
bind
(
this
,
'highlight'
)
);
element
.
querySelector
(
ANNOTATE_BTN_SELECTOR
)
.
addEventListener
(
'click'
,
handleCommand
);
element
.
querySelector
(
HIGHLIGHT_BTN_SELECTOR
)
.
addEventListener
(
'click'
,
handleCommand
);
function
handleCommand
(
command
,
event
)
{
function
handleCommand
(
event
)
{
event
.
preventDefault
();
event
.
stopPropagation
();
if
(
command
===
'annotate'
)
{
var
isAnnotateCommand
=
this
.
classList
.
contains
(
ANNOTATE_BTN_CLASS
);
if
(
isAnnotateCommand
)
{
options
.
onAnnotate
();
}
else
{
options
.
onHighlight
();
}
this
.
hide
();
self
.
hide
();
}
function
width
()
{
...
...
@@ -221,6 +229,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 - without 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