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

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

Issue 695883002: Create ListContainer and SpinnerController class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 6 years, 1 month 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/spinner_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/spinner_controller.js b/ui/file_manager/file_manager/foreground/js/spinner_controller.js
new file mode 100644
index 0000000000000000000000000000000000000000..60e953d09b722a7a35753e2c3f68e77fc28be5a4
--- /dev/null
+++ b/ui/file_manager/file_manager/foreground/js/spinner_controller.js
@@ -0,0 +1,67 @@
+// Copyright 2014 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.
+
+/**
+ * Controller for spinner.
+ * @param {!HTMLElement} element
+ * @param {!DirectoryModel} directoryModel
+ * @constructor
+ */
+function SpinnerController(element, directoryModel) {
+ /**
+ * The container element of the file list.
+ * @type {!HTMLElement}
+ * @const
+ * @private
+ */
+ this.element_ = element;
+
+ /**
+ * Directory model.
+ * @type {!DirectoryModel}
+ * @const
+ * @private
+ */
+ this.directoryModel_ = directoryModel;
+
+ /**
+ * @type {number}
+ * @private
+ */
+ this.timeoutId_ = 0;
+}
+
+/**
+ * Shows the spinner.
+ */
+SpinnerController.prototype.show = function() {
+ if (!this.directoryModel_.isScanning())
+ return;
+ this.element_.hidden = false;
+ clearTimeout(this.timeoutId_);
+ this.timeoutId_ = 0;
+};
+
+/**
+ * Hides the spinner.
+ */
+SpinnerController.prototype.hide = function() {
+ if (this.directoryModel_.isScanning() &&
+ this.directoryModel_.getFileList().length == 0) {
+ return;
+ }
+ this.element_.hidden = true;
+ clearTimeout(this.timeoutId_);
+ this.timeoutId_ = 0;
+};
+
+/**
+ * Shows the spinner after 500ms.
+ */
+SpinnerController.prototype.showLater = function() {
+ if (!this.element_.hidden)
+ return;
+ clearTimeout(this.timeoutId_);
+ this.timeoutId_ = setTimeout(this.show.bind(this), 500);
+};

Powered by Google App Engine
This is Rietveld 408576698