Commit 8ace13aa authored by frjo's avatar frjo
Browse files

750332: Porting over all features from the Thickbox module to Colorbox.

parent de169a20
Drupal colorbox module:
------------------------
Maintainers:
Joe Wheaton (http://drupal.org/user/298179)
Fredrik Jonsson (http://drupal.org/user/5546)
Requires - Drupal 6 and jQuery Update version 6.x-2.x
License - GPL (see LICENSE)
Overview:
--------
The Colorbox module is a wrapper for Colorbox, a light-weight,
customizable lightbox plugin for jQuery 1.3 and 1.4.
The jQuery library is a part of Drupal since version 5+.
Integrates with Image, Imagefield and Imagecache modules.
Provides a feature to display the login form in a Colorbox and a simple API to display any form in a Colorbox.
* jQuery - http://jquery.com/
* Colorbox - http://colorpowered.com/colorbox/
Drush:
------
A Drush command is provides for easy installation of the Colorbox script itself.
% drush colorbox-script
The command will download the script and unpack it in sites/all/libraries. It is
possible to add another path as an option to the command, but not recommended unless you know what you are doing.
Installation:
------------
1. Download and install the jQuery Update module version 6.x-2.x.
2. Download and unpack the Colorbox script itself to "sites/all/libraries".
Drush users can just use the command "drush colorbox-script".
3. Place this module directory in your modules folder (this will
usually be "sites/all/modules/").
4. Go to "Administer" -> "Site building" -> "Modules" and enable the module.
Configuration:
-------------
Go to "Administer" -> "Site configuration" -> "Colorbox" to find
all the configuration options.
Contributions:
-------------
* Porting all features from the Thickbox module,
by Fredrik Jonsson (http://drupal.org/user/5546).
Last updated:
------------
$Id$
\ No newline at end of file
<?php
// $Id$
/**
* @file
* Administrative page callbacks for the colorbox module.
*/
/**
* General configuration form for controlling the colorbox behaviour.
*/
function colorbox_admin_settings() {
drupal_add_js(drupal_get_path('module', 'colorbox') .'/js/colorbox_admin_settings.js', 'module', 'header', FALSE, TRUE, FALSE);
if (module_exists('imagefield')) {
$form['colorbox_imagefield'] = array(
'#type' => 'fieldset',
'#title' => t('Image field options (CCK)')
);
$form['colorbox_imagefield']['colorbox_imagefield_gallery'] = array(
'#type' => 'radios',
'#title' => t('Image field gallery'),
'#default_value' => variable_get('colorbox_imagefield_gallery', 1),
'#options' => array(0 => t('Per page gallery'), 1 => t('Per post gallery'), 2 => t('Per field gallery'), 3 => t('No gallery')),
'#description' => t('Should the gallery be images within a single field, a single post (default) or all images on the page. The last option disables galleries.'),
);
if (module_exists('imagecache')) {
$presets_options = array(0 => t('Original image (no preset)'));
foreach (imagecache_presets() as $preset) {
$presets_options[$preset['presetname']] = $preset['presetname'];
}
$form['colorbox_imagefield']['colorbox_imagecache_preset'] = array(
'#type' => 'select',
'#title' => t('Imagecache preset'),
'#options' => $presets_options,
'#default_value' => variable_get('colorbox_imagecache_preset', 0),
'#description' => t('Select which Imagecache preset to use for viewing images in the colorbox.'),
);
}
}
if (module_exists('image')) {
$form['colorbox_image_module'] = array(
'#type' => 'fieldset',
'#title' => t('Image module settings'),
);
$form['colorbox_image_module']['colorbox_auto_image_nodes'] = array(
'#type' => 'select',
'#title' => t('Image node setting'),
'#default_value' => variable_get('colorbox_auto_image_nodes', 'disabled'),
'#options' => array(
'disabled' => t('Disabled'),
'colorbox' => t('Colorbox'),
),
);
}
$form['colorbox_login_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Login settings')
);
$form['colorbox_login_settings']['colorbox_login'] = array(
'#type' => 'checkbox',
'#title' => t('Enable for login links'),
'#default_value' => variable_get('colorbox_login', 0),
'#description' => t('Automatically activate Colorbox for links to user/login.'),
);
$form['colorbox_login_settings']['colorbox_login_form'] = array(
'#type' => 'select',
'#title' => t('Login form to use'),
'#options' => array('user_login' => t('User login'), 'user_login_block' => t('User login block'), 'custom' => t('Custom')),
'#default_value' => variable_get('colorbox_login_form', 'user_login'),
'#description' => t('Select which form to use for login. If "custom", specify below.'),
);
$form['colorbox_login_settings']['colorbox_login_custom'] = array(
'#type' => 'textfield',
'#title' => t('Custom login form'),
'#default_value' => variable_get('colorbox_login_custom', ''),
'#description' => t('Specify the form here if you have set the login form to "custom" above.'),
);
$form['colorbox_custom_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Custom settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$colorbox_path = variable_get('colorbox_path', COLORBOX_PATH);
$example_styles = array(
'default' => t('Default'),
$colorbox_path .'/example1' => t('Example 1'),
$colorbox_path .'/example2' => t('Example 2'),
$colorbox_path .'/example3' => t('Example 3'),
$colorbox_path .'/example4' => t('Example 4'),
$colorbox_path .'/example5' => t('Example 5'),
'none' => t('Let the theme handle styling.'),
);
$form['colorbox_custom_settings']['colorbox_style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#options' => $example_styles,
'#default_value' => variable_get('colorbox_style', 'default'),
'#description' => t('Select the style to use for the Colorbox. The examples are the ones that comes with Colorbox.'),
);
$form['colorbox_custom_settings']['colorbox_custom_settings_activate'] = array(
'#type' => 'radios',
'#options' => array(0 => t('Default settings'), 1 => t('Custom settings')),
'#title' => t('Custom Settings'),
'#default_value' => variable_get('colorbox_custom_settings_activate', 0),
'#description' => t('Use the default or custom settings for Colorbox.'),
'#prefix' => '<div class="colorbox-custom-settings-activate">',
'#suffix' => '</div>',
);
$js_hide = variable_get('colorbox_custom_settings_activate', 0) ? '' : ' js-hide';
$form['colorbox_custom_settings']['colorbox_transition_type'] = array(
'#type' => 'select',
'#title' => t('Transition type'),
'#options' => array('elastic' => t('Elastic'), 'fade' => t('Fade'), 'none' => t('None')),
'#default_value' => variable_get('colorbox_transition_type', 'elastic'),
'#description' => t('The transition type.'),
'#prefix' => '<div class="colorbox-custom-settings'. $js_hide .'">',
);
$form['colorbox_custom_settings']['colorbox_transition_speed'] = array(
'#type' => 'select',
'#title' => t('Transition speed'),
'#options' => drupal_map_assoc(array(100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600)),
'#default_value' => variable_get('colorbox_transition_speed', 350),
'#description' => t('Sets the speed of the fade and elastic transitions, in milliseconds.'),
);
$form['colorbox_custom_settings']['colorbox_opacity'] = array(
'#type' => 'select',
'#title' => t('Opacity'),
'#options' => drupal_map_assoc(array('0', '0.10', '0.15', '0.20', '0.25', '0.30', '0.35', '0.40', '0.45', '0.50', '0.55', '0.60', '0.65', '0.70', '0.75', '0.80', '0.85', '0.90', '0.95', '1')),
'#default_value' => variable_get('colorbox_opacity', '0.90'),
'#description' => t('The overlay opacity level. Range: 0 to 1.'),
);
$form['colorbox_custom_settings']['colorbox_slideshow'] = array(
'#type' => 'radios',
'#title' => t('Slideshow'),
'#options' => array(0 => t('No'), 1 => t('Yes')),
'#default_value' => variable_get('colorbox_slideshow', 0),
'#description' => t('An automatic slideshow to a content group / gallery.'),
);
$form['colorbox_custom_settings']['colorbox_text_current'] = array(
'#type' => 'textfield',
'#title' => t('Current'),
'#default_value' => variable_get('colorbox_text_current', '{current} of {total}'),
'#description' => t('Text format for the content group / gallery count. {current} and {total} are detected and replaced with actual numbers while Colorbox runs.'),
);
$form['colorbox_custom_settings']['colorbox_text_previous'] = array(
'#type' => 'textfield',
'#title' => t('Previous'),
'#default_value' => variable_get('colorbox_text_previous', '« Prev'),
'#description' => t('Text for the previous button in a shared relation group.'),
);
$form['colorbox_custom_settings']['colorbox_text_next'] = array(
'#type' => 'textfield',
'#title' => t('Next'),
'#default_value' => variable_get('colorbox_text_next', 'Next »'),
'#description' => t('Text for the next button in a shared relation group.'),
);
$form['colorbox_custom_settings']['colorbox_text_close'] = array(
'#type' => 'textfield',
'#title' => t('Close'),
'#default_value' => variable_get('colorbox_text_close', 'Close'),
'#description' => t('Text for the close button. The "Esc" key will also close Colorbox.'),
'#suffix' => '</div>',
);
$form['colorbox_advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['colorbox_advanced_settings']['colorbox_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to Colorbox'),
'#default_value' => $colorbox_path,
'#description' => t('Enter the path relative to Drupal root to the colorbox directory. NO trailing slash!'),
);
$form['colorbox_advanced_settings']['colorbox_pages'] = array(
'#type' => 'textarea',
'#title' => t('Deactivate Colorbox on specific pages'),
'#default_value' => variable_get('colorbox_pages', "admin*\nimg_assist*\nnode/add/*\nnode/*/edit"),
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
);
return system_settings_form($form);
}
/* $Id$ */
/*
ColorBox Core Style
The following rules are the styles that are consistant between themes.
Avoid changing this area to maintain compatability with future versions of ColorBox.
*/
#colorbox, #cboxOverlay, #cboxWrapper {
position: absolute;
top: 0;
left: 0;
z-index: 9999;
overflow: hidden;
}
#cboxOverlay {
position: fixed;
width: 100%;
height: 100%;
}
#cboxMiddleLeft, #cboxBottomLeft {
clear: left;
}
#cboxContent {
position: relative;
overflow: hidden;
}
#cboxLoadedContent {
overflow: auto;
}
#cboxLoadedContent iframe {
display: block;
width: 100%;
height: 100%;
border: 0;
}
#cboxTitle {
margin: 0;
}
#cboxLoadingOverlay, #cboxLoadingGraphic {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow {
cursor: pointer;
}
/*
ColorBox example user style
The following rules are ordered and tabbed in a way that represents the
order/nesting of the generated HTML, so that the structure easier to understand.
*/
#cboxOverlay {
background: #000;
}
#colorBox {}
#cboxWrapper {
background: #fff;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
#cboxTopLeft {
width: 15px;
height: 15px;
}
#cboxTopCenter {
height: 15px;
}
#cboxTopRight {
width: 15px;
height: 15px;
}
#cboxBottomLeft {
width: 15px;
height: 10px;
}
#cboxBottomCenter {
height: 10px;
}
#cboxBottomRight {
width: 15px;
height: 10px;
}
#cboxMiddleLeft {
width: 15px;
}
#cboxMiddleRight {
width: 15px;
}
#cboxContent {
background: #fff;
font: 12px "Lucida Grande", Verdana, Arial, sans-serif;
}
#cboxLoadedContent {
margin-bottom: 28px;
}
#cboxTitle {
position: absolute;
bottom: 4px;
left: 100px;
color: #949494;
}
#cboxCurrent {
position: absolute;
bottom: 4px;
left: 60px;
color: #949494;
}
.cboxSlideshow_on #cboxSlideshow {
position: absolute;
bottom: 0px;
right: 30px;
background: url(images/controls.png) -75px -50px no-repeat;
width: 25px;
height: 25px;
text-indent: -9999px;
}
.cboxSlideshow_on #cboxSlideshow.hover {
background-position: -101px -50px;
}
.cboxSlideshow_off #cboxSlideshow {
position: absolute;
bottom: 0px;
right: 30px;
background: url(images/controls.png) -49px -50px no-repeat;
width: 25px;
height: 25px;
text-indent: -9999px;
}
.cboxSlideshow_off #cboxSlideshow.hover {
background-position: -25px -50px;
}
#cboxPrevious {
position: absolute;
bottom: 0;
left: 0px;
background: url(images/controls.png) -75px 0px no-repeat;
width: 25px;
height: 25px;
text-indent: -9999px;
}
#cboxPrevious.hover {
background-position: -75px -25px;
}
#cboxNext {
position: absolute;
bottom: 0;
left: 27px;
background: url(images/controls.png) -50px 0px no-repeat;
width: 25px;
height: 25px;
text-indent: -9999px;
}
#cboxNext.hover {
background-position: -50px -25px;
}
#cboxLoadingOverlay {
background: #fff;
}
#cboxLoadingGraphic {
background: url(images/loading_animation.gif) center center no-repeat;
}
#cboxClose {
position: absolute;
bottom: 0;
right: 0;
background: url(images/controls.png) -25px 0px no-repeat;
width: 25px;
height: 25px;
text-indent: -9999px;
}
#cboxClose.hover {
background-position: -25px -25px;
}
; $Id$
name = Colorbox
description = A light-weight, customizable lightbox plugin for jQuery 1.3
description = A light-weight, customizable lightbox plugin for jQuery 1.3 and 1.4.
core = 6.x
dependencies[] = jquery_update
<?php
// $Id$
/**
* @file
* Installation functions for colorbox.
*/
/**
* Implementation of hook_requirements().
*/
// function colorbox_update_requirements($phase) {
// $requirements = array();
// $t = get_t();
//
// if ($phase == 'runtime') {
// $requirements['colorbox'] = array(
// 'title' => $t('Colorbox'),
// 'severity' => REQUIREMENT_OK,
// 'value' => ,
// );
// }
//
// return $requirements;
// }
/**
* Implementation of hook_uninstall().
*/
function colorbox_uninstall() {
variable_del('colorbox_auto_image_nodes');
variable_del('colorbox_custom_settings_activate');
variable_del('colorbox_imagecache_preset');
variable_del('colorbox_imagefield_gallery');
variable_del('colorbox_login_custom');
variable_del('colorbox_login_form');
variable_del('colorbox_login');
variable_del('colorbox_opacity');
variable_del('colorbox_pages');
variable_del('colorbox_path');
variable_del('colorbox_slideshow');
variable_del('colorbox_style');
variable_del('colorbox_text_close');
variable_del('colorbox_text_current');
variable_del('colorbox_text_next');
variable_del('colorbox_text_previous');
variable_del('colorbox_transition_speed');
variable_del('colorbox_transition_type');
}
// $Id$
if (jQuery().colorbox) {
Drupal.behaviors.colorbox = function (context) {
// Image Attach Functionality
$('.image-attach-body > a').each(function (i) {
// Modify link to jpg
this.href = $('.image-attach-body > a > img:eq('+i+')').attr("src").replace(".thumbnail", "");
// Add rel tag to group
this.rel = "testing1";
// Colorbox it
});
$("a[rel='testing1']").colorbox();
$("a[rel='testing2']").colorbox();
$('.colorbox').colorbox();
};
}
<?php
// $Id$
/**
* @file
* A light-weight, customizable lightbox plugin for jQuery 1.3
*/
/**
* The default path to the Colorbox directory.
*/
define('COLORBOX_PATH', 'sites/all/libraries/colorbox');
/**
* Implmentation of hook_theme().
*/
function colorbox_theme() {
$theme = array(
'colorbox_imagefield' => array(
'arguments' => array('namespace' => NULL, 'path' => NULL, 'alt' => NULL, 'title' => NULL, 'gid' => NULL, 'attributes' => NULL),
'file' => 'colorbox.theme.inc',
),
);
if (module_exists('imagecache')) {
foreach (imagecache_presets() as $preset) {
$theme['colorbox_formatter_'. $preset['presetname'] .'][colorbox'] = array(
'function' => 'theme_colorbox_formatter_imagefield',
'arguments' => array('element' => NULL),
'file' => 'colorbox.theme.inc',
);
}
}
return $theme;
}
/**
* Implementation of hook_init().
*/
function colorbox_init() {
_colorbox_doheader();
}
/**
* Implementation of hook_menu().
*/
function colorbox_menu() {
$items = array();
$items['admin/settings/colorbox'] = array(
'title' => 'Colorbox Settings',
'title' => 'Colorbox',
'description' => 'Adjust Colorbox settings.',
'file' => 'colorbox.admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('colorbox_admin_settings'),
'access arguments' => array('administer site configuration'),
);
$items['user/login/colorbox'] = array(
'title' => 'Login',
'page callback' => 'colorbox_login',
'access callback' => 'user_is_anonymous',
'type' => MENU_CALLBACK,
);
$items['colorbox/form'] = array(
'title' => 'Form',
'page callback' => 'colorbox_form',
'page arguments' => array(2),
'access callback' => 'user_access',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function colorbox_init() {
if (variable_get('colorbox_js_path', FALSE)) {
drupal_add_js(variable_get('colorbox_js_path', ''));
/**
* Menu callback for colorbox_login.
*/
function colorbox_login() {
$form_id = variable_get('colorbox_login_form', '') == 'custom' ? variable_get('colorbox_login_custom', 'user_login') : variable_get('colorbox_login_form', 'user_login');
colorbox_form($form_id);
}
/**
* Menu callback for colorbox_form.
*/
function colorbox_form($form_id) {
$GLOBALS['devel_shutdown'] = FALSE; // Prevent devel module from spewing.
$form = drupal_get_form($form_id);
if (!empty($form)) {
print $form;
}
if (variable_get('colorbox_css_path', FALSE)) {
drupal_add_css(variable_get('colorbox_css_path', ''));
exit;
}
/**
* Check if Colorbox should be active for the current URL.
*
* @return
* TRUE if Colorbox should be active for the current page.
*/
function _colorbox_active() {
// Code from the block_list funtion in block.module.
$path = drupal_get_path_alias($_GET['q']);
// Compare with the internal and path alias (if any).
$page_match = drupal_match_path($path, variable_get('colorbox_pages', ''));
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], variable_get('colorbox_pages', ''));
}
return !$page_match;
}
/**