forked from x/volcanos
opt date.js
This commit is contained in:
parent
a912f2f8a4
commit
e715794e76
11
frame.js
11
frame.js
@ -393,7 +393,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
} else { can.page.Append(can, target, [item]) }
|
||||
}
|
||||
}); return list } ui.list = append(target, type, list||[html.PROJECT, [[html.CONTENT, html.PROFILE], html.DISPLAY]])
|
||||
function calc(item, size, total) { return !ui.size[item]? size: ui.size[item] < 1? total*ui.size[item]: ui.size[item] }
|
||||
function calc(item, size, total) { return !ui.size[item]? can.base.isString(size)? parseInt(can.base.trimSuffix(size, "px")): size: ui.size[item] < 1? total*ui.size[item]: ui.size[item] }
|
||||
var defer = [], content_height, content_width; function layout(type, list, height, width) { var _width = width, _height = height; can.core.List(list, function(item) {
|
||||
if (item == html.CONTENT) { content_height = height, content_width = width
|
||||
return defer.push(function() { can.page.style(can, ui[item], html.HEIGHT, height, html.WIDTH, width) })
|
||||
@ -402,13 +402,12 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
if (type == FLOW) { var h = calc(item, ui[item].offsetHeight, height)
|
||||
if (can.base.isObject(meta)) { meta.layout(h, width) }
|
||||
can.page.style(can, ui[item], html.WIDTH, width), height -= h
|
||||
} else { var w = calc(item, ui[item].offsetWidth||_width/list.length, _width), h = height
|
||||
} else { var w = calc(item, ui[item].offsetWidth||ui[item].style.width||_width/list.length, _width), h = height
|
||||
if (can.base.isObject(meta)) { meta.layout(h, w = _width/list.length) }
|
||||
can.page.style(can, ui[item], html.HEIGHT, h, html.WIDTH, w), width -= w
|
||||
}
|
||||
}), can.core.List(list, function(item) { if (can.base.isArray(item)) { layout(type == FLOW? FLEX: FLOW, item, height, width) } }) }
|
||||
ui.layout = function(height, width, delay, cb) { can.onmotion.delay(can, function() { defer = [], layout(type, ui.list, height, width), defer.forEach(function(cb) { cb() }), cb && cb(content_height, content_width) }, delay||0) }
|
||||
return ui
|
||||
ui.layout = function(height, width, delay, cb) { can.onmotion.delay(can, function() { defer = [], layout(type, ui.list, height, width), defer.forEach(function(cb) { cb() }), cb && cb(content_height, content_width) }, delay||0) }; return ui
|
||||
},
|
||||
tabview: function(can, meta, list, target) { var ui = can.page.Append(can, target, [html.ACTION, html.OUTPUT])
|
||||
can.core.List(can.base.getValid(list, can.core.Item(meta)), function(name, index) {
|
||||
@ -446,7 +445,9 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
var input = meta.action||mdb.KEY, path = chat.PLUGIN_INPUT+input+nfs._JS; can.require([path], function(can) {
|
||||
function _cb(sub, value, old) { if (value == old) { return } can.base.isFunc(cb)? cb(sub, value, old): target.value = value }
|
||||
can.core.ItemCB(can.onfigure[input], function(key, on) { var last = target[key]||function(){}; target[key] = function(event) { can.misc.Event(event, can, function(msg) {
|
||||
function show(sub, cb) { can.base.isFunc(cb) && cb(sub, _cb), can.onlayout.figure(event, can, sub._target, false), can.onmotion.toggle(can, sub._target, true) }
|
||||
function show(sub, cb) { can.base.isFunc(cb) && cb(sub, _cb), can.onmotion.delay(can, function() {
|
||||
can.onlayout.figure(event, can, sub._target, false), can.onmotion.toggle(can, sub._target, true)
|
||||
}) }
|
||||
can.core.CallFunc(on, {event: event, can: can, meta: meta, cb: _cb, target: target, sub: target._can, last: last, cbs: function(cb) {
|
||||
target._can? show(target._can, cb): can.onappend._init(can, {type: html.INPUT, name: input, style: meta.name, mode: chat.FLOAT}, [path], function(sub) { sub.Conf(meta)
|
||||
sub.run = function(event, cmds, cb) { var msg = sub.request(event)
|
||||
|
15
index.css
15
index.css
@ -103,6 +103,7 @@ body>div.input textarea { height:120px; width:200px; }
|
||||
body>div.input input:not([type=button]) { width:200px; }
|
||||
body>div.input div.action input[type=button] { width:90px; }
|
||||
body>div.input div.action div { margin:5px; float:right; }
|
||||
body>div.input div.action { width:100%; }
|
||||
body>div.upload div.item { float:left; }
|
||||
body>div.upload div.output { border:red solid 1px; clear:both; }
|
||||
body>div.upload div.progress { background-color:red; height:10px; width:0; }
|
||||
@ -120,13 +121,13 @@ div.action>div.tabs { padding:5px; height:31px; }
|
||||
div.status>div.item { padding:5px; height:30px; }
|
||||
div.status>div.item>label { font-size:0.6rem; }
|
||||
/* display */
|
||||
form.option, div.action { display:contents; } form.option.hide, div.action.hide { display:none; }
|
||||
fieldset>form.option, fieldset>div.action { display:contents; } form.option.hide, div.action.hide { display:none; }
|
||||
form.option>div.item>label, div.action>div.item>label, .hidden, .hide { display:none; }
|
||||
form.option>div.cmd, form.option>div.textarea { width:100%; } textarea { resize:vertical; }
|
||||
legend, form.option, form.option>div.item, div.action, div.action>div.item, div.action>div.tabs, fieldset>div.status>div.item, div.layout.flex>* { float:left; }
|
||||
div.action, div.output, div.status, div.project, div.display, div.profile, div.content, table.content, table.content td, div.code, div.plug, div.story, div.toast, div.carte, fieldset.input { overflow:auto; }
|
||||
fieldset>div.output, fieldset>div.status, div.item.textarea, div.project div.item, div.content:not(.item), div.code, div.story[data-type=spark] { clear:both; }
|
||||
fieldset>div.status>legend { margin-left:2px; margin-right:0; float:right; clear:none; }
|
||||
fieldset>div.status>legend { margin-left:2px; margin-right:0; height:30px; float:right; clear:none; }
|
||||
fieldset.plugin:not(.output):not(.float):not(.full):not(.cmd) { padding:10px; margin:10px; }
|
||||
fieldset.plugin:not(.float):not(.full):not(.cmd)>legend { float:none; }
|
||||
fieldset.auto, fieldset.full, fieldset.float, div.float { position:fixed; z-index:10; }
|
||||
@ -153,6 +154,16 @@ div.carte.select.float { border-radius:0; }
|
||||
div.carte.select.float>div.item { text-align:center; }
|
||||
div.item.select span { margin-left:-20px; margin-right:10px; }
|
||||
div.item.select input { font-family:monospace; border-radius:0; min-width:60px; }
|
||||
div.project div.zone div.list { clear:both; }
|
||||
|
||||
body.en fieldset.input.date.float>div.action>div.item.select { margin:0 5px; }
|
||||
body.en fieldset.input.date.float>div.action>div.item.select select { width:65px; }
|
||||
body.en fieldset.input.date.float>div.action>div.item.select.year select { width:115px; }
|
||||
body.en fieldset.input.date.float>div.action>div.item.select.month select { width:115px; }
|
||||
body.zh fieldset.input.date.float>div.action>div.item.select { margin:0 5px; }
|
||||
body.zh fieldset.input.date.float>div.action>div.item.select select { width:68px; }
|
||||
body.zh fieldset.input.date.float>div.action>div.item.select.year select { width:95px; }
|
||||
body.zh fieldset.input.date.float>div.action>div.item.select.month select { width:95px; }
|
||||
/* hover */
|
||||
legend:hover { background-color:skyblue; }
|
||||
select:hover { background-color:gray; color:cyan; }
|
||||
|
@ -9,7 +9,7 @@ Volcanos("date", {
|
||||
var begin = new Date(first); begin.setDate(first.getDate()-first.getDay()); var end = new Date(last); end.setDate(last.getDate()+7-last.getDay())
|
||||
for (var day = new Date(begin); day < first; day.setDate(day.getDate()+1)) { _cb(day, mdb.PREV) }
|
||||
for (var day = new Date(first); day < last; day.setDate(day.getDate()+1)) { _cb(day, mdb.MAIN) }
|
||||
for (var day = new Date(last); day < end; day.setDate(day.getDate()+1)) { _cb(day, mdb.NEXT) }
|
||||
for (var day = new Date(last); day.getDay() != 0 && day < end; day.setDate(day.getDate()+1)) { _cb(day, mdb.NEXT) }
|
||||
return list
|
||||
},
|
||||
})
|
||||
|
@ -9,16 +9,11 @@ Volcanos(chat.ONFIGURE, {date: {
|
||||
MINUTE, function(event, can, button, value) { now.setMinutes(parseInt(value)||0), show(now) },
|
||||
SECOND, function(event, can, button, value) { now.setSeconds(parseInt(value)||0), show(now) },
|
||||
TODAY, function() { show(today) },
|
||||
|
||||
mdb.PREV, function() { now.setMonth(now.getMonth()-1), show(now) },
|
||||
YEAR, function(event, can, button, value) { now.setFullYear(parseInt(value)), show(now) },
|
||||
MONTH, function(event, can, button, value) { now.setMonth(parseInt(value)-1), show(now) },
|
||||
mdb.NEXT, function() { now.setMonth(now.getMonth()+1), show(now) },
|
||||
|
||||
"rand", function() { now.setDate((Math.random() * 100 - 50) + now.getDate()), show(now) },
|
||||
"over", function() { now.setFullYear(now.getFullYear()-1), show(now) },
|
||||
"come", function() { now.setFullYear(now.getFullYear()+1), show(now) },
|
||||
chat._TRANS, kit.Dict(TODAY, "今天", mdb.NEXT, "下一月", mdb.PREV, "上一月", "over", "去年", "come", "今年"),
|
||||
chat._TRANS, kit.Dict(TODAY, "今天", mdb.NEXT, "下一月", mdb.PREV, "上一月"),
|
||||
)), can._table = can.page.Appends(can, can._output, [{view: [chat.CONTENT, html.TABLE]}])._target
|
||||
target.value == "" && (now.setMinutes(now.getMinutes()>30? 30: 0), now.setSeconds(0))
|
||||
function show(now) { can.Action(YEAR, now.getFullYear()), can.Action(MONTH, now.getMonth()+1)
|
||||
@ -26,13 +21,12 @@ Volcanos(chat.ONFIGURE, {date: {
|
||||
can.page.Appends(can, can._table, can.date.List(can, function(event, day) { day.setHours(now.getHours()), day.setMinutes(now.getMinutes()), day.getSeconds(now.getSeconds()), _cb(day), can.close() }, now))
|
||||
var l = can.date.solar2lunar(now); can.page.Appends(can, can._status, [{view: "today", inner: [l.gzYear, l.Animal+"年", l.cnMonth, l.cnDay, l.lunarFestival||l.festival||l.Term, l.Astro].join(ice.SP)}])
|
||||
return now
|
||||
}
|
||||
show(now), can._show = function(d) { _cb(show(new Date(now.getTime()+d*24*3600*1000))) }
|
||||
} show(now), can._show = function(d) { d? _cb(show(now = new Date(now.getTime()+d*24*3600*1000))): _cb(show(now)) }
|
||||
})},
|
||||
onkeydown: function(event, can, meta, cb, target, sub, last) { if (sub && sub.hidden()) { return last(event) } switch (event.key) {
|
||||
case "n": can.page.SelectInput(can, sub._action, mdb.NEXT, function(target) { target.click() }); break
|
||||
case "p": can.page.SelectInput(can, sub._action, mdb.PREV, function(target) { target.click() }); break
|
||||
case "t": can.page.SelectInput(can, sub._action, "today", function(target) { target.click() }); break
|
||||
case "n": can.page.SelectInput(can, sub._action, mdb.NEXT, function(target) { target.click(), sub._show() }); break
|
||||
case "p": can.page.SelectInput(can, sub._action, mdb.PREV, function(target) { target.click(), sub._show() }); break
|
||||
case "t": can.page.SelectInput(can, sub._action, "today", function(target) { target.click(), sub._show() }); break
|
||||
case "j": sub._show(7); break
|
||||
case "k": sub._show(-7); break
|
||||
case "h": sub._show(-1); break
|
||||
|
Loading…
x
Reference in New Issue
Block a user