internal: an alternative to default_focus
authorJason Etheridge <jason@esilibrary.com>
Thu, 20 Dec 2012 22:17:24 +0000 (17:17 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 12 Sep 2013 17:50:39 +0000 (13:50 -0400)
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 <jason@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/util/browser.js

index 805dcdb..c461602 100644 (file)
@@ -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);
                             }
index 20cb4dc..e452051 100644 (file)
@@ -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() {