signin.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: _.router.url('request_activation')},
  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. ])
  55. ])
  56. ])
  57. );
  58. }
  59. };
  60. Misago.addService('modal:sign-in', function(_) {
  61. _.modal('sign-in', signin);
  62. },
  63. {
  64. after: 'modals'
  65. });
  66. }(Misago.prototype));