Show comment boxes for all annotations at the clicked point

This commit is contained in:
Amaia Castro
2017-02-24 13:43:32 +01:00
parent 83e4c2bd03
commit c7eaadb4b2
9 changed files with 137 additions and 116 deletions

View File

@@ -37,7 +37,9 @@ App.LegislationAnnotatable =
return
renderAnnotationComments: (event) ->
$('#comments-box').css({top: event.offset - $('.calc-comments').offset().top})
if event.offset
$("#comments-box").css({top: event.offset - $('.calc-comments').offset().top})
if App.LegislationAnnotatable.isMobile()
return
@@ -58,17 +60,30 @@ App.LegislationAnnotatable =
$('[data-annotation-id]').removeClass('current-annotation')
target = $(this)
parents = target.parents('.annotator-hl')
parents_ids = parents.map (_, elem) ->
$(elem).data("annotation-id")
annotation_id = target.data('annotation-id')
$('[data-annotation-id="'+annotation_id+'"]').addClass('current-annotation')
$('#comments-box').html('')
App.LegislationAllegations.show_comments()
$("#comments-box").show()
$.event.trigger
type: "renderLegislationAnnotation"
annotation_id: target.data("annotation-id")
annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url")
offset: target.offset()["top"]
parents_ids.each (i, pid) ->
$.event.trigger
type: "renderLegislationAnnotation"
annotation_id: pid
annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url")
isMobile: () ->
return window.innerWidth <= 652