diff --git a/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js b/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js index 288acfdce8b2c4..a2c1542a1d906d 100644 --- a/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js +++ b/ui/file_manager/file_manager/foreground/js/mock_thumbnail_loader.js @@ -4,19 +4,39 @@ /** * Mock thumbnail loader. - * - * @param {Entry} entry An entry. - * @param {ThumbnailLoader.LoaderType=} opt_loaderType Loader type. - * @param {Object=} opt_metadata Metadata. - * @param {string=} opt_mediaType Media type. - * @param {Array=} opt_loadTargets Load targets. - * @param {number=} opt_priority Priority. - * @constructor */ -function MockThumbnailLoader( - entry, opt_loaderType, opt_metadata, opt_mediaType, opt_loadTargets, - opt_priority) { - this.entry_ = entry; +class MockThumbnailLoader { + /** + * @param {Entry} entry An entry. + * @param {ThumbnailLoader.LoaderType=} opt_loaderType Loader type. + * @param {Object=} opt_metadata Metadata. + * @param {string=} opt_mediaType Media type. + * @param {Array=} opt_loadTargets Load targets. + * @param {number=} opt_priority Priority. + */ + constructor( + entry, opt_loaderType, opt_metadata, opt_mediaType, opt_loadTargets, + opt_priority) { + this.entry_ = entry; + } + + /** + * Loads thumbnail as data url. + * + * @return {!Promise<{data:?string, width:number, height:number}>} A + * promise which is resolved with data url. + */ + loadAsDataUrl() { + if (MockThumbnailLoader.errorUrls.indexOf(this.entry_.toURL()) !== -1) { + throw new Error('Failed to load thumbnail.'); + } + + return Promise.resolve({ + data: MockThumbnailLoader.testImageDataUrl, + width: MockThumbnailLoader.testImageWidth, + height: MockThumbnailLoader.testImageHeight + }); + } } /** @@ -42,21 +62,3 @@ MockThumbnailLoader.testImageHeight = 0; * @private {Array} */ MockThumbnailLoader.errorUrls = []; - -/** - * Loads thumbnail as data url. - * - * @return {!Promise<{data:?string, width:number, height:number}>} A - * promise which is resolved with data url. - */ -MockThumbnailLoader.prototype.loadAsDataUrl = function() { - if (MockThumbnailLoader.errorUrls.indexOf(this.entry_.toURL()) !== -1) { - throw new Error('Failed to load thumbnail.'); - } - - return Promise.resolve({ - data: MockThumbnailLoader.testImageDataUrl, - width: MockThumbnailLoader.testImageWidth, - height: MockThumbnailLoader.testImageHeight - }); -}; diff --git a/ui/file_manager/file_manager/foreground/js/selection_menu_controller.js b/ui/file_manager/file_manager/foreground/js/selection_menu_controller.js index 1993848f389c8d..1d852317d90cfa 100644 --- a/ui/file_manager/file_manager/foreground/js/selection_menu_controller.js +++ b/ui/file_manager/file_manager/foreground/js/selection_menu_controller.js @@ -2,51 +2,53 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -/** - * @param {!cr.ui.MenuButton} selectionMenuButton - * @param {!cr.ui.Menu} menu - * @constructor - * @struct - */ -function SelectionMenuController(selectionMenuButton, menu) { +class SelectionMenuController { /** - * @type {!FilesToggleRipple} - * @const - * @private + * @param {!cr.ui.MenuButton} selectionMenuButton + * @param {!cr.ui.Menu} menu */ - this.toggleRipple_ = - /** @type {!FilesToggleRipple} */ ( - queryRequiredElement('files-toggle-ripple', selectionMenuButton)); + constructor(selectionMenuButton, menu) { + /** + * @type {!FilesToggleRipple} + * @const + * @private + */ + this.toggleRipple_ = + /** @type {!FilesToggleRipple} */ ( + queryRequiredElement('files-toggle-ripple', selectionMenuButton)); - /** - * @type {!cr.ui.Menu} - * @const - */ - this.menu_ = menu; + /** + * @type {!cr.ui.Menu} + * @const + */ + this.menu_ = menu; - selectionMenuButton.addEventListener('menushow', this.onShowMenu_.bind(this)); - selectionMenuButton.addEventListener('menuhide', this.onHideMenu_.bind(this)); -} + selectionMenuButton.addEventListener( + 'menushow', this.onShowMenu_.bind(this)); + selectionMenuButton.addEventListener( + 'menuhide', this.onHideMenu_.bind(this)); + } -/** - * @private - */ -SelectionMenuController.prototype.onShowMenu_ = function() { - this.menu_.classList.toggle('toolbar-menu', true); - this.toggleRipple_.activated = true; - // crbug.com 752035 focus still on button, get rid of the tooltip - document.querySelector('files-tooltip').hideTooltip(); -}; + /** + * @private + */ + onShowMenu_() { + this.menu_.classList.toggle('toolbar-menu', true); + this.toggleRipple_.activated = true; + // crbug.com 752035 focus still on button, get rid of the tooltip + document.querySelector('files-tooltip').hideTooltip(); + } -/** - * @private - */ -SelectionMenuController.prototype.onHideMenu_ = function() { - // If menu is animating to close, then do not remove 'toolbar-menu' yet, it - // will be removed at the end of FilesMenuItem.setMenuAsAnimating_ to avoid - // flicker. See crbug.com/862926. - if (!this.menu_.classList.contains('animating')) { - this.menu_.classList.toggle('toolbar-menu', false); + /** + * @private + */ + onHideMenu_() { + // If menu is animating to close, then do not remove 'toolbar-menu' yet, it + // will be removed at the end of FilesMenuItem.setMenuAsAnimating_ to avoid + // flicker. See crbug.com/862926. + if (!this.menu_.classList.contains('animating')) { + this.menu_.classList.toggle('toolbar-menu', false); + } + this.toggleRipple_.activated = false; } - this.toggleRipple_.activated = false; -}; +}