From 9230c610a4416fe2b20c26669c239feccbcf549d Mon Sep 17 00:00:00 2001 From: shylinux Date: Wed, 25 Jan 2023 09:33:19 +0800 Subject: [PATCH] opt some --- frame.js | 3 ++- index.css | 1 + plugin/table.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frame.js b/frame.js index 2c5ebc5c..8a99bbbd 100644 --- a/frame.js +++ b/frame.js @@ -327,6 +327,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.onmotion.modifys(can, event.target, function(event, value, old) { run(event, mdb.MODIFY, [key, value]) }, item) }} }); table && can.onappend.style(can, chat.CONTENT, table), msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table) + table.offsetWidth > can.ConfWidth() / 2 && can.onappend.style(can, "full", table) return keys && can.page.RangeTable(can, table, can.core.List(keys, function(key) { return can.page.Select(can, table, html.TH, function(th, index) { if (th.innerHTML == key) { return index } })[0] })), table }, board: function(can, text, target) { text && text.Result && (text = text.Result()); if (!text) { return } @@ -440,7 +441,7 @@ Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||can._ro var rect = event.target == document.body? {left: can.page.width()/2, top: can.page.height()/2, right: can.page.width()/2, bottom: can.page.height()/2}: event.target.getBoundingClientRect() var layout = right? {left: rect.right, top: rect.top}: {left: rect.left, top: rect.bottom} can.getActionSize(function(left, top, width, height) { left = left||0, top = top||0, height = can.base.Max(height, can.page.height()-top) - can.page.style(can, target, html.MAX_HEIGHT, can.base.Max(top+height-layout.top, height/2)) + can.page.style(can, target, html.MAX_HEIGHT, can.base.Max(top+height-layout.top, height/4*3)) if (layout.top+target.offsetHeight > top+height) { layout.top = top+height-target.offsetHeight } if (layout.left+target.offsetWidth > left+width) { layout.left = left+width-target.offsetWidth } }); return can.onmotion.move(can, target, layout), layout diff --git a/index.css b/index.css index 24063806..07ac4df2 100644 --- a/index.css +++ b/index.css @@ -41,6 +41,7 @@ table.content th { background-color:steelblue; padding:2px 5px; } table.content td { padding:2px 5px; } table.content.action th:last-child { position:sticky; right:2px; } table.content.action td:last-child { background-color:steelblue; position:sticky; right:2px; } +table.content.full { width:100%; } div.code { background-color:#343a3445; font-size:14px; padding:10px; border:green solid 1px; } div.story[data-type=spark] { background-color:#2169a9a6; color:white; padding:5px 10px; border-left:blue solid 5px; margin:10px; } h1 { text-align:center; margin:20px 0; } h2 { margin:20px 0; } h3 { margin:20px 0; } ul { padding-left:40px; margin:20px 0; } diff --git a/plugin/table.js b/plugin/table.js index c19c9edf..6ea7fab1 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -11,7 +11,9 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( }); return } var cbs = can.onimport[can.Conf(ctx.STYLE)||msg.Option(ctx.STYLE)]; if (can.base.isFunc(cbs)) { can.onappend.style(can, can._args[ctx.STYLE], target), can.core.CallFunc(cbs, {can: can, msg: msg, target: target}) - } else { can.onappend.table(can, msg, null, target), can.onappend.board(can, msg, target) } can.onmotion.story.auto(can, target) + } else { + can.onappend.table(can, msg, null, target), can.onappend.board(can, msg, target) + } can.onmotion.story.auto(can, target) }, _system_app: function(can, msg, target) { can.page.Appends(can, target, msg.Table(function(item) { var name = item.name||item.text return {view: html.ITEM, style: {"text-align": "center", margin: 10, width: 100, "float": "left"}, list: [