forked from x/volcanos
opt draw.js
This commit is contained in:
parent
28fcaa1af5
commit
c8334e8bbd
@ -136,7 +136,10 @@ Volcanos("base", {
|
||||
if (this.isArray(args)) { for (var i = args.length-1; i >= 0; i--) { if (!args[i]) { args.pop() } else { break } } }
|
||||
return args
|
||||
},
|
||||
trimPrefix: function(str, pre) { if (str.indexOf(pre) == -1) { return str } return str.slice(pre.length) },
|
||||
trimPrefix: function(str, pre) { var callee = arguments.callee
|
||||
if (arguments.length > 2) { for (var i = 1; i < arguments.length; i++) { str = callee(str, arguments[i]) } return str }
|
||||
if (str.indexOf(pre) == -1) { return str } return str.slice(pre.length)
|
||||
},
|
||||
trimSuffix: function(str, end) { var index = str.lastIndexOf(end); if (index == -1 || index+end.length != str.length) { return str } return str.slice(0, index) },
|
||||
join: function(list, sp) { return (list||[]).join(sp||ice.SP) },
|
||||
joins: function(list, inner, outer) { for (var i = 0; i < list.length; i++) { list[i] = typeof list[i] == lang.STRING? list[i]: list[i].join(inner||ice.FS) } return list.join(outer||ice.SP) },
|
||||
|
52
lib/lunar.js
52
lib/lunar.js
@ -1,4 +1,4 @@
|
||||
var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
var calendar = { // @1900-2100区间内的公历转农历
|
||||
solar2lunar: function(date) { var y = date.getFullYear(), m = date.getMonth()+1, d = date.getDate()
|
||||
var day = (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) - Date.UTC(1900,0,31))/86400000
|
||||
for (var year = 1900, days = 0; year < 2101 && day > 0; year++) { days = this.lYearDays(year), day -= days } if (day < 0) { day += days, year-- }
|
||||
@ -18,38 +18,38 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
var nWeek = date.getDay(), cWeek = this.nStr3[nWeek]; if (nWeek == 0) { nWeek = 7 }
|
||||
function getFestival(list, m, d) { return list[m+"-"+d]? list[m+"-"+d].title: null }
|
||||
|
||||
var res = {date: y+'-'+m+'-'+d, lunarDate: year+'-'+month+'-'+day,
|
||||
var res = {Date: y+'-'+m+'-'+d, lunarDate: year+'-'+month+'-'+day,
|
||||
Year: y, Month: m, Day: d, lYear: year, lMonth: month, lDay: day, gzYear: gzY, gzMonth: gzM, gzDay: gzD,
|
||||
Animal: this.getAnimal(year), cnMonth: (isLeap?"\u95f0":'')+this.toChinaMonth(month), cnDay: this.toChinaDay(day),
|
||||
isLeap: isLeap, Term: term, Astro: this.toAstro(m, d), nWeek: nWeek, ncWeek: "\u661f\u671f"+cWeek,
|
||||
lunarFestival: getFestival(this.lfestival, month, day), festival: getFestival(this.festival, m, d),
|
||||
lunarFestival: getFestival(this.lfestival, month, day), Festival: getFestival(this.festival, m, d),
|
||||
}
|
||||
res.autoDay = res.lunarFestival||res.festival||term||(day==1? this.toChinaMonth(month): this.toChinaDay(day))
|
||||
res.autoClass = "lunar"+(res.lunarFestival||res.festival? " fest":"")+(res.isTerm? " term": "")
|
||||
res.autoDay = res.lunarFestival||res.Festival||term||(day==1? this.toChinaMonth(month): this.toChinaDay(day))
|
||||
res.autoClass = "lunar"+(res.lunarFestival||res.Festival? " fest":"")+(term? " term": "")
|
||||
return res
|
||||
},
|
||||
|
||||
/* 天干表 ["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"] */
|
||||
// 天干表 ["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"]
|
||||
Gan: ["\u7532","\u4e59","\u4e19","\u4e01","\u620a","\u5df1","\u5e9a","\u8f9b","\u58ec","\u7678"],
|
||||
/* 地支表 ["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"] */
|
||||
// 地支表 ["子","丑","寅","卯","辰","巳","午","未","申","酉","j戌","亥"]
|
||||
Zhi: ["\u5b50","\u4e11","\u5bc5","\u536f","\u8fb0","\u5df3","\u5348","\u672a","\u7533","\u9149","\u620c","\u4ea5"],
|
||||
toGanZhi: function(offset) { return this.Gan[offset%10] + this.Zhi[offset%12] },
|
||||
toGanZhiYear: function(lYear) { /* 农历年份转换为干支纪年 */
|
||||
toGanZhiYear: function(lYear) { // 农历年份转换为干支纪年
|
||||
var ganKey = (lYear-3)%10; if (ganKey == 0) { ganKey = 10 }
|
||||
var zhiKey = (lYear-3)%12; if (zhiKey == 0) { zhiKey = 12 }
|
||||
return this.Gan[ganKey-1] + this.Zhi[zhiKey-1]
|
||||
},
|
||||
|
||||
/* 生肖表 ["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"] */
|
||||
// 生肖表 ["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"]
|
||||
Animals: ["\u9f20","\u725b","\u864e","\u5154","\u9f99","\u86c7","\u9a6c","\u7f8a","\u7334","\u9e21","\u72d7","\u732a"],
|
||||
/* 年份转生肖,精确划分生肖分界线是"立春" */
|
||||
// 年份转生肖,精确划分生肖分界线是"立春"
|
||||
getAnimal: function(y) { return this.Animals[(y - 4) % 12] },
|
||||
|
||||
/* 月份表 ['正','一','二','三','四','五','六','七','八','九','十','冬','腊'] */
|
||||
// 月份表 ['正','一','二','三','四','五','六','七','八','九','十','冬','腊']
|
||||
nStr1: ["\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a"],
|
||||
/* 月旬表 ['初','十','廿','卅'] */
|
||||
// 月旬表 ['初','十','廿','卅']
|
||||
nStr2: ["\u521d","\u5341","\u5eff","\u5345"],
|
||||
/* 日子表 ['日','一','二','三','四','五','六','七','八','九','十'] */
|
||||
// 日子表 ['日','一','二','三','四','五','六','七','八','九','十']
|
||||
nStr3: ["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341"],
|
||||
toChinaMonth: function(m) { return this.nStr1[m-1]+"\u6708" },
|
||||
toChinaDay: function(d) { switch (d) {
|
||||
@ -59,16 +59,16 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
default: return this.nStr2[Math.floor(d/10)]+this.nStr3[d%10]
|
||||
} },
|
||||
|
||||
/* 公历每个月份的天数普通表 */
|
||||
// 公历每个月份的天数普通表
|
||||
solarMonth: [31,28,31,30,31,30,31,31,30,31,30,31],
|
||||
/* 返回公历y年m月的天数 */
|
||||
// 返回公历y年m月的天数
|
||||
solarDays: function(y, m) { var ms = m-1; if (ms == 1) { return ((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28 } else { return this.solarMonth[ms] } },
|
||||
/* 公历月、日判断所属星座 */
|
||||
// 公历月、日判断所属星座
|
||||
toAstro: function(m, d) { var arr = [20,19,21,21,21,22,23,23,23,23,22,22]
|
||||
var s = "\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf"
|
||||
return s.substr(m*2 - (d < arr[m-1]? 2: 0), 2) + "\u5ea7"
|
||||
},
|
||||
festival: { /* 公历节日 */
|
||||
festival: { // 公历节日
|
||||
'1-1': {title: '元旦节'},
|
||||
'12-24': {title: '平安夜'},
|
||||
'12-25': {title: '圣诞节'},
|
||||
@ -85,7 +85,7 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
'8-1': {title: '建军节'},
|
||||
'10-1': {title: '国庆节'},
|
||||
},
|
||||
lfestival: { /* 农历节日 */
|
||||
lfestival: { // 农历节日
|
||||
'12-30': {title: '除夕'},
|
||||
'1-1': {title: '春节'},
|
||||
'1-15': {title: '元宵'},
|
||||
@ -95,18 +95,18 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
'9-9': {title: '重阳'},
|
||||
},
|
||||
|
||||
/* 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法 */
|
||||
// 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法
|
||||
monthDays: function(y, m) { return (this.lunarInfo[y-1900] & (0x10000>>m))? 30: 29 },
|
||||
/* 返回农历y年闰月是哪个月;若y年没有闰月则返回0 */
|
||||
// 返回农历y年闰月是哪个月;若y年没有闰月则返回0
|
||||
leapMonth: function(y) { return this.lunarInfo[y-1900] & 0xf },
|
||||
/* 返回农历y年闰月的天数 若该年没有闰月则返回0 */
|
||||
// 返回农历y年闰月的天数 若该年没有闰月则返回0
|
||||
leapDays: function(y) { if (this.leapMonth(y)) { return (this.lunarInfo[y-1900] & 0x10000)? 30: 29 } return 0 },
|
||||
/* 返回农历y年一整年的总天数 */
|
||||
// 返回农历y年一整年的总天数
|
||||
lYearDays: function(y) { var i, sum = 348
|
||||
for (i = 0x8000; i > 0x8; i >>= 1) { sum += (this.lunarInfo[y-1900] & i)? 1: 0 }
|
||||
return sum+this.leapDays(y)
|
||||
},
|
||||
lunarInfo: [ /* 农历1900-2100的润大小信息表 */
|
||||
lunarInfo: [ // 农历1900-2100的润大小信息表
|
||||
0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,//1900-1909
|
||||
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,//1910-1919
|
||||
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,//1920-1929
|
||||
@ -130,7 +130,7 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
0x0d520, //2100
|
||||
],
|
||||
|
||||
getTerm: function(y, n) { /* 传入公历y年获得该年第n个节气的公历日期 */
|
||||
getTerm: function(y, n) { // 传入公历y年获得该年第n个节气的公历日期
|
||||
var _table = this.termInfo[y-1900]
|
||||
var _info = [
|
||||
parseInt('0x'+_table.substr(0,5)).toString(),
|
||||
@ -172,9 +172,9 @@ var calendar = { /* @1900-2100区间内的公历转农历 */
|
||||
_info[5].substr(4,2),
|
||||
]; return parseInt(_calday[n-1])
|
||||
},
|
||||
/* 二十四节气速查表 ["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"] */
|
||||
// 二十四节气速查表 ["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"]
|
||||
termName: ["\u5c0f\u5bd2","\u5927\u5bd2","\u7acb\u6625","\u96e8\u6c34","\u60ca\u86f0","\u6625\u5206","\u6e05\u660e","\u8c37\u96e8","\u7acb\u590f","\u5c0f\u6ee1","\u8292\u79cd","\u590f\u81f3","\u5c0f\u6691","\u5927\u6691","\u7acb\u79cb","\u5904\u6691","\u767d\u9732","\u79cb\u5206","\u5bd2\u9732","\u971c\u964d","\u7acb\u51ac","\u5c0f\u96ea","\u5927\u96ea","\u51ac\u81f3"],
|
||||
termInfo: [ /* 1900-2100各年的24节气日期速查表 */
|
||||
termInfo: [ // 1900-2100各年的24节气日期速查表
|
||||
'9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c3598082c95f8c965cc920f',
|
||||
'97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e',
|
||||
'97bcf97c359801ec95f8c965cc920f','97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa',
|
||||
|
@ -32,6 +32,7 @@ Volcanos("misc", {Message: function(event, can) { var msg = {}
|
||||
return res
|
||||
} return msg.result && msg.result.join("") || ""
|
||||
},
|
||||
Results: function() { return msg.result && msg.result[0] == ice.ErrWarn? "": msg.Result() },
|
||||
TableDetail: function() { var item = {hash: can.Option(mdb.HASH)}
|
||||
return msg.Table(function(value) { can.core.Value(item, value.key, value.value) }), item
|
||||
},
|
||||
|
@ -110,11 +110,11 @@ Volcanos("user", {info: {}, agent: {
|
||||
carte: function(event, can, meta, list, cb, parent) {
|
||||
meta = meta||can.ondetail||can.onaction||{}, list = can.base.getValid(list, meta.list, can.core.Item(meta))||[]; if (list.length == 0) { return }
|
||||
cb = cb||function(event, button, meta) { var cb = meta[button]||meta[chat._ENGINE]; can.base.isFunc(cb) && cb(event, can, button) }
|
||||
parent || can.page.Select(can, can._root._target, can.page.Keys("div.carte.float"), function(target) { can.page.Remove(can, target) })
|
||||
parent || can.page.Select(can, can._root._target, can.page.Keys("div.carte.float"), function(target) { can.onmotion.delay(can, function () { can.page.Remove(can, target) }) })
|
||||
var ui = can.page.Append(can, can._root._target, [{view: [[chat.CARTE, chat.FLOAT]], list: can.core.List(list, function(item, index) {
|
||||
return can.base.isString(item)? item ==""? /* space */ {view: html.SPACE}: /* string */ {view: html.ITEM, list: [{text: can.user.trans(can, item), onclick: function(event) {
|
||||
return can.base.isString(item)? item ==""? /* space */ {view: html.SPACE}: /* string */ {view: [html.ITEM, html.DIV, can.user.trans(can, item)], onclick: function(event) {
|
||||
can.base.isFunc(cb) && cb(event, item, meta, index), can.onkeymap.prevent(event), can.user.isMobile && can.page.Remove(can, ui._target)
|
||||
}, onmouseenter: function(event) { carte._float && can.page.Remove(can, carte._float._target) } }] }:
|
||||
}, onmouseenter: function(event) { carte._float && can.page.Remove(can, carte._float._target) } }:
|
||||
can.base.isArray(item)? /* array */ {view: html.ITEM, list: [{text: can.user.trans(can, item[0])+" -> "}], onmouseenter: function(event) {
|
||||
var sub = can.user.carte(event, can, meta, item.slice(1), cb, carte); can.onlayout.figure(event, can, sub._target, true)
|
||||
carte._float && can.page.Remove(can, carte._float._target), carte._float = sub
|
||||
|
@ -33,6 +33,9 @@ fieldset.inner.float>div.status { display:none; }
|
||||
|
||||
fieldset.inner>div.output td.content>div.tabs { display:none; }
|
||||
fieldset.inner>div.output td.content>div.path { display:none; }
|
||||
fieldset.inner>div.output td.content>div.path { font-family:monospace; }
|
||||
fieldset.inner>div.output td.content>div.path span.item { padding:3px 12px; }
|
||||
fieldset.inner>div.output td.content>div.path span.item:hover { background-color:cornflowerblue; }
|
||||
fieldset.inner div.output fieldset.toolkit { position:absolute; bottom:0px; right:0px; }
|
||||
fieldset.inner>div.output fieldset.toolkit>div.output>fieldset { display:none; }
|
||||
fieldset.inner>div.output fieldset.toolkit>div.output>fieldset.select { background-color:#0e3369b3; color:white; display:block; z-index:10; }
|
||||
|
@ -8,6 +8,34 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
|
||||
}}])
|
||||
},
|
||||
|
||||
tabInputs: function(event, can, ps, key, pre, cb, parent) {
|
||||
can.runAction(event, mdb.INPUTS, [key, pre], function(msg) { var _trans = {}
|
||||
var carte = can.user[parent? "carteRight": "carte"](event, can, {}, msg.Table(function(value) { var p = can.base.trimPrefix(value[key], pre)
|
||||
if (can.base.beginWith(pre, "usr/icebergs/core/") && can.base.beginWith(value[key], "usr/volcanos/plugin/local/")) {
|
||||
var p = can.base.trimPrefix(can.base.replaceAll(value[key], "usr/volcanos/plugin/local/", "usr/icebergs/core/"), pre)
|
||||
}
|
||||
if (can.base.beginWith(pre, "usr/volcanos/plugin/local/") && can.base.beginWith(value[key], "usr/icebergs/core/")) {
|
||||
var p = can.base.trimPrefix(can.base.replaceAll(value[key], "usr/icebergs/core/", "usr/volcanos/plugin/local/"), pre)
|
||||
}
|
||||
return _trans[p] = value[key], p
|
||||
}), function(event, button) {
|
||||
if (can.base.endWith(button, ps)) { can.onimport.tabInputs(event, can, ps, key, pre+button, cb, carte); return }
|
||||
cb(can.core.Split(_trans[button], ps), pre)
|
||||
}, parent)._target
|
||||
function remove(p) { if (p && p._sub) { remove(p._sub), can.page.Remove(can, p._sub), delete(p._sub) } }
|
||||
if (parent) { remove(parent), parent._sub = carte }
|
||||
var _p = can.core.Split(event.target.innerHTML.trim(), ice.PT)[0]
|
||||
can.page.Select(can, carte, html.DIV_ITEM, function(target) { can.base.beginWith(target.innerHTML, _p) && carte.insertBefore(target, carte.firstChild) })
|
||||
})
|
||||
},
|
||||
_tabInputs: function(can, ps, key, value, cb) {
|
||||
can.core.List(can.core.Split(value, ps), function(value, index, array) {
|
||||
can.page.Append(can, can.ui._path, [{text: [value, html.SPAN, html.ITEM], onclick: function(event) {
|
||||
can.onimport.tabInputs(event, can, ps, key, array.slice(0, index).join(ps)+ps, cb)
|
||||
}}, index < array.length-1? {text: ps}: null])
|
||||
})
|
||||
},
|
||||
|
||||
project: function(can, path) {
|
||||
can.onimport.zone(can, can.core.Item(can.onfigure, function(name, cb) {
|
||||
if (can.base.isFunc(cb)) { return {name: name, _init: function(target, zone) { return cb(can, target, zone, path) }} }
|
||||
@ -23,8 +51,21 @@ Volcanos(chat.ONIMPORT, {help: "导入数据",
|
||||
can.Option(can.onimport.history(can, {path: path, file: file, line: line||can.misc.localStorage(can, "web.code.vimer:selectLine:"+path+file)||can._msg.Option(nfs.LINE)|| 1}))
|
||||
can.onsyntax._init(can, can._msg, function(content) { var msg = can._msg
|
||||
can.onexport.hash(can), msg._tab && can.onmotion.select(can, msg._tab.parentNode, html.DIV_TABS, msg._tab)
|
||||
can.ui._path && (can.ui._path.innerHTML = isDream()? can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: can.Option(nfs.FILE)})):
|
||||
isCommand()? can.Option(nfs.FILE): can.base.Path(can.Option(nfs.PATH), can.Option(nfs.FILE)))
|
||||
if (can.ui._path) { can.ui._path.innerHTML = ""
|
||||
if (isDream()) {
|
||||
can.ui._path.innerHTML = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: can.Option(nfs.FILE)}))
|
||||
} else if (isCommand()) {
|
||||
can.ui._path.innerHTML = can.Option(nfs.FILE)
|
||||
} else {
|
||||
can.onimport._tabInputs(can, ice.PS, nfs.PATH, can.base.Path(can.Option(nfs.PATH), can.Option(nfs.FILE)), function(ls, pre) {
|
||||
if (can.base.beginWith(pre, "usr/")) {
|
||||
can.onimport.tabview(can, ls.slice(0, 2).join(ice.PS)+ice.PS, ls.slice(2).join(ice.PS))
|
||||
} else {
|
||||
can.onimport.tabview(can, ls.slice(0, 1).join(ice.PS)+ice.PS, ls.slice(1).join(ice.PS))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
can.ui.current && can.onmotion.toggle(can, can.ui.current, !isCommand() && !isDream())
|
||||
|
||||
can.page.Select(can, can.ui._content.parentNode, can.page.Keys(html.DIV_CONTENT, html.IFRAME), function(item) {
|
||||
|
@ -4,12 +4,9 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear(
|
||||
svg.GO, ice.RUN, svg.SHAPE, svg.RECT), function(key, value) { can.Action(key, can.svg.Value(key, can.svg.Value(key)||value)) })
|
||||
can.ondetail._select(can, can.misc.SearchHash(can)[0]||can.Option(svg.PID)||can.svg.Value(svg.PID), function(target) { can.onimport._profile(can, target) })
|
||||
}), can.isCmdMode()? (can.keylist = [], can.onkeymap._build(can)): can.onmotion.hidden(can, can._action)
|
||||
can.require(["/require/src/lunar.js"], function() {
|
||||
can.misc.Log(Lunar.toLunar(2022, 11, 7))
|
||||
})
|
||||
},
|
||||
_show: function(can, msg) { can.svg = null, can.group = null, can.temp = null, can.current = null, can.points = [], can._display_heights = {}
|
||||
can.ui = can.onlayout.profile(can), can.page.Modify(can, can.ui.content, msg.Result()||can.onexport.content(can)), can.onmotion.hidden(can, [can.ui.project, can.ui.profile])
|
||||
can.ui = can.onlayout.profile(can), can.page.Modify(can, can.ui.content, msg.Results()||can.onexport.content(can)), can.onmotion.hidden(can, [can.ui.project, can.ui.profile])
|
||||
can.page.Select(can, can.ui.content, html.SVG, function(target) { can.svg = can.group = can.onimport._block(can, target), can.onimport._group(can, target).click()
|
||||
can.page.Select(can, target, mdb.FOREACH, function(target) { can.onimport._block(can, target), can.page.tagis(target, svg.G) && target.Value(html.CLASS) && can.onimport._group(can, target) })
|
||||
can.core.ItemCB(can.onaction, function(key, cb) { target[key] = function(event) { cb(event, can) } })
|
||||
@ -43,9 +40,10 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear(
|
||||
{th: [mdb.KEY, mdb.VALUE]}, {td: [mdb.TYPE, target.tagName]}, {td: [svg.PID, target.Value(svg.PID)]},
|
||||
].concat(can.core.List([].concat(figure.data.copy, [svg.X, svg.Y, mdb.INDEX, ctx.ARGS]), function(key) {
|
||||
return key = can.core.Value(figure.data, can.core.Keys(svg.TRANS, key))||key, {td: [key, target.Value(key)], ondblclick: function(event) {
|
||||
can.onmotion.modify(can, event.target, function(event, value) { target.Value(key, value), can.ondetail._move(can, target) })
|
||||
can.onmotion.modify(can, event.target, function(event, value) { target.Value(key, value), can.ondetail._move(can, target) }, {action: "key"})
|
||||
}}
|
||||
})) }])
|
||||
// can.onappend._action(can, [""], ui.action, {_engine: function(event, can, button) { can.ondetail[button]({target: target}, can, button) }})
|
||||
// , can.onappend._action(can, can.ondetail.list, ui.action, {_engine: function(event, can, button) { can.ondetail[button]({target: target}, can, button) }})
|
||||
target.Value(ctx.INDEX)? can.onappend.plugin(can, {index: target.Value(ctx.INDEX), args: target.Value(ctx.ARGS), height: can.ConfHeight()/2-2*html.ACTION_HEIGHT}, function(sub) {
|
||||
can.onimport.layout(can), sub.onaction._output = function() { can._display_heights[target.Value(svg.PID)] = can.base.Max(sub._target.offsetHeight, can.ConfHeight()/2), can.onimport.layout(can) }
|
||||
@ -92,7 +90,7 @@ Volcanos(chat.ONACTION, {list: [[svg.GRID, 1, 2, 3, 4, 5, 10, 20],
|
||||
clear: function(event, can) { can.onmotion.clear(can, can.group), delete(can.temp), can.points = [] },
|
||||
remove: function(event, can) { can.group == can.svg || can.page.Remove(can, can.group) },
|
||||
|
||||
save: function(event, can, button) { can.runAction(can.request(event, {text: can.onexport.content(can, can.svg)}), button, [can.Option(nfs.PATH)]) },
|
||||
save: function(event, can, button) { can.runAction(event, button, [can.Option(nfs.PATH), can.onexport.content(can, can.svg)]) },
|
||||
edit: function(event, can) { can.Action(svg.GO, can.Action(svg.GO) == ice.RUN? ice.AUTO: ice.RUN) },
|
||||
|
||||
_mode: {
|
||||
@ -141,7 +139,7 @@ Volcanos(chat.ONACTION, {list: [[svg.GRID, 1, 2, 3, 4, 5, 10, 20],
|
||||
can.onaction._figure(event, can, can.points = can.points.concat(point))
|
||||
},
|
||||
ondblclick: function(event, can) { can.ondetail.label(event, can) },
|
||||
oncontextmenu: function(event) { can.page.style(can, can.user.carte(event, can, can.ondetail, null, function(ev, button, meta) { meta[button](event, can, button) })._target, {left: event.clientX, top: event.clientY}) },
|
||||
oncontextmenu: function(event, can) { can.page.style(can, can.user.carte(event, can, can.ondetail, null, function(ev, button, meta) { meta[button](event, can, button) })._target, {left: event.clientX, top: event.clientY}) },
|
||||
})
|
||||
Volcanos(chat.ONDETAIL, {list: [cli.START, ice.COPY, html.LABEL, "toimage", mdb.REMOVE],
|
||||
_select(can, name, cb) { return name? can.page.Select(can, can.svg, ice.PT+name, cb)[0]: null },
|
||||
@ -166,9 +164,9 @@ Volcanos(chat.ONDETAIL, {list: [cli.START, ice.COPY, html.LABEL, "toimage", mdb.
|
||||
return can.onimport.block(can, target.tagName, data, can.group)
|
||||
},
|
||||
label: function(event, can) { var target = event.target
|
||||
var text = target.Value(mdb.TEXT); can.ondetail._select(can, text, function(target) { text = target.Value(html.INNER) })
|
||||
can.user.input(event, can, [{name: html.LABEL, value: text}], function(list) { if (target.tagName == html.TEXT) { return target.innerHTML = list[0] }
|
||||
if (can.ondetail._select(can, text, function(target) { target.Value(html.INNER, list[0]) })) { return }
|
||||
var _target, text = target.Value(mdb.TEXT); can.ondetail._select(can, text, function(target) { _target = target, text = target.Value(html.INNER) })
|
||||
can.user.input(event, can, [{name: html.LABEL, value: text}], function(list) {
|
||||
if (_target) { _target.Value(html.INNER, list[0]); return } if (can.page.tagis(target, html.TEXT)) { target.innerHTML = list[0]; return }
|
||||
target.Value(mdb.TEXT, can.onexport._pid(can, can.onimport.block(can, html.TEXT, can.onexport._text(can, target, can.onfigure._get(can, target), {inner: list[0]}), target.Group()) ))
|
||||
})
|
||||
},
|
||||
@ -190,7 +188,7 @@ Volcanos(chat.ONEXPORT, {list: [svg.GROUP, svg.FIGURE, ctx.INDEX, "pos"],
|
||||
},
|
||||
_pid: function(can, target) { if (target.Value(svg.PID)) { return target.Value(svg.PID) }
|
||||
var pid = "p"+can.svg.Val(mdb.COUNT, can.svg.Val(mdb.COUNT)+1)
|
||||
return target.Value(html.CLASS, (target.Value(html.CLASS)+ice.SP+target.Value(svg.PID, pid)).trim()), pid
|
||||
return target.Value(html.CLASS, [target.Value(html.CLASS), target.Value(svg.PID, pid)].join(ice.SP).trim()), pid
|
||||
},
|
||||
_text: function(can, target, figure, data) { var trans = can.core.Value(figure.data, svg.TRANS)||{}
|
||||
if (figure.text) { return figure.text(can, target, data) }
|
||||
@ -209,10 +207,10 @@ Volcanos(chat.ONEXPORT, {list: [svg.GROUP, svg.FIGURE, ctx.INDEX, "pos"],
|
||||
can.Status(ctx.INDEX, target.Value(ctx.INDEX)||"")
|
||||
},
|
||||
content: function(can, target) {
|
||||
return ['<svg vertion="1.1" xmlns="https://www.w3.org/2000/svg" text-anchor="middle" dominant-baseline="middle"'].concat(
|
||||
return ['<svg xmlns="https://www.w3.org/2000/svg" vertion="1.1" text-anchor="middle" dominant-baseline="middle" '].concat(
|
||||
target? can.core.List([html.HEIGHT, html.WIDTH, svg.GRID, mdb.COUNT, svg.PID, svg.FONT_SIZE, svg.STROKE_WIDTH, svg.STROKE, svg.FILL], function(item) {
|
||||
return target.Value(item)? ice.SP + item + '="' + target.Value(item) + '"': ""
|
||||
}): [" height="+((can.ConfHeight()||450)-50)+" width="+(can.ConfWidth()||600)]).concat(['>', target? target.innerHTML: "", ""]).join("")
|
||||
return target.Value(item)? can.base.joinKV([item, target.Value(item)], ice.EQ): ""
|
||||
}).join(ice.SP): can.base.joinKV([html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth()], ice.EQ)).concat(['>', target? target.innerHTML: "", "</svg>"]).join("")
|
||||
},
|
||||
cursor: function(event, can, target) {
|
||||
var p = target.getBoundingClientRect(), q = {x: event.clientX, y: event.clientY}, pos = 5, margin = 20
|
||||
|
Loading…
x
Reference in New Issue
Block a user