OSDN Git Service

03e280f89769471bac2ece86eaedf114fe9c76fb
[wvm/gitlab.git] / app / assets / javascripts / blob.js.coffee
1 class BlobView
2   constructor: ->
3     # See if there are lines selected
4     # "#L12" and "#L34-56" supported
5     highlightBlobLines = ->
6       if window.location.hash isnt ""
7         matches = window.location.hash.match(/\#L(\d+)(\-(\d+))?/)
8         first_line = parseInt(matches?[1])
9         last_line = parseInt(matches?[3])
10
11         unless isNaN first_line
12           last_line = first_line if isNaN(last_line)
13           $("#tree-content-holder .highlight .line").removeClass("hll")
14           $("#LC#{line}").addClass("hll") for line in [first_line..last_line]
15           $("#L#{first_line}").ScrollTo()
16
17     # Highlight the correct lines on load
18     highlightBlobLines()
19
20     # Highlight the correct lines when the hash part of the URL changes
21     $(window).on 'hashchange', highlightBlobLines
22
23
24 @BlobView = BlobView