forked from x/volcanos
opt action.js
This commit is contained in:
parent
02fcf73f17
commit
9fcb69e8db
12
lib/user.js
12
lib/user.js
@ -231,8 +231,7 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
can.page.Modify(can, ui._target, {style: {left: event.clientX, top: event.clientY}})
|
||||
},
|
||||
|
||||
input: function(event, can, form, cb, button) { // form [ string, array, object, {type: "select", values: []}
|
||||
if (!form || form.length == 0) { return cb()}
|
||||
input: function(event, can, form, cb, button) { if (!form || form.length == 0) { return cb()}
|
||||
var msg = can.request(event)
|
||||
var ui = can.page.Append(can, document.body, [{view: [html.INPUT], style: {left: 0, top: 0}, list: [
|
||||
{view: [chat.OPTION, html.TABLE], list: can.core.List(form, function(item) {
|
||||
@ -242,10 +241,10 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
item._init = function(target) {
|
||||
item.run = function(event, cmds, cb) {
|
||||
can.request(event, function() { var value = {_handle: ice.TRUE, action: msg.Option(chat.ACTION)}
|
||||
can.page.Select(can, ui.table, "textarea,input,select", function(item) {
|
||||
can.page.Select(can, ui.table, chat.OPTION_ARGS, function(item) {
|
||||
item.name && item.value && (value[item.name] = item.value)
|
||||
}); return value
|
||||
}, msg, can.Option()); can.run(event, cmds, cb, true)
|
||||
}, msg, can.Option()), can.run(event, cmds, cb, true)
|
||||
}
|
||||
|
||||
target.value = target.value||(item.name&&(msg.Option(item.name)||can.Option(item.name)))||""
|
||||
@ -255,12 +254,13 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
return {type: html.TR, list: [{type: html.TD, list: [{text: item._trans||can.user.trans(can, item.name)||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]}
|
||||
})}, {view: chat.ACTION},
|
||||
]}]); can.onlayout.figure(event, can, ui._target)
|
||||
can.page.ClassList.add(can, ui._target, chat.FLOAT)
|
||||
|
||||
var action = can.onappend._action(can, button||[html.SUBMIT, html.CANCEL], ui.action, {
|
||||
cancel: function(event) { can.page.Remove(can, ui._target) },
|
||||
_engine: function(event, can, button) { action.submit(event, can, button) },
|
||||
submit: function(event, can, button) { var data = {}, args = [], list = []
|
||||
list = can.page.Select(can, ui.table, "textarea,input,select", function(item) {
|
||||
list = can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
||||
return item.name && item.value && args.push(item.name, item.value), data[item.name] = item.value
|
||||
})
|
||||
var msg = can.request(event, {_handle: ice.TRUE})
|
||||
@ -268,7 +268,7 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
}, _target: ui._target,
|
||||
})
|
||||
|
||||
can.page.Select(can, ui._target, "textarea,input", function(item, index) {
|
||||
can.page.Select(can, ui._target, html.INPUT_ARGS, function(item, index) {
|
||||
index == 0 && can.onmotion.focus(can, item)
|
||||
})
|
||||
return action
|
||||
|
@ -24,19 +24,18 @@ fieldset.Action>div.action div.item.select {
|
||||
background-color:#2e515f;
|
||||
}
|
||||
|
||||
fieldset.Action div.output fieldset.plugin.fixed {
|
||||
position:fixed;
|
||||
left:0px;
|
||||
top:0px;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
background-color:black;
|
||||
height: -webkit-fill-available;
|
||||
width: -webkit-fill-available;
|
||||
overflow: auto;
|
||||
background-color: #061c3cd9;
|
||||
|
||||
fieldset.Action div.output fieldset.plugin:hover {
|
||||
box-shadow:4px 4px 12px 6px #626bd0;
|
||||
}
|
||||
fieldset.Action div.output fieldset.plugin legend {
|
||||
font-size:16px; font-family:monospace;
|
||||
margin-top:4px 5px; padding:2px 20px;
|
||||
background-color:#0c739cd9;
|
||||
}
|
||||
fieldset.Action div.output fieldset.plugin legend:hover {
|
||||
background:red;
|
||||
}
|
||||
|
||||
fieldset.Action div.output.tabs {
|
||||
margin-top:28px;
|
||||
}
|
||||
@ -64,18 +63,6 @@ fieldset.Action div.output.free fieldset.plugin.select {
|
||||
display:block;
|
||||
}
|
||||
|
||||
fieldset.Action div.output fieldset.plugin:hover {
|
||||
box-shadow:4px 4px 12px 6px #626bd0;
|
||||
}
|
||||
fieldset.Action div.output fieldset.plugin legend {
|
||||
font-size:16px; font-family:monospace;
|
||||
margin-top:4px 5px; padding:2px 20px;
|
||||
background-color:#0c739cd9;
|
||||
}
|
||||
fieldset.Action div.output fieldset.plugin legend:hover {
|
||||
background:red;
|
||||
}
|
||||
|
||||
fieldset.panel.cmd>div.legend {
|
||||
display:none;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg) {
|
||||
var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM)
|
||||
can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) { item.type = chat.PLUGIN
|
||||
can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) {
|
||||
item.height = parseInt(can.Conf(html.HEIGHT))-can.Conf(html.MARGIN_Y)
|
||||
item.width = parseInt(can.Conf(html.WIDTH))-can.Conf(html.MARGIN_X)
|
||||
item.feature = can.base.Obj(item.feature||item.meta)
|
||||
@ -15,7 +15,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg)
|
||||
},
|
||||
_plugin: function(can, river, storm, sub, meta) { sub._target._meta = meta
|
||||
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
|
||||
return can.run(event, can.misc.concat([river, storm, meta.id||meta.index||can.core.Keys(meta.key, meta.name)], cmds||[]), cb)
|
||||
return can.run(event, can.misc.concat([river, storm, meta.id||meta.index], cmds||[]), cb)
|
||||
}, can._plugins = (can._plugins||[]).concat([sub])
|
||||
|
||||
meta.id && (sub._option.dataset = sub._option.dataset||{}, sub._option.dataset.id = meta.id)
|
||||
@ -133,7 +133,7 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, cb, t
|
||||
})
|
||||
},
|
||||
onsearch: function(can, msg, word) {
|
||||
if (word[0] == "*" || word[0] == mdb.PLUGIN) { can.onexport.plugin(can, msg, word) }
|
||||
if (word[0] == mdb.FOREACH || word[0] == mdb.PLUGIN) { can.onexport.plugin(can, msg, word) }
|
||||
},
|
||||
onsize: function(can, msg, height, width) { can.Conf({height: height, width: width}) },
|
||||
|
||||
@ -142,11 +142,10 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, cb, t
|
||||
can.page.Modify(can, can._action, {className: chat.ACTION+ice.SP+button})
|
||||
can.page.Modify(can, can._output, {className: chat.OUTPUT+ice.SP+button})
|
||||
|
||||
if (button == "tabs" && !can.tabs) { can.tabs = true
|
||||
if (button == "tabs") {
|
||||
can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, 0)
|
||||
can.onmotion.select(can, can._action, html.DIV_ITEM, 0)
|
||||
}
|
||||
if (button == "free" && !can.free) { can.free = true
|
||||
} else if (button == "free") {
|
||||
can.page.Select(can, can._target, html.DIV_OUTPUT+ice.GT+html.FIELDSET_PLUGIN, function(item, index) {
|
||||
can.page.Modify(can, item, {style: {left: 40*index, top: 40*index}})
|
||||
can.onmotion.move(can, item, {left: 40*index, top: 40*index})
|
||||
@ -168,25 +167,24 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _focus: [], _init: functio
|
||||
b: function(event, can, target) { can.search(event, ["Header.onaction.black"]) },
|
||||
w: function(event, can, target) { can.search(event, ["Header.onaction.white"]) },
|
||||
|
||||
g: function(event, can, target) { can.search(event, ["River.ondetail.创建群组"]) },
|
||||
s: function(event, can, target) { can.search(event, ["River.ondetail.添加应用"]) },
|
||||
t: function(event, can, target) { can.search(event, ["River.ondetail.添加工具"]) },
|
||||
|
||||
":": function(event, can, target) {
|
||||
can.onengine.signal(can, "oncommandfocus")
|
||||
},
|
||||
" ": function(event, can, target) {
|
||||
can.onengine.signal(can, "onsearchfocus")
|
||||
},
|
||||
":": function(event, can, target) {
|
||||
can.onengine.signal(can, "oncommandfocus")
|
||||
},
|
||||
enter: function(event, can, target) { can.misc.Log("enter") },
|
||||
escape: function(event, can, target) {
|
||||
can.page.Select(can, document.body, "fieldset.float,div.float", function(item) {
|
||||
can.page.Remove(can, item)
|
||||
})
|
||||
can.page.Select(can, document.body, "fieldset.auto", function(item) {
|
||||
can.page.Select(can, document.body, html.FIELDSET_AUTO, function(item) {
|
||||
can.onmotion.hidden(can, item)
|
||||
})
|
||||
can.search(event, ["Search.onaction.hide"])
|
||||
can.misc.Log("enter")
|
||||
can.page.Select(can, document.body, can.base.join([html.FIELDSET_FLOAT, html.DIV_FLOAT], ice.FS), function(item) {
|
||||
can.page.Remove(can, item)
|
||||
})
|
||||
},
|
||||
},
|
||||
}, _engine: {},
|
||||
|
@ -59,6 +59,13 @@ Volcanos("onaction", {help: "交互操作", list: [cli.CLEAR, cli.CLOSE, cli.DON
|
||||
if (event.ctrlKey) { return can.onaction[cli.DONE](event, can) }
|
||||
can.input(event, event.target.value)
|
||||
}
|
||||
can.page.Select(can, can.ui.content, html.TR, function(tr, index) {
|
||||
if (index == 0) { return }
|
||||
var has = false; can.page.Select(can, tr, html.TD, function(td) {
|
||||
has = has || td.innerText.indexOf(event.target.value) > -1
|
||||
})
|
||||
can.page.ClassList.set(can, tr, html.HIDDEN, !has)
|
||||
})
|
||||
}]},
|
||||
{view: chat.CONTENT}, {view: html.STATUS}, {view: [chat.DISPLAY, html.TABLE]},{view: chat.PROFILE},
|
||||
]), can.page.ClassList.add(can, can.ui.display, chat.CONTENT)
|
||||
|
@ -62,8 +62,8 @@ Volcanos("onfigure", {help: "控件详情", list: [], key: {
|
||||
if (event.ctrlKey && ["n", "p"].indexOf(event.key) > -1) {
|
||||
return event.stopPropagation(), event.preventDefault()
|
||||
}
|
||||
last(event, can)
|
||||
// can.onaction && can.onaction.onkeydown && can.onaction.onkeydown(event, can)
|
||||
switch (event.key) { case lang.ESCAPE: event.target.blur(); return }
|
||||
can.base.isFunc(last) && last(event, can)
|
||||
},
|
||||
}})
|
||||
|
||||
|
6
proto.js
6
proto.js
@ -87,6 +87,8 @@ var mdb = {
|
||||
|
||||
PLUGIN: "plugin", RENDER: "render", SEARCH: "search", ENGINE: "engine",
|
||||
NEXT: "next", PREV: "prev", PAGE: "page", MAIN: "main",
|
||||
|
||||
FOREACH: "*", RANDOMS: "%",
|
||||
}
|
||||
var ssh = {
|
||||
SCRIPT: "script",
|
||||
@ -176,11 +178,13 @@ var html = {
|
||||
FIELDSET: "fieldset", LEGEND: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status",
|
||||
FORM_OPTION: "form.option", DIV_ACTION: "div.action", DIV_OUTPUT: "div.output", DIV_STATUS: "div.status",
|
||||
FIELDSET_PANEL: "fieldset.panel", FIELDSET_PLUGIN: "fieldset.plugin", FIELDSET_STORY: "fieldset.story",
|
||||
FIELDSET_FLOAT: "fieldset.float", FIELDSET_AUTO: "fieldset.auto",
|
||||
OPTION_ARGS: "select.args,input.args,textarea.args",
|
||||
INPUT_ARGS: "input.args,textarea.args",
|
||||
DIV_ITEM: "div.item", DIV_FLOAT: "div.float",
|
||||
|
||||
UPLOAD: "upload", USERNAME: "username", PASSWORD: "password",
|
||||
INPUT: "input", INPUT_ARGS: ".args", TEXT: "text", TEXTAREA: "textarea", SELECT: "select", BUTTON: "button",
|
||||
INPUT: "input", TEXT: "text", TEXTAREA: "textarea", SELECT: "select", BUTTON: "button",
|
||||
FORM: "form", FILE: "file", SPACE: "space", CLICK: "click", SUBMIT: "submit", CANCEL: "cancel",
|
||||
DIV: "div", IMG: "img", CODE: "code", SPAN: "span", VIDEO: "video",
|
||||
TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br", UL: "ul", LI: "li",
|
||||
|
Loading…
x
Reference in New Issue
Block a user