You are here

function flexslider_add in Flex Slider 7

Same name and namespace in other branches
  1. 8.2 flexslider.module \flexslider_add()
  2. 7.2 flexslider.module \flexslider_add()
3 calls to flexslider_add()
flexslider.api.php in ./flexslider.api.php
API documentation for FlexSlider
template_preprocess_flexslider_container in theme/flexslider.theme.inc
Template preprocess handler for 'flexslider_container' theme.
_flexslider_views_slideshow_preprocess_flexslider_views_slideshow_main_frame in flexslider_views_slideshow/theme/flexslider_views_slideshow.theme.inc
FlexSlider Views theme for the main wrapper element

File

./flexslider.module, line 265
A light-weight, customizable image gallery plugin for Drupal based on jQuery

Code

function flexslider_add($id = NULL, $optionset = NULL) {

  // Static array to remember which scripts are already attached.
  // @todo not currently in use
  $cache =& drupal_static(__FUNCTION__, array());

  // @todo investigate the best way to cache data loaded from drupal_add_library()
  drupal_add_library('flexslider', 'flexslider');

  // Moved theme configuration into hook_library_alter().
  // If the ID or optionset aren't set, it is assumed the settings will be set
  // manually via the calling module/theme
  if (!empty($id) && !empty($optionset)) {

    // JavaScript settings
    $js_settings = array(
      'optionsets' => array(
        $optionset->name => $optionset->options,
      ),
      'instances' => array(
        'flexslider-' . $id => $optionset->name,
      ),
    );
    drupal_add_js(array(
      'flexslider' => $js_settings,
    ), 'setting');
  }

  // Loader JavaScript
  drupal_add_js(drupal_get_path('module', 'flexslider') . '/assets/js/flexslider.load.js');
}