Add reveling field support for settings

HFP-495
pull/38/head
Frode Petterson 2017-02-20 15:06:42 +01:00
parent 8f132cfffb
commit c4b88c3992
1 changed files with 32 additions and 1 deletions

View File

@ -16,8 +16,39 @@
toggle(); toggle();
} }
function setupRevealing() {
var $button = $(this);
// Getting the field which should have the value:
var $input = $('#' + $button.data('control'));
if (!$input.data('value')) {
$button.remove();
return;
}
// Setup button action
var revealed = false;
var text = $button.html();
$button.click(function () {
if (revealed) {
$input.val('');
$button.html(text);
revealed = false;
}
else {
$input.val($input.data('value'));
$button.html($button.data('hide'));
revealed = true;
}
});
}
$(document).ready(function () { $(document).ready(function () {
// Get the checkboxes making other fields being hidden: // Get the checkboxes making other fields being hidden:
$('.h5p-visibility-toggler').each(setupHiding); $('.h5p-visibility-toggler').each(setupHiding);
// Get the buttons making other fields have hidden values:
$('.h5p-reveal-value').each(setupRevealing);
}); });
})(H5P.jQuery); })(H5P.jQuery);