function backstretch_page_alter in Backstretch 7
Implements hook_page_alter().
Loads the backstretch library and adds stretched image to page.
File
- ./
backstretch.module, line 75
Code
function backstretch_page_alter(&$page) {
if (($library = libraries_load('backstretch')) && !empty($library['loaded'])) {
drupal_add_css(drupal_get_path('module', 'backstretch') . '/backstretch.css');
if (module_exists('context')) {
if ($plugin = context_get_plugin('reaction', 'backstretch')) {
$plugin
->execute();
}
}
if ($url = variable_get('backstretch_image_url', '') || $plugin) {
$settings = array(
'backstretchURL' => variable_get('backstretch_image_url', ''),
'backstretchMinWidth' => variable_get('backstretch_min_width', 0),
);
if (variable_get('backstretch_scroller', FALSE)) {
$settings['backstretchScroller'] = TRUE;
$settings['backstretchScrollerAdj'] = variable_get('backstretch_scroller_adjustment', 0);
}
drupal_add_js($settings, 'setting');
drupal_add_js(drupal_get_path('module', 'backstretch') . '/bs.js', array(
'scope' => 'footer',
));
}
}
if (variable_get('backstretch_scrollto', FALSE)) {
$waypoints = libraries_load('waypoints');
$scrollto = libraries_load('scrollto');
if (!empty($waypoints['loaded']) && !empty($scrollto['loaded'])) {
// Enable ScrollTo.
$settings['backstretchScrollTo'] = TRUE;
drupal_add_js($settings, 'setting');
// Add footer link.
$page['page_bottom']['scrollto'] = array(
'#theme' => 'links',
'#attributes' => array(
'class' => array(
'footer-links',
'links',
),
),
'#links' => array(
array(
'title' => t('View Photo'),
'href' => '<front>',
'attributes' => array(
'id' => 'backstretch-scrollto',
),
'fragment' => 'backstretchmargin',
),
),
);
}
}
}