提交 08e79738 编写于 作者: K kohsuke

made tooltip support reusable.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2398 71c3de6d-444a-0410-be80-ed276b4c234a
上级 3372a325
......@@ -236,7 +236,7 @@
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler</artifactId>
<version>1.22</version>
<version>1.23-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.kohsuke</groupId>
......
......@@ -328,10 +328,23 @@ public class Functions {
return Util.encode(s);
}
public void adminCheck(StaplerRequest req, StaplerResponse rsp,boolean required) throws IOException, ServletException {
public static void adminCheck(StaplerRequest req, StaplerResponse rsp,boolean required) throws IOException, ServletException {
if(required && !Hudson.adminCheck(req,rsp)) {
// check failed
throw new ServletException("Unauthorized access");
}
}
/**
* Infers the hudson installation URL from the given request.
*/
public static String inferHudsonURL(StaplerRequest req) {
StringBuilder buf = new StringBuilder();
buf.append(req.getScheme()).append("://");
buf.append(req.getServerName());
if(req.getLocalPort()!=80)
buf.append(':').append(req.getLocalPort());
buf.append('/').append(req.getContextPath());
return buf.toString();
}
}
......@@ -7,10 +7,5 @@
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:set var="id" value="${h.generateId()}"/>
<t:progressBar id="${id}" pos="${build.executor.progress}" href="${rootURL}/${build.url}console"/>
<script>
new YAHOO.widget.Tooltip("tooltip-${id}", {
context:"${id}",
text:"Started ${build.timestampString} ago&lt;br> Estimated remaining time: ${build.executor.estimatedRemainingTime}",
showDelay:500 } );
</script>
<t:tooltip id="${id}">Started ${build.timestampString} ago&lt;br> Estimated remaining time: ${build.executor.estimatedRemainingTime}</t:tooltip>
</j:jelly>
......@@ -30,12 +30,7 @@
<a href="${rootURL}/${item.project.url}">
${item.project.name}
</a>
<script>
new YAHOO.widget.Tooltip("tooltip-${id}", {
context:"${id}",
text:"${item.why}",
showDelay:500 } );
</script>
<t:tooltip id="${id}">${item.why}</t:tooltip>
</td>
<td class="pane" width="16" align="center" valign="middle">
<l:isAdmin>
......
<!--
generates script fragment to display a tooltip
Attributes:
@id: HTML ID of the target of the popup. For ID generation you can use:
<j:set var="id" value="${h.generateId()}"/>
Body:
HTML to be displayed as tooltip. Note that there cannot be any newline in it,
so you have to write <t:tooltip>...</t:tooltip>, not
<t:tooltip>
...
</t:tooltip>
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<script>
new YAHOO.widget.Tooltip("tooltip-${id}", {
context:"${id}",
text:"<d:invokeBody/>",
showDelay:500 } );
</script>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册