register-complete.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. (function (Misago) {
  2. 'use strict';
  3. var persistent = function(el, isInit, context) {
  4. context.retain = true;
  5. };
  6. var refresh = function() {
  7. document.location.reload();
  8. };
  9. var registerComplete = {
  10. controller: function(message, _) {
  11. if (message.activation === 'active') {
  12. _.runloop.runOnce(
  13. refresh, 'refresh-after-registration', 10000);
  14. }
  15. },
  16. view: function(ctrl, message, _) {
  17. var messageHtml = null;
  18. if (message.activation === 'active') {
  19. messageHtml = this.active(message);
  20. } else {
  21. messageHtml = this.inactive(message);
  22. }
  23. return m('.modal-dialog.modal-message.modal-register[role="document"]',
  24. {config: persistent},
  25. m('.modal-content', [
  26. _.component('modal:header', gettext('Registration complete')),
  27. m('.modal-body',
  28. messageHtml
  29. )
  30. ])
  31. );
  32. },
  33. active: function(message) {
  34. var lead = gettext("%(username)s, your account has been created and you were signed in.");
  35. return [
  36. m('.message-icon',
  37. m('span.material-icon', 'check')
  38. ),
  39. m('.message-body', [
  40. m('p.lead',
  41. interpolate(lead, {'username': message.username}, true)
  42. ),
  43. m('p',
  44. gettext('The page will refresh automatically in 10 seconds.')
  45. ),
  46. m('p',
  47. m('button[type="button"].btn.btn-default', {onclick: refresh},
  48. gettext('Refresh page')
  49. )
  50. )
  51. ])
  52. ];
  53. },
  54. inactive: function(message) {
  55. var lead = null;
  56. var help = null;
  57. if (message.activation === 'user') {
  58. lead = gettext("%(username)s, your account has been created but you need to activate it before you will be able to sign in.");
  59. help = gettext("We have sent an e-mail to %(email)s with link that you have to click to activate your account.");
  60. } else if (message.activation === 'admin') {
  61. lead = gettext("%(username)s, your account has been created but board administrator will have to activate it before you will be able to sign in.");
  62. help = gettext("We will send an e-mail to %(email)s when this takes place.");
  63. }
  64. return [
  65. m('.message-icon',
  66. m('span.material-icon', 'info_outline')
  67. ),
  68. m('.message-body', [
  69. m('p.lead',
  70. interpolate(lead, {'username': message.username}, true)
  71. ),
  72. m('p',
  73. interpolate(help, {'email': message.email}, true)
  74. )
  75. ])
  76. ];
  77. }
  78. };
  79. Misago.addService('modal:register-complete', function(_) {
  80. _.modal('register-complete', registerComplete);
  81. },
  82. {
  83. after: 'modals'
  84. });
  85. }(Misago.prototype));