Commit 6b5bf319 by Arthur Barrett

Style and behavior changes. Added return links to discussions.

parent 0c70d201
...@@ -50,18 +50,13 @@ class AnnotatableModule(XModule): ...@@ -50,18 +50,13 @@ class AnnotatableModule(XModule):
del span.attrib['discussion'] del span.attrib['discussion']
def _decorate_span(self, span, index, xmltree): def _decorate_span(self, span, index, xmltree):
""" Decorates the span highlight. """ """ Adds a highlight class to the span. """
cls = ['annotatable-span', 'highlight'] cls = ['annotatable-span', 'highlight']
marker = self._get_marker_color(span) marker = self._get_marker_color(span)
if marker is not None: if marker is not None:
cls.append('highlight-'+marker) cls.append('highlight-'+marker)
icon = etree.Element('span', { 'class': 'annotatable-icon ss-icon ss-textchat' })
icon.append(etree.Entity('#xE396'))
icon.tail = span.text
span.text = ''
span.insert(0, icon)
span.set('class', ' '.join(cls)) span.set('class', ' '.join(cls))
span.tag = 'div' span.tag = 'div'
...@@ -79,7 +74,7 @@ class AnnotatableModule(XModule): ...@@ -79,7 +74,7 @@ class AnnotatableModule(XModule):
comment.set('class', 'annotatable-comment') comment.set('class', 'annotatable-comment')
def _get_marker_color(self, span): def _get_marker_color(self, span):
""" Returns the name of the marker color for the span if it is valid, otherwise none.""" """ Returns the name of the marker/highlight color for the span if it is valid, otherwise none."""
valid_markers = ['yellow', 'orange', 'purple', 'blue', 'green'] valid_markers = ['yellow', 'orange', 'purple', 'blue', 'green']
if 'marker' in span.attrib: if 'marker' in span.attrib:
...@@ -88,7 +83,7 @@ class AnnotatableModule(XModule): ...@@ -88,7 +83,7 @@ class AnnotatableModule(XModule):
if marker in valid_markers: if marker in valid_markers:
return marker return marker
return None return None
def _render(self): def _render(self):
""" Renders annotatable content by transforming spans and adding discussions. """ """ Renders annotatable content by transforming spans and adding discussions. """
...@@ -98,6 +93,7 @@ class AnnotatableModule(XModule): ...@@ -98,6 +93,7 @@ class AnnotatableModule(XModule):
self._decorate_span, self._decorate_span,
self._decorate_comment self._decorate_comment
]) ])
xmltree.tag = 'div'
return etree.tostring(xmltree) return etree.tostring(xmltree)
...@@ -120,8 +116,6 @@ class AnnotatableModule(XModule): ...@@ -120,8 +116,6 @@ class AnnotatableModule(XModule):
self.element_id = self.location.html_id(); self.element_id = self.location.html_id();
self.content = self.definition['data'] self.content = self.definition['data']
self.spans = {}
class AnnotatableDescriptor(RawDescriptor): class AnnotatableDescriptor(RawDescriptor):
module_class = AnnotatableModule module_class = AnnotatableModule
......
.annotatable-header { .annotatable-header {
margin-bottom: 1em; margin-bottom: 1em;
.annotatable-title { .annotatable-title {
font-size: em(20); font-size: em(22);
text-transform: uppercase; text-transform: uppercase;
padding: 2px 4px; padding: 2px 4px;
} }
.annotatable-description { .annotatable-description {
position: relative; position: relative;
font-size: em(14); font-size: $body-font-size;
padding: 2px 4px; padding: 2px 4px;
border: 1px solid $border-color; border: 1px solid $border-color;
border-radius: 3px; border-radius: 3px;
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
background: url(../images/info-icon.png) no-repeat; background: url(../images/info-icon.png) no-repeat;
} }
.ui-tooltip.qtip.ui-tooltip-annotatable { .ui-tooltip.qtip.ui-tooltip {
font-size: $body-font-size;
border: 1px solid #333; border: 1px solid #333;
border-radius: 1em; border-radius: 1em;
background-color: rgba(0,0,0,.85); background-color: rgba(0,0,0,.85);
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
.ui-tooltip-titlebar { .ui-tooltip-titlebar {
font-size: em(16);
color: inherit; color: inherit;
background-color: transparent; background-color: transparent;
padding: 5px 10px; padding: 5px 10px;
...@@ -85,26 +87,30 @@ ...@@ -85,26 +87,30 @@
} }
.ui-tooltip-content { .ui-tooltip-content {
color: inherit; color: inherit;
background-color: transparent; font-size: em(14);
text-align: left; text-align: left;
font-weight: 400; font-weight: 400;
font-size: 11px; padding: 0 10px 10px 10px;
padding: 0 10px; background-color: transparent;
} }
p { color: inherit; } p {
color: inherit;
line-height: normal;
}
} }
.ui-tooltip.qtip.ui-tooltip-annotatable-comment { .ui-tooltip.qtip.ui-tooltip-annotatable {
max-width: 350px; max-width: 350px;
.ui-tooltip-title:before { .ui-tooltip-title:before {
font-weight: normal; font-weight: normal;
content: "Guided Discussion: "; content: "Guided Discussion: ";
} }
.ui-tooltip-content { .ui-tooltip-content {
padding: 0 10px;
.annotatable-comment { .annotatable-comment {
display: block; display: block;
margin: 0px 0px 10px 0; margin: 0px 0px 10px 0;
max-height: 200px; max-height: 175px;
overflow: hidden; overflow: hidden;
} }
.annotatable-reply { .annotatable-reply {
...@@ -127,4 +133,4 @@ ...@@ -127,4 +133,4 @@
border: 10px solid transparent; border: 10px solid transparent;
border-top-color: rgba(0, 0, 0, .85); border-top-color: rgba(0, 0, 0, .85);
} }
} }
\ No newline at end of file
...@@ -6,8 +6,10 @@ class @Annotatable ...@@ -6,8 +6,10 @@ class @Annotatable
spanSelector: '.annotatable-span' spanSelector: '.annotatable-span'
commentSelector: '.annotatable-comment' commentSelector: '.annotatable-comment'
replySelector: '.annotatable-reply' replySelector: '.annotatable-reply'
returnSelector: '.annotatable-return'
helpSelector: '.annotatable-help-icon' helpSelector: '.annotatable-help-icon'
inlineDiscussionSelector: '.xmodule_DiscussionModule .discussion-module' discussionXModuleSelector: '.xmodule_DiscussionModule'
discussionSelector: '.discussion-module'
constructor: (el) -> constructor: (el) ->
console.log 'loaded Annotatable' if @_debug console.log 'loaded Annotatable' if @_debug
...@@ -20,11 +22,13 @@ class @Annotatable ...@@ -20,11 +22,13 @@ class @Annotatable
init: () -> init: () ->
@initEvents() @initEvents()
@initTips() @initTips()
@initDiscussionReturnLinks()
initEvents: () -> initEvents: () ->
@annotationsHidden = false @annotationsHidden = false
@$(@toggleSelector).bind 'click', @onClickToggleAnnotations @$(@toggleSelector).bind 'click', @onClickToggleAnnotations
@$(@wrapperSelector).delegate @replySelector, 'click', @onClickReply @$(@wrapperSelector).delegate @replySelector, 'click', @onClickReply
$(@discussionXModuleSelector).delegate @returnSelector, 'click', @onClickReturn
initTips: () -> initTips: () ->
@savedTips = [] @savedTips = []
...@@ -35,13 +39,12 @@ class @Annotatable ...@@ -35,13 +39,12 @@ class @Annotatable
at: 'bottom left' at: 'bottom left'
container: @$(@wrapperSelector) container: @$(@wrapperSelector)
content: content:
title: 'Annotated Reading Help' title: 'Annotated Reading'
text: "Move your cursor over the highlighted areas to display annotations. text: true # use title attribute of this element
Discuss the annotations in the forums using the link at the
bottom of the annotation. You may hide annotations at any time by initDiscussionReturnLinks: () ->
using the button at the top of the section." $(@discussionXModuleSelector).find(@discussionSelector).each (index, el) =>
style: $(el).after @createReturnLink(@getDiscussionId el)
classes: 'ui-tooltip-annotatable'
getTipOptions: (el) -> getTipOptions: (el) ->
content: content:
...@@ -62,7 +65,7 @@ class @Annotatable ...@@ -62,7 +65,7 @@ class @Annotatable
hide: hide:
event: 'unfocus' event: 'unfocus'
style: style:
classes: 'ui-tooltip-annotatable ui-tooltip-annotatable-comment' classes: 'ui-tooltip-annotatable'
events: events:
show: @onShowTip show: @onShowTip
...@@ -74,11 +77,20 @@ class @Annotatable ...@@ -74,11 +77,20 @@ class @Annotatable
onClickReply: (e) => onClickReply: (e) =>
e.preventDefault() e.preventDefault()
@scrollTo(@getInlineDiscussion e.currentTarget) discussion_el = @getInlineDiscussion e.currentTarget
@scrollTo(discussion_el, @afterScrollToDiscussion)
onClickReturn: (e) =>
e.preventDefault()
@scrollTo(@getSpan e.currentTarget, @afterScrollToSpan)
getSpan: (el) ->
discussion_id = @getDiscussionId(el)
@$(@spanSelector).filter("[data-discussion-id='#{discussion_id}']")
getInlineDiscussion: (el) -> getInlineDiscussion: (el) ->
discussion_id = @getDiscussionId(el) discussion_id = @getDiscussionId(el)
$(@inlineDiscussionSelector).filter("[data-discussion-id='#{discussion_id}']") $(@discussionXModuleSelector).find(@discussionSelector).filter("[data-discussion-id='#{discussion_id}']")
getDiscussionId: (el) -> getDiscussionId: (el) ->
$(el).data('discussion-id') $(el).data('discussion-id')
...@@ -99,18 +111,19 @@ class @Annotatable ...@@ -99,18 +111,19 @@ class @Annotatable
toggleSpans: (hide) -> toggleSpans: (hide) ->
@$(@spanSelector).toggleClass 'hide', hide @$(@spanSelector).toggleClass 'hide', hide
scrollTo: (el) -> scrollTo: (el, after) ->
$('html,body').scrollTo(el, { $('html,body').scrollTo(el, {
duration: 500, duration: 500
onAfter: @makeAfterScroll(el) #onAfter: @_once => after.call this, el
}) })
makeAfterScroll: (el, duration = 1500) -> afterScrollToDiscussion: () ->
@_once -> (el) ->
btn = $('.discussion-show', el) btn = $('.discussion-show', el)
if !btn.hasClass('shown') btn.click() if !btn.hasClass('shown')
btn.click()
#el.effect 'highlight', {}, duration afterScrollToSpan: (el) ->
(el) -> el.effect('highlight', {}, 500)
makeTipContent: (el) -> makeTipContent: (el) ->
(api) => (api) =>
...@@ -128,6 +141,9 @@ class @Annotatable ...@@ -128,6 +141,9 @@ class @Annotatable
createReplyLink: (discussion_id) -> createReplyLink: (discussion_id) ->
$("<a class=\"annotatable-reply\" href=\"javascript:void(0);\" data-discussion-id=\"#{discussion_id}\">See Full Discussion</a>") $("<a class=\"annotatable-reply\" href=\"javascript:void(0);\" data-discussion-id=\"#{discussion_id}\">See Full Discussion</a>")
createReturnLink: (discussion_id) ->
$("<a class=\"annotatable-return button\" href=\"javascript:void(0);\" data-discussion-id=\"#{discussion_id}\">Return to annotation</a>")
openSavedTips: () -> openSavedTips: () ->
@showTips @savedTips @showTips @savedTips
......
...@@ -4,10 +4,9 @@ ...@@ -4,10 +4,9 @@
<div class="annotatable-title">${display_name} </div> <div class="annotatable-title">${display_name} </div>
% endif % endif
<div class="annotatable-description"> <div class="annotatable-description">
<div class="annotatable-help-icon"></div> <div class="annotatable-help-icon" title="Move your cursor over the highlighted areas to display annotations. Discuss the annotations in the forums using the link at the bottom of the annotation. You may hide annotations at any time by using the button at the top of the section."></div>
Annotated Reading + Guided Discussion<br/> Annotated Reading + Guided Discussion<br/>
<a href="javascript:void(0)" class="annotatable-toggle">Hide Annotations</a> <a href="javascript:void(0)" class="annotatable-toggle">Hide Annotations</a>
</div> </div>
</div> </div>
......
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