OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * A controller class detects mouse inactivity and hides "tool" elements. | 6 * A controller class detects mouse inactivity and hides "tool" elements. |
7 * | 7 * |
8 * @param {Element} container The main DOM container. | 8 * @param {Element} container The main DOM container. |
9 * @param {number} opt_timeout Hide timeout in ms. | 9 * @param {number} opt_timeout Hide timeout in ms. |
10 * @param {function():boolean=} opt_toolsActive Function that returns |true| | 10 * @param {function():boolean=} opt_toolsActive Function that returns |true| |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 * @param {boolean} on True if show, false if hide. | 60 * @param {boolean} on True if show, false if hide. |
61 */ | 61 */ |
62 MouseInactivityWatcher.prototype.showTools = function(on) { | 62 MouseInactivityWatcher.prototype.showTools = function(on) { |
63 if (on) | 63 if (on) |
64 this.container_.setAttribute('tools', 'true'); | 64 this.container_.setAttribute('tools', 'true'); |
65 else | 65 else |
66 this.container_.removeAttribute('tools'); | 66 this.container_.removeAttribute('tools'); |
67 }; | 67 }; |
68 | 68 |
69 /** | 69 /** |
70 * @param {Element} element DOM element | 70 * @param {Element} element DOM element. |
71 * @return {boolean} True if the element is a tool. Tools should never be hidden | 71 * @return {boolean} True if the element is a tool. Tools should never be hidden |
72 * while the mouse is over one of them. | 72 * while the mouse is over one of them. |
73 */ | 73 */ |
74 MouseInactivityWatcher.prototype.isToolElement = function(element) { | 74 MouseInactivityWatcher.prototype.isToolElement = function(element) { |
75 return element.classList.contains('tool'); | 75 return element.classList.contains('tool'); |
76 }; | 76 }; |
77 | 77 |
78 /** | 78 /** |
79 * To be called when the user started activity. Shows the tools | 79 * To be called when the user started activity. Shows the tools |
80 * and cancels the countdown. | 80 * and cancels the countdown. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 /** | 158 /** |
159 * Timeout handler. | 159 * Timeout handler. |
160 * @private | 160 * @private |
161 */ | 161 */ |
162 MouseInactivityWatcher.prototype.onTimeout_ = function() { | 162 MouseInactivityWatcher.prototype.onTimeout_ = function() { |
163 this.timeoutID_ = null; | 163 this.timeoutID_ = null; |
164 if (!this.disabled_ && !this.toolsActive_()) | 164 if (!this.disabled_ && !this.toolsActive_()) |
165 this.showTools(false); | 165 this.showTools(false); |
166 }; | 166 }; |
OLD | NEW |