$(document).ready(function () {
//function GetRecordForUpdate(controlClicked) {
// $('#btnUpdateUserRoleRecord').css('visibility', 'hidden');
// var containerDiv = controlClicked.closest(".row");
// $('#modalUserRoleAdministration').modal();
// FindInputsToTraverse();
//}
//Added for testing:
$("#openModal").click(function () {
$("#modalUserRoleAdministration").modal();
});
function StatusHasChanged(statusDropdown) {
var RoleStatus = statusDropdown.val();
var RoleStatusOriginal = $('#RoleStatusOriginal').val();
var JustificationOriginal = $('#JustificationOriginal').val();
if (RoleStatus == RoleStatusOriginal) { //if role hasn't changed
$('#Justification').val(JustificationOriginal);
$('#Justification').attr("readonly", true);
$('#btnUpdateUserRoleRecord').css('visibility', 'hidden');
FindInputsToTraverse();
}
else if (RoleStatus != RoleStatusOriginal) { //if role has changed
$('#Justification').attr("readonly", false);
$('#btnUpdateUserRoleRecord').css('visibility', 'visible');
FindInputsToTraverse();
}
//Statuses of "Requested" should not be allowed to have justification changed or saved. This helps prevent a valid status being changed to "Requested".
if (RoleStatus == "Requested") { //if role is 'requested'
$('#Justification').attr("readonly", true);
$('#btnUpdateUserRoleRecord').css('visibility', 'hidden');
FindInputsToTraverse();
}
}
function FindInputsToTraverse() {
var inputs = $('.modal-content .form-group > input.form-control, .modal-content button').not("[style='visibility: hidden;']");
/*redirect last tab to first input*/ //EVERYTHING WORKS, except this function. Bottom one, not top. This top sucks.
lastInput.on('keydown', function (e) {
if ((e.which === 9 && !e.shiftKey)) { //This skips the save button when it is available.
e.preventDefault();
firstInput.focus();
}
});
/*redirect first shift+tab to last input*/ //This works 100%
firstInput.on('keydown', function (e) {
if (e.which === 9) {
if (e.shiftKey) {
e.preventDefault();
lastInput.focus();
}
}
});
}
});