function popups_add_popups in Popups API (Ajax Dialogs) 6.2
Same name and namespace in other branches
- 5 popups.module \popups_add_popups()
- 6 popups.module \popups_add_popups()
- 7 popups.module \popups_add_popups()
Attach the popup behavior to the page.
The default behavior of a popup is to open a form that will modify the original page. The popup submits the form and reloads the original page with the resulting new content. The popup then replaces the original page's content area with the new copy of that content area.
Parameters
array $rules: Array of rules to apply to the page or form, keyed by jQuery link selector.: See README.txt for a listing of the options, and popups_admin.module for examples.
5 calls to popups_add_popups()
- popups_admin_settings in ./
popups.module - Form for the Popups Settings page.
- popups_form_alter in ./
popups.module - Implementation of hook_form_alter().
- popups_init in ./
popups.module - Implementation of hook_init().
- _popups_test_popups in ./
popups_test.module - _popups_test_popups_old in ./
popups_test.module
File
- ./
popups.module, line 288 - This module provides a hook_popups for links to be opened in an Ajax Popup Modal Dialog.
Code
function popups_add_popups($rules = NULL) {
static $added = FALSE;
$settings = array(
'popups' => array(),
);
if (is_array($rules)) {
$settings['popups']['links'] = array();
foreach ($rules as $popup_selector => $options) {
if (is_array($options)) {
$settings['popups']['links'][$popup_selector] = $options;
}
else {
$settings['popups']['links'][$options] = array();
}
}
if ($added) {
drupal_add_js($settings, 'setting');
}
}
if (!$added) {
// Determing if we are showing the default theme or a custom theme.
global $custom_theme;
$theme = $custom_theme;
if (!$theme) {
$theme = variable_get('theme_default', 'none');
}
drupal_add_js('misc/jquery.form.js');
drupal_add_css(drupal_get_path('module', 'popups') . '/popups.css');
drupal_add_js(drupal_get_path('module', 'popups') . '/popups.js');
// Allow skinning of the popup.
$skin = variable_get('popups_skin', 'Basic');
$skins = popups_skins();
if (!isset($skins[$skin]['css'])) {
// $skin == 'Unskinned'
// Look in the current theme for popups-skin.js
drupal_add_js(drupal_get_path('theme', $theme) . '/popups-skin.js');
}
else {
// Get css and js from selected skin.
drupal_add_css($skins[$skin]['css']);
if (isset($skins[$skin]['js'])) {
drupal_add_js($skins[$skin]['js']);
}
}
$default_target_selector = variable_get('popups_' . $theme . '_content_selector', _popups_default_content_selector());
$settings['popups']['originalPath'] = $_GET['q'];
$settings['popups']['defaultTargetSelector'] = $default_target_selector;
$settings['popups']['modulePath'] = drupal_get_path('module', 'popups');
$settings['popups']['autoCloseFinalMessage'] = variable_get('popups_autoclose_final_message', 1);
drupal_add_js($settings, 'setting');
$added = TRUE;
}
}