Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / resources / pdf / ui_manager.js
blobf16535c81627a5a6e640a6fdc5d39ac2751c197b
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.
5 'use strict';
7 var HIDE_TIMEOUT = 2000;
9 /**
10 * Creates a UI Manager to handle transitioning of toolbars and panes.
11 * @constructor
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;
19 this.panes_ = panes;
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 = {
29 /**
30 * @private
31 * Display the toolbar and any pane that was previously opened.
33 showUi_: function() {
34 this.toolbar_.show();
35 for (var i = 0; i < this.panes_.length; i++)
36 this.panes_[i].showIfOpenedByUser();
38 this.hideUiAfterTimeout();
41 /**
42 * @private
43 * Hide the toolbar and any pane that was previously opened.
45 hideUi_: function() {
46 this.toolbar_.hide();
47 for (var i = 0; i < this.panes_.length; i++)
48 this.panes_[i].hideIfOpenedByUser();
51 /**
52 * Hide the toolbar after the HIDE_TIMEOUT has elapsed.
54 hideUiAfterTimeout: function() {
55 if (this.uiTimeout_)
56 clearTimeout(this.uiTimeout_);
57 this.uiTimeout_ = setTimeout(this.hideUi_.bind(this), HIDE_TIMEOUT);