Ejemplo n.º 1
0
function kr2011_preprocess_views_slideshow_thumbnailhover(&$vars)
{
    $options = $vars['options'];
    $view = $vars['view'];
    $rows = $vars['rows'];
    $vss_id = $view->name . '-' . $view->current_display;
    //drupal_set_message('rows: '.count($rows));
    $vars['image_count'] = count($rows);
    $settings = array_merge(array('num_divs' => sizeof($vars['rows']), 'teasers_last' => $options['thumbnailhover']['teasers_last'] ? TRUE : FALSE, 'id_prefix' => '#views_slideshow_thumbnailhover_main_', 'div_prefix' => '#views_slideshow_thumbnailhover_div_', 'vss_id' => $vss_id, 'view_id' => $vss_id), $options['views_slideshow_thumbnailhover']);
    // We need to go through the current js setting values to make sure the one we
    // want to add is not already there. If it is already there then append -[num]
    // to the id to make it unique.
    $slideshow_count = 1;
    $current_settings = drupal_add_js();
    foreach ($current_settings['setting'] as $current_setting) {
        if (isset($current_setting['viewsSlideshowThumbnailHover'])) {
            $current_keys = array_keys($current_setting['viewsSlideshowThumbnailHover']);
            if (stristr($current_keys[0], '#views_slideshow_thumbnailhover_main_' . $vss_id)) {
                $slideshow_count++;
            }
        }
    }
    if ($slideshow_count > 1) {
        $vss_id .= '-' . $slideshow_count;
        $settings['vss_id'] = $vss_id;
    }
    drupal_add_js(array('viewsSlideshowThumbnailHover' => array("#views_slideshow_thumbnailhover_main_" . $vss_id => $settings)), 'setting');
    // Add the hoverIntent plugin.
    if ($settings['pager_event'] == 'hoverIntent') {
        if (module_exists('jq')) {
            $loaded_plugins = jq_plugins();
            if (!empty($loaded_plugins['hoverIntent'])) {
                jq_add('hoverIntent');
            }
        }
        if (module_exists('hoverintent')) {
            hoverintent_add();
        }
    }
    $teaser = $options['views_slideshow_thumbnailhover']['hover_breakout'] == 'teaser' ? TRUE : FALSE;
    $hidden_elements = theme('views_slideshow_thumbnailhover_no_display_section', $view, $rows, $vss_id, $options, $teaser);
    $vars['slideshow'] = theme('views_slideshow_main_section', $vss_id, $hidden_elements, 'views_slideshow_thumbnailhover');
    $thumbnailhover = $vars['options']['views_slideshow_thumbnailhover'];
    if (count($rows) > 1) {
        $vars['ctr_prev'] = theme_views_slideshow_thumbnailhover_control_previous($vss_id, $view, $options);
        $vars['ctr_next'] = theme_views_slideshow_thumbnailhover_control_next($vss_id, $view, $options);
    }
    // Only show controls when there is more than one result.
    if ($settings['num_divs'] > 1) {
        if ($thumbnailhover['controls'] == 1) {
            $vars['controls_top'] = theme('views_slideshow_thumbnailhover_controls', $vss_id, $view, $options);
        } elseif ($thumbnailhover['controls'] == 2) {
            $vars['controls_bottom'] = theme('views_slideshow_thumbnailhover_controls', $vss_id, $view, $options);
        }
    }
    if (!$thumbnailhover['teasers_last']) {
        $vars['breakout_top'] = theme('views_slideshow_thumbnailhover_breakout_teasers', $view, $rows, $vss_id, $options);
    } else {
        $vars['breakout_bottom'] = theme('views_slideshow_thumbnailhover_breakout_teasers', $view, $rows, $vss_id, $options);
    }
    if ($thumbnailhover['image_count'] == 1) {
        $vars['image_count_top'] = theme('views_slideshow_thumbnailhover_image_count', $vss_id, $view, $options);
    } elseif ($thumbnailhover['image_count'] == 2) {
        $vars['image_count_bottom'] = theme('views_slideshow_thumbnailhover_image_count', $vss_id, $view, $options);
    }
}
 * - $empty: The empty text to display if the view is empty
 * - $pager: The pager next/prev links to display, if any
 * - $exposed: Exposed widget form/info to display
 * - $feed_icon: Feed icon to display, if any
 * - $more: A link to view more, if any
 * - $admin_links: A rendered list of administrative links
 * - $admin_links_raw: A list of administrative links suitable for theme('links')
 *
 * @ingroup views_templates
 */
if (module_exists('jq')) {
    // I'm using jq_add here. It assumes you have the jQuery Cycle plug-in
    // installed. That plug-in comes bundled with the jQuery Plugins module as
    // jq_add('cycle'), but you could also just drop it into a /plugins or
    // /sites/all/plugins folder (as done here) and call it with the same method.
    jq_add('cycle');
    // Here's the actual call for our cycle slide show plug-in.
    // I'm using the 'fade' effect, fading the image cycle, slowing it from the
    // default with 'timeout', and using 'pause' to allow a pause on mouse hover.
    // There are lots of cool effects; see the plug-in home at malsup.com/jquery/cycle/.
    $js = <<<js
   \$('.view-senator-carousel ul').cycle({
     fx: 'fade',
     pause: 1,
     timeout: 10000
   });
js;
    // Make it degrade gracefully in non-javascript browsers.
    $js = "if (Drupal.jsEnabled) {  \$(document).ready(function() { {$js}  });  }";
    drupal_add_js($js, 'inline');
}