to js source files, via js blob.
-->
<script>
+ // Add a boost-style format function to JavaScript string.
+ // Implementation stolen from StackOverflow:
+ // https://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format
+ String.prototype.format = function() {
+ var args = arguments;
+ return this.replace(/{(\d+)}/g, function(match, number) {
+ return typeof args[number] != 'undefined'
+ ? args[number]
+ : match;
+ });
+ };
+
var eg_opac_i18n = {};
eg_opac_i18n.EG_MISSING_REQUIRED_INPUT = "[% l('Please fill out all required fields') %]";
+ // For multiple holds placement confirmation dialog. {0} is replaced by number of copies requested.
+ eg_opac_i18n.EG_MULTIHOLD_MESSAGE = "[% l('Do you really want to place {0} holds for this title?') %]";
</script>
return { isValid: isFormOK, culpritNames : culprits };
}
+function confirmMultipleHolds() {
+ var result = true;
+ var numSelect = document.getElementById("num_copies");
+ if (numSelect) {
+ var num = parseInt(numSelect.value);
+ if (num > 1) {
+ result = window.confirm(eg_opac_i18n.EG_MULTIHOLD_MESSAGE.format(num));
+ }
+ }
+ return result;
+}
+
function validateHoldForm() {
var res = validateMethodSelections(document.getElementsByClassName("hold-alert-method"));
- if (res.isValid)
- {
- return true;
+ if (res.isValid) {
+ return confirmMultipleHolds();
} else {
alert(eg_opac_i18n.EG_MISSING_REQUIRED_INPUT);
res.culpritNames.forEach(function(n){