You are here

function apachesolr_js in Apache Solr Search 6.2

2 calls to apachesolr_js()
theme_apachesolr_facet_list in ./apachesolr.module
theme_apachesolr_unclick_link in ./apachesolr.module

File

./apachesolr.module, line 2299
Integration with the Apache Solr search application.

Code

function apachesolr_js() {
  static $settings;

  // Only add the js stuff once.
  if (is_null($settings)) {
    $settings['apachesolr_facetstyle'] = variable_get('apachesolr_facetstyle', 'checkboxes');

    // This code looks for enabled facet blocks and injects the block #ids into
    // Drupal.settings as jQuery selectors to add the Show more links.
    $show_more_blocks = array();
    $facet_map = array();
    foreach (apachesolr_get_facet_definitions() as $module => $definitions) {
      foreach ($definitions as $facet => $facet_definition) {
        $facet_map[$facet_definition['facet_field']] = $facet;
      }
    }
    $show_more_selector = array();
    foreach (apachesolr_get_enabled_facets() as $module => $blocks) {
      foreach ($blocks as $block) {
        $show_more_selector[] = "#block-{$module}-{$facet_map[$block]}:has(.apachesolr-hidden-facet) .apachesolr-facet-list";
      }
    }
    $settings['apachesolr_show_more_blocks'] = implode(', ', $show_more_selector);
    drupal_add_js($settings, 'setting');
    drupal_add_js(drupal_get_path('module', 'apachesolr') . '/apachesolr.js');
  }
}