/** * @file * Munin API for Drupal: settings UI eye candy * * @copyright (c) 2011-2019 Ouest Systèmes Informatiques * * Licensed under the General Public License version 2 or later. */ /*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, indent: 2 */ /*global Drupal,$ */ /** * Fade a selection in or out, depending on the parameters * * @param string selector * A jQuery selector * @param boolean visible * Set to true to fade in, to fase to fade out * @return void */ function muninApiFade(selector, visible) { if (visible) { $(selector).fadeIn(); } else { $(selector).fadeOut(); } } /** * Ready handler to apply visibility to the path field on the settings form. * * Hide the manual path selector initially unless the current watchdog mode is * set to init. * * @return void */ function onReadySettingsVisibility() { if ($('#edit-munin-api-watchdog-init').attr('checked') === false) { $('#edit-munin-api-init-path-wrapper').hide(); } if ($('#edit-munin-api-next-report').attr('checked') === false) { $('.munin-api-report').hide(); } $("input:radio[name='munin_api_watchdog']").click(function () { muninApiFade('#edit-munin-api-init-path-wrapper', $("input:radio[name='munin_api_watchdog']:checked").val() === 'init'); }); $('#edit-munin-api-next-report').click(function () { muninApiFade('.munin-api-report', $("#edit-munin-api-next-report").attr('checked')); }); } /** * Assign ready handler */ $(function () { onReadySettingsVisibility(); });