close lightbox if the user press the browswer back button

stable
Juanfran 2016-10-04 09:12:24 +02:00 committed by Alejandro Alonso
parent 4d76356024
commit 56327838cd
2 changed files with 11 additions and 1 deletions

View File

@ -690,7 +690,7 @@ i18nInit = (lang, $translate) ->
init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $navUrls, appMetaService,
loaderService, navigationBarService, errorHandlingService) ->
loaderService, navigationBarService, errorHandlingService, lightboxService) ->
$log.debug("Initialize application")
$rootscope.$on '$translatePartialLoaderStructureChanged', () ->
@ -737,6 +737,11 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na
$rootscope.$on '$locationChangeStart', (event) ->
errorHandlingService.init()
if lightboxService.getLightboxOpen().length
event.preventDefault();
lightboxService.closeAll()
# On the first page load the loader is painted in `$routeChangeSuccess`
# because we need to hide the tg-navigation-bar.
# In the other cases the loader is in `$routeChangeSuccess`
@ -861,5 +866,6 @@ module.run([
"tgLoader",
"tgNavigationBarService",
"tgErrorHandlingService",
"lightboxService",
init
])

View File

@ -97,6 +97,10 @@ class LightboxService extends taiga.Service
scope.$destroy() if scope
$el.remove()
getLightboxOpen: ->
return $(".lightbox.open")
closeAll: ->
docEl = angular.element(document)
for lightboxEl in docEl.find(".lightbox.open")