You are here

function theme_slickgrid in Slickgrid 6

Same name and namespace in other branches
  1. 7.2 theme/theme.inc \theme_slickgrid()
  2. 7 theme/theme.inc \theme_slickgrid()

The main theme function for the slickgrid

Parameters

array $options:

array $columns:

array $data:

array $view_name:

1 theme call to theme_slickgrid()
slickgrid_preprocess_views_view_slickgrid in ./slickgrid.module
Preprocessor for views-view-slickgrid.tpl.php Repurpose the views result for slickgrid

File

./slickgrid.module, line 447

Code

function theme_slickgrid($options, $columns, $data, $view) {
  $output = '';

  // Add all the CSS & JS
  _slickgrid_add_files($options, $columns);
  $js = array();
  $js[] = 'var options = ' . drupal_to_js($options) . ';';
  $js[] = 'var data = [];';
  if (count($data)) {
    $js[] = 'data = ' . drupal_to_js($data) . ';';
  }
  $js[] = 'var columns = ' . _slickgrid_drupal_to_js($columns) . ';';
  $js[] = 'var slickgrid;';
  $js[] = '$(function() {';
  $js[] = 'slickgrid = new Slickgrid("#slickgrid", "' . $view->name . '", "' . $view->current_display . '", "' . url(SLICKGRID_CALLBACK_PATH) . '");';
  $js[] = '})';
  drupal_add_js(implode("\n", $js), 'inline');

  // Adjust hieght to allow for scrollbar
  // output a placeholder div for the slickgrid
  $output .= '<div id="slickgrid" style="width:100%;height:' . $options['viewport_height'] . 'px;" class="hideCols hideRows ' . ($options['editable'] ? 'editable' : '') . '"></div>';
  $output .= '<div id="controls">';
  if ($options['pager']) {
    $output .= '<div id="slickgrid-pager"></div>';
  }
  if ($options['undo']) {
    $output .= '<div id="slickgrid-undo" title="Undo"></div>';
  }
  $output .= '<div id="slickgrid-status"></div>';
  $output .= '<div id="slickgrid-loading-bar"></div>';
  $output .= '</div>';
  if ($options['delete_nodes']) {
    $output .= '<div id="slickgrid-delete" style="display:none;position:absolute"><h6>Delete node</h6><p>Are you sure you want to delete this node? This action cannot be undone!</p><p class="buttons"><input type="button" value="Delete" id="slickgrid-delete-button" /><input type="button" value="Cancel" id="slickgrid-cancel-delete" /></p></div>';
  }
  return $output;
}