1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-26 01:04:06 +08:00
This commit is contained in:
harveyshao 2022-04-30 02:04:31 +08:00
parent 788173b548
commit 078f9fb814
3 changed files with 239 additions and 2 deletions

122
frame.js
View File

@ -428,6 +428,124 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
})
return (code.scrollBy && code.scrollBy(0, 10000)), code
},
parse: function(can, list, target, type, data) { target = target||can._output, data = data || {}
if (!list) { return } else if (can.base.isArray(list)) {
return can.core.List(list, function(meta) { return can.onappend.parse(can, meta, target, type, data) })
} else if (can.base.isString(list)) {
var ls = can.core.Split(list, "", ":="); if (ls.length == 1) {
var meta = type? {type: type, name: ls[0]}: {type: ls[0]}
} else {
var meta = {name: ls[0]}; for (var i = 1; i < ls.length; i += 2) { switch (ls[i]) {
case ":": meta.type = ls[i+1]; break
case "=": meta.value = ls[i+1]; break
} }
}
} else if (can.base.isObject(list)) { var meta = list }
var item = {view: meta.type}, init; switch (meta.type) {
case "head": data = {}
init = function(target) {
data.head = target
can.page.ClassList.add(can, target, "layout")
}
break
case "left":
init = function(target) {
can.page.ClassList.add(can, target, "layout")
can.core.Timer(10, function() {
var height = target.parentNode.offsetHeight
can.page.Select(can, target.parentNode, "div.layout.head", function(item) {
height -= item.offsetHeight
})
can.page.Select(can, target.parentNode, "div.layout.foot", function(item) {
height -= item.offsetHeight
})
can.page.style(can, target, html.HEIGHT, height)
})
}
break
case "main":
init = function(target) {
data.main = target
var width = target.parentNode.offsetWidth
can.page.Select(can, target.parentNode, "div.layout.left", function(item) {
width -= item.offsetWidth+1
})
can.page.style(can, target, html.HEIGHT, height, html.WIDTH, width)
can.core.Timer(10, function() {
var height = target.parentNode.offsetHeight
can.page.Select(can, target.parentNode, "div.layout.head", function(item) {
height -= item.offsetHeight
})
can.page.Select(can, target.parentNode, "div.layout.foot", function(item) {
height -= item.offsetHeight
})
can.page.style(can, target, html.HEIGHT, height)
})
}
break
case "foot":
init = function(target) {
can.page.ClassList.add(can, target, "layout")
}
break
case "tabs":
var height = target.offsetHeight
item.list = [{view: "name"}, {view: "page", style: {width: 240}}], item._init = function(_target, ui) {
can.core.Timer(100, function() {
var height = target.offsetHeight
can.page.style(can, _target, html.HEIGHT, height-10)
can.page.style(can, ui.page, html.HEIGHT, height-10-(meta.style? 0: ui.name.offsetHeight))
})
can.page.Append(can, ui.page, [{view: "input", list: [{type: "input", onkeyup: function(event) {
can.page.Select(can, _target, ["div.page", html.DIV_ITEM], function(item) {
can.page.ClassList.set(can, item, "hide", item.innerText.indexOf(event.target.value) == -1)
})
}}]}])
can.core.List(meta.list, function(item, index) {
can.page.Append(can, ui.name, [{view: ["item", html.DIV, item.name||item], onclick: function(event) {
can.onmotion.select(can, _target, [["div.page", "div.list"]], index)
can.onmotion.select(can, ui.name, html.DIV_ITEM, index)
ui.page.scrollTo(0, 0)
}}])
can.page.Append(can, ui.page, [{view: ["item", html.DIV, item.name], onclick: function(event) {
can.page.ClassList.neg(can, event.target.nextSibling, html.SELECT)
can.onmotion.select(can, ui.name, html.DIV_ITEM, index)
}}, {view: ["list"], _init: function(target) { can.onappend.parse(can, item.list, target, "item", data) }}])
})
can.page.Select(can, ui.name, html.DIV_ITEM)[0].click()
}
break
case "plugin":
break
default:
}
item._init = item._init||function(target) { meta.list && can.onappend.parse(can, meta.list, target, type, data), can.base.isFunc(init) && init(target) }
if (can.base.isString(meta.style)) { item.className = meta.style }
if (can.base.isObject(meta.style)) { item.style = meta.style }
if (type == "item") {
can.page.Append(can, target, [{view: ["item", "div", meta.name||meta], onclick: function(event) {
switch (meta.type) {
case "plugin":
can.onappend.plugin(can, {index: meta.index}, function(sub) {
sub.ConfWidth(data.main.offsetWidth)
sub.run = function(event, cmds, cb, silent) {
can.run(event, can.misc.concat(can, [ctx.ACTION, ice.RUN, meta.index], cmds), cb, true)
}
}, data.main)
default:
meta.list && can.onmotion.toggle(can, event.target.nextSibling)
}
}}])
if (!meta.list) { return }
item.view = "list"
}
return can.page.Append(can, target, [item]).first
},
_plugin: function(can, value, meta, cb, target) {
meta.feature = can.base.getValid(meta.feature, can.base.Obj(value.meta))||{}
@ -710,9 +828,13 @@ Volcanos("onmotion", {help: "动态特效", list: [], _init: function(can, targe
return status
},
select: function(can, target, name, which) {
var old = can.page.Select(can, target, name, function(item, index) {
if (can.page.ClassList.has(can, item, "select")) { return index }
})[0]
can.page.Select(can, target, name, function(item, index) {
can.page.ClassList.set(can, item, html.SELECT, item == which || which == index)
})
return old
},
modify: function(can, target, cb, item) { var back = target.innerHTML, text = target.innerText
if (back.length > 120 || back.indexOf(ice.NL) > -1) {

View File

@ -188,7 +188,7 @@ Volcanos("page", {help: "用户界面", ClassList: {
// 递归节点
item.list && can.page.Append(can, node, item.list, value)
target && target.appendChild && target.appendChild(node)
can.base.isFunc(item._init) && item._init(node)
can.base.isFunc(item._init) && item._init(node, value)
})
return value
}),
@ -380,7 +380,7 @@ Volcanos("page", {help: "用户界面", ClassList: {
}
return can.page.Modify(can, target, {style: value}), value
},
Keys: function() { var list = []
Keys: function() { var list = [] // FS SP GT PT
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]
if (typeof v == lang.OBJECT) {
for (var j = 0; j < v.length; j++) {

View File

@ -31,3 +31,118 @@ div.output.form div.item {
div.output.form div.item div.label {
margin:5px 0px;
}
div.head {
height:32px;
background-color:#404040;
clear:both;
}
div.left {
background-color:blue; float:left;
}
div.main {
background-color:#cccccc; height:180px; width:180px; float:left;
overflow:auto;
}
div.foot {
height:32px; clear:both;
background-color:#404040;
}
div.left {
overflow:auto;
background-color:#323232;
}
div.left:hover {
background-color:#323232;
}
div.left div.item:hover {
background-color:#404040;
}
div.left div.item {
background-color:#323232;
}
div.tabs:hover {
background-color:#272727;
}
div.tabs div.list.select {
background-color:#323232;
}
div.tabs div.name {
float:left;
position:sticky;
top:5px;
}
div.tabs div.name div.item {
float:left;
padding:10px;
color:gray;
}
div.tabs div.name div.item.select {
background-color:#404040;
/* background-color:red; */
border-bottom:solid red 2px;
color:white;
}
div.tabs div.page {
overflow:auto;
clear:both;
}
div.tabs div.page>div.input {
position:sticky;
padding:5px;
top:0px;
}
div.tabs div.page>div.input input {
color:white;
background-color:#212121;
width:230px;
border:0;
}
div.tabs div.page>div.input input:focus {
border:0;
outline:none;
}
div.tabs div.page>div.item {
display:none; clear:both;
background-color:#404040;
}
div.tabs div.page>div.list {
clear:both;
}
div.tabs div.page>div.list {
display:none;
}
div.tabs div.page>div.list.select {
display:block;
}
div.tabs div.page div.list {
padding-left:20px;
}
div.tabs.left div.name {
float:left;
}
div.tabs.left div.name div.item.select {
border-right:solid red 2px;
}
div.tabs.left div.name div.item {
float:none;
border-bottom:none;
}
div.tabs.left div.page {
float:left;
clear:none;
}
div.tabs.left div.page>div.item {
display:block;
}
div.tabs.void div.name {
display:none;
}
div.tabs.void div.page>div.item {
display:block;
}