LoginDialog.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * LoginDialog.js
  3. *
  4. * @author realor
  5. */
  6. import { Dialog } from './Dialog.js'
  7. class LoginDialog extends Dialog {
  8. constructor(application, message) {
  9. super('title.login')
  10. this.application = application
  11. this.setI18N(this.application.i18n)
  12. this.setSize(240, 180)
  13. if (message) {
  14. this.errorElem = this.addText(message, 'error block')
  15. }
  16. this.usernameElem = this.addTextField('loginUser', 'label.username', '')
  17. this.usernameElem.setAttribute('spellcheck', 'false')
  18. this.passwordElem = this.addPasswordField('loginPassword', 'label.password', '')
  19. this.passwordElem.addEventListener('keypress', event => {
  20. if (event.keyCode === 13) {
  21. this.onAccept()
  22. }
  23. })
  24. this.acceptButton = this.addButton('login_accept', 'button.accept', () => this.onAccept())
  25. this.cancelButton = this.addButton('login_cancel', 'button.cancel', () => this.onCancel())
  26. }
  27. onShow() {
  28. this.usernameElem.focus()
  29. }
  30. onAccept() {
  31. this.hide()
  32. this.login(this.usernameElem.value, this.passwordElem.value)
  33. }
  34. onCancel() {
  35. this.hide()
  36. }
  37. login(username, password) {}
  38. }
  39. export { LoginDialog }