From 2f5a9d4d9738a43f6c1901b67159d9b0f5e483d9 Mon Sep 17 00:00:00 2001 From: shy Date: Wed, 22 Nov 2023 10:48:49 +0800 Subject: [PATCH] add some --- const.js | 4 ++-- frame.js | 30 +++++++++++++----------------- lib/page.js | 2 +- panel/action.js | 3 +-- panel/header.js | 5 +++-- plugin/state.js | 2 +- plugin/table.js | 1 + 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/const.js b/const.js index 3a3ba44b..c60bfe39 100644 --- a/const.js +++ b/const.js @@ -145,7 +145,7 @@ var nfs = { REPLACE: "replace", FROM: "from", TO: "to", SUBJECT: "subject", CONTENT: "content", SOURCE: "source", TARGET: "target", - PUSH: "push", PULL: "pull", + CLONE: "clone", PUSH: "push", PULL: "pull", RECENT: "recent", IMAGE: "image", SH: "sh", SHY: "shy", GO: "go", JS: "js", CSS: "css", HTML: "html", SVG: "svg", _JS: ".js", _CSS: ".css", @@ -257,7 +257,7 @@ var http = { GET: "GET", PUT: "PUT", POST: "POST", DELETE: "DELETE", Accept: "Accept", ContentType: "Content-Type", ApplicationJSON: "application/json", ApplicationFORM: "application/x-www-form-urlencoded", } -var html = {PLUGIN_MARGIN: 10, PLUGIN_PADDING: 10, ACTION_HEIGHT: 32, ACTION_MARGIN: 200, +var html = {PLUGIN_MARGIN: 10, PLUGIN_PADDING: 10, ACTION_MARGIN: 200, ACTION_HEIGHT: 32, STATUS_HEIGHT: 32, FIELDSET: "fieldset", LEGEND: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status", OPTION_ARGS: "select.args,input.args,textarea.args", INPUT_ARGS: "input.args,textarea.args", INPUT_BUTTON: "input[type=button]", INPUT_FILE: "input[type=file]", FORM_OPTION: "form.option", DIV_ACTION: "div.action", DIV_OUTPUT: "div.output", DIV_STATUS: "div.status", diff --git a/frame.js b/frame.js index e96b9c71..96766937 100644 --- a/frame.js +++ b/frame.js @@ -237,23 +237,19 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: can.page.inputs(can, sub.onimport.list, html.TEXT) }) } sub.db.hash = can.isCmdMode()? can.misc.SearchHash(can): [] - can.page.requireModules(can, can.Conf("modules"), function() { if (sub.Mode() != "result") { can.onmotion.clear(can, output) } - can.onexport._output(sub, msg) - can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) { - if (action !== false) { can.onkeymap._build(sub) - can.onmotion.clear(can, can._action), sub.onappend._action(sub, can.Conf(ice.MSG_ACTION)||msg.Option(ice.MSG_ACTION), action||can._action) - sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS)), can.user.isMobile || sub.onappend.tools(sub, msg) - can.core.Item(can.Action(), function(key) { - var value = can.misc.sessionStorage(can, [can.ConfIndex(), ctx.ACTION, key]) - value && can.Action(key, value[0]) - }) - } - can.onappend.style(sub, sub.Conf(ctx.STYLE)), can.onmotion.story.auto(can, can._output) - if (can.onimport.size) { if (can.isFullMode() || can.isCmdMode()) { can.ConfHeight(can.page.height()), can.ConfWidth(can.page.width()) } - can.onimport.size(can, can.ConfHeight(), can.ConfWidth(), can.Conf("_auto"), can.Mode()), can.onexport.output(sub, msg) - } can.base.isFunc(cb) && cb(msg) - }, target: output}) - }) + can.onexport._output(sub, msg), sub.Mode() != "result" && can.onmotion.clear(can, output) + can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) { + if (action !== false) { can.onkeymap._build(sub) + can.onmotion.clear(can, can._action), sub.onappend._action(sub, can.Conf(ice.MSG_ACTION)||msg.Option(ice.MSG_ACTION), action||can._action) + sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS)), can.user.isMobile || sub.onappend.tools(sub, msg) + can.core.Item(can.Action(), function(key) { var value = can.misc.sessionStorage(can, [can.ConfIndex(), ctx.ACTION, key]); value && can.Action(key, value[0]) }) + } + can.onappend.style(sub, sub.Conf(ctx.STYLE)), can.onmotion.story.auto(can, can._output) + if (can.onimport.size) { if (can.isFullMode() || can.isCmdMode()) { can.ConfHeight(can.page.height()), can.ConfWidth(can.page.width()) } + can.onimport.size(can, can.ConfHeight(), can.ConfWidth(), can.Conf("_auto"), can.Mode()), can.onexport.output(sub, msg) + can.isCmdMode() && can.page.style(can, can._output, html.HEIGHT, sub.ConfHeight(), html.WIDTH, sub.ConfWidth()) + } can.base.isFunc(cb) && cb(msg) + }, target: output}) }) }, _status: function(can, list, status) { status = status||can._status, can.onmotion.clear(can, status); var keys = {} diff --git a/lib/page.js b/lib/page.js index 1e67ec5f..d3e78362 100644 --- a/lib/page.js +++ b/lib/page.js @@ -374,5 +374,5 @@ Volcanos("page", { return msg }, styleValue: function(can, key) { const styles = getComputedStyle(document.body); return styles.getPropertyValue(key) }, - styleValueInt: function(can, key) { return can.base.trimSuffix(can.page.styleValue(can, key), "px") } + styleValueInt: function(can, key) { return parseInt(can.base.trimSuffix(can.page.styleValue(can, key), "px")) } }) diff --git a/panel/action.js b/panel/action.js index 8c19ab20..37c1e027 100644 --- a/panel/action.js +++ b/panel/action.js @@ -1,8 +1,7 @@ (function() { const TABS = "tabs", TABVIEW = "tabview", HORIZON = "horizon", VERTICAL = "vertical", GRID = "grid", FREE = "free", FLOW = "flow", PAGE = "page", CAN_LAYOUT = "can.layout" Volcanos(chat.ONIMPORT, {_init: function(can, msg) { var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM), list = can.misc.SearchHash(can) can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) { item.type = chat.PLUGIN, item.mode = can.Mode(); if (item.deleted == ice.TRUE) { return next() } - item.width = can.ConfWidth()-can.Conf(html.MARGIN_X) - if (item.style == html.OUTPUT) { item.width = can.ConfWidth() } + item.width = can.ConfWidth()-can.Conf(html.MARGIN_X); if (item.style == html.OUTPUT) { item.width = can.ConfWidth() } if (msg.Length() == 1) { item.height = can.ConfHeight()-html.ACTION_HEIGHT-can.Conf(html.MARGIN_Y) } can.onappend.plugin(can, item, function(sub, meta, skip) { can._plugins = (can._plugins||[]).concat([sub]), can.onimport._tabs(can, sub, meta), skip || next() sub.onaction._close = function() { can.onengine.signal(can, chat.ONACTION_REMOVE, can.request({river: river, storm: storm}, item)), can.page.Remove(can, sub._target) } diff --git a/panel/header.js b/panel/header.js index efea8d8f..fe8bf5e7 100644 --- a/panel/header.js +++ b/panel/header.js @@ -62,10 +62,11 @@ Volcanos(chat.ONACTION, {_init: function(can) { can.user.info.email = msg.Option(aaa.EMAIL), can.user.info.repos = msg.Option(nfs.REPOS) msg.Option(nfs.SCRIPT) && can.require(can.base.Obj(msg.Option(nfs.SCRIPT)), function(can) { can.onaction.source(can, msg) }) msg.Option(mdb.PLUGIN) && can.onappend.plugin(can, {index: msg.Option(mdb.PLUGIN)}, function(sub) { can.onmotion.hidden(can, sub._target) }, document.body) - html.ACTION_HEIGHT = can.page.styleValueInt(can, "--action-height") - html.ACTION_MARGIN = can.page.styleValueInt(can, "--action-margin") html.PLUGIN_MARGIN = can.page.styleValueInt(can, "--plugin-margin") html.PLUGIN_PADDING = can.page.styleValueInt(can, "--plugin-padding") + html.ACTION_MARGIN = can.page.styleValueInt(can, "--action-margin") + html.ACTION_HEIGHT = can.page.styleValueInt(can, "--action-height") + html.STATUS_HEIGHT = can.page.styleValueInt(can, "--status-height") lang(msg, function() { can.onmotion.clear(can), can.onimport._init(can, can.request(), can._output), can.onengine.signal(can, chat.ONLOGIN) }) } can.run(can.request({}, {_method: http.GET}), [], function(msg) { lang(msg) diff --git a/plugin/state.js b/plugin/state.js index 72252d29..74a1edfd 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -206,7 +206,7 @@ Volcanos(chat.ONEXPORT, { return can.base.Min(height, can.sub.ConfHeight()/2) }, outputMargin: function(can) { return 0 }, - statusHeight: function(can) { return can.page.ClassList.has(can, can._target, html.OUTPUT) || !can.page.isDisplay(can._status) || can._status.innerHTML == "" || (can._target.offsetHeight > 0 && can._status.offsetHeight == 0)? 0: html.ACTION_HEIGHT }, + statusHeight: function(can) { return can.page.ClassList.has(can, can._target, html.OUTPUT) || !can.page.isDisplay(can._status) || can._status.innerHTML == "" || (can._target.offsetHeight > 0 && can._status.offsetHeight == 0)? 0: html.STATUS_HEIGHT }, link: function(can) { var args = can.Option(); args.pod = can.ConfSpace(), args.cmd = can.ConfIndex(); return can.misc.MergePodCmd(can, args, true) }, args: function(can) { return can.Option() }, close: function(can, msg) {}, diff --git a/plugin/table.js b/plugin/table.js index 025271c2..de6ba196 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -187,6 +187,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( sub.onexport.output = function() { var width = can.ConfWidth()-(can.ui && can.ui.project? can.ui.project.offsetWidth: 0) can.page.style(can, sub._output, html.MAX_HEIGHT, "", html.HEIGHT, "", html.WIDTH, "", html.MAX_WIDTH, "") sub.onimport.size(sub, can.ConfHeight()/2, can.base.Min(sub._target.offsetWidth, width/2, width/(can.base.isIn(sub.ConfIndex(), code.COMPILE, cli.RUNTIME)? 1: 2)), true) + sub.onimport.size(sub, can.ConfHeight()/2, can.base.Min(sub._target.offsetWidth, width/2, width), true) } can.onmotion.hidden(can, sub._target), sub._legend._target = sub._target, sub._legend._meta = {index: meta.index} can.page.Append(can, sub._legend,[{text: [can.page.unicode.remove, "", mdb.REMOVE], onclick: function(event) {