Browse Source

Decode URL fragment before searching for the target element

Thibaut 12 năm trước cách đây
mục cha
commit
258c97e387
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      assets/javascripts/views/content/content.coffee

+ 4 - 1
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'