From 35bbeaea9a5dfc812c82c19061d96a9c514e2b7d 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 Signed-off-by: Mike Rylander --- 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 805dcdb252..c461602a1b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -2043,6 +2043,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)); @@ -2506,6 +2510,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 20cb4dc4d9..e4520514f9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js @@ -400,6 +400,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