diff --git a/contrib/views_slideshow_cycle/views_slideshow_cycle.module b/contrib/views_slideshow_cycle/views_slideshow_cycle.module index 29483bd..3903db2 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.module +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.module @@ -12,9 +12,8 @@ function views_slideshow_cycle_init() { // Don't load javascript unless libraries module is present. if (module_exists('libraries')) { // Load jQuery Cycle - $cycle_path = libraries_get_path('jquery.cycle'); - if (!empty($cycle_path) && file_exists($cycle_path . '/jquery.cycle.all.min.js')) { - drupal_add_js($cycle_path . '/jquery.cycle.all.min.js'); + if ($cycle_path = _views_slideshow_cycle_library_path()) { + drupal_add_js($cycle_path); } // Load Json2 @@ -74,6 +73,35 @@ function views_slideshow_cycle_help($path, $arg) { } /** + * Gets the path to the jQuery cycle library. + * + * @return + * The path to the cycle library js file, or FALSE if not found. + */ +function _views_slideshow_cycle_library_path() { + $cycle_path = libraries_get_path('jquery.cycle'); + + if (!empty($cycle_path)) { + // Attempt to use minified version of jQuery cycle plugin. + if (file_exists($cycle_path . '/jquery.cycle.all.min.js')) { + $cycle_path .= '/jquery.cycle.all.min.js'; + } + // Otherwise use non-minified version if available. + elseif (file_exists($cycle_path . '/jquery.cycle.all.js')) { + $cycle_path .= '/jquery.cycle.all.js'; + } + else { + $cycle_path = FALSE; + } + } + else { + $cycle_path = FALSE; + } + + return $cycle_path; +} + +/** * Need to have preprocess functions here because drupal doesn't cache them * correctly in the theme.inc file. * diff --git a/contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc b/contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc index c6f03ab..7641bfd 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc @@ -69,10 +69,9 @@ function views_slideshow_cycle_views_slideshow_option_definition() { } function views_slideshow_cycle_views_slideshow_slideshow_type_form(&$form, &$form_state, &$view) { - $cycle_path = libraries_get_path('jquery.cycle'); - if (empty($cycle_path) || !file_exists($cycle_path . '/jquery.cycle.all.min.js')) { + if (!$cycle_path = _views_slideshow_cycle_library_path()) { $form['views_slideshow_cycle']['no_cycle_js'] = array( - '#markup' => '
' . t('You need to install the jQuery cycle plugin. Create a directory in sites/all/libraries called jquery.cycle, and then copy jquery.cycle.all.min.js into it. You can find the plugin at !url.', array('!url' => l('http://malsup.com/jquery/cycle', 'http://malsup.com/jquery/cycle', array('attributes' => array('target' => '_blank'))))) . '
', + '#markup' => '
' . t('You need to install the jQuery cycle plugin. Create a directory in sites/all/libraries called jquery.cycle, and then copy jquery.cycle.all.min.js or jquery.cycle.all.js into it. You can find the plugin at !url.', array('!url' => l('http://malsup.com/jquery/cycle', 'http://malsup.com/jquery/cycle', array('attributes' => array('target' => '_blank'))))) . '
', ); }