| 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);
|
| +};
|
|
|