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,7 +64,7 @@ class BlobView | ||
64 | nodes.attr("id", hash) | 64 | nodes.attr("id", hash) |
65 | 65 | ||
66 | # initialize multi-line select | 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 | # Highlight the correct lines on load | 69 | # Highlight the correct lines on load |
70 | highlightBlobLines() | 70 | highlightBlobLines() |
app/assets/javascripts/dispatcher.js.coffee
@@ -4,6 +4,7 @@ $ -> | @@ -4,6 +4,7 @@ $ -> | ||
4 | class Dispatcher | 4 | class Dispatcher |
5 | constructor: () -> | 5 | constructor: () -> |
6 | @initSearch() | 6 | @initSearch() |
7 | + @initHighlight() | ||
7 | @initPageScripts() | 8 | @initPageScripts() |
8 | 9 | ||
9 | initPageScripts: -> | 10 | initPageScripts: -> |
@@ -53,3 +54,10 @@ class Dispatcher | @@ -53,3 +54,10 @@ class Dispatcher | ||
53 | project_ref = opts.data('autocomplete-project-ref') | 54 | project_ref = opts.data('autocomplete-project-ref') |
54 | 55 | ||
55 | new SearchAutocomplete(path, project_id, project_ref) | 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,9 +56,6 @@ document.addEventListener("page:fetch", unbindEvents) | ||
56 | document.addEventListener("page:change", stopSpinner) | 56 | document.addEventListener("page:change", stopSpinner) |
57 | 57 | ||
58 | $ -> | 58 | $ -> |
59 | - $('pre code').each (i, e) -> | ||
60 | - hljs.highlightBlock(e) | ||
61 | - | ||
62 | # Click a .one_click_select field, select the contents | 59 | # Click a .one_click_select field, select the contents |
63 | $(".one_click_select").on 'click', -> $(@).select() | 60 | $(".one_click_select").on 'click', -> $(@).select() |
64 | 61 |
app/assets/stylesheets/generic/highlight.scss
app/assets/stylesheets/highlight/dark.scss
1 | .dark { | 1 | .dark { |
2 | background-color: #232323; | 2 | background-color: #232323; |
3 | 3 | ||
4 | + .line.hll { | ||
5 | + background: #558; | ||
6 | + } | ||
7 | + | ||
4 | .highlight{ | 8 | .highlight{ |
5 | border-left: 1px solid #444; | 9 | border-left: 1px solid #444; |
6 | } | 10 | } |
@@ -15,7 +19,6 @@ | @@ -15,7 +19,6 @@ | ||
15 | 19 | ||
16 | .hljs { | 20 | .hljs { |
17 | display: block; | 21 | display: block; |
18 | - padding: 0.5em; | ||
19 | background: #232323; | 22 | background: #232323; |
20 | color: #E6E1DC; | 23 | color: #E6E1DC; |
21 | } | 24 | } |
app/assets/stylesheets/highlight/monokai.scss
@@ -5,6 +5,10 @@ | @@ -5,6 +5,10 @@ | ||
5 | border-left: 1px solid #444; | 5 | border-left: 1px solid #444; |
6 | } | 6 | } |
7 | 7 | ||
8 | + .line.hll { | ||
9 | + background: #558; | ||
10 | + } | ||
11 | + | ||
8 | .line-numbers a { | 12 | .line-numbers a { |
9 | color: #666; | 13 | color: #666; |
10 | } | 14 | } |
@@ -15,7 +19,7 @@ | @@ -15,7 +19,7 @@ | ||
15 | } | 19 | } |
16 | 20 | ||
17 | .hljs { | 21 | .hljs { |
18 | - display: block; padding: 0.5em; | 22 | + display: block; |
19 | background: #272822; | 23 | background: #272822; |
20 | } | 24 | } |
21 | 25 |
app/assets/stylesheets/highlight/solarized_dark.scss
@@ -5,6 +5,10 @@ | @@ -5,6 +5,10 @@ | ||
5 | border-left: 1px solid #113b46; | 5 | border-left: 1px solid #113b46; |
6 | } | 6 | } |
7 | 7 | ||
8 | + .line.hll { | ||
9 | + background: #000; | ||
10 | + } | ||
11 | + | ||
8 | pre { | 12 | pre { |
9 | background-color: #002B36; | 13 | background-color: #002B36; |
10 | color: #eee; | 14 | color: #eee; |
@@ -16,7 +20,6 @@ | @@ -16,7 +20,6 @@ | ||
16 | 20 | ||
17 | .hljs { | 21 | .hljs { |
18 | display: block; | 22 | display: block; |
19 | - padding: 0.5em; | ||
20 | background: #002b36; | 23 | background: #002b36; |
21 | color: #839496; | 24 | color: #839496; |
22 | } | 25 | } |
app/assets/stylesheets/highlight/white.scss
1 | .white { | 1 | .white { |
2 | background-color: #fff; | 2 | background-color: #fff; |
3 | 3 | ||
4 | + .line.hll { | ||
5 | + background: #FFA; | ||
6 | + } | ||
7 | + | ||
4 | .highlight{ | 8 | .highlight{ |
5 | border-left: 1px solid #eee; | 9 | border-left: 1px solid #eee; |
6 | } | 10 | } |
@@ -19,7 +23,7 @@ | @@ -19,7 +23,7 @@ | ||
19 | } | 23 | } |
20 | 24 | ||
21 | .hljs { | 25 | .hljs { |
22 | - display: block; padding: 0.5em; | 26 | + display: block; |
23 | background: #fff; color: black; | 27 | background: #fff; color: black; |
24 | } | 28 | } |
25 | 29 |