]> asedeno.scripts.mit.edu Git - bluechips.git/blob - bluechips/templates/mobile/base.mako
added ability to switch back and forth between mobile and non-mobile interface on iphone
[bluechips.git] / bluechips / templates / mobile / base.mako
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4   <head>
5     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6     <title>${self.title()}</title>
7     ${h.stylesheet_link('/css/main.css')}
8     <link media="only screen and (max-device-width: 480px)" href="/css/mobile.css" type="text/css" rel="stylesheet">
9     <meta name="viewport" content="width = device-width, user-scalable=no">
10     <link rel="apple-touch-icon" href="/icons/apple-touch.png">
11   </head>
12   <body>
13     % for message in h.flash.pop_messages():
14       <div class="flash">${message | n}</div>
15     % endfor
16     ${next.body()}
17     <div id="non-mobile">
18       <a href="${h.url_for(request.url, use_non_mobile='yes')}">Use non mobile interface</a>
19     </div>
20     ${h.javascript_link('/js/jquery-1.3.2.js')}
21     ${h.javascript_link('/js/mobile.js')}
22   </body>
23 </html>
24
25 <%!
26   from datetime import date
27 %>
28
29 <%def name="title()">BlueChips
30 % if c.title != '':
31   :: ${c.title}
32 % endif
33 </%def>
34
35 <%def name="formatUser(user)">
36   % if user == request.environ['user']:
37     <strong>Me</strong>
38   % else:
39     ${user.name}
40   % endif
41 </%def>
42
43 <%def name="tabs(selected)">
44   <div id="tabs">
45     % for name in ('status', 'spend', 'transfer'):
46       <%
47         if name == selected:
48           klass = 'selected'
49         else:
50           klass = 'unselected'
51       %>
52       <a id="${name}" class="${klass}" href="${h.url_for(controller=name, action='index', id=None)}">
53         <img src="/icons/${name}.png" alt="">
54         <span>${name.capitalize()}</span>
55       </a>
56     % endfor
57   </div>
58 </%def>
59
60 <%def name="spendForm()">
61   <div id="tab-spend" class="tab">
62     <%
63       if c.id != '':
64           id = c.id
65       else:
66           id = None
67     %>
68     <form action="${h.url_for(controller='spend', action='update', id=id)}" method="post">
69       ${h.auth_token_hidden_field()}
70       <table class="form">
71         <tr>
72           <th><label for="spender_id">Spender</label></th>
73           <td>${h.select('spender_id', [h.grab(c.expenditure, 'spender_id')], c.users)}</td>
74         </tr>
75         <tr>
76           <th><label for="amount">Amount</label></th>
77           <td>${h.currency('amount', h.grab(c.expenditure, 'amount'), size=8)}</td>
78         </tr>
79         <tr>
80           <th><label for="date">Date</label></th>
81           <td>${h.text('date', h.grab(c.expenditure, 'date').strftime('%m/%d/%Y'), size=16)}</td>
82         </tr>
83         <tr>
84           <th><label for="description">Description</label></th>
85           <td>${h.text('description', h.grab(c.expenditure, 'description'))}</td>
86         </tr>
87       </table>
88
89       <p>Change how an expenditure is split up.</p>
90
91       <table class="form">
92         % for ii, user_row in enumerate(c.users):
93           <%
94             user_id, user = user_row
95             if user.resident:
96               percent = 1
97             else:
98               percent = 0
99           %>
100           <tr>
101             <th><label for="shares-${ii}amount">${user.name}</label></th>
102             <td>
103               ${h.text('shares-%d.amount' % ii, percent)}
104               ${h.hidden('shares-%d.user_id' % ii, user.id)}
105             </td>
106           </tr>
107         % endfor
108         <tr>
109           <td colspan="2">
110             ${h.submit(None, 'Submit', class_="submitbutton")}
111           </td>
112         </tr>
113       </table>
114     </form>
115   </div>
116 </%def>
117
118 <%def name="transferForm()">
119   <%
120     if c.id != '':
121         id = c.id
122     else:
123         id = None
124   %>
125   <div id="tab-transfer" class="tab">
126     <form action="${h.url_for(controller='transfer', action='update', id=id)}" method="post">
127       ${h.auth_token_hidden_field()}
128       <table class="form">
129         <tr>
130           <th><label for="debtor_id">From</label></th>
131           <td>${h.select('debtor_id', [h.grab(c.transfer, 'debtor_id')], c.users)}</td>
132         </tr>
133         <tr>
134           <th><label for="creditor_id">To</label></th>
135           <td>${h.select('creditor_id', [h.grab(c.transfer, 'creditor_id')], c.users)}</td>
136         </tr>
137         <tr>
138           <th><label for="amount">Amount</label></th>
139           <td>${h.currency('amount', h.grab(c.transfer, 'amount'), size=8)}</td>
140         </tr>
141         <tr>
142           <th><label for="date">Date</label></th>
143           <td>${h.text('date', h.grab(c.transfer, 'date').strftime('%m/%d/%Y'), size=16)}</td>
144         </tr>
145         <tr>
146           <th><label for="description">Description</label></th>
147           <td>${h.text('description', h.grab(c.transfer, 'description'))}</td>
148         </tr>
149         <tr>
150           <td colspan="2">
151             <input type="submit" value="Submit" />
152           </td>
153         </tr>
154       </table>
155     </form>
156   </div>
157 </%def>