mirror of
https://github.com/netzbegruenung/meteor-accounts-saml.git
synced 2024-04-27 09:34:50 +02:00
Merge pull request #1 from gigya/master
Fixed broken flow when running in Cordova's InAppBrowser plugin's window
This commit is contained in:
commit
d03e37b49b
|
@ -32,22 +32,45 @@ Accounts.saml.initiateLogin = function (options, callback, dimensions) {
|
||||||
|
|
||||||
|
|
||||||
var openCenteredPopup = function (url, width, height) {
|
var openCenteredPopup = function (url, width, height) {
|
||||||
var screenX = typeof window.screenX !== 'undefined' ? window.screenX : window.screenLeft;
|
var newwindow;
|
||||||
var screenY = typeof window.screenY !== 'undefined' ? window.screenY : window.screenTop;
|
|
||||||
var outerWidth = typeof window.outerWidth !== 'undefined' ? window.outerWidth : document.body.clientWidth;
|
|
||||||
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
|
|
||||||
// XXX what is the 22?
|
|
||||||
|
|
||||||
// Use `outerWidth - width` and `outerHeight - height` for help in
|
if (typeof cordova !== 'undefined' && typeof cordova.InAppBrowser !== 'undefined') {
|
||||||
// positioning the popup centered relative to the current window
|
newwindow = cordova.InAppBrowser.open(url, '_blank');
|
||||||
var left = screenX + (outerWidth - width) / 2;
|
newwindow.closed = false;
|
||||||
var top = screenY + (outerHeight - height) / 2;
|
|
||||||
var features = ('width=' + width + ',height=' + height +
|
var intervalId = setInterval(function () {
|
||||||
',left=' + left + ',top=' + top + ',scrollbars=yes');
|
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;
|
||||||
|
var outerHeight = typeof window.outerHeight !== 'undefined' ? window.outerHeight : (document.body.clientHeight - 22);
|
||||||
|
// XXX what is the 22?
|
||||||
|
|
||||||
|
// Use `outerWidth - width` and `outerHeight - height` for help in
|
||||||
|
// positioning the popup centered relative to the current window
|
||||||
|
var left = screenX + (outerWidth - width) / 2;
|
||||||
|
var top = screenY + (outerHeight - height) / 2;
|
||||||
|
var features = ('width=' + width + ',height=' + height +
|
||||||
|
',left=' + left + ',top=' + top + ',scrollbars=yes');
|
||||||
|
|
||||||
|
var newwindow = window.open(url, 'Login', features);
|
||||||
|
if (newwindow.focus)
|
||||||
|
newwindow.focus();
|
||||||
|
}
|
||||||
|
|
||||||
var newwindow = window.open(url, 'Login', features);
|
|
||||||
if (newwindow.focus)
|
|
||||||
newwindow.focus();
|
|
||||||
return newwindow;
|
return newwindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,4 +100,4 @@ Meteor.logoutWithSaml = function (options, callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue