diff --git a/comment_notify.module b/comment_notify.module index b7613c9..b615e1a 100644 --- a/comment_notify.module +++ b/comment_notify.module @@ -54,6 +54,18 @@ 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. We only need the JS if they have options. + $options = array('every_page' => TRUE); + drupal_add_css(drupal_get_path('module', 'comment_notify') . '/comment_notify.css', $options); + $available_options = _comment_notify_options(); + if (count($available_options) > 1) { + drupal_add_js(drupal_get_path('module', 'comment_notify') . '/comment_notify.js', $options); + } +} /** * Provide an array of available options for notification on a comment. @@ -91,10 +103,6 @@ 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.