You are here

public function ElevateZoomPlusManager::library in ElevateZoom Plus 7

Implements hook_library_info_build().

File

src/ElevateZoomPlusManager.php, line 38

Class

ElevateZoomPlusManager
Provides ElevateZoom Plus library methods mainly for hooks.

Namespace

Drupal\elevatezoomplus

Code

public function library() {
  if (!isset($this->libraries)) {
    $info = system_get_info('module', 'elevatezoomplus');
    $library = libraries_get_path('elevatezoom-plus') ?: libraries_get_path('ez-plus');
    $path = drupal_get_path('module', 'elevatezoomplus');
    $common = [
      'website' => 'https://drupal.org/project/elevatezoomplus',
      'version' => empty($info['version']) ? '7.x-1.x' : $info['version'],
    ];
    $ext = is_file($library . '/src/jquery.ez-plus.min.js') ? 'min.js' : 'js';
    $libraries['elevatezoomplus'] = [
      'title' => 'ElevateZoom Plus',
      'website' => 'https://github.com/igorlino/elevatezoom-plus',
      'js' => [
        $library . '/src/jquery.ez-plus.' . $ext => [
          'group' => JS_LIBRARY,
        ],
      ],
      'version' => '1.x',
      'dependencies' => [
        [
          'system',
          'jquery',
        ],
      ],
    ];
    $libraries['load'] = [
      'css' => [
        $path . '/css/elevatezoomplus.css' => [],
      ],
      'js' => [
        $path . '/js/elevatezoomplus.load.min.js' => [
          'group' => JS_DEFAULT,
          'weight' => -0.03,
        ],
      ],
      'dependencies' => [
        [
          'blazy',
          'blazybox',
        ],
        [
          'elevatezoomplus',
          'elevatezoomplus',
        ],
      ],
    ];
    $libraries['admin'] = [
      'css' => [
        $path . '/css/elevatezoomplus.admin.css' => [],
      ],
      'dependencies' => [
        [
          'blazy',
          'admin',
        ],
      ],
    ];
    foreach ($libraries as &$library) {
      $library += $common;
      if (isset($library['js'])) {
        $library['dependencies'][] = [
          'system',
          'jquery.once',
        ];
      }
    }
    $this->libraries = $libraries;
  }
  return $this->libraries;
}