You are here

function sharebar_init in ShareBar 7

Same name and namespace in other branches
  1. 6 sharebar.module \sharebar_init()
  2. 7.2 sharebar.module \sharebar_init()

Implements hook_init().

File

./sharebar.module, line 92
Various module information.

Code

function sharebar_init() {
  if (arg(0) != 'admin') {
    $node = menu_get_object();
    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '' && (!empty($node) && variable_get('sharebar_bar_posts_' . $node->type . '_enabled', TRUE)) || !(arg(0) == 'node' && is_numeric(arg(1))) && arg(1) != 'add' && arg(2) != 'edit' && arg(3) != 'edit' && variable_get('sharebar_bar_pages_enabled', TRUE)) {
      drupal_add_css(drupal_get_path('module', 'sharebar') . '/css/sharebar.css');
      drupal_add_js(drupal_get_path('module', 'sharebar') . '/js/sharebar.js');
      if (variable_get('sharebar_bar_horizontal', TRUE)) {
        $hori = 'TRUE';
        $width = variable_get('sharebar_bar_width', 1000);
        $swidth = variable_get('sharebar_bar_swidth', 75);
        $position = variable_get('sharebar_bar_position', 'left');
        $leftoffset = variable_get('sharebar_bar_leftoffset', 10);
        $rightoffset = variable_get('sharebar_bar_rightoffset', 10);
        $sharebarx = variable_get('sharebar_bar_idhorizontal', 'sharebarx');
        drupal_add_js('jQuery(document).ready(function($) { $(\'' . $sharebarx . '\').sharebar({horizontal:\'' . $hori . '\',swidth:\'' . $swidth . '\',minwidth:' . $width . ',position:\'' . $position . '\',leftOffset:' . $leftoffset . ',rightOffset:' . $rightoffset . '}); });', 'inline');
      }
    }
  }
}