Commit 1d22e7a0 authored by greggles's avatar greggles Committed by greggles

Issue #1224444 by greggles | sun: Only add javascript if truly necessary,...

Issue #1224444 by greggles | sun: Only add javascript if truly necessary, optimize css/js addition for sitewide performance
parent a0cea691
......@@ -54,6 +54,22 @@ by creating your own user with a few clicks here [site:login-url]
[site:url]');
/**
* Implements hook_init().
*/
function comment_notify_init() {
// Add on every page - they are both very small so it's better to add
// everywhere than force a second file on some pages.
$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 +107,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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment