1 | # Template helpers |
---|
2 | |
---|
3 | import os |
---|
4 | |
---|
5 | |
---|
6 | def A_button(*a, **b): |
---|
7 | b['_data-role'] = 'button' |
---|
8 | b['_data-inline'] = 'true' |
---|
9 | return A(*a, **b) |
---|
10 | |
---|
11 | def button(href, label): |
---|
12 | if is_mobile: |
---|
13 | ret = A_button(SPAN(label), _href=href) |
---|
14 | else: |
---|
15 | ret = A(SPAN(label), _class='button btn', _href=href) |
---|
16 | return ret |
---|
17 | |
---|
18 | def button_enable(href, app): |
---|
19 | if os.path.exists(os.path.join(apath(app, r=request), 'DISABLED')): |
---|
20 | label = SPAN(T('Enable'), _style='color:red') |
---|
21 | else: |
---|
22 | label = SPAN(T('Disable'), _style='color:green') |
---|
23 | id = 'enable_' + app |
---|
24 | return A(label, _class='button btn', _id=id, callback=href, target=id) |
---|
25 | |
---|
26 | def sp_button(href, label): |
---|
27 | if request.user_agent().get('is_mobile'): |
---|
28 | ret = A_button(SPAN(label), _href=href) |
---|
29 | else: |
---|
30 | ret = A(SPAN(label), _class='button special btn btn-inverse', _href=href) |
---|
31 | return ret |
---|
32 | |
---|
33 | def helpicon(): |
---|
34 | return IMG(_src=URL('static', 'images/help.png'), _alt='help') |
---|
35 | |
---|
36 | def searchbox(elementid): |
---|
37 | return SPAN(LABEL(IMG(_id="search_start", _src=URL('static', 'images/search.png'), _alt=T('filter')), |
---|
38 | _class='icon', _for=elementid), ' ', |
---|
39 | INPUT(_id=elementid, _type='text', _size=12, _class="input-medium"), |
---|
40 | _class="searchbox") |
---|