Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1055)

Side by Side Diff: chrome/browser/resources/options/language_list.js

Issue 1617243004: Stop checking for null selectionModel field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ArrayDataModel = cr.ui.ArrayDataModel; 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
7 /** @const */ var DeletableItem = options.DeletableItem; 7 /** @const */ var DeletableItem = options.DeletableItem;
8 /** @const */ var DeletableItemList = options.DeletableItemList; 8 /** @const */ var DeletableItemList = options.DeletableItemList;
9 /** @const */ var List = cr.ui.List; 9 /** @const */ var List = cr.ui.List;
10 /** @const */ var ListItem = cr.ui.ListItem; 10 /** @const */ var ListItem = cr.ui.ListItem;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 * @private 388 * @private
389 */ 389 */
390 load_: function(languageCodes) { 390 load_: function(languageCodes) {
391 // Preserve the original selected index. See comments below. 391 // Preserve the original selected index. See comments below.
392 var originalSelectedIndex = (this.selectionModel ? 392 var originalSelectedIndex = (this.selectionModel ?
393 this.selectionModel.selectedIndex : -1); 393 this.selectionModel.selectedIndex : -1);
394 this.dataModel = new ArrayDataModel(languageCodes); 394 this.dataModel = new ArrayDataModel(languageCodes);
395 if (originalSelectedIndex >= 0 && 395 if (originalSelectedIndex >= 0 &&
396 originalSelectedIndex < this.dataModel.length) { 396 originalSelectedIndex < this.dataModel.length) {
397 // Restore the original selected index if the selected index is 397 // Restore the original selected index if the selected index is
398 // valid after the data model is loaded. This is neeeded to keep 398 // valid after the data model is loaded. This is neeeded to keep
Dan Beam 2016/01/25 23:27:16 needed
Kevin Bailey 2016/01/26 15:00:40 Done.
399 // the selected language after the languge is added or removed. 399 // the selected language after the languge is added or removed.
400 this.selectionModel.selectedIndex = originalSelectedIndex; 400 this.selectionModel.selectedIndex = originalSelectedIndex;
401 // The lead index should be updated too. 401 // The lead index should be updated too.
402 this.selectionModel.leadIndex = originalSelectedIndex; 402 this.selectionModel.leadIndex = originalSelectedIndex;
403 } else if (this.dataModel.length > 0) {
404 // Otherwise, select the first item if it's not empty.
405 // Note that ListSingleSelectionModel won't select an item
406 // automatically, hence we manually select the first item here.
Dan Beam 2016/01/25 23:27:16 this is why selectedIndex starts as -1: https://co
407 this.selectionModel.selectedIndex = 0;
Kevin Bailey 2016/01/22 15:12:50 While looking around, trying to figure out how sto
please use gerrit instead 2016/01/22 18:31:09 I defer to Dan as the resident JS expert.
Dan Beam 2016/01/25 23:27:16 this is where selectionModel is created (on page l
408 } 403 }
409 }, 404 },
410 405
411 /** 406 /**
412 * Saves the preference. 407 * Saves the preference.
413 */ 408 */
414 savePreference_: function() { 409 savePreference_: function() {
415 chrome.send('updateLanguageList', [this.dataModel.slice()]); 410 chrome.send('updateLanguageList', [this.dataModel.slice()]);
416 cr.dispatchSimpleEvent(this, 'save'); 411 cr.dispatchSimpleEvent(this, 'save');
417 }, 412 },
(...skipping 18 matching lines...) Expand all
436 } 431 }
437 return filteredLanguageCodes; 432 return filteredLanguageCodes;
438 }, 433 },
439 }; 434 };
440 435
441 return { 436 return {
442 LanguageList: LanguageList, 437 LanguageList: LanguageList,
443 LanguageListItem: LanguageListItem 438 LanguageListItem: LanguageListItem
444 }; 439 };
445 }); 440 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698