1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00

add checkbox

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-12-11 15:38:15 +08:00
parent 1500290674
commit c0b9ce8eb1
6 changed files with 39 additions and 14 deletions

View File

@ -45,6 +45,7 @@ var ice = {
MSG_MODE: "sess.mode", MSG_THEME: "sess.theme", MSG_TITLE: "sess.title", MSG_RIVER: "sess.river", MSG_STORM: "sess.storm",
MSG_DAEMON: "sess.daemon", LOG_DISABLE: "log.disable", LOG_TRACEID: "log.id",
MSG_COST: "sess.cost",
TABLE_CHECKBOX: "table.checkbox",
MSG_DEBUG: "debug",
ErrWarn: "warn: ", ErrNotLogin: "not login: ", ErrNotRight: "not right: ", ErrNotValid: "not valid: ", ErrNotFound: "not found: ",
@ -118,10 +119,11 @@ var aaa = {
USER: "user", AUTH: "auth", SESS: "sess", ROLE: "role",
LOGIN: "login", LOGOUT: "logout",
BACKGROUND: "background", AVATAR: "avatar", EMAIL: "email", SECRET: "secret",
AVATAR: "avatar", BACKGROUND: "background",
LANGUAGE: "language", ENGLISH: "english", CHINESE: "chinese",
LONGITUDE: "longitude", LATITUDE: "latitude",
PROVINCE: "province", COUNTRY: "country", CITY: "city",
LONGITUDE: "longitude", LATITUDE: "latitude",
EMAIL: "email", SECRET: "secret",
USERNICK: "usernick", USERNAME: "username", PASSWORD: "password", USERROLE: "userrole", USERZONE: "userzone",
VOID: "void", TECH: "tech", ROOT: "root",
@ -299,6 +301,7 @@ var html = {RIVER_WIDTH: 230, PROJECT_WIDTH: 230,
WSS: "wss", WEBVIEW: "webview", CHROME: "chrome", MOBILE: "mobile", LANDSCAPE: "landscape",
BODY: "body", FORM: "form", LABEL: "label", TITLE: "title", INNER: "inner", SPACE: "space", CLICK: "click",
SELECT: "select", INPUT: "input", TEXT: "text", FILE: "file", TEXTAREA: "textarea", BUTTON: "button",
CHECKBOX: "checkbox",
CANCEL: "cancel", SUBMIT: "submit", UPLOAD: "upload", USERNAME: "username", PASSWORD: "password",
TABLE: "table", THEAD: "thead", TBODY: "tbody", TR: "tr", TH: "th", TD: "td",
HEADER: "header", NAV: "nav", MAIN: "main", ASIDE: "aside", FOOTER: "footer",

View File

@ -123,7 +123,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
value && (value = can.user.trans(sub, value, null, html.INPUT))
return can.page.SelectArgs(can, option, key, value)[0] },
Update: function(event, cmds, cb, silent) { event = event||{}
sub.request(event, {_toast: event.isTrusted? ice.PROCESS: ""})._caller(), sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input([], !silent), cb, silent); return true },
sub.request(event, {_toast: event.isTrusted? ice.PROCESS: ""}, can.core.Value(sub, "sub.db._checkbox"))._caller(), sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input([], !silent), cb, silent); return true },
Focus: function() { can.page.SelectOne(can, option, html.INPUT_ARGS, function(target) { target.focus() }) },
Input: function(cmds, save, opts) { cmds = cmds && cmds.length > 0? cmds: can.page.SelectArgs(sub), cmds && cmds[0] != ctx.ACTION && (cmds = can.base.trim(cmds))
cmds._opts = opts
@ -309,7 +309,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
} }, icon.push({icon: mdb.DELETE, onclick: function(event) { _input.value = "", input.onkeyup({target: event.target.previousSibling}) }})
} if (item.range) { input._init = function(target) { can.onappend.figure(can, item, target, function(sub, value, old) { target.value = value, can.core.CallFunc([can.onaction, item.name], [event, can, item.name]) }) } }
var _style = can.page.buttonStyle(can, item.name)
var _input = can.page.Append(can, target, [{view: [[html.ITEM].concat(style, [item.type, item.name, item._className], _style)], list: [item.icon && {icon: item.icon}, input].concat(icon), _init: function(target, _input) {
var _input = can.page.Append(can, target, [{view: [[html.ITEM].concat(style, [item.type, item.name, item._className, html.FLEX], _style)], list: [item.icon && {icon: item.icon}, input].concat(icon), _init: function(target, _input) {
if (item.type == html.SELECT) {
_input.select.value = value||_item.value||_item.values[0]
can.onappend.select(can, _input.select, _item)
@ -356,6 +356,15 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
})
}, _init: function(target) { can.page.style(can, target, html.WIDTH, (select.offsetWidth||80)+30), can.onappend.style(can, html.HIDE, select) }}, {icon: mdb.SELECT}])
},
checkbox: function(can, table, msg) { can.page.Select(can, table, "tr>th:first-child,tr>td:first-child", function(target) {
can.page.insertBefore(can, [{type: target.tagName, list: [{type: html.INPUT, data: {type: html.CHECKBOX}, onchange: function(event) {
can.page.tagis(target, html.TH) && can.page.Select(can, table, "tr>td:first-child>input[type=checkbox]", function(target) { target.checked = event.target.checked })
var list = {}, key = can.page.SelectArgs(can, can._option, "", function(target) { if (target.value == "") { return target.name } })
can.page.Select(can, table, "tr>td:first-child>input[type=checkbox]", function(target) { can.page.ClassList.set(can, can.page.parentNode(can, target, html.TR), html.SELECT, target.checked)
target.checked && can.core.List(key, function(key) { list[key] = (list[key]||[]).concat([msg[key][can.page.parentNode(can, target, html.TR).dataset.index]]) })
}), can.db._checkbox = {}, can.core.Item(list, function(k, v) { can.db._checkbox[k] = v.join(",") })
}}] }], target)
}) },
table: function(can, msg, cb, target, keys) { if (!msg || msg.Length() == 0) { return } var meta = can.base.Obj(msg.Option(mdb.META))
if (can.user.isMobile) { can.base.toLast(msg.append, mdb.TIME) } can.base.toLast(msg.append, web.LINK), can.base.toLast(msg.append, ctx.ACTION)
if (msg.append[msg.append.length-1] == ctx.ACTION && (!msg[ctx.ACTION] || msg[ctx.ACTION].length == 0)) { msg.append.pop() }
@ -393,7 +402,8 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
}}
}); table && can.onappend.style(can, chat.CONTENT, table), table && msg.IsDetail() && can.onappend.style(can, mdb.DETAIL, table)
msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table)
;(can.isCmdMode() || table.offsetWidth > can.ConfWidth() / 2) && can.onappend.style(can, "full", table)
if (msg.Option(ice.TABLE_CHECKBOX) == ice.TRUE) { can.onappend.checkbox(can, table, msg), can.onappend.style(can, html.CHECKBOX, table) }
(can.isCmdMode() || 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 }

View File

@ -42,8 +42,11 @@ body {
--plugin-padding:10px; --button-padding:var(--plugin-padding); --input-padding:5px; --table-padding:var(--button-padding);
--plugin-radius:var(--plugin-padding); --button-radius:var(--input-padding);
}
body { font-family:var(--body-font-family); }
input { font-family:var(--input-font-family); }
body { font-family:var(--body-font-family); }
body.cmd {
--plug-width:1200px; --plug-height:480px;
}
body.width1 { /* 320-640 手机竖屏 */
--footer-height:60px; --input-width:80px;
--river-margin:0; --plugin-margin:0; --button-margin:5px;
@ -72,6 +75,7 @@ legend { font-family:var(--legend-font-family); padding:0 var(--legend-padding);
select { padding:0 var(--button-padding); }
input:not([type=file]) { padding:0 var(--button-padding); }
input:not([type=button]) { padding:0 var(--input-padding); border-radius:0; outline:none; }
input[type=checkbox] { height:22px; width:22px; margin:5px; }
table.content.full { width:100%; }
table.content thead { position:sticky; top:2px; }
table.content tr.disable { color:var(--disable-fg-color); }
@ -87,9 +91,13 @@ table.content th.select { border:var(--notice-bg-color) solid 1px; }
table.content th.select[data-asc="1"] i.bi-sort-down-alt { display:none; }
table.content th.select[data-asc="0"] i.bi-sort-up { display:none; }
table.content td { padding:var(--table-padding); }
table.content.checkbox th:first-child { text-align:center; padding:var(--table-padding); }
table.content.checkbox td:first-child { text-align:center; }
table.content.detail td:first-child { width:var(--input-width); }
table.content.action th:last-child { position:sticky; right:2px; }
table.content.action td:last-child { position:sticky; right:2px; text-align:center; }
table.content.action td:last-child { background-color:var(--th-bg-color); position:sticky; right:2px; text-align:center; }
table.content.checkbox th:first-child { position:sticky; left:2px; }
table.content.checkbox td:first-child { background-color:var(--th-bg-color); position:sticky; left:2px; text-align:center; }
table.content:hover col.option { background-color:var(--hover-bg-color); }
table.content col.action { width:var(--project); }
table.content col.time { width:180px; }
@ -157,8 +165,9 @@ 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:var(--plugin-padding); z-index:100; }
body>fieldset.input.float { padding:0; border-radius:0 !important; z-index:100; }
body>fieldset.input.float table.content td { padding:var(--input-padding); z-index:100; }
body>div.input>legend { font-style:italic; width:100%; }
body>fieldset.input.float table.content td { padding:var(--input-padding); }
body>fieldset.input.float table.content th { padding:var(--input-padding); }
body>div.input>legend { font-style:italic; width:100%; justify-content:center; }
body>div.input td { padding:var(--table-padding); }
body>div.input td:nth-child(2) { padding:var(--table-padding) 0; }
body>div.input tr.img td:last-child>span { display:none; }
@ -253,7 +262,7 @@ div.item.text.line>input { width:var(--button-width) !important; }
div.item.text.limit>input { width:var(--button-width); }
div.item.text.offend>input { width:var(--button-width); }
div.item.text.will>input { border:var(--box-notice); }
div.item.text>i:first-child { position:absolute; padding:7px; }
div.item.text>i:first-child { position:absolute; left:0; padding:7px; }
div.item.text>span.icon { font-size:var(--icon-font-size); padding:var(--input-padding); position:absolute; right:0; visibility:hidden; }
div.item.text:hover>span.icon { visibility:visible; }
div.item.button { position:relative; height:var(--action-height); }

View File

@ -251,6 +251,11 @@ Volcanos("page", {
while (list.node.childNodes.length > 0) { var item = list.node.childNodes[0]; item.parentNode.removeChild(item), output.appendChild(item) }
return delete(cache[name]), list.data
},
parentNode: function(can, target, tag) {
for (target; target; target = target.parentNode) {
if (can.page.tagis(target, tag)) { return target }
}
},
insertBefore: function(can, target, before, parent) { parent = parent||before.parentNode
if (can.base.isArray(target)) {
return can.core.List(target, function(item) { if (!item) { return }

View File

@ -198,9 +198,7 @@ Volcanos("user", {
item.title = can.user.trans(can, item.title||item.placeholder||item.name, null, html.INPUT)
return {view: [[item.name, item.type, item.action], html.TR], list: [
{type: html.TD, list: [{text: [can.user.trans(can, item.name||"", item._trans, html.INPUT), html.LABEL]}]}, {type: html.TD, list: [{text: item.need == "must"? "*": "", style: {color: cli.RED}}]},
{type: html.TD, _init: function(target) {
can.onappend.input(can, item, "", target)
}},
{type: html.TD, _init: function(target) { can.onappend.input(can, item, "", target) }},
]}
})}]}, html.ACTION,
], onclick: function(event) { if (!can.page.tagis(event.target, html.INPUT, html.TEXTAREA)) { can.onmotion.clearCarte(can) } }}])

View File

@ -26,7 +26,7 @@ fieldset.inner>div.output>div.layout>div.layout>div.profile h2 { border-bottom:v
fieldset.inner>div.output>div.layout>div.layout>div.profile pre>code { padding-left:var(--table-padding); border-left:var(--code-border-color) solid 5px; display:block; }
fieldset.inner>div.output>div.layout>div.layout>div.profile>div.code { white-space:unset; padding:var(--table-padding); }
fieldset.inner>div.output>div.layout>div.layout>div.profile div.status>div { padding:var(--input-padding); float:left; }
fieldset.inner>div.output>div.layout>div.layout div.content div.tips { color:var(--disable-fg-color); font-style:italic; position:absolute; top:0; right:10px; }
fieldset.inner>div.output>div.layout>div.layout div.content div.tips { line-height:var(--code-line-height); color:var(--disable-fg-color); font-style:italic; position:absolute; top:0; right:10px; }
fieldset.inner.cmd>div.output>div.layout>div.tabs:not(.hide) { background-color:var(--plugin-bg-color); height:var(--code-tabs-height); display:flex; }
fieldset.inner.cmd>div.output>div.layout>div.tabs>div { height:var(--code-tabs-height); }
fieldset.inner.cmd>div.output>div.layout>div.tabs>div.icon>div.icon { font-size:26px; line-height:32px; padding:2px 5px; position:sticky; top:0; }