You are here

function acquia_lift_library in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift.module \acquia_lift_library()

Implements hook_library().

File

./acquia_lift.module, line 1114
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_library() {
  $path = drupal_get_path('module', 'acquia_lift');
  $options = array(
    'scope' => 'footer',
    'defer' => TRUE,
  );

  // Acquia lift campaign management toolbar.
  $libraries['acquia_lift.personalize'] = array(
    'title' => 'Acquia lift navigation',
    'website' => '',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.personalize.js' => $options,
      array(
        'data' => array(
          'personalize' => array(
            'links' => array(
              'campaigns' => array(
                'getActive' => url('personalize/campaign_context'),
                'setActive' => url('personalize/campaign_context/') . '%personalize_agent',
              ),
            ),
          ),
        ),
        'type' => 'setting',
      ),
    ),
    'css' => array(
      $path . '/css/acquia_lift.personalize.css' => array(),
      $path . '/css/acquia_lift.personalize.theme.css' => array(),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'system',
        'drupal.ajax',
      ),
      array(
        'acquia_lift',
        'underscore',
      ),
      array(
        'acquia_lift',
        'backbone',
      ),
      array(
        'visitor_actions_ui',
        'utilities.backbone_parent',
      ),
    ),
  );
  $libraries['acquia_lift.page'] = array(
    'title' => 'Adds Acquia Lift page processing necessary for all page views.',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.page.js' => $options,
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'acquia_lift',
        'acquia_lift.agent_api',
      ),
    ),
  );
  $libraries['acquia_lift.agent_api'] = array(
    'title' => 'Adds the Acquia Lift API files.',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.goals_queue.js' => $options,
      $path . '/js/acquia-lift-js-wrapper-min.js' => array(
        'type' => 'file',
        'scope' => 'header',
      ),
      $path . '/js/acquia_lift.api.js' => $options,
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
    ),
  );
  $libraries['acquia_lift.fields'] = array(
    'title' => 'Add navigation to personalizable fields',
    'website' => '',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.fields.js' => $options,
    ),
    'css' => array(
      $path . '/css/acquia_lift.fields.theme.css' => array(),
      $path . '/css/acquia_lift.fields.admin.css' => array(),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
    ),
  );

  // Note that there is an additional CSS file: acquia_lift.ctools.modal.css.
  // It needs to be loaded separately in order to be processed after CTools
  // default modal CSS.
  $libraries['acquia_lift.modal'] = array(
    'title' => 'Acquia Lift modal campaign management',
    'website' => '',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.flow.js' => $options,
      array(
        'data' => array(
          'acquia-lift-style' => array(
            'modalSize' => array(
              'type' => 'dynamic',
              'width' => 450,
              'addWidth' => 0,
              'addHeight' => 0,
              'contentRight' => 0,
              'contentBottom' => 0,
            ),
            'modalTheme' => 'AcquiaLiftModalDialog',
            'modalOptions' => array(
              'background-color' => '#000000',
            ),
            'closeImage' => theme('image', array(
              'path' => ctools_image_path('close.png', 'acquia_lift'),
              'alt' => t('Close window'),
              'title' => t('Close window'),
            )),
            'closeText' => '',
          ),
        ),
        'type' => 'setting',
      ),
    ),
    'css' => array(
      $path . '/css/acquia_lift.buttons.css' => array(),
      $path . '/css/acquia_lift.dialog.css' => array(),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'system',
        'drupal.states',
      ),
      array(
        'acquia_lift',
        'underscore',
      ),
      array(
        'acquia_lift',
        'backbone',
      ),
      array(
        'visitor_actions_ui',
        'ui.element_dialog',
      ),
      array(
        'visitor_actions_ui',
        'utilities.element_selector',
      ),
      array(
        'acquia_lift',
        'acquia_lift.message_box',
      ),
      array(
        'acquia_lift',
        'acquia_lift.dom_selector',
      ),
    ),
  );
  $libraries['acquia_lift.dom_selector'] = array(
    'title' => 'DOM selection library',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.dom_selector.js' => $options,
    ),
    'dependencies' => array(
      array(
        'acquia_lift',
        'qtip',
      ),
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
    ),
  );

  // Message box
  $libraries['acquia_lift.message_box'] = array(
    'title' => 'Assets to display a message box.',
    'website' => '',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.messagebox.js' => $options,
    ),
    'css' => array(
      $path . '/css/acquia_lift.messagebox.css' => array(),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
    ),
  );

  // Navbar module integration.
  $libraries['acquia_lift.navbar'] = array(
    'title' => 'Assets for integration with the Navbar module',
    'website' => 'http://drupal.org/project/navbar',
    'version' => '1.0',
    'js' => array(
      $path . '/js/acquia_lift.navbar.js' => $options,
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
    ),
  );

  // If navbar is enabled before the class names were changed from .menu then include the old css.
  if (acquia_lift_using_older_navbar()) {
    $libraries['acquia_lift.navbar']['css'][$path . '/css/acquia_lift.navbar_1-5.css'] = array(
      'weight' => 100,
    );
  }
  else {

    // Navbar is not enabled, or it is enabled with the later menu class names.
    $libraries['acquia_lift.navbar']['css'][$path . '/css/acquia_lift.navbar.css'] = array(
      'weight' => 100,
    );
  }

  // Save the menu class name to be used.
  $libraries['acquia_lift.navbar']['js'][] = array(
    'data' => array(
      'acquia_lift' => array(
        'menuClass' => acquia_lift_unibar_menu_class(),
      ),
    ),
    'type' => 'setting',
  );

  // Toolbar module integration.
  $libraries['acquia_lift.toolbar'] = array(
    'title' => 'Assets for integration with toolbar module',
    'website' => 'https://www.drupal.org/project/toolbar',
    'version' => '1.0',
    'js' => array(
      $path . '/js/acquia_lift.unified_navbar.toolbar.js' => array(),
    ),
    'dependencies' => array(
      array(
        'acquia_lift',
        'acquia_lift.unified.navbar',
      ),
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.debounce',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.displace',
      ),
    ),
  );

  // Admin_menu module integration.
  $libraries['acquia_lift.admin_menu'] = array(
    'title' => 'Assets for integration with admin_menu module',
    'website' => 'https://www.drupal.org/project/admin_menu',
    'version' => '1.0',
    'js' => array(
      $path . '/js/acquia_lift.unified_navbar.admin_menu.js' => array(),
    ),
    'dependencies' => array(
      array(
        'acquia_lift',
        'acquia_lift.unified.navbar',
      ),
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.debounce',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.displace',
      ),
    ),
  );

  // Unified navigation bar.
  $libraries['acquia_lift.unified.navbar'] = array(
    'title' => 'Unified navbar',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.unified_navbar.js' => array(),
      // The regular navbar file generates the drop-downs.
      $path . '/js/acquia_lift.navbar.js' => array(),
    ),
    'css' => array(
      $path . '/css/acquia_lift.unified_navbar.css',
      $path . '/css/navbar/navbar.module.css',
      $path . '/css/navbar/navbar.theme.css',
      $path . '/css/navbar/navbar.icons.css',
      $path . '/css/acquia_lift.navbar.css',
    ),
    'dependencies' => array(
      array(
        'acquia_lift',
        'modernizr',
      ),
      array(
        'system',
        'jquery',
      ),
      array(
        'acquia_lift',
        'underscore',
      ),
      array(
        'acquia_lift',
        'backbone',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.matchmedia',
      ),
      array(
        'system',
        'jquery.once',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.debounce',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.announce',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.displace',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.menu',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.tableheader',
      ),
    ),
  );

  // Set the menu class to be used.
  $libraries['acquia_lift.unified.navbar']['js'][] = array(
    'data' => array(
      'acquia_lift' => array(
        'menuClass' => acquia_lift_unibar_menu_class(),
      ),
    ),
    'type' => 'setting',
  );

  // Only load navbar.overlay if overlay is enabled.
  if (module_exists('overlay')) {
    $libraries['acquia_lift.unified.navbar']['dependencies'][] = array(
      'acquia_lift',
      'acquia_lift.navbar.overlay',
    );
  }

  // Reporting
  $libraries['acquia_lift.reports'] = array(
    'title' => 'Acquia Lift Reporting',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.reports.js' => array(),
    ),
    'css' => array(
      $path . '/css/acquia_lift.reports.css',
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'ui.slider',
      ),
      array(
        'acquia_lift',
        'd3',
      ),
      array(
        'acquia_lift',
        'rickshaw',
      ),
    ),
  );

  // Help tooltips
  $libraries['acquia_lift.help'] = array(
    'title' => 'Acquia Lift Help Tooltips',
    'version' => VERSION,
    'js' => array(
      $path . '/js/acquia_lift.help.js' => array(),
    ),
    'css' => array(
      $path . '/css/acquia_lift.help.css',
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'acquia_lift',
        'qtip',
      ),
    ),
  );

  /*** 3rd PARTY LIBRARY DEPENDENCIES ***/

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

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

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

  // QTip
  $libraries['qtip'] = _acquia_lift_convert_libraries_to_library(libraries_detect('qtip'), array(
    'group' => JS_LIBRARY,
    'weight' => -15,
  ));

  // D3
  $libraries['d3'] = _acquia_lift_convert_libraries_to_library(libraries_detect('d3'), array(
    'group' => JS_LIBRARY,
    'weight' => -18,
  ));

  // Rickshaw
  $libraries['rickshaw'] = _acquia_lift_convert_libraries_to_library(libraries_detect('rickshaw'), array(
    'group' => JS_LIBRARY,
    'weight' => -15,
  ));

  /*** REQUIRED BY ACQUIA LIFT UNIFIED NAVBAR ***/

  // All libraries below this point are dependencies for the unified navbar.
  // These are identical to navbar dependencies.
  $libraries['acquia_lift.navbar.menu'] = array(
    'title' => 'Navbar nested accordion menus.',
    'version' => VERSION,
    'js' => array(
      $path . '/js/navbar/navbar.menu.js' => array(),
    ),
    'css' => array(
      $path . '/css/navbar/navbar.menu.css',
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'system',
        'jquery.once',
      ),
    ),
  );

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

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

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

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

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

  // Support Tableheader displacement.
  $libraries['acquia_lift.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/navbar-tableheader.js' => array(
        'weight' => 100,
      ),
    ),
    'dependencies' => array(
      array(
        'system',
        'jquery',
      ),
      array(
        'acquia_lift',
        'acquia_lift.navbar.displace',
      ),
    ),
  );
  return $libraries;
}