diff --git a/comment_notify.js b/comment_notify.js index 16f352a..8356722 100644 --- a/comment_notify.js +++ b/comment_notify.js @@ -1,19 +1,15 @@ (function ($) { - Drupal.behaviors.commentNotify = { - attach: function (context) { - $('#edit-notify-type', context).hide(); - $('#edit-notify', context).bind('change', function() { - if ($(this).attr('checked')) { - $('#edit-notify-type', context).show(); - if ($('#edit-notify-type input:checked', context).length == 0) { - $('#edit-notify-type input', context)[0].checked = 'checked'; - } - } - else { - $('#edit-notify-type', context).hide(); - } - }); - $('#edit-notify', context).trigger('change'); - } + +Drupal.behaviors.commentNotify = { + attach: function (context) { + $('#edit-notify', context) + .bind('change', function() { + $('#edit-notify-type', context) + [this.checked ? 'show' : 'hide']() + .find('input[type=checkbox]:checked').attr('checked', 'checked'); + }) + .trigger('change'); } +} + })(jQuery);