Format JS files.

This commit is contained in:
Paulo Gustavo Veiga 2022-07-12 18:58:11 -07:00
parent cf29f4f953
commit 5ee7448d3c
70 changed files with 7930 additions and 1420 deletions

View File

@ -4,7 +4,9 @@
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery'); }
if (typeof jQuery === 'undefined') {
throw new Error("Bootstrap's JavaScript requires jQuery");
}
/* ========================================================================
* Bootstrap: transition.js v3.1.1
@ -39,10 +41,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) {
let called = false; const
$el = this;
$(this).one($.support.transition.end, () => { called = true; });
const callback = function () { if (!called) $($el).trigger($.support.transition.end); };
let called = false;
const $el = this;
$(this).one($.support.transition.end, () => {
called = true;
});
const callback = function () {
if (!called) $($el).trigger($.support.transition.end);
};
setTimeout(callback, duration);
return this;
};
@ -50,7 +56,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(() => {
$.support.transition = transitionEnd();
});
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: alert.js v3.1.1
@ -86,7 +92,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$parent = $this.hasClass('alert') ? $this : $this.parent();
}
$parent.trigger(e = $.Event('close.bs.alert'));
$parent.trigger((e = $.Event('close.bs.alert')));
if (e.isDefaultPrevented()) return;
@ -97,9 +103,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
}
$.support.transition && $parent.hasClass('fade')
? $parent
.one($.support.transition.end, removeElement)
.emulateTransitionEnd(150)
? $parent.one($.support.transition.end, removeElement).emulateTransitionEnd(150)
: removeElement();
};
@ -132,7 +136,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// ==============
$(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close);
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: button.js v3.1.1
@ -169,7 +173,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$el[val](data[state] || this.options[state]);
// push to event loop to allow forms to submit
setTimeout($.proxy(function () {
setTimeout(
$.proxy(function () {
if (state == 'loadingText') {
this.isLoading = true;
$el.addClass(d).attr(d, d);
@ -177,7 +182,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.isLoading = false;
$el.removeClass(d).removeAttr(d);
}
}, this), 0);
}, this),
0,
);
};
Button.prototype.toggle = function () {
@ -233,7 +240,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$btn.button('toggle');
e.preventDefault();
});
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: carousel.js v3.1.1
@ -253,7 +260,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.options = options;
this.paused = this.sliding = this.interval = this.$active = this.$items = null;
this.options.pause == 'hover' && this.$element
this.options.pause == 'hover' &&
this.$element
.on('mouseenter', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, this));
};
@ -269,9 +277,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.interval && clearInterval(this.interval);
this.options.interval
&& !this.paused
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval));
this.options.interval &&
!this.paused &&
(this.interval = setInterval($.proxy(this.next, this), this.options.interval));
return this;
};
@ -287,9 +295,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const that = this;
const activeIndex = this.getActiveIndex();
if (pos > (this.$items.length - 1) || pos < 0) return;
if (pos > this.$items.length - 1 || pos < 0) return;
if (this.sliding) return this.$element.one('slid.bs.carousel', () => { that.to(pos); });
if (this.sliding)
return this.$element.one('slid.bs.carousel', () => {
that.to(pos);
});
if (activeIndex == pos) return this.pause().cycle();
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]));
@ -331,7 +342,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$next = this.$element.find('.item')[fallback]();
}
if ($next.hasClass('active')) return this.sliding = false;
if ($next.hasClass('active')) return (this.sliding = false);
const e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction });
this.$element.trigger(e);
@ -359,7 +370,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$next.removeClass([type, direction].join(' ')).addClass('active');
$active.removeClass(['active', direction].join(' '));
that.sliding = false;
setTimeout(() => { that.$element.trigger('slid.bs.carousel'); }, 0);
setTimeout(() => {
that.$element.trigger('slid.bs.carousel');
}, 0);
})
.emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000);
} else {
@ -383,7 +396,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return this.each(function () {
const $this = $(this);
let data = $this.data('bs.carousel');
const options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option === 'object' && option);
const options = $.extend(
{},
Carousel.DEFAULTS,
$this.data(),
typeof option === 'object' && option,
);
const action = typeof option === 'string' ? option : options.slide;
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)));
@ -407,16 +425,19 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// =================
$(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
const $this = $(this); let
href;
const $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')); // strip for ie7
const $this = $(this);
let href;
const $target = $(
$this.attr('data-target') ||
((href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')),
); // strip for ie7
const options = $.extend({}, $target.data(), $this.data());
let slideIndex = $this.attr('data-slide-to');
if (slideIndex) options.interval = false;
$target.carousel(options);
if (slideIndex = $this.attr('data-slide-to')) {
if ((slideIndex = $this.attr('data-slide-to'))) {
$target.data('bs.carousel').to(slideIndex);
}
@ -429,7 +450,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$carousel.carousel($carousel.data());
});
});
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: collapse.js v3.1.1
@ -479,18 +500,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const dimension = this.dimension();
this.$element
.removeClass('collapse')
.addClass('collapsing')
[dimension](0);
this.$element.removeClass('collapse').addClass('collapsing')[dimension](0);
this.transitioning = 1;
const complete = function () {
this.$element
.removeClass('collapsing')
.addClass('collapse in')
[dimension]('auto');
this.$element.removeClass('collapsing').addClass('collapse in')[dimension]('auto');
this.transitioning = 0;
this.$element.trigger('shown.bs.collapse');
};
@ -514,29 +529,20 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const dimension = this.dimension();
this.$element
[dimension](this.$element[dimension]())
[0].offsetHeight;
this.$element[dimension](this.$element[dimension]())[0].offsetHeight;
this.$element
.addClass('collapsing')
.removeClass('collapse')
.removeClass('in');
this.$element.addClass('collapsing').removeClass('collapse').removeClass('in');
this.transitioning = 1;
const complete = function () {
this.transitioning = 0;
this.$element
.trigger('hidden.bs.collapse')
.removeClass('collapsing')
.addClass('collapse');
this.$element.trigger('hidden.bs.collapse').removeClass('collapsing').addClass('collapse');
};
if (!$.support.transition) return complete.call(this);
this.$element
[dimension](0)
this.$element[dimension](0)
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350);
};
@ -554,7 +560,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return this.each(function () {
const $this = $(this);
let data = $this.data('bs.collapse');
const options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option === 'object' && option);
const options = $.extend(
{},
Collapse.DEFAULTS,
$this.data(),
typeof option === 'object' && option,
);
if (!data && options.toggle && option == 'show') option = !option;
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)));
@ -576,11 +587,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// =================
$(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
const $this = $(this); let
href;
const target = $this.attr('data-target')
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); // strip for ie7
const $this = $(this);
let href;
const target =
$this.attr('data-target') ||
e.preventDefault() ||
((href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')); // strip for ie7
const $target = $(target);
const data = $target.data('bs.collapse');
const option = data ? 'toggle' : $this.data();
@ -588,13 +600,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $parent = parent && $(parent);
if (!data || !data.transitioning) {
if ($parent) $parent.find(`[data-toggle=collapse][data-parent="${parent}"]`).not($this).addClass('collapsed');
if ($parent)
$parent
.find(`[data-toggle=collapse][data-parent="${parent}"]`)
.not($this)
.addClass('collapsed');
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed');
}
$target.collapse(option);
});
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: dropdown.js v3.1.1
@ -631,13 +647,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
}
const relatedTarget = { relatedTarget: this };
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget));
$parent.trigger((e = $.Event('show.bs.dropdown', relatedTarget)));
if (e.isDefaultPrevented()) return;
$parent
.toggleClass('open')
.trigger('shown.bs.dropdown', relatedTarget);
$parent.toggleClass('open').trigger('shown.bs.dropdown', relatedTarget);
$this.focus();
}
@ -683,7 +697,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $parent = getParent($(this));
const relatedTarget = { relatedTarget: this };
if (!$parent.hasClass('open')) return;
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget));
$parent.trigger((e = $.Event('hide.bs.dropdown', relatedTarget)));
if (e.isDefaultPrevented()) return;
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget);
});
@ -732,10 +746,16 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(document)
.on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', (e) => { e.stopPropagation(); })
.on('click.bs.dropdown.data-api', '.dropdown form', (e) => {
e.stopPropagation();
})
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', `${toggle}, [role=menu], [role=listbox]`, Dropdown.prototype.keydown);
}(jQuery));
.on(
'keydown.bs.dropdown.data-api',
`${toggle}, [role=menu], [role=listbox]`,
Dropdown.prototype.keydown,
);
})(jQuery);
/* ========================================================================
* Bootstrap: modal.js v3.1.1
@ -755,11 +775,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.$backdrop = this.isShown = null;
if (this.options.remote) {
this.$element
.find('.modal-content')
.load(this.options.remote, $.proxy(function () {
this.$element.find('.modal-content').load(
this.options.remote,
$.proxy(function () {
this.$element.trigger('loaded.bs.modal');
}, this));
}, this),
);
}
};
@ -794,24 +815,21 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
that.$element.appendTo(document.body); // don't move modals dom position
}
that.$element
.show()
.scrollTop(0);
that.$element.show().scrollTop(0);
if (transition) {
that.$element[0].offsetWidth; // force reflow
}
that.$element
.addClass('in')
.attr('aria-hidden', false);
that.$element.addClass('in').attr('aria-hidden', false);
that.enforceFocus();
const e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget });
transition
? that.$element.find('.modal-dialog') // wait for modal to slide in
? that.$element
.find('.modal-dialog') // wait for modal to slide in
.one($.support.transition.end, () => {
that.$element.focus().trigger(e);
})
@ -835,10 +853,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(document).off('focusin.bs.modal');
this.$element
.removeClass('in')
.attr('aria-hidden', true)
.off('click.dismiss.bs.modal');
this.$element.removeClass('in').attr('aria-hidden', true).off('click.dismiss.bs.modal');
$.support.transition && this.$element.hasClass('fade')
? this.$element
@ -850,18 +865,24 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Modal.prototype.enforceFocus = function () {
$(document)
.off('focusin.bs.modal') // guard against infinite focus loop
.on('focusin.bs.modal', $.proxy(function (e) {
.on(
'focusin.bs.modal',
$.proxy(function (e) {
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.focus();
}
}, this));
}, this),
);
};
Modal.prototype.escape = function () {
if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
this.$element.on(
'keyup.dismiss.bs.modal',
$.proxy(function (e) {
e.which == 27 && this.hide();
}, this));
}, this),
);
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.bs.modal');
}
@ -887,15 +908,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
if (this.isShown && this.options.backdrop) {
const doAnimate = $.support.transition && animate;
this.$backdrop = $(`<div class="modal-backdrop ${animate}" />`)
.appendTo(document.body);
this.$backdrop = $(`<div class="modal-backdrop ${animate}" />`).appendTo(document.body);
this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
this.$element.on(
'click.dismiss.bs.modal',
$.proxy(function (e) {
if (e.target !== e.currentTarget) return;
this.options.backdrop == 'static'
? this.$element[0].focus.call(this.$element[0])
: this.hide.call(this);
}, this));
}, this),
);
if (doAnimate) this.$backdrop[0].offsetWidth; // force reflow
@ -904,17 +927,13 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
if (!callback) return;
doAnimate
? this.$backdrop
.one($.support.transition.end, callback)
.emulateTransitionEnd(150)
? this.$backdrop.one($.support.transition.end, callback).emulateTransitionEnd(150)
: callback();
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in');
$.support.transition && this.$element.hasClass('fade')
? this.$backdrop
.one($.support.transition.end, callback)
.emulateTransitionEnd(150)
? this.$backdrop.one($.support.transition.end, callback).emulateTransitionEnd(150)
: callback();
} else if (callback) {
callback();
@ -930,7 +949,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return this.each(function () {
const $this = $(this);
let data = $this.data('bs.modal');
const options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option === 'object' && option);
const options = $.extend(
{},
Modal.DEFAULTS,
$this.data(),
typeof option === 'object' && option,
);
if (!data) $this.data('bs.modal', (data = new Modal(this, options)));
if (typeof option === 'string') data[option](_relatedTarget);
@ -955,21 +979,25 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $this = $(this);
const href = $this.attr('href');
const $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))); // strip for ie7
const option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
const option = $target.data('bs.modal')
? 'toggle'
: $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
if ($this.is('a')) e.preventDefault();
$target
.modal(option, this)
.one('hide', () => {
$target.modal(option, this).one('hide', () => {
$this.is(':visible') && $this.focus();
});
});
$(document)
.on('show.bs.modal', '.modal', () => { $(document.body).addClass('modal-open'); })
.on('hidden.bs.modal', '.modal', () => { $(document.body).removeClass('modal-open'); });
}(jQuery));
.on('show.bs.modal', '.modal', () => {
$(document.body).addClass('modal-open');
})
.on('hidden.bs.modal', '.modal', () => {
$(document.body).removeClass('modal-open');
});
})(jQuery);
/* ========================================================================
* Bootstrap: tooltip.js v3.1.1
@ -994,7 +1022,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
animation: true,
placement: 'top',
selector: false,
template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
template:
'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
trigger: 'hover focus',
title: '',
delay: 0,
@ -1010,7 +1039,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const triggers = this.options.trigger.split(' ');
for (let i = triggers.length; i--;) {
for (let i = triggers.length; i--; ) {
const trigger = triggers[i];
if (trigger == 'click') {
@ -1019,8 +1048,16 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
const eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
this.$element.on(`${eventIn}.${this.type}`, this.options.selector, $.proxy(this.enter, this));
this.$element.on(`${eventOut}.${this.type}`, this.options.selector, $.proxy(this.leave, this));
this.$element.on(
`${eventIn}.${this.type}`,
this.options.selector,
$.proxy(this.enter, this),
);
this.$element.on(
`${eventOut}.${this.type}`,
this.options.selector,
$.proxy(this.leave, this),
);
}
}
@ -1050,7 +1087,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const options = {};
const defaults = this.getDefaults();
this._options && $.each(this._options, (key, value) => {
this._options &&
$.each(this._options, (key, value) => {
if (defaults[key] != value) options[key] = value;
});
@ -1058,8 +1096,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
};
Tooltip.prototype.enter = function (obj) {
const self = obj instanceof this.constructor
? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`);
const self =
obj instanceof this.constructor
? obj
: $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`);
clearTimeout(self.timeout);
@ -1073,8 +1113,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
};
Tooltip.prototype.leave = function (obj) {
const self = obj instanceof this.constructor
? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`);
const self =
obj instanceof this.constructor
? obj
: $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`);
clearTimeout(self.timeout);
@ -1102,7 +1144,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
if (this.options.animation) $tip.addClass('fade');
let placement = typeof this.options.placement === 'function'
let placement =
typeof this.options.placement === 'function'
? this.options.placement.call(this, $tip[0], this.$element[0])
: this.options.placement;
@ -1110,12 +1153,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const autoPlace = autoToken.test(placement);
if (autoPlace) placement = placement.replace(autoToken, '') || 'top';
$tip
.detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement);
$tip.detach().css({ top: 0, left: 0, display: 'block' }).addClass(placement);
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element);
this.options.container
? $tip.appendTo(this.options.container)
: $tip.insertAfter(this.$element);
const pos = this.getPosition();
const actualWidth = $tip[0].offsetWidth;
@ -1126,19 +1168,24 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const orgPlacement = placement;
const docScroll = document.documentElement.scrollTop || document.body.scrollTop;
const parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth();
const parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight();
const parentWidth =
this.options.container == 'body' ? window.innerWidth : $parent.outerWidth();
const parentHeight =
this.options.container == 'body' ? window.innerHeight : $parent.outerHeight();
const parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left;
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top'
: placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom'
: placement == 'right' && pos.right + actualWidth > parentWidth ? 'left'
: placement == 'left' && pos.left - actualWidth < parentLeft ? 'right'
placement =
placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight
? 'top'
: placement == 'top' && pos.top - docScroll - actualHeight < 0
? 'bottom'
: placement == 'right' && pos.right + actualWidth > parentWidth
? 'left'
: placement == 'left' && pos.left - actualWidth < parentLeft
? 'right'
: placement;
$tip
.removeClass(orgPlacement)
.addClass(placement);
$tip.removeClass(orgPlacement).addClass(placement);
}
const calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight);
@ -1151,9 +1198,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
};
$.support.transition && this.$tip.hasClass('fade')
? $tip
.one($.support.transition.end, complete)
.emulateTransitionEnd(150)
? $tip.one($.support.transition.end, complete).emulateTransitionEnd(150)
: complete();
}
};
@ -1177,14 +1222,21 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// $.fn.offset doesn't round pixel values
// so we use setOffset directly with our own function B-0
$.offset.setOffset($tip[0], $.extend({
$.offset.setOffset(
$tip[0],
$.extend(
{
using(props) {
$tip.css({
top: Math.round(props.top),
left: Math.round(props.left),
});
},
}, offset), 0);
},
offset,
),
0,
);
$tip.addClass('in');
@ -1219,7 +1271,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
};
Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
this.arrow().css(position, delta ? (`${50 * (1 - delta / dimension)}%`) : '');
this.arrow().css(position, delta ? `${50 * (1 - delta / dimension)}%` : '');
};
Tooltip.prototype.setContent = function () {
@ -1247,9 +1299,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$tip.removeClass('in');
$.support.transition && this.$tip.hasClass('fade')
? $tip
.one($.support.transition.end, complete)
.emulateTransitionEnd(150)
? $tip.one($.support.transition.end, complete).emulateTransitionEnd(150)
: complete();
this.hoverState = null;
@ -1259,7 +1309,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Tooltip.prototype.fixTitle = function () {
const $e = this.$element;
if ($e.attr('title') || typeof ($e.attr('data-original-title')) !== 'string') {
if ($e.attr('title') || typeof $e.attr('data-original-title') !== 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '');
}
};
@ -1270,17 +1320,29 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Tooltip.prototype.getPosition = function () {
const el = this.$element[0];
return $.extend({}, (typeof el.getBoundingClientRect === 'function') ? el.getBoundingClientRect() : {
return $.extend(
{},
typeof el.getBoundingClientRect === 'function'
? el.getBoundingClientRect()
: {
width: el.offsetWidth,
height: el.offsetHeight,
}, this.$element.offset());
},
this.$element.offset(),
);
};
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 }
: placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 }
: placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth }
/* placement == 'right' */ : { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width };
return placement == 'bottom'
? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 }
: placement == 'top'
? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 }
: placement == 'left'
? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth }
: /* placement == 'right' */ {
top: pos.top + pos.height / 2 - actualHeight / 2,
left: pos.left + pos.width,
};
};
Tooltip.prototype.getTitle = function () {
@ -1288,18 +1350,19 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $e = this.$element;
const o = this.options;
title = $e.attr('data-original-title')
|| (typeof o.title === 'function' ? o.title.call($e[0]) : o.title);
title =
$e.attr('data-original-title') ||
(typeof o.title === 'function' ? o.title.call($e[0]) : o.title);
return title;
};
Tooltip.prototype.tip = function () {
return this.$tip = this.$tip || $(this.options.template);
return (this.$tip = this.$tip || $(this.options.template));
};
Tooltip.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow');
return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'));
};
Tooltip.prototype.validate = function () {
@ -1323,7 +1386,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
};
Tooltip.prototype.toggle = function (e) {
const self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`) : this;
const self = e
? $(e.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`)
: this;
self.tip().hasClass('in') ? self.leave(self) : self.enter(self);
};
@ -1358,7 +1423,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$.fn.tooltip = old;
return this;
};
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: popover.js v3.1.1
@ -1382,7 +1447,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
placement: 'right',
trigger: 'click',
content: '',
template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
template:
'<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
});
// NOTE: POPOVER EXTENDS tooltip.js
@ -1402,9 +1468,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const content = this.getContent();
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title);
$tip.find('.popover-content')[// we use append for html objects to maintain js events
this.options.html ? (typeof content === 'string' ? 'html' : 'append') : 'text'
](content);
$tip
.find('.popover-content') // we use append for html objects to maintain js events
[this.options.html ? (typeof content === 'string' ? 'html' : 'append') : 'text'](content);
$tip.removeClass('fade top bottom left right in');
@ -1421,14 +1487,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $e = this.$element;
const o = this.options;
return $e.attr('data-content')
|| (typeof o.content === 'function'
? o.content.call($e[0])
: o.content);
return (
$e.attr('data-content') ||
(typeof o.content === 'function' ? o.content.call($e[0]) : o.content)
);
};
Popover.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.arrow');
return (this.$arrow = this.$arrow || this.tip().find('.arrow'));
};
Popover.prototype.tip = function () {
@ -1462,7 +1528,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$.fn.popover = old;
return this;
};
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: scrollspy.js v3.1.1
@ -1484,9 +1550,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.$body = $('body');
this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process);
this.options = $.extend({}, ScrollSpy.DEFAULTS, options);
this.selector = `${this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
|| ''} .nav li > a`;
this.selector = `${
this.options.target ||
((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) || // strip for ie7
''
} .nav li > a`;
this.offsets = $([]);
this.targets = $([]);
this.activeTarget = null;
@ -1513,10 +1581,18 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const href = $el.data('target') || $el.attr('href');
const $href = /^#./.test(href) && $(href);
return ($href
&& $href.length
&& $href.is(':visible')
&& [[$href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null;
return (
($href &&
$href.length &&
$href.is(':visible') && [
[
$href[offsetMethod]().top +
(!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()),
href,
],
]) ||
null
);
})
.sort((a, b) => a[0] - b[0])
.each(function () {
@ -1542,33 +1618,25 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return activeTarget != (i = targets[0]) && this.activate(i);
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate(targets[i]);
for (i = offsets.length; i--; ) {
activeTarget != targets[i] &&
scrollTop >= offsets[i] &&
(!offsets[i + 1] || scrollTop <= offsets[i + 1]) &&
this.activate(targets[i]);
}
};
ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target;
$(this.selector)
.parentsUntil(this.options.target, '.active')
.removeClass('active');
$(this.selector).parentsUntil(this.options.target, '.active').removeClass('active');
const selector = `${this.selector
}[data-target="${target}"],${
this.selector}[href="${target}"]`;
const selector = `${this.selector}[data-target="${target}"],${this.selector}[href="${target}"]`;
let active = $(selector)
.parents('li')
.addClass('active');
let active = $(selector).parents('li').addClass('active');
if (active.parent('.dropdown-menu').length) {
active = active
.closest('li.dropdown')
.addClass('active');
active = active.closest('li.dropdown').addClass('active');
}
active.trigger('activate.bs.scrollspy');
@ -1609,7 +1677,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$spy.scrollspy($spy.data());
});
});
}(jQuery));
})(jQuery);
/* ========================================================================
* Bootstrap: tab.js v3.1.1
@ -1661,15 +1729,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Tab.prototype.activate = function (element, container, callback) {
const $active = container.find('> .active');
const transition = callback
&& $.support.transition
&& $active.hasClass('fade');
const transition = callback && $.support.transition && $active.hasClass('fade');
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active');
$active.removeClass('active').find('> .dropdown-menu > .active').removeClass('active');
element.addClass('active');
@ -1687,11 +1750,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
callback && callback();
}
transition
? $active
.one($.support.transition.end, next)
.emulateTransitionEnd(150)
: next();
transition ? $active.one($.support.transition.end, next).emulateTransitionEnd(150) : next();
$active.removeClass('in');
};
@ -1724,11 +1783,15 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// TAB DATA-API
// ============
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
$(document).on(
'click.bs.tab.data-api',
'[data-toggle="tab"], [data-toggle="pill"]',
function (e) {
e.preventDefault();
$(this).tab('show');
});
}(jQuery));
},
);
})(jQuery);
/* ========================================================================
* Bootstrap: affix.js v3.1.1
@ -1788,9 +1851,15 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
if (typeof offsetTop === 'function') offsetTop = offset.top(this.$element);
if (typeof offsetBottom === 'function') offsetBottom = offset.bottom(this.$element);
const affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false
: offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom'
: offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false;
const affix =
this.unpin != null && scrollTop + this.unpin <= position.top
? false
: offsetBottom != null &&
position.top + this.$element.height() >= scrollHeight - offsetBottom
? 'bottom'
: offsetTop != null && scrollTop <= offsetTop
? 'top'
: false;
if (this.affixed === affix) return;
if (this.unpin) this.$element.css('top', '');
@ -1857,4 +1926,4 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$spy.affix(data);
});
});
}(jQuery));
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -8,105 +8,186 @@
*
* Original idea by:
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
*/
*/
/*
* One small change is: now keys are passed by object { keys: '...' }
* Might be useful, when you want to pass some other data to your handler
*/
function initHotKeyPluggin(jQuery){
function initHotKeyPluggin(jQuery) {
jQuery.hotkeys = {
version: "0.8",
version: '0.8',
specialKeys: {
8: "backspace", 9: "tab", 10: "return", 13: "enter", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home",
37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del",
96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7",
104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/",
112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8",
120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: ";", 191: "/",
220: "\\", 222: "'", 224: "meta"
8: 'backspace',
9: 'tab',
10: 'return',
13: 'enter',
16: 'shift',
17: 'ctrl',
18: 'alt',
19: 'pause',
20: 'capslock',
27: 'esc',
32: 'space',
33: 'pageup',
34: 'pagedown',
35: 'end',
36: 'home',
37: 'left',
38: 'up',
39: 'right',
40: 'down',
45: 'insert',
46: 'del',
96: '0',
97: '1',
98: '2',
99: '3',
100: '4',
101: '5',
102: '6',
103: '7',
104: '8',
105: '9',
106: '*',
107: '+',
109: '-',
110: '.',
111: '/',
112: 'f1',
113: 'f2',
114: 'f3',
115: 'f4',
116: 'f5',
117: 'f6',
118: 'f7',
119: 'f8',
120: 'f9',
121: 'f10',
122: 'f11',
123: 'f12',
144: 'numlock',
145: 'scroll',
186: ';',
191: '/',
220: '\\',
222: "'",
224: 'meta',
},
shiftNums: {
"`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&",
"8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<",
".": ">", "/": "?", "\\": "|"
}
'`': '~',
1: '!',
2: '@',
3: '#',
4: '$',
5: '%',
6: '^',
7: '&',
8: '*',
9: '(',
0: ')',
'-': '_',
'=': '+',
';': ': ',
"'": '"',
',': '<',
'.': '>',
'/': '?',
'\\': '|',
},
};
function keyHandler( handleObj ) {
if ( typeof handleObj.data === "string" ) {
function keyHandler(handleObj) {
if (typeof handleObj.data === 'string') {
handleObj.data = { keys: handleObj.data };
}
// Only care when a possible input has been specified
if ( !handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string" ) {
if (!handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== 'string') {
return;
}
var origHandler = handleObj.handler,
keys = handleObj.data.keys.toLowerCase().split(" "),
textAcceptingInputTypes = ["text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime", "datetime-local", "search", "color", "tel"];
keys = handleObj.data.keys.toLowerCase().split(' '),
textAcceptingInputTypes = [
'text',
'password',
'number',
'email',
'url',
'range',
'date',
'month',
'week',
'time',
'datetime',
'datetime-local',
'search',
'color',
'tel',
];
handleObj.handler = function( event ) {
handleObj.handler = function (event) {
// Don't fire in text-accepting inputs that we didn't directly bind to
if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) ||
jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1 ) ) {
if (
this !== event.target &&
(/textarea|select/i.test(event.target.nodeName) ||
jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1)
) {
return;
}
var special = jQuery.hotkeys.specialKeys[ event.keyCode ],
character = String.fromCharCode( event.which ).toLowerCase(),
modif = "", possible = {};
var special = jQuery.hotkeys.specialKeys[event.keyCode],
character = String.fromCharCode(event.which).toLowerCase(),
modif = '',
possible = {};
// check combinations (alt|ctrl|shift+anything)
if ( event.altKey && special !== "alt" ) {
modif += "alt+";
if (event.altKey && special !== 'alt') {
modif += 'alt+';
}
if ( event.ctrlKey && special !== "ctrl" ) {
modif += "ctrl+";
if (event.ctrlKey && special !== 'ctrl') {
modif += 'ctrl+';
}
// TODO: Need to make sure this works consistently across platforms
if ( event.metaKey && !event.ctrlKey && special !== "meta" ) {
modif += "meta+";
if (event.metaKey && !event.ctrlKey && special !== 'meta') {
modif += 'meta+';
}
if ( event.shiftKey && special !== "shift" ) {
modif += "shift+";
if (event.shiftKey && special !== 'shift') {
modif += 'shift+';
}
if ( special ) {
possible[ modif + special ] = true;
if (special) {
possible[modif + special] = true;
}
if ( character ) {
possible[ modif + character ] = true;
possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true;
if (character) {
possible[modif + character] = true;
possible[modif + jQuery.hotkeys.shiftNums[character]] = true;
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
if ( modif === "shift+" ) {
possible[ jQuery.hotkeys.shiftNums[ character ] ] = true;
if (modif === 'shift+') {
possible[jQuery.hotkeys.shiftNums[character]] = true;
}
}
for ( var i = 0, l = keys.length; i < l; i++ ) {
if ( possible[ keys[i] ] ) {
return origHandler.apply( this, arguments );
for (var i = 0, l = keys.length; i < l; i++) {
if (possible[keys[i]]) {
return origHandler.apply(this, arguments);
}
}
};
}
jQuery.each([ "keydown", "keyup", "keypress" ], function() {
jQuery.event.special[ this ] = { add: keyHandler };
jQuery.each(['keydown', 'keyup', 'keypress'], function () {
jQuery.event.special[this] = { add: keyHandler };
});
};
}
export default initHotKeyPluggin;

View File

@ -8,7 +8,7 @@ module.exports = {
publicPath: '',
library: {
type: 'umd',
}
},
},
target: 'web',
optimization: {
@ -19,17 +19,17 @@ module.exports = {
{
use: 'babel-loader',
test: /.js$/,
exclude: [
/node_modules/,
]
exclude: [/node_modules/],
},
],
},
resolve: {
extensions: ['.js'],
},
plugins: [new CleanWebpackPlugin({
plugins: [
new CleanWebpackPlugin({
dangerouslyAllowCleanPatternsOutsideProject: true,
dry: false,
})],
}),
],
};

View File

@ -5,7 +5,7 @@ const common = require('./webpack.common');
const devConfig = {
mode: 'development',
plugins: [new HotModuleReplacementPlugin()],
devtool: 'eval-source-map'
devtool: 'eval-source-map',
};
module.exports = merge(common, devConfig);

View File

@ -1,6 +1,17 @@
context('Playground', () => {
it('viewmode page should match its snapshot', () => {
['welcome', 'sample1', 'sample2', 'sample3', 'sample4', 'sample5', 'sample6', 'complex', 'img-support', 'icon-sample'].forEach((mapId) => {
[
'welcome',
'sample1',
'sample2',
'sample3',
'sample4',
'sample5',
'sample6',
'complex',
'img-support',
'icon-sample',
].forEach((mapId) => {
cy.visit(`/viewmode.html?id=${mapId}`);
cy.get('#mindplot.ready').should('exist');
cy.matchImageSnapshot(`viewmode-${mapId}`);
@ -8,9 +19,7 @@ context('Playground', () => {
});
it('the playground container.html page should match its snapshot', () => {
cy.visit('/container.html');
cy.getIframeBody()
.find('#mindplot.ready')
.should('exist');
cy.getIframeBody().find('#mindplot.ready').should('exist');
cy.matchImageSnapshot('container');
});
it('the playground editor.html page should match its snapshot', () => {

View File

@ -18,7 +18,6 @@ if (Cypress.env('imageSnaphots')) {
}
// https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/
Cypress.Commands.add('getIframeBody', () => cy
.get('iframe')
.its('0.contentDocument.body').should('not.be.empty')
.then(cy.wrap));
Cypress.Commands.add('getIframeBody', () =>
cy.get('iframe').its('0.contentDocument.body').should('not.be.empty').then(cy.wrap),
);

View File

@ -75,9 +75,7 @@ class BootstrapDialog extends Options {
)}</button>`,
);
footer.append(this.acceptButton);
this.acceptButton
.unbind('click')
.on('click', this.options.onEventData, this.onAcceptClick);
this.acceptButton.unbind('click').on('click', this.options.onEventData, this.onAcceptClick);
}
if (this.options.removeButton) {
this.removeButton = $(

View File

@ -49,10 +49,7 @@ class BootstrapDialogRequest extends BootstrapDialog {
this._native.find('.modal-body').load(url, () => {
me.acceptButton.unbind('click').click(() => {
if (
$defined(global.submitDialogForm)
&& typeof global.submitDialogForm === 'function'
) {
if ($defined(global.submitDialogForm) && typeof global.submitDialogForm === 'function') {
global.submitDialogForm();
}
});

View File

@ -96,26 +96,113 @@ export const buildHtml = () => {
const palettes = [
{
id: ':3p',
colors: [['(0, 0, 0)', '(68, 68, 68)', '(102, 102, 102)', '(153, 153, 153)', '(204, 204, 204)', '(238, 238, 238)', '(243, 243, 243)', '(254, 255, 255)']],
colors: [
[
'(0, 0, 0)',
'(68, 68, 68)',
'(102, 102, 102)',
'(153, 153, 153)',
'(204, 204, 204)',
'(238, 238, 238)',
'(243, 243, 243)',
'(254, 255, 255)',
],
],
},
{
id: '3q',
colors: [['(255, 0, 0)', '(255, 153, 0)', '(255, 255, 0)', '(0, 255, 0)', '(0, 255, 255)', '(0, 0, 255)', '(153, 0, 255)', '(255, 0, 255)']],
colors: [
[
'(255, 0, 0)',
'(255, 153, 0)',
'(255, 255, 0)',
'(0, 255, 0)',
'(0, 255, 255)',
'(0, 0, 255)',
'(153, 0, 255)',
'(255, 0, 255)',
],
],
},
{
id: '3r',
colors: [
['(244, 204, 204)', '(252, 229, 205)', '(255, 242, 204)', '(217, 234, 211)', '(208, 224, 227)', '(207, 226, 243)', '(217, 210, 233)', '(234, 209, 220)'],
['(234, 153, 153)', '(249, 203, 156)', '(255, 229, 153)', '(182, 215, 168)', '(162, 196, 201)', '(159, 197, 232)', '(180, 167, 214)', '(213, 166, 189)'],
['(224, 102, 102)', '(246, 178, 107)', '(255, 217, 102)', '(147, 196, 125)', '(118, 165, 175)', '(111, 168, 220)', '(142, 124, 195)', '(194, 123, 160)'],
['(204, 0, 0)', '(230, 145, 56)', '(241, 194, 50)', '(106, 168, 79)', '(69, 129, 142)', '(61, 133, 198)', '(103, 78, 167)', '(166, 77, 121)'],
['(153, 0, 0)', '(180, 95, 6)', '(191, 144, 0)', '(56, 118, 29)', '(19, 79, 92)', '(11, 83, 148)', '(53, 28, 117)', '(116, 27, 71)'],
['(102, 0, 0)', '(120, 63, 4)', '(127, 96, 0)', '(39, 78, 19)', '(12, 52, 61)', '(7, 55, 99)', '(32, 18, 77)', '(76, 17, 48)'],
[
'(244, 204, 204)',
'(252, 229, 205)',
'(255, 242, 204)',
'(217, 234, 211)',
'(208, 224, 227)',
'(207, 226, 243)',
'(217, 210, 233)',
'(234, 209, 220)',
],
[
'(234, 153, 153)',
'(249, 203, 156)',
'(255, 229, 153)',
'(182, 215, 168)',
'(162, 196, 201)',
'(159, 197, 232)',
'(180, 167, 214)',
'(213, 166, 189)',
],
[
'(224, 102, 102)',
'(246, 178, 107)',
'(255, 217, 102)',
'(147, 196, 125)',
'(118, 165, 175)',
'(111, 168, 220)',
'(142, 124, 195)',
'(194, 123, 160)',
],
[
'(204, 0, 0)',
'(230, 145, 56)',
'(241, 194, 50)',
'(106, 168, 79)',
'(69, 129, 142)',
'(61, 133, 198)',
'(103, 78, 167)',
'(166, 77, 121)',
],
[
'(153, 0, 0)',
'(180, 95, 6)',
'(191, 144, 0)',
'(56, 118, 29)',
'(19, 79, 92)',
'(11, 83, 148)',
'(53, 28, 117)',
'(116, 27, 71)',
],
[
'(102, 0, 0)',
'(120, 63, 4)',
'(127, 96, 0)',
'(39, 78, 19)',
'(12, 52, 61)',
'(7, 55, 99)',
'(32, 18, 77)',
'(76, 17, 48)',
],
],
},
{
id: '2p',
colors: [['(255, 255, 255)', '(224, 229, 239)', '(80, 157, 192)', '(57, 113, 177)', '(2, 59, 185)', '(244, 184, 45)', '(241, 163, 39)', '(82, 92, 97)']],
colors: [
[
'(255, 255, 255)',
'(224, 229, 239)',
'(80, 157, 192)',
'(57, 113, 177)',
'(2, 59, 185)',
'(244, 184, 45)',
'(241, 163, 39)',
'(82, 92, 97)',
],
],
},
];

View File

@ -21,7 +21,8 @@ import ToolbarPaneItem from './ToolbarPaneItem';
import { buildHtml, css } from './ColorPaletteHtml';
// rgbToHex implementation from https://stackoverflow.com/a/3627747/58128
export const rgb2hex = (rgb) => `#${rgb
export const rgb2hex = (rgb) =>
`#${rgb
.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)
.slice(1)
.map((n) => parseInt(n, 10).toString(16).padStart(2, '0'))
@ -71,9 +72,7 @@ class ColorPalettePanel extends ToolbarPaneItem {
const panelElem = this.getPanelElem();
// Clear selected cell based on the color ...
panelElem
.find("td[class='palette-cell palette-cell-selected']")
.attr('class', 'palette-cell');
panelElem.find("td[class='palette-cell palette-cell-selected']").attr('class', 'palette-cell');
// Mark the cell as selected ...
const colorCells = panelElem.find('div[class=palette-colorswatch]');

View File

@ -22,7 +22,20 @@ class FontFamilyPanel extends ListToolbarPanel {
// eslint-disable-next-line class-methods-use-this
buildPanel() {
const content = $("<div class='toolbarPanel' id='fontFamilyPanel'></div>");
const list = ['Arial', 'Baskerville', 'Tahoma', 'Limunari', 'Brush Script MT', 'Verdana', 'Times', 'Cursive', 'Fantasy', 'Perpetua', 'Brush Script', 'Copperplate']
const list = [
'Arial',
'Baskerville',
'Tahoma',
'Limunari',
'Brush Script MT',
'Verdana',
'Times',
'Cursive',
'Fantasy',
'Perpetua',
'Brush Script',
'Copperplate',
]
.sort()
.map((f) => `<div model="${f}" class="toolbarPanelLink" style="font-family:${f};">${f}</div>`)
.join('\n');

View File

@ -22,11 +22,12 @@ class FontSizePanel extends ListToolbarPanel {
// eslint-disable-next-line class-methods-use-this
buildPanel() {
const content = $("<div class='toolbarPanel' id='fontSizePanel'></div>");
content[0].innerHTML = ''
+ '<div id="small" model="6" style="font-size:8px">Small</div>'
+ '<div id="normal" model="8" style="font-size:12px">Normal</div>'
+ '<div id="large" model="10" style="font-size:15px">Large</div>'
+ '<div id="huge" model="15" style="font-size:24px">Huge</div>';
content[0].innerHTML =
'' +
'<div id="small" model="6" style="font-size:8px">Small</div>' +
'<div id="normal" model="8" style="font-size:12px">Normal</div>' +
'<div id="large" model="10" style="font-size:15px">Large</div>' +
'<div id="huge" model="15" style="font-size:24px">Huge</div>';
return content;
}

View File

@ -19,15 +19,16 @@ import $ from 'jquery';
import ToolbarPaneItem from './ToolbarPaneItem';
import { ImageIcon } from '@wisemapping/mindplot';
class IconPanel extends ToolbarPaneItem {
_updateSelectedItem() {
return this.getPanelElem();
}
buildPanel() {
const content = $('<div class="toolbarPanel" id="IconsPanel"></div>')
.css({ width: 295, height: 305 });
const content = $('<div class="toolbarPanel" id="IconsPanel"></div>').css({
width: 295,
height: 305,
});
content.on('click', (event) => {
event.stopPropagation();
});
@ -37,7 +38,7 @@ class IconPanel extends ToolbarPaneItem {
for (let i = 0; i < ImageIcon.prototype.ICON_FAMILIES.length; i += 1) {
const familyIcons = ImageIcon.prototype.ICON_FAMILIES[i].icons;
for (let j = 0; j < familyIcons.length; j += 1) {
if ((count % 12) === 0) {
if (count % 12 === 0) {
familyContent = $('<div></div>');
content.append(familyContent);
}
@ -52,10 +53,10 @@ class IconPanel extends ToolbarPaneItem {
const panel = this;
const model = this.getModel();
img.on('click', ((event) => {
img.on('click', (event) => {
model.setValue($(event.target).attr('id'));
panel.hide();
}));
});
count += 1;
}

View File

@ -18,7 +18,6 @@
import BootstrapDialog from '../bootstrap/BootstrapDialog';
import { $msg } from '@wisemapping/mindplot';
class KeyboardShortcutDialog extends BootstrapDialog {
constructor() {
super($msg('SHORTCUTS'), {

View File

@ -36,7 +36,8 @@ class KeyboardShortcutTooltip extends FloatingTip {
html: true,
placement: 'bottom',
className: 'keyboardShortcutTip',
template: '<div class="popover popoverBlack" role="tooltip"><div class="arrow arrowBlack"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
template:
'<div class="popover popoverBlack" role="tooltip"><div class="arrow arrowBlack"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
});
tipDiv.on('click', (e) => {
tipDiv.trigger('mouseleave', e);

View File

@ -43,7 +43,9 @@ class ListToolbarPanel extends ToolbarPaneItem {
const menuElems = panelElem.find('div');
const value = this.getModel().getValue();
menuElems.each((index, elem) => {
const elemValue = $defined($(elem).attr('model')) ? $(elem).attr('model') : $(elem).attr('id');
const elemValue = $defined($(elem).attr('model'))
? $(elem).attr('model')
: $(elem).attr('id');
$assert(elemValue, 'elemValue can not be null');
if (elemValue === value) $(elem).attr('class', 'toolbarPanelLinkSelectedLink');
else $(elem).attr('class', 'toolbarPanelLink');

View File

@ -10,23 +10,23 @@ module.exports = {
},
},
stats: {
errorDetails: true
errorDetails: true,
},
entry: {
"editor.bundle": path.join(__dirname, 'src', 'index.tsx')
'editor.bundle': path.join(__dirname, 'src', 'index.tsx'),
},
mode: 'development',
devtool: 'source-map',
target: 'web',
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/'
exclude: '/node_modules/',
},
{
test: /\.(png|jpe?g|gif|svg)$/,
@ -36,14 +36,15 @@ module.exports = {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
}, {
},
{
test: /\.css$/i,
loader: 'style-loader'
loader: 'style-loader',
},
{
test: /\.css$/,
loader: 'css-loader',
}
},
],
},
};

View File

@ -9,12 +9,10 @@ const prodConfig = {
},
externals: {
react: 'react',
"react-dom": 'react-dom',
"react-intl": 'react-intl',
'react-dom': 'react-dom',
'react-intl': 'react-intl',
},
plugins: [
new CleanWebpackPlugin(),
]
plugins: [new CleanWebpackPlugin()],
};
module.exports = merge(common, prodConfig);

View File

@ -18,7 +18,6 @@ if (Cypress.env('imageSnaphots')) {
}
// https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/
Cypress.Commands.add('getIframeBody', () => cy
.get('iframe')
.its('0.contentDocument.body').should('not.be.empty')
.then(cy.wrap));
Cypress.Commands.add('getIframeBody', () =>
cy.get('iframe').its('0.contentDocument.body').should('not.be.empty').then(cy.wrap),
);

View File

@ -15,9 +15,7 @@
* 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 Icon from './Icon';
import ActionDispatcher from './ActionDispatcher';
@ -85,7 +83,7 @@ class ImageIcon extends Icon {
for (let i = 0; i < familyIcons.length && result == null; i++) {
if (familyIcons[i] === iconId) {
// Is last one?
if (i === (familyIcons.length - 1)) {
if (i === familyIcons.length - 1) {
[result] = familyIcons;
} else {
result = familyIcons[i + 1];
@ -122,116 +120,219 @@ class ImageIcon extends Icon {
}
}
ImageIcon.prototype.ICON_FAMILIES = [{
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: 'sport',
icons: ['sport_basketball', 'sport_football', 'sport_golf', 'sport_raquet', 'sport_shuttlecock', 'sport_soccer', 'sport_tennis'],
},
{
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'],
},
{
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'],
},
{
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'],
},
{
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', 'hard_webcam', 'hard_microphone'],
},
{
icons: [
'hard_cd',
'hard_computer',
'hard_controller',
'hard_driver_disk',
'hard_ipod',
'hard_keyboard',
'hard_mouse',
'hard_printer',
'hard_webcam',
'hard_microphone',
],
},
{
id: 'things',
icons: ['things_address_book', 'things_wrench', 'things_pin', 'things_window-layout', 'things_bubbles'],
},
{
icons: [
'things_address_book',
'things_wrench',
'things_pin',
'things_window-layout',
'things_bubbles',
],
},
{
id: 'soft',
icons: ['soft_bug', 'soft_cursor', 'soft_database_table', 'soft_database', 'soft_feed', 'soft_folder_explore', 'soft_rss', 'soft_penguin'],
},
{
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'],
},
{
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: 'social',
icons: ['social_facebook', 'social_twitter', 'social_redit', 'social_instagram', 'social_google-plus'],
},
{
icons: [
'social_facebook',
'social_twitter',
'social_redit',
'social_instagram',
'social_google-plus',
],
},
{
id: 'meetapps',
icons: ['meetapps_slack', 'meetapps_google-meet', 'meetapps_whatapp', 'meetapps_ms-teams', 'meetapps_zoom', 'meetapps_facebook-messenger'],
},
{
icons: [
'meetapps_slack',
'meetapps_google-meet',
'meetapps_whatapp',
'meetapps_ms-teams',
'meetapps_zoom',
'meetapps_facebook-messenger',
],
},
{
id: 'appsgoogle',
icons: ['appsgoogle_youtube', 'appsgoogle_gmail', 'appsgoogle_maps'],
},
{
},
{
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',
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'],
},
{
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'],
},
},
];
export default ImageIcon;

View File

@ -9,7 +9,7 @@ class Options {
const optionsKeys = Object.keys(options);
for (let index = 0; index < optionsKeys.length; index++) {
const option = optionsKeys[index];
if (typeof (options[option]) === 'function' && (/^on[A-Z]/).test(option)) {
if (typeof options[option] === 'function' && /^on[A-Z]/.test(option)) {
this.addEvent(option, options[option]);
delete options[option];
}

View File

@ -44,12 +44,17 @@ const TopicFeatureFactory = {
$assert(topic, 'topic can not be null');
$assert(model, 'model can not be null');
const { icon: Icon } = TopicFeatureFactory._featuresMetadataById
.filter((elem) => elem.id === model.getType())[0];
const { icon: Icon } = TopicFeatureFactory._featuresMetadataById.filter(
(elem) => elem.id === model.getType(),
)[0];
return new Icon(topic, model, readOnly);
},
};
TopicFeatureFactory._featuresMetadataById = [TopicFeatureFactory.Icon, TopicFeatureFactory.Link, TopicFeatureFactory.Note];
TopicFeatureFactory._featuresMetadataById = [
TopicFeatureFactory.Icon,
TopicFeatureFactory.Link,
TopicFeatureFactory.Note,
];
export default TopicFeatureFactory;

View File

@ -15,16 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
$assert,
$defined,
} from '@wisemapping/core-js';
import {
$msg,
} from './Messages';
import {
TopicShape,
} from './model/INodeModel';
import { $assert, $defined } from '@wisemapping/core-js';
import { $msg } from './Messages';
import { TopicShape } from './model/INodeModel';
class TopicStyle {
static _getStyles(topic) {
@ -49,9 +42,7 @@ class TopicStyle {
}
static defaultText(topic) {
const {
msgKey,
} = this._getStyles(topic);
const { msgKey } = this._getStyles(topic);
return $msg(msgKey);
}

View File

@ -59,7 +59,9 @@ class ChangeEvent {
/** @return {String} order and position */
toString() {
return `[order:${this.getOrder()}, position: {${this.getPosition().x},${this.getPosition().y}}]`;
return `[order:${this.getOrder()}, position: {${this.getPosition().x},${
this.getPosition().y
}}]`;
}
}

View File

@ -42,12 +42,12 @@ class GridSorter extends AbstractBasicSorter {
for (let i = 0; i < heights.length; i++) {
const even = i % 2 === 0 ? 1 : -1;
const zeroHeight = i === 0 ? 0 : ((heights[0].height / 2) * even);
const zeroHeight = i === 0 ? 0 : (heights[0].height / 2) * even;
let middleHeight = 0;
for (let j = i - 2; j > 0; j -= 2) {
middleHeight += heights[j].height * even;
}
const finalHeight = i === 0 ? 0 : ((heights[i].height / 2) * even);
const finalHeight = i === 0 ? 0 : (heights[i].height / 2) * even;
const yOffset = zeroHeight + middleHeight + finalHeight;
const xOffset = node.getSize().width + GridSorter.GRID_HORIZONTAR_SIZE;

View File

@ -35,29 +35,22 @@ 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(
rootNode.getPosition(),
parent.getPosition(),
);
const limitXPos = parent.getPosition().x
+ direction
* (parent.getSize().width / 2
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
const direction = this._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
const limitXPos =
parent.getPosition().x +
direction *
(parent.getSize().width / 2 +
node.getSize().width / 2 +
SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
let xPos;
if (direction > 0) {
xPos = position.x >= limitXPos
? position.x
: limitXPos;
xPos = position.x >= limitXPos ? position.x : limitXPos;
} else {
xPos = position.x <= limitXPos
? position.x
: limitXPos;
xPos = position.x <= limitXPos ? position.x : limitXPos;
}
return [0, { x: xPos, y: position.y }];
}
@ -71,9 +64,8 @@ class SymmetricSorter extends AbstractBasicSorter {
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, result];
@ -81,10 +73,7 @@ class SymmetricSorter extends AbstractBasicSorter {
// If it is a dragged node...
$assert($defined(position), 'position cannot be null for predict in dragging');
const nodeDirection = this._getRelativeDirection(
rootNode.getPosition(),
node.getPosition(),
);
const nodeDirection = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
const positionDirection = this._getRelativeDirection(rootNode.getPosition(), position);
const siblings = graph.getSiblings(node);
@ -98,9 +87,10 @@ class SymmetricSorter extends AbstractBasicSorter {
if (parentChildren.length === 0) {
// Fit as a child of the parent node...
const result = {
x: parent.getPosition().x
+ positionDirection
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
x:
parent.getPosition().x +
positionDirection *
(parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y,
};
@ -115,41 +105,38 @@ class SymmetricSorter extends AbstractBasicSorter {
// Fit at the bottom
if (!nodeAfter && position.y > parentChild.getPosition().y) {
const 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;
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, result];
}
// 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()
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()];
}
const orderResult = position.y > node.getPosition().y
? nodeAfter.getOrder() - 1
: parentChild.getOrder() + 1;
const orderResult =
position.y > node.getPosition().y ? nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1;
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 [orderResult, positionResult];
@ -161,9 +148,9 @@ class SymmetricSorter extends AbstractBasicSorter {
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, resultPosition];
}
@ -227,13 +214,14 @@ class SymmetricSorter extends AbstractBasicSorter {
// Compute heights ...
const heights = children
.map(((child) => ({
.map((child) => ({
id: child.getId(),
order: child.getOrder(),
position: child.getPosition(),
width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child),
}))).reverse();
}))
.reverse();
// Compute the center of the branch ...
let totalHeight = 0;
@ -250,10 +238,11 @@ class SymmetricSorter extends AbstractBasicSorter {
const direction = this.getChildDirection(treeSet, childNode);
const yOffset = ysum + heights[i].height / 2;
const xOffset = direction
* (heights[i].width / 2
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
const xOffset =
direction *
(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');

View File

@ -106,10 +106,7 @@ const Shape = {
const x2 = tarPos.x + Math.sqrt((l * l) / (1 + m * m)) * fix * -1;
const y2 = m * (x2 - tarPos.x) + tarPos.y;
return [
new Point(-srcPos.x + x1, -srcPos.y + y1),
new Point(-tarPos.x + x2, -tarPos.y + y2),
];
return [new Point(-srcPos.x + x1, -srcPos.y + y1), new Point(-tarPos.x + x2, -tarPos.y + y2)];
},
workoutIncomingConnectionPoint(targetNode, sourcePosition) {

View File

@ -215,8 +215,8 @@ class BalancedTestSuite extends TestSuite {
const prediction1a = manager.predict(0, null, { x: 165, y: -70 });
this._plotPrediction(graph1, prediction1a);
$assert(
prediction1a.position.y < manager.find(1).getPosition().y
&& prediction1a.position.x == manager.find(1).getPosition().x,
prediction1a.position.y < manager.find(1).getPosition().y &&
prediction1a.position.x == manager.find(1).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction1a.order == 0, 'Prediction order should be 0');
@ -225,9 +225,9 @@ class BalancedTestSuite extends TestSuite {
const prediction1b = manager.predict(0, null, { x: 165, y: -10 });
this._plotPrediction(graph1, prediction1b);
$assert(
prediction1b.position.y > manager.find(1).getPosition().y
&& prediction1b.position.y < manager.find(3).getPosition().y
&& prediction1b.position.x == manager.find(1).getPosition().x,
prediction1b.position.y > manager.find(1).getPosition().y &&
prediction1b.position.y < manager.find(3).getPosition().y &&
prediction1b.position.x == manager.find(1).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction1b.order == 2, 'Prediction order should be 2');
@ -236,9 +236,9 @@ class BalancedTestSuite extends TestSuite {
const prediction1c = manager.predict(0, null, { x: 145, y: 15 });
this._plotPrediction(graph1, prediction1c);
$assert(
prediction1c.position.y > manager.find(3).getPosition().y
&& prediction1c.position.y < manager.find(5).getPosition().y
&& prediction1c.position.x == manager.find(3).getPosition().x,
prediction1c.position.y > manager.find(3).getPosition().y &&
prediction1c.position.y < manager.find(5).getPosition().y &&
prediction1c.position.x == manager.find(3).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction1c.order == 4, 'Prediction order should be 4');
@ -247,8 +247,8 @@ class BalancedTestSuite extends TestSuite {
const prediction1d = manager.predict(0, null, { x: 145, y: 70 });
this._plotPrediction(graph1, prediction1d);
$assert(
prediction1d.position.y > manager.find(5).getPosition().y
&& prediction1d.position.x == manager.find(5).getPosition().x,
prediction1d.position.y > manager.find(5).getPosition().y &&
prediction1d.position.x == manager.find(5).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction1d.order == 6, 'Prediction order should be 6');
@ -260,8 +260,8 @@ class BalancedTestSuite extends TestSuite {
const prediction2a = manager.predict(0, null, { x: -145, y: -50 });
this._plotPrediction(graph2, prediction2a);
$assert(
prediction2a.position.y < manager.find(2).getPosition().y
&& prediction2a.position.x == manager.find(2).getPosition().x,
prediction2a.position.y < manager.find(2).getPosition().y &&
prediction2a.position.x == manager.find(2).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2a.order == 1, 'Prediction order should be 1');
@ -270,9 +270,9 @@ class BalancedTestSuite extends TestSuite {
const prediction2b = manager.predict(0, null, { x: -145, y: -10 });
this._plotPrediction(graph2, prediction2b);
$assert(
prediction2b.position.y > manager.find(2).getPosition().y
&& prediction2b.position.y < manager.find(4).getPosition().y
&& prediction2b.position.x == manager.find(2).getPosition().x,
prediction2b.position.y > manager.find(2).getPosition().y &&
prediction2b.position.y < manager.find(4).getPosition().y &&
prediction2b.position.x == manager.find(2).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2b.order == 3, 'Prediction order should be 3');
@ -281,8 +281,8 @@ class BalancedTestSuite extends TestSuite {
const prediction2c = manager.predict(0, null, { x: -145, y: 400 });
this._plotPrediction(graph2, prediction2c);
$assert(
prediction2c.position.y > manager.find(4).getPosition().y
&& prediction2c.position.x == manager.find(4).getPosition().x,
prediction2c.position.y > manager.find(4).getPosition().y &&
prediction2c.position.x == manager.find(4).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2c.order == 5, 'Prediction order should be 5');
@ -293,8 +293,8 @@ class BalancedTestSuite extends TestSuite {
const prediction3 = manager.predict(0, null, null);
this._plotPrediction(graph3, prediction3);
$assert(
prediction3.position.y > manager.find(4).getPosition().y
&& prediction3.position.x == manager.find(4).getPosition().x,
prediction3.position.y > manager.find(4).getPosition().y &&
prediction3.position.x == manager.find(4).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction3.order == 5, 'Prediction order should be 5');
@ -307,15 +307,14 @@ class BalancedTestSuite extends TestSuite {
const prediction4 = manager.predict(0, null, null);
this._plotPrediction(graph4, prediction4);
$assert(
prediction4.position.y > manager.find(5).getPosition().y
&& prediction4.position.x == manager.find(5).getPosition().x,
prediction4.position.y > manager.find(5).getPosition().y &&
prediction4.position.x == manager.find(5).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction4.order == 6, 'Prediction order should be 6');
console.log('\tPredict nodes added only a root node:');
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4)
.removeNode(5);
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
manager.layout();
const graph5 = manager.plot('testBalancedPredict5', { width: 1000, height: 400 });
const prediction5a = manager.predict(0, null, null);
@ -323,14 +322,14 @@ class BalancedTestSuite extends TestSuite {
this._plotPrediction(graph5, prediction5a);
this._plotPrediction(graph5, prediction5b);
$assert(
prediction5a.position.x > manager.find(0).getPosition().x
&& prediction5a.position.y == manager.find(0).getPosition().y,
prediction5a.position.x > manager.find(0).getPosition().x &&
prediction5a.position.y == manager.find(0).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction5a.order == 0, 'Prediction order should be 0');
$assert(
prediction5a.position.x == prediction5b.position.x
&& prediction5a.position.y == prediction5b.position.y,
prediction5a.position.x == prediction5b.position.x &&
prediction5a.position.y == prediction5b.position.y,
'Both predictions should be the same',
);
$assert(prediction5a.order == prediction5b.order, 'Both predictions should be the same');
@ -351,8 +350,8 @@ class BalancedTestSuite extends TestSuite {
const prediction1a = manager.predict(0, 1, { x: 50, y: 50 });
this._plotPrediction(graph1, prediction1a);
$assert(
prediction1a.position.x == manager.find(1).getPosition().x
&& prediction1a.position.y == manager.find(1).getPosition().y,
prediction1a.position.x == manager.find(1).getPosition().x &&
prediction1a.position.y == manager.find(1).getPosition().y,
'Prediction position should be the same as node 1',
);
$assert(
@ -363,8 +362,8 @@ class BalancedTestSuite extends TestSuite {
const prediction1b = manager.predict(0, 1, { x: 50, y: -50 });
this._plotPrediction(graph1, prediction1b);
$assert(
prediction1b.position.x == manager.find(1).getPosition().x
&& prediction1b.position.y == manager.find(1).getPosition().y,
prediction1b.position.x == manager.find(1).getPosition().x &&
prediction1b.position.y == manager.find(1).getPosition().y,
'Prediction position should be the same as node 1',
);
$assert(
@ -375,8 +374,8 @@ class BalancedTestSuite extends TestSuite {
const prediction1c = manager.predict(0, 1, { x: -50, y: 50 });
this._plotPrediction(graph1, prediction1c);
$assert(
prediction1c.position.x < manager.find(0).getPosition().x
&& prediction1c.position.y == manager.find(0).getPosition().y,
prediction1c.position.x < manager.find(0).getPosition().x &&
prediction1c.position.y == manager.find(0).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction1c.order == 1, 'Prediction order should be the same as node 1');
@ -384,8 +383,8 @@ class BalancedTestSuite extends TestSuite {
const prediction1d = manager.predict(0, 1, { x: -50, y: -50 });
this._plotPrediction(graph1, prediction1d);
$assert(
prediction1d.position.x < manager.find(0).getPosition().x
&& prediction1d.position.y == manager.find(0).getPosition().y,
prediction1d.position.x < manager.find(0).getPosition().x &&
prediction1d.position.y == manager.find(0).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction1d.order == 1, 'Prediction order should be the same as node 1');
@ -399,8 +398,8 @@ class BalancedTestSuite extends TestSuite {
const prediction2a = manager.predict(0, 1, { x: 50, y: 50 });
this._plotPrediction(graph2, prediction2a);
$assert(
prediction2a.position.x > manager.find(0).getPosition().x
&& prediction2a.position.y == manager.find(0).getPosition().y,
prediction2a.position.x > manager.find(0).getPosition().x &&
prediction2a.position.y == manager.find(0).getPosition().y,
'Prediction is positioned incorrectly',
);
$assert(prediction2a.order == 0, 'Prediction order should be 0');
@ -408,8 +407,8 @@ class BalancedTestSuite extends TestSuite {
const prediction2b = manager.predict(0, 1, { x: 50, y: -50 });
this._plotPrediction(graph2, prediction2b);
$assert(
prediction2b.position.x > manager.find(0).getPosition().x
&& prediction2b.position.y == manager.find(0).getPosition().y,
prediction2b.position.x > manager.find(0).getPosition().x &&
prediction2b.position.y == manager.find(0).getPosition().y,
'Prediction is positioned incorrectly',
);
$assert(prediction2b.order == 0, 'Prediction order should be 0');
@ -417,8 +416,8 @@ class BalancedTestSuite extends TestSuite {
const prediction2c = manager.predict(0, 1, { x: -50, y: 50 });
this._plotPrediction(graph2, prediction2c);
$assert(
prediction2c.position.x == manager.find(1).getPosition().x
&& prediction2c.position.y == manager.find(1).getPosition().y,
prediction2c.position.x == manager.find(1).getPosition().x &&
prediction2c.position.y == manager.find(1).getPosition().y,
'Prediction position should be the same as node 1',
);
$assert(
@ -429,8 +428,8 @@ class BalancedTestSuite extends TestSuite {
const prediction2d = manager.predict(0, 1, { x: -50, y: -50 });
this._plotPrediction(graph2, prediction2d);
$assert(
prediction2d.position.x == manager.find(1).getPosition().x
&& prediction2d.position.y == manager.find(1).getPosition().y,
prediction2d.position.x == manager.find(1).getPosition().x &&
prediction2d.position.y == manager.find(1).getPosition().y,
'Prediction position should be the same as node 1',
);
$assert(
@ -448,8 +447,8 @@ class BalancedTestSuite extends TestSuite {
const prediction3a = manager.predict(0, 1, { x: 50, y: 50 });
this._plotPrediction(graph3, prediction3a);
$assert(
prediction3a.position.x == manager.find(2).getPosition().x
&& prediction3a.position.y > manager.find(2).getPosition().y,
prediction3a.position.x == manager.find(2).getPosition().x &&
prediction3a.position.y > manager.find(2).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction3a.order == 4, 'Prediction order should be 4');
@ -457,17 +456,17 @@ class BalancedTestSuite extends TestSuite {
const prediction3b = manager.predict(0, 1, { x: 50, y: -50 });
this._plotPrediction(graph3, prediction3b);
$assert(
prediction3b.position.x == manager.find(1).getPosition().x
&& prediction3b.position.y == manager.find(1).getPosition().y
&& prediction3b.order == manager.find(1).getOrder(),
prediction3b.position.x == manager.find(1).getPosition().x &&
prediction3b.position.y == manager.find(1).getPosition().y &&
prediction3b.order == manager.find(1).getOrder(),
'Prediction should be the exact same as dragged node',
);
const prediction3c = manager.predict(0, 1, { x: -50, y: 50 });
this._plotPrediction(graph3, prediction3c);
$assert(
prediction3c.position.x < manager.find(0).getPosition().x
&& prediction3c.position.y == manager.find(0).getPosition().y,
prediction3c.position.x < manager.find(0).getPosition().x &&
prediction3c.position.y == manager.find(0).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction3c.order == 1, 'Prediction order should be 1');
@ -475,8 +474,8 @@ class BalancedTestSuite extends TestSuite {
const prediction3d = manager.predict(0, 1, { x: -50, y: -50 });
this._plotPrediction(graph3, prediction3d);
$assert(
prediction3d.position.x < manager.find(0).getPosition().x
&& prediction3d.position.y == manager.find(0).getPosition().y,
prediction3d.position.x < manager.find(0).getPosition().x &&
prediction3d.position.y == manager.find(0).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction3d.order == 1, 'Prediction order should be 1');
@ -484,8 +483,8 @@ class BalancedTestSuite extends TestSuite {
const prediction3e = manager.predict(0, 1, { x: 50, y: 0 });
this._plotPrediction(graph3, prediction3e);
$assert(
prediction3e.position.x == manager.find(1).getPosition().x
&& prediction3e.position.y == manager.find(1).getPosition().y,
prediction3e.position.x == manager.find(1).getPosition().x &&
prediction3e.position.y == manager.find(1).getPosition().y,
'Prediction position should be the same as node 1',
);
$assert(

View File

@ -78,18 +78,18 @@ class SymmetricTestSuite extends TestSuite {
'Symmetry is not respected',
);
$assert(
manager.find(11).getPosition().y - manager.find(6).getPosition().y
=== -(manager.find(12).getPosition().y - manager.find(6).getPosition().y),
manager.find(11).getPosition().y - manager.find(6).getPosition().y ===
-(manager.find(12).getPosition().y - manager.find(6).getPosition().y),
'Symmetry is not respected',
);
$assert(
manager.find(8).getPosition().y - manager.find(1).getPosition().y
== -(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
manager.find(8).getPosition().y - manager.find(1).getPosition().y ==
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
'Symmetry is not respected',
);
$assert(
manager.find(9).getPosition().y - manager.find(1).getPosition().y
== -(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
manager.find(9).getPosition().y - manager.find(1).getPosition().y ==
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
'Symmetry is not respected',
);
@ -135,8 +135,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1a = manager.predict(9, null, { x: -280, y: 45 });
this._plotPrediction(graph1, prediction1a);
$assert(
prediction1a.position.x < manager.find(9).getPosition().x
&& prediction1a.position.y == manager.find(9).getPosition().y,
prediction1a.position.x < manager.find(9).getPosition().x &&
prediction1a.position.y == manager.find(9).getPosition().y,
'Prediction incorrectly positioned',
);
$assert(prediction1a.order == 0, 'Prediction order should be 0');
@ -145,8 +145,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1b = manager.predict(1, null, { x: -155, y: -90 });
this._plotPrediction(graph1, prediction1b);
$assert(
prediction1b.position.x > manager.find(1).getPosition().x
&& prediction1b.position.y == manager.find(1).getPosition().y,
prediction1b.position.x > manager.find(1).getPosition().x &&
prediction1b.position.y == manager.find(1).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction1b.order == 0, 'Prediction order should be 0');
@ -160,8 +160,8 @@ class SymmetricTestSuite extends TestSuite {
// Prediction calculator error
$assert(
prediction2d.position.y < manager.find(7).getPosition().y
&& prediction2d.position.x == manager.find(7).getPosition().x,
prediction2d.position.y < manager.find(7).getPosition().y &&
prediction2d.position.x == manager.find(7).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2d.order == 0, 'Prediction order should be 0');
@ -171,9 +171,9 @@ class SymmetricTestSuite extends TestSuite {
this._plotPrediction(graph2, prediction2a);
$assert(
prediction2a.position.y > manager.find(7).getPosition().y
&& prediction2a.position.y < manager.find(8).getPosition().y
&& prediction2a.position.x == manager.find(7).getPosition().x,
prediction2a.position.y > manager.find(7).getPosition().y &&
prediction2a.position.y < manager.find(8).getPosition().y &&
prediction2a.position.x == manager.find(7).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2a.order == 1, 'Prediction order should be 1');
@ -182,9 +182,9 @@ class SymmetricTestSuite extends TestSuite {
const prediction2b = manager.predict(5, null, { x: 375, y: 45 });
this._plotPrediction(graph2, prediction2b);
$assert(
prediction2b.position.y > manager.find(8).getPosition().y
&& prediction2b.position.y < manager.find(11).getPosition().y
&& prediction2b.position.x == manager.find(7).getPosition().x,
prediction2b.position.y > manager.find(8).getPosition().y &&
prediction2b.position.y < manager.find(11).getPosition().y &&
prediction2b.position.x == manager.find(7).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2b.order == 2, 'Prediction order should be 2');
@ -193,8 +193,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction2c = manager.predict(5, null, { x: 375, y: 65 });
this._plotPrediction(graph2, prediction2c);
$assert(
prediction2c.position.y > manager.find(11).getPosition().y
&& prediction2c.position.x == manager.find(11).getPosition().x,
prediction2c.position.y > manager.find(11).getPosition().y &&
prediction2c.position.x == manager.find(11).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction2c.order == 3, 'Prediction order should be 3');
@ -206,9 +206,9 @@ class SymmetricTestSuite extends TestSuite {
const prediction3a = manager.predict(3, null, { x: 280, y: 45 });
this._plotPrediction(graph3, prediction3a);
$assert(
prediction3a.position.y > manager.find(5).getPosition().y
&& prediction3a.position.y < manager.find(6).getPosition().y
&& prediction3a.position.x == manager.find(5).getPosition().x,
prediction3a.position.y > manager.find(5).getPosition().y &&
prediction3a.position.y < manager.find(6).getPosition().y &&
prediction3a.position.x == manager.find(5).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction3a.order == 2, 'Prediction order should be 2');
@ -217,8 +217,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction3b = manager.predict(3, null, { x: 255, y: 110 });
this._plotPrediction(graph3, prediction3b);
$assert(
prediction3b.position.y > manager.find(6).getPosition().y
&& prediction3b.position.x == manager.find(6).getPosition().x,
prediction3b.position.y > manager.find(6).getPosition().y &&
prediction3b.position.x == manager.find(6).getPosition().x,
'Prediction incorrectly positioned',
);
$assert(prediction3b.order == 3, 'Prediction order should be 3');
@ -229,9 +229,9 @@ class SymmetricTestSuite extends TestSuite {
const prediction4 = manager.predict(2, null, { x: -260, y: 0 });
this._plotPrediction(graph4, prediction4);
$assert(
prediction4.position.y > manager.find(9).getPosition().y
&& prediction4.position.y < manager.find(10).getPosition().y
&& prediction4.position.x == manager.find(9).getPosition().x,
prediction4.position.y > manager.find(9).getPosition().y &&
prediction4.position.y < manager.find(10).getPosition().y &&
prediction4.position.x == manager.find(9).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction4.order == 1, 'Prediction order should be 1');
@ -242,8 +242,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction5a = manager.predict(1, null, null);
this._plotPrediction(graph5, prediction5a);
$assert(
prediction5a.position.y == manager.find(1).getPosition().y
&& prediction5a.position.x > manager.find(1).getPosition().x,
prediction5a.position.y == manager.find(1).getPosition().y &&
prediction5a.position.x > manager.find(1).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction5a.order == 0, 'Prediction order should be 0');
@ -251,9 +251,9 @@ class SymmetricTestSuite extends TestSuite {
const prediction5b = manager.predict(2, null, null);
this._plotPrediction(graph5, prediction5b);
$assert(
prediction5b.position.y > manager.find(10).getPosition().y
&& prediction5b.position.x < manager.find(2).getPosition().x
&& prediction5b.position.x == manager.find(10).getPosition().x,
prediction5b.position.y > manager.find(10).getPosition().y &&
prediction5b.position.x < manager.find(2).getPosition().x &&
prediction5b.position.x == manager.find(10).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction5b.order == 2, 'Prediction order should be 2');
@ -261,9 +261,9 @@ class SymmetricTestSuite extends TestSuite {
const prediction5c = manager.predict(3, null, null);
this._plotPrediction(graph5, prediction5c);
$assert(
prediction5c.position.y > manager.find(6).getPosition().y
&& prediction5c.position.x > manager.find(3).getPosition().x
&& prediction5c.position.x == manager.find(6).getPosition().x,
prediction5c.position.y > manager.find(6).getPosition().y &&
prediction5c.position.x > manager.find(3).getPosition().x &&
prediction5c.position.x == manager.find(6).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction5c.order == 3, 'Prediction order should be 3');
@ -271,8 +271,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction5d = manager.predict(10, null, null);
this._plotPrediction(graph5, prediction5d);
$assert(
prediction5d.position.y == manager.find(10).getPosition().y
&& prediction5d.position.x < manager.find(10).getPosition().x,
prediction5d.position.y == manager.find(10).getPosition().y &&
prediction5d.position.x < manager.find(10).getPosition().x,
'Prediction is incorrectly positioned',
);
$assert(prediction5d.order == 0, 'Prediction order should be 0');
@ -295,8 +295,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1a = manager.predict(1, 2, { x: -250, y: -20 });
this._plotPrediction(graph1, prediction1a);
$assert(
prediction1a.position.x == manager.find(2).getPosition().x
&& prediction1a.position.y == manager.find(2).getPosition().y,
prediction1a.position.x == manager.find(2).getPosition().x &&
prediction1a.position.y == manager.find(2).getPosition().y,
'Prediction position should be the same as node 2',
);
$assert(
@ -307,8 +307,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1b = manager.predict(1, 2, { x: -250, y: 20 });
this._plotPrediction(graph1, prediction1b);
$assert(
prediction1b.position.x == manager.find(2).getPosition().x
&& prediction1b.position.y == manager.find(2).getPosition().y,
prediction1b.position.x == manager.find(2).getPosition().x &&
prediction1b.position.y == manager.find(2).getPosition().y,
'Prediction position should be the same as node 2',
);
$assert(
@ -319,8 +319,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1c = manager.predict(0, 2, { x: -100, y: -20 });
this._plotPrediction(graph1, prediction1c);
$assert(
prediction1c.position.x == manager.find(1).getPosition().x
&& prediction1c.position.y < manager.find(1).getPosition().y,
prediction1c.position.x == manager.find(1).getPosition().x &&
prediction1c.position.y < manager.find(1).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction1c.order == 1, 'Prediction order should be 1');
@ -328,8 +328,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1d = manager.predict(0, 2, { x: -100, y: 20 });
this._plotPrediction(graph1, prediction1d);
$assert(
prediction1d.position.x == manager.find(1).getPosition().x
&& prediction1d.position.y > manager.find(1).getPosition().y,
prediction1d.position.x == manager.find(1).getPosition().x &&
prediction1d.position.y > manager.find(1).getPosition().y,
'Prediction is incorrectly positioned',
);
$assert(prediction1d.order == 3, 'Prediction order should be 3');
@ -337,8 +337,8 @@ class SymmetricTestSuite extends TestSuite {
const prediction1e = manager.predict(1, 2, { x: -250, y: 0 });
this._plotPrediction(graph1, prediction1e);
$assert(
prediction1e.position.x == manager.find(2).getPosition().x
&& prediction1e.position.y == manager.find(2).getPosition().y,
prediction1e.position.x == manager.find(2).getPosition().x &&
prediction1e.position.y == manager.find(2).getPosition().y,
'Prediction position should be the same as node 2',
);
$assert(

View File

@ -164,11 +164,9 @@ class TestSuite extends ChildrenSorterStrategy {
let events = [];
manager.addEvent('change', (event) => {
console.log(
`\tUpdated nodes: {id:${event.getId()
} order: ${event.getOrder()
}position: {${event.getPosition().x
}${event.getPosition().y
}}`,
`\tUpdated nodes: {id:${event.getId()} order: ${event.getOrder()}position: {${
event.getPosition().x
}${event.getPosition().y}}`,
);
events.push(event);
});
@ -206,11 +204,9 @@ class TestSuite extends ChildrenSorterStrategy {
let events = [];
manager.addEvent('change', (event) => {
console.log(
`\tUpdated nodes: {id:${event.getId()
} order: ${event.getOrder()
}position: {${event.getPosition().x
}${event.getPosition().y
}}`,
`\tUpdated nodes: {id:${event.getId()} order: ${event.getOrder()}position: {${
event.getPosition().x
}${event.getPosition().y}}`,
);
events.push(event);
});
@ -259,12 +255,7 @@ class TestSuite extends ChildrenSorterStrategy {
const pos = event.getPosition();
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
}}`,
);
console.log(`\tUpdated nodes: {id:${event.getId()} order: ${event.getOrder()}${posStr}}`);
events.push(event);
});
manager.layout(true);
@ -349,8 +340,8 @@ class TestSuite extends ChildrenSorterStrategy {
'Node 6 and their children should be to the left of node 4',
);
$assert(
manager.find(6).getPosition().x > manager.find(11).getPosition().x
&& manager.find(11).getPosition().x == manager.find(12).getPosition().x,
manager.find(6).getPosition().x > manager.find(11).getPosition().x &&
manager.find(11).getPosition().x == manager.find(12).getPosition().x,
'Nodes 11 and 12 should be to the left of node 6 and horizontally aligned',
);
@ -471,8 +462,8 @@ class TestSuite extends ChildrenSorterStrategy {
// Check that all enlarged nodes shift children accordingly
$assert(
manager.find(10).getPosition().x > manager.find(3).getPosition().x
&& manager.find(10).getPosition().x == manager.find(11).getPosition().x,
manager.find(10).getPosition().x > manager.find(3).getPosition().x &&
manager.find(10).getPosition().x == manager.find(11).getPosition().x,
'Nodes 10 and 11 should be horizontally algined and to the right of enlarged node 3',
);
const xPosNode7 = manager.find(7).getPosition().x;
@ -564,12 +555,7 @@ class TestSuite extends ChildrenSorterStrategy {
}
const { position } = prediction;
const { order } = prediction;
console.log(
`\t\tprediction {order:${order
} position: (${position.x
}${position.y
})}`,
);
console.log(`\t\tprediction {order:${order} position: (${position.x}${position.y})}`);
const cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2;
const cy = position.y + canvas.height / 2 - TestSuite.NODE_SIZE.height / 2;
canvas.rect(cx, cy, TestSuite.NODE_SIZE.width, TestSuite.NODE_SIZE.height);

File diff suppressed because one or more lines are too long

View File

@ -54,6 +54,7 @@ Grid.prototype._createContainer = function () {
result.style.borderCollapse = 'collapse';
result.style.emptyCells = 'show';
result.style.position = 'absolute';
result.innerHTML = '<table style="table-layout:fixed;border-collapse:collapse;empty-cells:show;"><tbody id="tableBody"></tbody></table>';
result.innerHTML =
'<table style="table-layout:fixed;border-collapse:collapse;empty-cells:show;"><tbody id="tableBody"></tbody></table>';
return result;
};

View File

@ -6,7 +6,8 @@ describe('Balanced Test Suite', () => {
const position = { x: 0, y: 0 };
const manager = new LayoutManager(0, Constants.ROOT_NODE_SIZE);
manager.addNode(1, Constants.NODE_SIZE, position);
manager.connectNode(0, 1, 0); manager.layout();
manager.connectNode(0, 1, 0);
manager.layout();
manager.addNode(2, Constants.NODE_SIZE, position);
manager.connectNode(0, 2, 1);
@ -194,8 +195,7 @@ describe('Balanced Test Suite', () => {
});
test('Predict nodes added only a root node', () => {
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4)
.removeNode(5);
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
manager.layout();
const prediction5a = manager.predict(0, null, null);
const prediction5b = manager.predict(0, null, { x: 40, y: 100 });

View File

@ -40,12 +40,15 @@ describe('Symmetric Test Suite', () => {
test('All nodes should be positioned symmetrically with respect to their common ancestors', () => {
expect(manager.find(14).getPosition().y).toEqual(manager.find(13).getPosition().y);
expect(manager.find(5).getPosition().y).toEqual(manager.find(10).getPosition().y);
expect(manager.find(11).getPosition().y - manager.find(6).getPosition().y)
.toEqual(-(manager.find(12).getPosition().y - manager.find(6).getPosition().y));
expect(manager.find(8).getPosition().y - manager.find(1).getPosition().y)
.toEqual(-(manager.find(11).getPosition().y - manager.find(1).getPosition().y));
expect(manager.find(9).getPosition().y - manager.find(1).getPosition().y)
.toEqual(-(manager.find(11).getPosition().y - manager.find(1).getPosition().y));
expect(manager.find(11).getPosition().y - manager.find(6).getPosition().y).toEqual(
-(manager.find(12).getPosition().y - manager.find(6).getPosition().y),
);
expect(manager.find(8).getPosition().y - manager.find(1).getPosition().y).toEqual(
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
);
expect(manager.find(9).getPosition().y - manager.find(1).getPosition().y).toEqual(
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
);
});
});

View File

@ -1,19 +1,19 @@
/*
* Copyright [2021] [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.
* Copyright [2021] [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.
*/
import FontPeer from './peer/svg/FontPeer';
import WorkspacePeer from './peer/svg/WorkspacePeer';

View File

@ -83,10 +83,7 @@ class ElementPeer {
children = children.filter((c) => c !== elementPeer);
this.setChildren(children);
$assert(
children.length < oldLength,
`element could not be removed:${elementPeer}`,
);
$assert(children.length < oldLength, `element could not be removed:${elementPeer}`);
// Append element as a child.
this._native.removeChild(elementPeer._native);

View File

@ -43,8 +43,8 @@ class ElipsePeer extends ElementPeer {
setPosition(pcx, pcy) {
const size = this.getSize();
const cx = (size.width / 2) + pcx;
const cy = (size.height / 2) + pcy;
const cx = size.width / 2 + pcx;
const cy = size.height / 2 + pcy;
if ($defined(cx)) {
this._native.setAttribute('cx', cx);

View File

@ -67,12 +67,7 @@ class PolyLinePeer extends ElementPeer {
}
_updateStraightPath() {
if (
$defined(this._x1)
&& $defined(this._x2)
&& $defined(this._y1)
&& $defined(this._y2)
) {
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2)) {
const path = PolyLineUtils.buildStraightPath.call(
this,
this.breakDistance,
@ -90,12 +85,7 @@ class PolyLinePeer extends ElementPeer {
const y1 = this._y1;
const x2 = this._x2;
const y2 = this._y2;
if (
$defined(x1)
&& $defined(x2)
&& $defined(y1)
&& $defined(y2)
) {
if ($defined(x1) && $defined(x2) && $defined(y1) && $defined(y2)) {
const diff = x2 - x1;
const middlex = diff / 2 + x1;
let signx = 1;
@ -114,12 +104,7 @@ class PolyLinePeer extends ElementPeer {
}
_updateCurvePath() {
if (
$defined(this._x1)
&& $defined(this._x2)
&& $defined(this._y1)
&& $defined(this._y2)
) {
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2)) {
const path = PolyLineUtils.buildCurvedPath.call(
this,
this.breakDistance,

View File

@ -30,10 +30,9 @@ export const buildCurvedPath = (dist, x1, y1, x2, y2) => {
const middlex = x1 + (x2 - x1 > 0 ? dist : -dist);
path = `${x1.toFixed(1)}, ${y1.toFixed(1)} ${middlex.toFixed(1)}, ${y1.toFixed(
1,
)} ${middlex.toFixed(1)}, ${(y2 - 5 * signy).toFixed(1)} ${(
middlex
+ 5 * signx
).toFixed(1)}, ${y2.toFixed(1)} ${x2.toFixed(1)}, ${y2.toFixed(1)}`;
)} ${middlex.toFixed(1)}, ${(y2 - 5 * signy).toFixed(1)} ${(middlex + 5 * signx).toFixed(
1,
)}, ${y2.toFixed(1)} ${x2.toFixed(1)}, ${y2.toFixed(1)}`;
} else {
path = `${x1.toFixed(1)}, ${y1.toFixed(1)} ${x2.toFixed(1)}, ${y2.toFixed(1)}`;
}

View File

@ -55,9 +55,10 @@ class Grid {
result.style.borderCollapse = 'collapse';
result.style.emptyCells = 'show';
result.style.position = 'absolute';
result.innerHTML = '<table style="table-layout:fixed;border-collapse:collapse;empty-cells:show;"><tbody id="tableBody"></tbody></table>';
result.innerHTML =
'<table style="table-layout:fixed;border-collapse:collapse;empty-cells:show;"><tbody id="tableBody"></tbody></table>';
return result;
}
}
export default Grid ;
export default Grid;

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, Arrow, Point,
} from '../../src';
import { Workspace, Arrow, Point } from '../../src';
const workspace = new Workspace({ fillColor: 'green' });
workspace.setSize('200px', '200px');

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, CurvedLine, Point,
} from '../../src';
import { Workspace, CurvedLine, Point } from '../../src';
const workspace = new Workspace({ fillColor: 'green' });
workspace.setSize('400px', '400px');

View File

@ -1,8 +1,6 @@
/* eslint-disable no-alert */
import $ from 'jquery';
import {
Workspace, Elipse,
} from '../../src';
import { Workspace, Elipse } from '../../src';
global.$ = $;
@ -55,7 +53,6 @@ MultipleEventHandler.prototype.unRegisterOneListener = function unRegisterOneLis
}
};
// Workspace with CoordOrigin(100,100);
const workspace = new Workspace();
workspace.setSize('150px', '150px');

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, Text,
} from '../../src';
import { Workspace, Text } from '../../src';
global.$ = $;
@ -51,5 +49,9 @@ function alignments(text, family, elemId) {
// Multine tests and alingments .. ...
['Arial', 'Tahoma', 'Verdana', 'Times', 'Brush Script MT'].forEach((fontName, i) => {
alignments('This multine text.\nThis is the long line just because :)\nShort line', fontName, `amulti${i}`);
alignments(
'This multine text.\nThis is the long line just because :)\nShort line',
fontName,
`amulti${i}`,
);
});

View File

@ -1,8 +1,6 @@
/* eslint-disable no-alert */
import $ from 'jquery';
import {
Toolkit, Workspace, Line, Group, Elipse,
} from '../../src';
import { Toolkit, Workspace, Line, Group, Elipse } from '../../src';
global.$ = $;
@ -68,7 +66,12 @@ const eventTest = () => {
workspace.setCoordSize(100, 100);
const groupAttributes = {
width: 50, height: 50, x: 25, y: 50, coordSize: '200 200', coordOrigin: '0 0',
width: 50,
height: 50,
x: 25,
y: 50,
coordSize: '200 200',
coordOrigin: '0 0',
};
const group = new Group(groupAttributes);
workspace.append(group);

View File

@ -2,9 +2,7 @@ import $ from 'jquery';
import svgResource from './resources/logo-icon.svg';
import pngResource from './resources/logo-icon.png';
import {
Workspace, Image,
} from '../../src';
import { Workspace, Image } from '../../src';
// URL Based image test ...
const workspace = new Workspace({ fillColor: 'light-gray' });

View File

@ -1,12 +1,13 @@
import $ from 'jquery';
import {
Workspace, Line, Rect,
} from '../../src';
import { Workspace, Line, Rect } from '../../src';
global.$ = $;
const workspaceAttributes = {
width: '700px', height: '100px', coordSize: '350 50', fillColor: '#ffffcc',
width: '700px',
height: '100px',
coordSize: '350 50',
fillColor: '#ffffcc',
};
const strokeWidthWorkspace = new Workspace(workspaceAttributes);
@ -18,8 +19,8 @@ strokeWidthWorkspace.append(rect);
for (let i = 0; i <= 10; i++) {
const line = new Line();
line.setFrom(5 + (i * 25), 5);
line.setTo(5 + (i * 25), 45);
line.setFrom(5 + i * 25, 5);
line.setTo(5 + i * 25, 45);
line.setAttribute('strokeWidth', i + 1);
strokeWidthWorkspace.append(line);
}
@ -30,8 +31,8 @@ strokeWidthWorkspace.addItAsChildTo($('#strokeWidthSample'));
const strokeOpacityWorkspace = new Workspace(workspaceAttributes);
for (let i = 0; i < 10; i++) {
const line = new Line();
line.setFrom(15 + (i * 25), 5);
line.setTo(3 + (i * 25), 45);
line.setFrom(15 + i * 25, 5);
line.setTo(3 + i * 25, 45);
line.setAttribute('strokeWidth', 2);
line.setAttribute('strokeOpacity', 1 / (i + 1));
line.setAttribute('strokeColor', 'red');
@ -43,8 +44,8 @@ const strokeStyleWorkspace = new Workspace(workspaceAttributes);
const styles = ['solid', 'dot', 'dash', 'dashdot', 'longdash'];
for (let i = 0; i < styles.length; i++) {
const line = new Line();
line.setFrom(25 + (i * 30), 5);
line.setTo(13 + (i * 30), 45);
line.setFrom(25 + i * 30, 5);
line.setTo(13 + i * 30, 45);
line.setAttribute('strokeWidth', 2);
line.setAttribute('strokeColor', 'red');
line.setAttribute('strokeStyle', styles[i]);
@ -53,11 +54,20 @@ for (let i = 0; i < styles.length; i++) {
strokeStyleWorkspace.addItAsChildTo($('#strokeStyleSample'));
const strokeArrowWorkspace = new Workspace(workspaceAttributes);
const styles2 = ['none ', 'block ', 'classic', 'diamond ', 'oval', 'open', 'chevron', 'doublechevron'];
const styles2 = [
'none ',
'block ',
'classic',
'diamond ',
'oval',
'open',
'chevron',
'doublechevron',
];
for (let i = 0; i < styles.length; i++) {
const line = new Line();
line.setFrom(25 + (i * 30), 5);
line.setTo(13 + (i * 30), 45);
line.setFrom(25 + i * 30, 5);
line.setTo(13 + i * 30, 45);
line.setAttribute('strokeWidth', 2);
line.setAttribute('strokeColor', 'red');
line.setArrowStyle(styles2[i]);

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, PolyLine,
} from '../../src';
import { Workspace, PolyLine } from '../../src';
global.$ = $;

View File

@ -100,10 +100,8 @@ global.createShape = function createShape() {
posx = e.pageX;
posy = e.pageY;
} else if (event.clientX || event.clientY) {
posx = event.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy = event.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
posx = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
shadowGroup.setPosition(posx - 50, posy - 150);

View File

@ -1,11 +1,8 @@
import $ from 'jquery';
import {
Workspace, Rect,
} from '../../src';
import { Workspace, Rect } from '../../src';
global.$ = $;
const rectExampleTest = () => {
const workspace = new Workspace();
workspace.setSize('100px', '100px');
@ -24,7 +21,7 @@ const roundrectExampleTest = () => {
function builder(container, x, width, height) {
for (let i = 1; i <= 10; i++) {
const rect = new Rect(i / 10);
rect.setPosition(x, ((i - 1) * (50 + 5)));
rect.setPosition(x, (i - 1) * (50 + 5));
rect.setSize(width, height);
container.append(rect);
}

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, Rect,
} from '../../src';
import { Workspace, Rect } from '../../src';
global.$ = $;
@ -96,7 +94,12 @@ const strokeOpacityTest = () => {
workspace.append(rect);
const rectAttributes = {
width: 60, height: 60, fillColor: 'yellow', strokeColor: 'black', strokeStyle: 'solid', strokeWidth: 10,
width: 60,
height: 60,
fillColor: 'yellow',
strokeColor: 'black',
strokeStyle: 'solid',
strokeWidth: 10,
};
rect = new Rect(0, rectAttributes);
rect.setPosition(20, 20);
@ -141,7 +144,12 @@ const fillOpacityTest = () => {
workspace.append(rect);
const rectAttributes = {
width: 60, height: 60, fillColor: 'yellow', strokeColor: 'black', strokeStyle: 'solid', strokeWidth: 10,
width: 60,
height: 60,
fillColor: 'yellow',
strokeColor: 'black',
strokeStyle: 'solid',
strokeWidth: 10,
};
rect = new Rect(0, rectAttributes);
rect.setPosition(20, 20);
@ -186,7 +194,12 @@ const opacityTest = () => {
workspace.append(rect);
const rectAttributes = {
width: 60, height: 60, fillColor: 'yellow', strokeColor: 'black', strokeStyle: 'solid', strokeWidth: 10,
width: 60,
height: 60,
fillColor: 'yellow',
strokeColor: 'black',
strokeStyle: 'solid',
strokeWidth: 10,
};
rect = new Rect(0, rectAttributes);
rect.setPosition(20, 20);
@ -219,7 +232,12 @@ const visibilityTest = () => {
workspace.setCoordOrigin(0, 0);
const rectAttributes = {
width: 60, height: 60, fillColor: 'green', strokeColor: 'black', strokeStyle: 'solid', strokeWidth: 10,
width: 60,
height: 60,
fillColor: 'green',
strokeColor: 'black',
strokeStyle: 'solid',
strokeWidth: 10,
};
const rect = new Rect(0, rectAttributes);
rect.setPosition(120, 20);

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, Text,
} from '../../src';
import { Workspace, Text } from '../../src';
import TransformUtils from '../../src/components/peer/utils/TransformUtils';
const workspaces = [];
@ -14,7 +12,17 @@ global.zoomIn = function zoomIn() {
}
};
const textTestHelper = function textTestHelper(coordSize, textval, font, fontSizeval, style, modifier, fontColor, htmlElemId, iesimo) {
const textTestHelper = function textTestHelper(
coordSize,
textval,
font,
fontSizeval,
style,
modifier,
fontColor,
htmlElemId,
iesimo,
) {
const workspace = new Workspace();
workspace.setSize('300px', '100px');
@ -38,7 +46,10 @@ const textTestHelper = function textTestHelper(coordSize, textval, font, fontSiz
const textHtml = document.createTextNode(textsize);
const fontSize = text.getHtmlFontSize(textsize);
span.append(textHtml);
span.setAttribute('style', `font-weight:${modifier};font-style: ${style}; font-size:${fontSize}pt; font-family: ${font};width:30;height:30;`);
span.setAttribute(
'style',
`font-weight:${modifier};font-style: ${style}; font-size:${fontSize}pt; font-family: ${font};width:30;height:30;`,
);
parent.append(span);
workspaces[iesimo] = workspace;

View File

@ -1,7 +1,5 @@
import $ from 'jquery';
import {
Workspace, Elipse,
} from '../../src';
import { Workspace, Elipse } from '../../src';
import Grid from './Grid';
global.$ = $;
@ -16,7 +14,10 @@ overflowWorkspace.addItAsChildTo($('#overflowExample'));
const workspacePosition = () => {
const elipseAttr = {
width: 100, height: 100, x: 100, y: 100,
width: 100,
height: 100,
x: 100,
y: 100,
};
const divElem = $('#positionExample');

View File

@ -18,9 +18,7 @@ module.exports = {
{
use: ['babel-loader'],
test: /.(js)$/,
exclude: [
/node_modules/,
],
exclude: [/node_modules/],
},
],
},

View File

@ -13,18 +13,16 @@ module.exports = merge(common, {
port: 3000,
hot: true,
historyApiFallback: {
rewrites: [
{ from: /^\/c\//, to: '/index.html' }
]
}
rewrites: [{ from: /^\/c\//, to: '/index.html' }],
},
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'),
templateParameters: {
PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:3000'
PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:3000',
},
base: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:3000'
})
]
base: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'http://localhost:3000',
}),
],
});

View File

@ -13,9 +13,7 @@ module.exports = merge(common, {
new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'),
templateParameters: {
PUBLIC_URL: process.env.PUBLIC_URL
? process.env.PUBLIC_URL
: 'https://www.wisemapping.com',
PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'https://www.wisemapping.com',
},
base: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'https://www.wisemapping.com',
}),