Enable horizontal scrolling in admin data tables on mobile

This commit is contained in:
Brian Miyaji
2014-01-06 20:57:03 +11:00
parent a68190f320
commit b54d5bbd3c
2 changed files with 240 additions and 226 deletions

View File

@@ -91,8 +91,10 @@
#sp_profilediv .wp-editor-container { #sp_profilediv .wp-editor-container {
background-color:#fff; background-color:#fff;
} }
.sp-data-table-container {
overflow: auto;
}
.sp-data-table td { .sp-data-table td {
padding: 4px 7px;
line-height: 2; line-height: 2;
} }
.sp-data-table td:first-child { .sp-data-table td:first-child {

View File

@@ -496,39 +496,41 @@ if ( !function_exists( 'sp_get_var_equations' ) ) {
if ( !function_exists( 'sp_league_table' ) ) { if ( !function_exists( 'sp_league_table' ) ) {
function sp_league_table( $columns = array(), $data = array(), $placeholders = array() ) { function sp_league_table( $columns = array(), $data = array(), $placeholders = array() ) {
?> ?>
<table class="widefat sp-data-table"> <div class="sp-data-table-container">
<thead> <table class="widefat sp-data-table">
<tr> <thead>
<th><?php _e( 'Team', 'sportspress' ); ?></th> <tr>
<?php foreach ( $columns as $label ): ?> <th><?php _e( 'Team', 'sportspress' ); ?></th>
<th><?php echo $label; ?></th> <?php foreach ( $columns as $label ): ?>
<?php endforeach; ?> <th><?php echo $label; ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ( $data as $team_id => $team_stats ):
if ( !$team_id ) continue;
$div = get_term( $team_id, 'sp_season' );
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $team_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $team_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_teams[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
</thead>
<tbody>
<?php <?php
$i++; $i = 0;
endforeach; foreach ( $data as $team_id => $team_stats ):
?> if ( !$team_id ) continue;
</tbody> $div = get_term( $team_id, 'sp_season' );
</table> ?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $team_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $team_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_teams[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php <?php
} }
} }
@@ -536,39 +538,41 @@ if ( !function_exists( 'sp_league_table' ) ) {
if ( !function_exists( 'sp_player_table' ) ) { if ( !function_exists( 'sp_player_table' ) ) {
function sp_player_table( $columns = array(), $data = array(), $placeholders = array() ) { function sp_player_table( $columns = array(), $data = array(), $placeholders = array() ) {
?> ?>
<table class="widefat sp-data-table"> <div class="sp-data-table-container">
<thead> <table class="widefat sp-data-table">
<tr> <thead>
<th><?php _e( 'Player', 'sportspress' ); ?></th> <tr>
<?php foreach ( $columns as $label ): ?> <th><?php _e( 'Player', 'sportspress' ); ?></th>
<th><?php echo $label; ?></th> <?php foreach ( $columns as $label ): ?>
<?php endforeach; ?> <th><?php echo $label; ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ( $data as $player_id => $player_stats ):
if ( !$player_id ) continue;
$div = get_term( $player_id, 'sp_season' );
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $player_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $player_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_players[<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
</thead>
<tbody>
<?php <?php
$i++; $i = 0;
endforeach; foreach ( $data as $player_id => $player_stats ):
?> if ( !$player_id ) continue;
</tbody> $div = get_term( $player_id, 'sp_season' );
</table> ?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $player_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $player_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_players[<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php <?php
} }
} }
@@ -576,47 +580,49 @@ if ( !function_exists( 'sp_player_table' ) ) {
if ( !function_exists( 'sp_team_columns_table' ) ) { if ( !function_exists( 'sp_team_columns_table' ) ) {
function sp_team_columns_table( $columns = array(), $data = array(), $placeholders = array() ) { function sp_team_columns_table( $columns = array(), $data = array(), $placeholders = array() ) {
?> ?>
<table class="widefat sp-data-table"> <div class="sp-data-table-container">
<thead> <table class="widefat sp-data-table">
<tr> <thead>
<th><?php _e( 'Season', 'sportspress' ); ?></th> <tr>
<?php foreach ( $columns as $label ): ?> <th><?php _e( 'Season', 'sportspress' ); ?></th>
<th><?php echo $label; ?></th> <?php foreach ( $columns as $label ): ?>
<?php endforeach; ?> <th><?php echo $label; ?></th>
</tr> <?php endforeach; ?>
</thead> </tr>
<tbody> </thead>
<?php <tbody>
$i = 0;
if ( empty( $data ) ):
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Season', 'sportspress' ) ); ?></strong></td>
</tr>
<?php <?php
else: $i = 0;
foreach ( $data as $div_id => $div_stats ): if ( empty( $data ) ):
if ( !$div_id ) continue;
$div = get_term( $div_id, 'sp_season' );
?> ?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>"> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td> <td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Season', 'sportspress' ) ); ?></strong></td>
<?php echo $div->name; ?> </tr>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $div_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_columns[<?php echo $div_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?>
</tr>
<?php <?php
$i++; else:
endforeach; foreach ( $data as $div_id => $div_stats ):
endif; if ( !$div_id ) continue;
?> $div = get_term( $div_id, 'sp_season' );
</tbody> ?>
</table> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo $div->name; ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $div_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 );
?>
<td><input type="text" name="sp_columns[<?php echo $div_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
<?php endforeach; ?>
</tr>
<?php
$i++;
endforeach;
endif;
?>
</tbody>
</table>
</div>
<?php <?php
} }
} }
@@ -624,47 +630,49 @@ if ( !function_exists( 'sp_team_columns_table' ) ) {
if ( !function_exists( 'sp_player_statistics_table' ) ) { if ( !function_exists( 'sp_player_statistics_table' ) ) {
function sp_player_statistics_table( $columns = array(), $data = array(), $placeholders = array() ) { function sp_player_statistics_table( $columns = array(), $data = array(), $placeholders = array() ) {
?> ?>
<table class="widefat sp-data-table"> <div class="sp-data-table-container">
<thead> <table class="widefat sp-data-table">
<tr> <thead>
<th><?php _e( 'Season', 'sportspress' ); ?></th> <tr>
<?php foreach ( $columns as $label ): ?> <th><?php _e( 'Season', 'sportspress' ); ?></th>
<th><?php echo $label; ?></th> <?php foreach ( $columns as $label ): ?>
<?php endforeach; ?> <th><?php echo $label; ?></th>
</tr> <?php endforeach; ?>
</thead> </tr>
<tbody> </thead>
<?php <tbody>
$i = 0; <?php
foreach ( $data as $team_id => $team_stats ): $i = 0;
if ( empty( $team_stats ) ): foreach ( $data as $team_id => $team_stats ):
?> if ( empty( $team_stats ) ):
<td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></strong></td> ?>
<?php <td><strong><?php printf( __( 'Select %s', 'sportspress' ), __( 'Team', 'sportspress' ) ); ?></strong></td>
continue; <?php
endif; continue;
foreach ( $team_stats as $div_id => $div_stats ): endif;
if ( !$div_id ) continue; foreach ( $team_stats as $div_id => $div_stats ):
$div = get_term( $div_id, 'sp_season' ); if ( !$div_id ) continue;
?> $div = get_term( $div_id, 'sp_season' );
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>"> ?>
<td> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<?php echo $div->name; ?> <td>
</td> <?php echo $div->name; ?>
<?php foreach( $columns as $column => $label ): </td>
$value = sp_array_value( $div_stats, $column, '' ); <?php foreach( $columns as $column => $label ):
$placeholder = sp_array_value( sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $div_id, array() ), $column, 0 ); $value = sp_array_value( $div_stats, $column, '' );
?> $placeholder = sp_array_value( sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $div_id, array() ), $column, 0 );
<td><input type="text" name="sp_statistics[<?php echo $team_id; ?>][<?php echo $div_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td> ?>
<?php endforeach; ?> <td><input type="text" name="sp_statistics[<?php echo $team_id; ?>][<?php echo $div_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
</tr> <?php endforeach; ?>
<?php </tr>
$i++; <?php
$i++;
endforeach;
endforeach; endforeach;
endforeach; ?>
?> </tbody>
</tbody> </table>
</table> </div>
<?php <?php
} }
} }
@@ -672,53 +680,55 @@ if ( !function_exists( 'sp_player_statistics_table' ) ) {
if ( !function_exists( 'sp_event_results_table' ) ) { if ( !function_exists( 'sp_event_results_table' ) ) {
function sp_event_results_table( $columns = array(), $data = array() ) { function sp_event_results_table( $columns = array(), $data = array() ) {
?> ?>
<table class="widefat sp-data-table"> <div class="sp-data-table-container">
<thead> <table class="widefat sp-data-table">
<tr> <thead>
<th><?php _e( 'Team', 'sportspress' ); ?></th> <tr>
<?php foreach ( $columns as $label ): ?> <th><?php _e( 'Team', 'sportspress' ); ?></th>
<th><?php echo $label; ?></th> <?php foreach ( $columns as $label ): ?>
<?php endforeach; ?> <th><?php echo $label; ?></th>
<th><?php _e( 'Outcome', 'sportspress' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ( $data as $team_id => $team_results ):
if ( !$team_id ) continue;
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $team_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $team_results, $column, '' );
?>
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" /></td>
<?php endforeach; ?> <?php endforeach; ?>
<td> <th><?php _e( 'Outcome', 'sportspress' ); ?></th>
<?php
$value = sp_array_value( $team_results, 'outcome', '' );
$args = array(
'post_type' => 'sp_outcome',
'name' => 'sp_results[' . $team_id . '][outcome]',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
'option_none_value' => 0,
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'selected' => $value
);
sp_dropdown_pages( $args );
?>
</td>
</tr> </tr>
</thead>
<tbody>
<?php <?php
$i++; $i = 0;
endforeach; foreach ( $data as $team_id => $team_results ):
?> if ( !$team_id ) continue;
</tbody> ?>
</table> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $team_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $team_results, $column, '' );
?>
<td><input type="text" name="sp_results[<?php echo $team_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" /></td>
<?php endforeach; ?>
<td>
<?php
$value = sp_array_value( $team_results, 'outcome', '' );
$args = array(
'post_type' => 'sp_outcome',
'name' => 'sp_results[' . $team_id . '][outcome]',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
'option_none_value' => 0,
'sort_order' => 'ASC',
'sort_column' => 'menu_order',
'selected' => $value
);
sp_dropdown_pages( $args );
?>
</td>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php <?php
} }
} }
@@ -773,55 +783,57 @@ if ( !function_exists( 'sp_event_player_sub_selector' ) ) {
if ( !function_exists( 'sp_event_players_table' ) ) { if ( !function_exists( 'sp_event_players_table' ) ) {
function sp_event_players_table( $columns = array(), $data = array(), $team_id ) { function sp_event_players_table( $columns = array(), $data = array(), $team_id ) {
?> ?>
<table class="widefat sp-data-table"> <div class="sp-data-table-container">
<thead> <table class="widefat sp-data-table">
<tr> <thead>
<th><?php _e( 'Player', 'sportspress' ); ?></th> <tr>
<?php foreach ( $columns as $label ): ?> <th><?php _e( 'Player', 'sportspress' ); ?></th>
<th><?php echo $label; ?></th> <?php foreach ( $columns as $label ): ?>
<?php endforeach; ?> <th><?php echo $label; ?></th>
<th><?php _e( 'Status', 'sportspress' ); ?></th> <?php endforeach; ?>
</tr> <th><?php _e( 'Status', 'sportspress' ); ?></th>
</thead> </tr>
<tbody> </thead>
<?php <tbody>
$i = 0; <?php
foreach ( $data as $player_id => $player_statistics ): $i = 0;
if ( !$player_id ) continue; foreach ( $data as $player_id => $player_statistics ):
if ( !$player_id ) continue;
?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td>
<?php echo get_the_title( $player_id ); ?>
</td>
<?php foreach( $columns as $column => $label ):
$value = sp_array_value( $player_statistics, $column, '' );
?>
<td>
<input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" />
</td>
<?php endforeach; ?>
<td class="sp-status-selector">
<?php echo sp_event_player_status_selector( $team_id, $player_id, sp_array_value( $player_statistics, 'status', null ) ); ?>
<?php echo sp_event_player_sub_selector( $team_id, $player_id, sp_array_value( $player_statistics, 'sub', null ), $data ); ?>
</td>
</tr>
<?php
$i++;
endforeach;
?> ?>
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>"> <tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td> <td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
<?php echo get_the_title( $player_id ); ?>
</td>
<?php foreach( $columns as $column => $label ): <?php foreach( $columns as $column => $label ):
$player_id = 0;
$player_statistics = sp_array_value( $data, 0, array() );
$value = sp_array_value( $player_statistics, $column, '' ); $value = sp_array_value( $player_statistics, $column, '' );
?> ?>
<td> <td><input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" /></td>
<input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" />
</td>
<?php endforeach; ?> <?php endforeach; ?>
<td class="sp-status-selector"> <td>&nbsp;</td>
<?php echo sp_event_player_status_selector( $team_id, $player_id, sp_array_value( $player_statistics, 'status', null ) ); ?>
<?php echo sp_event_player_sub_selector( $team_id, $player_id, sp_array_value( $player_statistics, 'sub', null ), $data ); ?>
</td>
</tr> </tr>
<?php </tbody>
$i++; </table>
endforeach; </div>
?>
<tr class="sp-row sp-total<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td><strong><?php _e( 'Total', 'sportspress' ); ?></strong></td>
<?php foreach( $columns as $column => $label ):
$player_id = 0;
$player_statistics = sp_array_value( $data, 0, array() );
$value = sp_array_value( $player_statistics, $column, '' );
?>
<td><input type="text" name="sp_players[<?php echo $team_id; ?>][<?php echo $player_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="0" /></td>
<?php endforeach; ?>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<?php <?php
} }
} }