|
|
@ -110,6 +110,28 @@ var Gogits = { |
|
|
|
$pre.addClass('prettyprint linenums'); |
|
|
|
$pre.addClass('prettyprint linenums'); |
|
|
|
prettyPrint(); |
|
|
|
prettyPrint(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set anchor.
|
|
|
|
|
|
|
|
var headers = {}; |
|
|
|
|
|
|
|
$md.find('h1, h2, h3, h4, h5, h6').each(function () { |
|
|
|
|
|
|
|
var node = $(this); |
|
|
|
|
|
|
|
var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-')); |
|
|
|
|
|
|
|
var name = val; |
|
|
|
|
|
|
|
if (headers[val] > 0) { |
|
|
|
|
|
|
|
name = val + '-' + headers[val]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (headers[val] == undefined) { |
|
|
|
|
|
|
|
headers[val] = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
headers[val] += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
node = node.wrap('<div id="' + name + '" class="anchor-wrap" ></div>'); |
|
|
|
|
|
|
|
node.append('<a class="anchor" href="#' + name + '"><span class="octicon octicon-link"></span></a>'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gogits.renderCodeView = function () { |
|
|
|
|
|
|
|
$('.code-view .lines-code > pre').each(function(){ |
|
|
|
|
|
|
|
var $pre = $(this); |
|
|
|
var $lineNums = $pre.parent().siblings('.lines-num'); |
|
|
|
var $lineNums = $pre.parent().siblings('.lines-num'); |
|
|
|
if ($lineNums.length > 0) { |
|
|
|
if ($lineNums.length > 0) { |
|
|
|
var nums = $pre.find('ol.linenums > li').length; |
|
|
|
var nums = $pre.find('ol.linenums > li').length; |
|
|
@ -128,25 +150,8 @@ var Gogits = { |
|
|
|
window.location.href = '#' + $e.attr('id'); |
|
|
|
window.location.href = '#' + $e.attr('id'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set anchor.
|
|
|
|
|
|
|
|
var headers = {}; |
|
|
|
|
|
|
|
$md.find('h1, h2, h3, h4, h5, h6').each(function () { |
|
|
|
|
|
|
|
var node = $(this); |
|
|
|
|
|
|
|
var val = encodeURIComponent(node.text().toLowerCase().replace(/[^\w\- ]/g, '').replace(/[ ]/g, '-')); |
|
|
|
|
|
|
|
var name = val; |
|
|
|
|
|
|
|
if (headers[val] > 0) { |
|
|
|
|
|
|
|
name = val + '-' + headers[val]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (headers[val] == undefined) { |
|
|
|
|
|
|
|
headers[val] = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
headers[val] += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
node = node.wrap('<div id="' + name + '" class="anchor-wrap" ></div>'); |
|
|
|
|
|
|
|
node.append('<a class="anchor" href="#' + name + '"><span class="octicon octicon-link"></span></a>'); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
})(jQuery); |
|
|
|
})(jQuery); |
|
|
|
|
|
|
|
|
|
|
@ -177,6 +182,7 @@ function initCore() { |
|
|
|
Gogits.initModals(); |
|
|
|
Gogits.initModals(); |
|
|
|
Gogits.initDropDown(); |
|
|
|
Gogits.initDropDown(); |
|
|
|
Gogits.renderMarkdown(); |
|
|
|
Gogits.renderMarkdown(); |
|
|
|
|
|
|
|
Gogits.renderCodeView(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function initRegister() { |
|
|
|
function initRegister() { |
|
|
|