Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #14461 from arcturus/bug-946250
Browse files Browse the repository at this point in the history
Bug 946250 - When settings is invoked from messaging and closed from home button it does not recover its original status
  • Loading branch information
arcturus committed Dec 10, 2013
2 parents 8a2b8d0 + 3ebd249 commit 9ef1819
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions apps/settings/js/settings.js
Expand Up @@ -528,17 +528,21 @@ var Settings = {
// or by a visibility change (i.e. home button or app switch).
finishActivityRequest: function settings_finishActivityRequest() {
// Remove the dialog mark to restore settings status
// once the animation from the activity finish
var currentPanel = document.querySelector('[data-dialog]');
document.addEventListener('visibilitychange', function restore(evt) {
if (document.hidden) {
document.removeEventListener('visibilitychange', restore);
// Send a result to finish this activity
if (currentPanel !== null) {
delete currentPanel.dataset.dialog;
// once the animation from the activity finish.
// If we finish the activity pressing home, we will have a
// different animation and will be hidden before the animation
// ends.
if (document.hidden) {
this.restoreDOMFromActivty();
} else {
var self = this;
document.addEventListener('visibilitychange', function restore(evt) {
if (document.hidden) {
document.removeEventListener('visibilitychange', restore);
self.restoreDOMFromActivty();
}
}
});
});
}

// Send a result to finish this activity
if (Settings._currentActivity !== null) {
Expand All @@ -547,6 +551,15 @@ var Settings = {
}
},

// When we finish an activity we need to leave the DOM
// as it was before handling the activity.
restoreDOMFromActivty: function settings_restoreDOMFromActivity() {
var currentPanel = document.querySelector('[data-dialog]');
if (currentPanel !== null) {
delete currentPanel.dataset.dialog;
}
},

visibilityHandler: function settings_visibilityHandler(evt) {
if (document.hidden) {
Settings.finishActivityRequest();
Expand Down

0 comments on commit 9ef1819

Please sign in to comment.