-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
20 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,41 @@ | ||
// Allows any number of dismissable banners to be placed, | ||
// with dismissal state for each saved in localStorage. | ||
// | ||
// To use, give your banner element the class "banner" and an ID. | ||
// (You must never change the ID, or the dismissal state will be lost.) | ||
// Give the banner an initial display state of "none". | ||
// Inside the banner, place a button with the class "banner-close". | ||
// That's it! | ||
// | ||
// Example in Slim: | ||
// | ||
// # Note: Do not use the d-none Bootstrap helper, as it uses !important. | ||
// .banner#my-banner-name style="display: none" | ||
// | This is a banner. | ||
// button.btn.btn-secondary.banner-close Close | ||
|
||
const initBanners = function () { | ||
for (const element of document.getElementsByClassName("banner")) { | ||
const storageKey = element.id; | ||
if (localStorage.getItem(storageKey) === "hide") { | ||
return; | ||
} | ||
element.style.display = "block"; | ||
} | ||
}; | ||
|
||
document.addEventListener("turbolinks:load", initBanners); | ||
|
||
document.addEventListener("click", (event) => { | ||
const element = event.target; | ||
if (element.classList.contains("banner-close")) { | ||
const bannerCloseButton = element; | ||
const banner = bannerCloseButton.closest(".banner"); | ||
if (banner === null) { | ||
return; | ||
} | ||
const storageKey = banner.id; | ||
localStorage.setItem(storageKey, "hide"); | ||
banner.style.display = "none"; | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
article.pt-0.mb-3#survey-container style='display: none; max-width: 50em;' | ||
div.text-right | ||
small: #hide-survey-button.text-secondary style='cursor: pointer' no thanks | ||
a#survey-button.btn.btn-secondary.btn-block.mb-0.text-center target='_blank' href=survey_url | ||
' Help us out by taking the Splits.io survey! | ||
- if current_user && current_user.email.nil? | ||
.alert.alert-warning | ||
' You don't have an email attached to your Splits.io account. If | ||
' you become locked out your account will be irrecoverable. | ||
' Please add an email address from the | ||
a href=settings_path settings page | ||
' . | ||
/ .banner.alert.alert-success.col-md-6.mx-auto#shutdown-saved-banner style="display: none" | ||
/ ' Thanks to help from | ||
/ a.alert-link target='_blank' href='https://gamesdonequick.com' Games Done Quick | ||
/ ', Splits.io's plans to shut down have been canceled! | ||
/ a.float-right.alert-link.banner-close style="cursor: pointer" X | ||
.m-2: .banner.alert.alert-success.col-md-12.col-lg-10.col-xl-8.mx-auto#gdq-test-banner style="display: none" | ||
a.alert-link target='_blank' href='https://gamesdonequick.com' Awesome Games Done Quick | ||
'< is happening right now! | ||
- button_link = 'https://gamesdonequick.com' | ||
.d-block.d-lg-none.mt-4 | ||
a.btn-sm.btn-success.mr-3.p-2 target='_blank' href='#{button_link}' Watch | ||
a.alert-link.banner-close style="cursor: pointer" Dismiss | ||
.float-right.d-none.d-lg-block | ||
a.btn-sm.btn-success.mr-3.p-2 target='_blank' href='#{button_link}' See Schedule | ||
a.alert-link.banner-close style="cursor: pointer" X | ||
.row.mx-2: #alerts.w-100 data-turbolinks-temporary=true | ||
= render partial: 'shared/alerts' |