Fix bug on slow page loads where banner and policy modal were both loaded

This solution makes the banner aware of the policy modal: the banner doesnt open if the policy modal is enabled
This commit is contained in:
luisramos0
2018-09-27 17:47:36 +01:00
parent 921105301c
commit 3cf10020bf
2 changed files with 9 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
Darkswarm.directive 'cookiesBanner', (CookiesBannerService) ->
Darkswarm.directive 'cookiesBanner', (CookiesBannerService, CookiesPolicyModalService) ->
restrict: 'A'
link: (scope, elm, attr)->
return if not attr.cookiesBanner? || attr.cookiesBanner == 'false'
CookiesBannerService.enable()
return if CookiesPolicyModalService.isEnabled()
CookiesBannerService.open()

View File

@@ -5,7 +5,7 @@ Darkswarm.factory "CookiesPolicyModalService", (Navigation, $modal, $location, C
modalMessage: null
constructor: ->
if $location.path() is @defaultPath || location.pathname is @defaultPath
if @isEnabled()
@open ''
open: (path = false, template = 'angular-templates/cookies_policy.html') =>
@@ -13,18 +13,16 @@ Darkswarm.factory "CookiesPolicyModalService", (Navigation, $modal, $location, C
templateUrl: template
windowClass: "cookies-policy-modal medium"
@closeCookiesBanner()
@onCloseReOpenCookiesBanner()
CookiesBannerService.close()
@onCloseOpenCookiesBanner()
selectedPath = path || @defaultPath
Navigation.navigate selectedPath
closeCookiesBanner: =>
setTimeout ->
CookiesBannerService.close()
, 200
onCloseReOpenCookiesBanner: =>
onCloseOpenCookiesBanner: =>
@modalInstance.result.then(
-> CookiesBannerService.open(),
-> CookiesBannerService.open() )
isEnabled: =>
$location.path() is @defaultPath || location.pathname is @defaultPath