This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15842 from lodr/bug-963682-providing-ux-for-non-r…
…eady-sim Bug 963682 - Providing a fake modal dialog to prevent the user to interact with the application unless the SIM is ready. r=mai (cherry picked from commit 397f3aa)
- Loading branch information
1 parent
4cc9855
commit bb36b41
Showing
7 changed files
with
325 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use strict'; | ||
|
||
/* global Common */ | ||
/* global _ */ | ||
|
||
function NonReadyScreen(container) { | ||
this.id = container.id; | ||
this.container = container; | ||
this.activity = container.querySelector('progress'); | ||
this.header = container.querySelector('h3'); | ||
this.message = container.querySelector('p'); | ||
this.button = container.querySelector('button'); | ||
|
||
this.button.onclick = Common.closeApplication; | ||
} | ||
|
||
// Configure the non ready screen depending on the card status. For | ||
// absent, pinRequired and pukRequired, shows a message and give the | ||
// user the opportunity to close the app. For other states, it shows | ||
// a progress spinner. | ||
NonReadyScreen.prototype.updateForState = function(cardState) { | ||
switch (cardState) { | ||
case null: | ||
case 'absent': | ||
case 'pinRequired': | ||
case 'pukRequired': | ||
this.setMessageMode(cardState); | ||
break; | ||
|
||
default: | ||
this.setWaitingMode(); | ||
break; | ||
} | ||
}; | ||
|
||
NonReadyScreen.prototype.setMessageMode = function(cardState) { | ||
this.activity.setAttribute('aria-hidden', true); | ||
[this.header, this.message, this.button.parentNode].forEach(function (el) { | ||
el.setAttribute('aria-hidden', false); | ||
}); | ||
|
||
var messageId = this.getMessageIdFor(cardState); | ||
if (messageId) { | ||
var header = _('widget-' + messageId + '-heading'); | ||
var msg = _('widget-' + messageId + '-meta'); | ||
this.header.textContent = header; | ||
this.message.textContent = msg; | ||
} | ||
}; | ||
|
||
NonReadyScreen.prototype.setWaitingMode = function() { | ||
this.activity.setAttribute('aria-hidden', false); | ||
[this.header, this.message, this.button.parentNode].forEach(function (el) { | ||
el.setAttribute('aria-hidden', true); | ||
}); | ||
}; | ||
|
||
NonReadyScreen.prototype.getMessageIdFor = function(cardState) { | ||
var message; | ||
|
||
// SIM is absent | ||
if (!cardState || cardState === 'absent') { | ||
message = 'no-sim2'; | ||
|
||
// SIM is locked | ||
} else if ( | ||
cardState === 'pinRequired' || | ||
cardState === 'pukRequired' | ||
) { | ||
message = 'sim-locked'; | ||
} | ||
|
||
return message; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
function MockNonReadyScreen(container) { | ||
this.id = container.id; | ||
} | ||
|
||
MockNonReadyScreen.prototype.updateForState = function(cardState) { | ||
var event = new CustomEvent('nonReadyScreenUpdated', { detail: cardState }); | ||
window.dispatchEvent(event); | ||
console.log('NonReadyScreen in state: ' + cardState); | ||
}; |
Oops, something went wrong.