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.autofillOptions', function() { | 5 cr.define('options.autofillOptions', function() { |
6 /** @const */ var DeletableItem = options.DeletableItem; | 6 /** @const */ var DeletableItem = options.DeletableItem; |
7 /** @const */ var DeletableItemList = options.DeletableItemList; | 7 /** @const */ var DeletableItemList = options.DeletableItemList; |
8 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 8 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
9 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; | 9 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
10 | 10 |
11 /** | 11 /** |
12 * @return {!HTMLButtonElement} | 12 * @return {!HTMLButtonElement} |
13 */ | 13 */ |
14 function AutofillEditProfileButton(edit) { | 14 function AutofillEditProfileButton(edit) { |
15 var editButtonEl = /** @type {HTMLButtonElement} */( | 15 var editButtonEl = /** @type {HTMLButtonElement} */( |
16 document.createElement('button')); | 16 document.createElement('button')); |
17 editButtonEl.className = 'list-inline-button custom-appearance'; | 17 editButtonEl.className = |
| 18 'list-inline-button hide-until-hover custom-appearance'; |
18 editButtonEl.textContent = | 19 editButtonEl.textContent = |
19 loadTimeData.getString('autofillEditProfileButton'); | 20 loadTimeData.getString('autofillEditProfileButton'); |
20 editButtonEl.onclick = edit; | 21 editButtonEl.onclick = edit; |
21 | 22 |
22 editButtonEl.onmousedown = function(e) { | 23 editButtonEl.onmousedown = function(e) { |
23 // Don't select the row when clicking the button. | 24 // Don't select the row when clicking the button. |
24 e.stopPropagation(); | 25 e.stopPropagation(); |
25 // Don't focus on the button when clicking it. | 26 // Don't focus on the button when clicking it. |
26 e.preventDefault(); | 27 e.preventDefault(); |
27 }; | 28 }; |
28 | 29 |
29 return editButtonEl; | 30 return editButtonEl; |
30 } | 31 } |
31 | 32 |
32 /** | 33 /** |
| 34 * @return {!HTMLSpanElement} |
| 35 */ |
| 36 function CreateGoogleAccountLabel() { |
| 37 var label = document.createElement('div'); |
| 38 label.className = 'deemphasized hides-on-hover'; |
| 39 label.textContent = loadTimeData.getString('autofillFromGoogleAccount'); |
| 40 return label; |
| 41 } |
| 42 |
| 43 /** |
33 * Creates a new address list item. | 44 * Creates a new address list item. |
34 * @param {Object} entry An object with metadata about an address profile. | 45 * @param {Object} entry An object with metadata about an address profile. |
35 * @constructor | 46 * @constructor |
36 * @extends {options.DeletableItem} | 47 * @extends {options.DeletableItem} |
37 */ | 48 */ |
38 function AddressListItem(entry) { | 49 function AddressListItem(entry) { |
39 var el = cr.doc.createElement('div'); | 50 var el = cr.doc.createElement('div'); |
40 for (var key in entry) { | 51 for (var key in entry) { |
41 el[key] = entry[key]; | 52 el[key] = entry[key]; |
42 } | 53 } |
43 el.__proto__ = AddressListItem.prototype; | 54 el.__proto__ = AddressListItem.prototype; |
44 el.decorate(); | 55 el.decorate(); |
45 | 56 |
46 return el; | 57 return el; |
47 } | 58 } |
48 | 59 |
49 AddressListItem.prototype = { | 60 AddressListItem.prototype = { |
50 __proto__: DeletableItem.prototype, | 61 __proto__: DeletableItem.prototype, |
51 | 62 |
52 /** @override */ | 63 /** @override */ |
53 decorate: function() { | 64 decorate: function() { |
54 DeletableItem.prototype.decorate.call(this); | 65 DeletableItem.prototype.decorate.call(this); |
55 | 66 |
56 // The stored label. | |
57 var label = this.ownerDocument.createElement('div'); | 67 var label = this.ownerDocument.createElement('div'); |
58 label.className = 'autofill-list-item'; | 68 label.className = 'autofill-list-item'; |
59 label.textContent = this.label; | 69 label.textContent = this.label; |
60 this.contentElement.appendChild(label); | 70 this.contentElement.appendChild(label); |
61 | 71 |
62 if (!this.isLocal) | 72 var sublabel = this.ownerDocument.createElement('div'); |
| 73 sublabel.className = 'deemphasized'; |
| 74 sublabel.textContent = this.sublabel; |
| 75 this.contentElement.appendChild(sublabel); |
| 76 |
| 77 if (!this.isLocal) { |
63 this.deletable = false; | 78 this.deletable = false; |
| 79 this.contentElement.appendChild(CreateGoogleAccountLabel()); |
| 80 } |
64 | 81 |
65 // The 'Edit' button. | 82 // The 'Edit' button. |
66 var guid = this.guid; | 83 var guid = this.guid; |
67 var editButtonEl = AutofillEditProfileButton( | 84 var editButtonEl = AutofillEditProfileButton( |
68 function() { AutofillOptions.loadAddressEditor(guid); }); | 85 function() { AutofillOptions.loadAddressEditor(guid); }); |
69 this.contentElement.appendChild(editButtonEl); | 86 this.contentElement.appendChild(editButtonEl); |
70 }, | 87 }, |
71 }; | 88 }; |
72 | 89 |
73 /** | 90 /** |
(...skipping 13 matching lines...) Expand all Loading... |
87 return el; | 104 return el; |
88 } | 105 } |
89 | 106 |
90 CreditCardListItem.prototype = { | 107 CreditCardListItem.prototype = { |
91 __proto__: DeletableItem.prototype, | 108 __proto__: DeletableItem.prototype, |
92 | 109 |
93 /** @override */ | 110 /** @override */ |
94 decorate: function() { | 111 decorate: function() { |
95 DeletableItem.prototype.decorate.call(this); | 112 DeletableItem.prototype.decorate.call(this); |
96 | 113 |
97 // The stored label. | |
98 var label = this.ownerDocument.createElement('div'); | 114 var label = this.ownerDocument.createElement('div'); |
99 label.className = 'autofill-list-item'; | 115 label.className = 'autofill-list-item'; |
100 label.textContent = this.label; | 116 label.textContent = this.label; |
101 this.contentElement.appendChild(label); | 117 this.contentElement.appendChild(label); |
102 | 118 |
103 if (!this.isLocal) | 119 var sublabel = this.ownerDocument.createElement('div'); |
| 120 sublabel.className = 'deemphasized'; |
| 121 sublabel.textContent = this.sublabel; |
| 122 this.contentElement.appendChild(sublabel); |
| 123 |
| 124 if (!this.isLocal) { |
104 this.deletable = false; | 125 this.deletable = false; |
| 126 this.contentElement.appendChild(CreateGoogleAccountLabel()); |
| 127 } |
105 | 128 |
106 var guid = this.guid; | 129 var guid = this.guid; |
107 if (this.isCached) { | 130 if (this.isCached) { |
108 var localCopyText = this.ownerDocument.createElement('span'); | 131 var localCopyText = this.ownerDocument.createElement('span'); |
| 132 localCopyText.className = 'hide-until-hover deemphasized'; |
109 localCopyText.textContent = | 133 localCopyText.textContent = |
110 loadTimeData.getString('autofillDescribeLocalCopy'); | 134 loadTimeData.getString('autofillDescribeLocalCopy'); |
111 this.contentElement.appendChild(localCopyText); | 135 this.contentElement.appendChild(localCopyText); |
112 | 136 |
113 var clearLocalCopyButton = AutofillEditProfileButton( | 137 var clearLocalCopyButton = AutofillEditProfileButton( |
114 function() { chrome.send('clearLocalCardCopy', [guid]); }); | 138 function() { chrome.send('clearLocalCardCopy', [guid]); }); |
115 clearLocalCopyButton.textContent = | 139 clearLocalCopyButton.textContent = |
116 loadTimeData.getString('autofillClearLocalCopyButton'); | 140 loadTimeData.getString('autofillClearLocalCopyButton'); |
117 this.contentElement.appendChild(clearLocalCopyButton); | 141 this.contentElement.appendChild(clearLocalCopyButton); |
118 } | 142 } |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 CreditCardListItem: CreditCardListItem, | 584 CreditCardListItem: CreditCardListItem, |
561 ValuesListItem: ValuesListItem, | 585 ValuesListItem: ValuesListItem, |
562 NameListItem: NameListItem, | 586 NameListItem: NameListItem, |
563 AutofillAddressList: AutofillAddressList, | 587 AutofillAddressList: AutofillAddressList, |
564 AutofillCreditCardList: AutofillCreditCardList, | 588 AutofillCreditCardList: AutofillCreditCardList, |
565 AutofillValuesList: AutofillValuesList, | 589 AutofillValuesList: AutofillValuesList, |
566 AutofillNameValuesList: AutofillNameValuesList, | 590 AutofillNameValuesList: AutofillNameValuesList, |
567 AutofillPhoneValuesList: AutofillPhoneValuesList, | 591 AutofillPhoneValuesList: AutofillPhoneValuesList, |
568 }; | 592 }; |
569 }); | 593 }); |
OLD | NEW |