From 9c1e71a29fe9f7fca48723971bf671da7c45aa8a Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Thu, 20 Dec 2012 17:17:24 -0500 Subject: [PATCH] internal: an alternative to default_focus Interfaces can now set event listeners on their window for 'tab_focus' instead of defining a single default_focus function. We also include a change to browser.js so that embedded interfaces also get their default_focus function called (and a tab_focus event sent). This is geared to help future functionality, but shouldn't produce any end-user visible changes by itself. Signed-off-by: Jason Etheridge --- Open-ILS/xul/staff_client/chrome/content/main/menu.js | 8 ++++++++ Open-ILS/xul/staff_client/chrome/content/util/browser.js | 11 +++++++++++ 2 files changed, 19 insertions(+) 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 80ea58bdc2..04a91f5e7b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -2017,6 +2017,10 @@ main.menu.prototype = { if (typeof cw.default_focus == 'function') { cw.default_focus(); } + // an alternative to the practice above + var evt = cw.document.createEvent("Events"); + evt.initEvent( 'tab_focus', true, true ); + cw.window.dispatchEvent(evt); } } catch(E) { obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E)); @@ -2480,6 +2484,10 @@ commands: if (typeof cw.default_focus == 'function') { cw.default_focus(); } + // an alternative to the practice above + var evt = cw.document.createEvent("Events"); + evt.initEvent( 'tab_focus', true, true ); + cw.window.dispatchEvent(evt); } catch(E) { obj.error.sdump('D_ERROR', 'main.menu, set_tab, onload: ' + E); } 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 fb0078ac22..9ff09bac2c 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js @@ -367,6 +367,17 @@ util.browser.prototype = { } else { dump(location.href + ': browser.js, updateNavButtons, xulG = ' + xulG + ' xulG.set_help_context = ' + xulG.set_help_context + '\n'); } + try { + var cw = obj.get_content(); + if (typeof cw.default_focus == 'function') { + cw.default_focus(); + } + var evt = cw.document.createEvent("Events"); + evt.initEvent( 'tab_focus', true, true ); + cw.dispatchEvent(evt); + } catch(E) { + dump('Error in browser.js, calling cw.default_focus and cw.dispatchEvent: ' + E); + } }, 'buildProgressListener' : function() { -- 2.11.0