You are here

twitter_bootstrap_modal_block.module in Twitter Bootstrap Modal 7.3

Generates a Twitter Bootstrap block with images block.

File

twitter_bootstrap_modal_block/twitter_bootstrap_modal_block.module
View source
<?php

/**
* @file
* Generates a Twitter Bootstrap block with images block.
*
*/

/**
 * Implements hook_init().
 */
function twitter_bootstrap_modal_block_init() {
  $settings = variable_get('twitter_bootstrap_modal_block_settings');
  $module_path = drupal_get_path('module', 'twitter_bootstrap_modal_block');
  drupal_add_js(array(
    'twitter_bootstrap_modal_block' => array(
      'trigger' => $settings['trigger'],
      'link_type' => $settings['link_type'],
    ),
  ), 'setting');
  drupal_add_js($module_path . '/twitter_bootstrap_modal_block.js');
  drupal_add_css($module_path . '/twitter_bootstrap_modal_block.css');
}

/**
* Implementation of hook_menu().
*/
function twitter_bootstrap_modal_block_menu() {

  // Admin settings.
  $items['admin/config/development/twitter_bootstrap_modal/TB_block'] = array(
    'title' => 'Twitter Bootstrap Modal Block',
    'description' => 'Shows any block on a Twitter Boostrap Modal',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'twitter_bootstrap_modal_block_settings',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

/**
 * Module settings form.
 */
function twitter_bootstrap_modal_block_settings($form, &$form_state) {
  $settings = variable_get('twitter_bootstrap_modal_block_settings');
  $options['trigger'] = array(
    '#type' => 'textarea',
    '#title' => t('Valid jQuery Classes/IDs to trigger TB Block Modal (One per line)'),
    '#default_value' => $settings['trigger'] . "\n",
    '#description' => t('Specify the class/ID of blocks to load in a TB Modal, one per line. For example by providing "#block-system-navigation" will convert Navigation Menu Block into a link to open Navigation Menu inside a Twitter Bootstrap Modal'),
  );
  $options['link_type'] = array(
    '#type' => 'select',
    '#title' => t('Type of Twitter Bottstrap Button'),
    '#default_value' => $settings['link_type'],
    '#description' => t('The type of button will be displayed to trigger the modal.'),
    '#options' => array(
      'btn-link' => t('Simple Link'),
      'btn-default' => t('Default Button'),
      'btn-primary' => t('Primary Button'),
      'btn-success' => t('Success Button'),
      'btn-info' => t('Info Button'),
      'btn-warning' => t('Warning Button'),
      'btn-danger' => t('Danger Button'),
    ),
  );
  $options['#tree'] = TRUE;
  $form['twitter_bootstrap_modal_block_settings'] = $options;

  // Disable automatic defaults, which don't work with nested values.
  return system_settings_form($form, FALSE);
}

Functions