OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html i18n-values="dir:textdirection"> | 2 <html i18n-values="dir:textdirection"> |
3 <head> | 3 <head> |
4 <style type="text/css"> | 4 <style type="text/css"> |
5 body { | 5 body { |
6 margin: 0px; | 6 margin: 10px 10px 0 10px; |
| 7 -webkit-user-select: none; |
7 } | 8 } |
8 | 9 |
9 #buttons { | 10 form { |
10 text-align: right; | 11 margin: 0; |
11 } | 12 } |
12 | 13 |
13 html[dir='rtl'] #buttons { | 14 #explanation { |
14 text-align: left; | 15 cursor: default; |
| 16 } |
| 17 |
| 18 #fields { |
| 19 padding: 10px 0; |
| 20 margin-left: auto; |
| 21 margin-right: auto; |
| 22 } |
| 23 |
| 24 #username-label-cell, |
| 25 #password-label-cell { |
| 26 text-align: end; |
| 27 -webkit-padding-end: 5px; |
15 } | 28 } |
16 | 29 |
17 #username, | 30 #username, |
18 #password { | 31 #password { |
19 width: 220px; | 32 width: 150px; |
20 } | 33 } |
| 34 |
| 35 #buttons { |
| 36 text-align: end; |
| 37 } |
| 38 |
21 </style> | 39 </style> |
22 <script type="text/javascript"> | 40 <script> |
23 function $(o) { | 41 function $(o) { |
24 return document.getElementById(o); | 42 return document.getElementById(o); |
25 } | 43 } |
26 | 44 |
27 function disableControls() { | 45 function disableControls() { |
28 $('username').disabled = true; | 46 $('username').disabled = true; |
29 $('password').disabled = true; | 47 $('password').disabled = true; |
30 $('login').disabled = true; | 48 $('login').disabled = true; |
31 $('cancel').disabled = true; | 49 $('cancel').disabled = true; |
32 } | 50 } |
33 | 51 |
34 function sendCredentialsAndClose() { | 52 function sendCredentialsAndClose() { |
35 disableControls(); | 53 disableControls(); |
36 | 54 |
37 var result = JSON.stringify({ | 55 var result = JSON.stringify({ |
38 'username': $('username').value, | 56 'username': $('username').value, |
39 'password': $('password').value}); | 57 'password': $('password').value}); |
40 | 58 |
41 chrome.send('DialogClose', [result]); | 59 chrome.send('DialogClose', [result]); |
42 } | 60 } |
43 | 61 |
| 62 function cancel() { |
| 63 disableControls(); |
| 64 chrome.send('DialogClose'); |
| 65 } |
| 66 |
| 67 function handleSubmit(e) { |
| 68 sendCredentialsAndClose(); |
| 69 e.preventDefault(); |
| 70 } |
| 71 |
| 72 function handleKeyDown(e) { |
| 73 if (e.keyCode == 27) { // Escape |
| 74 cancel(); |
| 75 e.preventDefault(); |
| 76 } |
| 77 } |
| 78 |
44 function setAutofillCredentials(username, password) { | 79 function setAutofillCredentials(username, password) { |
45 $('username').value = username; | 80 $('username').value = username; |
46 $('password').value = password; | 81 $('password').value = password; |
47 } | 82 } |
48 | 83 |
49 function handleKeyDown(event) { | |
50 if (event.keyCode == 13) { // Enter. | |
51 $('login').onclick(); | |
52 } else if (event.keyCode == 27) { // Escape. | |
53 $('cancel').onclick(); | |
54 } | |
55 } | |
56 | |
57 function load() { | 84 function load() { |
| 85 document.addEventListener('keydown', handleKeyDown); |
58 $('explanation').textContent = chrome.dialogArguments; | 86 $('explanation').textContent = chrome.dialogArguments; |
59 | 87 $('form').onsubmit = handleSubmit; |
60 $('cancel').onclick = function() { | 88 $('cancel').onclick = cancel; |
61 disableControls(); | |
62 chrome.send('DialogClose', ['']); | |
63 }; | |
64 | |
65 $('login').onclick = function() { | |
66 sendCredentialsAndClose(); | |
67 }; | |
68 | |
69 $('username').focus(); | 89 $('username').focus(); |
70 | 90 |
71 chrome.send('GetAutofill', ['']); | 91 chrome.send('GetAutofill', ['']); |
72 } | 92 } |
73 | 93 |
74 document.addEventListener('DOMContentLoaded', load); | 94 document.addEventListener('DOMContentLoaded', load); |
75 document.addEventListener('keydown', handleKeyDown); | |
76 </script> | 95 </script> |
77 </head> | 96 </head> |
78 <body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> | 97 <body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> |
79 <div id="explanation"></div> | 98 <div id="explanation"></div> |
80 <table> | 99 <form id="form"> |
81 <tr> | 100 <table id="fields"> |
82 <td i18n-content="username"></td> | 101 <tr> |
83 <td> | 102 <td id="username-label-cell"> |
84 <input id="username" type="text"> | 103 <label for="username" i18n-content="username"></label> |
85 </td> | 104 </td> |
86 </tr> | 105 <td> |
87 <tr> | 106 <input id="username" type="text"> |
88 <td i18n-content="password"></td> | 107 </td> |
89 <td> | 108 </tr> |
90 <input id="password" name="password" type="password"> | 109 <tr> |
91 </td> | 110 <td id="password-label-cell"> |
92 </tr> | 111 <label for="password" i18n-content="password"></label> |
93 </table> | 112 </td> |
94 <div id="buttons"> | 113 <td> |
95 <input id="cancel" type="button" i18n-values="value:cancel"> | 114 <input id="password" name="password" type="password"> |
96 <input id="login" type="button" i18n-values="value:signin"> | 115 </td> |
97 </div> | 116 </tr> |
| 117 </table> |
| 118 <div id="buttons"> |
| 119 <input id="cancel" type="button" i18n-values="value:cancel"> |
| 120 <input id="login" type="submit" i18n-values="value:signin"> |
| 121 </div> |
| 122 </form> |
98 </body> | 123 </body> |
99 </html> | 124 </html> |
OLD | NEW |