You are here

function scroll_to_top_init in scroll to top 6

Same name and namespace in other branches
  1. 6.2 scroll_to_top.module \scroll_to_top_init()
  2. 7.2 scroll_to_top.module \scroll_to_top_init()
  3. 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() {
  drupal_add_css(drupal_get_path('module', 'scroll_to_top') . '/scroll_to_top.css', 'module');
  drupal_add_js(drupal_get_path('module', 'scroll_to_top') . '/scroll_to_top.js', 'module');
  $position = "";
  if (variable_get('scroll_to_top_position', 1) == 1) {
    $position = "\$('#back-top').css('right','40px');";
  }
  if (variable_get('scroll_to_top_position', 1) == 3) {
    $position = "\$('#back-top').css({'left':'50%','margin':'0px'});";
  }
  if (variable_get('scroll_to_top_display_text', TRUE) == FALSE) {
    $display = "\$('div#link').css('display','none');";
  }
  $bgcolor = " \$('#back-top span').mouseover(function(){ \$(this).css('background-color','" . variable_get('scroll_to_top_bg_color_hover', '#777777') . "');}).mouseout(function(){ \$(this).css('background-color','" . variable_get('scroll_to_top_bg_color_out', '#CCCCCC') . "');});";
  $script = "\$(document).ready(function() {";
  $script .= $position;
  $script .= $bgcolor;
  $script .= $display;
  $script .= "});";
  drupal_add_js($script, 'inline');
}