function fitvids_page_build in FitVids 7
Implements hook_page_build().
Include the FitVids.js script on every page
File
- ./
fitvids.module, line 125 - Includes the FitVids.js jQuery plugin for fluid width video embeds.
Code
function fitvids_page_build(&$page) {
// Is the library installed?
$path = libraries_get_path('fitvids') . '/jquery.fitvids.js';
$installed = file_exists($path);
if (!$installed) {
return;
}
// TODO User should be able to choose which paths this should/shouldn't run on
// Add the library reference
drupal_add_js($path, array(
'group' => JS_LIBRARY,
'every_page' => TRUE,
));
// Generate the custom vendor selectors
$fitvids_customselectors = variable_get('fitvids_customselectors', '');
$fitvids_customselectors_array = array();
if ($fitvids_customselectors != '') {
$fitvids_customselectors_array = explode(PHP_EOL, $fitvids_customselectors);
$custom_selectors = '';
if (count($fitvids_customselectors_array) > 0) {
foreach ($fitvids_customselectors_array as $key => $value) {
$fitvids_customselectors_array[$key] = 'iframe[src^=\'' . trim($value) . '\']';
}
$custom_selectors = '{ customSelector: "' . implode(',', $fitvids_customselectors_array) . '" }';
}
}
else {
$custom_selectors = '';
}
// Get fitvids containers
$fitvids_selectors = variable_get('fitvids_selectors', FITVIDS_DEFAULT_REGIONS);
$fitvids_selectors_array = explode(PHP_EOL, $fitvids_selectors);
// Simplify markup?
$simplifymarkup = variable_get('fitvids_simplifymarkup', TRUE);
// Export the variables to Drupal.settings
drupal_add_js(array(
'fitvids' => array(
'custom_domains' => $fitvids_customselectors_array,
'selectors' => $fitvids_selectors_array,
'simplifymarkup' => $simplifymarkup,
),
), 'setting');
}