Fix annotation highlight on click

This commit is contained in:
Amaia Castro
2017-02-23 16:04:55 +01:00
parent 7061d70f22
commit 20bfe5e0e5
2 changed files with 5 additions and 9 deletions

View File

@@ -57,11 +57,7 @@ App.LegislationAnnotatable =
$('[data-annotation-id]').removeClass('current-annotation') $('[data-annotation-id]').removeClass('current-annotation')
parent = $(this).parents('[data-annotation-id]:eq(0)') target = $(this)
if parent.length
target = parent
else
target = $(this)
annotation_id = target.data('annotation-id') annotation_id = target.data('annotation-id')
$('[data-annotation-id="'+annotation_id+'"]').addClass('current-annotation') $('[data-annotation-id="'+annotation_id+'"]').addClass('current-annotation')
@@ -69,9 +65,9 @@ App.LegislationAnnotatable =
$("#comments-box").show() $("#comments-box").show()
$.event.trigger $.event.trigger
type: "renderLegislationAnnotation" type: "renderLegislationAnnotation"
annotation_id: $(event.target).data("annotation-id") annotation_id: target.data("annotation-id")
annotation_url: $(event.target).closest(".legislation-annotatable").data("legislation-annotatable-base-url") annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url")
offset: $(event.target).offset()["top"] offset: target.offset()["top"]
isMobile: () -> isMobile: () ->
return window.innerWidth <= 652 return window.innerWidth <= 652

View File

@@ -48,7 +48,7 @@ class Legislation::AnnotationsController < ApplicationController
end end
def search def search
@annotations = @draft_version.annotations @annotations = @draft_version.annotations.order("LENGTH(quote) DESC")
annotations_hash = { total: @annotations.size, rows: @annotations } annotations_hash = { total: @annotations.size, rows: @annotations }
render json: annotations_hash.to_json render json: annotations_hash.to_json
end end