function _colorbox_doheader in Colorbox 7.2
Same name and namespace in other branches
- 6 colorbox.module \_colorbox_doheader()
- 7 colorbox.module \_colorbox_doheader()
Loads the various js and css files.
1 call to _colorbox_doheader()
- colorbox_init in ./
colorbox.module - Implements hook_init().
File
- ./
colorbox.module, line 163 - A light-weight, customizable lightbox plugin for jQuery 1.3.
Code
function _colorbox_doheader() {
static $already_added = FALSE;
if ($already_added) {
// Don't add the JavaScript and CSS multiple times.
return;
}
// 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' => strip_tags(variable_get('colorbox_text_current', '{current} of {total}')),
'previous' => strip_tags(variable_get('colorbox_text_previous', '« Prev')),
'next' => strip_tags(variable_get('colorbox_text_next', 'Next »')),
'close' => strip_tags(variable_get('colorbox_text_close', 'Close')),
'overlayClose' => variable_get('colorbox_overlayclose', 1) ? TRUE : FALSE,
'returnFocus' => variable_get('colorbox_returnfocus', 1) ? TRUE : FALSE,
'maxWidth' => variable_get('colorbox_maxwidth', '98%'),
'maxHeight' => variable_get('colorbox_maxheight', '98%'),
'initialWidth' => variable_get('colorbox_initialwidth', '300'),
'initialHeight' => variable_get('colorbox_initialheight', '250'),
'fixed' => variable_get('colorbox_fixed', 1) ? TRUE : FALSE,
'scrolling' => variable_get('colorbox_scrolling', 1) ? TRUE : FALSE,
'mobiledetect' => variable_get('colorbox_mobile_detect', 1) ? TRUE : FALSE,
'mobiledevicewidth' => variable_get('colorbox_mobile_device_width', '480px'),
);
}
else {
$js_settings = array(
'opacity' => '0.85',
'current' => t('{current} of {total}'),
'previous' => t('« Prev'),
'next' => t('Next »'),
'close' => t('Close'),
'maxWidth' => '98%',
'maxHeight' => '98%',
'fixed' => TRUE,
'mobiledetect' => variable_get('colorbox_mobile_detect', 1) ? TRUE : FALSE,
'mobiledevicewidth' => variable_get('colorbox_mobile_device_width', '480px'),
);
}
$js_settings['specificPagesDefaultValue'] = "admin*\nimagebrowser*\nimg_assist*\nimce*\nnode/add/*\nnode/*/edit\nprint/*\nprintpdf/*\nsystem/ajax\nsystem/ajax/*";
$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.
$variant = variable_get('colorbox_compression_type', 'minified');
if (module_exists('libraries')) {
libraries_load('colorbox', $variant);
}
drupal_add_js($path . '/js/colorbox.js');
// Add JS and CSS based on selected style.
switch ($style) {
case 'none':
break;
case 'default':
case 'plain':
case 'stockholmsyndrome':
drupal_add_css($path . '/styles/' . $style . '/colorbox_style.css');
drupal_add_js($path . '/styles/' . $style . '/colorbox_style.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');
}
$already_added = TRUE;
}