var bricks = window.bricks || {}; var tooltip = null; bricks.createTooltip = function(){ tooltip = document.createElement('div'); tooltip.className = 'tooltip'; tooltip.style.left = '50%'; tooltip.style.trabsform = 'translateX(-50%)'; var mouseoutHandler = (event) => { event.target.removeChild(tooltip); } window.addEventListener('mouseover', event => { if (!event.target.tooltop) return true; tooltip.textContent = event.target.tooltip; event.target.addEventListener( 'mouseout', mouseoutHandler, {once:true} ); }); } bricks.app = null; /* all type of bind action's desc has the following attributes: actiontype:'bricks', wid: event: target: datawidget: datascript: datamethod: datakwargs: rtdata: conform: and each type of binds specified attributes list following urlwidget action: mode:, options:{ method: params:{}, url: } bricks action: mode:, options:{ "widgettype":"gg", ... } method action: method: params: for methods kwargs script action: script: params: registerfunction action: rfname: params: event action: dispatch_event: params: */ bricks.widgetBuild = async function(desc, widget){ if (! widget){ widget = bricks.Body; } const klassname = desc.widgettype; var base_url = null; if (klassname == 'urlwidget'){ let url = absurl(desc.options.url, widget); base_url = url; let method = desc.options.method || 'GET'; let opts = desc.options.params || {}; var jcall = bricks.jcall; desc = await jcall(url, { "method":method, "params":opts}); } else { base_url = widget.baseURI; } let klass = bricks.Factory.get(desc.widgettype); if (! klass){ console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw); return null; } desc.options.baseURI = base_url; let w = new klass(desc.options); if (desc.hasOwnProperty('id')){ w.set_id(desc.id); } if (desc.hasOwnProperty('subwidgets')){ for (let i=0; i