OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('options.passwordManager', function() { | 5 cr.define('options.passwordManager', function() { |
6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
7 /** @const */ var DeletableItemList = options.DeletableItemList; | 7 /** @const */ var DeletableItemList = options.DeletableItemList; |
8 /** @const */ var DeletableItem = options.DeletableItem; | 8 /** @const */ var DeletableItem = options.DeletableItem; |
9 /** @const */ var List = cr.ui.List; | 9 /** @const */ var List = cr.ui.List; |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 url = url.replace(/[^A-Za-z0-9]+$/, ''); | 60 url = url.replace(/[^A-Za-z0-9]+$/, ''); |
61 return url; | 61 return url; |
62 } | 62 } |
63 | 63 |
64 PasswordListItem.prototype = { | 64 PasswordListItem.prototype = { |
65 __proto__: DeletableItem.prototype, | 65 __proto__: DeletableItem.prototype, |
66 | 66 |
67 /** @override */ | 67 /** @override */ |
68 decorate: function() { | 68 decorate: function() { |
69 DeletableItem.prototype.decorate.call(this); | 69 DeletableItem.prototype.decorate.call(this); |
70 var deletableItem = this; | |
70 | 71 |
71 // The URL of the site. | 72 // The URL of the site. |
72 var urlDiv = this.ownerDocument.createElement('div'); | 73 var urlDiv = this.ownerDocument.createElement('div'); |
73 urlDiv.className = 'favicon-cell left-elided-url url'; | 74 urlDiv.className = 'favicon-cell left-elided-url url'; |
74 urlDiv.setAttribute( | 75 urlDiv.setAttribute( |
75 'title', getTitleForPasswordOrigin(this.url, this.isUrlSecure)); | 76 'title', getTitleForPasswordOrigin(this.url, this.isUrlSecure)); |
76 var urlLink = this.ownerDocument.createElement('a'); | 77 var urlLink = this.ownerDocument.createElement('a'); |
77 urlLink.href = this.url; | 78 urlLink.href = this.url; |
78 urlLink.setAttribute('target', '_blank'); | 79 urlLink.setAttribute('target', '_blank'); |
79 urlLink.textContent = this.shownUrl.split('').reverse().join(''); | 80 urlLink.textContent = this.shownUrl.split('').reverse().join(''); |
81 urlLink.addEventListener('focus', function() { | |
82 deletableItem.handleFocus(); | |
Evan Stade
2015/11/30 18:23:36
urlLink.addEventListener('focus', function() {
t
kolos1
2015/12/01 09:00:13
Thanks. Done.
| |
83 }); | |
80 urlDiv.appendChild(urlLink); | 84 urlDiv.appendChild(urlLink); |
81 urlDiv.style.backgroundImage = getFaviconImageSet( | 85 urlDiv.style.backgroundImage = getFaviconImageSet( |
82 'origin/' + this.url, 16); | 86 'origin/' + this.url, 16); |
83 this.contentElement.appendChild(urlDiv); | 87 this.contentElement.appendChild(urlDiv); |
84 this.urlLink = urlLink; | 88 this.urlLink = urlLink; |
85 | 89 |
86 // The stored username. | 90 // The stored username. |
87 var usernameDiv = this.ownerDocument.createElement('div'); | 91 var usernameDiv = this.ownerDocument.createElement('div'); |
88 usernameDiv.className = 'name'; | 92 usernameDiv.className = 'name'; |
89 usernameDiv.title = this.username; | 93 usernameDiv.title = this.username; |
90 this.contentElement.appendChild(usernameDiv); | 94 this.contentElement.appendChild(usernameDiv); |
91 var usernameInput = this.ownerDocument.createElement('input'); | 95 var usernameInput = this.ownerDocument.createElement('input'); |
92 usernameInput.type = 'text'; | 96 usernameInput.type = 'text'; |
93 usernameInput.className = 'inactive-item'; | 97 usernameInput.className = 'inactive-item'; |
94 usernameInput.readOnly = true; | 98 usernameInput.readOnly = true; |
95 usernameInput.value = this.username; | 99 usernameInput.value = this.username; |
100 usernameInput.addEventListener('focus', function() { | |
101 deletableItem.handleFocus(); | |
102 }); | |
96 usernameDiv.appendChild(usernameInput); | 103 usernameDiv.appendChild(usernameInput); |
97 this.usernameField = usernameInput; | 104 this.usernameField = usernameInput; |
98 | 105 |
99 if (this.federation) { | 106 if (this.federation) { |
100 // The federation. | 107 // The federation. |
101 var federationDiv = this.ownerDocument.createElement('div'); | 108 var federationDiv = this.ownerDocument.createElement('div'); |
102 federationDiv.className = 'federation'; | 109 federationDiv.className = 'federation'; |
103 federationDiv.textContent = this.federation; | 110 federationDiv.textContent = this.federation; |
104 this.contentElement.appendChild(federationDiv); | 111 this.contentElement.appendChild(federationDiv); |
105 } else { | 112 } else { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 } | 317 } |
311 | 318 |
312 PasswordExceptionsListItem.prototype = { | 319 PasswordExceptionsListItem.prototype = { |
313 __proto__: DeletableItem.prototype, | 320 __proto__: DeletableItem.prototype, |
314 | 321 |
315 /** | 322 /** |
316 * Call when an element is decorated as a list item. | 323 * Call when an element is decorated as a list item. |
317 */ | 324 */ |
318 decorate: function() { | 325 decorate: function() { |
319 DeletableItem.prototype.decorate.call(this); | 326 DeletableItem.prototype.decorate.call(this); |
327 var deletableItem = this; | |
320 | 328 |
321 // The URL of the site. | 329 // The URL of the site. |
322 var urlDiv = this.ownerDocument.createElement('div'); | 330 var urlDiv = this.ownerDocument.createElement('div'); |
323 urlDiv.className = 'url'; | 331 urlDiv.className = 'url'; |
324 urlDiv.classList.add('favicon-cell'); | 332 urlDiv.classList.add('favicon-cell'); |
325 urlDiv.classList.add('left-elided-url'); | 333 urlDiv.classList.add('left-elided-url'); |
326 urlDiv.setAttribute( | 334 urlDiv.setAttribute( |
327 'title', getTitleForPasswordOrigin(this.url, this.isUrlSecure)); | 335 'title', getTitleForPasswordOrigin(this.url, this.isUrlSecure)); |
328 var urlLink = this.ownerDocument.createElement('a'); | 336 var urlLink = this.ownerDocument.createElement('a'); |
329 urlLink.href = this.url; | 337 urlLink.href = this.url; |
330 urlLink.textContent = this.shownUrl.split('').reverse().join(''); | 338 urlLink.textContent = this.shownUrl.split('').reverse().join(''); |
331 urlLink.setAttribute('target', '_blank'); | 339 urlLink.setAttribute('target', '_blank'); |
340 urlLink.addEventListener('focus', function() { | |
341 deletableItem.handleFocus(); | |
342 }); | |
343 this.urlLink = urlLink; | |
332 urlDiv.appendChild(urlLink); | 344 urlDiv.appendChild(urlLink); |
333 urlDiv.style.backgroundImage = getFaviconImageSet( | 345 urlDiv.style.backgroundImage = getFaviconImageSet( |
334 'origin/' + this.url, 16); | 346 'origin/' + this.url, 16); |
335 urlLink.tabIndex = -1; | |
336 this.contentElement.appendChild(urlDiv); | 347 this.contentElement.appendChild(urlDiv); |
337 }, | 348 }, |
338 | 349 |
350 /** @override */ | |
351 selectionChanged: function() { | |
352 if (this.selected) { | |
353 this.setFocusable_(true); | |
354 this.urlLink.focus(); | |
355 } else { | |
356 this.setFocusable_(false); | |
357 } | |
358 }, | |
359 | |
360 /** | |
361 * Set the focusability of this row. | |
362 * @param {boolean} focusable | |
363 * @private | |
364 */ | |
365 setFocusable_: function(focusable) { | |
366 var tabIndex = focusable ? 0 : -1; | |
367 this.urlLink.tabIndex = tabIndex; | |
368 this.closeButtonElement.tabIndex = tabIndex; | |
369 }, | |
370 | |
339 /** | 371 /** |
340 * Get the url for the entry. | 372 * Get the url for the entry. |
341 * @type {string} | 373 * @type {string} |
342 */ | 374 */ |
343 get url() { | 375 get url() { |
344 return this.dataItem[ORIGIN_FIELD]; | 376 return this.dataItem[ORIGIN_FIELD]; |
345 }, | 377 }, |
346 set url(url) { | 378 set url(url) { |
347 this.dataItem[ORIGIN_FIELD] = url; | 379 this.dataItem[ORIGIN_FIELD] = url; |
348 }, | 380 }, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 PasswordExceptionsList: PasswordExceptionsList, | 518 PasswordExceptionsList: PasswordExceptionsList, |
487 ORIGIN_FIELD: ORIGIN_FIELD, | 519 ORIGIN_FIELD: ORIGIN_FIELD, |
488 SHOWN_URL_FIELD: SHOWN_URL_FIELD, | 520 SHOWN_URL_FIELD: SHOWN_URL_FIELD, |
489 IS_SECURE_FIELD: IS_SECURE_FIELD, | 521 IS_SECURE_FIELD: IS_SECURE_FIELD, |
490 USERNAME_FIELD: USERNAME_FIELD, | 522 USERNAME_FIELD: USERNAME_FIELD, |
491 PASSWORD_FIELD: PASSWORD_FIELD, | 523 PASSWORD_FIELD: PASSWORD_FIELD, |
492 FEDERATION_FIELD: FEDERATION_FIELD, | 524 FEDERATION_FIELD: FEDERATION_FIELD, |
493 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD | 525 ORIGINAL_INDEX_FIELD: ORIGINAL_INDEX_FIELD |
494 }; | 526 }; |
495 }); | 527 }); |
OLD | NEW |