OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** Idle time in ms before the UI is hidden. */ | 7 /** Idle time in ms before the UI is hidden. */ |
8 var HIDE_TIMEOUT = 2000; | 8 var HIDE_TIMEOUT = 2000; |
9 /** Time in ms after force hide before toolbar is shown again. */ | 9 /** Time in ms after force hide before toolbar is shown again. */ |
10 var FORCE_HIDE_TIMEOUT = 1000; | 10 var FORCE_HIDE_TIMEOUT = 1000; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 this.zoomToolbar_ = zoomToolbar; | 55 this.zoomToolbar_ = zoomToolbar; |
56 | 56 |
57 this.toolbarTimeout_ = null; | 57 this.toolbarTimeout_ = null; |
58 this.isMouseNearTopToolbar_ = false; | 58 this.isMouseNearTopToolbar_ = false; |
59 this.isMouseNearSideToolbar_ = false; | 59 this.isMouseNearSideToolbar_ = false; |
60 | 60 |
61 this.sideToolbarAllowedOnly_ = false; | 61 this.sideToolbarAllowedOnly_ = false; |
62 this.sideToolbarAllowedOnlyTimer_ = null; | 62 this.sideToolbarAllowedOnlyTimer_ = null; |
63 | 63 |
64 this.window_.addEventListener('resize', this.resizeDropdowns_.bind(this)); | 64 this.window_.addEventListener('resize', this.resizeDropdowns_.bind(this)); |
65 this.resizeDropdowns_(); | |
66 } | 65 } |
67 | 66 |
68 ToolbarManager.prototype = { | 67 ToolbarManager.prototype = { |
69 | 68 |
70 /** | 69 /** |
71 * Allow the toolbars to be shown. Should be called after the plugin has | 70 * Allow the toolbars to be shown. Should be called after the plugin has |
72 * loaded and we are ready to show a document. | 71 * loaded and we are ready to show a document. |
73 */ | 72 */ |
74 enableToolbars: function() { | 73 enableToolbars: function() { |
75 this.toolbar_.hidden = false; | 74 this.toolbar_.hidden = false; |
76 this.zoomToolbar_.hidden = false; | 75 this.zoomToolbar_.hidden = false; |
| 76 this.resizeDropdowns_(); |
77 }, | 77 }, |
78 | 78 |
79 showToolbarsForMouseMove: function(e) { | 79 showToolbarsForMouseMove: function(e) { |
80 this.isMouseNearTopToolbar_ = isMouseNearTopToolbar(e); | 80 this.isMouseNearTopToolbar_ = isMouseNearTopToolbar(e); |
81 this.isMouseNearSideToolbar_ = isMouseNearSideToolbar(e); | 81 this.isMouseNearSideToolbar_ = isMouseNearSideToolbar(e); |
82 | 82 |
83 // Allow the top toolbar to be shown if the mouse moves away from the side | 83 // Allow the top toolbar to be shown if the mouse moves away from the side |
84 // toolbar (as long as the timeout has elapsed). | 84 // toolbar (as long as the timeout has elapsed). |
85 if (!this.isMouseNearSideToolbar_ && !this.sideToolbarAllowedOnlyTimer_) | 85 if (!this.isMouseNearSideToolbar_ && !this.sideToolbarAllowedOnlyTimer_) |
86 this.sideToolbarAllowedOnly_ = false; | 86 this.sideToolbarAllowedOnly_ = false; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 /** | 160 /** |
161 * Updates the size of toolbar dropdowns based on the positions of the rest of | 161 * Updates the size of toolbar dropdowns based on the positions of the rest of |
162 * the UI. | 162 * the UI. |
163 * @private | 163 * @private |
164 */ | 164 */ |
165 resizeDropdowns_: function() { | 165 resizeDropdowns_: function() { |
166 var lowerBound = this.window_.innerHeight - this.zoomToolbar_.clientHeight; | 166 var lowerBound = this.window_.innerHeight - this.zoomToolbar_.clientHeight; |
167 this.toolbar_.setDropdownLowerBound(lowerBound); | 167 this.toolbar_.setDropdownLowerBound(lowerBound); |
168 } | 168 } |
169 }; | 169 }; |
OLD | NEW |