@extends('layouts.mobile') @section('page_title') OSAA - Pitch Counts @stop @section('page_sub_title') {{ $info['activity_program']->name }} @stop @section('head') @stop @section('jquery_init') // Handle the pitcher auto-complete option selection $('[data-pitcher-option]').click(function(event) { var option = $(this); var text = option.html(); var list = option.parents('ul'); var input_id = list.attr('data-input'); var input = $(input_id); input.val(text); list.fadeOut(); list.filterable("refresh"); }); // Handle the pitcher text box auto-complete functionality $('[name="pitcher"]').blur(function() { var id = '#' + $(this).attr('id'); var list = $('ul[data-input="' + id + '"]'); list.fadeOut(); list.filterable("refresh"); }) .focus(function() { var id = '#' + $(this).attr('id'); var list = $('ul[data-input="' + id + '"]'); list.fadeIn(); list.filterable("refresh"); }); // Check if the count is above the limit, toggle exception check-box $('[name="count"]').bind('input', function() { var input = $(this); var value = input.val(); var popup = input.parents('div[data-role="popup"]'); var exception = $('[name="exception"]', popup); var limit = $('input[name="under_limit"]', popup); if (value <= {{ $info['pitch_count_limits']['daily_maximum'] }}) { exception.fadeOut(); limit.val(1); } else { exception.fadeIn(); limit.val(0); } }); // Modify check-box to show green label if checked $('[name="is_batter_exception"]').click(function() { var input = $(this); var label = $('label[for="' + input.attr('id') + '"]'); if (input.is(':checked')) { label.addClass('check_box_checked'); } else { label.removeClass('check_box_checked'); } }); // Submit button for adding a new pitch count entry $('button[type="submit"][data-button-action="add_pitch_count"]').click(function() { var button = $(this); var popup = button.parents('div[data-role="popup"]'); // Get the data to add var pitcher = $('input[name="pitcher"]', popup).val(); var count = $('input[name="count"]', popup).val(); // Ensure the pitcher name was provided if (pitcher == "") { alert('You must type in the name of the pitcher.'); $('input[name="pitcher"]', popup).focus(); return; } // Ensure the count was provided if (count == "" || parseInt(count) == NaN || parseInt(count) == 0) { alert('You must type in the number of pitches for this pitcher.'); $('input[name="count"]', popup).focus(); return; } // Was the exception check-box checked? if ($('input[name="is_batter_exception"]', popup).is(':checked')) { var is_batter_exception = 1; } else { var is_batter_exception = 0; } // Show loading status popup.html('

Adding Pitch Count...

Please wait, this may take a while to process...
'); // Gather data var ap_id = popup.attr('data-ap-id'); var record_id = popup.attr('data-record-id'); var schedule_index = popup.attr('data-index'); var date = popup.attr('data-date'); // Compose a data payload var data = { 'ap_id' : ap_id, 'record_id' : record_id, 'schedule_index' : schedule_index, 'date' : date, 'pitcher' : pitcher, 'count' : count, 'is_batter_exception' : is_batter_exception }; // Add the date to the schedule var jqxhr = $.ajax( { type : 'POST', url : '{{ url('/teams/' . $info['activity_program']->id . '/add-pitch-count') }}', data : data, dataType : 'html' }) .done(function (data) { //$('[data-processing]').remove(); location.reload(); }) .fail(function (jqXHR, status, error) { var response = jqXHR.responseText; var errorData = $.parseJSON(response); //console.log(errorData); alert("There was an error adding this pitch count.\n\n" + errorData.error.message + "\n\nThis will be reloaded. Please try again."); location.reload(); }); }); // Submit button for adding a date $('button[type="submit"][data-button-action="add_date"]').click(function() { var button = $(this); var popup = button.parents('div[data-role="popup"]'); // Get the date to add var add_date = $('input', popup).val(); // Ensure the date was provided if (add_date == "") { alert('You must select a date in order to add it to your pitch count schedule.'); $('input', dialog_object).focus(); return; } // Show loading status popup.html('

Adding Date...

Please wait, this may take a while to process...
'); // Gather data var ap_id = popup.attr('data-ap-id'); var record_id = popup.attr('data-record-id'); // Compose a data payload var data = { 'ap_id' : ap_id, 'record_id' : record_id, 'add_date' : add_date }; // Add the date to the schedule var jqxhr = $.ajax( { type : 'POST', url : '{{ url('/teams/' . $info['activity_program']->id . '/add-pitch-count-date') }}', data : data, dataType : 'html' }) .done(function (data) { //$('[data-processing]').remove(); location.reload(); }) .fail(function (jqXHR, status, error) { var response = jqXHR.responseText; var errorData = $.parseJSON(response); //console.log(errorData); alert("There was an error adding this date.\n\n" + errorData.error.message + "\n\nThis will be reloaded. Please try again."); location.reload(); }); }); // Delete pitch count button $('a[data-button-action="delete_pitch_count"]').click(function(event) { var button = $(this); event.preventDefault(); var result = confirm('Are you sure you want to delete this pitch count entry?'); if (!result) { button.blur(); return false; } var popup = button.parents('div[data-role="popup"]'); // Show loading status popup.html('

Deleting Pitch Count...

Please wait, this may take a while to process...
'); // Gather data var ap_id = popup.attr('data-ap-id'); var record_id = popup.attr('data-record-id'); var schedule_index = popup.attr('data-index'); var sub_index = parseInt(popup.attr('data-sub-index')); var date = popup.attr('data-date'); var pitcher = popup.attr('data-pitcher'); // Compose a data payload var data = { 'ap_id' : ap_id, 'record_id' : record_id, 'schedule_index' : schedule_index, 'sub_index' : sub_index, 'date' : date, 'pitcher' : pitcher }; // Remove the date from the schedule var jqxhr = $.ajax( { type : 'POST', url : '{{ url('/teams/' . $info['activity_program']->id . '/remove-pitch-count') }}', data : data, dataType : 'html' }) .done(function (data) { //$('[data-processing]').remove(); location.reload(); }) .fail(function (jqXHR, status, error) { var response = jqXHR.responseText; var errorData = $.parseJSON(response); //console.log(errorData); alert("There was an error adding this pitch count.\n\n" + errorData.error.message + "\n\nThis will be reloaded. Please try again."); location.reload(); }); }); @stop @section('header_button_left') Back @stop @section('left_nav_panel') @parent @stop @section('main_content')
Add Date
Close
Add a Date to the Pitch Count Schedule
Dates are automatically added from your scheduled contests at any level. You can also add another date to your team's baseball pitch count schedule using this form.
@stop