From 632042305da005acb9b9f864c51e5562682e501e Mon Sep 17 00:00:00 2001
From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com>
Date: Tue, 29 Oct 2024 16:03:42 +0200
Subject: [PATCH] [JENKINS-74012] Extract JavaScript block in
`SourceCodeViewModel/index.jelly`
---
.../prism/SourceCodeViewModel/index.jelly | 22 +------------------
.../prism/SourceCodeViewModel/scroll-view.js | 18 +++++++++++++++
2 files changed, 19 insertions(+), 21 deletions(-)
create mode 100644 src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/scroll-view.js
diff --git a/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/index.jelly b/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/index.jelly
index 1a6c026..ecbd28c 100644
--- a/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/index.jelly
+++ b/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/index.jelly
@@ -12,27 +12,7 @@
-
-
+
diff --git a/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/scroll-view.js b/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/scroll-view.js
new file mode 100644
index 0000000..a471a7f
--- /dev/null
+++ b/src/main/resources/io/jenkins/plugins/prism/SourceCodeViewModel/scroll-view.js
@@ -0,0 +1,18 @@
+/* global jQuery3 */
+/**
+ * Scroll to the warning.
+ */
+jQuery3.fn.scrollView = function () {
+ return this.each(function () {
+ jQuery3('html, body').animate({
+ scrollTop: jQuery3(this).offset().top - (jQuery3(window).height() / 2)
+ }, 1000);
+ });
+};
+jQuery3(document).ready(function () {
+ jQuery3('.highlight').scrollView();
+});
+jQuery3('.analysis-collapse-button').click(function () {
+ jQuery3('#analysis-description').collapse('toggle');
+ jQuery3('.analysis-collapse-button').toggleClass('open');
+});