jsmind 0.4.6 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +45 -31
- package/docs/en/1.usage.md +11 -11
- package/docs/en/2.options.md +213 -1
- package/docs/en/3.operation.md +137 -1
- package/docs/en/4.contribution.md +35 -0
- package/docs/en/5.development.md +18 -0
- package/docs/en/index.md +23 -12
- package/docs/zh/1.usage.md +22 -20
- package/docs/zh/2.options.md +54 -8
- package/docs/zh/3.operation.md +35 -21
- package/docs/zh/4.contribution.md +41 -0
- package/docs/zh/5.development.md +78 -0
- package/docs/zh/index.md +2 -1
- package/es6/jsmind.draggable-node.js +9 -0
- package/es6/jsmind.draggable-node.js.map +1 -0
- package/es6/jsmind.js +9 -0
- package/es6/jsmind.js.map +1 -0
- package/es6/jsmind.screenshot.js +9 -0
- package/es6/jsmind.screenshot.js.map +1 -0
- package/js/{jsmind.draggable.js → jsmind.draggable-node.js} +128 -122
- package/js/jsmind.js +1211 -1064
- package/js/jsmind.screenshot.js +139 -137
- package/package.json +51 -31
- package/style/jsmind.css +357 -114
- package/example/1_basic.html +0 -62
- package/example/2_features.html +0 -526
- package/example/ant.png +0 -0
- package/example/data_example.json +0 -48
- package/example/demo.html +0 -102
- package/features/jsmind.shell.js +0 -116
- package/screenshots/jsmind.png +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsmind.screenshot.js","sources":["../src/plugins/jsmind.screenshot.js"],"sourcesContent":["/**\n * @license BSD\n * @copyright 2014-2022 hizzgdev@163.com\n *\n * Project Home:\n * https://github.com/hizzgdev/jsmind/\n */\n\nif (!jsMind) {\n throw new Error('jsMind is not defined');\n}\n\nconst $ = jsMind.$;\n\nvar css = function (cStyle, property_name) {\n return cStyle.getPropertyValue(property_name);\n};\nvar is_visible = function (cStyle) {\n var visibility = css(cStyle, 'visibility');\n var display = css(cStyle, 'display');\n return visibility !== 'hidden' && display !== 'none';\n};\nvar jcanvas = {};\njcanvas.rect = function (ctx, x, y, w, h, r) {\n if (w < 2 * r) r = w / 2;\n if (h < 2 * r) r = h / 2;\n ctx.moveTo(x + r, y);\n ctx.arcTo(x + w, y, x + w, y + h, r);\n ctx.arcTo(x + w, y + h, x, y + h, r);\n ctx.arcTo(x, y + h, x, y, r);\n ctx.arcTo(x, y, x + w, y, r);\n};\n\njcanvas.text_multiline = function (ctx, text, x, y, w, h, lineheight) {\n var line = '';\n var text_len = text.length;\n var chars = text.split('');\n var test_line = null;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n for (var i = 0; i < text_len; i++) {\n test_line = line + chars[i];\n if (ctx.measureText(test_line).width > w && i > 0) {\n ctx.fillText(line, x, y);\n line = chars[i];\n y += lineheight;\n } else {\n line = test_line;\n }\n }\n ctx.fillText(line, x, y);\n};\n\njcanvas.text_ellipsis = function (ctx, text, x, y, w, h) {\n var center_y = y + h / 2;\n var text = jcanvas.fittingString(ctx, text, w);\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n ctx.fillText(text, x, center_y, w);\n};\n\njcanvas.fittingString = function (ctx, text, max_width) {\n var width = ctx.measureText(text).width;\n var ellipsis = '…';\n var ellipsis_width = ctx.measureText(ellipsis).width;\n if (width <= max_width || width <= ellipsis_width) {\n return text;\n } else {\n var len = text.length;\n while (width >= max_width - ellipsis_width && len-- > 0) {\n text = text.substring(0, len);\n width = ctx.measureText(text).width;\n }\n return text + ellipsis;\n }\n};\n\njcanvas.image = function (ctx, url, x, y, w, h, r, rotation, callback) {\n var img = new Image();\n img.onload = function () {\n ctx.save();\n ctx.translate(x, y);\n ctx.save();\n ctx.beginPath();\n jcanvas.rect(ctx, 0, 0, w, h, r);\n ctx.closePath();\n ctx.clip();\n ctx.translate(w / 2, h / 2);\n ctx.rotate((rotation * Math.PI) / 180);\n ctx.drawImage(img, -w / 2, -h / 2);\n ctx.restore();\n ctx.restore();\n !!callback && callback();\n };\n img.src = url;\n};\n\nclass screenshot {\n constructor(jm) {\n this.jm = jm;\n this.canvas_elem = null;\n this.canvas_ctx = null;\n this._inited = false;\n }\n init() {\n if (this._inited) {\n return;\n }\n console.log('init');\n var c = $.c('canvas');\n var ctx = c.getContext('2d');\n\n this.canvas_elem = c;\n this.canvas_ctx = ctx;\n this.jm.view.e_panel.appendChild(c);\n this._inited = true;\n this.resize();\n }\n shoot(callback) {\n this.init();\n this._draw(\n function () {\n !!callback && callback();\n this.clean();\n }.bind(this)\n );\n this._watermark();\n }\n shootDownload() {\n this.shoot(\n function () {\n this._download();\n }.bind(this)\n );\n }\n shootAsDataURL(callback) {\n this.shoot(\n function () {\n !!callback && callback(this.canvas_elem.toDataURL());\n }.bind(this)\n );\n }\n resize() {\n if (this._inited) {\n this.canvas_elem.width = this.jm.view.size.w;\n this.canvas_elem.height = this.jm.view.size.h;\n }\n }\n clean() {\n var c = this.canvas_elem;\n this.canvas_ctx.clearRect(0, 0, c.width, c.height);\n }\n _draw(callback) {\n var ctx = this.canvas_ctx;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n this._draw_lines(\n function () {\n this._draw_nodes(callback);\n }.bind(this)\n );\n }\n _watermark() {\n var c = this.canvas_elem;\n var ctx = this.canvas_ctx;\n ctx.textAlign = 'right';\n ctx.textBaseline = 'bottom';\n ctx.fillStyle = '#000';\n ctx.font = '11px Verdana,Arial,Helvetica,sans-serif';\n ctx.fillText('hizzgdev.github.io/jsmind', c.width - 5.5, c.height - 2.5);\n ctx.textAlign = 'left';\n ctx.fillText($.w.location, 5.5, c.height - 2.5);\n }\n _draw_lines(callback) {\n this.jm.view.graph.copy_to(this.canvas_ctx, callback);\n }\n _draw_nodes(callback) {\n var nodes = this.jm.mind.nodes;\n var node;\n for (var nodeid in nodes) {\n node = nodes[nodeid];\n this._draw_node(node);\n }\n\n function check_nodes_ready() {\n console.log('check_node_ready' + new Date());\n var allOk = true;\n for (var nodeid in nodes) {\n node = nodes[nodeid];\n allOk = allOk & node.ready;\n }\n\n if (!allOk) {\n $.w.setTimeout(check_nodes_ready, 200);\n } else {\n $.w.setTimeout(callback, 200);\n }\n }\n check_nodes_ready();\n }\n _draw_node(node) {\n var ctx = this.canvas_ctx;\n var view_data = node._data.view;\n var node_element = view_data.element;\n var ncs = getComputedStyle(node_element);\n if (!is_visible(ncs)) {\n node.ready = true;\n return;\n }\n\n var bgcolor = css(ncs, 'background-color');\n var round_radius = parseInt(css(ncs, 'border-top-left-radius'));\n var color = css(ncs, 'color');\n var padding_left = parseInt(css(ncs, 'padding-left'));\n var padding_right = parseInt(css(ncs, 'padding-right'));\n var padding_top = parseInt(css(ncs, 'padding-top'));\n var padding_bottom = parseInt(css(ncs, 'padding-bottom'));\n var text_overflow = css(ncs, 'text-overflow');\n var font =\n css(ncs, 'font-style') +\n ' ' +\n css(ncs, 'font-variant') +\n ' ' +\n css(ncs, 'font-weight') +\n ' ' +\n css(ncs, 'font-size') +\n '/' +\n css(ncs, 'line-height') +\n ' ' +\n css(ncs, 'font-family');\n\n var rb = {\n x: view_data.abs_x,\n y: view_data.abs_y,\n w: view_data.width + 1,\n h: view_data.height + 1,\n };\n var tb = {\n x: rb.x + padding_left,\n y: rb.y + padding_top,\n w: rb.w - padding_left - padding_right,\n h: rb.h - padding_top - padding_bottom,\n };\n\n ctx.font = font;\n ctx.fillStyle = bgcolor;\n ctx.beginPath();\n jcanvas.rect(ctx, rb.x, rb.y, rb.w, rb.h, round_radius);\n ctx.closePath();\n ctx.fill();\n\n ctx.fillStyle = color;\n if ('background-image' in node.data) {\n var backgroundUrl = css(ncs, 'background-image').slice(5, -2);\n node.ready = false;\n var rotation = 0;\n if ('background-rotation' in node.data) {\n rotation = node.data['background-rotation'];\n }\n jcanvas.image(\n ctx,\n backgroundUrl,\n rb.x,\n rb.y,\n rb.w,\n rb.h,\n round_radius,\n rotation,\n function () {\n node.ready = true;\n }\n );\n }\n if (!!node.topic) {\n if (text_overflow === 'ellipsis') {\n jcanvas.text_ellipsis(ctx, node.topic, tb.x, tb.y, tb.w, tb.h);\n } else {\n var line_height = parseInt(css(ncs, 'line-height'));\n jcanvas.text_multiline(ctx, node.topic, tb.x, tb.y, tb.w, tb.h, line_height);\n }\n }\n if (!!view_data.expander) {\n this._draw_expander(view_data.expander);\n }\n if (!('background-image' in node.data)) {\n node.ready = true;\n }\n }\n _draw_expander(expander) {\n var ctx = this.canvas_ctx;\n var ncs = getComputedStyle(expander);\n if (!is_visible(ncs)) {\n return;\n }\n\n var style_left = css(ncs, 'left');\n var style_top = css(ncs, 'top');\n var font = css(ncs, 'font');\n var left = parseInt(style_left);\n var top = parseInt(style_top);\n var is_plus = expander.innerHTML === '+';\n\n ctx.lineWidth = 1;\n\n ctx.beginPath();\n ctx.arc(left + 7, top + 7, 5, 0, Math.PI * 2, true);\n ctx.moveTo(left + 10, top + 7);\n ctx.lineTo(left + 4, top + 7);\n if (is_plus) {\n ctx.moveTo(left + 7, top + 4);\n ctx.lineTo(left + 7, top + 10);\n }\n ctx.closePath();\n ctx.stroke();\n }\n _download() {\n var c = this.canvas_elem;\n var name = this.jm.mind.name + '.png';\n\n if (navigator.msSaveBlob && !!c.msToBlob) {\n var blob = c.msToBlob();\n navigator.msSaveBlob(blob, name);\n } else {\n var bloburl = this.canvas_elem.toDataURL();\n var anchor = $.c('a');\n if ('download' in anchor) {\n anchor.style.visibility = 'hidden';\n anchor.href = bloburl;\n anchor.download = name;\n $.d.body.appendChild(anchor);\n var evt = $.d.createEvent('MouseEvents');\n evt.initEvent('click', true, true);\n anchor.dispatchEvent(evt);\n $.d.body.removeChild(anchor);\n } else {\n location.href = bloburl;\n }\n }\n }\n jm_event_handle(type, data) {\n if (type === jsMind.event_type.resize) {\n this.resize();\n }\n }\n}\n\nvar screenshot_plugin = new jsMind.plugin('screenshot', function (jm) {\n var jss = new screenshot(jm);\n jm.screenshot = jss;\n jm.shoot = function () {\n jss.shoot();\n };\n jm.add_event_listener(function (type, data) {\n jss.jm_event_handle.call(jss, type, data);\n });\n});\n\njsMind.register_plugin(screenshot_plugin);\n"],"names":["jsMind","Error","$","css","cStyle","property_name","getPropertyValue","is_visible","visibility","display","jcanvas","ctx","x","y","w","h","r","moveTo","arcTo","text","lineheight","line","text_len","length","chars","split","test_line","textAlign","textBaseline","i","measureText","width","fillText","center_y","fittingString","max_width","ellipsis_width","len","substring","url","rotation","callback","img","Image","onload","save","translate","beginPath","rect","closePath","clip","rotate","Math","PI","drawImage","restore","src","screenshot","constructor","jm","this","canvas_elem","canvas_ctx","_inited","init","console","log","c","getContext","view","e_panel","appendChild","resize","shoot","_draw","clean","bind","_watermark","shootDownload","_download","shootAsDataURL","toDataURL","size","height","clearRect","_draw_lines","_draw_nodes","fillStyle","font","location","graph","copy_to","node","nodes","mind","nodeid","_draw_node","check_nodes_ready","Date","allOk","ready","setTimeout","view_data","_data","node_element","element","ncs","getComputedStyle","bgcolor","round_radius","parseInt","color","padding_left","padding_right","padding_top","padding_bottom","text_overflow","rb","abs_x","abs_y","tb","fill","data","backgroundUrl","slice","image","topic","text_ellipsis","line_height","text_multiline","expander","_draw_expander","style_left","style_top","left","top","is_plus","innerHTML","lineWidth","arc","lineTo","stroke","name","navigator","msSaveBlob","msToBlob","blob","bloburl","anchor","style","href","download","d","body","evt","createEvent","initEvent","dispatchEvent","removeChild","jm_event_handle","type","event_type","screenshot_plugin","plugin","jss","add_event_listener","call","register_plugin"],"mappings":";;;;;;;yBAQA,IAAKA,OACD,MAAM,IAAIC,MAAM,yBAGpB,MAAMC,EAAIF,OAAOE,EAEjB,IAAIC,EAAM,SAAUC,EAAQC,GACxB,OAAOD,EAAOE,iBAAiBD,IAE/BE,EAAa,SAAUH,GACvB,IAAII,EAAaL,EAAIC,EAAQ,cACzBK,EAAUN,EAAIC,EAAQ,WAC1B,MAAsB,WAAfI,GAAuC,SAAZC,GAElCC,EAAU,CACdA,KAAe,SAAUC,EAAKC,EAAGC,EAAGC,EAAGC,EAAGC,GAClCF,EAAI,EAAIE,IAAGA,EAAIF,E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AIP,KAAKC,YACTiF,EAAOlF,KAAKD,GAAGmC,KAAKgD,KAAO,OAE/B,GAAIC,UAAUC,YAAgB7E,EAAE8E,SAAU,CACtC,IAAIC,EAAO/E,EAAE8E,WACbF,UAAUC,WAAWE,EAAMJ,OACxB,CACH,IAAIK,EAAUvF,KAAKC,YAAYoB,YAC3BmE,EAASlJ,EAAEiE,EAAE,KACjB,GAAI,aAAciF,EAAQ,CACtBA,EAAOC,MAAM7I,WAAa,SAC1B4I,EAAOE,KAAOH,EACdC,EAAOG,SAAWT,EAClB5I,EAAEsJ,EAAEC,KAAKlF,YAAY6E,GACrB,IAAIM,EAAMxJ,EAAEsJ,EAAEG,YAAY,eAC1BD,EAAIE,UAAU,SAAS,GAAM,GAC7BR,EAAOS,cAAcH,GACrBxJ,EAAEsJ,EAAEC,KAAKK,YAAYV,QAErB3D,SAAS6D,KAAOH,GAI5BY,gBAAgBC,EAAMtC,GACdsC,IAAShK,OAAOiK,WAAWzF,QAC3BZ,KAAKY,UAKjB,IAAI0F,EAAoB,IAAIlK,OAAOmK,OAAO,cAAc,SAAUxG,GAC9D,IAAIyG,EAAM,IAAI3G,EAAWE,GACzBA,EAAGF,WAAa2G,EAChBzG,EAAGc,MAAQ,WACP2F,EAAI3F,SAERd,EAAG0G,oBAAmB,SAAUL,EAAMtC,GAClC0C,EAAIL,gBAAgBO,KAAKF,EAAKJ,EAAMtC,SAI5C1H,OAAOuK,gBAAgBL"}
|
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* @license BSD
|
|
3
|
+
* @copyright 2014-2022 hizzgdev@163.com
|
|
4
4
|
*
|
|
5
5
|
* Project Home:
|
|
6
6
|
* https://github.com/hizzgdev/jsmind/
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
(function($w){
|
|
9
|
+
(function ($w) {
|
|
10
10
|
'use strict';
|
|
11
11
|
var $d = $w.document;
|
|
12
12
|
var __name__ = 'jsMind';
|
|
13
13
|
var jsMind = $w[__name__];
|
|
14
|
-
if(!jsMind){return;}
|
|
15
|
-
if(typeof jsMind.draggable != 'undefined'){return;}
|
|
14
|
+
if (!jsMind) { return; }
|
|
15
|
+
if (typeof jsMind.draggable != 'undefined') { return; }
|
|
16
16
|
|
|
17
17
|
var jdom = jsMind.util.dom;
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} : function(){
|
|
23
|
-
$d.selection.empty();
|
|
18
|
+
var clear_selection = 'getSelection' in $w ? function () {
|
|
19
|
+
$w.getSelection().removeAllRanges();
|
|
20
|
+
} : function () {
|
|
21
|
+
$d.selection.empty();
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
var options = {
|
|
27
|
-
line_width
|
|
28
|
-
lookup_delay
|
|
29
|
-
lookup_interval
|
|
25
|
+
line_width: 5,
|
|
26
|
+
lookup_delay: 500,
|
|
27
|
+
lookup_interval: 80
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
jsMind.draggable = function(jm){
|
|
30
|
+
jsMind.draggable = function (jm) {
|
|
33
31
|
this.jm = jm;
|
|
34
32
|
this.e_canvas = null;
|
|
35
33
|
this.canvas_ctx = null;
|
|
@@ -50,19 +48,19 @@
|
|
|
50
48
|
};
|
|
51
49
|
|
|
52
50
|
jsMind.draggable.prototype = {
|
|
53
|
-
init:function(){
|
|
51
|
+
init: function () {
|
|
54
52
|
this._create_canvas();
|
|
55
53
|
this._create_shadow();
|
|
56
54
|
this._event_bind();
|
|
57
55
|
},
|
|
58
56
|
|
|
59
|
-
resize:function(){
|
|
57
|
+
resize: function () {
|
|
60
58
|
this.jm.view.e_nodes.appendChild(this.shadow);
|
|
61
|
-
this.e_canvas.width=this.jm.view.size.w;
|
|
62
|
-
this.e_canvas.height=this.jm.view.size.h;
|
|
59
|
+
this.e_canvas.width = this.jm.view.size.w;
|
|
60
|
+
this.e_canvas.height = this.jm.view.size.h;
|
|
63
61
|
},
|
|
64
62
|
|
|
65
|
-
_create_canvas:function(){
|
|
63
|
+
_create_canvas: function () {
|
|
66
64
|
var c = $d.createElement('canvas');
|
|
67
65
|
this.jm.view.e_panel.appendChild(c);
|
|
68
66
|
var ctx = c.getContext('2d');
|
|
@@ -70,16 +68,16 @@
|
|
|
70
68
|
this.canvas_ctx = ctx;
|
|
71
69
|
},
|
|
72
70
|
|
|
73
|
-
_create_shadow:function(){
|
|
71
|
+
_create_shadow: function () {
|
|
74
72
|
var s = $d.createElement('jmnode');
|
|
75
73
|
s.style.visibility = 'hidden';
|
|
76
74
|
s.style.zIndex = '3';
|
|
77
75
|
s.style.cursor = 'move';
|
|
78
|
-
s.style.opacity= '0.7';
|
|
76
|
+
s.style.opacity = '0.7';
|
|
79
77
|
this.shadow = s;
|
|
80
78
|
},
|
|
81
79
|
|
|
82
|
-
reset_shadow:function(el){
|
|
80
|
+
reset_shadow: function (el) {
|
|
83
81
|
var s = this.shadow.style;
|
|
84
82
|
this.shadow.innerHTML = el.innerHTML;
|
|
85
83
|
s.left = el.style.left;
|
|
@@ -94,77 +92,84 @@
|
|
|
94
92
|
|
|
95
93
|
},
|
|
96
94
|
|
|
97
|
-
show_shadow:function(){
|
|
98
|
-
if(!this.moved){
|
|
95
|
+
show_shadow: function () {
|
|
96
|
+
if (!this.moved) {
|
|
99
97
|
this.shadow.style.visibility = 'visible';
|
|
100
98
|
}
|
|
101
99
|
},
|
|
102
100
|
|
|
103
|
-
hide_shadow:function(){
|
|
101
|
+
hide_shadow: function () {
|
|
104
102
|
this.shadow.style.visibility = 'hidden';
|
|
105
103
|
},
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
_magnet_shadow:function(node){
|
|
112
|
-
if(!!node){
|
|
105
|
+
_magnet_shadow: function (node) {
|
|
106
|
+
if (!!node) {
|
|
113
107
|
this.canvas_ctx.lineWidth = options.line_width;
|
|
114
108
|
this.canvas_ctx.strokeStyle = 'rgba(0,0,0,0.3)';
|
|
115
109
|
this.canvas_ctx.lineCap = 'round';
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
node.sp.x,
|
|
119
|
-
node.sp.y,
|
|
120
|
-
node.np.x,
|
|
121
|
-
node.np.y);
|
|
110
|
+
this._clear_lines();
|
|
111
|
+
this._canvas_lineto(node.sp.x, node.sp.y, node.np.x, node.np.y);
|
|
122
112
|
}
|
|
123
113
|
},
|
|
124
114
|
|
|
125
|
-
|
|
115
|
+
_clear_lines: function () {
|
|
116
|
+
this.canvas_ctx.clearRect(0, 0, this.jm.view.size.w, this.jm.view.size.h);
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
_canvas_lineto: function (x1, y1, x2, y2) {
|
|
120
|
+
this.canvas_ctx.beginPath();
|
|
121
|
+
this.canvas_ctx.moveTo(x1, y1);
|
|
122
|
+
this.canvas_ctx.lineTo(x2, y2);
|
|
123
|
+
this.canvas_ctx.stroke();
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
_lookup_close_node: function () {
|
|
126
127
|
var root = this.jm.get_root();
|
|
127
128
|
var root_location = root.get_location();
|
|
128
129
|
var root_size = root.get_size();
|
|
129
|
-
var root_x = root_location.x + root_size.w/2;
|
|
130
|
+
var root_x = root_location.x + root_size.w / 2;
|
|
130
131
|
|
|
131
132
|
var sw = this.shadow_w;
|
|
132
133
|
var sh = this.shadow_h;
|
|
133
134
|
var sx = this.shadow.offsetLeft;
|
|
134
135
|
var sy = this.shadow.offsetTop;
|
|
135
136
|
|
|
136
|
-
var ns,nl;
|
|
137
|
+
var ns, nl;
|
|
137
138
|
|
|
138
|
-
var direct = (sx + sw/2)>=root_x ?
|
|
139
|
-
|
|
139
|
+
var direct = (sx + sw / 2) >= root_x ?
|
|
140
|
+
jsMind.direction.right : jsMind.direction.left;
|
|
140
141
|
var nodes = this.jm.mind.nodes;
|
|
141
142
|
var node = null;
|
|
143
|
+
var layout = this.jm.layout;
|
|
142
144
|
var min_distance = Number.MAX_VALUE;
|
|
143
145
|
var distance = 0;
|
|
144
146
|
var closest_node = null;
|
|
145
147
|
var closest_p = null;
|
|
146
148
|
var shadow_p = null;
|
|
147
|
-
for(var nodeid in nodes){
|
|
148
|
-
var np,sp;
|
|
149
|
+
for (var nodeid in nodes) {
|
|
150
|
+
var np, sp;
|
|
149
151
|
node = nodes[nodeid];
|
|
150
|
-
if(node.isroot || node.direction == direct){
|
|
151
|
-
if(node.id == this.active_node.id){
|
|
152
|
+
if (node.isroot || node.direction == direct) {
|
|
153
|
+
if (node.id == this.active_node.id) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (!layout.is_visible(node)) {
|
|
152
157
|
continue;
|
|
153
158
|
}
|
|
154
159
|
ns = node.get_size();
|
|
155
160
|
nl = node.get_location();
|
|
156
|
-
if(direct == jsMind.direction.right){
|
|
157
|
-
if(sx-nl.x-ns.w<=0){continue;}
|
|
158
|
-
distance = Math.abs(sx-nl.x-ns.w) + Math.abs(sy+sh/2-nl.y-ns.h/2);
|
|
159
|
-
np = {x:nl.x+ns.w-options.line_width,y:nl.y+ns.h/2};
|
|
160
|
-
sp = {x:sx+options.line_width,y:sy+sh/2};
|
|
161
|
-
}else{
|
|
162
|
-
if(nl.x-sx-sw<=0){continue;}
|
|
163
|
-
distance = Math.abs(sx+sw-nl.x) + Math.abs(sy+sh/2-nl.y-ns.h/2);
|
|
164
|
-
np = {x:nl.x+options.line_width,y:nl.y+ns.h/2};
|
|
165
|
-
sp = {x:sx+sw-options.line_width,y:sy+sh/2};
|
|
161
|
+
if (direct == jsMind.direction.right) {
|
|
162
|
+
if (sx - nl.x - ns.w <= 0) { continue; }
|
|
163
|
+
distance = Math.abs(sx - nl.x - ns.w) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
|
|
164
|
+
np = { x: nl.x + ns.w - options.line_width, y: nl.y + ns.h / 2 };
|
|
165
|
+
sp = { x: sx + options.line_width, y: sy + sh / 2 };
|
|
166
|
+
} else {
|
|
167
|
+
if (nl.x - sx - sw <= 0) { continue; }
|
|
168
|
+
distance = Math.abs(sx + sw - nl.x) + Math.abs(sy + sh / 2 - nl.y - ns.h / 2);
|
|
169
|
+
np = { x: nl.x + options.line_width, y: nl.y + ns.h / 2 };
|
|
170
|
+
sp = { x: sx + sw - options.line_width, y: sy + sh / 2 };
|
|
166
171
|
}
|
|
167
|
-
if(distance < min_distance){
|
|
172
|
+
if (distance < min_distance) {
|
|
168
173
|
closest_node = node;
|
|
169
174
|
closest_p = np;
|
|
170
175
|
shadow_p = sp;
|
|
@@ -173,126 +178,127 @@
|
|
|
173
178
|
}
|
|
174
179
|
}
|
|
175
180
|
var result_node = null;
|
|
176
|
-
if(!!closest_node){
|
|
181
|
+
if (!!closest_node) {
|
|
177
182
|
result_node = {
|
|
178
|
-
node:closest_node,
|
|
179
|
-
direction:direct,
|
|
180
|
-
sp:shadow_p,
|
|
181
|
-
np:closest_p
|
|
183
|
+
node: closest_node,
|
|
184
|
+
direction: direct,
|
|
185
|
+
sp: shadow_p,
|
|
186
|
+
np: closest_p
|
|
182
187
|
};
|
|
183
188
|
}
|
|
184
189
|
return result_node;
|
|
185
190
|
},
|
|
186
191
|
|
|
187
|
-
lookup_close_node:function(){
|
|
192
|
+
lookup_close_node: function () {
|
|
188
193
|
var node_data = this._lookup_close_node();
|
|
189
|
-
if(!!node_data){
|
|
194
|
+
if (!!node_data) {
|
|
190
195
|
this._magnet_shadow(node_data);
|
|
191
196
|
this.target_node = node_data.node;
|
|
192
197
|
this.target_direct = node_data.direction;
|
|
193
198
|
}
|
|
194
199
|
},
|
|
195
200
|
|
|
196
|
-
_event_bind:function(){
|
|
201
|
+
_event_bind: function () {
|
|
197
202
|
var jd = this;
|
|
198
203
|
var container = this.jm.view.container;
|
|
199
|
-
jdom.add_event(container,'mousedown',function(e){
|
|
204
|
+
jdom.add_event(container, 'mousedown', function (e) {
|
|
200
205
|
var evt = e || event;
|
|
201
|
-
jd.dragstart.call(jd,evt);
|
|
206
|
+
jd.dragstart.call(jd, evt);
|
|
202
207
|
});
|
|
203
|
-
jdom.add_event(container,'mousemove',function(e){
|
|
208
|
+
jdom.add_event(container, 'mousemove', function (e) {
|
|
204
209
|
var evt = e || event;
|
|
205
|
-
jd.drag.call(jd,evt);
|
|
210
|
+
jd.drag.call(jd, evt);
|
|
206
211
|
});
|
|
207
|
-
jdom.add_event(container,'mouseup',function(e){
|
|
212
|
+
jdom.add_event(container, 'mouseup', function (e) {
|
|
208
213
|
var evt = e || event;
|
|
209
|
-
jd.dragend.call(jd,evt);
|
|
214
|
+
jd.dragend.call(jd, evt);
|
|
210
215
|
});
|
|
211
|
-
jdom.add_event(container,'touchstart',function(e){
|
|
216
|
+
jdom.add_event(container, 'touchstart', function (e) {
|
|
212
217
|
var evt = e || event;
|
|
213
|
-
jd.dragstart.call(jd,evt);
|
|
218
|
+
jd.dragstart.call(jd, evt);
|
|
214
219
|
});
|
|
215
|
-
jdom.add_event(container,'touchmove',function(e){
|
|
220
|
+
jdom.add_event(container, 'touchmove', function (e) {
|
|
216
221
|
var evt = e || event;
|
|
217
|
-
jd.drag.call(jd,evt);
|
|
222
|
+
jd.drag.call(jd, evt);
|
|
218
223
|
});
|
|
219
|
-
jdom.add_event(container,'touchend',function(e){
|
|
224
|
+
jdom.add_event(container, 'touchend', function (e) {
|
|
220
225
|
var evt = e || event;
|
|
221
|
-
jd.dragend.call(jd,evt);
|
|
226
|
+
jd.dragend.call(jd, evt);
|
|
222
227
|
});
|
|
223
228
|
},
|
|
224
229
|
|
|
225
|
-
dragstart:function(e){
|
|
226
|
-
if(!this.jm.get_editable()){return;}
|
|
227
|
-
if(this.capture){return;}
|
|
230
|
+
dragstart: function (e) {
|
|
231
|
+
if (!this.jm.get_editable()) { return; }
|
|
232
|
+
if (this.capture) { return; }
|
|
228
233
|
this.active_node = null;
|
|
229
234
|
|
|
230
235
|
var jview = this.jm.view;
|
|
231
236
|
var el = e.target || event.srcElement;
|
|
232
|
-
if(el.tagName.toLowerCase() != 'jmnode'){return;}
|
|
237
|
+
if (el.tagName.toLowerCase() != 'jmnode') { return; }
|
|
238
|
+
if (jview.get_draggable_canvas()) { jview.disable_draggable_canvas() }
|
|
233
239
|
var nodeid = jview.get_binded_nodeid(el);
|
|
234
|
-
if(!!nodeid){
|
|
240
|
+
if (!!nodeid) {
|
|
235
241
|
var node = this.jm.get_node(nodeid);
|
|
236
|
-
if(!node.isroot){
|
|
242
|
+
if (!node.isroot) {
|
|
237
243
|
this.reset_shadow(el);
|
|
238
244
|
this.active_node = node;
|
|
239
|
-
this.offset_x = (e.clientX || e.touches[0].clientX) - el.offsetLeft;
|
|
240
|
-
this.offset_y = (e.clientY || e.touches[0].clientY) - el.offsetTop;
|
|
241
|
-
this.client_hw = Math.floor(el.clientWidth/2);
|
|
242
|
-
this.client_hh = Math.floor(el.clientHeight/2);
|
|
243
|
-
if(this.hlookup_delay != 0){
|
|
245
|
+
this.offset_x = (e.clientX || e.touches[0].clientX) / jview.actualZoom - el.offsetLeft;
|
|
246
|
+
this.offset_y = (e.clientY || e.touches[0].clientY) / jview.actualZoom - el.offsetTop;
|
|
247
|
+
this.client_hw = Math.floor(el.clientWidth / 2);
|
|
248
|
+
this.client_hh = Math.floor(el.clientHeight / 2);
|
|
249
|
+
if (this.hlookup_delay != 0) {
|
|
244
250
|
$w.clearTimeout(this.hlookup_delay);
|
|
245
251
|
}
|
|
246
|
-
if(this.hlookup_timer != 0){
|
|
252
|
+
if (this.hlookup_timer != 0) {
|
|
247
253
|
$w.clearInterval(this.hlookup_timer);
|
|
248
254
|
}
|
|
249
255
|
var jd = this;
|
|
250
|
-
this.hlookup_delay = $w.setTimeout(function(){
|
|
256
|
+
this.hlookup_delay = $w.setTimeout(function () {
|
|
251
257
|
jd.hlookup_delay = 0;
|
|
252
|
-
jd.hlookup_timer = $w.setInterval(function(){
|
|
258
|
+
jd.hlookup_timer = $w.setInterval(function () {
|
|
253
259
|
jd.lookup_close_node.call(jd);
|
|
254
|
-
},options.lookup_interval);
|
|
255
|
-
},options.lookup_delay);
|
|
260
|
+
}, options.lookup_interval);
|
|
261
|
+
}, options.lookup_delay);
|
|
256
262
|
this.capture = true;
|
|
257
263
|
}
|
|
258
264
|
}
|
|
259
265
|
},
|
|
260
266
|
|
|
261
|
-
drag:function(e){
|
|
262
|
-
if(!this.jm.get_editable()){return;}
|
|
263
|
-
if(this.capture){
|
|
267
|
+
drag: function (e) {
|
|
268
|
+
if (!this.jm.get_editable()) { return; }
|
|
269
|
+
if (this.capture) {
|
|
264
270
|
e.preventDefault();
|
|
265
271
|
this.show_shadow();
|
|
266
272
|
this.moved = true;
|
|
267
273
|
clear_selection();
|
|
268
|
-
var
|
|
269
|
-
var
|
|
270
|
-
var
|
|
271
|
-
var cy = py + this.client_hh;
|
|
274
|
+
var jview = this.jm.view;
|
|
275
|
+
var px = (e.clientX || e.touches[0].clientX) / jview.actualZoom - this.offset_x;
|
|
276
|
+
var py = (e.clientY || e.touches[0].clientY) / jview.actualZoom - this.offset_y;
|
|
272
277
|
this.shadow.style.left = px + 'px';
|
|
273
278
|
this.shadow.style.top = py + 'px';
|
|
274
279
|
clear_selection();
|
|
275
280
|
}
|
|
276
281
|
},
|
|
277
282
|
|
|
278
|
-
dragend:function(e){
|
|
279
|
-
if(!this.jm.get_editable()){return;}
|
|
280
|
-
if(this.
|
|
281
|
-
|
|
283
|
+
dragend: function (e) {
|
|
284
|
+
if (!this.jm.get_editable()) { return; }
|
|
285
|
+
if (this.jm.view.get_draggable_canvas()) { this.jm.view.enable_draggable_canvas() }
|
|
286
|
+
if (this.capture) {
|
|
287
|
+
if (this.hlookup_delay != 0) {
|
|
282
288
|
$w.clearTimeout(this.hlookup_delay);
|
|
283
289
|
this.hlookup_delay = 0;
|
|
284
|
-
this.
|
|
290
|
+
this._clear_lines();
|
|
285
291
|
}
|
|
286
|
-
if(this.hlookup_timer != 0){
|
|
292
|
+
if (this.hlookup_timer != 0) {
|
|
287
293
|
$w.clearInterval(this.hlookup_timer);
|
|
288
294
|
this.hlookup_timer = 0;
|
|
289
|
-
this.
|
|
295
|
+
this._clear_lines();
|
|
290
296
|
}
|
|
291
|
-
if(this.moved){
|
|
297
|
+
if (this.moved) {
|
|
292
298
|
var src_node = this.active_node;
|
|
293
299
|
var target_node = this.target_node;
|
|
294
300
|
var target_direct = this.target_direct;
|
|
295
|
-
this.move_node(src_node,target_node,target_direct);
|
|
301
|
+
this.move_node(src_node, target_node, target_direct);
|
|
296
302
|
}
|
|
297
303
|
this.hide_shadow();
|
|
298
304
|
}
|
|
@@ -300,9 +306,9 @@
|
|
|
300
306
|
this.capture = false;
|
|
301
307
|
},
|
|
302
308
|
|
|
303
|
-
move_node:function(src_node,target_node,target_direct){
|
|
309
|
+
move_node: function (src_node, target_node, target_direct) {
|
|
304
310
|
var shadow_h = this.shadow.offsetTop;
|
|
305
|
-
if(!!target_node && !!src_node && !jsMind.node.inherited(src_node, target_node)){
|
|
311
|
+
if (!!target_node && !!src_node && !jsMind.node.inherited(src_node, target_node)) {
|
|
306
312
|
// lookup before_node
|
|
307
313
|
var sibling_nodes = target_node.children;
|
|
308
314
|
var sc = sibling_nodes.length;
|
|
@@ -310,18 +316,18 @@
|
|
|
310
316
|
var delta_y = Number.MAX_VALUE;
|
|
311
317
|
var node_before = null;
|
|
312
318
|
var beforeid = '_last_';
|
|
313
|
-
while(sc--){
|
|
319
|
+
while (sc--) {
|
|
314
320
|
node = sibling_nodes[sc];
|
|
315
|
-
if(node.direction == target_direct && node.id != src_node.id){
|
|
321
|
+
if (node.direction == target_direct && node.id != src_node.id) {
|
|
316
322
|
var dy = node.get_location().y - shadow_h;
|
|
317
|
-
if(dy > 0 && dy < delta_y){
|
|
323
|
+
if (dy > 0 && dy < delta_y) {
|
|
318
324
|
delta_y = dy;
|
|
319
325
|
node_before = node;
|
|
320
326
|
beforeid = '_first_';
|
|
321
327
|
}
|
|
322
328
|
}
|
|
323
329
|
}
|
|
324
|
-
if(!!node_before){beforeid = node_before.id;}
|
|
330
|
+
if (!!node_before) { beforeid = node_before.id; }
|
|
325
331
|
this.jm.move_node(src_node.id, beforeid, target_node.id, target_direct);
|
|
326
332
|
}
|
|
327
333
|
this.active_node = null;
|
|
@@ -329,18 +335,18 @@
|
|
|
329
335
|
this.target_direct = null;
|
|
330
336
|
},
|
|
331
337
|
|
|
332
|
-
jm_event_handle:function(type,data){
|
|
333
|
-
if(type === jsMind.event_type.resize){
|
|
338
|
+
jm_event_handle: function (type, data) {
|
|
339
|
+
if (type === jsMind.event_type.resize) {
|
|
334
340
|
this.resize();
|
|
335
341
|
}
|
|
336
342
|
}
|
|
337
343
|
};
|
|
338
344
|
|
|
339
|
-
var draggable_plugin = new jsMind.plugin('draggable',function(jm){
|
|
345
|
+
var draggable_plugin = new jsMind.plugin('draggable', function (jm) {
|
|
340
346
|
var jd = new jsMind.draggable(jm);
|
|
341
347
|
jd.init();
|
|
342
|
-
jm.add_event_listener(function(type,data){
|
|
343
|
-
jd.jm_event_handle.call(jd,type,data);
|
|
348
|
+
jm.add_event_listener(function (type, data) {
|
|
349
|
+
jd.jm_event_handle.call(jd, type, data);
|
|
344
350
|
});
|
|
345
351
|
});
|
|
346
352
|
|