function initDynamic () {
    // Bootstrap popover
    $('button[data-toggle="popover"]').popover().click(function (e) {
      e.preventDefault();
    });

    const version = $('#version strong').html();
    $('#sidenav li').removeClass('is-new');
    if (apiProject.template.withCompare) {
      $('#sidenav li[data-version=\'' + version + '\']').each(function () {
        const group = $(this).data('group');
        const name = $(this).data('name');
        const length = $('#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\']').length;
        const index = $('#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\']').index($(this));
        if (length === 1 || index === length - 1) { $(this).addClass('is-new'); }
      });
    }

    // tabs
    $('.nav-tabs-examples a').click(function (e) {
      e.preventDefault();
      $(this).tab('show');
    });
    $('.nav-tabs-examples').find('a:first').tab('show');

    // switch content-type for body inputs (json or form-data)
    $('.sample-request-content-type-switch').change(function () {
      if ($(this).val() === 'body-form-data') {
        $('#sample-request-body-json-input-' + $(this).data('id')).hide();
        $('#sample-request-body-form-input-' + $(this).data('id')).show();
      } else {
        $('#sample-request-body-form-input-' + $(this).data('id')).hide();
        $('#sample-request-body-json-input-' + $(this).data('id')).show();
      }
    });

    if (apiProject.template.aloneDisplay) {
      // show group
      $('.show-group').click(function () {
        const apiGroup = '.' + $(this).attr('data-group') + '-group';
        const apiGroupArticle = '.' + $(this).attr('data-group') + '-article';
        $('.show-api-group').addClass('hide');
        $(apiGroup).removeClass('hide');
        $('.show-api-article').addClass('hide');
        $(apiGroupArticle).removeClass('hide');
      });

      // show api
      $('.show-api').click(function () {
        const id = this.getAttribute('href').substring(1);
        const selectedVersion = document.getElementById('version').textContent.trim();
        const apiName = `.${this.dataset.name}-article`;
        const apiNameVersioned = `[id="${id}-${selectedVersion}"]`;
        const apiGroup = `.${this.dataset.group}-group`;

        $('.show-api-group').addClass('hide');
        $(apiGroup).removeClass('hide');
        $('.show-api-article').addClass('hide');

        let targetEl = $(apiName);
        if ($(apiNameVersioned).length) {
          targetEl = $(apiNameVersioned).parent();
        }
        targetEl.removeClass('hide');

        if (id.match(/_(header|footer)/)) {
          document.getElementById(id).classList.remove('hide');
        }
      });
    }

    // call scrollspy refresh method
    if (!apiProject.template.aloneDisplay) {
      $('body').scrollspy('refresh');
    }

    if (apiProject.template.aloneDisplay) {
      const hashVal = window.location.hash;
      if (hashVal != null && hashVal.length !== 0) {
        const version = document.getElementById('version').textContent.trim();
        const el = document.querySelector(`li .${hashVal.slice(1)}-init`);
        const elVersioned = document.querySelector(`li[data-version="${version}"] .show-api.${hashVal.slice(1)}-init`);
        let targetEl = el;
        if (elVersioned) {
          targetEl = elVersioned;
        }
        targetEl.click();
      }
    }
  }
/**
     * On Template changes, recall plugins.
     */
On Template changes, recall plugins.
On Template changes recall plugins .
function initDynamic () {
    $('button[data-toggle="popover"]').popover().click(function (e) {
      e.preventDefault();
    });
    const version = $('#version strong').html();
    $('#sidenav li').removeClass('is-new');
    if (apiProject.template.withCompare) {
      $('#sidenav li[data-version=\'' + version + '\']').each(function () {
        const group = $(this).data('group');
        const name = $(this).data('name');
        const length = $('#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\']').length;
        const index = $('#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\']').index($(this));
        if (length === 1 || index === length - 1) { $(this).addClass('is-new'); }
      });
    }
    $('.nav-tabs-examples a').click(function (e) {
      e.preventDefault();
      $(this).tab('show');
    });
    $('.nav-tabs-examples').find('a:first').tab('show');
    $('.sample-request-content-type-switch').change(function () {
      if ($(this).val() === 'body-form-data') {
        $('#sample-request-body-json-input-' + $(this).data('id')).hide();
        $('#sample-request-body-form-input-' + $(this).data('id')).show();
      } else {
        $('#sample-request-body-form-input-' + $(this).data('id')).hide();
        $('#sample-request-body-json-input-' + $(this).data('id')).show();
      }
    });
    if (apiProject.template.aloneDisplay) {
      $('.show-group').click(function () {
        const apiGroup = '.' + $(this).attr('data-group') + '-group';
        const apiGroupArticle = '.' + $(this).attr('data-group') + '-article';
        $('.show-api-group').addClass('hide');
        $(apiGroup).removeClass('hide');
        $('.show-api-article').addClass('hide');
        $(apiGroupArticle).removeClass('hide');
      });
      $('.show-api').click(function () {
        const id = this.getAttribute('href').substring(1);
        const selectedVersion = document.getElementById('version').textContent.trim();
        const apiName = `.${this.dataset.name}-article`;
        const apiNameVersioned = `[id="${id}-${selectedVersion}"]`;
        const apiGroup = `.${this.dataset.group}-group`;
        $('.show-api-group').addClass('hide');
        $(apiGroup).removeClass('hide');
        $('.show-api-article').addClass('hide');
        let targetEl = $(apiName);
        if ($(apiNameVersioned).length) {
          targetEl = $(apiNameVersioned).parent();
        }
        targetEl.removeClass('hide');
        if (id.match(/_(header|footer)/)) {
          document.getElementById(id).classList.remove('hide');
        }
      });
    }
    if (!apiProject.template.aloneDisplay) {
      $('body').scrollspy('refresh');
    }
    if (apiProject.template.aloneDisplay) {
      const hashVal = window.location.hash;
      if (hashVal != null && hashVal.length !== 0) {
        const version = document.getElementById('version').textContent.trim();
        const el = document.querySelector(`li .${hashVal.slice(1)}-init`);
        const elVersioned = document.querySelector(`li[data-version="${version}"] .show-api.${hashVal.slice(1)}-init`);
        let targetEl = el;
        if (elVersioned) {
          targetEl = elVersioned;
        }
        targetEl.click();
      }
    }
  }
function initDynamic ( ) { $ ( 'button[data-toggle="popover"]' ) . popover ( ) . click ( function ( e ) { e . preventDefault ( ) ; } ) ; const version = $ ( '#version strong' ) . html ( ) ; $ ( '#sidenav li' ) . removeClass ( 'is-new' ) ; if ( apiProject . template . withCompare ) { $ ( '#sidenav li[data-version=\'' + version + '\']' ) . each ( function ( ) { const group = $ ( this ) . data ( 'group' ) ; const name = $ ( this ) . data ( 'name' ) ; const length = $ ( '#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\']' ) . length ; const index = $ ( '#sidenav li[data-group=\'' + group + '\'][data-name=\'' + name + '\']' ) . index ( $ ( this ) ) ; if ( length === 1 || index === length - 1 ) { $ ( this ) . addClass ( 'is-new' ) ; } } ) ; } $ ( '.nav-tabs-examples a' ) . click ( function ( e ) { e . preventDefault ( ) ; $ ( this ) . tab ( 'show' ) ; } ) ; $ ( '.nav-tabs-examples' ) . find ( 'a:first' ) . tab ( 'show' ) ; $ ( '.sample-request-content-type-switch' ) . change ( function ( ) { if ( $ ( this ) . val ( ) === 'body-form-data' ) { $ ( '#sample-request-body-json-input-' + $ ( this ) . data ( 'id' ) ) . hide ( ) ; $ ( '#sample-request-body-form-input-' + $ ( this ) . data ( 'id' ) ) . show ( ) ; } else { $ ( '#sample-request-body-form-input-' + $ ( this ) . data ( 'id' ) ) . hide ( ) ; $ ( '#sample-request-body-json-input-' + $ ( this ) . data ( 'id' ) ) . show ( ) ; } } ) ; if ( apiProject . template . aloneDisplay ) { $ ( '.show-group' ) . click ( function ( ) { const apiGroup = '.' + $ ( this ) . attr ( 'data-group' ) + '-group' ; const apiGroupArticle = '.' + $ ( this ) . attr ( 'data-group' ) + '-article' ; $ ( '.show-api-group' ) . addClass ( 'hide' ) ; $ ( apiGroup ) . removeClass ( 'hide' ) ; $ ( '.show-api-article' ) . addClass ( 'hide' ) ; $ ( apiGroupArticle ) . removeClass ( 'hide' ) ; } ) ; $ ( '.show-api' ) . click ( function ( ) { const id = this . getAttribute ( 'href' ) . substring ( 1 ) ; const selectedVersion = document . getElementById ( 'version' ) . textContent . trim ( ) ; const apiName = ` ${ this . dataset . name } ` ; const apiNameVersioned = ` ${ id } ${ selectedVersion } ` ; const apiGroup = ` ${ this . dataset . group } ` ; $ ( '.show-api-group' ) . addClass ( 'hide' ) ; $ ( apiGroup ) . removeClass ( 'hide' ) ; $ ( '.show-api-article' ) . addClass ( 'hide' ) ; let targetEl = $ ( apiName ) ; if ( $ ( apiNameVersioned ) . length ) { targetEl = $ ( apiNameVersioned ) . parent ( ) ; } targetEl . removeClass ( 'hide' ) ; if ( id . match ( / _(header|footer) / ) ) { document . getElementById ( id ) . classList . remove ( 'hide' ) ; } } ) ; } if ( ! apiProject . template . aloneDisplay ) { $ ( 'body' ) . scrollspy ( 'refresh' ) ; } if ( apiProject . template . aloneDisplay ) { const hashVal = window . location . hash ; if ( hashVal != null && hashVal . length !== 0 ) { const version = document . getElementById ( 'version' ) . textContent . trim ( ) ; const el = document . querySelector ( ` ${ hashVal . slice ( 1 ) } ` ) ; const elVersioned = document . querySelector ( ` ${ version } ${ hashVal . slice ( 1 ) } ` ) ; let targetEl = el ; if ( elVersioned ) { targetEl = elVersioned ; } targetEl . click ( ) ; } } }
On Template changes, recall plugins.
On Template changes recall plugins .
// Bootstrap popover // tabs // switch content-type for body inputs (json or form-data) // show group // show api // call scrollspy refresh method