diff --git a/src/ethicalads.css b/src/ethicalads.css index 835c347..cf50ba1 100644 --- a/src/ethicalads.css +++ b/src/ethicalads.css @@ -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 */ diff --git a/src/ethicalads.js b/src/ethicalads.js index f554c2d..b16f412 100644 --- a/src/ethicalads.js +++ b/src/ethicalads.js @@ -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,