OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
6 * @typedef {{hasChildren: boolean, | 6 * @typedef {{hasChildren: boolean, |
7 * id: string, | 7 * id: string, |
8 * title: string, | 8 * title: string, |
9 * totalUsage: string, | 9 * totalUsage: string, |
10 * type: string}} | 10 * type: string}} |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 * @return {!Array<!CookieDataSummaryItem>} The summary list. | 159 * @return {!Array<!CookieDataSummaryItem>} The summary list. |
160 */ | 160 */ |
161 getSummaryList: function() { | 161 getSummaryList: function() { |
162 var list = []; | 162 var list = []; |
163 for (var i = 0; i < this.children_.length; ++i) { | 163 for (var i = 0; i < this.children_.length; ++i) { |
164 var siteEntry = this.children_[i]; | 164 var siteEntry = this.children_[i]; |
165 var title = siteEntry.data_.title; | 165 var title = siteEntry.data_.title; |
166 var id = siteEntry.data_.id; | 166 var id = siteEntry.data_.id; |
167 var description = ''; | 167 var description = ''; |
168 | 168 |
169 if (siteEntry.children_.length == 0) | |
170 continue; | |
171 | |
169 for (var j = 0; j < siteEntry.children_.length; ++j) { | 172 for (var j = 0; j < siteEntry.children_.length; ++j) { |
170 var descriptionNode = siteEntry.children_[j]; | 173 var descriptionNode = siteEntry.children_[j]; |
171 if (j > 0) | 174 if (j > 0) |
172 description += ', '; | 175 description += ', '; |
173 | 176 |
174 // Some types, like quota, have no description nodes. | 177 // Some types, like quota, have no description nodes. |
175 var dataType = ''; | 178 var dataType = ''; |
176 if (descriptionNode.data_.type != undefined) { | 179 if (descriptionNode.data_.type != undefined) { |
177 dataType = descriptionNode.data_.type; | 180 dataType = descriptionNode.data_.type; |
178 } else { | 181 } else { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 return null; | 223 return null; |
221 }, | 224 }, |
222 | 225 |
223 /** | 226 /** |
224 * Add cookie data to a given HTML node. | 227 * Add cookie data to a given HTML node. |
225 * @param {HTMLElement} root The node to add the data to. | 228 * @param {HTMLElement} root The node to add the data to. |
226 * @param {!settings.CookieTreeNode} item The data to add. | 229 * @param {!settings.CookieTreeNode} item The data to add. |
227 */ | 230 */ |
228 addCookieData: function(root, item) { | 231 addCookieData: function(root, item) { |
229 var fields = cookieInfo[item.data_.type]; | 232 var fields = cookieInfo[item.data_.type]; |
233 var first = true; | |
230 for (var field of fields) { | 234 for (var field of fields) { |
231 // Iterate through the keys found in |cookieInfo| for the given |type| | 235 // Iterate through the keys found in |cookieInfo| for the given |type| |
232 // and see if those keys are present in the data. If so, display them | 236 // and see if those keys are present in the data. If so, display them |
233 // (in the order determined by |cookieInfo|). | 237 // (in the order determined by |cookieInfo|). |
234 var key = field[0]; | 238 var key = field[0]; |
235 if (item.data_[key].length > 0) { | 239 if (item.data_[key].length > 0) { |
236 var label = loadTimeData.getString(field[1]); | 240 var label = loadTimeData.getString(field[1]); |
237 | 241 |
238 var header = document.createElement('div'); | 242 var header = document.createElement('div'); |
243 if (!first) { | |
244 header.style.cssText += | |
245 'border-top: 1px solid rgba(0, 0, 0, 0.14);' + | |
246 'margin-top: 7px;' + | |
247 'padding-top: 7px;'; | |
Finnur
2016/10/05 13:42:22
I'd like to do the styling in the html section for
dschuyler
2016/10/05 22:04:02
Let's call the above Option A.
Here's Option B:
Finnur
2016/10/07 15:16:42
I love it. Done.
| |
248 } | |
239 header.appendChild(document.createTextNode(label)); | 249 header.appendChild(document.createTextNode(label)); |
250 | |
240 var content = document.createElement('div'); | 251 var content = document.createElement('div'); |
252 content.style.cssText += | |
253 'color: var(--settings-secondary_-_color);' + | |
254 'margin-top: 3px;'; | |
241 content.appendChild(document.createTextNode(item.data_[key])); | 255 content.appendChild(document.createTextNode(item.data_[key])); |
242 root.appendChild(header); | 256 root.appendChild(header); |
243 root.appendChild(content); | 257 root.appendChild(content); |
258 first = false; | |
244 } | 259 } |
245 } | 260 } |
246 }, | 261 }, |
247 }; | 262 }; |
248 | 263 |
249 return { | 264 return { |
250 CookieTreeNode: CookieTreeNode, | 265 CookieTreeNode: CookieTreeNode, |
251 }; | 266 }; |
252 }); | 267 }); |
OLD | NEW |