function popups_add_popups in Popups API (Ajax Dialogs) 5
Same name and namespace in other branches
- 6.2 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 behavoir 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 $rule: Array of rules to apply to the page or form, keyed by jQuery link selector.: Options: noReload: Does the popup NOT modify the original page (Default: false). titleSelectors: Array of jQuery selectors to place the new page title (Default: do nothing). targetSelectors: Array (or hash) of jQuery selectors with areas to update (Default: use single theme-wide setting) forceReturn: url to force a stop to work flow (only use in conjunction with noReload). href: override the href in the a element, or attach an href to a non-link element. width: override the width specified in the css. additionalJavascript: Array of JavaScript files that must be included to correctly run the page in the popup. additionalCss: Array of CSS files that must be included to correctly style the page in the popup.
Rule Format Example: 'admin/content/taxonomy' => array( // Act only on the links on this page. 'div#tabs-wrapper a:eq(1)', // No options, so use defaults. Note: Selector must select <a> element(s). 'table td:nth-child(2) a' => array( 'noReload' => true, // Popup will not modify original page. ), )
3 calls to popups_add_popups()
- popups_form_alter in ./
popups.module - popups_init in ./
popups.module - hook_init
- _popups_test_popups in ./
popups.module
File
- ./
popups.module, line 248 - popups.module
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;
if (isset($options['additionalJavascript']) && is_array($options['additionalJavascript'])) {
foreach ($options['additionalJavascript'] as $file) {
drupal_add_js($file);
}
}
if (isset($options['additionalCss']) && is_array($options['additionalCss'])) {
foreach ($options['additionalCss'] as $file) {
drupal_add_css($file);
}
}
}
else {
$settings['popups']['links'][$options] = array();
}
}
if ($added) {
drupal_add_js($settings, 'setting');
}
}
if (!$added) {
drupal_add_css(drupal_get_path('module', 'popups') . '/popups.css');
drupal_add_css(drupal_get_path('module', 'popups') . '/popups-skin.css');
drupal_add_js(drupal_get_path('module', 'popups') . '/popups.js');
drupal_add_js(drupal_get_path('module', 'popups') . '/dimensions/dimensions.js');
drupal_add_js(drupal_get_path('module', 'popups') . '/form/form.js');
drupal_add_js('misc/jquery.form.js');
// 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');
}
$defaultTargetSelector = variable_get('popups_' . $theme . '_content_selector', 'div#content');
$settings['popups']['defaultTargetSelector'] = $defaultTargetSelector;
$settings['popups']['modulePath'] = base_path() . drupal_get_path('module', 'popups');
$settings['popups']['popupFinalMessage'] = variable_get('popups_popup_final_message', 1);
drupal_add_js($settings, 'setting');
$added = TRUE;
}
}