You are here

function newsletter_add_js in Newsletter 7

Add newsletter js file and settings.

2 calls to newsletter_add_js()
newsletter_block_view in ./newsletter.module
Implements hook_block_view().
newsletter_manage_subscriptions_form in includes/newsletter.pages.inc

File

./newsletter.module, line 1320
Defines menu items for newsletter administration, permissions and basic drupal hooks.

Code

function newsletter_add_js() {
  static $added;
  if ($added) {
    return;
  }
  drupal_add_js(drupal_get_path('module', 'newsletter') . '/js/newsletter.js');
  $lists = newsletter_exposed_lists();
  if (!field_is_translatable('newsletter_subscriber', field_info_field('field_newsletter_list'))) {
    $lang = LANGUAGE_NONE;
  }
  else {
    $lang = language_default()->language;
  }
  drupal_add_js(array(
    'exposed' => $lists,
    'lang' => $lang,
  ), 'setting');
  drupal_add_js('(function ($) {$(document).ready(function () {
    Drupal.behaviors.newsletter.subscribeForm();
  });})(jQuery);', 'inline');
  $added++;
}