From 1296591da7ea8b5a55d3651718b58e48979aeb4f Mon Sep 17 00:00:00 2001 From: shy Date: Thu, 7 Jul 2022 10:00:10 +0800 Subject: [PATCH] opt word.js --- frame.js | 5 +++-- page/index.css | 4 ++++ panel/action.js | 6 ++---- panel/search.js | 2 +- plugin/local/chat/div.js | 2 +- plugin/local/code/inner.js | 30 ++++++++++++++++-------------- plugin/local/wiki/word.js | 6 +++--- plugin/state.js | 10 +++++++++- plugin/story/spide.js | 6 +++--- proto.js | 8 +++++--- 10 files changed, 47 insertions(+), 32 deletions(-) diff --git a/frame.js b/frame.js index c3471af5..05c54c6c 100644 --- a/frame.js +++ b/frame.js @@ -158,6 +158,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, case lang.STRING: can.page.ClassList.add(can, field, style); break case lang.OBJECT: can.page.style(can, sub._target, style); break } + meta.type != sub.Mode() && can.page.ClassList.add(can, field, sub.Mode()) meta.inputs && sub.onappend._option(sub, meta, sub._option, meta.msg) if (meta.msg) { var msg = sub.request(); msg.Copy(can.base.Obj(meta.msg)), sub.onappend._output(sub, msg, msg.Option(ice.MSG_DISPLAY)||meta.feature.display) } @@ -192,7 +193,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, skip? next(): can.core.CallFunc([input.onaction, chat._INIT], [input, item, next, input._target]); (item.action||can.core.Value(meta, [ctx.FEATURE, ctx.INPUTS])) && can.onappend.figure(input, item, input._target) }) - }; can.core.Next(can.base.Obj(meta.inputs, can.core.Value(can, [chat.ONIMPORT, mdb.LIST])).concat(meta.type == chat.FLOAT? [{type: html.BUTTON, name: cli.CLOSE}]: []), add) + }; can.core.Next(can.base.getValid(can.core.Value(can, [chat.ONIMPORT, mdb.LIST]), can.base.Obj(meta.inputs)).concat([{type: html.BUTTON, name: cli.CLOSE}]), add) }, _action: function(can, list, action, meta) { list = can.base.Obj(can.base.getValid(list, can.core.Item(meta)), can.core.Value(can, [chat.ONACTION, mdb.LIST])); if (!list) { return } var _list = []; for (var i = 0; i < list.length; i++) { @@ -278,7 +279,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, return can.Update(event, can.Input(cmds, silent), cb, silent) }, can._outputs && can._outputs.push(table), table.sup = can, table._msg = msg - table._mode = can._mode, table.Conf(table._args = can.base.ParseURL(table._display)) + table.Mode(can.Mode()), table.Conf(table._args = can.base.ParseURL(table._display)) table._trans = can.base.Copy(table._trans||{}, can.core.Value(table, "onaction._trans")) if (table.onimport && can.base.isArray(table.onimport.list) && table.onimport.list.length > 0) { can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: table.onimport.list}) diff --git a/page/index.css b/page/index.css index aca13ba4..bc11fb6c 100644 --- a/page/index.css +++ b/page/index.css @@ -89,6 +89,10 @@ fieldset.story div.status { border-top:1px solid darkcyan; } /* fieldset.story>legend { height:30px; margin-right:5px; float:left; } */ fieldset.story>legend { padding:0 20px; margin:5px 0; } fieldset.float { background-color:#023531cf; } +fieldset.float input[type="button"][name="close"]{ display:block; } +fieldset.Full input[type="button"][name="close"]{ display:block; } +fieldset.plug input[type="button"][name="close"]{ display:block; } +fieldset input[type="button"][name="close"]{ display:none; } /* fieldset.float>div.action { display:block; height:2.3rem; } */ fieldset.float table { color:white; } diff --git a/panel/action.js b/panel/action.js index 0626d332..c62e8d3f 100644 --- a/panel/action.js +++ b/panel/action.js @@ -42,12 +42,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) { }) }, _cmd: function(can, item, next) { can.onengine.signal(can, chat.ONACTION_CMD) - - can.onappend.plugin(can, can.base.Copy(item, {opts: can.misc.Search(can)}), function(sub, meta, skip) { + can.onappend.plugin(can, can.base.Copy(item, {opts: can.misc.Search(can), mode: "cmd"}), function(sub, meta, skip) { sub.ConfHeight(can.ConfHeight()-can.Conf(html.MARGIN_Y)) can.page.style(can, sub._output, html.MAX_WIDTH, can.ConfWidth()) can.user.title(meta.name), skip || next() - sub._mode = can._mode }) }, height: function(can, height) { @@ -211,7 +209,7 @@ Volcanos(chat.ONACTION, {help: "交互操作", _init: function(can, cb, target) can.page.ClassList.add(can, can._root._target, "simple") can.page.ClassList.add(can, can._target, "cmd") can.onlayout._init(can) - can._mode = "cmd" + can.isCmdMode() }, layout: function(can, button, silent) { button = button||ice.AUTO diff --git a/panel/search.js b/panel/search.js index 167ec862..c8d9423d 100644 --- a/panel/search.js +++ b/panel/search.js @@ -114,7 +114,7 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [cli.CLOSE, cli.CLEAR, cli. if (can.page.tagis(html.A, event.target)) { return } var cmd = line.cmd == ctx.COMMAND? can.core.Keys(line.type, line.name.split(ice.SP)[0]): can.core.Keys(line.ctx, line.cmd) - can.onappend.plugin(can, {type: chat.PLUGIN, index: cmd||msg.Option(mdb.INDEX)}, function(sub, meta) { + can.onappend.plugin(can, {type: chat.STORY, index: cmd||msg.Option(mdb.INDEX), mode: "plug"}, function(sub, meta) { can.getActionSize(function(msg, height, width) { height = can.base.Min(height - can.ui.content.offsetHeight+204, height/2) can.page.style(can, sub._output, html.MAX_HEIGHT, height-26, html.MAX_WIDTH, width-40) sub.ConfHeight(height+28), sub.ConfWidth(width-60) diff --git a/plugin/local/chat/div.js b/plugin/local/chat/div.js index ce48e67a..4cd2610f 100644 --- a/plugin/local/chat/div.js +++ b/plugin/local/chat/div.js @@ -20,7 +20,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.onmotion.hidden(can, can._option) can.onmotion.hidden(can, can._action) } - if (can._mode == "cmd" || can.user.mod.isDiv) { + if (can.isCmdMode() || can.user.mod.isDiv) { width = can._root._width, height = can._root._height can.page.style(can, can._output, {width: width, height: height}) } diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index ff816d87..d59f3820 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -24,7 +24,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar })) can.onengine.listen(can, "orientationchange", function(event) { - if (can._mode == "cmd") { can.ConfHeight(can._root._height), can.ConfWidth(can._root._width) } + if (can.isCmdMode()) { can.ConfHeight(can._root._height), can.ConfWidth(can._root._width) } can.user.toast(can, can.ConfHeight()+"") can.onimport.layout(can) }) @@ -44,12 +44,6 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.ui._path = can.page.insertBefore(can, [{view: "path"}], can.ui.content) can.base.isFunc(cb) && cb(msg) - can._mode == "float" && can.onmotion.hidden(can, can.ui.project) - can._mode == "float" && can.onmotion.hidden(can, can._action) - can._mode == "float" && can.onmotion.hidden(can, can._action) - can._mode == "float" && can.onmotion.hidden(can, can.ui._tabs) - can._mode == "float" && can.onmotion.hidden(can, can.ui._path) - can.Conf("mode") == "simple"? can.onimport._simple(can): can.onimport.project(can, paths, function() { can.onimport._toolkit(can, can.ui.toolkit), can.onimport._session(can, msg), can.onimport._keydown(can) can.onmotion.delay(can, function() { @@ -137,7 +131,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }) }) }, _keydown: function(can) { can.onkeymap._build(can) - can._mode == "cmd" && can.onengine.listen(can, chat.ONKEYDOWN, function(event) { + can.isCmdMode() && can.onengine.listen(can, chat.ONKEYDOWN, function(event) { can._key_list = can.onkeymap._parse(event, can, "plugin", can._key_list, can.ui.content) }) }, @@ -195,8 +189,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, project.plugin) }, tabview: function(can, path, file, line, cb, skip, skip2) { var key = can.onexport.keys(can, file, path) - if (can._mode == "cmd") { location.hash = file } - if (!skip && can.tabview[key]) { can._mode == "cmd" && can.user.title(path+file) + if (can.isCmdMode()) { location.hash = file } + 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}) return can._msg.Option(can.Option()), can.onsyntax._init(can, can._msg, cb, skip2) @@ -275,7 +269,15 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, target) }, layout: function(can) { - var width = can.ConfWidth()+(can.user.isMobile && can._mode == "cmd" && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can._mode == "cmd"? 20: 0) + switch (can.Mode()) { + case "float": + can.onmotion.hidden(can, can.ui.project) + can.onmotion.hidden(can, can._action) + can.onmotion.hidden(can, can.ui._tabs) + can.onmotion.hidden(can, can.ui._path) + } + + var width = can.ConfWidth()+(can.user.isMobile && can.isCmdMode() && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can._mode == "cmd"? 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.content, width-can.ui.project.offsetWidth-can.ui.profile.offsetWidth) can.page.styleWidth(can, can.ui.display, width-can.ui.project.offsetWidth) @@ -286,7 +288,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar if (!height || height > can._root._height) { height = can._root._height - 200 } if (can.user.isMobile && can.user.isLandscape() && height < 200) { height = 400 } - if (can._mode == "cmd") { can.page.styleHeight(can, can.ui.project, height+2*html.ACTION_HEIGHT) + if (can.isCmdMode()) { can.page.styleHeight(can, can.ui.project, height+2*html.ACTION_HEIGHT) if (can.ui.project.offsetHeight) { var rest = can.ui.display.offsetHeight+can.ui._path.offsetHeight+can.ui._tabs.offsetHeight+5 can.page.styleHeight(can, can.ui.content, can.ui.project.offsetHeight-rest) @@ -298,7 +300,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar } } else { var rest = can.ui.display.offsetHeight+can.ui._path.offsetHeight+can.ui._tabs.offsetHeight+5 - can.page.style(can, can.ui.content, can._mode == "cmd" || can.user.isMobile? html.HEIGHT: html.MAX_HEIGHT, height) + can.page.style(can, can.ui.content, can.isCmdMode() || can.user.isMobile? html.HEIGHT: html.MAX_HEIGHT, height) can.page.styleHeight(can, can.ui.project, can.ui.content.offsetHeight+rest) if (can.page.ClassList.has(can, can._fields, "full")) { can.page.styleHeight(can, can.ui.profile_output, can.ui.content.offsetHeight) @@ -424,7 +426,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", list: ["keyword", "prefix", "line p && p.engine && can.onaction["执行"]({}, can) } can.onimport.layout(can) - if (!can.page.ClassList.has(can, can._fields, chat.STORY) && !can._mode == "cmd") { + if (!can.page.ClassList.has(can, can._fields, chat.STORY) && !can.isCmdMode()) { can.page.style(can, can.ui.project, html.MIN_HEIGHT, can.ConfHeight()-200) can.page.style(can, can.ui.content, html.MIN_HEIGHT, can.ConfHeight()-200) } diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index a7d0f101..2bc6c216 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -17,12 +17,12 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar if (can.core.Value(can, list[0])) { return can.core.CallFunc([can, list[0]], list.slice(1)) } if (!link || link == can.Option(nfs.PATH)) { return false } - if (can.onmotion.cache(can, function() { can._mode == "cmd" && can.user.title(item.meta.name); return can.Option(nfs.PATH, link) })) { return } + if (can.onmotion.cache(can, function() { can.isCmdMode() && can.user.title(item.meta.name); return can.Option(nfs.PATH, link) })) { return } return can.sup.Update(event, [link]) }, nav), can.sup._navmenu = nav can.getActionSize(function(msg) { - can.page.style(can, nav, html.HEIGHT, can.ConfHeight()+(can._mode == "cmd"? msg.Option(html.MARGIN_Y): 0)) + can.page.style(can, nav, html.HEIGHT, can.ConfHeight()+(can.isCmdMode()? msg.Option(html.MARGIN_Y): 0)) can.ConfWidth(can.ConfWidth()-nav.offsetWidth-20) can.page.style(can, can._output, html.HEIGHT, can.sup._navmenu.offsetHeight-20, html.MAX_WIDTH, can.ConfWidth(), @@ -39,7 +39,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }) }, title: function(can, data, target) { - can._mode == "cmd" && target.tagName == "H1" && can.user.title(data.text) + can.isCmdMode() && target.tagName == "H1" && can.user.title(data.text) }, refer: function(can, data, target) { can.page.Select(can, target, html.A, function(item) { diff --git a/plugin/state.js b/plugin/state.js index 77c1e31f..5d5f2a5e 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -94,9 +94,11 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ "刷新数据": function(event, can) { can.Update({}, can.Input([], true)) }, "切换全屏": function(event, can) { var sub = can._outputs[can._outputs.length-1] if (can.page.ClassList.neg(can, can._target, "Full")) { sub._height_bak = sub.ConfHeight(), sub._width_bak = sub.ConfWidth() + can._mode = can.Mode(), can.Mode("full"), sub.Mode("full") var height = can._root._height-(can._status.innerText? 2: 1)*html.ACTION_HEIGHT; can.user.isMobile && (height -= 2*html.ACTION_HEIGHT) can.page.style(can, can._output, html.HEIGHT, sub.ConfHeight(height), html.MIN_WIDTH, sub.ConfWidth(can._root._width)) } else { + can.Mode(can._mode), sub.Mode(can._mode) sub.ConfHeight(sub._height_bak), sub.ConfWidth(sub._width_bak) can.page.style(can, can._output, html.HEIGHT, "", html.MIN_WIDTH, "") } @@ -170,7 +172,13 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ }, clear: function(event, can, name) { can.onmotion.clear(can, can._output) }, - close: function(event, can) { can.page.Remove(can, can._target) }, + close: function(event, can) { + if (can.isFullMode()) { + can.onaction["切换全屏"](event, can) + } else { + can.page.Remove(can, can._target) + } + }, upload: function(event, can) { can.user.upload(event, can) }, actions: function(event, can) { can.onmotion.toggle(can, can._action) }, next: function(event, can) { can.Update(event, [ctx.ACTION, mdb.NEXT, can.Status(mdb.TOTAL)||0, can.Option(mdb.LIMIT)||can.Action(mdb.LIMIT)||"", can.Option(mdb.OFFEND)||can.Action(mdb.OFFEND)||""]) }, diff --git a/plugin/story/spide.js b/plugin/story/spide.js index 367298cc..bed1ecfd 100644 --- a/plugin/story/spide.js +++ b/plugin/story/spide.js @@ -152,10 +152,10 @@ Volcanos(chat.ONDETAIL, {help: "用户交互", }, true) }, plugin: function(can, index, args, prefix) { - can.onappend.plugin(can, {type: chat.FLOAT, index: index, args: args}, function(sub) { + can.onappend.plugin(can, {type: chat.FLOAT, index: index, args: args, mode: "float"}, function(sub) { sub.run = function(event, cmds, cb) { can.runAction(can.request(event), prefix, cmds, cb) } - 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.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.onmotion.move(can, sub._target, {position: html.FIXED, left: left, top: top}) }) diff --git a/proto.js b/proto.js index 6159da87..5b8d24bc 100644 --- a/proto.js +++ b/proto.js @@ -372,9 +372,11 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", pack: getAction: function(key, cb) { return can.get("Action", key, cb) }, getActionSize: function(cb) { return can.get("Action", "size", cb) }, - ConfDefault: function(value) { - can.core.Item(value, function(k, v) { can.Conf(k) || can.Conf(k, v) }) - }, + isCmdMode: function(value) { return can.Mode() == "cmd" }, + isFullMode: function(value) { return can.Mode() == "full" }, + isFloatMode: function(value) { return can.Mode() == "float" }, + Mode: function(value) { return can.Conf("mode", value) }, + ConfDefault: function(value) { can.core.Item(value, function(k, v) { can.Conf(k) || can.Conf(k, v) }) }, ConfHeight: function(value) { return can.Conf(html.HEIGHT, value) }, ConfWidth: function(value) { return can.Conf(html.WIDTH, value) }, Conf: function(key, value) { var res = can._conf