function popups_get_js in Popups API (Ajax Dialogs) 6.2
Get the added JS in a format that is readable by popups.js.
2 calls to popups_get_js()
- popups_preprocess_page in ./
popups.module - Implementation of hook_preprocess_hook().
- popups_render_as_json in ./
popups.module - Render the page contents in a custom json wrapper.
File
- ./
popups.module, line 152 - This module provides a hook_popups for links to be opened in an Ajax Popup Modal Dialog.
Code
function popups_get_js() {
$js = array_merge_recursive(drupal_add_js(), drupal_add_js(NULL, NULL, 'footer'));
$query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
$popup_js = array();
foreach ($js as $type => $data) {
if (!$data) {
continue;
}
switch ($type) {
case 'setting':
// Why not just array_merge_recursive($data);
$popup_js['setting'] = call_user_func_array('array_merge_recursive', $data);
break;
case 'inline':
foreach ($data as $info) {
$popup_js['inline'][] = '<script type="text/javascript"' . ($info['defer'] ? ' defer="defer"' : '') . '>' . $info['code'] . "</script>\n";
}
break;
default:
foreach ($data as $path => $info) {
$popup_js[$type][$path] = '<script type="text/javascript"' . ($info['defer'] ? ' defer="defer"' : '') . ' src="' . base_path() . $path . $query_string . "\"></script>\n";
}
break;
}
}
unset($popup_js['core']['misc/jquery.js']);
unset($popup_js['core']['misc/drupal.js']);
if (module_exists('jquery_update')) {
foreach (jquery_update_get_replacements() as $type => $replacements) {
foreach ($replacements as $find => $replace) {
if (isset($popup_js[$type][$find])) {
// Create a new entry for the replacement file, and unset the original one.
$replace = JQUERY_UPDATE_REPLACE_PATH . '/' . $replace;
//$popup_js[$type][$replace] = str_replace($find, $replace, $popup_js[$type][$find]);
unset($popup_js[$type][$find]);
}
}
}
}
return $popup_js;
}