mirror of
https://shylinux.com/x/ContextOS
synced 2025-06-26 18:07:30 +08:00
opt layout
This commit is contained in:
parent
ce7d698550
commit
d9a40b1c82
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-09-22 22:04:56", "com", 640,
|
"2019-09-23 11:05:14", "centos", 565,
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,32 @@
|
|||||||
var page = Page({check: true,
|
var page = Page({check: true,
|
||||||
conf: {refresh: 1000, border: 4, layout: {header:30, river:120, action:180, source:60, storm:100, footer:30}},
|
conf: {refresh: 1000, border: 4, first: "工作", mobile: "工作", layout: {header:30, footer:30, river:100, storm:100, action:180, source:45}},
|
||||||
onlayout: function(event, sizes) {
|
onlayout: function(event, sizes) {
|
||||||
var page = this
|
var page = this
|
||||||
kit.isWindows && (document.body.style.overflow = "hidden")
|
|
||||||
|
|
||||||
var height = document.body.clientHeight-page.conf.border
|
var height = document.body.clientHeight-page.conf.border
|
||||||
var width = document.body.clientWidth-page.conf.border
|
var width = document.body.clientWidth-page.conf.border
|
||||||
page.conf.height = height
|
kit.device.isWindows && (document.body.style.overflow = "hidden")
|
||||||
page.conf.width = width
|
|
||||||
|
|
||||||
sizes = sizes || {}
|
sizes = sizes || {}
|
||||||
sizes.header == undefined && (sizes.header = page.header.clientHeight)
|
sizes.header == undefined && (sizes.header = page.header.clientHeight)
|
||||||
sizes.footer == undefined && (sizes.footer = page.footer.clientHeight)
|
sizes.footer == undefined && (sizes.footer = page.footer.clientHeight)
|
||||||
page.header.Pane.Size(width, sizes.header)
|
page.header.Pane.Size(width, sizes.header)
|
||||||
page.footer.Pane.Size(width, sizes.footer)
|
page.footer.Pane.Size(width, sizes.footer)
|
||||||
|
height -= page.header.offsetHeight+page.footer.offsetHeight
|
||||||
|
|
||||||
sizes.river == undefined && (sizes.river = page.river.clientWidth)
|
sizes.river == undefined && (sizes.river = page.river.clientWidth)
|
||||||
sizes.storm == undefined && (sizes.storm = page.storm.clientWidth)
|
sizes.storm == undefined && (sizes.storm = page.storm.clientWidth)
|
||||||
height -= page.header.offsetHeight+page.footer.offsetHeight
|
|
||||||
page.river.Pane.Size(sizes.river, height)
|
page.river.Pane.Size(sizes.river, height)
|
||||||
page.storm.Pane.Size(sizes.storm, height)
|
page.storm.Pane.Size(sizes.storm, height)
|
||||||
|
|
||||||
var full = false
|
|
||||||
if (kit.device.isMobile && sizes.action == -1) {
|
|
||||||
full = true
|
|
||||||
}
|
|
||||||
sizes.action == undefined && (sizes.action = page.action.clientHeight)
|
|
||||||
sizes.source == undefined && (sizes.source = page.source.clientHeight);
|
|
||||||
(sizes.action == -1 || sizes.source == 0) && (sizes.action = height, sizes.source = 0)
|
|
||||||
width -= page.river.offsetWidth+page.storm.offsetWidth
|
width -= page.river.offsetWidth+page.storm.offsetWidth
|
||||||
|
|
||||||
|
sizes.action == -1 && (sizes.action = kit.device.isMobile? "": height, sizes.target = 0, sizes.source = 0)
|
||||||
|
sizes.action == undefined && (sizes.action = page.action.clientHeight)
|
||||||
|
sizes.source == undefined && (sizes.source = page.source.clientHeight)
|
||||||
page.action.Pane.Size(width, sizes.action)
|
page.action.Pane.Size(width, sizes.action)
|
||||||
full && (page.action.style.height = "")
|
|
||||||
page.source.Pane.Size(width, sizes.source)
|
page.source.Pane.Size(width, sizes.source)
|
||||||
|
height -= sizes.target==0? height: page.source.offsetHeight+page.action.offsetHeight
|
||||||
|
|
||||||
height -= page.source.offsetHeight+page.action.offsetHeight
|
|
||||||
page.target.Pane.Size(width, height)
|
page.target.Pane.Size(width, height)
|
||||||
kit.History.add("lay", sizes)
|
|
||||||
},
|
},
|
||||||
oncontrol: function(event, target, action) {
|
oncontrol: function(event, target, action) {
|
||||||
var page = this
|
var page = this
|
||||||
@ -253,11 +243,29 @@ var page = Page({check: true,
|
|||||||
ui.first.value = ""
|
ui.first.value = ""
|
||||||
},
|
},
|
||||||
Size: function(width, height) {
|
Size: function(width, height) {
|
||||||
field.style.display = (width<=0 || height<=0)? "none": "block"
|
if (width > 0) {
|
||||||
field.style.width = width+"px"
|
field.style.width = width+"px"
|
||||||
field.style.height = height+"px"
|
ui.first.style.width = (width-7)+"px"
|
||||||
ui.first.style.width = (width-7)+"px"
|
field.style.display = "block"
|
||||||
ui.first.style.height = (height-7)+"px"
|
} else if (width === "") {
|
||||||
|
field.style.width = ""
|
||||||
|
field.style.display = "block"
|
||||||
|
} else {
|
||||||
|
field.style.display = "none"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height > 0) {
|
||||||
|
field.style.height = height+"px"
|
||||||
|
ui.first.style.height = (height-7)+"px"
|
||||||
|
field.style.display = "block"
|
||||||
|
} else if (height === "") {
|
||||||
|
field.style.height = ""
|
||||||
|
field.style.display = "block"
|
||||||
|
} else {
|
||||||
|
field.style.display = "none"
|
||||||
|
return
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -361,6 +369,8 @@ var page = Page({check: true,
|
|||||||
|
|
||||||
pane.clear(), pane.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
|
pane.clear(), pane.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
|
||||||
pane.Core(event, line, args, cbs)
|
pane.Core(event, line, args, cbs)
|
||||||
|
}, function(msg) {
|
||||||
|
!page.plugin && output.querySelector("fieldset.item").Plugin.Select()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Layout: function(name) {var pane = field.Pane
|
Layout: function(name) {var pane = field.Pane
|
||||||
@ -380,35 +390,23 @@ var page = Page({check: true,
|
|||||||
Action: {
|
Action: {
|
||||||
"聊天": function(event, value) {
|
"聊天": function(event, value) {
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
page.onlayout(event)
|
|
||||||
page.onlayout(event)
|
|
||||||
},
|
},
|
||||||
"办公": function(event, value) {
|
"办公": function(event, value) {
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
page.onlayout(event, {river: 0, action:300, source:60})
|
page.onlayout(event, {river: 0, action:300})
|
||||||
page.onlayout(event)
|
|
||||||
page.onlayout(event)
|
|
||||||
},
|
},
|
||||||
"工作": function(event, value) {
|
"工作": function(event, value) {
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
page.onlayout(event, {river:0, action:-1, source:60})
|
page.onlayout(event, {river:0, action:-1})
|
||||||
page.onlayout(event)
|
|
||||||
page.onlayout(event)
|
|
||||||
},
|
},
|
||||||
"最高": function(event, value) {
|
"最高": function(event, value) {
|
||||||
page.onlayout(event, {action: -1})
|
page.onlayout(event, {action: -1})
|
||||||
page.onlayout(event)
|
|
||||||
page.onlayout(event)
|
|
||||||
},
|
},
|
||||||
"最宽": function(event, value) {
|
"最宽": function(event, value) {
|
||||||
page.onlayout(event, {river:0, storm:0})
|
page.onlayout(event, {river:0, storm:0})
|
||||||
page.onlayout(event)
|
|
||||||
page.onlayout(event)
|
|
||||||
},
|
},
|
||||||
"最大": function(event, value) {
|
"最大": function(event, value) {
|
||||||
page.onlayout(event, {header:0, footer:0, river:0, action: -1, storm:0})
|
page.onlayout(event, {header:0, footer:0, river:0, storm:0, action: -1})
|
||||||
page.onlayout(event)
|
|
||||||
page.onlayout(event)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"刷新": function(event, value) {
|
"刷新": function(event, value) {
|
||||||
@ -470,17 +468,12 @@ var page = Page({check: true,
|
|||||||
"返回": function(event, value) {
|
"返回": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Last()
|
page.plugin && page.plugin.Plugin.Last()
|
||||||
},
|
},
|
||||||
"推送": function(event, value) {
|
|
||||||
if (page.socket) {return}
|
|
||||||
page.socket = page.WSS()
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
|
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
|
||||||
"", "刷新", "清屏", "并行", "串行",
|
"", "刷新", "清屏", "并行", "串行",
|
||||||
"", ["display", "表格", "编辑", "绘图"],
|
"", ["display", "表格", "编辑", "绘图"],
|
||||||
"", "添加", "删除", "加参", "减参",
|
"", "添加", "删除", "加参", "减参",
|
||||||
"", "执行", "下载", "清空", "返回",
|
"", "执行", "下载", "清空", "返回",
|
||||||
"", "推送",
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -641,15 +634,7 @@ var page = Page({check: true,
|
|||||||
page.onaction[item] && page.onaction[item](event, item, value, page)
|
page.onaction[item] && page.onaction[item](event, item, value, page)
|
||||||
})
|
})
|
||||||
page.river.Pane.Show(), page.pane = page.action, page.plugin = kit.Selector(page.action, "fieldset")[0]
|
page.river.Pane.Show(), page.pane = page.action, page.plugin = kit.Selector(page.action, "fieldset")[0]
|
||||||
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.device.isMobile? "办公": "工作")
|
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.device.isMobile? page.conf.first: page.conf.mobile)
|
||||||
|
page.WSS()
|
||||||
function conn() {
|
|
||||||
page.socket = page.WSS(null, function() {
|
|
||||||
page.socket.close()
|
|
||||||
}, function() {
|
|
||||||
setTimeout(conn, 1000)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
conn()
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -438,7 +438,7 @@ function Page(page) {
|
|||||||
return typeof page[args[0]] == "function" && kit._call(page[args[0]], args.slice(1))
|
return typeof page[args[0]] == "function" && kit._call(page[args[0]], args.slice(1))
|
||||||
},
|
},
|
||||||
WSS: function(cb, onerror, onclose) {
|
WSS: function(cb, onerror, onclose) {
|
||||||
return ctx.WSS(cb || (function(m) {
|
return page.socket || (page.socket = ctx.WSS(cb || (function(m) {
|
||||||
if (m.detail) {
|
if (m.detail) {
|
||||||
page.action.Pane.Core(event, m, ["_cmd", m.detail], function(msg) {
|
page.action.Pane.Core(event, m, ["_cmd", m.detail], function(msg) {
|
||||||
m.reply(msg)
|
m.reply(msg)
|
||||||
@ -446,7 +446,15 @@ function Page(page) {
|
|||||||
} else {
|
} else {
|
||||||
page.ontoast(m.result.join(""))
|
page.ontoast(m.result.join(""))
|
||||||
}
|
}
|
||||||
}), onerror, onclose)
|
|
||||||
|
}), onerror || (function() {
|
||||||
|
page.socket.close()
|
||||||
|
|
||||||
|
}), onclose || (function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
page.WSS(cb, onerror, onclose)
|
||||||
|
}, 1000)
|
||||||
|
})))
|
||||||
},
|
},
|
||||||
|
|
||||||
initToast: function() {},
|
initToast: function() {},
|
||||||
@ -583,7 +591,7 @@ function Pane(page, field) {
|
|||||||
})
|
})
|
||||||
return ui
|
return ui
|
||||||
},
|
},
|
||||||
Update: function(cmds, type, key, which, first, cb) {
|
Update: function(cmds, type, key, which, first, cb, cbs) {
|
||||||
pane.Runs(cmds, function(line, index, msg) {
|
pane.Runs(cmds, function(line, index, msg) {
|
||||||
var ui = pane.Append(type, line, key, which, cb)
|
var ui = pane.Append(type, line, key, which, cb)
|
||||||
if (typeof first == "string") {
|
if (typeof first == "string") {
|
||||||
@ -591,6 +599,9 @@ function Pane(page, field) {
|
|||||||
} else {
|
} else {
|
||||||
first && index == 0 && ui.first.click()
|
first && index == 0 && ui.first.click()
|
||||||
}
|
}
|
||||||
|
if (index == msg[msg.append[0]].length-1) {
|
||||||
|
typeof cbs == "function" && cbs(msg)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Select: function(index, key) {
|
Select: function(index, key) {
|
||||||
@ -664,9 +675,27 @@ function Pane(page, field) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Size: function(width, height) {
|
Size: function(width, height) {
|
||||||
field.style.display = (width<=0 || height<=0)? "none": "block"
|
if (width > 0) {
|
||||||
field.style.width = width+"px"
|
field.style.width = width+"px"
|
||||||
field.style.height = height+"px"
|
field.style.display = "block"
|
||||||
|
} else if (width === "") {
|
||||||
|
field.style.width = ""
|
||||||
|
field.style.display = "block"
|
||||||
|
} else {
|
||||||
|
field.style.display = "none"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height > 0) {
|
||||||
|
field.style.height = height+"px"
|
||||||
|
field.style.display = "block"
|
||||||
|
} else if (height === "") {
|
||||||
|
field.style.height = ""
|
||||||
|
field.style.display = "block"
|
||||||
|
} else {
|
||||||
|
field.style.display = "none"
|
||||||
|
return
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Dialog: function(width, height) {
|
Dialog: function(width, height) {
|
||||||
if (field.style.display != "block") {
|
if (field.style.display != "block") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user