Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
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
edx
edx-platform
Commits
b7158e9f
Commit
b7158e9f
authored
Feb 09, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switched to $.scrollTo instead of custom animation and refactored toggle method.
parent
5fc7f1a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
36 deletions
+44
-36
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
+44
-36
No files found.
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
View file @
b7158e9f
...
...
@@ -26,10 +26,8 @@ class @Annotatable
@
$
(
@
wrapperSelector
).
delegate
@
replySelector
,
'click'
,
@
onClickReply
initTips
:
()
->
@
visibleTips
=
[]
@
$
(
@
spanSelector
).
each
(
index
,
el
)
=>
$
(
el
).
qtip
(
@
getTipOptions
el
)
@
savedTips
=
[]
@
$
(
@
spanSelector
).
each
(
index
,
el
)
=>
$
(
el
).
qtip
(
@
getTipOptions
el
)
@
$
(
@
helpSelector
).
qtip
position
:
my
:
'right top'
...
...
@@ -75,42 +73,42 @@ class @Annotatable
event
.
preventDefault
()
if
@
annotationsHidden
onClickToggleAnnotations
:
(
e
)
=>
toggle
=
@
$
(
@
toggleSelector
)
spans
=
@
$
(
@
spanSelector
)
@
annotationsHidden
=
!
@
annotationsHidden
if
@
annotationsHidden
spans
.
toggleClass
(
'hide'
,
true
)
toggle
.
text
(
'Show Annotations'
)
@
visibleTips
=
@
getVisibleTips
()
@
hideTips
(
@
visibleTips
)
else
spans
.
toggleClass
(
'hide'
,
false
)
toggle
.
text
(
'Hide Annotations'
)
@
showTips
(
@
visibleTips
)
@
annotationsHidden
=
not
@
annotationsHidden
@
toggleButtonText
@
annotationsHidden
@
toggleSpans
@
annotationsHidden
@
toggleTips
@
annotationsHidden
onClickReply
:
(
e
)
=>
hash
=
$
(
e
.
currentTarget
).
attr
(
'href'
)
if
hash
?
.
charAt
(
0
)
==
'#'
name
=
hash
.
substr
(
1
)
anchor
=
$
(
"a[name='
#{
name
}
']"
).
first
()
@
scrollTo
(
anchor
)
if
anchor
.
length
==
1
@
scrollTo
(
anchor
)
scrollTo
:
(
el
,
padding
=
20
)
->
props
=
scrollTop
:
(
el
.
offset
().
top
-
padding
)
opts
=
duration
:
500
complete
:
@
_once
->
el
.
effect
'highlight'
,
{},
2000
toggleTips
:
(
hide
)
->
if
hide
@
closeAndSaveTips
()
else
@
openSavedTips
()
toggleButtonText
:
(
hide
)
->
buttonText
=
(
if
hide
then
'Show'
else
'Hide'
)
+
' Annotations'
@
$
(
@
toggleSelector
).
text
(
buttonText
)
$
(
'html,body'
).
animate
(
props
,
opts
)
toggleSpans
:
(
hide
)
->
@
$
(
@
spanSelector
).
toggleClass
'hide'
,
hide
scrollTo
:
(
el
)
->
options
=
duration
:
500
onAfter
:
@
_once
->
el
.
effect
'highlight'
,
{},
2000
$
(
'html,body'
).
scrollTo
(
el
,
options
)
makeTipContent
:
(
el
)
->
(
api
)
=>
comment
=
$
(
@
commentSelector
,
el
).
first
().
clone
()
anchor
=
$
(
el
).
data
(
'discussion-anchor'
)
if
anchor
comment
.
append
(
@
createReplyLink
(
anchor
))
comment
=
$
(
@
commentSelector
,
el
).
first
().
clone
()
comment
.
append
(
@
createReplyLink
(
anchor
))
if
anchor
comment
.
contents
()
makeTipTitle
:
(
el
)
->
...
...
@@ -120,9 +118,19 @@ class @Annotatable
(
if
title
then
title
else
'Commentary'
)
createReplyLink
:
(
anchor
)
->
$
(
"<a class=
\"
annotatable-reply
\"
href=
\"
#
#{
anchor
}
\"
>Reply to this comment</a>"
)
cls
=
'annotatable-reply'
href
=
'#'
+
anchor
text
=
'Reply to this comment'
$
(
"<a class=
\"
#{
cls
}
\"
href=
\"
#{
href
}
\"
>
#{
text
}
</a>"
)
openSavedTips
:
()
->
@
showTips
@
savedTips
closeAndSaveTips
:
()
->
@
savedTips
=
@
findVisibleTips
()
@
hideTips
@
savedTips
get
VisibleTips
:
()
->
find
VisibleTips
:
()
->
visible
=
[]
@
$
(
@
spanSelector
).
each
(
index
,
el
)
->
api
=
$
(
el
).
qtip
(
'api'
)
...
...
@@ -131,15 +139,15 @@ class @Annotatable
visible
.
push
[
el
,
tip
.
offset
()]
visible
hideTips
:
(
item
s
)
->
elements
=
(
pair
[
0
]
for
pair
in
item
s
)
hideTips
:
(
pair
s
)
->
elements
=
(
pair
[
0
]
for
pair
in
pair
s
)
$
(
elements
).
qtip
(
'hide'
)
showTips
:
(
items
)
->
$
.
each
items
,
(
index
,
item
)
->
[
el
,
offset
]
=
item
showTips
:
(
pairs
)
->
$
.
each
pairs
,
(
index
,
pair
)
->
[
el
,
offset
]
=
pair
$
(
el
).
qtip
(
'show'
)
api
=
$
(
el
).
qtip
(
'api'
)
api
?
.
show
()
$
(
api
?
.
elements
.
tooltip
).
offset
(
offset
)
_once
:
(
fn
)
->
...
...
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