mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add plugin import
This commit is contained in:
parent
30bcd0df6f
commit
9bdb7f464b
5
frame.js
5
frame.js
@ -32,10 +32,12 @@ var can = Volcanos("chat", {
|
||||
action: field.querySelector("div.action"),
|
||||
output: field.querySelector("div.output"),
|
||||
Plugin: can.Plugin, Inputs: can.Inputs, Output: can.Output,
|
||||
_plugins: [],
|
||||
|
||||
Export: function(event, value, key) {can.Report(event, value, key)},
|
||||
Import: function(event, value, key) {var cb = pane.onimport[key];
|
||||
typeof cb == "function" && cb(event, pane, value, key, pane.output);
|
||||
can.core.List(pane._plugins, function(item) {item.Import(event, value, key)})
|
||||
},
|
||||
|
||||
Size: function(event, width, height) {var cb = pane.onimport["size"];
|
||||
@ -117,6 +119,7 @@ var can = Volcanos("chat", {
|
||||
|
||||
Import: function(event, value, key) {var cb = plugin.onimport[key];
|
||||
typeof cb == "function" && cb(event, plugin, value, key, plugin.output);
|
||||
key && plugin[key] && plugin[key].target && plugin[key].Import(event, value, key)
|
||||
},
|
||||
|
||||
Remove: function(event) {var list = can.page.Select(can, option, "input.temp")
|
||||
@ -156,7 +159,7 @@ var can = Volcanos("chat", {
|
||||
},
|
||||
Check: function(event, target, cb) {
|
||||
plugin.page.Select(can, option, ".args", function(item, index, list) {
|
||||
if (item == target && index < list.length-1) {can._plugin.target == field && list[index+1].focus(); return item}
|
||||
if (item == target && index < list.length-1) {can._plugin && can._plugin.target == field && list[index+1].focus(); return item}
|
||||
}).length == 0 && plugin.Runs(event, cb)
|
||||
},
|
||||
Last: function(event) {
|
||||
|
34
lib/page.js
34
lib/page.js
@ -187,6 +187,40 @@ Volcanos("page", {help: "网页模块",
|
||||
}))
|
||||
return table;
|
||||
}),
|
||||
RangeTable: function(can, table, index, sort_asc) {
|
||||
var list = can.page.Select(can, table, "tr", function(tr) {
|
||||
return tr.style.display == "none" || can.page.ClassList.has(can, tr, "hide")? null: tr
|
||||
}).slice(1)
|
||||
|
||||
var is_time = true, is_number = true
|
||||
can.core.List(list, function(tr) {
|
||||
var text = tr.childNodes[index].innerText
|
||||
is_time = is_time && Date.parse(text) > 0
|
||||
is_number = is_number && !isNaN(parseInt(text))
|
||||
})
|
||||
|
||||
var num_list = can.core.List(list, function(tr) {
|
||||
var text = tr.childNodes[index].innerText
|
||||
return is_time? Date.parse(text):
|
||||
is_number? parseInt(text): text
|
||||
})
|
||||
|
||||
for (var i = 0; i < num_list.length; i++) {
|
||||
for (var j = i+1; j < num_list.length; j++) {
|
||||
if (sort_asc? num_list[i] < num_list[j]: num_list[i] > num_list[j]) {
|
||||
var temp = num_list[i]
|
||||
num_list[i] = num_list[j]
|
||||
num_list[j] = temp
|
||||
var temp = list[i]
|
||||
list[i] = list[j]
|
||||
list[j] = temp
|
||||
}
|
||||
}
|
||||
var tbody = list[i].parentElement
|
||||
list[i].parentElement && tbody.removeChild(list[i])
|
||||
tbody.appendChild(list[i])
|
||||
}
|
||||
},
|
||||
|
||||
Display: function(text) {
|
||||
if (text.startsWith("http")) {return "<a href='"+text+"' target='_blank'>"+text+"</a>"}
|
||||
|
@ -1,9 +1,9 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
init: function(event, can, msg, cmd, output) {output.innerHTML = "";
|
||||
msg.Table(function(item, index) {if (!item.name) {return}
|
||||
can[item.name] = can.Plugin(can, item.name, item, function(event, cmds, cbs) {
|
||||
can._plugins.push(can[item.name] = can.Plugin(can, item.name, item, function(event, cmds, cbs) {
|
||||
can.run(event, [item.river, item.storm, item.action].concat(cmds), cbs)
|
||||
}, can.page.AppendField(can, output, "item "+item.group+" "+item.name, item))
|
||||
}, can.page.AppendField(can, output, "item "+item.group+" "+item.name, item)))
|
||||
})
|
||||
},
|
||||
size: function(event, can, value, cmd, output) {
|
||||
@ -30,7 +30,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
},
|
||||
you: function(event, can, value, cmd, output) {
|
||||
can.page.Select(can, can.action, "input."+cmd, function(item) {
|
||||
item.value = value
|
||||
document.title = item.value = value;
|
||||
})
|
||||
},
|
||||
layout: function(event, can, value, cmd, output) {can.layout = value;
|
||||
|
@ -1,5 +1,9 @@
|
||||
Volcanos("onimport", {help: "导入数据", list: [],
|
||||
_init: function(can, conf, output) {
|
||||
can.Show(200, 100, -100)
|
||||
can.target.style.height = ""
|
||||
can.target.style.width = ""
|
||||
|
||||
can.user.toast = function(text, title, duration, list) {if (!text) {return can.Hide()}
|
||||
text = typeof text == "object"? text: {list: list, text: text, title: title||""}
|
||||
text.duration = text.duration || conf.duration || 3000
|
||||
@ -30,8 +34,6 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
return timer
|
||||
}
|
||||
},
|
||||
show: function(event, can, value, cmd, output) {
|
||||
}
|
||||
})
|
||||
Volcanos("onaction", {help: "组件交互", list: []})
|
||||
Volcanos("onchoice", {help: "组件菜单", list: []})
|
||||
|
@ -14,6 +14,12 @@ Volcanos("onimport", {help: "导入数据", list: [],
|
||||
})
|
||||
break
|
||||
case "TH":
|
||||
var index = 0;
|
||||
can.page.Select(can, table, "th", function(item, i) {if (item == event.target) {index = i}})
|
||||
var dataset = event.target.dataset
|
||||
dataset["sort_asc"] = (dataset["sort_asc"] == "1") ? 0: 1
|
||||
can.page.RangeTable(can, table, index, dataset["sort_asc"] == "1")
|
||||
break
|
||||
case "TR":
|
||||
case "TABLE":
|
||||
}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user