Same name and namespace in other branches
- 7.x-2.x colorbox.module \_colorbox_doheader() 1 comment
Loads the various js and css files.
1 call to _colorbox_doheader()
- colorbox_init in ./
colorbox.module - Implements hook_init().
File
-
./
colorbox.module, line 170
Code
function _colorbox_doheader() {
static $already_added = FALSE;
if ($already_added) {
return;
// Don't add the JavaScript and CSS multiple times.
}
if (!_colorbox_active()) {
return;
// Don't add the JavaScript and CSS on specified paths.
}
// Insert options and translated strings as javascript settings.
if (variable_get('colorbox_custom_settings_activate', 0)) {
$js_settings = array(
'transition' => variable_get('colorbox_transition_type', 'elastic'),
'speed' => variable_get('colorbox_transition_speed', 350),
'opacity' => variable_get('colorbox_opacity', '0.85'),
'slideshow' => variable_get('colorbox_slideshow', 0) ? TRUE : FALSE,
'slideshowAuto' => variable_get('colorbox_slideshowauto', 1) ? TRUE : FALSE,
'slideshowSpeed' => variable_get('colorbox_slideshowspeed', 2500),
'slideshowStart' => variable_get('colorbox_text_start', 'start slideshow'),
'slideshowStop' => variable_get('colorbox_text_stop', 'stop slideshow'),
'current' => variable_get('colorbox_text_current', '{current} of {total}'),
'previous' => variable_get('colorbox_text_previous', '« Prev'),
'next' => variable_get('colorbox_text_next', 'Next »'),
'close' => variable_get('colorbox_text_close', 'Close'),
'overlayClose' => variable_get('colorbox_overlayclose', 1) ? TRUE : FALSE,
'maxWidth' => variable_get('colorbox_maxwidth', '100%'),
'maxHeight' => variable_get('colorbox_maxheight', '100%'),
'initialWidth' => variable_get('colorbox_initialwidth', '300'),
'initialHeight' => variable_get('colorbox_initialheight', '100'),
'fixed' => variable_get('colorbox_fixed', 1) ? TRUE : FALSE,
'scrolling' => variable_get('colorbox_scrolling', 1) ? TRUE : FALSE,
);
}
else {
$js_settings = array(
'opacity' => '0.85',
'current' => t('{current} of {total}'),
'previous' => t('« Prev'),
'next' => t('Next »'),
'close' => t('Close'),
'maxWidth' => '100%',
'maxHeight' => '100%',
'fixed' => TRUE,
);
}
$path = drupal_get_path('module', 'colorbox');
$style = variable_get('colorbox_style', 'default');
// Give other modules the possibility to override Colorbox settings and style.
$data =& $js_settings;
drupal_alter('colorbox_settings', $data, $style);
drupal_add_js(array(
'colorbox' => $js_settings,
), array(
'type' => 'setting',
'scope' => JS_DEFAULT,
));
// Add and initialise the Colorbox plugin.
drupal_add_js(colorbox_get_js());
drupal_add_js($path . '/js/colorbox.js');
// Add JS and CSS based on selected style.
switch ($style) {
case 'none':
break;
case 'default':
drupal_add_css($path . '/styles/default/colorbox_default_style.css');
drupal_add_js($path . '/styles/default/colorbox_default_style.js');
break;
case 'stockholmsyndrome':
drupal_add_css($path . '/styles/stockholmsyndrome/colorbox_stockholmsyndrome.css');
drupal_add_js($path . '/styles/stockholmsyndrome/colorbox_stockholmsyndrome.js');
break;
default:
drupal_add_css($style . '/colorbox.css');
}
if (variable_get('colorbox_load', 0)) {
drupal_add_js($path . '/js/colorbox_load.js');
}
if (variable_get('colorbox_inline', 0)) {
drupal_add_js($path . '/js/colorbox_inline.js');
}
if ($GLOBALS['user']->uid == 0 && variable_get('colorbox_login', 0)) {
drupal_add_js($path . '/js/colorbox_login.js');
}
$already_added = TRUE;
}