Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-protocol/src/util/make-link.ts
2500 views
1
/**
2
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
function isOpenNewTab(event: MouseEvent): boolean {
8
return event.metaKey || event.ctrlKey;
9
}
10
11
export function makeLink(node: HTMLElement, url: string, hover: string): void {
12
node.onclick = (event) => {
13
let target = "_self";
14
if (isOpenNewTab(event)) {
15
target = "_blank";
16
}
17
window.open(url, target);
18
};
19
node.style.cursor = "pointer";
20
node.title = hover;
21
}
22
23