From 174fe5ee049e321f7ef8612990211143bed0e725 Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Tue, 10 Jan 2017 18:59:18 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20scroll=20and=20show=20comments?= =?UTF-8?q?=20when=20there=20isn=E2=80=99t=20an=20anchor=20in=20the=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legislation_annotatable.js.coffee | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/legislation_annotatable.js.coffee b/app/assets/javascripts/legislation_annotatable.js.coffee index 01bd42bf5..ce9e9b8d7 100644 --- a/app/assets/javascripts/legislation_annotatable.js.coffee +++ b/app/assets/javascripts/legislation_annotatable.js.coffee @@ -22,16 +22,16 @@ App.LegislationAnnotatable = scrollToAnchor: -> annotationsLoaded: (annotations) -> - anchor = $(location).attr('hash') - ann_id = anchor.split("-")[-1..] - el = $("span[data-annotation-id='" + ann_id + "']") - App.LegislationAllegations.show_comments() - $('html,body').animate({scrollTop: el.offset().top}) - $.event.trigger - type: "renderLegislationAnnotation" - annotation_id: ann_id - annotation_url: el.closest(".legislation-annotatable").data("legislation-annotatable-base-url") - offset: el.offset()["top"] + if anchor = $(location).attr('hash') + ann_id = anchor.split("-")[-1..] + el = $("span[data-annotation-id='" + ann_id + "']") + App.LegislationAllegations.show_comments() + $('html,body').animate({scrollTop: el.offset().top}) + $.event.trigger + type: "renderLegislationAnnotation" + annotation_id: ann_id + annotation_url: el.closest(".legislation-annotatable").data("legislation-annotatable-base-url") + offset: el.offset()["top"] initialize: -> $(document).on("renderLegislationAnnotation", App.LegislationAnnotatable.renderAnnotationComments)