Implements hook_libraries_info().
Sujets associés
Fichier
-
advagg_font/
advagg_font.module, line 221
Code
function advagg_font_libraries_info() {
$libraries['fontfaceobserver'] = array(
// Only used in administrative UI of Libraries API.
'name' => 'fontfaceobserver',
'vendor url' => 'https://github.com/bramstein/fontfaceobserver',
'download url' => 'https://github.com/bramstein/fontfaceobserver/archive/master.zip',
'version arguments' => array(
'file' => 'package.json',
// 1.50. : "version": "1.5.0".
'pattern' => '/"version":\\s+"([0-9\\.]+)"/',
'lines' => 100,
'default_version' => '2.1.0',
),
'remote' => array(
'callback' => 'advagg_get_github_version_json',
'url' => 'https://cdn.jsdelivr.net/gh/bramstein/fontfaceobserver@master/package.json',
),
'files' => array(
'js' => array(
'fontfaceobserver.js' => array(
'type' => 'file',
'group' => JS_LIBRARY,
'async' => TRUE,
'defer' => TRUE,
),
),
),
'variants' => array(),
);
// Get the latest tagged version for external file loading.
$version = advagg_get_remote_libraries_version('fontfaceobserver', $libraries['fontfaceobserver']);
$libraries['fontfaceobserver']['variants'] += array(
'external' => array(
'files' => array(
'js' => array(
"https://cdn.jsdelivr.net/gh/bramstein/fontfaceobserver@v{$version}/fontfaceobserver.js" => array(
'type' => 'external',
'data' => "https://cdn.jsdelivr.net/gh/bramstein/fontfaceobserver@v{$version}/fontfaceobserver.js",
'async' => TRUE,
'defer' => TRUE,
),
),
),
),
);
// Inline if local js is there.
$libraries_paths = array();
if (is_callable('libraries_get_libraries')) {
$libraries_paths = libraries_get_libraries();
}
if (!empty($libraries_paths['fontfaceobserver']) && is_readable($libraries_paths['fontfaceobserver'] . '/fontfaceobserver.js')) {
$libraries['fontfaceobserver']['variants'] += array(
'inline' => array(
'files' => array(
'js' => array(
'loadCSS_inline' => array(
'type' => 'inline',
'data' => (string) @advagg_file_get_contents($libraries_paths['fontfaceobserver'] . '/fontfaceobserver.js'),
'no_defer' => TRUE,
),
),
),
),
);
}
return $libraries;
}