Commit f304f975d67e9e7f4388b1401c3a580b29b8d8c8
1 parent
78b2fb5d
Exists in
spb-stable
and in
3 other branches
Fix blob multiline highlight
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
8 changed files
with
32 additions
and
8 deletions
Show diff stats
app/assets/javascripts/blob.js.coffee
... | ... | @@ -64,7 +64,7 @@ class BlobView |
64 | 64 | nodes.attr("id", hash) |
65 | 65 | |
66 | 66 | # initialize multi-line select |
67 | - $("#tree-content-holder .line_numbers a[id^=L]").on("click", handleMultiSelect) | |
67 | + $("#tree-content-holder .line-numbers a[id^=L]").on("click", handleMultiSelect) | |
68 | 68 | |
69 | 69 | # Highlight the correct lines on load |
70 | 70 | highlightBlobLines() | ... | ... |
app/assets/javascripts/dispatcher.js.coffee
... | ... | @@ -4,6 +4,7 @@ $ -> |
4 | 4 | class Dispatcher |
5 | 5 | constructor: () -> |
6 | 6 | @initSearch() |
7 | + @initHighlight() | |
7 | 8 | @initPageScripts() |
8 | 9 | |
9 | 10 | initPageScripts: -> |
... | ... | @@ -53,3 +54,10 @@ class Dispatcher |
53 | 54 | project_ref = opts.data('autocomplete-project-ref') |
54 | 55 | |
55 | 56 | new SearchAutocomplete(path, project_id, project_ref) |
57 | + | |
58 | + initHighlight: -> | |
59 | + $('pre code').each (i, e) -> | |
60 | + hljs.highlightBlock(e) | |
61 | + $(e).html($.map($(e).html().split("\n"), (line, i) -> | |
62 | + "<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>" | |
63 | + ).join("\n")) | ... | ... |
app/assets/javascripts/main.js.coffee
... | ... | @@ -56,9 +56,6 @@ document.addEventListener("page:fetch", unbindEvents) |
56 | 56 | document.addEventListener("page:change", stopSpinner) |
57 | 57 | |
58 | 58 | $ -> |
59 | - $('pre code').each (i, e) -> | |
60 | - hljs.highlightBlock(e) | |
61 | - | |
62 | 59 | # Click a .one_click_select field, select the contents |
63 | 60 | $(".one_click_select").on 'click', -> $(@).select() |
64 | 61 | ... | ... |
app/assets/stylesheets/generic/highlight.scss
app/assets/stylesheets/highlight/dark.scss
1 | 1 | .dark { |
2 | 2 | background-color: #232323; |
3 | 3 | |
4 | + .line.hll { | |
5 | + background: #558; | |
6 | + } | |
7 | + | |
4 | 8 | .highlight{ |
5 | 9 | border-left: 1px solid #444; |
6 | 10 | } |
... | ... | @@ -15,7 +19,6 @@ |
15 | 19 | |
16 | 20 | .hljs { |
17 | 21 | display: block; |
18 | - padding: 0.5em; | |
19 | 22 | background: #232323; |
20 | 23 | color: #E6E1DC; |
21 | 24 | } | ... | ... |
app/assets/stylesheets/highlight/monokai.scss
... | ... | @@ -5,6 +5,10 @@ |
5 | 5 | border-left: 1px solid #444; |
6 | 6 | } |
7 | 7 | |
8 | + .line.hll { | |
9 | + background: #558; | |
10 | + } | |
11 | + | |
8 | 12 | .line-numbers a { |
9 | 13 | color: #666; |
10 | 14 | } |
... | ... | @@ -15,7 +19,7 @@ |
15 | 19 | } |
16 | 20 | |
17 | 21 | .hljs { |
18 | - display: block; padding: 0.5em; | |
22 | + display: block; | |
19 | 23 | background: #272822; |
20 | 24 | } |
21 | 25 | ... | ... |
app/assets/stylesheets/highlight/solarized_dark.scss
... | ... | @@ -5,6 +5,10 @@ |
5 | 5 | border-left: 1px solid #113b46; |
6 | 6 | } |
7 | 7 | |
8 | + .line.hll { | |
9 | + background: #000; | |
10 | + } | |
11 | + | |
8 | 12 | pre { |
9 | 13 | background-color: #002B36; |
10 | 14 | color: #eee; |
... | ... | @@ -16,7 +20,6 @@ |
16 | 20 | |
17 | 21 | .hljs { |
18 | 22 | display: block; |
19 | - padding: 0.5em; | |
20 | 23 | background: #002b36; |
21 | 24 | color: #839496; |
22 | 25 | } | ... | ... |
app/assets/stylesheets/highlight/white.scss
1 | 1 | .white { |
2 | 2 | background-color: #fff; |
3 | 3 | |
4 | + .line.hll { | |
5 | + background: #FFA; | |
6 | + } | |
7 | + | |
4 | 8 | .highlight{ |
5 | 9 | border-left: 1px solid #eee; |
6 | 10 | } |
... | ... | @@ -19,7 +23,7 @@ |
19 | 23 | } |
20 | 24 | |
21 | 25 | .hljs { |
22 | - display: block; padding: 0.5em; | |
26 | + display: block; | |
23 | 27 | background: #fff; color: black; |
24 | 28 | } |
25 | 29 | ... | ... |