summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/web
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2016-05-12 21:22:51 +0200
committerDavid Lawrence <dkl@mozilla.com>2016-05-12 21:22:51 +0200
commit44a2e60b4f7030a06471a03699e2a167875f250e (patch)
tree31feaf091280d583fe043ae693a709df508600e7 /extensions/BugModal/web
parent6a48e0211dec6ec2d5a73ad1982682b744fb3474 (diff)
downloadbugzilla-44a2e60b4f7030a06471a03699e2a167875f250e.tar.gz
bugzilla-44a2e60b4f7030a06471a03699e2a167875f250e.tar.xz
Bug 1270295 - don't update timestamps when the tab is not active / in the background
Diffstat (limited to 'extensions/BugModal/web')
-rw-r--r--extensions/BugModal/web/bug_modal.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js
index e0ef40a13..6c10c6fb0 100644
--- a/extensions/BugModal/web/bug_modal.js
+++ b/extensions/BugModal/web/bug_modal.js
@@ -51,7 +51,16 @@ $(function() {
'use strict';
// update relative dates
- window.setInterval(function() {
+ var relative_timer_duration = 60000;
+ var relative_timer_id = window.setInterval(relativeTimer, relative_timer_duration);
+ $(document).on('show.visibility', function() {
+ relative_timer_id = window.setInterval(relativeTimer, relative_timer_duration)
+ });
+ $(document).on('hide.visibility', function() {
+ window.clearInterval(relative_timer_id);
+ });
+
+ function relativeTimer() {
var now = Math.floor(new Date().getTime() / 1000);
$('.rel-time').each(function() {
$(this).text(timeAgo(now - $(this).data('time')));
@@ -59,7 +68,7 @@ $(function() {
$('.rel-time-title').each(function() {
$(this).attr('title', timeAgo(now - $(this).data('time')));
});
- }, 60000);
+ }
// all keywords for autocompletion (lazy-loaded on edit)
var keywords = [];