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
4c19128c
Commit
4c19128c
authored
Feb 09, 2015
by
Aron Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Host to show/hide the sidebar UI
Also removed a couple of unused event handlers.
parent
00e09913
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
36 deletions
+30
-36
host.coffee
h/static/scripts/host.coffee
+6
-32
host-test.coffee
tests/js/host-test.coffee
+24
-4
No files found.
h/static/scripts/host.coffee
View file @
4c19128c
...
...
@@ -31,6 +31,7 @@ class Annotator.Host extends Annotator.Guest
.
attr
(
'src'
,
src
)
super
element
,
options
,
dontScan
:
true
this
.
_addCrossFrameListeners
()
app
.
appendTo
(
@
frame
)
...
...
@@ -62,41 +63,14 @@ class Annotator.Host extends Annotator.Guest
@
frame
.
addClass
'annotator-no-transition'
@
frame
.
removeClass
'annotator-collapsed'
_setupXDM
:
(
options
)
->
channel
=
super
channel
.
bind
'showFrame'
,
(
ctx
)
=>
this
.
showFrame
()
.
bind
(
'hideFrame'
,
(
ctx
)
=>
hideFrame
:
->
@
frame
.
css
'margin-left'
:
''
@
frame
.
removeClass
'annotator-no-transition'
@
frame
.
addClass
'annotator-collapsed'
)
.
bind
(
'dragFrame'
,
(
ctx
,
screenX
)
=>
this
.
_dragUpdate
screenX
)
.
bind
(
'getMaxBottom'
,
=>
sel
=
'*'
+
(
":not(.annotator-
#{
x
}
)"
for
x
in
[
'adder'
,
'outer'
,
'notice'
,
'filter'
,
'frame'
]).
join
(
''
)
# use the maximum bottom position in the page
all
=
for
el
in
$
(
document
.
body
).
find
(
sel
)
p
=
$
(
el
).
css
(
'position'
)
t
=
$
(
el
).
offset
().
top
z
=
$
(
el
).
css
(
'z-index'
)
if
(
y
=
/\d+/
.
exec
(
$
(
el
).
css
(
'top'
))
?
[
0
])
t
=
Math
.
min
(
Number
y
,
t
)
if
(
p
==
'absolute'
or
p
==
'fixed'
)
and
t
==
0
and
z
!=
'auto'
bottom
=
$
(
el
).
outerHeight
(
false
)
# but don't go larger than 80, because this isn't bulletproof
if
bottom
>
80
then
0
else
bottom
else
0
Math
.
max
.
apply
(
Math
,
all
)
)
_addCrossFrameListeners
:
->
@
crossframe
.
on
(
'showFrame'
,
this
.
showFrame
.
bind
(
this
,
null
))
@
crossframe
.
on
(
'hideFrame'
,
this
.
hideFrame
.
bind
(
this
,
null
))
_setupDragEvents
:
->
el
=
document
.
createElementNS
'http://www.w3.org/1999/xhtml'
,
'canvas'
...
...
tests/js/host-test.coffee
View file @
4c19128c
...
...
@@ -3,8 +3,9 @@ sinon.assert.expose(assert, prefix: '')
describe
'Annotator.Host'
,
->
sandbox
=
sinon
.
sandbox
.
create
()
fakeCrossFrame
=
null
createHost
=
(
options
)
->
createHost
=
(
options
=
{}
)
->
element
=
document
.
createElement
(
'div'
)
return
new
Annotator
.
Host
(
element
,
options
)
...
...
@@ -12,9 +13,10 @@ describe 'Annotator.Host', ->
# Disable Annotator's ridiculous logging.
sandbox
.
stub
(
console
,
'log'
)
fakeCrossFrame
=
onConnect
:
sandbox
.
stub
()
on
:
sandbox
.
stub
()
fakeCrossFrame
=
{}
fakeCrossFrame
.
onConnect
=
sandbox
.
stub
().
returns
(
fakeCrossFrame
)
fakeCrossFrame
.
on
=
sandbox
.
stub
().
returns
(
fakeCrossFrame
)
fakeCrossFrame
.
notify
=
sandbox
.
stub
().
returns
(
fakeCrossFrame
)
sandbox
.
stub
(
Annotator
.
Plugin
,
'CrossFrame'
).
returns
(
fakeCrossFrame
)
...
...
@@ -34,3 +36,21 @@ describe 'Annotator.Host', ->
assert
.
isFalse
(
host
.
visibleHighlights
)
done
()
host
.
publish
(
'panelReady'
)
describe
'crossframe listeners'
,
->
emitHostEvent
=
(
event
,
args
...)
->
fn
(
args
...)
for
[
evt
,
fn
]
in
fakeCrossFrame
.
on
.
args
when
event
==
evt
describe
'on "showFrame" event'
,
->
it
'shows the frame'
,
->
target
=
sandbox
.
stub
(
Annotator
.
Host
.
prototype
,
'showFrame'
)
host
=
createHost
()
emitHostEvent
(
'showFrame'
)
assert
.
called
(
target
)
describe
'on "hideFrame" event'
,
->
it
'hides the frame'
,
->
target
=
sandbox
.
stub
(
Annotator
.
Host
.
prototype
,
'hideFrame'
)
host
=
createHost
()
emitHostEvent
(
'hideFrame'
)
assert
.
called
(
target
)
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