Commit aedac22a authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

[Files app] Convert to ES6 classes file file_table_list.js

Manual edit:
- change to reset onMergeItems_ inside FileTabledecorate because that
replaces the class constructor.
- remove closure markup @struct and @extends because they aren't needed
with ES6 class (they're implicit).

CL 3 of 4.

Bug: 778674
Change-Id: Iddbc2278b700f55588b85567aa9fbbe25a595b3f
Reviewed-on: https://chromium-review.googlesource.com/c/1460200
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630456}
parent 02171e5a
......@@ -9,40 +9,30 @@ const filelist = {};
/**
* File table list.
* @constructor
* @struct
* @extends {cr.ui.table.TableList}
*/
function FileTableList() {
throw new Error('Designed to decorate elements');
}
/**
* Decorates TableList as FileTableList.
* @param {!cr.ui.table.TableList} self A tabel list element.
*/
FileTableList.decorate = self => {
self.__proto__ = FileTableList.prototype;
};
FileTableList.prototype.__proto__ = cr.ui.table.TableList.prototype;
/**
class FileTableList extends cr.ui.table.TableList {
constructor() {
// To silence closure compiler.
super();
/*
* @type {?function(number, number)}
*/
FileTableList.prototype.onMergeItems_ = null;
this.onMergeItems_ = null;
/**
throw new Error('Designed to decorate elements');
}
/**
* @param {function(number, number)} onMergeItems callback called from
* |mergeItems| with the parameters |beginIndex| and |endIndex|.
*/
FileTableList.prototype.setOnMergeItems = function(onMergeItems) {
setOnMergeItems(onMergeItems) {
assert(!this.onMergeItems_);
this.onMergeItems_ = onMergeItems;
};
}
/** @override */
FileTableList.prototype.mergeItems = function(beginIndex, endIndex) {
/** @override */
mergeItems(beginIndex, endIndex) {
cr.ui.table.TableList.prototype.mergeItems.call(this, beginIndex, endIndex);
// Make sure that list item's selected attribute is updated just after the
......@@ -62,23 +52,34 @@ FileTableList.prototype.mergeItems = function(beginIndex, endIndex) {
if (this.onMergeItems_) {
this.onMergeItems_(beginIndex, endIndex);
}
};
}
/** @override */
FileTableList.prototype.createSelectionController = function(sm) {
/** @override */
createSelectionController(sm) {
return new FileListSelectionController(assert(sm));
}
}
/**
* Decorates TableList as FileTableList.
* @param {!cr.ui.table.TableList} self A tabel list element.
*/
FileTableList.decorate = self => {
self.__proto__ = FileTableList.prototype;
self.onMergeItems_ = null;
};
/**
* Selection controller for the file table list.
*/
class FileListSelectionController extends cr.ui.ListSelectionController {
/**
* @param {!cr.ui.ListSelectionModel} selectionModel The selection model to
* interact with.
* @constructor
* @extends {cr.ui.ListSelectionController}
* @struct
*/
function FileListSelectionController(selectionModel) {
cr.ui.ListSelectionController.call(this, selectionModel);
constructor(selectionModel) {
super(selectionModel);
//cr.ui.ListSelectionController.call(this, selectionModel);
/**
* Whether to allow touch-specific interaction.
......@@ -94,19 +95,15 @@ function FileListSelectionController(selectionModel) {
* @const
*/
this.tapHandler_ = new FileTapHandler();
}
FileListSelectionController.prototype = /** @struct */ {
__proto__: cr.ui.ListSelectionController.prototype
};
}
/** @override */
FileListSelectionController.prototype.handlePointerDownUp = function(e, index) {
/** @override */
handlePointerDownUp(e, index) {
filelist.handlePointerDownUp.call(this, e, index);
};
}
/** @override */
FileListSelectionController.prototype.handleTouchEvents = function(e, index) {
/** @override */
handleTouchEvents(e, index) {
if (!this.enableTouchMode_) {
return;
}
......@@ -117,12 +114,13 @@ FileListSelectionController.prototype.handleTouchEvents = function(e, index) {
// list. So we do that here explicitly.
filelist.focusParentList(e);
}
};
}
/** @override */
FileListSelectionController.prototype.handleKeyDown = function(e) {
/** @override */
handleKeyDown(e) {
filelist.handleKeyDown.call(this, e);
};
}
}
/**
* Common item decoration for table's and grid's items.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment