From da95391fc7045ba7eac227ecbdffe7d6887e7bcd Mon Sep 17 00:00:00 2001 From: Judah Anthony Date: Tue, 4 Aug 2009 10:58:18 -0400 Subject: [PATCH] making popups js aggregation compatible --- html/sites/all/modules/contrib/popups/popups.js | 10 ++++++++++ .../sites/all/modules/contrib/popups/popups.module | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-) mode change 100644 => 100755 html/sites/all/modules/contrib/popups/popups.js mode change 100644 => 100755 html/sites/all/modules/contrib/popups/popups.module diff --git a/html/sites/all/modules/contrib/popups/popups.js b/html/sites/all/modules/contrib/popups/popups.js old mode 100644 new mode 100755 index b38db88..f37783f --- a/html/sites/all/modules/contrib/popups/popups.js +++ b/html/sites/all/modules/contrib/popups/popups.js @@ -647,6 +647,16 @@ Popups.close = function(popup) { Popups.saveSettings = function() { if (!Popups.originalSettings) { Popups.originalSettings = Drupal.settings; + + // added in hopes to make js aggragation compatible + // adding original js int (Array) Popups.addedJS + for(type in Drupal.settings.popups.js) { + if(type != 'setting' && type != 'inline') { + for(file in Drupal.settings.popups.js[type]) { + Popups.addedJS[$(Drupal.settings.popups.js[type][file]).attr('src')] = true; + } + } + } } }; diff --git a/html/sites/all/modules/contrib/popups/popups.module b/html/sites/all/modules/contrib/popups/popups.module old mode 100644 new mode 100755 index e8c48a5..499616c --- a/html/sites/all/modules/contrib/popups/popups.module +++ b/html/sites/all/modules/contrib/popups/popups.module @@ -132,6 +132,21 @@ function popups_form_alter(&$form, $form_state, $form_id) { // ************************************************************************** // UTILITY FUNCTIONS ****************************************************** // ************************************************************************** +/** + * Implementation of hook_preprocess_page(). + * + * Get the current list of JS and CSS files that are going to be used on the + * loaded page. Save this list in a JS variable. This preprocess function is + * absolutely the very latest in the display cycle we can get a list of JS files + * and add it to the page. + */ +function popups_preprocess_page(&$vars) { + $js = popups_get_js(); + $css = popups_get_css(); + + drupal_add_js(array('popups' => array('css' => $css, 'js' => $js)), 'setting'); + $vars['scripts'] = drupal_get_js(); +} /** * Render the page contents in a custom json wrapper. @@ -276,6 +291,7 @@ function popups_get_popups($reset = FALSE) { */ function popups_add_popups($rules=NULL) { static $added = FALSE; + // TODO: make this compatible with new popups_preprocess_page() $settings = array('popups' => array()); if (is_array($rules)) { -- 1.5.4.3