munin_api.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // $Id$
  2. /**
  3. * @file
  4. * Munin API for Drupal: settings UI eye candy
  5. *
  6. * @author Frederic G. MARAND
  7. *
  8. * @copyright (c) 2011 Ouest Systèmes Informatiques
  9. *
  10. * Licensed under the General Public License version 2 or later.
  11. */
  12. /*jslint white: true, onevar: true, undef: true, nomen: true, eqeqeq: true,
  13. plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true,
  14. indent: 2 */
  15. /*global Drupal,$ */
  16. /**
  17. * Fade a selection in or out, depending on the parameters
  18. *
  19. * @param string selector
  20. * A jQuery selector
  21. * @param boolean visible
  22. * Set to true to fade in, to fase to fade out
  23. * @return void
  24. */
  25. function muninApiFade(selector, visible) {
  26. if (visible) {
  27. $(selector).fadeIn();
  28. }
  29. else {
  30. $(selector).fadeOut();
  31. }
  32. }
  33. /**
  34. * Ready handler to apply visibility to the path field on the settings form.
  35. *
  36. * Hide the manual path selector initially unless the current watchdog mode is
  37. * set to init.
  38. *
  39. * @return void
  40. */
  41. function onReadySettingsVisibility() {
  42. if ($('#edit-munin-api-watchdog-init').attr('checked') === false) {
  43. $('#edit-munin-api-init-path-wrapper').hide();
  44. }
  45. if ($('#edit-munin-api-next-report').attr('checked') === false) {
  46. $('.munin-api-report').hide();
  47. }
  48. $("input:radio[name='munin_api_watchdog']").click(function () {
  49. muninApiFade('#edit-munin-api-init-path-wrapper',
  50. $("input:radio[name='munin_api_watchdog']:checked").val() === 'init');
  51. });
  52. $('#edit-munin-api-next-report').click(function () {
  53. muninApiFade('.munin-api-report',
  54. $("#edit-munin-api-next-report").attr('checked'));
  55. });
  56. }
  57. /**
  58. * Assign ready handler
  59. */
  60. $(function () {
  61. onReadySettingsVisibility();
  62. });