-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
/
icon.jelly
101 lines (85 loc) · 4.45 KB
/
icon.jelly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<st:documentation>
@since 1.576
<st:attribute name="src" use="optional">
Icon source
Supports Jenkins Symbols (e.g. 'symbol-search')
Supports path to bitmap image
Only relevant if the 'class' attribute is NOT specified.
</st:attribute>
<st:attribute name="class" use="optional">
The icon class specification e.g. 'icon-help icon-sm', 'icon-blue icon-md', 'icon-blue-anime icon-xlg'.
</st:attribute>
<st:attribute name="id">
ID of the icon element. Since TODO.
</st:attribute>
<st:attribute name="onclick" deprecated="true">onclick handler. Deprecated; assign an ID and look up the element that way to attach event handlers.</st:attribute>
<st:attribute name="title" deprecated="true">title, deprecated use tooltip instead</st:attribute>
<st:attribute name="style">style</st:attribute>
<st:attribute name="tooltip">tooltip</st:attribute>
<st:attribute name="alt">alt, adds invisible text suitable for screen-readers for symbols, sets the alt attribute for normal images</st:attribute>
</st:documentation>
<j:set var="iconSrc" value="${h.tryGetIconPath(src, context)}"/>
<j:set var="iconMetadata" value="${h.tryGetIcon(src)}"/>
<j:set var="imgStyle" value="${attrs.style}"/>
<j:if test="${iconSrc == null}">
<j:set var="iconSrc" value="${h.tryGetIconPath(class, context)}"/>
<j:set var="iconMetadata" value="${h.tryGetIcon(class)}"/>
</j:if>
<j:if test="${iconMetadata != null}">
<j:set var="imgStyle" value="${iconMetadata.style} ${attrs.style}"/>
</j:if>
<j:choose>
<j:when test="${iconSrc.startsWith('symbol-')}">
<j:invokeStatic var="icon" className="org.jenkins.ui.icon.IconSet" method="getSymbol">
<j:arg value="${iconSrc.substring(7)}" />
<j:arg value="${alt ?: ''}" />
<j:arg value="${attrs.tooltip ?: ''}" />
<j:arg value="${iconMetadata.classSpec ?: ''}" />
<j:arg value="${h.extractPluginNameFromIconSrc(iconSrc)}" />
<j:arg value="${attrs.id ?: ''}" />
</j:invokeStatic>
<j:out value="${icon}" />
</j:when>
<j:otherwise>
<j:choose>
<j:when test="${iconMetadata.buildStatus}">
<j:set var="outerLayer" value="${iconMetadata.inProgress ? 'build-status-in-progress' : 'build-status-static'}" />
<span class="build-status-icon__wrapper ${attrs.class}" style="${imgStyle}">
<span class="build-status-icon__outer">
<l:svgIcon href="${rootURL}/images/build-status/build-status-sprite.svg#${outerLayer}" id="${attrs.id}" tooltip="${attrs.tooltip}"/>
</span>
<l:svgIcon class="${attrs.class}" href="${iconSrc}" id="${attrs.id}" tooltip="${attrs.tooltip}"/>
</span>
</j:when>
<j:when test="${iconMetadata.svgSprite and !iconMetadata.buildStatus}">
<l:svgIcon class="${attrs.class}" href="${iconSrc}" id="${attrs.id}"/>
</j:when>
<j:otherwise>
<img class="${attrs.class}" src="${iconSrc}" style="${imgStyle}" title="${attrs.title}" height="${attrs.height}"
alt="${attrs.alt}" width="${attrs.width}" onclick="${attrs.onclick}" tooltip="${attrs.tooltip}" id="${attrs.id}" />
</j:otherwise>
</j:choose>
</j:otherwise>
</j:choose>
</j:jelly>