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 += ''; + loading += ''; + loading += ''; + loading += ''; + loading += ''; + loading += ''; + loading += '
'; + loading += 'Loading...'; + loading += '
'; + loading += '
'; + return loading; +}; + +/** + * We need to resize the popups-container as well as the popups if it scrolls + */ +Drupal.behaviors.resizePopupsContainer = function() { + var $popups = $('#popups-container'); + var popupHeight = $popups.height(); + var windowHeight = $(window).height(); + if (popupHeight > (0.9 * windowHeight) ) { // Must fit in 90% of window. + // we make this slightly smaller than popups so that it fits inside + popupHeight = 0.85 * windowHeight; + $popups.height(popupHeight); + } +}; Index: skins/facebook/facebook.css =================================================================== RCS file: skins/facebook/facebook.css diff -N skins/facebook/facebook.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ skins/facebook/facebook.css 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,91 @@ +#popups-overlay { + background-color:transparent; +} +#popups-loading { + width:248px; + position:absolute; + display:none; + opacity:1; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + z-index:99; +} +#popups-loading span.popups-loading-message { + background:#FFF url(loading-large.gif) no-repeat 8px center; + display:block; + color:#444444; + font-family:Arial; + font-size:22px; + font-weight:bold; + height:36px; + line-height:36px; + padding:0 40px; +} +#popups-loading table, +#popups table { margin:0px; } +#popups-loading tbody, +#popups tbody { border:none; } +#popups tr { background-color:transparent;} +td.popups-border { + background: url(popups-border.png); + background-color:transparent; + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=85); +} +td#popups-tl, +td#popups-tr, +td#popups-bl, +td#popups-br { + background-repeat: no-repeat; + height:10px; + padding:0px; +} +td#popups-tl { background-position: 0px 0px; } +td#popups-t, +td#popups-b { + background-position: 0px -40px; + background-repeat: repeat-x; + height:10px; +} +td#popups-tr { background-position: 0px -10px; } +td#popups-cl, +td#popups-cr { + background-position: -10px 0; + background-repeat: repeat-y; + width:10px; +} +td#popups-cl, +td#popups-cr, +td#popups-c { padding:0; } +td#popups-bl { background-position: 0px -20px; } +td#popups-br { background-position: 0px -30px; } + +#popups, +#popups-loading { + border: 0px solid #454545; + opacity:1; + overflow:hidden; + padding:0; + background-color:transparent; +} +#popups-container { + overflow:auto; + max-height:100%; + background-color:#fff; +} +#popups-title { + -moz-border-radius-topleft: 0px; + -webkit-border-radius-topleft: 0px; + margin-bottom:0px; + background-color:#6D84B4; + border:1px solid #3B5998; + padding:4px 10px 5px; + color:white; + font-size:14px; + font-weight:bold; +} +#popups-body { + background-color:#fff; + padding:8px; +} +#popups #popups-buttons, +#popups #popups-footer { background-color:#fff; } Index: skins/basic/popups-popup.tpl.php =================================================================== RCS file: skins/basic/popups-popup.tpl.php diff -N skins/basic/popups-popup.tpl.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ skins/basic/popups-popup.tpl.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ + +
+
+
+
%title
+
+
+
%body
+
%buttons
+ +
Index: skins/facebook/popups-popup.tpl.php =================================================================== RCS file: skins/facebook/popups-popup.tpl.php diff -N skins/facebook/popups-popup.tpl.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ skins/facebook/popups-popup.tpl.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,36 @@ + +
+ + + + + + + + + + + + + + + + +
+
+
+
+
%title
+
+
+
%body
+
%buttons
+ +
+
+
Index: skins/basic/basic.css =================================================================== RCS file: skins/basic/basic.css diff -N skins/basic/basic.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ skins/basic/basic.css 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +#popups { + border: 2px solid #EDF5FA; + -moz-border-radius: 8px; + -webkit-border-radius: 8px; + opacity: 0.9; +} +#popups-title { + border-bottom: 1px solid #b4d7f0; + background-color: #d4e7f3; + color: #455067; + margin-bottom: 0.25em; + padding: 0.25em; + -moz-border-radius-topleft: 5px; + -webkit-border-radius-topleft: 5px; +} +#popups-title #popups-close a { + color: red; +} +#popups input { + margin: 0.1em; +} +#popups input[type="text"]:focus, #popups input[type="password"]:focus, #popups textarea:focus { + background-color: #FFA; + outline: thin solid grey; +} +a.popups-processed:after { + content: "\25A1"; + vertical-align: super; + font-size: smaller; +}