Skip to content

Commit

Permalink
new: clean up on return
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli Bye committed Jan 28, 2012
1 parent a644dd5 commit 4149631
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/webintents.js
Expand Up @@ -55,14 +55,13 @@
intent._callback = (onResult) ? true : false;
intent._error = (onFailure) ? true : false;
intents[id] = { intent: intent };

var w = window.open(pickerSource, encodeNameTransport(intent), params);

//
// Iframe instead of window
var pickerIframe = document.createElement("iframe");
pickerIframe.id = id;
pickerIframe.name = encodeNameTransport(intent);
pickerIframe.src = pickerSource;
document.body.appendChild(pickerIframe);
document.body.insertBefore(pickerIframe,document.body.childNodes[0]);


if(onResult) {
Expand All @@ -85,9 +84,16 @@
};

var handler = function(e) {

var data;
try {
data = JSON.parse(e.data);

if(!!data.intent == true) {
var pickerIFrame = document.getElementById(data.intent._id);
if (!!pickerIFrame) document.body.removeChild(pickerIFrame);
}

if(
!!data.intent == true &&
!!intents[data.intent._id] == true &&
Expand Down

0 comments on commit 4149631

Please sign in to comment.