diff --git a/contrib/views_slideshow_cycle/views_slideshow_cycle.module b/contrib/views_slideshow_cycle/views_slideshow_cycle.module index a7f25b5..6b6ca10 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.module +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.module @@ -10,9 +10,9 @@ */ function views_slideshow_cycle_init() { // 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'); + $cycle_path = _views_slideshow_cycle_library_path(); + if (!empty($cycle_path)) { + drupal_add_js($cycle_path); } // Load Json2 @@ -71,4 +71,33 @@ function views_slideshow_cycle_help($path, $arg) { } return $output; } +} + +/** + * 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; } \ No newline at end of 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 2e77033..273dbfb 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,10 @@ 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')) { + $cycle_path = _views_slideshow_cycle_library_path(); + if (empty($cycle_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'))))) . '
', ); }