File tree 1 file changed +27
-5
lines changed
datamodels/2.x/itop-portal-base/portal/public/js
1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -426,12 +426,34 @@ $(function()
426
426
}
427
427
else
428
428
{
429
- // Try to close the window
430
- window . close ( ) ;
429
+
430
+ if ( window . history . length == 1 ) {
431
+
432
+ // This window doesn't seem to be a modal, yet there is no history. Try to close the window.
433
+ window . close ( ) ;
431
434
432
- // In some browser (eg. Firefox 70), window won't close if it has NOT been open by JS. In that case, we try to redirect to homepage as a fallback.
433
- var sHomepageUrl = ( this . options . base_url !== null ) ? this . options . base_url : $ ( '#sidebar .menu .brick_menu_item:first a' ) . attr ( 'href' )
434
- window . location . href = sHomepageUrl ;
435
+ // In some browser (eg. Firefox 70), window won't close if it has NOT been open by JS. In that case, we try to redirect to homepage as a fallback.
436
+ var sHomepageUrl = ( this . options . base_url !== null ) ? this . options . base_url : $ ( '#sidebar .menu .brick_menu_item:first a' ) . attr ( 'href' )
437
+
438
+ var regexPortal = new RegExp ( '(pages\\/exec\\.php)(.*?)(\\?exec_module=itop-portal-base&exec_page=index\\.php&portal_id=.*?)(&|$)' ) ;
439
+ var aRegexMatch = window . location . href . match ( regexPortal ) ;
440
+
441
+ if ( aRegexMatch !== null ) {
442
+
443
+ sHomepageUrl += aRegexMatch [ 1 ] + aRegexMatch [ 3 ] ;
444
+
445
+ }
446
+
447
+ window . location . href = sHomepageUrl ;
448
+
449
+ }
450
+ else {
451
+
452
+ // Unless the previous page was for some reason an automatic redirection to the current one, this should work:
453
+ window . history . back ( - 1 ) ;
454
+
455
+ }
456
+
435
457
}
436
458
} ,
437
459
submit : function ( oEvent )
You can’t perform that action at this time.
0 commit comments