Fixed broken flow when running in Cordova's InAppBrowser plugin's window

Tested successfully on Android & iOS devices.
This commit is contained in:
Dekel Barzilay 2016-04-19 22:42:48 +03:00
parent c6cde9c701
commit 4dbad564ea

View file

@ -30,6 +30,27 @@ Accounts.saml.initiateLogin = function (options, callback, dimensions) {
var openCenteredPopup = function (url, width, height) {
var newwindow;
if (typeof cordova !== 'undefined' && typeof cordova.InAppBrowser !== 'undefined') {
newwindow = cordova.InAppBrowser.open(url, '_blank');
newwindow.closed = false;
var intervalId = setInterval(function () {
newwindow.executeScript({
code: "document.getElementsByTagName('script')[0].textContent"
}, function (data) {
if (data && data.length > 0 && data[0] == 'window.close()') {
newwindow.close();
newwindow.closed = true;
}
});
}, 100);
newwindow.addEventListener('exit', function () {
clearInterval(intervalId);
});
} else {
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
@ -46,6 +67,8 @@ var openCenteredPopup = function (url, width, height) {
var newwindow = window.open(url, 'Login', features);
if (newwindow.focus)
newwindow.focus();
}
return newwindow;
};