diff options
author | slene <vslene@gmail.com> | 2014-03-23 20:58:12 +0800 |
---|---|---|
committer | slene <vslene@gmail.com> | 2014-03-23 20:58:12 +0800 |
commit | 559cd63fc5feace32bb44c695207579609516f15 (patch) | |
tree | 23ce410f6463a1a5945409ea6d796e17b23d8b8f /public | |
parent | 97e82a0ff6286fd0a42281cd1e34dd734110e2f4 (diff) | |
download | gitea-559cd63fc5feace32bb44c695207579609516f15.tar.gz gitea-559cd63fc5feace32bb44c695207579609516f15.zip |
fix code view indentation
Diffstat (limited to 'public')
-rw-r--r-- | public/css/markdown.css | 5 | ||||
-rw-r--r-- | public/js/app.js | 44 |
2 files changed, 27 insertions, 22 deletions
diff --git a/public/css/markdown.css b/public/css/markdown.css index 9f4024ba89..d46fd94365 100644 --- a/public/css/markdown.css +++ b/public/css/markdown.css @@ -135,13 +135,12 @@ box-shadow: inset 40px 0 0 #f5f5f5, inset 41px 0 0 #ccc; } -.markdown > pre > code, -.markdown > pre > ol.linenums > li > code { +.markdown > pre > code { white-space: pre; word-wrap: normal; } -.markdown > pre > ol.linenums > li > code { +.markdown > pre > ol.linenums > li { padding: 0 10px; } diff --git a/public/js/app.js b/public/js/app.js index e0f92854f4..3e995d5b0e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -110,25 +110,6 @@ var Gogits = { $pre.addClass('prettyprint linenums'); prettyPrint(); - var $lineNums = $pre.parent().siblings('.lines-num'); - if ($lineNums.length > 0) { - var nums = $pre.find('ol.linenums > li').length; - for (var i = 1; i <= nums; i++) { - $lineNums.append('<span id="L' + i + '" rel=".L' + i + '">' + i + '</span>'); - } - - var last; - $(document).on('click', '.lines-num span', function () { - var $e = $(this); - if (last) { - last.removeClass('active'); - } - last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')); - last.addClass('active'); - window.location.href = '#' + $e.attr('id'); - }); - } - // Set anchor. var headers = {}; $md.find('h1, h2, h3, h4, h5, h6').each(function () { @@ -148,6 +129,30 @@ var Gogits = { }); } + Gogits.renderCodeView = function () { + $('.code-view .lines-code > pre').each(function(){ + var $pre = $(this); + var $lineNums = $pre.parent().siblings('.lines-num'); + if ($lineNums.length > 0) { + var nums = $pre.find('ol.linenums > li').length; + for (var i = 1; i <= nums; i++) { + $lineNums.append('<span id="L' + i + '" rel=".L' + i + '">' + i + '</span>'); + } + + var last; + $(document).on('click', '.lines-num span', function () { + var $e = $(this); + if (last) { + last.removeClass('active'); + } + last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')); + last.addClass('active'); + window.location.href = '#' + $e.attr('id'); + }); + } + }); + }; + })(jQuery); // ajax utils @@ -177,6 +182,7 @@ function initCore() { Gogits.initModals(); Gogits.initDropDown(); Gogits.renderMarkdown(); + Gogits.renderCodeView(); } function initRegister() { |