You are here

function slider_pro_add in Slider Pro 7

This function loads the required JavaScripts and css for a slider pro instance.

Parameters

type $id:

type $option_set:

1 call to slider_pro_add()
template_preprocess_slider_pro_view in ./slider_pro.module
Display a view as a Slider Pro style.

File

./slider_pro.module, line 189

Code

function slider_pro_add($id = NULL, $option_set = NULL) {

  // Add library.
  if (!($library = libraries_load('slider-pro')) || empty($library['loaded'])) {
    drupal_set_message(t('Slider Pro library was not found.'), 'error');
    return FALSE;
  }

  // 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($option_set)) {

    // JavaScript settings
    $js_settings = array(
      'instances' => array(
        $id => $option_set,
      ),
    );

    // Add settings.
    drupal_add_js(array(
      'sliderPro' => $js_settings,
    ), 'setting');

    // Add loader file.
    drupal_add_js(drupal_get_path('module', 'slider_pro') . '/js/slider_pro_load.js', array(
      'type' => 'file',
      'scope' => 'footer',
    ));
  }
}