Mercurial > hg > martINI
comparison martini/templates/table.html @ 0:3c3522ce6e3a
initial import of martINI from https://svn.openplans.org/svn/standalone/martINI/
author | k0s <k0scist@gmail.com> |
---|---|
date | Tue, 08 Dec 2009 15:13:28 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3c3522ce6e3a |
---|---|
1 <!DOCTYPE html | |
2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
4 <html xmlns="http://www.w3.org/1999/xhtml" | |
5 xmlns:py="http://genshi.edgewall.org/"> | |
6 <head> | |
7 <title>${request.path_info}</title> | |
8 <script src="/jquery.js"></script> | |
9 <script type="text/javascript"> | |
10 $(document).ready(function() { | |
11 $("td").click(function() { | |
12 | |
13 if ( $(this).find('input').length == 0 ) { | |
14 | |
15 $(this).html('<input type="text" value="' + $(this).text() + '"/>'); | |
16 $(this).find('input').focus(); | |
17 $(this).find('input').blur(function() { | |
18 dict = {}; | |
19 column = $(this).closest("td").attr('class'); | |
20 row = $(this).closest("tr").attr('id'); | |
21 if ( column == 'section' ) { | |
22 key = '[' + row + ']'; | |
23 } | |
24 else { | |
25 key = '[' + row + ']' + column; | |
26 } | |
27 dict[key] = $(this).val(); | |
28 $.post("${request.path_info}", dict); | |
29 $(this).parent().html($(this).val()); | |
30 }); | |
31 } | |
32 }); | |
33 $(":button").click(function() { | |
34 var headers = $(this).closest("table").find("th").map(function() { | |
35 return $(this).attr('class'); | |
36 }); | |
37 var row_html = '<tr><td class="section"><input type="text" /></td>'; | |
38 for ( var i=1; i != headers.length; i++ ) { | |
39 row_html += '<td class="'; | |
40 row_html += headers[i]; | |
41 row_html += '"></td>'; | |
42 } | |
43 row_html += '</tr>'; | |
44 $(this).closest("tr").before(row_html); | |
45 }); | |
46 }); | |
47 </script> | |
48 </head> | |
49 <body> | |
50 | |
51 <table py:with="columns=sorted(set(sum([section.keys() for section in sections.values()], [])))"> | |
52 | |
53 <tr> | |
54 <th class="section"></th> | |
55 <th class="${column}" py:for="column in columns">${column}</th> | |
56 </tr> | |
57 | |
58 <tr py:for="section in sections" id="${section}"> | |
59 <td class="section">${section}</td> | |
60 <td py:for="column in columns" class="${column}">${sections[section].get(column)}</td> | |
61 </tr> | |
62 | |
63 <tr> | |
64 <td><input type="button" id="add_section" value="+"/></td> | |
65 </tr> | |
66 </table> | |
67 | |
68 </body> | |
69 </html> |