Mercurial > defr > drupal > popups
comparison popups.module @ 7:85e281a44a62 tip
Refuse to add popups.js to an ajax request that's not already a popup
In some case, if you enable the "Always scan for popups links" options,
Popups Ajax processing will break the original module request.
author | Franck Deroche <franck@defr.org> |
---|---|
date | Fri, 31 Dec 2010 14:13:37 +0100 |
parents | 5efa741592f9 |
children |
comparison
equal
deleted
inserted
replaced
6:e02de6b2566e | 7:85e281a44a62 |
---|---|
289 * @param array $rules: Array of rules to apply to the page or form, keyed by jQuery link selector. | 289 * @param array $rules: Array of rules to apply to the page or form, keyed by jQuery link selector. |
290 * See README.txt for a listing of the options, and popups_admin.module for examples. | 290 * See README.txt for a listing of the options, and popups_admin.module for examples. |
291 */ | 291 */ |
292 function popups_add_popups($rules=NULL) { | 292 function popups_add_popups($rules=NULL) { |
293 static $added = FALSE; | 293 static $added = FALSE; |
294 static $shouldAdd = NULL; | |
295 if (is_null($shouldAdd)) { | |
296 $shouldAdd = !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' || $_SESSION['page_override']; | |
297 } | |
294 $settings = array('popups' => array()); | 298 $settings = array('popups' => array()); |
295 | 299 |
296 if (is_array($rules)) { | 300 if (is_array($rules)) { |
297 $settings['popups']['links'] = array(); | 301 $settings['popups']['links'] = array(); |
298 foreach ($rules as $popup_selector => $options) { | 302 foreach ($rules as $popup_selector => $options) { |
305 } | 309 } |
306 if($added) { | 310 if($added) { |
307 drupal_add_js( $settings, 'setting' ); | 311 drupal_add_js( $settings, 'setting' ); |
308 } | 312 } |
309 } | 313 } |
310 if (!$added) { | 314 if (!$added && $shouldAdd) { |
311 // Determing if we are showing the default theme or a custom theme. | 315 // Determing if we are showing the default theme or a custom theme. |
312 global $custom_theme; | 316 global $custom_theme; |
313 $theme = $custom_theme; | 317 $theme = $custom_theme; |
314 if (!$theme) { | 318 if (!$theme) { |
315 $theme = variable_get('theme_default','none'); | 319 $theme = variable_get('theme_default','none'); |