Merge pull request #1937 from riyad/add-file-line-links

Add file line links
This commit is contained in:
Dmitriy Zaporozhets 2012-11-16 03:46:43 -08:00
commit b339c747a9
9 changed files with 411 additions and 199 deletions

View file

@ -13,6 +13,7 @@
//= require jquery.history
//= require jquery.waitforimages
//= require jquery.atwho
//= require jquery.scrollto
//= require bootstrap
//= require modernizr
//= require chosen-jquery

View file

@ -35,3 +35,22 @@ $ ->
state = History.getState()
window.ajaxGet(state.url)
)(window)
# See if there are lines selected
# "#L12" and "#L34-56" supported
highlightBlobLines = ->
if window.location.hash isnt ""
matches = window.location.hash.match /\#L(\d+)(\-(\d+))?/
first_line = parseInt matches[1]
last_line = parseInt matches[3]
unless isNaN first_line
last_line = first_line if isNaN last_line
$("#tree-content-holder .highlight .line").removeClass("hll")
$("#LC#{line}").addClass("hll") for line in [first_line..last_line]
$("#L#{first_line}").ScrollTo()
# Highlight the correct lines on load
highlightBlobLines()
# Highlight the correct lines when the hash part of the URL changes
$(window).on 'hashchange', highlightBlobLines