source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/applications/admin/models/plugin_statebutton.py

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 735 bytes
Line 
1response.files.append(URL('static','plugin_statebutton/js/bootstrap-switch.js'))
2response.files.append(URL('static','plugin_statebutton/css/bootstrap-switch.css'))
3
4def stateWidget(field, value, data={'on-label':'Enabled', 'off-label':'Disabled', 'on':"primary", 'off':"default" }):
5    try:
6        fieldName = str(field).split('.')[1]
7    except:
8        fieldName = field
9
10    div = DIV(INPUT( _type='checkbox', _name='%s' % fieldName, _checked= 'checked' if value == 'true' else None, _value='true'),
11              _class='make-bootstrap-switch',
12              data=data)
13    script = SCRIPT("""
14        jQuery(".make-bootstrap-switch input[name='%s']").parent().bootstrapSwitch();
15    """ % fieldName)
16    return DIV(div, script)
Note: See TracBrowser for help on using the repository browser.