From 983d757ad3d73812e79b7e2a7a01561cef59635b Mon Sep 17 00:00:00 2001 From: Benjamin Fuchs Date: Fri, 21 Jul 2017 22:38:28 +0200 Subject: [PATCH 1/2] [JENKINS-33105] Fixing pom.xml for JDK 1.8 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4aba7ba..3dd4b4f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.jenkins-ci.plugins plugin - 1.509.4 + 1.554.1 linenumbers From 4194ecc44b20862ae106f0ef8681be5b446c2e00 Mon Sep 17 00:00:00 2001 From: Benjamin Fuchs Date: Sat, 5 Aug 2017 23:44:43 +0200 Subject: [PATCH 2/2] [JENKINS-41284] Implementing a custom anchor to give it an offset. --- .../LineNumbersAnnotatorFactory/script.js | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/main/resources/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory/script.js b/src/main/resources/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory/script.js index 8b87c0a..7685dee 100644 --- a/src/main/resources/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory/script.js +++ b/src/main/resources/org/jenkinsci/plugins/linenumbers/LineNumbersAnnotatorFactory/script.js @@ -1,5 +1,32 @@ -Behaviour.specify('div.fold', 'fold.toggle', 10, function(element) { - element.onclick = function() { - element.toggleClassName('open'); - } -}); \ No newline at end of file +/*global window */ +(function () { + "use strict"; + + Behaviour.specify('div.fold', 'fold.toggle', 10, function (element) { + element.onclick = function () { + element.toggleClassName('open'); + }; + }); + + function scrollToElement(element) { + window.scrollTo(0, element.offsetTop - 30); + } + + $(document).on("click", "a[href^='#L']", function (event) { + event.preventDefault(); + scrollToElement(event.target); + }); + + $(document).observe("dom:loaded", function () { + var hash = window.location.hash.substring(1), + targetLine; + if (hash.length !== 0) { + targetLine = document.getElementById(hash); + if (targetLine) { + window.setTimeout(function () { + scrollToElement(targetLine); + }, 200); + } + } + }); +}());