/hudson-core/src/main/resources/lib/form/expandableTextbox.jelly

http://github.com/hudson/hudson · Unknown · 82 lines · 73 code · 9 blank · 0 comment · 0 complexity · 86a7f364a25ff7e1c6f846827421f864 MD5 · raw file

  1. <!--
  2. The MIT License
  3. Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. -->
  20. <!--
  21. TODO: support @checkUrl
  22. -->
  23. <?jelly escape-by-default='true'?>
  24. <j:jelly xmlns:j="jelly:core" xmlns:d="jelly:define" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
  25. <st:documentation>
  26. single-line textbox that can be expanded into a multi-line textarea.
  27. This control is useful for a field that expects multiple whitespaec-separated tokens
  28. (such as URLs, glob patterns, etc.) When the user only enters a few tokens,
  29. they can keep it as a single line to save space, but to enter a large number of values,
  30. this can be turned into textarea for better visibility.
  31. If the initial value is already multi-line text, the control starts with
  32. textarea.
  33. On the server side, your program is responsible for treating ' ', \t, \r, and \n for
  34. separators. (StringTokenizer would do this.)
  35. <st:attribute name="field">
  36. Used for databinding. TBD.
  37. </st:attribute>
  38. <st:attribute name="name">
  39. This becomes @name of the &lt;input> tag.
  40. If @field is specified, this value is inferred from it.
  41. </st:attribute>
  42. <st:attribute name="value">
  43. The initial value of the field. This becomes the @value of the &lt;input> tag.
  44. If @field is specified, the current property from the "instance" object
  45. will be set as the initial value automatically,
  46. which is the recommended approach.
  47. </st:attribute>
  48. </st:documentation>
  49. <f:prepareDatabinding />
  50. <j:set var="value" value="${attrs.value?:instance[attrs.field]}" />
  51. <j:choose>
  52. <j:when test="${h.isMultiline(value)}">
  53. <!-- multiline text area to begin with -->
  54. <f:textarea name='${attrs.name}' value="${value}" field="${attrs.field}"/>
  55. </j:when>
  56. <j:otherwise>
  57. <!-- single line textbox with expand button -->
  58. <table border="0" style="width:100%" cellspacing="0" cellpadding="0">
  59. <tr>
  60. <td width="*">
  61. <j:set var="name" value="${attrs.name ?: '_.'+attrs.field}" />
  62. <input class="setting-input" type="text"
  63. name="${name}" value="${value}"
  64. id="textarea.${name}" />
  65. </td><td width="1">
  66. <input type="button" value="&#x25BC;" onclick="expandTextArea(this,'textarea.${name}')"
  67. tooltip="${%tooltip}"/>
  68. </td>
  69. </tr>
  70. </table>
  71. </j:otherwise>
  72. </j:choose>
  73. </j:jelly>