Skip to content

Commit

Permalink
Merge pull request #1678 from rtfd/add-call-to-theme-js
Browse files Browse the repository at this point in the history
Fix theme js on third party themes
  • Loading branch information
ericholscher committed Sep 23, 2015
2 parents 6edb65c + 717faa9 commit bf5dca7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
45 changes: 29 additions & 16 deletions readthedocs/core/static-src/core/js/doc-embed/sphinx.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,37 @@ function init() {
if (!("builder" in rtd) || "builder" in rtd && rtd["builder"] != "mkdocs") {
var theme = sphinx_theme.ThemeNav;

// Because generated HTML will not immediately have the new scroll
// element, gracefully handle failover by adding it dynamically.
var navBar = jquery('div.wy-side-scroll:first');
if (! navBar.length) {
var navInner = jquery('nav.wy-nav-side:first'),
navScroll = $('<div />')
.addClass('wy-side-scroll');

navInner
.children()
.detach()
.appendTo(navScroll);
navScroll.prependTo(navInner);

theme.navBar = navScroll;
// TODO dont do this, the theme should explicitly check when it has be
// already enabled. See:
// https://github.com/snide/sphinx_rtd_theme/issues/250
$(document).ready(function () {
setTimeout(function() {
if (!theme.navBar) {
theme.enable();
}
}, 1000);
});

if (rtd.is_rtd_theme()) {
// Because generated HTML will not immediately have the new
// scroll element, gracefully handle failover by adding it
// dynamically.
var navBar = jquery('div.wy-side-scroll:first');
if (! navBar.length) {
var navInner = jquery('nav.wy-nav-side:first'),
navScroll = $('<div />')
.addClass('wy-side-scroll');

navInner
.children()
.detach()
.appendTo(navScroll);
navScroll.prependTo(navInner);

theme.navBar = navScroll;
}
}
}

}


Expand Down
6 changes: 5 additions & 1 deletion readthedocs/core/static-src/core/js/sponsorship.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ Promo.prototype.display = function () {
if (! promo) {
promo = this.promo = this.create();
}
promo.show();

// Promo still might not exist yet
if (promo) {
promo.show();
}
}

Promo.prototype.disable = function () {
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/core/static/core/js/readthedocs-doc-embed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf5dca7

Please sign in to comment.