2); } function template_preprocess_viewscarousel_view(&$vars) { drupal_add_css(drupal_get_path('module', 'viewscarousel') .'/jquery.jcarousel.css'); drupal_add_css(drupal_get_path('module', 'viewscarousel') .'/skins/ie7/skin.css'); drupal_add_js(drupal_get_path('module', 'viewscarousel') .'/jquery.jcarousel.min.js'); drupal_add_js(drupal_get_path('module', 'viewscarousel') .'/viewscarousel.js'); $options = viewscarousel_get_options($vars); $view = $vars['view']; $vars['viewscarousel_id'] = 'viewscarousel-'. $view->name .'-'. $view->current_display; $vars['viewscarousel_class'] = viewscarousel_get_class($vars); drupal_add_js(array('viewscarousel' => array($vars['viewscarousel_id'] => $options)), 'setting'); } /** * Get the options to pass to jcarousel from the settings. * * @param array $vars * Variables from a _preprocess_viewscarousel_view function * * @return array * Options that can be passed to jcarousel */ function viewscarousel_get_options(&$vars) { $options = array(); $options['vertical'] = $vars['options']['vertical']; $options['start'] = $vars['options']['start']; $options['scroll'] = $vars['options']['scroll']; $options['visible'] = $vars['options']['visible']; $options['animation'] = $vars['options']['animation']; $options['easing'] = $vars['options']['easing']; $options['auto'] = $vars['options']['auto']; $options['wrap'] = $vars['options']['wrap']; foreach ($options as $key => $value) { if (empty($value)) { unset($options[$key]); } } // Bug fix. 1 is default. If you manually set 1 an empty row is added to left side. if ($options['start'] == 1) unset($options['start']); return $options; } /** * Get class for skin and add css file if available * * @param array $vars * Variables from a _preprocess_viewscarousel_view function * @return string * Class name to add to ul */ function viewscarousel_get_class($vars) { switch ($vars['options']['skin']) { case 'ie7': drupal_add_css(drupal_get_path('module', 'viewscarousel') .'/skins/ie7/skin.css'); return 'jcarousel-skin-ie7'; break; case 'tango': drupal_add_css(drupal_get_path('module', 'viewscarousel') .'/skins/tango/skin.css'); return 'jcarousel-skin-tango'; break; default: return; break; } }