function qtip_views_preprocess_views_view in qTip (Stylish jQuery Tooltips) 7.2
Implements hook_preprocess_views_view().
File
- modules/
qtip_views/ qtip_views.module, line 111
Code
function qtip_views_preprocess_views_view(&$vars) {
$view =& $vars['view'];
if ($tooltips = qtip_views_fetch_element_tooltips($view)) {
// Theme tooltip and add our element class before rendering.
$themed = array();
foreach ($view->result as $row => $result) {
$i = 0;
foreach ($tooltips as $field => $tooltip) {
$field_css = drupal_clean_css_identifier($field);
$tokens = $view->style_plugin->row_tokens[$row];
$qtip_title = str_replace(array_keys($tokens), array_values($tokens), $tooltip['title']);
$qtip_text = str_replace(array_keys($tokens), array_values($tokens), $tooltip['text']);
if (!empty($view->field[$field]) && !empty($view->field[$field]->options['qtip_text']) && empty($view->field[$field]->options['exclude'])) {
$themed[$row][$field_css] = theme('qtip_views_tooltip', array(
'view' => $view,
'title' => $qtip_title,
'text' => $qtip_text,
'instance' => $tooltip['instance'],
));
}
}
$i++;
}
// Bail early if nothing to do.
if (!empty($themed)) {
// Set qtip_views.js' weight to make it run before qtip.js.
drupal_add_js(drupal_get_path('module', 'qtip_views') . '/js/qtip_views.js', array(
'weight' => 0,
));
drupal_add_js(array(
'qtipViewsTooltip' => array(
$view->name => array(
$view->current_display => array(
'tooltips' => $themed,
),
),
),
), 'setting');
}
}
}