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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/file_list_selection_model.js

Issue 962103002: Files.app: Introduce check-select mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove remaining debug log. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/foreground/js/ui/file_list_selection_model.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_list_selection_model.js b/ui/file_manager/file_manager/foreground/js/ui/file_list_selection_model.js
new file mode 100644
index 0000000000000000000000000000000000000000..77589fb956dc7bbc2cfc97c43e9caa0c10dae695
--- /dev/null
+++ b/ui/file_manager/file_manager/foreground/js/ui/file_list_selection_model.js
@@ -0,0 +1,89 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @param {number=} opt_length The number items in the selection.
+ * @constructor
+ * @extends {cr.ui.ListSelectionModel}
+ * @struct
+ * @suppress {checkStructDictInheritance}
+ */
+function FileListSelectionModel(opt_length) {
+ cr.ui.ListSelectionModel.call(this, opt_length);
+
+ /** @private {boolean} */
+ this.isCheckSelectMode_ = false;
+
+ this.addEventListener('change', this.onChangeEvent_.bind(this));
+}
+
+FileListSelectionModel.prototype = /** @struct */ {
+ __proto__: cr.ui.ListSelectionModel.prototype
+};
+
+/**
+ * Updates the check-select mode.
+ * @param {boolean} enabled True if check-select mode should be enabled.
+ */
+FileListSelectionModel.prototype.setCheckSelectMode = function(enabled) {
+ this.isCheckSelectMode_ = enabled;
+};
+
+/**
+ * Gets the check-select mode.
+ * @return {boolean} True if check-select mode is enabled.
+ */
+FileListSelectionModel.prototype.getCheckSelectMode = function() {
+ return this.isCheckSelectMode_;
+};
+
+/**
+ * Handles change event to update isCheckSelectMode_ BEFORE the change event is
+ * dispatched to other listeners.
+ * @param {!Event} event Event object of 'change' event.
+ * @private
+ */
+FileListSelectionModel.prototype.onChangeEvent_ = function(event) {
+ // When the number of selected item is not one, update che check-select mode.
+ // When the number of selected item is one, the mode depends on the last
+ // keyboard/mouse operation. In this case, the mode is controlled from
+ // outside. See filelist.handlePointerDownUp and filelist.handleKeyDown.
+ var selectedIndexes = this.selectedIndexes;
+ if (selectedIndexes.length === 0) {
+ this.isCheckSelectMode_ = false;
+ } else if (selectedIndexes.length >= 2) {
+ this.isCheckSelectMode_ = true;
+ }
+};
+
+/**
+ * @param {number=} opt_length The number items in the selection.
+ * @constructor
+ * @extends {cr.ui.ListSingleSelectionModel}
+ * @struct
+ * @suppress {checkStructDictInheritance}
+ */
+function FileListSingleSelectionModel(opt_length) {
+ cr.ui.ListSingleSelectionModel.call(this, opt_length);
+}
+
+FileListSingleSelectionModel.prototype = /** @struct */ {
+ __proto__: cr.ui.ListSingleSelectionModel.prototype
+};
+
+/**
+ * Updates the check-select mode.
+ * @param {boolean} enabled True if check-select mode should be enabled.
+ */
+FileListSingleSelectionModel.prototype.setCheckSelectMode = function(enabled) {
+ // Do nothing, as check-select mode is invalid in single selection model.
+};
+
+/**
+ * Gets the check-select mode.
+ * @return {boolean} True if check-select mode is enabled.
+ */
+FileListSingleSelectionModel.prototype.getCheckSelectMode = function() {
+ return false;
+};

Powered by Google App Engine
This is Rietveld 408576698