Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: chrome/browser/resources/file_manager/js/media/util.js

Issue 10834354: Refactor the Photo Editor to enable new feature work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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|
11 * if the tools are active and should not be hidden.
10 * @constructor 12 * @constructor
11 */ 13 */
12 function MouseInactivityWatcher(container, opt_timeout) { 14 function MouseInactivityWatcher(container, opt_timeout, opt_toolsActive) {
13 this.container_ = container; 15 this.container_ = container;
14 this.timeout_ = opt_timeout || MouseInactivityWatcher.DEFAULT_TIMEOUT; 16 this.timeout_ = opt_timeout || MouseInactivityWatcher.DEFAULT_TIMEOUT;
17 this.toolsActive_ = opt_toolsActive || function() { return false };
15 18
16 this.onTimeoutBound_ = this.onTimeout_.bind(this); 19 this.onTimeoutBound_ = this.onTimeout_.bind(this);
17 this.timeoutID_ = null; 20 this.timeoutID_ = null;
18 this.mouseOverTool_ = false; 21 this.mouseOverTool_ = false;
19 22
20 this.container_.addEventListener('mousemove', this.onMouseMove_.bind(this)); 23 this.container_.addEventListener('mousemove', this.onMouseMove_.bind(this));
21 } 24 }
22 25
23 /** 26 /**
24 * Default inactivity timeout. 27 * Default inactivity timeout.
(...skipping 30 matching lines...) Expand all
55 clearTimeout(this.timeoutID_); 58 clearTimeout(this.timeoutID_);
56 this.timeoutID_ = null; 59 this.timeoutID_ = null;
57 } 60 }
58 }; 61 };
59 62
60 /** 63 /**
61 * Called when user activity has stopped. Re-starts the countdown. 64 * Called when user activity has stopped. Re-starts the countdown.
62 * @param {number} opt_timeout Timeout. 65 * @param {number} opt_timeout Timeout.
63 */ 66 */
64 MouseInactivityWatcher.prototype.stopActivity = function(opt_timeout) { 67 MouseInactivityWatcher.prototype.stopActivity = function(opt_timeout) {
65 if (this.mouseOverTool_) 68 if (this.mouseOverTool_ || this.toolsActive_())
66 return; 69 return;
67 70
68 if (this.timeoutID_) 71 if (this.timeoutID_)
69 clearTimeout(this.timeoutID_); 72 clearTimeout(this.timeoutID_);
70 73
71 this.timeoutID_ = setTimeout( 74 this.timeoutID_ = setTimeout(
72 this.onTimeoutBound_, opt_timeout || this.timeout_); 75 this.onTimeoutBound_, opt_timeout || this.timeout_);
73 }; 76 };
74 77
75 /** 78 /**
(...skipping 23 matching lines...) Expand all
99 102
100 this.stopActivity(); 103 this.stopActivity();
101 }; 104 };
102 105
103 /** 106 /**
104 * Timeout handler. 107 * Timeout handler.
105 * @private 108 * @private
106 */ 109 */
107 MouseInactivityWatcher.prototype.onTimeout_ = function() { 110 MouseInactivityWatcher.prototype.onTimeout_ = function() {
108 this.timeoutID_ = null; 111 this.timeoutID_ = null;
109 this.showTools(false); 112 if (!this.toolsActive_())
113 this.showTools(false);
110 }; 114 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698