mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-06-03 00:54:32 +02:00
Compare commits
895 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
74d3b09beb | ||
|
5c26624b00 | ||
|
f19f2bb0c9 | ||
|
209f4fc01e | ||
|
e98d6ca2a9 | ||
|
712fbaa3a7 | ||
|
19d083e218 | ||
|
15325672a0 | ||
|
cd3d21f106 | ||
|
12b0bb4866 | ||
|
2c1e634a1a | ||
|
597e3ab165 | ||
|
1c73a8d79d | ||
|
68c8f5c6b8 | ||
|
d26b516eb9 | ||
|
538083ae83 | ||
|
60923e4c8b | ||
|
214e3938c1 | ||
|
f49ae37866 | ||
|
ad158e4821 | ||
|
769968376b | ||
|
9668823c31 | ||
|
55c104cfbe | ||
|
92edef9bd6 | ||
|
884a93478b | ||
|
63975464ca | ||
|
2b918a0df3 | ||
|
9c1320b63b | ||
|
1589665633 | ||
|
479eb6db2c | ||
|
a739bb3e0b | ||
|
50e4a68d28 | ||
|
8ec7c4edea | ||
|
480fd49fd0 | ||
|
61c691fc82 | ||
|
3eaeb8f500 | ||
|
07e8259417 | ||
|
ab15fb2d36 | ||
|
315267e68c | ||
|
881a16b908 | ||
|
dd8f5ab1ea | ||
|
0c37ed904a | ||
|
946ef517d3 | ||
|
5116a18952 | ||
|
3467114a8a | ||
|
cda97891ba | ||
|
675802dab7 | ||
|
8b72f75b56 | ||
|
e85a670695 | ||
|
28dc77c501 | ||
|
c4ae51b50e | ||
|
9912897879 | ||
|
8d3983fd08 | ||
|
169c6e6538 | ||
|
4bb2960716 | ||
|
70c0b0c532 | ||
|
0b96026507 | ||
|
87712b2493 | ||
|
c783feef65 | ||
|
ea12d0246c | ||
|
4f94d7117a | ||
|
abcd0d8515 | ||
|
1742b268a9 | ||
|
aaa8d5f0f3 | ||
|
553688b070 | ||
|
d2788ae00e | ||
|
d4840b9c20 | ||
|
b8601d7029 | ||
|
86682ca7d8 | ||
|
762ebabe7e | ||
|
30b2e7e8eb | ||
|
5844663701 | ||
|
55c5126d95 | ||
|
734ec3df67 | ||
|
40afd70780 | ||
|
4ebef65728 | ||
|
e55e7e8867 | ||
|
1340fff68a | ||
|
68aa7c20eb | ||
|
963ed70d8d | ||
|
0090464d88 | ||
|
53173ec75d | ||
|
a66dff8ae4 | ||
1d7633b65c | |||
|
f72b89d59a | ||
|
30098527b5 | ||
|
ae633022ab | ||
|
6ff203f019 | ||
|
87bd4bf182 | ||
|
fb1de1fcca | ||
|
fd07ea6102 | ||
|
046c2af947 | ||
|
bb14c0d1c5 | ||
|
9871ad6843 | ||
|
33f9eae3cb | ||
|
d918f210aa | ||
|
fa6c0bac33 | ||
|
c41796a54b | ||
|
e3bcaec5de | ||
|
c2bec7ca4a | ||
|
198038f110 | ||
|
df72b64e1b | ||
|
1f59f26c07 | ||
|
8c17b4bdcd | ||
|
c92ff3154f | ||
|
b1805f55b2 | ||
|
1379a593ae | ||
|
4967a5b930 | ||
|
02ee11a094 | ||
|
6acde03327 | ||
|
7918bc20d0 | ||
|
11ee64fcf1 | ||
|
ca27e37c4b | ||
|
917442f418 | ||
|
3f00b76bd6 | ||
|
0769a511b5 | ||
|
c138f7b667 | ||
|
ef6d50b26d | ||
|
439b237caa | ||
|
39ff7622f3 | ||
|
766de183eb | ||
|
844a3768b0 | ||
|
16180f4c6d | ||
|
2592d338bb | ||
|
d88e655eee | ||
|
6205cba586 | ||
|
7f6343bdc8 | ||
|
ac3f4bed31 | ||
|
f6a8cbdf38 | ||
|
b34eabc800 | ||
|
72368be54e | ||
|
da6feccc5b | ||
|
5a79c1ef38 | ||
|
ea071562ca | ||
|
4f701d0b74 | ||
|
34b00a8a7f | ||
|
11dba85641 | ||
|
35d8e19c3c | ||
|
16ac1c468d | ||
|
52d6a12e0f | ||
|
23b0f7351e | ||
|
49732ec06d | ||
|
6c78eb078f | ||
|
17e04a6f3f | ||
|
59d7ffd9c5 | ||
|
24e2ba93f3 | ||
|
6cd0f635d5 | ||
|
4ee62035b8 | ||
|
38639e18aa | ||
|
e3a60102fb | ||
|
7c060ee192 | ||
|
2981fe79f7 | ||
|
c5009e8a07 | ||
|
44bb67936b | ||
|
6b220ccb81 | ||
|
4d8c2aa6cb | ||
|
308092abbd | ||
|
b97d5b1a00 | ||
|
ad84282ef8 | ||
|
5b4a6e4c78 | ||
|
103534475d | ||
|
2146e2e457 | ||
|
f0531551d7 | ||
|
e511d5e23d | ||
|
aa6ac9bf7f | ||
|
5f26874b47 | ||
|
599bc9ec00 | ||
|
708a42c560 | ||
|
86964febc1 | ||
|
0c88b8a474 | ||
|
225a913a3a | ||
|
047c8cce9d | ||
|
704fb1a880 | ||
|
b5e7389e41 | ||
|
39bb8f458b | ||
|
242906d6d4 | ||
|
0301c5c63a | ||
|
befb252850 | ||
|
0c2c6c0b6e | ||
|
fecd5f3592 | ||
|
48eae09985 | ||
|
b431c90758 | ||
|
27f64e9feb | ||
|
7af9822777 | ||
|
5f687fa78b | ||
|
777a5a5212 | ||
|
485814f22a | ||
|
cb2436889b | ||
|
f7369e33dc | ||
|
edaa4b78f4 | ||
|
8ffb48d095 | ||
|
cf0d19de4e | ||
|
845fb2f1df | ||
|
8554fb7507 | ||
|
a49b870f03 | ||
|
0920dab922 | ||
|
c5dca51df9 | ||
|
038c4fa6fe | ||
|
b44ace6992 | ||
|
1290261966 | ||
|
d831c9d81f | ||
|
51cfa961e6 | ||
|
1cabb59b2f | ||
|
0f1e0d29f2 | ||
|
deb4cf498a | ||
|
3732e858b5 | ||
|
3e9a5a0b12 | ||
|
7af7925610 | ||
|
c6ddadba45 | ||
|
50e0069532 | ||
|
b0517db79e | ||
|
c76ae8da06 | ||
|
b8b63509d0 | ||
|
735bb640b6 | ||
|
f1cfef8cf0 | ||
|
e435cd4666 | ||
|
08374056cc | ||
|
86a0a876ca | ||
|
a618849afc | ||
|
ad20d06d19 | ||
|
accf252e78 | ||
|
641bcbbe17 | ||
|
8248e162fe | ||
|
6f19323292 | ||
|
8a5bd2de94 | ||
|
6508b9eb67 | ||
|
1ac332a18e | ||
|
e9ff9b36fc | ||
|
5fa6a82b3a | ||
|
de5febaf15 | ||
|
b4fb536137 | ||
|
86a5b39124 | ||
|
791b99e753 | ||
|
d063e4eb20 | ||
|
ff2b37f4cf | ||
|
8989914eb3 | ||
|
f70f1d89ab | ||
|
50f0dba93a | ||
|
20b2e8f1e8 | ||
|
c5c47892cb | ||
|
9d08ad57b9 | ||
|
d380b97938 | ||
|
b8eadb7533 | ||
|
63f83e879d | ||
|
0ee642c246 | ||
|
20a9978577 | ||
|
b18505050a | ||
|
f4cf7e623e | ||
|
cbdd6ebb47 | ||
|
fdd6fb928b | ||
|
340ddcd1ef | ||
|
92dd4a7014 | ||
|
a9d091a187 | ||
|
4cab5299c4 | ||
|
9d35aa8279 | ||
|
c769a5fbe7 | ||
|
7ca5bf716f | ||
|
e38c1bcc7c | ||
|
c978d02514 | ||
|
c68c43f5d7 | ||
|
5694697c5f | ||
|
d217768b83 | ||
|
d0a03ad2a3 | ||
|
ffd976ffe5 | ||
|
297931508a | ||
|
5c201d40df | ||
|
1acf84de3f | ||
|
f5fabae644 | ||
|
e0dac73873 | ||
|
a8e2c74a21 | ||
|
8d5245da5a | ||
|
67cc7e586c | ||
|
732127a7a9 | ||
|
b60f5b331f | ||
|
82a3e1c793 | ||
|
402393a9f7 | ||
|
5cdf2d6de2 | ||
|
c5f1ca88be | ||
|
194e858191 | ||
|
6892732389 | ||
|
8b61809bbe | ||
|
c3be0b6552 | ||
|
ba80f9479c | ||
|
50fa9d80f5 | ||
|
5bb6f199c3 | ||
|
31980ca444 | ||
|
dd8e9e2f5d | ||
|
77a1560625 | ||
|
2cda03e80d | ||
|
73b0454d14 | ||
|
fbbd2c43ff | ||
|
c3f93fdf4a | ||
|
342099194d | ||
|
0cd62f612b | ||
|
820e268e3e | ||
|
aa6531efe1 | ||
|
859c3dd927 | ||
|
93f3e91cc1 | ||
|
f7a9804065 | ||
|
1c8f3bb203 | ||
|
6aadb5a363 | ||
|
f2c15d100d | ||
|
9966412705 | ||
|
e1bd2630aa | ||
|
bea7bea486 | ||
|
fad7442ffc | ||
|
1eab15f8f3 | ||
|
8e080075a0 | ||
|
f0f32178c7 | ||
|
7cf2644fa8 | ||
|
5c18c44a2f | ||
|
f16762636b | ||
|
1f99ce3889 | ||
|
63cfe44d50 | ||
|
07ad57e3b4 | ||
|
7fd227d56f | ||
|
5d7e7f8d30 | ||
|
d69373f563 | ||
|
7d7373768f | ||
|
5c0c18eba0 | ||
|
188b280bf2 | ||
|
6f205e04ce | ||
|
ff4c7d2949 | ||
|
fb1755768c | ||
|
c269cd9edb | ||
|
89dd7e0193 | ||
|
ccc0b10ea0 | ||
|
83cff3f66d | ||
|
f35d145fb8 | ||
|
609fdd7144 | ||
|
b67cd407a4 | ||
|
6c808dfc2a | ||
|
9af7247072 | ||
|
ea1349c518 | ||
|
607418dcf7 | ||
|
0da8c73d74 | ||
|
cd0ff1dc89 | ||
|
19ae88e93f | ||
|
ebea27b3df | ||
|
13f8eb0898 | ||
|
aed943ce5a | ||
|
d9c7db9c1f | ||
|
4f662acefe | ||
|
6abc5a9e5e | ||
|
571895a2b3 | ||
|
62e009b7e4 | ||
|
4e45aea3f9 | ||
|
50e09762b2 | ||
|
11e4a4a76a | ||
|
a5cc7f2e5b | ||
|
45bdd80f8d | ||
|
afa73b6a44 | ||
|
e5200d337b | ||
|
ae80d74122 | ||
|
faa0f4cf72 | ||
|
1c83dd62d6 | ||
|
265d493dfd | ||
|
c55025f07f | ||
|
119eb03f53 | ||
|
f68a3ac7bc | ||
|
06fbf208ec | ||
|
677bfe8b89 | ||
|
a71f083416 | ||
|
bcd3384829 | ||
|
45ec4b371f | ||
|
466163f791 | ||
|
993b998bfc | ||
|
aa3d6c556d | ||
|
5bea640a83 | ||
|
a0b8bdb924 | ||
|
023d7f39a2 | ||
|
8fe80a95d0 | ||
|
19e29957c5 | ||
|
844edf2f61 | ||
|
83f5a04197 | ||
|
82a22af590 | ||
|
904b4e8547 | ||
|
058bb4ef1c | ||
|
f25a1279a3 | ||
|
19354f4ec1 | ||
|
5923d514b7 | ||
|
eabc55307c | ||
|
6307af005c | ||
|
f844692e66 | ||
|
7fc91abe59 | ||
|
4668cba3bf | ||
|
202b3dd285 | ||
|
75997b11b3 | ||
|
451c181fd6 | ||
|
fc182bc69f | ||
|
5db0b756bf | ||
|
ba71ff848f | ||
|
9cba042f70 | ||
|
dcc9bdcdef | ||
|
7bab7ccd53 | ||
|
d2617f8358 | ||
|
7f8b9a8121 | ||
|
a6b6d67277 | ||
|
decc76015c | ||
|
b1b8dde547 | ||
|
618ea57d17 | ||
|
0f9877e17f | ||
|
4a3900c44c | ||
|
a118547523 | ||
|
86b83807f4 | ||
|
3bac526593 | ||
|
9b5b4b2eda | ||
|
897e7d90a5 | ||
|
101dbd81c3 | ||
|
761b2e5ee0 | ||
|
965c65e793 | ||
|
e40330e720 | ||
|
0f9639fc73 | ||
|
006698341c | ||
|
b2fe5f220f | ||
|
dbf8cee1c5 | ||
|
541e1f9e55 | ||
|
d64067a5ff | ||
|
b4f53b7633 | ||
|
47ca2e3365 | ||
|
18f109587d | ||
|
5c5af9ecfe | ||
|
e244d694f5 | ||
|
307d8ea2b8 | ||
|
758e18dffc | ||
|
0885c9e27e | ||
|
7153b0b103 | ||
|
ea5e990b76 | ||
|
2ee4a1bcd0 | ||
|
24941d6e57 | ||
|
4fb144b63c | ||
|
6b97736d59 | ||
|
628d819325 | ||
|
71fefdd8c6 | ||
|
ac7fd7e706 | ||
|
99e5066746 | ||
|
c387eca16c | ||
|
c5c95c55d8 | ||
|
b7d6bcb5d9 | ||
|
955a363ce5 | ||
|
fbc9a978f2 | ||
|
9cb4018ce4 | ||
|
b3e26caee4 | ||
|
76ff1cc83d | ||
|
39ff095df7 | ||
|
cade40e1a3 | ||
|
4e0c621994 | ||
|
23631b8ac3 | ||
|
50eabdebc4 | ||
|
e8a246d980 | ||
|
7a5b4ca75a | ||
|
3ef7f6a7f0 | ||
|
dcd04df8df | ||
|
4c5097a8fc | ||
|
eae4c9b512 | ||
|
939478cda5 | ||
|
ddb7de8c63 | ||
|
306c34d7d5 | ||
|
62fa88cb3e | ||
|
3a006f1fbc | ||
|
64411c6232 | ||
|
2a485b71db | ||
|
df88b7d0ff | ||
|
49c459f386 | ||
|
430b30bffb | ||
|
1a524434da | ||
|
4778433466 | ||
|
c230fb4f3e | ||
|
e4af8acdc2 | ||
|
ad9cea069a | ||
|
542c0c33e0 | ||
|
535141c28f | ||
|
57a71427c3 | ||
|
70a1862351 | ||
|
585b01f7d4 | ||
|
b324415c18 | ||
|
e138923694 | ||
|
b89a82760c | ||
|
752aff4e5f | ||
|
146e84d790 | ||
|
936dae2209 | ||
|
0cda5e4d9e | ||
|
c2334df403 | ||
|
4234ca7e38 | ||
|
57b2e79c0d | ||
|
8be186d90e | ||
|
1068ed499d | ||
|
4824d7643d | ||
|
5db868bb56 | ||
|
a5ee4475e1 | ||
|
2ece0533a0 | ||
|
2ee977c501 | ||
|
59c4330f4f | ||
|
feae417221 | ||
|
db0854bed6 | ||
|
5bc91379f9 | ||
|
4acdc0b994 | ||
|
4acc9ec50f | ||
|
f414e94fe5 | ||
|
d15a97ef02 | ||
|
69a3889ca2 | ||
|
b722d5035b | ||
|
cb1ff39d54 | ||
|
740de21ea1 | ||
|
f57e98309a | ||
|
ab9576ae61 | ||
|
0d2450d901 | ||
|
7782dea327 | ||
|
3546b3ae82 | ||
|
219d7e2efe | ||
|
4474d7fb0b | ||
|
7edf167bfe | ||
|
0199dee9ef | ||
|
baa9ad6924 | ||
|
05e8b3e7bb | ||
|
db48ef67f4 | ||
|
e7ce96fd30 | ||
|
9caa90db63 | ||
|
113a93f48a | ||
|
2f26b19250 | ||
|
d73ee3b902 | ||
|
74a05cb7db | ||
|
2914f5b256 | ||
|
15d7ae1c1d | ||
|
33b9a679d3 | ||
|
89772a9e6e | ||
|
c1cf798e2e | ||
|
9d136df1fe | ||
|
2316459cf1 | ||
|
4822267970 | ||
|
02b9fa83ab | ||
|
f6a80bb8bf | ||
|
78f1805fd0 | ||
|
feead16974 | ||
|
90893f70e2 | ||
|
b485086b4e | ||
|
91a2f22549 | ||
|
0ff314a2a0 | ||
|
dff870e3ee | ||
|
0e43964428 | ||
|
363c902d09 | ||
|
9c2bfac61f | ||
|
db9c90c0a2 | ||
|
298efc4d20 | ||
|
f7d58787c8 | ||
|
c298732f64 | ||
|
a4da6fb7cd | ||
|
268f3cfecf | ||
|
fe3f3e7752 | ||
|
eefad1c7f6 | ||
|
bd04bf2ea4 | ||
|
fd07af4f5f | ||
|
ba5efdeaad | ||
|
6ce24d39df | ||
|
8436ad286c | ||
|
1708787747 | ||
|
2a10642188 | ||
|
4899d6d9da | ||
|
6396d5faa1 | ||
|
62138c905c | ||
|
2fafbc03a2 | ||
|
a8cb63d0d8 | ||
|
687bc582d0 | ||
|
4d00c49458 | ||
|
596d567ee4 | ||
|
4732b13196 | ||
|
2d513f5c85 | ||
|
e38f5dbce6 | ||
|
ed3adb3894 | ||
|
277bd499da | ||
|
bfd00c9649 | ||
|
8a0194c26c | ||
|
b55dd12495 | ||
|
dc58509a0f | ||
|
c1e3d07957 | ||
|
1f1da2a837 | ||
|
db66cc2c03 | ||
|
079c649966 | ||
|
8003ef73bf | ||
|
0dbc2f32a6 | ||
|
0c86d7c3d8 | ||
|
79f35ecb9a | ||
|
b80888e9a7 | ||
|
81e9fa2793 | ||
|
6dbd19899b | ||
|
ea0a507044 | ||
|
04a71f7646 | ||
|
bacd863c07 | ||
|
bbba2f1f0d | ||
|
2a55a1b86c | ||
|
b36fbbbb8d | ||
|
e642567900 | ||
|
ac8581943d | ||
|
5246ecbbf3 | ||
|
12bfe5fa31 | ||
|
beee696246 | ||
|
053b0842dd | ||
|
6c4b0fe1e5 | ||
|
d8015c5608 | ||
|
248efeb717 | ||
|
0eef0c1f83 | ||
|
2f3cc5fd32 | ||
|
49cba6090a | ||
|
dd2d50a95d | ||
|
09606bf820 | ||
|
c3ebde34d7 | ||
|
e249dee600 | ||
|
ef84e3fbbd | ||
|
dfaa8ccd89 | ||
|
4d89851d1a | ||
|
6176ac9558 | ||
|
ac425c6f0d | ||
|
c78ae247f4 | ||
|
616b782c5d | ||
|
234d8cb09d | ||
|
0cf62d53d0 | ||
|
f30f8fb0f2 | ||
|
fff432b634 | ||
|
8bdbdae5c9 | ||
|
3eca991285 | ||
|
35e7341654 | ||
|
63b8c32d63 | ||
|
c946742767 | ||
|
9fd5c2c8d4 | ||
|
903d03fdf4 | ||
|
e9444f373e | ||
|
d7ca99a69c | ||
|
3b10674925 | ||
|
6710fbd9f7 | ||
|
ea0b7fd8d1 | ||
|
438bb5a7d6 | ||
|
94f070832c | ||
|
9906f46ce6 | ||
|
4581f07daf | ||
|
69631a11b1 | ||
|
0cec7c2fec | ||
|
77a087277a | ||
|
013a31ca6e | ||
|
b66d15e51f | ||
|
0447cb995f | ||
|
eadea5e442 | ||
|
cb80d5e976 | ||
|
68b8428439 | ||
|
0df077d14b | ||
|
9855e032ef | ||
|
01071a9236 | ||
|
72ee23849f | ||
|
37b2cc7466 | ||
|
bf5ae3b0de | ||
|
2a121f91d2 | ||
|
26a18ae7d0 | ||
|
2459a14c9b | ||
|
369f015af2 | ||
|
43790c1b9a | ||
|
696ac88330 | ||
|
094d08df4d | ||
|
c4a4424364 | ||
|
e1a28027db | ||
|
8bfdda82b7 | ||
|
b923e21bce | ||
|
c282a80b5d | ||
|
a6eeecbbf7 | ||
|
46fd579933 | ||
|
961865eb6f | ||
|
91bc92d18b | ||
|
f3c7667359 | ||
|
05e44551a3 | ||
|
658bbdf135 | ||
|
96aabe5386 | ||
|
b550f7892e | ||
|
78e05e6aaf | ||
|
d821db27ba | ||
|
8cb45c587f | ||
|
d41a261897 | ||
|
4705a4e612 | ||
|
8df2441a66 | ||
|
16e64f7247 | ||
|
9549050d3e | ||
|
07903bd66e | ||
|
2084bb429e | ||
|
f40aaab2ea | ||
|
21e5850ee5 | ||
|
71154ca05a | ||
|
6ab59967d2 | ||
|
367a6d7cb7 | ||
|
fedef3cbac | ||
|
a6fabc5a5a | ||
|
a85d3db2c8 | ||
|
86bbfd7784 | ||
|
c3ef872360 | ||
|
fe59b1ce46 | ||
|
fb5546111e | ||
|
5432c9c8a4 | ||
|
6ab5597a82 | ||
|
756afef4b6 | ||
|
aaf8be2f70 | ||
|
2166dd9504 | ||
|
425ac4a7ad | ||
|
9713bd6fa3 | ||
|
a6df171798 | ||
|
6fc214551d | ||
|
144424ffe5 | ||
|
aaa28b83b2 | ||
|
9491f8d4a0 | ||
|
6ebfc1b233 | ||
|
9641e978a6 | ||
|
87b792efdf | ||
|
153cff8205 | ||
|
e6badad763 | ||
|
3716b1a3b9 | ||
|
1b7f131602 | ||
|
f10b14ef5b | ||
|
597205751e | ||
|
4b3a00f2e8 | ||
|
f3dff1b1e6 | ||
|
524b0167bf | ||
|
1592f3caa7 | ||
|
b9ec5b1bf3 | ||
|
3a9c9790e9 | ||
|
6d50e0769e | ||
|
30dac452ad | ||
|
a59c5e7372 | ||
|
0ffcbe39b7 | ||
|
3a6a810108 | ||
|
382af76753 | ||
|
f8fee50076 | ||
|
d3b1c9087f | ||
|
35a397c734 | ||
|
bcdc1a1ca4 | ||
|
f2f1db84f8 | ||
|
5b588d2425 | ||
|
ddc5b933ad | ||
|
715d3d49b6 | ||
|
107a59132a | ||
|
d543e09952 | ||
|
8aea5499d3 | ||
|
aac835a516 | ||
|
63cc373817 | ||
|
86eeb3c6f6 | ||
|
e0d018e1a0 | ||
|
634cd3e8be | ||
|
713a312823 | ||
|
d1a5bd56f9 | ||
|
78cbf3e307 | ||
|
1bfbd8ea60 | ||
|
c46f65e23f | ||
|
abd39b604f | ||
|
928d65b024 | ||
|
258abc232f | ||
|
eef8865774 | ||
|
200d5c517a | ||
|
a56850d214 | ||
|
3ef2cd48b9 | ||
|
86bf506c64 | ||
|
10ff33be13 | ||
|
1f61a40e5c | ||
|
fccbf7b996 | ||
|
66e769cab0 | ||
|
98e798bfce | ||
|
e5b5e28843 | ||
|
7ea9da3512 | ||
|
8b679bae00 | ||
|
96068e05d4 | ||
|
ff327c5b5c | ||
|
b427747f9a | ||
|
4c54bc5cad | ||
|
9d86fdd7e1 | ||
|
5206d3b627 | ||
|
0f3d4856d2 | ||
|
1a7bae563e | ||
|
25783d8152 | ||
|
bf26c4c0ef | ||
|
8e7133c4ab | ||
|
725be7ca9b | ||
|
e8567fccf0 | ||
|
a0f4024d26 | ||
|
f401410e81 | ||
|
771833e8f2 | ||
|
8dcf0be662 | ||
|
8b396768d5 | ||
|
3df56a4d97 | ||
|
679f13ebd6 | ||
|
45a8bd4454 | ||
|
df821e754e | ||
|
51b5907ed5 | ||
|
87c2f3dcd3 | ||
|
63959d086a | ||
|
363284f5d1 | ||
|
9518fbf6d0 | ||
|
8823303442 | ||
|
5d8dc697b0 | ||
|
5ce15f6ca5 | ||
|
a355b7d2a2 | ||
|
07143af04d | ||
|
a11d50909d | ||
|
f22c0de2ad | ||
|
423df6057c | ||
|
0480735330 | ||
|
32edaef745 | ||
|
6a8e087c6d | ||
|
6f44429972 | ||
|
8da140a67f | ||
|
de47b638ac | ||
|
ccab3bf9ec | ||
|
fe4bff17cf | ||
|
1708fe0c27 | ||
|
e9f4b0c7d8 | ||
|
2f29dfe203 | ||
|
42cedd9aec | ||
|
2c59e37bf6 | ||
|
c1c022c96b | ||
|
6edaf3f30a | ||
|
42d22ffcb4 | ||
|
da9f861333 | ||
|
26058e3d81 | ||
|
678e5ff5ce | ||
|
e856260fbb | ||
|
95d1c72956 | ||
|
3309777327 | ||
|
1da6082906 | ||
|
e5b9de1cc8 | ||
|
9ca7b7d8e4 | ||
|
9dc195cc4b | ||
|
2a3878faae | ||
|
9f69c30b25 | ||
|
d29bba4b64 | ||
|
5c299bad10 | ||
|
d830fd6f33 | ||
|
e8e5954cea | ||
|
e6e05e6be3 | ||
|
16985ae7d7 | ||
|
2b5c1518f4 | ||
|
c3fd645515 | ||
|
5ac8e92abd | ||
|
58be9c0848 | ||
|
67ceede236 | ||
|
2ec17259e8 | ||
|
73f48b6de5 | ||
|
d7cfa0de04 | ||
|
907a808151 | ||
|
c674186e05 | ||
|
a26fbed276 | ||
|
a96df13658 | ||
|
e229ed96e4 | ||
|
78859324a1 | ||
|
c6b7e48d7a | ||
|
de515c572c | ||
|
d9b7269d29 | ||
|
cb36e97c07 | ||
|
892c939376 | ||
|
dea5b727ac | ||
|
5710d77bd5 | ||
|
695b8d92e3 | ||
|
f1fa99a85e | ||
|
18d956fa08 | ||
|
cb2d63de6a | ||
|
6d08df41f0 | ||
|
4c2d335a2b | ||
|
d3087a6626 | ||
|
43d1308f74 | ||
|
e38638663e | ||
|
135c956406 | ||
|
d36c52b40a | ||
|
dfd5da684b | ||
|
832fe4e957 | ||
|
bf82491de8 | ||
|
8cbc941a70 | ||
|
949a2f2d4a | ||
|
441b9aab65 | ||
|
8e1a4e73be | ||
|
8ae2ab8fbf | ||
|
6c20ed025a | ||
|
fbea000aad | ||
|
1c530a0460 | ||
|
3f478de905 | ||
|
ad7bde02e3 | ||
|
74a817e63d | ||
|
383b9dce22 | ||
|
d5f658677e | ||
|
ec9d0470d8 | ||
|
e9ca68732e | ||
|
c7674825a6 | ||
|
dfefd6da40 | ||
|
4b4c07c5fe | ||
|
6299f43067 | ||
|
c78b8db81c | ||
|
788cb1ea98 | ||
|
6b73dd10b1 | ||
|
adb0ab4891 | ||
|
8996df4cbb | ||
|
c5932dc0f8 | ||
|
832fb6ce52 | ||
|
bbc380366f | ||
|
95d9414ae3 | ||
|
f339ed777e |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,8 +5,10 @@ wisemapping.iws
|
|||
wisemapping.iml
|
||||
wisemapping.ids
|
||||
wise-webapp/wisemapping.log*
|
||||
wise-webapp/velocity.log
|
||||
wisemapping.log*
|
||||
*/.DS_Store
|
||||
.DS_Store
|
||||
target
|
||||
.idea
|
||||
wise-webapp/src/main/webapp/react/*
|
||||
|
|
15
LICENSE.md
Normal file
15
LICENSE.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# WiseMapping Public License Version 1.0 (WPL)
|
||||
|
||||
WiseMapping open source edition is licensed under the WiseMapping Public License Version 1.0. It is basically Apache License Version 2.0 plus the "powered by wisemapping" text requirement on every single page (the "License") unless we authorize you to remove it.
|
||||
The WiseMapping Public License Version 1.0 ("WPL") consists of the [APACHE LICENSE, VERSION 2.0](http://www.apache.org/licenses/LICENSE-2.0), modified to be specific to WiseMapping, with the Additional Terms in Exhibit B.
|
||||
|
||||
Unless Required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
## EXHIBIT B - WiseMapping Public License.
|
||||
Additional Terms applicable to the WiseMapping Public License.
|
||||
I. Effect.
|
||||
These additional terms described in this wiseMapping Public License - Additional Terms shall apply to the Covered Code under this License.
|
||||
II. WiseMapping and "powered by WiseMapping" text.
|
||||
This License does not grant any rights to use the trademarks "WiseMapping" even if such marks are included in the Original Code or Modifications.
|
||||
However, in addition to the other notice obligations, unless wisemapping founders authorize you by email not to do it, (1) all copies of the Original Code in Executable and Source Code form must, as a form of attribution of the original author, include on each user interface screen (i) the "powered by WiseMapping" text; and (2) all derivative works and copies of derivative works of the Covered Code in Executable and Source Code form must include on each user interface screen (i) the "powered by WiseMapping" text. In addition, the "powered by WiseMapping" text, as appropriate, must be visible to all users, must appear in each user interface screen, and must be in the same position. When users click on the "powered by WiseMapping" text it must direct them to http://www.wisemapping.com. This obligation shall also apply to any copies or derivative works which are distributed under the alternative terms of Section 3.6 and this obligation must be included in any such license
|
1
Procfile
1
Procfile
|
@ -1 +0,0 @@
|
|||
web: java $JAVA_OPTS -Dspring.profiles.active=heroku -jar wise-webapp/target/dependency/jetty-runner.jar --port $PORT wise-webapp/target/*.war
|
73
README.md
73
README.md
|
@ -1,72 +1,3 @@
|
|||
# Project Information
|
||||
# WiseMapping Open Source has New Home
|
||||
|
||||
The goal of this project is to provide a high quality product that can be deployed by educational and academic institutions, private and public companies and anyone who needs to have a mindmapping application. WiseMapping is based on the same code source supporting WiseMapping.com. More info: www.wisemapping.org
|
||||
|
||||
## Compiling and Running
|
||||
|
||||
### Prerequisites
|
||||
|
||||
The following products must be installed:
|
||||
|
||||
* Java Development Kit 7 or higher ([http://www.oracle.com/technetwork/java/javase/downloads/index.html])
|
||||
* Maven 3.x or higher ([http://maven.apache.org/])
|
||||
|
||||
### Compiling
|
||||
|
||||
WiseMapping uses Maven as packaging and project management. It's composed of 5 maven sub-modules:
|
||||
|
||||
* core-js: Utilities JavaScript classes
|
||||
* web2d: JavaScript 2D SVG abstraction library used by the mind map editor
|
||||
* mindplot: JavaScript mindmap designer core
|
||||
* wise-editor: Mindmap Editor standalone distribution
|
||||
* wise-webapp: J2EE web application
|
||||
|
||||
The full compilation of the project can be performed executing within <project-dir>:
|
||||
|
||||
`mvn package`
|
||||
|
||||
Once this command is execute, the file <project-dir>/wise-webapp/target/wisemapping*.war will be generated.
|
||||
|
||||
### Testing
|
||||
The previously generated war can be deployed locally executing within the directory <project-dir>/wise-webapp the following command:
|
||||
|
||||
`cd wise-webapp;mvn jetty:run-war`
|
||||
|
||||
This will start the application on the URL: [http://localhost:8080/wise-webapp/]. Additionally, a file based database is automatically populated with a test user.
|
||||
|
||||
User: test@wisemapping.org
|
||||
Password: test
|
||||
|
||||
## Running the JS only version
|
||||
|
||||
Start by creating the .zip file:
|
||||
|
||||
`mvn assembly:assembly -Dmaven.test.skip=true`
|
||||
|
||||
To test the javascript frontend you then do:
|
||||
|
||||
ruby -rwebrick -e 'WEBrick::HTTPServer.new(:Port=>8000,:DocumentRoot=>".").start'
|
||||
|
||||
Now open a browser using the URL http://localhost:8000/wise-editor/src/main/webapp/
|
||||
|
||||
## Members
|
||||
|
||||
### Founders
|
||||
|
||||
* Pablo Luna <pveiga@wisemapping.com>
|
||||
* Paulo Veiga <pablo@wisemapping.com>
|
||||
|
||||
### Individual Controbutors
|
||||
|
||||
* Ezequiel Bergamaschi <ezequielbergamaschi@gmail.com>
|
||||
* Claudio Barril <claudiobarril@gmail.com>
|
||||
|
||||
### Past Individual Contributors
|
||||
|
||||
* Ignacio Manzano
|
||||
* Nicolas Damonte
|
||||
|
||||
## License
|
||||
|
||||
The source code is Licensed under the WiseMapping Open License, Version 1.0 (the “License”);
|
||||
You may obtain a copy of the License at: [https://wisemapping.atlassian.net/wiki/display/WS/License]
|
||||
Project has been migrated to in GitHub -> https://github.com/wisemapping/
|
||||
|
|
39
bitbucket-pipelines.yml
Normal file
39
bitbucket-pipelines.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Template maven-build
|
||||
|
||||
# This template allows you to test and build your Java project with Maven.
|
||||
# The workflow allows running tests, code checkstyle and security scans on the default branch.
|
||||
|
||||
# Prerequisites: pom.xml and appropriate project structure should exist in the repository.
|
||||
|
||||
image: maven:3.8.7
|
||||
|
||||
pipelines:
|
||||
branches:
|
||||
'{master,develop}':
|
||||
- step:
|
||||
name: Build and Test
|
||||
caches:
|
||||
- node
|
||||
- maven
|
||||
- docker
|
||||
script:
|
||||
# Compile sources ...
|
||||
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
|
||||
- . $HOME/.nvm/nvm.sh && nvm install node
|
||||
- mvn clean install --file pom.xml -DskipTests
|
||||
# Publish to docker repo ...
|
||||
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
|
||||
- docker build -t wisemapping/wisemapping:latest -f distribution/Dockerfile wise-webapp/target/
|
||||
- docker push wisemapping/wisemapping:latest
|
||||
after-script:
|
||||
# Collect checkstyle results, if any, and convert to Bitbucket Code Insights.
|
||||
- pipe: atlassian/checkstyle-report:0.3.0
|
||||
services:
|
||||
- docker
|
||||
- step:
|
||||
name: Security Scan
|
||||
script:
|
||||
# Run a security scan for sensitive data.
|
||||
# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
|
||||
- pipe: atlassian/git-secrets-scan:0.5.1
|
||||
|
45
config/README.md
Normal file
45
config/README.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Database Configuration
|
||||
|
||||
## Overview
|
||||
|
||||
WiseMapping supports a wide variety of databases. However, we run intensively tests over HSQL and MySQL database.
|
||||
|
||||
* HyperSQL: Automatically configured when you compile WiseMapping and It's used primarily for testing. Additionally, the binary distribution already has an instance configured to provide a single click installation.
|
||||
* MySQL: This version is the most tested database we support. MySQL is the database use in http://www.wisemapping.com and it's the suggested version for production environments.
|
||||
* PostgreSQL: Scripts are distributed for the creation and configuration of the it. You will find them within "config/postgres" directory in the binary distribution. Additionally, JDBC driver need to be added to the container.
|
||||
* Others: In spite of the fact that we don't provide yet initialization scripts for others databases, WiseMapping can be deployed in any relational database. Please, contact us if you have any particular question on this area.
|
||||
|
||||
* In the following section, you are going to find a detailed explanation how to configure you WiseMapping using MySQL 5.5.
|
||||
|
||||
## MySQL Installation
|
||||
### Prerequisites
|
||||
* Download and install MySQL. You can download it for free from: http://dev.mysql.com/downloads/
|
||||
Running SQL Scripts
|
||||
Inside the WiseMapping binary distribution, you will find a directory "config/mysql". It contains all the SQL script required to configure a new WiseMapping database instance.
|
||||
|
||||
You will find 4 scripts:
|
||||
* create-database.sql: Create all wisemapping database and wisemapping user.
|
||||
* create-schemas.sql: Create all database tables and index.
|
||||
* apopulate-schemas.sql: Creates a mind map example and an a test user "test@wisemapping.org" with password "test".
|
||||
* drop-schemas.sql: Drop all wisemapping tables in case you want to have a fresh installation.
|
||||
|
||||
There are a lot of good tools you can use to run this scripts (eg: MySQLWorkbench). However, the simples way is to use the command line tool that is distributed as part of the MySQL installation.
|
||||
If you are one brave hearts that is not afraid of the command line tools, open a terminar and execute the following lines:
|
||||
~~~~
|
||||
cd <WISEMAPPING-DIR>/config/database/mysql
|
||||
# Default MySQL installation creates a "root" user with empty password. You can connect to the database with this user if you are # logged in same machine where the database is installed and must be executed logged as "root"
|
||||
#
|
||||
# If you have changed the default database "root" password , you need to specify an additional -p parameter and provide the
|
||||
# new password.
|
||||
mysql -uroot < create-database.sql
|
||||
|
||||
# Create tables and default tests user
|
||||
mysql -uwisemapping -Dwisemapping -ppassword < create-schemas.sql
|
||||
mysql -uwisemapping -Dwisemapping -ppassword < apopulate-schemas.sql
|
||||
~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
Great, you have configured you database !. Let's configure WiseMapping now.
|
||||
|
|
@ -1,27 +1 @@
|
|||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'admin', 1237, CURDATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (3, 'homer@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (3, 'Homer', 'Simpson', 'homer', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (4, 'marge@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (4, 'Marge', 'Bouvier', 'marge', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (5, 'bart@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (5, 'Bart', 'Simpson', 'bart', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (6, 'lisa@wisemapping.org', CURDATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (6, 'Lisa', 'Simpson', 'lisa', 1237, CURDATE(), 1, 'D');
|
||||
|
||||
|
||||
COMMIT;
|
||||
SHUTDOWN;
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
COMMIT;
SHUTDOWN;
|
|
@ -1,95 +1 @@
|
|||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
creation_date DATE
|
||||
);
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL IDENTITY,
|
||||
authentication_type CHAR(1) NOT NULL,
|
||||
authenticator_uri VARCHAR(255) NULL,
|
||||
firstname VARCHAR(255) NOT NULL,
|
||||
lastname VARCHAR(255) NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
activation_code BIGINT NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) NOT NULL,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
public BOOLEAN NOT NULL,
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014),
|
||||
last_editor_id INTEGER NOT NULL
|
||||
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
|
||||
title VARCHAR(30),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
xml LONGVARBINARY NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
starred BOOLEAN NOT NULL,
|
||||
mindmap_properties VARCHAR(512)
|
||||
);
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
--FOREIGN KEY(user_id) REFERENCES USER(colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL IDENTITY,
|
||||
user_id INTEGER NOT NULL,
|
||||
login_date DATE,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
CREATE TABLE COLLABORATOR (
id INTEGER NOT NULL IDENTITY,
email VARCHAR(255) NOT NULL UNIQUE,
creation_date DATE
);
CREATE TABLE USER (
colaborator_id INTEGER NOT NULL IDENTITY,
authentication_type CHAR(1) NOT NULL,
authenticator_uri VARCHAR(255) NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
activation_code BIGINT NOT NULL,
activation_date DATE,
allow_send_email CHAR(1) NOT NULL,
locale VARCHAR(5),
google_sync BOOLEAN,
sync_code VARCHAR(255),
google_token VARCHAR(255),
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
);
CREATE TABLE MINDMAP (
id INTEGER NOT NULL IDENTITY,
title VARCHAR(255) NOT NULL,
description VARCHAR(255),
xml LONGVARBINARY NOT NULL,
public BOOLEAN NOT NULL,
creation_date DATETIME,
edition_date DATETIME,
creator_id INTEGER NOT NULL,
last_editor_id INTEGER NOT NULL
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
);
CREATE TABLE LABEL (
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
title VARCHAR(30),
creator_id INTEGER NOT NULL,
parent_label_id INTEGER,
color VARCHAR(7) NOT NULL,
iconName VARCHAR(50) NOT NULL
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
);
CREATE TABLE R_LABEL_MINDMAP (
mindmap_id INTEGER NOT NULL,
label_id INTEGER NOT NULL,
PRIMARY KEY (mindmap_id, label_id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE TABLE MINDMAP_HISTORY (
id INTEGER NOT NULL IDENTITY,
xml LONGVARBINARY NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date DATETIME,
editor_id INTEGER NOT NULL,
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
);
CREATE TABLE COLLABORATION_PROPERTIES (
id INTEGER NOT NULL IDENTITY,
starred BOOLEAN NOT NULL,
mindmap_properties VARCHAR(512)
);
CREATE TABLE COLLABORATION (
id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
properties_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
);
CREATE TABLE ACCESS_AUDITORY (
id INTEGER NOT NULL IDENTITY,
user_id INTEGER NOT NULL,
login_date DATE,
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
COMMIT;
|
|
@ -1,11 +1 @@
|
|||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
DROP TABLE IF EXISTS COLLABORATION;
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
DROP TABLE IF EXISTS MINDMAP_HISTORY;
DROP TABLE IF EXISTS R_LABEL_MINDMAP;
DROP TABLE IF EXISTS LABEL;
DROP TABLE IF EXISTS MINDMAP;
DROP TABLE IF EXISTS USER;
DROP TABLE IF EXISTS COLLABORATOR;
COMMIT;
|
|
@ -1,29 +1 @@
|
|||
#
|
||||
# Command: mysql -u root -p < apopulate_schemas.sql
|
||||
#
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (2, 'Admin', 'User', 'admin', 1237, CURRENT_DATE(), 1,'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (3, 'homer@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (3, 'Homer', 'Simpson', 'homer', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (4, 'marge@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (4, 'Marge', 'Bouvier', 'marge', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (5, 'bart@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (5, 'Bart', 'Simpson', 'bart', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (6, 'lisa@wisemapping.org', CURRENT_DATE());
|
||||
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
|
||||
VALUES (6, 'Lisa', 'Simpson', 'lisa', 1237, CURRENT_DATE(), 1, 'D');
|
||||
|
||||
COMMIT;
|
||||
#
# Command: mysql -u root -p < apopulate_schemas.sql
#
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURRENT_DATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURRENT_DATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURRENT_DATE(), 1,'D');
COMMIT;
|
|
@ -1,10 +1 @@
|
|||
#
|
||||
# Command: mysql -u root -p < create_database.sql
|
||||
#
|
||||
DROP DATABASE IF EXISTS wisemapping;
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS wisemapping
|
||||
CHARACTER SET = 'utf8'
|
||||
COLLATE = 'utf8_unicode_ci';
|
||||
GRANT ALL ON wisemapping.* TO 'wisemapping'@'localhost';
|
||||
SET PASSWORD FOR 'wisemapping'@'localhost' = PASSWORD('password');
|
||||
#
# Command: mysql -u root -p < create_database.sql
#
DROP DATABASE IF EXISTS wisemapping;
CREATE DATABASE IF NOT EXISTS wisemapping
CHARACTER SET = 'utf8'
COLLATE = 'utf8_unicode_ci';
GRANT ALL ON wisemapping.* TO 'wisemapping'@'localhost';
SET PASSWORD FOR 'wisemapping'@'localhost' = PASSWORD('password');
|
|
@ -1,136 +1 @@
|
|||
#
|
||||
# Command: mysql -u root -p < create_schemas.sql
|
||||
#
|
||||
|
||||
USE wisemapping;
|
||||
|
||||
CREATE TABLE COLLABORATOR (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
email VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL UNIQUE,
|
||||
creation_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE USER (
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
authentication_type CHAR(1)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
authenticator_uri VARCHAR(255)
|
||||
CHARACTER SET utf8,
|
||||
firstname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
lastname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
password VARCHAR(255) CHARACTER SET utf8 NOT NULL,
|
||||
activation_code BIGINT(20) NOT NULL,
|
||||
activation_date DATE,
|
||||
allow_send_email CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
description VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT 0,
|
||||
creation_date DATETIME,
|
||||
edition_date DATETIME,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014)
|
||||
CHARACTER SET utf8,
|
||||
last_editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
xml MEDIUMBLOB NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
creation_date DATETIME,
|
||||
editor_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE COLLABORATION (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
colaborator_id INTEGER NOT NULL,
|
||||
properties_id INTEGER NOT NULL,
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
role_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
name VARCHAR(255)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
COMMIT;
|
||||
#
# Command: mysql -u root -p < create_schemas.sql
#
USE wisemapping;
CREATE TABLE COLLABORATOR (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(255)
CHARACTER SET utf8 NOT NULL UNIQUE,
creation_date DATE
)
CHARACTER SET utf8;
CREATE TABLE USER (
colaborator_id INTEGER NOT NULL PRIMARY KEY,
authentication_type CHAR(1)
CHARACTER SET utf8 NOT NULL,
authenticator_uri VARCHAR(255)
CHARACTER SET utf8,
firstname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
lastname VARCHAR(255) CHARACTER SET utf8 NOT NULL,
password VARCHAR(255) CHARACTER SET utf8 NOT NULL,
activation_code BIGINT(20) NOT NULL,
activation_date DATE,
allow_send_email CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 0,
locale VARCHAR(5),
google_sync BOOL,
sync_code VARCHAR(255),
google_token VARCHAR(255),
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
CREATE TABLE MINDMAP (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255)
CHARACTER SET utf8 NOT NULL,
description VARCHAR(255)
CHARACTER SET utf8 NOT NULL,
xml MEDIUMBLOB NOT NULL,
public BOOL NOT NULL DEFAULT 0,
creation_date DATETIME,
edition_date DATETIME,
creator_id INTEGER NOT NULL,
last_editor_id INTEGER NOT NULL,
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
CREATE TABLE LABEL (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(30)
CHARACTER SET utf8 NOT NULL,
creator_id INTEGER NOT NULL,
parent_label_id INTEGER,
color VARCHAR(7) NOT NULL,
iconName VARCHAR(50) NOT NULL,
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
CREATE TABLE R_LABEL_MINDMAP (
mindmap_id INTEGER NOT NULL,
label_id INTEGER NOT NULL,
PRIMARY KEY (mindmap_id, label_id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (label_id) REFERENCES LABEL (id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
CREATE TABLE MINDMAP_HISTORY
(id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
xml MEDIUMBLOB NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date DATETIME,
editor_id INTEGER NOT NULL,
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
CREATE TABLE COLLABORATION_PROPERTIES (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
starred BOOL NOT NULL DEFAULT 0,
mindmap_properties VARCHAR(512)
CHARACTER SET utf8
)
CHARACTER SET utf8;
CREATE TABLE COLLABORATION (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
colaborator_id INTEGER NOT NULL,
properties_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
UNIQUE KEY UC_ROLE (mindmap_id,colaborator_id),
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
ON DELETE CASCADE
ON UPDATE NO ACTION,
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
CREATE TABLE ACCESS_AUDITORY (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
login_date DATE,
user_id INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
CHARACTER SET utf8;
COMMIT;
|
|
@ -1,11 +1 @@
|
|||
DROP TABLE IF EXISTS TAG;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS LABEL;
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP
|
||||
DROP TABLE IF EXISTS USER;
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
DROP TABLE IF EXISTS COLLABORATION;
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
DROP TABLE IF EXISTS MINDMAP_HISTORY;
DROP TABLE IF EXISTS LABEL;
DROP TABLE IF EXISTS MINDMAP;
DROP TABLE IF EXISTS R_LABEL_MINDMAP
DROP TABLE IF EXISTS USER;
DROP TABLE IF EXISTS COLLABORATOR;
COMMIT;
|
|
@ -1,57 +0,0 @@
|
|||
CREATE TABLE COLLABORATION_PROPERTIES (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
starred BOOL NOT NULL DEFAULT 0,
|
||||
mindmap_properties VARCHAR(512)
|
||||
CHARACTER SET utf8
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
DROP TABLE `MINDMAP_NATIVE`;
|
||||
ALTER TABLE `MINDMAP_COLABORATOR` RENAME TO `COLLABORATION`;
|
||||
ALTER TABLE `COLABORATOR` RENAME TO `COLLABORATOR`;
|
||||
|
||||
ALTER TABLE `MINDMAP` DROP COLUMN `editor_properties`, DROP COLUMN `mindMapNative_id`;
|
||||
|
||||
ALTER TABLE `MINDMAP` CHANGE COLUMN `owner_id` `creator_id` INT(11) NOT NULL
|
||||
, DROP INDEX `owner_id`
|
||||
, ADD INDEX `owner_id` (`creator_id` ASC);
|
||||
|
||||
ALTER TABLE `COLLABORATION` ADD COLUMN `properties_id` INT(11) NULL DEFAULT NULL
|
||||
AFTER `role_id`;
|
||||
DROP TABLE USER_LOGIN;
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
login_date DATE
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
#ALTER TABLE ACCESS_AUDITORY
|
||||
# ADD CONSTRAINT `user_id`
|
||||
# FOREIGN KEY ()
|
||||
# REFERENCES `USER` ()
|
||||
# ON DELETE CASCADE
|
||||
# ON UPDATE NO ACTION
|
||||
#, ADD INDEX `user_id` () ;
|
||||
|
||||
ALTER TABLE `MINDMAP_HISTORY` DROP COLUMN `creator_user`, ADD COLUMN `editor_id` INT(11) NULL DEFAULT NULL AFTER `creation_date`;
|
||||
|
||||
ALTER TABLE `USER` ADD COLUMN `locale` VARCHAR(5) NULL
|
||||
AFTER `allowSendEmail`;
|
||||
|
||||
ALTER TABLE `MINDMAP` DROP COLUMN `last_editor`, ADD COLUMN `last_editor_id` INT(11) NULL DEFAULT 2
|
||||
AFTER `tags`;
|
||||
|
||||
ALTER TABLE `USER` DROP COLUMN `username`, CHANGE COLUMN `activationCode` `activation_code` BIGINT(20) NOT NULL, CHANGE COLUMN `allowSendEmail` `allow_send_email` CHAR(1) NOT NULL DEFAULT '0';
|
||||
|
||||
INSERT INTO `MINDMAP` (`last_editor_id`) VALUES (1);
|
||||
|
||||
INSERT INTO `COLLABORATOR` (`id`, `email`, `creation_date`) VALUES (8081, 'migfake@wis.com', '2007-10-09');
|
||||
DELETE FROM `USER`
|
||||
WHERE activation_date IS null;
|
||||
DROP TABLE FEEDBACK;
|
||||
|
||||
|
||||
ALTER TABLE `MINDMAP` CHANGE COLUMN `XML` `XML` MEDIUMBLOB NULL DEFAULT NULL;
|
||||
ALTER TABLE `MINDMAP_HISTORY` CHANGE COLUMN `XML` `XML` MEDIUMBLOB NULL DEFAULT NULL;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE `USER` ADD COLUMN `authentication_type` CHAR(1) CHARACTER SET utf8 NOT NULL DEFAULT 'D'
|
||||
AFTER `colaborator_id`;
|
||||
|
||||
ALTER TABLE `USER` ADD COLUMN `authenticator_uri` VARCHAR(255) CHARACTER SET utf8
|
||||
AFTER `authentication_type`;
|
|
@ -1,34 +0,0 @@
|
|||
ALTER TABLE `USER` DROP COLUMN `id`;
|
||||
|
||||
ALTER TABLE `ACCESS_AUDITORY`
|
||||
ADD CONSTRAINT
|
||||
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION;
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
title VARCHAR(30)
|
||||
CHARACTER SET utf8 NOT NULL,
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id),
|
||||
FOREIGN KEY (parent_label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
mindmap_id INTEGER NOT NULL,
|
||||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION
|
||||
)
|
||||
CHARACTER SET utf8;
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
CREATE DATABASE wisemapping;
|
||||
CREATE USER wisemapping WITH PASSWORD 'password';
|
||||
GRANT ALL PRIVILEGES ON DATABASE wisemapping TO wisemapping;
|
||||
|
||||
GRANT ALL PRIVILEGES ON DATABASE wisemapping TO wisemapping;
|
|
@ -4,7 +4,7 @@ CREATE TABLE COLLABORATOR (
|
|||
creation_date DATE
|
||||
);
|
||||
|
||||
CREATE TABLE "user" (
|
||||
CREATE TABLE "USER" (
|
||||
authentication_type TEXT NOT NULL,
|
||||
authenticator_uri VARCHAR(255),
|
||||
colaborator_id INTEGER NOT NULL PRIMARY KEY,
|
||||
|
@ -15,16 +15,33 @@ CREATE TABLE "user" (
|
|||
activation_date DATE,
|
||||
allow_send_email TEXT NOT NULL DEFAULT 0,
|
||||
locale VARCHAR(5),
|
||||
google_sync BOOLEAN,
|
||||
sync_code VARCHAR(255),
|
||||
google_token VARCHAR(255),
|
||||
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE LABEL (
|
||||
CREATE TABLE "LABEL" (
|
||||
id INTEGER NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255),
|
||||
creator_id INTEGER NOT NULL,
|
||||
parent_label_id INTEGER,
|
||||
color VARCHAR(7) NOT NULL
|
||||
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
|
||||
color VARCHAR(7) NOT NULL,
|
||||
iconName VARCHAR(50) NOT NULL,
|
||||
FOREIGN KEY (creator_id) REFERENCES "USER" (colaborator_id)
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255),
|
||||
xml BYTEA NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT FALSE,
|
||||
creation_date TIMESTAMP,
|
||||
edition_date TIMESTAMP,
|
||||
creator_id INTEGER NOT NULL,
|
||||
last_editor_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE R_LABEL_MINDMAP (
|
||||
|
@ -32,24 +49,9 @@ CREATE TABLE R_LABEL_MINDMAP (
|
|||
label_id INTEGER NOT NULL,
|
||||
PRIMARY KEY (mindmap_id, label_id),
|
||||
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
|
||||
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
FOREIGN KEY (label_id) REFERENCES "LABEL" (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE MINDMAP (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL,
|
||||
xml BYTEA NOT NULL,
|
||||
public BOOL NOT NULL DEFAULT FALSE,
|
||||
creation_date TIMESTAMP,
|
||||
edition_date TIMESTAMP,
|
||||
creator_id INTEGER NOT NULL,
|
||||
tags VARCHAR(1014),
|
||||
last_editor_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(creator_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE MINDMAP_HISTORY
|
||||
(id SERIAL NOT NULL PRIMARY KEY,
|
||||
xml BYTEA NOT NULL,
|
||||
|
@ -77,20 +79,15 @@ CREATE TABLE COLLABORATION (
|
|||
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
CREATE TABLE TAG (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
user_id INTEGER NOT NULL --,
|
||||
--FOREIGN KEY(user_id) REFERENCES "USER"(colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE ACCESS_AUDITORY (
|
||||
id SERIAL NOT NULL PRIMARY KEY,
|
||||
login_date DATE,
|
||||
user_id INTEGER NOT NULL,
|
||||
FOREIGN KEY (user_id) REFERENCES "user" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
FOREIGN KEY (user_id) REFERENCES "USER" (colaborator_id) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
);
|
||||
|
||||
|
||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO wisemapping;
|
||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO wisemapping;
|
||||
|
||||
COMMIT;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
DROP TABLE TAG;
|
||||
DROP TABLE ACCESS_AUDITORY;
|
||||
DROP TABLE COLLABORATION;
|
||||
DROP TABLE COLLABORATION_PROPERTIES;
|
||||
DROP TABLE MINDMAP_HISTORY;
|
||||
DROP TABLE R_LABEL_MINDMAP;
|
||||
DROP TABLE LABEL;
|
||||
DROP TABLE MINDMAP;
|
||||
DROP TABLE "user";
|
||||
DROP TABLE COLLABORATOR;
|
||||
DROP TABLE IF EXISTS ACCESS_AUDITORY;
|
||||
DROP TABLE IF EXISTS COLLABORATION;
|
||||
DROP TABLE IF EXISTS COLLABORATION_PROPERTIES;
|
||||
DROP TABLE IF EXISTS MINDMAP_HISTORY;
|
||||
DROP TABLE IF EXISTS R_LABEL_MINDMAP;
|
||||
DROP TABLE IF EXISTS "LABEL";
|
||||
DROP TABLE IF EXISTS MINDMAP;
|
||||
DROP TABLE IF EXISTS "USER";
|
||||
DROP TABLE IF EXISTS COLLABORATOR;
|
||||
COMMIT;
|
|
@ -1,79 +0,0 @@
|
|||
<project>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-js</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Core JavaScript Utils Libraries</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>merge-js-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<mkdir dir="${basedir}/target/classes"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>compress</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/main/javascript/</sourceDirectory>
|
||||
<outputDirectory>target/tmp/</outputDirectory>
|
||||
<aggregations>
|
||||
<aggregation>
|
||||
<output>${basedir}/target/classes/core.js</output>
|
||||
<includes>
|
||||
<include>${basedir}/target/tmp/header-min.js</include>
|
||||
<include>${basedir}/target/tmp/Functions-min.js</include>
|
||||
<include>${basedir}/target/tmp/Utils-min.js</include>
|
||||
<!-- @Todo:Review this -->
|
||||
<include>
|
||||
${basedir}/../mindplot/src/main/javascript/libraries/moodialog/Overlay.js
|
||||
</include>
|
||||
<include>
|
||||
${basedir}/../mindplot/src/main/javascript/libraries/moodialog/MooDialog.js
|
||||
</include>
|
||||
<include>
|
||||
${basedir}/../mindplot/src/main/javascript/libraries/moodialog/MooDialog.Request.js
|
||||
</include>
|
||||
<include>
|
||||
${basedir}/../mindplot/src/main/javascript/libraries/moodialog/MooDialog.Fx.js
|
||||
</include>
|
||||
</includes>
|
||||
</aggregation>
|
||||
</aggregations>
|
||||
<nomunge>true</nomunge>
|
||||
<jswarn>false</jswarn>
|
||||
<force>true</force>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
Function: $defined
|
||||
Returns true if the passed in value/object is defined, that means is not null or undefined.
|
||||
|
||||
Arguments:
|
||||
obj - object to inspect
|
||||
*/
|
||||
|
||||
$defined = function (obj) {
|
||||
return (obj != undefined);
|
||||
};
|
||||
|
||||
|
||||
$assert = function (assert, message) {
|
||||
if (!$defined(assert) || !assert) {
|
||||
logStackTrace();
|
||||
console.log(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
};
|
||||
|
||||
Math.sign = function (value) {
|
||||
return (value >= 0) ? 1 : -1;
|
||||
};
|
||||
|
||||
function logStackTrace(exception) {
|
||||
|
||||
if (!$defined(exception)) {
|
||||
try {
|
||||
throw Error("Unexpected Exception");
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
var result = "";
|
||||
if (exception.stack) { //Firefox and Chrome...
|
||||
result = exception.stack;
|
||||
}
|
||||
else if (window.opera && exception.message) { //Opera
|
||||
result = exception.message;
|
||||
} else { //IE and Safari
|
||||
result = exception.sourceURL + ': ' + exception.line + "\n\n";
|
||||
|
||||
var currentFunction = arguments.callee.caller;
|
||||
while (currentFunction) {
|
||||
var fn = currentFunction.toString();
|
||||
result = result + "\n" + fn;
|
||||
currentFunction = currentFunction.caller;
|
||||
}
|
||||
}
|
||||
window.errorStack = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Support for Windows ...
|
||||
if (!window.console) {
|
||||
console = {
|
||||
log:function (e) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
core.Utils = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
core.Utils.innerXML = function (node) {
|
||||
// summary:
|
||||
// Implementation of MS's innerXML function.
|
||||
if ($defined(node.innerXML)) {
|
||||
return node.innerXML;
|
||||
// string
|
||||
} else if ($defined(node.xml)) {
|
||||
return node.xml;
|
||||
// string
|
||||
} else if ($defined(XMLSerializer)) {
|
||||
return (new XMLSerializer()).serializeToString(node);
|
||||
// string
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cross-browser implementation of creating an XML document object.
|
||||
*/
|
||||
core.Utils.createDocument = function () {
|
||||
var doc = null;
|
||||
if ($defined(window.ActiveXObject)) {
|
||||
//http://blogs.msdn.com/b/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx
|
||||
var progIDs = [ 'Msxml2.DOMDocument.6.0', 'Msxml2.DOMDocument.3.0'];
|
||||
for (var i = 0; i < progIDs.length; i++) {
|
||||
try {
|
||||
doc = new ActiveXObject(progIDs[i]);
|
||||
break;
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
} else if (window.document.implementation && window.document.implementation.createDocument) {
|
||||
doc = window.document.implementation.createDocument("", "", null);
|
||||
}
|
||||
$assert(doc, "Parser could not be instantiated");
|
||||
|
||||
return doc;
|
||||
};
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var core = {};
|
37
distribution/Dockerfile
Normal file
37
distribution/Dockerfile
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Dockerizing WiseMapping: Dockerfile for building WiseMapping images
|
||||
# Based on ubuntu:latest, installs WiseMapping (http://ww.wisemapping.org)
|
||||
|
||||
# Based info setup ...
|
||||
#FROM --platform=$BUILDPLATFORM tomcat:9.0.71-jdk17
|
||||
FROM tomcat:10.1.11-jdk17
|
||||
LABEL maintainer="Paulo Gustavo Veiga <pveiga@wisemapping.com>"
|
||||
|
||||
# Build variables ...
|
||||
ARG WEBAPP_TARGET_DIR="/usr/local/tomcat/webapps/ROOT"
|
||||
ARG DB_BASE_DIR="/var/lib/wisemapping"
|
||||
|
||||
# Default ENV configurations ...
|
||||
ENV JAVA_OPTS="-XX:+PrintFlagsFinal -XX:InitialRAMPercentage=30 -XX:MaxRAMPercentage=80 -Dfile.encoding=UTF-8"
|
||||
ENV database.base.url=${DB_BASE_DIR}
|
||||
|
||||
# Copy wisemapping distribution ...
|
||||
COPY wisemapping.war /tmp
|
||||
RUN mkdir ${WEBAPP_TARGET_DIR}
|
||||
RUN cd ${WEBAPP_TARGET_DIR} && jar -xvf /tmp/wisemapping.war
|
||||
RUN rm /tmp/wisemapping.war
|
||||
|
||||
# Change logger to
|
||||
RUN cp ${WEBAPP_TARGET_DIR}/WEB-INF/log4j2-stdout.xml ${WEBAPP_TARGET_DIR}/WEB-INF/classes/log4j2.xml
|
||||
|
||||
# Add support for proxy
|
||||
RUN sed -i 's|\
|
||||
</Host>|\
|
||||
<Valve className="org.apache.catalina.valves.RemoteIpValve" \
|
||||
remoteIpHeader="X-Forwarded-For" \
|
||||
protocolHeader="X-Forwarded-Proto"/>\
|
||||
</Host>|' \
|
||||
/usr/local/tomcat/conf/server.xml
|
||||
|
||||
# Copy default HSQL DB for testing ...
|
||||
RUN mkdir -p ${DB_BASE_DIR}/db
|
||||
COPY db/ ${DB_BASE_DIR}/db
|
59
distribution/README.md
Normal file
59
distribution/README.md
Normal file
|
@ -0,0 +1,59 @@
|
|||
# What is WiseMapping ?
|
||||
|
||||
Wise Mapping is the web mind mapping open source tool that leverages the power of Mind Maps mixing open standards technologies such as SVG and React.
|
||||
WiseMapping is based on the same code product supporting [http://www.wisemapping.com].
|
||||
|
||||
# How to use this image.
|
||||
|
||||
There are multiple ways to run WiseMapping depending on your database configuration preference
|
||||
|
||||
## Option 1: Running HSQL within the image storage
|
||||
|
||||
> $ docker run -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
|
||||
Then, open your browser at `http://localhost:8888`. A default user is available for testing `test@wisemapping.org` and password `test`.
|
||||
|
||||
***This option, all changes will be lost once the image is stopped. Use it for testing only***
|
||||
|
||||
## Option 2: Running HSQL with mounted directory
|
||||
|
||||
Only one time, copy the empty default out of the container:
|
||||
|
||||
> $ mkdir your- db-dir-store-path
|
||||
>
|
||||
> $ docker run --name wiseapp -d --mount type=bind,source=your-db-dir-store-path,target=/var/lib/wise-db wisemapping/wisemapping:latest
|
||||
>
|
||||
> $ docker cp wiseapp:/var/lib/wisemapping/db your-db-dir-store-path
|
||||
>
|
||||
> $ docker stop wiseapp;docker rm wiseapp
|
||||
|
||||
Then, execute the container mounting tbe directory:
|
||||
|
||||
> $ docker run --mount type=bind,source=your-db-dir-store-path/db,target=/var/lib/wisemapping/db -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
|
||||
## Option 3: External MySQL/PostgreSQL
|
||||
|
||||
### Setup database
|
||||
|
||||
Depending on the database your want to configure, you can create initialization scripts [here](https://bitbucket.org/wisemapping/wisemapping-open-source/src/develop/config/database/)
|
||||
|
||||
### Configure application properties
|
||||
|
||||
The next step is configure the WiseMapping for the database and credentials.
|
||||
Download `app.properties` configuration file and configure the required sections:
|
||||
|
||||
> $ curl https://bitbucket.org/wisemapping/wisemapping-open-source/src/master/wise-webapp/src/main/webapp/WEB-INF/app.properties
|
||||
|
||||
### Starting the application
|
||||
|
||||
Run the application mounting your previously configured `app.properties`
|
||||
|
||||
> $ docker run --mount type=bind,source=your-file-path/app.properties,target=/usr/local/tomcat/webapps/ROOT/WEB-INF/app.properties -it --rm -p 8080:8080 wisemapping/wisemapping:latest
|
||||
|
||||
# Advanced configuration
|
||||
|
||||
## Increase Tomcat memory
|
||||
> docker run\
|
||||
> --mount type=bind,source<your-file-path/app.properties,target=/usr/local/tomcat/webapps/ROOT/classes/app.properties
|
||||
> -m 1.5GB -e JAVA_OPTS=" -XX:+PrintFlagsFinal -XX:InitialRAMPercentage=30 -XX:MaxRAMPercentage=80"
|
||||
> -it --rm -p 8888:8080 veigap/wisemapping:latest
|
|
@ -1,36 +0,0 @@
|
|||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<id>editor</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<files>
|
||||
<file>
|
||||
<source>core-js/target/classes/core.js</source>
|
||||
<outputDirectory>/js</outputDirectory>
|
||||
</file>
|
||||
<file>
|
||||
<source>mindplot/target/classes/mindplot-min.js</source>
|
||||
<outputDirectory>/js</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<directory>wise-editor/src/main/webapp</directory>
|
||||
<includes>
|
||||
<include>css/**/*</include>
|
||||
<include>images/**/*</include>
|
||||
<include>icons/**/*</include>
|
||||
<include>js/editor.js</include>
|
||||
<include>js/less*.js</include>
|
||||
<include>js/mootools*.js</include>
|
||||
<include>html/editor.html</include>
|
||||
<include>html/*</include>
|
||||
<include>samples/*</include>
|
||||
<include>index.html</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
10
distribution/build-image.sh
Executable file
10
distribution/build-image.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -o
|
||||
set -u
|
||||
|
||||
mvn -f ../pom.xml clean package
|
||||
docker build --platform linux/amd64 -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
||||
#docker buildx create --use --platform=linux/arm64,linux/amd64 --name multi-platform-builder
|
||||
#docker buildx inspect --bootstrap
|
||||
#docker buildx build --platform=linux/amd64,linux/arm64 --push -t wisemapping/wisemapping:latest -f ./Dockerfile ../wise-webapp/target/
|
|
@ -1,64 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
WISE_VERSION=$1
|
||||
BASE_DIR=`pwd`
|
||||
TARGET_DIR=$BASE_DIR/target
|
||||
JETTY_DIR=$TARGET_DIR/wisemapping-$WISE_VERSION
|
||||
WISE_WEBAPP_DIR=$JETTY_DIR/webapps/wisemapping
|
||||
JETTY_VERSION=8.1.14.v20131031
|
||||
JETTY_DIST_DIR=jetty-distribution-${JETTY_VERSION}
|
||||
JETTY_ZIP=${JETTY_DIST_DIR}.zip
|
||||
|
||||
# Clean ...
|
||||
mvn -o -f $BASE_DIR/../pom.xml clean
|
||||
[ ! -e target ] && mkdir target
|
||||
rm -fr ${JETTY_DIR}
|
||||
rm -fr ${TARGET_DIR}/${JETTY_DIST_DIR}
|
||||
|
||||
# Prepare resources ..
|
||||
mvn -o -f $BASE_DIR/../pom.xml package -Dmaven.test.skip=true
|
||||
|
||||
if [ ! -f ./target/${JETTY_ZIP} ]
|
||||
then
|
||||
echo "Download Jetty"
|
||||
wget http://download.eclipse.org/jetty/${JETTY_VERSION}/dist/${JETTY_ZIP} -P $TARGET_DIR
|
||||
fi
|
||||
|
||||
echo "Unzip Jetty ...:"
|
||||
unzip ${TARGET_DIR}/${JETTY_ZIP} -d ${TARGET_DIR}/ > /dev/null
|
||||
mv ${TARGET_DIR}/${JETTY_DIST_DIR} ${JETTY_DIR}
|
||||
|
||||
# Clean unsed files ...
|
||||
rm -rf $JETTY_DIR/webapps/*
|
||||
rm -rf $JETTY_DIR/contexts/*
|
||||
rm -rf $JETTY_DIR/javadoc
|
||||
|
||||
# Now, start wise-webapps customization ...
|
||||
echo "Unzip wisemappig.war ..."
|
||||
mkdir $WISE_WEBAPP_DIR
|
||||
unzip $BASE_DIR/../wise-webapp/target/wisemapping.war -d $WISE_WEBAPP_DIR >/dev/null
|
||||
|
||||
# DB Configuration ...
|
||||
sed 's/\${database.base.url}\/db\/wisemapping/webapps\/wisemapping\/WEB-INF\/database\/wisemapping/' $WISE_WEBAPP_DIR/WEB-INF/app.properties > $WISE_WEBAPP_DIR/WEB-INF/app.properties2
|
||||
mv $WISE_WEBAPP_DIR/WEB-INF/app.properties2 $WISE_WEBAPP_DIR/WEB-INF/app.properties
|
||||
|
||||
mkdir $WISE_WEBAPP_DIR/WEB-INF/database
|
||||
cp -r $BASE_DIR/../wise-webapp/target/db/* $WISE_WEBAPP_DIR/WEB-INF/database/
|
||||
cp $BASE_DIR/wisemapping.xml $JETTY_DIR/contexts/
|
||||
|
||||
|
||||
# Distribute scripts
|
||||
cp -r $BASE_DIR/../config/ $TARGET_DIR/wisemapping-$WISE_VERSION/config
|
||||
cp ./start.sh ${JETTY_DIR}/
|
||||
|
||||
# Store version
|
||||
echo $1 > $WISE_WEBAPP_DIR/version
|
||||
git rev-parse HEAD >> $WISE_WEBAPP_DIR/version
|
||||
|
||||
# Zip all ...
|
||||
cd $TARGET_DIR
|
||||
zip -r wisemapping-$WISE_VERSION.zip wisemapping-$WISE_VERSION
|
||||
cd ..
|
4
distribution/registration-google/update-db-mysql.sql
Normal file
4
distribution/registration-google/update-db-mysql.sql
Normal file
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE USER
|
||||
ADD COLUMN `google_sync` TINYINT(1) NULL,
|
||||
ADD COLUMN `sync_code` VARCHAR(255) NULL,
|
||||
ADD COLUMN `google_token` VARCHAR(255) NULL;
|
4
distribution/registration-google/update-db-postgres.sql
Normal file
4
distribution/registration-google/update-db-postgres.sql
Normal file
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE "user"
|
||||
ADD COLUMN `google_sync` BOOLEAN NULL,
|
||||
ADD COLUMN `sync_code` VARCHAR(255) NULL,
|
||||
ADD COLUMN `google_token` VARCHAR(255) NULL;
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
java -Xmx256m -Dorg.apache.jasper.compiler.disablejsr199=true -jar start.jar
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
|
||||
<!-- ==================================================================
|
||||
Configure and deploy the wisemapping web application in $(jetty.home)/webapps/wisemapping
|
||||
|
||||
Note. If this file did not exist or used a context path other that /wisemapping
|
||||
then the default configuration of jetty.xml would discover the wisemapping
|
||||
webapplication with a WebAppDeployer. By specifying a context in this
|
||||
directory, additional configuration may be specified and hot deployments
|
||||
detected.
|
||||
===================================================================== -->
|
||||
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Required minimal context configuration : -->
|
||||
<!-- + contextPath -->
|
||||
<!-- + war OR resourceBase -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<Set name="contextPath">/wisemapping</Set>
|
||||
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webapps/wisemapping
|
||||
</Set>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Optional context configuration -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- <Set name="extractWAR">true</Set>
|
||||
<Set name="copyWebDir">false</Set>
|
||||
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
|
||||
<Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/contexts/wisemapping.d/override-web.xml</Set> -->
|
||||
|
||||
<!-- virtual hosts
|
||||
<Set name="virtualHosts">
|
||||
<Array type="String">
|
||||
<Item>www.myVirtualDomain.com</Item>
|
||||
<Item>localhost</Item>
|
||||
<Item>127.0.0.1</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
-->
|
||||
|
||||
<!-- disable cookies
|
||||
<Get name="sessionHandler">
|
||||
<Get name="sessionManager">
|
||||
<Set name="usingCookies" type="boolean">false</Set>
|
||||
</Get>
|
||||
</Get>
|
||||
-->
|
||||
|
||||
<Get name="securityHandler">
|
||||
<Set name="loginService">
|
||||
<New class="org.eclipse.jetty.security.HashLoginService">
|
||||
<Set name="name">Test Realm</Set>
|
||||
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties
|
||||
</Set>
|
||||
<!-- To enable reload of realm when properties change, uncomment the following lines -->
|
||||
<!-- changing refreshInterval (in seconds) as desired -->
|
||||
<!--
|
||||
<Set name="refreshInterval">5</Set>
|
||||
<Call name="start"></Call>
|
||||
-->
|
||||
</New>
|
||||
</Set>
|
||||
<Set name="checkWelcomeFiles">true</Set>
|
||||
</Get>
|
||||
|
||||
<!-- Non standard error page mapping -->
|
||||
<!--
|
||||
<Get name="errorHandler">
|
||||
<Call name="addErrorPage">
|
||||
<Arg type="int">500</Arg>
|
||||
<Arg type="int">599</Arg>
|
||||
<Arg type="String">/dump/errorCodeRangeMapping</Arg>
|
||||
</Call>
|
||||
</Get>
|
||||
-->
|
||||
|
||||
</Configure>
|
15
license.txt
15
license.txt
|
@ -1,15 +0,0 @@
|
|||
Copyright [2014] [wisemapping]
|
||||
|
||||
Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
"powered by wisemapping" text requirement on every single page;
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the license at
|
||||
|
||||
http://www.wisemapping.org/license
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
255
mindplot/pom.xml
255
mindplot/pom.xml
|
@ -1,255 +0,0 @@
|
|||
<project>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>mindplot</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mindmap Draw JavaScript Library</name>
|
||||
|
||||
<parent>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>wisemapping</artifactId>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>3.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wisemapping</groupId>
|
||||
<artifactId>web2d</artifactId>
|
||||
<version>${com.wisemapping.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.google.jstestdriver</groupId>
|
||||
<artifactId>maven-jstestdriver-plugin</artifactId>
|
||||
<version>1.2.2-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency> -->
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jstd-maven-plugin google code repo</id>
|
||||
<url>http://jstd-maven-plugin.googlecode.com/svn/maven2</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>gmaven-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>
|
||||
def outdir = new File(project.basedir, 'src/main/javascript');
|
||||
if (project.packaging != 'pom')
|
||||
{
|
||||
def dir = new File(project.basedir, 'src/main/resources/');
|
||||
|
||||
dir.eachFile { file ->
|
||||
def matcher = file.name =~ /messages_(.+)\.properties/;
|
||||
def lang = matcher[0][1];
|
||||
def outfile = new File(outdir, "MessageBundle_${lang}.js");
|
||||
println "Converting ${file.name} to ${outfile.name}";
|
||||
|
||||
outfile.withWriter('UTF-8') { out ->
|
||||
out.writeLine "mindplot.Messages.BUNDLES['${lang.toLowerCase()}'] = { ";
|
||||
file.eachLine('UTF-8') { line ->
|
||||
if( line.trim()!="" && line[0]!='#' ) {
|
||||
matcher = line =~ /(.+)=(.+)/;
|
||||
out.writeLine("'${matcher[0][1]}' : \"${matcher[0][2]}\",");
|
||||
}
|
||||
}
|
||||
out.writeLine("'DUMMY' : '' ");
|
||||
out.writeLine "};"
|
||||
}
|
||||
}
|
||||
}
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>merge-js-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy toDir="${basedir}/target/classes/">
|
||||
<fileset dir="${basedir}/src/main/javascript/">
|
||||
<include name="libraries/**/*"/>
|
||||
<include name="widget/colorPalette.*"/>
|
||||
<include name="widget/*.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</tasks>
|
||||
</configuration>
|
||||
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>net.alchim31.maven</groupId>
|
||||
<artifactId>yuicompressor-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>compress</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>${basedir}/src/main/javascript</sourceDirectory>
|
||||
<outputDirectory>${basedir}/target/compress/</outputDirectory>
|
||||
<nosuffix>true</nosuffix>
|
||||
<excludes>
|
||||
<exclude>libraries/**/*.js</exclude>
|
||||
</excludes>
|
||||
<aggregations>
|
||||
<aggregation>
|
||||
<output>${project.build.directory}/classes/mindplot-min.js</output>
|
||||
<inputDir>${basedir}/target/compress</inputDir>
|
||||
<includes>
|
||||
<include>header.js</include>
|
||||
<include>${basedir}/../web2d/target/classes/web2d.svg-min.js</include>
|
||||
<include>Messages.js</include>
|
||||
<include>TopicEventDispatcher.js</include>
|
||||
<include>model/IMindmap.js</include>
|
||||
<include>model/Mindmap.js</include>
|
||||
<include>model/INodeModel.js</include>
|
||||
<include>model/NodeModel.js</include>
|
||||
<include>model/RelationshipModel.js</include>
|
||||
<include>ActionDispatcher.js</include>
|
||||
<include>StandaloneActionDispatcher.js</include>
|
||||
<include>DesignerModel.js</include>
|
||||
<include>Designer.js</include>
|
||||
<include>ScreenManager.js</include>
|
||||
<include>Workspace.js</include>
|
||||
<include>ShrinkConnector.js</include>
|
||||
<include>DesignerKeyboard.js</include>
|
||||
<include>TopicStyle.js</include>
|
||||
<include>NodeGraph.js</include>
|
||||
<include>Topic.js</include>
|
||||
<include>CentralTopic.js</include>
|
||||
<include>MainTopic.js</include>
|
||||
<include>DragTopic.js</include>
|
||||
<include>DragManager.js</include>
|
||||
<include>DragPivot.js</include>
|
||||
<include>ConnectionLine.js</include>
|
||||
<include>Relationship.js</include>
|
||||
<include>DragConnector.js</include>
|
||||
<include>TextEditor.js</include>
|
||||
<include>MultilineTextEditor.js</include>
|
||||
<include>TextEditorFactory.js</include>
|
||||
<include>util/Shape.js</include>
|
||||
<include>util/FadeEffect.js</include>
|
||||
<include>persistence/ModelCodeName.js</include>
|
||||
<include>persistence/XMLSerializer_Pela.js</include>
|
||||
<include>persistence/XMLSerializer_Tango.js</include>
|
||||
<include>persistence/Pela2TangoMigrator.js</include>
|
||||
<include>persistence/XMLSerializer_Beta.js</include>
|
||||
<include>persistence/Beta2PelaMigrator.js</include>
|
||||
<include>persistence/XMLSerializerFactory.js</include>
|
||||
<include>PersistenceManager.js</include>
|
||||
<include>RestPersistenceManager.js</include>
|
||||
<include>LocalStorageManager.js</include>
|
||||
<include>EditorProperties.js</include>
|
||||
<include>IconGroup.js</include>
|
||||
<include>Icon.js</include>
|
||||
<include>LinkIcon.js</include>
|
||||
<include>NoteIcon.js</include>
|
||||
<include>ActionIcon.js</include>
|
||||
<include>ImageIcon.js</include>
|
||||
<include>model/FeatureModel.js</include>
|
||||
<include>model/IconModel.js</include>
|
||||
<include>model/LinkModel.js</include>
|
||||
<include>model/NoteModel.js</include>
|
||||
<include>Command.js</include>
|
||||
<include>DesignerActionRunner.js</include>
|
||||
<include>DesignerUndoManager.js</include>
|
||||
<include>ControlPoint.js</include>
|
||||
<include>EditorOptions.js</include>
|
||||
<include>RelationshipPivot.js</include>
|
||||
<include>TopicFeature.js</include>
|
||||
<include>commands/GenericFunctionCommand.js</include>
|
||||
<include>commands/DeleteCommand.js</include>
|
||||
<include>commands/DragTopicCommand.js</include>
|
||||
<include>commands/AddTopicCommand.js</include>
|
||||
<include>commands/ChangeFeatureToTopicCommand.js</include>
|
||||
<include>commands/RemoveFeatureFromTopicCommand.js</include>
|
||||
<include>commands/AddFeatureToTopicCommand.js</include>
|
||||
<include>commands/AddRelationshipCommand.js</include>
|
||||
<include>commands/MoveControlPointCommand.js</include>
|
||||
<include>widget/ModalDialogNotifier.js</include>
|
||||
<include>widget/ToolbarNotifier.js</include>
|
||||
<include>widget/ToolbarItem.js</include>
|
||||
<include>widget/ToolbarPaneItem.js</include>
|
||||
<include>widget/NoteEditor.js</include>
|
||||
<include>widget/LinkEditor.js</include>
|
||||
<include>widget/FloatingTip.js</include>
|
||||
<include>widget/LinkIconTooltip.js</include>
|
||||
<include>widget/KeyboardShortcutTooltip.js</include>
|
||||
<include>widget/ColorPalettePanel.js</include>
|
||||
<include>widget/ListToolbarPanel.js</include>
|
||||
<include>widget/FontFamilyPanel.js</include>
|
||||
<include>widget/FontSizePanel.js</include>
|
||||
<include>widget/TopicShapePanel.js</include>
|
||||
<include>widget/IconPanel.js</include>
|
||||
<include>widget/IMenu.js</include>
|
||||
<include>widget/Menu.js</include>
|
||||
<include>TopicFeature.js</include>
|
||||
<include>layout/EventBusDispatcher.js</include>
|
||||
<include>layout/ChangeEvent.js</include>
|
||||
<include>layout/LayoutManager.js</include>
|
||||
<include>layout/Node.js</include>
|
||||
<include>layout/RootedTreeSet.js</include>
|
||||
<include>layout/ChildrenSorterStrategy.js</include>
|
||||
<include>layout/AbstractBasicSorter.js</include>
|
||||
<include>layout/BalancedSorter.js</include>
|
||||
<include>layout/SymmetricSorter.js</include>
|
||||
<include>layout/GridSorter.js</include>
|
||||
<include>layout/OriginalLayout.js</include>
|
||||
<include>layout/EventBus.js</include>
|
||||
<include>MessageBundle_en.js</include>
|
||||
<include>MessageBundle_es.js</include>
|
||||
<include>MessageBundle_de.js</include>
|
||||
<include>MessageBundle_fr.js</include>
|
||||
<include>MessageBundle_pt_BR.js</include>
|
||||
<include>MessageBundle_zh_CN.js</include>
|
||||
<include>MessageBundle_zh_TW.js</include>
|
||||
<include>MessageBundle_ca.js</include>
|
||||
<include>footer.js</include>
|
||||
</includes>
|
||||
</aggregation>
|
||||
</aggregations>
|
||||
<jswarn>false</jswarn>
|
||||
<force>false</force>
|
||||
<encoding>UTF-8</encoding>
|
||||
<statistics>false</statistics>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
1
mindplot/src/main/javascript/.gitignore
vendored
1
mindplot/src/main/javascript/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
MessageBundle_*
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//noinspection JSUnusedLocalSymbols
|
||||
mindplot.ActionDispatcher = new Class({
|
||||
Implements:[Events],
|
||||
initialize: function(commandContext) {
|
||||
$assert(commandContext, "commandContext can not be null");
|
||||
},
|
||||
|
||||
addRelationship: function(model, mindmap) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addTopics: function(models, parentTopicId) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
deleteEntities: function(topicsIds, relIds) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
dragTopic: function(topicId, position, order, parentTopic) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
moveTopic: function(topicId, position) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
moveControlPoint: function(ctrlPoint, point) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontFamilyToTopic: function(topicIds, fontFamily) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontStyleToTopic: function(topicsIds) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontColorToTopic: function(topicsIds, color) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontSizeToTopic : function(topicsIds, size) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeBackgroundColorToTopic: function(topicsIds, color) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeBorderColorToTopic: function(topicsIds, color) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeShapeTypeToTopic : function(topicsIds, shapeType) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFontWeightToTopic : function(topicsIds) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeTextToTopic : function(topicsIds, text) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
shrinkBranch : function(topicsIds, collapse) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
addFeatureToTopic : function(topicId, type, attributes) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
changeFeatureToTopic : function(topicId, featureId, attributes) {
|
||||
throw "method must be implemented.";
|
||||
},
|
||||
|
||||
removeFeatureFromTopic : function(topicId, featureId) {
|
||||
throw "method must be implemented.";
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.ActionDispatcher.setInstance = function(dispatcher) {
|
||||
mindplot.ActionDispatcher._instance = dispatcher;
|
||||
};
|
||||
|
||||
mindplot.ActionDispatcher.getInstance = function() {
|
||||
return mindplot.ActionDispatcher._instance;
|
||||
};
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ActionIcon = new Class({
|
||||
Extends:mindplot.Icon,
|
||||
initialize: function(topic, url) {
|
||||
this.parent(url);
|
||||
this._node = topic;
|
||||
},
|
||||
getNode:function() {
|
||||
return this._node;
|
||||
},
|
||||
|
||||
setPosition:function(x, y) {
|
||||
var size = this.getSize();
|
||||
this.getImage().setPosition(x - size.width / 2, y - size.height / 2);
|
||||
},
|
||||
|
||||
addEvent:function(event, fn) {
|
||||
this.getImage().addEvent(event, fn);
|
||||
},
|
||||
|
||||
addToGroup:function(group) {
|
||||
group.appendChild(this.getImage());
|
||||
},
|
||||
|
||||
setVisibility:function(visible) {
|
||||
this.getImage().setVisibility(visible);
|
||||
},
|
||||
|
||||
isVisible:function() {
|
||||
return this.getImage().isVisible();
|
||||
},
|
||||
|
||||
setCursor:function(cursor) {
|
||||
return this.getImage().setCursor(cursor);
|
||||
},
|
||||
|
||||
moveToBack:function(cursor) {
|
||||
return this.getImage().moveToBack(cursor);
|
||||
},
|
||||
|
||||
moveToFront:function(cursor) {
|
||||
return this.getImage().moveToFront(cursor);
|
||||
}
|
||||
});
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.CentralTopic = new Class({
|
||||
|
||||
Extends:mindplot.Topic,
|
||||
initialize:function (model, options) {
|
||||
this.parent(model, options);
|
||||
},
|
||||
|
||||
_registerEvents:function () {
|
||||
this.parent();
|
||||
|
||||
// This disable the drag of the central topic. But solves the problem of deselecting the nodes when the screen is clicked.
|
||||
this.addEvent('mousedown', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
},
|
||||
|
||||
workoutIncomingConnectionPoint:function () {
|
||||
return this.getPosition();
|
||||
},
|
||||
|
||||
setCursor:function (type) {
|
||||
type = (type == 'move') ? 'default' : type;
|
||||
this.parent(type);
|
||||
},
|
||||
|
||||
updateTopicShape:function () {
|
||||
|
||||
},
|
||||
|
||||
_updatePositionOnChangeSize:function () {
|
||||
|
||||
// Center main topic ...
|
||||
var zeroPoint = new core.Point(0, 0);
|
||||
this.setPosition(zeroPoint);
|
||||
},
|
||||
|
||||
getShrinkConnector:function () {
|
||||
return null;
|
||||
},
|
||||
|
||||
workoutOutgoingConnectionPoint:function (targetPosition) {
|
||||
$assert(targetPosition, 'targetPoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||
var size = this.getSize();
|
||||
return mindplot.util.Shape.calculateRectConnectionPoint(pos, size, !isAtRight);
|
||||
}
|
||||
});
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.Command = new Class(
|
||||
{
|
||||
initialize: function()
|
||||
{
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext)
|
||||
{
|
||||
throw "execute must be implemented.";
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext)
|
||||
{
|
||||
throw "undo must be implemented.";
|
||||
},
|
||||
|
||||
getId:function()
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.Command._nextUUID = function()
|
||||
{
|
||||
if (!$defined(mindplot.Command._uuid))
|
||||
{
|
||||
mindplot.Command._uuid = 1;
|
||||
}
|
||||
|
||||
mindplot.Command._uuid = mindplot.Command._uuid + 1;
|
||||
return mindplot.Command._uuid;
|
||||
};
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ConnectionLine = new Class({
|
||||
initialize:function (sourceNode, targetNode, lineType) {
|
||||
$assert(targetNode, 'parentNode node can not be null');
|
||||
$assert(sourceNode, 'childNode node can not be null');
|
||||
$assert(sourceNode != targetNode, 'Circular connection');
|
||||
|
||||
this._targetTopic = targetNode;
|
||||
this._sourceTopic = sourceNode;
|
||||
|
||||
var line;
|
||||
var ctrlPoints = this._getCtrlPoints(sourceNode, targetNode);
|
||||
if (targetNode.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
line = this._createLine(lineType, mindplot.ConnectionLine.CURVED);
|
||||
line.setSrcControlPoint(ctrlPoints[0]);
|
||||
line.setDestControlPoint(ctrlPoints[1]);
|
||||
} else {
|
||||
line = this._createLine(lineType, mindplot.ConnectionLine.SIMPLE_CURVED);
|
||||
line.setSrcControlPoint(ctrlPoints[0]);
|
||||
line.setDestControlPoint(ctrlPoints[1]);
|
||||
}
|
||||
// Set line styles ...
|
||||
var strokeColor = mindplot.ConnectionLine.getStrokeColor();
|
||||
line.setStroke(1, 'solid', strokeColor, 1);
|
||||
line.setFill(strokeColor, 1);
|
||||
|
||||
this._line2d = line;
|
||||
},
|
||||
|
||||
_getCtrlPoints:function (sourceNode, targetNode) {
|
||||
var srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
|
||||
var destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
|
||||
var deltaX = (srcPos.x - destPos.x) / 3;
|
||||
return [new core.Point(deltaX, 0), new core.Point(-deltaX, 0)];
|
||||
},
|
||||
|
||||
_createLine:function (lineType, defaultStyle) {
|
||||
if (!$defined(lineType)) {
|
||||
lineType = defaultStyle;
|
||||
}
|
||||
lineType = parseInt(lineType);
|
||||
this._lineType = lineType;
|
||||
var line = null;
|
||||
switch (lineType) {
|
||||
case mindplot.ConnectionLine.POLYLINE:
|
||||
line = new web2d.PolyLine();
|
||||
break;
|
||||
case mindplot.ConnectionLine.CURVED:
|
||||
line = new web2d.CurvedLine();
|
||||
break;
|
||||
case mindplot.ConnectionLine.SIMPLE_CURVED:
|
||||
line = new web2d.CurvedLine();
|
||||
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
break;
|
||||
default:
|
||||
line = new web2d.Line();
|
||||
break;
|
||||
}
|
||||
return line;
|
||||
},
|
||||
|
||||
setVisibility:function (value) {
|
||||
this._line2d.setVisibility(value);
|
||||
},
|
||||
|
||||
isVisible:function () {
|
||||
return this._line2d.isVisible();
|
||||
},
|
||||
|
||||
setOpacity:function (opacity) {
|
||||
this._line2d.setOpacity(opacity);
|
||||
},
|
||||
|
||||
redraw:function () {
|
||||
var line2d = this._line2d;
|
||||
var sourceTopic = this._sourceTopic;
|
||||
var sourcePosition = sourceTopic.getPosition();
|
||||
|
||||
var targetTopic = this._targetTopic;
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
|
||||
var sPos, tPos;
|
||||
sPos = sourceTopic.workoutOutgoingConnectionPoint(targetPosition);
|
||||
tPos = targetTopic.workoutIncomingConnectionPoint(sourcePosition);
|
||||
|
||||
line2d.setFrom(tPos.x, tPos.y);
|
||||
line2d.setTo(sPos.x, sPos.y);
|
||||
|
||||
if (line2d.getType() == "CurvedLine") {
|
||||
var ctrlPoints = this._getCtrlPoints(this._sourceTopic, this._targetTopic);
|
||||
line2d.setSrcControlPoint(ctrlPoints[0]);
|
||||
line2d.setDestControlPoint(ctrlPoints[1]);
|
||||
}
|
||||
|
||||
// Add connector ...
|
||||
this._positionateConnector(targetTopic);
|
||||
|
||||
},
|
||||
|
||||
_positionateConnector:function (targetTopic) {
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
|
||||
var targetTopicSize = targetTopic.getSize();
|
||||
var y, x;
|
||||
if (targetTopic.getShapeType() == mindplot.model.TopicShape.LINE) {
|
||||
y = targetTopicSize.height;
|
||||
} else {
|
||||
y = targetTopicSize.height / 2;
|
||||
}
|
||||
y = y - offset;
|
||||
|
||||
var connector = targetTopic.getShrinkConnector();
|
||||
if ($defined(connector)) {
|
||||
if (Math.sign(targetPosition.x) > 0) {
|
||||
x = targetTopicSize.width;
|
||||
connector.setPosition(x, y);
|
||||
}
|
||||
else {
|
||||
x = -mindplot.Topic.CONNECTOR_WIDTH;
|
||||
}
|
||||
connector.setPosition(x, y);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setStroke:function (color, style, opacity) {
|
||||
this._line2d.setStroke(null, null, color, opacity);
|
||||
},
|
||||
|
||||
addToWorkspace:function (workspace) {
|
||||
workspace.appendChild(this._line2d);
|
||||
this._line2d.moveToBack();
|
||||
},
|
||||
|
||||
removeFromWorkspace:function (workspace) {
|
||||
workspace.removeChild(this._line2d);
|
||||
},
|
||||
|
||||
getTargetTopic:function () {
|
||||
return this._targetTopic;
|
||||
},
|
||||
|
||||
getSourceTopic:function () {
|
||||
return this._sourceTopic;
|
||||
},
|
||||
|
||||
getLineType:function () {
|
||||
return this._lineType;
|
||||
},
|
||||
|
||||
getLine:function () {
|
||||
return this._line2d;
|
||||
},
|
||||
|
||||
getModel:function () {
|
||||
return this._model;
|
||||
},
|
||||
|
||||
setModel:function (model) {
|
||||
this._model = model;
|
||||
},
|
||||
|
||||
getType:function () {
|
||||
return "ConnectionLine";
|
||||
},
|
||||
|
||||
getId:function () {
|
||||
return this._model.getId();
|
||||
},
|
||||
|
||||
moveToBack:function () {
|
||||
this._line2d.moveToBack();
|
||||
},
|
||||
|
||||
moveToFront:function () {
|
||||
this._line2d.moveToFront();
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.ConnectionLine.getStrokeColor = function () {
|
||||
return '#495879';
|
||||
};
|
||||
|
||||
mindplot.ConnectionLine.SIMPLE = 0;
|
||||
mindplot.ConnectionLine.POLYLINE = 1;
|
||||
mindplot.ConnectionLine.CURVED = 2;
|
||||
mindplot.ConnectionLine.SIMPLE_CURVED = 3;
|
|
@ -1,193 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ControlPoint = new Class({
|
||||
initialize:function() {
|
||||
var control1 = new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false});
|
||||
control1.setCursor('pointer');
|
||||
|
||||
var control2 = new web2d.Elipse({width:6, height:6, stroke:'1 solid #6589de',fillColor:'gray', visibility:false});
|
||||
control2.setCursor('pointer');
|
||||
|
||||
this._controlPointsController = [control1,control2];
|
||||
this._controlLines = [new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3}),
|
||||
new web2d.Line({strokeColor:"#6589de", strokeWidth:1, opacity:0.3})];
|
||||
|
||||
this._isBinded = false;
|
||||
this._controlPointsController[0].addEvent('mousedown', function(event) {
|
||||
(this._mouseDown.bind(this))(event, mindplot.ControlPoint.FROM);
|
||||
}.bind(this));
|
||||
this._controlPointsController[0].addEvent('click', function(event) {
|
||||
(this._mouseClick.bind(this))(event);
|
||||
}.bind(this));
|
||||
this._controlPointsController[0].addEvent('dblclick', function(event) {
|
||||
(this._mouseClick.bind(this))(event);
|
||||
}.bind(this));
|
||||
|
||||
this._controlPointsController[1].addEvent('mousedown', function(event) {
|
||||
(this._mouseDown.bind(this))(event, mindplot.ControlPoint.TO);
|
||||
}.bind(this));
|
||||
this._controlPointsController[1].addEvent('click', function(event) {
|
||||
(this._mouseClick.bind(this))(event);
|
||||
}.bind(this));
|
||||
this._controlPointsController[1].addEvent('dblclick', function(event) {
|
||||
(this._mouseClick.bind(this))(event);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
||||
setSide : function(side) {
|
||||
this._side = side;
|
||||
},
|
||||
|
||||
setLine : function(line) {
|
||||
if ($defined(this._line)) {
|
||||
this._removeLine();
|
||||
}
|
||||
this._line = line;
|
||||
this._createControlPoint();
|
||||
this._endPoint = [];
|
||||
this._orignalCtrlPoint = [];
|
||||
this._orignalCtrlPoint[0] = this._controls[0].clone();
|
||||
this._orignalCtrlPoint[1] = this._controls[1].clone();
|
||||
this._endPoint[0] = this._line.getLine().getFrom().clone();
|
||||
this._endPoint[1] = this._line.getLine().getTo().clone();
|
||||
},
|
||||
|
||||
redraw : function() {
|
||||
if ($defined(this._line))
|
||||
this._createControlPoint();
|
||||
},
|
||||
|
||||
_createControlPoint : function() {
|
||||
this._controls = this._line.getLine().getControlPoints();
|
||||
var pos = this._line.getLine().getFrom();
|
||||
this._controlPointsController[0].setPosition(this._controls[mindplot.ControlPoint.FROM].x + pos.x, this._controls[mindplot.ControlPoint.FROM].y + pos.y - 3);
|
||||
this._controlLines[0].setFrom(pos.x, pos.y);
|
||||
this._controlLines[0].setTo(this._controls[mindplot.ControlPoint.FROM].x + pos.x + 3, this._controls[mindplot.ControlPoint.FROM].y + pos.y);
|
||||
pos = this._line.getLine().getTo();
|
||||
this._controlLines[1].setFrom(pos.x, pos.y);
|
||||
this._controlLines[1].setTo(this._controls[mindplot.ControlPoint.TO].x + pos.x + 3, this._controls[mindplot.ControlPoint.TO].y + pos.y);
|
||||
this._controlPointsController[1].setPosition(this._controls[mindplot.ControlPoint.TO].x + pos.x, this._controls[mindplot.ControlPoint.TO].y + pos.y - 3);
|
||||
|
||||
},
|
||||
|
||||
_removeLine : function() {
|
||||
|
||||
},
|
||||
|
||||
_mouseDown : function(event, point) {
|
||||
if (!this._isBinded) {
|
||||
this._isBinded = true;
|
||||
|
||||
this._mouseMoveFunction = function(event) {
|
||||
(this._mouseMoveEvent.bind(this))(event, point);
|
||||
}.bind(this);
|
||||
|
||||
this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction);
|
||||
this._mouseUpFunction = function(event) {
|
||||
(this._mouseUp.bind(this))(event, point);
|
||||
}.bind(this);
|
||||
this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
return false;
|
||||
},
|
||||
|
||||
_mouseMoveEvent : function(event, point) {
|
||||
var screen = this._workspace.getScreenManager();
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
var topic = null;
|
||||
if (point == 0) {
|
||||
var cords = mindplot.util.Shape.calculateRelationShipPointCoordinates(this._line.getSourceTopic(), pos);
|
||||
this._line.setFrom(cords.x, cords.y);
|
||||
this._line.setSrcControlPoint(new core.Point(pos.x - cords.x, pos.y - cords.y));
|
||||
} else {
|
||||
var cords = mindplot.util.Shape.calculateRelationShipPointCoordinates(this._line.getTargetTopic(), pos);
|
||||
this._line.setTo(cords.x, cords.y);
|
||||
this._line.setDestControlPoint(new core.Point(pos.x - cords.x, pos.y - cords.y));
|
||||
}
|
||||
this._controls[point].x = (pos.x - cords.x);
|
||||
this._controls[point].y = (pos.y - cords.y);
|
||||
this._controlPointsController[point].setPosition(pos.x - 5, pos.y - 3);
|
||||
this._controlLines[point].setFrom(cords.x, cords.y);
|
||||
this._controlLines[point].setTo(pos.x - 2, pos.y);
|
||||
this._line.getLine().updateLine(point);
|
||||
|
||||
},
|
||||
|
||||
_mouseUp : function(event, point) {
|
||||
this._workspace.getScreenManager().removeEvent('mousemove', this._mouseMoveFunction);
|
||||
this._workspace.getScreenManager().removeEvent('mouseup', this._mouseUpFunction);
|
||||
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.moveControlPoint(this, point);
|
||||
this._isBinded = false;
|
||||
},
|
||||
|
||||
_mouseClick : function(event) {
|
||||
event.preventDefault();
|
||||
event.stop();
|
||||
return false;
|
||||
},
|
||||
|
||||
setVisibility : function(visible) {
|
||||
if (visible) {
|
||||
this._controlLines[0].moveToFront();
|
||||
this._controlLines[1].moveToFront();
|
||||
this._controlPointsController[0].moveToFront();
|
||||
this._controlPointsController[1].moveToFront();
|
||||
}
|
||||
this._controlPointsController[0].setVisibility(visible);
|
||||
this._controlPointsController[1].setVisibility(visible);
|
||||
this._controlLines[0].setVisibility(visible);
|
||||
this._controlLines[1].setVisibility(visible);
|
||||
},
|
||||
|
||||
addToWorkspace : function(workspace) {
|
||||
this._workspace = workspace;
|
||||
workspace.appendChild(this._controlPointsController[0]);
|
||||
workspace.appendChild(this._controlPointsController[1]);
|
||||
workspace.appendChild(this._controlLines[0]);
|
||||
workspace.appendChild(this._controlLines[1]);
|
||||
},
|
||||
|
||||
removeFromWorkspace : function(workspace) {
|
||||
this._workspace = null;
|
||||
workspace.removeChild(this._controlPointsController[0]);
|
||||
workspace.removeChild(this._controlPointsController[1]);
|
||||
workspace.removeChild(this._controlLines[0]);
|
||||
workspace.removeChild(this._controlLines[1]);
|
||||
},
|
||||
|
||||
getControlPoint : function(index) {
|
||||
return this._controls[index];
|
||||
},
|
||||
|
||||
getOriginalEndPoint : function(index) {
|
||||
return this._endPoint[index];
|
||||
},
|
||||
|
||||
getOriginalCtrlPoint : function(index) {
|
||||
return this._orignalCtrlPoint[index];
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.ControlPoint.FROM = 0;
|
||||
mindplot.ControlPoint.TO = 1;
|
|
@ -1,946 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.Designer = new Class({
|
||||
Extends:Events,
|
||||
initialize:function (options, divElement) {
|
||||
$assert(options, "options must be defined");
|
||||
$assert(options.zoom, "zoom must be defined");
|
||||
$assert(divElement, "divElement must be defined");
|
||||
|
||||
// Set up i18n location ...
|
||||
mindplot.Messages.init(options.locale);
|
||||
|
||||
this._options = options;
|
||||
|
||||
// Set full div elem render area ...
|
||||
divElement.setStyles(options.size);
|
||||
|
||||
// Dispatcher manager ...
|
||||
var commandContext = new mindplot.CommandContext(this);
|
||||
this._actionDispatcher = new mindplot.StandaloneActionDispatcher(commandContext);
|
||||
|
||||
this._actionDispatcher.addEvent("modelUpdate", function (event) {
|
||||
this.fireEvent("modelUpdate", event);
|
||||
}.bind(this));
|
||||
|
||||
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
||||
this._model = new mindplot.DesignerModel(options);
|
||||
|
||||
// Init Screen manager..
|
||||
var screenManager = new mindplot.ScreenManager(divElement);
|
||||
this._workspace = new mindplot.Workspace(screenManager, this._model.getZoom());
|
||||
|
||||
// Init layout manager ...
|
||||
this._eventBussDispatcher = new mindplot.layout.EventBusDispatcher(this.getModel());
|
||||
|
||||
// Register events
|
||||
if (!this.isReadOnly()) {
|
||||
// Register mouse events ...
|
||||
this._registerMouseEvents();
|
||||
|
||||
// Register keyboard events ...
|
||||
mindplot.DesignerKeyboard.register(this);
|
||||
|
||||
this._dragManager = this._buildDragManager(this._workspace);
|
||||
}
|
||||
this._registerWheelEvents();
|
||||
|
||||
this._relPivot = new mindplot.RelationshipPivot(this._workspace, this);
|
||||
|
||||
// Set editor working area ...
|
||||
this.setViewPort(options.viewPort);
|
||||
|
||||
mindplot.TopicEventDispatcher.configure(this.isReadOnly());
|
||||
this._clipboard = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Deactivates the keyboard events so you can enter text into forms
|
||||
*/
|
||||
deactivateKeyboard:function () {
|
||||
mindplot.DesignerKeyboard.getInstance().deactivate();
|
||||
this.deselectAll();
|
||||
},
|
||||
|
||||
_registerWheelEvents:function () {
|
||||
var workspace = this._workspace;
|
||||
var screenManager = workspace.getScreenManager();
|
||||
|
||||
// Zoom In and Zoom Out must active event
|
||||
$(document).addEvent('mousewheel', function (event) {
|
||||
// Change mousewheel handling so we let the default
|
||||
//event happen if we are outside the container.
|
||||
var coords = screenManager.getContainer().getCoordinates();
|
||||
var isOutsideContainer = event.client.y < coords.top ||
|
||||
event.client.y > coords.bottom ||
|
||||
event.client.x < coords.left ||
|
||||
event.client.x > coords.right;
|
||||
|
||||
if (!isOutsideContainer) {
|
||||
if (event.wheel > 0) {
|
||||
this.zoomIn(1.05);
|
||||
}
|
||||
else {
|
||||
this.zoomOut(1.05);
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Activates the keyboard events so you can enter text into forms
|
||||
*/
|
||||
activateKeyboard:function () {
|
||||
mindplot.DesignerKeyboard.getInstance().activate();
|
||||
},
|
||||
|
||||
|
||||
addEvent:function (type, listener) {
|
||||
if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) {
|
||||
var editor = mindplot.TopicEventDispatcher.getInstance();
|
||||
editor.addEvent(type, listener);
|
||||
} else {
|
||||
this.parent(type, listener);
|
||||
}
|
||||
},
|
||||
|
||||
_registerMouseEvents:function () {
|
||||
var workspace = this._workspace;
|
||||
var screenManager = workspace.getScreenManager();
|
||||
|
||||
// Initialize workspace event listeners.
|
||||
screenManager.addEvent('update', function () {
|
||||
// Topic must be set to his original state. All editors must be closed.
|
||||
var topics = this.getModel().getTopics();
|
||||
topics.each(function (object) {
|
||||
object.closeEditors();
|
||||
});
|
||||
|
||||
// Clean some selected nodes on event ..
|
||||
if (this._cleanScreen)
|
||||
this._cleanScreen();
|
||||
|
||||
}.bind(this));
|
||||
|
||||
// Deselect on click ...
|
||||
screenManager.addEvent('click', function (event) {
|
||||
this.onObjectFocusEvent(null, event);
|
||||
}.bind(this));
|
||||
|
||||
// Create nodes on double click...
|
||||
screenManager.addEvent('dblclick', function (event) {
|
||||
if (workspace.isWorkspaceEventsEnabled()) {
|
||||
|
||||
var mousePos = screenManager.getWorkspaceMousePosition(event);
|
||||
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
var model = this._createChildModel(centralTopic, mousePos);
|
||||
this._actionDispatcher.addTopics([model], [centralTopic.getId()]);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Register mouse drag and drop event ...
|
||||
function noopHandler(evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
||||
// Enable drag events ...
|
||||
// @Todo: Images support on progress ...
|
||||
// Element.NativeEvents.dragenter = 2;
|
||||
// Element.NativeEvents.dragexit = 2;
|
||||
// Element.NativeEvents.dragover = 2;
|
||||
// Element.NativeEvents.drop = 2;
|
||||
//
|
||||
// screenManager.addEvent('dragenter', noopHandler);
|
||||
// screenManager.addEvent('dragexit', noopHandler);
|
||||
// screenManager.addEvent('dragover', noopHandler);
|
||||
// screenManager.addEvent('drop', function (evt) {
|
||||
// evt.stopPropagation();
|
||||
// evt.preventDefault();
|
||||
////
|
||||
// var files = evt.event.dataTransfer.files;
|
||||
// console.log(event);
|
||||
//
|
||||
// var count = files.length;
|
||||
//
|
||||
// // Only call the handler if 1 or more files was dropped.
|
||||
// if (count > 0) {
|
||||
//
|
||||
// var model = this.getMindmap().createNode();
|
||||
// model.setImageSize(80, 43);
|
||||
// model.setMetadata("{'media':'video,'url':'http://www.youtube.com/watch?v=P3FrXftyuzw&feature=g-vrec&context=G2b4ab69RVAAAAAAAAAA'}");
|
||||
// model.setImageUrl("images/logo-small.png");
|
||||
// model.setShapeType(mindplot.model.TopicShape.IMAGE);
|
||||
//
|
||||
// var position = screenManager.getWorkspaceMousePosition(evt);
|
||||
// model.setPosition(position.x, position.y);
|
||||
// model.setPosition(100, 100);
|
||||
//
|
||||
// this._actionDispatcher.addTopics([model]);
|
||||
// }
|
||||
// }.bind(this));
|
||||
|
||||
|
||||
},
|
||||
|
||||
_buildDragManager:function (workspace) {
|
||||
|
||||
var designerModel = this.getModel();
|
||||
var dragConnector = new mindplot.DragConnector(designerModel, this._workspace);
|
||||
var dragManager = new mindplot.DragManager(workspace, this._eventBussDispatcher);
|
||||
var topics = designerModel.getTopics();
|
||||
|
||||
dragManager.addEvent('startdragging', function () {
|
||||
// Enable all mouse events.
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
topics[i].setMouseEventsEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
dragManager.addEvent('dragging', function (event, dragTopic) {
|
||||
dragTopic.updateFreeLayout(event);
|
||||
if (!dragTopic.isFreeLayoutOn(event)) {
|
||||
// The node is being drag. Is the connection still valid ?
|
||||
dragConnector.checkConnection(dragTopic);
|
||||
|
||||
if (!dragTopic.isVisible() && dragTopic.isConnected()) {
|
||||
dragTopic.setVisibility(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dragManager.addEvent('enddragging', function (event, dragTopic) {
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
topics[i].setMouseEventsEnabled(true);
|
||||
}
|
||||
dragTopic.applyChanges(workspace);
|
||||
});
|
||||
|
||||
return dragManager;
|
||||
},
|
||||
|
||||
setViewPort:function (size) {
|
||||
this._workspace.setViewPort(size);
|
||||
var model = this.getModel();
|
||||
this._workspace.setZoom(model.getZoom(), true);
|
||||
},
|
||||
|
||||
|
||||
_buildNodeGraph:function (model, readOnly) {
|
||||
// Create node graph ...
|
||||
var topic = mindplot.NodeGraph.create(model, {readOnly:readOnly});
|
||||
this.getModel().addTopic(topic);
|
||||
|
||||
// Add Topic events ...
|
||||
if (!readOnly) {
|
||||
// If a node had gained focus, clean the rest of the nodes ...
|
||||
topic.addEvent('mousedown', function (event) {
|
||||
this.onObjectFocusEvent(topic, event);
|
||||
}.bind(this));
|
||||
|
||||
// Register node listeners ...
|
||||
if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
|
||||
// Central Topic doesn't support to be dragged
|
||||
this._dragManager.add(topic);
|
||||
}
|
||||
}
|
||||
|
||||
// Connect Topic ...
|
||||
var isConnected = model.isConnected();
|
||||
if (isConnected) {
|
||||
// Improve this ...
|
||||
var targetTopicModel = model.getParent();
|
||||
var targetTopic = null;
|
||||
|
||||
var topics = this.getModel().getTopics();
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
var t = topics[i];
|
||||
if (t.getModel() == targetTopicModel) {
|
||||
targetTopic = t;
|
||||
// Disconnect the node. It will be connected again later ...
|
||||
model.disconnect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
$assert(targetTopic, "Could not find a topic to connect");
|
||||
topic.connectTo(targetTopic, this._workspace);
|
||||
}
|
||||
|
||||
topic.addEvent('ontblur', function () {
|
||||
var topics = this.getModel().filterSelectedTopics();
|
||||
var rels = this.getModel().filterSelectedRelationships();
|
||||
|
||||
if (topics.length == 0 || rels.length == 0) {
|
||||
this.fireEvent('onblur');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
topic.addEvent('ontfocus', function () {
|
||||
var topics = this.getModel().filterSelectedTopics();
|
||||
var rels = this.getModel().filterSelectedRelationships();
|
||||
|
||||
if (topics.length == 1 || rels.length == 1) {
|
||||
this.fireEvent('onfocus');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
return topic;
|
||||
},
|
||||
|
||||
onObjectFocusEvent:function (currentObject, event) {
|
||||
// Close node editors ..
|
||||
var topics = this.getModel().getTopics();
|
||||
topics.each(function (topic) {
|
||||
topic.closeEditors();
|
||||
});
|
||||
|
||||
var model = this.getModel();
|
||||
var objects = model.getEntities();
|
||||
objects.each(function (object) {
|
||||
// Disable all nodes on focus but not the current if Ctrl key isn't being pressed
|
||||
if (!$defined(event) || (!event.control && !event.meta)) {
|
||||
if (object.isOnFocus() && object != currentObject) {
|
||||
object.setOnFocus(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
selectAll:function () {
|
||||
var model = this.getModel();
|
||||
var objects = model.getEntities();
|
||||
objects.each(function (object) {
|
||||
object.setOnFocus(true);
|
||||
});
|
||||
},
|
||||
|
||||
deselectAll:function () {
|
||||
var objects = this.getModel().getEntities();
|
||||
objects.each(function (object) {
|
||||
object.setOnFocus(false);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the zoom of the map.
|
||||
* @param: zoom: number between 0.3 and 1.9
|
||||
*/
|
||||
setZoom:function (zoom) {
|
||||
if (zoom > 1.9 || zoom < 0.3) {
|
||||
$notify($msg('ZOOM_IN_ERROR'));
|
||||
return;
|
||||
}
|
||||
this.getModel().setZoom(zoom);
|
||||
this._workspace.setZoom(zoom);
|
||||
},
|
||||
|
||||
zoomOut:function (factor) {
|
||||
if (!factor)
|
||||
factor = 1.2;
|
||||
|
||||
var model = this.getModel();
|
||||
var scale = model.getZoom() * factor;
|
||||
if (scale <= 1.9) {
|
||||
model.setZoom(scale);
|
||||
this._workspace.setZoom(scale);
|
||||
}
|
||||
else {
|
||||
$notify($msg('ZOOM_ERROR'));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
zoomIn:function (factor) {
|
||||
if (!factor)
|
||||
factor = 1.2;
|
||||
|
||||
var model = this.getModel();
|
||||
var scale = model.getZoom() / factor;
|
||||
|
||||
if (scale >= 0.3) {
|
||||
model.setZoom(scale);
|
||||
this._workspace.setZoom(scale);
|
||||
}
|
||||
else {
|
||||
$notify($msg('ZOOM_ERROR'));
|
||||
}
|
||||
},
|
||||
|
||||
copyToClipboard:function () {
|
||||
var topics = this.getModel().filterSelectedTopics();
|
||||
if (topics.length <= 0) {
|
||||
// If there are more than one node selected,
|
||||
$notify($msg('AT_LEAST_ONE_TOPIC_MUST_BE_SELECTED'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Exclude central topic ..
|
||||
topics = topics.filter(function (topic) {
|
||||
return !topic.isCentralTopic();
|
||||
});
|
||||
|
||||
this._clipboard = topics.map(function (topic) {
|
||||
var nodeModel = topic.getModel().deepCopy();
|
||||
|
||||
// Change position to make the new topic evident...
|
||||
var pos = nodeModel.getPosition();
|
||||
nodeModel.setPosition(pos.x + (60 * Math.sign(pos.x)), pos.y + 30);
|
||||
|
||||
return nodeModel;
|
||||
});
|
||||
|
||||
$notify($msg('SELECTION_COPIED_TO_CLIPBOARD'));
|
||||
},
|
||||
|
||||
pasteClipboard:function () {
|
||||
if (this._clipboard.length == 0) {
|
||||
$notify($msg('CLIPBOARD_IS_EMPTY'));
|
||||
return;
|
||||
}
|
||||
this._actionDispatcher.addTopics(this._clipboard);
|
||||
this._clipboard = [];
|
||||
},
|
||||
|
||||
getModel:function () {
|
||||
return this._model;
|
||||
},
|
||||
|
||||
|
||||
shrinkSelectedBranch:function () {
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0 || nodes.length != 1) {
|
||||
// If there are more than one node selected,
|
||||
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED_COLLAPSE'));
|
||||
return;
|
||||
|
||||
}
|
||||
// Execute event ...
|
||||
var topic = nodes[0];
|
||||
if (topic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
this._actionDispatcher.shrinkBranch([topic.getId()], !topic.areChildrenShrunken());
|
||||
}
|
||||
},
|
||||
|
||||
createChildForSelectedNode:function () {
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0) {
|
||||
// If there are more than one node selected,
|
||||
$notify($msg('ONE_TOPIC_MUST_BE_SELECTED'));
|
||||
return;
|
||||
|
||||
}
|
||||
if (nodes.length != 1) {
|
||||
|
||||
// If there are more than one node selected,
|
||||
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Add new node ...
|
||||
var parentTopic = nodes[0];
|
||||
var parentTopicId = parentTopic.getId();
|
||||
var childModel = this._createChildModel(parentTopic);
|
||||
|
||||
// Execute event ...
|
||||
this._actionDispatcher.addTopics([childModel], [parentTopicId]);
|
||||
|
||||
},
|
||||
|
||||
_copyNodeProps: function(sourceModel,targetModel){
|
||||
|
||||
// I don't copy the font size if the target is the source is the central topic.
|
||||
if(sourceModel.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE)
|
||||
{
|
||||
var fontSize = sourceModel.getFontSize();
|
||||
if(fontSize){
|
||||
targetModel.setFontSize(fontSize)
|
||||
}
|
||||
}
|
||||
|
||||
var fontFamily = sourceModel.getFontFamily();
|
||||
if(fontFamily){
|
||||
targetModel.setFontFamily(fontFamily)
|
||||
}
|
||||
|
||||
var fontColor = sourceModel.getFontColor();
|
||||
if(fontColor){
|
||||
targetModel.setFontColor(fontColor)
|
||||
}
|
||||
|
||||
var fontWeight = sourceModel.getFontWeight();
|
||||
if(fontWeight){
|
||||
targetModel.setFontWeight(fontWeight)
|
||||
}
|
||||
|
||||
var fontStyle = sourceModel.getFontStyle();
|
||||
if(fontStyle){
|
||||
targetModel.setFontStyle(fontStyle)
|
||||
}
|
||||
|
||||
var shape = sourceModel.getShapeType();
|
||||
if(shape){
|
||||
targetModel.setShapeType(shape)
|
||||
}
|
||||
|
||||
var borderColor = sourceModel.getBorderColor();
|
||||
if(borderColor){
|
||||
targetModel.setBorderColor(borderColor)
|
||||
}
|
||||
},
|
||||
|
||||
_createChildModel:function (topic, mousePos) {
|
||||
// Create a new node ...
|
||||
var parentModel = topic.getModel();
|
||||
var mindmap = parentModel.getMindmap();
|
||||
var childModel = mindmap.createNode();
|
||||
|
||||
// Create a new node ...
|
||||
var layoutManager = this._eventBussDispatcher.getLayoutManager();
|
||||
var result = layoutManager.predict(topic.getId(), null, mousePos);
|
||||
childModel.setOrder(result.order);
|
||||
|
||||
var position = result.position;
|
||||
childModel.setPosition(position.x, position.y);
|
||||
|
||||
this._copyNodeProps(parentModel,childModel);
|
||||
|
||||
return childModel;
|
||||
},
|
||||
|
||||
addDraggedNode:function (event, model) {
|
||||
$assert(event, "event can not be null");
|
||||
$assert(model, "model can not be null");
|
||||
|
||||
// Position far from the visual area ...
|
||||
model.setPosition(1000, 1000);
|
||||
|
||||
this._actionDispatcher.addTopics([model]);
|
||||
var topic = this.getModel().findTopicById(model.getId());
|
||||
|
||||
// Simulate a mouse down event to start the dragging ...
|
||||
topic.fireEvent("mousedown", event);
|
||||
},
|
||||
|
||||
createSiblingForSelectedNode:function () {
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0) {
|
||||
// If there are no nodes selected,
|
||||
$notify($msg('ONE_TOPIC_MUST_BE_SELECTED'));
|
||||
return;
|
||||
|
||||
}
|
||||
if (nodes.length > 1) {
|
||||
// If there are more than one node selected,
|
||||
$notify($msg('ONLY_ONE_TOPIC_MUST_BE_SELECTED'));
|
||||
return;
|
||||
}
|
||||
|
||||
var topic = nodes[0];
|
||||
if (!topic.getOutgoingConnectedTopic()) { // Central topic and isolated topics ....
|
||||
// Central topic doesn't have siblings ...
|
||||
this.createChildForSelectedNode();
|
||||
|
||||
} else {
|
||||
var parentTopic = topic.getOutgoingConnectedTopic();
|
||||
var siblingModel = this._createSiblingModel(topic);
|
||||
|
||||
// Hack: if parent is central topic, add node below not on opposite side.
|
||||
// This should be done in the layout
|
||||
if (parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
siblingModel.setOrder(topic.getOrder() + 2);
|
||||
}
|
||||
|
||||
var parentTopicId = parentTopic.getId();
|
||||
this._actionDispatcher.addTopics([siblingModel], [parentTopicId]);
|
||||
}
|
||||
},
|
||||
|
||||
_createSiblingModel:function (topic) {
|
||||
var result = null;
|
||||
var parentTopic = topic.getOutgoingConnectedTopic();
|
||||
if (parentTopic != null) {
|
||||
|
||||
// Create a new node ...
|
||||
var model = topic.getModel();
|
||||
var mindmap = model.getMindmap();
|
||||
result = mindmap.createNode();
|
||||
|
||||
// Create a new node ...
|
||||
var order = topic.getOrder() + 1;
|
||||
result.setOrder(order);
|
||||
result.setPosition(10, 10); // Set a dummy position ...
|
||||
}
|
||||
|
||||
this._copyNodeProps(model,result);
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
showRelPivot:function (event) {
|
||||
|
||||
var nodes = this.getModel().filterSelectedTopics();
|
||||
if (nodes.length <= 0) {
|
||||
// This could not happen ...
|
||||
$notify($msg('RELATIONSHIP_COULD_NOT_BE_CREATED'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Current mouse position ....
|
||||
var screen = this._workspace.getScreenManager();
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
|
||||
// create a connection ...
|
||||
this._relPivot.start(nodes[0], pos);
|
||||
},
|
||||
|
||||
getMindmapProperties:function () {
|
||||
return {zoom:this.getModel().getZoom()};
|
||||
},
|
||||
|
||||
loadMap:function (mindmapModel) {
|
||||
$assert(mindmapModel, "mindmapModel can not be null");
|
||||
this._mindmap = mindmapModel;
|
||||
|
||||
// Init layout manager ...
|
||||
var size = {width:25, height:25};
|
||||
var layoutManager = new mindplot.layout.LayoutManager(mindmapModel.getCentralTopic().getId(), size);
|
||||
layoutManager.addEvent('change', function (event) {
|
||||
var id = event.getId();
|
||||
var topic = this.getModel().findTopicById(id);
|
||||
topic.setPosition(event.getPosition());
|
||||
topic.setOrder(event.getOrder());
|
||||
}.bind(this));
|
||||
this._eventBussDispatcher.setLayoutManager(layoutManager);
|
||||
|
||||
|
||||
// Building node graph ...
|
||||
var branches = mindmapModel.getBranches();
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
// NodeModel -> NodeGraph ...
|
||||
var nodeModel = branches[i];
|
||||
var nodeGraph = this._nodeModelToNodeGraph(nodeModel);
|
||||
|
||||
// Update shrink render state...
|
||||
nodeGraph.setBranchVisibility(true);
|
||||
}
|
||||
|
||||
var relationships = mindmapModel.getRelationships();
|
||||
for (var j = 0; j < relationships.length; j++) {
|
||||
this._relationshipModelToRelationship(relationships[j]);
|
||||
}
|
||||
|
||||
// Place the focus on the Central Topic
|
||||
var centralTopic = this.getModel().getCentralTopic();
|
||||
this.goToNode(centralTopic);
|
||||
|
||||
// Finally, sort the map ...
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
this.fireEvent('loadSuccess');
|
||||
},
|
||||
|
||||
getMindmap:function () {
|
||||
return this._mindmap;
|
||||
},
|
||||
|
||||
undo:function () {
|
||||
// @Todo: This is a hack...
|
||||
this._actionDispatcher._actionRunner.undo();
|
||||
},
|
||||
|
||||
redo:function () {
|
||||
this._actionDispatcher._actionRunner.redo();
|
||||
},
|
||||
|
||||
isReadOnly:function () {
|
||||
return this._options.readOnly;
|
||||
},
|
||||
|
||||
_nodeModelToNodeGraph:function (nodeModel) {
|
||||
$assert(nodeModel, "Node model can not be null");
|
||||
var children = nodeModel.getChildren().slice();
|
||||
children = children.sort(function (a, b) {
|
||||
return a.getOrder() - b.getOrder()
|
||||
});
|
||||
|
||||
var nodeGraph = this._buildNodeGraph(nodeModel, this.isReadOnly());
|
||||
nodeGraph.setVisibility(false);
|
||||
|
||||
this._workspace.appendChild(nodeGraph);
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if ($defined(child))
|
||||
this._nodeModelToNodeGraph(child);
|
||||
}
|
||||
|
||||
return nodeGraph;
|
||||
},
|
||||
|
||||
_relationshipModelToRelationship:function (model) {
|
||||
$assert(model, "Node model can not be null");
|
||||
|
||||
var result = this._buildRelationshipShape(model);
|
||||
|
||||
var sourceTopic = result.getSourceTopic();
|
||||
sourceTopic.addRelationship(result);
|
||||
|
||||
var targetTopic = result.getTargetTopic();
|
||||
targetTopic.addRelationship(result);
|
||||
|
||||
result.setVisibility(sourceTopic.isVisible() && targetTopic.isVisible());
|
||||
|
||||
this._workspace.appendChild(result);
|
||||
return result;
|
||||
},
|
||||
|
||||
_addRelationship:function (model) {
|
||||
var mindmap = this.getMindmap();
|
||||
mindmap.addRelationship(model);
|
||||
return this._relationshipModelToRelationship(model);
|
||||
},
|
||||
|
||||
_deleteRelationship:function (rel) {
|
||||
var sourceTopic = rel.getSourceTopic();
|
||||
sourceTopic.deleteRelationship(rel);
|
||||
|
||||
var targetTopic = rel.getTargetTopic();
|
||||
targetTopic.deleteRelationship(rel);
|
||||
|
||||
this.getModel().removeRelationship(rel);
|
||||
this._workspace.removeChild(rel);
|
||||
|
||||
var mindmap = this.getMindmap();
|
||||
mindmap.deleteRelationship(rel.getModel());
|
||||
},
|
||||
|
||||
_buildRelationshipShape:function (model) {
|
||||
var dmodel = this.getModel();
|
||||
|
||||
var sourceTopicId = model.getFromNode();
|
||||
var sourceTopic = dmodel.findTopicById(sourceTopicId);
|
||||
|
||||
var targetTopicId = model.getToNode();
|
||||
var targetTopic = dmodel.findTopicById(targetTopicId);
|
||||
$assert(targetTopic, "targetTopic could not be found:" + targetTopicId + dmodel.getTopics().map(function (e) {
|
||||
return e.getId()
|
||||
}));
|
||||
|
||||
// Build relationship line ....
|
||||
var result = new mindplot.Relationship(sourceTopic, targetTopic, model);
|
||||
|
||||
result.addEvent('ontblur', function () {
|
||||
var topics = this.getModel().filterSelectedTopics();
|
||||
var rels = this.getModel().filterSelectedRelationships();
|
||||
|
||||
if (topics.length == 0 || rels.length == 0) {
|
||||
this.fireEvent('onblur');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
result.addEvent('ontfocus', function () {
|
||||
var topics = this.getModel().filterSelectedTopics();
|
||||
var rels = this.getModel().filterSelectedRelationships();
|
||||
|
||||
if (topics.length == 1 || rels.length == 1) {
|
||||
this.fireEvent('onfocus');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
// Append it to the workspace ...
|
||||
dmodel.addRelationship(result);
|
||||
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_removeTopic:function (node) {
|
||||
if (!node.isCentralTopic()) {
|
||||
var parent = node._parent;
|
||||
node.disconnect(this._workspace);
|
||||
|
||||
//remove children
|
||||
while (node.getChildren().length > 0) {
|
||||
this._removeTopic(node.getChildren()[0]);
|
||||
}
|
||||
|
||||
this._workspace.removeChild(node);
|
||||
this.getModel().removeTopic(node);
|
||||
|
||||
// Delete this node from the model...
|
||||
var model = node.getModel();
|
||||
model.deleteNode();
|
||||
|
||||
if ($defined(parent)) {
|
||||
this.goToNode(parent);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_resetEdition:function () {
|
||||
var screenManager = this._workspace.getScreenManager();
|
||||
screenManager.fireEvent("update");
|
||||
screenManager.fireEvent("mouseup");
|
||||
this._relPivot.dispose();
|
||||
},
|
||||
|
||||
deleteSelectedEntities:function () {
|
||||
// Is there some action in progress ?.
|
||||
this._resetEdition();
|
||||
|
||||
var topics = this.getModel().filterSelectedTopics();
|
||||
var relation = this.getModel().filterSelectedRelationships();
|
||||
if (topics.length <= 0 && relation.length <= 0) {
|
||||
// If there are more than one node selected,
|
||||
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
|
||||
return;
|
||||
} else if (topics.length == 1 && topics[0].isCentralTopic()) {
|
||||
$notify($msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED'));
|
||||
return;
|
||||
}
|
||||
|
||||
// If the central topic has been selected, I must filter ir
|
||||
var topicIds = topics.filter(function (topic) {
|
||||
return !topic.isCentralTopic();
|
||||
}).map(function (topic) {
|
||||
return topic.getId()
|
||||
});
|
||||
|
||||
|
||||
var relIds = relation.map(function (rel) {
|
||||
return rel.getId();
|
||||
});
|
||||
|
||||
// Finally delete the topics ...
|
||||
if (topicIds.length > 0 || relIds.length > 0) {
|
||||
this._actionDispatcher.deleteEntities(topicIds, relIds);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
changeFontFamily:function (font) {
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeFontFamilyToTopic(topicsIds, font);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
changeFontStyle:function () {
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeFontStyleToTopic(topicsIds);
|
||||
}
|
||||
},
|
||||
|
||||
changeFontColor:function (color) {
|
||||
$assert(color, "color can not be null");
|
||||
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeFontColorToTopic(topicsIds, color);
|
||||
}
|
||||
},
|
||||
|
||||
changeBackgroundColor:function (color) {
|
||||
|
||||
var validateFunc = function (topic) {
|
||||
return topic.getShapeType() != mindplot.model.TopicShape.LINE;
|
||||
};
|
||||
var validateError = 'Color can not be set to line topics.';
|
||||
|
||||
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeBackgroundColorToTopic(topicsIds, color);
|
||||
}
|
||||
},
|
||||
|
||||
changeBorderColor:function (color) {
|
||||
var validateFunc = function (topic) {
|
||||
return topic.getShapeType() != mindplot.model.TopicShape.LINE;
|
||||
};
|
||||
var validateError = 'Color can not be set to line topics.';
|
||||
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeBorderColorToTopic(topicsIds, color);
|
||||
}
|
||||
},
|
||||
|
||||
changeFontSize:function (size) {
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeFontSizeToTopic(topicsIds, size);
|
||||
}
|
||||
},
|
||||
|
||||
changeTopicShape:function (shape) {
|
||||
var validateFunc = function (topic) {
|
||||
return !(topic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE && shape == mindplot.model.TopicShape.LINE)
|
||||
};
|
||||
|
||||
var validateError = 'Central Topic shape can not be changed to line figure.';
|
||||
var topicsIds = this.getModel().filterTopicsIds(validateFunc, validateError);
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeShapeTypeToTopic(topicsIds, shape);
|
||||
}
|
||||
},
|
||||
|
||||
changeFontWeight:function () {
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.changeFontWeightToTopic(topicsIds);
|
||||
}
|
||||
},
|
||||
|
||||
addIconType:function (iconType) {
|
||||
var topicsIds = this.getModel().filterTopicsIds();
|
||||
if (topicsIds.length > 0) {
|
||||
this._actionDispatcher.addFeatureToTopic(topicsIds[0], mindplot.TopicFeature.Icon.id, {id:iconType});
|
||||
}
|
||||
},
|
||||
|
||||
addLink:function () {
|
||||
var model = this.getModel();
|
||||
var topic = model.selectedTopic();
|
||||
if (topic) {
|
||||
topic.showLinkEditor();
|
||||
}
|
||||
},
|
||||
|
||||
addNote:function () {
|
||||
var model = this.getModel();
|
||||
var topic = model.selectedTopic();
|
||||
if (topic) {
|
||||
topic.showNoteEditor();
|
||||
}
|
||||
},
|
||||
|
||||
goToNode:function (node) {
|
||||
node.setOnFocus(true);
|
||||
this.onObjectFocusEvent(node);
|
||||
},
|
||||
|
||||
getWorkSpace:function () {
|
||||
return this._workspace;
|
||||
}
|
||||
}
|
||||
);
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DesignerActionRunner = new Class({
|
||||
initialize:function (commandContext, notifier) {
|
||||
$assert(commandContext, "commandContext can not be null");
|
||||
|
||||
this._undoManager = new mindplot.DesignerUndoManager();
|
||||
this._context = commandContext;
|
||||
this._notifier = notifier;
|
||||
},
|
||||
|
||||
execute:function (command) {
|
||||
$assert(command, "command can not be null");
|
||||
command.execute(this._context);
|
||||
this._undoManager.enqueue(command);
|
||||
this.fireChangeEvent();
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
},
|
||||
|
||||
undo:function () {
|
||||
this._undoManager.execUndo(this._context);
|
||||
this.fireChangeEvent();
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
},
|
||||
|
||||
redo:function () {
|
||||
this._undoManager.execRedo(this._context);
|
||||
this.fireChangeEvent();
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
|
||||
|
||||
},
|
||||
|
||||
fireChangeEvent:function () {
|
||||
var event = this._undoManager.buildEvent();
|
||||
this._notifier.fireEvent("modelUpdate", event);
|
||||
}
|
||||
});
|
|
@ -1,490 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DesignerKeyboard = new Class({
|
||||
Extends:Keyboard,
|
||||
Static:{
|
||||
register:function (designer) {
|
||||
this._instance = new mindplot.DesignerKeyboard(designer);
|
||||
this._instance.activate();
|
||||
},
|
||||
|
||||
getInstance:function () {
|
||||
return this._instance;
|
||||
}
|
||||
},
|
||||
|
||||
initialize:function (designer) {
|
||||
$assert(designer, "designer can not be null");
|
||||
this.parent({defaultEventType:'keydown'});
|
||||
this._registerEvents(designer);
|
||||
},
|
||||
|
||||
|
||||
_registerEvents:function (designer) {
|
||||
|
||||
// Try with the keyboard ..
|
||||
var model = designer.getModel();
|
||||
var keyboardEvents = {
|
||||
'backspace':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.deleteSelectedEntities();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'space':function () {
|
||||
designer.shrinkSelectedBranch();
|
||||
}.bind(this),
|
||||
|
||||
'f2':function () {
|
||||
var node = model.selectedTopic();
|
||||
if (node) {
|
||||
node.showTextEditor();
|
||||
}
|
||||
}.bind(this),
|
||||
|
||||
'delete':function (event) {
|
||||
designer.deleteSelectedEntities();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this),
|
||||
|
||||
'enter':function () {
|
||||
designer.createSiblingForSelectedNode();
|
||||
}.bind(this),
|
||||
|
||||
'insert':function (event) {
|
||||
designer.createChildForSelectedNode();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this),
|
||||
|
||||
'tab':function (event) {
|
||||
designer.createChildForSelectedNode();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this),
|
||||
|
||||
'-':function () { // "-" is a insert on several Browsers. Don't ask why ...
|
||||
designer.createChildForSelectedNode();
|
||||
}.bind(this),
|
||||
|
||||
'meta+enter':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
designer.createChildForSelectedNode();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+z':function (event) {
|
||||
event.preventDefault(event);
|
||||
event.stopPropagation();
|
||||
designer.undo();
|
||||
}.bind(this),
|
||||
|
||||
'meta+z':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.undo();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+c':function (event) {
|
||||
event.preventDefault(event);
|
||||
event.stopPropagation();
|
||||
designer.copyToClipboard();
|
||||
}.bind(this),
|
||||
|
||||
'meta+c':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.copyToClipboard();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+v':function (event) {
|
||||
event.preventDefault(event);
|
||||
event.stopPropagation();
|
||||
|
||||
designer.pasteClipboard();
|
||||
}.bind(this),
|
||||
|
||||
'meta+v':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.pasteClipboard();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+z+shift':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
}.bind(this),
|
||||
|
||||
'meta+z+shift':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+y':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'meta+y':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.redo();
|
||||
|
||||
}.bind(this),
|
||||
|
||||
'ctrl+a':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.selectAll();
|
||||
},
|
||||
|
||||
'ctrl+b':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontWeight();
|
||||
},
|
||||
|
||||
'meta+b':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontWeight();
|
||||
},
|
||||
|
||||
'ctrl+s':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
$('save').fireEvent('click');
|
||||
},
|
||||
|
||||
'meta+s':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
$('save').fireEvent('click');
|
||||
},
|
||||
|
||||
'ctrl+i':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontStyle();
|
||||
},
|
||||
|
||||
'meta+i':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.changeFontStyle();
|
||||
},
|
||||
|
||||
'meta+shift+a':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.deselectAll();
|
||||
},
|
||||
|
||||
'ctrl+shift+a':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.deselectAll();
|
||||
},
|
||||
|
||||
'meta+a':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.selectAll();
|
||||
},
|
||||
|
||||
'meta+=':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.zoomIn();
|
||||
},
|
||||
|
||||
'meta+-':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.zoomOut();
|
||||
},
|
||||
|
||||
'ctrl+=':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.zoomIn();
|
||||
},
|
||||
|
||||
'ctrl+-':function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
designer.zoomOut();
|
||||
},
|
||||
|
||||
|
||||
'right':function (event) {
|
||||
var node = model.selectedTopic();
|
||||
if (node) {
|
||||
if (node.isCentralTopic()) {
|
||||
this._goToSideChild(designer, node, 'RIGHT');
|
||||
}
|
||||
else {
|
||||
if (node.getPosition().x < 0) {
|
||||
this._goToParent(designer, node);
|
||||
}
|
||||
else if (!node.areChildrenShrunken()) {
|
||||
this._goToChild(designer, node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var centralTopic = model.getCentralTopic();
|
||||
this._goToNode(designer, centralTopic);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this),
|
||||
|
||||
'left':function (event) {
|
||||
var node = model.selectedTopic();
|
||||
if (node) {
|
||||
if (node.isCentralTopic()) {
|
||||
this._goToSideChild(designer, node, 'LEFT');
|
||||
}
|
||||
else {
|
||||
if (node.getPosition().x > 0) {
|
||||
this._goToParent(designer, node);
|
||||
}
|
||||
else if (!node.areChildrenShrunken()) {
|
||||
this._goToChild(designer, node);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var centralTopic = model.getCentralTopic();
|
||||
this._goToNode(designer, centralTopic);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this),
|
||||
|
||||
'up':function (event) {
|
||||
var node = model.selectedTopic();
|
||||
if (node) {
|
||||
if (!node.isCentralTopic()) {
|
||||
this._goToBrother(designer, node, 'UP');
|
||||
}
|
||||
} else {
|
||||
var centralTopic = model.getCentralTopic();
|
||||
this._goToNode(designer, centralTopic);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this),
|
||||
|
||||
'down':function (event) {
|
||||
var node = model.selectedTopic();
|
||||
if (node) {
|
||||
if (!node.isCentralTopic()) {
|
||||
this._goToBrother(designer, node, 'DOWN');
|
||||
}
|
||||
} else {
|
||||
var centralTopic = model.getCentralTopic();
|
||||
this._goToNode(designer, centralTopic);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}.bind(this)
|
||||
};
|
||||
this.addEvents(keyboardEvents);
|
||||
|
||||
var regex = /^(?:shift|control|ctrl|alt|meta)$/;
|
||||
var modifiers = ['shift', 'control', 'alt', 'meta'];
|
||||
|
||||
var excludes = ['esc', 'capslock', 'tab', 'f1', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'backspace', 'down', 'up', 'left', 'right', 'control'];
|
||||
if (!Browser.Platform.mac) {
|
||||
// This is to avoid enter on edition mode in the node when alt+tab is pressed.
|
||||
excludes.push("alt");
|
||||
}
|
||||
|
||||
$(document).addEvent('keydown', function (event) {
|
||||
|
||||
// Convert key to mootools keyboard event format...
|
||||
var keys = [];
|
||||
modifiers.each(function (mod) {
|
||||
if (event[mod]) keys.push(mod);
|
||||
});
|
||||
if (!regex.test(event.key))
|
||||
keys.push(event.key);
|
||||
var key = keys.join('+');
|
||||
|
||||
// Is the pressed key one of the already registered in the keyboard ?
|
||||
var isRegistered = false;
|
||||
for (var eKey in keyboardEvents) {
|
||||
if (eKey == key) {
|
||||
isRegistered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If it's not registered, let's
|
||||
if (!isRegistered && !excludes.contains(key) && !excludes.contains(event.key) && !event.meta && !event.control) {
|
||||
var nodes = designer.getModel().filterSelectedTopics();
|
||||
if (nodes.length > 0) {
|
||||
|
||||
// If a modifier is press, the key selected must be ignored.
|
||||
var pressKey = event.key;
|
||||
if (modifiers.contains(event.key)) {
|
||||
pressKey = "";
|
||||
}
|
||||
|
||||
nodes[0].showTextEditor(pressKey);
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
_goToBrother:function (designer, node, direction) {
|
||||
var parent = node.getParent();
|
||||
if (parent) {
|
||||
var brothers = parent.getChildren();
|
||||
|
||||
var target = node;
|
||||
var y = node.getPosition().y;
|
||||
var x = node.getPosition().x;
|
||||
var dist = null;
|
||||
for (var i = 0; i < brothers.length; i++) {
|
||||
var sameSide = (x * brothers[i].getPosition().x) >= 0;
|
||||
if (brothers[i] != node && sameSide) {
|
||||
var brother = brothers[i];
|
||||
var brotherY = brother.getPosition().y;
|
||||
if (direction == "DOWN" && brotherY > y) {
|
||||
var distancia = y - brotherY;
|
||||
if (distancia < 0) {
|
||||
distancia = distancia * (-1);
|
||||
}
|
||||
if (dist == null || dist > distancia) {
|
||||
dist = distancia;
|
||||
target = brothers[i];
|
||||
}
|
||||
}
|
||||
else if (direction == "UP" && brotherY < y) {
|
||||
var distance = y - brotherY;
|
||||
if (distance < 0) {
|
||||
distance = distance * (-1);
|
||||
}
|
||||
if (dist == null || dist > distance) {
|
||||
dist = distance;
|
||||
target = brothers[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this._goToNode(designer, target);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
_goToSideChild:function (designer, node, side) {
|
||||
var children = node.getChildren();
|
||||
if (children.length > 0) {
|
||||
var target = children[0];
|
||||
var top = null;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
var childY = child.getPosition().y;
|
||||
if (side == 'LEFT' && child.getPosition().x < 0) {
|
||||
if (top == null || childY < top) {
|
||||
target = child;
|
||||
top = childY;
|
||||
}
|
||||
}
|
||||
if (side == 'RIGHT' && child.getPosition().x > 0) {
|
||||
if (top == null || childY < top) {
|
||||
target = child;
|
||||
top = childY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._goToNode(designer, target);
|
||||
}
|
||||
},
|
||||
|
||||
_goToParent:function (designer, node) {
|
||||
var parent = node.getParent();
|
||||
if (parent) {
|
||||
this._goToNode(designer, parent);
|
||||
}
|
||||
},
|
||||
|
||||
_goToChild:function (designer, node) {
|
||||
var children = node.getChildren();
|
||||
if (children.length > 0) {
|
||||
var target = children[0];
|
||||
var top = target.getPosition().y;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
if (child.getPosition().y < top) {
|
||||
top = child.getPosition().y;
|
||||
target = child;
|
||||
}
|
||||
}
|
||||
this._goToNode(designer, target);
|
||||
}
|
||||
},
|
||||
|
||||
_goToNode:function (designer, node) {
|
||||
// First deselect all the nodes ...
|
||||
designer.deselectAll();
|
||||
|
||||
// Give focus to the selected node....
|
||||
node.setOnFocus(true);
|
||||
}
|
||||
|
||||
});
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DesignerModel = new Class({
|
||||
Implements:[Events],
|
||||
initialize:function (options) {
|
||||
this._zoom = options.zoom;
|
||||
this._topics = [];
|
||||
this._relationships = [];
|
||||
},
|
||||
|
||||
getZoom:function () {
|
||||
return this._zoom;
|
||||
},
|
||||
|
||||
setZoom:function (zoom) {
|
||||
this._zoom = zoom;
|
||||
},
|
||||
|
||||
getTopics:function () {
|
||||
return this._topics;
|
||||
},
|
||||
|
||||
getRelationships:function () {
|
||||
return this._relationships;
|
||||
},
|
||||
|
||||
getCentralTopic:function () {
|
||||
var topics = this.getTopics();
|
||||
return topics[0];
|
||||
},
|
||||
|
||||
filterSelectedTopics:function () {
|
||||
var result = [];
|
||||
for (var i = 0; i < this._topics.length; i++) {
|
||||
if (this._topics[i].isOnFocus()) {
|
||||
result.push(this._topics[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
filterSelectedRelationships:function () {
|
||||
var result = [];
|
||||
for (var i = 0; i < this._relationships.length; i++) {
|
||||
if (this._relationships[i].isOnFocus()) {
|
||||
result.push(this._relationships[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getEntities:function () {
|
||||
var result = [].append(this._topics);
|
||||
result.append(this._relationships);
|
||||
return result;
|
||||
},
|
||||
|
||||
removeTopic:function (topic) {
|
||||
$assert(topic, "topic can not be null");
|
||||
this._topics.erase(topic);
|
||||
},
|
||||
|
||||
removeRelationship:function (rel) {
|
||||
$assert(rel, "rel can not be null");
|
||||
this._relationships.erase(rel);
|
||||
},
|
||||
|
||||
addTopic:function (topic) {
|
||||
$assert(topic, "topic can not be null");
|
||||
$assert(typeof topic.getId() == "number", "id is not a number:" + topic.getId());
|
||||
this._topics.push(topic);
|
||||
},
|
||||
|
||||
addRelationship:function (rel) {
|
||||
$assert(rel, "rel can not be null");
|
||||
this._relationships.push(rel);
|
||||
},
|
||||
|
||||
filterTopicsIds:function (validate, errorMsg) {
|
||||
var result = [];
|
||||
var topics = this.filterSelectedTopics();
|
||||
|
||||
|
||||
var isValid = true;
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
var selectedNode = topics[i];
|
||||
if ($defined(validate)) {
|
||||
isValid = validate(selectedNode);
|
||||
}
|
||||
|
||||
// Add node only if it's valid.
|
||||
if (isValid) {
|
||||
result.push(selectedNode.getId());
|
||||
} else {
|
||||
$notify(errorMsg);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
selectedTopic:function () {
|
||||
var topics = this.filterSelectedTopics();
|
||||
return (topics.length > 0) ? topics[0] : null;
|
||||
},
|
||||
|
||||
findTopicById:function (id) {
|
||||
var result = null;
|
||||
for (var i = 0; i < this._topics.length; i++) {
|
||||
var topic = this._topics[i];
|
||||
if (topic.getId() == id) {
|
||||
result = topic;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
});
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DesignerUndoManager = new Class({
|
||||
initialize: function(fireChange) {
|
||||
this._undoQueue = [];
|
||||
this._redoQueue = [];
|
||||
this._baseId = 0;
|
||||
},
|
||||
|
||||
enqueue:function(command) {
|
||||
$assert(command, "Command can not be null");
|
||||
var length = this._undoQueue.length;
|
||||
if (command.discardDuplicated && length > 0) {
|
||||
// Skip duplicated events ...
|
||||
var lastItem = this._undoQueue[length - 1];
|
||||
if (lastItem.discardDuplicated != command.discardDuplicated) {
|
||||
this._undoQueue.push(command);
|
||||
}
|
||||
} else {
|
||||
this._undoQueue.push(command);
|
||||
}
|
||||
this._redoQueue = [];
|
||||
},
|
||||
|
||||
execUndo: function(commandContext) {
|
||||
if (this._undoQueue.length > 0) {
|
||||
var command = this._undoQueue.pop();
|
||||
this._redoQueue.push(command);
|
||||
|
||||
command.undoExecute(commandContext);
|
||||
}
|
||||
},
|
||||
|
||||
execRedo: function(commandContext) {
|
||||
if (this._redoQueue.length > 0) {
|
||||
var command = this._redoQueue.pop();
|
||||
this._undoQueue.push(command);
|
||||
command.execute(commandContext);
|
||||
}
|
||||
},
|
||||
|
||||
buildEvent: function() {
|
||||
return {undoSteps: this._undoQueue.length, redoSteps:this._redoQueue.length};
|
||||
},
|
||||
|
||||
markAsChangeBase: function() {
|
||||
var undoLength = this._undoQueue.length;
|
||||
if (undoLength > 0) {
|
||||
var command = this._undoQueue[undoLength - 1];
|
||||
this._baseId = command.getId();
|
||||
} else {
|
||||
this._baseId = 0;
|
||||
}
|
||||
},
|
||||
|
||||
hasBeenChanged: function() {
|
||||
var result = true;
|
||||
var undoLength= this._undoQueue.length;
|
||||
if (undoLength == 0 && this._baseId == 0) {
|
||||
result = false;
|
||||
} else if (undoLength > 0) {
|
||||
var command = this._undoQueue[undoLength - 1];
|
||||
result = (this._baseId != command.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DragConnector = new Class({
|
||||
initialize:function (designerModel, workspace) {
|
||||
$assert(designerModel, 'designerModel can not be null');
|
||||
$assert(workspace, 'workspace can not be null');
|
||||
|
||||
// this._layoutManager = layoutManager;
|
||||
this._designerModel = designerModel;
|
||||
this._workspace = workspace;
|
||||
},
|
||||
|
||||
checkConnection:function (dragTopic) {
|
||||
var topics = this._designerModel.getTopics();
|
||||
|
||||
// Must be disconnected from their current connection ?.
|
||||
var candidates = this._searchConnectionCandidates(dragTopic);
|
||||
var currentConnection = dragTopic.getConnectedToTopic();
|
||||
|
||||
|
||||
if (currentConnection && (candidates.length == 0 || candidates[0] != currentConnection)) {
|
||||
dragTopic.disconnect(this._workspace);
|
||||
}
|
||||
|
||||
// Finally, connect nodes ...
|
||||
if (!dragTopic.isConnected() && candidates.length > 0) {
|
||||
dragTopic.connectTo(candidates[0]);
|
||||
}
|
||||
},
|
||||
|
||||
_searchConnectionCandidates:function (dragTopic) {
|
||||
var topics = this._designerModel.getTopics();
|
||||
var draggedNode = dragTopic.getDraggedTopic();
|
||||
|
||||
// Drag node connects to the border ...
|
||||
var dragTopicWidth = dragTopic.getSize ? dragTopic.getSize().width : 0; // Hack...
|
||||
var xMouseGap = dragTopic.getPosition().x > 0 ? 0 : dragTopicWidth;
|
||||
var sPos = {x:dragTopic.getPosition().x - xMouseGap, y:dragTopic.getPosition().y};
|
||||
|
||||
// Perform a initial filter to discard topics:
|
||||
// - Exclude dragged topic
|
||||
// - Exclude dragTopic pivot
|
||||
// - Nodes that are collapsed
|
||||
// - It's not part of the branch dragged itself
|
||||
topics = topics.filter(function (topic) {
|
||||
var result = draggedNode != topic;
|
||||
result = result && topic != draggedNode;
|
||||
result = result && !topic.areChildrenShrunken() && !topic.isCollapsed();
|
||||
result = result && !draggedNode.isChildTopic(topic);
|
||||
return result;
|
||||
});
|
||||
|
||||
// Filter all the nodes that are outside the vertical boundary:
|
||||
// * The node is to out of the x scope
|
||||
// * The x distance greater the vertical tolerated distance
|
||||
topics = topics.filter(function (topic) {
|
||||
var tpos = topic.getPosition();
|
||||
// Center topic has different alignment than the rest of the nodes. That's why i need to divide it by two...
|
||||
var txborder = tpos.x + (topic.getSize().width / 2) * Math.sign(sPos.x);
|
||||
var distance = (sPos.x - txborder) * Math.sign(sPos.x);
|
||||
return distance > 0 && (distance < mindplot.DragConnector.MAX_VERTICAL_CONNECTION_TOLERANCE);
|
||||
|
||||
});
|
||||
|
||||
// Assign a priority based on the distance:
|
||||
// - Alignment with the targetNode
|
||||
// - Vertical distance
|
||||
// - Horizontal proximity
|
||||
// - It's already connected.
|
||||
var currentConnection = dragTopic.getConnectedToTopic();
|
||||
topics = topics.sort(function (a, b) {
|
||||
var aPos = a.getPosition();
|
||||
var bPos = b.getPosition();
|
||||
|
||||
var av = this._isVerticallyAligned(a.getSize(), aPos, sPos);
|
||||
var bv = this._isVerticallyAligned(b.getSize(), bPos, sPos);
|
||||
return this._proximityWeight(av, a, sPos, currentConnection) - this._proximityWeight(bv, b, sPos, currentConnection);
|
||||
|
||||
}.bind(this));
|
||||
return topics;
|
||||
},
|
||||
|
||||
_proximityWeight:function (isAligned, target, sPos, currentConnection) {
|
||||
var tPos = target.getPosition();
|
||||
return (isAligned ? 0 : 200 ) + Math.abs(tPos.x - sPos.x) + Math.abs(tPos.y - sPos.y) + (currentConnection == target ? 0 : 100);
|
||||
},
|
||||
|
||||
_isVerticallyAligned:function (targetSize, targetPosition, sourcePosition) {
|
||||
|
||||
return Math.abs(sourcePosition.y - targetPosition.y) < targetSize.height / 2;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.DragConnector.MAX_VERTICAL_CONNECTION_TOLERANCE = 80;
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DragManager = new Class({
|
||||
initialize:function(workspace, eventDispatcher) {
|
||||
this._workspace = workspace;
|
||||
this._designerModel = workspace;
|
||||
this._listeners = {};
|
||||
this._isDragInProcess = false;
|
||||
this._eventDispatcher = eventDispatcher;
|
||||
mindplot.DragTopic.init(this._workspace);
|
||||
},
|
||||
|
||||
add : function(node) {
|
||||
// Add behaviour ...
|
||||
var workspace = this._workspace;
|
||||
var screen = workspace.getScreenManager();
|
||||
var dragManager = this;
|
||||
|
||||
var mouseDownListener = function(event) {
|
||||
if (workspace.isWorkspaceEventsEnabled()) {
|
||||
// Disable double drag...
|
||||
workspace.enableWorkspaceEvents(false);
|
||||
|
||||
// Set initial position.
|
||||
var layoutManager = this._eventDispatcher.getLayoutManager();
|
||||
var dragNode = node.createDragNode(layoutManager);
|
||||
|
||||
// Register mouse move listener ...
|
||||
var mouseMoveListener = dragManager._buildMouseMoveListener(workspace, dragNode, dragManager);
|
||||
screen.addEvent('mousemove', mouseMoveListener);
|
||||
|
||||
// Register mouse up listeners ...
|
||||
var mouseUpListener = dragManager._buildMouseUpListener(workspace, node, dragNode, dragManager);
|
||||
screen.addEvent('mouseup', mouseUpListener);
|
||||
|
||||
// Change cursor.
|
||||
window.document.body.style.cursor = 'move';
|
||||
}
|
||||
}.bind(this);
|
||||
node.addEvent('mousedown', mouseDownListener);
|
||||
},
|
||||
|
||||
remove : function(node) {
|
||||
var nodes = this._topics;
|
||||
var contained = false;
|
||||
var index = -1;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i] == node) {
|
||||
contained = true;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_buildMouseMoveListener : function(workspace, dragNode, dragManager) {
|
||||
var screen = workspace.getScreenManager();
|
||||
|
||||
var result = function(event) {
|
||||
|
||||
if (!this._isDragInProcess) {
|
||||
// Execute Listeners ..
|
||||
var startDragListener = dragManager._listeners['startdragging'];
|
||||
startDragListener(event, dragNode);
|
||||
|
||||
// Add shadow node to the workspace.
|
||||
workspace.appendChild(dragNode);
|
||||
|
||||
this._isDragInProcess = true;
|
||||
}
|
||||
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
dragNode.setPosition(pos.x, pos.y);
|
||||
|
||||
// Call mouse move listeners ...
|
||||
var dragListener = dragManager._listeners['dragging'];
|
||||
if ($defined(dragListener)) {
|
||||
dragListener(event, dragNode);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}.bind(this);
|
||||
dragManager._mouseMoveListener = result;
|
||||
return result;
|
||||
},
|
||||
|
||||
_buildMouseUpListener : function(workspace, node, dragNode, dragManager) {
|
||||
var screen = workspace.getScreenManager();
|
||||
var result = function(event) {
|
||||
$assert(dragNode.isDragTopic, 'dragNode must be an DragTopic');
|
||||
|
||||
// Remove all the events.
|
||||
screen.removeEvent('mousemove', dragManager._mouseMoveListener);
|
||||
screen.removeEvent('mouseup', dragManager._mouseUpListener);
|
||||
|
||||
// Help GC
|
||||
dragManager._mouseMoveListener = null;
|
||||
dragManager._mouseUpListener = null;
|
||||
|
||||
workspace.enableWorkspaceEvents(true);
|
||||
// Change the cursor to the default.
|
||||
window.document.body.style.cursor = 'default';
|
||||
|
||||
if (this._isDragInProcess) {
|
||||
|
||||
// Execute Listeners only if the node has been moved.
|
||||
var endDragListener = dragManager._listeners['enddragging'];
|
||||
endDragListener(event, dragNode);
|
||||
|
||||
// Remove drag node from the workspace.
|
||||
dragNode.removeFromWorkspace(workspace);
|
||||
|
||||
this._isDragInProcess = false;
|
||||
}
|
||||
|
||||
|
||||
}.bind(this);
|
||||
dragManager._mouseUpListener = result;
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* type:
|
||||
* - startdragging.
|
||||
* - dragging
|
||||
* - enddragging
|
||||
*/
|
||||
addEvent : function(type, listener) {
|
||||
this._listeners[type] = listener;
|
||||
}
|
||||
});
|
|
@ -1,228 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DragPivot = new Class({
|
||||
initialize:function() {
|
||||
this._position = new core.Point();
|
||||
this._size = mindplot.DragTopic.PIVOT_SIZE;
|
||||
|
||||
this._straightLine = this._buildStraightLine();
|
||||
this._curvedLine = this._buildCurvedLine();
|
||||
this._dragPivot = this._buildRect();
|
||||
this._connectRect = this._buildRect();
|
||||
this._targetTopic = null;
|
||||
this._isVisible = false;
|
||||
},
|
||||
|
||||
isVisible:function() {
|
||||
return this._isVisible;
|
||||
},
|
||||
|
||||
getTargetTopic : function() {
|
||||
return this._targetTopic;
|
||||
},
|
||||
|
||||
_buildStraightLine : function() {
|
||||
var line = new web2d.CurvedLine();
|
||||
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
line.setStroke(1, 'solid', '#CC0033');
|
||||
line.setOpacity(0.4);
|
||||
line.setVisibility(false);
|
||||
return line;
|
||||
},
|
||||
|
||||
_buildCurvedLine : function() {
|
||||
var line = new web2d.CurvedLine();
|
||||
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
line.setStroke(1, 'solid', '#CC0033');
|
||||
line.setOpacity(0.4);
|
||||
line.setVisibility(false);
|
||||
return line;
|
||||
},
|
||||
|
||||
|
||||
_redrawLine : function() {
|
||||
// Update line position.
|
||||
$assert(this.getTargetTopic(), 'Illegal invocation. Target node can not be null');
|
||||
|
||||
var pivotRect = this._getPivotRect();
|
||||
|
||||
// Pivot position has not changed. In this case, position change is not required.
|
||||
var targetTopic = this.getTargetTopic();
|
||||
var position = this._position;
|
||||
|
||||
// Calculate pivot connection point ...
|
||||
var size = this._size;
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
var line = this._getConnectionLine();
|
||||
|
||||
// Update Line position.
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
|
||||
var pivotPoint = mindplot.util.Shape.calculateRectConnectionPoint(position, size, isAtRight);
|
||||
line.setFrom(pivotPoint.x, pivotPoint.y);
|
||||
|
||||
// Update rect position
|
||||
var cx = position.x - (parseInt(size.width) / 2);
|
||||
var cy = position.y - (parseInt(size.height) / 2);
|
||||
pivotRect.setPosition(cx, cy);
|
||||
|
||||
// Make line visible only when the position has been already changed.
|
||||
// This solve several strange effects ;)
|
||||
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
|
||||
line.setTo(targetPoint.x, targetPoint.y);
|
||||
},
|
||||
|
||||
setPosition : function(point) {
|
||||
this._position = point;
|
||||
this._redrawLine();
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
_buildRect : function() {
|
||||
var size = this._size;
|
||||
var rectAttributes = {fillColor:'#CC0033',opacity:0.4,width:size.width,height:size.height,strokeColor:'#FF9933'};
|
||||
var rect = new web2d.Rect(0, rectAttributes);
|
||||
rect.setVisibility(false);
|
||||
return rect;
|
||||
},
|
||||
|
||||
_getPivotRect : function() {
|
||||
return this._dragPivot;
|
||||
},
|
||||
|
||||
getSize : function() {
|
||||
var elem2d = this._getPivotRect();
|
||||
return elem2d.getSize();
|
||||
},
|
||||
|
||||
setVisibility : function(value) {
|
||||
if (this.isVisible() != value) {
|
||||
|
||||
var pivotRect = this._getPivotRect();
|
||||
pivotRect.setVisibility(value);
|
||||
|
||||
var connectRect = this._connectRect;
|
||||
connectRect.setVisibility(value);
|
||||
|
||||
var line = this._getConnectionLine();
|
||||
if (line) {
|
||||
line.setVisibility(value);
|
||||
}
|
||||
this._isVisible = value;
|
||||
}
|
||||
},
|
||||
|
||||
// If the node is connected, validate that there is a line connecting both...
|
||||
_getConnectionLine : function() {
|
||||
var result = null;
|
||||
var parentTopic = this._targetTopic;
|
||||
if (parentTopic) {
|
||||
if (parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
result = this._straightLine;
|
||||
} else {
|
||||
result = this._curvedLine;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
addToWorkspace : function(workspace) {
|
||||
var pivotRect = this._getPivotRect();
|
||||
workspace.appendChild(pivotRect);
|
||||
|
||||
var connectToRect = this._connectRect;
|
||||
workspace.appendChild(connectToRect);
|
||||
|
||||
// Add a hidden straight line ...
|
||||
var straighLine = this._straightLine;
|
||||
straighLine.setVisibility(false);
|
||||
workspace.appendChild(straighLine);
|
||||
straighLine.moveToBack();
|
||||
|
||||
// Add a hidden curved line ...
|
||||
var curvedLine = this._curvedLine;
|
||||
curvedLine.setVisibility(false);
|
||||
workspace.appendChild(curvedLine);
|
||||
curvedLine.moveToBack();
|
||||
|
||||
// Add a connect rect ...
|
||||
var connectRect = this._connectRect;
|
||||
connectRect.setVisibility(false);
|
||||
workspace.appendChild(connectRect);
|
||||
connectRect.moveToBack();
|
||||
},
|
||||
|
||||
removeFromWorkspace : function(workspace) {
|
||||
var shape = this._getPivotRect();
|
||||
workspace.removeChild(shape);
|
||||
|
||||
var connectToRect = this._connectRect;
|
||||
workspace.removeChild(connectToRect);
|
||||
|
||||
if ($defined(this._straightLine)) {
|
||||
workspace.removeChild(this._straightLine);
|
||||
}
|
||||
|
||||
if ($defined(this._curvedLine)) {
|
||||
workspace.removeChild(this._curvedLine);
|
||||
}
|
||||
},
|
||||
|
||||
connectTo : function(targetTopic, position) {
|
||||
$assert(!this._outgoingLine, 'Could not connect an already connected node');
|
||||
$assert(targetTopic != this, 'Circular connection are not allowed');
|
||||
$assert(position, 'position can not be null');
|
||||
$assert(targetTopic, 'parent can not be null');
|
||||
|
||||
this._position = position;
|
||||
this._targetTopic = targetTopic;
|
||||
|
||||
// Connected to Rect ...
|
||||
var connectRect = this._connectRect;
|
||||
var targetSize = targetTopic.getSize();
|
||||
|
||||
// Add 4 pixel in order to keep create a rect bigger than the topic.
|
||||
var width = targetSize.width + 4;
|
||||
var height = targetSize.height + 4;
|
||||
|
||||
connectRect.setSize(width, height);
|
||||
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
var cx = Math.ceil(targetPosition.x - (width / 2));
|
||||
var cy = Math.ceil(targetPosition.y - (height / 2));
|
||||
connectRect.setPosition(cx, cy);
|
||||
|
||||
// Change elements position ...
|
||||
var pivotRect = this._getPivotRect();
|
||||
pivotRect.moveToFront();
|
||||
pivotRect.setPosition(position.x, position.y);
|
||||
|
||||
this._redrawLine();
|
||||
},
|
||||
|
||||
disconnect : function(workspace) {
|
||||
$assert(workspace, 'workspace can not be null.');
|
||||
$assert(this._targetTopic, 'There are not connected topic.');
|
||||
|
||||
this.setVisibility(false);
|
||||
this._targetTopic = null;
|
||||
}
|
||||
});
|
|
@ -1,215 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.DragTopic = new Class({
|
||||
initialize:function (dragShape, draggedNode, layoutManger) {
|
||||
$assert(dragShape, 'Rect can not be null.');
|
||||
$assert(draggedNode, 'draggedNode can not be null.');
|
||||
$assert(layoutManger, 'layoutManger can not be null.');
|
||||
|
||||
this._elem2d = dragShape;
|
||||
this._order = null;
|
||||
this._draggedNode = draggedNode;
|
||||
this._layoutManager = layoutManger;
|
||||
this._position = new core.Point();
|
||||
this._isInWorkspace = false;
|
||||
this._isFreeLayoutEnabled = false;
|
||||
},
|
||||
|
||||
setOrder:function (order) {
|
||||
this._order = order;
|
||||
},
|
||||
|
||||
setPosition:function (x, y) {
|
||||
// Update drag shadow position ....
|
||||
var position = {x:x, y:y};
|
||||
if (this.isFreeLayoutOn() && this.isConnected()) {
|
||||
var _layoutManager = this._layoutManager;
|
||||
var par = this.getConnectedToTopic();
|
||||
position = _layoutManager.predict(par.getId(), this._draggedNode.getId(), position, true).position;
|
||||
}
|
||||
this._position.setValue(position.x, position.y);
|
||||
|
||||
// Elements are positioned in the center.
|
||||
// All topic element must be positioned based on the innerShape.
|
||||
var draggedNode = this._draggedNode;
|
||||
var size = draggedNode.getSize();
|
||||
var cx = position.x - (position.x > 0 ? 0 : size.width);
|
||||
var cy = Math.ceil(position.y - (size.height / 2));
|
||||
this._elem2d.setPosition(cx, cy);
|
||||
|
||||
// In case is not free, pivot must be draw ...
|
||||
if (this.isConnected() && !this.isFreeLayoutOn()) {
|
||||
var parent = this.getConnectedToTopic();
|
||||
var predict = this._layoutManager.predict(parent.getId(), this._draggedNode.getId(), this.getPosition());
|
||||
if (this._order != predict.order) {
|
||||
var dragPivot = this._getDragPivot();
|
||||
var pivotPosition = predict.position;
|
||||
dragPivot.connectTo(parent, pivotPosition);
|
||||
this.setOrder(predict.order);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updateFreeLayout:function (event) {
|
||||
var isFreeEnabled = (event.meta && Browser.Platform.mac) || (event.control && !Browser.Platform.mac);
|
||||
if (this.isFreeLayoutOn() != isFreeEnabled) {
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setVisibility(!isFreeEnabled);
|
||||
this._isFreeLayoutEnabled = isFreeEnabled;
|
||||
}
|
||||
},
|
||||
|
||||
setVisibility:function (value) {
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setVisibility(value);
|
||||
},
|
||||
|
||||
isVisible:function () {
|
||||
var dragPivot = this._getDragPivot();
|
||||
return dragPivot.isVisible();
|
||||
},
|
||||
|
||||
getInnerShape:function () {
|
||||
return this._elem2d;
|
||||
},
|
||||
|
||||
disconnect:function (workspace) {
|
||||
// Clear connection line ...
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.disconnect(workspace);
|
||||
},
|
||||
|
||||
connectTo:function (parent) {
|
||||
$assert(parent, 'Parent connection node can not be null.');
|
||||
|
||||
// Where it should be connected ?
|
||||
var predict = designer._eventBussDispatcher._layoutManager.predict(parent.getId(), this._draggedNode.getId(), this.getPosition());
|
||||
|
||||
// Connect pivot ...
|
||||
var dragPivot = this._getDragPivot();
|
||||
var position = predict.position;
|
||||
dragPivot.connectTo(parent, position);
|
||||
dragPivot.setVisibility(true);
|
||||
|
||||
this.setOrder(predict.order);
|
||||
},
|
||||
|
||||
getDraggedTopic:function () {
|
||||
return this._draggedNode;
|
||||
},
|
||||
|
||||
removeFromWorkspace:function (workspace) {
|
||||
if (this._isInWorkspace) {
|
||||
// Remove drag shadow.
|
||||
workspace.removeChild(this._elem2d);
|
||||
|
||||
// Remove pivot shape. To improve performance it will not be removed. Only the visibility will be changed.
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.setVisibility(false);
|
||||
|
||||
this._isInWorkspace = false;
|
||||
}
|
||||
},
|
||||
|
||||
isInWorkspace:function () {
|
||||
return this._isInWorkspace;
|
||||
},
|
||||
|
||||
addToWorkspace:function (workspace) {
|
||||
if (!this._isInWorkspace) {
|
||||
workspace.appendChild(this._elem2d);
|
||||
var dragPivot = this._getDragPivot();
|
||||
dragPivot.addToWorkspace(workspace);
|
||||
this._isInWorkspace = true;
|
||||
}
|
||||
},
|
||||
|
||||
_getDragPivot:function () {
|
||||
return mindplot.DragTopic.__getDragPivot();
|
||||
},
|
||||
|
||||
getPosition:function () {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
isDragTopic:function () {
|
||||
return true;
|
||||
},
|
||||
|
||||
applyChanges:function (workspace) {
|
||||
$assert(workspace, 'workspace can not be null');
|
||||
|
||||
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
var draggedTopic = this.getDraggedTopic();
|
||||
var topicId = draggedTopic.getId();
|
||||
var position = this.getPosition();
|
||||
|
||||
if (!this.isFreeLayoutOn()) {
|
||||
var order = null;
|
||||
var parent = null;
|
||||
var isDragConnected = this.isConnected();
|
||||
if (isDragConnected) {
|
||||
var targetTopic = this.getConnectedToTopic();
|
||||
order = this._order;
|
||||
parent = targetTopic;
|
||||
}
|
||||
|
||||
// If the node is not connected, position based on the original drag topic position.
|
||||
actionDispatcher.dragTopic(topicId, position, order, parent);
|
||||
} else {
|
||||
actionDispatcher.moveTopic(topicId, position);
|
||||
}
|
||||
},
|
||||
|
||||
getConnectedToTopic:function () {
|
||||
var dragPivot = this._getDragPivot();
|
||||
return dragPivot.getTargetTopic();
|
||||
},
|
||||
|
||||
isConnected:function () {
|
||||
return this.getConnectedToTopic() != null;
|
||||
},
|
||||
|
||||
isFreeLayoutOn:function () {
|
||||
// return this._isFreeLayoutEnabled;
|
||||
// Disable free layout ...
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.DragTopic.PIVOT_SIZE = {width:50, height:6};
|
||||
|
||||
mindplot.DragTopic.init = function (workspace) {
|
||||
|
||||
$assert(workspace, "workspace can not be null");
|
||||
var pivot = mindplot.DragTopic.__getDragPivot();
|
||||
workspace.appendChild(pivot);
|
||||
};
|
||||
|
||||
mindplot.DragTopic.__getDragPivot = function () {
|
||||
var result = mindplot.DragTopic._dragPivot;
|
||||
if (!$defined(result)) {
|
||||
result = new mindplot.DragPivot();
|
||||
mindplot.DragTopic._dragPivot = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.Icon = new Class({
|
||||
initialize:function(url) {
|
||||
$assert(url, 'topic can not be null');
|
||||
this._image = new web2d.Image();
|
||||
this._image.setHref(url);
|
||||
this._image.setSize(mindplot.Icon.SIZE, mindplot.Icon.SIZE);
|
||||
},
|
||||
|
||||
getImage : function() {
|
||||
return this._image;
|
||||
},
|
||||
|
||||
setGroup : function(group) {
|
||||
this._group = group;
|
||||
},
|
||||
|
||||
getGroup : function() {
|
||||
return this._group;
|
||||
},
|
||||
|
||||
getSize : function() {
|
||||
return this._image.getSize();
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
return this._image.getPosition();
|
||||
},
|
||||
|
||||
addEvent : function(type, fnc) {
|
||||
this._image.addEvent(type, fnc);
|
||||
},
|
||||
|
||||
remove : function() {
|
||||
throw "Unsupported operation";
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.Icon.SIZE = 90;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.IconGroup = new Class({
|
||||
initialize:function (topicId, iconSize) {
|
||||
$assert($defined(topicId), "topicId can not be null");
|
||||
$assert($defined(iconSize), "iconSize can not be null");
|
||||
|
||||
this._icons = [];
|
||||
this._group = new web2d.Group({width:0, height:iconSize, x:0, y:0, coordSizeWidth:0, coordSizeHeight:100});
|
||||
this._removeTip = new mindplot.IconGroup.RemoveTip(this._group, topicId);
|
||||
this.seIconSize(iconSize, iconSize);
|
||||
|
||||
this._registerListeners();
|
||||
|
||||
},
|
||||
|
||||
setPosition:function (x, y) {
|
||||
this._group.setPosition(x, y);
|
||||
},
|
||||
|
||||
getPosition:function () {
|
||||
return this._group.getPosition();
|
||||
},
|
||||
|
||||
getNativeElement:function () {
|
||||
return this._group;
|
||||
},
|
||||
|
||||
getSize:function () {
|
||||
return this._group.getSize();
|
||||
},
|
||||
|
||||
seIconSize:function (width, height) {
|
||||
this._iconSize = {width:width, height:height};
|
||||
this._resize(this._icons.length);
|
||||
},
|
||||
|
||||
addIcon:function (icon, remove) {
|
||||
$defined(icon, "icon is not defined");
|
||||
|
||||
icon.setGroup(this);
|
||||
this._icons.push(icon);
|
||||
|
||||
// Adjust group and position ...
|
||||
this._resize(this._icons.length);
|
||||
this._positionIcon(icon, this._icons.length - 1);
|
||||
|
||||
var imageShape = icon.getImage();
|
||||
this._group.appendChild(imageShape);
|
||||
|
||||
// Register event for the group ..
|
||||
if (remove) {
|
||||
this._removeTip.decorate(this._topicId, icon);
|
||||
}
|
||||
},
|
||||
|
||||
_findIconFromModel:function (iconModel) {
|
||||
var result = null;
|
||||
this._icons.each(function (icon) {
|
||||
var elModel = icon.getModel();
|
||||
if (elModel.getId() == iconModel.getId()) {
|
||||
result = icon;
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (result == null) {
|
||||
throw new Error("Icon can no be found:" + iconModel.getId() + ", Icons:" + this._icons);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
removeIconByModel:function (featureModel) {
|
||||
$assert(featureModel, "featureModel can not be null");
|
||||
|
||||
var icon = this._findIconFromModel(featureModel);
|
||||
this._removeIcon(icon);
|
||||
},
|
||||
|
||||
_removeIcon:function (icon) {
|
||||
$assert(icon, "icon can not be null");
|
||||
|
||||
this._removeTip.close(0);
|
||||
this._group.removeChild(icon.getImage());
|
||||
|
||||
this._icons.erase(icon);
|
||||
this._resize(this._icons.length);
|
||||
|
||||
// Add all again ...
|
||||
this._icons.each(function (elem, i) {
|
||||
this._positionIcon(elem, i);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
moveToFront:function () {
|
||||
this._group.moveToFront();
|
||||
},
|
||||
|
||||
_registerListeners:function () {
|
||||
this._group.addEvent('click', function (event) {
|
||||
// Avoid node creation ...
|
||||
event.stopPropagation();
|
||||
|
||||
});
|
||||
|
||||
this._group.addEvent('dblclick', function (event) {
|
||||
event.stopPropagation();
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
_resize:function (iconsLength) {
|
||||
this._group.setSize(iconsLength * this._iconSize.width, this._iconSize.height);
|
||||
|
||||
var iconSize = mindplot.Icon.SIZE + (mindplot.IconGroup.ICON_PADDING * 2);
|
||||
this._group.setCoordSize(iconsLength * iconSize, iconSize);
|
||||
},
|
||||
|
||||
_positionIcon:function (icon, order) {
|
||||
|
||||
var iconSize = mindplot.Icon.SIZE + (mindplot.IconGroup.ICON_PADDING * 2);
|
||||
icon.getImage().setPosition(iconSize * order + mindplot.IconGroup.ICON_PADDING, mindplot.IconGroup.ICON_PADDING);
|
||||
}
|
||||
});
|
||||
mindplot.IconGroup.ICON_PADDING = 5;
|
||||
|
||||
mindplot.IconGroup.RemoveTip = new Class({
|
||||
initialize:function (container) {
|
||||
$assert(container, "group can not be null");
|
||||
this._fadeElem = container;
|
||||
},
|
||||
|
||||
|
||||
show:function (topicId, icon) {
|
||||
$assert(icon, 'icon can not be null');
|
||||
|
||||
// Nothing to do ...
|
||||
if (this._activeIcon != icon) {
|
||||
// If there is an active icon, close it first ...
|
||||
if (this._activeIcon) {
|
||||
this.close(0);
|
||||
}
|
||||
|
||||
// Now, let move the position the icon...
|
||||
var pos = icon.getPosition();
|
||||
|
||||
// Register events ...
|
||||
var widget = this._buildWeb2d();
|
||||
widget.addEvent('click', function () {
|
||||
icon.remove();
|
||||
});
|
||||
|
||||
widget.addEvent('mouseover', function () {
|
||||
this.show(topicId, icon);
|
||||
}.bind(this));
|
||||
|
||||
widget.addEvent('mouseout', function () {
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
|
||||
widget.setPosition(pos.x + 80, pos.y - 50);
|
||||
this._fadeElem.appendChild(widget);
|
||||
|
||||
// Setup current element ...
|
||||
this._activeIcon = icon;
|
||||
this._widget = widget;
|
||||
|
||||
} else {
|
||||
clearTimeout(this._closeTimeoutId);
|
||||
}
|
||||
},
|
||||
|
||||
hide:function () {
|
||||
this.close(200);
|
||||
},
|
||||
|
||||
close:function (delay) {
|
||||
|
||||
// This is not ok, trying to close the same dialog twice ?
|
||||
if (this._closeTimeoutId) {
|
||||
clearTimeout(this._closeTimeoutId)
|
||||
}
|
||||
|
||||
if (this._activeIcon) {
|
||||
var widget = this._widget;
|
||||
var close = function () {
|
||||
|
||||
this._activeIcon = null;
|
||||
this._fadeElem.removeChild(widget);
|
||||
this._widget = null;
|
||||
|
||||
this._closeTimeoutId = null;
|
||||
|
||||
}.bind(this);
|
||||
|
||||
if (!$defined(delay) || delay == 0) {
|
||||
close();
|
||||
}
|
||||
else {
|
||||
this._closeTimeoutId = close.delay(delay);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_buildWeb2d:function () {
|
||||
var result = new web2d.Group({
|
||||
width:10,
|
||||
height:10,
|
||||
x:0,
|
||||
y:0,
|
||||
coordSizeWidth:10,
|
||||
coordSizeHeight:10
|
||||
});
|
||||
|
||||
var outerRect = new web2d.Rect(0, {
|
||||
x:0,
|
||||
y:0,
|
||||
width:10,
|
||||
height:10,
|
||||
stroke:'0',
|
||||
fillColor:'black'
|
||||
});
|
||||
result.appendChild(outerRect);
|
||||
outerRect.setCursor('pointer');
|
||||
|
||||
var innerRect = new web2d.Rect(0, {
|
||||
x:1,
|
||||
y:1,
|
||||
width:8,
|
||||
height:8,
|
||||
stroke:'1 solid white',
|
||||
fillColor:'gray'
|
||||
});
|
||||
result.appendChild(innerRect);
|
||||
|
||||
var line = new web2d.Line({stroke:'1 solid white'});
|
||||
line.setFrom(1, 1);
|
||||
line.setTo(9, 9);
|
||||
result.appendChild(line);
|
||||
|
||||
var line2 = new web2d.Line({stroke:'1 solid white'});
|
||||
line2.setFrom(1, 9);
|
||||
line2.setTo(9, 1);
|
||||
result.appendChild(line2);
|
||||
|
||||
// Some events ...
|
||||
result.addEvent('mouseover', function () {
|
||||
innerRect.setFill('#CC0033');
|
||||
});
|
||||
result.addEvent('mouseout', function () {
|
||||
innerRect.setFill('gray');
|
||||
});
|
||||
|
||||
result.setSize(50, 50);
|
||||
return result;
|
||||
},
|
||||
|
||||
decorate:function (topicId, icon) {
|
||||
|
||||
if (!icon.__remove) {
|
||||
icon.addEvent('mouseover', function () {
|
||||
this.show(topicId, icon);
|
||||
}.bind(this));
|
||||
|
||||
icon.addEvent('mouseout', function () {
|
||||
this.hide();
|
||||
}.bind(this));
|
||||
icon.__remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ImageIcon = new Class({
|
||||
Extends:mindplot.Icon,
|
||||
initialize:function (topic, iconModel, readOnly) {
|
||||
$assert(iconModel, 'iconModel can not be null');
|
||||
$assert(topic, 'topic can not be null');
|
||||
|
||||
this._topicId = topic.getId();
|
||||
this._featureModel = iconModel;
|
||||
|
||||
// Build graph image representation ...
|
||||
var iconType = iconModel.getIconType();
|
||||
var imgUrl = this._getImageUrl(iconType);
|
||||
this.parent(imgUrl);
|
||||
|
||||
if (!readOnly) {
|
||||
|
||||
//Icon
|
||||
var image = this.getImage();
|
||||
image.addEvent('click', function () {
|
||||
|
||||
var iconType = iconModel.getIconType();
|
||||
var newIconType = this._getNextFamilyIconId(iconType);
|
||||
iconModel.setIconType(newIconType);
|
||||
|
||||
var imgUrl = this._getImageUrl(newIconType);
|
||||
this._image.setHref(imgUrl);
|
||||
|
||||
}.bind(this));
|
||||
this._image.setCursor('pointer');
|
||||
}
|
||||
},
|
||||
|
||||
_getImageUrl:function (iconId) {
|
||||
return "icons/" + iconId + ".png";
|
||||
},
|
||||
|
||||
getModel:function () {
|
||||
return this._featureModel;
|
||||
},
|
||||
|
||||
_getNextFamilyIconId:function (iconId) {
|
||||
|
||||
var familyIcons = this._getFamilyIcons(iconId);
|
||||
$assert(familyIcons != null, "Family Icon not found!");
|
||||
|
||||
var result = null;
|
||||
for (var i = 0; i < familyIcons.length && result == null; i++) {
|
||||
if (familyIcons[i] == iconId) {
|
||||
//Is last one?
|
||||
if (i == (familyIcons.length - 1)) {
|
||||
result = familyIcons[0];
|
||||
} else {
|
||||
result = familyIcons[i + 1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_getFamilyIcons:function (iconId) {
|
||||
$assert(iconId != null, "id must not be null");
|
||||
$assert(iconId.indexOf("_") != -1, "Invalid icon id (it must contain '_')");
|
||||
|
||||
var result = null;
|
||||
for (var i = 0; i < mindplot.ImageIcon.prototype.ICON_FAMILIES.length; i++) {
|
||||
var family = mindplot.ImageIcon.prototype.ICON_FAMILIES[i];
|
||||
var iconFamilyId = iconId.substr(0, iconId.indexOf("_"));
|
||||
|
||||
if (family.id == iconFamilyId) {
|
||||
result = family.icons;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
remove:function () {
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
var featureId = this._featureModel.getId();
|
||||
var topicId = this._topicId;
|
||||
actionDispatcher.removeFeatureFromTopic(topicId, featureId);
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.ImageIcon.prototype.ICON_FAMILIES = [
|
||||
{"id":"face", "icons":["face_plain", "face_sad", "face_crying", "face_smile", "face_surprise", "face_wink"]},
|
||||
{"id":"funy", "icons":["funy_angel", "funy_devilish", "funy_glasses", "funy_grin", "funy_kiss", "funy_monkey"]},
|
||||
{"id":"conn", "icons":["conn_connect", "conn_disconnect"]},
|
||||
{"id":"sport", "icons":["sport_basketball", "sport_football", "sport_golf", "sport_raquet", "sport_shuttlecock", "sport_soccer", "sport_tennis"]},
|
||||
{"id":"bulb", "icons":["bulb_light_on", "bulb_light_off"]},
|
||||
{"id":"thumb", "icons":["thumb_thumb_up", "thumb_thumb_down"]},
|
||||
{"id":"tick", "icons":["tick_tick", "tick_cross"]},
|
||||
{"id":"onoff", "icons":["onoff_clock", "onoff_clock_red", "onoff_add", "onoff_delete", "onoff_status_offline", "onoff_status_online"]},
|
||||
{"id":"money", "icons":["money_money", "money_dollar", "money_euro", "money_pound", "money_yen", "money_coins", "money_ruby"]},
|
||||
{"id":"time", "icons":["time_calendar", "time_clock", "time_hourglass"]},
|
||||
{"id":"number", "icons":["number_1", "number_2", "number_3", "number_4", "number_5", "number_6", "number_7", "number_8", "number_9"]},
|
||||
{"id":"chart", "icons":["chart_bar", "chart_line", "chart_curve", "chart_pie", "chart_organisation"]},
|
||||
{"id":"sign", "icons":["sign_warning", "sign_info", "sign_stop", "sign_help", "sign_cancel"]},
|
||||
{"id":"hard", "icons":["hard_cd", "hard_computer", "hard_controller", "hard_driver_disk", "hard_ipod", "hard_keyboard", "hard_mouse", "hard_printer"]},
|
||||
{"id":"soft", "icons":["soft_bug", "soft_cursor", "soft_database_table", "soft_database", "soft_feed", "soft_folder_explore", "soft_rss", "soft_penguin"]},
|
||||
{"id":"arrow", "icons":["arrow_up", "arrow_down", "arrow_left", "arrow_right"]},
|
||||
{"id":"arrowc", "icons":["arrowc_rotate_anticlockwise", "arrowc_rotate_clockwise", "arrowc_turn_left", "arrowc_turn_right"]},
|
||||
{"id":"people", "icons":["people_group", "people_male1", "people_male2", "people_female1", "people_female2"]},
|
||||
{"id":"mail", "icons":["mail_envelop", "mail_mailbox", "mail_edit", "mail_list"]},
|
||||
{"id":"flag", "icons":["flag_blue", "flag_green", "flag_orange", "flag_pink", "flag_purple", "flag_yellow"]},
|
||||
{"id":"bullet", "icons":["bullet_black", "bullet_blue", "bullet_green", "bullet_orange", "bullet_red", "bullet_pink", "bullet_purple"]},
|
||||
{"id":"tag", "icons":["tag_blue", "tag_green", "tag_orange", "tag_red", "tag_pink", "tag_yellow"]},
|
||||
{"id":"object", "icons":["object_bell", "object_clanbomber", "object_key", "object_pencil", "object_phone", "object_magnifier", "object_clip", "object_music", "object_star", "object_wizard", "object_house", "object_cake", "object_camera", "object_palette", "object_rainbow"]},
|
||||
{"id":"weather", "icons":["weather_clear-night", "weather_clear", "weather_few-clouds-night", "weather_few-clouds", "weather_overcast", "weather_severe-alert", "weather_showers-scattered", "weather_showers", "weather_snow", "weather_storm"]},
|
||||
{"id":"task", "icons":["task_0", "task_25", "task_50", "task_75", "task_100"]}
|
||||
];
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.LinkIcon = new Class({
|
||||
|
||||
Extends:mindplot.Icon,
|
||||
initialize:function (topic, linkModel, readOnly) {
|
||||
$assert(topic, 'topic can not be null');
|
||||
$assert(linkModel, 'linkModel can not be null');
|
||||
|
||||
this.parent(mindplot.LinkIcon.IMAGE_URL);
|
||||
this._linksModel = linkModel;
|
||||
this._topic = topic;
|
||||
this._readOnly = readOnly;
|
||||
|
||||
this._registerEvents();
|
||||
},
|
||||
|
||||
_registerEvents:function () {
|
||||
this._image.setCursor('pointer');
|
||||
|
||||
if (!this._readOnly) {
|
||||
// Add on click event to open the editor ...
|
||||
this.addEvent('click', function (event) {
|
||||
this._topic.showLinkEditor();
|
||||
event.stopPropagation();
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
this._tip = new mindplot.widget.LinkIconTooltip(this);
|
||||
},
|
||||
|
||||
getModel:function () {
|
||||
return this._linksModel;
|
||||
}
|
||||
});
|
||||
mindplot.LinkIcon.IMAGE_URL = "images/links.png";
|
||||
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.LocalStorageManager = new Class({
|
||||
Extends:mindplot.PersistenceManager,
|
||||
initialize:function (documentUrl,forceLoad) {
|
||||
this.parent();
|
||||
this.documentUrl = documentUrl;
|
||||
this.forceLoad = forceLoad;
|
||||
},
|
||||
|
||||
saveMapXml:function (mapId, mapXml, pref, saveHistory, events) {
|
||||
localStorage.setItem(mapId + "-xml", mapXml);
|
||||
},
|
||||
|
||||
discardChanges:function (mapId) {
|
||||
localStorage.removeItem(mapId + "-xml");
|
||||
},
|
||||
|
||||
loadMapDom:function (mapId) {
|
||||
var xml = localStorage.getItem(mapId + "-xml");
|
||||
if (xml == null || this.forceLoad) {
|
||||
var xmlRequest = new Request({
|
||||
url:this.documentUrl.replace("{id}", mapId),
|
||||
headers:{"Content-Type":"text/plain","Accept":"application/xml"},
|
||||
method:'get',
|
||||
async:false,
|
||||
onSuccess:function (responseText) {
|
||||
xml = responseText;
|
||||
}
|
||||
});
|
||||
xmlRequest.send();
|
||||
|
||||
// If I could not load it from a file, hard code one.
|
||||
if (xml == null) {
|
||||
throw new Error("Map could not be loaded");
|
||||
}
|
||||
}
|
||||
|
||||
var parser = new DOMParser();
|
||||
return parser.parseFromString(xml, "text/xml");
|
||||
},
|
||||
|
||||
unlockMap:function (mindmap) {
|
||||
// Ignore, no implementation required ...
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.MainTopic = new Class({
|
||||
Extends:mindplot.Topic,
|
||||
initialize:function (model, options) {
|
||||
this.parent(model, options);
|
||||
},
|
||||
|
||||
INNER_RECT_ATTRIBUTES:{stroke:'0.5 solid #009900'},
|
||||
|
||||
_buildDragShape:function () {
|
||||
var innerShape = this._buildShape(this.INNER_RECT_ATTRIBUTES, this.getShapeType());
|
||||
var size = this.getSize();
|
||||
innerShape.setSize(size.width, size.height);
|
||||
innerShape.setPosition(0, 0);
|
||||
innerShape.setOpacity(0.5);
|
||||
innerShape.setCursor('default');
|
||||
innerShape.setVisibility(true);
|
||||
|
||||
var brColor = this.getBorderColor();
|
||||
innerShape.setAttribute("strokeColor", brColor);
|
||||
|
||||
var bgColor = this.getBackgroundColor();
|
||||
innerShape.setAttribute("fillColor", bgColor);
|
||||
|
||||
// Create group ...
|
||||
var groupAttributes = {width:100, height:100, coordSizeWidth:100, coordSizeHeight:100};
|
||||
var group = new web2d.Group(groupAttributes);
|
||||
group.appendChild(innerShape);
|
||||
|
||||
// Add Text ...
|
||||
if (this.getShapeType() != mindplot.model.TopicShape.IMAGE) {
|
||||
var textShape = this._buildTextShape(true);
|
||||
var text = this.getText();
|
||||
textShape.setText(text);
|
||||
textShape.setOpacity(0.5);
|
||||
group.appendChild(textShape);
|
||||
}
|
||||
return group;
|
||||
},
|
||||
|
||||
updateTopicShape:function (targetTopic, workspace) {
|
||||
// Change figure based on the connected topic ...
|
||||
var model = this.getModel();
|
||||
var shapeType = model.getShapeType();
|
||||
if (!targetTopic.isCentralTopic()) {
|
||||
if (!$defined(shapeType)) {
|
||||
// Get the real shape type ...
|
||||
shapeType = this.getShapeType();
|
||||
this._setShapeType(shapeType, false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
disconnect:function (workspace) {
|
||||
this.parent(workspace);
|
||||
var size = this.getSize();
|
||||
|
||||
var model = this.getModel();
|
||||
var shapeType = model.getShapeType();
|
||||
if (!$defined(shapeType)) {
|
||||
// Change figure ...
|
||||
shapeType = this.getShapeType();
|
||||
this._setShapeType(mindplot.model.TopicShape.ROUNDED_RECT, false);
|
||||
}
|
||||
var innerShape = this.getInnerShape();
|
||||
innerShape.setVisibility(true);
|
||||
},
|
||||
|
||||
_updatePositionOnChangeSize:function (oldSize, newSize) {
|
||||
|
||||
var xOffset = Math.round((newSize.width - oldSize.width) / 2);
|
||||
var pos = this.getPosition();
|
||||
if ($defined(pos)) {
|
||||
if (pos.x > 0) {
|
||||
pos.x = pos.x + xOffset;
|
||||
} else {
|
||||
pos.x = pos.x - xOffset;
|
||||
}
|
||||
this.setPosition(pos);
|
||||
}
|
||||
},
|
||||
|
||||
workoutIncomingConnectionPoint:function (sourcePosition) {
|
||||
return mindplot.util.Shape.workoutIncomingConnectionPoint(this, sourcePosition);
|
||||
},
|
||||
|
||||
workoutOutgoingConnectionPoint:function (targetPosition) {
|
||||
$assert(targetPosition, 'targetPoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||
var size = this.getSize();
|
||||
|
||||
var result;
|
||||
if (this.getShapeType() == mindplot.model.TopicShape.LINE) {
|
||||
|
||||
result = new core.Point();
|
||||
var groupPosition = this._elem2d.getPosition();
|
||||
var innerShareSize = this.getInnerShape().getSize();
|
||||
|
||||
if (innerShareSize) {
|
||||
var magicCorrectionNumber = 0.3;
|
||||
if (!isAtRight) {
|
||||
result.x = groupPosition.x + innerShareSize.width - magicCorrectionNumber;
|
||||
} else {
|
||||
result.x = groupPosition.x + magicCorrectionNumber;
|
||||
}
|
||||
result.y = groupPosition.y + innerShareSize.height;
|
||||
} else {
|
||||
// Hack: When the size has not being defined. This is because the node has not being added.
|
||||
// Try to do our best ...
|
||||
if (!isAtRight) {
|
||||
result.x = pos.x + (size.width / 2);
|
||||
} else {
|
||||
result.x = pos.x - (size.width / 2);
|
||||
}
|
||||
result.y = pos.y + (size.height / 2);
|
||||
}
|
||||
|
||||
} else {
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.Messages = new Class({
|
||||
Static:{
|
||||
init:function (locale) {
|
||||
locale = $defined(locale) ? locale : 'en';
|
||||
var bundle = mindplot.Messages.BUNDLES[locale];
|
||||
if (bundle == null && locale.indexOf("_") != -1) {
|
||||
// Try to locate without the specialization ...
|
||||
locale = locale.substring(0, locale.indexOf("_"));
|
||||
bundle = mindplot.Messages.BUNDLES[locale];
|
||||
}
|
||||
mindplot.Messages.__bundle = bundle;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$msg = function (key) {
|
||||
if (!mindplot.Messages.__bundle) {
|
||||
mindplot.Messages.init('en');
|
||||
}
|
||||
|
||||
var msg = mindplot.Messages.__bundle[key];
|
||||
return msg ? msg : key;
|
||||
};
|
||||
|
||||
mindplot.Messages.BUNDLES = {};
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.MultilineTextEditor = new Class({
|
||||
Extends:Events,
|
||||
initialize:function () {
|
||||
this._topic = null;
|
||||
this._timeoutId = -1;
|
||||
},
|
||||
|
||||
_buildEditor:function () {
|
||||
|
||||
var result = new Element('div');
|
||||
result.setStyles({
|
||||
position:"absolute",
|
||||
display:"none",
|
||||
zIndex:"8",
|
||||
overflow:"hidden",
|
||||
border:"0 none"
|
||||
}
|
||||
);
|
||||
|
||||
var textareaElem = new Element('textarea',
|
||||
{ tabindex:'-1',
|
||||
value:"",
|
||||
wrap:'off'
|
||||
}
|
||||
);
|
||||
|
||||
textareaElem.setStyles({
|
||||
border:"1px gray dashed",
|
||||
background:"rgba(98, 135, 167, .3)",
|
||||
outline:'0 none',
|
||||
resize:'none',
|
||||
overflow:"hidden"
|
||||
});
|
||||
textareaElem.inject(result);
|
||||
return result;
|
||||
},
|
||||
|
||||
_registerEvents:function (containerElem) {
|
||||
var textareaElem = this._getTextareaElem();
|
||||
|
||||
textareaElem.addEvent('keydown', function (event) {
|
||||
switch (event.key) {
|
||||
case 'esc':
|
||||
this.close(false);
|
||||
break;
|
||||
case 'enter':
|
||||
if (event.meta || event.control) {
|
||||
|
||||
// Add return ...
|
||||
var text = textareaElem.value;
|
||||
var cursorPosition = text.length;
|
||||
if (textareaElem.selectionStart) {
|
||||
cursorPosition = textareaElem.selectionStart;
|
||||
}
|
||||
|
||||
var head = text.substring(0, cursorPosition);
|
||||
var tail = "";
|
||||
if (cursorPosition < text.length) {
|
||||
tail = text.substring(cursorPosition, text.length);
|
||||
}
|
||||
textareaElem.value = head + "\n" + tail;
|
||||
|
||||
// Position cursor ...
|
||||
if (textareaElem.setSelectionRange) {
|
||||
textareaElem.focus();
|
||||
textareaElem.setSelectionRange(cursorPosition + 1, cursorPosition + 1);
|
||||
} else if (textareaElem.createTextRange) {
|
||||
var range = textareaElem.createTextRange();
|
||||
range.moveStart('character', cursorPosition + 1);
|
||||
range.select();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
this.close(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
event.stopPropagation();
|
||||
}.bind(this));
|
||||
|
||||
textareaElem.addEvent('keypress', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
textareaElem.addEvent('keyup', function (event) {
|
||||
var text = this._getTextareaElem().value;
|
||||
this.fireEvent('input', [event, text]);
|
||||
this._adjustEditorSize();
|
||||
}.bind(this));
|
||||
|
||||
// If the user clicks on the input, all event must be ignored ...
|
||||
containerElem.addEvent('click', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
containerElem.addEvent('dblclick', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
containerElem.addEvent('mousedown', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
},
|
||||
|
||||
_adjustEditorSize:function () {
|
||||
|
||||
if (this.isVisible()) {
|
||||
var textElem = this._getTextareaElem();
|
||||
|
||||
var lines = textElem.value.split('\n');
|
||||
var maxLineLength = 1;
|
||||
lines.each(function (line) {
|
||||
if (maxLineLength < line.length)
|
||||
maxLineLength = line.length;
|
||||
});
|
||||
|
||||
textElem.setAttribute('cols', maxLineLength);
|
||||
textElem.setAttribute('rows', lines.length);
|
||||
|
||||
this._containerElem.setStyles({
|
||||
width:(maxLineLength + 3) + 'em',
|
||||
height:textElem.getSize().height
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
isVisible:function () {
|
||||
return $defined(this._containerElem) && this._containerElem.getStyle('display') == 'block';
|
||||
},
|
||||
|
||||
_updateModel:function () {
|
||||
|
||||
if (this._topic.getText() != this._getText()) {
|
||||
var text = this._getText();
|
||||
var topicId = this._topic.getId();
|
||||
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.changeTextToTopic([topicId], text);
|
||||
}
|
||||
},
|
||||
|
||||
show:function (topic, text) {
|
||||
// Close a previous node editor if it's opened ...
|
||||
if (this._topic) {
|
||||
this.close(false);
|
||||
}
|
||||
|
||||
this._topic = topic;
|
||||
if (!this.isVisible()) {
|
||||
//Create editor ui
|
||||
var containerElem = this._buildEditor();
|
||||
containerElem.inject($(document.body));
|
||||
|
||||
this._containerElem = containerElem;
|
||||
this._registerEvents(containerElem);
|
||||
this._showEditor(text);
|
||||
}
|
||||
},
|
||||
|
||||
_showEditor:function (defaultText) {
|
||||
|
||||
var topic = this._topic;
|
||||
|
||||
// Hide topic text ...
|
||||
topic.getTextShape().setVisibility(false);
|
||||
|
||||
// Set Editor Style
|
||||
var nodeText = topic.getTextShape();
|
||||
var font = nodeText.getFont();
|
||||
font.size = nodeText.getHtmlFontSize();
|
||||
font.color = nodeText.getColor();
|
||||
this._setStyle(font);
|
||||
|
||||
// Set editor's initial size
|
||||
var displayFunc = function () {
|
||||
// Position the editor and set the size...
|
||||
var textShape = topic.getTextShape();
|
||||
textShape.positionRelativeTo(this._containerElem, {
|
||||
position:{x:'left', y:'top'},
|
||||
edge:{x:'left', y:'top'}
|
||||
});
|
||||
this._containerElem.setStyle('display', 'block');
|
||||
|
||||
// Set editor's initial text ...
|
||||
var text = $defined(defaultText) ? defaultText : topic.getText();
|
||||
this._setText(text);
|
||||
|
||||
// Set the element focus and select the current text ...
|
||||
var inputElem = this._getTextareaElem();
|
||||
this._positionCursor(inputElem, !$defined(defaultText));
|
||||
|
||||
}.bind(this);
|
||||
|
||||
this._timeoutId = displayFunc.delay(10);
|
||||
},
|
||||
|
||||
_setStyle:function (fontStyle) {
|
||||
var inputField = this._getTextareaElem();
|
||||
if (!$defined(fontStyle.font)) {
|
||||
fontStyle.font = "Arial";
|
||||
}
|
||||
if (!$defined(fontStyle.style)) {
|
||||
fontStyle.style = "normal";
|
||||
}
|
||||
if (!$defined(fontStyle.weight)) {
|
||||
fontStyle.weight = "normal";
|
||||
}
|
||||
if (!$defined(fontStyle.size)) {
|
||||
fontStyle.size = 12;
|
||||
}
|
||||
var style = {
|
||||
fontSize:fontStyle.size + "px",
|
||||
fontFamily:fontStyle.font,
|
||||
fontStyle:fontStyle.style,
|
||||
fontWeight:fontStyle.weight,
|
||||
color:fontStyle.color
|
||||
};
|
||||
inputField.setStyles(style);
|
||||
this._containerElem.setStyles(style);
|
||||
},
|
||||
|
||||
_setText:function (text) {
|
||||
var textareaElem = this._getTextareaElem();
|
||||
textareaElem.value = text;
|
||||
this._adjustEditorSize();
|
||||
},
|
||||
|
||||
_getText:function () {
|
||||
return this._getTextareaElem().value;
|
||||
},
|
||||
|
||||
_getTextareaElem:function () {
|
||||
return this._containerElem.getElement('textarea');
|
||||
},
|
||||
|
||||
_positionCursor:function (textareaElem, selectText) {
|
||||
textareaElem.focus();
|
||||
if (selectText) {
|
||||
// Mark text as selected ...
|
||||
if (textareaElem.createTextRange) {
|
||||
var rang = textareaElem.createTextRange();
|
||||
rang.select();
|
||||
rang.move("character", textareaElem.value.length);
|
||||
}
|
||||
else {
|
||||
textareaElem.setSelectionRange(0, textareaElem.value.length);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Move the cursor to the last character ..
|
||||
if (textareaElem.createTextRange) {
|
||||
var range = textareaElem.createTextRange();
|
||||
range.move("character", textareaElem.value.length);
|
||||
} else {
|
||||
textareaElem.selectionStart = textareaElem.value.length;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
close:function (update) {
|
||||
if (this.isVisible() && this._topic) {
|
||||
// Update changes ...
|
||||
clearTimeout(this._timeoutId);
|
||||
|
||||
if (!$defined(update) || update) {
|
||||
this._updateModel();
|
||||
}
|
||||
|
||||
// Let make the visible text in the node visible again ...
|
||||
this._topic.getTextShape().setVisibility(true);
|
||||
|
||||
// Remove it form the screen ...
|
||||
this._containerElem.dispose();
|
||||
this._containerElem = null;
|
||||
this._timeoutId = -1;
|
||||
}
|
||||
this._topic = null;
|
||||
}
|
||||
});
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.NodeGraph = new Class({
|
||||
initialize:function(nodeModel, options) {
|
||||
$assert(nodeModel, "model can not be null");
|
||||
|
||||
this._options = options;
|
||||
this._mouseEvents = true;
|
||||
this.setModel(nodeModel);
|
||||
this._onFocus = false;
|
||||
this._event = new Events();
|
||||
this._size = {width:50,height:20};
|
||||
},
|
||||
|
||||
isReadOnly : function(){
|
||||
return this._options.readOnly;
|
||||
},
|
||||
|
||||
getType : function() {
|
||||
var model = this.getModel();
|
||||
return model.getType();
|
||||
},
|
||||
|
||||
setId : function(id) {
|
||||
$assert(typeof topic.getId() == "number", "id is not a number:" + id);
|
||||
this.getModel().setId(id);
|
||||
},
|
||||
|
||||
_set2DElement : function(elem2d) {
|
||||
this._elem2d = elem2d;
|
||||
},
|
||||
|
||||
get2DElement : function() {
|
||||
$assert(this._elem2d, 'NodeGraph has not been initialized properly');
|
||||
return this._elem2d;
|
||||
},
|
||||
|
||||
setPosition : function(point, fireEvent) {
|
||||
throw "Unsupported operation";
|
||||
},
|
||||
|
||||
addEvent : function(type, listener) {
|
||||
var elem = this.get2DElement();
|
||||
elem.addEvent(type, listener);
|
||||
},
|
||||
|
||||
removeEvent : function(type, listener) {
|
||||
var elem = this.get2DElement();
|
||||
elem.removeEvent(type, listener);
|
||||
},
|
||||
|
||||
fireEvent: function(type, event) {
|
||||
var elem = this.get2DElement();
|
||||
elem.fireEvent(type, event);
|
||||
},
|
||||
|
||||
setMouseEventsEnabled : function(isEnabled) {
|
||||
this._mouseEvents = isEnabled;
|
||||
},
|
||||
|
||||
isMouseEventsEnabled : function() {
|
||||
return this._mouseEvents;
|
||||
},
|
||||
|
||||
getSize : function() {
|
||||
return this._size;
|
||||
},
|
||||
|
||||
setSize : function(size) {
|
||||
this._size.width = parseInt(size.width);
|
||||
this._size.height = parseInt(size.height);
|
||||
},
|
||||
|
||||
getModel:function() {
|
||||
$assert(this._model, 'Model has not been initialized yet');
|
||||
return this._model;
|
||||
},
|
||||
|
||||
setModel : function(model) {
|
||||
$assert(model, 'Model can not be null');
|
||||
this._model = model;
|
||||
},
|
||||
|
||||
getId : function() {
|
||||
return this._model.getId();
|
||||
},
|
||||
|
||||
setOnFocus : function(focus) {
|
||||
if (this._onFocus != focus) {
|
||||
|
||||
this._onFocus = focus;
|
||||
var outerShape = this.getOuterShape();
|
||||
if (focus) {
|
||||
outerShape.setFill(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES_FOCUS.fillColor);
|
||||
outerShape.setOpacity(1);
|
||||
|
||||
} else {
|
||||
outerShape.setFill(mindplot.Topic.OUTER_SHAPE_ATTRIBUTES.fillColor);
|
||||
outerShape.setOpacity(0);
|
||||
}
|
||||
this.setCursor('move');
|
||||
|
||||
// In any case, always try to hide the editor ...
|
||||
this.closeEditors();
|
||||
|
||||
// Fire event ...
|
||||
this.fireEvent(focus ? 'ontfocus' : 'ontblur',this);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
isOnFocus : function() {
|
||||
return this._onFocus;
|
||||
},
|
||||
|
||||
dispose : function(workspace) {
|
||||
this.setOnFocus(false);
|
||||
workspace.removeChild(this);
|
||||
},
|
||||
|
||||
createDragNode : function(layoutManager) {
|
||||
var dragShape = this._buildDragShape();
|
||||
return new mindplot.DragTopic(dragShape, this, layoutManager);
|
||||
},
|
||||
|
||||
_buildDragShape : function() {
|
||||
$assert(false, '_buildDragShape must be implemented by all nodes.');
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
var model = this.getModel();
|
||||
return model.getPosition();
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.NodeGraph.create = function(nodeModel, options) {
|
||||
$assert(nodeModel, 'Model can not be null');
|
||||
|
||||
var type = nodeModel.getType();
|
||||
$assert(type, 'Node model type can not be null');
|
||||
|
||||
var result;
|
||||
if (type == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
result = new mindplot.CentralTopic(nodeModel, options);
|
||||
} else
|
||||
if (type == mindplot.model.INodeModel.MAIN_TOPIC_TYPE) {
|
||||
result = new mindplot.MainTopic(nodeModel, options);
|
||||
} else {
|
||||
$assert(false, "unsupported node type:" + type);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.NoteIcon = new Class({
|
||||
Extends:mindplot.Icon,
|
||||
initialize:function (topic, noteModel, readOnly) {
|
||||
$assert(topic, 'topic can not be null');
|
||||
|
||||
this.parent(mindplot.NoteIcon.IMAGE_URL);
|
||||
this._linksModel = noteModel;
|
||||
this._topic = topic;
|
||||
this._readOnly = readOnly;
|
||||
|
||||
this._registerEvents();
|
||||
},
|
||||
|
||||
_registerEvents:function () {
|
||||
this._image.setCursor('pointer');
|
||||
|
||||
if (!this._readOnly) {
|
||||
|
||||
// Add on click event to open the editor ...
|
||||
this.addEvent('click', function (event) {
|
||||
this._topic.showNoteEditor();
|
||||
event.stopPropagation();
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
this._tip = new mindplot.widget.FloatingTip(this.getImage()._peer._native, {
|
||||
// Content can also be a function of the target element!
|
||||
content:function () {
|
||||
var result = new Element('div');
|
||||
result.setStyles({padding:'5px'});
|
||||
|
||||
var title = new Element('div', {text:$msg('NOTE')});
|
||||
title.setStyles({
|
||||
'font-weight':'bold',
|
||||
color:'black',
|
||||
'padding-bottom':'5px',
|
||||
width:'100px'
|
||||
});
|
||||
title.inject(result);
|
||||
|
||||
var text = new Element('div', {text:this._linksModel.getText()});
|
||||
text.setStyles({
|
||||
'white-space':'pre-wrap',
|
||||
'word-wrap':'break-word'
|
||||
}
|
||||
);
|
||||
text.inject(result);
|
||||
|
||||
|
||||
return result;
|
||||
}.bind(this),
|
||||
html:true,
|
||||
position:'bottom',
|
||||
arrowOffset:10,
|
||||
center:true,
|
||||
arrowSize:15,
|
||||
offset:{x:10, y:20},
|
||||
className:'notesTip'
|
||||
});
|
||||
},
|
||||
|
||||
getModel:function () {
|
||||
return this._linksModel;
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.NoteIcon.IMAGE_URL = "images/notes.png";
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.PersistenceManager = new Class({
|
||||
Static:{
|
||||
loadFromDom:function (mapId, mapDom) {
|
||||
$assert(mapId, "mapId can not be null");
|
||||
$assert(mapDom, "mapDom can not be null");
|
||||
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromDocument(mapDom);
|
||||
return serializer.loadFromDom(mapDom, mapId);
|
||||
}
|
||||
},
|
||||
|
||||
initialize:function () {
|
||||
|
||||
},
|
||||
|
||||
save:function (mindmap, editorProperties, saveHistory, events, sync) {
|
||||
$assert(mindmap, "mindmap can not be null");
|
||||
$assert(editorProperties, "editorProperties can not be null");
|
||||
|
||||
var mapId = mindmap.getId();
|
||||
$assert(mapId, "mapId can not be null");
|
||||
|
||||
var serializer = mindplot.persistence.XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||
var domMap = serializer.toXML(mindmap);
|
||||
var mapXml = core.Utils.innerXML(domMap);
|
||||
|
||||
var pref = JSON.encode(editorProperties);
|
||||
try {
|
||||
this.saveMapXml(mapId, mapXml, pref, saveHistory, events, sync);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
events.onError(this._buildError());
|
||||
}
|
||||
},
|
||||
|
||||
load:function (mapId) {
|
||||
$assert(mapId, "mapId can not be null");
|
||||
var domDocument = this.loadMapDom(mapId);
|
||||
return mindplot.PersistenceManager.loadFromDom(mapId, domDocument);
|
||||
},
|
||||
|
||||
discardChanges:function (mapId) {
|
||||
throw new Error("Method must be implemented");
|
||||
},
|
||||
|
||||
loadMapDom:function (mapId) {
|
||||
throw new Error("Method must be implemented");
|
||||
},
|
||||
|
||||
saveMapXml:function (mapId, mapXml, pref, saveHistory, events, sync) {
|
||||
throw new Error("Method must be implemented");
|
||||
},
|
||||
|
||||
unlockMap:function (mindmap) {
|
||||
throw new Error("Method must be implemented");
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.PersistenceManager.init = function (instance) {
|
||||
mindplot.PersistenceManager._instance = instance;
|
||||
};
|
||||
|
||||
mindplot.PersistenceManager.getInstance = function () {
|
||||
return mindplot.PersistenceManager._instance;
|
||||
};
|
||||
|
|
@ -1,330 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.Relationship = new Class({
|
||||
Extends:mindplot.ConnectionLine,
|
||||
Static:{
|
||||
getStrokeColor:function () {
|
||||
return '#9b74e6';
|
||||
},
|
||||
type:"Relationship"
|
||||
},
|
||||
initialize:function (sourceNode, targetNode, model) {
|
||||
$assert(sourceNode, "sourceNode can not be null");
|
||||
$assert(targetNode, "targetNode can not be null");
|
||||
|
||||
this.parent(sourceNode, targetNode, model.getLineType());
|
||||
this.setModel(model);
|
||||
|
||||
var strokeColor = mindplot.Relationship.getStrokeColor();
|
||||
|
||||
this._line2d.setIsSrcControlPointCustom(false);
|
||||
this._line2d.setIsDestControlPointCustom(false);
|
||||
this._line2d.setCursor('pointer');
|
||||
this._line2d.setStroke(1, 'solid', strokeColor);
|
||||
this._line2d.setDashed(4, 2);
|
||||
this._focusShape = this._createLine(this.getLineType(), mindplot.ConnectionLine.SIMPLE_CURVED);
|
||||
this._focusShape.setStroke(2, "solid", "#3f96ff");
|
||||
|
||||
var ctrlPoints = this._line2d.getControlPoints();
|
||||
this._focusShape.setSrcControlPoint(ctrlPoints[0]);
|
||||
this._focusShape.setDestControlPoint(ctrlPoints[1]);
|
||||
this._focusShape.setVisibility(false);
|
||||
this._onFocus = false;
|
||||
this._isInWorkspace = false;
|
||||
this._controlPointsController = new mindplot.ControlPoint();
|
||||
|
||||
this._startArrow = new web2d.Arrow();
|
||||
this._startArrow.setStrokeColor(strokeColor);
|
||||
this._startArrow.setStrokeWidth(2);
|
||||
this.setShowStartArrow(true);
|
||||
|
||||
// Share style is disable ...
|
||||
if (this._showEndArrow) {
|
||||
this._endArrow = new web2d.Arrow();
|
||||
this._endArrow.setStrokeColor(strokeColor);
|
||||
this._endArrow.setStrokeWidth(2);
|
||||
}
|
||||
|
||||
// Position the line ...
|
||||
if ($defined(model.getSrcCtrlPoint())) {
|
||||
var srcPoint = model.getSrcCtrlPoint().clone();
|
||||
this.setSrcControlPoint(srcPoint);
|
||||
}
|
||||
if ($defined(model.getDestCtrlPoint())) {
|
||||
var destPoint = model.getDestCtrlPoint().clone();
|
||||
this.setDestControlPoint(destPoint);
|
||||
}
|
||||
},
|
||||
|
||||
setStroke:function (color, style, opacity) {
|
||||
this.parent(color, style, opacity);
|
||||
this._startArrow.setStrokeColor(color);
|
||||
},
|
||||
|
||||
redraw:function () {
|
||||
var line2d = this._line2d;
|
||||
var sourceTopic = this._sourceTopic;
|
||||
var sourcePosition = sourceTopic.getPosition();
|
||||
|
||||
var targetTopic = this._targetTopic;
|
||||
var targetPosition = targetTopic.getPosition();
|
||||
if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
targetPosition = mindplot.util.Shape.workoutIncomingConnectionPoint(targetTopic, sourcePosition);
|
||||
}
|
||||
|
||||
var sPos, tPos;
|
||||
this._line2d.setStroke(2);
|
||||
var ctrlPoints = this._line2d.getControlPoints();
|
||||
if (!this._line2d.isDestControlPointCustom() && !this._line2d.isSrcControlPointCustom()) {
|
||||
|
||||
var defaultPoints = mindplot.util.Shape.calculateDefaultControlPoints(sourcePosition, targetPosition);
|
||||
ctrlPoints[0].x = defaultPoints[0].x;
|
||||
ctrlPoints[0].y = defaultPoints[0].y;
|
||||
|
||||
ctrlPoints[1].x = defaultPoints[1].x;
|
||||
ctrlPoints[1].y = defaultPoints[1].y;
|
||||
}
|
||||
var spoint = new core.Point();
|
||||
spoint.x = parseInt(ctrlPoints[0].x) + parseInt(sourcePosition.x);
|
||||
spoint.y = parseInt(ctrlPoints[0].y) + parseInt(sourcePosition.y);
|
||||
|
||||
var tpoint = new core.Point();
|
||||
tpoint.x = parseInt(ctrlPoints[1].x) + parseInt(targetPosition.x);
|
||||
tpoint.y = parseInt(ctrlPoints[1].y) + parseInt(targetPosition.y);
|
||||
|
||||
sPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(sourceTopic, spoint);
|
||||
tPos = mindplot.util.Shape.calculateRelationShipPointCoordinates(targetTopic, tpoint);
|
||||
|
||||
line2d.setFrom(sPos.x, sPos.y);
|
||||
line2d.setTo(tPos.x, tPos.y);
|
||||
|
||||
line2d.moveToFront();
|
||||
|
||||
//Positionate Arrows
|
||||
this._positionArrows();
|
||||
|
||||
// Add connector ...
|
||||
this._positionateConnector(targetTopic);
|
||||
|
||||
if (this.isOnFocus()) {
|
||||
this._refreshShape();
|
||||
}
|
||||
this._focusShape.moveToBack();
|
||||
this._controlPointsController.redraw();
|
||||
},
|
||||
|
||||
_positionArrows:function () {
|
||||
var tpos = this._line2d.getTo();
|
||||
var spos = this._line2d.getFrom();
|
||||
|
||||
this._startArrow.setFrom(spos.x, spos.y);
|
||||
this._startArrow.moveToBack();
|
||||
|
||||
if (this._endArrow) {
|
||||
this._endArrow.setFrom(tpos.x, tpos.y);
|
||||
this._endArrow.moveToBack();
|
||||
}
|
||||
|
||||
if (this._line2d.getType() == "CurvedLine") {
|
||||
var controlPoints = this._line2d.getControlPoints();
|
||||
this._startArrow.setControlPoint(controlPoints[0]);
|
||||
if (this._endArrow) {
|
||||
this._endArrow.setControlPoint(controlPoints[1]);
|
||||
}
|
||||
} else {
|
||||
this._startArrow.setControlPoint(this._line2d.getTo());
|
||||
if (this._endArrow) {
|
||||
this._endArrow.setControlPoint(this._line2d.getFrom());
|
||||
}
|
||||
}
|
||||
|
||||
if (this._showEndArrow) {
|
||||
this._endArrow.setVisibility(this.isVisible());
|
||||
}
|
||||
this._startArrow.setVisibility(this.isVisible() && this._showStartArrow);
|
||||
},
|
||||
|
||||
addToWorkspace:function (workspace) {
|
||||
workspace.appendChild(this._focusShape);
|
||||
workspace.appendChild(this._controlPointsController);
|
||||
|
||||
this._controlPointControllerListener = this._initializeControlPointController.bind(this);
|
||||
this._line2d.addEvent('click', this._controlPointControllerListener);
|
||||
this._isInWorkspace = true;
|
||||
|
||||
workspace.appendChild(this._startArrow);
|
||||
if (this._endArrow)
|
||||
workspace.appendChild(this._endArrow);
|
||||
|
||||
this.parent(workspace);
|
||||
this._positionArrows();
|
||||
this.redraw();
|
||||
|
||||
},
|
||||
|
||||
_initializeControlPointController:function () {
|
||||
this.setOnFocus(true);
|
||||
},
|
||||
|
||||
removeFromWorkspace:function (workspace) {
|
||||
workspace.removeChild(this._focusShape);
|
||||
workspace.removeChild(this._controlPointsController);
|
||||
this._line2d.removeEvent('click', this._controlPointControllerListener);
|
||||
this._isInWorkspace = false;
|
||||
workspace.removeChild(this._startArrow);
|
||||
if (this._endArrow)
|
||||
workspace.removeChild(this._endArrow);
|
||||
|
||||
this.parent(workspace);
|
||||
},
|
||||
|
||||
getType:function () {
|
||||
return mindplot.Relationship.type;
|
||||
},
|
||||
|
||||
setOnFocus:function (focus) {
|
||||
// Change focus shape
|
||||
if (this.isOnFocus() != focus) {
|
||||
if (focus) {
|
||||
this._refreshShape();
|
||||
this._controlPointsController.setLine(this);
|
||||
}
|
||||
this._focusShape.setVisibility(focus);
|
||||
|
||||
this._controlPointsController.setVisibility(focus);
|
||||
this._onFocus = focus;
|
||||
this.fireEvent(focus ? 'ontfocus' : 'ontblur', this);
|
||||
}
|
||||
},
|
||||
|
||||
_refreshShape:function () {
|
||||
var sPos = this._line2d.getFrom();
|
||||
var tPos = this._line2d.getTo();
|
||||
var ctrlPoints = this._line2d.getControlPoints();
|
||||
this._focusShape.setFrom(sPos.x, sPos.y);
|
||||
this._focusShape.setTo(tPos.x, tPos.y);
|
||||
var shapeCtrlPoints = this._focusShape.getControlPoints();
|
||||
shapeCtrlPoints[0].x = ctrlPoints[0].x;
|
||||
shapeCtrlPoints[0].y = ctrlPoints[0].y;
|
||||
shapeCtrlPoints[1].x = ctrlPoints[1].x;
|
||||
shapeCtrlPoints[1].y = ctrlPoints[1].y;
|
||||
this._focusShape.updateLine();
|
||||
},
|
||||
|
||||
addEvent:function (type, listener) {
|
||||
// Translate to web 2d events ...
|
||||
if (type == 'onfocus') {
|
||||
type = 'mousedown';
|
||||
}
|
||||
|
||||
var line = this._line2d;
|
||||
line.addEvent(type, listener);
|
||||
},
|
||||
|
||||
isOnFocus:function () {
|
||||
return this._onFocus;
|
||||
},
|
||||
|
||||
isInWorkspace:function () {
|
||||
return this._isInWorkspace;
|
||||
},
|
||||
|
||||
setVisibility:function (value) {
|
||||
this.parent(value);
|
||||
if (this._showEndArrow)
|
||||
this._endArrow.setVisibility(this._showEndArrow);
|
||||
this._startArrow.setVisibility(this._showStartArrow && value);
|
||||
},
|
||||
|
||||
setOpacity:function (opacity) {
|
||||
this.parent(opacity);
|
||||
if (this._showEndArrow)
|
||||
this._endArrow.setOpacity(opacity);
|
||||
if (this._showStartArrow)
|
||||
this._startArrow.setOpacity(opacity);
|
||||
},
|
||||
|
||||
setShowEndArrow:function (visible) {
|
||||
this._showEndArrow = visible;
|
||||
if (this._isInWorkspace)
|
||||
this.redraw();
|
||||
},
|
||||
|
||||
setShowStartArrow:function (visible) {
|
||||
this._showStartArrow = visible;
|
||||
if (this._isInWorkspace)
|
||||
this.redraw();
|
||||
},
|
||||
|
||||
setFrom:function (x, y) {
|
||||
$assert($defined(x), "x must be defined");
|
||||
$assert($defined(y), "y must be defined");
|
||||
|
||||
this._line2d.setFrom(x, y);
|
||||
this._startArrow.setFrom(x, y);
|
||||
},
|
||||
|
||||
setTo:function (x, y) {
|
||||
$assert($defined(x), "x must be defined");
|
||||
$assert($defined(y), "y must be defined");
|
||||
|
||||
this._line2d.setTo(x, y);
|
||||
if (this._endArrow)
|
||||
this._endArrow.setFrom(x, y);
|
||||
},
|
||||
|
||||
setSrcControlPoint:function (control) {
|
||||
this._line2d.setSrcControlPoint(control);
|
||||
this._startArrow.setControlPoint(control);
|
||||
},
|
||||
|
||||
setDestControlPoint:function (control) {
|
||||
this._line2d.setDestControlPoint(control);
|
||||
if (this._showEndArrow)
|
||||
this._endArrow.setControlPoint(control);
|
||||
},
|
||||
|
||||
getControlPoints:function () {
|
||||
return this._line2d.getControlPoints();
|
||||
},
|
||||
|
||||
isSrcControlPointCustom:function () {
|
||||
return this._line2d.isSrcControlPointCustom();
|
||||
},
|
||||
|
||||
isDestControlPointCustom:function () {
|
||||
return this._line2d.isDestControlPointCustom();
|
||||
},
|
||||
|
||||
setIsSrcControlPointCustom:function (isCustom) {
|
||||
this._line2d.setIsSrcControlPointCustom(isCustom);
|
||||
},
|
||||
|
||||
setIsDestControlPointCustom:function (isCustom) {
|
||||
this._line2d.setIsDestControlPointCustom(isCustom);
|
||||
},
|
||||
|
||||
getId:function () {
|
||||
return this._model.getId();
|
||||
},
|
||||
|
||||
fireEvent:function (type, event) {
|
||||
var elem = this._line2d;
|
||||
elem.fireEvent(type, event);
|
||||
}
|
||||
});
|
|
@ -1,158 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.RelationshipPivot = new Class({
|
||||
initialize:function (workspace, designer) {
|
||||
$assert(workspace, "workspace can not be null");
|
||||
$assert(designer, "designer can not be null");
|
||||
this._workspace = workspace;
|
||||
this._designer = designer;
|
||||
|
||||
this._mouseMoveEvent = this._mouseMove.bind(this);
|
||||
this._onClickEvent = this._cleanOnMouseClick.bind(this);
|
||||
this._onTopicClick = this._connectOnFocus.bind(this);
|
||||
|
||||
},
|
||||
|
||||
start:function (sourceTopic, targetPos) {
|
||||
$assert(sourceTopic, "sourceTopic can not be null");
|
||||
$assert(targetPos, "targetPos can not be null");
|
||||
|
||||
this.dispose();
|
||||
this._sourceTopic = sourceTopic;
|
||||
if (sourceTopic != null) {
|
||||
this._workspace.enableWorkspaceEvents(false);
|
||||
|
||||
var sourcePos = sourceTopic.getPosition();
|
||||
var strokeColor = mindplot.Relationship.getStrokeColor();
|
||||
|
||||
this._pivot = new web2d.CurvedLine();
|
||||
this._pivot.setStyle(web2d.CurvedLine.SIMPLE_LINE);
|
||||
|
||||
var fromPos = this._calculateFromPosition(sourcePos);
|
||||
this._pivot.setFrom(fromPos.x, fromPos.y);
|
||||
|
||||
this._pivot.setTo(targetPos.x, targetPos.y);
|
||||
this._pivot.setStroke(2, 'solid', strokeColor);
|
||||
this._pivot.setDashed(4, 2);
|
||||
|
||||
this._startArrow = new web2d.Arrow();
|
||||
this._startArrow.setStrokeColor(strokeColor);
|
||||
this._startArrow.setStrokeWidth(2);
|
||||
this._startArrow.setFrom(sourcePos.x, sourcePos.y);
|
||||
|
||||
this._workspace.appendChild(this._pivot);
|
||||
this._workspace.appendChild(this._startArrow);
|
||||
|
||||
this._workspace.addEvent('mousemove', this._mouseMoveEvent);
|
||||
this._workspace.addEvent('click', this._onClickEvent);
|
||||
|
||||
// Register focus events on all topics ...
|
||||
var model = this._designer.getModel();
|
||||
var topics = model.getTopics();
|
||||
topics.each(function (topic) {
|
||||
topic.addEvent('ontfocus', this._onTopicClick);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
dispose:function () {
|
||||
var workspace = this._workspace;
|
||||
|
||||
if (this._isActive()) {
|
||||
workspace.removeEvent('mousemove', this._mouseMoveEvent);
|
||||
workspace.removeEvent('click', this._onClickEvent);
|
||||
|
||||
var model = this._designer.getModel();
|
||||
var topics = model.getTopics();
|
||||
topics.each(function (topic) {
|
||||
topic.removeEvent('ontfocus', this._onTopicClick);
|
||||
}.bind(this));
|
||||
|
||||
workspace.removeChild(this._pivot);
|
||||
workspace.removeChild(this._startArrow);
|
||||
workspace.enableWorkspaceEvents(true);
|
||||
|
||||
this._sourceTopic = null;
|
||||
this._pivot = null;
|
||||
this._startArrow = null;
|
||||
}
|
||||
},
|
||||
|
||||
_mouseMove:function (event) {
|
||||
var screen = this._workspace.getScreenManager();
|
||||
var pos = screen.getWorkspaceMousePosition(event);
|
||||
|
||||
// Leave the arrow a couple of pixels away from the cursor.
|
||||
var sourcePosition = this._sourceTopic.getPosition();
|
||||
var gapDistance = Math.sign(pos.x - sourcePosition.x) * 5;
|
||||
|
||||
var sPos = this._calculateFromPosition(pos);
|
||||
this._pivot.setFrom(sPos.x, sPos.y);
|
||||
|
||||
// Update target position ...
|
||||
this._pivot.setTo(pos.x - gapDistance, pos.y);
|
||||
|
||||
var controlPoints = this._pivot.getControlPoints();
|
||||
this._startArrow.setFrom(pos.x - gapDistance, pos.y);
|
||||
this._startArrow.setControlPoint(controlPoints[1]);
|
||||
|
||||
event.stopPropagation();
|
||||
return false;
|
||||
},
|
||||
|
||||
_cleanOnMouseClick:function (event) {
|
||||
|
||||
// The user clicks on a desktop on in other element that is not a node.
|
||||
this.dispose();
|
||||
event.stopPropagation();
|
||||
},
|
||||
|
||||
_calculateFromPosition:function (toPosition) {
|
||||
|
||||
// Calculate origin position ...
|
||||
var sourcePosition = this._sourceTopic.getPosition();
|
||||
if (this._sourceTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
||||
sourcePosition = mindplot.util.Shape.workoutIncomingConnectionPoint(this._sourceTopic, toPosition);
|
||||
}
|
||||
var controlPoint = mindplot.util.Shape.calculateDefaultControlPoints(sourcePosition, toPosition);
|
||||
|
||||
var spoint = new core.Point();
|
||||
spoint.x = parseInt(controlPoint[0].x) + parseInt(sourcePosition.x);
|
||||
spoint.y = parseInt(controlPoint[0].y) + parseInt(sourcePosition.y);
|
||||
return mindplot.util.Shape.calculateRelationShipPointCoordinates(this._sourceTopic, spoint);
|
||||
},
|
||||
|
||||
_connectOnFocus:function (targetTopic) {
|
||||
var sourceTopic = this._sourceTopic;
|
||||
var mindmap = this._designer.getMindmap();
|
||||
|
||||
// Avoid circular connections ...
|
||||
if (targetTopic.getId() != sourceTopic.getId()) {
|
||||
var relModel = mindmap.createRelationship(targetTopic.getId(), sourceTopic.getId());
|
||||
this._designer._actionDispatcher.addRelationship(relModel);
|
||||
}
|
||||
this.dispose();
|
||||
},
|
||||
|
||||
_isActive:function () {
|
||||
return this._pivot != null;
|
||||
}
|
||||
});
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.RESTPersistenceManager = new Class({
|
||||
Extends:mindplot.PersistenceManager,
|
||||
initialize:function (options) {
|
||||
this.parent();
|
||||
$assert(options.documentUrl, "documentUrl can not be null");
|
||||
$assert(options.revertUrl, "revertUrl can not be null");
|
||||
$assert(options.lockUrl, "lockUrl can not be null");
|
||||
$assert(options.session, "session can not be null");
|
||||
$assert(options.timestamp, "timestamp can not be null");
|
||||
|
||||
this.documentUrl = options.documentUrl;
|
||||
this.revertUrl = options.revertUrl;
|
||||
this.lockUrl = options.lockUrl;
|
||||
this.timestamp = options.timestamp;
|
||||
this.session = options.session;
|
||||
},
|
||||
|
||||
saveMapXml:function (mapId, mapXml, pref, saveHistory, events, sync) {
|
||||
|
||||
var data = {
|
||||
id:mapId,
|
||||
xml:mapXml,
|
||||
properties:pref
|
||||
};
|
||||
|
||||
var persistence = this;
|
||||
var query = "minor=" + !saveHistory;
|
||||
query = query + "×tamp=" + this.timestamp;
|
||||
query = query + "&session=" + this.session;
|
||||
|
||||
if (!persistence.onSave) {
|
||||
|
||||
// Mark save in process and fire a event unlocking the save ...
|
||||
persistence.onSave = true;
|
||||
persistence.clearTimeout = setTimeout(function () {
|
||||
persistence.clearTimeout = null;
|
||||
persistence.onSave = false;
|
||||
}, 10000);
|
||||
|
||||
var request = new Request({
|
||||
url:this.documentUrl.replace("{id}", mapId) + "?" + query,
|
||||
method:'put',
|
||||
async:!sync,
|
||||
|
||||
onSuccess:function (responseText, responseXML) {
|
||||
persistence.timestamp = responseText;
|
||||
events.onSuccess();
|
||||
},
|
||||
|
||||
onException:function (headerName, value) {
|
||||
events.onError(persistence._buildError());
|
||||
},
|
||||
|
||||
onComplete:function () {
|
||||
// Clear event timeout ...
|
||||
if (persistence.clearTimeout) {
|
||||
clearTimeout(persistence.clearTimeout);
|
||||
}
|
||||
persistence.onSave = false;
|
||||
},
|
||||
|
||||
onFailure:function (xhr) {
|
||||
|
||||
var responseText = xhr.responseText;
|
||||
var userMsg = {severity:"SEVERE", message:$msg('SAVE_COULD_NOT_BE_COMPLETED')};
|
||||
|
||||
var contentType = this.getHeader("Content-Type");
|
||||
if (contentType != null && contentType.indexOf("application/json") != -1) {
|
||||
var serverMsg = null;
|
||||
try {
|
||||
serverMsg = JSON.decode(responseText);
|
||||
serverMsg = serverMsg.globalSeverity ? serverMsg : null;
|
||||
} catch (e) {
|
||||
// Message could not be decoded ...
|
||||
}
|
||||
userMsg = persistence._buildError(serverMsg);
|
||||
|
||||
} else {
|
||||
if (this.status == 405) {
|
||||
userMsg = {severity:"SEVERE", message:$msg('SESSION_EXPIRED')};
|
||||
}
|
||||
}
|
||||
events.onError(userMsg);
|
||||
persistence.onSave = false;
|
||||
},
|
||||
|
||||
headers:{"Content-Type":"application/json; charset=utf-8", "Accept":"application/json"},
|
||||
emulation:false,
|
||||
urlEncoded:false
|
||||
});
|
||||
request.put(JSON.encode(data));
|
||||
}
|
||||
},
|
||||
|
||||
discardChanges:function (mapId) {
|
||||
var request = new Request({
|
||||
url:this.revertUrl.replace("{id}", mapId),
|
||||
async:false,
|
||||
method:'post',
|
||||
onSuccess:function () {
|
||||
},
|
||||
onException:function () {
|
||||
},
|
||||
onFailure:function () {
|
||||
},
|
||||
headers:{"Content-Type":"application/json; charset=utf-8", "Accept":"application/json"},
|
||||
emulation:false,
|
||||
urlEncoded:false
|
||||
});
|
||||
request.post();
|
||||
},
|
||||
|
||||
unlockMap:function (mindmap) {
|
||||
var mapId = mindmap.getId();
|
||||
var request = new Request({
|
||||
url:this.lockUrl.replace("{id}", mapId),
|
||||
async:false,
|
||||
method:'put',
|
||||
onSuccess:function () {
|
||||
|
||||
},
|
||||
onException:function () {
|
||||
},
|
||||
onFailure:function () {
|
||||
},
|
||||
headers:{"Content-Type":"text/plain"},
|
||||
emulation:false,
|
||||
urlEncoded:false
|
||||
});
|
||||
request.put("false");
|
||||
},
|
||||
|
||||
_buildError:function (jsonSeverResponse) {
|
||||
var message = jsonSeverResponse ? jsonSeverResponse.globalErrors[0] : null;
|
||||
var severity = jsonSeverResponse ? jsonSeverResponse.globalSeverity : null;
|
||||
|
||||
if (!message) {
|
||||
message = $msg('SAVE_COULD_NOT_BE_COMPLETED');
|
||||
}
|
||||
|
||||
if (!severity) {
|
||||
severity = "INFO";
|
||||
}
|
||||
return {severity:severity, message:message};
|
||||
},
|
||||
|
||||
loadMapDom:function (mapId) {
|
||||
// Let's try to open one from the local directory ...
|
||||
var xml;
|
||||
var xmlRequest = new Request({
|
||||
url:this.documentUrl.replace("{id}", mapId) + "/xml",
|
||||
method:'get',
|
||||
async:false,
|
||||
headers:{"Content-Type":"text/plain","Accept":"application/xml"},
|
||||
onSuccess:function (responseText) {
|
||||
xml = responseText;
|
||||
}
|
||||
});
|
||||
xmlRequest.send();
|
||||
|
||||
// If I could not load it from a file, hard code one.
|
||||
if (xml == null) {
|
||||
throw new Error("Map could not be loaded");
|
||||
}
|
||||
|
||||
var parser = new DOMParser();
|
||||
return parser.parseFromString(xml, "text/xml");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ScreenManager = new Class({
|
||||
initialize:function(divElement) {
|
||||
$assert(divElement, "can not be null");
|
||||
this._divContainer = divElement;
|
||||
this._padding = {x:0,y:0};
|
||||
|
||||
// Ignore default click event propagation. Prevent 'click' event on drag.
|
||||
this._clickEvents = [];
|
||||
this._divContainer.addEvent('click', function(event) {
|
||||
event.stopPropagation()
|
||||
}.bind(this));
|
||||
|
||||
this._divContainer.addEvent('dblclick', function(event) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
});
|
||||
},
|
||||
|
||||
setScale : function(scale) {
|
||||
$assert(scale, 'Screen scale can not be null');
|
||||
this._scale = scale;
|
||||
},
|
||||
|
||||
addEvent : function(event, listener) {
|
||||
if (event == 'click')
|
||||
this._clickEvents.push(listener);
|
||||
else
|
||||
this._divContainer.addEvent(event, listener);
|
||||
},
|
||||
|
||||
removeEvent : function(event, listener) {
|
||||
if (event == 'click') {
|
||||
this._clickEvents.remove(listener);
|
||||
}
|
||||
else{
|
||||
this._divContainer.removeEvent(event, listener);
|
||||
}
|
||||
},
|
||||
|
||||
fireEvent : function(type, event) {
|
||||
if (type == 'click') {
|
||||
this._clickEvents.each(function(listener) {
|
||||
listener(type, event);
|
||||
});
|
||||
}
|
||||
else {
|
||||
this._divContainer.fireEvent(type, event);
|
||||
}
|
||||
},
|
||||
|
||||
_getElementPosition : function(elem) {
|
||||
// Retrieve current element position.
|
||||
var elementPosition = elem.getPosition();
|
||||
var x = elementPosition.x;
|
||||
var y = elementPosition.y;
|
||||
|
||||
// Add workspace offset.
|
||||
x = x - this._padding.x;
|
||||
y = y - this._padding.y;
|
||||
|
||||
// Scale coordinate in order to be relative to the workspace. That's coord/size;
|
||||
x = x / this._scale;
|
||||
y = y / this._scale;
|
||||
|
||||
// Remove decimal part..
|
||||
return {x:x,y:y};
|
||||
},
|
||||
|
||||
getWorkspaceIconPosition : function(e) {
|
||||
// Retrieve current icon position.
|
||||
var image = e.getImage();
|
||||
var elementPosition = image.getPosition();
|
||||
var imageSize = e.getSize();
|
||||
|
||||
//Add group offset
|
||||
var iconGroup = e.getGroup();
|
||||
var group = iconGroup.getNativeElement();
|
||||
var coordOrigin = group.getCoordOrigin();
|
||||
var groupSize = group.getSize();
|
||||
var coordSize = group.getCoordSize();
|
||||
|
||||
var scale = {x:coordSize.width / parseInt(groupSize.width), y:coordSize.height / parseInt(groupSize.height)};
|
||||
|
||||
var x = (elementPosition.x - coordOrigin.x - (parseInt(imageSize.width) / 2)) / scale.x;
|
||||
var y = (elementPosition.y - coordOrigin.y - (parseInt(imageSize.height) / 2)) / scale.y;
|
||||
|
||||
//Retrieve iconGroup Position
|
||||
var groupPosition = iconGroup.getPosition();
|
||||
x = x + groupPosition.x;
|
||||
y = y + groupPosition.y;
|
||||
|
||||
//Retrieve topic Position
|
||||
var topic = iconGroup.getTopic();
|
||||
var topicPosition = this._getElementPosition(topic);
|
||||
topicPosition.x = topicPosition.x - (parseInt(topic.getSize().width) / 2);
|
||||
|
||||
// Remove decimal part..
|
||||
return {x:x + topicPosition.x,y:y + topicPosition.y};
|
||||
},
|
||||
|
||||
getWorkspaceMousePosition : function(event) {
|
||||
// Retrieve current mouse position.
|
||||
var x = event.client.x;
|
||||
var y = event.client.y;
|
||||
|
||||
// Subtract div position.
|
||||
var containerPosition = this.getContainer().getPosition();
|
||||
x = x - containerPosition.x;
|
||||
y = y - containerPosition.y;
|
||||
|
||||
// Scale coordinate in order to be relative to the workspace. That's coordSize/size;
|
||||
x = x * this._scale;
|
||||
y = y * this._scale;
|
||||
|
||||
// Add workspace offset.
|
||||
x = x + this._padding.x;
|
||||
y = y + this._padding.y;
|
||||
|
||||
// Remove decimal part..
|
||||
return new core.Point(x, y);
|
||||
},
|
||||
|
||||
getContainer : function() {
|
||||
return this._divContainer;
|
||||
},
|
||||
|
||||
setOffset : function(x, y) {
|
||||
this._padding.x = x;
|
||||
this._padding.y = y;
|
||||
}
|
||||
});
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.ShirinkConnector = new Class({
|
||||
initialize: function(topic) {
|
||||
|
||||
var ellipse = new web2d.Elipse(mindplot.Topic.prototype.INNER_RECT_ATTRIBUTES);
|
||||
this._ellipse = ellipse;
|
||||
ellipse.setFill('rgb(62,118,179)');
|
||||
|
||||
ellipse.setSize(mindplot.Topic.CONNECTOR_WIDTH, mindplot.Topic.CONNECTOR_WIDTH);
|
||||
ellipse.addEvent('click', function(event) {
|
||||
var model = topic.getModel();
|
||||
var collapse = !model.areChildrenShrunken();
|
||||
|
||||
var topicId = topic.getId();
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.shrinkBranch([topicId], collapse);
|
||||
|
||||
event.stopPropagation();
|
||||
|
||||
});
|
||||
|
||||
ellipse.addEvent('mousedown', function(event) {
|
||||
// Avoid node creation ...
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
ellipse.addEvent('dblclick', function(event) {
|
||||
// Avoid node creation ...
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
ellipse.addEvent('mouseover', function(event) {
|
||||
|
||||
ellipse.setFill('rgb(153, 0, 255)');
|
||||
});
|
||||
|
||||
ellipse.addEvent('mouseout', function(event) {
|
||||
var color = topic.getBackgroundColor();
|
||||
this.setFill(color);
|
||||
}.bind(this));
|
||||
|
||||
ellipse.setCursor('default');
|
||||
this._fillColor = '#f7f7f7';
|
||||
var model = topic.getModel();
|
||||
this.changeRender(model.areChildrenShrunken());
|
||||
|
||||
},
|
||||
|
||||
changeRender: function(isShrink) {
|
||||
var elipse = this._ellipse;
|
||||
if (isShrink) {
|
||||
elipse.setStroke('2', 'solid');
|
||||
} else {
|
||||
elipse.setStroke('1', 'solid');
|
||||
}
|
||||
},
|
||||
|
||||
setVisibility: function(value) {
|
||||
this._ellipse.setVisibility(value);
|
||||
},
|
||||
|
||||
setOpacity: function(opacity) {
|
||||
this._ellipse.setOpacity(opacity);
|
||||
},
|
||||
|
||||
setFill: function(color) {
|
||||
this._fillColor = color;
|
||||
this._ellipse.setFill(color);
|
||||
},
|
||||
|
||||
setAttribute: function(name, value) {
|
||||
this._ellipse.setAttribute(name, value);
|
||||
},
|
||||
|
||||
addToWorkspace: function(group) {
|
||||
group.appendChild(this._ellipse);
|
||||
},
|
||||
|
||||
setPosition: function(x, y) {
|
||||
this._ellipse.setPosition(x, y);
|
||||
},
|
||||
|
||||
moveToBack: function() {
|
||||
this._ellipse.moveToBack();
|
||||
},
|
||||
|
||||
moveToFront: function() {
|
||||
this._ellipse.moveToFront();
|
||||
}
|
||||
});
|
|
@ -1,314 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.StandaloneActionDispatcher = new Class({
|
||||
Extends:mindplot.ActionDispatcher,
|
||||
initialize:function (commandContext) {
|
||||
this.parent(commandContext);
|
||||
this._actionRunner = new mindplot.DesignerActionRunner(commandContext, this);
|
||||
},
|
||||
|
||||
addTopics:function (models, parentTopicsId) {
|
||||
var command = new mindplot.commands.AddTopicCommand(models, parentTopicsId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
addRelationship:function (model) {
|
||||
var command = new mindplot.commands.AddRelationshipCommand(model);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
deleteEntities:function (topicsIds, relIds) {
|
||||
var command = new mindplot.commands.DeleteCommand(topicsIds, relIds);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
dragTopic:function (topicId, position, order, parentTopic) {
|
||||
var command = new mindplot.commands.DragTopicCommand(topicId, position, order, parentTopic);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
moveTopic:function (topicId, position) {
|
||||
$assert($defined(topicId), "topicsId can not be null");
|
||||
$assert($defined(position), "position can not be null");
|
||||
|
||||
var commandFunc = function (topic, value) {
|
||||
var result = topic.getPosition();
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent, {node:topic.getModel(), position:value});
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicId, position);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
moveControlPoint:function (ctrlPoint, point) {
|
||||
var command = new mindplot.commands.MoveControlPointCommand(ctrlPoint, point);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontStyleToTopic:function (topicsIds) {
|
||||
|
||||
var commandFunc = function (topic) {
|
||||
var result = topic.getFontStyle();
|
||||
var style = (result == "italic") ? "normal" : "italic";
|
||||
topic.setFontStyle(style, true);
|
||||
return result;
|
||||
};
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
|
||||
},
|
||||
|
||||
changeTextToTopic:function (topicsIds, text) {
|
||||
$assert($defined(topicsIds), "topicsIds can not be null");
|
||||
|
||||
var commandFunc = function (topic, value) {
|
||||
var result = topic.getText();
|
||||
topic.setText(value);
|
||||
return result;
|
||||
};
|
||||
commandFunc.commandType = "changeTextToTopic";
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, text);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontFamilyToTopic:function (topicIds, fontFamily) {
|
||||
$assert(topicIds, "topicIds can not be null");
|
||||
$assert(fontFamily, "fontFamily can not be null");
|
||||
|
||||
|
||||
var commandFunc = function (topic, fontFamily) {
|
||||
var result = topic.getFontFamily();
|
||||
topic.setFontFamily(fontFamily, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicIds, fontFamily);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontColorToTopic:function (topicsIds, color) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(color, "color can not be null");
|
||||
|
||||
var commandFunc = function (topic, color) {
|
||||
var result = topic.getFontColor();
|
||||
topic.setFontColor(color, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = "fontColorCommandId";
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeBackgroundColorToTopic:function (topicsIds, color) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(color, "color can not be null");
|
||||
|
||||
var commandFunc = function (topic, color) {
|
||||
var result = topic.getBackgroundColor();
|
||||
topic.setBackgroundColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = "backColor";
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeBorderColorToTopic:function (topicsIds, color) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(color, "topicIds can not be null");
|
||||
|
||||
var commandFunc = function (topic, color) {
|
||||
var result = topic.getBorderColor();
|
||||
topic.setBorderColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = "borderColorCommandId";
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontSizeToTopic:function (topicsIds, size) {
|
||||
$assert(topicsIds, "topicIds can not be null");
|
||||
$assert(size, "size can not be null");
|
||||
|
||||
var commandFunc = function (topic, size) {
|
||||
var result = topic.getFontSize();
|
||||
topic.setFontSize(size, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, size);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeShapeTypeToTopic:function (topicsIds, shapeType) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
$assert(shapeType, "shapeType can not be null");
|
||||
|
||||
var commandFunc = function (topic, shapeType) {
|
||||
var result = topic.getShapeType();
|
||||
topic.setShapeType(shapeType, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, shapeType);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFontWeightToTopic:function (topicsIds) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
|
||||
var commandFunc = function (topic) {
|
||||
var result = topic.getFontWeight();
|
||||
var weight = (result == "bold") ? "normal" : "bold";
|
||||
topic.setFontWeight(weight, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
shrinkBranch:function (topicsIds, collapse) {
|
||||
$assert(topicsIds, "topicsIds can not be null");
|
||||
|
||||
var commandFunc = function (topic, isShrink) {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
return !isShrink;
|
||||
};
|
||||
|
||||
var command = new mindplot.commands.GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
||||
this.execute(command, false);
|
||||
},
|
||||
|
||||
addFeatureToTopic:function (topicId, featureType, attributes) {
|
||||
var command = new mindplot.commands.AddFeatureToTopicCommand(topicId, featureType, attributes);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
changeFeatureToTopic:function (topicId, featureId, attributes) {
|
||||
var command = new mindplot.commands.ChangeFeatureToTopicCommand(topicId, featureId, attributes);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
removeFeatureFromTopic:function (topicId, featureId) {
|
||||
var command = new mindplot.commands.RemoveFeatureFromTopicCommand(topicId, featureId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
execute:function (command) {
|
||||
this._actionRunner.execute(command);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.CommandContext = new Class({
|
||||
initialize:function (designer) {
|
||||
$assert(designer, "designer can not be null");
|
||||
this._designer = designer;
|
||||
},
|
||||
|
||||
findTopics:function (topicsIds) {
|
||||
$assert($defined(topicsIds), "topicsIds can not be null");
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicsIds = [topicsIds];
|
||||
}
|
||||
|
||||
var designerTopics = this._designer.getModel().getTopics();
|
||||
var result = designerTopics.filter(function (topic) {
|
||||
return topicsIds.contains(topic.getId());
|
||||
});
|
||||
|
||||
if (result.length != topicsIds.length) {
|
||||
var ids = designerTopics.map(function (topic) {
|
||||
return topic.getId();
|
||||
});
|
||||
$assert(result.length == topicsIds.length, "Could not find topic. Result:" + result + ", Filter Criteria:" + topicsIds + ", Current Topics: [" + ids + "]");
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
deleteTopic:function (topic) {
|
||||
this._designer._removeTopic(topic);
|
||||
},
|
||||
|
||||
createTopic:function (model) {
|
||||
$assert(model, "model can not be null");
|
||||
return this._designer._nodeModelToNodeGraph(model);
|
||||
},
|
||||
|
||||
createModel:function () {
|
||||
var mindmap = this._designer.getMindmap();
|
||||
return mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE);
|
||||
},
|
||||
|
||||
addTopic:function (topic) {
|
||||
var mindmap = this._designer.getMindmap();
|
||||
return mindmap.addBranch(topic.getModel());
|
||||
},
|
||||
|
||||
connect:function (childTopic, parentTopic) {
|
||||
childTopic.connectTo(parentTopic, this._designer._workspace);
|
||||
},
|
||||
|
||||
disconnect:function (topic) {
|
||||
topic.disconnect(this._designer._workspace);
|
||||
},
|
||||
|
||||
addRelationship:function (model) {
|
||||
$assert(model, "model cannot be null");
|
||||
return this._designer._addRelationship(model);
|
||||
},
|
||||
|
||||
deleteRelationship:function (relationship) {
|
||||
this._designer._deleteRelationship(relationship);
|
||||
},
|
||||
|
||||
findRelationships:function (relIds) {
|
||||
$assert($defined(relIds), "relId can not be null");
|
||||
if (!(relIds instanceof Array)) {
|
||||
relIds = [relIds];
|
||||
}
|
||||
|
||||
var designerRel = this._designer.getModel().getRelationships();
|
||||
return designerRel.filter(function (rel) {
|
||||
return relIds.contains(rel.getId());
|
||||
});
|
||||
},
|
||||
|
||||
moveTopic:function (topic, position) {
|
||||
$assert(topic, "topic cannot be null");
|
||||
$assert(position, "position cannot be null");
|
||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeMoveEvent, {node:topic.getModel(), position:position});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1,264 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.TextEditor = new Class({
|
||||
initialize:function(topic) {
|
||||
this._topic = topic;
|
||||
},
|
||||
|
||||
_buildEditor : function() {
|
||||
|
||||
this._size = {width:500, height:100};
|
||||
var result = new Element('div');
|
||||
result.setStyles({
|
||||
position:"absolute",
|
||||
display: "none",
|
||||
zIndex: "8",
|
||||
width:"500px",
|
||||
height:"100px"}
|
||||
);
|
||||
|
||||
|
||||
var inputContainer = new Element('div');
|
||||
inputContainer.setStyles({
|
||||
border:"none",
|
||||
overflow:"auto"
|
||||
});
|
||||
inputContainer.inject(result);
|
||||
|
||||
var inputText = new Element('input',
|
||||
{type:"text",
|
||||
tabindex:'-1',
|
||||
value:""}
|
||||
);
|
||||
inputText.setStyles({
|
||||
border:"none",
|
||||
background:"transparent"
|
||||
});
|
||||
inputText.inject(inputContainer);
|
||||
|
||||
var spanContainer = new Element('div');
|
||||
spanContainer.setStyle('visibility', "hidden");
|
||||
spanContainer.inject(result);
|
||||
|
||||
var spanElem = new Element('span', {tabindex:"-1"});
|
||||
spanElem.setStyle('white-space', "nowrap");
|
||||
spanElem.setStyle('nowrap', 'nowrap');
|
||||
spanElem.inject(spanContainer);
|
||||
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_registerEvents : function(divElem) {
|
||||
var inputElem = this._getTextareaElem();
|
||||
var spanElem = this._getSpanElem();
|
||||
|
||||
divElem.addEvent('keydown', function (event) {
|
||||
switch (event.key) {
|
||||
case 'esc':
|
||||
this.close(false);
|
||||
break;
|
||||
case 'enter':
|
||||
this.close(true);
|
||||
break;
|
||||
default:
|
||||
spanElem.innerHTML = inputElem.value;
|
||||
var size = inputElem.value.length + 1;
|
||||
inputElem.size = size;
|
||||
if (spanElem.offsetWidth > (parseInt(divElem.style.width) - 100)) {
|
||||
divElem.style.width = (spanElem.offsetWidth + 100) + "px";
|
||||
}
|
||||
break;
|
||||
}
|
||||
event.stopPropagation();
|
||||
}.bind(this));
|
||||
|
||||
// If the user clicks on the input, all event must be ignored ...
|
||||
divElem.addEvent('click', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
divElem.addEvent('dblclick', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
divElem.addEvent('mousedown', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
},
|
||||
|
||||
isVisible : function () {
|
||||
return $defined(this._containerElem) && this._containerElem.getStyle('display') == 'block';
|
||||
},
|
||||
|
||||
_updateModel : function () {
|
||||
|
||||
if (this._topic.getText() != this._getText()) {
|
||||
var text = this._getText();
|
||||
var topicId = this._topic.getId();
|
||||
|
||||
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
|
||||
actionDispatcher.changeTextToTopic([topicId], text);
|
||||
}
|
||||
},
|
||||
|
||||
show : function (text) {
|
||||
|
||||
if (!this.isVisible()) {
|
||||
//Create editor ui
|
||||
var editorElem = this._buildEditor();
|
||||
editorElem.inject($(document.body));
|
||||
|
||||
this._containerElem = editorElem;
|
||||
this._registerEvents(editorElem);
|
||||
this._showEditor(text);
|
||||
}
|
||||
},
|
||||
|
||||
_showEditor : function (defaultText) {
|
||||
|
||||
var topic = this._topic;
|
||||
|
||||
// Hide topic text ...
|
||||
topic.getTextShape().setVisibility(false);
|
||||
|
||||
// Set Editor Style
|
||||
var nodeText = topic.getTextShape();
|
||||
var font = nodeText.getFont();
|
||||
font.size = nodeText.getHtmlFontSize();
|
||||
font.color = nodeText.getColor();
|
||||
this._setStyle(font);
|
||||
|
||||
// Set editor's initial text
|
||||
var text = $defined(defaultText) ? defaultText : topic.getText();
|
||||
this._setText(text);
|
||||
|
||||
// Set editor's initial size
|
||||
var displayFunc = function() {
|
||||
// Position the editor and set the size...
|
||||
var textShape = this._topic.getTextShape();
|
||||
textShape.positionRelativeTo(this._containerElem, {
|
||||
position: {x: 'left',y:'top'},
|
||||
edge: {x: 'left', y: 'top'}
|
||||
});
|
||||
this._containerElem.setStyle('display', 'block');
|
||||
|
||||
// Set size ...
|
||||
var elemSize = topic.getSize();
|
||||
this._setEditorSize(elemSize.width, elemSize.height);
|
||||
|
||||
var textareaElem = this._getTextareaElem();
|
||||
textareaElem.focus();
|
||||
this._positionCursor(textareaElem, !$defined(defaultText));
|
||||
|
||||
}.bind(this);
|
||||
|
||||
displayFunc.delay(10);
|
||||
},
|
||||
|
||||
_setStyle : function (fontStyle) {
|
||||
var inputField = this._getTextareaElem();
|
||||
var spanField = this._getSpanElem();
|
||||
if (!$defined(fontStyle.font)) {
|
||||
fontStyle.font = "Arial";
|
||||
}
|
||||
if (!$defined(fontStyle.style)) {
|
||||
fontStyle.style = "normal";
|
||||
}
|
||||
if (!$defined(fontStyle.weight)) {
|
||||
fontStyle.weight = "normal";
|
||||
}
|
||||
if (!$defined(fontStyle.size)) {
|
||||
fontStyle.size = 12;
|
||||
}
|
||||
inputField.style.fontSize = fontStyle.size + "px";
|
||||
inputField.style.fontFamily = fontStyle.font;
|
||||
inputField.style.fontStyle = fontStyle.style;
|
||||
inputField.style.fontWeight = fontStyle.weight;
|
||||
inputField.style.color = fontStyle.color;
|
||||
spanField.style.fontFamily = fontStyle.font;
|
||||
spanField.style.fontStyle = fontStyle.style;
|
||||
spanField.style.fontWeight = fontStyle.weight;
|
||||
spanField.style.fontSize = fontStyle.size + "px";
|
||||
},
|
||||
|
||||
_setText : function(text) {
|
||||
var inputField = this._getTextareaElem();
|
||||
inputField.size = text.length + 1;
|
||||
this._containerElem.style.width = (inputField.size * parseInt(inputField.style.fontSize) + 100) + "px";
|
||||
var spanField = this._getSpanElem();
|
||||
spanField.innerHTML = text;
|
||||
inputField.value = text;
|
||||
},
|
||||
|
||||
_getText : function() {
|
||||
return this._getTextareaElem().value;
|
||||
},
|
||||
|
||||
_getTextareaElem : function() {
|
||||
return this._containerElem.getElement('input');
|
||||
},
|
||||
|
||||
_getSpanElem : function() {
|
||||
return this._containerElem.getElement('span');
|
||||
},
|
||||
|
||||
_setEditorSize : function (width, height) {
|
||||
var textShape = this._topic.getTextShape();
|
||||
var scale = web2d.peer.utils.TransformUtil.workoutScale(textShape._peer);
|
||||
this._size = {width:width * scale.width, height:height * scale.height};
|
||||
this._containerElem.style.width = this._size.width * 2 + "px";
|
||||
this._containerElem.style.height = this._size.height + "px";
|
||||
},
|
||||
|
||||
_positionCursor : function(inputElem, selectText) {
|
||||
// Select text if it's required ...
|
||||
if (inputElem.createTextRange) //ie
|
||||
{
|
||||
var range = inputElem.createTextRange();
|
||||
var pos = inputElem.value.length;
|
||||
if (!selectText) {
|
||||
range.select();
|
||||
range.move("character", pos);
|
||||
}
|
||||
else {
|
||||
range.move("character", pos);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
else if (!selectText) {
|
||||
inputElem.setSelectionRange(0, inputElem.value.length);
|
||||
}
|
||||
},
|
||||
|
||||
close : function(update) {
|
||||
if (this.isVisible()) {
|
||||
// Update changes ...
|
||||
if (!$defined(update) || update) {
|
||||
this._updateModel();
|
||||
}
|
||||
|
||||
// Let make the visible text in the node visible again ...
|
||||
this._topic.getTextShape().setVisibility(true);
|
||||
|
||||
// Remove it form the screen ...
|
||||
this._containerElem.dispose();
|
||||
this._containerElem = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.TextEditorFactory = {};
|
||||
|
||||
mindplot.TextEditorFactory.getTextEditorFromName = function(name) {
|
||||
var editorClass = null;
|
||||
if (name == "RichTextEditor") {
|
||||
editorClass = mindplot.RichTextEditor;
|
||||
} else {
|
||||
editorClass = mindplot.TextEditor;
|
||||
}
|
||||
return editorClass;
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.TopicEventDispatcher = new Class({
|
||||
Extends: Events,
|
||||
Static: {
|
||||
_instance: null,
|
||||
|
||||
configure: function(readOnly) {
|
||||
this._instance = new mindplot.TopicEventDispatcher(readOnly);
|
||||
},
|
||||
|
||||
getInstance : function() {
|
||||
return this._instance;
|
||||
}
|
||||
},
|
||||
|
||||
initialize:function(readOnly) {
|
||||
this._readOnly = readOnly;
|
||||
this._activeEditor = null;
|
||||
this._multilineEditor = new mindplot.MultilineTextEditor();
|
||||
},
|
||||
|
||||
close : function(update) {
|
||||
if (this.isVisible()) {
|
||||
this._activeEditor.close(update);
|
||||
this._activeEditor = null;
|
||||
}
|
||||
},
|
||||
|
||||
show : function(topic, options) {
|
||||
this.process(mindplot.TopicEvent.EDIT, topic, options);
|
||||
},
|
||||
|
||||
process : function(eventType, topic, options) {
|
||||
$assert(eventType, "eventType can not be null");
|
||||
|
||||
// Close all previous open editor ....
|
||||
if (this.isVisible()) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
// Open the new editor ...
|
||||
var model = topic.getModel();
|
||||
if (model.getShapeType() != mindplot.model.TopicShape.IMAGE && !this._readOnly && eventType == mindplot.TopicEvent.EDIT) {
|
||||
this._multilineEditor.show(topic, options ? options.text : null);
|
||||
this._activeEditor = this._multilineEditor;
|
||||
} else {
|
||||
this.fireEvent(eventType, {model:model,readOnly:this._readOnly});
|
||||
}
|
||||
},
|
||||
|
||||
isVisible: function() {
|
||||
return this._activeEditor != null && this._activeEditor.isVisible();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mindplot.TopicEvent = {
|
||||
EDIT : "editnode",
|
||||
CLICK : "clicknode"
|
||||
};
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.TopicFeature = {
|
||||
Icon:{
|
||||
id:mindplot.model.IconModel.FEATURE_TYPE,
|
||||
model:mindplot.model.IconModel,
|
||||
icon:mindplot.ImageIcon
|
||||
},
|
||||
|
||||
Link:{
|
||||
id:mindplot.model.LinkModel.FEATURE_TYPE,
|
||||
model:mindplot.model.LinkModel,
|
||||
icon:mindplot.LinkIcon
|
||||
},
|
||||
|
||||
Note:{
|
||||
id:mindplot.model.NoteModel.FEATURE_TYPE,
|
||||
model:mindplot.model.NoteModel,
|
||||
icon:mindplot.NoteIcon
|
||||
},
|
||||
|
||||
isSupported:function (id) {
|
||||
return mindplot.TopicFeature._featuresMetadataById.some(function (elem) {
|
||||
return elem.id == id;
|
||||
});
|
||||
},
|
||||
|
||||
createModel:function (type, attributes) {
|
||||
$assert(type, 'type can not be null');
|
||||
$assert(attributes, 'attributes can not be null');
|
||||
|
||||
var model = mindplot.TopicFeature._featuresMetadataById.filter(function (elem) {
|
||||
return elem.id == type;
|
||||
})[0].model;
|
||||
return new model(attributes);
|
||||
},
|
||||
|
||||
createIcon:function (topic, model, readOnly) {
|
||||
$assert(topic, 'topic can not be null');
|
||||
$assert(model, 'model can not be null');
|
||||
|
||||
var icon = mindplot.TopicFeature._featuresMetadataById.filter(function (elem) {
|
||||
return elem.id == model.getType();
|
||||
})[0].icon;
|
||||
return new icon(topic, model, readOnly);
|
||||
}
|
||||
};
|
||||
|
||||
mindplot.TopicFeature._featuresMetadataById = [mindplot.TopicFeature.Icon, mindplot.TopicFeature.Link, mindplot.TopicFeature.Note];
|
||||
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.TopicStyle = new Class({
|
||||
Static:{
|
||||
_getStyles:function (topic) {
|
||||
$assert(topic, "topic can not be null");
|
||||
|
||||
var result;
|
||||
if (topic.isCentralTopic()) {
|
||||
result = mindplot.TopicStyle.STYLES.CENTRAL_TOPIC;
|
||||
} else {
|
||||
var targetTopic = topic.getOutgoingConnectedTopic();
|
||||
if ($defined(targetTopic)) {
|
||||
if (targetTopic.isCentralTopic()) {
|
||||
result = mindplot.TopicStyle.STYLES.MAIN_TOPIC;
|
||||
} else {
|
||||
result = mindplot.TopicStyle.STYLES.SUB_TOPIC;
|
||||
}
|
||||
} else {
|
||||
result = mindplot.TopicStyle.STYLES.ISOLATED_TOPIC;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
defaultText:function (topic) {
|
||||
var msgKey = this._getStyles(topic).msgKey;
|
||||
return $msg(msgKey);
|
||||
},
|
||||
|
||||
defaultFontStyle:function (topic) {
|
||||
return this._getStyles(topic).fontStyle;
|
||||
},
|
||||
|
||||
defaultBackgroundColor:function (topic) {
|
||||
return this._getStyles(topic).backgroundColor;
|
||||
},
|
||||
|
||||
defaultBorderColor:function (topic) {
|
||||
return this._getStyles(topic).borderColor;
|
||||
},
|
||||
|
||||
getInnerPadding:function (topic) {
|
||||
return this._getStyles(topic).innerPadding;
|
||||
},
|
||||
|
||||
defaultShapeType:function (topic) {
|
||||
return this._getStyles(topic).shapeType;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.TopicStyle.STYLES =
|
||||
{
|
||||
CENTRAL_TOPIC:{
|
||||
borderColor:'rgb(57,113,177)',
|
||||
backgroundColor:'rgb(80,157,192)',
|
||||
fontStyle:{
|
||||
font:"Verdana",
|
||||
size:10,
|
||||
style:"normal",
|
||||
weight:"bold",
|
||||
color:"#ffffff"
|
||||
},
|
||||
msgKey:'CENTRAL_TOPIC',
|
||||
innerPadding:11,
|
||||
shapeType:mindplot.model.TopicShape.ROUNDED_RECT
|
||||
},
|
||||
|
||||
MAIN_TOPIC:{
|
||||
borderColor:'rgb(2,59,185)',
|
||||
backgroundColor:'rgb(224,229,239)',
|
||||
fontStyle:{
|
||||
font:"Arial",
|
||||
size:8,
|
||||
style:"normal",
|
||||
weight:"normal",
|
||||
color:"rgb(82,92,97)"
|
||||
},
|
||||
msgKey:'MAIN_TOPIC',
|
||||
innerPadding:3,
|
||||
shapeType:mindplot.model.TopicShape.LINE
|
||||
|
||||
},
|
||||
|
||||
SUB_TOPIC:{
|
||||
borderColor:'rgb(2,59,185)',
|
||||
backgroundColor:'rgb(224,229,239)',
|
||||
fontStyle:{
|
||||
font:"Arial",
|
||||
size:6,
|
||||
style:"normal",
|
||||
weight:"normal",
|
||||
color:"rgb(82,92,97)"
|
||||
},
|
||||
msgKey:'SUB_TOPIC',
|
||||
innerPadding:3,
|
||||
shapeType:mindplot.model.TopicShape.LINE
|
||||
},
|
||||
|
||||
ISOLATED_TOPIC:{
|
||||
borderColor:'rgb(2,59,185)',
|
||||
backgroundColor:'rgb(224,229,239)',
|
||||
fontStyle:{
|
||||
font:"Verdana",
|
||||
size:8,
|
||||
style:"normal",
|
||||
weight:"normal",
|
||||
color:"rgb(82,92,97)"
|
||||
},
|
||||
msgKey:'ISOLATED_TOPIC',
|
||||
innerPadding:4,
|
||||
shapeType:mindplot.model.TopicShape.LINE
|
||||
}
|
||||
};
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.Workspace = new Class({
|
||||
initialize: function(screenManager, zoom) {
|
||||
// Create a suitable container ...
|
||||
$assert(screenManager, 'Div container can not be null');
|
||||
$assert(zoom, 'zoom container can not be null');
|
||||
|
||||
this._zoom = zoom;
|
||||
this._screenManager = screenManager;
|
||||
|
||||
var divContainer = screenManager.getContainer();
|
||||
this._screenWidth = parseInt(divContainer.getStyle('width'));
|
||||
this._screenHeight = parseInt(divContainer.getStyle('height'));
|
||||
|
||||
// Initialize web2d workspace.
|
||||
var workspace = this._createWorkspace();
|
||||
this._workspace = workspace;
|
||||
|
||||
// Append to the workspace...
|
||||
workspace.addItAsChildTo(divContainer);
|
||||
this.setZoom(zoom, true);
|
||||
|
||||
// Register drag events ...
|
||||
this._registerDragEvents();
|
||||
this._eventsEnabled = true;
|
||||
},
|
||||
|
||||
_createWorkspace: function() {
|
||||
// Initialize workspace ...
|
||||
var coordOriginX = -(this._screenWidth / 2);
|
||||
var coordOriginY = -(this._screenHeight / 2);
|
||||
|
||||
var workspaceProfile = {
|
||||
width: this._screenWidth + "px",
|
||||
height: this._screenHeight + "px",
|
||||
coordSizeWidth:this._screenWidth,
|
||||
coordSizeHeight:this._screenHeight,
|
||||
coordOriginX:coordOriginX,
|
||||
coordOriginY:coordOriginY,
|
||||
fillColor:'transparent',
|
||||
strokeWidth:0
|
||||
};
|
||||
web2d.peer.Toolkit.init();
|
||||
return new web2d.Workspace(workspaceProfile);
|
||||
},
|
||||
|
||||
appendChild: function(shape) {
|
||||
if ($defined(shape.addToWorkspace)) {
|
||||
shape.addToWorkspace(this);
|
||||
} else {
|
||||
this._workspace.appendChild(shape);
|
||||
}
|
||||
},
|
||||
|
||||
removeChild: function(shape) {
|
||||
// Element is a node, not a web2d element?
|
||||
if ($defined(shape.removeFromWorkspace)) {
|
||||
shape.removeFromWorkspace(this);
|
||||
} else {
|
||||
this._workspace.removeChild(shape);
|
||||
}
|
||||
},
|
||||
|
||||
addEvent: function(type, listener) {
|
||||
this._workspace.addEvent(type, listener);
|
||||
},
|
||||
|
||||
removeEvent: function(type, listener) {
|
||||
$assert(type, 'type can not be null');
|
||||
$assert(listener, 'listener can not be null');
|
||||
this._workspace.removeEvent(type, listener);
|
||||
},
|
||||
|
||||
getSize: function() {
|
||||
return this._workspace.getCoordSize();
|
||||
},
|
||||
|
||||
setZoom: function(zoom, center) {
|
||||
this._zoom = zoom;
|
||||
var workspace = this._workspace;
|
||||
|
||||
// Update coord scale...
|
||||
var coordWidth = zoom * this._screenWidth;
|
||||
var coordHeight = zoom * this._screenHeight;
|
||||
workspace.setCoordSize(coordWidth, coordHeight);
|
||||
|
||||
// View port coords ...
|
||||
if (this._viewPort) {
|
||||
this._viewPort.width = this._viewPort.width * zoom;
|
||||
this._viewPort.height = this._viewPort.height * zoom;
|
||||
}
|
||||
|
||||
// Center topic....
|
||||
var coordOriginX;
|
||||
var coordOriginY;
|
||||
|
||||
if (center) {
|
||||
if (this._viewPort) {
|
||||
coordOriginX = -(this._viewPort.width / 2);
|
||||
coordOriginY = -(this._viewPort.height / 2);
|
||||
} else {
|
||||
coordOriginX = -(coordWidth / 2);
|
||||
coordOriginY = -(coordHeight / 2);
|
||||
}
|
||||
} else {
|
||||
var coordOrigin = workspace.getCoordOrigin();
|
||||
coordOriginX = coordOrigin.x;
|
||||
coordOriginY = coordOrigin.y;
|
||||
}
|
||||
|
||||
workspace.setCoordOrigin(coordOriginX, coordOriginY);
|
||||
|
||||
// Update screen.
|
||||
this._screenManager.setOffset(coordOriginX, coordOriginY);
|
||||
this._screenManager.setScale(zoom);
|
||||
|
||||
// Some changes in the screen. Let's fire an update event...
|
||||
this._screenManager.fireEvent('update');
|
||||
},
|
||||
|
||||
getScreenManager: function() {
|
||||
return this._screenManager;
|
||||
},
|
||||
|
||||
enableWorkspaceEvents: function(value) {
|
||||
this._eventsEnabled = value;
|
||||
},
|
||||
|
||||
isWorkspaceEventsEnabled: function() {
|
||||
return this._eventsEnabled;
|
||||
},
|
||||
|
||||
dumpNativeChart: function() {
|
||||
return this._workspace.dumpNativeChart();
|
||||
},
|
||||
|
||||
_registerDragEvents: function() {
|
||||
var workspace = this._workspace;
|
||||
var screenManager = this._screenManager;
|
||||
var mWorkspace = this;
|
||||
var mouseDownListener = function(event) {
|
||||
if (!$defined(workspace._mouseMoveListener)) {
|
||||
if (mWorkspace.isWorkspaceEventsEnabled()) {
|
||||
mWorkspace.enableWorkspaceEvents(false);
|
||||
|
||||
var mouseDownPosition = screenManager.getWorkspaceMousePosition(event);
|
||||
var originalCoordOrigin = workspace.getCoordOrigin();
|
||||
|
||||
var wasDragged = false;
|
||||
workspace._mouseMoveListener = function(event) {
|
||||
|
||||
var currentMousePosition = screenManager.getWorkspaceMousePosition(event);
|
||||
|
||||
var offsetX = currentMousePosition.x - mouseDownPosition.x;
|
||||
var coordOriginX = -offsetX + originalCoordOrigin.x;
|
||||
|
||||
var offsetY = currentMousePosition.y - mouseDownPosition.y;
|
||||
var coordOriginY = -offsetY + originalCoordOrigin.y;
|
||||
|
||||
workspace.setCoordOrigin(coordOriginX, coordOriginY);
|
||||
|
||||
// Change cursor.
|
||||
if (Browser.firefox) {
|
||||
window.document.body.style.cursor = "-moz-grabbing";
|
||||
} else {
|
||||
window.document.body.style.cursor = "move";
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
// Fire drag event ...
|
||||
screenManager.fireEvent('update');
|
||||
wasDragged = true;
|
||||
|
||||
|
||||
}.bind(this);
|
||||
screenManager.addEvent('mousemove', workspace._mouseMoveListener);
|
||||
|
||||
// Register mouse up listeners ...
|
||||
workspace._mouseUpListener = function(event) {
|
||||
|
||||
screenManager.removeEvent('mousemove', workspace._mouseMoveListener);
|
||||
screenManager.removeEvent('mouseup', workspace._mouseUpListener);
|
||||
workspace._mouseUpListener = null;
|
||||
workspace._mouseMoveListener = null;
|
||||
window.document.body.style.cursor = 'default';
|
||||
|
||||
// Update screen manager offset.
|
||||
var coordOrigin = workspace.getCoordOrigin();
|
||||
screenManager.setOffset(coordOrigin.x, coordOrigin.y);
|
||||
mWorkspace.enableWorkspaceEvents(true);
|
||||
|
||||
if (!wasDragged) {
|
||||
screenManager.fireEvent('click');
|
||||
}
|
||||
};
|
||||
screenManager.addEvent('mouseup', workspace._mouseUpListener);
|
||||
}
|
||||
} else {
|
||||
workspace._mouseUpListener();
|
||||
}
|
||||
};
|
||||
screenManager.addEvent('mousedown', mouseDownListener);
|
||||
},
|
||||
|
||||
setViewPort : function(size) {
|
||||
this._viewPort = size;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.AddFeatureToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (topicId, featureType, attributes) {
|
||||
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
$assert(featureType, 'featureType can not be null');
|
||||
$assert(attributes, 'attributes can not be null');
|
||||
|
||||
this.parent();
|
||||
this._topicId = topicId;
|
||||
this._featureType = featureType;
|
||||
this._attributes = attributes;
|
||||
this._featureModel = null;
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
|
||||
// Feature must be created only one time.
|
||||
if (!this._featureModel) {
|
||||
var model = topic.getModel();
|
||||
this._featureModel = model.createFeature(this._featureType, this._attributes);
|
||||
}
|
||||
topic.addFeature(this._featureModel);
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
topic.removeFeature(this._featureModel);
|
||||
}
|
||||
});
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.commands.AddRelationshipCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (model) {
|
||||
$assert(model, 'Relationship model can not be null');
|
||||
|
||||
this.parent();
|
||||
this._model = model;
|
||||
},
|
||||
execute:function (commandContext) {
|
||||
var relationship = commandContext.addRelationship(this._model);
|
||||
relationship.setOnFocus(true);
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
var rel = commandContext.findRelationships(this._model.getId());
|
||||
commandContext.deleteRelationship(rel[0]);
|
||||
}
|
||||
});
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.AddTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (models, parentTopicsId) {
|
||||
$assert(models, 'models can not be null');
|
||||
$assert(parentTopicsId == null || parentTopicsId.length == models.length, 'parents and models must have the same size');
|
||||
|
||||
this.parent();
|
||||
this._models = models;
|
||||
this._parentsIds = parentTopicsId;
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
|
||||
this._models.each(function (model, index) {
|
||||
|
||||
// Add a new topic ...
|
||||
var topic = commandContext.createTopic(model);
|
||||
|
||||
// Connect to topic ...
|
||||
if (this._parentsIds) {
|
||||
var parentId = this._parentsIds[index];
|
||||
if ($defined(parentId)) {
|
||||
var parentTopic = commandContext.findTopics(parentId)[0];
|
||||
commandContext.connect(topic, parentTopic);
|
||||
}
|
||||
}else {
|
||||
commandContext.addTopic(topic);
|
||||
}
|
||||
|
||||
// Select just created node ...
|
||||
var designer = commandContext._designer;
|
||||
designer.onObjectFocusEvent(topic);
|
||||
topic.setOnFocus(true);
|
||||
|
||||
// Render node ...
|
||||
topic.setVisibility(true);
|
||||
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
// Delete disconnected the nodes. Create a copy of the topics ...
|
||||
var clonedModel = [];
|
||||
this._models.each(function (model) {
|
||||
clonedModel.push(model.clone());
|
||||
});
|
||||
|
||||
// Finally, remove the nodes ...
|
||||
this._models.each(function (model) {
|
||||
|
||||
var topicId = model.getId();
|
||||
var topic = commandContext.findTopics(topicId)[0];
|
||||
commandContext.deleteTopic(topic);
|
||||
}.bind(this));
|
||||
|
||||
this._models = clonedModel;
|
||||
}
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.ChangeFeatureToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, featureId, attributes) {
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
$assert($defined(featureId), 'featureId can not be null');
|
||||
$assert($defined(attributes), 'attributes can not be null');
|
||||
|
||||
this.parent();
|
||||
this._topicId = topicId;
|
||||
this._featureId = featureId;
|
||||
this._attributes = attributes;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
var feature = topic.findFeatureById(this._featureId);
|
||||
|
||||
var oldAttributes = feature.getAttributes();
|
||||
feature.setAttributes(this._attributes);
|
||||
this._attributes = oldAttributes;
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
this.execute(commandContext);
|
||||
}
|
||||
});
|
|
@ -1,169 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.DeleteCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (topicIds, relIds) {
|
||||
$assert($defined(relIds), 'topicIds can not be null');
|
||||
|
||||
this.parent();
|
||||
this._relIds = relIds;
|
||||
this._topicIds = topicIds;
|
||||
this._deletedTopicModels = [];
|
||||
this._deletedRelModel = [];
|
||||
this._parentTopicIds = [];
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
|
||||
// If a parent has been selected for deletion, the children must be excluded from the delete ...
|
||||
var topics = this._filterChildren(this._topicIds, commandContext);
|
||||
|
||||
if (topics.length > 0) {
|
||||
topics.each(function (topic) {
|
||||
// In case that it's editing text node, force close without update ...
|
||||
topic.closeEditors();
|
||||
|
||||
var model = topic.getModel();
|
||||
|
||||
// Delete relationships
|
||||
var relationships = this._collectInDepthRelationships(topic);
|
||||
this._deletedRelModel.append(relationships.map(function (rel) {
|
||||
return rel.getModel().clone();
|
||||
}));
|
||||
|
||||
relationships.each(function (relationship) {
|
||||
commandContext.deleteRelationship(relationship);
|
||||
});
|
||||
|
||||
// Store information for undo ...
|
||||
var clonedModel = model.clone();
|
||||
this._deletedTopicModels.push(clonedModel);
|
||||
var outTopic = topic.getOutgoingConnectedTopic();
|
||||
var outTopicId = null;
|
||||
if (outTopic != null) {
|
||||
outTopicId = outTopic.getId();
|
||||
}
|
||||
this._parentTopicIds.push(outTopicId);
|
||||
|
||||
// Finally, delete the topic from the workspace...
|
||||
commandContext.deleteTopic(topic);
|
||||
|
||||
}, this);
|
||||
}
|
||||
|
||||
var rels = commandContext.findRelationships(this._relIds);
|
||||
if (rels.length > 0) {
|
||||
rels.each(function (rel) {
|
||||
this._deletedRelModel.push(rel.getModel().clone());
|
||||
commandContext.deleteRelationship(rel);
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
|
||||
// Add all the topics ...
|
||||
this._deletedTopicModels.each(function (model) {
|
||||
commandContext.createTopic(model);
|
||||
}, this);
|
||||
|
||||
// Do they need to be connected ?
|
||||
this._deletedTopicModels.each(function (topicModel, index) {
|
||||
var topics = commandContext.findTopics(topicModel.getId());
|
||||
|
||||
var parentId = this._parentTopicIds[index];
|
||||
if (parentId) {
|
||||
var parentTopics = commandContext.findTopics(parentId);
|
||||
commandContext.connect(topics[0], parentTopics[0]);
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Add rebuild relationships ...
|
||||
this._deletedRelModel.each(function (model) {
|
||||
commandContext.addRelationship(model);
|
||||
}.bind(this));
|
||||
|
||||
// Finally display the topics ...
|
||||
this._deletedTopicModels.each(function (topicModel) {
|
||||
var topics = commandContext.findTopics(topicModel.getId());
|
||||
topics[0].setBranchVisibility(true);
|
||||
}, this);
|
||||
|
||||
// Focus on last recovered topic ..
|
||||
if (this._deletedTopicModels.length > 0) {
|
||||
var firstTopic = this._deletedTopicModels[0];
|
||||
var topic = commandContext.findTopics(firstTopic.getId())[0];
|
||||
topic.setOnFocus(true);
|
||||
}
|
||||
|
||||
this._deletedTopicModels = [];
|
||||
this._parentTopicIds = [];
|
||||
this._deletedRelModel = [];
|
||||
},
|
||||
|
||||
_filterChildren:function (topicIds, commandContext) {
|
||||
var topics = commandContext.findTopics(topicIds);
|
||||
|
||||
var result = [];
|
||||
topics.each(function (topic) {
|
||||
var parent = topic.getParent();
|
||||
var found = false;
|
||||
while (parent != null && !found) {
|
||||
found = topicIds.contains(parent.getId());
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
result.push(topic);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_collectInDepthRelationships:function (topic) {
|
||||
var result = [];
|
||||
result.append(topic.getRelationships());
|
||||
|
||||
var children = topic.getChildren();
|
||||
var rels = children.map(function (topic) {
|
||||
return this._collectInDepthRelationships(topic);
|
||||
}, this);
|
||||
result.append(rels.flatten());
|
||||
|
||||
if (result.length > 0) {
|
||||
// Filter for unique ...
|
||||
result = result.sort(function (a, b) {
|
||||
return a.getModel().getId() - b.getModel().getId();
|
||||
});
|
||||
var ret = [result[0]];
|
||||
for (var i = 1; i < result.length; i++) { // start loop at 1 as element 0 can never be a duplicate
|
||||
if (result[i - 1] !== result[i]) {
|
||||
ret.push(result[i]);
|
||||
}
|
||||
}
|
||||
result = ret;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
});
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.DragTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (topicId, position, order, parentTopic) {
|
||||
$assert(topicId, "topicId must be defined");
|
||||
|
||||
this._topicsId = topicId;
|
||||
if ($defined(parentTopic))
|
||||
this._parentId = parentTopic.getId();
|
||||
|
||||
this.parent();
|
||||
this._position = position;
|
||||
this._order = order;
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
|
||||
var topic = commandContext.findTopics(this._topicsId)[0];
|
||||
topic.setVisibility(false);
|
||||
|
||||
// Save old position ...
|
||||
var origParentTopic = topic.getOutgoingConnectedTopic();
|
||||
|
||||
// In this case, topics are positioned using order ...
|
||||
var origOrder = topic.getOrder();
|
||||
var origPosition = topic.getPosition();
|
||||
|
||||
// Disconnect topic ..
|
||||
if ($defined(origParentTopic) && origParentTopic != this._parentId) {
|
||||
commandContext.disconnect(topic);
|
||||
}
|
||||
|
||||
// Set topic order ...
|
||||
if (this._order != null) {
|
||||
topic.setOrder(this._order);
|
||||
} else if (this._position != null) {
|
||||
commandContext.moveTopic(topic, this._position);
|
||||
} else {
|
||||
$assert("Illegal command state exception.");
|
||||
}
|
||||
|
||||
// Finally, connect topic ...
|
||||
if (origParentTopic != this._parentId) {
|
||||
|
||||
if ($defined(this._parentId)) {
|
||||
var parentTopic = commandContext.findTopics(this._parentId)[0];
|
||||
commandContext.connect(topic, parentTopic);
|
||||
}
|
||||
|
||||
// Backup old parent id ...
|
||||
this._parentId = null;
|
||||
if ($defined(origParentTopic)) {
|
||||
this._parentId = origParentTopic.getId();
|
||||
}
|
||||
}
|
||||
topic.setVisibility(true);
|
||||
|
||||
// Store for undo ...
|
||||
this._order = origOrder;
|
||||
this._position = origPosition;
|
||||
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
this.execute(commandContext);
|
||||
}
|
||||
});
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.GenericFunctionCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (commandFunc, topicsIds, value) {
|
||||
$assert(commandFunc, "commandFunc must be defined");
|
||||
$assert($defined(topicsIds), "topicsIds must be defined");
|
||||
|
||||
this.parent();
|
||||
this._value = value;
|
||||
this._topicsId = topicsIds;
|
||||
this._commandFunc = commandFunc;
|
||||
this._oldValues = [];
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
if (!this.applied) {
|
||||
|
||||
var topics = null;
|
||||
try {
|
||||
topics = commandContext.findTopics(this._topicsId);
|
||||
} catch (e) {
|
||||
if (this._commandFunc.commandType != "changeTextToTopic") {
|
||||
// Workaround: For some reason, there is a combination of events that involves
|
||||
// making some modification and firing out of focus event. This is causing
|
||||
// that a remove node try to be removed. In some other life, I will come with the solution.
|
||||
// Almost aways occurs with IE9. I could be related with some change of order in sets o something similar.
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (topics != null) {
|
||||
topics.each(function (topic) {
|
||||
var oldValue = this._commandFunc(topic, this._value);
|
||||
this._oldValues.push(oldValue);
|
||||
}.bind(this));
|
||||
}
|
||||
this.applied = true;
|
||||
|
||||
} else {
|
||||
throw "Command can not be applied two times in a row.";
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
if (this.applied) {
|
||||
var topics = commandContext.findTopics(this._topicsId);
|
||||
topics.each(function (topic, index) {
|
||||
this._commandFunc(topic, this._oldValues[index]);
|
||||
|
||||
}.bind(this));
|
||||
|
||||
this.applied = false;
|
||||
this._oldValues = [];
|
||||
} else {
|
||||
throw "undo can not be applied.";
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.commands.MoveControlPointCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (ctrlPointController, point) {
|
||||
$assert(ctrlPointController, 'line can not be null');
|
||||
$assert($defined(point), 'point can not be null');
|
||||
|
||||
this.parent();
|
||||
this._ctrlPointControler = ctrlPointController;
|
||||
this._line = ctrlPointController._line;
|
||||
this._controlPoint = this._ctrlPointControler.getControlPoint(point).clone();
|
||||
this._oldControlPoint = this._ctrlPointControler.getOriginalCtrlPoint(point).clone();
|
||||
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point).clone();
|
||||
switch (point) {
|
||||
case 0:
|
||||
this._wasCustom = this._line.getLine().isSrcControlPointCustom();
|
||||
this._endPoint = this._line.getLine().getFrom().clone();
|
||||
break;
|
||||
case 1:
|
||||
this._wasCustom = this._line.getLine().isDestControlPointCustom();
|
||||
this._endPoint = this._line.getLine().getTo().clone();
|
||||
break;
|
||||
}
|
||||
this._point = point;
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
var model = this._line.getModel();
|
||||
switch (this._point) {
|
||||
case 0:
|
||||
model.setSrcCtrlPoint(this._controlPoint.clone());
|
||||
this._line.setFrom(this._endPoint.x, this._endPoint.y);
|
||||
this._line.setIsSrcControlPointCustom(true);
|
||||
this._line.setSrcControlPoint(this._controlPoint.clone());
|
||||
break;
|
||||
case 1:
|
||||
model.setDestCtrlPoint(this._controlPoint.clone());
|
||||
this._wasCustom = this._line.getLine().isDestControlPointCustom();
|
||||
this._line.setTo(this._endPoint.x, this._endPoint.y);
|
||||
this._line.setIsDestControlPointCustom(true);
|
||||
this._line.setDestControlPoint(this._controlPoint.clone());
|
||||
break;
|
||||
}
|
||||
if (this._line.isOnFocus()) {
|
||||
this._line._refreshShape();
|
||||
this._ctrlPointControler.setLine(this._line);
|
||||
}
|
||||
this._line.getLine().updateLine(this._point);
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
var line = this._line;
|
||||
var model = line.getModel();
|
||||
switch (this._point) {
|
||||
case 0:
|
||||
if ($defined(this._oldControlPoint)) {
|
||||
line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y);
|
||||
model.setSrcCtrlPoint(this._oldControlPoint.clone());
|
||||
line.setSrcControlPoint(this._oldControlPoint.clone());
|
||||
line.setIsSrcControlPointCustom(this._wasCustom);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if ($defined(this._oldControlPoint)) {
|
||||
line.setTo(this._originalEndPoint.x, this._originalEndPoint.y);
|
||||
model.setDestCtrlPoint(this._oldControlPoint.clone());
|
||||
line.setDestControlPoint(this._oldControlPoint.clone());
|
||||
line.setIsDestControlPointCustom(this._wasCustom);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this._line.getLine().updateLine(this._point);
|
||||
if (this._line.isOnFocus()) {
|
||||
this._ctrlPointControler.setLine(line);
|
||||
line._refreshShape();
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.RemoveFeatureFromTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize:function (topicId, featureId) {
|
||||
$assert($defined(topicId), 'topicId can not be null');
|
||||
$assert(featureId, 'iconModel can not be null');
|
||||
|
||||
this.parent();
|
||||
this._topicId = topicId;
|
||||
this._featureId = featureId;
|
||||
this._oldFeature = null;
|
||||
},
|
||||
|
||||
execute:function (commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
var feature = topic.findFeatureById(this._featureId);
|
||||
topic.removeFeature(feature);
|
||||
this._oldFeature = feature;
|
||||
},
|
||||
|
||||
undoExecute:function (commandContext) {
|
||||
var topic = commandContext.findTopics(this._topicId)[0];
|
||||
topic.addFeature(this._oldFeature);
|
||||
this._oldFeature = null;
|
||||
}
|
||||
});
|
|
@ -1 +0,0 @@
|
|||
$(document).fireEvent('loadcomplete', 'mind');
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var mindplot = {};
|
||||
mindplot.util = {};
|
||||
mindplot.commands = {};
|
||||
mindplot.layout = {};
|
||||
mindplot.layout.boards = {};
|
||||
mindplot.layout.boards.original = {};
|
||||
mindplot.widget = {};
|
||||
mindplot.model = {};
|
||||
mindplot.collaboration = {};
|
||||
mindplot.collaboration.framework = {};
|
||||
mindplot.persistence = {};
|
||||
|
||||
mindplot.layout = {};
|
||||
|
||||
Class.Mutators.Static = function(items){
|
||||
this.extend(items);
|
||||
};
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.layout.AbstractBasicSorter = new Class({
|
||||
Extends: mindplot.layout.ChildrenSorterStrategy,
|
||||
|
||||
computeChildrenIdByHeights: function(treeSet, node) {
|
||||
var result = {};
|
||||
this._computeChildrenHeight(treeSet, node, result);
|
||||
return result;
|
||||
},
|
||||
|
||||
_getVerticalPadding: function() {
|
||||
return mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING;
|
||||
},
|
||||
|
||||
_computeChildrenHeight : function(treeSet, node, heightCache) {
|
||||
var height = node.getSize().height + (this._getVerticalPadding() * 2); // 2* Top and down padding;
|
||||
|
||||
var result;
|
||||
var children = treeSet.getChildren(node);
|
||||
if (children.length == 0 || node.areChildrenShrunken()) {
|
||||
result = height;
|
||||
} else {
|
||||
var childrenHeight = 0;
|
||||
children.each(function(child) {
|
||||
childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache);
|
||||
}, this);
|
||||
|
||||
result = Math.max(height, childrenHeight);
|
||||
}
|
||||
|
||||
if (heightCache) {
|
||||
heightCache[node.getId()] = result;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_getSortedChildren:function(treeSet, node) {
|
||||
var result = treeSet.getChildren(node);
|
||||
result.sort(function(a, b) {
|
||||
return a.getOrder() - b.getOrder()
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
_getRelativeDirection: function(reference, position) {
|
||||
var offset = position.x - reference.x;
|
||||
return offset >= 0 ? 1 : -1;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.layout.AbstractBasicSorter.INTERNODE_VERTICAL_PADDING = 5;
|
||||
mindplot.layout.AbstractBasicSorter.INTERNODE_HORIZONTAL_PADDING = 30;
|
|
@ -1,225 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.BalancedSorter = new Class({
|
||||
Extends:mindplot.layout.AbstractBasicSorter,
|
||||
|
||||
initialize:function () {
|
||||
|
||||
},
|
||||
|
||||
predict:function (graph, parent, node, position, free) {
|
||||
// If its a free node...
|
||||
if (free) {
|
||||
$assert($defined(position), "position cannot be null for predict in free positioning");
|
||||
$assert($defined(node), "node cannot be null for predict in free positioning");
|
||||
|
||||
var rootNode = graph.getRootNode(parent);
|
||||
var direction = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
|
||||
|
||||
var limitXPos = parent.getPosition().x + direction * (parent.getSize().width / 2 + node.getSize().width / 2 + mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||
|
||||
var xPos = direction > 0 ?
|
||||
(position.x >= limitXPos ? position.x : limitXPos) :
|
||||
(position.x <= limitXPos ? position.x : limitXPos);
|
||||
|
||||
return [0, {x:xPos, y:position.y}];
|
||||
}
|
||||
|
||||
var rootNode = graph.getRootNode(parent);
|
||||
|
||||
// If it is a dragged node...
|
||||
if (node) {
|
||||
$assert($defined(position), "position cannot be null for predict in dragging");
|
||||
var nodeDirection = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
|
||||
var positionDirection = this._getRelativeDirection(rootNode.getPosition(), position);
|
||||
var siblings = graph.getSiblings(node);
|
||||
|
||||
var sameParent = parent == graph.getParent(node);
|
||||
if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) {
|
||||
return [node.getOrder(), node.getPosition()];
|
||||
}
|
||||
}
|
||||
|
||||
if (!position) {
|
||||
var right = this._getChildrenForOrder(parent, graph, 0);
|
||||
var left = this._getChildrenForOrder(parent, graph, 1);
|
||||
}
|
||||
// Filter nodes on one side..
|
||||
var order = position ? (position.x > rootNode.getPosition().x ? 0 : 1) : ((right.length - left.length) > 0 ? 1 : 0);
|
||||
var direction = order % 2 == 0 ? 1 : -1;
|
||||
|
||||
// Exclude the dragged node (if set)
|
||||
var children = this._getChildrenForOrder(parent, graph, order).filter(function (child) {
|
||||
return child != node;
|
||||
});
|
||||
|
||||
// No children?
|
||||
if (children.length == 0) {
|
||||
return [order, {x:parent.getPosition().x + direction * (parent.getSize().width / 2 + mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2), y:parent.getPosition().y}];
|
||||
}
|
||||
|
||||
// Try to fit within ...
|
||||
var result = null;
|
||||
var last = children.getLast();
|
||||
position = position || {x:last.getPosition().x, y:last.getPosition().y + 1};
|
||||
children.each(function (child, index) {
|
||||
var cpos = child.getPosition();
|
||||
if (position.y > cpos.y) {
|
||||
yOffset = child == last ?
|
||||
child.getSize().height + mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2 :
|
||||
(children[index + 1].getPosition().y - child.getPosition().y) / 2;
|
||||
result = [child.getOrder() + 2, {x:cpos.x, y:cpos.y + yOffset}];
|
||||
}
|
||||
});
|
||||
|
||||
// Position wasn't below any node, so it must be inserted above
|
||||
if (!result) {
|
||||
var first = children[0];
|
||||
result = [position.x > 0 ? 0 : 1, {
|
||||
x:first.getPosition().x,
|
||||
y:first.getPosition().y - first.getSize().height - mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
|
||||
}];
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
insert:function (treeSet, parent, child, order) {
|
||||
var children = this._getChildrenForOrder(parent, treeSet, order);
|
||||
|
||||
// If no children, return 0 or 1 depending on the side
|
||||
if (children.length == 0) {
|
||||
child.setOrder(order % 2);
|
||||
return;
|
||||
}
|
||||
|
||||
// Shift all the elements by two, so side is the same.
|
||||
// In case of balanced sorter, order don't need to be continuous...
|
||||
var max = 0;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var node = children[i];
|
||||
max = Math.max(max, node.getOrder());
|
||||
if (node.getOrder() >= order) {
|
||||
max = Math.max(max, node.getOrder() + 2);
|
||||
node.setOrder(node.getOrder() + 2);
|
||||
}
|
||||
}
|
||||
|
||||
var newOrder = order > (max + 1) ? (max + 2) : order;
|
||||
child.setOrder(newOrder);
|
||||
},
|
||||
|
||||
detach:function (treeSet, node) {
|
||||
var parent = treeSet.getParent(node);
|
||||
// Filter nodes on one side..
|
||||
var children = this._getChildrenForOrder(parent, treeSet, node.getOrder());
|
||||
|
||||
children.each(function (child, index) {
|
||||
if (child.getOrder() > node.getOrder()) {
|
||||
child.setOrder(child.getOrder() - 2);
|
||||
}
|
||||
});
|
||||
node.setOrder(node.getOrder() % 2 == 0 ? 0 : 1);
|
||||
},
|
||||
|
||||
computeOffsets:function (treeSet, node) {
|
||||
$assert(treeSet, "treeSet can no be null.");
|
||||
$assert(node, "node can no be null.");
|
||||
|
||||
var children = this._getSortedChildren(treeSet, node);
|
||||
|
||||
// Compute heights ...
|
||||
var heights = children.map(
|
||||
function (child) {
|
||||
return {id:child.getId(), order:child.getOrder(), width:child.getSize().width, height:this._computeChildrenHeight(treeSet, child)};
|
||||
}, this).reverse();
|
||||
|
||||
|
||||
// Compute the center of the branch ...
|
||||
var totalPHeight = 0;
|
||||
var totalNHeight = 0;
|
||||
|
||||
heights.each(function (elem) {
|
||||
if (elem.order % 2 == 0) {
|
||||
totalPHeight += elem.height;
|
||||
} else {
|
||||
totalNHeight += elem.height;
|
||||
}
|
||||
});
|
||||
var psum = totalPHeight / 2;
|
||||
var nsum = totalNHeight / 2;
|
||||
var ysum = 0;
|
||||
|
||||
// Calculate the offsets ...
|
||||
var result = {};
|
||||
for (var i = 0; i < heights.length; i++) {
|
||||
var direction = heights[i].order % 2 ? -1 : 1;
|
||||
|
||||
if (direction > 0) {
|
||||
psum = psum - heights[i].height;
|
||||
ysum = psum;
|
||||
} else {
|
||||
nsum = nsum - heights[i].height;
|
||||
ysum = nsum;
|
||||
}
|
||||
|
||||
var yOffset = ysum + heights[i].height / 2;
|
||||
var xOffset = direction * (node.getSize().width / 2 + heights[i].width / 2 + +mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||
|
||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||
$assert(!isNaN(yOffset), "yOffset can not be null");
|
||||
|
||||
result[heights[i].id] = {x:xOffset, y:yOffset};
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
verify:function (treeSet, node) {
|
||||
// Check that all is consistent ...
|
||||
var children = this._getChildrenForOrder(node, treeSet, node.getOrder());
|
||||
|
||||
// All odd ordered nodes should be "continuous" by themselves
|
||||
// All even numbered nodes should be "continuous" by themselves
|
||||
var factor = node.getOrder() % 2 == 0 ? 2 : 1;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var order = i == 0 && factor == 1 ? 1 : (factor * i);
|
||||
$assert(children[i].getOrder() == order, "Missing order elements. Missing order: " + (i * factor) + ". Parent:" + node.getId() + ",Node:" + children[i].getId());
|
||||
}
|
||||
},
|
||||
|
||||
getChildDirection:function (treeSet, child) {
|
||||
return child.getOrder() % 2 == 0 ? 1 : -1;
|
||||
},
|
||||
|
||||
toString:function () {
|
||||
return "Balanced Sorter";
|
||||
},
|
||||
|
||||
_getChildrenForOrder:function (parent, graph, order) {
|
||||
return this._getSortedChildren(graph, parent).filter(function (child) {
|
||||
return child.getOrder() % 2 == order % 2;
|
||||
});
|
||||
},
|
||||
|
||||
_getVerticalPadding:function () {
|
||||
return mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING;
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.layout.BalancedSorter.INTERNODE_VERTICAL_PADDING = 5;
|
||||
mindplot.layout.BalancedSorter.INTERNODE_HORIZONTAL_PADDING = 30;
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.ChangeEvent = new Class({
|
||||
initialize:function(id) {
|
||||
$assert(!isNaN(id), "id can not be null");
|
||||
this._id = id;
|
||||
this._position = null;
|
||||
this._order = null;
|
||||
},
|
||||
|
||||
getId:function() {
|
||||
return this._id;
|
||||
},
|
||||
|
||||
getOrder: function() {
|
||||
return this._order;
|
||||
},
|
||||
|
||||
getPosition: function() {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
setOrder: function(value) {
|
||||
$assert(!isNaN(value), "value can not be null");
|
||||
this._order = value;
|
||||
},
|
||||
|
||||
setPosition: function(value) {
|
||||
$assert(value, "value can not be null");
|
||||
this._position = value;
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
return "[order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}]";
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.ChildrenSorterStrategy = new Class({
|
||||
initialize:function() {
|
||||
|
||||
},
|
||||
|
||||
computeChildrenIdByHeights: function(treeSet, node) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
computeOffsets:function(treeSet, node) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
insert: function(treeSet, parent, child, order) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
detach:function(treeSet, node) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
predict:function(treeSet, parent, node, position, free) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
verify:function(treeSet, node) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
getChildDirection: function(treeSet, node) {
|
||||
throw "Method must be implemented";
|
||||
},
|
||||
|
||||
toString:function() {
|
||||
throw "Method must be implemented: print name";
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.EventBus = new Class({
|
||||
Implements:Events,
|
||||
initialize: function() {
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.EventBus.events = {
|
||||
NodeResizeEvent:'NodeResizeEvent',
|
||||
NodeMoveEvent:'NodeMoveEvent',
|
||||
NodeShrinkEvent:'NodeShrinkEvent',
|
||||
NodeConnectEvent:'NodeConnectEvent',
|
||||
NodeDisconnectEvent:'NodeDisconnectEvent',
|
||||
NodeAdded:'NodeAdded',
|
||||
NodeRemoved:'NodeRemoved',
|
||||
DoLayout:'DoLayout'
|
||||
};
|
||||
|
||||
mindplot.EventBus.instance = new mindplot.EventBus();
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.EventBusDispatcher = new Class({
|
||||
|
||||
initialize:function() {
|
||||
this.registerBusEvents();
|
||||
},
|
||||
|
||||
setLayoutManager : function(layoutManager) {
|
||||
this._layoutManager = layoutManager;
|
||||
},
|
||||
|
||||
registerBusEvents:function () {
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeAdded, this._nodeAdded.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeRemoved, this._nodeRemoved.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeResizeEvent, this._nodeResizeEvent.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeMoveEvent, this._nodeMoveEvent.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeDisconnectEvent, this._nodeDisconnectEvent.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeConnectEvent, this._nodeConnectEvent.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.NodeShrinkEvent, this._nodeShrinkEvent.bind(this));
|
||||
mindplot.EventBus.instance.addEvent(mindplot.EventBus.events.DoLayout, this._doLayout.bind(this));
|
||||
},
|
||||
|
||||
_nodeResizeEvent: function(args) {
|
||||
this._layoutManager.updateNodeSize(args.node.getId(), args.size);
|
||||
},
|
||||
|
||||
_nodeMoveEvent: function(args) {
|
||||
this._layoutManager.moveNode(args.node.getId(), args.position);
|
||||
},
|
||||
|
||||
_nodeDisconnectEvent: function(node) {
|
||||
this._layoutManager.disconnectNode(node.getId());
|
||||
},
|
||||
|
||||
_nodeConnectEvent: function(args) {
|
||||
this._layoutManager.connectNode(args.parentNode.getId(), args.childNode.getId(), args.childNode.getOrder());
|
||||
|
||||
},
|
||||
|
||||
_nodeShrinkEvent: function(node) {
|
||||
this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken());
|
||||
},
|
||||
|
||||
_nodeAdded: function(node) {
|
||||
// Central topic must not be added twice ...
|
||||
if (node.getId() != 0) {
|
||||
this._layoutManager.addNode(node.getId(), {width:10,height:10}, node.getPosition());
|
||||
this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken());
|
||||
}
|
||||
},
|
||||
|
||||
_nodeRemoved: function(node) {
|
||||
this._layoutManager.removeNode(node.getId());
|
||||
},
|
||||
|
||||
_doLayout: function() {
|
||||
// (function() {
|
||||
this._layoutManager.layout(true);
|
||||
// console.log("---------");
|
||||
// this._layoutManager.dump();
|
||||
// console.log("---------");
|
||||
// console.log("---------");
|
||||
// }).delay(0, this);
|
||||
},
|
||||
|
||||
getLayoutManager: function() {
|
||||
return this._layoutManager;
|
||||
}
|
||||
|
||||
});
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.GridSorter = new Class({
|
||||
Extends: mindplot.layout.AbstractBasicSorter,
|
||||
|
||||
computeOffsets: function(treeSet, node) {
|
||||
$assert(treeSet, "treeSet can no be null.");
|
||||
$assert(node, "node can no be null.");
|
||||
$assert("order can no be null.");
|
||||
|
||||
var children = this._getSortedChildren(treeSet, node);
|
||||
|
||||
// Compute heights ...
|
||||
var heights = children.map(function(child) {
|
||||
return {id:child.getId(),height:this._computeChildrenHeight(treeSet, child)};
|
||||
}.bind(this));
|
||||
|
||||
// Calculate the offsets ...
|
||||
var result = {};
|
||||
for (var i = 0; i < heights.length; i++) {
|
||||
var even = i%2 == 0 ? 1 : -1;
|
||||
|
||||
var zeroHeight = i == 0 ? 0 : heights[0].height/2 * even;
|
||||
var middleHeight = 0;
|
||||
for (var j=i-2; j>0; j=j-2) {
|
||||
middleHeight += heights[j].height * even;
|
||||
}
|
||||
var finalHeight = i == 0 ? 0 : heights[i].height/2 * even;
|
||||
|
||||
var yOffset = zeroHeight + middleHeight +finalHeight;
|
||||
var xOffset = node.getSize().width + mindplot.layout.GridSorter.GRID_HORIZONTAR_SIZE;
|
||||
|
||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||
$assert(!isNaN(yOffset), "yOffset can not be null");
|
||||
|
||||
result[heights[i].id] = {x:xOffset,y:yOffset};
|
||||
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
toString:function() {
|
||||
return "Grid Sorter";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.layout.GridSorter.GRID_HORIZONTAR_SIZE = 20;
|
||||
mindplot.layout.GridSorter.INTER_NODE_VERTICAL_DISTANCE = 50;
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.LayoutManager = new Class({
|
||||
Extends: Events,
|
||||
initialize: function(rootNodeId, rootSize) {
|
||||
$assert($defined(rootNodeId), "rootNodeId can not be null");
|
||||
$assert(rootSize, "rootSize can not be null");
|
||||
var position = position || {x:0, y:0};
|
||||
|
||||
this._treeSet = new mindplot.layout.RootedTreeSet();
|
||||
this._layout = new mindplot.layout.OriginalLayout(this._treeSet);
|
||||
|
||||
var rootNode = this._layout.createNode(rootNodeId, rootSize, position, 'root');
|
||||
this._treeSet.setRoot(rootNode);
|
||||
this._events = [];
|
||||
},
|
||||
|
||||
updateNodeSize: function(id, size) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
node.setSize(size);
|
||||
},
|
||||
|
||||
updateShrinkState: function(id, value) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
$assert($defined(value), "value can not be null");
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
node.setShrunken(value);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
find: function(id) {
|
||||
return this._treeSet.find(id);
|
||||
},
|
||||
|
||||
moveNode: function(id, position) {
|
||||
$assert($defined(id), "id cannot be null");
|
||||
$assert($defined(position), "position cannot be null");
|
||||
$assert($defined(position.x), "x can not be null");
|
||||
$assert($defined(position.y), "y can not be null");
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
// @Todo: this should not be here. This is broking the isolated node support...
|
||||
// node.setFree(true);
|
||||
// node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y - node.getPosition().y});
|
||||
node.setPosition(position);
|
||||
},
|
||||
|
||||
connectNode: function(parentId, childId, order) {
|
||||
$assert($defined(parentId), "parentId cannot be null");
|
||||
$assert($defined(childId), "childId cannot be null");
|
||||
$assert($defined(order), "order cannot be null");
|
||||
|
||||
this._layout.connectNode(parentId, childId, order);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
disconnectNode: function(id) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
this._layout.disconnectNode(id);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
addNode:function(id, size, position) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
var result = this._layout.createNode(id, size, position, 'topic');
|
||||
this._treeSet.add(result);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeNode: function(id) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
var node = this._treeSet.find(id);
|
||||
|
||||
// Is It connected ?
|
||||
if (this._treeSet.getParent(node)) {
|
||||
this.disconnectNode(id);
|
||||
}
|
||||
|
||||
// Remove the all the branch ...
|
||||
this._treeSet.remove(id);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
predict: function(parentId, nodeId, position, free) {
|
||||
$assert($defined(parentId), "parentId can not be null");
|
||||
|
||||
var parent = this._treeSet.find(parentId);
|
||||
var node = nodeId ? this._treeSet.find(nodeId) : null;
|
||||
var sorter = parent.getSorter();
|
||||
|
||||
var result = sorter.predict(this._treeSet, parent, node, position, free);
|
||||
return {order:result[0],position:result[1]};
|
||||
},
|
||||
|
||||
dump: function() {
|
||||
console.log(this._treeSet.dump());
|
||||
},
|
||||
|
||||
plot: function(containerId, size) {
|
||||
$assert(containerId, "containerId cannot be null");
|
||||
size = size || {width:200,height:200};
|
||||
var squaresize = 10;
|
||||
var canvas = Raphael(containerId, size.width, size.height);
|
||||
canvas.drawGrid(0, 0, size.width, size.height, size.width / squaresize, size.height / squaresize);
|
||||
this._treeSet.plot(canvas);
|
||||
|
||||
return canvas;
|
||||
},
|
||||
|
||||
layout: function(fireEvents) {
|
||||
// File repositioning ...
|
||||
this._layout.layout();
|
||||
|
||||
// Collect changes ...
|
||||
this._collectChanges();
|
||||
|
||||
if (!$(fireEvents) || fireEvents) {
|
||||
this._flushEvents();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_flushEvents: function() {
|
||||
this._events.each(function(event) {
|
||||
this.fireEvent('change', event);
|
||||
}, this);
|
||||
this._events = [];
|
||||
},
|
||||
|
||||
_collectChanges: function(nodes) {
|
||||
if (!nodes)
|
||||
nodes = this._treeSet.getTreeRoots();
|
||||
|
||||
nodes.each(function(node) {
|
||||
if (node.hasOrderChanged() || node.hasPositionChanged()) {
|
||||
|
||||
// Find or create a event ...
|
||||
var id = node.getId();
|
||||
var event = this._events.some(function(event) {
|
||||
return event.id == id;
|
||||
});
|
||||
if (!event) {
|
||||
event = new mindplot.layout.ChangeEvent(id);
|
||||
}
|
||||
|
||||
// Update nodes ...
|
||||
event.setOrder(node.getOrder());
|
||||
event.setPosition(node.getPosition());
|
||||
|
||||
node.resetPositionState();
|
||||
node.resetOrderState();
|
||||
node.resetFreeState();
|
||||
this._events.push(event);
|
||||
}
|
||||
this._collectChanges(this._treeSet.getChildren(node));
|
||||
}, this);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.Node = new Class({
|
||||
initialize:function (id, size, position, sorter) {
|
||||
$assert(typeof id === 'number' && isFinite(id), "id can not be null");
|
||||
$assert(size, "size can not be null");
|
||||
$assert(position, "position can not be null");
|
||||
$assert(sorter, "sorter can not be null");
|
||||
|
||||
this._id = id;
|
||||
this._sorter = sorter;
|
||||
this._properties = {};
|
||||
|
||||
this.setSize(size);
|
||||
this.setPosition(position);
|
||||
this.setShrunken(false);
|
||||
},
|
||||
|
||||
getId:function () {
|
||||
return this._id;
|
||||
},
|
||||
|
||||
setFree:function (value) {
|
||||
this._setProperty('free', value);
|
||||
},
|
||||
|
||||
isFree:function () {
|
||||
return this._getProperty('free');
|
||||
},
|
||||
|
||||
hasFreeChanged:function () {
|
||||
return this._isPropertyChanged('free');
|
||||
},
|
||||
|
||||
hasFreeDisplacementChanged:function () {
|
||||
return this._isPropertyChanged('freeDisplacement');
|
||||
},
|
||||
|
||||
setShrunken:function (value) {
|
||||
this._setProperty('shrink', value);
|
||||
},
|
||||
|
||||
areChildrenShrunken:function () {
|
||||
return this._getProperty('shrink');
|
||||
},
|
||||
|
||||
setOrder:function (order) {
|
||||
$assert(typeof order === 'number' && isFinite(order), "Order can not be null. Value:" + order);
|
||||
this._setProperty('order', order);
|
||||
},
|
||||
|
||||
resetPositionState:function () {
|
||||
var prop = this._properties['position'];
|
||||
if (prop) {
|
||||
prop.hasChanged = false;
|
||||
}
|
||||
},
|
||||
|
||||
resetOrderState:function () {
|
||||
var prop = this._properties['order'];
|
||||
if (prop) {
|
||||
prop.hasChanged = false;
|
||||
}
|
||||
},
|
||||
|
||||
resetFreeState:function () {
|
||||
var prop = this._properties['freeDisplacement'];
|
||||
if (prop) {
|
||||
prop.hasChanged = false;
|
||||
}
|
||||
},
|
||||
|
||||
getOrder:function () {
|
||||
return this._getProperty('order');
|
||||
},
|
||||
|
||||
hasOrderChanged:function () {
|
||||
return this._isPropertyChanged('order');
|
||||
},
|
||||
|
||||
hasPositionChanged:function () {
|
||||
return this._isPropertyChanged('position');
|
||||
},
|
||||
|
||||
hasSizeChanged:function () {
|
||||
return this._isPropertyChanged('size');
|
||||
},
|
||||
|
||||
getPosition:function () {
|
||||
return this._getProperty('position');
|
||||
},
|
||||
|
||||
setSize:function (size) {
|
||||
$assert($defined(size), "Size can not be null");
|
||||
this._setProperty('size', Object.clone(size));
|
||||
},
|
||||
|
||||
getSize:function () {
|
||||
return this._getProperty('size');
|
||||
},
|
||||
|
||||
setFreeDisplacement:function (displacement) {
|
||||
$assert($defined(displacement), "Position can not be null");
|
||||
$assert($defined(displacement.x), "x can not be null");
|
||||
$assert($defined(displacement.y), "y can not be null");
|
||||
var oldDisplacement = this.getFreeDisplacement();
|
||||
var newDisplacement = {x:oldDisplacement.x + displacement.x, y:oldDisplacement.y + displacement.y};
|
||||
|
||||
this._setProperty('freeDisplacement', Object.clone(newDisplacement));
|
||||
},
|
||||
|
||||
resetFreeDisplacement:function () {
|
||||
this._setProperty('freeDisplacement', {x:0, y:0});
|
||||
},
|
||||
|
||||
getFreeDisplacement:function () {
|
||||
var freeDisplacement = this._getProperty('freeDisplacement');
|
||||
return (freeDisplacement || {x:0, y:0});
|
||||
},
|
||||
|
||||
setPosition:function (position) {
|
||||
$assert($defined(position), "Position can not be null");
|
||||
$assert($defined(position.x), "x can not be null");
|
||||
$assert($defined(position.y), "y can not be null");
|
||||
|
||||
// This is a performance improvement to avoid movements that really could be avoided.
|
||||
var currentPos = this.getPosition();
|
||||
if (currentPos == null || Math.abs(currentPos.x - position.x) > 2 || Math.abs(currentPos.y - position.y) > 2)
|
||||
this._setProperty('position', position);
|
||||
},
|
||||
|
||||
_setProperty:function (key, value) {
|
||||
var prop = this._properties[key];
|
||||
if (!prop) {
|
||||
prop = {
|
||||
hasChanged:false,
|
||||
value:null,
|
||||
oldValue:null
|
||||
};
|
||||
}
|
||||
|
||||
// Only update if the property has changed ...
|
||||
if (JSON.encode(prop.value) != JSON.encode(value)) {
|
||||
prop.oldValue = prop.value;
|
||||
prop.value = value;
|
||||
prop.hasChanged = true;
|
||||
}
|
||||
this._properties[key] = prop;
|
||||
},
|
||||
|
||||
_getProperty:function (key) {
|
||||
var prop = this._properties[key];
|
||||
return $defined(prop) ? prop.value : null;
|
||||
},
|
||||
|
||||
_isPropertyChanged:function (key) {
|
||||
var prop = this._properties[key];
|
||||
return prop ? prop.hasChanged : false;
|
||||
},
|
||||
|
||||
getSorter:function () {
|
||||
return this._sorter;
|
||||
},
|
||||
|
||||
toString:function () {
|
||||
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "," + this.getSize().height + "}, shrink:" + this.areChildrenShrunken() + "]";
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.OriginalLayout = new Class({
|
||||
initialize:function (treeSet) {
|
||||
this._treeSet = treeSet;
|
||||
},
|
||||
|
||||
createNode:function (id, size, position, type) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
$assert(size, "size can not be null");
|
||||
$assert(position, "position can not be null");
|
||||
$assert(type, "type can not be null");
|
||||
|
||||
var strategy = type === 'root' ?
|
||||
mindplot.layout.OriginalLayout.BALANCED_SORTER :
|
||||
mindplot.layout.OriginalLayout.SYMMETRIC_SORTER;
|
||||
return new mindplot.layout.Node(id, size, position, strategy);
|
||||
},
|
||||
|
||||
connectNode:function (parentId, childId, order) {
|
||||
|
||||
var parent = this._treeSet.find(parentId);
|
||||
var child = this._treeSet.find(childId);
|
||||
|
||||
// Insert the new node ...
|
||||
var sorter = parent.getSorter();
|
||||
sorter.insert(this._treeSet, parent, child, order);
|
||||
|
||||
// Connect the new node ...
|
||||
this._treeSet.connect(parentId, childId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
sorter.verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
disconnectNode:function (nodeId) {
|
||||
var node = this._treeSet.find(nodeId);
|
||||
var parent = this._treeSet.getParent(node);
|
||||
$assert(parent, "Node already disconnected");
|
||||
|
||||
// Make it fixed
|
||||
node.setFree(false);
|
||||
node.resetFreeDisplacement();
|
||||
|
||||
// Remove from children list.
|
||||
var sorter = parent.getSorter();
|
||||
sorter.detach(this._treeSet, node);
|
||||
|
||||
// Disconnect the new node ...
|
||||
this._treeSet.disconnect(nodeId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
parent.getSorter().verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
layout:function () {
|
||||
var roots = this._treeSet.getTreeRoots();
|
||||
roots.each(function (node) {
|
||||
|
||||
// Calculate all node heights ...
|
||||
var sorter = node.getSorter();
|
||||
|
||||
var heightById = sorter.computeChildrenIdByHeights(this._treeSet, node);
|
||||
|
||||
this._layoutChildren(node, heightById);
|
||||
|
||||
this._fixOverlapping(node, heightById);
|
||||
}, this);
|
||||
},
|
||||
|
||||
_layoutChildren:function (node, heightById) {
|
||||
|
||||
var nodeId = node.getId();
|
||||
var children = this._treeSet.getChildren(node);
|
||||
var parent = this._treeSet.getParent(node);
|
||||
var childrenOrderMoved = children.some(function (child) {
|
||||
return child.hasOrderChanged();
|
||||
});
|
||||
var childrenSizeChanged = children.some(function (child) {
|
||||
return child.hasSizeChanged();
|
||||
});
|
||||
|
||||
// If ether any of the nodes has been changed of position or the height of the children is not
|
||||
// the same, children nodes must be repositioned ....
|
||||
var newBranchHeight = heightById[nodeId];
|
||||
|
||||
var parentHeightChanged = $defined(parent) ? parent._heightChanged : false;
|
||||
var heightChanged = node._branchHeight != newBranchHeight;
|
||||
node._heightChanged = heightChanged || parentHeightChanged;
|
||||
|
||||
if (childrenOrderMoved || childrenSizeChanged || heightChanged || parentHeightChanged) {
|
||||
var sorter = node.getSorter();
|
||||
var offsetById = sorter.computeOffsets(this._treeSet, node);
|
||||
var parentPosition = node.getPosition();
|
||||
|
||||
children.each(function (child) {
|
||||
var offset = offsetById[child.getId()];
|
||||
|
||||
var childFreeDisplacement = child.getFreeDisplacement();
|
||||
var direction = node.getSorter().getChildDirection(this._treeSet, child);
|
||||
|
||||
if ((direction > 0 && childFreeDisplacement.x < 0) || (direction < 0 && childFreeDisplacement.x > 0)) {
|
||||
child.resetFreeDisplacement();
|
||||
child.setFreeDisplacement({x:-childFreeDisplacement.x, y:childFreeDisplacement.y});
|
||||
}
|
||||
|
||||
offset.x += child.getFreeDisplacement().x;
|
||||
offset.y += child.getFreeDisplacement().y;
|
||||
|
||||
var parentX = parentPosition.x;
|
||||
var parentY = parentPosition.y;
|
||||
|
||||
var newPos = {x:parentX + offset.x, y:parentY + offset.y + this._calculateAlignOffset(node, child, heightById)};
|
||||
this._treeSet.updateBranchPosition(child, newPos);
|
||||
}.bind(this));
|
||||
|
||||
node._branchHeight = newBranchHeight;
|
||||
}
|
||||
|
||||
// Continue reordering the children nodes ...
|
||||
children.each(function (child) {
|
||||
this._layoutChildren(child, heightById);
|
||||
}, this);
|
||||
},
|
||||
|
||||
_calculateAlignOffset:function (node, child, heightById) {
|
||||
if (child.isFree()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var offset = 0;
|
||||
|
||||
var nodeHeight = node.getSize().height;
|
||||
var childHeight = child.getSize().height;
|
||||
|
||||
if (this._treeSet.isStartOfSubBranch(child) && this._branchIsTaller(child, heightById)) {
|
||||
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
|
||||
offset = heightById[child.getId()] / 2 - (childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
|
||||
} else {
|
||||
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
|
||||
}
|
||||
} else if (nodeHeight > childHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = nodeHeight / 2 - childHeight / 2;
|
||||
}
|
||||
}
|
||||
else if (childHeight > nodeHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = -(childHeight / 2 - nodeHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_branchIsTaller:function (node, heightById) {
|
||||
return heightById[node.getId()] > (node.getSize().height + node.getSorter()._getVerticalPadding() * 2);
|
||||
},
|
||||
|
||||
_fixOverlapping:function (node, heightById) {
|
||||
var children = this._treeSet.getChildren(node);
|
||||
|
||||
if (node.isFree()) {
|
||||
this._shiftBranches(node, heightById);
|
||||
}
|
||||
|
||||
children.each(function (child) {
|
||||
this._fixOverlapping(child, heightById);
|
||||
}, this);
|
||||
},
|
||||
|
||||
_shiftBranches:function (node, heightById) {
|
||||
var shiftedBranches = [node];
|
||||
|
||||
var siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(node, node.getFreeDisplacement().y);
|
||||
var last = node;
|
||||
siblingsToShift.each(function (sibling) {
|
||||
var overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
|
||||
return this._branchesOverlap(shiftedBranch, sibling, heightById);
|
||||
}, this);
|
||||
|
||||
if (!sibling.isFree() || overlappingOccurs) {
|
||||
var sAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
|
||||
shiftedBranches.push(sibling);
|
||||
}
|
||||
}, this);
|
||||
|
||||
var branchesToShift = this._treeSet.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y).filter(function (branch) {
|
||||
return !shiftedBranches.contains(branch);
|
||||
});
|
||||
|
||||
branchesToShift.each(function (branch) {
|
||||
var bAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
|
||||
shiftedBranches.push(branch);
|
||||
last = branch;
|
||||
}, this);
|
||||
},
|
||||
|
||||
_branchesOverlap:function (branchA, branchB, heightById) {
|
||||
// a branch doesn't really overlap with itself
|
||||
if (branchA == branchB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var topA = branchA.getPosition().y - heightById[branchA.getId()] / 2;
|
||||
var bottomA = branchA.getPosition().y + heightById[branchA.getId()] / 2;
|
||||
var topB = branchB.getPosition().y - heightById[branchB.getId()] / 2;
|
||||
var bottomB = branchB.getPosition().y + heightById[branchB.getId()] / 2;
|
||||
|
||||
return !(topA >= bottomB || bottomA <= topB);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
mindplot.layout.OriginalLayout.SYMMETRIC_SORTER = new mindplot.layout.SymmetricSorter();
|
||||
mindplot.layout.OriginalLayout.BALANCED_SORTER = new mindplot.layout.BalancedSorter();
|
||||
|
||||
|
||||
|
|
@ -1,294 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.RootedTreeSet = new Class({
|
||||
initialize:function () {
|
||||
this._rootNodes = [];
|
||||
},
|
||||
|
||||
setRoot:function (root) {
|
||||
$assert(root, 'root can not be null');
|
||||
this._rootNodes.push(this._decodate(root));
|
||||
},
|
||||
|
||||
getTreeRoots:function () {
|
||||
return this._rootNodes;
|
||||
},
|
||||
|
||||
_decodate:function (node) {
|
||||
node._children = [];
|
||||
return node;
|
||||
},
|
||||
|
||||
add:function (node) {
|
||||
$assert(node, 'node can not be null');
|
||||
$assert(!this.find(node.getId(), false), 'node already exits with this id. Id:' + node.getId());
|
||||
$assert(!node._children, 'node already added');
|
||||
this._rootNodes.push(this._decodate(node));
|
||||
},
|
||||
|
||||
|
||||
remove:function (nodeId) {
|
||||
$assert($defined(nodeId), 'nodeId can not be null');
|
||||
var node = this.find(nodeId);
|
||||
this._rootNodes.erase(node);
|
||||
},
|
||||
|
||||
connect:function (parentId, childId) {
|
||||
$assert($defined(parentId), 'parent can not be null');
|
||||
$assert($defined(childId), 'child can not be null');
|
||||
|
||||
var parent = this.find(parentId);
|
||||
var child = this.find(childId, true);
|
||||
$assert(!child._parent, 'node already connected. Id:' + child.getId() + ",previous:" + child._parent);
|
||||
|
||||
parent._children.push(child);
|
||||
child._parent = parent;
|
||||
this._rootNodes.erase(child);
|
||||
},
|
||||
|
||||
disconnect:function (nodeId) {
|
||||
$assert($defined(nodeId), 'nodeId can not be null');
|
||||
var node = this.find(nodeId);
|
||||
$assert(node._parent, "Node is not connected");
|
||||
|
||||
node._parent._children.erase(node);
|
||||
this._rootNodes.push(node);
|
||||
node._parent = null;
|
||||
},
|
||||
|
||||
find:function (id, validate) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
|
||||
var graphs = this._rootNodes;
|
||||
var result = null;
|
||||
for (var i = 0; i < graphs.length; i++) {
|
||||
var node = graphs[i];
|
||||
result = this._find(id, node);
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
validate = !$defined(validate) ? true : validate;
|
||||
$assert(validate ? result : true, 'node could not be found id:' + id + "\n,RootedTreeSet" + this.dump());
|
||||
return result;
|
||||
|
||||
},
|
||||
|
||||
_find:function (id, parent) {
|
||||
if (parent.getId() == id) {
|
||||
return parent;
|
||||
|
||||
}
|
||||
|
||||
var result = null;
|
||||
var children = parent._children;
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
result = this._find(id, child);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
getChildren:function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return node._children;
|
||||
},
|
||||
|
||||
getRootNode:function (node) {
|
||||
$assert(node, "node cannot be null");
|
||||
var parent = this.getParent(node);
|
||||
if ($defined(parent)) {
|
||||
return this.getRootNode(parent);
|
||||
}
|
||||
|
||||
return node;
|
||||
},
|
||||
|
||||
getAncestors:function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this._getAncestors(this.getParent(node), []);
|
||||
},
|
||||
|
||||
_getAncestors:function (node, ancestors) {
|
||||
var result = ancestors;
|
||||
if (node) {
|
||||
result.push(node);
|
||||
this._getAncestors(this.getParent(node), result);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getSiblings:function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
if (!$defined(node._parent)) {
|
||||
return [];
|
||||
}
|
||||
var siblings = node._parent._children.filter(function (child) {
|
||||
return child != node;
|
||||
});
|
||||
return siblings;
|
||||
},
|
||||
|
||||
hasSinglePathToSingleLeaf:function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this._hasSinglePathToSingleLeaf(node);
|
||||
},
|
||||
|
||||
_hasSinglePathToSingleLeaf:function (node) {
|
||||
var children = this.getChildren(node);
|
||||
|
||||
if (children.length == 1) {
|
||||
return this._hasSinglePathToSingleLeaf(children[0]);
|
||||
}
|
||||
|
||||
return children.length == 0;
|
||||
},
|
||||
|
||||
isStartOfSubBranch:function (node) {
|
||||
return this.getSiblings(node).length > 0 && this.getChildren(node).length == 1;
|
||||
},
|
||||
|
||||
isLeaf:function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this.getChildren(node).length == 0;
|
||||
},
|
||||
|
||||
getParent:function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return node._parent;
|
||||
},
|
||||
|
||||
dump:function () {
|
||||
var branches = this._rootNodes;
|
||||
var result = "";
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var branch = branches[i];
|
||||
result += this._dump(branch, "");
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_dump:function (node, indent) {
|
||||
var result = indent + node + "\n";
|
||||
var children = this.getChildren(node);
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
result += this._dump(child, indent + " ");
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
plot:function (canvas) {
|
||||
var branches = this._rootNodes;
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var branch = branches[i];
|
||||
this._plot(canvas, branch);
|
||||
}
|
||||
},
|
||||
|
||||
_plot:function (canvas, node, root) {
|
||||
var children = this.getChildren(node);
|
||||
var cx = node.getPosition().x + canvas.width / 2 - node.getSize().width / 2;
|
||||
var cy = node.getPosition().y + canvas.height / 2 - node.getSize().height / 2;
|
||||
var rect = canvas.rect(cx, cy, node.getSize().width, node.getSize().height);
|
||||
var order = node.getOrder() == null ? "r" : node.getOrder();
|
||||
var text = canvas.text(node.getPosition().x + canvas.width / 2, node.getPosition().y + canvas.height / 2, node.getId() + "[" + order + "]");
|
||||
text.attr('fill', '#FFF');
|
||||
var fillColor = this._rootNodes.contains(node) ? "#000" : (node.isFree() ? "#abc" : "#c00");
|
||||
rect.attr('fill', fillColor);
|
||||
|
||||
var rectPosition = {x:rect.attr("x") - canvas.width / 2 + rect.attr("width") / 2, y:rect.attr("y") - canvas.height / 2 + rect.attr("height") / 2};
|
||||
var rectSize = {width:rect.attr("width"), height:rect.attr("height")};
|
||||
rect.click(function () {
|
||||
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position:(" + rectPosition.x + "," + rectPosition.y + "), size:" + rectSize.width + "x" + rectSize.height + ", freeDisplacement:(" + node.getFreeDisplacement().x + "," + node.getFreeDisplacement().y + ")]");
|
||||
});
|
||||
text.click(function () {
|
||||
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position:(" + rectPosition.x + "," + rectPosition.y + "), size:" + rectSize.width + "x" + rectSize.height + ", freeDisplacement:(" + node.getFreeDisplacement().x + "," + node.getFreeDisplacement().y + ")]");
|
||||
});
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
this._plot(canvas, child);
|
||||
}
|
||||
},
|
||||
|
||||
updateBranchPosition:function (node, position) {
|
||||
|
||||
var oldPos = node.getPosition();
|
||||
node.setPosition(position);
|
||||
|
||||
var xOffset = oldPos.x - position.x;
|
||||
var yOffset = oldPos.y - position.y;
|
||||
|
||||
var children = this.getChildren(node);
|
||||
children.each(function (child) {
|
||||
this.shiftBranchPosition(child, xOffset, yOffset);
|
||||
}.bind(this));
|
||||
|
||||
},
|
||||
|
||||
shiftBranchPosition:function (node, xOffset, yOffset) {
|
||||
var position = node.getPosition();
|
||||
node.setPosition({x:position.x + xOffset, y:position.y + yOffset});
|
||||
|
||||
var children = this.getChildren(node);
|
||||
children.each(function (child) {
|
||||
this.shiftBranchPosition(child, xOffset, yOffset);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
getSiblingsInVerticalDirection:function (node, yOffset) {
|
||||
// siblings with lower or higher order, depending on the direction of the offset and on the same side as their parent
|
||||
var parent = this.getParent(node);
|
||||
var siblings = this.getSiblings(node).filter(function (sibling) {
|
||||
var sameSide = node.getPosition().x > parent.getPosition().x ? sibling.getPosition().x > parent.getPosition().x : sibling.getPosition().x < parent.getPosition().x;
|
||||
var orderOK = yOffset < 0 ? sibling.getOrder() < node.getOrder() : sibling.getOrder() > node.getOrder();
|
||||
return orderOK && sameSide;
|
||||
});
|
||||
|
||||
if (yOffset < 0) {
|
||||
siblings.reverse();
|
||||
}
|
||||
|
||||
return siblings;
|
||||
},
|
||||
|
||||
getBranchesInVerticalDirection:function (node, yOffset) {
|
||||
// direct descendants of the root that do not contain the node and are on the same side
|
||||
// and on the direction of the offset
|
||||
var rootNode = this.getRootNode(node);
|
||||
var branches = this.getChildren(rootNode).filter(function (child) {
|
||||
return this._find(node.getId(), child);
|
||||
}, this);
|
||||
|
||||
var branch = branches[0];
|
||||
var rootDescendants = this.getSiblings(branch).filter(function (sibling) {
|
||||
var sameSide = node.getPosition().x > rootNode.getPosition().x ? sibling.getPosition().x > rootNode.getPosition().x : sibling.getPosition().x < rootNode.getPosition().x;
|
||||
var sameDirection = yOffset < 0 ? sibling.getOrder() < branch.getOrder() : sibling.getOrder() > branch.getOrder();
|
||||
return sameSide && sameDirection;
|
||||
}, this);
|
||||
|
||||
return rootDescendants;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mindplot.layout.SymmetricSorter = new Class({
|
||||
Extends:mindplot.layout.AbstractBasicSorter,
|
||||
initialize:function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Predict the order and position of a dragged node.
|
||||
*
|
||||
* @param graph The tree set
|
||||
* @param parent The parent of the node
|
||||
* @param node The node
|
||||
* @param position The position of the drag
|
||||
* @param free Free drag or not
|
||||
* @return {*}
|
||||
*/
|
||||
predict:function (graph, parent, node, position, free) {
|
||||
|
||||
var self = this;
|
||||
var rootNode = graph.getRootNode(parent);
|
||||
|
||||
// If its a free node...
|
||||
if (free) {
|
||||
$assert($defined(position), "position cannot be null for predict in free positioning");
|
||||
$assert($defined(node), "node cannot be null for predict in free positioning");
|
||||
|
||||
var direction = this._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
|
||||
var limitXPos = parent.getPosition().x + direction * (parent.getSize().width / 2 + node.getSize().width / 2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||
|
||||
var xPos = direction > 0 ?
|
||||
(position.x >= limitXPos ? position.x : limitXPos) :
|
||||
(position.x <= limitXPos ? position.x : limitXPos);
|
||||
|
||||
return [0, {x:xPos, y:position.y}];
|
||||
}
|
||||
|
||||
// Its not a dragged node (it is being added)
|
||||
if (!node) {
|
||||
var parentDirection = self._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
|
||||
var position = {
|
||||
x:parent.getPosition().x + parentDirection * (parent.getSize().width + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
|
||||
y:parent.getPosition().y
|
||||
};
|
||||
return [graph.getChildren(parent).length, position];
|
||||
}
|
||||
|
||||
// If it is a dragged node...
|
||||
$assert($defined(position), "position cannot be null for predict in dragging");
|
||||
var nodeDirection = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
|
||||
var positionDirection = this._getRelativeDirection(rootNode.getPosition(), position);
|
||||
var siblings = graph.getSiblings(node);
|
||||
|
||||
// node has no siblings and its trying to reconnect to its own parent
|
||||
var sameParent = parent == graph.getParent(node);
|
||||
if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) {
|
||||
return [node.getOrder(), node.getPosition()];
|
||||
}
|
||||
|
||||
var parentChildren = graph.getChildren(parent);
|
||||
|
||||
if (parentChildren.length == 0) {
|
||||
// Fit as a child of the parent node...
|
||||
var position = {
|
||||
x:parent.getPosition().x + positionDirection * (parent.getSize().width + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
|
||||
y:parent.getPosition().y
|
||||
};
|
||||
return [0, position];
|
||||
} else {
|
||||
// Try to fit within ...
|
||||
var result = null;
|
||||
var last = parentChildren.getLast();
|
||||
for (var i = 0; i < parentChildren.length; i++) {
|
||||
var parentChild = parentChildren[i];
|
||||
var nodeAfter = (i + 1) == parentChild.length ? null : parentChildren[i + 1];
|
||||
|
||||
// Fit at the bottom
|
||||
if (!nodeAfter && position.y > parentChild.getPosition().y) {
|
||||
var order = (graph.getParent(node) && graph.getParent(node).getId() == parent.getId()) ?
|
||||
last.getOrder() : last.getOrder() + 1;
|
||||
var position = {
|
||||
x:parentChild.getPosition().x,
|
||||
y:parentChild.getPosition().y + parentChild.getSize().height + mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
|
||||
};
|
||||
return [order, position];
|
||||
}
|
||||
|
||||
// Fit after this node
|
||||
if (nodeAfter && position.y > parentChild.getPosition().y && position.y < nodeAfter.getPosition().y) {
|
||||
if (nodeAfter.getId() == node.getId() || parentChild.getId() == node.getId()) {
|
||||
return [node.getOrder(), node.getPosition()];
|
||||
} else {
|
||||
var order = position.y > node.getPosition().y ?
|
||||
nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1;
|
||||
var position = {
|
||||
x:parentChild.getPosition().x,
|
||||
y:parentChild.getPosition().y + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2
|
||||
};
|
||||
|
||||
return [order, position];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Position wasn't below any node, so it must be fitted above the first
|
||||
var first = parentChildren[0];
|
||||
var position = {
|
||||
x:first.getPosition().x,
|
||||
y:first.getPosition().y - first.getSize().height - mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
|
||||
};
|
||||
return [0, position];
|
||||
},
|
||||
|
||||
insert:function (treeSet, parent, child, order) {
|
||||
var children = this._getSortedChildren(treeSet, parent);
|
||||
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
|
||||
|
||||
// Shift all the elements in one .
|
||||
for (var i = order; i < children.length; i++) {
|
||||
var node = children[i];
|
||||
node.setOrder(i + 1);
|
||||
}
|
||||
child.setOrder(order);
|
||||
},
|
||||
|
||||
detach:function (treeSet, node) {
|
||||
var parent = treeSet.getParent(node);
|
||||
var children = this._getSortedChildren(treeSet, parent);
|
||||
var order = node.getOrder();
|
||||
$assert(children[order] === node, "Node seems not to be in the right position");
|
||||
|
||||
// Shift all the nodes ...
|
||||
for (var i = node.getOrder() + 1; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
child.setOrder(child.getOrder() - 1);
|
||||
}
|
||||
node.setOrder(0);
|
||||
},
|
||||
|
||||
computeOffsets:function (treeSet, node) {
|
||||
$assert(treeSet, "treeSet can no be null.");
|
||||
$assert(node, "node can no be null.");
|
||||
|
||||
var children = this._getSortedChildren(treeSet, node);
|
||||
|
||||
// Compute heights ...
|
||||
var heights = children.map(
|
||||
function (child) {
|
||||
return {id:child.getId(), order:child.getOrder(), position:child.getPosition(), width:child.getSize().width, height:this._computeChildrenHeight(treeSet, child)};
|
||||
}, this).reverse();
|
||||
|
||||
// Compute the center of the branch ...
|
||||
var totalHeight = 0;
|
||||
heights.each(function (elem) {
|
||||
totalHeight += elem.height;
|
||||
});
|
||||
var ysum = totalHeight / 2;
|
||||
|
||||
// Calculate the offsets ...
|
||||
var result = {};
|
||||
for (var i = 0; i < heights.length; i++) {
|
||||
ysum = ysum - heights[i].height;
|
||||
var childNode = treeSet.find(heights[i].id);
|
||||
var direction = this.getChildDirection(treeSet, childNode);
|
||||
|
||||
var yOffset = ysum + heights[i].height / 2;
|
||||
var xOffset = direction * (heights[i].width / 2 + node.getSize().width / 2 + mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
|
||||
|
||||
$assert(!isNaN(xOffset), "xOffset can not be null");
|
||||
$assert(!isNaN(yOffset), "yOffset can not be null");
|
||||
|
||||
result[heights[i].id] = {x:xOffset, y:yOffset};
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
verify:function (treeSet, node) {
|
||||
// Check that all is consistent ...
|
||||
var children = this._getSortedChildren(treeSet, node);
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
$assert(children[i].getOrder() == i, "missing order elements");
|
||||
}
|
||||
},
|
||||
|
||||
getChildDirection:function (treeSet, child) {
|
||||
$assert(treeSet, "treeSet can no be null.");
|
||||
$assert(treeSet.getParent(child), "This should not happen");
|
||||
|
||||
var result;
|
||||
var rootNode = treeSet.getRootNode(child);
|
||||
if (treeSet.getParent(child) == rootNode) {
|
||||
// This is the case of a isolated child ... In this case, the directions is based on the root.
|
||||
result = Math.sign(rootNode.getPosition().x);
|
||||
} else {
|
||||
// if this is not the case, honor the direction of the parent ...
|
||||
var parent = treeSet.getParent(child);
|
||||
var grandParent = treeSet.getParent(parent);
|
||||
var sorter = grandParent.getSorter();
|
||||
result = sorter.getChildDirection(treeSet, parent);
|
||||
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
toString:function () {
|
||||
return "Symmetric Sorter";
|
||||
},
|
||||
|
||||
_getVerticalPadding:function () {
|
||||
return mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING;
|
||||
}
|
||||
});
|
||||
|
||||
mindplot.layout.SymmetricSorter.INTERNODE_VERTICAL_PADDING = 5;
|
||||
mindplot.layout.SymmetricSorter.INTERNODE_HORIZONTAL_PADDING = 30;
|
||||
|
||||
|
|
@ -1,971 +0,0 @@
|
|||
//
|
||||
// LESS - Leaner CSS v1.1.3
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2009-2011, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
//
|
||||
// LESS - Leaner CSS v1.1.3
|
||||
// http://lesscss.org
|
||||
//
|
||||
// Copyright (c) 2009-2011, Alexis Sellier
|
||||
// Licensed under the Apache 2.0 License.
|
||||
//
|
||||
(function(a, b) {
|
||||
function v(a, b) {
|
||||
var c = "less-error-message:" + p(b),e = ["<ul>",'<li><label>[-1]</label><pre class="ctx">{0}</pre></li>',"<li><label>[0]</label><pre>{current}</pre></li>",'<li><label>[1]</label><pre class="ctx">{2}</pre></li>',"</ul>"].join("\n"),f = document.createElement("div"),g,h;
|
||||
f.id = c,f.className = "less-error-message",h = "<h3>" + (a.message || "There is an error in your .less file") + "</h3>" + '<p><a href="' + b + '">' + b + "</a> ",a.extract && (h += "on line " + a.line + ", column " + (a.column + 1) + ":</p>" + e.replace(/\[(-?\d)\]/g,
|
||||
function(b, c) {
|
||||
return parseInt(a.line) + parseInt(c) || ""
|
||||
}).replace(/\{(\d)\}/g,
|
||||
function(b, c) {
|
||||
return a.extract[parseInt(c)] || ""
|
||||
}).replace(/\{current\}/, a.extract[1].slice(0, a.column) + '<span class="error">' + a.extract[1].slice(a.column) + "</span>")),f.innerHTML = h,q([".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #ee4444;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.ctx {","color: #dd4444;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"), {title:"error-message"}),f.style.cssText = ["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),d.env == "development" && (g = setInterval(function() {
|
||||
document.body && (document.getElementById(c) ? document.body.replaceChild(f, document.getElementById(c)) : document.body.insertBefore(f, document.body.firstChild),clearInterval(g))
|
||||
}, 10))
|
||||
}
|
||||
|
||||
function u(a) {
|
||||
d.env == "development" && typeof console != "undefined" && console.log("less: " + a)
|
||||
}
|
||||
|
||||
function t(a) {
|
||||
return a && a.parentNode.removeChild(a)
|
||||
}
|
||||
|
||||
function s() {
|
||||
if (a.XMLHttpRequest)return new XMLHttpRequest;
|
||||
try {
|
||||
return new ActiveXObject("MSXML2.XMLHTTP.3.0")
|
||||
} catch(b) {
|
||||
u("browser doesn't support AJAX.");
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function r(a, b, c, e) {
|
||||
function i(b, c, d) {
|
||||
b.status >= 200 && b.status < 300 ? c(b.responseText, b.getResponseHeader("Last-Modified")) : typeof d == "function" && d(b.status, a)
|
||||
}
|
||||
|
||||
var f = s(),h = g ? !1 : d.async;
|
||||
typeof f.overrideMimeType == "function" && f.overrideMimeType("text/css"),f.open("GET", a, h),f.setRequestHeader("Accept", b || "text/x-less, text/css; q=0.9, */*; q=0.5"),f.send(null),g ? f.status === 0 ? c(f.responseText) : e(f.status, a) : h ? f.onreadystatechange = function() {
|
||||
f.readyState == 4 && i(f, c, e)
|
||||
} : i(f, c, e)
|
||||
}
|
||||
|
||||
function q(a, b, c) {
|
||||
var d,e = b.href ? b.href.replace(/\?.*$/, "") : "",f = "less:" + (b.title || p(e));
|
||||
(d = document.getElementById(f)) === null && (d = document.createElement("style"),d.type = "text/css",d.media = b.media || "screen",d.id = f,document.getElementsByTagName("head")[0].appendChild(d));
|
||||
if (d.styleSheet)try {
|
||||
d.styleSheet.cssText = a
|
||||
} catch(g) {
|
||||
throw new Error("Couldn't reassign styleSheet.cssText.")
|
||||
} else(function(a) {
|
||||
d.childNodes.length > 0 ? d.firstChild.nodeValue !== a.nodeValue && d.replaceChild(a, d.firstChild) : d.appendChild(a)
|
||||
})(document.createTextNode(a));
|
||||
c && h && (u("saving " + e + " to cache."),h.setItem(e, a),h.setItem(e + ":timestamp", c))
|
||||
}
|
||||
|
||||
function p(a) {
|
||||
return a.replace(/^[a-z]+:\/\/?[^\/]+/, "").replace(/^\//, "").replace(/\?.*$/, "").replace(/\.[^\.\/]+$/, "").replace(/[^\.\w-]+/g, "-").replace(/\./g, ":")
|
||||
}
|
||||
|
||||
function o(b, c, e, f) {
|
||||
var g = a.location.href.replace(/[#?].*$/, ""),i = b.href.replace(/\?.*$/, ""),j = h && h.getItem(i),k = h && h.getItem(i + ":timestamp"),l = {css:j,timestamp:k};
|
||||
/^(https?|file):/.test(i) || (i.charAt(0) == "/" ? i = a.location.protocol + "//" + a.location.host + i : i = g.slice(0, g.lastIndexOf("/") + 1) + i),r(b.href, b.type, function(a, g) {
|
||||
if (!e && l && g && (new Date(g)).valueOf() === (new Date(l.timestamp)).valueOf())q(l.css, b),c(null, b, {local:!0,remaining:f}); else try {
|
||||
(new d.Parser({optimization:d.optimization,paths:[i.replace(/[\w\.-]+$/, "")],mime:b.type})).parse(a, function(a, d) {
|
||||
if (a)return v(a, i);
|
||||
try {
|
||||
c(d, b, {local:!1,lastModified:g,remaining:f}),t(document.getElementById("less-error-message:" + p(i)))
|
||||
} catch(a) {
|
||||
v(a, i)
|
||||
}
|
||||
})
|
||||
} catch(h) {
|
||||
v(h, i)
|
||||
}
|
||||
}, function(a, b) {
|
||||
throw new Error("Couldn't load " + b + " (" + a + ")")
|
||||
})
|
||||
}
|
||||
|
||||
function n(a, b) {
|
||||
for (var c = 0; c < d.sheets.length; c++)o(d.sheets[c], a, b, d.sheets.length - (c + 1))
|
||||
}
|
||||
|
||||
function m() {
|
||||
var a = document.getElementsByTagName("style");
|
||||
for (var b = 0; b < a.length; b++)a[b].type.match(k) && (new d.Parser).parse(a[b].innerHTML || "", function(c, d) {
|
||||
a[b].type = "text/css",a[b].innerHTML = d.toCSS()
|
||||
})
|
||||
}
|
||||
|
||||
function c(b) {
|
||||
return a.less[b.split("/")[1]]
|
||||
}
|
||||
|
||||
Array.isArray || (Array.isArray = function(a) {
|
||||
return Object.prototype.toString.call(a) === "[object Array]" || a instanceof Array
|
||||
}),Array.prototype.forEach || (Array.prototype.forEach = function(a, b) {
|
||||
var c = this.length >>> 0;
|
||||
for (var d = 0; d < c; d++)d in this && a.call(b, this[d], d, this)
|
||||
}),Array.prototype.map || (Array.prototype.map = function(a) {
|
||||
var b = this.length >>> 0,c = Array(b),d = arguments[1];
|
||||
for (var e = 0; e < b; e++)e in this && (c[e] = a.call(d, this[e], e, this));
|
||||
return c
|
||||
}),Array.prototype.filter || (Array.prototype.filter = function(a) {
|
||||
var b = [],c = arguments[1];
|
||||
for (var d = 0; d < this.length; d++)a.call(c, this[d]) && b.push(this[d]);
|
||||
return b
|
||||
}),Array.prototype.reduce || (Array.prototype.reduce = function(a) {
|
||||
var b = this.length >>> 0,c = 0;
|
||||
if (b === 0 && arguments.length === 1)throw new TypeError;
|
||||
if (arguments.length >= 2)var d = arguments[1]; else for (; ;) {
|
||||
if (c in this) {
|
||||
d = this[c++];
|
||||
break
|
||||
}
|
||||
if (++c >= b)throw new TypeError
|
||||
}
|
||||
for (; c < b; c++)c in this && (d = a.call(null, d, this[c], c, this));
|
||||
return d
|
||||
}),Array.prototype.indexOf || (Array.prototype.indexOf = function(a) {
|
||||
var b = this.length,c = arguments[1] || 0;
|
||||
if (!b)return-1;
|
||||
if (c >= b)return-1;
|
||||
c < 0 && (c += b);
|
||||
for (; c < b; c++) {
|
||||
if (!Object.prototype.hasOwnProperty.call(this, c))continue;
|
||||
if (a === this[c])return c
|
||||
}
|
||||
return-1
|
||||
}),Object.keys || (Object.keys = function(a) {
|
||||
var b = [];
|
||||
for (var c in a)Object.prototype.hasOwnProperty.call(a, c) && b.push(c);
|
||||
return b
|
||||
}),String.prototype.trim || (String.prototype.trim = function() {
|
||||
return String(this).replace(/^\s\s*/, "").replace(/\s\s*$/, "")
|
||||
});
|
||||
var d,e;
|
||||
typeof a == "undefined" ? (d = exports,e = c("less/tree")) : (typeof a.less == "undefined" && (a.less = {}),d = a.less,e = a.less.tree = {}),d.Parser = function(a) {
|
||||
function t(a) {
|
||||
return typeof a == "string" ? b.charAt(c) === a : a.test(j[f]) ? !0 : !1
|
||||
}
|
||||
|
||||
function s(a) {
|
||||
var d,e,g,h,i,m,n,o;
|
||||
if (a instanceof Function)return a.call(l.parsers);
|
||||
if (typeof a == "string")d = b.charAt(c) === a ? a : null,g = 1,r(); else {
|
||||
r();
|
||||
if (d = a.exec(j[f]))g = d[0].length; else return null
|
||||
}
|
||||
if (d) {
|
||||
o = c += g,m = c + j[f].length - g;
|
||||
while (c < m) {
|
||||
h = b.charCodeAt(c);
|
||||
if (h !== 32 && h !== 10 && h !== 9)break;
|
||||
c++
|
||||
}
|
||||
j[f] = j[f].slice(g + (c - o)),k = c,j[f].length === 0 && f < j.length - 1 && f++;
|
||||
return typeof d == "string" ? d : d.length === 1 ? d[0] : d
|
||||
}
|
||||
}
|
||||
|
||||
function r() {
|
||||
c > k && (j[f] = j[f].slice(c - k),k = c)
|
||||
}
|
||||
|
||||
function q() {
|
||||
j[f] = g,c = h,k = c
|
||||
}
|
||||
|
||||
function p() {
|
||||
g = j[f],h = c,k = c
|
||||
}
|
||||
|
||||
var b,c,f,g,h,i,j,k,l,m = this,n = function() {
|
||||
},o = this.imports = {paths:a && a.paths || [],queue:[],files:{},mime:a && a.mime,push:function(b, c) {
|
||||
var e = this;
|
||||
this.queue.push(b),d.Parser.importer(b, this.paths, function(a) {
|
||||
e.queue.splice(e.queue.indexOf(b), 1),e.files[b] = a,c(a),e.queue.length === 0 && n()
|
||||
}, a)
|
||||
}};
|
||||
this.env = a = a || {},this.optimization = "optimization"in this.env ? this.env.optimization : 1,this.env.filename = this.env.filename || null;
|
||||
return l = {imports:o,parse:function(d, g) {
|
||||
var h,l,m,o,p,q,r = [],t,u = null;
|
||||
c = f = k = i = 0,j = [],b = d.replace(/\r\n/g, "\n"),j = function(c) {
|
||||
var d = 0,e = /[^"'`\{\}\/\(\)]+/g,f = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,g = 0,h,i = c[0],j,k;
|
||||
for (var l = 0,m,n; l < b.length; l++) {
|
||||
e.lastIndex = l,(h = e.exec(b)) && h.index === l && (l += h[0].length,i.push(h[0])),m = b.charAt(l),f.lastIndex = l,!k && !j && m === "/" && (n = b.charAt(l + 1),(n === "/" || n === "*") && (h = f.exec(b)) && h.index === l && (l += h[0].length,i.push(h[0]),m = b.charAt(l)));
|
||||
if (m === "{" && !k && !j)g++,i.push(m); else if (m === "}" && !k && !j)g--,i.push(m),c[++d] = i = []; else if (m === "(" && !k && !j)i.push(m),j = !0; else if (m === ")" && !k && j)i.push(m),j = !1; else {
|
||||
if (m === '"' || m === "'" || m === "`")k ? k = k === m ? !1 : k : k = m;
|
||||
i.push(m)
|
||||
}
|
||||
}
|
||||
if (g > 0)throw{type:"Syntax",message:"Missing closing `}`",filename:a.filename};
|
||||
return c.map(function(a) {
|
||||
return a.join("")
|
||||
})
|
||||
}([
|
||||
[]
|
||||
]),h = new e.Ruleset([], s(this.parsers.primary)),h.root = !0,h.toCSS = function(c) {
|
||||
var d,f,g;
|
||||
return function(g, h) {
|
||||
function n(a) {
|
||||
return a ? (b.slice(0, a).match(/\n/g) || "").length : null
|
||||
}
|
||||
|
||||
var i = [];
|
||||
g = g || {},typeof h == "object" && !Array.isArray(h) && (h = Object.keys(h).map(function(a) {
|
||||
var b = h[a];
|
||||
b instanceof e.Value || (b instanceof e.Expression || (b = new e.Expression([b])),b = new e.Value([b]));
|
||||
return new e.Rule("@" + a, b, !1, 0)
|
||||
}),i = [new e.Ruleset(null, h)]);
|
||||
try {
|
||||
var j = c.call(this, {frames:i}).toCSS([], {compress:g.compress || !1})
|
||||
} catch(k) {
|
||||
f = b.split("\n"),d = n(k.index);
|
||||
for (var l = k.index,m = -1; l >= 0 && b.charAt(l) !== "\n"; l--)m++;
|
||||
throw{type:k.type,message:k.message,filename:a.filename,index:k.index,line:typeof d == "number" ? d + 1 : null,callLine:k.call && n(k.call) + 1,callExtract:f[n(k.call)],stack:k.stack,column:m,extract:[f[d - 1],f[d],f[d + 1]]}
|
||||
}
|
||||
return g.compress ? j.replace(/(\s)+/g, "$1") : j
|
||||
}
|
||||
}(h.eval);
|
||||
if (c < b.length - 1) {
|
||||
c = i,q = b.split("\n"),p = (b.slice(0, c).match(/\n/g) || "").length + 1;
|
||||
for (var v = c,w = -1; v >= 0 && b.charAt(v) !== "\n"; v--)w++;
|
||||
u = {name:"ParseError",message:"Syntax Error on line " + p,index:c,filename:a.filename,line:p,column:w,extract:[q[p - 2],q[p - 1],q[p]]}
|
||||
}
|
||||
this.imports.queue.length > 0 ? n = function() {
|
||||
g(u, h)
|
||||
} : g(u, h)
|
||||
},parsers:{primary:function() {
|
||||
var a,b = [];
|
||||
while ((a = s(this.mixin.definition) || s(this.rule) || s(this.ruleset) || s(this.mixin.call) || s(this.comment) || s(this.directive)) || s(/^[\s\n]+/))a && b.push(a);
|
||||
return b
|
||||
},comment:function() {
|
||||
var a;
|
||||
if (b.charAt(c) === "/") {
|
||||
if (b.charAt(c + 1) === "/")return new e.Comment(s(/^\/\/.*/), !0);
|
||||
if (a = s(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new e.Comment(a)
|
||||
}
|
||||
},entities:{quoted:function() {
|
||||
var a,d = c,f;
|
||||
b.charAt(d) === "~" && (d++,f = !0);
|
||||
if (b.charAt(d) === '"' || b.charAt(d) === "'") {
|
||||
f && s("~");
|
||||
if (a = s(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new e.Quoted(a[0], a[1] || a[2], f)
|
||||
}
|
||||
},keyword:function() {
|
||||
var a;
|
||||
if (a = s(/^[A-Za-z-]+/))return new e.Keyword(a)
|
||||
},call:function() {
|
||||
var a,b,d = c;
|
||||
if (!!(a = /^([\w-]+|%)\(/.exec(j[f]))) {
|
||||
a = a[1].toLowerCase();
|
||||
if (a === "url")return null;
|
||||
c += a.length;
|
||||
if (a === "alpha")return s(this.alpha);
|
||||
s("("),b = s(this.entities.arguments);
|
||||
if (!s(")"))return;
|
||||
if (a)return new e.Call(a, b, d)
|
||||
}
|
||||
},arguments:function() {
|
||||
var a = [],b;
|
||||
while (b = s(this.expression)) {
|
||||
a.push(b);
|
||||
if (!s(","))break
|
||||
}
|
||||
return a
|
||||
},literal:function() {
|
||||
return s(this.entities.dimension) || s(this.entities.color) || s(this.entities.quoted)
|
||||
},url:function() {
|
||||
var a;
|
||||
if (b.charAt(c) === "u" && !!s(/^url\(/)) {
|
||||
a = s(this.entities.quoted) || s(this.entities.variable) || s(this.entities.dataURI) || s(/^[-\w%@$\/.&=:;#+?~]+/) || "";
|
||||
if (!s(")"))throw new Error("missing closing ) for url()");
|
||||
return new e.URL(a.value || a.data || a instanceof e.Variable ? a : new e.Anonymous(a), o.paths)
|
||||
}
|
||||
},dataURI:function() {
|
||||
var a;
|
||||
if (s(/^data:/)) {
|
||||
a = {},a.mime = s(/^[^\/]+\/[^,;)]+/) || "",a.charset = s(/^;\s*charset=[^,;)]+/) || "",a.base64 = s(/^;\s*base64/) || "",a.data = s(/^,\s*[^)]+/);
|
||||
if (a.data)return a
|
||||
}
|
||||
},variable:function() {
|
||||
var a,d = c;
|
||||
if (b.charAt(c) === "@" && (a = s(/^@@?[\w-]+/)))return new e.Variable(a, d)
|
||||
},color:function() {
|
||||
var a;
|
||||
if (b.charAt(c) === "#" && (a = s(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new e.Color(a[1])
|
||||
},dimension:function() {
|
||||
var a,d = b.charCodeAt(c);
|
||||
if (!(d > 57 || d < 45 || d === 47))if (a = s(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/))return new e.Dimension(a[1], a[2])
|
||||
},javascript:function() {
|
||||
var a,d = c,f;
|
||||
b.charAt(d) === "~" && (d++,f = !0);
|
||||
if (b.charAt(d) === "`") {
|
||||
f && s("~");
|
||||
if (a = s(/^`([^`]*)`/))return new e.JavaScript(a[1], c, f)
|
||||
}
|
||||
}},variable:function() {
|
||||
var a;
|
||||
if (b.charAt(c) === "@" && (a = s(/^(@[\w-]+)\s*:/)))return a[1]
|
||||
},shorthand:function() {
|
||||
var a,b;
|
||||
if (!!t(/^[@\w.%-]+\/[@\w.-]+/) && (a = s(this.entity)) && s("/") && (b = s(this.entity)))return new e.Shorthand(a, b)
|
||||
},mixin:{call:function() {
|
||||
var a = [],d,f,g,h = c,i = b.charAt(c);
|
||||
if (i === "." || i === "#") {
|
||||
while (d = s(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/))a.push(new e.Element(f, d)),f = s(">");
|
||||
s("(") && (g = s(this.entities.arguments)) && s(")");
|
||||
if (a.length > 0 && (s(";") || t("}")))return new e.mixin.Call(a, g, h)
|
||||
}
|
||||
},definition:function() {
|
||||
var a,d = [],f,g,h,i;
|
||||
if (!(b.charAt(c) !== "." && b.charAt(c) !== "#" || t(/^[^{]*(;|})/)))if (f = s(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) {
|
||||
a = f[1];
|
||||
while (h = s(this.entities.variable) || s(this.entities.literal) || s(this.entities.keyword)) {
|
||||
if (h instanceof e.Variable)if (s(":"))if (i = s(this.expression))d.push({name:h.name,value:i}); else throw new Error("Expected value"); else d.push({name:h.name}); else d.push({value:h});
|
||||
if (!s(","))break
|
||||
}
|
||||
if (!s(")"))throw new Error("Expected )");
|
||||
g = s(this.block);
|
||||
if (g)return new e.mixin.Definition(a, d, g)
|
||||
}
|
||||
}},entity:function() {
|
||||
return s(this.entities.literal) || s(this.entities.variable) || s(this.entities.url) || s(this.entities.call) || s(this.entities.keyword) || s(this.entities.javascript) || s(this.comment)
|
||||
},end:function() {
|
||||
return s(";") || t("}")
|
||||
},alpha:function() {
|
||||
var a;
|
||||
if (!!s(/^\(opacity=/i))if (a = s(/^\d+/) || s(this.entities.variable)) {
|
||||
if (!s(")"))throw new Error("missing closing ) for alpha()");
|
||||
return new e.Alpha(a)
|
||||
}
|
||||
},element:function() {
|
||||
var a,b,c;
|
||||
c = s(this.combinator),a = s(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || s("*") || s(this.attribute) || s(/^\([^)@]+\)/);
|
||||
if (a)return new e.Element(c, a)
|
||||
},combinator:function() {
|
||||
var a,d = b.charAt(c);
|
||||
if (d === ">" || d === "&" || d === "+" || d === "~") {
|
||||
c++;
|
||||
while (b.charAt(c) === " ")c++;
|
||||
return new e.Combinator(d)
|
||||
}
|
||||
if (d === ":" && b.charAt(c + 1) === ":") {
|
||||
c += 2;
|
||||
while (b.charAt(c) === " ")c++;
|
||||
return new e.Combinator("::")
|
||||
}
|
||||
return b.charAt(c - 1) === " " ? new e.Combinator(" ") : new e.Combinator(null)
|
||||
},selector:function() {
|
||||
var a,d,f = [],g,h;
|
||||
while (d = s(this.element)) {
|
||||
g = b.charAt(c),f.push(d);
|
||||
if (g === "{" || g === "}" || g === ";" || g === ",")break
|
||||
}
|
||||
if (f.length > 0)return new e.Selector(f)
|
||||
},tag:function() {
|
||||
return s(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || s("*")
|
||||
},attribute:function() {
|
||||
var a = "",b,c,d;
|
||||
if (!!s("[")) {
|
||||
if (b = s(/^[a-zA-Z-]+/) || s(this.entities.quoted))(d = s(/^[|~*$^]?=/)) && (c = s(this.entities.quoted) || s(/^[\w-]+/)) ? a = [b,d,c.toCSS ? c.toCSS() : c].join("") : a = b;
|
||||
if (!s("]"))return;
|
||||
if (a)return"[" + a + "]"
|
||||
}
|
||||
},block:function() {
|
||||
var a;
|
||||
if (s("{") && (a = s(this.primary)) && s("}"))return a
|
||||
},ruleset:function() {
|
||||
var a = [],b,d,g;
|
||||
p();
|
||||
if (g = /^([.#: \w-]+)[\s\n]*\{/.exec(j[f]))c += g[0].length - 1,a = [new e.Selector([new e.Element(null, g[1])])]; else while (b = s(this.selector)) {
|
||||
a.push(b),s(this.comment);
|
||||
if (!s(","))break;
|
||||
s(this.comment)
|
||||
}
|
||||
if (a.length > 0 && (d = s(this.block)))return new e.Ruleset(a, d);
|
||||
i = c,q()
|
||||
},rule:function() {
|
||||
var a,d,g = b.charAt(c),k,l;
|
||||
p();
|
||||
if (g !== "." && g !== "#" && g !== "&")if (a = s(this.variable) || s(this.property)) {
|
||||
a.charAt(0) != "@" && (l = /^([^@+\/'"*`(;{}-]*);/.exec(j[f])) ? (c += l[0].length - 1,d = new e.Anonymous(l[1])) : a === "font" ? d = s(this.font) : d = s(this.value),k = s(this.important);
|
||||
if (d && s(this.end))return new e.Rule(a, d, k, h);
|
||||
i = c,q()
|
||||
}
|
||||
},"import":function() {
|
||||
var a;
|
||||
if (s(/^@import\s+/) && (a = s(this.entities.quoted) || s(this.entities.url)) && s(";"))return new e.Import(a, o)
|
||||
},directive:function() {
|
||||
var a,d,f,g;
|
||||
if (b.charAt(c) === "@") {
|
||||
if (d = s(this["import"]))return d;
|
||||
if (a = s(/^@media|@page|@-[-a-z]+/)) {
|
||||
g = (s(/^[^{]+/) || "").trim();
|
||||
if (f = s(this.block))return new e.Directive(a + " " + g, f)
|
||||
} else if (a = s(/^@[-a-z]+/))if (a === "@font-face") {
|
||||
if (f = s(this.block))return new e.Directive(a, f)
|
||||
} else if ((d = s(this.entity)) && s(";"))return new e.Directive(a, d)
|
||||
}
|
||||
},font:function() {
|
||||
var a = [],b = [],c,d,f,g;
|
||||
while (g = s(this.shorthand) || s(this.entity))b.push(g);
|
||||
a.push(new e.Expression(b));
|
||||
if (s(","))while (g = s(this.expression)) {
|
||||
a.push(g);
|
||||
if (!s(","))break
|
||||
}
|
||||
return new e.Value(a)
|
||||
},value:function() {
|
||||
var a,b = [],c;
|
||||
while (a = s(this.expression)) {
|
||||
b.push(a);
|
||||
if (!s(","))break
|
||||
}
|
||||
if (b.length > 0)return new e.Value(b)
|
||||
},important:function() {
|
||||
if (b.charAt(c) === "!")return s(/^! *important/)
|
||||
},sub:function() {
|
||||
var a;
|
||||
if (s("(") && (a = s(this.expression)) && s(")"))return a
|
||||
},multiplication:function() {
|
||||
var a,b,c,d;
|
||||
if (a = s(this.operand)) {
|
||||
while ((c = s("/") || s("*")) && (b = s(this.operand)))d = new e.Operation(c, [d || a,b]);
|
||||
return d || a
|
||||
}
|
||||
},addition:function() {
|
||||
var a,d,f,g;
|
||||
if (a = s(this.multiplication)) {
|
||||
while ((f = s(/^[-+]\s+/) || b.charAt(c - 1) != " " && (s("+") || s("-"))) && (d = s(this.multiplication)))g = new e.Operation(f, [g || a,d]);
|
||||
return g || a
|
||||
}
|
||||
},operand:function() {
|
||||
var a,d = b.charAt(c + 1);
|
||||
b.charAt(c) === "-" && (d === "@" || d === "(") && (a = s("-"));
|
||||
var f = s(this.sub) || s(this.entities.dimension) || s(this.entities.color) || s(this.entities.variable) || s(this.entities.call);
|
||||
return a ? new e.Operation("*", [new e.Dimension(-1),f]) : f
|
||||
},expression:function() {
|
||||
var a,b,c = [],d;
|
||||
while (a = s(this.addition) || s(this.entity))c.push(a);
|
||||
if (c.length > 0)return new e.Expression(c)
|
||||
},property:function() {
|
||||
var a;
|
||||
if (a = s(/^(\*?-?[-a-z_0-9]+)\s*:/))return a[1]
|
||||
}}}
|
||||
},typeof a != "undefined" && (d.Parser.importer = function(a, b, c, d) {
|
||||
a.charAt(0) !== "/" && b.length > 0 && (a = b[0] + a),o({href:a,title:a,type:d.mime}, c, !0)
|
||||
}),function(a) {
|
||||
function d(a) {
|
||||
return Math.min(1, Math.max(0, a))
|
||||
}
|
||||
|
||||
function c(b) {
|
||||
if (b instanceof a.Dimension)return parseFloat(b.unit == "%" ? b.value / 100 : b.value);
|
||||
if (typeof b == "number")return b;
|
||||
throw{error:"RuntimeError",message:"color functions take numbers as parameters"}
|
||||
}
|
||||
|
||||
function b(b) {
|
||||
return a.functions.hsla(b.h, b.s, b.l, b.a)
|
||||
}
|
||||
|
||||
a.functions = {rgb:function(a, b, c) {
|
||||
return this.rgba(a, b, c, 1)
|
||||
},rgba:function(b, d, e, f) {
|
||||
var g = [b,d,e].map(function(a) {
|
||||
return c(a)
|
||||
}),f = c(f);
|
||||
return new a.Color(g, f)
|
||||
},hsl:function(a, b, c) {
|
||||
return this.hsla(a, b, c, 1)
|
||||
},hsla:function(a, b, d, e) {
|
||||
function h(a) {
|
||||
a = a < 0 ? a + 1 : a > 1 ? a - 1 : a;
|
||||
return a * 6 < 1 ? g + (f - g) * a * 6 : a * 2 < 1 ? f : a * 3 < 2 ? g + (f - g) * (2 / 3 - a) * 6 : g
|
||||
}
|
||||
|
||||
a = c(a) % 360 / 360,b = c(b),d = c(d),e = c(e);
|
||||
var f = d <= .5 ? d * (b + 1) : d + b - d * b,g = d * 2 - f;
|
||||
return this.rgba(h(a + 1 / 3) * 255, h(a) * 255, h(a - 1 / 3) * 255, e)
|
||||
},hue:function(b) {
|
||||
return new a.Dimension(Math.round(b.toHSL().h))
|
||||
},saturation:function(b) {
|
||||
return new a.Dimension(Math.round(b.toHSL().s * 100), "%")
|
||||
},lightness:function(b) {
|
||||
return new a.Dimension(Math.round(b.toHSL().l * 100), "%")
|
||||
},alpha:function(b) {
|
||||
return new a.Dimension(b.toHSL().a)
|
||||
},saturate:function(a, c) {
|
||||
var e = a.toHSL();
|
||||
e.s += c.value / 100,e.s = d(e.s);
|
||||
return b(e)
|
||||
},desaturate:function(a, c) {
|
||||
var e = a.toHSL();
|
||||
e.s -= c.value / 100,e.s = d(e.s);
|
||||
return b(e)
|
||||
},lighten:function(a, c) {
|
||||
var e = a.toHSL();
|
||||
e.l += c.value / 100,e.l = d(e.l);
|
||||
return b(e)
|
||||
},darken:function(a, c) {
|
||||
var e = a.toHSL();
|
||||
e.l -= c.value / 100,e.l = d(e.l);
|
||||
return b(e)
|
||||
},fadein:function(a, c) {
|
||||
var e = a.toHSL();
|
||||
e.a += c.value / 100,e.a = d(e.a);
|
||||
return b(e)
|
||||
},fadeout:function(a, c) {
|
||||
var e = a.toHSL();
|
||||
e.a -= c.value / 100,e.a = d(e.a);
|
||||
return b(e)
|
||||
},spin:function(a, c) {
|
||||
var d = a.toHSL(),e = (d.h + c.value) % 360;
|
||||
d.h = e < 0 ? 360 + e : e;
|
||||
return b(d)
|
||||
},mix:function(b, c, d) {
|
||||
var e = d.value / 100,f = e * 2 - 1,g = b.toHSL().a - c.toHSL().a,h = ((f * g == -1 ? f : (f + g) / (1 + f * g)) + 1) / 2,i = 1 - h,j = [b.rgb[0] * h + c.rgb[0] * i,b.rgb[1] * h + c.rgb[1] * i,b.rgb[2] * h + c.rgb[2] * i],k = b.alpha * e + c.alpha * (1 - e);
|
||||
return new a.Color(j, k)
|
||||
},greyscale:function(b) {
|
||||
return this.desaturate(b, new a.Dimension(100))
|
||||
},e:function(b) {
|
||||
return new a.Anonymous(b instanceof a.JavaScript ? b.evaluated : b)
|
||||
},escape:function(b) {
|
||||
return new a.Anonymous(encodeURI(b.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"))
|
||||
},"%":function(b) {
|
||||
var c = Array.prototype.slice.call(arguments, 1),d = b.value;
|
||||
for (var e = 0; e < c.length; e++)d = d.replace(/%[sda]/i, function(a) {
|
||||
var b = a.match(/s/i) ? c[e].value : c[e].toCSS();
|
||||
return a.match(/[A-Z]$/) ? encodeURIComponent(b) : b
|
||||
});
|
||||
d = d.replace(/%%/g, "%");
|
||||
return new a.Quoted('"' + d + '"', d)
|
||||
},round:function(b) {
|
||||
if (b instanceof a.Dimension)return new a.Dimension(Math.round(c(b)), b.unit);
|
||||
if (typeof b == "number")return Math.round(b);
|
||||
throw{error:"RuntimeError",message:"math functions take numbers as parameters"}
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Alpha = function(a) {
|
||||
this.value = a
|
||||
},a.Alpha.prototype = {toCSS:function() {
|
||||
return"alpha(opacity=" + (this.value.toCSS ? this.value.toCSS() : this.value) + ")"
|
||||
},eval:function(a) {
|
||||
this.value.eval && (this.value = this.value.eval(a));
|
||||
return this
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Anonymous = function(a) {
|
||||
this.value = a.value || a
|
||||
},a.Anonymous.prototype = {toCSS:function() {
|
||||
return this.value
|
||||
},eval:function() {
|
||||
return this
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Call = function(a, b, c) {
|
||||
this.name = a,this.args = b,this.index = c
|
||||
},a.Call.prototype = {eval:function(b) {
|
||||
var c = this.args.map(function(a) {
|
||||
return a.eval(b)
|
||||
});
|
||||
if (!(this.name in a.functions))return new a.Anonymous(this.name + "(" + c.map(
|
||||
function(a) {
|
||||
return a.toCSS()
|
||||
}).join(", ") + ")");
|
||||
try {
|
||||
return a.functions[this.name].apply(a.functions, c)
|
||||
} catch(d) {
|
||||
throw{message:"error evaluating function `" + this.name + "`",index:this.index}
|
||||
}
|
||||
},toCSS:function(a) {
|
||||
return this.eval(a).toCSS()
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Color = function(a, b) {
|
||||
Array.isArray(a) ? this.rgb = a : a.length == 6 ? this.rgb = a.match(/.{2}/g).map(function(a) {
|
||||
return parseInt(a, 16)
|
||||
}) : a.length == 8 ? (this.alpha = parseInt(a.substring(0, 2), 16) / 255,this.rgb = a.substr(2).match(/.{2}/g).map(function(a) {
|
||||
return parseInt(a, 16)
|
||||
})) : this.rgb = a.split("").map(function(a) {
|
||||
return parseInt(a + a, 16)
|
||||
}),this.alpha = typeof b == "number" ? b : 1
|
||||
},a.Color.prototype = {eval:function() {
|
||||
return this
|
||||
},toCSS:function() {
|
||||
return this.alpha < 1 ? "rgba(" + this.rgb.map(
|
||||
function(a) {
|
||||
return Math.round(a)
|
||||
}).concat(this.alpha).join(", ") + ")" : "#" + this.rgb.map(
|
||||
function(a) {
|
||||
a = Math.round(a),a = (a > 255 ? 255 : a < 0 ? 0 : a).toString(16);
|
||||
return a.length === 1 ? "0" + a : a
|
||||
}).join("")
|
||||
},operate:function(b, c) {
|
||||
var d = [];
|
||||
c instanceof a.Color || (c = c.toColor());
|
||||
for (var e = 0; e < 3; e++)d[e] = a.operate(b, this.rgb[e], c.rgb[e]);
|
||||
return new a.Color(d, this.alpha + c.alpha)
|
||||
},toHSL:function() {
|
||||
var a = this.rgb[0] / 255,b = this.rgb[1] / 255,c = this.rgb[2] / 255,d = this.alpha,e = Math.max(a, b, c),f = Math.min(a, b, c),g,h,i = (e + f) / 2,j = e - f;
|
||||
if (e === f)g = h = 0; else {
|
||||
h = i > .5 ? j / (2 - e - f) : j / (e + f);
|
||||
switch (e) {
|
||||
case a:
|
||||
g = (b - c) / j + (b < c ? 6 : 0);
|
||||
break;
|
||||
case b:
|
||||
g = (c - a) / j + 2;
|
||||
break;
|
||||
case c:
|
||||
g = (a - b) / j + 4
|
||||
}
|
||||
g /= 6
|
||||
}
|
||||
return{h:g * 360,s:h,l:i,a:d}
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Comment = function(a, b) {
|
||||
this.value = a,this.silent = !!b
|
||||
},a.Comment.prototype = {toCSS:function(a) {
|
||||
return a.compress ? "" : this.value
|
||||
},eval:function() {
|
||||
return this
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Dimension = function(a, b) {
|
||||
this.value = parseFloat(a),this.unit = b || null
|
||||
},a.Dimension.prototype = {eval:function() {
|
||||
return this
|
||||
},toColor:function() {
|
||||
return new a.Color([this.value,this.value,this.value])
|
||||
},toCSS:function() {
|
||||
var a = this.value + this.unit;
|
||||
return a
|
||||
},operate:function(b, c) {
|
||||
return new a.Dimension(a.operate(b, this.value, c.value), this.unit || c.unit)
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Directive = function(b, c) {
|
||||
this.name = b,Array.isArray(c) ? this.ruleset = new a.Ruleset([], c) : this.value = c
|
||||
},a.Directive.prototype = {toCSS:function(a, b) {
|
||||
if (this.ruleset) {
|
||||
this.ruleset.root = !0;
|
||||
return this.name + (b.compress ? "{" : " {\n ") + this.ruleset.toCSS(a, b).trim().replace(/\n/g, "\n ") + (b.compress ? "}" : "\n}\n")
|
||||
}
|
||||
return this.name + " " + this.value.toCSS() + ";\n"
|
||||
},eval:function(a) {
|
||||
a.frames.unshift(this),this.ruleset = this.ruleset && this.ruleset.eval(a),a.frames.shift();
|
||||
return this
|
||||
},variable:function(b) {
|
||||
return a.Ruleset.prototype.variable.call(this.ruleset, b)
|
||||
},find:function() {
|
||||
return a.Ruleset.prototype.find.apply(this.ruleset, arguments)
|
||||
},rulesets:function() {
|
||||
return a.Ruleset.prototype.rulesets.apply(this.ruleset)
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Element = function(b, c) {
|
||||
this.combinator = b instanceof a.Combinator ? b : new a.Combinator(b),this.value = c.trim()
|
||||
},a.Element.prototype.toCSS = function(a) {
|
||||
return this.combinator.toCSS(a || {}) + this.value
|
||||
},a.Combinator = function(a) {
|
||||
a === " " ? this.value = " " : this.value = a ? a.trim() : ""
|
||||
},a.Combinator.prototype.toCSS = function(a) {
|
||||
return{"":""," ":" ","&":"",":":" :","::":"::","+":a.compress ? "+" : " + ","~":a.compress ? "~" : " ~ ",">":a.compress ? ">" : " > "}[this.value]
|
||||
}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Expression = function(a) {
|
||||
this.value = a
|
||||
},a.Expression.prototype = {eval:function(b) {
|
||||
return this.value.length > 1 ? new a.Expression(this.value.map(function(a) {
|
||||
return a.eval(b)
|
||||
})) : this.value.length === 1 ? this.value[0].eval(b) : this
|
||||
},toCSS:function(a) {
|
||||
return this.value.map(
|
||||
function(b) {
|
||||
return b.toCSS(a)
|
||||
}).join(" ")
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Import = function(b, c) {
|
||||
var d = this;
|
||||
this._path = b,b instanceof a.Quoted ? this.path = /\.(le?|c)ss$/.test(b.value) ? b.value : b.value + ".less" : this.path = b.value.value || b.value,this.css = /css$/.test(this.path),this.css || c.push(this.path, function(a) {
|
||||
if (!a)throw new Error("Error parsing " + d.path);
|
||||
d.root = a
|
||||
})
|
||||
},a.Import.prototype = {toCSS:function() {
|
||||
return this.css ? "@import " + this._path.toCSS() + ";\n" : ""
|
||||
},eval:function(b) {
|
||||
var c;
|
||||
if (this.css)return this;
|
||||
c = new a.Ruleset(null, this.root.rules.slice(0));
|
||||
for (var d = 0; d < c.rules.length; d++)c.rules[d]instanceof a.Import && Array.prototype.splice.apply(c.rules, [d,1].concat(c.rules[d].eval(b)));
|
||||
return c.rules
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.JavaScript = function(a, b, c) {
|
||||
this.escaped = c,this.expression = a,this.index = b
|
||||
},a.JavaScript.prototype = {eval:function(b) {
|
||||
var c,d = this,e = {},f = this.expression.replace(/@\{([\w-]+)\}/g, function(c, e) {
|
||||
return a.jsify((new a.Variable("@" + e, d.index)).eval(b))
|
||||
});
|
||||
try {
|
||||
f = new Function("return (" + f + ")")
|
||||
} catch(g) {
|
||||
throw{message:"JavaScript evaluation error: `" + f + "`",index:this.index}
|
||||
}
|
||||
for (var h in b.frames[0].variables())e[h.slice(1)] = {value:b.frames[0].variables()[h].value,toJS:function() {
|
||||
return this.value.eval(b).toCSS()
|
||||
}};
|
||||
try {
|
||||
c = f.call(e)
|
||||
} catch(g) {
|
||||
throw{message:"JavaScript evaluation error: '" + g.name + ": " + g.message + "'",index:this.index}
|
||||
}
|
||||
return typeof c == "string" ? new a.Quoted('"' + c + '"', c, this.escaped, this.index) : Array.isArray(c) ? new a.Anonymous(c.join(", ")) : new a.Anonymous(c)
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Keyword = function(a) {
|
||||
this.value = a
|
||||
},a.Keyword.prototype = {eval:function() {
|
||||
return this
|
||||
},toCSS:function() {
|
||||
return this.value
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.mixin = {},a.mixin.Call = function(b, c, d) {
|
||||
this.selector = new a.Selector(b),this.arguments = c,this.index = d
|
||||
},a.mixin.Call.prototype = {eval:function(a) {
|
||||
var b,c,d = [],e = !1;
|
||||
for (var f = 0; f < a.frames.length; f++)if ((b = a.frames[f].find(this.selector)).length > 0) {
|
||||
c = this.arguments && this.arguments.map(function(b) {
|
||||
return b.eval(a)
|
||||
});
|
||||
for (var g = 0; g < b.length; g++)if (b[g].match(c, a))try {
|
||||
Array.prototype.push.apply(d, b[g].eval(a, this.arguments).rules),e = !0
|
||||
} catch(h) {
|
||||
throw{message:h.message,index:h.index,stack:h.stack,call:this.index}
|
||||
}
|
||||
if (e)return d;
|
||||
throw{message:"No matching definition was found for `" + this.selector.toCSS().trim() + "(" + this.arguments.map(
|
||||
function(a) {
|
||||
return a.toCSS()
|
||||
}).join(", ") + ")`",index:this.index}
|
||||
}
|
||||
throw{message:this.selector.toCSS().trim() + " is undefined",index:this.index}
|
||||
}},a.mixin.Definition = function(b, c, d) {
|
||||
this.name = b,this.selectors = [new a.Selector([new a.Element(null, b)])],this.params = c,this.arity = c.length,this.rules = d,this._lookups = {},this.required = c.reduce(function(a, b) {
|
||||
return!b.name || b.name && !b.value ? a + 1 : a
|
||||
}, 0),this.parent = a.Ruleset.prototype,this.frames = []
|
||||
},a.mixin.Definition.prototype = {toCSS:function() {
|
||||
return""
|
||||
},variable:function(a) {
|
||||
return this.parent.variable.call(this, a)
|
||||
},variables:function() {
|
||||
return this.parent.variables.call(this)
|
||||
},find:function() {
|
||||
return this.parent.find.apply(this, arguments)
|
||||
},rulesets:function() {
|
||||
return this.parent.rulesets.apply(this)
|
||||
},eval:function(b, c) {
|
||||
var d = new a.Ruleset(null, []),e,f = [];
|
||||
for (var g = 0,h; g < this.params.length; g++)if (this.params[g].name)if (h = c && c[g] || this.params[g].value)d.rules.unshift(new a.Rule(this.params[g].name, h.eval(b))); else throw{message:"wrong number of arguments for " + this.name + " (" + c.length + " for " + this.arity + ")"};
|
||||
for (var g = 0; g < Math.max(this.params.length, c && c.length); g++)f.push(c[g] || this.params[g].value);
|
||||
d.rules.unshift(new a.Rule("@arguments", (new a.Expression(f)).eval(b)));
|
||||
return(new a.Ruleset(null, this.rules.slice(0))).eval({frames:[this,d].concat(this.frames, b.frames)})
|
||||
},match:function(a, b) {
|
||||
var c = a && a.length || 0,d;
|
||||
if (c < this.required)return!1;
|
||||
if (this.required > 0 && c > this.params.length)return!1;
|
||||
d = Math.min(c, this.arity);
|
||||
for (var e = 0; e < d; e++)if (!this.params[e].name && a[e].eval(b).toCSS() != this.params[e].value.eval(b).toCSS())return!1;
|
||||
return!0
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Operation = function(a, b) {
|
||||
this.op = a.trim(),this.operands = b
|
||||
},a.Operation.prototype.eval = function(b) {
|
||||
var c = this.operands[0].eval(b),d = this.operands[1].eval(b),e;
|
||||
if (c instanceof a.Dimension && d instanceof a.Color)if (this.op === "*" || this.op === "+")e = d,d = c,c = e; else throw{name:"OperationError",message:"Can't substract or divide a color from a number"};
|
||||
return c.operate(this.op, d)
|
||||
},a.operate = function(a, b, c) {
|
||||
switch (a) {
|
||||
case"+":
|
||||
return b + c;
|
||||
case"-":
|
||||
return b - c;
|
||||
case"*":
|
||||
return b * c;
|
||||
case"/":
|
||||
return b / c
|
||||
}
|
||||
}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Quoted = function(a, b, c, d) {
|
||||
this.escaped = c,this.value = b || "",this.quote = a.charAt(0),this.index = d
|
||||
},a.Quoted.prototype = {toCSS:function() {
|
||||
return this.escaped ? this.value : this.quote + this.value + this.quote
|
||||
},eval:function(b) {
|
||||
var c = this,d = this.value.replace(/`([^`]+)`/g,
|
||||
function(d, e) {
|
||||
return(new a.JavaScript(e, c.index, !0)).eval(b).value
|
||||
}).replace(/@\{([\w-]+)\}/g, function(d, e) {
|
||||
var f = (new a.Variable("@" + e, c.index)).eval(b);
|
||||
return f.value || f.toCSS()
|
||||
});
|
||||
return new a.Quoted(this.quote + d + this.quote, d, this.escaped, this.index)
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Rule = function(b, c, d, e) {
|
||||
this.name = b,this.value = c instanceof a.Value ? c : new a.Value([c]),this.important = d ? " " + d.trim() : "",this.index = e,b.charAt(0) === "@" ? this.variable = !0 : this.variable = !1
|
||||
},a.Rule.prototype.toCSS = function(a) {
|
||||
return this.variable ? "" : this.name + (a.compress ? ":" : ": ") + this.value.toCSS(a) + this.important + ";"
|
||||
},a.Rule.prototype.eval = function(b) {
|
||||
return new a.Rule(this.name, this.value.eval(b), this.important, this.index)
|
||||
},a.Shorthand = function(a, b) {
|
||||
this.a = a,this.b = b
|
||||
},a.Shorthand.prototype = {toCSS:function(a) {
|
||||
return this.a.toCSS(a) + "/" + this.b.toCSS(a)
|
||||
},eval:function() {
|
||||
return this
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Ruleset = function(a, b) {
|
||||
this.selectors = a,this.rules = b,this._lookups = {}
|
||||
},a.Ruleset.prototype = {eval:function(b) {
|
||||
var c = new a.Ruleset(this.selectors, this.rules.slice(0));
|
||||
c.root = this.root,b.frames.unshift(c);
|
||||
if (c.root)for (var d = 0; d < c.rules.length; d++)c.rules[d]instanceof a.Import && Array.prototype.splice.apply(c.rules, [d,1].concat(c.rules[d].eval(b)));
|
||||
for (var d = 0; d < c.rules.length; d++)c.rules[d]instanceof a.mixin.Definition && (c.rules[d].frames = b.frames.slice(0));
|
||||
for (var d = 0; d < c.rules.length; d++)c.rules[d]instanceof a.mixin.Call && Array.prototype.splice.apply(c.rules, [d,1].concat(c.rules[d].eval(b)));
|
||||
for (var d = 0,e; d < c.rules.length; d++)e = c.rules[d],e instanceof a.mixin.Definition || (c.rules[d] = e.eval ? e.eval(b) : e);
|
||||
b.frames.shift();
|
||||
return c
|
||||
},match:function(a) {
|
||||
return!a || a.length === 0
|
||||
},variables:function() {
|
||||
return this._variables ? this._variables : this._variables = this.rules.reduce(function(b, c) {
|
||||
c instanceof a.Rule && c.variable === !0 && (b[c.name] = c);
|
||||
return b
|
||||
}, {})
|
||||
},variable:function(a) {
|
||||
return this.variables()[a]
|
||||
},rulesets:function() {
|
||||
return this._rulesets ? this._rulesets : this._rulesets = this.rules.filter(function(b) {
|
||||
return b instanceof a.Ruleset || b instanceof a.mixin.Definition
|
||||
})
|
||||
},find:function(b, c) {
|
||||
c = c || this;
|
||||
var d = [],e,f,g = b.toCSS();
|
||||
if (g in this._lookups)return this._lookups[g];
|
||||
this.rulesets().forEach(function(e) {
|
||||
if (e !== c)for (var g = 0; g < e.selectors.length; g++)if (f = b.match(e.selectors[g])) {
|
||||
b.elements.length > 1 ? Array.prototype.push.apply(d, e.find(new a.Selector(b.elements.slice(1)), c)) : d.push(e);
|
||||
break
|
||||
}
|
||||
});
|
||||
return this._lookups[g] = d
|
||||
},toCSS:function(b, c) {
|
||||
var d = [],e = [],f = [],g = [],h,i;
|
||||
if (!this.root)if (b.length === 0)g = this.selectors.map(function(a) {
|
||||
return[a]
|
||||
}); else for (var j = 0; j < this.selectors.length; j++)for (var k = 0; k < b.length; k++)g.push(b[k].concat([this.selectors[j]]));
|
||||
for (var l = 0; l < this.rules.length; l++)i = this.rules[l],i.rules || i instanceof a.Directive ? f.push(i.toCSS(g, c)) : i instanceof a.Comment ? i.silent || (this.root ? f.push(i.toCSS(c)) : e.push(i.toCSS(c))) : i.toCSS && !i.variable ? e.push(i.toCSS(c)) : i.value && !i.variable && e.push(i.value.toString());
|
||||
f = f.join(""),this.root ? d.push(e.join(c.compress ? "" : "\n")) : e.length > 0 && (h = g.map(
|
||||
function(a) {
|
||||
return a.map(
|
||||
function(a) {
|
||||
return a.toCSS(c)
|
||||
}).join("").trim()
|
||||
}).join(c.compress ? "," : g.length > 3 ? ",\n" : ", "),d.push(h, (c.compress ? "{" : " {\n ") + e.join(c.compress ? "" : "\n ") + (c.compress ? "}" : "\n}\n"))),d.push(f);
|
||||
return d.join("") + (c.compress ? "\n" : "")
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Selector = function(a) {
|
||||
this.elements = a,this.elements[0].combinator.value === "" && (this.elements[0].combinator.value = " ")
|
||||
},a.Selector.prototype.match = function(a) {
|
||||
return this.elements[0].value === a.elements[0].value ? !0 : !1
|
||||
},a.Selector.prototype.toCSS = function(a) {
|
||||
if (this._css)return this._css;
|
||||
return this._css = this.elements.map(
|
||||
function(b) {
|
||||
return typeof b == "string" ? " " + b.trim() : b.toCSS(a)
|
||||
}).join("")
|
||||
}
|
||||
}(c("less/tree")),function(b) {
|
||||
b.URL = function(b, c) {
|
||||
b.data ? this.attrs = b : (!/^(?:https?:\/|file:\/|data:\/)?\//.test(b.value) && c.length > 0 && typeof a != "undefined" && (b.value = c[0] + (b.value.charAt(0) === "/" ? b.value.slice(1) : b.value)),this.value = b,this.paths = c)
|
||||
},b.URL.prototype = {toCSS:function() {
|
||||
return"url(" + (this.attrs ? "data:" + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data : this.value.toCSS()) + ")"
|
||||
},eval:function(a) {
|
||||
return this.attrs ? this : new b.URL(this.value.eval(a), this.paths)
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Value = function(a) {
|
||||
this.value = a,this.is = "value"
|
||||
},a.Value.prototype = {eval:function(b) {
|
||||
return this.value.length === 1 ? this.value[0].eval(b) : new a.Value(this.value.map(function(a) {
|
||||
return a.eval(b)
|
||||
}))
|
||||
},toCSS:function(a) {
|
||||
return this.value.map(
|
||||
function(b) {
|
||||
return b.toCSS(a)
|
||||
}).join(a.compress ? "," : ", ")
|
||||
}}
|
||||
}(c("less/tree")),function(a) {
|
||||
a.Variable = function(a, b) {
|
||||
this.name = a,this
|
||||
.index = b
|
||||
},a.Variable.prototype = {eval:function(b) {
|
||||
var c,d,e = this.name;
|
||||
e.indexOf("@@") == 0 && (e = "@" + (new a.Variable(e.slice(1))).eval(b).value);
|
||||
if (c = a.find(b.frames, function(a) {
|
||||
if (d = a.variable(e))return d.value.eval(b)
|
||||
}))return c;
|
||||
throw{message:"variable " + e + " is undefined",index:this.index}
|
||||
}}
|
||||
}(c("less/tree")),c("less/tree").find = function(a, b) {
|
||||
for (var c = 0,d; c < a.length; c++)if (d = b.call(a, a[c]))return d;
|
||||
return null
|
||||
},c("less/tree").jsify = function(a) {
|
||||
return Array.isArray(a.value) && a.value.length > 1 ? "[" + a.value.map(
|
||||
function(a) {
|
||||
return a.toCSS(!1)
|
||||
}).join(", ") + "]" : a.toCSS(!1)
|
||||
};
|
||||
var g = location.protocol === "file:" || location.protocol === "chrome:" || location.protocol === "chrome-extension:" || location.protocol === "resource:";
|
||||
d.env = d.env || (location.hostname == "127.0.0.1" || location.hostname == "0.0.0.0" || location.hostname == "localhost" || location.port.length > 0 || g ? "development" : "production"),d.async = !1,d.poll = d.poll || (g ? 1e3 : 1500),d.watch = function() {
|
||||
return this.watchMode = !0
|
||||
},d.unwatch = function() {
|
||||
return this.watchMode = !1
|
||||
},d.env === "development" ? (d.optimization = 0,/!watch/.test(location.hash) && d.watch(),d.watchTimer = setInterval(function() {
|
||||
d.watchMode && n(function(a, b, c) {
|
||||
a && q(a.toCSS(), b, c.lastModified)
|
||||
})
|
||||
}, d.poll)) : d.optimization = 3;
|
||||
var h;
|
||||
try {
|
||||
h = typeof a.localStorage == "undefined" ? null : a.localStorage
|
||||
} catch(i) {
|
||||
h = null
|
||||
}
|
||||
var j = document.getElementsByTagName("link"),k = /^text\/(x-)?less$/;
|
||||
d.sheets = [];
|
||||
for (var l = 0; l < j.length; l++)(j[l].rel === "stylesheet/less" || j[l].rel.match(/stylesheet/) && j[l].type.match(k)) && d.sheets.push(j[l]);
|
||||
d.refresh = function(a) {
|
||||
var b,c;
|
||||
b = c = new Date,n(function(a, d, e) {
|
||||
e.local ? u("loading " + d.href + " from cache.") : (u("parsed " + d.href + " successfully."),q(a.toCSS(), d, e.lastModified)),u("css for " + d.href + " generated in " + (new Date - c) + "ms"),e.remaining === 0 && u("css generated in " + (new Date - b) + "ms"),c = new Date
|
||||
}, a),m()
|
||||
},d.refreshStyles = m,d.refresh(d.env === "development")
|
||||
})(window)
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
---
|
||||
name: MooDialog.Alert
|
||||
description: Creates an Alert dialog
|
||||
authors: Arian Stolwijk
|
||||
license: MIT-style license
|
||||
requires: MooDialog
|
||||
provides: MooDialog.Alert
|
||||
...
|
||||
*/
|
||||
|
||||
|
||||
MooDialog.Alert = new Class({
|
||||
|
||||
Extends: MooDialog,
|
||||
|
||||
options: {
|
||||
okText: 'Ok',
|
||||
focus: true,
|
||||
textPClass: 'MooDialogAlert'
|
||||
},
|
||||
|
||||
initialize: function(msg, options){
|
||||
this.parent(options);
|
||||
|
||||
var okButton = new Element('input[type=button]', {
|
||||
events: {
|
||||
click: this.close.bind(this)
|
||||
},
|
||||
value: this.options.okText
|
||||
});
|
||||
|
||||
this.setContent(
|
||||
new Element('p.' + this.options.textPClass, {text: msg}),
|
||||
new Element('div.buttons').adopt(okButton)
|
||||
);
|
||||
if (this.options.autoOpen) this.open();
|
||||
|
||||
if (this.options.focus) this.addEvent('show', function(){
|
||||
okButton.focus()
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
---
|
||||
name: MooDialog.Confirm
|
||||
description: Creates an Confirm Dialog
|
||||
authors: Arian Stolwijk
|
||||
license: MIT-style license
|
||||
requires: MooDialog
|
||||
provides: [MooDialog.Confirm, Element.confirmLinkClick, Element.confirmFormSubmit]
|
||||
...
|
||||
*/
|
||||
|
||||
|
||||
MooDialog.Confirm = new Class({
|
||||
|
||||
Extends: MooDialog,
|
||||
|
||||
options: {
|
||||
okText: 'Ok',
|
||||
cancelText: 'Cancel',
|
||||
focus: true,
|
||||
textPClass: 'MooDialogConfirm'
|
||||
},
|
||||
|
||||
initialize: function(msg, fn, fn1, options){
|
||||
this.parent(options);
|
||||
var emptyFn = function(){},
|
||||
self = this;
|
||||
|
||||
var buttons = [
|
||||
{fn: fn || emptyFn, txt: this.options.okText},
|
||||
{fn: fn1 || emptyFn, txt: this.options.cancelText}
|
||||
].map(function(button){
|
||||
return new Element('input[type=button]', {
|
||||
events: {
|
||||
click: function(){
|
||||
button.fn();
|
||||
self.close();
|
||||
}
|
||||
},
|
||||
value: button.txt
|
||||
});
|
||||
});
|
||||
|
||||
this.setContent(
|
||||
new Element('p.' + this.options.textPClass, {text: msg}),
|
||||
new Element('div.buttons').adopt(buttons)
|
||||
);
|
||||
if (this.options.autoOpen) this.open();
|
||||
|
||||
if(this.options.focus) this.addEvent('show', function(){
|
||||
buttons[1].focus();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Element.implement({
|
||||
|
||||
confirmLinkClick: function(msg, options){
|
||||
this.addEvent('click', function(e){
|
||||
e.stop();
|
||||
new MooDialog.Confirm(msg, function(){
|
||||
location.href = this.get('href');
|
||||
}.bind(this), null, options)
|
||||
});
|
||||
return this;
|
||||
},
|
||||
|
||||
confirmFormSubmit: function(msg, options){
|
||||
this.addEvent('submit', function(e){
|
||||
e.stop();
|
||||
new MooDialog.Confirm(msg, function(){
|
||||
this.submit();
|
||||
}.bind(this), null, options)
|
||||
}.bind(this));
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user