encode / apistar

The Web API toolkit. 🛠
https://docs.apistar.com
BSD 3-Clause "New" or "Revised" License
5.57k stars 411 forks source link

Documentation: Fix python code tab switcher #591

Closed danigosa closed 5 years ago

danigosa commented 6 years ago

Hi,

it looks that since b99d4ac and a8ce4e0 nobody is calling the necessary code for the language chooser tabs that was removed when removing old api.js file:

//////////// api.js:66 /////////////
$(function () {
  var $selectedAuthentication = $('#selected-authentication')
  var $authControl = $('#auth-control')
  var $authTokenModal = $('#auth_token_modal')
  var $authBasicModal = $('#auth_basic_modal')
  var $authSessionModal = $('#auth_session_modal')

 ////// ----> REMOVED code for `language-control` navs
  // Language Control
  $('#language-control li').click(function (event) {
    event.preventDefault()
    var $languageMenuItem = $(this).find('a')
    var $languageControls = $(this).closest('ul').find('li')
    var $languageControlLinks = $languageControls.find('a')
    var language = $languageMenuItem.data('language')

    $languageControlLinks.not('[data-language="' + language + '"]').removeClass('active')
    $languageControlLinks.filter('[data-language="' + language + '"]').addClass('active')

    $('#selected-language').text(language)

    var $codeBlocks = $('pre.highlight')
    $codeBlocks.not('[data-language="' + language + '"]').addClass('d-none')
    $codeBlocks.filter('[data-language="' + language + '"]').removeClass('d-none')
  })
////// <----- REMOVED code for `language-control` navs

So somewhat the language picker is now only showing up Javascript, Python samples were dead forever 😅

This PR adds only the code necessary in the index.html file embedded, if for any case you do not want an small piece of JS in the body, it can easily be restored into an api.js and just point to it. For now it's so small the code that is not very verbose.

n8henrie commented 6 years ago

Nice. Just installed for the first time and couldn't figure out why that button wasn't working.

tomchristie commented 5 years ago

Thanks. Fixed in #624.