Code

0749525bbe8a1d9a75c7e026c5383626c498189c
[roundup.git] / roundup / templates / classic / html / _generic.help
1 <html>
2 <head>
3 <link rel="stylesheet" type="text/css" href="_file/style.css">
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8;">
5 <script language="JavaScript" 
6         tal:condition="python:request.form.has_key('property')"
7         tal:content="structure string:
9 // this is the name of the field in the original form that we're working on
10 field = '${request/form/property/value}';
12 function listClose() {
13   window.close();
14 }
15         
16 function listClear() {
17   window.opener.document.itemSynopsis[field].value = '';
18 }
19         
20 function pick(opt) {
21   if (window.opener && !window.opener.closed) {
22     window.opener.document.itemSynopsis[field].value = opt;
23   }
24 }
25         
26 // add a value to the form field
27 function add(opt) {
28   val = window.opener.document.itemSynopsis[field].value;
29   if (/^\s*$$/.test(val)) {
30     newval = opt;   // existing is all whitespace, so just replace
31   } else {
32     newval = val + ', ' + opt;
33   }
34   pick(newval);
35 }
36         
37 // remove a value from the form field
38 function remove(opt) {
39   // ((opt(,\s*)?)|(,\s*opt))
40   replaceStr = new String('(('+opt+'(,\\s*)?)|(,\\s*'+opt+'))');
41   re = new RegExp(replaceStr);
43   str = window.opener.document.itemSynopsis[field].value;
45   // replace occurences with empty string
46   newstr = str.replace(re, '');
47   pick(newstr);
48 }
49 ">
50 </script>
51 </head>
53 <body class="body" marginwidth="0" marginheight="0">
54 <form>
55 <div style="padding:10px;text-align:center;">
56  <script language="javascript">
57   // put up a 'reset' button if the field has values when we pop up this window
59   // this is the name of the field in the original form that we're working on
60   orig = window.opener.document.itemSynopsis[field].value;
61   if (/[^\s]/.test(orig)) {
62     reset = '<input type="button" onclick="pick(orig);" ' +
63       'value="Reset to original values" /> | ';
64     document.write(reset);
65   }
66  </script>
67  <input type="button"
68         tal:attributes="value string:Clear all ${request/form/property/value} values"
69         onclick="listClear();" /> | 
70  <input type="button" onclick="listClose();" value="Close this window" />
71 </div>
73 <table class="classhelp"
74        tal:define="props python:request.form['properties'].value.split(',')">
75 <tr>
76  <th tal:condition="python:request.form.has_key('property')">add/remove</th>
77  <th tal:repeat="prop props" tal:content="prop"></th>
78 </tr>
79 <tr tal:repeat="item context/list">
80  <td tal:condition="python:request.form.has_key('property')">
81  <input type="button" tal:define="opt python: item[props[0]]" 
82          tal:attributes="onclick string:add('${opt}')" value=" + ">
83  <input type="button" tal:define="opt python: item[props[0]]" 
84          tal:attributes="onclick string:remove('${opt}')" value=" - " />
85  </td>
86  <td tal:repeat="prop props" tal:content="structure python:item[prop]"></td>
87 </tr>
88 </table>
89 </form>
90 </body>
91 </html>