diff --git a/contrib/views_slideshow_cycle/js/views_slideshow_cycle.js b/contrib/views_slideshow_cycle/js/views_slideshow_cycle.js index 5ee71ec..096003c 100644 --- a/contrib/views_slideshow_cycle/js/views_slideshow_cycle.js +++ b/contrib/views_slideshow_cycle/js/views_slideshow_cycle.js @@ -99,11 +99,20 @@ // Pause on hover. if (settings.pause) { - $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(function() { + var mouseIn = function() { Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId }); - }, function() { + } + + var mouseOut = function() { Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId }); - }); + } + + if (jQuery.fn.hoverIntent) { + $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hoverIntent(mouseIn, mouseOut); + } + else { + $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(mouseIn, mouseOut); + } } // Pause on clicking of the slide. diff --git a/contrib/views_slideshow_cycle/theme/views_slideshow_cycle.theme.inc b/contrib/views_slideshow_cycle/theme/views_slideshow_cycle.theme.inc index 1d9a8ff..9afccda 100644 --- a/contrib/views_slideshow_cycle/theme/views_slideshow_cycle.theme.inc +++ b/contrib/views_slideshow_cycle/theme/views_slideshow_cycle.theme.inc @@ -71,17 +71,15 @@ function _views_slideshow_cycle_preprocess_views_slideshow_cycle_main_frame(&$va drupal_add_js(array('viewsSlideshowCycle' => array('#views_slideshow_cycle_main_' . $vss_id => $settings)), 'setting'); - // Add the hoverIntent plugin. - if (isset($settings['advanced_pagerevent']) && $settings['advanced_pagerevent'] == 'hoverIntent') { - if (module_exists('jq')) { - $loaded_plugins = jq_plugins(); - if (!empty($loaded_plugins['hoverIntent'])) { - jq_add('hoverIntent'); + // Add hover intent library + if ($settings['pause']) { + if (module_exists('libraries')) { + // Load jQuery hoverIntent + $hoverIntent_path = libraries_get_path('jquery.hoverIntent'); + if (!empty($hoverIntent_path) && file_exists($hoverIntent_path . '/jquery.hoverIntent.js')) { + drupal_add_js($hoverIntent_path . '/jquery.hoverIntent.js'); } } - if (module_exists('hoverintent')) { - hoverintent_add(); - } } // Add the slideshow elements. diff --git a/js/views_slideshow.js b/js/views_slideshow.js index c8dc99b..c3d05b9 100644 --- a/js/views_slideshow.js +++ b/js/views_slideshow.js @@ -253,13 +253,21 @@ // Add the activate and pause on pager hover event to each pager item. if (Drupal.settings.viewsSlideshowPagerFields[uniqueID][location].activatePauseOnHover) { $(this).children().each(function(index, pagerItem) { - $(pagerItem).hover(function() { + var mouseIn = function() { Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index }); Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID }); - }, - function() { + } + + var mouseOut = function() { Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID }); - }); + } + + if (jQuery.fn.hoverIntent) { + $(pagerItem).hoverIntent(mouseIn, mouseOut); + } + else { + $(pagerItem).hover(mouseIn, mouseOut); + } }); } else { diff --git a/theme/views_slideshow.theme.inc b/theme/views_slideshow.theme.inc index c3fff24..d5f7f2d 100644 --- a/theme/views_slideshow.theme.inc +++ b/theme/views_slideshow.theme.inc @@ -220,6 +220,17 @@ function _views_slideshow_preprocess_views_slideshow_pager_fields(&$vars) { // Add the settings to the page. drupal_add_js($js_vars, 'setting'); + + // Add hover intent library + if ($vars['settings']['views_slideshow_pager_fields_hover']) { + if (module_exists('libraries')) { + // Load jQuery hoverIntent + $hoverIntent_path = libraries_get_path('jquery.hoverIntent'); + if (!empty($hoverIntent_path) && file_exists($hoverIntent_path . '/jquery.hoverIntent.js')) { + drupal_add_js($hoverIntent_path . '/jquery.hoverIntent.js'); + } + } + } // Add our class to the wrapper. $vars['attributes']['class'] = (isset($vars['attributes']['class'])) ? $vars['attributes']['class'] . ' views_slideshow_pager_field' : 'views_slideshow_pager_field';