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

Fixed footer ads again #3895

Merged
Merged
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
39 changes: 38 additions & 1 deletion media/css/readthedocs-doc-embed.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/* Please keep RTD badge displayed on your site */
.rst-versions.rst-badge {
display: block;

bottom: 50px;
}

.rst-other-versions {
Expand Down Expand Up @@ -60,7 +62,7 @@ div.ethical-sidebar, div.ethical-footer {
padding-top: 1em;
clear: both;
}
.ethical-sidebar .ethical-pixel, .ethical-footer .ethical-pixel {
.ethical-sidebar .ethical-pixel, .ethical-footer .ethical-pixel, .ethical-fixedfooter .ethical-pixel {
display: none !important;
}
.ethical-sidebar .ethical-text, .ethical-footer .ethical-text {
Expand Down Expand Up @@ -88,6 +90,41 @@ div.ethical-sidebar, div.ethical-footer {
text-align: right;
}

/* Fixed footer promotions */
.ethical-fixedfooter {
box-sizing: border-box;
width: 100%;
position: fixed;
bottom: 0;
left: 0;
z-index: 100;
background-color: #eee;
border-top: 1px solid #bfbfbf;
font-size: 12px;
line-height: 16px;
padding: 0.5em 2.5em;
text-align: center;
color: #404040;
}
.ethical-fixedfooter a,
.ethical-fixedfooter a:hover,
.ethical-fixedfooter a:active,
.ethical-fixedfooter a:visited {
color: #004B6B;
text-decoration: underline;
}
.ethical-fixedfooter .ethical-close {
position: absolute;
top: 0;
right: 5px;
font-size: 15px;
line-height: 15px;
}
.ethical-fixedfooter .ethical-close a {
color: black;
text-decoration: none;
}

/* RTD Theme specific customizations */
.ethical-rtd .ethical-sidebar {
/* RTD theme doesn't set sidebar text color */
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Read the Docs build dependencies",
"author": "Anthony Johnson <anthony@readthedocs.com>",
"dependencies": {
"bowser": "^1.9.3",
"cssfilter": "0.0.8",
"github-changelog": "git+https://github.com/agjohnson/github-changelog.git"
},
Expand Down
5 changes: 3 additions & 2 deletions readthedocs/core/static-src/core/js/doc-embed/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ exports.PROMO_SUPPORTED_THEMES = [
];

exports.PROMO_TYPES = {
LEFTNAV: 'doc', // Left navigation on documentation pages
FOOTER: 'site-footer', // Footer of documentation pages
LEFTNAV: 'doc', // Left navigation on documentation pages
FOOTER: 'site-footer', // Footer of documentation pages
FIXED_FOOTER: 'fixed-footer' // A footer ad fixed at the bottom fo the screen
};

module.exports = exports;
25 changes: 24 additions & 1 deletion readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
var constants = require('./constants');
var rtddata = require('./rtd-data');

var bowser = require('bowser');

var rtd;

/*
Expand Down Expand Up @@ -60,6 +62,23 @@ function create_footer_placement() {
return null;
}

/*
* Creates a fixed footer placmenet
* Returns the ID of the div or none if a fixed footer ad shouldn't be used
*/
function create_fixed_footer_placement() {
var element_id = 'rtd-' + (Math.random() + 1).toString(36).substring(4);
var display_type = constants.PROMO_TYPES.FIXED_FOOTER;

// Only propose the fixed footer ad for mobile
if (bowser && bowser.mobile) {
$('<div />').attr('id', element_id).appendTo('body');
return {'div_id': element_id, 'display_type': display_type};
}

return null;
}

function Promo(data) {
this.id = data.id; // analytics id
this.div_id = data.div_id || '';
Expand Down Expand Up @@ -113,7 +132,11 @@ function init() {
var request_data = {format: "jsonp"};
var div_ids = [];
var display_types = [];
var placement_funcs = [create_footer_placement, create_sidebar_placement];
var placement_funcs = [
create_footer_placement,
create_sidebar_placement,
create_fixed_footer_placement,
];
var params;
var placement;

Expand Down