@@ -113,6 +113,16 @@ javaxt.express.app.Horizon = function(parent, config) {
113113 } ,
114114
115115
116+ /** Map of keywords
117+ */
118+ keywords : {
119+
120+ /** URL parameter used to indicate a preferred tab to raise
121+ */
122+ requestedTab : "tab"
123+ } ,
124+
125+
116126 /** Used to define the maximum idle time for a user before calling
117127 * logoff(). Units are in milliseconds. Default is false (i.e. no
118128 * auto-logoff).
@@ -325,6 +335,50 @@ javaxt.express.app.Horizon = function(parent, config) {
325335 } ;
326336
327337
338+ //**************************************************************************
339+ //** getTabs
340+ //**************************************************************************
341+ /** Returns an array of tabs. Each entry includes:
342+ * <ul>
343+ * <li>name: Name/label of the tab (String)</li>
344+ * <li>tab: Tab in the tab bar (DOM Object)</li>
345+ * <li>panel: The panel that is rendered in the body (Object). Note that
346+ * the panel might be null/undefined if it has never been raised. This is
347+ * because panels are only instantiated if a user clicks on a tab.
348+ * </li>
349+ * </ul>
350+ */
351+ this . getTabs = function ( ) {
352+ var arr = [ ] ;
353+ for ( var key in tabs ) {
354+ if ( tabs . hasOwnProperty ( key ) ) {
355+ arr . push ( {
356+ name : key ,
357+ tab : tabs [ key ] ,
358+ panel : panels [ key ]
359+ } ) ;
360+ }
361+ }
362+ return arr ;
363+ } ;
364+
365+
366+ //**************************************************************************
367+ //** getTab
368+ //**************************************************************************
369+ /** Returns an individual tab for a given label.
370+ */
371+ this . getTab = function ( name ) {
372+ var tab = tabs [ name ] ;
373+ if ( ! tab ) return null ;
374+ return {
375+ name : name ,
376+ tab : tab ,
377+ panel : panels [ name ]
378+ } ;
379+ } ;
380+
381+
328382 //**************************************************************************
329383 //** beforeTabChange
330384 //**************************************************************************
@@ -446,7 +500,7 @@ javaxt.express.app.Horizon = function(parent, config) {
446500
447501 //Get active and requested tab
448502 var currTab , requestedTab ;
449- var t = getParameter ( "tab" ) . toLowerCase ( ) ;
503+ var t = getParameter ( config . keywords . requestedTab ) . toLowerCase ( ) ;
450504 for ( var key in tabs ) {
451505 if ( tabs . hasOwnProperty ( key ) ) {
452506 var tab = tabs [ key ] ;
@@ -472,7 +526,7 @@ javaxt.express.app.Horizon = function(parent, config) {
472526
473527 //Remove tab parameter from the url
474528 var url = window . location . href ;
475- url = url . replace ( "tab=" + getParameter ( "tab" ) , "" ) ;
529+ url = url . replace ( "tab=" + getParameter ( config . keywords . requestedTab ) , "" ) ;
476530 if ( url . lastIndexOf ( "&" ) === url . length - 1 ) url = url . substring ( 0 , url . length - 1 ) ;
477531 if ( url . lastIndexOf ( "?" ) === url . length - 1 ) url = url . substring ( 0 , url . length - 1 ) ;
478532
@@ -875,6 +929,25 @@ javaxt.express.app.Horizon = function(parent, config) {
875929
876930 if ( e . state [ me . className ] ) {
877931 var label = e . state [ me . className ] . tab ;
932+
933+ //Check if the label matches the requested tab in the url
934+ var t = getParameter ( config . keywords . requestedTab ) . toLowerCase ( ) ;
935+ if ( t && t . length > 0 ) {
936+ if ( t !== label . toLowerCase ( ) ) {
937+ for ( var key in tabs ) {
938+ if ( tabs . hasOwnProperty ( key ) ) {
939+ var tab = tabs [ key ] ;
940+ if ( tab . isVisible ( ) ) {
941+ if ( key . toLowerCase ( ) === t ) {
942+ label = key ;
943+ break ;
944+ }
945+ }
946+ }
947+ }
948+ }
949+ }
950+
878951 var tab = tabs [ label ] ;
879952 if ( tab ) tab . raise ( ) ;
880953 }
0 commit comments