mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 15:47:55 +01:00
Keep class migration
This commit is contained in:
parent
a95dc597f9
commit
025e4714e9
@ -1,4 +1,4 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
/* eslint-disable class-methods-use-this */
|
||||
/*
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
@ -19,89 +19,88 @@
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Events from './Events';
|
||||
|
||||
// noinspection JSUnusedLocalSymbols
|
||||
const ActionDispatcher = new Class({
|
||||
Implements: [Events],
|
||||
initialize(commandContext) {
|
||||
class ActionDispatcher extends Events {
|
||||
constructor(commandContext) {
|
||||
$assert(commandContext, 'commandContext can not be null');
|
||||
},
|
||||
super();
|
||||
}
|
||||
|
||||
addRelationship(model, mindmap) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
addTopics(models, parentTopicId) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
deleteEntities(topicsIds, relIds) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
dragTopic(topicId, position, order, parentTopic) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
moveTopic(topicId, position) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
moveControlPoint(ctrlPoint, point) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeFontFamilyToTopic(topicIds, fontFamily) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeFontStyleToTopic(topicsIds) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeFontColorToTopic(topicsIds, color) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeFontSizeToTopic(topicsIds, size) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeBackgroundColorToTopic(topicsIds, color) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeBorderColorToTopic(topicsIds, color) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeShapeTypeToTopic(topicsIds, shapeType) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeFontWeightToTopic(topicsIds) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeTextToTopic(topicsIds, text) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
shrinkBranch(topicsIds, collapse) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
addFeatureToTopic(topicId, type, attributes) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
changeFeatureToTopic(topicId, featureId, attributes) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
}
|
||||
|
||||
removeFeatureFromTopic(topicId, featureId) {
|
||||
throw new Error('method must be implemented.');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ActionDispatcher.setInstance = (dispatcher) => {
|
||||
ActionDispatcher._instance = dispatcher;
|
||||
|
115
packages/mindplot/src/components/CommandContext.js
Normal file
115
packages/mindplot/src/components/CommandContext.js
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from "@wisemapping/core-js";
|
||||
|
||||
class CommandContext {
|
||||
constructor(designer) {
|
||||
$assert(designer, 'designer can not be null');
|
||||
this._designer = designer;
|
||||
}
|
||||
|
||||
/** */
|
||||
findTopics(topicsIds) {
|
||||
$assert($defined(topicsIds), 'topicsIds can not be null');
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicsIds = [topicsIds];
|
||||
}
|
||||
|
||||
const designerTopics = this._designer.getModel().getTopics();
|
||||
const result = designerTopics.filter((topic) => topicsIds.contains(topic.getId()));
|
||||
|
||||
if (result.length !== topicsIds.length) {
|
||||
const ids = designerTopics.map((topic) => topic.getId());
|
||||
$assert(
|
||||
result.length === topicsIds.length,
|
||||
`Could not find topic. Result:${result
|
||||
} Filter Criteria:${topicsIds
|
||||
} Current Topics: [${ids
|
||||
}]`,
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** */
|
||||
deleteTopic(topic) {
|
||||
this._designer.removeTopic(topic);
|
||||
}
|
||||
|
||||
/** */
|
||||
createTopic(model) {
|
||||
$assert(model, 'model can not be null');
|
||||
return this._designer.nodeModelToNodeGraph(model);
|
||||
}
|
||||
|
||||
/** */
|
||||
createModel() {
|
||||
const mindmap = this._designer.getMindmap();
|
||||
return mindmap.createNode(NodeModel.MAIN_TOPIC_TYPE);
|
||||
}
|
||||
|
||||
/** */
|
||||
addTopic(topic) {
|
||||
const mindmap = this._designer.getMindmap();
|
||||
return mindmap.addBranch(topic.getModel());
|
||||
}
|
||||
|
||||
/** */
|
||||
connect(childTopic, parentTopic) {
|
||||
childTopic.connectTo(parentTopic, this._designer._workspace);
|
||||
}
|
||||
|
||||
/** */
|
||||
disconnect(topic) {
|
||||
topic.disconnect(this._designer._workspace);
|
||||
}
|
||||
|
||||
/** */
|
||||
addRelationship(model) {
|
||||
$assert(model, 'model cannot be null');
|
||||
return this._designer.addRelationship(model);
|
||||
}
|
||||
|
||||
/** */
|
||||
deleteRelationship(relationship) {
|
||||
this._designer.deleteRelationship(relationship);
|
||||
}
|
||||
|
||||
/** */
|
||||
findRelationships(relIds) {
|
||||
$assert($defined(relIds), 'relId can not be null');
|
||||
if (!(relIds instanceof Array)) {
|
||||
relIds = [relIds];
|
||||
}
|
||||
|
||||
const designerRel = this._designer.getModel().getRelationships();
|
||||
return designerRel.filter((rel) => relIds.contains(rel.getId()));
|
||||
}
|
||||
|
||||
/** */
|
||||
moveTopic(topic, position) {
|
||||
$assert(topic, 'topic cannot be null');
|
||||
$assert(position, 'position cannot be null');
|
||||
EventBus.instance.fireEvent(EventBus.events.NodeMoveEvent, {
|
||||
node: topic.getModel(),
|
||||
position,
|
||||
});
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export default CommandContext;
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Keyboard from './Keyboard';
|
||||
|
||||
const DesignerKeyboard = new Class({
|
||||
|
@ -15,51 +15,42 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import Events from './Events';
|
||||
|
||||
const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
Implements: [Events],
|
||||
/**
|
||||
* @implements {mindplot.Events}
|
||||
* @constructs
|
||||
* @param {{readOnly: Boolean, zoom: Number, saveOnLoad: Boolean, size: {width: Number,
|
||||
* height: Number}, viewPort: {width: Number, height: Number}, container: String,
|
||||
* persistenceManager: String, mapId: String, locale: String}} options
|
||||
* options loaded from json config
|
||||
* @see {@link ConfigParameters.md}
|
||||
* @see {@link editor.html}
|
||||
*/
|
||||
initialize(options) {
|
||||
class DesignerModel extends Events {
|
||||
constructor(options) {
|
||||
super();
|
||||
this._zoom = options.zoom;
|
||||
this._topics = [];
|
||||
this._relationships = [];
|
||||
},
|
||||
}
|
||||
|
||||
/** @return {Number} zoom between 0.3 (largest text) and 1.9 */
|
||||
getZoom() {
|
||||
return this._zoom;
|
||||
},
|
||||
}
|
||||
|
||||
/** @param {Number} zoom number between 0.3 and 1.9 to set the zoom to */
|
||||
setZoom(zoom) {
|
||||
this._zoom = zoom;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return {@link mindplot.Topic[]} all topics */
|
||||
getTopics() {
|
||||
return this._topics;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return {mindplot.Relationship[]} all relationships */
|
||||
getRelationships() {
|
||||
return this._relationships;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return {mindplot.CentralTopic} the central topic */
|
||||
getCentralTopic() {
|
||||
const topics = this.getTopics();
|
||||
return topics[0];
|
||||
},
|
||||
}
|
||||
|
||||
/** @return {mindplot.Topic[]} selected topics */
|
||||
filterSelectedTopics() {
|
||||
@ -70,7 +61,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {mindplot.Relationship[]} selected relationships
|
||||
@ -83,7 +74,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Array.<mindplot.Relationship, mindplot.Topic>} all topics and relationships
|
||||
@ -92,7 +83,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
const result = [].append(this._topics);
|
||||
result.append(this._relationships);
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* removes occurrences of the given topic from the topic array
|
||||
@ -101,7 +92,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
removeTopic(topic) {
|
||||
$assert(topic, 'topic can not be null');
|
||||
this._topics.erase(topic);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* removes occurrences of the given relationship from the relationship array
|
||||
@ -110,7 +101,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
removeRelationship(rel) {
|
||||
$assert(rel, 'rel can not be null');
|
||||
this._relationships.erase(rel);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* adds the given topic to the topic array
|
||||
@ -122,7 +113,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
$assert(topic, 'topic can not be null');
|
||||
$assert(typeof topic.getId() === 'number', `id is not a number:${topic.getId()}`);
|
||||
this._topics.push(topic);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* adds the given relationship to the relationship array
|
||||
@ -132,7 +123,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
addRelationship(rel) {
|
||||
$assert(rel, 'rel can not be null');
|
||||
this._relationships.push(rel);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function=} validate a function to validate nodes
|
||||
@ -158,7 +149,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {mindplot.Topic} the first selected topic if one or more are found by the
|
||||
@ -167,7 +158,7 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
selectedTopic() {
|
||||
const topics = this.filterSelectedTopics();
|
||||
return (topics.length > 0) ? topics[0] : null;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} id the id of the topic to be retrieved
|
||||
@ -177,13 +168,13 @@ const DesignerModel = new Class(/** @lends DesignerModel */{
|
||||
let result = null;
|
||||
for (let i = 0; i < this._topics.length; i++) {
|
||||
const topic = this._topics[i];
|
||||
if (topic.getId() == id) {
|
||||
if (topic.getId() === id) {
|
||||
result = topic;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default DesignerModel;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
|
||||
const DesignerUndoManager = new Class({
|
||||
initialize(fireChange) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
const DragConnector = new Class({
|
||||
initialize(designerModel, workspace) {
|
||||
$assert(designerModel, 'designerModel can not be null');
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import DragTopic from './DragTopic';
|
||||
|
||||
const DragManager = new Class({
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
import DragTopicConfig from './DragTopicConfig';
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
import ActionDispatcher from './ActionDispatcher';
|
||||
|
@ -1,20 +1,41 @@
|
||||
const Events = new Class({
|
||||
$events: {},
|
||||
/*
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import _ from '@libraries/underscore-min';
|
||||
|
||||
_removeOn(string) {
|
||||
class Events {
|
||||
constructor() {
|
||||
this.$events = {};
|
||||
}
|
||||
|
||||
static _removeOn(string) {
|
||||
return string.replace(/^on([A-Z])/, (full, first) => first.toLowerCase());
|
||||
},
|
||||
}
|
||||
|
||||
addEvent(type, fn, internal) {
|
||||
type = this._removeOn(type);
|
||||
type = Events._removeOn(type);
|
||||
|
||||
this.$events[type] = (this.$events[type] || []).include(fn);
|
||||
if (internal) fn.internal = true;
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
fireEvent(type, args, delay) {
|
||||
type = this._removeOn(type);
|
||||
type = Events._removeOn(type);
|
||||
const events = this.$events[type];
|
||||
if (!events) return this;
|
||||
args = Array.isArray(args) ? args : [args];
|
||||
@ -27,17 +48,17 @@ const Events = new Class({
|
||||
this,
|
||||
);
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
removeEvent(type, fn) {
|
||||
type = this._removeOn(type);
|
||||
type = Events._removeOn(type);
|
||||
const events = this.$events[type];
|
||||
if (events && !fn.internal) {
|
||||
const index = events.indexOf(fn);
|
||||
if (index != -1) events.splice(index, 1);
|
||||
if (index !== -1) events.splice(index, 1);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Events;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
import Icon from './Icon';
|
||||
|
@ -16,11 +16,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const Keyboard = new Class({
|
||||
|
||||
initialize() {
|
||||
},
|
||||
|
||||
class Keyboard {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
addShortcut(shortcuts, callback) {
|
||||
if (!$.isArray(shortcuts)) {
|
||||
shortcuts = [shortcuts];
|
||||
@ -28,8 +25,7 @@ const Keyboard = new Class({
|
||||
_.each(shortcuts, (shortcut) => {
|
||||
$(document).bind('keydown', shortcut, callback);
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Keyboard;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Icon from './Icon';
|
||||
import LinkIconTooltip from './widget/LinkIconTooltip';
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
import Topic from './Topic';
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import TopicConfig from './TopicConfig';
|
||||
import DragTopic from './DragTopic';
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
|
||||
import CentralTopic from './CentralTopic';
|
||||
import MainTopic from './MainTopic';
|
||||
import INodeModel from './model/INodeModel';
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Icon from './Icon';
|
||||
import FloatingTip from './widget/FloatingTip';
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import web2d from '@wisemapping/web2d';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
|
||||
import ConnectionLine from './ConnectionLine';
|
||||
import ControlPoint from './ControlPoint';
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import PersistenceManager from './PersistenceManager';
|
||||
|
||||
const RESTPersistenceManager = new Class({
|
||||
|
@ -30,345 +30,238 @@ import ChangeFeatureToTopicCommand from './commands/ChangeFeatureToTopicCommand'
|
||||
import NodeModel from './model/NodeModel';
|
||||
import EventBus from './layout/EventBus';
|
||||
|
||||
const StandaloneActionDispatcher = new Class(
|
||||
/** @lends StandaloneActionDispatcher */ {
|
||||
Extends: ActionDispatcher,
|
||||
/**
|
||||
* @extends mindplot.ActionDispatcher
|
||||
* @constructs
|
||||
* @param {mindplot.CommandContext} commandContext
|
||||
*/
|
||||
initialize(commandContext) {
|
||||
this.parent(commandContext);
|
||||
this._actionRunner = new DesignerActionRunner(commandContext, this);
|
||||
},
|
||||
class StandaloneActionDispatcher extends ActionDispatcher {
|
||||
constructor(commandContext) {
|
||||
super(commandContext);
|
||||
this._actionRunner = new DesignerActionRunner(commandContext, this);
|
||||
}
|
||||
|
||||
/** */
|
||||
addTopics(models, parentTopicsId) {
|
||||
const command = new AddTopicCommand(models, parentTopicsId);
|
||||
this.execute(command);
|
||||
},
|
||||
/** */
|
||||
addTopics(models, parentTopicsId) {
|
||||
const command = new AddTopicCommand(models, parentTopicsId);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
addRelationship(model) {
|
||||
const command = new AddRelationshipCommand(model);
|
||||
this.execute(command);
|
||||
},
|
||||
/** */
|
||||
addRelationship(model) {
|
||||
const command = new AddRelationshipCommand(model);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
deleteEntities(topicsIds, relIds) {
|
||||
const command = new DeleteCommand(topicsIds, relIds);
|
||||
this.execute(command);
|
||||
},
|
||||
/** */
|
||||
deleteEntities(topicsIds, relIds) {
|
||||
const command = new DeleteCommand(topicsIds, relIds);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
dragTopic(topicId, position, order, parentTopic) {
|
||||
const command = new DragTopicCommand(topicId, position, order, parentTopic);
|
||||
this.execute(command);
|
||||
},
|
||||
/** */
|
||||
dragTopic(topicId, position, order, parentTopic) {
|
||||
const command = new DragTopicCommand(topicId, position, order, parentTopic);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
moveTopic(topicId, position) {
|
||||
$assert($defined(topicId), 'topicsId can not be null');
|
||||
$assert($defined(position), 'position can not be null');
|
||||
/** */
|
||||
moveTopic(topicId, position) {
|
||||
$assert($defined(topicId), 'topicsId can not be null');
|
||||
$assert($defined(position), 'position can not be null');
|
||||
|
||||
const commandFunc = (topic, value) => {
|
||||
const result = topic.getPosition();
|
||||
EventBus.instance.fireEvent(EventBus.events.NodeMoveEvent, {
|
||||
node: topic.getModel(),
|
||||
position: value,
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicId, position);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
moveControlPoint(ctrlPoint, point) {
|
||||
const command = new MoveControlPointCommand(ctrlPoint, point);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeFontStyleToTopic(topicsIds) {
|
||||
const commandFunc = (topic) => {
|
||||
const result = topic.getFontStyle();
|
||||
const style = result === 'italic' ? 'normal' : 'italic';
|
||||
topic.setFontStyle(style, true);
|
||||
return result;
|
||||
};
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeTextToTopic(topicsIds, text) {
|
||||
$assert($defined(topicsIds), 'topicsIds can not be null');
|
||||
|
||||
const commandFunc = (topic, value) => {
|
||||
const result = topic.getText();
|
||||
topic.setText(value);
|
||||
return result;
|
||||
};
|
||||
commandFunc.commandType = 'changeTextToTopic';
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, text);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeFontFamilyToTopic(topicIds, fontFamily) {
|
||||
$assert(topicIds, 'topicIds can not be null');
|
||||
$assert(fontFamily, 'fontFamily can not be null');
|
||||
|
||||
const commandFunc = (topic, fontFamily) => {
|
||||
const result = topic.getFontFamily();
|
||||
topic.setFontFamily(fontFamily, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicIds, fontFamily);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeFontColorToTopic(topicsIds, color) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(color, 'color can not be null');
|
||||
|
||||
const commandFunc = (topic, color) => {
|
||||
const result = topic.getFontColor();
|
||||
topic.setFontColor(color, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = 'fontColorCommandId';
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeBackgroundColorToTopic(topicsIds, color) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(color, 'color can not be null');
|
||||
|
||||
const commandFunc = (topic, color) => {
|
||||
const result = topic.getBackgroundColor();
|
||||
topic.setBackgroundColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = 'backColor';
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeBorderColorToTopic(topicsIds, color) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(color, 'topicIds can not be null');
|
||||
|
||||
const commandFunc = (topic, color) => {
|
||||
const result = topic.getBorderColor();
|
||||
topic.setBorderColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = 'borderColorCommandId';
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeFontSizeToTopic(topicsIds, size) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(size, 'size can not be null');
|
||||
|
||||
const commandFunc = (topic, size) => {
|
||||
const result = topic.getFontSize();
|
||||
topic.setFontSize(size, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, size);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeShapeTypeToTopic(topicsIds, shapeType) {
|
||||
$assert(topicsIds, 'topicsIds can not be null');
|
||||
$assert(shapeType, 'shapeType can not be null');
|
||||
|
||||
const commandFunc = (topic, shapeType) => {
|
||||
const result = topic.getShapeType();
|
||||
topic.setShapeType(shapeType, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, shapeType);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeFontWeightToTopic(topicsIds) {
|
||||
$assert(topicsIds, 'topicsIds can not be null');
|
||||
|
||||
const commandFunc = (topic) => {
|
||||
const result = topic.getFontWeight();
|
||||
const weight = result === 'bold' ? 'normal' : 'bold';
|
||||
topic.setFontWeight(weight, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
shrinkBranch(topicsIds, collapse) {
|
||||
$assert(topicsIds, 'topicsIds can not be null');
|
||||
|
||||
const commandFunc = (topic, isShrink) => {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
return !isShrink;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
||||
this.execute(command, false);
|
||||
},
|
||||
|
||||
/** */
|
||||
addFeatureToTopic(topicId, featureType, attributes) {
|
||||
const command = new AddFeatureToTopicCommand(topicId, featureType, attributes);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
changeFeatureToTopic(topicId, featureId, attributes) {
|
||||
const command = new ChangeFeatureToTopicCommand(topicId, featureId, attributes);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
removeFeatureFromTopic(topicId, featureId) {
|
||||
const command = new RemoveFeatureFromTopicCommand(topicId, featureId);
|
||||
this.execute(command);
|
||||
},
|
||||
|
||||
/** */
|
||||
execute(command) {
|
||||
this._actionRunner.execute(command);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const CommandContext = new Class(
|
||||
/** @lends CommandContext */ {
|
||||
/**
|
||||
* @constructs
|
||||
* @param {mindplot.Designer} designer
|
||||
*/
|
||||
initialize(designer) {
|
||||
$assert(designer, 'designer can not be null');
|
||||
this._designer = designer;
|
||||
},
|
||||
|
||||
/** */
|
||||
findTopics(topicsIds) {
|
||||
$assert($defined(topicsIds), 'topicsIds can not be null');
|
||||
if (!(topicsIds instanceof Array)) {
|
||||
topicsIds = [topicsIds];
|
||||
}
|
||||
|
||||
const designerTopics = this._designer.getModel().getTopics();
|
||||
const result = designerTopics.filter((topic) => topicsIds.contains(topic.getId()));
|
||||
|
||||
if (result.length !== topicsIds.length) {
|
||||
const ids = designerTopics.map((topic) => topic.getId());
|
||||
$assert(
|
||||
result.length === topicsIds.length,
|
||||
`Could not find topic. Result:${result
|
||||
}, Filter Criteria:${topicsIds
|
||||
}, Current Topics: [${ids
|
||||
}]`,
|
||||
);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/** */
|
||||
deleteTopic(topic) {
|
||||
this._designer.removeTopic(topic);
|
||||
},
|
||||
|
||||
/** */
|
||||
createTopic(model) {
|
||||
$assert(model, 'model can not be null');
|
||||
return this._designer.nodeModelToNodeGraph(model);
|
||||
},
|
||||
|
||||
/** */
|
||||
createModel() {
|
||||
const mindmap = this._designer.getMindmap();
|
||||
return mindmap.createNode(NodeModel.MAIN_TOPIC_TYPE);
|
||||
},
|
||||
|
||||
/** */
|
||||
addTopic(topic) {
|
||||
const mindmap = this._designer.getMindmap();
|
||||
return mindmap.addBranch(topic.getModel());
|
||||
},
|
||||
|
||||
/** */
|
||||
connect(childTopic, parentTopic) {
|
||||
childTopic.connectTo(parentTopic, this._designer._workspace);
|
||||
},
|
||||
|
||||
/** */
|
||||
disconnect(topic) {
|
||||
topic.disconnect(this._designer._workspace);
|
||||
},
|
||||
|
||||
/** */
|
||||
addRelationship(model) {
|
||||
$assert(model, 'model cannot be null');
|
||||
return this._designer.addRelationship(model);
|
||||
},
|
||||
|
||||
/** */
|
||||
deleteRelationship(relationship) {
|
||||
this._designer.deleteRelationship(relationship);
|
||||
},
|
||||
|
||||
/** */
|
||||
findRelationships(relIds) {
|
||||
$assert($defined(relIds), 'relId can not be null');
|
||||
if (!(relIds instanceof Array)) {
|
||||
relIds = [relIds];
|
||||
}
|
||||
|
||||
const designerRel = this._designer.getModel().getRelationships();
|
||||
return designerRel.filter((rel) => relIds.contains(rel.getId()));
|
||||
},
|
||||
|
||||
/** */
|
||||
moveTopic(topic, position) {
|
||||
$assert(topic, 'topic cannot be null');
|
||||
$assert(position, 'position cannot be null');
|
||||
const commandFunc = (topic, value) => {
|
||||
const result = topic.getPosition();
|
||||
EventBus.instance.fireEvent(EventBus.events.NodeMoveEvent, {
|
||||
node: topic.getModel(),
|
||||
position,
|
||||
position: value,
|
||||
});
|
||||
},
|
||||
},
|
||||
);
|
||||
return result;
|
||||
};
|
||||
|
||||
export { StandaloneActionDispatcher, CommandContext };
|
||||
const command = new GenericFunctionCommand(commandFunc, topicId, position);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
moveControlPoint(ctrlPoint, point) {
|
||||
const command = new MoveControlPointCommand(ctrlPoint, point);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeFontStyleToTopic(topicsIds) {
|
||||
const commandFunc = (topic) => {
|
||||
const result = topic.getFontStyle();
|
||||
const style = result === 'italic' ? 'normal' : 'italic';
|
||||
topic.setFontStyle(style, true);
|
||||
return result;
|
||||
};
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeTextToTopic(topicsIds, text) {
|
||||
$assert($defined(topicsIds), 'topicsIds can not be null');
|
||||
|
||||
const commandFunc = (topic, value) => {
|
||||
const result = topic.getText();
|
||||
topic.setText(value);
|
||||
return result;
|
||||
};
|
||||
commandFunc.commandType = 'changeTextToTopic';
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, text);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeFontFamilyToTopic(topicIds, fontFamily) {
|
||||
$assert(topicIds, 'topicIds can not be null');
|
||||
$assert(fontFamily, 'fontFamily can not be null');
|
||||
|
||||
const commandFunc = (topic, fontFamily) => {
|
||||
const result = topic.getFontFamily();
|
||||
topic.setFontFamily(fontFamily, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicIds, fontFamily);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeFontColorToTopic(topicsIds, color) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(color, 'color can not be null');
|
||||
|
||||
const commandFunc = (topic, color) => {
|
||||
const result = topic.getFontColor();
|
||||
topic.setFontColor(color, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = 'fontColorCommandId';
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeBackgroundColorToTopic(topicsIds, color) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(color, 'color can not be null');
|
||||
|
||||
const commandFunc = (topic, color) => {
|
||||
const result = topic.getBackgroundColor();
|
||||
topic.setBackgroundColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = 'backColor';
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeBorderColorToTopic(topicsIds, color) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(color, 'topicIds can not be null');
|
||||
|
||||
const commandFunc = (topic, color) => {
|
||||
const result = topic.getBorderColor();
|
||||
topic.setBorderColor(color);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, color);
|
||||
command.discardDuplicated = 'borderColorCommandId';
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeFontSizeToTopic(topicsIds, size) {
|
||||
$assert(topicsIds, 'topicIds can not be null');
|
||||
$assert(size, 'size can not be null');
|
||||
|
||||
const commandFunc = (topic, size) => {
|
||||
const result = topic.getFontSize();
|
||||
topic.setFontSize(size, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, size);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeShapeTypeToTopic(topicsIds, shapeType) {
|
||||
$assert(topicsIds, 'topicsIds can not be null');
|
||||
$assert(shapeType, 'shapeType can not be null');
|
||||
|
||||
const commandFunc = (topic, shapeType) => {
|
||||
const result = topic.getShapeType();
|
||||
topic.setShapeType(shapeType, true);
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, shapeType);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeFontWeightToTopic(topicsIds) {
|
||||
$assert(topicsIds, 'topicsIds can not be null');
|
||||
|
||||
const commandFunc = (topic) => {
|
||||
const result = topic.getFontWeight();
|
||||
const weight = result === 'bold' ? 'normal' : 'bold';
|
||||
topic.setFontWeight(weight, true);
|
||||
|
||||
topic._adjustShapes();
|
||||
return result;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
shrinkBranch(topicsIds, collapse) {
|
||||
$assert(topicsIds, 'topicsIds can not be null');
|
||||
|
||||
const commandFunc = (topic, isShrink) => {
|
||||
topic.setChildrenShrunken(isShrink);
|
||||
return !isShrink;
|
||||
};
|
||||
|
||||
const command = new GenericFunctionCommand(commandFunc, topicsIds, collapse);
|
||||
this.execute(command, false);
|
||||
}
|
||||
|
||||
/** */
|
||||
addFeatureToTopic(topicId, featureType, attributes) {
|
||||
const command = new AddFeatureToTopicCommand(topicId, featureType, attributes);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
changeFeatureToTopic(topicId, featureId, attributes) {
|
||||
const command = new ChangeFeatureToTopicCommand(topicId, featureId, attributes);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
removeFeatureFromTopic(topicId, featureId) {
|
||||
const command = new RemoveFeatureFromTopicCommand(topicId, featureId);
|
||||
this.execute(command);
|
||||
}
|
||||
|
||||
/** */
|
||||
execute(command) {
|
||||
this._actionRunner.execute(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default StandaloneActionDispatcher ;
|
||||
|
@ -12,8 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $defined } from '@wisemapping/core-js';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
import ActionDispatcher from './ActionDispatcher';
|
||||
|
||||
// FIXME: Not used!
|
||||
|
@ -15,6 +15,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import { _ } from '@libraries/underscore-min';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
import NodeGraph from './NodeGraph';
|
||||
@ -192,7 +194,7 @@ const Topic = new Class(
|
||||
return model.getImageSize();
|
||||
};
|
||||
|
||||
result.setPosition = function () {};
|
||||
result.setPosition = function () { };
|
||||
} else if (shapeType === TopicShape.ELLIPSE) {
|
||||
result = new web2d.Rect(0.9, attributes);
|
||||
} else if (shapeType === TopicShape.ROUNDED_RECT) {
|
||||
@ -213,11 +215,11 @@ const Topic = new Class(
|
||||
return this.size;
|
||||
};
|
||||
|
||||
result.setPosition = function () {};
|
||||
result.setPosition = function () { };
|
||||
|
||||
result.setFill = function () {};
|
||||
result.setFill = function () { };
|
||||
|
||||
result.setStroke = function () {};
|
||||
result.setStroke = function () { };
|
||||
} else {
|
||||
$assert(false, `Unsupported figure shapeType:${shapeType}`);
|
||||
}
|
||||
@ -644,7 +646,7 @@ const Topic = new Class(
|
||||
let value = true;
|
||||
if (
|
||||
(event.metaKey && Browser.Platform.mac)
|
||||
|| (event.ctrlKey && !Browser.Platform.mac)
|
||||
|| (event.ctrlKey && !Browser.Platform.mac)
|
||||
) {
|
||||
value = !me.isOnFocus();
|
||||
event.stopPropagation();
|
||||
@ -969,8 +971,8 @@ const Topic = new Class(
|
||||
const sourceParent = sourceTopic.getModel().getParent();
|
||||
relationship.setVisibility(
|
||||
value
|
||||
&& (targetParent == null || !targetParent.areChildrenShrunken())
|
||||
&& (sourceParent == null || !sourceParent.areChildrenShrunken()),
|
||||
&& (targetParent == null || !targetParent.areChildrenShrunken())
|
||||
&& (sourceParent == null || !sourceParent.areChildrenShrunken()),
|
||||
);
|
||||
});
|
||||
},
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Events from './Events';
|
||||
import MultilineTextEditor from './MultilineTextEditor';
|
||||
import { TopicShape } from './model/INodeModel';
|
||||
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** */
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import IconModel from './model/IconModel';
|
||||
import ImageIcon from './ImageIcon';
|
||||
import LinkModel from './model/LinkModel';
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import { TopicShape } from './model/INodeModel';
|
||||
|
||||
const TopicStyle = new Class({});
|
||||
|
@ -15,7 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import web2d from '@wisemapping/web2d';
|
||||
|
||||
class Workspace {
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const mindplot = {};
|
||||
mindplot.util = {};
|
||||
mindplot.commands = {};
|
||||
mindplot.layout = {};
|
||||
mindplot.layout.boards = {};
|
||||
mindplot.layout.boards.original = {};
|
||||
mindplot.widget = {};
|
||||
mindplot.model = {};
|
||||
mindplot.collaboration = {};
|
||||
mindplot.collaboration.framework = {};
|
||||
mindplot.persistence = {};
|
||||
|
||||
mindplot.layout = {};
|
||||
|
||||
Class.Mutators.Static = function (items) {
|
||||
this.extend(items);
|
||||
};
|
@ -1,95 +0,0 @@
|
||||
import actionDispatcher from './ActionDispatcher';
|
||||
import actionIcon from './ActionIcon';
|
||||
import centralTopic from './CentralTopic';
|
||||
import command from './Command';
|
||||
import connectionLine from './ConnectionLine';
|
||||
import controlPoint from './ControlPoint';
|
||||
import designer from './Designer';
|
||||
import designerActionRunner from './DesignerActionRunner';
|
||||
import designerKeyboard from './DesignerKeyboard';
|
||||
import designerModal from './DesignerModel';
|
||||
import designerUndoManager from './DesignerUndoManager';
|
||||
import dragConnector from './DragConnector';
|
||||
import dragManager from './DragManager';
|
||||
import dragPivot from './DragPivot';
|
||||
import dragTopic from './DragTopic';
|
||||
import editorOptions from './EditorOptions';
|
||||
import editorProperties from './EditorProperties';
|
||||
import events from './Events';
|
||||
import footer from './footer';
|
||||
import header from './header';
|
||||
import icon from './Icon';
|
||||
import iconGroup from './IconGroup';
|
||||
import imageIcon from './ImageIcon';
|
||||
import keyboard from './Keyboard';
|
||||
import linkIcon from './LinkIcon';
|
||||
import localSorageManager from './LocalStorageManager';
|
||||
import mainTopic from './MainTopic';
|
||||
import messages from './Messages';
|
||||
import multilineTextEditor from './MultilineTextEditor';
|
||||
import nodeGraph from './NodeGraph';
|
||||
import noteIcon from './NoteIcon';
|
||||
import options from './Options';
|
||||
import persistenceManager from './PersistenceManager';
|
||||
import relationship from './Relationship';
|
||||
import relationshipPivot from './RelationshipPivot';
|
||||
import resetPersistenceManager from './RestPersistenceManager';
|
||||
import screenManager from './ScreenManager';
|
||||
import shrinkConnector from './ShrinkConnector';
|
||||
import standaloneActionDispatcher from './StandaloneActionDispatcher';
|
||||
import textEditor from './TextEditor';
|
||||
import textEditorFactory from './TextEditorFactory';
|
||||
import topic from './Topic';
|
||||
import topicEventDispatcher from './TopicEventDispatcher';
|
||||
import topicFeature from './TopicFeature';
|
||||
import topicStyle from './TopicStyle';
|
||||
import workspace from './Workspace';
|
||||
|
||||
export default {
|
||||
ActionDispatcher: actionDispatcher,
|
||||
ActionIcon: actionIcon,
|
||||
CentralTopic: centralTopic,
|
||||
Command: command,
|
||||
ConnectionLine: connectionLine,
|
||||
ControlPoint: controlPoint,
|
||||
Designer: designer,
|
||||
DesignerActionRunner: designerActionRunner,
|
||||
DesignerKeyboard: designerKeyboard,
|
||||
DesignerModel: designerModal,
|
||||
DesignerUndoManager: designerUndoManager,
|
||||
DragConnector: dragConnector,
|
||||
DragManager: dragManager,
|
||||
DragPivot: dragPivot,
|
||||
DragTopic: dragTopic,
|
||||
EditorOptions: editorOptions,
|
||||
EditorProperties: editorProperties,
|
||||
Events: events,
|
||||
Footer: footer,
|
||||
Header: header,
|
||||
Icon: icon,
|
||||
IconGroup: iconGroup,
|
||||
ImageIcon: imageIcon,
|
||||
Keyboard: keyboard,
|
||||
LinkIcon: linkIcon,
|
||||
LocalStorageManager: localSorageManager,
|
||||
MainTopic: mainTopic,
|
||||
Messages: messages,
|
||||
MultilineTextEditor: multilineTextEditor,
|
||||
NodeGraph: nodeGraph,
|
||||
NoteIcon: noteIcon,
|
||||
Options: options,
|
||||
PersistenceManager: persistenceManager,
|
||||
Relationship: relationship,
|
||||
RelationshipPivot: relationshipPivot,
|
||||
RestPersistenceManager: resetPersistenceManager,
|
||||
ScreenManager: screenManager,
|
||||
ShrinkConnector: shrinkConnector,
|
||||
StandaloneActionDispatcher: standaloneActionDispatcher,
|
||||
TextEditor: textEditor,
|
||||
TextEditorFactory: textEditorFactory,
|
||||
Topic: topic,
|
||||
TopicEventDispatcher: topicEventDispatcher,
|
||||
TopicFeature: topicFeature,
|
||||
TopicStyle: topicStyle,
|
||||
Workspace: workspace,
|
||||
};
|
@ -15,6 +15,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import _ from '@libraries/underscore-min';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import AbstractBasicSorter from './AbstractBasicSorter';
|
||||
|
||||
const BalancedSorter = new Class(
|
||||
|
@ -15,34 +15,30 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
|
||||
const ChangeEvent = new Class(/** @lends ChangeEvent */{
|
||||
/**
|
||||
* @constructs
|
||||
* @param {} id
|
||||
* @throws will throw an error if the given id is not/cannot be converted to a numerical value
|
||||
*/
|
||||
initialize(id) {
|
||||
$assert(!isNaN(id), 'id can not be null');
|
||||
class ChangeEvent {
|
||||
constructor(id) {
|
||||
$assert(!Number.isNaN(id), 'id can not be null');
|
||||
this._id = id;
|
||||
this._position = null;
|
||||
this._order = null;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return id */
|
||||
getId() {
|
||||
return this._id;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return order */
|
||||
getOrder() {
|
||||
return this._order;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return position */
|
||||
getPosition() {
|
||||
return this._position;
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {} value the order to set
|
||||
@ -50,21 +46,21 @@ const ChangeEvent = new Class(/** @lends ChangeEvent */{
|
||||
* value
|
||||
*/
|
||||
setOrder(value) {
|
||||
$assert(!isNaN(value), 'value can not be null');
|
||||
$assert(!Number.isNaN(value), 'value can not be null');
|
||||
this._order = value;
|
||||
},
|
||||
}
|
||||
|
||||
/** @param {} value
|
||||
* @throws will throw an error if the value is null or undefined */
|
||||
setPosition(value) {
|
||||
$assert(value, 'value can not be null');
|
||||
this._position = value;
|
||||
},
|
||||
}
|
||||
|
||||
/** @return {String} order and position */
|
||||
toString() {
|
||||
return `[order:${this.getOrder()}, position: {${this.getPosition().x},${this.getPosition().y}}]`;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ChangeEvent;
|
||||
|
@ -17,15 +17,8 @@
|
||||
*/
|
||||
import Events from '../Events';
|
||||
|
||||
const EventBus = new Class(/** @lends EventBus */{
|
||||
Implements: Events,
|
||||
/**
|
||||
* @constructs
|
||||
* @implements mindplot.Events
|
||||
*/
|
||||
initialize() {
|
||||
},
|
||||
});
|
||||
class EventBus extends Events {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for events
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import AbstractBasicSorter from './AbstractBasicSorter';
|
||||
|
||||
/**
|
||||
|
@ -15,274 +15,269 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import _ from '@libraries/underscore-min';
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import Events from '../Events';
|
||||
import RootedTreeSet from './RootedTreeSet';
|
||||
import OriginalLayout from './OriginalLayout';
|
||||
import ChangeEvent from './ChangeEvent';
|
||||
|
||||
const LayoutManager = new Class(
|
||||
/** @lends LayoutManager */ {
|
||||
Extends: Events,
|
||||
/**
|
||||
* @constructs
|
||||
* @extends mindplot.Events
|
||||
* @param {} rootNodeId
|
||||
* @param {} rootSize
|
||||
* @throws will throw an error if the root node id is null or undefined
|
||||
* @throws will throw an error if the root size is null
|
||||
*/
|
||||
initialize(rootNodeId, rootSize) {
|
||||
$assert($defined(rootNodeId), 'rootNodeId can not be null');
|
||||
$assert(rootSize, 'rootSize can not be null');
|
||||
var position = position || { x: 0, y: 0 };
|
||||
class LayoutManager extends Events {
|
||||
constructor(rootNodeId, rootSize) {
|
||||
super();
|
||||
$assert($defined(rootNodeId), 'rootNodeId can not be null');
|
||||
$assert(rootSize, 'rootSize can not be null');
|
||||
var position = position || { x: 0, y: 0 };
|
||||
|
||||
this._treeSet = new RootedTreeSet();
|
||||
this._layout = new OriginalLayout(this._treeSet);
|
||||
this._treeSet = new RootedTreeSet();
|
||||
this._layout = new OriginalLayout(this._treeSet);
|
||||
|
||||
const rootNode = this._layout.createNode(rootNodeId, rootSize, position, 'root');
|
||||
this._treeSet.setRoot(rootNode);
|
||||
this._events = [];
|
||||
},
|
||||
const rootNode = this._layout.createNode(rootNodeId, rootSize, position, 'root');
|
||||
this._treeSet.setRoot(rootNode);
|
||||
this._events = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param size
|
||||
* @throws will throw an error if id is null or undefined
|
||||
*/
|
||||
updateNodeSize(id, size) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
/**
|
||||
* @param id
|
||||
* @param size
|
||||
* @throws will throw an error if id is null or undefined
|
||||
*/
|
||||
updateNodeSize(id, size) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
|
||||
const node = this._treeSet.find(id);
|
||||
node.setSize(size);
|
||||
},
|
||||
const node = this._treeSet.find(id);
|
||||
node.setSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param value
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @throws will throw an error if value is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
updateShrinkState(id, value) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
$assert($defined(value), 'value can not be null');
|
||||
/**
|
||||
* @param id
|
||||
* @param value
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @throws will throw an error if value is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
updateShrinkState(id, value) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
$assert($defined(value), 'value can not be null');
|
||||
|
||||
const node = this._treeSet.find(id);
|
||||
node.setShrunken(value);
|
||||
const node = this._treeSet.find(id);
|
||||
node.setShrunken(value);
|
||||
|
||||
return this;
|
||||
},
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return {@link RootedTreeSet}.find(id)
|
||||
*/
|
||||
find(id) {
|
||||
return this._treeSet.find(id);
|
||||
},
|
||||
/**
|
||||
* @param id
|
||||
* @return {@link RootedTreeSet}.find(id)
|
||||
*/
|
||||
find(id) {
|
||||
return this._treeSet.find(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param position
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @throws will throw an error if position is null or undefined
|
||||
* @throws will throw an error if the position's x property is null or undefined
|
||||
* @throws will throw an error if the position's y property is null or undefined
|
||||
*/
|
||||
moveNode(id, position) {
|
||||
$assert($defined(id), 'id cannot be null');
|
||||
$assert($defined(position), 'position cannot be null');
|
||||
$assert($defined(position.x), 'x can not be null');
|
||||
$assert($defined(position.y), 'y can not be null');
|
||||
/**
|
||||
* @param id
|
||||
* @param position
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @throws will throw an error if position is null or undefined
|
||||
* @throws will throw an error if the position's x property is null or undefined
|
||||
* @throws will throw an error if the position's y property is null or undefined
|
||||
*/
|
||||
moveNode(id, position) {
|
||||
$assert($defined(id), 'id cannot be null');
|
||||
$assert($defined(position), 'position cannot be null');
|
||||
$assert($defined(position.x), 'x can not be null');
|
||||
$assert($defined(position.y), 'y can not be null');
|
||||
|
||||
const node = this._treeSet.find(id);
|
||||
// @Todo: this should not be here. This is broking the isolated node support...
|
||||
// node.setFree(true);
|
||||
// node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y - node.getPosition().y});
|
||||
node.setPosition(position);
|
||||
},
|
||||
const node = this._treeSet.find(id);
|
||||
// @Todo: this should not be here. This is broking the isolated node support...
|
||||
// node.setFree(true);
|
||||
// node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y - node.getPosition().y});
|
||||
node.setPosition(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parentId
|
||||
* @param childId
|
||||
* @param order
|
||||
* @throws will throw an error if parentId is null or undefined
|
||||
* @throws will throw an error if childId is null or undefined
|
||||
* @throws will throw an error if order is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
connectNode(parentId, childId, order) {
|
||||
$assert($defined(parentId), 'parentId cannot be null');
|
||||
$assert($defined(childId), 'childId cannot be null');
|
||||
$assert($defined(order), 'order cannot be null');
|
||||
/**
|
||||
* @param parentId
|
||||
* @param childId
|
||||
* @param order
|
||||
* @throws will throw an error if parentId is null or undefined
|
||||
* @throws will throw an error if childId is null or undefined
|
||||
* @throws will throw an error if order is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
connectNode(parentId, childId, order) {
|
||||
$assert($defined(parentId), 'parentId cannot be null');
|
||||
$assert($defined(childId), 'childId cannot be null');
|
||||
$assert($defined(order), 'order cannot be null');
|
||||
|
||||
this._layout.connectNode(parentId, childId, order);
|
||||
this._layout.connectNode(parentId, childId, order);
|
||||
|
||||
return this;
|
||||
},
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
disconnectNode(id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
this._layout.disconnectNode(id);
|
||||
/**
|
||||
* @param id
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
disconnectNode(id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
this._layout.disconnectNode(id);
|
||||
|
||||
return this;
|
||||
},
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param size
|
||||
* @param position
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
addNode(id, size, position) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
const result = this._layout.createNode(id, size, position, 'topic');
|
||||
this._treeSet.add(result);
|
||||
/**
|
||||
* @param id
|
||||
* @param size
|
||||
* @param position
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
addNode(id, size, position) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
const result = this._layout.createNode(id, size, position, 'topic');
|
||||
this._treeSet.add(result);
|
||||
|
||||
return this;
|
||||
},
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a node and its connection to parent if existing
|
||||
* @param id
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
removeNode(id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
const node = this._treeSet.find(id);
|
||||
/**
|
||||
* removes a node and its connection to parent if existing
|
||||
* @param id
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
removeNode(id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
const node = this._treeSet.find(id);
|
||||
|
||||
// Is It connected ?
|
||||
if (this._treeSet.getParent(node)) {
|
||||
this.disconnectNode(id);
|
||||
}
|
||||
// Is It connected ?
|
||||
if (this._treeSet.getParent(node)) {
|
||||
this.disconnectNode(id);
|
||||
}
|
||||
|
||||
// Remove the all the branch ...
|
||||
this._treeSet.remove(id);
|
||||
// Remove the all the branch ...
|
||||
this._treeSet.remove(id);
|
||||
|
||||
return this;
|
||||
},
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} parentId
|
||||
* @param {Number=} nodeId
|
||||
* @param {String=} position the position to use as mindplot.layout.Node.properties position
|
||||
* property as '(x,y)'
|
||||
* @param {Boolean=} free true specifies free node positioning
|
||||
* @throws will throw an error if parentId is null or undefined
|
||||
*/
|
||||
predict(parentId, nodeId, position, free) {
|
||||
$assert($defined(parentId), 'parentId can not be null');
|
||||
/**
|
||||
* @param {Number} parentId
|
||||
* @param {Number=} nodeId
|
||||
* @param {String=} position the position to use as mindplot.layout.Node.properties position
|
||||
* property as '(x,y)'
|
||||
* @param {Boolean=} free true specifies free node positioning
|
||||
* @throws will throw an error if parentId is null or undefined
|
||||
*/
|
||||
predict(parentId, nodeId, position, free) {
|
||||
$assert($defined(parentId), 'parentId can not be null');
|
||||
|
||||
const parent = this._treeSet.find(parentId);
|
||||
const node = nodeId ? this._treeSet.find(nodeId) : null;
|
||||
const sorter = parent.getSorter();
|
||||
const parent = this._treeSet.find(parentId);
|
||||
const node = nodeId ? this._treeSet.find(nodeId) : null;
|
||||
const sorter = parent.getSorter();
|
||||
|
||||
const result = sorter.predict(this._treeSet, parent, node, position, free);
|
||||
return { order: result[0], position: result[1] };
|
||||
},
|
||||
const result = sorter.predict(this._treeSet, parent, node, position, free);
|
||||
return { order: result[0], position: result[1] };
|
||||
}
|
||||
|
||||
/**
|
||||
* logs dump to console
|
||||
*/
|
||||
dump() {
|
||||
console.log(this._treeSet.dump());
|
||||
},
|
||||
/**
|
||||
* logs dump to console
|
||||
*/
|
||||
dump() {
|
||||
console.log(this._treeSet.dump());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param containerId
|
||||
* @param {width:Number, height:Number} size
|
||||
* @throws will throw an error if containerId is null or undefined
|
||||
* @return canvas
|
||||
*/
|
||||
plot(containerId, size) {
|
||||
// this method is only used from tests that include Raphael
|
||||
if (!global.Raphael) {
|
||||
console.warn('Raphael.js not found, exiting plot()');
|
||||
return null;
|
||||
}
|
||||
$assert(containerId, 'containerId cannot be null');
|
||||
size = size || { width: 200, height: 200 };
|
||||
const squaresize = 10;
|
||||
const canvas = global.Raphael(containerId, size.width, size.height);
|
||||
canvas.drawGrid(
|
||||
0,
|
||||
0,
|
||||
size.width,
|
||||
size.height,
|
||||
size.width / squaresize,
|
||||
size.height / squaresize,
|
||||
);
|
||||
this._treeSet.plot(canvas);
|
||||
/**
|
||||
* @param containerId
|
||||
* @param {width:Number, height:Number} size
|
||||
* @throws will throw an error if containerId is null or undefined
|
||||
* @return canvas
|
||||
*/
|
||||
plot(containerId, size) {
|
||||
// this method is only used from tests that include Raphael
|
||||
if (!global.Raphael) {
|
||||
console.warn('Raphael.js not found, exiting plot()');
|
||||
return null;
|
||||
}
|
||||
$assert(containerId, 'containerId cannot be null');
|
||||
size = size || { width: 200, height: 200 };
|
||||
const squaresize = 10;
|
||||
const canvas = global.Raphael(containerId, size.width, size.height);
|
||||
canvas.drawGrid(
|
||||
0,
|
||||
0,
|
||||
size.width,
|
||||
size.height,
|
||||
size.width / squaresize,
|
||||
size.height / squaresize,
|
||||
);
|
||||
this._treeSet.plot(canvas);
|
||||
|
||||
return canvas;
|
||||
},
|
||||
return canvas;
|
||||
}
|
||||
|
||||
/**
|
||||
* initializes the layout to be updated
|
||||
* @param fireEvents
|
||||
* @return this
|
||||
*/
|
||||
layout(fireEvents) {
|
||||
// File repositioning ...
|
||||
this._layout.layout();
|
||||
/**
|
||||
* initializes the layout to be updated
|
||||
* @param fireEvents
|
||||
* @return this
|
||||
*/
|
||||
layout(fireEvents) {
|
||||
// File repositioning ...
|
||||
this._layout.layout();
|
||||
|
||||
// Collect changes ...
|
||||
this._collectChanges();
|
||||
// Collect changes ...
|
||||
this._collectChanges();
|
||||
|
||||
if ($(fireEvents).length > 0 || fireEvents) {
|
||||
this._flushEvents();
|
||||
}
|
||||
if ($(fireEvents).length > 0 || fireEvents) {
|
||||
this._flushEvents();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
return this;
|
||||
}
|
||||
|
||||
_flushEvents() {
|
||||
_.each(
|
||||
this._events,
|
||||
function (event) {
|
||||
this.fireEvent('change', event);
|
||||
},
|
||||
this,
|
||||
);
|
||||
this._events = [];
|
||||
},
|
||||
_flushEvents() {
|
||||
_.each(
|
||||
this._events,
|
||||
function (event) {
|
||||
this.fireEvent('change', event);
|
||||
},
|
||||
this,
|
||||
);
|
||||
this._events = [];
|
||||
}
|
||||
|
||||
_collectChanges(nodes) {
|
||||
if (!nodes) nodes = this._treeSet.getTreeRoots();
|
||||
_collectChanges(nodes) {
|
||||
if (!nodes) {
|
||||
nodes = this._treeSet.getTreeRoots();
|
||||
}
|
||||
|
||||
_.each(
|
||||
nodes,
|
||||
function (node) {
|
||||
if (node.hasOrderChanged() || node.hasPositionChanged()) {
|
||||
// Find or create a event ...
|
||||
const id = node.getId();
|
||||
let event = this._events.some((event) => event.id == id);
|
||||
if (!event) {
|
||||
event = new ChangeEvent(id);
|
||||
}
|
||||
|
||||
// Update nodes ...
|
||||
event.setOrder(node.getOrder());
|
||||
event.setPosition(node.getPosition());
|
||||
|
||||
node.resetPositionState();
|
||||
node.resetOrderState();
|
||||
node.resetFreeState();
|
||||
this._events.push(event);
|
||||
_.each(
|
||||
nodes,
|
||||
function (node) {
|
||||
if (node.hasOrderChanged() || node.hasPositionChanged()) {
|
||||
// Find or create a event ...
|
||||
const id = node.getId();
|
||||
let event = this._events.some((event) => event.id == id);
|
||||
if (!event) {
|
||||
event = new ChangeEvent(id);
|
||||
}
|
||||
this._collectChanges(this._treeSet.getChildren(node));
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Update nodes ...
|
||||
event.setOrder(node.getOrder());
|
||||
event.setPosition(node.getPosition());
|
||||
|
||||
node.resetPositionState();
|
||||
node.resetOrderState();
|
||||
node.resetFreeState();
|
||||
this._events.push(event);
|
||||
}
|
||||
this._collectChanges(this._treeSet.getChildren(node));
|
||||
},
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default LayoutManager;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
|
||||
const Node = new Class(
|
||||
/** @lends Node */ {
|
||||
@ -30,7 +31,7 @@ const Node = new Class(
|
||||
* @throws will throw an error if sorter is null or undefined
|
||||
*/
|
||||
initialize(id, size, position, sorter) {
|
||||
$assert(typeof id === 'number' && isFinite(id), 'id can not be null');
|
||||
$assert(typeof id === 'number' && Number.isFinite(id), 'id can not be null');
|
||||
$assert(size, 'size can not be null');
|
||||
$assert(position, 'position can not be null');
|
||||
$assert(sorter, 'sorter can not be null');
|
||||
@ -82,7 +83,7 @@ const Node = new Class(
|
||||
/** */
|
||||
setOrder(order) {
|
||||
$assert(
|
||||
typeof order === 'number' && isFinite(order),
|
||||
typeof order === 'number' && Number.isFinite(order),
|
||||
`Order can not be null. Value:${order}`,
|
||||
);
|
||||
this._setProperty('order', order);
|
||||
@ -199,7 +200,7 @@ const Node = new Class(
|
||||
}
|
||||
|
||||
// Only update if the property has changed ...
|
||||
if (JSON.stringify(prop.value) != JSON.stringify(value)) {
|
||||
if (JSON.stringify(prop.value) !== JSON.stringify(value)) {
|
||||
prop.oldValue = prop.value;
|
||||
prop.value = value;
|
||||
prop.hasChanged = true;
|
||||
|
@ -15,265 +15,261 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import _ from '@libraries/underscore-min';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import Node from './Node';
|
||||
import SymmetricSorter from './SymmetricSorter';
|
||||
import BalancedSorter from './BalancedSorter';
|
||||
|
||||
const OriginalLayout = new Class(
|
||||
/** @lends OriginalLayout */ {
|
||||
/**
|
||||
* @constructs
|
||||
* @param treeSet
|
||||
*/
|
||||
initialize(treeSet) {
|
||||
this._treeSet = treeSet;
|
||||
},
|
||||
|
||||
/** */
|
||||
createNode(id, size, position, type) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
$assert(size, 'size can not be null');
|
||||
$assert(position, 'position can not be null');
|
||||
$assert(type, 'type can not be null');
|
||||
|
||||
const strategy = type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
|
||||
return new Node(id, size, position, strategy);
|
||||
},
|
||||
|
||||
/** */
|
||||
connectNode(parentId, childId, order) {
|
||||
const parent = this._treeSet.find(parentId);
|
||||
const child = this._treeSet.find(childId);
|
||||
|
||||
// Insert the new node ...
|
||||
const sorter = parent.getSorter();
|
||||
sorter.insert(this._treeSet, parent, child, order);
|
||||
|
||||
// Connect the new node ...
|
||||
this._treeSet.connect(parentId, childId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
sorter.verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
/** */
|
||||
disconnectNode(nodeId) {
|
||||
const node = this._treeSet.find(nodeId);
|
||||
const parent = this._treeSet.getParent(node);
|
||||
$assert(parent, 'Node already disconnected');
|
||||
|
||||
// Make it fixed
|
||||
node.setFree(false);
|
||||
node.resetFreeDisplacement();
|
||||
|
||||
// Remove from children list.
|
||||
const sorter = parent.getSorter();
|
||||
sorter.detach(this._treeSet, node);
|
||||
|
||||
// Disconnect the new node ...
|
||||
this._treeSet.disconnect(nodeId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
parent.getSorter().verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
/** */
|
||||
layout() {
|
||||
const roots = this._treeSet.getTreeRoots();
|
||||
_.each(
|
||||
roots,
|
||||
function (node) {
|
||||
// Calculate all node heights ...
|
||||
const sorter = node.getSorter();
|
||||
|
||||
const heightById = sorter.computeChildrenIdByHeights(this._treeSet, node);
|
||||
|
||||
this._layoutChildren(node, heightById);
|
||||
|
||||
this._fixOverlapping(node, heightById);
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_layoutChildren(node, heightById) {
|
||||
const nodeId = node.getId();
|
||||
const children = this._treeSet.getChildren(node);
|
||||
const parent = this._treeSet.getParent(node);
|
||||
const childrenOrderMoved = children.some((child) => child.hasOrderChanged());
|
||||
const childrenSizeChanged = children.some((child) => child.hasSizeChanged());
|
||||
|
||||
// If ether any of the nodes has been changed of position or the height of the children is not
|
||||
// the same, children nodes must be repositioned ....
|
||||
const newBranchHeight = heightById[nodeId];
|
||||
|
||||
const parentHeightChanged = $defined(parent) ? parent._heightChanged : false;
|
||||
const heightChanged = node._branchHeight != newBranchHeight;
|
||||
node._heightChanged = heightChanged || parentHeightChanged;
|
||||
|
||||
if (childrenOrderMoved || childrenSizeChanged || heightChanged || parentHeightChanged) {
|
||||
const sorter = node.getSorter();
|
||||
const offsetById = sorter.computeOffsets(this._treeSet, node);
|
||||
const parentPosition = node.getPosition();
|
||||
const me = this;
|
||||
_.each(children, (child) => {
|
||||
const offset = offsetById[child.getId()];
|
||||
|
||||
const childFreeDisplacement = child.getFreeDisplacement();
|
||||
const direction = node.getSorter().getChildDirection(me._treeSet, child);
|
||||
|
||||
if (
|
||||
(direction > 0 && childFreeDisplacement.x < 0)
|
||||
|| (direction < 0 && childFreeDisplacement.x > 0)
|
||||
) {
|
||||
child.resetFreeDisplacement();
|
||||
child.setFreeDisplacement({
|
||||
x: -childFreeDisplacement.x,
|
||||
y: childFreeDisplacement.y,
|
||||
});
|
||||
}
|
||||
|
||||
offset.x += child.getFreeDisplacement().x;
|
||||
offset.y += child.getFreeDisplacement().y;
|
||||
|
||||
const parentX = parentPosition.x;
|
||||
const parentY = parentPosition.y;
|
||||
|
||||
const newPos = {
|
||||
x: parentX + offset.x,
|
||||
y: parentY + offset.y + me._calculateAlignOffset(node, child, heightById),
|
||||
};
|
||||
me._treeSet.updateBranchPosition(child, newPos);
|
||||
});
|
||||
|
||||
node._branchHeight = newBranchHeight;
|
||||
}
|
||||
|
||||
// Continue reordering the children nodes ...
|
||||
_.each(
|
||||
children,
|
||||
function (child) {
|
||||
this._layoutChildren(child, heightById);
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_calculateAlignOffset(node, child, heightById) {
|
||||
if (child.isFree()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let offset = 0;
|
||||
|
||||
const nodeHeight = node.getSize().height;
|
||||
const childHeight = child.getSize().height;
|
||||
|
||||
if (
|
||||
this._treeSet.isStartOfSubBranch(child)
|
||||
&& this._branchIsTaller(child, heightById)
|
||||
) {
|
||||
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
|
||||
offset = heightById[child.getId()] / 2
|
||||
- (childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
|
||||
} else {
|
||||
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
|
||||
}
|
||||
} else if (nodeHeight > childHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = nodeHeight / 2 - childHeight / 2;
|
||||
}
|
||||
} else if (childHeight > nodeHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = -(childHeight / 2 - nodeHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_branchIsTaller(node, heightById) {
|
||||
return (
|
||||
heightById[node.getId()]
|
||||
> node.getSize().height + node.getSorter()._getVerticalPadding() * 2
|
||||
);
|
||||
},
|
||||
|
||||
_fixOverlapping(node, heightById) {
|
||||
const children = this._treeSet.getChildren(node);
|
||||
|
||||
if (node.isFree()) {
|
||||
this._shiftBranches(node, heightById);
|
||||
}
|
||||
|
||||
_.each(
|
||||
children,
|
||||
function (child) {
|
||||
this._fixOverlapping(child, heightById);
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_shiftBranches(node, heightById) {
|
||||
const shiftedBranches = [node];
|
||||
|
||||
const siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(
|
||||
node,
|
||||
node.getFreeDisplacement().y,
|
||||
);
|
||||
let last = node;
|
||||
_.each(
|
||||
siblingsToShift,
|
||||
function (sibling) {
|
||||
const overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
|
||||
return this._branchesOverlap(shiftedBranch, sibling, heightById);
|
||||
}, this);
|
||||
|
||||
if (!sibling.isFree() || overlappingOccurs) {
|
||||
const sAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
|
||||
shiftedBranches.push(sibling);
|
||||
}
|
||||
},
|
||||
this,
|
||||
);
|
||||
|
||||
const branchesToShift = this._treeSet
|
||||
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
|
||||
.filter((branch) => !shiftedBranches.contains(branch));
|
||||
|
||||
_.each(
|
||||
branchesToShift,
|
||||
function (branch) {
|
||||
const bAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
|
||||
shiftedBranches.push(branch);
|
||||
last = branch;
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_branchesOverlap(branchA, branchB, heightById) {
|
||||
// a branch doesn't really overlap with itself
|
||||
if (branchA == branchB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const topA = branchA.getPosition().y - heightById[branchA.getId()] / 2;
|
||||
const bottomA = branchA.getPosition().y + heightById[branchA.getId()] / 2;
|
||||
const topB = branchB.getPosition().y - heightById[branchB.getId()] / 2;
|
||||
const bottomB = branchB.getPosition().y + heightById[branchB.getId()] / 2;
|
||||
|
||||
return !(topA >= bottomB || bottomA <= topB);
|
||||
},
|
||||
const OriginalLayout = new Class({
|
||||
initialize(treeSet) {
|
||||
this._treeSet = treeSet;
|
||||
},
|
||||
|
||||
/** */
|
||||
createNode(id, size, position, type) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
$assert(size, 'size can not be null');
|
||||
$assert(position, 'position can not be null');
|
||||
$assert(type, 'type can not be null');
|
||||
|
||||
const strategy = type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
|
||||
return new Node(id, size, position, strategy);
|
||||
},
|
||||
|
||||
/** */
|
||||
connectNode(parentId, childId, order) {
|
||||
const parent = this._treeSet.find(parentId);
|
||||
const child = this._treeSet.find(childId);
|
||||
|
||||
// Insert the new node ...
|
||||
const sorter = parent.getSorter();
|
||||
sorter.insert(this._treeSet, parent, child, order);
|
||||
|
||||
// Connect the new node ...
|
||||
this._treeSet.connect(parentId, childId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
sorter.verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
/** */
|
||||
disconnectNode(nodeId) {
|
||||
const node = this._treeSet.find(nodeId);
|
||||
const parent = this._treeSet.getParent(node);
|
||||
$assert(parent, 'Node already disconnected');
|
||||
|
||||
// Make it fixed
|
||||
node.setFree(false);
|
||||
node.resetFreeDisplacement();
|
||||
|
||||
// Remove from children list.
|
||||
const sorter = parent.getSorter();
|
||||
sorter.detach(this._treeSet, node);
|
||||
|
||||
// Disconnect the new node ...
|
||||
this._treeSet.disconnect(nodeId);
|
||||
|
||||
// Fire a basic validation ...
|
||||
parent.getSorter().verify(this._treeSet, parent);
|
||||
},
|
||||
|
||||
/** */
|
||||
layout() {
|
||||
const roots = this._treeSet.getTreeRoots();
|
||||
_.each(
|
||||
roots,
|
||||
function (node) {
|
||||
// Calculate all node heights ...
|
||||
const sorter = node.getSorter();
|
||||
|
||||
const heightById = sorter.computeChildrenIdByHeights(this._treeSet, node);
|
||||
|
||||
this._layoutChildren(node, heightById);
|
||||
|
||||
this._fixOverlapping(node, heightById);
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_layoutChildren(node, heightById) {
|
||||
const nodeId = node.getId();
|
||||
const children = this._treeSet.getChildren(node);
|
||||
const parent = this._treeSet.getParent(node);
|
||||
const childrenOrderMoved = children.some((child) => child.hasOrderChanged());
|
||||
const childrenSizeChanged = children.some((child) => child.hasSizeChanged());
|
||||
|
||||
// If ether any of the nodes has been changed of position or the height of the children is not
|
||||
// the same, children nodes must be repositioned ....
|
||||
const newBranchHeight = heightById[nodeId];
|
||||
|
||||
const parentHeightChanged = $defined(parent) ? parent._heightChanged : false;
|
||||
const heightChanged = node._branchHeight !== newBranchHeight;
|
||||
node._heightChanged = heightChanged || parentHeightChanged;
|
||||
|
||||
if (childrenOrderMoved || childrenSizeChanged || heightChanged || parentHeightChanged) {
|
||||
const sorter = node.getSorter();
|
||||
const offsetById = sorter.computeOffsets(this._treeSet, node);
|
||||
const parentPosition = node.getPosition();
|
||||
const me = this;
|
||||
_.each(children, (child) => {
|
||||
const offset = offsetById[child.getId()];
|
||||
|
||||
const childFreeDisplacement = child.getFreeDisplacement();
|
||||
const direction = node.getSorter().getChildDirection(me._treeSet, child);
|
||||
|
||||
if (
|
||||
(direction > 0 && childFreeDisplacement.x < 0)
|
||||
|| (direction < 0 && childFreeDisplacement.x > 0)
|
||||
) {
|
||||
child.resetFreeDisplacement();
|
||||
child.setFreeDisplacement({
|
||||
x: -childFreeDisplacement.x,
|
||||
y: childFreeDisplacement.y,
|
||||
});
|
||||
}
|
||||
|
||||
offset.x += child.getFreeDisplacement().x;
|
||||
offset.y += child.getFreeDisplacement().y;
|
||||
|
||||
const parentX = parentPosition.x;
|
||||
const parentY = parentPosition.y;
|
||||
|
||||
const newPos = {
|
||||
x: parentX + offset.x,
|
||||
y: parentY + offset.y + me._calculateAlignOffset(node, child, heightById),
|
||||
};
|
||||
me._treeSet.updateBranchPosition(child, newPos);
|
||||
});
|
||||
|
||||
node._branchHeight = newBranchHeight;
|
||||
}
|
||||
|
||||
// Continue reordering the children nodes ...
|
||||
_.each(
|
||||
children,
|
||||
function (child) {
|
||||
this._layoutChildren(child, heightById);
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_calculateAlignOffset(node, child, heightById) {
|
||||
if (child.isFree()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let offset = 0;
|
||||
|
||||
const nodeHeight = node.getSize().height;
|
||||
const childHeight = child.getSize().height;
|
||||
|
||||
if (
|
||||
this._treeSet.isStartOfSubBranch(child)
|
||||
&& this._branchIsTaller(child, heightById)
|
||||
) {
|
||||
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
|
||||
offset = heightById[child.getId()] / 2
|
||||
- (childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
|
||||
} else {
|
||||
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
|
||||
}
|
||||
} else if (nodeHeight > childHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = nodeHeight / 2 - childHeight / 2;
|
||||
}
|
||||
} else if (childHeight > nodeHeight) {
|
||||
if (this._treeSet.getSiblings(child).length > 0) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = -(childHeight / 2 - nodeHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
},
|
||||
|
||||
_branchIsTaller(node, heightById) {
|
||||
return (
|
||||
heightById[node.getId()]
|
||||
> node.getSize().height + node.getSorter()._getVerticalPadding() * 2
|
||||
);
|
||||
},
|
||||
|
||||
_fixOverlapping(node, heightById) {
|
||||
const children = this._treeSet.getChildren(node);
|
||||
|
||||
if (node.isFree()) {
|
||||
this._shiftBranches(node, heightById);
|
||||
}
|
||||
|
||||
_.each(
|
||||
children,
|
||||
function (child) {
|
||||
this._fixOverlapping(child, heightById);
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_shiftBranches(node, heightById) {
|
||||
const shiftedBranches = [node];
|
||||
|
||||
const siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(
|
||||
node,
|
||||
node.getFreeDisplacement().y,
|
||||
);
|
||||
let last = node;
|
||||
_.each(
|
||||
siblingsToShift,
|
||||
function (sibling) {
|
||||
const overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
|
||||
return this._branchesOverlap(shiftedBranch, sibling, heightById);
|
||||
}, this);
|
||||
|
||||
if (!sibling.isFree() || overlappingOccurs) {
|
||||
const sAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
|
||||
shiftedBranches.push(sibling);
|
||||
}
|
||||
},
|
||||
this,
|
||||
);
|
||||
|
||||
const branchesToShift = this._treeSet
|
||||
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
|
||||
.filter((branch) => !shiftedBranches.contains(branch));
|
||||
|
||||
_.each(
|
||||
branchesToShift,
|
||||
function (branch) {
|
||||
const bAmount = node.getFreeDisplacement().y;
|
||||
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
|
||||
shiftedBranches.push(branch);
|
||||
last = branch;
|
||||
},
|
||||
this,
|
||||
);
|
||||
},
|
||||
|
||||
_branchesOverlap(branchA, branchB, heightById) {
|
||||
// a branch doesn't really overlap with itself
|
||||
if (branchA === branchB) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const topA = branchA.getPosition().y - heightById[branchA.getId()] / 2;
|
||||
const bottomA = branchA.getPosition().y + heightById[branchA.getId()] / 2;
|
||||
const topB = branchB.getPosition().y - heightById[branchB.getId()] / 2;
|
||||
const bottomB = branchB.getPosition().y + heightById[branchB.getId()] / 2;
|
||||
|
||||
return !(topA >= bottomB || bottomA <= topB);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
|
||||
const RootedTreeSet = new Class(
|
||||
/** @lends RootedTreeSet */ {
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import AbstractBasicSorter from './AbstractBasicSorter';
|
||||
|
||||
const SymmetricSorter = new Class(
|
||||
|
@ -1,27 +0,0 @@
|
||||
import abstractBasicSorter from './AbstractBasicSorter';
|
||||
import balancedSorter from './BalancedSorter';
|
||||
import changeEvent from './ChangeEvent';
|
||||
import childrenSorterStrategy from './ChildrenSorterStrategy';
|
||||
import eventBus from './EventBus';
|
||||
import eventBusDispatcher from './EventBusDispatcher';
|
||||
import gridSorter from './GridSorter';
|
||||
import layoutManager from './LayoutManager';
|
||||
import node from './Node';
|
||||
import originalLayout from './OriginalLayout';
|
||||
import rootedTreeSet from './RootedTreeSet';
|
||||
import symmetricSorter from './SymmetricSorter';
|
||||
|
||||
export default {
|
||||
AbstractBasicSorter: abstractBasicSorter,
|
||||
BalancedSorter: balancedSorter,
|
||||
ChangeEvent: changeEvent,
|
||||
ChildrenSorterStrategy: childrenSorterStrategy,
|
||||
EventBus: eventBus,
|
||||
EventBusDispatcher: eventBusDispatcher,
|
||||
GridSorter: gridSorter,
|
||||
LayoutManager: layoutManager,
|
||||
Node: node,
|
||||
OriginalLayout: originalLayout,
|
||||
RootedTreeSet: rootedTreeSet,
|
||||
SymmetricSorter: symmetricSorter,
|
||||
};
|
@ -1,172 +0,0 @@
|
||||
/*
|
||||
* jQuery Hotkeys Plugin
|
||||
* Copyright 2010, John Resig
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Based upon the plugin by Tzury Bar Yochay:
|
||||
* http://github.com/tzuryby/hotkeys
|
||||
*
|
||||
* Original idea by:
|
||||
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||
*/
|
||||
|
||||
/*
|
||||
* One small change is: now keys are passed by object { keys: '...' }
|
||||
* Might be useful, when you want to pass some other data to your handler
|
||||
*/
|
||||
|
||||
(function (jQuery) {
|
||||
jQuery.hotkeys = {
|
||||
version: '0.8',
|
||||
|
||||
specialKeys: {
|
||||
8: 'backspace',
|
||||
9: 'tab',
|
||||
10: 'return',
|
||||
13: 'enter',
|
||||
16: 'shift',
|
||||
17: 'ctrl',
|
||||
18: 'alt',
|
||||
19: 'pause',
|
||||
20: 'capslock',
|
||||
27: 'esc',
|
||||
32: 'space',
|
||||
33: 'pageup',
|
||||
34: 'pagedown',
|
||||
35: 'end',
|
||||
36: 'home',
|
||||
37: 'left',
|
||||
38: 'up',
|
||||
39: 'right',
|
||||
40: 'down',
|
||||
45: 'insert',
|
||||
46: 'del',
|
||||
96: '0',
|
||||
97: '1',
|
||||
98: '2',
|
||||
99: '3',
|
||||
100: '4',
|
||||
101: '5',
|
||||
102: '6',
|
||||
103: '7',
|
||||
104: '8',
|
||||
105: '9',
|
||||
106: '*',
|
||||
107: '+',
|
||||
109: '-',
|
||||
110: '.',
|
||||
111: '/',
|
||||
112: 'f1',
|
||||
113: 'f2',
|
||||
114: 'f3',
|
||||
115: 'f4',
|
||||
116: 'f5',
|
||||
117: 'f6',
|
||||
118: 'f7',
|
||||
119: 'f8',
|
||||
120: 'f9',
|
||||
121: 'f10',
|
||||
122: 'f11',
|
||||
123: 'f12',
|
||||
144: 'numlock',
|
||||
145: 'scroll',
|
||||
186: ';',
|
||||
191: '/',
|
||||
220: '\\',
|
||||
222: "'",
|
||||
224: 'meta',
|
||||
},
|
||||
|
||||
shiftNums: {
|
||||
'`': '~',
|
||||
1: '!',
|
||||
2: '@',
|
||||
3: '#',
|
||||
4: '$',
|
||||
5: '%',
|
||||
6: '^',
|
||||
7: '&',
|
||||
8: '*',
|
||||
9: '(',
|
||||
0: ')',
|
||||
'-': '_',
|
||||
'=': '+',
|
||||
';': ': ',
|
||||
"'": '"',
|
||||
',': '<',
|
||||
'.': '>',
|
||||
'/': '?',
|
||||
'\\': '|',
|
||||
},
|
||||
};
|
||||
|
||||
function keyHandler(handleObj) {
|
||||
if (typeof handleObj.data === 'string') {
|
||||
handleObj.data = { keys: handleObj.data };
|
||||
}
|
||||
|
||||
// Only care when a possible input has been specified
|
||||
if (!handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
const origHandler = handleObj.handler;
|
||||
const keys = handleObj.data.keys.toLowerCase().split(' ');
|
||||
const textAcceptingInputTypes = ['text', 'password', 'number', 'email', 'url', 'range', 'date', 'month', 'week', 'time', 'datetime', 'datetime-local', 'search', 'color', 'tel'];
|
||||
|
||||
handleObj.handler = function (event) {
|
||||
// Don't fire in text-accepting inputs that we didn't directly bind to
|
||||
if (this !== event.target && (/textarea|select/i.test(event.target.nodeName)
|
||||
|| jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const special = jQuery.hotkeys.specialKeys[event.keyCode];
|
||||
const character = String.fromCharCode(event.which).toLowerCase();
|
||||
let modif = ''; const
|
||||
possible = {};
|
||||
|
||||
// check combinations (alt|ctrl|shift+anything)
|
||||
if (event.altKey && special !== 'alt') {
|
||||
modif += 'alt+';
|
||||
}
|
||||
|
||||
if (event.ctrlKey && special !== 'ctrl') {
|
||||
modif += 'ctrl+';
|
||||
}
|
||||
|
||||
// TODO: Need to make sure this works consistently across platforms
|
||||
if (event.metaKey && !event.ctrlKey && special !== 'meta') {
|
||||
modif += 'meta+';
|
||||
}
|
||||
|
||||
if (event.shiftKey && special !== 'shift') {
|
||||
modif += 'shift+';
|
||||
}
|
||||
|
||||
if (special) {
|
||||
possible[modif + special] = true;
|
||||
}
|
||||
|
||||
if (character) {
|
||||
possible[modif + character] = true;
|
||||
possible[modif + jQuery.hotkeys.shiftNums[character]] = true;
|
||||
|
||||
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
|
||||
if (modif === 'shift+') {
|
||||
possible[jQuery.hotkeys.shiftNums[character]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0, l = keys.length; i < l; i++) {
|
||||
if (possible[keys[i]]) {
|
||||
return origHandler.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
jQuery.each(['keydown', 'keyup', 'keypress'], function () {
|
||||
jQuery.event.special[this] = { add: keyHandler };
|
||||
});
|
||||
}(this.jQuery));
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,12 +0,0 @@
|
||||
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Version: 3.1.11
|
||||
*
|
||||
* Requires: jQuery 1.2.2+
|
||||
*/
|
||||
!(function (a) { typeof define === 'function' && define.amd ? define(['jquery'], a) : typeof exports === 'object' ? module.exports = a : a(jQuery); }((a) => {
|
||||
function b(b) { const g = b || window.event; const h = i.call(arguments, 1); let j = 0; let l = 0; let m = 0; let n = 0; let o = 0; let p = 0; if (b = a.event.fix(g), b.type = 'mousewheel', 'detail' in g && (m = -1 * g.detail), 'wheelDelta' in g && (m = g.wheelDelta), 'wheelDeltaY' in g && (m = g.wheelDeltaY), 'wheelDeltaX' in g && (l = -1 * g.wheelDeltaX), 'axis' in g && g.axis === g.HORIZONTAL_AXIS && (l = -1 * m, m = 0), j = m === 0 ? l : m, 'deltaY' in g && (m = -1 * g.deltaY, j = m), 'deltaX' in g && (l = g.deltaX, m === 0 && (j = -1 * l)), m !== 0 || l !== 0) { if (g.deltaMode === 1) { const q = a.data(this, 'mousewheel-line-height'); j *= q, m *= q, l *= q; } else if (g.deltaMode === 2) { const r = a.data(this, 'mousewheel-page-height'); j *= r, m *= r, l *= r; } if (n = Math.max(Math.abs(m), Math.abs(l)), (!f || f > n) && (f = n, d(g, n) && (f /= 40)), d(g, n) && (j /= 40, l /= 40, m /= 40), j = Math[j >= 1 ? 'floor' : 'ceil'](j / f), l = Math[l >= 1 ? 'floor' : 'ceil'](l / f), m = Math[m >= 1 ? 'floor' : 'ceil'](m / f), k.settings.normalizeOffset && this.getBoundingClientRect) { const s = this.getBoundingClientRect(); o = b.clientX - s.left, p = b.clientY - s.top; } return b.deltaX = l, b.deltaY = m, b.deltaFactor = f, b.offsetX = o, b.offsetY = p, b.deltaMode = 0, h.unshift(b, j, l, m), e && clearTimeout(e), e = setTimeout(c, 200), (a.event.dispatch || a.event.handle).apply(this, h); } } function c() { f = null; } function d(a, b) { return k.settings.adjustOldDeltas && a.type === 'mousewheel' && b % 120 === 0; } let e; let f; const g = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll']; const h = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; var i = Array.prototype.slice; if (a.event.fixHooks) for (let j = g.length; j;)a.event.fixHooks[g[--j]] = a.event.mouseHooks; var k = a.event.special.mousewheel = {
|
||||
version: '3.1.11', setup() { if (this.addEventListener) for (let c = h.length; c;) this.addEventListener(h[--c], b, !1); else this.onmousewheel = b; a.data(this, 'mousewheel-line-height', k.getLineHeight(this)), a.data(this, 'mousewheel-page-height', k.getPageHeight(this)); }, teardown() { if (this.removeEventListener) for (let c = h.length; c;) this.removeEventListener(h[--c], b, !1); else this.onmousewheel = null; a.removeData(this, 'mousewheel-line-height'), a.removeData(this, 'mousewheel-page-height'); }, getLineHeight(b) { let c = a(b)['offsetParent' in a.fn ? 'offsetParent' : 'parent'](); return c.length || (c = a('body')), parseInt(c.css('fontSize'), 10); }, getPageHeight(b) { return a(b).height(); }, settings: { adjustOldDeltas: !0, normalizeOffset: !0 },
|
||||
}; a.fn.extend({ mousewheel(a) { return a ? this.bind('mousewheel', a) : this.trigger('mousewheel'); }, unmousewheel(a) { return this.unbind('mousewheel', a); } });
|
||||
}));
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,596 +0,0 @@
|
||||
/*
|
||||
---
|
||||
MooTools: the javascript framework
|
||||
|
||||
web build:
|
||||
- http://mootools.net/core/b28139f033891d55fabb70ffafd6813b
|
||||
|
||||
packager build:
|
||||
- packager build Core/Core Core/Array Core/Class Core/Class.Extras
|
||||
|
||||
copyrights:
|
||||
- [MooTools](http://mootools.net)
|
||||
|
||||
licenses:
|
||||
- [MIT License](http://mootools.net/license.txt)
|
||||
...
|
||||
*/
|
||||
|
||||
(function () {
|
||||
this.MooTools = { version: '1.4.5', build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0' };
|
||||
const o = this.typeOf = function (i) {
|
||||
if (i == null) {
|
||||
return 'null';
|
||||
}
|
||||
if (i.$family != null) {
|
||||
return i.$family();
|
||||
}
|
||||
if (i.nodeName) {
|
||||
if (i.nodeType == 1) {
|
||||
return 'element';
|
||||
}
|
||||
if (i.nodeType == 3) {
|
||||
return (/\S/).test(i.nodeValue) ? 'textnode' : 'whitespace';
|
||||
}
|
||||
} else if (typeof i.length === 'number') {
|
||||
if (i.callee) {
|
||||
return 'arguments';
|
||||
}
|
||||
if ('item' in i) {
|
||||
return 'collection';
|
||||
}
|
||||
}
|
||||
return typeof i;
|
||||
};
|
||||
this.instanceOf = function (t, i) {
|
||||
if (t == null) {
|
||||
return false;
|
||||
}
|
||||
let s = t.$constructor || t.constructor;
|
||||
while (s) {
|
||||
if (s === i) {
|
||||
return true;
|
||||
}
|
||||
s = s.parent;
|
||||
}
|
||||
if (!t.hasOwnProperty) {
|
||||
return false;
|
||||
}
|
||||
return t instanceof i;
|
||||
};
|
||||
const f = this.Function;
|
||||
let p = true;
|
||||
for (const k in { toString: 1 }) {
|
||||
p = null;
|
||||
}
|
||||
if (p) {
|
||||
p = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];
|
||||
}
|
||||
f.prototype.overloadSetter = function (s) {
|
||||
const i = this;
|
||||
return function (u, t) {
|
||||
if (u == null) {
|
||||
return this;
|
||||
}
|
||||
if (s || typeof u !== 'string') {
|
||||
for (var v in u) {
|
||||
i.call(this, v, u[v]);
|
||||
}
|
||||
if (p) {
|
||||
for (let w = p.length; w--;) {
|
||||
v = p[w];
|
||||
if (u.hasOwnProperty(v)) {
|
||||
i.call(this, v, u[v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
i.call(this, u, t);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
};
|
||||
f.prototype.extend = function (i, s) {
|
||||
this[i] = s;
|
||||
}.overloadSetter();
|
||||
f.prototype.implement = function (i, s) {
|
||||
this.prototype[i] = s;
|
||||
}.overloadSetter();
|
||||
const n = Array.prototype.slice;
|
||||
Array.from = function (i) {
|
||||
if (i == null) {
|
||||
return [];
|
||||
}
|
||||
return (a.isEnumerable(i) && typeof i !== 'string') ? (o(i) == 'array') ? i : n.call(i) : [i];
|
||||
};
|
||||
f.implement({
|
||||
hide() {
|
||||
this.$hidden = true;
|
||||
return this;
|
||||
},
|
||||
protect() {
|
||||
this.$protected = true;
|
||||
return this;
|
||||
},
|
||||
});
|
||||
var a = this.Type = function (u, t) {
|
||||
if (u) {
|
||||
const s = u.toLowerCase();
|
||||
const i = function (v) {
|
||||
return (o(v) == s);
|
||||
};
|
||||
a[`is${u}`] = i;
|
||||
if (t != null) {
|
||||
t.prototype.$family = (function () {
|
||||
return s;
|
||||
}).hide();
|
||||
}
|
||||
}
|
||||
if (t == null) {
|
||||
return null;
|
||||
}
|
||||
t.extend(this);
|
||||
t.$constructor = a;
|
||||
t.prototype.$constructor = t;
|
||||
return t;
|
||||
};
|
||||
const e = Object.prototype.toString;
|
||||
a.isEnumerable = function (i) {
|
||||
return (i != null && typeof i.length === 'number' && e.call(i) != '[object Function]');
|
||||
};
|
||||
const q = {};
|
||||
const r = function (i) {
|
||||
const s = o(i.prototype);
|
||||
return q[s] || (q[s] = []);
|
||||
};
|
||||
var b = function (t, x) {
|
||||
if (x && x.$hidden) {
|
||||
return;
|
||||
}
|
||||
const s = r(this);
|
||||
for (let u = 0; u < s.length;
|
||||
u++) {
|
||||
const w = s[u];
|
||||
if (o(w) == 'type') {
|
||||
b.call(w, t, x);
|
||||
} else {
|
||||
w.call(this, t, x);
|
||||
}
|
||||
}
|
||||
const v = this.prototype[t];
|
||||
if (v == null || !v.$protected) {
|
||||
this.prototype[t] = x;
|
||||
}
|
||||
if (this[t] == null && o(x) == 'function') {
|
||||
m.call(this, t, function (i) {
|
||||
return x.apply(i, n.call(arguments, 1));
|
||||
});
|
||||
}
|
||||
};
|
||||
var m = function (i, t) {
|
||||
if (t && t.$hidden) {
|
||||
return;
|
||||
}
|
||||
const s = this[i];
|
||||
if (s == null || !s.$protected) {
|
||||
this[i] = t;
|
||||
}
|
||||
};
|
||||
a.implement({
|
||||
implement: b.overloadSetter(),
|
||||
extend: m.overloadSetter(),
|
||||
alias: function (i, s) {
|
||||
b.call(this, i, this.prototype[s]);
|
||||
}.overloadSetter(),
|
||||
mirror(i) {
|
||||
r(this).push(i);
|
||||
return this;
|
||||
},
|
||||
});
|
||||
new a('Type', a);
|
||||
var d = function (s, x, v) {
|
||||
const u = (x != Object); const
|
||||
B = x.prototype;
|
||||
if (u) {
|
||||
x = new a(s, x);
|
||||
}
|
||||
for (let y = 0, w = v.length; y < w; y++) {
|
||||
const C = v[y]; const A = x[C]; const
|
||||
z = B[C];
|
||||
if (A) {
|
||||
A.protect();
|
||||
}
|
||||
if (u && z) {
|
||||
x.implement(C, z.protect());
|
||||
}
|
||||
}
|
||||
if (u) {
|
||||
const t = B.propertyIsEnumerable(v[0]);
|
||||
x.forEachMethod = function (G) {
|
||||
if (!t) {
|
||||
for (let F = 0, D = v.length; F < D; F++) {
|
||||
G.call(B, B[v[F]], v[F]);
|
||||
}
|
||||
}
|
||||
for (const E in B) {
|
||||
G.call(B, B[E], E);
|
||||
}
|
||||
};
|
||||
}
|
||||
return d;
|
||||
};
|
||||
d('String', String, ['charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search', 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'])('Array', Array, ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice', 'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'])('Number', Number, ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision'])('Function', f, ['apply', 'call', 'bind'])('RegExp', RegExp, ['exec', 'test'])('Object', Object, ['create', 'defineProperty', 'defineProperties', 'keys', 'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen'])('Date', Date, ['now']);
|
||||
Object.extend = m.overloadSetter();
|
||||
Date.extend('now', () => +(new Date()));
|
||||
new a('Boolean', Boolean);
|
||||
Number.prototype.$family = function () {
|
||||
return isFinite(this) ? 'number' : 'null';
|
||||
}.hide();
|
||||
Number.extend('random', (s, i) => Math.floor(Math.random() * (i - s + 1) + s));
|
||||
const g = Object.prototype.hasOwnProperty;
|
||||
Object.extend('forEach', (i, t, u) => {
|
||||
for (const s in i) {
|
||||
if (g.call(i, s)) {
|
||||
t.call(u, i[s], s, i);
|
||||
}
|
||||
}
|
||||
});
|
||||
Object.each = Object.forEach;
|
||||
Array.implement({
|
||||
forEach(u, v) {
|
||||
for (let t = 0, s = this.length; t < s; t++) {
|
||||
if (t in this) {
|
||||
u.call(v, this[t], t, this);
|
||||
}
|
||||
}
|
||||
},
|
||||
each(i, s) {
|
||||
Array.forEach(this, i, s);
|
||||
return this;
|
||||
},
|
||||
});
|
||||
const l = function (i) {
|
||||
switch (o(i)) {
|
||||
case 'array':
|
||||
return i.clone();
|
||||
case 'object':
|
||||
return Object.clone(i);
|
||||
default:
|
||||
return i;
|
||||
}
|
||||
};
|
||||
Array.implement('clone', function () {
|
||||
let s = this.length; const
|
||||
t = new Array(s);
|
||||
while (s--) {
|
||||
t[s] = l(this[s]);
|
||||
}
|
||||
return t;
|
||||
});
|
||||
const h = function (s, i, t) {
|
||||
switch (o(t)) {
|
||||
case 'object':
|
||||
if (o(s[i]) == 'object') {
|
||||
Object.merge(s[i], t);
|
||||
} else {
|
||||
s[i] = Object.clone(t);
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
s[i] = t.clone();
|
||||
break;
|
||||
default:
|
||||
s[i] = t;
|
||||
}
|
||||
return s;
|
||||
};
|
||||
Object.extend({
|
||||
merge(z, u, t) {
|
||||
if (o(u) == 'string') {
|
||||
return h(z, u, t);
|
||||
}
|
||||
for (let y = 1, s = arguments.length;
|
||||
y < s; y++) {
|
||||
const w = arguments[y];
|
||||
for (const x in w) {
|
||||
h(z, x, w[x]);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
},
|
||||
clone(i) {
|
||||
const t = {};
|
||||
for (const s in i) {
|
||||
t[s] = l(i[s]);
|
||||
}
|
||||
return t;
|
||||
},
|
||||
append(w) {
|
||||
for (let v = 1, t = arguments.length;
|
||||
v < t; v++) {
|
||||
const s = arguments[v] || {};
|
||||
for (const u in s) {
|
||||
w[u] = s[u];
|
||||
}
|
||||
}
|
||||
return w;
|
||||
},
|
||||
});
|
||||
['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each((i) => {
|
||||
new a(i);
|
||||
});
|
||||
let c = Date.now();
|
||||
String.extend('uniqueID', () => (c++).toString(36));
|
||||
}());
|
||||
|
||||
Array.implement({
|
||||
filter(d, f) {
|
||||
const c = [];
|
||||
for (var e, b = 0, a = this.length >>> 0; b < a; b++) {
|
||||
if (b in this) {
|
||||
e = this[b];
|
||||
if (d.call(f, e, b, this)) {
|
||||
c.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
},
|
||||
indexOf(c, d) {
|
||||
const b = this.length >>> 0;
|
||||
for (let a = (d < 0) ? Math.max(0, b + d) : d || 0; a < b; a++) {
|
||||
if (this[a] === c) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
map(c, e) {
|
||||
const d = this.length >>> 0; const
|
||||
b = Array(d);
|
||||
for (let a = 0; a < d; a++) {
|
||||
if (a in this) {
|
||||
b[a] = c.call(e, this[a], a, this);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
},
|
||||
some(c, d) {
|
||||
for (let b = 0, a = this.length >>> 0;
|
||||
b < a; b++) {
|
||||
if ((b in this) && c.call(d, this[b], b, this)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
clean() {
|
||||
return this.filter((a) => a != null);
|
||||
},
|
||||
contains(a, b) {
|
||||
return this.indexOf(a, b) != -1;
|
||||
},
|
||||
append(a) {
|
||||
this.push.apply(this, a);
|
||||
return this;
|
||||
},
|
||||
getLast() {
|
||||
return (this.length) ? this[this.length - 1] : null;
|
||||
},
|
||||
include(a) {
|
||||
if (!this.contains(a)) {
|
||||
this.push(a);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
erase(b) {
|
||||
for (let a = this.length; a--;) {
|
||||
if (this[a] === b) {
|
||||
this.splice(a, 1);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
empty() {
|
||||
this.length = 0;
|
||||
return this;
|
||||
},
|
||||
flatten() {
|
||||
let d = [];
|
||||
for (let b = 0, a = this.length; b < a; b++) {
|
||||
const c = typeOf(this[b]);
|
||||
if (c == 'null') {
|
||||
continue;
|
||||
}
|
||||
d = d.concat((c == 'array' || c == 'collection' || c == 'arguments' || instanceOf(this[b], Array)) ? Array.flatten(this[b]) : this[b]);
|
||||
}
|
||||
return d;
|
||||
},
|
||||
pick() {
|
||||
for (let b = 0, a = this.length; b < a; b++) {
|
||||
if (this[b] != null) {
|
||||
return this[b];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
rgbToHex(d) {
|
||||
if (this.length < 3) {
|
||||
return null;
|
||||
}
|
||||
if (this.length == 4 && this[3] == 0 && !d) {
|
||||
return 'transparent';
|
||||
}
|
||||
const b = [];
|
||||
for (let a = 0; a < 3; a++) {
|
||||
const c = (this[a] - 0).toString(16);
|
||||
b.push((c.length == 1) ? `0${c}` : c);
|
||||
}
|
||||
return (d) ? b : `#${b.join('')}`;
|
||||
},
|
||||
});
|
||||
String.implement({
|
||||
test(a, b) {
|
||||
return ((typeOf(a) == 'regexp') ? a : new RegExp(`${a}`, b)).test(this);
|
||||
},
|
||||
contains(a, b) {
|
||||
return (b) ? (b + this + b).indexOf(b + a + b) > -1 : String(this).indexOf(a) > -1;
|
||||
},
|
||||
capitalize() {
|
||||
return String(this).replace(/\b[a-z]/g, (a) => a.toUpperCase());
|
||||
},
|
||||
rgbToHex(b) {
|
||||
const a = String(this).match(/\d{1,3}/g);
|
||||
return (a) ? a.rgbToHex(b) : null;
|
||||
},
|
||||
});
|
||||
Function.implement({
|
||||
bind(e) {
|
||||
const a = this; const b = arguments.length > 1 ? Array.slice(arguments, 1) : null; const
|
||||
d = function () {
|
||||
};
|
||||
var c = function () {
|
||||
let g = e; const
|
||||
h = arguments.length;
|
||||
if (this instanceof c) {
|
||||
d.prototype = a.prototype;
|
||||
g = new d();
|
||||
}
|
||||
const f = (!b && !h) ? a.call(g) : a.apply(g, b && h ? b.concat(Array.slice(arguments)) : b || arguments);
|
||||
return g == e ? f : g;
|
||||
};
|
||||
return c;
|
||||
},
|
||||
pass(b, c) {
|
||||
const a = this;
|
||||
if (b != null) {
|
||||
b = Array.from(b);
|
||||
}
|
||||
return function () {
|
||||
return a.apply(c, b || arguments);
|
||||
};
|
||||
},
|
||||
delay(b, c, a) {
|
||||
return setTimeout(this.pass((a == null ? [] : a), c), b);
|
||||
},
|
||||
});
|
||||
|
||||
Number.alias('each', 'times');
|
||||
(function (b) {
|
||||
const a = {};
|
||||
b.each((c) => {
|
||||
if (!Number[c]) {
|
||||
a[c] = function () {
|
||||
return Math[c].apply(null, [this].concat(Array.from(arguments)));
|
||||
};
|
||||
}
|
||||
});
|
||||
Number.implement(a);
|
||||
}(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']));
|
||||
|
||||
(function () {
|
||||
var a = this.Class = new Type('Class', function (h) {
|
||||
if (instanceOf(h, Function)) {
|
||||
h = { initialize: h };
|
||||
}
|
||||
var g = function () {
|
||||
e(this);
|
||||
if (g.$prototyping) {
|
||||
return this;
|
||||
}
|
||||
this.$caller = null;
|
||||
const i = (this.initialize) ? this.initialize.apply(this, arguments) : this;
|
||||
this.$caller = this.caller = null;
|
||||
return i;
|
||||
}.extend(this).implement(h);
|
||||
g.$constructor = a;
|
||||
g.prototype.$constructor = g;
|
||||
g.prototype.parent = c;
|
||||
return g;
|
||||
});
|
||||
var c = function () {
|
||||
if (!this.$caller) {
|
||||
throw new Error('The method "parent" cannot be called.');
|
||||
}
|
||||
const g = this.$caller.$name; const h = this.$caller.$owner.parent; const
|
||||
i = (h) ? h.prototype[g] : null;
|
||||
if (!i) {
|
||||
throw new Error(`The method "${g}" has no parent.`);
|
||||
}
|
||||
return i.apply(this, arguments);
|
||||
};
|
||||
var e = function (g) {
|
||||
for (const h in g) {
|
||||
const j = g[h];
|
||||
switch (typeOf(j)) {
|
||||
case 'object':
|
||||
var i = function () {
|
||||
};
|
||||
i.prototype = j;
|
||||
g[h] = e(new i());
|
||||
break;
|
||||
case 'array':
|
||||
g[h] = j.clone();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return g;
|
||||
};
|
||||
const b = function (g, h, j) {
|
||||
if (j.$origin) {
|
||||
j = j.$origin;
|
||||
}
|
||||
var i = function () {
|
||||
if (j.$protected && this.$caller == null) {
|
||||
throw new Error(`The method "${h}" cannot be called.`);
|
||||
}
|
||||
const l = this.caller; const
|
||||
m = this.$caller;
|
||||
this.caller = m;
|
||||
this.$caller = i;
|
||||
const k = j.apply(this, arguments);
|
||||
this.$caller = m;
|
||||
this.caller = l;
|
||||
return k;
|
||||
}.extend({ $owner: g, $origin: j, $name: h });
|
||||
return i;
|
||||
};
|
||||
const f = function (h, i, g) {
|
||||
if (a.Mutators.hasOwnProperty(h)) {
|
||||
i = a.Mutators[h].call(this, i);
|
||||
if (i == null) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
if (typeOf(i) == 'function') {
|
||||
if (i.$hidden) {
|
||||
return this;
|
||||
}
|
||||
this.prototype[h] = (g) ? i : b(this, h, i);
|
||||
} else {
|
||||
Object.merge(this.prototype, h, i);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
const d = function (g) {
|
||||
g.$prototyping = true;
|
||||
const h = new g();
|
||||
delete g.$prototyping;
|
||||
return h;
|
||||
};
|
||||
a.implement('implement', f.overloadSetter());
|
||||
a.Mutators = {
|
||||
Extends(g) {
|
||||
this.parent = g;
|
||||
this.prototype = d(g);
|
||||
},
|
||||
Implements(g) {
|
||||
Array.from(g).each(function (j) {
|
||||
const h = new j();
|
||||
for (const i in h) {
|
||||
f.call(this, i, h[i], true);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
};
|
||||
}());
|
@ -1,271 +0,0 @@
|
||||
/*
|
||||
---
|
||||
MooTools: the javascript framework
|
||||
|
||||
web build:
|
||||
- http://mootools.net/core/b28139f033891d55fabb70ffafd6813b
|
||||
|
||||
packager build:
|
||||
- packager build Core/Core Core/Array Core/Class Core/Class.Extras
|
||||
|
||||
copyrights:
|
||||
- [MooTools](http://mootools.net)
|
||||
|
||||
licenses:
|
||||
- [MIT License](http://mootools.net/license.txt)
|
||||
...
|
||||
*/
|
||||
|
||||
(function () {
|
||||
this.MooTools = { version: '1.4.5', build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0' }; const o = this.typeOf = function (i) {
|
||||
if (i == null) { return 'null'; } if (i.$family != null) {
|
||||
return i.$family();
|
||||
} if (i.nodeName) { if (i.nodeType == 1) { return 'element'; } if (i.nodeType == 3) { return (/\S/).test(i.nodeValue) ? 'textnode' : 'whitespace'; } } else if (typeof i.length === 'number') {
|
||||
if (i.callee) {
|
||||
return 'arguments';
|
||||
} if ('item' in i) { return 'collection'; }
|
||||
} return typeof i;
|
||||
}; const j = this.instanceOf = function (t, i) {
|
||||
if (t == null) { return false; } let s = t.$constructor || t.constructor;
|
||||
while (s) { if (s === i) { return true; }s = s.parent; } if (!t.hasOwnProperty) { return false; } return t instanceof i;
|
||||
}; const f = this.Function; let p = true; for (const k in { toString: 1 }) {
|
||||
p = null;
|
||||
} if (p) { p = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor']; }f.prototype.overloadSetter = function (s) {
|
||||
const i = this;
|
||||
return function (u, t) {
|
||||
if (u == null) { return this; } if (s || typeof u !== 'string') {
|
||||
for (var v in u) { i.call(this, v, u[v]); } if (p) {
|
||||
for (let w = p.length; w--;) {
|
||||
v = p[w]; if (u.hasOwnProperty(v)) {
|
||||
i.call(this, v, u[v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { i.call(this, u, t); } return this;
|
||||
};
|
||||
}; f.prototype.overloadGetter = function (s) {
|
||||
const i = this; return function (u) {
|
||||
let v; let t; if (typeof u !== 'string') { v = u; } else if (arguments.length > 1) {
|
||||
v = arguments;
|
||||
} else if (s) { v = [u]; } if (v) { t = {}; for (let w = 0; w < v.length; w++) { t[v[w]] = i.call(this, v[w]); } } else { t = i.call(this, u); } return t;
|
||||
};
|
||||
}; f.prototype.extend = function (i, s) {
|
||||
this[i] = s;
|
||||
}.overloadSetter(); f.prototype.implement = function (i, s) { this.prototype[i] = s; }.overloadSetter(); const n = Array.prototype.slice; f.from = function (i) {
|
||||
return (o(i) == 'function') ? i : function () {
|
||||
return i;
|
||||
};
|
||||
}; Array.from = function (i) { if (i == null) { return []; } return (a.isEnumerable(i) && typeof i !== 'string') ? (o(i) == 'array') ? i : n.call(i) : [i]; }; Number.from = function (s) {
|
||||
const i = parseFloat(s);
|
||||
return isFinite(i) ? i : null;
|
||||
}; String.from = function (i) { return `${i}`; }; f.implement({
|
||||
hide() { this.$hidden = true; return this; },
|
||||
protect() {
|
||||
this.$protected = true;
|
||||
return this;
|
||||
},
|
||||
}); var a = this.Type = function (u, t) {
|
||||
if (u) {
|
||||
const s = u.toLowerCase(); const i = function (v) { return (o(v) == s); }; a[`is${u}`] = i; if (t != null) {
|
||||
t.prototype.$family = (function () {
|
||||
return s;
|
||||
}).hide();
|
||||
}
|
||||
} if (t == null) { return null; }t.extend(this); t.$constructor = a; t.prototype.$constructor = t; return t;
|
||||
}; const e = Object.prototype.toString; a.isEnumerable = function (i) {
|
||||
return (i != null && typeof i.length === 'number' && e.call(i) != '[object Function]');
|
||||
}; const q = {}; const r = function (i) { const s = o(i.prototype); return q[s] || (q[s] = []); }; var b = function (t, x) {
|
||||
if (x && x.$hidden) { return; } const s = r(this); for (let u = 0; u < s.length;
|
||||
u++) { const w = s[u]; if (o(w) == 'type') { b.call(w, t, x); } else { w.call(this, t, x); } } const v = this.prototype[t]; if (v == null || !v.$protected) { this.prototype[t] = x; } if (this[t] == null && o(x) == 'function') {
|
||||
m.call(this, t, function (i) {
|
||||
return x.apply(i, n.call(arguments, 1));
|
||||
});
|
||||
}
|
||||
}; var m = function (i, t) { if (t && t.$hidden) { return; } const s = this[i]; if (s == null || !s.$protected) { this[i] = t; } }; a.implement({
|
||||
implement: b.overloadSetter(),
|
||||
extend: m.overloadSetter(),
|
||||
alias: function (i, s) {
|
||||
b.call(this, i, this.prototype[s]);
|
||||
}.overloadSetter(),
|
||||
mirror(i) { r(this).push(i); return this; },
|
||||
}); new a('Type', a); var d = function (s, x, v) {
|
||||
const u = (x != Object); const B = x.prototype; if (u) {
|
||||
x = new a(s, x);
|
||||
} for (let y = 0, w = v.length; y < w; y++) { const C = v[y]; const A = x[C]; const z = B[C]; if (A) { A.protect(); } if (u && z) { x.implement(C, z.protect()); } } if (u) {
|
||||
const t = B.propertyIsEnumerable(v[0]);
|
||||
x.forEachMethod = function (G) { if (!t) { for (let F = 0, D = v.length; F < D; F++) { G.call(B, B[v[F]], v[F]); } } for (const E in B) { G.call(B, B[E], E); } };
|
||||
} return d;
|
||||
}; d('String', String, ['charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search', 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'])('Array', Array, ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice', 'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'])('Number', Number, ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision'])('Function', f, ['apply', 'call', 'bind'])('RegExp', RegExp, ['exec', 'test'])('Object', Object, ['create', 'defineProperty', 'defineProperties', 'keys', 'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen'])('Date', Date, ['now']);
|
||||
Object.extend = m.overloadSetter(); Date.extend('now', () => +(new Date())); new a('Boolean', Boolean); Number.prototype.$family = function () {
|
||||
return isFinite(this) ? 'number' : 'null';
|
||||
}.hide(); Number.extend('random', (s, i) => Math.floor(Math.random() * (i - s + 1) + s)); const g = Object.prototype.hasOwnProperty; Object.extend('forEach', (i, t, u) => {
|
||||
for (const s in i) {
|
||||
if (g.call(i, s)) {
|
||||
t.call(u, i[s], s, i);
|
||||
}
|
||||
}
|
||||
}); Object.each = Object.forEach; Array.implement({
|
||||
forEach(u, v) { for (let t = 0, s = this.length; t < s; t++) { if (t in this) { u.call(v, this[t], t, this); } } },
|
||||
each(i, s) {
|
||||
Array.forEach(this, i, s);
|
||||
return this;
|
||||
},
|
||||
}); const l = function (i) { switch (o(i)) { case 'array': return i.clone(); case 'object': return Object.clone(i); default: return i; } }; Array.implement('clone', function () {
|
||||
let s = this.length; const t = new Array(s);
|
||||
while (s--) { t[s] = l(this[s]); } return t;
|
||||
}); const h = function (s, i, t) {
|
||||
switch (o(t)) {
|
||||
case 'object': if (o(s[i]) == 'object') { Object.merge(s[i], t); } else {
|
||||
s[i] = Object.clone(t);
|
||||
} break; case 'array': s[i] = t.clone(); break; default: s[i] = t;
|
||||
} return s;
|
||||
}; Object.extend({
|
||||
merge(z, u, t) {
|
||||
if (o(u) == 'string') { return h(z, u, t); } for (let y = 1, s = arguments.length;
|
||||
y < s; y++) { const w = arguments[y]; for (const x in w) { h(z, x, w[x]); } } return z;
|
||||
},
|
||||
clone(i) { const t = {}; for (const s in i) { t[s] = l(i[s]); } return t; },
|
||||
append(w) {
|
||||
for (let v = 1, t = arguments.length;
|
||||
v < t; v++) { const s = arguments[v] || {}; for (const u in s) { w[u] = s[u]; } } return w;
|
||||
},
|
||||
}); ['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each((i) => {
|
||||
new a(i);
|
||||
}); let c = Date.now(); String.extend('uniqueID', () => (c++).toString(36));
|
||||
}()); Array.implement({
|
||||
every(c, d) {
|
||||
for (let b = 0, a = this.length >>> 0;
|
||||
b < a; b++) { if ((b in this) && !c.call(d, this[b], b, this)) { return false; } } return true;
|
||||
},
|
||||
filter(d, f) {
|
||||
const c = []; for (var e, b = 0, a = this.length >>> 0; b < a; b++) {
|
||||
if (b in this) {
|
||||
e = this[b];
|
||||
if (d.call(f, e, b, this)) { c.push(e); }
|
||||
}
|
||||
} return c;
|
||||
},
|
||||
indexOf(c, d) {
|
||||
const b = this.length >>> 0; for (let a = (d < 0) ? Math.max(0, b + d) : d || 0; a < b; a++) {
|
||||
if (this[a] === c) {
|
||||
return a;
|
||||
}
|
||||
} return -1;
|
||||
},
|
||||
map(c, e) { const d = this.length >>> 0; const b = Array(d); for (let a = 0; a < d; a++) { if (a in this) { b[a] = c.call(e, this[a], a, this); } } return b; },
|
||||
some(c, d) {
|
||||
for (let b = 0, a = this.length >>> 0;
|
||||
b < a; b++) { if ((b in this) && c.call(d, this[b], b, this)) { return true; } } return false;
|
||||
},
|
||||
clean() { return this.filter((a) => a != null); },
|
||||
invoke(a) {
|
||||
const b = Array.slice(arguments, 1);
|
||||
return this.map((c) => c[a].apply(c, b));
|
||||
},
|
||||
associate(c) {
|
||||
const d = {}; const b = Math.min(this.length, c.length); for (let a = 0; a < b; a++) {
|
||||
d[c[a]] = this[a];
|
||||
} return d;
|
||||
},
|
||||
link(c) { const a = {}; for (let e = 0, b = this.length; e < b; e++) { for (const d in c) { if (c[d](this[e])) { a[d] = this[e]; delete c[d]; break; } } } return a; },
|
||||
contains(a, b) {
|
||||
return this.indexOf(a, b) != -1;
|
||||
},
|
||||
append(a) { this.push.apply(this, a); return this; },
|
||||
getLast() { return (this.length) ? this[this.length - 1] : null; },
|
||||
getRandom() {
|
||||
return (this.length) ? this[Number.random(0, this.length - 1)] : null;
|
||||
},
|
||||
include(a) { if (!this.contains(a)) { this.push(a); } return this; },
|
||||
combine(c) {
|
||||
for (let b = 0, a = c.length; b < a; b++) { this.include(c[b]); } return this;
|
||||
},
|
||||
erase(b) { for (let a = this.length; a--;) { if (this[a] === b) { this.splice(a, 1); } } return this; },
|
||||
empty() { this.length = 0; return this; },
|
||||
flatten() {
|
||||
let d = [];
|
||||
for (let b = 0, a = this.length; b < a; b++) {
|
||||
const c = typeOf(this[b]); if (c == 'null') { continue; }d = d.concat((c == 'array' || c == 'collection' || c == 'arguments' || instanceOf(this[b], Array)) ? Array.flatten(this[b]) : this[b]);
|
||||
} return d;
|
||||
},
|
||||
pick() { for (let b = 0, a = this.length; b < a; b++) { if (this[b] != null) { return this[b]; } } return null; },
|
||||
rgbToHex(d) {
|
||||
if (this.length < 3) { return null; } if (this.length == 4 && this[3] == 0 && !d) {
|
||||
return 'transparent';
|
||||
} const b = []; for (let a = 0; a < 3; a++) { const c = (this[a] - 0).toString(16); b.push((c.length == 1) ? `0${c}` : c); } return (d) ? b : `#${b.join('')}`;
|
||||
},
|
||||
}); String.implement({
|
||||
test(a, b) {
|
||||
return ((typeOf(a) == 'regexp') ? a : new RegExp(`${a}`, b)).test(this);
|
||||
},
|
||||
contains(a, b) { return (b) ? (b + this + b).indexOf(b + a + b) > -1 : String(this).indexOf(a) > -1; },
|
||||
trim() {
|
||||
return String(this).replace(/^\s+|\s+$/g, '');
|
||||
},
|
||||
clean() { return String(this).replace(/\s+/g, ' ').trim(); },
|
||||
camelCase() {
|
||||
return String(this).replace(/-\D/g, (a) => a.charAt(1).toUpperCase());
|
||||
},
|
||||
hyphenate() { return String(this).replace(/[A-Z]/g, (a) => (`-${a.charAt(0).toLowerCase()}`)); },
|
||||
capitalize() {
|
||||
return String(this).replace(/\b[a-z]/g, (a) => a.toUpperCase());
|
||||
},
|
||||
escapeRegExp() { return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1'); },
|
||||
rgbToHex(b) {
|
||||
const a = String(this).match(/\d{1,3}/g);
|
||||
return (a) ? a.rgbToHex(b) : null;
|
||||
},
|
||||
substitute(a, b) {
|
||||
return String(this).replace(b || (/\\?\{([^{}]+)\}/g), (d, c) => {
|
||||
if (d.charAt(0) == '\\') {
|
||||
return d.slice(1);
|
||||
} return (a[c] != null) ? a[c] : '';
|
||||
});
|
||||
},
|
||||
});
|
||||
Function.implement({ bind(e) { const a = this; const b = arguments.length > 1 ? Array.slice(arguments, 1) : null; const d = function () {}; var c = function () { let g = e; const h = arguments.length; if (this instanceof c) { d.prototype = a.prototype; g = new d(); } const f = (!b && !h) ? a.call(g) : a.apply(g, b && h ? b.concat(Array.slice(arguments)) : b || arguments); return g == e ? f : g; }; return c; }, pass(b, c) { const a = this; if (b != null) { b = Array.from(b); } return function () { return a.apply(c, b || arguments); }; }, delay(b, c, a) { return setTimeout(this.pass((a == null ? [] : a), c), b); } });
|
||||
Number.alias('each', 'times'); (function (b) {
|
||||
const a = {}; b.each((c) => {
|
||||
if (!Number[c]) {
|
||||
a[c] = function () {
|
||||
return Math[c].apply(null, [this].concat(Array.from(arguments)));
|
||||
};
|
||||
}
|
||||
}); Number.implement(a);
|
||||
}(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan'])); (function () {
|
||||
var a = this.Class = new Type('Class', function (h) {
|
||||
if (instanceOf(h, Function)) {
|
||||
h = { initialize: h };
|
||||
} var g = function () {
|
||||
e(this); if (g.$prototyping) { return this; } this.$caller = null; const i = (this.initialize) ? this.initialize.apply(this, arguments) : this; this.$caller = this.caller = null;
|
||||
return i;
|
||||
}.extend(this).implement(h); g.$constructor = a; g.prototype.$constructor = g; g.prototype.parent = c; return g;
|
||||
}); var c = function () {
|
||||
if (!this.$caller) {
|
||||
throw new Error('The method "parent" cannot be called.');
|
||||
} const g = this.$caller.$name; const h = this.$caller.$owner.parent; const i = (h) ? h.prototype[g] : null; if (!i) { throw new Error(`The method "${g}" has no parent.`); } return i.apply(this, arguments);
|
||||
}; var e = function (g) {
|
||||
for (const h in g) {
|
||||
const j = g[h]; switch (typeOf(j)) {
|
||||
case 'object': var i = function () {}; i.prototype = j; g[h] = e(new i()); break; case 'array': g[h] = j.clone();
|
||||
break;
|
||||
}
|
||||
} return g;
|
||||
}; const b = function (g, h, j) {
|
||||
if (j.$origin) { j = j.$origin; } var i = function () {
|
||||
if (j.$protected && this.$caller == null) {
|
||||
throw new Error(`The method "${h}" cannot be called.`);
|
||||
} const l = this.caller; const m = this.$caller; this.caller = m; this.$caller = i; const k = j.apply(this, arguments); this.$caller = m; this.caller = l; return k;
|
||||
}.extend({ $owner: g, $origin: j, $name: h });
|
||||
return i;
|
||||
}; const f = function (h, i, g) {
|
||||
if (a.Mutators.hasOwnProperty(h)) { i = a.Mutators[h].call(this, i); if (i == null) { return this; } } if (typeOf(i) == 'function') {
|
||||
if (i.$hidden) {
|
||||
return this;
|
||||
} this.prototype[h] = (g) ? i : b(this, h, i);
|
||||
} else { Object.merge(this.prototype, h, i); } return this;
|
||||
}; const d = function (g) {
|
||||
g.$prototyping = true; const h = new g(); delete g.$prototyping;
|
||||
return h;
|
||||
}; a.implement('implement', f.overloadSetter()); a.Mutators = { Extends(g) { this.parent = g; this.prototype = d(g); }, Implements(g) { Array.from(g).each(function (j) { const h = new j(); for (const i in h) { f.call(this, i, h[i], true); } }, this); } };
|
||||
}());
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -363,7 +363,7 @@ class INodeModel {
|
||||
|
||||
/** @abstract */
|
||||
removeChild(child) {
|
||||
throw 'Unsupported operation';
|
||||
throw new Error('Unsupported operation');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class LinkModel extends FeatureModel {
|
||||
}
|
||||
|
||||
// url format is already checked in LinkEditor.checkUrl
|
||||
_fixUrl(url) {
|
||||
static _fixUrl(url) {
|
||||
let result = url;
|
||||
if (!result.contains('http://') && !result.contains('https://') && !result.contains('mailto://')) {
|
||||
result = `http://${result}`;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import IMindmap from './IMindmap';
|
||||
import INodeModel from './INodeModel';
|
||||
import NodeModel from './NodeModel';
|
||||
@ -71,10 +72,10 @@ class Mindmap extends IMindmap {
|
||||
$assert(nodeModel && nodeModel.isNodeModel(), 'Add node must be invoked with model objects');
|
||||
const branches = this.getBranches();
|
||||
if (branches.length === 0) {
|
||||
$assert(nodeModel.getType() == INodeModel.CENTRAL_TOPIC_TYPE, 'First element must be the central topic');
|
||||
$assert(nodeModel.getType() === INodeModel.CENTRAL_TOPIC_TYPE, 'First element must be the central topic');
|
||||
nodeModel.setPosition(0, 0);
|
||||
} else {
|
||||
$assert(nodeModel.getType() != INodeModel.CENTRAL_TOPIC_TYPE, 'Mindmaps only have one cental topic');
|
||||
$assert(nodeModel.getType() !== INodeModel.CENTRAL_TOPIC_TYPE, 'Mindmaps only have one cental topic');
|
||||
}
|
||||
|
||||
this._branches.push(nodeModel);
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import INodeModel from './INodeModel';
|
||||
import TopicFeature from '../TopicFeature';
|
||||
|
||||
@ -63,7 +64,7 @@ class NodeModel extends INodeModel {
|
||||
removeFeature(feature) {
|
||||
$assert(feature, 'feature can not be null');
|
||||
const size = this._feature.length;
|
||||
this._feature = this._feature.filter((f) => feature.getId() != f.getId());
|
||||
this._feature = this._feature.filter((f) => feature.getId() !== f.getId());
|
||||
$assert(size - 1 === this._feature.length, 'Could not be removed ...');
|
||||
}
|
||||
|
||||
@ -190,7 +191,7 @@ class NodeModel extends INodeModel {
|
||||
|
||||
_isChildNode(node) {
|
||||
let result = false;
|
||||
if (node == this) {
|
||||
if (node === this) {
|
||||
result = true;
|
||||
} else {
|
||||
const children = this.getChildren();
|
||||
@ -211,7 +212,7 @@ class NodeModel extends INodeModel {
|
||||
*/
|
||||
findNodeById(id) {
|
||||
let result = null;
|
||||
if (this.getId() == id) {
|
||||
if (this.getId() === id) {
|
||||
result = this;
|
||||
} else {
|
||||
const children = this.getChildren();
|
||||
|
@ -1,21 +0,0 @@
|
||||
import featureModel from './FeatureModel';
|
||||
import iconModel from './IconModel';
|
||||
import iMindmap from './IMindmap';
|
||||
import iNodeModel from './INodeModel';
|
||||
import linkModel from './LinkModel';
|
||||
import noteModel from './NoteModel';
|
||||
import mindmap from './Mindmap';
|
||||
import nodeModel from './NodeModel';
|
||||
import relationshipModel from './RelationshipModel';
|
||||
|
||||
export default {
|
||||
FeatureModel: featureModel,
|
||||
IconModel: iconModel,
|
||||
IMindmap: iMindmap,
|
||||
INodeModel: iNodeModel,
|
||||
LinkModel: linkModel,
|
||||
NoteModel: noteModel,
|
||||
Mindmap: mindmap,
|
||||
NodeModel: nodeModel,
|
||||
RelationshipModel: relationshipModel,
|
||||
};
|
@ -15,17 +15,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import _ from '@libraries/underscore-min';
|
||||
import { $assert, $defined } from '@wisemapping/core-js';
|
||||
import ToolbarPaneItem from './ToolbarPaneItem';
|
||||
|
||||
const ColorPalettePanel = new Class({
|
||||
Extends: ToolbarPaneItem,
|
||||
|
||||
initialize(buttonId, model, baseUrl) {
|
||||
class ColorPalettePanel extends ToolbarPaneItem {
|
||||
constructor(buttonId, model, baseUrl) {
|
||||
super(buttonId, model);
|
||||
this._baseUrl = baseUrl;
|
||||
this.parent(buttonId, model);
|
||||
$assert($defined(baseUrl), 'baseUrl can not be null');
|
||||
},
|
||||
}
|
||||
|
||||
_load() {
|
||||
if (!ColorPalettePanel._panelContent) {
|
||||
@ -52,7 +52,7 @@ const ColorPalettePanel = new Class({
|
||||
ColorPalettePanel._panelContent = result;
|
||||
}
|
||||
return ColorPalettePanel._panelContent;
|
||||
},
|
||||
}
|
||||
|
||||
buildPanel() {
|
||||
const content = $('<div class="toolbarPanel"></div>').attr(
|
||||
@ -74,7 +74,7 @@ const ColorPalettePanel = new Class({
|
||||
});
|
||||
|
||||
return content;
|
||||
},
|
||||
}
|
||||
|
||||
_updateSelectedItem() {
|
||||
const panelElem = this.getPanelElem();
|
||||
@ -99,7 +99,7 @@ const ColorPalettePanel = new Class({
|
||||
}
|
||||
});
|
||||
return panelElem;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ColorPalettePanel;
|
||||
|
@ -15,32 +15,29 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import Options from '../Options';
|
||||
import Events from '../Events';
|
||||
|
||||
const FloatingTip = new Class({
|
||||
Implements: [Options, Events],
|
||||
// const options = {
|
||||
// animation: true,
|
||||
// html: false,
|
||||
// placement: 'right',
|
||||
// selector: false,
|
||||
// trigger: 'hover',
|
||||
// title: '',
|
||||
// content: '',
|
||||
// delay: 0,
|
||||
// container: false,
|
||||
// destroyOnExit: false,
|
||||
// };
|
||||
|
||||
options: {
|
||||
animation: true,
|
||||
html: false,
|
||||
placement: 'right',
|
||||
selector: false,
|
||||
trigger: 'hover',
|
||||
title: '',
|
||||
content: '',
|
||||
delay: 0,
|
||||
container: false,
|
||||
destroyOnExit: false,
|
||||
},
|
||||
|
||||
initialize(element, options) {
|
||||
class FloatingTip extends Events {
|
||||
constructor(element, options) {
|
||||
super(element, options);
|
||||
this.setOptions(options);
|
||||
this.element = element;
|
||||
this._createPopover();
|
||||
},
|
||||
}
|
||||
|
||||
// FIXME: find a better way to do that...
|
||||
_createPopover() {
|
||||
this.element.popover(this.options);
|
||||
const me = this;
|
||||
@ -50,19 +47,30 @@ const FloatingTip = new Class({
|
||||
me._createPopover();
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
show() {
|
||||
this.element.popover('show');
|
||||
this.fireEvent('show');
|
||||
return this;
|
||||
},
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.element.popover('hide');
|
||||
this.fireEvent('hide');
|
||||
return this;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
setOptions() {
|
||||
const options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));
|
||||
if (this.addEvent) {
|
||||
for (const option in options) {
|
||||
if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
|
||||
this.addEvent(option, options[option]);
|
||||
delete options[option];
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
export default FloatingTip;
|
||||
|
@ -15,24 +15,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import ListToolbarPanel from './ListToolbarPanel';
|
||||
|
||||
const FontFamilyPanel = new Class({
|
||||
Extends: ListToolbarPanel,
|
||||
initialize(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
class FontFamilyPanel extends ListToolbarPanel {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
buildPanel() {
|
||||
const content = $("<div class='toolbarPanel' id='fontFamilyPanel'></div>");
|
||||
content.html(
|
||||
'<div id="times" model="Times" class="toolbarPanelLink" style="font-family:times;">Times</div>'
|
||||
+ '<div id="arial" model="Arial" style="font-family:arial;">Arial</div>'
|
||||
+ '<div id="tahoma" model="Tahoma" style="font-family:tahoma;">Tahoma</div>'
|
||||
+ '<div id="verdana" model="Verdana" style="font-family:verdana;">Verdana</div>',
|
||||
+ '<div id="arial" model="Arial" style="font-family:arial;">Arial</div>'
|
||||
+ '<div id="tahoma" model="Tahoma" style="font-family:tahoma;">Tahoma</div>'
|
||||
+ '<div id="verdana" model="Verdana" style="font-family:verdana;">Verdana</div>',
|
||||
);
|
||||
return content;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default FontFamilyPanel;
|
||||
|
@ -16,23 +16,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import ListToolbarPanel from './ListToolbarPanel';
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
|
||||
const FontSizePanel = new Class({
|
||||
Extends: ListToolbarPanel,
|
||||
initialize(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
class FontSizePanel extends ListToolbarPanel {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
buildPanel() {
|
||||
const content = $("<div class='toolbarPanel' id='fontSizePanel'></div>");
|
||||
content[0].innerHTML = ''
|
||||
+ '<div id="small" model="6" style="font-size:8px">Small</div>'
|
||||
+ '<div id="normal" model="8" style="font-size:12px">Normal</div>'
|
||||
+ '<div id="large" model="10" style="font-size:15px">Large</div>'
|
||||
+ '<div id="huge" model="15" style="font-size:24px">Huge</div>';
|
||||
+ '<div id="small" model="6" style="font-size:8px">Small</div>'
|
||||
+ '<div id="normal" model="8" style="font-size:12px">Normal</div>'
|
||||
+ '<div id="large" model="10" style="font-size:15px">Large</div>'
|
||||
+ '<div id="huge" model="15" style="font-size:24px">Huge</div>';
|
||||
|
||||
return content;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default FontSizePanel;
|
||||
|
@ -15,18 +15,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import ToolbarPaneItem from './ToolbarPaneItem';
|
||||
import ImageIcon from '../ImageIcon';
|
||||
|
||||
const IconPanel = new Class({
|
||||
Extends: ToolbarPaneItem,
|
||||
initialize(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
class IconPanel extends ToolbarPaneItem {
|
||||
_updateSelectedItem() {
|
||||
return this.getPanelElem();
|
||||
},
|
||||
}
|
||||
|
||||
buildPanel() {
|
||||
const content = $('<div class="toolbarPanel" id="IconsPanel"></div>').css({ width: 245, height: 230 });
|
||||
@ -44,7 +40,7 @@ const IconPanel = new Class({
|
||||
familyContent = $('<div></div>');
|
||||
content.append(familyContent);
|
||||
}
|
||||
|
||||
|
||||
const iconId = familyIcons[j];
|
||||
const img = $('<img>')
|
||||
.attr('id', iconId)
|
||||
@ -53,8 +49,8 @@ const IconPanel = new Class({
|
||||
|
||||
familyContent.append(img);
|
||||
|
||||
var panel = this;
|
||||
var model = this.getModel();
|
||||
const panel = this;
|
||||
const model = this.getModel();
|
||||
img.on('click', function (event) {
|
||||
model.setValue($(this).attr('id'));
|
||||
panel.hide();
|
||||
@ -64,7 +60,7 @@ const IconPanel = new Class({
|
||||
}
|
||||
}
|
||||
return content;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default IconPanel;
|
||||
|
@ -15,16 +15,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import FloatingTip from './FloatingTip';
|
||||
|
||||
const KeyboardShortcutTooltip = new Class({
|
||||
Extends: FloatingTip,
|
||||
|
||||
initialize(buttonElem, text) {
|
||||
class KeyboardShortcutTooltip extends FloatingTip {
|
||||
constructor(buttonElem, text) {
|
||||
$assert(buttonElem, 'buttonElem can not be null');
|
||||
$assert(text, 'text can not be null');
|
||||
this._text = text;
|
||||
|
||||
const children = buttonElem.children().first();
|
||||
const tipElemId = `${buttonElem.attr('id')}Tip`;
|
||||
@ -32,21 +30,21 @@ const KeyboardShortcutTooltip = new Class({
|
||||
tipDiv.append(children);
|
||||
buttonElem.append(tipDiv);
|
||||
|
||||
this.parent(tipDiv, {
|
||||
super(tipDiv, {
|
||||
// Content can also be a function of the target element!
|
||||
content: this._buildContent(),
|
||||
content: KeyboardShortcutTooltip._buildContent(),
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
className: 'keyboardShortcutTip',
|
||||
template: '<div class="popover popoverBlack" role="tooltip"><div class="arrow arrowBlack"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
||||
});
|
||||
|
||||
this._text = text;
|
||||
tipDiv.on('click', (e) => {
|
||||
tipDiv.trigger('mouseleave', e);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_buildContent() {
|
||||
static _buildContent() {
|
||||
const result = $('<div></div>');
|
||||
result.css({
|
||||
padding: '3px 0px',
|
||||
@ -64,7 +62,7 @@ const KeyboardShortcutTooltip = new Class({
|
||||
|
||||
result.append(textContainer);
|
||||
return result;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default KeyboardShortcutTooltip;
|
||||
|
@ -17,15 +17,13 @@
|
||||
*/
|
||||
import FloatingTip from './FloatingTip';
|
||||
|
||||
const LinkIconTooltip = new Class({
|
||||
Extends: FloatingTip,
|
||||
|
||||
initialize(linkIcon) {
|
||||
class LinkIconTooltip extends FloatingTip {
|
||||
constructor(linkIcon) {
|
||||
$assert(linkIcon, 'linkIcon can not be null');
|
||||
const nativeElement = $(linkIcon.getImage().peer._native);
|
||||
this.parent(nativeElement, {
|
||||
super(nativeElement, {
|
||||
// Content can also be a function of the target element!
|
||||
content: this._buildContent(linkIcon),
|
||||
content: LinkIconTooltip._buildContent(linkIcon),
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
container: 'body',
|
||||
@ -33,9 +31,9 @@ const LinkIconTooltip = new Class({
|
||||
trigger: 'manual',
|
||||
template: '<div id="linkPopover" class="popover" onmouseover="$(this).mouseleave(function() {$(this).fadeOut(200); });" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_buildContent(linkIcon) {
|
||||
static _buildContent(linkIcon) {
|
||||
const result = $('<div></div>').css({
|
||||
padding: '5px',
|
||||
width: '100%',
|
||||
@ -73,7 +71,7 @@ const LinkIconTooltip = new Class({
|
||||
imgContainer.append(link);
|
||||
result.append(imgContainer);
|
||||
return result;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default LinkIconTooltip;
|
||||
|
@ -17,12 +17,11 @@
|
||||
*/
|
||||
import ToolbarPaneItem from './ToolbarPaneItem';
|
||||
|
||||
const ListToolbarPanel = new Class({
|
||||
Extends: ToolbarPaneItem,
|
||||
initialize(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
class ListToolbarPanel extends ToolbarPaneItem {
|
||||
constructor(buttonId, model) {
|
||||
super(buttonId, model);
|
||||
this._initPanel();
|
||||
},
|
||||
}
|
||||
|
||||
_initPanel() {
|
||||
// Register on toolbar elements ...
|
||||
@ -33,7 +32,7 @@ const ListToolbarPanel = new Class({
|
||||
const value = $defined($(this).attr('model')) ? $(this).attr('model') : $(this).attr('id');
|
||||
me.getModel().setValue(value);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_updateSelectedItem() {
|
||||
const panelElem = this.getPanelElem();
|
||||
@ -42,11 +41,11 @@ const ListToolbarPanel = new Class({
|
||||
_.each(menuElems, (elem) => {
|
||||
const elemValue = $defined($(elem).attr('model')) ? $(elem).attr('model') : $(elem).attr('id');
|
||||
$assert(elemValue, 'elemValue can not be null');
|
||||
if (elemValue == value) $(elem).attr('class', 'toolbarPanelLinkSelectedLink');
|
||||
if (elemValue === value) $(elem).attr('class', 'toolbarPanelLinkSelectedLink');
|
||||
else $(elem).attr('class', 'toolbarPanelLink');
|
||||
});
|
||||
return panelElem;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ListToolbarPanel;
|
||||
|
@ -15,6 +15,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import _ from '@libraries/underscore-min';
|
||||
|
||||
import { $defined } from '@wisemapping/core-js';
|
||||
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
|
||||
import IMenu from './IMenu';
|
||||
@ -26,11 +29,10 @@ import ColorPalettePanel from './ColorPalettePanel';
|
||||
import ToolbarItem from './ToolbarItem';
|
||||
import KeyboardShortcutTooltip from './KeyboardShortcutTooltip';
|
||||
|
||||
const Menu = new Class({
|
||||
Extends: IMenu,
|
||||
|
||||
initialize(designer, containerId, mapId, readOnly, baseUrl) {
|
||||
this.parent(designer, containerId, mapId);
|
||||
class Menu extends IMenu {
|
||||
constructor(designer, containerId, mapId, readOnly, baseUrl) {
|
||||
super(designer, containerId, mapId);
|
||||
const saveElem = $('#save');
|
||||
|
||||
baseUrl = !$defined(baseUrl) ? '' : baseUrl;
|
||||
const widgetsBaseUrl = `${baseUrl}css/widget`;
|
||||
@ -57,7 +59,7 @@ const Menu = new Class({
|
||||
let result = null;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const fontFamily = nodes[i].getFontFamily();
|
||||
if (result != null && result != fontFamily) {
|
||||
if (result != null && result !== fontFamily) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
@ -71,7 +73,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new FontFamilyPanel('fontFamily', fontFamilyModel));
|
||||
this._registerTooltip('fontFamily', $msg('FONT_FAMILY'));
|
||||
Menu._registerTooltip('fontFamily', $msg('FONT_FAMILY'));
|
||||
}
|
||||
|
||||
const fontSizeBtn = $('#fontSize');
|
||||
@ -82,7 +84,7 @@ const Menu = new Class({
|
||||
let result = null;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const fontSize = nodes[i].getFontSize();
|
||||
if (result != null && result != fontSize) {
|
||||
if (result != null && result !== fontSize) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
@ -95,7 +97,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new FontSizePanel('fontSize', fontSizeModel));
|
||||
this._registerTooltip('fontSize', $msg('FONT_SIZE'));
|
||||
Menu._registerTooltip('fontSize', $msg('FONT_SIZE'));
|
||||
}
|
||||
|
||||
const topicShapeBtn = $('#topicShape');
|
||||
@ -106,7 +108,7 @@ const Menu = new Class({
|
||||
let result = null;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const shapeType = nodes[i].getShapeType();
|
||||
if (result != null && result != shapeType) {
|
||||
if (result != null && result !== shapeType) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
@ -119,7 +121,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new TopicShapePanel('topicShape', topicShapeModel));
|
||||
this._registerTooltip('topicShape', $msg('TOPIC_SHAPE'));
|
||||
Menu._registerTooltip('topicShape', $msg('TOPIC_SHAPE'));
|
||||
}
|
||||
|
||||
const topicIconBtn = $('#topicIcon');
|
||||
@ -134,7 +136,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new IconPanel('topicIcon', topicIconModel));
|
||||
this._registerTooltip('topicIcon', $msg('TOPIC_ICON'));
|
||||
Menu._registerTooltip('topicIcon', $msg('TOPIC_ICON'));
|
||||
}
|
||||
|
||||
// Topic color item ...
|
||||
@ -146,7 +148,7 @@ const Menu = new Class({
|
||||
let result = null;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const color = nodes[i].getBackgroundColor();
|
||||
if (result != null && result != color) {
|
||||
if (result != null && result !== color) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
@ -159,7 +161,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new ColorPalettePanel('topicColor', topicColorModel, widgetsBaseUrl));
|
||||
this._registerTooltip('topicColor', $msg('TOPIC_COLOR'));
|
||||
Menu._registerTooltip('topicColor', $msg('TOPIC_COLOR'));
|
||||
}
|
||||
|
||||
// Border color item ...
|
||||
@ -171,7 +173,7 @@ const Menu = new Class({
|
||||
let result = null;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const color = nodes[i].getBorderColor();
|
||||
if (result != null && result != color) {
|
||||
if (result != null && result !== color) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
@ -184,7 +186,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new ColorPalettePanel('topicBorder', borderColorModel, widgetsBaseUrl));
|
||||
this._registerTooltip('topicBorder', $msg('TOPIC_BORDER_COLOR'));
|
||||
Menu._registerTooltip('topicBorder', $msg('TOPIC_BORDER_COLOR'));
|
||||
}
|
||||
|
||||
// Font color item ...
|
||||
@ -196,7 +198,7 @@ const Menu = new Class({
|
||||
const nodes = designerModel.filterSelectedTopics();
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const color = nodes[i].getFontColor();
|
||||
if (result != null && result != color) {
|
||||
if (result != null && result !== color) {
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
@ -209,7 +211,7 @@ const Menu = new Class({
|
||||
},
|
||||
};
|
||||
this._toolbarElems.push(new ColorPalettePanel('fontColor', fontColorModel, baseUrl));
|
||||
this._registerTooltip('fontColor', $msg('FONT_COLOR'));
|
||||
Menu._registerTooltip('fontColor', $msg('FONT_COLOR'));
|
||||
}
|
||||
|
||||
this._addButton('export', false, false, () => {
|
||||
@ -218,7 +220,7 @@ const Menu = new Class({
|
||||
closeButton: true,
|
||||
});
|
||||
});
|
||||
this._registerTooltip('export', $msg('EXPORT'));
|
||||
Menu._registerTooltip('export', $msg('EXPORT'));
|
||||
|
||||
const me = this;
|
||||
|
||||
@ -228,17 +230,17 @@ const Menu = new Class({
|
||||
window.open(`${baseUrl}c/maps/${mapId}/print`);
|
||||
});
|
||||
|
||||
this._registerTooltip('print', $msg('PRINT'));
|
||||
Menu._registerTooltip('print', $msg('PRINT'));
|
||||
|
||||
this._addButton('zoomIn', false, false, () => {
|
||||
designer.zoomIn();
|
||||
});
|
||||
this._registerTooltip('zoomIn', $msg('ZOOM_IN'));
|
||||
Menu._registerTooltip('zoomIn', $msg('ZOOM_IN'));
|
||||
|
||||
this._addButton('zoomOut', false, false, () => {
|
||||
designer.zoomOut();
|
||||
});
|
||||
this._registerTooltip('zoomOut', $msg('ZOOM_OUT'));
|
||||
Menu._registerTooltip('zoomOut', $msg('ZOOM_OUT'));
|
||||
|
||||
const undoButton = this._addButton('undoEdition', false, false, () => {
|
||||
designer.undo();
|
||||
@ -246,7 +248,7 @@ const Menu = new Class({
|
||||
if (undoButton) {
|
||||
undoButton.disable();
|
||||
}
|
||||
this._registerTooltip('undoEdition', $msg('UNDO'), 'meta+Z');
|
||||
Menu._registerTooltip('undoEdition', $msg('UNDO'), 'meta+Z');
|
||||
|
||||
const redoButton = this._addButton('redoEdition', false, false, () => {
|
||||
designer.redo();
|
||||
@ -254,7 +256,7 @@ const Menu = new Class({
|
||||
if (redoButton) {
|
||||
redoButton.disable();
|
||||
}
|
||||
this._registerTooltip('redoEdition', $msg('REDO'), 'meta+shift+Z');
|
||||
Menu._registerTooltip('redoEdition', $msg('REDO'), 'meta+shift+Z');
|
||||
|
||||
if (redoButton && undoButton) {
|
||||
designer.addEvent('modelUpdate', (event) => {
|
||||
@ -274,45 +276,44 @@ const Menu = new Class({
|
||||
this._addButton('addTopic', true, false, () => {
|
||||
designer.createSiblingForSelectedNode();
|
||||
});
|
||||
this._registerTooltip('addTopic', $msg('ADD_TOPIC'), 'Enter');
|
||||
Menu._registerTooltip('addTopic', $msg('ADD_TOPIC'), 'Enter');
|
||||
|
||||
this._addButton('deleteTopic', true, true, () => {
|
||||
designer.deleteSelectedEntities();
|
||||
});
|
||||
this._registerTooltip('deleteTopic', $msg('TOPIC_DELETE'), 'Delete');
|
||||
Menu._registerTooltip('deleteTopic', $msg('TOPIC_DELETE'), 'Delete');
|
||||
|
||||
this._addButton('topicLink', true, false, () => {
|
||||
designer.addLink();
|
||||
});
|
||||
this._registerTooltip('topicLink', $msg('TOPIC_LINK'));
|
||||
Menu._registerTooltip('topicLink', $msg('TOPIC_LINK'));
|
||||
|
||||
this._addButton('topicRelation', true, false, (event) => {
|
||||
designer.showRelPivot(event);
|
||||
});
|
||||
this._registerTooltip('topicRelation', $msg('TOPIC_RELATIONSHIP'));
|
||||
Menu._registerTooltip('topicRelation', $msg('TOPIC_RELATIONSHIP'));
|
||||
|
||||
this._addButton('topicNote', true, false, () => {
|
||||
designer.addNote();
|
||||
});
|
||||
this._registerTooltip('topicNote', $msg('TOPIC_NOTE'));
|
||||
Menu._registerTooltip('topicNote', $msg('TOPIC_NOTE'));
|
||||
|
||||
this._addButton('fontBold', true, false, () => {
|
||||
designer.changeFontWeight();
|
||||
});
|
||||
this._registerTooltip('fontBold', $msg('FONT_BOLD'), 'meta+B');
|
||||
Menu._registerTooltip('fontBold', $msg('FONT_BOLD'), 'meta+B');
|
||||
|
||||
this._addButton('fontItalic', true, false, () => {
|
||||
designer.changeFontStyle();
|
||||
});
|
||||
this._registerTooltip('fontItalic', $msg('FONT_ITALIC'), 'meta+I');
|
||||
Menu._registerTooltip('fontItalic', $msg('FONT_ITALIC'), 'meta+I');
|
||||
|
||||
var saveElem = $('#save');
|
||||
if (saveElem) {
|
||||
this._addButton('save', false, false,
|
||||
() => {
|
||||
me.save(saveElem, designer, true);
|
||||
});
|
||||
this._registerTooltip('save', $msg('SAVE'), 'meta+S');
|
||||
Menu._registerTooltip('save', $msg('SAVE'), 'meta+S');
|
||||
|
||||
if (!readOnly) {
|
||||
// To prevent the user from leaving the page with changes ...
|
||||
@ -340,7 +341,7 @@ const Menu = new Class({
|
||||
this._addButton('discard', false, false, () => {
|
||||
me.discardChanges(designer);
|
||||
});
|
||||
this._registerTooltip('discard', $msg('DISCARD_CHANGES'));
|
||||
Menu._registerTooltip('discard', $msg('DISCARD_CHANGES'));
|
||||
}
|
||||
|
||||
const shareElem = $('#shareIt');
|
||||
@ -352,7 +353,7 @@ const Menu = new Class({
|
||||
});
|
||||
designer.onObjectFocusEvent();
|
||||
});
|
||||
this._registerTooltip('shareIt', $msg('COLLABORATE'));
|
||||
Menu._registerTooltip('shareIt', $msg('COLLABORATE'));
|
||||
}
|
||||
|
||||
const publishElem = $('#publishIt');
|
||||
@ -364,7 +365,7 @@ const Menu = new Class({
|
||||
});
|
||||
designer.onObjectFocusEvent();
|
||||
});
|
||||
this._registerTooltip('publishIt', $msg('PUBLISH'));
|
||||
Menu._registerTooltip('publishIt', $msg('PUBLISH'));
|
||||
}
|
||||
|
||||
const historyElem = $('#history');
|
||||
@ -376,7 +377,7 @@ const Menu = new Class({
|
||||
});
|
||||
designer.onObjectFocusEvent();
|
||||
});
|
||||
this._registerTooltip('history', $msg('HISTORY'));
|
||||
Menu._registerTooltip('history', $msg('HISTORY'));
|
||||
}
|
||||
|
||||
this._registerEvents(designer);
|
||||
@ -406,7 +407,7 @@ const Menu = new Class({
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
_registerEvents(designer) {
|
||||
const me = this;
|
||||
@ -454,7 +455,7 @@ const Menu = new Class({
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
_addButton(buttonId, topic, rel, fn) {
|
||||
const me = this;
|
||||
@ -470,18 +471,18 @@ const Menu = new Class({
|
||||
result = button;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
}
|
||||
|
||||
_registerTooltip(buttonId, text, shortcut) {
|
||||
static _registerTooltip(buttonId, text, shortcut) {
|
||||
if ($(`#${buttonId}`)) {
|
||||
let tooltip = text;
|
||||
if (shortcut) {
|
||||
shortcut = navigator.appVersion.indexOf('Mac') != -1 ? shortcut.replace('meta+', '⌘') : shortcut.replace('meta+', 'ctrl+');
|
||||
shortcut = navigator.appVersion.indexOf('Mac') !== -1 ? shortcut.replace('meta+', '⌘') : shortcut.replace('meta+', 'ctrl+');
|
||||
tooltip = `${tooltip} (${shortcut})`;
|
||||
}
|
||||
new KeyboardShortcutTooltip($(`#${buttonId}`), tooltip);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Menu;
|
||||
|
@ -15,6 +15,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import jQuery from '@libraries/jquery-2.1.0';
|
||||
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
|
||||
|
||||
const NoteEditor = new Class({
|
||||
|
@ -15,42 +15,49 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Events from '../Events';
|
||||
|
||||
const ToolbarItem = new Class({
|
||||
Implements: Events, // FIXME: should be extends?
|
||||
initialize(buttonId, fn, options) {
|
||||
class ToolbarItem extends Events {
|
||||
constructor(buttonId, fn, options) {
|
||||
$assert(buttonId, 'buttonId can not be null');
|
||||
$assert(fn, 'fn can not be null');
|
||||
super();
|
||||
this._buttonId = buttonId;
|
||||
this._fn = fn;
|
||||
this._options = options;
|
||||
if (fn) {
|
||||
this.setEventHandler(fn);
|
||||
}
|
||||
}
|
||||
|
||||
setEventHandler(fn) {
|
||||
$assert(fn, 'fn can not be null');
|
||||
this._fn = fn;
|
||||
this._enable = false;
|
||||
this.enable();
|
||||
},
|
||||
}
|
||||
|
||||
getButtonElem: function () {
|
||||
getButtonElem() {
|
||||
const elem = $(`#${this._buttonId}`);
|
||||
$assert(elem, `Could not find element for ${this._buttonId}`);
|
||||
return elem;
|
||||
}.protect(),
|
||||
}
|
||||
|
||||
show() {
|
||||
this.fireEvent('show');
|
||||
},
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.fireEvent('hide');
|
||||
},
|
||||
}
|
||||
|
||||
isTopicAction() {
|
||||
return this._options.topicAction;
|
||||
},
|
||||
}
|
||||
|
||||
isRelAction() {
|
||||
return this._options.relAction;
|
||||
},
|
||||
}
|
||||
|
||||
disable() {
|
||||
const elem = this.getButtonElem();
|
||||
@ -60,7 +67,7 @@ const ToolbarItem = new Class({
|
||||
elem.addClass('buttonOff');
|
||||
this._enable = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
enable() {
|
||||
const elem = this.getButtonElem();
|
||||
@ -70,11 +77,11 @@ const ToolbarItem = new Class({
|
||||
elem.addClass('buttonOn');
|
||||
this._enable = true;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
getTip: function () {
|
||||
getTip() {
|
||||
return this._tip;
|
||||
}.protect(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ToolbarItem;
|
||||
|
@ -19,21 +19,18 @@ import { $assert } from '@wisemapping/core-js';
|
||||
import ToolbarItem from './ToolbarItem';
|
||||
import FloatingTip from './FloatingTip';
|
||||
|
||||
const ToolbarPaneItem = new Class({
|
||||
Extends: ToolbarItem,
|
||||
initialize(buttonId, model) {
|
||||
class ToolbarPaneItem extends ToolbarItem {
|
||||
constructor(buttonId, model) {
|
||||
$assert(buttonId, 'buttonId can not be null');
|
||||
$assert(model, 'model can not be null');
|
||||
super(buttonId, null, { topicAction: true, relAction: false });
|
||||
|
||||
const handler = () => (this.isVisible() ? this.hide() : this.show());
|
||||
this.setEventHandler(handler);
|
||||
this._model = model;
|
||||
const me = this;
|
||||
const fn = () => {
|
||||
return me.isVisible() ? me.hide() : me.show();
|
||||
};
|
||||
|
||||
this.parent(buttonId, fn, { topicAction: true, relAction: false });
|
||||
this._panelElem = this._init();
|
||||
this._visible = false;
|
||||
},
|
||||
}
|
||||
|
||||
_init() {
|
||||
// Load the context of the panel ...
|
||||
@ -51,7 +48,7 @@ const ToolbarPaneItem = new Class({
|
||||
className: 'toolbarPaneTip',
|
||||
trigger: 'manual',
|
||||
template:
|
||||
'<div class="popover popoverGray" role="tooltip"><div class="arrow arrowGray"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
||||
'<div class="popover popoverGray" role="tooltip"><div class="arrow arrowGray"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
||||
});
|
||||
|
||||
this._tip.addEvent('hide', () => {
|
||||
@ -63,15 +60,15 @@ const ToolbarPaneItem = new Class({
|
||||
});
|
||||
|
||||
return panelElem;
|
||||
},
|
||||
}
|
||||
|
||||
getModel() {
|
||||
return this._model;
|
||||
},
|
||||
}
|
||||
|
||||
getPanelElem: function () {
|
||||
getPanelElem() {
|
||||
return this._panelElem;
|
||||
}.protect(),
|
||||
}
|
||||
|
||||
show() {
|
||||
if (!this.isVisible()) {
|
||||
@ -79,7 +76,7 @@ const ToolbarPaneItem = new Class({
|
||||
this._tip.show();
|
||||
this.getButtonElem().className = 'buttonExtActive';
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
hide() {
|
||||
if (this.isVisible()) {
|
||||
@ -87,11 +84,11 @@ const ToolbarPaneItem = new Class({
|
||||
this._tip.hide();
|
||||
this.getButtonElem().className = 'buttonExtOn';
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
isVisible() {
|
||||
return this._visible;
|
||||
},
|
||||
}
|
||||
|
||||
disable() {
|
||||
this.hide();
|
||||
@ -106,7 +103,7 @@ const ToolbarPaneItem = new Class({
|
||||
elem.addClass('buttonExtOff');
|
||||
this._enable = false;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
enable() {
|
||||
const elem = this.getButtonElem();
|
||||
@ -116,11 +113,12 @@ const ToolbarPaneItem = new Class({
|
||||
elem.addClass('buttonExtOn');
|
||||
this._enable = true;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
buildPanel: function () {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
buildPanel() {
|
||||
throw new Error('Method must be implemented');
|
||||
}.protect(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default ToolbarPaneItem;
|
||||
|
@ -15,24 +15,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
import ListToolbarPanel from './ListToolbarPanel';
|
||||
|
||||
const TopicShapePanel = new Class({
|
||||
Extends: ListToolbarPanel,
|
||||
initialize(buttonId, model) {
|
||||
this.parent(buttonId, model);
|
||||
},
|
||||
|
||||
class TopicShapePanel extends ListToolbarPanel {
|
||||
// eslint-disable-next-line class-methods-use-this
|
||||
buildPanel() {
|
||||
const content = $("<div class='toolbarPanel' id='topicShapePanel'></div>");
|
||||
content[0].innerHTML = ''
|
||||
+ '<div id="rectagle" model="rectagle"><img src="images/shape-rectangle.png" alt="Rectangle"></div>'
|
||||
+ '<div id="rounded_rectagle" model="rounded rectagle" ><img src="images/shape-rectangle-round.png" alt="Rounded Rectangle"></div>'
|
||||
+ '<div id="line" model="line"><img src="images/shape-line.png" alt="Line"></div>'
|
||||
+ '<div id="elipse" model="elipse"><img src="images/shape-circle.png"></div>';
|
||||
+ '<div id="rectagle" model="rectagle"><img src="images/shape-rectangle.png" alt="Rectangle"></div>'
|
||||
+ '<div id="rounded_rectagle" model="rounded rectagle" ><img src="images/shape-rectangle-round.png" alt="Rounded Rectangle"></div>'
|
||||
+ '<div id="line" model="line"><img src="images/shape-line.png" alt="Line"></div>'
|
||||
+ '<div id="elipse" model="elipse"><img src="images/shape-circle.png"></div>';
|
||||
|
||||
return content;
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default TopicShapePanel;
|
||||
|
@ -1,37 +0,0 @@
|
||||
import colorPalettePanel from './ColorPalettePanel';
|
||||
import floatingTip from './FloatingTip';
|
||||
import fontFamilyPanel from './FontFamilyPanel';
|
||||
import fontSizePanel from './FontSizePanel';
|
||||
import iconPanel from './IconPanel';
|
||||
import iMenu from './IMenu';
|
||||
import keyboardShortcutTooltip from './KeyboardShortcutTooltip';
|
||||
import linkEditor from './LinkEditor';
|
||||
import linkIconTooltip from './LinkIconTooltip';
|
||||
import listToolbarPanel from './ListToolbarPanel';
|
||||
import menu from './Menu';
|
||||
import modalDialogNotifier from './ModalDialogNotifier';
|
||||
import noteEditor from './NoteEditor';
|
||||
import toolbarItem from './ToolbarItem';
|
||||
import toolbarNotifier from './ToolbarNotifier';
|
||||
import toolbarPanelItem from './ToolbarPaneItem';
|
||||
import topicShapePanel from './TopicShapePanel';
|
||||
|
||||
export default {
|
||||
ColorPalettePanel: colorPalettePanel,
|
||||
FloatingTip: floatingTip,
|
||||
FontFamilyPanel: fontFamilyPanel,
|
||||
FontSizePanel: fontSizePanel,
|
||||
IconPanel: iconPanel,
|
||||
IMenu: iMenu,
|
||||
KeyboardShortcutTooltip: keyboardShortcutTooltip,
|
||||
LinkEditor: linkEditor,
|
||||
LinkIconTooltip: linkIconTooltip,
|
||||
ListToolbarPanel: listToolbarPanel,
|
||||
Menu: menu,
|
||||
ModalDialogNotifier: modalDialogNotifier,
|
||||
NoteEditor: noteEditor,
|
||||
ToolbarItem: toolbarItem,
|
||||
ToolbarNotifier: toolbarNotifier,
|
||||
ToolbarPaneItem: toolbarPanelItem,
|
||||
TopicShapePanel: topicShapePanel,
|
||||
};
|
13
packages/mindplot/src/index.js
Normal file
13
packages/mindplot/src/index.js
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import '@libraries/mootools-core-1.4.5';
|
||||
import _ from '@libraries/underscore-min';
|
||||
|
||||
import Mindmap from './components/model/Mindmap';
|
||||
import PersistenceManager from './components/PersistenceManager';
|
||||
import Designer from './components/Designer';
|
||||
import LocalStorageManager from './components/LocalStorageManager';
|
||||
import Menu from './components/widget/Menu';
|
||||
|
||||
export {
|
||||
Mindmap, PersistenceManager, Designer, LocalStorageManager, Menu,
|
||||
};
|
@ -1,6 +0,0 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import '@libraries/mootools-core-1.4.5';
|
||||
import _ from '@libraries/underscore-min';
|
||||
|
||||
import Mindmap from './components/model/Mindmap';
|
||||
import PersistenceManager from './components/PersistenceManager';
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import TestSuite from './TestSuite';
|
||||
import mindplot from '../../../src/mindplot';
|
||||
import LayoutManager from '../../../src/components/layout/LayoutManager';
|
||||
|
||||
const BalancedTestSuite = new Class({
|
||||
Extends: TestSuite,
|
||||
@ -33,7 +33,7 @@ const BalancedTestSuite = new Class({
|
||||
console.log('testBalanced:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const plotsize = { width: 1000, height: 200 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.connectNode(0, 1, 0);
|
||||
@ -181,7 +181,7 @@ const BalancedTestSuite = new Class({
|
||||
testBalancedPredict() {
|
||||
console.log('testBalancedPredict:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -215,7 +215,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1a.order == 0, 'Prediction order should be 0');
|
||||
@ -225,8 +225,8 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1b);
|
||||
$assert(
|
||||
prediction1b.position.y > manager.find(1).getPosition().y
|
||||
&& prediction1b.position.y < manager.find(3).getPosition().y
|
||||
&& prediction1b.position.x == manager.find(1).getPosition().x,
|
||||
&& prediction1b.position.y < manager.find(3).getPosition().y
|
||||
&& prediction1b.position.x == manager.find(1).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction1b.order == 2, 'Prediction order should be 2');
|
||||
@ -236,8 +236,8 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1c);
|
||||
$assert(
|
||||
prediction1c.position.y > manager.find(3).getPosition().y
|
||||
&& prediction1c.position.y < manager.find(5).getPosition().y
|
||||
&& prediction1c.position.x == manager.find(3).getPosition().x,
|
||||
&& prediction1c.position.y < manager.find(5).getPosition().y
|
||||
&& prediction1c.position.x == manager.find(3).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction1c.order == 4, 'Prediction order should be 4');
|
||||
@ -247,7 +247,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1d);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1d.order == 6, 'Prediction order should be 6');
|
||||
@ -260,7 +260,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction2a.order == 1, 'Prediction order should be 1');
|
||||
@ -270,8 +270,8 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2b);
|
||||
$assert(
|
||||
prediction2b.position.y > manager.find(2).getPosition().y
|
||||
&& prediction2b.position.y < manager.find(4).getPosition().y
|
||||
&& prediction2b.position.x == manager.find(2).getPosition().x,
|
||||
&& prediction2b.position.y < manager.find(4).getPosition().y
|
||||
&& prediction2b.position.x == manager.find(2).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction2b.order == 3, 'Prediction order should be 3');
|
||||
@ -281,7 +281,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2c);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction2c.order == 5, 'Prediction order should be 5');
|
||||
@ -293,7 +293,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction3.order == 5, 'Prediction order should be 5');
|
||||
@ -307,7 +307,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph4, prediction4);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction4.order == 6, 'Prediction order should be 6');
|
||||
@ -323,13 +323,13 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph5, prediction5b);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction5a.order == 0, 'Prediction order should be 0');
|
||||
$assert(
|
||||
prediction5a.position.x == prediction5b.position.x
|
||||
&& prediction5a.position.y == prediction5b.position.y,
|
||||
&& prediction5a.position.y == prediction5b.position.y,
|
||||
'Both predictions should be the same',
|
||||
);
|
||||
$assert(prediction5a.order == prediction5b.order, 'Both predictions should be the same');
|
||||
@ -340,7 +340,7 @@ const BalancedTestSuite = new Class({
|
||||
testBalancedNodeDragPredict() {
|
||||
console.log('testBalancedNodeDragPredict:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Graph 1
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
@ -351,7 +351,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
@ -363,7 +363,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1b);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
@ -375,7 +375,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1c);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1c.order == 1, 'Prediction order should be the same as node 1');
|
||||
@ -384,7 +384,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1d);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1d.order == 1, 'Prediction order should be the same as node 1');
|
||||
@ -399,7 +399,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction2a.order == 0, 'Prediction order should be 0');
|
||||
@ -408,7 +408,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2b);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction2b.order == 0, 'Prediction order should be 0');
|
||||
@ -417,7 +417,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2c);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
@ -429,7 +429,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2d);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
@ -448,7 +448,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction3a.order == 4, 'Prediction order should be 4');
|
||||
@ -457,8 +457,8 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3b);
|
||||
$assert(
|
||||
prediction3b.position.x == manager.find(1).getPosition().x
|
||||
&& prediction3b.position.y == manager.find(1).getPosition().y
|
||||
&& prediction3b.order == manager.find(1).getOrder(),
|
||||
&& prediction3b.position.y == manager.find(1).getPosition().y
|
||||
&& prediction3b.order == manager.find(1).getOrder(),
|
||||
'Prediction should be the exact same as dragged node',
|
||||
);
|
||||
|
||||
@ -466,7 +466,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3c);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction3c.order == 1, 'Prediction order should be 1');
|
||||
@ -475,7 +475,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3d);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction3d.order == 1, 'Prediction order should be 1');
|
||||
@ -484,7 +484,7 @@ const BalancedTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3e);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import TestSuite from './TestSuite';
|
||||
import mindplot from '../../../src/mindplot';
|
||||
import LayoutManager from '../../../src/components/layout/LayoutManager';
|
||||
|
||||
const FreeTestSuite = new Class({
|
||||
Extends: TestSuite,
|
||||
@ -37,7 +37,7 @@ const FreeTestSuite = new Class({
|
||||
testFreePosition() {
|
||||
console.log('testFreePosition:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
@ -104,7 +104,7 @@ const FreeTestSuite = new Class({
|
||||
this._assertFreePosition(manager, 11, { x: 250, y: -50 });
|
||||
$assert(
|
||||
manager.find(13).getPosition().x == node13Pos.x
|
||||
&& manager.find(13).getPosition().y == node13Pos.y,
|
||||
&& manager.find(13).getPosition().y == node13Pos.y,
|
||||
"Node 13 shouldn't have moved",
|
||||
);
|
||||
|
||||
@ -147,7 +147,7 @@ const FreeTestSuite = new Class({
|
||||
testFreePredict() {
|
||||
console.log('testFreePredict:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
@ -217,7 +217,7 @@ const FreeTestSuite = new Class({
|
||||
testReconnectFreeNode() {
|
||||
console.log('testReconnectFreeNode:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
@ -260,7 +260,7 @@ const FreeTestSuite = new Class({
|
||||
manager.plot('testReconnectFreeNode3', { width: 1000, height: 400 });
|
||||
$assert(
|
||||
manager.find(5).getPosition().y > manager.find(10).getPosition().y
|
||||
&& manager.find(5).getPosition().x == manager.find(10).getPosition().x,
|
||||
&& manager.find(5).getPosition().x == manager.find(10).getPosition().x,
|
||||
'Node 5 is incorrectly positioned',
|
||||
);
|
||||
$assert(manager.find(5).getOrder() == 2, 'Node 5 should have order 2');
|
||||
@ -278,7 +278,7 @@ const FreeTestSuite = new Class({
|
||||
manager.plot('testReconnectFreeNode5', { width: 1000, height: 400 });
|
||||
$assert(
|
||||
manager.find(5).getPosition().y == manager.find(10).getPosition().y
|
||||
&& manager.find(5).getPosition().x < manager.find(10).getPosition().x,
|
||||
&& manager.find(5).getPosition().x < manager.find(10).getPosition().x,
|
||||
'Node 5 is incorrectly positioned',
|
||||
);
|
||||
$assert(manager.find(5).getOrder() == 0, 'Node 5 should have order 0');
|
||||
@ -290,7 +290,7 @@ const FreeTestSuite = new Class({
|
||||
manager.plot('testReconnectFreeNode6', { width: 1000, height: 400 });
|
||||
$assert(
|
||||
manager.find(5).getPosition().y > manager.find(6).getPosition().y
|
||||
&& manager.find(5).getPosition().x == manager.find(6).getPosition().x,
|
||||
&& manager.find(5).getPosition().x == manager.find(6).getPosition().x,
|
||||
'Node 5 is incorrectly positioned',
|
||||
);
|
||||
$assert(manager.find(5).getOrder() == 2, 'Node 5 should have order 2');
|
||||
@ -307,7 +307,7 @@ const FreeTestSuite = new Class({
|
||||
testSiblingOverlapping() {
|
||||
console.log('testSiblingOverlapping:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
@ -340,7 +340,7 @@ const FreeTestSuite = new Class({
|
||||
testRootNodeChildrenPositioning() {
|
||||
console.log('testRootNodeChildrenPositioning:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
@ -383,7 +383,7 @@ const FreeTestSuite = new Class({
|
||||
testBalancedFreePredict() {
|
||||
console.log('testBalancedFreePredict:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
@ -403,7 +403,7 @@ const FreeTestSuite = new Class({
|
||||
testFreeReorder() {
|
||||
console.log('testFreeReorder:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
@ -440,7 +440,7 @@ const FreeTestSuite = new Class({
|
||||
testFreeOverlap() {
|
||||
console.log('testFreeOverlap:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
@ -481,18 +481,13 @@ const FreeTestSuite = new Class({
|
||||
const node = manager.find(id);
|
||||
$assert(
|
||||
node.getPosition().x == position.x && node.getPosition().y == position.y,
|
||||
`Freely moved node ${
|
||||
id
|
||||
} is not left at free position (${
|
||||
position.x
|
||||
},${
|
||||
position.y
|
||||
`Freely moved node ${id
|
||||
} is not left at free position (${position.x
|
||||
},${position.y
|
||||
}). `
|
||||
+ `Actual position: (${
|
||||
node.getPosition().x
|
||||
},${
|
||||
node.getPosition().y
|
||||
})`,
|
||||
+ `Actual position: (${node.getPosition().x
|
||||
},${node.getPosition().y
|
||||
})`,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import TestSuite from './TestSuite';
|
||||
import mindplot from '../../../src/mindplot';
|
||||
import LayoutManager from '../../../src/components/layout/LayoutManager';
|
||||
|
||||
const SymmetricTestSuite = new Class({
|
||||
Extends: TestSuite,
|
||||
@ -32,7 +32,7 @@ const SymmetricTestSuite = new Class({
|
||||
testSymmetry() {
|
||||
console.log('testSymmetry:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -68,26 +68,26 @@ const SymmetricTestSuite = new Class({
|
||||
|
||||
// All nodes should be positioned symmetrically with respect to their common ancestors
|
||||
$assert(
|
||||
manager.find(14).getPosition().y == manager.find(13).getPosition().y,
|
||||
manager.find(14).getPosition().y === manager.find(13).getPosition().y,
|
||||
'Symmetry is not respected',
|
||||
);
|
||||
$assert(
|
||||
manager.find(5).getPosition().y == manager.find(10).getPosition().y,
|
||||
manager.find(5).getPosition().y === manager.find(10).getPosition().y,
|
||||
'Symmetry is not respected',
|
||||
);
|
||||
$assert(
|
||||
manager.find(11).getPosition().y - manager.find(6).getPosition().y
|
||||
== -(manager.find(12).getPosition().y - manager.find(6).getPosition().y),
|
||||
=== -(manager.find(12).getPosition().y - manager.find(6).getPosition().y),
|
||||
'Symmetry is not respected',
|
||||
);
|
||||
$assert(
|
||||
manager.find(8).getPosition().y - manager.find(1).getPosition().y
|
||||
== -(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
|
||||
== -(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
|
||||
'Symmetry is not respected',
|
||||
);
|
||||
$assert(
|
||||
manager.find(9).getPosition().y - manager.find(1).getPosition().y
|
||||
== -(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
|
||||
== -(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
|
||||
'Symmetry is not respected',
|
||||
);
|
||||
|
||||
@ -97,7 +97,7 @@ const SymmetricTestSuite = new Class({
|
||||
testSymmetricPredict() {
|
||||
console.log('testSymmetricPredict:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
@ -134,7 +134,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1a.order == 0, 'Prediction order should be 0');
|
||||
@ -144,7 +144,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1b);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1b.order == 0, 'Prediction order should be 0');
|
||||
@ -159,7 +159,7 @@ const SymmetricTestSuite = new Class({
|
||||
// Prediction calculator error
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction2d.order == 0, 'Prediction order should be 0');
|
||||
@ -170,8 +170,8 @@ const SymmetricTestSuite = new Class({
|
||||
|
||||
$assert(
|
||||
prediction2a.position.y > manager.find(7).getPosition().y
|
||||
&& prediction2a.position.y < manager.find(8).getPosition().y
|
||||
&& prediction2a.position.x == manager.find(7).getPosition().x,
|
||||
&& prediction2a.position.y < manager.find(8).getPosition().y
|
||||
&& prediction2a.position.x == manager.find(7).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction2a.order == 1, 'Prediction order should be 1');
|
||||
@ -181,8 +181,8 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2b);
|
||||
$assert(
|
||||
prediction2b.position.y > manager.find(8).getPosition().y
|
||||
&& prediction2b.position.y < manager.find(11).getPosition().y
|
||||
&& prediction2b.position.x == manager.find(7).getPosition().x,
|
||||
&& prediction2b.position.y < manager.find(11).getPosition().y
|
||||
&& prediction2b.position.x == manager.find(7).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction2b.order == 2, 'Prediction order should be 2');
|
||||
@ -192,7 +192,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph2, prediction2c);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction2c.order == 3, 'Prediction order should be 3');
|
||||
@ -205,8 +205,8 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3a);
|
||||
$assert(
|
||||
prediction3a.position.y > manager.find(5).getPosition().y
|
||||
&& prediction3a.position.y < manager.find(6).getPosition().y
|
||||
&& prediction3a.position.x == manager.find(5).getPosition().x,
|
||||
&& prediction3a.position.y < manager.find(6).getPosition().y
|
||||
&& prediction3a.position.x == manager.find(5).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction3a.order == 2, 'Prediction order should be 2');
|
||||
@ -216,7 +216,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph3, prediction3b);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction3b.order == 3, 'Prediction order should be 3');
|
||||
@ -228,8 +228,8 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph4, prediction4);
|
||||
$assert(
|
||||
prediction4.position.y > manager.find(9).getPosition().y
|
||||
&& prediction4.position.y < manager.find(10).getPosition().y
|
||||
&& prediction4.position.x == manager.find(9).getPosition().x,
|
||||
&& prediction4.position.y < manager.find(10).getPosition().y
|
||||
&& prediction4.position.x == manager.find(9).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction4.order == 1, 'Prediction order should be 1');
|
||||
@ -241,7 +241,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph5, prediction5a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction5a.order == 0, 'Prediction order should be 0');
|
||||
@ -250,8 +250,8 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph5, prediction5b);
|
||||
$assert(
|
||||
prediction5b.position.y > manager.find(10).getPosition().y
|
||||
&& prediction5b.position.x < manager.find(2).getPosition().x
|
||||
&& prediction5b.position.x == manager.find(10).getPosition().x,
|
||||
&& prediction5b.position.x < manager.find(2).getPosition().x
|
||||
&& prediction5b.position.x == manager.find(10).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction5b.order == 2, 'Prediction order should be 2');
|
||||
@ -260,8 +260,8 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph5, prediction5c);
|
||||
$assert(
|
||||
prediction5c.position.y > manager.find(6).getPosition().y
|
||||
&& prediction5c.position.x > manager.find(3).getPosition().x
|
||||
&& prediction5c.position.x == manager.find(6).getPosition().x,
|
||||
&& prediction5c.position.x > manager.find(3).getPosition().x
|
||||
&& prediction5c.position.x == manager.find(6).getPosition().x,
|
||||
'Prediction is incorrectly positioned',
|
||||
);
|
||||
$assert(prediction5c.order == 3, 'Prediction order should be 3');
|
||||
@ -270,7 +270,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph5, prediction5d);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction5d.order == 0, 'Prediction order should be 0');
|
||||
@ -281,7 +281,7 @@ const SymmetricTestSuite = new Class({
|
||||
testSymmetricDragPredict() {
|
||||
console.log('testSymmetricDragPredict:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 1);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
||||
@ -294,7 +294,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1a);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
@ -306,7 +306,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1b);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
@ -318,7 +318,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1c);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1c.order == 1, 'Prediction order should be 1');
|
||||
@ -327,7 +327,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1d);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(prediction1d.order == 3, 'Prediction order should be 3');
|
||||
@ -336,7 +336,7 @@ const SymmetricTestSuite = new Class({
|
||||
this._plotPrediction(graph1, prediction1e);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
$assert(
|
||||
|
@ -15,10 +15,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import mindplot from '../../../src/mindplot';
|
||||
import LayoutManager from '../../../src/components/layout/LayoutManager';
|
||||
|
||||
const TestSuite = new Class({
|
||||
Extends: mindplot.layout.ChildrenSorterStrategy,
|
||||
Extends: ChildrenSorterStrategy,
|
||||
|
||||
initialize() {
|
||||
$('#basicTest').css('display', 'block');
|
||||
@ -37,7 +37,7 @@ const TestSuite = new Class({
|
||||
testAligned() {
|
||||
console.log('testAligned:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
||||
@ -84,7 +84,7 @@ const TestSuite = new Class({
|
||||
testBaselineAligned1() {
|
||||
console.log('testBaselineAligned1:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 0);
|
||||
@ -130,7 +130,7 @@ const TestSuite = new Class({
|
||||
testBaselineAligned2() {
|
||||
console.log('testBaselineAligned2:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
manager.addNode(2, { width: 130, height: 200 }, position).connectNode(1, 2, 0);
|
||||
@ -148,7 +148,7 @@ const TestSuite = new Class({
|
||||
testEvents() {
|
||||
console.log('testEvents:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -161,14 +161,10 @@ const TestSuite = new Class({
|
||||
const events = [];
|
||||
manager.addEvent('change', (event) => {
|
||||
console.log(
|
||||
`\tUpdated nodes: {id:${
|
||||
event.getId()
|
||||
}, order: ${
|
||||
event.getOrder()
|
||||
},position: {${
|
||||
event.getPosition().x
|
||||
},${
|
||||
event.getPosition().y
|
||||
`\tUpdated nodes: {id:${event.getId()
|
||||
}, order: ${event.getOrder()
|
||||
},position: {${event.getPosition().x
|
||||
},${event.getPosition().y
|
||||
}}`,
|
||||
);
|
||||
events.push(event);
|
||||
@ -190,7 +186,7 @@ const TestSuite = new Class({
|
||||
testEventsComplex() {
|
||||
console.log('testEventsComplex:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -207,14 +203,10 @@ const TestSuite = new Class({
|
||||
const events = [];
|
||||
manager.addEvent('change', (event) => {
|
||||
console.log(
|
||||
`\tUpdated nodes: {id:${
|
||||
event.getId()
|
||||
}, order: ${
|
||||
event.getOrder()
|
||||
},position: {${
|
||||
event.getPosition().x
|
||||
},${
|
||||
event.getPosition().y
|
||||
`\tUpdated nodes: {id:${event.getId()
|
||||
}, order: ${event.getOrder()
|
||||
},position: {${event.getPosition().x
|
||||
},${event.getPosition().y
|
||||
}}`,
|
||||
);
|
||||
events.push(event);
|
||||
@ -242,7 +234,7 @@ const TestSuite = new Class({
|
||||
testDisconnect() {
|
||||
console.log('testDisconnect:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -265,10 +257,8 @@ const TestSuite = new Class({
|
||||
const posStr = pos ? `,position: {${pos.x},${pos.y}` : '';
|
||||
const node = manager.find(event.getId());
|
||||
console.log(
|
||||
`\tUpdated nodes: {id:${
|
||||
event.getId()
|
||||
}, order: ${
|
||||
event.getOrder()
|
||||
`\tUpdated nodes: {id:${event.getId()
|
||||
}, order: ${event.getOrder()
|
||||
}${posStr
|
||||
}}`,
|
||||
);
|
||||
@ -305,7 +295,7 @@ const TestSuite = new Class({
|
||||
testReconnect() {
|
||||
console.log('testReconnect:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -357,7 +347,7 @@ const TestSuite = new Class({
|
||||
);
|
||||
$assert(
|
||||
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',
|
||||
);
|
||||
|
||||
@ -367,7 +357,7 @@ const TestSuite = new Class({
|
||||
testRemoveNode() {
|
||||
console.log('testRemoveNode:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
@ -437,7 +427,7 @@ const TestSuite = new Class({
|
||||
testSize() {
|
||||
console.log('testSize:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, { width: 60, height: 60 }, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -479,7 +469,7 @@ const TestSuite = new Class({
|
||||
// Check that all enlarged nodes shift children accordingly
|
||||
$assert(
|
||||
manager.find(10).getPosition().x > manager.find(3).getPosition().x
|
||||
&& manager.find(10).getPosition().x == manager.find(11).getPosition().x,
|
||||
&& manager.find(10).getPosition().x == manager.find(11).getPosition().x,
|
||||
'Nodes 10 and 11 should be horizontally algined and to the right of enlarged node 3',
|
||||
);
|
||||
const xPosNode7 = manager.find(7).getPosition().x;
|
||||
@ -534,7 +524,7 @@ const TestSuite = new Class({
|
||||
testReconnectSingleNode() {
|
||||
console.log('testReconnectSingleNode:');
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
// Prepare a sample graph ...
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
@ -565,19 +555,16 @@ const TestSuite = new Class({
|
||||
},
|
||||
|
||||
_plotPrediction(canvas, prediction) {
|
||||
if(!canvas) {
|
||||
if (!canvas) {
|
||||
console.warn('no canvas in _plotPrediction. Remove this method if plot() not in use');
|
||||
return;
|
||||
}
|
||||
const { position } = prediction;
|
||||
const { order } = prediction;
|
||||
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;
|
||||
@ -587,6 +574,6 @@ const TestSuite = new Class({
|
||||
});
|
||||
|
||||
(TestSuite.NODE_SIZE = { width: 80, height: 30 }),
|
||||
(TestSuite.ROOT_NODE_SIZE = { width: 120, height: 40 });
|
||||
(TestSuite.ROOT_NODE_SIZE = { width: 120, height: 40 });
|
||||
|
||||
export default TestSuite;
|
||||
|
@ -1,23 +1,21 @@
|
||||
BootstrapDialog.Request = new Class({
|
||||
|
||||
Extends: BootstrapDialog,
|
||||
|
||||
initialize: function(url, title, options) {
|
||||
initialize: function (url, title, options) {
|
||||
this.parent(title, options);
|
||||
this.requestOptions = {};
|
||||
this.requestOptions.cache = false;
|
||||
var me = this;
|
||||
this.requestOptions.fail = function(xhr) {
|
||||
this.requestOptions.fail = function (xhr) {
|
||||
// Intercept form requests ...
|
||||
console.log("Failure:");
|
||||
console.log(xhr);
|
||||
};
|
||||
|
||||
this.requestOptions.success = function() {
|
||||
this.requestOptions.success = function () {
|
||||
// Intercept form requests ...
|
||||
var forms = me._native.find('form');
|
||||
_.each(forms, function(form) {
|
||||
$(form).on('submit', function(event) {
|
||||
_.each(forms, function (form) {
|
||||
$(form).on('submit', function (event) {
|
||||
// Intercept form ...
|
||||
me.requestOptions.url = form.action;
|
||||
me.requestOptions.method = form.method ? form.method : 'post';
|
||||
@ -39,8 +37,8 @@ BootstrapDialog.Request = new Class({
|
||||
});
|
||||
},
|
||||
|
||||
onDialogShown: function() {
|
||||
if (typeof(onDialogShown) == "function") {
|
||||
onDialogShown: function () {
|
||||
if (typeof (onDialogShown) == "function") {
|
||||
onDialogShown();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -16,9 +16,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import Mindmap from '../../../../src/components/model/Mindmap';
|
||||
import PersistenceManager from '../../../../src/components/PersistenceManager';
|
||||
import $ from '@libraries/jquery-2.1.0'
|
||||
import { Mindmap, PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/';
|
||||
|
||||
import $ from '@libraries/jquery-2.1.0';
|
||||
global.jQuery = $;
|
||||
|
||||
let designer = null;
|
||||
|
||||
@ -48,7 +49,7 @@ function buildDesigner(options) {
|
||||
$assert(container, 'container could not be null');
|
||||
|
||||
// Register load events ...
|
||||
designer = new mindplot.Designer(options, container);
|
||||
designer = new Designer(options, container);
|
||||
designer.addEvent('loadSuccess', () => {
|
||||
window.waitDialog.close();
|
||||
window.waitDialog = null;
|
||||
@ -109,13 +110,13 @@ function buildDesigner(options) {
|
||||
persistence = options.persistenceManager;
|
||||
}
|
||||
} else {
|
||||
persistence = new mindplot.LocalStorageManager('samples/{id}.xml');
|
||||
persistence = new LocalStorageManager('samples/{id}.xml');
|
||||
}
|
||||
mindplot.PersistenceManager.init(persistence);
|
||||
PersistenceManager.init(persistence);
|
||||
|
||||
// Register toolbar event ...
|
||||
if ($('#toolbar')) {
|
||||
const menu = new mindplot.widget.Menu(designer, 'toolbar', options.mapId, '');
|
||||
const menu = new Menu(designer, 'toolbar', options.mapId, '');
|
||||
|
||||
// If a node has focus, focus can be move to another node using the keys.
|
||||
designer._cleanScreen = function () {
|
||||
@ -193,7 +194,7 @@ global.editor.WaitDialog = new Class({
|
||||
|
||||
// Show loading dialog ...
|
||||
$(() => {
|
||||
import('./bootstrap').then(() => {
|
||||
import('../../../../../../libraries/bootstrap').then(() => {
|
||||
global.waitDialog = new global.editor.WaitDialog();
|
||||
global.waitDialog.show();
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import LayoutManager from '../../../src/components/layout/LayoutManager';
|
||||
|
||||
describe('Balanced Test Suite', () => {
|
||||
it('balancedTest', () => {
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.connectNode(0, 1, 0);
|
||||
manager.layout();
|
||||
@ -96,7 +98,7 @@ describe('Balanced Test Suite', () => {
|
||||
|
||||
it('balancedPredictTest', () => {
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||
@ -198,7 +200,7 @@ describe('Balanced Test Suite', () => {
|
||||
|
||||
it('balancedNodeDragPredictTest', () => {
|
||||
const position = { x: 0, y: 0 };
|
||||
const manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||
|
||||
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||
manager.layout();
|
||||
|
@ -3,7 +3,6 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
|
||||
/** @type {import('webpack').Configuration} */
|
||||
module.exports = {
|
||||
entry: './src/mindplot',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: '[name].js',
|
||||
@ -29,14 +28,6 @@ module.exports = {
|
||||
resolve: {
|
||||
alias: {
|
||||
'@libraries': path.resolve(__dirname, '../../libraries/'),
|
||||
'@commands': path.resolve(__dirname, './src/components/commands/'),
|
||||
'@layout': path.resolve(__dirname, './src/components/layout/'),
|
||||
'@libs': path.resolve(__dirname, './src/components/libraries/'),
|
||||
'@model': path.resolve(__dirname, './src/components/model'),
|
||||
'@persistence': path.resolve(__dirname, './src/components/persistence/'),
|
||||
'@util': path.resolve(__dirname, './src/components/util/'),
|
||||
'@widget': path.resolve(__dirname, './src/components/widget/'),
|
||||
'@components': path.resolve(__dirname, './src/components/'),
|
||||
},
|
||||
extensions: ['.js', '.json'],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user