You are here

function _slickgrid_add_files in Slickgrid 6

1 call to _slickgrid_add_files()
theme_slickgrid in ./slickgrid.module
The main theme function for the slickgrid

File

./slickgrid.module, line 573

Code

function _slickgrid_add_files($options, $columns) {
  $path = drupal_get_path('module', 'slickgrid');
  drupal_add_js($path . '/js/slickgrid/lib/jquery-1.4.3.min.js');

  // Add slickgrid dependencies
  drupal_add_js($path . '/js/slickgrid/lib/firebugx.js');
  drupal_add_js($path . '/js/slickgrid/lib/jquery.event.drag-2.0.min.js');

  // Add the slickgrid files
  drupal_add_js($path . '/js/slickgrid/slick.core.js');
  drupal_add_js($path . '/js/slickgrid/slick.dataview.js');
  drupal_add_js($path . '/js/slickgrid/slick.grid.js');
  drupal_add_css($path . '/js/slickgrid/slick.grid.css');

  // Add jQuery UI files
  // Uses the UI files included in slickgrid to ensure compatibility
  drupal_add_js($path . '/js/slickgrid/lib/jquery-ui-1.8.5.custom.min.js');
  drupal_add_css($path . '/js/slickgrid/css/smoothness/jquery-ui-1.8.5.custom.css');

  // Depending on options slected for the view, enable slickgrid plugins
  // Is check box select column enabled?
  drupal_add_js($path . '/js/slickgrid/plugins/slick.checkboxselectcolumn.js');
  drupal_add_js($path . '/js/slickgrid/plugins/slick.rowselectionmodel.js');

  // Depending on options selected, enable controls (pager, show / hide column headers)
  if ($options['pager']) {
    drupal_add_js($path . '/js/slickgrid/controls/slick.pager.js');
    drupal_add_css($path . '/js/slickgrid/controls/slick.pager.css');
  }

  // Can user select which columns to display
  if ($options['select_columns']) {
    drupal_add_js($path . '/js/slickgrid/controls/slick.columnpicker.js');
    drupal_add_css($path . '/js/slickgrid/controls/slick.columnpicker.css');
  }

  // Add groups UI js file - adds buttons to expand / collpase all
  if ($options['grouping_field']) {
    drupal_add_js($path . '/js/slickgrid.groups-ui.js');
  }
  if ($options['collapsible_taxonomy_field']) {
    drupal_add_js($path . '/js/slickgrid.collapsible.js');
  }
  $slickgrid_plugins = slickgrid_get_plugins();

  // Need to add all the files associated with plugins
  // Loop through all the columns
  foreach ($columns as $column) {
    foreach (array_keys(slickgrid_get_plugin_types()) as $plugin_type) {

      // Does this column have this type of plugin defined? And is there as JS file?
      if (isset($column[$plugin_type])) {
        if (isset($slickgrid_plugins[$column[$plugin_type]]['js'])) {
          drupal_add_js($slickgrid_plugins[$column[$plugin_type]]['js']);
        }
        if (isset($slickgrid_plugins[$column[$plugin_type]]['css'])) {
          drupal_add_css($slickgrid_plugins[$column[$plugin_type]]['css']);
        }
      }
    }
  }

  // Add bespoke slickgrid js/css
  drupal_add_js($path . '/js/slickgrid.js');
  drupal_add_css($path . '/css/slickgrid.css');

  // Add beautytips
  beautytips_add_beautytips();

  // ajax_load borks on wysiwyg so load all the profiles on page load to add all the js / css files
  // Get the filter formats
  if (module_exists('wysiwyg')) {
    $filter_formats = filter_formats();
    foreach ($filter_formats as $filter_format) {
      wysiwyg_get_profile($filter_format->format);
    }
  }
}