Browse Source

fix(LoginDialog.web): 'states' is passed as undefined

j8
paweldomas 8 years ago
parent
commit
6890414bad
1 changed files with 35 additions and 33 deletions
  1. 35
    33
      modules/UI/authentication/LoginDialog.js

+ 35
- 33
modules/UI/authentication/LoginDialog.js View File

@@ -61,29 +61,44 @@ function LoginDialog(successCallback, cancelCallback) {
61 61
         finishedButtons.push(cancelButton());
62 62
     }
63 63
 
64
-    const connDialog = APP.UI.messageHandler.openDialogWithStates(
65
-        states, // eslint-disable-line no-use-before-define
66
-        {
67
-            persistent: true,
68
-            closeText: ''
64
+    const states = {
65
+        connecting: {
66
+            buttons: [],
67
+            defaultButton: 0,
68
+            html: '<div id="connectionStatus"></div>',
69
+            titleKey: 'dialog.connecting'
69 70
         },
70
-        null
71
-    );
71
+        finished: {
72
+            buttons: finishedButtons,
73
+            defaultButton: 0,
74
+            html: '<div id="errorMessage"></div>',
75
+            titleKey: 'dialog.error',
72 76
 
73
-    const states = {
77
+            submit(e, v) {
78
+                e.preventDefault();
79
+                if (v === 'retry') {
80
+                    // eslint-disable-next-line no-use-before-define
81
+                    connDialog.goToState('login');
82
+                } else {
83
+                    // User cancelled
84
+                    cancelCallback();
85
+                }
86
+            }
87
+        },
74 88
         login: {
75
-            titleKey: 'dialog.passwordRequired',
76
-            html: getPasswordInputHtml(),
77 89
             buttons: loginButtons,
78 90
             focus: ':input:first',
79
-            // eslint-disable-next-line max-params
80
-            submit(e, v, m, f) {
91
+            html: getPasswordInputHtml(),
92
+            titleKey: 'dialog.passwordRequired',
93
+
94
+            submit(e, v, m, f) { // eslint-disable-line max-params
81 95
                 e.preventDefault();
82 96
                 if (v) {
83 97
                     const jid = f.username;
84 98
                     const password = f.password;
85 99
 
86 100
                     if (jid && password) {
101
+                        // eslint-disable-next-line no-use-before-define
87 102
                         connDialog.goToState('connecting');
88 103
                         successCallback(toJid(jid, config.hosts), password);
89 104
                     }
@@ -92,29 +107,16 @@ function LoginDialog(successCallback, cancelCallback) {
92 107
                     cancelCallback();
93 108
                 }
94 109
             }
95
-        },
96
-        connecting: {
97
-            titleKey: 'dialog.connecting',
98
-            html: '<div id="connectionStatus"></div>',
99
-            buttons: [],
100
-            defaultButton: 0
101
-        },
102
-        finished: {
103
-            titleKey: 'dialog.error',
104
-            html: '<div id="errorMessage"></div>',
105
-            buttons: finishedButtons,
106
-            defaultButton: 0,
107
-            submit(e, v) {
108
-                e.preventDefault();
109
-                if (v === 'retry') {
110
-                    connDialog.goToState('login');
111
-                } else {
112
-                    // User cancelled
113
-                    cancelCallback();
114
-                }
115
-            }
116 110
         }
117 111
     };
112
+    const connDialog = APP.UI.messageHandler.openDialogWithStates(
113
+        states,
114
+        {
115
+            closeText: '',
116
+            persistent: true
117
+        },
118
+        null
119
+    );
118 120
 
119 121
     /**
120 122
      * Displays error message in 'finished' state which allows either to cancel

Loading…
Cancel
Save