Skip to content

Commit

Permalink
Merge pull request #15912 from mcav/stopwatch-wakelock
Browse files Browse the repository at this point in the history
Bug 966211 - Screen should not timeout when I have a running stopwatch. r=mcav
  • Loading branch information
mcav committed Feb 3, 2014
2 parents 86551a7 + 3c78864 commit 6901d4f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/clock/js/stopwatch_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ define(function(require) {
this.nodes = {};
this.lapTemplate = new Template('lap-list-item-tmpl');
this.interval = null;
this.screenWakeLock = null;

// Gather elements
[
Expand Down Expand Up @@ -169,6 +170,7 @@ define(function(require) {
tickfn();
this.showButtons('pause', 'lap');
this.hideButtons('start', 'resume', 'reset');
this.screenWakeLock = navigator.requestWakeLock('screen');
};

Stopwatch.Panel.prototype.onpause = function() {
Expand All @@ -177,6 +179,10 @@ define(function(require) {
this.nodes.reset.removeAttribute('disabled');
this.showButtons('resume', 'reset');
this.hideButtons('pause', 'start', 'lap');
if (this.screenWakeLock) {
this.screenWakeLock.unlock();
this.screenWakeLock = null;
}
};

Stopwatch.Panel.prototype.onresume = function() {
Expand Down

0 comments on commit 6901d4f

Please sign in to comment.