diff options
author | Jared Dillard <jdillard@netgate.com> | 2015-09-22 12:17:28 -0500 |
---|---|---|
committer | Jared Dillard <jdillard@netgate.com> | 2015-09-22 12:17:35 -0500 |
commit | 7c0f116b1155e778aa4a6831943fad9eef9db5d6 (patch) | |
tree | 5293dad366d824bb769dc44010452ff9b3227b20 /src/usr/local/www/diag_backup.php | |
parent | a50534b6078319711cbe8b31d164b30b28addec6 (diff) | |
download | pfsense-7c0f116b1155e778aa4a6831943fad9eef9db5d6.zip pfsense-7c0f116b1155e778aa4a6831943fad9eef9db5d6.tar.gz |
Ticket #5182 change show/hide functionality
Diffstat (limited to 'src/usr/local/www/diag_backup.php')
-rw-r--r-- | src/usr/local/www/diag_backup.php | 91 |
1 files changed, 83 insertions, 8 deletions
diff --git a/src/usr/local/www/diag_backup.php b/src/usr/local/www/diag_backup.php index cc93b5c..2302158 100644 --- a/src/usr/local/www/diag_backup.php +++ b/src/usr/local/www/diag_backup.php @@ -663,7 +663,7 @@ $section->addInput(new Form_Checkbox( 'Encryption', 'Encrypt this configuration file.', false -))->toggles('.toggle-passwords');; +)); $section->addInput(new Form_Input( 'encrypt_password', @@ -671,7 +671,7 @@ $section->addInput(new Form_Input( 'password', null, ['placeholder' => 'Password'] -))->addClass('toggle-passwords'); +)); $section->addInput(new Form_Input( 'encrypt_passconf', @@ -679,7 +679,7 @@ $section->addInput(new Form_Input( 'password', null, ['placeholder' => 'Confirm password'] -))->addClass('toggle-passwords'); +)); $group = new Form_Group(''); $group->add(new Form_Button( @@ -712,11 +712,11 @@ $section->addInput(new Form_Input( )); $section->addInput(new Form_Checkbox( - 'encrypt', + 'decrypt', 'Encryption', - 'Encrypt this configuration file.', + 'Configuration file is encrypted.', false -))->toggles('.toggle-dpasswords');; +)); $section->addInput(new Form_Input( 'decrypt_password', @@ -724,7 +724,7 @@ $section->addInput(new Form_Input( 'password', null, ['placeholder' => 'Password'] -))->addClass('toggle-dpasswords'); +)); $section->addInput(new Form_Input( 'decrypt_passconf', @@ -732,7 +732,7 @@ $section->addInput(new Form_Input( 'password', null, ['placeholder' => 'Confirm password'] -))->addClass('toggle-dpasswords'); +)); $group = new Form_Group(''); $group->add(new Form_Button( @@ -771,7 +771,82 @@ if (($config['installedpackages']['package'] != "") || (is_subsystem_dirty("pack } print($form); +?> +<script type="text/javascript"> +//<![CDATA[ +events.push(function(){ + //---------- "Standard" show/hide functions --------------------------------------------------- + + // Hides all elements of the specified class. This will usually be a section or group + function hideClass(s_class, hide) { + if(hide) + $('.' + s_class).hide(); + else + $('.' + s_class).show(); + } + + // Hides all elements of the specified class belonging to a multiselect. + function hideMultiClass(s_class, hide) { + if(hide) + $('.' + s_class).parent().parent().hide(); + else + $('.' + s_class).parent().parent().show(); + } + + // Hides the <div> in which the specified input element lives so that the input, its label and help text are hidden + function hideInput(id, hide) { + if(hide) + $('#' + id).parent().parent('div').addClass('hidden'); + else + $('#' + id).parent().parent('div').removeClass('hidden'); + } + // Hides the <div> in which the specified checkbox lives so that the checkbox, its label and help text are hidden + function hideCheckbox(id, hide) { + if(hide) + $('#' + id).parent().parent().parent('div').addClass('hidden'); + else + $('#' + id).parent().parent().parent('div').removeClass('hidden'); + } + + // Disables the specified input element + function disableInput(id, disable) { + $('#' + id).prop("disabled", disable); + } + + // ------- Show/hide sections based on checkbox settings -------------------------------------- + function hideSections(hide) { + hidePasswords(); + } + + function hidePasswords() { + + encryptHide = !($('input[name="encrypt"]').is(':checked')); + decryptHide = !($('input[name="decrypt"]').is(':checked')); + + hideInput('encrypt_password', encryptHide); + hideInput('encrypt_passconf', encryptHide); + hideInput('decrypt_password', decryptHide); + hideInput('decrypt_passconf', decryptHide); + } + + // ---------- Click checkbox handlers --------------------------------------------------------- + + $('input[name="encrypt"]').on('change', function() { + hidePasswords(); + }); + + $('input[name="decrypt"]').on('change', function() { + hidePasswords(); + }); + + // ---------- On itial page load -------------------------------------------------------------- + hideSections(); +}); +//]]> +</script> + +<?php include("foot.inc"); if (is_subsystem_dirty('restore')) { |