bricks/bricks/conform.js
2024-05-13 13:32:18 +08:00

43 lines
958 B
JavaScript

var bricks = window.bricks || {};
bricks.Conform = class extends bricks.Message {
constructor(opts){
opts.auto_open = true;
opts.auto_close = false;
opts.timeout = 0;
super(opts);
this.create_toolbar();
}
create_toolbar(){
var desc = {
tools:[
bricks.extend({
"name":"conform",
"icon":bricks_resource('imgs/conform.png'),
"label":'Conform'
}, this.opts.conform||{}),
bricks.extend({
"name":"discard",
"icon":bricks_resource('imgs/cancel.png'),
"label":"Discard"
}, this.opts.discard||{})
]
}
var w = new bricks.IconTextBar(desc);
w.bind('conform', this.conform_hndl.bind(this));
w.bind('discard', this.discard_hndl.bind(this));
if (!w) return;
this.message_w.add_widget(w);
}
conform_hndl(event){
this.dismiss();
this.dispatch('conformed');
}
discard_hndl(event){
this.dismiss();
this.dispatch('cancelled');
}
}
bricks.Factory.register('Conform', bricks.Conform);