You are here

public function JuiceboxGallery::getJavascriptVars in Juicebox HTML5 Responsive Image Galleries 8.2

Same name and namespace in other branches
  1. 8.3 src/JuiceboxGallery.php \Drupal\juicebox\JuiceboxGallery::getJavascriptVars()

Get the variables needed to instantiate a new JS Juicebox.

These values can be used as direct constructor inputs for a new juicebox object.

Parameters

string $xml_url: The URL to the Juicebox XML for this gallery.

Return value

array An associative array of properties that can be used as direct constructor inputs for a new JS Juicebox object.

Overrides JuiceboxGalleryInterface::getJavascriptVars

1 call to JuiceboxGallery::getJavascriptVars()
JuiceboxGallery::renderJavascript in src/JuiceboxGallery.php
Get javascript code for Juicebox gallery once images and options are added.

File

src/JuiceboxGallery.php, line 286

Class

JuiceboxGallery
Class to generate the script and markup for a Juicebox gallery.

Namespace

Drupal\juicebox

Code

public function getJavascriptVars($xml_url) {
  $vars = [
    'configUrl' => $xml_url,
    'containerId' => $this
      ->getId(),
  ];

  // Add options that need to be loaded immediately (before XML is available).
  $load_before_xml = [
    'gallerywidth',
    'galleryheight',
    'backgroundcolor',
    'themeurl',
    'baseurl',
    'showpreloader',
    'debugmode',
  ];
  $current_options = $this
    ->getOptions(TRUE);
  foreach ($load_before_xml as $key => $option) {
    if (!empty($current_options[$option])) {
      $vars[$option] = $current_options[$option];
    }
  }
  return $vars;
}