Show or hide league table selector as needed

This commit is contained in:
Brian Miyaji
2015-03-28 12:47:21 +11:00
parent 779a998160
commit 057d17a875
3 changed files with 63 additions and 49 deletions

View File

@@ -557,6 +557,16 @@ jQuery(document).ready(function($){
}); });
$(".sp-date-selector select").trigger("change"); $(".sp-date-selector select").trigger("change");
// Show or hide league table selector
$(".sp-team-selector .sp-team-picker select").change(function() {
console.log( $(this) );
if ( $(this).val() == "table" ) {
$(this).closest(".sp-team-selector").find(".sp-league-table-picker").show();
} else {
$(this).closest(".sp-team-selector").find(".sp-league-table-picker").hide();
}
}).trigger("change");
// Apply color scheme // Apply color scheme
$(".sp-color-option").on("click", function() { $(".sp-color-option").on("click", function() {
colors = $(this).find("label").data("sp-colors").split(","); colors = $(this).find("label").data("sp-colors").split(",");

View File

@@ -63,36 +63,40 @@ class SP_Meta_Box_Calendar_Details {
sp_taxonomy_field( $taxonomy, $post, true ); sp_taxonomy_field( $taxonomy, $post, true );
} }
?> ?>
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p> <div class="sp-team-selector">
<p> <p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
<?php <p class="sp-team-picker">
$args = array( <?php
'show_option_all' => __( 'All', 'sportspress' ), $args = array(
'post_type' => 'sp_team', 'show_option_all' => __( 'All', 'sportspress' ),
'name' => 'sp_team', 'post_type' => 'sp_team',
'selected' => $team_id, 'name' => 'sp_team',
'values' => 'ID' 'selected' => $team_id,
); 'values' => 'ID',
if ( ! sp_dropdown_pages( $args ) ): 'append_options' => array(
sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) ); 'table' => sprintf( __( 'Select %s:', 'sportspress' ), __( 'League Table', 'sportspress' ) ),
endif; ),
?> );
</p> if ( ! sp_dropdown_pages( $args ) ):
<p><strong><?php _e( 'League Table', 'sportspress' ); ?></strong></p> sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) );
<p> endif;
<?php ?>
$args = array( </p>
'show_option_all' => __( 'All', 'sportspress' ), <p class="sp-league-table-picker">
'post_type' => 'sp_table', <?php
'name' => 'sp_table', $args = array(
'selected' => $table_id, 'show_option_all' => __( 'All', 'sportspress' ),
'values' => 'ID' 'post_type' => 'sp_table',
); 'name' => 'sp_table',
if ( ! sp_dropdown_pages( $args ) ): 'selected' => $table_id,
sp_post_adder( 'sp_table', __( 'Add New', 'sportspress' ) ); 'values' => 'ID',
endif; );
?> if ( ! sp_dropdown_pages( $args ) ):
</p> sp_post_adder( 'sp_table', __( 'Add New', 'sportspress' ) );
endif;
?>
</p>
</div>
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p> <p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
<p> <p>
<select name="sp_order"> <select name="sp_order">

View File

@@ -143,25 +143,25 @@ class SP_Calendar extends SP_Custom_Post {
endif; endif;
if ( $team ): if ( $team ):
$args['meta_query'] = array( if ( 'table' !== $team ):
array( $args['meta_query'] = array(
'key' => 'sp_team', array(
'value' => $team, 'key' => 'sp_team',
), 'value' => $team,
); ),
endif; );
elseif ( $table ) :
if ( $table ) : $teams = get_post_meta( $table, 'sp_team' );
$teams = get_post_meta( $table, 'sp_team' ); $teams = array_filter( $teams );
$teams = array_filter( $teams );
$args['meta_query'] = array(
$args['meta_query'] = array( array(
array( 'key' => 'sp_team',
'key' => 'sp_team', 'value' => $teams,
'value' => $teams, 'compare' => 'IN'
'compare' => 'IN' ),
), );
); endif;
endif; endif;
endif; endif;