hopefully completing types features
This commit is contained in:
@@ -16,58 +16,93 @@
|
||||
</script>
|
||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
$( document ).ready(function() {
|
||||
var boattypes = {
|
||||
'1x': '1x (single)',
|
||||
'2x': '2x (double)',
|
||||
'2x+': '2x+ (coxed double)',
|
||||
'2-': '2- (pair)',
|
||||
'2+': '2+ (coxed pair)',
|
||||
'3x+': '3x+ (coxed triple)',
|
||||
'3x-': '3x- (triple)',
|
||||
'4x': '4x (quad)',
|
||||
'4x+': '4x+ (coxed quad)',
|
||||
'4-': '4- (four)',
|
||||
'4+': '4+ (coxed four)',
|
||||
'8+': '8+ (eight)',
|
||||
'8x+': '8x+ (octuple scull)',
|
||||
}
|
||||
|
||||
var ergtypes = {
|
||||
'static': 'Concept2 static',
|
||||
'dynamic': 'Concept2 dynamic',
|
||||
'slides': 'Concept2 slides',
|
||||
'rp3': 'RP3',
|
||||
'waterrower': 'Water Rower',
|
||||
'other': 'Other Indoor Rower',
|
||||
}
|
||||
|
||||
// Get the form fields and hidden div
|
||||
var modality = $("#id_modality");
|
||||
var hidden = $("#id_waterboattype");
|
||||
|
||||
|
||||
// Hide the fields.
|
||||
// Use JS to do this in case the user doesn't have JS
|
||||
// enabled.
|
||||
|
||||
hidden.hide();
|
||||
|
||||
|
||||
|
||||
// Setup an event listener for when the state of the
|
||||
// checkbox changes.
|
||||
modality.change(function() {
|
||||
// Check to see if the checkbox is checked.
|
||||
// If it is, show the fields and populate the input.
|
||||
// If not, hide the fields.
|
||||
var Value = modality.val();
|
||||
if (Value=='water') {
|
||||
// Show the hidden fields.
|
||||
hidden.show();
|
||||
} else {
|
||||
// Make sure that the hidden fields are indeed
|
||||
// hidden.
|
||||
hidden.hide();
|
||||
|
||||
// You may also want to clear the value of the
|
||||
// hidden fields here. Just in case somebody
|
||||
// shows the fields, enters data to them and then
|
||||
// unticks the checkbox.
|
||||
//
|
||||
// This would do the job:
|
||||
//
|
||||
// $("#hidden_field").val("");
|
||||
}
|
||||
$('#id_modality').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'water'
|
||||
|| $(this).val() == 'coastal'
|
||||
|| $(this).val() == 'c-boat'
|
||||
|| $(this).val() == 'churchboat'
|
||||
) {
|
||||
var $el = $('#id_waterboattype');
|
||||
$el.empty();
|
||||
$.each(boattypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
|
||||
}
|
||||
else if (
|
||||
$(this).val() == 'rower'
|
||||
) {
|
||||
var $el = $('#id_waterboattype');
|
||||
$el.empty();
|
||||
$.each(ergtypes, function(key,value) {
|
||||
if ( key == '{{ workout.boattype }}') {
|
||||
$el.append($("<option></option").attr("value", key).attr("selected", "selected").text(value));
|
||||
} else {
|
||||
$el.append($("<option></option").attr("value", key).text(value));
|
||||
}
|
||||
});
|
||||
$el.toggle(true);
|
||||
}
|
||||
else {
|
||||
$('#id_waterboattype').toggle(false);
|
||||
$('#id_waterboattype').val('1x');
|
||||
}
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'slides'
|
||||
) {
|
||||
$('#id_dragfactor').toggle(true);
|
||||
} else {
|
||||
$('#id_dragfactor').toggle(false);
|
||||
$('#id_dragfactor').val('0');
|
||||
}
|
||||
|
||||
});
|
||||
$('#id_modality').change();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
console.log('kill parents')
|
||||
$("#id_killparents").change(function() {
|
||||
if (this.checked) {
|
||||
$("#id_killparentswarning").html("<p><em>Warning: Deleted workouts cannot be recovered</em></p>");
|
||||
console.log('kill parents')
|
||||
$("#id_killparents").change(function() {
|
||||
if (this.checked) {
|
||||
$("#id_killparentswarning").html("<p><em>Warning: Deleted workouts cannot be recovered</em></p>");
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user