You are here

function jq_maphilight_init in jQuery Map Hilight 6

Same name and namespace in other branches
  1. 7 jq_maphilight.module \jq_maphilight_init()

add the jquery map hilight plugin code to all pages

File

./jq_maphilight.module, line 11
Configurable javascript based image map hilighting using the jquery map hilight plugin.

Code

function jq_maphilight_init() {
  $available = _jq_maphilight_available();
  if ($available !== FALSE) {
    $script = "(function (\$) {\n" . "Drupal.behaviors.jq_maphilight = function(context, settings) {\n" . "\$.fn.maphilight.defaults = {\n" . "fill: " . variable_get('jq_maphilight_fill', 'true') . ",\n" . "fillColor: '" . variable_get('jq_maphilight_fillcolor', '000000') . "',\n" . "fillOpacity: " . variable_get('jq_maphilight_fillopacity', '2') / 10 . ",\n" . "stroke: " . variable_get('jq_maphilight_stroke', 'true') . ",\n" . "strokeColor: '" . variable_get('jq_maphilight_strokecolor', 'ff0000') . "',\n" . "strokeOpacity: " . variable_get('jq_maphilight_strokeopacity', '10') / 10 . ",\n" . "strokeWidth: " . variable_get('jq_maphilight_strokewidth', '2') . ",\n" . "fade: " . variable_get('jq_maphilight_fade', 'true') . ",\n" . "alwaysOn: " . variable_get('jq_maphilight_alwayson', 'false') . ",\n" . "neverOn: " . variable_get('jq_maphilight_neveron', 'false') . ",\n" . "groupBy: " . variable_get('jq_maphilight_groupby', 'false') . "};\n";
    if (variable_get('jq_maphilight_allmaps_enabled', TRUE)) {
      $script .= "\$('img[usemap]').maphilight();\n";
    }
    else {
      $script .= "\$('.jq_maphilight').maphilight();\n";
    }
    $script .= "}})(jQuery);";
    jquery_plugin_add('metadata');
    drupal_add_js($available, 'module');
    drupal_add_js($script, 'inline');
  }
  return '';
}