bugfix
This commit is contained in:
parent
e2268a518d
commit
7bfabb51ce
64
bricks/floaticonbar.js
Normal file
64
bricks/floaticonbar.js
Normal file
@ -0,0 +1,64 @@
|
||||
var bricks = window.bricks || {};
|
||||
|
||||
bricks.IconBar = class extends bricks.HBox {
|
||||
/*
|
||||
{
|
||||
margin:
|
||||
rate:
|
||||
tools:[
|
||||
{
|
||||
name:
|
||||
icon:
|
||||
rate:
|
||||
tip
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
var tools = this.opts.tools;
|
||||
for (var i=0;i<tools.length;i++){
|
||||
var rate = this.opts.rate || 1;
|
||||
var w = new bricks.Icon({
|
||||
url:tools[i].icon,
|
||||
rate:tools[i].rate || rate,
|
||||
tip:tools[i].tip
|
||||
});
|
||||
w.set_style('margin', this.opts.margin || '10px');
|
||||
if (tools[i].name){
|
||||
w.widget_id = tools[i].name;
|
||||
}
|
||||
w.set_style('cursor', 'pointer');
|
||||
w.bind('click', this.regen_event.bind(this,tools[i]))
|
||||
this.add_widget(w);
|
||||
}
|
||||
}
|
||||
regen_event(desc, event){
|
||||
this.dispatch(desc.name, desc);
|
||||
this.dispatch('command', desc);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
bricks.FloatIconBar = class extends bricks.HBox {
|
||||
constructor(opts){
|
||||
opts.height = opts.height || "auto";
|
||||
super(opts);
|
||||
this.float_w = new bricks.Icon({url:bricks_resource('imgs/float-out.png')});
|
||||
this.float_w.set_style('margin', '10px');
|
||||
this.float_w.bind('mousemove', this.show_icons.bind(this));
|
||||
this.add_widget(this.float_w);
|
||||
this.icons_box = new bricks.IconBar(opts);
|
||||
bricks.Body.bind('click', this.hide_icons.bind(this));
|
||||
}
|
||||
show_icons(){
|
||||
this.icons_box.set_style('display', 'flex');
|
||||
}
|
||||
hide_icons(){
|
||||
this.icons_box.set_style('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
bricks.Factory.register('IconBar', bricks.IconBar);
|
||||
bricks.Factory.register('FloatIconBar', bricks.FloatIconBar);
|
Loading…
Reference in New Issue
Block a user