You are here

fancybox.module in fancyBox 5

Same filename and directory in other branches
  1. 6 fancybox.module
  2. 7.2 fancybox.module
  3. 7 fancybox.module

File

fancybox.module
View source
<?php

/**
 * @file
 */

/**
 * Implementation of hook_menu().
 */
function fancybox_menu($may_cache) {
  $path = drupal_get_path('module', 'fancybox');
  $items = array();
  if (!$may_cache) {
    if (variable_get('fancybox_class_id', '') != '') {
      drupal_add_css($path . '/fancybox/jquery.fancybox.css');
      drupal_add_js($path . '/fancybox/jquery.easing.1.3.js');
      drupal_add_js($path . '/fancybox/jquery.fancybox-1.2.1.pack.js');
      drupal_add_js('
        $(document).ready(
          function(){
            $("a' . variable_get('fancybox_class_id', '') . '").fancybox({
            padding:' . variable_get('fancybox_padding', '0') . ',
            zoomOpacity:' . variable_get('fancybox_zoomopacity', 'true') . ',
            zoomSpeedIn:' . variable_get('fancybox_zoomspeedin', '300') . ',
            zoomSpeedOut:' . variable_get('fancybox_zoomspeedout', '300') . ',
            zoomSpeedChange:' . variable_get('fancybox_zoomspeedchange', '300') . ',
            easingIn:"' . variable_get('fancybox_easingin', 'easeOutBack') . '",
            easingOut:"' . variable_get('fancybox_easingout', 'easeInBack') . '",
            overlayShow:' . variable_get('fancybox_overlayshow', 'true') . ',
            overlayOpacity:' . variable_get('fancybox_overlayopacity', '10') . ',
            hideOnContentClick:' . variable_get('fancybox_hideoncontentclick', 'true') . '
          });
        }
      );', 'inline');

      /*drupal_add_js('
        $(document).ready(
          function(){
            $("a'.variable_get('fancybox_class_id', '').'")
            .fancybox();
          }
        );',
        'inline');*/
    }
    $items[] = array(
      'path' => 'admin/settings/fancybox',
      'title' => t('Fancybox'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'fancybox_admin_settings',
      ),
      'access' => user_access('administer fancybox'),
      'description' => t('Settings page fo fancybox.'),
    );
  }
  return $items;
}

/**
 * Implementation of hook_perm().
 */
function fancybox_perm() {
  return array(
    'administer fancybox',
  );
}

/**
 * The default fancybox settings page.
 */
function fancybox_admin_settings() {
  $form['fancybox']['fancybox_class_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Css classe or id'),
    '#description' => t('The css class or ID to consider for fancybox. Fancybox will insert this value after the tag a.<br />Example: insert .myimageclass and fancybox will output a.image. Your markup has to be like this: &lt;a ...&gt&lt;img class="myimageclass" ... &gt;.'),
    '#default_value' => variable_get('fancybox_class_id', ''),
  );
  $form['fancybox']['fancybox_hideoncontentclick'] = array(
    '#type' => 'textfield',
    '#title' => t('Hide on content click'),
    '#description' => t('Hides FancyBox when cliked on opened item (true or false).'),
    '#default_value' => variable_get('fancybox_hideoncontentclick', 'true'),
  );
  $form['fancybox']['fancybox_padding'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox padding'),
    '#default_value' => variable_get('fancybox_padding', '0'),
  );
  $form['fancybox']['fancybox_zoomopacity'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox zoom opacity'),
    '#default_value' => variable_get('fancybox_zoomopacity', 'true'),
  );
  $form['fancybox']['fancybox_zoomspeedin'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox zoom speed in'),
    '#default_value' => variable_get('fancybox_zoomspeedin', '300'),
  );
  $form['fancybox']['fancybox_zoomspeedout'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox zoom speed out'),
    '#default_value' => variable_get('fancybox_zoomspeedout', '300'),
  );
  $form['fancybox']['fancybox_zoomspeedchange'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox zoom speed change'),
    '#description' => t('Speed in miliseconds of the animation when changing gallery items.'),
    '#default_value' => variable_get('fancybox_zoomspeedchange', '300'),
  );
  $form['fancybox']['fancybox_easingin'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox zoom speed change'),
    '#description' => t('Easing used for animations. Insert easeOutBack or none.'),
    '#default_value' => variable_get('fancybox_easingin', 'easeOutBack'),
  );
  $form['fancybox']['fancybox_easingout'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox zoom speed change'),
    '#description' => t('Easing used for animations. Insert easeInBack or none.'),
    '#default_value' => variable_get('fancybox_easingout', 'easeInBack'),
  );
  $form['fancybox']['fancybox_overlayshow'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox overlay show'),
    '#default_value' => variable_get('fancybox_overlayshow', 'true'),
  );
  $form['fancybox']['fancybox_overlayopacity'] = array(
    '#type' => 'textfield',
    '#title' => t('Fancybox overlay opacity'),
    '#default_value' => variable_get('fancybox_overlayopacity', '10'),
  );
  return system_settings_form($form);
}

Functions

Namesort descending Description
fancybox_admin_settings The default fancybox settings page.
fancybox_menu Implementation of hook_menu().
fancybox_perm Implementation of hook_perm().