From f6f6c9d73073cdc7282c2e9f5aaf830f0309f89c Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Sat, 28 Jul 2012 15:17:40 -0400 Subject: [PATCH] Window.open fixes Add a window.open compatible "browser" file for unsecured calls. Add "chrome" to most window.open calls to bypass the wrapper. Signed-off-by: Thomas Berezansky Signed-off-by: Dan Scott --- Open-ILS/web/js/dojo/openils/Util.js | 2 +- Open-ILS/web/js/ui/default/acq/common/li_table.js | 6 +++--- .../js/ui/default/acq/financial/claim_voucher.js | 2 +- Open-ILS/web/js/ui/default/booking/populator.js | 2 +- Open-ILS/web/js/ui/default/cat/authority/list.js | 2 +- .../web/js/ui/default/circ/selfcheck/selfcheck.js | 2 +- Open-ILS/web/js/ui/default/vandelay/vandelay.js | 2 +- Open-ILS/web/opac/common/js/utils.js | 2 +- Open-ILS/web/opac/skin/default/js/rdetail.js | 2 +- Open-ILS/web/reports/oils_rpt_utils.js | 2 +- .../xul/staff_client/chrome/content/cat/opac.js | 2 +- .../xul/staff_client/chrome/content/util/print.js | 8 ++++---- .../chrome/content/util/untrusted_window.xul | 15 +++++++++++++++ .../defaults/preferences/standalone_xul_app.js | 4 ++-- Open-ILS/xul/staff_client/server/cat/marcedit.js | 2 +- 15 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 Open-ILS/xul/staff_client/chrome/content/util/untrusted_window.xul diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index 5745fad574..804d13c3c4 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -474,7 +474,7 @@ if(!dojo._hasResource["openils.Util"]) { */ openils.Util.printHtmlString = function(html, callback) { - var win = window.open('', 'Print Window', 'resizable,width=800,height=600,scrollbars=1'); + var win = window.open('', 'Print Window', 'resizable,width=800,height=600,scrollbars=1,chrome'); // force the new window to the background win.blur(); diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index f9abb71bae..aba6da960c 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -2662,9 +2662,9 @@ function AcqLiTable() { to true in about:config */ if(openils.XUL.isXUL()) { - win = window.open('/xul/' + openils.XUL.buildId() + '/server/cat/marcedit.xul'); + win = window.open('/xul/' + openils.XUL.buildId() + '/server/cat/marcedit.xul','','chrome'); } else { - win = window.open('/xul/server/cat/marcedit.xul'); + win = window.open('/xul/server/cat/marcedit.xul','','chrome'); } var self = this; win.xulG = { @@ -2852,7 +2852,7 @@ function AcqLiTable() { win = window.open( oilsBasePath + '/acq/lineitem/findbib?query=' + escape(query), - '', 'resizable,scrollbars=1'); + '', 'resizable,scrollbars=1,chrome'); win.window.recordFound = function(bibId) { win.close(); diff --git a/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js b/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js index c6191f84dc..70ed2f0769 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js +++ b/Open-ILS/web/js/ui/default/acq/financial/claim_voucher.js @@ -1,6 +1,6 @@ function openClaimVoucherWindow() { var win = window.open( - "", "", "resizable,width=800,height=600,scrollbars=1" + "", "", "resizable,width=800,height=600,scrollbars=1,chrome" ); /* XXX i18n - also, the reason this isn't loaded from a server-side page * has to do with problems of knowing when the page has loaded, so we diff --git a/Open-ILS/web/js/ui/default/booking/populator.js b/Open-ILS/web/js/ui/default/booking/populator.js index 1eeb7cbfe7..c6927e65f5 100644 --- a/Open-ILS/web/js/ui/default/booking/populator.js +++ b/Open-ILS/web/js/ui/default/booking/populator.js @@ -333,7 +333,7 @@ function display_transit_slip(e) { /* XXX i18n and/or template */ try { var win = window.open( - "","","resizeable,width=600,height=400,scrollbars=1" + "","","resizeable,width=600,height=400,scrollbars=1,chrome" ); win.document.body.innerHTML = "

Transit Slip

\n" + diff --git a/Open-ILS/web/js/ui/default/cat/authority/list.js b/Open-ILS/web/js/ui/default/cat/authority/list.js index 99fba63e1b..3f1c666a22 100644 --- a/Open-ILS/web/js/ui/default/cat/authority/list.js +++ b/Open-ILS/web/js/ui/default/cat/authority/list.js @@ -281,7 +281,7 @@ function loadMarcEditor(pcrud, rec) { To run in Firefox directly, must set signed.applets.codebase_principal_support to true in about:config */ - win = window.open('/xul/server/cat/marcedit.xul'); // XXX version? + win = window.open('/xul/server/cat/marcedit.xul','','chrome'); // XXX version? win.xulG = { "record": {"marc": rec.marc(), "rtype": "are"}, diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index 886c8c37ff..0b47be3913 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -1279,7 +1279,7 @@ SelfCheckManager.prototype.printSessionReceipt = function(callback) { SelfCheckManager.prototype.printData = function(data, numItems, callback) { - var win = window.open('', '', 'resizable,width=700,height=500,scrollbars=1'); + var win = window.open('', '', 'resizable,width=700,height=500,scrollbars=1,chrome'); win.document.body.innerHTML = data; win.print(); diff --git a/Open-ILS/web/js/ui/default/vandelay/vandelay.js b/Open-ILS/web/js/ui/default/vandelay/vandelay.js index e8b8f5a2a8..8e5f314d07 100644 --- a/Open-ILS/web/js/ui/default/vandelay/vandelay.js +++ b/Open-ILS/web/js/ui/default/vandelay/vandelay.js @@ -1520,7 +1520,7 @@ function vlOpenMarcEditWindow(rec, postReloadHTMLHandler) { To run in Firefox directly, must set signed.applets.codebase_principal_support to true in about:config */ - win = window.open('/xul/server/cat/marcedit.xul'); // XXX version? + win = window.open('/xul/server/cat/marcedit.xul','','chrome'); // XXX version? var type; if (currentType == 'bib') { diff --git a/Open-ILS/web/opac/common/js/utils.js b/Open-ILS/web/opac/common/js/utils.js index 444d9cf88d..3d1366ea28 100644 --- a/Open-ILS/web/opac/common/js/utils.js +++ b/Open-ILS/web/opac/common/js/utils.js @@ -564,7 +564,7 @@ function openWindow( data ) { 'chrome,resizable,width=700,height=500'); } else { - win = window.open('','', 'resizable,width=700,height=500,scrollbars=1'); + win = window.open('','', 'resizable,width=700,height=500,scrollbars=1,chrome'); win.document.body.innerHTML = data; } } diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index 2a228f5c13..3446574dad 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -337,7 +337,7 @@ function OpenMarcEditWindow(pcrud, rec) { To run in Firefox directly, must set signed.applets.codebase_principal_support to true in about:config */ - win = window.open('/xul/server/cat/marcedit.xul'); // XXX version? + win = window.open('/xul/server/cat/marcedit.xul','','chrome'); // XXX version? dojo.require('openils.PermaCrud'); win.xulG = { diff --git a/Open-ILS/web/reports/oils_rpt_utils.js b/Open-ILS/web/reports/oils_rpt_utils.js index 2ab687eb6b..676d4c7268 100644 --- a/Open-ILS/web/reports/oils_rpt_utils.js +++ b/Open-ILS/web/reports/oils_rpt_utils.js @@ -129,7 +129,7 @@ function oilsRptDebug() { /* if(!oilsRptDebugWindow) - oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1'); + oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1,chrome'); oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString(); */ } diff --git a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js index 9f58b815f7..9151ab1367 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -736,7 +736,7 @@ function open_mfhd_editor(sre_id) { } function open_marc_editor(rec, label) { - win = window.open( xulG.url_prefix('XUL_MARC_EDIT') ); + win = window.open( xulG.url_prefix('XUL_MARC_EDIT'), '', 'chrome' ); win.xulG = { record : {marc : rec.marc()}, diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index c3ff12b1d0..c84833a80e 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -510,9 +510,9 @@ util.print.prototype = { } } else { if (params.content_type == 'text/plain') { - w = window.open('data:text/plain,'+escape(params.msg)); + w = window.open('data:text/plain,'+escape(params.msg),'','chrome'); } else { - w = window.open('data:text/html,'+escape(params.msg)); + w = window.open('data:text/html,'+escape(params.msg),'','chrome'); } setTimeout( function() { @@ -535,9 +535,9 @@ util.print.prototype = { obj._NSPrint_webBrowserPrint(w,silent,params); } else { if (params.content_type == 'text/plain') { - w = window.open('data:text/plain,'+escape(params.msg)); + w = window.open('data:text/plain,'+escape(params.msg),'','chrome'); } else { - w = window.open('data:text/html,'+escape(params.msg)); + w = window.open('data:text/html,'+escape(params.msg),'','chrome'); } setTimeout( function() { diff --git a/Open-ILS/xul/staff_client/chrome/content/util/untrusted_window.xul b/Open-ILS/xul/staff_client/chrome/content/util/untrusted_window.xul new file mode 100644 index 0000000000..a68e666366 --- /dev/null +++ b/Open-ILS/xul/staff_client/chrome/content/util/untrusted_window.xul @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/Open-ILS/xul/staff_client/defaults/preferences/standalone_xul_app.js b/Open-ILS/xul/staff_client/defaults/preferences/standalone_xul_app.js index 2b2fe741c3..65d995a81b 100644 --- a/Open-ILS/xul/staff_client/defaults/preferences/standalone_xul_app.js +++ b/Open-ILS/xul/staff_client/defaults/preferences/standalone_xul_app.js @@ -9,8 +9,8 @@ pref("javascript.options.jit.content", true); pref("general.useragent.locale", "en-US"); // We need something like this to get window.open to work in some places (where it complains about -// navigator.xul not being registered. But is about:blank the best value to use here? -pref("browser.chromeURL","about:blank"); +// navigator.xul not being registered). The untrusted_window file provided the minimum required elements. +pref("browser.chromeURL","chrome://open_ils_staff_client/content/util/untrusted_window.xul"); // This one just makes things speedier. We use a lot of XMLHttpRequest pref("network.http.max-persistent-connections-per-server",8); diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js index 620923a835..71e6f22d4e 100644 --- a/Open-ILS/xul/staff_client/server/cat/marcedit.js +++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js @@ -2048,7 +2048,7 @@ function loadMarcEditor(pcrud, marcxml, target, sf) { To run in Firefox directly, must set signed.applets.codebase_principal_support to true in about:config */ - win = window.open('/xul/server/cat/marcedit.xul'); // XXX version? + win = window.open('/xul/server/cat/marcedit.xul', '_blank', 'chrome'); // XXX version? // Match marc2are.pl last_xact_id format, roughly var now = new Date; -- 2.43.2