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 #5820 from alivedise/bugzilla/800689/modal-dialog-…
Browse files Browse the repository at this point in the history
…with-inline-activity

Bug 800689 - Support modal dialogs (alert/prompt/confirm) from inline activity frames
  • Loading branch information
alivedise committed Oct 16, 2012
2 parents e635c52 + dd01e08 commit ac94981
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/system/js/modal_dialog.js
Expand Up @@ -58,6 +58,8 @@ var ModalDialog = {
window.addEventListener('resize', this);
window.addEventListener('keyboardchange', this);
window.addEventListener('keyboardhide', this);
window.addEventListener('home', this);
window.addEventListener('holdhome', this);

for (var id in elements) {
var tagName = elements[id].tagName.toLowerCase();
Expand All @@ -73,7 +75,8 @@ var ModalDialog = {
switch (evt.type) {
case 'mozbrowsererror':
case 'mozbrowsershowmodalprompt':
if (evt.target.dataset.frameType != 'window')
var frameType = evt.target.dataset.frameType;
if (frameType != 'window' && frameType != 'inline-activity')
return;

/* fatal case (App crashing) is handled in Window Manager */
Expand All @@ -86,7 +89,8 @@ var ModalDialog = {

// Show modal dialog only if
// the frame is currently displayed.
if (origin == WindowManager.getDisplayedApp())
if (origin == WindowManager.getDisplayedApp() ||
frameType == 'inline-activity')
this.show(origin);
break;

Expand All @@ -112,6 +116,14 @@ var ModalDialog = {
this.show(evt.detail.origin);
break;

case 'home':
case 'holdhome':
// Inline activity, which origin is different from foreground app
if (this.isVisible() &&
this.currentOrigin != WindowManager.getDisplayedApp())
this.cancelHandler();
break;

case 'appwillclose':
// Do nothing if the app is closed at background.
if (evt.detail.origin !== this.currentOrigin)
Expand Down
1 change: 1 addition & 0 deletions test_apps/test-receiver-inline/index.html
Expand Up @@ -91,5 +91,6 @@ <h1>Inline Web Activities receiver</h1>
<!-- add an input field to test keyboard work well -->
<p><input type="number" id="number" size="4" /></p>
<p><button onclick="cancel()" disabled id="cancelButton">Cancel</button></p>
<p><button onclick="prompt('inline-activty prompt!');">Prompt</button></p>
</body>
</html>

0 comments on commit ac94981

Please sign in to comment.