Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EthicalAds: Default to fixedfooter for smaller screens #447

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 2 additions & 50 deletions src/ethicalads.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,56 +128,8 @@ div.ethical-footer {
font-size: 10px;
}

/* Fixed footer promotions */
.ethical-fixedfooter {
box-sizing: border-box;
position: fixed;
bottom: 0;
left: 0;
z-index: 100;
background-color: #eee;
border-top: 1px solid #bfbfbf;
font-size: 12px;
line-height: 1.5;
padding: 0.5em 1.5em;
text-align: center;
color: #404040;
width: 100%; /* Fallback for Opera Mini */
width: 100vw;
}
@media (min-width: 769px) {
/* Improve viewing on non-mobile */
.ethical-fixedfooter {
font-size: 13px;
padding: 1em 1.5em;
}
}
.ethical-fixedfooter .ethical-text:before {
margin-right: 4px;
padding: 2px 6px;
border-radius: 3px;
background-color: #4caf50;
color: #fff;
content: "Sponsored";
}
.ethical-fixedfooter .ethical-callout {
color: #999;
padding-left: 6px;
white-space: nowrap;
}
.ethical-fixedfooter a,
.ethical-fixedfooter a:hover,
.ethical-fixedfooter a:active,
.ethical-fixedfooter a:visited {
color: #404040;
text-decoration: none;
}
.ethical-fixedfooter .ethical-close {
position: absolute;
top: 0;
right: 5px;
font-size: 20px;
line-height: 20px;
.ethical-fixedfooter-margin {
margin-bottom: 3em;
}

/* RTD Theme specific customizations */
Expand Down
30 changes: 23 additions & 7 deletions src/ethicalads.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,29 @@ export class EthicalAdsAddon extends AddonBase {
if (elementToAppend) {
elementToAppend.append(placement);
}
} else if (window.innerWidth > 1300) {
// https://ethical-ad-client.readthedocs.io/en/latest/#stickybox
placement.setAttribute("data-ea-type", "image");
placement.setAttribute("data-ea-style", "stickybox");
this.addEaPlacementToElement(placement);
// `document.body` here is not too much relevant, since we are going to
// use this selector only for a floating stickybox ad
// } else if (window.innerWidth > 1300) {
// // https://ethical-ad-client.readthedocs.io/en/latest/#stickybox
// placement.setAttribute("data-ea-type", "image");
// placement.setAttribute("data-ea-style", "stickybox");
// this.addEaPlacementToElement(placement);
// // `document.body` here is not too much relevant, since we are going to
// // use this selector only for a floating stickybox ad
// const elementInsertBefore = document.body;
// elementInsertBefore.insertBefore(
// placement,
// elementInsertBefore.lastChild,
// );
} else if (window.innerWidth > 768) {
// Use fixed footer for smaller widths, but not mobile
placement.setAttribute("data-ea-type", "text");
placement.setAttribute("data-ea-style", "fixedfooter");
placement.classList.add("ethical-fixedfooter");
// TODO: THIS IS A HACK. IS THERE A BETTER WAY?
// Add margin to the bottom to avoid hiding bottom of content
const root_node = document.querySelector(docTool.getRootSelector());
root_node.classList.add("ethical-fixedfooter-margin");
// Also add to body for good measure.
document.body.classList.add("ethical-fixedfooter-margin");
const elementInsertBefore = document.body;
elementInsertBefore.insertBefore(
placement,
Expand Down