-
-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added cookies banner (with link to cookie policy page) and accept coo…
…kies button
- Loading branch information
1 parent
1962bb0
commit 9b45b42
Showing
11 changed files
with
160 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
app/assets/javascripts/darkswarm/cookies_banner/cookies_banner.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.row | ||
.large-9.columns | ||
%p | ||
{{ 'legal.cookies_banner.cookies_usage' | t}} | ||
%p | ||
{{ 'legal.cookies_banner.cookies_desc' | t}} | ||
%p | ||
{{ 'legal.cookies_banner.cookies_policy_link_desc' | t}} | ||
-# | ||
%a{ 'cookies-policy-modal'=> true} | ||
{{ 'legal.cookies_banner.cookies_policy_link' | t}} | ||
|
||
.large-3.columns | ||
%button{ng: { controller:"CookiesBannerCtrl", click: "acceptCookies()" }} | ||
{{ 'legal.cookies_banner.cookies_accept_button' | t}} |
5 changes: 5 additions & 0 deletions
5
app/assets/javascripts/darkswarm/cookies_banner/cookies_banner_controller.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Darkswarm.controller "CookiesBannerCtrl", ($scope, CookiesBannerService, $http)-> | ||
|
||
$scope.acceptCookies = -> | ||
$http.get('/cookie_consent') | ||
CookiesBannerService.close() |
5 changes: 5 additions & 0 deletions
5
app/assets/javascripts/darkswarm/cookies_banner/cookies_banner_directive.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Darkswarm.directive 'cookiesBanner', (CookiesBannerService) -> | ||
restrict: 'A' | ||
link: (scope, elm, attr)-> | ||
CookiesBannerService.setActive() | ||
CookiesBannerService.open() |
20 changes: 20 additions & 0 deletions
20
app/assets/javascripts/darkswarm/cookies_banner/cookies_banner_service.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Darkswarm.factory "CookiesBannerService", (Navigation, $modal, $location, Redirections, Loading)-> | ||
|
||
new class CookiesBannerService | ||
modalMessage: null | ||
isActive: false | ||
|
||
open: (path, template = 'darkswarm/cookies_banner/cookies_banner.html') => | ||
return unless @isActive | ||
@modalInstance = $modal.open | ||
templateUrl: template | ||
windowClass: "cookies-banner full" | ||
backdrop: 'static' | ||
keyboard: false | ||
|
||
close: => | ||
return unless @isActive | ||
@modalInstance.close() | ||
|
||
setActive: => | ||
@isActive = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.cookies-banner { | ||
background: #3b3b3b; | ||
position: fixed; | ||
bottom: 0; | ||
z-index: 100000; | ||
top: 20vh !important; | ||
|
||
@media only screen and (min-width: 640px) { | ||
top: 20vh !important; | ||
} | ||
|
||
@media only screen and (min-width: 800px) { | ||
top: 40vh !important; | ||
} | ||
|
||
@media only screen and (min-width: 1024px) { | ||
top: 60vh !important; | ||
} | ||
} | ||
|
||
.cookies-banner button { | ||
background-color: green; | ||
} | ||
|
||
.cookies-banner p { | ||
color: white; | ||
font-size: 0.75rem; | ||
} | ||
|
||
// The following styles may be useful to change the banner's reveal-modal behaviour (it will have to be done on the controller to activate and deactivate styles on open/close ) | ||
|
||
// makes the main page body actionable | ||
//.reveal-modal-bg { | ||
// display: none !important; | ||
//} | ||
|
||
// Makes the main page body scrollable on large screens | ||
// body { | ||
// overflow: auto !important; | ||
// @media only screen and (max-width: 400px) { | ||
// overflow: hidden !important; | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Api | ||
class CookiesConsentController < BaseController | ||
respond_to :json | ||
|
||
def initialize | ||
super | ||
@cookie_name = 'cookies_consent' | ||
end | ||
|
||
def show | ||
render json: {cookie_consent: cookies[@cookie_name] != nil} | ||
end | ||
|
||
def create | ||
cookies[@cookie_name] = { | ||
:value => @cookie_name, | ||
:expires => 1.year.from_now, | ||
:domain => request.host | ||
} | ||
show | ||
end | ||
|
||
def destroy | ||
cookies.delete(@cookie_name, :domain => request.host) | ||
show | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters