Commit 949603e3 by Arthur Barrett

Fixed issue with return link and scroll after effects.

parent 6b5bf319
...@@ -6,10 +6,11 @@ class @Annotatable ...@@ -6,10 +6,11 @@ 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'
returnSelector: '.annotatable-return'
discussionXModuleSelector: '.xmodule_DiscussionModule' discussionXModuleSelector: '.xmodule_DiscussionModule'
discussionSelector: '.discussion-module' discussionSelector: '.discussion-module'
constructor: (el) -> constructor: (el) ->
console.log 'loaded Annotatable' if @_debug console.log 'loaded Annotatable' if @_debug
...@@ -82,7 +83,8 @@ class @Annotatable ...@@ -82,7 +83,8 @@ class @Annotatable
onClickReturn: (e) => onClickReturn: (e) =>
e.preventDefault() e.preventDefault()
@scrollTo(@getSpan e.currentTarget, @afterScrollToSpan) span_el = @getSpan e.currentTarget
@scrollTo(span_el, @afterScrollToSpan)
getSpan: (el) -> getSpan: (el) ->
discussion_id = @getDiscussionId(el) discussion_id = @getDiscussionId(el)
...@@ -96,34 +98,38 @@ class @Annotatable ...@@ -96,34 +98,38 @@ class @Annotatable
$(el).data('discussion-id') $(el).data('discussion-id')
toggleAnnotations: () -> toggleAnnotations: () ->
@annotationsHidden = not @annotationsHidden hide = (@annotationsHidden = not @annotationsHidden)
@toggleButtonText @annotationsHidden @toggleButtonText hide
@toggleSpans @annotationsHidden @toggleSpans hide
@toggleTips @annotationsHidden @toggleReturnLinks hide
@toggleTips hide
toggleTips: (hide) -> toggleTips: (hide) ->
if hide then @closeAndSaveTips() else @openSavedTips() if hide then @closeAndSaveTips() else @openSavedTips()
toggleReturnLinks: (hide) ->
$(@returnSelector)[if hide then 'hide' else 'show']()
toggleButtonText: (hide) -> toggleButtonText: (hide) ->
buttonText = (if hide then 'Show' else 'Hide')+' Annotations' buttonText = (if hide then 'Show' else 'Hide')+' Annotations'
@$(@toggleSelector).text(buttonText) @$(@toggleSelector).text(buttonText)
toggleSpans: (hide) -> toggleSpans: (hide) ->
@$(@spanSelector).toggleClass 'hide', hide @$(@spanSelector).toggleClass 'hide', hide, 250
scrollTo: (el, after) -> scrollTo: (el, after = -> true) ->
$('html,body').scrollTo(el, { $('html,body').scrollTo(el, {
duration: 500 duration: 500
#onAfter: @_once => after.call this, el onAfter: @_once => after.call this, el
offset: -20
}) })
afterScrollToDiscussion: () -> afterScrollToDiscussion: (el) ->
(el) -> btn = $('.discussion-show', el)
btn = $('.discussion-show', el) btn.click() if !btn.hasClass('shown')
btn.click() if !btn.hasClass('shown')
afterScrollToSpan: (el) -> afterScrollToSpan: (el) ->
(el) -> el.effect('highlight', {}, 500) el.effect 'highlight', {color: 'rgba(0,0,0,0.5)' }, 1000
makeTipContent: (el) -> makeTipContent: (el) ->
(api) => (api) =>
...@@ -142,7 +148,7 @@ class @Annotatable ...@@ -142,7 +148,7 @@ class @Annotatable
$("<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) -> createReturnLink: (discussion_id) ->
$("<a class=\"annotatable-return button\" href=\"javascript:void(0);\" data-discussion-id=\"#{discussion_id}\">Return to annotation</a>") $("<a class=\"annotatable-return\" href=\"javascript:void(0);\" data-discussion-id=\"#{discussion_id}\">Return to annotation</a>")
openSavedTips: () -> openSavedTips: () ->
@showTips @savedTips @showTips @savedTips
......
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