var bricks = window.bricks || {}; /* */ bricks.Menu = class extends bricks.VBox { /* { "items": } */ constructor(options){ super(options); this.dom_element.style.display = ""; this.dom_element.style.backgroundColor = options.bgcolor || "white"; this.build_title(); this.build_description(); this.create_children(this, this.opts.items); this.bind('item_click', this.menu_clicked.bind(this)); } create_submenu_container(){ let cp = new bricks.VBox({}); cp.set_style('marginLeft', "15px"); cp.set_style('display', 'none'); return cp; } async menu_clicked(event){ console.log(event); let e = event.target; let opts = event.params; var t; var popts; if (this.target == 'PopupWindow'){ popts = bricks.get_popupwindow_default_options(); bricks.extend(popts, this.popup_options || {}); t = new bricks.PopupWindow(popts); } else if (this.target == 'Popup'){ popts = bricks.get_popup_default_options(); bricks.extend(popts, this.popup_options || {}); t = new bricks.Popup(popts); } else { t = bricks.getWidgetById(this.target); } if (t){ var desc = { "widgettype":"urlwidget", "options":{ "url":opts.url } } var w = await bricks.widgetBuild(desc, this); if (w && ! w.parent){ t.clear_widgets(); t.add_widget(w); } else { console.log('menu_clicked():widgetBuild() failed', desc); } } else { console.log('menu_clicked():', this.target, 'not found') } this.dispatch('command', opts); } create_children(w, items){ for (let i=0;i