signin.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (function (Misago) {
  2. 'use strict';
  3. function persistent(el, isInit, context) {
  4. context.retain = true;
  5. }
  6. var signin = {
  7. controller: function(_) {
  8. return {
  9. form: _.form('sign-in')
  10. };
  11. },
  12. view: function(ctrl, _) {
  13. var activateButton = null;
  14. if (ctrl.form.showActivation) {
  15. activateButton = m('a.btn.btn-block.btn-success',
  16. {href: _.context.REQUEST_ACTIVATION_URL},
  17. gettext("Activate account")
  18. );
  19. }
  20. return m('.modal-dialog.modal-sm.modal-signin[role="document"]',
  21. {config: persistent},
  22. m('.modal-content', [
  23. _.component('modal:header', gettext("Sign in")),
  24. m('form', {onsubmit: ctrl.form.submit}, [
  25. m('.modal-body', [
  26. m('.form-group',
  27. m('.control-input',
  28. Misago.input({
  29. disabled: ctrl.form.isBusy,
  30. value: ctrl.form.username,
  31. placeholder: gettext("Username or e-mail")
  32. })
  33. )
  34. ),
  35. m('.form-group',
  36. m('.control-input',
  37. Misago.input({
  38. type: 'password',
  39. disabled: ctrl.form.isBusy,
  40. value: ctrl.form.password,
  41. placeholder: gettext("Password")
  42. })
  43. )
  44. )
  45. ]),
  46. m('.modal-footer', [
  47. activateButton,
  48. _.component('button', {
  49. class: '.btn-primary.btn-block',
  50. submit: true,
  51. loading: ctrl.form.isBusy,
  52. label: gettext("Sign in")
  53. }),
  54. m('a.btn.btn-block.btn-default',
  55. {href: _.context.FORGOTTEN_PASSWORD_URL},
  56. gettext("Forgot password?")
  57. )
  58. ])
  59. ])
  60. ])
  61. );
  62. }
  63. };
  64. Misago.addService('modal:sign-in', function(_) {
  65. _.modal('sign-in', signin);
  66. },
  67. {
  68. after: 'modals'
  69. });
  70. }(Misago.prototype));