views_mediatable.module in Views MediaTable 7
This is where all of the logic is kept for determining how to a Views table in a responsive table display.
File
views_mediatable.moduleView source
<?php
/**
* @file
* This is where all of the logic is kept for determining how to a Views table
* in a responsive table display.
*/
/**
* Implements hook_library().
*/
function views_mediatable_library() {
$libraries['mediatable'] = array(
'title' => 'MediaTable',
'website' => 'http://consulenza-web.com/jquery/MediaTable/',
'version' => '',
'js' => array(
libraries_get_path('MediaTable') . '/jquery.mediaTable.js' => array(),
),
'css' => array(
drupal_get_path('module', 'views_mediatable') . '/css/views_mediatable.css' => array(
'type' => 'file',
'media' => 'screen',
),
),
);
return $libraries;
}
/**
* Implements hook_views_api().
*/
function views_mediatable_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'views_mediatable') . '/views',
);
}
/**
* Implements hook_theme().
*/
function views_mediatable_theme() {
return array(
'views_mediatable_table_view' => array(
'arguments' => array(
'form' => NULL,
),
),
'views_mediatable_style_plugin_table' => array(
'render element' => 'form',
'file' => 'views_mediatable.admin.inc',
),
);
}
/**
* Theme preprocess function for views-mediatable-mediatable-view.tpl.php.
*/
function template_preprocess_views_mediatable_view(&$vars) {
template_preprocess_views_view_table($vars);
if (!$vars['rows']) {
return;
}
$view = $vars['view'];
$options = $view->style_plugin->options;
$style_options = $view->style_options;
$handler = $view->style_plugin;
$fields =& $view->field;
$columns = $handler
->sanitize_columns($options['columns'], $fields);
$vars['classes_array'][] = 'responsive-table';
foreach ($columns as $field => $column) {
$column_options = NULL;
if ($field == $column && empty($fields[$field]->options['exclude'])) {
if (isset($style_options['info'][$field])) {
switch ($style_options['info'][$field]['responsive']) {
case 'persist':
if ($vars['header_classes'][$field]) {
$vars['header_classes'][$field] .= ' ';
}
$vars['header_classes'][$field] .= 'persist';
case 'essential':
if ($vars['header_classes'][$field]) {
$vars['header_classes'][$field] .= ' ';
}
$vars['header_classes'][$field] .= 'essential';
break;
case 'optional':
if ($vars['header_classes'][$field]) {
$vars['header_classes'][$field] .= ' ';
}
$vars['header_classes'][$field] .= 'optional';
break;
}
}
else {
if ($vars['header_classes'][$field]) {
$vars['header_classes'][$field] .= ' ';
}
$vars['header_classes'][$field] .= 'persist';
}
}
}
drupal_add_library('views_mediatable', 'mediatable');
drupal_add_js(drupal_get_path('module', 'views_mediatable') . '/js/responsive_table.js');
}
Functions
Name | Description |
---|---|
template_preprocess_views_mediatable_view | Theme preprocess function for views-mediatable-mediatable-view.tpl.php. |
views_mediatable_library | Implements hook_library(). |
views_mediatable_theme | Implements hook_theme(). |
views_mediatable_views_api | Implements hook_views_api(). |