Lucas Gass
941b5aaecc
This patch adds the checkEnter function to the OPAC global.js and then applies it to the SCO login page. TO TEST: 1. Go to SCO login and try entering something in the "Login:" input amd "Password:" input. 2. Pressing enter while in either will automatically submit the form. 3. Apply patch. 4. Type something into the Login: field and press enter, the form should NOT submit. 5. Type something into the Password: field and pess enter, this SHOULD submit the form. 6. Change the syspref SelfCheckoutByLogin to 'Cardnumber' 7. Type something into the Please enter your card number: field, the form should submit. Signed-off-by: Donnab <donna@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
115 lines
4.5 KiB
JavaScript
115 lines
4.5 KiB
JavaScript
(function( w ){
|
|
// if the class is already set, the font has already been loaded
|
|
if( w.document.documentElement.className.indexOf( "fonts-loaded" ) > -1 ){
|
|
return;
|
|
}
|
|
var PrimaryFont = new w.FontFaceObserver( "NotoSans", {
|
|
weight: 400
|
|
});
|
|
|
|
PrimaryFont.load(null, 5000).then(function(){
|
|
w.document.documentElement.className += " fonts-loaded";
|
|
}, function(){
|
|
console.log("Failed");
|
|
});
|
|
}( this ));
|
|
|
|
// http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855
|
|
String.prototype.format = function() { return formatstr(this, arguments) }
|
|
function formatstr(str, col) {
|
|
col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1);
|
|
var idx = 0;
|
|
return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) {
|
|
if (m == "%%") { return "%"; }
|
|
if (m == "%s") { return col[idx++]; }
|
|
return col[n];
|
|
});
|
|
};
|
|
|
|
function confirmDelete(message) {
|
|
return (confirm(message) ? true : false);
|
|
}
|
|
|
|
function Dopop(link) {
|
|
newin=window.open(link,'popup','width=500,height=400,toolbar=false,scrollbars=yes,resizeable=yes');
|
|
}
|
|
|
|
jQuery.fn.preventDoubleFormSubmit = function() {
|
|
jQuery(this).submit(function() {
|
|
if (this.beenSubmitted)
|
|
return false;
|
|
else
|
|
this.beenSubmitted = true;
|
|
});
|
|
};
|
|
|
|
function prefixOf (s, tok) {
|
|
var index = s.indexOf(tok);
|
|
return s.substring(0, index);
|
|
}
|
|
function suffixOf (s, tok) {
|
|
var index = s.indexOf(tok);
|
|
return s.substring(index + 1);
|
|
}
|
|
|
|
$("body").on("keypress", ".noEnterSubmit", function(e){
|
|
return checkEnter(e);
|
|
});
|
|
|
|
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
|
|
function checkEnter(e){ //e is event object passed from function invocation
|
|
var characterCode; // literal character code will be stored in this variable
|
|
if(e && e.which){ //if which property of event object is supported (NN4)
|
|
characterCode = e.which; //character code is contained in NN4's which property
|
|
} else {
|
|
characterCode = e.keyCode; //character code is contained in IE's keyCode property
|
|
}
|
|
if( characterCode == 13 //if generated character code is equal to ascii 13 (if enter key)
|
|
&& e.target.nodeName == "INPUT"
|
|
&& e.target.type != "submit" // Allow enter to submit using the submit button
|
|
){
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Adapted from https://gist.github.com/jnormore/7418776
|
|
function confirmModal(message, title, yes_label, no_label, callback) {
|
|
$("#bootstrap-confirm-box-modal").data('confirm-yes', false);
|
|
if($("#bootstrap-confirm-box-modal").length == 0) {
|
|
$("body").append('<div id="bootstrap-confirm-box-modal" class="modal">\
|
|
<div class="modal-dialog">\
|
|
<div class="modal-content">\
|
|
<div class="modal-header" style="min-height:40px;">\
|
|
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>\
|
|
<h4 class="modal-title"></h4>\
|
|
</div>\
|
|
<div class="modal-body"><p></p></div>\
|
|
<div class="modal-footer">\
|
|
<a href="#" id="bootstrap-confirm-box-modal-submit" class="btn btn-danger"><i class="fa fa-check" aria-hidden="true"></i></a>\
|
|
<a href="#" id="bootstrap-confirm-box-modal-cancel" data-dismiss="modal" class="btn btn-default"><i class="fa fa-remove" aria-hidden="true"></i></a>\
|
|
</div>\
|
|
</div>\
|
|
</div>\
|
|
</div>');
|
|
$("#bootstrap-confirm-box-modal-submit").on('click', function () {
|
|
$("#bootstrap-confirm-box-modal").data('confirm-yes', true);
|
|
$("#bootstrap-confirm-box-modal").modal('hide');
|
|
return false;
|
|
});
|
|
$("#bootstrap-confirm-box-modal").on('hide.bs.modal', function () {
|
|
if(callback) callback($("#bootstrap-confirm-box-modal").data('confirm-yes'));
|
|
});
|
|
}
|
|
|
|
$("#bootstrap-confirm-box-modal .modal-header h4").text( title || "" );
|
|
if( message && message != "" ){
|
|
$("#bootstrap-confirm-box-modal .modal-body").html( message || "" );
|
|
} else {
|
|
$("#bootstrap-confirm-box-modal .modal-body").remove();
|
|
}
|
|
$("#bootstrap-confirm-box-modal-submit").text( yes_label || 'Confirm' );
|
|
$("#bootstrap-confirm-box-modal-cancel").text( no_label || 'Cancel' );
|
|
$("#bootstrap-confirm-box-modal").modal('show');
|
|
}
|