From 254ed07ce0c54ad75b41adc58df794d1db9d0451 Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 27 Jul 2021 22:52:50 +0800 Subject: [PATCH] opt mall --- frame.js | 11 +++++++++-- page/index.css | 4 ++++ proto.js | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frame.js b/frame.js index a7f71f10..b03cbff7 100644 --- a/frame.js +++ b/frame.js @@ -343,12 +343,19 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, var table = can.page.AppendTable(can, msg, target||can._output, msg.append, cb||function(value, key, index, line, array) { if (key == "value") { key = line.key||line.name, line = {} can.core.List(array, function(item, index) { line[item.key||line.name] = item.value }) + if (key == "extra.cmd") { + can.onappend.plugin(can, {ctx: line["extra.ctx"], cmd: line["extra.cmd"], arg: line["extra.arg"]}, function(sub) { + sub.run = function(event, cmds, cb) { + can.run(event, [ctx.ACTION, cli.RUN].concat(cmds), cb, true) + } + }, target) + } } return {text: [value, "td"], onclick: function(event) { var target = event.target if (target.tagName == "INPUT" && target.type == "button") { var msg = can.sup.request(event, can.Option()) key == "value"? can.core.List(array, function(item, index) { msg.Option(item.key, item.value) }): msg.Option(line) - return can.run(event, ["action", target.name], function(msg) { can.run() }, true) + return can.run(event, [ctx.ACTION, target.name], function(msg) { can.run() }, true) } can.sup.onaction.change(event, can.sup, key, value, function(msg) { @@ -357,7 +364,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, }, ondblclick: function(event) { var target = event.target can.onmotion.modify(can, target, function(event, value, old) { var msg = can.sup.request(event, can.Option()) key == "value"? can.core.List(array, function(item, index) { msg.Option(item.key, item.value) }): msg.Option(line) - can.run(event, ["action", "modify", key == "value"? line.key||line.name: key, value], function(msg) { can.run() }, true) + can.run(event, [ctx.ACTION, mdb.MODIFY, key == "value"? line.key||line.name: key, value], function(msg) { can.run() }, true) }) }} }); table && can.page.Modify(can, table, {className: "content"}) diff --git a/page/index.css b/page/index.css index 94021731..35c3da5d 100644 --- a/page/index.css +++ b/page/index.css @@ -128,6 +128,7 @@ input[type=button]:hover { } td>input[type=button][name=remove] { background-color:red; + } td>input[type=button][name=create] { background-color:blue; @@ -357,6 +358,9 @@ fieldset>form.option { fieldset>div.action { float:left; } +fieldset>div.status { + border-top:1px solid darkcyan; +} fieldset>form.option>div.item { float:left; margin-right:3px; min-height:25px; vertical-align:middle; diff --git a/proto.js b/proto.js index 62d87ee2..ad17b779 100644 --- a/proto.js +++ b/proto.js @@ -113,6 +113,8 @@ var kit = { MDB_TEXT: "text", MDB_LINK: "link", } +var ice = { +} var ctx = { CONTEXT: "context", COMMAND: "command", @@ -122,3 +124,6 @@ var ctx = { var cli = { RUN: "run", } +var mdb = { + MODIFY: "modify", +}