From fbe57697a472743ecbfc17bb6d93e7c14ed6d48c Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 13 Apr 2010 18:02:25 +0000 Subject: [PATCH] tweaks to widget to support non-chrome help content with chrome widgets, and wiring it up into a generic Help button for embedded browser based interfaces git-svn-id: svn://svn.open-ils.org/ILS/trunk@16229 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 4 ++++ .../staff_client/chrome/content/main/bindings.xml | 24 +++++++++++++++------- .../staff_client/chrome/content/util/browser.js | 14 ++++++++++++- .../staff_client/chrome/content/util/browser.xul | 5 +++-- .../staff_client/chrome/content/util/rbrowser.xul | 9 ++++++-- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 49c9f427e6..7dfbd5a42b 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -58,6 +58,10 @@ + + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml b/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml index 9216e581f2..e3bc819d39 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml +++ b/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml @@ -34,7 +34,10 @@ // /custom_help.html // /help.html // - // If @pathname is specified, it will override the value from location.href + // If @pathname is specified, it will override the value from location.pathname + // If @hostname is specified, it will override the value from location.hostname + // If @port is specified, it will override the value from location.port + // If @protocol is specified, it will override the value from location.protocol this.addEventListener( 'command', function(ev) { this._open_window(); }, false); } catch(E) { @@ -50,23 +53,30 @@ try { var obj = this; + var protocol = obj.getAttribute('protocol') || location.protocol; + var hostname = obj.getAttribute('hostname') || location.hostname; + var port = obj.getAttribute('port') || location.port; + var pathname = obj.getAttribute('pathname') || location.pathname; function test_url(loc) { - if (!loc) { return false; } + if (loc == '/' || !loc) { return false; } var x = new XMLHttpRequest(); - x.open("HEAD",loc,false); + var url = protocol + '//' + hostname + ( port ? ':' + port : '' ) + loc; + dump('help widget: testing <'+url+'>\n'); + x.open("HEAD", url, false); x.send(null); return x.status == 200; } function open_url(loc) { - window.open(loc+'?id='+obj.id,obj.getAttribute('label'),'resizable,scrollbars'); + var url = protocol + '//' + hostname + ( port ? ':' + port : '' ) + loc +'?id='+obj.id; + dump('help widget: opening <'+url+'>\n'); + window.open(url, obj.getAttribute('label'), 'resizable,scrollbars'); } - if (test_url(this.src)) { - open_url(this.src); + if (test_url('/'+this.getAttribute('src'))) { + open_url('/'+this.getAttribute('src')); } else { - var pathname = obj.getAttribute('pathname') || location.pathname; if (test_url(pathname + '.custom_help.html')) { open_url(pathname + '.custom_help.html'); } else { diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.js b/Open-ILS/xul/staff_client/chrome/content/util/browser.js index 5b79d06151..f543f40a8a 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js @@ -211,8 +211,20 @@ util.browser.prototype = { } catch(E) { s += E + '\n'; } - //this.error.sdump('D_BROWSER',s); + + // Let's also update @protocol, @hostname, @port, and @pathname on the widget + var help_btn = document.getElementById('help_btn'); + if (help_btn) { + try { + help_btn.setAttribute('protocol', obj.get_content().location.protocol); + help_btn.setAttribute('hostname', obj.get_content().location.hostname); + help_btn.setAttribute('port', obj.get_content().location.port); + help_btn.setAttribute('pathname', obj.get_content().location.pathname); + } catch(E) { + dump('Error in browser.js, setting location on help widget: ' + E); + } + } }, 'buildProgressListener' : function() { diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul index d9279927b1..a9a80437bc 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul @@ -98,7 +98,7 @@ - + @@ -112,7 +112,8 @@