You are here

function elf_init in External Links Filter 6.2

Same name and namespace in other branches
  1. 6.3 elf.module \elf_init()
  2. 7.3 elf.module \elf_init()

Implementation of hook_init().

File

./elf.module, line 21

Code

function elf_init() {
  if (variable_get('elf_css', TRUE)) {
    require_once 'includes/common.inc';
    $path = drupal_get_path('module', 'elf');
    drupal_add_css($path . '/elf.css');
  }
  if (variable_get('elf_window', FALSE)) {
    drupal_add_js('
      $(document).ready(function() {
        // Find all external links and let them open in a new window.
        $("a.external-link").each(function() {
          $(this).click(function() {
            window.open($(this).attr("href"));
            return false;
          });
        });
      });
    ', 'inline');
  }
}