bugfix
This commit is contained in:
parent
3f8caaae81
commit
88930f63f9
@ -20,10 +20,21 @@ bricks.IconBar = class extends bricks.HBox {
|
||||
if (! opts.cheight){
|
||||
opts.cheight = 2;
|
||||
}
|
||||
if (! opts.rate){
|
||||
opts.rate = 1;
|
||||
}
|
||||
super(opts);
|
||||
this.height_int = 0;
|
||||
var tools = this.opts.tools;
|
||||
for (var i=0;i<tools.length;i++){
|
||||
var w = this.build_item(tools[i]);
|
||||
var opts_i = bricks.extend({}, tools[i]);
|
||||
if (!opts_i.rate){
|
||||
opts_i.rate = this.rate;
|
||||
}
|
||||
opts_i.cheight = opts.cheight;
|
||||
opts_i.cwidth = opts.cheight;
|
||||
opts_i.dynsize = true;
|
||||
var w = this.build_item(opts_i);
|
||||
w.set_style('margin-left', this.opts.margin || '10px');
|
||||
w.set_style('margin-right', this.opts.margin || '10px');
|
||||
if (tools[i].name){
|
||||
@ -37,27 +48,28 @@ bricks.IconBar = class extends bricks.HBox {
|
||||
}
|
||||
build_item(opts){
|
||||
var rate = opts.rate || this.opts.rate || 1;
|
||||
var h = bricks.app.charsize * rate;
|
||||
var h = bricks.app.charsize * rate * opts.cheight;
|
||||
if (this.height_int < h){
|
||||
this.height_int = h;
|
||||
}
|
||||
if (opts.name == 'blankicon'){
|
||||
return new bricks.BlankIcon({
|
||||
rate:rate,
|
||||
cheight:opts.cheight,
|
||||
cwidth:opts.cwidth,
|
||||
dynsize:opts.dynsize||true
|
||||
});
|
||||
}
|
||||
var opts1 = bricks.extend({}, opts);
|
||||
opts1.url = opts.icon;
|
||||
opts1.rate = opts.rate || rate;
|
||||
opts1.dynsize = opts.dynsize||true;
|
||||
var w = new bricks.Icon(opts1);
|
||||
w.bind('click', this.regen_event.bind(this, opts1));
|
||||
opts.url = opts.icon;
|
||||
console.log('opts=', opts, '-------');
|
||||
var w = new bricks.Icon(opts);
|
||||
w.bind('click', this.regen_event.bind(this, opts));
|
||||
return w;
|
||||
}
|
||||
regen_event(desc, event){
|
||||
this.dispatch(desc.name, desc);
|
||||
this.dispatch('command', desc);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
@ -24,28 +24,41 @@ bricks.Popup = class extends bricks.VBox {
|
||||
if (this.auto_dismiss){
|
||||
bricks.Body.bind('click', this.click_outside.bind(this));
|
||||
}
|
||||
this.moving_status = false;
|
||||
if (this.movable){
|
||||
this.setup_movable();
|
||||
console.log('movable ...');
|
||||
}
|
||||
}
|
||||
setup_movable(){
|
||||
this.moving_w.bind('mousedown', this.rec_start_pos.bind(this));
|
||||
this.moving_w.bind('touchstart', this.rec_start_pos.bind(this));
|
||||
}
|
||||
rec_start_pos(e){
|
||||
if (e.tsarget != this.moving_w.dom_element)
|
||||
if (e.target != this.moving_w.dom_element)
|
||||
{
|
||||
console.log('moving star failed', e.target, this.moving_w.dom_element, 'difference ...');
|
||||
return;
|
||||
}
|
||||
this.moving_status = true;
|
||||
this.offsetX = e.clientX - this.showRectage().left;
|
||||
this.offsetY = e.clientY - this.showRectage().top;
|
||||
this.moving_w.bind('mouseup', this.stop_moving.bind(this));
|
||||
bricks.Body.bind('mouseup', this.stop_moving.bind(this));
|
||||
bricks.Body.bind('touchend', this.stop_moving.bind(this));
|
||||
this.moving_w.bind('mousemove', this.moving.bind(this));
|
||||
this.moving_w.bind('touchmove', this.moving.bind(this));
|
||||
e.preventDefault();
|
||||
console.log('moving started ...');
|
||||
}
|
||||
moving(e){
|
||||
if (e.target != this.moving_w.dom_element){
|
||||
console.log('moving failed', e.target, this.moving_w.dom_element, 'difference ...');
|
||||
this.stop_moving();
|
||||
}
|
||||
if (!this.moving_status){
|
||||
console.log('moving failed', 'not started ...');
|
||||
return;
|
||||
}
|
||||
var cx, cy;
|
||||
cx = e.clientX - this.offsetX;
|
||||
cy = e.clientY - this.offsetY;
|
||||
@ -53,8 +66,12 @@ bricks.Popup = class extends bricks.VBox {
|
||||
this.set_style('top', cy + 'px');
|
||||
}
|
||||
stop_moving(e){
|
||||
console.log('stop moving ....');
|
||||
this.moving_status = false;
|
||||
this.moving_w.unbind('mousemove', this.moving.bind(this));
|
||||
this.moving_w.unbind('mouseup', this.stop_moving.bind(this));
|
||||
this.moving_w.unbind('touchmove', this.moving.bind(this));
|
||||
bricks.Body.unbind('mouseup', this.stop_moving.bind(this));
|
||||
bricks.Body.unbind('touchend', this.stop_moving.bind(this));
|
||||
}
|
||||
click_outside(event){
|
||||
if (event.target != this.dom_element){
|
||||
@ -140,15 +157,15 @@ bricks.PopupWindow = class extends bricks.Popup {
|
||||
this.auto_destroy = false;
|
||||
this.moving_w = this.title_bar;
|
||||
this.old_add_widget = bricks.Layout.prototype.add_widget.bind(this);
|
||||
console.log(this.old_add_widget);
|
||||
this.old_add_widget(this.title_bar);
|
||||
this.old_add_widget(this.content_w);
|
||||
this.build_title_bar();
|
||||
}
|
||||
build_title_bar(){
|
||||
this.tb_w = new bricks.IconBar( {
|
||||
cheight:1,
|
||||
margin:'5px',
|
||||
rate:1,
|
||||
rate:0.8,
|
||||
tools:[
|
||||
{
|
||||
name:'delete',
|
||||
|
Loading…
Reference in New Issue
Block a user