diff --git a/app/assets/javascripts/legislation_annotatable.js.coffee b/app/assets/javascripts/legislation_annotatable.js.coffee index 9714482d6..3c77238f2 100644 --- a/app/assets/javascripts/legislation_annotatable.js.coffee +++ b/app/assets/javascripts/legislation_annotatable.js.coffee @@ -57,11 +57,7 @@ App.LegislationAnnotatable = $('[data-annotation-id]').removeClass('current-annotation') - parent = $(this).parents('[data-annotation-id]:eq(0)') - if parent.length - target = parent - else - target = $(this) + target = $(this) annotation_id = target.data('annotation-id') $('[data-annotation-id="'+annotation_id+'"]').addClass('current-annotation') @@ -69,9 +65,9 @@ App.LegislationAnnotatable = $("#comments-box").show() $.event.trigger type: "renderLegislationAnnotation" - annotation_id: $(event.target).data("annotation-id") - annotation_url: $(event.target).closest(".legislation-annotatable").data("legislation-annotatable-base-url") - offset: $(event.target).offset()["top"] + annotation_id: target.data("annotation-id") + annotation_url: target.closest(".legislation-annotatable").data("legislation-annotatable-base-url") + offset: target.offset()["top"] isMobile: () -> return window.innerWidth <= 652 diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index 0e536dd5e..bda36dd4d 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -48,7 +48,7 @@ class Legislation::AnnotationsController < ApplicationController end def search - @annotations = @draft_version.annotations + @annotations = @draft_version.annotations.order("LENGTH(quote) DESC") annotations_hash = { total: @annotations.size, rows: @annotations } render json: annotations_hash.to_json end