mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
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:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user