1 function _(s) { return s; } // dummy function for gettext
3 // http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855
4 String.prototype.format = function() { return formatstr(this, arguments); };
5 function formatstr(str, col) {
6 col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1);
8 return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) {
9 if (m == "%%") { return "%"; }
10 if (m == "%s") { return col[idx++]; }
15 jQuery.validator.addMethod( "category_code_check", function(value,element){
16 var patt = /^[A-Za-z0-9]{0,10}$/g;
17 if (patt.test(element.value)) {
22 }, MSG_LETTERS_NUMBERS_ONLY
25 jQuery.validator.addMethod( "enrollment_period", function(){
26 enrolmentperiod = $("#enrolmentperiod").val();
27 enrolmentperioddate = $("#enrolmentperioddate").val();
28 if (( $("#enrolmentperiod").val() === "" && $("#enrolmentperioddate").val() === "") || ($("#enrolmentperiod").val() !== "" && $("#enrolmentperioddate").val() !== "")) {
33 }, MSG_ONLY_ONE_ENROLLMENTPERIOD
36 jQuery.validator.addMethod( "password_match", function(value,element){
37 var MSG_PASSWORD_MISMATCH = ( MSG_PASSWORD_MISMATCH );
38 var password = document.getElementById('password').value;
39 var confirmpassword = document.getElementById('password2').value;
41 if ( password != confirmpassword ){
47 }, MSG_PASSWORD_MISMATCH
51 var x=f.value.toUpperCase();
56 $(document).ready(function() {
57 if ($("#branches option:selected").length < 1) {
58 $("#branches option:first").attr("selected", "selected");
60 $("#categorycode").on("blur",function(){
64 $("#enrolmentperioddate").flatpickr({
65 /* Default Flatpickr configuration uses Font Awesome icons for arrows. Onboarding doesn't include Font Awesome, so we redefine these arrows with some SVG icons */
66 nextArrow: '<svg width="17" height="17" viewBox="0 0 4.498 4.498" xmlns="http://www.w3.org/2000/svg"><path d="M3.761 2.491c.158.17.47.12.566-.09.085-.158.02-.356-.116-.461L2.562.292C2.445.17 2.3.282 2.217.382c-.087.102-.255.193-.195.35.107.149.254.265.378.399l1.361 1.36zm.496.017c.17-.157.12-.47-.091-.566-.158-.085-.355-.02-.46.117L2.057 3.707c-.12.118-.01.263.091.345.101.087.193.255.35.195.148-.106.264-.254.398-.378l1.36-1.36zm-.746.095c.206.006.457-.124.462-.353-.005-.23-.256-.36-.462-.354-1.054 0-2.109-.002-3.163 0-.174-.003-.234.166-.212.308.01.128-.043.3.104.369.157.056.33.02.493.03h2.778z"/></svg>',
67 prevArrow: '<svg width="17" height="17" viewBox="0 0 4.498 4.498" xmlns="http://www.w3.org/2000/svg"><path d="M.737 2.008c-.158-.17-.47-.12-.566.09-.085.158-.02.356.116.461l1.649 1.648c.117.121.263.01.345-.09.087-.102.255-.193.195-.35-.107-.149-.254-.265-.378-.399L.737 2.008zM.241 1.99c-.17.157-.12.47.091.566.158.085.355.02.46-.117L2.441.792C2.56.674 2.45.53 2.35.447 2.249.36 2.157.192 2 .252c-.148.106-.264.254-.398.378L.242 1.99zm.746-.095C.781 1.89.53 2.02.525 2.249c.005.23.256.36.462.354 1.054 0 2.109.002 3.163 0 .174.003.234-.166.212-.308-.01-.128.043-.3-.104-.369-.157-.056-.33-.02-.493-.03H.987z"/></svg>',
68 minDate: new Date().fp_incr(1),
69 onReady: function( selectedDates, dateStr, instance ){
71 /* Add a wrapper element so that we can prevent the clear button from wrapping */
72 .wrap("<span class='flatpickr_wrapper'></span>")
75 .addClass("clear_date")
76 .on("click", function(e){
80 .attr("aria-hidden", true)
83 }); // Require that "until date" be in the future
85 $("#category_form").validate({
89 category_code_check: true
95 required: function(element){
96 return $("#enrolmentperioddate").val() === "";
99 enrollment_period: true,
101 enrolmentperioddate: {
102 required: function(element){
103 return $("#enrolmentperiod").val() === "";
105 enrollment_period: true,
106 // is_valid_date ($(#"enrolementperioddate").val());
108 dateofbirthrequired: {
126 required: MSG_ONE_ENROLLMENTPERIOD
128 enrolmentperioddate: {
129 required: MSG_ONE_ENROLLMENTPERIOD
134 $("#createpatron").validate({
147 password_strong: true,
148 password_no_spaces: true
157 required: MSG_PASSWORD_MISMATCH
163 $("#createitemform").validate();
164 $("#createcirculationrule").validate();