From ac6f14877c0fb9a77d7ec6674e987027f997bbb5 Mon Sep 17 00:00:00 2001 From: shylinux Date: Wed, 3 May 2023 23:23:59 +0800 Subject: [PATCH] opt macos --- frame.js | 14 ++++++++++---- plugin/input/date.js | 2 +- plugin/local/chat/iframe.js | 5 +---- plugin/local/team/plan.js | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/frame.js b/frame.js index 30f94686..d63a67ab 100644 --- a/frame.js +++ b/frame.js @@ -226,7 +226,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { return can.onengine._plugin(event, can, msg, can, cmds, cb) || can.run(event, cmds, function(msg) { if (can.base.isFunc(cb)) { return cb(msg) } if (silent) { return } var _can = can._fields? can.sup: can; if (_can == (msg._can._fields? msg._can.sup: msg._can)) { if (can.core.CallFunc([_can, chat.ONIMPORT, ice.MSG_PROCESS], {can: _can, msg: msg})) { return } } - if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.CREATE, mdb.INSERT, mdb.IMPORT, mdb.EXPORT, "exports", "imports", nfs.TRASH) || msg.Length() == 0 && !msg.Result()) { return can.user.toastSuccess(can, cmds[1]), can.Update() } } + if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.CREATE, mdb.INSERT, mdb.PRUNES, mdb.IMPORT, mdb.EXPORT, "exports", "imports", nfs.TRASH) || msg.Length() == 0 && !msg.Result()) { return can.user.toastSuccess(can, cmds[1]), can.Update() } } can.onappend._output(can, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display) }) }, @@ -680,9 +680,9 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { begin = {left: target.offsetLeft, top: target.offsetTop, width: target.offsetWidth, height: target.offsetHeight, x: event.x, y: event.y} can.page.SelectChild(can, target.parentNode, html.FIELDSET, function(target) { can.page.style(can, target, "z-index") && can.page.style(can, target, "z-index", 9) }), can.page.style(can, target, "z-index", 10) window._scroll = _window.onmousemove - }, _window.onmouseup = function(event) { target = null, begin = {} } + }, _window.onmouseup = function(event) { target = null, begin = {}, delete(window._scroll) } _window.onmousemove = function(event) { - if (target) { can.onkeymap.prevent(event) + if (window._scroll) { can.onkeymap.prevent(event) switch (action) { case "left": can.page.style(can, target, html.LEFT, can.base.Min(begin.left + event.x - begin.x, 0, window.innerWidth-target.offsetWidth)) @@ -691,6 +691,10 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { case "right": cb? cb(target.offsetHeight, begin.width + event.x - begin.x): can.page.style(can, target, html.WIDTH, begin.width + event.x - begin.x); break + case "top": + can.page.style(can, target, html.TOP, can.base.Min(begin.top + event.y - begin.y, top, window.innerHeight-target.offsetHeight)) + cb? cb(begin.height + begin.y - event.y, target.offsetWidth): can.page.style(can, target, html.HEIGHT, begin.height + begin.y - event.y) + break case "bottom": cb? cb(begin.height + event.y - begin.y, target.offsetWidth): can.page.style(can, target, html.HEIGHT, begin.height + event.y - begin.y) break @@ -701,7 +705,7 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { ) } } else { var _target = findTarget(event); if (!_target) { return } - var x = event.x - _target.offsetLeft, y = event.y - _target.offsetTop, margin = 32 + var x = event.x - _target.offsetLeft, y = event.y - _target.offsetTop, margin = 20 if (-margin < x && x < margin) { action = "left" can.page.style(can, _target, "cursor", "ew-resize") } else if (_target.offsetWidth-margin < x && x < _target.offsetWidth+margin) { action = "right" @@ -709,6 +713,8 @@ Volcanos(chat.ONMOTION, {_init: function(can, target) { } else if (_target.offsetHeight-margin < y && y < _target.offsetHeight+margin) { action = "bottom" can.page.style(can, _target, "cursor", "ns-resize") } else if (-margin < y && y < margin) { action = "top" + can.page.style(can, _target, "cursor", "ns-resize") + } else if (margin < y && y < (can._fields? can.sup: can).onexport.actionHeight(can._fields? can.sup: can)) { action = "top" can.page.style(can, _target, "cursor", "move") } else { action = "" can.page.style(can, _target, "cursor", "") diff --git a/plugin/input/date.js b/plugin/input/date.js index 7b48076b..b2d01bbc 100644 --- a/plugin/input/date.js +++ b/plugin/input/date.js @@ -14,7 +14,7 @@ Volcanos(chat.ONFIGURE, {date: { MONTH, function(event, can, button, value) { now.setMonth(parseInt(value)-1), show(now) }, mdb.NEXT, function() { now.setMonth(now.getMonth()+1), show(now) }, chat._TRANS, kit.Dict(TODAY, "今天", mdb.NEXT, "下一月", mdb.PREV, "上一月"), - )), can._table = can.page.Appends(can, can._output, [{view: [chat.CONTENT, html.TABLE]}])._target + )), can._table = can.page.Appends(can, can._output, [{view: [chat.CONTENT, html.TABLE], list: [{type: html.TBODY}]}]).tbody 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) can.Action(HOUR, now.getHours()), can.Action(MINUTE, parseInt(now.getMinutes()/5)*5), can.Action(SECOND, parseInt(now.getSeconds()/5)*5) diff --git a/plugin/local/chat/iframe.js b/plugin/local/chat/iframe.js index 55101924..a1ea0c5b 100644 --- a/plugin/local/chat/iframe.js +++ b/plugin/local/chat/iframe.js @@ -1,11 +1,8 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg) { can.current = msg.TableDetail(), can.onimport.layout(can) }, - layout: function(can) { var item = can.current; can.sup.onexport.title(can, item.name||item.link.split("?")[0]) + layout: function(can) { var item = can.current; can.sup.onexport.title(can, item.name||item.link.split(mdb.QS)[0]) var target = can.page.Appends(can, can._output, [{type: html.IFRAME, src: item.link, height: can.ConfHeight(), width: can.ConfWidth(), style: {border: 0}}])._target - can.onmotion.delay(can, function() { - can.page.style(can, target.contentDocument.body, "background-color", "transparent") - }) }, }) Volcanos(chat.ONACTION, {open: function(event, can) { can.user.open(can.current.link) }}) diff --git a/plugin/local/team/plan.js b/plugin/local/team/plan.js index acbd3565..17b8b9c2 100644 --- a/plugin/local/team/plan.js +++ b/plugin/local/team/plan.js @@ -7,12 +7,12 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( }, _content: function(can, msg, head, list, key, get, set) { var begin_time = can.base.Date(can.Option(team.BEGIN_TIME)); can.sup.task && (can.sup.task._target = null) var hash = {}; msg.Table(function(value, index) { var k = key(can.base.Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value]) }) - can.ui.table = can.page.Append(can, can.ui.content, [{view: [[chat.CONTENT, team.PLAN], html.TABLE], list: can.core.List(list, function(hour, row) { + can.ui.table = can.page.Append(can, can.ui.content, [{view: [[chat.CONTENT, team.PLAN], html.TABLE], list: [{type: html.TBODY, list: can.core.List(list, function(hour, row) { return {type: html.TR, list: can.core.List(head, function(week, col) { if (row == 0) { return {text: [can.user.trans(can, week), html.TH]} } if (col == 0) { return {text: [hour, html.TH]} } return can.onimport._task(can, msg, get(begin_time, col, row, hash), set(begin_time, col, row)) })} - }) }])._target, can.onmotion.delay(can, function() { var target = can.sup.task && can.sup.task._target; target && target.click(), can.Status(mdb.COUNT, msg.Length()) }) + }) }] }])._target, can.onmotion.delay(can, function() { var target = can.sup.task && can.sup.task._target; target && target.click(), can.Status(mdb.COUNT, msg.Length()) }) }, _task: function(can, msg, list, time) { return {type: html.TD, className: time == can.base.Time().slice(0, time.length)? html.SELECT: "", ondblclick: function(event) { can.onaction.insertTask(event, can, time+can.base.Time().slice(time.length)) },