Small JS improvements

This commit is contained in:
Raphael Michel
2017-07-26 13:41:53 +02:00
parent 4293ec3805
commit 9a18f2b553

View File

@@ -1,30 +1,29 @@
$(document).ready(function() { $(document).ready(function () {
hideDeselected(); hideDeselected(false);
});
function hideDeselected() { function hideDeselected(animate) {
var v = $("input[name='quota_option']:checked").val(); var v = $("input[name='quota_option']:checked").val(),
fn = animate ? 'slideDown' : 'show';
if (v === "existing") { if (v === "existing") {
hideAll(); hideAll(animate);
$("#existing-quota-group").children().slideDown(); $("#existing-quota-group").children()[fn]();
} else if (v === "new") { } else if (v === "new") {
hideAll(); hideAll(animate);
$("#new-quota-group").children().slideDown(); $("#new-quota-group").children()[fn]();
} else { } else {
hideAll(); hideAll(animate);
}
} }
};
function hideAll() { function hideAll(animate) {
$("#new-quota-group").children().slideUp(); var fn = animate ? 'slideUp' : 'hide';
$("#existing-quota-group").children().slideUp(); $("#new-quota-group").children()[fn]();
}; $("#existing-quota-group").children()[fn]();
}
$(function () {
$("input[name='quota_option']").on('change', $("input[name='quota_option']").on('change',
function() { function () {
hideDeselected(); hideDeselected(true);
} }
); );
}); });