tweaks to <help> widget to support non-chrome help content with chrome <help> widgets...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 13 Apr 2010 18:02:25 +0000 (18:02 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 13 Apr 2010 18:02:25 +0000 (18:02 +0000)
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
Open-ILS/xul/staff_client/chrome/content/main/bindings.xml
Open-ILS/xul/staff_client/chrome/content/util/browser.js
Open-ILS/xul/staff_client/chrome/content/util/browser.xul
Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul

index 49c9f42..7dfbd5a 100644 (file)
 <!ENTITY common.browser.backward.accesskey "B">
 <!ENTITY common.browser.reload.label "Reload">
 <!ENTITY common.browser.reload.accesskey "l">
+<!ENTITY common.browser.print.label "Print Page">
+<!ENTITY common.browser.print.accesskey "P">
+<!ENTITY common.browser.help.label "Help">
+<!ENTITY common.browser.help.accesskey "H">
 
 <!ENTITY common.textbox.cut "Cut">
 <!ENTITY common.textbox.copy "Copy">
index 9216e58..e3bc819 100644 (file)
                     // /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) {
                     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 {
index 5b79d06..f543f40 100644 (file)
@@ -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 <help> 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() {
index d927992..a9a8043 100644 (file)
@@ -98,7 +98,7 @@
 
     <commandset id="util_browser_cmds">
         <command id="cmd_broken" />
-        <command id="cmd_print" />
+        <command id="cmd_print" label="&common.browser.print.label;" accesskey="&common.browser.print.accesskey;" />
         <command id="cmd_debug" />
         <command id="cmd_back" label="&common.browser.backward.label;" accesskey="&common.browser.backward.accesskey;" />
         <command id="cmd_reload" label="&common.browser.reload.label;" accesskey="&common.browser.reload.accesskey;" />
             <button id="forward" command="cmd_forward" disabled="true" hidden="true"/>
             <spacer flex="1"/>
             <label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
-            <button id="browser_print" label="Print Page" command="cmd_print" hidden="true"/>
+            <button id="browser_print" command="cmd_print" hidden="true"/>
+            <help id="help_btn" label="&common.browser.help.label;" accesskey="&common.browser.help.accesskey;" />
         </hbox>
         <browser id="browser_browser" flex="1" type="content"/>
     </vbox>
index 8ba1a70..b8c7a52 100644 (file)
@@ -99,7 +99,7 @@
 
     <commandset id="util_browser_cmds">
         <command id="cmd_broken" />
-        <command id="cmd_print" />
+        <command id="cmd_print" label="&common.browser.print.label;" accesskey="&common.browser.print.accesskey;" />
         <command id="cmd_debug" />
         <command id="cmd_back" label="&common.browser.backward.label;" accesskey="&common.browser.backward.accesskey;" />
         <command id="cmd_reload" label="&common.browser.reload.label;" accesskey="&common.browser.reload.accesskey;" />
             <button id="forward" command="cmd_forward" disabled="true" hidden="true"/>
             <spacer flex="1"/>
             <label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
-            <button id="browser_print" label="Print Page" oldcommand="cmd_print" hidden="true"
+            <button id="browser_print"
+                label="&common.browser.print.label;" 
+                accesskey="&common.browser.print.accesskey;" 
+                hidden="true"
+                oldcommand="cmd_print"
                 oncommand="netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); if (g.browser.alt_print) { JSAN.use('util.print'); var p = new util.print(); p.NSPrint(g.browser.get_content(),false,{}); } else { g.browser.get_content().print(); }"
             />
+            <help id="help_btn" label="&common.browser.help.label;" accesskey="&common.browser.help.accesskey;" />
         </hbox>
         <browser id="browser_browser" flex="1" type="content"/>
     </vbox>