Commit 32366d18 authored by Robert Speicher's avatar Robert Speicher

Rename BlobView to LineHighlighter

parent 1f88d9b5
...@@ -87,7 +87,7 @@ class Dispatcher ...@@ -87,7 +87,7 @@ class Dispatcher
new TreeView() new TreeView()
shortcut_handler = new ShortcutsNavigation() shortcut_handler = new ShortcutsNavigation()
when 'projects:blob:show' when 'projects:blob:show'
new BlobView() new LineHighlighter()
shortcut_handler = new ShortcutsNavigation() shortcut_handler = new ShortcutsNavigation()
when 'projects:labels:new', 'projects:labels:edit' when 'projects:labels:new', 'projects:labels:edit'
new Labels() new Labels()
......
# BlobView # LineHighlighter
# #
# Handles single- and multi-line selection and highlight for blob views. # Handles single- and multi-line selection and highlight for blob views.
# #
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
# </pre> # </pre>
# </div> # </div>
# </div> # </div>
class @BlobView class @LineHighlighter
# Internal copy of location.hash so we're not dependent on `location` in tests # Internal copy of location.hash so we're not dependent on `location` in tests
@_hash = '' @_hash = ''
# Initialize a BlobView object # Initialize a LineHighlighter object
# #
# hash - String URL hash for dependency injection in tests # hash - String URL hash for dependency injection in tests
constructor: (hash = location.hash) -> constructor: (hash = location.hash) ->
......
#= require blob/blob #= require line_highlighter
describe 'BlobView', -> describe 'LineHighlighter', ->
fixture.preload('blob.html') fixture.preload('line_highlighter.html')
clickLine = (number, eventData = {}) -> clickLine = (number, eventData = {}) ->
if $.isEmptyObject(eventData) if $.isEmptyObject(eventData)
...@@ -11,25 +11,25 @@ describe 'BlobView', -> ...@@ -11,25 +11,25 @@ describe 'BlobView', ->
$("#L#{number}").trigger(e).click() $("#L#{number}").trigger(e).click()
beforeEach -> beforeEach ->
fixture.load('blob.html') fixture.load('line_highlighter.html')
@class = new BlobView() @class = new LineHighlighter()
@spies = { @spies = {
__setLocationHash__: spyOn(@class, '__setLocationHash__').and.callFake -> __setLocationHash__: spyOn(@class, '__setLocationHash__').and.callFake ->
} }
describe 'behavior', -> describe 'behavior', ->
it 'highlights one line given in the URL hash', -> it 'highlights one line given in the URL hash', ->
new BlobView('#L13') new LineHighlighter('#L13')
expect($('#LC13')).toHaveClass('hll') expect($('#LC13')).toHaveClass('hll')
it 'highlights a range of lines given in the URL hash', -> it 'highlights a range of lines given in the URL hash', ->
new BlobView('#L5-25') new LineHighlighter('#L5-25')
expect($('.hll').length).toBe(21) expect($('.hll').length).toBe(21)
expect($("#LC#{line}")).toHaveClass('hll') for line in [5..25] expect($("#LC#{line}")).toHaveClass('hll') for line in [5..25]
it 'scrolls to the first highlighted line on initial load', -> it 'scrolls to the first highlighted line on initial load', ->
spy = spyOn($, 'scrollTo') spy = spyOn($, 'scrollTo')
new BlobView('#L5-25') new LineHighlighter('#L5-25')
expect(spy).toHaveBeenCalledWith('#L5', jasmine.anything()) expect(spy).toHaveBeenCalledWith('#L5', jasmine.anything())
it 'discards click events', -> it 'discards click events', ->
...@@ -38,7 +38,7 @@ describe 'BlobView', -> ...@@ -38,7 +38,7 @@ describe 'BlobView', ->
expect(spy).toHaveBeenPrevented() expect(spy).toHaveBeenPrevented()
it 'handles garbage input from the hash', -> it 'handles garbage input from the hash', ->
func = -> new BlobView('#tree-content-holder') func = -> new LineHighlighter('#tree-content-holder')
expect(func).not.toThrow() expect(func).not.toThrow()
describe '#clickHandler', -> describe '#clickHandler', ->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment