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 8b2640e..9a8c5d0 100644 --- a/contrib/views_slideshow_cycle/theme/views_slideshow_cycle.theme.inc +++ b/contrib/views_slideshow_cycle/theme/views_slideshow_cycle.theme.inc @@ -70,6 +70,7 @@ 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'); + drupal_add_library('views_slideshow_cycle', 'views_slideshow_cycle'); // Add the hoverIntent plugin. if (isset($settings['advanced_pagerevent']) && $settings['advanced_pagerevent'] == 'hoverIntent') { diff --git a/contrib/views_slideshow_cycle/views_slideshow_cycle.module b/contrib/views_slideshow_cycle/views_slideshow_cycle.module index 29483bd..7cc1051 100644 --- a/contrib/views_slideshow_cycle/views_slideshow_cycle.module +++ b/contrib/views_slideshow_cycle/views_slideshow_cycle.module @@ -6,30 +6,58 @@ */ /** - * Implements hook_init(). + * Implements hook_library(). */ -function views_slideshow_cycle_init() { - // Don't load javascript unless libraries module is present. +function views_slideshow_cycle_library() { + $libraries = array(); + + $libraries['views_slideshow_cycle'] = array( + 'title' => 'Views slideshow cycle', + 'version' => '1.0', + 'js' => array( + drupal_get_path('module', 'views_slideshow_cycle') . '/js/views_slideshow_cycle.js' => array(), + ), + 'css' => array( + drupal_get_path('module', 'views_slideshow_cycle') . '/views_slideshow_cycle.css' => array( + 'type' => 'file', + 'media' => 'screen', + ), + ), + 'dependencies' => array( + array('views_slideshow_cycle', 'jcycle'), + ), + ); + + $libraries['jcycle'] = array( + 'title' => 'jCycle', + 'version' => '1.0', + 'dependencies' => array( + array('views_slideshow_cycle', 'json2'), + ), + ); + 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'); + $libraries['jcycle']['js'][$cycle_path . '/jquery.cycle.all.min.js'] = array(); } + } + $libraries['json2'] = array( + 'title' => 'jCycle', + 'version' => '1.0', + ); + + if (module_exists('libraries')) { // 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'); + $libraries['json2']['js'][$json_path . '/json2.js'] = array(); } - - // 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'); + return $libraries; } /** @@ -74,9 +102,9 @@ function views_slideshow_cycle_help($path, $arg) { } /** - * Need to have preprocess functions here because drupal doesn't cache them + * Need to have preprocess functions here because drupal doesn't cache them * correctly in the theme.inc file. - * + * * If you would like to override the preprocess functions make sure to look at * the associated function in theme.inc. */ diff --git a/theme/views_slideshow.theme.inc b/theme/views_slideshow.theme.inc index 1e428d5..7e9412a 100644 --- a/theme/views_slideshow.theme.inc +++ b/theme/views_slideshow.theme.inc @@ -24,7 +24,7 @@ function _views_slideshow_preprocess_views_slideshow(&$vars) { } } } - + // Make sure the main slideshow settings are defined before building the // slideshow. if (empty($main_frame_module)) { @@ -87,6 +87,7 @@ function _views_slideshow_preprocess_views_slideshow(&$vars) { ) ); drupal_add_js($js_settings, 'setting'); + drupal_add_library('views_slideshow', 'views_slideshow'); /** * Process Skins @@ -191,6 +192,7 @@ function theme_views_slideshow_pager_widget_render($vars) { ); drupal_add_js($js_vars, 'setting'); + drupal_add_library('views_slideshow', 'views_slideshow'); // Create some attributes $attributes['class'] = 'widget_pager widget_pager_' . $vars['location']; @@ -215,6 +217,7 @@ function _views_slideshow_preprocess_views_slideshow_pager_fields(&$vars) { // Add the settings to the page. drupal_add_js($js_vars, 'setting'); + drupal_add_library('views_slideshow', 'views_slideshow'); $vars['classes_array'][] = $vars['attributes']['class']; $vars['widget_id'] = $vars['attributes']['id']; @@ -265,6 +268,7 @@ function theme_views_slideshow_controls_widget_render($vars) { ); drupal_add_js($js_vars, 'setting'); + drupal_add_library('views_slideshow', 'views_slideshow'); $output = ''; if (count($vars['rows']) > 1) { diff --git a/views_slideshow.module b/views_slideshow.module index c31d908..f6b4c22 100644 --- a/views_slideshow.module +++ b/views_slideshow.module @@ -82,14 +82,26 @@ function views_slideshow_help($path, $arg) { } /** - * Implements hook_init(). + * Implements hook_library(). */ -function views_slideshow_init() { - // Load javascript on the page in init to help fool caching. - drupal_add_js(drupal_get_path('module', 'views_slideshow') . '/js/views_slideshow.js'); +function views_slideshow_library() { + $libraries = array(); + + $libraries['views_slideshow'] = array( + 'title' => 'Views slideshow', + 'version' => '1.0', + 'js' => array( + drupal_get_path('module', 'views_slideshow') . '/js/views_slideshow.js' => array(), + ), + 'css' => array( + drupal_get_path('module', 'views_slideshow') . '/views_slideshow.css' => array( + 'type' => 'file', + 'media' => 'screen', + ), + ), + ); - $vs_path = drupal_get_path('module', 'views_slideshow'); - drupal_add_css($vs_path . '/views_slideshow.css'); + return $libraries; } /**