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) * 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 * 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 // http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) { $.fn.emulateTransitionEnd = function (duration) {
let called = false; const let called = false;
$el = this; const $el = this;
$(this).one($.support.transition.end, () => { called = true; }); $(this).one($.support.transition.end, () => {
const callback = function () { if (!called) $($el).trigger($.support.transition.end); }; called = true;
});
const callback = function () {
if (!called) $($el).trigger($.support.transition.end);
};
setTimeout(callback, duration); setTimeout(callback, duration);
return this; return this;
}; };
@ -50,7 +56,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(() => { $(() => {
$.support.transition = transitionEnd(); $.support.transition = transitionEnd();
}); });
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: alert.js v3.1.1 * 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 = $this.hasClass('alert') ? $this : $this.parent();
} }
$parent.trigger(e = $.Event('close.bs.alert')); $parent.trigger((e = $.Event('close.bs.alert')));
if (e.isDefaultPrevented()) return; if (e.isDefaultPrevented()) return;
@ -97,9 +103,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
$.support.transition && $parent.hasClass('fade') $.support.transition && $parent.hasClass('fade')
? $parent ? $parent.one($.support.transition.end, removeElement).emulateTransitionEnd(150)
.one($.support.transition.end, removeElement)
.emulateTransitionEnd(150)
: removeElement(); : 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); $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close);
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: button.js v3.1.1 * 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]); $el[val](data[state] || this.options[state]);
// push to event loop to allow forms to submit // push to event loop to allow forms to submit
setTimeout($.proxy(function () { setTimeout(
$.proxy(function () {
if (state == 'loadingText') { if (state == 'loadingText') {
this.isLoading = true; this.isLoading = true;
$el.addClass(d).attr(d, d); $el.addClass(d).attr(d, d);
@ -177,7 +182,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.isLoading = false; this.isLoading = false;
$el.removeClass(d).removeAttr(d); $el.removeClass(d).removeAttr(d);
} }
}, this), 0); }, this),
0,
);
}; };
Button.prototype.toggle = function () { Button.prototype.toggle = function () {
@ -233,7 +240,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$btn.button('toggle'); $btn.button('toggle');
e.preventDefault(); e.preventDefault();
}); });
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: carousel.js v3.1.1 * 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.options = options;
this.paused = this.sliding = this.interval = this.$active = this.$items = null; 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('mouseenter', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, 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.interval && clearInterval(this.interval);
this.options.interval this.options.interval &&
&& !this.paused !this.paused &&
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval)); (this.interval = setInterval($.proxy(this.next, this), this.options.interval));
return this; return this;
}; };
@ -287,9 +295,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const that = this; const that = this;
const activeIndex = this.getActiveIndex(); 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(); if (activeIndex == pos) return this.pause().cycle();
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])); 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](); $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 }); const e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction });
this.$element.trigger(e); 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'); $next.removeClass([type, direction].join(' ')).addClass('active');
$active.removeClass(['active', direction].join(' ')); $active.removeClass(['active', direction].join(' '));
that.sliding = false; 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); .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000);
} else { } else {
@ -383,7 +396,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return this.each(function () { return this.each(function () {
const $this = $(this); const $this = $(this);
let data = $this.data('bs.carousel'); 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; const action = typeof option === 'string' ? option : options.slide;
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))); 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) { $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
const $this = $(this); let const $this = $(this);
href; let href;
const $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')); // strip for ie7 const $target = $(
$this.attr('data-target') ||
((href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')),
); // strip for ie7
const options = $.extend({}, $target.data(), $this.data()); const options = $.extend({}, $target.data(), $this.data());
let slideIndex = $this.attr('data-slide-to'); let slideIndex = $this.attr('data-slide-to');
if (slideIndex) options.interval = false; if (slideIndex) options.interval = false;
$target.carousel(options); $target.carousel(options);
if (slideIndex = $this.attr('data-slide-to')) { if ((slideIndex = $this.attr('data-slide-to'))) {
$target.data('bs.carousel').to(slideIndex); $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()); $carousel.carousel($carousel.data());
}); });
}); });
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: collapse.js v3.1.1 * 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(); const dimension = this.dimension();
this.$element this.$element.removeClass('collapse').addClass('collapsing')[dimension](0);
.removeClass('collapse')
.addClass('collapsing')
[dimension](0);
this.transitioning = 1; this.transitioning = 1;
const complete = function () { const complete = function () {
this.$element this.$element.removeClass('collapsing').addClass('collapse in')[dimension]('auto');
.removeClass('collapsing')
.addClass('collapse in')
[dimension]('auto');
this.transitioning = 0; this.transitioning = 0;
this.$element.trigger('shown.bs.collapse'); 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(); const dimension = this.dimension();
this.$element this.$element[dimension](this.$element[dimension]())[0].offsetHeight;
[dimension](this.$element[dimension]())
[0].offsetHeight;
this.$element this.$element.addClass('collapsing').removeClass('collapse').removeClass('in');
.addClass('collapsing')
.removeClass('collapse')
.removeClass('in');
this.transitioning = 1; this.transitioning = 1;
const complete = function () { const complete = function () {
this.transitioning = 0; this.transitioning = 0;
this.$element this.$element.trigger('hidden.bs.collapse').removeClass('collapsing').addClass('collapse');
.trigger('hidden.bs.collapse')
.removeClass('collapsing')
.addClass('collapse');
}; };
if (!$.support.transition) return complete.call(this); if (!$.support.transition) return complete.call(this);
this.$element this.$element[dimension](0)
[dimension](0)
.one($.support.transition.end, $.proxy(complete, this)) .one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350); .emulateTransitionEnd(350);
}; };
@ -554,7 +560,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return this.each(function () { return this.each(function () {
const $this = $(this); const $this = $(this);
let data = $this.data('bs.collapse'); 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 && options.toggle && option == 'show') option = !option;
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))); 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) { $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
const $this = $(this); let const $this = $(this);
href; let href;
const target = $this.attr('data-target') const target =
|| e.preventDefault() $this.attr('data-target') ||
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''); // strip for ie7 e.preventDefault() ||
((href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')); // strip for ie7
const $target = $(target); const $target = $(target);
const data = $target.data('bs.collapse'); const data = $target.data('bs.collapse');
const option = data ? 'toggle' : $this.data(); 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); const $parent = parent && $(parent);
if (!data || !data.transitioning) { 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'); $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed');
} }
$target.collapse(option); $target.collapse(option);
}); });
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: dropdown.js v3.1.1 * 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 }; const relatedTarget = { relatedTarget: this };
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)); $parent.trigger((e = $.Event('show.bs.dropdown', relatedTarget)));
if (e.isDefaultPrevented()) return; if (e.isDefaultPrevented()) return;
$parent $parent.toggleClass('open').trigger('shown.bs.dropdown', relatedTarget);
.toggleClass('open')
.trigger('shown.bs.dropdown', relatedTarget);
$this.focus(); $this.focus();
} }
@ -683,7 +697,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $parent = getParent($(this)); const $parent = getParent($(this));
const relatedTarget = { relatedTarget: this }; const relatedTarget = { relatedTarget: this };
if (!$parent.hasClass('open')) return; 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; if (e.isDefaultPrevented()) return;
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget); $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget);
}); });
@ -732,10 +746,16 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(document) $(document)
.on('click.bs.dropdown.data-api', clearMenus) .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('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', `${toggle}, [role=menu], [role=listbox]`, Dropdown.prototype.keydown); .on(
}(jQuery)); 'keydown.bs.dropdown.data-api',
`${toggle}, [role=menu], [role=listbox]`,
Dropdown.prototype.keydown,
);
})(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: modal.js v3.1.1 * 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; this.$backdrop = this.isShown = null;
if (this.options.remote) { if (this.options.remote) {
this.$element this.$element.find('.modal-content').load(
.find('.modal-content') this.options.remote,
.load(this.options.remote, $.proxy(function () { $.proxy(function () {
this.$element.trigger('loaded.bs.modal'); 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.appendTo(document.body); // don't move modals dom position
} }
that.$element that.$element.show().scrollTop(0);
.show()
.scrollTop(0);
if (transition) { if (transition) {
that.$element[0].offsetWidth; // force reflow that.$element[0].offsetWidth; // force reflow
} }
that.$element that.$element.addClass('in').attr('aria-hidden', false);
.addClass('in')
.attr('aria-hidden', false);
that.enforceFocus(); that.enforceFocus();
const e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }); const e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget });
transition 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, () => { .one($.support.transition.end, () => {
that.$element.focus().trigger(e); 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'); $(document).off('focusin.bs.modal');
this.$element this.$element.removeClass('in').attr('aria-hidden', true).off('click.dismiss.bs.modal');
.removeClass('in')
.attr('aria-hidden', true)
.off('click.dismiss.bs.modal');
$.support.transition && this.$element.hasClass('fade') $.support.transition && this.$element.hasClass('fade')
? this.$element ? this.$element
@ -850,18 +865,24 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Modal.prototype.enforceFocus = function () { Modal.prototype.enforceFocus = function () {
$(document) $(document)
.off('focusin.bs.modal') // guard against infinite focus loop .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) { if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.focus(); this.$element.focus();
} }
}, this)); }, this),
);
}; };
Modal.prototype.escape = function () { Modal.prototype.escape = function () {
if (this.isShown && this.options.keyboard) { 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(); e.which == 27 && this.hide();
}, this)); }, this),
);
} else if (!this.isShown) { } else if (!this.isShown) {
this.$element.off('keyup.dismiss.bs.modal'); 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) { if (this.isShown && this.options.backdrop) {
const doAnimate = $.support.transition && animate; const doAnimate = $.support.transition && animate;
this.$backdrop = $(`<div class="modal-backdrop ${animate}" />`) this.$backdrop = $(`<div class="modal-backdrop ${animate}" />`).appendTo(document.body);
.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; if (e.target !== e.currentTarget) return;
this.options.backdrop == 'static' this.options.backdrop == 'static'
? this.$element[0].focus.call(this.$element[0]) ? this.$element[0].focus.call(this.$element[0])
: this.hide.call(this); : this.hide.call(this);
}, this)); }, this),
);
if (doAnimate) this.$backdrop[0].offsetWidth; // force reflow 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; if (!callback) return;
doAnimate doAnimate
? this.$backdrop ? this.$backdrop.one($.support.transition.end, callback).emulateTransitionEnd(150)
.one($.support.transition.end, callback)
.emulateTransitionEnd(150)
: callback(); : callback();
} else if (!this.isShown && this.$backdrop) { } else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in'); this.$backdrop.removeClass('in');
$.support.transition && this.$element.hasClass('fade') $.support.transition && this.$element.hasClass('fade')
? this.$backdrop ? this.$backdrop.one($.support.transition.end, callback).emulateTransitionEnd(150)
.one($.support.transition.end, callback)
.emulateTransitionEnd(150)
: callback(); : callback();
} else if (callback) { } else if (callback) {
callback(); callback();
@ -930,7 +949,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
return this.each(function () { return this.each(function () {
const $this = $(this); const $this = $(this);
let data = $this.data('bs.modal'); 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 (!data) $this.data('bs.modal', (data = new Modal(this, options)));
if (typeof option === 'string') data[option](_relatedTarget); 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 $this = $(this);
const href = $this.attr('href'); const href = $this.attr('href');
const $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))); // strip for ie7 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(); if ($this.is('a')) e.preventDefault();
$target $target.modal(option, this).one('hide', () => {
.modal(option, this)
.one('hide', () => {
$this.is(':visible') && $this.focus(); $this.is(':visible') && $this.focus();
}); });
}); });
$(document) $(document)
.on('show.bs.modal', '.modal', () => { $(document.body).addClass('modal-open'); }) .on('show.bs.modal', '.modal', () => {
.on('hidden.bs.modal', '.modal', () => { $(document.body).removeClass('modal-open'); }); $(document.body).addClass('modal-open');
}(jQuery)); })
.on('hidden.bs.modal', '.modal', () => {
$(document.body).removeClass('modal-open');
});
})(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: tooltip.js v3.1.1 * Bootstrap: tooltip.js v3.1.1
@ -994,7 +1022,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
animation: true, animation: true,
placement: 'top', placement: 'top',
selector: false, 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', trigger: 'hover focus',
title: '', title: '',
delay: 0, delay: 0,
@ -1010,7 +1039,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const triggers = this.options.trigger.split(' '); const triggers = this.options.trigger.split(' ');
for (let i = triggers.length; i--;) { for (let i = triggers.length; i--; ) {
const trigger = triggers[i]; const trigger = triggers[i];
if (trigger == 'click') { 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 eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
const eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'; const eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
this.$element.on(`${eventIn}.${this.type}`, this.options.selector, $.proxy(this.enter, this)); this.$element.on(
this.$element.on(`${eventOut}.${this.type}`, this.options.selector, $.proxy(this.leave, this)); `${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 options = {};
const defaults = this.getDefaults(); 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; 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) { Tooltip.prototype.enter = function (obj) {
const self = obj instanceof this.constructor const self =
? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`); obj instanceof this.constructor
? obj
: $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`);
clearTimeout(self.timeout); clearTimeout(self.timeout);
@ -1073,8 +1113,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
}; };
Tooltip.prototype.leave = function (obj) { Tooltip.prototype.leave = function (obj) {
const self = obj instanceof this.constructor const self =
? obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`); obj instanceof this.constructor
? obj
: $(obj.currentTarget)[this.type](this.getDelegateOptions()).data(`bs.${this.type}`);
clearTimeout(self.timeout); 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'); 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.call(this, $tip[0], this.$element[0])
: this.options.placement; : this.options.placement;
@ -1110,12 +1153,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const autoPlace = autoToken.test(placement); const autoPlace = autoToken.test(placement);
if (autoPlace) placement = placement.replace(autoToken, '') || 'top'; if (autoPlace) placement = placement.replace(autoToken, '') || 'top';
$tip $tip.detach().css({ top: 0, left: 0, display: 'block' }).addClass(placement);
.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 pos = this.getPosition();
const actualWidth = $tip[0].offsetWidth; const actualWidth = $tip[0].offsetWidth;
@ -1126,19 +1168,24 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const orgPlacement = placement; const orgPlacement = placement;
const docScroll = document.documentElement.scrollTop || document.body.scrollTop; const docScroll = document.documentElement.scrollTop || document.body.scrollTop;
const parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth(); const parentWidth =
const parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight(); 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; const parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left;
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' placement =
: placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight
: placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' ? 'top'
: placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' : placement == 'top' && pos.top - docScroll - actualHeight < 0
? 'bottom'
: placement == 'right' && pos.right + actualWidth > parentWidth
? 'left'
: placement == 'left' && pos.left - actualWidth < parentLeft
? 'right'
: placement; : placement;
$tip $tip.removeClass(orgPlacement).addClass(placement);
.removeClass(orgPlacement)
.addClass(placement);
} }
const calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight); 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') $.support.transition && this.$tip.hasClass('fade')
? $tip ? $tip.one($.support.transition.end, complete).emulateTransitionEnd(150)
.one($.support.transition.end, complete)
.emulateTransitionEnd(150)
: complete(); : complete();
} }
}; };
@ -1177,14 +1222,21 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// $.fn.offset doesn't round pixel values // $.fn.offset doesn't round pixel values
// so we use setOffset directly with our own function B-0 // so we use setOffset directly with our own function B-0
$.offset.setOffset($tip[0], $.extend({ $.offset.setOffset(
$tip[0],
$.extend(
{
using(props) { using(props) {
$tip.css({ $tip.css({
top: Math.round(props.top), top: Math.round(props.top),
left: Math.round(props.left), left: Math.round(props.left),
}); });
}, },
}, offset), 0); },
offset,
),
0,
);
$tip.addClass('in'); $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) { 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 () { Tooltip.prototype.setContent = function () {
@ -1247,9 +1299,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$tip.removeClass('in'); $tip.removeClass('in');
$.support.transition && this.$tip.hasClass('fade') $.support.transition && this.$tip.hasClass('fade')
? $tip ? $tip.one($.support.transition.end, complete).emulateTransitionEnd(150)
.one($.support.transition.end, complete)
.emulateTransitionEnd(150)
: complete(); : complete();
this.hoverState = null; this.hoverState = null;
@ -1259,7 +1309,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Tooltip.prototype.fixTitle = function () { Tooltip.prototype.fixTitle = function () {
const $e = this.$element; 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', ''); $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 () { Tooltip.prototype.getPosition = function () {
const el = this.$element[0]; const el = this.$element[0];
return $.extend({}, (typeof el.getBoundingClientRect === 'function') ? el.getBoundingClientRect() : { return $.extend(
{},
typeof el.getBoundingClientRect === 'function'
? el.getBoundingClientRect()
: {
width: el.offsetWidth, width: el.offsetWidth,
height: el.offsetHeight, height: el.offsetHeight,
}, this.$element.offset()); },
this.$element.offset(),
);
}; };
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } return placement == 'bottom'
: placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 }
: placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : placement == 'top'
/* placement == 'right' */ : { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }; ? { 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 () { Tooltip.prototype.getTitle = function () {
@ -1288,18 +1350,19 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const $e = this.$element; const $e = this.$element;
const o = this.options; const o = this.options;
title = $e.attr('data-original-title') title =
|| (typeof o.title === 'function' ? o.title.call($e[0]) : o.title); $e.attr('data-original-title') ||
(typeof o.title === 'function' ? o.title.call($e[0]) : o.title);
return title; return title;
}; };
Tooltip.prototype.tip = function () { Tooltip.prototype.tip = function () {
return this.$tip = this.$tip || $(this.options.template); return (this.$tip = this.$tip || $(this.options.template));
}; };
Tooltip.prototype.arrow = function () { 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 () { Tooltip.prototype.validate = function () {
@ -1323,7 +1386,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
}; };
Tooltip.prototype.toggle = function (e) { 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); 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; $.fn.tooltip = old;
return this; return this;
}; };
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: popover.js v3.1.1 * Bootstrap: popover.js v3.1.1
@ -1382,7 +1447,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
placement: 'right', placement: 'right',
trigger: 'click', trigger: 'click',
content: '', 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 // NOTE: POPOVER EXTENDS tooltip.js
@ -1402,9 +1468,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
const content = this.getContent(); const content = this.getContent();
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title); $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title);
$tip.find('.popover-content')[// we use append for html objects to maintain js events $tip
this.options.html ? (typeof content === 'string' ? 'html' : 'append') : 'text' .find('.popover-content') // we use append for html objects to maintain js events
](content); [this.options.html ? (typeof content === 'string' ? 'html' : 'append') : 'text'](content);
$tip.removeClass('fade top bottom left right in'); $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 $e = this.$element;
const o = this.options; const o = this.options;
return $e.attr('data-content') return (
|| (typeof o.content === 'function' $e.attr('data-content') ||
? o.content.call($e[0]) (typeof o.content === 'function' ? o.content.call($e[0]) : o.content)
: o.content); );
}; };
Popover.prototype.arrow = function () { 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 () { Popover.prototype.tip = function () {
@ -1462,7 +1528,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$.fn.popover = old; $.fn.popover = old;
return this; return this;
}; };
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: scrollspy.js v3.1.1 * 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.$body = $('body');
this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process); this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process);
this.options = $.extend({}, ScrollSpy.DEFAULTS, options); this.options = $.extend({}, ScrollSpy.DEFAULTS, options);
this.selector = `${this.options.target this.selector = `${
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 this.options.target ||
|| ''} .nav li > a`; ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) || // strip for ie7
''
} .nav li > a`;
this.offsets = $([]); this.offsets = $([]);
this.targets = $([]); this.targets = $([]);
this.activeTarget = null; 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 = $el.data('target') || $el.attr('href');
const $href = /^#./.test(href) && $(href); const $href = /^#./.test(href) && $(href);
return ($href return (
&& $href.length ($href &&
&& $href.is(':visible') $href.length &&
&& [[$href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null; $href.is(':visible') && [
[
$href[offsetMethod]().top +
(!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()),
href,
],
]) ||
null
);
}) })
.sort((a, b) => a[0] - b[0]) .sort((a, b) => a[0] - b[0])
.each(function () { .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); return activeTarget != (i = targets[0]) && this.activate(i);
} }
for (i = offsets.length; i--;) { for (i = offsets.length; i--; ) {
activeTarget != targets[i] activeTarget != targets[i] &&
&& scrollTop >= offsets[i] scrollTop >= offsets[i] &&
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1]) (!offsets[i + 1] || scrollTop <= offsets[i + 1]) &&
&& this.activate(targets[i]); this.activate(targets[i]);
} }
}; };
ScrollSpy.prototype.activate = function (target) { ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target; this.activeTarget = target;
$(this.selector) $(this.selector).parentsUntil(this.options.target, '.active').removeClass('active');
.parentsUntil(this.options.target, '.active')
.removeClass('active');
const selector = `${this.selector const selector = `${this.selector}[data-target="${target}"],${this.selector}[href="${target}"]`;
}[data-target="${target}"],${
this.selector}[href="${target}"]`;
let active = $(selector) let active = $(selector).parents('li').addClass('active');
.parents('li')
.addClass('active');
if (active.parent('.dropdown-menu').length) { if (active.parent('.dropdown-menu').length) {
active = active active = active.closest('li.dropdown').addClass('active');
.closest('li.dropdown')
.addClass('active');
} }
active.trigger('activate.bs.scrollspy'); active.trigger('activate.bs.scrollspy');
@ -1609,7 +1677,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$spy.scrollspy($spy.data()); $spy.scrollspy($spy.data());
}); });
}); });
}(jQuery)); })(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: tab.js v3.1.1 * 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) { Tab.prototype.activate = function (element, container, callback) {
const $active = container.find('> .active'); const $active = container.find('> .active');
const transition = callback const transition = callback && $.support.transition && $active.hasClass('fade');
&& $.support.transition
&& $active.hasClass('fade');
function next() { function next() {
$active $active.removeClass('active').find('> .dropdown-menu > .active').removeClass('active');
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active');
element.addClass('active'); element.addClass('active');
@ -1687,11 +1750,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
callback && callback(); callback && callback();
} }
transition transition ? $active.one($.support.transition.end, next).emulateTransitionEnd(150) : next();
? $active
.one($.support.transition.end, next)
.emulateTransitionEnd(150)
: next();
$active.removeClass('in'); $active.removeClass('in');
}; };
@ -1724,11 +1783,15 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// TAB DATA-API // 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(); e.preventDefault();
$(this).tab('show'); $(this).tab('show');
}); },
}(jQuery)); );
})(jQuery);
/* ======================================================================== /* ========================================================================
* Bootstrap: affix.js v3.1.1 * 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 offsetTop === 'function') offsetTop = offset.top(this.$element);
if (typeof offsetBottom === 'function') offsetBottom = offset.bottom(this.$element); if (typeof offsetBottom === 'function') offsetBottom = offset.bottom(this.$element);
const affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false const affix =
: offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' this.unpin != null && scrollTop + this.unpin <= position.top
: offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false; ? false
: offsetBottom != null &&
position.top + this.$element.height() >= scrollHeight - offsetBottom
? 'bottom'
: offsetTop != null && scrollTop <= offsetTop
? 'top'
: false;
if (this.affixed === affix) return; if (this.affixed === affix) return;
if (this.unpin) this.$element.css('top', ''); 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); $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: * Original idea by:
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ * Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
*/ */
/* /*
* One small change is: now keys are passed by object { keys: '...' } * 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 * Might be useful, when you want to pass some other data to your handler
*/ */
function initHotKeyPluggin(jQuery){ function initHotKeyPluggin(jQuery) {
jQuery.hotkeys = { jQuery.hotkeys = {
version: "0.8", version: '0.8',
specialKeys: { specialKeys: {
8: "backspace", 9: "tab", 10: "return", 13: "enter", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", 8: 'backspace',
20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", 9: 'tab',
37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", 10: 'return',
96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", 13: 'enter',
104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/", 16: 'shift',
112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", 17: 'ctrl',
120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: ";", 191: "/", 18: 'alt',
220: "\\", 222: "'", 224: "meta" 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: { shiftNums: {
"`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", '`': '~',
"8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<", 1: '!',
".": ">", "/": "?", "\\": "|" 2: '@',
} 3: '#',
4: '$',
5: '%',
6: '^',
7: '&',
8: '*',
9: '(',
0: ')',
'-': '_',
'=': '+',
';': ': ',
"'": '"',
',': '<',
'.': '>',
'/': '?',
'\\': '|',
},
}; };
function keyHandler( handleObj ) { function keyHandler(handleObj) {
if ( typeof handleObj.data === "string" ) { if (typeof handleObj.data === 'string') {
handleObj.data = { keys: handleObj.data }; handleObj.data = { keys: handleObj.data };
} }
// Only care when a possible input has been specified // 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; return;
} }
var origHandler = handleObj.handler, var origHandler = handleObj.handler,
keys = handleObj.data.keys.toLowerCase().split(" "), keys = handleObj.data.keys.toLowerCase().split(' '),
textAcceptingInputTypes = ["text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime", "datetime-local", "search", "color", "tel"]; 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 // 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 ) || if (
jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1 ) ) { this !== event.target &&
(/textarea|select/i.test(event.target.nodeName) ||
jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1)
) {
return; return;
} }
var special = jQuery.hotkeys.specialKeys[ event.keyCode ], var special = jQuery.hotkeys.specialKeys[event.keyCode],
character = String.fromCharCode( event.which ).toLowerCase(), character = String.fromCharCode(event.which).toLowerCase(),
modif = "", possible = {}; modif = '',
possible = {};
// check combinations (alt|ctrl|shift+anything) // check combinations (alt|ctrl|shift+anything)
if ( event.altKey && special !== "alt" ) { if (event.altKey && special !== 'alt') {
modif += "alt+"; modif += 'alt+';
} }
if ( event.ctrlKey && special !== "ctrl" ) { if (event.ctrlKey && special !== 'ctrl') {
modif += "ctrl+"; modif += 'ctrl+';
} }
// TODO: Need to make sure this works consistently across platforms // TODO: Need to make sure this works consistently across platforms
if ( event.metaKey && !event.ctrlKey && special !== "meta" ) { if (event.metaKey && !event.ctrlKey && special !== 'meta') {
modif += "meta+"; modif += 'meta+';
} }
if ( event.shiftKey && special !== "shift" ) { if (event.shiftKey && special !== 'shift') {
modif += "shift+"; modif += 'shift+';
} }
if ( special ) { if (special) {
possible[ modif + special ] = true; possible[modif + special] = true;
} }
if ( character ) { if (character) {
possible[ modif + character ] = true; possible[modif + character] = true;
possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true; possible[modif + jQuery.hotkeys.shiftNums[character]] = true;
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$" // "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
if ( modif === "shift+" ) { if (modif === 'shift+') {
possible[ jQuery.hotkeys.shiftNums[ character ] ] = true; possible[jQuery.hotkeys.shiftNums[character]] = true;
} }
} }
for ( var i = 0, l = keys.length; i < l; i++ ) { for (var i = 0, l = keys.length; i < l; i++) {
if ( possible[ keys[i] ] ) { if (possible[keys[i]]) {
return origHandler.apply( this, arguments ); return origHandler.apply(this, arguments);
} }
} }
}; };
} }
jQuery.each([ "keydown", "keyup", "keypress" ], function() { jQuery.each(['keydown', 'keyup', 'keypress'], function () {
jQuery.event.special[ this ] = { add: keyHandler }; jQuery.event.special[this] = { add: keyHandler };
}); });
}
};
export default initHotKeyPluggin; export default initHotKeyPluggin;

View File

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

View File

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

View File

@ -1,6 +1,17 @@
context('Playground', () => { context('Playground', () => {
it('viewmode page should match its snapshot', () => { 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.visit(`/viewmode.html?id=${mapId}`);
cy.get('#mindplot.ready').should('exist'); cy.get('#mindplot.ready').should('exist');
cy.matchImageSnapshot(`viewmode-${mapId}`); cy.matchImageSnapshot(`viewmode-${mapId}`);
@ -8,9 +19,7 @@ context('Playground', () => {
}); });
it('the playground container.html page should match its snapshot', () => { it('the playground container.html page should match its snapshot', () => {
cy.visit('/container.html'); cy.visit('/container.html');
cy.getIframeBody() cy.getIframeBody().find('#mindplot.ready').should('exist');
.find('#mindplot.ready')
.should('exist');
cy.matchImageSnapshot('container'); cy.matchImageSnapshot('container');
}); });
it('the playground editor.html page should match its snapshot', () => { 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/ // https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/
Cypress.Commands.add('getIframeBody', () => cy Cypress.Commands.add('getIframeBody', () =>
.get('iframe') cy.get('iframe').its('0.contentDocument.body').should('not.be.empty').then(cy.wrap),
.its('0.contentDocument.body').should('not.be.empty') );
.then(cy.wrap));

View File

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

View File

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

View File

@ -96,26 +96,113 @@ export const buildHtml = () => {
const palettes = [ const palettes = [
{ {
id: ':3p', 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', 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', id: '3r',
colors: [ 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)'], '(244, 204, 204)',
['(224, 102, 102)', '(246, 178, 107)', '(255, 217, 102)', '(147, 196, 125)', '(118, 165, 175)', '(111, 168, 220)', '(142, 124, 195)', '(194, 123, 160)'], '(252, 229, 205)',
['(204, 0, 0)', '(230, 145, 56)', '(241, 194, 50)', '(106, 168, 79)', '(69, 129, 142)', '(61, 133, 198)', '(103, 78, 167)', '(166, 77, 121)'], '(255, 242, 204)',
['(153, 0, 0)', '(180, 95, 6)', '(191, 144, 0)', '(56, 118, 29)', '(19, 79, 92)', '(11, 83, 148)', '(53, 28, 117)', '(116, 27, 71)'], '(217, 234, 211)',
['(102, 0, 0)', '(120, 63, 4)', '(127, 96, 0)', '(39, 78, 19)', '(12, 52, 61)', '(7, 55, 99)', '(32, 18, 77)', '(76, 17, 48)'], '(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', 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'; import { buildHtml, css } from './ColorPaletteHtml';
// rgbToHex implementation from https://stackoverflow.com/a/3627747/58128 // 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+)\)$/) .match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)
.slice(1) .slice(1)
.map((n) => parseInt(n, 10).toString(16).padStart(2, '0')) .map((n) => parseInt(n, 10).toString(16).padStart(2, '0'))
@ -71,9 +72,7 @@ class ColorPalettePanel extends ToolbarPaneItem {
const panelElem = this.getPanelElem(); const panelElem = this.getPanelElem();
// Clear selected cell based on the color ... // Clear selected cell based on the color ...
panelElem panelElem.find("td[class='palette-cell palette-cell-selected']").attr('class', 'palette-cell');
.find("td[class='palette-cell palette-cell-selected']")
.attr('class', 'palette-cell');
// Mark the cell as selected ... // Mark the cell as selected ...
const colorCells = panelElem.find('div[class=palette-colorswatch]'); 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 // eslint-disable-next-line class-methods-use-this
buildPanel() { buildPanel() {
const content = $("<div class='toolbarPanel' id='fontFamilyPanel'></div>"); 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() .sort()
.map((f) => `<div model="${f}" class="toolbarPanelLink" style="font-family:${f};">${f}</div>`) .map((f) => `<div model="${f}" class="toolbarPanelLink" style="font-family:${f};">${f}</div>`)
.join('\n'); .join('\n');

View File

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

View File

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

View File

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

View File

@ -36,7 +36,8 @@ class KeyboardShortcutTooltip extends FloatingTip {
html: true, html: true,
placement: 'bottom', placement: 'bottom',
className: 'keyboardShortcutTip', 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.on('click', (e) => {
tipDiv.trigger('mouseleave', e); tipDiv.trigger('mouseleave', e);

View File

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

View File

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

View File

@ -9,12 +9,10 @@ const prodConfig = {
}, },
externals: { externals: {
react: 'react', react: 'react',
"react-dom": 'react-dom', 'react-dom': 'react-dom',
"react-intl": 'react-intl', 'react-intl': 'react-intl',
}, },
plugins: [ plugins: [new CleanWebpackPlugin()],
new CleanWebpackPlugin(),
]
}; };
module.exports = merge(common, prodConfig); 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/ // https://www.cypress.io/blog/2020/02/12/working-with-iframes-in-cypress/
Cypress.Commands.add('getIframeBody', () => cy Cypress.Commands.add('getIframeBody', () =>
.get('iframe') cy.get('iframe').its('0.contentDocument.body').should('not.be.empty').then(cy.wrap),
.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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { import { $assert } from '@wisemapping/core-js';
$assert,
} from '@wisemapping/core-js';
import Icon from './Icon'; import Icon from './Icon';
import ActionDispatcher from './ActionDispatcher'; import ActionDispatcher from './ActionDispatcher';
@ -85,7 +83,7 @@ class ImageIcon extends Icon {
for (let i = 0; i < familyIcons.length && result == null; i++) { for (let i = 0; i < familyIcons.length && result == null; i++) {
if (familyIcons[i] === iconId) { if (familyIcons[i] === iconId) {
// Is last one? // Is last one?
if (i === (familyIcons.length - 1)) { if (i === familyIcons.length - 1) {
[result] = familyIcons; [result] = familyIcons;
} else { } else {
result = familyIcons[i + 1]; result = familyIcons[i + 1];
@ -122,116 +120,219 @@ class ImageIcon extends Icon {
} }
} }
ImageIcon.prototype.ICON_FAMILIES = [{ ImageIcon.prototype.ICON_FAMILIES = [
{
id: 'face', id: 'face',
icons: ['face_plain', 'face_sad', 'face_crying', 'face_smile', 'face_surprise', 'face_wink'], icons: ['face_plain', 'face_sad', 'face_crying', 'face_smile', 'face_surprise', 'face_wink'],
}, },
{ {
id: 'funy', id: 'funy',
icons: ['funy_angel', 'funy_devilish', 'funy_glasses', 'funy_grin', 'funy_kiss', 'funy_monkey'], icons: ['funy_angel', 'funy_devilish', 'funy_glasses', 'funy_grin', 'funy_kiss', 'funy_monkey'],
}, },
{ {
id: 'sport', 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', id: 'bulb',
icons: ['bulb_light_on', 'bulb_light_off'], icons: ['bulb_light_on', 'bulb_light_off'],
}, },
{ {
id: 'thumb', id: 'thumb',
icons: ['thumb_thumb_up', 'thumb_thumb_down'], icons: ['thumb_thumb_up', 'thumb_thumb_down'],
}, },
{ {
id: 'tick', id: 'tick',
icons: ['tick_tick', 'tick_cross'], icons: ['tick_tick', 'tick_cross'],
}, },
{ {
id: 'onoff', 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', 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', id: 'time',
icons: ['time_calendar', 'time_clock', 'time_hourglass'], icons: ['time_calendar', 'time_clock', 'time_hourglass'],
}, },
{ {
id: 'number', 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', id: 'chart',
icons: ['chart_bar', 'chart_line', 'chart_curve', 'chart_pie', 'chart_organisation'], icons: ['chart_bar', 'chart_line', 'chart_curve', 'chart_pie', 'chart_organisation'],
}, },
{ {
id: 'sign', id: 'sign',
icons: ['sign_warning', 'sign_info', 'sign_stop', 'sign_help', 'sign_cancel'], icons: ['sign_warning', 'sign_info', 'sign_stop', 'sign_help', 'sign_cancel'],
}, },
{ {
id: 'hard', 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', 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', 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', id: 'arrow',
icons: ['arrow_up', 'arrow_down', 'arrow_left', 'arrow_right'], icons: ['arrow_up', 'arrow_down', 'arrow_left', 'arrow_right'],
}, },
{ {
id: 'arrowc', 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', id: 'people',
icons: ['people_group', 'people_male1', 'people_male2', 'people_female1', 'people_female2'], icons: ['people_group', 'people_male1', 'people_male2', 'people_female1', 'people_female2'],
}, },
{ {
id: 'mail', id: 'mail',
icons: ['mail_envelop', 'mail_mailbox', 'mail_edit', 'mail_list'], icons: ['mail_envelop', 'mail_mailbox', 'mail_edit', 'mail_list'],
}, },
{ {
id: 'flag', id: 'flag',
icons: ['flag_blue', 'flag_green', 'flag_orange', 'flag_pink', 'flag_purple', 'flag_yellow'], icons: ['flag_blue', 'flag_green', 'flag_orange', 'flag_pink', 'flag_purple', 'flag_yellow'],
}, },
{ {
id: 'social', 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', 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', id: 'appsgoogle',
icons: ['appsgoogle_youtube', 'appsgoogle_gmail', 'appsgoogle_maps'], icons: ['appsgoogle_youtube', 'appsgoogle_gmail', 'appsgoogle_maps'],
}, },
{ {
id: 'tag', id: 'tag',
icons: ['tag_blue', 'tag_green', 'tag_orange', 'tag_red', 'tag_pink', 'tag_yellow'], icons: ['tag_blue', 'tag_green', 'tag_orange', 'tag_red', 'tag_pink', 'tag_yellow'],
}, },
{ {
id: 'object', id: 'object',
icons: ['object_bell', 'object_clanbomber', 'object_key', 'object_pencil', 'object_phone', 'object_magnifier', 'object_clip', icons: [
'object_music', 'object_star', 'object_wizard', 'object_house', 'object_cake', 'object_camera', 'object_palette', 'object_rainbow', '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', 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', id: 'task',
icons: ['task_0', 'task_25', 'task_50', 'task_75', 'task_100'], icons: ['task_0', 'task_25', 'task_50', 'task_75', 'task_100'],
}, },
]; ];
export default ImageIcon; export default ImageIcon;

View File

@ -9,7 +9,7 @@ class Options {
const optionsKeys = Object.keys(options); const optionsKeys = Object.keys(options);
for (let index = 0; index < optionsKeys.length; index++) { for (let index = 0; index < optionsKeys.length; index++) {
const option = optionsKeys[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]); this.addEvent(option, options[option]);
delete options[option]; delete options[option];
} }

View File

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

View File

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

View File

@ -59,7 +59,9 @@ class ChangeEvent {
/** @return {String} order and position */ /** @return {String} order and position */
toString() { 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++) { for (let i = 0; i < heights.length; i++) {
const even = i % 2 === 0 ? 1 : -1; 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; let middleHeight = 0;
for (let j = i - 2; j > 0; j -= 2) { for (let j = i - 2; j > 0; j -= 2) {
middleHeight += heights[j].height * even; 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 yOffset = zeroHeight + middleHeight + finalHeight;
const xOffset = node.getSize().width + GridSorter.GRID_HORIZONTAR_SIZE; 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 its a free node...
if (free) { if (free) {
$assert($defined(position), $assert($defined(position), 'position cannot be null for predict in free positioning');
'position cannot be null for predict in free positioning');
$assert($defined(node), 'node cannot be null for predict in free positioning'); $assert($defined(node), 'node cannot be null for predict in free positioning');
const direction = this._getRelativeDirection( const direction = this._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
rootNode.getPosition(), const limitXPos =
parent.getPosition(), parent.getPosition().x +
); direction *
const limitXPos = parent.getPosition().x (parent.getSize().width / 2 +
+ direction node.getSize().width / 2 +
* (parent.getSize().width / 2 SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
+ node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
let xPos; let xPos;
if (direction > 0) { if (direction > 0) {
xPos = position.x >= limitXPos xPos = position.x >= limitXPos ? position.x : limitXPos;
? position.x
: limitXPos;
} else { } else {
xPos = position.x <= limitXPos xPos = position.x <= limitXPos ? position.x : limitXPos;
? position.x
: limitXPos;
} }
return [0, { x: xPos, y: position.y }]; return [0, { x: xPos, y: position.y }];
} }
@ -71,9 +64,8 @@ class SymmetricSorter extends AbstractBasicSorter {
const result = { const result = {
x: x:
parent.getPosition().x parent.getPosition().x +
+ parentDirection parentDirection * (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y, y: parent.getPosition().y,
}; };
return [graph.getChildren(parent).length, result]; return [graph.getChildren(parent).length, result];
@ -81,10 +73,7 @@ class SymmetricSorter extends AbstractBasicSorter {
// If it is a dragged node... // If it is a dragged node...
$assert($defined(position), 'position cannot be null for predict in dragging'); $assert($defined(position), 'position cannot be null for predict in dragging');
const nodeDirection = this._getRelativeDirection( const nodeDirection = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
rootNode.getPosition(),
node.getPosition(),
);
const positionDirection = this._getRelativeDirection(rootNode.getPosition(), position); const positionDirection = this._getRelativeDirection(rootNode.getPosition(), position);
const siblings = graph.getSiblings(node); const siblings = graph.getSiblings(node);
@ -98,9 +87,10 @@ class SymmetricSorter extends AbstractBasicSorter {
if (parentChildren.length === 0) { if (parentChildren.length === 0) {
// Fit as a child of the parent node... // Fit as a child of the parent node...
const result = { const result = {
x: parent.getPosition().x x:
+ positionDirection parent.getPosition().x +
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING), positionDirection *
(parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y, y: parent.getPosition().y,
}; };
@ -115,41 +105,38 @@ class SymmetricSorter extends AbstractBasicSorter {
// Fit at the bottom // Fit at the bottom
if (!nodeAfter && position.y > parentChild.getPosition().y) { 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()
: last.getOrder() + 1; : last.getOrder() + 1;
const result = { const result = {
x: parentChild.getPosition().x, x: parentChild.getPosition().x,
y: y:
parentChild.getPosition().y parentChild.getPosition().y +
+ parentChild.getSize().height parentChild.getSize().height +
+ SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2, SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
}; };
return [order, result]; return [order, result];
} }
// Fit after this node // Fit after this node
if ( if (
nodeAfter nodeAfter &&
&& position.y > parentChild.getPosition().y position.y > parentChild.getPosition().y &&
&& position.y < nodeAfter.getPosition().y position.y < nodeAfter.getPosition().y
) {
if (
nodeAfter.getId() === node.getId()
|| parentChild.getId() === node.getId()
) { ) {
if (nodeAfter.getId() === node.getId() || parentChild.getId() === node.getId()) {
return [node.getOrder(), node.getPosition()]; return [node.getOrder(), node.getPosition()];
} }
const orderResult = position.y > node.getPosition().y const orderResult =
? nodeAfter.getOrder() - 1 position.y > node.getPosition().y ? nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1;
: parentChild.getOrder() + 1;
const positionResult = { const positionResult = {
x: parentChild.getPosition().x, x: parentChild.getPosition().x,
y: y:
parentChild.getPosition().y parentChild.getPosition().y +
+ (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2, (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2,
}; };
return [orderResult, positionResult]; return [orderResult, positionResult];
@ -161,9 +148,9 @@ class SymmetricSorter extends AbstractBasicSorter {
const resultPosition = { const resultPosition = {
x: first.getPosition().x, x: first.getPosition().x,
y: y:
first.getPosition().y first.getPosition().y -
- first.getSize().height first.getSize().height -
- SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2, SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
}; };
return [0, resultPosition]; return [0, resultPosition];
} }
@ -227,13 +214,14 @@ class SymmetricSorter extends AbstractBasicSorter {
// Compute heights ... // Compute heights ...
const heights = children const heights = children
.map(((child) => ({ .map((child) => ({
id: child.getId(), id: child.getId(),
order: child.getOrder(), order: child.getOrder(),
position: child.getPosition(), position: child.getPosition(),
width: child.getSize().width, width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child), height: this._computeChildrenHeight(treeSet, child),
}))).reverse(); }))
.reverse();
// Compute the center of the branch ... // Compute the center of the branch ...
let totalHeight = 0; let totalHeight = 0;
@ -250,10 +238,11 @@ class SymmetricSorter extends AbstractBasicSorter {
const direction = this.getChildDirection(treeSet, childNode); const direction = this.getChildDirection(treeSet, childNode);
const yOffset = ysum + heights[i].height / 2; const yOffset = ysum + heights[i].height / 2;
const xOffset = direction const xOffset =
* (heights[i].width / 2 direction *
+ node.getSize().width / 2 (heights[i].width / 2 +
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING); node.getSize().width / 2 +
SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!Number.isNaN(xOffset), 'xOffset can not be null'); $assert(!Number.isNaN(xOffset), 'xOffset can not be null');
$assert(!Number.isNaN(yOffset), 'yOffset 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 x2 = tarPos.x + Math.sqrt((l * l) / (1 + m * m)) * fix * -1;
const y2 = m * (x2 - tarPos.x) + tarPos.y; const y2 = m * (x2 - tarPos.x) + tarPos.y;
return [ return [new Point(-srcPos.x + x1, -srcPos.y + y1), new Point(-tarPos.x + x2, -tarPos.y + y2)];
new Point(-srcPos.x + x1, -srcPos.y + y1),
new Point(-tarPos.x + x2, -tarPos.y + y2),
];
}, },
workoutIncomingConnectionPoint(targetNode, sourcePosition) { workoutIncomingConnectionPoint(targetNode, sourcePosition) {

View File

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

View File

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

View File

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

View File

@ -6,7 +6,8 @@ describe('Balanced Test Suite', () => {
const position = { x: 0, y: 0 }; const position = { x: 0, y: 0 };
const manager = new LayoutManager(0, Constants.ROOT_NODE_SIZE); const manager = new LayoutManager(0, Constants.ROOT_NODE_SIZE);
manager.addNode(1, Constants.NODE_SIZE, position); 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.addNode(2, Constants.NODE_SIZE, position);
manager.connectNode(0, 2, 1); manager.connectNode(0, 2, 1);
@ -194,8 +195,7 @@ describe('Balanced Test Suite', () => {
}); });
test('Predict nodes added only a root node', () => { test('Predict nodes added only a root node', () => {
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4) manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
.removeNode(5);
manager.layout(); manager.layout();
const prediction5a = manager.predict(0, null, null); const prediction5a = manager.predict(0, null, null);
const prediction5b = manager.predict(0, null, { x: 40, y: 100 }); 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', () => { 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(14).getPosition().y).toEqual(manager.find(13).getPosition().y);
expect(manager.find(5).getPosition().y).toEqual(manager.find(10).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) expect(manager.find(11).getPosition().y - manager.find(6).getPosition().y).toEqual(
.toEqual(-(manager.find(12).getPosition().y - manager.find(6).getPosition().y)); -(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(8).getPosition().y - manager.find(1).getPosition().y).toEqual(
expect(manager.find(9).getPosition().y - manager.find(1).getPosition().y) -(manager.find(11).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] * Copyright [2021] [wisemapping]
* *
* Licensed under WiseMapping Public License, Version 1.0 (the "License"). * Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the * It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page; * "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the license at * You may obtain a copy of the license at
* *
* http://www.wisemapping.org/license * http://www.wisemapping.org/license
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import FontPeer from './peer/svg/FontPeer'; import FontPeer from './peer/svg/FontPeer';
import WorkspacePeer from './peer/svg/WorkspacePeer'; import WorkspacePeer from './peer/svg/WorkspacePeer';

View File

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

View File

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

View File

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

View File

@ -30,10 +30,9 @@ export const buildCurvedPath = (dist, x1, y1, x2, y2) => {
const middlex = x1 + (x2 - x1 > 0 ? dist : -dist); const middlex = x1 + (x2 - x1 > 0 ? dist : -dist);
path = `${x1.toFixed(1)}, ${y1.toFixed(1)} ${middlex.toFixed(1)}, ${y1.toFixed( path = `${x1.toFixed(1)}, ${y1.toFixed(1)} ${middlex.toFixed(1)}, ${y1.toFixed(
1, 1,
)} ${middlex.toFixed(1)}, ${(y2 - 5 * signy).toFixed(1)} ${( )} ${middlex.toFixed(1)}, ${(y2 - 5 * signy).toFixed(1)} ${(middlex + 5 * signx).toFixed(
middlex 1,
+ 5 * signx )}, ${y2.toFixed(1)} ${x2.toFixed(1)}, ${y2.toFixed(1)}`;
).toFixed(1)}, ${y2.toFixed(1)} ${x2.toFixed(1)}, ${y2.toFixed(1)}`;
} else { } else {
path = `${x1.toFixed(1)}, ${y1.toFixed(1)} ${x2.toFixed(1)}, ${y2.toFixed(1)}`; 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.borderCollapse = 'collapse';
result.style.emptyCells = 'show'; result.style.emptyCells = 'show';
result.style.position = 'absolute'; 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; return result;
} }
} }
export default Grid ; export default Grid;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,5 @@
import $ from 'jquery'; import $ from 'jquery';
import { import { Workspace, Text } from '../../src';
Workspace, Text,
} from '../../src';
global.$ = $; global.$ = $;
@ -51,5 +49,9 @@ function alignments(text, family, elemId) {
// Multine tests and alingments .. ... // Multine tests and alingments .. ...
['Arial', 'Tahoma', 'Verdana', 'Times', 'Brush Script MT'].forEach((fontName, i) => { ['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 */ /* eslint-disable no-alert */
import $ from 'jquery'; import $ from 'jquery';
import { import { Toolkit, Workspace, Line, Group, Elipse } from '../../src';
Toolkit, Workspace, Line, Group, Elipse,
} from '../../src';
global.$ = $; global.$ = $;
@ -68,7 +66,12 @@ const eventTest = () => {
workspace.setCoordSize(100, 100); workspace.setCoordSize(100, 100);
const groupAttributes = { 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); const group = new Group(groupAttributes);
workspace.append(group); workspace.append(group);

View File

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

View File

@ -1,12 +1,13 @@
import $ from 'jquery'; import $ from 'jquery';
import { import { Workspace, Line, Rect } from '../../src';
Workspace, Line, Rect,
} from '../../src';
global.$ = $; global.$ = $;
const workspaceAttributes = { 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); const strokeWidthWorkspace = new Workspace(workspaceAttributes);
@ -18,8 +19,8 @@ strokeWidthWorkspace.append(rect);
for (let i = 0; i <= 10; i++) { for (let i = 0; i <= 10; i++) {
const line = new Line(); const line = new Line();
line.setFrom(5 + (i * 25), 5); line.setFrom(5 + i * 25, 5);
line.setTo(5 + (i * 25), 45); line.setTo(5 + i * 25, 45);
line.setAttribute('strokeWidth', i + 1); line.setAttribute('strokeWidth', i + 1);
strokeWidthWorkspace.append(line); strokeWidthWorkspace.append(line);
} }
@ -30,8 +31,8 @@ strokeWidthWorkspace.addItAsChildTo($('#strokeWidthSample'));
const strokeOpacityWorkspace = new Workspace(workspaceAttributes); const strokeOpacityWorkspace = new Workspace(workspaceAttributes);
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
const line = new Line(); const line = new Line();
line.setFrom(15 + (i * 25), 5); line.setFrom(15 + i * 25, 5);
line.setTo(3 + (i * 25), 45); line.setTo(3 + i * 25, 45);
line.setAttribute('strokeWidth', 2); line.setAttribute('strokeWidth', 2);
line.setAttribute('strokeOpacity', 1 / (i + 1)); line.setAttribute('strokeOpacity', 1 / (i + 1));
line.setAttribute('strokeColor', 'red'); line.setAttribute('strokeColor', 'red');
@ -43,8 +44,8 @@ const strokeStyleWorkspace = new Workspace(workspaceAttributes);
const styles = ['solid', 'dot', 'dash', 'dashdot', 'longdash']; const styles = ['solid', 'dot', 'dash', 'dashdot', 'longdash'];
for (let i = 0; i < styles.length; i++) { for (let i = 0; i < styles.length; i++) {
const line = new Line(); const line = new Line();
line.setFrom(25 + (i * 30), 5); line.setFrom(25 + i * 30, 5);
line.setTo(13 + (i * 30), 45); line.setTo(13 + i * 30, 45);
line.setAttribute('strokeWidth', 2); line.setAttribute('strokeWidth', 2);
line.setAttribute('strokeColor', 'red'); line.setAttribute('strokeColor', 'red');
line.setAttribute('strokeStyle', styles[i]); line.setAttribute('strokeStyle', styles[i]);
@ -53,11 +54,20 @@ for (let i = 0; i < styles.length; i++) {
strokeStyleWorkspace.addItAsChildTo($('#strokeStyleSample')); strokeStyleWorkspace.addItAsChildTo($('#strokeStyleSample'));
const strokeArrowWorkspace = new Workspace(workspaceAttributes); 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++) { for (let i = 0; i < styles.length; i++) {
const line = new Line(); const line = new Line();
line.setFrom(25 + (i * 30), 5); line.setFrom(25 + i * 30, 5);
line.setTo(13 + (i * 30), 45); line.setTo(13 + i * 30, 45);
line.setAttribute('strokeWidth', 2); line.setAttribute('strokeWidth', 2);
line.setAttribute('strokeColor', 'red'); line.setAttribute('strokeColor', 'red');
line.setArrowStyle(styles2[i]); line.setArrowStyle(styles2[i]);

View File

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

View File

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

View File

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

View File

@ -1,7 +1,5 @@
import $ from 'jquery'; import $ from 'jquery';
import { import { Workspace, Rect } from '../../src';
Workspace, Rect,
} from '../../src';
global.$ = $; global.$ = $;
@ -96,7 +94,12 @@ const strokeOpacityTest = () => {
workspace.append(rect); workspace.append(rect);
const rectAttributes = { 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 = new Rect(0, rectAttributes);
rect.setPosition(20, 20); rect.setPosition(20, 20);
@ -141,7 +144,12 @@ const fillOpacityTest = () => {
workspace.append(rect); workspace.append(rect);
const rectAttributes = { 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 = new Rect(0, rectAttributes);
rect.setPosition(20, 20); rect.setPosition(20, 20);
@ -186,7 +194,12 @@ const opacityTest = () => {
workspace.append(rect); workspace.append(rect);
const rectAttributes = { 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 = new Rect(0, rectAttributes);
rect.setPosition(20, 20); rect.setPosition(20, 20);
@ -219,7 +232,12 @@ const visibilityTest = () => {
workspace.setCoordOrigin(0, 0); workspace.setCoordOrigin(0, 0);
const rectAttributes = { 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); const rect = new Rect(0, rectAttributes);
rect.setPosition(120, 20); rect.setPosition(120, 20);

View File

@ -1,7 +1,5 @@
import $ from 'jquery'; import $ from 'jquery';
import { import { Workspace, Text } from '../../src';
Workspace, Text,
} from '../../src';
import TransformUtils from '../../src/components/peer/utils/TransformUtils'; import TransformUtils from '../../src/components/peer/utils/TransformUtils';
const workspaces = []; 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(); const workspace = new Workspace();
workspace.setSize('300px', '100px'); workspace.setSize('300px', '100px');
@ -38,7 +46,10 @@ const textTestHelper = function textTestHelper(coordSize, textval, font, fontSiz
const textHtml = document.createTextNode(textsize); const textHtml = document.createTextNode(textsize);
const fontSize = text.getHtmlFontSize(textsize); const fontSize = text.getHtmlFontSize(textsize);
span.append(textHtml); 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); parent.append(span);
workspaces[iesimo] = workspace; workspaces[iesimo] = workspace;

View File

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

View File

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

View File

@ -13,18 +13,16 @@ module.exports = merge(common, {
port: 3000, port: 3000,
hot: true, hot: true,
historyApiFallback: { historyApiFallback: {
rewrites: [ rewrites: [{ from: /^\/c\//, to: '/index.html' }],
{ from: /^\/c\//, to: '/index.html' } },
]
}
}, },
plugins: [ plugins: [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'), template: path.join(__dirname, 'public/index.html'),
templateParameters: { 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({ new HtmlWebpackPlugin({
template: path.join(__dirname, 'public/index.html'), template: path.join(__dirname, 'public/index.html'),
templateParameters: { templateParameters: {
PUBLIC_URL: process.env.PUBLIC_URL PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'https://www.wisemapping.com',
? process.env.PUBLIC_URL
: 'https://www.wisemapping.com',
}, },
base: 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',
}), }),