From 258c97e3874bec3509de997b2c4e4f749ae2a067 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Tue, 12 Nov 2013 15:48:22 +0100 Subject: [PATCH] Decode URL fragment before searching for the target element --- assets/javascripts/views/content/content.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/views/content/content.coffee b/assets/javascripts/views/content/content.coffee index eed5c4dc..5bc91451 100644 --- a/assets/javascripts/views/content/content.coffee +++ b/assets/javascripts/views/content/content.coffee @@ -85,7 +85,7 @@ class app.views.Content extends app.View return scrollToTarget: -> - if @routeCtx.hash and el = $.id @routeCtx.hash + if @routeCtx.hash and el = @findTargetByHash @routeCtx.hash $.scrollToWithImageLock el, @scrollEl, 'top', margin: 20 + if @scrollEl is @el then 0 else $.offset(@el).top $.highlight el, className: '_highlight' @@ -150,5 +150,8 @@ class app.views.Content extends app.View $.popup(link) return + findTargetByHash: (hash) -> + try $.id decodeURIComponent(hash) catch + isExternalUrl: (url) -> url?[0..3] is 'http'