munin_api.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 onReadyPathVisibility() {
  42. if ($('#edit-munin-api-watchdog-init').attr('checked') === false) {
  43. $('#edit-munin-api-init-path-wrapper').hide();
  44. }
  45. $("input:radio[name='munin_api_watchdog']").click(function () {
  46. muninApiFade('#edit-munin-api-init-path-wrapper',
  47. $("input:radio[name='munin_api_watchdog']:checked").val() === 'init');
  48. });
  49. }
  50. /**
  51. * Assign ready handler
  52. */
  53. $(function () {
  54. onReadyPathVisibility();
  55. });