mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
opt require
This commit is contained in:
parent
d0044e0b43
commit
82d4af3592
15
frame.js
15
frame.js
@ -783,16 +783,13 @@ Volcanos("onmotion", {help: "动态交互", list: [], _init: function(can) {
|
||||
move: function(can, target, layout) { var begin
|
||||
target.onmousedown = function(event) {
|
||||
begin = {left: layout.left, top: layout.top, x: event.x, y: event.y}
|
||||
}
|
||||
}, target.onmouseup = function(event) { begin = null }
|
||||
|
||||
target.onmousemove = function(event) {
|
||||
if (event.target == target && begin) {
|
||||
layout.top = begin.top + event.y - begin.y
|
||||
layout.left = begin.left + event.x - begin.x
|
||||
can.page.Modify(can, target, {style: {left: layout.left, top: layout.top}})
|
||||
}
|
||||
}
|
||||
target.onmouseup = function(event) {
|
||||
begin = null
|
||||
if (!begin || !event.ctrlKey) { return }
|
||||
layout.top = begin.top + event.y - begin.y
|
||||
layout.left = begin.left + event.x - begin.x
|
||||
can.page.Modify(can, target, {style: {left: layout.left, top: layout.top}})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
13
lib/user.js
13
lib/user.js
@ -87,7 +87,7 @@ var user = Volcanos("user", {help: "用户模块",
|
||||
event.preventDefault()
|
||||
return ui
|
||||
},
|
||||
input: function(event, can, form, cb) {
|
||||
input: function(event, can, form, cb) { // form [ string, {_input: }, array, object, button ]
|
||||
function cbs(event, button) {
|
||||
var data = {}; var list = can.page.Select(can, ui.table, "select,input,textarea", function(item) {
|
||||
return data[item.name] = item.value
|
||||
@ -122,11 +122,12 @@ var user = Volcanos("user", {help: "用户模块",
|
||||
}
|
||||
return {type: ["tr"], list: [
|
||||
{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._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}: /* other */ item,
|
||||
/* other */ item,
|
||||
]},
|
||||
]}
|
||||
})},
|
||||
@ -137,7 +138,7 @@ var user = Volcanos("user", {help: "用户模块",
|
||||
}]}]},
|
||||
]}])
|
||||
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
|
||||
},
|
||||
|
@ -7,7 +7,9 @@ Volcanos("onfigure", {help: "控件详情", list: [],
|
||||
can._figure && can.page.Remove(can, can._figure.fieldset)
|
||||
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.Append(can, can._figure.action, [
|
||||
@ -25,5 +27,5 @@ Volcanos("onfigure", {help: "控件详情", list: [],
|
||||
}
|
||||
run()
|
||||
}},
|
||||
})
|
||||
}, ["/plugin/input/key.css"])
|
||||
|
||||
|
16
proto.js
16
proto.js
@ -52,32 +52,30 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, pack: {}, libs:
|
||||
return // 加载完成
|
||||
}
|
||||
|
||||
if (meta.cache[libs[0]]) {
|
||||
can._load(libs[0], each), can.require(libs.slice(1), cb, each)
|
||||
var source = !libs[0].endsWith("/") && (libs[0].indexOf(".") == -1? libs[0]+".js": libs[0]) || libs[0]
|
||||
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 // 缓存加载
|
||||
}
|
||||
|
||||
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 (can.user && source.indexOf("publish") == 0) {
|
||||
source += "?pod="+(can.user.Search(can, "pod")||"")
|
||||
libs[0] = source
|
||||
}
|
||||
if (can.user && source.indexOf("/publish") == 0) {
|
||||
source += "?pod="+(can.user.Search(can, "pod")||"")
|
||||
libs[0] = source
|
||||
}
|
||||
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)
|
||||
|
||||
} else if (source.endsWith(".css")) { var style = document.createElement("link")
|
||||
style.rel = "stylesheet", style.type = "text/css"
|
||||
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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user