From f01f59613801f9a4607baef4bb323c14ea1ecb82 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 30 Oct 2017 22:46:35 -0700 Subject: [PATCH] help: Merge api.js and help.js bundles to fix code blocks. In addition to decreasing the excessive number of bundles we had, this will set us up to fix rendering of code blocks when clicking the sidebar links in the /api-new site. --- static/js/portico/api.js | 21 --------------------- static/js/portico/help.js | 25 +++++++++++++++++++++++++ templates/zerver/api/main.html | 2 +- tools/webpack.assets.json | 6 ------ 4 files changed, 26 insertions(+), 28 deletions(-) delete mode 100644 static/js/portico/api.js diff --git a/static/js/portico/api.js b/static/js/portico/api.js deleted file mode 100644 index 49fcf78cc5..0000000000 --- a/static/js/portico/api.js +++ /dev/null @@ -1,21 +0,0 @@ -function registerCodeSection($codeSection) { - const $li = $codeSection.find("ul.nav li"); - const $blocks = $codeSection.find(".blocks div"); - - $li.click(function () { - const language = this.dataset.language; - - $li.removeClass("active"); - $li.filter("[data-language="+language+"]").addClass("active"); - - $blocks.removeClass("active"); - $blocks.filter("[data-language="+language+"]").addClass("active"); - }); - - $li.eq(0).click(); -} - - -$(".code-section").each(function () { - registerCodeSection($(this)); -}); diff --git a/static/js/portico/help.js b/static/js/portico/help.js index 647414ea88..f62d3b018e 100644 --- a/static/js/portico/help.js +++ b/static/js/portico/help.js @@ -1,5 +1,28 @@ const Ps = require('perfect-scrollbar'); +function registerCodeSection($codeSection) { + const $li = $codeSection.find("ul.nav li"); + const $blocks = $codeSection.find(".blocks div"); + + $li.click(function () { + const language = this.dataset.language; + + $li.removeClass("active"); + $li.filter("[data-language="+language+"]").addClass("active"); + + $blocks.removeClass("active"); + $blocks.filter("[data-language="+language+"]").addClass("active"); + }); + + $li.eq(0).click(); +} + +function render_code_sections() { + $(".code-section").each(function () { + registerCodeSection($(this)); + }); +} + (function () { var html_map = {}; var loading = { @@ -86,4 +109,6 @@ const Ps = require('perfect-scrollbar'); $(".sidebar.show").toggleClass("show"); } }); + + render_code_sections(); }()); diff --git a/templates/zerver/api/main.html b/templates/zerver/api/main.html index bec486bdb2..9cdbdf0395 100644 --- a/templates/zerver/api/main.html +++ b/templates/zerver/api/main.html @@ -29,5 +29,5 @@ -{{ render_bundle("api") }} +{{ render_bundle("help") }} {% endblock %} diff --git a/tools/webpack.assets.json b/tools/webpack.assets.json index f7ebbed551..73c64a3aa4 100644 --- a/tools/webpack.assets.json +++ b/tools/webpack.assets.json @@ -1,6 +1,5 @@ { "activity": "./static/third/sorttable/sorttable.js", - "api": "./static/js/portico/api.js", "portico": [ "./static/js/portico/header.js" ], @@ -17,11 +16,6 @@ "./node_modules/perfect-scrollbar/dist/js/perfect-scrollbar.jquery.js", "./static/js/portico/help.js" ], - "api": [ - "./node_modules/perfect-scrollbar/dist/js/perfect-scrollbar.jquery.js", - "./static/js/portico/api.js", - "./static/js/portico/help.js" - ], "katex": "./node_modules/katex/dist/katex.min.js", "landing-page": "./static/js/portico/landing-page.js", "integrations": "./static/js/portico/integrations.js",