1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-26 17:24:05 +08:00

add button

This commit is contained in:
shaoying 2019-06-12 09:30:13 +08:00
parent 2c9479bca6
commit 842fbdba61
6 changed files with 80 additions and 32 deletions

View File

@ -1599,14 +1599,16 @@ func (m *Message) Cmd(args ...interface{}) *Message {
msg.TryCatch(msg, true, func(msg *Message) { msg.TryCatch(msg, true, func(msg *Message) {
msg.Log("cmd", "%s %s %v %v", c.Name, key, arg, msg.Meta["option"]) msg.Log("cmd", "%s %s %v %v", c.Name, key, arg, msg.Meta["option"])
if args := []string{}; x.Form != nil { for _, form := range []map[string]int{map[string]int{"page.limit": 1, "page.offset": 1}, x.Form} {
if args := []string{}; form != nil {
for i := 0; i < len(arg); i++ { for i := 0; i < len(arg); i++ {
if n, ok := x.Form[arg[i]]; ok { if n, ok := form[arg[i]]; ok {
if n < 0 { if n < 0 {
n += len(arg) - i n += len(arg) - i
} }
for j := i + 1; j <= i+n && j < len(arg); j++ { for j := i + 1; j <= i+n && j < len(arg); j++ {
if _, ok := x.Form[arg[j]]; ok { if _, ok := form[arg[j]]; ok {
n = j - i - 1 n = j - i - 1
} }
} }
@ -1622,6 +1624,7 @@ func (m *Message) Cmd(args ...interface{}) *Message {
} }
arg = args arg = args
} }
}
target := msg.target target := msg.target
msg.target = s msg.target = s

View File

@ -1417,6 +1417,8 @@ func Start(args ...string) bool {
} }
Pulse.Option("routine", 0) Pulse.Option("routine", 0)
Pulse.Option("page.limit", 10)
Pulse.Option("page.offset", 0)
if Index.Begin(Pulse, args...); Index.Start(Pulse, args...) { if Index.Begin(Pulse, args...); Index.Start(Pulse, args...) {
return Index.Close(Pulse, args...) return Index.Close(Pulse, args...)
} }

View File

@ -1127,11 +1127,10 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
"commit": map[string]interface{}{"args": []interface{}{"commit", "-am"}}, "commit": map[string]interface{}{"args": []interface{}{"commit", "-am"}},
"branch": map[string]interface{}{"args": []interface{}{"branch", "-v"}}, "branch": map[string]interface{}{"args": []interface{}{"branch", "-v"}},
"status": map[string]interface{}{"args": []interface{}{"status", "-sb"}}, "status": map[string]interface{}{"args": []interface{}{"status", "-sb"}},
"log": map[string]interface{}{"args": []interface{}{"log", "-n", "limit", "--reverse", "pretty", "date"}}, "log": map[string]interface{}{"args": []interface{}{"log", "-n", "@page.limit", "--skip", "@page.offset", "pretty", "date"}},
"trans": map[string]interface{}{ "trans": map[string]interface{}{
"date": "--date=format:%m/%d %H:%M", "date": "--date=format:%m/%d %H:%M",
"pretty": "--pretty=format:%h %ad %an %s", "pretty": "--pretty=format:%h %ad %an %s",
"limit": "10",
}, },
}, Help: "命令集合"}, }, Help: "命令集合"},
"paths": &ctx.Config{Name: "paths", Value: []interface{}{"var", "usr", "etc", "bin", ""}, Help: "文件路径"}, "paths": &ctx.Config{Name: "paths", Value: []interface{}{"var", "usr", "etc", "bin", ""}, Help: "文件路径"},
@ -1245,7 +1244,6 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
m.Assert(e) m.Assert(e)
m.Option("git_dir", wd) m.Option("git_dir", wd)
} }
m.Log("fuck", "what %v", arg[0])
cmds := []string{} cmds := []string{}
if v := m.Confv("git", []string{arg[0], "cmds"}); v != nil { if v := m.Confv("git", []string{arg[0], "cmds"}); v != nil {
@ -1264,8 +1262,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
args = append(args, arg[1:]...) args = append(args, arg[1:]...)
for i, _ := range args { for i, _ := range args {
args[i] = m.Parse(args[i]) v := m.Parse(args[i])
if v == args[i] || v == "" {
args[i] = kit.Select(args[i], m.Conf("git", []string{"trans", args[i]})) args[i] = kit.Select(args[i], m.Conf("git", []string{"trans", args[i]}))
} else {
args[i] = v
}
} }
m.Cmd("cli.system", "git", args).Echo("\n\n").CopyTo(m) m.Cmd("cli.system", "git", args).Echo("\n\n").CopyTo(m)

View File

@ -21,8 +21,8 @@ var page = Page({
page.storm.Size(sizes.storm, height) page.storm.Size(sizes.storm, height)
sizes.action == undefined && (sizes.action = page.action.clientHeight) sizes.action == undefined && (sizes.action = page.action.clientHeight)
sizes.source == undefined && (sizes.source = page.source.clientHeight) sizes.source == undefined && (sizes.source = page.source.clientHeight);
sizes.action == -1 && (sizes.action = height, sizes.source = 0) (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
page.action.Size(width, sizes.action) page.action.Size(width, sizes.action)
page.source.Size(width, sizes.source) page.source.Size(width, sizes.source)
@ -391,8 +391,20 @@ var page = Page({
"全屏": 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, action: -1, storm:0})
}, },
"添加": function(event, value) {
page.plugin && page.plugin.Clone()
},
"删除": function(event, value) {
page.plugin && page.plugin.Clear()
},
"加参": function(event, value) {
page.plugin.Append({})
},
"去参": function(event, value) {
page.input && page.plugin.Remove(page.input)
},
} }
return {"button": ["恢复", "缩小", "放大", "最高", "最宽", "最大", "全屏"], "action": pane.Action} return {"button": ["恢复", "缩小", "放大", "最高", "最宽", "最大", "全屏", "br", "添加", "删除", "加参", "去参"], "action": pane.Action}
}, },
initStorm: function(page, pane, form, output) { initStorm: function(page, pane, form, output) {
var river = "", index = -1 var river = "", index = -1
@ -568,11 +580,15 @@ var page = Page({
if (conf && conf["button"]) { if (conf && conf["button"]) {
var buttons = [] var buttons = []
conf.button.forEach(function(value, index) { conf.button.forEach(function(value, index) {
if (value == "br") {
buttons.push({type: "br"})
} else {
buttons.push({"button": [value, function(event) { buttons.push({"button": [value, function(event) {
typeof conf["action"] == "function" && conf["action"](value, event) typeof conf["action"] == "function" && conf["action"](value, event)
typeof conf["action"] == "object" && conf["action"][value](event, value) typeof conf["action"] == "object" && conf["action"][value](event, value)
pane.Button = value pane.Button = value
}]}) }]})
}
}) })
kit.InsertChild(pane, output, "div", buttons).className = "action "+form.dataset.componet_name kit.InsertChild(pane, output, "div", buttons).className = "action "+form.dataset.componet_name
} else if (conf) { } else if (conf) {
@ -586,7 +602,7 @@ var page = Page({
kit.isMobile && page.action.Action["最宽"]() kit.isMobile && page.action.Action["最宽"]()
ctx.Search("layout") && page.action.Action[ctx.Search("layout")]() ctx.Search("layout") && page.action.Action[ctx.Search("layout")]()
page.footer.Order({"text": "", "ip": ""}, ["ip", "text"]) page.footer.Order({"text": "", "ip": "", ".": "", ":":""}, ["ip", "text", ":", "."])
kit.isMobile && page.footer.Order({"text": "", "site": "", "ip": ""}, ["ip", "text", "site"]) kit.isMobile && page.footer.Order({"text": "", "site": "", "ip": ""}, ["ip", "text", "site"])
page.header.Order({"user": "", "logout": "logout"}, ["logout", "user"], function(event, item, value) { page.header.Order({"user": "", "logout": "logout"}, ["logout", "user"], function(event, item, value) {
switch (item) { switch (item) {

View File

@ -407,12 +407,28 @@ function Plugin(field, tool, args, plugin) {
index == total-1 || (index == total-2 && event.target.parentNode.nextSibling.childNodes[1].type == "button")? index == total-1 || (index == total-2 && event.target.parentNode.nextSibling.childNodes[1].type == "button")?
option.Runs(event): event.target.parentNode.nextSibling.childNodes[1].focus() option.Runs(event): event.target.parentNode.nextSibling.childNodes[1].focus()
} }
field.Clone = option.Clone = function() {
page.View(field.parentNode, "plugin", field.Meta, [], option.Run)
}
field.Clear = option.Clear = function() {
field.parentNode && field.parentNode.removeChild(field)
}
field.Remove = option.Remove = function(who) {
who.parentNode && who.parentNode.removeChild(who)
}
field.Select = option.Select = function(who) {
page.plugin = field
page.footer.State(".", field.id)
}
field.Append = option.Append = function(item) { field.Append = option.Append = function(item) {
var index = total var index = total
total += 1 total += 1
item.onfocus = function(event) { item.onfocus = function(event) {
page.plugin = field page.plugin = field
page.input = event.target
page.footer.State(".", field.id)
page.footer.State(":", index)
} }
item.onkeyup = function(event) { item.onkeyup = function(event) {
page.oninput(event, function(event) { page.oninput(event, function(event) {
@ -476,6 +492,8 @@ function Plugin(field, tool, args, plugin) {
var ui = kit.AppendChild(option, [{type: "div", list: [{type: "label", inner: item.label||""}, input]}]) var ui = kit.AppendChild(option, [{type: "div", list: [{type: "label", inner: item.label||""}, input]}])
page.plugin = field
page.input = ui[item.name]
item.imports && page.Sync(item.imports).change(function(value, old) { item.imports && page.Sync(item.imports).change(function(value, old) {
ui[item.name].value = value ui[item.name].value = value
}) })

View File

@ -563,11 +563,18 @@ kit = toolkit = {
obj.querySelectorAll(item).forEach(function(item, index) { obj.querySelectorAll(item).forEach(function(item, index) {
if (typeof cb == "function") { if (typeof cb == "function") {
var value = cb(item) var value = cb(item)
value && list.push(value) value != undefined && list.push(value)
} else { } else {
list.push(item) list.push(item)
} }
}) })
for (var i = list.length-1; i >= 0; i--) {
if (list[i] == "") {
list.pop()
} else {
break
}
}
return list return list
}, },
} }