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', function() { | 5 cr.define('options', function() { |
6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 9 |
10 ///////////////////////////////////////////////////////////////////////////// | 10 ///////////////////////////////////////////////////////////////////////////// |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 * @param {!cr.ui.List} list The list to toggle visilibility for. | 158 * @param {!cr.ui.List} list The list to toggle visilibility for. |
159 */ | 159 */ |
160 updateListVisibility_: function(list) { | 160 updateListVisibility_: function(list) { |
161 var empty = list.dataModel.length == 0; | 161 var empty = list.dataModel.length == 0; |
162 var listPlaceHolderID = list.id + '-empty-placeholder'; | 162 var listPlaceHolderID = list.id + '-empty-placeholder'; |
163 list.hidden = empty; | 163 list.hidden = empty; |
164 $(listPlaceHolderID).hidden = !empty; | 164 $(listPlaceHolderID).hidden = !empty; |
165 }, | 165 }, |
166 | 166 |
167 /** | 167 /** |
168 * Updates eliding of origins. If there is no enough space to show the full | |
169 * origin, the origin is elided from the left with ellipsis. | |
170 * @param {!cr.ui.List} list The list to update eliding. | |
171 */ | |
172 updateOriginsEliding_: function(list) { | |
173 var entries = list.getElementsByClassName('deletable-item'); | |
174 if (entries.length == 0) | |
175 return; | |
176 var entry = entries[0]; | |
177 var computedStyle = window.getComputedStyle(entry.urlDiv); | |
178 var columnWidth = entry.urlDiv.offsetWidth - | |
179 parseInt(computedStyle.webkitMarginStart) - | |
180 parseInt(computedStyle.webkitPaddingStart); | |
181 for (var i = 0; i < entries.length; ++i) { | |
182 var urlLink = entries[i].urlLink; | |
183 if (entries[i].isAndroidUri || urlLink.offsetWidth <= columnWidth) | |
184 continue; | |
185 urlLink.textContent = '…' + urlLink.textContent.substring(1); | |
Evan Stade
2016/03/22 19:42:23
to maintain the tooltip, do you need urlLink.title
kolos1
2016/03/22 19:49:26
tootip is initialized with entry.url (fullorigin)
| |
186 while (urlLink.offsetWidth > columnWidth) | |
187 urlLink.textContent = '…' + urlLink.textContent.substring(2); | |
188 } | |
189 }, | |
190 | |
191 /** | |
168 * Updates the data model for the saved passwords list with the values from | 192 * Updates the data model for the saved passwords list with the values from |
169 * |entries|. | 193 * |entries|. |
170 * @param {!Array} entries The list of saved password data. | 194 * @param {!Array} entries The list of saved password data. |
171 */ | 195 */ |
172 setSavedPasswordsList_: function(entries) { | 196 setSavedPasswordsList_: function(entries) { |
173 if (this.lastQuery_) { | 197 if (this.lastQuery_) { |
174 // Implement password searching here in javascript, rather than in C++. | 198 // Implement password searching here in javascript, rather than in C++. |
175 // The number of saved passwords shouldn't be too big for us to handle. | 199 // The number of saved passwords shouldn't be too big for us to handle. |
176 var query = this.lastQuery_; | 200 var query = this.lastQuery_; |
177 var filter = function(entry, index, list) { | 201 var filter = function(entry, index, list) { |
178 // Search both shown URL and username. | 202 // Search both shown URL and username. |
179 var shownUrl = entry[options.passwordManager.SHOWN_URL_FIELD]; | 203 var shownUrl = entry[options.passwordManager.SHOWN_URL_FIELD]; |
180 var username = entry[options.passwordManager.USERNAME_FIELD]; | 204 var username = entry[options.passwordManager.USERNAME_FIELD]; |
181 if (shownUrl.toLowerCase().indexOf(query.toLowerCase()) >= 0 || | 205 if (shownUrl.toLowerCase().indexOf(query.toLowerCase()) >= 0 || |
182 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) { | 206 username.toLowerCase().indexOf(query.toLowerCase()) >= 0) { |
183 // Keep the original index so we can delete correctly. See also | 207 // Keep the original index so we can delete correctly. See also |
184 // deleteItemAtIndex() in password_manager_list.js that uses this. | 208 // deleteItemAtIndex() in password_manager_list.js that uses this. |
185 entry[options.passwordManager.ORIGINAL_INDEX_FIELD] = index; | 209 entry[options.passwordManager.ORIGINAL_INDEX_FIELD] = index; |
186 return true; | 210 return true; |
187 } | 211 } |
188 return false; | 212 return false; |
189 }; | 213 }; |
190 entries = entries.filter(filter); | 214 entries = entries.filter(filter); |
191 } | 215 } |
192 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); | 216 this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
217 this.updateOriginsEliding_(this.savedPasswordsList_); | |
193 this.updateListVisibility_(this.savedPasswordsList_); | 218 this.updateListVisibility_(this.savedPasswordsList_); |
194 }, | 219 }, |
195 | 220 |
196 /** | 221 /** |
197 * Updates the data model for the password exceptions list with the values | 222 * Updates the data model for the password exceptions list with the values |
198 * from |entries|. | 223 * from |entries|. |
199 * @param {!Array} entries The list of password exception data. | 224 * @param {!Array} entries The list of password exception data. |
200 */ | 225 */ |
201 setPasswordExceptionsList_: function(entries) { | 226 setPasswordExceptionsList_: function(entries) { |
202 this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); | 227 this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); |
228 this.updateOriginsEliding_(this.passwordExceptionsList_); | |
203 this.updateListVisibility_(this.passwordExceptionsList_); | 229 this.updateListVisibility_(this.passwordExceptionsList_); |
204 }, | 230 }, |
205 | 231 |
206 /** | 232 /** |
207 * Reveals the password for a saved password entry. This is called by the | 233 * Reveals the password for a saved password entry. This is called by the |
208 * backend after it has authenticated the user. | 234 * backend after it has authenticated the user. |
209 * @param {number} index The original index of the entry in the model. | 235 * @param {number} index The original index of the entry in the model. |
210 * @param {string} password The saved password. | 236 * @param {string} password The saved password. |
211 */ | 237 */ |
212 showPassword_: function(index, password) { | 238 showPassword_: function(index, password) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 'setPasswordExceptionsList', | 284 'setPasswordExceptionsList', |
259 'showPassword' | 285 'showPassword' |
260 ]); | 286 ]); |
261 | 287 |
262 // Export | 288 // Export |
263 return { | 289 return { |
264 PasswordManager: PasswordManager | 290 PasswordManager: PasswordManager |
265 }; | 291 }; |
266 | 292 |
267 }); | 293 }); |
OLD | NEW |