Remove mootools as dependency.

This commit is contained in:
Paulo Veiga 2021-12-14 17:06:09 +00:00
parent 25b86f3cff
commit 75a153d1d5
47 changed files with 255 additions and 1107 deletions

View File

@ -1,802 +0,0 @@
/*
---
MooTools: the javascript framework
web build:
- http://mootools.net/core/b28139f033891d55fabb70ffafd6813b
packager build:
- packager build Core/Core Core/Array Core/Class Core/Class.Extras
copyrights:
- [MooTools](http://mootools.net)
licenses:
- [MIT License](http://mootools.net/license.txt)
...
*/
(function () {
this.MooTools = { version: '1.4.5', build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0' };
var o = (this.typeOf = function (i) {
if (i == null) {
return 'null';
}
if (i.$family != null) {
return i.$family();
}
if (i.nodeName) {
if (i.nodeType == 1) {
return 'element';
}
if (i.nodeType == 3) {
return /\S/.test(i.nodeValue) ? 'textnode' : 'whitespace';
}
} else {
if (typeof i.length == 'number') {
if (i.callee) {
return 'arguments';
}
if ('item' in i) {
return 'collection';
}
}
}
return typeof i;
});
var j = (this.instanceOf = function (t, i) {
if (t == null) {
return false;
}
var s = t.$constructor || t.constructor;
while (s) {
if (s === i) {
return true;
}
s = s.parent;
}
if (!t.hasOwnProperty) {
return false;
}
return t instanceof i;
});
var f = this.Function;
var p = true;
for (var k in { toString: 1 }) {
p = null;
}
if (p) {
p = [
'hasOwnProperty',
'valueOf',
'isPrototypeOf',
'propertyIsEnumerable',
'toLocaleString',
'toString',
'constructor',
];
}
f.prototype.overloadSetter = function (s) {
var i = this;
return function (u, t) {
if (u == null) {
return this;
}
if (s || typeof u != 'string') {
for (var v in u) {
i.call(this, v, u[v]);
}
if (p) {
for (var w = p.length; w--; ) {
v = p[w];
if (u.hasOwnProperty(v)) {
i.call(this, v, u[v]);
}
}
}
} else {
i.call(this, u, t);
}
return this;
};
};
f.prototype.overloadGetter = function (s) {
var i = this;
return function (u) {
var v, t;
if (typeof u != 'string') {
v = u;
} else {
if (arguments.length > 1) {
v = arguments;
} else {
if (s) {
v = [u];
}
}
}
if (v) {
t = {};
for (var w = 0; w < v.length; w++) {
t[v[w]] = i.call(this, v[w]);
}
} else {
t = i.call(this, u);
}
return t;
};
};
f.prototype.extend = function (i, s) {
this[i] = s;
}.overloadSetter();
f.prototype.implement = function (i, s) {
this.prototype[i] = s;
}.overloadSetter();
var n = Array.prototype.slice;
f.from = function (i) {
return o(i) == 'function'
? i
: function () {
return i;
};
};
Array.from = function (i) {
if (i == null) {
return [];
}
return a.isEnumerable(i) && typeof i != 'string' ? (o(i) == 'array' ? i : n.call(i)) : [i];
};
Number.from = function (s) {
var i = parseFloat(s);
return isFinite(i) ? i : null;
};
String.from = function (i) {
return i + '';
};
f.implement({
hide: function () {
this.$hidden = true;
return this;
},
protect: function () {
this.$protected = true;
return this;
},
});
var a = (this.Type = function (u, t) {
if (u) {
var s = u.toLowerCase();
var i = function (v) {
return o(v) == s;
};
a['is' + u] = i;
if (t != null) {
t.prototype.$family = function () {
return s;
}.hide();
}
}
if (t == null) {
return null;
}
t.extend(this);
t.$constructor = a;
t.prototype.$constructor = t;
return t;
});
var e = Object.prototype.toString;
a.isEnumerable = function (i) {
return i != null && typeof i.length == 'number' && e.call(i) != '[object Function]';
};
var q = {};
var r = function (i) {
var s = o(i.prototype);
return q[s] || (q[s] = []);
};
var b = function (t, x) {
if (x && x.$hidden) {
return;
}
var s = r(this);
for (var u = 0; u < s.length; u++) {
var w = s[u];
if (o(w) == 'type') {
b.call(w, t, x);
} else {
w.call(this, t, x);
}
}
var v = this.prototype[t];
if (v == null || !v.$protected) {
this.prototype[t] = x;
}
if (this[t] == null && o(x) == 'function') {
m.call(this, t, function (i) {
return x.apply(i, n.call(arguments, 1));
});
}
};
var m = function (i, t) {
if (t && t.$hidden) {
return;
}
var s = this[i];
if (s == null || !s.$protected) {
this[i] = t;
}
};
a.implement({
implement: b.overloadSetter(),
extend: m.overloadSetter(),
alias: function (i, s) {
b.call(this, i, this.prototype[s]);
}.overloadSetter(),
mirror: function (i) {
r(this).push(i);
return this;
},
});
new a('Type', a);
var d = function (s, x, v) {
var u = x != Object,
B = x.prototype;
if (u) {
x = new a(s, x);
}
for (var y = 0, w = v.length; y < w; y++) {
var C = v[y],
A = x[C],
z = B[C];
if (A) {
A.protect();
}
if (u && z) {
x.implement(C, z.protect());
}
}
if (u) {
var t = B.propertyIsEnumerable(v[0]);
x.forEachMethod = function (G) {
if (!t) {
for (var F = 0, D = v.length; F < D; F++) {
G.call(B, B[v[F]], v[F]);
}
}
for (var E in B) {
G.call(B, B[E], E);
}
};
}
return d;
};
d('String', String, [
'charAt',
'charCodeAt',
'concat',
'indexOf',
'lastIndexOf',
'match',
'quote',
'replace',
'search',
'slice',
'split',
'substr',
'substring',
'trim',
'toLowerCase',
'toUpperCase',
])('Array', Array, [
'pop',
'push',
'reverse',
'shift',
'sort',
'splice',
'unshift',
'concat',
'join',
'slice',
'indexOf',
'lastIndexOf',
'filter',
'forEach',
'every',
'map',
'some',
'reduce',
'reduceRight',
])('Number', Number, ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision'])(
'Function',
f,
['apply', 'call', 'bind']
)('RegExp', RegExp, ['exec', 'test'])('Object', Object, [
'create',
'defineProperty',
'defineProperties',
'keys',
'getPrototypeOf',
'getOwnPropertyDescriptor',
'getOwnPropertyNames',
'preventExtensions',
'isExtensible',
'seal',
'isSealed',
'freeze',
'isFrozen',
])('Date', Date, ['now']);
Object.extend = m.overloadSetter();
Date.extend('now', function () {
return +new Date();
});
new a('Boolean', Boolean);
Number.prototype.$family = function () {
return isFinite(this) ? 'number' : 'null';
}.hide();
Number.extend('random', function (s, i) {
return Math.floor(Math.random() * (i - s + 1) + s);
});
var g = Object.prototype.hasOwnProperty;
Object.extend('forEach', function (i, t, u) {
for (var s in i) {
if (g.call(i, s)) {
t.call(u, i[s], s, i);
}
}
});
Object.each = Object.forEach;
Array.implement({
forEach: function (u, v) {
for (var t = 0, s = this.length; t < s; t++) {
if (t in this) {
u.call(v, this[t], t, this);
}
}
},
each: function (i, s) {
Array.forEach(this, i, s);
return this;
},
});
var l = function (i) {
switch (o(i)) {
case 'array':
return i.clone();
case 'object':
return Object.clone(i);
default:
return i;
}
};
Array.implement('clone', function () {
var s = this.length,
t = new Array(s);
while (s--) {
t[s] = l(this[s]);
}
return t;
});
var h = function (s, i, t) {
switch (o(t)) {
case 'object':
if (o(s[i]) == 'object') {
Object.merge(s[i], t);
} else {
s[i] = Object.clone(t);
}
break;
case 'array':
s[i] = t.clone();
break;
default:
s[i] = t;
}
return s;
};
Object.extend({
merge: function (z, u, t) {
if (o(u) == 'string') {
return h(z, u, t);
}
for (var y = 1, s = arguments.length; y < s; y++) {
var w = arguments[y];
for (var x in w) {
h(z, x, w[x]);
}
}
return z;
},
clone: function (i) {
var t = {};
for (var s in i) {
t[s] = l(i[s]);
}
return t;
},
append: function (w) {
for (var v = 1, t = arguments.length; v < t; v++) {
var s = arguments[v] || {};
for (var u in s) {
w[u] = s[u];
}
}
return w;
},
});
['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function (i) {
new a(i);
});
var c = Date.now();
String.extend('uniqueID', function () {
return (c++).toString(36);
});
})();
Array.implement({
every: function (c, d) {
for (var b = 0, a = this.length >>> 0; b < a; b++) {
if (b in this && !c.call(d, this[b], b, this)) {
return false;
}
}
return true;
},
filter: function (d, f) {
var c = [];
for (var e, b = 0, a = this.length >>> 0; b < a; b++) {
if (b in this) {
e = this[b];
if (d.call(f, e, b, this)) {
c.push(e);
}
}
}
return c;
},
indexOf: function (c, d) {
var b = this.length >>> 0;
for (var a = d < 0 ? Math.max(0, b + d) : d || 0; a < b; a++) {
if (this[a] === c) {
return a;
}
}
return -1;
},
map: function (c, e) {
var d = this.length >>> 0,
b = Array(d);
for (var a = 0; a < d; a++) {
if (a in this) {
b[a] = c.call(e, this[a], a, this);
}
}
return b;
},
some: function (c, d) {
for (var b = 0, a = this.length >>> 0; b < a; b++) {
if (b in this && c.call(d, this[b], b, this)) {
return true;
}
}
return false;
},
clean: function () {
return this.filter(function (a) {
return a != null;
});
},
invoke: function (a) {
var b = Array.slice(arguments, 1);
return this.map(function (c) {
return c[a].apply(c, b);
});
},
associate: function (c) {
var d = {},
b = Math.min(this.length, c.length);
for (var a = 0; a < b; a++) {
d[c[a]] = this[a];
}
return d;
},
link: function (c) {
var a = {};
for (var e = 0, b = this.length; e < b; e++) {
for (var d in c) {
if (c[d](this[e])) {
a[d] = this[e];
delete c[d];
break;
}
}
}
return a;
},
contains: function (a, b) {
return this.indexOf(a, b) != -1;
},
append: function (a) {
this.push.apply(this, a);
return this;
},
getLast: function () {
return this.length ? this[this.length - 1] : null;
},
getRandom: function () {
return this.length ? this[Number.random(0, this.length - 1)] : null;
},
include: function (a) {
if (!this.contains(a)) {
this.push(a);
}
return this;
},
combine: function (c) {
for (var b = 0, a = c.length; b < a; b++) {
this.include(c[b]);
}
return this;
},
erase: function (b) {
for (var a = this.length; a--; ) {
if (this[a] === b) {
this.splice(a, 1);
}
}
return this;
},
empty: function () {
this.length = 0;
return this;
},
flatten: function () {
var d = [];
for (var b = 0, a = this.length; b < a; b++) {
var c = typeOf(this[b]);
if (c == 'null') {
continue;
}
d = d.concat(
c == 'array' || c == 'collection' || c == 'arguments' || instanceOf(this[b], Array)
? Array.flatten(this[b])
: this[b]
);
}
return d;
},
pick: function () {
for (var b = 0, a = this.length; b < a; b++) {
if (this[b] != null) {
return this[b];
}
}
return null;
},
rgbToHex: function (d) {
if (this.length < 3) {
return null;
}
if (this.length == 4 && this[3] == 0 && !d) {
return 'transparent';
}
var b = [];
for (var a = 0; a < 3; a++) {
var c = (this[a] - 0).toString(16);
b.push(c.length == 1 ? '0' + c : c);
}
return d ? b : '#' + b.join('');
},
});
String.implement({
test: function (a, b) {
return (typeOf(a) == 'regexp' ? a : new RegExp('' + a, b)).test(this);
},
contains: function (a, b) {
return b ? (b + this + b).indexOf(b + a + b) > -1 : String(this).indexOf(a) > -1;
},
trim: function () {
return String(this).replace(/^\s+|\s+$/g, '');
},
clean: function () {
return String(this).replace(/\s+/g, ' ').trim();
},
camelCase: function () {
return String(this).replace(/-\D/g, function (a) {
return a.charAt(1).toUpperCase();
});
},
hyphenate: function () {
return String(this).replace(/[A-Z]/g, function (a) {
return '-' + a.charAt(0).toLowerCase();
});
},
capitalize: function () {
return String(this).replace(/\b[a-z]/g, function (a) {
return a.toUpperCase();
});
},
escapeRegExp: function () {
return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
rgbToHex: function (b) {
var a = String(this).match(/\d{1,3}/g);
return a ? a.rgbToHex(b) : null;
},
substitute: function (a, b) {
return String(this).replace(b || /\\?\{([^{}]+)\}/g, function (d, c) {
if (d.charAt(0) == '\\') {
return d.slice(1);
}
return a[c] != null ? a[c] : '';
});
},
});
Function.implement({
bind: function (e) {
var a = this,
b = arguments.length > 1 ? Array.slice(arguments, 1) : null,
d = function () {};
var c = function () {
var g = e,
h = arguments.length;
if (this instanceof c) {
d.prototype = a.prototype;
g = new d();
}
var f =
!b && !h
? a.call(g)
: a.apply(g, b && h ? b.concat(Array.slice(arguments)) : b || arguments);
return g == e ? f : g;
};
return c;
},
pass: function (b, c) {
var a = this;
if (b != null) {
b = Array.from(b);
}
return function () {
return a.apply(c, b || arguments);
};
},
delay: function (b, c, a) {
return setTimeout(this.pass(a == null ? [] : a, c), b);
},
});
Number.alias('each', 'times');
(function (b) {
var a = {};
b.each(function (c) {
if (!Number[c]) {
a[c] = function () {
return Math[c].apply(null, [this].concat(Array.from(arguments)));
};
}
});
Number.implement(a);
})([
'abs',
'acos',
'asin',
'atan',
'atan2',
'ceil',
'cos',
'exp',
'floor',
'log',
'max',
'min',
'pow',
'sin',
'sqrt',
'tan',
]);
(function () {
var a = (this.Class = new Type('Class', function (h) {
if (instanceOf(h, Function)) {
h = { initialize: h };
}
var g = function () {
e(this);
if (g.$prototyping) {
return this;
}
this.$caller = null;
var i = this.initialize ? this.initialize.apply(this, arguments) : this;
this.$caller = this.caller = null;
return i;
}
.extend(this)
.implement(h);
g.$constructor = a;
g.prototype.$constructor = g;
g.prototype.parent = c;
return g;
}));
var c = function () {
if (!this.$caller) {
throw new Error('The method "parent" cannot be called.');
}
var g = this.$caller.$name,
h = this.$caller.$owner.parent,
i = h ? h.prototype[g] : null;
if (!i) {
throw new Error('The method "' + g + '" has no parent.');
}
return i.apply(this, arguments);
};
var e = function (g) {
for (var h in g) {
var j = g[h];
switch (typeOf(j)) {
case 'object':
var i = function () {};
i.prototype = j;
g[h] = e(new i());
break;
case 'array':
g[h] = j.clone();
break;
}
}
return g;
};
var b = function (g, h, j) {
if (j.$origin) {
j = j.$origin;
}
var i = function () {
if (j.$protected && this.$caller == null) {
throw new Error('The method "' + h + '" cannot be called.');
}
var l = this.caller,
m = this.$caller;
this.caller = m;
this.$caller = i;
var k = j.apply(this, arguments);
this.$caller = m;
this.caller = l;
return k;
}.extend({ $owner: g, $origin: j, $name: h });
return i;
};
var f = function (h, i, g) {
if (a.Mutators.hasOwnProperty(h)) {
i = a.Mutators[h].call(this, i);
if (i == null) {
return this;
}
}
if (typeOf(i) == 'function') {
if (i.$hidden) {
return this;
}
this.prototype[h] = g ? i : b(this, h, i);
} else {
Object.merge(this.prototype, h, i);
}
return this;
};
var d = function (g) {
g.$prototyping = true;
var h = new g();
delete g.$prototyping;
return h;
};
a.implement('implement', f.overloadSetter());
a.Mutators = {
Extends: function (g) {
this.parent = g;
this.prototype = d(g);
},
Implements: function (g) {
Array.from(g).each(function (j) {
var h = new j();
for (var i in h) {
f.call(this, i, h[i], true);
}
}, this);
},
};
})();

View File

@ -8,12 +8,6 @@
"airbnb-base",
"plugin:cypress/recommended"
],
"globals":{
"Class": "readonly",
"$": "readonly",
"$msg": "readonly",
"_": "readonly"
},
"plugins": ["only-warn"],
"rules": {
"no-underscore-dangle": "off",

View File

@ -34,8 +34,7 @@
"@wisemapping/core-js": "^0.0.1",
"@wisemapping/web2d": "^0.0.1",
"jest": "^27.4.3",
"jquery": "^3.6.0",
"mootools": "1.4.5"
"jquery": "^3.6.0"
},
"devDependencies": {
"@babel/core": "^7.14.6",

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined } from "@wisemapping/core-js";
import EventBus from "./layout/EventBus";
class CommandContext {
constructor(designer) {
@ -31,7 +32,7 @@ class CommandContext {
}
const designerTopics = this._designer.getModel().getTopics();
const result = designerTopics.filter((topic) => topicsIds.contains(topic.getId()));
const result = designerTopics.filter((topic) => topicsIds.includes(topic.getId()));
if (result.length !== topicsIds.length) {
const ids = designerTopics.map((topic) => topic.getId());
@ -98,7 +99,7 @@ class CommandContext {
}
const designerRel = this._designer.getModel().getRelationships();
return designerRel.filter((rel) => relIds.contains(rel.getId()));
return designerRel.filter((rel) => relIds.includes(rel.getId()));
}
/** */

View File

@ -78,10 +78,10 @@ class ControlPoint {
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();
this._orignalCtrlPoint[0] = { ...this._controls[0] };
this._orignalCtrlPoint[1] = { ...this._controls[1] };
this._endPoint[0] = { ...this._line.getLine().getFrom() };
this._endPoint[1] = { ...this._line.getLine().getTo() };
}
redraw() {

View File

@ -240,7 +240,7 @@ class DesignerKeyboard extends Keyboard {
$(document).on('keypress', (event) => {
let keyCode;
// Firefox doesn't skip special keys for keypress event...
if (event.key && excludes.contains(event.key.toLowerCase())) {
if (event.key && excludes.includes(event.key.toLowerCase())) {
return;
}
// Sometimes Firefox doesn't contain keyCode value

View File

@ -81,8 +81,8 @@ class DesignerModel extends Events {
* @return {Array.<mindplot.Relationship, mindplot.Topic>} all topics and relationships
*/
getEntities() {
const result = [].append(this._topics);
result.append(this._relationships);
let result = [].concat(this._topics);
result = result.concat(this._relationships);
return result;
}
@ -92,7 +92,7 @@ class DesignerModel extends Events {
*/
removeTopic(topic) {
$assert(topic, 'topic can not be null');
this._topics.erase(topic);
this._topics = this._topics.filter((t) => t !== topic);
}
/**
@ -101,7 +101,7 @@ class DesignerModel extends Events {
*/
removeRelationship(rel) {
$assert(rel, 'rel can not be null');
this._relationships.erase(rel);
this._relationships = this._relationships.filter((r) => r !== rel);
}
/**

View File

@ -59,8 +59,8 @@ class DragConnector {
// - Nodes that are collapsed
// - It's not part of the branch dragged itself
topics = topics.filter((topic) => {
let result = draggedNode != topic;
result = result && topic != draggedNode;
let result = draggedNode !== topic;
result = result && topic !== draggedNode;
result = result && !topic.areChildrenShrunken() && !topic.isCollapsed();
result = result && !draggedNode.isChildTopic(topic);
return result;

View File

@ -25,16 +25,24 @@ class Events {
return string.replace(/^on([A-Z])/, (full, first) => first.toLowerCase());
}
addEvent(type, fn, internal) {
type = Events._removeOn(type);
addEvent(typeName, fn, internal) {
const type = Events._removeOn(typeName);
this.$events[type] = (this.$events[type] || []).include(fn);
if (internal) fn.internal = true;
// Add function had not been added yet
const funByType = this.$events[type] ? this.$events[type] : [];
if (!funByType.includes(fn)) {
funByType.push(fn);
this.$events[type] = funByType;
}
// Mark reference ...
// eslint-disable-next-line no-param-reassign
fn.internal = Boolean(internal);
return this;
}
fireEvent(type, args, delay) {
type = Events._removeOn(type);
fireEvent(typeName, args, delay) {
const type = Events._removeOn(typeName);
const events = this.$events[type];
if (!events) return this;
@ -42,16 +50,15 @@ class Events {
events.forEach(((fn) => {
if (delay) {
fn.delay(delay, this, args);
}
else {
} else {
fn.apply(this, args);
}
}).bind(this));
}));
return this;
}
removeEvent(type, fn) {
type = Events._removeOn(type);
removeEvent(typeName, fn) {
const type = Events._removeOn(typeName);
const events = this.$events[type];
if (events && !fn.internal) {
const index = events.indexOf(fn);

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line max-classes-per-file
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import IconGroupRemoveTip from './IconGroupRemoveTip';
@ -22,14 +23,6 @@ import IconGroupRemoveTip from './IconGroupRemoveTip';
import Icon from './Icon';
class IconGroup {
/** @lends IconGroup */
/**
* @constructs
* @param topicId
* @param iconSize
* @throws will throw an error if topicId is null or undefined
* @throws will throw an error if iconSize is null or undefined
*/
constructor(topicId, iconSize) {
$assert($defined(topicId), 'topicId can not be null');
$assert($defined(iconSize), 'iconSize can not be null');
@ -43,7 +36,7 @@ class IconGroup {
coordSizeWidth: 0,
coordSizeHeight: 100,
});
this._removeTip = new IconGroup.RemoveTip(this._group, topicId);
this._removeTip = new IconGroupRemoveTip(this._group, topicId);
this.seIconSize(iconSize, iconSize);
this._registerListeners();
@ -76,10 +69,10 @@ class IconGroup {
}
/**
* @param icon the icon to be added to the icon group
* @param {Boolean} remove
* @throws will throw an error if icon is not defined
*/
* @param icon the icon to be added to the icon group
* @param {Boolean} remove
* @throws will throw an error if icon is not defined
*/
addIcon(icon, remove) {
$defined(icon, 'icon is not defined');
@ -111,7 +104,7 @@ class IconGroup {
});
if (result == null) {
throw new Error(`Icon can no be found:${iconModel.getId()}, Icons:${this._icons}`);
throw new Error(`Icon can no be found:${iconModel.getId()} Icons:${this._icons}`);
}
return result;
@ -131,7 +124,7 @@ class IconGroup {
this._removeTip.close(0);
this._group.removeChild(icon.getImage());
this._icons.erase(icon);
this._icons = this._icons.filter((i) => i !== icon);
this._resize(this._icons.length);
const me = this;
@ -164,7 +157,6 @@ class IconGroup {
this._group.setCoordSize(iconsLength * iconSize, iconSize);
}
// eslint-disable-next-line class-methods-use-this
_positionIcon(icon, order) {
const iconSize = Icon.SIZE + IconGroup.ICON_PADDING * 2;
icon.getImage().setPosition(
@ -181,6 +173,4 @@ class IconGroup {
*/
IconGroup.ICON_PADDING = 5;
IconGroup.RemoveTip = IconGroupRemoveTip;
export default IconGroup;

View File

@ -22,7 +22,7 @@ export default class RemoveTip {
$assert(icon, 'icon can not be null');
// Nothing to do ...
if (this._activeIcon != icon) {
if (this._activeIcon !== icon) {
// If there is an active icon, close it first ...
if (this._activeIcon) {
this.close(0);
@ -82,10 +82,10 @@ export default class RemoveTip {
me._closeTimeoutId = null;
};
if (!$defined(delay) || delay == 0) {
if (!$defined(delay) || delay === 0) {
close();
} else {
this._closeTimeoutId = close.delay(delay);
this._closeTimeoutId = $(close).delay(delay);
}
}
}

View File

@ -1,10 +1,14 @@
class Options {
setOptions() {
const options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));
setOptions(...args) {
this.options = { ...this.options, ...args };
const { options } = this;
if (this.addEvent) {
for (const option in options) {
if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
if (typeof (options[option]) != 'function' || !(/^on[A-Z]/).test(option) ){
continue;
}
this.addEvent(option, options[option]);
delete options[option];
}

View File

@ -65,11 +65,11 @@ class Relationship extends ConnectionLine {
// Position the line ...
if ($defined(model.getSrcCtrlPoint())) {
const srcPoint = model.getSrcCtrlPoint().clone();
const srcPoint = { ...model.getSrcCtrlPoint() };
this.setSrcControlPoint(srcPoint);
}
if ($defined(model.getDestCtrlPoint())) {
const destPoint = model.getDestCtrlPoint().clone();
const destPoint = { ...model.getDestCtrlPoint() };
this.setDestControlPoint(destPoint);
}
}

View File

@ -355,7 +355,7 @@ class Topic extends NodeGraph {
/** */
deleteRelationship(relationship) {
this._relationships.erase(relationship);
this._relationships = this._relationships.filter((r) => r !== relationship);
}
/** */
@ -1186,7 +1186,7 @@ class Topic extends NodeGraph {
/** */
removeChild(child) {
const children = this.getChildren();
children.erase(child);
this._children = children.filter((c) => c !== child);
}
/** */

View File

@ -75,7 +75,7 @@ class AddTopicCommand extends Command {
// Delete disconnected the nodes. Create a copy of the topics ...
const clonedModel = [];
this._models.forEach((model) => {
clonedModel.push(model.clone());
clonedModel.push({ ...model });
});
// Finally, remove the nodes ...

View File

@ -53,14 +53,14 @@ class DeleteCommand extends Command {
// Delete relationships
const relationships = this._collectInDepthRelationships(topic);
this._deletedRelModel.append(relationships.map((rel) => rel.getModel().clone()));
this._deletedRelModel.append(relationships.map((rel) => ({ ...rel.getModel() })));
relationships.forEach((relationship) => {
commandContext.deleteRelationship(relationship);
});
// Store information for undo ...
const clonedModel = model.clone();
const clonedModel = { ...model };
this._deletedTopicModels.push(clonedModel);
const outTopic = topic.getOutgoingConnectedTopic();
let outTopicId = null;
@ -77,9 +77,9 @@ class DeleteCommand extends Command {
const rels = commandContext.findRelationships(this._relIds);
if (rels.length > 0) {
rels.forEach(((rel) => {
this._deletedRelModel.push(rel.getModel().clone());
this._deletedRelModel.push({ ...rel.getModel() });
commandContext.deleteRelationship(rel);
}).bind(this));
}));
}
}
@ -102,7 +102,7 @@ class DeleteCommand extends Command {
const parentTopics = commandContext.findTopics(parentId);
commandContext.connect(topics[0], parentTopics[0]);
}
}).bind(this));
}));
// Add rebuild relationships ...
this._deletedRelModel.forEach((model) => {
@ -135,7 +135,7 @@ class DeleteCommand extends Command {
let parent = topic.getParent();
let found = false;
while (parent != null && !found) {
found = topicIds.contains(parent.getId());
found = topicIds.includes(parent.getId());
if (found) {
break;
}
@ -152,12 +152,10 @@ class DeleteCommand extends Command {
_collectInDepthRelationships(topic) {
let result = [];
result.append(topic.getRelationships());
result = result.concat(topic.getRelationships());
const children = topic.getChildren();
const rels = children.map(function (topic) {
return this._collectInDepthRelationships(topic);
}, this);
const rels = children.map(((t) => this._collectInDepthRelationships(t)));
result.append(rels.flatten());
if (result.length > 0) {

View File

@ -37,17 +37,17 @@ class MoveControlPointCommand extends Command {
super();
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();
this._controlPoint = { ...this._ctrlPointControler.getControlPoint(point) };
this._oldControlPoint = { ...this._ctrlPointControler.getOriginalCtrlPoint(point) };
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point);
switch (point) {
case 0:
this._wasCustom = this._line.getLine().isSrcControlPointCustom();
this._endPoint = this._line.getLine().getFrom().clone();
this._endPoint = { ...this._line.getLine().getFrom() };
break;
case 1:
this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._endPoint = this._line.getLine().getTo().clone();
this._endPoint = { ...this._line.getLine().getTo() };
break;
default:
break;
@ -62,17 +62,17 @@ class MoveControlPointCommand extends Command {
const model = this._line.getModel();
switch (this._point) {
case 0:
model.setSrcCtrlPoint(this._controlPoint.clone());
model.setSrcCtrlPoint({ ...this._controlPoint });
this._line.setFrom(this._endPoint.x, this._endPoint.y);
this._line.setIsSrcControlPointCustom(true);
this._line.setSrcControlPoint(this._controlPoint.clone());
this._line.setSrcControlPoint({ ...this._controlPoint });
break;
case 1:
model.setDestCtrlPoint(this._controlPoint.clone());
model.setDestCtrlPoint({ ...this._controlPoint });
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());
this._line.setDestControlPoint({ ...this._controlPoint });
break;
default:
break;
@ -95,16 +95,16 @@ class MoveControlPointCommand extends Command {
case 0:
if ($defined(this._oldControlPoint)) {
line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y);
model.setSrcCtrlPoint(this._oldControlPoint.clone());
line.setSrcControlPoint(this._oldControlPoint.clone());
model.setSrcCtrlPoint({ ...this._oldControlPoint });
line.setSrcControlPoint({ ...this._oldControlPoint });
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());
model.setDestCtrlPoint({ ...this._oldControlPoint });
line.setDestControlPoint({ ...this._oldControlPoint });
line.setIsDestControlPointCustom(this._wasCustom);
}
break;

View File

@ -23,13 +23,6 @@ import ChildrenSorterStrategy from './ChildrenSorterStrategy';
* @extends mindplot.layout.ChildrenSorterStrategy
*/
class AbstractBasicSorter extends ChildrenSorterStrategy {
/** @lends AbstractBasicSorter */
/**
* @param {} treeSet
* @param {} node
* @return the height of a node and its children if existing and not shrunken
*/
computeChildrenIdByHeights(treeSet, node) {
const result = {};
this._computeChildrenHeight(treeSet, node, result);

View File

@ -20,19 +20,6 @@ import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter';
class BalancedSorter extends AbstractBasicSorter {
/** @lends BalancedSorter */
/**
* @constructs
* @extends mindplot.layout.AbstractBasicSorter
*/
/**
* @param {} graph
* @param {} parent
* @param {} node
* @param {} position
* @param {Boolean} free
* @return an array with order and position
*/
predict(graph, parent, node, position, free) {
// If its a free node...
if (free) {
@ -42,8 +29,8 @@ class BalancedSorter extends AbstractBasicSorter {
);
$assert($defined(node), 'node cannot be null for predict in free positioning');
var rootNode = graph.getRootNode(parent);
var direction = this._getRelativeDirection(
const rootNode = graph.getRootNode(parent);
const direction = this._getRelativeDirection(
rootNode.getPosition(),
node.getPosition(),
);
@ -65,7 +52,7 @@ class BalancedSorter extends AbstractBasicSorter {
return [0, { x: xPos, y: position.y }];
}
var rootNode = graph.getRootNode(parent);
const rootNode = graph.getRootNode(parent);
// If it is a dragged node...
if (node) {
@ -86,9 +73,10 @@ class BalancedSorter extends AbstractBasicSorter {
}
}
let right; let left;
if (!position) {
var right = this._getChildrenForOrder(parent, graph, 0);
var left = this._getChildrenForOrder(parent, graph, 1);
right = this._getChildrenForOrder(parent, graph, 0);
left = this._getChildrenForOrder(parent, graph, 1);
}
// Filter nodes on one side..
const order = position
@ -101,7 +89,7 @@ class BalancedSorter extends AbstractBasicSorter {
var direction = order % 2 == 0 ? 1 : -1;
// Exclude the dragged node (if set)
const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child != node);
const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child !== node);
// No children?
if (children.length == 0) {
@ -120,7 +108,7 @@ class BalancedSorter extends AbstractBasicSorter {
// Try to fit within ...
let result = null;
const last = children.getLast();
const last = children[children.length - 1];
position = position || { x: last.getPosition().x, y: last.getPosition().y + 1 };
children.forEach((child, index) => {
const cpos = child.getPosition();
@ -303,7 +291,7 @@ class BalancedSorter extends AbstractBasicSorter {
}
_getChildrenForOrder(parent, graph, order) {
return this._getSortedChildren(graph, parent).filter((child) => child.getOrder() % 2 == order % 2);
return this._getSortedChildren(graph, parent).filter((child) => child.getOrder() % 2 === order % 2);
}
_getVerticalPadding() {

View File

@ -16,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class ChildrenSorterStrategy {/** @lends ChildrenSorterStrategy */
/**
* @constructs

View File

@ -17,10 +17,7 @@
*/
import EventBus from './EventBus';
class EventBusDispatcher {/** @lends EventBusDispatcher */
/**
* @constructs
*/
class EventBusDispatcher {
constructor() {
this.registerBusEvents();
}

View File

@ -22,12 +22,7 @@ import AbstractBasicSorter from './AbstractBasicSorter';
* @class
* @extends mindplot.layout.AbstractBasicSorter
*/
class GridSorter extends AbstractBasicSorter {/** @lends GridSorter */
/**
* @param {} treeSet
* @param {} node
* @return offsets
*/
class GridSorter extends AbstractBasicSorter {
computeOffsets(treeSet, node) {
$assert(treeSet, 'treeSet can no be null.');
$assert(node, 'node can no be null.');

View File

@ -18,18 +18,6 @@
import { $assert, $defined } from '@wisemapping/core-js';
class Node {
/** @lends Node */
/**
* @constructs
* @param id
* @param size
* @param position
* @param sorter
* @throws will throw an error if id is not a finite number or is null or undefined
* @throws will throw an error if size is null or undefined
* @throws will throw an error if position is null or undefined
* @throws will throw an error if sorter is null or undefined
*/
constructor(id, size, position, sorter) {
$assert(typeof id === 'number' && Number.isFinite(id), 'id can not be null');
$assert(size, 'size can not be null');
@ -141,7 +129,7 @@ class Node {
/** */
setSize(size) {
$assert($defined(size), 'Size can not be null');
this._setProperty('size', Object.clone(size));
this._setProperty('size', { ...size });
}
/** */
@ -245,5 +233,4 @@ class Node {
}
}
export default Node;

View File

@ -77,7 +77,7 @@ class OriginalLayout {
/** */
layout() {
const roots = this._treeSet.getTreeRoots();
roots.each(((node) => {
roots.forEach(((node) => {
// Calculate all node heights ...
const sorter = node.getSorter();
@ -109,7 +109,7 @@ class OriginalLayout {
const parentPosition = node.getPosition();
const me = this;
children.each((child) => {
children.forEach((child) => {
const offset = offsetById[child.getId()];
const childFreeDisplacement = child.getFreeDisplacement();
@ -143,7 +143,7 @@ class OriginalLayout {
}
// Continue reordering the children nodes ...
children.each(((child) => {
children.forEach(((child) => {
this._layoutChildren(child, heightById);
}));
}
@ -198,7 +198,7 @@ class OriginalLayout {
if (node.isFree()) {
this._shiftBranches(node, heightById);
}
children.each(((child) => {
children.forEach(((child) => {
this._fixOverlapping(child, heightById);
}));
}
@ -211,27 +211,25 @@ class OriginalLayout {
node.getFreeDisplacement().y,
);
siblingsToShift.each(((sibling) => {
const overlappingOccurs = shiftedBranches.some(((shiftedBranch) =>{
return OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById);
}).bind(this));
siblingsToShift.forEach(((sibling) => {
const overlappingOccurs = shiftedBranches.some(((shiftedBranch) => OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById)));
if (!sibling.isFree() || overlappingOccurs) {
const sAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
shiftedBranches.push(sibling);
}
}).bind(this));
}));
const branchesToShift = this._treeSet
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
.filter((branch) => !shiftedBranches.contains(branch));
.filter((branch) => !shiftedBranches.includes(branch));
branchesToShift.each(((branch) =>{
branchesToShift.forEach(((branch) => {
const bAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
shiftedBranches.push(branch);
}).bind(this));
}));
}
static _branchesOverlap(branchA, branchB, heightById) {

View File

@ -18,8 +18,6 @@
import { $assert, $defined } from '@wisemapping/core-js';
class RootedTreeSet {
/** @lends RootedTreeSet */
/** @constructs */
constructor() {
this._rootNodes = [];
}
@ -53,20 +51,20 @@ class RootedTreeSet {
$assert(node, 'node can not be null');
$assert(
!this.find(node.getId(), false),
`node already exits with this id. Id:${node.getId()}`,
`node already exits with this id. Id:${node.getId()}: ${this.dump()}`,
);
$assert(!node._children, 'node already added');
this._rootNodes.push(this._decodate(node));
}
/**
* @param nodeId
* @throws will throw an error if nodeId is null or undefined
*/
* @param nodeId
* @throws will throw an error if nodeId is null or undefined
*/
remove(nodeId) {
$assert($defined(nodeId), 'nodeId can not be null');
const node = this.find(nodeId);
this._rootNodes.erase(node);
this._rootNodes = this._rootNodes.filter((n) => n !== node);
}
/**
@ -89,7 +87,7 @@ class RootedTreeSet {
parent._children.push(child);
child._parent = parent;
this._rootNodes.erase(child);
this._rootNodes = this._rootNodes.filter((c) => c !== child);
}
/**
@ -102,7 +100,7 @@ class RootedTreeSet {
const node = this.find(nodeId);
$assert(node._parent, 'Node is not connected');
node._parent._children.erase(node);
node._parent._children = node._parent._children.filter((n)=> node !== n);
this._rootNodes.push(node);
node._parent = null;
}
@ -301,7 +299,7 @@ class RootedTreeSet {
`${node.getId()}[${order}]`,
);
text.attr('fill', '#FFF');
const fillColor = this._rootNodes.contains(node)
const fillColor = this._rootNodes.includes(node)
? '#000'
: node.isFree()
? '#abc'
@ -321,11 +319,11 @@ class RootedTreeSet {
node.getOrder()
}, position:(${
rectPosition.x
},${
}, ${
rectPosition.y
}), size:${
rectSize.width
}x${
},${
rectSize.height
}, freeDisplacement:(${
node.getFreeDisplacement().x

View File

@ -19,8 +19,6 @@ import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter';
class SymmetricSorter extends AbstractBasicSorter {
/** @lends SymmetricSorter */
/**
* Predict the order and position of a dragged node.
*
@ -37,10 +35,8 @@ class SymmetricSorter extends AbstractBasicSorter {
// If its a free node...
if (free) {
$assert(
$defined(position),
'position cannot be null for predict in free positioning',
);
$assert($defined(position),
'position cannot be null for predict in free positioning');
$assert($defined(node), 'node cannot be null for predict in free positioning');
const direction = this._getRelativeDirection(
@ -48,10 +44,10 @@ class SymmetricSorter extends AbstractBasicSorter {
parent.getPosition(),
);
const limitXPos = parent.getPosition().x
+ direction
* (parent.getSize().width / 2
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
+ direction
* (parent.getSize().width / 2
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
const xPos = direction > 0
? position.x >= limitXPos
@ -71,14 +67,14 @@ class SymmetricSorter extends AbstractBasicSorter {
parent.getPosition(),
);
var position = {
const result = {
x:
parent.getPosition().x
+ parentDirection
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
parent.getPosition().x
+ parentDirection
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y,
};
return [graph.getChildren(parent).length, position];
return [graph.getChildren(parent).length, result];
}
// If it is a dragged node...
@ -91,81 +87,81 @@ class SymmetricSorter extends AbstractBasicSorter {
const siblings = graph.getSiblings(node);
// node has no siblings and its trying to reconnect to its own parent
const sameParent = parent == graph.getParent(node);
const sameParent = parent === graph.getParent(node);
if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) {
return [node.getOrder(), node.getPosition()];
}
const parentChildren = graph.getChildren(parent);
if (parentChildren.length == 0) {
if (parentChildren.length === 0) {
// Fit as a child of the parent node...
var position = {
x:
parent.getPosition().x
+ positionDirection
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
const result = {
x: parent.getPosition().x + positionDirection * (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y,
};
return [0, position];
return [0, result];
}
// Try to fit within ...
const result = null;
const last = parentChildren.getLast();
const last = parentChildren[parentChildren.length - 1];
for (let i = 0; i < parentChildren.length; i++) {
const parentChild = parentChildren[i];
const nodeAfter = i + 1 == parentChild.length ? null : parentChildren[i + 1];
const 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()
const order = graph.getParent(node) && graph.getParent(node).getId() === parent.getId()
? last.getOrder()
: last.getOrder() + 1;
var position = {
const result = {
x: parentChild.getPosition().x,
y:
parentChild.getPosition().y
+ parentChild.getSize().height
+ SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
parentChild.getPosition().y
+ parentChild.getSize().height
+ SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
};
return [order, position];
return [order, result];
}
// Fit after this node
if (
nodeAfter
&& position.y > parentChild.getPosition().y
&& position.y < nodeAfter.getPosition().y
&& position.y > parentChild.getPosition().y
&& position.y < nodeAfter.getPosition().y
) {
if (
nodeAfter.getId() == node.getId()
|| parentChild.getId() == node.getId()
nodeAfter.getId() === node.getId()
|| parentChild.getId() === node.getId()
) {
return [node.getOrder(), node.getPosition()];
}
var order = position.y > node.getPosition().y
const orderResult = position.y > node.getPosition().y
? nodeAfter.getOrder() - 1
: parentChild.getOrder() + 1;
var position = {
const positionResult = {
x: parentChild.getPosition().x,
y:
parentChild.getPosition().y
+ (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2,
parentChild.getPosition().y
+ (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2,
};
return [order, position];
return [orderResult, positionResult];
}
}
// Position wasn't below any node, so it must be fitted above the first
const first = parentChildren[0];
var position = {
const resultPosition = {
x: first.getPosition().x,
y:
first.getPosition().y
- first.getSize().height
- SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
first.getPosition().y
- first.getSize().height
- SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
};
return [0, position];
return [0, resultPosition];
}
/**
@ -209,16 +205,16 @@ class SymmetricSorter extends AbstractBasicSorter {
}
/**
* @param treeSet
* @param node
* @throws will throw an error if treeSet is null or undefined
* @throws will throw an error if node is null or undefined
* @throws will throw an error if the calculated x offset cannot be converted to a numeric
* value, is null or undefined
* @throws will throw an error if the calculated y offset cannot be converted to a numeric
* value, is null or undefined
* @return offsets
*/
* @param treeSet
* @param node
* @throws will throw an error if treeSet is null or undefined
* @throws will throw an error if node is null or undefined
* @throws will throw an error if the calculated x offset cannot be converted to a numeric
* value, is null or undefined
* @throws will throw an error if the calculated y offset cannot be converted to a numeric
* value, is null or undefined
* @return offsets
*/
computeOffsets(treeSet, node) {
$assert(treeSet, 'treeSet can no be null.');
$assert(node, 'node can no be null.');
@ -227,16 +223,13 @@ class SymmetricSorter extends AbstractBasicSorter {
// Compute heights ...
const 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();
.map(((child) => ({
id: child.getId(),
order: child.getOrder(),
position: child.getPosition(),
width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child),
})).bind(this)).reverse();
// Compute the center of the branch ...
let totalHeight = 0;
@ -254,9 +247,9 @@ class SymmetricSorter extends AbstractBasicSorter {
const yOffset = ysum + heights[i].height / 2;
const xOffset = direction
* (heights[i].width / 2
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
* (heights[i].width / 2
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!Number.isNaN(xOffset), 'xOffset can not be null');
$assert(!Number.isNaN(yOffset), 'yOffset can not be null');
@ -281,9 +274,9 @@ class SymmetricSorter extends AbstractBasicSorter {
}
/**
* @param treeSet
* @param child
* @return direction of the given child from its parent or from the root node, if isolated */
* @param treeSet
* @param child
* @return direction of the given child from its parent or from the root node, if isolated */
getChildDirection(treeSet, child) {
$assert(treeSet, 'treeSet can no be null.');
$assert(treeSet.getParent(child), 'This should not happen');

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert, $defined } from "@wisemapping/core-js";
import { $assert, $defined } from '@wisemapping/core-js';
import $ from 'jquery';
class FeatureModel {
@ -33,18 +33,24 @@ class FeatureModel {
this._attributes = {};
// Create type method ...
this[`is${$.camelCase(type)}Model`] = () => true;
this[`is${FeatureModel.camelize(type)}Model`] = () => true;
}
/** */
getAttributes() {
return Object.clone(this._attributes);
return { ...this._attributes };
}
static camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => (index === 0 ? word.toLowerCase() : word.toUpperCase())).replace(/\s+/g, '');
}
/** */
setAttributes(attributes) {
for (const key in attributes) {
this[`set${key.capitalize()}`](attributes[key]);
for (const attr in attributes) {
const funName = `set${FeatureModel.camelize(attr)}`;
const value = attributes[attr];
this[funName](value);
}
}

View File

@ -39,14 +39,14 @@ class LinkModel extends FeatureModel {
const fixedUrl = LinkModel._fixUrl(url);
this.setAttribute('url', fixedUrl);
const type = fixedUrl.contains('mailto:') ? 'mail' : 'url';
const type = fixedUrl.includes('mailto:') ? 'mail' : 'url';
this.setAttribute('urlType', type);
}
// url format is already checked in LinkEditor.checkUrl
static _fixUrl(url) {
let result = url;
if (!result.contains('http://') && !result.contains('https://') && !result.contains('mailto://')) {
if (!result.includes('http://') && !result.includes('https://') && !result.includes('mailto://')) {
result = `http://${result}`;
}
return result;

View File

@ -86,7 +86,7 @@ class Mindmap extends IMindmap {
*/
removeBranch(nodeModel) {
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
return this._branches.erase(nodeModel);
this._branches = this._branches.filter((b) => b !== nodeModel);
}
/** */
@ -151,7 +151,7 @@ class Mindmap extends IMindmap {
* @param relationship
*/
deleteRelationship(relationship) {
this._relationships.erase(relationship);
this._relationships = this._branches.filter((r) => r !== relationship);
}
/**

View File

@ -169,7 +169,7 @@ class NodeModel extends INodeModel {
*/
removeChild(child) {
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
this._children.erase(child);
this._children = this._children.filter((c) => c !== child);
child._parent = null;
}

View File

@ -61,11 +61,15 @@ class FloatingTip extends Events {
return this;
}
setOptions() {
const options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));
setOptions(...args) {
this.options = { ...this.options, ...args };
const { options } = this;
if (this.addEvent) {
for (const option in options) {
if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
if (typeof (options[option]) != 'function' || !(/^on[A-Z]/).test(option)) {
continue;
}
this.addEvent(option, options[option]);
delete options[option];
}

View File

@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
import { $assert } from '@wisemapping/core-js';
import PersistenceManager from '../PersistenceManager';
import { $notify } from './ToolbarNotifier';
import $notifyModal from './ModalDialogNotifier';
class IMenu {
constructor(designer, containerId, mapId) {
$assert(designer, 'designer can not be null');
$assert(containerId, 'containerId can not be null');
@ -97,7 +97,7 @@ class IMenu {
$notifyModal(error.message);
}
}
}
},
}, sync);
}

View File

@ -111,19 +111,19 @@ class LinkEditor extends BootstrapDialog {
}
/**
* checks whether the input is a valid url
* @return {Boolean} true if the url is valid
*/
* checks whether the input is a valid url
* @return {Boolean} true if the url is valid
*/
checkURL(url) {
const regex = /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i;
return (regex.test(url));
}
/**
* overrides abstract parent method
* triggered when the user clicks the accept button - submits the url input
* @param event
*/
* overrides abstract parent method
* triggered when the user clicks the accept button - submits the url input
* @param event
*/
onAcceptClick(event) {
this.formSubmitted = false;
$('#linkFormId').trigger('submit');
@ -133,22 +133,21 @@ class LinkEditor extends BootstrapDialog {
}
/**
* overrides parent method
* sets the url input on focus
*/
* overrides parent method
* sets the url input on focus
*/
onDialogShown() {
$(this).find('#inputUrl').focus();
}
/**
* overrides abstract parent method
* triggered when the user clicks the remove button - deletes the link
*/
* overrides abstract parent method
* triggered when the user clicks the remove button - deletes the link
*/
onRemoveClick(event) {
event.data.model.setValue(null);
event.data.dialog.close();
}
}
export default LinkEditor;

View File

@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
class ModalDialogNotifier {
// FIXME: replace by alert()
show(message, title) {
$assert(message, 'message can not be null');
@ -42,11 +42,10 @@ class ModalDialogNotifier {
modalDialog.find('.alert-content').append(h4 + p);
modalDialog.modal();
},
});
}
}
const dialogNotifier = new ModalDialogNotifier();
const $notifyModal = dialogNotifier.show.bind(dialogNotifier);
export { $notifyModal };
export default ModalDialogNotifier;
export default { $notifyModal };

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
class NoteEditor extends BootstrapDialog {

View File

@ -1,6 +1,4 @@
/* eslint-disable no-unused-vars */
import '@libraries/mootools-core-1.4.5';
import Mindmap from './components/model/Mindmap';
import PersistenceManager from './components/PersistenceManager';
import Designer from './components/Designer';

View File

@ -20,6 +20,7 @@ import $ from 'jquery';
import { $assert } from '@wisemapping/core-js';
import TestSuite from './TestSuite';
import LayoutManager from '../../../src/components/layout/LayoutManager';
class BalancedTestSuite extends TestSuite {
constructor() {
$('#balancedTest').css('display', 'block');

View File

@ -501,13 +501,13 @@ class FreeTestSuite extends TestSuite {
_assertBranchCollision(treeSet, node, heightById) {
const children = treeSet.getChildren(node);
const childOfRootNode = treeSet._rootNodes.contains(node);
const childOfRootNode = treeSet._rootNodes.includes(node);
children.forEach((child) => {
const height = heightById[child.getId()];
let siblings = treeSet.getSiblings(child);
if (childOfRootNode) {
siblings = siblings.filter((sibling) => child.getOrder() % 2 == sibling.getOrder() % 2);
siblings = siblings.filter((sibling) => child.getOrder() % 2 === sibling.getOrder() % 2);
}
siblings.forEach((sibling) => {

View File

@ -91,7 +91,7 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 0);
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(3, 5, 0);
manager.addNode(6, { width: 140, height: 130 }, position).connectNode(3, 6, 1);
manager.addNode(6, { width: 140, height: 130 } , position).connectNode(3, 6, 1);
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(6, 7, 0);
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(7, 8, 0);
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(7, 9, 1);
@ -105,10 +105,10 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(17, TestSuite.NODE_SIZE, position).connectNode(7, 17, 9);
manager.addNode(29, TestSuite.NODE_SIZE, position).connectNode(6, 29, 1);
manager.addNode(30, TestSuite.NODE_SIZE, position).connectNode(6, 30, 2);
manager.addNode(31, { width: 100, height: 50 }, position).connectNode(6, 31, 3);
manager.addNode(31, { width: 100, height: 50 } , position).connectNode(6, 31, 3);
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 1);
manager.addNode(18, { width: 80, height: 70 }, position).connectNode(4, 18, 0);
manager.addNode(18, { width: 80, height: 70 } , position).connectNode(4, 18, 0);
manager.addNode(19, TestSuite.NODE_SIZE, position).connectNode(18, 19, 0);
manager.addNode(20, TestSuite.NODE_SIZE, position).connectNode(19, 20, 0);
manager.addNode(21, TestSuite.NODE_SIZE, position).connectNode(20, 21, 0);
@ -117,11 +117,11 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(22, TestSuite.NODE_SIZE, position).connectNode(2, 22, 0);
manager.addNode(24, TestSuite.NODE_SIZE, position).connectNode(22, 24, 0);
manager.addNode(23, { width: 80, height: 50 }, position).connectNode(2, 23, 1);
manager.addNode(25, { width: 80, height: 40 }, position).connectNode(23, 25, 0);
manager.addNode(26, { width: 80, height: 80 }, position).connectNode(25, 26, 0);
manager.addNode(23, { width: 80, height: 50 } , position).connectNode(2, 23, 1);
manager.addNode(25, { width: 80, height: 40 } , position).connectNode(23, 25, 0);
manager.addNode(26, { width: 80, height: 80 } , position).connectNode(25, 26, 0);
manager.addNode(27, TestSuite.NODE_SIZE, position).connectNode(26, 27, 0);
manager.addNode(28, { width: 80, height: 80 }, position).connectNode(27, 28, 0);
manager.addNode(28, { width: 80, height: 80 } , position).connectNode(27, 28, 0);
// manager.layout();
// manager.plot("testBaselineAligned1", {width:1600,height:800});
@ -135,7 +135,7 @@ class TestSuite extends ChildrenSorterStrategy {
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
manager.addNode(2, { width: 130, height: 200 }, position).connectNode(1, 2, 0);
manager.addNode(2, { width: 130, height: 200 } , position).connectNode(1, 2, 0);
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(2, 4, 1);
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(2, 5, 2);
@ -164,9 +164,9 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addEvent('change', (event) => {
console.log(
`\tUpdated nodes: {id:${event.getId()
}, order: ${event.getOrder()
},position: {${event.getPosition().x
},${event.getPosition().y
} order: ${event.getOrder()
}position: {${event.getPosition().x
}${event.getPosition().y
}}`,
);
events.push(event);
@ -206,9 +206,9 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addEvent('change', (event) => {
console.log(
`\tUpdated nodes: {id:${event.getId()
}, order: ${event.getOrder()
},position: {${event.getPosition().x
},${event.getPosition().y
} order: ${event.getOrder()
}position: {${event.getPosition().x
}${event.getPosition().y
}}`,
);
events.push(event);
@ -256,12 +256,12 @@ class TestSuite extends ChildrenSorterStrategy {
const events = [];
manager.addEvent('change', (event) => {
const pos = event.getPosition();
const posStr = pos ? `,position: {${pos.x},${pos.y}` : '';
const posStr = pos ? `,position: {${pos.x}${pos.y}` : '';
const node = manager.find(event.getId());
console.log(
`\tUpdated nodes: {id:${event.getId()
}, order: ${event.getOrder()
},${posStr
} order: ${event.getOrder()
}${posStr
}}`,
);
events.push(event);
@ -385,7 +385,7 @@ class TestSuite extends ChildrenSorterStrategy {
const events = [];
manager.addEvent('change', (event) => {
const pos = event.getPosition();
const posStr = pos ? `,position: {${pos.x},${event.getPosition().y}` : '';
const posStr = pos ? `,position: {${pos.x}${event.getPosition().y}` : '';
events.push(event);
});
manager.layout(true);
@ -431,17 +431,17 @@ class TestSuite extends ChildrenSorterStrategy {
const position = { x: 0, y: 0 };
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, { width: 60, height: 60 }, position);
manager.addNode(1, { width: 60, height: 60 } ,position);
manager.addNode(2, TestSuite.NODE_SIZE, position);
manager.addNode(3, { width: 260, height: 30 }, position);
manager.addNode(3, { width: 260, height: 30 } ,position);
manager.addNode(4, TestSuite.NODE_SIZE, position);
manager.addNode(5, TestSuite.NODE_SIZE, position);
manager.addNode(7, { width: 80, height: 80 }, position);
manager.addNode(7, { width: 80, height: 80 } ,position);
manager.addNode(8, TestSuite.NODE_SIZE, position);
manager.addNode(9, { width: 30, height: 30 }, position);
manager.addNode(9, { width: 30, height: 30 } ,position);
manager.addNode(10, TestSuite.NODE_SIZE, position);
manager.addNode(11, TestSuite.NODE_SIZE, position);
manager.addNode(12, { width: 100, height: 70 }, position);
manager.addNode(12, { width: 100, height: 70 } ,position);
manager.addNode(13, TestSuite.NODE_SIZE, position);
manager.addNode(14, TestSuite.NODE_SIZE, position);
manager.addNode(15, TestSuite.NODE_SIZE, position);
@ -565,8 +565,8 @@ class TestSuite extends ChildrenSorterStrategy {
const { order } = prediction;
console.log(
`\t\tprediction {order:${order
}, position: (${position.x
},${position.y
} position: (${position.x
}${position.y
})}`,
);
const cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2;

View File

@ -11,7 +11,6 @@
<![endif]-->
<link rel="stylesheet/less" type="text/css" href="css/editor.less"/>
<script type='text/javascript' src='js/mootools-core.js'></script>
<script type='text/javascript' src='js/core.js'></script>
<script type='text/javascript' src='js/less.js'></script>

View File

@ -18,6 +18,7 @@
import { $assert } from '@wisemapping/core-js';
import { PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/';
import * as mindplot from '../../../../src/';
import $notifyModal from '../../../../src/components/widget/ModalDialogNotifier';
import $ from 'jquery';
global.jQuery = $;

View File

@ -33,7 +33,7 @@ describe('Free Test Suite', () => {
function branchCollision(treeSet, node, heightById) {
const children = treeSet.getChildren(node);
const childOfRootNode = treeSet._rootNodes.contains(node);
const childOfRootNode = treeSet._rootNodes.includes(node);
children.forEach(((child) => {
let siblings = treeSet.getSiblings(child);

View File

@ -18,7 +18,6 @@ module.exports = {
test: /.(js$)/,
exclude: [
/node_modules/,
path.resolve(__dirname, '../../libraries/mootools-core-1.4.5'),
],
},
],

View File

@ -36,7 +36,6 @@ module.exports = {
test: /.js$/,
exclude: [
/node_modules/,
path.resolve(__dirname, '../../libraries/mootools-core-1.4.5'),
/lib\/raphael/ig,
],
},

View File

@ -13,6 +13,7 @@
"rules": {
"no-underscore-dangle": "off",
"no-restricted-syntax": "off",
"no-underscore-dangle": "off",
"no-plusplus": "off",
"max-len": [1,250],
"import/no-extraneous-dependencies": ["warn", {

View File

@ -3,7 +3,7 @@ const BASE_URL = 'http://localhost:8080';
context('Playground', () => {
it('every test page should match its snapshot', () => {
cy.visit(BASE_URL);
cy.get('a').each(($el) => {
cy.get('a').forEach(($el) => {
const url = `${BASE_URL}${$el.attr('href')}`;
cy.visit(url);
cy.matchImageSnapshot($el.text());

View File

@ -74,12 +74,14 @@ class ElementPeer {
removeChild(elementPeer) {
// Store parent and child relationship.
elementPeer.setParent(null);
const children = this.getChildren();
let children = this.getChildren();
// Remove from children array ...
const oldLength = children.length;
children.erase(elementPeer);
children = children.filter((c) => c !== elementPeer);
this.setChildren(children);
$assert(
children.length < oldLength,
`element could not be removed:${elementPeer}`,