View source
<?php
function popup_init() {
$path = drupal_get_path('module', 'popup');
drupal_add_js($path . '/popup.js', array(
'preprocess' => variable_get('popup-preprocess', FALSE),
));
drupal_add_css($path . '/popup.css', array(
'preprocess' => variable_get('popup-preprocess', FALSE),
));
$effects = module_invoke_all('popup_effects');
drupal_add_js(array(
'popup' => array(
'effects' => $effects,
'linger' => variable_get('popup-hover-linger', 250),
'delay' => variable_get('popup-hover-delay', 0),
),
), 'setting');
}
function popup_popup_effects() {
return array(
'show' => array(
'default' => "this.body.show();",
'fade' => "\n if (this.opacity){\n this.body.fadeTo('medium',this.opacity);\n }else{\n this.body.fadeIn('medium');\n }",
'slide-down' => "this.body.slideDown('medium')",
'slide-down-fade' => "\n this.body.animate(\n {\n height:'show',\n opacity:(this.opacity ? this.opacity : 'show')\n }, 'medium'\n );",
),
'hide' => array(
'default' => "this.body.hide();",
'fade' => "this.body.fadeOut('medium');",
'slide-down' => "this.body.slideUp('medium');",
'slide-down-fade' => "\n this.body.animate(\n {\n height:'hide',\n opacity:'hide'\n }, 'medium'\n );",
),
);
}
function popup_menu() {
$path = drupal_get_path('module', 'popup');
return array(
'admin/config/user-interface/popup' => array(
'access arguments' => array(
'administer popup elements',
),
'description' => t('Configure popup element behavior and default presentation.'),
'file' => 'popup.admin.inc',
'file path' => $path . '/includes',
'page arguments' => array(
'popup_admin_settings',
),
'page callback' => 'drupal_get_form',
'title' => 'Popup elements',
'type' => MENU_NORMAL_ITEM,
),
'ahah/popup' => array(
'access arguments' => array(
'access content',
),
'file' => 'popup.util.inc',
'file path' => $path . '/includes',
'page callback' => 'popup_get_ahah',
'type' => MENU_CALLBACK,
),
);
}
function popup_permission() {
return array(
'administer popup elements' => array(
'title' => t('Administer popup elements'),
'description' => t('Configure popup element behavior and default presentation.'),
),
);
}
function popup_theme() {
module_load_include('inc', 'popup', 'includes/popup.theme');
module_load_include('inc', 'popup', 'includes/popup.util');
$styles = _popup_styles();
$theme = _popup_theme_array();
foreach ($styles as $style => $path) {
$theme += _popup_theme_array(_popup_title_to_key($style), $path);
}
$theme += array(
'popup_ahah_placeholder' => array(
'variables' => array(
'type' => '',
'attributes' => array(),
),
'file' => 'includes/popup.theme.inc',
),
);
return $theme;
}
function popup_popup_styles() {
$path = drupal_get_path('module', 'popup') . '/styles';
return array(
'McPopup' => $path . '/McPopup',
'Bent white' => $path . '/bent_white',
'Black' => $path . '/black',
'Obsidian' => $path . '/obsidian',
'White' => $path . '/white',
);
}
function popup_popup_attributes_alter(&$attributes) {
module_load_include('inc', 'popup', 'includes/popup.util');
$defaults = _popup_defaults();
$attributes = array_merge($defaults, $attributes);
}
function popup_preprocess_popup_element(&$variables) {
module_load_include('inc', 'popup', 'includes/popup.util');
$styles = _popup_styles();
$style = isset($variables['style']) && $variables['style'] ? $variables['style'] : variable_get('popup-style', 'White');
$path = isset($styles[$style]) ? $styles[$style] : NULL;
$variables['classes_array'] = array();
$variables['attributes_array'] = array();
$variables['title_attributes_array'] = array();
$variables['content_attributes_array'] = array();
if (isset($path)) {
if (file_exists($path . '/popup-element.css')) {
drupal_add_css($path . '/popup-element.css', array(
'media' => 'screen, projection',
'preprocess' => variable_get('popup-preprocess', FALSE),
'basename' => _popup_title_to_key($style) . '.popup-element.css',
));
}
if (file_exists($path . '/popup-element.js')) {
drupal_add_js($path . '/popup-element.js', array(
'scope' => 'header',
'preprocess' => variable_get('popup-preprocess', FALSE),
));
}
}
}