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

opt table.js

This commit is contained in:
harveyshao 2022-10-24 23:08:22 +08:00
parent 9682cd9dd6
commit 307c9a1703
7 changed files with 108 additions and 167 deletions

View File

@ -650,6 +650,9 @@ Volcanos(chat.ONMOTION, {help: "动态特效", _init: function(can, target) {
can.page.Select(can, target, html.IFRAME, function(item) { can.page.Select(can, target, html.IFRAME, function(item) {
can.page.style(can, item, html.HEIGHT, can.ConfHeight()-88, html.WIDTH, can.ConfWidth()-30) can.page.style(can, item, html.HEIGHT, can.ConfHeight()-88, html.WIDTH, can.ConfWidth()-30)
}) })
can.page.Select(can, target, "input[type=button]", function(target) {
if (target.value == target.name) { target.value = can.user.trans(can, target.name) }
})
}, },
}, },
copy: function(can, target, text, cb) { copy: function(can, target, text, cb) {

View File

@ -56,7 +56,7 @@ fieldset.plugin { background-color:#061c3c9e; padding:10px; margin:10px; }
fieldset.float { background-color:#0e3369; color:white; padding:0; margin:0; } fieldset.float { background-color:#0e3369; color:white; padding:0; margin:0; }
fieldset.full { background-color:#0e3369; color:white; padding:0; margin:0; left:0; top:0; overflow:auto; } fieldset.full { background-color:#0e3369; color:white; padding:0; margin:0; left:0; top:0; overflow:auto; }
fieldset.Action>div.output>fieldset.plugin>legend { float:none; } fieldset.Action>div.output>fieldset.plugin:not(.float):not(.full)>legend { float:none; }
fieldset.Action>div.output>fieldset.plugin>legend { box-shadow:4px 4px 20px 4px #626bd0; } fieldset.Action>div.output>fieldset.plugin>legend { box-shadow:4px 4px 20px 4px #626bd0; }
fieldset>form.option input[type=button][name=close]{ display:none; } fieldset>form.option input[type=button][name=close]{ display:none; }

View File

@ -104,8 +104,7 @@ Volcanos(chat.ONACTION, {_init: function(can, target) {
onstorm_select: function(can, msg, river, storm) { onstorm_select: function(can, msg, river, storm) {
if (can.onmotion.cache(can, function(cache, old) { if (can.onmotion.cache(can, function(cache, old) {
var key = can.core.Keys(can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm)) var key = can.core.Keys(can.Conf(chat.RIVER, river), can.Conf(chat.STORM, storm))
cache[old] = can._plugins, can._plugins = cache[key]||[] return cache[old] = can._plugins, can._plugins = cache[key]||[], key
return key
}, can._output, can._action, can._header_tabs)) { }, can._output, can._action, can._header_tabs)) {
var conf = can.core.Value(can._root, can.core.Keys(chat.RIVER, river, chat.STORM, storm))||{} var conf = can.core.Value(can._root, can.core.Keys(chat.RIVER, river, chat.STORM, storm))||{}
return can.onaction.layout(can, can.misc.SearchOrConf(can, chat.LAYOUT)||msg.Option(chat.LAYOUT)||conf.layout, true) return can.onaction.layout(can, can.misc.SearchOrConf(can, chat.LAYOUT)||msg.Option(chat.LAYOUT)||conf.layout, true)
@ -139,8 +138,7 @@ Volcanos(chat.ONACTION, {_init: function(can, target) {
can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button)) can.page.ClassList.add(can, can._target, can.Conf(chat.LAYOUT, button))
can._header_tabs && can.onmotion.hidden(can, can._header_tabs) can._header_tabs && can.onmotion.hidden(can, can._header_tabs)
can.user.isMobile || can.isCmdMode() || (can.onmotion.toggle(can, can._root.River._target, true), can.onmotion.toggle(can, can._root.Footer._target, true)) can.user.isMobile || can.isCmdMode() || (can.onmotion.toggle(can, can._root.River._target, true), can.onmotion.toggle(can, can._root.Footer._target, true))
can.onlayout._init(can); var cb = can.onlayout[button]; if (can.base.isFunc(cb) && cb(can, silent)) { return } can.onlayout._init(can); var cb = can.onlayout[button]; if (can.base.isFunc(cb) && cb(can, silent)) { return } can.onlayout._plugin(can, button)
can.onlayout._plugin(can, button)
}, },
help: function(can, button) { can.user.open("/help/"+button+".shy") }, help: function(can, button) { can.user.open("/help/"+button+".shy") },
}) })

View File

@ -212,10 +212,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
if (can.onmotion.cache(can, function() { return item.hash }, can.ui.profile)) { if (can.onmotion.cache(can, function() { return item.hash }, can.ui.profile)) {
} else { item.extra = can.base.Obj(item.extra, {}) } else { item.extra = can.base.Obj(item.extra, {})
item.extra.index && can.onimport.plug(can, {index: item.extra.index, args: item.extra.args}, can.ui.profile, function(sub) { item._plugin = sub item.extra.index && can.onimport.plug(can, {index: item.extra.index, args: item.extra.args}, function(sub) { item._plugin = sub
can.page.style(can, sub._target, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()), html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()*3/4)) can.page.style(can, sub._target, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()), html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()*3/4))
can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()-2*html.ACTION_HEIGHT), html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()*3/4)) can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()-2*html.ACTION_HEIGHT), html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()*3/4))
}) }, can.ui.profile)
} }
}, },
_plugin: function(can, item, meta) { _plugin: function(can, item, meta) {

View File

@ -111,7 +111,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", _init: function(can, msg, cb) {
can.onimport.layout(can) can.onimport.layout(can)
} }
return can.onimport.plug(can, meta, can.ui._content, function(sub) { return can.onimport.plug(can, meta, function(sub) {
sub.onimport.size(sub, sub.ConfHeight(can.ui.content.offsetHeight-html.ACTION_HEIGHT-sub.onexport.statusHeight(sub)), sub.ConfWidth(can.ui.content.offsetWidth), true) sub.onimport.size(sub, sub.ConfHeight(can.ui.content.offsetHeight-html.ACTION_HEIGHT-sub.onexport.statusHeight(sub)), sub.ConfWidth(can.ui.content.offsetWidth), true)
msg._plugin = sub, can.base.isFunc(cb) && cb(msg._content = can.ui._content), can.onmotion.delay(can, function() { sub.Focus() }) msg._plugin = sub, can.base.isFunc(cb) && cb(msg._content = can.ui._content), can.onmotion.delay(can, function() { sub.Focus() })
sub.onaction.close = function() { can.onaction.back(can), msg._tab._close() } sub.onaction.close = function() { can.onaction.back(can), msg._tab._close() }
@ -122,7 +122,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", _init: function(can, msg, cb) {
} }
return can.user.open(_arg), sub.Update() return can.user.open(_arg), sub.Update()
} }
}) }, can.ui._content)
}, },
_parse: function(can, line) { line = can.page.replace(can, line||"") _parse: function(can, line) { line = can.page.replace(can, line||"")
function wrap(text, type) { return can.page.Format(html.SPAN, text, type) } function wrap(text, type) { return can.page.Format(html.SPAN, text, type) }
@ -273,10 +273,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target), can.user.toastSuccess(can) process: function(can, msg, target, height, width, cb) { can.onmotion.clear(can, target), can.user.toastSuccess(can)
if (msg.Option(ice.MSG_PROCESS) == "_field") { if (msg.Option(ice.MSG_PROCESS) == "_field") {
msg.Table(function(item) { item.display = msg.Option(ice.MSG_DISPLAY), item.height = height-3*html.ACTION_HEIGHT msg.Table(function(item) { item.display = msg.Option(ice.MSG_DISPLAY), item.height = height-3*html.ACTION_HEIGHT
can.onimport.plug(can, item, target, function(sub) { sub.onaction._output = function(_sub, _msg) { can.base.isFunc(cb) && cb(_sub, _msg) } can.onimport.plug(can, item, function(sub) { sub.onaction._output = function(_sub, _msg) { can.base.isFunc(cb) && cb(_sub, _msg) }
sub.onaction.close = function() { can.onmotion.hidden(can, target.parentNode), can.onimport.layout(can) } sub.onaction.close = function() { can.onmotion.hidden(can, target.parentNode), can.onimport.layout(can) }
height && sub.ConfHeight(height-3*html.ACTION_HEIGHT), width && sub.ConfWidth(width), sub.Focus() height && sub.ConfHeight(height-3*html.ACTION_HEIGHT), width && sub.ConfWidth(width), sub.Focus()
}) }, target)
}) })
} else if (msg.Option(ice.MSG_DISPLAY) != "") { } else if (msg.Option(ice.MSG_DISPLAY) != "") {
can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY), target, false, function(msg) { can.onmotion.delay(can, function() { can.onimport.layout(can) }) }) can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY), target, false, function(msg) { can.onmotion.delay(can, function() { can.onimport.layout(can) }) })
@ -439,7 +439,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
can.page.Select(can, can.ui.profile, html.IFRAME, function(iframe) { can.page.Modify(can, iframe, {height: profile_height-html.ACTION_HEIGHT-4, width: profile_width}) }) can.page.Select(can, can.ui.profile, html.IFRAME, function(iframe) { can.page.Modify(can, iframe, {height: profile_height-html.ACTION_HEIGHT-4, width: profile_width}) })
}, },
toolkit: function(can, meta, cb) { meta.msg = true toolkit: function(can, meta, cb) { meta.msg = true
can.onimport.plug(can, meta, can.ui.toolkit.output, function(sub) { can.onimport.plug(can, meta, function(sub) {
sub.onexport.record = function(sub, line) { if (!line.file && !line.line) { return } sub.onexport.record = function(sub, line) { if (!line.file && !line.line) { return }
can.onimport.tabview(can, line.path||can.Option(nfs.PATH), can.base.trimPrefix(line.file, nfs.PWD)||can.Option(nfs.FILE), parseInt(line.line)), can.current.scroll(can.current.scroll()-4) can.onimport.tabview(can, line.path||can.Option(nfs.PATH), can.base.trimPrefix(line.file, nfs.PWD)||can.Option(nfs.FILE), parseInt(line.line)), can.current.scroll(can.current.scroll()-4)
} }
@ -456,7 +456,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
}, sub._legend.onmouseenter = null }, sub._legend.onmouseenter = null
sub.onaction.close = sub.select = function() { return sub._legend.click(), sub } sub.onaction.close = sub.select = function() { return sub._legend.click(), sub }
can.base.isFunc(cb) && cb(sub) can.base.isFunc(cb) && cb(sub)
}) }, can.ui.toolkit.output)
}, },
exts: function(can, url, cb) { exts: function(can, url, cb) {
can.require([url], function() {}, function(can, name, sub) { sub._init(can, sub, function(sub) { can.require([url], function() {}, function(can, name, sub) { sub._init(can, sub, function(sub) {

View File

@ -2,7 +2,6 @@ Volcanos(chat.ONIMPORT, {_process: function(can, msg) {
msg.OptionStatus() && can.onmotion.clear(can, can._status) && can.onappend._status(can, msg.OptionStatus()) msg.OptionStatus() && can.onmotion.clear(can, can._status) && can.onappend._status(can, msg.OptionStatus())
return can.core.CallFunc([can.onimport, msg.OptionProcess()], {can: can, msg: msg}) return can.core.CallFunc([can.onimport, msg.OptionProcess()], {can: can, msg: msg})
}, },
_location: function(can, msg, _arg) { can.user.jumps(_arg); return true }, _location: function(can, msg, _arg) { can.user.jumps(_arg); return true },
_replace: function(can, msg, _arg) { location.replace(_arg); return true }, _replace: function(can, msg, _arg) { location.replace(_arg); return true },
_history: function(can, msg) { history.back(); return true }, _history: function(can, msg) { history.back(); return true },
@ -17,9 +16,7 @@ Volcanos(chat.ONIMPORT, {_process: function(can, msg) {
can.Option(msg._arg[i], msg._arg[i+1]), can.Action(msg._arg[i], msg._arg[i+1]) can.Option(msg._arg[i], msg._arg[i+1]), can.Action(msg._arg[i], msg._arg[i+1])
}; return can.Update() }; return can.Update()
}, },
_display: function(can, msg) { _display: function(can, msg) { return can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY)), true },
return can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY)), true
},
_inner: function(can, msg) { _inner: function(can, msg) {
can.onappend.table(can, msg), can.onappend.board(can, msg), can.onmotion.story.auto(can) can.onappend.table(can, msg), can.onappend.board(can, msg), can.onmotion.story.auto(can)
can.page.style(can, can._output, html.DISPLAY, html.BLOCK); return true can.page.style(can, can._output, html.DISPLAY, html.BLOCK); return true

View File

@ -1,33 +1,31 @@
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) { Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) { can.onmotion.clear(can, target)
var cbs = can.onimport[msg.Option(ctx.STYLE)||can.Conf(ctx.STYLE)]; if (can.base.isFunc(cbs)) { var cbs = can.onimport[can.Conf(ctx.STYLE)||msg.Option(ctx.STYLE)]; if (can.base.isFunc(cbs)) {
can.core.CallFunc(cbs, {can: can, msg: msg, target: target, list: msg.Table()}) can.core.CallFunc(cbs, {can: can, msg: msg, target: target})
can.page.ClassList.add(can, target, can._args[ctx.STYLE]) can.page.ClassList.add(can, target, can._args[ctx.STYLE])
return cbs(can, msg, cb, target) } else {
} can.onappend.table(can, msg, null, target), can.onappend.board(can, msg, target)
} can.onmotion.story.auto(can, target), can.base.isFunc(cb) && cb(msg)
can.page.style(can, can._output, html.HEIGHT, "")
can.onmotion.clear(can, target)
can.onappend.table(can, msg, null, target)
can.onappend.board(can, msg, target)
can.onmotion.story.auto(can, target)
can.base.isFunc(cb) && cb(msg)
can.user.isMobile && can.onmotion.toggle(can, can._action, can.ConfHeight() < can.ConfWidth())
can.page.Select(can, target, "input[type=button]", function(target) {
if (target.value == target.name) { target.value = can.user.trans(can, target.name) }
})
}, },
_open: function(can, msg, list) { card: function(can, msg, target) {
can.core.List(list, function(item) { can.page.Appends(can, target, msg.Table(function(item) {
can.page.Append(can, can._output, [{view: html.ITEM, style: {"text-align": "center", "float": "left", width: "100", margin: "10"}, list: [ return {view: html.ITEM+ice.SP+(item.status||""), list: [
{view: [wiki.TITLE, html.DIV, item.name]},
{view: [wiki.CONTENT, html.DIV, item.text]},
{view: html.ACTION, inner: item.action, onclick: function(event) {
can.run(can.request(event, item), [ctx.ACTION, event.target.name])
}},
]}
}))
},
_open: function(can, msg, target) {
can.page.Appends(can, target, msg.Table(function(item) {
return {view: html.ITEM, style: {"text-align": "center", margin: 10, width: 100, "float": "left"}, list: [
{type: html.IMG, src: "/share/local/usr/icons/"+item.name, style: {display: html.BLOCK, width: 100}}, {type: html.IMG, src: "/share/local/usr/icons/"+item.name, style: {display: html.BLOCK, width: 100}},
{text: item.name.split(ice.PT)[0].replace(ice.SP, ice.NL), style: {display: html.BLOCK, height: 40}}], onclick: function(event) { {text: item.name.split(ice.PT)[0].replace(ice.SP, ice.NL), style: {display: html.BLOCK, height: 40}},
can.runAction(can.request(event, item, can.Option()), "click", []) ], onclick: function(event) { can.runAction(can.request(event, item, can.Option()), "click", []) }}
}}]) }))
})
},
_title: function(can, title) {
can.user.title(title+ice.SP+(can.misc.Search(can, ice.POD)||location.host))
}, },
_panel: function(can, target, action) { _panel: function(can, target, action) {
var ui = can.page.Append(can, target, [html.ACTION, html.OUTPUT]) var ui = can.page.Append(can, target, [html.ACTION, html.OUTPUT])
var action = can.onappend._action(can, [], ui.action, kit.Dict( var action = can.onappend._action(can, [], ui.action, kit.Dict(
@ -36,29 +34,72 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
cli.SHOW, function(event) { can.onaction[cli.SHOW](event, can) }, cli.SHOW, function(event) { can.onaction[cli.SHOW](event, can) },
action, action,
mdb.PLUGIN, function(event) { can.user.input(event, can, [ctx.INDEX, ctx.ARGS], function(data) { mdb.PLUGIN, function(event) { can.user.input(event, can, [ctx.INDEX, ctx.ARGS], function(data) {
can.onimport.plug(can, data, ui.output, function(sub) { can.onimport.plug(can, data, function(sub) {
sub.ConfHeight(target.offsetHeight-4*html.ACTION_HEIGHT) sub.ConfHeight(target.offsetHeight-4*html.ACTION_HEIGHT)
}) }, ui.output)
}) }, }) },
)); target._toggle = function(event, show) { action[show? cli.SHOW: cli.CLOSE](event) } )); target._toggle = function(event, show) { action[show? cli.SHOW: cli.CLOSE](event) }
return ui return ui
}, },
title: function(can, title) { _title: function(can, title) {
can._legend.innerHTML = title, can.sup && can.sup._tabs && (can.sup._tabs.innerHTML = title) can.user.title(title+ice.SP+(can.misc.Search(can, ice.POD)||location.host))
can.sup && can.sup._header_tabs && (can.sup._header_tabs.innerHTML = title)
can.isCmdMode() && can.user.title(title)
}, },
zone: function(can, list, target) { var color = [""] title: function(can, title) { can._legend.innerHTML = title
return can.page.Append(can, target, can.core.List(list, function(zone, index) { can.base.isString(zone) && (zone = {name: zone}); return zone && {view: html.ZONE+" "+zone.name, list: [ can.sup && can.sup._tabs && (can.sup._tabs.innerHTML = title)
{view: html.NAME, inner: can.user.trans(can, zone.name), style: {background: color[index%color.length]}, onclick: function() { can.sup && can.sup._header_tabs && (can.sup._header_tabs.innerHTML = title)
can.isCmdMode() && can.onimport._title(can, title)
},
item: function(can, item, cb, cbs, target) { target = target||(can.ui && can.ui.project? can.ui.project: can._output)
var ui = can.page.Append(can, target, [{view: [html.ITEM, html.DIV, item.nick||item.name],
onclick: function(event) { can.onmotion.select(can, target, html.DIV_ITEM, event.target)
cb(event, event.target, event.target._list && can.onmotion.toggle(can, event.target._list))
}, onmouseenter: function(event) {
if (can.base.isFunc(cbs)) { var menu = cbs(event, ui.first); if (menu) {
can.user.carteRight(event, can, menu.meta, menu.list, menu)
} }
},
}]); return ui.first
},
itemlist: function(can, list, cb, cbs, target) {
return target._list = can.page.insertBefore(can, [{view: html.LIST, list: can.core.List(list, function(item) {
return {view: [html.ITEM, html.DIV, item.name], onclick: function(event) {
cb(event, item, event.target._list && can.onmotion.toggle(can, event.target._list))
}, onmouseenter: function(event) { cbs(event, item) }}
}) }], target.nextSibling, target.parentNode)
},
list: function(can, root, cb, target) { target = target||can._output
can.core.List(root.list, function(item) {
var ui = can.page.Append(can, target, [{view: [html.ITEM, html.DIV, item.meta.name], onclick: function(event) {
can.base.isFunc(cb) && cb(event, item) || can.onmotion.toggle(can, ui.list)
can.onmotion.select(can, target, html.DIV_ITEM, event.target)
}}, {view: html.LIST}]); can.onimport.list(can, item, cb, ui.list)
})
},
tree: function(can, list, field, split, cb, target, node) {
node = node||{"": target}; can.core.List(list, function(item) {
item[field] && can.core.List(item[field].split(split), function(value, index, array) { if (!value) { return }
var last = array.slice(0, index).join(split), name = array.slice(0, index+1).join(split); if (node[name]) { return }
var ui = can.page.Append(can, node[last], [{view: html.ITEM, list: [{view: ["switch", html.DIV, (index==array.length-1?"":"⌃")]}, {view: [mdb.NAME, html.DIV, value+(index==array.length-1?"":"")], _init: item._init, onmouseenter: function(event) { if (!item._menu) { return }
can.user.carteRight(event, can, item._menu.meta, item._menu.list||can.core.Item(item._meta.meta), function(event, button) {
(item._menu.meta[button]||item._menu)(event, can, button)
})
}}], onclick: function(event) { if (node[name].childElementCount == 2) { node[name].firstChild.click() }
index < array.length - 1? can.page.ClassList.set(can, ui["switch"], "open", can.onmotion.toggle(can, node[name])): can.base.isFunc(cb) && cb(event, item)
}}, {view: html.LIST, style: {display: html.NONE}, _init: function(list) { item.expand && can.page.style(can, list, html.DISPLAY, html.BLOCK) }}]); node[name] = ui.list
})
}); return node
},
zone: function(can, list, target) {
return can.page.Append(can, target, can.core.List(list, function(zone, index) { can.base.isString(zone) && (zone = {name: zone}); return zone && {view: html.ZONE+ice.SP+zone.name, list: [
{view: html.NAME, inner: can.user.trans(can, zone.name), onclick: function() {
can.onmotion.toggle(can, zone._action), can.onmotion.toggle(can, zone._target) can.onmotion.toggle(can, zone._action), can.onmotion.toggle(can, zone._target)
}, onmouseenter: function(event) { }, onmouseenter: function(event) {
zone._menu? can.user.carteRight(event, can, zone._menu.meta, zone._menu.list||can.core.Item(zone._menu.meta), function(event, button, meta) { zone._menu? can.user.carteRight(event, can, zone._menu.meta, zone._menu.list||can.core.Item(zone._menu.meta), function(event, button, meta) {
(meta[button]||can.onaction[button])(event, can, button) (meta[button]||can.onaction[button])(event, can, button)
}): can.user.carteRight(event, can, { }): can.user.carteRight(event, can, {
"刷新": function() { zone.refresh() },
"折叠": function() { can.page.Select(can, zone._target, html.DIV_LIST, function(item) { can.onmotion.toggle(can, item, false) }) }, "折叠": function() { can.page.Select(can, zone._target, html.DIV_LIST, function(item) { can.onmotion.toggle(can, item, false) }) },
"展开": function() { can.page.Select(can, zone._target, html.DIV_LIST, function(item) { can.onmotion.toggle(can, item, true) }) }, "展开": function() { can.page.Select(can, zone._target, html.DIV_LIST, function(item) { can.onmotion.toggle(can, item, true) }) },
"刷新": function() { can.onmotion.clear(can, zone._target), zone._init(zone._target) },
}, ["刷新", "折叠", "展开"]) }, ["刷新", "折叠", "展开"])
}}, }},
{view: html.ACTION, _init: function(target) { zone._action = target {view: html.ACTION, _init: function(target) { zone._action = target
@ -80,58 +121,14 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
}} }}
]} })) ]} }))
}, },
tree: function(can, list, field, split, cb, target, node) {
node = node||{"": target}; can.core.List(list, function(item) {
item[field] && can.core.List(item[field].split(split), function(value, index, array) { if (!value) { return }
var last = array.slice(0, index).join(split), name = array.slice(0, index+1).join(split); if (node[name]) { return }
var ui = can.page.Append(can, node[last], [{view: "item", list: [{view: ["switch", "div", (index==array.length-1?"":"⌃")]}, {view: ["name", html.DIV, value+(index==array.length-1?"":"")], _init: item._init, onmouseenter: function(event) { if (!item._menu) { return }
can.user.carteRight(event, can, item._menu.meta, item._menu.list||can.core.Item(item._meta.meta), function(event, button) {
(item._menu.meta[button]||item._menu)(event, can, button)
})
}}], onclick: function(event) {
index < array.length - 1? can.onmotion.toggle(can, node[name], function() { can.page.ClassList.add(can, ui["switch"], "open") }, function() { can.page.ClassList.del(can, ui["switch"], "open") }): can.base.isFunc(cb) && cb(event, item)
if (node[name].childElementCount == 2) { node[name].firstChild.click() }
}}, {view: html.LIST, style: {display: html.NONE}, _init: function(list) { item.expand && can.page.style(can, list, html.DISPLAY, html.BLOCK) }}])
node[name] = ui.list
})
}); return node
},
list: function(can, root, cb, target) { target = target||can._output
can.core.List(root.list, function(item) {
var ui = can.page.Append(can, target, [{view: [html.ITEM, html.DIV, item.meta.name], onclick: function(event) {
can.base.isFunc(cb) && cb(event, item) || can.onmotion.toggle(can, ui.list)
can.onmotion.select(can, target, html.DIV_ITEM, event.target)
}}, {view: html.LIST}]); can.onimport.list(can, item, cb, ui.list)
})
},
item: function(can, item, cb, cbs, target) { target = target||(can.ui && can.ui.project? can.ui.project: can._output)
var ui = can.page.Append(can, target, [{view: [html.ITEM, html.DIV, item.nick||item.name],
onclick: function(event) { cb(event, ui.first, event.target._list && can.onmotion.toggle(can, event.target._list))
can.onmotion.select(can, target, can.core.Keys(html.DIV, html.ITEM), ui.first)
}, onmouseenter: function(event) {
if (can.base.isFunc(cbs)) {
var menu = cbs(event, ui.first)
if (menu) {
can.user.carteRight(event, can, menu.meta, menu.list, menu)
}
}
},
}]); return ui.first
},
itemlist: function(can, list, cb, cbs, target) {
return target._list = can.page.insertBefore(can, [{view: html.LIST, list: can.core.List(list, function(item) {
return {view: [html.ITEM, html.DIV, item.name], onclick: function(event) {
cb(event, item, event.target._list && can.onmotion.toggle(can, event.target._list))
}, onmouseenter: function(event) { cbs(event, item) }}
}) }], target.nextSibling, target.parentNode)
},
tabs: function(can, list, cb, cbs, action, each) { action = action||can._action tabs: function(can, list, cb, cbs, action, each) { action = action||can._action
return can.page.Append(can, action, can.core.List(list, function(tabs) { return can.page.Append(can, action, can.core.List(list, function(tabs) {
return {text: [tabs.name, html.DIV, html.TABS], title: tabs.text, onclick: function(event) { return {text: [tabs.name, html.DIV, html.TABS], title: tabs.text, onclick: function(event) {
can.onmotion.select(can, action, html.DIV_TABS, event.target), can.base.isFunc(cb) && cb(event, tabs) can.onmotion.select(can, action, html.DIV_TABS, event.target), can.base.isFunc(cb) && cb(event, tabs)
}, _init: function(item) { }, _init: function(item) {
function close(item) { var next = item.nextSibling||item.previousSibling; next && next.click() function close(item) { var next = item.nextSibling||item.previousSibling; if (!next) { return }
if (next) { can.base.isFunc(cbs) && cbs(item._meta), can.page.Remove(can, item) } can.base.isFunc(cbs) && cbs(item._meta), can.page.Remove(can, item), next.click()
} }
var menu = tabs._menu||shy({}, [], function(event, button, meta) { (meta[button])(event, can, button) }) var menu = tabs._menu||shy({}, [], function(event, button, meta) { (meta[button])(event, can, button) })
can.page.Modify(can, item, {draggable: true, _close: function() { close(item) }, _meta: tabs, can.page.Modify(can, item, {draggable: true, _close: function() { close(item) }, _meta: tabs,
@ -150,59 +147,20 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
}} }}
})).first })).first
}, },
card: function(can, msg, cb, target) { plug: function(can, meta, cb, target) { if (!meta || !meta.index) { return }
can.page.Appends(can, target, msg.Table(function(value) {
return {view: html.ITEM+" "+(value.status||""), list: [
{view: [wiki.TITLE, html.DIV, value.name]},
{view: [wiki.CONTENT, html.DIV, value.text]},
{view: html.ACTION, inner: value.action, onclick: function(event) {
can.run(can.request(event, value), [ctx.ACTION, event.target.name])
}},
]}
}))
can.page.Select(can, target, "input[type=button]", function(target) {
if (target.value == target.name) { target.value = can.user.trans(can, target.name) }
})
can.base.isFunc(cb) && cb(msg)
},
card_detail: function(can, msg, cb, target) {
},
card_left: function(can, msg, cb, target) {
can.page.Appends(can, target, msg.Table(function(value) {
return {view: html.ITEM+" "+(value.status||""), list: [
{view: "image", list: [{img: can.misc.MergeURL(can, {_path: "/share/cache/"+can.core.Split(value.image)[0]}), width: 150}]}, {view: "content", list: [
{view: [wiki.TITLE, html.DIV, value.name]},
{view: [wiki.CONTENT, html.DIV, value.text]},
{view: ["price", html.DIV, "¥"+value.price]},
{view: html.ACTION, inner: value.action, onclick: function(event) {
can.run(can.request(event, value), [ctx.ACTION, event.target.name])
}},
]},
], onclick: function(event) {
if (can.page.tagis(event.target, html.INPUT)) { return }
can.Option(mdb.HASH, value.hash), can.Update()
}}
}))
can.page.Select(can, target, "input[type=button]", function(target) {
if (target.value == target.name) { target.value = can.user.trans(can, target.name) }
})
can.base.isFunc(cb) && cb(msg)
},
plug: function(can, meta, target, cb) { if (!meta || !meta.index) { return }
meta.type = "plug", can.onappend.plugin(can, meta, function(sub) { sub.sup = can meta.type = "plug", can.onappend.plugin(can, meta, function(sub) { sub.sup = can
sub.ConfHeight(target.offsetHeight-2*html.ACTION_HEIGHT), sub.ConfWidth(target.offsetWidth) sub.ConfHeight(target.offsetHeight-2*html.ACTION_HEIGHT), sub.ConfWidth(target.offsetWidth)
can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(), html.MAX_WIDTH, sub.ConfWidth())
sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, can.Option()), meta.index, cmds, cb) } sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, can.Option()), meta.index, cmds, cb) }
sub.onaction.close = function() { can.ui && target == can.ui.profile? can.onmotion.hidden(sub, target): can.onmotion.hidden(sub, sub._target) } sub.onaction.close = function() { can.onmotion.hidden(can, target) }
can.base.isFunc(cb) && cb(sub), can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(), html.MAX_WIDTH, sub.ConfWidth()) can.base.isFunc(cb) && cb(sub)
}, target) }, target)
}, },
tool: function(can, list, cb, target) { target = target||can._output tool: function(can, list, cb, target) { target = target||can._output
can.core.List(list.reverse(), function(meta) { typeof meta == "string" && (meta = {index: meta}) can.core.List(list.reverse(), function(meta) { can.base.isString(meta) && (meta = {index: meta})
can.onimport.plug(can, meta, target, function(sub) { sub._delay_init = true can.onimport.plug(can, meta, function(sub) { sub._delay_init = true
sub.ConfHeight(can.ConfHeight()-4*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth()) sub.ConfHeight(can.ConfHeight()-4*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth())
sub.page.style(sub, sub._output, html.MAX_HEIGHT, sub.ConfHeight()) can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(), html.MAX_WIDTH, sub.ConfWidth())
sub.page.style(sub, sub._output, html.MAX_WIDTH, sub.ConfWidth())
can._status.appendChild(sub._legend), sub._legend.onclick = function(event) { can._status.appendChild(sub._legend), sub._legend.onclick = function(event) {
if (can.page.Select(can, can._status, ice.PT+html.SELECT)[0] == event.target) { if (can.page.Select(can, can._status, ice.PT+html.SELECT)[0] == event.target) {
can.page.ClassList.del(can, event.target, html.SELECT) can.page.ClassList.del(can, event.target, html.SELECT)
@ -212,39 +170,24 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
can.onmotion.select(can, target, html.FIELDSET, sub._target), sub.Focus() can.onmotion.select(can, target, html.FIELDSET, sub._target), sub.Focus()
can.onmotion.select(can, can._status, html.LEGEND, event.target) can.onmotion.select(can, can._status, html.LEGEND, event.target)
if (sub._delay_init || meta.msg == true) { sub._delay_init = false, meta.msg = false, sub.Update() } if (sub._delay_init || meta.msg == true) { sub._delay_init = false, meta.msg = false, sub.Update() }
}, sub.select = function() { return sub._legend.click(), sub } }, sub.select = function() { return sub._legend.click(), sub }, sub._legend.onmouseenter = null
sub.onaction.close = function() { sub.select() } sub.onaction.close = function() { sub.select() }
sub._legend.onmouseenter = null
can.base.isFunc(cb) && cb(sub) can.base.isFunc(cb) && cb(sub)
}) }, target)
}) })
}, },
}) })
Volcanos(chat.ONLAYOUT, {help: "界面布局", Volcanos(chat.ONLAYOUT, {help: "界面布局",
_init: function(can) { _init: function(can) { can.core.CallFunc([can.onimport, html.LAYOUT], {can: can}) },
can.user.isMobile && can.onmotion.toggle(can, can._action, can.ConfHeight() < can.ConfWidth())
can.core.CallFunc([can.onimport, html.LAYOUT], {can: can})
},
float: function(can) { can.onlayout._init(can) }, float: function(can) { can.onlayout._init(can) },
full: function(can) { full: function(can) { can.onlayout._init(can) },
can.sup.onimport.size(can.sup, can.ConfHeight(), can.ConfWidth(), false) cmd: function(can) { can.onlayout._init(can) },
can.onlayout._init(can)
},
cmd: function(can) {
// can.ConfHeight(can.ConfHeight()+html.ACTION_HEIGHT)
can.sup.onimport.size(can.sup, can.ConfHeight(), can.ConfWidth(), true)
can.onlayout._init(can)
},
})
Volcanos(chat.ONACTION, {help: "操作数据",
_trans: {"full": "全屏"},
}) })
Volcanos(chat.ONEXPORT, {help: "导出数据", Volcanos(chat.ONEXPORT, {help: "导出数据",
table: function(can) { var msg = can._msg; if (msg.Length() == 0) { return } table: function(can) { var msg = can._msg; if (msg.Length() == 0) { return }
var res = [msg.append && msg.append.join(ice.FS)]; msg.Table(function(line, index, array) { var res = [msg.append && msg.append.join(ice.FS)]; msg.Table(function(line, index, array) {
res.push(can.core.Item(line, function(key, value) { return value }).join(ice.FS)) res.push(can.core.Item(line, function(key, value) { return value }).join(ice.FS))
}) }); return res.join(ice.NL)
return res.join(ice.NL)
}, },
board: function(can) { var msg = can._msg; return msg.Result() }, board: function(can) { var msg = can._msg; return msg.Result() },
}) })