From 47ab951dca9d7b4a109fd85bb82526c7457033a6 Mon Sep 17 00:00:00 2001 From: Brad Horrocks Date: Wed, 11 Mar 2015 15:49:24 -0600 Subject: [PATCH] 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 Reviewed-by: Nathan Mills Tested-by: Jenkins Product-Review: Brad Horrocks --- public/javascripts/submit_assignment.js | 37 +++++++++---------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/public/javascripts/submit_assignment.js b/public/javascripts/submit_assignment.js index 6a6ca1d29f7..9d499fbc260 100644 --- a/public/javascripts/submit_assignment.js +++ b/public/javascripts/submit_assignment.js @@ -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() {