forked from jspreadsheet/ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjexcel.webcomponent.js
51 lines (42 loc) · 1.34 KB
/
jexcel.webcomponent.js
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
class Jexcel extends HTMLElement {
constructor() {
super();
}
init(o) {
// Shadow root
const shadowRoot = this.attachShadow({mode: 'open'});
// Style
const cssJexcel = document.createElement('link');
cssJexcel.rel = 'stylesheet';
cssJexcel.type = 'text/css'
cssJexcel.href = 'jexcel.css';
shadowRoot.appendChild(cssJexcel);
const cssJsuites = document.createElement('link');
cssJsuites.rel = 'stylesheet';
cssJsuites.type = 'text/css'
cssJsuites.href = 'jsuites.css';
shadowRoot.appendChild(cssJsuites);
// Jexcel container
var container = document.createElement('div');
shadowRoot.appendChild(container);
// Garantee all elements are rendered
setTimeout(function() {
// Parse JSON
var config = JSON.parse(o.innerHTML);
// Root
config.root = shadowRoot;
// Reset container
o.innerHTML = '';
// Create jexcel element
jexcel(container, config);
}, 0);
}
connectedCallback() {
this.init(this);
}
disconnectedCallback() {
}
attributeChangedCallback() {
}
}
window.customElements.define('jexcel-spreadsheet', Jexcel);