You are here

function beautytips_manager_build_beautytip in BeautyTips 6.2

Same name and namespace in other branches
  1. 8 beautytips_manager/beautytips_manager.module \beautytips_manager_build_beautytip()
  2. 7.2 beautytips_manager.module \beautytips_manager_build_beautytip()

Given a custom tip, build an array of options that can be passed to beautytips_add_beautytips().

1 call to beautytips_manager_build_beautytip()
beautytips_manager_init in ./beautytips_manager.module
Implementation of hook_init().

File

./beautytips_manager.module, line 429

Code

function beautytips_manager_build_beautytip($tip) {
  $single_triggers = array(
    'hover',
    'hoverIntent',
  );
  $trigger = in_array($tip->trigger_on, $single_triggers) ? $tip->trigger_on : array(
    $tip->trigger_on,
    $tip->trigger_off,
  );
  $options = array(
    'cssSelect' => check_plain($tip->element),
    'style' => $tip->style,
    'trigger' => $trigger,
    'shrinkToFit' => (bool) $tip->shrink,
  );
  if ($tip->animation_on) {
    $options['animate']['on'] = $tip->animation_on;
  }
  if ($tip->animation_off) {
    $options['animate']['off'] = $tip->animation_off;
  }
  if ($tip->positions) {
    $options['positions'] = explode(',', $tip->positions);
  }
  switch ($tip->content_type) {
    case 'attribute':
      if ($tip->content) {
        $options['contentSelector'] = "\$(this).attr('" . check_plain($tip->content) . "')";
      }
      break;
    case 'text':
      $options['text'] = check_markup($tip->content);
      break;
    case 'ajax':
      $options['ajaxPath'] = !$tip->content ? "\$(this).attr('href')" : array(
        "\$(this).attr('href')",
        check_plain($tip->content),
      );
      break;
    case 'js':
      $options['contentSelector'] = check_plain($tip->content);
      break;
  }
  return $options;
}