Browse files

Merge remote branch 'origin/visibility' into visibility

  • Loading branch information...
2 parents f7a33d9 + 81e311a commit 1c699c4b2121cf72adce7e9ce0fb06862caa28f0 @vingtetun vingtetun committed Jun 5, 2012
Showing with 6 additions and 25 deletions.
  1. +6 −6 apps/dialer/js/dialer.js
  2. +0 −19 apps/dialer/js/helper.js
View
12 apps/dialer/js/dialer.js
@@ -10,8 +10,8 @@ var gTonesFrequencies = {
'*': [941, 1209], '0': [941, 1336], '#': [941, 1477]
};
-function visibilityChanged(url, evt) {
- var data = evt.data;
+document.addEventListener('mozvisibilitychange', function visibility(e) {
+ var url = document.location.href;
var params = (function makeURL() {
var a = document.createElement('a');
a.href = url;
@@ -25,7 +25,9 @@ function visibilityChanged(url, evt) {
return rv;
})();
- if (!data.hidden) {
+ if (document.mozHidden) {
+ Recents.stopUpdatingDates();
+ } else {
Recents.startUpdatingDates();
var choice = params['choice'];
@@ -34,10 +36,8 @@ function visibilityChanged(url, evt) {
Contacts.load();
choiceChanged(contacts);
}
- } else {
- Recents.stopUpdatingDates();
}
-}
+});
function choiceChanged(target) {
var choice = target.dataset.choice;
View
19 apps/dialer/js/helper.js
@@ -23,22 +23,3 @@ function prettyDate(time) {
day_diff < 7 && (new Date(time)).toLocaleFormat('%A') ||
(new Date(time)).toLocaleFormat('%x');
}
-
-(function() {
- var updatePrettyDate = function updatePrettyDate() {
- var labels = document.querySelectorAll('[data-time]');
- var i = labels.length;
- while (i--) {
- labels[i].textContent = prettyDate(labels[i].dataset.time);
- }
- };
- var timer = setInterval(updatePrettyDate, 60 * 1000);
-
- document.addEventListener('mozvisibilitychange', function visibility(e) {
- clearTimeout(timer);
- if (!document.mozHidden) {
- updatePrettyDate();
- timer = setInterval(updatePrettyDate, 60 * 1000);
- }
- });
-})();

0 comments on commit 1c699c4

Please sign in to comment.