forked from jan/debianmemberportfolio
add checkbox and ECMAScript code to toggle display of all fields
This commit is contained in:
parent
d3fe053dd3
commit
8b1613346e
2 changed files with 32 additions and 1 deletions
|
@ -42,6 +42,10 @@ ${h.form(h.url_for(action='urllist'), method='get')}
|
|||
${h.text('email',
|
||||
h.escape(request.params.get('email', None), True), id='email')}<br />
|
||||
</div>
|
||||
<div id="showallfield">
|
||||
${h.checkbox('showall', value='1', checked=False, id='showall')}
|
||||
<label for="showall">${_(u'Show all form fields')}</label><br />
|
||||
</div>
|
||||
<div id="namefield" \
|
||||
% if 'name' in c.messages['errors']:
|
||||
class="witherrors" \
|
||||
|
|
|
@ -20,6 +20,17 @@ License along with this program. If not, see
|
|||
<http://www.gnu.org/licenses/>.
|
||||
</%doc>
|
||||
|
||||
var defaulthiddendivs = new Array(
|
||||
'#gpgfpfield');
|
||||
var defaultreadonlydivs = new Array(
|
||||
'#gpgfpfield');
|
||||
var maskedfielddivs = new Array(
|
||||
'#namefield', '#gpgfpfield', '#usernamefield', '#nonddemailfield',
|
||||
'#aliothusernamefield');
|
||||
var allfielddivs = new Array(
|
||||
'#namefield', '#gpgfpfield', '#usernamefield', '#nonddemailfield',
|
||||
'#aliothusernamefield');
|
||||
|
||||
function updateFields(data, textStatus) {
|
||||
if (data.type == 2) { // DD
|
||||
$('#name').attr('value', data.name).attr('readonly', 'readonly');
|
||||
|
@ -66,7 +77,15 @@ function updateFields(data, textStatus) {
|
|||
}
|
||||
|
||||
function onChangeShowAll(event) {
|
||||
alert(event);
|
||||
if ($('#showall').attr('checked')) {
|
||||
for (var fielddiv in allfielddivs) {
|
||||
$(allfielddivs[fielddiv]).show();
|
||||
}
|
||||
} else {
|
||||
for (var fielddiv in maskedfielddivs) {
|
||||
$(maskedfielddivs[fielddiv]).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onBlurEmail() {
|
||||
|
@ -92,6 +111,14 @@ $(document).ready(function() {
|
|||
$(fields[index]).hide();
|
||||
}
|
||||
}
|
||||
for (var index in defaulthiddendivs) {
|
||||
$(defaulthiddendivs[index]).hide();
|
||||
}
|
||||
for (var index in defaultreadonlydivs) {
|
||||
$(defaultreadonlydivs[index]).hide();
|
||||
}
|
||||
|
||||
$('#email').blur(onBlurEmail).focus();
|
||||
$('#showall').attr('checked', false);
|
||||
$('#showall').change(onChangeShowAll);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue