1
0
forked from x/volcanos
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-09-18 22:07:51 +08:00
parent ec8910c462
commit add0dfc832
6 changed files with 33 additions and 4 deletions

View File

@ -464,7 +464,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
sub.onmotion.float(sub), sub.onaction.close = function() { can.page.Remove(can, sub._target) }, cb && cb(sub)
}, can._root._target) },
figure: function(can, meta, target, cb) { if (meta.type == html.SELECT || meta.type == html.BUTTON) { return }
var input = meta.action||mdb.KEY, path = chat.PLUGIN_INPUT+input+nfs._JS; can.require([path], function(can) {
var input = meta.action||(meta.name == mdb.ICON? mdb.ICON: mdb.KEY), path = chat.PLUGIN_INPUT+input+nfs._JS; can.require([path], function(can) {
function _cb(sub, value, old) { if (value == old) { return } target.value = value, can.base.isFunc(cb) && cb(sub, value, old) }
target.onkeydown = function() { if (event.key == code.ESCAPE && target._can) { return target._can.close(), target.blur() } else if (event.key == code.ENTER) { can.base.isFunc(cb) && cb(event, target.value) } }
can.core.ItemCB(can.onfigure[input], function(key, on) { var last = target[key]||function() { }; target[key] = function(event) { can.misc.Event(event, can, function(msg) {

View File

@ -124,6 +124,10 @@ body>div.carte div.item span.icon.next { float:right; line-height:22px; height:2
body>div.carte.select.float>div.item { text-align:center; }
body>div.input { padding:20px; }
body>div.input td { padding:10px; }
body>div.input td:nth-child(2) { padding:10px 0;}
body>div.input tr.icon td:last-child { position:relative; }
body>div.input tr.icon td:last-child i:first-child { font-size:22px; position:absolute; left:15px; top:14px; }
body>div.input tr.icon td:last-child input { padding-left:30px; }
body>div.input td span.icon { margin-left:-20px; visibility:hidden; }
body>div.input td:hover span.icon { visibility:visible; }
body>div.input select { width:230px; }
@ -424,6 +428,7 @@ body.print select, body.print input[type=text], body.print textarea { box-shadow
body.print fieldset.draw div.output { background-color:lightgray; }
body.print fieldset.draw div.output div.content svg { background-color:lightgray; }
/* misc */
fieldset.input.icon div.output td { font-size:28px; padding:5px; }
fieldset.Search div.story[data-type=spark] { margin:0; }
fieldset.Search>div.output>div.profile { border-left:none; width:unset; }
fieldset.Action>div.output>fieldset.plugin:not(.output):not(.float):not(.full):not(.cmd) { padding:10px; margin:10px; box-shadow:var(--box-shadow); }

View File

@ -168,7 +168,7 @@ Volcanos("user", {
can.run(event, cmds, cb, true)
}, _enter: function(event) { return action.submit(event, can, html.SUBMIT), true }}, item), target)
}, item.onkeydown = function(event) { if (event.key == code.ESCAPE) { event.target.blur() } }
return {type: html.TR, list: [
return {type: html.TR, className: item.name, list: [
{type: html.TD, list: [{text: [can.user.trans(can, item.name||"", item._trans), html.LABEL]}]}, {type: html.TD, list: [{text: item.need == "must"? "*": "", style: {color: cli.RED}}]},
{type: html.TD, list: [can.page.input(can, item), item.type == html.TEXT && {icon: "delete", onclick: function(event) { event.target.previousSibling.value = "" }}]},
]}

View File

@ -30,7 +30,7 @@ Volcanos(chat.ONACTION, {list: [mdb.CREATE, web.SHARE, web.REFRESH], _init: func
create: function(event, can) { can.user.input(can.request(event, {title: "创建群组"}), can, [
{name: mdb.TYPE, values: [aaa.TECH, aaa.ROOT, aaa.TECH, aaa.VOID], _trans: "类型"},
{name: mdb.NAME, value: "hi", _trans: "群名", need: "must"},
{name: mdb.ICON, value: "", _trans: "图标"},
{name: mdb.ICON, value: "", _trans: "图标", action: "icon"},
{name: mdb.TEXT, value: "hello", _trans: "简介"},
], function(args) {
can.runAction(event, mdb.CREATE, args, function(msg) { can.misc.Search(can, {river: msg.Result()}) })

View File

@ -1,3 +1,3 @@
fieldset.Search { padding:10px; position:fixed; left:230px; top:48px; }
fieldset.Search { padding:10px; box-shadow:unset; position:fixed; left:230px; top:48px; }
fieldset.Search>div.output>div.profile { max-width:unset; }
fieldset.Search>div.output table.content { width:100%; }

24
plugin/input/icon.js Normal file
View File

@ -0,0 +1,24 @@
Volcanos(chat.ONFIGURE, {icon: {
_load: function(event, can, cb, target, name, value) {
can.runAction(event, ctx.RUN, ["web.chat.icons"], function(msg) {
can._show(can, msg, cb, target, name)
})
},
_show: function(can, msg, cb, target, name) { can.onmotion.clear(can)
var table = can.page.Append(can, can._output, [{type: html.TABLE}])._target, tr
msg.Table(function(value, index) { if (index%10 == 0) { tr = can.page.Append(can, table, [{type: html.TR}])._target }
can.page.Append(can, tr, [{type: html.TD, inner: value.icon, title: value.name, onclick: function() {
can.close(), can.base.isFunc(cb) && cb(can, value.name, target.value)
target._icon.className = value.name
}}])
}), can.onappend._status(can, [mdb.TOTAL]), can.Status(mdb.TOTAL, msg.Length())
can.page.style(can, can._output, html.MAX_HEIGHT, can.page.height()/2, html.MIN_WIDTH, target.offsetWidth, html.MAX_WIDTH, can.page.width()/2)
},
onclick: function(event, can, meta, target, cbs) { can.onmotion.focus(can, target) },
onfocus: function(event, can, meta, target, cbs) { cbs(function(sub, cb) { if (sub.Status(mdb.TOTAL) > 0) { return }
target._icon = target._icon || can.page.insertBefore(can, [{type: "i"}], target)
meta.msg && meta.msg.Length() > 0? sub._show(sub, meta.msg, cb, target, meta.name): sub._load(event, sub, cb, target, meta.name, target.value)
}) },
onblur: function(event, can, sub, cb) { sub && can.onmotion.delay(can, sub.close, 300) },
}})