mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
opt inner.js
This commit is contained in:
parent
73563a6e07
commit
9ba7097749
47
frame.js
47
frame.js
@ -272,7 +272,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
||||
}
|
||||
can.core.Timer(10, function() { item.click() })
|
||||
can.page.Modify(can, item, {draggable: true, _close: cbs,
|
||||
oncontextmenu: function(event) {
|
||||
onmouseenter: function(event) {
|
||||
can.user.carte(event, can, kit.Dict(
|
||||
cli.CLOSE, function(event) { close(item) },
|
||||
"close other", function(event) {
|
||||
@ -503,21 +503,22 @@ Volcanos("onlayout", {help: "页面布局", list: [], _init: function(can, targe
|
||||
can.page.Modify(can, target||document.body, {style: {background: url == "" || url == "void"? "": 'url("'+url+'")'}})
|
||||
},
|
||||
figure: function(event, can, target, right, layout) { target = target||can._target
|
||||
if (!layout) { if (!event || !event.target) { return }
|
||||
var left = event.clientX-event.offsetX, top = event.clientY-event.offsetY+event.target.offsetHeight-5; if (right) {
|
||||
var left = event.clientX-event.offsetX+event.target.offsetWidth, top = event.clientY-event.offsetY
|
||||
}
|
||||
if (left+target.offsetWidth>window.innerWidth) { left = window.innerWidth - target.offsetWidth }
|
||||
if (top+target.offsetHeight>window.innerHeight-100) { top = window.innerHeight - target.offsetHeight - 100 }
|
||||
if (layout) { return can.page.Modify(can, target, {style: layout}), can.onmotion.move(can, target, layout), layout }
|
||||
|
||||
|
||||
layout = {left: left, top: top}
|
||||
if (layout.left < 0) { layout.left = 0 }
|
||||
if (layout.top < 0) { layout.top = 0 }
|
||||
if (!event || !event.target) { return }
|
||||
var left = event.clientX-event.offsetX, top = event.clientY-event.offsetY+event.target.offsetHeight-5; if (right) {
|
||||
var left = event.clientX-event.offsetX+event.target.offsetWidth, top = event.clientY-event.offsetY
|
||||
}
|
||||
can.page.Modify(can, target, {style: layout})
|
||||
can.onmotion.move(can, target, layout)
|
||||
return layout
|
||||
layout = {left: left, top: top}
|
||||
if (layout.top < 0) { layout.top = 0 }
|
||||
if (layout.left < 0) { layout.left = 0 }
|
||||
if (layout.left+target.offsetWidth>window.innerWidth) {
|
||||
layout.right = 0, layout.left = ""
|
||||
}
|
||||
if (top+target.offsetHeight>window.innerHeight-100) {
|
||||
layout.bottom = window.innerHeight - event.clientY+event.offsetY, layout.top = ""
|
||||
}
|
||||
return can.page.Modify(can, target, {style: layout}), can.onmotion.move(can, target, layout), layout
|
||||
},
|
||||
|
||||
display: function(can, target) { target = target||can._target
|
||||
@ -538,7 +539,10 @@ Volcanos("onlayout", {help: "页面布局", list: [], _init: function(can, targe
|
||||
},
|
||||
profile: function(can, target) { target = target||can._output
|
||||
var gt = "❯", lt = "❮", down = "˅", up = "˄"
|
||||
function init(view) { return view._show && view._show(event, view.style.display == html.NONE), view }
|
||||
function toggle(view) {
|
||||
view._toggle? view._toggle(event, view.style.display == html.NONE): can.onmotion.toggle(can, view)
|
||||
return view.style.display == html.NONE
|
||||
}
|
||||
|
||||
var ui = can.page.Append(can, target, [{view: [chat.LAYOUT, html.TABLE], list: [
|
||||
{view: [chat.PROJECT, html.TD], list: [{view: [chat.PROJECT]}]},
|
||||
@ -546,20 +550,20 @@ Volcanos("onlayout", {help: "页面布局", list: [], _init: function(can, targe
|
||||
{type: html.TR, list: [{type: html.TR, list: [
|
||||
{view: [chat.CONTENT, html.TD], list: [{view: [chat.CONTENT]},
|
||||
{view: ["toggle project"], list: [{text: [gt, html.DIV]}], onclick: function(event) {
|
||||
event.target.innerHTML = can.onmotion.toggle(can, init(ui.project))? lt: gt
|
||||
event.target.innerHTML = toggle(can.ui.project)? gt: lt
|
||||
}},
|
||||
{view: ["toggle profile"], list: [{text: [lt, html.DIV]}], onclick: function(event) {
|
||||
event.target.innerHTML = can.onmotion.toggle(can, init(ui.profile))? gt: lt
|
||||
event.target.innerHTML = toggle(can.ui.profile)? lt: gt
|
||||
}},
|
||||
{view: ["toggle display"], list: [{text: [down, html.DIV]}], onclick: function(event) {
|
||||
event.target.innerHTML = can.onmotion.toggle(can, init(ui.display))? down: up
|
||||
{view: ["toggle display"], list: [{text: [up, html.DIV]}], onclick: function(event) {
|
||||
event.target.innerHTML = toggle(can.ui.display)? up: down
|
||||
}},
|
||||
]},
|
||||
{view: [chat.PROFILE, html.TD], list: [{view: [chat.PROFILE], style: {display: html.NONE}}]},
|
||||
]}]},
|
||||
{view: [chat.DISPLAY, html.TR], list: [{view: [chat.DISPLAY], style: {display: html.NONE}}]}
|
||||
]}
|
||||
] }]); return ui
|
||||
] }]); return can.ui = ui
|
||||
},
|
||||
})
|
||||
Volcanos("onmotion", {help: "动态特效", list: [], _init: function(can, target) {
|
||||
@ -633,7 +637,8 @@ Volcanos("onmotion", {help: "动态特效", list: [], _init: function(can, targe
|
||||
},
|
||||
cache: function(can, next) { var list = can.base.Obj(can.core.List(arguments).slice(2), [can._output])
|
||||
can.core.List(list, function(item) { can.page.Cache(item._cache_key, item, item.scrollTop+1) })
|
||||
return can.core.List(list, function(item) { var pos = can.page.Cache(item._cache_key = next(), item)
|
||||
var key = next(can._cache_data = can._cache_data||{})
|
||||
return can.core.List(list, function(item) { var pos = can.page.Cache(item._cache_key = key, item)
|
||||
if (pos) { item.scrollTo(0, pos-1); return item }
|
||||
}).length > 0
|
||||
},
|
||||
|
@ -205,7 +205,7 @@ Volcanos("base", {help: "数据类型",
|
||||
if (v.length > 0) { return v }
|
||||
} else if (typeof v == lang.STRING && v) {
|
||||
return v
|
||||
} else if (typeof v == undefined) {
|
||||
} else if (v == undefined) {
|
||||
continue
|
||||
} else {
|
||||
return v
|
||||
@ -231,6 +231,9 @@ Volcanos("base", {help: "数据类型",
|
||||
isNight: function() { var now = new Date()
|
||||
return now.getHours() < 7 || now.getHours() > 17
|
||||
},
|
||||
beginWith: function(str, begin) {
|
||||
return str.trim().indexOf(begin) == 0
|
||||
},
|
||||
endWith: function(str, end) {
|
||||
return str.lastIndexOf(end) + end.length == str.length
|
||||
},
|
||||
|
12
lib/page.js
12
lib/page.js
@ -12,10 +12,10 @@ Volcanos("page", {help: "用户界面", ClassList: {
|
||||
}).join(ice.SP).trim()
|
||||
},
|
||||
set: function(can, obj, key, condition) {
|
||||
condition? this.add(can, obj, key): this.del(can, obj, key)
|
||||
return (condition? this.add(can, obj, key): this.del(can, obj, key)).indexOf(key) > -1
|
||||
},
|
||||
neg: function(can, obj, key) {
|
||||
return (this.has(can, obj, key)? this.del(can, obj, key): this.add(can, obj, key)).indexOf > -1
|
||||
return (this.has(can, obj, key)? this.del(can, obj, key): this.add(can, obj, key)).indexOf(key) > -1
|
||||
},
|
||||
},
|
||||
SelectArgs: function(can, option, key, cb) {
|
||||
@ -394,5 +394,13 @@ Volcanos("page", {help: "用户界面", ClassList: {
|
||||
styleSheet.type = "text/css", styleSheet.innerText = text
|
||||
document.head.appendChild(styleSheet)
|
||||
},
|
||||
offsetTop: function(item) { var res = 0
|
||||
while (item) { res += item.offsetTop||0, item = item.parentNode }
|
||||
return res
|
||||
},
|
||||
offsetLeft: function(item) { var res = 0
|
||||
while (item) { res += item.offsetLeft||0, item = item.parentNode }
|
||||
return res
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -242,7 +242,7 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
item._init = function(target) {
|
||||
item.run = function(event, cmds, cb) {
|
||||
can.request(event, function() { var value = {_handle: ice.TRUE, action: msg.Option(chat.ACTION)}
|
||||
can.page.Select(can, ui.table, chat.OPTION_ARGS, function(item) {
|
||||
can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
||||
item.name && item.value && (value[item.name] = item.value)
|
||||
}); return value
|
||||
}, msg, can.Option()), can.run(event, cmds, cb, true)
|
||||
@ -270,7 +270,7 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
})
|
||||
|
||||
can.page.Select(can, ui._target, html.INPUT_ARGS, function(item, index) {
|
||||
index == 0 && can.onmotion.focus(can, item)
|
||||
index == 0 && can.core.Timer(100, function() { can.onmotion.focus(can, item) })
|
||||
})
|
||||
return action
|
||||
},
|
||||
|
@ -51,7 +51,6 @@ p.story[data-type=brief] {
|
||||
font-size:20px; font-family:cursive; font-weight:bolder;
|
||||
}
|
||||
|
||||
|
||||
select {
|
||||
background-color:black; color:cyan;
|
||||
font-size:14px; font-family:monospace;
|
||||
|
@ -49,7 +49,7 @@ Volcanos({name: "chat", panels: [
|
||||
}},
|
||||
project: {name: "研发群", storm: {
|
||||
studio: {name: "研发 studio", list: [
|
||||
{name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"], _action: ["autogen", "compile", "binpack"]},
|
||||
{name: "vimer", help: "编辑器", index: "web.code.inner", args: ["src/", "main.go"], _action: ["autogen", "compile", "binpack"]},
|
||||
{name: "repos", help: "代码库", index: "web.code.git.status"},
|
||||
{name: "plan", help: "任务表", index: "web.team.plan"},
|
||||
{name: "ctx", help: "上下文", index: "web.wiki.word", args: ["src/main.shy"]},
|
||||
|
@ -1,5 +1,6 @@
|
||||
fieldset.Search {
|
||||
background:#041a25bd; padding:10px;
|
||||
left:0px; top:26px;
|
||||
position:fixed;
|
||||
display:none;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
|
||||
|
||||
can.onappend._status(can, can.base.Obj(msg.Option("_status"), []).concat({name: "selected", value: "0"}))
|
||||
can.getActionSize(function(msg, height) {
|
||||
can.page.Modify(can, can.ui.profile, kit.Dict(html.MAX_HEIGHT, height-table.offsetHeight))
|
||||
can.page.Modify(can, can.ui.profile, kit.Dict(html.MAX_HEIGHT, height-(table&&table.offsetHeight||0)))
|
||||
})
|
||||
msg.Length() == 1 && can.page.Select(can, table, html.TD)[0].click()
|
||||
},
|
||||
|
@ -31,6 +31,17 @@ Volcanos("onfigure", {help: "控件详情", list: [], key: {
|
||||
default: target._index = 0, target._value = ""
|
||||
}
|
||||
},
|
||||
onfocus: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
||||
target._figure = can.onlayout.figure(event, can, can._target, false, {top: can.page.offsetTop(target)+target.offsetHeight, left: can.page.offsetLeft(target)})
|
||||
can.run(event, [ctx.ACTION, mdb.INPUTS, meta.name, target.value], function(msg) {
|
||||
if (msg.Length() == 0) { return can.close() }
|
||||
target._msg = msg, can.onfigure.key._init(can, msg, target), can.Status(mdb.TOTAL, msg.Length())
|
||||
can.base.isFunc(cbs) && cbs(can)
|
||||
})
|
||||
}) },
|
||||
onblur: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
||||
can.close()
|
||||
}) },
|
||||
onclick: function(event, can, meta, cb, target) { cb(function(can, cbs) {
|
||||
can.run(event, [ctx.ACTION, mdb.INPUTS, meta.name, target.value], function(msg) {
|
||||
if (msg.Length() == 0) { return can.close() }
|
||||
|
@ -102,12 +102,12 @@ fieldset.inner>div.output div.display {
|
||||
}
|
||||
|
||||
fieldset.inner div.output fieldset.toolkit {
|
||||
background:#0d969f8a;
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
bottom:0px; right:0px;
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.output>fieldset {
|
||||
display:none; margin:0;padding:0;
|
||||
/* float:right; */
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.output>fieldset.select {
|
||||
display:block;
|
||||
@ -115,9 +115,21 @@ fieldset.inner>div.output fieldset.toolkit>div.output>fieldset.select {
|
||||
fieldset.inner>div.output fieldset.toolkit>div.output>fieldset>legend {
|
||||
display:none;
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>div.legend {
|
||||
float:left; padding:4px; cursor:pointer;
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>legend {
|
||||
float:right; padding:4px; cursor:pointer;
|
||||
padding:4px 4px; border-right:solid 2px red;
|
||||
background:#0d969f8a;
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>legend.select {
|
||||
background:green;
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>legend:hover {
|
||||
background:green;
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>div.legend {
|
||||
float:right; padding:4px; cursor:pointer;
|
||||
padding:4px 4px; border-right:solid 2px red;
|
||||
background:#0d969f8a;
|
||||
}
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>div.legend.select {
|
||||
background:green;
|
||||
@ -125,6 +137,21 @@ fieldset.inner>div.output fieldset.toolkit>div.status>div.legend.select {
|
||||
fieldset.inner>div.output fieldset.toolkit>div.status>div.legend:hover {
|
||||
background:green;
|
||||
}
|
||||
fieldset.inner>div.docker {
|
||||
position:absolute;
|
||||
right:0;
|
||||
bottom:0;
|
||||
}
|
||||
fieldset.inner>div.docker div.legend {
|
||||
float:right; padding:4px; cursor:pointer;
|
||||
padding:4px 4px; border-right:solid 2px red;
|
||||
}
|
||||
fieldset.inner>div.docker div.legend.select {
|
||||
background:green;
|
||||
}
|
||||
fieldset.inner>div.docker div.legend:hover {
|
||||
background:green;
|
||||
}
|
||||
|
||||
body.white fieldset.inner>div.output div.project {
|
||||
color:#a2dad2;
|
||||
|
@ -1,212 +1,231 @@
|
||||
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, cb, target) {
|
||||
can.onmotion.clear(can), can.ui = can.onlayout.profile(can)
|
||||
can.tabview = can.tabview||{}, can.tabview[can.Option(nfs.PATH)+":"+can.Option(nfs.FILE)] = msg
|
||||
can.history = can.history||[], can.toolkit = {}
|
||||
|
||||
can.onmotion.clear(can), can.onlayout.profile(can)
|
||||
can.onimport._project(can, can.ui.project)
|
||||
can.onimport._content(can, can.ui.content)
|
||||
can.onimport._profile(can, can.ui.profile)
|
||||
can.onimport._display(can, can.ui.display)
|
||||
can.onimport._search(can, target)
|
||||
can.onimport._favor(can, target)
|
||||
can.base.isFunc(cb) && cb(msg)
|
||||
|
||||
msg.Option({path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE)||1})
|
||||
can.tabview = can.tabview||{}, can.tabview[can.Option(nfs.PATH)+can.Option(nfs.FILE)] = msg
|
||||
can.history = can.history||[]
|
||||
|
||||
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), msg.Option(nfs.LINE)||1, function() {
|
||||
var repos = can.base.trimSuffix(can.base.trimPrefix(msg.Option(nfs.PATH), "usr/"), ice.PS)
|
||||
can.onimport.toolkit(can, {index: "web.code.git.spide", args: [repos]})
|
||||
can.onimport.toolkit(can, {index: "web.code.git.trend", args: [repos]})
|
||||
can.onimport.toolkit(can, {index: "web.code.git.total", args: [repos]})
|
||||
can.onimport.project(can, msg.Option(nfs.PATH))
|
||||
can.onaction["工具"](event, can)
|
||||
can.base.isFunc(cb) && cb(msg)
|
||||
can.onimport.tabview(can, can.Option(nfs.PATH), can.Option(nfs.FILE), can.Option(nfs.LINE))
|
||||
can.onimport.project(can, can.Option(nfs.PATH), function() {
|
||||
can.onimport._toolkit(can, can.ui.toolkit), can.core.Timer(100, function() {
|
||||
can.core.Next(can.core.Split(msg.OptionOrSearch("tool")), function(item, next) {
|
||||
can.onimport.toolkit(can, {index: item}, next)
|
||||
}, function() {
|
||||
can.core.Next(["inner/search.js", "inner/favor.js", "inner/sess.js"].reverse(), function(item, next) {
|
||||
can.require([item], function() {}, function(can, name, sub) { sub._init(can, next) })
|
||||
}, function() {
|
||||
can.core.List(can.core.Split(msg.OptionOrSearch("tabs")), function(item) {
|
||||
can.onimport.tabview(can, can.Option(nfs.PATH), item)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
var run = can.run; can.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
||||
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||
ctx.INPUTS, function(cmds) {
|
||||
if (cmds[0] == nfs.FILE) {
|
||||
switch (msg.Option(mdb.TYPE)) {
|
||||
case ctx.INDEX:
|
||||
run(event, [ctx.ACTION, ctx.INPUTS, ctx.INDEX].concat(cmds.slice(1)), cb, silent)
|
||||
break
|
||||
default:
|
||||
can.core.List(can._file, function(item) {
|
||||
if (!cmds[1] || item.path.indexOf(cmds[1])) {
|
||||
msg.Push(nfs.FILE, item.path)
|
||||
}
|
||||
})
|
||||
can.base.isFunc(cb) && cb(msg)
|
||||
}
|
||||
return
|
||||
}
|
||||
run(event, [ctx.ACTION, ctx.INPUTS].concat(cmds), cb, silent)
|
||||
},
|
||||
))) { return }
|
||||
run(event, cmds, cb, silent)
|
||||
}
|
||||
},
|
||||
_project: function(can, target) {
|
||||
target._show = function(event) { can.onimport._content(can) }
|
||||
},
|
||||
_content: function(can, target) { var height = can.Conf(html.HEIGHT)
|
||||
if (can.user.mod.isCmd) {
|
||||
can.page.style(can, can.ui.project, html.HEIGHT, height)
|
||||
can.page.style(can, can.ui.content, html.HEIGHT, height)
|
||||
can.page.style(can, can.ui.content, html.MAX_WIDTH, can.Conf(html.WIDTH)-can.ui.project.offsetWidth-33)
|
||||
can.page.style(can, can._output, html.WIDTH, can.Conf(html.WIDTH))
|
||||
} else {
|
||||
can.page.style(can, can.ui.project, html.MAX_HEIGHT, height)
|
||||
can.page.style(can, can.ui.content, html.MAX_HEIGHT, height)
|
||||
}
|
||||
target._toggle = function(event) { can.onmotion.toggle(can, target), can.onimport.layout(can) }
|
||||
},
|
||||
_profile: function(can, target) {
|
||||
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}]); can.ui.profile_output = ui.output
|
||||
var action = can.onappend._action(can, [cli.SHOW, cli.CLEAR, cli.CLOSE], ui.action, kit.Dict(
|
||||
var action = can.onappend._action(can, [cli.SHOW, cli.CLEAR, mdb.PLUGIN, cli.CLOSE], ui.action, kit.Dict(
|
||||
cli.SHOW, function(event) { can.onaction["展示"](event, can) },
|
||||
cli.CLEAR, function(event) { can.onmotion.clear(can, ui.output) },
|
||||
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport._content(can, target) },
|
||||
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport.layout(can) },
|
||||
mdb.PLUGIN, function(event) {
|
||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data, list, args) {
|
||||
can.onappend.plugin(can, data, function(sub) {
|
||||
sub.run = function(event, cmds, cb) {
|
||||
can.run(event, [ctx.ACTION, ice.RUN, data.index].concat(cmds), cb, true)
|
||||
}
|
||||
}, ui.output)
|
||||
})
|
||||
},
|
||||
))
|
||||
target._show = function(event, hidden) { action[hidden? cli.CLOSE: cli.SHOW](event) }
|
||||
target._toggle = function(event, show) { action[show? cli.SHOW: cli.CLOSE](event) }
|
||||
},
|
||||
_display: function(can, target) { can.ui.toolkit = can.onappend.field(can, "toolkit", {}, can._output)
|
||||
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}]); can.ui.display_output = ui.output
|
||||
var action = can.onappend._action(can, [cli.EXEC, cli.CLEAR, cli.CLOSE], ui.action, kit.Dict(
|
||||
_display: function(can, target) {
|
||||
var ui = can.page.Append(can, target, [{view: html.ACTION}, {view: html.OUTPUT}]); can.ui.display_output = ui.output
|
||||
var action = can.onappend._action(can, [cli.EXEC, cli.CLEAR, mdb.PLUGIN, cli.CLOSE], ui.action, kit.Dict(
|
||||
cli.EXEC, function(event) { can.onaction["执行"](event, can) },
|
||||
cli.CLEAR, function(event) { can.onmotion.clear(can, ui.output) },
|
||||
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport._content(can, target) },
|
||||
))
|
||||
target._show = function(event, hidden) { action[hidden? cli.CLOSE: cli.EXEC](event) }
|
||||
},
|
||||
_search: function(can, target) {
|
||||
can.onengine.plugin(can, "can.code.inner.search", shy("搜索", {}, [
|
||||
{type: html.TEXT, name: "word", value: cli.MAIN}, {type: html.BUTTON, name: nfs.FIND}, {type: html.BUTTON, name: cli.BACK},
|
||||
], function(msg, cmds, cb) { can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||
nfs.FIND, function(cmds) { msg.Option(kit.Dict(ice.MSG_HANDLE, ice.TRUE, ice.MSG_FIELDS, "file,line,text"))
|
||||
can.run(msg._event, [ctx.ACTION, mdb.SEARCH, can.parse, cmds[0], can.Option(nfs.PATH)], function(msg) { var sub = msg._can
|
||||
sub.Option("word", cmds[0]), can.page.style(can, sub._output, html.MAX_HEIGHT, 200)
|
||||
can.onmotion.hidden(can, can.ui.toolkit.fieldset, true), can.page.ClassList.has(sub, sub._target, html.SELECT) || sub._legend.click()
|
||||
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
|
||||
return {text: ["", html.TD], list: [{text: [can.page.replace(can, value, ice.PWD, ""), html.DIV]}], onclick: function(event) {
|
||||
line.line && can.onimport.tabview(can, can.Option(nfs.PATH), line.file.replace(ice.PWD, ""), parseInt(line.line), function() {
|
||||
can.onaction.selectLine(can, line.line)
|
||||
})
|
||||
}}
|
||||
}, sub._output), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length())
|
||||
}, true)
|
||||
},
|
||||
)) }))
|
||||
can.onimport.toolkit(can, {index: "can.code.inner.search"}, function(sub) { can.ui.search = sub })
|
||||
},
|
||||
_favor: function(can, target) {
|
||||
can.onimport.toolkit(can, {index: "web.code.favor"}, function(sub) {
|
||||
sub.run = function(event, cmds, cb) { var msg = can.request(event)
|
||||
if (can.misc.runAction(can, msg, cmds, cb, kit.Dict(
|
||||
code.INNER, function(cmds) {
|
||||
can.onimport.tabview(can, msg.Option(nfs.PATH), msg.Option(nfs.FILE), msg.Option(nfs.LINE))
|
||||
},
|
||||
))) { return }
|
||||
|
||||
can.run(event, can.misc.concat(can, [ctx.ACTION, code.FAVOR], cmds), function(msg) { var sub = msg._can
|
||||
sub.onmotion.clear(sub), sub.onappend.table(sub, msg, function(value, key, index, line) {
|
||||
if (msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE) {
|
||||
if (key == mdb.VALUE) { key = line.key }
|
||||
cli.CLOSE, function(event) { can.onmotion.hidden(can, target), can.onimport.layout(can) },
|
||||
mdb.PLUGIN, function(event) {
|
||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data, list, args) {
|
||||
can.onappend.plugin(can, data, function(sub) {
|
||||
sub.run = function(event, cmds, cb) {
|
||||
can.run(event, [ctx.ACTION, ice.RUN, data.index].concat(cmds), cb, true)
|
||||
}
|
||||
if (key != ctx.ACTION) { value = sub.page.replace(sub, value, ice.PWD, "") }
|
||||
|
||||
return {text: ["", html.TD], list: [{text: [value, html.DIV]}], onclick: function(event) {
|
||||
if ([mdb.ZONE, mdb.ID].indexOf(key) > -1) { return sub.onaction.change(event, sub, key, value) }
|
||||
|
||||
if (target.tagName == "INPUT" && target.type == html.BUTTON) { var msg = sub.sup.request(event, line, sub.Option())
|
||||
return sub.run(event, [ctx.ACTION, target.name], function(msg) { sub.run() }, true)
|
||||
}
|
||||
|
||||
line.line && can.onimport.tabview(can, can.Option(nfs.PATH), line.file.replace(ice.PWD, ""), parseInt(line.line), function() {
|
||||
can.onaction.selectLine(can, line.line)
|
||||
})
|
||||
}}
|
||||
}, sub._output), sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), can.Status("标签数", msg.Length())
|
||||
}, true)
|
||||
}
|
||||
})
|
||||
}, ui.output)
|
||||
})
|
||||
},
|
||||
))
|
||||
target._toggle = function(event, show) { action[show? cli.EXEC: cli.CLOSE](event) }
|
||||
},
|
||||
_toolkit: function(can, target) {
|
||||
can.ui.toolkit = can.onappend.field(can, "toolkit", {}, can._output)
|
||||
can.ui.docker = can.page.Append(can, can._fields, [{view: "docker"}]).first
|
||||
var repos = can.base.trimSuffix(can.base.trimPrefix(can.Option(nfs.PATH), "usr/"), ice.PS)
|
||||
|
||||
project: function(can, path) { can.Option({path: path})
|
||||
var msg = can.request({}, {dir_root: path, dir_deep: true})
|
||||
can.run(msg._event, [ice.PWD], function(msg) { can.onmotion.clear(can, can.ui.project)
|
||||
can.onappend.tree(can, msg.Table(), nfs.PATH, ice.PS, function(event, item) {
|
||||
can.onimport.tabview(can, path, item.path)
|
||||
}, can.ui.project), can.Status("文件数", msg.Length())
|
||||
can.run({}, [ctx.ACTION, ctx.COMMAND].concat([
|
||||
"web.code.git.spide", "web.code.git.trend", "web.code.git.total",
|
||||
].reverse()), function(msg) {
|
||||
can.core.Next(msg.Table(), function(item, next) {
|
||||
item.args = can.base.getValid(item.args, [repos]), can.onimport.toolkit(can, item, next)
|
||||
})
|
||||
}, true)
|
||||
},
|
||||
tabview: function(can, path, file, line, cb) {
|
||||
if (can.tabview[path+file]) {
|
||||
can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE))
|
||||
can._msg = can.tabview[path+file]
|
||||
|
||||
project: function(can, path, cb) { can.Option({path: path})
|
||||
var msg = can.request({}, {dir_root: path, dir_deep: true})
|
||||
can.run(msg._event, [ice.PWD], function(msg) { can.onmotion.clear(can, can.ui.project)
|
||||
can.onappend.tree(can, can._file = msg.Table(), nfs.PATH, ice.PS, function(event, item) {
|
||||
can.onimport.tabview(can, path, item.path)
|
||||
}, can.ui.project), can.onimport.layout(can), can.Status("文件数", msg.Length())
|
||||
can.base.isFunc(cb) && cb()
|
||||
}, true)
|
||||
},
|
||||
tabview: function(can, path, file, line, cb) { var key = path+":"+file
|
||||
if (can.tabview[key]) {
|
||||
can._msg && can._msg.Option(nfs.LINE, can.Option(nfs.LINE)), can._msg = can.tabview[key]
|
||||
can.Option({path: path, file: file, line: line||parseInt(can._msg.Option(nfs.LINE))||1})
|
||||
return can.onsyntax._init(can, can._msg), can.base.isFunc(cb) && cb()
|
||||
return can._msg.Option(can.Option()), can.onsyntax._init(can, can._msg, cb)
|
||||
}
|
||||
|
||||
can.run({}, [path, file], function(msg) { can.tabview[path+file] = msg
|
||||
msg.Option({path: path, file: file, line: line||1})
|
||||
if (line == ctx.INDEX) { var msg = can.request({}, {index: file})
|
||||
can.tabview[key] = msg
|
||||
msg._tab = can.onappend.tabs(can, [{name: file.split(ice.PS).pop(), text: file}], function(event, meta) {
|
||||
can.onimport.tabview(can, path, file, "", cb)
|
||||
}, function(item) { delete(can.tabview[path+file]) })
|
||||
}, function(item) { delete(can.tabview[key]) })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
can.Option({path: path, file: file, line: line||1})
|
||||
can.run({}, [path, file], function(msg) { can.tabview[key] = msg
|
||||
msg._tab = can.onappend.tabs(can, [{name: file.split(ice.PS).pop(), text: file}], function(event, meta) {
|
||||
can.onimport.tabview(can, path, file, "", cb)
|
||||
}, function(item) { delete(can.tabview[key]) })
|
||||
}, true)
|
||||
},
|
||||
profile: function(can, msg) {
|
||||
if (msg) {
|
||||
can.onappend.table(can, msg, null, can.ui.profile_output)
|
||||
// can.onappend.table(can, msg, null, can.ui.profile_output)
|
||||
can.onappend.board(can, msg.Result(), can.ui.profile_output)
|
||||
}
|
||||
can.page.style(can, can.ui.profile, html.DISPLAY, html.BLOCK)
|
||||
can.page.style(can, can.ui.profile, html.HEIGHT, can.ui.content.offsetHeight)
|
||||
can.page.style(can, can.ui.profile_output, html.WIDTH, (can.Conf(html.WIDTH)-can.ui.project.offsetWidth)/2)
|
||||
can.onmotion.hidden(can, can.ui.profile, true), can.onimport.layout(can)
|
||||
},
|
||||
display: function(can, msg) {
|
||||
if (msg) {
|
||||
can.onappend.table(can, msg, null, can.ui.output||can.ui.display)
|
||||
can.onappend.board(can, msg.Result(), can.ui.output||can.ui.display)
|
||||
// can.onappend.table(can, msg, null, can.ui.display_output)
|
||||
can.onappend.board(can, msg.Result(), can.ui.display_output)
|
||||
}
|
||||
can.page.style(can, can.ui.display, html.DISPLAY, html.BLOCK)
|
||||
can.page.style(can, can.ui.output, html.HEIGHT, 200)
|
||||
can.page.style(can, can.ui.content, html.HEIGHT, can.ui.project.offsetHeight-200-1*html.ACTION_HEIGHT)
|
||||
can.page.style(can, can.ui.profile, html.HEIGHT, can.ui.content.offsetHeight)
|
||||
can.page.style(can, can.ui.display_output, html.HEIGHT, 200)
|
||||
can.onmotion.hidden(can, can.ui.display, true), can.onimport.layout(can)
|
||||
},
|
||||
toolkit: function(can, meta, cb) {
|
||||
can.onappend.plugin(can, meta, function(sub) {
|
||||
sub.run = function(event, cmds, cb, silent) {
|
||||
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
|
||||
}
|
||||
sub.Conf(html.HEIGHT, 400), sub.Conf(html.WIDTH, can.Conf(html.WIDTH))
|
||||
sub.page.style(sub, sub._output, html.MAX_WIDTH, can.Conf(html.WIDTH))
|
||||
sub.page.style(sub, sub._output, html.MAX_HEIGHT, can.Conf(html.HEIGHT)-2*html.ACTION_HEIGHT)
|
||||
|
||||
can.ui.toolkit.status.appendChild(sub._legend)
|
||||
sub._legend.onclick = function(event) {
|
||||
if (can.page.ClassList.has(can, sub._target, html.SELECT)) {
|
||||
sub.Conf(html.HEIGHT, can.Conf(html.HEIGHT)-4*html.ACTION_HEIGHT, html.WIDTH, can.Conf(html.WIDTH))
|
||||
sub.page.style(sub, sub._output, html.MAX_HEIGHT, sub.Conf(html.HEIGHT))
|
||||
sub.page.style(sub, sub._output, html.MAX_WIDTH, sub.Conf(html.WIDTH))
|
||||
|
||||
can.ui.toolkit.status.appendChild(sub._legend), sub._legend.onclick = function(event) {
|
||||
if (can.page.Select(can, can.ui.toolkit.status, ice.PT+html.SELECT)[0] == event.target) {
|
||||
can.page.ClassList.del(can, sub._target, html.SELECT)
|
||||
return
|
||||
}
|
||||
can.onmotion.select(can, can.ui.toolkit.output, html.FIELDSET, sub._target)
|
||||
can.onmotion.select(can, can.ui.toolkit.status, html.DIV_LEGEND, event.target)
|
||||
can.onmotion.select(can, can.ui.toolkit.output, html.FIELDSET, sub._target)
|
||||
}
|
||||
sub._legend.oncontextmenu = sub._legend.onmouseenter, sub._legend.onmouseenter = function() {}
|
||||
can.base.isFunc(cb) && cb(sub)
|
||||
}, can.ui.toolkit.output)
|
||||
},
|
||||
layout: function(can) { var height = can.Conf(html.HEIGHT), width = can.Conf(html.WIDTH)
|
||||
can.page.style(can, can.ui.content, can.user.mod.isCmd? html.HEIGHT: html.MAX_HEIGHT, height)
|
||||
if (can.ui.project.style.display != html.NONE) {
|
||||
can.page.style(can, can.ui.project, html.HEIGHT, can.ui.content.offsetHeight)
|
||||
}
|
||||
if (can.user.mod.isCmd) {
|
||||
can.page.style(can, can.ui.content, html.HEIGHT, (can.ui.project.offsetHeight||height)-can.ui.display.offsetHeight)
|
||||
}
|
||||
can.page.style(can, can.ui.content, html.WIDTH, width-can.ui.project.offsetWidth-can.ui.profile.offsetWidth-25)
|
||||
can.page.style(can, can.ui.profile_output, html.HEIGHT, can.ui.content.offsetHeight-html.ACTION_HEIGHT)
|
||||
},
|
||||
}, [""])
|
||||
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg) {
|
||||
can._cache_list = can._cache_list||{}, can._cache_list[can.file] = {current: can.current, max: can.max}
|
||||
if (can.onmotion.cache(can, function() { can.file = can.base.Path(msg.Option(nfs.PATH), msg.Option(nfs.FILE))
|
||||
var p = can._cache_list[can.file]; if (p) { can.current = p.current, can.max = p.max }
|
||||
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg, cb) {
|
||||
if (can.onmotion.cache(can, function(cache_data) {
|
||||
can.file && (cache_data[can.file] = {current: can.current, max: can.max})
|
||||
can.file = can.base.Path(msg.Option(nfs.PATH), msg.Option(nfs.FILE))
|
||||
var p = cache_data[can.file]; p && (can.current = p.current, can.max = p.max)
|
||||
can.parse = can.base.Ext(can.file), can.Status("模式", "normal")
|
||||
can.onmotion.select(can, can._action, chat.DIV_TABS, msg._tab)
|
||||
return can.file
|
||||
}, can.ui.content, can.ui.profile_output, can.ui.display_output)) {
|
||||
return can.onaction.selectLine(can, parseInt(msg.Option(nfs.LINE)))
|
||||
return can.onaction.selectLine(can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb()
|
||||
}
|
||||
if (msg.Option(ctx.INDEX)) {
|
||||
can.onappend.plugin(can, {index: msg.Option(ctx.INDEX)}, function(sub) {
|
||||
sub.run = function(event, cmds, cb) {
|
||||
can.run(event, [ctx.ACTION, ice.RUN, msg.Option(ctx.INDEX)].concat(cmds), cb, true)
|
||||
}
|
||||
}, can.ui.content)
|
||||
return
|
||||
}
|
||||
|
||||
function init(p) { can.max = 0, can.core.List(can.ls = msg.Result().split(ice.NL), function(item) {
|
||||
can.onaction.appendLine(can, item)
|
||||
}), can.onaction.selectLine(can, msg.Option(nfs.LINE)||1) }
|
||||
}), can.onaction.selectLine(can, msg.Option(nfs.LINE)), can.base.isFunc(cb) && cb() }
|
||||
|
||||
var p = can.onsyntax[can.parse]; !p? can.run({}, [ctx.ACTION, mdb.PLUGIN, can.parse, msg.Option(nfs.FILE), msg.Option(nfs.PATH)], function(msg) {
|
||||
init(p = can.onsyntax[can.parse] = can.base.Obj(msg.Result()))
|
||||
}, true): init(p)
|
||||
},
|
||||
_parse: function(can, line) { line = can.page.replace(can, line||"")
|
||||
var p = can.onsyntax[can.parse]; if (!p) { return line }
|
||||
p = can.onsyntax[p.link]||p
|
||||
|
||||
function wrap(type, str) { return type? '<span class="'+type+'">'+str+'</span>': str }
|
||||
p.keyword && (line = can.core.List(can.core.Split(line, p.split&&p.split.space||ice.SP, p.split&&p.split.operator||"{[(|)]}", {detail: true}), function(item, index, array) {
|
||||
item = can.base.isObject(item)? item: {text: item}, p.word && (item = p.word(item, index, array))
|
||||
var text = item.text; var key = item.keyword||p.keyword[text]
|
||||
|
||||
var p = can.onsyntax[can.parse]; if (!p) { return line } p = can.onsyntax[p.link]||p, p.split = p.split||{}
|
||||
p.keyword && (line = can.core.List(can.core.Split(line, p.split.space||ice.SP, p.split.operator||"{[(|)]}", {detail: true}), function(item, index, array) {
|
||||
item = can.base.isObject(item)? item: {text: item}
|
||||
var text = item.text; var type = item.keyword||p.keyword[text]
|
||||
|
||||
switch (item.type) { case html.SPACE: return text
|
||||
case lang.STRING: return wrap(lang.STRING, item.left+text+item.right)
|
||||
default: return wrap(key, text)
|
||||
default: return wrap(type, text)
|
||||
}
|
||||
}).join(""))
|
||||
|
||||
p.prefix && can.core.Item(p.prefix, function(pre, type) {
|
||||
if (line.trim().indexOf(pre) == 0) {
|
||||
if (can.base.beginWith(line, pre)) {
|
||||
line = wrap(type, line)
|
||||
} else {
|
||||
var ls = line.split(pre); if (ls.length > 1) {
|
||||
@ -214,34 +233,43 @@ Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"],
|
||||
}
|
||||
}
|
||||
})
|
||||
p.suffix && can.core.Item(p.suffix, function(pre, type) {
|
||||
if (line.endsWith(pre)) { line = wrap(type, line) }
|
||||
p.suffix && can.core.Item(p.suffix, function(end, type) {
|
||||
if (can.base.endWith(line, end)) { line = wrap(type, line) }
|
||||
})
|
||||
return p.line? p.line(can, line): line
|
||||
return line
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {help: "控件交互", list: ["项目", "工具"],
|
||||
"项目": function(event, can) {
|
||||
can.onmotion.toggle(can, can.ui.project)
|
||||
can.onimport._content(can)
|
||||
Volcanos("onaction", {help: "控件交互", list: ["打开", "插件", "添加"],
|
||||
"打开": function(event, can) {
|
||||
can.user.input(event, can, [nfs.FILE], function(event, button, data, list, args) {
|
||||
can.onimport.tabview(can, can.Option(nfs.PATH), data.file)
|
||||
})
|
||||
},
|
||||
|
||||
"展示": function(event, can) { var msg = can.request(event, {_toast: "运行中..."})
|
||||
can.onimport.profile(can)
|
||||
"插件": function(event, can) {
|
||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data, list, args) {
|
||||
can.onimport.tabview(can, can.Option(nfs.PATH), data.index, ctx.INDEX)
|
||||
})
|
||||
},
|
||||
"添加": function(event, can) {
|
||||
can.user.input(event, can, [ctx.INDEX], function(event, button, data, list, args) {
|
||||
can.onimport.toolkit(can, data, function(sub) { can.toolkit[data.index] = data
|
||||
sub._legend.click(), sub.page.Select(sub, sub._target, html.OPTION_ARGS)[0].focus()
|
||||
})
|
||||
})
|
||||
},
|
||||
"项目": function(event, can) { can.onmotion.toggle(can, can.ui.project), can.onimport.layout(can) },
|
||||
"展示": function(event, can) { can.onimport.profile(can)
|
||||
can.run(event, [ctx.ACTION, mdb.ENGINE, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
||||
can.onimport.profile(can, msg)
|
||||
}, true)
|
||||
},
|
||||
"执行": function(event, can) { var msg = can.request(event, {_toast: "运行中..."})
|
||||
can.onimport.profile(can)
|
||||
"执行": function(event, can) { can.onimport.display(can)
|
||||
can.run(event, [ctx.ACTION, mdb.ENGINE, can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function(msg) {
|
||||
can.onimport.display(can, msg)
|
||||
}, true)
|
||||
},
|
||||
"工具": function(event, can) { can.onmotion.toggle(can, can.ui.toolkit.fieldset) },
|
||||
|
||||
back: function(event, can) {
|
||||
var last = can.history.pop(); last = can.history.pop()
|
||||
back: function(event, can) { can.history.pop(); var last = can.history.pop()
|
||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||
can.Status("跳转数", can.history.length)
|
||||
},
|
||||
@ -250,102 +278,65 @@ Volcanos("onaction", {help: "控件交互", list: ["项目", "工具"],
|
||||
var ui = can.page.Append(can, can.ui.content, [{type: html.TR, list: [
|
||||
{view: ["line unselectable", html.TD, ++can.max], onclick: function(event) {
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
|
||||
}, ondblclick: function(event) {
|
||||
can.onaction.favorLine(can, ui.text.innerText)
|
||||
}},
|
||||
|
||||
{view: [html.TEXT, html.TD], list: [can.onsyntax._parse(can, value)], onclick: function(event) {
|
||||
can.onaction._selectLine(can, ui)
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
|
||||
}, ondblclick: function(event) {
|
||||
can.onaction._searchLine(can, ui)
|
||||
var s = document.getSelection().toString(), str = ui.text.innerText
|
||||
var begin = str.indexOf(s), end = begin+s.length
|
||||
|
||||
for (var i = begin; i >= 0; i--) {
|
||||
if (str[i].match(/[a-zA-Z0-9_.]/)) { s = str.slice(i, end) } else { break }
|
||||
}
|
||||
|
||||
if (s.indexOf("kit.") == 0) { s = s.replace("kit.", "toolkits.") }
|
||||
if (s.indexOf(".") == 0) { s = s.slice(1) }
|
||||
can.onaction.searchLine(event, can, s)
|
||||
}}
|
||||
]}]); return ui.tr
|
||||
},
|
||||
modifyLine: function(can, line, value) {
|
||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||
if (item != line && index+1 != line) { return }
|
||||
|
||||
can.page.Select(can, item, "td.text", function(item) {
|
||||
can.page.Appends(can, item, [can.onsyntax._parse(can, value)])
|
||||
})
|
||||
})
|
||||
},
|
||||
rerankLine: function(can, value) { can.max = 0
|
||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||
can.max++, can.page.Select(can, item, "td.line", function(item) {
|
||||
item.innerText = index+1
|
||||
})
|
||||
})
|
||||
},
|
||||
selectLine: function(can, line) { if (!line) { return }
|
||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||
can.page.ClassList.del(can, item, html.SELECT)
|
||||
if (item != line && index+1 != line) { return }
|
||||
can.page.ClassList.add(can, item, html.SELECT)
|
||||
|
||||
line = item
|
||||
can.Option(nfs.LINE, index+1)
|
||||
can.Status("文件名", can.file)
|
||||
can.Status("解析器", can.parse)
|
||||
can.Status("当前行", can.onexport.position(can, index+1))
|
||||
if (!can.page.ClassList.set(can, item, html.SELECT, item == line || index+1 == line)) { return }
|
||||
line = item, can.Status(kit.Dict("文件名", can.file, "解析器", can.parse, "当前行", can.onexport.position(can, can.Option(nfs.LINE, index+1))))
|
||||
})
|
||||
|
||||
can.base.isObject(line) && can.page.Select(can, line, "td.text", function(item) {
|
||||
can.current = {
|
||||
scroll: function(x, y) {
|
||||
can.ui.content.scrollLeft += x
|
||||
can.ui.content.scrollTop += y
|
||||
// return can.ui.content.scrollBy(x, y)
|
||||
},
|
||||
scroll: function(x, y) { can.ui.content.scrollLeft += x, can.ui.content.scrollTop += y },
|
||||
window: function() { return can.ui.content.offsetHeight },
|
||||
offset: function() { return can.ui.content.scrollTop },
|
||||
height: function() { return line.offsetHeight },
|
||||
|
||||
prev: function() { return line.previousSibling },
|
||||
next: function() { return line.nextSibling },
|
||||
line: line, text: function(text) {
|
||||
return text != undefined && can.onaction.modifyLine(can, line, text), item.innerText
|
||||
}, height: function() { return line.offsetHeight },
|
||||
},
|
||||
}
|
||||
|
||||
var offhead = 5, size = 20
|
||||
var pos = can.current.line.offsetTop-can.current.offset(); if (pos < offhead*20) {
|
||||
can.current.scroll(0, pos-offhead*size)
|
||||
} else if (pos > can.current.window()/2) {
|
||||
can.current.scroll(0, pos-can.current.window()/2)
|
||||
}
|
||||
|
||||
var push = {path: can.Option(nfs.PATH), file: can.Option(nfs.FILE), line: can.Option(nfs.LINE)}
|
||||
can.base.Eq({path: push.path, file: push.file}, can.history[can.history.length-1]) || can.history.push(push)
|
||||
can.base.Eq({path: push.path, file: push.file, line: push.line}, can.history[can.history.length-1]) || can.history.push(push)
|
||||
can.Status("跳转数", can.history.length)
|
||||
})
|
||||
|
||||
if (can.current) { var offline = 5
|
||||
var pos = can.current.line.offsetTop-can.current.offset()
|
||||
if (pos > can.current.window()-offline*20) {
|
||||
can.current.scroll(0, pos-can.current.window()+offline*20)
|
||||
} else if (pos < offline*20) {
|
||||
can.current.scroll(0, pos-offline*20)
|
||||
}
|
||||
} can.onkeymap && can.onkeymap.selectLine(can)
|
||||
// can.onkeymap && can.onkeymap._mode(can, "insert")
|
||||
// can.onkeymap && can.onkeymap.selectLine(can)
|
||||
},
|
||||
searchLine: function(event, can, value) { if (!can.ui.search) { return }
|
||||
can.ui.search.Update(event, [ctx.ACTION, nfs.FIND, value.trim()])
|
||||
},
|
||||
_searchLine: function(can, ui) {
|
||||
var s = document.getSelection().toString(), str = ui.text.innerText
|
||||
var begin = str.indexOf(s), end = begin+s.length
|
||||
|
||||
for (var i = begin; i >= 0; i--) {
|
||||
if (str[i].match(/[a-zA-Z0-9_.]/)) {
|
||||
s = str.slice(i, end)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (s.indexOf("kit.") == 0) { s = s.replace("kit.", "toolkits.") }
|
||||
if (s.indexOf(".") == 0) { s = s.slice(1) }
|
||||
can.onaction.searchLine(event, can, s)
|
||||
},
|
||||
_selectLine: function(can, ui) {
|
||||
can.onkeymap && can.onkeymap._mode(can, "insert")
|
||||
can.onaction.selectLine(can, ui.tr)
|
||||
},
|
||||
|
||||
favorLine: function(can, value) {
|
||||
can.user.input(event, can, [{name: "zone", value: "hi"}, {name: "name", value: "hello"}], function(event, button, meta, list) {
|
||||
can.run(event, [ctx.ACTION, code.FAVOR, ctx.ACTION, mdb.INSERT, mdb.ZONE, meta.zone||"",
|
||||
@ -356,7 +347,7 @@ Volcanos("onaction", {help: "控件交互", list: ["项目", "工具"],
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: ["文件数", "解析器", "文件名", "当前行", "跳转数", "标签数"],
|
||||
position: function(can, index, total) { total = total || can.max
|
||||
position: function(can, index, total) { total = total||can.max
|
||||
return (parseInt(index))+ice.PS+parseInt(total)+" = "+parseInt((index)*100/total)+"%"
|
||||
},
|
||||
content: function(can) {
|
||||
|
@ -303,6 +303,22 @@ Volcanos("onaction", {help: "控件交互", list: ["run"],
|
||||
can.user.toastSuccess(can)
|
||||
}, true)
|
||||
},
|
||||
modifyLine: function(can, line, value) {
|
||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||
if (item != line && index+1 != line) { return }
|
||||
|
||||
can.page.Select(can, item, "td.text", function(item) {
|
||||
can.page.Appends(can, item, [can.onsyntax._parse(can, value)])
|
||||
})
|
||||
})
|
||||
},
|
||||
rerankLine: function(can, value) { can.max = 0
|
||||
can.page.Select(can, can.ui.content, html.TR, function(item, index) {
|
||||
can.max++, can.page.Select(can, item, "td.line", function(item) {
|
||||
item.innerText = index+1
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos("onexport", {help: "导出数据", list: ["文件数", "模式", "按键", "解析器", "文件名", "当前行", "跳转数"]})
|
||||
|
||||
|
@ -147,7 +147,7 @@ Volcanos("ondetail", {help: "交互操作", list: ["删除"], _init: function(ca
|
||||
show: function(sub, which) { sub.page.Modify(sub, sub.ui.content, {className: chat.CONTENT})
|
||||
sub.page.Select(sub, sub.ui.content, wiki.DIV_PAGE, function(page, index) {
|
||||
if (index == which || page == which) {
|
||||
sub.page.Select(sub, page, can.page.Keys(html.H1, html.H2, html.H3), function(item) { sub.Action("菜单", item.innerHTML) })
|
||||
sub.page.Select(sub, page, sub.page.Keys(html.H1, html.H2, html.H3), function(item) { sub.Action("菜单", item.innerHTML) })
|
||||
sub.onmotion.select(sub, sub.ui.project, html.DIV_ITEM, index)
|
||||
sub.Status(mdb.PAGE, index+1+ice.PS+sub.list.length)
|
||||
sub.page.ClassList.add(sub, page, html.SHOW)
|
||||
@ -157,12 +157,12 @@ Volcanos("ondetail", {help: "交互操作", list: ["删除"], _init: function(ca
|
||||
})
|
||||
},
|
||||
next: function(sub) {
|
||||
sub.page.Select(sub, sub.ui.content, can.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
||||
sub.page.Select(sub, sub.ui.content, sub.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
||||
page.nextSibling? sub.sup.ondetail.show(sub, page.nextSibling): sub.user.toast(sub, cli.END)
|
||||
})
|
||||
},
|
||||
prev: function(sub) {
|
||||
sub.page.Select(sub, sub.ui.content, can.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
||||
sub.page.Select(sub, sub.ui.content, sub.core.Keys(wiki.DIV_PAGE, ice.SHOW), function(page) {
|
||||
page.previousSibling? sub.sup.ondetail.show(sub, page.previousSibling): sub.user.toast(sub, cli.END)
|
||||
})
|
||||
},
|
||||
|
10
proto.js
10
proto.js
@ -293,6 +293,12 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args:
|
||||
if (!libs[0]) { return can.require(libs.slice(1), cb, each) }
|
||||
libs[0] = libs[0].toLowerCase()
|
||||
|
||||
if (libs[0] == "") {
|
||||
libs[0] = can._name.replace(".js", ".css")
|
||||
} else if (libs[0][0] != ice.PS && libs[0].indexOf(ice.HTTP) != 0) {
|
||||
libs[0] = can._name.slice(0, can._name.lastIndexOf(ice.PS)+1)+libs[0]
|
||||
}
|
||||
|
||||
// 请求模块
|
||||
var name = libs[0].split("?")[0]
|
||||
function next() { can._load(name, each), can.require(libs.slice(1), cb, each) }
|
||||
@ -323,6 +329,9 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args:
|
||||
getHeader: function(key, cb) { return can.get("Header", key, cb) },
|
||||
getAction: function(key, cb) { return can.get("Action", key, cb) },
|
||||
getActionSize: function(cb) { return can.get("Action", "size", cb) },
|
||||
openSearch: function(cmds, cb) {
|
||||
return can.search({}, [can.core.Keys("Search", "onimport", "select")].concat(cmds||[]), cb)
|
||||
},
|
||||
search: function(event, cmds, cb) { return can.run && can.run(event, ["_search"].concat(cmds), cb, true) },
|
||||
|
||||
Conf: function(key, value) { var res = can._conf
|
||||
@ -375,5 +384,6 @@ function can(tool) {
|
||||
Volcanos({name: "chat", panels: [
|
||||
{name: "Header", help: "标题栏", pos: "hide", state: ["time", "usernick", "avatar"]},
|
||||
{name: "Action", help: "工作台", pos: chat.MAIN, tool: tool},
|
||||
{name: "Search", help: "搜索框", pos: "auto"},
|
||||
]})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user