1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-26 01:04:06 +08:00

opt require

This commit is contained in:
shaoying 2020-09-17 07:04:32 +08:00
parent d0044e0b43
commit 82d4af3592
4 changed files with 24 additions and 26 deletions

View File

@ -783,16 +783,13 @@ Volcanos("onmotion", {help: "动态交互", list: [], _init: function(can) {
move: function(can, target, layout) { var begin move: function(can, target, layout) { var begin
target.onmousedown = function(event) { target.onmousedown = function(event) {
begin = {left: layout.left, top: layout.top, x: event.x, y: event.y} begin = {left: layout.left, top: layout.top, x: event.x, y: event.y}
} }, target.onmouseup = function(event) { begin = null }
target.onmousemove = function(event) { target.onmousemove = function(event) {
if (event.target == target && begin) { if (!begin || !event.ctrlKey) { return }
layout.top = begin.top + event.y - begin.y layout.top = begin.top + event.y - begin.y
layout.left = begin.left + event.x - begin.x layout.left = begin.left + event.x - begin.x
can.page.Modify(can, target, {style: {left: layout.left, top: layout.top}}) can.page.Modify(can, target, {style: {left: layout.left, top: layout.top}})
}
}
target.onmouseup = function(event) {
begin = null
} }
}, },
}) })

View File

@ -87,7 +87,7 @@ var user = Volcanos("user", {help: "用户模块",
event.preventDefault() event.preventDefault()
return ui return ui
}, },
input: function(event, can, form, cb) { input: function(event, can, form, cb) { // form [ string, {_input: }, array, object, button ]
function cbs(event, button) { function cbs(event, button) {
var data = {}; var list = can.page.Select(can, ui.table, "select,input,textarea", function(item) { var data = {}; var list = can.page.Select(can, ui.table, "select,input,textarea", function(item) {
return data[item.name] = item.value return data[item.name] = item.value
@ -122,11 +122,12 @@ var user = Volcanos("user", {help: "用户模块",
} }
return {type: ["tr"], list: [ return {type: ["tr"], list: [
{type: "td", list: [{text: typeof item == "string"? item: item.length > 0? item[0]: item.name || ""}]}, {type: "td", list: [{text: typeof item == "string"? item: item.length > 0? item[0]: item.name || ""}]},
{type: "td", list: [typeof item == "string"? /* input */ {input: item, data: {autofocus: true}}: {type: "td", list: [typeof item == "string"? /* input */ {input: item, data: {autofocus: true}, _init: _init}:
item._input == "textarea"? /* textarea */ {type: "textarea", data: item, _init: _init}:
item._input == "select"? /* select */ {select: [[item.name].concat(item.values)], data: item}:
item._input? /* input */ {type: "input", data: (item.type = item._input, item), _init: _init}:
item.length > 0? /* select */ {select: [item]}: item.length > 0? /* select */ {select: [item]}:
item._input == "textarea"? /* textarea */ {type: "textarea", data: item, _init: _init}: /* other */ item,
item._input == "select"? /* select */ {select: [[item.name].concat(item.values)], data: item}:
item._input? /* input */ {type: "input", data: (item.type = item._input, item), _init: _init}: /* other */ item,
]}, ]},
]} ]}
})}, })},
@ -137,7 +138,7 @@ var user = Volcanos("user", {help: "用户模块",
}]}]}, }]}]},
]}]) ]}])
can.page.Select(can, ui.first, "input", function(item, index) { can.page.Select(can, ui.first, "input", function(item, index) {
index == 0 && (item.setSelectionRange(0, -1), item.focus()) index == 0 && (item.focus(), item.setSelectionRange(0, -1))
}) })
return ui return ui
}, },

View File

@ -7,7 +7,9 @@ Volcanos("onfigure", {help: "控件详情", list: [],
can._figure && can.page.Remove(can, can._figure.fieldset) can._figure && can.page.Remove(can, can._figure.fieldset)
can._figure = can.onappend.field(can, document.body, "input key", {}) can._figure = can.onappend.field(can, document.body, "input key", {})
can.page.Modify(can, can._figure.fieldset, {style: {top: event.clientY+10, left: event.clientX}}) var layout = {top: event.clientY+10, left: event.clientX}
can.onmotion.move(can, can._figure.fieldset, layout)
can.page.Modify(can, can._figure.fieldset, {style: layout})
can.page.Remove(can, can._figure.legend) can.page.Remove(can, can._figure.legend)
can.page.Append(can, can._figure.action, [ can.page.Append(can, can._figure.action, [
@ -25,5 +27,5 @@ Volcanos("onfigure", {help: "控件详情", list: [],
} }
run() run()
}}, }},
}) }, ["/plugin/input/key.css"])

View File

@ -52,32 +52,30 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, pack: {}, libs:
return // 加载完成 return // 加载完成
} }
if (meta.cache[libs[0]]) { var source = !libs[0].endsWith("/") && (libs[0].indexOf(".") == -1? libs[0]+".js": libs[0]) || libs[0]
can._load(libs[0], each), can.require(libs.slice(1), cb, each) var target = source.endsWith(".css")? (can._head||document.head): (can._body||document.body)
if (meta.cache[source]) {
can._load(source, each), can.require(libs.slice(1), cb, each)
return // 缓存加载 return // 缓存加载
} }
var target = libs[0].endsWith(".css")? (can._head||document.head): (can._body||document.body)
var source = !libs[0].endsWith("/") && (libs[0].indexOf(".") == -1? libs[0]+".js": libs[0]) || libs[0]
if (source.endsWith(".js")) { var script = document.createElement("script") if (source.endsWith(".js")) { var script = document.createElement("script")
if (can.user && source.indexOf("publish") == 0) { if (can.user && source.indexOf("publish") == 0) {
source += "?pod="+(can.user.Search(can, "pod")||"") source += "?pod="+(can.user.Search(can, "pod")||"")
libs[0] = source
} }
if (can.user && source.indexOf("/publish") == 0) { if (can.user && source.indexOf("/publish") == 0) {
source += "?pod="+(can.user.Search(can, "pod")||"") source += "?pod="+(can.user.Search(can, "pod")||"")
libs[0] = source
} }
script.src = source, script.onload = function() { script.src = source, script.onload = function() {
can._load(libs[0], each), can.require(libs.slice(1), cb, each) can._load(source, each), can.require(libs.slice(1), cb, each)
} // 加载脚本 } // 加载脚本
target.appendChild(script) target.appendChild(script)
} else if (source.endsWith(".css")) { var style = document.createElement("link") } else if (source.endsWith(".css")) { var style = document.createElement("link")
style.rel = "stylesheet", style.type = "text/css" style.rel = "stylesheet", style.type = "text/css"
style.href = source; style.onload = function() { style.href = source; style.onload = function() {
can._load(libs[0], each), can.require(libs.slice(1), cb, each) can._load(source, each), can.require(libs.slice(1), cb, each)
} // 加载样式 } // 加载样式
target.appendChild(style) target.appendChild(style)
} }