mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
add toast
This commit is contained in:
parent
5c39492fa6
commit
96224b7862
56
frame.js
56
frame.js
@ -242,6 +242,31 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
|||||||
} })
|
} })
|
||||||
}, function(event, value, key, index, tr, td) {
|
}, function(event, value, key, index, tr, td) {
|
||||||
can.onappend.carte(can, can.ondetail||{}, msg["_detail"] || can.Conf("detail") || can.ondetail.list, function(event, item, meta) {
|
can.onappend.carte(can, can.ondetail||{}, msg["_detail"] || can.Conf("detail") || can.ondetail.list, function(event, item, meta) {
|
||||||
|
var back = td.innerHTML
|
||||||
|
switch (item) {
|
||||||
|
case "编辑":
|
||||||
|
var ui = can.page.Appends(can, td, [{type: "input", value: back, onkeydown: function(event) {
|
||||||
|
console.log("key", event.key)
|
||||||
|
switch (event.key) {
|
||||||
|
case "Enter":
|
||||||
|
td.innerHTML = event.target.value
|
||||||
|
|
||||||
|
var res = can.request(event); can.core.List(msg.append, function(key) {
|
||||||
|
res.Option(key, msg[key][index])
|
||||||
|
}); can.run(event, ["field", "action", item, key, event.target.value.trim(), value.trim()], function(res) {}, true)
|
||||||
|
break
|
||||||
|
case "Escape":
|
||||||
|
td.innerHTML = back
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}, onkeyup: function(event) {
|
||||||
|
|
||||||
|
}}]);
|
||||||
|
ui.input.focus()
|
||||||
|
ui.input.setSelectionRange(0, -1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var res = can.request(event); can.core.List(msg.append, function(key) {
|
var res = can.request(event); can.core.List(msg.append, function(key) {
|
||||||
res.Option(key, msg[key][index])
|
res.Option(key, msg[key][index])
|
||||||
}); can.run(event, ["field", "action", item, key, value.trim()], function(res) {}, true)
|
}); can.run(event, ["field", "action", item, key, value.trim()], function(res) {}, true)
|
||||||
@ -251,6 +276,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
|||||||
board: function(can, target, type, msg) {
|
board: function(can, target, type, msg) {
|
||||||
msg.result && can.page.AppendBoard(can, can._output, can.page.Display(msg.Result()))
|
msg.result && can.page.AppendBoard(can, can._output, can.page.Display(msg.Result()))
|
||||||
},
|
},
|
||||||
|
|
||||||
carte: function(can, meta, list, cb) {
|
carte: function(can, meta, list, cb) {
|
||||||
can._carte = can._carte || can.page.Append(can, can._target, [{view: "carte", onmouseleave: function(event) {
|
can._carte = can._carte || can.page.Append(can, can._target, [{view: "carte", onmouseleave: function(event) {
|
||||||
can.page.Modify(can, can._carte, {style: {display: "none"}})
|
can.page.Modify(can, can._carte, {style: {display: "none"}})
|
||||||
@ -281,6 +307,36 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
|
|||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
},
|
},
|
||||||
|
toast: function(can, text, title, duration) {
|
||||||
|
var meta = typeof text == "object"? text: {text: text, title: title, duration: duration}
|
||||||
|
can._toast = can._toast || can.page.Append(can, can._target, [{view: "toast", onmouseleave: function(event) {
|
||||||
|
can.page.Modify(can, can._carte, {style: {display: "none"}})
|
||||||
|
}}]).last
|
||||||
|
|
||||||
|
var ui = can.page.Appends(can, can._toast, [
|
||||||
|
{text: [meta.title||"", "div", "title"]},
|
||||||
|
{text: [meta.text||"执行成功", "div", "content"]},
|
||||||
|
meta.button,
|
||||||
|
{text: ["", "div", "duration"]},
|
||||||
|
])
|
||||||
|
|
||||||
|
var width = meta.width||200, height = meta.height||100
|
||||||
|
var pos = {position: "absolute", display: "block",
|
||||||
|
width: width+"px",
|
||||||
|
top: document.body.clientHeight/2,
|
||||||
|
left: document.body.clientWidth/2-width/2,
|
||||||
|
}; pos.left += "px"; pos.top += "px";
|
||||||
|
can.page.Modify(can, can._toast, {style: pos})
|
||||||
|
|
||||||
|
can.Timer({value: 1000, length: (meta.duration||3000)/1000}, function(event, interval, index) {
|
||||||
|
if (index > 2) {
|
||||||
|
ui.duration.innerHTML = index+"s..."
|
||||||
|
}
|
||||||
|
}, function() {
|
||||||
|
can.page.Modify(can, can._toast, {style: {display: "none"}})
|
||||||
|
})
|
||||||
|
return ui
|
||||||
|
},
|
||||||
share: function(can, meta) {
|
share: function(can, meta) {
|
||||||
return
|
return
|
||||||
can._share = can._share || can.page.Append(can, can._target, [{view: "share", onmouseleave: function(event) {
|
can._share = can._share || can.page.Append(can, can._target, [{view: "share", onmouseleave: function(event) {
|
||||||
|
@ -21,7 +21,10 @@ Volcanos("onexport", {help: "导出数据", list: [],
|
|||||||
sub.run = function(event, cmds, cb, silent) {
|
sub.run = function(event, cmds, cb, silent) {
|
||||||
// 插件回调
|
// 插件回调
|
||||||
var msg = can.request(event); pod && msg.Option("pod", pod);
|
var msg = can.request(event); pod && msg.Option("pod", pod);
|
||||||
can.run(event, [river, storm, index].concat(cmds), cb, silent);
|
can.run(event, [river, storm, index].concat(cmds), function(msg) {
|
||||||
|
can.onappend.toast(can, "执行成功", value.name, 2000);
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
}, silent);
|
||||||
can.run(msg._event, ["search", "Footer.onaction.cmd"])
|
can.run(msg._event, ["search", "Footer.onaction.cmd"])
|
||||||
}
|
}
|
||||||
}, can._output);
|
}, can._output);
|
||||||
|
@ -7,8 +7,9 @@ Volcanos("onaction", {help: "交互数据", list: [],
|
|||||||
can.onexport._init(can, msg, list, cb, target)
|
can.onexport._init(can, msg, list, cb, target)
|
||||||
},
|
},
|
||||||
cmd: function(can, msg, list, cb, target) {
|
cmd: function(can, msg, list, cb, target) {
|
||||||
can.Conf("ncmd", parseInt(can.Conf("ncmd")||"0")+1+"")
|
can.page.Select(can, can._target, "span.ncmd", function(item) {
|
||||||
can.onexport._init(can, msg, list, cb, target)
|
item.innerHTML = can.Conf("ncmd", parseInt(can.Conf("ncmd")||"0")+1+"")+""
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Volcanos("onexport", {help: "导出数据", list: [],
|
Volcanos("onexport", {help: "导出数据", list: [],
|
||||||
@ -19,7 +20,7 @@ Volcanos("onexport", {help: "导出数据", list: [],
|
|||||||
})
|
})
|
||||||
|
|
||||||
can.ui = can.page.Append(can, can._output, [{view: "state", list: can.core.List(can.Conf("state"), function(item) {
|
can.ui = can.page.Append(can, can._output, [{view: "state", list: can.core.List(can.Conf("state"), function(item) {
|
||||||
return {view: "item", list: [{text: item}, {text: ": "}, {text: can.Conf(item)||""}], click: function(event) {
|
return {view: "item", list: [{text: item}, {text: ": "}, {text: [can.Conf(item)||"", "span", item]}], click: function(event) {
|
||||||
can.onaction[item](event, can, item);
|
can.onaction[item](event, can, item);
|
||||||
}};
|
}};
|
||||||
}) }])
|
}) }])
|
||||||
|
@ -16,7 +16,6 @@ fieldset.Header>div.output>div.title:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fieldset.Header>div.output>div.state {
|
fieldset.Header>div.output>div.state {
|
||||||
margin-right:5px;
|
|
||||||
float:right;
|
float:right;
|
||||||
}
|
}
|
||||||
fieldset.Header>div.output>div.state>div {
|
fieldset.Header>div.output>div.state>div {
|
||||||
|
20
style.css
20
style.css
@ -125,6 +125,7 @@ fieldset table td.select {
|
|||||||
div.carte {
|
div.carte {
|
||||||
background:black;
|
background:black;
|
||||||
border:solid 2px red;
|
border:solid 2px red;
|
||||||
|
position:absolute;
|
||||||
}
|
}
|
||||||
div.carte div.item {
|
div.carte div.item {
|
||||||
padding:0 5px;
|
padding:0 5px;
|
||||||
@ -134,3 +135,22 @@ div.carte div.item:hover {
|
|||||||
border:solid 2px yellow;
|
border:solid 2px yellow;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.toast {
|
||||||
|
background:black;
|
||||||
|
border:solid 2px red;
|
||||||
|
position:absolute;
|
||||||
|
padding:5px;
|
||||||
|
color:yellow
|
||||||
|
}
|
||||||
|
div.toast div.title {
|
||||||
|
font-size:14px;
|
||||||
|
color:gray;
|
||||||
|
}
|
||||||
|
div.toast div.content {
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
div.toast div.duration {
|
||||||
|
font-size:14px;
|
||||||
|
color:gray;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user