From f42ee4ead95969b333cab07496dfc813db2da7fd Mon Sep 17 00:00:00 2001
From: Brian Miyaji
Date: Fri, 9 Dec 2016 15:12:07 +1100
Subject: [PATCH] Add chronological streak format to league table column
equation generator
---
assets/css/sportspress.css | 18 +++
assets/js/admin/colorpicker.js | 26 +++++
includes/admin/class-sp-admin-assets.php | 7 ++
.../meta-boxes/class-sp-meta-box-equation.php | 2 +-
.../class-sp-meta-box-outcome-details.php | 11 ++
includes/class-sp-league-table.php | 108 +++++++++++++++---
includes/sp-core-functions.php | 5 +
modules/sportspress-league-tables.php | 13 +++
8 files changed, 172 insertions(+), 18 deletions(-)
create mode 100644 assets/js/admin/colorpicker.js
diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css
index 5f9747b5..8e015da7 100644
--- a/assets/css/sportspress.css
+++ b/assets/css/sportspress.css
@@ -417,6 +417,24 @@
font-size: 36px;
}
+/* Event Form */
+.sp-form-events {
+ text-align: left;
+}
+
+.sp-form-event-link {
+ display: inline-block;
+ text-align: center;
+ width: 1.5em;
+ margin: 0 0 0.25em;
+ color: #fff;
+ font-weight: normal;
+}
+
+.sp-form-event-link:hover {
+ color: #fff;
+}
+
/* Countdowns */
.sp-template-countdown .event-name {
clear: both;
diff --git a/assets/js/admin/colorpicker.js b/assets/js/admin/colorpicker.js
new file mode 100644
index 00000000..95aaa618
--- /dev/null
+++ b/assets/js/admin/colorpicker.js
@@ -0,0 +1,26 @@
+jQuery(document).ready(function($){
+
+ // Color picker
+ $('.colorpick').iris( {
+ change: function(event, ui){
+ $(this).css( { backgroundColor: ui.color.toString() } );
+ },
+ hide: true,
+ border: true
+ } ).each( function() {
+ $(this).css( { backgroundColor: $(this).val() } );
+ })
+ .click(function(){
+ $('.iris-picker').hide();
+ $(this).closest('.sp-color-box, td').find('.iris-picker').show();
+ });
+
+ $('body').click(function() {
+ $('.iris-picker').hide();
+ });
+
+ $('.sp-color-box, .colorpick').click(function(event){
+ event.stopPropagation();
+ });
+
+});
\ No newline at end of file
diff --git a/includes/admin/class-sp-admin-assets.php b/includes/admin/class-sp-admin-assets.php
index b758fdfb..876a8520 100755
--- a/includes/admin/class-sp-admin-assets.php
+++ b/includes/admin/class-sp-admin-assets.php
@@ -94,6 +94,8 @@ class SP_Admin_Assets {
wp_register_script( 'sportspress-admin-equationbuilder', SP()->plugin_url() . '/assets/js/admin/equationbuilder.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable' ), SP_VERSION, true );
+ wp_register_script( 'sportspress-admin-colorpicker', SP()->plugin_url() . '/assets/js/admin/colorpicker.js', array( 'jquery', 'wp-color-picker', 'iris' ), SP_VERSION, true );
+
wp_register_script( 'sportspress-admin-widgets', SP()->plugin_url() . '/assets/js/admin/widgets.js', array( 'jquery' ), SP_VERSION, true );
wp_register_script( 'sportspress-admin-quickeditor', SP()->plugin_url() . '/assets/js/admin/quickeditor.js', array( 'jquery' ), SP_VERSION, true );
@@ -137,6 +139,11 @@ class SP_Admin_Assets {
wp_enqueue_script( 'sportspress-admin-locationpicker' );
}
+ // Edit color
+ if ( in_array( $screen->id, array( 'sp_outcome' ) ) ) {
+ wp_enqueue_script( 'sportspress-admin-colorpicker' );
+ }
+
// Edit equation
if ( in_array( $screen->id, array( 'sp_result', 'sp_performance', 'sp_column', 'sp_statistic' ) ) ) {
wp_enqueue_script( 'sportspress-admin-equationbuilder' );
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
index 30f9b43e..1e2bbd73 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php
@@ -43,7 +43,7 @@ class SP_Meta_Box_Equation {
$options[ 'Outcomes' ] = self::optgroup( 'sp_outcome' );
break;
case 'preset':
- $options[ 'Presets' ] = array( '$gamesback' => __( 'Games Back', 'sportspress' ), '$homerecord' => __( 'Home Record', 'sportspress' ), '$awayrecord' => __( 'Away Record', 'sportspress' ), '$streak' => __( 'Streak', 'sportspress' ), '$last5' => __( 'Last 5', 'sportspress' ), '$last10' => __( 'Last 10', 'sportspress' ) );
+ $options[ 'Presets' ] = array( '$gamesback' => __( 'Games Back', 'sportspress' ), '$homerecord' => __( 'Home Record', 'sportspress' ), '$awayrecord' => __( 'Away Record', 'sportspress' ), '$streak' => __( 'Streak', 'sportspress' ), '$form' => __( 'Form', 'sportspress' ), '$last5' => __( 'Last 5', 'sportspress' ), '$last10' => __( 'Last 10', 'sportspress' ) );
break;
case 'subset':
$options[ 'Subsets' ] = array( '_home' => '@' . __( 'Home', 'sportspress' ), '_away' => '@' . __( 'Away', 'sportspress' ), '_venue' => '@' . __( 'Venue', 'sportspress' ) );
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php
index 4e2b07b6..9f9c30ff 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-outcome-details.php
@@ -30,10 +30,13 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
$readonly = false;
}
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
+ $color = get_post_meta( $post->ID, 'sp_color', true );
$condition = get_post_meta( $post->ID, 'sp_condition', true );
$main_result = get_option( 'sportspress_primary_result', null );
$result = get_page_by_path( $main_result, ARRAY_A, 'sp_result' );
$label = sp_array_value( $result, 'post_title', __( 'Primary', 'sportspress' ) );
+
+ if ( '' === $color ) $color = '#888888';
?>
@@ -44,6 +47,13 @@ class SP_Meta_Box_Outcome_Details extends SP_Meta_Box_Config {
+
+
+
+