You are here

class jcarousel_style_plugin in jCarousel 7.3

Same name and namespace in other branches
  1. 8.3 includes/jcarousel_style_plugin.inc \jcarousel_style_plugin
  2. 6.2 includes/jcarousel_style_plugin.inc \jcarousel_style_plugin
  3. 7.2 includes/jcarousel_style_plugin.inc \jcarousel_style_plugin

Style plugin to render each item in an ordered or unordered list.

Hierarchy

Expanded class hierarchy of jcarousel_style_plugin

1 string reference to 'jcarousel_style_plugin'
jcarousel_views_plugins in includes/jcarousel.views.inc
Implements hook_views_plugin().

File

includes/jcarousel_style_plugin.inc, line 13
Contains the jCarousel style plugin.

View source
class jcarousel_style_plugin extends views_plugin_style {
  function option_definition() {
    $options = parent::option_definition();
    $options['wrap'] = array(
      'default' => 'circular',
    );
    $options['skin'] = array(
      'default' => 'default',
    );
    $options['visible'] = array(
      'default' => NULL,
    );
    $options['scroll'] = array(
      'default' => '',
    );
    $options['auto'] = array(
      'default' => 0,
    );
    $options['autoPause'] = array(
      'default' => '1',
    );
    $options['animation'] = array(
      'default' => '',
    );
    $options['start'] = array(
      'default' => '1',
    );
    $options['easing'] = array(
      'default' => NULL,
    );
    $options['vertical'] = array(
      'default' => FALSE,
    );
    $options['center'] = array(
      'default' => FALSE,
    );
    $options['navigation'] = array(
      'default' => '',
    );
    $options['ajax'] = array(
      'default' => 0,
    );
    $options['responsive'] = array(
      'default' => 1,
    );
    return $options;
  }
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    // Build the list of skins as options.
    $skins = array();
    foreach (jcarousel_skins() as $key => $skin) {
      $skins[$key] = $skin['title'];
    }
    $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;
    $form['description'] = array(
      '#type' => 'markup',
      '#value' => '<div class="messages">' . t('The jCarousel style is affected by several other settings within the display. Enable the "Use AJAX" option on your display to have items loaded dynamically. The "Items to display" option will determine how many items are preloaded into the carousel on each AJAX request. Non-AJAX carousels will contain the total number of items set in the "Items to display" option. Carousels may not be used with the "Use pager" option.') . '</div>',
    );
    $form['wrap'] = array(
      '#type' => 'select',
      '#title' => t('Wrap content'),
      '#default_value' => $this->options['wrap'],
      '#description' => t('Specifies whether to wrap at the first/last item (or both) and jump back to the start/end.'),
      '#options' => array(
        0 => t('Disabled'),
        'circular' => t('Circular'),
        'both' => t('Both'),
        'last' => t('Last'),
        'first' => t('First'),
      ),
    );
    $form['skin'] = array(
      '#type' => 'select',
      '#title' => t('Skin'),
      '#default_value' => $this->options['skin'],
      '#options' => $skins,
      '#description' => t('Skins may be provided by other modules. Set to "None" if your theme includes carousel theming directly in style.css or another stylesheet. "None" does not include any built-in navigation, arrows, or positioning at all.'),
    );
    $form['responsive'] = array(
      '#type' => 'checkbox',
      '#title' => t('Responsive'),
      '#default_value' => $this->options['responsive'],
      '#description' => t('Should the carousel fill the available space and respond to page flow changes? Untick for a fixed-width carousel.'),
    );
    $form['visible'] = array(
      '#type' => 'select',
      '#title' => t('Number of visible items'),
      '#options' => $auto_range,
      '#default_value' => $this->options['visible'],
      '#description' => t('Set an exact number of items to show at a time. It is recommended to leave set this to "auto", in which the number of items will be determined automatically by the space available to the carousel.') . ' <strong>' . t('Changing this option will override "width" properties set in your CSS.') . '</strong>',
    );
    $form['scroll'] = array(
      '#type' => 'select',
      '#title' => t('Scroll'),
      '#description' => t('The number of items to scroll at a time. The "auto" setting scrolls all the visible items.'),
      '#options' => $auto_range,
      '#default_value' => $this->options['scroll'],
    );
    $form['auto'] = array(
      '#type' => 'textfield',
      '#title' => t('Auto-scroll after'),
      '#size' => 4,
      '#maxlength' => 4,
      '#default_value' => $this->options['auto'],
      '#field_suffix' => ' ' . t('seconds'),
      '#description' => t('Specifies how many seconds to periodically auto-scroll the content. If set to 0 (default) then autoscrolling is turned off.'),
    );
    $form['navigation'] = array(
      '#type' => 'select',
      '#title' => t('Enable navigation'),
      '#options' => array(
        '' => t('None'),
        'before' => t('Before'),
        'after' => t('After'),
      ),
      '#default_value' => $this->options['navigation'],
      '#description' => t('Enable a clickable navigation list to jump straight to a given page.'),
    );
    $form['ajax'] = array(
      '#type' => 'checkbox',
      '#title' => t('AJAX load pages'),
      '#default_value' => $this->options['ajax'],
      '#description' => t('The number of items set in the pager settings will be preloaded. All additional pages will be loaded by AJAX as needed.'),
    );
    $form['advanced'] = array(
      '#type' => 'fieldset',
      '#title' => t('Advanced'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#parents' => array(
        'style_options',
      ),
    );
    $form['advanced']['animation'] = array(
      '#type' => 'textfield',
      '#title' => t('Animation speed'),
      '#size' => 10,
      '#maxlength' => 10,
      '#default_value' => $this->options['animation'],
      '#description' => t('The speed of the scroll animation as string in jQuery terms ("slow"  or "fast") or milliseconds as integer (See <a href="http://api.jquery.com/animate/">jQuery Documentation</a>).'),
    );
    $form['advanced']['easing'] = array(
      '#type' => 'textfield',
      '#title' => t('Easing effect'),
      '#size' => 10,
      '#maxlength' => 128,
      '#default_value' => $this->options['easing'],
      '#description' => t('The name of the easing effect that you want to use such as "swing" (the default) or "linear". See list of options in the <a href="http://api.jquery.com/animate/">jQuery Documentation</a>.'),
    );
    $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.'),
      '#options' => $range,
      '#default_value' => $this->options['start'],
    );
    $form['advanced']['autoPause'] = array(
      '#type' => 'checkbox',
      '#title' => t('Pause auto-scroll on hover'),
      '#description' => t('If auto-scrolling, pause the carousel when the user hovers the mouse over an item.'),
      '#default_value' => $this->options['autoPause'],
    );
    $form['advanced']['vertical'] = array(
      '#type' => 'checkbox',
      '#title' => t('Vertical'),
      '#description' => t('Specifies whether the carousel appears in horizontal or vertical orientation. Changes the carousel from a left/right style to a up/down style carousel. Defaults to horizontal.'),
      '#default_value' => $this->options['vertical'],
    );
    $form['advanced']['center'] = array(
      '#type' => 'checkbox',
      '#title' => t('Center'),
      '#description' => t('Specifies wether the targeted item should be centered inside the root element. Note: This feature is experimental and may not work with all setups.'),
      '#default_value' => $this->options['center'],
    );
  }
  function validate() {
    $errors = parent::validate();
    if ($this->display->handler
      ->use_pager()) {
      $errors[] = t('The jCarousel style cannot be used with a pager. Disable the "Use pager" option for this display.');
    }
    return $errors;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
jcarousel_style_plugin::options_form function Provide a form to edit options for this plugin. Overrides views_plugin_style::options_form
jcarousel_style_plugin::option_definition function Information about options for all kinds of purposes will be held here. Overrides views_plugin_style::option_definition
jcarousel_style_plugin::validate function Validate that the plugin is correct and can be saved. Overrides views_plugin_style::validate
views_object::$definition public property Handler's definition.
views_object::$options public property Except for displays, options for the object will be held here. 1
views_object::altered_option_definition function Collect this handler's option definition and alter them, ready for use.
views_object::construct public function Views handlers use a special construct function. 4
views_object::export_option public function 1
views_object::export_options public function
views_object::export_option_always public function Always exports the option, regardless of the default value.
views_object::options Deprecated public function Set default options on this object. 1
views_object::set_default_options public function Set default options.
views_object::set_definition public function Let the handler know what its full definition is.
views_object::unpack_options public function Unpack options over our existing defaults, drilling down into arrays so that defaults don't get totally blown away.
views_object::unpack_translatable public function Unpack a single option definition.
views_object::unpack_translatables public function Unpacks each handler to store translatable texts.
views_object::_set_option_defaults public function
views_plugin::$display public property The current used views display.
views_plugin::$plugin_name public property The plugin name of this plugin, for example table or full.
views_plugin::$plugin_type public property The plugin type of this plugin, for example style or query.
views_plugin::$view public property The top object of a view. Overrides views_object::$view 1
views_plugin::additional_theme_functions public function Provide a list of additional theme functions for the theme info page.
views_plugin::options_submit public function Handle any special handling on the validate form. 9
views_plugin::plugin_title public function Return the human readable name of the display.
views_plugin::summary_title public function Returns the summary of the settings in the display. 8
views_plugin::theme_functions public function Provide a full list of possible theme templates used by this style.
views_plugin_style::$row_plugin public property The row plugin, if it's initialized and the style itself supports it.
views_plugin_style::$row_tokens public property Store all available tokens row rows.
views_plugin_style::build_sort public function Called by the view builder to see if this style handler wants to interfere with the sorts. If so it should build; if it returns any non-TRUE value, normal sorting will NOT be added to the query. 1
views_plugin_style::build_sort_post public function Called by the view builder to let the style build a second set of sorts that will come after any other sorts in the view. 1
views_plugin_style::destroy public function Destructor. Overrides views_object::destroy
views_plugin_style::even_empty public function Should the output of the style plugin be rendered even if it's empty. 1
views_plugin_style::get_field public function Get a rendered field.
views_plugin_style::get_field_value public function Get the raw field value.
views_plugin_style::get_row_class public function Return the token replaced row class for the specified row.
views_plugin_style::init public function Initialize a style plugin.
views_plugin_style::options_validate public function Validate the options form. Overrides views_plugin::options_validate
views_plugin_style::pre_render public function Allow the style to do stuff before each row is rendered.
views_plugin_style::query public function Add anything to the query that we might need to. Overrides views_plugin::query 2
views_plugin_style::render public function Render the display in this style. 5
views_plugin_style::render_fields public function Render all of the fields for a given style and store them on the object.
views_plugin_style::render_grouping public function Group records as needed for rendering.
views_plugin_style::render_grouping_sets public function Render the grouping sets.
views_plugin_style::tokenize_value public function Take a value and apply token replacement logic to it.
views_plugin_style::uses_fields public function Return TRUE if this style also uses fields.
views_plugin_style::uses_row_class public function Return TRUE if this style also uses a row plugin.
views_plugin_style::uses_row_plugin public function Return TRUE if this style also uses a row plugin.
views_plugin_style::uses_tokens public function Return TRUE if this style uses tokens.