| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Configurable javascript based image map hilighting using the jquery map hilight plugin.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* add the jquery map hilight plugin code to all pages
|
| 11 |
*/
|
| 12 |
function jq_maphilight_init() {
|
| 13 |
$available = _jq_maphilight_available();
|
| 14 |
if (($available !== FALSE) && (arg(0) != 'admin') && (arg(0) != 'user') && (arg(1) != 'add') && (arg(2) != 'edit')) {
|
| 15 |
|
| 16 |
$script = "\$(document).ready(function() { \$.fn.maphilight.defaults = { "
|
| 17 |
."fill: ". variable_get('jq_maphilight_fill', 'true') .","
|
| 18 |
."fillColor: '". variable_get('jq_maphilight_fillcolor', 'ff0000') ."',"
|
| 19 |
."fillOpacity: ". (variable_get('jq_maphilight_fillopacity', '2') / 10) .","
|
| 20 |
."stroke: ". variable_get('jq_maphilight_stroke', 'true') .","
|
| 21 |
."strokeColor: '". variable_get('jq_maphilight_strokecolor', 'D51910') ."',"
|
| 22 |
."strokeOpacity: ". (variable_get('jq_maphilight_strokeopacity', '10') / 10) .","
|
| 23 |
."strokeWidth: ". variable_get('jq_maphilight_strokewidth', '2') .","
|
| 24 |
."fade: ". variable_get('jq_maphilight_fade', 'true') .","
|
| 25 |
."alwaysOn: false}; "
|
| 26 |
."\$('.jq_maphilight').maphilight();});";
|
| 27 |
|
| 28 |
jquery_plugin_add('metadata');
|
| 29 |
jquery_plugin_add('maphilight');
|
| 30 |
drupal_add_js($script, 'inline');
|
| 31 |
|
| 32 |
}
|
| 33 |
return '';
|
| 34 |
}
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Implemention of hook_menu().
|
| 38 |
*/
|
| 39 |
function jq_maphilight_menu() {
|
| 40 |
$items = array();
|
| 41 |
$items['admin/settings/jq_maphilight'] = array(
|
| 42 |
'title' => 'JQuery Map Hilight',
|
| 43 |
'description' => 'Javascript image map highlighting using the jquery Map Hilight plugin.',
|
| 44 |
'page callback' => 'drupal_get_form',
|
| 45 |
'page arguments' => array('jq_maphilight_admin_settings'),
|
| 46 |
'access callback' => 'user_access',
|
| 47 |
'access arguments' => array('access administration pages'),
|
| 48 |
'type' => MENU_NORMAL_ITEM,
|
| 49 |
);
|
| 50 |
|
| 51 |
return $items;
|
| 52 |
}
|
| 53 |
|
| 54 |
/**
|
| 55 |
* jq_maphilight admin/settings page; implements hook_form
|
| 56 |
*/
|
| 57 |
function jq_maphilight_admin_settings() {
|
| 58 |
$form['jq_maphilight_status'] = array(
|
| 59 |
'#type' => 'fieldset',
|
| 60 |
'#title' => t('jQuery Map Hilight Plugin Status'),
|
| 61 |
'#weight' => -10,
|
| 62 |
'#description' => (_jq_maphilight_available() !== false) ? t('The Map Hilight jQuery plugin is available at: /') . _jq_maphilight_available() : '<em><span style="color: #A50000;">'. t('The Map Hilight jQuery plugin is unavailable or not located in the jquery_plugin module directory.') .'</span></em>'
|
| 63 |
);
|
| 64 |
|
| 65 |
$form['jq_maphilight_settings'] = array(
|
| 66 |
'#type' => 'fieldset',
|
| 67 |
'#title' => t('jQuery Map Hilight Plugin Settings'),
|
| 68 |
'#description' => 'Be sure to add <strong><em>class="jq_maphilight"</em></strong> to the IMG tag of all image maps you want hilighted.'
|
| 69 |
);
|
| 70 |
|
| 71 |
$form['jq_maphilight_settings']['jq_maphilight_fill'] = array(
|
| 72 |
'#type' => 'select',
|
| 73 |
'#title' => t('Fill'),
|
| 74 |
'#default_value' => variable_get('jq_maphilight_fill', 'true'),
|
| 75 |
'#options' => array('true' => t('TRUE'), 'false' => t('FALSE')),
|
| 76 |
'#description' => 'Specify whether or not the hilighted area should be filled.'
|
| 77 |
);
|
| 78 |
|
| 79 |
$form['jq_maphilight_settings']['jq_maphilight_fillcolor'] = array(
|
| 80 |
'#type' => 'textfield',
|
| 81 |
'#title' => t('Fill Color'),
|
| 82 |
'#default_value' => variable_get('jq_maphilight_fillcolor', 'ff0000'),
|
| 83 |
'#size' => 8,
|
| 84 |
'#description' => 'Specify the color of the fill. Use HTML # notation without the #.'
|
| 85 |
);
|
| 86 |
|
| 87 |
$form['jq_maphilight_settings']['jq_maphilight_fillopacity'] = array(
|
| 88 |
'#type' => 'select',
|
| 89 |
'#title' => t('Fill Opacity'),
|
| 90 |
'#default_value' => variable_get('jq_maphilight_fillopacity', 2),
|
| 91 |
'#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
|
| 92 |
'#description' => 'Specify the opacity of the fill (0 = lightest, 10 = darkest).'
|
| 93 |
);
|
| 94 |
|
| 95 |
$form['jq_maphilight_settings']['jq_maphilight_stroke'] = array(
|
| 96 |
'#type' => 'select',
|
| 97 |
'#title' => t('Stroke (outline)'),
|
| 98 |
'#options' => array('true' => t('TRUE'), 'false' => t('FALSE')),
|
| 99 |
'#default_value' => (variable_get('jq_maphilight_stroke', 'true')),
|
| 100 |
'#description' => 'Specify whether or not the hilighted area will be outlined.'
|
| 101 |
);
|
| 102 |
|
| 103 |
$form['jq_maphilight_settings']['jq_maphilight_strokecolor'] = array(
|
| 104 |
'#type' => 'textfield',
|
| 105 |
'#title' => t('Stroke Color'),
|
| 106 |
'#default_value' => variable_get('jq_maphilight_strokecolor', 'D51910'),
|
| 107 |
'#size' => 8,
|
| 108 |
'#description' => 'Specify the color of the outline. Use HTML # notation without the #.'
|
| 109 |
);
|
| 110 |
|
| 111 |
$form['jq_maphilight_settings']['jq_maphilight_strokewidth'] = array(
|
| 112 |
'#type' => 'textfield',
|
| 113 |
'#title' => t('Stroke Width'),
|
| 114 |
'#default_value' => variable_get('jq_maphilight_strokewidth', 2),
|
| 115 |
'#size' => 8,
|
| 116 |
'#description' => 'Specify the width of the outline in pixels.'
|
| 117 |
);
|
| 118 |
|
| 119 |
$form['jq_maphilight_settings']['jq_maphilight_strokeopacity'] = array(
|
| 120 |
'#type' => 'select',
|
| 121 |
'#title' => t('Stroke Opacity'),
|
| 122 |
'#default_value' => variable_get('jq_maphilight_strokeopacity', 10),
|
| 123 |
'#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
|
| 124 |
'#description' => 'Specify the opacity of the outline (0 = lightest, 10 = darkest).'
|
| 125 |
);
|
| 126 |
|
| 127 |
$form['jq_maphilight_settings']['jq_maphilight_fade'] = array(
|
| 128 |
'#type' => 'select',
|
| 129 |
'#title' => t('Fade'),
|
| 130 |
'#options' => array('true' => t('TRUE'), 'false' => t('FALSE')),
|
| 131 |
'#default_value' => (variable_get('jq_maphilight_fade', 'true')),
|
| 132 |
'#description' => 'Specify whether or not the hilighting uses a fade transition.'
|
| 133 |
);
|
| 134 |
|
| 135 |
return system_settings_form($form);
|
| 136 |
}
|
| 137 |
|
| 138 |
/**
|
| 139 |
* check jquery_plugin directory for the jquery.maphilight.min.js file
|
| 140 |
*/
|
| 141 |
function _jq_maphilight_available() {
|
| 142 |
|
| 143 |
$available = drupal_get_path('module', 'jquery_plugin') .'/jquery.maphilight.min.js';
|
| 144 |
|
| 145 |
if (!is_file($available)) {
|
| 146 |
return FALSE;
|
| 147 |
}
|
| 148 |
|
| 149 |
return $available;
|
| 150 |
}
|