Skip to content

Commit

Permalink
ts: Convert trivial portico modules to TypeScript.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk committed Feb 25, 2023
1 parent 2fa61bc commit 96fadb3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $ from "jquery";

function sync_open_organizations_page_with_current_hash() {
function sync_open_organizations_page_with_current_hash(): void {
const hash = window.location.hash;
if (!hash || hash === "#all" || hash === "#undefined") {
$(".eligible_realm").show();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ClipboardJS from "clipboard";

new ClipboardJS("#copy");
document.querySelector("#copy").focus();
document.querySelector<HTMLElement>("#copy")!.focus();
4 changes: 2 additions & 2 deletions web/src/portico/dev-login.js → web/src/portico/dev-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import $ from "jquery";
$(() => {
// This code will be executed when the user visits /login and
// dev_login.html is rendered.
if ($("[data-page-id='dev-login']").length > 0 && window.location.hash.slice(0, 1) === "#") {
if ($("[data-page-id='dev-login']").length > 0 && window.location.hash.startsWith("#")) {
/* We append the location.hash to the input field with name next so that URL can be
preserved after user is logged in. See this:
https://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects */
$("input[name='next']").each(function () {
const new_value = $(this).attr("value") + window.location.hash;
const new_value = $(this).attr("value")! + window.location.hash;
$(this).attr("value", new_value);
});
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion web/src/portico/tippyjs.js → web/src/portico/tippyjs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from "jquery";
import tippy from "tippy.js";

function initialize() {
function initialize(): void {
tippy("[data-tippy-content]", {
// Same defaults as set in web app tippyjs module.
maxWidth: 300,
Expand Down

0 comments on commit 96fadb3

Please sign in to comment.