From b0cae8701005b4cfdcb23e818e718e4d546b26e8 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Mon, 2 Jan 2017 04:45:36 -0600 Subject: [PATCH] Output: prevent error on output to open popup --- js/widgets/widget-output.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/widgets/widget-output.js b/js/widgets/widget-output.js index 06f69013..ed14c3f2 100644 --- a/js/widgets/widget-output.js +++ b/js/widgets/widget-output.js @@ -162,7 +162,6 @@ // process to array of arrays csvData = output.processRow(c, $rows); - if (wo.output_includeFooter) { // clone, to force the tfoot rows to the end of this selection of rows // otherwise they appear after the thead (the order in the HTML) @@ -274,13 +273,20 @@ popup : function(data, style, wrap) { var generator = window.open('', output.popupTitle, style); - generator.document.write( - '' + output.popupTitle + '' + - '' + - '' - ); - generator.document.close(); - generator.focus(); + try { + generator.document.write( + '' + output.popupTitle + '' + + '' + + '' + ); + generator.document.close(); + generator.focus(); + } catch (e) { + // popup already open + generator.close(); + return output.popup(data, style, wrap); + } // select all text and focus within the textarea in the popup // $(generator.document).find('textarea').select().focus(); return true;