-
Notifications
You must be signed in to change notification settings - Fork 0
/
barebone.js
49 lines (44 loc) · 1.17 KB
/
barebone.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
import Origo from 'Origo';
const Barebone = function Barebone(options = {}) {
const {
buttonText = 'Default text',
content = 'Default content'
} = options;
const icon = '#fa-pencil';
let bareboneButton;
let viewer;
let target;
let modal;
return Origo.ui.Component({
name: 'barebone',
onInit() {
bareboneButton = Origo.ui.Button({
cls: 'o-barebone padding-small icon-smaller round light box-shadow',
click() {
modal = Origo.ui.Modal({
title: buttonText,
content,
target: viewer.getId()
});
this.addComponent(modal);
},
icon,
tooltipText: 'tooltipText to be shown!!',
tooltipPlacement: 'east'
});
},
onAdd(evt) {
viewer = evt.target;
if (!target) target = `${viewer.getMain().getNavigation().getId()}`;
this.addComponents([bareboneButton]);
this.render();
},
render() {
const htmlString = bareboneButton.render();
const el = Origo.ui.dom.html(htmlString);
document.getElementById(target).appendChild(el);
this.dispatch('render');
}
});
};
export default Barebone;