PageRenderTime 11ms CodeModel.GetById 8ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/hudson-core/src/main/resources/lib/layout/taskWithDialog.jelly

http://github.com/hudson/hudson
Unknown | 119 lines | 103 code | 16 blank | 0 comment | 0 complexity | 6dee7c5a86252c978a0bdbea15f64e0c MD5 | raw file
  1<!--
  2The MIT License
  3
  4Copyright (c) 2004-2009, Oracle Corporation, Winston Prakash
  5
  6Permission is hereby granted, free of charge, to any person obtaining a copy
  7of this software and associated documentation files (the "Software"), to deal
  8in the Software without restriction, including without limitation the rights
  9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10copies of the Software, and to permit persons to whom the Software is
 11furnished to do so, subject to the following conditions:
 12
 13The above copyright notice and this permission notice shall be included in
 14all copies or substantial portions of the Software.
 15
 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 22THE SOFTWARE.
 23-->
 24
 25<?jelly escape-by-default='true'?>
 26<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
 27  <st:documentation>
 28    This tag inside &lt;l:tasks> tag renders the left navigation bar of Hudson.
 29    Each &lt;task> tag gets an icon and link.
 30
 31    <st:attribute name="href" use="required">
 32      Link target. Relative to the current page.
 33    </st:attribute>
 34    <st:attribute name="icon" use="required">
 35      URL to the icon, which should be 24x24 in size.
 36      It's relative to the context path of Hudson.
 37
 38      The common values include:
 39
 40      # "images/24x24/..." then points to the stock icon resources
 41      # "plugin/foobar/abc/def.png" that points to "src/main/webapp/abc/def.png" in your plugin resources
 42    </st:attribute>
 43    <st:attribute name="title" use="required">
 44      Human readable text that follows the icon.
 45    </st:attribute>
 46    <st:attribute name="permission">
 47      If specified, the link will be only displayed when the current user
 48      has the specified permission against the "it" object.
 49
 50      This is useful for showing links to restricted pages, as showing
 51      them to unprivileged users don't make sense.
 52    </st:attribute>
 53    <st:attribute name="dialogPanel">
 54       The Panel for the dialog
 55    </st:attribute>
 56  </st:documentation>
 57
 58  <!--
 59    Much of the following horrible code is to implement hierarchy support in <task> tag.
 60    The semantics is that when one of the nested <task> matches, the parent is also considered as a match
 61    and thus gets a highlight.
 62  -->
 63  <j:set var="match" value="${h.hyperlinkMatchesCurrentPage(href)}" />
 64  <j:scope>
 65    <j:set var="taskMatching" value="${context.parent}"/>
 66    <d:invokeBody />
 67  </j:scope>
 68
 69    <j:choose>
 70        <j:when test="${attrs.onclick != null}">
 71            <j:set var="onLinkClick" value="${attrs.onclick}" />
 72        </j:when>
 73        <j:otherwise>
 74            <j:set var="onLinkClick" value="onLinkClick('question'); return false;" />
 75        </j:otherwise>
 76    </j:choose>
 77
 78  <j:if test="${attrs.permission==null or h.hasPermission(it,attrs.permission)}">
 79    <j:choose>
 80      <j:when test="${taskMatching!=null}">
 81        <j:if test="${match}">
 82          <j:set target="${taskMatching.variables}" property="match" value="true"/>
 83        </j:if>
 84      </j:when>
 85      <j:otherwise>
 86        <!--Plug popup dialog script-->
 87        <script src="${resURL}/scripts/popup-dialog.js" type="text/javascript" />
 88        <div class="task">
 89
 90          <a href="${href}" onclick="${onLinkClick}">
 91            <img width="24" height="24" style="margin: 2px;" alt="" src="${rootURL}${icon.startsWith('images/') ? h.resourcePath : ''}/${icon}"/>
 92          </a>
 93          <st:nbsp />
 94
 95          <a href="${href}" onclick="${onLinkClick}">
 96            <j:choose>
 97              <j:when test="${match}">
 98                <b>${title}</b>
 99              </j:when>
100              <j:otherwise>
101                ${title}
102              </j:otherwise>
103            </j:choose>
104          </a>
105          
106          <div id="question" style="display:none; cursor: default">
107                <st:include page="${dialogPanel}" />
108          </div>
109
110          <j:if test="${match}">
111            <div class="subtasks">
112              <d:invokeBody />
113            </div>
114          </j:if>
115        </div>
116      </j:otherwise>
117    </j:choose>
118  </j:if>
119</j:jelly>