From 1d82ddd3329be2827b160bb4485f471a1011febb Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Fri, 21 May 2021 23:39:33 +0200 Subject: [PATCH] [JENKINS-60866] Clean up build button column JS --- .../hudson/views/BuildButtonColumn/column.jelly | 17 +++++------------ .../hudson/views/BuildButtonColumn/icon.js | 12 ++++++++++++ core/src/main/resources/lib/layout/icon.jelly | 14 +++++++++----- .../src/main/resources/lib/layout/svgIcon.jelly | 7 ++++++- 4 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 core/src/main/resources/hudson/views/BuildButtonColumn/icon.js diff --git a/core/src/main/resources/hudson/views/BuildButtonColumn/column.jelly b/core/src/main/resources/hudson/views/BuildButtonColumn/column.jelly index f57d537f2e58..110f40149bf4 100644 --- a/core/src/main/resources/hudson/views/BuildButtonColumn/column.jelly +++ b/core/src/main/resources/hudson/views/BuildButtonColumn/column.jelly @@ -27,29 +27,22 @@ THE SOFTWARE. - + + - + - + title="${title}" alt="${title}" id="${id}" /> + - diff --git a/core/src/main/resources/hudson/views/BuildButtonColumn/icon.js b/core/src/main/resources/hudson/views/BuildButtonColumn/icon.js new file mode 100644 index 000000000000..58d836b6f2af --- /dev/null +++ b/core/src/main/resources/hudson/views/BuildButtonColumn/icon.js @@ -0,0 +1,12 @@ +Behaviour.specify(".build-button-column-icon-reference-holder", 'build-button-column', 0, function (e) { + var url = e.getAttribute('data-url'); + var message = e.getAttribute('data-notification') + var id = e.getAttribute('data-id'); + var icon = document.getElementById(id); + + icon.onclick = function(el) { + new Ajax.Request(url); + hoverNotification(message, this, -100); + return false; + } +}); diff --git a/core/src/main/resources/lib/layout/icon.jelly b/core/src/main/resources/lib/layout/icon.jelly index b0ee33f871ba..1f6eec8a42ed 100644 --- a/core/src/main/resources/lib/layout/icon.jelly +++ b/core/src/main/resources/lib/layout/icon.jelly @@ -30,11 +30,15 @@ THE SOFTWARE. The icon class specification e.g. 'icon-help icon-sm', 'icon-blue icon-md', 'icon-blue-anime icon-xlg'. + + ID of the icon element. Since TODO. + + Icon source raw URL. Only relevant if the 'class' attribute is NOT specified. - onclick handler. + onclick handler. Deprecated; assign an ID and look up the element that way to attach event handlers. title style tooltip @@ -66,19 +70,19 @@ THE SOFTWARE. - + - + - + ${attrs.alt} + alt="${attrs.alt}" width="${attrs.width}" onclick="${attrs.onclick}" tooltip="${attrs.tooltip}" id="${attrs.id}" /> diff --git a/core/src/main/resources/lib/layout/svgIcon.jelly b/core/src/main/resources/lib/layout/svgIcon.jelly index 01f1d3e0ab33..bd808215fe8d 100644 --- a/core/src/main/resources/lib/layout/svgIcon.jelly +++ b/core/src/main/resources/lib/layout/svgIcon.jelly @@ -12,6 +12,10 @@ Extra CSS classes passed to the icon. Currently only the 'svg-icon' class is applied by default. + + ID of the icon element. Since TODO. + + Href of the 'use' tag. Normally path to a sprite plus an icon id @@ -22,7 +26,7 @@ Whether the icon can receive keyboard focus. Possible values 'true' or 'false' - onclick handler. + onclick handler. Deprecated; assign an ID and look up the element that way to attach event handlers. style tooltip aria-hidden @@ -34,6 +38,7 @@ aria-hidden="${attrs.ariaHidden}" style="${attrs.style}" onclick="${attrs.onclick}" + id="${attrs.id}" tooltip="${attrs.tooltip != null ? h.xmlEscape(attrs.tooltip) : null}">