mirror of https://github.com/zulip/zulip.git
ts: Convert portico/tabbed-instructions.js to TypeScript.
This commit is contained in:
parent
213d0f4990
commit
5047f1a81d
|
@ -1,8 +1,11 @@
|
|||
import $ from "jquery";
|
||||
|
||||
import * as blueslip from "../blueslip";
|
||||
import * as common from "../common";
|
||||
|
||||
export function detect_user_os() {
|
||||
export type UserOS = "android" | "ios" | "mac" | "windows" | "linux";
|
||||
|
||||
export function detect_user_os(): UserOS {
|
||||
if (/android/i.test(navigator.userAgent)) {
|
||||
return "android";
|
||||
}
|
||||
|
@ -21,7 +24,7 @@ export function detect_user_os() {
|
|||
return "mac"; // if unable to determine OS return Mac by default
|
||||
}
|
||||
|
||||
export function activate_correct_tab($codeSection) {
|
||||
export function activate_correct_tab($codeSection: JQuery<HTMLElement>): void {
|
||||
const user_os = detect_user_os();
|
||||
const desktop_os = new Set(["mac", "linux", "windows"]);
|
||||
const $li = $codeSection.find("ul.nav li");
|
||||
|
@ -56,7 +59,11 @@ export function activate_correct_tab($codeSection) {
|
|||
if (!$active_list_items.length) {
|
||||
$li.first().addClass("active");
|
||||
const language = $li.first()[0].dataset.language;
|
||||
if (language) {
|
||||
$blocks.filter("[data-language=" + language + "]").addClass("active");
|
||||
} else {
|
||||
blueslip.error("Tabbed instructions widget has no tabs to activate!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue