{"version":3,"file":"js/05-features.js","sources":["js/05-features.js"],"sourcesContent":["/*******************************************************************************\n * Copyright (c) 2020 IBM Corporation and others.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors:\n * IBM Corporation - initial API and implementation\n *******************************************************************************/\n\n// Setup and listen to version clicks if there is more than one version of a feature on the version picker.\nfunction addVersionClick() {\n if ($(\".feature_version\").length === 1) {\n // If there's just one version, then disable the hover/click behavior for the version.\n $(\".feature_version\").css(\"cursor\", \"default\");\n $(\".feature_version\").attr(\"role\",\"text\");\n return;\n }\n var onclick = function(event) {\n var resource = $(event.currentTarget);\n var href = resource.attr(\"href\");\n var url = window.location.href;\n var newUrl = url.substring(0, url.lastIndexOf(\"/\")) + \"/\" + href;\n window.location.href = newUrl;\n };\n $(\".feature_version\").on(\"click\", onclick);\n}\n\nfunction acivateNavMenu() {\n // Add active class to the nav-menu\n $(\".nav-panel-menu\").addClass(\"is-active\");\n}\n\nfunction highlightSelectedVersion() {\n if (window.location.hash) {\n var url = window.location.href.split('#')[0];\n } else {\n var url = window.location.href;\n }\n var version = url.substring(url.lastIndexOf(\"/\") + 1);\n var versionHref = $('.feature_version[href=\"' + version + '\"]');\n if (versionHref.length === 1) {\n versionHref.addClass(\"feature_version_selected\");\n var ariaLabel = versionHref.attr(\"aria-label\");\n versionHref.attr(\"aria-label\", ariaLabel + \" selected\");\n }\n}\n\n// Versioned features have a non-versioned page to support linking to the latest version of a feature without having to supply the version. E.g. link:docs/ref/feature/appSecurity.adoc will create appSecurity.html which redirects to the highest version of that feature (at the time), appSecurity-3.0.html. If there are versions for the current page but the current href doesn't match any of them, then we're on a versionless page that should be versioned, so we should redirect to the highest version of this feature.\nfunction checkForNonVersionedPage() {\n if ($(\".feature_version\").length > 0) {\n var url = window.location.href;\n var urlWithoutHash = url;\n if (url.indexOf(\"#\") > -1) {\n urlWithoutHash = url.substring(0, url.indexOf(\"#\"));\n }\n var href = urlWithoutHash.substring(\n urlWithoutHash.indexOf(\"/reference/feature/\") + 19\n );\n if ($('.feature_version[href=\"' + href + '\"]').length === 0) {\n // Redirect to the highest version\n var href = $(\".feature_version\")\n .first()\n .attr(\"href\");\n var newUrl = url.substring(0, url.lastIndexOf(\"/\")) + \"/\" + href;\n window.location.href = newUrl;\n }\n }\n}\n\n// When loading the page, if the page from the url isn't selected in the TOC we need to look for its version in the TOC and highlight it since the multiple feature versions only have one TOC entry.\nfunction selectTOC() {\n var first_version = $(\".feature_version\").first();\n var href = first_version.attr(\"href\");\n if (!href) {\n // If the feature is a single version it won't have a version switcher at the top. Get the href from the url.\n href = window.location.href;\n href = href.substring(href.lastIndexOf(\"/\") + 1);\n }\n // Look for toc under the features dropdown\n var featureDropdown = $(\"li > span\").filter(function() {\n return this.innerText == \"Features\";\n });\n if (featureDropdown.length === 0) {\n featureDropdown = $(\"li > a.nav-link\").filter(function() {\n return this.innerText == \"Features\";\n });\n }\n featureDropdown = featureDropdown.parent();\n var featureToc = featureDropdown.find(\"a.nav-link\").filter(function() {\n var tocHref = $(this).attr(\"href\");\n tocHref = tocHref.substring(tocHref.lastIndexOf(\"/\") + 1);\n return href === tocHref;\n });\n if (featureToc.length > 0) {\n var li = featureToc.parent()[0];\n var anchor = li.querySelector(\".nav-link\");\n navigation.activateCurrentPath($(li));\n navigation.scrollItemToMidpoint($(anchor));\n }\n}\n\n$(document).ready(function() {\n checkForNonVersionedPage();\n addVersionClick();\n acivateNavMenu();\n highlightSelectedVersion();\n selectTOC();\n});\n"],"names":["addVersionClick","$","length","css","attr","on","event","href","currentTarget","url","window","location","newUrl","substring","lastIndexOf","acivateNavMenu","addClass","highlightSelectedVersion","ariaLabel","version","hash","split","versionHref","checkForNonVersionedPage","urlWithoutHash","indexOf","first","selectTOC","anchor","first_version","featureDropdown","filter","this","innerText","featureToc","parent","find","tocHref","li","querySelector","navigation","activateCurrentPath","scrollItemToMidpoint","document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