-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageWidget_Builder.js
More file actions
136 lines (124 loc) · 3.54 KB
/
ImageWidget_Builder.js
File metadata and controls
136 lines (124 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
(function() {
let template = document.createElement("template");
template.innerHTML = `
<br>
<style>
#form {
font-family: Arial, sans-serif;
width: 400px;
margin: 0 auto;
}
a {
text-decoration: none;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 10px;
}
td {
padding: 1px;
text-align: left;
font-size: 13px;
}
input[type="text"] {
width: 100%;
padding: 10px;
border: 2px solid #ccc;
border-radius: 5px;
font-size: 13px;
box-sizing: border-box;
margin-bottom: 10px;
}
select {
width: 100%;
padding: 10px;
border: 2px solid #ccc;
border-radius: 5px;
font-size: 13px;
box-sizing: border-box;
margin-bottom: 10px;
}
input[type="submit"] {
background-color: #487cac;
color: white;
padding: 10px;
border: none;
border-radius: 5px;
font-size: 14px;
cursor: pointer;
width: 100%;
}
#label {
width: 140px;
}
</style>
<form id="form">
<table>
<tr>
<td>Image URL</td>
<td><input id="builder_src" type="text" placeholder="Enter Image URL"></td>
</tr>
<tr>
<td>Image Width</td>
<td><input id="builder_width" type="text" placeholder="Enter Image Width"></td>
</tr>
<tr>
<td>Image Height</td>
<td><input id="builder_height" type="text" placeholder="Enter Image Height"></td>
</tr>
</table>
<input value="Update Image" type="submit">
<br>
<p>Developed by <a target="_blank" href="https://linkedin.com/in/itsrohitchouhan">Rohit Chouhan</a></p>
</form>
`;
class ImageWidgetBuilderPanel extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({
mode: "open"
});
this._shadowRoot.appendChild(template.content.cloneNode(true));
this._shadowRoot
.getElementById("form")
.addEventListener("submit", this._submit.bind(this));
}
_submit(e) {
e.preventDefault();
this.dispatchEvent(
new CustomEvent("propertiesChanged", {
detail: {
properties: {
src: this.src,
width: this.width,
height: this.height
},
},
})
);
}
set src(_src) {
this._shadowRoot.getElementById("builder_src").value = _src;
}
get src() {
return this._shadowRoot.getElementById("builder_src").value;
}
set width(_width) {
this._shadowRoot.getElementById("builder_width").value = _width;
}
get width() {
return this._shadowRoot.getElementById("builder_width").value;
}
set height(_height) {
this._shadowRoot.getElementById("builder_height").value = _height;
}
get height() {
return this._shadowRoot.getElementById("builder_height").value;
}
}
customElements.define(
"com-rohitchouhan-sap-imagewidget-builder",
ImageWidgetBuilderPanel
);
})();