From 13b2165d846b5052425e8941f7cb082beb1737d2 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 18 Jan 2023 19:08:08 +0800 Subject: [PATCH] opt table.js --- frame.js | 3 +-- index.css | 2 ++ lib/user.js | 2 +- plugin/local/code/inner.css | 2 ++ plugin/local/code/inner.js | 6 ++++++ plugin/table.js | 6 +++--- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frame.js b/frame.js index 6e3eda9d..23b928b2 100644 --- a/frame.js +++ b/frame.js @@ -486,8 +486,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) - if (target.offsetWidth > width/2) { can.page.style(can, target, html.MAX_WIDTH, width) } - if (target.offsetHeight > height/4) { can.page.style(can, target, html.MAX_HEIGHT, height/2) } + can.page.style(can, target, html.MAX_HEIGHT, can.base.Max(top+height-layout.top, height/2)) 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 2ef2f8ee..115adc91 100644 --- a/index.css +++ b/index.css @@ -144,6 +144,8 @@ div.status>legend { margin-left:2px; margin-right:0; float:right; clear:none; } fieldset.plugin:not(.float):not(.full):not(.cmd) { padding:10px; margin:10px; } fieldset.plugin:not(.float):not(.full):not(.cmd)>legend { float:none; } fieldset.auto, fieldset.full, fieldset.float, div.float { position:fixed; z-index:10; } +div.carte { overflow:auto; } +fieldset.input { overflow:auto; } div.code { position:sticky; left:0; } hr { border-bottom:gray dashed 1px; margin:5px; } td.hr { border-bottom:gray dashed 1px; margin:5px; } diff --git a/lib/user.js b/lib/user.js index fe88bac0..ff74c0c5 100644 --- a/lib/user.js +++ b/lib/user.js @@ -53,7 +53,7 @@ Volcanos("user", {info: {}, agent: { cli.SYSTEM, "命令", cli.ORDER, "加载", cli.BUILD, "构建", code.INNER, "源码", chat.IFRAME, "浏览", chat.LOCATION, "地图", html.PLUGIN, "插件", html.LABEL, "标签", html.HEIGHT, "高度", html.WIDTH, "宽度", ice.SHOW, "显示", ice.HIDE, "隐藏", chat.PROJECT, "项目", chat.PROFILE, "详情", chat.ACTIONS, "参数", - "full", "全屏", "Close", "关闭", "Close others", "关闭其它", "Close all", "关闭所有", + "full", "全屏", "Close", "关闭", "Close Other", "关闭其它", )[text]||text }, time: function(can, time, fmt) { var now = can.base.Date(time) diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index 7cfea558..7fb9321a 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -20,6 +20,7 @@ fieldset.inner>div.output>div.layout.flow { position:relative; } fieldset.inner>div.output>div.layout.flow>div.tabs { display:none; } fieldset.inner>div.output>div.layout.flow>div.path { display:none; } fieldset.inner.cmd>div.output>div.layout.flow>div.tabs { height:38px; display:block; overflow:auto; } +fieldset.inner.cmd>div.output>div.layout.flow>div.tabs.hide { display:none; } fieldset.inner.cmd>div.output>div.layout.flow>div.tabs>div { padding:10px; height:38px; float:left; } fieldset.inner.cmd>div.output>div.layout.flow>div.tabs>div>span { font-style:italic; } fieldset.inner.cmd>div.output>div.layout.flow>div.tabs>div>span.icon { padding:0 5px; } @@ -30,6 +31,7 @@ fieldset.inner.cmd>div.output>div.layout.flow>div.tabs div.avatar>img { height:3 fieldset.inner.cmd>div.output>div.layout.flow>div.tabs div.time { float:right; } fieldset.inner.cmd>div.output>div.layout.flow>div.path { font-style:italic; padding:5px; display:block; } fieldset.inner.cmd>div.output>div.layout.flow>div.path span.func { margin-left:20px; } +fieldset.inner.cmd>div.output>div.layout.flow>div.path.hide { display:none; } fieldset.inner.cmd>div.output>div.layout.flow>div.path span.view { font-size:22px; line-height:12px; padding:0 4px; float:right; cursor:pointer; } fieldset.inner.cmd>div.output>div.layout.flow>div.plug { height:31px; clear:both; } fieldset.inner.cmd>div.output>div.layout.flow>div.plug>legend { float:right; } diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index fac55a04..51bd7dd6 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -79,6 +79,11 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.onmotion.cl can.onimport.tabview(can, can.Option(nfs.PATH), can.Option(nfs.FILE), can.core.Split(button, ice.DF)[1]), can.onmotion.clearFloat(can) }) }}]) + can.ui.path.ondblclick = function(event) { + can.onmotion.toggle(can, can.ui.tabs) + can.onmotion.toggle(can, can.ui.plug) + can.onimport.layout(can) + } can.page.Append(can, can.ui.path, can.core.Item({ "\u25E8 ": function(event) { if (can.page.isDisplay(can.ui.profile)) { return can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) } @@ -418,6 +423,7 @@ Volcanos(chat.ONACTION, { can.page.style(can, can.user.input(can.request(event, {paths: paths}), can, [{name: nfs.FILE, style: {width: can.ui.content.offsetWidth/2}, run: function(event, cmds, cb) { can.run(can.request(event, {paths: paths}), cmds, function(msg) { if (cmds[0] == ctx.ACTION && cmds[1] == mdb.INPUTS) { var _msg = can.request({}), func = can.onexport.func(can) + can.core.Item(can.db.tabview, function(key) { var ls = can.core.Split(key, ice.DF); _msg.Push(nfs.PATH, ls[0]+ls[1]) }) can.core.List(func.list, function(item) { var ls = can.core.Split(item, ice.DF, ice.DF); _msg.Push(nfs.PATH, "line:"+ls[1]+":"+ls[0]) }) can.core.Item(can.onengine.plugin.meta, function(key, value) { _msg.Push(nfs.PATH, "index:can."+key) }) _msg.Copy(msg), cb(_msg) diff --git a/plugin/table.js b/plugin/table.js index 27272de2..82df82ef 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -41,12 +41,12 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( can.onmotion.select(can, action, html.DIV_TABS, tabs._target), can.base.isFunc(cb) && cb(event, tabs) }, _init: function(target) { tabs._target = target; var menu = tabs._menu||shy() can.page.Modify(can, target, {draggable: true, _close: function() { close(target) }, - ondragstart: function(event) { var target = event.target; action._drop = function(before) { action.insertBefore(target, before) } }, + ondragstart: function(event) { action._drop = function(before) { before.parentNode == action && action.insertBefore(target, before) } }, ondragover: function(event) { event.preventDefault(), action._drop(event.target) }, ondrop: function(event) { event.preventDefault(), action._drop(event.target) }, oncontextmenu: function(event) { can.user.carte(event, can, kit.Dict("Close", function(event) { close(target) }, - "Close others", function(event) { can.page.Select(can, action, html.DIV_TABS, function(_item) { _item == target || close(_item) }) }, - ), ["Close", "Close others", ""].concat(menu.list), function(event, button, meta) { (meta[button]||menu)(event, button, meta) }) }, + "Close Other", function(event) { can.page.Select(can, action, html.DIV_TABS, function(target) { target == tabs._target || close(target) }) }, + ), ["Close", "Close Other", ""].concat(menu.list), function(event, button, meta) { (meta[button]||menu)(event, button, meta) }) }, }), can.onmotion.delay(can, function() { target.click() }) }} }))._target