From 503cb9aa6aca8481c8e9cff99896a5fbbd9e5eb8 Mon Sep 17 00:00:00 2001 From: John Martin Date: Tue, 18 Dec 2012 12:07:14 +0000 Subject: [PATCH] [#1635] Tweaked the edit profile form notifications email checkbox --- ckan/public/base/less/forms.less | 7 +++++++ ckan/templates/macros/form.html | 22 ++++++++++++++++++++++ ckan/templates/user/edit_user_form.html | 16 +++++++--------- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/ckan/public/base/less/forms.less b/ckan/public/base/less/forms.less index 2ccf5a86d58..885cdc0d9ad 100644 --- a/ckan/public/base/less/forms.less +++ b/ckan/public/base/less/forms.less @@ -143,6 +143,13 @@ textarea { margin-top: 6px; } +.form-horizontal .info-help { + padding: 6px 0; +} +.form-horizontal .info-help-tight { + margin-top: -10px; +} + .form-horizontal .info-inline { float: right; width: 265px; diff --git a/ckan/templates/macros/form.html b/ckan/templates/macros/form.html index 6eb41dae25b..459a1606288 100644 --- a/ckan/templates/macros/form.html +++ b/ckan/templates/macros/form.html @@ -309,6 +309,28 @@ {%- endif -%} {% endmacro %} +{# +Renders an small help box with a description. This will usually be used +with in a call block when creating an input element. + +text - The text to include as a helper. +inline - If true displays the info box inline with the input. +classes - A list of classes to add to the info box. + +Example + + {% import 'macros/form.html' as form %} + {% call form.input('name') %} + {{ form.help(_('A little bit of text describing the input')) }} + {% endcall %} + +#} +{% macro help(text='', inline=false, classes=[]) %} + {%- if text -%} +
{{ text }}
+ {%- endif -%} +{% endmacro %} + {# Builds a space seperated list of html attributes from a dict of key/value pairs. Generally only used internally by macros. diff --git a/ckan/templates/user/edit_user_form.html b/ckan/templates/user/edit_user_form.html index 1a567d2af99..f56d1d46138 100644 --- a/ckan/templates/user/edit_user_form.html +++ b/ckan/templates/user/edit_user_form.html @@ -13,6 +13,13 @@ {{ form.input('email', label=_('Email'), id='field-email', type='email', value=data.email, error=errors.email, placeholder=_('eg. joe@example.com'), classes=['control-medium']) }} {{ form.markdown('about', label=_('About'), id='field-about', value=data.about, error=errors.about, placeholder=_('A little information about yourself')) }} + + {% if c.show_email_notifications %} + {% call form.checkbox('email_notifications', label=_('Subscribe to activity notification emails'), id='field-email-notifications', value=True, checked=c.userobj.email_notifications) %} + {{ form.help(_('Whenever there\'s a new activity on the site related to a thing that you follow you\'ll get a notification email'), classes=['info-help-tight']) }} + {% endcall %} + {% endif %} +
@@ -23,15 +30,6 @@ {{ form.input('password2', label=_('Confirm Password'), id='field-password-confirm', value=data.password2, error=errors.password2, classes=['control-medium']) }}
- {% if c.show_email_notifications %} -
- {{ _('Change your preferences') }} - - {{ form.checkbox('email_notifications', label=_('Email Notifications'), id='field-email-notifications', value=True, checked=c.userobj.email_notifications, classes=['control-medium']) }} - -
- {% endif %} -