1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 var HIDE_TIMEOUT = 2000;
10 * Creates a UI Manager to handle transitioning of toolbars and panes.
12 * @param {Object} window The window containing the UI.
13 * @param {Object} toolbar The toolbar element.
14 * @param {Array} panes The panes that may be pulled in.
16 function UiManager(window, toolbar, panes) {
17 this.window_ = window;
18 this.toolbar_ = toolbar;
21 this.uiTimeout_ = null;
23 var userInputs = ['click', 'keydown', 'mousemove', 'scroll'];
24 for (var i = 0; i < userInputs.length; i++)
25 this.window_.addEventListener(userInputs[i], this.showUi_.bind(this));
28 UiManager.prototype = {
31 * Display the toolbar and any pane that was previously opened.
35 for (var i = 0; i < this.panes_.length; i++)
36 this.panes_[i].showIfOpenedByUser();
38 this.hideUiAfterTimeout();
43 * Hide the toolbar and any pane that was previously opened.
47 for (var i = 0; i < this.panes_.length; i++)
48 this.panes_[i].hideIfOpenedByUser();
52 * Hide the toolbar after the HIDE_TIMEOUT has elapsed.
54 hideUiAfterTimeout: function() {
56 clearTimeout(this.uiTimeout_);
57 this.uiTimeout_ = setTimeout(this.hideUi_.bind(this), HIDE_TIMEOUT);