346 |
346 |
347 function handleFormValidationResponse(formid, onsuccess, onfailure, result) { |
347 function handleFormValidationResponse(formid, onsuccess, onfailure, result) { |
348 // Success |
348 // Success |
349 if (result[0]) { |
349 if (result[0]) { |
350 if (onsuccess) { |
350 if (onsuccess) { |
351 return onsuccess(result[1], formid); |
351 onsuccess(result[1], formid); |
352 } else { |
352 } else { |
353 document.location.href = result[1]; |
353 document.location.href = result[1]; |
354 return ; |
354 } |
355 } |
355 return; |
356 } |
356 } |
357 unfreezeFormButtons(formid); |
357 unfreezeFormButtons(formid); |
358 // Failures |
358 // Failures |
359 _clearPreviousErrors(formid); |
359 _clearPreviousErrors(formid); |
360 var descr = result[1]; |
360 var descr = result[1]; |
361 // Unknown structure |
361 // Unknown structure |
362 if ( !isArrayLike(descr) || descr.length != 2 ) { |
362 if ( !isArrayLike(descr) || descr.length != 2 ) { |
363 log('got strange error :', descr); |
363 log('got strange error :', descr); |
364 updateMessage(descr); |
364 updateMessage(descr); |
365 return ; |
365 return; |
366 } |
366 } |
367 _displayValidationerrors(formid, descr[0], descr[1]); |
367 _displayValidationerrors(formid, descr[0], descr[1]); |
368 updateMessage(_("please correct errors below")); |
368 updateMessage(_("please correct errors below")); |
369 document.location.hash = '#header'; |
369 document.location.hash = '#header'; |
370 if (onfailure){ |
370 if (onfailure){ |
371 onfailure(formid); |
371 onfailure(formid); |
372 } |
372 } |
373 return false; |
373 return; |
374 } |
374 } |
375 |
375 |
376 |
376 |
377 /* unfreeze form buttons when the validation process is over*/ |
377 /* unfreeze form buttons when the validation process is over*/ |
378 function unfreezeFormButtons(formid) { |
378 function unfreezeFormButtons(formid) { |
420 width: '0px', height: '0px'})); |
420 width: '0px', height: '0px'})); |
421 } |
421 } |
422 }); |
422 }); |
423 } |
423 } |
424 |
424 |
425 $(document).ready(setFormsTarget); |
425 jQuery(document).ready(setFormsTarget); |
426 |
426 |
427 |
427 |
428 /* |
428 /* |
429 * called on traditionnal form submission : the idea is to try |
429 * called on traditionnal form submission : the idea is to try |
430 * to post the form. If the post is successful, `validateForm` redirects |
430 * to post the form. If the post is successful, `validateForm` redirects |