You are here

speedboxes.module in Speedboxes - Fast checkbox handling 7

Same filename and directory in other branches
  1. 8 speedboxes.module

Drupal Module: Speedboxes.

Adds the Speedboxes js lib code to the site.

@author: Original Author Manuel Pistner <http://drupal.org/user/302791> @author: Another Author Frank Anderson <http://drupal.org/user/249517>

File

speedboxes.module
View source
<?php

/**
 * @file
 * Drupal Module: Speedboxes.
 *
 * Adds the Speedboxes js lib code to the site.
 *
 * @author: Original Author Manuel Pistner <http://drupal.org/user/302791>
 * @author: Another Author Frank Anderson <http://drupal.org/user/249517>
 */

/**
 * Implements hook_init().
 */
function speedboxes_init() {
  $allowed_paths = array(
    'admin/people/permissions',
    'admin/config/group/permissions/node/group',
  );
  if (!in_array($_GET['q'], $allowed_paths)) {
    return;
  }
  drupal_load('module', 'user');
  if (user_access('use speedboxes')) {
    $path = drupal_get_path('module', 'speedboxes');
    drupal_add_js($path . '/speedboxes-0.1b.js');
    drupal_add_js('
      var speedboxes  = {
        config          : {
          localization    : {
            check_all       : "' . t('Check all') . '",
            uncheck_all     : "' . t('Uncheck all') . '",
            reverse         : "' . t('Check reverse') . '"
          }
        }
      };
    ', 'inline');
    drupal_add_css($path . '/speedboxes-0.1b.css');
  }
}

/**
 * Implements hood_permission().
 */
function speedboxes_permission() {
  return array(
    'use speedboxes' => array(
      'title' => t('Use Speedboxes'),
      'description' => t('Allow users to use the "Speedboxes" JavaScript for fast checking/unchecking/selection reverse.'),
    ),
  );
}

Functions

Namesort descending Description
speedboxes_init Implements hook_init().
speedboxes_permission Implements hood_permission().