[open-ils-commits] r16350 - in trunk/Open-ILS: web/opac/locale/en-US xul/staff_client/chrome/content/cat 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
Thu Apr 29 14:45:44 EDT 2010


Author: phasefx
Date: 2010-04-29 14:45:39 -0400 (Thu, 29 Apr 2010)
New Revision: 16350

Modified:
   trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
   trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
   trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
   trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
   trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul
   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:
Return of the top-level Help menu, with a context sensitive For Active Tab menu entry.

So now every interface has a help option, though more work can still be done for interfaces containing sub-interfaces (I've reworked the OPAC wrapper here, but Patron Display / Patron Search could still use some love).

We'll also want to give thought to adding Help widgets to any popup dialogs.

Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2010-04-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd	2010-04-29 18:45:39 UTC (rev 16350)
@@ -951,6 +951,8 @@
 <!ENTITY staff.main.menu.file.save.label "Save Session">
 <!ENTITY staff.main.menu.help.accesskey "H">
 <!ENTITY staff.main.menu.help.label "Help">
+<!ENTITY staff.main.menu.help.active_tab.accesskey "A">
+<!ENTITY staff.main.menu.help.active_tab.label "For Active Tab">
 <!ENTITY staff.main.menu.quit "Quit Program">
 <!ENTITY staff.main.menu.quit.accesskey "Q">
 <!ENTITY staff.main.menu.replace_barcode.label "Replace Barcode">

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js	2010-04-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/cat/opac.js	2010-04-29 18:45:39 UTC (rev 16350)
@@ -28,6 +28,8 @@
             eval( r.responseText );
         }
 
+        window.help_context_set_locally = true;
+
         JSAN.use('util.network'); g.network = new util.network();
 
         g.cgi = new CGI();
@@ -49,6 +51,40 @@
     }
 }
 
+function default_focus() {
+    opac_wrapper_set_help_context(); 
+}
+
+function opac_wrapper_set_help_context() {
+    try {
+        dump('Entering opac.js, opac_wrapper_set_help_context\n');
+        var cw = bottom_pane.get_contentWindow(); 
+        if (cw && typeof cw['location'] != 'undefined') {
+            if (typeof cw.help_context_set_locally == 'undefined') {
+                var help_params = {
+                    'protocol' : cw.location.protocol,
+                    'hostname' : cw.location.hostname,
+                    'port' : cw.location.port,
+                    'pathname' : cw.location.pathname,
+                    'src' : ''
+                };
+                xulG.set_help_context(help_params);
+            } else {
+                dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
+                if (typeof cw.default_focus == 'function') {
+                    cw.default_focus();
+                }
+            }
+        } else {
+            dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
+            dump('\tcw.location = ' + cw.location + '\n');
+        }
+    } catch(E) {
+        // We can expect some errors here if this called before the DOM is ready.  Easiest to just trap and ignore
+        dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
+    }
+}
+
 function set_brief_view() {
     var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid); 
     dump('spawning ' + url + '\n');
@@ -75,6 +111,8 @@
     } else {
         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
     }
+    opac_wrapper_set_help_context(); 
+    bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
 }
 
 function set_marc_edit() {
@@ -201,6 +239,8 @@
     } else {
         bottom_pane.set_iframe( a,b,c );
     }
+    opac_wrapper_set_help_context(); 
+    bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
 }
 
 function set_copy_browser() {
@@ -211,6 +251,8 @@
     } else {
         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
     }
+    opac_wrapper_set_help_context(); 
+    bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
 }
 
 function set_hold_browser() {
@@ -221,6 +263,8 @@
     } else {
         bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
     }
+    opac_wrapper_set_help_context(); 
+    bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
 }
 
 function set_opac() {
@@ -320,6 +364,7 @@
         content_params.network_meter = xulG.network_meter;
         content_params.page_meter = xulG.page_meter;
         content_params.set_statusbar = xulG.set_statusbar;
+        content_params.set_help_context = xulG.set_help_context;
 
         if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
         browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
@@ -329,12 +374,31 @@
     } catch(E) {
         g.error.sdump('D_ERROR','set_opac: ' + E);
     }
+    opac_wrapper_set_help_context(); 
+    bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
 }
 
 function bib_in_new_tab() {
     try {
         var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
         var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
+        content_params.url_prefix = xulG.url_prefix;
+        content_params.new_tab = xulG.new_tab;
+        content_params.set_tab = xulG.set_tab;
+        content_params.close_tab = xulG.close_tab;
+        content_params.new_patron_tab = xulG.new_patron_tab;
+        content_params.set_patron_tab = xulG.set_patron_tab;
+        content_params.volume_item_creator = xulG.volume_item_creator;
+        content_params.get_new_session = xulG.get_new_session;
+        content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
+        content_params.set_tab_name = xulG.set_tab_name;
+        content_params.open_chrome_window = xulG.open_chrome_window;
+        content_params.url_prefix = xulG.url_prefix;
+        content_params.network_meter = xulG.network_meter;
+        content_params.page_meter = xulG.page_meter;
+        content_params.set_statusbar = xulG.set_statusbar;
+        content_params.set_help_context = xulG.set_help_context;
+
         xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
     } catch(E) {
         g.error.sdump('D_ERROR',E);
@@ -488,6 +552,7 @@
             case 'opac' :
             default: set_opac(); break;
         }
+        opac_wrapper_set_help_context(); 
     } catch(E) {
         g.error.standard_unexpected_error_alert('in refresh_display',E);
     }

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-04-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-04-29 18:45:39 UTC (rev 16350)
@@ -1218,18 +1218,25 @@
                 function(p) {
                     return function() {
                         try {
-                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                if (p
-                                    && p.firstChild 
-                                    && ( p.firstChild.nodeName == 'iframe' || p.firstChild.nodeName == 'browser' )
-                                    && p.firstChild.contentWindow 
-                                ) {
-                                    if (typeof p.firstChild.contentWindow.default_focus == 'function') {
-                                        p.firstChild.contentWindow.default_focus();
-                                    } else {
-                                        //p.firstChild.contentWindow.firstChild.focus();
-                                    }
+                            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                            if (p
+                                && p.firstChild 
+                                && ( p.firstChild.nodeName == 'iframe' || p.firstChild.nodeName == 'browser' )
+                                && p.firstChild.contentWindow 
+                            ) {
+                                var cw = p.firstChild.contentWindow;
+                                var help_params = {
+                                    'protocol' : cw.location.protocol,
+                                    'hostname' : cw.location.hostname,
+                                    'port' : cw.location.port,
+                                    'pathname' : cw.location.pathname,
+                                    'src' : ''
+                                };
+                                obj.set_help_context(help_params);
+                                if (typeof cw.default_focus == 'function') {
+                                    cw.default_focus();
                                 }
+                            }
                         } catch(E) {
                             obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E));
                         }
@@ -1456,6 +1463,20 @@
         }
         return result;
     },
+    'set_help_context' : function(params) {
+        var obj = this;
+        if (!params) { params = {}; }
+        if (params.protocol == 'chrome:') { return; } /* not supported */
+        var help_btn = document.getElementById('help_btn');
+        if (help_btn) {
+            dump('set_help_context: ' + js2JSON(params) + '\n');
+            if (params.protocol) { help_btn.setAttribute('protocol', params.protocol); }
+            if (params.hostname) { help_btn.setAttribute('hostname', params.hostname);  }
+            if (params.port) { help_btn.setAttribute('port', params.port);  }
+            if (params.pathname) { help_btn.setAttribute('pathname', params.pathname); }
+            if (params.src) { help_btn.setAttribute('src', params.src); }
+        }
+    },
     'set_tab' : function(url,params,content_params) {
         var obj = this;
         if (!url) url = '/xul/server/';
@@ -1478,6 +1499,7 @@
         content_params.get_new_session = function(a) { return obj.get_new_session(a); };
         content_params.holdings_maintenance_tab = function(a,b,c) { return obj.holdings_maintenance_tab(a,b,c); };
         content_params.set_tab_name = function(name) { tab.setAttribute('label',(idx + 1) + ' ' + name); };
+        content_params.set_help_context = function(params) { return obj.set_help_context(params); };
         content_params.open_chrome_window = function(a,b,c) { return xulG.window.open(a,b,c); };
         content_params.url_prefix = function(url) { return obj.url_prefix(url); };
         content_params.network_meter = obj.network_meter;
@@ -1529,6 +1551,28 @@
                     if (typeof cw.wrappedJSObject != 'undefined') cw = cw.wrappedJSObject;
                     cw.IAMXUL = true;
                     cw.xulG = content_params;
+                    cw.addEventListener(
+                        'load',
+                        function() {
+                            try {
+                                if (typeof cw.help_context_set_locally == 'undefined') {
+                                    var help_params = {
+                                        'protocol' : cw.location.protocol,
+                                        'hostname' : cw.location.hostname,
+                                        'port' : cw.location.port,
+                                        'pathname' : cw.location.pathname,
+                                        'src' : ''
+                                    };
+                                    obj.set_help_context(help_params);
+                                } else if (typeof cw.default_focus == 'function') {
+                                    cw.default_focus();
+                                }
+                            } catch(E) {
+                                obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload: ' + E);
+                            }
+                        },
+                        false
+                    );
                 } catch(E) {
                     this.error.sdump('D_ERROR', 'main.menu: ' + E);
                 }

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul	2010-04-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul	2010-04-29 18:45:39 UTC (rev 16350)
@@ -307,7 +307,12 @@
 <!-- The Help menu on the main menu -->
 <menu id="main.menu.help" label="&staff.main.menu.help.label;" accesskey="&staff.main.menu.help.accesskey;">
     <menupopup id="main.menu.help.popup">
-        <menuitem label="stub" />
+        <!-- kludge -->
+        <menuitem
+            label="&staff.main.menu.help.active_tab.label;" 
+            accesskey="&staff.main.menu.help.active_tab.accesskey;" 
+            oncommand="try { this.nextSibling.doCommand(); } catch(E) { alert(E); }" />
+        <help id="help_btn" hidden="true" />
     </menupopup>
 </menu>
 

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul	2010-04-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul	2010-04-29 18:45:39 UTC (rev 16350)
@@ -81,9 +81,7 @@
         <menu id="main.menu.booking" />
         <spacer flex="1" />
         <menu id="main.menu.admin" />
-        <!--
         <menu id="main.menu.help" />
-        -->
     </menubar>
     <toolbar id="main_toolbar" hidden="true">
         <toolbarbutton id="tb_checkout" 

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-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.js	2010-04-29 18:45:39 UTC (rev 16350)
@@ -113,6 +113,8 @@
             obj.controller.view.browser_browser.setAttribute('src',obj.url);
             //dump('browser url = ' + obj.url + '\n');
 
+            window.help_context_set_locally = true;
+
         } catch(E) {
             this.error.sdump('D_ERROR','util.browser.init: ' + E + '\n');
         }
@@ -214,16 +216,21 @@
         //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) {
+        if (xulG.set_help_context) {
             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);
+                var help_params = {
+                    'protocol' : obj.get_content().location.protocol,
+                    'hostname' : obj.get_content().location.hostname,
+                    'port' : obj.get_content().location.port,
+                    'pathname' : obj.get_content().location.pathname,
+                    'src' : ''
+                };
+                xulG.set_help_context(help_params);
             } catch(E) {
                 dump('Error in browser.js, setting location on help widget: ' + E);
             }
+        } else {
+            dump(location.href + ': browser.js, updateNavButtons, xulG = ' + xulG + ' xulG.set_help_context = ' + xulG.set_help_context + '\n');
         }
     },
 

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-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/browser.xul	2010-04-29 18:45:39 UTC (rev 16350)
@@ -93,6 +93,15 @@
             }
         }
 
+        function default_focus() {
+            try {
+                dump('entering browser.xul, default_focus()\n');
+                g.browser.updateNavButtons();
+            } catch(E) {
+                dump('Error in browser.xul, default_focus(): ' + E + '\n');
+            }
+        }
+
     ]]>
     </script>
 
@@ -113,7 +122,6 @@
             <spacer flex="1"/>
             <label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
             <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-29 18:45:38 UTC (rev 16349)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul	2010-04-29 18:45:39 UTC (rev 16350)
@@ -96,6 +96,15 @@
             }
         }
 
+        function default_focus() {
+            try {
+                dump('entering rbrowser.xul, default_focus()\n');
+                g.browser.updateNavButtons();
+            } catch(E) {
+                dump('Error in rbrowser.xul, default_focus(): ' + E + '\n');
+            }
+        }
+
     ]]>
     </script>
 
@@ -122,7 +131,6 @@
                 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