function scroll_to_top_init in scroll to top 7.2
Same name and namespace in other branches
- 6.2 scroll_to_top.module \scroll_to_top_init()
- 6 scroll_to_top.module \scroll_to_top_init()
- 7 scroll_to_top.module \scroll_to_top_init()
Implementation of hook_init().
File
- ./
scroll_to_top.module, line 11 - Provide scroll to top link.
Code
function scroll_to_top_init() {
global $theme;
if (variable_get('scroll_to_top_enable_admin_theme', TRUE) == TRUE || variable_get('scroll_to_top_enable_admin_theme', TRUE) == FALSE && $theme != variable_get('admin_theme')) {
drupal_add_css(drupal_get_path('module', 'scroll_to_top') . '/scroll_to_top.css', array(
'group' => CSS_DEFAULT,
'every_page' => TRUE,
));
drupal_add_js(drupal_get_path('module', 'scroll_to_top') . '/scroll_to_top.js');
drupal_add_js(array(
'scroll_to_top' => array(
'label' => t(check_plain(variable_get('scroll_to_top_label', 'Back to top'))),
),
), 'setting');
//building the css style
$position = "";
// Button position
if (variable_get('scroll_to_top_position', 1) == 1) {
$position = "#back-top { right:40px; }";
}
if (variable_get('scroll_to_top_position', 1) == 3) {
$position = "#back-top { left:50%;margin:0px;}";
}
// Display label
if (variable_get('scroll_to_top_display_text', TRUE) == FALSE) {
$display = "span#link {display : none;}";
}
else {
$display = "";
}
// background color on hover
$bgcolor = "#back-top span#button { background-color: " . variable_get('scroll_to_top_bg_color_out', '#CCCCCC') . ";}";
$bgcolor .= " #back-top span#button:hover {opacity:1;filter:alpha(opacity = 1);background-color: " . variable_get('scroll_to_top_bg_color_hover', '#777777') . ";}";
$css = $position;
$css .= $bgcolor;
$css .= $display;
drupal_add_css($css, 'inline');
}
}