[open-ils-commits] r16229 - in trunk/Open-ILS: web/opac/locale/en-US xul/staff_client/chrome/content/main xul/staff_client/chrome/content/util (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Apr 13 14:02:30 EDT 2010


Author: phasefx
Date: 2010-04-13 14:02:25 -0400 (Tue, 13 Apr 2010)
New Revision: 16229

Modified:
   trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
   trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml
   trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
   trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.xul
   trunk/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul
Log:
tweaks to <help> widget to support non-chrome help content with chrome <help> widgets, and wiring it up into a generic Help button for embedded browser based interfaces


Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2010-04-13 16:19:12 UTC (rev 16228)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2010-04-13 18:02:25 UTC (rev 16229)
@@ -58,6 +58,10 @@
 <!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">

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml	2010-04-13 16:19:12 UTC (rev 16228)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml	2010-04-13 18:02:25 UTC (rev 16229)
@@ -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 {

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-04-13 16:19:12 UTC (rev 16228)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-04-13 18:02:25 UTC (rev 16229)
@@ -211,8 +211,20 @@
         } catch(E) {
             s += E + '\n';
         }
+        //this.error.sdump('D_BROWSER',s);
 
-        //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() {

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.xul	2010-04-13 16:19:12 UTC (rev 16228)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.xul	2010-04-13 18:02:25 UTC (rev 16229)
@@ -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;" />
@@ -112,7 +112,8 @@
             <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>

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul	2010-04-13 16:19:12 UTC (rev 16228)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul	2010-04-13 18:02:25 UTC (rev 16229)
@@ -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;" />
@@ -113,9 +113,14 @@
             <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>



More information about the open-ils-commits mailing list