diff --git a/comment_notify.module b/comment_notify.module index b7613c9..0b8badd 100644 --- a/comment_notify.module +++ b/comment_notify.module @@ -54,6 +54,21 @@ by creating your own user with a few clicks here [site:login-url] [site:url]'); +/** + * Implements hook_init(). + */ +function comment_notify_init() { + // Add CSS/JS. + $options = array('every_page' => TRUE); + $path = drupal_get_path('module', 'comment_notify'); + drupal_add_css($path . '/comment_notify.css', $options); + + // We only add the JS if more than one subscription mode is enabled. + $available_options = _comment_notify_options(); + if (count($available_options) > 1) { + drupal_add_js($path . '/comment_notify.js', $options); + } +} /** * Provide an array of available options for notification on a comment. @@ -91,13 +106,9 @@ function comment_notify_form_comment_form_alter(&$form, &$form_state, $form_id) } $available_options = _comment_notify_options(); - - drupal_add_css(drupal_get_path('module', 'comment_notify') . '/comment_notify.css'); - drupal_add_js(drupal_get_path('module', 'comment_notify') . '/comment_notify.js'); - // Add the checkbox for anonymous users. if ($user->uid == 0) { - // If anonymous user's can't enter their e-mail don't tempt them with the checkbox. + // If anonymous users can't enter their e-mail don't tempt them with the checkbox. if (empty($form['author']['mail'])) { return; }