From d748e0dae5ebb68f6a39da239fe00d8e49b10fc8 Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 9 Jul 2015 12:45:02 -0700 Subject: [PATCH] give instructions in hanging tab --- .../discourse/components/query-result.js.es6 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/discourse/components/query-result.js.es6 b/assets/javascripts/discourse/components/query-result.js.es6 index 4c9a522..b1d2971 100644 --- a/assets/javascripts/discourse/components/query-result.js.es6 +++ b/assets/javascripts/discourse/components/query-result.js.es6 @@ -102,8 +102,12 @@ const QueryResultComponent = Ember.Component.extend({ actions: { downloadResult() { - const blankUrl = "about:blank"; - const windowName = randomIdShort(); + // Create a frame to submit the form in (?) + // to avoid leaving an about:blank behind + let windowName = randomIdShort(); + const newWindowContents = "Click anywhere to close this window once the download finishes."; + + let newWindow = window.open('data:text/html;base64,' + btoa(newWindowContents), windowName); let form = document.createElement("form"); form.setAttribute('id', 'query-download-result'); @@ -124,18 +128,11 @@ const QueryResultComponent = Ember.Component.extend({ addInput(form, 'explain', this.get('hasExplain')); addInput(form, 'limit', '1000000'); - const newWindow = window.open(blankUrl, windowName); - Discourse.ajax('/session/csrf.json').then(function(csrf) { addInput(form, 'authenticity_token', csrf.csrf); document.body.appendChild(form); form.submit(); - - Em.run.next('afterRender', function() { - document.body.removeChild(form); - newWindow.close(); - }); }); } },