{"version":3,"file":"js/07-tabs.js","sources":["js/07-tabs.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// determine user's operating system and show prerequisite instructions for that OS\nfunction setDefaultTab() {\n var OSName = \"\";\n // Detect user's operating system\n var ua = navigator.userAgent.toLowerCase();\n if (ua.indexOf(\"win\") != -1) {\n OSName = \"windows\";\n }\n if (ua.indexOf(\"mac\") != -1) {\n OSName = \"mac\";\n }\n if (ua.indexOf(\"linux\") != -1) {\n OSName = \"linux\";\n }\n // hide tab content except for selected tab and add active class to selected tab\n $(\".tab_content\").hide();\n\n // For each of the groups of tab contents, show the first one unless an OS is detected\n var sections = $('.sectionbody:has(.tab_content)');\n for(var i = 0; i < sections.length; i++){\n var section = $(sections.get(i));\n // Check if the current OS tab exists in the section\n if(OSName){\n var content = section.find(\".\" + OSName + \"_section\");\n var tab = section.find(\".\" + OSName + \"_link\");\n if(content.length > 0 && tab.length > 0){\n content.show(); \n tab.addClass(\"active\");\n continue;\n } \n }\n // If the current Operating System's tab has not been found\n // show the first tab's contents for every set of tabs in this section.\n var first_tab = section.find('.tab_link').first();\n // Find OS name to show all of its tab contents in this section.\n var class_list = first_tab[0].classList;\n for (var j = 0; j < class_list.length; j++) {\n var class_name = class_list[j];\n if (class_name !== \"tab_link\" && class_name.indexOf(\"_link\") > -1) {\n var tab_class = \".\" + class_name;\n var tab_content_class = \".\" + class_name.replace(\"link\", \"section\");\n section.find(tab_class).addClass(\"active\");\n section.find(tab_content_class).show();\n break;\n }\n }\n }\n}\n\n$(document).ready(function() {\n // show content for clicked OS tab\n $('.tab_link').on('click', function(event) {\n // hide all tab content and remove active class from all links\n $(\".tab_content\").hide();\n $(\".tab_link\").removeClass(\"active\");\n \n // get class of clicked tab and class of its respective content section\n var class_list = this.classList;\n for (var i = 0; i < class_list.length; i++) {\n var class_name = class_list[i];\n if (class_name !== \"tab_link\" && class_name.indexOf(\"_link\") > -1) {\n var tab_content = \".\" + class_name.replace(\"link\", \"section\");\n var tab_class = \".\" + class_name;\n }\n }\n\n // show content of clicked tab and add active class to clicked tab\n $(tab_content).show();\n $(tab_class).addClass(\"active\");\n });\n});\n\n$(window).on(\"load\", function(){\n $.ready.then(function(){\n setDefaultTab();\n });\n })"],"names":["setDefaultTab","OSName","ua","navigator","userAgent","toLowerCase","sections","indexOf","$","hide","i","length","section","get","content","find","tab","show","addClass","class_list","first","classList","j","class_name","tab_class","tab_content_class","replace","document","ready","on","event","removeClass","this","tab_content","window","then"],"mappings":"AAYA,SAASA,gBAkBL,IAjBA,IAAIC,EAAS,GAETC,EAAKC,UAAUC,UAAUC,YAAY,EAcrCC,GAbqB,CAAC,GAAtBJ,EAAGK,QAAQ,KAAK,IAChBN,EAAS,WAEY,CAAC,GAAtBC,EAAGK,QAAQ,KAAK,IAChBN,EAAS,OAEc,CAAC,GAAxBC,EAAGK,QAAQ,OAAO,IAClBN,EAAS,SAGbO,EAAE,cAAc,EAAEC,KAAK,EAGRD,EAAE,gCAAgC,GACzCE,EAAI,EAAGA,EAAIJ,EAASK,OAAQD,CAAC,GAAG,CACpC,IAAIE,EAAUJ,EAAEF,EAASO,IAAIH,CAAC,CAAC,EAE/B,GAAGT,EAAO,CACN,IAAIa,EAAUF,EAAQG,KAAK,IAAMd,EAAS,UAAU,EAChDe,EAAMJ,EAAQG,KAAK,IAAMd,EAAS,OAAO,EAC7C,GAAoB,EAAjBa,EAAQH,QAA2B,EAAbK,EAAIL,OAAW,CACpCG,EAAQG,KAAK,EACbD,EAAIE,SAAS,QAAQ,EACrB,QACJ,CACJ,CAMA,IAHA,IAEIC,EAFYP,EAAQG,KAAK,WAAW,EAAEK,MAAM,EAErB,GAAGC,UACrBC,EAAI,EAAGA,EAAIH,EAAWR,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