You are here

function navbar_library in Navbar 7

Implements hook_library().

File

./navbar.module, line 620
Administration navbar for quick access to top level administration items.

Code

function navbar_library() {
  $path = drupal_get_path('module', 'navbar');
  $libraries['navbar'] = array(
    'title' => 'Navbar',
    'version' => VERSION,
    'js' => array(
      $path . '/js/navbar.js' => array(),
    ),
    'css' => array(
      $path . '/css/navbar.module.css',
      $path . '/css/navbar.theme.css',
      $path . '/css/navbar.icons.css',
    ),
    'dependencies' => array(
      array(
        'navbar',
        'modernizr',
      ),
      array(
        'system',
        'jquery',
      ),
      array(
        'navbar',
        'underscore',
      ),
      array(
        'navbar',
        'backbone',
      ),
      array(
        'navbar',
        'navbar.matchmedia',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'navbar',
        'navbar.debounce',
      ),
      array(
        'navbar',
        'navbar.announce',
      ),
      array(
        'navbar',
        'navbar.displace',
      ),
      array(
        'navbar',
        'navbar.menu',
      ),
      array(
        'navbar',
        'navbar.tableheader',
      ),
      array(
        'navbar',
        'navbar.escape_admin',
      ),
    ),
  );

  // Only load navbar.overlay if overlay is enabled.
  if (module_exists('overlay')) {
    $libraries['navbar']['dependencies'][] = array(
      'navbar',
      'navbar.overlay',
    );
  }
  $libraries['navbar.escape_admin'] = array(
    'title' => 'Provides a button to escape the administration area.',
    'version' => VERSION,
    'js' => array(
      $path . '/js/escape-admin.js' => array(),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
    ),
  );
  $libraries['navbar.menu'] = array(
    'title' => 'Navbar nested accordion menus.',
    'version' => VERSION,
    'js' => array(
      $path . '/js/navbar.menu.js' => array(),
    ),
    'css' => array(
      $path . '/css/navbar.menu.css',
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
    ),
  );

  // Backport of D8 matchMedia polyfill.
  $libraries['navbar.matchmedia'] = array(
    'title' => 'window.matchMedia polyfill',
    'website' => 'http://drupal.org/node/1815602',
    'version' => VERSION,
    'js' => array(
      $path . '/js/matchmedia.js' => array(),
    ),
  );

  // A utility function to limit calls to a function with a given time.
  $libraries['navbar.debounce'] = array(
    'title' => 'Navbar debounce',
    'version' => VERSION,
    'js' => array(
      $path . '/js/debounce.js' => array(
        'group' => JS_LIBRARY,
      ),
    ),
  );

  // A utility function determine viewport offset distances.
  $libraries['navbar.displace'] = array(
    'title' => 'Navbar displace',
    'version' => VERSION,
    'js' => array(
      $path . '/js/displace.js' => array(
        'group' => JS_LIBRARY,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'navbar',
        'navbar.debounce',
      ),
    ),
  );

  // A utility for writing text to a common aria-live region.
  $libraries['navbar.announce'] = array(
    'title' => 'Navbar announce',
    'version' => VERSION,
    'js' => array(
      $path . '/js/announce.js' => array(
        'group' => JS_LIBRARY,
      ),
    ),
    'dependencies' => array(
      array(
        'navbar',
        'navbar.debounce',
      ),
    ),
  );

  // Override Overlay methods to support displacement.
  $libraries['navbar.overlay'] = array(
    'title' => 'Overlay method overrides to support D8 viewport displacement.',
    'version' => VERSION,
    'css' => array(
      $path . '/css/navbar-overlay.css',
    ),
    'js' => array(
      // Load this file well after Overlay code has loaded.
      $path . '/js/navbar-overlay.js' => array(
        'weight' => 100,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'navbar',
        'navbar.displace',
      ),
    ),
  );

  // Support Tableheader displacement.
  $libraries['navbar.tableheader'] = array(
    'title' => 'Tableheader method to support D8 viewport displacement.',
    'version' => VERSION,
    'js' => array(
      // Load this file well after Overlay code has loaded.
      $path . '/js/navbar-tableheader.js' => array(
        'weight' => 100,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'navbar',
        'navbar.displace',
      ),
    ),
  );

  // Ensure that each 3rd party library dependency has a default variant.
  // Convert Libraries module data structures to library data structures.
  // Modernizr
  $libraries['modernizr'] = _navbar_convert_libraries_to_library(libraries_detect('modernizr'), array(
    'group' => JS_LIBRARY,
    'weight' => -100,
  ));

  // Underscore
  $libraries['underscore'] = _navbar_convert_libraries_to_library(libraries_detect('underscore'), array(
    'group' => JS_LIBRARY,
    'weight' => -20,
  ));

  // Backbone
  $libraries['backbone'] = _navbar_convert_libraries_to_library(libraries_detect('backbone'), array(
    'group' => JS_LIBRARY,
    'weight' => -19,
  ));
  return $libraries;
}