welcome to Windoz
This commit is contained in:
Executable
+76
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @category MyEic
|
||||
* @subcategory Libraries
|
||||
* @extends View
|
||||
*/
|
||||
class WindozDialogContent extends View {
|
||||
|
||||
icon = null;
|
||||
|
||||
actions = [
|
||||
{
|
||||
label: 'Cancel',
|
||||
onclick: this.cancel.bind(this),
|
||||
severity: 'secondary'
|
||||
},
|
||||
{
|
||||
label: 'OK',
|
||||
onclick: this.accept.bind(this),
|
||||
severity: 'primary'
|
||||
}
|
||||
]
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.options = options || {};
|
||||
window.addEventListener('resize', this.DOMContentResized.bind(this));
|
||||
}
|
||||
|
||||
DOMContentLoaded(options) {
|
||||
|
||||
}
|
||||
|
||||
get buttons() {
|
||||
let list = [];
|
||||
for(let descriptor of this.actions) {
|
||||
if(!descriptor.button) {
|
||||
let button = new Button(ui.create(`<button eicbutton>${descriptor.label}</>`), {
|
||||
icon: descriptor.icon,
|
||||
severity: descriptor.severity || '',
|
||||
disabled: descriptor.disabled || false,
|
||||
onclick: descriptor.onclick
|
||||
});
|
||||
descriptor.button = button;
|
||||
}
|
||||
list.push(descriptor.button) ;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
cancel(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
this.abort();
|
||||
}
|
||||
|
||||
accept(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
this.commit(true);
|
||||
}
|
||||
|
||||
DOMContentResized() {
|
||||
let limits = [
|
||||
{ name: 'desktop', min: 768 },
|
||||
{ name: 'tablet', min: 600 },
|
||||
{ name: 'mobile', min: 0 }
|
||||
];
|
||||
let device = limits.find(item => item.min < window.innerWidth);
|
||||
this.el.closest('[eicdialog], [eicdialog="eicdialog"]').setAttribute('device', device ? device.name: limits[0].name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('WindozDialogContent', WindozDialogContent);
|
||||
Reference in New Issue
Block a user