From 39582da9f8b2888950b5e82443d7a4e736176ede Mon Sep 17 00:00:00 2001 From: shylinux Date: Sat, 3 Sep 2022 16:43:06 +0800 Subject: [PATCH] opt some --- frame.js | 9 ++++++--- lib/base.js | 6 ++++++ lib/page.js | 5 ++++- page/index.css | 3 ++- panel/action.js | 3 ++- panel/header.js | 5 ++++- plugin/local/code/inner.css | 4 ++++ plugin/local/code/inner.js | 29 +++++++++++++++++++++++------ plugin/local/wiki/draw.js | 3 +-- plugin/local/wiki/word.js | 3 ++- plugin/state.js | 15 ++++++++++----- plugin/story/spide.js | 22 ++++++++++------------ proto.js | 8 ++++++-- 13 files changed, 80 insertions(+), 35 deletions(-) diff --git a/frame.js b/frame.js index 9aef0161..8e702447 100644 --- a/frame.js +++ b/frame.js @@ -213,10 +213,11 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, var cb = meta[item]||meta[chat._ENGINE]; cb? can.core.CallFunc(cb, {event: event, can: can, button: item}): can.run(event, [ctx.ACTION, item].concat(can.sup.Input())) } - }}: item.length > 0? /*列表*/ {type: html.SELECT, name: item[0], values: item.slice(1), onchange: function(event) { + }}: item.length > 0? /*列表*/ {type: html.SELECT, name: item[0], values: item.slice(1), value: can.sup[item[0]], onchange: function(event) { var which = item[event.target.selectedIndex+1] can.core.CallFunc(meta[which], [event, can, which]) can.core.CallFunc(meta[item[0]], [event, can, item[0], which]) + can.sup && (can.sup[item[0]] = can.Action(item[0])) }}: /*其它*/ item, "", action)}), meta }, @@ -250,8 +251,8 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, } return can.run(event, cmds, function(msg) { var sub = can.core.Value(can, chat._OUTPUTS_CURRENT)||{} - if (!cmds || cmds[0] != ctx.ACTION) { can._msg = msg, sub._msg = msg, msg._cmds = cmds } if (can.base.isFunc(cb)) { can.core.CallFunc(cb, {can: can, msg: msg}); return } + if (!cmds || cmds[0] != ctx.ACTION) { can._msg = msg, sub._msg = msg, msg._cmds = cmds } var process = msg._can == can || msg._can == sub if (process && can.core.CallFunc([sub, chat.ONIMPORT, ice.MSG_PROCESS], {can: sub, msg: msg})) { return } if (process && can.core.CallFunc([can, chat.ONIMPORT, ice.MSG_PROCESS], {can: can, msg: msg})) { return } @@ -277,6 +278,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, } can.onmotion.clear(can, can._action) + can._display_output? can._display_output(table, msg): can.core.CallFunc([table, chat.ONIMPORT, chat._INIT], {can: table, msg: msg, cb: function(msg) { action === false || table.onappend._action(table, msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), action) action === false || table.onappend._status(table, msg.Option(ice.MSG_STATUS)) @@ -310,6 +312,8 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, case html.SPACE: return can.page.Append(can, target, [{view: can.base.join([html.ITEM, html.SPACE])}]) } var input = can.page.input(can, item, value) + if (item.type == "select" && item.value) { input._init = function(target) { target.value = item.value } } + if (item.range) { input._init = function(target) { item.mode = "simple" can.onappend.figure(can, item, target, function(sub, value, old) { @@ -334,7 +338,6 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, // switch (event.key) { case lang.TAB: can.onkeymap.insertText(event.target, ice.TB); can.onkeymap.prevent(event); break } break } - }, _init: function(target) { }, list: [input]}]).concat(br))[item.name] }, diff --git a/lib/base.js b/lib/base.js index 79db950b..59ecb361 100644 --- a/lib/base.js +++ b/lib/base.js @@ -236,6 +236,12 @@ Volcanos("base", {help: "数据类型", Int: function(val, def) { return parseIn if (index == -1 || index+end.length != str.length) { return str } return str.slice(0, index) }, join: function(list, sp) { return (list||[]).join(sp||ice.SP) }, + joinKV: function(list, inner, outer) { var res = [] + for (var i = 0; i < list.length-1; i += 2) { + res.push(list[i]+(inner||": ")+list[i+1]) + } + return res.join(outer||" ") + }, joins: function(list, inner, outer) { for (var i = 0; i < list.length; i++) { list[i] = typeof list[i] == lang.STRING? list[i]: list[i].join(inner||ice.FS) diff --git a/lib/page.js b/lib/page.js index 2adfab16..895dc1d2 100644 --- a/lib/page.js +++ b/lib/page.js @@ -357,6 +357,9 @@ Volcanos("page", {help: "用户界面", ClassList: { item.values = can.base.isString(item.values)? can.core.Split(item.values): item.values if (!item.values && item.value) { item.values = can.core.Split(item.value), item.value = item.values[0] } + if (item.values.slice(1).indexOf(item.values[0]) > -1) { + item.value = item.value||item.values[0], item.values = item.values.slice(1) + } item.value = value||item.value, input.list = item.values.map(function(value) { return {type: html.OPTION, value: value, inner: value} }), item.className || can.page.ClassList.add(can, item, ctx.ARGS) @@ -387,7 +390,7 @@ Volcanos("page", {help: "用户界面", ClassList: { } item.action && (function() { item._init = function(target) { can.onappend.figure(can, item, target) } })() item.type == html.BUTTON? _list.push(list[i]): _list.push(item) - }) () + })() } } return _list diff --git a/page/index.css b/page/index.css index cd9cd88b..ca7480e4 100644 --- a/page/index.css +++ b/page/index.css @@ -52,7 +52,8 @@ div.output div.project div.zone>div.action>div.item { float:right; clear:none; p div.output div.project div.zone>div.action>div.item input[type=text] { background-color:#ff000000; padding-left:10px; color:white; } fieldset.plugin { background-color:#061c3c9e; padding:10px; margin:10px; } -fieldset.float { background-color:#0e3369b3; position:absolute; } +fieldset.float { background-color:#0e3369; position:absolute; } +/* fieldset.float { background-color:#0e3369b3; position:absolute; } */ fieldset.full { background-color:#073947f2; padding:0; margin:0; left:0; top:0; overflow:auto; } fieldset.story>legend { margin:10px 0; } fieldset.plug>legend { float:left; margin-right:5px; } diff --git a/panel/action.js b/panel/action.js index cc455eb8..e2448c12 100644 --- a/panel/action.js +++ b/panel/action.js @@ -94,9 +94,10 @@ Volcanos(chat.ONPLUGIN, {help: "注册插件", cmds && cmds[0] && can._root.Action.run({}, cmds, cb, true) }), - "plugin": shy("插件", {}, ["text", "list", "back"], function(can, msg, cmds) { + "plugin": shy("插件", {}, ["list", "back"], function(can, msg, cmds) { msg.Echo("hello world") }), + "output": shy("插件", {}, ["some"], function(can, msg, cmds) {}), "nfs.save": shy("保存文件", {}, ["file=hi.txt", "text:textarea='hello world'", "save:button"], function(can, msg, cmds, cb) { can.misc.runAction(can, msg, cmds, cb, kit.Dict( "save", function(cmds) { can.user.downloads(can, cmds[1], cmds[0]) } diff --git a/panel/header.js b/panel/header.js index 0e981b42..1a5ab1b2 100644 --- a/panel/header.js +++ b/panel/header.js @@ -244,7 +244,10 @@ Volcanos(chat.ONACTION, {help: "交互数据", _init: function(can, cb, target) }) Volcanos(chat.ONEXPORT, {help: "导出数据", height: function(can) { return can._target.offsetHeight }, - topic: function(can) { return can._topic }, + topic: function(can) { + return can._topic || can.misc.Search(can, chat.TOPIC) || Volcanos.meta.args.topic || (can.base.isNight()? chat.BLACK: chat.WHITE) + return can._topic + }, avatar: function(can) { if (can.user.info.avatar == "void") { return "" diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index 172063fa..c22a1c85 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -1,3 +1,5 @@ +fieldset.word fieldset.inner>form.option input[name=path] { width:240px; } + fieldset.inner>form.option input[name=path] { width:80px; } fieldset.inner>form.option input[name=file] { width:160px; } fieldset.inner>div.action>div.tabs { padding:5px; margin:0 1px; } @@ -34,6 +36,8 @@ body.white fieldset.inner>div.output div.content { color:black; } body.white fieldset.inner.float>div.output div.content { color:white; } body.black fieldset.inner.float>div.output div.content { color:white; } +body.white fieldset.inner.float>div.output div.profile { color:black; } + body.simple fieldset.inner>div.output td.content>div.tabs { background-color:gray; padding:0px; height:31px; overflow:auto; display:block; } body.simple fieldset.inner>div.output td.content>div.tabs div.tabs { background-color:gray; font-family:monospace; padding:7px 20px; height:17px; float:left; } body.simple fieldset.inner>div.output td.content>div.tabs div.tabs.select { background-color:#1d3349; } diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 2a1478d5..c043e012 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -1,4 +1,9 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) { if (msg.Result() == "" && msg.Length() == 0) { can.onmotion.hidden(can, can._output); return } + if (msg.Option(nfs.FILE)) { + msg.Option(nfs.PATH) && can.Option(nfs.PATH, msg.Option(nfs.PATH)) + can.Option(nfs.FILE, msg.Option(nfs.FILE)) + msg.Option(nfs.LINE) && can.Option(nfs.LINE, msg.Option(nfs.LINE)) + } if (can.Option(nfs.PATH) == "man") { msg.result = [msg.Option(mdb.TEXT)] } @@ -119,7 +124,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar if (can.isFloatMode()) { can.onmotion.hidden(can, can._action), can.onmotion.hidden(can, can.ui.project) } var width = can.ConfWidth()+(can.user.isMobile && can.isCmdMode() && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can.isCmdMode()? 20: 0) - can.page.styleWidth(can, can.ui.profile_output, can.profile_size[can.onexport.keys(can)]||(width-can.ui.project.offsetWidth)/2) + can.page.styleWidth(can, can.ui.profile_output, can.profile_size[can.onexport.keys(can)]||(width-can.ui.project.offsetWidth)/3) can.page.styleWidth(can, can.ui.content, width-can.ui.project.offsetWidth-can.ui.profile.offsetWidth) can.page.styleWidth(can, can.ui.display, width-can.ui.project.offsetWidth) @@ -175,7 +180,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar return can.Status("跳转数", can.history.length), push }, tabview: function(can, path, file, line, cb, skip, skip2) { var key = can.onexport.keys(can, file, path) - if (can.isCmdMode()) { location.hash = file+ice.FS+(line||1) } + if (can.isCmdMode()) { (location.hash = location.pathname.indexOf(file) > -1? "": file+ice.FS+(line||1)) } if (!skip && can.tabview[key]) { can.isCmdMode() && can.user.title(path+file) can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.tabview[key] can.Option({path: path, file: file, line: line||can._msg.Option(nfs.LINE)||1}) @@ -356,8 +361,8 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", list: ["keyword", "prefix", "line can.onaction.selectLine(null, can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb() msg.Option(nfs.FILE).indexOf("website/") == 0 && can.onaction[cli.SHOW]({}, can) + p && p.render && can.onaction[cli.SHOW]({}, can) if (can.page.ClassList.has(can, can._fields, chat.PLUGIN)) { - p && p.render && can.onaction[cli.SHOW]({}, can) p && p.engine && can.onaction[cli.EXEC]({}, can) } } @@ -385,6 +390,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", list: ["keyword", "prefix", "line return line }, go: { + render: {}, keyword: { "package": "keyword", "import": "keyword", @@ -601,6 +607,10 @@ Volcanos(chat.ONACTION, {help: "控件交互", list: ["搜索", "打开"], } can.runAction(event, mdb.RENDER, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) { can.onimport.profile(can, msg) + can.onappend._status(can, msg.Option(ice.MSG_STATUS), can.page.Append(can, can.ui._profile_output, ["status"]).first) + can.page.Select(can, can.ui._profile_output, "table.content", function(target) { + can.page.style(can, target, "max-height", "1000px") + }) }) }, exec: function(event, can) { can.request(event, {_toast: "执行中...", "some": "run"}) @@ -686,13 +696,20 @@ Volcanos(chat.ONACTION, {help: "控件交互", list: ["搜索", "打开"], } var push = can.onimport.history(can, {path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE), text: can.current.text()}) - if (can.isCmdMode()) { location.hash = push.file+ice.FS+(push.line||1) } + if (can.isCmdMode()) { (location.hash = location.pathname.indexOf(can.Option(nfs.FILE)) > -1? "": push.file+ice.FS+(push.line||1)) } can.onaction._selectLine(event, can) }) }, _selectLine: function(event, can) { }, - searchLine: function(event, can, value) { if (!can.ui.search) { return } - can.ui.search.Update(event, [ctx.ACTION, nfs.TAGS, value.trim()]) + searchLine: function(event, can, value) { + if (can.ui.search) { + can.ui.search.Update(event, [ctx.ACTION, nfs.TAGS, value.trim()]) + } else { + can.runAction(event, nfs.TAGS, [value], function(msg) { + msg.Append(nfs.FILE)? can.onimport.tabview(can, msg.Append(nfs.PATH), msg.Append(nfs.FILE), msg.Append(nfs.LINE)): + can.user.toast(can, "not found") + }) + } }, favorLine: function(event, can) { }, }) diff --git a/plugin/local/wiki/draw.js b/plugin/local/wiki/draw.js index 4989a9ba..5bc47ce8 100644 --- a/plugin/local/wiki/draw.js +++ b/plugin/local/wiki/draw.js @@ -18,7 +18,6 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, _show: function(can, msg) { can.point = [] can.svg = null, can.group = null, can.temp = null, can.current = null - can.ui = can.onlayout.profile(can), can.onmotion.hidden(can, can.ui.project) can.page.Modify(can, can.ui.content, msg.Result()||can.onexport.content(can)) can.page.Select(can, can.ui.content, html.SVG, function(svg) { @@ -279,7 +278,7 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: [ project: function(event, can) { can.onmotion.toggle(can, can.ui.project) }, profile: function(event, can) { can.onmotion.toggle(can, can.ui.profile) }, - show: function(event, can) { can.onmotion.show(can, {interval: 100, length: 10}, null, can.group) }, + show: function(event, can) { can.onmotion.show(can, {interval: 10, length: 1}, null, can.group) }, hide: function(event, can) { can.onmotion.hide(can, {interval: 100, length: 10}, null, can.group) }, create: function(event, can) { can.user.input(event, can, [svg.GROUP], function(list) { var name = list[0] diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index 7099274c..3129bc3c 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -114,7 +114,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.page.Select(can, target, html.TD, function(item) { can.onmotion.copy(can, item) }) }, image: function(can, data, target) { - can.page.style(can, target, html.MAX_HEIGHT, can.ConfHeight()/(can.user.isMobile? 2: 1), html.MAX_WIDTH, can.ConfWidth()) + // can.page.style(can, target, html.MAX_HEIGHT, can.ConfHeight()/(can.user.isMobile? 2: 1), html.MAX_WIDTH, can.ConfWidth()) + can.page.style(can, target, html.MAX_WIDTH, can.ConfWidth()) }, field: function(can, data, target, width) { var item = can.base.Obj(data.meta) can.onappend._init(can, item, [chat.PLUGIN_STATE_JS], function(sub) { diff --git a/plugin/state.js b/plugin/state.js index fec30560..713ffb52 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -20,9 +20,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, conf, cb, ta sub.Mode("float"), can.getActionSize(function(left, top, width, height) { left = left||0 var top = can.Mode() == undefined? 120: 0; if (can.user.isMobile) { top = can.user.isLandscape()? 0: 48 } sub.ConfHeight(height-top-2*html.ACTION_HEIGHT-(can.user.isMobile&&!can.user.isLandscape()? 2*html.ACTION_HEIGHT: 0)), sub.ConfWidth(width) + can.page.style(can, sub._output, "max-height", window.innerHeight - top, "overflow", "auto") can.onmotion.move(can, sub._target, {position: html.FIXED, left: left, top: top}) }) - }) + }, document.body) }, _rewrite: function(can, msg) { for (var i = 0; i < msg._arg.length; i += 2) { @@ -37,15 +38,15 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, conf, cb, ta msg.Table(function(item) { item.type = chat.STORY, can.onappend._plugin(can, item, {type: chat.STORY, arg: can.base.Obj(item[ice.ARG], [])}, function(sub, meta) { sub.Conf(can.base.Obj(item.conf)) if (sub.Conf("mode") == "simple") { (function() { - var msg = can.request(); msg.Echo(sub.Conf("result")) - sub.ConfHeight(can.ConfHeight()/2) + var msg = can.request(); msg.Echo(sub.Conf("result")), sub.ConfHeight(can.ConfHeight()/2) can.onappend._output(sub, msg, msg.Option(ice.MSG_DISPLAY)||sub.Conf("feature.display")) })(); return } + var opt = can.base.Obj(item[ice.OPT], []) sub.ConfHeight(can.ConfHeight()) sub.ConfWidth(can.ConfWidth()-4*html.PLUGIN_MARGIN) sub.run = function(event, cmds, cb, silent) { - var res = can.request(event, can.Option()) + var res = can.request(event, can.Option(), {pid: msg.Option("pid")}) for (var i = 0; i < opt.length; i += 2) { res.Option(opt[i], opt[i+1]) } can.run(event, (msg[ice.MSG_PREFIX]||[]).concat(cmds), cb, true) } @@ -101,7 +102,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, conf, cb, ta }) Volcanos(chat.ONACTION, {help: "交互操作", list: [ "刷新数据", "切换全屏", "共享工具", "打开链接", "生成链接", "生成脚本", "生成图片", [ - "其它", "刷新页面", "保存参数", "清空参数", "扩展参数", "复制数据", "下载数据", "清空数据", "删除配置", "查看配置", "删除工具","摄像头", + "其它", "刷新页面", "保存参数", "清空参数", "扩展参数", "复制数据", "下载数据", "清空数据", + "查看文档", "查看脚本", "查看源码", "查看配置", "删除配置", "删除工具", ], ], _engine: function(event, can, button) { can.Update(event, [ctx.ACTION, button].concat(can.Input([], true))) }, @@ -162,6 +164,9 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ "查看配置": function(event, can) { can.runAction(event, "config", ["select"], function(msg) { can.onappend.board(can, msg) }) }, + "查看文档": function(event, can) { can.runAction(event, "config", ["help"]) }, + "查看脚本": function(event, can) { can.runAction(event, "config", ["script"]) }, + "查看源码": function(event, can) { can.runAction(event, "config", ["source"]) }, "帮助文档": function(event, can) { can.runAction(event, "help") }, "打包页面": function(event, can) { can.onengine.signal(can, "onwebpack", can.request(event)) }, diff --git a/plugin/story/spide.js b/plugin/story/spide.js index a3108170..51f6a3c0 100644 --- a/plugin/story/spide.js +++ b/plugin/story/spide.js @@ -31,7 +31,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, _height: function(can, tree, deep) { if (!tree) { return 0 } tree.deep = deep||0 - if (tree.list.length == 0 || tree.hide) { return tree.height = 1 } + if (!tree.list || tree.list.length == 0 || tree.hide) { return tree.height = 1 } var height = 0; can.core.List(tree.list, function(item) { height += can.onimport._height(can, item, (deep||0)+1) @@ -40,7 +40,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, _width: function(can, tree, deep) { if (!tree) { return 0 } tree.deep = deep||0 - if (tree.list.length == 0 || tree.hide) { + if (!tree.list || tree.list.length == 0 || tree.hide) { if (!tree.name) { return tree.width = 20 } tree.view = can.onimport.draw({}, can, {shape: html.TEXT, point: [{x: 0, y: 0}], style: {inner: tree.name}}) return tree.width = tree.view.Val("textLength")+can.margin } @@ -53,11 +53,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar _color: function(can, tree) { return tree.meta&&tree.meta.color || (tree.list == 0? cli.PURPLE: cli.YELLOW) }, - layout: function(can) { - var p = can.Action(ice.VIEW, can.sup.view||can.Action(ice.VIEW)) + layout: function(can) { can.margin = can.margin||20 can.onmotion.clear(can), can.onimport._show(can, can.request()) can.svg.Val(html.FONT_SIZE, can.Action("size")) - can.onaction[p](event, can, p) + can.onaction[can.Action(ice.VIEW)](event, can, can.Action(ice.VIEW)) }, }, [""]) Volcanos(chat.ONACTION, {help: "用户操作", list: [ @@ -82,6 +81,7 @@ Volcanos(chat.ONACTION, {help: "用户操作", list: [ can.svg.Val(html.HEIGHT, can.height+can.margin) }, _draw: function(can, tree, x, y, style) { var color = can.onimport._color(can, tree) + if (!tree.name) { return } tree.view = can.onimport.draw({}, can, {shape: html.TEXT, point: [{x: x, y: y}], style: can.base.Copy(kit.Dict( html.STROKE, color, html.FILL, color, html.TEXT_ANCHOR, "start", "inner", tree.name||tree.file, ), style), }), can.core.ItemCB(can.ondetail, tree.view, can, tree) @@ -93,24 +93,22 @@ Volcanos(chat.ONACTION, {help: "用户操作", list: [ if (y+tree.height > can.height) { can.height = y+tree.height } if (tree.hide) { return } - var offset = 0; can.core.List(tree.list, function(item) { - can.onimport.draw({}, can, {shape: svg.PATH2V, point: [ + var offset = 0; can.core.List(tree.list, function(item) { if (!item) { return } + item.name && item.name != " " && can.onimport.draw({}, can, {shape: svg.PATH2V, point: [ {x: x+tree.width/2, y: y+tree.height-can.margin/2}, {x: x+offset+item.width/2, y: y+tree.height+can.margin/2}, ], style: {stroke: cli.CYAN}}) - - can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin) - offset += item.width + can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin), offset += item.width }) }, _draw_horizontal: function(can, tree, x, y) { tree.x = x, tree.y = y can.onaction._draw(can, tree, x, y+tree.height*can.margin/2, kit.Dict(html.TEXT_ANCHOR, "start")) - tree.width = tree.view.Val("textLength")||(tree.name||"").length*10 + tree.width = tree.view&&tree.view.Val("textLength")||(tree.name||"").length*10 if (x+tree.width > can.width) { can.width = x+tree.width } if (tree.hide) { return } - var offset = 0; can.core.List(tree.list, function(item) { + var offset = 0; can.core.List(tree.list, function(item) { if (!item || !item.name) { return } can.onimport.draw({}, can, {shape: svg.PATH2H, point: [ {x: x+tree.width+can.margin/8, y: y+tree.height*can.margin/2}, {x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.margin/2} diff --git a/proto.js b/proto.js index 806e921f..bf606913 100644 --- a/proto.js +++ b/proto.js @@ -238,7 +238,7 @@ var html = { OPACITY: "opacity", STROKE_WIDTH: "stroke-width", STROKE: "stroke", FILL: "fill", FONT_SIZE: "font-size", FONT_FAMILY: "font-family", MONOSPACE: "monospace", SCROLL: "scroll", HEIGHT: "height", WIDTH: "width", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom", - SPEED: "speed", PADDING: "padding", + SPEED: "speed", PADDING: "padding", MARGIN: "margin", MIN_HEIGHT: "min-height", MAX_HEIGHT: "max-height", MAX_WIDTH: "max-width", MIN_WIDTH: "min-width", MARGIN_TOP: "margin-top", MARGIN_X: "margin-x", MARGIN_Y: "margin-y", PLUGIN_MARGIN: 10, ACTION_HEIGHT: 31, ACTION_MARGIN: 200, TEXT_ANCHOR: "text-anchor", @@ -261,6 +261,7 @@ var html = { DIV_ITEM: "div.item", DIV_NAME: "div.name", DIV_CODE: "div.code", + DIV_TOGGLE: "div.toggle", DIV_LAYOUT_HEAD: "div.layout.head", DIV_LAYOUT_LEFT: "div.layout.left", DIV_LAYOUT_FOOT: "div.layout.foot", @@ -379,7 +380,10 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", pack: } return can.run && can.run(event, [chat._SEARCH].concat(cmds), cb, true) }, - get: function(name, key, cb) { return can.search({}, [can.core.Keys(name, chat.ONEXPORT, key)], cb) }, + get: function(name, key, cb) { var value + var res = can.search({}, [can.core.Keys(name, chat.ONEXPORT, key)], cb||function(msg) { value = msg.Result() }) + return value||res + }, set: function(name, key, value) { var msg = can.request({}); msg.Option(key, value) return can.search(msg, [[name, chat.ONIMPORT, key]]) },