public function BlazyLibrary::library in Blazy 7
Implements hook_library().
File
- src/
BlazyLibrary.php, line 48
Class
- BlazyLibrary
- Provides Blazy library definitions.
Namespace
Drupal\blazyCode
public function library() {
if (!isset($this->libraries)) {
$info = system_get_info('module', 'blazy');
$path = drupal_get_path('module', 'blazy');
$components = $path . '/css/components';
$js_library = [
'group' => JS_LIBRARY,
];
$js_default = [
'group' => JS_DEFAULT,
];
$common = [
'website' => 'https://drupal.org/project/blazy',
'version' => empty($info['version']) ? '1.x' : $info['version'],
];
$libraries['blazy'] = [
'title' => 'Blazy',
'website' => 'https://github.com/dinbror/blazy',
'js' => [
libraries_get_path('blazy') . '/blazy.min.js' => [
$js_library,
'weight' => -6,
],
],
];
$libraries['base'] = [
'css' => [
$path . '/css/blazy.css' => [],
],
];
$libraries['dblazy'] = [
'js' => [
$path . '/js/dblazy.min.js' => [
$js_library,
'weight' => -5.5,
],
],
'dependencies' => [
[
'blazy',
'base',
],
],
];
$libraries['bio'] = [
'js' => [
$path . '/js/bio.min.js' => [
$js_library,
'weight' => -5.4,
],
],
'dependencies' => [
[
'blazy',
'dblazy',
],
],
];
$libraries['bio.media'] = [
'js' => [
$path . '/js/bio.media.min.js' => [
$js_library,
'weight' => -5.3,
],
],
'dependencies' => [
[
'blazy',
'bio',
],
],
];
$libraries['load'] = [
'js' => [
$path . '/js/blazy.load.min.js' => [
$js_default,
'weight' => -3,
],
],
'css' => [
$components . '/blazy.loading.css' => [],
],
'dependencies' => [
[
'blazy',
'blazy',
],
[
'blazy',
'dblazy',
],
[
'blazy',
'bio.media',
],
],
];
$libraries['bio.ajax'] = [
// Drupal ajax set its weight to 2, go lower.
'js' => [
$path . '/js/bio.ajax.min.js' => [
[
$js_default,
],
'weight' => 2.5,
],
],
'dependencies' => [
[
'system',
'drupal.ajax',
],
[
'blazy',
'load',
],
],
];
if ($this->manager
->config('io.enabled', FALSE) && $this->manager
->config('io.unblazy', FALSE)) {
$libraries['load']['dependencies'] = [
[
'blazy',
'bio.media',
],
];
}
foreach ([
'column',
'filter',
'fx.blur',
'grid',
'lightbox',
'ratio',
] as $item) {
$libraries[$item] = [
'css' => [
$components . '/blazy.' . $item . '.css' => [],
],
'dependencies' => [
[
'blazy',
'base',
],
],
];
}
$libraries['admin'] = [
'css' => [
$components . '/blazy.admin.css' => [],
],
'js' => [
$path . '/js/blazy.admin.min.js' => [],
],
];
foreach ([
'blazybox',
'colorbox',
'photobox',
'media',
] as $item) {
$css = $item == 'photobox' ? 'lightbox' : $item;
$libraries[$item] = [
'js' => [
$path . '/js/blazy.' . $item . '.min.js' => [
$js_default,
'weight' => -0.01,
],
],
'css' => [
$components . '/blazy.' . $css . '.css' => [],
],
'dependencies' => [
[
'blazy',
'load',
],
],
];
if ($item != 'media') {
$libraries[$item]['dependencies'][] = [
'blazy',
'lightbox',
];
// Doh, colorbox has no core library definitions to depend on.
if ($item == 'colorbox' && ($colorbox = libraries_get_path('colorbox'))) {
$libraries['colorbox']['js'][$colorbox . '/jquery.colorbox-min.js'] = [
$js_library,
'weight' => -4,
];
}
}
}
if (module_exists('photobox')) {
$libraries['photobox']['dependencies'][] = [
'photobox',
'photobox',
];
}
elseif ($photobox = libraries_get_path('photobox')) {
$libraries['photobox']['js'][$photobox . '/photobox/jquery.photobox.js'] = [
$js_library,
'weight' => -4,
];
$libraries['photobox']['css'][$photobox . '/photobox/photobox.css'] = [];
}
foreach ($libraries as &$library) {
$library += $common;
// jQuery is required at D7.
if (isset($library['js'])) {
$library['dependencies'][] = [
'system',
'jquery.once',
];
}
}
$this->libraries = $libraries;
}
return $this->libraries;
}