custom js

Prev Next

// Header Dropdown

window.addEventListener("load", function() {

var elNavListItems = document.querySelectorAll("header .header_top .header_top_nav .header_top_nav_left ul li");

var elMobileNavListItems = document.querySelectorAll(".slicknav_menu .header_top_nav_left ul li");

var customDropdownsDesktop = [elNavListItems[0], elNavListItems[2]];

var customDropdownsMobile = [elMobileNavListItems[0], elMobileNavListItems[2]]; // TODO: This menu is sometimes rendered after the execution of this code.

// Dropdowns HTML

var elProductsDropdown = `<div class="products__dropdown--items">

<ul>

<li>

<a href="https://knowledge.gexcon.com/docs/what-is-flacs">FLACS</a>

</li>

<li>

<a href="https://knowledge.gexcon.com/docs/what-is-effects">EFFECTS</a>

</li>

<li>

<a href="https://knowledge.gexcon.com/docs/what-is-riskcurves"

>RISKCURVES</a

>

</li>

</ul>

</div>`;

var elFAQsDropdown = `<div class="products__dropdown--items">

<ul>

<li>

<a href="https://knowledge.gexcon.com/docs/faqs">FLACS</a>

</li>

<li>

<a href="https://knowledge.gexcon.com/docs/faqs-for-effects">EFFECTS</a>

</li>

<li>

<a href="https://knowledge.gexcon.com/docs/faqs-for-riskcurves">RISKCURVES</a>

</li>

</ul>

</div>`;

// Responsive Hamburger Menu (For More Items)

if (elNavListItems.length > 3) {

var elResponsiveHamburger = document.createElement("li");

elResponsiveHamburger.classList.add("products__dropdown", "nav__more");

elResponsiveHamburger.innerHTML = `<a class="products__dropdown--title">

<i class="fas fa-bars"></i>

<div class="products__dropdown--items">

<ul></ul>

</div>

$('img[src*=".gif"]').each(function() {

var supergif = new SuperGif({

gif: this,

progressbar_height: 0,

auto_play: false,

});

var classes = '';

if ($(this).hasClass('fr-dib')) {

classes += ' fr-dib';

}

if ($(this).hasClass('fr-fil')) {

classes += ' fr-fil';

}

if ($(this).hasClass('fr-fir')) {

classes += ' fr-fir';

}

var control = $("<div class='control loading'>");

supergif.load(function() {

control.removeClass('loading').addClass('paused');

var playing = false;

var current_gif = supergif;

control.click(function() {

if (playing) {

current_gif.pause();

playing = false;

control.removeClass('playing').addClass('paused');

} else {

current_gif.play();

playing = true;

control.removeClass('paused').addClass('playing');

}

});

});

var $canvas = $(supergif.get_canvas());

$canvas.parent().addClass(classes).append(control);

});

}

// Override autocomplete template

$(document).ready(function() {

function sanitizeSearch(query) {

return query.replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/&/g, "&").replace(/"/g, """)

}

if (typeof autocompleteSearch !== 'undefined') {

var t = location.protocol + "//" + location.hostname + (location.port ? ":" + location.port : "") + (layoutData.mainVersion ? "" : "/" + layoutData.versionSlug);

var a = layoutData.isDefaultLanguage ? "/" + layoutData.hostingPath + "/" : "/" + layoutData.hostingPath + "/" + layoutData.langCode + "/";

autocompleteSearch.first().data().aaAutocomplete.dropdown.datasets[0].templates.suggestion = function(e, n) {

}

});

// put the breadcrumb in the correct place

$(function() {

$('#doc_content_block').prepend($('#bread-crumb-container'));

});

// Add responsive behaviour to tables

$(function() {

$('.content_block .content_container .content_block_text table').wrap('<div class="table-responsive"></div>');

});

$(function() {

// play controls on gifs

addGifControls();

$(window).on('articleload', function() {

// console.log("load event");

addGifControls();

});

$(window).one('load articleload', function() {

// Replace the texts in the feedback form at the bottom of the page

var feedbackElement = document.getElementById("doc_feedback_collect");

if (feedbackElement !== null) {

var observer = new MutationObserver(function() {

if ($('#doc_feedback_collect').is(':visible')) {

$('#doc_review_container .txt').html('Thank you for your feedback. <p>Your vote has been recorded. Feel free to provide additional details in the form below.</p>');

} else if ($('#doc_review_container .actions').is(':empty')) {

$('#doc_review_container .txt').html('Thank you for your feedback.');

}

});

observer.observe(feedbackElement, {

attributes: true

});

}

});

});

// Move the share buttons to the right sidebar

function fixSidebar() {

var $container = $('#partialViewContainer #doc_content_block .content_container_text_sec');

var $sharebox = $('.stickytop .share-details');

var elShareMobile = $('.content-header .article-action-items');

if ($container.hasClass('no-page-action')) {

$container.removeClass('no-page-action');

var right_sidebar = '<div class="page-action"><div class="right_sidebar_sticky" id="right_sidebar"></div></div>';

</a>`;

elNavListItems[2].after(elResponsiveHamburger);

var extraNav = [...elNavListItems].slice(3);

extraNav.forEach(function(item) {

document.querySelector("li.nav__more ul").innerHTML += item.outerHTML;

});

}

// Configuring header dropdowns

var appendDropdown = function(dropdown, i) {

dropdown.classList.add("products__dropdown");

dropdown.children[0].classList.add("products__dropdown--title");

dropdown.children[0].removeAttribute("href");

// Append dropdowns based on list item

if (i === 0) dropdown.children[0].insertAdjacentHTML("afterend", elProductsDropdown);

if (i === 1) dropdown.children[0].insertAdjacentHTML("afterend", elFAQsDropdown);

}

// TODO: remove these log statements after fixing the timing bug.

console.log(customDropdownsDesktop);

console.log(customDropdownsMobile); // These log statements show that the mobile elements can sometimes be empty. This is causing a javascript error in appendDropdown

customDropdownsDesktop.forEach((el, i) => appendDropdown(el, i));

customDropdownsMobile.forEach((el, i) => appendDropdown(el, i));

// Toggle dropdown

var elHeaderDropdownArr = document.querySelectorAll(".products__dropdown--title");

document.body.addEventListener("click", function(event) {

elHeaderDropdownArr?.forEach(function(el) {

event.target.closest(".products__dropdown") === el.closest(".products__dropdown") ?

el.closest(".products__dropdown").classList.toggle("show") :

el.closest(".products__dropdown").classList.remove("show");

});

});

});

/* Customize translation */

layoutData.viewAllResults = 'View all results';

/* Animated gifs */

function addGifControls() {

return '<div class="header_search_Results" id="attachmentResults"><a href = "' + t + a + e.slug + (layoutData.enableSearchHighlight ? "?highlight=" + sanitizeSearch(n.query) :"") + '" >' +

'<div> ' + e._highlightResult.title.value + "</div><p>" + e._snippetResult.content.value + "...</p><p>" + e.breadcrumb.trim() + "</p></a></div>"

}

autocompleteSearch.first().data().aaAutocomplete.dropdown.datasets[0].templates.empty = function(e) {

layoutData.showAttachmentsTabInSearch && layoutData.enableSearchAttachmentsFeature && getSearchResultHeder();

if (layoutData.isNoSearchResultFeedbackEnabled) {

const t = '<div class="no-search-results"><div class="no-search-feedback-container" style="display:none"><img src="https://cdn.document360.io/3dc9f77f-abbe-477e-a749-0e336d12c0cc/Images/Documentation/high-five5-anim-rm-delay1.svg"><div class="no-search-submit-comments">Thank you for your feedback! It means a lot to us.</div><div>Our team will address this as soon as possible.</div></div><div class="no-data"><div class="no-result-found">Sorry, no results for <span>"' + sanitizeSearch(e.query) + '"</span></div><textarea class="no-search-textarea" id="no-search-textarea" rows="3" maxlength="500" placeholder="Try a different search or suggest what you think we should write next."></textarea><div class="no-search-feedback_maxlimit" id="character-count">Characters: 0</div><div class="no-search-email-container"><div class="email-label-container"><div class="email_label" id="no_search_email_label">Email</div><div class="notify_changes"> <input id="no_search_notifyMeAboutChanges" class="feedback-checkbox" name="no_search_notifyMeAboutChanges" type="checkbox"> <label for="no_search_notifyMeAboutChanges" class="custom-control-label w-100"> Notify me about changes</label> </div></div><input class="feedback_text" type="text" id="no_search_feedback_mail" placeholder="Enter your email" value=""><div id="no_search_emailValidator" class="validator-error-msg hidden"> Please enter a valid email</div></div><div id="NoSearchCommentValidator" class="validator-error-msg hidden">Please enter valid comments</div><div class="no-search-feedbacks-button"><button disabled type="button" id="no-search-submit" class="btn btn-primary" onclick="submitNoSearchFeedback()">Submit</button></div></div></div>';

return t

}

return result = '<div class="no-data"><img src="//' + layoutData.cdn + '/images/no-search-data-icon.png"><p>No results were found for your query <span>"' + sanitizeSearch(e.query) + '"</span>, please try again.</div>',

result

};

}

});

$(function() {

if (typeof autocompleteSearch !== 'undefined') {

autocompleteSearch.on('autocomplete:updated', function() {

if ($('.aa-dropdown-menu').is(':visible')) {

autocompleteSearch.parents('.search-form').addClass('results-open');

} else {

autocompleteSearch.parents('.search-form, .searchform').removeClass('results-open');

}

});

$('#partialViewContainer #doc_content_block .content_container').append(right_sidebar);

$('#partialViewContainer #doc_content_block .content_container .right_sidebar_sticky').prepend($sharebox);

}

$sharebox.find('p').html("Share");

$('#right_sidebar div.os-size-observer.os-size-observer-appear + div').append($sharebox);

$(".content-header .article-action-items ul li .action-item").hasClass("share_content") ? $($sharebox).css("display", "flex") : $($sharebox).css("display", "none");

}

$(window).on('load articleload', fixSidebar);

$(fixSidebar);

$(document).ready(function() {

$('.email-txt').each(function() {

var text = $(this).html();

$(this).html(text.replace('Email (Optional)', 'If you would like a response to your comment above, please add your email address here'));

});

});