diff --git a/contrib/views_slideshow_cycle/views_slideshow_cycle.info b/contrib/views_slideshow_cycle/views_slideshow_cycle.info index 296ecbb..d33e0ac 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.info +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.info @@ -1,6 +1,7 @@ name = Views Slideshow: Cycle description = Adds a Rotating slideshow mode to Views Slideshow. dependencies[] = views_slideshow +dependencies[] = libraries package = Views core = 7.x diff --git a/contrib/views_slideshow_cycle/views_slideshow_cycle.module b/contrib/views_slideshow_cycle/views_slideshow_cycle.module index 613f34f..a7f25b5 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.module +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.module @@ -9,31 +9,23 @@ * Implements hook_init(). */ function views_slideshow_cycle_init() { - // If the jQ module is installed, use that to add the jQuery Cycle plugin. - // This allows different versions of the plugin to be used. - $js = FALSE; - if (module_exists('jq')) { - $loaded_plugins = jq_plugins(); - if (!empty($loaded_plugins['cycle'])) { - $js = jq_add('cycle'); - } + // 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'); } - // Set location of the libraries directory. - $libraries_path = 'sites/all/libraries'; - - // Otherwise, we'll add the version included with this module. - if (!$js && file_exists($libraries_path . '/jquery.cycle/jquery.cycle.all.min.js')) { - drupal_add_js($libraries_path . '/jquery.cycle/jquery.cycle.all.min.js'); - } - - if (file_exists($libraries_path . '/json2/json2.js')) { - drupal_add_js($libraries_path . '/json2/json2.js'); + // Load Json2 + $json_path = libraries_get_path('json2'); + if (!empty($json_path) && file_exists($json_path . '/json2.js')) { + drupal_add_js($json_path . '/json2.js'); } + // Load our cycle js $module_path = drupal_get_path('module', 'views_slideshow_cycle'); drupal_add_js($module_path . '/js/views_slideshow_cycle.js'); + // Load our cycle css drupal_add_css($module_path . '/views_slideshow_cycle.css', '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 1de9fcd..951f2b5 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.views_slideshow.inc @@ -69,8 +69,8 @@ function views_slideshow_cycle_views_slideshow_option_definition() { } function views_slideshow_cycle_views_slideshow_slideshow_type_form(&$form, &$form_state, &$view) { - - if (!file_exists('sites/all/libraries/jquery.cycle/jquery.cycle.all.min.js')) { + $cycle_path = libraries_get_path('jquery.cycle'); + if (empty($cycle_path) || !file_exists($cycle_path . '/jquery.cycle.all.min.js')) { $form['views_slideshow_cycle']['no_cycle_js'] = array( '#markup' => '
' . t('You need to download jQuery cycle plugin and copy jquery.cycle.all.min.js to sites/all/libraries/jquery.cycle 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'))))) . '
', ); @@ -346,8 +346,9 @@ function views_slideshow_cycle_views_slideshow_slideshow_type_form(&$form, &$for $form['views_slideshow_cycle']['advanced_options_header'] = array( '#markup' => '

' . t('jQuery Cycle Custom Options') . '

', ); - - if (!file_exists('sites/all/libraries/json2/json2.js')) { + + $json2_path = libraries_get_path('json2'); + if (empty($json2_path) || !file_exists($json2_path . '/json2.js')) { $form['views_slideshow_cycle']['no_json_js'] = array( '#markup' => '
' . t('To use the advanced options you need to download json2.js. You can do this by clicking the download button at !url and extract json2.js to sites/all/libraries/json2', array('!url' => l('https://github.com/douglascrockford/JSON-js', 'https://github.com/douglascrockford/JSON-js', array('attributes' => array('target' => '_blank'))))) . '
', );