mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add inner.split
This commit is contained in:
parent
430d31d636
commit
2fce469514
15
frame.js
15
frame.js
@ -323,7 +323,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
||||
sub.onimport && sub.onimport._init(sub, sub.Conf(meta), list, function() {}, field)
|
||||
|
||||
meta.inputs && sub.onappend._option(sub, meta, list, cb)
|
||||
sub.onaction && sub.onappend._action(sub, sub._action, sub.onaction.list)
|
||||
sub.onaction && sub.onappend._action(sub, sub._action, meta.button || sub.onaction.list)
|
||||
sub.onexport && sub.onappend._status(sub, sub._status, sub.onexport.list)
|
||||
})
|
||||
return sub
|
||||
@ -528,6 +528,19 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
|
||||
board: function(can, target, type, msg, text) { text = text || can.page.Display(msg.Result())
|
||||
return text && can.page.Append(can, target, [{view: ["code", "div", text]}]).code
|
||||
},
|
||||
|
||||
plugin: function(can, value, cb, target) { value = value || {}
|
||||
can.run({}, ["action", "command", value.index], function(msg) {
|
||||
value.name = value.name || msg.name && msg.name[0] || "plugin"
|
||||
value.help = value.help || msg.help && msg.help[0] || "plugin"
|
||||
value.inputs = can.base.Obj(msg.list && msg.list[0] || "[]", [])
|
||||
value.feature = can.base.Obj(msg.meta && msg.meta[0] || "{}", {})
|
||||
|
||||
var plugin = can.onappend._init(can, value, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
||||
typeof cb == "function" && cb(sub, value)
|
||||
}, target || document.body)
|
||||
}, true)
|
||||
},
|
||||
}, [], function(can) {})
|
||||
Volcanos("onlayout", {help: "页面布局", list: [], _init: function(can, meta, list, cb, target) {
|
||||
if (can.user.Search(can, "share")) { return typeof cb == "function" && cb() }
|
||||
|
11
lib/page.js
11
lib/page.js
@ -30,13 +30,10 @@ var page = Volcanos("page", {help: "网页模块",
|
||||
typeof value == "string"? (target.innerHTML = value): can.core.Item(value, function(key, value) {
|
||||
typeof value != "object"? (target[key] = value): can.core.Item(value, function(sub, value) {
|
||||
var size = {
|
||||
"width": true, "height": true,
|
||||
"max-height": true,
|
||||
"min-height": true,
|
||||
"margin-left": true,
|
||||
"margin-top": true,
|
||||
"left": true, "right": true,
|
||||
"top": true, "bottom": true,
|
||||
"width": true, "max-width": true, "min-width": true,
|
||||
"height": true, "max-height": true, "min-height": true,
|
||||
"left": true, "right": true, "top": true, "bottom": true,
|
||||
"margin-top": true, "margin-left": true,
|
||||
}
|
||||
if (size[sub] && (typeof value == "number" || !value.endsWith("px"))) {
|
||||
value += "px"
|
||||
|
@ -1,4 +1,6 @@
|
||||
Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb, target) {
|
||||
can.Conf("content") && (msg = can.request({}), msg.result = [can.Conf("content")])
|
||||
|
||||
can.ui = can.page.Appends(can, target, [
|
||||
{view: "project", style: {display: "none"}},
|
||||
{view: "profile", list: [
|
||||
@ -27,13 +29,6 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
|
||||
]}, {view: "tags"}, ]},
|
||||
])
|
||||
|
||||
if (can.Conf("content")) {
|
||||
msg = can.request({})
|
||||
msg.result = [can.Conf("content")]
|
||||
}
|
||||
|
||||
can.user.isMobile || can.page.Modify(can, can.ui.content, {style: {"min-width": document.body.innerWidth-200+"px"}})
|
||||
can.user.isMobile || can.page.Modify(can, can.ui.profile, {style: {"min-width": document.body.innerWidth-100+"px"}})
|
||||
|
||||
can.tabview = {}, can.history = []
|
||||
can.tabview[can.Option("path")+can.Option("file")] = msg
|
||||
@ -169,14 +164,6 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
||||
var last = can.history.pop(); last = can.history.pop()
|
||||
last && can.onimport.tabview(can, last.path, last.file, last.line)
|
||||
},
|
||||
"运行": function(event, can) {
|
||||
can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "none"}})
|
||||
can.run(event, ["action", "engine", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||
(msg.Result() || msg.append && msg.append.length > 0) && can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "block"}})
|
||||
can.onappend.table(can, can.ui.display, "table", msg)
|
||||
can.onappend.board(can, can.ui.display, "board", msg)
|
||||
}, true)
|
||||
},
|
||||
"项目": function(event, can) { var hide = can.ui.project.style.display == "none"
|
||||
can.page.Modify(can, can.ui.project, {style: {display: hide? "": "none"}})
|
||||
var width = can._target.offsetWidth - can.ui.project.offsetWidth - can.ui.preview.offsetWidth - 120
|
||||
@ -188,6 +175,14 @@ Volcanos("onaction", {help: "控件交互", list: [],
|
||||
can.page.Modify(can, can.ui.search, {style: {display: hide? "": "none"}})
|
||||
hide && can.onaction.searchLine(event, can, "")
|
||||
},
|
||||
"运行": function(event, can) {
|
||||
can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "none"}})
|
||||
can.run(event, ["action", "engine", can.parse, can.Option("file"), can.Option("path")], function(msg) {
|
||||
(msg.Result() || msg.append && msg.append.length > 0) && can.page.Modify(can, can.ui.display, {innerHTML: "", style: {display: "block"}})
|
||||
can.onappend.table(can, can.ui.display, "table", msg)
|
||||
can.onappend.board(can, can.ui.display, "board", msg)
|
||||
}, true)
|
||||
},
|
||||
|
||||
appendLine: function(can, value) { var index = ++can.max
|
||||
can.page.Append(can, can.ui.preview, [{view: ["item", "div", index], onclick: function(event) {
|
||||
|
@ -108,28 +108,12 @@ Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "横向",
|
||||
return
|
||||
}
|
||||
|
||||
tree.inner = can.onappend._init(can, {name: "inner", help: "源码", inputs: [
|
||||
{type: "text", name: "path", value: can.Option("path")},
|
||||
{type: "text", name: "file", value: tree.file},
|
||||
{type: "text", name: "line", value: tree.line},
|
||||
{type: "button", name: "查看", value: "auto"},
|
||||
{type: "button", name: "关闭"},
|
||||
], index: "web.code.inner", feature: {
|
||||
display: "/plugin/local/code/inner.js", style: "editor", width: 800, height: 600,
|
||||
}}, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
|
||||
sub.run = function(event, cmds, cb, silent) { var msg = can.request(event)
|
||||
if (msg.Option("_action") == "关闭") {
|
||||
can.page.Remove(can, tree.inner._target)
|
||||
return
|
||||
}
|
||||
can.run(event, ["inner"].concat(cmds), cb, true)
|
||||
}
|
||||
}, document.body)
|
||||
|
||||
can.page.Modify(can, tree.inner._target, {style: {position: "fixed",
|
||||
can.onaction._show(can, [can.Option("path"), tree.file, tree.line], {
|
||||
position: "fixed",
|
||||
left: event.x-(event.x>600? 400: 100),
|
||||
top: event.y-(event.y>600? 400: 0),
|
||||
}})
|
||||
width: 600, height: 600,
|
||||
})
|
||||
}
|
||||
tree.view.onmouseenter = function(event) {
|
||||
can.page.Remove(can, can.pos)
|
||||
@ -163,6 +147,90 @@ Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "横向",
|
||||
offset += item.height*30
|
||||
})
|
||||
},
|
||||
_resize: function(can, layout) {
|
||||
can.page.Modify(can, can._target, {style: layout})
|
||||
can.page.Select(can, can._output, "div.profile", function(item) {
|
||||
can.page.Modify(can, item, {style: {
|
||||
"max-height": layout.height,
|
||||
"width": layout.width,
|
||||
}})
|
||||
})
|
||||
can.page.Select(can, can._output, "div.content", function(item) {
|
||||
can.page.Modify(can, item, {style: {
|
||||
"max-width": layout.width - 120,
|
||||
}})
|
||||
})
|
||||
},
|
||||
_show: function(can, args, layout) {
|
||||
can.onappend.plugin(can, {index: "web.code.inner", args: args, _action: ["最大", "上下", "左右", "复制", "重围", "关闭"], width: layout.width, height: layout.height}, function(sub, value) {
|
||||
can.onaction._resize(sub, layout)
|
||||
|
||||
var begin
|
||||
sub._target.onmousedown = function(event) {
|
||||
begin = {left: layout.left, top: layout.top, x: event.x, y: event.y}
|
||||
console.log(begin)
|
||||
}
|
||||
sub._target.onmousemove = function(event) {
|
||||
if (event.target == sub._target && begin) {
|
||||
layout.left= begin.left + event.x - begin.x
|
||||
layout.top= begin.top + event.y - begin.y
|
||||
sub.page.Modify(sub, sub._target, {style: {left: layout.left, top: layout.top}})
|
||||
console.log(layout)
|
||||
}
|
||||
}
|
||||
sub._target.onmouseup = function(event) {
|
||||
begin = null
|
||||
}
|
||||
|
||||
sub.run = function(event, cmds, cb, silent) {
|
||||
switch (cmds[1]) {
|
||||
case "复制":
|
||||
can.onaction._show(can, args, {
|
||||
position: "fixed",
|
||||
left: layout.left+100, top: layout.top+100,
|
||||
width: layout.width, height: layout.height,
|
||||
})
|
||||
break
|
||||
case "重围":
|
||||
can.onaction._resize(sub, layout)
|
||||
break
|
||||
case "上下":
|
||||
layout.height = layout.height/2-20
|
||||
can.onaction._resize(sub, layout)
|
||||
|
||||
can.onaction._show(can, args, {
|
||||
position: "fixed",
|
||||
left: layout.left, top: layout.top+layout.height+70,
|
||||
width: layout.width, height: layout.height,
|
||||
})
|
||||
break
|
||||
case "左右":
|
||||
layout.width = layout.width/2
|
||||
can.onaction._resize(sub, layout)
|
||||
|
||||
can.onaction._show(can, args, {
|
||||
position: "fixed",
|
||||
left: layout.left+layout.width+10, top: layout.top,
|
||||
width: layout.width-10, height: layout.height,
|
||||
})
|
||||
break
|
||||
case "最大":
|
||||
layout.left = 0, layout.top = 0
|
||||
layout.width = window.innerWidth-40
|
||||
layout.height = window.innerHeight-60
|
||||
can.onaction._resize(sub, layout)
|
||||
break
|
||||
case "关闭":
|
||||
can.page.Remove(can, sub._target)
|
||||
break
|
||||
default:
|
||||
can.run(event, ["inner"].concat(cmds), function(msg) {
|
||||
cb(msg), can.onaction._resize(sub, layout)
|
||||
}, true)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
"横向": function(event, can) { var sub = can.sub
|
||||
can.width = 0
|
||||
@ -176,7 +244,4 @@ Volcanos("onaction", {help: "组件菜单", list: ["编辑", ["view", "横向",
|
||||
"纵向": function(event, can) {
|
||||
},
|
||||
})
|
||||
Volcanos("onchoice", {help: "组件交互", list: []})
|
||||
Volcanos("ondetail", {help: "组件详情", list: []})
|
||||
Volcanos("onexport", {help: "导出数据", list: ["date", "begin", "add", "del", "close", "note"]})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user