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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
41 deletions
+49
-41
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
+49
-41
No files found.
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
View file @
b7158e9f
...
@@ -2,11 +2,11 @@ class @Annotatable
...
@@ -2,11 +2,11 @@ class @Annotatable
@
_debug
:
true
@
_debug
:
true
wrapperSelector
:
'.annotatable-wrapper'
wrapperSelector
:
'.annotatable-wrapper'
toggleSelector
:
'.annotatable-toggle'
toggleSelector
:
'.annotatable-toggle'
spanSelector
:
'.annotatable-span'
spanSelector
:
'.annotatable-span'
commentSelector
:
'.annotatable-comment'
commentSelector
:
'.annotatable-comment'
replySelector
:
'.annotatable-reply'
replySelector
:
'.annotatable-reply'
helpSelector
:
'.annotatable-help-icon'
helpSelector
:
'.annotatable-help-icon'
constructor
:
(
el
)
->
constructor
:
(
el
)
->
console
.
log
'loaded Annotatable'
if
@
_debug
console
.
log
'loaded Annotatable'
if
@
_debug
...
@@ -26,10 +26,8 @@ class @Annotatable
...
@@ -26,10 +26,8 @@ class @Annotatable
@
$
(
@
wrapperSelector
).
delegate
@
replySelector
,
'click'
,
@
onClickReply
@
$
(
@
wrapperSelector
).
delegate
@
replySelector
,
'click'
,
@
onClickReply
initTips
:
()
->
initTips
:
()
->
@
visibleTips
=
[]
@
savedTips
=
[]
@
$
(
@
spanSelector
).
each
(
index
,
el
)
=>
@
$
(
@
spanSelector
).
each
(
index
,
el
)
=>
$
(
el
).
qtip
(
@
getTipOptions
el
)
$
(
el
).
qtip
(
@
getTipOptions
el
)
@
$
(
@
helpSelector
).
qtip
@
$
(
@
helpSelector
).
qtip
position
:
position
:
my
:
'right top'
my
:
'right top'
...
@@ -75,42 +73,42 @@ class @Annotatable
...
@@ -75,42 +73,42 @@ class @Annotatable
event
.
preventDefault
()
if
@
annotationsHidden
event
.
preventDefault
()
if
@
annotationsHidden
onClickToggleAnnotations
:
(
e
)
=>
onClickToggleAnnotations
:
(
e
)
=>
toggle
=
@
$
(
@
toggleSelector
)
@
annotationsHidden
=
not
@
annotationsHidden
spans
=
@
$
(
@
spanSelector
)
@
toggleButtonText
@
annotationsHidden
@
toggleSpans
@
annotationsHidden
@
annotationsHidden
=
!
@
annotationsHidden
@
toggleTips
@
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
)
onClickReply
:
(
e
)
=>
onClickReply
:
(
e
)
=>
hash
=
$
(
e
.
currentTarget
).
attr
(
'href'
)
hash
=
$
(
e
.
currentTarget
).
attr
(
'href'
)
if
hash
?
.
charAt
(
0
)
==
'#'
if
hash
?
.
charAt
(
0
)
==
'#'
name
=
hash
.
substr
(
1
)
name
=
hash
.
substr
(
1
)
anchor
=
$
(
"a[name='
#{
name
}
']"
).
first
()
anchor
=
$
(
"a[name='
#{
name
}
']"
).
first
()
@
scrollTo
(
anchor
)
if
anchor
.
length
==
1
@
scrollTo
(
anchor
)
scrollTo
:
(
el
,
padding
=
20
)
->
toggleTips
:
(
hide
)
->
props
=
if
hide
scrollTop
:
(
el
.
offset
().
top
-
padding
)
@
closeAndSaveTips
()
opts
=
else
duration
:
500
@
openSavedTips
()
complete
:
@
_once
->
el
.
effect
'highlight'
,
{},
2000
$
(
'html,body'
).
animate
(
props
,
opts
)
toggleButtonText
:
(
hide
)
->
buttonText
=
(
if
hide
then
'Show'
else
'Hide'
)
+
' Annotations'
@
$
(
@
toggleSelector
).
text
(
buttonText
)
toggleSpans
:
(
hide
)
->
@
$
(
@
spanSelector
).
toggleClass
'hide'
,
hide
scrollTo
:
(
el
)
->
options
=
duration
:
500
onAfter
:
@
_once
->
el
.
effect
'highlight'
,
{},
2000
$
(
'html,body'
).
scrollTo
(
el
,
options
)
makeTipContent
:
(
el
)
->
makeTipContent
:
(
el
)
->
(
api
)
=>
(
api
)
=>
comment
=
$
(
@
commentSelector
,
el
).
first
().
clone
()
anchor
=
$
(
el
).
data
(
'discussion-anchor'
)
anchor
=
$
(
el
).
data
(
'discussion-anchor'
)
if
anchor
comment
=
$
(
@
commentSelector
,
el
).
first
().
clone
()
comment
.
append
(
@
createReplyLink
(
anchor
))
comment
.
append
(
@
createReplyLink
(
anchor
))
if
anchor
comment
.
contents
()
comment
.
contents
()
makeTipTitle
:
(
el
)
->
makeTipTitle
:
(
el
)
->
...
@@ -120,9 +118,19 @@ class @Annotatable
...
@@ -120,9 +118,19 @@ class @Annotatable
(
if
title
then
title
else
'Commentary'
)
(
if
title
then
title
else
'Commentary'
)
createReplyLink
:
(
anchor
)
->
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
getVisibleTips
:
()
->
closeAndSaveTips
:
()
->
@
savedTips
=
@
findVisibleTips
()
@
hideTips
@
savedTips
findVisibleTips
:
()
->
visible
=
[]
visible
=
[]
@
$
(
@
spanSelector
).
each
(
index
,
el
)
->
@
$
(
@
spanSelector
).
each
(
index
,
el
)
->
api
=
$
(
el
).
qtip
(
'api'
)
api
=
$
(
el
).
qtip
(
'api'
)
...
@@ -130,16 +138,16 @@ class @Annotatable
...
@@ -130,16 +138,16 @@ class @Annotatable
if
tip
.
is
(
':visible'
)
if
tip
.
is
(
':visible'
)
visible
.
push
[
el
,
tip
.
offset
()]
visible
.
push
[
el
,
tip
.
offset
()]
visible
visible
hideTips
:
(
item
s
)
->
hideTips
:
(
pair
s
)
->
elements
=
(
pair
[
0
]
for
pair
in
item
s
)
elements
=
(
pair
[
0
]
for
pair
in
pair
s
)
$
(
elements
).
qtip
(
'hide'
)
$
(
elements
).
qtip
(
'hide'
)
showTips
:
(
items
)
->
showTips
:
(
pairs
)
->
$
.
each
items
,
(
index
,
item
)
->
$
.
each
pairs
,
(
index
,
pair
)
->
[
el
,
offset
]
=
item
[
el
,
offset
]
=
pair
$
(
el
).
qtip
(
'show'
)
api
=
$
(
el
).
qtip
(
'api'
)
api
=
$
(
el
).
qtip
(
'api'
)
api
?
.
show
()
$
(
api
?
.
elements
.
tooltip
).
offset
(
offset
)
$
(
api
?
.
elements
.
tooltip
).
offset
(
offset
)
_once
:
(
fn
)
->
_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