Auto detect user OS and default tabs to it

pull/9814/head
Steven Powell 2020-11-30 15:46:05 -07:00
parent 322e138f6b
commit 2b43ff9989
7 changed files with 54 additions and 27 deletions

View File

@ -10,15 +10,15 @@ aliases:
The vmware driver supports virtualization across all VMware based hypervisors.
{{% tabs %}}
{{% tab "macOS" %}}
{{% mactab %}}
{{% readfile file="/docs/drivers/includes/vmware_macos_usage.inc" %}}
{{% /tab %}}
{{% tab "Linux" %}}
{{% /mactab %}}
{{% linuxtab %}}
No documentation is available yet.
{{% /tab %}}
{{% tab "Windows" %}}
{{% /linuxtab %}}
{{% windowstab %}}
No documentation is available yet.
{{% /tab %}}
{{% /windowstab %}}
{{% /tabs %}}
## Issues

View File

@ -136,7 +136,7 @@ eval $(minikube podman-env)
You should now be able to use podman client on the command line on your host machine talking to the podman service inside the minikube VM:
{{% tabs %}}
{{% tab "Linux" %}}
{{% linuxtab %}}
```shell
podman-remote help
@ -146,8 +146,8 @@ podman-remote help
Note: On Linux the remote client is called "podman-remote", while the local program is called "podman".
{{% /pageinfo %}}
{{% /tab %}}
{{% tab "macOS" %}}
{{% /linuxtab %}}
{{% mactab %}}
```shell
podman help
@ -157,8 +157,8 @@ podman help
Note: On macOS the remote client is called "podman", since there is no local "podman" program available.
{{% /pageinfo %}}
{{% /tab %}}
{{% tab "Windows" %}}
{{% /mactab %}}
{{% windowstab %}}
```shell
podman help
@ -168,7 +168,7 @@ podman help
Note: On Windows the remote client is called "podman", since there is no local "podman" program available.
{{% /pageinfo %}}
{{% /tab %}}
{{% /windowstab %}}
{{% /tabs %}}

View File

@ -22,7 +22,7 @@ All you need is Docker (or similarly compatible) container or a Virtual Machine
<h2 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">1</strong></span>Installation</h2>
{{% tabs %}}
{{% tab "Linux" %}}
{{% linuxtab %}}
For Linux users, we provide 3 easy download options:
@ -47,8 +47,8 @@ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest
sudo rpm -ivh minikube-latest.x86_64.rpm
```
{{% /tab %}}
{{% tab "macOS" %}}
{{% /linuxtab %}}
{{% mactab %}}
If the [Brew Package Manager](https://brew.sh/) installed:
@ -70,8 +70,8 @@ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
```
{{% /tab %}}
{{% tab "Windows" %}}
{{% /mactab %}}
{{% windowstab %}}
If the [Chocolatey Package Manager](https://chocolatey.org/) is installed, use it to install minikube:
@ -81,7 +81,7 @@ choco install minikube
Otherwise, download and run the [Windows installer](https://storage.googleapis.com/minikube/releases/latest/minikube-installer.exe)
{{% /tab %}}
{{% /windowstab %}}
{{% /tabs %}}
<h2 class="step"><span class="fa-stack fa-1x"><i class="fa fa-circle fa-stack-2x"></i><strong class="fa-stack-1x text-primary">2</strong></span>Start your cluster</h2>

View File

@ -0,0 +1,3 @@
<div class="tab-pane Linux" title="Linux" os="Linux">
{{ .Inner }}
</div>

View File

@ -0,0 +1,3 @@
<div class="tab-pane Mac" title="macOS" os="Mac">
{{ .Inner }}
</div>

View File

@ -0,0 +1,3 @@
<div class="tab-pane Windows" title="Windows" os="Windows">
{{ .Inner }}
</div>

View File

@ -2,17 +2,20 @@
function initTabs() {
$('.tab-content').find('.tab-pane').each(function(idx, item) {
var navTabs = $(this).closest('.code-tabs').find('.nav-tabs'),
title = $(this).attr('title');
navTabs.append('<li class="nav-tab"><a href="#" class="nav-tab">'+title+'</a></li>');
title = $(this).attr('title'),
os = $(this).attr('os');
navTabs.append('<li class="nav-tab '+os+'"><a href="#" class="nav-tab">'+title+'</a></li>');
});
$('.code-tabs ul.nav-tabs').each(function() {
$(this).find("li:first").addClass('active');
})
let tabSelector = getTabSelector(this);
$(this).find('li'+tabSelector).addClass('active');
});
$('.code-tabs .tab-content').each(function() {
$(this).find("div:first").addClass('active');
});
let tabSelector = getTabSelector(this);
$(this).find('div'+tabSelector).addClass('active');
})
$('.nav-tabs a').click(function(e){
e.preventDefault();
@ -25,3 +28,18 @@ function initTabs() {
tabPane.addClass('active');
});
}
const getTabSelector = currElement => {
let osSelector = '.'+getUserOS();
let hasMatchingOSTab = $(currElement).find(osSelector).length;
return hasMatchingOSTab ? osSelector : ':first';
}
const getUserOS = () => {
let os = ['Linux', 'Mac', 'Windows'];
let userAgent = navigator.userAgent;
for (let currentOS of os) {
if (userAgent.indexOf(currentOS) !== -1) return currentOS;
}
return 'Linux';
}