summaryrefslogtreecommitdiffstats
path: root/extensions
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
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')
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/header.html.tmpl1
-rw-r--r--extensions/BugModal/web/bug_modal.js13
2 files changed, 12 insertions, 2 deletions
diff --git a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
index 84efbd077..48064f06c 100644
--- a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
@@ -60,6 +60,7 @@
jquery.push(
"datetimepicker",
"contextMenu",
+ "visibility"
);
style_urls.push(
"extensions/BugModal/web/bug_modal.css",
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 = [];