diff options
author | Nico von Geyso <Nico.Geyso@FU-Berlin.de> | 2012-09-29 01:58:04 +0200 |
---|---|---|
committer | Nico von Geyso <Nico.Geyso@FU-Berlin.de> | 2012-09-29 01:58:04 +0200 |
commit | 3f7c6fdee0b1f906d0d89bfa5573b94977905a24 (patch) | |
tree | a113a99fc4d0c81e8b00293c0015b5f87d1baefa /templates | |
parent | 6bb79f5a4a93c18024bdd7448c93f0babc1bc574 (diff) | |
download | web-3f7c6fdee0b1f906d0d89bfa5573b94977905a24.tar.gz web-3f7c6fdee0b1f906d0d89bfa5573b94977905a24.tar.bz2 web-3f7c6fdee0b1f906d0d89bfa5573b94977905a24.zip |
added some javascript code to handle visiblity of service forms
Diffstat (limited to 'templates')
-rw-r--r-- | templates/_macros.html | 12 | ||||
-rw-r--r-- | templates/base.html | 7 | ||||
-rw-r--r-- | templates/lost_password.html | 4 | ||||
-rw-r--r-- | templates/lost_password_complete.html | 4 | ||||
-rw-r--r-- | templates/register.html | 4 | ||||
-rw-r--r-- | templates/register_complete.html | 4 | ||||
-rw-r--r-- | templates/settings.html | 77 |
7 files changed, 85 insertions, 27 deletions
diff --git a/templates/_macros.html b/templates/_macros.html index 1608c1f..58739ae 100644 --- a/templates/_macros.html +++ b/templates/_macros.html @@ -1,3 +1,15 @@ +{% macro render_submit() %} +<div class="control-group"> + <div class="controls"> + <input type="submit" + {%- for key, value in kwargs.items() %} + {{key}}="{{value}}" + {% endfor %} + /> + </div> +</div> +{%- endmacro %} + {% macro render_field(field) %} <div class="control-group"> {{ field.label }} diff --git a/templates/base.html b/templates/base.html index df4658f..95384d9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,7 +1,6 @@ {%- set styles = ['layout.css', 'bootstrap-form.css'] + styles|default([]) %} {%- set scripts = ['jquery-1.8.2.min.js'] + scripts|default([]) %} -<!doctype html> -<html> +<!doctype html> <html> <head> <meta charset="utf-8" /> <title>{% if title %}{{ title }} – {% endif %}spline accounts</title> @@ -60,5 +59,9 @@ {% endif %} {% block content %}{% endblock %} </section> + + <script type="text/javascript"> + {% block javascript %}{% endblock %} + </script> </body> </html> diff --git a/templates/lost_password.html b/templates/lost_password.html index 0856366..7f6dbd7 100644 --- a/templates/lost_password.html +++ b/templates/lost_password.html @@ -1,5 +1,5 @@ {%- extends 'base.html' %} -{%- from '_macros.html' import render_field %} +{%- from '_macros.html' import render_field, render_submit %} {%- set title = 'Passwort vergessen' %} {%- set no_login_message = true %} {%- block content %} @@ -10,6 +10,6 @@ mit dem du dir ein neues setzen kannst. </p> {{ render_field(form.username, autofocus="autofocus") }} - <div class="form-actions"><input type="submit" value="Weiter" /></div> + {{ render_submit(value='Weiter')}} </form> {%- endblock %} diff --git a/templates/lost_password_complete.html b/templates/lost_password_complete.html index de59d64..6ab4a1c 100644 --- a/templates/lost_password_complete.html +++ b/templates/lost_password_complete.html @@ -1,5 +1,5 @@ {%- extends 'base.html' %} -{%- from '_macros.html' import render_field %} +{%- from '_macros.html' import render_field, render_submit %} {%- set title = 'Passwort vergessen' %} {%- set no_login_message = true %} {%- block content %} @@ -13,6 +13,6 @@ </div> {{ render_field(form.password, autofocus="autofocus") }} {{ render_field(form.password_confirm) }} - <div class="form-actions"><input type="submit" value="Speichern" /></div> + {{ render_submit(value='Speichern')}} </form> {%- endblock %} diff --git a/templates/register.html b/templates/register.html index 2fe562a..489a7a0 100644 --- a/templates/register.html +++ b/templates/register.html @@ -1,11 +1,11 @@ {%- extends 'base.html' %} -{%- from '_macros.html' import render_field %} +{%- from '_macros.html' import render_field, render_submit %} {%- set title = 'Account erstellen' %} {%- set no_login_message = true %} {%- block content %} <form action="{{ url_for('register') }}" method="post" class="form-horizontal"> {{ render_field(form.username, autofocus="autofocus") }} {{ render_field(form.mail) }} - <div class="form-actions"><input type="submit" value="E-Mail-Adresse bestätigen" /></div> + {{ render_submit(value='E-Mail-Adresse bestätigen')}} </form> {%- endblock %} diff --git a/templates/register_complete.html b/templates/register_complete.html index 1372b7f..558606a 100644 --- a/templates/register_complete.html +++ b/templates/register_complete.html @@ -1,5 +1,5 @@ {%- extends 'base.html' %} -{%- from '_macros.html' import render_field %} +{%- from '_macros.html' import render_field, render_submit %} {%- set title = 'Account erstellen' %} {%- set no_login_message = true %} {%- block content %} @@ -19,6 +19,6 @@ </div> {{ render_field(form.password, autofocus="autofocus") }} {{ render_field(form.password_confirm) }} - <div class="form-actions"><input type="submit" value="Registrieren" /></div> + {{ render_submit(value='Registrieren')}} </form> {%- endblock %} diff --git a/templates/settings.html b/templates/settings.html index 8bf3d7e..241ea00 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -1,5 +1,5 @@ {%- extends 'base.html' %} -{%- from '_macros.html' import render_field, render_csrf %} +{%- from '_macros.html' import render_field, render_csrf, render_submit %} {%- set title = 'Einstellungen' %} {%- block content %} <form action="{{ url_for('settings') }}" method="post" class="form-horizontal"> @@ -8,25 +8,68 @@ {{ render_field(form.password) }} {{ render_field(form.password_confirm) }} {{ render_csrf(form) }} - <div class="form-actions"><input type="submit" value="Speichern" name="submit_main" /></div> + {{ render_submit(value='Speichern',name='submit_main') }} <h2>Dienste verwalten</h2> + <p> + Du kannst für jeden Dienst ein eigenes Passwort setzen: + </p> + {%- for service in services %} - <h3> - {{ service.name }} - <small> - {%- if service.changed %} - <span class="active">aktiv</span> - <a href="{{ url_for('settings',delete_service_password=service.name)}}">löschen</a> - {%- else %} - <span class="inactive">inaktiv</span> - {%- endif %} - </small> - </h3> - <p>Neues Passwort setzen:</p> - {{ render_field(form.get_servicepassword(service.id)) }} - {{ render_field(form.get_servicepasswordconfirm(service.id)) }} - <input type="submit" value="Speichern" name="submit_main" /> + <div class="service"> + <h3> + {{ service.name }} + </h3> + + <ul> + {%- if service.changed %} + <li class="active">aktiv</li> + <li> + <a href="{{ url_for('settings',delete_service_password=service.name)}}">löschen</a> + </li> + {%- else %} + <li class="inactive">inaktiv</li> + {%- endif %} + </ul> + + <div class="form-service"> + <p>Neues Passwort setzen:</p> + {{ render_field(form.get_servicepassword(service.id)) }} + {{ render_field(form.get_servicepasswordconfirm(service.id)) }} + {{ render_submit(value='Speichern',name='submit_main') }} + </div> + </div> {%- endfor %} </form> {%- endblock %} + + +{% block javascript %} + $(document).ready(function() { + + $('.service').each(function() { + var header = $(this).find('h3'); + var list = $(this).find('ul'); + var content = $(this).find('.form-service'); + var elem = $('<a class="service-edit" href="">bearbeiten</a>') + + elem.click(function() { + content.toggle(); + + return false; + }); + + console.log(list.find('a')) + if(list.find('a').length > 0) { + list.find('a').parent().prepend(elem); + } else { + var li = $('<li></li>'); + li.append(elem); + list.append(li); + } + + content.hide(); + }); + + }); +{% endblock %} |