mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
opt spide.js
This commit is contained in:
parent
19931c4f02
commit
e51da4f90a
6
frame.js
6
frame.js
@ -130,7 +130,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
|||||||
sub.page.ClassList.add(sub, field, meta.style||meta.feature.style||"")
|
sub.page.ClassList.add(sub, field, meta.style||meta.feature.style||"")
|
||||||
|
|
||||||
sub.page.Modify(sub, sub._legend, {onmouseenter: function(event) {
|
sub.page.Modify(sub, sub._legend, {onmouseenter: function(event) {
|
||||||
sub.user.carte(event, sub, sub.onaction, sub.onaction.list.concat([["所有 ->"].concat(can.core.Item(meta.feature._trans))]))
|
sub.user.carte(event, sub, sub.onaction, sub.onaction.list.concat([["所有 ->"].concat(can.core.Item(meta.feature._trans))], ["close"]))
|
||||||
}})
|
}})
|
||||||
|
|
||||||
meta.inputs && sub.onappend._option(sub, meta, sub._option)
|
meta.inputs && sub.onappend._option(sub, meta, sub._option)
|
||||||
@ -157,7 +157,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
|||||||
|
|
||||||
(item.action||meta.feature["inputs"]) && can.onappend.figure(input, item, input._target)
|
(item.action||meta.feature["inputs"]) && can.onappend.figure(input, item, input._target)
|
||||||
})
|
})
|
||||||
}; can.core.Next(can.base.Obj(meta.inputs, []), add)
|
}; can.core.Next(can.base.Obj(meta.inputs, []).concat(meta.type == chat.FLOAT? [{type: html.BUTTON, name: cli.CLOSE}]: []), add)
|
||||||
},
|
},
|
||||||
_action: function(can, list, action, meta) { action = action||can._action, meta = meta||can.onaction
|
_action: function(can, list, action, meta) { action = action||can._action, meta = meta||can.onaction
|
||||||
can.core.List(list||can.onaction.list, function(item) { can.onappend.input(can, item == ""? /*空白*/ {type: html.SPACE}:
|
can.core.List(list||can.onaction.list, function(item) { can.onappend.input(can, item == ""? /*空白*/ {type: html.SPACE}:
|
||||||
@ -249,7 +249,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
|||||||
var title = !item.help || can.user.language(can) == "en"? name: name+"("+item.help.split(ice.SP)[0]+")"
|
var title = !item.help || can.user.language(can) == "en"? name: name+"("+item.help.split(ice.SP)[0]+")"
|
||||||
return can.page.Append(can, target||can._output, [{view: [can.base.join([type||"", item.name||"", item.pos||""]), html.FIELDSET], list: [
|
return can.page.Append(can, target||can._output, [{view: [can.base.join([type||"", item.name||"", item.pos||""]), html.FIELDSET], list: [
|
||||||
name && {text: [title, html.LEGEND]},
|
name && {text: [title, html.LEGEND]},
|
||||||
can.user.mod.isCmd && type == chat.PLUGIN && {view: [html.LEGEND, html.DIV, title]},
|
(can.user.mod.isCmd && type == chat.PLUGIN || type == chat.FLOAT) && {view: [html.LEGEND, html.DIV, title]},
|
||||||
{view: [html.OPTION, html.FORM]}, {view: [html.ACTION]}, {view: [html.OUTPUT]}, {view: [html.STATUS]},
|
{view: [html.OPTION, html.FORM]}, {view: [html.ACTION]}, {view: [html.OUTPUT]}, {view: [html.STATUS]},
|
||||||
]}])
|
]}])
|
||||||
},
|
},
|
||||||
|
13
lib/base.js
13
lib/base.js
@ -58,6 +58,13 @@ Volcanos("base", {help: "数据类型",
|
|||||||
}
|
}
|
||||||
return res.join("&")
|
return res.join("&")
|
||||||
},
|
},
|
||||||
|
ParseURL: function(url) { var res = {link: url}
|
||||||
|
var list = url.split("?"); res["origin"] = list[0]
|
||||||
|
list[1] && list[1].split("&").forEach(function(item) {
|
||||||
|
var ls = item.split("="); res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1])
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
},
|
||||||
MergeURL: function(url) { var args = {}
|
MergeURL: function(url) { var args = {}
|
||||||
var arg = url.split("?")[1]||""
|
var arg = url.split("?")[1]||""
|
||||||
arg && arg.split("&").forEach(function(item) {
|
arg && arg.split("&").forEach(function(item) {
|
||||||
@ -224,5 +231,11 @@ Volcanos("base", {help: "数据类型",
|
|||||||
isFunc: function(cb) { return typeof cb == "function" },
|
isFunc: function(cb) { return typeof cb == "function" },
|
||||||
isUndefined: function(arg) { return arg == undefined },
|
isUndefined: function(arg) { return arg == undefined },
|
||||||
isNull: function(arg) { return arg == null },
|
isNull: function(arg) { return arg == null },
|
||||||
|
joins: function(list) {
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
list[i] = typeof list[i] == lang.STRING? list[i]: list[i].join(ice.FS)
|
||||||
|
}
|
||||||
|
return list.join(ice.SP)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
15
lib/core.js
15
lib/core.js
@ -182,13 +182,18 @@ Volcanos("core", {help: "数据结构",
|
|||||||
}
|
}
|
||||||
return list
|
return list
|
||||||
}),
|
}),
|
||||||
ItemCB: shy("迭代器", function(obj, cb) { var list = []
|
ItemCB: shy("迭代器", function(meta, cb, can, item) { var list = []
|
||||||
for (var k in obj) {
|
for (var k in meta) { (function(k) {
|
||||||
if (k.indexOf("on") == 0 && typeof obj[k] == lang.FUNCTION) {
|
if (k.indexOf("on") == 0 && typeof meta[k] == lang.FUNCTION) {
|
||||||
cb(k, obj[k])
|
if (typeof cb == lang.FUNCTION) {
|
||||||
|
cb(k, meta[k])
|
||||||
|
} else {
|
||||||
|
cb[k] = function(event) { meta[k](event, can, item) }
|
||||||
|
}
|
||||||
list.push(k)
|
list.push(k)
|
||||||
}
|
}
|
||||||
}
|
})(k) }
|
||||||
|
return list
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -221,6 +221,15 @@ legend {
|
|||||||
fieldset {
|
fieldset {
|
||||||
margin:0; border:0; padding:0;
|
margin:0; border:0; padding:0;
|
||||||
}
|
}
|
||||||
|
fieldset>div.legend {
|
||||||
|
float:left; padding:0 10px; margin-right:3px;
|
||||||
|
height:25px; font-size:18px;
|
||||||
|
background-color:darkcyan;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
fieldset>div.legend {
|
||||||
|
background-color:honeydew;
|
||||||
|
}
|
||||||
fieldset>form.option {
|
fieldset>form.option {
|
||||||
float:left;
|
float:left;
|
||||||
display:contents;
|
display:contents;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
fieldset.panel.cmd>div.legend {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
fieldset.panel.cmd>div.output>fieldset.plugin {
|
fieldset.panel.cmd>div.output>fieldset.plugin {
|
||||||
margin:0; padding:0;
|
margin:0; padding:0;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
var figure = can.onfigure[value.shape]
|
var figure = can.onfigure[value.shape]
|
||||||
var data = figure.draw(event, can, value.point, value.style)
|
var data = figure.draw(event, can, value.point, value.style)
|
||||||
can.core.Item(value.style, function(key, value) { data[key] = value })
|
can.core.Item(value.style, function(key, value) { data[key] = value })
|
||||||
var item = can.onfigure._push(can, value.shape, data, can.group||can.svg)
|
var item = can.onfigure._push(can, figure.data.name||value.shape, data, can.group||can.svg)
|
||||||
can.core.ItemCB(value, function(key, cb) { item[key] = cb })
|
can.core.ItemCB(value, function(key, cb) { item[key] = cb })
|
||||||
can.onimport._block(can, item), can.onfigure._pid(can, item)
|
can.onimport._block(can, item), can.onfigure._pid(can, item)
|
||||||
return value._init && value._init(item), item
|
return value._init && value._init(item), item
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
Volcanos("onfigure", {help: "图形绘制", list: [],
|
Volcanos("onfigure", {help: "图形绘制", list: [],
|
||||||
path: { // <path d="M10 10 H 90 V 90 H 10 Z"/>
|
path2v: { // <path d="M x0,y0 Q x2,y2 x3,y3 T x1,y1"/>
|
||||||
|
data: {name: "path", size: {}, copy: []},
|
||||||
|
draw: function(event, can, point) {
|
||||||
|
function line(p0, p1) { return can.base.joins([
|
||||||
|
svg.M, [p0.x, p0.y], svg.Q, [p0.x, p0.y+(p1.y-p0.y)/3], [(p0.x+p1.x)/2, (p0.y+p1.y)/2], svg.T, [p1.x, p1.y]
|
||||||
|
]) }
|
||||||
|
return {fill: html.NONE, d: line(point[0], point[1])}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
path2h: { // <path d="M x0,y0 Q x2,y2 x3,y3 T x1,y1"/>
|
||||||
|
data: {name: "path", size: {}, copy: []},
|
||||||
|
draw: function(event, can, point) {
|
||||||
|
function line(p0, p1) { return can.base.joins([
|
||||||
|
svg.M, [p0.x, p0.y], svg.Q, [p0.x+(p1.x-p0.x)/3, p0.y], [(p0.x+p1.x)/2, (p0.y+p1.y)/2], svg.T, [p1.x, p1.y]
|
||||||
|
]) }
|
||||||
|
return {fill: html.NONE, d: line(point[0], point[1])}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
path: { // <path d="M10 10 H 90 V 90 H 10 Z"/>
|
||||||
data: {size: {}, copy: ["d", "tt", "xx", "yy"],
|
data: {size: {}, copy: ["d", "tt", "xx", "yy"],
|
||||||
x: function(can, value, cmd, target) {
|
x: function(can, value, cmd, target) {
|
||||||
var tt = JSON.parse(target.Value("tt")||'{"tx":0, "ty":0}')
|
var tt = JSON.parse(target.Value("tt")||'{"tx":0, "ty":0}')
|
||||||
|
@ -2,16 +2,17 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||||
if (msg.Option("branch")) { return can.onappend.table(can, msg) }
|
if (msg.Option("branch")) { return can.onappend.table(can, msg) }
|
||||||
|
|
||||||
can._tree = can.onimport._tree(can, msg.Table(), nfs.PATH, ice.PS)
|
can._args = can.base.Copy({root: "root", field: nfs.PATH, split: ice.PS}, can.base.ParseURL(can._display))
|
||||||
|
can._tree = can.onimport._tree(can, msg.Table(), can._args.field, can._args.split)
|
||||||
if (!can._tree[""]) { return }
|
if (!can._tree[""]) { return }
|
||||||
can.dir_root = msg.Option(nfs.DIR_ROOT)
|
can.dir_root = msg.Option(nfs.DIR_ROOT)||can._args.root
|
||||||
can._tree[""].name = can.dir_root.split(ice.PS).slice(-2)[0]
|
can._tree[""].name = can.dir_root.split(can._args.split).slice(-2)[0]
|
||||||
|
|
||||||
can.size = 30, can.margin = 30
|
can.size = 30, can.margin = 30
|
||||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||||
can.page.ClassList.add(can, can._fields, "draw")
|
can.page.ClassList.add(can, can._fields, "draw")
|
||||||
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
||||||
var p = can.Action("view", can.sup.view||can.Action("view"))
|
var p = can.Action(ice.VIEW, can.sup.view||can.Action(ice.VIEW))
|
||||||
can.onaction[p](event, can, p)
|
can.onaction[p](event, can, p)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -19,136 +20,104 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
|||||||
_tree: function(can, list, field, split) {
|
_tree: function(can, list, field, split) {
|
||||||
var node = {}; can.core.List(list, function(item) {
|
var node = {}; can.core.List(list, function(item) {
|
||||||
item[field] && can.core.List(item[field].split(split), function(value, index, array) {
|
item[field] && can.core.List(item[field].split(split), function(value, index, array) {
|
||||||
var last = array.slice(0, index).join(split) || "", name = array.slice(0, index+1).join(split)
|
var last = array.slice(0, index).join(split)||"", name = array.slice(0, index+1).join(split)
|
||||||
if (!value || node[name]) { return }
|
if (!value || node[name]) { return }
|
||||||
|
|
||||||
node[last] = node[last]||{name: last, meta: {}, list: []}
|
node[last] = node[last]||{name: last, meta: {}, list: []}
|
||||||
node[last].list.push(node[name] = {
|
node[last].list.push(node[name] = {
|
||||||
name: value+(index==array.length-1? "": split),
|
name: value+(index==array.length-1? "": split),
|
||||||
meta: item, list: [], last: last,
|
meta: item, list: [], last: last,
|
||||||
file: item[field], hide: true,
|
file: item[field]||item.file, hide: true,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return node
|
return node
|
||||||
},
|
},
|
||||||
_height: function(can, tree) { if (!tree) { return 0 }
|
_height: function(can, tree, deep) { if (!tree) { return 0 }
|
||||||
|
tree.deep = deep||0
|
||||||
if (tree.list.length == 0 || tree.hide) { return tree.height = 1 }
|
if (tree.list.length == 0 || tree.hide) { return tree.height = 1 }
|
||||||
|
|
||||||
var height = 0; can.core.List(tree.list, function(item) {
|
var height = 0; can.core.List(tree.list, function(item) {
|
||||||
height += can.onimport._height(can, item)
|
height += can.onimport._height(can, item, (deep||0)+1)
|
||||||
})
|
})
|
||||||
return tree.height = height
|
return tree.height = height
|
||||||
},
|
},
|
||||||
_width: function(can, tree) { if (!tree) { return 0 }
|
_width: function(can, tree, deep) { if (!tree) { return 0 }
|
||||||
|
tree.deep = deep||0
|
||||||
if (tree.list.length == 0 || tree.hide) {
|
if (tree.list.length == 0 || tree.hide) {
|
||||||
tree.view = can.onimport.draw({}, can, {
|
tree.view = can.onimport.draw({}, can, {shape: html.TEXT, point: [{x: 0, y: 0}], style: {inner: tree.name}})
|
||||||
shape: "text", point: [{x: 0, y: 0}], style: {
|
|
||||||
"stroke-width": 1, "text-anchor": "middle", inner: tree.name,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return tree.width = tree.view.Val("textLength")+can.margin
|
return tree.width = tree.view.Val("textLength")+can.margin
|
||||||
}
|
}
|
||||||
|
|
||||||
var width = 0; can.core.List(tree.list, function(item) {
|
var width = 0; can.core.List(tree.list, function(item) {
|
||||||
width += can.onimport._width(can, item)
|
width += can.onimport._width(can, item, (deep||0)+1)
|
||||||
})
|
})
|
||||||
return tree.width = width
|
return tree.width = width
|
||||||
},
|
},
|
||||||
|
_color: function(can, tree) {
|
||||||
|
return tree.meta&&tree.meta.color || (tree.list == 0? cli.PURPLE: cli.YELLOW)
|
||||||
|
},
|
||||||
}, [""])
|
}, [""])
|
||||||
Volcanos("onaction", {help: "用户操作", list: ["编辑", ["view", "横向", "纵向"]],
|
Volcanos("onaction", {help: "用户操作", list: ["编辑", [ice.VIEW, "横向", "纵向"]],
|
||||||
"编辑": function(event, can) {
|
"编辑": function(event, can) {
|
||||||
can.onmotion.toggle(can, can._action)
|
can.onmotion.toggle(can, can._action)
|
||||||
can.onmotion.toggle(can, can._status)
|
can.onmotion.toggle(can, can._status)
|
||||||
},
|
},
|
||||||
"横向": function(event, can, button) {
|
"横向": function(event, can) {
|
||||||
can.sup.view = button
|
|
||||||
can.onmotion.clear(can, can.svg)
|
|
||||||
can.onimport._height(can, can._tree[""])
|
can.onimport._height(can, can._tree[""])
|
||||||
|
can.sup.view = "横向", can.onmotion.clear(can, can.svg)
|
||||||
|
|
||||||
can.svg.Val(chat.HEIGHT, can._tree[""].height*can.size+2*can.margin)
|
can.svg.Val(chat.HEIGHT, can._tree[""].height*can.size+2*can.margin)
|
||||||
can.width = 0, can.onaction._draw(can, can._tree[""], can.margin, can.margin)
|
can.width = 0, can.onaction._draw(can, can._tree[""], can.margin, can.margin)
|
||||||
can.svg.Val(chat.WIDTH, can.width+can.margin)
|
can.svg.Val(chat.WIDTH, can.width+can.margin)
|
||||||
},
|
},
|
||||||
"纵向": function(event, can, button) {
|
"纵向": function(event, can) {
|
||||||
can.sup.view = button
|
|
||||||
can.onimport._width(can, can._tree[""])
|
can.onimport._width(can, can._tree[""])
|
||||||
can.onmotion.clear(can, can.svg)
|
can.sup.view = "纵向", can.onmotion.clear(can, can.svg)
|
||||||
|
|
||||||
can.svg.Val(chat.WIDTH, can._tree[""].width+2*can.margin)
|
can.svg.Val(chat.WIDTH, can._tree[""].width+2*can.margin)
|
||||||
can.svg.Value("font-family", "monospace")
|
|
||||||
can.height = 0, can.onaction._draw_vertical(can, can._tree[""], can.margin, can.margin+can.size)
|
can.height = 0, can.onaction._draw_vertical(can, can._tree[""], can.margin, can.margin+can.size)
|
||||||
can.svg.Val(chat.HEIGHT, can.height+can.margin)
|
can.svg.Val(chat.HEIGHT, can.height+can.margin)
|
||||||
},
|
},
|
||||||
_draw_vertical: function(can, tree, x, y) { tree.x = x, tree.y = y
|
_draw_vertical: function(can, tree, x, y) { tree.x = x, tree.y = y
|
||||||
var color = tree.meta&&tree.meta.color||cli.YELLOW
|
var color = can.onimport._color(can, tree)
|
||||||
tree.view = can.onimport.draw({}, can, {
|
tree.view = can.onimport.draw({}, can, {
|
||||||
shape: "text", point: [
|
shape: html.TEXT, point: [{x: x+tree.width/2, y: y}], style: {
|
||||||
{x: x+tree.width/2, y: y}
|
stroke: color, fill: color, "text-anchor": "middle", inner: tree.name,
|
||||||
], style: {
|
|
||||||
"stroke-width": 1, "stroke": color,
|
|
||||||
"fill": color, "text-anchor": "middle", inner: tree.name,
|
|
||||||
},
|
},
|
||||||
})
|
}), can.core.ItemCB(can.ondetail, tree.view, can, tree)
|
||||||
|
|
||||||
can.core.ItemCB(can.ondetail, function(key, cb) {
|
|
||||||
tree.view[key] = function(event) { cb(event, can, tree) }
|
|
||||||
})
|
|
||||||
tree.height = can.size
|
tree.height = can.size
|
||||||
if (y+tree.height > can.height) { can.height = y+tree.height }
|
if (y+tree.height > can.height) { can.height = y+tree.height }
|
||||||
if (tree.hide) { return }
|
if (tree.hide) { return }
|
||||||
|
|
||||||
function line(p0, p1) {
|
|
||||||
return "M "+p0.x+","+p0.y+" Q "+p0.x+","+(p0.y+(p1.y-p0.y)/3)+" "+(p0.x+p1.x)/2+","+(p0.y+p1.y)/2+" T "+p1.x+","+p1.y
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset = 0; can.core.List(tree.list, function(item) {
|
var offset = 0; can.core.List(tree.list, function(item) {
|
||||||
can.onimport.draw({}, can, {
|
can.onimport.draw({}, can, {shape: "path2v", point: [
|
||||||
shape: "path", point: [], style: {
|
{x: x+tree.width/2, y: y+tree.height-can.margin/2},
|
||||||
"stroke-width": 1, "stroke": cli.CYAN, "fill": html.NONE, d: line(
|
{x: x+offset+item.width/2, y: y+tree.height+can.margin/2},
|
||||||
{x: x+tree.width/2, y: y+tree.height-can.margin/2},
|
], style: {stroke: cli.CYAN}})
|
||||||
{x: x+offset+item.width/2, y: y+tree.height+can.margin/2},
|
|
||||||
),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin)
|
can.onaction._draw_vertical(can, item, x+offset, y+tree.height+can.margin)
|
||||||
offset += item.width
|
offset += item.width
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
_draw: function(can, tree, x, y) { tree.x = x, tree.y = y
|
_draw: function(can, tree, x, y) { tree.x = x, tree.y = y
|
||||||
var color = tree.meta&&tree.meta.color||cli.YELLOW
|
var color = can.onimport._color(can, tree)
|
||||||
tree.view = can.onimport.draw({}, can, {
|
tree.view = can.onimport.draw({}, can, {
|
||||||
shape: "text", point: [
|
shape: html.TEXT, point: [{x: x, y: y+tree.height*can.size/2}], style: {
|
||||||
{x: x, y: y+tree.height*can.size/2}
|
stroke: color, fill: color, "text-anchor": "start", inner: tree.name,
|
||||||
], style: {
|
|
||||||
"stroke-width": 1, "stroke": color,
|
|
||||||
"fill": color, "text-anchor": "start", inner: tree.name,
|
|
||||||
},
|
},
|
||||||
})
|
}), can.core.ItemCB(can.ondetail, tree.view, can, tree)
|
||||||
|
|
||||||
tree.width = tree.view.Val("textLength")
|
tree.width = tree.view.Val("textLength")
|
||||||
if (x+tree.width > can.width) { can.width = x+tree.width }
|
if (x+tree.width > can.width) { can.width = x+tree.width }
|
||||||
|
|
||||||
can.core.ItemCB(can.ondetail, function(key, cb) {
|
|
||||||
tree.view[key] = function(event) { cb(event, can, tree) }
|
|
||||||
})
|
|
||||||
if (tree.hide) { return }
|
if (tree.hide) { return }
|
||||||
|
|
||||||
function line(p0, p1) {
|
|
||||||
return "M "+p0.x+","+p0.y+" Q "+(p0.x+(p1.x-p0.x)/3)+","+p0.y+" "+(p0.x+p1.x)/2+","+(p0.y+p1.y)/2+" T "+p1.x+","+p1.y
|
|
||||||
}
|
|
||||||
|
|
||||||
var offset = 0; can.core.List(tree.list, function(item) {
|
var offset = 0; can.core.List(tree.list, function(item) {
|
||||||
can.onimport.draw({}, can, {
|
can.onimport.draw({}, can, {shape: "path2h", point: [
|
||||||
shape: "path", point: [], style: {
|
{x: x+tree.width+can.margin/8, y: y+tree.height*can.size/2},
|
||||||
"stroke-width": 1, "stroke": cli.CYAN, "fill": html.NONE, d: line(
|
{x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.size/2}
|
||||||
{x: x+tree.width+can.margin/8, y: y+tree.height*can.size/2},
|
], style: {stroke: cli.CYAN}})
|
||||||
{x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.size/2}
|
|
||||||
),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
can.onaction._draw(can, item, x+tree.width+2*can.margin, y+offset)
|
can.onaction._draw(can, item, x+tree.width+2*can.margin, y+offset)
|
||||||
offset += item.height*can.size
|
offset += item.height*can.size
|
||||||
@ -158,63 +127,62 @@ Volcanos("onaction", {help: "用户操作", list: ["编辑", ["view", "横向",
|
|||||||
Volcanos("ondetail", {help: "用户交互", list: [],
|
Volcanos("ondetail", {help: "用户交互", list: [],
|
||||||
onmouseenter: function(event, can, tree) { var y = tree.y+tree.height*can.size/2
|
onmouseenter: function(event, can, tree) { var y = tree.y+tree.height*can.size/2
|
||||||
can.page.Remove(can, can.pos), can.pos = can.onimport.draw({}, can, {
|
can.page.Remove(can, can.pos), can.pos = can.onimport.draw({}, can, {
|
||||||
shape: "rect", point: [
|
shape: html.RECT, point: [
|
||||||
{x: tree.x-can.margin/4, y: y-can.size/2},
|
{x: tree.x-can.margin/4, y: y-can.size/2},
|
||||||
{x: tree.x+tree.width+can.margin/8, y: y+can.size/2},
|
{x: tree.x+tree.width+can.margin/8, y: y+can.size/2},
|
||||||
], style: {
|
], style: {stroke: cli.RED, fill: html.NONE},
|
||||||
"stroke": cli.RED, "stroke-width": 2, "fill": html.NONE,
|
|
||||||
},
|
|
||||||
}), event.stopPropagation(), event.preventDefault()
|
}), event.stopPropagation(), event.preventDefault()
|
||||||
},
|
},
|
||||||
onclick: function(event, can, tree) {
|
onclick: function(event, can, tree) {
|
||||||
if (tree.name.endsWith(ice.PS) || tree.tags) {
|
if (tree.list.length > 0 || tree.tags || tree.name.endsWith(can._args.split)) {
|
||||||
tree.hide = !tree.hide, can.onaction[can.Action("view")](event, can)
|
return tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tree.name.endsWith(".go") || tree.name.endsWith(".c") || tree.name.endsWith(".h")) {
|
can.run(event, (can._args.prefix? [can._args.prefix]: []).concat([can.Option(kit.MDB_NAME)||"", tree.file||"", tree.name]), function(msg) {
|
||||||
can.run(event, [can.Option(kit.MDB_NAME), tree.file], function(msg) {
|
if (msg.Length() == 0) {
|
||||||
msg.Table(function(value) { tree.tags = true
|
return can.ondetail.plugin(can, "web.code.inner", [can.dir_root, tree.file, tree.line], [ctx.ACTION, "inner"])
|
||||||
tree.list.push({type: "tags", file: value.file, line: value.line, name: value.name, last: tree, list: []})
|
}
|
||||||
})
|
if (msg.Append(kit.MDB_INDEX)) { msg.Table(function(value) {
|
||||||
|
can.ondetail.plugin(can, value.index, [], [ctx.ACTION, ice.RUN, value.index])
|
||||||
|
}); return }
|
||||||
|
|
||||||
tree.hide = !tree.hide, can.onaction[can.Action("view")](event, can)
|
msg.Table(function(value) { tree.tags = true
|
||||||
}, true)
|
tree.list.push({type: "tags", file: value.file, line: value.line, name: value.name, last: tree, list: []})
|
||||||
return
|
}), tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||||
}
|
}, true)
|
||||||
|
|
||||||
can.ondetail.plugin(event, can, [can.dir_root, tree.file, tree.line])
|
|
||||||
},
|
},
|
||||||
|
|
||||||
plugin: function(event, can, args) {
|
plugin: function(can, index, args, prefix) {
|
||||||
can.onappend.plugin(can, {type: chat.FLOAT, index: "web.code.inner", args: args, _action: [cli.CLOSE]}, function(sub) {
|
can.onappend.plugin(can, {type: chat.FLOAT, index: index, args: args}, function(sub) {
|
||||||
sub.run = function(event, cmds, cb) {
|
sub.run = function(event, cmds, cb) {
|
||||||
can.run(event, can.misc.Concat([ctx.ACTION, "inner"], cmds), function(msg) {
|
can.run(event, can.misc.Concat(prefix, cmds), function(msg) {
|
||||||
msg.Option(ice.MSG_ACTION, cli.CLOSE)
|
can.ondetail.figure(can, sub, msg, cb)
|
||||||
can.get("Action", "size", function(left, top, width, height) { left = left||0
|
|
||||||
if (height > window.innerHeight) { height = window.innerHeight }
|
|
||||||
var top = 120, margin = 20; if (can.user.isMobile) { margin = 0
|
|
||||||
if (can.user.isLandscape()) {
|
|
||||||
height += (can.user.mod.isCmd? -20: 200)
|
|
||||||
top = 24, sub.Conf(chat.HEIGHT, height-top)
|
|
||||||
} else {
|
|
||||||
height += (can.user.mod.isCmd? -80: 200)
|
|
||||||
top = 48, sub.Conf(chat.HEIGHT, height-top)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
height += (can.user.mod.isCmd? 0: 300)
|
|
||||||
sub.Conf(chat.HEIGHT, height-top)
|
|
||||||
}
|
|
||||||
|
|
||||||
var layout = {position: "fixed", left: left+margin, top: top}
|
|
||||||
can.onmotion.move(can, sub._target, layout)
|
|
||||||
can.page.Modify(can, sub._target, {style: layout})
|
|
||||||
can.page.Modify(can, sub._output, {style: {"max-width": width-margin*2}})
|
|
||||||
can.base.isFunc(cb) && cb(msg)
|
|
||||||
})
|
|
||||||
}, true)
|
}, true)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
figure: function(can, sub, msg, cb) {
|
||||||
|
can.get("Action", "size", function(left, top, width, height) { left = left||0
|
||||||
|
if (height > window.innerHeight) { height = window.innerHeight }
|
||||||
|
var top = 120, margin = 20; if (can.user.isMobile) { margin = 0
|
||||||
|
if (can.user.isLandscape()) {
|
||||||
|
height += (can.user.mod.isCmd? -20: 200)
|
||||||
|
top = 24, sub.Conf(chat.HEIGHT, height-top)
|
||||||
|
} else {
|
||||||
|
height += (can.user.mod.isCmd? -80: 200)
|
||||||
|
top = 48, sub.Conf(chat.HEIGHT, height-top)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
height += (can.user.mod.isCmd? 0: 300)
|
||||||
|
sub.Conf(chat.HEIGHT, height-top)
|
||||||
|
}
|
||||||
|
|
||||||
|
var layout = {position: "fixed", left: left+margin, top: top}
|
||||||
|
can.onmotion.move(can, sub._target, layout)
|
||||||
|
can.page.Modify(can, sub._target, {style: layout})
|
||||||
|
can.page.Modify(can, sub._output, {style: {"max-width": width-margin*2}})
|
||||||
|
can.base.isFunc(cb) && cb(msg)
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
17
proto.js
17
proto.js
@ -24,7 +24,7 @@ var ice = {
|
|||||||
|
|
||||||
TRUE: "true", SUCCESS: "success", FAILURE: "failure", PROCESS: "process",
|
TRUE: "true", SUCCESS: "success", FAILURE: "failure", PROCESS: "process",
|
||||||
|
|
||||||
AUTO: "auto",
|
AUTO: "auto", VIEW: "view",
|
||||||
COPY: "copy", SHOW: "show", HIDE: "hide", MODE: "mode", SHIP: "ship",
|
COPY: "copy", SHOW: "show", HIDE: "hide", MODE: "mode", SHIP: "ship",
|
||||||
|
|
||||||
MSG_USERNAME: "user.name",
|
MSG_USERNAME: "user.name",
|
||||||
@ -60,7 +60,7 @@ var cli = {
|
|||||||
CLEAR: "clear", REFRESH: "refresh",
|
CLEAR: "clear", REFRESH: "refresh",
|
||||||
|
|
||||||
RED: "red", GREEN: "green", BLUE: "blue",
|
RED: "red", GREEN: "green", BLUE: "blue",
|
||||||
YELLOW: "yellow", CYAN: "cyan", PURPLE: "purple",
|
YELLOW: "yellow", CYAN: "cyan", PURPLE: "purple", MAGENTA: "magenta",
|
||||||
WHITE: "white", BLACK: "black",
|
WHITE: "white", BLACK: "black",
|
||||||
}
|
}
|
||||||
var web = {
|
var web = {
|
||||||
@ -130,6 +130,9 @@ var mall = {
|
|||||||
ASSET: "asset", SALARY: "salary",
|
ASSET: "asset", SALARY: "salary",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var svg = {
|
||||||
|
M: "M", Q: "Q", T: "T",
|
||||||
|
}
|
||||||
var html = {
|
var html = {
|
||||||
FIELDSET: "fieldset", LEGEND: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status",
|
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",
|
FORM_OPTION: "form.option", DIV_ACTION: "div.action", DIV_OUTPUT: "div.output", DIV_STATUS: "div.status",
|
||||||
@ -140,7 +143,7 @@ var html = {
|
|||||||
|
|
||||||
TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br",
|
TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br",
|
||||||
DIV: "div", IMG: "img", CODE: "code", SPAN: "span", VIDEO: "video",
|
DIV: "div", IMG: "img", CODE: "code", SPAN: "span", VIDEO: "video",
|
||||||
SVG: "svg", G: "g", X: "x", Y: "y", R: "r",
|
SVG: "svg", G: "g", X: "x", Y: "y", R: "r", RECT: "rect",
|
||||||
LABEL: "label", INNER: "inner",
|
LABEL: "label", INNER: "inner",
|
||||||
|
|
||||||
CLASS: "class", BLOCK: "block", NONE: "none",
|
CLASS: "class", BLOCK: "block", NONE: "none",
|
||||||
@ -202,12 +205,12 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!libs[0]) { return can.require(libs.slice(1), cb, each) }
|
if (!libs[0]) { return can.require(libs.slice(1), cb, each) }
|
||||||
|
|
||||||
libs[0] = libs[0].toLowerCase()
|
libs[0] = libs[0].toLowerCase()
|
||||||
|
|
||||||
// 请求模块
|
// 请求模块
|
||||||
function next() { can._load(libs[0], each), can.require(libs.slice(1), cb, each) }
|
var name = libs[0].split("?")[0]
|
||||||
meta.cache[libs[0]]? next(): meta._load(libs[0], next)
|
function next() { can._load(name, each), can.require(libs.slice(1), cb, each) }
|
||||||
|
meta.cache[name]? next(): (_can_path = libs[0], meta._load(name, next))
|
||||||
},
|
},
|
||||||
request: function(event, option) { event = event||{}
|
request: function(event, option) { event = event||{}
|
||||||
var msg = event._msg||can.misc.Message(event, can); event._msg = msg
|
var msg = event._msg||can.misc.Message(event, can); event._msg = msg
|
||||||
@ -260,7 +263,7 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args:
|
|||||||
}
|
}
|
||||||
return can.require(libs, cb), can
|
return can.require(libs, cb), can
|
||||||
})
|
})
|
||||||
Volcanos.meta._load = function(url, cb) { _can_path = url
|
Volcanos.meta._load = function(url, cb) {
|
||||||
switch (url.split("?")[0].split(ice.PT).pop().toLowerCase()) {
|
switch (url.split("?")[0].split(ice.PT).pop().toLowerCase()) {
|
||||||
case "css":
|
case "css":
|
||||||
var item = document.createElement(kit.MDB_LINK)
|
var item = document.createElement(kit.MDB_LINK)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user