diff --git a/includes/jcarousel.views.inc b/includes/jcarousel.views.inc index 68a090b..2b5bdb3 100644 --- a/includes/jcarousel.views.inc +++ b/includes/jcarousel.views.inc @@ -156,6 +156,11 @@ function jcarousel_views_add($view, $display_id = NULL) { $options['auto'] = 0; } + // Calculate proper value for start if a negative value was chosen + if ($options['start'] < 0) { + $options['start'] += $count + 1; + } + // Determine AJAX functionality in a backwards-compatible way. Versions prior // to jCarousel 2.6 used the view-level "Use AJAX" option instead of a style // setting. We check $view->style_options here intentionally instead of diff --git a/includes/jcarousel_style_plugin.inc b/includes/jcarousel_style_plugin.inc index 23fe069..db2289f 100644 --- a/includes/jcarousel_style_plugin.inc +++ b/includes/jcarousel_style_plugin.inc @@ -39,8 +39,10 @@ class jcarousel_style_plugin extends views_plugin_style { $skins[''] = t('None'); // Number of options to provide in count-based options. - $range = drupal_map_assoc(range(1, 10)); - $auto_range = array('' => t('Auto')) + $range; + $start_range = range(-10, 10); + unset($start_range[10]); //Remove '0' + $range = drupal_map_assoc($start_range); + $auto_range = array('' => t('Auto')) + drupal_map_assoc(range(1, 10)); $form['description'] = array( '#type' => 'markup', @@ -134,7 +136,7 @@ class jcarousel_style_plugin extends views_plugin_style { $form['advanced']['start'] = array( '#type' => 'select', '#title' => t('Start position'), - '#description' => t('The item that will be shown as the first item in the list upon loading. Useful for starting a list in the middle of a set.'), + '#description' => t('The item that will be shown as the first item in the list upon loading. Useful for starting a list in the middle of a set. A negative value allows choosing an item in the end, e.g. -1 is the last item.'), '#options' => $range, '#default_value' => $this->options['start'], );