@@ -89,6 +89,17 @@ javaxt.express.app.Horizon = function(parent, config) {
8989
9090 renderers : {
9191 profileButton : function ( user , profileButton ) { }
92+ } ,
93+
94+ messages : {
95+ connectionLost : "The connection to the server has been lost. " +
96+ "The internet might be down or there might be a problem with the server. " +
97+ "Some features might not work as expected while the server is offline. " +
98+ "Please do not refresh your browser. We will try to reconnect in a few moments." ,
99+
100+ connectionTimeout : "We have lost contact with the server. " +
101+ "It has been unavailable for over 5 minutes. Please check your " +
102+ "internet connection or contact the system administrator for assistance."
92103 }
93104 } ;
94105
@@ -107,13 +118,13 @@ javaxt.express.app.Horizon = function(parent, config) {
107118 var mainMenu , profileMenu ;
108119 var callout ;
109120
110-
111- var tabbar , body ;
121+ //Other components
122+ var tabbar , body , footer ;
112123 var tabs = { } ;
113124 var panels = { } ;
114125 var timers = { } ;
115126
116- var userInteractions = [ "mousemove" , "click" , "keydown" , "touchmove" ] ;
127+ var userInteractions = [ "mousemove" , "click" , "keydown" , "touchmove" , "wheel" ] ;
117128
118129
119130
@@ -165,7 +176,7 @@ javaxt.express.app.Horizon = function(parent, config) {
165176
166177
167178 //Create footer
168- createFooter ( table . addRow ( ) . addColumn ( config . style . footer . div ) ) ;
179+ footer = table . addRow ( ) . addColumn ( config . style . footer . div ) ;
169180
170181
171182 me . el = table ;
@@ -274,7 +285,8 @@ javaxt.express.app.Horizon = function(parent, config) {
274285 }
275286 } ,
276287 onTimeout : function ( ) {
277- alert ( "Connection lost" ) ;
288+ if ( communicationError ) communicationError . hide ( ) ;
289+ alert ( config . messages . connectionTimeout ) ;
278290 }
279291 } ) ;
280292 } ;
@@ -369,14 +381,19 @@ javaxt.express.app.Horizon = function(parent, config) {
369381
370382
371383
372- //Get active tab
373- var currTab ;
384+ //Get active and requested tab
385+ var currTab , requestedTab ;
386+ var t = getParameter ( "tab" ) . toLowerCase ( ) ;
374387 for ( var key in tabs ) {
375388 if ( tabs . hasOwnProperty ( key ) ) {
376389 var tab = tabs [ key ] ;
377- if ( tab . isVisible ( ) && tab . className === "active" ) {
378- currTab = tab ;
379- break ;
390+ if ( tab . isVisible ( ) ) {
391+ if ( tab . className === "active" ) {
392+ currTab = tab ;
393+ }
394+ if ( key . toLowerCase ( ) === t ) {
395+ requestedTab = tab ;
396+ }
380397 }
381398 }
382399 }
@@ -386,17 +403,37 @@ javaxt.express.app.Horizon = function(parent, config) {
386403 //Get user preferences
387404 user . preferences = new javaxt . express . UserPreferences ( ( ) => {
388405
389- //Click on user's last tab
390- if ( ! currTab ) currTab = user . preferences . get ( "Tab" ) ;
391- if ( currTab && tabs [ currTab ] ) {
392- tabs [ currTab ] . click ( ) ;
406+
407+ //Click on a tab
408+ if ( requestedTab ) {
409+
410+ //Click on the requested tab
411+ requestedTab . click ( ) ;
412+
413+
414+ //Remove tab parameter from the url
415+ var state = window . history . state ;
416+ if ( ! state ) state = { } ;
417+ var url = window . location . href ;
418+ url = url . replace ( "tab=" + getParameter ( "tab" ) , "" ) ;
419+ if ( url . lastIndexOf ( "&" ) === url . length - 1 ) url = url . substring ( 0 , url . length - 1 ) ;
420+ if ( url . lastIndexOf ( "?" ) === url . length - 1 ) url = url . substring ( 0 , url . length - 1 ) ;
421+ history . replaceState ( state , document . title , url ) ;
422+
393423 }
394424 else {
395- Object . values ( tabs ) [ 0 ] . click ( ) ;
396- }
397- } ) ;
398425
426+ //Click on user's last tab
427+ if ( ! currTab ) currTab = user . preferences . get ( "Tab" ) ;
428+ if ( currTab && tabs [ currTab ] ) {
429+ tabs [ currTab ] . click ( ) ;
430+ }
431+ else {
432+ Object . values ( tabs ) [ 0 ] . click ( ) ;
433+ }
434+ }
399435
436+ } ) ;
400437 } ;
401438
402439
@@ -712,6 +749,7 @@ javaxt.express.app.Horizon = function(parent, config) {
712749 position : "absolute" ,
713750 top : "10px" ,
714751 width : "100%" ,
752+ height : "0px" ,
715753 display : "none"
716754 } ) ;
717755
@@ -726,14 +764,14 @@ javaxt.express.app.Horizon = function(parent, config) {
726764 if ( isVisible ) return ;
727765 isVisible = true ;
728766 fx . fadeIn ( div , transitionEffect , duration , function ( ) {
729-
767+ menuButton . className += " warning" ;
730768 } ) ;
731769 } ;
732770 div . hide = function ( ) {
733771 if ( ! isVisible ) return ;
734772 isVisible = false ;
735773 fx . fadeOut ( div , transitionEffect , duration / 2 , function ( ) {
736-
774+ menuButton . className = menuButton . className . replaceAll ( "warning" , "" ) . trim ( ) ;
737775 } ) ;
738776 } ;
739777 div . isVisible = function ( ) {
@@ -745,10 +783,7 @@ javaxt.express.app.Horizon = function(parent, config) {
745783 var error = createElement ( "div" , div , "communication-error center" ) ;
746784 createElement ( "div" , error , "icon" ) ;
747785 createElement ( "div" , error , "title" ) . innerText = "Connection Lost" ;
748- createElement ( "div" , error , "message" ) . innerText =
749- "The connection to the server has been lost. The internet might be down " +
750- "or there might be a problem with the server. Don't worry, this app will " +
751- "automatically reconnect once the issue is resolved." ;
786+ createElement ( "div" , error , "message" ) . innerText = config . messages . connectionLost ;
752787
753788
754789 //Add main div to windows array so it closes automatically on logoff
@@ -862,6 +897,7 @@ javaxt.express.app.Horizon = function(parent, config) {
862897 //** Utils
863898 //**************************************************************************
864899 var createElement = javaxt . dhtml . utils . createElement ;
900+ var getParameter = javaxt . dhtml . utils . getParameter ;
865901 var createTable = javaxt . dhtml . utils . createTable ;
866902 var addShowHide = javaxt . dhtml . utils . addShowHide ;
867903 var isArray = javaxt . dhtml . utils . isArray ;
0 commit comments