Mercurial > defr > drupal > popups
diff popups.module @ 2:c076d54409cb
Popus: Version RF
author | Franck Deroche <franck@defr.org> |
---|---|
date | Fri, 31 Dec 2010 13:46:12 +0100 |
parents | 76f9b43738f2 |
children |
line wrap: on
line diff
--- a/popups.module Fri Dec 31 13:41:08 2010 +0100 +++ b/popups.module Fri Dec 31 13:46:12 2010 +0100 @@ -153,6 +153,25 @@ $popup_js = array(); + // Allow modules to specifically alter the JS used in a popup. + drupal_alter('popups_js', $js); + if (module_exists('jquery_update')) { + $replacements = jquery_update_get_replacements(); + $path = drupal_get_path('module', 'jquery_update') .'/replace/'; + foreach($replacements as $type => $data) { + foreach($data as $src => $dst) { + $replacements[$type][$src] = $path . $dst; + } + } + // The behavior got called, so we're pretty sure that jQuery is already + // loaded. + unset($js['core']['misc/jquery.js']); + unset($js['core']['misc/drupal.js']); + } + else { + $replacements = array(); + } + foreach ($js as $type => $data) { if (!$data) continue; switch ($type) { @@ -167,6 +186,7 @@ break; default: foreach ($data as $path => $info) { + $path = isset($replacements[$type][$path]) ? $replacements[$type][$path] : $path; $popup_js[$type][$path] = '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. base_path() . $path . $query_string ."\"></script>\n"; } break; @@ -273,6 +293,10 @@ */ function popups_add_popups($rules=NULL) { static $added = FALSE; + static $shouldAdd = NULL; + if (is_null($shouldAdd)) { + $shouldAdd = !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || $_SESSION['page_override']; + } $settings = array('popups' => array()); if (is_array($rules)) { @@ -289,7 +313,7 @@ drupal_add_js( $settings, 'setting' ); } } - if (!$added) { + if (!$added && $shouldAdd) { // Determing if we are showing the default theme or a custom theme. global $custom_theme; $theme = $custom_theme;