2022-11-27 17:16:56 +11:00
|
|
|
<html>
|
|
|
|
<head>
|
2022-11-29 22:02:38 +11:00
|
|
|
<style>
|
|
|
|
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');
|
|
|
|
</style>
|
2022-11-27 17:16:56 +11:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div style="height: 50px; width: 10000px; background-color: blue;"></div>
|
2022-11-28 21:32:06 +11:00
|
|
|
<button id="button"></button>
|
2022-11-29 22:02:38 +11:00
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
close
|
|
|
|
</span>
|
2022-11-27 17:16:56 +11:00
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
v
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
<p>Nice thanks man awesome</p>
|
|
|
|
|
|
|
|
|
|
|
|
<template id="x-widget-template">
|
|
|
|
<style>
|
2022-11-29 22:02:38 +11:00
|
|
|
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
* {
|
|
|
|
box-sizing: border-box;
|
2022-11-28 21:32:06 +11:00
|
|
|
--icon-default-dim: 60px;
|
2022-11-29 22:02:38 +11:00
|
|
|
--form-default-width: 450px;
|
|
|
|
--form-default-height: 600px;
|
2022-11-27 17:16:56 +11:00
|
|
|
--side-margin: 20px;
|
|
|
|
--site-falcon-purple: #AE55E7;
|
|
|
|
}
|
|
|
|
|
|
|
|
#icon {
|
2022-11-28 21:32:06 +11:00
|
|
|
width: var(--icon-default-dim);
|
|
|
|
height: var(--icon-default-dim);
|
2022-11-27 17:16:56 +11:00
|
|
|
position: fixed;
|
2022-11-28 21:32:06 +11:00
|
|
|
visibility: visible;
|
|
|
|
opacity: 1;
|
2022-11-29 22:02:38 +11:00
|
|
|
transition: top 0.3s ease 0s, left 0.3s ease 0s, scale 0.2s ease, transform 0.5s ease, visibility 0s linear 0.3s, opacity 0.3s linear;
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#icon.location-top-left {
|
|
|
|
left: var(--side-margin);
|
|
|
|
top: var(--side-margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
#icon.location-top-right {
|
2022-11-28 21:32:06 +11:00
|
|
|
left: calc(100% - var(--icon-default-dim) - var(--side-margin));
|
2022-11-27 17:16:56 +11:00
|
|
|
top: var(--side-margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
#icon.location-bottom-left {
|
|
|
|
left: var(--side-margin);
|
2022-11-28 21:32:06 +11:00
|
|
|
top: calc(100% - var(--icon-default-dim) - var(--side-margin));
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#icon.location-bottom-right {
|
2022-11-28 21:32:06 +11:00
|
|
|
left: calc(100% - var(--icon-default-dim) - var(--side-margin));
|
|
|
|
top: calc(100% - var(--icon-default-dim) - var(--side-margin));
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
2022-11-28 21:32:06 +11:00
|
|
|
#icon:hover {
|
|
|
|
scale: 1.05;
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
#icon > img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
#form {
|
2022-11-28 21:32:06 +11:00
|
|
|
width: var(--form-default-width);
|
|
|
|
height: var(--form-default-height);
|
2022-11-27 17:16:56 +11:00
|
|
|
background-color: white;
|
|
|
|
border: 0px;
|
|
|
|
border-radius: 10px 10px 10px 10px;
|
|
|
|
box-shadow: 0 4px 16px rgb(0 0 0 / 25%);
|
2022-11-29 22:02:38 +11:00
|
|
|
border-radius: 12px;
|
2022-11-27 17:16:56 +11:00
|
|
|
position: fixed;
|
2022-11-28 21:32:06 +11:00
|
|
|
visibility: visible;
|
|
|
|
opacity: 1;
|
2022-11-29 22:02:38 +11:00
|
|
|
transition: transform 0.6s ease, visibility 0s linear 0.3s, opacity 0.3s linear;
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#form.location-top-left {
|
|
|
|
left: var(--side-margin);
|
2022-11-28 21:32:06 +11:00
|
|
|
top: var(--side-margin);
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#form.location-top-right {
|
2022-11-28 21:32:06 +11:00
|
|
|
left: calc(100% - var(--form-default-width) - var(--side-margin));
|
|
|
|
top: var(--side-margin);
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#form.location-bottom-left {
|
|
|
|
left: var(--side-margin);
|
2022-11-28 21:32:06 +11:00
|
|
|
top: calc(100% - var(--form-default-height) - var(--side-margin));
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#form.location-bottom-right {
|
2022-11-28 21:32:06 +11:00
|
|
|
left: calc(100% - var(--form-default-width) - var(--side-margin));
|
|
|
|
top: calc(100% - var(--form-default-height) - var(--side-margin));
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#form-header {
|
|
|
|
top: 0px;
|
|
|
|
width: 100%;
|
|
|
|
height: 60px;
|
2022-11-29 22:02:38 +11:00
|
|
|
background-image: linear-gradient(#a544e3, var(--site-falcon-purple));
|
|
|
|
border-radius: 12px 12px 0px 0px;
|
2022-11-27 17:16:56 +11:00
|
|
|
border: 0px;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
.form-header-buttons {
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
color: white;
|
|
|
|
margin-left: 16px;
|
|
|
|
font-size: 26px;
|
|
|
|
transition: scale 0.2s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.form-header-buttons:hover {
|
|
|
|
scale: 1.1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#form-button-help {
|
|
|
|
margin-left: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#form-button-close {
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
#form-title {
|
2022-11-29 22:02:38 +11:00
|
|
|
font-family: "Alexandria", sans-serif;
|
2022-11-27 17:16:56 +11:00
|
|
|
font-weight: 400;
|
|
|
|
font-size: 24px;
|
|
|
|
color: white;
|
|
|
|
text-align: center;
|
2022-11-29 22:02:38 +11:00
|
|
|
user-select: none;
|
|
|
|
flex-grow: 1;
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#form-content-container {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
2022-11-27 18:31:55 +11:00
|
|
|
padding-left: 32px;
|
|
|
|
padding-right: 32px;
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#input-name-container {
|
2022-11-27 18:31:55 +11:00
|
|
|
width: 100%;
|
2022-11-27 19:02:48 +11:00
|
|
|
margin-top: 24px;
|
2022-11-27 17:16:56 +11:00
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:44:11 +11:00
|
|
|
.md-input {
|
2022-11-27 18:31:55 +11:00
|
|
|
width: 100%;
|
2022-11-27 17:16:56 +11:00
|
|
|
border: 1px solid #c0c0c0;
|
|
|
|
border-radius: 4px;
|
|
|
|
padding: 16px;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:44:11 +11:00
|
|
|
#input-name {
|
|
|
|
height: 48px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.label-md-input {
|
2022-11-27 17:16:56 +11:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 16px;
|
|
|
|
display: flex;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
2022-11-28 00:41:01 +11:00
|
|
|
#input-name + .label-md-input {
|
|
|
|
bottom: 0;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
#input-comment + .label-md-input {
|
|
|
|
margin-top: 15px;
|
|
|
|
}
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
#input-name:not(#input-name[value=""]), #input-comment:not(#input-comment[value=""]) {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:44:11 +11:00
|
|
|
.md-input, .label-md-input > div {
|
2022-11-29 22:02:38 +11:00
|
|
|
font-family: "Alexandria", sans-serif;
|
2022-11-27 17:16:56 +11:00
|
|
|
font-weight: 300;
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:44:11 +11:00
|
|
|
.label-md-input > div {
|
2022-11-27 17:16:56 +11:00
|
|
|
transition: all 0.15s ease-out, visibility 0s;
|
|
|
|
color: grey;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:44:11 +11:00
|
|
|
.md-input:focus {
|
2022-11-27 17:16:56 +11:00
|
|
|
outline: none;
|
|
|
|
border: 2px solid var(--site-falcon-purple);
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:55:16 +11:00
|
|
|
#input-name:focus + .label-md-input > div, #input-name:not(#input-name[value=""]) + .label-md-input > div {
|
2022-11-27 17:16:56 +11:00
|
|
|
font-size: 14px;
|
|
|
|
transform: translate(0, -150%);
|
|
|
|
background-color: white;
|
|
|
|
padding-left: 4px;
|
|
|
|
padding-right: 4px;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:55:16 +11:00
|
|
|
#input-comment:focus + .label-md-input > div, #input-comment:not(#input-comment[value=""]) + .label-md-input > div {
|
|
|
|
font-size: 14px;
|
2022-11-28 00:41:01 +11:00
|
|
|
transform: translate(0, -150%);
|
2022-11-27 18:55:16 +11:00
|
|
|
background-color: white;
|
|
|
|
padding-left: 4px;
|
|
|
|
padding-right: 4px;
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:44:11 +11:00
|
|
|
.md-input:focus + .label-md-input > div {
|
2022-11-27 17:16:56 +11:00
|
|
|
color: var(--site-falcon-purple);
|
|
|
|
}
|
2022-11-27 18:31:55 +11:00
|
|
|
|
|
|
|
#select-severity-container {
|
2022-11-27 19:02:48 +11:00
|
|
|
margin-top: 24px;
|
2022-11-27 18:31:55 +11:00
|
|
|
width: 100%;
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
|
|
grid-column-gap: 0px;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.severity-option {
|
|
|
|
margin: 0px;
|
|
|
|
height: 48px;
|
|
|
|
background-color: #ececec;
|
|
|
|
border: 2px solid #d3d3d3;
|
|
|
|
border-left: 0px;
|
2022-11-29 22:02:38 +11:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
transition: background-color 0.15s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.severity-option .material-symbols-rounded {
|
|
|
|
color: #5A5A5A;
|
|
|
|
}
|
|
|
|
|
|
|
|
.severity-option .material-symbols-rounded:not(:first-child) {
|
|
|
|
margin-left: -12px;
|
|
|
|
color: #5A5A5A;
|
2022-11-27 18:31:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
.severity-option:hover:not(.selected) {
|
|
|
|
background-color: #e0e0e0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.severity-option.selected {
|
|
|
|
background-color: #d3d3d3;
|
|
|
|
}
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
#select-severity-container > :first-child {
|
2022-11-27 18:31:55 +11:00
|
|
|
border-left: 2px solid #d3d3d3;
|
2022-11-27 19:02:48 +11:00
|
|
|
border-radius: 4px 0px 0px 4px;
|
2022-11-27 18:31:55 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#select-severity-container :last-child {
|
2022-11-27 19:02:48 +11:00
|
|
|
border-radius: 0px 4px 4px 0px;
|
2022-11-27 18:31:55 +11:00
|
|
|
}
|
2022-11-27 18:44:11 +11:00
|
|
|
|
|
|
|
#input-comment-container {
|
|
|
|
width: 100%;
|
2022-11-27 19:02:48 +11:00
|
|
|
margin-top: 24px;
|
2022-11-27 18:44:11 +11:00
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
#input-comment {
|
|
|
|
height: 150px;
|
2022-11-27 19:02:48 +11:00
|
|
|
resize: none;
|
2022-11-27 18:44:11 +11:00
|
|
|
}
|
2022-11-28 21:32:06 +11:00
|
|
|
|
|
|
|
#icon:not(.hidden), #form:not(.hidden) {
|
|
|
|
transition-delay: 0s;
|
|
|
|
}
|
|
|
|
|
|
|
|
#icon.hidden, #form.hidden {
|
|
|
|
pointer-events: none;
|
|
|
|
visibility: hidden;
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#icon.hidden.location-bottom-left, #form.hidden.location-bottom-left,
|
|
|
|
#icon.hidden.location-bottom-right, #form.hidden.location-bottom-right {
|
2022-11-29 22:02:38 +11:00
|
|
|
transform: translateY(100%);
|
2022-11-28 21:32:06 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#icon.hidden.location-top-left, #form.hidden.location-top-left,
|
|
|
|
#icon.hidden.location-top-right, #form.hidden.location-top-right {
|
2022-11-29 22:02:38 +11:00
|
|
|
transform: translateY(-100%);
|
2022-11-28 21:32:06 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#icon.hidden {
|
|
|
|
scale: 1.05;
|
|
|
|
}
|
2022-11-27 17:16:56 +11:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<div id="icon">
|
2022-11-28 21:32:06 +11:00
|
|
|
<img src="icon_open.png">
|
2022-11-27 17:16:56 +11:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="form">
|
|
|
|
<div id="form-header">
|
2022-11-29 22:02:38 +11:00
|
|
|
<span id="form-button-help" class="material-symbols-rounded form-header-buttons">
|
|
|
|
help
|
|
|
|
</span>
|
2022-11-27 17:16:56 +11:00
|
|
|
<div id="form-title">
|
|
|
|
New Ticket
|
|
|
|
</div>
|
2022-11-29 22:02:38 +11:00
|
|
|
<span id="form-button-close" class="material-symbols-rounded form-header-buttons">
|
|
|
|
close
|
|
|
|
</span>
|
2022-11-27 17:16:56 +11:00
|
|
|
</div>
|
|
|
|
<div id="form-content-container">
|
|
|
|
<div id="input-name-container">
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="input-name"
|
2022-11-27 18:44:11 +11:00
|
|
|
class="md-input"
|
2022-11-27 17:16:56 +11:00
|
|
|
name="name"
|
|
|
|
value=""
|
|
|
|
aria-labelledby="label-input-name"
|
|
|
|
/>
|
2022-11-27 18:44:11 +11:00
|
|
|
<label for="name" class="label-md-input">
|
2022-11-27 17:16:56 +11:00
|
|
|
<div>Name</div>
|
|
|
|
</label>
|
|
|
|
</div>
|
2022-11-27 18:31:55 +11:00
|
|
|
<div id="select-severity-container">
|
2022-11-29 22:02:38 +11:00
|
|
|
<div title="Info" class="severity-option selected" id="option-no-severity">
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
info
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div title="Low Priority" class="severity-option" id="option-low-severity">
|
|
|
|
<span class="material-symbols-rounded">
|
2022-11-27 18:31:55 +11:00
|
|
|
priority_high
|
2022-11-29 22:02:38 +11:00
|
|
|
</span>
|
2022-11-27 18:31:55 +11:00
|
|
|
</div>
|
2022-11-29 22:02:38 +11:00
|
|
|
<div title="Medium Priority" class="severity-option" id="option-medium-severity">
|
|
|
|
<span class="material-symbols-rounded">
|
2022-11-27 18:31:55 +11:00
|
|
|
priority_high
|
|
|
|
</span>
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
priority_high
|
2022-11-29 22:02:38 +11:00
|
|
|
</span>
|
2022-11-27 18:31:55 +11:00
|
|
|
</div>
|
2022-11-29 22:02:38 +11:00
|
|
|
<div title="High Priority" class="severity-option" id="option-high-severity">
|
|
|
|
<span class="material-symbols-rounded">
|
2022-11-27 18:31:55 +11:00
|
|
|
priority_high
|
|
|
|
</span>
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
priority_high
|
|
|
|
</span>
|
|
|
|
<span class="material-symbols-rounded">
|
|
|
|
priority_high
|
2022-11-29 22:02:38 +11:00
|
|
|
</span>
|
2022-11-27 18:31:55 +11:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-11-27 18:44:11 +11:00
|
|
|
<div id="input-comment-container">
|
|
|
|
<textarea
|
|
|
|
type="text"
|
|
|
|
id="input-comment"
|
|
|
|
class="md-input"
|
|
|
|
name="comment"
|
|
|
|
value=""
|
|
|
|
aria-labelledby="label-input-comment"
|
|
|
|
></textarea>
|
|
|
|
<label for="comment" class="label-md-input">
|
|
|
|
<div>Comment</div>
|
|
|
|
</label>
|
|
|
|
</div>
|
2022-11-27 17:16:56 +11:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
class XWidget extends HTMLElement {
|
|
|
|
#icon;
|
|
|
|
#form;
|
|
|
|
#location;
|
|
|
|
|
|
|
|
#pointerDown;
|
|
|
|
#moving;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
|
|
shadowRoot.appendChild(document.getElementById("x-widget-template").content.cloneNode(true));
|
|
|
|
|
|
|
|
this.#icon = this.#createIcon();
|
|
|
|
|
|
|
|
this.#form = this.#createForm();
|
|
|
|
|
|
|
|
this.#pointerDown = false;
|
|
|
|
this.#moving = false;
|
|
|
|
this.#location = "bottom-right";
|
|
|
|
}
|
|
|
|
|
|
|
|
connectedCallback() {
|
2022-11-29 22:02:38 +11:00
|
|
|
this.#renderInitial();
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
#renderInitial() {
|
2022-11-27 17:16:56 +11:00
|
|
|
if (this.isConnected) {
|
2022-11-28 21:32:06 +11:00
|
|
|
this.#renderIcon({visibility: "visible"});
|
2022-11-27 17:16:56 +11:00
|
|
|
this.#renderForm({visibility: "hidden"});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#createIcon() {
|
|
|
|
let icon = this.shadowRoot.getElementById("icon");
|
|
|
|
|
|
|
|
icon.addEventListener("pointerdown", (e) => this.#onIconPointerDown(e));
|
|
|
|
icon.addEventListener("pointermove", (e) => this.#onIconPointerMove(e));
|
|
|
|
icon.addEventListener("pointerup", (e) => this.#onIconPointerUp(e));
|
|
|
|
icon.addEventListener("pointerover", (e) => this.#onIconPointerOver(e));
|
|
|
|
icon.addEventListener("pointerout", (e) => this.#onIconPointerOut(e));
|
|
|
|
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
#createForm() {
|
|
|
|
let form = this.shadowRoot.getElementById("form");
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
let buttonHelp = this.shadowRoot.getElementById("form-button-help");
|
|
|
|
buttonHelp.addEventListener("click", (e) => this.#onFormHelpButtonClicked(e));
|
|
|
|
|
|
|
|
let buttonClose = this.shadowRoot.getElementById("form-button-close");
|
|
|
|
buttonClose.addEventListener("click", (e) => this.#onFormCloseButtonClicked(e));
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
let inputName = this.shadowRoot.getElementById("input-name");
|
|
|
|
inputName.addEventListener("input", (e) => this.#onNameInput(e));
|
|
|
|
|
2022-11-27 18:31:55 +11:00
|
|
|
let selectSeverityContainer = this.shadowRoot.getElementById("select-severity-container");
|
|
|
|
|
|
|
|
for (let i = 0; i < selectSeverityContainer.childElementCount; i++) {
|
|
|
|
let severityOption = selectSeverityContainer.children[i];
|
|
|
|
severityOption.addEventListener("click", (e) => this.#OnSeverityOptionClicked(e));
|
|
|
|
}
|
|
|
|
|
2022-11-27 19:02:48 +11:00
|
|
|
let inputComment = this.shadowRoot.getElementById("input-comment");
|
|
|
|
inputComment.addEventListener("input", (e) => this.#onCommentInput(e));
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
return form;
|
|
|
|
}
|
|
|
|
|
|
|
|
#renderIcon(parameters={}) {
|
|
|
|
if (this.#location == "top-left") {
|
|
|
|
removeClassByPrefix(this.#icon, "location");
|
|
|
|
this.#icon.classList.add("location-top-left");
|
|
|
|
}
|
|
|
|
else if (this.#location == "top-right") {
|
|
|
|
removeClassByPrefix(this.#icon, "location");
|
|
|
|
this.#icon.classList.add("location-top-right");
|
|
|
|
}
|
|
|
|
else if (this.#location == "bottom-left") {
|
|
|
|
removeClassByPrefix(this.#icon, "location");
|
|
|
|
this.#icon.classList.add("location-bottom-left");
|
|
|
|
}
|
|
|
|
else if (this.#location == "bottom-right") {
|
|
|
|
removeClassByPrefix(this.#icon, "location");
|
|
|
|
this.#icon.classList.add("location-bottom-right");
|
|
|
|
}
|
2022-11-28 21:32:06 +11:00
|
|
|
|
|
|
|
if (parameters["visibility"]) {
|
|
|
|
if (parameters["visibility"] == "visible") {
|
|
|
|
this.#icon.classList.remove("hidden");
|
|
|
|
}
|
|
|
|
else if (parameters["visibility"] == "hidden") {
|
|
|
|
this.#icon.classList.add("hidden");
|
|
|
|
}
|
|
|
|
}
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
#renderForm(parameters={}) {
|
|
|
|
if (this.#location == "top-left") {
|
|
|
|
removeClassByPrefix(this.#form, "location");
|
|
|
|
this.#form.classList.add("location-top-left");
|
|
|
|
} else if (this.#location == "top-right") {
|
|
|
|
removeClassByPrefix(this.#form, "location");
|
|
|
|
this.#form.classList.add("location-top-right");
|
|
|
|
} else if (this.#location == "bottom-left") {
|
|
|
|
removeClassByPrefix(this.#form, "location");
|
|
|
|
this.#form.classList.add("location-bottom-left");
|
|
|
|
} else if (this.#location == "bottom-right") {
|
|
|
|
removeClassByPrefix(this.#form, "location");
|
|
|
|
this.#form.classList.add("location-bottom-right");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parameters["visibility"]) {
|
2022-11-28 21:32:06 +11:00
|
|
|
if (parameters["visibility"] == "visible") {
|
|
|
|
this.#form.classList.remove("hidden");
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
2022-11-28 21:32:06 +11:00
|
|
|
else if (parameters["visibility"] == "hidden") {
|
|
|
|
this.#form.classList.add("hidden");
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
#onFormHelpButtonClicked(e) {
|
|
|
|
console.log("help pressed");
|
|
|
|
}
|
|
|
|
|
|
|
|
#onFormCloseButtonClicked(e) {
|
|
|
|
if (!this.#form.classList.contains("hidden")) {
|
|
|
|
this.#renderIcon({visibility: "visible"});
|
|
|
|
this.#renderForm({visibility: "hidden"});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
#onNameInput(e) {
|
|
|
|
let inputName = this.shadowRoot.getElementById("input-name");
|
|
|
|
|
|
|
|
inputName.setAttribute('value', inputName.value);
|
|
|
|
}
|
|
|
|
|
2022-11-27 19:02:48 +11:00
|
|
|
#onCommentInput(e) {
|
|
|
|
let inputComment = this.shadowRoot.getElementById("input-comment");
|
|
|
|
|
|
|
|
inputComment.setAttribute('value', inputComment.value);
|
|
|
|
}
|
|
|
|
|
2022-11-27 18:31:55 +11:00
|
|
|
#OnSeverityOptionClicked(e) {
|
|
|
|
let selectedSeverityOption = e.currentTarget;
|
|
|
|
|
|
|
|
let selectSeverityContainer = this.shadowRoot.getElementById("select-severity-container");
|
|
|
|
|
|
|
|
for (let i = 0; i < selectSeverityContainer.childElementCount; i++) {
|
|
|
|
let severityOption = selectSeverityContainer.children[i];
|
|
|
|
|
|
|
|
if (severityOption == selectedSeverityOption) {
|
|
|
|
if (!severityOption.classList.contains("selected")) {
|
|
|
|
severityOption.classList.add("selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
severityOption.classList.remove("selected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
#onIconPointerOver(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
#onIconPointerOut(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
#onIconPointerDown(e) {
|
2022-11-28 21:32:06 +11:00
|
|
|
if (e.button !== 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
this.#pointerDown = true;
|
|
|
|
|
|
|
|
this.#icon.setPointerCapture(e.pointerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
#onIconPointerMove(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
if (this.#pointerDown) {
|
|
|
|
this.#moving = true;
|
|
|
|
this.#icon.style.cursor = "grabbing";
|
|
|
|
this.#snapToCorner(e.clientX, e.clientY);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.#icon.style.cursor = "pointer";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#onIconPointerUp(e) {
|
2022-11-28 21:32:06 +11:00
|
|
|
if (e.button !== 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-27 17:16:56 +11:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
this.#icon.style.cursor = "pointer";
|
|
|
|
|
|
|
|
if (!this.#moving) {
|
2022-11-28 21:32:06 +11:00
|
|
|
if (this.#form.classList.contains("hidden")) {
|
|
|
|
this.#renderIcon({visibility: "hidden"});
|
|
|
|
this.#renderForm({visibility: "visible"});
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.#moving = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.#pointerDown = false;
|
|
|
|
|
|
|
|
this.#icon.releasePointerCapture(e.pointerId);
|
|
|
|
}
|
|
|
|
|
|
|
|
#snapToCorner(anchorX, anchorY) {
|
|
|
|
let locationChanged = false;
|
|
|
|
|
2022-11-29 22:02:38 +11:00
|
|
|
if (anchorX < window.innerWidth / 2) {
|
|
|
|
if (this.#location != "top-left" && anchorY < window.innerHeight / 2) {
|
2022-11-27 17:16:56 +11:00
|
|
|
this.#location = "top-left";
|
|
|
|
locationChanged = true;
|
|
|
|
}
|
2022-11-29 22:02:38 +11:00
|
|
|
else if (this.#location != "bottom-left" && anchorY > window.innerHeight - window.innerHeight / 2) {
|
2022-11-27 17:16:56 +11:00
|
|
|
this.#location = "bottom-left";
|
|
|
|
locationChanged = true;
|
|
|
|
}
|
|
|
|
}
|
2022-11-29 22:02:38 +11:00
|
|
|
else if (anchorX > window.innerWidth - window.innerWidth / 2) {
|
|
|
|
if (this.#location != "top-right" && anchorY < window.innerHeight / 2) {
|
2022-11-27 17:16:56 +11:00
|
|
|
this.#location = "top-right";
|
|
|
|
locationChanged = true;
|
|
|
|
}
|
2022-11-29 22:02:38 +11:00
|
|
|
else if (this.#location != "bottom-right" && anchorY > window.innerHeight - window.innerHeight / 2) {
|
2022-11-27 17:16:56 +11:00
|
|
|
this.#location = "bottom-right";
|
|
|
|
locationChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (locationChanged) {
|
2022-11-28 21:32:06 +11:00
|
|
|
this.#renderIcon({visibility: "visible"});
|
2022-11-27 17:16:56 +11:00
|
|
|
this.#renderForm({visibility: "hidden"});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeClassByPrefix(el, prefix) {
|
|
|
|
if (!el.classList) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let filteredClassList = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < el.classList.length; i++) {
|
|
|
|
if (!el.classList[i].startsWith(prefix)) {
|
|
|
|
filteredClassList.push(el.classList[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-28 21:32:06 +11:00
|
|
|
el.className = "";
|
|
|
|
|
|
|
|
for (let i = 0; i < filteredClassList; i++) {
|
|
|
|
el.classList.add(filteredClassList[i]);
|
|
|
|
}
|
2022-11-27 17:16:56 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
customElements.define("x-widget", XWidget);
|
|
|
|
document.body.appendChild(document.createElement("x-widget"));
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|