From 7914b395f34aa00321b09e008ff0b961b9d19ded Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 10 May 2024 10:29:19 +0800 Subject: [PATCH] add some --- const.js | 2 ++ frame.js | 3 +-- index.css | 4 +++- lib/page.js | 6 ++++++ plugin/state.js | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/const.js b/const.js index ebdde383..f53b40fd 100644 --- a/const.js +++ b/const.js @@ -47,6 +47,7 @@ var ice = { PROCESS_FIELD: "_field", PROCESS_AGAIN: "_again", PROCESS_HOLD: "_hold", + FIELD_PREFIX: "_prefix", MSG_PREFIX: "_prefix", MSG_INDEX: "_index", @@ -433,6 +434,7 @@ var icon = { full: "bi bi-arrows-fullscreen", open: "bi bi-box-arrow-up-right", more: "bi bi-three-dots-vertical", actions: "bi bi-three-dots", search: "bi bi-search", favor: "bi bi-star", + plugs: "bi bi-tools", key: "bi bi-hash", hash: "bi bi-hash", zone: "bi bi-diagram-3", id: "bi bi-sort-numeric-down", modify: "bi bi-pencil-square", rename: "bi bi-pencil-square", remove: "bi bi-trash", diff --git a/frame.js b/frame.js index 5d507c9f..9edaef4e 100644 --- a/frame.js +++ b/frame.js @@ -407,8 +407,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { var title = item.title || can.user.isMobile && (can.user.isEnglish(can)? name: (item.help||name)) || (!item.help || name == item.help || can.user.isEnglish(can)? name: name+"("+can.core.Split(item.help)[0]+")") target = can.base.isFunc(target)? target(): target return can.page.Append(can, target||can._output, [{view: [type, html.FIELDSET], style: item.style, list: [{type: html.LEGEND, list: [ - item.icons && {img: can.misc.Resource(can, (item.icons.indexOf(nfs.PS) == -1? nfs.USR_ICONS: "")+item.icons, item.space||item._space)}, - item.icon && {icon: item.icon}, {text: title}, + can.page.icons(can, item.icons||item.icon||name, item.space||item._space), {text: title}, ]}, {view: [html.OPTION, html.FORM]}, html.ACTION, html.OUTPUT, html.STATUS]}]) }, input: function(can, item, value, target, style) { if ([html.BR, html.HR].indexOf(item.type) > -1) { return can.page.Append(can, target, [item]) } diff --git a/index.css b/index.css index 11ff6aa5..f0065a1e 100644 --- a/index.css +++ b/index.css @@ -588,7 +588,9 @@ body div.path { font-family:var(--code-font-family); } body div.carte { font-family:var(--code-font-family); } body { font-size:var(--body-font-size); } legend { font-size:var(--legend-font-size); line-height:30px; height:var(--action-height); } -legend img { margin-right:var(--input-margin); height:32px } +legend>img { margin-right:var(--input-margin); height:var(--action-height); } +legend>span.icon:first-child { margin-right:var(--input-margin); } +legend>i:first-child { margin-right:var(--input-margin); } select, input { font-size:var(--body-font-size); height:var(--action-height); } input::placeholder, textarea::placeholder { font-style:italic; color:var(--disable-fg-color); } input[type=checkbox] { height:16px; width:16px; } textarea { font-size:var(--body-font-size); padding:var(--input-padding); height:var(--textarea-height); width:100%; outline:none; resize:vertical; } diff --git a/lib/page.js b/lib/page.js index 2f0582ed..ee39f3fe 100644 --- a/lib/page.js +++ b/lib/page.js @@ -381,6 +381,12 @@ Volcanos("page", { case html.BUTTON: item.value = item.value||item.name||mdb.LIST; break } return input }, + icons: function(can, name, space) { if (!name) { return } + if (can.base.contains(name, ".ico", ".png", ".jpg")) { return {img: can.misc.Resource(can, (name.indexOf(nfs.PS) == -1? nfs.USR_ICONS: "")+name, space)} } + // if (can.page.unicode[name]) { return {text: [can.page.unicode[name], "", "icon"]} } + if (can.base.beginWith(name, "bi ")) { return {icon: name} } + if (icon[name]) { return {icon: icon[name]} } + }, requireChina: function(can, title, list, name, path) { can.onappend.plugin(can, {title: title, display: "/plugin/story/china.js", style: html.FLOAT, height: can.ConfHeight(), width: can.ConfHeight()}, function(sub) { sub.run = function(event, cmds, cb) { var msg = can.request(event, {title: title, name: name, path: path}) diff --git a/plugin/state.js b/plugin/state.js index 2558746e..806dd686 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -28,7 +28,7 @@ Volcanos(chat.ONIMPORT, { } msg.Table(function(item) { tabs && can.onmotion.cache(can, function() { return tabHash }) can.onappend._plugin(can, item, {index: item.index, args: can.base.Obj(item.args||item.arg, []), height: height, width: width}, function(sub) { can._plugins = (can._plugins||[]).concat([sub]) - sub.run = function(event, cmds, cb) { var index = msg.Option(ice.MSG_INDEX)||item.index; can.run(can.request(event, {pod: item.space}), (msg[ice.MSG_PREFIX]? msg[ice.MSG_PREFIX]: index? [ctx.RUN, index]: []).concat(cmds), cb, true) } + sub.run = function(event, cmds, cb) { var index = msg.Option(ice.MSG_INDEX)||item.index; can.run(can.request(event, {pod: item.space}), (msg[ice.FIELD_PREFIX]? msg[ice.FIELD_PREFIX]: index? [ctx.RUN, index]: []).concat(cmds), cb, true) } can.page.ClassList.has(can, sub._target, html.FLOAT)? can.onmotion.float(sub): sub.onimport.size(sub, height, width, true), cb && cb(sub) if (item.style == html.FLOAT) { return } can.onmotion.delay(can, function() { can.onmotion.scrollIntoView(can, sub._target) }, 300) sub.onexport.output = function() { if (tabs) { msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION))