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
6d5f7d94
Commit
6d5f7d94
authored
Sep 15, 2013
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor toolbar for multi-frame
parent
2227a706
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
14 deletions
+72
-14
guest.coffee
h/js/guest.coffee
+35
-8
services.coffee
h/js/services.coffee
+32
-0
toolbar.coffee
h/js/toolbar.coffee
+5
-6
No files found.
h/js/guest.coffee
View file @
6d5f7d94
...
...
@@ -12,6 +12,10 @@ class Annotator.Guest extends Annotator
options
:
Document
:
{}
# Internal state
tool
:
'comment'
visibleHighlights
:
false
constructor
:
(
element
,
options
)
->
Gettext
.
prototype
.
parse_locale_data
annotator_locale_data
...
...
@@ -80,6 +84,12 @@ class Annotator.Guest extends Annotator
}
)
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
this
.
setTool
name
)
.
bind
(
'setVisibleHighlights'
,
(
ctx
,
state
)
=>
this
.
setVisibleHighlights
state
)
scanDocument
:
(
reason
=
"something happened"
)
=>
try
console
.
log
"Analyzing host frame, because "
+
reason
+
"..."
...
...
@@ -132,7 +142,7 @@ class Annotator.Guest extends Annotator
return
confirm
"You have selected a very short piece of text: only "
+
length
+
" chars. Are you sure you want to highlight this?"
onSuccessfulSelection
:
(
event
)
->
if
@
highlightingMode
if
@
tool
is
'highlight'
# Do we really want to make this selection?
return
unless
this
.
confirmSelection
()
...
...
@@ -160,12 +170,12 @@ class Annotator.Guest extends Annotator
# When clicking on a highlight in highlighting mode,
# set @noBack to true to prevent the sidebar from closing
onHighlightMousedown
:
(
event
)
=>
if
@
highlightingMode
or
@
alwaysOnMode
then
@
noBack
=
true
if
(
@
tool
is
'highlight'
)
or
@
visibleHighlights
then
@
noBack
=
true
# When clicking on a highlight in highlighting mode,
# tell the sidebar to bring up the viewer for the relevant annotations
onHighlightClick
:
(
event
)
=>
return
unless
@
highlightingMode
or
@
alwaysOnMode
and
@
noBack
return
unless
(
@
tool
is
'highlight'
)
or
@
visibleHighlights
and
@
noBack
# Collect relevant annotations
annotations
=
$
(
event
.
target
)
...
...
@@ -179,13 +189,30 @@ class Annotator.Guest extends Annotator
# We have already prevented closing the sidebar, now reset this flag
@
noBack
=
false
setPersistentHighlights
:
(
state
)
->
body
=
$
(
'body'
)
setTool
:
(
name
)
->
@
tool
=
name
@
panel
?
.
notify
method
:
'setTool'
params
:
name
switch
name
when
'comment'
this
.
setVisibleHighlights
this
.
visibleHighlights
,
true
when
'highlight'
this
.
setVisibleHighlights
true
,
true
setVisibleHighlights
:
(
state
=
true
,
temporary
=
false
)
->
unless
temporary
@
visibleHighlights
=
state
@
panel
?
.
notify
method
:
'setVisibleHighlights'
params
:
state
markerClass
=
'annotator-highlights-always-on'
if
@
alwaysOnMode
or
@
highlightingMode
body
.
addClass
markerClass
if
state
or
(
@
tool
is
'highlight'
)
@
element
.
addClass
markerClass
else
body
.
removeClass
markerClass
@
element
.
removeClass
markerClass
addComment
:
->
sel
=
@
selectedRanges
# Save the selection
...
...
h/js/services.coffee
View file @
6d5f7d94
...
...
@@ -48,6 +48,9 @@ class Hypothesis extends Annotator
providers
:
null
host
:
null
tool
:
'comment'
visibleHighlights
:
false
# Here as a noop just to make the Permissions plugin happy
# XXX: Change me when Annotator stops assuming things about viewers
viewer
:
...
...
@@ -127,6 +130,14 @@ class Hypothesis extends Annotator
entities
.
push
href
this
.
plugins
.
Store
?
.
loadAnnotations
()
channel
.
notify
method
:
'setTool'
params
:
this
.
tool
channel
.
notify
method
:
'setVisibleHighlights'
params
:
this
.
visibleHighlights
@
providers
.
push
channel
:
channel
entities
:
entities
...
...
@@ -216,6 +227,12 @@ class Hypothesis extends Annotator
this
.
updateViewer
((
@
threading
.
getContainer
id
).
message
for
id
in
ids
)
)
.
bind
(
'setTool'
,
(
ctx
,
name
)
=>
this
.
setTool
name
)
.
bind
(
'setVisibleHighlights'
,
(
ctx
,
state
)
=>
this
.
setVisibleHighlights
state
)
_setupWrapper
:
->
@
wrapper
=
@
element
.
find
(
'#wrapper'
)
.
on
'mousewheel'
,
(
event
,
delta
)
->
...
...
@@ -422,6 +439,21 @@ class Hypothesis extends Annotator
angular
.
extend
@
options
.
Store
,
options
this
.
addPlugin
'Store'
,
@
options
.
Store
setTool
:
(
name
)
=>
return
if
name
is
@
tool
@
tool
=
name
for
p
in
@
providers
p
.
channel
.
notify
method
:
'setTool'
params
:
name
setVisibleHighlights
:
(
state
)
=>
return
if
state
is
@
visibleHighlights
@
visibleHighlights
=
state
for
p
in
@
providers
p
.
channel
.
notify
method
:
'setVisibleHighlights'
params
:
state
class
AuthenticationProvider
constructor
:
->
...
...
h/js/toolbar.coffee
View file @
6d5f7d94
...
...
@@ -21,9 +21,8 @@ class Annotator.Toolbar extends Annotator.Widget
"click"
:
(
event
)
->
event
.
preventDefault
()
event
.
stopPropagation
()
state
=
not
window
.
annotator
.
alwaysOnMode
window
.
annotator
.
alwaysOnMode
=
state
window
.
annotator
.
setPersistentHighlights
()
state
=
not
window
.
annotator
.
visibleHighlights
window
.
annotator
.
setVisibleHighlights
state
if
state
$
(
event
.
target
).
addClass
(
'pushed'
)
else
...
...
@@ -34,9 +33,9 @@ class Annotator.Toolbar extends Annotator.Widget
"click"
:
(
event
)
->
event
.
preventDefault
()
event
.
stopPropagation
()
state
=
not
window
.
annotator
.
highlightingMode
window
.
annotator
.
highlightingMode
=
state
window
.
annotator
.
set
PersistentHighlights
()
state
=
not
(
window
.
annotator
.
tool
is
'highlight'
)
tool
=
if
state
then
'highlight'
else
'comment'
window
.
annotator
.
set
Tool
tool
if
state
$
(
event
.
target
).
addClass
(
'pushed'
)
else
...
...
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