uc_termsofservice.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @file
  3. * Terms of Service modal frames.
  4. */
  5. (function ($) {
  6. Drupal.behaviors.uc_termsofservice_modalframe = function() {
  7. $('.uc_termsofservice-child:not(.modalframe-tos-processed)').addClass('modalframe-tos-processed').click(function() {
  8. var element = this;
  9. function onSubmitCallbackToS(args, statusMessages){
  10. if (args && args.tos_selected.agreed) {
  11. if (args.tos_selected.agreed == 'agreed') {
  12. $(".form-checkboxes input[id*='tos-agree-popup-agreed']").attr('checked', true);
  13. }
  14. else {
  15. $(".form-checkboxes input[id*='tos-agree-popup-agreed']").attr('checked', false);
  16. }
  17. }
  18. }
  19. // Build modal frame options.
  20. var modalOptions = {
  21. url: $(element).attr('href'),
  22. autoResize: true,
  23. onSubmit: onSubmitCallbackToS
  24. };
  25. // Try to obtain the dialog size from the className of the element.
  26. var regExp = /^.*uc_termsofservice-size\[\s*([0-9]*\s*,\s*[0-9]*)\s*\].*$/;
  27. if (typeof element.className == 'string' && regExp.test(element.className)) {
  28. var size = element.className.replace(regExp, '$1').split(',');
  29. modalOptions.width = parseInt(size[0].replace(/ /g, ''));
  30. modalOptions.height = parseInt(size[1].replace(/ /g, ''));
  31. }
  32. // Open the modal frame dialog.
  33. Drupal.modalFrame.open(modalOptions);
  34. // Prevent default action of the link click event.
  35. return false;
  36. });
  37. };
  38. })(jQuery);