Commit b983313c authored by frjo's avatar frjo
Browse files

Removed the form support from Colorbox, good riddance.

parent f81e6636
......@@ -12,7 +12,7 @@ Colorbox is a light-weight, customizable lightbox plugin for jQuery 1.4.3+.
This module allows for integration of Colorbox into Drupal.
The jQuery library is a part of Drupal since version 5+.
Images, forms, iframed or inline content etc. can be displayed in a
Images, iframed or inline content etc. can be displayed in a
overlay above the current page.
* jQuery - http://jquery.com/
......@@ -27,8 +27,6 @@ The Colorbox module:
* Excellent integration with Image field and Image styles
* Choose between a default style and 5 example styles that are included.
* Style the Colorbox with a custom colorbox.css file in your theme.
* Option to open a login form by clicking on any login link
* Simple API to open any form in a Colorbox
* Drush command to download and install the Colorbox plugin in
sites/all/libraries
......@@ -121,28 +119,6 @@ this "?width=500&height=500&inline=true#id-of-content".
Other modules may activate this for easy Colorbox integration.
Load a selection of forms in a Colorbox:
----------------------------------------
Check the "Enable Colorbox load" option in Colorbox settings.
The following form_id can be used:
* contact_site_form
* user_login
* user_login_block
* user_register
* user_pass
The links to open a form needs the class "colorbox-load". The URL should
look like this.
"/colorbox/form/[form_id]?destination=[path_to_send_user_to_after_submit]&width=[with_in_pixel]&height=[height_in_pixel]".
Here is an example where the user register form is opened in an
500 by 250 pixel Colorbox.
<a class="colorbox-load" href="/colorbox/form/user_register_form?destination=user&width=500&height=250">Create new account</a>
Drush:
------
A Drush command is provides for easy installation of the Colorbox
......
......@@ -59,30 +59,6 @@ function colorbox_admin_settings() {
);
}
$form['colorbox_login_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Login links 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_links'] = array(
'#type' => 'radios',
'#title' => t('Display links'),
'#options' => array(0 => t('No links'), 1 => t('Show links'), 2 => t('Show links and open them in a Colorbox')),
'#default_value' => variable_get('colorbox_login_links', 0),
'#description' => t('Display the "Create new account" (if allowed) and "Request new password" links below the login form.'),
'#after_build' => array('_colorbox_admin_settings_login_links_load'),
'#states' => array(
'visible' => array(
':input[name="colorbox_login"]' => array('checked' => TRUE),
),
),
);
$form['colorbox_extra_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Extra settings'),
......@@ -346,15 +322,3 @@ function _colorbox_admin_settings_check_plugin_path($form_element) {
return $form_element;
}
/**
* Enable the Colorbox load feature of the login links are set to open in a Colorbox.
*/
function _colorbox_admin_settings_login_links_load($form_element) {
$login_links = $form_element['#value'];
if ($login_links == 2) {
variable_set('colorbox_load', 1);
}
return $form_element;
}
......@@ -27,22 +27,3 @@ function hook_colorbox_settings_alter(&$settings, &$style) {
$style = 'mystyle';
}
}
/**
* Allow other modules to control access to forms opening in Colorbox.
*
* Implements hook_colorbox_form_access().
*
* @param $form_id
* The unique string identifying the current form.
*/
function hook_colorbox_form_access($form_id) {
$access = FALSE;
if ($form_id == 'forward_form') {
return user_access('access forward');
}
return $access;
}
......@@ -72,3 +72,15 @@ function colorbox_update_7002() {
return $ret;
}
/**
* Delete the unused colorbox_login and colorbox_login_links variabels.
*/
function colorbox_update_7200() {
$ret = array();
variable_del('colorbox_login');
variable_del('colorbox_login_links');
return $ret;
}
......@@ -85,59 +85,10 @@ function colorbox_menu() {
'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,
'file' => 'colorbox.pages.inc',
);
$items['colorbox/form'] = array(
'title' => 'Form',
'page callback' => 'colorbox_form_page',
'page arguments' => array(2),
'access callback' => '_colorbox_form_page_access',
'access arguments' => array(2),
'type' => MENU_CALLBACK,
'file' => 'colorbox.pages.inc',
);
return $items;
}
/**
* Colorbox menu access check.
*/
function _colorbox_form_page_access($form_id) {
$access = FALSE;
// First check if this is one of the forms Colorbox support out of the box.
switch ($form_id) {
case 'contact_site_form':
$access = user_access('access site-wide contact form');
break;
case 'user_register_form':
$access = user_register_access();
break;
case 'user_pass':
case 'user_login':
case 'user_login_block':
$access = user_is_anonymous();
break;
}
// Invoke hook_colorbox_form_access for all modules.
if (!$access) {
foreach (module_implements('colorbox_form_access') as $module) {
if ($access = module_invoke($module, 'colorbox_form_access', $form_id)) {
return $access;
}
}
}
return $access;
}
/**
* Check if Colorbox should be active for the current URL.
*
......@@ -250,10 +201,6 @@ function _colorbox_doheader() {
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;
}
......@@ -342,54 +289,6 @@ function colorbox_get_path() {
return $library_path;
}
/**
* Implements hook_form_alter().
* Reformat the login form.
*/
function colorbox_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_login':
if (arg(0) == 'user' && arg(1) == 'login' && arg(2) == 'colorbox') {
$form['name']['#size'] = 25;
$form['name']['#id'] = 'cbox-edit-name';
$form['pass']['#size'] = 25;
$form['pass']['#id'] = 'cbox-edit-pass';
// Add links as needed.
if (variable_get('colorbox_login_links', 0)) {
$items = array();
// Add standard links.
if (variable_get('colorbox_login_links', 0) == 1) {
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
$items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
}
$items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
}
// Add links that opens in a Colorbox.
if (variable_get('colorbox_login_links', 0) == 2) {
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
$items[] = l(t('Create new account'), 'colorbox/form/user_register_form', array('query' => array('width' => '300', 'height' => 'auto'), 'attributes' => array('title' => t('Create a new user account.'), 'class' => 'colorbox-load')));
}
$items[] = l(t('Request new password'), 'colorbox/form/user_pass', array('query' => array('width' => '300', 'height' => '150'), 'attributes' => array('title' => t('Request new password via e-mail.'), 'class' => 'colorbox-load')));
}
$form['links'] = array('#markup' => theme('item_list', array('items' => $items)));
}
}
break;
case 'user_register_form':
if (arg(0) == 'colorbox' && arg(1) == 'form') {
$form['account']['name']['#size'] = 30;
$form['account']['mail']['#size'] = 30;
}
break;
case 'user_pass':
if (arg(0) == 'colorbox' && arg(1) == 'form') {
$form['name']['#size'] = 30;
}
break;
}
}
/**
* Implements hook_link_alter().
*/
......
<?php
/**
* @file
* User page callback file for the colorbox module.
*/
/**
* Menu callback for colorbox_login.
*/
function colorbox_login() {
// Redirect failed logins to the standard user login form.
if (isset($_POST['form_id']) && $_POST['form_id'] == 'user_login') {
return drupal_get_form('user_login');
}
colorbox_form_page('user_login');
}
/**
* Menu callback for colorbox_form_page.
*/
function colorbox_form_page($form_id) {
$GLOBALS['devel_shutdown'] = FALSE; // Prevent devel module from spewing.
switch ($form_id) {
case 'contact_site_form':
module_load_include('inc', 'contact', 'contact.pages');
case 'user_pass':
module_load_include('inc', 'user', 'user.pages');
default:
$form = drupal_get_form($form_id);
if (!empty($form)) {
print drupal_render($form);
}
}
exit;
}
(function ($) {
Drupal.behaviors.initColorboxLogin = {
attach: function (context, settings) {
if (!$.isFunction($.colorbox)) {
return;
}
$("a[href*='/user/login'], a[href*='?q=user/login']", context).once('init-colorbox-login', function () {
var path = this.href;
var new_path = path.replace(/user\/login/,'user/login/colorbox')
var addquery = (path.indexOf('?') !=-1) ? '&' : '?';
var dest = window.location.pathname.replace(Drupal.settings.basePath, '').replace(Drupal.settings.pathPrefix, '');
// If no destination, add one to the current page.
if (path.indexOf('destination') != -1 || dest == '') {
this.href = new_path;
}
else {
this.href = new_path + addquery + 'destination=' + dest;
}
}).colorbox({
initialWidth:200,
initialHeight:200,
onComplete:function(){
$('#cbox-edit-name').focus();
}
});
}
};
})(jQuery);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment