mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt draw.js
This commit is contained in:
parent
1e42313ffc
commit
636c1d7fc9
9
frame.js
9
frame.js
@ -259,9 +259,9 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", list: [], _init: function(can, me
|
||||
}
|
||||
|
||||
return can.run(event, cmds, function(msg) { var sub = can.core.Value(can, chat._OUTPUTS_CURRENT)||{}
|
||||
if (!cmds || cmds[0] != ctx.ACTION) { can._msg = msg, sub._msg = msg }
|
||||
if (!cmds || cmds[0] != ctx.ACTION) { can._msg = msg, sub._msg = msg, msg._cmds = cmds }
|
||||
if (can.base.isFunc(cb)) { can.core.CallFunc(cb, {can: can, msg: msg}); return }
|
||||
var process = msg._can == can || msg._can == sub; msg._cmds = cmds
|
||||
var process = msg._can == can || msg._can == sub
|
||||
if (process && can.core.CallFunc([sub, chat.ONIMPORT, ice.MSG_PROCESS], {can: sub, msg: msg})) { return }
|
||||
if (process && can.core.CallFunc([can, chat.ONIMPORT, ice.MSG_PROCESS], {can: can, msg: msg})) { return }
|
||||
!silent && can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY)||meta.display||meta.feature.display, can._output, can._action)
|
||||
@ -278,7 +278,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", list: [], _init: function(can, me
|
||||
return can.Update(event, can.Input(cmds, silent), cb, silent)
|
||||
}, can._outputs && can._outputs.push(table), table.sup = can, table._msg = msg
|
||||
|
||||
table.Conf(table._args = can.base.ParseURL(table._display))
|
||||
table._mode = can._mode, table.Conf(table._args = can.base.ParseURL(table._display))
|
||||
table._trans = can.base.Copy(table._trans||{}, can.core.Value(table, "onaction._trans"))
|
||||
if (table.onimport && can.base.isArray(table.onimport.list) && table.onimport.list.length > 0) {
|
||||
can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: table.onimport.list})
|
||||
@ -607,8 +607,11 @@ Volcanos(chat.ONMOTION, {help: "动态特效", list: [], _init: function(can, ta
|
||||
|
||||
hidden: function(can, target, show) {
|
||||
can.page.styleDisplay(can, target||can._target, show? "": html.NONE)
|
||||
return show
|
||||
},
|
||||
toggle: function(can, target, show, hide) { target = target||can._target
|
||||
if (show === true) { return can.onmotion.hidden(can, target, true) }
|
||||
if (show === false) { return can.onmotion.hidden(can, target, false) }
|
||||
var status = target.style.display == html.NONE
|
||||
if (!(status? can.base.isFunc(show) && show(): can.base.isFunc(hide) && hide())) {
|
||||
can.page.styleDisplay(can, target, status? "": html.NONE)
|
||||
|
@ -165,6 +165,9 @@ Volcanos("page", {help: "用户界面", ClassList: {
|
||||
}
|
||||
|
||||
// 语言转换
|
||||
if (type == html.SELECT) {
|
||||
data.title = can.user.trans(can, data.title||data.name)
|
||||
}
|
||||
if (type == html.INPUT) { data.type == html.BUTTON && (data.value = can.user.trans(can, data.value))
|
||||
if (data.type == html.TEXT||data.type == html.PASSWORD||!data.type) { data.autocomplete = data.autocomplete||"off"
|
||||
// data.placeholder = can.user.trans(can, (data.placeholder||data.name||"").split(ice.PT).pop())
|
||||
|
@ -6,8 +6,8 @@ select { background-color:black; color:cyan; padding:0 10px; height:1.92rem; }
|
||||
textarea { background-color:cyan; height:60px; width:400px; }
|
||||
input[type=button] { background-color:black; color:cyan; }
|
||||
input[name=cmd] { background-color:black; color:white; width:240px; }
|
||||
input[type=text] { background-color:cyan; color:black; padding:0 4px; height:1.65rem; width:82px; }
|
||||
input[type=password] { background-color:cyan; color:black; padding:0 4px; height:1.65rem; width:82px; }
|
||||
input[type=text] { background-color:cyan; color:black; padding:0 4px; height:27px; width:90px; }
|
||||
input[type=password] { background-color:cyan; color:black; padding:0 4px; height:27px; width:90px; }
|
||||
input[name=where] { width:320px; }
|
||||
input[name=date] { width:150px; }
|
||||
input[name=path] { width:160px; }
|
||||
|
@ -47,6 +47,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
sub.ConfHeight(can.ConfHeight()-can.Conf(html.MARGIN_Y))
|
||||
can.page.style(can, sub._output, html.MAX_WIDTH, can.ConfWidth())
|
||||
can.user.title(meta.name), skip || next()
|
||||
sub._mode = can._mode
|
||||
})
|
||||
},
|
||||
height: function(can, height) {
|
||||
@ -210,6 +211,7 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [], _init: function(can, cb
|
||||
can.page.ClassList.add(can, can._root._target, "simple")
|
||||
can.page.ClassList.add(can, can._target, "cmd")
|
||||
can.onlayout._init(can)
|
||||
can._mode = "cmd"
|
||||
},
|
||||
|
||||
layout: function(can, button, silent) { button = button||ice.AUTO
|
||||
|
@ -73,7 +73,7 @@ Volcanos(chat.ONACTION, {help: "控件交互", list: [], _init: function(can, cb
|
||||
can.run({}, [], function(msg) { if (msg.Option(ice.MSG_RIVER) == "_share") { return }
|
||||
can.onimport._init(can, msg, null, can._output), can.onappend._action(can, can.Conf(ctx.ACTION))
|
||||
if (can.user.mod.isPod ||can.user.isExtension || can.user.isMobile) { return }
|
||||
can.onmotion.hidden(can, can._target, true)
|
||||
can.onmotion.toggle(can, can._target, true)
|
||||
})
|
||||
},
|
||||
onsearch: function(can, msg, word) {
|
||||
|
@ -20,7 +20,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
can.onmotion.hidden(can, can._option)
|
||||
can.onmotion.hidden(can, can._action)
|
||||
}
|
||||
if (can.user.mod.isCmd || can.user.mod.isDiv) {
|
||||
if (can._mode == "cmd" || can.user.mod.isDiv) {
|
||||
width = can._root._width, height = can._root._height
|
||||
can.page.style(can, can._output, {width: width, height: height})
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
}))
|
||||
|
||||
can.onengine.listen(can, "orientationchange", function(event) {
|
||||
if (can.user.mod.isCmd) { can.ConfHeight(can._root._height), can.ConfWidth(can._root._width) }
|
||||
if (can._mode == "cmd") { can.ConfHeight(can._root._height), can.ConfWidth(can._root._width) }
|
||||
can.user.toast(can, can.ConfHeight()+"")
|
||||
can.onimport.layout(can)
|
||||
})
|
||||
@ -44,6 +44,12 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
can.ui._path = can.page.insertBefore(can, [{view: "path"}], can.ui.content)
|
||||
can.base.isFunc(cb) && cb(msg)
|
||||
|
||||
can._mode == "float" && can.onmotion.hidden(can, can.ui.project)
|
||||
can._mode == "float" && can.onmotion.hidden(can, can._action)
|
||||
can._mode == "float" && can.onmotion.hidden(can, can._action)
|
||||
can._mode == "float" && can.onmotion.hidden(can, can.ui._tabs)
|
||||
can._mode == "float" && can.onmotion.hidden(can, can.ui._path)
|
||||
|
||||
can.Conf("mode") == "simple"? can.onimport._simple(can): can.onimport.project(can, paths, function() {
|
||||
can.onimport._toolkit(can, can.ui.toolkit), can.onimport._session(can, msg), can.onimport._keydown(can)
|
||||
can.onmotion.delay(can, function() {
|
||||
@ -131,7 +137,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
}) })
|
||||
},
|
||||
_keydown: function(can) { can.onkeymap._build(can)
|
||||
can.user.mod.isCmd && can.onengine.listen(can, chat.ONKEYDOWN, function(event) {
|
||||
can._mode == "cmd" && can.onengine.listen(can, chat.ONKEYDOWN, function(event) {
|
||||
can._key_list = can.onkeymap._parse(event, can, "plugin", can._key_list, can.ui.content)
|
||||
})
|
||||
},
|
||||
@ -189,8 +195,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
}, project.plugin)
|
||||
},
|
||||
tabview: function(can, path, file, line, cb, skip, skip2) { var key = can.onexport.keys(can, file, path)
|
||||
if (can.user.mod.isCmd) { location.hash = file }
|
||||
if (!skip && can.tabview[key]) { can.user.mod.isCmd && can.user.title(path+file)
|
||||
if (can._mode == "cmd") { location.hash = file }
|
||||
if (!skip && can.tabview[key]) { can._mode == "cmd" && can.user.title(path+file)
|
||||
can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.tabview[key]
|
||||
can.Option({path: path, file: file, line: line||can._msg.Option(nfs.LINE)||1})
|
||||
return can._msg.Option(can.Option()), can.onsyntax._init(can, can._msg, cb, skip2)
|
||||
@ -212,13 +218,13 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
profile: function(can, msg) {
|
||||
var width = can.profile_size[can.onexport.keys(can)]||(can.ConfWidth()-can.ui.project.offsetWidth)/2
|
||||
msg && can.onimport.process(can, msg, can.ui.profile_output, width-32)
|
||||
can.onmotion.hidden(can, can.ui.profile, true), can.onimport.layout(can)
|
||||
can.onmotion.toggle(can, can.ui.profile, true), can.onimport.layout(can)
|
||||
},
|
||||
display: function(can, msg) {
|
||||
var height = can.profile_size[can.onexport.keys(can)]||{sh: can.ConfHeight()/2}[can.parse]||can.ConfHeight()/4
|
||||
msg && can.onimport.process(can, msg, can.ui.display_output, can.ConfWidth())
|
||||
can.page.style(can, can.ui.display_output, html.MAX_HEIGHT, height)
|
||||
can.onmotion.hidden(can, can.ui.display, true), can.onimport.layout(can)
|
||||
can.onmotion.toggle(can, can.ui.display, true), can.onimport.layout(can)
|
||||
},
|
||||
toolkit: function(can, meta, cb) {
|
||||
meta.opts = meta.opts||{repos: can.base.trimSuffix(can.base.trimPrefix(can.Option(nfs.PATH), "usr/"), ice.PS) }
|
||||
@ -269,17 +275,17 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
}, target)
|
||||
},
|
||||
layout: function(can) {
|
||||
var width = can.ConfWidth()+(can.user.isMobile && can.user.mod.isCmd && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can.user.mod.isCmd? 20: 0)
|
||||
var width = can.ConfWidth()+(can.user.isMobile && can._mode == "cmd" && can.user.isLandscape()? 16: 0)-(can.user.isWindows && !can._mode == "cmd"? 20: 0)
|
||||
can.page.styleWidth(can, can.ui.profile_output, can.profile_size[can.onexport.keys(can)]||(width-can.ui.project.offsetWidth)/2)
|
||||
can.page.styleWidth(can, can.ui.content, width-can.ui.project.offsetWidth-can.ui.profile.offsetWidth)
|
||||
can.page.styleWidth(can, can.ui.display, width-can.ui.project.offsetWidth)
|
||||
|
||||
if (!height && can.Conf("mode") == "simple") { return }
|
||||
var height = can.ConfHeight()-(can.user.isMobile && can.user.mod.isCmd? (can.user.isLandscape()? 14: 54): 0)-(can.user.isWindows? 20: 0)
|
||||
var height = can.ConfHeight()-(can.user.isMobile && can._mode == "cmd"? (can.user.isLandscape()? 14: 54): 0)-(can.user.isWindows? 20: 0)
|
||||
if (!height || height > can._root._height) { height = can._root._height - 200 }
|
||||
if (can.user.isMobile && can.user.isLandscape() && height < 200) { height = 400 }
|
||||
|
||||
if (can.user.mod.isCmd) { can.page.styleHeight(can, can.ui.project, height+2*html.ACTION_HEIGHT)
|
||||
if (can._mode == "cmd") { can.page.styleHeight(can, can.ui.project, height+2*html.ACTION_HEIGHT)
|
||||
if (can.ui.project.offsetHeight) {
|
||||
var rest = can.ui.display.offsetHeight+can.ui._path.offsetHeight+can.ui._tabs.offsetHeight+5
|
||||
can.page.styleHeight(can, can.ui.content, can.ui.project.offsetHeight-rest)
|
||||
@ -291,7 +297,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
}
|
||||
} else {
|
||||
var rest = can.ui.display.offsetHeight+can.ui._path.offsetHeight+can.ui._tabs.offsetHeight+5
|
||||
can.page.style(can, can.ui.content, can.user.mod.isCmd || can.user.isMobile? html.HEIGHT: html.MAX_HEIGHT, height)
|
||||
can.page.style(can, can.ui.content, can._mode == "cmd" || can.user.isMobile? html.HEIGHT: html.MAX_HEIGHT, height)
|
||||
can.page.styleHeight(can, can.ui.project, can.ui.content.offsetHeight+rest)
|
||||
if (can.page.ClassList.has(can, can._fields, "full")) {
|
||||
can.page.styleHeight(can, can.ui.profile_output, can.ui.content.offsetHeight)
|
||||
@ -417,7 +423,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", list: ["keyword", "prefix", "line
|
||||
p && p.engine && can.onaction["执行"]({}, can)
|
||||
}
|
||||
can.onimport.layout(can)
|
||||
if (!can.page.ClassList.has(can, can._fields, chat.STORY) && !can.user.mod.isCmd) {
|
||||
if (!can.page.ClassList.has(can, can._fields, chat.STORY) && !can._mode == "cmd") {
|
||||
can.page.style(can, can.ui.project, html.MIN_HEIGHT, can.ConfHeight()-200)
|
||||
can.page.style(can, can.ui.content, html.MIN_HEIGHT, can.ConfHeight()-200)
|
||||
}
|
||||
@ -571,7 +577,7 @@ Volcanos(chat.ONACTION, {help: "控件交互", list: ["搜索", "打开", "添
|
||||
can.onmotion.hidden(can, can.ui.project)
|
||||
can.ConfHeight(can._root._height)
|
||||
} else {
|
||||
can.onmotion.hidden(can, can.ui.project, true)
|
||||
can.onmotion.toggle(can, can.ui.project, true)
|
||||
can.ConfHeight(can._root._height-2*html.ACTION_HEIGHT)
|
||||
}
|
||||
can.onimport.layout(can)
|
||||
|
@ -1,35 +1,33 @@
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||
can.onmotion.clear(can), can.onmotion.hidden(can, can._action)
|
||||
can.onimport._show(can, msg), can.base.isFunc(cb) && cb(msg)
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||
can.onimport._show(can, msg), can.onmotion.hidden(can, can._action)
|
||||
can.keylist = [], can.onkeymap._build(can)
|
||||
|
||||
can.onmotion.delay(can, function() {
|
||||
can.core.Item(kit.Dict(
|
||||
html.STROKE_WIDTH, 2, html.STROKE, cli.YELLOW, html.FILL, cli.PURPLE,
|
||||
html.FONT_SIZE, 24, html.FONT_FAMILY, html.MONOSPACE,
|
||||
"go", ice.RUN, svg.SHAPE, svg.RECT, svg.GRID, 10,
|
||||
), function(key, value) { can.svg.Value(key, can.Action(key, can.svg.Value(key)||value)) })
|
||||
|
||||
can.page.style(can, can.ui.display, html.MIN_HEIGHT, 80, html.MAX_HEIGHT, can.ConfHeight()-can.svg.Val(html.HEIGHT)-52)
|
||||
var pid = can.Option(svg.PID)||can.svg.Value(svg.PID); pid && can.page.Select(can, can.svg, ice.PT+pid, function(item) {
|
||||
can.onimport._profile(can, item), can.ondetail.run({target: item}, can)
|
||||
}) || can.onimport._profile(can, can.svg)
|
||||
})
|
||||
},
|
||||
_show: function(can, msg) { can.point = []
|
||||
can.svg = null, can.group = null, can.temp = null, can.current = null
|
||||
|
||||
// 加载图形
|
||||
can.ui = can.onlayout.profile(can), can.onmotion.hidden(can, can.ui.project)
|
||||
can.page.Modify(can, can.ui.content, msg.Result()||can.onexport.content(can))
|
||||
can.page.Select(can, can.ui.content, html.SVG, function(svg) {
|
||||
can.svg = can.group = can.onimport._block(can, svg), can.onimport._group(can, svg).click()
|
||||
can.core.ItemCB(can.onaction, function(key, cb) { svg[key] = function(event) { cb(event, can) } })
|
||||
can.page.Select(can, svg, mdb.FOREACH, function(item, index) { can.onimport._block(can, item)
|
||||
item.tagName == svg.G && item.Value(html.CLASS) && can.onimport._group(can, item)
|
||||
can.page.tagis(svg.G, item) && item.Value(html.CLASS) && can.onimport._group(can, item)
|
||||
})
|
||||
})
|
||||
|
||||
// 默认参数
|
||||
can.onmotion.delay(can, function() {
|
||||
can.core.Item(kit.Dict(
|
||||
html.STROKE_WIDTH, 2, html.STROKE, cli.YELLOW, html.FILL, cli.PURPLE,
|
||||
html.FONT_SIZE, 24, html.FONT_FAMILY, html.MONOSPACE,
|
||||
"go", ice.RUN, svg.SHAPE, svg.RECT, "grid", 10,
|
||||
), function(key, value) { can.svg.Value(key, can.Action(key, can.svg.Value(key)||value)) })
|
||||
|
||||
can.page.style(can, can.ui.display, html.MIN_HEIGHT, 80, html.MAX_HEIGHT, can.ConfHeight()-can.svg.Val(html.HEIGHT)-52)
|
||||
var pid = can.Option(svg.PID)||can.svg.Value(svg.PID); pid && can.page.Select(can, can.svg, ice.PT+pid, function(item) {
|
||||
can.onimport._profile(can, item), can.ondetail.run({target: item}, can)
|
||||
}) || can.onimport._profile(can, can.svg)
|
||||
})
|
||||
},
|
||||
_group: function(can, target) { var name = target.Groups()
|
||||
function show(event) { can.group = target
|
||||
@ -37,10 +35,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
can.Action(key, target.Value(key)||can.Action(key))
|
||||
})
|
||||
}
|
||||
return (name || target == can.svg) && can.onimport.item(can, html.ITEM, {name: name||html.SVG}, function(event) { show(event)
|
||||
can.onaction.show(event, can), can.Status(svg.GROUP, name||html.SVG)
|
||||
return (name || target == can.svg) && can.onimport.item(can, html.ITEM, {name: name||html.SVG}, function(event) {
|
||||
show(event), can.onaction.show(event, can), can.Status(svg.GROUP, name||html.SVG)
|
||||
}, function(event) {
|
||||
can.user.carteRight(event, can, can.onaction, [ice.HIDE, ice.SHOW, mdb.CREATE, cli.CLEAR, mdb.REMOVE])
|
||||
can.user.carteRight(event, can, can.onaction, can.onaction.menu_list)
|
||||
}, can.ui.project)
|
||||
},
|
||||
_block: function(can, target) {
|
||||
@ -101,14 +99,19 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
})
|
||||
}}
|
||||
})) }])
|
||||
|
||||
},
|
||||
draw: function(event, can, value) {
|
||||
draw: function(event, can, value, group) { // {shape, point, style, _init}
|
||||
var figure = can.onfigure[value.shape], data = figure.draw(event, can, value.point, value.style)
|
||||
can.core.Item(value.style, function(key, value) { data[key] = value })
|
||||
var item = can.onfigure._push(can, figure.data.name||value.shape, data, can.group||can.svg)
|
||||
var item = can.onfigure._push(can, figure.data.name||value.shape, data, group||can.svg||can.group)
|
||||
can.core.ItemCB(value, function(key, cb) { item[key] = cb })
|
||||
return can.onimport._block(can, item), can.onfigure._pid(can, item), value._init && value._init(item), item
|
||||
// return can.onimport._block(can, item), can.onfigure._pid(can, item), value._init && value._init(item), item
|
||||
return can.onimport._block(can, item), value._init && value._init(item), item
|
||||
},
|
||||
group: function(can, name, value, group) { group = group||can.svg||can.group
|
||||
var g = document.createElementNS('http://www.w3.org/2000/svg', svg.G); group.append(g)
|
||||
can.onimport._block(can, g), g.Value(html.CLASS, name), can.onimport._group(can, g).click()
|
||||
return value && g.Value(value), g
|
||||
},
|
||||
}, [""])
|
||||
Volcanos(chat.ONFIGURE, {help: "图形绘制", list: [],
|
||||
@ -181,19 +184,6 @@ Volcanos(chat.ONFIGURE, {help: "图形绘制", list: [],
|
||||
},
|
||||
text: function(can, data, target) { return data.x = target.Val(svg.X)+target.Val(html.WIDTH)/2, data.y = target.Val(svg.Y)+target.Val(html.HEIGHT)/2, data },
|
||||
},
|
||||
block: { // <rect height="30" width="30" ry="10" rx="10" x="60" y="10"/>
|
||||
data: {points: 2, ry: 4, rx: 4, size: {}, copy: [html.HEIGHT, html.WIDTH, svg.RY, svg.RX]},
|
||||
draw: function(event, can, point) { if (point.length < 2) { return }
|
||||
this._temp && can.page.Remove(can, this._temp) && delete(this._temp)
|
||||
this._temp = can.onfigure._push(can, svg.G, {}, can.group||can.svg)
|
||||
|
||||
var rect = can.onfigure._push(can, svg.RECT, can.onfigure.rect.draw(event, can, point), this._temp)
|
||||
if (event.type == html.CLICK) {
|
||||
can.onfigure._pid(can, rect), delete(this._temp)
|
||||
}
|
||||
},
|
||||
text: function(can, data, target) { can.onfigure.rect.text(can, data, target) },
|
||||
},
|
||||
line: { // <line x1="10" y1="50" x2="110" y2="150" xx="100" yy="100"/>
|
||||
data: {points: 2, size: {x: svg.X1, y: svg.Y1}, copy: [svg.X1, svg.Y1, svg.X2, svg.Y2]},
|
||||
grid: function(event, can, point) { var target = event.target
|
||||
@ -206,11 +196,24 @@ Volcanos(chat.ONFIGURE, {help: "图形绘制", list: [],
|
||||
var p0 = point[0], p1 = point[1], ship = []
|
||||
p0.target && p0.target.Value && ship.push({pid: p0.target.Value(svg.PID)})
|
||||
p1.target && p1.target.Value && ship.push({pid: p1.target.Value(svg.PID)})
|
||||
return {x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, ship: ship}
|
||||
return {x1: p0.x, y1: p0.y, x2: p1.x, y2: p1.y, ship: ship.length > 0? ship: undefined}
|
||||
},
|
||||
text: function(can, target, data) { return data.x = (target.Val(svg.X1)+target.Val(svg.X2))/2, data.y = (target.Val(svg.Y1)+target.Val(svg.Y2))/2, data },
|
||||
show: function(can, target, figure) { return "<("+(target.Val(svg.Y2)-target.Val(svg.Y1))+ice.FS+(target.Val(svg.X2)-target.Val(svg.X1))+")"+can.onexport._position(can, target, figure) },
|
||||
},
|
||||
block: { // <rect height="30" width="30" ry="10" rx="10" x="60" y="10"/>
|
||||
data: {points: 2, ry: 4, rx: 4, size: {}, copy: [html.HEIGHT, html.WIDTH, svg.RY, svg.RX]},
|
||||
draw: function(event, can, point) { if (point.length < 2) { return }
|
||||
this._temp && can.page.Remove(can, this._temp) && delete(this._temp)
|
||||
this._temp = can.onfigure._push(can, svg.G, {}, can.group||can.svg)
|
||||
|
||||
var rect = can.onfigure._push(can, svg.RECT, can.onfigure.rect.draw(event, can, point), this._temp)
|
||||
if (event.type == html.CLICK) {
|
||||
can.onfigure._pid(can, rect), delete(this._temp)
|
||||
}
|
||||
},
|
||||
text: function(can, data, target) { can.onfigure.rect.text(can, data, target) },
|
||||
},
|
||||
}, [])
|
||||
Volcanos(chat.ONKEYMAP, {help: "键盘交互", list: [],
|
||||
_mode: {
|
||||
@ -256,9 +259,9 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: [
|
||||
|
||||
["go", ice.RUN, ice.AUTO, "manual"],
|
||||
["mode", "draw", "resize"],
|
||||
[svg.SHAPE, svg.TEXT, svg.CIRCLE, svg.ELLIPSE, svg.RECT, svg.BLOCK, svg.LINE],
|
||||
["grid", 1, 2, 3, 4, 5, 10, 20],
|
||||
],
|
||||
[svg.SHAPE, svg.TEXT, svg.CIRCLE, svg.ELLIPSE, svg.RECT, svg.LINE, svg.BLOCK],
|
||||
[svg.GRID, 1, 2, 3, 4, 5, 10, 20],
|
||||
], menu_list: [ice.HIDE, ice.SHOW, mdb.CREATE, cli.CLEAR, mdb.REMOVE],
|
||||
_change: function(can, key, value) { can.Action(key, value), can.group.Value(key, value) },
|
||||
"stroke-width": function(event, can, key, value) { can.onaction._change(can, key, value) },
|
||||
stroke: function(event, can, key, value) { can.onaction._change(can, key, value) },
|
||||
@ -280,10 +283,10 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: [
|
||||
hide: function(event, can) { can.onmotion.hide(can, {interval: 100, length: 10}, null, can.group) },
|
||||
create: function(event, can) {
|
||||
can.user.input(event, can, [svg.GROUP], function(list) { var name = list[0]
|
||||
var group = document.createElementNS('http://www.w3.org/2000/svg', svg.G); can.group.append(group), can.onimport._block(can, group)
|
||||
group.Value(html.CLASS, name), can.core.List([html.STROKE_WIDTH, html.STROKE, html.FILL, html.FONT_SIZE], function(name) {
|
||||
var group = can.onimport.group(can, name)
|
||||
can.core.List([html.STROKE_WIDTH, html.STROKE, html.FILL, html.FONT_SIZE], function(name) {
|
||||
group.Value(name, can.Action(name))
|
||||
}), can.onimport._group(can, group).click()
|
||||
})
|
||||
})
|
||||
},
|
||||
remove: function(event, can) { if (can.group == can.svg) { return }
|
||||
@ -402,7 +405,7 @@ Volcanos(chat.ONDETAIL, {help: "组件详情", list: [cli.START, ice.RUN, ice.CO
|
||||
var index = target.Value(mdb.INDEX); index && can.onappend.plugin(can, {type: chat.STORY, index: index, args: target.Value(ctx.ARGS)}, function(sub) {
|
||||
sub.run = function(event, cmds, cb) { can.runActionCommand(event, index, cmds, cb) }
|
||||
sub.ConfHeight(can.ConfHeight()-can.svg.Val(html.HEIGHT)-4*html.ACTION_HEIGHT), sub.ConfWidth(can.ConfWidth())
|
||||
can.onmotion.hidden(can, sub._legend), can.onmotion.hidden(can, can.ui.display, true)
|
||||
can.onmotion.hidden(can, sub._legend), can.onmotion.toggle(can, can.ui.display, true)
|
||||
}, can.ui.display)
|
||||
},
|
||||
toimage: function(event, can) { can.onmotion.toimage(event, can, can.Option(nfs.PATH).split(ice.PS).pop().split(ice.PT)[0], can.svg) },
|
||||
@ -453,13 +456,13 @@ Volcanos(chat.ONEXPORT, {help: "导出数据", list: [svg.GROUP, "figure", "inde
|
||||
_point: function(event, can) {
|
||||
var p = can.svg.getBoundingClientRect()
|
||||
var point = {x: event.clientX-p.x, y: event.clientY-p.y}
|
||||
point.x = point.x - point.x % parseInt(can.Action("grid"))
|
||||
point.y = point.y - point.y % parseInt(can.Action("grid"))
|
||||
point.x = point.x - point.x % parseInt(can.Action(svg.GRID))
|
||||
point.y = point.y - point.y % parseInt(can.Action(svg.GRID))
|
||||
return can.Status("pos", point.x+ice.FS+point.y), point
|
||||
},
|
||||
content: function(can, svg) {
|
||||
return ['<svg vertion="1.1" xmlns="https://www.w3.org/2000/svg" text-anchor="middle" dominant-baseline="middle"'].concat(
|
||||
svg? can.core.List([html.HEIGHT, html.WIDTH, mdb.COUNT, svg.PID, "grid", html.STROKE_WIDTH, html.STROKE, html.FILL, html.FONT_SIZE], function(item) {
|
||||
svg? can.core.List([html.HEIGHT, html.WIDTH, mdb.COUNT, svg.PID, svg.GRID, html.STROKE_WIDTH, html.STROKE, html.FILL, html.FONT_SIZE], function(item) {
|
||||
return svg.Value(item)? ice.SP + item + '="' + svg.Value(item) + '"': ""
|
||||
}): [" height="+((can.ConfHeight()||450)-50)+" width="+(can.ConfWidth()||600)]).concat(['>', svg? svg.innerHTML: "", "</svg>"]).join("")
|
||||
},
|
||||
|
@ -31,13 +31,13 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
if (can.core.Value(can, list[0])) { return can.core.CallFunc([can, list[0]], list.slice(1)) }
|
||||
if (!link || link == can.Option(nfs.PATH)) { return false }
|
||||
|
||||
if (can.onmotion.cache(can, function() { can.user.mod.isCmd && can.user.title(item.meta.name); return can.Option(nfs.PATH, link) })) { return }
|
||||
if (can.onmotion.cache(can, function() { can._mode == "cmd" && can.user.title(item.meta.name); return can.Option(nfs.PATH, link) })) { return }
|
||||
return can.sup.Update(event, [link])
|
||||
}, nav), can.sup._navmenu = nav
|
||||
|
||||
can.getActionSize(function(msg) {
|
||||
can.page.style(can, nav, html.HEIGHT, can.ConfHeight()+(can.user.mod.isCmd? msg.Option(html.MARGIN_Y): 0))
|
||||
can.ConfWidth(can.ConfWidth()-nav.offsetWidth-(can.user.mod.isCmd? 10: 20)-10)
|
||||
can.page.style(can, nav, html.HEIGHT, can.ConfHeight()+(can._mode == "cmd"? msg.Option(html.MARGIN_Y): 0))
|
||||
can.ConfWidth(can.ConfWidth()-nav.offsetWidth-(can._mode == "cmd"? 10: 20)-10)
|
||||
can.page.style(can, can._output,
|
||||
html.HEIGHT, can.sup._navmenu.offsetHeight, html.MAX_WIDTH, can.ConfWidth(),
|
||||
html.FLOAT, html.LEFT, html.CLEAR, html.NONE
|
||||
@ -52,7 +52,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
})
|
||||
},
|
||||
title: function(can, data, target) {
|
||||
can.user.mod.isCmd && target.tagName == "H1" && can.user.title(data.text)
|
||||
can._mode == "cmd" && target.tagName == "H1" && can.user.title(data.text)
|
||||
},
|
||||
refer: function(can, data, target) {
|
||||
can.page.Select(can, target, html.A, function(item) {
|
||||
@ -126,7 +126,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar
|
||||
field: function(can, data, target, width) { var item = can.base.Obj(data.meta)
|
||||
can.onappend._init(can, item, [chat.PLUGIN_STATE_JS], function(sub) {
|
||||
sub.run = function(event, cmds, cb, silent) {
|
||||
can.runAction(event, chat.STORY, [data.type, data.name, data.text].concat(cmds), cb)
|
||||
can.runAction(event, chat.STORY, can.misc.concat(can, [data.type, data.name, data.text], cmds), cb)
|
||||
}
|
||||
sub.ConfHeight(can.ConfHeight())
|
||||
sub.ConfWidth(item.width = (width||can.ConfWidth())-(can.user.isWindows? 40: 20))
|
||||
|
@ -45,7 +45,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
Volcanos(chat.ONACTION, {help: "组件菜单", list: ["展开", "折叠", "复制"],
|
||||
"展开": function(event, can) {
|
||||
can.page.Select(can, can._output, "div.list div.list", function(list) {
|
||||
can.onmotion.hidden(can, list, true)
|
||||
can.onmotion.toggle(can, list, true)
|
||||
})
|
||||
},
|
||||
"折叠": function(event, can) {
|
||||
|
@ -1,16 +1,18 @@
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, msg, cb, target) {
|
||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||
var color = [cli.RED, cli.YELLOW, cli.GREEN, cli.CYAN, cli.BLUE, cli.PURPLE]
|
||||
var color = ["#3300FF", "#2196F3", "#4CAF50", "#CDDC39", "#FFEB3B", "#9C27B0", "#795548", "#607D8B", "#CC33FF"]
|
||||
var height = msg.Option(html.HEIGHT)||can.ConfHeight()
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||
can.onimport._show(can, msg), can.onmotion.hidden(can, can._action), can.onappend._status(can, [].concat(msg.append, ["weight"]))
|
||||
var color = [cli.RED, cli.YELLOW, cli.GREEN, cli.CYAN, cli.BLUE, cli.PURPLE]
|
||||
var color = ["#3300FF", "#2196F3", "#4CAF50", "#CDDC39", "#FFEB3B", "#9C27B0", "#795548", "#607D8B", "#CC33FF"]
|
||||
var height = msg.Option(html.HEIGHT)||can.ConfHeight()
|
||||
|
||||
can.page.ClassList.add(can, can._fields, "draw")
|
||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||
can.onimport._show(can, msg), can.onappend._status(can, [].concat(msg.append, ["weight"]))
|
||||
var margin = height/8, r = height/2-margin; can.svg.Val(html.WIDTH, 2*(r+margin)), can.svg.Val(html.HEIGHT, 2*(r+margin))
|
||||
can.onimport._draw(can, msg, can.Conf(mdb.FIELD), color, r+margin, r+margin, r, margin, 0)
|
||||
|
||||
can.page.style(can, can.ui.project, html.MAX_WIDTH, can.ConfWidth()-height)
|
||||
can.onmotion.clear(can, can.ui.project), can.onmotion.hidden(can, can.ui.project, true)
|
||||
can.onmotion.clear(can, can.ui.project), can.onmotion.toggle(can, can.ui.project, true)
|
||||
can.onappend.table(can, msg, null, can.ui.project), can.page.Select(can, can.ui.project, html.TR, function(tr, index) {
|
||||
can.page.Modify(can, tr, {onmouseenter: function(event) {
|
||||
can.onimport._draw(can, msg, can.Conf(mdb.FIELD), color, r+margin, r+margin, r, margin, index-1)
|
||||
@ -41,6 +43,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
_parseInt: function(can, value) { value = value.toLowerCase()
|
||||
if (can.base.endWith(value, "mi")) { return parseInt(value)*1000000 }
|
||||
if (can.base.endWith(value, "gi")) { return parseInt(value)*1000000000 }
|
||||
if (can.base.endWith(value, "g")) { return parseInt(value)*1000000000 }
|
||||
if (can.base.endWith(value, "m")) { return parseInt(value)*1000000 }
|
||||
return parseInt(value)
|
||||
}
|
||||
})
|
||||
|
@ -1,25 +1,21 @@
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||
if (msg.Length() == 0) { return }
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg); if (msg.Length() == 0) { return }
|
||||
|
||||
can._args = can.base.Copy({root: "ice", field: msg.append[0], split: ice.PS}, can.base.ParseURL(can._display))
|
||||
can.dir_root = msg.Option(nfs.DIR_ROOT)||can._args.root||""
|
||||
can._tree = can.onimport._tree(can, msg.Table(), can._args.field, can._args.split)
|
||||
if (!can._tree[""]) { return } can._tree[""].name = can._args.root
|
||||
can.ConfDefault({root: "ice", field: msg.append[0], split: ice.PS})
|
||||
can.dir_root = msg.Option(nfs.DIR_ROOT)||can.Conf("root")
|
||||
can._tree = can.onimport._tree(can, msg.Table(), can.Conf(mdb.FIELD), can.Conf(lex.SPLIT))
|
||||
if (!can._tree[""]) { return } can._tree[""].name = can.Conf("root")
|
||||
|
||||
can.size = 30, can.margin = 30
|
||||
can.onmotion.hidden(can, can._action)
|
||||
can.size = parseInt(can.Action("size")||24)
|
||||
can.margin = parseInt(can.Action("margin")||30)
|
||||
can.page.ClassList.add(can, can._fields, "draw")
|
||||
can.require(["/plugin/local/wiki/draw.js", "/plugin/local/wiki/draw/path.js"], function() {
|
||||
can.page.ClassList.add(can, can._fields, "draw")
|
||||
can.onimport._show(can, msg), can.onmotion.hidden(can, can.ui.project)
|
||||
var p = can.Action(ice.VIEW, can.sup.view||can.Action(ice.VIEW))
|
||||
can.onaction[p](event, can, p)
|
||||
can.onimport.layout(can)
|
||||
})
|
||||
},
|
||||
|
||||
_tree: function(can, list, field, split) {
|
||||
var node = {}; can.core.List(list, function(item) { if (!item[field]) { return }
|
||||
can.core.List(can.base.trimPrefix(item[field], can.dir_root+can._args.split).split(split), function(value, index, array) {
|
||||
can.core.List(can.base.trimPrefix(item[field], can.dir_root+split).split(split), function(value, index, array) {
|
||||
var last = array.slice(0, index).join(split)||"", name = array.slice(0, index+1).join(split)
|
||||
if (!value || node[name]) { return }
|
||||
|
||||
@ -57,41 +53,43 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
_color: function(can, tree) {
|
||||
return tree.meta&&tree.meta.color || (tree.list == 0? cli.PURPLE: cli.YELLOW)
|
||||
},
|
||||
layout: function(can) {
|
||||
var p = can.Action(ice.VIEW, can.sup.view||can.Action(ice.VIEW))
|
||||
can.onmotion.clear(can), can.onimport._show(can, can.request())
|
||||
can.svg.Val(html.FONT_SIZE, can.Action("size"))
|
||||
can.onaction[p](event, can, p)
|
||||
},
|
||||
}, [""])
|
||||
Volcanos(chat.ONACTION, {help: "用户操作", list: ["edit", [ice.VIEW, "横向", "纵向"], "生成图片"],
|
||||
"edit": function(event, can) { can.onmotion.toggle(can, can._action), can.onmotion.toggle(can, can._status) },
|
||||
|
||||
"横向": function(event, can) {
|
||||
Volcanos(chat.ONACTION, {help: "用户操作", list: [
|
||||
[ice.VIEW, "横向", "纵向"], ["size", 24, 32, 48], ["margin", 30, 50, 100],
|
||||
],
|
||||
size: function(event, can) { can.size = parseInt(can.Action("size")||30), can.onimport.layout(can) },
|
||||
margin: function(event, can) { can.margin = parseInt(can.Action("margin")||30), can.onimport.layout(can) },
|
||||
"横向": function(event, can, button) {
|
||||
can.onimport._height(can, can._tree[""])
|
||||
can.sup.view = "横向", can.onmotion.clear(can, can.svg)
|
||||
can.sup.view = button, can.onmotion.clear(can, can.svg)
|
||||
|
||||
can.svg.Val(html.HEIGHT, can._tree[""].height*can.size+2*can.margin)
|
||||
can.svg.Val(html.HEIGHT, can._tree[""].height*can.margin+2*can.margin)
|
||||
can.width = 0, can.onaction._draw_horizontal(can, can._tree[""], can.margin, can.margin)
|
||||
can.svg.Val(html.WIDTH, can.width+can.margin)
|
||||
},
|
||||
"纵向": function(event, can) {
|
||||
"纵向": function(event, can, button) {
|
||||
can.onimport._width(can, can._tree[""])
|
||||
can.sup.view = "纵向", can.onmotion.clear(can, can.svg)
|
||||
can.sup.view = button, can.onmotion.clear(can, can.svg)
|
||||
|
||||
can.svg.Val(html.WIDTH, can._tree[""].width+2*can.margin)
|
||||
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.margin)
|
||||
can.svg.Val(html.HEIGHT, can.height+can.margin)
|
||||
},
|
||||
"生成图片": function(event, can) {
|
||||
can.onmotion.toimage(event, can, can._legend.innerText, can._output)
|
||||
},
|
||||
_draw: function(can, tree, x, y, style) {
|
||||
var color = can.onimport._color(can, tree)
|
||||
tree.view = can.onimport.draw({}, can, {
|
||||
shape: html.TEXT, point: [{x: x, y: y}], style: can.base.Copy({
|
||||
stroke: color, fill: color, "text-anchor": "start", inner: tree.name||tree.file,
|
||||
}, style),
|
||||
}), can.core.ItemCB(can.ondetail, tree.view, can, tree)
|
||||
_draw: function(can, tree, x, y, style) { var color = can.onimport._color(can, tree)
|
||||
tree.view = can.onimport.draw({}, can, {shape: html.TEXT, point: [{x: x, y: y}], style: can.base.Copy(kit.Dict(
|
||||
html.STROKE, color, html.FILL, color, html.TEXT_ANCHOR, "start", "inner", tree.name||tree.file,
|
||||
), style), }), can.core.ItemCB(can.ondetail, tree.view, can, tree)
|
||||
},
|
||||
_draw_vertical: function(can, tree, x, y) { tree.x = x, tree.y = y
|
||||
can.onaction._draw(can, tree, x+tree.width/2, y, {"text-anchor": "middle"})
|
||||
can.onaction._draw(can, tree, x+tree.width/2, y, kit.Dict(html.TEXT_ANCHOR, "middle"))
|
||||
|
||||
tree.height = can.size
|
||||
tree.height = can.margin
|
||||
if (y+tree.height > can.height) { can.height = y+tree.height }
|
||||
if (tree.hide) { return }
|
||||
|
||||
@ -106,7 +104,7 @@ Volcanos(chat.ONACTION, {help: "用户操作", list: ["edit", [ice.VIEW, "横向
|
||||
})
|
||||
},
|
||||
_draw_horizontal: function(can, tree, x, y) { tree.x = x, tree.y = y
|
||||
can.onaction._draw(can, tree, x, y+tree.height*can.size/2, {"text-anchor": "start"})
|
||||
can.onaction._draw(can, tree, x, y+tree.height*can.margin/2, kit.Dict(html.TEXT_ANCHOR, "start"))
|
||||
|
||||
tree.width = tree.view.Val("textLength")||(tree.name||"").length*10
|
||||
if (x+tree.width > can.width) { can.width = x+tree.width }
|
||||
@ -114,42 +112,32 @@ Volcanos(chat.ONACTION, {help: "用户操作", list: ["edit", [ice.VIEW, "横向
|
||||
|
||||
var offset = 0; can.core.List(tree.list, function(item) {
|
||||
can.onimport.draw({}, can, {shape: svg.PATH2H, point: [
|
||||
{x: x+tree.width+can.margin/8, y: y+tree.height*can.size/2},
|
||||
{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.margin/2},
|
||||
{x: x+tree.width+can.margin*2-2*can.margin/8, y: y+offset+item.height*can.margin/2}
|
||||
], style: {stroke: cli.CYAN}})
|
||||
|
||||
can.onaction._draw_horizontal(can, item, x+tree.width+2*can.margin, y+offset)
|
||||
offset += item.height*can.size
|
||||
offset += item.height*can.margin
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONDETAIL, {help: "用户交互", list: [],
|
||||
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, {
|
||||
shape: svg.RECT, point: [
|
||||
{x: tree.x-can.margin/4, y: y-can.size/2},
|
||||
{x: tree.x+tree.width+can.margin/8, y: y+can.size/2},
|
||||
], style: {stroke: cli.RED, fill: html.NONE},
|
||||
}), can.onkeymap.prevent(event)
|
||||
onmouseenter: function(event, can, tree) { var y = tree.y+tree.height*can.margin/2
|
||||
can.page.Remove(can, can.pos), can.pos = can.onimport.draw({}, can, {shape: svg.RECT, point: [
|
||||
{x: tree.x-can.margin/4, y: y-can.margin/2}, {x: tree.x+tree.width+can.margin/8, y: y+can.margin/2},
|
||||
], style: {stroke: cli.RED, fill: html.NONE}}), can.onkeymap.prevent(event)
|
||||
},
|
||||
onclick: function(event, can, tree) {
|
||||
if (tree.list.length > 0 || tree.tags || tree.name.endsWith(can._args.split)) {
|
||||
if (tree.list.length > 0 || tree.tags || tree.name.endsWith(can.Conf(lex.SPLIT))) {
|
||||
return tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||
}
|
||||
|
||||
for (var node = tree; node; node = node.last) {
|
||||
can.request(event, node.meta)
|
||||
}
|
||||
var msg = can.request(event, can.Option())
|
||||
can.run(event, can.base.Obj(can._args.prefix, []).concat([can.Option("repos")||"", tree.file||"", tree.name]), function(msg) {
|
||||
if (msg.Length() == 0) {
|
||||
return can.ondetail.plugin(can, tree, {}, "web.code.inner", [can.dir_root, tree.file, tree.line], [ctx.ACTION, "inner"])
|
||||
}
|
||||
if (msg.Append(mdb.INDEX)) { msg.Table(function(value) {
|
||||
can.ondetail.plugin(can, tree, value, value.index, [], [ctx.ACTION, ice.RUN, value.index])
|
||||
}); return }
|
||||
for (var node = tree; node; node = node.last) { can.request(event, node.meta) }
|
||||
|
||||
can.run(can.request(event, can.Option()), can.base.Obj(can.Conf(lex.PREFIX), []).concat([can.Option("repos")||"", tree.file||"", tree.name]), function(msg) {
|
||||
if (msg.Length() == 0) { return can.ondetail.plugin(can, "web.code.inner", [can.dir_root, tree.file, tree.line], code.INNER) }
|
||||
if (msg.Append(mdb.INDEX)) { msg.Table(function(value) { can.ondetail.plugin(can, value.index, [], value.index) }); return }
|
||||
|
||||
tree.tags = true
|
||||
if (msg.Option(lex.SPLIT)) {
|
||||
tree.list = can.onimport._tree(can, msg.Table(), msg.Option(mdb.FIELD)||msg.append[0], msg.Option(lex.SPLIT))[""].list||[]
|
||||
can.core.List(tree.list, function(item) { item.last = tree })
|
||||
@ -160,28 +148,17 @@ Volcanos(chat.ONDETAIL, {help: "用户交互", list: [],
|
||||
file: item.file, line: item.line, hide: true,
|
||||
}) })
|
||||
}
|
||||
tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||
tree.tags = true, tree.hide = !tree.hide, can.onaction[can.Action(ice.VIEW)](event, can)
|
||||
}, true)
|
||||
},
|
||||
|
||||
plugin: function(can, tree, value, index, args, prefix) {
|
||||
for (var node = tree; node; node = node.last) {
|
||||
can.base.Copy(value, node.meta)
|
||||
}
|
||||
can.onappend.plugin(can, can.base.Copy({type: chat.FLOAT, index: index, args: args}), function(sub) {
|
||||
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
||||
can.run(event, can.misc.concat(can, prefix, cmds), cb, true)
|
||||
}, can.ondetail.figure(can, sub)
|
||||
})
|
||||
},
|
||||
figure: function(can, sub, msg, cb) {
|
||||
can.getActionSize(function(left, top, width, height) { left = left||0
|
||||
var top = 120; if (can.user.isMobile) { top = can.user.isLandscape()? 0: 48 }
|
||||
sub.ConfHeight(height-top-html.ACTION_HEIGHT-(can.user.isMobile&&!can.user.isLandscape()? 2*html.ACTION_HEIGHT: 0)), sub.ConfWidth(width)
|
||||
|
||||
can.onmotion.move(can, sub._target, {position: html.FIXED, left: left, top: top})
|
||||
can.page.style(can, sub._output, html.MAX_WIDTH)
|
||||
can.base.isFunc(cb) && cb(msg)
|
||||
plugin: function(can, index, args, prefix) {
|
||||
can.onappend.plugin(can, {type: chat.FLOAT, index: index, args: args}, function(sub) {
|
||||
sub.run = function(event, cmds, cb) { can.runAction(can.request(event), prefix, cmds, cb) }
|
||||
sub._mode = "float", can.getActionSize(function(left, top, width, height) { left = left||0
|
||||
var top = can._mode == undefined? 120: 0; if (can.user.isMobile) { top = can.user.isLandscape()? 0: 48 }
|
||||
sub.ConfHeight(height-top-html.ACTION_HEIGHT-(can.user.isMobile&&!can.user.isLandscape()? 2*html.ACTION_HEIGHT: 0)), sub.ConfWidth(width)
|
||||
can.onmotion.move(can, sub._target, {position: html.FIXED, left: left, top: top})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
@ -1,6 +1,5 @@
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg)
|
||||
if (msg.Length() == 0) { return }
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||
can.onmotion.clear(can), can.base.isFunc(cb) && cb(msg); if (msg.Length() == 0) { return }
|
||||
if (msg.Option("branch")) { return can.onappend.table(can, msg) }
|
||||
|
||||
can.data = msg.Table(), can.onimport._sum(can)
|
||||
@ -39,48 +38,41 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", list: [], _init: function(can, ms
|
||||
},
|
||||
_layout: function(can) {
|
||||
var height = can.onexport.height(can)
|
||||
var width = parseInt(can.ConfWidth()), space = 10
|
||||
var width = parseInt(can.ConfWidth()), space = parseInt(can.Action("space")||"10")
|
||||
var step = parseInt((width-2*space) / can.list.length)
|
||||
|
||||
can.onmotion.clear(can, can._output)
|
||||
can.onimport._show(can, can._msg), can.onmotion.hidden(can, can.ui.project)
|
||||
can.onmotion.clear(can, can._output), can.onimport._show(can, can._msg)
|
||||
can.svg.Val(html.HEIGHT, height), can.svg.Val(html.WIDTH, width)
|
||||
return {height: height, width: width, space: 10, step: step}
|
||||
return {height: height, width: width, space: space, step: step}
|
||||
},
|
||||
layout: function(can) {
|
||||
can.onaction[can.Action(ice.VIEW)]({}, can)
|
||||
},
|
||||
}, [""])
|
||||
Volcanos(chat.ONACTION, {help: "组件菜单", list: ["edit",
|
||||
Volcanos(chat.ONACTION, {help: "组件菜单", list: [
|
||||
[ice.VIEW, "趋势图", "柱状图", "数据源"],
|
||||
[html.HEIGHT, "100", "200", "400", "600", "800", ice.AUTO],
|
||||
[html.SPEED, "10", "20", "50", "100"]
|
||||
[html.HEIGHT, 100, 200, 400, 600, 800, ice.AUTO],
|
||||
["space", 10, 20, 50, 100],
|
||||
[html.SPEED, 10, 20, 50, 100],
|
||||
],
|
||||
"edit": function(event, can) { can.onmotion.toggle(can, can._action), can.onmotion.toggle(can, can._status) },
|
||||
|
||||
"趋势图": function(event, can) { var args = can.onimport._layout(can)
|
||||
function scale(y) { return (y - can.min)/(can.max - can.min)*(args.height-2*args.space) }
|
||||
function order(index, x, y) { return {x: args.space+args.step*index+x, y: args.height-args.space-scale(y)} }
|
||||
|
||||
can.core.Next(can.list, function(line, next, index) {
|
||||
can.onimport.draw({}, can, {
|
||||
shape: svg.LINE, point: [
|
||||
order(index, args.step/2, line.min), order(index, args.step/2, line.max),
|
||||
], style: kit.Dict(html.STROKE_WIDTH, 1, html.STROKE, line.begin < line.close? chat.WHITE: chat.BLACK),
|
||||
})
|
||||
var black = can.onimport.group(can, cli.BLACK, kit.Dict(html.STROKE, cli.BLACK, html.FILL, cli.BLACK))
|
||||
var white = can.onimport.group(can, cli.WHITE, kit.Dict(html.STROKE, cli.WHITE, html.FILL, cli.WHITE))
|
||||
|
||||
can.onimport.draw({}, can, {
|
||||
shape: svg.RECT, point: [
|
||||
order(index, args.step/4, line.close), order(index, args.step/4*3, line.begin),
|
||||
], style: can.base.Copy(kit.Dict(html.STROKE_WIDTH, 1, svg.RX, 0, svg.RY, 0), line.begin < line.close?
|
||||
kit.Dict(html.STROKE, chat.WHITE, html.FILL, chat.WHITE): kit.Dict(html.STROKE, chat.BLACK, html.FILL, chat.BLACK)
|
||||
),
|
||||
_init: function(view) {
|
||||
can.core.ItemCB(can.ondetail, function(key, cb) { view[key] = function(event) { cb(event, can, line) } })
|
||||
},
|
||||
})
|
||||
can.core.Next(can.list, function(line, next, index) { can.Status(line)
|
||||
can.onimport.draw({}, can, {shape: svg.LINE, point: [
|
||||
order(index, args.step/2, line.min), order(index, args.step/2, line.max),
|
||||
]}, line.begin < line.close? white: black)
|
||||
|
||||
can.onimport.draw({}, can, {shape: svg.RECT, point: [
|
||||
order(index, args.step/4, line.close), order(index, args.step/4*3, line.begin),
|
||||
], _init: function(view) {
|
||||
can.core.ItemCB(can.ondetail, function(key, cb) { view[key] = function(event) { cb(event, can, line) } })
|
||||
}}, line.begin < line.close? white: black)
|
||||
|
||||
can.Status(line, ["date", "text", "add", "del"])
|
||||
can.core.Timer(parseInt(can.Action(html.SPEED)), next)
|
||||
})
|
||||
},
|
||||
@ -115,12 +107,13 @@ Volcanos(chat.ONACTION, {help: "组件菜单", list: ["edit",
|
||||
},
|
||||
|
||||
height: function(event, can) { can.onimport.layout(can) },
|
||||
space: function(event, can) { can.onimport.layout(can) },
|
||||
speed: function(event, can) { can.onimport.layout(can) },
|
||||
})
|
||||
Volcanos(chat.ONDETAIL, {help: "用户交互", list: [],
|
||||
onmouseenter: function(event, can, line) { can.Status(line, ["date", "note", "adds", "dels"]) },
|
||||
onmouseenter: function(event, can, line) { can.Status(line) },
|
||||
})
|
||||
Volcanos(chat.ONEXPORT, {help: "导出数据", list: ["from", "commit", "total", "max", "date", "note", "adds", "dels"],
|
||||
Volcanos(chat.ONEXPORT, {help: "导出数据", list: ["from", "commit", "total", "max", "date", "text", "add", "del"],
|
||||
height: function(can) { var height = can.Action(html.HEIGHT)
|
||||
if (height == ice.AUTO) { height = can.ConfHeight() }
|
||||
return parseInt(height)
|
||||
|
12
proto.js
12
proto.js
@ -115,7 +115,7 @@ var gdb = {
|
||||
SIGNAL: "signal",
|
||||
}
|
||||
var lex = {
|
||||
SPLIT: "split",
|
||||
SPLIT: "split", PREFIX: "prefix",
|
||||
}
|
||||
|
||||
var code = {
|
||||
@ -198,7 +198,7 @@ var mall = {
|
||||
}
|
||||
|
||||
var svg = {
|
||||
GROUP: "group", PID: "pid",
|
||||
GROUP: "group", PID: "pid", GRID: "grid",
|
||||
SHAPE: "shape", TEXT: "text", RECT: "rect", LINE: "line", CIRCLE: "circle", ELLIPSE: "ellipse",
|
||||
G: "g", X: "x", Y: "y", R: "r", RX: "rx", RY: "ry", CX: "cx", CY: "cy", X1: "x1", Y1: "y1", X2: "x2", Y2: "y2",
|
||||
PATH: "path", PATH2V: "path2v", PATH2H: "path2h",
|
||||
@ -236,6 +236,7 @@ var html = {
|
||||
SPEED: "speed",
|
||||
MIN_HEIGHT: "min-height", MAX_HEIGHT: "max-height", MAX_WIDTH: "max-width", MIN_WIDTH: "min-width", MARGIN_TOP: "margin-top", MARGIN_X: "margin-x", MARGIN_Y: "margin-y",
|
||||
PLUGIN_MARGIN: 10, ACTION_HEIGHT: 29, ACTION_MARGIN: 200,
|
||||
TEXT_ANCHOR: "text-anchor",
|
||||
TOGGLE: "toggle",
|
||||
|
||||
PAGE: "page", TABS: "tabs",
|
||||
@ -341,9 +342,11 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", pack:
|
||||
},
|
||||
|
||||
actions: function(event, button) { can.runAction(event, button, []) },
|
||||
runActionCommand: function(event, index, args, cb) { can.runAction(event, ice.RUN, [index].concat(args), cb) },
|
||||
runActionCommand: function(event, index, args, cb) { can.runAction(event, ice.RUN, can.misc.concat(can, [index], args), cb) },
|
||||
runAction: function(event, action, args, cb) { can.request(event, {_handle: ice.TRUE}, can.Option())
|
||||
can.run(event, can.misc.concat(can, [ctx.ACTION, action], args), cb||function(msg) {
|
||||
if (can.core.CallFunc([can, chat.ONIMPORT, ice.MSG_PROCESS], {can: can, msg: msg})) { return }
|
||||
if (can.core.CallFunc([can.sup, chat.ONIMPORT, ice.MSG_PROCESS], {can: can.sup, msg: msg})) { return }
|
||||
can.user.toastSuccess(can, action)
|
||||
}, true)
|
||||
},
|
||||
@ -369,6 +372,9 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", pack:
|
||||
getAction: function(key, cb) { return can.get("Action", key, cb) },
|
||||
getActionSize: function(cb) { return can.get("Action", "size", cb) },
|
||||
|
||||
ConfDefault: function(value) {
|
||||
can.core.Item(value, function(k, v) { can.Conf(k) || can.Conf(k, v) })
|
||||
},
|
||||
ConfHeight: function(value) { return can.Conf(html.HEIGHT, value) },
|
||||
ConfWidth: function(value) { return can.Conf(html.WIDTH, value) },
|
||||
Conf: function(key, value) { var res = can._conf
|
||||
|
Loading…
x
Reference in New Issue
Block a user