diff --git a/const.js b/const.js index 9cf1aa50..d4ee457f 100644 --- a/const.js +++ b/const.js @@ -154,6 +154,7 @@ var nfs = { USR_INTSHELL: "usr/intshell", USR_LEARNING: "usr/learning", REQUIRE: "/require/", REQUIRE_MODULES: "/require/modules/", SHARE_LOCAL: "/share/local/", + SHARE_CACHE: "/share/cache/", WIKI_PORTAL: "/wiki/portal/", CHAT_PORTAL: "/chat/portal/", DF: ice.DF, PS: ice.PS, PT: ice.PT, diff --git a/frame.js b/frame.js index bbf3064f..663d62da 100644 --- a/frame.js +++ b/frame.js @@ -350,8 +350,10 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { var table = can.page.AppendTable(can, msg, target||can._output, msg.append, cb||function(value, key, index, data, list) { if (msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE) { if (key == mdb.VALUE) { key = data.key } data = {}, can.core.List(list, function(item) { data[item.key] = item.value }) } function run(event, cmd, arg) { can.misc.Event(event, can, function(msg) { can.run(can.request(event, data, can.Option()), [ctx.ACTION, cmd].concat(arg)) }) } + function img(p) { return can.page.Format(html.IMG, p, msg.IsDetail()? 128: 48, msg.IsDetail()? null: 48) } if (key == web.SPACE && value) { value = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: value}), value) } - if (key == mdb.ICONS && value) { value = can.page.Format(html.IMG, can.misc.Resource(can, data[key]), msg.IsDetail()? 128: 48, msg.IsDetail()? null: 48) } + if (key == nfs.IMAGE && value) { value = can.core.List(can.core.Split(data[key]), function(item) { return img(can.misc.ShareCache(can, item)) }).join("") } + if (key == mdb.ICONS && value) { value = img(can.misc.Resource(can, data[key])) } if (key == mdb.NAME) { value = can.user.trans(can, value, null, html.INPUT) } return {text: [msg.IsDetail() && key == mdb.KEY? can.user.trans(can, value, null, html.INPUT): can.user.trans(can, value, null, html.VALUE), html.TD], onclick: function(event) { var target = event.target if (key == cli.QRCODE && can.page.tagis(event.target, html.IMG)) { can.user.opens(event.target.title) } @@ -581,6 +583,7 @@ Volcanos(chat.ONLAYOUT, {_init: function(can, target) { target = target||can._ro } } if (layout.left+target.offsetWidth > left+width) { layout.left = (right? rect.left: left+width)-target.offsetWidth-1 } + layout.left = can.base.Min(layout.left, 0), layout.top = can.base.Min(layout.top, 32) can.page.style(can, target, html.MAX_HEIGHT, top+height-layout.top) }); can.onmotion.move(can, target, layout), can.onmotion.slideGrow(can, target) diff --git a/lib/misc.js b/lib/misc.js index 13661ef2..5db8afba 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -152,6 +152,9 @@ Volcanos("misc", { ShareLocal(can, path, space) { if (can.base.beginWith(path, web.HTTP, nfs.PS)) { return path } return can.base.MergeURL(nfs.SHARE_LOCAL+path, ice.POD, space||can.Conf(web.SPACE)) }, + ShareCache(can, path, space) { if (can.base.beginWith(path, web.HTTP, nfs.PS)) { return path } + return can.base.MergeURL(nfs.SHARE_CACHE+path, ice.POD, space||can.Conf(web.SPACE)) + }, Template(can, path, file) { return can.base.Path(nfs.SRC_TEMPLATE, can.ConfIndex(), path, file) }, MergePath: function(can, file, path) { return file.indexOf(nfs.PS) == 0 || file.indexOf(ice.HTTP) == 0? file: can.base.Path(path, file) }, MergeCache: function(can, hash, pod) { return can.base.MergeURL(can.misc.MergeURL(can, {_path: can.base.Path(web.SHARE_CACHE, hash)}, true), ice.POD, pod) }, diff --git a/lib/user.js b/lib/user.js index f761b922..30730b6d 100644 --- a/lib/user.js +++ b/lib/user.js @@ -231,6 +231,7 @@ Volcanos("user", { ui.show.innerHTML = value+"%", value == 0 && action.begin(event) ui.size.innerHTML = can.base.Size(loaded)+nfs.PS+can.base.Size(total) can.page.styleWidth(can, ui.progress, value*(ui.output.offsetWidth-2)/100) + if (silent) { can.user.toast(can, ui.size.innerHTML, ui.cost.innerHTML, -1, value) } }, _target: ui._target, }); can.page.Select(can, ui.action, html.INPUT_FILE)[0].click(), silent && can.onmotion.hidden(can, ui._target); return action }, diff --git a/plugin/input/img.js b/plugin/input/img.js index bb812d00..c2fc781c 100644 --- a/plugin/input/img.js +++ b/plugin/input/img.js @@ -1,7 +1,7 @@ Volcanos(chat.ONFIGURE, {img: { _init: function(can, meta, target) { target.value == meta.value && (target.value = ""); var images = can.core.Split(target.value) - var count = parseInt(meta.value||"1"), width = target.parentNode.offsetWidth-22; for (var n = 1; n < 10; n++) { if (n*n >= count) { width = width/n; break } } width -= 1 - function add(target, hash) { target._hash = hash, can.page.Appends(can, target, [{img: can.base.MergeURL(can.misc.MergeURL(can, {_path: web.SHARE_CACHE+hash}, true), ice.POD, meta.space), height: width, width: width}]) } + var count = parseInt(meta.value||"1"), width = target.parentNode.offsetWidth-22; for (var n = 1; n < 10; n++) { if (n*n >= count) { width = width/n; break } } width -= 2 + function add(target, hash) { target._hash = hash, can.page.Appends(can, target, [{img: can.base.MergeURL(can.misc.MergeURL(can, {_path: web.SHARE_CACHE+hash}, true), {pod: meta.space||undefined}), height: width, width: width}]) } function set() { target.value = can.page.SelectChild(can, target.parentNode, html.DIV, function(target) { return target._hash }).join(mdb.FS) } can.onmotion.hidden(can, target) for (var i = 0; i < count; i++) {