Index: popups.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/popups/popups.module,v retrieving revision 1.11.2.19 diff -u -r1.11.2.19 popups.module --- popups.module 20 Nov 2008 21:18:57 -0000 1.11.2.19 +++ popups.module 13 Feb 2009 01:47:23 -0000 @@ -109,6 +109,21 @@ } /** + * Implementation of hook_theme_registry_alter(). + * + * Hijack the popups theming to use a custom tpl. + */ +function popups_theme_registry_alter(&$theme_registry) { + $skin = variable_get('popups_skin', 'Basic'); + $skins = module_invoke_all('popups_skins'); + $skin_path = dirname($skins[$skin]['css']); + $theme_registry['popups_popup']['template'] = $skin_path .'/popups-popup'; + $theme_registry['popups_popup']['theme path'] = $skin_path; + // Note that we overwrite 'theme paths' instead of adding to it. + $theme_registry['popups_popup']['theme paths'][0] = $skin_path; +} + +/** * Implementation of hook_form_alter(). * * Look at the form_id and see if popup behavior has been requested for any links in this form. @@ -226,10 +241,17 @@ } if (!$added) { drupal_add_css(drupal_get_path('module', 'popups') .'/popups.css'); - drupal_add_css(drupal_get_path('module', 'popups') .'/popups-skin.css'); + + // Allow skinning of the popup. + $skin = variable_get('popups_skin', 'Basic'); + $skins = popups_skins(); + drupal_add_css($skins[$skin]['css']); + if (isset($skins[$skin]['js'])) { + drupal_add_js($skins[$skin]['js']); + } drupal_add_js(drupal_get_path('module', 'popups') .'/popups.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; @@ -249,6 +271,56 @@ } /** + * Retrieve all information from the popup skin registry. + * + * @param $reset + * (optional) If TRUE, will force the the skin registry to reset. + * @see popups_popups_skins + */ +function popups_skins($reset = FALSE) { + static $skins = array(); + if (empty($skins) || $reset) { + if (!$reset && ($cache = cache_get('popups:skins')) && !empty($cache->data)) { + $skins = $cache->data; + } + else { + // Create the popup skin registry (hook_popups_skins) and cache it. + $skins = module_invoke_all('popups_skins'); + cache_set('popups:skins', $skins, 'cache', CACHE_PERMANENT); + } + } + return $skins; +} + +/** + * Implementation of hook_popups_skins. + * + * This hook allows other modules to create additional custom skins for the + * popups module. + * + * @return array + * An array of key => value pairs suitable for inclusion as the #options in a + * select or radios form element. Each key must be the location of at least a + * css file for a popups skin. Optionally can have a js index as well. Each + * value should be the name of the widget. + */ +function popups_popups_skins() { + $skins = array(); + $skins_directory = drupal_get_path('module', 'popups') .'/skins'; + $files = file_scan_directory($skins_directory, '\.css$'); + + foreach ($files as $file) { + $name = drupal_ucfirst($file->name); + $skins[$name]['css'] = $file->filename; + $js = substr_replace($file->filename, '.js', -4); + if (file_exists($js)) { + $skins[$name]['js'] = $js; + } + } + return $skins; +} + +/** * Returns the default jQuery content selector as a string. * Currently uses the selector for Garland. * Sometime in the future I will change this to '#content' or '#content-content'. @@ -266,6 +338,7 @@ * */ function popups_admin_settings() { + popups_add_popups(); drupal_set_title("Popups Settings"); $form = array(); @@ -279,7 +352,24 @@ '#title' => t('Do NOT auto-close final message.'), '#default_value' => variable_get('popups_popup_final_message', 1), ); - + + // Retrieve all available skins, forcing the registry to refresh. + $skins = popups_skins(TRUE); + $skin_options = drupal_map_assoc(array_keys($skins)); + $form['popups_skins'] = array( + '#type' => 'fieldset', + '#title' => t('Skins'), + '#description' => t('Choose a skin from the list. Click !here to test it out.', array('!here' => l('here', 'user', array('attributes' => array('class' => 'popups'))))), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + $form['popups_skins']['popups_skin'] = array( + '#type' => 'radios', + '#title' => t('Available skins'), + '#default_value' => variable_get('popups_skin', 'Basic'), + '#options' => $skin_options, + ); + return system_settings_form($form); } @@ -295,4 +385,3 @@ $content_selector = $form_state['values']['popups_content_selector']; variable_set('popups_'. $theme .'_content_selector', $content_selector); } - Index: skins/facebook/facebook.js =================================================================== RCS file: skins/facebook/facebook.js diff -N skins/facebook/facebook.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ skins/facebook/facebook.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,42 @@ + +/** + * Custom theming for the popupsLoading. + */ +Drupal.theme.popupLoading = function() { + var loading = '
| '; + loading += ' | '; + loading += ' | '; + loading += ' |
| '; + loading += ' | '; + loading += ''; + loading += ' | '; + loading += ''; + loading += ' |
| '; + loading += ' | '; + loading += ' | '; + loading += ' |