From 75e672e2ba455dcfdf069bc9bd3377960e6b51b8 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 29 Apr 2010 18:45:39 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16350 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 + .../xul/staff_client/chrome/content/cat/opac.js | 65 +++++++++++++++++++++ .../xul/staff_client/chrome/content/main/menu.js | 66 ++++++++++++++++++---- .../chrome/content/main/menu_frame_menus.xul | 7 ++- .../chrome/content/main/menu_frame_overlay.xul | 2 - .../staff_client/chrome/content/util/browser.js | 19 +++++-- .../staff_client/chrome/content/util/browser.xul | 10 +++- .../staff_client/chrome/content/util/rbrowser.xul | 10 +++- 8 files changed, 159 insertions(+), 22 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 19931560f6..60c5ed67a3 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -951,6 +951,8 @@ + + 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 865b0db6e3..faa3edc351 100644 --- a/Open-ILS/xul/staff_client/chrome/content/cat/opac.js +++ b/Open-ILS/xul/staff_client/chrome/content/cat/opac.js @@ -28,6 +28,8 @@ function my_init() { 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 my_init() { } } +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 @@ function set_marc_view() { } 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 @@ function set_marc_edit() { } 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 @@ function set_copy_browser() { } 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 @@ function set_hold_browser() { } 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 @@ function set_opac() { 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 @@ function set_opac() { } 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 @@ function refresh_display(id) { case 'opac' : default: set_opac(); break; } + opac_wrapper_set_help_context(); } catch(E) { g.error.standard_unexpected_error_alert('in refresh_display',E); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index 33dfac5e71..d0d2169651 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -1218,18 +1218,25 @@ main.menu.prototype = { 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 @@ main.menu.prototype = { } 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 @@ main.menu.prototype = { 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 @@ main.menu.prototype = { 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); } diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 16513573f2..08045ed7e0 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -307,7 +307,12 @@ - + + + diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul index 2481b9bf53..faaefd5d94 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_overlay.xul @@ -81,9 +81,7 @@ -