OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 this.data.splice(position, 1); | 455 this.data.splice(position, 1); |
456 this.boxObject.rowCountChanged(position, -1); | 456 this.boxObject.rowCountChanged(position, -1); |
457 FilterView.addDummyRow(); | 457 FilterView.addDummyRow(); |
458 | 458 |
459 this.selectRow(position); | 459 this.selectRow(position); |
460 } | 460 } |
461 }, | 461 }, |
462 | 462 |
463 /** | 463 /** |
464 * Selects a row in the tree and makes sure it is visible. | 464 * Selects a row in the tree and makes sure it is visible. |
| 465 * @param {number} row |
| 466 * row index |
| 467 * @param {boolean} [scrollToTop] |
| 468 * if true, the selected row should become the top row of the list if |
| 469 * possible, otherwise the list is only scrolled if the row isn't visible. |
465 */ | 470 */ |
466 selectRow: function(row) | 471 selectRow: function(row, scrollToTop) |
467 { | 472 { |
468 if (this.selection) | 473 if (this.selection) |
469 { | 474 { |
470 row = Math.min(Math.max(row, 0), this.data.length - 1); | 475 row = Math.min(Math.max(row, 0), this.data.length - 1); |
471 this.selection.select(row); | 476 this.selection.select(row); |
472 this.boxObject.ensureRowIsVisible(row); | 477 if (scrollToTop) |
| 478 this.boxObject.scrollToRow(row); |
| 479 else |
| 480 this.boxObject.ensureRowIsVisible(row); |
473 } | 481 } |
474 }, | 482 }, |
475 | 483 |
476 /** | 484 /** |
477 * Finds a particular filter in the list and selects it. | 485 * Finds a particular filter in the list and selects it. |
478 */ | 486 */ |
479 selectFilter: function(/**Filter*/ filter) | 487 selectFilter: function(/**Filter*/ filter) |
480 { | 488 { |
481 let index = -1; | 489 let index = -1; |
482 for (let i = 0; i < this.data.length; i++) | 490 for (let i = 0; i < this.data.length; i++) |
483 { | 491 { |
484 if (this.data[i].filter == filter) | 492 if (this.data[i].filter == filter) |
485 { | 493 { |
486 index = i; | 494 index = i; |
487 break; | 495 break; |
488 } | 496 } |
489 } | 497 } |
490 if (index >= 0) | 498 if (index >= 0) |
491 { | 499 { |
492 this.selectRow(index); | 500 this.selectRow(index, true); |
493 this.treeElement.focus(); | 501 this.treeElement.focus(); |
494 } | 502 } |
495 }, | 503 }, |
496 | 504 |
497 /** | 505 /** |
498 * Updates value of data property on sorting or filter subscription changes. | 506 * Updates value of data property on sorting or filter subscription changes. |
499 */ | 507 */ |
500 updateData: function() | 508 updateData: function() |
501 { | 509 { |
502 let oldCount = this.rowCount; | 510 let oldCount = this.rowCount; |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 getProgressMode: () => null, | 842 getProgressMode: () => null, |
835 getImageSrc: () => null, | 843 getImageSrc: () => null, |
836 isSeparator: () => false, | 844 isSeparator: () => false, |
837 performAction: () => {}, | 845 performAction: () => {}, |
838 performActionOnRow: () => {}, | 846 performActionOnRow: () => {}, |
839 performActionOnCell: () => {}, | 847 performActionOnCell: () => {}, |
840 getCellValue: () => null, | 848 getCellValue: () => null, |
841 setCellValue: () => {}, | 849 setCellValue: () => {}, |
842 selectionChanged: () => {} | 850 selectionChanged: () => {} |
843 }; | 851 }; |
OLD | NEW |