Fix popup issues in safari
opener isnt set on modals, just removed showModalDialog since there wasn't a huge need for it. Fixes PLAT-941 Make sure you can auth on the submissions page from firefox, chrome, IE, and safari Change-Id: I3b32319347b80951122f5625749eb6de21921172 Reviewed-on: https://gerrit.instructure.com/50187 QA-Review: August Thornton <august@instructure.com> Reviewed-by: Nathan Mills <nathanm@instructure.com> Tested-by: Jenkins Product-Review: Brad Horrocks <bhorrocks@instructure.com>
This commit is contained in:
parent
5f18c60d8a
commit
47ab951dca
|
@ -290,39 +290,28 @@ define([
|
|||
reauth(href);
|
||||
});
|
||||
|
||||
// Yay for IE!
|
||||
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
|
||||
var eventHandler = window[eventMethod];
|
||||
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
|
||||
|
||||
|
||||
// Post message for anybody to listen to //
|
||||
if (window.opener)
|
||||
window.opener.postMessage({
|
||||
type: "event",
|
||||
payload: "done"
|
||||
}, window.location.origin);
|
||||
if (window.opener) {
|
||||
window.opener.postMessage({
|
||||
"type": "event",
|
||||
"payload": "done"
|
||||
}, window.opener.location.toString());
|
||||
}
|
||||
|
||||
|
||||
function reauth(auth_url) {
|
||||
var modal;
|
||||
|
||||
if(window.showModalDialog) {
|
||||
modal = window.showModalDialog(auth_url, "Authorize Google Docs");
|
||||
} else {
|
||||
modal = window.open(auth_url, "Authorize Google Docs", 'menubar=no;directories=no;location=no;modal=yes');
|
||||
}
|
||||
|
||||
eventHandler(messageEvent, function(event) {
|
||||
if(!event || !event.data || event.origin !== window.location.origin) return;
|
||||
var modal = window.open(auth_url, "Authorize Google Docs", 'menubar=no,directories=no,location=no,height=500,width=500');
|
||||
$(window).on("message", function (event){
|
||||
event = event.originalEvent;
|
||||
if(!event || !event.data || event.origin !== window.location.protocol + "//" + window.location.host) return;
|
||||
|
||||
if(event.data.type == "event" && event.data.payload == "done") {
|
||||
if (modal)
|
||||
modal.close();
|
||||
modal.close();
|
||||
|
||||
reloadGoogleDrive();
|
||||
}
|
||||
}, false);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function reloadGoogleDrive() {
|
||||
|
|
Loading…
Reference in New Issue