You are here

function views_quicksand_style_plugin::render in Views Quicksand 7

Render the display in this style.

Overrides views_plugin_style::render

File

./views_quicksand_style_plugin.inc, line 112
Provide an accordion style plugin for Views. This file is autoloaded by views.

Class

views_quicksand_style_plugin
Implementation of views_plugin_style().

Code

function render() {
  $output = parent::render();

  // Add the javascript for quicksand if it exists in the correct place.
  if ($path = libraries_get_path('jquery.quicksand')) {
    if (file_exists($path . '/jquery.quicksand.js')) {
      drupal_add_js($path . '/jquery.quicksand.js');
    }
    else {

      // Otherwise inform the user that the library couldn't be located.
      drupal_set_message('The jQuery Quicksand library is missing under path: "' . $path . '/jquery.quicksand.js"', 'error');
    }
  }
  drupal_add_library('system', 'effects');

  // Scope our javascript to the footer to allow us to access Drupal.settings
  // before document ready has fired.
  $path = drupal_get_path('module', 'views_quicksand');
  drupal_add_js($path . '/views_quicksand.js', array(
    'scope' => 'footer',
  ));

  // add css
  if ($this->options['css'] == true) {
    drupal_add_css($path . '/views_quicksand.css');
  }

  // Preparing the js variables and adding the js to our display.
  $view_settings['adjustHeight'] = $this->options['adjustHeight'];
  $view_settings['element'] = $this->options['element'];
  $view_settings['attribute'] = $this->options['attribute'];
  $view_settings['duration'] = $this->options['duration'];
  $view_settings['easing'] = $this->options['easing'];
  $view_settings['display'] = $this->view->current_display;
  $view_settings['viewname'] = $this->view->name;
  if (isset($this->view->dom_id)) {
    $view_settings['dom_id'] = $this->view->dom_id;
  }
  $view_settings['row_plugin'] = get_class($this->row_plugin);
  $quicksand_id = 'views-quicksand-' . $this->view->name . '-' . $this->view->current_display;
  drupal_add_js(array(
    'views_quicksand' => array(
      $quicksand_id => $view_settings,
    ),
  ), 'setting');
  return $output;
}