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
435fd05e
Commit
435fd05e
authored
Feb 04, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the coffeescript behavior so it is a bit more testable.
parent
0ca71319
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
28 deletions
+73
-28
common/lib/xmodule/xmodule/css/annotatable/display.scss
+4
-0
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
+67
-24
lms/templates/annotatable.html
+2
-4
No files found.
common/lib/xmodule/xmodule/css/annotatable/display.scss
View file @
435fd05e
...
...
@@ -60,4 +60,8 @@ span.annotatable {
right
:
8px
;
margin-top
:
4px
;
}
&
.opaque
{
opacity
:
0
.4
;
}
}
common/lib/xmodule/xmodule/js/src/annotatable/display.coffee
View file @
435fd05e
class
@
Annotatable
@
_debug
:
true
wrapperSelector
:
'.annotatable-wrapper'
spanSelector
:
'span.annotatable[data-span-id]'
discussionSelector
:
'.annotatable-discussion[data-discussion-id]'
constructor
:
(
el
)
->
console
.
log
'loaded Annotatable'
if
@
_debug
@
el
=
el
@
spandata
=
$
(
'.annotatable-wrapper'
,
@
el
).
data
"spans"
@
initSpans
()
initSpans
:
()
->
selector
=
'span.annotatable[data-span-id]'
$
(
@
el
).
find
(
selector
).
on
'click'
,
(
e
)
=>
@
onClickSpan
.
call
this
,
e
onClickSpan
:
(
e
)
->
span_id
=
e
.
target
.
getAttribute
(
'data-span-id'
)
discussion_id
=
@
spandata
[
span_id
]
selector
=
'.annotatable-discussion[data-discussion-id="'
+
discussion_id
+
'"]'
;
$discussion
=
$
(
selector
,
@
el
)
padding
=
20
top
=
$discussion
.
offset
().
top
-
padding
highlighted
=
false
complete
=
()
->
if
!
highlighted
$discussion
.
effect
(
'highlight'
,
{},
1000
)
highlighted
=
true
$
(
'html, body'
).
animate
({
scrollTop
:
top
,
},
1000
,
'swing'
,
complete
)
@
init
()
init
:
()
->
@
loadSpanData
()
@
initEvents
()
initEvents
:
()
->
$
(
@
wrapperSelector
,
@
el
).
delegate
(
@
spanSelector
,
{
'click'
:
@
_bind
@
onSpanEvent
@
onClickSpan
'mouseenter'
:
@
_bind
@
onSpanEvent
@
onEnterSpan
'mouseleave'
:
@
_bind
@
onSpanEvent
@
onLeaveSpan
})
loadSpanData
:
()
->
@
spandata
=
$
(
@
wrapperSelector
,
@
el
).
data
(
'spans'
)
getDiscussionId
:
(
span_id
)
->
@
spandata
[
span_id
]
getDiscussionEl
:
(
discussion_id
)
->
$
(
@
discussionSelector
,
@
el
).
filter
(
'[data-discussion-id="'
+
discussion_id
+
'"]'
)
onSpanEvent
:
(
fn
)
->
(
e
)
=>
span_id
=
e
.
target
.
getAttribute
(
'data-span-id'
)
discussion_id
=
@
getDiscussionId
(
span_id
)
span
=
{
id
:
span_id
,
el
:
e
.
target
}
discussion
=
{
id
:
discussion_id
,
el
:
@
getDiscussionEl
(
discussion_id
)
}
fn
.
call
this
,
span
,
discussion
onClickSpan
:
(
span
,
discussion
)
->
@
scrollToDiscussion
(
discussion
.
el
)
onEnterSpan
:
(
span
,
discussion
)
->
$
(
@
discussionSelector
,
@
el
).
not
(
discussion
.
el
).
toggleClass
(
'opaque'
,
true
)
onLeaveSpan
:
(
span
,
discussion
)
->
$
(
@
discussionSelector
,
@
el
).
not
(
discussion
.
el
).
toggleClass
(
'opaque'
,
false
)
scrollToDiscussion
:
(
el
)
->
complete
=
@
makeHighlighter
(
el
)
top
=
el
.
offset
().
top
-
20
# with some padding
$
(
'html, body'
).
animate
({
scrollTop
:
top
},
750
,
'swing'
,
complete
)
makeHighlighter
:
(
el
)
->
return
@
_once
->
el
.
effect
(
'highlight'
,
{},
750
)
_once
:
(
fn
)
->
done
=
false
return
=>
fn
.
call
this
unless
done
done
=
true
_bind
:
(
fn
)
->
return
=>
fn
.
apply
(
this
,
arguments
)
lms/templates/annotatable.html
View file @
435fd05e
<div
class=
"annotatable-wrapper"
id=
"${element_id}"
>
<div
class=
"annotatable-wrapper"
id=
"${element_id}
-wrapper
"
>
<div
class=
"annotatable-header"
>
<div
class=
"help-icon"
></div>
...
...
@@ -14,9 +14,7 @@
<script>
$
(
function
()
{
// TODO pass spans to module directly
var
el
=
$
(
'#${element_id}.annotatable-wrapper'
);
el
.
data
(
'spans'
,
$
{
json_discussion_for
});
$
(
'#${element_id}-wrapper'
).
data
(
'spans'
,
$
{
json_discussion_for
});
});
</script>
...
...
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