@@ -325,6 +325,21 @@ javaxt.express.app.Horizon = function(parent, config) {
325325 } ;
326326
327327
328+ //**************************************************************************
329+ //** beforeTabChange
330+ //**************************************************************************
331+ /** Called immediately before a tab is raised in the tab bar.
332+ * @param currTab Object representing the current tab. Example:
333+ * <ul>
334+ * <li>name: Name/label of the tab (String)</li>
335+ * <li>tab: Tab in the tab bar (DOM Object)</li>
336+ * <li>panel: The panel that is rendered in the body (Object)</li>
337+ * </ul>
338+ * @param nextTab Object representing the tab that will be raised.
339+ */
340+ this . beforeTabChange = function ( currTab , nextTab ) { } ;
341+
342+
328343 //**************************************************************************
329344 //** onTabChange
330345 //**************************************************************************
@@ -463,7 +478,7 @@ javaxt.express.app.Horizon = function(parent, config) {
463478
464479
465480 //Update history
466- updateHistory ( {
481+ me . updateHistory ( {
467482 title : config . name + " - " + requestedTab ,
468483 tab : requestedTab ,
469484 url : url
@@ -480,7 +495,7 @@ javaxt.express.app.Horizon = function(parent, config) {
480495 if ( ! currTab ) currTab = user . preferences . get ( "Tab" ) ;
481496 if ( currTab && tabs [ currTab ] ) {
482497
483- updateHistory ( {
498+ me . updateHistory ( {
484499 title : config . name + " - " + currTab ,
485500 tab : currTab
486501 } ) ;
@@ -492,7 +507,7 @@ javaxt.express.app.Horizon = function(parent, config) {
492507 for ( var tabLabel in tabs ) {
493508 if ( tabs . hasOwnProperty ( tabLabel ) ) {
494509
495- updateHistory ( {
510+ me . updateHistory ( {
496511 title : config . name + " - " + tabLabel ,
497512 tab : tabLabel
498513 } ) ;
@@ -740,9 +755,33 @@ javaxt.express.app.Horizon = function(parent, config) {
740755 tab . onclick = function ( ) {
741756 if ( this . className === "active" ) return ;
742757
758+
759+ var currTab ;
760+ for ( var i = 0 ; i < tabbar . childNodes . length ; i ++ ) {
761+ var t = tabbar . childNodes [ i ] ;
762+ if ( t . className === "active" ) {
763+
764+ var l = t . innerText ;
765+ currTab = {
766+ name : l ,
767+ tab : t ,
768+ panel : panels [ l ]
769+ } ;
770+ break ;
771+ }
772+ }
773+
774+ me . beforeTabChange ( currTab , {
775+ name : label ,
776+ tab : this ,
777+ panel : panels [ label ]
778+ } ) ;
779+
780+
781+
743782 //Update history. Do this BEFORE raising the tab so that whatever
744783 //history the tab panel wants to modify happens AFTER the tab change.
745- addHistory ( {
784+ me . addHistory ( {
746785 title : config . name + " - " + label ,
747786 tab : label
748787 } ) ;
@@ -760,15 +799,15 @@ javaxt.express.app.Horizon = function(parent, config) {
760799 //**************************************************************************
761800 //** addHistory
762801 //**************************************************************************
763- var addHistory = function ( params ) {
802+ this . addHistory = function ( params ) {
764803 updateState ( params , false ) ;
765804 } ;
766805
767806
768807 //**************************************************************************
769808 //** updateHistory
770809 //**************************************************************************
771- var updateHistory = function ( params ) {
810+ this . updateHistory = function ( params ) {
772811 updateState ( params , true ) ;
773812 } ;
774813
0 commit comments