Commit 2097b693 by Arthur Barrett

Added button to show/hide guided notes and discussions.

parent 45e4c0cf
...@@ -14,12 +14,24 @@ ...@@ -14,12 +14,24 @@
} }
} }
.annotatable-toggle {
display: block;
font-size: $body-font-size;
}
span.annotatable { span.annotatable {
color: $blue; color: $blue;
cursor: pointer; cursor: pointer;
.annotatable-icon { .annotatable-icon {
margin: auto 2px auto 4px; margin: auto 2px auto 4px;
} }
&.hide {
cursor: none;
color: inherit;
.annotatable-icon {
display: none;
}
}
} }
.annotatable-icon { .annotatable-icon {
...@@ -64,4 +76,7 @@ span.annotatable { ...@@ -64,4 +76,7 @@ span.annotatable {
&.opaque { &.opaque {
opacity: 0.4; opacity: 0.4;
} }
&.hide {
display: none;
}
} }
...@@ -4,6 +4,7 @@ class @Annotatable ...@@ -4,6 +4,7 @@ class @Annotatable
wrapperSelector: '.annotatable-wrapper' wrapperSelector: '.annotatable-wrapper'
spanSelector: 'span.annotatable[data-span-id]' spanSelector: 'span.annotatable[data-span-id]'
discussionSelector: '.annotatable-discussion[data-discussion-id]' discussionSelector: '.annotatable-discussion[data-discussion-id]'
toggleSelector: '.annotatable-toggle'
constructor: (el) -> constructor: (el) ->
console.log 'loaded Annotatable' if @_debug console.log 'loaded Annotatable' if @_debug
...@@ -11,10 +12,14 @@ class @Annotatable ...@@ -11,10 +12,14 @@ class @Annotatable
@init() @init()
init: () -> init: () ->
@hideAnnotations = false
@spandata = {}
@loadSpanData() @loadSpanData()
@initEvents() @initEvents()
initEvents: () -> initEvents: () ->
$(@toggleSelector, @el).bind('click', @_bind @onClickToggleAnnotations)
$(@wrapperSelector, @el).delegate(@spanSelector, { $(@wrapperSelector, @el).delegate(@spanSelector, {
'click': @_bind @onSpanEvent @onClickSpan 'click': @_bind @onSpanEvent @onClickSpan
'mouseenter': @_bind @onSpanEvent @onEnterSpan 'mouseenter': @_bind @onSpanEvent @onEnterSpan
...@@ -30,6 +35,11 @@ class @Annotatable ...@@ -30,6 +35,11 @@ class @Annotatable
getDiscussionEl: (discussion_id) -> getDiscussionEl: (discussion_id) ->
$(@discussionSelector, @el).filter('[data-discussion-id="'+discussion_id+'"]') $(@discussionSelector, @el).filter('[data-discussion-id="'+discussion_id+'"]')
onClickToggleAnnotations: (e) ->
@hideAnnotations = !@hideAnnotations
$(@spanSelector, @el).add(@discussionSelector, @el).toggleClass('hide', @hideAnnotations)
$(@toggleSelector, @el).text(if @hideAnnotations then 'Show Annotations' else 'Hide Annotations')
onSpanEvent: (fn) -> onSpanEvent: (fn) ->
(e) => (e) =>
span_el = e.currentTarget span_el = e.currentTarget
...@@ -44,7 +54,8 @@ class @Annotatable ...@@ -44,7 +54,8 @@ class @Annotatable
id: discussion_id id: discussion_id
el: discussion_el el: discussion_el
} }
fn.call this, span, discussion if !@hideAnnotations
fn.call this, span, discussion
onClickSpan: (span, discussion) -> onClickSpan: (span, discussion) ->
@scrollToDiscussion(discussion.el) @scrollToDiscussion(discussion.el)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<div class="annotatable-title">${display_name} </div> <div class="annotatable-title">${display_name} </div>
% endif % endif
<div class="annotatable-description">Annotated Reading + Guided Discussion</div> <div class="annotatable-description">Annotated Reading + Guided Discussion</div>
<a href="javascript:void(0)" class="annotatable-toggle">Hide Annotations</a>
</div> </div>
<div class="annotatable-content"> <div class="annotatable-content">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment