bugfix
This commit is contained in:
parent
0f544d4699
commit
5496d7b841
@ -474,6 +474,7 @@ bricks.App = class extends bricks.Layout {
|
||||
this.lang = navigator.language;
|
||||
}
|
||||
this.lang_x = this.observable('lang', this.lang);
|
||||
this.zindex = 10000;
|
||||
this.textList = [];
|
||||
this.i18n = new bricks.I18n(objget(opts, 'i18n', {}));
|
||||
this.session_id = null;
|
||||
@ -483,6 +484,11 @@ bricks.App = class extends bricks.Layout {
|
||||
this._Height = this.dom_element.offsetHeight;
|
||||
document.addEventListener('keydown', this.key_down_action.bind(this));
|
||||
}
|
||||
new_zindex(){
|
||||
const v = this.zindex;
|
||||
this.zindex = v + 1;
|
||||
return v;
|
||||
}
|
||||
screenHeight(){
|
||||
return this.dom_element.clientHeight;
|
||||
}
|
||||
|
@ -1,63 +1,4 @@
|
||||
var bricks = window.bricks || {};
|
||||
bricks.BPopup = class extends bricks.VBox {
|
||||
/*
|
||||
{
|
||||
holder:
|
||||
title:
|
||||
auto_open:
|
||||
auto_dismiss:
|
||||
archor:cc
|
||||
timeout:
|
||||
}
|
||||
*/
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
this.task = null;
|
||||
this.title = opts.title|| 'Title';
|
||||
this.archor = opts.archor || 'cc';
|
||||
this.timeout = opts.timeout || 0;
|
||||
this.panel.set_css('message');
|
||||
this.build();
|
||||
archorize(this.dom_element, this.archor);
|
||||
}
|
||||
|
||||
build(){
|
||||
var tb = new bricks.HBox({height:'40px'});
|
||||
tb.set_css('title');
|
||||
bricks.VBox.prototype.add_widget.bind(this)(tb);
|
||||
var tit = new bricks.Text({otext:this.title, i18n:true});
|
||||
this.content = new bricks.Filler({});
|
||||
bricks.VBox.prototype.add_widget.bind(this)(this.content);
|
||||
tb.add_widget(tit);
|
||||
this.holder = bricks.Body;
|
||||
if (this.opts.holder){
|
||||
if (type(this.opts.holder) == 'string'){
|
||||
this.holder = getWidgetById(this.opts.holder, bricks.Body);
|
||||
} else {
|
||||
this.holder = this.opts.holder;
|
||||
}
|
||||
}
|
||||
}
|
||||
open(){
|
||||
this.holder.add_widget(this);
|
||||
if (this.timeout > 0){
|
||||
this.task = schedule_once(this.dismiss.bind(this), this.timeout);
|
||||
}
|
||||
}
|
||||
add_widget(w, idx){
|
||||
this.content.add_widget(w, idx);
|
||||
if (this.opts.auto_open){
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
dismiss(){
|
||||
if (this.task){
|
||||
this.task.cancel();
|
||||
this.task = null
|
||||
}
|
||||
this.target_w.remove_widget(this);
|
||||
}
|
||||
}
|
||||
|
||||
bricks.Message = class extends bricks.Modal {
|
||||
/*
|
||||
|
34
bricks/popup.js
Normal file
34
bricks/popup.js
Normal file
@ -0,0 +1,34 @@
|
||||
var bricks = window.bricks || {};
|
||||
|
||||
bricks.Popup = class extends bricks.VBox {
|
||||
/*
|
||||
{
|
||||
timeout:0
|
||||
|
||||
*/
|
||||
constructor(opts){
|
||||
super();
|
||||
this.auto_task = null;
|
||||
this.set_css('popup');
|
||||
const zindex = bricks.app.new_zindex();
|
||||
this.set_style('zIndex', zindex);
|
||||
}
|
||||
open(){
|
||||
var rect = this.parent.showRectage();
|
||||
this.set_style('display', 'block');
|
||||
this.set_style('top',`${rect.top + window.scrollY}px`);
|
||||
thos.set_style('left',`${rect.left + window.scrollX}px`);
|
||||
this.set_style('width', `${rect.width}px`);
|
||||
this.set_style('height', `${rect.height}px`);
|
||||
if (this.timeout > 0){
|
||||
this.auto_task = schedule_once(this.auto_dismiss.bind(this), this.timeout)
|
||||
}
|
||||
}
|
||||
dismiss(){
|
||||
if (this.auto_task){
|
||||
this.auto_task.cancel();
|
||||
this.auto_task = null;
|
||||
}
|
||||
this.set_css('display':'none');
|
||||
}
|
||||
}
|
@ -41,6 +41,9 @@ bricks.JsWidget = class {
|
||||
}
|
||||
bricks.resize_observer.observe(this.dom_element);
|
||||
}
|
||||
showRectage(){
|
||||
return this.dom_element.getBoundingClientRect();
|
||||
}
|
||||
is_in_dom(){
|
||||
return document.contains(this.dom_element);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user