forked from x/volcanos
opt user.trans
This commit is contained in:
parent
1984669651
commit
052537ef04
2
frame.js
2
frame.js
@ -1033,4 +1033,4 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _init: function(can, targe
|
||||
if (target._keys.length == 0) { event.stopPropagation(), event.preventDefault() }
|
||||
},
|
||||
})
|
||||
|
||||
var _can_name = ""
|
||||
|
11
lib/user.js
11
lib/user.js
@ -36,7 +36,12 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
can.user.isMobile && (name += " mobile") && can.user.isLandscape && (name += " landscape")
|
||||
can.page.Modify(can, document.body, {className: name})
|
||||
},
|
||||
trans: function(can, text) { if (typeof text == "function") { text = text.name || "" }
|
||||
trans: function(can, text) {
|
||||
if (typeof text == "object") {
|
||||
return can.core.Item(text, function(k, v) { can.core.Value(can._trans, k, v) })
|
||||
}
|
||||
|
||||
if (typeof text == "function") { text = text.name || "" }
|
||||
return can._trans&&can._trans[text] || can.Conf("trans."+text) || can.Conf("feature.trans."+text) || {
|
||||
"submit": "提交", "cancel": "取消",
|
||||
"open": "打开", "close": "关闭",
|
||||
@ -180,7 +185,7 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
target.value = target.value || msg.Option(item.name)
|
||||
}
|
||||
|
||||
return {type: "tr", list: [{type: "td", list: [{text: item.name||""}]}, {type: "td", list: [item]} ]}
|
||||
return {type: "tr", list: [{type: "td", list: [{text: can.user.trans(can, item.name)||""}]}, {type: "td", list: [item]} ]}
|
||||
})},
|
||||
{view: "action"},
|
||||
]}]); can.onlayout.figure(event, can, ui._target)
|
||||
@ -190,7 +195,7 @@ Volcanos("user", {help: "用户操作", agent: {
|
||||
_engine: function(event, can, button) { action.submit(event, can, button) },
|
||||
submit: function(event, can, button) { var data = {}, args = [], list = []
|
||||
list = can.page.Select(can, ui.table, "textarea,input,select", function(item) {
|
||||
return args.push(item.name, item.value), data[item.name] = item.value
|
||||
return item.name && item.value && args.push(item.name, item.value), data[item.name] = item.value
|
||||
})
|
||||
can.base.isFunc(cb) && !cb(event, button, data, list, args) && action.cancel()
|
||||
}, _target: ui._target,
|
||||
|
@ -240,9 +240,9 @@ div.toast a {
|
||||
color:yellow;
|
||||
}
|
||||
div.toast div.title {
|
||||
float:left; word-break:break-all;
|
||||
color:#cae850; font-size:14px;
|
||||
cursor:copy;
|
||||
float:left;
|
||||
}
|
||||
div.toast div.duration {
|
||||
color:gray; font-size:14px;
|
||||
@ -286,10 +286,9 @@ div.input {
|
||||
z-index:50;
|
||||
}
|
||||
div.input textarea {
|
||||
width:145px;
|
||||
padding:4px;
|
||||
margin:2px;
|
||||
height:45px;
|
||||
background-color:cyan;
|
||||
margin:2px; padding:4px;
|
||||
width:145px; height:45px;
|
||||
}
|
||||
div.input div.item {
|
||||
float:left;
|
||||
|
@ -9,7 +9,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<script src="/proto.js"></script>
|
||||
<script src="/frame.js"></script>
|
||||
<script src="/page/cache.js"></script>
|
||||
<script src="/page/index.js"></script>
|
||||
</body>
|
||||
|
@ -122,6 +122,7 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg,
|
||||
},
|
||||
|
||||
create: function(event, can) {
|
||||
can.user.trans(can, {type: "类型", name: "群名", text: "简介"})
|
||||
can.user.input(event, can, [
|
||||
{name: "type", values: ["public", "protected", "private"]},
|
||||
{name: "name", value: "hi"}, {type: "textarea", name: "text", value: "hello"},
|
||||
@ -164,12 +165,12 @@ Volcanos("ondetail", {help: "菜单交互", list: ["共享群组", "添加用户
|
||||
})
|
||||
},
|
||||
"添加应用": function(event, can, button, river) {
|
||||
can.user.trans(can, {type: "类型", name: "名称", text: "简介"})
|
||||
can.user.input(event, can, [
|
||||
["类型", "public", "protected", "private"],
|
||||
{name: "名称", value: "hi"},
|
||||
{name: "简介", value: "hello"},
|
||||
], function(event, button, meta, list) {
|
||||
can.run({}, [river, "tool", can._ACTION, "create"].concat(["type", list[0], "name", list[1], "text", list[2]]), function(msg) {
|
||||
{name: "type", values: ["public", "protected", "private"]},
|
||||
{name: "name", value: "hi"}, {name: "text", value: "hello"},
|
||||
], function(event, button, meta, list, args) {
|
||||
can.run({}, [river, "tool", can._ACTION, "create"].concat(args), function(msg) {
|
||||
can.user.Search(can, {river: river, storm: msg.Result()})
|
||||
})
|
||||
})
|
||||
|
5
proto.js
5
proto.js
@ -17,13 +17,13 @@ var Volcanos = shy("火山架", {args: {}, pack: {}, libs: [], cache: {}}, [], f
|
||||
meta.libs = Config.libs, meta.volcano = Config.volcano
|
||||
|
||||
// 预加载
|
||||
var Preload = [Config.volcano]; for (var i = 0; i < Config.panels.length; i++) { var panel = Config.panels[i]
|
||||
var Preload = []; for (var i = 0; i < Config.panels.length; i++) { var panel = Config.panels[i]
|
||||
panel && (Preload = Preload.concat(panel.list = panel.list || ["/panel/"+panel.name+".css", "/panel/"+panel.name+".js"]))
|
||||
}; Preload = Preload.concat(Config.plugin)
|
||||
|
||||
// 根模块
|
||||
name = Config.name, can = {_follow: Config.name, _target: document.body}
|
||||
libs = Preload.concat(Config.main.list, Config.libs), cb = function(can) {
|
||||
libs = Preload.concat(Config.main.list, Config.libs, Config.volcano), cb = function(can) {
|
||||
can.onengine._init(can, can.Conf(Config), Config.panels, function(msg) {}, can._target)
|
||||
}
|
||||
}
|
||||
@ -47,6 +47,7 @@ var Volcanos = shy("火山架", {args: {}, pack: {}, libs: [], cache: {}}, [], f
|
||||
typeof cb == "function" && setTimeout(function() { cb(can) }, 10)
|
||||
return // 加载完成
|
||||
}
|
||||
libs[0] = libs[0].toLowerCase()
|
||||
|
||||
// 请求模块
|
||||
function next() { can._load(libs[0], each), can.require(libs.slice(1), cb, each) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user